ferst-core 0.5.1 → 0.5.2
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/check-thin.mjs +17 -2
- package/bin/cms-config.mjs +19 -3
- package/package.json +1 -1
package/bin/check-thin.mjs
CHANGED
|
@@ -6,10 +6,25 @@
|
|
|
6
6
|
// only content DATA, pages, the content config re-export, and a `custom/`
|
|
7
7
|
// override sandbox. Shipped from core (its own single source) and run in each
|
|
8
8
|
// client's CI/build: `ferst-check-thin [srcDir]` (defaults to ./src).
|
|
9
|
-
import { readdirSync, statSync, existsSync } from 'node:fs';
|
|
9
|
+
import { readdirSync, statSync, existsSync, realpathSync } from 'node:fs';
|
|
10
10
|
import { join, relative } from 'node:path';
|
|
11
11
|
import { pathToFileURL } from 'node:url';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* True when run as a CLI (not imported). Handles npm's `node_modules/.bin` symlink,
|
|
15
|
+
* where `process.argv[1]` is the symlink path but `import.meta.url` is the realpath —
|
|
16
|
+
* a plain `===` check silently skips `main()`, making this guard a false pass.
|
|
17
|
+
*/
|
|
18
|
+
export function isDirectInvocation(argv1) {
|
|
19
|
+
if (!argv1) return false;
|
|
20
|
+
if (import.meta.url === pathToFileURL(argv1).href) return true;
|
|
21
|
+
try {
|
|
22
|
+
return import.meta.url === pathToFileURL(realpathSync(argv1)).href;
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
13
28
|
// Directories directly under src/ that belong to the core, not the client.
|
|
14
29
|
const CORE_OWNED_DIRS = ['components', 'layouts', 'lib', 'utils', 'styles'];
|
|
15
30
|
// Files under src/content/ that are the core's contract, not client data.
|
|
@@ -69,6 +84,6 @@ function main() {
|
|
|
69
84
|
}
|
|
70
85
|
|
|
71
86
|
// Run only when invoked directly as a bin (not when imported by a test).
|
|
72
|
-
if (
|
|
87
|
+
if (isDirectInvocation(process.argv[1])) {
|
|
73
88
|
main();
|
|
74
89
|
}
|
package/bin/cms-config.mjs
CHANGED
|
@@ -14,11 +14,27 @@
|
|
|
14
14
|
//
|
|
15
15
|
// Output path: dist/admin/config.yml under the CWD (the client repo root at build
|
|
16
16
|
// time). Override with a first CLI arg.
|
|
17
|
-
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
17
|
+
import { readFileSync, writeFileSync, mkdirSync, realpathSync } from 'node:fs';
|
|
18
18
|
import { execSync } from 'node:child_process';
|
|
19
19
|
import { dirname, resolve } from 'node:path';
|
|
20
20
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* True when this file is being run as a CLI (not imported). Handles npm's
|
|
24
|
+
* `node_modules/.bin` **symlink**: there `process.argv[1]` is the symlink path but
|
|
25
|
+
* `import.meta.url` is the realpath, so a plain `===` check silently skips `main()`
|
|
26
|
+
* and the config is never generated — the bug this guards against.
|
|
27
|
+
*/
|
|
28
|
+
export function isDirectInvocation(argv1) {
|
|
29
|
+
if (!argv1) return false;
|
|
30
|
+
if (import.meta.url === pathToFileURL(argv1).href) return true;
|
|
31
|
+
try {
|
|
32
|
+
return import.meta.url === pathToFileURL(realpathSync(argv1)).href;
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
22
38
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
23
39
|
export const TEMPLATE_PATH = resolve(HERE, '../cms/config.template.yml');
|
|
24
40
|
|
|
@@ -132,7 +148,7 @@ function main() {
|
|
|
132
148
|
console.log(`ferst-cms-config: wrote ${outPath} (repo=${repo}, branch="${branch}", base=${base})`);
|
|
133
149
|
}
|
|
134
150
|
|
|
135
|
-
// Run
|
|
136
|
-
if (
|
|
151
|
+
// Run when invoked directly as a bin — including via npm's node_modules/.bin symlink.
|
|
152
|
+
if (isDirectInvocation(process.argv[1])) {
|
|
137
153
|
main();
|
|
138
154
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ferst-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ferst Core — the shared, brand-agnostic client-site system: Astro components, layouts, content schemas, the layered config resolver, and a neutral styling architecture that every client overrides.",
|
|
6
6
|
"license": "BUSL-1.1",
|