@schnebel-crm/cli 0.1.7 → 0.1.8-staging.1776154028
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 +38 -23
- package/package.json +3 -4
package/dist/cli.mjs
CHANGED
|
@@ -244,8 +244,7 @@ dist/
|
|
|
244
244
|
const DEFAULTS = {
|
|
245
245
|
entry: "./src/index.ts",
|
|
246
246
|
outDir: "./dist",
|
|
247
|
-
github: ""
|
|
248
|
-
external: []
|
|
247
|
+
github: ""
|
|
249
248
|
};
|
|
250
249
|
async function loadConfig(cwd) {
|
|
251
250
|
const configPath = resolve(cwd, "schnebel.config.ts");
|
|
@@ -264,27 +263,39 @@ async function loadConfig(cwd) {
|
|
|
264
263
|
//#endregion
|
|
265
264
|
//#region src/commands/build.ts
|
|
266
265
|
/**
|
|
267
|
-
* Extract
|
|
268
|
-
*
|
|
269
|
-
* 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.
|
|
270
269
|
*/
|
|
271
|
-
async function
|
|
272
|
-
const wrapped = [
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
target: "node20",
|
|
282
|
-
write: false,
|
|
283
|
-
external: ["@schnebel-crm/integration-sdk", "@schnebel-crm/*"]
|
|
284
|
-
})).outputFiles[0].text.replace(/import\s*\{[^}]*\}\s*from\s*["'][^"']*["'];?/g, "")
|
|
285
|
-
].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");
|
|
286
280
|
return (await import(`data:text/javascript;base64,${Buffer.from(wrapped).toString("base64")}`)).definition;
|
|
287
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
|
+
}
|
|
288
299
|
const buildCommand = new Command("build").description("Build the integration into a deployable bundle").action(async () => {
|
|
289
300
|
const cwd = process.cwd();
|
|
290
301
|
const config = await loadConfig(cwd);
|
|
@@ -300,16 +311,18 @@ const buildCommand = new Command("build").description("Build the integration int
|
|
|
300
311
|
platform: "node",
|
|
301
312
|
target: "node20",
|
|
302
313
|
outfile: outFile,
|
|
303
|
-
external: ["@schnebel-crm/integration-sdk"
|
|
314
|
+
external: ["@schnebel-crm/integration-sdk"],
|
|
315
|
+
banner: { js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);" },
|
|
304
316
|
minify: false,
|
|
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));
|
|
@@ -616,7 +630,8 @@ const devCommand = new Command("dev").description("Watch and validate the integr
|
|
|
616
630
|
platform: "node",
|
|
617
631
|
target: "node20",
|
|
618
632
|
outfile: `${outDir}/index.mjs`,
|
|
619
|
-
external: ["@schnebel-crm/integration-sdk"
|
|
633
|
+
external: ["@schnebel-crm/integration-sdk"],
|
|
634
|
+
banner: { js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);" },
|
|
620
635
|
logLevel: "info"
|
|
621
636
|
})).watch();
|
|
622
637
|
log.success("Watching for changes...");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schnebel-crm/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8-staging.1776154028",
|
|
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.8-staging.1776154028",
|
|
34
33
|
"@types/prompts": "^2.4.9",
|
|
35
34
|
"tsdown": "^0.16.5",
|
|
36
35
|
"typescript": "^5"
|