@schnebel-crm/cli 0.1.2 → 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.
- package/dist/cli.mjs +33 -18
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -422,25 +422,28 @@ const deployCommand = new Command("deploy").description("Deploy the integration
|
|
|
422
422
|
const cwd = process.cwd();
|
|
423
423
|
const outDir = resolve(cwd, (await loadConfig(cwd)).outDir);
|
|
424
424
|
log.step("Reading build artifacts...");
|
|
425
|
-
let
|
|
425
|
+
let bundleContent;
|
|
426
426
|
let manifest;
|
|
427
427
|
try {
|
|
428
|
-
|
|
428
|
+
bundleContent = await readFile(join(outDir, "index.mjs"), "utf-8");
|
|
429
429
|
manifest = await readFile(join(outDir, "manifest.json"), "utf-8");
|
|
430
430
|
} catch {
|
|
431
|
-
log.error("Build artifacts not found. Run '
|
|
431
|
+
log.error("Build artifacts not found. Run 'npm run build' first.");
|
|
432
432
|
process.exit(1);
|
|
433
433
|
}
|
|
434
434
|
const manifestData = JSON.parse(manifest);
|
|
435
435
|
log.step(`Deploying ${manifestData.name}@${manifestData.version}...`);
|
|
436
436
|
try {
|
|
437
|
-
const
|
|
438
|
-
formData.append("bundle", new Blob([bundle]), "index.mjs");
|
|
439
|
-
formData.append("manifest", manifest);
|
|
440
|
-
const res = await fetch(`${auth.url}/api/integrations/custom/upload`, {
|
|
437
|
+
const res = await fetch(`${auth.url}/rpc/customIntegration.upload`, {
|
|
441
438
|
method: "POST",
|
|
442
|
-
headers: {
|
|
443
|
-
|
|
439
|
+
headers: {
|
|
440
|
+
"Content-Type": "application/json",
|
|
441
|
+
"x-api-key": auth.apiKey
|
|
442
|
+
},
|
|
443
|
+
body: JSON.stringify({
|
|
444
|
+
manifest,
|
|
445
|
+
bundle: bundleContent
|
|
446
|
+
})
|
|
444
447
|
});
|
|
445
448
|
if (!res.ok) {
|
|
446
449
|
const body = await res.text();
|
|
@@ -449,7 +452,7 @@ const deployCommand = new Command("deploy").description("Deploy the integration
|
|
|
449
452
|
}
|
|
450
453
|
const result = await res.json();
|
|
451
454
|
log.success(`Deployed ${manifestData.name}@${manifestData.version} to your workspace`);
|
|
452
|
-
log.info(`
|
|
455
|
+
log.info(`Integration ID: ${result.result.id}`);
|
|
453
456
|
} catch (err) {
|
|
454
457
|
log.error(`Deploy failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
455
458
|
process.exit(1);
|
|
@@ -491,19 +494,23 @@ const publishCommand = new Command("publish").description("Submit the integratio
|
|
|
491
494
|
try {
|
|
492
495
|
manifest = await readFile(join(outDir, "manifest.json"), "utf-8");
|
|
493
496
|
} catch {
|
|
494
|
-
log.error("Manifest not found. Run '
|
|
497
|
+
log.error("Manifest not found. Run 'npm run build' first.");
|
|
495
498
|
process.exit(1);
|
|
496
499
|
}
|
|
497
500
|
const manifestData = JSON.parse(manifest);
|
|
501
|
+
const slug = `${manifestData.id}`;
|
|
498
502
|
log.step(`Submitting ${manifestData.name}@${manifestData.version} for review...`);
|
|
499
503
|
try {
|
|
500
|
-
const res = await fetch(`${auth.url}/
|
|
504
|
+
const res = await fetch(`${auth.url}/rpc/customIntegration.submitForReview`, {
|
|
501
505
|
method: "POST",
|
|
502
506
|
headers: {
|
|
503
507
|
"Content-Type": "application/json",
|
|
504
508
|
"x-api-key": auth.apiKey
|
|
505
509
|
},
|
|
506
|
-
body: JSON.stringify({
|
|
510
|
+
body: JSON.stringify({
|
|
511
|
+
slug,
|
|
512
|
+
githubUrl: config.github
|
|
513
|
+
})
|
|
507
514
|
});
|
|
508
515
|
if (!res.ok) {
|
|
509
516
|
const body = await res.text();
|
|
@@ -524,8 +531,8 @@ const loginCommand = new Command("login").description("Authenticate with your Sc
|
|
|
524
531
|
const answers = await prompts([{
|
|
525
532
|
type: "text",
|
|
526
533
|
name: "url",
|
|
527
|
-
message: "Schnebel CRM URL:",
|
|
528
|
-
initial: "https://
|
|
534
|
+
message: "Schnebel CRM API URL:",
|
|
535
|
+
initial: "https://crm.schnebel.cloud"
|
|
529
536
|
}, {
|
|
530
537
|
type: "password",
|
|
531
538
|
name: "apiKey",
|
|
@@ -535,9 +542,17 @@ const loginCommand = new Command("login").description("Authenticate with your Sc
|
|
|
535
542
|
log.error("Aborted.");
|
|
536
543
|
return;
|
|
537
544
|
}
|
|
545
|
+
const url = answers.url.replace(/\/+$/, "");
|
|
538
546
|
log.step("Verifying connection...");
|
|
539
547
|
try {
|
|
540
|
-
const res = await fetch(`${
|
|
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
|
+
});
|
|
541
556
|
if (!res.ok) {
|
|
542
557
|
log.error(`Connection failed (${res.status}). Check your URL and API key.`);
|
|
543
558
|
return;
|
|
@@ -547,11 +562,11 @@ const loginCommand = new Command("login").description("Authenticate with your Sc
|
|
|
547
562
|
return;
|
|
548
563
|
}
|
|
549
564
|
await saveAuth({
|
|
550
|
-
url
|
|
565
|
+
url,
|
|
551
566
|
apiKey: answers.apiKey
|
|
552
567
|
});
|
|
553
568
|
log.success("Authenticated successfully.");
|
|
554
|
-
log.info(
|
|
569
|
+
log.info("Config saved to ~/.schnebel/config.json");
|
|
555
570
|
});
|
|
556
571
|
|
|
557
572
|
//#endregion
|