@cloudflare/deploy-helpers 0.1.3 → 0.2.1

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.
@@ -1,4 +1,4 @@
1
- import { FetchResultFetcher, FetchListResultFetcher, FetchPagedListResultFetcher, FetchKVGetValueFetcher, Logger, Entry, AssetsOptions, EphemeralDirectory, LegacyAssetPaths, Route, CfModule, CfModuleType, Config } from '@cloudflare/workers-utils';
1
+ import { FetchResultFetcher, FetchListResultFetcher, FetchPagedListResultFetcher, FetchKVGetValueFetcher, Logger, Entry, ValidatedAssetsOptions, LegacyAssetPaths, Route, CfModule, CfWorkerSourceMap, CfModuleType, Config } from '@cloudflare/workers-utils';
2
2
 
3
3
  /**
4
4
  * client needs to handle logger and fetch/auth implementation
@@ -36,41 +36,30 @@ type SharedDeployVersionsProps = {
36
36
  compatibilityDate: string | undefined;
37
37
  /** Merged: --compatibility-flags arg ?? config.compatibility_flags. */
38
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;
39
+ /**
40
+ * Validated/resolved assets directory, merged from --assets arg and
41
+ * config.assets. The full AssetsOptions are resolved later via
42
+ * `resolveAssetOptions`.
43
+ */
44
+ assetsDir: ValidatedAssetsOptions | undefined;
45
+ /**
46
+ * The user Worker entry, merged: --script arg ?? config.main. Undefined for
47
+ * assets-only Workers. Drives `has_user_worker` when resolving assets.
48
+ */
49
+ main: string | undefined;
53
50
  /** Merged: --keep-vars arg || config.keep_vars. */
54
51
  keepVars: boolean;
55
52
  /** Merged from --site arg and config.site. */
56
53
  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
54
  /**
62
55
  * Whether to use the deprecated service environments API path.
63
56
  * True only when config opts in (legacy_env: false) AND --env is specified.
64
57
  */
65
58
  useServiceEnvApiPath: boolean;
66
- /** Output directory for the bundled Worker. From --outdir arg or a temp directory. */
67
- destination: string | EphemeralDirectory;
68
59
  /** From --dry-run arg. */
69
60
  dryRun: boolean;
70
61
  /** From --env arg. */
71
62
  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
63
  /** From --outfile arg. */
75
64
  outfile: string | undefined;
76
65
  /** From --tag arg. */
@@ -89,6 +78,8 @@ type SharedDeployVersionsProps = {
89
78
  sendMetrics: boolean;
90
79
  /** Resolved from getFlag("RESOURCES_PROVISION"). Controls whether bindings are auto-provisioned before upload. */
91
80
  resourcesProvision: boolean;
81
+ /** temporary hack - cf is not yet a recognised deploy source, so any deploys from cf comes back normalised to 'api'*/
82
+ skipLastDeployedFromApiCheck: boolean;
92
83
  };
