@intra-mart/accel 0.3.0-next.202605250439 → 0.3.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/README.md +157 -41
- package/dist/asset/deployer.js +8 -17
- package/dist/asset/foreach-replacement.d.ts +2 -0
- package/dist/asset/foreach-replacement.js +20 -0
- package/dist/asset/github-provider.d.ts +2 -0
- package/dist/asset/github-provider.js +37 -0
- package/dist/asset/local-provider.js +1 -22
- package/dist/asset/walker.js +4 -15
- package/dist/commands/attach.d.ts +13 -1
- package/dist/commands/attach.js +33 -12
- package/dist/commands/deploy.d.ts +42 -3
- package/dist/commands/deploy.js +274 -40
- package/dist/commands/init.d.ts +13 -1
- package/dist/commands/init.js +33 -12
- package/dist/commands/login.d.ts +31 -0
- package/dist/commands/login.js +76 -0
- package/dist/core/catalog.d.ts +11 -0
- package/dist/core/catalog.js +40 -0
- package/dist/core/condition-evaluator.js +6 -3
- package/dist/core/constants.d.ts +3 -3
- package/dist/core/constants.js +6 -11
- package/dist/core/eval-context.d.ts +3 -0
- package/dist/core/eval-context.js +45 -0
- package/dist/core/types.d.ts +61 -12
- package/dist/core/types.js +2 -1
- package/dist/core/validators.d.ts +7 -2
- package/dist/core/validators.js +25 -12
- package/dist/core/variable-interpolator.d.ts +1 -1
- package/dist/core/variable-interpolator.js +19 -19
- package/dist/deploy/api-client.d.ts +5 -2
- package/dist/deploy/api-client.js +47 -1
- package/dist/deploy/target-selector.d.ts +11 -0
- package/dist/deploy/target-selector.js +16 -0
- package/dist/i18n/en.js +38 -5
- package/dist/i18n/ja.js +38 -5
- package/dist/i18n/zh_CN.js +38 -5
- package/dist/index.js +2 -0
- package/dist/interactive/agent-detect.js +1 -0
- package/dist/interactive/credential-auth.d.ts +15 -0
- package/dist/interactive/credential-auth.js +61 -0
- package/dist/interactive/credentials-prompts.d.ts +3 -1
- package/dist/interactive/credentials-prompts.js +50 -7
- package/dist/interactive/next-steps.js +3 -0
- package/dist/interactive/prompts.d.ts +3 -0
- package/dist/interactive/prompts.js +112 -52
- package/dist/interactive/summary.js +5 -1
- package/dist/juggling/extractor.d.ts +3 -2
- package/dist/juggling/extractor.js +9 -9
- package/dist/utils/args.d.ts +1 -0
- package/dist/utils/args.js +4 -0
- package/dist/utils/credentials.d.ts +7 -0
- package/dist/utils/credentials.js +21 -0
- package/dist/utils/date-formatter.d.ts +1 -0
- package/dist/utils/date-formatter.js +23 -0
- package/dist/utils/https.d.ts +2 -0
- package/dist/utils/https.js +44 -0
- package/dist/utils/mcp-sync.d.ts +4 -0
- package/dist/utils/mcp-sync.js +97 -0
- package/dist/utils/settings-io.d.ts +1 -0
- package/dist/utils/settings-io.js +8 -0
- package/package.json +6 -5
- package/assets/assets.tar.gz +0 -0
- package/dist/asset/default-source.d.ts +0 -1
- package/dist/asset/default-source.js +0 -6
- package/dist/core/module-map.d.ts +0 -3
- package/dist/core/module-map.js +0 -7
- package/dist/core/version-map.d.ts +0 -7
- package/dist/core/version-map.js +0 -45
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as p from "@clack/prompts";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { createValidators } from "../core/validators.js";
|
|
2
|
+
import { getReleases, findReleaseById, resolveLabel, } from "../core/catalog.js";
|
|
3
|
+
import { DATABASE_OPTIONS, AGENT_OPTIONS, DEFAULT_SETTINGS, } from "../core/constants.js";
|
|
4
|
+
import { createValidators, createReleaseValidators, } from "../core/validators.js";
|
|
5
5
|
import { getMessage } from "../i18n/index.js";
|
|
6
6
|
import { withHint } from "./format.js";
|
|
7
7
|
import { detectAgents, detectDefaultAgents } from "./agent-detect.js";
|
|
8
8
|
import { parseJugglingFile } from "../juggling/parser.js";
|
|
9
|
-
import {
|
|
9
|
+
import { extractVersion, extractModules, findRelease, } from "../juggling/extractor.js";
|
|
10
10
|
import { stat } from "node:fs/promises";
|
|
11
11
|
import { join } from "node:path";
|
|
12
12
|
const resolveJuggling = async (jugglingPath, locale) => {
|
|
@@ -18,19 +18,16 @@ const resolveJuggling = async (jugglingPath, locale) => {
|
|
|
18
18
|
throw new Error(getMessage("juggling.notFound", locale, { path: imPath }));
|
|
19
19
|
}
|
|
20
20
|
const data = await parseJugglingFile(imPath);
|
|
21
|
-
const
|
|
22
|
-
const modules = extractModules(data);
|
|
23
|
-
return {
|
|
21
|
+
const release = findRelease(data) ?? null;
|
|
22
|
+
const modules = release ? extractModules(data, release) : [];
|
|
23
|
+
return { release, baseVersion: extractVersion(data), modules };
|
|
24
24
|
};
|
|
25
25
|
export const validateNonInteractive = (opts) => {
|
|
26
26
|
const missing = [];
|
|
27
27
|
if (!opts.name)
|
|
28
28
|
missing.push("--name");
|
|
29
|
-
if (!opts.jugglingProject) {
|
|
30
|
-
|
|
31
|
-
missing.push("--accelplatform-version");
|
|
32
|
-
if (!opts.module || opts.module.length === 0)
|
|
33
|
-
missing.push("--module");
|
|
29
|
+
if (!opts.jugglingProject && !opts.accelplatformVersion) {
|
|
30
|
+
missing.push("--accelplatform-version");
|
|
34
31
|
}
|
|
35
32
|
return missing;
|
|
36
33
|
};
|
|
@@ -56,17 +53,10 @@ export const validateCliValues = (opts, validators) => {
|
|
|
56
53
|
throw new Error(err);
|
|
57
54
|
}
|
|
58
55
|
if (opts.accelplatformVersion !== undefined) {
|
|
59
|
-
const err = validators.
|
|
56
|
+
const err = validators.accelplatformVersion(opts.accelplatformVersion);
|
|
60
57
|
if (err)
|
|
61
58
|
throw new Error(err);
|
|
62
59
|
}
|
|
63
|
-
if (opts.module !== undefined) {
|
|
64
|
-
for (const m of opts.module) {
|
|
65
|
-
const err = validators.module(m);
|
|
66
|
-
if (err)
|
|
67
|
-
throw new Error(err);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
60
|
if (opts.database !== undefined) {
|
|
71
61
|
const err = validators.database(opts.database);
|
|
72
62
|
if (err)
|
|
@@ -85,6 +75,23 @@ export const validateCliValues = (opts, validators) => {
|
|
|
85
75
|
throw new Error(err);
|
|
86
76
|
}
|
|
87
77
|
};
|
|
78
|
+
export const validateCatalogValues = (opts, release, locale) => {
|
|
79
|
+
const releaseValidators = createReleaseValidators(locale, release);
|
|
80
|
+
if (opts.module !== undefined) {
|
|
81
|
+
for (const m of opts.module) {
|
|
82
|
+
const err = releaseValidators.module(m);
|
|
83
|
+
if (err)
|
|
84
|
+
throw new Error(err);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (opts.feature !== undefined) {
|
|
88
|
+
for (const f of opts.feature) {
|
|
89
|
+
const err = releaseValidators.feature(f);
|
|
90
|
+
if (err)
|
|
91
|
+
throw new Error(err);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
88
95
|
export const runPrompts = async (opts) => {
|
|
89
96
|
const locale = opts.locale;
|
|
90
97
|
const validators = createValidators(locale);
|
|
@@ -96,28 +103,42 @@ export const runPrompts = async (opts) => {
|
|
|
96
103
|
options: missing.join(", "),
|
|
97
104
|
}));
|
|
98
105
|
}
|
|
99
|
-
let
|
|
106
|
+
let jugglingRelease = null;
|
|
100
107
|
let jugglingModules = [];
|
|
101
108
|
if (opts.jugglingProject) {
|
|
102
109
|
const resolved = await resolveJuggling(opts.jugglingProject, locale);
|
|
103
|
-
|
|
110
|
+
if (!resolved.release) {
|
|
111
|
+
throw new Error(getMessage("error.jugglingVersionUnknown", locale, {
|
|
112
|
+
version: resolved.baseVersion,
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
jugglingRelease = resolved.release;
|
|
104
116
|
jugglingModules = resolved.modules;
|
|
105
117
|
}
|
|
106
118
|
const resolvedName = opts.name ?? DEFAULT_SETTINGS.name;
|
|
119
|
+
const releaseId = opts.accelplatformVersion ??
|
|
120
|
+
jugglingRelease?.id ??
|
|
121
|
+
DEFAULT_SETTINGS.accelplatformVersion.label;
|
|
122
|
+
const release = findReleaseById(releaseId);
|
|
123
|
+
if (!release) {
|
|
124
|
+
throw new Error(getMessage("error.invalidVersion", locale, { version: releaseId }));
|
|
125
|
+
}
|
|
126
|
+
validateCatalogValues(opts, release, locale);
|
|
127
|
+
const releaseArtifactIds = release.modules.map((m) => m.artifactId);
|
|
128
|
+
const modules = opts.module && opts.module.length > 0
|
|
129
|
+
? opts.module
|
|
130
|
+
: opts.jugglingProject
|
|
131
|
+
? jugglingModules.filter((m) => releaseArtifactIds.includes(m))
|
|
132
|
+
: releaseArtifactIds;
|
|
107
133
|
return {
|
|
108
134
|
name: resolvedName,
|
|
109
135
|
artifactId: opts.artifactId ?? resolvedName,
|
|
110
136
|
group: opts.group ?? DEFAULT_SETTINGS.group,
|
|
111
137
|
projectVersion: opts.projectVersion ?? DEFAULT_SETTINGS.projectVersion,
|
|
112
138
|
description: opts.description ?? DEFAULT_SETTINGS.description,
|
|
113
|
-
accelplatformVersion:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
modules: opts.module && opts.module.length > 0
|
|
117
|
-
? opts.module
|
|
118
|
-
: jugglingModules.length > 0
|
|
119
|
-
? jugglingModules
|
|
120
|
-
: [],
|
|
139
|
+
accelplatformVersion: { label: release.id, semver: release.version },
|
|
140
|
+
modules,
|
|
141
|
+
features: opts.feature ?? release.functions.map((f) => f.id),
|
|
121
142
|
database: (opts.database ?? DEFAULT_SETTINGS.database),
|
|
122
143
|
agents: opts.agent ?? detectDefaultAgents(),
|
|
123
144
|
javascript: opts.javascript ?? DEFAULT_SETTINGS.javascript,
|
|
@@ -153,44 +174,63 @@ export const runPrompts = async (opts) => {
|
|
|
153
174
|
}));
|
|
154
175
|
if (p.isCancel(jugglingInput))
|
|
155
176
|
process.exit(0);
|
|
156
|
-
let
|
|
177
|
+
let jugglingRelease = null;
|
|
157
178
|
let jugglingModules = [];
|
|
158
179
|
const jugglingProject = jugglingInput || null;
|
|
159
180
|
if (jugglingProject) {
|
|
160
181
|
try {
|
|
161
182
|
const resolved = await resolveJuggling(jugglingProject, locale);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
version
|
|
166
|
-
|
|
183
|
+
if (resolved.release) {
|
|
184
|
+
jugglingRelease = resolved.release;
|
|
185
|
+
jugglingModules = resolved.modules;
|
|
186
|
+
p.note(getMessage("juggling.detected.version", locale, {
|
|
187
|
+
version: jugglingRelease.id,
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
p.log.warning(getMessage("juggling.versionUnknown", locale, {
|
|
192
|
+
version: resolved.baseVersion,
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
167
195
|
}
|
|
168
196
|
catch (err) {
|
|
169
197
|
p.log.warning(err instanceof Error ? err.message : String(err));
|
|
170
198
|
}
|
|
171
199
|
}
|
|
172
|
-
const versionDefault = opts.accelplatformVersion ??
|
|
173
|
-
|
|
200
|
+
const versionDefault = opts.accelplatformVersion ??
|
|
201
|
+
jugglingRelease?.id ??
|
|
202
|
+
DEFAULT_SETTINGS.accelplatformVersion.label;
|
|
203
|
+
if (opts.accelplatformVersion &&
|
|
204
|
+
jugglingRelease &&
|
|
205
|
+
opts.accelplatformVersion !== jugglingRelease.id) {
|
|
174
206
|
p.log.warning(getMessage("warning.versionMismatch", locale, {
|
|
175
207
|
option: opts.accelplatformVersion,
|
|
176
|
-
juggling:
|
|
208
|
+
juggling: jugglingRelease.id,
|
|
177
209
|
}));
|
|
178
210
|
}
|
|
179
|
-
const
|
|
211
|
+
const accelplatformVersionId = (await p.select({
|
|
180
212
|
message: withHint("prompt.accelplatformVersion", locale),
|
|
181
|
-
options:
|
|
182
|
-
value:
|
|
183
|
-
label: `${
|
|
213
|
+
options: getReleases().map((r) => ({
|
|
214
|
+
value: r.id,
|
|
215
|
+
label: `${r.name} (${r.version})`,
|
|
184
216
|
})),
|
|
185
217
|
initialValue: versionDefault,
|
|
186
218
|
}));
|
|
187
|
-
if (p.isCancel(
|
|
219
|
+
if (p.isCancel(accelplatformVersionId))
|
|
188
220
|
process.exit(0);
|
|
221
|
+
const release = findReleaseById(accelplatformVersionId);
|
|
222
|
+
if (!release) {
|
|
223
|
+
throw new Error(getMessage("error.invalidVersion", locale, {
|
|
224
|
+
version: accelplatformVersionId,
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
validateCatalogValues(opts, release, locale);
|
|
228
|
+
const releaseArtifactIds = release.modules.map((m) => m.artifactId);
|
|
189
229
|
const moduleDefault = opts.module && opts.module.length > 0
|
|
190
|
-
? opts.module
|
|
191
|
-
:
|
|
192
|
-
? jugglingModules
|
|
193
|
-
:
|
|
230
|
+
? opts.module.filter((m) => releaseArtifactIds.includes(m))
|
|
231
|
+
: jugglingProject
|
|
232
|
+
? jugglingModules.filter((m) => releaseArtifactIds.includes(m))
|
|
233
|
+
: releaseArtifactIds;
|
|
194
234
|
if (opts.module && opts.module.length > 0 && jugglingModules.length > 0) {
|
|
195
235
|
const diff = opts.module.some((m) => !jugglingModules.includes(m)) ||
|
|
196
236
|
jugglingModules.some((m) => !opts.module.includes(m));
|
|
@@ -200,14 +240,33 @@ export const runPrompts = async (opts) => {
|
|
|
200
240
|
}
|
|
201
241
|
const modules = (await p.multiselect({
|
|
202
242
|
message: withHint("prompt.modules", locale),
|
|
203
|
-
options:
|
|
204
|
-
value: m,
|
|
205
|
-
label: m,
|
|
243
|
+
options: release.modules.map((m) => ({
|
|
244
|
+
value: m.artifactId,
|
|
245
|
+
label: resolveLabel(m.labels, locale),
|
|
206
246
|
})),
|
|
207
247
|
initialValues: moduleDefault,
|
|
248
|
+
required: true,
|
|
208
249
|
}));
|
|
209
250
|
if (p.isCancel(modules))
|
|
210
251
|
process.exit(0);
|
|
252
|
+
let features;
|
|
253
|
+
if (release.functions.length === 0) {
|
|
254
|
+
features = [];
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
const selected = (await p.multiselect({
|
|
258
|
+
message: withHint("prompt.features", locale),
|
|
259
|
+
options: release.functions.map((f) => ({
|
|
260
|
+
value: f.id,
|
|
261
|
+
label: resolveLabel(f.labels, locale),
|
|
262
|
+
})),
|
|
263
|
+
initialValues: opts.feature ?? release.functions.map((f) => f.id),
|
|
264
|
+
required: true,
|
|
265
|
+
}));
|
|
266
|
+
if (p.isCancel(selected))
|
|
267
|
+
process.exit(0);
|
|
268
|
+
features = selected;
|
|
269
|
+
}
|
|
211
270
|
const group = (await p.text({
|
|
212
271
|
message: withHint("prompt.group", locale),
|
|
213
272
|
defaultValue: opts.group ?? DEFAULT_SETTINGS.group,
|
|
@@ -272,8 +331,9 @@ export const runPrompts = async (opts) => {
|
|
|
272
331
|
group,
|
|
273
332
|
projectVersion,
|
|
274
333
|
description,
|
|
275
|
-
accelplatformVersion,
|
|
334
|
+
accelplatformVersion: { label: release.id, semver: release.version },
|
|
276
335
|
modules,
|
|
336
|
+
features,
|
|
277
337
|
database,
|
|
278
338
|
agents,
|
|
279
339
|
javascript,
|
|
@@ -17,12 +17,16 @@ export const buildSummaryBody = (settings, outputDir, locale) => {
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
labelKey: "summary.label.accelplatformVersion",
|
|
20
|
-
value: settings.accelplatformVersion,
|
|
20
|
+
value: settings.accelplatformVersion.label,
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
labelKey: "summary.label.modules",
|
|
24
24
|
value: formatList(settings.modules, empty),
|
|
25
25
|
},
|
|
26
|
+
{
|
|
27
|
+
labelKey: "summary.label.features",
|
|
28
|
+
value: formatList(settings.features, empty),
|
|
29
|
+
},
|
|
26
30
|
{ labelKey: "summary.label.database", value: settings.database },
|
|
27
31
|
{
|
|
28
32
|
labelKey: "summary.label.javascript",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { JugglingData } from "./parser.js";
|
|
2
|
+
import { type Release } from "../core/catalog.js";
|
|
2
3
|
export declare const extractVersion: (data: JugglingData) => string;
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const extractModules: (data: JugglingData) => string[];
|
|
4
|
+
export declare const findRelease: (data: JugglingData) => Release | undefined;
|
|
5
|
+
export declare const extractModules: (data: JugglingData, release: Release) => string[];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { semverToLabel } from "../core/version-map.js";
|
|
1
|
+
import { findReleaseBySemver, findModuleByCatalogId, } from "../core/catalog.js";
|
|
3
2
|
export const extractVersion = (data) => data.baseVersion;
|
|
4
|
-
export const
|
|
5
|
-
export const extractModules = (data) => {
|
|
6
|
-
const selectedModules = data.modules.filter((m) => m.selected);
|
|
3
|
+
export const findRelease = (data) => findReleaseBySemver(data.baseVersion);
|
|
4
|
+
export const extractModules = (data, release) => {
|
|
7
5
|
const result = [];
|
|
8
|
-
for (const mod of
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
for (const mod of data.modules) {
|
|
7
|
+
if (!mod.selected)
|
|
8
|
+
continue;
|
|
9
|
+
const entry = findModuleByCatalogId(release, mod.id);
|
|
10
|
+
if (entry) {
|
|
11
|
+
result.push(entry.artifactId);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
return [...new Set(result)].sort();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const lastFlagValue: (v: unknown) => string | undefined;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { AccelCredentials } from "../core/types.js";
|
|
2
2
|
export declare const CREDENTIALS_GITIGNORE_ENTRY = ".accel/credentials.json";
|
|
3
3
|
export declare const normalizeEndpoint: (raw: string) => string;
|
|
4
|
+
export declare const ENDPOINT_ENV = "ACCEL_ENDPOINT";
|
|
5
|
+
export declare const API_KEY_ENV = "ACCEL_API_KEY";
|
|
6
|
+
export declare const resolveCredentialInputs: (flags: {
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
}, env: Record<string, string | undefined>) => Partial<AccelCredentials>;
|
|
4
10
|
export declare const readCredentials: (projectDir: string) => Promise<Partial<AccelCredentials>>;
|
|
5
11
|
export declare const writeCredentials: (projectDir: string, creds: AccelCredentials) => Promise<void>;
|
|
12
|
+
export declare const persistCredentials: (projectDir: string, creds: AccelCredentials) => Promise<void>;
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { ensureGitignoreEntry } from "./gitignore.js";
|
|
3
4
|
const ACCEL_DIR = ".accel";
|
|
4
5
|
const CREDENTIALS_FILE = "credentials.json";
|
|
5
6
|
export const CREDENTIALS_GITIGNORE_ENTRY = `${ACCEL_DIR}/${CREDENTIALS_FILE}`;
|
|
6
7
|
export const normalizeEndpoint = (raw) => raw.trim().replace(/\/+$/, "");
|
|
8
|
+
export const ENDPOINT_ENV = "ACCEL_ENDPOINT";
|
|
9
|
+
export const API_KEY_ENV = "ACCEL_API_KEY";
|
|
10
|
+
export const resolveCredentialInputs = (flags, env) => {
|
|
11
|
+
const pick = (flag, envVal) => {
|
|
12
|
+
const raw = flag ?? envVal;
|
|
13
|
+
return raw && raw.trim().length > 0 ? raw : undefined;
|
|
14
|
+
};
|
|
15
|
+
const endpoint = pick(flags.endpoint, env[ENDPOINT_ENV]);
|
|
16
|
+
const apiKey = pick(flags.apiKey, env[API_KEY_ENV]);
|
|
17
|
+
const result = {};
|
|
18
|
+
if (endpoint !== undefined)
|
|
19
|
+
result.endpoint = normalizeEndpoint(endpoint);
|
|
20
|
+
if (apiKey !== undefined)
|
|
21
|
+
result.apiKey = apiKey;
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
7
24
|
export const readCredentials = async (projectDir) => {
|
|
8
25
|
const filePath = join(projectDir, ACCEL_DIR, CREDENTIALS_FILE);
|
|
9
26
|
try {
|
|
@@ -23,3 +40,7 @@ export const writeCredentials = async (projectDir, creds) => {
|
|
|
23
40
|
const filePath = join(accelDir, CREDENTIALS_FILE);
|
|
24
41
|
await writeFile(filePath, JSON.stringify(creds, null, 2) + "\n", "utf-8");
|
|
25
42
|
};
|
|
43
|
+
export const persistCredentials = async (projectDir, creds) => {
|
|
44
|
+
await writeCredentials(projectDir, creds);
|
|
45
|
+
await ensureGitignoreEntry(projectDir, CREDENTIALS_GITIGNORE_ENTRY);
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatEpochMillis: (ms: number, locale: string) => string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const INTL_LOCALE_MAP = {
|
|
2
|
+
ja: "ja-JP",
|
|
3
|
+
en: "en-US",
|
|
4
|
+
zh_CN: "zh-CN",
|
|
5
|
+
};
|
|
6
|
+
export const formatEpochMillis = (ms, locale) => {
|
|
7
|
+
if (!Number.isFinite(ms))
|
|
8
|
+
return String(ms);
|
|
9
|
+
const intlLocale = INTL_LOCALE_MAP[locale] ?? INTL_LOCALE_MAP["en"];
|
|
10
|
+
try {
|
|
11
|
+
return new Intl.DateTimeFormat(intlLocale, {
|
|
12
|
+
year: "numeric",
|
|
13
|
+
month: "2-digit",
|
|
14
|
+
day: "2-digit",
|
|
15
|
+
hour: "2-digit",
|
|
16
|
+
minute: "2-digit",
|
|
17
|
+
second: "2-digit",
|
|
18
|
+
}).format(new Date(ms));
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return String(ms);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { get as httpGet } from "node:http";
|
|
2
|
+
import { get as httpsGet } from "node:https";
|
|
3
|
+
import { createWriteStream } from "node:fs";
|
|
4
|
+
const MAX_REDIRECTS = 5;
|
|
5
|
+
export const isInsecureRedirect = (from, location) => {
|
|
6
|
+
if (!from.startsWith("https:"))
|
|
7
|
+
return false;
|
|
8
|
+
return new URL(location, from).protocol === "http:";
|
|
9
|
+
};
|
|
10
|
+
export const downloadFile = (url, destPath, redirectsLeft = MAX_REDIRECTS) => {
|
|
11
|
+
const requester = url.startsWith("http:") ? httpGet : httpsGet;
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
requester(url, (response) => {
|
|
14
|
+
const status = response.statusCode ?? 0;
|
|
15
|
+
const location = response.headers.location;
|
|
16
|
+
if (status >= 300 && status < 400 && location) {
|
|
17
|
+
response.resume();
|
|
18
|
+
if (redirectsLeft <= 0) {
|
|
19
|
+
reject(new Error(`Too many redirects when downloading from ${url}`));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (isInsecureRedirect(url, location)) {
|
|
23
|
+
reject(new Error(`Refusing insecure https→http redirect from ${url} to ${location}`));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const nextUrl = new URL(location, url).toString();
|
|
27
|
+
downloadFile(nextUrl, destPath, redirectsLeft - 1).then(resolve, reject);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (status !== 200) {
|
|
31
|
+
response.resume();
|
|
32
|
+
reject(new Error(`HTTP ${status} when downloading from ${url}`));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const file = createWriteStream(destPath);
|
|
36
|
+
response.pipe(file);
|
|
37
|
+
file.on("finish", () => file.close(() => resolve()));
|
|
38
|
+
file.on("error", (err) => {
|
|
39
|
+
file.close();
|
|
40
|
+
reject(err);
|
|
41
|
+
});
|
|
42
|
+
}).on("error", reject);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AccelCredentials } from "../core/types.js";
|
|
2
|
+
export declare const matchesEndpoint: (url: string, endpoint: string) => boolean;
|
|
3
|
+
export declare const syncMcpAuthorization: (projectDir: string, creds: AccelCredentials) => Promise<void>;
|
|
4
|
+
export declare const persistCredentialsAndSyncMcp: (projectDir: string, creds: AccelCredentials) => Promise<void>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
|
|
4
|
+
import { persistCredentials } from "./credentials.js";
|
|
5
|
+
import { readSettingsSafe } from "./settings-io.js";
|
|
6
|
+
const AUTHORIZATION_HEADER = "Authorization";
|
|
7
|
+
export const matchesEndpoint = (url, endpoint) => {
|
|
8
|
+
if (typeof url !== "string" || url.length === 0)
|
|
9
|
+
return false;
|
|
10
|
+
if (typeof endpoint !== "string" || endpoint.length === 0)
|
|
11
|
+
return false;
|
|
12
|
+
if (url === endpoint)
|
|
13
|
+
return true;
|
|
14
|
+
return url.startsWith(endpoint + "/");
|
|
15
|
+
};
|
|
16
|
+
const updateServers = (servers, endpoint, bearer, rules) => {
|
|
17
|
+
if (!servers || typeof servers !== "object")
|
|
18
|
+
return 0;
|
|
19
|
+
let updated = 0;
|
|
20
|
+
for (const value of Object.values(servers)) {
|
|
21
|
+
if (!value || typeof value !== "object")
|
|
22
|
+
continue;
|
|
23
|
+
const entry = value;
|
|
24
|
+
if (rules.requireHttpType && entry.type !== "http")
|
|
25
|
+
continue;
|
|
26
|
+
if (typeof entry.url !== "string")
|
|
27
|
+
continue;
|
|
28
|
+
if (!matchesEndpoint(entry.url, endpoint))
|
|
29
|
+
continue;
|
|
30
|
+
if (rules.shouldSkip?.(entry))
|
|
31
|
+
continue;
|
|
32
|
+
const existing = entry[rules.headersKey];
|
|
33
|
+
const headers = existing && typeof existing === "object"
|
|
34
|
+
? existing
|
|
35
|
+
: {};
|
|
36
|
+
headers[AUTHORIZATION_HEADER] = bearer;
|
|
37
|
+
entry[rules.headersKey] = headers;
|
|
38
|
+
updated++;
|
|
39
|
+
}
|
|
40
|
+
return updated;
|
|
41
|
+
};
|
|
42
|
+
const syncJsonFile = async (filePath, serversKey, endpoint, bearer) => {
|
|
43
|
+
try {
|
|
44
|
+
const content = await readFile(filePath, "utf-8");
|
|
45
|
+
const doc = JSON.parse(content);
|
|
46
|
+
const updated = updateServers(doc[serversKey], endpoint, bearer, {
|
|
47
|
+
headersKey: "headers",
|
|
48
|
+
requireHttpType: true,
|
|
49
|
+
});
|
|
50
|
+
if (updated > 0) {
|
|
51
|
+
await writeFile(filePath, JSON.stringify(doc, null, 2) + "\n", "utf-8");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const syncCodexToml = async (filePath, endpoint, bearer) => {
|
|
58
|
+
try {
|
|
59
|
+
const content = await readFile(filePath, "utf-8");
|
|
60
|
+
const doc = parseToml(content);
|
|
61
|
+
const updated = updateServers(doc.mcp_servers, endpoint, bearer, {
|
|
62
|
+
headersKey: "http_headers",
|
|
63
|
+
requireHttpType: false,
|
|
64
|
+
shouldSkip: (entry) => "env_http_headers" in entry,
|
|
65
|
+
});
|
|
66
|
+
if (updated > 0) {
|
|
67
|
+
const out = stringifyToml(doc);
|
|
68
|
+
await writeFile(filePath, out.endsWith("\n") ? out : out + "\n", "utf-8");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export const syncMcpAuthorization = async (projectDir, creds) => {
|
|
75
|
+
const settings = await readSettingsSafe(projectDir);
|
|
76
|
+
if (!settings)
|
|
77
|
+
return;
|
|
78
|
+
const agents = settings.agents ?? [];
|
|
79
|
+
const bearer = `Bearer ${creds.apiKey}`;
|
|
80
|
+
if (agents.includes("claude-code")) {
|
|
81
|
+
await syncJsonFile(join(projectDir, ".mcp.json"), "mcpServers", creds.endpoint, bearer);
|
|
82
|
+
}
|
|
83
|
+
if (agents.includes("codex")) {
|
|
84
|
+
await syncCodexToml(join(projectDir, ".codex", "config.toml"), creds.endpoint, bearer);
|
|
85
|
+
}
|
|
86
|
+
if (agents.includes("github-copilot")) {
|
|
87
|
+
await syncJsonFile(join(projectDir, ".vscode", "mcp.json"), "servers", creds.endpoint, bearer);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
export const persistCredentialsAndSyncMcp = async (projectDir, creds) => {
|
|
91
|
+
await persistCredentials(projectDir, creds);
|
|
92
|
+
try {
|
|
93
|
+
await syncMcpAuthorization(projectDir, creds);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
}
|
|
97
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AccelSettings, HashsumEntry } from "../core/types.js";
|
|
2
2
|
export declare const writeSettings: (projectDir: string, settings: AccelSettings) => Promise<void>;
|
|
3
3
|
export declare const readSettings: (projectDir: string) => Promise<AccelSettings>;
|
|
4
|
+
export declare const readSettingsSafe: (projectDir: string) => Promise<AccelSettings | null>;
|
|
4
5
|
export declare const serializeHashsum: (entries: HashsumEntry[]) => string;
|
|
5
6
|
export declare const parseHashsum: (content: string) => HashsumEntry[];
|
|
6
7
|
export declare const writeHashsum: (projectDir: string, entries: HashsumEntry[]) => Promise<void>;
|
|
@@ -18,6 +18,14 @@ export const readSettings = async (projectDir) => {
|
|
|
18
18
|
const content = await readFile(filePath, "utf-8");
|
|
19
19
|
return JSON.parse(content);
|
|
20
20
|
};
|
|
21
|
+
export const readSettingsSafe = async (projectDir) => {
|
|
22
|
+
try {
|
|
23
|
+
return await readSettings(projectDir);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
21
29
|
export const serializeHashsum = (entries) => {
|
|
22
30
|
const sorted = [...entries].sort((a, b) => a.filePath.localeCompare(b.filePath));
|
|
23
31
|
return sorted
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intra-mart/accel",
|
|
3
|
-
"version": "0.3.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI tool for intra-mart Accel Platform development",
|
|
6
6
|
"author": "NTT DATA INTRAMART",
|
|
@@ -19,11 +19,10 @@
|
|
|
19
19
|
"accel": "./dist/index.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
"assets/assets.tar.gz"
|
|
22
|
+
"dist"
|
|
24
23
|
],
|
|
25
24
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
25
|
+
"node": ">=24.0.0"
|
|
27
26
|
},
|
|
28
27
|
"publishConfig": {
|
|
29
28
|
"access": "public"
|
|
@@ -40,18 +39,20 @@
|
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
42
41
|
"@clack/prompts": "^1.4.0",
|
|
42
|
+
"@intra-mart/catalog": "0.1.0-dev.202606250213",
|
|
43
43
|
"citty": "^0.1.6",
|
|
44
44
|
"fast-xml-parser": "^5.2.0",
|
|
45
45
|
"remark": "^15.0.1",
|
|
46
46
|
"remark-parse": "^11.0.0",
|
|
47
47
|
"remark-stringify": "^11.0.0",
|
|
48
48
|
"semver": "^7.7.1",
|
|
49
|
+
"smol-toml": "^1.6.1",
|
|
49
50
|
"tar": "^7.4.3",
|
|
50
51
|
"unified": "^11.0.5",
|
|
51
52
|
"unist-util-visit": "^5.0.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@types/node": "^
|
|
55
|
+
"@types/node": "^24",
|
|
55
56
|
"@types/semver": "^7.7.0",
|
|
56
57
|
"execa": "^9.5.2",
|
|
57
58
|
"typescript": "^5.8.3",
|
package/assets/assets.tar.gz
DELETED
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const defaultAssetSourcePath: () => string;
|
package/dist/core/module-map.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export const MODULE_ID_MAP = {
|
|
2
|
-
workflow: "jp.co.intra_mart.im_workflow",
|
|
3
|
-
copilot: "jp.co.intra_mart.im_copilot",
|
|
4
|
-
};
|
|
5
|
-
const reverseMap = new Map(Object.entries(MODULE_ID_MAP).map(([key, value]) => [value, key]));
|
|
6
|
-
export const xmlIdToModuleName = (xmlId) => reverseMap.get(xmlId);
|
|
7
|
-
export const moduleNameToXmlId = (moduleName) => MODULE_ID_MAP[moduleName];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { IapVersion } from "./types.js";
|
|
2
|
-
export declare const IAP_VERSIONS: readonly IapVersion[];
|
|
3
|
-
export declare const SELECTABLE_VERSIONS: readonly IapVersion[];
|
|
4
|
-
export declare const labelToSemver: (label: string) => string;
|
|
5
|
-
export declare const semverToLabel: (semver: string) => string;
|
|
6
|
-
export declare const findByLabel: (label: string) => IapVersion | undefined;
|
|
7
|
-
export declare const findBySemver: (semver: string) => IapVersion | undefined;
|