@smoothbricks/cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +27 -23
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +19 -3
  4. package/dist/generate/index.d.ts +20 -0
  5. package/dist/generate/index.d.ts.map +1 -0
  6. package/dist/generate/index.js +47 -0
  7. package/dist/lib/run.d.ts +1 -0
  8. package/dist/lib/run.d.ts.map +1 -1
  9. package/dist/lib/run.js +19 -0
  10. package/dist/lib/workspace.d.ts +10 -0
  11. package/dist/lib/workspace.d.ts.map +1 -1
  12. package/dist/lib/workspace.js +55 -16
  13. package/dist/monorepo/lockfile.d.ts.map +1 -1
  14. package/dist/monorepo/lockfile.js +9 -0
  15. package/dist/monorepo/package-policy.d.ts +6 -17
  16. package/dist/monorepo/package-policy.d.ts.map +1 -1
  17. package/dist/monorepo/package-policy.js +63 -1127
  18. package/dist/monorepo/publish-workflow.js +2 -3
  19. package/dist/nx/index.d.ts +1 -0
  20. package/dist/nx/index.d.ts.map +1 -1
  21. package/dist/nx/index.js +23 -5
  22. package/dist/release/candidates.js +1 -1
  23. package/dist/release/core.d.ts +3 -1
  24. package/dist/release/core.d.ts.map +1 -1
  25. package/dist/release/core.js +76 -9
  26. package/dist/release/github-release.d.ts +1 -0
  27. package/dist/release/github-release.d.ts.map +1 -1
  28. package/dist/release/github-release.js +1 -1
  29. package/dist/release/index.d.ts +9 -3
  30. package/dist/release/index.d.ts.map +1 -1
  31. package/dist/release/index.js +265 -39
  32. package/dist/release/orchestration.d.ts +10 -2
  33. package/dist/release/orchestration.d.ts.map +1 -1
  34. package/dist/release/orchestration.js +33 -3
  35. package/managed/templates/github/workflows/ci.yml +3 -2
  36. package/package.json +7 -12
  37. package/src/cli.ts +21 -4
  38. package/src/generate/index.ts +92 -0
  39. package/src/lib/run.ts +25 -0
  40. package/src/lib/workspace.ts +72 -16
  41. package/src/monorepo/lockfile.ts +9 -0
  42. package/src/monorepo/package-policy.test.ts +250 -22
  43. package/src/monorepo/package-policy.ts +88 -1351
  44. package/src/monorepo/publish-workflow.ts +2 -3
  45. package/src/nx/index.test.ts +9 -0
  46. package/src/nx/index.ts +25 -5
  47. package/src/release/__tests__/candidates.test.ts +53 -8
  48. package/src/release/__tests__/core-properties.test.ts +2 -2
  49. package/src/release/__tests__/core-scenarios.test.ts +12 -15
  50. package/src/release/__tests__/core.test.ts +50 -3
  51. package/src/release/__tests__/fixture-repo.test.ts +68 -18
  52. package/src/release/__tests__/github-release.test.ts +9 -16
  53. package/src/release/__tests__/orchestration.test.ts +91 -5
  54. package/src/release/__tests__/retag-unpublished.test.ts +9 -9
  55. package/src/release/__tests__/trust-publisher.test.ts +65 -33
  56. package/src/release/candidates.ts +1 -1
  57. package/src/release/core.ts +95 -10
  58. package/src/release/github-release.ts +1 -1
  59. package/src/release/index.ts +343 -49
  60. package/src/release/orchestration.ts +50 -5
  61. package/dist/nx-version-actions.cjs +0 -25
  62. package/dist/nx-version-actions.d.cts +0 -6
  63. package/dist/nx-version-actions.d.cts.map +0 -1
  64. package/src/nx-version-actions.cts +0 -36
@@ -11,6 +11,7 @@ export interface ReleaseSummary<Package extends ReleasePackageInfo = ReleasePack
11
11
  published: Package[];
12
12
  alreadyPublished: Package[];
13
13
  githubReleases: Package[];
14
+ githubReleaseLinks: Array<{ pkg: Package; url: string }>;
14
15
  rerunRequired: boolean;
15
16
  noRelease: boolean;
16
17
  }
@@ -22,7 +23,11 @@ export interface ReleaseCompletionShell<Package extends ReleasePackageInfo = Rel
22
23
  buildReleaseCandidate(packages: Package[]): Promise<void>;
23
24
  publishPackage(pkg: Package, distTag: string, dryRun: boolean): Promise<void>;
24
25
  listGithubMissingPackages(packages: Package[]): Promise<Package[]>;
