Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Force version bump in
prerelease
(#750)
- Loading branch information
Showing
7 changed files
with
117 additions
and
55 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
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,68 @@ | ||
const { promises: fs } = require('fs'); | ||
const { getAllDependencies, baseDir, readChangesetState, formatFiles, rm } = require('./helpers'); | ||
const writeJson = require('write-json-file'); | ||
|
||
const [, , ...args] = process.argv; | ||
const clean = args.includes('--clean'); | ||
|
||
const FORCED_FILE_NAME = 'pre-forced-update'; | ||
const FORCED_FILE_PATH = baseDir('.changeset', `${FORCED_FILE_NAME}.md`); | ||
const PRE_FILE_PATH = baseDir('.changeset', 'pre.json'); | ||
|
||
/** @typedef {import('@manypkg/get-packages').Package['packageJson']} PackageJSON */ | ||
|
||
/** | ||
* @param {PackageJSON[]} packages | ||
* @returns {Promise<void>} | ||
*/ | ||
async function createForcedUpdateFile(packages) { | ||
const frontMatter = packages.map((pkg) => `'${pkg.name}': patch`); | ||
const fileContents = `--- | ||
${frontMatter.join('\n')} | ||
--- | ||
Forced update in pre-release mode.`; | ||
|
||
await fs.writeFile(FORCED_FILE_PATH, fileContents); | ||
} | ||
|
||
async function run() { | ||
const { changesets, preState } = await readChangesetState(); | ||
|
||
if (!preState) { | ||
return; | ||
} | ||
|
||
if (clean) { | ||
await rm(FORCED_FILE_PATH); | ||
await writeJson(PRE_FILE_PATH, { | ||
...preState, | ||
changesets: preState.changesets.filter((name) => name !== FORCED_FILE_NAME), | ||
}); | ||
|
||
await formatFiles(PRE_FILE_PATH); | ||
return; | ||
} | ||
|
||
/** @type {Set<string>} */ | ||
const includedNames = new Set(); | ||
|
||
for (const changeset of changesets) { | ||
changeset.releases.forEach((release) => { | ||
includedNames.add(release.name); | ||
}); | ||
} | ||
|
||
const packages = (await getAllDependencies()).filter( | ||
(pkg) => !pkg.private && !includedNames.has(pkg.name), | ||
); | ||
|
||
if (packages.length === 0) { | ||
return; | ||
} | ||
|
||
await createForcedUpdateFile(packages); | ||
await formatFiles(FORCED_FILE_PATH); | ||
} | ||
|
||
run(); |
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
This file was deleted.
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
de6a430
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://remirror.io as production
🚀 Deployed on https://5f818d62d1e6204ee2c0c2f2--remirror.netlify.app