@zenithbuild/cli 0.6.7 → 0.6.10
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/dist/build.js +2 -2
- package/dist/toolchain-paths.js +72 -6
- package/dist/toolchain-runner.js +31 -3
- package/dist/ui/format.js +1 -1
- package/package.json +2 -2
package/dist/build.js
CHANGED
|
@@ -19,7 +19,7 @@ import { generateManifest } from './manifest.js';
|
|
|
19
19
|
import { buildComponentRegistry, expandComponents, extractTemplate, isDocumentMode } from './resolve-components.js';
|
|
20
20
|
import { collectExpandedComponentOccurrences } from './component-occurrences.js';
|
|
21
21
|
import { applyOccurrenceRewritePlans, cloneComponentIrForInstance } from './component-instance-ir.js';
|
|
22
|
-
import { resolveBundlerBin
|
|
22
|
+
import { resolveBundlerBin } from './toolchain-paths.js';
|
|
23
23
|
import { createBundlerToolchain, createCompilerToolchain, ensureToolchainCompatibility, getActiveToolchainCandidate, runToolchainSync } from './toolchain-runner.js';
|
|
24
24
|
import { maybeWarnAboutZenithVersionMismatch } from './version-check.js';
|
|
25
25
|
const require = createRequire(import.meta.url);
|
|
@@ -106,7 +106,7 @@ function runCompiler(filePath, stdinSource, compilerOpts = {}, compilerRunOption
|
|
|
106
106
|
: null);
|
|
107
107
|
const compilerBin = !compilerToolchain && typeof compilerRunOptions.compilerBin === 'string'
|
|
108
108
|
? compilerRunOptions.compilerBin
|
|
109
|
-
:
|
|
109
|
+
: null;
|
|
110
110
|
const args = stdinSource !== undefined
|
|
111
111
|
? ['--stdin', filePath]
|
|
112
112
|
: [filePath];
|
package/dist/toolchain-paths.js
CHANGED
|
@@ -8,6 +8,42 @@ const CLI_ROOT = resolve(__dirname, '..');
|
|
|
8
8
|
const localRequire = createRequire(import.meta.url);
|
|
9
9
|
const IS_WINDOWS = process.platform === 'win32';
|
|
10
10
|
const COMPILER_BRIDGE_RUNNER = resolve(__dirname, 'compiler-bridge-runner.js');
|
|
11
|
+
const COMPILER_PLATFORM_PACKAGES = {
|
|
12
|
+
'darwin-arm64': {
|
|
13
|
+
packageName: '@zenithbuild/compiler-darwin-arm64',
|
|
14
|
+
binaryName: 'zenith-compiler'
|
|
15
|
+
},
|
|
16
|
+
'darwin-x64': {
|
|
17
|
+
packageName: '@zenithbuild/compiler-darwin-x64',
|
|
18
|
+
binaryName: 'zenith-compiler'
|
|
19
|
+
},
|
|
20
|
+
'linux-x64': {
|
|
21
|
+
packageName: '@zenithbuild/compiler-linux-x64',
|
|
22
|
+
binaryName: 'zenith-compiler'
|
|
23
|
+
},
|
|
24
|
+
'win32-x64': {
|
|
25
|
+
packageName: '@zenithbuild/compiler-win32-x64',
|
|
26
|
+
binaryName: 'zenith-compiler.exe'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const BUNDLER_PLATFORM_PACKAGES = {
|
|
30
|
+
'darwin-arm64': {
|
|
31
|
+
packageName: '@zenithbuild/bundler-darwin-arm64',
|
|
32
|
+
binaryName: 'zenith-bundler'
|
|
33
|
+
},
|
|
34
|
+
'darwin-x64': {
|
|
35
|
+
packageName: '@zenithbuild/bundler-darwin-x64',
|
|
36
|
+
binaryName: 'zenith-bundler'
|
|
37
|
+
},
|
|
38
|
+
'linux-x64': {
|
|
39
|
+
packageName: '@zenithbuild/bundler-linux-x64',
|
|
40
|
+
binaryName: 'zenith-bundler'
|
|
41
|
+
},
|
|
42
|
+
'win32-x64': {
|
|
43
|
+
packageName: '@zenithbuild/bundler-win32-x64',
|
|
44
|
+
binaryName: 'zenith-bundler.exe'
|
|
45
|
+
}
|
|
46
|
+
};
|
|
11
47
|
function safeCreateRequire(projectRoot) {
|
|
12
48
|
if (!projectRoot) {
|
|
13
49
|
return localRequire;
|
|
@@ -68,6 +104,9 @@ function createCompilerBridgeCandidate(modulePath) {
|
|
|
68
104
|
argsPrefix: [COMPILER_BRIDGE_RUNNER, '--bridge-module', modulePath]
|
|
69
105
|
};
|
|
70
106
|
}
|
|
107
|
+
function currentPlatformPackage(packages) {
|
|
108
|
+
return packages[`${process.platform}-${process.arch}`] || null;
|
|
109
|
+
}
|
|
71
110
|
export function resolveBinary(candidates) {
|
|
72
111
|
for (const candidate of candidates) {
|
|
73
112
|
const path = typeof candidate === 'string' ? candidate : candidate.path;
|
|
@@ -112,6 +151,24 @@ export function readCliPackageVersion() {
|
|
|
112
151
|
return '0.0.0';
|
|
113
152
|
}
|
|
114
153
|
}
|
|
154
|
+
function createInstalledPlatformPackageCandidate(tool, packages, projectRoot) {
|
|
155
|
+
const platformPackage = currentPlatformPackage(packages);
|
|
156
|
+
if (!platformPackage) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const platformPackageRoot = resolvePackageRoot(platformPackage.packageName, projectRoot);
|
|
160
|
+
if (!platformPackageRoot) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
return createBinaryCandidate(tool, 'installed platform package binary', resolve(platformPackageRoot, 'bin', platformPackage.binaryName));
|
|
164
|
+
}
|
|
165
|
+
function createLegacyInstalledPackageCandidate(tool, packageName, binaryName, projectRoot) {
|
|
166
|
+
const installedRoot = resolvePackageRoot(packageName, projectRoot);
|
|
167
|
+
if (!installedRoot) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return createBinaryCandidate(tool, 'legacy installed package binary', resolve(installedRoot, 'target', 'release', binaryName));
|
|
171
|
+
}
|
|
115
172
|
function compilerWorkspaceBinaryCandidates() {
|
|
116
173
|
return [
|
|
117
174
|
createBinaryCandidate('compiler', 'workspace binary', resolve(CLI_ROOT, '../compiler/target/release/zenith-compiler')),
|
|
@@ -133,11 +190,16 @@ export function compilerCommandCandidates(projectRoot = null, env = process.env)
|
|
|
133
190
|
explicit: true
|
|
134
191
|
});
|
|
135
192
|
}
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
candidates.push(
|
|
193
|
+
const platformCandidate = createInstalledPlatformPackageCandidate('compiler', COMPILER_PLATFORM_PACKAGES, projectRoot);
|
|
194
|
+
if (platformCandidate) {
|
|
195
|
+
candidates.push(platformCandidate);
|
|
196
|
+
}
|
|
197
|
+
const legacyCandidate = createLegacyInstalledPackageCandidate('compiler', '@zenithbuild/compiler', IS_WINDOWS ? 'zenith-compiler.exe' : 'zenith-compiler', projectRoot);
|
|
198
|
+
if (legacyCandidate) {
|
|
199
|
+
candidates.push(legacyCandidate);
|
|
139
200
|
}
|
|
140
201
|
candidates.push(...compilerWorkspaceBinaryCandidates());
|
|
202
|
+
const installedRoot = resolvePackageRoot('@zenithbuild/compiler', projectRoot);
|
|
141
203
|
if (installedRoot) {
|
|
142
204
|
const bridgeCandidate = createCompilerBridgeCandidate(resolve(installedRoot, 'dist/index.js'));
|
|
143
205
|
if (bridgeCandidate) {
|
|
@@ -163,9 +225,13 @@ export function bundlerCommandCandidates(projectRoot = null, env = process.env)
|
|
|
163
225
|
explicit: true
|
|
164
226
|
});
|
|
165
227
|
}
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
candidates.push(
|
|
228
|
+
const platformCandidate = createInstalledPlatformPackageCandidate('bundler', BUNDLER_PLATFORM_PACKAGES, projectRoot);
|
|
229
|
+
if (platformCandidate) {
|
|
230
|
+
candidates.push(platformCandidate);
|
|
231
|
+
}
|
|
232
|
+
const legacyCandidate = createLegacyInstalledPackageCandidate('bundler', '@zenithbuild/bundler', IS_WINDOWS ? 'zenith-bundler.exe' : 'zenith-bundler', projectRoot);
|
|
233
|
+
if (legacyCandidate) {
|
|
234
|
+
candidates.push(legacyCandidate);
|
|
169
235
|
}
|
|
170
236
|
candidates.push(...bundlerWorkspaceBinaryCandidates());
|
|
171
237
|
return candidates;
|
package/dist/toolchain-runner.js
CHANGED
|
@@ -9,6 +9,7 @@ const INCOMPATIBLE_STDERR_PATTERNS = [
|
|
|
9
9
|
/cannot execute binary file/i,
|
|
10
10
|
/not a valid win32 application/i
|
|
11
11
|
];
|
|
12
|
+
const INSTALL_COMPATIBILITY_DOC = 'https://github.com/zenithbuild/framework/blob/master/docs/documentation/install-compatibility.md';
|
|
12
13
|
function currentPlatformLabel() {
|
|
13
14
|
return `${process.platform}-${process.arch}`;
|
|
14
15
|
}
|
|
@@ -53,9 +54,20 @@ function emitFallbackWarning(toolchain, nextCandidate) {
|
|
|
53
54
|
FALLBACK_LOG_KEYS.add(onceKey);
|
|
54
55
|
console.warn(message);
|
|
55
56
|
}
|
|
57
|
+
function missingToolchainError(toolchain) {
|
|
58
|
+
if (toolchain.tool === 'bundler') {
|
|
59
|
+
return new Error(`[zenith] Bundler binary not installed for ${process.platform}/${process.arch}. ` +
|
|
60
|
+
`Reinstall @zenithbuild/bundler and ensure the matching platform package is installed. ` +
|
|
61
|
+
`See ${INSTALL_COMPATIBILITY_DOC}.`);
|
|
62
|
+
}
|
|
63
|
+
return new Error(`[zenith] ${toolchain.tool} binary not installed for ${currentPlatformLabel()}; ` +
|
|
64
|
+
`reinstall, ensure the matching platform package is installed, or set ${toolEnvVar(toolchain.tool)}=... ` +
|
|
65
|
+
`See ${INSTALL_COMPATIBILITY_DOC}.`);
|
|
66
|
+
}
|
|
56
67
|
function incompatibleBinaryError(toolchain) {
|
|
57
68
|
return new Error(`[zenith] ${toolchain.tool} binary is incompatible for ${currentPlatformLabel()}; ` +
|
|
58
|
-
`reinstall or set ${toolEnvVar(toolchain.tool)}
|
|
69
|
+
`reinstall, clear the wrong-platform package, or set ${toolEnvVar(toolchain.tool)}=... ` +
|
|
70
|
+
`See ${INSTALL_COMPATIBILITY_DOC}.`);
|
|
59
71
|
}
|
|
60
72
|
function toolchainProbeError(toolchain, result) {
|
|
61
73
|
const detail = result?.error?.message
|
|
@@ -115,6 +127,14 @@ export function ensureToolchainCompatibility(toolchain, probeArgs = ['--version'
|
|
|
115
127
|
if (!candidate) {
|
|
116
128
|
break;
|
|
117
129
|
}
|
|
130
|
+
if (!candidateExists(candidate)) {
|
|
131
|
+
const nextIndex = findNextFallbackIndex(toolchain, probeArgs);
|
|
132
|
+
if (nextIndex === -1) {
|
|
133
|
+
throw missingToolchainError(toolchain);
|
|
134
|
+
}
|
|
135
|
+
toolchain.activeIndex = nextIndex;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
118
138
|
if (!candidateSupportsArgs(candidate, probeArgs)) {
|
|
119
139
|
const nextIndex = findNextFallbackIndex(toolchain, probeArgs);
|
|
120
140
|
if (nextIndex === -1) {
|
|
@@ -138,7 +158,7 @@ export function ensureToolchainCompatibility(toolchain, probeArgs = ['--version'
|
|
|
138
158
|
toolchain.activeIndex = nextIndex;
|
|
139
159
|
emitFallbackWarning(toolchain, toolchain.candidates[nextIndex]);
|
|
140
160
|
}
|
|
141
|
-
throw
|
|
161
|
+
throw missingToolchainError(toolchain);
|
|
142
162
|
}
|
|
143
163
|
export function runToolchainSync(toolchain, args, spawnOptions = { encoding: 'utf8' }) {
|
|
144
164
|
while (toolchain.activeIndex < toolchain.candidates.length) {
|
|
@@ -146,6 +166,14 @@ export function runToolchainSync(toolchain, args, spawnOptions = { encoding: 'ut
|
|
|
146
166
|
if (!candidate) {
|
|
147
167
|
break;
|
|
148
168
|
}
|
|
169
|
+
if (!candidateExists(candidate)) {
|
|
170
|
+
const nextIndex = findNextFallbackIndex(toolchain, args);
|
|
171
|
+
if (nextIndex === -1) {
|
|
172
|
+
throw missingToolchainError(toolchain);
|
|
173
|
+
}
|
|
174
|
+
toolchain.activeIndex = nextIndex;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
149
177
|
if (!candidateSupportsArgs(candidate, args)) {
|
|
150
178
|
const nextIndex = findNextFallbackIndex(toolchain, args);
|
|
151
179
|
if (nextIndex === -1) {
|
|
@@ -166,5 +194,5 @@ export function runToolchainSync(toolchain, args, spawnOptions = { encoding: 'ut
|
|
|
166
194
|
toolchain.activeIndex = nextIndex;
|
|
167
195
|
emitFallbackWarning(toolchain, toolchain.candidates[nextIndex]);
|
|
168
196
|
}
|
|
169
|
-
throw
|
|
197
|
+
throw missingToolchainError(toolchain);
|
|
170
198
|
}
|
package/dist/ui/format.js
CHANGED
|
@@ -2,7 +2,7 @@ import pc from 'picocolors';
|
|
|
2
2
|
import { relative, sep } from 'node:path';
|
|
3
3
|
const DEFAULT_PHASE = 'cli';
|
|
4
4
|
const DEFAULT_FILE = '.';
|
|
5
|
-
const DEFAULT_HINT_BASE = 'https://github.com/zenithbuild/
|
|
5
|
+
const DEFAULT_HINT_BASE = 'https://github.com/zenithbuild/framework/blob/master/packages/cli/CLI_CONTRACT.md';
|
|
6
6
|
const PREFIX = '[zenith]';
|
|
7
7
|
const TAG_WIDTH = 6;
|
|
8
8
|
const TAG_COLORS = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenithbuild/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "Deterministic project orchestrator for Zenith framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"prepublishOnly": "npm run build"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@zenithbuild/compiler": "0.6.
|
|
37
|
+
"@zenithbuild/compiler": "0.6.10",
|
|
38
38
|
"picocolors": "^1.1.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|