@synkro-sh/cli 1.3.2 → 1.3.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/bootstrap.js CHANGED
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
8
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
9
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
10
  }) : x)(function(x) {
@@ -10,10 +14,29 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
10
14
  var __esm = (fn, res) => function __init() {
11
15
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
16
  };
17
+ var __commonJS = (cb, mod) => function __require2() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
13
20
  var __export = (target, all) => {
14
21
  for (var name in all)
15
22
  __defProp(target, name, { get: all[name], enumerable: true });
16
23
  };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") {
26
+ for (let key of __getOwnPropNames(from))
27
+ if (!__hasOwnProp.call(to, key) && key !== except)
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
+ }
30
+ return to;
31
+ };
32
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
+ // If the importer is in node compatibility mode or this is not an ESM
34
+ // file that has been converted to a CommonJS file using a Babel-
35
+ // compatible transform (i.e. "__esModule" has not been set), then set
36
+ // "default" to the CommonJS "module.exports" for node compatibility.
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
+ mod
39
+ ));
17
40
 
18
41
  // cli/installer/agentDetect.ts
19
42
  import { existsSync } from "fs";
@@ -2284,6 +2307,404 @@ var init_stub = __esm({
2284
2307
  }
2285
2308
  });
2286
2309
 
2310
+ // ../../node_modules/.pnpm/dotenv@17.2.4/node_modules/dotenv/package.json
2311
+ var require_package = __commonJS({
2312
+ "../../node_modules/.pnpm/dotenv@17.2.4/node_modules/dotenv/package.json"(exports, module) {
2313
+ module.exports = {
2314
+ name: "dotenv",
2315
+ version: "17.2.4",
2316
+ description: "Loads environment variables from .env file",
2317
+ main: "lib/main.js",
2318
+ types: "lib/main.d.ts",
2319
+ exports: {
2320
+ ".": {
2321
+ types: "./lib/main.d.ts",
2322
+ require: "./lib/main.js",
2323
+ default: "./lib/main.js"
2324
+ },
2325
+ "./config": "./config.js",
2326
+ "./config.js": "./config.js",
2327
+ "./lib/env-options": "./lib/env-options.js",
2328
+ "./lib/env-options.js": "./lib/env-options.js",
2329
+ "./lib/cli-options": "./lib/cli-options.js",
2330
+ "./lib/cli-options.js": "./lib/cli-options.js",
2331
+ "./package.json": "./package.json"
2332
+ },
2333
+ scripts: {
2334
+ "dts-check": "tsc --project tests/types/tsconfig.json",
2335
+ lint: "standard",
2336
+ pretest: "npm run lint && npm run dts-check",
2337
+ test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
2338
+ "test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
2339
+ prerelease: "npm test",
2340
+ release: "standard-version"
2341
+ },
2342
+ repository: {
2343
+ type: "git",
2344
+ url: "git://github.com/motdotla/dotenv.git"
2345
+ },
2346
+ homepage: "https://github.com/motdotla/dotenv#readme",
2347
+ funding: "https://dotenvx.com",
2348
+ keywords: [
2349
+ "dotenv",
2350
+ "env",
2351
+ ".env",
2352
+ "environment",
2353
+ "variables",
2354
+ "config",
2355
+ "settings"
2356
+ ],
2357
+ readmeFilename: "README.md",
2358
+ license: "BSD-2-Clause",
2359
+ devDependencies: {
2360
+ "@types/node": "^18.11.3",
2361
+ decache: "^4.6.2",
2362
+ sinon: "^14.0.1",
2363
+ standard: "^17.0.0",
2364
+ "standard-version": "^9.5.0",
2365
+ tap: "^19.2.0",
2366
+ typescript: "^4.8.4"
2367
+ },
2368
+ engines: {
2369
+ node: ">=12"
2370
+ },
2371
+ browser: {
2372
+ fs: false
2373
+ }
2374
+ };
2375
+ }
2376
+ });
2377
+
2378
+ // ../../node_modules/.pnpm/dotenv@17.2.4/node_modules/dotenv/lib/main.js
2379
+ var require_main = __commonJS({
2380
+ "../../node_modules/.pnpm/dotenv@17.2.4/node_modules/dotenv/lib/main.js"(exports, module) {
2381
+ "use strict";
2382
+ var fs = __require("fs");
2383
+ var path = __require("path");
2384
+ var os = __require("os");
2385
+ var crypto = __require("crypto");
2386
+ var packageJson = require_package();
2387
+ var version = packageJson.version;
2388
+ var TIPS = [
2389
+ "\u{1F510} encrypt with Dotenvx: https://dotenvx.com",
2390
+ "\u{1F510} prevent committing .env to code: https://dotenvx.com/precommit",
2391
+ "\u{1F510} prevent building .env in docker: https://dotenvx.com/prebuild",
2392
+ "\u{1F4E1} add observability to secrets: https://dotenvx.com/ops",
2393
+ "\u{1F465} sync secrets across teammates & machines: https://dotenvx.com/ops",
2394
+ "\u{1F5C2}\uFE0F backup and recover secrets: https://dotenvx.com/ops",
2395
+ "\u2705 audit secrets and track compliance: https://dotenvx.com/ops",
2396
+ "\u{1F504} add secrets lifecycle management: https://dotenvx.com/ops",
2397
+ "\u{1F511} add access controls to secrets: https://dotenvx.com/ops",
2398
+ "\u{1F6E0}\uFE0F run anywhere with `dotenvx run -- yourcommand`",
2399
+ "\u2699\uFE0F specify custom .env file path with { path: '/custom/path/.env' }",
2400
+ "\u2699\uFE0F enable debug logging with { debug: true }",
2401
+ "\u2699\uFE0F override existing env vars with { override: true }",
2402
+ "\u2699\uFE0F suppress all logs with { quiet: true }",
2403
+ "\u2699\uFE0F write to custom object with { processEnv: myObject }",
2404
+ "\u2699\uFE0F load multiple .env files with { path: ['.env.local', '.env'] }"
2405
+ ];
2406
+ function _getRandomTip() {
2407
+ return TIPS[Math.floor(Math.random() * TIPS.length)];
2408
+ }
2409
+ function parseBoolean(value) {
2410
+ if (typeof value === "string") {
2411
+ return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
2412
+ }
2413
+ return Boolean(value);
2414
+ }
2415
+ function supportsAnsi() {
2416
+ return process.stdout.isTTY;
2417
+ }
2418
+ function dim(text) {
2419
+ return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
2420
+ }
2421
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
2422
+ function parse(src) {
2423
+ const obj = {};
2424
+ let lines = src.toString();
2425
+ lines = lines.replace(/\r\n?/mg, "\n");
2426
+ let match;
2427
+ while ((match = LINE.exec(lines)) != null) {
2428
+ const key = match[1];
2429
+ let value = match[2] || "";
2430
+ value = value.trim();
2431
+ const maybeQuote = value[0];
2432
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
2433
+ if (maybeQuote === '"') {
2434
+ value = value.replace(/\\n/g, "\n");
2435
+ value = value.replace(/\\r/g, "\r");
2436
+ }
2437
+ obj[key] = value;
2438
+ }
2439
+ return obj;
2440
+ }
2441
+ function _parseVault(options) {
2442
+ options = options || {};
2443
+ const vaultPath = _vaultPath(options);
2444
+ options.path = vaultPath;
2445
+ const result = DotenvModule.configDotenv(options);
2446
+ if (!result.parsed) {
2447
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
2448
+ err.code = "MISSING_DATA";
2449
+ throw err;
2450
+ }
2451
+ const keys = _dotenvKey(options).split(",");
2452
+ const length = keys.length;
2453
+ let decrypted;
2454
+ for (let i = 0; i < length; i++) {
2455
+ try {
2456
+ const key = keys[i].trim();
2457
+ const attrs = _instructions(result, key);
2458
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
2459
+ break;
2460
+ } catch (error) {
2461
+ if (i + 1 >= length) {
2462
+ throw error;
2463
+ }
2464
+ }
2465
+ }
2466
+ return DotenvModule.parse(decrypted);
2467
+ }
2468
+ function _warn(message) {
2469
+ console.error(`[dotenv@${version}][WARN] ${message}`);
2470
+ }
2471
+ function _debug(message) {
2472
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
2473
+ }
2474
+ function _log(message) {
2475
+ console.log(`[dotenv@${version}] ${message}`);
2476
+ }
2477
+ function _dotenvKey(options) {
2478
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
2479
+ return options.DOTENV_KEY;
2480
+ }
2481
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
2482
+ return process.env.DOTENV_KEY;
2483
+ }
2484
+ return "";
2485
+ }
2486
+ function _instructions(result, dotenvKey) {
2487
+ let uri;
2488
+ try {
2489
+ uri = new URL(dotenvKey);
2490
+ } catch (error) {
2491
+ if (error.code === "ERR_INVALID_URL") {
2492
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
2493
+ err.code = "INVALID_DOTENV_KEY";
2494
+ throw err;
2495
+ }
2496
+ throw error;
2497
+ }
2498
+ const key = uri.password;
2499
+ if (!key) {
2500
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
2501
+ err.code = "INVALID_DOTENV_KEY";
2502
+ throw err;
2503
+ }
2504
+ const environment = uri.searchParams.get("environment");
2505
+ if (!environment) {
2506
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
2507
+ err.code = "INVALID_DOTENV_KEY";
2508
+ throw err;
2509
+ }
2510
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
2511
+ const ciphertext = result.parsed[environmentKey];
2512
+ if (!ciphertext) {
2513
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
2514
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
2515
+ throw err;
2516
+ }
2517
+ return { ciphertext, key };
2518
+ }
2519
+ function _vaultPath(options) {
2520
+ let possibleVaultPath = null;
2521
+ if (options && options.path && options.path.length > 0) {
2522
+ if (Array.isArray(options.path)) {
2523
+ for (const filepath of options.path) {
2524
+ if (fs.existsSync(filepath)) {
2525
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
2526
+ }
2527
+ }
2528
+ } else {
2529
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
2530
+ }
2531
+ } else {
2532
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
2533
+ }
2534
+ if (fs.existsSync(possibleVaultPath)) {
2535
+ return possibleVaultPath;
2536
+ }
2537
+ return null;
2538
+ }
2539
+ function _resolveHome(envPath) {
2540
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
2541
+ }
2542
+ function _configVault(options) {
2543
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
2544
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
2545
+ if (debug || !quiet) {
2546
+ _log("Loading env from encrypted .env.vault");
2547
+ }
2548
+ const parsed = DotenvModule._parseVault(options);
2549
+ let processEnv = process.env;
2550
+ if (options && options.processEnv != null) {
2551
+ processEnv = options.processEnv;
2552
+ }
2553
+ DotenvModule.populate(processEnv, parsed, options);
2554
+ return { parsed };
2555
+ }
2556
+ function configDotenv(options) {
2557
+ const dotenvPath = path.resolve(process.cwd(), ".env");
2558
+ let encoding = "utf8";
2559
+ let processEnv = process.env;
2560
+ if (options && options.processEnv != null) {
2561
+ processEnv = options.processEnv;
2562
+ }
2563
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
2564
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
2565
+ if (options && options.encoding) {
2566
+ encoding = options.encoding;
2567
+ } else {
2568
+ if (debug) {
2569
+ _debug("No encoding is specified. UTF-8 is used by default");
2570
+ }
2571
+ }
2572
+ let optionPaths = [dotenvPath];
2573
+ if (options && options.path) {
2574
+ if (!Array.isArray(options.path)) {
2575
+ optionPaths = [_resolveHome(options.path)];
2576
+ } else {
2577
+ optionPaths = [];
2578
+ for (const filepath of options.path) {
2579
+ optionPaths.push(_resolveHome(filepath));
2580
+ }
2581
+ }
2582
+ }
2583
+ let lastError;
2584
+ const parsedAll = {};
2585
+ for (const path2 of optionPaths) {
2586
+ try {
2587
+ const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
2588
+ DotenvModule.populate(parsedAll, parsed, options);
2589
+ } catch (e) {
2590
+ if (debug) {
2591
+ _debug(`Failed to load ${path2} ${e.message}`);
2592
+ }
2593
+ lastError = e;
2594
+ }
2595
+ }
2596
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
2597
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
2598
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
2599
+ if (debug || !quiet) {
2600
+ const keysCount = Object.keys(populated).length;
2601
+ const shortPaths = [];
2602
+ for (const filePath of optionPaths) {
2603
+ try {
2604
+ const relative = path.relative(process.cwd(), filePath);
2605
+ shortPaths.push(relative);
2606
+ } catch (e) {
2607
+ if (debug) {
2608
+ _debug(`Failed to load ${filePath} ${e.message}`);
2609
+ }
2610
+ lastError = e;
2611
+ }
2612
+ }
2613
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
2614
+ }
2615
+ if (lastError) {
2616
+ return { parsed: parsedAll, error: lastError };
2617
+ } else {
2618
+ return { parsed: parsedAll };
2619
+ }
2620
+ }
2621
+ function config2(options) {
2622
+ if (_dotenvKey(options).length === 0) {
2623
+ return DotenvModule.configDotenv(options);
2624
+ }
2625
+ const vaultPath = _vaultPath(options);
2626
+ if (!vaultPath) {
2627
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
2628
+ return DotenvModule.configDotenv(options);
2629
+ }
2630
+ return DotenvModule._configVault(options);
2631
+ }
2632
+ function decrypt(encrypted, keyStr) {
2633
+ const key = Buffer.from(keyStr.slice(-64), "hex");
2634
+ let ciphertext = Buffer.from(encrypted, "base64");
2635
+ const nonce = ciphertext.subarray(0, 12);
2636
+ const authTag = ciphertext.subarray(-16);
2637
+ ciphertext = ciphertext.subarray(12, -16);
2638
+ try {
2639
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
2640
+ aesgcm.setAuthTag(authTag);
2641
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
2642
+ } catch (error) {
2643
+ const isRange = error instanceof RangeError;
2644
+ const invalidKeyLength = error.message === "Invalid key length";
2645
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
2646
+ if (isRange || invalidKeyLength) {
2647
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
2648
+ err.code = "INVALID_DOTENV_KEY";
2649
+ throw err;
2650
+ } else if (decryptionFailed) {
2651
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
2652
+ err.code = "DECRYPTION_FAILED";
2653
+ throw err;
2654
+ } else {
2655
+ throw error;
2656
+ }
2657
+ }
2658
+ }
2659
+ function populate(processEnv, parsed, options = {}) {
2660
+ const debug = Boolean(options && options.debug);
2661
+ const override = Boolean(options && options.override);
2662
+ const populated = {};
2663
+ if (typeof parsed !== "object") {
2664
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
2665
+ err.code = "OBJECT_REQUIRED";
2666
+ throw err;
2667
+ }
2668
+ for (const key of Object.keys(parsed)) {
2669
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
2670
+ if (override === true) {
2671
+ processEnv[key] = parsed[key];
2672
+ populated[key] = parsed[key];
2673
+ }
2674
+ if (debug) {
2675
+ if (override === true) {
2676
+ _debug(`"${key}" is already defined and WAS overwritten`);
2677
+ } else {
2678
+ _debug(`"${key}" is already defined and was NOT overwritten`);
2679
+ }
2680
+ }
2681
+ } else {
2682
+ processEnv[key] = parsed[key];
2683
+ populated[key] = parsed[key];
2684
+ }
2685
+ }
2686
+ return populated;
2687
+ }
2688
+ var DotenvModule = {
2689
+ configDotenv,
2690
+ _configVault,
2691
+ _parseVault,
2692
+ config: config2,
2693
+ decrypt,
2694
+ parse,
2695
+ populate
2696
+ };
2697
+ module.exports.configDotenv = DotenvModule.configDotenv;
2698
+ module.exports._configVault = DotenvModule._configVault;
2699
+ module.exports._parseVault = DotenvModule._parseVault;
2700
+ module.exports.config = DotenvModule.config;
2701
+ module.exports.decrypt = DotenvModule.decrypt;
2702
+ module.exports.parse = DotenvModule.parse;
2703
+ module.exports.populate = DotenvModule.populate;
2704
+ module.exports = DotenvModule;
2705
+ }
2706
+ });
2707
+
2287
2708
  // cli/auth/index.ts
