@intra-mart/accel 0.4.0 → 0.5.0-dev.202608030656
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/README.md +71 -4
- package/dist/asset/deployer.js +3 -4
- package/dist/asset/git-provider.js +53 -25
- package/dist/asset/installer.d.ts +4 -1
- package/dist/asset/installer.js +13 -0
- package/dist/asset/updater.d.ts +6 -1
- package/dist/asset/updater.js +122 -23
- package/dist/commands/cache.d.ts +1 -0
- package/dist/commands/cache.js +74 -0
- package/dist/commands/switch.d.ts +24 -0
- package/dist/commands/switch.js +203 -0
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/git/object-cache.d.ts +12 -0
- package/dist/git/object-cache.js +95 -0
- package/dist/git/object-store.d.ts +3 -1
- package/dist/git/object-store.js +49 -9
- package/dist/i18n/en.js +24 -0
- package/dist/i18n/ja.js +24 -0
- package/dist/i18n/zh_CN.js +24 -0
- package/dist/index.js +4 -0
- package/dist/interactive/prompts.d.ts +4 -1
- package/dist/interactive/prompts.js +51 -43
- package/dist/utils/concurrency.d.ts +1 -0
- package/dist/utils/concurrency.js +1 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/hash.js +5 -0
- package/dist/utils/safe-rel-path.d.ts +1 -0
- package/dist/utils/safe-rel-path.js +5 -0
- package/dist/utils/settings-io.js +3 -1
- package/package.json +1 -1
|
@@ -101,6 +101,54 @@ export const printIntro = (mode, locale) => {
|
|
|
101
101
|
p.intro("Accel CLI");
|
|
102
102
|
p.note(getMessage(`intro.${mode}`, locale));
|
|
103
103
|
};
|
|
104
|
+
export const promptModules = async (release, initialValues, locale) => {
|
|
105
|
+
const releaseArtifactIds = release.modules.map((m) => m.artifactId);
|
|
106
|
+
const modules = (await p.multiselect({
|
|
107
|
+
message: withHint("prompt.modules", locale),
|
|
108
|
+
options: release.modules.map((m) => ({
|
|
109
|
+
value: m.artifactId,
|
|
110
|
+
label: resolveLabel(m.labels, locale),
|
|
111
|
+
})),
|
|
112
|
+
initialValues: initialValues.filter((m) => releaseArtifactIds.includes(m)),
|
|
113
|
+
required: true,
|
|
114
|
+
}));
|
|
115
|
+
if (p.isCancel(modules))
|
|
116
|
+
process.exit(0);
|
|
117
|
+
return modules;
|
|
118
|
+
};
|
|
119
|
+
export const promptFeatures = async (release, initialValues, locale) => {
|
|
120
|
+
if (release.functions.length === 0) {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
const featureIds = release.functions.map((f) => f.id);
|
|
124
|
+
const selected = (await p.multiselect({
|
|
125
|
+
message: withHint("prompt.features", locale),
|
|
126
|
+
options: release.functions.map((f) => ({
|
|
127
|
+
value: f.id,
|
|
128
|
+
label: resolveLabel(f.labels, locale),
|
|
129
|
+
})),
|
|
130
|
+
initialValues: initialValues?.filter((f) => featureIds.includes(f)) ?? featureIds,
|
|
131
|
+
required: true,
|
|
132
|
+
}));
|
|
133
|
+
if (p.isCancel(selected))
|
|
134
|
+
process.exit(0);
|
|
135
|
+
return selected;
|
|
136
|
+
};
|
|
137
|
+
export const promptAgents = async (initialValues, locale) => {
|
|
138
|
+
const detected = detectAgents();
|
|
139
|
+
const defaults = initialValues?.filter((a) => AGENT_OPTIONS.includes(a)) ??
|
|
140
|
+
(detected.length > 0
|
|
141
|
+
? detected.map((a) => a.name)
|
|
142
|
+
: [...AGENT_OPTIONS]);
|
|
143
|
+
const agents = (await p.multiselect({
|
|
144
|
+
message: withHint("prompt.agent", locale),
|
|
145
|
+
options: AGENT_OPTIONS.map((a) => ({ value: a, label: a })),
|
|
146
|
+
initialValues: defaults,
|
|
147
|
+
}));
|
|
148
|
+
if (p.isCancel(agents))
|
|
149
|
+
process.exit(0);
|
|
150
|
+
return agents;
|
|
151
|
+
};
|
|
104
152
|
export const runPrompts = async (opts) => {
|
|
105
153
|
const locale = opts.locale;
|
|
106
154
|
const validators = createValidators(locale);
|
|
@@ -247,36 +295,8 @@ export const runPrompts = async (opts) => {
|
|
|
247
295
|
p.log.warning(getMessage("warning.moduleMismatch", locale));
|
|
248
296
|
}
|
|
249
297
|
}
|
|
250
|
-
const modules =
|
|
251
|
-
|
|
252
|
-
options: release.modules.map((m) => ({
|
|
253
|
-
value: m.artifactId,
|
|
254
|
-
label: resolveLabel(m.labels, locale),
|
|
255
|
-
})),
|
|
256
|
-
initialValues: moduleDefault,
|
|
257
|
-
required: true,
|
|
258
|
-
}));
|
|
259
|
-
if (p.isCancel(modules))
|
|
260
|
-
process.exit(0);
|
|
261
|
-
let features;
|
|
262
|
-
if (release.functions.length === 0) {
|
|
263
|
-
features = [];
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
const featureIds = release.functions.map((f) => f.id);
|
|
267
|
-
const selected = (await p.multiselect({
|
|
268
|
-
message: withHint("prompt.features", locale),
|
|
269
|
-
options: release.functions.map((f) => ({
|
|
270
|
-
value: f.id,
|
|
271
|
-
label: resolveLabel(f.labels, locale),
|
|
272
|
-
})),
|
|
273
|
-
initialValues: opts.feature?.filter((f) => featureIds.includes(f)) ?? featureIds,
|
|
274
|
-
required: true,
|
|
275
|
-
}));
|
|
276
|
-
if (p.isCancel(selected))
|
|
277
|
-
process.exit(0);
|
|
278
|
-
features = selected;
|
|
279
|
-
}
|
|
298
|
+
const modules = await promptModules(release, moduleDefault, locale);
|
|
299
|
+
const features = await promptFeatures(release, opts.feature, locale);
|
|
280
300
|
const group = (await p.text({
|
|
281
301
|
message: withHint("prompt.group", locale),
|
|
282
302
|
defaultValue: opts.group ?? DEFAULT_SETTINGS.group,
|
|
@@ -313,19 +333,7 @@ export const runPrompts = async (opts) => {
|
|
|
313
333
|
}));
|
|
314
334
|
if (p.isCancel(javascript))
|
|
315
335
|
process.exit(0);
|
|
316
|
-
const
|
|
317
|
-
const agentOptions = AGENT_OPTIONS.map((a) => ({ value: a, label: a }));
|
|
318
|
-
const defaultAgents = opts.agent?.filter((a) => AGENT_OPTIONS.includes(a)) ??
|
|
319
|
-
(detected.length > 0
|
|
320
|
-
? detected.map((a) => a.name)
|
|
321
|
-
: [...AGENT_OPTIONS]);
|
|
322
|
-
const agents = (await p.multiselect({
|
|
323
|
-
message: withHint("prompt.agent", locale),
|
|
324
|
-
options: agentOptions,
|
|
325
|
-
initialValues: defaultAgents,
|
|
326
|
-
}));
|
|
327
|
-
if (p.isCancel(agents))
|
|
328
|
-
process.exit(0);
|
|
336
|
+
const agents = await promptAgents(opts.agent, locale);
|
|
329
337
|
let withGit = opts.withGit ?? true;
|
|
330
338
|
if (opts.isInit) {
|
|
331
339
|
withGit = (await p.confirm({
|
package/dist/utils/hash.d.ts
CHANGED
package/dist/utils/hash.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isSafeRelPath: (p: string) => boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { isSafeRelPath } from "./safe-rel-path.js";
|
|
3
4
|
const ACCEL_DIR = ".accel";
|
|
4
5
|
const SETTINGS_FILE = "settings.json";
|
|
5
6
|
const HASHSUM_FILE = "hashsum.txt";
|
|
@@ -46,7 +47,8 @@ export const parseHashsum = (content) => {
|
|
|
46
47
|
version: match[2],
|
|
47
48
|
sha1: match[3],
|
|
48
49
|
};
|
|
49
|
-
})
|
|
50
|
+
})
|
|
51
|
+
.filter((e) => isSafeRelPath(e.filePath));
|
|
50
52
|
};
|
|
51
53
|
export const writeHashsum = async (projectDir, entries) => {
|
|
52
54
|
const accelDir = await ensureAccelDir(projectDir);
|