@weave-framework/nx 1.0.3 → 1.0.5
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/generators/application/generator.d.ts +2 -2
- package/dist/generators/application/generator.d.ts.map +1 -1
- package/dist/generators/application/generator.js +22 -5
- package/dist/generators/application/generator.js.map +1 -1
- package/dist/generators/component/files.js +1 -1
- package/dist/generators/component/files.js.map +1 -1
- package/dist/generators/component/generator.d.ts.map +1 -1
- package/dist/generators/component/generator.js +9 -1
- package/dist/generators/component/generator.js.map +1 -1
- package/dist/generators/library/generator.d.ts +2 -2
- package/dist/generators/library/generator.d.ts.map +1 -1
- package/dist/generators/library/generator.js +16 -3
- package/dist/generators/library/generator.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* register it with `build`/`serve`/`check` targets (wired to this plugin's executors). The
|
|
4
4
|
* app mirrors the `create-weave` layout (root component + config + HTML shell).
|
|
5
5
|
*/
|
|
6
|
-
import { type Tree } from '@nx/devkit';
|
|
6
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
7
7
|
export interface ApplicationGeneratorSchema {
|
|
8
8
|
name: string;
|
|
9
9
|
directory?: string;
|
|
@@ -11,6 +11,6 @@ export interface ApplicationGeneratorSchema {
|
|
|
11
11
|
}
|
|
12
12
|
/** Compute the workspace-relative project root for an app (default under `apps/`). */
|
|
13
13
|
export declare function appRoot(name: string, directory?: string): string;
|
|
14
|
-
export declare function applicationGenerator(tree: Tree, schema: ApplicationGeneratorSchema): Promise<
|
|
14
|
+
export declare function applicationGenerator(tree: Tree, schema: ApplicationGeneratorSchema): Promise<GeneratorCallback>;
|
|
15
15
|
export default applicationGenerator;
|
|
16
16
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/application/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/application/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,iBAAiB,EAItB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACxB;AAKD,sFAAsF;AACtF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,iBAAiB,CAAC,CAgF5B;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* register it with `build`/`serve`/`check` targets (wired to this plugin's executors). The
|
|
4
4
|
* app mirrors the `create-weave` layout (root component + config + HTML shell).
|
|
5
5
|
*/
|
|
6
|
-
import { addProjectConfiguration, formatFiles, joinPathFragments, names, } from '@nx/devkit';
|
|
6
|
+
import { addDependenciesToPackageJson, addProjectConfiguration, formatFiles, joinPathFragments, names, } from '@nx/devkit';
|
|
7
|
+
/** Version range for the generated app's `@weave-framework/*` deps — mirrors the create-weave template. */
|
|
8
|
+
const WEAVE_DEP_RANGE = '^1.0.0';
|
|
7
9
|
/** Compute the workspace-relative project root for an app (default under `apps/`). */
|
|
8
10
|
export function appRoot(name, directory) {
|
|
9
11
|
const fileName = names(name).fileName;
|
|
@@ -25,11 +27,9 @@ export async function applicationGenerator(tree, schema) {
|
|
|
25
27
|
tree.write(joinPathFragments(root, 'src/app/app.ts'), `import { signal, type Signal } from '@weave-framework/runtime';\n\n` +
|
|
26
28
|
`export function setup(): { count: Signal<number>; inc: () => void } {\n` +
|
|
27
29
|
` const count: Signal<number> = signal(0);\n` +
|
|
28
|
-
` const inc = (): void => count.set((n) => n + 1);\n` +
|
|
30
|
+
` const inc = (): void => { count.set((n) => n + 1); };\n` +
|
|
29
31
|
` return { count, inc };\n` +
|
|
30
32
|
`}\n`);
|
|
31
|
-
tree.write(joinPathFragments(root, 'src/app/app.html'), `<main class="app">\n <h1>Hello, Weave</h1>\n` +
|
|
32
|
-
` <button on:click={{ inc }}>clicked {{ count() }} times</button>\n</main>\n`);
|
|
33
33
|
tree.write(joinPathFragments(root, `src/app/app.${style}`), `.app {\n font-family: system-ui, sans-serif;\n text-align: center;\n padding: 2rem;\n}\n`);
|
|
34
34
|
const project = {
|
|
35
35
|
root,
|
|
@@ -47,8 +47,25 @@ export async function applicationGenerator(tree, schema) {
|
|
|
47
47
|
},
|
|
48
48
|
};
|
|
49
49
|
addProjectConfiguration(tree, schema.name, project);
|
|
50
|
+
// Add the runtime deps the scaffold imports (mirrors create-weave) + the CLI dev dep.
|
|
51
|
+
// The returned task installs them — and, crucially, is a *function*, which is the shape
|
|
52
|
+
// Nx expects a generator to return (returning a non-function broke `nx g` with
|
|
53
|
+
// "task is not a function").
|
|
54
|
+
const installTask = addDependenciesToPackageJson(tree, {
|
|
55
|
+
'@weave-framework/runtime': WEAVE_DEP_RANGE,
|
|
56
|
+
'@weave-framework/router': WEAVE_DEP_RANGE,
|
|
57
|
+
'@weave-framework/store': WEAVE_DEP_RANGE,
|
|
58
|
+
'@weave-framework/forms': WEAVE_DEP_RANGE,
|
|
59
|
+
'@weave-framework/i18n': WEAVE_DEP_RANGE,
|
|
60
|
+
'@weave-framework/data': WEAVE_DEP_RANGE,
|
|
61
|
+
}, { '@weave-framework/cli': WEAVE_DEP_RANGE });
|
|
50
62
|
await formatFiles(tree);
|
|
51
|
-
|
|
63
|
+
// Weave `.html` templates use `{{ }}` bindings that Prettier (run by formatFiles) mangles
|
|
64
|
+
// — e.g. `on:click={{ inc }}` becomes `on:click="{{" inc }}`. Write the template AFTER
|
|
65
|
+
// formatting so the canonical binding survives untouched.
|
|
66
|
+
tree.write(joinPathFragments(root, 'src/app/app.html'), `<main class="app">\n <h1>Hello, Weave</h1>\n` +
|
|
67
|
+
` <button on:click={{ inc }}>clicked {{ count() }} times</button>\n</main>\n`);
|
|
68
|
+
return installTask;
|
|
52
69
|
}
|
|
53
70
|
export default applicationGenerator;
|
|
54
71
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/application/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,uBAAuB,EACvB,WAAW,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/application/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,WAAW,EAEX,iBAAiB,EACjB,KAAK,GAGN,MAAM,YAAY,CAAC;AAQpB,2GAA2G;AAC3G,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEjC,sFAAsF;AACtF,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,SAAkB;IACtD,MAAM,QAAQ,GAAW,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC9C,OAAO,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAClG,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAU,EACV,MAAkC;IAElC,MAAM,KAAK,GAAmB,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC;IACpD,MAAM,IAAI,GAAW,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAE5D,IAAI,CAAC,KAAK,CACR,iBAAiB,C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WAAW,GAAsB,4BAA4B,CACjE,IAAI,EACJ;QACE,0BAA0B,EAAE,eAAe;QAC3C,yBAAyB,EAAE,eAAe;QAC1C,wBAAwB,EAAE,eAAe;QACzC,wBAAwB,EAAE,eAAe;QACzC,uBAAuB,EAAE,eAAe;QACxC,uBAAuB,EAAE,eAAe;KACzC,EACD,EAAE,sBAAsB,EAAE,eAAe,EAAE,CAC5C,CAAC;IAEF,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IAExB,0FAA0F;IAC1F,uFAAuF;IACvF,0DAA0D;IAC1D,IAAI,CAAC,KAAK,CACR,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,CAAC,EAC3C,+CAA+C;QAC7C,8EAA8E,CACjF,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -7,7 +7,7 @@ export function componentFiles(dir, fileName, style) {
|
|
|
7
7
|
content: `import { signal, type Signal } from '@weave-framework/runtime';\n\n` +
|
|
8
8
|
`export function setup(): { count: Signal<number>; inc: () => void } {\n` +
|
|
9
9
|
` const count: Signal<number> = signal(0);\n` +
|
|
10
|
-
` const inc = (): void => count.set((n) => n + 1);\n` +
|
|
10
|
+
` const inc = (): void => { count.set((n) => n + 1); };\n` +
|
|
11
11
|
` return { count, inc };\n` +
|
|
12
12
|
`}\n`,
|
|
13
13
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/generators/component/files.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAO7F,yFAAyF;AACzF,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,QAAgB,EAAE,KAA8B;IAC1F,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,KAAK,CAAC,IAAI,CAAC;QACT,IAAI,EAAE,GAAG,GAAG,IAAI,QAAQ,KAAK;QAC7B,OAAO,EACL,qEAAqE;YACrE,yEAAyE;YACzE,8CAA8C;YAC9C,
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/generators/component/files.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAO7F,yFAAyF;AACzF,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,QAAgB,EAAE,KAA8B;IAC1F,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,KAAK,CAAC,IAAI,CAAC;QACT,IAAI,EAAE,GAAG,GAAG,IAAI,QAAQ,KAAK;QAC7B,OAAO,EACL,qEAAqE;YACrE,yEAAyE;YACzE,8CAA8C;YAC9C,2DAA2D;YAC3D,4BAA4B;YAC5B,KAAK;KACR,CAAC,CAAC;IACH,KAAK,CAAC,IAAI,CAAC;QACT,IAAI,EAAE,GAAG,GAAG,IAAI,QAAQ,OAAO;QAC/B,OAAO,EACL,mBAAmB,QAAQ,MAAM;YACjC,qEAAqE;YACrE,cAAc;KACjB,CAAC,CAAC;IACH,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACrB,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,QAAQ,IAAI,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,QAAQ,4BAA4B,EAAE,CAAC,CAAC;IACzG,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/component/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAML,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;CACjC;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/component/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAML,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;CACjC;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBpG;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -10,10 +10,18 @@ export async function componentGenerator(tree, schema) {
|
|
|
10
10
|
const sourceRoot = project.sourceRoot ?? joinPathFragments(project.root, 'src');
|
|
11
11
|
const dir = joinPathFragments(sourceRoot, schema.directory ?? '', fileName);
|
|
12
12
|
const style = schema.style ?? 'css';
|
|
13
|
-
|
|
13
|
+
const files = componentFiles(dir, fileName, style);
|
|
14
|
+
// Write the Weave `.html` template after formatFiles so Prettier can't mangle its
|
|
15
|
+
// `{{ }}` bindings (e.g. `on:click={{ inc }}` → `on:click="{{" inc }}`).
|
|
16
|
+
const htmlFiles = files.filter((f) => f.path.endsWith('.html'));
|
|
17
|
+
for (const file of files) {
|
|
18
|
+
if (file.path.endsWith('.html'))
|
|
19
|
+
continue;
|
|
14
20
|
tree.write(file.path, file.content);
|
|
15
21
|
}
|
|
16
22
|
await formatFiles(tree);
|
|
23
|
+
for (const file of htmlFiles)
|
|
24
|
+
tree.write(file.path, file.content);
|
|
17
25
|
}
|
|
18
26
|
export default componentGenerator;
|
|
19
27
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/component/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,KAAK,EACL,wBAAwB,GAGzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAS5C,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAU,EAAE,MAAgC;IACnF,MAAM,OAAO,GAAyB,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACrF,MAAM,QAAQ,GAAW,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IACrD,MAAM,UAAU,GAAW,OAAO,CAAC,UAAU,IAAI,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxF,MAAM,GAAG,GAAW,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IACpF,MAAM,KAAK,GAA4B,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC;IAE7D,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/component/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,KAAK,EACL,wBAAwB,GAGzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAS5C,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAU,EAAE,MAAgC;IACnF,MAAM,OAAO,GAAyB,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACrF,MAAM,QAAQ,GAAW,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IACrD,MAAM,UAAU,GAAW,OAAO,CAAC,UAAU,IAAI,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxF,MAAM,GAAG,GAAW,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IACpF,MAAM,KAAK,GAA4B,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC;IAE7D,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IACnD,kFAAkF;IAClF,yEAAyE;IACzE,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAChE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,SAAS;QAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IACD,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,MAAM,IAAI,IAAI,SAAS;QAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AACpE,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* imported-from-source library (one component + a barrel `index.ts`); a fully-bundled
|
|
4
4
|
* publishable lib is a fast-follow (RFC 0004 §Open #1). Gets a `check` target only.
|
|
5
5
|
*/
|
|
6
|
-
import { type Tree } from '@nx/devkit';
|
|
6
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
7
7
|
export interface LibraryGeneratorSchema {
|
|
8
8
|
name: string;
|
|
9
9
|
directory?: string;
|
|
@@ -11,6 +11,6 @@ export interface LibraryGeneratorSchema {
|
|
|
11
11
|
}
|
|
12
12
|
/** Compute the workspace-relative project root for a library (default under `libs/`). */
|
|
13
13
|
export declare function libRoot(name: string, directory?: string): string;
|
|
14
|
-
export declare function libraryGenerator(tree: Tree, schema: LibraryGeneratorSchema): Promise<
|
|
14
|
+
export declare function libraryGenerator(tree: Tree, schema: LibraryGeneratorSchema): Promise<GeneratorCallback>;
|
|
15
15
|
export default libraryGenerator;
|
|
16
16
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/library/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/library/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,iBAAiB,EAItB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;CACjC;AAKD,yFAAyF;AACzF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,iBAAiB,CAAC,CAuC5B;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* imported-from-source library (one component + a barrel `index.ts`); a fully-bundled
|
|
4
4
|
* publishable lib is a fast-follow (RFC 0004 §Open #1). Gets a `check` target only.
|
|
5
5
|
*/
|
|
6
|
-
import { addProjectConfiguration, formatFiles, joinPathFragments, names, } from '@nx/devkit';
|
|
6
|
+
import { addDependenciesToPackageJson, addProjectConfiguration, formatFiles, joinPathFragments, names, } from '@nx/devkit';
|
|
7
7
|
import { componentFiles } from '../component/files.js';
|
|
8
|
+
/** Version range for the generated lib's `@weave-framework/*` deps — mirrors the create-weave template. */
|
|
9
|
+
const WEAVE_DEP_RANGE = '^1.0.0';
|
|
8
10
|
/** Compute the workspace-relative project root for a library (default under `libs/`). */
|
|
9
11
|
export function libRoot(name, directory) {
|
|
10
12
|
const fileName = names(name).fileName;
|
|
@@ -15,7 +17,13 @@ export async function libraryGenerator(tree, schema) {
|
|
|
15
17
|
const root = libRoot(schema.name, schema.directory);
|
|
16
18
|
const src = joinPathFragments(root, 'src');
|
|
17
19
|
const style = schema.style ?? 'css';
|
|
18
|
-
|
|
20
|
+
const files = componentFiles(joinPathFragments(src, 'lib', fileName), fileName, style);
|
|
21
|
+
// Write everything except the Weave `.html` template now; the template is written after
|
|
22
|
+
// formatFiles so Prettier can't mangle its `{{ }}` bindings.
|
|
23
|
+
const htmlFiles = files.filter((f) => f.path.endsWith('.html'));
|
|
24
|
+
for (const file of files) {
|
|
25
|
+
if (file.path.endsWith('.html'))
|
|
26
|
+
continue;
|
|
19
27
|
tree.write(file.path, file.content);
|
|
20
28
|
}
|
|
21
29
|
tree.write(joinPathFragments(src, 'index.ts'), `export { setup } from './lib/${fileName}/${fileName}.js';\n`);
|
|
@@ -28,8 +36,13 @@ export async function libraryGenerator(tree, schema) {
|
|
|
28
36
|
},
|
|
29
37
|
};
|
|
30
38
|
addProjectConfiguration(tree, schema.name, project);
|
|
39
|
+
// A Weave component imports the runtime; the `check` target needs the CLI. Adding them
|
|
40
|
+
// returns an install task — a function, the shape Nx requires a generator to return.
|
|
41
|
+
const installTask = addDependenciesToPackageJson(tree, { '@weave-framework/runtime': WEAVE_DEP_RANGE }, { '@weave-framework/cli': WEAVE_DEP_RANGE });
|
|
31
42
|
await formatFiles(tree);
|
|
32
|
-
|
|
43
|
+
for (const file of htmlFiles)
|
|
44
|
+
tree.write(file.path, file.content);
|
|
45
|
+
return installTask;
|
|
33
46
|
}
|
|
34
47
|
export default libraryGenerator;
|
|
35
48
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/library/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,uBAAuB,EACvB,WAAW,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/library/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,WAAW,EAEX,iBAAiB,EACjB,KAAK,GAGN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAQvD,2GAA2G;AAC3G,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEjC,yFAAyF;AACzF,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,SAAkB;IACtD,MAAM,QAAQ,GAAW,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC9C,OAAO,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAClG,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAU,EACV,MAA8B;IAE9B,MAAM,QAAQ,GAAW,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IACrD,MAAM,IAAI,GAAW,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAW,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACnD,MAAM,KAAK,GAA4B,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC;IAE7D,MAAM,KAAK,GAAG,cAAc,CAAC,iBAA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,eAAe,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weave-framework/nx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Nx plugin for Weave — inferred build/serve/check targets (crystal createNodesV2), executors, and generators, so a Weave app is a first-class project in an Nx monorepo.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|