@smoothbricks/cli 0.10.1 → 0.10.3

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 (77) hide show
  1. package/README.md +25 -13
  2. package/dist/cli.js +24 -0
  3. package/dist/github-ci/index.d.ts +17 -2
  4. package/dist/github-ci/index.d.ts.map +1 -1
  5. package/dist/github-ci/index.js +145 -14
  6. package/dist/github-ci/outputs.d.ts +22 -0
  7. package/dist/github-ci/outputs.d.ts.map +1 -0
  8. package/dist/github-ci/outputs.js +649 -0
  9. package/dist/lib/conflict-markers.d.ts.map +1 -1
  10. package/dist/lib/workspace.d.ts +1 -1
  11. package/dist/lib/workspace.d.ts.map +1 -1
  12. package/dist/monorepo/ci-workflow.d.ts.map +1 -1
  13. package/dist/monorepo/ci-workflow.js +2 -1
  14. package/dist/monorepo/managed-files.d.ts +2 -0
  15. package/dist/monorepo/managed-files.d.ts.map +1 -1
  16. package/dist/monorepo/managed-files.js +50 -5
  17. package/dist/monorepo/package-policy.d.ts.map +1 -1
  18. package/dist/monorepo/package-policy.js +26 -0
  19. package/dist/monorepo/packs/index.d.ts +3 -0
  20. package/dist/monorepo/packs/index.d.ts.map +1 -1
  21. package/dist/monorepo/packs/index.js +5 -2
  22. package/dist/monorepo/publish-workflow.d.ts +1 -0
  23. package/dist/monorepo/publish-workflow.d.ts.map +1 -1
  24. package/dist/monorepo/publish-workflow.js +240 -2
  25. package/dist/monorepo/tool-validation.d.ts.map +1 -1
  26. package/dist/monorepo/tool-validation.js +20 -7
  27. package/dist/nx/index.d.ts +6 -0
  28. package/dist/nx/index.d.ts.map +1 -1
  29. package/dist/nx/index.js +55 -5
  30. package/dist/release/github-release.d.ts +5 -2
  31. package/dist/release/github-release.d.ts.map +1 -1
  32. package/dist/release/github-release.js +11 -0
  33. package/dist/release/index.d.ts +19 -1
  34. package/dist/release/index.d.ts.map +1 -1
  35. package/dist/release/index.js +140 -31
  36. package/dist/release/orchestration.d.ts +8 -1
  37. package/dist/release/orchestration.d.ts.map +1 -1
  38. package/dist/release/orchestration.js +38 -1
  39. package/dist/wrangler/prepare-env.d.ts.map +1 -1
  40. package/dist/wrangler/prepare-env.js +1 -1
  41. package/dist/wrangler/scaffold.d.ts.map +1 -1
  42. package/dist/wrangler/scaffold.js +1 -1
  43. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +5 -0
  44. package/managed/raw/tooling/direnv/setup-environment.ts +32 -1
  45. package/managed/templates/github/actions/cache-nix-devenv/action.yml +12 -10
  46. package/managed/templates/github/actions/cache-node-modules/action.yml +3 -2
  47. package/managed/templates/github/actions/cache-nx/action.yml +2 -2
  48. package/managed/templates/github/actions/save-nix-devenv/action.yml +11 -3
  49. package/package.json +7 -14
  50. package/src/cli.ts +30 -4
  51. package/src/github-ci/index.test.ts +486 -0
  52. package/src/github-ci/index.ts +177 -16
  53. package/src/github-ci/outputs.ts +506 -0
  54. package/src/monorepo/__tests__/ci-workflow.test.ts +13 -0
  55. package/src/monorepo/__tests__/publish-workflow.test.ts +234 -5
  56. package/src/monorepo/ci-workflow.ts +3 -1
  57. package/src/monorepo/managed-files.test.ts +75 -0
  58. package/src/monorepo/managed-files.ts +61 -5
  59. package/src/monorepo/package-policy.test.ts +57 -38
  60. package/src/monorepo/package-policy.ts +28 -0
  61. package/src/monorepo/packs/index.test.ts +18 -1
  62. package/src/monorepo/packs/index.ts +7 -3
  63. package/src/monorepo/publish-workflow.ts +481 -2
  64. package/src/monorepo/tool-validation.test.ts +59 -24
  65. package/src/monorepo/tool-validation.ts +21 -7
  66. package/src/monorepo/wrangler.test.ts +9 -2
  67. package/src/nx/index.test.ts +39 -0
  68. package/src/nx/index.ts +65 -5
  69. package/src/release/__tests__/fixture-repo.test.ts +18 -16
  70. package/src/release/__tests__/github-release.test.ts +11 -0
  71. package/src/release/__tests__/orchestration.test.ts +57 -2
  72. package/src/release/__tests__/trust-publisher.test.ts +91 -2
  73. package/src/release/github-release.ts +12 -0
  74. package/src/release/index.ts +218 -40
  75. package/src/release/orchestration.ts +55 -3
  76. package/src/wrangler/prepare-env.ts +14 -4
  77. package/src/wrangler/scaffold.ts +8 -3
@@ -60,7 +60,13 @@ function kvIn(toml: string, table: AST.TOMLTable, key: string): AST.TOMLKeyValue
60
60
  }
