@storm-software/workspace-tools 1.269.0 → 1.270.0

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.
Files changed (274) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +2 -1
  3. package/dist/chunk-A7JGVU4P.js +468 -0
  4. package/dist/chunk-SRN4D7WO.mjs +468 -0
  5. package/dist/executors.js +2 -2
  6. package/dist/executors.mjs +1 -1
  7. package/dist/index.js +2 -2
  8. package/dist/index.mjs +1 -1
  9. package/dist/src/executors/npm-publish/executor.js +2 -2
  10. package/dist/src/executors/npm-publish/executor.mjs +1 -1
  11. package/docs/executors/rollup.md +88 -0
  12. package/executors.ts +23 -0
  13. package/generators.ts +14 -0
  14. package/index.ts +5 -0
  15. package/package.json +4 -4
  16. package/project.json +58 -0
  17. package/src/base/base-executor.ts +200 -0
  18. package/src/base/base-executor.untyped.ts +18 -0
  19. package/src/base/base-generator.ts +130 -0
  20. package/src/base/base-generator.untyped.ts +16 -0
  21. package/src/base/cargo-base-executor.untyped.ts +73 -0
  22. package/src/base/index.ts +8 -0
  23. package/src/base/typescript-build-executor.untyped.ts +153 -0
  24. package/src/base/typescript-library-generator.ts +415 -0
  25. package/src/base/typescript-library-generator.untyped.ts +106 -0
  26. package/src/executors/cargo-build/executor.spec.ts +18 -0
  27. package/src/executors/cargo-build/executor.ts +28 -0
  28. package/src/executors/cargo-build/untyped.ts +18 -0
  29. package/src/executors/cargo-check/executor.spec.ts +18 -0
  30. package/src/executors/cargo-check/executor.ts +27 -0
  31. package/src/executors/cargo-check/untyped.ts +11 -0
  32. package/src/executors/cargo-clippy/executor.spec.ts +18 -0
  33. package/src/executors/cargo-clippy/executor.ts +28 -0
  34. package/src/executors/cargo-clippy/untyped.ts +18 -0
  35. package/src/executors/cargo-doc/executor.spec.ts +18 -0
  36. package/src/executors/cargo-doc/executor.ts +39 -0
  37. package/src/executors/cargo-doc/untyped.ts +44 -0
  38. package/src/executors/cargo-format/executor.spec.ts +18 -0
  39. package/src/executors/cargo-format/executor.ts +28 -0
  40. package/src/executors/cargo-format/untyped.ts +11 -0
  41. package/src/executors/cargo-publish/executor.spec.ts +11 -0
  42. package/src/executors/cargo-publish/executor.ts +139 -0
  43. package/src/executors/cargo-publish/untyped.ts +33 -0
  44. package/src/executors/clean-package/constants.ts +99 -0
  45. package/src/executors/clean-package/executor.spec.ts +18 -0
  46. package/src/executors/clean-package/executor.ts +214 -0
  47. package/src/executors/clean-package/types.ts +6 -0
  48. package/src/executors/clean-package/untyped.ts +60 -0
  49. package/src/executors/clean-package/utils.ts +85 -0
  50. package/src/executors/esbuild/executor.spec.ts +11 -0
  51. package/src/executors/esbuild/executor.ts +67 -0
  52. package/src/executors/esbuild/untyped.ts +20 -0
  53. package/src/executors/npm-publish/executor.spec.ts +11 -0
  54. package/src/executors/npm-publish/executor.ts +681 -0
  55. package/src/executors/npm-publish/untyped.ts +56 -0
  56. package/src/executors/size-limit/executor.spec.ts +18 -0
  57. package/src/executors/size-limit/executor.ts +88 -0
  58. package/src/executors/size-limit/untyped.ts +22 -0
  59. package/src/executors/typia/executor.ts +54 -0
  60. package/src/executors/typia/untyped.ts +48 -0
  61. package/src/executors/unbuild/executor.spec.ts +11 -0
  62. package/src/executors/unbuild/executor.ts +136 -0
  63. package/src/executors/unbuild/untyped.ts +152 -0
  64. package/src/generators/browser-library/generator.spec.ts +20 -0
  65. package/src/generators/browser-library/generator.ts +109 -0
  66. package/src/generators/browser-library/untyped.ts +29 -0
  67. package/src/generators/config-schema/generator.spec.ts +20 -0
  68. package/src/generators/config-schema/generator.ts +90 -0
  69. package/src/generators/config-schema/untyped.ts +19 -0
  70. package/src/generators/init/init.ts +32 -0
  71. package/src/generators/init/untyped.ts +16 -0
  72. package/src/generators/neutral-library/generator.spec.ts +20 -0
  73. package/src/generators/neutral-library/generator.ts +81 -0
  74. package/src/generators/neutral-library/untyped.ts +29 -0
  75. package/src/generators/node-library/generator.spec.ts +20 -0
  76. package/src/generators/node-library/generator.ts +84 -0
  77. package/src/generators/node-library/untyped.ts +29 -0
  78. package/src/generators/preset/files/.all-contributorsrc.template +48 -0
  79. package/src/generators/preset/files/.editorconfig +454 -0
  80. package/src/generators/preset/files/.env.template +38 -0
  81. package/src/generators/preset/files/.gitattributes +52 -0
  82. package/src/generators/preset/files/.github/.nvmrc +1 -0
  83. package/src/generators/preset/files/.github/CODEOWNERS +3 -0
  84. package/src/generators/preset/files/.github/CODE_OF_CONDUCT.md +125 -0
  85. package/src/generators/preset/files/.github/CONTRIBUTING.md.template +15 -0
  86. package/src/generators/preset/files/.github/FUNDING.yml +3 -0
  87. package/src/generators/preset/files/.github/ISSUE_TEMPLATE/bug-report.yml.template +102 -0
  88. package/src/generators/preset/files/.github/ISSUE_TEMPLATE/documentation.yml.template +56 -0
  89. package/src/generators/preset/files/.github/ISSUE_TEMPLATE/feature-request.yml.template +60 -0
  90. package/src/generators/preset/files/.github/PULL_REQUEST_TEMPLATE.md.template +39 -0
  91. package/src/generators/preset/files/.github/SECURITY.md +9 -0
  92. package/src/generators/preset/files/.github/codecov.yml +29 -0
  93. package/src/generators/preset/files/.github/dependabot.yml +64 -0
  94. package/src/generators/preset/files/.github/labels.yml +84 -0
  95. package/src/generators/preset/files/.github/renovate.json +4 -0
  96. package/src/generators/preset/files/.github/renovate.json.template +63 -0
  97. package/src/generators/preset/files/.github/stale.yml +55 -0
  98. package/src/generators/preset/files/.github/workflows/build-release.yml.template +25 -0
  99. package/src/generators/preset/files/.github/workflows/code-review.yml +18 -0
  100. package/src/generators/preset/files/.github/workflows/codeql.yml +84 -0
  101. package/src/generators/preset/files/.github/workflows/dependabot-update.yml +32 -0
  102. package/src/generators/preset/files/.github/workflows/git-guardian.yml +23 -0
  103. package/src/generators/preset/files/.github/workflows/greetings.yml +31 -0
  104. package/src/generators/preset/files/.github/workflows/labels.yml +31 -0
  105. package/src/generators/preset/files/.github/workflows/lock.yml +26 -0
  106. package/src/generators/preset/files/.log4brains.yml.template +5 -0
  107. package/src/generators/preset/files/.markdownlint.json +155 -0
  108. package/src/generators/preset/files/.verdaccio/config.yml.template +40 -0
  109. package/src/generators/preset/files/.vscode/README.md +32 -0
  110. package/src/generators/preset/files/.vscode/cspell.json +3 -0
  111. package/src/generators/preset/files/.vscode/extensions.json +14 -0
  112. package/src/generators/preset/files/.vscode/launch.json +37 -0
  113. package/src/generators/preset/files/.vscode/settings.json +401 -0
  114. package/src/generators/preset/files/.vscode/tasks.json +4 -0
  115. package/src/generators/preset/files/.whitesource +14 -0
  116. package/src/generators/preset/files/assets/diagrams/.gitkeep +0 -0
  117. package/src/generators/preset/files/assets/icons/dark/.gitkeep +0 -0
  118. package/src/generators/preset/files/assets/icons/light/.gitkeep +0 -0
  119. package/src/generators/preset/files/assets/logos/.gitkeep +0 -0
  120. package/src/generators/preset/files/docs/api-reference/.gitkeep +0 -0
  121. package/src/generators/preset/generator.spec.ts +20 -0
  122. package/src/generators/preset/generator.ts +315 -0
  123. package/src/generators/preset/untyped.ts +88 -0
  124. package/src/generators/release-version/generator.spec.ts +20 -0
  125. package/src/generators/release-version/generator.ts +920 -0
  126. package/src/generators/release-version/untyped.ts +156 -0
  127. package/src/plugins/rust/cargo-toml.ts +434 -0
  128. package/src/plugins/rust/index.ts +1 -0
  129. package/src/plugins/typescript/index.ts +1 -0
  130. package/src/plugins/typescript/project-config.ts +564 -0
  131. package/src/plugins/typescript/tsup.ts +198 -0
  132. package/src/types.ts +130 -0
  133. package/src/utils/apply-workspace-tokens.ts +73 -0
  134. package/src/utils/cargo.ts +219 -0
  135. package/src/utils/create-cli-options.ts +23 -0
  136. package/src/utils/get-project-configurations.ts +27 -0
  137. package/src/utils/index.ts +12 -0
  138. package/src/utils/lock-file.ts +159 -0
  139. package/src/utils/package-helpers.ts +54 -0
  140. package/src/utils/plugin-helpers.ts +112 -0
  141. package/src/utils/pnpm-deps-update.ts +111 -0
  142. package/src/utils/project-tags.ts +162 -0
  143. package/src/utils/toml.ts +204 -0
  144. package/src/utils/typia-transform.ts +8 -0
  145. package/src/utils/versions.ts +19 -0
  146. package/tsconfig.json +30 -0
  147. package/tsup.config.ts +36 -0
  148. package/dist/chunk-62LQXZNY.js +0 -282
  149. package/dist/chunk-F3VG4R53.mjs +0 -282
  150. package/dist/src/generators/preset/files/LICENSE +0 -201
  151. package/docs/api/base/base-executor.schema.md +0 -16
  152. package/docs/api/base/base-generator.schema.md +0 -15
  153. package/docs/api/base/cargo-base-executor.schema.md +0 -90
  154. package/docs/api/base/typescript-build-executor.schema.md +0 -126
  155. package/docs/api/base/typescript-library-generator.schema.md +0 -129
  156. package/docs/api/executors/cargo-build/schema.md +0 -89
  157. package/docs/api/executors/cargo-check/schema.md +0 -90
  158. package/docs/api/executors/cargo-clippy/schema.md +0 -99
  159. package/docs/api/executors/cargo-doc/schema.md +0 -130
  160. package/docs/api/executors/cargo-format/schema.md +0 -90
  161. package/docs/api/executors/cargo-publish/schema.md +0 -117
  162. package/docs/api/executors/clean-package/schema.md +0 -65
  163. package/docs/api/executors/esbuild/schema.md +0 -126
  164. package/docs/api/executors/npm-publish/schema.md +0 -64
  165. package/docs/api/executors/size-limit/schema.md +0 -25
  166. package/docs/api/executors/typia/schema.md +0 -46
  167. package/docs/api/executors/unbuild/schema.md +0 -222
  168. package/docs/api/generators/browser-library/files/README.md +0 -58
  169. package/docs/api/generators/browser-library/schema.md +0 -129
  170. package/docs/api/generators/config-schema/schema.md +0 -25
  171. package/docs/api/generators/init/schema.md +0 -15
  172. package/docs/api/generators/neutral-library/files/README.md +0 -58
  173. package/docs/api/generators/neutral-library/schema.md +0 -129
  174. package/docs/api/generators/node-library/files/README.md +0 -63
  175. package/docs/api/generators/node-library/schema.md +0 -129
  176. package/docs/api/generators/preset/schema.md +0 -110
  177. package/docs/api/generators/release-version/schema.md +0 -160
  178. /package/{dist/src → src}/base/base-executor.schema.d.ts +0 -0
  179. /package/{dist/src → src}/base/base-executor.schema.json +0 -0
  180. /package/{dist/src → src}/base/base-executor.schema.md +0 -0
  181. /package/{dist/src → src}/base/base-generator.schema.d.ts +0 -0
  182. /package/{dist/src → src}/base/base-generator.schema.json +0 -0
  183. /package/{dist/src → src}/base/base-generator.schema.md +0 -0
  184. /package/{dist/src → src}/base/cargo-base-executor.schema.d.ts +0 -0
  185. /package/{dist/src → src}/base/cargo-base-executor.schema.json +0 -0
  186. /package/{dist/src → src}/base/cargo-base-executor.schema.md +0 -0
  187. /package/{dist/src → src}/base/typescript-build-executor.schema.d.ts +0 -0
  188. /package/{dist/src → src}/base/typescript-build-executor.schema.json +0 -0
  189. /package/{dist/src → src}/base/typescript-build-executor.schema.md +0 -0
  190. /package/{dist/src → src}/base/typescript-library-generator.schema.d.ts +0 -0
  191. /package/{dist/src → src}/base/typescript-library-generator.schema.json +0 -0
  192. /package/{dist/src → src}/base/typescript-library-generator.schema.md +0 -0
  193. /package/{dist/src → src}/executors/cargo-build/schema.d.ts +0 -0
  194. /package/{dist/src → src}/executors/cargo-build/schema.json +0 -0
  195. /package/{dist/src → src}/executors/cargo-build/schema.md +0 -0
  196. /package/{dist/src → src}/executors/cargo-check/schema.d.ts +0 -0
  197. /package/{dist/src → src}/executors/cargo-check/schema.json +0 -0
  198. /package/{dist/src → src}/executors/cargo-check/schema.md +0 -0
  199. /package/{dist/src → src}/executors/cargo-clippy/schema.d.ts +0 -0
  200. /package/{dist/src → src}/executors/cargo-clippy/schema.json +0 -0
  201. /package/{dist/src → src}/executors/cargo-clippy/schema.md +0 -0
  202. /package/{dist/src → src}/executors/cargo-doc/schema.d.ts +0 -0
  203. /package/{dist/src → src}/executors/cargo-doc/schema.json +0 -0
  204. /package/{dist/src → src}/executors/cargo-doc/schema.md +0 -0
  205. /package/{dist/src → src}/executors/cargo-format/schema.d.ts +0 -0
  206. /package/{dist/src → src}/executors/cargo-format/schema.json +0 -0
  207. /package/{dist/src → src}/executors/cargo-format/schema.md +0 -0
  208. /package/{dist/src → src}/executors/cargo-publish/schema.d.ts +0 -0
  209. /package/{dist/src → src}/executors/cargo-publish/schema.json +0 -0
  210. /package/{dist/src → src}/executors/cargo-publish/schema.md +0 -0
  211. /package/{dist/src → src}/executors/clean-package/schema.d.ts +0 -0
  212. /package/{dist/src → src}/executors/clean-package/schema.json +0 -0
  213. /package/{dist/src → src}/executors/clean-package/schema.md +0 -0
  214. /package/{dist/src → src}/executors/esbuild/schema.d.ts +0 -0
  215. /package/{dist/src → src}/executors/esbuild/schema.json +0 -0
  216. /package/{dist/src → src}/executors/esbuild/schema.md +0 -0
  217. /package/{dist/src → src}/executors/npm-publish/schema.d.ts +0 -0
  218. /package/{dist/src → src}/executors/npm-publish/schema.json +0 -0
  219. /package/{dist/src → src}/executors/npm-publish/schema.md +0 -0
  220. /package/{dist/src → src}/executors/size-limit/schema.d.ts +0 -0
  221. /package/{dist/src → src}/executors/size-limit/schema.json +0 -0
  222. /package/{dist/src → src}/executors/size-limit/schema.md +0 -0
  223. /package/{dist/src → src}/executors/typia/schema.d.ts +0 -0
  224. /package/{dist/src → src}/executors/typia/schema.json +0 -0
  225. /package/{dist/src → src}/executors/typia/schema.md +0 -0
  226. /package/{dist/src → src}/executors/unbuild/schema.d.ts +0 -0
  227. /package/{dist/src → src}/executors/unbuild/schema.json +0 -0
  228. /package/{dist/src → src}/executors/unbuild/schema.md +0 -0
  229. /package/{dist/src → src}/generators/browser-library/files/README.md +0 -0
  230. /package/{dist/src → src}/generators/browser-library/files/jest.config.ts +0 -0
  231. /package/{dist/src → src}/generators/browser-library/files/src/index.ts.template +0 -0
  232. /package/{dist/src → src}/generators/browser-library/files/tsconfig.spec.json +0 -0
  233. /package/{dist/src → src}/generators/browser-library/schema.d.ts +0 -0
  234. /package/{dist/src → src}/generators/browser-library/schema.json +0 -0
  235. /package/{dist/src → src}/generators/browser-library/schema.md +0 -0
  236. /package/{dist/src → src}/generators/config-schema/schema.d.ts +0 -0
  237. /package/{dist/src → src}/generators/config-schema/schema.json +0 -0
  238. /package/{dist/src → src}/generators/config-schema/schema.md +0 -0
  239. /package/{dist/src → src}/generators/init/schema.d.ts +0 -0
  240. /package/{dist/src → src}/generators/init/schema.json +0 -0
  241. /package/{dist/src → src}/generators/init/schema.md +0 -0
  242. /package/{dist/src → src}/generators/neutral-library/files/README.md +0 -0
  243. /package/{dist/src → src}/generators/neutral-library/files/jest.config.ts +0 -0
  244. /package/{dist/src → src}/generators/neutral-library/files/src/index.ts.template +0 -0
  245. /package/{dist/src → src}/generators/neutral-library/files/tsconfig.spec.json +0 -0
  246. /package/{dist/src → src}/generators/neutral-library/schema.d.ts +0 -0
  247. /package/{dist/src → src}/generators/neutral-library/schema.json +0 -0
  248. /package/{dist/src → src}/generators/neutral-library/schema.md +0 -0
  249. /package/{dist/src → src}/generators/node-library/files/README.md +0 -0
  250. /package/{dist/src → src}/generators/node-library/files/jest.config.ts +0 -0
  251. /package/{dist/src → src}/generators/node-library/files/src/index.ts.template +0 -0
  252. /package/{dist/src → src}/generators/node-library/files/tsconfig.spec.json +0 -0
  253. /package/{dist/src → src}/generators/node-library/schema.d.ts +0 -0
  254. /package/{dist/src → src}/generators/node-library/schema.json +0 -0
  255. /package/{dist/src → src}/generators/node-library/schema.md +0 -0
  256. /package/{LICENSE → src/generators/preset/files/LICENSE} +0 -0
  257. /package/{dist/src → src}/generators/preset/files/README.md.template +0 -0
  258. /package/{dist/src → src}/generators/preset/files/docs/readme-templates/README.footer.md.template +0 -0
  259. /package/{dist/src → src}/generators/preset/files/docs/readme-templates/README.header.md.template +0 -0
  260. /package/{dist/src → src}/generators/preset/files/eslint.config.js.template +0 -0
  261. /package/{dist/src → src}/generators/preset/files/knip.json +0 -0
  262. /package/{dist/src → src}/generators/preset/files/lefthook.json +0 -0
  263. /package/{dist/src → src}/generators/preset/files/nx.json +0 -0
  264. /package/{dist/src → src}/generators/preset/files/pnpm-workspace.yaml +0 -0
  265. /package/{dist/src → src}/generators/preset/files/socket.yaml +0 -0
  266. /package/{dist/src → src}/generators/preset/files/storm.json.template +0 -0
  267. /package/{dist/src → src}/generators/preset/files/tsconfig.base.json.template +0 -0
  268. /package/{dist/src → src}/generators/preset/schema.d.ts +0 -0
  269. /package/{dist/src → src}/generators/preset/schema.json +0 -0
  270. /package/{dist/src → src}/generators/preset/schema.md +0 -0
  271. /package/{dist/src → src}/generators/release-version/schema.d.ts +0 -0
  272. /package/{dist/src → src}/generators/release-version/schema.json +0 -0
  273. /package/{dist/src → src}/generators/release-version/schema.md +0 -0
  274. /package/{dist/src → src}/plugins/typescript/untyped-schema.ts +0 -0
