@catladder/cli 0.0.0-new-cli-80ac360a → 0.0.0-new-cli-81ed6546

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.
Files changed (71) hide show
  1. package/dist/bundles/catenv/index.js +4341 -27
  2. package/dist/bundles/cli/index.js +15872 -694
  3. package/dist/cli/src/apps/catenv/catenv.d.ts +1 -0
  4. package/dist/cli/src/apps/catenv/catenv.js +1 -1
  5. package/dist/cli/src/apps/catenv/catenv.js.map +1 -1
  6. package/dist/cli/src/apps/catenv/printVariables.js +0 -10
  7. package/dist/cli/src/apps/catenv/printVariables.js.map +1 -1
  8. package/dist/cli/src/catenv.js +13 -16
  9. package/dist/cli/src/catenv.js.map +1 -1
  10. package/dist/cli/src/commands/index.d.ts +3 -0
  11. package/dist/cli/src/commands/index.js +23 -1
  12. package/dist/cli/src/commands/index.js.map +1 -1
  13. package/dist/cli/src/commands/project/commandSecurityEvaluate.js +1 -1
  14. package/dist/cli/src/commands/project/commandSecurityEvaluate.js.map +1 -1
  15. package/dist/cli/src/commands/security/commandSecurityAuditCiJob.d.ts +27 -0
  16. package/dist/cli/src/commands/security/commandSecurityAuditCiJob.js +83 -0
  17. package/dist/cli/src/commands/security/commandSecurityAuditCiJob.js.map +1 -0
  18. package/dist/cli/src/commands/security/commandSecurityAuditCreate.d.ts +22 -0
  19. package/dist/cli/src/commands/security/commandSecurityAuditCreate.js +60 -0
  20. package/dist/cli/src/commands/security/commandSecurityAuditCreate.js.map +1 -0
  21. package/dist/cli/src/commands/security/commandSecurityAuditEvaluate.d.ts +7 -0
  22. package/dist/cli/src/commands/security/commandSecurityAuditEvaluate.js +35 -0
  23. package/dist/cli/src/commands/security/commandSecurityAuditEvaluate.js.map +1 -0
  24. package/dist/cli/src/security/auditDocument.js.map +1 -0
  25. package/dist/cli/src/security/createSecurityAuditMergeRequest.js.map +1 -0
  26. package/dist/cli/src/security/evaluateSecurityAudit.js.map +1 -0
  27. package/dist/pipeline/src/build/types.d.ts +1 -1
  28. package/dist/pipeline/src/constants.js +1 -1
  29. package/dist/pipeline/src/context/getEnvironmentVariables.d.ts +1 -1
  30. package/dist/pipeline/src/deploy/types/index.d.ts +2 -2
  31. package/dist/pipeline/src/types/config.d.ts +3 -3
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +3 -6
  34. package/scripts/bundle +0 -2
  35. package/src/apps/catenv/catenv.ts +4 -2
  36. package/src/apps/catenv/printVariables.ts +0 -8
  37. package/src/catenv.ts +18 -19
  38. package/src/commands/index.ts +5 -0
  39. package/src/commands/project/commandSecurityEvaluate.ts +1 -1
  40. package/src/commands/security/commandSecurityAuditCiJob.ts +91 -0
  41. package/src/commands/security/commandSecurityAuditCreate.ts +58 -0
  42. package/src/commands/security/commandSecurityAuditEvaluate.ts +30 -0
  43. package/bin/catci +0 -3
  44. package/bin/catci-dev +0 -3
  45. package/dist/bundles/catci/index.js +0 -71714
  46. package/dist/cli/src/apps/catci/catci.d.ts +0 -1
  47. package/dist/cli/src/apps/catci/catci.js +0 -33
  48. package/dist/cli/src/apps/catci/catci.js.map +0 -1
  49. package/dist/cli/src/apps/catci/commands/security/auditDocument.js.map +0 -1
  50. package/dist/cli/src/apps/catci/commands/security/commands.d.ts +0 -2
  51. package/dist/cli/src/apps/catci/commands/security/commands.js +0 -118
  52. package/dist/cli/src/apps/catci/commands/security/commands.js.map +0 -1
  53. package/dist/cli/src/apps/catci/commands/security/createSecurityAuditMergeRequest.js.map +0 -1
  54. package/dist/cli/src/apps/catci/commands/security/evaluateSecurityAudit.js.map +0 -1
  55. package/dist/cli/src/catci.d.ts +0 -1
  56. package/dist/cli/src/catci.js +0 -7
  57. package/dist/cli/src/catci.js.map +0 -1
  58. package/src/apps/catci/catci.ts +0 -26
  59. package/src/apps/catci/commands/security/commands.ts +0 -161
  60. package/src/catci.ts +0 -3
  61. /package/dist/cli/src/{apps/catci/commands/security → security}/auditDocument.d.ts +0 -0
  62. /package/dist/cli/src/{apps/catci/commands/security → security}/auditDocument.js +0 -0
  63. /package/dist/cli/src/{apps/catci/commands/security → security}/createSecurityAuditMergeRequest.d.ts +0 -0
  64. /package/dist/cli/src/{apps/catci/commands/security → security}/createSecurityAuditMergeRequest.js +0 -0
  65. /package/dist/cli/src/{apps/catci/commands/security → security}/evaluateSecurityAudit.d.ts +0 -0
  66. /package/dist/cli/src/{apps/catci/commands/security → security}/evaluateSecurityAudit.js +0 -0
  67. /package/dist/cli/src/{apps/catci/commands/security → security}/topics.json +0 -0
  68. /package/src/{apps/catci/commands/security → security}/auditDocument.ts +0 -0
  69. /package/src/{apps/catci/commands/security → security}/createSecurityAuditMergeRequest.ts +0 -0
  70. /package/src/{apps/catci/commands/security → security}/evaluateSecurityAudit.ts +0 -0
  71. /package/src/{apps/catci/commands/security → security}/topics.json +0 -0
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "0.0.0-new-cli-80ac360a",
56
+ "version": "0.0.0-new-cli-81ed6546",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -66,7 +66,6 @@
66
66
  "build:watch": "tsc-watch --onSuccess \"yarn dev:own-catenv\""
