@intra-mart/accel 0.3.1 → 0.4.0-dev.202607170346
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 +72 -12
- package/assets/githooks/.githooks/.gitattributes +2 -0
- package/assets/githooks/.githooks/pre-commit/_meta.json +24 -0
- package/assets/githooks/.githooks/pre-commit/pre-commit_en +268 -0
- package/assets/githooks/.githooks/pre-commit/pre-commit_ja +255 -0
- package/assets/githooks/.githooks/pre-commit/pre-commit_zh_CN +255 -0
- package/dist/asset/asset-tree.d.ts +5 -0
- package/dist/asset/asset-tree.js +7 -0
- package/dist/asset/deployer.d.ts +2 -1
- package/dist/asset/deployer.js +28 -59
- package/dist/asset/file-provider.js +19 -18
- package/dist/asset/git-provider.d.ts +14 -0
- package/dist/asset/git-provider.js +163 -0
- package/dist/asset/installer.d.ts +6 -0
- package/dist/asset/installer.js +31 -0
- package/dist/asset/renderer.d.ts +2 -0
- package/dist/asset/renderer.js +22 -0
- package/dist/asset/types.d.ts +1 -1
- package/dist/asset/updater.d.ts +52 -0
- package/dist/asset/updater.js +297 -0
- package/dist/asset/walker.d.ts +4 -2
- package/dist/asset/walker.js +74 -45
- package/dist/commands/asset-provider.d.ts +7 -0
- package/dist/commands/asset-provider.js +9 -0
- package/dist/commands/attach.d.ts +0 -4
- package/dist/commands/attach.js +11 -20
- package/dist/commands/deploy.d.ts +11 -6
- package/dist/commands/deploy.js +77 -23
- package/dist/commands/init.d.ts +0 -4
- package/dist/commands/init.js +11 -20
- package/dist/commands/update.d.ts +86 -0
- package/dist/commands/update.js +448 -0
- package/dist/core/constants.d.ts +3 -3
- package/dist/core/constants.js +4 -2
- package/dist/core/types.d.ts +13 -1
- package/dist/deploy/api-client.d.ts +6 -2
- package/dist/deploy/api-client.js +8 -4
- package/dist/deploy/deploy-files.d.ts +20 -0
- package/dist/deploy/deploy-files.js +37 -0
- package/dist/git/errors.d.ts +6 -0
- package/dist/git/errors.js +9 -0
- package/dist/git/http.d.ts +3 -0
- package/dist/git/http.js +58 -0
- package/dist/git/object-store.d.ts +13 -0
- package/dist/git/object-store.js +79 -0
- package/dist/git/pkt-line.d.ts +13 -0
- package/dist/git/pkt-line.js +41 -0
- package/dist/git/smart-http.d.ts +18 -0
- package/dist/git/smart-http.js +109 -0
- package/dist/i18n/en.js +53 -6
- package/dist/i18n/ja.js +53 -6
- package/dist/i18n/zh_CN.js +53 -6
- package/dist/index.js +4 -1
- package/dist/interactive/progress.js +1 -0
- package/dist/interactive/prompts.d.ts +7 -1
- package/dist/interactive/prompts.js +63 -64
- package/dist/markdown/section-replacement.js +34 -8
- package/dist/utils/args.d.ts +1 -0
- package/dist/utils/args.js +4 -0
- package/dist/utils/fs-list.d.ts +1 -0
- package/dist/utils/fs-list.js +11 -0
- package/dist/utils/githooks-sync.d.ts +1 -0
- package/dist/utils/githooks-sync.js +91 -0
- package/dist/utils/mcp-sync.js +6 -0
- package/dist/utils/merge-file.d.ts +6 -0
- package/dist/utils/merge-file.js +20 -0
- package/package.json +8 -9
- package/dist/asset/github-provider.d.ts +0 -2
- package/dist/asset/github-provider.js +0 -37
- package/dist/asset/local-provider.d.ts +0 -2
- package/dist/asset/local-provider.js +0 -24
- package/dist/utils/archive.d.ts +0 -3
- package/dist/utils/archive.js +0 -20
- package/dist/utils/https.d.ts +0 -2
- package/dist/utils/https.js +0 -44
package/dist/asset/walker.js
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
|
-
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
-
import { join, relative, dirname, sep } from "node:path";
|
|
3
1
|
import { evaluateCondition } from "../core/condition-evaluator.js";
|
|
4
2
|
import { emptyEvalContext } from "../core/eval-context.js";
|
|
5
|
-
const toPosixPath = (p) => sep === "/" ? p : p.split(sep).join("/");
|
|
6
3
|
const META_FILE = "_meta.json";
|
|
7
|
-
const
|
|
4
|
+
const joinPosix = (...parts) => parts.filter((p) => p !== "").join("/");
|
|
5
|
+
const dirnamePosix = (p) => {
|
|
6
|
+
const idx = p.lastIndexOf("/");
|
|
7
|
+
return idx === -1 ? "" : p.slice(0, idx);
|
|
8
|
+
};
|
|
9
|
+
const buildVirtualTree = (files) => {
|
|
10
|
+
const tree = new Map();
|
|
11
|
+
const ensureDir = (dir) => {
|
|
12
|
+
let node = tree.get(dir);
|
|
13
|
+
if (!node) {
|
|
14
|
+
node = { files: new Set(), subdirs: new Set() };
|
|
15
|
+
tree.set(dir, node);
|
|
16
|
+
}
|
|
17
|
+
return node;
|
|
18
|
+
};
|
|
19
|
+
ensureDir("");
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
const parts = file.split("/");
|
|
22
|
+
let dir = "";
|
|
23
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
24
|
+
ensureDir(dir).subdirs.add(parts[i]);
|
|
25
|
+
dir = joinPosix(dir, parts[i]);
|
|
26
|
+
}
|
|
27
|
+
ensureDir(dir).files.add(parts[parts.length - 1]);
|
|
28
|
+
}
|
|
29
|
+
return tree;
|
|
30
|
+
};
|
|
31
|
+
const readMetaJson = async (tree, vtree, dir) => {
|
|
32
|
+
if (!vtree.get(dir)?.files.has(META_FILE))
|
|
33
|
+
return null;
|
|
8
34
|
try {
|
|
9
|
-
const content = await readFile(
|
|
35
|
+
const content = await tree.readFile(joinPosix(dir, META_FILE));
|
|
10
36
|
const parsed = JSON.parse(content);
|
|
11
37
|
if (!parsed.type) {
|
|
12
38
|
parsed.type = "directory";
|
|
@@ -23,21 +49,20 @@ const resolveRenameRule = (rules, context, dir) => {
|
|
|
23
49
|
for (const rule of rules) {
|
|
24
50
|
if (evaluateCondition(rule.condition, context)) {
|
|
25
51
|
return {
|
|
26
|
-
|
|
52
|
+
sourceRelPath: joinPosix(dir, rule.from),
|
|
27
53
|
targetName: rule.to,
|
|
28
54
|
};
|
|
29
55
|
}
|
|
30
56
|
}
|
|
31
57
|
return null;
|
|
32
58
|
};
|
|
33
|
-
const findMatchingVersionDirs = async (
|
|
34
|
-
const
|
|
59
|
+
const findMatchingVersionDirs = async (tree, vtree, targetSemver) => {
|
|
60
|
+
const root = vtree.get("");
|
|
61
|
+
if (!root)
|
|
62
|
+
return [];
|
|
35
63
|
const matched = [];
|
|
36
|
-
for (const
|
|
37
|
-
|
|
38
|
-
continue;
|
|
39
|
-
const dirPath = join(repoDir, entry.name);
|
|
40
|
-
const meta = await readMetaJson(dirPath);
|
|
64
|
+
for (const name of [...root.subdirs].sort()) {
|
|
65
|
+
const meta = await readMetaJson(tree, vtree, name);
|
|
41
66
|
if (!meta) {
|
|
42
67
|
continue;
|
|
43
68
|
}
|
|
@@ -46,69 +71,64 @@ const findMatchingVersionDirs = async (repoDir, targetSemver) => {
|
|
|
46
71
|
accelplatformVersion: { label: "", semver: targetSemver },
|
|
47
72
|
});
|
|
48
73
|
if (evaluateCondition(meta.conditions, context)) {
|
|
49
|
-
matched.push(
|
|
74
|
+
matched.push(name);
|
|
50
75
|
}
|
|
51
76
|
}
|
|
52
77
|
}
|
|
53
78
|
return matched;
|
|
54
79
|
};
|
|
55
|
-
const walkDirectory = async (dir, baseDir, parentMeta, context) => {
|
|
80
|
+
const walkDirectory = async (tree, vtree, dir, baseDir, parentMeta, context) => {
|
|
56
81
|
const entries = [];
|
|
57
|
-
const
|
|
58
|
-
|
|
82
|
+
const node = vtree.get(dir);
|
|
83
|
+
if (!node)
|
|
84
|
+
return entries;
|
|
85
|
+
const ownMeta = await readMetaJson(tree, vtree, dir);
|
|
59
86
|
const effectiveMeta = ownMeta ?? parentMeta;
|
|
60
87
|
if (ownMeta?.conditions) {
|
|
61
88
|
if (!evaluateCondition(ownMeta.conditions, context)) {
|
|
62
89
|
return [];
|
|
63
90
|
}
|
|
64
91
|
}
|
|
92
|
+
const relativeOf = (p) => p === baseDir ? "" : baseDir === "" ? p : p.slice(baseDir.length + 1);
|
|
65
93
|
if (ownMeta?.type === "file") {
|
|
66
|
-
const parentRelative =
|
|
94
|
+
const parentRelative = relativeOf(dirnamePosix(dir));
|
|
67
95
|
if (ownMeta.rename && ownMeta.rename.length > 0) {
|
|
68
96
|
const resolved = resolveRenameRule(ownMeta.rename, context, dir);
|
|
69
97
|
if (!resolved)
|
|
70
98
|
return [];
|
|
71
|
-
const targetPath = parentRelative
|
|
72
|
-
? join(parentRelative, resolved.targetName)
|
|
73
|
-
: resolved.targetName;
|
|
74
99
|
entries.push({
|
|
75
|
-
|
|
76
|
-
relativePath:
|
|
100
|
+
sourceRelPath: resolved.sourceRelPath,
|
|
101
|
+
relativePath: joinPosix(parentRelative, resolved.targetName),
|
|
77
102
|
meta: effectiveMeta,
|
|
78
103
|
});
|
|
79
104
|
}
|
|
80
105
|
else {
|
|
81
|
-
for (const
|
|
82
|
-
if (
|
|
106
|
+
for (const name of [...node.files].sort()) {
|
|
107
|
+
if (name === META_FILE)
|
|
83
108
|
continue;
|
|
84
|
-
if (!entry.isFile())
|
|
85
|
-
continue;
|
|
86
|
-
const fullPath = join(dir, entry.name);
|
|
87
|
-
const targetPath = parentRelative
|
|
88
|
-
? join(parentRelative, entry.name)
|
|
89
|
-
: entry.name;
|
|
90
109
|
entries.push({
|
|
91
|
-
|
|
92
|
-
relativePath:
|
|
110
|
+
sourceRelPath: joinPosix(dir, name),
|
|
111
|
+
relativePath: joinPosix(parentRelative, name),
|
|
93
112
|
meta: effectiveMeta,
|
|
94
113
|
});
|
|
95
114
|
}
|
|
96
115
|
}
|
|
97
116
|
return entries;
|
|
98
117
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (
|
|
118
|
+
const childNames = [...new Set([...node.files, ...node.subdirs])].sort();
|
|
119
|
+
for (const name of childNames) {
|
|
120
|
+
if (name === META_FILE) {
|
|
102
121
|
continue;
|
|
103
122
|
}
|
|
104
|
-
|
|
105
|
-
|
|
123
|
+
const fullPath = joinPosix(dir, name);
|
|
124
|
+
if (node.subdirs.has(name)) {
|
|
125
|
+
const children = await walkDirectory(tree, vtree, fullPath, baseDir, effectiveMeta, context);
|
|
106
126
|
entries.push(...children);
|
|
107
127
|
}
|
|
108
|
-
else
|
|
128
|
+
else {
|
|
109
129
|
entries.push({
|
|
110
|
-
|
|
111
|
-
relativePath:
|
|
130
|
+
sourceRelPath: fullPath,
|
|
131
|
+
relativePath: relativeOf(fullPath),
|
|
112
132
|
meta: effectiveMeta,
|
|
113
133
|
});
|
|
114
134
|
}
|
|
@@ -131,12 +151,21 @@ const deduplicateByPath = (entries) => {
|
|
|
131
151
|
}
|
|
132
152
|
return [...byPath.values()];
|
|
133
153
|
};
|
|
134
|
-
export const
|
|
135
|
-
const
|
|
154
|
+
export const walkAssetDir = async (tree, context) => {
|
|
155
|
+
const files = await tree.listFiles();
|
|
156
|
+
const vtree = buildVirtualTree(files);
|
|
157
|
+
const meta = await readMetaJson(tree, vtree, "");
|
|
158
|
+
const entries = await walkDirectory(tree, vtree, "", "", meta, context);
|
|
159
|
+
return deduplicateByPath(entries);
|
|
160
|
+
};
|
|
161
|
+
export const walkAssetRepo = async (tree, targetSemver, context) => {
|
|
162
|
+
const files = await tree.listFiles();
|
|
163
|
+
const vtree = buildVirtualTree(files);
|
|
164
|
+
const versionDirs = await findMatchingVersionDirs(tree, vtree, targetSemver);
|
|
136
165
|
const allEntries = [];
|
|
137
166
|
for (const versionDir of versionDirs) {
|
|
138
|
-
const meta = await readMetaJson(versionDir);
|
|
139
|
-
const entries = await walkDirectory(versionDir, versionDir, meta, context);
|
|
167
|
+
const meta = await readMetaJson(tree, vtree, versionDir);
|
|
168
|
+
const entries = await walkDirectory(tree, vtree, versionDir, versionDir, meta, context);
|
|
140
169
|
allEntries.push(...entries);
|
|
141
170
|
}
|
|
142
171
|
return deduplicateByPath(allEntries);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AssetProvider } from "../core/types.js";
|
|
2
|
+
export type AssetProviderArgs = {
|
|
3
|
+
assetSource?: string;
|
|
4
|
+
assetServerUrl?: string;
|
|
5
|
+
assetRef?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const selectAssetProvider: (args: AssetProviderArgs, locale: string) => Promise<AssetProvider>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, } from "../core/constants.js";
|
|
2
|
+
import { createFileAssetProvider } from "../asset/file-provider.js";
|
|
3
|
+
import { createGitAssetProvider } from "../asset/git-provider.js";
|
|
4
|
+
export const selectAssetProvider = async (args, locale) => {
|
|
5
|
+
if (args.assetSource) {
|
|
6
|
+
return createFileAssetProvider(args.assetSource);
|
|
7
|
+
}
|
|
8
|
+
return createGitAssetProvider(args.assetServerUrl ?? DEFAULT_ASSET_REPO_URL, args.assetRef ?? DEFAULT_ASSET_REF, { locale });
|
|
9
|
+
};
|
package/dist/commands/attach.js
CHANGED
|
@@ -2,12 +2,10 @@ import { defineCommand } from "citty";
|
|
|
2
2
|
import * as p from "@clack/prompts";
|
|
3
3
|
import { stat } from "node:fs/promises";
|
|
4
4
|
import { basename, join } from "node:path";
|
|
5
|
-
import { CLI_VERSION
|
|
5
|
+
import { CLI_VERSION } from "../core/constants.js";
|
|
6
6
|
import { runPrompts } from "../interactive/prompts.js";
|
|
7
7
|
import { deployAssets, } from "../asset/deployer.js";
|
|
8
|
-
import {
|
|
9
|
-
import { createFileAssetProvider } from "../asset/file-provider.js";
|
|
10
|
-
import { createGitHubAssetProvider } from "../asset/github-provider.js";
|
|
8
|
+
import { selectAssetProvider } from "./asset-provider.js";
|
|
11
9
|
import { getMessage } from "../i18n/index.js";
|
|
12
10
|
import { detectLocale } from "../utils/locale-detect.js";
|
|
13
11
|
import { printSummary } from "../interactive/summary.js";
|
|
@@ -92,19 +90,15 @@ export const attachCommand = defineCommand({
|
|
|
92
90
|
},
|
|
93
91
|
"asset-server-url": {
|
|
94
92
|
type: "string",
|
|
95
|
-
description: "
|
|
93
|
+
description: "Git repository URL to fetch assets from (overrides the default repository)",
|
|
96
94
|
},
|
|
97
95
|
"asset-ref": {
|
|
98
96
|
type: "string",
|
|
99
|
-
description: "Git
|
|
97
|
+
description: "Git branch/tag to fetch from the asset repository. Default: experiment",
|
|
100
98
|
},
|
|
101
99
|
"asset-source": {
|
|
102
100
|
type: "string",
|
|
103
|
-
description: "(debug) Local asset source
|
|
104
|
-
},
|
|
105
|
-
"debug-server-url": {
|
|
106
|
-
type: "string",
|
|
107
|
-
description: "(debug) Local asset server URL serving GET /archive",
|
|
101
|
+
description: "(debug) Local asset source directory",
|
|
108
102
|
},
|
|
109
103
|
},
|
|
110
104
|
run: async ({ args }) => {
|
|
@@ -170,18 +164,15 @@ export const attachCommand = defineCommand({
|
|
|
170
164
|
javascript: resolved.javascript,
|
|
171
165
|
locale: resolved.locale,
|
|
172
166
|
packageManager: resolved.packageManager,
|
|
173
|
-
jugglingProject: resolved.jugglingProject,
|
|
167
|
+
jugglingProject: resolved.jugglingProject ?? null,
|
|
174
168
|
deployedAssets: {},
|
|
175
169
|
};
|
|
176
|
-
const assetSource = args["asset-source"];
|
|
177
|
-
const debugServerUrl = args["debug-server-url"];
|
|
178
|
-
const provider = assetSource
|
|
179
|
-
? createFileAssetProvider(assetSource)
|
|
180
|
-
: debugServerUrl
|
|
181
|
-
? createLocalAssetProvider(debugServerUrl)
|
|
182
|
-
: createGitHubAssetProvider(args["asset-server-url"] ??
|
|
183
|
-
DEFAULT_ASSET_REPO_URL, args["asset-ref"] ?? DEFAULT_ASSET_REF);
|
|
184
170
|
const isInteractive = !args["non-interactive"];
|
|
171
|
+
const provider = await selectAssetProvider({
|
|
172
|
+
assetSource: args["asset-source"],
|
|
173
|
+
assetServerUrl: args["asset-server-url"],
|
|
174
|
+
assetRef: args["asset-ref"],
|
|
175
|
+
}, locale);
|
|
185
176
|
const overwriteFlag = args.overwrite;
|
|
186
177
|
if (isInteractive) {
|
|
187
178
|
printSummary(settings, projectDir, locale);
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import type { AccelCredentials, SetupConfigResponse, StagingResponse } from "../core/types.js";
|
|
2
2
|
import { type ApiClient } from "../deploy/api-client.js";
|
|
3
|
-
|
|
4
|
-
type ConfirmInfo = {
|
|
3
|
+
import { type DeployFile } from "../deploy/deploy-files.js";
|
|
4
|
+
export type ConfirmInfo = {
|
|
5
5
|
endpoint: string;
|
|
6
6
|
stagingId: string;
|
|
7
|
-
|
|
8
|
-
sentAs: string;
|
|
7
|
+
files: DeployFile[];
|
|
9
8
|
};
|
|
10
9
|
export type DeployPrompts = {
|
|
11
10
|
selectStaging: (stagings: StagingResponse[], locale: string) => Promise<string>;
|
|
12
11
|
selectZip: (zips: string[], locale: string) => Promise<string>;
|
|
13
12
|
description: (locale: string) => Promise<string>;
|
|
13
|
+
confirmOrder: (files: DeployFile[], locale: string) => Promise<boolean>;
|
|
14
|
+
selectNextFile: (candidates: DeployFile[], position: number, total: number, locale: string) => Promise<DeployFile>;
|
|
14
15
|
confirm: (info: ConfirmInfo, locale: string) => Promise<boolean>;
|
|
15
16
|
confirmSetup: (configs: SetupConfigResponse[], locale: string) => Promise<boolean>;
|
|
16
17
|
confirmSetupAll: (locale: string) => Promise<boolean>;
|
|
17
|
-
selectSetupConfigs: (configs: SetupConfigResponse[], locale: string) => Promise<
|
|
18
|
+
selectSetupConfigs: (configs: SetupConfigResponse[], locale: string) => Promise<SetupConfigResponse[]>;
|
|
18
19
|
};
|
|
19
20
|
export type RunDeployDeps = {
|
|
20
21
|
projectDir: string;
|
|
@@ -24,6 +25,7 @@ export type RunDeployDeps = {
|
|
|
24
25
|
apiKey?: string;
|
|
25
26
|
stagingId?: string;
|
|
26
27
|
file?: string;
|
|
28
|
+
additionalFiles?: string[];
|
|
27
29
|
description?: string;
|
|
28
30
|
env?: Record<string, string | undefined>;
|
|
29
31
|
ensureCredentials?: (projectDir: string, locale: string, seed?: Partial<AccelCredentials>) => Promise<AccelCredentials>;
|
|
@@ -52,6 +54,10 @@ export declare const deployCommand: import("citty").CommandDef<{
|
|
|
52
54
|
type: "string";
|
|
53
55
|
description: string;
|
|
54
56
|
};
|
|
57
|
+
"additional-file": {
|
|
58
|
+
type: "string";
|
|
59
|
+
description: string;
|
|
60
|
+
};
|
|
55
61
|
description: {
|
|
56
62
|
type: "string";
|
|
57
63
|
description: string;
|
|
@@ -62,4 +68,3 @@ export declare const deployCommand: import("citty").CommandDef<{
|
|
|
62
68
|
default: false;
|
|
63
69
|
};
|
|
64
70
|
}>;
|
|
65
|
-
export {};
|
package/dist/commands/deploy.js
CHANGED
|
@@ -8,16 +8,19 @@ import { readSettings, readSettingsSafe } from "../utils/settings-io.js";
|
|
|
8
8
|
import { resolveCredentialInputs } from "../utils/credentials.js";
|
|
9
9
|
import { persistCredentialsAndSyncMcp as defaultPersistCredentials } from "../utils/mcp-sync.js";
|
|
10
10
|
import { getMessage } from "../i18n/index.js";
|
|
11
|
-
import { lastFlagValue } from "../utils/args.js";
|
|
11
|
+
import { allFlagValues, lastFlagValue } from "../utils/args.js";
|
|
12
12
|
import { ensureCredentials as defaultEnsureCredentials, repromptCredentials as defaultRepromptCredentials, resolveCredentialsOrThrow as defaultResolveCredentialsOrThrow, } from "../interactive/credentials-prompts.js";
|
|
13
13
|
import { scanTargets as defaultScanTargets } from "../deploy/target-scanner.js";
|
|
14
14
|
import { selectDeployTarget } from "../deploy/target-selector.js";
|
|
15
15
|
import { verifyCredentialsLoop } from "../interactive/credential-auth.js";
|
|
16
16
|
import { createApiClient as defaultApiClientFactory, isDeployError, } from "../deploy/api-client.js";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
import { buildDeployFiles, validateAdditionalFiles, } from "../deploy/deploy-files.js";
|
|
18
|
+
const ADDITIONAL_FILE_ERROR_KEY = {
|
|
19
|
+
notFound: "deploy.error.additionalFileNotFound",
|
|
20
|
+
invalidExtension: "deploy.error.additionalFileInvalidExtension",
|
|
21
|
+
duplicate: "deploy.error.additionalFileDuplicate",
|
|
20
22
|
};
|
|
23
|
+
const setupConfigKey = (c) => `${c.moduleId}\u0000${c.configNumber}`;
|
|
21
24
|
const defaultPrompts = {
|
|
22
25
|
selectStaging: async (stagings, locale) => {
|
|
23
26
|
const res = await p.select({
|
|
@@ -52,12 +55,34 @@ const defaultPrompts = {
|
|
|
52
55
|
process.exit(0);
|
|
53
56
|
return res;
|
|
54
57
|
},
|
|
58
|
+
confirmOrder: async (files, locale) => {
|
|
59
|
+
p.note(files.map((f, i) => `${i + 1}. ${f.display}`).join("\n"), getMessage("deploy.order.heading", locale));
|
|
60
|
+
const res = await p.confirm({
|
|
61
|
+
message: getMessage("deploy.order.confirm", locale),
|
|
62
|
+
initialValue: true,
|
|
63
|
+
});
|
|
64
|
+
if (p.isCancel(res))
|
|
65
|
+
process.exit(0);
|
|
66
|
+
return res;
|
|
67
|
+
},
|
|
68
|
+
selectNextFile: async (candidates, position, total, locale) => {
|
|
69
|
+
const res = await p.select({
|
|
70
|
+
message: getMessage("deploy.order.selectNext", locale, {
|
|
71
|
+
position: String(position),
|
|
72
|
+
total: String(total),
|
|
73
|
+
}),
|
|
74
|
+
options: candidates.map((f) => ({ value: f, label: f.display })),
|
|
75
|
+
});
|
|
76
|
+
if (p.isCancel(res))
|
|
77
|
+
process.exit(0);
|
|
78
|
+
return res;
|
|
79
|
+
},
|
|
55
80
|
confirm: async (info, locale) => {
|
|
56
81
|
p.note([
|
|
57
82
|
`${getMessage("deploy.confirm.endpoint", locale)}: ${info.endpoint}`,
|
|
58
83
|
`${getMessage("deploy.confirm.stagingId", locale)}: ${info.stagingId}`,
|
|
59
|
-
`${getMessage("deploy.confirm.
|
|
60
|
-
|
|
84
|
+
`${getMessage("deploy.confirm.files", locale)}:`,
|
|
85
|
+
...info.files.map((f, i) => ` ${i + 1}. ${f.display}`),
|
|
61
86
|
].join("\n"));
|
|
62
87
|
const res = await p.confirm({
|
|
63
88
|
message: getMessage("deploy.confirm", locale),
|
|
@@ -92,14 +117,15 @@ const defaultPrompts = {
|
|
|
92
117
|
const res = await p.multiselect({
|
|
93
118
|
message: getMessage("deploy.setup.selectConfigs", locale),
|
|
94
119
|
options: configs.map((c) => ({
|
|
95
|
-
value: c
|
|
120
|
+
value: setupConfigKey(c),
|
|
96
121
|
label: `#${c.configNumber} ${c.moduleId} [${c.sections.join(", ")}]`,
|
|
97
122
|
})),
|
|
98
123
|
required: true,
|
|
99
124
|
});
|
|
100
125
|
if (p.isCancel(res))
|
|
101
126
|
process.exit(0);
|
|
102
|
-
|
|
127
|
+
const selected = new Set(res);
|
|
128
|
+
return configs.filter((c) => selected.has(setupConfigKey(c)));
|
|
103
129
|
},
|
|
104
130
|
};
|
|
105
131
|
const resolveLocale = async (projectDir) => {
|
|
@@ -188,6 +214,9 @@ export const runDeploy = async (deps) => {
|
|
|
188
214
|
const seed = resolveCredentialInputs({ endpoint: deps.endpoint, apiKey: deps.apiKey }, env);
|
|
189
215
|
const fileArg = deps.file?.trim();
|
|
190
216
|
const stagingArg = deps.stagingId?.trim();
|
|
217
|
+
const additionalArgs = (deps.additionalFiles ?? [])
|
|
218
|
+
.map((s) => s.trim())
|
|
219
|
+
.filter((s) => s.length > 0);
|
|
191
220
|
p.intro(getMessage("deploy.intro", locale));
|
|
192
221
|
const spin = p.spinner();
|
|
193
222
|
const initialCreds = nonInteractive
|
|
@@ -231,29 +260,40 @@ export const runDeploy = async (deps) => {
|
|
|
231
260
|
scan,
|
|
232
261
|
selectZip: prompts.selectZip,
|
|
233
262
|
});
|
|
263
|
+
const validated = await validateAdditionalFiles(projectDir, additionalArgs, zipPath);
|
|
264
|
+
if (!validated.ok) {
|
|
265
|
+
p.log.error(getMessage(ADDITIONAL_FILE_ERROR_KEY[validated.error.kind], locale, {
|
|
266
|
+
path: validated.error.path,
|
|
267
|
+
}));
|
|
268
|
+
throw new Error(`additional file ${validated.error.kind}`);
|
|
269
|
+
}
|
|
270
|
+
let deployFiles = buildDeployFiles(validated.paths, zipPath, projectDir);
|
|
271
|
+
if (additionalArgs.length > 0 && !nonInteractive) {
|
|
272
|
+
const keepDefault = await prompts.confirmOrder(deployFiles, locale);
|
|
273
|
+
if (!keepDefault) {
|
|
274
|
+
deployFiles = await reorderFiles(deployFiles, prompts, locale);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
234
277
|
const description = (deps.description !== undefined
|
|
235
278
|
? deps.description
|
|
236
279
|
: nonInteractive
|
|
237
280
|
? ""
|
|
238
281
|
: await prompts.description(locale)).trim();
|
|
239
|
-
const immName = toImmFileName(zipPath);
|
|
240
282
|
if (!nonInteractive) {
|
|
241
|
-
const confirmed = await prompts.confirm({
|
|
242
|
-
endpoint: creds.endpoint,
|
|
243
|
-
stagingId,
|
|
244
|
-
sourceFile: basename(zipPath),
|
|
245
|
-
sentAs: immName,
|
|
246
|
-
}, locale);
|
|
283
|
+
const confirmed = await prompts.confirm({ endpoint: creds.endpoint, stagingId, files: deployFiles }, locale);
|
|
247
284
|
if (!confirmed) {
|
|
248
285
|
p.log.info(getMessage("deploy.cancelled", locale));
|
|
249
286
|
return;
|
|
250
287
|
}
|
|
251
288
|
}
|
|
252
|
-
const
|
|
289
|
+
const archives = [];
|
|
290
|
+
for (const file of deployFiles) {
|
|
291
|
+
archives.push({ bytes: await readFile(file.path), fileName: file.sentAs });
|
|
292
|
+
}
|
|
253
293
|
spin.start(getMessage("deploy.progress.deploying", locale));
|
|
254
294
|
let result;
|
|
255
295
|
try {
|
|
256
|
-
result = await api.createDeployment(stagingId,
|
|
296
|
+
result = await api.createDeployment(stagingId, archives, description.length > 0 ? description : undefined);
|
|
257
297
|
}
|
|
258
298
|
catch (err) {
|
|
259
299
|
spin.stop(getMessage("deploy.progress.deploying", locale));
|
|
@@ -285,6 +325,16 @@ export const runDeploy = async (deps) => {
|
|
|
285
325
|
}
|
|
286
326
|
p.outro(getMessage("deploy.success", locale));
|
|
287
327
|
};
|
|
328
|
+
const reorderFiles = async (files, prompts, locale) => {
|
|
329
|
+
const remaining = [...files];
|
|
330
|
+
const ordered = [];
|
|
331
|
+
while (remaining.length > 1) {
|
|
332
|
+
const picked = await prompts.selectNextFile(remaining, ordered.length + 1, files.length, locale);
|
|
333
|
+
ordered.push(picked);
|
|
334
|
+
remaining.splice(remaining.findIndex((f) => f.path === picked.path), 1);
|
|
335
|
+
}
|
|
336
|
+
return [...ordered, ...remaining];
|
|
337
|
+
};
|
|
288
338
|
const runSetup = async (api, stagingId, configs, locale, prompts, spin) => {
|
|
289
339
|
const doSetup = await prompts.confirmSetup(configs, locale);
|
|
290
340
|
if (!doSetup)
|
|
@@ -302,17 +352,16 @@ const runSetup = async (api, stagingId, configs, locale, prompts, spin) => {
|
|
|
302
352
|
}
|
|
303
353
|
else {
|
|
304
354
|
const selected = await prompts.selectSetupConfigs(configs, locale);
|
|
355
|
+
const selectedKeys = new Set(selected.map(setupConfigKey));
|
|
356
|
+
const ordered = configs.filter((c) => selectedKeys.has(setupConfigKey(c)));
|
|
305
357
|
const allResults = [];
|
|
306
358
|
let allSuccess = true;
|
|
307
|
-
for (const
|
|
308
|
-
const
|
|
309
|
-
const label = config
|
|
310
|
-
? `#${config.configNumber} ${config.moduleId}`
|
|
311
|
-
: `#${configNumber}`;
|
|
359
|
+
for (const config of ordered) {
|
|
360
|
+
const label = `#${config.configNumber} ${config.moduleId}`;
|
|
312
361
|
spin.start(getMessage("deploy.setup.executing", locale, { config: label }));
|
|
313
362
|
let partial;
|
|
314
363
|
try {
|
|
315
|
-
partial = await api.executeSetupConfig(stagingId, configNumber);
|
|
364
|
+
partial = await api.executeSetupConfig(stagingId, config.moduleId, config.configNumber);
|
|
316
365
|
}
|
|
317
366
|
finally {
|
|
318
367
|
spin.stop(getMessage("deploy.setup.executing", locale, { config: label }));
|
|
@@ -393,6 +442,10 @@ export const deployCommand = defineCommand({
|
|
|
393
442
|
type: "string",
|
|
394
443
|
description: "Path to the zip to deploy (not restricted to ./target/)",
|
|
395
444
|
},
|
|
445
|
+
"additional-file": {
|
|
446
|
+
type: "string",
|
|
447
|
+
description: "Additional archive (.imm/.zip) deployed before the main artifact (repeatable)",
|
|
448
|
+
},
|
|
396
449
|
description: {
|
|
397
450
|
type: "string",
|
|
398
451
|
description: "Deployment description",
|
|
@@ -412,6 +465,7 @@ export const deployCommand = defineCommand({
|
|
|
412
465
|
apiKey: lastFlagValue(args["api-key"]),
|
|
413
466
|
stagingId: lastFlagValue(args["staging-id"]),
|
|
414
467
|
file: lastFlagValue(args.file),
|
|
468
|
+
additionalFiles: allFlagValues(args["additional-file"]),
|
|
415
469
|
description: lastFlagValue(args.description),
|
|
416
470
|
});
|
|
417
471
|
}
|
package/dist/commands/init.d.ts
CHANGED
package/dist/commands/init.js
CHANGED
|
@@ -3,12 +3,10 @@ import * as p from "@clack/prompts";
|
|
|
3
3
|
import { mkdir, stat } from "node:fs/promises";
|
|
4
4
|
import { execSync } from "node:child_process";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
|
-
import { CLI_VERSION
|
|
6
|
+
import { CLI_VERSION } from "../core/constants.js";
|
|
7
7
|
import { runPrompts } from "../interactive/prompts.js";
|
|
8
8
|
import { deployAssets } from "../asset/deployer.js";
|
|
9
|
-
import {
|
|
10
|
-
import { createFileAssetProvider } from "../asset/file-provider.js";
|
|
11
|
-
import { createGitHubAssetProvider } from "../asset/github-provider.js";
|
|
9
|
+
import { selectAssetProvider } from "./asset-provider.js";
|
|
12
10
|
import { getMessage } from "../i18n/index.js";
|
|
13
11
|
import { detectLocale } from "../utils/locale-detect.js";
|
|
14
12
|
import { commandExists } from "../utils/command-exists.js";
|
|
@@ -95,19 +93,15 @@ export const initCommand = defineCommand({
|
|
|
95
93
|
},
|
|
96
94
|
"asset-server-url": {
|
|
97
95
|
type: "string",
|
|
98
|
-
description: "
|
|
96
|
+
description: "Git repository URL to fetch assets from (overrides the default repository)",
|
|
99
97
|
},
|
|
100
98
|
"asset-ref": {
|
|
101
99
|
type: "string",
|
|
102
|
-
description: "Git
|
|
100
|
+
description: "Git branch/tag to fetch from the asset repository. Default: experiment",
|
|
103
101
|
},
|
|
104
102
|
"asset-source": {
|
|
105
103
|
type: "string",
|
|
106
|
-
description: "(debug) Local asset source
|
|
107
|
-
},
|
|
108
|
-
"debug-server-url": {
|
|
109
|
-
type: "string",
|
|
110
|
-
description: "(debug) Local asset server URL serving GET /archive",
|
|
104
|
+
description: "(debug) Local asset source directory",
|
|
111
105
|
},
|
|
112
106
|
},
|
|
113
107
|
run: async ({ args }) => {
|
|
@@ -176,21 +170,18 @@ export const initCommand = defineCommand({
|
|
|
176
170
|
javascript: resolved.javascript,
|
|
177
171
|
locale: resolved.locale,
|
|
178
172
|
packageManager: resolved.packageManager,
|
|
179
|
-
jugglingProject: resolved.jugglingProject,
|
|
173
|
+
jugglingProject: resolved.jugglingProject ?? null,
|
|
180
174
|
deployedAssets: {},
|
|
181
175
|
};
|
|
182
176
|
const isInteractive = !args["non-interactive"];
|
|
183
177
|
if (isInteractive) {
|
|
184
178
|
printSummary(settings, projectDir, locale);
|
|
185
179
|
}
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
? createLocalAssetProvider(debugServerUrl)
|
|
192
|
-
: createGitHubAssetProvider(args["asset-server-url"] ??
|
|
193
|
-
DEFAULT_ASSET_REPO_URL, args["asset-ref"] ?? DEFAULT_ASSET_REF);
|
|
180
|
+
const provider = await selectAssetProvider({
|
|
181
|
+
assetSource: args["asset-source"],
|
|
182
|
+
assetServerUrl: args["asset-server-url"],
|
|
183
|
+
assetRef: args["asset-ref"],
|
|
184
|
+
}, locale);
|
|
194
185
|
await deployAssets({
|
|
195
186
|
projectDir,
|
|
196
187
|
settings,
|