61
61
 
62
62
  /** The `<field>` KV of the `[[env.<env>.<arrayKey>]]` table whose `binding` matches, or null. */
63
- function arrayTableKv(toml: string, env: string, arrayKey: string, binding: string, field: string): AST.TOMLKeyValue | null {
63
+ function arrayTableKv(
64
+ toml: string,
65
+ env: string,
66
+ arrayKey: string,
67
+ binding: string,
68
+ field: string,
69
+ ): AST.TOMLKeyValue | null {
64
70
  const block = envRecord(toml, env);
65
71
  const rows = isRecord(block) && Array.isArray(block[arrayKey]) ? block[arrayKey] : [];
66
72
  const index = rows.findIndex((r) => isRecord(r) && r.binding === binding);
@@ -173,7 +179,8 @@ export function getD1Name(toml: string, env: string, binding: string): string |
173
179
  const block = envRecord(toml, env);
174
180
  const rows = isRecord(block) && Array.isArray(block.d1_databases) ? block.d1_databases : [];
175
181
  for (const row of rows) {
176
- if (isRecord(row) && row.binding === binding && typeof row.database_name === 'string') return row.database_name || null;
182
+ if (isRecord(row) && row.binding === binding && typeof row.database_name === 'string')
183
+ return row.database_name || null;
177
184
  }
178
185
  return null;
179
186
  }
@@ -193,7 +200,10 @@ export function blankD1Ids(toml: string, env: string): string {
193
200
  /** Blank one field across every `[[env.<env>.<arrayKey>]]` table (value..EOL -> `""`). */
194
201
  function blankArrayField(toml: string, env: string, arrayKey: string, field: string): string {
195
202
  const edits = tables(toml)
196
- .filter((t) => t.kind === 'array' && t.resolvedKey[0] === 'env' && t.resolvedKey[1] === env && t.resolvedKey[2] === arrayKey)
203
+ .filter(
204
+ (t) =>
205
+ t.kind === 'array' && t.resolvedKey[0] === 'env' && t.resolvedKey[1] === env && t.resolvedKey[2] === arrayKey,
206
+ )
197
207
  .map((t) => kvIn(toml, t, field))
198
208
  .flatMap((kv) => (kv ? [{ start: kv.value.range[0], end: endOfLine(toml, kv.value.range[1]) }] : []));
199
209
  return applyBlanks(toml, edits);
@@ -332,7 +342,7 @@ export async function ensureNamespace(logical: string, existing: KvNamespace[],
332
342
  try {
333
343
  await $`bunx wrangler kv namespace create ${logical}`.cwd(cwd).quiet();
334
344
  } catch (err) {
335
- return errText(err).includes('already') ? (await reList(logical, cwd)) : null;
345
+ return errText(err).includes('already') ? await reList(logical, cwd) : null;
336
346
  }
337
347
  return reList(logical, cwd);
338
348
  }
@@ -16,7 +16,10 @@ export interface ScaffoldOptions {
16
16
  }
17
17
 
18
18
  /** Locate a workspace package by nx name, package name, or relative path; must have a wrangler.toml. */
19
- function resolveProject(root: string, project: string): { dir: string; label: string; packageJsonPath: string; json: Record<string, unknown> } {
19
+ function resolveProject(
20
+ root: string,
21
+ project: string,
22
+ ): { dir: string; label: string; packageJsonPath: string; json: Record<string, unknown> } {
20
23
  const manifests = getWorkspacePackageManifests(root);
21
24
  const match = manifests.find((m) => {
22
25
  const nx = recordProperty(m.json, 'nx');
@@ -83,7 +86,7 @@ async function checkMode(env: string): Promise<void> {
83
86
  for (const binding of kvBindings) {
84
87
  const inToml = pe.getKvId(toml, env, binding);
85
88
  const liveId = live.find((n) => n.title === kvTitle(binding, env))?.id ?? null;
86
- p.log.message(\` KV \${binding}: \${!liveId ? '✗ not created' : inToml === liveId ? \`✓ \${liveId}\` : \`⚠ drift (live \${liveId}, toml \${inToml ?? 'unset'})\`}\`);
89
+ p.log.message(\` KV \${binding}: \${!liveId ? '✗ not created' : inToml === liveId ? \`✓ \${liveId}\` : \`! drift (live \${liveId}, toml \${inToml ?? 'unset'})\`}\`);
87
90
  }
88
91
  for (const name of vars) {
89
92
  p.log.message(\` var \${name}: \${pe.getVar(toml, env, name) ? '✓ set' : '✗ empty'}\`);
@@ -234,6 +237,8 @@ export function scaffold(root: string, project: string, options: ScaffoldOptions
234
237
  console.log(`updated ${label}/package.json prepare-env target`);
235
238
  }
236
239
 
237
- console.log(`\nnext: fill secret NAMES in ${label}/.dev.vars.example, then\n bunx nx run ${project}:prepare-env -- <env>`);
240
+ console.log(
241
+ `\nnext: fill secret NAMES in ${label}/.dev.vars.example, then\n bunx nx run ${project}:prepare-env -- <env>`,
242
+ );
238
243
  return scriptPath;
239
244
  }