@di-framework/cli-plugin-platform 0.0.1 → 6.0.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/README.md +408 -0
- package/dist/actor-protocol.d.ts +4 -0
- package/dist/actor-protocol.js +162 -0
- package/dist/actors.d.ts +31 -0
- package/dist/actors.js +296 -0
- package/dist/args.d.ts +15 -0
- package/dist/args.js +66 -0
- package/dist/assets/http-adapter.js +876 -0
- package/dist/assets/platform/.gitignore.tmpl +6 -0
- package/dist/assets/platform/Pulumi.yaml.tmpl +6 -0
- package/dist/assets/platform/README.md +208 -0
- package/dist/assets/platform/index.ts.tmpl +2 -0
- package/dist/assets/platform/package.json.tmpl +18 -0
- package/dist/assets/platform/tsconfig.json +11 -0
- package/dist/assets/queue-adapter.js +60 -0
- package/dist/assets/sqlite/BUILD-INFO.txt +13 -0
- package/dist/assets/sqlite/SHA256SUMS +2 -0
- package/dist/assets/sqlite/di-framework-sqlite.wasm +0 -0
- package/dist/assets/sqlite/di-framework-sqlite.wit +337 -0
- package/dist/assets/wit/deps/LICENSE.md +8 -0
- package/dist/assets/wit/deps/di-framework-queues/package.wit +18 -0
- package/dist/assets/wit/deps/di-framework-sqlite/package.wit +211 -0
- package/dist/assets/wit/deps/wasi-cli/package.wit +70 -0
- package/dist/assets/wit/deps/wasi-clocks/package.wit +42 -0
- package/dist/assets/wit/deps/wasi-config/package.wit +15 -0
- package/dist/assets/wit/deps/wasi-filesystem/package.wit +184 -0
- package/dist/assets/wit/deps/wasi-http/package.wit +170 -0
- package/dist/assets/wit/deps/wasi-random/package.wit +17 -0
- package/dist/assets/wit/deps/wasi-sockets/package.wit +105 -0
- package/dist/assets/wit/deps/wasi-tls/package.wit +26 -0
- package/dist/assets/wit/deps/wasmcloud-blobstore/package.wit +153 -0
- package/dist/assets/wit/deps/wasmcloud-keyvalue/package.wit +370 -0
- package/dist/assets/wit/deps/wasmcloud-messaging/package.wit +125 -0
- package/dist/assets/wit/deps/wasmcloud-postgres/package.wit +435 -0
- package/dist/assets/wit/deps/wasmcloud-secrets/package.wit +80 -0
- package/dist/async-transform.d.ts +3 -0
- package/dist/async-transform.js +60 -0
- package/dist/bindings.d.ts +34 -0
- package/dist/bindings.js +307 -0
- package/dist/build.d.ts +29 -0
- package/dist/build.js +325 -0
- package/dist/command.d.ts +3 -0
- package/dist/command.js +141 -0
- package/dist/control/auth.d.ts +18 -0
- package/dist/control/auth.js +89 -0
- package/dist/control/cron.d.ts +7 -0
- package/dist/control/cron.js +86 -0
- package/dist/control/index.d.ts +4 -0
- package/dist/control/index.js +4 -0
- package/dist/control/network.d.ts +12 -0
- package/dist/control/network.js +49 -0
- package/dist/control/queues.d.ts +15 -0
- package/dist/control/queues.js +77 -0
- package/dist/cron.d.ts +26 -0
- package/dist/cron.js +239 -0
- package/dist/deploy.d.ts +29 -0
- package/dist/deploy.js +57 -0
- package/dist/deps.d.ts +96 -0
- package/dist/deps.js +303 -0
- package/dist/destroy.d.ts +3 -0
- package/dist/destroy.js +24 -0
- package/dist/dev-runner.d.ts +24 -0
- package/dist/dev-runner.js +83 -0
- package/dist/dev.d.ts +8 -0
- package/dist/dev.js +76 -0
- package/dist/discovery.d.ts +15 -0
- package/dist/discovery.js +182 -0
- package/dist/doctor.d.ts +8 -0
- package/dist/doctor.js +82 -0
- package/dist/guests.d.ts +9 -0
- package/dist/guests.js +56 -0
- package/dist/host-interface.d.ts +29 -0
- package/dist/host-interface.js +142 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +39 -0
- package/dist/kubernetes.d.ts +9 -0
- package/dist/kubernetes.js +17 -0
- package/dist/managed-bindings.d.ts +9 -0
- package/dist/managed-bindings.js +150 -0
- package/dist/manifest.d.ts +36 -0
- package/dist/manifest.js +257 -0
- package/dist/namespace.d.ts +2 -0
- package/dist/namespace.js +4 -0
- package/dist/node-compat/async-hooks.d.ts +29 -0
- package/dist/node-compat/async-hooks.js +80 -0
- package/dist/node-compat/bootstrap.d.ts +1 -0
- package/dist/node-compat/bootstrap.js +9 -0
- package/dist/node-compat/bytes.d.ts +7 -0
- package/dist/node-compat/bytes.js +41 -0
- package/dist/node-compat/crypto-hash.d.ts +27 -0
- package/dist/node-compat/crypto-hash.js +108 -0
- package/dist/node-compat/crypto-subtle.d.ts +59 -0
- package/dist/node-compat/crypto-subtle.js +288 -0
- package/dist/node-compat/crypto.d.ts +136 -0
- package/dist/node-compat/crypto.js +142 -0
- package/dist/node-compat/dgram.d.ts +49 -0
- package/dist/node-compat/dgram.js +197 -0
- package/dist/node-compat/env.d.ts +6 -0
- package/dist/node-compat/env.js +88 -0
- package/dist/node-compat/fetch-runtime.d.ts +80 -0
- package/dist/node-compat/fetch-runtime.js +314 -0
- package/dist/node-compat/fs.d.ts +84 -0
- package/dist/node-compat/fs.js +285 -0
- package/dist/node-compat/http-parser.d.ts +40 -0
- package/dist/node-compat/http-parser.js +185 -0
- package/dist/node-compat/http.d.ts +130 -0
- package/dist/node-compat/http.js +688 -0
- package/dist/node-compat/https.d.ts +28 -0
- package/dist/node-compat/https.js +88 -0
- package/dist/node-compat/module.d.ts +11 -0
- package/dist/node-compat/module.js +35 -0
- package/dist/node-compat/net.d.ts +119 -0
- package/dist/node-compat/net.js +441 -0
- package/dist/node-compat/process.d.ts +25 -0
- package/dist/node-compat/process.js +63 -0
- package/dist/node-compat/runtime-application.d.ts +4 -0
- package/dist/node-compat/runtime-application.js +24 -0
- package/dist/node-compat/seed-virtual.d.ts +6 -0
- package/dist/node-compat/seed-virtual.js +6 -0
- package/dist/node-compat/seed.d.ts +20 -0
- package/dist/node-compat/seed.js +106 -0
- package/dist/node-compat/socket-address.d.ts +35 -0
- package/dist/node-compat/socket-address.js +162 -0
- package/dist/node-compat/timers.d.ts +32 -0
- package/dist/node-compat/timers.js +96 -0
- package/dist/node-compat/tls.d.ts +57 -0
- package/dist/node-compat/tls.js +290 -0
- package/dist/node-compat/wasi-random.d.ts +2 -0
- package/dist/node-compat/wasi-random.js +25 -0
- package/dist/node-compat/wasi-sockets.d.ts +47 -0
- package/dist/node-compat/wasi-sockets.js +134 -0
- package/dist/oci.d.ts +9 -0
- package/dist/oci.js +9 -0
- package/dist/paths.d.ts +7 -0
- package/dist/paths.js +13 -0
- package/dist/platform-init.d.ts +13 -0
- package/dist/platform-init.js +265 -0
- package/dist/platform.d.ts +22 -0
- package/dist/platform.js +170 -0
- package/dist/project.d.ts +39 -0
- package/dist/project.js +130 -0
- package/dist/publish.d.ts +15 -0
- package/dist/publish.js +57 -0
- package/dist/pulumi.d.ts +4 -0
- package/dist/pulumi.js +27 -0
- package/dist/queues-module.d.ts +4 -0
- package/dist/queues-module.js +89 -0
- package/dist/queues.d.ts +16 -0
- package/dist/queues.js +167 -0
- package/dist/registry.d.ts +16 -0
- package/dist/registry.js +27 -0
- package/dist/service.d.ts +162 -0
- package/dist/service.js +678 -0
- package/dist/support.d.ts +14 -0
- package/dist/support.js +37 -0
- package/dist/target.d.ts +18 -0
- package/dist/target.js +45 -0
- package/dist/toml.d.ts +6 -0
- package/dist/toml.js +245 -0
- package/dist/wash-dev.d.ts +18 -0
- package/dist/wash-dev.js +80 -0
- package/dist/wit.d.ts +76 -0
- package/dist/wit.js +248 -0
- package/dist/workload-members.d.ts +12 -0
- package/dist/workload-members.js +136 -0
- package/dist/workload.d.ts +45 -0
- package/dist/workload.js +457 -0
- package/package.json +55 -8
- package/src/index.ts +0 -2
package/dist/cron.js
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
import { ALWAYS_SKIP_DIRECTORIES } from './manifest.js';
|
|
5
|
+
export function toKebabCase(str) {
|
|
6
|
+
return str
|
|
7
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
8
|
+
.toLowerCase()
|
|
9
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
10
|
+
.replace(/^-+|-+$/g, '');
|
|
11
|
+
}
|
|
12
|
+
export function normalizeCronExpression(schedule) {
|
|
13
|
+
if (typeof schedule === 'number') {
|
|
14
|
+
const mins = Math.max(1, Math.round(schedule / 60000));
|
|
15
|
+
return mins === 1 ? '* * * * *' : `*/${mins} * * * *`;
|
|
16
|
+
}
|
|
17
|
+
return schedule.trim();
|
|
18
|
+
}
|
|
19
|
+
function stringLiteral(node) {
|
|
20
|
+
if (node === undefined)
|
|
21
|
+
return undefined;
|
|
22
|
+
if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node))
|
|
23
|
+
return node.text;
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function numericLiteral(node) {
|
|
27
|
+
if (node === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
if (ts.isNumericLiteral(node))
|
|
30
|
+
return Number(node.text);
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
function booleanLiteral(node) {
|
|
34
|
+
if (node === undefined)
|
|
35
|
+
return undefined;
|
|
36
|
+
if (node.kind === ts.SyntaxKind.TrueKeyword)
|
|
37
|
+
return true;
|
|
38
|
+
if (node.kind === ts.SyntaxKind.FalseKeyword)
|
|
39
|
+
return false;
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
function memberDecorators(node) {
|
|
43
|
+
const fromModifiers = (node.modifiers ?? []).filter((modifier) => ts.isDecorator(modifier));
|
|
44
|
+
const legacy = node
|
|
45
|
+
.decorators;
|
|
46
|
+
return [...fromModifiers, ...(legacy ?? [])];
|
|
47
|
+
}
|
|
48
|
+
function decoratorName(expression) {
|
|
49
|
+
let current = expression;
|
|
50
|
+
while (ts.isCallExpression(current))
|
|
51
|
+
current = current.expression;
|
|
52
|
+
if (ts.isIdentifier(current))
|
|
53
|
+
return current.text;
|
|
54
|
+
if (!ts.isPropertyAccessExpression(current) || !ts.isIdentifier(current.name))
|
|
55
|
+
return undefined;
|
|
56
|
+
return current.name.text;
|
|
57
|
+
}
|
|
58
|
+
function parseJobOptions(node) {
|
|
59
|
+
if (node === undefined || !ts.isObjectLiteralExpression(node))
|
|
60
|
+
return {};
|
|
61
|
+
const opts = {};
|
|
62
|
+
for (const prop of node.properties) {
|
|
63
|
+
if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name))
|
|
64
|
+
continue;
|
|
65
|
+
const name = prop.name.text;
|
|
66
|
+
const val = prop.initializer;
|
|
67
|
+
if (name === 'name')
|
|
68
|
+
opts.name = stringLiteral(val);
|
|
69
|
+
else if (name === 'allowConcurrent')
|
|
70
|
+
opts.allowConcurrent = booleanLiteral(val);
|
|
71
|
+
else if (name === 'description')
|
|
72
|
+
opts.description = stringLiteral(val);
|
|
73
|
+
else if (name === 'timeoutMs')
|
|
74
|
+
opts.timeoutMs = numericLiteral(val);
|
|
75
|
+
}
|
|
76
|
+
return opts;
|
|
77
|
+
}
|
|
78
|
+
function walkSourceFiles(dir, results) {
|
|
79
|
+
if (!existsSync(dir))
|
|
80
|
+
return;
|
|
81
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
82
|
+
for (const entry of entries) {
|
|
83
|
+
if (ALWAYS_SKIP_DIRECTORIES.has(entry.name))
|
|
84
|
+
continue;
|
|
85
|
+
const fullPath = join(dir, entry.name);
|
|
86
|
+
if (entry.isDirectory()) {
|
|
87
|
+
walkSourceFiles(fullPath, results);
|
|
88
|
+
}
|
|
89
|
+
else if (entry.isFile() &&
|
|
90
|
+
(entry.name.endsWith('.ts') || entry.name.endsWith('.js')) &&
|
|
91
|
+
!entry.name.endsWith('.d.ts')) {
|
|
92
|
+
results.push(fullPath);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export function discoverScheduledJobsInFile(filePath) {
|
|
97
|
+
let sourceText;
|
|
98
|
+
try {
|
|
99
|
+
sourceText = readFileSync(filePath, 'utf8');
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
// Fast pre-filter
|
|
105
|
+
if (!sourceText.includes('Cron'))
|
|
106
|
+
return [];
|
|
107
|
+
const source = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
108
|
+
const jobs = [];
|
|
109
|
+
function visit(node) {
|
|
110
|
+
if (ts.isClassDeclaration(node) && node.name) {
|
|
111
|
+
const className = node.name.text;
|
|
112
|
+
for (const member of node.members) {
|
|
113
|
+
if (ts.isMethodDeclaration(member) && member.name && ts.isIdentifier(member.name)) {
|
|
114
|
+
const methodName = member.name.text;
|
|
115
|
+
const decorators = memberDecorators(member);
|
|
116
|
+
for (const decorator of decorators) {
|
|
117
|
+
if (!ts.isCallExpression(decorator.expression))
|
|
118
|
+
continue;
|
|
119
|
+
const name = decoratorName(decorator.expression);
|
|
120
|
+
if (name === 'Cron') {
|
|
121
|
+
const [scheduleArg, optionsArg] = decorator.expression.arguments;
|
|
122
|
+
const stringSchedule = stringLiteral(scheduleArg);
|
|
123
|
+
const numSchedule = numericLiteral(scheduleArg);
|
|
124
|
+
const schedule = stringSchedule ?? numSchedule;
|
|
125
|
+
if (schedule === undefined)
|
|
126
|
+
continue;
|
|
127
|
+
const options = parseJobOptions(optionsArg);
|
|
128
|
+
const jobId = options.name || `${className}.${methodName}`;
|
|
129
|
+
const kebabId = options.name
|
|
130
|
+
? toKebabCase(options.name)
|
|
131
|
+
: `${toKebabCase(className)}-${toKebabCase(methodName)}`;
|
|
132
|
+
const cronExpression = normalizeCronExpression(schedule);
|
|
133
|
+
jobs.push({
|
|
134
|
+
jobId,
|
|
135
|
+
kebabId,
|
|
136
|
+
className,
|
|
137
|
+
methodName,
|
|
138
|
+
schedule,
|
|
139
|
+
cronExpression,
|
|
140
|
+
name: options.name,
|
|
141
|
+
allowConcurrent: options.allowConcurrent ?? false,
|
|
142
|
+
description: options.description,
|
|
143
|
+
timeoutMs: options.timeoutMs,
|
|
144
|
+
filePath,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
ts.forEachChild(node, visit);
|
|
152
|
+
}
|
|
153
|
+
visit(source);
|
|
154
|
+
return jobs;
|
|
155
|
+
}
|
|
156
|
+
export function discoverScheduledJobs(projectRoot) {
|
|
157
|
+
const srcDir = join(projectRoot, 'src');
|
|
158
|
+
const files = [];
|
|
159
|
+
if (existsSync(srcDir)) {
|
|
160
|
+
walkSourceFiles(srcDir, files);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
walkSourceFiles(projectRoot, files);
|
|
164
|
+
}
|
|
165
|
+
const allJobs = [];
|
|
166
|
+
const seenIds = new Set();
|
|
167
|
+
for (const file of files) {
|
|
168
|
+
const jobs = discoverScheduledJobsInFile(file);
|
|
169
|
+
for (const job of jobs) {
|
|
170
|
+
if (!seenIds.has(job.jobId)) {
|
|
171
|
+
seenIds.add(job.jobId);
|
|
172
|
+
allJobs.push(job);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return allJobs;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Renders the private invocation interface module.
|
|
180
|
+
* Resolves the owning service through DI, awaits the method, and reports completion or failure.
|
|
181
|
+
*/
|
|
182
|
+
export function renderCronInvokerModule(jobs) {
|
|
183
|
+
return `// Private cron invocation interface generated by @di-framework/cli-plugin-platform
|
|
184
|
+
import { loadApplication } from 'virtual:di-framework-wasmcloud-runtime';
|
|
185
|
+
|
|
186
|
+
export const scheduledJobs = ${JSON.stringify(jobs, null, 2)};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Invokes a scheduled method by resolving the owning service through DI,
|
|
190
|
+
* awaiting execution, and returning a structured result.
|
|
191
|
+
*/
|
|
192
|
+
export async function invokeJob(jobId, context) {
|
|
193
|
+
const application = await loadApplication();
|
|
194
|
+
const container = application.default?.container ?? application.container ?? application.default;
|
|
195
|
+
if (typeof container?.invokeCronJob !== 'function') {
|
|
196
|
+
throw new TypeError('Scheduled application must export its registered container');
|
|
197
|
+
}
|
|
198
|
+
container.setCronMode('external');
|
|
199
|
+
return await container.invokeCronJob(jobId, context);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function listJobs() {
|
|
203
|
+
return scheduledJobs;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function getJob(jobId) {
|
|
207
|
+
return scheduledJobs.find(
|
|
208
|
+
(j) => j.jobId === jobId || j.name === jobId || \`\${j.className}.\${j.methodName}\` === jobId,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export default {
|
|
213
|
+
invokeJob,
|
|
214
|
+
listJobs,
|
|
215
|
+
getJob,
|
|
216
|
+
scheduledJobs,
|
|
217
|
+
};
|
|
218
|
+
`;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Adapter module used when a component has ONLY scheduled jobs and no HTTP ingress.
|
|
222
|
+
*/
|
|
223
|
+
export function renderCronAdapterModule(jobs) {
|
|
224
|
+
return `// Scheduled-only component adapter (no HTTP ingress)
|
|
225
|
+
export * from './cron-invoker.js';
|
|
226
|
+
import { invokeJob } from './cron-invoker.js';
|
|
227
|
+
import { getEnvironment } from 'wasi:cli/environment@0.3.0';
|
|
228
|
+
|
|
229
|
+
export const run = {
|
|
230
|
+
async run() {
|
|
231
|
+
const environment = Object.fromEntries(getEnvironment());
|
|
232
|
+
const jobId = environment.DI_CRON_INVOKE_JOB;
|
|
233
|
+
if (!jobId) throw new Error('DI_CRON_INVOKE_JOB is required');
|
|
234
|
+
const result = await invokeJob(jobId);
|
|
235
|
+
if (!result.success) throw new Error(result.error || 'Cron invocation failed');
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
`;
|
|
239
|
+
}
|
package/dist/deploy.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CliIo, CommandResult } from '@di-framework/cli-extension';
|
|
2
|
+
import { type WasmcloudDeps } from './deps.js';
|
|
3
|
+
import type { RegistryLocation } from './registry.js';
|
|
4
|
+
export type WasmcloudDeployData = {
|
|
5
|
+
cronJobs?: Array<{
|
|
6
|
+
jobId: string;
|
|
7
|
+
schedule: string | number;
|
|
8
|
+
cronExpression: string;
|
|
9
|
+
}>;
|
|
10
|
+
application: string;
|
|
11
|
+
target: string;
|
|
12
|
+
namespace: string;
|
|
13
|
+
registry: RegistryLocation;
|
|
14
|
+
image: string;
|
|
15
|
+
publishedImage: string;
|
|
16
|
+
digest: string;
|
|
17
|
+
deploymentDigest: string;
|
|
18
|
+
service: string;
|
|
19
|
+
http?: {
|
|
20
|
+
url: string;
|
|
21
|
+
host: string;
|
|
22
|
+
};
|
|
23
|
+
endpoints?: Record<string, string>;
|
|
24
|
+
};
|
|
25
|
+
export type WasmcloudDeployResult = Omit<CommandResult, 'data' | 'text'> & {
|
|
26
|
+
data: WasmcloudDeployData;
|
|
27
|
+
text: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function runWasmcloudDeploy(args: readonly string[], io: CliIo, deps?: WasmcloudDeps): Promise<WasmcloudDeployResult>;
|
package/dist/deploy.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { parseAppCommandArgs } from './args.js';
|
|
2
|
+
import { buildComponent } from './build.js';
|
|
3
|
+
import { discoverScheduledJobs } from './cron.js';
|
|
4
|
+
import { DEFAULT_DEPS } from './deps.js';
|
|
5
|
+
import { discoverProjects, resolveApplication } from './discovery.js';
|
|
6
|
+
import { loadDeployManifest } from './manifest.js';
|
|
7
|
+
import { publishComponent } from './publish.js';
|
|
8
|
+
import { resolveConnection, resolveTarget } from './target.js';
|
|
9
|
+
import { applyWorkload, deploymentResourceName } from './workload.js';
|
|
10
|
+
import { writeWorkloadManifest } from './workload-members.js';
|
|
11
|
+
export async function runWasmcloudDeploy(args, io, deps = DEFAULT_DEPS) {
|
|
12
|
+
const options = parseAppCommandArgs(args, 'platform deploy');
|
|
13
|
+
const manifest = loadDeployManifest(deps.cwd(), deps.env);
|
|
14
|
+
const target = resolveTarget(manifest, options.target);
|
|
15
|
+
const project = resolveApplication(deps.cwd(), options.name, manifest.workspaceRoot, manifest.discovery);
|
|
16
|
+
if (project.workload) {
|
|
17
|
+
const path = writeWorkloadManifest(manifest.workspaceRoot, project.workload, discoverProjects(manifest.workspaceRoot, manifest.discovery).values());
|
|
18
|
+
io.stdout.write(`Generated workload manifest ${path}\n`);
|
|
19
|
+
}
|
|
20
|
+
const build = await buildComponent(project, io, deps);
|
|
21
|
+
const connection = await resolveConnection(target, manifest.workspaceRoot, manifest.path, deps);
|
|
22
|
+
io.stdout.write(`Deploying ${project.applicationName} to target ${connection.target}...\n`);
|
|
23
|
+
const image = await publishComponent(project, connection, io, deps, build.deploymentDigest);
|
|
24
|
+
await applyWorkload(project, connection, image.pullReference, io, deps);
|
|
25
|
+
const service = deploymentResourceName(project);
|
|
26
|
+
const hasHttp = project.ingress !== false;
|
|
27
|
+
const cronJobs = discoverScheduledJobs(project.projectRoot);
|
|
28
|
+
return {
|
|
29
|
+
data: {
|
|
30
|
+
application: project.applicationName,
|
|
31
|
+
target: connection.target,
|
|
32
|
+
namespace: connection.namespace,
|
|
33
|
+
registry: connection.registry,
|
|
34
|
+
image: image.pullReference,
|
|
35
|
+
publishedImage: image.pushReference,
|
|
36
|
+
digest: image.artifactDigest,
|
|
37
|
+
deploymentDigest: image.digest,
|
|
38
|
+
service,
|
|
39
|
+
...(hasHttp && connection.endpoints?.http !== undefined
|
|
40
|
+
? { http: { url: connection.endpoints.http, host: project.applicationName } }
|
|
41
|
+
: {}),
|
|
42
|
+
...(connection.endpoints === undefined ? {} : { endpoints: connection.endpoints }),
|
|
43
|
+
...(cronJobs.length > 0
|
|
44
|
+
? {
|
|
45
|
+
cronJobs: cronJobs.map((j) => ({
|
|
46
|
+
jobId: j.jobId,
|
|
47
|
+
schedule: j.schedule,
|
|
48
|
+
cronExpression: j.cronExpression,
|
|
49
|
+
})),
|
|
50
|
+
}
|
|
51
|
+
: {}),
|
|
52
|
+
},
|
|
53
|
+
text: `Deployed ${project.applicationName} to ${connection.target} (namespace ${connection.namespace}, ${image.pullReference}).${hasHttp && connection.endpoints?.http !== undefined
|
|
54
|
+
? ` HTTP: ${connection.endpoints.http} with Host: ${project.applicationName}`
|
|
55
|
+
: ''}${cronJobs.length > 0 ? ` Scheduled jobs (${cronJobs.length}): ${cronJobs.map((j) => j.jobId).join(', ')}` : ''}`,
|
|
56
|
+
};
|
|
57
|
+
}
|
package/dist/deps.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type NodeCompatSeed } from './node-compat/seed.js';
|
|
2
|
+
export type ProcessRunOptions = {
|
|
3
|
+
cwd: string;
|
|
4
|
+
env?: Record<string, string | undefined>;
|
|
5
|
+
};
|
|
6
|
+
export type ProcessRunner = (command: string, args: readonly string[], options: ProcessRunOptions) => Promise<{
|
|
7
|
+
exitCode: number;
|
|
8
|
+
}>;
|
|
9
|
+
export type CapturedProcess = {
|
|
10
|
+
exitCode: number;
|
|
11
|
+
stdout: string;
|
|
12
|
+
stderr: string;
|
|
13
|
+
};
|
|
14
|
+
export type CapturedRunner = (command: string, args: readonly string[], options: ProcessRunOptions) => Promise<CapturedProcess>;
|
|
15
|
+
/** First output line of a probe command, or undefined when it is unavailable. */
|
|
16
|
+
export type CaptureRunner = (command: string, args: readonly string[]) => string | undefined;
|
|
17
|
+
export type BundleOptions = {
|
|
18
|
+
adapterPath: string;
|
|
19
|
+
entryPath: string;
|
|
20
|
+
outFile: string;
|
|
21
|
+
guestsPath?: string;
|
|
22
|
+
actorsPath?: string;
|
|
23
|
+
cronPath?: string;
|
|
24
|
+
queuesPath?: string;
|
|
25
|
+
projectRoot?: string;
|
|
26
|
+
files?: Record<string, string>;
|
|
27
|
+
env?: Record<string, string | undefined>;
|
|
28
|
+
cwd?: string;
|
|
29
|
+
};
|
|
30
|
+
export type Bundler = (options: BundleOptions) => Promise<void>;
|
|
31
|
+
/** Component imports are WIT specifiers, not npm packages. */
|
|
32
|
+
export declare const COMPONENT_IMPORT_EXTERNAL: RegExp;
|
|
33
|
+
/** Every process, filesystem-adjacent, and toolchain boundary the commands touch. */
|
|
34
|
+
export type WasmcloudDeps = {
|
|
35
|
+
runner: ProcessRunner;
|
|
36
|
+
capture: CaptureRunner;
|
|
37
|
+
/** Captures stdout/stderr for tools whose output the CLI must parse. */
|
|
38
|
+
runCaptured: CapturedRunner;
|
|
39
|
+
wait(ms: number): Promise<void>;
|
|
40
|
+
bundler: Bundler;
|
|
41
|
+
jcoCliPath(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional componentize-qjs CLI built against wasmtime 48+ with
|
|
44
|
+
* `concurrency_support`. Resolved from `DI_FRAMEWORK_COMPONENTIZE_QJS`,
|
|
45
|
+
* `@di-framework/componentize-qjs`, or `PATH`. Stock jco 1.32.1 uses
|
|
46
|
+
* wasmtime 47, which cannot stub imported `async func`s during wizer.
|
|
47
|
+
*/
|
|
48
|
+
componentizeQjsPath(): string | undefined;
|
|
49
|
+
/** jco needs real Node.js; it uses node internals Bun does not implement. */
|
|
50
|
+
nodeBinaryPath(): string | undefined;
|
|
51
|
+
/** wasmtime serve hosts WASI 0.3 HTTP components locally. */
|
|
52
|
+
wasmtimeBinaryPath(): string | undefined;
|
|
53
|
+
washBinaryPath(): string | undefined;
|
|
54
|
+
assetsDirectory(): string;
|
|
55
|
+
resolveFromProject(projectRoot: string, specifier: string): string | undefined;
|
|
56
|
+
env: Record<string, string | undefined>;
|
|
57
|
+
cwd(): string;
|
|
58
|
+
};
|
|
59
|
+
export type NodeCompatibilityPaths = {
|
|
60
|
+
guestsPath?: string;
|
|
61
|
+
actorsPath?: string;
|
|
62
|
+
cronPath?: string;
|
|
63
|
+
queuesPath?: string;
|
|
64
|
+
};
|
|
65
|
+
/** Resolves the virtual application module and Node built-ins through unenv. */
|
|
66
|
+
export declare function nodeCompatibilityPlugin(entryPath: string, guestsPath?: string | NodeCompatibilityPaths, seedOrActorsPath?: NodeCompatSeed | string, maybeSeed?: NodeCompatSeed): {
|
|
67
|
+
name: string;
|
|
68
|
+
resolveId(source: string, importer?: string): string | {
|
|
69
|
+
id: string;
|
|
70
|
+
external: boolean;
|
|
71
|
+
} | null;
|
|
72
|
+
load(id: string): string | null;
|
|
73
|
+
};
|
|
74
|
+
/** Points at a wasmtime-48+ componentize-qjs CLI that can stub imported `async func`s. */
|
|
75
|
+
export declare const COMPONENTIZE_QJS_ENV = "DI_FRAMEWORK_COMPONENTIZE_QJS";
|
|
76
|
+
/** npm wrapper that selects the matching optional platform CLI package. */
|
|
77
|
+
export declare const COMPONENTIZE_QJS_PACKAGE = "@di-framework/componentize-qjs";
|
|
78
|
+
export declare function componentizeQjsPlatformPackageName(): string;
|
|
79
|
+
export declare function componentizeQjsPlatformPackageVersion(platform?: NodeJS.Platform, arch?: NodeJS.Architecture, wrapperVersion?: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Locate the native CLI shipped as `@di-framework/componentize-qjs@<version>-<os>-<arch>`.
|
|
82
|
+
* Walks `node_modules` from `startDirectory` (same strategy as `findJcoEntry`)
|
|
83
|
+
* so Bun's install cache is not required. The wrapper aliases that version into
|
|
84
|
+
* an unscoped `componentize-qjs-<os>-<arch>` folder.
|
|
85
|
+
*/
|
|
86
|
+
export declare function findInstalledComponentizeQjsCli(startDirectory?: string, platform?: NodeJS.Platform, arch?: NodeJS.Architecture): string | undefined;
|
|
87
|
+
export declare function resolveComponentizeQjsPath(env?: Record<string, string | undefined>, installedCliPath?: string, pathCli?: string): string | undefined;
|
|
88
|
+
/** PATH entries inside node_modules are the npm wrapper, not a native wasmtime-48 CLI. */
|
|
89
|
+
export declare function nativeComponentizeQjsOnPath(whichPath?: string | undefined): string | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* jco's entry inside a real node_modules tree, walking up from this package.
|
|
92
|
+
* Bun's `import.meta.resolve` can return its global install cache, where jco's
|
|
93
|
+
* own dependencies are not resolvable by Node; a node_modules path always is.
|
|
94
|
+
*/
|
|
95
|
+
export declare function findJcoEntry(startDirectory: string): string | undefined;
|
|
96
|
+
export declare const DEFAULT_DEPS: WasmcloudDeps;
|