varlock 0.1.6 → 0.2.1

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 (40) hide show
  1. package/dist/{chunk-QYL63H5X.js → chunk-4CRDKWAU.js} +97 -7
  2. package/dist/chunk-4CRDKWAU.js.map +1 -0
  3. package/dist/{chunk-4LIQGKEE.js → chunk-H5IG4ZVM.js} +13 -8
  4. package/dist/chunk-H5IG4ZVM.js.map +1 -0
  5. package/dist/{chunk-N6YMZ3HA.js → chunk-NA4YDM42.js} +34 -8
  6. package/dist/chunk-NA4YDM42.js.map +1 -0
  7. package/dist/{chunk-ARMP7LS5.js → chunk-NDWB3TT5.js} +3 -3
  8. package/dist/{chunk-ARMP7LS5.js.map → chunk-NDWB3TT5.js.map} +1 -1
  9. package/dist/{chunk-6Z6JYESC.js → chunk-NHA2P5AV.js} +30 -6
  10. package/dist/chunk-NHA2P5AV.js.map +1 -0
  11. package/dist/{chunk-OOBWRTIS.js → chunk-OKNWYS57.js} +161 -112
  12. package/dist/chunk-OKNWYS57.js.map +1 -0
  13. package/dist/{chunk-N4HZJLL3.js → chunk-ZLM3MCYF.js} +16 -5
  14. package/dist/chunk-ZLM3MCYF.js.map +1 -0
  15. package/dist/cli/cli-executable.js +12 -12
  16. package/dist/cli/cli-executable.js.map +1 -1
  17. package/dist/{env-graph-eF0B8G0j.d.ts → env-graph-BZwrHQbb.d.ts} +0 -2
  18. package/dist/index.d.ts +4 -2
  19. package/dist/index.js +2 -2
  20. package/dist/init.command-GNLFBWYF.js +8 -0
  21. package/dist/{init.command-RZ3LEK7W.js.map → init.command-GNLFBWYF.js.map} +1 -1
  22. package/dist/load.command-WR5QCE6M.js +8 -0
  23. package/dist/{load.command-6Z3QLGY2.js.map → load.command-WR5QCE6M.js.map} +1 -1
  24. package/dist/plugin-lib.d.ts +2 -2
  25. package/dist/run.command-GXQTDDDP.js +9 -0
  26. package/dist/{run.command-DSZSZMCY.js.map → run.command-GXQTDDDP.js.map} +1 -1
  27. package/dist/runtime/env.d.ts +1 -1
  28. package/dist/telemetry.command-ZFW55RLH.js +8 -0
  29. package/dist/{telemetry.command-XKHQ3QFE.js.map → telemetry.command-ZFW55RLH.js.map} +1 -1
  30. package/package.json +2 -2
  31. package/dist/chunk-4LIQGKEE.js.map +0 -1
  32. package/dist/chunk-6Z6JYESC.js.map +0 -1
  33. package/dist/chunk-N4HZJLL3.js.map +0 -1
  34. package/dist/chunk-N6YMZ3HA.js.map +0 -1
  35. package/dist/chunk-OOBWRTIS.js.map +0 -1
  36. package/dist/chunk-QYL63H5X.js.map +0 -1
  37. package/dist/init.command-RZ3LEK7W.js +0 -8
  38. package/dist/load.command-6Z3QLGY2.js +0 -8
  39. package/dist/run.command-DSZSZMCY.js +0 -9
  40. package/dist/telemetry.command-XKHQ3QFE.js +0 -8
@@ -1,14 +1,15 @@
1
- import { detectJsPackageManager, logLines, fmt, installJsDependency } from './chunk-4LIQGKEE.js';
1
+ import { detectJsPackageManager, logLines, fmt, installJsDependency } from './chunk-H5IG4ZVM.js';
2
2
  import { define } from './chunk-33ROL4J5.js';
3
- import { tryCatch, gracefulExit, checkIsFileGitIgnored, ansis_default, pathExists } from './chunk-OOBWRTIS.js';
3
+ import { tryCatch, gracefulExit, ansis_default, pathExists } from './chunk-OKNWYS57.js';
4
4
  import { __commonJS, __name, __toESM } from './chunk-XN24GZXQ.js';
5
- import path2 from 'path';
5
+ import path2, { dirname } from 'path';
6
6
  import fs3 from 'fs/promises';
7
- import 'util';
7
+ import { promisify } from 'util';
8
8
  import y2, { stdin, stdout } from 'process';
9
9
  import O from 'readline';
10
10
  import { Writable } from 'stream';
11
11
  import { envSpecUpdater, ParsedEnvSpecStaticValue, parseEnvSpecDotEnvFile } from '@env-spec/parser';
12
+ import { exec, spawn } from 'child_process';
12
13
  import { WriteStream } from 'tty';
13
14
 
14
15
  // ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
