@saidulbadhon/jssm-cli 1.6.5 → 1.6.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/index.js +69 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4173,15 +4173,11 @@ async function getProjects(host, apiKey) {
|
|
|
4173
4173
|
const url = `${host}/projects`;
|
|
4174
4174
|
return apiRequest(url, apiKey);
|
|
4175
4175
|
}
|
|
4176
|
-
async function pushEnvFile(host, apiKey, project, content, filename = ".env"
|
|
4176
|
+
async function pushEnvFile(host, apiKey, project, content, filename = ".env") {
|
|
4177
4177
|
const url = `${host}/projects/${project}/files/push`;
|
|
4178
|
-
const body = { content, filename };
|
|
4179
|
-
if (environment) {
|
|
4180
|
-
body.environment = environment;
|
|
4181
|
-
}
|
|
4182
4178
|
return apiRequest(url, apiKey, {
|
|
4183
4179
|
method: "POST",
|
|
4184
|
-
body: JSON.stringify(
|
|
4180
|
+
body: JSON.stringify({ content, filename })
|
|
4185
4181
|
});
|
|
4186
4182
|
}
|
|
4187
4183
|
async function pullEnvFile(host, apiKey, project, filename = ".env") {
|
|
@@ -4490,12 +4486,15 @@ async function initCommand(args2) {
|
|
|
4490
4486
|
console.log(` ${f.relativePath} (${f.variableCount} variables)`);
|
|
4491
4487
|
});
|
|
4492
4488
|
const confirmUpload = await dist_default3({
|
|
4493
|
-
message:
|
|
4489
|
+
message: `
|
|
4490
|
+
Upload to ${projectName}?`,
|
|
4494
4491
|
default: true
|
|
4495
4492
|
});
|
|
4496
4493
|
if (confirmUpload) {
|
|
4497
|
-
console.log(
|
|
4498
|
-
|
|
4494
|
+
console.log(
|
|
4495
|
+
`
|
|
4496
|
+
\u2B06\uFE0F Uploading ${selectedFileInfos.length} file(s) to ${projectName}...`
|
|
4497
|
+
);
|
|
4499
4498
|
let successCount = 0;
|
|
4500
4499
|
let failCount = 0;
|
|
4501
4500
|
for (const fileInfo of selectedFileInfos) {
|
|
@@ -4508,6 +4507,7 @@ async function initCommand(args2) {
|
|
|
4508
4507
|
projectName,
|
|
4509
4508
|
content,
|
|
4510
4509
|
fileInfo.relativePath
|
|
4510
|
+
// environment not specified - defaults to "default" on server
|
|
4511
4511
|
);
|
|
4512
4512
|
console.log(` \u2705 ${fileInfo.relativePath}`);
|
|
4513
4513
|
successCount++;
|
|
@@ -4561,12 +4561,16 @@ async function initCommand(args2) {
|
|
|
4561
4561
|
// src/commands/pull.ts
|
|
4562
4562
|
import { writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
4563
4563
|
import { join as join4, dirname } from "path";
|
|
4564
|
+
import { existsSync as existsSync2 } from "fs";
|
|
4564
4565
|
async function pullCommand2(args2) {
|
|
4565
4566
|
const flags = {};
|
|
4566
4567
|
let pullAll = false;
|
|
4568
|
+
let forceOverwrite = false;
|
|
4567
4569
|
for (let i = 0; i < args2.length; i++) {
|
|
4568
4570
|
if (args2[i] === "--all" || args2[i] === "-a") {
|
|
4569
4571
|
pullAll = true;
|
|
4572
|
+
} else if (args2[i] === "--force" || args2[i] === "-f") {
|
|
4573
|
+
forceOverwrite = true;
|
|
4570
4574
|
} else if (args2[i].startsWith("-")) {
|
|
4571
4575
|
const key = args2[i].replace(/^-+/, "");
|
|
4572
4576
|
const value = args2[i + 1];
|
|
@@ -4596,6 +4600,17 @@ async function pullCommand2(args2) {
|
|
|
4596
4600
|
}
|
|
4597
4601
|
try {
|
|
4598
4602
|
if (output) {
|
|
4603
|
+
const outputPath = join4(process.cwd(), output);
|
|
4604
|
+
if (existsSync2(outputPath) && !forceOverwrite) {
|
|
4605
|
+
const shouldOverwrite = await dist_default3({
|
|
4606
|
+
message: `\u26A0\uFE0F ${output} already exists. Overwrite?`,
|
|
4607
|
+
default: false
|
|
4608
|
+
});
|
|
4609
|
+
if (!shouldOverwrite) {
|
|
4610
|
+
console.log(`\u23ED\uFE0F Skipped ${output}`);
|
|
4611
|
+
return;
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4599
4614
|
console.log(`\u{1F4E5} Pulling ${output} from ${project}...`);
|
|
4600
4615
|
const content = await pullEnvFile(
|
|
4601
4616
|
config.host,
|
|
@@ -4603,7 +4618,6 @@ async function pullCommand2(args2) {
|
|
|
4603
4618
|
project,
|
|
4604
4619
|
output
|
|
4605
4620
|
);
|
|
4606
|
-
const outputPath = join4(process.cwd(), output);
|
|
4607
4621
|
const dir = dirname(outputPath);
|
|
4608
4622
|
if (dir !== process.cwd()) {
|
|
4609
4623
|
await mkdir3(dir, { recursive: true });
|
|
@@ -4671,6 +4685,36 @@ async function pullCommand2(args2) {
|
|
|
4671
4685
|
});
|
|
4672
4686
|
}
|
|
4673
4687
|
}
|
|
4688
|
+
const existingFiles = selectedFiles.filter(
|
|
4689
|
+
(f) => existsSync2(join4(process.cwd(), f))
|
|
4690
|
+
);
|
|
4691
|
+
if (existingFiles.length > 0 && !forceOverwrite) {
|
|
4692
|
+
console.log(`
|
|
4693
|
+
\u26A0\uFE0F The following local files already exist:`);
|
|
4694
|
+
existingFiles.forEach((f) => console.log(` \u2022 ${f}`));
|
|
4695
|
+
const overwriteChoice = await dist_default6({
|
|
4696
|
+
message: "\nHow would you like to proceed?",
|
|
4697
|
+
choices: [
|
|
4698
|
+
{
|
|
4699
|
+
name: "\u23ED\uFE0F Skip existing files (only pull new ones)",
|
|
4700
|
+
value: "skip"
|
|
4701
|
+
},
|
|
4702
|
+
{ name: "\u{1F4DD} Overwrite all existing files", value: "overwrite" },
|
|
4703
|
+
{ name: "\u274C Cancel", value: "cancel" }
|
|
4704
|
+
]
|
|
4705
|
+
});
|
|
4706
|
+
if (overwriteChoice === "cancel") {
|
|
4707
|
+
console.log("\u274C Cancelled");
|
|
4708
|
+
return;
|
|
4709
|
+
}
|
|
4710
|
+
if (overwriteChoice === "skip") {
|
|
4711
|
+
selectedFiles = selectedFiles.filter((f) => !existingFiles.includes(f));
|
|
4712
|
+
if (selectedFiles.length === 0) {
|
|
4713
|
+
console.log("\u23ED\uFE0F No new files to pull");
|
|
4714
|
+
return;
|
|
4715
|
+
}
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4674
4718
|
if (selectedFiles.length === 1) {
|
|
4675
4719
|
console.log(`
|
|
4676
4720
|
\u{1F4E5} Pulling ${selectedFiles[0]}...`);
|
|
@@ -4683,13 +4727,13 @@ async function pullCommand2(args2) {
|
|
|
4683
4727
|
let failCount = 0;
|
|
4684
4728
|
for (const filename of selectedFiles) {
|
|
4685
4729
|
try {
|
|
4730
|
+
const outputPath = join4(process.cwd(), filename);
|
|
4686
4731
|
const content = await pullEnvFile(
|
|
4687
4732
|
config.host,
|
|
4688
4733
|
config.authToken,
|
|
4689
4734
|
project,
|
|
4690
4735
|
filename
|
|
4691
4736
|
);
|
|
4692
|
-
const outputPath = join4(process.cwd(), filename);
|
|
4693
4737
|
const dir = dirname(outputPath);
|
|
4694
4738
|
if (dir !== process.cwd()) {
|
|
4695
4739
|
await mkdir3(dir, { recursive: true });
|
|
@@ -4762,8 +4806,7 @@ async function pushCommand2(args2) {
|
|
|
4762
4806
|
process.exit(1);
|
|
4763
4807
|
}
|
|
4764
4808
|
const project = flags.p || flags.project || config.project;
|
|
4765
|
-
|
|
4766
|
-
let input = flags.in || flags.input;
|
|
4809
|
+
let inputFile = flags.in || flags.input;
|
|
4767
4810
|
let searchDepth = 10;
|
|
4768
4811
|
if (flags.depth) {
|
|
4769
4812
|
const parsedDepth = parseInt(flags.depth, 10);
|
|
@@ -4776,7 +4819,7 @@ async function pushCommand2(args2) {
|
|
|
4776
4819
|
console.log(` This directory is initialized for ${config.project}`);
|
|
4777
4820
|
}
|
|
4778
4821
|
let selectedFiles = [];
|
|
4779
|
-
if (!
|
|
4822
|
+
if (!inputFile) {
|
|
4780
4823
|
const cwd = process.cwd();
|
|
4781
4824
|
const envFiles = await findEnvFiles(cwd, searchDepth);
|
|
4782
4825
|
if (envFiles.length === 0) {
|
|
@@ -4832,18 +4875,15 @@ async function pushCommand2(args2) {
|
|
|
4832
4875
|
}
|
|
4833
4876
|
}
|
|
4834
4877
|
} else {
|
|
4835
|
-
selectedFiles = [
|
|
4878
|
+
selectedFiles = [inputFile];
|
|
4836
4879
|
}
|
|
4837
|
-
const envSuffix = environment ? ` (env: ${environment})` : "";
|
|
4838
4880
|
if (selectedFiles.length === 1) {
|
|
4839
|
-
console.log(
|
|
4840
|
-
|
|
4841
|
-
\u{1F4E4} Pushing ${selectedFiles[0]} to ${project}${envSuffix}...`
|
|
4842
|
-
);
|
|
4881
|
+
console.log(`
|
|
4882
|
+
\u{1F4E4} Pushing ${selectedFiles[0]} to ${project}...`);
|
|
4843
4883
|
} else {
|
|
4844
4884
|
console.log(
|
|
4845
4885
|
`
|
|
4846
|
-
\u{1F4E4} Pushing ${selectedFiles.length} files to ${project}
|
|
4886
|
+
\u{1F4E4} Pushing ${selectedFiles.length} files to ${project}...
|
|
4847
4887
|
`
|
|
4848
4888
|
);
|
|
4849
4889
|
}
|
|
@@ -4880,22 +4920,23 @@ async function pushCommand2(args2) {
|
|
|
4880
4920
|
failCount++;
|
|
4881
4921
|
continue;
|
|
4882
4922
|
}
|
|
4883
|
-
await pushEnvFile(
|
|
4923
|
+
const result = await pushEnvFile(
|
|
4884
4924
|
config.host,
|
|
4885
4925
|
config.authToken,
|
|
4886
4926
|
project,
|
|
4887
4927
|
fileContent,
|
|
4888
|
-
file
|
|
4928
|
+
file
|
|
4889
4929
|
// Use full relative path, not just filename
|
|
4890
|
-
environment
|
|
4891
|
-
// Optional environment tag
|
|
4892
4930
|
);
|
|
4931
|
+
const tagInfo = result.environmentTag ? ` [${result.environmentTag}${result.tagSource === "auto" ? " auto" : ""}]` : "";
|
|
4893
4932
|
if (selectedFiles.length === 1) {
|
|
4894
4933
|
console.log(
|
|
4895
|
-
`\u2705 Pushed ${file} (${variables.length} variables) to ${project}${
|
|
4934
|
+
`\u2705 Pushed ${file} (${variables.length} variables) to ${project}${tagInfo}`
|
|
4896
4935
|
);
|
|
4897
4936
|
} else {
|
|
4898
|
-
console.log(
|
|
4937
|
+
console.log(
|
|
4938
|
+
`\u2705 ${file}: Pushed (${variables.length} variables)${tagInfo}`
|
|
4939
|
+
);
|
|
4899
4940
|
}
|
|
4900
4941
|
successCount++;
|
|
4901
4942
|
} catch (error) {
|
|
@@ -5835,7 +5876,7 @@ ${import_chalk.default.bold("Usage in Docker:")}
|
|
|
5835
5876
|
|
|
5836
5877
|
// src/utils/versionCheck.ts
|
|
5837
5878
|
var PACKAGE_NAME = "@saidulbadhon/jssm-cli";
|
|
5838
|
-
var CURRENT_VERSION = "1.6.
|
|
5879
|
+
var CURRENT_VERSION = "1.6.7";
|
|
5839
5880
|
async function getLatestVersion() {
|
|
5840
5881
|
try {
|
|
5841
5882
|
const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}`);
|