@storm-software/workspace-tools 1.264.27 → 1.265.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.
@@ -1,450 +0,0 @@
1
- import {
2
- getProjectPlatform
3
- } from "./chunk-XBRJIYCS.mjs";
4
- import {
5
- ProjectTagConstants,
6
- addProjectTag,
7
- isEqualProjectTag,
8
- setDefaultProjectTags
9
- } from "./chunk-HUVBVDJ7.mjs";
10
- import {
11
- __name
12
- } from "./chunk-2BPV2XV2.mjs";
13
-
14
- // src/plugins/typescript/project-config.ts
15
- import { existsSync } from "node:fs";
16
- import { dirname, join } from "node:path";
17
- import { readNxJson } from "nx/src/config/nx-json.js";
18
- import { readJsonFile } from "nx/src/utils/fileutils";
19
- import { readTargetsFromPackageJson } from "nx/src/utils/package-json";
20
- import { readTSConfig } from "pkg-types";
21
- var name = "storm-software/typescript";
22
- var createNodes = [
23
- "{project.json,**/project.json}",
24
- async (file, opts = {
25
- includeApps: true
26
- }, ctx) => {
27
- const packageJson = createPackageJson(file, ctx.workspaceRoot);
28
- if (!packageJson) {
29
- return {};
30
- }
31
- const tsconfig = await createTsconfig(file, ctx.workspaceRoot);
32
- if (!tsconfig) {
33
- return {};
34
- }
35
- const project = createProjectFromPackageJsonNextToProjectJson(file, packageJson);
36
- if (opts?.includeApps === false && project.projectType === "application") {
37
- return {};
38
- }
39
- const enableMarkdownlint = opts?.enableMarkdownlint !== false;
40
- const enableEslint = opts?.enableEslint !== false;
41
- const nxJson = readNxJson(ctx.workspaceRoot);
42
- const targets = readTargetsFromPackageJson(packageJson, nxJson);
43
- if (join(ctx.workspaceRoot, project.root).startsWith(join(ctx.workspaceRoot, "tools")) && opts?.lintInternalTools !== true) {
44
- targets.lint = {
45
- dependsOn: [
46
- "^lint"
47
- ],
48
- executor: "nx:run-commands",
49
- options: {
50
- command: "echo 'Skipping linting of internal tools package \"{projectName}\". This can be changed by setting `lintInternalTools` to `true` in the Storm TypeScript plugin options.' "
51
- }
52
- };
53
- } else {
54
- if (!targets["lint-ls"]) {
55
- targets["lint-ls"] = {
56
- cache: true,
57
- inputs: [
58
- "linting",
59
- "typescript",
60
- "^production"
61
- ],
62
- dependsOn: [
63
- "^lint-ls"
64
- ],
65
- executor: "nx:run-commands",
66
- options: {
67
- command: 'pnpm exec ls-lint --config="node_modules/@storm-software/linting-tools/ls-lint/.ls-lint.yml" '
68
- }
69
- };
70
- }
71
- if (!targets["lint-markdown"] && enableMarkdownlint) {
72
- targets["lint-markdown"] = {
73
- cache: true,
74
- outputs: [
75
- "{projectRoot}/**/*.md",
76
- "{projectRoot}/**/*.mdx"
77
- ],
78
- inputs: [
79
- "linting",
80
- "{projectRoot}/**/*.md",
81
- "{projectRoot}/**/*.mdx"
82
- ],
83
- dependsOn: [
84
- "^lint-markdown"
85
- ],
86
- executor: "nx:run-commands",
87
- options: {
88
- command: 'pnpm exec markdownlint-cli2 "{projectRoot}/*.{md,mdx}" "{projectRoot}/**/*.{md,mdx}" --config "node_modules/@storm-software/markdownlint/config/base.markdownlint-cli2.jsonc" --fix'
89
- }
90
- };
91
- }
92
- if (!targets.lint && enableEslint) {
93
- let eslintConfig = checkEslintConfigAtPath(project.root);
94
- if (!eslintConfig) {
95
- eslintConfig = checkEslintConfigAtPath(ctx.workspaceRoot);
96
- }
97
- if (eslintConfig) {
98
- targets.lint = {
99
- cache: true,
100
- inputs: [
101
- "linting",
102
- "typescript",
103
- "^production"
104
- ],
105
- outputs: [
106
- "{projectRoot}/**/*.{ts,tsx,js,jsx,json,md,mdx,yaml,yml,html,css,scss,sass,less,graphql,gql}"
107
- ],
108
- dependsOn: [
109
- "lint-markdown",
110
- "lint-knip",
111
- "^lint"
112
- ],
113
- executor: "@nx/eslint:lint",
114
- options: {
115
- format: "stylish",
116
- fix: true,
117
- errorOnUnmatchedPattern: false,
118
- cache: true,
119
- cacheLocation: "{workspaceRoot}/node_modules/.cache/eslint/{projectRoot}",
120
- eslintConfig
121
- }
122
- };
123
- }
124
- }
125
- }
126
- if (!targets["format-toml"]) {
127
- targets["format-toml"] = {
128
- inputs: [
129
- "linting",
130
- "{projectRoot}/**/*.toml"
131
- ],
132
- outputs: [
133
- "{projectRoot}/**/*.toml"
134
- ],
135
- dependsOn: [
136
- "^format-toml"
137
- ],
138
- executor: "nx:run-commands",
139
- options: {
140
- command: 'pnpm exec taplo format --config="node_modules/@storm-software/linting-tools/taplo/config.toml" --cache-path="node_modules/.cache/taplo/{projectRoot}" --colors="always" "{projectRoot}/*.toml" "{projectRoot}/**/*.toml" '
141
- }
142
- };
143
- }
144
- if (!targets["format-readme"]) {
145
- targets["format-readme"] = {
146
- inputs: [
147
- "linting",
148
- "documentation",
149
- "{projectRoot}/{README.md,package.json,Cargo.toml,executors.json,generators.json}"
150
- ],
151
- outputs: [
152
- "{projectRoot}/README.md"
153
- ],
154
- dependsOn: [
155
- "^format-readme"
156
- ],
157
- executor: "nx:run-commands",
158
- options: {
159
- command: 'pnpm exec storm-git readme --templates="tools/readme-templates" --project="{projectName}"'
160
- }
161
- };
162
- }
163
- if (!targets["format-prettier"]) {
164
- targets["format-prettier"] = {
165
- inputs: [
166
- "linting",
167
- "typescript",
168
- "^production"
169
- ],
170
- outputs: [
171
- "{projectRoot}/**/*"
172
- ],
173
- dependsOn: [
174
- "^format-prettier"
175
- ],
176
- executor: "nx:run-commands",
177
- options: {
178
- command: 'pnpm exec prettier "{projectRoot}/**/*" --write --ignore-unknown --no-error-on-unmatched-pattern --config="node_modules/@storm-software/prettier/config.json" --ignore-path="node_modules/@storm-software/prettier/.prettierignore" --cache --cache-location="node_modules/.cache/prettier/{projectRoot}" '
179
- }
180
- };
181
- }
182
- if (!targets.format) {
183
- targets.format = {
184
- dependsOn: [
185
- "format-readme",
186
- "format-toml",
187
- "format-prettier",
188
- "^format"
189
- ],
190
- executor: "nx:run-commands",
191
- options: {
192
- command: `echo 'Formatting the project files in "{projectRoot}"' `
193
- }
194
- };
195
- }
196
- if (!targets.clean) {
197
- targets.clean = {
198
- cache: true,
199
- executor: "nx:run-commands",
200
- inputs: [
201
- "typescript",
202
- "^production"
203
- ],
204
- outputs: [
205
- "{workspaceRoot}/dist/{projectRoot}"
206
- ],
207
- options: {
208
- command: "pnpm exec rimraf dist/{projectRoot}",
209
- color: true,
210
- cwd: "{workspaceRoot}"
211
- }
212
- };
213
- }
214
- if (!targets.rebuild) {
215
- targets.rebuild = {
216
- cache: false,
217
- executor: "nx:run-commands",
218
- dependsOn: [
219
- "clean",
220
- "^build"
221
- ],
222
- inputs: [
223
- "typescript",
224
- "default",
225
- "^production"
226
- ],
227
- outputs: [
228
- "{workspaceRoot}/dist/{projectRoot}"
229
- ],
230
- options: {
231
- command: `pnpm exec nx run ${project.name}:build`
232
- }
233
- };
234
- }
235
- if (!targets.test && checkJestConfigAtPath(project.root)) {
236
- targets.test = {
237
- cache: true,
238
- executor: "@nx/jest:jest",
239
- inputs: [
240
- "testing",
241
- "typescript",
242
- "^production"
243
- ],
244
- outputs: [
245
- "{workspaceRoot}/coverage/{projectRoot}"
246
- ],
247
- defaultConfiguration: "development",
248
- options: {
249
- jestConfig: "{projectRoot}/jest.config.ts",
250
- passWithNoTests: true
251
- },
252
- configurations: {
253
- development: {
254
- ci: false,
255
- codeCoverage: true
256
- },
257
- production: {
258
- ci: true,
259
- codeCoverage: true
260
- }
261
- }
262
- };
263
- }
264
- targets["size-limit"] = {
265
- dependsOn: [
266
- "build",
267
- "^size-limit"
268
- ],
269
- options: {}
270
- };
271
- const isPrivate = packageJson.private ?? false;
272
- if (!isPrivate) {
273
- addProjectTag(project, ProjectTagConstants.Registry.TAG_ID, ProjectTagConstants.Registry.NPM, {
274
- overwrite: true
275
- });
276
- targets["nx-release-publish"] = {
277
- dependsOn: [
278
- "build",
279
- "size-limit",
280
- "^nx-release-publish"
281
- ],
282
- executor: "@storm-software/workspace-tools:npm-publish",
283
- options: {}
284
- };
285
- if (project.projectType === "application" || isEqualProjectTag(project, ProjectTagConstants.ProjectType.TAG_ID, ProjectTagConstants.ProjectType.APPLICATION) || isEqualProjectTag(project, ProjectTagConstants.DistStyle.TAG_ID, ProjectTagConstants.DistStyle.CLEAN)) {
286
- targets["clean-package"] = {
287
- cache: true,
288
- dependsOn: [
289
- "build"
290
- ],
291
- inputs: [
292
- "linting",
293
- "testing",
294
- "documentation",
295
- "default",
296
- "^production"
297
- ],
298
- outputs: [
299
- "{workspaceRoot}/dist/{projectRoot}"
300
- ],
301
- executor: "@storm-software/workspace-tools:clean-package",
302
- options: {
303
- cleanReadMe: true,
304
- cleanComments: true
305
- }
306
- };
307
- targets["nx-release-publish"].dependsOn?.push("clean-package");
308
- targets["size-limit"].dependsOn?.push("clean-package");
309
- }
310
- }
311
- addProjectTag(project, ProjectTagConstants.Language.TAG_ID, ProjectTagConstants.Language.TYPESCRIPT, {
312
- overwrite: true
313
- });
314
- const platform = getProjectPlatform(project);
315
- switch (platform) {
316
- case "worker":
317
- addProjectTag(project, ProjectTagConstants.Platform.TAG_ID, ProjectTagConstants.Platform.WORKER, {
318
- overwrite: true
319
- });
320
- break;
321
- case "node":
322
- addProjectTag(project, ProjectTagConstants.Platform.TAG_ID, ProjectTagConstants.Platform.NODE, {
323
- overwrite: true
324
- });
325
- break;
326
- case "browser":
327
- addProjectTag(project, ProjectTagConstants.Platform.TAG_ID, ProjectTagConstants.Platform.BROWSER, {
328
- overwrite: true
329
- });
330
- break;
331
- default:
332
- addProjectTag(project, ProjectTagConstants.Platform.TAG_ID, ProjectTagConstants.Platform.NEUTRAL, {
333
- overwrite: true
334
- });
335
- break;
336
- }
337
- setDefaultProjectTags(project, name);
338
- return project?.name ? {
339
- projects: {
340
- [project.name]: {
341
- ...project,
342
- targets,
343
- release: {
344
- ...project?.release,
345
- version: {
346
- ...project?.release?.version,
347
- generator: "@storm-software/workspace-tools:release-version"
348
- }
349
- }
350
- }
351
- }
352
- } : {};
353
- }
354
- ];
355
- function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, packageJson) {
356
- const { nx, name: name2 } = packageJson;
357
- const root = dirname(projectJsonPath);
358
- return {
359
- ...nx,
360
- name: name2,
361
- root,
362
- targets: {}
363
- };
364
- }
365
- __name(createProjectFromPackageJsonNextToProjectJson, "createProjectFromPackageJsonNextToProjectJson");
366
- function createPackageJson(projectJsonPath, workspaceRoot) {
367
- try {
368
- const root = dirname(projectJsonPath);
369
- const packageJsonPath = join(workspaceRoot, root, "package.json");
370
- if (!existsSync(packageJsonPath)) {
371
- return null;
372
- }
373
- return readJsonFile(packageJsonPath);
374
- } catch (e) {
375
- console.log(e);
376
- return null;
377
- }
378
- }
379
- __name(createPackageJson, "createPackageJson");
380
- async function createTsconfig(projectJsonPath, workspaceRoot) {
381
- try {
382
- const root = dirname(projectJsonPath);
383
- const tsconfigJsonPath = join(workspaceRoot, root, "tsconfig.json");
384
- if (!existsSync(tsconfigJsonPath)) {
385
- return null;
386
- }
387
- return readTSConfig(tsconfigJsonPath);
388
- } catch (e) {
389
- console.log(e);
390
- return null;
391
- }
392
- }
393
- __name(createTsconfig, "createTsconfig");
394
- function checkEslintConfigAtPath(directory) {
395
- const hasEslintConfigFile = /* @__PURE__ */ __name((fileName) => {
396
- return existsSync(join(directory, fileName));
397
- }, "hasEslintConfigFile");
398
- if (hasEslintConfigFile(".eslintrc.js")) {
399
- return ".eslintrc.js";
400
- } else if (hasEslintConfigFile(".eslintrc.cjs")) {
401
- return ".eslintrc.cjs";
402
- } else if (hasEslintConfigFile(".eslintrc.yaml")) {
403
- return ".eslintrc.yaml";
404
- } else if (hasEslintConfigFile(".eslintrc.yml")) {
405
- return ".eslintrc.yml";
406
- } else if (hasEslintConfigFile(".eslintrc.json")) {
407
- return ".eslintrc.json";
408
- } else if (hasEslintConfigFile(".eslintrc")) {
409
- return ".eslintrc";
410
- } else if (hasEslintConfigFile("eslint.config.js")) {
411
- return "eslint.config.js";
412
- } else if (hasEslintConfigFile("eslint.config.cjs")) {
413
- return "eslint.config.cjs";
414
- } else if (hasEslintConfigFile("eslint.config.mjs")) {
415
- return "eslint.config.mjs";
416
- } else if (hasEslintConfigFile("eslint.config.ts")) {
417
- return "eslint.config.ts";
418
- } else if (hasEslintConfigFile("eslint.config.cts")) {
419
- return "eslint.config.cts";
420
- } else if (hasEslintConfigFile("eslint.config.mts")) {
421
- return "eslint.config.mts";
422
- }
423
- return null;
424
- }
425
- __name(checkEslintConfigAtPath, "checkEslintConfigAtPath");
426
- function checkJestConfigAtPath(directory) {
427
- const hasJestConfigFile = /* @__PURE__ */ __name((fileName) => {
428
- return existsSync(join(directory, fileName));
429
- }, "hasJestConfigFile");
430
- if (hasJestConfigFile("eslint.config.js")) {
431
- return "jest.config.js";
432
- } else if (hasJestConfigFile("eslint.config.cjs")) {
433
- return "jest.config.cjs";
434
- } else if (hasJestConfigFile("eslint.config.mjs")) {
435
- return "jest.config.mjs";
436
- } else if (hasJestConfigFile("eslint.config.ts")) {
437
- return "jest.config.ts";
438
- } else if (hasJestConfigFile("jest.config.cts")) {
439
- return "jest.config.cts";
440
- } else if (hasJestConfigFile("jest.config.mts")) {
441
- return "jest.config.mts";
442
- }
443
- return null;
444
- }
445
- __name(checkJestConfigAtPath, "checkJestConfigAtPath");
446
-
447
- export {
448
- name,
449
- createNodes
450
- };