@smoothbricks/cli 0.1.0 → 0.2.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 (148) hide show
  1. package/README.md +338 -88
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +136 -22
  4. package/dist/devenv/index.d.ts +10 -0
  5. package/dist/devenv/index.d.ts.map +1 -0
  6. package/dist/devenv/index.js +27 -0
  7. package/dist/lib/cli-package.d.ts +4 -0
  8. package/dist/lib/cli-package.d.ts.map +1 -0
  9. package/dist/lib/cli-package.js +15 -0
  10. package/dist/lib/devenv.d.ts +6 -0
  11. package/dist/lib/devenv.d.ts.map +1 -0
  12. package/dist/lib/devenv.js +82 -0
  13. package/dist/lib/run.d.ts +5 -0
  14. package/dist/lib/run.d.ts.map +1 -1
  15. package/dist/lib/run.js +13 -0
  16. package/dist/lib/workspace.d.ts +20 -1
  17. package/dist/lib/workspace.d.ts.map +1 -1
  18. package/dist/lib/workspace.js +87 -7
  19. package/dist/monorepo/commit-msg.d.ts +8 -1
  20. package/dist/monorepo/commit-msg.d.ts.map +1 -1
  21. package/dist/monorepo/commit-msg.js +85 -7
  22. package/dist/monorepo/index.d.ts +24 -2
  23. package/dist/monorepo/index.d.ts.map +1 -1
  24. package/dist/monorepo/index.js +136 -15
  25. package/dist/monorepo/lockfile.d.ts +5 -1
  26. package/dist/monorepo/lockfile.d.ts.map +1 -1
  27. package/dist/monorepo/lockfile.js +45 -5
  28. package/dist/monorepo/managed-files.d.ts +1 -1
  29. package/dist/monorepo/managed-files.d.ts.map +1 -1
  30. package/dist/monorepo/managed-files.js +28 -11
  31. package/dist/monorepo/nx-sync.d.ts +2 -1
  32. package/dist/monorepo/nx-sync.d.ts.map +1 -1
  33. package/dist/monorepo/nx-sync.js +8 -2
  34. package/dist/monorepo/package-hygiene.d.ts +6 -2
  35. package/dist/monorepo/package-hygiene.d.ts.map +1 -1
  36. package/dist/monorepo/package-hygiene.js +12 -4
  37. package/dist/monorepo/package-policy.d.ts +25 -2
  38. package/dist/monorepo/package-policy.d.ts.map +1 -1
  39. package/dist/monorepo/package-policy.js +1289 -27
  40. package/dist/monorepo/packed-manifest.d.ts +4 -0
  41. package/dist/monorepo/packed-manifest.d.ts.map +1 -0
  42. package/dist/monorepo/packed-manifest.js +51 -0
  43. package/dist/monorepo/packed-package.d.ts +3 -0
  44. package/dist/monorepo/packed-package.d.ts.map +1 -1
  45. package/dist/monorepo/packed-package.js +69 -31
  46. package/dist/monorepo/packs/index.d.ts +20 -1
  47. package/dist/monorepo/packs/index.d.ts.map +1 -1
  48. package/dist/monorepo/packs/index.js +240 -18
  49. package/dist/monorepo/publish-workflow.d.ts +82 -0
  50. package/dist/monorepo/publish-workflow.d.ts.map +1 -0
  51. package/dist/monorepo/publish-workflow.js +336 -0
  52. package/dist/monorepo/tool-validation.d.ts +22 -0
  53. package/dist/monorepo/tool-validation.d.ts.map +1 -0
  54. package/dist/monorepo/tool-validation.js +399 -0
  55. package/dist/nx/index.d.ts +24 -0
  56. package/dist/nx/index.d.ts.map +1 -0
  57. package/dist/nx/index.js +94 -0
  58. package/dist/nx-version-actions.cjs +25 -0
  59. package/dist/nx-version-actions.d.cts +6 -0
  60. package/dist/nx-version-actions.d.cts.map +1 -0
  61. package/dist/release/bootstrap-npm-packages.d.ts +19 -0
  62. package/dist/release/bootstrap-npm-packages.d.ts.map +1 -0
  63. package/dist/release/bootstrap-npm-packages.js +58 -0
  64. package/dist/release/candidates.d.ts +11 -0
  65. package/dist/release/candidates.d.ts.map +1 -0
  66. package/dist/release/candidates.js +181 -0
  67. package/dist/release/core.d.ts +51 -0
  68. package/dist/release/core.d.ts.map +1 -0
  69. package/dist/release/core.js +97 -0
  70. package/dist/release/github-release.d.ts +46 -0
  71. package/dist/release/github-release.d.ts.map +1 -0
  72. package/dist/release/github-release.js +97 -0
  73. package/dist/release/index.d.ts +39 -5
  74. package/dist/release/index.d.ts.map +1 -1
  75. package/dist/release/index.js +763 -130
  76. package/dist/release/npm-auth.d.ts +16 -0
  77. package/dist/release/npm-auth.d.ts.map +1 -0
  78. package/dist/release/npm-auth.js +39 -0
  79. package/dist/release/orchestration.d.ts +49 -0
  80. package/dist/release/orchestration.d.ts.map +1 -0
  81. package/dist/release/orchestration.js +113 -0
  82. package/dist/release/publish-plan.d.ts +17 -0
  83. package/dist/release/publish-plan.d.ts.map +1 -0
  84. package/dist/release/publish-plan.js +15 -0
  85. package/dist/release/retag-unpublished.d.ts +34 -0
  86. package/dist/release/retag-unpublished.d.ts.map +1 -0
  87. package/dist/release/retag-unpublished.js +77 -0
  88. package/managed/raw/git-format-staged.yml +54 -0
  89. package/managed/raw/tooling/git-hooks/commit-msg.sh +1 -1
  90. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -7
  91. package/managed/templates/github/actions/setup-devenv/action.yml +1 -7
  92. package/managed/templates/github/workflows/ci.yml +3 -0
  93. package/package.json +37 -4
  94. package/src/cli.ts +193 -40
  95. package/src/devenv/index.test.ts +49 -0
  96. package/src/devenv/index.ts +38 -0
  97. package/src/lib/cli-package.ts +18 -0
  98. package/src/lib/devenv.test.ts +28 -0
  99. package/src/lib/devenv.ts +89 -0
  100. package/src/lib/run.ts +19 -0
  101. package/src/lib/workspace.ts +117 -7
  102. package/src/monorepo/__tests__/nx-version-actions.test.ts +75 -0
  103. package/src/monorepo/__tests__/publish-workflow.test.ts +322 -0
  104. package/src/monorepo/commit-msg.test.ts +45 -0
  105. package/src/monorepo/commit-msg.ts +107 -7
  106. package/src/monorepo/index.ts +181 -15
  107. package/src/monorepo/lockfile.ts +52 -7
  108. package/src/monorepo/managed-files.ts +43 -13
  109. package/src/monorepo/nx-sync.ts +9 -2
  110. package/src/monorepo/package-hygiene.test.ts +34 -0
  111. package/src/monorepo/package-hygiene.ts +26 -4
  112. package/src/monorepo/package-policy.test.ts +902 -0
  113. package/src/monorepo/package-policy.ts +1527 -25
  114. package/src/monorepo/packed-manifest.ts +67 -0
  115. package/src/monorepo/packed-package.ts +90 -31
  116. package/src/monorepo/packs/index.test.ts +189 -0
  117. package/src/monorepo/packs/index.ts +314 -19
  118. package/src/monorepo/publish-workflow.ts +422 -0
  119. package/src/monorepo/setup-test-tracing.test.ts +120 -0
  120. package/src/monorepo/tool-validation.test.ts +261 -0
  121. package/src/monorepo/tool-validation.ts +462 -0
  122. package/src/nx/index.test.ts +64 -0
  123. package/src/nx/index.ts +119 -0
  124. package/src/nx-version-actions.cts +36 -0
  125. package/src/release/__tests__/bootstrap-npm-packages.test.ts +127 -0
  126. package/src/release/__tests__/candidates.test.ts +217 -0
  127. package/src/release/__tests__/core-properties.test.ts +149 -0
  128. package/src/release/__tests__/core-scenarios.test.ts +187 -0
  129. package/src/release/__tests__/core.test.ts +73 -0
  130. package/src/release/__tests__/fixture-repo.test.ts +314 -0
  131. package/src/release/__tests__/github-release.test.ts +149 -0
  132. package/src/release/__tests__/helpers/fixture-repo.ts +114 -0
  133. package/src/release/__tests__/npm-auth.test.ts +120 -0
  134. package/src/release/__tests__/orchestration.test.ts +246 -0
  135. package/src/release/__tests__/publish-plan.test.ts +67 -0
  136. package/src/release/__tests__/retag-unpublished.test.ts +160 -0
  137. package/src/release/__tests__/trust-publisher.test.ts +133 -0
  138. package/src/release/bootstrap-npm-packages.ts +88 -0
  139. package/src/release/candidates.ts +225 -0
  140. package/src/release/core.ts +171 -0
  141. package/src/release/github-release.ts +134 -0
  142. package/src/release/index.ts +974 -138
  143. package/src/release/npm-auth.ts +93 -0
  144. package/src/release/orchestration.ts +196 -0
  145. package/src/release/publish-plan.ts +37 -0
  146. package/src/release/retag-unpublished.ts +122 -0
  147. package/managed/raw/.git-format-staged.yml +0 -47
  148. package/managed/templates/github/workflows/publish.yml +0 -136
