@cloudflare/deploy-helpers 0.1.1 → 0.1.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/dist/chunk-NAAB7FBS.mjs +55 -0
- package/dist/context-CUxVlvJf.d.mts +179 -0
- package/dist/context.d.mts +2 -0
- package/dist/context.mjs +1 -0
- package/dist/index.d.mts +744 -99
- package/dist/index.mjs +8641 -0
- package/dist/metafile-esm.json +1 -1
- package/package.json +27 -5
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
// src/shared/context.ts
|
|
35
|
+
var logger;
|
|
36
|
+
var fetchResult;
|
|
37
|
+
var fetchListResult;
|
|
38
|
+
var fetchPagedListResult;
|
|
39
|
+
var fetchKVGetValue;
|
|
40
|
+
var confirm;
|
|
41
|
+
var prompt;
|
|
42
|
+
var isNonInteractiveOrCI;
|
|
43
|
+
function initDeployHelpersContext(ctx) {
|
|
44
|
+
logger = ctx.logger;
|
|
45
|
+
fetchResult = ctx.fetchResult;
|
|
46
|
+
fetchListResult = ctx.fetchListResult;
|
|
47
|
+
fetchPagedListResult = ctx.fetchPagedListResult;
|
|
48
|
+
fetchKVGetValue = ctx.fetchKVGetValue;
|
|
49
|
+
confirm = ctx.confirm;
|
|
50
|
+
prompt = ctx.prompt;
|
|
51
|
+
isNonInteractiveOrCI = ctx.isNonInteractiveOrCI;
|
|
52
|
+
}
|
|
53
|
+
__name(initDeployHelpersContext, "initDeployHelpersContext");
|
|
54
|
+
|
|
55
|
+
export { __commonJS, __name, __require, __toESM, confirm, fetchKVGetValue, fetchListResult, fetchPagedListResult, fetchResult, initDeployHelpersContext, isNonInteractiveOrCI, logger, prompt };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { FetchResultFetcher, FetchListResultFetcher, FetchPagedListResultFetcher, FetchKVGetValueFetcher, Logger, Entry, AssetsOptions, EphemeralDirectory, LegacyAssetPaths, Route, CfModule, CfModuleType, Config } from '@cloudflare/workers-utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* client needs to handle logger and fetch/auth implementation
|
|
5
|
+
* these are passed into this package to handle any API requests/logs
|
|
6
|
+
*/
|
|
7
|
+
type DeployHelpersContext = {
|
|
8
|
+
fetchResult: FetchResultFetcher;
|
|
9
|
+
fetchListResult: FetchListResultFetcher;
|
|
10
|
+
fetchPagedListResult: FetchPagedListResultFetcher;
|
|
11
|
+
fetchKVGetValue: FetchKVGetValueFetcher;
|
|
12
|
+
logger: Logger;
|
|
13
|
+
confirm: (text: string, options?: {
|
|
14
|
+
defaultValue?: boolean;
|
|
15
|
+
fallbackValue?: boolean;
|
|
16
|
+
}) => Promise<boolean>;
|
|
17
|
+
prompt: (text: string, options?: {
|
|
18
|
+
defaultValue?: string;
|
|
19
|
+
}) => Promise<string>;
|
|
20
|
+
isNonInteractiveOrCI: () => boolean;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Shared fields produced by merging CLI args with wrangler config.
|
|
24
|
+
* After this point, no raw config/arg merging should happen.
|
|
25
|
+
*
|
|
26
|
+
* Use props for all resolved/merged values. Only access config directly
|
|
27
|
+
* for raw values that aren't merged with CLI args (e.g., config.durable_objects,
|
|
28
|
+
* config.unsafe, config.tail_consumers).
|
|
29
|
+
*/
|
|
30
|
+
type SharedDeployVersionsProps = {
|
|
31
|
+
/** Merged from args.script/config.main/config.site.entry-point/config.assets. */
|
|
32
|
+
entry: Entry;
|
|
33
|
+
/** Merged: --name arg ?? config.name, with CI override applied. Validated as required separately. */
|
|
34
|
+
name: string | undefined;
|
|
35
|
+
/** Merged: --compatibility-date arg ?? config.compatibility_date. Still optional — validated as required later. */
|
|
36
|
+
compatibilityDate: string | undefined;
|
|
37
|
+
/** Merged: --compatibility-flags arg ?? config.compatibility_flags. */
|
|
38
|
+
compatibilityFlags: string[];
|
|
39
|
+
/** Merged from --assets arg and config.assets. */
|
|
40
|
+
assetsOptions: AssetsOptions | undefined;
|
|
41
|
+
/** Merged: --jsx-factory arg || config.jsx_factory. */
|
|
42
|
+
jsxFactory: string;
|
|
43
|
+
/** Merged: --jsx-fragment arg || config.jsx_fragment. */
|
|
44
|
+
jsxFragment: string;
|
|
45
|
+
/** Merged: --tsconfig arg ?? config.tsconfig. */
|
|
46
|
+
tsconfig: string | undefined;
|
|
47
|
+
/** Merged: --minify arg ?? config.minify. */
|
|
48
|
+
minify: boolean | undefined;
|
|
49
|
+
/** Merged: !(--bundle arg ?? !config.no_bundle). */
|
|
50
|
+
noBundle: boolean;
|
|
51
|
+
/** Merged: --upload-source-maps arg ?? config.upload_source_maps. */
|
|
52
|
+
uploadSourceMaps: boolean | undefined;
|
|
53
|
+
/** Merged: --keep-vars arg || config.keep_vars. */
|
|
54
|
+
keepVars: boolean;
|
|
55
|
+
/** Merged from --site arg and config.site. */
|
|
56
|
+
isWorkersSite: boolean;
|
|
57
|
+
/** Merged: { ...config.define, ...--define arg }. CLI overrides config. */
|
|
58
|
+
defines: Record<string, string>;
|
|
59
|
+
/** Merged: { ...config.alias, ...--alias arg }. CLI overrides config. */
|
|
60
|
+
alias: Record<string, string>;
|
|
61
|
+
/**
|
|
62
|
+
* Whether to use the deprecated service environments API path.
|
|
63
|
+
* True only when config opts in (legacy_env: false) AND --env is specified.
|
|
64
|
+
*/
|
|
65
|
+
useServiceEnvApiPath: boolean;
|
|
66
|
+
/** Output directory for the bundled Worker. From --outdir arg or a temp directory. */
|
|
67
|
+
destination: string | EphemeralDirectory;
|
|
68
|
+
/** From --dry-run arg. */
|
|
69
|
+
dryRun: boolean;
|
|
70
|
+
/** From --env arg. */
|
|
71
|
+
env: string | undefined;
|
|
72
|
+
/** From --outdir arg. Already used to derive `destination`, but also needed for outdir README and noBundleWorker. */
|
|
73
|
+
outdir: string | undefined;
|
|
74
|
+
/** From --outfile arg. */
|
|
75
|
+
outfile: string | undefined;
|
|
76
|
+
/** From --tag arg. */
|
|
77
|
+
tag: string | undefined;
|
|
78
|
+
/** From --message arg. */
|
|
79
|
+
message: string | undefined;
|
|
80
|
+
/** From --secrets-file arg. */
|
|
81
|
+
secretsFile: string | undefined;
|
|
82
|
+
/** From collectKeyValues(--var arg). CLI-only vars; config vars flow separately via getBindings(config). */
|
|
83
|
+
cliVars: Record<string, string>;
|
|
84
|
+
/** From --experimental-auto-create arg. */
|
|
85
|
+
experimentalAutoCreate: boolean;
|
|
86
|
+
/** Resolved from requireAuth() before calling deploy-helpers. undefined only in dry-run. */
|
|
87
|
+
accountId: string | undefined;
|
|
88
|
+
/** Resolved from getMetricsUsageHeaders() / config.send_metrics. Controls whether usage metrics headers are sent with upload requests. */
|
|
89
|
+
sendMetrics: boolean;
|
|
90
|
+
/** Resolved from getFlag("RESOURCES_PROVISION"). Controls whether bindings are auto-provisioned before upload. */
|
|
91
|
+
resourcesProvision: boolean;
|
|
92
|
+
};
|
|
93
|
+
type DeployProps = SharedDeployVersionsProps & {
|
|
94
|
+
/** Discriminant for DeployProps vs VersionsUploadProps */
|
|
95
|
+
command: "deploy";
|
|
96
|
+
/** Merged from --site arg and config.site. */
|
|
97
|
+
legacyAssetPaths: LegacyAssetPaths | undefined;
|
|
98
|
+
/** Merged: --triggers arg ?? config.triggers.crons. */
|
|
99
|
+
triggers: string[] | undefined;
|
|
100
|
+
/** Merged: --routes arg ?? config.routes ?? config.route. AND --domains and custom_domains*/
|
|
101
|
+
routes: Route[];
|
|
102
|
+
/** Merged: --logpush arg ?? config.logpush. */
|
|
103
|
+
logpush: boolean | undefined;
|
|
104
|
+
/** From --dispatch-namespace arg. Deploy-only (Workers for Platforms). */
|
|
105
|
+
dispatchNamespace: string | undefined;
|
|
106
|
+
/** From --strict arg. Deploy-only. */
|
|
107
|
+
strict: boolean;
|
|
108
|
+
/** From --metafile arg. Deploy-only. */
|
|
109
|
+
metafile: string | boolean | undefined;
|
|
110
|
+
/** From --old-asset-ttl arg. Deploy-only. */
|
|
111
|
+
oldAssetTtl: number | undefined;
|
|
112
|
+
/** From --containers-rollout arg. Deploy-only. */
|
|
113
|
+
containersRollout: "immediate" | "gradual" | "none" | undefined;
|
|
114
|
+
};
|
|
115
|
+
type VersionsUploadProps = SharedDeployVersionsProps & {
|
|
116
|
+
/** Discriminant for DeployProps vs VersionsUploadProps */
|
|
117
|
+
command: "versions upload";
|
|
118
|
+
/** CLI-only (--preview-alias), or auto-generated from CI branch name. */
|
|
119
|
+
previewAlias: string | undefined;
|
|
120
|
+
};
|
|
121
|
+
type BuildBundleInfo = {
|
|
122
|
+
sourceMapPath?: string | undefined;
|
|
123
|
+
sourceMapMetadata?: {
|
|
124
|
+
tmpDir: string;
|
|
125
|
+
entryDirectory: string;
|
|
126
|
+
} | undefined;
|
|
127
|
+
};
|
|
128
|
+
type WorkerBuildResult = {
|
|
129
|
+
modules: CfModule[];
|
|
130
|
+
dependencies: Record<string, {
|
|
131
|
+
bytesInOutput: number;
|
|
132
|
+
}>;
|
|
133
|
+
resolvedEntryPointPath: string;
|
|
134
|
+
bundleType: CfModuleType;
|
|
135
|
+
content: string;
|
|
136
|
+
bundle: BuildBundleInfo;
|
|
137
|
+
};
|
|
138
|
+
interface TriggerDeployment {
|
|
139
|
+
targets: string[];
|
|
140
|
+
error?: Error;
|
|
141
|
+
}
|
|
142
|
+
type TriggerProps = {
|
|
143
|
+
config: Config;
|
|
144
|
+
accountId: string;
|
|
145
|
+
scriptName: string;
|
|
146
|
+
env: string | undefined;
|
|
147
|
+
crons: string[] | undefined;
|
|
148
|
+
routes: Route[];
|
|
149
|
+
useServiceEnvironments: boolean;
|
|
150
|
+
firstDeploy: boolean;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Module-level context globals for deploy-helpers.
|
|
155
|
+
*
|
|
156
|
+
* These are typed as non-nullable but are undefined until initDeployHelpersContext()
|
|
157
|
+
* is called. Consumers must import the live binding directly (e.g. `import { logger }`)
|
|
158
|
+
* and NOT destructure or cache the value at module-load time, otherwise they will
|
|
159
|
+
* capture `undefined` before init runs.
|
|
160
|
+
*
|
|
161
|
+
* Example:
|
|
162
|
+
* import { logger } from "./context"; // correct: live binding
|
|
163
|
+
* const { logger } = await import("./context"); // WRONG: captures undefined
|
|
164
|
+
*/
|
|
165
|
+
declare let logger: Logger;
|
|
166
|
+
declare let fetchResult: FetchResultFetcher;
|
|
167
|
+
declare let fetchListResult: FetchListResultFetcher;
|
|
168
|
+
declare let fetchPagedListResult: FetchPagedListResultFetcher;
|
|
169
|
+
declare let fetchKVGetValue: FetchKVGetValueFetcher;
|
|
170
|
+
declare let confirm: DeployHelpersContext["confirm"];
|
|
171
|
+
declare let prompt: DeployHelpersContext["prompt"];
|
|
172
|
+
declare let isNonInteractiveOrCI: () => boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Set the global context for deploy-helpers. Must be called once at
|
|
175
|
+
* startup before any deploy-helpers function that needs these values.
|
|
176
|
+
*/
|
|
177
|
+
declare function initDeployHelpersContext(ctx: DeployHelpersContext): void;
|
|
178
|
+
|
|
179
|
+
export { type BuildBundleInfo as B, type DeployProps as D, type SharedDeployVersionsProps as S, type TriggerProps as T, type VersionsUploadProps as V, type WorkerBuildResult as W, type TriggerDeployment as a, type DeployHelpersContext as b, fetchListResult as c, fetchPagedListResult as d, fetchKVGetValue as e, fetchResult as f, confirm as g, isNonInteractiveOrCI as h, initDeployHelpersContext as i, logger as l, prompt as p };
|
package/dist/context.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { confirm, fetchKVGetValue, fetchListResult, fetchPagedListResult, fetchResult, initDeployHelpersContext, isNonInteractiveOrCI, logger, prompt } from './chunk-NAAB7FBS.mjs';
|