@cloudflare/containers-shared 0.27.0 → 0.27.2
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/index.d.mts +11 -1
- package/dist/index.mjs +12 -16
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StdioOptions } from "node:child_process";
|
|
2
2
|
import { ComplianceConfig } from "@cloudflare/workers-utils/compliance";
|
|
3
|
-
import { ComplianceConfig as ComplianceConfig$1,
|
|
3
|
+
import { ComplianceConfig as ComplianceConfig$1, FetchPagedListResultFetcher, FetchResultFetcher, Logger } from "@cloudflare/workers-utils";
|
|
4
|
+
import { Config, ContainerApp } from "@cloudflare/workers-utils/config";
|
|
4
5
|
import { ParsedBuildOutputContainerConfig, ParsedBuildOutputWorkerConfig, ParsedContainerConfig, ParsedSettings, ParsedWorkerConfig } from "@cloudflare/config";
|
|
5
6
|
//#region src/client/core/ApiRequestOptions.d.ts
|
|
6
7
|
type ApiRequestOptions = {
|
|
@@ -3775,12 +3776,21 @@ declare function dockerBuild(dockerPath: string, options: {
|
|
|
3775
3776
|
* Registry references pass through unchanged. Locally built tags are retained
|
|
3776
3777
|
* on success so a later deploy can resolve each emitted `localReference`.
|
|
3777
3778
|
*
|
|
3779
|
+
* Tags left by a previous build are removed first. Finding them means running
|
|
3780
|
+
* Docker, so a project with no Containers skips the lookup when the caller
|
|
3781
|
+
* reports that the output it replaced had no Containers either.
|
|
3782
|
+
*
|
|
3778
3783
|
* @param options - The validated Container configs and Docker build environment.
|
|
3784
|
+
* @param options.previousOutputHadContainers - Whether the Build Output tree
|
|
3785
|
+
* that this build replaces held any Container output. Callers clean the tree
|
|
3786
|
+
* before this runs, so they must check beforehand. When omitted, previous tags
|
|
3787
|
+
* are always looked up.
|
|
3779
3788
|
*/
|
|
3780
3789
|
declare function buildAndWriteContainerOutput(options: {
|
|
3781
3790
|
containers: ParsedContainerConfig[];
|
|
3782
3791
|
root: string;
|
|
3783
3792
|
pathToDocker: string;
|
|
3793
|
+
previousOutputHadContainers?: boolean;
|
|
3784
3794
|
}): Promise<void>;
|
|
3785
3795
|
//#endregion
|
|
3786
3796
|
//#region src/context.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -12,10 +12,10 @@ import { COMPLIANCE_REGION_CONFIG_UNKNOWN, getCloudflareApiBaseUrl, getComplianc
|
|
|
12
12
|
import { release } from "node:os";
|
|
13
13
|
import { cleanBuildOutputDir, normalizeDirectoryName, writeContainerConfig } from "@cloudflare/build-output-utils";
|
|
14
14
|
import assert from "node:assert";
|
|
15
|
-
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
16
15
|
import { endSection, log, newline, shapes, showCursor, startSection, success, updateStatus } from "@cloudflare/cli-shared-helpers";
|
|
17
16
|
import { bold, brandColor, dim, green, red } from "@cloudflare/cli-shared-helpers/colors";
|
|
18
|
-
import {
|
|
17
|
+
import { retryWhileVersionNotReadable } from "@cloudflare/workers-utils";
|
|
18
|
+
import { formatConfigSnippet, getResolvedDurableObjectContainerApps, isDockerfile, isDurableObjectContainerApp, resolveContainerClassName } from "@cloudflare/workers-utils/config";
|
|
19
19
|
import { spinner } from "@cloudflare/cli-shared-helpers/interactive";
|
|
20
20
|
import { once } from "node:events";
|
|
21
21
|
import { createServer } from "node:net";
|
|
@@ -3624,13 +3624,21 @@ const DOCKER_REPOSITORY_NAME_LENGTH = 255;
|
|
|
3624
3624
|
* Registry references pass through unchanged. Locally built tags are retained
|
|
3625
3625
|
* on success so a later deploy can resolve each emitted `localReference`.
|
|
3626
3626
|
*
|
|
3627
|
+
* Tags left by a previous build are removed first. Finding them means running
|
|
3628
|
+
* Docker, so a project with no Containers skips the lookup when the caller
|
|
3629
|
+
* reports that the output it replaced had no Containers either.
|
|
3630
|
+
*
|
|
3627
3631
|
* @param options - The validated Container configs and Docker build environment.
|
|
3632
|
+
* @param options.previousOutputHadContainers - Whether the Build Output tree
|
|
3633
|
+
* that this build replaces held any Container output. Callers clean the tree
|
|
3634
|
+
* before this runs, so they must check beforehand. When omitted, previous tags
|
|
3635
|
+
* are always looked up.
|
|
3628
3636
|
*/
|
|
3629
3637
|
async function buildAndWriteContainerOutput(options) {
|
|
3630
3638
|
const localTags = /* @__PURE__ */ new Set();
|
|
3631
3639
|
try {
|
|
3632
3640
|
const containers = resolveContainerDirectories(options.containers);
|
|
3633
|
-
await cleanupPreviousBuildOutputImageTags({
|
|
3641
|
+
if (containers.length > 0 || options.previousOutputHadContainers !== false) await cleanupPreviousBuildOutputImageTags({
|
|
3634
3642
|
root: options.root,
|
|
3635
3643
|
pathToDocker: options.pathToDocker
|
|
3636
3644
|
});
|
|
@@ -4094,7 +4102,7 @@ function createDurableObjectNamespaceResolver(config, { versionId, accountId, sc
|
|
|
4094
4102
|
let maybeAllDurableObjects;
|
|
4095
4103
|
return async (className) => {
|
|
4096
4104
|
if (boundDOs.has(className) && dispatchNamespace === void 0) {
|
|
4097
|
-
maybeVersionInfo ??= await
|
|
4105
|
+
maybeVersionInfo ??= await retryWhileVersionNotReadable(() => fetchResult(config, `/accounts/${accountId}/workers/scripts/${scriptName}/versions/${versionId}`), logger);
|
|
4098
4106
|
const targetDurableObject = maybeVersionInfo.resources.bindings.find((binding) => binding.type === "durable_object_namespace" && binding.class_name === className && (binding.script_name === void 0 || binding.script_name === scriptName) && binding.namespace_id !== void 0);
|
|
4099
4107
|
if (!targetDurableObject?.namespace_id) throw new UserError("Could not deploy container configuration as durable object was not found in list of bindings", { telemetryMessage: "containers deploy durable object binding missing" });
|
|
4100
4108
|
return targetDurableObject.namespace_id;
|
|
@@ -4120,18 +4128,6 @@ async function deployContainers(config, containerDeployments, { versionId, accou
|
|
|
4120
4128
|
observabilityTargetCountField
|
|
4121
4129
|
}, container, config, accountId);
|
|
4122
4130
|
}
|
|
4123
|
-
async function fetchUploadedVersion(config, accountId, scriptName, versionId) {
|
|
4124
|
-
for (let attempt = 0; attempt < 5; attempt++) try {
|
|
4125
|
-
return await fetchResult(config, `/accounts/${accountId}/workers/scripts/${scriptName}/versions/${versionId}`);
|
|
4126
|
-
} catch (error) {
|
|
4127
|
-
if (!isUploadedVersionNotReadyError(error) || attempt === 4) throw error;
|
|
4128
|
-
await setTimeout$1(500);
|
|
4129
|
-
}
|
|
4130
|
-
throw new Error("Unable to fetch uploaded Worker version");
|
|
4131
|
-
}
|
|
4132
|
-
function isUploadedVersionNotReadyError(error) {
|
|
4133
|
-
return error instanceof Error && "code" in error && error.code === 100146;
|
|
4134
|
-
}
|
|
4135
4131
|
async function listDurableObjects(complianceConfig, accountId) {
|
|
4136
4132
|
return await fetchPagedListResult(complianceConfig, `/accounts/${accountId}/workers/durable_objects/namespaces`, {}, new URLSearchParams({ per_page: "1000" }));
|
|
4137
4133
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/containers-shared",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.2",
|
|
4
4
|
"description": "Internal-only shared container helpers for workers-sdk. Do not use directly; APIs are unstable and may change or disappear without notice.",
|
|
5
5
|
"homepage": "https://github.com/cloudflare/workers-sdk/tree/main/packages/containers-shared#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@cloudflare/
|
|
28
|
-
"@cloudflare/
|
|
29
|
-
"@cloudflare/
|
|
30
|
-
"@cloudflare/
|
|
27
|
+
"@cloudflare/build-output-utils": "1.0.0-rc.4",
|
|
28
|
+
"@cloudflare/cli-shared-helpers": "0.3.13",
|
|
29
|
+
"@cloudflare/config": "1.0.0-rc.4",
|
|
30
|
+
"@cloudflare/workers-utils": "0.57.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "22.15.17",
|
|
34
34
|
"@types/ws": "^8.5.7",
|
|
35
35
|
"tsdown": "0.22.14",
|
|
36
|
-
"typescript": "
|
|
36
|
+
"typescript": "6.0.3",
|
|
37
37
|
"vitest": "5.0.4",
|
|
38
38
|
"ws": "8.21.0",
|
|
39
39
|
"@cloudflare/workers-tsconfig": "0.0.0"
|