@catladder/cli 3.3.0 → 3.5.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/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "3.3.0",
56
+ "version": "3.5.0",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -1,12 +1,14 @@
1
1
  import type Vorpal from "vorpal";
2
2
  import { setupProject } from "./setup";
3
+ import { allComponents } from "./utils/autocompletions";
3
4
 
4
5
  export default async (vorpal: Vorpal) =>
5
6
  vorpal
6
7
  .command(
7
- "project-setup",
8
+ "project-setup [component]",
8
9
  "Initializes all environments and creates requires resources, service accounts, etc.",
9
10
  )
10
- .action(async function () {
11
- await setupProject(this);
11
+ .autocomplete(await allComponents())
12
+ .action(async function ({ component }) {
13
+ await setupProject(this, component);
12
14
  });
@@ -4,15 +4,20 @@ import { setupAccessTokens } from "./setupAccessTokens";
4
4
  import { setupContext } from "./setupContext";
5
5
  import { setupTopic } from "./setupTopic";
6
6
 
7
- export const setupProject = async (instance: CommandInstance) => {
8
- const allContext = await getAllPipelineContexts();
9
-
7
+ export const setupProject = async (
8
+ instance: CommandInstance,
9
+ onlyComponents?: string | string[],
10
+ ) => {
11
+ const allContext = await getAllPipelineContexts(onlyComponents);
12
+ instance.log("will setup those contexts:");
13
+ allContext.forEach((context) => {
14
+ instance.log(` - ${context.name}:${context.env}`);
15
+ });
10
16
  for (const context of allContext) {
11
17
  await setupContext(instance, context);
12
18
  }
13
19
  await setupAccessTokens(instance);
14
20
  await setupTopic(instance);
15
-
16
21
  instance.log("");
17
22
  instance.log("gitlab is ready! 🥂");
18
23
  instance.log("\n");
@@ -12,6 +12,15 @@ export const allEnvs = async () => {
12
12
  return getAllEnvsInAllComponents(config);
13
13
  };
14
14
 
15
+ export const allComponents = async () => {
16
+ const config = await getProjectConfig();
17
+ if (!config) {
18
+ return [];
19
+ }
20
+
21
+ return Object.keys(config.components);
22
+ };
23
+
15
24
  export const envAndComponents = async () => {
16
25
  const allEnvAndcomponents = await getAllComponentsWithAllEnvsFlat();
17
26
 
@@ -94,10 +94,21 @@ export const getAllComponentsWithAllEnvsHierarchical = async (): Promise<{
94
94
  );
95
95
  };
96
96
 
97
- export const getAllPipelineContexts = async () => {
97
+ export const getAllPipelineContexts = async (
98
+ onlyComponent?: string | string[],
99
+ ) => {
100
+ const onlyComponentsArray = onlyComponent
101
+ ? Array.isArray(onlyComponent)
102
+ ? onlyComponent
103
+ : [onlyComponent]
104
+ : null;
98
105
  return Promise.all(
99
106
  (await getAllComponentsWithAllEnvsFlat())
100
107
  .filter((c) => c.env !== "local")
108
+ .filter(
109
+ (c) =>
110
+ !onlyComponentsArray || onlyComponentsArray.includes(c.componentName),
111
+ )
101
112
  .map(({ env, componentName }) =>
102
113
  getPipelineContextByChoice(env, componentName),
103
114
  ),