25
- createGithubRelease(pkg: Package, dryRun: boolean): Promise<void>;
26
+ createGithubRelease(pkg: Package, dryRun: boolean): Promise<string | null>;
27
+ }
28
+
29
+ export interface ReleaseNextShell<Package extends ReleasePackageInfo = ReleasePackageInfo> {
30
+ bumpStablePackagesToNext(packages: Package[]): Promise<void>;
26
31
  }
27
32
 
28
33
  export interface ReleaseRepairShell<Package extends ReleasePackageInfo = ReleasePackageInfo>
@@ -38,7 +43,7 @@ export interface ReleaseVersionShell<Package extends ReleasePackageInfo = Releas
38
43
  releaseVersionPackages(bump: string): Promise<Package[]>;
39
44
  ensureLocalReleaseTags(packages: Package[]): Promise<void>;
40
45
  gitHead(): Promise<string>;
41
- runNxReleaseVersion(packages: Package[], bump: string, dryRun: boolean): Promise<void>;
46
+ runNxReleaseVersion(packages: Package[], bump: string, dryRun: boolean): Promise<Package[]>;
42
47
  assertCleanGitTree(): Promise<void>;
43
48
  }
44
49
 
@@ -70,9 +75,9 @@ export async function runReleaseVersion<Package extends ReleasePackageInfo>(
70
75
  }
71
76
 
72
77
  const headBeforeVersioning = await shell.gitHead();
73
- await shell.runNxReleaseVersion(versionPackages, options.bump, options.dryRun);
78
+ const dryRunPackages = await shell.runNxReleaseVersion(versionPackages, options.bump, options.dryRun);
74
79
  if (options.dryRun) {
75
- return { mode: 'none', packages: [], status: 'dry-run' };
80
+ return { mode: 'none', packages: dryRunPackages, status: 'dry-run' };
76
81
  }
77
82
 
78
83
  await shell.assertCleanGitTree();
@@ -113,12 +118,30 @@ export async function completeReleaseAtHead<Package extends ReleasePackageInfo>(
113
118
  });
114
119
  }
115
120
 