67
67
  },
68
68
  "bin": {
69
- "catci": "./bin/catci",
70
69
  "catenv": "./bin/catenv",
71
70
  "catladder": "./bin/catladder"
72
71
  },
@@ -80,6 +79,7 @@
80
79
  "@babel/core": "^7.29.0",
81
80
  "@babel/plugin-syntax-typescript": "^7.28.6",
82
81
  "@gitbeaker/rest": "^39.28.0",
82
+ "@inquirer/prompts": "^8.4.3",
83
83
  "@kubernetes/client-node": "^0.16.2",
84
84
  "@tsconfig/node14": "^1.0.1",
85
85
  "@types/common-tags": "^1.8.4",
@@ -90,13 +90,13 @@
90
90
  "@types/request": "^2.48.12",
91
91
  "@types/tmp": "^0.2.3",
92
92
  "@types/update-notifier": "^2.5.0",
93
- "@types/vorpal": "^1.12.0",
94
93
  "@types/websocket": "^0.0.40",
95
94
  "@types/yargs": "^17.0.33",
96
95
  "babel-plugin-transform-inline-environment-variables": "^0.4.4",
97
96
  "child-process-promise": "^2.2.1",
98
97
  "clipboardy": "^2.0.0",
99
98
  "command-exists-promise": "^2.0.2",
99
+ "commander": "^14.0.3",
100
100
  "common-tags": "^1.8.2",
101
101
  "connection-string-parser": "^1.0.4",
102
102
  "date-fns": "^3.6.0",
@@ -111,12 +111,9 @@
111
111
  "tsc-alias": "^1.8.16",
112
112
  "tsc-watch": "^7.2.0",
113
113
  "typescript": "^5.4.5",
114
- "vorpal": "^1.12.0",
115
114
  "yaml": "^2.5.0"
116
115
  },
117
116
  "dependencies": {
118
- "@inquirer/prompts": "^8.4.3",
119
- "commander": "^14.0.3",
120
117
  "tsx": "^4.21.0"
121
118
  },
122
119
  "stableVersion": "0.0.0"
