@aws/nx-plugin 1.0.0-rc.37 → 1.0.0-rc.38

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 (35) hide show
  1. package/generators.json +7 -0
  2. package/package.json +1 -1
  3. package/src/init/generator.d.ts +18 -0
  4. package/src/init/generator.js +35 -0
  5. package/src/init/generator.js.map +1 -0
  6. package/src/init/schema.d.js +6 -0
  7. package/src/init/schema.d.js.map +1 -0
  8. package/src/init/schema.d.ts +16 -0
  9. package/src/init/schema.json +35 -0
  10. package/src/mcp-server/generator-info.js +27 -13
  11. package/src/mcp-server/generator-info.js.map +1 -1
  12. package/src/mcp-server/guide-pipeline.js +16 -1
  13. package/src/mcp-server/guide-pipeline.js.map +1 -1
  14. package/src/mcp-server/server.js +2 -0
  15. package/src/mcp-server/server.js.map +1 -1
  16. package/src/mcp-server/tools/add-to-existing-project.d.ts +12 -0
  17. package/src/mcp-server/tools/add-to-existing-project.js +36 -0
  18. package/src/mcp-server/tools/add-to-existing-project.js.map +1 -0
  19. package/src/mcp-server/tools/general-guidance.d.ts +1 -1
  20. package/src/mcp-server/tools/general-guidance.js +1 -0
  21. package/src/mcp-server/tools/general-guidance.js.map +1 -1
  22. package/src/preset/__snapshots__/generator.spec.ts.snap +3 -0
  23. package/src/preset/generator.js +19 -129
  24. package/src/preset/generator.js.map +1 -1
  25. package/src/ts/lib/ts-project-utils.js +0 -7
  26. package/src/ts/lib/ts-project-utils.js.map +1 -1
  27. package/src/utils/base-tsconfig.d.ts +30 -0
  28. package/src/utils/base-tsconfig.js +32 -0
  29. package/src/utils/base-tsconfig.js.map +1 -0
  30. package/src/utils/commands.d.ts +9 -2
  31. package/src/utils/commands.js +19 -9
  32. package/src/utils/commands.js.map +1 -1
  33. package/src/utils/init.d.ts +53 -0
  34. package/src/utils/init.js +251 -0
  35. package/src/utils/init.js.map +1 -0
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */ import { addDependenciesToPackageJson, detectPackageManager, generateFiles, joinPathFragments, OverwriteStrategy, readNxJson, updateJson, updateNxJson } from "@nx/devkit";
5
+ import { initGenerator } from "@nx/js";
6
+ import yaml from "js-yaml";
7
+ import { readModulePackageJson } from "nx/src/utils/package-json";
8
+ import GeneratorsJson from "../../generators.json" with {
9
+ type: 'json'
10
+ };
11
+ import { SYNC_GENERATOR_NAME as TS_SYNC_GENERATOR_NAME } from "../ts/sync/generator.js";
12
+ import { BASE_TSCONFIG_COMPILER_OPTIONS } from "./base-tsconfig.js";
13
+ import { ensureAwsNxPluginConfig, updateAwsNxPluginConfig } from "./config/utils.js";
14
+ import { inferContainers } from "./containers.js";
15
+ import { DEFAULT_BIOME_CONFIG } from "./format.js";
16
+ import { configureMcpServers } from "./mcp.js";
17
+ import { getNpmScope } from "./npm-scope.js";
18
+ import { getPackageManagerDisplayCommands } from "./pkg-manager.js";
19
+ import { withVersions } from "./versions.js";
20
+ const WORKSPACES = [
21
+ 'packages/*'
22
+ ];
23
+ const NX_TYPESCRIPT_SYNC_GENERATOR = '@nx/js:typescript-sync';
24
+ // Built dependencies whose install scripts the generated workspace trusts.
25
+ // `onlyBuiltDependencies` is the pnpm 10 key (silently ignored by pnpm 11);
26
+ // pnpm 11 reads `allowBuilds` instead. Any dep NOT in this allowlist will
27
+ // have its install scripts skipped with a warning — matching pnpm 10's
28
+ // default behaviour. The user can opt-in later via `pnpm approve-builds`.
29
+ export const PNPM_BUILT_DEPENDENCIES = [
30
+ '@swc/core',
31
+ 'esbuild',
32
+ 'nx',
33
+ 'sharp'
34
+ ];
35
+ /**
36
+ * Add or repair the pnpm `allowBuilds` / `onlyBuiltDependencies` allowlist for
37
+ * the workspace's `packages` globs, without clobbering any packages the user
38
+ * has already declared.
39
+ *
40
+ * A workspace not created by the preset commonly has either no
41
+ * `pnpm-workspace.yaml`, one missing the `packages` globs, or one carrying the
42
+ * broken `set this to true or false` placeholder pnpm writes when it skips a
43
+ * build script. This makes the file self-consistent so the first generator's
44
+ * install doesn't fail with `ERR_PNPM_IGNORED_BUILDS`.
45
+ */ const setUpPnpmWorkspace = (tree)=>{
46
+ const existing = tree.exists('pnpm-workspace.yaml') ? yaml.load(tree.read('pnpm-workspace.yaml', 'utf-8') ?? '') ?? {} : {};
47
+ // Preserve any packages globs the user already has, ensuring ours are present.
48
+ const packages = Array.from(new Set([
49
+ ...existing.packages ?? [],
50
+ ...WORKSPACES
51
+ ]));
52
+ const allowBuilds = {
53
+ ...typeof existing.allowBuilds === 'object' && existing.allowBuilds ? existing.allowBuilds : {},
54
+ // Overwrite any non-boolean (e.g. the "set this to true or false"
55
+ // placeholder) with an explicit true for the deps we trust.
56
+ ...Object.fromEntries(PNPM_BUILT_DEPENDENCIES.map((dep)=>[
57
+ dep,
58
+ true
59
+ ]))
60
+ };
61
+ tree.write('pnpm-workspace.yaml', yaml.dump({
62
+ ...existing,
63
+ packages,
64
+ allowBuilds,
65
+ onlyBuiltDependencies: PNPM_BUILT_DEPENDENCIES
66
+ }, {
67
+ quotingType: "'"
68
+ }));
69
+ };
70
+ /**
71
+ * Configure the workspace's package manager for a monorepo layout.
72
+ *
73
+ * pnpm workspaces are declared in `pnpm-workspace.yaml`; every other package
74
+ * manager reads the `workspaces` field of the root `package.json`.
75
+ */ const setUpWorkspaces = (tree)=>{
76
+ if (detectPackageManager() === 'pnpm') {
77
+ setUpPnpmWorkspace(tree);
78
+ } else {
79
+ updateJson(tree, 'package.json', (json)=>({
80
+ ...json,
81
+ workspaces: Array.from(new Set([
82
+ ...json.workspaces ?? [],
83
+ ...WORKSPACES
84
+ ]))
85
+ }));
86
+ }
87
+ };
88
+ /**
89
+ * Ensure the workspace has a `tsconfig.base.json`.
90
+ *
91
+ * `@nx/js` `initGenerator` (with `addTsPlugin`) normally creates this, but it
92
+ * short-circuits when the workspace already has a root `tsconfig.json` — in
93
+ * which case no base file is written and the next project generator fails with
94
+ * `Cannot find tsconfig.base.json`. So we create a compatible one when it's
95
+ * absent. An existing base is left untouched: the user may have tuned it, and
96
+ * rewriting shared compiler options can break other projects (see the
97
+ * "add to an existing workspace" guide).
98
+ */ const ensureBaseTsConfig = (tree)=>{
99
+ if (tree.exists('tsconfig.base.json')) {
100
+ return;
101
+ }
102
+ tree.write('tsconfig.base.json', JSON.stringify({
103
+ compilerOptions: {
104
+ ...BASE_TSCONFIG_COMPILER_OPTIONS,
105
+ customConditions: [
106
+ getNpmScope(tree)
107
+ ]
108
+ }
109
+ }, null, 2));
110
+ };
111
+ /**
112
+ * Ensure the workspace has a root `tsconfig.json`.
113
+ *
114
+ * Nx's `@nx/js:typescript-sync` generator hard-fails with
115
+ * `Missing root "tsconfig.json"` when it's absent. The plugin's TypeScript
116
+ * projects reference each other via this file, so we guarantee a minimal one
117
+ * exists (sync populates its `references`).
118
+ */ const ensureRootTsConfig = (tree)=>{
119
+ if (tree.exists('tsconfig.json')) {
120
+ return;
121
+ }
122
+ tree.write('tsconfig.json', JSON.stringify({
123
+ extends: './tsconfig.base.json',
124
+ files: [],
125
+ references: []
126
+ }, null, 2));
127
+ };
128
+ /**
129
+ * Transform an Nx workspace into one ready to run `@aws/nx-plugin` generators.
130
+ *
131
+ * This is the deterministic core shared by the workspace preset and the `init`
132
+ * generator. It is safe to re-run: every step is idempotent (config merges,
133
+ * keyed nx.json / package.json entries, create-if-missing files), so running
134
+ * it against an already-initialised workspace is a no-op.
135
+ *
136
+ * It preserves the workspace's module format: the root package.json `type`
137
+ * field is owned by the preset (written from its `--module` option) and left
138
+ * untouched here. It does NOT rewrite an existing `tsconfig.base.json`'s
139
+ * compiler options, migrate a workspace's package manager, or restructure
140
+ * existing projects — those are decisions for the user (see the "add to an
141
+ * existing workspace" guide).
142
+ */ export const applyWorkspaceInit = async (tree, { iac, containers, mcp, readmeOverwriteStrategy = OverwriteStrategy.KeepExisting, overwriteScripts = false })=>{
143
+ const resolvedContainers = !containers || containers === 'infer' ? inferContainers() : containers;
144
+ // Write IaC provider and container engine to plugin config
145
+ await ensureAwsNxPluginConfig(tree);
146
+ await updateAwsNxPluginConfig(tree, {
147
+ iac: {
148
+ provider: iac
149
+ },
150
+ containers: {
151
+ engine: resolvedContainers
152
+ }
153
+ });
154
+ // Set up the TypeScript plugin, base tsconfig, formatter etc. `@nx/js`
155
+ // creates `tsconfig.base.json` when absent, but skips it when a root
156
+ // `tsconfig.json` already exists — so we ensure both explicitly below.
157
+ await initGenerator(tree, {
158
+ formatter: 'none',
159
+ addTsPlugin: true
160
+ });
161
+ ensureBaseTsConfig(tree);
162
+ ensureRootTsConfig(tree);
163
+ setUpWorkspaces(tree);
164
+ const nxJson = readNxJson(tree);
165
+ updateNxJson(tree, {
166
+ ...nxJson,
167
+ // Preserve an explicit analytics choice in an existing workspace.
168
+ analytics: nxJson.analytics ?? false,
169
+ targetDefaults: {
170
+ ...nxJson.targetDefaults,
171
+ compile: {
172
+ ...nxJson.targetDefaults?.compile,
173
+ syncGenerators: [
174
+ ...(nxJson.targetDefaults?.compile?.syncGenerators ?? []).filter((g)=>![
175
+ TS_SYNC_GENERATOR_NAME,
176
+ NX_TYPESCRIPT_SYNC_GENERATOR
177
+ ].includes(g)),
178
+ NX_TYPESCRIPT_SYNC_GENERATOR,
179
+ TS_SYNC_GENERATOR_NAME
180
+ ]
181
+ }
182
+ }
183
+ });
184
+ const CONVENIENCE_SCRIPTS = {
185
+ dev: 'nx run-many --target dev',
186
+ build: 'nx run-many --target build',
187
+ lint: 'nx run-many --target lint --configuration=fix',
188
+ test: 'nx run-many --target test --all',
189
+ 'build:skip-lint': 'nx run-many --target build --configuration=skip-lint',
190
+ 'build:all': 'nx run-many --target build --all',
191
+ 'affected:all': 'nx affected --target build'
192
+ };
193
+ updateJson(tree, 'package.json', (packageJson)=>({
194
+ ...packageJson,
195
+ // The root `type` field is owned by the preset (written explicitly from
196
+ // its `--module` option). `init` preserves an existing workspace's field
197
+ // as-is: an ESM workspace already carries `type: "module"` (that is how
198
+ // the format is inferred), and introducing a `type` into a CommonJS
199
+ // workspace that lacks one changes behaviour for frameworks that parse it
200
+ // (e.g. Next.js starts treating the app's ESM source as CJS).
201
+ scripts: overwriteScripts ? {
202
+ ...packageJson.scripts,
203
+ ...CONVENIENCE_SCRIPTS
204
+ } : {
205
+ ...CONVENIENCE_SCRIPTS,
206
+ ...packageJson.scripts
207
+ }
208
+ }));
209
+ // Pin the workspace's `nx` to the version the plugin's @nx/* packages are
210
+ // built against. A mismatched workspace nx (even a patch apart) hoists a
211
+ // second nested nx under @nx/js, and the two instances deadlock `nx sync`.
212
+ // `@nx/js` must be a root dependency for the `@nx/js:typescript-sync`
213
+ // generator registered in nx.json to resolve (npm doesn't hoist the
214
+ // plugin's own copy reliably).
215
+ const nxVersion = readModulePackageJson('@nx/js').packageJson.version;
216
+ addDependenciesToPackageJson(tree, {}, {
217
+ nx: nxVersion,
218
+ '@nx/js': nxVersion,
219
+ '@nx/workspace': nxVersion,
220
+ ...withVersions([
221
+ 'typescript',
222
+ '@biomejs/biome'
223
+ ])
224
+ });
225
+ // Write biome.json for formatting and linting
226
+ if (!tree.exists('biome.json')) {
227
+ tree.write('biome.json', JSON.stringify(DEFAULT_BIOME_CONFIG, null, 2));
228
+ }
229
+ generateFiles(tree, joinPathFragments(import.meta.dirname, '..', 'preset', 'files'), '.', {
230
+ projectName: getNpmScope(tree),
231
+ generators: Object.entries(GeneratorsJson.generators).filter(([_, v])=>!v['hidden']).map(([k, v])=>({
232
+ name: k,
233
+ description: v.description
234
+ })),
235
+ ...(()=>{
236
+ const cmds = getPackageManagerDisplayCommands();
237
+ return {
238
+ pkgMgrCmd: cmds.exec,
239
+ buildCmd: `${cmds.run} build`,
240
+ lintCmd: `${cmds.run} lint`
241
+ };
242
+ })()
243
+ }, {
244
+ overwriteStrategy: readmeOverwriteStrategy
245
+ });
246
+ if (mcp !== false) {
247
+ configureMcpServers(tree);
248
+ }
249
+ };
250
+
251
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/init.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n detectPackageManager,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readNxJson,\n type Tree,\n updateJson,\n updateNxJson,\n} from '@nx/devkit';\nimport { initGenerator } from '@nx/js';\nimport { readFileSync } from 'fs';\nimport yaml from 'js-yaml';\nimport { readModulePackageJson } from 'nx/src/utils/package-json';\nimport GeneratorsJson from '../../generators.json' with { type: 'json' };\nimport { SYNC_GENERATOR_NAME as TS_SYNC_GENERATOR_NAME } from '../ts/sync/generator';\nimport { BASE_TSCONFIG_COMPILER_OPTIONS } from './base-tsconfig';\nimport {\n ensureAwsNxPluginConfig,\n updateAwsNxPluginConfig,\n} from './config/utils';\nimport { type Containers, inferContainers } from './containers';\nimport { DEFAULT_BIOME_CONFIG } from './format';\nimport type { Iac } from './iac';\nimport { configureMcpServers } from './mcp';\nimport { getNpmScope } from './npm-scope';\nimport { getPackageManagerDisplayCommands } from './pkg-manager';\nimport { withVersions } from './versions';\n\nconst WORKSPACES = ['packages/*'];\nconst NX_TYPESCRIPT_SYNC_GENERATOR = '@nx/js:typescript-sync';\n\n// Built dependencies whose install scripts the generated workspace trusts.\n// `onlyBuiltDependencies` is the pnpm 10 key (silently ignored by pnpm 11);\n// pnpm 11 reads `allowBuilds` instead. Any dep NOT in this allowlist will\n// have its install scripts skipped with a warning — matching pnpm 10's\n// default behaviour. The user can opt-in later via `pnpm approve-builds`.\nexport const PNPM_BUILT_DEPENDENCIES = ['@swc/core', 'esbuild', 'nx', 'sharp'];\n\n/**\n * Options controlling how the workspace is initialised. These mirror the\n * preset schema so a workspace created via the preset and one initialised via\n * the `init` generator end up in the same shape.\n */\nexport interface ApplyWorkspaceInitOptions {\n /** The IaC provider to record in the plugin config. */\n readonly iac: Iac;\n /**\n * The container engine to record. `undefined`/`'infer'` picks docker when\n * installed, else finch.\n */\n readonly containers?: Containers | 'infer';\n /** Whether to configure MCP servers for coding agents. Defaults to true. */\n readonly mcp?: boolean;\n /**\n * How to treat the generated workspace README. The preset owns the README of\n * a greenfield workspace (`Overwrite`); the `init` generator must not clobber\n * an existing workspace's README (`KeepExisting`, the default).\n */\n readonly readmeOverwriteStrategy?: OverwriteStrategy;\n /**\n * Whether to overwrite root package.json scripts that already exist. The\n * preset owns a greenfield workspace's scripts (`true`); the `init`\n * generator must not clobber an existing workspace's scripts (`false`,\n * the default) — it only adds the convenience scripts that are absent.\n */\n readonly overwriteScripts?: boolean;\n}\n\n/**\n * Add or repair the pnpm `allowBuilds` / `onlyBuiltDependencies` allowlist for\n * the workspace's `packages` globs, without clobbering any packages the user\n * has already declared.\n *\n * A workspace not created by the preset commonly has either no\n * `pnpm-workspace.yaml`, one missing the `packages` globs, or one carrying the\n * broken `set this to true or false` placeholder pnpm writes when it skips a\n * build script. This makes the file self-consistent so the first generator's\n * install doesn't fail with `ERR_PNPM_IGNORED_BUILDS`.\n */\nconst setUpPnpmWorkspace = (tree: Tree) => {\n const existing = tree.exists('pnpm-workspace.yaml')\n ? ((yaml.load(tree.read('pnpm-workspace.yaml', 'utf-8') ?? '') as Record<\n string,\n unknown\n >) ?? {})\n : {};\n\n // Preserve any packages globs the user already has, ensuring ours are present.\n const packages = Array.from(\n new Set([...((existing.packages as string[]) ?? []), ...WORKSPACES]),\n );\n\n const allowBuilds = {\n ...(typeof existing.allowBuilds === 'object' && existing.allowBuilds\n ? (existing.allowBuilds as Record<string, unknown>)\n : {}),\n // Overwrite any non-boolean (e.g. the \"set this to true or false\"\n // placeholder) with an explicit true for the deps we trust.\n ...Object.fromEntries(PNPM_BUILT_DEPENDENCIES.map((dep) => [dep, true])),\n };\n\n tree.write(\n 'pnpm-workspace.yaml',\n yaml.dump(\n {\n ...existing,\n packages,\n allowBuilds,\n onlyBuiltDependencies: PNPM_BUILT_DEPENDENCIES,\n },\n { quotingType: \"'\" },\n ),\n );\n};\n\n/**\n * Configure the workspace's package manager for a monorepo layout.\n *\n * pnpm workspaces are declared in `pnpm-workspace.yaml`; every other package\n * manager reads the `workspaces` field of the root `package.json`.\n */\nconst setUpWorkspaces = (tree: Tree) => {\n if (detectPackageManager() === 'pnpm') {\n setUpPnpmWorkspace(tree);\n } else {\n updateJson(tree, 'package.json', (json) => ({\n ...json,\n workspaces: Array.from(\n new Set([...(json.workspaces ?? []), ...WORKSPACES]),\n ),\n }));\n }\n};\n\n/**\n * Ensure the workspace has a `tsconfig.base.json`.\n *\n * `@nx/js` `initGenerator` (with `addTsPlugin`) normally creates this, but it\n * short-circuits when the workspace already has a root `tsconfig.json` — in\n * which case no base file is written and the next project generator fails with\n * `Cannot find tsconfig.base.json`. So we create a compatible one when it's\n * absent. An existing base is left untouched: the user may have tuned it, and\n * rewriting shared compiler options can break other projects (see the\n * \"add to an existing workspace\" guide).\n */\nconst ensureBaseTsConfig = (tree: Tree) => {\n if (tree.exists('tsconfig.base.json')) {\n return;\n }\n tree.write(\n 'tsconfig.base.json',\n JSON.stringify(\n {\n compilerOptions: {\n ...BASE_TSCONFIG_COMPILER_OPTIONS,\n customConditions: [getNpmScope(tree)],\n },\n },\n null,\n 2,\n ),\n );\n};\n\n/**\n * Ensure the workspace has a root `tsconfig.json`.\n *\n * Nx's `@nx/js:typescript-sync` generator hard-fails with\n * `Missing root \"tsconfig.json\"` when it's absent. The plugin's TypeScript\n * projects reference each other via this file, so we guarantee a minimal one\n * exists (sync populates its `references`).\n */\nconst ensureRootTsConfig = (tree: Tree) => {\n if (tree.exists('tsconfig.json')) {\n return;\n }\n tree.write(\n 'tsconfig.json',\n JSON.stringify(\n {\n extends: './tsconfig.base.json',\n files: [],\n references: [],\n },\n null,\n 2,\n ),\n );\n};\n\n/**\n * Transform an Nx workspace into one ready to run `@aws/nx-plugin` generators.\n *\n * This is the deterministic core shared by the workspace preset and the `init`\n * generator. It is safe to re-run: every step is idempotent (config merges,\n * keyed nx.json / package.json entries, create-if-missing files), so running\n * it against an already-initialised workspace is a no-op.\n *\n * It preserves the workspace's module format: the root package.json `type`\n * field is owned by the preset (written from its `--module` option) and left\n * untouched here. It does NOT rewrite an existing `tsconfig.base.json`'s\n * compiler options, migrate a workspace's package manager, or restructure\n * existing projects — those are decisions for the user (see the \"add to an\n * existing workspace\" guide).\n */\nexport const applyWorkspaceInit = async (\n tree: Tree,\n {\n iac,\n containers,\n mcp,\n readmeOverwriteStrategy = OverwriteStrategy.KeepExisting,\n overwriteScripts = false,\n }: ApplyWorkspaceInitOptions,\n) => {\n const resolvedContainers =\n !containers || containers === 'infer' ? inferContainers() : containers;\n\n // Write IaC provider and container engine to plugin config\n await ensureAwsNxPluginConfig(tree);\n await updateAwsNxPluginConfig(tree, {\n iac: { provider: iac },\n containers: { engine: resolvedContainers },\n });\n\n // Set up the TypeScript plugin, base tsconfig, formatter etc. `@nx/js`\n // creates `tsconfig.base.json` when absent, but skips it when a root\n // `tsconfig.json` already exists — so we ensure both explicitly below.\n await initGenerator(tree, {\n formatter: 'none',\n addTsPlugin: true,\n });\n\n ensureBaseTsConfig(tree);\n ensureRootTsConfig(tree);\n\n setUpWorkspaces(tree);\n\n const nxJson = readNxJson(tree);\n updateNxJson(tree, {\n ...nxJson,\n // Preserve an explicit analytics choice in an existing workspace.\n analytics: (nxJson as { analytics?: boolean }).analytics ?? false,\n targetDefaults: {\n ...nxJson.targetDefaults,\n compile: {\n ...nxJson.targetDefaults?.compile,\n syncGenerators: [\n ...(nxJson.targetDefaults?.compile?.syncGenerators ?? []).filter(\n (g) =>\n ![TS_SYNC_GENERATOR_NAME, NX_TYPESCRIPT_SYNC_GENERATOR].includes(\n g,\n ),\n ),\n NX_TYPESCRIPT_SYNC_GENERATOR,\n TS_SYNC_GENERATOR_NAME,\n ],\n },\n },\n });\n\n const CONVENIENCE_SCRIPTS = {\n dev: 'nx run-many --target dev',\n build: 'nx run-many --target build',\n lint: 'nx run-many --target lint --configuration=fix',\n test: 'nx run-many --target test --all',\n 'build:skip-lint': 'nx run-many --target build --configuration=skip-lint',\n 'build:all': 'nx run-many --target build --all',\n 'affected:all': 'nx affected --target build',\n };\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n // The root `type` field is owned by the preset (written explicitly from\n // its `--module` option). `init` preserves an existing workspace's field\n // as-is: an ESM workspace already carries `type: \"module\"` (that is how\n // the format is inferred), and introducing a `type` into a CommonJS\n // workspace that lacks one changes behaviour for frameworks that parse it\n // (e.g. Next.js starts treating the app's ESM source as CJS).\n scripts: overwriteScripts\n ? { ...packageJson.scripts, ...CONVENIENCE_SCRIPTS }\n : { ...CONVENIENCE_SCRIPTS, ...packageJson.scripts },\n }));\n\n // Pin the workspace's `nx` to the version the plugin's @nx/* packages are\n // built against. A mismatched workspace nx (even a patch apart) hoists a\n // second nested nx under @nx/js, and the two instances deadlock `nx sync`.\n // `@nx/js` must be a root dependency for the `@nx/js:typescript-sync`\n // generator registered in nx.json to resolve (npm doesn't hoist the\n // plugin's own copy reliably).\n const nxVersion = readModulePackageJson('@nx/js').packageJson.version;\n addDependenciesToPackageJson(\n tree,\n {},\n {\n nx: nxVersion,\n '@nx/js': nxVersion,\n '@nx/workspace': nxVersion,\n ...withVersions(['typescript', '@biomejs/biome']),\n },\n );\n\n // Write biome.json for formatting and linting\n if (!tree.exists('biome.json')) {\n tree.write('biome.json', JSON.stringify(DEFAULT_BIOME_CONFIG, null, 2));\n }\n\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, '..', 'preset', 'files'),\n '.',\n {\n projectName: getNpmScope(tree),\n generators: Object.entries(GeneratorsJson.generators)\n .filter(([_, v]) => !v['hidden'])\n .map(([k, v]) => ({ name: k, description: v.description })),\n ...(() => {\n const cmds = getPackageManagerDisplayCommands();\n return {\n pkgMgrCmd: cmds.exec,\n buildCmd: `${cmds.run} build`,\n lintCmd: `${cmds.run} lint`,\n };\n })(),\n },\n {\n overwriteStrategy: readmeOverwriteStrategy,\n },\n );\n\n if (mcp !== false) {\n configureMcpServers(tree);\n }\n};\n"],"names":["addDependenciesToPackageJson","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readNxJson","updateJson","updateNxJson","initGenerator","yaml","readModulePackageJson","GeneratorsJson","type","SYNC_GENERATOR_NAME","TS_SYNC_GENERATOR_NAME","BASE_TSCONFIG_COMPILER_OPTIONS","ensureAwsNxPluginConfig","updateAwsNxPluginConfig","inferContainers","DEFAULT_BIOME_CONFIG","configureMcpServers","getNpmScope","getPackageManagerDisplayCommands","withVersions","WORKSPACES","NX_TYPESCRIPT_SYNC_GENERATOR","PNPM_BUILT_DEPENDENCIES","setUpPnpmWorkspace","tree","existing","exists","load","read","packages","Array","from","Set","allowBuilds","Object","fromEntries","map","dep","write","dump","onlyBuiltDependencies","quotingType","setUpWorkspaces","json","workspaces","ensureBaseTsConfig","JSON","stringify","compilerOptions","customConditions","ensureRootTsConfig","extends","files","references","applyWorkspaceInit","iac","containers","mcp","readmeOverwriteStrategy","KeepExisting","overwriteScripts","resolvedContainers","provider","engine","formatter","addTsPlugin","nxJson","analytics","targetDefaults","compile","syncGenerators","filter","g","includes","CONVENIENCE_SCRIPTS","dev","build","lint","test","packageJson","scripts","nxVersion","version","nx","dirname","projectName","generators","entries","_","v","k","name","description","cmds","pkgMgrCmd","exec","buildCmd","run","lintCmd","overwriteStrategy"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,oBAAoB,EACpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,UAAU,EAEVC,UAAU,EACVC,YAAY,QACP,aAAa;AACpB,SAASC,aAAa,QAAQ,SAAS;AAEvC,OAAOC,UAAU,UAAU;AAC3B,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,OAAOC,oBAAoB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACzE,SAASC,uBAAuBC,sBAAsB,QAA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