@saidulbadhon/jssm-cli 1.6.5 → 1.6.6

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/index.js +58 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4490,12 +4490,15 @@ async function initCommand(args2) {
4490
4490
  console.log(` ${f.relativePath} (${f.variableCount} variables)`);
4491
4491
  });
4492
4492
  const confirmUpload = await dist_default3({
4493
- message: "\nProceed with upload?",
4493
+ message: `
4494
+ Upload to ${projectName}?`,
4494
4495
  default: true
4495
4496
  });
4496
4497
  if (confirmUpload) {
4497
- console.log(`
4498
- \u2B06\uFE0F Uploading ${selectedFileInfos.length} file(s)...`);
4498
+ console.log(
4499
+ `
4500
+ \u2B06\uFE0F Uploading ${selectedFileInfos.length} file(s) to ${projectName}...`
4501
+ );
4499
4502
  let successCount = 0;
4500
4503
  let failCount = 0;
4501
4504
  for (const fileInfo of selectedFileInfos) {
@@ -4508,6 +4511,7 @@ async function initCommand(args2) {
4508
4511
  projectName,
4509
4512
  content,
4510
4513
  fileInfo.relativePath
4514
+ // environment not specified - defaults to "default" on server
4511
4515
  );
4512
4516
  console.log(` \u2705 ${fileInfo.relativePath}`);
4513
4517
  successCount++;
@@ -4561,12 +4565,16 @@ async function initCommand(args2) {
4561
4565
  // src/commands/pull.ts
4562
4566
  import { writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
4563
4567
  import { join as join4, dirname } from "path";
4568
+ import { existsSync as existsSync2 } from "fs";
4564
4569
  async function pullCommand2(args2) {
4565
4570
  const flags = {};
4566
4571
  let pullAll = false;
4572
+ let forceOverwrite = false;
4567
4573
  for (let i = 0; i < args2.length; i++) {
4568
4574
  if (args2[i] === "--all" || args2[i] === "-a") {
4569
4575
  pullAll = true;
4576
+ } else if (args2[i] === "--force" || args2[i] === "-f") {
4577
+ forceOverwrite = true;
4570
4578
  } else if (args2[i].startsWith("-")) {
4571
4579
  const key = args2[i].replace(/^-+/, "");
4572
4580
  const value = args2[i + 1];
@@ -4596,6 +4604,17 @@ async function pullCommand2(args2) {
4596
4604
  }
4597
4605
  try {
4598
4606
  if (output) {
4607
+ const outputPath = join4(process.cwd(), output);
4608
+ if (existsSync2(outputPath) && !forceOverwrite) {
4609
+ const shouldOverwrite = await dist_default3({
4610
+ message: `\u26A0\uFE0F ${output} already exists. Overwrite?`,
4611
+ default: false
4612
+ });
4613
+ if (!shouldOverwrite) {
4614
+ console.log(`\u23ED\uFE0F Skipped ${output}`);
4615
+ return;
4616
+ }
4617
+ }
4599
4618
  console.log(`\u{1F4E5} Pulling ${output} from ${project}...`);
4600
4619
  const content = await pullEnvFile(
4601
4620
  config.host,
@@ -4603,7 +4622,6 @@ async function pullCommand2(args2) {
4603
4622
  project,
4604
4623
  output
4605
4624
  );
4606
- const outputPath = join4(process.cwd(), output);
4607
4625
  const dir = dirname(outputPath);
4608
4626
  if (dir !== process.cwd()) {
4609
4627
  await mkdir3(dir, { recursive: true });
@@ -4671,6 +4689,36 @@ async function pullCommand2(args2) {
4671
4689
  });
4672
4690
  }
4673
4691
  }
4692
+ const existingFiles = selectedFiles.filter(
4693
+ (f) => existsSync2(join4(process.cwd(), f))
4694
+ );
4695
+ if (existingFiles.length > 0 && !forceOverwrite) {
4696
+ console.log(`
4697
+ \u26A0\uFE0F The following local files already exist:`);
4698
+ existingFiles.forEach((f) => console.log(` \u2022 ${f}`));
4699
+ const overwriteChoice = await dist_default6({
4700
+ message: "\nHow would you like to proceed?",
4701
+ choices: [
4702
+ {
4703
+ name: "\u23ED\uFE0F Skip existing files (only pull new ones)",
4704
+ value: "skip"
4705
+ },
4706
+ { name: "\u{1F4DD} Overwrite all existing files", value: "overwrite" },
4707
+ { name: "\u274C Cancel", value: "cancel" }
4708
+ ]
4709
+ });
4710
+ if (overwriteChoice === "cancel") {
4711
+ console.log("\u274C Cancelled");
4712
+ return;
4713
+ }
4714
+ if (overwriteChoice === "skip") {
4715
+ selectedFiles = selectedFiles.filter((f) => !existingFiles.includes(f));
4716
+ if (selectedFiles.length === 0) {
4717
+ console.log("\u23ED\uFE0F No new files to pull");
4718
+ return;
4719
+ }
4720
+ }
4721
+ }
4674
4722
  if (selectedFiles.length === 1) {
4675
4723
  console.log(`
4676
4724
  \u{1F4E5} Pulling ${selectedFiles[0]}...`);
@@ -4683,13 +4731,13 @@ async function pullCommand2(args2) {
4683
4731
  let failCount = 0;
4684
4732
  for (const filename of selectedFiles) {
4685
4733
  try {
4734
+ const outputPath = join4(process.cwd(), filename);
4686
4735
  const content = await pullEnvFile(
4687
4736
  config.host,
4688
4737
  config.authToken,
4689
4738
  project,
4690
4739
  filename
4691
4740
  );
4692
- const outputPath = join4(process.cwd(), filename);
4693
4741
  const dir = dirname(outputPath);
4694
4742
  if (dir !== process.cwd()) {
4695
4743
  await mkdir3(dir, { recursive: true });
@@ -4763,7 +4811,7 @@ async function pushCommand2(args2) {
4763
4811
  }
4764
4812
  const project = flags.p || flags.project || config.project;
4765
4813
  const environment = flags.e || flags.env;
4766
- let input = flags.in || flags.input;
4814
+ let inputFile = flags.in || flags.input;
4767
4815
  let searchDepth = 10;
4768
4816
  if (flags.depth) {
4769
4817
  const parsedDepth = parseInt(flags.depth, 10);
@@ -4776,7 +4824,7 @@ async function pushCommand2(args2) {
4776
4824
  console.log(` This directory is initialized for ${config.project}`);
4777
4825
  }
4778
4826
  let selectedFiles = [];
4779
- if (!input) {
4827
+ if (!inputFile) {
4780
4828
  const cwd = process.cwd();
4781
4829
  const envFiles = await findEnvFiles(cwd, searchDepth);
4782
4830
  if (envFiles.length === 0) {
@@ -4832,7 +4880,7 @@ async function pushCommand2(args2) {
4832
4880
  }
4833
4881
  }
4834
4882
  } else {
4835
- selectedFiles = [input];
4883
+ selectedFiles = [inputFile];
4836
4884
  }
4837
4885
  const envSuffix = environment ? ` (env: ${environment})` : "";
4838
4886
  if (selectedFiles.length === 1) {
@@ -4888,7 +4936,7 @@ async function pushCommand2(args2) {
4888
4936
  file,
4889
4937
  // Use full relative path, not just filename
4890
4938
  environment
4891
- // Optional environment tag
4939
+ // Optional - defaults to "default" on server if not provided
4892
4940
  );
4893
4941
  if (selectedFiles.length === 1) {
4894
4942
  console.log(
@@ -5835,7 +5883,7 @@ ${import_chalk.default.bold("Usage in Docker:")}
5835
5883
 
5836
5884
  // src/utils/versionCheck.ts
5837
5885
  var PACKAGE_NAME = "@saidulbadhon/jssm-cli";
5838
- var CURRENT_VERSION = "1.6.5";
5886
+ var CURRENT_VERSION = "1.6.6";
5839
5887
  async function getLatestVersion() {
5840
5888
  try {
5841
5889
  const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saidulbadhon/jssm-cli",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "private": false,
5
5
  "description": "CLI for JSSM - Simple environment variable manager",
6
6
  "author": "Saidul Badhon",