-
Notifications
You must be signed in to change notification settings - Fork 461
Expand file tree
/
Copy pathsnapshot.mjs
More file actions
executable file
·58 lines (45 loc) · 1.64 KB
/
Copy pathsnapshot.mjs
File metadata and controls
executable file
·58 lines (45 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env zx
import { $, argv, echo } from 'zx';
import {
constants,
getChangesetIgnoredPackages,
getPackageNames,
isElectronPasskeysPackage,
pinWorkspaceDeps,
} from './common.mjs';
const ignoredPackages = await getChangesetIgnoredPackages();
const packageNames = (await getPackageNames()).filter(
name => !ignoredPackages.has(name) && !isElectronPasskeysPackage(name),
);
const packageEntries = packageNames.map(name => `'${name}': patch`).join('\n');
const snapshot = `---
${packageEntries}
---
Snapshot release
`;
const prefix = argv.name || argv._[0] || 'snapshot';
await $`pnpm dlx json -I -f ${constants.ChangesetConfigFile} -e "this.changelog = false"`;
try {
// exit pre-release mode if we're in it
await $`pnpm changeset pre exit`;
// bump the version of all affected packages
// this will remove the prerelease versions
// but will also clear the changeset .md files
await $`pnpm changeset version`;
} catch {
// not in pre-release mode, continue
}
// Always generate a temp .md file that indicates that all packages have changes
// in order to force a snapshot release of all packages
await $`touch .changeset/snap.md && echo ${snapshot} > .changeset/snap.md`;
// Convert workspace:^ to workspace:* for @clerk/* deps to ensure exact versions
// This prevents semver range issues like ^3.0.0-snapshot matching older versions
await pinWorkspaceDeps();
const res = await $`pnpm changeset version --snapshot ${prefix}`;
const success = !res.stderr.includes('No unreleased changesets found');
await $`git checkout HEAD -- ${constants.ChangesetConfigFile}`;
if (success) {
echo('success=1');
} else {
echo('success=0');
}