@aws/nx-plugin 1.0.0-rc.40 → 1.0.0-rc.41
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/package.json +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +42 -0
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/ts-hooks/generator.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +4 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +17 -0
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +51 -0
- package/src/ts/lib/biome.js +36 -3
- package/src/ts/lib/biome.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +572 -195
- package/src/ts/sync/generator.js +0 -2
- package/src/ts/sync/generator.js.map +1 -1
- package/src/utils/ast.js.map +1 -1
- package/src/utils/files/terraform/src/core/asset-bucket/asset-bucket.tf.template +61 -70
- package/src/utils/format.js +11 -2
- package/src/utils/format.js.map +1 -1
- package/src/utils/warm-ruff-cache.d.ts +12 -0
- package/src/utils/warm-ruff-cache.js +39 -0
- package/src/utils/warm-ruff-cache.js.map +1 -0
- package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +127 -36
- package/src/utils/website-constructs/files/terraform/core/static-website/static-website.tf.template +77 -74
package/package.json
CHANGED
|
@@ -207,6 +207,24 @@ exports[`infra generator > should configure project.json with correct targets >
|
|
|
207
207
|
"cwd": "{projectRoot}",
|
|
208
208
|
},
|
|
209
209
|
},
|
|
210
|
+
"format": {
|
|
211
|
+
"cache": true,
|
|
212
|
+
"configurations": {
|
|
213
|
+
"fix": {
|
|
214
|
+
"command": "biome format --write {projectRoot}",
|
|
215
|
+
},
|
|
216
|
+
"skip-lint": {
|
|
217
|
+
"command": "node -e """,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
"executor": "nx:run-commands",
|
|
221
|
+
"inputs": [
|
|
222
|
+
"biome",
|
|
223
|
+
],
|
|
224
|
+
"options": {
|
|
225
|
+
"command": "biome format {projectRoot}",
|
|
226
|
+
},
|
|
227
|
+
},
|
|
210
228
|
"lint": {
|
|
211
229
|
"cache": true,
|
|
212
230
|
"configurations": {
|
|
@@ -217,6 +235,9 @@ exports[`infra generator > should configure project.json with correct targets >
|
|
|
217
235
|
"command": "node -e """,
|
|
218
236
|
},
|
|
219
237
|
},
|
|
238
|
+
"dependsOn": [
|
|
239
|
+
"format",
|
|
240
|
+
],
|
|
220
241
|
"executor": "nx:run-commands",
|
|
221
242
|
"inputs": [
|
|
222
243
|
"biome",
|
|
@@ -763,6 +784,24 @@ exports[`infra generator > should handle custom project names correctly > custom
|
|
|
763
784
|
"cwd": "{projectRoot}",
|
|
764
785
|
},
|
|
765
786
|
},
|
|
787
|
+
"format": {
|
|
788
|
+
"cache": true,
|
|
789
|
+
"configurations": {
|
|
790
|
+
"fix": {
|
|
791
|
+
"command": "biome format --write {projectRoot}",
|
|
792
|
+
},
|
|
793
|
+
"skip-lint": {
|
|
794
|
+
"command": "node -e """,
|
|
795
|
+
},
|
|
796
|
+
},
|
|
797
|
+
"executor": "nx:run-commands",
|
|
798
|
+
"inputs": [
|
|
799
|
+
"biome",
|
|
800
|
+
],
|
|
801
|
+
"options": {
|
|
802
|
+
"command": "biome format {projectRoot}",
|
|
803
|
+
},
|
|
804
|
+
},
|
|
766
805
|
"lint": {
|
|
767
806
|
"cache": true,
|
|
768
807
|
"configurations": {
|
|
@@ -773,6 +812,9 @@ exports[`infra generator > should handle custom project names correctly > custom
|
|
|
773
812
|
"command": "node -e """,
|
|
774
813
|
},
|
|
775
814
|
},
|
|
815
|
+
"dependsOn": [
|
|
816
|
+
"format",
|
|
817
|
+
],
|
|
776
818
|
"executor": "nx:run-commands",
|
|
777
819
|
"inputs": [
|
|
778
820
|
"biome",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/ts-client/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { generateFiles, logger, type Tree } from '@nx/devkit';\nimport * as path from 'path';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { esmVars } from '../../utils/module-format';\nimport { buildOpenApiCodeGenData } from '../utils/codegen-data';\nimport type { CodeGenData } from '../utils/codegen-data/types';\nimport { parseOpenApiSpec } from '../utils/parse';\nimport type { Spec } from '../utils/types';\nimport type { OpenApiTsClientGeneratorSchema } from './schema';\n\n/**\n * Generates typescript client from an openapi spec\n */\nexport const openApiTsClientGenerator = async (\n tree: Tree,\n options: OpenApiTsClientGeneratorSchema,\n) => {\n const data = await buildOpenApiCodeGenerationData(\n tree,\n options.openApiSpecPath,\n );\n\n generateOpenApiTsClient(tree, data, options.outputPath);\n\n await formatFilesInSubtree(tree);\n};\n\n/**\n * Build a data structure which can be used to generate code from OpenAPI\n */\nexport const buildOpenApiCodeGenerationData = async (\n tree: Tree,\n specPath: string,\n) => {\n const spec = await parseOpenApiSpec(tree, specPath);\n warnForUnsupportedFeatures(spec);\n return buildOpenApiCodeGenData(spec);\n};\n\n/**\n * Warn for spec features the generated client does not implement, so their\n * omission is never silent.\n */\nconst warnForUnsupportedFeatures = (spec: Spec) => {\n if (Object.keys((spec as { webhooks?: object }).webhooks ?? {}).length > 0) {\n logger.warn(\n 'OpenAPI webhooks are not supported and no client code is generated for them',\n );\n }\n for (const [p, pathItem] of Object.entries(spec.paths ?? {})) {\n for (const [method, op] of Object.entries(pathItem ?? {})) {\n if (typeof op !== 'object' || op === null) continue;\n const operation = op as {\n callbacks?: object;\n servers?: unknown[];\n };\n if (Object.keys(operation.callbacks ?? {}).length > 0) {\n logger.warn(\n `Operation ${method.toUpperCase()} ${p} declares callbacks, which are not supported and are ignored`,\n );\n }\n if ((operation.servers ?? []).length > 0) {\n logger.warn(\n `Operation ${method.toUpperCase()} ${p} declares operation-level servers, which are ignored — the client always uses its configured url`,\n );\n }\n }\n }\n};\n\n/**\n * Generate an OpenAPI typescript client in the target directory\n */\nexport const generateOpenApiTsClient = (\n tree: Tree,\n data: CodeGenData,\n outputPath: string,\n) => {\n generateFiles(
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/ts-client/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { generateFiles, logger, type Tree } from '@nx/devkit';\nimport * as path from 'path';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { esmVars } from '../../utils/module-format';\nimport { buildOpenApiCodeGenData } from '../utils/codegen-data';\nimport type { CodeGenData } from '../utils/codegen-data/types';\nimport { parseOpenApiSpec } from '../utils/parse';\nimport type { Spec } from '../utils/types';\nimport type { OpenApiTsClientGeneratorSchema } from './schema';\n\n/**\n * Generates typescript client from an openapi spec\n */\nexport const openApiTsClientGenerator = async (\n tree: Tree,\n options: OpenApiTsClientGeneratorSchema,\n) => {\n const data = await buildOpenApiCodeGenerationData(\n tree,\n options.openApiSpecPath,\n );\n\n generateOpenApiTsClient(tree, data, options.outputPath);\n\n await formatFilesInSubtree(tree);\n};\n\n/**\n * Build a data structure which can be used to generate code from OpenAPI\n */\nexport const buildOpenApiCodeGenerationData = async (\n tree: Tree,\n specPath: string,\n) => {\n const spec = await parseOpenApiSpec(tree, specPath);\n warnForUnsupportedFeatures(spec);\n return buildOpenApiCodeGenData(spec);\n};\n\n/**\n * Warn for spec features the generated client does not implement, so their\n * omission is never silent.\n */\nconst warnForUnsupportedFeatures = (spec: Spec) => {\n if (Object.keys((spec as { webhooks?: object }).webhooks ?? {}).length > 0) {\n logger.warn(\n 'OpenAPI webhooks are not supported and no client code is generated for them',\n );\n }\n for (const [p, pathItem] of Object.entries(spec.paths ?? {})) {\n for (const [method, op] of Object.entries(pathItem ?? {})) {\n if (typeof op !== 'object' || op === null) continue;\n const operation = op as {\n callbacks?: object;\n servers?: unknown[];\n };\n if (Object.keys(operation.callbacks ?? {}).length > 0) {\n logger.warn(\n `Operation ${method.toUpperCase()} ${p} declares callbacks, which are not supported and are ignored`,\n );\n }\n if ((operation.servers ?? []).length > 0) {\n logger.warn(\n `Operation ${method.toUpperCase()} ${p} declares operation-level servers, which are ignored — the client always uses its configured url`,\n );\n }\n }\n }\n};\n\n/**\n * Generate an OpenAPI typescript client in the target directory\n */\nexport const generateOpenApiTsClient = (\n tree: Tree,\n data: CodeGenData,\n outputPath: string,\n) => {\n generateFiles(tree, path.join(import.meta.dirname, 'files'), outputPath, {\n ...data,\n ...esmVars(tree),\n });\n};\n\nexport default openApiTsClientGenerator;\n"],"names":["generateFiles","logger","path","formatFilesInSubtree","esmVars","buildOpenApiCodeGenData","parseOpenApiSpec","openApiTsClientGenerator","tree","options","data","buildOpenApiCodeGenerationData","openApiSpecPath","generateOpenApiTsClient","outputPath","specPath","spec","warnForUnsupportedFeatures","Object","keys","webhooks","length","warn","p","pathItem","entries","paths","method","op","operation","callbacks","toUpperCase","servers","join","dirname"],"mappings":"AAAA;;;CAGC,GACD,SAASA,aAAa,EAAEC,MAAM,QAAmB,aAAa;AAC9D,YAAYC,UAAU,OAAO;AAC7B,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,OAAO,QAAQ,+BAA4B;AACpD,SAASC,uBAAuB,QAAQ,2BAAwB;AAEhE,SAASC,gBAAgB,QAAQ,oBAAiB;AAIlD;;CAEC,GACD,OAAO,MAAMC,2BAA2B,OACtCC,MACAC;IAEA,MAAMC,OAAO,MAAMC,+BACjBH,MACAC,QAAQG,eAAe;IAGzBC,wBAAwBL,MAAME,MAAMD,QAAQK,UAAU;IAEtD,MAAMX,qBAAqBK;AAC7B,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMG,iCAAiC,OAC5CH,MACAO;IAEA,MAAMC,OAAO,MAAMV,iBAAiBE,MAAMO;IAC1CE,2BAA2BD;IAC3B,OAAOX,wBAAwBW;AACjC,EAAE;AAEF;;;CAGC,GACD,MAAMC,6BAA6B,CAACD;IAClC,IAAIE,OAAOC,IAAI,CAAC,AAACH,KAA+BI,QAAQ,IAAI,CAAC,GAAGC,MAAM,GAAG,GAAG;QAC1EpB,OAAOqB,IAAI,CACT;IAEJ;IACA,KAAK,MAAM,CAACC,GAAGC,SAAS,IAAIN,OAAOO,OAAO,CAACT,KAAKU,KAAK,IAAI,CAAC,GAAI;QAC5D,KAAK,MAAM,CAACC,QAAQC,GAAG,IAAIV,OAAOO,OAAO,CAACD,YAAY,CAAC,GAAI;YACzD,IAAI,OAAOI,OAAO,YAAYA,OAAO,MAAM;YAC3C,MAAMC,YAAYD;YAIlB,IAAIV,OAAOC,IAAI,CAACU,UAAUC,SAAS,IAAI,CAAC,GAAGT,MAAM,GAAG,GAAG;gBACrDpB,OAAOqB,IAAI,CACT,CAAC,UAAU,EAAEK,OAAOI,WAAW,GAAG,CAAC,EAAER,EAAE,4DAA4D,CAAC;YAExG;YACA,IAAI,AAACM,CAAAA,UAAUG,OAAO,IAAI,EAAE,AAAD,EAAGX,MAAM,GAAG,GAAG;gBACxCpB,OAAOqB,IAAI,CACT,CAAC,UAAU,EAAEK,OAAOI,WAAW,GAAG,CAAC,EAAER,EAAE,gGAAgG,CAAC;YAE5I;QACF;IACF;AACF;AAEA;;CAEC,GACD,OAAO,MAAMV,0BAA0B,CACrCL,MACAE,MACAI;IAEAd,cAAcQ,MAAMN,KAAK+B,IAAI,CAAC,YAAYC,OAAO,EAAE,UAAUpB,YAAY;QACvE,GAAGJ,IAAI;QACP,GAAGN,QAAQI,KAAK;IAClB;AACF,EAAE;AAEF,eAAeD,yBAAyB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/ts-hooks/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { generateFiles, type Tree } from '@nx/devkit';\nimport path from 'path';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { esmVars } from '../../utils/module-format';\nimport {\n buildOpenApiCodeGenerationData,\n generateOpenApiTsClient,\n} from '../ts-client/generator';\nimport type { CodeGenData } from '../utils/codegen-data/types';\nimport type { OpenApiTsHooksGeneratorSchema } from './schema';\n\n/**\n * Generates typescript hooks from an openapi spec\n */\nexport const openApiTsHooksGenerator = async (\n tree: Tree,\n options: OpenApiTsHooksGeneratorSchema,\n) => {\n const data = await buildOpenApiCodeGenerationData(\n tree,\n options.openApiSpecPath,\n );\n\n generateOpenApiTsClient(tree, data, options.outputPath);\n generateOpenApiTsHooks(tree, data, options.outputPath);\n\n await formatFilesInSubtree(tree);\n};\n\n/**\n * Generate OpenAPI typescript hooks in the target directory\n */\nexport const generateOpenApiTsHooks = (\n tree: Tree,\n data: CodeGenData,\n outputPath: string,\n) => {\n generateFiles(
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/ts-hooks/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { generateFiles, type Tree } from '@nx/devkit';\nimport path from 'path';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { esmVars } from '../../utils/module-format';\nimport {\n buildOpenApiCodeGenerationData,\n generateOpenApiTsClient,\n} from '../ts-client/generator';\nimport type { CodeGenData } from '../utils/codegen-data/types';\nimport type { OpenApiTsHooksGeneratorSchema } from './schema';\n\n/**\n * Generates typescript hooks from an openapi spec\n */\nexport const openApiTsHooksGenerator = async (\n tree: Tree,\n options: OpenApiTsHooksGeneratorSchema,\n) => {\n const data = await buildOpenApiCodeGenerationData(\n tree,\n options.openApiSpecPath,\n );\n\n generateOpenApiTsClient(tree, data, options.outputPath);\n generateOpenApiTsHooks(tree, data, options.outputPath);\n\n await formatFilesInSubtree(tree);\n};\n\n/**\n * Generate OpenAPI typescript hooks in the target directory\n */\nexport const generateOpenApiTsHooks = (\n tree: Tree,\n data: CodeGenData,\n outputPath: string,\n) => {\n generateFiles(tree, path.join(import.meta.dirname, 'files'), outputPath, {\n ...data,\n ...esmVars(tree),\n });\n};\n\nexport default openApiTsHooksGenerator;\n"],"names":["generateFiles","path","formatFilesInSubtree","esmVars","buildOpenApiCodeGenerationData","generateOpenApiTsClient","openApiTsHooksGenerator","tree","options","data","openApiSpecPath","outputPath","generateOpenApiTsHooks","join","dirname"],"mappings":"AAAA;;;CAGC,GACD,SAASA,aAAa,QAAmB,aAAa;AACtD,OAAOC,UAAU,OAAO;AACxB,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,OAAO,QAAQ,+BAA4B;AACpD,SACEC,8BAA8B,EAC9BC,uBAAuB,QAClB,4BAAyB;AAIhC;;CAEC,GACD,OAAO,MAAMC,0BAA0B,OACrCC,MACAC;IAEA,MAAMC,OAAO,MAAML,+BACjBG,MACAC,QAAQE,eAAe;IAGzBL,wBAAwBE,MAAME,MAAMD,QAAQG,UAAU;IACtDC,uBAAuBL,MAAME,MAAMD,QAAQG,UAAU;IAErD,MAAMT,qBAAqBK;AAC7B,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMK,yBAAyB,CACpCL,MACAE,MACAE;IAEAX,cAAcO,MAAMN,KAAKY,IAAI,CAAC,YAAYC,OAAO,EAAE,UAAUH,YAAY;QACvE,GAAGF,IAAI;QACP,GAAGN,QAAQI,KAAK;IAClB;AACF,EAAE;AAEF,eAAeD,wBAAwB"}
|
|
@@ -289,7 +289,10 @@ exports[`preset generator > should run successfully > biome.json 1`] = `
|
|
|
289
289
|
"!**/node_modules",
|
|
290
290
|
"!**/.nx",
|
|
291
291
|
"!**/.venv",
|
|
292
|
-
"!**/*.css"
|
|
292
|
+
"!**/*.css",
|
|
293
|
+
"!**/*.gen.*",
|
|
294
|
+
"!**/generated/**",
|
|
295
|
+
"!**/tsconfig*.json"
|
|
293
296
|
]
|
|
294
297
|
}
|
|
295
298
|
}
|
|
@@ -1491,10 +1491,27 @@ exports[`tsSmithyApiGenerator > should generate smithy ts api with default optio
|
|
|
1491
1491
|
"cwd": "{projectRoot}"
|
|
1492
1492
|
}
|
|
1493
1493
|
},
|
|
1494
|
+
"format": {
|
|
1495
|
+
"executor": "nx:run-commands",
|
|
1496
|
+
"cache": true,
|
|
1497
|
+
"inputs": ["biome"],
|
|
1498
|
+
"options": {
|
|
1499
|
+
"command": "biome format {projectRoot}"
|
|
1500
|
+
},
|
|
1501
|
+
"configurations": {
|
|
1502
|
+
"fix": {
|
|
1503
|
+
"command": "biome format --write {projectRoot}"
|
|
1504
|
+
},
|
|
1505
|
+
"skip-lint": {
|
|
1506
|
+
"command": "node -e \\"\\""
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
},
|
|
1494
1510
|
"lint": {
|
|
1495
1511
|
"executor": "nx:run-commands",
|
|
1496
1512
|
"cache": true,
|
|
1497
1513
|
"inputs": ["biome"],
|
|
1514
|
+
"dependsOn": ["format"],
|
|
1498
1515
|
"options": {
|
|
1499
1516
|
"command": "biome lint {projectRoot}"
|
|
1500
1517
|
},
|
|
@@ -95,10 +95,27 @@ exports[`ts lib generator > should generate library with custom directory > cust
|
|
|
95
95
|
"cwd": "{projectRoot}"
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
|
+
"format": {
|
|
99
|
+
"executor": "nx:run-commands",
|
|
100
|
+
"cache": true,
|
|
101
|
+
"inputs": ["biome"],
|
|
102
|
+
"options": {
|
|
103
|
+
"command": "biome format {projectRoot}"
|
|
104
|
+
},
|
|
105
|
+
"configurations": {
|
|
106
|
+
"fix": {
|
|
107
|
+
"command": "biome format --write {projectRoot}"
|
|
108
|
+
},
|
|
109
|
+
"skip-lint": {
|
|
110
|
+
"command": "node -e \\"\\""
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
98
114
|
"lint": {
|
|
99
115
|
"executor": "nx:run-commands",
|
|
100
116
|
"cache": true,
|
|
101
117
|
"inputs": ["biome"],
|
|
118
|
+
"dependsOn": ["format"],
|
|
102
119
|
"options": {
|
|
103
120
|
"command": "biome lint {projectRoot}"
|
|
104
121
|
},
|
|
@@ -163,10 +180,27 @@ exports[`ts lib generator > should generate library with default options > proje
|
|
|
163
180
|
"cwd": "{projectRoot}"
|
|
164
181
|
}
|
|
165
182
|
},
|
|
183
|
+
"format": {
|
|
184
|
+
"executor": "nx:run-commands",
|
|
185
|
+
"cache": true,
|
|
186
|
+
"inputs": ["biome"],
|
|
187
|
+
"options": {
|
|
188
|
+
"command": "biome format {projectRoot}"
|
|
189
|
+
},
|
|
190
|
+
"configurations": {
|
|
191
|
+
"fix": {
|
|
192
|
+
"command": "biome format --write {projectRoot}"
|
|
193
|
+
},
|
|
194
|
+
"skip-lint": {
|
|
195
|
+
"command": "node -e \\"\\""
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
166
199
|
"lint": {
|
|
167
200
|
"executor": "nx:run-commands",
|
|
168
201
|
"cache": true,
|
|
169
202
|
"inputs": ["biome"],
|
|
203
|
+
"dependsOn": ["format"],
|
|
170
204
|
"options": {
|
|
171
205
|
"command": "biome lint {projectRoot}"
|
|
172
206
|
},
|
|
@@ -229,10 +263,27 @@ exports[`ts lib generator > should generate library with subdirectory > subdir-p
|
|
|
229
263
|
"cwd": "{projectRoot}"
|
|
230
264
|
}
|
|
231
265
|
},
|
|
266
|
+
"format": {
|
|
267
|
+
"executor": "nx:run-commands",
|
|
268
|
+
"cache": true,
|
|
269
|
+
"inputs": ["biome"],
|
|
270
|
+
"options": {
|
|
271
|
+
"command": "biome format {projectRoot}"
|
|
272
|
+
},
|
|
273
|
+
"configurations": {
|
|
274
|
+
"fix": {
|
|
275
|
+
"command": "biome format --write {projectRoot}"
|
|
276
|
+
},
|
|
277
|
+
"skip-lint": {
|
|
278
|
+
"command": "node -e \\"\\""
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
},
|
|
232
282
|
"lint": {
|
|
233
283
|
"executor": "nx:run-commands",
|
|
234
284
|
"cache": true,
|
|
235
285
|
"inputs": ["biome"],
|
|
286
|
+
"dependsOn": ["format"],
|
|
236
287
|
"options": {
|
|
237
288
|
"command": "biome lint {projectRoot}"
|
|
238
289
|
},
|
package/src/ts/lib/biome.js
CHANGED
|
@@ -6,9 +6,10 @@ import { readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
|
6
6
|
import { sortObjectKeys } from "../../utils/object.js";
|
|
7
7
|
export const configureBiomeLint = async (tree, options)=>{
|
|
8
8
|
const projectJson = readProjectConfigurationUnqualified(tree, options.fullyQualifiedName);
|
|
9
|
+
const biomeConfigured = tree.exists('biome.json');
|
|
9
10
|
// When there's no root Biome configuration (eg the user removed it), make the
|
|
10
11
|
// lint target a no-op rather than failing on a missing config.
|
|
11
|
-
const lintTarget =
|
|
12
|
+
const lintTarget = biomeConfigured ? {
|
|
12
13
|
executor: 'nx:run-commands',
|
|
13
14
|
cache: true,
|
|
14
15
|
inputs: [
|
|
@@ -25,16 +26,48 @@ export const configureBiomeLint = async (tree, options)=>{
|
|
|
25
26
|
// Cross-platform no-op (`true` is not available on Windows cmd).
|
|
26
27
|
command: 'node -e ""'
|
|
27
28
|
}
|
|
29
|
+
},
|
|
30
|
+
// Format before linting so any fixable formatting issues (eg line too
|
|
31
|
+
// long) are resolved first, mirroring the Python project generator.
|
|
32
|
+
dependsOn: [
|
|
33
|
+
'format'
|
|
34
|
+
]
|
|
35
|
+
} : {
|
|
36
|
+
executor: 'nx:noop'
|
|
37
|
+
};
|
|
38
|
+
// The base format target checks formatting (failing when files aren't
|
|
39
|
+
// formatted); the `fix` configuration writes the changes. `skip-lint` is a
|
|
40
|
+
// no-op so `nx lint --configuration=skip-lint` propagates cleanly through the
|
|
41
|
+
// lint -> format dependency edge.
|
|
42
|
+
const formatTarget = biomeConfigured ? {
|
|
43
|
+
executor: 'nx:run-commands',
|
|
44
|
+
cache: true,
|
|
45
|
+
inputs: [
|
|
46
|
+
'biome'
|
|
47
|
+
],
|
|
48
|
+
options: {
|
|
49
|
+
command: 'biome format {projectRoot}'
|
|
50
|
+
},
|
|
51
|
+
configurations: {
|
|
52
|
+
fix: {
|
|
53
|
+
command: 'biome format --write {projectRoot}'
|
|
54
|
+
},
|
|
55
|
+
'skip-lint': {
|
|
56
|
+
// Cross-platform no-op (`true` is not available on Windows cmd).
|
|
57
|
+
command: 'node -e ""'
|
|
58
|
+
}
|
|
28
59
|
}
|
|
29
60
|
} : {
|
|
30
61
|
executor: 'nx:noop'
|
|
31
62
|
};
|
|
32
63
|
updateProjectConfiguration(tree, options.fullyQualifiedName, {
|
|
33
64
|
...projectJson,
|
|
34
|
-
// Sort targets so the lint
|
|
35
|
-
// regardless of whether
|
|
65
|
+
// Sort targets so the lint and format targets land in deterministic
|
|
66
|
+
// positions regardless of whether they already existed (keeps re-runs
|
|
67
|
+
// stable)
|
|
36
68
|
targets: sortObjectKeys({
|
|
37
69
|
...projectJson?.targets,
|
|
70
|
+
format: formatTarget,
|
|
38
71
|
lint: lintTarget
|
|
39
72
|
})
|
|
40
73
|
});
|
package/src/ts/lib/biome.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/biome.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n readNxJson,\n type Tree,\n updateNxJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { readProjectConfigurationUnqualified } from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport type { ConfigureProjectOptions } from './types';\n\nexport const configureBiomeLint = async (\n tree: Tree,\n options: ConfigureProjectOptions,\n) => {\n const projectJson = readProjectConfigurationUnqualified(\n tree,\n options.fullyQualifiedName,\n );\n\n // When there's no root Biome configuration (eg the user removed it), make the\n // lint target a no-op rather than failing on a missing config.\n const lintTarget =
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/biome.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n readNxJson,\n type Tree,\n updateNxJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { readProjectConfigurationUnqualified } from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport type { ConfigureProjectOptions } from './types';\n\nexport const configureBiomeLint = async (\n tree: Tree,\n options: ConfigureProjectOptions,\n) => {\n const projectJson = readProjectConfigurationUnqualified(\n tree,\n options.fullyQualifiedName,\n );\n\n const biomeConfigured = tree.exists('biome.json');\n\n // When there's no root Biome configuration (eg the user removed it), make the\n // lint target a no-op rather than failing on a missing config.\n const lintTarget = biomeConfigured\n ? {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['biome'],\n options: {\n command: 'biome lint {projectRoot}',\n },\n configurations: {\n fix: {\n command: 'biome check --write {projectRoot}',\n },\n 'skip-lint': {\n // Cross-platform no-op (`true` is not available on Windows cmd).\n command: 'node -e \"\"',\n },\n },\n // Format before linting so any fixable formatting issues (eg line too\n // long) are resolved first, mirroring the Python project generator.\n dependsOn: ['format'],\n }\n : { executor: 'nx:noop' };\n\n // The base format target checks formatting (failing when files aren't\n // formatted); the `fix` configuration writes the changes. `skip-lint` is a\n // no-op so `nx lint --configuration=skip-lint` propagates cleanly through the\n // lint -> format dependency edge.\n const formatTarget = biomeConfigured\n ? {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['biome'],\n options: {\n command: 'biome format {projectRoot}',\n },\n configurations: {\n fix: {\n command: 'biome format --write {projectRoot}',\n },\n 'skip-lint': {\n // Cross-platform no-op (`true` is not available on Windows cmd).\n command: 'node -e \"\"',\n },\n },\n }\n : { executor: 'nx:noop' };\n\n updateProjectConfiguration(tree, options.fullyQualifiedName, {\n ...projectJson,\n // Sort targets so the lint and format targets land in deterministic\n // positions regardless of whether they already existed (keeps re-runs\n // stable)\n targets: sortObjectKeys({\n ...projectJson?.targets,\n format: formatTarget,\n lint: lintTarget,\n }),\n });\n\n // Register the `biome` named input so lint targets are cache-invalidated when\n // the root biome.json changes.\n const nxJson = readNxJson(tree);\n if (\n !nxJson.namedInputs?.biome ||\n !nxJson.namedInputs.biome.includes('{workspaceRoot}/biome.json')\n ) {\n updateNxJson(tree, {\n ...nxJson,\n namedInputs: {\n ...nxJson.namedInputs,\n biome: ['default', '{workspaceRoot}/biome.json'],\n },\n });\n }\n};\n"],"names":["readNxJson","updateNxJson","updateProjectConfiguration","readProjectConfigurationUnqualified","sortObjectKeys","configureBiomeLint","tree","options","projectJson","fullyQualifiedName","biomeConfigured","exists","lintTarget","executor","cache","inputs","command","configurations","fix","dependsOn","formatTarget","targets","format","lint","nxJson","namedInputs","biome","includes"],"mappings":"AAAA;;;CAGC,GACD,SACEA,UAAU,EAEVC,YAAY,EACZC,0BAA0B,QACrB,aAAa;AACpB,SAASC,mCAAmC,QAAQ,oBAAiB;AACrE,SAASC,cAAc,QAAQ,wBAAqB;AAGpD,OAAO,MAAMC,qBAAqB,OAChCC,MACAC;IAEA,MAAMC,cAAcL,oCAClBG,MACAC,QAAQE,kBAAkB;IAG5B,MAAMC,kBAAkBJ,KAAKK,MAAM,CAAC;IAEpC,8EAA8E;IAC9E,+DAA+D;IAC/D,MAAMC,aAAaF,kBACf;QACEG,UAAU;QACVC,OAAO;QACPC,QAAQ;YAAC;SAAQ;QACjBR,SAAS;YACPS,SAAS;QACX;QACAC,gBAAgB;YACdC,KAAK;gBACHF,SAAS;YACX;YACA,aAAa;gBACX,iEAAiE;gBACjEA,SAAS;YACX;QACF;QACA,sEAAsE;QACtE,oEAAoE;QACpEG,WAAW;YAAC;SAAS;IACvB,IACA;QAAEN,UAAU;IAAU;IAE1B,sEAAsE;IACtE,2EAA2E;IAC3E,8EAA8E;IAC9E,kCAAkC;IAClC,MAAMO,eAAeV,kBACjB;QACEG,UAAU;QACVC,OAAO;QACPC,QAAQ;YAAC;SAAQ;QACjBR,SAAS;YACPS,SAAS;QACX;QACAC,gBAAgB;YACdC,KAAK;gBACHF,SAAS;YACX;YACA,aAAa;gBACX,iEAAiE;gBACjEA,SAAS;YACX;QACF;IACF,IACA;QAAEH,UAAU;IAAU;IAE1BX,2BAA2BI,MAAMC,QAAQE,kBAAkB,EAAE;QAC3D,GAAGD,WAAW;QACd,oEAAoE;QACpE,sEAAsE;QACtE,UAAU;QACVa,SAASjB,eAAe;YACtB,GAAGI,aAAaa,OAAO;YACvBC,QAAQF;YACRG,MAAMX;QACR;IACF;IAEA,8EAA8E;IAC9E,+BAA+B;IAC/B,MAAMY,SAASxB,WAAWM;IAC1B,IACE,CAACkB,OAAOC,WAAW,EAAEC,SACrB,CAACF,OAAOC,WAAW,CAACC,KAAK,CAACC,QAAQ,CAAC,+BACnC;QACA1B,aAAaK,MAAM;YACjB,GAAGkB,MAAM;YACTC,aAAa;gBACX,GAAGD,OAAOC,WAAW;gBACrBC,OAAO;oBAAC;oBAAW;iBAA6B;YAClD;QACF;IACF;AACF,EAAE"}
|