@@ -0,0 +1,153 @@
1
+ import { defineUntypedSchema } from "untyped";
2
+ import baseExecutorSchema from "./base-executor.untyped";
3
+
4
+ export default defineUntypedSchema({
5
+ ...baseExecutorSchema,
6
+ $schema: {
7
+ id: "TypeScriptBuildExecutorSchema",
8
+ title: "TypeScript Build Executor",
9
+ description:
10
+ "A type definition for the base TypeScript build executor schema",
11
+ required: ["entry", "tsconfig"],
12
+ },
13
+ entry: {
14
+ $schema: {
15
+ title: "Entry File(s)",
16
+ format: "path",
17
+ type: "array",
18
+ description: "The entry file or files to build",
19
+ items: { type: "string" },
20
+ },
21
+ $default: ["{sourceRoot}/index.ts"],
22
+ },
23
+ tsconfig: {
24
+ $schema: {
25
+ title: "TSConfig Path",
26
+ type: "string",
27
+ format: "path",
28
+ description: "The path to the tsconfig file",
29
+ },
30
+ $default: "{projectRoot}/tsconfig.json",
31
+ },
32
+ bundle: {
33
+ $schema: {
34
+ title: "Bundle",
35
+ type: "boolean",
36
+ description: "Bundle the output",
37
+ },
38
+ },
39
+ minify: {
40
+ $schema: {
41
+ title: "Minify",
42
+ type: "boolean",
43
+ description: "Minify the output",
44
+ },
45
+ },
46
+ debug: {
47
+ $schema: {
48
+ title: "Debug",
49
+ type: "boolean",
50
+ description: "Debug the output",
51
+ },
52
+ },
53
+ sourcemap: {
54
+ $schema: {
55
+ title: "Sourcemap",
56
+ type: "boolean",
57
+ description: "Generate a sourcemap",
58
+ },
59
+ },
60
+ silent: {
61
+ $schema: {
62
+ title: "Silent",
63
+ type: "boolean",
64
+ description:
65
+ "Should the build run silently - only report errors back to the user",
66
+ },
67
+ $default: false,
68
+ },
69
+ target: {
70
+ $schema: {
71
+ title: "Target",
72
+ type: "string",
73
+ description: "The target to build",
74
+ enum: [
75
+ "es3",
76
+ "es5",
77
+ "es6",
78
+ "es2015",
79
+ "es2016",
80
+ "es2017",
81
+ "es2018",
82
+ "es2019",
83
+ "es2020",
84
+ "es2021",
85
+ "es2022",
86
+ "es2023",
87
+ "es2024",
88
+ "esnext",
89
+ "node12",
90
+ "node14",
91
+ "node16",
92
+ "node18",
93
+ "node20",
94
+ "node22",
95
+ "browser",
96
+ "chrome58",
97
+ "chrome59",
98
+ "chrome60",
99
+ ],
100
+ },
101
+ $default: "esnext",
102
+ $resolve: (val: string = "esnext") => val.toLowerCase(),
103
+ },
104
+ format: {
105
+ $schema: {
106
+ title: "Format",
107
+ type: "array",
108
+ description: "The format to build",
109
+ items: {
110
+ type: "string",
111
+ enum: ["cjs", "esm", "iife"],
112
+ },
113
+ },
114
+ $resolve: (val: string[] = ["cjs", "esm"]) => ([] as string[]).concat(val),
115
+ },
116
+ platform: {
117
+ $schema: {
118
+ title: "Platform",
119
+ type: "string",
120
+ description: "The platform to build",
121
+ enum: ["neutral", "node", "browser"],
122
+ },
123
+ $default: "neutral",
124
+ },
125
+ external: {
126
+ $schema: {
127
+ title: "External",
128
+ type: "array",
129
+ description: "The external dependencies",
130
+ },
131
+ $resolve: (val: string[] = []) => ([] as string[]).concat(val),
132
+ },
133
+ define: {
134
+ $schema: {
135
+ title: "Define",
136
+ type: "object",
137
+ tsType: "Record<string, string>",
138
+ description: "The define values",
139
+ },
140
+ $resolve: (val: Record<string, string> = {}) => val,
141
+ $default: {},
142
+ },
143
+ env: {
144
+ $schema: {
145
+ title: "Environment Variables",
146
+ type: "object",
147
+ tsType: "Record<string, string>",
148
+ description: "The environment variable values",
149
+ },
150
+ $resolve: (val: Record<string, string> = {}) => val,
151
+ $default: {},
152
+ },
153
+ });
@@ -0,0 +1,415 @@
1
+ import {
2
+ type GeneratorCallback,
3
+ type ProjectConfiguration,
4
+ type Tree,
5
+ addDependenciesToPackageJson,
6
+ addProjectConfiguration,
7
+ ensurePackage,
8
+ formatFiles,
9
+ names,
10
+ offsetFromRoot,
11
+ readJson,
12
+ updateJson,
13
+ writeJson
14
+ } from "@nx/devkit";
15
+ import { determineProjectNameAndRootOptions } from "@nx/devkit/src/generators/project-name-and-root-utils";
16
+ import {
17
+ addTsConfigPath,
18
+ getRelativePathToRootTsConfig,
19
+ tsConfigBaseOptions
20
+ } from "@nx/js";
21
+ import jsInitGenerator from "@nx/js/src/generators/init/init";
22
+ import { InitSchema } from "@nx/js/src/generators/init/schema";
23
+ import {
24
+ Bundler,
25
+ NormalizedLibraryGeneratorOptions
26
+ } from "@nx/js/src/generators/library/schema";
27
+ import setupVerdaccio from "@nx/js/src/generators/setup-verdaccio/generator";
28
+ import { ProjectPackageManagerWorkspaceState } from "@nx/js/src/utils/package-manager-workspaces";
29
+ import { StormWorkspaceConfig } from "@storm-software/config";
30
+ import { joinPaths } from "@storm-software/config-tools/utilities/correct-paths";
31
+ import type { PackageJson } from "nx/src/utils/package-json";
32
+ import { UnbuildExecutorSchema } from "../executors/unbuild/schema.d";
33
+ import { addProjectTag, ProjectTagConstants } from "../utils/project-tags";
34
+ import { nxVersion } from "../utils/versions";
35
+ import { TypeScriptLibraryGeneratorSchema } from "./typescript-library-generator.schema.d";
36
+
37
+ export type TypeScriptLibraryGeneratorOptions =
38
+ TypeScriptLibraryGeneratorSchema & {
39
+ devDependencies?: Record<string, string>;
40
+ peerDependencies?: Record<string, string>;
41
+ peerDependenciesMeta?: Record<string, any>;
42
+ tsconfigOptions?: Record<string, any>;
43
+ };
44
+
45
+ export type TypeScriptLibraryGeneratorNormalizedOptions =
46
+ TypeScriptLibraryGeneratorOptions &
47
+ NormalizedLibraryGeneratorOptions & {
48
+ rootProject: boolean;
49
+ };
50
+
51
+ type TypeScriptLibraryProjectConfig = ProjectConfiguration & {
52
+ targets: {
53
+ build: { options: Partial<UnbuildExecutorSchema> };
54
+ } & Record<string, any>;
55
+ };
56
+
57
+ export async function typeScriptLibraryGeneratorFn(
58
+ tree: Tree,
59
+ options: TypeScriptLibraryGeneratorOptions,
60
+ config?: StormWorkspaceConfig
61
+ ) {
62
+ const normalized = await normalizeOptions(tree, { ...options });
63
+
64
+ const tasks: GeneratorCallback[] = [];
65
+ tasks.push(
66
+ await jsInitGenerator(tree, {
67
+ ...normalized,
68
+ tsConfigName: normalized.rootProject
69
+ ? "tsconfig.json"
70
+ : "tsconfig.base.json"
71
+ } as InitSchema)
72
+ );
73
+
74
+ tasks.push(
75
+ addDependenciesToPackageJson(
76
+ tree,
77
+ {},
78
+ {
79
+ "@storm-software/workspace-tools": "latest",
80
+ "@storm-software/testing-tools": "latest",
81
+ ...(options.devDependencies ?? {})
82
+ }
83
+ )
84
+ );
85
+
86
+ if (normalized.publishable) {
87
+ tasks.push(await setupVerdaccio(tree, { ...normalized, skipFormat: true }));
88
+ }
89
+
90
+ const projectConfig = {
91
+ root: normalized.directory,
92
+ projectType: "library",
93
+ sourceRoot: joinPaths(normalized.directory ?? "", "src"),
94
+ targets: {
95
+ build: {
96
+ executor: options.buildExecutor,
97
+ outputs: ["{options.outputPath}"],
98
+ options: {
99
+ entry: [joinPaths(normalized.projectRoot, "src", "index.ts")],
100
+ outputPath: getOutputPath(normalized),
101
+ tsconfig: joinPaths(normalized.projectRoot, "tsconfig.json"),
102
+ project: joinPaths(normalized.projectRoot, "package.json"),
103
+ defaultConfiguration: "production",
104
+ platform: "neutral",
105
+ assets: [
106
+ {
107
+ input: normalized.projectRoot,
108
+ glob: "*.md",
109
+ output: "/"
110
+ },
111
+ {
112
+ input: "",
113
+ glob: "LICENSE",
114
+ output: "/"
115
+ }
116
+ ]
117
+ },
118
+ configurations: {
119
+ production: {
120
+ debug: false,
121
+ verbose: false
122
+ },
123
+ development: {
124
+ debug: true,
125
+ verbose: true
126
+ }
127
+ }
128
+ }
129
+ }
130
+ } as TypeScriptLibraryProjectConfig;
131
+
132
+ if (options.platform) {
133
+ projectConfig.targets.build.options.platform =
134
+ options.platform === "worker" ? "node" : options.platform;
135
+ }
136
+
137
+ addProjectTag(
138
+ projectConfig,
139
+ ProjectTagConstants.Platform.TAG_ID,
140
+ options.platform === "node"
141
+ ? ProjectTagConstants.Platform.NODE
142
+ : options.platform === "worker"
143
+ ? ProjectTagConstants.Platform.WORKER
144
+ : options.platform === "browser"
145
+ ? ProjectTagConstants.Platform.BROWSER
146
+ : ProjectTagConstants.Platform.NEUTRAL,
147
+ { overwrite: false }
148
+ );
149
+
150
+ createProjectTsConfigJson(tree, normalized);
151
+ addProjectConfiguration(tree, normalized.name, projectConfig);
152
+
153
+ let repository = {
154
+ type: "github",
155
+ url:
156
+ config?.repository ||
157
+ `https://github.com/${config?.organization || "storm-software"}/${config?.namespace || config?.name || "repository"}.git`
158
+ };
159
+
160
+ let description =
161
+ options.description ||
162
+ "A package developed by Storm Software used to create modern, scalable web applications.";
163
+
164
+ if (tree.exists("package.json")) {
165
+ const packageJson = readJson<{
166
+ repository: any;
167
+ description: string;
168
+ }>(tree, "package.json");
169
+
170
+ if (packageJson?.repository) {
171
+ repository = packageJson.repository;
172
+ }
173
+ if (packageJson?.description) {
174
+ description = packageJson.description;
175
+ }
176
+ }
177
+
178
+ if (!normalized.importPath) {
179
+ normalized.importPath = normalized.name;
180
+ }
181
+
182
+ const packageJsonPath = joinPaths(normalized.projectRoot, "package.json");
183
+ if (tree.exists(packageJsonPath)) {
184
+ updateJson<PackageJson>(tree, packageJsonPath, (json: PackageJson) => {
185
+ if (!normalized.importPath) {
186
+ normalized.importPath = normalized.name;
187
+ }
188
+
189
+ json.name = normalized.importPath;
190
+ json.version = "0.0.1";
191
+
192
+ // If the package is publishable or root/standalone, we should remove the private field.
193
+ if (json.private && (normalized.publishable || normalized.rootProject)) {
194
+ json.private = undefined;
195
+ }
196
+
197
+ return {
198
+ ...json,
199
+ version: "0.0.1",
200
+ description,
201
+ repository: {
202
+ ...repository,
203
+ directory: normalized.projectRoot
204
+ },
205
+ type: "module",
206
+ dependencies: {
207
+ ...json.dependencies
208
+ },
209
+ publishConfig: {
210
+ access: "public"
211
+ }
212
+ } as unknown as PackageJson;
213
+ });
214
+ } else {
215
+ writeJson<PackageJson>(tree, packageJsonPath, {
216
+ name: normalized.importPath,
217
+ version: "0.0.1",
218
+ description,
219
+ repository: {
220
+ ...repository,
221
+ directory: normalized.projectRoot
222
+ },
223
+ private: !normalized.publishable || normalized.rootProject,
224
+ type: "module",
225
+ publishConfig: {
226
+ access: "public"
227
+ }
228
+ } as unknown as PackageJson);
229
+ }
230
+
231
+ if (tree.exists("package.json") && normalized.importPath) {
232
+ updateJson(tree, "package.json", json => ({
233
+ ...json,
234
+ pnpm: {
235
+ ...json?.pnpm,
236
+ overrides: {
237
+ ...json?.pnpm?.overrides,
238
+ [normalized.importPath ?? ""]: "workspace:*"
239
+ }
240
+ }
241
+ }));
242
+ }
243
+
244
+ addTsConfigPath(tree, normalized.importPath, [
245
+ joinPaths(
246
+ normalized.projectRoot,
247
+ "./src",
248
+ `index.${normalized.js ? "js" : "ts"}`
249
+ )
250
+ ]);
251
+ addTsConfigPath(tree, joinPaths(normalized.importPath, "/*"), [
252
+ joinPaths(normalized.projectRoot, "./src", "/*")
253
+ ]);
254
+
255
+ if (tree.exists("package.json")) {
256
+ const packageJson = readJson<{
257
+ repository: any;
258
+ description: string;
259
+ }>(tree, "package.json");
260
+
261
+ if (packageJson?.repository) {
262
+ repository = packageJson.repository;
263
+ }
264
+ if (packageJson?.description) {
265
+ description = packageJson.description;
266
+ }
267
+ }
268
+
269
+ const tsconfigPath = joinPaths(normalized.projectRoot, "tsconfig.json");
270
+ if (tree.exists(tsconfigPath)) {
271
+ updateJson(tree, tsconfigPath, (json: any) => {
272
+ json.composite ??= true;
273
+
274
+ return json;
275
+ });
276
+ } else {
277
+ writeJson(tree, tsconfigPath, {
278
+ extends: `${offsetFromRoot(normalized.projectRoot)}tsconfig.base.json`,
279
+ composite: true,
280
+ compilerOptions: {
281
+ outDir: `${offsetFromRoot(normalized.projectRoot)}dist/out-tsc`
282
+ },
283
+ files: [],
284
+ include: ["src/**/*.ts", "src/**/*.js"],
285
+ exclude: ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
286
+ });
287
+ }
288
+
289
+ // const lintCallback = await addLint(tree, options);
290
+ // tasks.push(lintCallback);
291
+
292
+ await formatFiles(tree);
293
+
294
+ return null;
295
+ }
296
+
297
+ export function getOutputPath(
298
+ options: TypeScriptLibraryGeneratorNormalizedOptions
299
+ ) {
300
+ const parts = ["dist"];
301
+ if (options.projectRoot === ".") {
302
+ parts.push(options.name);
303
+ } else {
304
+ parts.push(options.projectRoot);
305
+ }
306
+ return joinPaths(...parts);
307
+ }
308
+
309
+ export function createProjectTsConfigJson(
310
+ tree: Tree,
311
+ options: TypeScriptLibraryGeneratorNormalizedOptions
312
+ ) {
313
+ const tsconfig = {
314
+ extends: options.rootProject
315
+ ? undefined
316
+ : getRelativePathToRootTsConfig(tree, options.projectRoot),
317
+ ...(options?.tsconfigOptions ?? {}),
318
+ compilerOptions: {
319
+ ...(options.rootProject ? tsConfigBaseOptions : {}),
320
+ outDir: joinPaths(offsetFromRoot(options.projectRoot), "dist/out-tsc"),
321
+ noEmit: true,
322
+ ...(options?.tsconfigOptions?.compilerOptions ?? {})
323
+ },
324
+ files: [...(options?.tsconfigOptions?.files ?? [])],
325
+ include: [
326
+ ...(options?.tsconfigOptions?.include ?? []),
327
+ "src/**/*.ts",
328
+ "src/**/*.js",
329
+ "bin/**/*"
330
+ ],
331
+ exclude: [
332
+ ...(options?.tsconfigOptions?.exclude ?? []),
333
+ "jest.config.ts",
334
+ "src/**/*.spec.ts",
335
+ "src/**/*.test.ts"
336
+ ]
337
+ };
338
+
339
+ writeJson(tree, joinPaths(options.projectRoot, "tsconfig.json"), tsconfig);
340
+ }
341
+
342
+ export type UnitTestRunner = "jest" | "vitest" | "none" | undefined;
343
+ export type TestEnvironment = "jsdom" | "node" | undefined;
344
+
345
+ export async function normalizeOptions(
346
+ tree: Tree,
347
+ options: TypeScriptLibraryGeneratorOptions,
348
+ config?: StormWorkspaceConfig
349
+ ): Promise<TypeScriptLibraryGeneratorNormalizedOptions> {
350
+ let importPath = options.importPath;
351
+ if (!importPath && config?.namespace) {
352
+ importPath = `@${config?.namespace}/${options.name}`;
353
+ }
354
+
355
+ if (options.publishable) {
356
+ if (!importPath) {
357
+ throw new Error(
358
+ `For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`
359
+ );
360
+ }
361
+ }
362
+
363
+ let bundler: Bundler = "tsc";
364
+ if (options.publishable === false && options.buildable === false) {
365
+ bundler = "none";
366
+ }
367
+
368
+ const { Linter } = ensurePackage("@nx/eslint", nxVersion);
369
+
370
+ const rootProject = false;
371
+ const {
372
+ projectName,
373
+ names: projectNames,
374
+ projectRoot,
375
+ importPath: normalizedImportPath
376
+ } = await determineProjectNameAndRootOptions(tree, {
377
+ name: options.name,
378
+ projectType: "library",
379
+ directory: options.directory,
380
+ importPath,
381
+ rootProject
382
+ });
383
+
384
+ const normalized = names(projectNames.projectFileName);
385
+ const fileName = normalized.fileName;
386
+
387
+ return {
388
+ js: false,
389
+ pascalCaseFiles: false,
390
+ skipFormat: false,
391
+ skipTsConfig: false,
392
+ includeBabelRc: false,
393
+ unitTestRunner: "jest" as UnitTestRunner,
394
+ linter: Linter.EsLint,
395
+ testEnvironment: "node" as TestEnvironment,
396
+ config: "project",
397
+ compiler: "tsc",
398
+ bundler,
399
+ skipTypeCheck: false,
400
+ minimal: false,
401
+ hasPlugin: false,
402
+ isUsingTsSolutionConfig: false,
403
+ projectPackageManagerWorkspaceState:
404
+ "included" as ProjectPackageManagerWorkspaceState,
405
+ ...options,
406
+ fileName,
407
+ name: projectName,
408
+ projectNames,
409
+ projectRoot,
410
+ parsedTags: options.tags ? options.tags.split(",").map(s => s.trim()) : [],
411
+ importPath: normalizedImportPath,
412
+ rootProject,
413
+ shouldUseSwcJest: false
414
+ } as TypeScriptLibraryGeneratorNormalizedOptions;
415
+ }
@@ -0,0 +1,106 @@
1
+ import { defineUntypedSchema } from "untyped";
2
+ import baseGeneratorSchema from "./base-generator.untyped";
3
+
4
+ export default defineUntypedSchema({
5
+ ...baseGeneratorSchema,
6
+ $schema: {
7
+ id: "TypeScriptLibraryGeneratorSchema",
8
+ title: "TypeScript Library Generator",
9
+ description:
10
+ "A type definition for the base TypeScript Library Generator schema",
11
+ required: ["directory", "name"],
12
+ },
13
+ name: {
14
+ $schema: {
15
+ title: "Name",
16
+ type: "string",
17
+ description: "The name of the library",
18
+ },
19
+ },
20
+ description: {
21
+ $schema: {
22
+ title: "Description",
23
+ type: "string",
24
+ description: "The description of the library",
25
+ },
26
+ },
27
+ buildExecutor: {
28
+ $schema: {
29
+ title: "Build Executor",
30
+ type: "string",
31
+ description: "The executor to use for building the library",
32
+ },
33
+ $default: "@storm-software/workspace-tools:unbuild",
34
+ },
35
+ platform: {
36
+ $schema: {
37
+ title: "Platform",
38
+ type: "string",
39
+ description: "The platform to target with the library",
40
+ enum: ["neutral", "node", "worker", "browser"],
41
+ },
42
+ $default: "neutral",
43
+ },
44
+ importPath: {
45
+ $schema: {
46
+ title: "Import Path",
47
+ type: "string",
48
+ description: "The import path for the library",
49
+ },
50
+ },
51
+ tags: {
52
+ $schema: {
53
+ title: "Tags",
54
+ type: "string",
55
+ description: "The tags for the library",
56
+ },
57
+ },
58
+ unitTestRunner: {
59
+ $schema: {
60
+ title: "Unit Test Runner",
61
+ type: "string",
62
+ enum: ["jest", "vitest", "none"],
63
+ description: "The unit test runner to use",
64
+ },
65
+ },
66
+ testEnvironment: {
67
+ $schema: {
68
+ title: "Test Environment",
69
+ type: "string",
70
+ enum: ["jsdom", "node"],
71
+ description: "The test environment to use",
72
+ },
73
+ },
74
+ pascalCaseFiles: {
75
+ $schema: {
76
+ title: "Pascal Case Files",
77
+ type: "boolean",
78
+ description: "Use PascalCase for file names",
79
+ },
80
+ $default: false,
81
+ },
82
+ strict: {
83
+ $schema: {
84
+ title: "Strict",
85
+ type: "boolean",
86
+ description: "Enable strict mode",
87
+ },
88
+ $default: true,
89
+ },
90
+ publishable: {
91
+ $schema: {
92
+ title: "Publishable",
93
+ type: "boolean",
94
+ description: "Make the library publishable",
95
+ },
96
+ $default: false,
97
+ },
98
+ buildable: {
99
+ $schema: {
100
+ title: "Buildable",
101
+ type: "boolean",
102
+ description: "Make the library buildable",
103
+ },
104
+ $default: true,
105
+ },
106
+ });
@@ -0,0 +1,18 @@
1
+ import { ExecutorContext } from "@nx/devkit";
2
+
3
+ import executor from "./executor";
4
+ import { CargoBuildExecutorSchema } from "./schema.d";
5
+
6
+ const options: CargoBuildExecutorSchema = {};
7
+ const context: ExecutorContext = {
8
+ root: "",
9
+ cwd: process.cwd(),
10
+ isVerbose: false,
11
+ };
12
+
13
+ describe("CargoBuild Executor", () => {
14
+ it("can run", async () => {
15
+ const output = await executor(options, context);
16
+ expect(output.success).toBe(true);
17
+ });
18
+ });