@@ -630,6 +631,80 @@ ${import_picocolors.default.cyan(d2)}
630
631
  } }).prompt();
631
632
  }, "ve");
632
633
  `${import_picocolors.default.gray(o)} `;
634
+ var ExecError = class extends Error {
635
+ constructor(exitCode, signal, data = "command gave no output") {
636
+ super(data);
637
+ this.exitCode = exitCode;
638
+ this.signal = signal;
639
+ this.data = data;
640
+ }
641
+ static {
642
+ __name(this, "ExecError");
643
+ }
644
+ };
645
+ function spawnAsyncHelper(command, args, spawnOptions) {
646
+ const childProcess = spawn(command, args, spawnOptions || {});
647
+ const deferred = new Promise((resolve, reject) => {
648
+ let stdoutData = "";
649
+ let stderrData = "";
650
+ childProcess.stdout?.on("data", (data) => {
651
+ stdoutData += data.toString();
652
+ });
653
+ childProcess.stderr?.on("data", (data) => {
654
+ stderrData += data.toString();
655
+ });
656
+ childProcess.stdout?.on("error", (err) => {
657
+ reject(err);
658
+ });
659
+ childProcess.stderr?.on("error", (err) => {
660
+ reject(err);
661
+ });
662
+ childProcess.on("error", (err) => {
663
+ reject(err);
664
+ });
665
+ childProcess.on("exit", (exitCode, signal) => {
666
+ if (!exitCode) {
667
+ resolve(stdoutData);
668
+ } else {
669
+ reject(
670
+ new ExecError(exitCode, signal, stderrData)
671
+ );
672
+ }
673
+ });
674
+ });
675
+ return { childProcess, execResult: deferred };
676
+ }
677
+ __name(spawnAsyncHelper, "spawnAsyncHelper");
678
+ async function spawnAsync(command, args, opts) {
679
+ const { execResult } = spawnAsyncHelper(command, args, opts);
680
+ return execResult;
681
+ }
682
+ __name(spawnAsync, "spawnAsync");
683
+ promisify(exec);
684
+ async function checkIsFileGitIgnored(path3, warnIfNotGitRepo = false) {
685
+ try {
686
+ await spawnAsync("git", ["check-ignore", path3, "-q"], { cwd: dirname(path3) });
687
+ return true;
688
+ } catch (err) {
689
+ const errorOutput = err.data;
690
+ if (err.exitCode === 127 || errorOutput.includes("not found") || errorOutput.includes("not recognized")) {
691
+ return void 0;
692
+ }
693
+ if (err.code === "ENOENT") return void 0;
694
+ if (errorOutput === "") return false;
695
+ if (errorOutput.includes("not a git repository")) {
696
+ if (warnIfNotGitRepo) {
697
+ console.log("\u{1F536} Your code is not currently in a git repository - run `git init` to initialize a new repo.");
698
+ }
699
+ return false;
700
+ }
701
+ if (stderr.includes("is outside repository")) {
702
+ return void 0;
703
+ }
704
+ throw err;
705
+ }
706
+ }
707
+ __name(checkIsFileGitIgnored, "checkIsFileGitIgnored");
633
708
  function isUnicodeSupported() {
634
709
  const { env } = y2;
635
710
  const { TERM, TERM_PROGRAM } = env;
@@ -1008,7 +1083,22 @@ __name(findEnvFiles, "findEnvFiles");
1008
1083
  var commandSpec = define({
1009
1084
  name: "init",
1010
1085
  description: "Set up varlock in the current project",
1011
- args: {}
1086
+ args: {},
1087
+ examples: `
1088
+ This command starts an interactive onboarding process to help you get started with Varlock.
1089
+ It will:
1090
+ - Scan for existing .env files in your project
1091
+ - Help create a .env.schema file from your .env.example or .env.sample file
1092
+ - Install varlock as a dependency in package.json (if applicable)
1093
+
1094
+ \u{1F4CD} Run this command in directories that contain .env or .env.* files
1095
+
1096
+ Examples:
1097
+ varlock init # Run in the current directory
1098
+ cd path/to/your/project && varlock init
1099
+
1100
+ For more information, visit https://varlock.dev/getting-started/installation
1101
+ `.trim()
1012
1102
  });
1013
1103
  var commandFn = /* @__PURE__ */ __name(async (ctx) => {
1014
1104
  const jsPackageManager = detectJsPackageManager();
@@ -1187,5 +1277,5 @@ var commandFn = /* @__PURE__ */ __name(async (ctx) => {
1187
1277
  }, "commandFn");
1188
1278
 
1189
1279
  export { commandFn, commandSpec };
1190
- //# sourceMappingURL=chunk-QYL63H5X.js.map
1191
- //# sourceMappingURL=chunk-QYL63H5X.js.map
1280
+ //# sourceMappingURL=chunk-4CRDKWAU.js.map
1281
+ //# sourceMappingURL=chunk-4CRDKWAU.js.map