@intra-mart/accel 0.1.0 → 0.3.0-next.202605250439
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 +67 -5
- package/assets/assets.tar.gz +0 -0
- package/dist/asset/deployer.d.ts +13 -0
- package/dist/asset/deployer.js +84 -13
- package/dist/asset/walker.js +2 -0
- package/dist/commands/attach.d.ts +9 -0
- package/dist/commands/attach.js +84 -3
- package/dist/commands/deploy.d.ts +26 -0
- package/dist/commands/deploy.js +188 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.js +20 -1
- package/dist/core/condition-evaluator.js +7 -1
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.js +8 -1
- package/dist/core/types.d.ts +51 -1
- package/dist/core/types.js +2 -0
- package/dist/core/validators.d.ts +2 -1
- package/dist/core/validators.js +58 -25
- package/dist/core/variable-interpolator.js +1 -0
- package/dist/deploy/api-client.d.ts +15 -0
- package/dist/deploy/api-client.js +81 -0
- package/dist/deploy/target-scanner.d.ts +5 -0
- package/dist/deploy/target-scanner.js +20 -0
- package/dist/i18n/en.js +80 -4
- package/dist/i18n/ja.js +83 -7
- package/dist/i18n/zh_CN.js +83 -7
- package/dist/index.js +2 -0
- package/dist/interactive/credentials-prompts.d.ts +2 -0
- package/dist/interactive/credentials-prompts.js +43 -0
- package/dist/interactive/format.d.ts +2 -0
- package/dist/interactive/format.js +33 -0
- package/dist/interactive/next-steps.d.ts +8 -0
- package/dist/interactive/next-steps.js +22 -0
- package/dist/interactive/progress.d.ts +2 -0
- package/dist/interactive/progress.js +21 -0
- package/dist/interactive/prompts.d.ts +1 -0
- package/dist/interactive/prompts.js +74 -15
- package/dist/interactive/summary.d.ts +3 -0
- package/dist/interactive/summary.js +58 -0
- package/dist/utils/credentials.d.ts +5 -0
- package/dist/utils/credentials.js +25 -0
- package/dist/utils/gitignore.d.ts +1 -0
- package/dist/utils/gitignore.js +23 -0
- package/package.json +2 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as p from "@clack/prompts";
|
|
2
|
-
import {
|
|
2
|
+
import { SELECTABLE_VERSIONS, } from "../core/version-map.js";
|
|
3
|
+
import { MODULE_OPTIONS, DATABASE_OPTIONS, AGENT_OPTIONS, DEFAULT_SETTINGS, } from "../core/constants.js";
|
|
3
4
|
import { createValidators } from "../core/validators.js";
|
|
4
5
|
import { getMessage } from "../i18n/index.js";
|
|
6
|
+
import { withHint } from "./format.js";
|
|
5
7
|
import { detectAgents, detectDefaultAgents } from "./agent-detect.js";
|
|
6
8
|
import { parseJugglingFile } from "../juggling/parser.js";
|
|
7
9
|
import { extractVersionLabel, extractModules, } from "../juggling/extractor.js";
|
|
@@ -24,6 +26,12 @@ export const validateNonInteractive = (opts) => {
|
|
|
24
26
|
const missing = [];
|
|
25
27
|
if (!opts.name)
|
|
26
28
|
missing.push("--name");
|
|
29
|
+
if (!opts.jugglingProject) {
|
|
30
|
+
if (!opts.accelplatformVersion)
|
|
31
|
+
missing.push("--accelplatform-version");
|
|
32
|
+
if (!opts.module || opts.module.length === 0)
|
|
33
|
+
missing.push("--module");
|
|
34
|
+
}
|
|
27
35
|
return missing;
|
|
28
36
|
};
|
|
29
37
|
export const validateCliValues = (opts, validators) => {
|
|
@@ -71,6 +79,11 @@ export const validateCliValues = (opts, validators) => {
|
|
|
71
79
|
throw new Error(err);
|
|
72
80
|
}
|
|
73
81
|
}
|
|
82
|
+
if (opts.packageManager !== undefined) {
|
|
83
|
+
const err = validators.packageManager(opts.packageManager);
|
|
84
|
+
if (err)
|
|
85
|
+
throw new Error(err);
|
|
86
|
+
}
|
|
74
87
|
};
|
|
75
88
|
export const runPrompts = async (opts) => {
|
|
76
89
|
const locale = opts.locale;
|
|
@@ -97,19 +110,27 @@ export const runPrompts = async (opts) => {
|
|
|
97
110
|
group: opts.group ?? DEFAULT_SETTINGS.group,
|
|
98
111
|
projectVersion: opts.projectVersion ?? DEFAULT_SETTINGS.projectVersion,
|
|
99
112
|
description: opts.description ?? DEFAULT_SETTINGS.description,
|
|
100
|
-
accelplatformVersion:
|
|
101
|
-
|
|
113
|
+
accelplatformVersion: opts.accelplatformVersion ??
|
|
114
|
+
jugglingVersion ??
|
|
115
|
+
DEFAULT_SETTINGS.accelplatformVersion,
|
|
116
|
+
modules: opts.module && opts.module.length > 0
|
|
117
|
+
? opts.module
|
|
118
|
+
: jugglingModules.length > 0
|
|
119
|
+
? jugglingModules
|
|
120
|
+
: [],
|
|
102
121
|
database: (opts.database ?? DEFAULT_SETTINGS.database),
|
|
103
122
|
agents: opts.agent ?? detectDefaultAgents(),
|
|
104
123
|
javascript: opts.javascript ?? DEFAULT_SETTINGS.javascript,
|
|
105
124
|
locale,
|
|
125
|
+
packageManager: opts.packageManager ?? DEFAULT_SETTINGS.packageManager,
|
|
106
126
|
jugglingProject: opts.jugglingProject ?? null,
|
|
107
127
|
withGit: opts.withGit ?? true,
|
|
108
128
|
};
|
|
109
129
|
}
|
|
110
130
|
p.intro("Accel CLI");
|
|
131
|
+
p.note(getMessage(opts.isInit ? "intro.init" : "intro.attach", locale));
|
|
111
132
|
const name = (await p.text({
|
|
112
|
-
message:
|
|
133
|
+
message: withHint("prompt.name", locale),
|
|
113
134
|
defaultValue: opts.name ?? DEFAULT_SETTINGS.name,
|
|
114
135
|
initialValue: opts.name ?? DEFAULT_SETTINGS.name,
|
|
115
136
|
validate: validators.name,
|
|
@@ -118,7 +139,7 @@ export const runPrompts = async (opts) => {
|
|
|
118
139
|
process.exit(0);
|
|
119
140
|
const artifactIdInitial = opts.artifactId ?? name;
|
|
120
141
|
const artifactId = (await p.text({
|
|
121
|
-
message:
|
|
142
|
+
message: withHint("prompt.artifactId", locale),
|
|
122
143
|
defaultValue: artifactIdInitial,
|
|
123
144
|
initialValue: artifactIdInitial,
|
|
124
145
|
validate: validators.artifactId,
|
|
@@ -126,7 +147,7 @@ export const runPrompts = async (opts) => {
|
|
|
126
147
|
if (p.isCancel(artifactId))
|
|
127
148
|
process.exit(0);
|
|
128
149
|
const jugglingInput = (await p.text({
|
|
129
|
-
message:
|
|
150
|
+
message: withHint("prompt.jugglingProject", locale),
|
|
130
151
|
defaultValue: opts.jugglingProject ?? "",
|
|
131
152
|
initialValue: opts.jugglingProject ?? "",
|
|
132
153
|
}));
|
|
@@ -148,10 +169,47 @@ export const runPrompts = async (opts) => {
|
|
|
148
169
|
p.log.warning(err instanceof Error ? err.message : String(err));
|
|
149
170
|
}
|
|
150
171
|
}
|
|
151
|
-
const
|
|
152
|
-
|
|
172
|
+
const versionDefault = opts.accelplatformVersion ?? jugglingVersion ?? DEFAULT_SETTINGS.accelplatformVersion;
|
|
173
|
+
if (opts.accelplatformVersion && jugglingVersion && opts.accelplatformVersion !== jugglingVersion) {
|
|
174
|
+
p.log.warning(getMessage("warning.versionMismatch", locale, {
|
|
175
|
+
option: opts.accelplatformVersion,
|
|
176
|
+
juggling: jugglingVersion,
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
const accelplatformVersion = (await p.select({
|
|
180
|
+
message: withHint("prompt.accelplatformVersion", locale),
|
|
181
|
+
options: SELECTABLE_VERSIONS.map((v) => ({
|
|
182
|
+
value: v.label,
|
|
183
|
+
label: `${v.label} (${v.codename})`,
|
|
184
|
+
})),
|
|
185
|
+
initialValue: versionDefault,
|
|
186
|
+
}));
|
|
187
|
+
if (p.isCancel(accelplatformVersion))
|
|
188
|
+
process.exit(0);
|
|
189
|
+
const moduleDefault = opts.module && opts.module.length > 0
|
|
190
|
+
? opts.module
|
|
191
|
+
: jugglingModules.length > 0
|
|
192
|
+
? jugglingModules
|
|
193
|
+
: [];
|
|
194
|
+
if (opts.module && opts.module.length > 0 && jugglingModules.length > 0) {
|
|
195
|
+
const diff = opts.module.some((m) => !jugglingModules.includes(m)) ||
|
|
196
|
+
jugglingModules.some((m) => !opts.module.includes(m));
|
|
197
|
+
if (diff) {
|
|
198
|
+
p.log.warning(getMessage("warning.moduleMismatch", locale));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const modules = (await p.multiselect({
|
|
202
|
+
message: withHint("prompt.modules", locale),
|
|
203
|
+
options: MODULE_OPTIONS.map((m) => ({
|
|
204
|
+
value: m,
|
|
205
|
+
label: m,
|
|
206
|
+
})),
|
|
207
|
+
initialValues: moduleDefault,
|
|
208
|
+
}));
|
|
209
|
+
if (p.isCancel(modules))
|
|
210
|
+
process.exit(0);
|
|
153
211
|
const group = (await p.text({
|
|
154
|
-
message:
|
|
212
|
+
message: withHint("prompt.group", locale),
|
|
155
213
|
defaultValue: opts.group ?? DEFAULT_SETTINGS.group,
|
|
156
214
|
initialValue: opts.group ?? DEFAULT_SETTINGS.group,
|
|
157
215
|
validate: validators.group,
|
|
@@ -159,7 +217,7 @@ export const runPrompts = async (opts) => {
|
|
|
159
217
|
if (p.isCancel(group))
|
|
160
218
|
process.exit(0);
|
|
161
219
|
const projectVersion = (await p.text({
|
|
162
|
-
message:
|
|
220
|
+
message: withHint("prompt.projectVersion", locale),
|
|
163
221
|
defaultValue: opts.projectVersion ?? DEFAULT_SETTINGS.projectVersion,
|
|
164
222
|
initialValue: opts.projectVersion ?? DEFAULT_SETTINGS.projectVersion,
|
|
165
223
|
validate: validators.projectVersion,
|
|
@@ -167,21 +225,21 @@ export const runPrompts = async (opts) => {
|
|
|
167
225
|
if (p.isCancel(projectVersion))
|
|
168
226
|
process.exit(0);
|
|
169
227
|
const description = (await p.text({
|
|
170
|
-
message:
|
|
228
|
+
message: withHint("prompt.description", locale),
|
|
171
229
|
defaultValue: opts.description ?? DEFAULT_SETTINGS.description,
|
|
172
230
|
initialValue: opts.description ?? DEFAULT_SETTINGS.description,
|
|
173
231
|
}));
|
|
174
232
|
if (p.isCancel(description))
|
|
175
233
|
process.exit(0);
|
|
176
234
|
const database = (await p.select({
|
|
177
|
-
message:
|
|
235
|
+
message: withHint("prompt.database", locale),
|
|
178
236
|
options: DATABASE_OPTIONS.map((d) => ({ value: d, label: d })),
|
|
179
237
|
initialValue: opts.database ?? DEFAULT_SETTINGS.database,
|
|
180
238
|
}));
|
|
181
239
|
if (p.isCancel(database))
|
|
182
240
|
process.exit(0);
|
|
183
241
|
const javascript = (await p.confirm({
|
|
184
|
-
message:
|
|
242
|
+
message: withHint("prompt.javascript", locale),
|
|
185
243
|
initialValue: opts.javascript ?? DEFAULT_SETTINGS.javascript,
|
|
186
244
|
}));
|
|
187
245
|
if (p.isCancel(javascript))
|
|
@@ -193,7 +251,7 @@ export const runPrompts = async (opts) => {
|
|
|
193
251
|
? detected.map((a) => a.name)
|
|
194
252
|
: [...AGENT_OPTIONS]);
|
|
195
253
|
const agents = (await p.multiselect({
|
|
196
|
-
message:
|
|
254
|
+
message: withHint("prompt.agent", locale),
|
|
197
255
|
options: agentOptions,
|
|
198
256
|
initialValues: defaultAgents,
|
|
199
257
|
}));
|
|
@@ -202,7 +260,7 @@ export const runPrompts = async (opts) => {
|
|
|
202
260
|
let withGit = opts.withGit ?? true;
|
|
203
261
|
if (opts.isInit) {
|
|
204
262
|
withGit = (await p.confirm({
|
|
205
|
-
message:
|
|
263
|
+
message: withHint("prompt.withGit", locale),
|
|
206
264
|
initialValue: opts.withGit ?? true,
|
|
207
265
|
}));
|
|
208
266
|
if (p.isCancel(withGit))
|
|
@@ -220,6 +278,7 @@ export const runPrompts = async (opts) => {
|
|
|
220
278
|
agents,
|
|
221
279
|
javascript,
|
|
222
280
|
locale,
|
|
281
|
+
packageManager: opts.packageManager ?? DEFAULT_SETTINGS.packageManager,
|
|
223
282
|
jugglingProject,
|
|
224
283
|
withGit,
|
|
225
284
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
2
|
+
import { getMessage } from "../i18n/index.js";
|
|
3
|
+
import { displayWidth } from "./format.js";
|
|
4
|
+
const formatList = (values, emptyLabel) => values.length > 0 ? values.join(", ") : emptyLabel;
|
|
5
|
+
const formatString = (value, emptyLabel) => value.length > 0 ? value : emptyLabel;
|
|
6
|
+
const formatBoolean = (value) => (value ? "true" : "false");
|
|
7
|
+
export const buildSummaryBody = (settings, outputDir, locale) => {
|
|
8
|
+
const empty = getMessage("summary.empty", locale);
|
|
9
|
+
const rows = [
|
|
10
|
+
{ labelKey: "summary.label.name", value: settings.name },
|
|
11
|
+
{ labelKey: "summary.label.artifactId", value: settings.artifactId },
|
|
12
|
+
{ labelKey: "summary.label.group", value: settings.group },
|
|
13
|
+
{ labelKey: "summary.label.projectVersion", value: settings.projectVersion },
|
|
14
|
+
{
|
|
15
|
+
labelKey: "summary.label.description",
|
|
16
|
+
value: formatString(settings.description, empty),
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
labelKey: "summary.label.accelplatformVersion",
|
|
20
|
+
value: settings.accelplatformVersion,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
labelKey: "summary.label.modules",
|
|
24
|
+
value: formatList(settings.modules, empty),
|
|
25
|
+
},
|
|
26
|
+
{ labelKey: "summary.label.database", value: settings.database },
|
|
27
|
+
{
|
|
28
|
+
labelKey: "summary.label.javascript",
|
|
29
|
+
value: formatBoolean(settings.javascript),
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
labelKey: "summary.label.agents",
|
|
33
|
+
value: formatList(settings.agents, empty),
|
|
34
|
+
},
|
|
35
|
+
{ labelKey: "summary.label.locale", value: settings.locale },
|
|
36
|
+
{
|
|
37
|
+
labelKey: "summary.label.packageManager",
|
|
38
|
+
value: settings.packageManager,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
labelKey: "summary.label.jugglingProject",
|
|
42
|
+
value: settings.jugglingProject ?? empty,
|
|
43
|
+
},
|
|
44
|
+
{ labelKey: "summary.outputDir", value: outputDir },
|
|
45
|
+
];
|
|
46
|
+
const labels = rows.map((r) => getMessage(r.labelKey, locale));
|
|
47
|
+
const maxLabelWidth = Math.max(...labels.map((l) => displayWidth(l)));
|
|
48
|
+
return rows
|
|
49
|
+
.map((row, i) => {
|
|
50
|
+
const label = labels[i];
|
|
51
|
+
const pad = " ".repeat(Math.max(0, maxLabelWidth - displayWidth(label)));
|
|
52
|
+
return `${label}${pad} : ${row.value}`;
|
|
53
|
+
})
|
|
54
|
+
.join("\n");
|
|
55
|
+
};
|
|
56
|
+
export const printSummary = (settings, outputDir, locale) => {
|
|
57
|
+
p.note(buildSummaryBody(settings, outputDir, locale), getMessage("summary.heading", locale));
|
|
58
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AccelCredentials } from "../core/types.js";
|
|
2
|
+
export declare const CREDENTIALS_GITIGNORE_ENTRY = ".accel/credentials.json";
|
|
3
|
+
export declare const normalizeEndpoint: (raw: string) => string;
|
|
4
|
+
export declare const readCredentials: (projectDir: string) => Promise<Partial<AccelCredentials>>;
|
|
5
|
+
export declare const writeCredentials: (projectDir: string, creds: AccelCredentials) => Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
const ACCEL_DIR = ".accel";
|
|
4
|
+
const CREDENTIALS_FILE = "credentials.json";
|
|
5
|
+
export const CREDENTIALS_GITIGNORE_ENTRY = `${ACCEL_DIR}/${CREDENTIALS_FILE}`;
|
|
6
|
+
export const normalizeEndpoint = (raw) => raw.trim().replace(/\/+$/, "");
|
|
7
|
+
export const readCredentials = async (projectDir) => {
|
|
8
|
+
const filePath = join(projectDir, ACCEL_DIR, CREDENTIALS_FILE);
|
|
9
|
+
try {
|
|
10
|
+
const content = await readFile(filePath, "utf-8");
|
|
11
|
+
const parsed = JSON.parse(content);
|
|
12
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
13
|
+
return {};
|
|
14
|
+
return parsed;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export const writeCredentials = async (projectDir, creds) => {
|
|
21
|
+
const accelDir = join(projectDir, ACCEL_DIR);
|
|
22
|
+
await mkdir(accelDir, { recursive: true });
|
|
23
|
+
const filePath = join(accelDir, CREDENTIALS_FILE);
|
|
24
|
+
await writeFile(filePath, JSON.stringify(creds, null, 2) + "\n", "utf-8");
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ensureGitignoreEntry: (projectDir: string, entry: string) => Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
export const ensureGitignoreEntry = async (projectDir, entry) => {
|
|
4
|
+
const gitignorePath = join(projectDir, ".gitignore");
|
|
5
|
+
let content = "";
|
|
6
|
+
try {
|
|
7
|
+
content = await readFile(gitignorePath, "utf-8");
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
content = "";
|
|
11
|
+
}
|
|
12
|
+
const alreadyPresent = content
|
|
13
|
+
.split("\n")
|
|
14
|
+
.some((line) => line.trim() === entry);
|
|
15
|
+
if (alreadyPresent)
|
|
16
|
+
return;
|
|
17
|
+
let next = content;
|
|
18
|
+
if (next.length > 0 && !next.endsWith("\n")) {
|
|
19
|
+
next += "\n";
|
|
20
|
+
}
|
|
21
|
+
next += `${entry}\n`;
|
|
22
|
+
await writeFile(gitignorePath, next, "utf-8");
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intra-mart/accel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-next.202605250439",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI tool for intra-mart Accel Platform development",
|
|
6
6
|
"author": "NTT DATA INTRAMART",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"prepublishOnly": "tsc"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@clack/prompts": "^
|
|
42
|
+
"@clack/prompts": "^1.4.0",
|
|
43
43
|
"citty": "^0.1.6",
|
|
44
44
|
"fast-xml-parser": "^5.2.0",
|
|
45
45
|
"remark": "^15.0.1",
|