@aws/nx-plugin 1.0.0-rc.94 → 1.0.0-rc.95
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/migrations.json +21 -1
- package/package.json +1 -1
- package/src/migrations/latest/agent-connection-pin-strands-peers/metadata.json +3 -0
- package/src/migrations/latest/agent-connection-pin-strands-peers/migration.d.ts +18 -0
- package/src/migrations/latest/agent-connection-pin-strands-peers/migration.js +38 -0
- package/src/migrations/latest/agent-connection-pin-strands-peers/migration.js.map +1 -0
- package/src/migrations/latest/ignore-package-manager-temp-files/metadata.json +3 -0
- package/src/migrations/latest/ignore-package-manager-temp-files/migration.d.ts +12 -0
- package/src/migrations/latest/ignore-package-manager-temp-files/migration.js +25 -0
- package/src/migrations/latest/ignore-package-manager-temp-files/migration.js.map +1 -0
- package/src/migrations/latest/rolldown-config-bundle-transient/metadata.json +3 -0
- package/src/migrations/latest/rolldown-config-bundle-transient/migration.d.ts +6 -0
- package/src/migrations/latest/rolldown-config-bundle-transient/migration.js +80 -0
- package/src/migrations/latest/rolldown-config-bundle-transient/migration.js.map +1 -0
- package/src/migrations/latest/shadcn-package-imports-exports/metadata.json +3 -0
- package/src/migrations/latest/shadcn-package-imports-exports/migration.d.ts +6 -0
- package/src/migrations/latest/shadcn-package-imports-exports/migration.js +184 -0
- package/src/migrations/latest/shadcn-package-imports-exports/migration.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +5 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +4 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +4 -0
- package/src/ts/agent/gateway-connection/generator.d.ts +4 -0
- package/src/ts/agent/generator.d.ts +4 -0
- package/src/ts/agent/mcp-connection/generator.d.ts +4 -0
- package/src/ts/react-website/agui/generator.js +2 -1
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/ts/react-website/app/generator.js +2 -1
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/utils/agent-connection/agent-connection.d.ts +2 -0
- package/src/utils/agent-connection/agent-connection.js +11 -4
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/bundle/bundle.js +10 -0
- package/src/utils/bundle/bundle.js.map +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/alert.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/avatar.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/breadcrumb.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/button.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/card.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/input.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/separator.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/sheet.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/sidebar.tsx.template +8 -8
- package/src/utils/files/common/shadcn/src/components/ui/skeleton.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/spinner.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/textarea.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/tooltip.tsx.template +1 -1
- package/src/utils/files/shadcn/components.json.template +5 -5
- package/src/utils/format.d.ts +16 -0
- package/src/utils/format.js +15 -0
- package/src/utils/format.js.map +1 -1
- package/src/utils/init.js +11 -4
- package/src/utils/init.js.map +1 -1
- package/src/utils/pnpm-workspace.d.ts +5 -5
- package/src/utils/pnpm-workspace.js +5 -5
- package/src/utils/pnpm-workspace.js.map +1 -1
- package/src/utils/shared-shadcn.d.ts +9 -0
- package/src/utils/shared-shadcn.js +36 -26
- package/src/utils/shared-shadcn.js.map +1 -1
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Tree } from '@nx/devkit';
|
|
6
6
|
/**
|
|
7
|
-
* Merge `allowBuilds` (pnpm 11) / `onlyBuiltDependencies` (pnpm 10)
|
|
8
|
-
* into the generated workspace's `pnpm-workspace.yaml`. No-op for
|
|
9
|
-
* workspaces.
|
|
7
|
+
* Merge `allowBuilds` (pnpm 11 and above) / `onlyBuiltDependencies` (pnpm 10)
|
|
8
|
+
* entries into the generated workspace's `pnpm-workspace.yaml`. No-op for
|
|
9
|
+
* non-pnpm workspaces.
|
|
10
10
|
*
|
|
11
11
|
* Generators call this when they introduce a dependency whose install
|
|
12
|
-
* script pnpm would otherwise reject under
|
|
12
|
+
* script pnpm would otherwise reject under the default
|
|
13
13
|
* `strictDepBuilds=true`. Keeping the allowlist explicit — rather than
|
|
14
|
-
* globally disabling strictness — preserves the supply-chain audit pnpm
|
|
14
|
+
* globally disabling strictness — preserves the supply-chain audit pnpm
|
|
15
15
|
* intends: each build-script dep is reviewed by the generator author and
|
|
16
16
|
* entered as either `true` (run the script) or `false` (known dep we
|
|
17
17
|
* don't want to run but have seen).
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import { detectWorkspacePackageManager } from "./dependencies.js";
|
|
6
6
|
const WORKSPACE_FILE = 'pnpm-workspace.yaml';
|
|
7
7
|
/**
|
|
8
|
-
* Merge `allowBuilds` (pnpm 11) / `onlyBuiltDependencies` (pnpm 10)
|
|
9
|
-
* into the generated workspace's `pnpm-workspace.yaml`. No-op for
|
|
10
|
-
* workspaces.
|
|
8
|
+
* Merge `allowBuilds` (pnpm 11 and above) / `onlyBuiltDependencies` (pnpm 10)
|
|
9
|
+
* entries into the generated workspace's `pnpm-workspace.yaml`. No-op for
|
|
10
|
+
* non-pnpm workspaces.
|
|
11
11
|
*
|
|
12
12
|
* Generators call this when they introduce a dependency whose install
|
|
13
|
-
* script pnpm would otherwise reject under
|
|
13
|
+
* script pnpm would otherwise reject under the default
|
|
14
14
|
* `strictDepBuilds=true`. Keeping the allowlist explicit — rather than
|
|
15
|
-
* globally disabling strictness — preserves the supply-chain audit pnpm
|
|
15
|
+
* globally disabling strictness — preserves the supply-chain audit pnpm
|
|
16
16
|
* intends: each build-script dep is reviewed by the generator author and
|
|
17
17
|
* entered as either `true` (run the script) or `false` (known dep we
|
|
18
18
|
* don't want to run but have seen).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/pnpm-workspace.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Tree } from '@nx/devkit';\nimport yaml from 'js-yaml';\nimport { detectWorkspacePackageManager } from './dependencies.js';\n\nconst WORKSPACE_FILE = 'pnpm-workspace.yaml';\n\ninterface PnpmWorkspaceYaml {\n allowBuilds?: Record<string, boolean>;\n onlyBuiltDependencies?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Merge `allowBuilds` (pnpm 11) / `onlyBuiltDependencies` (pnpm 10)
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/pnpm-workspace.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Tree } from '@nx/devkit';\nimport yaml from 'js-yaml';\nimport { detectWorkspacePackageManager } from './dependencies.js';\n\nconst WORKSPACE_FILE = 'pnpm-workspace.yaml';\n\ninterface PnpmWorkspaceYaml {\n allowBuilds?: Record<string, boolean>;\n onlyBuiltDependencies?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Merge `allowBuilds` (pnpm 11 and above) / `onlyBuiltDependencies` (pnpm 10)\n * entries into the generated workspace's `pnpm-workspace.yaml`. No-op for\n * non-pnpm workspaces.\n *\n * Generators call this when they introduce a dependency whose install\n * script pnpm would otherwise reject under the default\n * `strictDepBuilds=true`. Keeping the allowlist explicit — rather than\n * globally disabling strictness — preserves the supply-chain audit pnpm\n * intends: each build-script dep is reviewed by the generator author and\n * entered as either `true` (run the script) or `false` (known dep we\n * don't want to run but have seen).\n *\n * Only `true` entries are also added to `onlyBuiltDependencies` (pnpm 10's\n * allowlist has no equivalent of the `false` decision).\n */\nexport const registerPnpmBuiltDependencies = (\n tree: Tree,\n entries: Record<string, boolean>,\n): void => {\n if (detectWorkspacePackageManager(tree) !== 'pnpm') {\n return;\n }\n if (!tree.exists(WORKSPACE_FILE)) {\n return;\n }\n\n const original = tree.read(WORKSPACE_FILE, 'utf-8') ?? '';\n const parsed = (yaml.load(original) as PnpmWorkspaceYaml | null) ?? {};\n\n const allowBuilds = { ...(parsed.allowBuilds ?? {}) };\n const onlyBuiltDependencies = new Set(parsed.onlyBuiltDependencies ?? []);\n let changed = false;\n\n for (const [pkg, decision] of Object.entries(entries)) {\n if (allowBuilds[pkg] !== decision) {\n allowBuilds[pkg] = decision;\n changed = true;\n }\n if (decision === true && !onlyBuiltDependencies.has(pkg)) {\n onlyBuiltDependencies.add(pkg);\n changed = true;\n }\n }\n\n if (!changed) {\n return;\n }\n\n parsed.allowBuilds = allowBuilds;\n parsed.onlyBuiltDependencies = [...onlyBuiltDependencies];\n\n tree.write(WORKSPACE_FILE, yaml.dump(parsed, { quotingType: \"'\" }));\n};\n"],"names":["yaml","detectWorkspacePackageManager","WORKSPACE_FILE","registerPnpmBuiltDependencies","tree","entries","exists","original","read","parsed","load","allowBuilds","onlyBuiltDependencies","Set","changed","pkg","decision","Object","has","add","write","dump","quotingType"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,UAAU,UAAU;AAC3B,SAASC,6BAA6B,QAAQ,oBAAoB;AAElE,MAAMC,iBAAiB;AAQvB;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMC,gCAAgC,CAC3CC,MACAC;IAEA,IAAIJ,8BAA8BG,UAAU,QAAQ;QAClD;IACF;IACA,IAAI,CAACA,KAAKE,MAAM,CAACJ,iBAAiB;QAChC;IACF;IAEA,MAAMK,WAAWH,KAAKI,IAAI,CAACN,gBAAgB,YAAY;IACvD,MAAMO,SAAS,AAACT,KAAKU,IAAI,CAACH,aAA0C,CAAC;IAErE,MAAMI,cAAc;QAAE,GAAIF,OAAOE,WAAW,IAAI,CAAC,CAAC;IAAE;IACpD,MAAMC,wBAAwB,IAAIC,IAAIJ,OAAOG,qBAAqB,IAAI,EAAE;IACxE,IAAIE,UAAU;IAEd,KAAK,MAAM,CAACC,KAAKC,SAAS,IAAIC,OAAOZ,OAAO,CAACA,SAAU;QACrD,IAAIM,WAAW,CAACI,IAAI,KAAKC,UAAU;YACjCL,WAAW,CAACI,IAAI,GAAGC;YACnBF,UAAU;QACZ;QACA,IAAIE,aAAa,QAAQ,CAACJ,sBAAsBM,GAAG,CAACH,MAAM;YACxDH,sBAAsBO,GAAG,CAACJ;YAC1BD,UAAU;QACZ;IACF;IAEA,IAAI,CAACA,SAAS;QACZ;IACF;IAEAL,OAAOE,WAAW,GAAGA;IACrBF,OAAOG,qBAAqB,GAAG;WAAIA;KAAsB;IAEzDR,KAAKgB,KAAK,CAAClB,gBAAgBF,KAAKqB,IAAI,CAACZ,QAAQ;QAAEa,aAAa;IAAI;AAClE,EAAE"}
|
|
@@ -28,4 +28,13 @@ export declare const SHADCN_DEPENDENCIES: readonly [{
|
|
|
28
28
|
}, {
|
|
29
29
|
readonly name: "@vitest/coverage-v8";
|
|
30
30
|
}];
|
|
31
|
+
/** The shared shadcn package's fully-qualified npm name for this workspace. */
|
|
32
|
+
export declare const getSharedShadcnFullyQualifiedName: (tree: Tree) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Declares a `workspace:*` dependency on the shared shadcn package in a
|
|
35
|
+
* consumer's own package.json, so it resolves through the shared package's
|
|
36
|
+
* `exports` map (real package resolution) rather than a tsconfig `paths`
|
|
37
|
+
* alias - see `sharedShadcnGenerator` for why.
|
|
38
|
+
*/
|
|
39
|
+
export declare const addSharedShadcnDependency: (tree: Tree, consumerDir: string) => void;
|
|
31
40
|
export declare function sharedShadcnGenerator<const D extends DependencyDeclaration>(tree: Tree, declaration: D & MustDeclare<typeof SHADCN_DEPENDENCIES, D>): Promise<void>;
|
|
@@ -6,7 +6,7 @@ import tsProjectGenerator from "../ts/lib/generator.js";
|
|
|
6
6
|
import { configureTsProject } from "../ts/lib/ts-project-utils.js";
|
|
7
7
|
import { VITEST_DEPENDENCIES } from "../ts/lib/vitest.js";
|
|
8
8
|
import { declaredNames, forDependencies } from "./declared-dependencies.js";
|
|
9
|
-
import { addDependenciesToPackageJson } from "./dependencies.js";
|
|
9
|
+
import { addDependenciesToPackageJson, getLocalDependencySpecifier } from "./dependencies.js";
|
|
10
10
|
import { formatFilesInSubtree } from "./format.js";
|
|
11
11
|
import { esmVars } from "./module-format.js";
|
|
12
12
|
import { getNpmScopePrefix } from "./npm-scope.js";
|
|
@@ -39,11 +39,19 @@ import { withVersions } from "./versions.js";
|
|
|
39
39
|
},
|
|
40
40
|
...VITEST_DEPENDENCIES
|
|
41
41
|
];
|
|
42
|
+
/** The shared shadcn package's fully-qualified npm name for this workspace. */ export const getSharedShadcnFullyQualifiedName = (tree)=>`${getNpmScopePrefix(tree)}${SHARED_SHADCN_NAME}`;
|
|
43
|
+
/**
|
|
44
|
+
* Declares a `workspace:*` dependency on the shared shadcn package in a
|
|
45
|
+
* consumer's own package.json, so it resolves through the shared package's
|
|
46
|
+
* `exports` map (real package resolution) rather than a tsconfig `paths`
|
|
47
|
+
* alias - see `sharedShadcnGenerator` for why.
|
|
48
|
+
*/ export const addSharedShadcnDependency = (tree, consumerDir)=>{
|
|
49
|
+
addDependenciesToPackageJson(tree, {
|
|
50
|
+
[getSharedShadcnFullyQualifiedName(tree)]: getLocalDependencySpecifier(tree)
|
|
51
|
+
}, {}, joinPathFragments(consumerDir, 'package.json'));
|
|
52
|
+
};
|
|
42
53
|
export async function sharedShadcnGenerator(tree, declaration) {
|
|
43
|
-
const
|
|
44
|
-
const scopeAlias = npmScopePrefix;
|
|
45
|
-
const sharedShadcnAlias = `${scopeAlias}${SHARED_SHADCN_NAME}`;
|
|
46
|
-
const fullyQualifiedName = `${npmScopePrefix}${SHARED_SHADCN_NAME}`;
|
|
54
|
+
const fullyQualifiedName = getSharedShadcnFullyQualifiedName(tree);
|
|
47
55
|
const libraryRoot = joinPathFragments(PACKAGES_DIR, SHARED_SHADCN_DIR);
|
|
48
56
|
const shadcnSrcRoot = joinPathFragments(libraryRoot, 'src');
|
|
49
57
|
if (!tree.exists(joinPathFragments(libraryRoot, 'project.json'))) {
|
|
@@ -53,15 +61,11 @@ export async function sharedShadcnGenerator(tree, declaration) {
|
|
|
53
61
|
subDirectory: SHARED_SHADCN_DIR
|
|
54
62
|
});
|
|
55
63
|
tree.delete(shadcnSrcRoot);
|
|
56
|
-
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', SHARED_SHADCN_DIR, 'src'), shadcnSrcRoot, {
|
|
57
|
-
scopeAlias,
|
|
58
|
-
...esmVars(tree)
|
|
59
|
-
}, {
|
|
64
|
+
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', SHARED_SHADCN_DIR, 'src'), shadcnSrcRoot, esmVars(tree), {
|
|
60
65
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
61
66
|
});
|
|
62
67
|
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', SHARED_SHADCN_DIR, 'readme'), libraryRoot, {
|
|
63
|
-
fullyQualifiedName
|
|
64
|
-
scopeAlias
|
|
68
|
+
fullyQualifiedName
|
|
65
69
|
}, {
|
|
66
70
|
overwriteStrategy: OverwriteStrategy.Overwrite
|
|
67
71
|
});
|
|
@@ -87,25 +91,31 @@ export async function sharedShadcnGenerator(tree, declaration) {
|
|
|
87
91
|
]))
|
|
88
92
|
}));
|
|
89
93
|
addDependenciesToPackageJson(tree, withVersions(forDependencies(declaration), declaredNames(SHADCN_DEPENDENCIES)), {}, joinPathFragments(libraryRoot, 'package.json'));
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
// shadcn 4.x's CLI resolves the `components.json` alias via `imports`/
|
|
95
|
+
// `exports` (Node's package resolution), not a tsconfig `paths` alias.
|
|
96
|
+
// `imports` covers this package's own internal component-to-component
|
|
97
|
+
// references (aliased in components.json below); `exports` covers every
|
|
98
|
+
// other consumer.
|
|
99
|
+
updateJson(tree, joinPathFragments(libraryRoot, 'package.json'), (packageJson)=>({
|
|
100
|
+
...packageJson,
|
|
101
|
+
imports: {
|
|
102
|
+
'#components/*': './src/components/*.tsx',
|
|
103
|
+
'#lib/*': './src/lib/*.ts',
|
|
104
|
+
'#hooks/*': './src/hooks/*.ts'
|
|
105
|
+
},
|
|
106
|
+
exports: {
|
|
107
|
+
'.': './src/index.ts',
|
|
108
|
+
'./styles/*': './src/styles/*',
|
|
109
|
+
'./components/*': './src/components/*.tsx',
|
|
110
|
+
'./lib/*': './src/lib/*.ts',
|
|
111
|
+
'./hooks/*': './src/hooks/*.ts'
|
|
100
112
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
103
115
|
// components.json lives in the package so `shadcn add` runs there and
|
|
104
116
|
// installs component dependencies into the package's own manifest.
|
|
105
117
|
if (!tree.exists(joinPathFragments(libraryRoot, 'components.json'))) {
|
|
106
|
-
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'shadcn'), libraryRoot, {
|
|
107
|
-
sharedShadcnAlias
|
|
108
|
-
}, {
|
|
118
|
+
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'shadcn'), libraryRoot, {}, {
|
|
109
119
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
110
120
|
});
|
|
111
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/shared-shadcn.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport tsProjectGenerator from '../ts/lib/generator.js';\nimport { configureTsProject } from '../ts/lib/ts-project-utils.js';\nimport { VITEST_DEPENDENCIES } from '../ts/lib/vitest.js';\nimport {\n type DependencyDeclaration,\n declaredNames,\n forDependencies,\n type MustDeclare,\n} from './declared-dependencies.js';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/shared-shadcn.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport tsProjectGenerator from '../ts/lib/generator.js';\nimport { configureTsProject } from '../ts/lib/ts-project-utils.js';\nimport { VITEST_DEPENDENCIES } from '../ts/lib/vitest.js';\nimport {\n type DependencyDeclaration,\n declaredNames,\n forDependencies,\n type MustDeclare,\n} from './declared-dependencies.js';\nimport {\n addDependenciesToPackageJson,\n getLocalDependencySpecifier,\n} from './dependencies.js';\nimport { formatFilesInSubtree } from './format.js';\nimport { esmVars } from './module-format.js';\nimport { getNpmScopePrefix } from './npm-scope.js';\nimport {\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n SHARED_SHADCN_NAME,\n} from './shared-constructs-constants.js';\nimport { type ITsDepVersion, withVersions } from './versions.js';\n\n/** Dependencies a caller must declare to use the shared shadcn project. */\nexport const SHADCN_DEPENDENCIES = [\n { name: 'react' },\n { name: 'react-dom' },\n { name: 'class-variance-authority' },\n { name: 'clsx' },\n { name: 'tailwind-merge' },\n { name: 'lucide-react' },\n { name: 'tw-animate-css' },\n { name: 'radix-ui' },\n ...VITEST_DEPENDENCIES,\n] as const satisfies readonly { name: ITsDepVersion }[];\n\n/** The shared shadcn package's fully-qualified npm name for this workspace. */\nexport const getSharedShadcnFullyQualifiedName = (tree: Tree): string =>\n `${getNpmScopePrefix(tree)}${SHARED_SHADCN_NAME}`;\n\n/**\n * Declares a `workspace:*` dependency on the shared shadcn package in a\n * consumer's own package.json, so it resolves through the shared package's\n * `exports` map (real package resolution) rather than a tsconfig `paths`\n * alias - see `sharedShadcnGenerator` for why.\n */\nexport const addSharedShadcnDependency = (\n tree: Tree,\n consumerDir: string,\n): void => {\n addDependenciesToPackageJson(\n tree,\n {\n [getSharedShadcnFullyQualifiedName(tree)]:\n getLocalDependencySpecifier(tree),\n },\n {},\n joinPathFragments(consumerDir, 'package.json'),\n );\n};\n\nexport async function sharedShadcnGenerator<\n const D extends DependencyDeclaration,\n>(tree: Tree, declaration: D & MustDeclare<typeof SHADCN_DEPENDENCIES, D>) {\n const fullyQualifiedName = getSharedShadcnFullyQualifiedName(tree);\n const libraryRoot = joinPathFragments(PACKAGES_DIR, SHARED_SHADCN_DIR);\n const shadcnSrcRoot = joinPathFragments(libraryRoot, 'src');\n\n if (!tree.exists(joinPathFragments(libraryRoot, 'project.json'))) {\n await tsProjectGenerator(tree, {\n name: SHARED_SHADCN_NAME,\n directory: PACKAGES_DIR,\n subDirectory: SHARED_SHADCN_DIR,\n });\n\n tree.delete(shadcnSrcRoot);\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', SHARED_SHADCN_DIR, 'src'),\n shadcnSrcRoot,\n esmVars(tree),\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n SHARED_SHADCN_DIR,\n 'readme',\n ),\n libraryRoot,\n {\n fullyQualifiedName,\n },\n {\n overwriteStrategy: OverwriteStrategy.Overwrite,\n },\n );\n\n await configureTsProject(\n tree,\n {\n dir: libraryRoot,\n fullyQualifiedName,\n },\n forDependencies<typeof SHADCN_DEPENDENCIES>(declaration),\n );\n\n updateJson(\n tree,\n joinPathFragments(libraryRoot, 'tsconfig.lib.json'),\n (json) => ({\n ...json,\n compilerOptions: {\n ...json.compilerOptions,\n jsx: 'react-jsx',\n module: 'preserve',\n moduleResolution: 'bundler',\n lib: Array.from(\n new Set([...(json.compilerOptions?.lib ?? []), 'DOM']),\n ),\n },\n include: Array.from(new Set([...(json.include ?? []), 'src/**/*.tsx'])),\n }),\n );\n\n addDependenciesToPackageJson(\n tree,\n withVersions(\n forDependencies<typeof SHADCN_DEPENDENCIES>(declaration),\n declaredNames(SHADCN_DEPENDENCIES),\n ),\n {},\n joinPathFragments(libraryRoot, 'package.json'),\n );\n\n // shadcn 4.x's CLI resolves the `components.json` alias via `imports`/\n // `exports` (Node's package resolution), not a tsconfig `paths` alias.\n // `imports` covers this package's own internal component-to-component\n // references (aliased in components.json below); `exports` covers every\n // other consumer.\n updateJson(\n tree,\n joinPathFragments(libraryRoot, 'package.json'),\n (packageJson) => ({\n ...packageJson,\n imports: {\n '#components/*': './src/components/*.tsx',\n '#lib/*': './src/lib/*.ts',\n '#hooks/*': './src/hooks/*.ts',\n },\n exports: {\n '.': './src/index.ts',\n './styles/*': './src/styles/*',\n './components/*': './src/components/*.tsx',\n './lib/*': './src/lib/*.ts',\n './hooks/*': './src/hooks/*.ts',\n },\n }),\n );\n }\n\n // components.json lives in the package so `shadcn add` runs there and\n // installs component dependencies into the package's own manifest.\n if (!tree.exists(joinPathFragments(libraryRoot, 'components.json'))) {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'shadcn'),\n libraryRoot,\n {},\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n\n await formatFilesInSubtree(tree);\n}\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateJson","tsProjectGenerator","configureTsProject","VITEST_DEPENDENCIES","declaredNames","forDependencies","addDependenciesToPackageJson","getLocalDependencySpecifier","formatFilesInSubtree","esmVars","getNpmScopePrefix","PACKAGES_DIR","SHARED_SHADCN_DIR","SHARED_SHADCN_NAME","withVersions","SHADCN_DEPENDENCIES","name","getSharedShadcnFullyQualifiedName","tree","addSharedShadcnDependency","consumerDir","sharedShadcnGenerator","declaration","fullyQualifiedName","libraryRoot","shadcnSrcRoot","exists","directory","subDirectory","delete","dirname","overwriteStrategy","KeepExisting","Overwrite","dir","json","compilerOptions","jsx","module","moduleResolution","lib","Array","from","Set","include","packageJson","imports","exports"],"mappings":"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"}
|