@catladder/cli 3.1.1 → 3.2.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/bundles/catenv/index.js +1 -1
- package/dist/bundles/cli/index.js +9 -9
- package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.js +84 -51
- package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/cli/src/utils/log.d.ts +65 -1
- package/dist/cli/src/utils/log.js +62 -8
- package/dist/cli/src/utils/log.js.map +1 -1
- package/dist/pipeline/src/deploy/types/index.d.ts +1 -0
- package/dist/pipeline/src/deploy/types/index.js +7 -1
- package/dist/pipeline/src/deploy/types/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +130 -66
- package/src/utils/log.ts +108 -8
|
@@ -1,55 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const pipeline_1 = require("../../../../../../pipeline/src/index.js");
|
|
7
|
+
const clipboardy_1 = __importDefault(require("clipboardy"));
|
|
4
8
|
const getProjectConfig_1 = require("../../../../config/getProjectConfig");
|
|
5
9
|
const autocompletions_1 = require("./utils/autocompletions");
|
|
6
10
|
const startProxy_1 = require("../../../../gcloud/cloudSql/startProxy");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.action(async function ({ envComponent }) {
|
|
11
|
-
var _a, _b;
|
|
12
|
-
const { env, componentName } = (0, getProjectConfig_1.parseChoice)(envComponent);
|
|
13
|
-
if (!componentName) {
|
|
14
|
-
this.log("need componentName");
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const context = await (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName);
|
|
18
|
-
let proxyInfo;
|
|
19
|
-
if (env === "review") {
|
|
20
|
-
vorpal.log("⚠️ connection string does not include mr information on review environments");
|
|
21
|
-
}
|
|
11
|
+
const log_1 = require("../../../../utils/log");
|
|
12
|
+
const getProxyInfo = (context) => {
|
|
13
|
+
var _a, _b, _c, _d;
|
|
22
14
|
if ((0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "kubernetes")) {
|
|
23
|
-
|
|
15
|
+
return getProxyInfoForKubernetes(this, context);
|
|
24
16
|
}
|
|
25
17
|
else if ((0, pipeline_1.isOfDeployType)((_b = context.deploy) === null || _b === void 0 ? void 0 : _b.config, "google-cloudrun")) {
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
throw new Error("unsupported environment");
|
|
18
|
+
return getProxyInfoForCloudRun(this, context);
|
|
30
19
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const { localPort } = await this.prompt({
|
|
34
|
-
type: "number",
|
|
35
|
-
name: "localPort",
|
|
36
|
-
default: "54320",
|
|
37
|
-
message: "Local port: ",
|
|
38
|
-
});
|
|
39
|
-
this.log("");
|
|
40
|
-
this.log(`postgres-PW: ${DB_PASSWORD}`);
|
|
41
|
-
this.log("");
|
|
42
|
-
this.log("connection strings:");
|
|
43
|
-
this.log("");
|
|
44
|
-
this.log(`DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@localhost:${localPort}/${DB_NAME}?schema=public`);
|
|
45
|
-
this.log("");
|
|
46
|
-
this.log(`DATABASE_JDBC_URL=jdbc:postgresql://localhost:${localPort}/${DB_NAME}?schema=public&user=${DB_USER}&password=${DB_PASSWORD}`);
|
|
47
|
-
this.log("");
|
|
48
|
-
await (0, startProxy_1.startCloudSqlProxyInCurrentShell)({
|
|
49
|
-
instanceName,
|
|
50
|
-
localPort,
|
|
51
|
-
});
|
|
52
|
-
});
|
|
20
|
+
throw new Error(`unsupported environment: ${(_d = (_c = context.deploy) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.type}`);
|
|
21
|
+
};
|
|
53
22
|
const getProxyInfoForKubernetes = async (vorpal, context) => {
|
|
54
23
|
var _a, _b;
|
|
55
24
|
if (!(0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "kubernetes")) {
|
|
@@ -69,20 +38,84 @@ const getProxyInfoForKubernetes = async (vorpal, context) => {
|
|
|
69
38
|
};
|
|
70
39
|
};
|
|
71
40
|
const getProxyInfoForCloudRun = async (vorpal, context) => {
|
|
72
|
-
var _a, _b, _c, _d, _e;
|
|
41
|
+
var _a, _b, _c, _d, _e, _f;
|
|
73
42
|
if (!(0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "google-cloudrun") ||
|
|
74
43
|
!((_b = context.deploy) === null || _b === void 0 ? void 0 : _b.config.cloudSql)) {
|
|
75
|
-
|
|
44
|
+
const deployType = (0, pipeline_1.getDeployConfigType)((_c = context.deploy) === null || _c === void 0 ? void 0 : _c.config);
|
|
45
|
+
const errorMessage = deployType === "google-cloudrun"
|
|
46
|
+
? `DeployConfig is missing the cloudSql property`
|
|
47
|
+
: `Unsupported DeployConfig type: ${deployType}`;
|
|
48
|
+
(0, log_1.logError)(vorpal, errorMessage);
|
|
49
|
+
throw new Error(errorMessage);
|
|
76
50
|
}
|
|
77
51
|
const envVars = await (0, getProjectConfig_1.getEnvVarsResolved)(vorpal, context.env, context.name);
|
|
78
|
-
const DB_PASSWORD = (_c = envVars === null || envVars === void 0 ? void 0 : envVars.DB_PASSWORD) === null || _c === void 0 ? void 0 : _c.toString();
|
|
79
|
-
const DB_USER = (_d = envVars === null || envVars === void 0 ? void 0 : envVars.DB_USER) === null || _d === void 0 ? void 0 : _d.toString();
|
|
80
|
-
const DB_NAME = context.environment.envVars.DB_NAME.toString();
|
|
81
52
|
return {
|
|
82
|
-
instanceName: (
|
|
83
|
-
DB_PASSWORD,
|
|
84
|
-
DB_NAME,
|
|
85
|
-
DB_USER,
|
|
53
|
+
instanceName: (_d = context.deploy) === null || _d === void 0 ? void 0 : _d.config.cloudSql.instanceConnectionName,
|
|
54
|
+
DB_PASSWORD: (_e = envVars === null || envVars === void 0 ? void 0 : envVars.DB_PASSWORD) === null || _e === void 0 ? void 0 : _e.toString(),
|
|
55
|
+
DB_NAME: context.environment.envVars.DB_NAME.toString(),
|
|
56
|
+
DB_USER: (_f = envVars === null || envVars === void 0 ? void 0 : envVars.DB_USER) === null || _f === void 0 ? void 0 : _f.toString(),
|
|
86
57
|
};
|
|
87
58
|
};
|
|
59
|
+
const getDbUrl = ({ DB_PASSWORD, DB_NAME, DB_USER }, localPort, additional = "") => `DATABASE_URL="postgresql://${DB_USER}:${DB_PASSWORD}@localhost:${localPort}/${DB_NAME}${additional}"`;
|
|
60
|
+
const getJdbcUrl = ({ DB_PASSWORD, DB_NAME, DB_USER }, localPort) => `DATABASE_JDBC_URL="jdbc:postgresql://localhost:${localPort}/${DB_NAME}?schema=public&user=${DB_USER}&password=${DB_PASSWORD}"`;
|
|
61
|
+
exports.default = async (vorpal) => vorpal
|
|
62
|
+
.command("project-cloud-sql-proxy <envComponent>", "proxy to cloud sql db")
|
|
63
|
+
.autocomplete(await (0, autocompletions_1.envAndComponents)())
|
|
64
|
+
.action(async function ({ envComponent }) {
|
|
65
|
+
const { env, componentName } = (0, getProjectConfig_1.parseChoice)(envComponent);
|
|
66
|
+
if (!componentName) {
|
|
67
|
+
(0, log_1.logWarning)(this, "need componentName");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const context = await (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName);
|
|
71
|
+
if (env === "review") {
|
|
72
|
+
(0, log_1.logWarning)(this, "connection string does not include mr information on review environments");
|
|
73
|
+
}
|
|
74
|
+
const { localPort } = await this.prompt({
|
|
75
|
+
type: "number",
|
|
76
|
+
name: "localPort",
|
|
77
|
+
default: "54320",
|
|
78
|
+
message: "Local port: ",
|
|
79
|
+
});
|
|
80
|
+
const proxyInfo = await getProxyInfo(context);
|
|
81
|
+
/**
|
|
82
|
+
* Env variables for libpq (e.g. psql client)
|
|
83
|
+
* https://www.postgresql.org/docs/current/libpq-envars.html#LIBPQ-ENVARS
|
|
84
|
+
*/
|
|
85
|
+
const psqlEnvVars = {
|
|
86
|
+
PGPASSWORD: proxyInfo.DB_PASSWORD,
|
|
87
|
+
PGUSER: proxyInfo.DB_USER,
|
|
88
|
+
PGDATABASE: proxyInfo.DB_NAME,
|
|
89
|
+
PGHOST: "localhost",
|
|
90
|
+
PGPORT: localPort,
|
|
91
|
+
};
|
|
92
|
+
const lipbqEnvVarDeclarations = Object.entries(psqlEnvVars).map(([key, value]) => `${key}="${value}"`);
|
|
93
|
+
const dbUrl = getDbUrl(proxyInfo, localPort);
|
|
94
|
+
const jdbcUrl = getJdbcUrl(proxyInfo, localPort);
|
|
95
|
+
clipboardy_1.default.writeSync([
|
|
96
|
+
"",
|
|
97
|
+
"## CloudSQL proxy connection .env variables",
|
|
98
|
+
dbUrl,
|
|
99
|
+
jdbcUrl,
|
|
100
|
+
"## DATABASE_URL with schema=public parameter (e. g. Prisma requires this):",
|
|
101
|
+
`# ${getDbUrl(proxyInfo, localPort, `?schema=public`)}`,
|
|
102
|
+
"## Env variables for libpq (e.g. psql client https://www.postgresql.org/docs/current/libpq-envars.html#LIBPQ-ENVARS)",
|
|
103
|
+
...lipbqEnvVarDeclarations,
|
|
104
|
+
"",
|
|
105
|
+
].join("\n"));
|
|
106
|
+
(0, log_1.logLines)(this, null, "Connection strings env variables DATABASE_URL and those for the 'psql' client (copied to your clipboard for .env file):", dbUrl, jdbcUrl, ...lipbqEnvVarDeclarations, null, "DATABASE_URL with schema=public parameter (e. g. Prisma requires this):", getDbUrl(proxyInfo, localPort, `?schema=public`), null);
|
|
107
|
+
try {
|
|
108
|
+
await (0, startProxy_1.startCloudSqlProxyInCurrentShell)({
|
|
109
|
+
instanceName: proxyInfo.instanceName,
|
|
110
|
+
localPort,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (!(error instanceof Error))
|
|
115
|
+
throw error;
|
|
116
|
+
if (error.message !== startProxy_1.ERROR_NOT_INSTALLED)
|
|
117
|
+
throw error;
|
|
118
|
+
(0, log_1.logError)(this, error.message, null, "Please install the Cloud SQL Auth Proxy from:", `https://cloud.google.com/sql/docs/postgres/connect-auth-proxy#install`, null);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
88
121
|
//# sourceMappingURL=commandCloudSqlProxy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandCloudSqlProxy.js","sourceRoot":"","sources":["../../../../../../../src/apps/cli/commands/project/commandCloudSqlProxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commandCloudSqlProxy.js","sourceRoot":"","sources":["../../../../../../../src/apps/cli/commands/project/commandCloudSqlProxy.ts"],"names":[],"mappings":";;;;;AACA,kDAI6B;AAG7B,4DAAmC;AACnC,0EAI6C;AAC7C,6DAA2D;AAC3D,uEAGgD;AAChD,+CAAuE;AASvE,MAAM,YAAY,GAAG,CAAC,OAAyB,EAAE,EAAE;;IACjD,IAAI,IAAA,yBAAc,EAAC,MAAA,OAAO,CAAC,MAAM,0CAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;QACzD,OAAO,yBAAyB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;SAAM,IAAI,IAAA,yBAAc,EAAC,MAAA,OAAO,CAAC,MAAM,0CAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,CAAC;QACrE,OAAO,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAA,MAAA,OAAO,CAAC,MAAM,0CAAE,MAAM,0CAAE,IAAI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,oBAAS,CAAC,SAAS,CACjB;QACE,EAAE;QACF,6CAA6C;QAC7C,KAAK;QACL,OAAO;QACP,4EAA4E;QAC5E,KAAK,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,gBAAgB,CAAC,EAAE;QACvD,sHAAsH;QACtH,GAAG,uBAAuB;QAC1B,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IAEF,IAAA,cAAQ,EACN,IAAI,EACJ,IAAI,EACJ,yHAAyH,EACzH,KAAK,EACL,OAAO,EACP,GAAG,uBAAuB,EAC1B,IAAI,EACJ,yEAAyE,EACzE,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,gBAAgB,CAAC,EAChD,IAAI,CACL,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,IAAA,6CAAgC,EAAC;YACrC,YAAY,EAAE,SAAS,CAAC,YAAY;YACpC,SAAS;SACV,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,IAAI,KAAK,CAAC,OAAO,KAAK,gCAAmB;YAAE,MAAM,KAAK,CAAC;QACvD,IAAA,cAAQ,EACN,IAAI,EACJ,KAAK,CAAC,OAAO,EACb,IAAI,EACJ,+CAA+C,EAC/C,uEAAuE,EACvE,IAAI,CACL,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CommandInstance } from "vorpal";
|
|
2
|
+
type AnyMessagesFn = (message?: any, ...optionalParams: any[]) => void;
|
|
3
|
+
type StringMessagesFn = (message?: string, ...optionalParams: string[]) => void;
|
|
4
|
+
type AnyMessageFn = (message?: any) => void;
|
|
5
|
+
type StringMessageFn = (message?: string) => void;
|
|
6
|
+
type StringMessageSpreadFn = (...message: string[]) => void;
|
|
7
|
+
type AnyMessageSpreadFn = (...message: any[]) => void;
|
|
8
|
+
type SomeKindOfLogFn = AnyMessagesFn | StringMessagesFn | AnyMessageFn | StringMessageFn | StringMessageSpreadFn | AnyMessageSpreadFn;
|
|
9
|
+
type HasSomeKindOfLogMethod = {
|
|
10
|
+
log: SomeKindOfLogFn;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Something that has a .log method taking a string argument.
|
|
14
|
+
*
|
|
15
|
+
* null and undefined will fall back to console.log.
|
|
16
|
+
*/
|
|
17
|
+
export type LoggerCmdInstance = CommandInstance | Console | HasSomeKindOfLogMethod | null | undefined;
|
|
18
|
+
type LinesArgItem = string | number | boolean | Date | RegExp | null | undefined;
|
|
19
|
+
type LinesArg = LinesArgItem | LinesArgItem[];
|
|
20
|
+
/**
|
|
21
|
+
* Logs multiple lines using the log method of the provided {@link LoggerCmdInstance}.
|
|
22
|
+
*
|
|
23
|
+
* Line items that are `null` or `undefined` are logged as empty lines.
|
|
24
|
+
*
|
|
25
|
+
* @param cmd - The logger instance to use. If `null` or `undefined`, `console` will be used.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* logLines(cmd, "line 1", "line 2", null, "line 3");
|
|
30
|
+
* logLines(cmd, ...linesArray); // arrays can be spread into the function
|
|
31
|
+
* logLines(cmd, linesArray); // but it will flatten the plain array for convenience
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function logLines(cmd?: LoggerCmdInstance, ...lines: LinesArg[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Logs an error message using the log method of the provided {@link LoggerCmdInstance}.
|
|
37
|
+
*
|
|
38
|
+
* Line items that are `null` or `undefined` are logged as empty lines.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* logError(cmd, "Message");
|
|
43
|
+
* logError(cmd, "Message", "Additional message");
|
|
44
|
+
* logError(cmd, "Message", "Additional message", "Another additional message line");
|
|
45
|
+
* logError(cmd, "Message", ...additionalMessages); // arrays can be spread into the function
|
|
46
|
+
* logError(cmd, "Message", additionalMessages); // but it will flatten the plain array for convenience
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const logError: (cmd: LoggerCmdInstance, message: string, ...additionalMessages: LinesArg[]) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Logs a warning message using the log method of the provided {@link LoggerCmdInstance}.
|
|
52
|
+
*
|
|
53
|
+
* Line items that are `null` or `undefined` are logged as empty lines.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* logWarning(cmd, "Message");
|
|
58
|
+
* logWarning(cmd, "Message", "Additional message");
|
|
59
|
+
* logWarning(cmd, "Message", "Additional message", "Another additional message line");
|
|
60
|
+
* logWarning(cmd, "Message", ...additionalMessages); // arrays can be spread into the function
|
|
61
|
+
* logWarning(cmd, "Message", additionalMessages); // but it will flatten the plain array for convenience
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare const logWarning: (cmd: LoggerCmdInstance, message: string, ...additionalMessages: LinesArg[]) => void;
|
|
65
|
+
export {};
|
|
@@ -1,14 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logError = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
exports.logWarning = exports.logError = exports.logLines = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Logs multiple lines using the log method of the provided {@link LoggerCmdInstance}.
|
|
6
|
+
*
|
|
7
|
+
* Line items that are `null` or `undefined` are logged as empty lines.
|
|
8
|
+
*
|
|
9
|
+
* @param cmd - The logger instance to use. If `null` or `undefined`, `console` will be used.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* logLines(cmd, "line 1", "line 2", null, "line 3");
|
|
14
|
+
* logLines(cmd, ...linesArray); // arrays can be spread into the function
|
|
15
|
+
* logLines(cmd, linesArray); // but it will flatten the plain array for convenience
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function logLines(cmd = console, ...lines) {
|
|
19
|
+
for (const line of lines.flat()) {
|
|
20
|
+
(cmd !== null && cmd !== void 0 ? cmd : console).log(`${line !== null && line !== void 0 ? line : ""}`);
|
|
11
21
|
}
|
|
22
|
+
}
|
|
23
|
+
exports.logLines = logLines;
|
|
24
|
+
/**
|
|
25
|
+
* Logs an error message using the log method of the provided {@link LoggerCmdInstance}.
|
|
26
|
+
*
|
|
27
|
+
* Line items that are `null` or `undefined` are logged as empty lines.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* logError(cmd, "Message");
|
|
32
|
+
* logError(cmd, "Message", "Additional message");
|
|
33
|
+
* logError(cmd, "Message", "Additional message", "Another additional message line");
|
|
34
|
+
* logError(cmd, "Message", ...additionalMessages); // arrays can be spread into the function
|
|
35
|
+
* logError(cmd, "Message", additionalMessages); // but it will flatten the plain array for convenience
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
const logError = (cmd = console, message, ...additionalMessages) => {
|
|
39
|
+
logLines(cmd, "", `[ERROR] 🙀 :${message}`);
|
|
40
|
+
if (additionalMessages === null || additionalMessages === void 0 ? void 0 : additionalMessages.length) {
|
|
41
|
+
logLines(cmd, ...additionalMessages.flat());
|
|
42
|
+
}
|
|
43
|
+
logLines(cmd, "");
|
|
12
44
|
};
|
|
13
45
|
exports.logError = logError;
|
|
46
|
+
/**
|
|
47
|
+
* Logs a warning message using the log method of the provided {@link LoggerCmdInstance}.
|
|
48
|
+
*
|
|
49
|
+
* Line items that are `null` or `undefined` are logged as empty lines.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* logWarning(cmd, "Message");
|
|
54
|
+
* logWarning(cmd, "Message", "Additional message");
|
|
55
|
+
* logWarning(cmd, "Message", "Additional message", "Another additional message line");
|
|
56
|
+
* logWarning(cmd, "Message", ...additionalMessages); // arrays can be spread into the function
|
|
57
|
+
* logWarning(cmd, "Message", additionalMessages); // but it will flatten the plain array for convenience
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
const logWarning = (cmd = console, message, ...additionalMessages) => {
|
|
61
|
+
logLines(cmd, "", `[WARNING] ⚠️ : ${message}`);
|
|
62
|
+
if (additionalMessages === null || additionalMessages === void 0 ? void 0 : additionalMessages.length) {
|
|
63
|
+
logLines(cmd, ...additionalMessages.flat());
|
|
64
|
+
}
|
|
65
|
+
logLines(cmd, "");
|
|
66
|
+
};
|
|
67
|
+
exports.logWarning = logWarning;
|
|
14
68
|
//# sourceMappingURL=log.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../src/utils/log.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../src/utils/log.ts"],"names":[],"mappings":";;;AAuCA;;;;;;;;;;;;;GAaG;AACH,SAAgB,QAAQ,CACtB,MAAyB,OAAO,EAChC,GAAG,KAAiB;IAEpB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAChC,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;AACH,CAAC;AAPD,4BAOC;AAED;;;;;;;;;;;;;GAaG;AACI,MAAM,QAAQ,GAAG,CACtB,MAAyB,OAAO,EAChC,OAAe,EACf,GAAG,kBAA8B,EACjC,EAAE;IACF,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,eAAe,OAAO,EAAE,CAAC,CAAC;IAC5C,IAAI,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,MAAM,EAAE,CAAC;QAC/B,QAAQ,CAAC,GAAG,EAAE,GAAG,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IACD,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACpB,CAAC,CAAC;AAVW,QAAA,QAAQ,YAUnB;AAEF;;;;;;;;;;;;;GAaG;AACI,MAAM,UAAU,GAAG,CACxB,MAAyB,OAAO,EAChC,OAAe,EACf,GAAG,kBAA8B,EACjC,EAAE;IACF,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,kBAAkB,OAAO,EAAE,CAAC,CAAC;IAC/C,IAAI,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,MAAM,EAAE,CAAC;QAC/B,QAAQ,CAAC,GAAG,EAAE,GAAG,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IACD,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACpB,CAAC,CAAC;AAVW,QAAA,UAAU,cAUrB"}
|
|
@@ -20,3 +20,4 @@ export declare const isOfDeployType: <T extends ("custom" | "kubernetes" | "dock
|
|
|
20
20
|
}> | Extract<DeployConfigKubernetes, {
|
|
21
21
|
type: T[number];
|
|
22
22
|
}>;
|
|
23
|
+
export declare const getDeployConfigType: (t: DeployConfig | false | null | undefined) => "custom" | "kubernetes" | "dockerTag" | "google-cloudrun";
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isOfDeployType = void 0;
|
|
17
|
+
exports.getDeployConfigType = exports.isOfDeployType = void 0;
|
|
18
18
|
__exportStar(require("./custom"), exports);
|
|
19
19
|
__exportStar(require("./googleCloudRun"), exports);
|
|
20
20
|
__exportStar(require("./kubernetes"), exports);
|
|
@@ -23,4 +23,10 @@ const isOfDeployType = (t, ...types) => {
|
|
|
23
23
|
return t && types.includes(t.type) ? true : false;
|
|
24
24
|
};
|
|
25
25
|
exports.isOfDeployType = isOfDeployType;
|
|
26
|
+
const getDeployConfigType = (t) => {
|
|
27
|
+
if (!t)
|
|
28
|
+
return undefined;
|
|
29
|
+
return t.type;
|
|
30
|
+
};
|
|
31
|
+
exports.getDeployConfigType = getDeployConfigType;
|
|
26
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../pipeline/src/deploy/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,2CAAyB;AACzB,mDAAiC;AACjC,+CAA6B;AAC7B,8CAA4B;AAcrB,MAAM,cAAc,GAAG,CAC5B,CAA0C,EAC1C,GAAG,KAAQ,EACsC,EAAE;IACnD,OAAO,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../pipeline/src/deploy/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,2CAAyB;AACzB,mDAAiC;AACjC,+CAA6B;AAC7B,8CAA4B;AAcrB,MAAM,cAAc,GAAG,CAC5B,CAA0C,EAC1C,GAAG,KAAQ,EACsC,EAAE;IACnD,OAAO,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB;AAEK,MAAM,mBAAmB,GAAG,CACjC,CAA0C,EAC1C,EAAE;IACF,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACzB,OAAO,CAAC,CAAC,IAAI,CAAC;AAChB,CAAC,CAAC;AALW,QAAA,mBAAmB,uBAK9B"}
|