Skip to content

Commit

Permalink
ci: add script for fixing changesets after stable release (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
martines3000 authored Oct 9, 2023
1 parent 1e45cac commit 0b8d7f4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions scripts/changesets/fix-after-stable-release.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import fs from 'node:fs';

// Read files inside the `.changeset` directory
const files = fs.readdirSync('.changeset');

// Filter out files that don't end with `.md` extension
const changesets = files.filter(
(file) => file.endsWith('.md') && file !== 'README.md'
);

// Read the contents of pre.json in the `.changeset` directory
const preJson = fs.readFileSync('.changeset/pre.json', 'utf-8');

// Parse the contents of pre.json into a JavaScript object
const pre = JSON.parse(preJson);

// Write changeset file names (without file extension) to the `changesets` key
pre.changesets = changesets.map((changeset) => changeset.replace('.md', ''));

// Write the updated pre.json back to the `.changeset` directory
fs.writeFileSync('.changeset/pre.json', JSON.stringify(pre, null, 2));
1 change: 1 addition & 0 deletions scripts/changesets/publish-stable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pnpm install --frozen-lockfile && \
pnpm build && \
pnpm changeset publish && \
pnpm changeset pre enter beta && \
node scripts/changesets/fix-after-stable-release.mjs && \
git add . && \
git commit -m "chore: release stable and enter beta mode" && \
git push --follow-tags && \
Expand Down
2 changes: 1 addition & 1 deletion scripts/changesets/update-snap-version.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';
import fs from 'node:fs';
import { execa } from 'execa';

// Read packages/snap/package.json
Expand Down

0 comments on commit 0b8d7f4

Please sign in to comment.