deepstrike 5.0.0 → 6.1.0
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/cli.js +417 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -30,6 +30,401 @@ var __export = (target, all) => {
|
|
|
30
30
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
31
31
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
32
32
|
|
|
33
|
+
// node_modules/dotenv/package.json
|
|
34
|
+
var require_package = __commonJS((exports, module) => {
|
|
35
|
+
module.exports = {
|
|
36
|
+
name: "dotenv",
|
|
37
|
+
version: "17.2.3",
|
|
38
|
+
description: "Loads environment variables from .env file",
|
|
39
|
+
main: "lib/main.js",
|
|
40
|
+
types: "lib/main.d.ts",
|
|
41
|
+
exports: {
|
|
42
|
+
".": {
|
|
43
|
+
types: "./lib/main.d.ts",
|
|
44
|
+
require: "./lib/main.js",
|
|
45
|
+
default: "./lib/main.js"
|
|
46
|
+
},
|
|
47
|
+
"./config": "./config.js",
|
|
48
|
+
"./config.js": "./config.js",
|
|
49
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
50
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
51
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
52
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
53
|
+
"./package.json": "./package.json"
|
|
54
|
+
},
|
|
55
|
+
scripts: {
|
|
56
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
57
|
+
lint: "standard",
|
|
58
|
+
pretest: "npm run lint && npm run dts-check",
|
|
59
|
+
test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
60
|
+
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
61
|
+
prerelease: "npm test",
|
|
62
|
+
release: "standard-version"
|
|
63
|
+
},
|
|
64
|
+
repository: {
|
|
65
|
+
type: "git",
|
|
66
|
+
url: "git://github.com/motdotla/dotenv.git"
|
|
67
|
+
},
|
|
68
|
+
homepage: "https://github.com/motdotla/dotenv#readme",
|
|
69
|
+
funding: "https://dotenvx.com",
|
|
70
|
+
keywords: [
|
|
71
|
+
"dotenv",
|
|
72
|
+
"env",
|
|
73
|
+
".env",
|
|
74
|
+
"environment",
|
|
75
|
+
"variables",
|
|
76
|
+
"config",
|
|
77
|
+
"settings"
|
|
78
|
+
],
|
|
79
|
+
readmeFilename: "README.md",
|
|
80
|
+
license: "BSD-2-Clause",
|
|
81
|
+
devDependencies: {
|
|
82
|
+
"@types/node": "^18.11.3",
|
|
83
|
+
decache: "^4.6.2",
|
|
84
|
+
sinon: "^14.0.1",
|
|
85
|
+
standard: "^17.0.0",
|
|
86
|
+
"standard-version": "^9.5.0",
|
|
87
|
+
tap: "^19.2.0",
|
|
88
|
+
typescript: "^4.8.4"
|
|
89
|
+
},
|
|
90
|
+
engines: {
|
|
91
|
+
node: ">=12"
|
|
92
|
+
},
|
|
93
|
+
browser: {
|
|
94
|
+
fs: false
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// node_modules/dotenv/lib/main.js
|
|
100
|
+
var require_main = __commonJS((exports, module) => {
|
|
101
|
+
var fs = __require("fs");
|
|
102
|
+
var path = __require("path");
|
|
103
|
+
var os = __require("os");
|
|
104
|
+
var crypto2 = __require("crypto");
|
|
105
|
+
var packageJson = require_package();
|
|
106
|
+
var version = packageJson.version;
|
|
107
|
+
var TIPS = [
|
|
108
|
+
"\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
|
|
109
|
+
"\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
110
|
+
"\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
111
|
+
"\uD83D\uDCE1 add observability to secrets: https://dotenvx.com/ops",
|
|
112
|
+
"\uD83D\uDC65 sync secrets across teammates & machines: https://dotenvx.com/ops",
|
|
113
|
+
"\uD83D\uDDC2️ backup and recover secrets: https://dotenvx.com/ops",
|
|
114
|
+
"✅ audit secrets and track compliance: https://dotenvx.com/ops",
|
|
115
|
+
"\uD83D\uDD04 add secrets lifecycle management: https://dotenvx.com/ops",
|
|
116
|
+
"\uD83D\uDD11 add access controls to secrets: https://dotenvx.com/ops",
|
|
117
|
+
"\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
|
|
118
|
+
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
119
|
+
"⚙️ enable debug logging with { debug: true }",
|
|
120
|
+
"⚙️ override existing env vars with { override: true }",
|
|
121
|
+
"⚙️ suppress all logs with { quiet: true }",
|
|
122
|
+
"⚙️ write to custom object with { processEnv: myObject }",
|
|
123
|
+
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
|
124
|
+
];
|
|
125
|
+
function _getRandomTip() {
|
|
126
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
127
|
+
}
|
|
128
|
+
function parseBoolean(value) {
|
|
129
|
+
if (typeof value === "string") {
|
|
130
|
+
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
|
131
|
+
}
|
|
132
|
+
return Boolean(value);
|
|
133
|
+
}
|
|
134
|
+
function supportsAnsi() {
|
|
135
|
+
return process.stdout.isTTY;
|
|
136
|
+
}
|
|
137
|
+
function dim(text) {
|
|
138
|
+
return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
|
|
139
|
+
}
|
|
140
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
141
|
+
function parse(src) {
|
|
142
|
+
const obj = {};
|
|
143
|
+
let lines = src.toString();
|
|
144
|
+
lines = lines.replace(/\r\n?/mg, `
|
|
145
|
+
`);
|
|
146
|
+
let match;
|
|
147
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
148
|
+
const key = match[1];
|
|
149
|
+
let value = match[2] || "";
|
|
150
|
+
value = value.trim();
|
|
151
|
+
const maybeQuote = value[0];
|
|
152
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
153
|
+
if (maybeQuote === '"') {
|
|
154
|
+
value = value.replace(/\\n/g, `
|
|
155
|
+
`);
|
|
156
|
+
value = value.replace(/\\r/g, "\r");
|
|
157
|
+
}
|
|
158
|
+
obj[key] = value;
|
|
159
|
+
}
|
|
160
|
+
return obj;
|
|
161
|
+
}
|
|
162
|
+
function _parseVault(options) {
|
|
163
|
+
options = options || {};
|
|
164
|
+
const vaultPath = _vaultPath(options);
|
|
165
|
+
options.path = vaultPath;
|
|
166
|
+
const result = DotenvModule.configDotenv(options);
|
|
167
|
+
if (!result.parsed) {
|
|
168
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
169
|
+
err.code = "MISSING_DATA";
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
const keys = _dotenvKey(options).split(",");
|
|
173
|
+
const length = keys.length;
|
|
174
|
+
let decrypted;
|
|
175
|
+
for (let i = 0;i < length; i++) {
|
|
176
|
+
try {
|
|
177
|
+
const key = keys[i].trim();
|
|
178
|
+
const attrs = _instructions(result, key);
|
|
179
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
180
|
+
break;
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (i + 1 >= length) {
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return DotenvModule.parse(decrypted);
|
|
188
|
+
}
|
|
189
|
+
function _warn(message) {
|
|
190
|
+
console.error(`[dotenv@${version}][WARN] ${message}`);
|
|
191
|
+
}
|
|
192
|
+
function _debug(message) {
|
|
193
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
194
|
+
}
|
|
195
|
+
function _log(message) {
|
|
196
|
+
console.log(`[dotenv@${version}] ${message}`);
|
|
197
|
+
}
|
|
198
|
+
function _dotenvKey(options) {
|
|
199
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
200
|
+
return options.DOTENV_KEY;
|
|
201
|
+
}
|
|
202
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
203
|
+
return process.env.DOTENV_KEY;
|
|
204
|
+
}
|
|
205
|
+
return "";
|
|
206
|
+
}
|
|
207
|
+
function _instructions(result, dotenvKey) {
|
|
208
|
+
let uri;
|
|
209
|
+
try {
|
|
210
|
+
uri = new URL(dotenvKey);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
213
|
+
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");
|
|
214
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
215
|
+
throw err;
|
|
216
|
+
}
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
const key = uri.password;
|
|
220
|
+
if (!key) {
|
|
221
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
222
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
223
|
+
throw err;
|
|
224
|
+
}
|
|
225
|
+
const environment = uri.searchParams.get("environment");
|
|
226
|
+
if (!environment) {
|
|
227
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
228
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
229
|
+
throw err;
|
|
230
|
+
}
|
|
231
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
232
|
+
const ciphertext = result.parsed[environmentKey];
|
|
233
|
+
if (!ciphertext) {
|
|
234
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
235
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
236
|
+
throw err;
|
|
237
|
+
}
|
|
238
|
+
return { ciphertext, key };
|
|
239
|
+
}
|
|
240
|
+
function _vaultPath(options) {
|
|
241
|
+
let possibleVaultPath = null;
|
|
242
|
+
if (options && options.path && options.path.length > 0) {
|
|
243
|
+
if (Array.isArray(options.path)) {
|
|
244
|
+
for (const filepath of options.path) {
|
|
245
|
+
if (fs.existsSync(filepath)) {
|
|
246
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
253
|
+
possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
|
254
|
+
}
|
|
255
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
256
|
+
return possibleVaultPath;
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
function _resolveHome(envPath) {
|
|
261
|
+
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
262
|
+
}
|
|
263
|
+
function _configVault(options) {
|
|
264
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
265
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
266
|
+
if (debug || !quiet) {
|
|
267
|
+
_log("Loading env from encrypted .env.vault");
|
|
268
|
+
}
|
|
269
|
+
const parsed = DotenvModule._parseVault(options);
|
|
270
|
+
let processEnv = process.env;
|
|
271
|
+
if (options && options.processEnv != null) {
|
|
272
|
+
processEnv = options.processEnv;
|
|
273
|
+
}
|
|
274
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
275
|
+
return { parsed };
|
|
276
|
+
}
|
|
277
|
+
function configDotenv(options) {
|
|
278
|
+
const dotenvPath = path.resolve(process.cwd(), ".env");
|
|
279
|
+
let encoding = "utf8";
|
|
280
|
+
let processEnv = process.env;
|
|
281
|
+
if (options && options.processEnv != null) {
|
|
282
|
+
processEnv = options.processEnv;
|
|
283
|
+
}
|
|
284
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
285
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
286
|
+
if (options && options.encoding) {
|
|
287
|
+
encoding = options.encoding;
|
|
288
|
+
} else {
|
|
289
|
+
if (debug) {
|
|
290
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
let optionPaths = [dotenvPath];
|
|
294
|
+
if (options && options.path) {
|
|
295
|
+
if (!Array.isArray(options.path)) {
|
|
296
|
+
optionPaths = [_resolveHome(options.path)];
|
|
297
|
+
} else {
|
|
298
|
+
optionPaths = [];
|
|
299
|
+
for (const filepath of options.path) {
|
|
300
|
+
optionPaths.push(_resolveHome(filepath));
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
let lastError;
|
|
305
|
+
const parsedAll = {};
|
|
306
|
+
for (const path2 of optionPaths) {
|
|
307
|
+
try {
|
|
308
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
|
|
309
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
310
|
+
} catch (e) {
|
|
311
|
+
if (debug) {
|
|
312
|
+
_debug(`Failed to load ${path2} ${e.message}`);
|
|
313
|
+
}
|
|
314
|
+
lastError = e;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
318
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
319
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
320
|
+
if (debug || !quiet) {
|
|
321
|
+
const keysCount = Object.keys(populated).length;
|
|
322
|
+
const shortPaths = [];
|
|
323
|
+
for (const filePath of optionPaths) {
|
|
324
|
+
try {
|
|
325
|
+
const relative = path.relative(process.cwd(), filePath);
|
|
326
|
+
shortPaths.push(relative);
|
|
327
|
+
} catch (e) {
|
|
328
|
+
if (debug) {
|
|
329
|
+
_debug(`Failed to load ${filePath} ${e.message}`);
|
|
330
|
+
}
|
|
331
|
+
lastError = e;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
335
|
+
}
|
|
336
|
+
if (lastError) {
|
|
337
|
+
return { parsed: parsedAll, error: lastError };
|
|
338
|
+
} else {
|
|
339
|
+
return { parsed: parsedAll };
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function config(options) {
|
|
343
|
+
if (_dotenvKey(options).length === 0) {
|
|
344
|
+
return DotenvModule.configDotenv(options);
|
|
345
|
+
}
|
|
346
|
+
const vaultPath = _vaultPath(options);
|
|
347
|
+
if (!vaultPath) {
|
|
348
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
349
|
+
return DotenvModule.configDotenv(options);
|
|
350
|
+
}
|
|
351
|
+
return DotenvModule._configVault(options);
|
|
352
|
+
}
|
|
353
|
+
function decrypt(encrypted, keyStr) {
|
|
354
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
355
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
356
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
357
|
+
const authTag = ciphertext.subarray(-16);
|
|
358
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
359
|
+
try {
|
|
360
|
+
const aesgcm = crypto2.createDecipheriv("aes-256-gcm", key, nonce);
|
|
361
|
+
aesgcm.setAuthTag(authTag);
|
|
362
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
363
|
+
} catch (error) {
|
|
364
|
+
const isRange = error instanceof RangeError;
|
|
365
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
366
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
367
|
+
if (isRange || invalidKeyLength) {
|
|
368
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
369
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
370
|
+
throw err;
|
|
371
|
+
} else if (decryptionFailed) {
|
|
372
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
373
|
+
err.code = "DECRYPTION_FAILED";
|
|
374
|
+
throw err;
|
|
375
|
+
} else {
|
|
376
|
+
throw error;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function populate(processEnv, parsed, options = {}) {
|
|
381
|
+
const debug = Boolean(options && options.debug);
|
|
382
|
+
const override = Boolean(options && options.override);
|
|
383
|
+
const populated = {};
|
|
384
|
+
if (typeof parsed !== "object") {
|
|
385
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
386
|
+
err.code = "OBJECT_REQUIRED";
|
|
387
|
+
throw err;
|
|
388
|
+
}
|
|
389
|
+
for (const key of Object.keys(parsed)) {
|
|
390
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
391
|
+
if (override === true) {
|
|
392
|
+
processEnv[key] = parsed[key];
|
|
393
|
+
populated[key] = parsed[key];
|
|
394
|
+
}
|
|
395
|
+
if (debug) {
|
|
396
|
+
if (override === true) {
|
|
397
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
398
|
+
} else {
|
|
399
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
} else {
|
|
403
|
+
processEnv[key] = parsed[key];
|
|
404
|
+
populated[key] = parsed[key];
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return populated;
|
|
408
|
+
}
|
|
409
|
+
var DotenvModule = {
|
|
410
|
+
configDotenv,
|
|
411
|
+
_configVault,
|
|
412
|
+
_parseVault,
|
|
413
|
+
config,
|
|
414
|
+
decrypt,
|
|
415
|
+
parse,
|
|
416
|
+
populate
|
|
417
|
+
};
|
|
418
|
+
exports.configDotenv = DotenvModule.configDotenv;
|
|
419
|
+
exports._configVault = DotenvModule._configVault;
|
|
420
|
+
exports._parseVault = DotenvModule._parseVault;
|
|
421
|
+
exports.config = DotenvModule.config;
|
|
422
|
+
exports.decrypt = DotenvModule.decrypt;
|
|
423
|
+
exports.parse = DotenvModule.parse;
|
|
424
|
+
exports.populate = DotenvModule.populate;
|
|
425
|
+
module.exports = DotenvModule;
|
|
426
|
+
});
|
|
427
|
+
|
|
33
428
|
// node_modules/@azure/core-tracing/dist/commonjs/state.js
|
|
34
429
|
var require_state = __commonJS((exports) => {
|
|
35
430
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -6420,6 +6815,7 @@ var require_tslib = __commonJS((exports, module) => {
|
|
|
6420
6815
|
});
|
|
6421
6816
|
|
|
6422
6817
|
// src/cli.ts
|
|
6818
|
+
var import_dotenv = __toESM(require_main(), 1);
|
|
6423
6819
|
import { promises as fs6 } from "fs";
|
|
6424
6820
|
import path5 from "path";
|
|
6425
6821
|
|
|
@@ -22664,6 +23060,7 @@ var formatEnvironmentToSafeSecretName = (environment, projectName) => {
|
|
|
22664
23060
|
};
|
|
22665
23061
|
var BASE_PATH = "./.deepstrike";
|
|
22666
23062
|
var TEMPLATE_FILE_NAME = formatEnvironmentFileName("env");
|
|
23063
|
+
var SECRET_INPUT_FILE_NAME = ".env.setup";
|
|
22667
23064
|
|
|
22668
23065
|
// src/fs/read.ts
|
|
22669
23066
|
import * as path3 from "path";
|
|
@@ -22830,9 +23227,21 @@ var writeJsonIfMissing = async (filePath, data) => {
|
|
|
22830
23227
|
`, "utf8");
|
|
22831
23228
|
return true;
|
|
22832
23229
|
};
|
|
23230
|
+
var writeSecretFileIfMissing = async () => {
|
|
23231
|
+
const filePath = path5.join(getDeepstrikeDir(), SECRET_INPUT_FILE_NAME);
|
|
23232
|
+
if (await fileExists(filePath))
|
|
23233
|
+
return false;
|
|
23234
|
+
await fs6.writeFile(filePath, `AZURE_CLIENT_SECRET=<input secret here>
|
|
23235
|
+
`, "utf8");
|
|
23236
|
+
return true;
|
|
23237
|
+
};
|
|
22833
23238
|
var appendGitignoreRules = async (projectRoot) => {
|
|
22834
23239
|
const gitignorePath = path5.join(projectRoot, ".gitignore");
|
|
22835
|
-
const rules = [
|
|
23240
|
+
const rules = [
|
|
23241
|
+
"!.deepstrike/.secrets.env.json",
|
|
23242
|
+
".deepstrike/.secrets.*.json",
|
|
23243
|
+
`.deepstrike/${SECRET_INPUT_FILE_NAME}`
|
|
23244
|
+
];
|
|
22836
23245
|
let existing = "";
|
|
22837
23246
|
if (await fileExists(gitignorePath)) {
|
|
22838
23247
|
existing = await fs6.readFile(gitignorePath, "utf8");
|
|
@@ -22867,6 +23276,11 @@ var getTemplateData = () => ({
|
|
|
22867
23276
|
secretNames: ["DatabasePassword", "ApiKey"]
|
|
22868
23277
|
});
|
|
22869
23278
|
var getClientSecret = () => {
|
|
23279
|
+
try {
|
|
23280
|
+
const envSetupPath = path5.join(getDeepstrikeDir(), SECRET_INPUT_FILE_NAME);
|
|
23281
|
+
import_dotenv.configDotenv({ path: envSetupPath });
|
|
23282
|
+
} catch {
|
|
23283
|
+
}
|
|
22870
23284
|
const value = process.env["AZURE_CLIENT_SECRET"];
|
|
22871
23285
|
if (!value) {
|
|
22872
23286
|
throw new Error("AZURE_CLIENT_SECRET environment variable is not set.");
|
|
@@ -22897,12 +23311,14 @@ var initCommand = async () => {
|
|
|
22897
23311
|
await ensureDir(deepstrikeDir);
|
|
22898
23312
|
const wroteTemplate = await writeJsonIfMissing(templatePath, getTemplateData());
|
|
22899
23313
|
const updatedGitignore = await appendGitignoreRules(projectRoot);
|
|
23314
|
+
const addedSecretFile = await writeSecretFileIfMissing();
|
|
22900
23315
|
const lines = [];
|
|
22901
23316
|
lines.push("Deepstrike initialized.");
|
|
22902
23317
|
lines.push(`Directory: ${deepstrikeDirName}`);
|
|
22903
23318
|
lines.push(`Template: ${path5.relative(projectRoot, templatePath)}`);
|
|
22904
23319
|
lines.push(wroteTemplate ? "Template file created." : "Template file already exists.");
|
|
22905
23320
|
lines.push(updatedGitignore ? ".gitignore updated." : ".gitignore already up to date.");
|
|
23321
|
+
lines.push(addedSecretFile ? `Secret input file created: ${SECRET_INPUT_FILE_NAME}` : `Secret input file already exists: ${SECRET_INPUT_FILE_NAME}`);
|
|
22906
23322
|
lines.push("Next: deepstrike create <environment>");
|
|
22907
23323
|
process.stdout.write(lines.join(`
|
|
22908
23324
|
`) + `
|
package/package.json
CHANGED