@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/dist/bundles/catenv/index.js +1 -1
- package/dist/bundles/cli/index.js +1 -1
- package/dist/cli/src/apps/cli/commands/project/commandSetup.js +5 -3
- package/dist/cli/src/apps/cli/commands/project/commandSetup.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/index.d.ts +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/index.js +6 -2
- package/dist/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/utils/autocompletions.d.ts +1 -0
- package/dist/cli/src/apps/cli/commands/project/utils/autocompletions.js +9 -1
- package/dist/cli/src/apps/cli/commands/project/utils/autocompletions.js.map +1 -1
- package/dist/cli/src/config/getProjectConfig.d.ts +1 -1
- package/dist/cli/src/config/getProjectConfig.js +7 -1
- package/dist/cli/src/config/getProjectConfig.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/apps/cli/commands/project/commandSetup.ts +5 -3
- package/src/apps/cli/commands/project/setup/index.ts +9 -4
- package/src/apps/cli/commands/project/utils/autocompletions.ts +9 -0
- package/src/config/getProjectConfig.ts +12 -1
package/package.json
CHANGED
|
@@ -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
|
-
.
|
|
11
|
-
|
|
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 (
|
|
8
|
-
|
|
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
|
),
|