@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.
- package/README.md +25 -13
- package/dist/cli.js +24 -0
- package/dist/github-ci/index.d.ts +17 -2
- package/dist/github-ci/index.d.ts.map +1 -1
- package/dist/github-ci/index.js +145 -14
- package/dist/github-ci/outputs.d.ts +22 -0
- package/dist/github-ci/outputs.d.ts.map +1 -0
- package/dist/github-ci/outputs.js +649 -0
- package/dist/lib/conflict-markers.d.ts.map +1 -1
- package/dist/lib/workspace.d.ts +1 -1
- package/dist/lib/workspace.d.ts.map +1 -1
- package/dist/monorepo/ci-workflow.d.ts.map +1 -1
- package/dist/monorepo/ci-workflow.js +2 -1
- package/dist/monorepo/managed-files.d.ts +2 -0
- package/dist/monorepo/managed-files.d.ts.map +1 -1
- package/dist/monorepo/managed-files.js +50 -5
- package/dist/monorepo/package-policy.d.ts.map +1 -1
- package/dist/monorepo/package-policy.js +26 -0
- package/dist/monorepo/packs/index.d.ts +3 -0
- package/dist/monorepo/packs/index.d.ts.map +1 -1
- package/dist/monorepo/packs/index.js +5 -2
- package/dist/monorepo/publish-workflow.d.ts +1 -0
- package/dist/monorepo/publish-workflow.d.ts.map +1 -1
- package/dist/monorepo/publish-workflow.js +240 -2
- package/dist/monorepo/tool-validation.d.ts.map +1 -1
- package/dist/monorepo/tool-validation.js +20 -7
- package/dist/nx/index.d.ts +6 -0
- package/dist/nx/index.d.ts.map +1 -1
- package/dist/nx/index.js +55 -5
- package/dist/release/github-release.d.ts +5 -2
- package/dist/release/github-release.d.ts.map +1 -1
- package/dist/release/github-release.js +11 -0
- package/dist/release/index.d.ts +19 -1
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +140 -31
- package/dist/release/orchestration.d.ts +8 -1
- package/dist/release/orchestration.d.ts.map +1 -1
- package/dist/release/orchestration.js +38 -1
- package/dist/wrangler/prepare-env.d.ts.map +1 -1
- package/dist/wrangler/prepare-env.js +1 -1
- package/dist/wrangler/scaffold.d.ts.map +1 -1
- package/dist/wrangler/scaffold.js +1 -1
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +5 -0
- package/managed/raw/tooling/direnv/setup-environment.ts +32 -1
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +12 -10
- package/managed/templates/github/actions/cache-node-modules/action.yml +3 -2
- package/managed/templates/github/actions/cache-nx/action.yml +2 -2
- package/managed/templates/github/actions/save-nix-devenv/action.yml +11 -3
- package/package.json +7 -14
- package/src/cli.ts +30 -4
- package/src/github-ci/index.test.ts +486 -0
- package/src/github-ci/index.ts +177 -16
- package/src/github-ci/outputs.ts +506 -0
- package/src/monorepo/__tests__/ci-workflow.test.ts +13 -0
- package/src/monorepo/__tests__/publish-workflow.test.ts +234 -5
- package/src/monorepo/ci-workflow.ts +3 -1
- package/src/monorepo/managed-files.test.ts +75 -0
- package/src/monorepo/managed-files.ts +61 -5
- package/src/monorepo/package-policy.test.ts +57 -38
- package/src/monorepo/package-policy.ts +28 -0
- package/src/monorepo/packs/index.test.ts +18 -1
- package/src/monorepo/packs/index.ts +7 -3
- package/src/monorepo/publish-workflow.ts +481 -2
- package/src/monorepo/tool-validation.test.ts +59 -24
- package/src/monorepo/tool-validation.ts +21 -7
- package/src/monorepo/wrangler.test.ts +9 -2
- package/src/nx/index.test.ts +39 -0
- package/src/nx/index.ts +65 -5
- package/src/release/__tests__/fixture-repo.test.ts +18 -16
- package/src/release/__tests__/github-release.test.ts +11 -0
- package/src/release/__tests__/orchestration.test.ts +57 -2
- package/src/release/__tests__/trust-publisher.test.ts +91 -2
- package/src/release/github-release.ts +12 -0
- package/src/release/index.ts +218 -40
- package/src/release/orchestration.ts +55 -3
- package/src/wrangler/prepare-env.ts +14 -4
- 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(
|
|
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')
|
|
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(
|
|
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') ?
|
|
345
|
+
return errText(err).includes('already') ? await reList(logical, cwd) : null;
|
|
336
346
|
}
|
|
337
347
|
return reList(logical, cwd);
|
|
338
348
|
}
|
package/src/wrangler/scaffold.ts
CHANGED
|
@@ -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(
|
|
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}\` :
|
|
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(
|
|
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
|
}
|