@schnebel-crm/cli 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +37 -25
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -132,15 +132,12 @@ const initCommand = new Command("init").description("Create a new Schnebel CRM i
132
132
  type: "module",
133
133
  private: true,
134
134
  scripts: {
135
- build: "schnebel build",
136
- dev: "schnebel dev",
137
- deploy: "schnebel deploy"
135
+ build: "npx @schnebel-crm/cli build",
136
+ dev: "npx @schnebel-crm/cli dev",
137
+ deploy: "npx @schnebel-crm/cli deploy"
138
138
  },
139
139
  dependencies: { "@schnebel-crm/integration-sdk": "^0.1.0" },
140
- devDependencies: {
141
- "@schnebel-crm/cli": "^0.1.0",
142
- typescript: "^5"
143
- }
140
+ devDependencies: { typescript: "^5" }
144
141
  }, null, 2));
145
142
  await writeFile(join(dir, "tsconfig.json"), JSON.stringify({
146
143
  compilerOptions: {
@@ -425,25 +422,28 @@ const deployCommand = new Command("deploy").description("Deploy the integration
425
422
  const cwd = process.cwd();
426
423
  const outDir = resolve(cwd, (await loadConfig(cwd)).outDir);
427
424
  log.step("Reading build artifacts...");
428
- let bundle;
425
+ let bundleContent;
429
426
  let manifest;
430
427
  try {
431
- bundle = await readFile(join(outDir, "index.mjs"));
428
+ bundleContent = await readFile(join(outDir, "index.mjs"), "utf-8");
432
429
  manifest = await readFile(join(outDir, "manifest.json"), "utf-8");
433
430
  } catch {
434
- log.error("Build artifacts not found. Run 'schnebel build' first.");
431
+ log.error("Build artifacts not found. Run 'npm run build' first.");
435
432
  process.exit(1);
436
433
  }
437
434
  const manifestData = JSON.parse(manifest);
438
435
  log.step(`Deploying ${manifestData.name}@${manifestData.version}...`);
439
436
  try {
440
- const formData = new FormData();
441
- formData.append("bundle", new Blob([bundle]), "index.mjs");
442
- formData.append("manifest", manifest);
443
- const res = await fetch(`${auth.url}/api/integrations/custom/upload`, {
437
+ const res = await fetch(`${auth.url}/rpc/customIntegration.upload`, {
444
438
  method: "POST",
445
- headers: { "x-api-key": auth.apiKey },
446
- body: formData
439
+ headers: {
440
+ "Content-Type": "application/json",
441
+ "x-api-key": auth.apiKey
442
+ },
443
+ body: JSON.stringify({
444
+ manifest,
445
+ bundle: bundleContent
446
+ })
447
447
  });
448
448
  if (!res.ok) {
449
449
  const body = await res.text();
@@ -452,7 +452,7 @@ const deployCommand = new Command("deploy").description("Deploy the integration
452
452
  }
453
453
  const result = await res.json();
454
454
  log.success(`Deployed ${manifestData.name}@${manifestData.version} to your workspace`);
455
- log.info(`Slug: ${result.slug}`);
455
+ log.info(`Integration ID: ${result.result.id}`);
456
456
  } catch (err) {
457
457
  log.error(`Deploy failed: ${err instanceof Error ? err.message : String(err)}`);
458
458
  process.exit(1);
@@ -494,19 +494,23 @@ const publishCommand = new Command("publish").description("Submit the integratio
494
494
  try {
495
495
  manifest = await readFile(join(outDir, "manifest.json"), "utf-8");
496
496
  } catch {
497
- log.error("Manifest not found. Run 'schnebel build' first.");
497
+ log.error("Manifest not found. Run 'npm run build' first.");
498
498
  process.exit(1);
499
499
  }
500
500
  const manifestData = JSON.parse(manifest);
501
+ const slug = `${manifestData.id}`;
501
502
  log.step(`Submitting ${manifestData.name}@${manifestData.version} for review...`);
502
503
  try {
503
- const res = await fetch(`${auth.url}/api/integrations/custom/${manifestData.id}/submit`, {
504
+ const res = await fetch(`${auth.url}/rpc/customIntegration.submitForReview`, {
504
505
  method: "POST",
505
506
  headers: {
506
507
  "Content-Type": "application/json",
507
508
  "x-api-key": auth.apiKey
508
509
  },
509
- body: JSON.stringify({ githubUrl: config.github })
510
+ body: JSON.stringify({
511
+ slug,
512
+ githubUrl: config.github
513
+ })
510
514
  });
511
515
  if (!res.ok) {
512
516
  const body = await res.text();
@@ -527,8 +531,8 @@ const loginCommand = new Command("login").description("Authenticate with your Sc
527
531
  const answers = await prompts([{
528
532
  type: "text",
529
533
  name: "url",
530
- message: "Schnebel CRM URL:",
531
- initial: "https://api.schnebel-crm.de"
534
+ message: "Schnebel CRM API URL:",
535
+ initial: "https://crm.schnebel.cloud"
532
536
  }, {
533
537
  type: "password",
534
538
  name: "apiKey",
@@ -538,9 +542,17 @@ const loginCommand = new Command("login").description("Authenticate with your Sc
538
542
  log.error("Aborted.");
539
543
  return;
540
544
  }
545
+ const url = answers.url.replace(/\/+$/, "");
541
546
  log.step("Verifying connection...");
542
547
  try {
543
- const res = await fetch(`${answers.url}/v1/health`, { headers: { "x-api-key": answers.apiKey } });
548
+ const res = await fetch(`${url}/rpc/healthCheck`, {
549
+ method: "POST",
550
+ headers: {
551
+ "Content-Type": "application/json",
552
+ "x-api-key": answers.apiKey
553
+ },
554
+ body: "{}"
555
+ });
544
556
  if (!res.ok) {
545
557
  log.error(`Connection failed (${res.status}). Check your URL and API key.`);
546
558
  return;
@@ -550,11 +562,11 @@ const loginCommand = new Command("login").description("Authenticate with your Sc
550
562
  return;
551
563
  }
552
564
  await saveAuth({
553
- url: answers.url,
565
+ url,
554
566
  apiKey: answers.apiKey
555
567
  });
556
568
  log.success("Authenticated successfully.");
557
- log.info(`Config saved to ~/.schnebel/config.json`);
569
+ log.info("Config saved to ~/.schnebel/config.json");
558
570
  });
559
571
 
560
572
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schnebel-crm/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "CLI for building and deploying Schnebel CRM integrations",
6
6
  "main": "./dist/cli.mjs",