@smoothbricks/cli 0.11.18 → 0.11.20
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 +91 -11
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +28 -4
- package/dist/github-ci/index.d.ts.map +1 -1
- package/dist/github-ci/index.js +6 -20
- package/dist/lib/deploy-tags.d.ts +17 -3
- package/dist/lib/deploy-tags.d.ts.map +1 -1
- package/dist/lib/deploy-tags.js +23 -4
- package/dist/lib/json.d.ts +22 -1
- package/dist/lib/json.d.ts.map +1 -1
- package/dist/lib/json.js +15 -3
- package/dist/monorepo/cargo-policy.d.ts +17 -0
- package/dist/monorepo/cargo-policy.d.ts.map +1 -1
- package/dist/monorepo/cargo-policy.js +73 -1
- package/dist/monorepo/index.d.ts.map +1 -1
- package/dist/monorepo/index.js +4 -2
- package/dist/monorepo/managed-files.d.ts +5 -2
- package/dist/monorepo/managed-files.d.ts.map +1 -1
- package/dist/monorepo/managed-files.js +35 -21
- package/dist/monorepo/packs/index.d.ts.map +1 -1
- package/dist/monorepo/packs/index.js +6 -1
- package/dist/nx/index.d.ts +6 -0
- package/dist/nx/index.d.ts.map +1 -1
- package/dist/nx/index.js +14 -0
- package/dist/secrets/commands.d.ts +9 -5
- package/dist/secrets/commands.d.ts.map +1 -1
- package/dist/secrets/commands.js +122 -49
- package/dist/secrets/index.d.ts +42 -56
- package/dist/secrets/index.d.ts.map +1 -1
- package/dist/secrets/index.js +52 -79
- package/dist/secrets/resolver.d.ts +59 -0
- package/dist/secrets/resolver.d.ts.map +1 -0
- package/dist/secrets/resolver.js +100 -0
- package/dist/secrets/run.d.ts +23 -0
- package/dist/secrets/run.d.ts.map +1 -0
- package/dist/secrets/run.js +130 -0
- package/dist/secrets/status.d.ts +177 -0
- package/dist/secrets/status.d.ts.map +1 -0
- package/dist/secrets/status.js +724 -0
- package/dist/wrangler/deploy-stage.d.ts +1 -1
- package/dist/wrangler/deploy-stage.d.ts.map +1 -1
- package/dist/wrangler/deploy-stage.js +22 -20
- package/dist/wrangler/deployed-version.d.ts.map +1 -1
- package/dist/wrangler/deployed-version.js +7 -12
- package/dist/wrangler/flat-config.d.ts +1 -4
- package/dist/wrangler/flat-config.d.ts.map +1 -1
- package/dist/wrangler/flat-config.js +98 -44
- package/dist/wrangler/prepare-env.d.ts +4 -3
- package/dist/wrangler/prepare-env.d.ts.map +1 -1
- package/dist/wrangler/prepare-env.js +7 -5
- package/dist/wrangler/source-config.d.ts +24 -0
- package/dist/wrangler/source-config.d.ts.map +1 -0
- package/dist/wrangler/source-config.js +110 -0
- package/dist/wrangler/stage.d.ts +55 -23
- package/dist/wrangler/stage.d.ts.map +1 -1
- package/dist/wrangler/stage.js +81 -162
- package/managed/raw/tooling/direnv/devenv.smoo.nix +19 -3
- package/managed/raw/tooling/direnv/secret-references.ts +280 -76
- package/managed/raw/tooling/direnv/setup-environment.ts +58 -2
- package/managed/raw/tsconfig.lib.json +28 -0
- package/package.json +7 -2
- package/src/cli.ts +34 -5
- package/src/github-ci/index.test.ts +6 -7
- package/src/github-ci/index.ts +11 -19
- package/src/lib/deploy-tags.ts +22 -4
- package/src/lib/json.ts +23 -1
- package/src/monorepo/cargo-policy.test.ts +91 -1
- package/src/monorepo/cargo-policy.ts +87 -1
- package/src/monorepo/index.ts +8 -2
- package/src/monorepo/managed-files.test.ts +69 -37
- package/src/monorepo/managed-files.ts +38 -21
- package/src/monorepo/packs/index.ts +10 -1
- package/src/monorepo/secret-references.test.ts +412 -6
- package/src/monorepo/setup-environment.test.ts +181 -0
- package/src/nx/index.test.ts +8 -0
- package/src/nx/index.ts +20 -0
- package/src/secrets/commands.test.ts +186 -4
- package/src/secrets/commands.ts +142 -51
- package/src/secrets/index.test.ts +4 -10
- package/src/secrets/index.ts +54 -115
- package/src/secrets/resolver.ts +130 -0
- package/src/secrets/run.test.ts +359 -0
- package/src/secrets/run.ts +148 -0
- package/src/secrets/status.test.ts +164 -0
- package/src/secrets/status.ts +297 -0
- package/src/wrangler/deploy-stage.test.ts +95 -2
- package/src/wrangler/deploy-stage.ts +26 -23
- package/src/wrangler/deployed-version.ts +7 -11
- package/src/wrangler/flat-config.test.ts +9 -4
- package/src/wrangler/flat-config.ts +1 -20
- package/src/wrangler/format-parity.test.ts +433 -0
- package/src/wrangler/prepare-env.ts +7 -5
- package/src/wrangler/source-config.test.ts +102 -0
- package/src/wrangler/source-config.ts +110 -0
- package/src/wrangler/stage.test.ts +61 -32
- package/src/wrangler/stage.ts +124 -173
|
@@ -39,7 +39,7 @@ export interface DeployStageResult {
|
|
|
39
39
|
export interface DeployStageOptions {
|
|
40
40
|
/** `staging`, `production`, or `prN`. */
|
|
41
41
|
stage: string;
|
|
42
|
-
/** A build-generated flat wrangler.json to deploy instead of
|
|
42
|
+
/** A build-generated flat wrangler.json to deploy instead of the project's own config (see `prepareFlatConfig`). */
|
|
43
43
|
config?: string;
|
|
44
44
|
/**
|
|
45
45
|
* A URL, served by this worker, whose trimmed body is the running version tag. When given, the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-stage.d.ts","sourceRoot":"","sources":["../../src/wrangler/deploy-stage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,gBAAgB,EAA+C,MAAM,iBAAiB,CAAC;AAErG,OAAO,EAOL,KAAK,0BAA0B,EAEhC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy-stage.d.ts","sourceRoot":"","sources":["../../src/wrangler/deploy-stage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,gBAAgB,EAA+C,MAAM,iBAAiB,CAAC;AAErG,OAAO,EAOL,KAAK,0BAA0B,EAEhC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEL,KAAK,eAAe,EAarB,MAAM,YAAY,CAAC;AASpB,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf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;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,kBAAkB,EAC3B,YAAY,GAAE,2BAAgC,GAC7C,OAAO,CAAC,iBAAiB,CAAC,CAmH5B;AAgFD;;;;GAIG;AACH,iBAAe,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhF;AACD,eAAO,MAAM,2BAA2B,6BAAuB,CAAC;AAoHhE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,KAAK,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,2BAAgC,GAC7C,OAAO,CAAC,aAAa,CAAC,CAoFxB;AAwFD,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,SAAS,CAgBnF;AAyCD,uGAAuG;AACvG,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAOlH"}
|
|
@@ -4,9 +4,10 @@ import { dirname, join } from 'node:path';
|
|
|
4
4
|
import { parseJsonFileText } from '../lib/json.js';
|
|
5
5
|
import { mergeEnv, printCommandOutput } from '../lib/run.js';
|
|
6
6
|
import { CloudflareRestClient } from './cloudflare.js';
|
|
7
|
-
import { parseFlatWranglerConfig
|
|
7
|
+
import { parseFlatWranglerConfig } from './flat-config.js';
|
|
8
8
|
import { awaitLiveVersion, awaitVersionEndpoint, currentDeploymentVersionId, findVersionIdByTag, liveVersionCacheDirectory, writeCachedLiveVersion, } from './live-version.js';
|
|
9
|
-
import {
|
|
9
|
+
import { readWranglerSourceConfig } from './source-config.js';
|
|
10
|
+
import { derivePullRequestDocument, derivePullRequestStageConfig, hasExactStageSegment, isPullRequestStage, parseDeploymentStage, planConfiguredStageResources, planPullRequestBindings, planPullRequestResources, planStageResources, pullRequestStage, } from './stage.js';
|
|
10
11
|
import { planStageSecrets, readDeclaredSecretNames, readSecretStageMap, stageSecretRefusal, } from './stage-secrets.js';
|
|
11
12
|
/** The child environment `options` describe; every runner, test doubles included, spawns with exactly this. */
|
|
12
13
|
export function childEnvironment(options) {
|
|
@@ -54,7 +55,7 @@ export async function deployStage(cwd, options, dependencies = {}) {
|
|
|
54
55
|
try {
|
|
55
56
|
const prepared = options.config
|
|
56
57
|
? await prepareFlatConfig(options.config, stage, accountId, gate, cloudflare)
|
|
57
|
-
: await
|
|
58
|
+
: await prepareSourceConfig(cwd, stage, accountId, gate, cloudflare);
|
|
58
59
|
temporaryConfigPath = prepared.temporaryConfigPath;
|
|
59
60
|
// The pull-request path already ran this before provisioning; the gate answers once per Worker.
|
|
60
61
|
// Everything below here writes to Cloudflare.
|
|
@@ -136,32 +137,33 @@ export async function deployStage(cwd, options, dependencies = {}) {
|
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
/**
|
|
141
|
+
* The project's own `wrangler.jsonc`/`wrangler.json`/`wrangler.toml`, whichever it declares.
|
|
142
|
+
* Format stops mattering at `readWranglerSourceConfig`: everything below derives from the model.
|
|
143
|
+
*/
|
|
144
|
+
async function prepareSourceConfig(cwd, stage, accountId, gate, cloudflare) {
|
|
145
|
+
const source = readWranglerSourceConfig(cwd);
|
|
142
146
|
if (!isPullRequestStage(stage)) {
|
|
143
147
|
return {
|
|
144
|
-
deployConfigPath:
|
|
145
|
-
plan: planConfiguredStageResources(
|
|
148
|
+
deployConfigPath: source.path,
|
|
149
|
+
plan: planConfiguredStageResources(source.document, stage),
|
|
146
150
|
d1MigrationBindings: [],
|
|
147
151
|
envFlag: stage,
|
|
148
152
|
};
|
|
149
153
|
}
|
|
150
154
|
const liveNamespaces = await cloudflare.listKvNamespaces();
|
|
151
|
-
const plan = planPullRequestResources(
|
|
155
|
+
const plan = planPullRequestResources(source.document, stage, liveNamespaces);
|
|
152
156
|
const { kvNamespaceIds, d1DatabaseIds } = await provisionPullRequestResources(plan, gate, cloudflare, liveNamespaces);
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
});
|
|
159
|
-
const temporaryConfigPath = join(cwd, `.wrangler.smoo-${process.pid}-${randomUUID()}.toml`);
|
|
160
|
-
await writeTemporaryConfig(temporaryConfigPath, derivedToml);
|
|
157
|
+
const derived = derivePullRequestDocument(source.document, { stage, accountId, kvNamespaceIds, d1DatabaseIds });
|
|
158
|
+
// JSON whatever the source format was: wrangler picks its parser by extension, and a file
|
|
159
|
+
// written to be read once and deleted has no reader for the comments a TOML rewrite preserved.
|
|
160
|
+
// Beside the original, because its main/assets/migrations paths are relative to the file.
|
|
161
|
+
const temporaryConfigPath = join(dirname(source.path), `.wrangler.smoo-${process.pid}-${randomUUID()}.json`);
|
|
162
|
+
await writeTemporaryConfig(temporaryConfigPath, `${JSON.stringify(derived, null, 2)}\n`);
|
|
161
163
|
return {
|
|
162
164
|
deployConfigPath: temporaryConfigPath,
|
|
163
165
|
temporaryConfigPath,
|
|
164
|
-
plan: planConfiguredStageResources(
|
|
166
|
+
plan: planConfiguredStageResources(derived, stage),
|
|
165
167
|
d1MigrationBindings: [],
|
|
166
168
|
envFlag: stage,
|
|
167
169
|
};
|
|
@@ -171,7 +173,7 @@ async function prepareFlatConfig(configPath, stage, accountId, gate, cloudflare)
|
|
|
171
173
|
if (!isPullRequestStage(stage)) {
|
|
172
174
|
return {
|
|
173
175
|
deployConfigPath: configPath,
|
|
174
|
-
plan:
|
|
176
|
+
plan: planStageResources(flat, stage),
|
|
175
177
|
d1MigrationBindings: migrationBindings(flat),
|
|
176
178
|
};
|
|
177
179
|
}
|
|
@@ -185,7 +187,7 @@ async function prepareFlatConfig(configPath, stage, accountId, gate, cloudflare)
|
|
|
185
187
|
return {
|
|
186
188
|
deployConfigPath: temporaryConfigPath,
|
|
187
189
|
temporaryConfigPath,
|
|
188
|
-
plan:
|
|
190
|
+
plan: planStageResources(derived, stage),
|
|
189
191
|
d1MigrationBindings: migrationBindings(derived),
|
|
190
192
|
};
|
|
191
193
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployed-version.d.ts","sourceRoot":"","sources":["../../src/wrangler/deployed-version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deployed-version.d.ts","sourceRoot":"","sources":["../../src/wrangler/deployed-version.ts"],"names":[],"mappings":"AAQA,OAAO,EAAoB,KAAK,aAAa,EAAwC,MAAM,mBAAmB,CAAC;AAW/G,OAAO,EACL,KAAK,eAAe,EAOrB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,sBAAsB;IACrC,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,eAAe,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAW/G;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,sBAAsB,EAC/B,YAAY,GAAE,2BAAgC,GAC7C,OAAO,CAAC,qBAAqB,CAAC,CAqChC"}
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
// Read-only by construction: it resolves the worker name from the committed config and asks
|
|
4
4
|
// Cloudflare. It never provisions, never derives a pull-request stage's resources, and never
|
|
5
5
|
// writes anything except its own cache entry.
|
|
6
|
-
import { existsSync } from 'node:fs';
|
|
7
6
|
import { readFile } from 'node:fs/promises';
|
|
8
|
-
import { join } from 'node:path';
|
|
9
7
|
import { parseJsonFileText } from '../lib/json.js';
|
|
10
8
|
import { BunProcessRunner, wranglerJson } from './deploy-stage.js';
|
|
11
|
-
import { parseFlatWranglerConfig
|
|
9
|
+
import { parseFlatWranglerConfig } from './flat-config.js';
|
|
12
10
|
import { LIVE_VERSION_CACHE_TTL_MS, liveVersionCacheDirectory, readCachedLiveVersion, readLiveVersion, writeCachedLiveVersion, } from './live-version.js';
|
|
13
|
-
import {
|
|
11
|
+
import { readWranglerSourceConfig } from './source-config.js';
|
|
12
|
+
import { isPullRequestStage, parseDeploymentStage, planConfiguredStageResources, planStageResources, stageResourceName, stagingWorkerBaseName, } from './stage.js';
|
|
14
13
|
/**
|
|
15
14
|
* The worker `stage` deploys to, from committed configuration alone.
|
|
16
15
|
*
|
|
@@ -23,16 +22,12 @@ export async function stageWorkerName(cwd, stage, configPath) {
|
|
|
23
22
|
const flat = parseJsonFileText(configPath, await readFile(configPath, 'utf8'), parseFlatWranglerConfig);
|
|
24
23
|
return isPullRequestStage(stage)
|
|
25
24
|
? stageResourceName(stagingWorkerBaseName(flat.name), stage)
|
|
26
|
-
:
|
|
25
|
+
: planStageResources(flat, stage).workerName;
|
|
27
26
|
}
|
|
28
|
-
const
|
|
29
|
-
if (!existsSync(tomlPath)) {
|
|
30
|
-
throw new Error(`${tomlPath} does not exist; pass --config for a build-generated flat configuration.`);
|
|
31
|
-
}
|
|
32
|
-
const toml = await readFile(tomlPath, 'utf8');
|
|
27
|
+
const { document } = readWranglerSourceConfig(cwd);
|
|
33
28
|
return isPullRequestStage(stage)
|
|
34
|
-
? stageResourceName(stagingWorkerBaseName(planConfiguredStageResources(
|
|
35
|
-
: planConfiguredStageResources(
|
|
29
|
+
? stageResourceName(stagingWorkerBaseName(planConfiguredStageResources(document, 'staging').workerName), stage)
|
|
30
|
+
: planConfiguredStageResources(document, stage).workerName;
|
|
36
31
|
}
|
|
37
32
|
/**
|
|
38
33
|
* Answers with the tag serving 100% of this worker's traffic, or refuses.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StageConfigFields } from './stage.js';
|
|
2
2
|
/**
|
|
3
3
|
* A Wrangler configuration with no `env` blocks: the shape build tools emit
|
|
4
4
|
* once they have resolved an environment (the Cloudflare Vite and Astro
|
|
@@ -8,10 +8,7 @@ import type { ConfiguredStageResourcePlan, DeploymentStage, StageConfigFields }
|
|
|
8
8
|
*/
|
|
9
9
|
export interface FlatWranglerConfig extends StageConfigFields {
|
|
10
10
|
env?: unknown;
|
|
11
|
-
[key: string]: unknown;
|
|
12
11
|
}
|
|
13
12
|
/** Reads a build-generated Wrangler JSON, refusing anything that is not already resolved for one stage. */
|
|
14
13
|
export declare function parseFlatWranglerConfig(json: string): FlatWranglerConfig;
|
|
15
|
-
/** The reconcile plan (`reconcileStageResources`) read off a flat config for any stage. */
|
|
16
|
-
export declare function planFlatStageResources(config: FlatWranglerConfig, stage: DeploymentStage): ConfiguredStageResourcePlan;
|
|
17
14
|
//# sourceMappingURL=flat-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flat-config.d.ts","sourceRoot":"","sources":["../../src/wrangler/flat-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"flat-config.d.ts","sourceRoot":"","sources":["../../src/wrangler/flat-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAID,2GAA2G;AAC3G,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CASxE"}
|
|
@@ -16,7 +16,7 @@ const parseFlatWranglerConfigText = (() => {
|
|
|
16
16
|
expected: "string",
|
|
17
17
|
value: input["binding"]
|
|
18
18
|
});
|
|
19
|
-
const _io0 = input => _ip0(input) && (undefined === input.routes || Array.isArray(input.routes) && input.routes.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && (undefined === input.vars || "object" === typeof input.vars && null !== input.vars && false === Array.isArray(input.vars) && _io2(input.vars)) && (undefined === input.kv_namespaces || Array.isArray(input.kv_namespaces) && input.kv_namespaces.every(elem => "object" === typeof elem && null !== elem && _io3(elem))) && (undefined === input.r2_buckets || Array.isArray(input.r2_buckets) && input.r2_buckets.every(elem => "object" === typeof elem && null !== elem && _io4(elem))) && (undefined === input.d1_databases || Array.isArray(input.d1_databases) && input.d1_databases.every(elem => "object" === typeof elem && null !== elem && _io5(elem))) && (undefined === input.services || Array.isArray(input.services) && input.services.every(elem => "object" === typeof elem && null !== elem && _io6(elem))) && (undefined === input.ratelimits || Array.isArray(input.ratelimits) && input.ratelimits.every(elem => "object" === typeof elem && null !== elem && _io7(elem))) && (undefined === input.send_email || Array.isArray(input.send_email) && input.send_email.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) &&
|
|
19
|
+
const _io0 = input => _ip0(input) && (undefined === input.routes || Array.isArray(input.routes) && input.routes.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && (undefined === input.vars || "object" === typeof input.vars && null !== input.vars && false === Array.isArray(input.vars) && _io2(input.vars)) && (undefined === input.kv_namespaces || Array.isArray(input.kv_namespaces) && input.kv_namespaces.every(elem => "object" === typeof elem && null !== elem && _io3(elem))) && (undefined === input.r2_buckets || Array.isArray(input.r2_buckets) && input.r2_buckets.every(elem => "object" === typeof elem && null !== elem && _io4(elem))) && (undefined === input.d1_databases || Array.isArray(input.d1_databases) && input.d1_databases.every(elem => "object" === typeof elem && null !== elem && _io5(elem))) && (undefined === input.services || Array.isArray(input.services) && input.services.every(elem => "object" === typeof elem && null !== elem && _io6(elem))) && (undefined === input.ratelimits || Array.isArray(input.ratelimits) && input.ratelimits.every(elem => "object" === typeof elem && null !== elem && _io7(elem))) && (undefined === input.send_email || Array.isArray(input.send_email) && input.send_email.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io2(elem))) && true && Object.keys(input).every(key => {
|
|
20
20
|
if (["name", "routes", "vars", "kv_namespaces", "r2_buckets", "d1_databases", "services", "ratelimits", "send_email", "env"].some(prop => key === prop))
|
|
21
21
|
return true;
|
|
22
22
|
const value = input[key];
|
|
@@ -24,20 +24,54 @@ const parseFlatWranglerConfigText = (() => {
|
|
|
24
24
|
return true;
|
|
25
25
|
return true;
|
|
26
26
|
});
|
|
27
|
-
const _io1 = input => "string" === typeof input.pattern && (undefined === input.zone_name || "string" === typeof input.zone_name) && (undefined === input.custom_domain || "boolean" === typeof input.custom_domain)
|
|
27
|
+
const _io1 = input => "string" === typeof input.pattern && (undefined === input.zone_name || "string" === typeof input.zone_name) && (undefined === input.custom_domain || "boolean" === typeof input.custom_domain) && Object.keys(input).every(key => {
|
|
28
|
+
if (["pattern", "zone_name", "custom_domain"].some(prop => key === prop))
|
|
29
|
+
return true;
|
|
30
|
+
const value = input[key];
|
|
31
|
+
if (undefined === value)
|
|
32
|
+
return true;
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
28
35
|
const _io2 = input => Object.keys(input).every(key => {
|
|
29
36
|
const value = input[key];
|
|
30
37
|
if (undefined === value)
|
|
31
38
|
return true;
|
|
32
39
|
return true;
|
|
33
40
|
});
|
|
34
|
-
const _io3 = input => _ip1(input) && "string" === typeof input.id
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
const _io3 = input => _ip1(input) && "string" === typeof input.id && Object.keys(input).every(key => {
|
|
42
|
+
if (["binding", "id"].some(prop => key === prop))
|
|
43
|
+
return true;
|
|
44
|
+
const value = input[key];
|
|
45
|
+
if (undefined === value)
|
|
46
|
+
return true;
|
|
47
|
+
return true;
|
|
48
|
+
});
|
|
49
|
+
const _io4 = input => _ip1(input) && "string" === typeof input.bucket_name && Object.keys(input).every(key => {
|
|
50
|
+
if (["binding", "bucket_name"].some(prop => key === prop))
|
|
51
|
+
return true;
|
|
52
|
+
const value = input[key];
|
|
53
|
+
if (undefined === value)
|
|
54
|
+
return true;
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
const _io5 = input => _ip1(input) && "string" === typeof input.database_name && "string" === typeof input.database_id && (undefined === input.migrations_dir || "string" === typeof input.migrations_dir) && Object.keys(input).every(key => {
|
|
58
|
+
if (["binding", "database_name", "database_id", "migrations_dir"].some(prop => key === prop))
|
|
59
|
+
return true;
|
|
60
|
+
const value = input[key];
|
|
61
|
+
if (undefined === value)
|
|
62
|
+
return true;
|
|
63
|
+
return true;
|
|
64
|
+
});
|
|
65
|
+
const _io6 = input => _ip1(input) && "string" === typeof input.service && (undefined === input.environment || "string" === typeof input.environment) && Object.keys(input).every(key => {
|
|
66
|
+
if (["binding", "service", "environment"].some(prop => key === prop))
|
|
67
|
+
return true;
|
|
68
|
+
const value = input[key];
|
|
69
|
+
if (undefined === value)
|
|
70
|
+
return true;
|
|
71
|
+
return true;
|
|
72
|
+
});
|
|
73
|
+
const _io7 = input => _ip0(input) && "string" === typeof input.namespace_id && Object.keys(input).every(key => {
|
|
74
|
+
if (["name", "namespace_id"].some(prop => key === prop))
|
|
41
75
|
return true;
|
|
42
76
|
const value = input[key];
|
|
43
77
|
if (undefined === value)
|
|
@@ -70,35 +104,35 @@ const parseFlatWranglerConfigText = (() => {
|
|
|
70
104
|
value: input.vars
|
|
71
105
|
}), undefined === input.kv_namespaces || (Array.isArray(input.kv_namespaces) || _report(_exceptionable, {
|
|
72
106
|
path: _path + ".kv_namespaces",
|
|
73
|
-
expected: "(Array<
|
|
107
|
+
expected: "(Array<StageKvBinding> | undefined)",
|
|
74
108
|
value: input.kv_namespaces
|
|
75
109
|
})) && input.kv_namespaces.map((elem, _index9) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
76
110
|
path: _path + ".kv_namespaces[" + _index9 + "]",
|
|
77
|
-
expected: "
|
|
111
|
+
expected: "StageKvBinding",
|
|
78
112
|
value: elem
|
|
79
113
|
})) && _vo3(elem, _path + ".kv_namespaces[" + _index9 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
80
114
|
path: _path + ".kv_namespaces[" + _index9 + "]",
|
|
81
|
-
expected: "
|
|
115
|
+
expected: "StageKvBinding",
|
|
82
116
|
value: elem
|
|
83
117
|
})).every(flag => flag) || _report(_exceptionable, {
|
|
84
118
|
path: _path + ".kv_namespaces",
|
|
85
|
-
expected: "(Array<
|
|
119
|
+
expected: "(Array<StageKvBinding> | undefined)",
|
|
86
120
|
value: input.kv_namespaces
|
|
87
121
|
}), undefined === input.r2_buckets || (Array.isArray(input.r2_buckets) || _report(_exceptionable, {
|
|
88
122
|
path: _path + ".r2_buckets",
|
|
89
|
-
expected: "(
|
|
123
|
+
expected: "(Array<StageR2Binding> | undefined)",
|
|
90
124
|
value: input.r2_buckets
|
|
91
125
|
})) && input.r2_buckets.map((elem, _index10) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
92
126
|
path: _path + ".r2_buckets[" + _index10 + "]",
|
|
93
|
-
expected: "
|
|
127
|
+
expected: "StageR2Binding",
|
|
94
128
|
value: elem
|
|
95
129
|
})) && _vo4(elem, _path + ".r2_buckets[" + _index10 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
96
130
|
path: _path + ".r2_buckets[" + _index10 + "]",
|
|
97
|
-
expected: "
|
|
131
|
+
expected: "StageR2Binding",
|
|
98
132
|
value: elem
|
|
99
133
|
})).every(flag => flag) || _report(_exceptionable, {
|
|
100
134
|
path: _path + ".r2_buckets",
|
|
101
|
-
expected: "(
|
|
135
|
+
expected: "(Array<StageR2Binding> | undefined)",
|
|
102
136
|
value: input.r2_buckets
|
|
103
137
|
}), undefined === input.d1_databases || (Array.isArray(input.d1_databases) || _report(_exceptionable, {
|
|
104
138
|
path: _path + ".d1_databases",
|
|
@@ -150,19 +184,19 @@ const parseFlatWranglerConfigText = (() => {
|
|
|
150
184
|
value: input.ratelimits
|
|
151
185
|
}), undefined === input.send_email || (Array.isArray(input.send_email) || _report(_exceptionable, {
|
|
152
186
|
path: _path + ".send_email",
|
|
153
|
-
expected: "(
|
|
187
|
+
expected: "(Array<Record<string, unknown>> | undefined)",
|
|
154
188
|
value: input.send_email
|
|
155
189
|
})) && input.send_email.map((elem, _index14) => ("object" === typeof elem && null !== elem && false === Array.isArray(elem) || _report(_exceptionable, {
|
|
156
190
|
path: _path + ".send_email[" + _index14 + "]",
|
|
157
|
-
expected: "
|
|
191
|
+
expected: "Record<string, unknown>",
|
|
158
192
|
value: elem
|
|
159
|
-
})) &&
|
|
193
|
+
})) && _vo2(elem, _path + ".send_email[" + _index14 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
160
194
|
path: _path + ".send_email[" + _index14 + "]",
|
|
161
|
-
expected: "
|
|
195
|
+
expected: "Record<string, unknown>",
|
|
162
196
|
value: elem
|
|
163
197
|
})).every(flag => flag) || _report(_exceptionable, {
|
|
164
198
|
path: _path + ".send_email",
|
|
165
|
-
expected: "(
|
|
199
|
+
expected: "(Array<Record<string, unknown>> | undefined)",
|
|
166
200
|
value: input.send_email
|
|
167
201
|
}), true, false === _exceptionable || Object.keys(input).map(key => {
|
|
168
202
|
if (["name", "routes", "vars", "kv_namespaces", "r2_buckets", "d1_databases", "services", "ratelimits", "send_email", "env"].some(prop => key === prop))
|
|
@@ -184,7 +218,14 @@ const parseFlatWranglerConfigText = (() => {
|
|
|
184
218
|
path: _path + ".custom_domain",
|
|
185
219
|
expected: "(boolean | undefined)",
|
|
186
220
|
value: input.custom_domain
|
|
187
|
-
})
|
|
221
|
+
}), false === _exceptionable || Object.keys(input).map(key => {
|
|
222
|
+
if (["pattern", "zone_name", "custom_domain"].some(prop => key === prop))
|
|
223
|
+
return true;
|
|
224
|
+
const value = input[key];
|
|
225
|
+
if (undefined === value)
|
|
226
|
+
return true;
|
|
227
|
+
return true;
|
|
228
|
+
}).every(flag => flag)].every(flag => flag);
|
|
188
229
|
const _vo2 = (input, _path, _exceptionable = true) => [false === _exceptionable || Object.keys(input).map(key => {
|
|
189
230
|
const value = input[key];
|
|
190
231
|
if (undefined === value)
|
|
@@ -195,12 +236,26 @@ const parseFlatWranglerConfigText = (() => {
|
|
|
195
236
|
path: _path + ".id",
|
|
196
237
|
expected: "string",
|
|
197
238
|
value: input.id
|
|
198
|
-
})
|
|
239
|
+
}), false === _exceptionable || Object.keys(input).map(key => {
|
|
240
|
+
if (["binding", "id"].some(prop => key === prop))
|
|
241
|
+
return true;
|
|
242
|
+
const value = input[key];
|
|
243
|
+
if (undefined === value)
|
|
244
|
+
return true;
|
|
245
|
+
return true;
|
|
246
|
+
}).every(flag => flag)].every(flag => flag);
|
|
199
247
|
const _vo4 = (input, _path, _exceptionable = true) => [_vp1(input, _path, true && _exceptionable), "string" === typeof input.bucket_name || _report(_exceptionable, {
|
|
200
248
|
path: _path + ".bucket_name",
|
|
201
249
|
expected: "string",
|
|
202
250
|
value: input.bucket_name
|
|
203
|
-
})
|
|
251
|
+
}), false === _exceptionable || Object.keys(input).map(key => {
|
|
252
|
+
if (["binding", "bucket_name"].some(prop => key === prop))
|
|
253
|
+
return true;
|
|
254
|
+
const value = input[key];
|
|
255
|
+
if (undefined === value)
|
|
256
|
+
return true;
|
|
257
|
+
return true;
|
|
258
|
+
}).every(flag => flag)].every(flag => flag);
|
|
204
259
|
const _vo5 = (input, _path, _exceptionable = true) => [_vp1(input, _path, true && _exceptionable), "string" === typeof input.database_name || _report(_exceptionable, {
|
|
205
260
|
path: _path + ".database_name",
|
|
206
261
|
expected: "string",
|
|
@@ -213,7 +268,14 @@ const parseFlatWranglerConfigText = (() => {
|
|
|
213
268
|
path: _path + ".migrations_dir",
|
|
214
269
|
expected: "(string | undefined)",
|
|
215
270
|
value: input.migrations_dir
|
|
216
|
-
})
|
|
271
|
+
}), false === _exceptionable || Object.keys(input).map(key => {
|
|
272
|
+
if (["binding", "database_name", "database_id", "migrations_dir"].some(prop => key === prop))
|
|
273
|
+
return true;
|
|
274
|
+
const value = input[key];
|
|
275
|
+
if (undefined === value)
|
|
276
|
+
return true;
|
|
277
|
+
return true;
|
|
278
|
+
}).every(flag => flag)].every(flag => flag);
|
|
217
279
|
const _vo6 = (input, _path, _exceptionable = true) => [_vp1(input, _path, true && _exceptionable), "string" === typeof input.service || _report(_exceptionable, {
|
|
218
280
|
path: _path + ".service",
|
|
219
281
|
expected: "string",
|
|
@@ -222,14 +284,20 @@ const parseFlatWranglerConfigText = (() => {
|
|
|
222
284
|
path: _path + ".environment",
|
|
223
285
|
expected: "(string | undefined)",
|
|
224
286
|
value: input.environment
|
|
225
|
-
})
|
|
287
|
+
}), false === _exceptionable || Object.keys(input).map(key => {
|
|
288
|
+
if (["binding", "service", "environment"].some(prop => key === prop))
|
|
289
|
+
return true;
|
|
290
|
+
const value = input[key];
|
|
291
|
+
if (undefined === value)
|
|
292
|
+
return true;
|
|
293
|
+
return true;
|
|
294
|
+
}).every(flag => flag)].every(flag => flag);
|
|
226
295
|
const _vo7 = (input, _path, _exceptionable = true) => [_vp0(input, _path, true && _exceptionable), "string" === typeof input.namespace_id || _report(_exceptionable, {
|
|
227
296
|
path: _path + ".namespace_id",
|
|
228
297
|
expected: "string",
|
|
229
298
|
value: input.namespace_id
|
|
230
|
-
}),
|
|
231
|
-
|
|
232
|
-
if (["allowed_sender_addresses"].some(prop => key === prop))
|
|
299
|
+
}), false === _exceptionable || Object.keys(input).map(key => {
|
|
300
|
+
if (["name", "namespace_id"].some(prop => key === prop))
|
|
233
301
|
return true;
|
|
234
302
|
const value = input[key];
|
|
235
303
|
if (undefined === value)
|
|
@@ -280,17 +348,3 @@ export function parseFlatWranglerConfig(json) {
|
|
|
280
348
|
}
|
|
281
349
|
return result.data;
|
|
282
350
|
}
|
|
283
|
-
/** The reconcile plan (`reconcileStageResources`) read off a flat config for any stage. */
|
|
284
|
-
export function planFlatStageResources(config, stage) {
|
|
285
|
-
return {
|
|
286
|
-
stage,
|
|
287
|
-
workerName: config.name,
|
|
288
|
-
kvNamespaces: (config.kv_namespaces ?? []).map(({ binding, id }) => ({ binding, id })),
|
|
289
|
-
r2Buckets: (config.r2_buckets ?? []).map((bucket) => ({ binding: bucket.binding, bucketName: bucket.bucket_name })),
|
|
290
|
-
routes: (config.routes ?? []).map((route) => ({
|
|
291
|
-
pattern: route.pattern,
|
|
292
|
-
...(typeof route.zone_name === 'string' ? { zoneName: route.zone_name } : {}),
|
|
293
|
-
customDomain: route.custom_domain === true,
|
|
294
|
-
})),
|
|
295
|
-
};
|
|
296
|
-
}
|
|
@@ -44,9 +44,10 @@ export interface Manifest {
|
|
|
44
44
|
/** Secret NAMES from a `.dev.vars.example` file (KEY=... / KEY="..."), ignoring comments/blanks. */
|
|
45
45
|
export declare function parseDevVarsExample(text: string): string[];
|
|
46
46
|
/**
|
|
47
|
-
* Read the vars/secrets split for `env` from
|
|
48
|
-
* keys) + `<root>/.dev.vars.example` (secret names). This is the "what to prompt
|
|
49
|
-
*
|
|
47
|
+
* Read the vars/secrets split for `env` from the project's own Wrangler configuration (public
|
|
48
|
+
* var keys) + `<root>/.dev.vars.example` (secret names). This is the "what to prompt for"
|
|
49
|
+
* manifest a prepare-env script derives its work from. The config may be JSONC, JSON or TOML —
|
|
50
|
+
* reading it is format-blind; the editors below are the TOML half of the flow.
|
|
50
51
|
*/
|
|
51
52
|
export declare function readManifest(root: string, env: string): Manifest;
|
|
52
53
|
/** True if `value` looks like a PEM block (any `-----BEGIN ...-----`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-env.d.ts","sourceRoot":"","sources":["../../src/wrangler/prepare-env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepare-env.d.ts","sourceRoot":"","sources":["../../src/wrangler/prepare-env.ts"],"names":[],"mappings":"AA4HA,sHAAsH;AACtH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK5D;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAG9D;AAED,yFAAyF;AACzF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG7E;AAED,oIAAoI;AACpI,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAKrF;AAED,yFAAyF;AACzF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,O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E,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAMxE;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAShH;AAMD,uHAAuH;AACvH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQjF;AAED,2GAA2G;AAC3G,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CASvG"}
|
|
@@ -22,6 +22,7 @@ import { $ } from 'bun';
|
|
|
22
22
|
import { getStaticTOMLValue, parseTOML } from 'toml-eslint-parser';
|
|
23
23
|
import typia from 'typia';
|
|
24
24
|
import { decode, printCommandOutput, runText } from '../lib/run.js';
|
|
25
|
+
import { readWranglerSourceConfig } from './source-config.js';
|
|
25
26
|
const isWranglerTomlRoot = (() => {
|
|
26
27
|
const _ip0 = input => undefined === input["binding"] || "string" === typeof input["binding"];
|
|
27
28
|
const _io0 = input => undefined === input.env || "object" === typeof input.env && null !== input.env && false === Array.isArray(input.env) && _io1(input.env);
|
|
@@ -276,13 +277,14 @@ export function parseDevVarsExample(text) {
|
|
|
276
277
|
return names;
|
|
277
278
|
}
|
|
278
279
|
/**
|
|
279
|
-
* Read the vars/secrets split for `env` from
|
|
280
|
-
* keys) + `<root>/.dev.vars.example` (secret names). This is the "what to prompt
|
|
281
|
-
*
|
|
280
|
+
* Read the vars/secrets split for `env` from the project's own Wrangler configuration (public
|
|
281
|
+
* var keys) + `<root>/.dev.vars.example` (secret names). This is the "what to prompt for"
|
|
282
|
+
* manifest a prepare-env script derives its work from. The config may be JSONC, JSON or TOML —
|
|
283
|
+
* reading it is format-blind; the editors below are the TOML half of the flow.
|
|
282
284
|
*/
|
|
283
285
|
export function readManifest(root, env) {
|
|
284
|
-
const
|
|
285
|
-
const block =
|
|
286
|
+
const declared = readWranglerSourceConfig(root).document.env?.[env];
|
|
287
|
+
const block = isWranglerEnvBlock(declared) ? declared : null;
|
|
286
288
|
const vars = Object.keys(block?.vars ?? {});
|
|
287
289
|
const kvBindings = (block?.kv_namespaces ?? []).flatMap((row) => typeof row.binding === 'string' ? [row.binding] : []);
|
|
288
290
|
const d1Bindings = (block?.d1_databases ?? []).flatMap((row) => typeof row.binding === 'string' ? [row.binding] : []);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { WranglerDocument } from './stage.js';
|
|
2
|
+
/** Which parser a source config needs; `wrangler.json` and `wrangler.jsonc` share one. */
|
|
3
|
+
export type WranglerConfigFormat = 'jsonc' | 'toml';
|
|
4
|
+
/** Wrangler's own precedence: the first of these that exists is the one it reads. */
|
|
5
|
+
export declare const WRANGLER_SOURCE_CONFIG_FILES: readonly ['wrangler.jsonc', 'wrangler.json', 'wrangler.toml'];
|
|
6
|
+
export interface WranglerSourceConfig {
|
|
7
|
+
/** The file wrangler itself would read, ready to hand back to it as `--config`. */
|
|
8
|
+
path: string;
|
|
9
|
+
document: WranglerDocument;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The one source config this project declares. Two configs is a refusal, not a precedence
|
|
13
|
+
* exercise: the repo would deploy whichever file wrangler prefers, which is not necessarily the
|
|
14
|
+
* one anybody is editing.
|
|
15
|
+
*/
|
|
16
|
+
export declare function discoverWranglerSourceConfig(cwd: string): {
|
|
17
|
+
path: string;
|
|
18
|
+
format: WranglerConfigFormat;
|
|
19
|
+
};
|
|
20
|
+
/** The discovered source config, parsed into the model every stage derivation reads. */
|
|
21
|
+
export declare function readWranglerSourceConfig(cwd: string): WranglerSourceConfig;
|
|
22
|
+
/** One document out of either format. The text is never handed on: everything downstream reads data. */
|
|
23
|
+
export declare function parseWranglerConfig(path: string, text: string, format: WranglerConfigFormat): WranglerDocument;
|
|
24
|
+
//# sourceMappingURL=source-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-config.d.ts","sourceRoot":"","sources":["../../src/wrangler/source-config.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,0FAA0F;AAC1F,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEpD,qFAAqF;AACrF,eAAO,MAAM,4BAA4B,YAAI,gBAAgB,EAAE,eAAe,EAAE,eAAe,CAAU,CAAC;AAE1G,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAID;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,CAcxG;AAED,wFAAwF;AACxF,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAG1E;AAED,wGAAwG;AACxG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,gBAAgB,CAY9G"}
|