@boltic/cli 1.0.40 ā 1.0.41
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/api/serverless.js +2 -2
- package/commands/serverless.js +78 -80
- package/package.json +1 -1
package/api/serverless.js
CHANGED
|
@@ -109,7 +109,7 @@ const publishServerless = async (apiUrl, token, session, payload) => {
|
|
|
109
109
|
try {
|
|
110
110
|
const axiosOptions = {
|
|
111
111
|
method: "post",
|
|
112
|
-
url:
|
|
112
|
+
url: `${apiUrl}/service/panel/serverless/v1.0/apps`,
|
|
113
113
|
headers: {
|
|
114
114
|
"Content-Type": "application/json",
|
|
115
115
|
Authorization: `Bearer ${token}`,
|
|
@@ -147,7 +147,7 @@ const updateServerless = async (
|
|
|
147
147
|
try {
|
|
148
148
|
const axiosOptions = {
|
|
149
149
|
method: "put",
|
|
150
|
-
url:
|
|
150
|
+
url: `${apiUrl}/service/panel/serverless/v1.0/apps/${serverlessId}`,
|
|
151
151
|
headers: {
|
|
152
152
|
"Content-Type": "application/json",
|
|
153
153
|
Authorization: `Bearer ${token}`,
|
package/commands/serverless.js
CHANGED
|
@@ -381,7 +381,7 @@ async function handleCodeTypeCreate(name, language, version, targetDir) {
|
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
/**
|
|
384
|
-
* Handle git type serverless creation - creates
|
|
384
|
+
* Handle git type serverless creation - creates serverless on server and clones the repo
|
|
385
385
|
*/
|
|
386
386
|
async function handleGitTypeCreate(name, language, version, targetDir) {
|
|
387
387
|
console.log(chalk.cyan("\nš Creating git-based serverless project..."));
|
|
@@ -442,7 +442,6 @@ async function handleGitTypeCreate(name, language, version, targetDir) {
|
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
// Extract serverless ID and git info from response
|
|
445
|
-
// Response structure: { ID, Links: { Git: { Repository: { SshURL, HtmlURL, CloneURL, ... } } } }
|
|
446
445
|
const serverlessId = response.ID || response.data?.ID || response._id;
|
|
447
446
|
const gitRepo =
|
|
448
447
|
response.Links?.Git?.Repository ||
|
|
@@ -451,8 +450,41 @@ async function handleGitTypeCreate(name, language, version, targetDir) {
|
|
|
451
450
|
const gitHttpUrl = gitRepo?.HtmlURL || "";
|
|
452
451
|
const gitCloneUrl = gitRepo?.CloneURL || "";
|
|
453
452
|
|
|
454
|
-
//
|
|
455
|
-
|
|
453
|
+
// Remove the empty directory created earlier - we'll clone into it
|
|
454
|
+
try {
|
|
455
|
+
fs.rmSync(targetDir, { recursive: true, force: true });
|
|
456
|
+
} catch {
|
|
457
|
+
// Ignore cleanup errors
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Clone the repo from server (which has the server-generated boltic.yaml)
|
|
461
|
+
let cloneSuccess = false;
|
|
462
|
+
if (gitSshUrl) {
|
|
463
|
+
console.log(chalk.cyan("\nš„ Cloning git repository..."));
|
|
464
|
+
try {
|
|
465
|
+
// Clone the repo
|
|
466
|
+
execSync(`git clone ${gitSshUrl} "${targetDir}"`, {
|
|
467
|
+
stdio: "pipe",
|
|
468
|
+
timeout: 30000,
|
|
469
|
+
});
|
|
470
|
+
cloneSuccess = true;
|
|
471
|
+
console.log(chalk.green("ā
Repository cloned successfully!"));
|
|
472
|
+
} catch (err) {
|
|
473
|
+
console.log(
|
|
474
|
+
chalk.yellow(
|
|
475
|
+
"ā ļø Could not clone repository. You may not have SSH access yet."
|
|
476
|
+
)
|
|
477
|
+
);
|
|
478
|
+
cloneSuccess = false;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// If clone failed, create directory with minimal setup
|
|
483
|
+
if (!cloneSuccess) {
|
|
484
|
+
try {
|
|
485
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
486
|
+
// Create a minimal boltic.yaml as fallback
|
|
487
|
+
const bolticYamlContent = `app: "${name}"
|
|
456
488
|
region: "asia-south1"
|
|
457
489
|
handler: "${HANDLER_MAPPING[language]}"
|
|
458
490
|
language: "${language}/${version}"
|
|
@@ -460,19 +492,7 @@ language: "${language}/${version}"
|
|
|
460
492
|
serverlessConfig:
|
|
461
493
|
serverlessId: "${serverlessId}"
|
|
462
494
|
Name: "${name}"
|
|
463
|
-
Description: ""
|
|
464
495
|
Runtime: "git"
|
|
465
|
-
# Environment variables for your serverless function
|
|
466
|
-
# To add env variables, replace {} with key-value pairs like:
|
|
467
|
-
# Env:
|
|
468
|
-
# API_KEY: "your-api-key"
|
|
469
|
-
#TO add port map, replace {} with port map like:
|
|
470
|
-
# PortMap:
|
|
471
|
-
# - Name: "port"
|
|
472
|
-
# Port: "8080"
|
|
473
|
-
# Protocol: "http"/"https"
|
|
474
|
-
Env: {}
|
|
475
|
-
PortMap: {}
|
|
476
496
|
Scaling:
|
|
477
497
|
AutoStop: false
|
|
478
498
|
Min: 1
|
|
@@ -483,61 +503,23 @@ serverlessConfig:
|
|
|
483
503
|
MemoryMB: 128
|
|
484
504
|
MemoryMaxMB: 128
|
|
485
505
|
Timeout: 60
|
|
486
|
-
Validations: null
|
|
487
|
-
|
|
488
|
-
build:
|
|
489
|
-
builtin: dockerfile
|
|
490
|
-
ignorefile: .gitignore
|
|
491
506
|
`;
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
bolticYamlContent
|
|
497
|
-
);
|
|
498
|
-
} catch (err) {
|
|
499
|
-
console.error(chalk.red(`\nā Failed to create boltic.yaml`));
|
|
500
|
-
console.error(chalk.red(`Error: ${err.message}`));
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
// Check if user has git access by trying ls-remote
|
|
505
|
-
let hasGitAccess = false;
|
|
506
|
-
if (gitSshUrl) {
|
|
507
|
-
console.log(chalk.cyan("\nš Checking git repository access..."));
|
|
508
|
-
try {
|
|
507
|
+
fs.writeFileSync(
|
|
508
|
+
path.join(targetDir, "boltic.yaml"),
|
|
509
|
+
bolticYamlContent
|
|
510
|
+
);
|
|
509
511
|
// Initialize git repo
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
cwd: targetDir,
|
|
518
|
-
stdio: "pipe",
|
|
519
|
-
timeout: 15000,
|
|
520
|
-
});
|
|
521
|
-
hasGitAccess = true;
|
|
522
|
-
} catch (err) {
|
|
523
|
-
hasGitAccess = false;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
// If user has access, create main branch
|
|
528
|
-
if (hasGitAccess) {
|
|
529
|
-
try {
|
|
530
|
-
console.log(chalk.cyan("š§ Setting up git branch..."));
|
|
531
|
-
// Create main branch
|
|
532
|
-
execSync(`git checkout -b main`, { cwd: targetDir, stdio: "pipe" });
|
|
533
|
-
console.log(chalk.green("ā Created main branch"));
|
|
512
|
+
if (gitSshUrl) {
|
|
513
|
+
execSync(`git init`, { cwd: targetDir, stdio: "pipe" });
|
|
514
|
+
execSync(`git remote add origin ${gitSshUrl}`, {
|
|
515
|
+
cwd: targetDir,
|
|
516
|
+
stdio: "pipe",
|
|
517
|
+
});
|
|
518
|
+
}
|
|
534
519
|
} catch (err) {
|
|
535
|
-
|
|
536
|
-
console.
|
|
537
|
-
|
|
538
|
-
"ā ļø Could not auto-setup git branch. You can set it up manually."
|
|
539
|
-
)
|
|
540
|
-
);
|
|
520
|
+
console.error(chalk.red(`\nā Failed to create project directory`));
|
|
521
|
+
console.error(chalk.red(`Error: ${err.message}`));
|
|
522
|
+
return;
|
|
541
523
|
}
|
|
542
524
|
}
|
|
543
525
|
|
|
@@ -573,11 +555,10 @@ build:
|
|
|
573
555
|
}
|
|
574
556
|
console.log();
|
|
575
557
|
|
|
576
|
-
if (
|
|
558
|
+
if (cloneSuccess) {
|
|
577
559
|
console.log(
|
|
578
|
-
chalk.green("ā
|
|
560
|
+
chalk.green("ā
Repository cloned with server configuration!")
|
|
579
561
|
);
|
|
580
|
-
console.log(chalk.green("ā
Main branch created!"));
|
|
581
562
|
console.log();
|
|
582
563
|
console.log(
|
|
583
564
|
chalk.yellow("š Next steps - Add your code and push:")
|
|
@@ -585,11 +566,13 @@ build:
|
|
|
585
566
|
console.log(chalk.dim(" 1. Add your server code to this folder"));
|
|
586
567
|
console.log(chalk.dim(" 2. Commit and push:"));
|
|
587
568
|
console.log(chalk.white(` git add .`));
|
|
588
|
-
console.log(
|
|
589
|
-
|
|
569
|
+
console.log(
|
|
570
|
+
chalk.white(` git commit -m "Add application code"`)
|
|
571
|
+
);
|
|
572
|
+
console.log(chalk.white(` git push origin main`));
|
|
590
573
|
} else {
|
|
591
574
|
console.log(
|
|
592
|
-
chalk.
|
|
575
|
+
chalk.yellow("ā ļø Could not clone repository automatically.")
|
|
593
576
|
);
|
|
594
577
|
console.log(
|
|
595
578
|
chalk.yellow(
|
|
@@ -598,14 +581,20 @@ build:
|
|
|
598
581
|
);
|
|
599
582
|
console.log();
|
|
600
583
|
console.log(
|
|
601
|
-
chalk.yellow("š Once you have access,
|
|
584
|
+
chalk.yellow("š Once you have access, sync with remote:")
|
|
585
|
+
);
|
|
586
|
+
console.log(chalk.dim(" 1. Pull the server config first:"));
|
|
587
|
+
console.log(
|
|
588
|
+
chalk.white(
|
|
589
|
+
` git pull origin main --allow-unrelated-histories`
|
|
590
|
+
)
|
|
602
591
|
);
|
|
603
|
-
console.log(chalk.dim("
|
|
604
|
-
console.log(chalk.dim(" 2. Run:"));
|
|
605
|
-
console.log(chalk.white(` git checkout -b main`));
|
|
592
|
+
console.log(chalk.dim(" 2. Add your code and push:"));
|
|
606
593
|
console.log(chalk.white(` git add .`));
|
|
607
|
-
console.log(
|
|
608
|
-
|
|
594
|
+
console.log(
|
|
595
|
+
chalk.white(` git commit -m "Add application code"`)
|
|
596
|
+
);
|
|
597
|
+
console.log(chalk.white(` git push origin main`));
|
|
609
598
|
}
|
|
610
599
|
} else {
|
|
611
600
|
console.log();
|
|
@@ -830,6 +819,15 @@ async function handlePublish(args = []) {
|
|
|
830
819
|
const languageBase = parseLanguageFromConfig(language);
|
|
831
820
|
const runtime = serverlessConfig?.Runtime || "code";
|
|
832
821
|
let code = null;
|
|
822
|
+
if (runtime === "git") {
|
|
823
|
+
console.log(
|
|
824
|
+
chalk.red("\nš Git type serverless does not support publish")
|
|
825
|
+
);
|
|
826
|
+
console.log(
|
|
827
|
+
chalk.yellow("Please publish using git push origin main")
|
|
828
|
+
);
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
833
831
|
|
|
834
832
|
if (runtime === "code") {
|
|
835
833
|
code = readHandlerFile(directory, languageBase, config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boltic/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.41",
|
|
4
4
|
"description": "Professional CLI for interacting with the Boltic platform ā create, manage, and publish integrations, serverless functions, workflows, MCPs, and more with enterprise-grade features and a seamless developer experience",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|