package/scripts/bundle CHANGED
@@ -2,5 +2,3 @@
2
2
  ncc build dist/cli/src/catenv.js -o dist/bundles/catenv -e 'tsx/cjs/api' $( ((SHOULD_MINIFY == 1)) && printf %s '-m')
3
3
 
4
4
  ncc build dist/cli/src/cli.js -o dist/bundles/cli -e 'tsx/cjs/api' $( ((SHOULD_MINIFY == 1)) && printf %s '-m')
5
-
6
- ncc build dist/cli/src/catci.js -o dist/bundles/catci -e 'tsx/cjs/api' $( ((SHOULD_MINIFY == 1)) && printf %s '-m')
@@ -11,6 +11,7 @@ import {
11
11
 
12
12
  type Options = {
13
13
  verbose?: boolean;
14
+ printVariables?: boolean;
14
15
  };
15
16
  export default async (choice?: Choice, options?: Options) => {
16
17
  const config = await getProjectConfig();
@@ -28,7 +29,8 @@ export default async (choice?: Choice, options?: Options) => {
28
29
  writeDotEnvFiles(context, choice),
29
30
 
30
31
  writeDTsFiles(context, choice),
31
-
32
- printVariables(context, choice),
32
+ options?.printVariables
33
+ ? printVariables(context, choice)
34
+ : Promise.resolve(),
33
35
  ]);
34
36
  };
@@ -14,10 +14,6 @@ const getAllVariablesToPrint = async (config: Config, choice?: Choice) => {
14
14
  );
15
15
 