93
84
  type DeployProps = SharedDeployVersionsProps & {
94
85
  /** Discriminant for DeployProps vs VersionsUploadProps */
@@ -105,8 +96,6 @@ type DeployProps = SharedDeployVersionsProps & {
105
96
  dispatchNamespace: string | undefined;
106
97
  /** From --strict arg. Deploy-only. */
107
98
  strict: boolean;
108
- /** From --metafile arg. Deploy-only. */
109
- metafile: string | boolean | undefined;
110
99
  /** From --old-asset-ttl arg. Deploy-only. */
111
100
  oldAssetTtl: number | undefined;
112
101
  /** From --containers-rollout arg. Deploy-only. */
@@ -118,22 +107,15 @@ type VersionsUploadProps = SharedDeployVersionsProps & {
118
107
  /** CLI-only (--preview-alias), or auto-generated from CI branch name. */
119
108
  previewAlias: string | undefined;
120
109
  };
121
- type BuildBundleInfo = {
122
- sourceMapPath?: string | undefined;
123
- sourceMapMetadata?: {
124
- tmpDir: string;
125
- entryDirectory: string;
126
- } | undefined;
127
- };
128
110
  type WorkerBuildResult = {
129
111
  modules: CfModule[];
112
+ sourceMaps: CfWorkerSourceMap[] | undefined;
130
113
  dependencies: Record<string, {
131
114
  bytesInOutput: number;
132
115
  }>;
133
116
  resolvedEntryPointPath: string;
134
117
  bundleType: CfModuleType;
135
118
  content: string;
136
- bundle: BuildBundleInfo;
137
119
  };
138
120
  interface TriggerDeployment {
139
121
  targets: string[];
@@ -176,4 +158,4 @@ declare let isNonInteractiveOrCI: () => boolean;
176
158
  */
177
159
  declare function initDeployHelpersContext(ctx: DeployHelpersContext): void;
178
160
 
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 };
161
+ export { 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 };
@@ -1,2 +1,2 @@
1
- export { g as confirm, e as fetchKVGetValue, c as fetchListResult, d as fetchPagedListResult, f as fetchResult, i as initDeployHelpersContext, h as isNonInteractiveOrCI, l as logger, p as prompt } from './context-CUxVlvJf.mjs';
1
+ export { g as confirm, e as fetchKVGetValue, c as fetchListResult, d as fetchPagedListResult, f as fetchResult, i as initDeployHelpersContext, h as isNonInteractiveOrCI, l as logger, p as prompt } from './context-CRT2xLqo.mjs';
2
2
  import '@cloudflare/workers-utils';
package/dist/index.d.mts CHANGED
@@ -1,8 +1,9 @@
1
- import { D as DeployProps, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment } from './context-CUxVlvJf.mjs';
2
- export { B as BuildBundleInfo, b as DeployHelpersContext, S as SharedDeployVersionsProps, i as initDeployHelpersContext } from './context-CUxVlvJf.mjs';
1
+ import { D as DeployProps, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment, S as SharedDeployVersionsProps } from './context-CRT2xLqo.mjs';
2
+ export { b as DeployHelpersContext, i as initDeployHelpersContext } from './context-CRT2xLqo.mjs';
3
+ export { InputWorkerSchema, ModuleType, OutputWorkerSchema, ParsedInputWorkerConfig, ParsedOutputWorkerConfig, convertToWranglerConfig } from '@cloudflare/config';
3
4
  import { ContainerNormalizedConfig, ImageURIConfig } from '@cloudflare/containers-shared';
4
5
  import * as _cloudflare_workers_utils from '@cloudflare/workers-utils';
5
- import { Config, ComplianceConfig, LegacyAssetPaths, Binding, Route, ZoneIdRoute, ZoneNameRoute, CustomDomainRoute, CfPlacement, CfModule, CfWorkerSourceMap, RawConfig, ConfigBindingFieldName, CfCapnp, CfModuleType, CfWorkerInit, CfScriptFormat, AssetsOptions, ParseError, WorkerMetadataBinding, CfUserLimits, TailConsumer, StreamingTailConsumer, Observability, StartDevWorkerInput, CfTailConsumer, ContainerApp } from '@cloudflare/workers-utils';
6
+ import { Config, ComplianceConfig, LegacyAssetPaths, Binding, Route, ZoneIdRoute, ZoneNameRoute, CustomDomainRoute, CfPlacement, RawConfig, ConfigBindingFieldName, CfCapnp, CfModuleType, CfWorkerInit, CfScriptFormat, CfModule, AssetsOptions, ParseError, WorkerMetadataBinding, CfUserLimits, TailConsumer, StreamingTailConsumer, Observability, StartDevWorkerInput, CfTailConsumer, ContainerApp } from '@cloudflare/workers-utils';
6
7
  import { FormData } from 'undici';
7
8
  import { Options } from '@cspotcode/source-map-support';
8
9
  import Protocol from 'devtools-protocol';
@@ -271,24 +272,6 @@ declare function addRequiredSecretsInheritBindings(config: Config, bindings: Rec
271
272
  */
272
273
  declare function handleMissingSecretsError(err: unknown, config: Config, options: SecretsValidationOptions): void;
273
274
 
274
- interface SourceMapMetadata {
275
- tmpDir: string;
276
- entryDirectory: string;
277
- }
278
- interface SourceMapBundle {
279
- sourceMapPath?: string | undefined;
280
- sourceMapMetadata?: SourceMapMetadata | undefined;
281
- [key: string]: unknown;
282
- }
283
- /**
284
- * Loads source maps that appear in the given build output.
285
- */
286
- declare function loadSourceMaps(main: CfModule, modules: CfModule[], bundle: SourceMapBundle): CfWorkerSourceMap[];
287
- /**
288
- * Attaches a sourcemap, if found, to a JavaScript module.
289
- */
290
- declare function tryAttachSourcemapToModule(module: CfModule): void;
291
-
292
275
  type JsonLike = string | number | boolean | null | JsonLike[] | undefined | {
293
276
  [id: string]: JsonLike;
294
277
  };
@@ -750,9 +733,10 @@ type AssetManifest = {
750
733
  };
751
734
  declare const syncAssets: (complianceConfig: ComplianceConfig, accountId: string | undefined, assetDirectory: string, scriptName: string, dispatchNamespace?: string) => Promise<string>;
752
735
  declare const buildAssetManifest: (dir: string) => Promise<AssetManifest>;
736
+ declare function resolveAssetOptions({ assetsDir, main }: Pick<SharedDeployVersionsProps, "assetsDir" | "main">, config: Config): AssetsOptions | undefined;
753
737
 
754
738
  declare const hashFile: (filepath: string) => string;
755
739
 
756
740
  declare const isJwtExpired: (token: string) => boolean | undefined;
757
741
 
758
- export { type ApiDeployment, type ApiVersion, type AssetManifest, type BulkInputNullableResult, type BulkInputResult, type Consumer, type ConsumerSettings, type CustomDomain, type CustomDomainChangeset, type DeployCallbacks, DeployProps, INVALID_INHERIT_BINDING_CODE, type JsonLike, NoInputError, type NonVersionedScriptSettings, type Percentage, type PostQueueBody, type PostQueueResponse, type PostTypedConsumerBody, type Producer, type PurgeQueueBody, type PurgeQueueResponse, type QueueResponse, type QueueSettings, type RetrieveSourceMapFunction, type RouteObject, type ScriptReference, type SourceMapBundle, TriggerDeployment, TriggerProps, type TypedConsumerResponse, type VersionCache, type VersionId, type VersionsUploadCallbacks, VersionsUploadProps, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_NOT_FOUND_CODE, WorkerBuildResult, type Workflow, type WorkflowConflict, type Zone, type ZoneIdCache, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, confirmLatestDeploymentOverwrite, convertConfigToBindings, createDeployment, createTruncatedAlias, createWorkerUploadForm, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, ensureQueuesExistByConfig, extractBindingsOfType, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, fromMimeType, generatePreviewAlias, getBindings, getBranchName, getConfigPatch, getDeployConfirmFunction, getMigrationsToUpload, getQueue, getRemoteConfigDiff, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, handleUnsafeCapnp, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isJwtExpired, isModifiedDiffValue, isNonDestructive, isUnsafeBindingType, isWorkerNotFoundError, listConsumers, listQueues, loadSourceMaps, maybeRetrieveFileSourceMap, moduleTypeMimeType, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, postConsumer, printBindings, printBundleSize, printVersions, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderRoute, sanitizeBranchName, syncAssets, tagsAreEqual, triggersDeploy, tryAttachSourcemapToModule, updateQueueConsumers, useServiceEnvironments, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };
742
+ export { type ApiDeployment, type ApiVersion, type AssetManifest, type BulkInputNullableResult, type BulkInputResult, type Consumer, type ConsumerSettings, type CustomDomain, type CustomDomainChangeset, type DeployCallbacks, DeployProps, INVALID_INHERIT_BINDING_CODE, type JsonLike, NoInputError, type NonVersionedScriptSettings, type Percentage, type PostQueueBody, type PostQueueResponse, type PostTypedConsumerBody, type Producer, type PurgeQueueBody, type PurgeQueueResponse, type QueueResponse, type QueueSettings, type RetrieveSourceMapFunction, type RouteObject, type ScriptReference, SharedDeployVersionsProps, TriggerDeployment, TriggerProps, type TypedConsumerResponse, type VersionCache, type VersionId, type VersionsUploadCallbacks, VersionsUploadProps, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_NOT_FOUND_CODE, WorkerBuildResult, type Workflow, type WorkflowConflict, type Zone, type ZoneIdCache, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, confirmLatestDeploymentOverwrite, convertConfigToBindings, createDeployment, createTruncatedAlias, createWorkerUploadForm, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, ensureQueuesExistByConfig, extractBindingsOfType, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, fromMimeType, generatePreviewAlias, getBindings, getBranchName, getConfigPatch, getDeployConfirmFunction, getMigrationsToUpload, getQueue, getRemoteConfigDiff, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, handleUnsafeCapnp, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isJwtExpired, isModifiedDiffValue, isNonDestructive, isUnsafeBindingType, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, moduleTypeMimeType, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, postConsumer, printBindings, printBundleSize, printVersions, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderRoute, resolveAssetOptions, sanitizeBranchName, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, useServiceEnvironments, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };