@fundamental-engine/create 0.9.1 → 0.9.3
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
CHANGED
|
@@ -8,15 +8,13 @@ npm create @fundamental-engine my-field-app
|
|
|
8
8
|
npm create @fundamental-engine my-field-app -- --template react
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Three variants, all **signals-first** (the field draws nothing by default — it writes `--field-*` CSS
|
|
12
|
-
variables your styles read; particles are one opt-in surface):
|
|
11
|
+
Three variants, all **signals-first** (the field draws nothing by default — it writes `--field-*` CSS variables your styles read; particles are one opt-in surface):
|
|
13
12
|
|
|
14
13
|
- **`vanilla`** (default) — a *contained, signals-only* field (`FieldField` + `bounds`, `render: 'none'`)
|
|
15
14
|
over a real list. No canvas; the rows react through CSS. The "this is what it's for" starter.
|
|
16
15
|
- **`web-component`** — the `<field-root>` custom element; works in any framework or plain HTML.
|
|
17
16
|
- **`react`** — `<FieldField>` from `@fundamental-engine/react`.
|
|
18
17
|
|
|
19
|
-
Each scaffolds a minimal Vite app you run with `npm install && npm run dev`. Every template is explicit
|
|
20
|
-
about `render`, so it behaves the same whichever engine version it resolves to.
|
|
18
|
+
Each scaffolds a minimal Vite app you run with `npm install && npm run dev`. Every template is explicit about `render`, so it behaves the same whichever engine version it resolves to.
|
|
21
19
|
|
|
22
20
|
Run with no arguments for an interactive prompt (directory + template).
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { dirname, join, resolve, basename } from 'node:path';
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
4
5
|
import { createInterface } from 'node:readline/promises';
|
|
5
6
|
import { stdin, stdout, argv, cwd, exit } from 'node:process';
|
|
6
7
|
import { scaffold, isTemplate, TEMPLATES } from "./scaffold.js";
|
|
7
|
-
const
|
|
8
|
-
|
|
8
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const templatesRoot = join(here, '../templates');
|
|
10
|
+
/** Read this package's own version from its package.json (for `--version`). */
|
|
11
|
+
function selfVersion() {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(readFileSync(join(here, '../package.json'), 'utf8')).version ?? '0.0.0';
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return '0.0.0';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const HELP = `create-fundamental-engine — scaffold a Fundamental starter (signals-first).
|
|
20
|
+
|
|
21
|
+
Usage:
|
|
22
|
+
npm create @fundamental-engine [directory] [-- --template <name>]
|
|
23
|
+
create-fundamental-engine [directory] [--template <name>]
|
|
24
|
+
|
|
25
|
+
Arguments:
|
|
26
|
+
directory target directory (default: my-field-app)
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
-t, --template <name> one of: ${TEMPLATES.join(', ')} (default: vanilla)
|
|
30
|
+
-h, --help show this help and exit
|
|
31
|
+
-v, --version print the version and exit
|
|
32
|
+
|
|
33
|
+
With no TTY (CI / piped), directory and template must be passed as flags — there is no prompt.`;
|
|
34
|
+
export { HELP, selfVersion };
|
|
35
|
+
export function parseArgs(args) {
|
|
9
36
|
const out = {};
|
|
10
37
|
for (let i = 0; i < args.length; i++) {
|
|
11
38
|
const a = args[i];
|
|
12
|
-
if (a === '--
|
|
39
|
+
if (a === '--help' || a === '-h')
|
|
40
|
+
out.help = true;
|
|
41
|
+
else if (a === '--version' || a === '-v')
|
|
42
|
+
out.version = true;
|
|
43
|
+
else if (a === '--template' || a === '-t')
|
|
13
44
|
out.template = args[++i];
|
|
14
45
|
else if (a.startsWith('--template='))
|
|
15
46
|
out.template = a.slice('--template='.length);
|
|
@@ -20,6 +51,14 @@ function parseArgs(args) {
|
|
|
20
51
|
}
|
|
21
52
|
async function main() {
|
|
22
53
|
const args = parseArgs(argv.slice(2));
|
|
54
|
+
if (args.help) {
|
|
55
|
+
console.log(HELP);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (args.version) {
|
|
59
|
+
console.log(selfVersion());
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
23
62
|
let dir = args.dir;
|
|
24
63
|
let template = args.template;
|
|
25
64
|
const interactive = Boolean(stdin.isTTY && stdout.isTTY);
|
|
@@ -48,4 +87,8 @@ async function main() {
|
|
|
48
87
|
`Next:\n cd ${dir}\n npm install\n npm run dev\n\n` +
|
|
49
88
|
`The field draws nothing by default — it writes --field-* signals your CSS reads. See src/ for the wiring.\n`);
|
|
50
89
|
}
|
|
51
|
-
|
|
90
|
+
// Run only as the CLI entrypoint, so tests can `import` this module (for parseArgs / HELP) without
|
|
91
|
+
// executing the scaffold flow.
|
|
92
|
+
if (import.meta.url === `file://${argv[1]}` || argv[1] === fileURLToPath(import.meta.url)) {
|
|
93
|
+
void main();
|
|
94
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fundamental-engine/create",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Scaffold a Fundamental starter — `npm create @fundamental-engine` — vanilla, React, or web-component, contained and signals-first by default.",
|
|
6
6
|
"keywords": [
|