121
+ export async function bumpStableReleaseToNext<Package extends ReleasePackageInfo>(
122
+ shell: ReleaseNextShell<Package>,
123
+ packages: Package[],
124
+ dryRun: boolean,
125
+ rerunRequired: boolean,
126
+ ): Promise<Package[]> {
127
+ const stablePackages = packages.filter((pkg) => !pkg.version.includes('-'));
128
+ if (dryRun || rerunRequired || stablePackages.length === 0) {
129
+ return [];
130
+ }
131
+ await shell.bumpStablePackagesToNext(stablePackages);
132
+ return stablePackages;
133
+ }
134
+
116
135
  export async function repairPendingTargets<Package extends ReleasePackageInfo>(
117
136
  shell: ReleaseRepairShell<Package>,
118
137
  targets: Array<ReleaseTarget<Package>>,
119
138
  restoreRef: string,
120
139
  dryRun: boolean,
121
140
  ): Promise<Array<ReleaseSummary<Package>>> {
141
+ if (dryRun) {
142
+ return targets.map((target) => repairDryRunSummary(target));
143
+ }
144
+
122
145
  const summaries: Array<ReleaseSummary<Package>> = [];
123
146
  try {
124
147
  for (const target of targets) {
@@ -139,6 +162,23 @@ export async function repairPendingTargets<Package extends ReleasePackageInfo>(
139
162
  return summaries;
140
163
  }
141
164
 
165
+ function repairDryRunSummary<Package extends ReleasePackageInfo>(
166
+ target: ReleaseTarget<Package>,
167
+ ): ReleaseSummary<Package> {
168
+ return {
169
+ sha: target.sha,
170
+ dryRun: true,
171
+ packages: target.packages,
172
+ pushed: false,
173
+ published: [],
174
+ alreadyPublished: target.packages.filter((pkg) => !target.npmPackages.includes(pkg)),
175
+ githubReleases: [],
176
+ githubReleaseLinks: [],
177
+ rerunRequired: false,
178
+ noRelease: false,
179
+ };
180
+ }
181
+
142
182
  export async function completeRepairTargetAtHead<Package extends ReleasePackageInfo>(
143
183
  shell: ReleaseCompletionShell<Package>,
144
184
  target: ReleaseTarget<Package>,
@@ -178,8 +218,12 @@ async function completePlannedRelease<Package extends ReleasePackageInfo>(
178
218
  for (const { pkg, distTag } of plan.publishPackages) {
179
219
  await shell.publishPackage(pkg, distTag, input.dryRun);
180
220
  }
221
+ const githubReleaseLinks: Array<{ pkg: Package; url: string }> = [];
181
222
  for (const pkg of plan.githubReleasePackages) {
182
- await shell.createGithubRelease(pkg, input.dryRun);
223
+ const url = await shell.createGithubRelease(pkg, input.dryRun);
224
+ if (url) {
225
+ githubReleaseLinks.push({ pkg, url });
226
+ }
183
227
  }
184
228
 
185
229
  return {
@@ -190,6 +234,7 @@ async function completePlannedRelease<Package extends ReleasePackageInfo>(
190
234
  published: input.dryRun ? [] : plan.publishPackages.map((action) => action.pkg),
191
235
  alreadyPublished: input.packages.filter((pkg) => !input.npmMissingPackages.includes(pkg)),
192
236
  githubReleases: input.dryRun ? [] : plan.githubReleasePackages,
237
+ githubReleaseLinks,
193
238
  rerunRequired: input.rerunRequired,
194
239
  noRelease: false,
195
240
  };
@@ -1,25 +0,0 @@
1
- "use strict";
2
- const nxJsVersionActions = require('@nx/js/src/release/version-actions');
3
- const baseVersionActions = nxJsVersionActions.default ?? nxJsVersionActions;
4
- const afterAllProjectsVersioned = async (cwd, options) => {
5
- const result = await nxJsVersionActions.afterAllProjectsVersioned(cwd, options);
6
- // Temporary Bun workaround. Remove this hook only after all three issues are
7
- // fixed in supported Bun versions:
8
- // - https://github.com/oven-sh/bun/issues/18906
9
- // - https://github.com/oven-sh/bun/issues/20477
10
- // - https://github.com/oven-sh/bun/issues/20829
11
- // Nx runs `bun install --lockfile-only`, but Bun currently leaves workspace
12
- // versions stale in bun.lock. `bun pm pack` then rewrites `workspace:*` using
13
- // those stale lockfile versions instead of the current package.json versions.
14
- const { syncBunLockfileVersions } = await import('./monorepo/lockfile.js');
15
- const updated = syncBunLockfileVersions(cwd);
16
- if (updated === 0) {
17
- return result;
18
- }
19
- return {
20
- changedFiles: Array.from(new Set([...result.changedFiles, 'bun.lock'])),
21
- deletedFiles: result.deletedFiles,
22
- };
23
- };
24
- baseVersionActions.afterAllProjectsVersioned = afterAllProjectsVersioned;
25
- module.exports = baseVersionActions;
@@ -1,6 +0,0 @@
1
- import type { AfterAllProjectsVersioned, VersionActions } from 'nx/release';
2
- declare const baseVersionActions: typeof VersionActions & {
3
- afterAllProjectsVersioned: AfterAllProjectsVersioned;
4
- };
5
- export = baseVersionActions;
6
- //# sourceMappingURL=nx-version-actions.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nx-version-actions.d.cts","sourceRoot":"","sources":["../src/nx-version-actions.cts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAQ5E,QAAA,MAAM,kBAAkB;+BALyC,yBAAyB;CAKf,CAAC;AA2B5E,SAAS,kBAAkB,CAAC"}
@@ -1,36 +0,0 @@
1
- import type { AfterAllProjectsVersioned, VersionActions } from 'nx/release';
2
-
3
- type VersionActionsModule = typeof VersionActions & {
4
- default?: typeof VersionActions & { afterAllProjectsVersioned: AfterAllProjectsVersioned };
5
- afterAllProjectsVersioned: AfterAllProjectsVersioned;
6
- };
7
-
8
- const nxJsVersionActions = require('@nx/js/src/release/version-actions') as VersionActionsModule;
9
- const baseVersionActions = nxJsVersionActions.default ?? nxJsVersionActions;
10
-
11
- const afterAllProjectsVersioned: AfterAllProjectsVersioned = async (cwd, options) => {
12
- const result = await nxJsVersionActions.afterAllProjectsVersioned(cwd, options);
13
-
14
- // Temporary Bun workaround. Remove this hook only after all three issues are
15
- // fixed in supported Bun versions:
16
- // - https://github.com/oven-sh/bun/issues/18906
17
- // - https://github.com/oven-sh/bun/issues/20477
18
- // - https://github.com/oven-sh/bun/issues/20829
19
- // Nx runs `bun install --lockfile-only`, but Bun currently leaves workspace
20
- // versions stale in bun.lock. `bun pm pack` then rewrites `workspace:*` using
21
- // those stale lockfile versions instead of the current package.json versions.
22
- const { syncBunLockfileVersions } = await import('./monorepo/lockfile.js');
23
- const updated = syncBunLockfileVersions(cwd);
24
- if (updated === 0) {
25
- return result;
26
- }
27
-
28
- return {
29
- changedFiles: Array.from(new Set([...result.changedFiles, 'bun.lock'])),
30
- deletedFiles: result.deletedFiles,
31
- };
32
- };
33
-
34
- baseVersionActions.afterAllProjectsVersioned = afterAllProjectsVersioned;
35
-
36
- export = baseVersionActions;