@schnebel-crm/cli 0.1.6 → 0.1.8

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +27 -8
  2. package/package.json +14 -7
package/dist/cli.mjs CHANGED
@@ -262,6 +262,28 @@ async function loadConfig(cwd) {
262
262
 
263
263
  //#endregion
264
264
  //#region src/commands/build.ts
265
+ /**
266
+ * Extract the definition metadata from the definition source file
267
+ * by building it standalone and evaluating it — without importing
268
+ * the full bundle (which may depend on native modules like Prisma).
269
+ */
270
+ async function extractDefinition(cwd) {
271
+ const wrapped = [
272
+ "const defineIntegration = (d) => d;",
273
+ "const defineHandler = (h) => h;",
274
+ "const createAction = (a) => a;",
275
+ (await build({
276
+ entryPoints: [resolve(cwd, "src", "definition.ts")],
277
+ bundle: true,
278
+ format: "esm",
279
+ platform: "node",
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");
285
+ return (await import(`data:text/javascript;base64,${Buffer.from(wrapped).toString("base64")}`)).definition;
286
+ }
265
287
  const buildCommand = new Command("build").description("Build the integration into a deployable bundle").action(async () => {
266
288
  const cwd = process.cwd();
267
289
  const config = await loadConfig(cwd);
@@ -278,20 +300,16 @@ const buildCommand = new Command("build").description("Build the integration int
278
300
  target: "node20",
279
301
  outfile: outFile,
280
302
  external: ["@schnebel-crm/integration-sdk"],
303
+ banner: { js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);" },
281
304
  minify: false,
282
305
  sourcemap: false
283
306
  });
284
307
  log.step("Generating manifest...");
285
- const mod = await import(pathToFileURL(outFile).href);
286
- if (!mod.definition) {
287
- log.error("Bundle must export a 'definition' named export.");
288
- process.exit(1);
289
- }
290
- if (!mod.handler) {
291
- log.error("Bundle must export a 'handler' named export.");
308
+ const def = await extractDefinition(cwd);
309
+ if (!def) {
310
+ log.error("src/definition.ts must export a 'definition'.");
292
311
  process.exit(1);
293
312
  }
294
- const def = mod.definition;
295
313
  const manifest = {
296
314
  id: def.id,
297
315
  name: def.name,
@@ -599,6 +617,7 @@ const devCommand = new Command("dev").description("Watch and validate the integr
599
617
  target: "node20",
600
618
  outfile: `${outDir}/index.mjs`,
601
619
  external: ["@schnebel-crm/integration-sdk"],
620
+ banner: { js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);" },
602
621
  logLevel: "info"
603
622
  })).watch();
604
623
  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.6",
4
- "type": "module",
3
+ "version": "0.1.8",
5
4
  "description": "CLI for building and deploying Schnebel CRM integrations",
6
- "main": "./dist/cli.mjs",
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": ["dist"],
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",