@schnebel-crm/cli 0.1.5 → 0.1.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/dist/cli.mjs +33 -15
- package/package.json +14 -7
package/dist/cli.mjs
CHANGED
|
@@ -244,7 +244,8 @@ dist/
|
|
|
244
244
|
const DEFAULTS = {
|
|
245
245
|
entry: "./src/index.ts",
|
|
246
246
|
outDir: "./dist",
|
|
247
|
-
github: ""
|
|
247
|
+
github: "",
|
|
248
|
+
external: []
|
|
248
249
|
};
|
|
249
250
|
async function loadConfig(cwd) {
|
|
250
251
|
const configPath = resolve(cwd, "schnebel.config.ts");
|
|
@@ -262,6 +263,28 @@ async function loadConfig(cwd) {
|
|
|
262
263
|
|
|
263
264
|
//#endregion
|
|
264
265
|
//#region src/commands/build.ts
|
|
266
|
+
/**
|
|
267
|
+
* Extract the definition metadata from the definition source file
|
|
268
|
+
* by building it standalone and evaluating it — without importing
|
|
269
|
+
* the full bundle (which may depend on native modules like Prisma).
|
|
270
|
+
*/
|
|
271
|
+
async function extractDefinition(cwd) {
|
|
272
|
+
const wrapped = [
|
|
273
|
+
"const defineIntegration = (d) => d;",
|
|
274
|
+
"const defineHandler = (h) => h;",
|
|
275
|
+
"const createAction = (a) => a;",
|
|
276
|
+
(await build({
|
|
277
|
+
entryPoints: [resolve(cwd, "src", "definition.ts")],
|
|
278
|
+
bundle: true,
|
|
279
|
+
format: "esm",
|
|
280
|
+
platform: "node",
|
|
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");
|
|
286
|
+
return (await import(`data:text/javascript;base64,${Buffer.from(wrapped).toString("base64")}`)).definition;
|
|
287
|
+
}
|
|
265
288
|
const buildCommand = new Command("build").description("Build the integration into a deployable bundle").action(async () => {
|
|
266
289
|
const cwd = process.cwd();
|
|
267
290
|
const config = await loadConfig(cwd);
|
|
@@ -277,21 +300,16 @@ const buildCommand = new Command("build").description("Build the integration int
|
|
|
277
300
|
platform: "node",
|
|
278
301
|
target: "node20",
|
|
279
302
|
outfile: outFile,
|
|
280
|
-
external: ["@schnebel-crm/integration-sdk"],
|
|
303
|
+
external: ["@schnebel-crm/integration-sdk", ...config.external],
|
|
281
304
|
minify: false,
|
|
282
305
|
sourcemap: false
|
|
283
306
|
});
|
|
284
307
|
log.step("Generating manifest...");
|
|
285
|
-
const
|
|
286
|
-
if (!
|
|
287
|
-
log.error("
|
|
308
|
+
const def = await extractDefinition(cwd);
|
|
309
|
+
if (!def) {
|
|
310
|
+
log.error("src/definition.ts must export a 'definition'.");
|
|
288
311
|
process.exit(1);
|
|
289
312
|
}
|
|
290
|
-
if (!mod.handler) {
|
|
291
|
-
log.error("Bundle must export a 'handler' named export.");
|
|
292
|
-
process.exit(1);
|
|
293
|
-
}
|
|
294
|
-
const def = mod.definition;
|
|
295
313
|
const manifest = {
|
|
296
314
|
id: def.id,
|
|
297
315
|
name: def.name,
|
|
@@ -446,13 +464,13 @@ const deployCommand = new Command("deploy").description("Deploy the integration
|
|
|
446
464
|
} })
|
|
447
465
|
});
|
|
448
466
|
if (!res.ok) {
|
|
449
|
-
const body = await res.text();
|
|
450
|
-
log.error(`Deploy failed (${res.status}): ${body}`);
|
|
467
|
+
const body$1 = await res.text();
|
|
468
|
+
log.error(`Deploy failed (${res.status}): ${body$1}`);
|
|
451
469
|
process.exit(1);
|
|
452
470
|
}
|
|
453
|
-
const
|
|
471
|
+
const body = await res.json();
|
|
454
472
|
log.success(`Deployed ${manifestData.name}@${manifestData.version} to your workspace`);
|
|
455
|
-
log.info(`Integration ID: ${
|
|
473
|
+
if (body.json?.id) log.info(`Integration ID: ${body.json.id}`);
|
|
456
474
|
} catch (err) {
|
|
457
475
|
log.error(`Deploy failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
458
476
|
process.exit(1);
|
|
@@ -598,7 +616,7 @@ const devCommand = new Command("dev").description("Watch and validate the integr
|
|
|
598
616
|
platform: "node",
|
|
599
617
|
target: "node20",
|
|
600
618
|
outfile: `${outDir}/index.mjs`,
|
|
601
|
-
external: ["@schnebel-crm/integration-sdk"],
|
|
619
|
+
external: ["@schnebel-crm/integration-sdk", ...config.external],
|
|
602
620
|
logLevel: "info"
|
|
603
621
|
})).watch();
|
|
604
622
|
log.success("Watching for changes...");
|
package/package.json
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schnebel-crm/cli",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.1.7",
|
|
5
4
|
"description": "CLI for building and deploying Schnebel CRM integrations",
|
|
6
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"crm",
|
|
8
|
+
"integration",
|
|
9
|
+
"schnebel"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://schnebel-crm.de/docs/integrations",
|
|
12
|
+
"license": "MIT",
|
|
7
13
|
"bin": {
|
|
8
14
|
"schnebel": "./dist/cli.mjs"
|
|
9
15
|
},
|
|
10
|
-
"files": [
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "./dist/cli.mjs",
|
|
11
21
|
"scripts": {
|
|
12
22
|
"build": "tsdown src/cli.ts --format esm --clean",
|
|
13
23
|
"check-types": "tsc --noEmit",
|
|
14
24
|
"prepublishOnly": "pnpm run build"
|
|
15
25
|
},
|
|
16
|
-
"keywords": ["schnebel", "crm", "integration", "cli"],
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"homepage": "https://schnebel-crm.de/docs/integrations",
|
|
19
26
|
"dependencies": {
|
|
20
27
|
"commander": "^13.0.0",
|
|
21
28
|
"esbuild": "^0.25.0",
|