@catladder/cli 1.101.4 → 1.103.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/apps/catenv/catenv.d.ts +2 -4
- package/dist/apps/catenv/catenv.js +8 -89
- package/dist/apps/catenv/catenv.js.map +1 -1
- package/dist/apps/catenv/printVariables.d.ts +3 -0
- package/dist/apps/catenv/printVariables.js +111 -0
- package/dist/apps/catenv/printVariables.js.map +1 -0
- package/dist/apps/catenv/types.d.ts +5 -0
- package/dist/apps/catenv/types.js +3 -0
- package/dist/apps/catenv/types.js.map +1 -0
- package/dist/apps/catenv/utils.d.ts +12 -0
- package/dist/apps/catenv/utils.js +108 -0
- package/dist/apps/catenv/utils.js.map +1 -0
- package/dist/apps/catenv/writeDotEnvFiles.d.ts +3 -0
- package/dist/apps/catenv/writeDotEnvFiles.js +93 -0
- package/dist/apps/catenv/writeDotEnvFiles.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +14 -11
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +36 -11
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/apps/cli/commands/project/commandEnvVars.js +1 -1
- package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -1
- package/dist/bundles/catenv/index.js +3 -3
- package/dist/bundles/cli/index.js +2 -2
- package/dist/config/getProjectConfig.d.ts +8 -1
- package/dist/config/getProjectConfig.js +45 -6
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/gitlab.d.ts +4 -4
- package/dist/utils/gitlab.js.map +1 -1
- package/package.json +2 -2
- package/src/apps/catenv/catenv.ts +8 -62
- package/src/apps/catenv/printVariables.ts +51 -0
- package/src/apps/catenv/types.ts +6 -0
- package/src/apps/catenv/utils.ts +49 -0
- package/src/apps/catenv/writeDotEnvFiles.ts +45 -0
- package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +5 -2
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +18 -12
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +26 -7
- package/src/apps/cli/commands/project/commandEnvVars.ts +5 -2
- package/src/config/getProjectConfig.ts +30 -6
- package/src/utils/gitlab.ts +4 -4
- package/tsconfig.json +1 -1
package/dist/utils/gitlab.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import memoizee from "memoizee";
|
|
|
2
2
|
import type { CommandInstance } from "vorpal";
|
|
3
3
|
export declare const hasGitlabToken: () => Promise<boolean>;
|
|
4
4
|
export declare const setupGitlabToken: (vorpal: CommandInstance) => Promise<void>;
|
|
5
|
-
export declare const getGitlabToken: (vorpal: CommandInstance) => Promise<string>;
|
|
5
|
+
export declare const getGitlabToken: (vorpal: CommandInstance | null) => Promise<string>;
|
|
6
6
|
declare type Method = "GET" | "PUT" | "POST" | "DELETE";
|
|
7
|
-
export declare const doGitlabRequest: <T = any>(vorpal: CommandInstance, path: string, data?: any, method?: Method) => Promise<T>;
|
|
8
|
-
export declare const getProjectInfo: (vorpal: CommandInstance) => Promise<{
|
|
7
|
+
export declare const doGitlabRequest: <T = any>(vorpal: CommandInstance | null, path: string, data?: any, method?: Method) => Promise<T>;
|
|
8
|
+
export declare const getProjectInfo: (vorpal: CommandInstance | null) => Promise<{
|
|
9
9
|
id: string;
|
|
10
10
|
web_url: string;
|
|
11
11
|
}>;
|
|
@@ -17,7 +17,7 @@ declare type GitlabVariable = {
|
|
|
17
17
|
masked: boolean;
|
|
18
18
|
environment_scope: string;
|
|
19
19
|
};
|
|
20
|
-
export declare const getAllVariables: ((vorpal: CommandInstance) => Promise<Array<GitlabVariable>>) & memoizee.Memoized<(vorpal: CommandInstance) => Promise<Array<GitlabVariable>>>;
|
|
20
|
+
export declare const getAllVariables: ((vorpal: CommandInstance | null) => Promise<Array<GitlabVariable>>) & memoizee.Memoized<(vorpal: CommandInstance | null) => Promise<Array<GitlabVariable>>>;
|
|
21
21
|
export declare const getVariableValueByRawName: (vorpal: CommandInstance, rawName: string) => Promise<string>;
|
|
22
22
|
export declare const clearBackups: (vorpal: CommandInstance, keep: number) => Promise<void>;
|
|
23
23
|
export declare const upsertAllVariables: (vorpal: CommandInstance, variables: Record<string, any>, env: string, componentName: string, backup?: boolean, masked?: boolean) => Promise<void>;
|
package/dist/utils/gitlab.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.js","sourceRoot":"","sources":["../../src/utils/gitlab.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAuD;AACvD,+DAA6C;AAC7C,iCAAuC;AACvC,sDAAgC;AAChC,0DAA+B;AAC/B,8CAAwB;AAExB,6CAA4E;AAE5E,IAAM,SAAS,GAAG,8BAA8B,CAAC;AAE1C,IAAM,cAAc,GAAG;;gBAAY,qBAAM,IAAA,2BAAa,EAAC,SAAS,CAAC,EAAA;gBAA9B,sBAAA,SAA8B,EAAA;;SAAA,CAAC;AAA5D,QAAA,cAAc,kBAA8C;AAClE,IAAM,gBAAgB,GAAG,UAAO,MAAuB;;;;;gBAC5D,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACf,MAAM,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;gBAC5E,MAAM,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;gBAChE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACf,MAAM,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;gBACtD,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACY,qBAAM,MAAM,CAAC,MAAM,CAAC;wBAC7C,SAAO,EA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;;oBAGpE,MAAM,CAAC,GAAG,CAAC,mBAAY,GAAG,CAAE,CAAC,CAAC;;;oBA5BP,IAA+B,CAAA;;;oBA+B1D,uBAAe,CAAC,KAAK,EAAE,CAAC;;;;;CACzB,CAAC;AA5CW,QAAA,kBAAkB,sBA4C7B"}
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"node": ">=12.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@catladder/pipeline": "1.
|
|
27
|
+
"@catladder/pipeline": "1.103.0",
|
|
28
28
|
"@kubernetes/client-node": "^0.16.2",
|
|
29
29
|
"@tsconfig/node14": "^1.0.1",
|
|
30
30
|
"@types/common-tags": "^1.8.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"typescript": "^4.5.4",
|
|
58
58
|
"vorpal": "^1.12.0"
|
|
59
59
|
},
|
|
60
|
-
"version": "1.
|
|
60
|
+
"version": "1.103.0"
|
|
61
61
|
}
|
|
@@ -1,69 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
const getCurrentComponentName = async (
|
|
6
|
-
components: Record<string, ComponentConfig>
|
|
7
|
-
) => {
|
|
8
|
-
const gitRoot = await getGitRoot();
|
|
9
|
-
const currentDir = process.cwd();
|
|
10
|
-
return Object.keys(components).find((c) =>
|
|
11
|
-
currentDir.startsWith(join(gitRoot, components[c].dir))
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const sanitizeEnvVarName = (name: string) => name.replace(/[\s\-.]+/g, "_");
|
|
16
|
-
|
|
17
|
-
const getAllVariablesToPrint = async (
|
|
18
|
-
config: Config,
|
|
19
|
-
choice?: {
|
|
20
|
-
env?: string;
|
|
21
|
-
componentName?: string;
|
|
22
|
-
}
|
|
23
|
-
) => {
|
|
24
|
-
const env = choice?.env ?? "local";
|
|
25
|
-
const { components } = config;
|
|
1
|
+
import { getProjectConfig } from "../../config/getProjectConfig";
|
|
2
|
+
import { printVariables } from "./printVariables";
|
|
3
|
+
import type { Choice } from "./types";
|
|
4
|
+
import { writeDotEnvFiles } from "./writeDotEnvFiles";
|
|
26
5
|
|
|
27
|
-
|
|
28
|
-
choice?.componentName ?? (await getCurrentComponentName(components));
|
|
29
|
-
|
|
30
|
-
let variables = {};
|
|
31
|
-
if (currentComponent) {
|
|
32
|
-
variables = await getEnvVars(null, env, currentComponent);
|
|
33
|
-
} else {
|
|
34
|
-
// when in a monorep and not in a subapp, merge all env vars.
|
|
35
|
-
// this is not 100% correct, but better than not exporting any vars at all
|
|
36
|
-
// so we also add prefixed variants
|
|
37
|
-
variables = await Object.keys(components).reduce(
|
|
38
|
-
async (acc, componentName) => {
|
|
39
|
-
const subappvars = await getEnvVars(null, env, componentName);
|
|
40
|
-
return {
|
|
41
|
-
...(await acc),
|
|
42
|
-
...subappvars,
|
|
43
|
-
// also add prefixed variants in case
|
|
44
|
-
...Object.fromEntries(
|
|
45
|
-
Object.entries(subappvars).map(([key, value]) => [
|
|
46
|
-
`${sanitizeEnvVarName(componentName.toUpperCase())}_${key}`,
|
|
47
|
-
value,
|
|
48
|
-
])
|
|
49
|
-
),
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
{}
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
return variables;
|
|
56
|
-
};
|
|
57
|
-
export default async (choice?: { env?: string; componentName?: string }) => {
|
|
6
|
+
export default async (choice?: Choice) => {
|
|
58
7
|
const config = await getProjectConfig();
|
|
59
8
|
if (!config) {
|
|
60
9
|
return;
|
|
61
10
|
}
|
|
62
|
-
const variables = await getAllVariablesToPrint(config, choice);
|
|
63
11
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.join("\n")
|
|
68
|
-
);
|
|
12
|
+
await printVariables(config, choice);
|
|
13
|
+
|
|
14
|
+
await writeDotEnvFiles(config, choice);
|
|
69
15
|
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Config } from "@catladder/pipeline";
|
|
2
|
+
import { getEnvVarsResolved } from "../../config/getProjectConfig";
|
|
3
|
+
import type { Choice, Variables } from "./types";
|
|
4
|
+
import {
|
|
5
|
+
getCurrentComponentAndEnvFromChoice,
|
|
6
|
+
makeKeyValueString,
|
|
7
|
+
sanitizeEnvVarName,
|
|
8
|
+
} from "./utils";
|
|
9
|
+
|
|
10
|
+
const getAllVariablesToPrint = async (config: Config, choice?: Choice) => {
|
|
11
|
+
const { env, currentComponent } = await getCurrentComponentAndEnvFromChoice(
|
|
12
|
+
config,
|
|
13
|
+
choice
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
let variables = {};
|
|
17
|
+
if (currentComponent) {
|
|
18
|
+
variables = await getEnvVarsResolved(null, env, currentComponent);
|
|
19
|
+
} else {
|
|
20
|
+
// when in a monorep and not in a subapp, merge all env vars.
|
|
21
|
+
// this is not 100% correct, but better than not exporting any vars at all
|
|
22
|
+
// so we also add prefixed variants
|
|
23
|
+
variables = await Object.keys(config.components).reduce(
|
|
24
|
+
async (acc, componentName) => {
|
|
25
|
+
const subappvars = await getEnvVarsResolved(null, env, componentName);
|
|
26
|
+
return {
|
|
27
|
+
...(await acc),
|
|
28
|
+
...subappvars,
|
|
29
|
+
// also add prefixed variants in case
|
|
30
|
+
...Object.fromEntries(
|
|
31
|
+
Object.entries(subappvars).map(([key, value]) => [
|
|
32
|
+
`${sanitizeEnvVarName(componentName.toUpperCase())}_${key}`,
|
|
33
|
+
value,
|
|
34
|
+
])
|
|
35
|
+
),
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
{}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return variables;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const printVariables = async (config: Config, choice?: Choice) => {
|
|
45
|
+
const variables = await getAllVariablesToPrint(config, choice);
|
|
46
|
+
|
|
47
|
+
console.log(makeExportKeyValuestring(variables));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const makeExportKeyValuestring = (variables: Variables) =>
|
|
51
|
+
makeKeyValueString(variables, "export ");
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Config } from "@catladder/pipeline";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { getGitRoot } from "../../utils/projects";
|
|
4
|
+
import type { Choice, Variables } from "./types";
|
|
5
|
+
export const getComponentFullPath = (
|
|
6
|
+
gitRoot: string,
|
|
7
|
+
config: Config,
|
|
8
|
+
componentName: string
|
|
9
|
+
) => {
|
|
10
|
+
return join(gitRoot, config.components[componentName].dir);
|
|
11
|
+
};
|
|
12
|
+
const getCurrentComponentName = async (config: Config) => {
|
|
13
|
+
const gitRoot = await getGitRoot();
|
|
14
|
+
const currentDir = process.cwd();
|
|
15
|
+
return Object.keys(config.components).find((c) =>
|
|
16
|
+
currentDir.startsWith(getComponentFullPath(gitRoot, config, c))
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const getCurrentComponentAndEnvFromChoice = async (
|
|
21
|
+
config: Config,
|
|
22
|
+
choice?: Choice
|
|
23
|
+
) => {
|
|
24
|
+
const env = choice?.env ?? "local";
|
|
25
|
+
const currentComponent =
|
|
26
|
+
choice?.componentName ?? (await getCurrentComponentName(config));
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
currentComponent,
|
|
30
|
+
env,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const makeKeyValueString = (variables: Variables, keyPrefix = "") =>
|
|
35
|
+
Object.entries(variables)
|
|
36
|
+
.map(([key, value]) => `${keyPrefix}${key}='${value}'`)
|
|
37
|
+
.join("\n");
|
|
38
|
+
|
|
39
|
+
export const sanitizeMultiLine = (variables: Variables) => {
|
|
40
|
+
return Object.fromEntries(
|
|
41
|
+
Object.entries(variables).map(([key, value]) => [
|
|
42
|
+
key,
|
|
43
|
+
value.replaceAll("\n", "\\n"),
|
|
44
|
+
])
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const sanitizeEnvVarName = (name: string) =>
|
|
49
|
+
name.replace(/[\s\-.]+/g, "_");
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Config } from "@catladder/pipeline";
|
|
2
|
+
import { writeFile } from "fs-extra";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { getEnvVarsResolved } from "../../config/getProjectConfig";
|
|
5
|
+
import { getGitRoot } from "../../utils/projects";
|
|
6
|
+
import type { Choice } from "./types";
|
|
7
|
+
import {
|
|
8
|
+
getComponentFullPath,
|
|
9
|
+
getCurrentComponentAndEnvFromChoice,
|
|
10
|
+
makeKeyValueString,
|
|
11
|
+
sanitizeMultiLine,
|
|
12
|
+
} from "./utils";
|
|
13
|
+
|
|
14
|
+
export const writeDotEnvFiles = async (config: Config, choice?: Choice) => {
|
|
15
|
+
const { env, currentComponent } = await getCurrentComponentAndEnvFromChoice(
|
|
16
|
+
config,
|
|
17
|
+
choice
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
// whether to print .dotenv is currentl configure on the "local" part of the env
|
|
21
|
+
|
|
22
|
+
const componentsWithEnabledDotEnvWrite = Object.entries(config.components)
|
|
23
|
+
.filter(([, component]) => component?.dotEnv)
|
|
24
|
+
.map(([componentName]) => componentName);
|
|
25
|
+
|
|
26
|
+
const componentsToActuallyWriteDotEnvNow = currentComponent
|
|
27
|
+
? componentsWithEnabledDotEnvWrite.includes(currentComponent)
|
|
28
|
+
? [currentComponent]
|
|
29
|
+
: []
|
|
30
|
+
: componentsWithEnabledDotEnvWrite;
|
|
31
|
+
const gitRoot = await getGitRoot();
|
|
32
|
+
|
|
33
|
+
for (const componentName of componentsToActuallyWriteDotEnvNow) {
|
|
34
|
+
const variables = await getEnvVarsResolved(null, env, componentName);
|
|
35
|
+
const componentDir = getComponentFullPath(gitRoot, config, componentName);
|
|
36
|
+
const filePath = join(componentDir, ".env");
|
|
37
|
+
// many .dotenv don't like multiline values, so we sanitize them here
|
|
38
|
+
const variablesSanitized = sanitizeMultiLine(variables);
|
|
39
|
+
await writeFile(
|
|
40
|
+
filePath,
|
|
41
|
+
"# automatically created by catladder. Do not modify!\n\n" +
|
|
42
|
+
makeKeyValueString(variablesSanitized)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type Vorpal from "vorpal";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getEnvVarsResolved,
|
|
4
|
+
parseChoice,
|
|
5
|
+
} from "../../../../config/getProjectConfig";
|
|
3
6
|
import { logError } from "../../../../utils/log";
|
|
4
7
|
import { startKubePortForward } from "../../../../kubernetes/portForward";
|
|
5
8
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
@@ -46,7 +49,7 @@ export default async (vorpal: Vorpal) =>
|
|
|
46
49
|
message: "Local port: ",
|
|
47
50
|
});
|
|
48
51
|
const { env, componentName } = parseChoice(envComponent);
|
|
49
|
-
const envVars = await
|
|
52
|
+
const envVars = await getEnvVarsResolved(this, env, componentName);
|
|
50
53
|
const MONGODB_ROOT_PASSWORD = envVars?.MONGODB_ROOT_PASSWORD;
|
|
51
54
|
const connectionUrl = `mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:${localPort}`;
|
|
52
55
|
clipboard.writeSync(connectionUrl);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Context } from "@catladder/pipeline";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
createKubernetesCloudsqlBaseValues,
|
|
4
|
+
isOfDeployType,
|
|
5
|
+
} from "@catladder/pipeline";
|
|
4
6
|
import { spawn } from "child-process-promise";
|
|
5
|
-
import { writeFile } from "fs-extra";
|
|
6
|
-
import { withFile } from "tmp-promise";
|
|
7
7
|
import type Vorpal from "vorpal";
|
|
8
|
+
import type { CommandInstance } from "vorpal";
|
|
8
9
|
import {
|
|
9
|
-
|
|
10
|
-
getGitlabVar,
|
|
10
|
+
getEnvVarsResolved,
|
|
11
11
|
getPipelineContextByChoice,
|
|
12
12
|
parseChoice,
|
|
13
13
|
} from "../../../../config/getProjectConfig";
|
|
@@ -25,6 +25,10 @@ export default async (vorpal: Vorpal) =>
|
|
|
25
25
|
.autocomplete(await envAndComponents())
|
|
26
26
|
.action(async function ({ envComponent }) {
|
|
27
27
|
const { env, componentName } = parseChoice(envComponent);
|
|
28
|
+
if (!componentName) {
|
|
29
|
+
this.log("need componentName");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
28
32
|
|
|
29
33
|
const context = await getPipelineContextByChoice(env, componentName);
|
|
30
34
|
let proxyInfo: ProxyInfo;
|
|
@@ -35,11 +39,11 @@ export default async (vorpal: Vorpal) =>
|
|
|
35
39
|
);
|
|
36
40
|
}
|
|
37
41
|
if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
38
|
-
proxyInfo = await getProxyInfoForKubernetes(context);
|
|
42
|
+
proxyInfo = await getProxyInfoForKubernetes(this, context);
|
|
39
43
|
} else if (
|
|
40
44
|
isOfDeployType(context.componentConfig.deploy, "google-cloudrun")
|
|
41
45
|
) {
|
|
42
|
-
proxyInfo = await getProxyInfoForCloudRun(context);
|
|
46
|
+
proxyInfo = await getProxyInfoForCloudRun(this, context);
|
|
43
47
|
} else {
|
|
44
48
|
throw new Error("unsupported environment");
|
|
45
49
|
}
|
|
@@ -77,14 +81,15 @@ export default async (vorpal: Vorpal) =>
|
|
|
77
81
|
});
|
|
78
82
|
|
|
79
83
|
const getProxyInfoForKubernetes = async (
|
|
84
|
+
vorpal: CommandInstance,
|
|
80
85
|
context: Context
|
|
81
86
|
): Promise<ProxyInfo> => {
|
|
82
87
|
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
83
88
|
throw new Error("unsupported");
|
|
84
89
|
}
|
|
85
90
|
|
|
86
|
-
const envVars = await
|
|
87
|
-
|
|
91
|
+
const envVars = await getEnvVarsResolved(
|
|
92
|
+
vorpal,
|
|
88
93
|
context.environment.shortName,
|
|
89
94
|
context.componentName
|
|
90
95
|
);
|
|
@@ -106,6 +111,7 @@ const getProxyInfoForKubernetes = async (
|
|
|
106
111
|
};
|
|
107
112
|
|
|
108
113
|
const getProxyInfoForCloudRun = async (
|
|
114
|
+
vorpal: CommandInstance,
|
|
109
115
|
context: Context
|
|
110
116
|
): Promise<ProxyInfo> => {
|
|
111
117
|
if (
|
|
@@ -115,8 +121,8 @@ const getProxyInfoForCloudRun = async (
|
|
|
115
121
|
throw new Error("unsupported");
|
|
116
122
|
}
|
|
117
123
|
|
|
118
|
-
const envVars = await
|
|
119
|
-
|
|
124
|
+
const envVars = await getEnvVarsResolved(
|
|
125
|
+
vorpal,
|
|
120
126
|
context.environment.shortName,
|
|
121
127
|
context.componentName
|
|
122
128
|
);
|
|
@@ -7,7 +7,8 @@ import type Vorpal from "vorpal";
|
|
|
7
7
|
import {
|
|
8
8
|
getAllComponentsWithAllEnvsHierarchical,
|
|
9
9
|
getEnvironment,
|
|
10
|
-
|
|
10
|
+
getEnvVarsResolved,
|
|
11
|
+
getJobOnlyEnvVarsResolved,
|
|
11
12
|
getProjectComponents,
|
|
12
13
|
parseChoice,
|
|
13
14
|
} from "../../../../config/getProjectConfig";
|
|
@@ -45,24 +46,42 @@ const resolveJson = (v: Vars) =>
|
|
|
45
46
|
})
|
|
46
47
|
);
|
|
47
48
|
|
|
48
|
-
const
|
|
49
|
+
const getSecretEnvVarKeysToConfigure = async (
|
|
49
50
|
env: string,
|
|
50
51
|
componentName: string
|
|
51
52
|
) => {
|
|
52
|
-
const { secretEnvVarKeys } = await getEnvironment(
|
|
53
|
-
|
|
53
|
+
const { secretEnvVarKeys, jobOnlyVars } = await getEnvironment(
|
|
54
|
+
env,
|
|
55
|
+
componentName
|
|
56
|
+
);
|
|
57
|
+
return [
|
|
58
|
+
...jobOnlyVars.build.secretEnvVarKeys,
|
|
59
|
+
...jobOnlyVars.deploy.secretEnvVarKeys,
|
|
60
|
+
...secretEnvVarKeys,
|
|
61
|
+
]
|
|
62
|
+
.filter((k) => !k.hidden)
|
|
63
|
+
.map((k) => k.key);
|
|
54
64
|
};
|
|
55
65
|
const getEnvVarsToEdit = async (
|
|
56
66
|
instance: CommandInstance,
|
|
57
67
|
env: string,
|
|
58
68
|
componentName: string
|
|
59
69
|
) => {
|
|
60
|
-
const secretEnvVarKeys = await
|
|
70
|
+
const secretEnvVarKeys = await getSecretEnvVarKeysToConfigure(
|
|
61
71
|
env,
|
|
62
72
|
componentName
|
|
63
73
|
);
|
|
64
74
|
|
|
65
|
-
const
|
|
75
|
+
const normalEnvVars = await getEnvVarsResolved(instance, env, componentName);
|
|
76
|
+
const jobOnlyEnvVars = await getJobOnlyEnvVarsResolved(
|
|
77
|
+
instance,
|
|
78
|
+
env,
|
|
79
|
+
componentName
|
|
80
|
+
);
|
|
81
|
+
const allEnvVars = {
|
|
82
|
+
...normalEnvVars,
|
|
83
|
+
...jobOnlyEnvVars,
|
|
84
|
+
};
|
|
66
85
|
return Object.fromEntries(
|
|
67
86
|
secretEnvVarKeys.map((key) => {
|
|
68
87
|
const value = allEnvVars[key];
|
|
@@ -117,7 +136,7 @@ const doItFor = async (
|
|
|
117
136
|
? Object.keys(valuesToEdit[componentName][env])
|
|
118
137
|
: [];
|
|
119
138
|
// check whether newValues have the exact number of keys
|
|
120
|
-
const secretEnvVarKeys = await
|
|
139
|
+
const secretEnvVarKeys = await getSecretEnvVarKeysToConfigure(
|
|
121
140
|
env,
|
|
122
141
|
componentName
|
|
123
142
|
);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type Vorpal from "vorpal";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getEnvVarsResolved,
|
|
4
|
+
parseChoice,
|
|
5
|
+
} from "../../../../config/getProjectConfig";
|
|
3
6
|
import { envAndComponents } from "./utils/autocompletions";
|
|
4
7
|
|
|
5
8
|
export default async (vorpal: Vorpal) =>
|
|
@@ -8,7 +11,7 @@ export default async (vorpal: Vorpal) =>
|
|
|
8
11
|
.autocomplete(await envAndComponents())
|
|
9
12
|
.action(async function ({ envComponent }) {
|
|
10
13
|
const { env, componentName } = parseChoice(envComponent);
|
|
11
|
-
const envvars = await
|
|
14
|
+
const envvars = await getEnvVarsResolved(this, env, componentName);
|
|
12
15
|
Object.keys(envvars).forEach((key) =>
|
|
13
16
|
this.log(`${key}: ${envvars[key]}`)
|
|
14
17
|
);
|
|
@@ -16,7 +16,7 @@ import { watch } from "fs";
|
|
|
16
16
|
|
|
17
17
|
export { parseChoice } from "./parseChoice";
|
|
18
18
|
|
|
19
|
-
let currentConfig: Config = null;
|
|
19
|
+
let currentConfig: Config | null = null;
|
|
20
20
|
|
|
21
21
|
// reload the config on change
|
|
22
22
|
const reloadConfigAndObserve = async () => {
|
|
@@ -39,7 +39,7 @@ export const getProjectConfig = async () => {
|
|
|
39
39
|
// initially
|
|
40
40
|
await reloadConfigAndObserve();
|
|
41
41
|
}
|
|
42
|
-
return currentConfig;
|
|
42
|
+
return currentConfig as Config;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export const getGitlabCiFilePath = async () => {
|
|
@@ -123,7 +123,7 @@ export const getGitlabVar = async (
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
const resolveSecrets = async (
|
|
126
|
-
vorpal: CommandInstance,
|
|
126
|
+
vorpal: CommandInstance | null,
|
|
127
127
|
allEnvVars: Record<string, string>
|
|
128
128
|
) => {
|
|
129
129
|
const allVariablesInGitlab = await getAllVariables(vorpal);
|
|
@@ -145,11 +145,14 @@ const resolveSecrets = async (
|
|
|
145
145
|
);
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
export const
|
|
149
|
-
vorpal: CommandInstance,
|
|
148
|
+
export const getEnvVarsResolved = async (
|
|
149
|
+
vorpal: CommandInstance | null,
|
|
150
150
|
env: string,
|
|
151
|
-
componentName: string
|
|
151
|
+
componentName: string | null
|
|
152
152
|
) => {
|
|
153
|
+
if (!componentName) {
|
|
154
|
+
return {};
|
|
155
|
+
}
|
|
153
156
|
try {
|
|
154
157
|
const envionment = await getEnvironment(env, componentName);
|
|
155
158
|
// in the pipeline the secrets alreadyy exists and bash will expand them
|
|
@@ -160,3 +163,24 @@ export const getEnvVars = async (
|
|
|
160
163
|
return {};
|
|
161
164
|
}
|
|
162
165
|
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
*
|
|
169
|
+
* is used to get job only vars that should also be editable locally with catladder.
|
|
170
|
+
*/
|
|
171
|
+
export const getJobOnlyEnvVarsResolved = async (
|
|
172
|
+
vorpal: CommandInstance,
|
|
173
|
+
env: string,
|
|
174
|
+
componentName: string
|
|
175
|
+
) => {
|
|
176
|
+
try {
|
|
177
|
+
const envionment = await getEnvironment(env, componentName);
|
|
178
|
+
return resolveSecrets(vorpal, {
|
|
179
|
+
...envionment.jobOnlyVars.build.envVars,
|
|
180
|
+
...envionment.jobOnlyVars.deploy.envVars,
|
|
181
|
+
});
|
|
182
|
+
} catch (e) {
|
|
183
|
+
// env is disabled
|
|
184
|
+
return {};
|
|
185
|
+
}
|
|
186
|
+
};
|
package/src/utils/gitlab.ts
CHANGED
|
@@ -38,7 +38,7 @@ export const setupGitlabToken = async (vorpal: CommandInstance) => {
|
|
|
38
38
|
await setPreference(TOKEN_KEY, personalToken);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
export const getGitlabToken = async (vorpal: CommandInstance) => {
|
|
41
|
+
export const getGitlabToken = async (vorpal: CommandInstance | null) => {
|
|
42
42
|
if (!(await hasGitlabToken())) {
|
|
43
43
|
if (!vorpal) {
|
|
44
44
|
console.error(
|
|
@@ -53,7 +53,7 @@ export const getGitlabToken = async (vorpal: CommandInstance) => {
|
|
|
53
53
|
|
|
54
54
|
type Method = "GET" | "PUT" | "POST" | "DELETE";
|
|
55
55
|
export const doGitlabRequest = async <T = any>(
|
|
56
|
-
vorpal: CommandInstance,
|
|
56
|
+
vorpal: CommandInstance | null,
|
|
57
57
|
path: string,
|
|
58
58
|
data: any = undefined,
|
|
59
59
|
method: Method = "GET"
|
|
@@ -89,7 +89,7 @@ export const doGitlabRequest = async <T = any>(
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
export const getProjectInfo = async (
|
|
92
|
-
vorpal: CommandInstance
|
|
92
|
+
vorpal: CommandInstance | null
|
|
93
93
|
): Promise<{ id: string; web_url: string }> => {
|
|
94
94
|
const gitRemoteOriginUrl = (
|
|
95
95
|
await exec("git config --get remote.origin.url")
|
|
@@ -114,7 +114,7 @@ type GitlabVariable = {
|
|
|
114
114
|
environment_scope: string;
|
|
115
115
|
};
|
|
116
116
|
export const getAllVariables = memoizee(
|
|
117
|
-
async (vorpal: CommandInstance): Promise<Array<GitlabVariable>> => {
|
|
117
|
+
async (vorpal: CommandInstance | null): Promise<Array<GitlabVariable>> => {
|
|
118
118
|
const { id } = await getProjectInfo(vorpal);
|
|
119
119
|
let all: Array<GitlabVariable> = [];
|
|
120
120
|
let result: Array<GitlabVariable>;
|