@smoothbricks/cli 0.10.8 → 0.10.10
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/dist/cli.js +7 -5
- package/dist/github-ci/index.d.ts +9 -7
- package/dist/github-ci/index.d.ts.map +1 -1
- package/dist/github-ci/index.js +36 -35
- package/dist/monorepo/ci-workflow.d.ts +3 -0
- package/dist/monorepo/ci-workflow.d.ts.map +1 -1
- package/dist/monorepo/ci-workflow.js +59 -15
- package/dist/monorepo/managed-files.d.ts +1 -0
- package/dist/monorepo/managed-files.d.ts.map +1 -1
- package/dist/monorepo/managed-files.js +15 -5
- package/dist/monorepo/publish-workflow.d.ts +2 -2
- package/dist/monorepo/publish-workflow.d.ts.map +1 -1
- package/dist/monorepo/publish-workflow.js +7 -7
- package/dist/release/index.d.ts +1 -0
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +14 -6
- package/dist/wrangler/cloudflare.d.ts +4 -2
- package/dist/wrangler/cloudflare.d.ts.map +1 -1
- package/dist/wrangler/cloudflare.js +6 -3
- package/dist/wrangler/{deploy-environment.d.ts → deploy-stage.d.ts} +6 -6
- package/dist/wrangler/deploy-stage.d.ts.map +1 -0
- package/dist/wrangler/{deploy-environment.js → deploy-stage.js} +26 -26
- package/dist/wrangler/stage.d.ts +58 -0
- package/dist/wrangler/stage.d.ts.map +1 -0
- package/dist/wrangler/{environment.js → stage.js} +44 -44
- package/package.json +8 -8
- package/src/cli.ts +11 -8
- package/src/github-ci/index.test.ts +105 -34
- package/src/github-ci/index.ts +53 -46
- package/src/monorepo/__tests__/ci-workflow.test.ts +87 -49
- package/src/monorepo/__tests__/publish-workflow.test.ts +14 -12
- package/src/monorepo/ci-workflow.ts +67 -14
- package/src/monorepo/managed-files.test.ts +26 -5
- package/src/monorepo/managed-files.ts +18 -5
- package/src/monorepo/publish-workflow.ts +15 -12
- package/src/release/index.ts +12 -4
- package/src/wrangler/cloudflare.test.ts +76 -0
- package/src/wrangler/cloudflare.ts +6 -3
- package/src/wrangler/{deploy-environment.test.ts → deploy-stage.test.ts} +11 -11
- package/src/wrangler/{deploy-environment.ts → deploy-stage.ts} +41 -41
- package/src/wrangler/{environment.test.ts → stage.test.ts} +15 -15
- package/src/wrangler/{environment.ts → stage.ts} +49 -52
- package/dist/wrangler/deploy-environment.d.ts.map +0 -1
- package/dist/wrangler/environment.d.ts +0 -58
- package/dist/wrangler/environment.d.ts.map +0 -1
|
@@ -175,7 +175,7 @@ function shouldRunStep(step, version, failed, inputs) {
|
|
|
175
175
|
return version.mode !== 'none';
|
|
176
176
|
}
|
|
177
177
|
if (step.condition === 'deploy-production') {
|
|
178
|
-
return version.mode !== 'none' && inputs.
|
|
178
|
+
return version.mode !== 'none' && inputs.deployStage === 'production' && !inputs.dryRun;
|
|
179
179
|
}
|
|
180
180
|
if (step.condition === 'failure') {
|
|
181
181
|
return failed;
|
|
@@ -199,7 +199,7 @@ export function renderPublishWorkflowYaml(options = {}) {
|
|
|
199
199
|
function renderPublishWorkflowHeader(options) {
|
|
200
200
|
const deployInput = options.deploy === true
|
|
201
201
|
? `
|
|
202
|
-
|
|
202
|
+
deploy_stage:
|
|
203
203
|
type: choice
|
|
204
204
|
description: Deploy live systems after a successful publish.
|
|
205
205
|
options: [none, production]
|
|
@@ -377,10 +377,10 @@ function deployProductionStep(step, options) {
|
|
|
377
377
|
return [
|
|
378
378
|
` - name: ${step.name}`,
|
|
379
379
|
' if:',
|
|
380
|
-
" ${{ steps.version.outputs.mode != 'none' && inputs.
|
|
380
|
+
" ${{ steps.version.outputs.mode != 'none' && inputs.deploy_stage == 'production' && inputs.dry_run !=",
|
|
381
381
|
" 'true' }}",
|
|
382
382
|
...deployEnvLines(options),
|
|
383
|
-
' run: smoo github-ci nx-deploy --
|
|
383
|
+
' run: smoo github-ci nx-deploy --stage production --mode run-many --verify --name "Deploy Production"',
|
|
384
384
|
];
|
|
385
385
|
}
|
|
386
386
|
function deployEnvLines(options) {
|
|
@@ -413,7 +413,7 @@ function renderSingleJobPublishWorkflowSteps(steps, options) {
|
|
|
413
413
|
function renderPlatformPublishWorkflowYaml(options) {
|
|
414
414
|
const deployInput = options.deploy === true
|
|
415
415
|
? `
|
|
416
|
-
|
|
416
|
+
deploy_stage:
|
|
417
417
|
type: choice
|
|
418
418
|
description: Deploy live systems after a successful publish.
|
|
419
419
|
options: [none, production]
|
|
@@ -557,7 +557,7 @@ function renderMacosPlatformSteps(options) {
|
|
|
557
557
|
if (isSmoothBricksCodebasePackageName(options.repoName)) {
|
|
558
558
|
lines.push('', ` # Step ${stepNumber++}`, ' - name: 🏗️ Build self-hosted smoo', ' # SmoothBricks self-hosts smoo from source for release commands.', ' run: nx build cli');
|
|
559
559
|
}
|
|
560
|
-
lines.push('', ` # Step ${stepNumber++}`, ' - name: 🍎 Build selected macOS and iOS release outputs', ' run:', ` smoo release build-platform-outputs --bump "${githubExpression('inputs.bump')}" --ref "${githubExpression('github.sha')}" --targets "${MACOS_PLATFORM_TARGET_GLOBS.join(',')}" --output`, ` "${githubExpression('runner.temp')}/macos-platform-outputs"`, '', ` # Step ${stepNumber++}`, ' - name: 🧪 Unit test macOS and iOS packages', ' run:',
|
|
560
|
+
lines.push('', ` # Step ${stepNumber++}`, ' - name: 🍎 Build selected macOS and iOS release outputs', ' id: platform-outputs', ' run:', ` smoo release build-platform-outputs --bump "${githubExpression('inputs.bump')}" --ref "${githubExpression('github.sha')}" --targets "${MACOS_PLATFORM_TARGET_GLOBS.join(',')}" --output`, ` "${githubExpression('runner.temp')}/macos-platform-outputs" --github-output "$GITHUB_OUTPUT"`, '', ` # Step ${stepNumber++}`, ' - name: 🧪 Unit test selected macOS and iOS packages', ` if: steps.platform-outputs.outputs.projects != ''`, ' run:', ' smoo github-ci nx-run-many --targets test --projects', ` "${githubExpression('steps.platform-outputs.outputs.projects')}"`, '', ` # Step ${stepNumber++}`, ' - name: 📤 Upload macOS platform outputs', ' uses: actions/upload-artifact@v7.0.1', ' with:', ` name: publish-macos-outputs-${githubExpression('github.run_id')}`, ` path: ${githubExpression('runner.temp')}/macos-platform-outputs`, ' if-no-files-found: error', ' retention-days: 1', ' include-hidden-files: true', '', ' # --- Cleanup ------------------------------------------------------------', '', ` # Step ${stepNumber}`, ' - name: 🧹 Cleanup and cache Nix/devenv', ' # success() is default; always() still saves GH Nix cache after a red job.', ' if: always()', ' uses: ./.github/actions/save-nix-devenv', ' with:', ` nix-cache-hit: ${githubExpression('steps.setup.outputs.nix-cache-hit')}`, ` devenv-cache-hit: ${githubExpression('steps.setup.outputs.devenv-cache-hit')}`);
|
|
561
561
|
return lines.join('\n').trimEnd();
|
|
562
562
|
}
|
|
563
563
|
function renderFinalLinuxPublishSteps(options) {
|
|
@@ -606,7 +606,7 @@ function renderFinalLinuxPublishSteps(options) {
|
|
|
606
606
|
}
|
|
607
607
|
lines.push('', ` # Step ${stepNumber++}`, ' - name: 🍎 Apply verified macOS outputs', ` if: ${mode} != 'none'`, ' run:', ` smoo github-ci apply-outputs --source-sha "${githubExpression('github.sha')}"`, ` "${githubExpression('runner.temp')}/publish-artifacts/publish-macos-outputs-${githubExpression('github.run_id')}/current"`, '', ` # Step ${stepNumber++}`, ` - name: ✅ Validate restored release (${githubExpression(mode)})`, ` if: ${mode} != 'none'`, ' run: smoo monorepo validate', '', ' # --- Release ------------------------------------------------------------', '', ` # Step ${stepNumber++}`, ` - name: 📦 Publish release (${githubExpression(mode)})`, ' # smoo packs with Bun, then publishes tarballs with npm. Existing', ' # packages must already exist on npm and use trusted publishing/OIDC.', ' # Missing package names are bootstrapped locally before trust setup.', ` run: smoo release publish --bump "${githubExpression('inputs.bump')}" --dry-run "${githubExpression('inputs.dry_run')}"`);
|
|
608
608
|
if (options.deploy === true) {
|
|
609
|
-
lines.push('', ` # Step ${stepNumber++}`, ' - name: 🚀 Deploy production', ' if:', " ${{ needs.linux-release-candidate.outputs.mode != 'none' && inputs.
|
|
609
|
+
lines.push('', ` # Step ${stepNumber++}`, ' - name: 🚀 Deploy production', ' if:', " ${{ needs.linux-release-candidate.outputs.mode != 'none' && inputs.deploy_stage == 'production' &&", " inputs.dry_run != 'true' }}", ...deployEnvLines(options), ' run: smoo github-ci nx-deploy --stage production --mode run-many --verify --name "Deploy Production"');
|
|
610
610
|
}
|
|
611
611
|
lines.push('', ' # --- Cleanup ------------------------------------------------------------', '', ` # Step ${stepNumber}`, ' - name: 🧹 Cleanup and cache Nix/devenv', ' # success() is default; always() still saves GH Nix cache after a red job.', ' if: always()', ' uses: ./.github/actions/save-nix-devenv', ' with:', ` nix-cache-hit: ${githubExpression('steps.setup.outputs.nix-cache-hit')}`, ` devenv-cache-hit: ${githubExpression('steps.setup.outputs.devenv-cache-hit')}`);
|
|
612
612
|
return lines.join('\n').trimEnd();
|
package/dist/release/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/release/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAML,KAAK,kBAAkB,EAGxB,MAAM,WAAW,CAAC;AAsBnB,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CA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BAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAShF;AA8CD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAkB9F"}
|
package/dist/release/index.js
CHANGED
|
@@ -104,7 +104,7 @@ export async function releaseCollectPlatformOutputs(root, options) {
|
|
|
104
104
|
? 'Release platform outputs: no current release packages selected.'
|
|
105
105
|
: `Release platform outputs: building current outputs for ${packageSummary(currentPackages)}.`);
|
|
106
106
|
const outputRoot = resolve(root, options.output);
|
|
107
|
-
await githubCiNxRunMany(root, {
|
|
107
|
+
const currentRuns = await githubCiNxRunMany(root, {
|
|
108
108
|
targets: options.targets,
|
|
109
109
|
projects: releasePackageProjects(currentPackages),
|
|
110
110
|
collectOutputs: join(outputRoot, 'current'),
|
|
@@ -114,6 +114,12 @@ export async function releaseCollectPlatformOutputs(root, options) {
|
|
|
114
114
|
const targets = await listPendingReleaseTargets(root, releaseRef);
|
|
115
115
|
logPendingReleaseTargets(targets);
|
|
116
116
|
await collectRepairPlatformOutputs(releaseRepairOutputsShell(root, options.targets, join(outputRoot, 'repairs')), targets, restoreRef);
|
|
117
|
+
if (options.githubOutput) {
|
|
118
|
+
const projects = [
|
|
119
|
+
...new Set(currentRuns.runs.flatMap((run) => run.projects.map((project) => project.project))),
|
|
120
|
+
].sort((left, right) => left.localeCompare(right));
|
|
121
|
+
await appendFile(options.githubOutput, `projects=${projects.join(',')}\n`);
|
|
122
|
+
}
|
|
117
123
|
}
|
|
118
124
|
export async function releaseTrustPublisher(root, options) {
|
|
119
125
|
const repository = githubRepositoryFromRootPackage(root);
|
|
@@ -653,11 +659,13 @@ function releaseRepairShell(root, platformOutputs) {
|
|
|
653
659
|
function releaseRepairOutputsShell(root, targetGlobs, outputRoot) {
|
|
654
660
|
return {
|
|
655
661
|
...releaseTargetCheckoutShell(root),
|
|
656
|
-
collectRepairTargetOutputs: (target) =>
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
662
|
+
collectRepairTargetOutputs: async (target) => {
|
|
663
|
+
await githubCiNxRunMany(root, {
|
|
664
|
+
targets: targetGlobs,
|
|
665
|
+
projects: releasePackageProjects(target.npmPackages),
|
|
666
|
+
collectOutputs: join(outputRoot, target.sha),
|
|
667
|
+
});
|
|
668
|
+
},
|
|
661
669
|
};
|
|
662
670
|
}
|
|
663
671
|
function releaseRetagShell(root, remote) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LiveKvNamespace } from './
|
|
1
|
+
import type { LiveKvNamespace } from './stage.js';
|
|
2
2
|
export interface R2Bucket {
|
|
3
3
|
name: string;
|
|
4
4
|
}
|
|
@@ -53,11 +53,12 @@ export declare class CloudflareApiError extends Error {
|
|
|
53
53
|
readonly codes: number[];
|
|
54
54
|
constructor(message: string, status: number, codes: number[]);
|
|
55
55
|
}
|
|
56
|
+
type CloudflareFetcher = (input: string, init?: RequestInit) => Promise<Response>;
|
|
56
57
|
export declare class CloudflareRestClient implements CloudflareClient {
|
|
57
58
|
private readonly apiToken;
|
|
58
59
|
private readonly fetcher;
|
|
59
60
|
private readonly accountPath;
|
|
60
|
-
constructor(accountId: string, apiToken: string, fetcher?:
|
|
61
|
+
constructor(accountId: string, apiToken: string, fetcher?: CloudflareFetcher);
|
|
61
62
|
listKvNamespaces(): Promise<LiveKvNamespace[]>;
|
|
62
63
|
createKvNamespace(title: string): Promise<LiveKvNamespace>;
|
|
63
64
|
deleteKvNamespace(id: string): Promise<void>;
|
|
@@ -82,4 +83,5 @@ export declare class CloudflareRestClient implements CloudflareClient {
|
|
|
82
83
|
private result;
|
|
83
84
|
private request;
|
|
84
85
|
}
|
|
86
|
+
export {};
|
|
85
87
|
//# sourceMappingURL=cloudflare.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../src/wrangler/cloudflare.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input["code"];
|
|
4
|
+
const _ip1 = input => undefined === input["message"] || "string" === typeof input["message"];
|
|
5
|
+
const _io0 = input => "boolean" === typeof input.success && true && (null === input.errors || undefined === input.errors || Array.isArray(input.errors) && input.errors.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io1(elem))) && (null === input.messages || undefined === input.messages || Array.isArray(input.messages) && input.messages.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io2(elem))) && (undefined === input.result_info || "object" === typeof input.result_info && null !== input.result_info && false === Array.isArray(input.result_info) && _io3(input.result_info));
|
|
6
|
+
const _io1 = input => _ip0(input) && _ip1(input);
|
|
7
|
+
const _io2 = input => _ip0(input) && _ip1(input);
|
|
8
|
+
const _io3 = input => (undefined === input.page || "number" === typeof input.page) && (undefined === input.total_pages || "number" === typeof input.total_pages) && (undefined === input.cursor || "string" === typeof input.cursor) && (undefined === input.is_truncated || "boolean" === typeof input.is_truncated);
|
|
6
9
|
return input => "object" === typeof input && null !== input && _io0(input);
|
|
7
10
|
})();
|
|
8
11
|
const isKvNamespaces = (() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CloudflareClient } from './cloudflare.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type DeploymentStage } from './stage.js';
|
|
3
3
|
export interface ProcessResult {
|
|
4
4
|
exitCode: number;
|
|
5
5
|
stdout: string;
|
|
@@ -22,15 +22,15 @@ export interface WranglerCommandDependencies {
|
|
|
22
22
|
cloudflare?: CloudflareClient;
|
|
23
23
|
processEnv?: NodeJS.ProcessEnv;
|
|
24
24
|
}
|
|
25
|
-
export interface
|
|
26
|
-
|
|
25
|
+
export interface DeployStageResult {
|
|
26
|
+
stage: DeploymentStage;
|
|
27
27
|
workerName: string;
|
|
28
28
|
action: 'deployed' | 'activated' | 'remote-cache-hit';
|
|
29
29
|
versionTag?: string;
|
|
30
30
|
}
|
|
31
|
-
export declare function
|
|
31
|
+
export declare function deployStage(cwd: string, stageValue: string, dependencies?: WranglerCommandDependencies): Promise<DeployStageResult>;
|
|
32
32
|
export interface CleanupResult {
|
|
33
|
-
|
|
33
|
+
stage: `pr${number}`;
|
|
34
34
|
deleted: {
|
|
35
35
|
workers: number;
|
|
36
36
|
routes: number;
|
|
@@ -45,4 +45,4 @@ export declare function cleanupPullRequest(cwd: string, prNumber: number, depend
|
|
|
45
45
|
export declare function nxTaskVersionTag(environment: NodeJS.ProcessEnv): string | undefined;
|
|
46
46
|
export declare function findVersionIdByTag(value: unknown, tag: string): string | null;
|
|
47
47
|
export declare function isFullCurrentDeployment(value: unknown, versionId: string): boolean;
|
|
48
|
-
//# sourceMappingURL=deploy-
|
|
48
|
+
//# sourceMappingURL=deploy-stage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-stage.d.ts","sourceRoot":"","sources":["../../src/wrangler/deploy-stage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,gBAAgB,EAAwB,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAEL,KAAK,eAAe,EASrB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACtH;AAED,qBAAa,gBAAiB,YAAW,aAAa;IAC9C,GAAG,CACP,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CA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EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAelF"}
|
|
@@ -4,8 +4,8 @@ import { readFile, rm, writeFile } from 'node:fs/promises';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import typia from 'typia';
|
|
6
6
|
import { CloudflareRestClient } from './cloudflare.js';
|
|
7
|
-
import { derivePullRequestWranglerConfig, environmentResourceName, hasExactEnvironmentSegment, isPullRequestEnvironment, parseEnvironmentToken, planConfiguredEnvironmentResources, planPullRequestResources, pullRequestEnvironment, } from './environment.js';
|
|
8
7
|
import { parseDevVarsExample } from './prepare-env.js';
|
|
8
|
+
import { derivePullRequestWranglerConfig, hasExactStageSegment, isPullRequestStage, parseDeploymentStage, planConfiguredStageResources, planPullRequestResources, pullRequestStage, stageResourceName, } from './stage.js';
|
|
9
9
|
export class BunProcessRunner {
|
|
10
10
|
async run(command, args, options) {
|
|
11
11
|
const child = Bun.spawn([command, ...args], {
|
|
@@ -32,8 +32,8 @@ const isUnknownRecord = (() => {
|
|
|
32
32
|
});
|
|
33
33
|
return input => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
|
|
34
34
|
})();
|
|
35
|
-
export async function
|
|
36
|
-
const
|
|
35
|
+
export async function deployStage(cwd, stageValue, dependencies = {}) {
|
|
36
|
+
const stage = parseDeploymentStage(stageValue);
|
|
37
37
|
const processEnv = dependencies.processEnv ?? process.env;
|
|
38
38
|
const accountId = processEnv.CLOUDFLARE_ACCOUNT_ID;
|
|
39
39
|
const apiToken = processEnv.CLOUDFLARE_API_TOKEN;
|
|
@@ -56,18 +56,18 @@ export async function deployEnvironment(cwd, environmentValue, dependencies = {}
|
|
|
56
56
|
let temporaryConfigPath;
|
|
57
57
|
let temporarySecretsPath;
|
|
58
58
|
try {
|
|
59
|
-
if (
|
|
60
|
-
const staging =
|
|
59
|
+
if (isPullRequestStage(stage)) {
|
|
60
|
+
const staging = planConfiguredStageResources(committedToml, 'staging');
|
|
61
61
|
if (!staging.workerName.endsWith('-staging')) {
|
|
62
62
|
throw new Error('[env.staging].name must end with the exact suffix -staging.');
|
|
63
63
|
}
|
|
64
|
-
const workerName =
|
|
64
|
+
const workerName = stageResourceName(staging.workerName.slice(0, -'-staging'.length), stage);
|
|
65
65
|
const firstDeployment = !(await cloudflare.listWorkerScripts()).some((script) => script.id === workerName);
|
|
66
66
|
if (firstDeployment && missingSecrets.length > 0) {
|
|
67
67
|
throw new Error(`First deployment of ${workerName} requires process environment values for: ${missingSecrets.join(', ')}.`);
|
|
68
68
|
}
|
|
69
69
|
const liveNamespaces = await cloudflare.listKvNamespaces();
|
|
70
|
-
const plan = planPullRequestResources(committedToml,
|
|
70
|
+
const plan = planPullRequestResources(committedToml, stage, liveNamespaces);
|
|
71
71
|
const derivedIds = new Map();
|
|
72
72
|
const byTitle = new Map(liveNamespaces.map((namespace) => [namespace.title, namespace]));
|
|
73
73
|
for (const namespace of plan.kvNamespaces) {
|
|
@@ -86,7 +86,7 @@ export async function deployEnvironment(cwd, environmentValue, dependencies = {}
|
|
|
86
86
|
derivedIds.set(namespace.stagingId, live.id);
|
|
87
87
|
}
|
|
88
88
|
const derivedToml = derivePullRequestWranglerConfig(committedToml, {
|
|
89
|
-
|
|
89
|
+
stage: stage,
|
|
90
90
|
accountId,
|
|
91
91
|
kvNamespaceIds: derivedIds,
|
|
92
92
|
});
|
|
@@ -95,16 +95,16 @@ export async function deployEnvironment(cwd, environmentValue, dependencies = {}
|
|
|
95
95
|
configPath = temporaryConfigPath;
|
|
96
96
|
}
|
|
97
97
|
const toml = configPath === committedConfigPath ? committedToml : await readFile(configPath, 'utf8');
|
|
98
|
-
const plan =
|
|
99
|
-
const workerExists = await
|
|
98
|
+
const plan = planConfiguredStageResources(toml, stage);
|
|
99
|
+
const workerExists = await reconcileStageResources(plan, cloudflare);
|
|
100
100
|
const versionTag = nxTaskVersionTag(processEnv);
|
|
101
|
-
const commandContext = { cwd, configPath,
|
|
101
|
+
const commandContext = { cwd, configPath, stage, workerName: plan.workerName };
|
|
102
102
|
if (versionTag && workerExists) {
|
|
103
103
|
const versions = await wranglerJson(runner, ['versions', 'list', '--name', plan.workerName, '--json'], cwd);
|
|
104
104
|
const deployments = await wranglerJson(runner, ['deployments', 'status', '--name', plan.workerName, '--json'], cwd);
|
|
105
105
|
const versionId = findVersionIdByTag(versions, versionTag);
|
|
106
106
|
if (versionId && isFullCurrentDeployment(deployments, versionId)) {
|
|
107
|
-
return {
|
|
107
|
+
return { stage, workerName: plan.workerName, action: 'remote-cache-hit', versionTag };
|
|
108
108
|
}
|
|
109
109
|
if (versionId) {
|
|
110
110
|
await wrangler(runner, [
|
|
@@ -117,13 +117,13 @@ export async function deployEnvironment(cwd, environmentValue, dependencies = {}
|
|
|
117
117
|
'--config',
|
|
118
118
|
configPath,
|
|
119
119
|
'--env',
|
|
120
|
-
|
|
120
|
+
stage,
|
|
121
121
|
'--yes',
|
|
122
122
|
], cwd);
|
|
123
|
-
return {
|
|
123
|
+
return { stage, workerName: plan.workerName, action: 'activated', versionTag };
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
const deployArgs = ['deploy', '--config', commandContext.configPath, '--env', commandContext.
|
|
126
|
+
const deployArgs = ['deploy', '--config', commandContext.configPath, '--env', commandContext.stage];
|
|
127
127
|
if (versionTag)
|
|
128
128
|
deployArgs.push('--tag', versionTag);
|
|
129
129
|
if (Object.keys(secretValues).length > 0) {
|
|
@@ -133,7 +133,7 @@ export async function deployEnvironment(cwd, environmentValue, dependencies = {}
|
|
|
133
133
|
}
|
|
134
134
|
await wrangler(runner, deployArgs, cwd);
|
|
135
135
|
return {
|
|
136
|
-
|
|
136
|
+
stage,
|
|
137
137
|
workerName: commandContext.workerName,
|
|
138
138
|
action: 'deployed',
|
|
139
139
|
...(versionTag ? { versionTag } : {}),
|
|
@@ -149,7 +149,7 @@ export async function deployEnvironment(cwd, environmentValue, dependencies = {}
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
export async function cleanupPullRequest(cwd, prNumber, dependencies = {}) {
|
|
152
|
-
const
|
|
152
|
+
const stage = pullRequestStage(prNumber);
|
|
153
153
|
const processEnv = dependencies.processEnv ?? process.env;
|
|
154
154
|
const cloudflare = dependencies.cloudflare ??
|
|
155
155
|
new CloudflareRestClient(requiredEnvironmentValue(processEnv.CLOUDFLARE_ACCOUNT_ID, 'CLOUDFLARE_ACCOUNT_ID'), requiredEnvironmentValue(processEnv.CLOUDFLARE_API_TOKEN, 'CLOUDFLARE_API_TOKEN'));
|
|
@@ -164,39 +164,39 @@ export async function cleanupPullRequest(cwd, prNumber, dependencies = {}) {
|
|
|
164
164
|
dnsRecords: 0,
|
|
165
165
|
};
|
|
166
166
|
for (const domain of await cloudflare.listWorkerDomains()) {
|
|
167
|
-
if (!
|
|
167
|
+
if (!hasExactStageSegment(domain.hostname, stage))
|
|
168
168
|
continue;
|
|
169
169
|
await cloudflare.deleteWorkerDomain(domain.id);
|
|
170
170
|
deleted.domains += 1;
|
|
171
171
|
}
|
|
172
172
|
for (const zone of await cloudflare.listZones()) {
|
|
173
173
|
for (const route of await cloudflare.listWorkerRoutes(zone.id)) {
|
|
174
|
-
if (!
|
|
174
|
+
if (!hasExactStageSegment(route.pattern, stage))
|
|
175
175
|
continue;
|
|
176
176
|
await cloudflare.deleteWorkerRoute(zone.id, route.id);
|
|
177
177
|
deleted.routes += 1;
|
|
178
178
|
}
|
|
179
179
|
for (const record of await cloudflare.listDnsRecords(zone.id)) {
|
|
180
|
-
if (!
|
|
180
|
+
if (!hasExactStageSegment(record.name, stage))
|
|
181
181
|
continue;
|
|
182
182
|
await cloudflare.deleteDnsRecord(zone.id, record.id);
|
|
183
183
|
deleted.dnsRecords += 1;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
for (const script of await cloudflare.listWorkerScripts()) {
|
|
187
|
-
if (!
|
|
187
|
+
if (!hasExactStageSegment(script.id, stage))
|
|
188
188
|
continue;
|
|
189
189
|
await cloudflare.deleteWorkerScript(script.id);
|
|
190
190
|
deleted.workers += 1;
|
|
191
191
|
}
|
|
192
192
|
for (const namespace of await cloudflare.listKvNamespaces()) {
|
|
193
|
-
if (!
|
|
193
|
+
if (!hasExactStageSegment(namespace.title, stage))
|
|
194
194
|
continue;
|
|
195
195
|
await cloudflare.deleteKvNamespace(namespace.id);
|
|
196
196
|
deleted.kvNamespaces += 1;
|
|
197
197
|
}
|
|
198
198
|
for (const bucket of await cloudflare.listR2Buckets()) {
|
|
199
|
-
if (!
|
|
199
|
+
if (!hasExactStageSegment(bucket.name, stage))
|
|
200
200
|
continue;
|
|
201
201
|
for (const key of await cloudflare.listR2Objects(bucket.name)) {
|
|
202
202
|
await cloudflare.deleteR2Object(bucket.name, key);
|
|
@@ -205,9 +205,9 @@ export async function cleanupPullRequest(cwd, prNumber, dependencies = {}) {
|
|
|
205
205
|
await cloudflare.deleteR2Bucket(bucket.name);
|
|
206
206
|
deleted.r2Buckets += 1;
|
|
207
207
|
}
|
|
208
|
-
return {
|
|
208
|
+
return { stage, deleted };
|
|
209
209
|
}
|
|
210
|
-
async function
|
|
210
|
+
async function reconcileStageResources(plan, cloudflare) {
|
|
211
211
|
const namespaces = await cloudflare.listKvNamespaces();
|
|
212
212
|
const namespaceIds = new Set(namespaces.map((namespace) => namespace.id));
|
|
213
213
|
for (const binding of plan.kvNamespaces) {
|
|
@@ -305,7 +305,7 @@ export function nxTaskVersionTag(environment) {
|
|
|
305
305
|
if (!underNx)
|
|
306
306
|
return undefined;
|
|
307
307
|
if (!hash)
|
|
308
|
-
throw new Error('NX_TASK_HASH is required when deploy-
|
|
308
|
+
throw new Error('NX_TASK_HASH is required when deploy-stage runs under Nx.');
|
|
309
309
|
if (/^(?:0|[1-9][0-9]*)$/.test(hash)) {
|
|
310
310
|
return `nx-${hash}`;
|
|
311
311
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type DeploymentStage = 'staging' | 'production' | `pr${number}`;
|
|
2
|
+
export declare function pullRequestStage(prNumber: number): `pr${number}`;
|
|
3
|
+
export declare function parseDeploymentStage(value: string): DeploymentStage;
|
|
4
|
+
export declare function isPullRequestStage(stage: DeploymentStage): stage is `pr${number}`;
|
|
5
|
+
export declare function stageDomain(stage: string, zone: string): string;
|
|
6
|
+
export declare function stageResourceName(base: string, stage: string): string;
|
|
7
|
+
export declare function hasExactStageSegment(value: string, stage: `pr${number}`): boolean;
|
|
8
|
+
export interface KvBinding {
|
|
9
|
+
binding: string;
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
export interface R2Binding {
|
|
13
|
+
binding: string;
|
|
14
|
+
bucketName: string;
|
|
15
|
+
}
|
|
16
|
+
export interface LiveKvNamespace {
|
|
17
|
+
id: string;
|
|
18
|
+
title: string;
|
|
19
|
+
}
|
|
20
|
+
export interface PullRequestKvResource {
|
|
21
|
+
binding: string;
|
|
22
|
+
stagingId: string;
|
|
23
|
+
stagingTitle: string;
|
|
24
|
+
title: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PullRequestResourcePlan {
|
|
27
|
+
stage: `pr${number}`;
|
|
28
|
+
workerName: string;
|
|
29
|
+
workerBaseName: string;
|
|
30
|
+
kvNamespaces: PullRequestKvResource[];
|
|
31
|
+
r2Buckets: R2Binding[];
|
|
32
|
+
routes: Array<{
|
|
33
|
+
pattern: string;
|
|
34
|
+
zoneName?: string;
|
|
35
|
+
customDomain: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export interface ConfiguredStageResourcePlan {
|
|
39
|
+
stage: DeploymentStage;
|
|
40
|
+
workerName: string;
|
|
41
|
+
kvNamespaces: KvBinding[];
|
|
42
|
+
r2Buckets: R2Binding[];
|
|
43
|
+
routes: Array<{
|
|
44
|
+
pattern: string;
|
|
45
|
+
zoneName?: string;
|
|
46
|
+
customDomain: boolean;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export declare function planConfiguredStageResources(toml: string, stage: DeploymentStage): ConfiguredStageResourcePlan;
|
|
50
|
+
export declare function planPullRequestResources(toml: string, stage: `pr${number}`, liveNamespaces: LiveKvNamespace[]): PullRequestResourcePlan;
|
|
51
|
+
export interface DerivePullRequestConfigOptions {
|
|
52
|
+
stage: `pr${number}`;
|
|
53
|
+
accountId: string;
|
|
54
|
+
kvNamespaceIds: ReadonlyMap<string, string>;
|
|
55
|
+
}
|
|
56
|
+
export declare function derivePullRequestWranglerConfig(toml: string, options: DerivePullRequestConfigOptions): string;
|
|
57
|
+
export declare function rateLimitNamespaceId(accountId: string, workerBaseName: string, stage: string, bindingName: string): string;
|
|
58
|
+
//# sourceMappingURL=stage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage.d.ts","sourceRoot":"","sources":["../../src/wrangler/stage.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,MAAM,EAAE,CAAC;AAKvE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,CAKhE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAQnE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,IAAI,KAAK,MAAM,EAAE,CAEjF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAM/D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMrE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,GAAG,OAAO,CAGjF;AAgBD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ;AACD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IACh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