@envpilot/cli 1.6.1 → 1.7.2
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.
|
@@ -7,7 +7,7 @@ function initSentry() {
|
|
|
7
7
|
Sentry.init({
|
|
8
8
|
dsn,
|
|
9
9
|
environment: "cli",
|
|
10
|
-
release: true ? "1.
|
|
10
|
+
release: true ? "1.11.0" : "0.0.0",
|
|
11
11
|
// Free tier: disable performance monitoring
|
|
12
12
|
tracesSampleRate: 0,
|
|
13
13
|
beforeSend(event) {
|
|
@@ -143,9 +143,6 @@ function getConfigPath() {
|
|
|
143
143
|
return config.path;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
// src/ui/render-tui.tsx
|
|
147
|
-
import chalk from "chalk";
|
|
148
|
-
|
|
149
146
|
// src/ui/execute-command.ts
|
|
150
147
|
import { spawn } from "child_process";
|
|
151
148
|
import { dirname, resolve } from "path";
|
|
@@ -177,9 +174,10 @@ async function executeCommand(argv) {
|
|
|
177
174
|
// src/ui/render-tui.tsx
|
|
178
175
|
import { jsx } from "react/jsx-runtime";
|
|
179
176
|
async function openTUI() {
|
|
180
|
-
const [{ render }, { CLIApp }] = await Promise.all([
|
|
177
|
+
const [{ render }, { CLIApp }, { PressAnyKey }] = await Promise.all([
|
|
181
178
|
import("ink"),
|
|
182
|
-
import("./app-
|
|
179
|
+
import("./app-QG4JFCWP.js"),
|
|
180
|
+
import("./press-any-key-64XFP4O2.js")
|
|
183
181
|
]);
|
|
184
182
|
while (true) {
|
|
185
183
|
let selectedArgv = null;
|
|
@@ -201,24 +199,18 @@ async function openTUI() {
|
|
|
201
199
|
if (code !== 0) {
|
|
202
200
|
process.exitCode = code;
|
|
203
201
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
process.stdin.resume();
|
|
213
|
-
process.stdin.once("data", (data) => {
|
|
214
|
-
const ch = data.toString();
|
|
215
|
-
if (process.stdin.isTTY) {
|
|
216
|
-
process.stdin.setRawMode(false);
|
|
202
|
+
let quit = false;
|
|
203
|
+
const prompt = render(
|
|
204
|
+
/* @__PURE__ */ jsx(
|
|
205
|
+
PressAnyKey,
|
|
206
|
+
{
|
|
207
|
+
onResolve: (q) => {
|
|
208
|
+
quit = q;
|
|
209
|
+
}
|
|
217
210
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
});
|
|
211
|
+
)
|
|
212
|
+
);
|
|
213
|
+
await prompt.waitUntilExit();
|
|
222
214
|
if (quit) {
|
|
223
215
|
break;
|
|
224
216
|
}
|
|
@@ -229,7 +221,7 @@ async function openTUI() {
|
|
|
229
221
|
import { Command } from "commander";
|
|
230
222
|
|
|
231
223
|
// src/lib/ui.ts
|
|
232
|
-
import
|
|
224
|
+
import chalk from "chalk";
|
|
233
225
|
import ora from "ora";
|
|
234
226
|
function createSpinner(text) {
|
|
235
227
|
return ora({
|
|
@@ -250,25 +242,25 @@ async function withSpinner(text, operation, options) {
|
|
|
250
242
|
}
|
|
251
243
|
}
|
|
252
244
|
function success(message) {
|
|
253
|
-
console.log(
|
|
245
|
+
console.log(chalk.green("\u2713"), message);
|
|
254
246
|
}
|
|
255
247
|
function info(message) {
|
|
256
|
-
console.log(
|
|
248
|
+
console.log(chalk.blue("\u2139"), message);
|
|
257
249
|
}
|
|
258
250
|
function warning(message) {
|
|
259
|
-
console.log(
|
|
251
|
+
console.log(chalk.yellow("\u26A0"), message);
|
|
260
252
|
}
|
|
261
253
|
function error(message) {
|
|
262
|
-
console.log(
|
|
254
|
+
console.log(chalk.red("\u2717"), message);
|
|
263
255
|
}
|
|
264
256
|
function header(text) {
|
|
265
257
|
console.log();
|
|
266
|
-
console.log(
|
|
267
|
-
console.log(
|
|
258
|
+
console.log(chalk.bold(text));
|
|
259
|
+
console.log(chalk.dim("\u2500".repeat(text.length)));
|
|
268
260
|
}
|
|
269
261
|
function table(data, columns) {
|
|
270
262
|
if (data.length === 0) {
|
|
271
|
-
console.log(
|
|
263
|
+
console.log(chalk.dim("No data to display"));
|
|
272
264
|
return;
|
|
273
265
|
}
|
|
274
266
|
const widths = columns.map((col) => {
|
|
@@ -279,8 +271,8 @@ function table(data, columns) {
|
|
|
279
271
|
return col.width ?? Math.max(headerWidth, maxDataWidth);
|
|
280
272
|
});
|
|
281
273
|
const headerLine = columns.map((col, i) => col.header.padEnd(widths[i])).join(" ");
|
|
282
|
-
console.log(
|
|
283
|
-
console.log(
|
|
274
|
+
console.log(chalk.bold(headerLine));
|
|
275
|
+
console.log(chalk.dim("\u2500".repeat(headerLine.length)));
|
|
284
276
|
for (const row of data) {
|
|
285
277
|
const line2 = columns.map((col, i) => String(row[col.key] ?? "").padEnd(widths[i])).join(" ");
|
|
286
278
|
console.log(line2);
|
|
@@ -290,23 +282,23 @@ function keyValue(pairs) {
|
|
|
290
282
|
const maxKeyLength = Math.max(...pairs.map(([key]) => key.length));
|
|
291
283
|
for (const [key, value] of pairs) {
|
|
292
284
|
const paddedKey = key.padEnd(maxKeyLength);
|
|
293
|
-
console.log(`${
|
|
285
|
+
console.log(`${chalk.dim(paddedKey)} ${value ?? chalk.dim("(not set)")}`);
|
|
294
286
|
}
|
|
295
287
|
}
|
|
296
288
|
function diff(added, removed, changed) {
|
|
297
289
|
if (Object.keys(added).length === 0 && Object.keys(removed).length === 0 && Object.keys(changed).length === 0) {
|
|
298
|
-
console.log(
|
|
290
|
+
console.log(chalk.dim("No changes"));
|
|
299
291
|
return;
|
|
300
292
|
}
|
|
301
293
|
for (const [key, value] of Object.entries(added)) {
|
|
302
|
-
console.log(
|
|
294
|
+
console.log(chalk.green(`+ ${key}=${maskValue(value)}`));
|
|
303
295
|
}
|
|
304
296
|
for (const [key, value] of Object.entries(removed)) {
|
|
305
|
-
console.log(
|
|
297
|
+
console.log(chalk.red(`- ${key}=${maskValue(value)}`));
|
|
306
298
|
}
|
|
307
299
|
for (const [key, { local, remote }] of Object.entries(changed)) {
|
|
308
|
-
console.log(
|
|
309
|
-
console.log(
|
|
300
|
+
console.log(chalk.red(`- ${key}=${maskValue(remote)}`));
|
|
301
|
+
console.log(chalk.green(`+ ${key}=${maskValue(local)}`));
|
|
310
302
|
}
|
|
311
303
|
}
|
|
312
304
|
function maskValue(value, showChars = 4) {
|
|
@@ -316,7 +308,7 @@ function maskValue(value, showChars = 4) {
|
|
|
316
308
|
return value.slice(0, showChars) + "****" + value.slice(-showChars);
|
|
317
309
|
}
|
|
318
310
|
function line() {
|
|
319
|
-
console.log(
|
|
311
|
+
console.log(chalk.dim("\u2500".repeat(50)));
|
|
320
312
|
}
|
|
321
313
|
function blank() {
|
|
322
314
|
console.log();
|
|
@@ -324,19 +316,19 @@ function blank() {
|
|
|
324
316
|
function formatRole(role) {
|
|
325
317
|
switch (role) {
|
|
326
318
|
case "admin":
|
|
327
|
-
return
|
|
319
|
+
return chalk.green("Admin");
|
|
328
320
|
case "team_lead":
|
|
329
|
-
return
|
|
321
|
+
return chalk.blue("Team Lead");
|
|
330
322
|
case "member":
|
|
331
|
-
return
|
|
323
|
+
return chalk.yellow("Member");
|
|
332
324
|
default:
|
|
333
|
-
return
|
|
325
|
+
return chalk.dim("Unknown");
|
|
334
326
|
}
|
|
335
327
|
}
|
|
336
328
|
function roleNotice(role) {
|
|
337
329
|
if (role === "member") {
|
|
338
330
|
console.log(
|
|
339
|
-
|
|
331
|
+
chalk.yellow(
|
|
340
332
|
" You have Member access. Write operations will create pending requests for approval."
|
|
341
333
|
)
|
|
342
334
|
);
|
|
@@ -345,19 +337,19 @@ function roleNotice(role) {
|
|
|
345
337
|
function formatProjectRole(role) {
|
|
346
338
|
switch (role) {
|
|
347
339
|
case "manager":
|
|
348
|
-
return
|
|
340
|
+
return chalk.green("Manager");
|
|
349
341
|
case "developer":
|
|
350
|
-
return
|
|
342
|
+
return chalk.blue("Developer");
|
|
351
343
|
case "viewer":
|
|
352
|
-
return
|
|
344
|
+
return chalk.yellow("Viewer");
|
|
353
345
|
default:
|
|
354
|
-
return
|
|
346
|
+
return chalk.dim("-");
|
|
355
347
|
}
|
|
356
348
|
}
|
|
357
349
|
function projectRoleNotice(projectRole) {
|
|
358
350
|
if (projectRole === "viewer") {
|
|
359
351
|
console.log(
|
|
360
|
-
|
|
352
|
+
chalk.yellow(
|
|
361
353
|
" You have Viewer access to this project. You can only view variables you have been explicitly granted access to."
|
|
362
354
|
)
|
|
363
355
|
);
|
|
@@ -365,7 +357,7 @@ function projectRoleNotice(projectRole) {
|
|
|
365
357
|
}
|
|
366
358
|
|
|
367
359
|
// src/lib/errors.ts
|
|
368
|
-
import
|
|
360
|
+
import chalk2 from "chalk";
|
|
369
361
|
var CLIError = class extends Error {
|
|
370
362
|
constructor(message, code, suggestion) {
|
|
371
363
|
super(message);
|
|
@@ -390,17 +382,17 @@ var ErrorCodes = {
|
|
|
390
382
|
};
|
|
391
383
|
function formatError(error2) {
|
|
392
384
|
if (error2 instanceof CLIError) {
|
|
393
|
-
let message =
|
|
385
|
+
let message = chalk2.red(`Error: ${error2.message}`);
|
|
394
386
|
if (error2.suggestion) {
|
|
395
387
|
message += `
|
|
396
|
-
${
|
|
388
|
+
${chalk2.yellow("Suggestion:")} ${error2.suggestion}`;
|
|
397
389
|
}
|
|
398
390
|
return message;
|
|
399
391
|
}
|
|
400
392
|
if (error2 instanceof Error) {
|
|
401
|
-
return
|
|
393
|
+
return chalk2.red(`Error: ${error2.message}`);
|
|
402
394
|
}
|
|
403
|
-
return
|
|
395
|
+
return chalk2.red(`Error: ${String(error2)}`);
|
|
404
396
|
}
|
|
405
397
|
async function handleError(error2) {
|
|
406
398
|
console.error(formatError(error2));
|
|
@@ -457,7 +449,7 @@ function invalidInput(message) {
|
|
|
457
449
|
|
|
458
450
|
// src/lib/auth-flow.ts
|
|
459
451
|
import open from "open";
|
|
460
|
-
import
|
|
452
|
+
import chalk3 from "chalk";
|
|
461
453
|
import { hostname } from "os";
|
|
462
454
|
|
|
463
455
|
// src/lib/api.ts
|
|
@@ -865,12 +857,12 @@ async function performLogin(options) {
|
|
|
865
857
|
}
|
|
866
858
|
spinner.stop();
|
|
867
859
|
console.log();
|
|
868
|
-
console.log(
|
|
860
|
+
console.log(chalk3.bold("Your authentication code:"));
|
|
869
861
|
console.log();
|
|
870
|
-
console.log(
|
|
862
|
+
console.log(chalk3.cyan.bold(` ${initResponse.code}`));
|
|
871
863
|
console.log();
|
|
872
864
|
console.log(`Open this URL to authenticate:`);
|
|
873
|
-
console.log(
|
|
865
|
+
console.log(chalk3.dim(initResponse.url));
|
|
874
866
|
console.log();
|
|
875
867
|
if (options?.browser !== false) {
|
|
876
868
|
info("Opening browser...");
|
|
@@ -912,7 +904,7 @@ async function performLogin(options) {
|
|
|
912
904
|
});
|
|
913
905
|
}
|
|
914
906
|
console.log();
|
|
915
|
-
success(`Logged in as ${
|
|
907
|
+
success(`Logged in as ${chalk3.bold(pollResponse.user?.email)}`);
|
|
916
908
|
return { email: pollResponse.user?.email || "" };
|
|
917
909
|
}
|
|
918
910
|
if (pollResponse.status === "expired" || pollResponse.status === "not_found") {
|
|
@@ -947,7 +939,7 @@ var loginCommand = new Command("login").description("Authenticate with Envpilot"
|
|
|
947
939
|
|
|
948
940
|
// src/commands/init.ts
|
|
949
941
|
import { Command as Command2 } from "commander";
|
|
950
|
-
import
|
|
942
|
+
import chalk4 from "chalk";
|
|
951
943
|
import inquirer from "inquirer";
|
|
952
944
|
|
|
953
945
|
// src/lib/project-config.ts
|
|
@@ -1452,18 +1444,18 @@ async function addProject(existingConfig, options) {
|
|
|
1452
1444
|
console.log();
|
|
1453
1445
|
success(`Added "${selectedProject.name}" to linked projects!`);
|
|
1454
1446
|
console.log(
|
|
1455
|
-
|
|
1447
|
+
chalk4.dim(` ${existingConfig.projects.length + 1} projects now linked`)
|
|
1456
1448
|
);
|
|
1457
1449
|
console.log();
|
|
1458
1450
|
console.log("Next steps:");
|
|
1459
1451
|
console.log(
|
|
1460
|
-
` ${
|
|
1452
|
+
` ${chalk4.cyan("envpilot pull --all")} Pull all projects`
|
|
1461
1453
|
);
|
|
1462
1454
|
console.log(
|
|
1463
|
-
` ${
|
|
1455
|
+
` ${chalk4.cyan(`envpilot pull --project "${selectedProject.name}"`)} Pull this project`
|
|
1464
1456
|
);
|
|
1465
1457
|
console.log(
|
|
1466
|
-
` ${
|
|
1458
|
+
` ${chalk4.cyan("envpilot list linked")} See all linked projects`
|
|
1467
1459
|
);
|
|
1468
1460
|
console.log();
|
|
1469
1461
|
}
|
|
@@ -1492,7 +1484,7 @@ async function selectOrgProjectEnv(options) {
|
|
|
1492
1484
|
selectedOrg = org;
|
|
1493
1485
|
} else if (organizations.length === 1) {
|
|
1494
1486
|
selectedOrg = organizations[0];
|
|
1495
|
-
info(`Using organization: ${
|
|
1487
|
+
info(`Using organization: ${chalk4.bold(selectedOrg.name)}`);
|
|
1496
1488
|
} else {
|
|
1497
1489
|
const { orgId } = await inquirer.prompt([
|
|
1498
1490
|
{
|
|
@@ -1500,7 +1492,7 @@ async function selectOrgProjectEnv(options) {
|
|
|
1500
1492
|
name: "orgId",
|
|
1501
1493
|
message: "Select an organization:",
|
|
1502
1494
|
choices: organizations.map((org) => ({
|
|
1503
|
-
name: `${org.name} ${org.tier === "pro" ?
|
|
1495
|
+
name: `${org.name} ${org.tier === "pro" ? chalk4.green("(Pro)") : chalk4.dim("(Free)")}`,
|
|
1504
1496
|
value: org._id
|
|
1505
1497
|
}))
|
|
1506
1498
|
}
|
|
@@ -1530,7 +1522,7 @@ async function selectOrgProjectEnv(options) {
|
|
|
1530
1522
|
selectedProject = project;
|
|
1531
1523
|
} else if (projects.length === 1) {
|
|
1532
1524
|
selectedProject = projects[0];
|
|
1533
|
-
info(`Using project: ${
|
|
1525
|
+
info(`Using project: ${chalk4.bold(selectedProject.name)}`);
|
|
1534
1526
|
} else {
|
|
1535
1527
|
const { projectId } = await inquirer.prompt([
|
|
1536
1528
|
{
|
|
@@ -1581,29 +1573,29 @@ function warnTrackedFiles() {
|
|
|
1581
1573
|
console.log();
|
|
1582
1574
|
warning("Security risk: .env files are tracked by git!");
|
|
1583
1575
|
for (const file of trackedFiles) {
|
|
1584
|
-
console.log(
|
|
1576
|
+
console.log(chalk4.red(` tracked: ${file}`));
|
|
1585
1577
|
}
|
|
1586
1578
|
console.log();
|
|
1587
1579
|
console.log(
|
|
1588
|
-
|
|
1580
|
+
chalk4.yellow(
|
|
1589
1581
|
" Run the following to untrack them (without deleting the files):"
|
|
1590
1582
|
)
|
|
1591
1583
|
);
|
|
1592
1584
|
for (const file of trackedFiles) {
|
|
1593
|
-
console.log(
|
|
1585
|
+
console.log(chalk4.cyan(` git rm --cached ${file}`));
|
|
1594
1586
|
}
|
|
1595
1587
|
}
|
|
1596
1588
|
}
|
|
1597
1589
|
function printPostInit(selectedOrg, selectedProject) {
|
|
1598
1590
|
console.log();
|
|
1599
|
-
console.log(
|
|
1591
|
+
console.log(chalk4.dim("Configuration saved to .envpilot"));
|
|
1600
1592
|
if (selectedOrg.role) {
|
|
1601
|
-
console.log(
|
|
1593
|
+
console.log(chalk4.dim(` Org role: ${formatRole(selectedOrg.role)}`));
|
|
1602
1594
|
roleNotice(selectedOrg.role);
|
|
1603
1595
|
}
|
|
1604
1596
|
if (selectedProject.projectRole) {
|
|
1605
1597
|
console.log(
|
|
1606
|
-
|
|
1598
|
+
chalk4.dim(
|
|
1607
1599
|
` Project role: ${formatProjectRole(selectedProject.projectRole)}`
|
|
1608
1600
|
)
|
|
1609
1601
|
);
|
|
@@ -1612,17 +1604,17 @@ function printPostInit(selectedOrg, selectedProject) {
|
|
|
1612
1604
|
console.log();
|
|
1613
1605
|
console.log("Next steps:");
|
|
1614
1606
|
console.log(
|
|
1615
|
-
` ${
|
|
1607
|
+
` ${chalk4.cyan("envpilot pull")} Download environment variables`
|
|
1616
1608
|
);
|
|
1617
1609
|
console.log(
|
|
1618
|
-
` ${
|
|
1610
|
+
` ${chalk4.cyan("envpilot push")} Upload local .env to cloud`
|
|
1619
1611
|
);
|
|
1620
1612
|
console.log();
|
|
1621
1613
|
}
|
|
1622
1614
|
|
|
1623
1615
|
// src/commands/pull.ts
|
|
1624
1616
|
import { Command as Command3 } from "commander";
|
|
1625
|
-
import
|
|
1617
|
+
import chalk5 from "chalk";
|
|
1626
1618
|
import inquirer2 from "inquirer";
|
|
1627
1619
|
|
|
1628
1620
|
// src/lib/format-converter.ts
|
|
@@ -2036,7 +2028,7 @@ async function pullAllProjects(options) {
|
|
|
2036
2028
|
const displayName = project.projectName || project.projectId;
|
|
2037
2029
|
console.log();
|
|
2038
2030
|
console.log(
|
|
2039
|
-
|
|
2031
|
+
chalk5.bold(
|
|
2040
2032
|
`Pulling "${displayName}" (${project.environment}) \u2192 ${outputPath}`
|
|
2041
2033
|
)
|
|
2042
2034
|
);
|
|
@@ -2086,7 +2078,7 @@ async function pullProject(project, outputPath, options) {
|
|
|
2086
2078
|
const api = createAPIClient();
|
|
2087
2079
|
let metaProjectRole;
|
|
2088
2080
|
const variables = await withSpinner(
|
|
2089
|
-
`Fetching ${
|
|
2081
|
+
`Fetching ${chalk5.bold(project.environment)} variables...`,
|
|
2090
2082
|
async () => {
|
|
2091
2083
|
const response = await api.get("/api/cli/variables", {
|
|
2092
2084
|
projectId: project.projectId,
|
|
@@ -2115,7 +2107,7 @@ async function pullProject(project, outputPath, options) {
|
|
|
2115
2107
|
return;
|
|
2116
2108
|
}
|
|
2117
2109
|
console.log();
|
|
2118
|
-
console.log(
|
|
2110
|
+
console.log(chalk5.bold("Changes:"));
|
|
2119
2111
|
console.log();
|
|
2120
2112
|
diff(diffResult.added, diffResult.removed, diffResult.changed);
|
|
2121
2113
|
console.log();
|
|
@@ -2165,7 +2157,7 @@ async function pullProject(project, outputPath, options) {
|
|
|
2165
2157
|
const role = getRole();
|
|
2166
2158
|
applyFileProtection(outputPath, role, metaProjectRole);
|
|
2167
2159
|
success(
|
|
2168
|
-
`Downloaded ${variables.length} variables to ${
|
|
2160
|
+
`Downloaded ${variables.length} variables to ${chalk5.bold(outputPath)}`
|
|
2169
2161
|
);
|
|
2170
2162
|
if (metaProjectRole === "viewer") {
|
|
2171
2163
|
info(
|
|
@@ -2179,12 +2171,12 @@ async function pullProject(project, outputPath, options) {
|
|
|
2179
2171
|
);
|
|
2180
2172
|
}
|
|
2181
2173
|
console.log();
|
|
2182
|
-
console.log(
|
|
2174
|
+
console.log(chalk5.dim(` Added: ${Object.keys(diffResult.added).length}`));
|
|
2183
2175
|
console.log(
|
|
2184
|
-
|
|
2176
|
+
chalk5.dim(` Changed: ${Object.keys(diffResult.changed).length}`)
|
|
2185
2177
|
);
|
|
2186
2178
|
console.log(
|
|
2187
|
-
|
|
2179
|
+
chalk5.dim(` Removed: ${Object.keys(diffResult.removed).length}`)
|
|
2188
2180
|
);
|
|
2189
2181
|
}
|
|
2190
2182
|
function checkTrackedFiles() {
|
|
@@ -2193,16 +2185,16 @@ function checkTrackedFiles() {
|
|
|
2193
2185
|
error("Security risk: .env files are tracked by git!");
|
|
2194
2186
|
console.log();
|
|
2195
2187
|
for (const file of trackedFiles) {
|
|
2196
|
-
console.log(
|
|
2188
|
+
console.log(chalk5.red(` tracked: ${file}`));
|
|
2197
2189
|
}
|
|
2198
2190
|
console.log();
|
|
2199
2191
|
console.log(
|
|
2200
|
-
|
|
2192
|
+
chalk5.yellow(
|
|
2201
2193
|
" Run the following to untrack them (without deleting the files):"
|
|
2202
2194
|
)
|
|
2203
2195
|
);
|
|
2204
2196
|
for (const file of trackedFiles) {
|
|
2205
|
-
console.log(
|
|
2197
|
+
console.log(chalk5.cyan(` git rm --cached ${file}`));
|
|
2206
2198
|
}
|
|
2207
2199
|
console.log();
|
|
2208
2200
|
process.exit(1);
|
|
@@ -2211,7 +2203,7 @@ function checkTrackedFiles() {
|
|
|
2211
2203
|
|
|
2212
2204
|
// src/commands/push.ts
|
|
2213
2205
|
import { Command as Command4 } from "commander";
|
|
2214
|
-
import
|
|
2206
|
+
import chalk6 from "chalk";
|
|
2215
2207
|
import inquirer3 from "inquirer";
|
|
2216
2208
|
|
|
2217
2209
|
// src/lib/validators.ts
|
|
@@ -2299,16 +2291,16 @@ var pushCommand = new Command4("push").description("Upload local .env file to cl
|
|
|
2299
2291
|
error("Security risk: .env files are tracked by git!");
|
|
2300
2292
|
console.log();
|
|
2301
2293
|
for (const file of trackedFiles) {
|
|
2302
|
-
console.log(
|
|
2294
|
+
console.log(chalk6.red(` tracked: ${file}`));
|
|
2303
2295
|
}
|
|
2304
2296
|
console.log();
|
|
2305
2297
|
console.log(
|
|
2306
|
-
|
|
2298
|
+
chalk6.yellow(
|
|
2307
2299
|
" Run the following to untrack them (without deleting the files):"
|
|
2308
2300
|
)
|
|
2309
2301
|
);
|
|
2310
2302
|
for (const file of trackedFiles) {
|
|
2311
|
-
console.log(
|
|
2303
|
+
console.log(chalk6.cyan(` git rm --cached ${file}`));
|
|
2312
2304
|
}
|
|
2313
2305
|
console.log();
|
|
2314
2306
|
process.exit(1);
|
|
@@ -2375,7 +2367,7 @@ var pushCommand = new Command4("push").description("Upload local .env file to cl
|
|
|
2375
2367
|
if (invalid.length > 0) {
|
|
2376
2368
|
warning("Some variables have invalid keys and will be skipped:");
|
|
2377
2369
|
for (const { key, error: err } of invalid) {
|
|
2378
|
-
console.log(
|
|
2370
|
+
console.log(chalk6.red(` ${key}: ${err}`));
|
|
2379
2371
|
}
|
|
2380
2372
|
console.log();
|
|
2381
2373
|
}
|
|
@@ -2408,14 +2400,14 @@ var pushCommand = new Command4("push").description("Upload local .env file to cl
|
|
|
2408
2400
|
return;
|
|
2409
2401
|
}
|
|
2410
2402
|
console.log();
|
|
2411
|
-
console.log(
|
|
2403
|
+
console.log(chalk6.bold("Changes to push:"));
|
|
2412
2404
|
console.log();
|
|
2413
2405
|
const removedToShow = mode === "replace" ? diffResult.removed : {};
|
|
2414
2406
|
diff(diffResult.added, removedToShow, diffResult.changed);
|
|
2415
2407
|
if (mode === "merge" && Object.keys(diffResult.removed).length > 0) {
|
|
2416
2408
|
console.log();
|
|
2417
2409
|
console.log(
|
|
2418
|
-
|
|
2410
|
+
chalk6.dim(
|
|
2419
2411
|
`Note: ${Object.keys(diffResult.removed).length} remote variables not in local file will be preserved (use --replace to remove them)`
|
|
2420
2412
|
)
|
|
2421
2413
|
);
|
|
@@ -2452,7 +2444,7 @@ var pushCommand = new Command4("push").description("Upload local .env file to cl
|
|
|
2452
2444
|
}
|
|
2453
2445
|
}
|
|
2454
2446
|
const result = await withSpinner(
|
|
2455
|
-
`Pushing variables to ${
|
|
2447
|
+
`Pushing variables to ${chalk6.bold(environment)}...`,
|
|
2456
2448
|
async () => {
|
|
2457
2449
|
const response = await api.post("/api/cli/variables/bulk", {
|
|
2458
2450
|
projectId,
|
|
@@ -2469,28 +2461,28 @@ var pushCommand = new Command4("push").description("Upload local .env file to cl
|
|
|
2469
2461
|
);
|
|
2470
2462
|
if (result?.requested && result.requested > 0) {
|
|
2471
2463
|
success(
|
|
2472
|
-
`Created ${result.requested} pending request(s) for ${
|
|
2464
|
+
`Created ${result.requested} pending request(s) for ${chalk6.bold(environment)}`
|
|
2473
2465
|
);
|
|
2474
2466
|
console.log();
|
|
2475
2467
|
console.log(
|
|
2476
|
-
|
|
2468
|
+
chalk6.yellow(
|
|
2477
2469
|
" These changes require approval from an Admin or Team Lead."
|
|
2478
2470
|
)
|
|
2479
2471
|
);
|
|
2480
2472
|
console.log();
|
|
2481
|
-
console.log(
|
|
2473
|
+
console.log(chalk6.dim(` Requested: ${result.requested}`));
|
|
2482
2474
|
if (result?.skipped && result.skipped > 0) {
|
|
2483
|
-
console.log(
|
|
2475
|
+
console.log(chalk6.dim(` Skipped: ${result.skipped}`));
|
|
2484
2476
|
}
|
|
2485
2477
|
} else {
|
|
2486
2478
|
success(
|
|
2487
|
-
`Pushed ${result?.total || Object.keys(valid).length} variables to ${
|
|
2479
|
+
`Pushed ${result?.total || Object.keys(valid).length} variables to ${chalk6.bold(environment)}`
|
|
2488
2480
|
);
|
|
2489
2481
|
console.log();
|
|
2490
|
-
console.log(
|
|
2491
|
-
console.log(
|
|
2482
|
+
console.log(chalk6.dim(` Created: ${result?.created || 0}`));
|
|
2483
|
+
console.log(chalk6.dim(` Updated: ${result?.updated || 0}`));
|
|
2492
2484
|
if (mode === "replace") {
|
|
2493
|
-
console.log(
|
|
2485
|
+
console.log(chalk6.dim(` Deleted: ${result?.deleted || 0}`));
|
|
2494
2486
|
}
|
|
2495
2487
|
}
|
|
2496
2488
|
} catch (err) {
|
|
@@ -2500,7 +2492,7 @@ var pushCommand = new Command4("push").description("Upload local .env file to cl
|
|
|
2500
2492
|
|
|
2501
2493
|
// src/commands/switch.ts
|
|
2502
2494
|
import { Command as Command5 } from "commander";
|
|
2503
|
-
import
|
|
2495
|
+
import chalk7 from "chalk";
|
|
2504
2496
|
import inquirer4 from "inquirer";
|
|
2505
2497
|
var switchCommand = new Command5("switch").description("Switch project, environment, or active linked project").argument("[target]", "project slug or environment name").option("-o, --organization <id>", "Switch organization").option("-p, --project <id>", "Switch project").option(
|
|
2506
2498
|
"-e, --env <environment>",
|
|
@@ -2528,7 +2520,7 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2528
2520
|
console.log();
|
|
2529
2521
|
console.log("Linked projects:");
|
|
2530
2522
|
for (const p of configV2.projects) {
|
|
2531
|
-
const mark = p.projectId === configV2.activeProjectId ?
|
|
2523
|
+
const mark = p.projectId === configV2.activeProjectId ? chalk7.green(" *") : "";
|
|
2532
2524
|
console.log(
|
|
2533
2525
|
` ${p.projectName || p.projectId} (${p.environment})${mark}`
|
|
2534
2526
|
);
|
|
@@ -2540,7 +2532,7 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2540
2532
|
setActiveProjectId(target2.projectId);
|
|
2541
2533
|
setActiveOrganizationId(target2.organizationId);
|
|
2542
2534
|
success(
|
|
2543
|
-
`Active project: ${
|
|
2535
|
+
`Active project: ${chalk7.bold(target2.projectName || target2.projectId)}`
|
|
2544
2536
|
);
|
|
2545
2537
|
return;
|
|
2546
2538
|
}
|
|
@@ -2551,7 +2543,7 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2551
2543
|
process.exit(1);
|
|
2552
2544
|
}
|
|
2553
2545
|
updateProjectConfig({ environment });
|
|
2554
|
-
success(`Switched to ${
|
|
2546
|
+
success(`Switched to ${chalk7.bold(environment)} environment`);
|
|
2555
2547
|
return;
|
|
2556
2548
|
}
|
|
2557
2549
|
if (options.organization) {
|
|
@@ -2576,9 +2568,9 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2576
2568
|
if (projectConfig) {
|
|
2577
2569
|
updateProjectConfig({ organizationId: org._id });
|
|
2578
2570
|
}
|
|
2579
|
-
success(`Switched to organization: ${
|
|
2571
|
+
success(`Switched to organization: ${chalk7.bold(org.name)}`);
|
|
2580
2572
|
if (org.role) {
|
|
2581
|
-
console.log(
|
|
2573
|
+
console.log(chalk7.dim(` Role: ${formatRole(org.role)}`));
|
|
2582
2574
|
roleNotice(org.role);
|
|
2583
2575
|
}
|
|
2584
2576
|
return;
|
|
@@ -2599,7 +2591,7 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2599
2591
|
setActiveProjectId(linked.projectId);
|
|
2600
2592
|
setActiveOrganizationId(linked.organizationId);
|
|
2601
2593
|
success(
|
|
2602
|
-
`Switched to project: ${
|
|
2594
|
+
`Switched to project: ${chalk7.bold(linked.projectName || linked.projectId)}`
|
|
2603
2595
|
);
|
|
2604
2596
|
return;
|
|
2605
2597
|
}
|
|
@@ -2629,7 +2621,7 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2629
2621
|
name: "orgId",
|
|
2630
2622
|
message: "Select an organization:",
|
|
2631
2623
|
choices: organizations.map((org) => ({
|
|
2632
|
-
name: `${org.name} ${org.tier === "pro" ?
|
|
2624
|
+
name: `${org.name} ${org.tier === "pro" ? chalk7.green("(Pro)") : chalk7.dim("(Free)")}`,
|
|
2633
2625
|
value: org._id
|
|
2634
2626
|
}))
|
|
2635
2627
|
}
|
|
@@ -2665,10 +2657,10 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2665
2657
|
organizationId,
|
|
2666
2658
|
environment
|
|
2667
2659
|
});
|
|
2668
|
-
success(`Switched to project: ${
|
|
2660
|
+
success(`Switched to project: ${chalk7.bold(project.name)}`);
|
|
2669
2661
|
if (project.projectRole) {
|
|
2670
2662
|
console.log(
|
|
2671
|
-
|
|
2663
|
+
chalk7.dim(
|
|
2672
2664
|
` Project role: ${formatProjectRole(project.projectRole)}`
|
|
2673
2665
|
)
|
|
2674
2666
|
);
|
|
@@ -2708,7 +2700,7 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2708
2700
|
choices: configV2.projects.map((p) => {
|
|
2709
2701
|
const isActive = p.projectId === configV2.activeProjectId;
|
|
2710
2702
|
return {
|
|
2711
|
-
name: `${p.projectName || p.projectId} (${p.environment})${isActive ?
|
|
2703
|
+
name: `${p.projectName || p.projectId} (${p.environment})${isActive ? chalk7.green(" *current") : ""}`,
|
|
2712
2704
|
value: p.projectId
|
|
2713
2705
|
};
|
|
2714
2706
|
}),
|
|
@@ -2723,7 +2715,7 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2723
2715
|
setActiveProjectId(projectId);
|
|
2724
2716
|
setActiveOrganizationId(selected.organizationId);
|
|
2725
2717
|
success(
|
|
2726
|
-
`Active project: ${
|
|
2718
|
+
`Active project: ${chalk7.bold(selected.projectName || selected.projectId)}`
|
|
2727
2719
|
);
|
|
2728
2720
|
return;
|
|
2729
2721
|
}
|
|
@@ -2746,7 +2738,7 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2746
2738
|
}
|
|
2747
2739
|
]);
|
|
2748
2740
|
updateProjectConfig({ environment });
|
|
2749
|
-
success(`Switched to ${
|
|
2741
|
+
success(`Switched to ${chalk7.bold(environment)} environment`);
|
|
2750
2742
|
return;
|
|
2751
2743
|
}
|
|
2752
2744
|
if (switchType === "organization" || switchType === "project") {
|
|
@@ -2767,7 +2759,7 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2767
2759
|
name: "orgId",
|
|
2768
2760
|
message: "Select an organization:",
|
|
2769
2761
|
choices: organizations.map((org) => ({
|
|
2770
|
-
name: `${org.name} ${org.tier === "pro" ?
|
|
2762
|
+
name: `${org.name} ${org.tier === "pro" ? chalk7.green("(Pro)") : chalk7.dim("(Free)")}`,
|
|
2771
2763
|
value: org._id
|
|
2772
2764
|
})),
|
|
2773
2765
|
default: projectConfig?.organizationId
|
|
@@ -2779,9 +2771,9 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2779
2771
|
if (org.role) {
|
|
2780
2772
|
setRole(org.role);
|
|
2781
2773
|
}
|
|
2782
|
-
success(`Switched to organization: ${
|
|
2774
|
+
success(`Switched to organization: ${chalk7.bold(org.name)}`);
|
|
2783
2775
|
if (org.role) {
|
|
2784
|
-
console.log(
|
|
2776
|
+
console.log(chalk7.dim(` Role: ${formatRole(org.role)}`));
|
|
2785
2777
|
roleNotice(org.role);
|
|
2786
2778
|
}
|
|
2787
2779
|
return;
|
|
@@ -2822,10 +2814,10 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2822
2814
|
organizationId: orgId,
|
|
2823
2815
|
environment
|
|
2824
2816
|
});
|
|
2825
|
-
success(`Switched to project: ${
|
|
2817
|
+
success(`Switched to project: ${chalk7.bold(project.name)}`);
|
|
2826
2818
|
if (project.projectRole) {
|
|
2827
2819
|
console.log(
|
|
2828
|
-
|
|
2820
|
+
chalk7.dim(
|
|
2829
2821
|
` Project role: ${formatProjectRole(project.projectRole)}`
|
|
2830
2822
|
)
|
|
2831
2823
|
);
|
|
@@ -2840,7 +2832,7 @@ var switchCommand = new Command5("switch").description("Switch project, environm
|
|
|
2840
2832
|
|
|
2841
2833
|
// src/commands/list.ts
|
|
2842
2834
|
import { Command as Command6 } from "commander";
|
|
2843
|
-
import
|
|
2835
|
+
import chalk8 from "chalk";
|
|
2844
2836
|
var listCommand = new Command6("list").description("List resources").argument(
|
|
2845
2837
|
"[resource]",
|
|
2846
2838
|
"Resource type: projects, organizations, variables, linked",
|
|
@@ -2895,19 +2887,19 @@ function listLinked() {
|
|
|
2895
2887
|
console.log();
|
|
2896
2888
|
for (const project of configV2.projects) {
|
|
2897
2889
|
const isActive = project.projectId === configV2.activeProjectId;
|
|
2898
|
-
const marker = isActive ?
|
|
2890
|
+
const marker = isActive ? chalk8.green("*") : " ";
|
|
2899
2891
|
const envFile = getEnvPathForEnvironment(project.environment);
|
|
2900
2892
|
console.log(
|
|
2901
|
-
` ${marker} ${
|
|
2893
|
+
` ${marker} ${chalk8.bold(project.projectName || project.projectId)} ${chalk8.dim(`(${project.organizationName || project.organizationId})`)}`
|
|
2902
2894
|
);
|
|
2903
|
-
console.log(` ${project.environment} ${
|
|
2895
|
+
console.log(` ${project.environment} ${chalk8.dim("\u2192")} ${envFile}`);
|
|
2904
2896
|
console.log();
|
|
2905
2897
|
}
|
|
2906
2898
|
if (configV2.projects.length > 1) {
|
|
2907
|
-
console.log(
|
|
2899
|
+
console.log(chalk8.dim(" (* = active project)"));
|
|
2908
2900
|
console.log();
|
|
2909
2901
|
console.log(
|
|
2910
|
-
|
|
2902
|
+
chalk8.dim(
|
|
2911
2903
|
' Use `envpilot switch --active "<name>"` to change the active project'
|
|
2912
2904
|
)
|
|
2913
2905
|
);
|
|
@@ -2935,7 +2927,7 @@ async function listOrganizations(api, options) {
|
|
|
2935
2927
|
organizations.map((org) => ({
|
|
2936
2928
|
name: org.name,
|
|
2937
2929
|
slug: org.slug,
|
|
2938
|
-
tier: org.tier === "pro" ?
|
|
2930
|
+
tier: org.tier === "pro" ? chalk8.green("Pro") : chalk8.dim("Free"),
|
|
2939
2931
|
role: org.role
|
|
2940
2932
|
})),
|
|
2941
2933
|
[
|
|
@@ -2993,9 +2985,9 @@ async function listProjects(api, projectConfig, options) {
|
|
|
2993
2985
|
icon: project.icon || "\u{1F4E6}",
|
|
2994
2986
|
name: project.name,
|
|
2995
2987
|
slug: project.slug,
|
|
2996
|
-
description: project.description ||
|
|
2988
|
+
description: project.description || chalk8.dim("-"),
|
|
2997
2989
|
role: project.userRole === "admin" ? formatRole("admin") : formatProjectRole(project.projectRole),
|
|
2998
|
-
active: projectConfig?.projectId === project._id ?
|
|
2990
|
+
active: projectConfig?.projectId === project._id ? chalk8.green("\u2713") : ""
|
|
2999
2991
|
})),
|
|
3000
2992
|
[
|
|
3001
2993
|
{ key: "icon", header: "" },
|
|
@@ -3009,7 +3001,7 @@ async function listProjects(api, projectConfig, options) {
|
|
|
3009
3001
|
const role = getRole();
|
|
3010
3002
|
if (role) {
|
|
3011
3003
|
console.log();
|
|
3012
|
-
console.log(
|
|
3004
|
+
console.log(chalk8.dim(`Your org role: ${formatRole(role)}`));
|
|
3013
3005
|
}
|
|
3014
3006
|
}
|
|
3015
3007
|
async function listVariables(api, projectConfig, options) {
|
|
@@ -3056,8 +3048,8 @@ async function listVariables(api, projectConfig, options) {
|
|
|
3056
3048
|
filtered.map((variable) => ({
|
|
3057
3049
|
key: variable.key,
|
|
3058
3050
|
value: options.showValues ? variable.value : maskValue(variable.value),
|
|
3059
|
-
sensitive: variable.isSensitive ?
|
|
3060
|
-
tags: hasTags ? variable.tags?.map((t) => t.name).join(", ") ||
|
|
3051
|
+
sensitive: variable.isSensitive ? chalk8.yellow("\u25CF") : "",
|
|
3052
|
+
tags: hasTags ? variable.tags?.map((t) => t.name).join(", ") || chalk8.dim("-") : "",
|
|
3061
3053
|
version: `v${variable.version}`
|
|
3062
3054
|
})),
|
|
3063
3055
|
[
|
|
@@ -3069,29 +3061,29 @@ async function listVariables(api, projectConfig, options) {
|
|
|
3069
3061
|
]
|
|
3070
3062
|
);
|
|
3071
3063
|
console.log();
|
|
3072
|
-
console.log(
|
|
3064
|
+
console.log(chalk8.dim(`Total: ${filtered.length} variables`));
|
|
3073
3065
|
const role = getRole();
|
|
3074
3066
|
if (role) {
|
|
3075
|
-
console.log(
|
|
3067
|
+
console.log(chalk8.dim(`Your org role: ${formatRole(role)}`));
|
|
3076
3068
|
}
|
|
3077
3069
|
if (metaProjectRole) {
|
|
3078
3070
|
console.log(
|
|
3079
|
-
|
|
3071
|
+
chalk8.dim(`Your project role: ${formatProjectRole(metaProjectRole)}`)
|
|
3080
3072
|
);
|
|
3081
3073
|
}
|
|
3082
3074
|
if (role === "member" || metaProjectRole === "viewer") {
|
|
3083
3075
|
console.log(
|
|
3084
|
-
|
|
3076
|
+
chalk8.dim("You may only see variables you have been granted access to.")
|
|
3085
3077
|
);
|
|
3086
3078
|
}
|
|
3087
3079
|
if (!options.showValues) {
|
|
3088
|
-
console.log(
|
|
3080
|
+
console.log(chalk8.dim("Use --show-values to see actual values"));
|
|
3089
3081
|
}
|
|
3090
3082
|
}
|
|
3091
3083
|
|
|
3092
3084
|
// src/commands/config.ts
|
|
3093
3085
|
import { Command as Command7 } from "commander";
|
|
3094
|
-
import
|
|
3086
|
+
import chalk9 from "chalk";
|
|
3095
3087
|
var configCommand = new Command7("config").description("Manage CLI configuration").argument("[action]", "Action: get, set, list, path, reset").argument("[key]", "Config key (for get/set)").argument("[value]", "Config value (for set)").action(async (action, key, value) => {
|
|
3096
3088
|
try {
|
|
3097
3089
|
switch (action) {
|
|
@@ -3146,14 +3138,14 @@ async function handleGet(key) {
|
|
|
3146
3138
|
if (config2.user) {
|
|
3147
3139
|
console.log(JSON.stringify(config2.user, null, 2));
|
|
3148
3140
|
} else {
|
|
3149
|
-
console.log(
|
|
3141
|
+
console.log(chalk9.dim("(not set)"));
|
|
3150
3142
|
}
|
|
3151
3143
|
break;
|
|
3152
3144
|
case "activeProjectId":
|
|
3153
|
-
console.log(config2.activeProjectId ||
|
|
3145
|
+
console.log(config2.activeProjectId || chalk9.dim("(not set)"));
|
|
3154
3146
|
break;
|
|
3155
3147
|
case "activeOrganizationId":
|
|
3156
|
-
console.log(config2.activeOrganizationId ||
|
|
3148
|
+
console.log(config2.activeOrganizationId || chalk9.dim("(not set)"));
|
|
3157
3149
|
break;
|
|
3158
3150
|
default:
|
|
3159
3151
|
error(`Unknown key: ${key}`);
|
|
@@ -3196,7 +3188,7 @@ async function handleList() {
|
|
|
3196
3188
|
console.log();
|
|
3197
3189
|
keyValue([
|
|
3198
3190
|
["API URL", config2.apiUrl],
|
|
3199
|
-
["Authenticated", isAuthenticated() ?
|
|
3191
|
+
["Authenticated", isAuthenticated() ? chalk9.green("Yes") : chalk9.red("No")],
|
|
3200
3192
|
["User", config2.user?.email],
|
|
3201
3193
|
["Active Organization", config2.activeOrganizationId],
|
|
3202
3194
|
["Active Project", config2.activeProjectId]
|
|
@@ -3265,7 +3257,7 @@ var logoutCommand = new Command8("logout").description("Log out from Envpilot").
|
|
|
3265
3257
|
|
|
3266
3258
|
// src/commands/unlink.ts
|
|
3267
3259
|
import { Command as Command9 } from "commander";
|
|
3268
|
-
import
|
|
3260
|
+
import chalk10 from "chalk";
|
|
3269
3261
|
import inquirer5 from "inquirer";
|
|
3270
3262
|
var unlinkCommand = new Command9("unlink").description("Remove a linked project from this directory").argument("[project]", "Project name or ID to unlink").option("--force", "Skip confirmation").action(async (projectArg, options) => {
|
|
3271
3263
|
try {
|
|
@@ -3300,7 +3292,7 @@ var unlinkCommand = new Command9("unlink").description("Remove a linked project
|
|
|
3300
3292
|
choices: config2.projects.map((p) => {
|
|
3301
3293
|
const isActive = p.projectId === config2.activeProjectId;
|
|
3302
3294
|
return {
|
|
3303
|
-
name: `${p.projectName || p.projectId} (${p.organizationName || p.organizationId})${isActive ?
|
|
3295
|
+
name: `${p.projectName || p.projectId} (${p.organizationName || p.organizationId})${isActive ? chalk10.green(" *active") : ""}`,
|
|
3304
3296
|
value: p.projectId
|
|
3305
3297
|
};
|
|
3306
3298
|
})
|
|
@@ -3343,7 +3335,7 @@ var unlinkCommand = new Command9("unlink").description("Remove a linked project
|
|
|
3343
3335
|
);
|
|
3344
3336
|
}
|
|
3345
3337
|
console.log(
|
|
3346
|
-
|
|
3338
|
+
chalk10.dim(
|
|
3347
3339
|
` ${updated.projects.length} project${updated.projects.length !== 1 ? "s" : ""} remaining`
|
|
3348
3340
|
)
|
|
3349
3341
|
);
|
|
@@ -3355,7 +3347,7 @@ var unlinkCommand = new Command9("unlink").description("Remove a linked project
|
|
|
3355
3347
|
|
|
3356
3348
|
// src/commands/sync.ts
|
|
3357
3349
|
import { Command as Command10 } from "commander";
|
|
3358
|
-
import
|
|
3350
|
+
import chalk11 from "chalk";
|
|
3359
3351
|
|
|
3360
3352
|
// src/lib/commit-guard.ts
|
|
3361
3353
|
import {
|
|
@@ -3533,7 +3525,7 @@ var syncCommand = new Command10("sync").description(
|
|
|
3533
3525
|
projectName = active.projectName;
|
|
3534
3526
|
organizationName = active.organizationName;
|
|
3535
3527
|
info(
|
|
3536
|
-
`Using project ${
|
|
3528
|
+
`Using project ${chalk11.bold(projectName || projectId)} (${environment})`
|
|
3537
3529
|
);
|
|
3538
3530
|
} else {
|
|
3539
3531
|
const selection = await selectOrgProjectEnv(options);
|
|
@@ -3587,7 +3579,7 @@ var syncCommand = new Command10("sync").description(
|
|
|
3587
3579
|
console.log();
|
|
3588
3580
|
let metaProjectRole;
|
|
3589
3581
|
const variables = await withSpinner(
|
|
3590
|
-
`Fetching ${
|
|
3582
|
+
`Fetching ${chalk11.bold(environment)} variables...`,
|
|
3591
3583
|
async () => {
|
|
3592
3584
|
const api = createAPIClient();
|
|
3593
3585
|
const response = await api.get("/api/cli/variables", {
|
|
@@ -3613,12 +3605,12 @@ var syncCommand = new Command10("sync").description(
|
|
|
3613
3605
|
const diffResult = diffEnvVars(remoteVars, localVars);
|
|
3614
3606
|
const hasChanges = Object.keys(diffResult.added).length > 0 || Object.keys(diffResult.removed).length > 0 || Object.keys(diffResult.changed).length > 0;
|
|
3615
3607
|
if (!hasChanges) {
|
|
3616
|
-
success(`${
|
|
3608
|
+
success(`${chalk11.bold(outputPath)} is up to date.`);
|
|
3617
3609
|
console.log();
|
|
3618
3610
|
return;
|
|
3619
3611
|
}
|
|
3620
3612
|
console.log();
|
|
3621
|
-
console.log(
|
|
3613
|
+
console.log(chalk11.bold("Changes:"));
|
|
3622
3614
|
console.log();
|
|
3623
3615
|
diff(diffResult.added, diffResult.removed, diffResult.changed);
|
|
3624
3616
|
console.log();
|
|
@@ -3639,7 +3631,7 @@ var syncCommand = new Command10("sync").description(
|
|
|
3639
3631
|
const role = getRole();
|
|
3640
3632
|
applyFileProtection(outputPath, role, metaProjectRole);
|
|
3641
3633
|
success(
|
|
3642
|
-
`Synced ${variables.length} variables to ${
|
|
3634
|
+
`Synced ${variables.length} variables to ${chalk11.bold(outputPath)}`
|
|
3643
3635
|
);
|
|
3644
3636
|
const isProtected = role !== "admin" && role !== "team_lead" && metaProjectRole !== "manager";
|
|
3645
3637
|
if (isProtected) {
|
|
@@ -3649,13 +3641,13 @@ var syncCommand = new Command10("sync").description(
|
|
|
3649
3641
|
}
|
|
3650
3642
|
console.log();
|
|
3651
3643
|
console.log(
|
|
3652
|
-
|
|
3644
|
+
chalk11.dim(` Added: ${Object.keys(diffResult.added).length}`)
|
|
3653
3645
|
);
|
|
3654
3646
|
console.log(
|
|
3655
|
-
|
|
3647
|
+
chalk11.dim(` Changed: ${Object.keys(diffResult.changed).length}`)
|
|
3656
3648
|
);
|
|
3657
3649
|
console.log(
|
|
3658
|
-
|
|
3650
|
+
chalk11.dim(` Removed: ${Object.keys(diffResult.removed).length}`)
|
|
3659
3651
|
);
|
|
3660
3652
|
console.log();
|
|
3661
3653
|
} catch (err) {
|
|
@@ -3665,17 +3657,17 @@ var syncCommand = new Command10("sync").description(
|
|
|
3665
3657
|
|
|
3666
3658
|
// src/commands/usage.ts
|
|
3667
3659
|
import { Command as Command11 } from "commander";
|
|
3668
|
-
import
|
|
3660
|
+
import chalk12 from "chalk";
|
|
3669
3661
|
function formatUsage(current, limit) {
|
|
3670
3662
|
const limitStr = limit === null ? "unlimited" : String(limit);
|
|
3671
3663
|
const ratio = `${current}/${limitStr}`;
|
|
3672
|
-
if (limit === null) return
|
|
3673
|
-
if (current >= limit) return
|
|
3674
|
-
if (current >= limit * 0.8) return
|
|
3675
|
-
return
|
|
3664
|
+
if (limit === null) return chalk12.green(ratio);
|
|
3665
|
+
if (current >= limit) return chalk12.red(ratio);
|
|
3666
|
+
if (current >= limit * 0.8) return chalk12.yellow(ratio);
|
|
3667
|
+
return chalk12.green(ratio);
|
|
3676
3668
|
}
|
|
3677
3669
|
function featureStatus(enabled) {
|
|
3678
|
-
return enabled ?
|
|
3670
|
+
return enabled ? chalk12.green("Enabled") : chalk12.dim("Disabled (Pro)");
|
|
3679
3671
|
}
|
|
3680
3672
|
var usageCommand = new Command11("usage").description("Show plan usage and limits for the active organization").option("-o, --organization <id>", "Organization ID").option("--json", "Output as JSON").action(async (options) => {
|
|
3681
3673
|
try {
|
|
@@ -3720,7 +3712,7 @@ var usageCommand = new Command11("usage").description("Show plan usage and limit
|
|
|
3720
3712
|
console.log(JSON.stringify(usage, null, 2));
|
|
3721
3713
|
return;
|
|
3722
3714
|
}
|
|
3723
|
-
const tierLabel = usage.tier === "pro" ?
|
|
3715
|
+
const tierLabel = usage.tier === "pro" ? chalk12.green("Pro") : chalk12.white("Free");
|
|
3724
3716
|
header(`Plan: ${tierLabel}`);
|
|
3725
3717
|
blank();
|
|
3726
3718
|
if (!usage.enforcementEnabled) {
|
|
@@ -3774,7 +3766,7 @@ var usageCommand = new Command11("usage").description("Show plan usage and limit
|
|
|
3774
3766
|
|
|
3775
3767
|
// src/commands/whoami.ts
|
|
3776
3768
|
import { Command as Command12 } from "commander";
|
|
3777
|
-
import
|
|
3769
|
+
import chalk13 from "chalk";
|
|
3778
3770
|
var whoamiCommand = new Command12("whoami").description("Show the current authenticated user and active CLI context").action(async () => {
|
|
3779
3771
|
try {
|
|
3780
3772
|
if (!isAuthenticated()) {
|
|
@@ -3800,7 +3792,7 @@ var whoamiCommand = new Command12("whoami").description("Show the current authen
|
|
|
3800
3792
|
["Environment", activeProject?.environment]
|
|
3801
3793
|
]);
|
|
3802
3794
|
blank();
|
|
3803
|
-
console.log(
|
|
3795
|
+
console.log(chalk13.dim("Token verified against the CLI auth endpoint."));
|
|
3804
3796
|
} catch (err) {
|
|
3805
3797
|
await handleError(err);
|
|
3806
3798
|
}
|
|
@@ -3809,7 +3801,7 @@ var whoamiCommand = new Command12("whoami").description("Show the current authen
|
|
|
3809
3801
|
// src/commands/run.ts
|
|
3810
3802
|
import { Command as Command13 } from "commander";
|
|
3811
3803
|
import { spawn as spawn2 } from "child_process";
|
|
3812
|
-
import
|
|
3804
|
+
import chalk14 from "chalk";
|
|
3813
3805
|
|
|
3814
3806
|
// src/lib/variables-cache.ts
|
|
3815
3807
|
import { createHash } from "crypto";
|
|
@@ -4057,9 +4049,9 @@ var runCommand = new Command13("run").description(
|
|
|
4057
4049
|
}
|
|
4058
4050
|
if (!options.quiet) {
|
|
4059
4051
|
const injectedCount = Object.keys(secrets).length;
|
|
4060
|
-
const cacheTag = cacheHit ?
|
|
4052
|
+
const cacheTag = cacheHit ? chalk14.dim(` \u26A1 cache (${cacheAge})`) : "";
|
|
4061
4053
|
info(
|
|
4062
|
-
`Injected ${
|
|
4054
|
+
`Injected ${chalk14.bold(injectedCount)} ${injectedCount === 1 ? "variable" : "variables"} from ${chalk14.bold(`${project.projectName || project.projectId}/${environment}`)}${cacheTag}`
|
|
4063
4055
|
);
|
|
4064
4056
|
if (overridden.length > 0) {
|
|
4065
4057
|
warning(
|
|
@@ -4075,7 +4067,7 @@ var runCommand = new Command13("run").description(
|
|
|
4075
4067
|
}
|
|
4076
4068
|
});
|
|
4077
4069
|
async function doFetch(project, environment, organizationId, quiet, labelPrefix = "Loading") {
|
|
4078
|
-
const label = `${labelPrefix} ${
|
|
4070
|
+
const label = `${labelPrefix} ${chalk14.bold(environment)} secrets for ${chalk14.bold(project.projectName || project.projectId)}...`;
|
|
4079
4071
|
const api = createAPIClient();
|
|
4080
4072
|
const { variables, decryptionFailures } = quiet ? await api.listVariables(project.projectId, environment, organizationId) : await withSpinner(
|
|
4081
4073
|
label,
|
|
@@ -4084,7 +4076,7 @@ async function doFetch(project, environment, organizationId, quiet, labelPrefix
|
|
|
4084
4076
|
if (decryptionFailures.length > 0) {
|
|
4085
4077
|
for (const key of decryptionFailures) {
|
|
4086
4078
|
warning(
|
|
4087
|
-
`Could not decrypt ${
|
|
4079
|
+
`Could not decrypt ${chalk14.bold(key)} \u2014 skipped (vault error, check server logs)`
|
|
4088
4080
|
);
|
|
4089
4081
|
}
|
|
4090
4082
|
}
|
|
@@ -4094,18 +4086,18 @@ function printInjectionPreview(secrets, project, environment) {
|
|
|
4094
4086
|
const keys = Object.keys(secrets).sort();
|
|
4095
4087
|
console.log();
|
|
4096
4088
|
console.log(
|
|
4097
|
-
|
|
4098
|
-
`Would inject ${keys.length} ${keys.length === 1 ? "variable" : "variables"} from ${
|
|
4089
|
+
chalk14.bold(
|
|
4090
|
+
`Would inject ${keys.length} ${keys.length === 1 ? "variable" : "variables"} from ${chalk14.cyan(`${project.projectName || project.projectId}/${environment}`)}:`
|
|
4099
4091
|
)
|
|
4100
4092
|
);
|
|
4101
4093
|
console.log();
|
|
4102
4094
|
if (keys.length === 0) {
|
|
4103
|
-
console.log(
|
|
4095
|
+
console.log(chalk14.dim(" (no variables)"));
|
|
4104
4096
|
} else {
|
|
4105
4097
|
for (const key of keys) {
|
|
4106
4098
|
const value = secrets[key];
|
|
4107
4099
|
const masked = maskForPreview(value);
|
|
4108
|
-
console.log(` ${
|
|
4100
|
+
console.log(` ${chalk14.cyan(key)}=${chalk14.dim(masked)}`);
|
|
4109
4101
|
}
|
|
4110
4102
|
}
|
|
4111
4103
|
console.log();
|
|
@@ -4185,38 +4177,38 @@ function runChild(commandArgs, env, options) {
|
|
|
4185
4177
|
|
|
4186
4178
|
// src/commands/man.ts
|
|
4187
4179
|
import { Command as Command14 } from "commander";
|
|
4188
|
-
import
|
|
4180
|
+
import chalk15 from "chalk";
|
|
4189
4181
|
function printCommandManual(commandName) {
|
|
4190
4182
|
const command = findCommandDefinition(commandName);
|
|
4191
4183
|
if (!command) {
|
|
4192
|
-
console.log(
|
|
4184
|
+
console.log(chalk15.red(`Unknown command reference: ${commandName}`));
|
|
4193
4185
|
console.log();
|
|
4194
4186
|
console.log("Run `envpilot man` to see all supported commands.");
|
|
4195
4187
|
process.exit(1);
|
|
4196
4188
|
}
|
|
4197
|
-
console.log(
|
|
4189
|
+
console.log(chalk15.bold(formatArgv(command.argv)));
|
|
4198
4190
|
if (command.args) {
|
|
4199
|
-
console.log(
|
|
4191
|
+
console.log(chalk15.dim(command.args));
|
|
4200
4192
|
}
|
|
4201
4193
|
blank();
|
|
4202
4194
|
console.log(command.description);
|
|
4203
4195
|
blank();
|
|
4204
|
-
console.log(
|
|
4196
|
+
console.log(chalk15.green("Examples"));
|
|
4205
4197
|
for (const example of command.examples) {
|
|
4206
|
-
console.log(` ${
|
|
4198
|
+
console.log(` ${chalk15.cyan(formatArgv(example))}`);
|
|
4207
4199
|
}
|
|
4208
4200
|
blank();
|
|
4209
|
-
console.log(
|
|
4201
|
+
console.log(chalk15.green("Notes"));
|
|
4210
4202
|
for (const note of command.notes) {
|
|
4211
4203
|
console.log(` - ${note}`);
|
|
4212
4204
|
}
|
|
4213
4205
|
}
|
|
4214
4206
|
function printManualIndex(commands) {
|
|
4215
|
-
console.log(
|
|
4207
|
+
console.log(chalk15.bold("ENVPILOT(1)"));
|
|
4216
4208
|
console.log("TypeScript CLI manual");
|
|
4217
4209
|
blank();
|
|
4218
4210
|
console.log(
|
|
4219
|
-
`Total supported top-level commands: ${
|
|
4211
|
+
`Total supported top-level commands: ${chalk15.green(String(CLI_COMMAND_COUNT))}`
|
|
4220
4212
|
);
|
|
4221
4213
|
blank();
|
|
4222
4214
|
console.log(
|
|
@@ -4224,15 +4216,15 @@ function printManualIndex(commands) {
|
|
|
4224
4216
|
);
|
|
4225
4217
|
blank();
|
|
4226
4218
|
line();
|
|
4227
|
-
console.log(
|
|
4219
|
+
console.log(chalk15.green("Commands"));
|
|
4228
4220
|
for (const command of commands) {
|
|
4229
4221
|
console.log(
|
|
4230
|
-
` ${
|
|
4222
|
+
` ${chalk15.cyan(formatArgv(command.argv).padEnd(24))} ${chalk15.dim(command.description)}`
|
|
4231
4223
|
);
|
|
4232
4224
|
}
|
|
4233
4225
|
blank();
|
|
4234
4226
|
line();
|
|
4235
|
-
console.log(
|
|
4227
|
+
console.log(chalk15.green("Security"));
|
|
4236
4228
|
console.log(" - `.env*` is ignored by the repository `.gitignore`.");
|
|
4237
4229
|
console.log(
|
|
4238
4230
|
" - `envpilot init` and `envpilot sync` ensure env files are added to `.gitignore` locally."
|
|
@@ -4245,7 +4237,7 @@ function printManualIndex(commands) {
|
|
|
4245
4237
|
);
|
|
4246
4238
|
blank();
|
|
4247
4239
|
line();
|
|
4248
|
-
console.log(
|
|
4240
|
+
console.log(chalk15.green("Usage"));
|
|
4249
4241
|
console.log(
|
|
4250
4242
|
" - `envpilot` or `envpilot ui` opens the interactive terminal UI."
|
|
4251
4243
|
);
|
package/dist/index.js
CHANGED
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
getTopLevelCommandCatalog,
|
|
5
5
|
initSentry,
|
|
6
6
|
openTUI
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UVAK2D4O.js";
|
|
8
8
|
|
|
9
9
|
// src/lib/program.ts
|
|
10
10
|
import { Command } from "commander";
|
|
11
11
|
|
|
12
12
|
// src/lib/cli-version.ts
|
|
13
|
-
var CLI_VERSION = true ? "1.
|
|
13
|
+
var CLI_VERSION = true ? "1.11.0" : "0.0.0";
|
|
14
14
|
|
|
15
15
|
// src/lib/version-check.ts
|
|
16
16
|
import chalk from "chalk";
|
|
17
17
|
import Conf from "conf";
|
|
18
|
-
var CLI_VERSION2 = true ? "1.
|
|
18
|
+
var CLI_VERSION2 = true ? "1.11.0" : "0.0.0";
|
|
19
19
|
var CHECK_INTERVAL = 60 * 60 * 1e3;
|
|
20
20
|
var _cache = null;
|
|
21
21
|
function getCache() {
|
|
@@ -74,11 +74,17 @@ function createProgram() {
|
|
|
74
74
|
|
|
75
75
|
// src/index.tsx
|
|
76
76
|
initSentry();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
async function main() {
|
|
78
|
+
const args = process.argv.slice(2);
|
|
79
|
+
const shouldOpenTUI = process.env.ENVPILOT_TUI_CHILD !== "1" && args.length === 0;
|
|
80
|
+
if (shouldOpenTUI) {
|
|
81
|
+
await openTUI();
|
|
82
|
+
} else {
|
|
83
|
+
const program = createProgram();
|
|
84
|
+
await program.parseAsync();
|
|
85
|
+
}
|
|
84
86
|
}
|
|
87
|
+
main().catch((err) => {
|
|
88
|
+
console.error(err);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/ui/press-any-key.tsx
|
|
2
|
+
import { Box, Text, useApp, useInput } from "ink";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
function PressAnyKey({ onResolve }) {
|
|
5
|
+
const { exit } = useApp();
|
|
6
|
+
useInput((input, key) => {
|
|
7
|
+
const quit = input === "q" || input === "Q" || key.ctrl && input === "c";
|
|
8
|
+
onResolve(quit);
|
|
9
|
+
exit();
|
|
10
|
+
});
|
|
11
|
+
return /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: " Press any key to return to the TUI\u2026 (q to quit)" }) });
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
PressAnyKey
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envpilot/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Envpilot CLI — sync and manage environment variables from the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"zod": "^4.3.6"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@envpilot/eslint-config": "
|
|
39
|
-
"@envpilot/tsconfig": "
|
|
38
|
+
"@envpilot/eslint-config": "1.1.0",
|
|
39
|
+
"@envpilot/tsconfig": "1.1.0",
|
|
40
40
|
"@types/node": "^22.10.10",
|
|
41
41
|
"@types/react": "^18.3.12",
|
|
42
42
|
"eslint": "^9",
|