@zenithbuild/core 0.7.10 → 0.7.11
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/bin/zenith-bin-utils.js +29 -0
- package/bin/zenith.js +2 -18
- package/dist/config-targets.d.ts +2 -0
- package/dist/config-targets.js +9 -0
- package/dist/config-types.d.ts +1 -1
- package/dist/config.js +2 -9
- package/package.json +6 -6
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
export function findPackageVersionForEntry(entryPath, packageName, options = {}) {
|
|
5
|
+
const readFile = options.readFile || readFileSync;
|
|
6
|
+
const pathApi = options.pathApi || path;
|
|
7
|
+
let currentDir = pathApi.dirname(entryPath);
|
|
8
|
+
const rootDir = pathApi.parse(currentDir).root;
|
|
9
|
+
|
|
10
|
+
while (currentDir && currentDir !== rootDir) {
|
|
11
|
+
try {
|
|
12
|
+
const pkgTxt = readFile(pathApi.join(currentDir, 'package.json'), 'utf-8');
|
|
13
|
+
const pkg = JSON.parse(pkgTxt);
|
|
14
|
+
if (pkg.name === packageName) {
|
|
15
|
+
return typeof pkg.version === 'string' ? pkg.version : null;
|
|
16
|
+
}
|
|
17
|
+
} catch {
|
|
18
|
+
// Continue walking toward the filesystem root.
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const nextDir = pathApi.dirname(currentDir);
|
|
22
|
+
if (nextDir === currentDir) {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
currentDir = nextDir;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return null;
|
|
29
|
+
}
|
package/bin/zenith.js
CHANGED
|
@@ -4,6 +4,7 @@ import { readFileSync } from 'node:fs';
|
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
7
|
+
import { findPackageVersionForEntry } from './zenith-bin-utils.js';
|
|
7
8
|
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
10
|
const __dirname = dirname(__filename);
|
|
@@ -50,24 +51,7 @@ for (const internal of expectedInternals) {
|
|
|
50
51
|
|
|
51
52
|
try {
|
|
52
53
|
const entryPath = resolveInternal(internal);
|
|
53
|
-
|
|
54
|
-
// Walk up to find the package's package.json
|
|
55
|
-
let currentDir = dirname(entryPath);
|
|
56
|
-
let pkgVersion = null;
|
|
57
|
-
|
|
58
|
-
while (currentDir !== '/' && currentDir !== '.') {
|
|
59
|
-
try {
|
|
60
|
-
const pkgTxt = readFileSync(join(currentDir, 'package.json'), 'utf-8');
|
|
61
|
-
const pkg = JSON.parse(pkgTxt);
|
|
62
|
-
if (pkg.name === internal) {
|
|
63
|
-
pkgVersion = pkg.version;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
} catch (e) {
|
|
67
|
-
// Ignored, continue walking up
|
|
68
|
-
}
|
|
69
|
-
currentDir = dirname(currentDir);
|
|
70
|
-
}
|
|
54
|
+
const pkgVersion = findPackageVersionForEntry(entryPath, internal);
|
|
71
55
|
|
|
72
56
|
if (pkgVersion && pkgVersion !== expectedVersion) {
|
|
73
57
|
console.error(`Version mismatch: ${internal} is version ${pkgVersion} but @zenithbuild/core expects exactly ${expectedVersion}`);
|
package/dist/config-types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ZenithTarget
|
|
1
|
+
export type { ZenithTarget } from './config-targets.js';
|
|
2
2
|
export type ZenithRenderMode = 'prerender' | 'server';
|
|
3
3
|
export type ZenithPathKind = 'static' | 'dynamic';
|
|
4
4
|
export interface RouteManifestEntry {
|
package/dist/config.js
CHANGED
|
@@ -3,16 +3,9 @@ import { readFile, rm, writeFile } from 'node:fs/promises';
|
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
5
|
import { pathToFileURL } from 'node:url';
|
|
6
|
+
import { ZENITH_TARGETS } from './config-targets.js';
|
|
6
7
|
const PACKAGE_REQUIRE = createRequire(import.meta.url);
|
|
7
8
|
const CONFIG_FILES = ['zenith.config.ts', 'zenith.config.js'];
|
|
8
|
-
const KNOWN_TARGETS = [
|
|
9
|
-
'static',
|
|
10
|
-
'vercel-static',
|
|
11
|
-
'netlify-static',
|
|
12
|
-
'vercel',
|
|
13
|
-
'netlify',
|
|
14
|
-
'node'
|
|
15
|
-
];
|
|
16
9
|
const DEFAULT_IMAGE_CONFIG = {
|
|
17
10
|
formats: ['webp', 'avif'],
|
|
18
11
|
quality: 75,
|
|
@@ -306,7 +299,7 @@ export function validateConfig(config) {
|
|
|
306
299
|
if (expectedType === 'string' && typeof value === 'string' && value.trim() === '') {
|
|
307
300
|
throw new Error(`[Zenith:Config] Key "${key}" must be a non-empty string`);
|
|
308
301
|
}
|
|
309
|
-
if (key === 'target' && !
|
|
302
|
+
if (key === 'target' && !ZENITH_TARGETS.includes(value)) {
|
|
310
303
|
throw new Error(`[Zenith:Config] Unsupported target: "${value}"`);
|
|
311
304
|
}
|
|
312
305
|
if (key === 'basePath') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenithbuild/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.11",
|
|
4
4
|
"description": "Deterministic utility substrate for the Zenith framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@zenithbuild/cli": "0.7.
|
|
47
|
-
"@zenithbuild/compiler": "0.7.
|
|
48
|
-
"@zenithbuild/runtime": "0.7.
|
|
49
|
-
"@zenithbuild/router": "0.7.
|
|
50
|
-
"@zenithbuild/bundler": "0.7.
|
|
46
|
+
"@zenithbuild/cli": "0.7.11",
|
|
47
|
+
"@zenithbuild/compiler": "0.7.11",
|
|
48
|
+
"@zenithbuild/runtime": "0.7.11",
|
|
49
|
+
"@zenithbuild/router": "0.7.11",
|
|
50
|
+
"@zenithbuild/bundler": "0.7.11"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|