@zuplo/cli 1.109.0 → 1.110.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 +7 -5
- package/dist/common/constants.js +3 -2
- package/dist/common/outdated.js +70 -0
- package/dist/common/output.js +5 -2
- package/dist/common/utils/box.js +55 -0
- package/package.json +6 -4
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="59466167-0404-586c-a0b1-a43e10b758a7")}catch(e){}}();
|
|
3
3
|
import * as dotenv from "dotenv";
|
|
4
4
|
dotenv.config();
|
|
5
5
|
import * as Sentry from "@sentry/node";
|
|
@@ -23,6 +23,7 @@ import variable from "./cmds/variable/index.js";
|
|
|
23
23
|
import { shutdownAnalytics } from "./common/analytics/lib.js";
|
|
24
24
|
import { MAX_WAIT_PENDING_TIME_MS, SENTRY_DSN } from "./common/constants.js";
|
|
25
25
|
import { logger } from "./common/logger.js";
|
|
26
|
+
import { warnIfOutdatedVersion } from "./common/outdated.js";
|
|
26
27
|
import { printCriticalFailureToConsoleAndExit } from "./common/output.js";
|
|
27
28
|
const MIN_NODE_VERSION = "18.0.0";
|
|
28
29
|
if (gte(process.versions.node, MIN_NODE_VERSION)) {
|
|
@@ -32,7 +33,7 @@ if (gte(process.versions.node, MIN_NODE_VERSION)) {
|
|
|
32
33
|
}
|
|
33
34
|
catch (e) {
|
|
34
35
|
logger.error(e);
|
|
35
|
-
printCriticalFailureToConsoleAndExit(`Unable to load @zuplo/cli. The package.json is missing or malformed.`);
|
|
36
|
+
await printCriticalFailureToConsoleAndExit(`Unable to load @zuplo/cli. The package.json is missing or malformed.`);
|
|
36
37
|
}
|
|
37
38
|
Sentry.init({
|
|
38
39
|
dsn: SENTRY_DSN,
|
|
@@ -59,6 +60,7 @@ if (gte(process.versions.node, MIN_NODE_VERSION)) {
|
|
|
59
60
|
.help();
|
|
60
61
|
try {
|
|
61
62
|
await cli.argv;
|
|
63
|
+
void warnIfOutdatedVersion(packageJson?.version);
|
|
62
64
|
void Sentry.close(MAX_WAIT_PENDING_TIME_MS).then(() => {
|
|
63
65
|
process.exit(0);
|
|
64
66
|
});
|
|
@@ -67,7 +69,7 @@ if (gte(process.versions.node, MIN_NODE_VERSION)) {
|
|
|
67
69
|
if (err instanceof Error) {
|
|
68
70
|
Sentry.captureException(err);
|
|
69
71
|
}
|
|
70
|
-
printCriticalFailureToConsoleAndExit(err.message ?? err);
|
|
72
|
+
await printCriticalFailureToConsoleAndExit(err.message ?? err);
|
|
71
73
|
cli.showHelp();
|
|
72
74
|
}
|
|
73
75
|
finally {
|
|
@@ -75,9 +77,9 @@ if (gte(process.versions.node, MIN_NODE_VERSION)) {
|
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
else {
|
|
78
|
-
printCriticalFailureToConsoleAndExit(`The zup CLI requires at least node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of node.js.
|
|
80
|
+
await printCriticalFailureToConsoleAndExit(`The zup CLI requires at least node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of node.js.
|
|
79
81
|
|
|
80
82
|
Consider using a Node.js version manager such as https://github.com/nvm-sh/nvm.`);
|
|
81
83
|
}
|
|
82
84
|
//# sourceMappingURL=cli.js.map
|
|
83
|
-
//# debugId=
|
|
85
|
+
//# debugId=59466167-0404-586c-a0b1-a43e10b758a7
|
package/dist/common/constants.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4daebd3e-ec9e-5f97-947a-e83332c8499e")}catch(e){}}();
|
|
3
3
|
export const ZUPLO_PREFERRED_JSON_FILE = "zuplo.jsonc";
|
|
4
4
|
export const ZUPLO_FALLBACK_JSON_FILE = "zuplo.json";
|
|
5
5
|
export const ZUPLO_CLI_XDG_FOLDER_NAME = "zup";
|
|
6
6
|
export const ZUPLO_AUTH_FILE_NAME = "auth.json";
|
|
7
|
+
export const ZUPLO_VERSION_CHECK_FILE = "version.json";
|
|
7
8
|
export const ZUPLO_SYSTEM_ENV_VAR = ".env.zuplo";
|
|
8
9
|
export const DEPLOYER_METADATA_FILE = "deployer.json";
|
|
9
10
|
export const ZUPLO_USER_ID_ARGV_KEY = "zuplo-user-id";
|
|
@@ -13,4 +14,4 @@ export const SENTRY_DSN = "https://28220fd3185a1281daff09ade2114dca@o1036703.ing
|
|
|
13
14
|
export const MAX_WAIT_PENDING_TIME_MS = 1000;
|
|
14
15
|
export const POST_HOG_CAPTURE_KEY = "phc_LDSwSTOvIjiDDZql2g54Q7xEXoQ0EN9RMYb3STbdz1V";
|
|
15
16
|
//# sourceMappingURL=constants.js.map
|
|
16
|
-
//# debugId=
|
|
17
|
+
//# debugId=4daebd3e-ec9e-5f97-947a-e83332c8499e
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f9015546-77f3-5e6e-9d05-4742665613e8")}catch(e){}}();
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
5
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { gt } from "semver";
|
|
8
|
+
import { ZUPLO_VERSION_CHECK_FILE } from "./constants.js";
|
|
9
|
+
import { printWarningToConsole } from "./output.js";
|
|
10
|
+
import box from "./utils/box.js";
|
|
11
|
+
import { ZUPLO_XDG_STATE_HOME } from "./xdg/lib.js";
|
|
12
|
+
export async function warnIfOutdatedVersion(currentVersion) {
|
|
13
|
+
if (!process.env.ZUPLO_OVERRIDE_CI_TO_TEST &&
|
|
14
|
+
(process.env.CI || process.env.ZUPLO_DISABLE_UPDATE_CHECK)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const versionCheckInfo = await getVersionCheckInfo();
|
|
18
|
+
const shouldWarn = gt(versionCheckInfo.latestVersion, currentVersion);
|
|
19
|
+
if (shouldWarn) {
|
|
20
|
+
printWarningToConsole(box(`Update available! ${chalk.gray(`v${currentVersion}`)} ≫ ${chalk.green(`v${versionCheckInfo.latestVersion}`)}
|
|
21
|
+
Run ${chalk.cyan("npm install zuplo@latest")} to update.
|
|
22
|
+
|
|
23
|
+
${chalk.gray("Older versions are unsupported and may not work as expected.")}`));
|
|
24
|
+
}
|
|
25
|
+
return shouldWarn;
|
|
26
|
+
}
|
|
27
|
+
async function getLatestVersion() {
|
|
28
|
+
const response = await fetch("https://raw.githubusercontent.com/zuplo/zuplo/main/packages/zuplo/package.json");
|
|
29
|
+
const result = await response.json();
|
|
30
|
+
return result.dependencies["@zuplo/cli"];
|
|
31
|
+
}
|
|
32
|
+
async function getVersionCheckInfo() {
|
|
33
|
+
if (!existsSync(ZUPLO_XDG_STATE_HOME)) {
|
|
34
|
+
mkdirSync(ZUPLO_XDG_STATE_HOME, { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
const versionCheckPath = join(ZUPLO_XDG_STATE_HOME, ZUPLO_VERSION_CHECK_FILE);
|
|
37
|
+
let versionCheckInfo;
|
|
38
|
+
if (existsSync(versionCheckPath)) {
|
|
39
|
+
try {
|
|
40
|
+
versionCheckInfo = await readFile(versionCheckPath, "utf-8").then(JSON.parse);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
}
|
|
44
|
+
if (versionCheckInfo) {
|
|
45
|
+
if (typeof versionCheckInfo.lastCheck !== "number" ||
|
|
46
|
+
typeof versionCheckInfo.latestVersion !== "string") {
|
|
47
|
+
versionCheckInfo = undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let shouldCheck = true;
|
|
52
|
+
if (versionCheckInfo) {
|
|
53
|
+
const now = Date.now();
|
|
54
|
+
const lastCheck = versionCheckInfo.lastCheck;
|
|
55
|
+
if (now - lastCheck < 1000 * 60 * 60 * 24) {
|
|
56
|
+
shouldCheck = false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!versionCheckInfo || shouldCheck) {
|
|
60
|
+
const latestVersion = await getLatestVersion();
|
|
61
|
+
versionCheckInfo = {
|
|
62
|
+
lastCheck: Date.now(),
|
|
63
|
+
latestVersion,
|
|
64
|
+
};
|
|
65
|
+
await writeFile(versionCheckPath, JSON.stringify(versionCheckInfo), "utf-8");
|
|
66
|
+
}
|
|
67
|
+
return versionCheckInfo;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=outdated.js.map
|
|
70
|
+
//# debugId=f9015546-77f3-5e6e-9d05-4742665613e8
|
package/dist/common/output.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c4c27bd6-8cfb-5bb5-86f6-e63b05aa573f")}catch(e){}}();
|
|
3
3
|
import * as Sentry from "@sentry/node";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import { MAX_WAIT_PENDING_TIME_MS } from "./constants.js";
|
|
6
6
|
export function printDiagnosticsToConsole(message) {
|
|
7
7
|
console.error(chalk.bold.blue(message));
|
|
8
8
|
}
|
|
9
|
+
export function printWarningToConsole(message) {
|
|
10
|
+
console.error(message);
|
|
11
|
+
}
|
|
9
12
|
export async function printCriticalFailureToConsoleAndExit(message) {
|
|
10
13
|
console.error(chalk.bold.red(message));
|
|
11
14
|
await Sentry.close(MAX_WAIT_PENDING_TIME_MS).then(() => {
|
|
@@ -51,4 +54,4 @@ export function textOrJson(text) {
|
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
//# sourceMappingURL=output.js.map
|
|
54
|
-
//# debugId=
|
|
57
|
+
//# debugId=c4c27bd6-8cfb-5bb5-86f6-e63b05aa573f
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2581e0ba-5dec-5b76-8b00-e2ed57baadcf")}catch(e){}}();
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import stripAnsi from "strip-ansi";
|
|
5
|
+
const border = ["─", "╭", "╮", "│", "│", "╰", "╯"];
|
|
6
|
+
const nothing = ["─", "", "", "", "", "", ""];
|
|
7
|
+
export default function box(message, { borderColor, padding = 1, textAlignment = "center", terminalColumns: cols = process.stdout.columns ||
|
|
8
|
+
(process.env.COLUMNS && parseInt(process.env.COLUMNS, 10)) ||
|
|
9
|
+
80, } = {}) {
|
|
10
|
+
const lines = message
|
|
11
|
+
.split(/\r?\n/)
|
|
12
|
+
.map((line) => [line, stripAnsi(line).length]);
|
|
13
|
+
const maxLine = lines.reduce((p, [, len]) => Math.max(p, len), 0);
|
|
14
|
+
const borderColorFn = (borderColor && chalk[borderColor]) || chalk.yellow;
|
|
15
|
+
const clampedSidePadding = Math.max(1, padding * 3);
|
|
16
|
+
const narrowMode = maxLine + 2 + clampedSidePadding * 2 > cols;
|
|
17
|
+
const sidePadding = narrowMode ? 0 : clampedSidePadding;
|
|
18
|
+
const innerWidth = Math.min(maxLine + sidePadding * 2, cols);
|
|
19
|
+
const [hr, topLeft, topRight, left, right, bottomLeft, bottomRight] = narrowMode ? nothing : border;
|
|
20
|
+
const spacerRow = narrowMode
|
|
21
|
+
? "\n".repeat(padding)
|
|
22
|
+
: `${borderColorFn(`${left}${" ".repeat(innerWidth)}${right}`)}\n`.repeat(padding);
|
|
23
|
+
const renderLine = ([line, len]) => {
|
|
24
|
+
let leftPadding = 0;
|
|
25
|
+
let rightPadding = 0;
|
|
26
|
+
if (!narrowMode) {
|
|
27
|
+
leftPadding = sidePadding;
|
|
28
|
+
rightPadding = sidePadding;
|
|
29
|
+
if (textAlignment === "center") {
|
|
30
|
+
leftPadding += Math.floor((maxLine - len) / 2);
|
|
31
|
+
rightPadding += maxLine - len - leftPadding + sidePadding;
|
|
32
|
+
}
|
|
33
|
+
else if (textAlignment === "right") {
|
|
34
|
+
leftPadding += maxLine - len;
|
|
35
|
+
}
|
|
36
|
+
else if (textAlignment === "left") {
|
|
37
|
+
rightPadding += maxLine - len;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return (borderColorFn(left) +
|
|
41
|
+
" ".repeat(leftPadding) +
|
|
42
|
+
line +
|
|
43
|
+
" ".repeat(rightPadding) +
|
|
44
|
+
borderColorFn(right));
|
|
45
|
+
};
|
|
46
|
+
return (borderColorFn(`${topLeft}${hr.repeat(innerWidth)}${topRight}`) +
|
|
47
|
+
"\n" +
|
|
48
|
+
spacerRow +
|
|
49
|
+
lines.map(renderLine).join("\n") +
|
|
50
|
+
"\n" +
|
|
51
|
+
spacerRow +
|
|
52
|
+
borderColorFn(`${bottomLeft}${hr.repeat(innerWidth)}${bottomRight}`));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=box.js.map
|
|
55
|
+
//# debugId=2581e0ba-5dec-5b76-8b00-e2ed57baadcf
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.110.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "https://github.com/zuplo/cli",
|
|
6
6
|
"description": "The command-line interface for Zuplo",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"mocha": "^10.2.0",
|
|
55
55
|
"openapi-types": "^12.1.3",
|
|
56
56
|
"prettier-plugin-organize-imports": "^3.2.2",
|
|
57
|
-
"typescript": "^5.2.2"
|
|
57
|
+
"typescript": "^5.2.2",
|
|
58
|
+
"undici": "^6.10.1"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
61
|
"@fastify/cors": "^8.3.0",
|
|
@@ -64,10 +65,10 @@
|
|
|
64
65
|
"@opentelemetry/api": "^1.8.0",
|
|
65
66
|
"@sentry/node": "7.69.0",
|
|
66
67
|
"@swc/core": "1.3.78",
|
|
67
|
-
"@zuplo/core": "5.
|
|
68
|
+
"@zuplo/core": "5.1999.0",
|
|
68
69
|
"@zuplo/deno-bin": "1.37.1",
|
|
69
70
|
"@zuplo/pino-pretty-configurations": "^1.5.0",
|
|
70
|
-
"@zuplo/runtime": "5.
|
|
71
|
+
"@zuplo/runtime": "5.1999.0",
|
|
71
72
|
"chalk": "^5.1.2",
|
|
72
73
|
"chokidar": "^3.5.3",
|
|
73
74
|
"dotenv": "^16.3.1",
|
|
@@ -91,6 +92,7 @@
|
|
|
91
92
|
"rollup-plugin-node-polyfills": "^0.2.1",
|
|
92
93
|
"semver": "^7.5.2",
|
|
93
94
|
"simple-git": "^3.17.0",
|
|
95
|
+
"strip-ansi": "^7.1.0",
|
|
94
96
|
"tar": "^6.1.13",
|
|
95
97
|
"temp": "^0.9.4",
|
|
96
98
|
"uuid": "^9.0.1",
|