@razorwind/nx 0.0.5 → 0.0.7

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/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  # Changelog for Razorwind - Nx
4
4
 
5
+ ## [0.0.7](https://github.com/storm-software/razorwind/releases/tag/nx%400.0.7) (07/31/2026)
6
+
7
+ ### Miscellaneous
8
+
9
+ - **nx:** Improve Nx plugin and Sync Generator to use user provided configuration ([71ff227](https://github.com/storm-software/razorwind/commit/71ff227))
10
+
11
+ ### Updated Dependencies
12
+
13
+ - Updated **core** to **v0.0.13**
14
+
15
+ ## [0.0.6](https://github.com/storm-software/razorwind/releases/tag/nx%400.0.6) (07/30/2026)
16
+
17
+ ### Features
18
+
19
+ - **nx:** Added sync generator to Nx plugin ([b72ebe4](https://github.com/storm-software/razorwind/commit/b72ebe4))
20
+
21
+ ### Updated Dependencies
22
+
23
+ - Updated **core** to **v0.0.12**
24
+
5
25
  ## [0.0.5](https://github.com/storm-software/razorwind/releases/tag/nx%400.0.5) (07/30/2026)
6
26
 
7
27
  ### Features
@@ -19,15 +19,19 @@ interface GenerateExecutorSchema {
19
19
  */
20
20
  mode: string;
21
21
  /**
22
- * The path to a directory containing component directories or files
22
+ * The path to a directory containing component directories or files, or an array of paths
23
23
  *
24
+ *
25
+ * @oneOf [object Object],[object Object]
24
26
  */
25
- componentsPath?: string;
27
+ componentsPath?: string | string[];
26
28
  /**
27
- * The path to the tokens.json file
29
+ * The path to the tokens.json file, or an array of paths
30
+ *
28
31
  *
32
+ * @oneOf [object Object],[object Object]
29
33
  */
30
- tokensPath?: string;
34
+ tokensPath?: string | string[];
31
35
  }
32
36
  //#endregion
33
37
  //#region src/executors/generate/executor.d.ts
@@ -19,15 +19,19 @@ interface GenerateExecutorSchema {
19
19
  */
20
20
  mode: string;
21
21
  /**
22
- * The path to a directory containing component directories or files
22
+ * The path to a directory containing component directories or files, or an array of paths
23
23
  *
24
+ *
25
+ * @oneOf [object Object],[object Object]
24
26
  */
25
- componentsPath?: string;
27
+ componentsPath?: string | string[];
26
28
  /**
27
- * The path to the tokens.json file
29
+ * The path to the tokens.json file, or an array of paths
30
+ *
28
31
  *
32
+ * @oneOf [object Object],[object Object]
29
33
  */
30
- tokensPath?: string;
34
+ tokensPath?: string | string[];
31
35
  }
32
36
  //#endregion
33
37
  //#region src/executors/generate/executor.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","names":[],"sources":["../../../src/executors/generate/schema.d.ts","../../../src/executors/generate/executor.ts"],"mappings":";;;;;UAIiB;;;;;;EAMhB;;;;;;;;EASA;;;;;EAMA;;;;;EAMA;;;;iBCPc,WACb,SAAS,wBACT,SAAS,kBACR,QAAQ"}
1
+ {"version":3,"file":"executor.d.ts","names":[],"sources":["../../../src/executors/generate/schema.d.ts","../../../src/executors/generate/executor.ts"],"mappings":";;;;;UAIiB;;;;;;EAMhB;;;;;;;;EASA;;;;;;;EAQA;;;;;;;EAQA;;;;iBCXc,WACb,SAAS,wBACT,SAAS,kBACR,QAAQ"}
@@ -20,15 +20,19 @@ export interface GenerateExecutorSchema {
20
20
  mode: string,
21
21
 
22
22
  /**
23
- * The path to a directory containing component directories or files
23
+ * The path to a directory containing component directories or files, or an array of paths
24
24
  *
25
+ *
26
+ * @oneOf [object Object],[object Object]
25
27
  */
26
- componentsPath?: string,
28
+ componentsPath?: string | string[],
27
29
 
28
30
  /**
29
- * The path to the tokens.json file
31
+ * The path to the tokens.json file, or an array of paths
32
+ *
30
33
  *
34
+ * @oneOf [object Object],[object Object]
31
35
  */
32
- tokensPath?: string,
36
+ tokensPath?: string | string[],
33
37
  }
34
38
 
@@ -22,12 +22,34 @@
22
22
  ]
23
23
  },
24
24
  "componentsPath": {
25
- "type": "string",
26
- "description": "The path to a directory containing component directories or files"
25
+ "oneOf": [
26
+ {
27
+ "type": "string"
28
+ },
29
+ {
30
+ "type": "array",
31
+ "items": {
32
+ "type": "string"
33
+ }
34
+ }
35
+ ],
36
+ "tsType": "string | string[]",
37
+ "description": "The path to a directory containing component directories or files, or an array of paths"
27
38
  },
28
39
  "tokensPath": {
29
- "type": "string",
30
- "description": "The path to the tokens.json file"
40
+ "oneOf": [
41
+ {
42
+ "type": "string"
43
+ },
44
+ {
45
+ "type": "array",
46
+ "items": {
47
+ "type": "string"
48
+ }
49
+ }
50
+ ],
51
+ "tsType": "string | string[]",
52
+ "description": "The path to the tokens.json file, or an array of paths"
31
53
  }
32
54
  },
33
55
  "additionalProperties": false,
@@ -0,0 +1,7 @@
1
+ import { Tree } from "@nx/devkit";
2
+ import { SyncGeneratorResult } from "nx/src/utils/sync-generators";
3
+ //#region src/generators/sync/generator.d.ts
4
+ declare function syncGenerator(tree: Tree): Promise<SyncGeneratorResult>;
5
+ //#endregion
6
+ export { syncGenerator as default, syncGenerator };
7
+ //# sourceMappingURL=generator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.mts","names":[],"sources":["../../../src/generators/sync/generator.ts"],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { Tree } from "@nx/devkit";
2
+ import { SyncGeneratorResult } from "nx/src/utils/sync-generators";
3
+ //#region src/generators/sync/generator.d.ts
4
+ declare function syncGenerator(tree: Tree): Promise<SyncGeneratorResult>;
5
+ //#endregion
6
+ export { syncGenerator as default, syncGenerator };
7
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","names":[],"sources":["../../../src/generators/sync/generator.ts"],"mappings":";;;iBAuHsB,cAAc,MAAM,OAAO,QAAQ"}
@@ -0,0 +1,137 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+
28
+ //#endregion
29
+ let _power_plant_core = require("@power-plant/core");
30
+ let _razorwind_core = require("@razorwind/core");
31
+ let _nx_devkit = require("@nx/devkit");
32
+ let _power_plant_noop_output = require("@power-plant/noop-output");
33
+ _power_plant_noop_output = __toESM(_power_plant_noop_output);
34
+ let node_path = require("node:path");
35
+ let c12 = require("c12");
36
+
37
+ //#region src/helpers/constants.ts
38
+ const GENERATOR_NAME = "@razorwind/nx:sync";
39
+ const GENERATE_EXECUTOR = "@razorwind/nx:generate";
40
+ const CONFIG_NAME = "razorwind";
41
+ /**
42
+ * Config file base paths resolved by c12 in priority order.
43
+ *
44
+ * @see https://github.com/unjs/c12
45
+ */
46
+ const CONFIG_FILE_BASES = [
47
+ `${CONFIG_NAME}.config`,
48
+ `.config/${CONFIG_NAME}`,
49
+ `.config/${CONFIG_NAME}.config`
50
+ ];
51
+ /**
52
+ * All Razorwind config file names supported by c12.
53
+ *
54
+ * @see https://github.com/unjs/c12/blob/main/src/loader.ts
55
+ */
56
+ const CONFIG_FILE_NAMES = c12.SUPPORTED_EXTENSIONS.flatMap((extension) => CONFIG_FILE_BASES.map((base) => `${base}${extension}`));
57
+
58
+ //#endregion
59
+ //#region src/generators/sync/generator.ts
60
+ const DEFAULT_OUT_OF_SYNC_MESSAGE = "Razorwind generated files are out of sync. Run `nx sync` to regenerate.";
61
+ function resolveConfigFileToken(configFile, projectRoot) {
62
+ return configFile.replaceAll("{projectRoot}", projectRoot);
63
+ }
64
+ function findDefaultConfigFile(tree, projectRoot) {
65
+ return CONFIG_FILE_NAMES.map((name) => (0, _nx_devkit.joinPathFragments)(projectRoot, name)).find((path) => tree.exists(path));
66
+ }
67
+ function getDocumentContent(document) {
68
+ return (document.chunks ?? []).map((chunk) => chunk.content ?? "").join("");
69
+ }
70
+ function toWorkspaceRelativePath(tree, filePath) {
71
+ if ((0, node_path.isAbsolute)(filePath)) return (0, node_path.relative)(tree.root, filePath).split(/[/\\]/).join("/");
72
+ return filePath;
73
+ }
74
+ function writeDocumentIfChanged(tree, document) {
75
+ const path = toWorkspaceRelativePath(tree, document.path);
76
+ const content = getDocumentContent(document);
77
+ if (tree.exists(path) && tree.read(path, "utf-8") === content) return;
78
+ tree.write(path, content);
79
+ return path;
80
+ }
81
+ async function generateForProject(tree, options) {
82
+ const documents = await (0, _power_plant_core.execute)(_razorwind_core.generator, {
83
+ configFile: options.configFile,
84
+ mode: options.mode,
85
+ componentsPath: options.componentsPath,
86
+ tokensPath: options.tokensPath,
87
+ cwd: tree.root,
88
+ output: _power_plant_noop_output.default
89
+ });
90
+ const changed = [];
91
+ for (const document of Object.values(documents ?? {})) {
92
+ const path = writeDocumentIfChanged(tree, document);
93
+ if (path) changed.push(path);
94
+ }
95
+ return changed;
96
+ }
97
+ async function syncGenerator(tree) {
98
+ const generatorOptions = (0, _nx_devkit.readNxJson)(tree)?.sync?.generatorOptions?.["@razorwind/nx:sync"] ?? {};
99
+ const defaultMode = generatorOptions.mode ?? "production";
100
+ const targetName = generatorOptions.targetName ?? "generate";
101
+ const outOfSyncMessage = generatorOptions.outOfSyncMessage ?? DEFAULT_OUT_OF_SYNC_MESSAGE;
102
+ const projectGraph = await (0, _nx_devkit.createProjectGraphAsync)();
103
+ const outOfSyncDetails = [];
104
+ const processedConfigFiles = /* @__PURE__ */ new Set();
105
+ for (const project of Object.values(projectGraph.nodes)) {
106
+ const projectRoot = project.data.root;
107
+ const generateTarget = project.data.targets?.[targetName] ?? Object.values(project.data.targets ?? {}).find((target) => target.executor === "@razorwind/nx:generate");
108
+ let configFile;
109
+ let mode = defaultMode;
110
+ let componentsPath;
111
+ let tokensPath;
112
+ if (generateTarget?.executor === "@razorwind/nx:generate") {
113
+ mode = generateTarget.configurations?.[generateTarget.defaultConfiguration ?? "production"]?.mode ?? generateTarget.options?.mode ?? defaultMode;
114
+ componentsPath = generateTarget.options?.componentsPath;
115
+ tokensPath = generateTarget.options?.tokensPath;
116
+ const configured = generateTarget.options?.configFile ? resolveConfigFileToken(generateTarget.options.configFile, projectRoot) : void 0;
117
+ configFile = configured && tree.exists(configured) ? configured : findDefaultConfigFile(tree, projectRoot);
118
+ } else configFile = findDefaultConfigFile(tree, projectRoot);
119
+ if (!configFile || processedConfigFiles.has(configFile)) continue;
120
+ processedConfigFiles.add(configFile);
121
+ const changed = await generateForProject(tree, {
122
+ configFile,
123
+ mode,
124
+ componentsPath,
125
+ tokensPath
126
+ });
127
+ outOfSyncDetails.push(...changed);
128
+ }
129
+ return {
130
+ outOfSyncMessage,
131
+ outOfSyncDetails
132
+ };
133
+ }
134
+
135
+ //#endregion
136
+ exports.default = syncGenerator;
137
+ exports.syncGenerator = syncGenerator;
@@ -0,0 +1,108 @@
1
+ import { execute } from "@power-plant/core";
2
+ import { generator } from "@razorwind/core";
3
+ import { createProjectGraphAsync, joinPathFragments, readNxJson } from "@nx/devkit";
4
+ import noop from "@power-plant/noop-output";
5
+ import { isAbsolute, relative } from "node:path";
6
+ import { SUPPORTED_EXTENSIONS } from "c12";
7
+
8
+ //#region src/helpers/constants.ts
9
+ const GENERATOR_NAME = "@razorwind/nx:sync";
10
+ const GENERATE_EXECUTOR = "@razorwind/nx:generate";
11
+ const CONFIG_NAME = "razorwind";
12
+ /**
13
+ * Config file base paths resolved by c12 in priority order.
14
+ *
15
+ * @see https://github.com/unjs/c12
16
+ */
17
+ const CONFIG_FILE_BASES = [
18
+ `${CONFIG_NAME}.config`,
19
+ `.config/${CONFIG_NAME}`,
20
+ `.config/${CONFIG_NAME}.config`
21
+ ];
22
+ /**
23
+ * All Razorwind config file names supported by c12.
24
+ *
25
+ * @see https://github.com/unjs/c12/blob/main/src/loader.ts
26
+ */
27
+ const CONFIG_FILE_NAMES = SUPPORTED_EXTENSIONS.flatMap((extension) => CONFIG_FILE_BASES.map((base) => `${base}${extension}`));
28
+
29
+ //#endregion
30
+ //#region src/generators/sync/generator.ts
31
+ const DEFAULT_OUT_OF_SYNC_MESSAGE = "Razorwind generated files are out of sync. Run `nx sync` to regenerate.";
32
+ function resolveConfigFileToken(configFile, projectRoot) {
33
+ return configFile.replaceAll("{projectRoot}", projectRoot);
34
+ }
35
+ function findDefaultConfigFile(tree, projectRoot) {
36
+ return CONFIG_FILE_NAMES.map((name) => joinPathFragments(projectRoot, name)).find((path) => tree.exists(path));
37
+ }
38
+ function getDocumentContent(document) {
39
+ return (document.chunks ?? []).map((chunk) => chunk.content ?? "").join("");
40
+ }
41
+ function toWorkspaceRelativePath(tree, filePath) {
42
+ if (isAbsolute(filePath)) return relative(tree.root, filePath).split(/[/\\]/).join("/");
43
+ return filePath;
44
+ }
45
+ function writeDocumentIfChanged(tree, document) {
46
+ const path = toWorkspaceRelativePath(tree, document.path);
47
+ const content = getDocumentContent(document);
48
+ if (tree.exists(path) && tree.read(path, "utf-8") === content) return;
49
+ tree.write(path, content);
50
+ return path;
51
+ }
52
+ async function generateForProject(tree, options) {
53
+ const documents = await execute(generator, {
54
+ configFile: options.configFile,
55
+ mode: options.mode,
56
+ componentsPath: options.componentsPath,
57
+ tokensPath: options.tokensPath,
58
+ cwd: tree.root,
59
+ output: noop
60
+ });
61
+ const changed = [];
62
+ for (const document of Object.values(documents ?? {})) {
63
+ const path = writeDocumentIfChanged(tree, document);
64
+ if (path) changed.push(path);
65
+ }
66
+ return changed;
67
+ }
68
+ async function syncGenerator(tree) {
69
+ const generatorOptions = readNxJson(tree)?.sync?.generatorOptions?.["@razorwind/nx:sync"] ?? {};
70
+ const defaultMode = generatorOptions.mode ?? "production";
71
+ const targetName = generatorOptions.targetName ?? "generate";
72
+ const outOfSyncMessage = generatorOptions.outOfSyncMessage ?? DEFAULT_OUT_OF_SYNC_MESSAGE;
73
+ const projectGraph = await createProjectGraphAsync();
74
+ const outOfSyncDetails = [];
75
+ const processedConfigFiles = /* @__PURE__ */ new Set();
76
+ for (const project of Object.values(projectGraph.nodes)) {
77
+ const projectRoot = project.data.root;
78
+ const generateTarget = project.data.targets?.[targetName] ?? Object.values(project.data.targets ?? {}).find((target) => target.executor === "@razorwind/nx:generate");
79
+ let configFile;
80
+ let mode = defaultMode;
81
+ let componentsPath;
82
+ let tokensPath;
83
+ if (generateTarget?.executor === "@razorwind/nx:generate") {
84
+ mode = generateTarget.configurations?.[generateTarget.defaultConfiguration ?? "production"]?.mode ?? generateTarget.options?.mode ?? defaultMode;
85
+ componentsPath = generateTarget.options?.componentsPath;
86
+ tokensPath = generateTarget.options?.tokensPath;
87
+ const configured = generateTarget.options?.configFile ? resolveConfigFileToken(generateTarget.options.configFile, projectRoot) : void 0;
88
+ configFile = configured && tree.exists(configured) ? configured : findDefaultConfigFile(tree, projectRoot);
89
+ } else configFile = findDefaultConfigFile(tree, projectRoot);
90
+ if (!configFile || processedConfigFiles.has(configFile)) continue;
91
+ processedConfigFiles.add(configFile);
92
+ const changed = await generateForProject(tree, {
93
+ configFile,
94
+ mode,
95
+ componentsPath,
96
+ tokensPath
97
+ });
98
+ outOfSyncDetails.push(...changed);
99
+ }
100
+ return {
101
+ outOfSyncMessage,
102
+ outOfSyncDetails
103
+ };
104
+ }
105
+
106
+ //#endregion
107
+ export { syncGenerator as default, syncGenerator };
108
+ //# sourceMappingURL=generator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.mjs","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+
2
+ // Generated by powerlines
3
+ // Do not edit this file directly
4
+
5
+ export interface SyncGeneratorSchema {
6
+ /**
7
+ * Mode
8
+ *
9
+ * The mode to use when running Razorwind generate
10
+ *
11
+ * @default "production"
12
+ *
13
+ * @enum development,production
14
+ */
15
+ mode?: string,
16
+
17
+ /**
18
+ * Target Name
19
+ *
20
+ * The name of the target to use when running Razorwind generate
21
+ *
22
+ *
23
+ * @$default generate
24
+ */
25
+ targetName?: string,
26
+
27
+ /**
28
+ * Out of Sync Message
29
+ *
30
+ * The message to display when Razorwind generated files are out of sync
31
+ *
32
+ * @default "Razorwind generated files are out of sync. Run `nx sync` to regenerate."
33
+ */
34
+ outOfSyncMessage?: string,
35
+ }
36
+
@@ -0,0 +1,38 @@
1
+ {
2
+ "id": "#",
3
+ "title": "Sync Generator",
4
+ "description": "A type definition for the Razorwind - Sync generator's options",
5
+ "required": [],
6
+ "properties": {
7
+ "mode": {
8
+ "title": "Mode",
9
+ "type": "string",
10
+ "description": "The mode to use when running Razorwind generate",
11
+ "enum": [
12
+ "development",
13
+ "production"
14
+ ],
15
+ "id": "#mode",
16
+ "default": "production"
17
+ },
18
+ "targetName": {
19
+ "title": "Target Name",
20
+ "type": "string",
21
+ "description": "The name of the target to use when running Razorwind generate",
22
+ "$default": "generate",
23
+ "id": "#targetName"
24
+ },
25
+ "outOfSyncMessage": {
26
+ "title": "Out of Sync Message",
27
+ "type": "string",
28
+ "description": "The message to display when Razorwind generated files are out of sync",
29
+ "id": "#outOfSyncMessage",
30
+ "default": "Razorwind generated files are out of sync. Run `nx sync` to regenerate."
31
+ }
32
+ },
33
+ "type": "object",
34
+ "default": {
35
+ "mode": "production",
36
+ "outOfSyncMessage": "Razorwind generated files are out of sync. Run `nx sync` to regenerate."
37
+ }
38
+ }
@@ -1,6 +1,25 @@
1
1
  import { CreateNodes } from "@nx/devkit";
2
2
  //#region src/plugin/index.d.ts
3
3
  interface NxPluginOptions {
4
+ /**
5
+ * The name of the target to use.
6
+ *
7
+ * @defaultValue `"generate"`
8
+ */
9
+ targetName?: string;
10
+ /**
11
+ * The path to a directory containing component directories or files, or an array of paths.
12
+ */
13
+ componentsPath?: string | string[];
14
+ /**
15
+ * The path to the tokens.json file, or an array of paths.
16
+ */
17
+ tokensPath?: string | string[];
18
+ /**
19
+ * Whether to output verbose logs.
20
+ *
21
+ * @defaultValue `false`
22
+ */
4
23
  verboseOutput?: boolean;
5
24
  }
6
25
  declare const createNodesV2: CreateNodes<NxPluginOptions>;
@@ -1,6 +1,25 @@
1
1
  import { CreateNodes } from "@nx/devkit";
2
2
  //#region src/plugin/index.d.ts
3
3
  interface NxPluginOptions {
4
+ /**
5
+ * The name of the target to use.
6
+ *
7
+ * @defaultValue `"generate"`
8
+ */
9
+ targetName?: string;
10
+ /**
11
+ * The path to a directory containing component directories or files, or an array of paths.
12
+ */
13
+ componentsPath?: string | string[];
14
+ /**
15
+ * The path to the tokens.json file, or an array of paths.
16
+ */
17
+ tokensPath?: string | string[];
18
+ /**
19
+ * Whether to output verbose logs.
20
+ *
21
+ * @defaultValue `false`
22
+ */
4
23
  verboseOutput?: boolean;
5
24
  }
6
25
  declare const createNodesV2: CreateNodes<NxPluginOptions>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugin/index.ts"],"mappings":";;UA6CiB;EACf;;cAGW,eAAe,YAAY"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugin/index.ts"],"mappings":";;UA8CiB;;;;;;EAMf;;;;EAKA;;;;EAKA;;;;;;EAOA;;cAGW,eAAe,YAAY"}
