@intra-mart/accel 0.2.0 → 0.3.0-dev.202606100311
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 +138 -4
- package/dist/asset/deployer.js +2 -3
- 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/commands/attach.d.ts +9 -1
- package/dist/commands/attach.js +21 -10
- package/dist/commands/deploy.d.ts +62 -0
- package/dist/commands/deploy.js +293 -0
- package/dist/commands/init.d.ts +9 -1
- package/dist/commands/init.js +21 -10
- package/dist/commands/login.d.ts +31 -0
- package/dist/commands/login.js +75 -0
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/types.d.ts +41 -1
- package/dist/core/version-map.d.ts +2 -1
- package/dist/core/version-map.js +9 -22
- package/dist/deploy/api-client.d.ts +16 -0
- package/dist/deploy/api-client.js +105 -0
- package/dist/deploy/target-scanner.d.ts +5 -0
- package/dist/deploy/target-scanner.js +20 -0
- package/dist/deploy/target-selector.d.ts +11 -0
- package/dist/deploy/target-selector.js +16 -0
- package/dist/i18n/en.js +46 -0
- package/dist/i18n/ja.js +46 -0
- package/dist/i18n/zh_CN.js +46 -0
- package/dist/index.js +4 -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 +4 -0
- package/dist/interactive/credentials-prompts.js +85 -0
- package/dist/interactive/prompts.js +56 -6
- package/dist/interactive/summary.js +8 -0
- package/dist/utils/args.d.ts +1 -0
- package/dist/utils/args.js +4 -0
- package/dist/utils/credentials.d.ts +12 -0
- package/dist/utils/credentials.js +46 -0
- package/dist/utils/date-formatter.d.ts +1 -0
- package/dist/utils/date-formatter.js +23 -0
- package/dist/utils/gitignore.d.ts +1 -0
- package/dist/utils/gitignore.js +23 -0
- package/dist/utils/https.d.ts +2 -0
- package/dist/utils/https.js +44 -0
- package/dist/utils/settings-io.d.ts +1 -0
- package/dist/utils/settings-io.js +8 -0
- package/package.json +2 -3
- package/assets/assets.tar.gz +0 -0
- package/dist/asset/default-source.d.ts +0 -1
- package/dist/asset/default-source.js +0 -6
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { ensureGitignoreEntry } from "./gitignore.js";
|
|
4
|
+
const ACCEL_DIR = ".accel";
|
|
5
|
+
const CREDENTIALS_FILE = "credentials.json";
|
|
6
|
+
export const CREDENTIALS_GITIGNORE_ENTRY = `${ACCEL_DIR}/${CREDENTIALS_FILE}`;
|
|
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
|
+
};
|
|
24
|
+
export const readCredentials = async (projectDir) => {
|
|
25
|
+
const filePath = join(projectDir, ACCEL_DIR, CREDENTIALS_FILE);
|
|
26
|
+
try {
|
|
27
|
+
const content = await readFile(filePath, "utf-8");
|
|
28
|
+
const parsed = JSON.parse(content);
|
|
29
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
30
|
+
return {};
|
|
31
|
+
return parsed;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const writeCredentials = async (projectDir, creds) => {
|
|
38
|
+
const accelDir = join(projectDir, ACCEL_DIR);
|
|
39
|
+
await mkdir(accelDir, { recursive: true });
|
|
40
|
+
const filePath = join(accelDir, CREDENTIALS_FILE);
|
|
41
|
+
await writeFile(filePath, JSON.stringify(creds, null, 2) + "\n", "utf-8");
|
|
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 @@
|
|
|
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
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -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
|
+
"version": "0.3.0-dev.202606100311",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI tool for intra-mart Accel Platform development",
|
|
6
6
|
"author": "NTT DATA INTRAMART",
|
|
@@ -19,8 +19,7 @@
|
|
|
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
25
|
"node": ">=20.0.0"
|
package/assets/assets.tar.gz
DELETED
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const defaultAssetSourcePath: () => string;
|