@webflow/cloud-app 0.1.0-beta.7
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/LICENSE +21 -0
- package/README.md +93 -0
- package/dist/bindings.d.ts +185 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +120 -0
- package/dist/bindings.js.map +1 -0
- package/dist/config/package-json.d.ts +57 -0
- package/dist/config/package-json.d.ts.map +1 -0
- package/dist/config/package-json.js +94 -0
- package/dist/config/package-json.js.map +1 -0
- package/dist/config/webflow-json.d.ts +53 -0
- package/dist/config/webflow-json.d.ts.map +1 -0
- package/dist/config/webflow-json.js +72 -0
- package/dist/config/webflow-json.js.map +1 -0
- package/dist/create-webflow-json.d.ts +24 -0
- package/dist/create-webflow-json.d.ts.map +1 -0
- package/dist/create-webflow-json.js +170 -0
- package/dist/create-webflow-json.js.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +23 -0
- package/dist/errors.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.d.ts +36 -0
- package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.js +94 -0
- package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.d.ts +2 -0
- package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.js +97 -0
- package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.js.map +1 -0
- package/dist/frameworks/astro/astro5.d.ts +28 -0
- package/dist/frameworks/astro/astro5.d.ts.map +1 -0
- package/dist/frameworks/astro/astro5.js +259 -0
- package/dist/frameworks/astro/astro5.js.map +1 -0
- package/dist/frameworks/astro/astro6.d.ts +28 -0
- package/dist/frameworks/astro/astro6.d.ts.map +1 -0
- package/dist/frameworks/astro/astro6.js +286 -0
- package/dist/frameworks/astro/astro6.js.map +1 -0
- package/dist/frameworks/astro/astro7.d.ts +28 -0
- package/dist/frameworks/astro/astro7.d.ts.map +1 -0
- package/dist/frameworks/astro/astro7.js +283 -0
- package/dist/frameworks/astro/astro7.js.map +1 -0
- package/dist/frameworks/astro/index.d.ts +10 -0
- package/dist/frameworks/astro/index.d.ts.map +1 -0
- package/dist/frameworks/astro/index.js +16 -0
- package/dist/frameworks/astro/index.js.map +1 -0
- package/dist/frameworks/astro/templates/astro.config.webflow.ts +61 -0
- package/dist/frameworks/astro/templates/v5/astro.config.mjs.template +25 -0
- package/dist/frameworks/astro/templates/v5/webflow-loader.ts +103 -0
- package/dist/frameworks/astro/templates/v5/wrangler.json +6 -0
- package/dist/frameworks/astro/templates/v6/astro.config.mjs.template +35 -0
- package/dist/frameworks/astro/templates/v6/webflow-loader.ts +112 -0
- package/dist/frameworks/astro/templates/v6/wrangler.json +9 -0
- package/dist/frameworks/astro/templates/v7/astro.config.mjs.template +34 -0
- package/dist/frameworks/astro/templates/v7/webflow-loader.ts +113 -0
- package/dist/frameworks/astro/templates/v7/wrangler.json +9 -0
- package/dist/frameworks/base.d.ts +134 -0
- package/dist/frameworks/base.d.ts.map +1 -0
- package/dist/frameworks/base.js +175 -0
- package/dist/frameworks/base.js.map +1 -0
- package/dist/frameworks/errors.d.ts +72 -0
- package/dist/frameworks/errors.d.ts.map +1 -0
- package/dist/frameworks/errors.js +120 -0
- package/dist/frameworks/errors.js.map +1 -0
- package/dist/frameworks/nextjs/adapter-resolver.d.ts +72 -0
- package/dist/frameworks/nextjs/adapter-resolver.d.ts.map +1 -0
- package/dist/frameworks/nextjs/adapter-resolver.js +246 -0
- package/dist/frameworks/nextjs/adapter-resolver.js.map +1 -0
- package/dist/frameworks/nextjs/index.d.ts +38 -0
- package/dist/frameworks/nextjs/index.d.ts.map +1 -0
- package/dist/frameworks/nextjs/index.js +268 -0
- package/dist/frameworks/nextjs/index.js.map +1 -0
- package/dist/frameworks/nextjs/templates/next.config.ts.template +13 -0
- package/dist/frameworks/nextjs/templates/next.config.webflow.ts +46 -0
- package/dist/frameworks/nextjs/templates/open-next.config.ts +3 -0
- package/dist/frameworks/nextjs/templates/webflow-loader.ts +44 -0
- package/dist/frameworks/nextjs/templates/wrangler.json +6 -0
- package/dist/frameworks/registry.d.ts +127 -0
- package/dist/frameworks/registry.d.ts.map +1 -0
- package/dist/frameworks/registry.js +257 -0
- package/dist/frameworks/registry.js.map +1 -0
- package/dist/frameworks/static/index.d.ts +93 -0
- package/dist/frameworks/static/index.d.ts.map +1 -0
- package/dist/frameworks/static/index.js +352 -0
- package/dist/frameworks/static/index.js.map +1 -0
- package/dist/frameworks/static/templates/wrangler.json +7 -0
- package/dist/frameworks/types.d.ts +138 -0
- package/dist/frameworks/types.d.ts.map +1 -0
- package/dist/frameworks/types.js +3 -0
- package/dist/frameworks/types.js.map +1 -0
- package/dist/frameworks/vite/index.d.ts +46 -0
- package/dist/frameworks/vite/index.d.ts.map +1 -0
- package/dist/frameworks/vite/index.js +303 -0
- package/dist/frameworks/vite/index.js.map +1 -0
- package/dist/frameworks/vite/templates/vite.config.ts.template +14 -0
- package/dist/frameworks/vite/templates/vite.config.webflow.ts +52 -0
- package/dist/frameworks/vite/templates/wrangler.json +10 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +118 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline.d.ts +8 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +263 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/ports/command-runner.d.ts +60 -0
- package/dist/ports/command-runner.d.ts.map +1 -0
- package/dist/ports/command-runner.js +116 -0
- package/dist/ports/command-runner.js.map +1 -0
- package/dist/ports/filesystem.d.ts +19 -0
- package/dist/ports/filesystem.d.ts.map +1 -0
- package/dist/ports/filesystem.js +68 -0
- package/dist/ports/filesystem.js.map +1 -0
- package/dist/ports/index.d.ts +17 -0
- package/dist/ports/index.d.ts.map +1 -0
- package/dist/ports/index.js +14 -0
- package/dist/ports/index.js.map +1 -0
- package/dist/ports/logger.d.ts +22 -0
- package/dist/ports/logger.d.ts.map +1 -0
- package/dist/ports/logger.js +18 -0
- package/dist/ports/logger.js.map +1 -0
- package/dist/ports/telemetry.d.ts +23 -0
- package/dist/ports/telemetry.d.ts.map +1 -0
- package/dist/ports/telemetry.js +12 -0
- package/dist/ports/telemetry.js.map +1 -0
- package/dist/toolchain/errors.d.ts +32 -0
- package/dist/toolchain/errors.d.ts.map +1 -0
- package/dist/toolchain/errors.js +31 -0
- package/dist/toolchain/errors.js.map +1 -0
- package/dist/toolchain/resolver.d.ts +25 -0
- package/dist/toolchain/resolver.d.ts.map +1 -0
- package/dist/toolchain/resolver.js +200 -0
- package/dist/toolchain/resolver.js.map +1 -0
- package/dist/toolchain/types.d.ts +52 -0
- package/dist/toolchain/types.d.ts.map +1 -0
- package/dist/toolchain/types.js +10 -0
- package/dist/toolchain/types.js.map +1 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/fs.d.ts +29 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +126 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +27 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/node-version.d.ts +20 -0
- package/dist/utils/node-version.d.ts.map +1 -0
- package/dist/utils/node-version.js +113 -0
- package/dist/utils/node-version.js.map +1 -0
- package/dist/utils/process.d.ts +25 -0
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +40 -0
- package/dist/utils/process.js.map +1 -0
- package/dist/utils/reserved-env.d.ts +26 -0
- package/dist/utils/reserved-env.d.ts.map +1 -0
- package/dist/utils/reserved-env.js +51 -0
- package/dist/utils/reserved-env.js.map +1 -0
- package/dist/utils/template.d.ts +15 -0
- package/dist/utils/template.d.ts.map +1 -0
- package/dist/utils/template.js +75 -0
- package/dist/utils/template.js.map +1 -0
- package/dist/utils/version.d.ts +9 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +52 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/wrangler.d.ts +192 -0
- package/dist/wrangler.d.ts.map +1 -0
- package/dist/wrangler.js +246 -0
- package/dist/wrangler.js.map +1 -0
- package/package.json +47 -0
package/dist/pipeline.js
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.buildApp = buildApp;
|
|
37
|
+
/**
|
|
38
|
+
* The build pipeline — the orchestration extracted from cosmic.ts::cosmicBuild,
|
|
39
|
+
* minus everything host-specific (source fetch, telemetry spans, upload, queue,
|
|
40
|
+
* DB). It operates on an **ephemeral workspace**: the project is copied to a
|
|
41
|
+
* temp dir, all mutation + the build happen there, and the worker-ready output
|
|
42
|
+
* is collected into `outputDir` — the user's source tree is never touched.
|
|
43
|
+
*
|
|
44
|
+
* Steps: isolate → detect → validate/install → wrangler synthesis →
|
|
45
|
+
* prepareConfig → createWebflowJson → npm install → build → postBuild →
|
|
46
|
+
* wrangler dry-run → collect output.
|
|
47
|
+
*/
|
|
48
|
+
const fs = __importStar(require("node:fs"));
|
|
49
|
+
const os = __importStar(require("node:os"));
|
|
50
|
+
const path = __importStar(require("node:path"));
|
|
51
|
+
const ports_1 = require("./ports");
|
|
52
|
+
const package_json_1 = require("./config/package-json");
|
|
53
|
+
const strip_cloudflare_base_nesting_1 = require("./frameworks/astro/adapter-patches/strip-cloudflare-base-nesting");
|
|
54
|
+
const webflow_json_1 = require("./config/webflow-json");
|
|
55
|
+
const registry_1 = require("./frameworks/registry");
|
|
56
|
+
const errors_1 = require("./frameworks/errors");
|
|
57
|
+
const utils_1 = require("./utils");
|
|
58
|
+
const wrangler_1 = require("./wrangler");
|
|
59
|
+
const create_webflow_json_1 = require("./create-webflow-json");
|
|
60
|
+
/** Top-level entries never copied into the build workspace. */
|
|
61
|
+
const ISOLATE_EXCLUDE = new Set(['node_modules', '.git']);
|
|
62
|
+
/**
|
|
63
|
+
* Copy the user's project into a fresh workspace, skipping node_modules/.git
|
|
64
|
+
* (deps are reinstalled in the workspace). Leaves the source tree pristine.
|
|
65
|
+
*/
|
|
66
|
+
function isolateWorkspace(src, dest) {
|
|
67
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
68
|
+
fs.cpSync(src, dest, {
|
|
69
|
+
recursive: true,
|
|
70
|
+
filter: (from) => !ISOLATE_EXCLUDE.has(path.basename(from)),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* URL prefix under which static assets are served. Prefers an explicit
|
|
75
|
+
* `cloud.assets_path_prefix` in webflow.json, else the mount path, else '/'.
|
|
76
|
+
*/
|
|
77
|
+
function assetPathPrefix(webflowJson, mountPath) {
|
|
78
|
+
return webflowJson?.cloud?.assets_path_prefix || mountPath || '/';
|
|
79
|
+
}
|
|
80
|
+
/** Copy framework build assets into `out/assets<prefix>`, mount-path aware. */
|
|
81
|
+
function copyAssets(ctx, frameworkName, output, cwd, out, webflowJson) {
|
|
82
|
+
const { log, mountPath = '/' } = ctx;
|
|
83
|
+
const prefix = assetPathPrefix(webflowJson, mountPath);
|
|
84
|
+
fs.mkdirSync(path.join(out, `assets${prefix}`), { recursive: true });
|
|
85
|
+
let assetsPath = output.staticAssetsPath;
|
|
86
|
+
if (!assetsPath) {
|
|
87
|
+
log.info('no assets to copy (framework does not define a static assets path)');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// Mount-path-aware source resolution for Next.js / Astro. The destination below always
|
|
91
|
+
// re-appends the mount (`assets<prefix>`), so the source must end up nested under the mount
|
|
92
|
+
// exactly once.
|
|
93
|
+
const skipMountPathForSource = webflowJson?.cloud?.assets_source_skip_mount_path === true;
|
|
94
|
+
if (frameworkName === 'nextjs' || frameworkName === 'astro') {
|
|
95
|
+
let cleanMountPath = mountPath;
|
|
96
|
+
while (cleanMountPath && cleanMountPath[0] === '/')
|
|
97
|
+
cleanMountPath = cleanMountPath.slice(1);
|
|
98
|
+
while (cleanMountPath && cleanMountPath.slice(-1) === '/')
|
|
99
|
+
cleanMountPath = cleanMountPath.slice(0, -1);
|
|
100
|
+
if (cleanMountPath && cleanMountPath.length > 0) {
|
|
101
|
+
if (skipMountPathForSource) {
|
|
102
|
+
// Astro 6/7: a fixed @astrojs/cloudflare adapter (base = mountPath) already nests the
|
|
103
|
+
// client tree under `<assetsPath>/<mount>/`, so descend into it. Copying the whole
|
|
104
|
+
// `dist/client` would double-nest to `assets/<mount>/<mount>/` (the /app/app 404).
|
|
105
|
+
assetsPath = (0, strip_cloudflare_base_nesting_1.stripCloudflareBaseNesting)(cwd, assetsPath, cleanMountPath);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// Astro 5 / Next.js: the build nests assets under the mount-path subdirectory.
|
|
109
|
+
assetsPath = path.join(assetsPath, cleanMountPath);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
log.debug(`computed asset path ${assetsPath} for ${frameworkName} (mount path ${mountPath})`);
|
|
113
|
+
}
|
|
114
|
+
const stat = fs.statSync(path.join(cwd, assetsPath), { throwIfNoEntry: false });
|
|
115
|
+
if (!stat || !stat.isDirectory()) {
|
|
116
|
+
log.info(`no assets to copy (${path.join(cwd, assetsPath)} not a directory)`);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const count = (0, utils_1.recursiveCopy)(log, path.join(cwd, assetsPath), path.join(out, `assets${prefix}`), {
|
|
120
|
+
exclude: output.staticAssetsExclude?.[0],
|
|
121
|
+
});
|
|
122
|
+
log.info(`copied ${count} asset${count === 1 ? '' : 's'}`);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Assemble the deploy-ready output directory: static assets, the
|
|
126
|
+
* contract-validated webflow.json, and the `clouduser.wrangler.json` bridge +
|
|
127
|
+
* D1 migrations the deployer consumes. The worker bundle was already written
|
|
128
|
+
* here by `wrangler deploy --dry-run --outdir`.
|
|
129
|
+
*/
|
|
130
|
+
function collectOutput(ctx, frameworkName, output, cwd, out) {
|
|
131
|
+
const { log } = ctx;
|
|
132
|
+
const webflowJson = (0, webflow_json_1.loadWebflowJson)(log, cwd);
|
|
133
|
+
copyAssets(ctx, frameworkName, output, cwd, out, webflowJson);
|
|
134
|
+
if (webflowJson) {
|
|
135
|
+
fs.writeFileSync(path.join(out, 'webflow.json'), JSON.stringify(webflowJson));
|
|
136
|
+
}
|
|
137
|
+
// Ship clouduser.wrangler.json (user bindings + migrations) for the deployer.
|
|
138
|
+
// The framework-written wrangler.json is intentionally NOT shipped — the
|
|
139
|
+
// deployer regenerates it.
|
|
140
|
+
if (fs.statSync(path.join(cwd, 'clouduser.wrangler.json'), { throwIfNoEntry: false })) {
|
|
141
|
+
fs.copyFileSync(path.join(cwd, 'clouduser.wrangler.json'), path.join(out, 'clouduser.wrangler.json'));
|
|
142
|
+
const count = (0, utils_1.recursiveCopy)(log, path.join(cwd, 'clouduser', 'migrations'), path.join(out, 'migrations'));
|
|
143
|
+
log.info(`copied ${count} migration${count === 1 ? '' : 's'} to output`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Build a project into a Webflow Cloud bundle. See module docs for the step
|
|
148
|
+
* sequence. Returns the detected framework, deployment type, bundled entry
|
|
149
|
+
* path, the emitted webflow.json, and the populated `outputDir`.
|
|
150
|
+
*/
|
|
151
|
+
async function buildApp(options) {
|
|
152
|
+
const { projectDir, outputDir } = options;
|
|
153
|
+
const log = options.ports.logger;
|
|
154
|
+
const runCommand = options.ports.runCommand;
|
|
155
|
+
const telemetry = options.ports.telemetry ?? ports_1.noopTelemetry;
|
|
156
|
+
const fsPort = options.ports.fs ?? ports_1.nodeFileSystem;
|
|
157
|
+
const mountPath = options.mountPath ?? '/';
|
|
158
|
+
const deployUrl = options.deployUrl ?? '';
|
|
159
|
+
// 1. Isolate into an ephemeral workspace so the source tree stays pristine.
|
|
160
|
+
const workspaceDir = options.workspaceDir ?? fs.mkdtempSync(path.join(os.tmpdir(), 'webflow-app-build-'));
|
|
161
|
+
log.info(`isolating project into ephemeral workspace: ${workspaceDir}`);
|
|
162
|
+
isolateWorkspace(projectDir, workspaceDir);
|
|
163
|
+
// 2. Load package.json + (optional) webflow.json from the workspace.
|
|
164
|
+
const packageJson = (0, package_json_1.loadPackageJson)(workspaceDir);
|
|
165
|
+
if (!packageJson) {
|
|
166
|
+
throw new errors_1.FrameworkDetectionError(`could not find package.json in ${projectDir}`, {
|
|
167
|
+
remediation: 'Run a build from a project directory that contains a package.json.',
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const webflowJson = (0, webflow_json_1.loadWebflowJson)(log, workspaceDir);
|
|
171
|
+
if (webflowJson?.cloud?.framework) {
|
|
172
|
+
(0, registry_1.validateFrameworkName)(webflowJson.cloud.framework);
|
|
173
|
+
log.info(`Framework specified in webflow.json: ${webflowJson.cloud.framework}`);
|
|
174
|
+
}
|
|
175
|
+
// Env made available to template substitution and the build command.
|
|
176
|
+
const userEnv = {
|
|
177
|
+
...options.env,
|
|
178
|
+
COSMIC_MOUNT_PATH: mountPath,
|
|
179
|
+
COSMIC_DEPLOY_URL: deployUrl,
|
|
180
|
+
};
|
|
181
|
+
// 3. Detect the framework and build it up.
|
|
182
|
+
const ctx = {
|
|
183
|
+
cwd: workspaceDir,
|
|
184
|
+
log,
|
|
185
|
+
runCommand,
|
|
186
|
+
telemetry,
|
|
187
|
+
fs: fsPort,
|
|
188
|
+
packageJson,
|
|
189
|
+
userEnv,
|
|
190
|
+
mountPath,
|
|
191
|
+
deployUrl,
|
|
192
|
+
};
|
|
193
|
+
const builder = (0, registry_1.detectAndCreateBuilder)(ctx, webflowJson);
|
|
194
|
+
const frameworkName = builder.info.name;
|
|
195
|
+
log.info(`Building with ${builder.info.displayName}`);
|
|
196
|
+
const span = telemetry.startSpan('buildApp', { framework: frameworkName });
|
|
197
|
+
try {
|
|
198
|
+
// 4. Validate + install framework deps.
|
|
199
|
+
const nodeReq = builder.getNodeVersionRequirement();
|
|
200
|
+
if (nodeReq) {
|
|
201
|
+
(0, utils_1.validateNodeVersion)(log, nodeReq, builder.info.displayName);
|
|
202
|
+
}
|
|
203
|
+
await builder.validate();
|
|
204
|
+
await builder.installDependencies();
|
|
205
|
+
// 5. Wrangler synthesis (sole writer of wrangler.json), then framework config.
|
|
206
|
+
(0, wrangler_1.handleWranglerJson)(log, builder, workspaceDir);
|
|
207
|
+
await builder.prepareConfig();
|
|
208
|
+
// 6. Emit the contract-validated webflow.json (producer self-check inside).
|
|
209
|
+
(0, create_webflow_json_1.createWebflowJson)(log, workspaceDir, frameworkName, builder);
|
|
210
|
+
// 7. Fresh dependency install.
|
|
211
|
+
const verb = fs.existsSync(path.join(workspaceDir, 'package-lock.json'))
|
|
212
|
+
? 'clean-install'
|
|
213
|
+
: 'install';
|
|
214
|
+
log.info(`running npm ${verb}...`);
|
|
215
|
+
await (0, utils_1.npm)({ log, runCommand, cwd: workspaceDir, args: [verb, '--include=dev'] });
|
|
216
|
+
// 8. Run the framework build (bypasses the user's package.json build script).
|
|
217
|
+
// A null build command means a no-framework static app. buildApp does not
|
|
218
|
+
// yet implement the assets-only path (asset-root relocation, no worker), so
|
|
219
|
+
// reject it here rather than silently mis-building — hosts that support
|
|
220
|
+
// static (cosmic-builder) drive the builders directly.
|
|
221
|
+
const buildCommand = builder.getBuildCommand();
|
|
222
|
+
if (buildCommand === null) {
|
|
223
|
+
throw new errors_1.FrameworkDetectionError('No-framework static apps are not yet supported by buildApp.', { remediation: 'Use a host that implements the static assets-only path.' });
|
|
224
|
+
}
|
|
225
|
+
log.info(`building using ${buildCommand}...`);
|
|
226
|
+
await (0, utils_1.npm)({
|
|
227
|
+
log,
|
|
228
|
+
runCommand,
|
|
229
|
+
cwd: workspaceDir,
|
|
230
|
+
env: userEnv,
|
|
231
|
+
args: ['exec', '-c', buildCommand],
|
|
232
|
+
}).catch((e) => {
|
|
233
|
+
throw new Error(`${frameworkName} build failed`, { cause: e });
|
|
234
|
+
});
|
|
235
|
+
await builder.postBuild();
|
|
236
|
+
// 9. Bundle the worker entry + verify bindings via wrangler dry-run.
|
|
237
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
238
|
+
log.info('creating wrangler dry-run...');
|
|
239
|
+
await (0, utils_1.npm)({
|
|
240
|
+
log,
|
|
241
|
+
runCommand,
|
|
242
|
+
cwd: workspaceDir,
|
|
243
|
+
args: ['exec', '--', 'wrangler', 'deploy', '--dry-run', `--outdir=${outputDir}`],
|
|
244
|
+
});
|
|
245
|
+
// 10. Collect assets + webflow.json + clouduser bridge into the output dir.
|
|
246
|
+
const output = builder.getOutputDeployMetadata();
|
|
247
|
+
collectOutput(ctx, frameworkName, output, workspaceDir, outputDir);
|
|
248
|
+
const finalWebflowJson = JSON.parse(fs.readFileSync(path.join(outputDir, 'webflow.json'), 'utf8'));
|
|
249
|
+
span.end();
|
|
250
|
+
return {
|
|
251
|
+
framework: frameworkName,
|
|
252
|
+
deploymentType: output.deploymentType,
|
|
253
|
+
entrypointPath: output.dryRunEntryPath ?? './index.js',
|
|
254
|
+
webflowJson: finalWebflowJson,
|
|
255
|
+
outputDir,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
catch (e) {
|
|
259
|
+
span.end(e);
|
|
260
|
+
throw e;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsJA,4BAkIC;AAxRD;;;;;;;;;;GAUG;AACH,4CAA8B;AAC9B,4CAA8B;AAC9B,gDAAkC;AAMlC,mCAAwD;AACxD,wDAAwD;AACxD,oHAA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AE,CAAC;QACX,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACZ,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface RunCommandOptions {
|
|
2
|
+
/** Working directory for the command (defaults to the host process cwd). */
|
|
3
|
+
cwd?: string;
|
|
4
|
+
/**
|
|
5
|
+
* Environment variables. When set, replaces the inherited environment at the
|
|
6
|
+
* spawn boundary — the host owns environment policy. Callers that want the
|
|
7
|
+
* host environment preserved (registry auth, proxies, custom CAs, npm config)
|
|
8
|
+
* should merge `process.env` in before passing it; the {@link npm} helper does
|
|
9
|
+
* this by default.
|
|
10
|
+
*/
|
|
11
|
+
env?: Record<string, string>;
|
|
12
|
+
/** Stream output as it arrives, e.g. to forward into the host's logger. */
|
|
13
|
+
onOutput?: (chunk: string, stream: 'stdout' | 'stderr') => void;
|
|
14
|
+
}
|
|
15
|
+
export interface CommandResult {
|
|
16
|
+
stdout: string;
|
|
17
|
+
stderr: string;
|
|
18
|
+
exitCode: number;
|
|
19
|
+
/**
|
|
20
|
+
* Set when the process was terminated by a signal (e.g. `SIGKILL` from an OOM
|
|
21
|
+
* kill, `SIGTERM` from a timeout). Signal termination is always a failure.
|
|
22
|
+
*/
|
|
23
|
+
signal?: NodeJS.Signals;
|
|
24
|
+
}
|
|
25
|
+
export interface CommandRunner {
|
|
26
|
+
/**
|
|
27
|
+
* Run `command` with `args`. Implementations SHOULD reject with a
|
|
28
|
+
* {@link CommandError} on a non-zero exit so callers can treat failures as
|
|
29
|
+
* exceptions.
|
|
30
|
+
*/
|
|
31
|
+
run(command: string, args: string[], options?: RunCommandOptions): Promise<CommandResult>;
|
|
32
|
+
}
|
|
33
|
+
/** Thrown by the default runner when a command exits non-zero or is signalled. */
|
|
34
|
+
export declare class CommandError extends Error {
|
|
35
|
+
readonly command: string;
|
|
36
|
+
readonly args: string[];
|
|
37
|
+
readonly exitCode: number;
|
|
38
|
+
readonly stdout: string;
|
|
39
|
+
readonly stderr: string;
|
|
40
|
+
readonly signal?: NodeJS.Signals;
|
|
41
|
+
constructor(command: string, args: string[], result: CommandResult);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* On Windows, `npm`/`npx`/`wrangler`/`yarn`/`pnpm` are `.cmd` shims that
|
|
45
|
+
* `spawn(..., { shell: false })` cannot launch by bare name. Resolve an
|
|
46
|
+
* extensionless, non-path command to its `.cmd` form so it launches while
|
|
47
|
+
* keeping `shell: false` — which preserves argument boundaries (unlike
|
|
48
|
+
* `shell: true`, where a multi-word arg like a build command would be re-split
|
|
49
|
+
* by the shell). No-op off Windows and for commands that already carry a path
|
|
50
|
+
* or extension.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveExecutable(command: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Default runner backed by `child_process.spawn`. Streams output in full via
|
|
55
|
+
* `onOutput`, retains a bounded tail for diagnostics, and rejects with
|
|
56
|
+
* {@link CommandError} on a non-zero exit OR signal termination. Hosts that need
|
|
57
|
+
* sandboxing or a curated environment supply their own implementation instead.
|
|
58
|
+
*/
|
|
59
|
+
export declare const nodeCommandRunner: CommandRunner;
|
|
60
|
+
//# sourceMappingURL=command-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-runner.d.ts","sourceRoot":"","sources":["../../src/ports/command-runner.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,KAAK,IAAI,CAAC;CACjE;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;CACzB;AAYD,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC3F;AAED,kFAAkF;AAClF,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;gBAErB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,aAAa;CAWnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIzD;AASD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,aA0C/B,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nodeCommandRunner = exports.CommandError = void 0;
|
|
4
|
+
exports.resolveExecutable = resolveExecutable;
|
|
5
|
+
/**
|
|
6
|
+
* Command-runner port.
|
|
7
|
+
*
|
|
8
|
+
* The build pipeline shells out for the heavy lifting (`npm install`, the
|
|
9
|
+
* framework build, `wrangler deploy --dry-run`). It never calls
|
|
10
|
+
* `child_process` directly — it goes through this port so the host owns *how*
|
|
11
|
+
* commands run: cosmic-builder runs them inside its ECS task with its own
|
|
12
|
+
* environment, the CLI runs them locally, and a sandboxed/agent host can
|
|
13
|
+
* intercept, restrict, or veto them. This is the security seam for a public,
|
|
14
|
+
* agent-importable package — nothing executes that the host didn't allow.
|
|
15
|
+
*/
|
|
16
|
+
const node_child_process_1 = require("node:child_process");
|
|
17
|
+
/**
|
|
18
|
+
* Retained-output cap (per stream). Output is still streamed in full via
|
|
19
|
+
* `onOutput`; only the in-memory `stdout`/`stderr` kept for the result/error is
|
|
20
|
+
* bounded, so a runaway build can't exhaust memory. The tail is kept (build
|
|
21
|
+
* failures report their last lines) with a marker prepended once truncation
|
|
22
|
+
* begins.
|
|
23
|
+
*/
|
|
24
|
+
const MAX_CAPTURED_OUTPUT = 1024 * 1024; // 1 MiB per stream
|
|
25
|
+
const TRUNCATION_MARKER = '…[output truncated]…\n';
|
|
26
|
+
/** Thrown by the default runner when a command exits non-zero or is signalled. */
|
|
27
|
+
class CommandError extends Error {
|
|
28
|
+
command;
|
|
29
|
+
args;
|
|
30
|
+
exitCode;
|
|
31
|
+
stdout;
|
|
32
|
+
stderr;
|
|
33
|
+
signal;
|
|
34
|
+
constructor(command, args, result) {
|
|
35
|
+
const reason = result.signal ? `killed by ${result.signal}` : `exit ${result.exitCode}`;
|
|
36
|
+
super(`Command failed (${reason}): ${command} ${args.join(' ')}`);
|
|
37
|
+
this.name = 'CommandError';
|
|
38
|
+
this.command = command;
|
|
39
|
+
this.args = args;
|
|
40
|
+
this.exitCode = result.exitCode;
|
|
41
|
+
this.stdout = result.stdout;
|
|
42
|
+
this.stderr = result.stderr;
|
|
43
|
+
this.signal = result.signal;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CommandError = CommandError;
|
|
47
|
+
/**
|
|
48
|
+
* On Windows, `npm`/`npx`/`wrangler`/`yarn`/`pnpm` are `.cmd` shims that
|
|
49
|
+
* `spawn(..., { shell: false })` cannot launch by bare name. Resolve an
|
|
50
|
+
* extensionless, non-path command to its `.cmd` form so it launches while
|
|
51
|
+
* keeping `shell: false` — which preserves argument boundaries (unlike
|
|
52
|
+
* `shell: true`, where a multi-word arg like a build command would be re-split
|
|
53
|
+
* by the shell). No-op off Windows and for commands that already carry a path
|
|
54
|
+
* or extension.
|
|
55
|
+
*/
|
|
56
|
+
function resolveExecutable(command) {
|
|
57
|
+
if (process.platform !== 'win32')
|
|
58
|
+
return command;
|
|
59
|
+
if (/[\\/]/.test(command) || /\.[^.]+$/.test(command))
|
|
60
|
+
return command;
|
|
61
|
+
return `${command}.cmd`;
|
|
62
|
+
}
|
|
63
|
+
/** Append `chunk` to `captured`, keeping the tail within {@link MAX_CAPTURED_OUTPUT}. */
|
|
64
|
+
function appendCapped(captured, chunk) {
|
|
65
|
+
const combined = captured + chunk;
|
|
66
|
+
if (combined.length <= MAX_CAPTURED_OUTPUT)
|
|
67
|
+
return combined;
|
|
68
|
+
return TRUNCATION_MARKER + combined.slice(combined.length - MAX_CAPTURED_OUTPUT);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Default runner backed by `child_process.spawn`. Streams output in full via
|
|
72
|
+
* `onOutput`, retains a bounded tail for diagnostics, and rejects with
|
|
73
|
+
* {@link CommandError} on a non-zero exit OR signal termination. Hosts that need
|
|
74
|
+
* sandboxing or a curated environment supply their own implementation instead.
|
|
75
|
+
*/
|
|
76
|
+
exports.nodeCommandRunner = {
|
|
77
|
+
run(command, args, options = {}) {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
const child = (0, node_child_process_1.spawn)(resolveExecutable(command), args, {
|
|
80
|
+
cwd: options.cwd,
|
|
81
|
+
env: options.env ?? process.env,
|
|
82
|
+
shell: false,
|
|
83
|
+
});
|
|
84
|
+
let stdout = '';
|
|
85
|
+
let stderr = '';
|
|
86
|
+
child.stdout?.on('data', (data) => {
|
|
87
|
+
const chunk = data.toString();
|
|
88
|
+
stdout = appendCapped(stdout, chunk);
|
|
89
|
+
options.onOutput?.(chunk, 'stdout');
|
|
90
|
+
});
|
|
91
|
+
child.stderr?.on('data', (data) => {
|
|
92
|
+
const chunk = data.toString();
|
|
93
|
+
stderr = appendCapped(stderr, chunk);
|
|
94
|
+
options.onOutput?.(chunk, 'stderr');
|
|
95
|
+
});
|
|
96
|
+
child.on('error', reject);
|
|
97
|
+
// `close` delivers exactly one of (code, signal). A signal kill (SIGKILL
|
|
98
|
+
// from OOM, SIGTERM from a timeout) arrives as `code === null` — treat it
|
|
99
|
+
// as a failure rather than letting `code ?? 0` mask it as success.
|
|
100
|
+
child.on('close', (code, signal) => {
|
|
101
|
+
if (code === 0) {
|
|
102
|
+
resolve({ stdout, stderr, exitCode: 0 });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const result = {
|
|
106
|
+
stdout,
|
|
107
|
+
stderr,
|
|
108
|
+
exitCode: code ?? 1,
|
|
109
|
+
signal: signal ?? undefined,
|
|
110
|
+
};
|
|
111
|
+
reject(new CommandError(command, args, result));
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=command-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-runner.js","sourceRoot":"","sources":["../../src/ports/command-runner.ts"],"names":[],"mappings":";;;AAyFA,8CAIC;AA7FD;;;;;;;;;;GAUG;AACH,2DAA2C;AA4B3C;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,mBAAmB;AAC5D,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AAWnD,kFAAkF;AAClF,MAAa,YAAa,SAAQ,KAAK;IAC5B,OAAO,CAAS;IAChB,IAAI,CAAW;IACf,QAAQ,CAAS;IACjB,MAAM,CAAS;IACf,MAAM,CAAS;IACf,MAAM,CAAkB;IAEjC,YAAY,OAAe,EAAE,IAAc,EAAE,MAAqB;QAChE,MAAM,MAAM,GAAG,MAAM,CAAC,MAA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AAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;oBACzC,OAAO;gBACT,CAAC;gBACD,MAAM,MAAM,GAAkB;oBAC5B,MAAM;oBACN,MAAM;oBACN,QAAQ,EAAE,IAAI,IAAI,CAAC;oBACnB,MAAM,EAAE,MAAM,IAAI,SAAS;iBAC5B,CAAC;gBACF,MAAM,CAAC,IAAI,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface FileSystemPort {
|
|
2
|
+
readFile(path: string): Promise<string>;
|
|
3
|
+
writeFile(path: string, data: string): Promise<void>;
|
|
4
|
+
exists(path: string): Promise<boolean>;
|
|
5
|
+
mkdir(path: string, options?: {
|
|
6
|
+
recursive?: boolean;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
rm(path: string, options?: {
|
|
9
|
+
recursive?: boolean;
|
|
10
|
+
force?: boolean;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
readdir(path: string): Promise<string[]>;
|
|
13
|
+
rename(from: string, to: string): Promise<void>;
|
|
14
|
+
/** Recursively copy `from` to `to`. */
|
|
15
|
+
copy(from: string, to: string): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/** Default filesystem backed by `node:fs/promises`. */
|
|
18
|
+
export declare const nodeFileSystem: FileSystemPort;
|
|
19
|
+
//# sourceMappingURL=filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../src/ports/filesystem.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpF,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,uCAAuC;IACvC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED,uDAAuD;AACvD,eAAO,MAAM,cAAc,EAAE,cAmB5B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.nodeFileSystem = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* Filesystem port.
|
|
39
|
+
*
|
|
40
|
+
* The pipeline reads/writes the ephemeral workspace through this port rather
|
|
41
|
+
* than `node:fs` directly. The node-backed default below is what every
|
|
42
|
+
* server/CLI host uses; the seam exists so unusual hosts (e.g. a browser-based
|
|
43
|
+
* agent with a virtual filesystem) can plug in their own, and so tests can
|
|
44
|
+
* observe filesystem effects without touching disk.
|
|
45
|
+
*/
|
|
46
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
47
|
+
/** Default filesystem backed by `node:fs/promises`. */
|
|
48
|
+
exports.nodeFileSystem = {
|
|
49
|
+
readFile: (path) => fs.readFile(path, 'utf8'),
|
|
50
|
+
writeFile: (path, data) => fs.writeFile(path, data, 'utf8'),
|
|
51
|
+
exists: async (path) => {
|
|
52
|
+
try {
|
|
53
|
+
await fs.access(path);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
mkdir: async (path, options) => {
|
|
61
|
+
await fs.mkdir(path, { recursive: options?.recursive ?? false });
|
|
62
|
+
},
|
|
63
|
+
rm: (path, options) => fs.rm(path, { recursive: options?.recursive ?? false, force: options?.force ?? false }),
|
|
64
|
+
readdir: (path) => fs.readdir(path),
|
|
65
|
+
rename: (from, to) => fs.rename(from, to),
|
|
66
|
+
copy: (from, to) => fs.cp(from, to, { recursive: true }),
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=filesystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../../src/ports/filesystem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;GAQG;AACH,qDAAuC;AAcvC,uDAAuD;AAC1C,QAAA,cAAc,GAAmB;IAC5C,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC7C,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC;IAC3D,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;QAC7B,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,KAAK,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CACpB,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,CAAC;IACzF,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACnC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;IACzC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;CACzD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ports — the injection seam between the build engine and its host.
|
|
3
|
+
*
|
|
4
|
+
* Everything environment-specific (logging, command execution, telemetry,
|
|
5
|
+
* filesystem) is expressed as a port with a safe default. Hosts override what
|
|
6
|
+
* they need and inherit the rest, so the same engine runs in ECS
|
|
7
|
+
* (cosmic-builder), locally (CLI), and headless (MCP/agents).
|
|
8
|
+
*/
|
|
9
|
+
export type { Logger } from './logger';
|
|
10
|
+
export { consoleLogger, silentLogger } from './logger';
|
|
11
|
+
export type { CommandRunner, CommandResult, RunCommandOptions } from './command-runner';
|
|
12
|
+
export { nodeCommandRunner, CommandError } from './command-runner';
|
|
13
|
+
export type { Telemetry, Span, TagValue } from './telemetry';
|
|
14
|
+
export { noopTelemetry } from './telemetry';
|
|
15
|
+
export type { FileSystemPort } from './filesystem';
|
|
16
|
+
export { nodeFileSystem } from './filesystem';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ports/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEvD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEnE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nodeFileSystem = exports.noopTelemetry = exports.CommandError = exports.nodeCommandRunner = exports.silentLogger = exports.consoleLogger = void 0;
|
|
4
|
+
var logger_1 = require("./logger");
|
|
5
|
+
Object.defineProperty(exports, "consoleLogger", { enumerable: true, get: function () { return logger_1.consoleLogger; } });
|
|
6
|
+
Object.defineProperty(exports, "silentLogger", { enumerable: true, get: function () { return logger_1.silentLogger; } });
|
|
7
|
+
var command_runner_1 = require("./command-runner");
|
|
8
|
+
Object.defineProperty(exports, "nodeCommandRunner", { enumerable: true, get: function () { return command_runner_1.nodeCommandRunner; } });
|
|
9
|
+
Object.defineProperty(exports, "CommandError", { enumerable: true, get: function () { return command_runner_1.CommandError; } });
|
|
10
|
+
var telemetry_1 = require("./telemetry");
|
|
11
|
+
Object.defineProperty(exports, "noopTelemetry", { enumerable: true, get: function () { return telemetry_1.noopTelemetry; } });
|
|
12
|
+
var filesystem_1 = require("./filesystem");
|
|
13
|
+
Object.defineProperty(exports, "nodeFileSystem", { enumerable: true, get: function () { return filesystem_1.nodeFileSystem; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ports/index.ts"],"names":[],"mappings":";;;AASA,mCAAuD;AAA9C,uGAAA,aAAa,OAAA;AAAE,sGAAA,YAAY,OAAA;AAGpC,mDAAmE;AAA1D,mHAAA,iBAAiB,OAAA;AAAE,8GAAA,YAAY,OAAA;AAGxC,yCAA4C;AAAnC,0GAAA,aAAa,OAAA;AAGtB,2CAA8C;AAArC,4GAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger port.
|
|
3
|
+
*
|
|
4
|
+
* The engine never reaches for `console` directly — it logs through this
|
|
5
|
+
* interface so each host can route output its own way: cosmic-builder wraps its
|
|
6
|
+
* structured ECS logger (with secret redaction), the CLI wraps its oclif logger
|
|
7
|
+
* with spinners/colors, and headless/agent hosts can stay silent or capture.
|
|
8
|
+
*
|
|
9
|
+
* Intentionally the minimal four-level surface the build pipeline needs. Hosts
|
|
10
|
+
* with richer loggers adapt down to this; they lose nothing the engine relies on.
|
|
11
|
+
*/
|
|
12
|
+
export interface Logger {
|
|
13
|
+
debug(message: string, ...args: unknown[]): void;
|
|
14
|
+
info(message: string, ...args: unknown[]): void;
|
|
15
|
+
warn(message: string, ...args: unknown[]): void;
|
|
16
|
+
error(message: string, ...args: unknown[]): void;
|
|
17
|
+
}
|
|
18
|
+
/** Default logger that writes to the console. Useful for the CLI and local runs. */
|
|
19
|
+
export declare const consoleLogger: Logger;
|
|
20
|
+
/** Logger that drops everything. Useful for tests and headless callers. */
|
|
21
|
+
export declare const silentLogger: Logger;
|
|
22
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/ports/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAClD;AAED,oFAAoF;AACpF,eAAO,MAAM,aAAa,EAAE,MAK3B,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,YAAY,EAAE,MAK1B,CAAC"}
|