@@ -1 +1 @@
1
- {"version":3,"file":"commit-msg.d.ts","sourceRoot":"","sources":["../../src/monorepo/commit-msg.ts"],"names":[],"mappings":"AAcA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoBpE"}
1
+ {"version":3,"file":"commit-msg.d.ts","sourceRoot":"","sources":["../../src/monorepo/commit-msg.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AAED,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACnC;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,4BAAiC,GAAG,MAAM,GAAG,IAAI,CA+BhH;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,MAAM,CA2CrG"}
@@ -1,3 +1,4 @@
1
+ import { spawnSync } from 'node:child_process';
1
2
  const validCommitTypes = new Set([
2
3
  'build',
3
4
  'chore',
@@ -10,25 +11,102 @@ const validCommitTypes = new Set([
10
11
  'revert',
11
12
  'style',
12
13
  'test',
14
+ 'types',
13
15
  ]);
14
- export function validateCommitMessage(message) {
16
+ export function validateCommitMessage(message, options = {}) {
15
17
  const subject = message.split('\n', 1)[0]?.trim() ?? '';
16
18
  if (!subject) {
17
19
  return 'Commit message subject is empty.';
18
20
  }
19
- if (/^(Merge|Revert ")/.test(subject) || /^(fixup|squash)! /.test(subject)) {
21
+ if (isGitGeneratedSubject(subject)) {
20
22
  return null;
21
23
  }
22
- const match = /^(?<type>[a-z]+)(\([a-z0-9._/-]+\))?(?<breaking>!)?: .+$/.exec(subject);
24
+ const match = /^(?<type>[a-z]+)(\((?<scope>[a-z0-9._/@-]+(?:,[a-z0-9._/@-]+)*)\))?(?<breaking>!)?: .+$/.exec(subject);
23
25
  const type = match?.groups?.type;
24
- if (type && validCommitTypes.has(type)) {
25
- return null;
26
- }
27
- return `Invalid conventional commit subject: ${subject}
26
+ if (!type || !validCommitTypes.has(type)) {
27
+ return `Invalid conventional commit subject: ${subject}
28
28
 
29
29
  Expected examples:
30
30
  feat(statebus-core): add optimistic transactions
31
31
  fix(money): round negative amounts consistently
32
32
  chore(release): publish 1.2.3
33
33
  feat!: remove deprecated API`;
34
+ }
35
+ const scope = match.groups?.scope;
36
+ if (scope && options.validScopes) {
37
+ const invalidScopes = scope.split(',').filter((entry) => !options.validScopes?.has(entry));
38
+ if (invalidScopes.length > 0) {
39
+ return `Invalid conventional commit scope: ${invalidScopes.join(',')}
40
+
41
+ Use package.json nx.name values, for example:
42
+ feat(statebus-core): add optimistic transactions
43
+ fix(money): round negative amounts consistently`;
44
+ }
45
+ }
46
+ return null;
47
+ }
48
+ export function formatCommitMessage(message, options = {}) {
49
+ const wrapBody = options.wrapBody ?? wrapBodyWithFmt;
50
+ const normalized = message.replace(/\r\n?/g, '\n');
51
+ const lines = normalized.split('\n');
52
+ const subject = lines.shift()?.trimEnd() ?? '';
53
+ const formatted = [subject];
54
+ let paragraph = [];
55
+ let inFence = false;
56
+ const flushParagraph = () => {
57
+ if (paragraph.length === 0) {
58
+ return;
59
+ }
60
+ formatted.push(wrapBody(paragraph.join('\n')).trimEnd());
61
+ paragraph = [];
62
+ };
63
+ for (const line of lines) {
64
+ const trimmedEnd = line.trimEnd();
65
+ if (trimmedEnd.startsWith('```') || trimmedEnd.startsWith('~~~')) {
66
+ flushParagraph();
67
+ inFence = !inFence;
68
+ formatted.push(trimmedEnd);
69
+ continue;
70
+ }
71
+ if (inFence || shouldPreserveLine(trimmedEnd)) {
72
+ flushParagraph();
73
+ formatted.push(trimmedEnd);
74
+ continue;
75
+ }
76
+ if (trimmedEnd === '') {
77
+ flushParagraph();
78
+ formatted.push('');
79
+ continue;
80
+ }
81
+ paragraph.push(trimmedEnd);
82
+ }
83
+ flushParagraph();
84
+ while (formatted.length > 1 && formatted.at(-1) === '') {
85
+ formatted.pop();
86
+ }
87
+ return `${formatted.join('\n')}\n`;
88
+ }
89
+ function wrapBodyWithFmt(paragraph) {
90
+ const result = spawnSync('fmt', ['-w', '72'], { input: `${paragraph}\n`, encoding: 'utf8' });
91
+ if (result.error) {
92
+ throw new Error(`fmt is required to format commit messages. Install it through devenv and retry.\n${result.error.message}`);
93
+ }
94
+ if (result.status !== 0) {
95
+ throw new Error([result.stderr.trim(), result.stdout.trim()].filter(Boolean).join('\n') ||
96
+ 'fmt failed to wrap commit message body.');
97
+ }
98
+ return result.stdout;
99
+ }
100
+ function shouldPreserveLine(line) {
101
+ return (line.startsWith('#') ||
102
+ line.startsWith('>') ||
103
+ /^\s/.test(line) ||
104
+ /^[-*+]\s+/.test(line) ||
105
+ /^\d+\.\s+/.test(line) ||
106
+ /^https?:\/\//.test(line) ||
107
+ /^[A-Za-z][A-Za-z0-9-]*: /.test(line) ||
108
+ /^BREAKING CHANGE: /.test(line));
109
+ }
110
+ function isGitGeneratedSubject(subject) {
111
+ return /^(Merge|Revert ")/.test(subject) || /^(fixup|squash)! /.test(subject);
34
112
  }
@@ -6,14 +6,36 @@ export interface InitOptions {
6
6
  }
7
7
  export interface ValidateOptions {
8
8
  failFast?: boolean;
9
+ onlyIfNewWorkspacePackage?: boolean;
10
+ fix?: boolean;
11
+ verbose?: boolean;
12
+ }
13
+ export interface ValidateCommitMessageOptions {
14
+ fix?: boolean;
15
+ }
16
+ export interface ListReleasePackagesOptions {
17
+ failEmpty?: boolean;
18
+ githubOutput?: string;
19
+ }
20
+ export interface SetupTestTracingOptions {
21
+ all?: boolean;
22
+ projects?: string;
23
+ opContextExport?: string;
24
+ tracerModule?: string;
25
+ dryRun?: boolean;
26
+ }
27
+ export interface SetupTestTracingShell {
28
+ run(command: string, args: string[], cwd: string): Promise<void>;
29
+ log(message: string): void;
9
30
  }
10
31
  export declare function initMonorepo(root: string, options: InitOptions): Promise<void>;
11
32
  export declare function validateMonorepo(root: string, options?: ValidateOptions): Promise<void>;
12
33
  export declare function updateManagedFiles(root: string): void;
13
34
  export declare function checkManagedFiles(root: string): void;
14
35
  export declare function diffManagedFiles(root: string): void;
15
- export declare function validateCommitMessageFile(path: string | undefined): void;
16
- export declare function listPublicProjects(root: string): string;
36
+ export declare function validateCommitMessageFile(path: string | undefined, options?: ValidateCommitMessageOptions, root?: string): void;
37
+ export declare function listReleaseProjectNamesForNx(root: string, options?: ListReleasePackagesOptions): string;
17
38
  export declare function validatePublicPackageTags(root: string): void;
39
+ export declare function setupTestTracing(root: string, options: SetupTestTracingOptions, shell?: SetupTestTracingShell): Promise<void>;
18
40
  export { applyWorkspaceGitConfig, syncBunLockfileVersions };
19
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/monorepo/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAMxD,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAQpF;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjG;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAErD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMpD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEnD;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CASxE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIvD;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAI5D;AAED,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/monorepo/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAMxD,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,4BAA4B;IAC3C,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAQpF;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBjG;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAErD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMpD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEnD;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,GAAE,4BAAiC,EAC1C,IAAI,SAAgB,GACnB,IAAI,CAgBN;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,MAAM,CAW3G;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAI5D;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,uBAAuB,EAChC,KAAK,GAAE,qBAAoD,GAC1D,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAC"}
@@ -1,10 +1,12 @@
1
- import { readFileSync } from 'node:fs';
2
- import { listPublicPackages } from '../lib/workspace.js';
3
- import { validateCommitMessage } from './commit-msg.js';
1
+ import { appendFileSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { $ } from 'bun';
3
+ import { decode, run } from '../lib/run.js';
4
+ import { escapeRegex, getWorkspacePackages, getWorkspacePatterns, listReleasePackages } from '../lib/workspace.js';
5
+ import { formatCommitMessage, validateCommitMessage } from './commit-msg.js';
4
6
  import { applyWorkspaceGitConfig } from './git-config.js';
5
7
  import { syncBunLockfileVersions } from './lockfile.js';
6
8
  import { applyManagedFiles, printResults } from './managed-files.js';
7
- import { validatePublicTags } from './package-policy.js';
9
+ import { listValidCommitScopes, validatePublicTags } from './package-policy.js';
8
10
  import { runInitPacks, runValidatePacks } from './packs/index.js';
9
11
  import { syncRootRuntimeVersions } from './runtime.js';
10
12
  export async function initMonorepo(root, options) {
@@ -16,12 +18,22 @@ export async function initMonorepo(root, options) {
16
18
  await runInitPacks({ root, syncRuntime: process.env.DEVENV_ROOT !== undefined || options.syncRuntime === true });
17
19
  }
18
20
  export async function validateMonorepo(root, options = {}) {
19
- const failures = await runValidatePacks({ root, syncRuntime: false }, options);
20
- if (failures > 0) {
21
- throw new Error(`Monorepo validation failed with ${failures} problem(s).`);
21
+ if (options.onlyIfNewWorkspacePackage && !(await hasNewWorkspacePackage(root))) {
22
+ return;
23
+ }
24
+ const result = await runValidatePacks({ root, syncRuntime: false, verbose: options.verbose === true }, options);
25
+ if (result.failures > 0) {
26
+ const checkNoun = result.failedChecks === 1 ? 'check' : 'checks';
27
+ const problemNoun = result.failures === 1 ? 'problem' : 'problems';
28
+ throw new Error(`\n🔴 Monorepo validation failed: ${result.failedChecks} ${checkNoun} failed with ${result.failures} ${problemNoun}.`);
29
+ }
30
+ if (options.verbose) {
31
+ console.log('\n== summary ==');
32
+ console.log('Monorepo configuration is valid.');
33
+ }
34
+ else {
35
+ console.log('🟢 Monorepo configuration is valid.');
22
36
  }
23
- console.log('\n== summary ==');
24
- console.log('Monorepo configuration is valid.');
25
37
  }
26
38
  export function updateManagedFiles(root) {
27
39
  printResults(applyManagedFiles(root, 'update'));
@@ -36,24 +48,133 @@ export function checkManagedFiles(root) {
36
48
  export function diffManagedFiles(root) {
37
49
  printResults(applyManagedFiles(root, 'diff'));
38
50
  }
39
- export function validateCommitMessageFile(path) {
51
+ export function validateCommitMessageFile(path, options = {}, root = process.cwd()) {
40
52
  if (!path) {
41
53
  throw new Error('Usage: smoo monorepo validate-commit-msg <commit-msg-file>');
42
54
  }
43
- const message = readFileSync(path, 'utf8');
44
- const error = validateCommitMessage(message);
55
+ let message = readFileSync(path, 'utf8');
56
+ if (options.fix) {
57
+ const formatted = formatCommitMessage(message);
58
+ if (formatted !== message) {
59
+ writeFileSync(path, formatted);
60
+ message = formatted;
61
+ }
62
+ }
63
+ const error = validateCommitMessage(message, { validScopes: listValidCommitScopes(root) });
45
64
  if (error) {
46
65
  throw new Error(error);
47
66
  }
48
67
  }
49
- export function listPublicProjects(root) {
50
- return listPublicPackages(root)
51
- .map((pkg) => pkg.name)
68
+ export function listReleaseProjectNamesForNx(root, options = {}) {
69
+ const packages = listReleasePackages(root)
70
+ .map((pkg) => pkg.projectName)
52
71
  .join(',');
72
+ if (!packages && options.failEmpty) {
73
+ throw new Error('No owned release packages found.');
74
+ }
75
+ if (options.githubOutput) {
76
+ appendFileSync(options.githubOutput, `projects=${packages}\n`);
77
+ }
78
+ return packages;
53
79
  }
54
80
  export function validatePublicPackageTags(root) {
55
81
  if (validatePublicTags(root) > 0) {
56
82
  throw new Error('npm:public tag validation failed.');
57
83
  }
58
84
  }
85
+ export async function setupTestTracing(root, options, shell = defaultSetupTestTracingShell) {
86
+ const selectedPackages = selectTestTracingPackages(root, options);
87
+ const opContextExport = options.opContextExport ?? 'opContext';
88
+ const tracerModule = options.tracerModule ?? '@smoothbricks/lmao/testing/bun';
89
+ if (selectedPackages.length === 0) {
90
+ throw new Error('No workspace packages matched LMAO test tracing setup selection.');
91
+ }
92
+ for (const pkg of selectedPackages) {
93
+ const args = [
94
+ 'g',
95
+ '@smoothbricks/nx-plugin:bun-test-tracing',
96
+ '--project',
97
+ pkg.projectName,
98
+ '--opContextModule',
99
+ pkg.name,
100
+ '--opContextExport',
101
+ opContextExport,
102
+ '--tracerModule',
103
+ tracerModule,
104
+ ];
105
+ const commandPreview = `nx ${args.join(' ')}`;
106
+ if (options.dryRun) {
107
+ shell.log(`would run ${commandPreview}`);
108
+ continue;
109
+ }
110
+ shell.log(`running ${commandPreview}`);
111
+ await shell.run('nx', args, root);
112
+ }
113
+ }
59
114
  export { applyWorkspaceGitConfig, syncBunLockfileVersions };
115
+ const defaultSetupTestTracingShell = {
116
+ run,
117
+ log(message) {
118
+ console.log(message);
119
+ },
120
+ };
121
+ function selectTestTracingPackages(root, options) {
122
+ const packages = getWorkspacePackages(root);
123
+ const requested = splitCommaList(options.projects);
124
+ if (options.all && requested.length > 0) {
125
+ throw new Error('Use either --all or --projects, not both.');
126
+ }
127
+ if (!options.all && requested.length === 0) {
128
+ throw new Error('Pass --all or --projects <projects> to select packages for LMAO test tracing setup.');
129
+ }
130
+ if (options.all) {
131
+ return packages;
132
+ }
133
+ const bySelector = new Map();
134
+ for (const pkg of packages) {
135
+ bySelector.set(pkg.projectName, pkg);
136
+ bySelector.set(pkg.name, pkg);
137
+ bySelector.set(pkg.path, pkg);
138
+ }
139
+ const selected = [];
140
+ const missing = [];
141
+ for (const selector of requested) {
142
+ const pkg = bySelector.get(selector);
143
+ if (pkg) {
144
+ selected.push(pkg);
145
+ }
146
+ else {
147
+ missing.push(selector);
148
+ }
149
+ }
150
+ if (missing.length > 0) {
151
+ throw new Error(`Unknown workspace package selection for LMAO test tracing setup: ${missing.join(', ')}`);
152
+ }
153
+ return selected;
154
+ }
155
+ function splitCommaList(value) {
156
+ return (value ?? '')
157
+ .split(',')
158
+ .map((entry) => entry.trim())
159
+ .filter(Boolean);
160
+ }
161
+ async function hasNewWorkspacePackage(root) {
162
+ const result = await $ `git diff --cached --name-only --diff-filter=A -- ${'*/package.json'}`
163
+ .cwd(root)
164
+ .quiet()
165
+ .nothrow();
166
+ if (result.exitCode !== 0) {
167
+ throw new Error('Unable to inspect staged package manifests.');
168
+ }
169
+ const manifests = decode(result.stdout)
170
+ .split('\n')
171
+ .map((path) => path.trim())
172
+ .filter(Boolean);
173
+ if (manifests.length === 0) {
174
+ return false;
175
+ }
176
+ const patterns = getWorkspacePatterns(root)
177
+ .filter((pattern) => pattern.endsWith('/*'))
178
+ .map((pattern) => new RegExp(`^${escapeRegex(pattern.slice(0, -2))}/[^/]+/package\\.json$`));
179
+ return manifests.some((manifest) => patterns.some((pattern) => pattern.test(manifest)));
180
+ }
@@ -1,2 +1,6 @@
1
- export declare function syncBunLockfileVersions(root: string): void;
1
+ export interface SyncBunLockfileVersionsOptions {
2
+ log?: boolean;
3
+ }
4
+ export declare function syncBunLockfileVersions(root: string, options?: SyncBunLockfileVersionsOptions): number;
5
+ export declare function validateBunLockfileVersions(root: string): number;
2
6
  //# sourceMappingURL=lockfile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lockfile.d.ts","sourceRoot":"","sources":["../../src/monorepo/lockfile.ts"],"names":[],"mappings":"AAIA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAgC1D"}
1
+ {"version":3,"file":"lockfile.d.ts","sourceRoot":"","sources":["../../src/monorepo/lockfile.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,8BAA8B;IAC7C,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,8BAAmC,GAAG,MAAM,CA0C1G;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA6BhE"}
@@ -1,7 +1,8 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { escapeRegex, getWorkspacePackages } from '../lib/workspace.js';
4
- export function syncBunLockfileVersions(root) {
4
+ export function syncBunLockfileVersions(root, options = {}) {
5
+ const log = options.log ?? true;
5
6
  const lockfilePath = join(root, 'bun.lock');
6
7
  if (!existsSync(lockfilePath)) {
7
8
  throw new Error('bun.lock not found');
@@ -15,20 +16,59 @@ export function syncBunLockfileVersions(root) {
15
16
  const pattern = new RegExp(`("${escaped}":\\s*\\{[^}]*"version":\\s*")([^"]+)(")`);
16
17
  const match = lockfile.match(pattern);
17
18
  if (!match) {
18
- console.log(`skip: ${relativePath} (not found in lockfile)`);
19
+ if (log) {
20
+ console.log(`skip: ${relativePath} (not found in lockfile)`);
21
+ }
19
22
  continue;
20
23
  }
21
24
  const lockVersion = match[2];
22
25
  if (lockVersion === pkg.version) {
23
- console.log(`ok: ${relativePath} = ${pkg.version}`);
26
+ if (log) {
27
+ console.log(`ok: ${relativePath} = ${pkg.version}`);
28
+ }
24
29
  continue;
25
30
  }
26
31
  lockfile = lockfile.replace(pattern, `$1${pkg.version}$3`);
27
- console.log(`fix: ${relativePath}: ${lockVersion} -> ${pkg.version}`);
32
+ if (log) {
33
+ console.log(`fix: ${relativePath}: ${lockVersion} -> ${pkg.version}`);
34
+ }
28
35
  updated++;
29
36
  }
30
37
  if (updated > 0) {
31
38
  writeFileSync(lockfilePath, lockfile);
32
39
  }
33
- console.log(updated > 0 ? `Updated ${updated} workspace version(s) in bun.lock` : 'All workspace versions already in sync.');
40
+ if (log) {
41
+ console.log(updated > 0 ? `Updated ${updated} workspace version(s) in bun.lock` : 'All workspace versions already in sync.');
42
+ }
43
+ return updated;
44
+ }
45
+ export function validateBunLockfileVersions(root) {
46
+ const lockfilePath = join(root, 'bun.lock');
47
+ if (!existsSync(lockfilePath)) {
48
+ console.error('bun.lock not found');
49
+ return 1;
50
+ }
51
+ const packages = getWorkspacePackages(root);
52
+ const lockfile = readFileSync(lockfilePath, 'utf8');
53
+ let failures = 0;
54
+ for (const pkg of packages) {
55
+ const relativePath = pkg.path.replaceAll('\\', '/');
56
+ const escaped = escapeRegex(relativePath);
57
+ const pattern = new RegExp(`("${escaped}":\\s*\\{[^}]*"version":\\s*")([^"]+)(")`);
58
+ const match = lockfile.match(pattern);
59
+ if (!match) {
60
+ console.error(`bun.lock missing workspace entry for ${relativePath}`);
61
+ failures++;
62
+ continue;
63
+ }
64
+ const lockVersion = match[2];
65
+ if (lockVersion !== pkg.version) {
66
+ console.error(`${relativePath}: bun.lock workspace version must be ${pkg.version}, got ${lockVersion}`);
67
+ failures++;
68
+ }
69
+ }
70
+ if (failures === 0) {
71
+ console.log('bun.lock workspace versions are valid.');
72
+ }
73
+ return failures;
34
74
  }
@@ -1,6 +1,6 @@
1
1
  export interface FileResult {
2
2
  target: string;
3
- action: 'created' | 'updated' | 'unchanged' | 'skipped-symlink' | 'drifted' | 'ok-symlink';
3
+ action: 'created' | 'updated' | 'unchanged' | 'skipped' | 'skipped-symlink' | 'drifted' | 'ok-symlink';
4
4
  }
5
5
  export declare function applyManagedFiles(root: string, mode: 'update' | 'check' | 'diff'): FileResult[];
6
6
  export declare function printResults(results: FileResult[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"managed-files.d.ts","sourceRoot":"","sources":["../../src/monorepo/managed-files.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,iBAAiB,GAAG,SAAS,GAAG,YAAY,CAAC;CAC5F;AAiED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,EAAE,CAE/F;AAsDD,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,CAIxD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQzD"}
1
+ {"version":3,"file":"managed-files.d.ts","sourceRoot":"","sources":["../../src/monorepo/managed-files.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,GAAG,YAAY,CAAC;CACxG;AAwED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,EAAE,CAG/F;AA0ED,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,CAIxD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQzD"}
@@ -1,7 +1,8 @@
1
1
  import { existsSync, lstatSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { dirname, join, resolve } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
- import { readPackageJson } from '../lib/workspace.js';
4
+ import { listReleasePackages, readPackageJson } from '../lib/workspace.js';
5
+ import { renderPublishWorkflowYaml } from './publish-workflow.js';
5
6
  const managedFiles = [
6
7
  {
7
8
  kind: 'raw',
@@ -23,7 +24,7 @@ const managedFiles = [
23
24
  },
24
25
  {
25
26
  kind: 'raw',
26
- source: '.git-format-staged.yml',
27
+ source: 'git-format-staged.yml',
27
28
  target: '.git-format-staged.yml',
28
29
  },
29
30
  {
@@ -32,9 +33,10 @@ const managedFiles = [
32
33
  target: '.github/workflows/ci.yml',
33
34
  },
34
35
  {
35
- kind: 'template',
36
- source: 'github/workflows/publish.yml',
36
+ kind: 'generated',
37
+ source: 'publish-workflow',
37
38
  target: '.github/workflows/publish.yml',
39
+ releasePackagesOnly: true,
38
40
  },
39
41
  {
40
42
  kind: 'template',
@@ -64,11 +66,15 @@ const managedFiles = [
64
66
  ];
65
67
  const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..');
66
68
  export function applyManagedFiles(root, mode) {
67
- return managedFiles.map((file) => applyManagedFile(root, file, mode));
69
+ const context = getManagedFileContext(root);
70
+ return managedFiles.map((file) => applyManagedFile(root, file, mode, context));
68
71
  }
69
- function applyManagedFile(root, file, mode) {
72
+ function applyManagedFile(root, file, mode, context) {
73
+ if (file.releasePackagesOnly === true && !context.hasReleasePackages) {
74
+ return { target: file.target, action: 'skipped' };
75
+ }
70
76
  const target = resolve(root, file.target);
71
- const content = getManagedContent(root, file);
77
+ const content = getManagedContent(file, context);
72
78
  if (existsSync(target)) {
73
79
  const info = lstatSync(target);
74
80
  if (info.isSymbolicLink()) {
@@ -93,22 +99,33 @@ function applyManagedFile(root, file, mode) {
93
99
  writeManagedFile(target, content, file.executable === true);
94
100
  return { target: file.target, action: 'created' };
95
101
  }
96
- function getManagedContent(root, file) {
102
+ function getManagedContent(file, context) {
103
+ if (file.kind === 'generated') {
104
+ if (file.source === 'publish-workflow') {
105
+ return renderPublishWorkflowYaml({ repoName: context.repoName });
106
+ }
107
+ throw new Error(`Unknown generated managed file source ${file.source}`);
108
+ }
97
109
  const sourceRoot = file.kind === 'raw' ? 'managed/raw' : 'managed/templates';
98
110
  const sourcePath = join(packageRoot, sourceRoot, file.source);
99
111
  const content = readFileSync(sourcePath, 'utf8');
100
112
  if (file.kind === 'raw') {
101
113
  return content;
102
114
  }
103
- return renderTemplate(root, content);
115
+ return renderTemplate(context, content);
104
116
  }
105
- function renderTemplate(root, template) {
117
+ function getManagedFileContext(root) {
106
118
  const packageJson = readPackageJson(join(root, 'package.json'));
107
119
  const repoName = packageJson?.name ?? 'monorepo';
108
120
  const nodeModulesCacheKey = existsSync(join(root, 'bun.lock'))
109
121
  ? `$${"{{ hashFiles('bun.lock', 'package.json', 'packages/*/package.json') }}"}`
110
122
  : `$${"{{ hashFiles('bun.lockb', 'package.json', 'packages/*/package.json') }}"}`;
111
- return template.replaceAll('{{REPO_NAME}}', repoName).replaceAll('{{NODE_MODULES_CACHE_KEY}}', nodeModulesCacheKey);
123
+ return { hasReleasePackages: listReleasePackages(root, packageJson).length > 0, nodeModulesCacheKey, repoName };
124
+ }
125
+ function renderTemplate(context, template) {
126
+ return template
127
+ .replaceAll('{{REPO_NAME}}', context.repoName)
128
+ .replaceAll('{{NODE_MODULES_CACHE_KEY}}', context.nodeModulesCacheKey);
112
129
  }
113
130
  function writeManagedFile(path, content, executable) {
114
131
  mkdirSync(dirname(path), { recursive: true });
@@ -1,2 +1,3 @@
1
- export declare function validateNxSync(root: string): Promise<number>;
1
+ export declare function fixNxSync(root: string, verbose?: boolean): Promise<void>;
2
+ export declare function validateNxSync(root: string, verbose?: boolean): Promise<number>;
2
3
  //# sourceMappingURL=nx-sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nx-sync.d.ts","sourceRoot":"","sources":["../../src/monorepo/nx-sync.ts"],"names":[],"mappings":"AAEA,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlE"}
1
+ {"version":3,"file":"nx-sync.d.ts","sourceRoot":"","sources":["../../src/monorepo/nx-sync.ts"],"names":[],"mappings":"AAEA,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAK5E;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnF"}
@@ -1,5 +1,11 @@
1
1
  import { runStatus } from '../lib/run.js';
2
- export async function validateNxSync(root) {
3
- const status = await runStatus('nx', ['sync:check'], root);
2
+ export async function fixNxSync(root, verbose = false) {
3
+ const status = await runStatus('nx', ['sync'], root, !verbose);
4
+ if (status !== 0) {
5
+ throw new Error(`nx sync failed with exit code ${status}`);
6
+ }
7
+ }
8
+ export async function validateNxSync(root, verbose = false) {
9
+ const status = await runStatus('nx', ['sync:check'], root, !verbose);
4
10
  return status === 0 ? 0 : 1;
5
11
  }
@@ -1,3 +1,7 @@
1
- export declare function fixPackageHygiene(root: string): Promise<void>;
2
- export declare function validatePackageHygiene(root: string): Promise<number>;
1
+ export interface PackageHygieneShell {
2
+ run(command: string, args: string[], cwd: string): Promise<void>;
3
+ runStatus(command: string, args: string[], cwd: string, quiet?: boolean): Promise<number>;
4
+ }
5
+ export declare function fixPackageHygiene(root: string, verboseOrShell?: boolean | PackageHygieneShell, maybeShell?: PackageHygieneShell): Promise<void>;
6
+ export declare function validatePackageHygiene(root: string, verboseOrShell?: boolean | PackageHygieneShell, maybeShell?: PackageHygieneShell): Promise<number>;
3
7
  //# sourceMappingURL=package-hygiene.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"package-hygiene.d.ts","sourceRoot":"","sources":["../../src/monorepo/package-hygiene.ts"],"names":[],"mappings":"AAEA,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO1E"}
1
+ {"version":3,"file":"package-hygiene.d.ts","sourceRoot":"","sources":["../../src/monorepo/package-hygiene.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3F;AAID,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAO,GAAG,mBAA2B,EACrD,UAAU,GAAE,mBAAkC,GAC7C,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAO,GAAG,mBAA2B,EACrD,UAAU,GAAE,mBAAkC,GAC7C,OAAO,CAAC,MAAM,CAAC,CASjB"}
@@ -1,9 +1,17 @@
1
1
  import { run, runStatus } from '../lib/run.js';
2
- export async function fixPackageHygiene(root) {
3
- await run('sherif', ['--fix', '--select', 'highest'], root);
2
+ const defaultShell = { run, runStatus };
3
+ export async function fixPackageHygiene(root, verboseOrShell = false, maybeShell = defaultShell) {
4
+ const verbose = typeof verboseOrShell === 'boolean' ? verboseOrShell : false;
5
+ const shell = typeof verboseOrShell === 'boolean' ? maybeShell : verboseOrShell;
6
+ const status = await shell.runStatus('sherif', ['-f', '--select', 'highest'], root, !verbose);
7
+ if (status !== 0) {
8
+ throw new Error(`sherif -f --select highest failed with exit code ${status}`);
9
+ }
4
10
  }
5
- export async function validatePackageHygiene(root) {
6
- const status = await runStatus('sherif', [], root);
11
+ export async function validatePackageHygiene(root, verboseOrShell = false, maybeShell = defaultShell) {
12
+ const verbose = typeof verboseOrShell === 'boolean' ? verboseOrShell : false;
13
+ const shell = typeof verboseOrShell === 'boolean' ? maybeShell : verboseOrShell;
14
+ const status = await shell.runStatus('sherif', ['--fail-on-warnings'], root, !verbose);
7
15
  if (status !== 0) {
8
16
  console.error('sherif package hygiene validation failed');
9
17
  return 1;
@@ -1,8 +1,31 @@
1
+ export interface WorkspaceDependencyDefaultOptions {
2
+ resolvedTargetsByProject?: ReadonlyMap<string, ReadonlySet<string> | ResolvedProjectTargets>;
3
+ }
4
+ export interface ResolvedProjectTargets {
5
+ targets: ReadonlySet<string>;
6
+ buildDependsOn?: readonly string[];
7
+ }
8
+ export declare const SMOO_NX_VERSION_ACTIONS = "@smoothbricks/cli/nx-version-actions";
9
+ export declare const SMOO_NX_RELEASE_TAG_PATTERN = "{projectName}@{version}";
10
+ export declare function applyFixableMonorepoDefaults(root: string): void;
11
+ export declare function applyRootScriptDefaults(root: string): void;
12
+ export declare function applyNxPluginDefaults(root: string): void;
1
13
  export declare function applyPublicPackageDefaults(root: string): void;
2
- export declare function applyWorkspaceDependencyDefaults(root: string): void;
14
+ export declare function applyWorkspaceDependencyDefaults(root: string, options?: WorkspaceDependencyDefaultOptions): void;
15
+ export declare function applyNxReleaseDefaults(root: string): void;
16
+ export declare function applyNxProjectNameDefaults(root: string): void;
17
+ export declare function listValidCommitScopes(root: string): ReadonlySet<string>;
18
+ export declare function listNxProjectNames(root: string): string[];
3
19
  export declare function validateRootPackagePolicy(root: string): number;
4
20
  export declare function validateNxReleaseConfig(root: string): number;
21
+ export declare function validateNxProjectNames(root: string): number;
5
22
  export declare function validatePublicTags(root: string): number;
6
23
  export declare function validatePublicPackageMetadata(root: string): number;
7
- export declare function validateWorkspaceDependencies(root: string): number;
24
+ export declare function validateWorkspaceDependencies(root: string, options?: WorkspaceDependencyDefaultOptions): number;
25
+ export declare function applyPackageScriptPolicy(pkg: Record<string, unknown>, _packagePath: string, workspaceNames: ReadonlySet<string>, options?: {
26
+ resolvedTargets?: ReadonlySet<string>;
27
+ }): boolean;
28
+ export declare function validatePackageScriptPolicy(pkg: Record<string, unknown>, packagePath: string, workspaceNames: ReadonlySet<string>, options?: {
29
+ resolvedTargets?: ReadonlySet<string>;
30
+ }): number;
8
31
  //# sourceMappingURL=package-policy.d.ts.map