zard-cli 1.0.0-beta.99 → 1.0.1
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/README.md +98 -36
- package/commands/add/component-installer.d.ts +3 -0
- package/commands/add/component-installer.d.ts.map +1 -1
- package/commands/add/component-installer.js +31 -8
- package/commands/add/component-installer.js.map +1 -1
- package/commands/add/component-selector.d.ts +6 -0
- package/commands/add/component-selector.d.ts.map +1 -1
- package/commands/add/component-selector.js +9 -27
- package/commands/add/component-selector.js.map +1 -1
- package/commands/add/dark-mode-setup.d.ts +2 -0
- package/commands/add/dark-mode-setup.d.ts.map +1 -1
- package/commands/add/dark-mode-setup.js +16 -11
- package/commands/add/dark-mode-setup.js.map +1 -1
- package/commands/add/dependency-resolver.d.ts +8 -1
- package/commands/add/dependency-resolver.d.ts.map +1 -1
- package/commands/add/dependency-resolver.js +87 -16
- package/commands/add/dependency-resolver.js.map +1 -1
- package/commands/add/index.d.ts.map +1 -1
- package/commands/add/index.js +142 -96
- package/commands/add/index.js.map +1 -1
- package/commands/add/stylesheet-setup.d.ts +3 -0
- package/commands/add/stylesheet-setup.d.ts.map +1 -0
- package/commands/add/stylesheet-setup.js +92 -0
- package/commands/add/stylesheet-setup.js.map +1 -0
- package/commands/add/wizard.d.ts +35 -0
- package/commands/add/wizard.d.ts.map +1 -0
- package/commands/add/wizard.js +299 -0
- package/commands/add/wizard.js.map +1 -0
- package/commands/init/config-prompter.d.ts +65 -3
- package/commands/init/config-prompter.d.ts.map +1 -1
- package/commands/init/config-prompter.js +93 -74
- package/commands/init/config-prompter.js.map +1 -1
- package/commands/init/dependencies.d.ts +1 -8
- package/commands/init/dependencies.d.ts.map +1 -1
- package/commands/init/dependencies.js +54 -24
- package/commands/init/dependencies.js.map +1 -1
- package/commands/init/index.d.ts.map +1 -1
- package/commands/init/index.js +175 -81
- package/commands/init/index.js.map +1 -1
- package/commands/init/library-peers.d.ts +28 -0
- package/commands/init/library-peers.d.ts.map +1 -0
- package/commands/init/library-peers.js +61 -0
- package/commands/init/library-peers.js.map +1 -0
- package/commands/init/project-kind.d.ts +82 -0
- package/commands/init/project-kind.d.ts.map +1 -0
- package/commands/init/project-kind.js +166 -0
- package/commands/init/project-kind.js.map +1 -0
- package/commands/init/steps.d.ts +15 -0
- package/commands/init/steps.d.ts.map +1 -0
- package/commands/init/steps.js +188 -0
- package/commands/init/steps.js.map +1 -0
- package/commands/init/tailwind-setup.d.ts +9 -2
- package/commands/init/tailwind-setup.d.ts.map +1 -1
- package/commands/init/tailwind-setup.js +47 -12
- package/commands/init/tailwind-setup.js.map +1 -1
- package/commands/init/tsconfig-updater.d.ts +8 -1
- package/commands/init/tsconfig-updater.d.ts.map +1 -1
- package/commands/init/tsconfig-updater.js +30 -11
- package/commands/init/tsconfig-updater.js.map +1 -1
- package/commands/init/update-angular-config.d.ts.map +1 -1
- package/commands/init/update-angular-config.js +28 -50
- package/commands/init/update-angular-config.js.map +1 -1
- package/commands/init/vite-setup.d.ts +11 -0
- package/commands/init/vite-setup.d.ts.map +1 -0
- package/commands/init/vite-setup.js +61 -0
- package/commands/init/vite-setup.js.map +1 -0
- package/commands/init/wizard.d.ts +33 -0
- package/commands/init/wizard.d.ts.map +1 -0
- package/commands/init/wizard.js +561 -0
- package/commands/init/wizard.js.map +1 -0
- package/constants/app.constants.d.ts +17 -0
- package/constants/app.constants.d.ts.map +1 -1
- package/constants/app.constants.js +39 -16
- package/constants/app.constants.js.map +1 -1
- package/core/icons/families.d.ts +38 -0
- package/core/icons/families.d.ts.map +1 -0
- package/core/icons/families.js +26 -0
- package/core/icons/families.js.map +1 -0
- package/core/icons/icon-map.d.ts +24 -0
- package/core/icons/icon-map.d.ts.map +1 -0
- package/core/icons/icon-map.js +141 -0
- package/core/icons/icon-map.js.map +1 -0
- package/core/icons/index.d.ts +107 -0
- package/core/icons/index.d.ts.map +1 -0
- package/core/icons/index.js +183 -0
- package/core/icons/index.js.map +1 -0
- package/core/registry/registry-data.d.ts.map +1 -1
- package/core/registry/registry-data.js +498 -36
- package/core/registry/registry-data.js.map +1 -1
- package/core/themes/theme-definitions.d.ts.map +1 -1
- package/core/themes/theme-definitions.js +61 -72
- package/core/themes/theme-definitions.js.map +1 -1
- package/index.js +6 -3
- package/index.js.map +1 -1
- package/package.json +6 -11
- package/ui/blocks.d.ts +71 -0
- package/ui/blocks.d.ts.map +1 -0
- package/ui/blocks.js +116 -0
- package/ui/blocks.js.map +1 -0
- package/ui/brand.d.ts +14 -0
- package/ui/brand.d.ts.map +1 -0
- package/ui/brand.js +35 -0
- package/ui/brand.js.map +1 -0
- package/ui/engine/animation/index.d.ts +38 -0
- package/ui/engine/animation/index.d.ts.map +1 -0
- package/ui/engine/animation/index.js +102 -0
- package/ui/engine/animation/index.js.map +1 -0
- package/ui/engine/ansi/index.d.ts +51 -0
- package/ui/engine/ansi/index.d.ts.map +1 -0
- package/ui/engine/ansi/index.js +116 -0
- package/ui/engine/ansi/index.js.map +1 -0
- package/ui/engine/components/index.d.ts +211 -0
- package/ui/engine/components/index.d.ts.map +1 -0
- package/ui/engine/components/index.js +109 -0
- package/ui/engine/components/index.js.map +1 -0
- package/ui/engine/cursor/index.d.ts +16 -0
- package/ui/engine/cursor/index.d.ts.map +1 -0
- package/ui/engine/cursor/index.js +40 -0
- package/ui/engine/cursor/index.js.map +1 -0
- package/ui/engine/diff/index.d.ts +26 -0
- package/ui/engine/diff/index.d.ts.map +1 -0
- package/ui/engine/diff/index.js +56 -0
- package/ui/engine/diff/index.js.map +1 -0
- package/ui/engine/events/index.d.ts +24 -0
- package/ui/engine/events/index.d.ts.map +1 -0
- package/ui/engine/events/index.js +60 -0
- package/ui/engine/events/index.js.map +1 -0
- package/ui/engine/focus/index.d.ts +25 -0
- package/ui/engine/focus/index.d.ts.map +1 -0
- package/ui/engine/focus/index.js +77 -0
- package/ui/engine/focus/index.js.map +1 -0
- package/ui/engine/frame/index.d.ts +48 -0
- package/ui/engine/frame/index.d.ts.map +1 -0
- package/ui/engine/frame/index.js +0 -0
- package/ui/engine/frame/index.js.map +1 -0
- package/ui/engine/index.d.ts +28 -0
- package/ui/engine/index.d.ts.map +1 -0
- package/ui/engine/index.js +28 -0
- package/ui/engine/index.js.map +1 -0
- package/ui/engine/input/index.d.ts +36 -0
- package/ui/engine/input/index.d.ts.map +1 -0
- package/ui/engine/input/index.js +224 -0
- package/ui/engine/input/index.js.map +1 -0
- package/ui/engine/layout/index.d.ts +42 -0
- package/ui/engine/layout/index.d.ts.map +1 -0
- package/ui/engine/layout/index.js +241 -0
- package/ui/engine/layout/index.js.map +1 -0
- package/ui/engine/renderer/index.d.ts +43 -0
- package/ui/engine/renderer/index.d.ts.map +1 -0
- package/ui/engine/renderer/index.js +619 -0
- package/ui/engine/renderer/index.js.map +1 -0
- package/ui/engine/scheduler/index.d.ts +22 -0
- package/ui/engine/scheduler/index.d.ts.map +1 -0
- package/ui/engine/scheduler/index.js +77 -0
- package/ui/engine/scheduler/index.js.map +1 -0
- package/ui/engine/screen/index.d.ts +39 -0
- package/ui/engine/screen/index.d.ts.map +1 -0
- package/ui/engine/screen/index.js +255 -0
- package/ui/engine/screen/index.js.map +1 -0
- package/ui/engine/terminal/index.d.ts +84 -0
- package/ui/engine/terminal/index.d.ts.map +1 -0
- package/ui/engine/terminal/index.js +235 -0
- package/ui/engine/terminal/index.js.map +1 -0
- package/ui/engine/testing/index.d.ts +27 -0
- package/ui/engine/testing/index.d.ts.map +1 -0
- package/ui/engine/testing/index.js +63 -0
- package/ui/engine/testing/index.js.map +1 -0
- package/ui/engine/theme/index.d.ts +26 -0
- package/ui/engine/theme/index.d.ts.map +1 -0
- package/ui/engine/theme/index.js +128 -0
- package/ui/engine/theme/index.js.map +1 -0
- package/ui/engine/utils/index.d.ts +12 -0
- package/ui/engine/utils/index.d.ts.map +1 -0
- package/ui/engine/utils/index.js +143 -0
- package/ui/engine/utils/index.js.map +1 -0
- package/ui/gate.d.ts +19 -0
- package/ui/gate.d.ts.map +1 -0
- package/ui/gate.js +36 -0
- package/ui/gate.js.map +1 -0
- package/ui/index.d.ts +18 -0
- package/ui/index.d.ts.map +1 -0
- package/ui/index.js +18 -0
- package/ui/index.js.map +1 -0
- package/ui/log-sink.d.ts +24 -0
- package/ui/log-sink.d.ts.map +1 -0
- package/ui/log-sink.js +35 -0
- package/ui/log-sink.js.map +1 -0
- package/ui/output.d.ts +14 -0
- package/ui/output.d.ts.map +1 -0
- package/ui/output.js +28 -0
- package/ui/output.js.map +1 -0
- package/ui/report.d.ts +30 -0
- package/ui/report.d.ts.map +1 -0
- package/ui/report.js +45 -0
- package/ui/report.js.map +1 -0
- package/ui/runner.d.ts +66 -0
- package/ui/runner.d.ts.map +1 -0
- package/ui/runner.js +135 -0
- package/ui/runner.js.map +1 -0
- package/ui/style.d.ts +24 -0
- package/ui/style.d.ts.map +1 -0
- package/ui/style.js +44 -0
- package/ui/style.js.map +1 -0
- package/ui/testing/fake-tty.d.ts +26 -0
- package/ui/testing/fake-tty.d.ts.map +1 -0
- package/ui/testing/fake-tty.js +61 -0
- package/ui/testing/fake-tty.js.map +1 -0
- package/ui/text-input.d.ts +31 -0
- package/ui/text-input.d.ts.map +1 -0
- package/ui/text-input.js +89 -0
- package/ui/text-input.js.map +1 -0
- package/ui/theme.d.ts +10 -0
- package/ui/theme.d.ts.map +1 -0
- package/ui/theme.js +20 -0
- package/ui/theme.js.map +1 -0
- package/utils/angular-compat.d.ts +21 -0
- package/utils/angular-compat.d.ts.map +1 -0
- package/utils/angular-compat.js +52 -0
- package/utils/angular-compat.js.map +1 -0
- package/utils/config.d.ts +29 -0
- package/utils/config.d.ts.map +1 -1
- package/utils/config.js +50 -4
- package/utils/config.js.map +1 -1
- package/utils/errors.d.ts +11 -0
- package/utils/errors.d.ts.map +1 -1
- package/utils/errors.js +14 -0
- package/utils/errors.js.map +1 -1
- package/utils/get-project-info.d.ts +29 -0
- package/utils/get-project-info.d.ts.map +1 -1
- package/utils/get-project-info.js +246 -1
- package/utils/get-project-info.js.map +1 -1
- package/utils/http-client.d.ts.map +1 -1
- package/utils/http-client.js +18 -3
- package/utils/http-client.js.map +1 -1
- package/utils/icon-catalog.d.ts +34 -0
- package/utils/icon-catalog.d.ts.map +1 -0
- package/utils/icon-catalog.js +63 -0
- package/utils/icon-catalog.js.map +1 -0
- package/utils/logger.d.ts +13 -1
- package/utils/logger.d.ts.map +1 -1
- package/utils/logger.js +95 -15
- package/utils/logger.js.map +1 -1
- package/utils/package-manager.d.ts +42 -1
- package/utils/package-manager.d.ts.map +1 -1
- package/utils/package-manager.js +204 -11
- package/utils/package-manager.js.map +1 -1
- package/utils/registry.d.ts +106 -2
- package/utils/registry.d.ts.map +1 -1
- package/utils/registry.js +155 -21
- package/utils/registry.js.map +1 -1
- package/utils/schema-version.d.ts +21 -0
- package/utils/schema-version.d.ts.map +1 -0
- package/utils/schema-version.js +28 -0
- package/utils/schema-version.js.map +1 -0
- package/utils/source-file.d.ts +40 -0
- package/utils/source-file.d.ts.map +1 -0
- package/utils/source-file.js +104 -0
- package/utils/source-file.js.map +1 -0
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { type Config } from '../../utils/config.js';
|
|
2
|
-
type ProjectInfo
|
|
3
|
-
framework: string;
|
|
4
|
-
hasTypeScript: boolean;
|
|
5
|
-
hasTailwind: boolean;
|
|
6
|
-
hasNx: boolean;
|
|
7
|
-
angularVersion: string | null;
|
|
8
|
-
};
|
|
2
|
+
import { type ProjectInfo } from '../../utils/get-project-info.js';
|
|
9
3
|
export declare function installDependencies(cwd: string, config: Config, projectInfo?: ProjectInfo): Promise<void>;
|
|
10
|
-
export {};
|
|
11
4
|
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/commands/init/dependencies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/commands/init/dependencies.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAKlF,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA0C/G"}
|
|
@@ -1,35 +1,65 @@
|
|
|
1
|
+
import { syncLibraryPeerDependencies } from '../../commands/init/library-peers.js';
|
|
2
|
+
import { bundlerFor, isLibraryKind } from '../../commands/init/project-kind.js';
|
|
3
|
+
import { iconPackagesFor } from '../../core/icons/index.js';
|
|
4
|
+
import { pinAllForAngular } from '../../utils/angular-compat.js';
|
|
1
5
|
import { getProjectInfo } from '../../utils/get-project-info.js';
|
|
6
|
+
import { iconCatalog } from '../../utils/icon-catalog.js';
|
|
2
7
|
import { logger } from '../../utils/logger.js';
|
|
3
|
-
import {
|
|
8
|
+
import { filterInstalledPackages, installPackagesWithRetry } from '../../utils/package-manager.js';
|
|
4
9
|
export async function installDependencies(cwd, config, projectInfo) {
|
|
5
10
|
const info = projectInfo || (await getProjectInfo(cwd));
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
// The icon package comes from the family chosen in `components.json`, not from
|
|
12
|
+
// a fixed list: that is what makes `"icons"` mean something the day there is
|
|
13
|
+
// more than one family.
|
|
14
|
+
//
|
|
15
|
+
// Pinned against the project's Angular: the CDK and ng-icons both ship one
|
|
16
|
+
// release per Angular major and peer on `>=` it, so `latest` is the wrong
|
|
17
|
+
// answer for anyone not already on the newest Angular.
|
|
18
|
+
const deps = pinAllForAngular([
|
|
19
|
+
'@angular/cdk',
|
|
20
|
+
'class-variance-authority',
|
|
21
|
+
'clsx',
|
|
22
|
+
'tailwind-merge',
|
|
23
|
+
...iconPackagesFor(config.icons, iconCatalog()),
|
|
24
|
+
], info.angularVersion);
|
|
25
|
+
const devDeps = tailwindPackages(config.projectType);
|
|
11
26
|
if (info.hasTailwind) {
|
|
12
|
-
logger.info('Tailwind CSS is already installed.
|
|
27
|
+
logger.info('Tailwind CSS is already installed. Only the missing pieces will be added.');
|
|
13
28
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
// Every batch that comes back empty is a whole manager invocation saved — and
|
|
30
|
+
// that is exactly the common case for a repeated `init`: nothing to install.
|
|
31
|
+
const [missingDeps, missingDevDeps] = await Promise.all([
|
|
32
|
+
filterInstalledPackages(deps, cwd),
|
|
33
|
+
filterInstalledPackages(devDeps, cwd),
|
|
34
|
+
]);
|
|
35
|
+
if (!missingDeps.length && !missingDevDeps.length) {
|
|
36
|
+
logger.info('All dependencies are already installed.');
|
|
17
37
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return '@angular/cdk';
|
|
38
|
+
else {
|
|
39
|
+
await installPackagesWithRetry(missingDeps, cwd, config.packageManager, false);
|
|
40
|
+
await installPackagesWithRetry(missingDevDeps, cwd, config.packageManager, true);
|
|
22
41
|
}
|
|
23
|
-
|
|
24
|
-
|
|
42
|
+
// A library's components import these, and the theme it ships loads Tailwind and its plugin.
|
|
43
|
+
await syncLibraryPeerDependencies(cwd, config, [...deps, ...tailwindPackages(config.projectType)]);
|
|
25
44
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
/**
|
|
46
|
+
* What Tailwind needs to run in that kind of project.
|
|
47
|
+
*
|
|
48
|
+
* The list is always the complete one and the installed-filter decides what is
|
|
49
|
+
* left: checking only for `tailwindcss` missed the case of someone who had it
|
|
50
|
+
* installed but not the bundler adapter, and then the build emitted no
|
|
51
|
+
* utilities at all.
|
|
52
|
+
*
|
|
53
|
+
* A library has no bundler to configure — the consuming application compiles
|
|
54
|
+
* the CSS — but the packages stay because the theme init writes there declares
|
|
55
|
+
* them.
|
|
56
|
+
*/
|
|
57
|
+
function tailwindPackages(kind) {
|
|
58
|
+
const shared = ['tailwindcss', 'tailwindcss-animate'];
|
|
59
|
+
if (isLibraryKind(kind))
|
|
60
|
+
return shared;
|
|
61
|
+
return bundlerFor(kind) === 'vite'
|
|
62
|
+
? [...shared, '@tailwindcss/vite']
|
|
63
|
+
: [...shared, '@tailwindcss/postcss', 'postcss'];
|
|
34
64
|
}
|
|
35
65
|
//# sourceMappingURL=dependencies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../src/commands/init/dependencies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../src/commands/init/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAoB,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAElG,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAW,EAAE,MAAc,EAAE,WAAyB;IAC9F,MAAM,IAAI,GAAG,WAAW,IAAI,CAAC,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IAExD,+EAA+E;IAC/E,6EAA6E;IAC7E,wBAAwB;IACxB,EAAE;IACF,2EAA2E;IAC3E,0EAA0E;IA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AEtD,IAAI,aAAa,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAEvC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,MAAM;QAChC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,mBAAmB,CAAC;QAClC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,IAAI,SA0Eb,CAAC"}
|
package/commands/init/index.js
CHANGED
|
@@ -1,53 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { resolveConfigPaths } from '../../utils/config.js';
|
|
1
|
+
import { buildConfig, defaultAnswers, inspectCssFile, withPresets, } from '../../commands/init/config-prompter.js';
|
|
2
|
+
import { candidateProjects, detectProjectKind, isLibraryKind, PROJECT_KINDS, } from '../../commands/init/project-kind.js';
|
|
3
|
+
import { buildInitSteps } from '../../commands/init/steps.js';
|
|
4
|
+
import { runInitWizard } from '../../commands/init/wizard.js';
|
|
5
|
+
import { isInteractive, printReport, WizardCancelledError } from '../../ui/index.js';
|
|
7
6
|
import { CliError } from '../../utils/errors.js';
|
|
8
7
|
import { getProjectInfo } from '../../utils/get-project-info.js';
|
|
8
|
+
import { loadIconCatalog } from '../../utils/icon-catalog.js';
|
|
9
9
|
import { logger, spinner } from '../../utils/logger.js';
|
|
10
|
-
import { detectPackageManager } from '../../utils/package-manager.js';
|
|
11
|
-
import
|
|
10
|
+
import { detectPackageManager, suggestedRunner } from '../../utils/package-manager.js';
|
|
11
|
+
import { getRegistryUrl } from '../../utils/registry.js';
|
|
12
|
+
import { getAvailableThemes } from '../../utils/theme-selector.js';
|
|
12
13
|
import { Command } from 'commander';
|
|
13
14
|
import { existsSync } from 'node:fs';
|
|
14
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
|
15
15
|
import * as path from 'node:path';
|
|
16
|
-
import prompts from 'prompts';
|
|
17
|
-
import { updateAngularConfig } from './update-angular-config.js';
|
|
18
16
|
export const init = new Command()
|
|
19
17
|
.name('init')
|
|
20
18
|
.description('initialize your project and install dependencies')
|
|
21
19
|
.option('-y, --yes', 'skip confirmation prompt.', false)
|
|
22
20
|
.option('-c, --cwd <cwd>', 'the working directory. defaults to the current directory.', process.cwd())
|
|
21
|
+
.option('-t, --type <type>', `the project type: ${PROJECT_KINDS.map(kind => kind.value).join(', ')}.`)
|
|
22
|
+
.option('-p, --project <name>', 'the workspace project to configure. defaults to the first compatible one.')
|
|
23
|
+
.option('--css <path>', 'the global stylesheet that receives the theme (in a library, the file init creates).')
|
|
24
|
+
.option('--app-config <path>', 'the app.config.ts that receives provideZard(). ignored for libraries.')
|
|
25
|
+
.option('--base-color <color>', `the theme base color: ${getAvailableThemes().join(', ')}.`)
|
|
26
|
+
.option('--components-alias <alias>', 'the import alias for components. defaults to @/shared/components.')
|
|
27
|
+
.option('--utils-alias <alias>', 'the import alias for utils. defaults to @/shared/utils.')
|
|
23
28
|
.action(async (options) => {
|
|
24
29
|
const cwd = path.resolve(options.cwd);
|
|
25
30
|
validateWorkingDirectory(cwd);
|
|
26
31
|
const projectInfo = await getProjectInfo(cwd);
|
|
27
32
|
validateAngularProject(projectInfo);
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const kind = resolveKind(options.type);
|
|
34
|
+
const presets = resolvePresets(options);
|
|
35
|
+
const projectRoot = resolveProjectRoot(options.project, kind ?? detectProjectKind(projectInfo), projectInfo);
|
|
36
|
+
const isReInitializing = existsSync(path.resolve(cwd, 'components.json'));
|
|
37
|
+
const packageManager = await detectPackageManager(cwd);
|
|
38
|
+
// Before any step: the catalog is what says which icon package to install,
|
|
39
|
+
// and it comes from the registry so it does not depend on the CLI version.
|
|
40
|
+
await loadIconCatalog(getRegistryUrl());
|
|
41
|
+
const buildSteps = (config) => buildInitSteps(cwd, config, projectInfo, isReInitializing);
|
|
42
|
+
if (!isInteractive()) {
|
|
43
|
+
logHeadlessReason();
|
|
44
|
+
await runHeadless({
|
|
45
|
+
cwd,
|
|
46
|
+
projectInfo,
|
|
47
|
+
packageManager,
|
|
48
|
+
isReInitializing,
|
|
49
|
+
buildSteps,
|
|
50
|
+
yes: options.yes,
|
|
51
|
+
kind,
|
|
52
|
+
projectRoot,
|
|
53
|
+
presets,
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
36
56
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
try {
|
|
58
|
+
const { config, logs } = await runInitWizard({
|
|
59
|
+
cwd,
|
|
60
|
+
projectInfo,
|
|
61
|
+
packageManager,
|
|
62
|
+
isReInitializing,
|
|
63
|
+
skipConfirmation: options.yes,
|
|
64
|
+
buildSteps,
|
|
65
|
+
presetKind: kind,
|
|
66
|
+
presetProjectRoot: projectRoot,
|
|
67
|
+
presetAnswers: presets,
|
|
68
|
+
});
|
|
69
|
+
reportSuccess(config, buildSteps(config), logs);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error instanceof WizardCancelledError) {
|
|
73
|
+
printReport({
|
|
74
|
+
status: 'cancelled',
|
|
75
|
+
headline: error.message,
|
|
76
|
+
notes: ['Nothing was changed in your project.'],
|
|
77
|
+
});
|
|
45
78
|
process.exit(0);
|
|
46
79
|
}
|
|
80
|
+
throw error;
|
|
47
81
|
}
|
|
48
|
-
await runInitializationSteps(cwd, config, projectInfo, isReInitializing);
|
|
49
|
-
displaySuccessMessage(config);
|
|
50
82
|
});
|
|
83
|
+
/**
|
|
84
|
+
* Why the full screen was not mounted.
|
|
85
|
+
*
|
|
86
|
+
* The CLI falling back to text mode is, to whoever is watching, indistinguishable
|
|
87
|
+
* from the interface not existing — which is how the degradation on macOS and
|
|
88
|
+
* Linux went unnoticed until it turned into "it never showed up" reports. With
|
|
89
|
+
* `--debug`, the command answers for itself.
|
|
90
|
+
*/
|
|
91
|
+
function logHeadlessReason() {
|
|
92
|
+
logger.debug(`No terminal to draw on (stdin TTY: ${Boolean(process.stdin.isTTY)}, ` +
|
|
93
|
+
`stdout TTY: ${Boolean(process.stdout.isTTY)}, controlling terminal: unreachable) — running headless.`);
|
|
94
|
+
}
|
|
51
95
|
function validateWorkingDirectory(cwd) {
|
|
52
96
|
if (!existsSync(cwd)) {
|
|
53
97
|
throw new CliError(`The path ${cwd} does not exist. Please try again.`, 'INVALID_CWD');
|
|
@@ -58,62 +102,112 @@ function validateAngularProject(projectInfo) {
|
|
|
58
102
|
throw new CliError('This project does not appear to be an Angular project.', 'NOT_ANGULAR');
|
|
59
103
|
}
|
|
60
104
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
105
|
+
/**
|
|
106
|
+
* The type asked for with `--type`, when there is one.
|
|
107
|
+
*
|
|
108
|
+
* It is the answer to the wizard's first question given up front — which is what
|
|
109
|
+
* makes init usable in CI, where nobody can pick from a menu.
|
|
110
|
+
*/
|
|
111
|
+
function resolveKind(value) {
|
|
112
|
+
if (!value)
|
|
113
|
+
return undefined;
|
|
114
|
+
const kind = PROJECT_KINDS.find(option => option.value === value);
|
|
115
|
+
if (!kind) {
|
|
116
|
+
throw new CliError(`Unknown project type "${value}". Expected one of: ${PROJECT_KINDS.map(option => option.value).join(', ')}.`, 'UNKNOWN_PROJECT_TYPE');
|
|
117
|
+
}
|
|
118
|
+
return kind.value;
|
|
70
119
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
120
|
+
/**
|
|
121
|
+
* The answers given as flags.
|
|
122
|
+
*
|
|
123
|
+
* Every question the wizard asks has one, so CI — and anyone who already knows
|
|
124
|
+
* the answers — can configure a project without a terminal to draw on.
|
|
125
|
+
*/
|
|
126
|
+
function resolvePresets(options) {
|
|
127
|
+
if (options.baseColor && !getAvailableThemes().includes(options.baseColor)) {
|
|
128
|
+
throw new CliError(`Unknown base color "${options.baseColor}". Expected one of: ${getAvailableThemes().join(', ')}.`, 'UNKNOWN_BASE_COLOR');
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
globalCss: options.css,
|
|
132
|
+
appConfig: options.appConfig,
|
|
133
|
+
theme: options.baseColor,
|
|
134
|
+
componentsAlias: options.componentsAlias,
|
|
135
|
+
utilsAlias: options.utilsAlias,
|
|
136
|
+
};
|
|
79
137
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
await createPostCssConfig(cwd);
|
|
138
|
+
/** The root of the project asked for with `--project`, looked up among the compatible ones. */
|
|
139
|
+
function resolveProjectRoot(name, kind, projectInfo) {
|
|
140
|
+
if (!name)
|
|
141
|
+
return undefined;
|
|
142
|
+
const candidates = candidateProjects(kind, projectInfo);
|
|
143
|
+
const project = candidates.find(candidate => candidate.name === name);
|
|
144
|
+
if (!project) {
|
|
145
|
+
const available = candidates.map(candidate => candidate.name).join(', ') || 'none';
|
|
146
|
+
throw new CliError(`Project "${name}" is not a ${kind} project in this workspace. Available: ${available}.`, 'UNKNOWN_PROJECT');
|
|
90
147
|
}
|
|
91
|
-
|
|
92
|
-
await applyThemeToStyles(cwd, config);
|
|
93
|
-
initSpinner.text = 'Updating TypeScript config...';
|
|
94
|
-
await updateTsConfig(cwd, config);
|
|
95
|
-
initSpinner.text = 'Installing core dependencies...';
|
|
96
|
-
await installCoreDependencies(cwd, config);
|
|
97
|
-
initSpinner.succeed('Project initialized');
|
|
148
|
+
return project.root;
|
|
98
149
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
150
|
+
/**
|
|
151
|
+
* The path without a UI — CI, pipes and non-interactive terminals.
|
|
152
|
+
*
|
|
153
|
+
* Nobody can answer anything here, so the defaults apply and `--yes` is
|
|
154
|
+
* required: without it the CLI refuses to overwrite the project's global CSS.
|
|
155
|
+
*/
|
|
156
|
+
async function runHeadless(options) {
|
|
157
|
+
if (!options.yes) {
|
|
158
|
+
throw new CliError('Running without an interactive terminal requires --yes, since init overwrites your global CSS.', 'NOT_INTERACTIVE');
|
|
159
|
+
}
|
|
160
|
+
const kind = options.kind ?? detectProjectKind(options.projectInfo);
|
|
161
|
+
const answers = withPresets(defaultAnswers(options.projectInfo, kind, options.projectRoot), options.presets);
|
|
162
|
+
const cssState = await inspectCssFile(options.cwd, answers.globalCss);
|
|
163
|
+
// In a library the theme CSS is created by init, so its absence is expected;
|
|
164
|
+
// in an application the file has to be there and wired into the build.
|
|
165
|
+
if (cssState === 'missing' && !isLibraryKind(answers.kind)) {
|
|
166
|
+
throw new CliError(`CSS file not found at: ${answers.globalCss}. Pass the right one with --css, or run init in an interactive terminal.`, 'CSS_NOT_FOUND');
|
|
167
|
+
}
|
|
168
|
+
const config = buildConfig(answers, options.packageManager);
|
|
169
|
+
const steps = options.buildSteps(config);
|
|
170
|
+
logger.info(options.isReInitializing ? 'Re-initializing zard/ui...' : 'Initializing zard/ui...');
|
|
171
|
+
for (const step of steps) {
|
|
172
|
+
const stepSpinner = spinner(`${step.label} — ${step.note}`).start();
|
|
173
|
+
try {
|
|
174
|
+
await step.run();
|
|
175
|
+
stepSpinner.succeed(step.label);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
stepSpinner.fail(`${step.label}: ${error instanceof Error ? error.message : String(error)}`);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
reportSuccess(config, steps, []);
|
|
183
|
+
}
|
|
184
|
+
function reportSuccess(config, steps, logs) {
|
|
185
|
+
printReport({
|
|
186
|
+
status: 'success',
|
|
187
|
+
headline: 'zard/ui has been initialized successfully!',
|
|
188
|
+
items: steps.map(step => `${step.label} — ${step.note}`),
|
|
189
|
+
notes: nextStepsFor(config),
|
|
190
|
+
commands: [{ command: `${suggestedRunner(config.packageManager)} zard-cli add`, argument: '[component]' }],
|
|
191
|
+
logs,
|
|
192
|
+
});
|
|
105
193
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
194
|
+
/**
|
|
195
|
+
* What is still left to do by hand.
|
|
196
|
+
*
|
|
197
|
+
* In a library init has nowhere to register `provideZard()` and no way to import
|
|
198
|
+
* the tokens — both belong to the app consuming the library, and without this
|
|
199
|
+
* notice the user only finds out when the components do not render.
|
|
200
|
+
*/
|
|
201
|
+
function nextStepsFor(config) {
|
|
202
|
+
if (!isLibraryKind(config.projectType)) {
|
|
203
|
+
return ['You can now add components using:'];
|
|
204
|
+
}
|
|
205
|
+
return [
|
|
206
|
+
'The consuming app still needs the Tailwind PostCSS pipeline (tailwindcss, @tailwindcss/postcss,',
|
|
207
|
+
'postcss, tailwindcss-animate and a .postcssrc.json), to register provideZard() in its',
|
|
208
|
+
`app.config.ts and to import the theme tokens from this library's ${path.basename(config.tailwind.css)}.`,
|
|
209
|
+
'',
|
|
210
|
+
'You can now add components using:',
|
|
211
|
+
];
|
|
118
212
|
}
|
|
119
213
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,EACd,WAAW,GAEZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,aAAa,GAEd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAiB,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,oBAAoB,EAAkB,MAAM,kBAAkB,CAAC;AAEpG,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAoB,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,OAAO,EAAE;KAC9B,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,kDAAkD,CAAC;KAC/D,MAAM,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C,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC7F,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,aAAa,CAAC,MAAc,EAAE,KAA0B,EAAE,IAA0B;IAC3F,WAAW,CAAC;QACV,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,4CAA4C;QACtD,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QACxD,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC;QAC3B,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,cAAc,CAAC,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;QAC1G,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,MAAc;IAClC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QACvC,OAAO,CAAC,mCAAmC,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO;QACL,iGAAiG;QACjG,uFAAuF;QACvF,oEAAoE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG;QACzG,EAAE;QACF,mCAAmC;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Config } from '../../utils/config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Declares what the library's components import as its peer dependencies.
|
|
4
|
+
*
|
|
5
|
+
* The packages are installed at the workspace root, where the library builds
|
|
6
|
+
* against them — but ng-packagr leaves them external, and an app installing the
|
|
7
|
+
* published library learns it needs `@angular/cdk` or `echarts` only when its
|
|
8
|
+
* build fails to resolve them. As peers, the package manager says so up front.
|
|
9
|
+
*
|
|
10
|
+
* The range is the one the workspace installed. An entry the library already
|
|
11
|
+
* declares is left alone: whoever wrote it chose that range on purpose.
|
|
12
|
+
* Libraries without a `package.json` of their own — a non-buildable Nx library —
|
|
13
|
+
* publish nothing, so there is nothing to declare.
|
|
14
|
+
*/
|
|
15
|
+
export declare function syncLibraryPeerDependencies(cwd: string, config: Config, packages: string[]): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the project is a library ng-packagr bundles — one with an `ng-package.json`.
|
|
18
|
+
*
|
|
19
|
+
* Only that kind needs relative imports: ng-packagr leaves aliased imports
|
|
20
|
+
* external. A non-buildable Nx library is compiled from source by the app that
|
|
21
|
+
* uses it, through the same aliases — and in a Vite build, reaching one file
|
|
22
|
+
* by alias and by relative path loads it twice, so rewriting there would only
|
|
23
|
+
* add risk. `baseUrl` is absolute; the library root sits two levels above it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isPublishableLibrary(config: {
|
|
26
|
+
projectType?: Config['projectType'];
|
|
27
|
+
}, baseUrl: string): boolean;
|
|
28
|
+
//# sourceMappingURL=library-peers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-peers.d.ts","sourceRoot":"","sources":["../../../src/commands/init/library-peers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAMnD;;;;;;;;;;;;GAYG;AACH,wBAAsB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BhH;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC,CAAA;CAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAK9G"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { isLibraryKind, projectRootOf } from '../../commands/init/project-kind.js';
|
|
2
|
+
import { logger } from '../../utils/logger.js';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
/**
|
|
7
|
+
* Declares what the library's components import as its peer dependencies.
|
|
8
|
+
*
|
|
9
|
+
* The packages are installed at the workspace root, where the library builds
|
|
10
|
+
* against them — but ng-packagr leaves them external, and an app installing the
|
|
11
|
+
* published library learns it needs `@angular/cdk` or `echarts` only when its
|
|
12
|
+
* build fails to resolve them. As peers, the package manager says so up front.
|
|
13
|
+
*
|
|
14
|
+
* The range is the one the workspace installed. An entry the library already
|
|
15
|
+
* declares is left alone: whoever wrote it chose that range on purpose.
|
|
16
|
+
* Libraries without a `package.json` of their own — a non-buildable Nx library —
|
|
17
|
+
* publish nothing, so there is nothing to declare.
|
|
18
|
+
*/
|
|
19
|
+
export async function syncLibraryPeerDependencies(cwd, config, packages) {
|
|
20
|
+
if (!isLibraryKind(config.projectType) || packages.length === 0)
|
|
21
|
+
return;
|
|
22
|
+
const libraryPackageJson = path.resolve(cwd, projectRootOf(config.baseUrl), 'package.json');
|
|
23
|
+
if (!existsSync(libraryPackageJson)) {
|
|
24
|
+
logger.debug(`No package.json in ${path.relative(cwd, path.dirname(libraryPackageJson))}; no peers to declare.`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const workspace = JSON.parse(await readFile(path.resolve(cwd, 'package.json'), 'utf8'));
|
|
28
|
+
const installed = { ...workspace.devDependencies, ...workspace.dependencies };
|
|
29
|
+
const library = JSON.parse(await readFile(libraryPackageJson, 'utf8'));
|
|
30
|
+
const peers = { ...library.peerDependencies };
|
|
31
|
+
let changed = false;
|
|
32
|
+
for (const name of packages.map(packageName)) {
|
|
33
|
+
if (peers[name])
|
|
34
|
+
continue;
|
|
35
|
+
peers[name] = installed[name] ?? '*';
|
|
36
|
+
changed = true;
|
|
37
|
+
}
|
|
38
|
+
if (!changed)
|
|
39
|
+
return;
|
|
40
|
+
library.peerDependencies = peers;
|
|
41
|
+
await writeFile(libraryPackageJson, `${JSON.stringify(library, null, 2)}\n`, 'utf8');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Whether the project is a library ng-packagr bundles — one with an `ng-package.json`.
|
|
45
|
+
*
|
|
46
|
+
* Only that kind needs relative imports: ng-packagr leaves aliased imports
|
|
47
|
+
* external. A non-buildable Nx library is compiled from source by the app that
|
|
48
|
+
* uses it, through the same aliases — and in a Vite build, reaching one file
|
|
49
|
+
* by alias and by relative path loads it twice, so rewriting there would only
|
|
50
|
+
* add risk. `baseUrl` is absolute; the library root sits two levels above it.
|
|
51
|
+
*/
|
|
52
|
+
export function isPublishableLibrary(config, baseUrl) {
|
|
53
|
+
return (Boolean(config.projectType && isLibraryKind(config.projectType)) &&
|
|
54
|
+
existsSync(path.resolve(baseUrl, '..', '..', 'ng-package.json')));
|
|
55
|
+
}
|
|
56
|
+
/** `@angular/cdk@^22` → `@angular/cdk`; the `@` that opens a scope is not a version. */
|
|
57
|
+
function packageName(spec) {
|
|
58
|
+
const separator = spec.lastIndexOf('@');
|
|
59
|
+
return separator > 0 ? spec.slice(0, separator) : spec;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=library-peers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-peers.js","sourceRoot":"","sources":["../../../src/commands/init/library-peers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAElF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,IAAI,MAA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