@@ -20,7 +20,7 @@ var __copyProps = (to, from, except, desc) => {
20
20
  }
21
21
  return to;
22
22
  };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
24
24
  value: mod,
25
25
  enumerable: true
26
26
  }) : target, mod));
@@ -40,7 +40,29 @@ let node_fs_promises = require("node:fs/promises");
40
40
  let nx_src_config_nx_json_js = require("nx/src/config/nx-json.js");
41
41
  let nx_src_utils_package_json_js = require("nx/src/utils/package-json.js");
42
42
  let nx_src_utils_package_manager_js = require("nx/src/utils/package-manager.js");
43
+ let c12 = require("c12");
43
44
 
45
+ //#region src/helpers/constants.ts
46
+ const GENERATE_EXECUTOR = "@razorwind/nx:generate";
47
+ const CONFIG_NAME = "razorwind";
48
+ /**
49
+ * Config file base paths resolved by c12 in priority order.
50
+ *
51
+ * @see https://github.com/unjs/c12
52
+ */
53
+ const CONFIG_FILE_BASES = [
54
+ `${CONFIG_NAME}.config`,
55
+ `.config/${CONFIG_NAME}`,
56
+ `.config/${CONFIG_NAME}.config`
57
+ ];
58
+ /**
59
+ * All Razorwind config file names supported by c12.
60
+ *
61
+ * @see https://github.com/unjs/c12/blob/main/src/loader.ts
62
+ */
63
+ const CONFIG_FILE_NAMES = c12.SUPPORTED_EXTENSIONS.flatMap((extension) => CONFIG_FILE_BASES.map((base) => `${base}${extension}`));
64
+
65
+ //#endregion
44
66
  //#region src/plugin/index.ts
