-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: run dist-tag after changeset publish to set latest tag on npm (#…
…2199) Changeset doesn't allow custom tags with prereleases 🤷 changesets/changesets#546
- Loading branch information
1 parent
e3be748
commit 712241a
Showing
4 changed files
with
50 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { glob } from "glob" | ||
import { readFileSync } from "fs" | ||
import { execSync } from "child_process" | ||
|
||
async function tagLatest() { | ||
// Find all package.json files in the packages directory | ||
const packageFiles = glob.sync("./packages/*/package.json") | ||
|
||
for (const file of packageFiles) { | ||
const pkg = JSON.parse(readFileSync(file)) | ||
const { name, version, private: isPrivate } = pkg | ||
|
||
if (!name || !version || isPrivate) continue | ||
|
||
console.log(`Tagging ${name}@${version} as latest`) | ||
try { | ||
execSync(`npm dist-tag add ${name}@${version} latest`, { | ||
stdio: "inherit", | ||
env: { ...process.env }, | ||
}) | ||
} catch (e) { | ||
console.error(`Failed to tag ${name}@${version}:`, e) | ||
process.exit(1) | ||
} | ||
} | ||
} | ||
|
||
tagLatest().catch((e) => { | ||
console.error(e) | ||
process.exit(1) | ||
}) |