2288
2709
  var init_auth = __esm({
2289
2710
  "cli/auth/index.ts"() {
@@ -2293,7 +2714,6 @@ var init_auth = __esm({
2293
2714
  });
2294
2715
 
2295
2716
  // cli/api/projects.ts
2296
- import { config } from "dotenv";
2297
2717
  async function callApi(method, endpoint, body) {
2298
2718
  if (!API_URL) {
2299
2719
  throw new Error("SYNKRO_CRUD_URL (or SYNKRO_API_URL) is not set. Add it to your .env file.");
@@ -2328,12 +2748,13 @@ async function listProjects() {
2328
2748
  async function unlinkRepo(projectId, repoId) {
2329
2749
  return callApi("DELETE", `/projects/${projectId}/repos/${repoId}`);
2330
2750
  }
2331
- var API_URL;
2751
+ var import_dotenv, API_URL;
2332
2752
  var init_projects = __esm({
2333
2753
  "cli/api/projects.ts"() {
2334
2754
  "use strict";
2755
+ import_dotenv = __toESM(require_main(), 1);
2335
2756
  init_auth();
2336
- config({ quiet: true });
2757
+ (0, import_dotenv.config)({ quiet: true });
2337
2758
  API_URL = process.env.SYNKRO_CRUD_URL || process.env.SYNKRO_API_URL;
2338
2759
  }
2339
2760
  });
@@ -2776,7 +3197,7 @@ function writeConfigEnv(opts) {
2776
3197
  `SYNKRO_GATEWAY_URL=${shellQuoteSingle(safeGateway)}`,
2777
3198
  `SYNKRO_CREDENTIALS_PATH=${shellQuoteSingle(credsPath)}`,
2778
3199
  `SYNKRO_TIER=${shellQuoteSingle(safeTier)}`,
2779
- `SYNKRO_VERSION=${shellQuoteSingle("1.3.2")}`
3200
+ `SYNKRO_VERSION=${shellQuoteSingle("1.3.3")}`
2780
3201
  ];
2781
3202
  if (safeUserId) lines.push(`SYNKRO_USER_ID=${shellQuoteSingle(safeUserId)}`);
2782
3203
  if (safeOrgId) lines.push(`SYNKRO_ORG_ID=${shellQuoteSingle(safeOrgId)}`);