16
16
  if (currentComponent) {
17
- // don't print vars if dotenv is enabled
18
- if (config.components[currentComponent].dotEnv ?? true) {
19
- return {};
20
- }
21
17
  return await getEnvVarsResolved(null, env, currentComponent);
22
18
  } else {
23
19
  // when in a monorep and not in a subapp, merge all env vars.
@@ -25,10 +21,6 @@ const getAllVariablesToPrint = async (config: Config, choice?: Choice) => {
25
21
  // so we also add prefixed variants
26
22
  return await Object.keys(config.components).reduce(
27
23
  async (acc, componentName) => {
28
- // don't print vars if dotenv is enabled
29
- if (config.components[componentName].dotEnv ?? true) {
30
- return await acc;
31
- }
32
24
  const subappvars = await getEnvVarsResolved(null, env, componentName);
33
25
  delete subappvars["_ALL_ENV_VAR_KEYS"];
34
26
  return {
package/src/catenv.ts CHANGED
@@ -1,24 +1,23 @@
1
+ import { Command } from "commander";
1
2
  import catenv from "./apps/catenv/catenv";
2
-
3
3
  import { parseChoice } from "./config/parseChoice";
4
+ import packageInfos from "./packageInfos";
4
5
 
5
- const args = process.argv.slice(2);
6
-
7
- const helpFlags = ["--help", "-h", "help"];
8
- if (args.some((arg) => helpFlags.includes(arg))) {
9
- const docLink =
10
- "https://git.panter.ch/catladder/catladder/-/blob/main/docs/1_VARS.md";
11
- console.log(
12
- `\nUsage: catenv [env|env:component] [-v|--verbose]\n\nEnv variable and catenv documentation:\n${docLink}`,
13
- );
14
- process.exit(0);
15
- }
6
+ const program = new Command();
16
7
 
17
- const verbose = args.some((arg) => arg === "-v" || arg === "--verbose");
18
- // choise arg is deprecated and will be removed in the future
19
- const choiceArg = args.find((arg) => arg !== "-v" && arg !== "--verbose");
8
+ program
9
+ .name("catenv")
10
+ .description("Environment variable and pipeline generation via direnv")
11
+ .version(packageInfos.version)
12
+ .argument("[envComponent]", "env or env:component")
13
+ .option("-v, --verbose", "verbose output")
14
+ .action((envComponent: string | undefined, opts: { verbose?: boolean }) => {
15
+ catenv(envComponent ? parseChoice(envComponent) : null, {
16
+ verbose: opts.verbose ?? false,
17
+ }).then(() => {
18
+ // we have to exit manually, because we have some file watches
19
+ process.exit();
20
+ });
21
+ });
20
22
 
21
- catenv(choiceArg ? parseChoice(choiceArg) : null, { verbose }).then(() => {
22
- // we have to exit manually, because we have some file watches
23
- process.exit();
24
- });
23
+ program.parse();
@@ -41,6 +41,11 @@ export { commandMongoDestroyMember } from "./mongodb/commandMongoDestroyMember";
41
41
  // CloudSQL commands
42
42
  export { commandRestoreDb } from "./cloudSQL/commandRestoreDb";
43
43
 
44
+ // Security commands
45
+ export { commandSecurityAuditCiJob } from "./security/commandSecurityAuditCiJob";
46
+ export { commandSecurityAuditEvaluate } from "./security/commandSecurityAuditEvaluate";
47
+ export { commandSecurityAuditCreate } from "./security/commandSecurityAuditCreate";
48
+
44
49
  // Fun commands
45
50
  export { commandDadjoke } from "./fun/commandDadjoke";
46
51
  export { commandStarwars } from "./fun/commandStarwars";
@@ -2,7 +2,7 @@ import { defineCommand } from "../../core/defineCommand";
2
2
  import {
3
3
  evaluateSecurityAudit,
4
4
  makeSecurityAuditOverview,
5
- } from "../../apps/catci/commands/security/evaluateSecurityAudit";
5
+ } from "../../security/evaluateSecurityAudit";
6
6
  import { getGitRoot } from "../../utils/projects";
7
7
 
8
8
  export const commandSecurityEvaluate = defineCommand({
@@ -0,0 +1,91 @@
1
+ import { defineCommand } from "../../core/defineCommand";
2
+ import { Gitlab } from "@gitbeaker/rest";
3
+ import {
4
+ evaluateSecurityAudit,
5
+ makeSecurityAuditOverview,
6
+ } from "../../security/evaluateSecurityAudit";
7
+ import {
8
+ createSecurityAuditMergeRequest,
9
+ SECURITY_AUDIT_FILE_NAME,
10
+ } from "../../security/createSecurityAuditMergeRequest";
11
+
12
+ const GITLAB_HOST = "https://git.panter.ch";
13
+
14
+ export const commandSecurityAuditCiJob = defineCommand({
15
+ name: "security-audit-ci-job",
16
+ description:
17
+ "Evaluates security audit document. Creates MR with template if missing.",
18
+ group: "security",
19
+ inputs: {
20
+ path: { type: "string", message: "path to project root", positional: true },
21
+ token: {
22
+ type: "string",
23
+ message: "GitLab token (api scope)",
24
+ positional: true,
25
+ },
26
+ mainBranch: {
27
+ type: "string",
28
+ message: "main branch name",
29
+ positional: true,
30
+ },
31
+ projectId: {
32
+ type: "string",
33
+ message: "GitLab project ID",
34
+ positional: true,
35
+ },
36
+ userId: {
37
+ type: "string",
38
+ message: "GitLab user ID (assignee)",
39
+ positional: true,
40
+ },
41
+ },
42
+ execute: async (ctx) => {
43
+ const path = await ctx.get("path");
44
+ const evaluation = await evaluateSecurityAudit({ path });
45
+
46
+ if (evaluation.isErr()) {
47
+ ctx.log("could not evaluate security audit document");
48
+ ctx.log("creating new merge request with security audit template...");
49
+
50
+ const token = await ctx.get("token");
51
+ const mainBranch = await ctx.get("mainBranch");
52
+ const projectId = await ctx.get("projectId");
53
+ const userId = await ctx.get("userId");
54
+
55
+ const api = new Gitlab({ host: GITLAB_HOST, token });
56
+
57
+ const mr = await createSecurityAuditMergeRequest({
58
+ api,
59
+ mainBranch,
60
+ projectId,
61
+ userId: parseInt(userId),
62
+ });
63
+
64
+ if (mr.isErr()) {
65
+ ctx.log(
66
+ `could not create merge request with security audit template: ${mr.error}`,
67
+ );
68
+ process.exitCode = 1;
69
+ return;
70
+ }
71
+
72
+ ctx.log("security audit merge request created successfully");
73
+ ctx.log(
74
+ `please finish the MR by updating SECURITY.md document: ${mr.value.web_url}`,
75
+ );
76
+ process.exitCode = 1;
77
+ return;
78
+ }
79
+
80
+ if (evaluation.value.score.answeredTopics === 0) {
81
+ ctx.log("audit document has no answered topics");
82
+ ctx.log(
83
+ `please answer security topics in ${SECURITY_AUDIT_FILE_NAME} by adding responsible people and check/cross in the table`,
84
+ );
85
+ process.exitCode = 1;
86
+ return;
87
+ }
88
+
89
+ ctx.log(makeSecurityAuditOverview(evaluation.value));
90
+ },
91
+ });
@@ -0,0 +1,58 @@
1
+ import { defineCommand } from "../../core/defineCommand";
2
+ import { Gitlab } from "@gitbeaker/rest";
3
+ import { createSecurityAuditMergeRequest } from "../../security/createSecurityAuditMergeRequest";
4
+
5
+ const GITLAB_HOST = "https://git.panter.ch";
6
+
7
+ export const commandSecurityAuditCreate = defineCommand({
8
+ name: "security-audit-create",
9
+ description: "Creates a MR with the latest security audit template document",
10
+ group: "security",
11
+ inputs: {
12
+ token: {
13
+ type: "string",
14
+ message: "GitLab token (api scope)",
15
+ positional: true,
16
+ },
17
+ mainBranch: {
18
+ type: "string",
19
+ message: "main branch name",
20
+ positional: true,
21
+ },
22
+ projectId: {
23
+ type: "string",
24
+ message: "GitLab project ID",
25
+ positional: true,
26
+ },
27
+ userId: {
28
+ type: "string",
29
+ message: "GitLab user ID (assignee)",
30
+ positional: true,
31
+ },
32
+ },
33
+ execute: async (ctx) => {
34
+ const token = await ctx.get("token");
35
+ const mainBranch = await ctx.get("mainBranch");
36
+ const projectId = await ctx.get("projectId");
37
+ const userId = await ctx.get("userId");
38
+
39
+ const api = new Gitlab({ host: GITLAB_HOST, token });
40
+
41
+ const result = await createSecurityAuditMergeRequest({
42
+ api,
43
+ mainBranch,
44
+ projectId,
45
+ userId: parseInt(userId),
46
+ });
47
+
48
+ if (result.isErr()) {
49
+ ctx.log(`could not create security audit merge request: ${result.error}`);
50
+ process.exitCode = 1;
51
+ } else {
52
+ ctx.log("security audit merge request created successfully");
53
+ ctx.log(
54
+ `please finish the MR by updating SECURITY.md document: ${result.value.web_url}`,
55
+ );
56
+ }
57
+ },
58
+ });
@@ -0,0 +1,30 @@
1
+ import { defineCommand } from "../../core/defineCommand";
2
+ import {
3
+ evaluateSecurityAudit,
4
+ makeSecurityAuditOverview,
5
+ } from "../../security/evaluateSecurityAudit";
6
+ import { SECURITY_AUDIT_FILE_NAME } from "../../security/createSecurityAuditMergeRequest";
7
+
8
+ export const commandSecurityAuditEvaluate = defineCommand({
9
+ name: "security-audit-evaluate",
10
+ description: "Evaluates security audit document in given path",
11
+ group: "security",
12
+ inputs: {
13
+ path: { type: "string", message: "path to project root", positional: true },
14
+ },
15
+ execute: async (ctx) => {
16
+ const path = await ctx.get("path");
17
+ ctx.log("evaluating security audit document...");
18
+
19
+ const result = await evaluateSecurityAudit({ path });
20
+ if (result.isErr()) {
21
+ ctx.log(`${result.error}`);
22
+ ctx.log(
23
+ `please make sure the security audit document ${SECURITY_AUDIT_FILE_NAME} is in the repository`,
24
+ );
25
+ process.exitCode = 1;
26
+ } else {
27
+ ctx.log(makeSecurityAuditOverview(result.value));
28
+ }
29
+ },
30
+ });
package/bin/catci DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- // tslint:disable-next-line:no-var-requires
3
- require("../dist/bundles/catci/index.js");
package/bin/catci-dev DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- // tslint:disable-next-line:no-var-requires
3
- require("../dist/cli/src/catci.js");