@catladder/cli 0.0.0-refactor-docker-de6b3576 → 0.0.0-refactor-docker-427f63d6

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
@@ -52,7 +52,7 @@
52
52
  }
53
53
  ],
54
54
  "license": "MIT",
55
- "version": "0.0.0-refactor-docker-de6b3576",
55
+ "version": "0.0.0-refactor-docker-427f63d6",
56
56
  "scripts": {
57
57
  "lint": "eslint \"src/**/*.ts\"",
58
58
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -11,13 +11,14 @@ export default async (choice?: Choice) => {
11
11
  return;
12
12
  }
13
13
 
14
- if (config.pipelineType) {
15
- await generatePipelineFiles(config, config.pipelineType, "local");
16
- }
17
-
18
- await writeDotEnvFiles(config, choice);
14
+ await Promise.all([
15
+ config.pipelineType
16
+ ? generatePipelineFiles(config, config.pipelineType, "local")
17
+ : undefined,
18
+ writeDotEnvFiles(config, choice),
19
19
 
20
- await writeDTsFiles(config, choice);
20
+ writeDTsFiles(config, choice),
21
21
 
22
- await printVariables(config, choice);
22
+ printVariables(config, choice),
23
+ ]);
23
24
  };
@@ -114,20 +114,36 @@ type GitlabVariable = {
114
114
  environment_scope: string;
115
115
  };
116
116
  export const getAllVariables = memoizee(
117
- async (vorpal: CommandInstance | null): Promise<Array<GitlabVariable>> => {
117
+ async (
118
+ vorpal: CommandInstance | null,
119
+ n = 5, // how many requests to do in parallel, 5 seems a good value for many projects, ideally we would do one request in parallel per component
120
+ ): Promise<Array<GitlabVariable>> => {
118
121
  const { id } = await getProjectInfo(vorpal);
122
+
119
123
  let all: Array<GitlabVariable> = [];
120
- let result: Array<GitlabVariable>;
124
+ let result: Array<Array<GitlabVariable>> = [];
121
125
  let page = 1;
126
+
122
127
  do {
123
- result = await doGitlabRequest(
124
- vorpal,
125
- // 100 is max page size
126
- `projects/${id}/variables?per_page=100&page=${page}`,
127
- );
128
- page++;
129
- all = [...all, ...result];
130
- } while (result?.length > 0);
128
+ // Create an array of promises for N pages
129
+ const promises = Array.from({ length: n }, (_, i) => {
130
+ return doGitlabRequest(
131
+ vorpal,
132
+ `projects/${id}/variables?per_page=100&page=${page + i}`,
133
+ );
134
+ });
135
+
136
+ // Wait for all promises to resolve
137
+ result = await Promise.all(promises);
138
+
139
+ // Increment the page by N
140
+ page += n;
141
+
142
+ // Flatten the result array and add it to 'all'
143
+ all = [...all, ...result.flat()];
144
+ // Continue only if the last page had results
145
+ } while (result.length > 0 && result[result.length - 1].length > 0);
146
+
131
147
  return all;
132
148
  },
133
149
  { promise: true },