@schnebel-crm/cli 0.1.8 → 0.1.9-dev.1776155474
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/cli.mjs +33 -19
- package/package.json +3 -4
package/dist/cli.mjs
CHANGED
|
@@ -263,27 +263,39 @@ async function loadConfig(cwd) {
|
|
|
263
263
|
//#endregion
|
|
264
264
|
//#region src/commands/build.ts
|
|
265
265
|
/**
|
|
266
|
-
* Extract
|
|
267
|
-
*
|
|
268
|
-
* the full bundle
|
|
266
|
+
* Extract metadata from the definition source file by building it
|
|
267
|
+
* standalone with stub SDK functions and evaluating via data: URL.
|
|
268
|
+
* This avoids importing the full bundle which may depend on native modules.
|
|
269
269
|
*/
|
|
270
|
-
async function
|
|
271
|
-
const wrapped = [
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
target: "node20",
|
|
281
|
-
write: false,
|
|
282
|
-
external: ["@schnebel-crm/integration-sdk", "@schnebel-crm/*"]
|
|
283
|
-
})).outputFiles[0].text.replace(/import\s*\{[^}]*\}\s*from\s*["'][^"']*["'];?/g, "")
|
|
284
|
-
].join("\n");
|
|
270
|
+
async function extractMetadata(cwd) {
|
|
271
|
+
const wrapped = ["const defineIntegration = (d) => d;", (await build({
|
|
272
|
+
entryPoints: [resolve(cwd, "src", "definition.ts")],
|
|
273
|
+
bundle: true,
|
|
274
|
+
format: "esm",
|
|
275
|
+
platform: "node",
|
|
276
|
+
target: "node20",
|
|
277
|
+
write: false,
|
|
278
|
+
external: ["@schnebel-crm/integration-sdk", "@schnebel-crm/*"]
|
|
279
|
+
})).outputFiles[0].text.replace(/import\s*\{[^}]*\}\s*from\s*["'][^"']*["'];?/g, "")].join("\n");
|
|
285
280
|
return (await import(`data:text/javascript;base64,${Buffer.from(wrapped).toString("base64")}`)).definition;
|
|
286
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Extract action metadata (id, name, description) from the built bundle.
|
|
284
|
+
* Runs the bundle via import() — safe because it's on the developer's machine.
|
|
285
|
+
*/
|
|
286
|
+
async function extractActions(bundlePath) {
|
|
287
|
+
try {
|
|
288
|
+
const mod = await import(pathToFileURL(bundlePath).href);
|
|
289
|
+
if (!mod.handler?.actions) return [];
|
|
290
|
+
return mod.handler.actions.map((a) => ({
|
|
291
|
+
id: a.id,
|
|
292
|
+
name: a.name,
|
|
293
|
+
description: a.description
|
|
294
|
+
}));
|
|
295
|
+
} catch {
|
|
296
|
+
return [];
|
|
297
|
+
}
|
|
298
|
+
}
|
|
287
299
|
const buildCommand = new Command("build").description("Build the integration into a deployable bundle").action(async () => {
|
|
288
300
|
const cwd = process.cwd();
|
|
289
301
|
const config = await loadConfig(cwd);
|
|
@@ -305,11 +317,12 @@ const buildCommand = new Command("build").description("Build the integration int
|
|
|
305
317
|
sourcemap: false
|
|
306
318
|
});
|
|
307
319
|
log.step("Generating manifest...");
|
|
308
|
-
const def = await
|
|
320
|
+
const def = await extractMetadata(cwd);
|
|
309
321
|
if (!def) {
|
|
310
322
|
log.error("src/definition.ts must export a 'definition'.");
|
|
311
323
|
process.exit(1);
|
|
312
324
|
}
|
|
325
|
+
const actions = await extractActions(outFile);
|
|
313
326
|
const manifest = {
|
|
314
327
|
id: def.id,
|
|
315
328
|
name: def.name,
|
|
@@ -325,6 +338,7 @@ const buildCommand = new Command("build").description("Build the integration int
|
|
|
325
338
|
credentialFields: def.credentialFields,
|
|
326
339
|
documentationUrl: def.documentationUrl,
|
|
327
340
|
tags: def.tags,
|
|
341
|
+
actions,
|
|
328
342
|
sdkVersion: "0.1.0"
|
|
329
343
|
};
|
|
330
344
|
await writeFile(join(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schnebel-crm/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9-dev.1776155474",
|
|
4
4
|
"description": "CLI for building and deploying Schnebel CRM integrations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
"main": "./dist/cli.mjs",
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsdown src/cli.ts --format esm --clean",
|
|
23
|
-
"check-types": "tsc --noEmit"
|
|
24
|
-
"prepublishOnly": "pnpm run build"
|
|
23
|
+
"check-types": "tsc --noEmit"
|
|
25
24
|
},
|
|
26
25
|
"dependencies": {
|
|
27
26
|
"commander": "^13.0.0",
|
|
@@ -30,7 +29,7 @@
|
|
|
30
29
|
"prompts": "^2.4.2"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@schnebel-crm/integration-sdk": "
|
|
32
|
+
"@schnebel-crm/integration-sdk": "^0.1.9-dev.1776155474",
|
|
34
33
|
"@types/prompts": "^2.4.9",
|
|
35
34
|
"tsdown": "^0.16.5",
|
|
36
35
|
"typescript": "^5"
|