@intra-mart/accel 0.1.0-dev-20260420
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/assets/assets.tar.gz +0 -0
- package/dist/asset/default-source.d.ts +1 -0
- package/dist/asset/default-source.js +9 -0
- package/dist/asset/deployer.d.ts +14 -0
- package/dist/asset/deployer.js +109 -0
- package/dist/asset/file-provider.d.ts +2 -0
- package/dist/asset/file-provider.js +25 -0
- package/dist/asset/local-provider.d.ts +2 -0
- package/dist/asset/local-provider.js +45 -0
- package/dist/asset/regex-replacement.d.ts +2 -0
- package/dist/asset/regex-replacement.js +12 -0
- package/dist/asset/types.d.ts +1 -0
- package/dist/asset/types.js +1 -0
- package/dist/asset/walker.d.ts +10 -0
- package/dist/asset/walker.js +165 -0
- package/dist/commands/attach.d.ts +64 -0
- package/dist/commands/attach.js +163 -0
- package/dist/commands/detach.d.ts +1 -0
- package/dist/commands/detach.js +74 -0
- package/dist/commands/init.d.ts +70 -0
- package/dist/commands/init.js +178 -0
- package/dist/core/condition-evaluator.d.ts +2 -0
- package/dist/core/condition-evaluator.js +26 -0
- package/dist/core/constants.d.ts +11 -0
- package/dist/core/constants.js +30 -0
- package/dist/core/module-map.d.ts +7 -0
- package/dist/core/module-map.js +12 -0
- package/dist/core/types.d.ts +100 -0
- package/dist/core/types.js +8 -0
- package/dist/core/variable-interpolator.d.ts +10 -0
- package/dist/core/variable-interpolator.js +37 -0
- package/dist/core/version-map.d.ts +7 -0
- package/dist/core/version-map.js +45 -0
- package/dist/i18n/en.d.ts +1 -0
- package/dist/i18n/en.js +47 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +19 -0
- package/dist/i18n/ja.d.ts +1 -0
- package/dist/i18n/ja.js +47 -0
- package/dist/i18n/zh_CN.d.ts +1 -0
- package/dist/i18n/zh_CN.js +47 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/interactive/agent-detect.d.ts +8 -0
- package/dist/interactive/agent-detect.js +31 -0
- package/dist/interactive/prompts.d.ts +22 -0
- package/dist/interactive/prompts.js +226 -0
- package/dist/juggling/extractor.d.ts +4 -0
- package/dist/juggling/extractor.js +15 -0
- package/dist/juggling/parser.d.ts +13 -0
- package/dist/juggling/parser.js +66 -0
- package/dist/markdown/processor.d.ts +3 -0
- package/dist/markdown/processor.js +16 -0
- package/dist/markdown/section-replacement.d.ts +2 -0
- package/dist/markdown/section-replacement.js +68 -0
- package/dist/markdown/text-replacement.d.ts +8 -0
- package/dist/markdown/text-replacement.js +32 -0
- package/dist/utils/archive.d.ts +3 -0
- package/dist/utils/archive.js +20 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/hash.js +6 -0
- package/dist/utils/locale-detect.d.ts +2 -0
- package/dist/utils/locale-detect.js +35 -0
- package/dist/utils/settings-io.d.ts +7 -0
- package/dist/utils/settings-io.js +54 -0
- package/package.json +60 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { unified } from "unified";
|
|
2
|
+
import remarkParse from "remark-parse";
|
|
3
|
+
import remarkStringify from "remark-stringify";
|
|
4
|
+
import { evaluateCondition } from "../core/condition-evaluator.js";
|
|
5
|
+
const findSectionRange = (tree, heading) => {
|
|
6
|
+
let startIdx = -1;
|
|
7
|
+
let headingDepth = 0;
|
|
8
|
+
for (let i = 0; i < tree.children.length; i++) {
|
|
9
|
+
const node = tree.children[i];
|
|
10
|
+
if (startIdx === -1) {
|
|
11
|
+
// Looking for the target heading
|
|
12
|
+
if (node.type === "heading") {
|
|
13
|
+
const text = extractHeadingText(node);
|
|
14
|
+
if (text === heading) {
|
|
15
|
+
startIdx = i;
|
|
16
|
+
headingDepth = node.depth;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
// Looking for the end of the section (same or higher level heading)
|
|
22
|
+
if (node.type === "heading" && node.depth <= headingDepth) {
|
|
23
|
+
return { start: startIdx, end: i };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (startIdx !== -1) {
|
|
28
|
+
// Section extends to end of document
|
|
29
|
+
return { start: startIdx, end: tree.children.length };
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
const extractHeadingText = (node) => {
|
|
34
|
+
if (node.type !== "heading")
|
|
35
|
+
return "";
|
|
36
|
+
return node.children
|
|
37
|
+
.map((child) => {
|
|
38
|
+
if (child.type === "text")
|
|
39
|
+
return child.value;
|
|
40
|
+
if ("children" in child) {
|
|
41
|
+
return child.children
|
|
42
|
+
.map((c) => c.value ?? "")
|
|
43
|
+
.join("");
|
|
44
|
+
}
|
|
45
|
+
return "";
|
|
46
|
+
})
|
|
47
|
+
.join("");
|
|
48
|
+
};
|
|
49
|
+
export const applySectionReplacements = (content, replacements, context) => {
|
|
50
|
+
const processor = unified().use(remarkParse).use(remarkStringify);
|
|
51
|
+
const tree = processor.parse(content);
|
|
52
|
+
// Process replacements in reverse order to maintain correct indices
|
|
53
|
+
const removals = [];
|
|
54
|
+
for (const replacement of replacements) {
|
|
55
|
+
if (!evaluateCondition(replacement.condition, context)) {
|
|
56
|
+
const range = findSectionRange(tree, replacement.heading);
|
|
57
|
+
if (range) {
|
|
58
|
+
removals.push(range);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Sort removals in reverse order and apply
|
|
63
|
+
removals.sort((a, b) => b.start - a.start);
|
|
64
|
+
for (const { start, end } of removals) {
|
|
65
|
+
tree.children.splice(start, end - start);
|
|
66
|
+
}
|
|
67
|
+
return processor.stringify(tree);
|
|
68
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TextReplacement, EvalContext } from "../core/types.js";
|
|
2
|
+
export type PlaceholderMatcher = (text: string, target: string) => {
|
|
3
|
+
index: number;
|
|
4
|
+
length: number;
|
|
5
|
+
}[];
|
|
6
|
+
export declare const defaultPlaceholderMatcher: PlaceholderMatcher;
|
|
7
|
+
export declare const resolveTextValue: (replacement: TextReplacement, context: EvalContext) => string;
|
|
8
|
+
export declare const applyTextReplacements: (content: string, replacements: TextReplacement[], context: EvalContext, matcher?: PlaceholderMatcher) => string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { evaluateCondition } from "../core/condition-evaluator.js";
|
|
2
|
+
import { interpolateVariables } from "../core/variable-interpolator.js";
|
|
3
|
+
export const defaultPlaceholderMatcher = (text, target) => {
|
|
4
|
+
const matches = [];
|
|
5
|
+
let idx = text.indexOf(target);
|
|
6
|
+
while (idx !== -1) {
|
|
7
|
+
matches.push({ index: idx, length: target.length });
|
|
8
|
+
idx = text.indexOf(target, idx + target.length);
|
|
9
|
+
}
|
|
10
|
+
return matches;
|
|
11
|
+
};
|
|
12
|
+
export const resolveTextValue = (replacement, context) => {
|
|
13
|
+
// first-match-wins
|
|
14
|
+
for (const entry of replacement.values) {
|
|
15
|
+
if (evaluateCondition(entry.condition, context)) {
|
|
16
|
+
return entry.value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return "";
|
|
20
|
+
};
|
|
21
|
+
export const applyTextReplacements = (content, replacements, context, matcher = defaultPlaceholderMatcher) => {
|
|
22
|
+
let result = content;
|
|
23
|
+
for (const replacement of replacements) {
|
|
24
|
+
const rawValue = resolveTextValue(replacement, context);
|
|
25
|
+
const value = interpolateVariables(rawValue, context);
|
|
26
|
+
// Simple string replacement — replace all occurrences
|
|
27
|
+
while (matcher(result, replacement.target).length > 0) {
|
|
28
|
+
result = result.replace(replacement.target, value);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const extractTarGz: (archivePath: string, destDir: string) => Promise<void>;
|
|
2
|
+
export declare const createTarGz: (sourceDir: string, destPath: string, entries?: string[]) => Promise<void>;
|
|
3
|
+
export declare const createTempDir: (prefix?: string) => Promise<string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { extract, create } from "tar";
|
|
2
|
+
import { mkdtemp } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
export const extractTarGz = async (archivePath, destDir) => {
|
|
6
|
+
await extract({
|
|
7
|
+
file: archivePath,
|
|
8
|
+
cwd: destDir,
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export const createTarGz = async (sourceDir, destPath, entries) => {
|
|
12
|
+
await create({
|
|
13
|
+
gzip: true,
|
|
14
|
+
file: destPath,
|
|
15
|
+
cwd: sourceDir,
|
|
16
|
+
}, entries ?? ["."]);
|
|
17
|
+
};
|
|
18
|
+
export const createTempDir = async (prefix = "accel-") => {
|
|
19
|
+
return mkdtemp(join(tmpdir(), prefix));
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const computeSha1: (content: string | Buffer) => string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LOCALE_OPTIONS } from "../core/constants.js";
|
|
2
|
+
const LOCALE_NORMALIZE_MAP = {
|
|
3
|
+
ja: "ja",
|
|
4
|
+
ja_jp: "ja",
|
|
5
|
+
en: "en",
|
|
6
|
+
en_us: "en",
|
|
7
|
+
en_gb: "en",
|
|
8
|
+
zh_cn: "zh_CN",
|
|
9
|
+
zh: "zh_CN",
|
|
10
|
+
};
|
|
11
|
+
const DEFAULT_LOCALE = "en";
|
|
12
|
+
export const detectLocale = () => {
|
|
13
|
+
const envLocale = process.env["LC_ALL"] ||
|
|
14
|
+
process.env["LC_MESSAGES"] ||
|
|
15
|
+
process.env["LANG"] ||
|
|
16
|
+
process.env["LANGUAGE"] ||
|
|
17
|
+
"";
|
|
18
|
+
return normalizeLocale(envLocale);
|
|
19
|
+
};
|
|
20
|
+
export const normalizeLocale = (raw) => {
|
|
21
|
+
// Strip encoding (e.g., ".UTF-8")
|
|
22
|
+
const stripped = raw.split(".")[0].toLowerCase();
|
|
23
|
+
const matched = LOCALE_NORMALIZE_MAP[stripped];
|
|
24
|
+
if (matched)
|
|
25
|
+
return matched;
|
|
26
|
+
// Try language part only (e.g., "ja_JP" -> "ja")
|
|
27
|
+
const langPart = stripped.split("_")[0];
|
|
28
|
+
const langMatched = LOCALE_NORMALIZE_MAP[langPart];
|
|
29
|
+
if (langMatched)
|
|
30
|
+
return langMatched;
|
|
31
|
+
// Check if it's directly a supported locale
|
|
32
|
+
if (LOCALE_OPTIONS.includes(raw))
|
|
33
|
+
return raw;
|
|
34
|
+
return DEFAULT_LOCALE;
|
|
35
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AccelSettings, HashsumEntry } from "../core/types.js";
|
|
2
|
+
export declare const writeSettings: (projectDir: string, settings: AccelSettings) => Promise<void>;
|
|
3
|
+
export declare const readSettings: (projectDir: string) => Promise<AccelSettings>;
|
|
4
|
+
export declare const serializeHashsum: (entries: HashsumEntry[]) => string;
|
|
5
|
+
export declare const parseHashsum: (content: string) => HashsumEntry[];
|
|
6
|
+
export declare const writeHashsum: (projectDir: string, entries: HashsumEntry[]) => Promise<void>;
|
|
7
|
+
export declare const readHashsum: (projectDir: string) => Promise<HashsumEntry[]>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
const ACCEL_DIR = ".accel";
|
|
4
|
+
const SETTINGS_FILE = "settings.json";
|
|
5
|
+
const HASHSUM_FILE = "hashsum.txt";
|
|
6
|
+
const ensureAccelDir = async (projectDir) => {
|
|
7
|
+
const accelDir = join(projectDir, ACCEL_DIR);
|
|
8
|
+
await mkdir(accelDir, { recursive: true });
|
|
9
|
+
return accelDir;
|
|
10
|
+
};
|
|
11
|
+
// --- settings.json ---
|
|
12
|
+
export const writeSettings = async (projectDir, settings) => {
|
|
13
|
+
const accelDir = await ensureAccelDir(projectDir);
|
|
14
|
+
const filePath = join(accelDir, SETTINGS_FILE);
|
|
15
|
+
await writeFile(filePath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
16
|
+
};
|
|
17
|
+
export const readSettings = async (projectDir) => {
|
|
18
|
+
const filePath = join(projectDir, ACCEL_DIR, SETTINGS_FILE);
|
|
19
|
+
const content = await readFile(filePath, "utf-8");
|
|
20
|
+
return JSON.parse(content);
|
|
21
|
+
};
|
|
22
|
+
// --- hashsum.txt ---
|
|
23
|
+
export const serializeHashsum = (entries) => {
|
|
24
|
+
const sorted = [...entries].sort((a, b) => a.filePath.localeCompare(b.filePath));
|
|
25
|
+
return sorted
|
|
26
|
+
.map((e) => `${e.filePath}@${e.version} sha1:${e.sha1}`)
|
|
27
|
+
.join("\n") + "\n";
|
|
28
|
+
};
|
|
29
|
+
export const parseHashsum = (content) => {
|
|
30
|
+
return content
|
|
31
|
+
.split("\n")
|
|
32
|
+
.filter((line) => line.trim().length > 0)
|
|
33
|
+
.map((line) => {
|
|
34
|
+
const match = line.match(/^(.+)@(\S+)\s+sha1:(\S+)$/);
|
|
35
|
+
if (!match) {
|
|
36
|
+
throw new Error(`Invalid hashsum line: ${line}`);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
filePath: match[1],
|
|
40
|
+
version: match[2],
|
|
41
|
+
sha1: match[3],
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export const writeHashsum = async (projectDir, entries) => {
|
|
46
|
+
const accelDir = await ensureAccelDir(projectDir);
|
|
47
|
+
const filePath = join(accelDir, HASHSUM_FILE);
|
|
48
|
+
await writeFile(filePath, serializeHashsum(entries), "utf-8");
|
|
49
|
+
};
|
|
50
|
+
export const readHashsum = async (projectDir) => {
|
|
51
|
+
const filePath = join(projectDir, ACCEL_DIR, HASHSUM_FILE);
|
|
52
|
+
const content = await readFile(filePath, "utf-8");
|
|
53
|
+
return parseHashsum(content);
|
|
54
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intra-mart/accel",
|
|
3
|
+
"version": "0.1.0-dev-20260420",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CLI tool for intra-mart Accel Platform development",
|
|
6
|
+
"author": "NTT DATA INTRAMART",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"intra-mart",
|
|
10
|
+
"AccelPlatform",
|
|
11
|
+
"iAP"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/accelplatform/accel-cli.git"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "http://oss.intra-mart.org",
|
|
18
|
+
"bin": {
|
|
19
|
+
"accel": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"assets/assets.tar.gz"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20.0.0"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"dev": "tsc --watch",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"test:unit": "vitest run tests/unit",
|
|
36
|
+
"test:e2e": "vitest run tests/e2e",
|
|
37
|
+
"test:watch": "vitest",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"prepublishOnly": "tsc"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@clack/prompts": "^0.10.0",
|
|
43
|
+
"citty": "^0.1.6",
|
|
44
|
+
"fast-xml-parser": "^5.2.0",
|
|
45
|
+
"remark": "^15.0.1",
|
|
46
|
+
"remark-parse": "^11.0.0",
|
|
47
|
+
"remark-stringify": "^11.0.0",
|
|
48
|
+
"semver": "^7.7.1",
|
|
49
|
+
"tar": "^7.4.3",
|
|
50
|
+
"unified": "^11.0.5",
|
|
51
|
+
"unist-util-visit": "^5.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^22.15.2",
|
|
55
|
+
"@types/semver": "^7.7.0",
|
|
56
|
+
"execa": "^9.5.2",
|
|
57
|
+
"typescript": "^5.8.3",
|
|
58
|
+
"vitest": "^3.1.2"
|
|
59
|
+
}
|
|
60
|
+
}
|