45
67
  const createNodesV2 = ["**/razorwind.config.ts", async (configFiles, options, contextV2) => {
46
68
  if (options?.verboseOutput) console.debug(`[razorwind] - ${(/* @__PURE__ */ new Date()).toISOString()} - Initializing the Razorwind plugin for the following inputs: ${configFiles.join(", ")}`);
@@ -77,22 +99,31 @@ const createNodesV2 = ["**/razorwind.config.ts", async (configFiles, options, co
77
99
  }
78
100
  const targets = (0, nx_src_utils_package_json_js.readTargetsFromPackageJson)(packageJson, nxJson, projectRoot, context.workspaceRoot, packageManagerCommand);
79
101
  if (options?.verboseOutput) console.debug(`[razorwind] - ${(/* @__PURE__ */ new Date()).toISOString()} - Preparing Nx targets for project in root directory ${projectRoot}.`);
80
- targets.generate = {
81
- executor: "@razorwind/nx:generate",
82
- dependsOn: ["^generate"],
102
+ const targetName = options?.targetName || Object.keys(targets ?? {}).find((name) => targets[name]?.executor === "@razorwind/nx:generate") || "generate";
103
+ targets[targetName] = (0, defu.default)(targets[targetName], {
104
+ inputs: [
105
+ configFile,
106
+ ...((0, _stryke_type_checks_is_set_string.isSetString)(options?.componentsPath) ? [options.componentsPath] : options?.componentsPath) ?? [],
107
+ ...((0, _stryke_type_checks_is_set_string.isSetString)(options?.tokensPath) ? [options.tokensPath] : options?.tokensPath) ?? []
108
+ ],
109
+ executor: GENERATE_EXECUTOR,
110
+ dependsOn: [`^${targetName}`],
83
111
  defaultConfiguration: "production",
84
- options: { configFile },
112
+ options: {
113
+ configFile,
114
+ componentsPath: options?.componentsPath,
115
+ tokensPath: options?.tokensPath
116
+ },
85
117
  configurations: {
86
118
  production: { mode: "production" },
87
119
  development: { mode: "development" }
88
120
  }
89
- };
121
+ });
90
122
  (0, _storm_software_workspace_tools_utils_project_tags.setDefaultProjectTags)(projectConfig, "razorwind");
91
123
  if (options?.verboseOutput) console.debug(`[razorwind] - ${(/* @__PURE__ */ new Date()).toISOString()} - Completed preparing Nx configuration for project in root directory ${projectRoot}.`);
92
124
  return { projects: { [root]: (0, defu.default)(projectConfig, {
93
125
  projectType: projectConfig.projectType || "library",
94
126
  root,
95
- sourceRoot: (0, _stryke_path_join_paths.joinPaths)(root, "src"),
96
127
  targets
97
128
  }) } };
98
129
  } catch (error) {
@@ -11,7 +11,29 @@ import { readFile } from "node:fs/promises";
11
11
  import { readNxJson } from "nx/src/config/nx-json.js";
12
12
  import { readTargetsFromPackageJson } from "nx/src/utils/package-json.js";
13
13
  import { detectPackageManager, getPackageManagerCommand } from "nx/src/utils/package-manager.js";
14
+ import { SUPPORTED_EXTENSIONS } from "c12";
14
15
 
16
+ //#region src/helpers/constants.ts
17
+ const GENERATE_EXECUTOR = "@razorwind/nx:generate";
18
+ const CONFIG_NAME = "razorwind";
19
+ /**
20
+ * Config file base paths resolved by c12 in priority order.
21
+ *
22
+ * @see https://github.com/unjs/c12
23
+ */
24
+ const CONFIG_FILE_BASES = [
25
+ `${CONFIG_NAME}.config`,
26
+ `.config/${CONFIG_NAME}`,
27
+ `.config/${CONFIG_NAME}.config`
28
+ ];
29
+ /**
30
+ * All Razorwind config file names supported by c12.
31
+ *
32
+ * @see https://github.com/unjs/c12/blob/main/src/loader.ts
33
+ */
34
+ const CONFIG_FILE_NAMES = SUPPORTED_EXTENSIONS.flatMap((extension) => CONFIG_FILE_BASES.map((base) => `${base}${extension}`));
35
+
36
+ //#endregion
15
37
  //#region src/plugin/index.ts
16
38
  const createNodesV2 = ["**/razorwind.config.ts", async (configFiles, options, contextV2) => {
17
39
  if (options?.verboseOutput) console.debug(`[razorwind] - ${(/* @__PURE__ */ new Date()).toISOString()} - Initializing the Razorwind plugin for the following inputs: ${configFiles.join(", ")}`);
@@ -48,22 +70,31 @@ const createNodesV2 = ["**/razorwind.config.ts", async (configFiles, options, co
48
70
  }
49
71
  const targets = readTargetsFromPackageJson(packageJson, nxJson, projectRoot, context.workspaceRoot, packageManagerCommand);
50
72
  if (options?.verboseOutput) console.debug(`[razorwind] - ${(/* @__PURE__ */ new Date()).toISOString()} - Preparing Nx targets for project in root directory ${projectRoot}.`);
51
- targets.generate = {
52
- executor: "@razorwind/nx:generate",
53
- dependsOn: ["^generate"],
73
+ const targetName = options?.targetName || Object.keys(targets ?? {}).find((name) => targets[name]?.executor === "@razorwind/nx:generate") || "generate";
74
+ targets[targetName] = defu(targets[targetName], {
75
+ inputs: [
76
+ configFile,
77
+ ...(isSetString(options?.componentsPath) ? [options.componentsPath] : options?.componentsPath) ?? [],
78
+ ...(isSetString(options?.tokensPath) ? [options.tokensPath] : options?.tokensPath) ?? []
79
+ ],
80
+ executor: GENERATE_EXECUTOR,
81
+ dependsOn: [`^${targetName}`],
54
82
  defaultConfiguration: "production",
55
- options: { configFile },
83
+ options: {
84
+ configFile,
85
+ componentsPath: options?.componentsPath,
86
+ tokensPath: options?.tokensPath
87
+ },
56
88
  configurations: {
57
89
  production: { mode: "production" },
58
90
  development: { mode: "development" }
59
91
  }
60
- };
92
+ });
61
93
  setDefaultProjectTags(projectConfig, "razorwind");
62
94
  if (options?.verboseOutput) console.debug(`[razorwind] - ${(/* @__PURE__ */ new Date()).toISOString()} - Completed preparing Nx configuration for project in root directory ${projectRoot}.`);
63
95
  return { projects: { [root]: defu(projectConfig, {
64
96
  projectType: projectConfig.projectType || "library",
65
97
  root,
66
- sourceRoot: joinPaths(root, "src"),
67
98
  targets
68
99
  }) } };
69
100
  } catch (error) {
@@ -21,16 +21,16 @@ The mode to use
21
21
 
22
22
 
23
23
  ## `componentsPath`
24
- - **Type**: `string`
24
+ - **Type**: `string | string[]`
25
25
 
26
26
 
27
- The path to a directory containing component directories or files
27
+ The path to a directory containing component directories or files, or an array of paths
28
28
 
29
29
 
30
30
  ## `tokensPath`
31
- - **Type**: `string`
31
+ - **Type**: `string | string[]`
32
32
 
33
33
 
34
- The path to the tokens.json file
34
+ The path to the tokens.json file, or an array of paths
35
35
 
36
36
 
@@ -0,0 +1,35 @@
1
+
2
+ <!-- Generated by powerlines -->
3
+ <!-- Do not edit this file directly -->
4
+
5
+ # Sync Generator
6
+
7
+ ## `mode`
8
+ - **Type**: `string`
9
+ - **Default**: `"production"`
10
+
11
+ > Mode
12
+
13
+
14
+ The mode to use when running Razorwind generate
15
+
16
+
17
+ ## `targetName`
18
+ - **Type**: `string`
19
+
20
+ > Target Name
21
+
22
+
23
+ The name of the target to use when running Razorwind generate
24
+
25
+
26
+ ## `outOfSyncMessage`
27
+ - **Type**: `string`
28
+ - **Default**: `"Razorwind generated files are out of sync. Run `nx sync` to regenerate."`
29
+
30
+ > Out of Sync Message
31
+
32
+
33
+ The message to display when Razorwind generated files are out of sync
34
+
35
+
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "generators": {
4
+ "sync": {
5
+ "factory": "./dist/generators/sync/generator",
6
+ "schema": "./dist/generators/sync/schema.json",
7
+ "description": "Synchronize Razorwind generated files across the workspace",
8
+ "alias": ["generate-sync"],
9
+ "hidden": true
10
+ }
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razorwind/nx",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "A Nx plugin to support Razorwind development in Nx monorepos.",
5
5
  "repository": {
6
6
  "type": "github",
@@ -12,7 +12,9 @@
12
12
  "./package.json": "./package.json",
13
13
  "./docs/*": "./docs/*",
14
14
  "./executors.json": "./executors.json",
15
+ "./generators.json": "./generators.json",
15
16
  "./executors/*/schema.json": "./dist/executors/*/schema.json",
17
+ "./generators/*/schema.json": "./dist/generators/*/schema.json",
16
18
  ".": {
17
19
  "import": {
18
20
  "types": "./dist/index.d.mts",
@@ -57,6 +59,20 @@
57
59
  "default": "./dist/executors/*/untyped.js"
58
60
  }
59
61
  },
62
+ "./generators/*/untyped": {
63
+ "import": {
64
+ "types": "./dist/generators/*/untyped.d.mts",
65
+ "default": "./dist/generators/*/untyped.mjs"
66
+ },
67
+ "require": {
68
+ "types": "./dist/generators/*/untyped.d.ts",
69
+ "default": "./dist/generators/*/untyped.js"
70
+ },
71
+ "default": {
72
+ "types": "./dist/generators/*/untyped.d.ts",
73
+ "default": "./dist/generators/*/untyped.js"
74
+ }
75
+ },
60
76
  "./executors/*/executor": {
61
77
  "import": {
62
78
  "types": "./dist/executors/*/executor.d.mts",
@@ -71,16 +87,33 @@
71
87
  "default": "./dist/executors/*/executor.js"
72
88
  }
73
89
  },
90
+ "./generators/*/generator": {
91
+ "import": {
92
+ "types": "./dist/generators/*/generator.d.mts",
93
+ "default": "./dist/generators/*/generator.mjs"
94
+ },
95
+ "require": {
96
+ "types": "./dist/generators/*/generator.d.ts",
97
+ "default": "./dist/generators/*/generator.js"
98
+ },
99
+ "default": {
100
+ "types": "./dist/generators/*/generator.d.ts",
101
+ "default": "./dist/generators/*/generator.js"
102
+ }
103
+ },
74
104
  "./executors/*/executor.js": "./dist/executors/*/executor.js",
75
- "./executors/*/executor.mjs": "./dist/executors/*/executor.mjs"
105
+ "./executors/*/executor.mjs": "./dist/executors/*/executor.mjs",
106
+ "./generators/*/generator.js": "./dist/generators/*/generator.js",
107
+ "./generators/*/generator.mjs": "./dist/generators/*/generator.mjs"
76
108
  },
77
109
  "main": "dist/index.js",
78
110
  "module": "dist/index.mjs",
79
111
  "typings": "dist/index.d.ts",
80
112
  "dependencies": {
113
+ "c12": "^3.3.4",
81
114
  "@nx/devkit": "23.1.0",
82
- "@power-plant/core": "^0.0.52",
83
- "@razorwind/core": "^0.0.11",
115
+ "@power-plant/core": "^0.0.55",
116
+ "@razorwind/core": "^0.0.13",
84
117
  "@stryke/hash": "^0.13.52",
85
118
  "@stryke/path": "^0.29.25",
86
119
  "@stryke/string-format": "^0.17.40",
@@ -90,8 +123,8 @@
90
123
  "untyped": "^2.0.0"
91
124
  },
92
125
  "devDependencies": {
93
- "@powerlines/plugin-tsdown": "^0.1.571",
94
- "@powerlines/plugin-untyped": "^0.2.585",
126
+ "@powerlines/plugin-tsdown": "^0.1.577",
127
+ "@powerlines/plugin-untyped": "^0.2.591",
95
128
  "@types/node": "^25.9.5",
96
129
  "eslint-flat-config-utils": "^3.2.0",
97
130
  "jsonc-eslint-parser": "^3.1.0"
@@ -99,5 +132,6 @@
99
132
  "peerDependencies": { "nx": ">=23.0.0" },
100
133
  "publishConfig": { "access": "public" },
101
134
  "executors": "./executors.json",
102
- "gitHead": "fd7712d76c7a07b13072384c0d57b7f36d5c9946"
135
+ "generators": "./generators.json",
136
+ "gitHead": "c8809ed75332698630354cdd342daae6a4535193"
103
137
  }