@angular/cli 22.2.0 → 22.3.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/ng.js +7 -10
- package/bin/version.js +98 -0
- package/index.d.ts +19 -0
- package/lib/chunk-5AASRQKS.js +85 -0
- package/lib/chunk-A2VIYA2E.js +165 -0
- package/lib/chunk-CAZUOCTC.js +225 -0
- package/lib/chunk-DHWVZMLH.js +206 -0
- package/lib/chunk-FZ5GFCWU.js +483 -0
- package/lib/chunk-G7TRU43D.js +42 -0
- package/lib/chunk-GHUUJYOY.js +40 -0
- package/lib/chunk-JBLF2TH3.js +267 -0
- package/lib/chunk-Q67GOPL7.js +380 -0
- package/lib/chunk-SN4KY4Z3.js +24 -0
- package/lib/chunk-XFL2J3CJ.js +24 -0
- package/lib/chunk-XG3HVNIL.js +59 -0
- package/lib/chunk-YM7ILCS5.js +2573 -0
- package/lib/cli/index.js +353 -105
- package/lib/cli-4CMZ6KMR.js +48 -0
- package/lib/cli-4Q7DGTBA.js +33 -0
- package/lib/cli-6AHY7ADW.js +96 -0
- package/lib/cli-A5UAJDO6.js +135 -0
- package/lib/cli-ACLGUIBI.js +2531 -0
- package/lib/cli-BQRFWIMG.js +35 -0
- package/lib/cli-CWICUPZW.js +42 -0
- package/lib/cli-DWQUM3M2.js +29 -0
- package/lib/cli-L4TM4JH3.js +88 -0
- package/lib/cli-LYBZEMDR.js +96 -0
- package/lib/cli-PDCEX7HQ.js +605 -0
- package/lib/cli-PJVTDBQM.js +51 -0
- package/lib/cli-PRIRL3WP.js +185 -0
- package/lib/cli-PU5VH7JB.js +189 -0
- package/lib/cli-QUH44NUB.js +68 -0
- package/lib/cli-VVITNTBC.js +50 -0
- package/lib/cli-XM4L4PP4.js +1651 -0
- package/lib/cli-Y2ECUR33.js +33 -0
- package/lib/cli-YDSMJOSO.js +182 -0
- package/lib/color-SJPGXZVA.js +8 -0
- package/lib/config/schema.json +210 -6
- package/lib/config-QXK7SSVG.js +22 -0
- package/lib/init.js +91 -180
- package/package.json +20 -15
- package/lib/cli/index.d.ts +0 -11
- package/lib/cli/index.js.map +0 -1
- package/lib/config/workspace-schema.d.ts +0 -1025
- package/lib/config/workspace-schema.js +0 -131
- package/lib/config/workspace-schema.js.map +0 -1
- package/lib/init.d.ts +0 -8
- package/lib/init.js.map +0 -1
- package/src/analytics/analytics-collector.d.ts +0 -35
- package/src/analytics/analytics-collector.js +0 -195
- package/src/analytics/analytics-collector.js.map +0 -1
- package/src/analytics/analytics-parameters.d.ts +0 -101
- package/src/analytics/analytics-parameters.js +0 -107
- package/src/analytics/analytics-parameters.js.map +0 -1
- package/src/analytics/analytics.d.ts +0 -27
- package/src/analytics/analytics.js +0 -183
- package/src/analytics/analytics.js.map +0 -1
- package/src/command-builder/architect-base-command-module.d.ts +0 -30
- package/src/command-builder/architect-base-command-module.js +0 -244
- package/src/command-builder/architect-base-command-module.js.map +0 -1
- package/src/command-builder/architect-command-module.d.ts +0 -28
- package/src/command-builder/architect-command-module.js +0 -218
- package/src/command-builder/architect-command-module.js.map +0 -1
- package/src/command-builder/command-module.d.ts +0 -73
- package/src/command-builder/command-module.js +0 -260
- package/src/command-builder/command-module.js.map +0 -1
- package/src/command-builder/command-runner.d.ts +0 -9
- package/src/command-builder/command-runner.js +0 -202
- package/src/command-builder/command-runner.js.map +0 -1
- package/src/command-builder/definitions.d.ts +0 -41
- package/src/command-builder/definitions.js +0 -20
- package/src/command-builder/definitions.js.map +0 -1
- package/src/command-builder/schematics-command-module.d.ts +0 -41
- package/src/command-builder/schematics-command-module.js +0 -408
- package/src/command-builder/schematics-command-module.js.map +0 -1
- package/src/command-builder/utilities/command.d.ts +0 -13
- package/src/command-builder/utilities/command.js +0 -39
- package/src/command-builder/utilities/command.js.map +0 -1
- package/src/command-builder/utilities/json-help.d.ts +0 -37
- package/src/command-builder/utilities/json-help.js +0 -92
- package/src/command-builder/utilities/json-help.js.map +0 -1
- package/src/command-builder/utilities/json-schema.d.ts +0 -64
- package/src/command-builder/utilities/json-schema.js +0 -349
- package/src/command-builder/utilities/json-schema.js.map +0 -1
- package/src/command-builder/utilities/normalize-options-middleware.d.ts +0 -18
- package/src/command-builder/utilities/normalize-options-middleware.js +0 -37
- package/src/command-builder/utilities/normalize-options-middleware.js.map +0 -1
- package/src/command-builder/utilities/schematic-engine-host.d.ts +0 -15
- package/src/command-builder/utilities/schematic-engine-host.js +0 -179
- package/src/command-builder/utilities/schematic-engine-host.js.map +0 -1
- package/src/command-builder/utilities/schematic-workflow.d.ts +0 -14
- package/src/command-builder/utilities/schematic-workflow.js +0 -70
- package/src/command-builder/utilities/schematic-workflow.js.map +0 -1
- package/src/commands/add/cli.d.ts +0 -41
- package/src/commands/add/cli.js +0 -705
- package/src/commands/add/cli.js.map +0 -1
- package/src/commands/add/long-description.md +0 -7
- package/src/commands/analytics/cli.d.ts +0 -16
- package/src/commands/analytics/cli.js +0 -34
- package/src/commands/analytics/cli.js.map +0 -1
- package/src/commands/analytics/info/cli.d.ts +0 -16
- package/src/commands/analytics/info/cli.js +0 -25
- package/src/commands/analytics/info/cli.js.map +0 -1
- package/src/commands/analytics/long-description.md +0 -20
- package/src/commands/analytics/settings/cli.d.ts +0 -35
- package/src/commands/analytics/settings/cli.js +0 -54
- package/src/commands/analytics/settings/cli.js.map +0 -1
- package/src/commands/build/cli.d.ts +0 -16
- package/src/commands/build/cli.js +0 -21
- package/src/commands/build/cli.js.map +0 -1
- package/src/commands/build/long-description.md +0 -18
- package/src/commands/cache/clean/cli.d.ts +0 -17
- package/src/commands/cache/clean/cli.js +0 -32
- package/src/commands/cache/clean/cli.js.map +0 -1
- package/src/commands/cache/cli.d.ts +0 -17
- package/src/commands/cache/cli.js +0 -36
- package/src/commands/cache/cli.js.map +0 -1
- package/src/commands/cache/info/cli.d.ts +0 -20
- package/src/commands/cache/info/cli.js +0 -139
- package/src/commands/cache/info/cli.js.map +0 -1
- package/src/commands/cache/long-description.md +0 -53
- package/src/commands/cache/settings/cli.d.ts +0 -27
- package/src/commands/cache/settings/cli.js +0 -41
- package/src/commands/cache/settings/cli.js.map +0 -1
- package/src/commands/cache/utilities.d.ts +0 -11
- package/src/commands/cache/utilities.js +0 -85
- package/src/commands/cache/utilities.js.map +0 -1
- package/src/commands/command-config.d.ts +0 -17
- package/src/commands/command-config.js +0 -116
- package/src/commands/command-config.js.map +0 -1
- package/src/commands/completion/cli.d.ts +0 -16
- package/src/commands/completion/cli.js +0 -61
- package/src/commands/completion/cli.js.map +0 -1
- package/src/commands/completion/long-description.md +0 -67
- package/src/commands/config/cli.d.ts +0 -24
- package/src/commands/config/cli.js +0 -150
- package/src/commands/config/cli.js.map +0 -1
- package/src/commands/config/long-description.md +0 -13
- package/src/commands/deploy/cli.d.ts +0 -17
- package/src/commands/deploy/cli.js +0 -38
- package/src/commands/deploy/cli.js.map +0 -1
- package/src/commands/deploy/long-description.md +0 -22
- package/src/commands/e2e/cli.d.ts +0 -18
- package/src/commands/e2e/cli.js +0 -42
- package/src/commands/e2e/cli.js.map +0 -1
- package/src/commands/extract-i18n/cli.d.ts +0 -17
- package/src/commands/extract-i18n/cli.js +0 -48
- package/src/commands/extract-i18n/cli.js.map +0 -1
- package/src/commands/generate/cli.d.ts +0 -47
- package/src/commands/generate/cli.js +0 -189
- package/src/commands/generate/cli.js.map +0 -1
- package/src/commands/lint/cli.d.ts +0 -17
- package/src/commands/lint/cli.js +0 -25
- package/src/commands/lint/cli.js.map +0 -1
- package/src/commands/lint/long-description.md +0 -20
- package/src/commands/make-this-awesome/cli.d.ts +0 -17
- package/src/commands/make-this-awesome/cli.js +0 -36
- package/src/commands/make-this-awesome/cli.js.map +0 -1
- package/src/commands/mcp/cli.d.ts +0 -21
- package/src/commands/mcp/cli.js +0 -74
- package/src/commands/mcp/cli.js.map +0 -1
- package/src/commands/mcp/constants.d.ts +0 -10
- package/src/commands/mcp/constants.js +0 -16
- package/src/commands/mcp/constants.js.map +0 -1
- package/src/commands/mcp/devserver.d.ts +0 -85
- package/src/commands/mcp/devserver.js +0 -109
- package/src/commands/mcp/devserver.js.map +0 -1
- package/src/commands/mcp/host.d.ts +0 -103
- package/src/commands/mcp/host.js +0 -270
- package/src/commands/mcp/host.js.map +0 -1
- package/src/commands/mcp/mcp-server.d.ts +0 -38
- package/src/commands/mcp/mcp-server.js +0 -176
- package/src/commands/mcp/mcp-server.js.map +0 -1
- package/src/commands/mcp/resources/ai-tutor.md +0 -822
- package/src/commands/mcp/resources/best-practices.md +0 -59
- package/src/commands/mcp/resources/instructions.d.ts +0 -9
- package/src/commands/mcp/resources/instructions.js +0 -26
- package/src/commands/mcp/resources/instructions.js.map +0 -1
- package/src/commands/mcp/shared-options.d.ts +0 -12
- package/src/commands/mcp/shared-options.js +0 -22
- package/src/commands/mcp/shared-options.js.map +0 -1
- package/src/commands/mcp/tools/ai-tutor.d.ts +0 -12
- package/src/commands/mcp/tools/ai-tutor.js +0 -59
- package/src/commands/mcp/tools/ai-tutor.js.map +0 -1
- package/src/commands/mcp/tools/best-practices.d.ts +0 -13
- package/src/commands/mcp/tools/best-practices.js +0 -196
- package/src/commands/mcp/tools/best-practices.js.map +0 -1
- package/src/commands/mcp/tools/devserver/devserver-start.d.ts +0 -32
- package/src/commands/mcp/tools/devserver/devserver-start.js +0 -110
- package/src/commands/mcp/tools/devserver/devserver-start.js.map +0 -1
- package/src/commands/mcp/tools/devserver/devserver-stop.d.ts +0 -31
- package/src/commands/mcp/tools/devserver/devserver-stop.js +0 -69
- package/src/commands/mcp/tools/devserver/devserver-stop.js.map +0 -1
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.d.ts +0 -41
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.js +0 -105
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.js.map +0 -1
- package/src/commands/mcp/tools/doc-search.d.ts +0 -21
- package/src/commands/mcp/tools/doc-search.js +0 -307
- package/src/commands/mcp/tools/doc-search.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.d.ts +0 -17
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.js +0 -62
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.d.ts +0 -12
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.js +0 -70
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.d.ts +0 -12
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.js +0 -60
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.d.ts +0 -15
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js +0 -238
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.d.ts +0 -9
- package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.js +0 -14
- package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.d.ts +0 -36
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.js +0 -135
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.d.ts +0 -13
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.js +0 -10
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.d.ts +0 -16
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js +0 -211
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js.map +0 -1
- package/src/commands/mcp/tools/projects.d.ts +0 -48
- package/src/commands/mcp/tools/projects.js +0 -541
- package/src/commands/mcp/tools/projects.js.map +0 -1
- package/src/commands/mcp/tools/run-target/build-target-strategy.d.ts +0 -14
- package/src/commands/mcp/tools/run-target/build-target-strategy.js +0 -53
- package/src/commands/mcp/tools/run-target/build-target-strategy.js.map +0 -1
- package/src/commands/mcp/tools/run-target/generic-target-strategy.d.ts +0 -14
- package/src/commands/mcp/tools/run-target/generic-target-strategy.js +0 -63
- package/src/commands/mcp/tools/run-target/generic-target-strategy.js.map +0 -1
- package/src/commands/mcp/tools/run-target/options-serializer.d.ts +0 -13
- package/src/commands/mcp/tools/run-target/options-serializer.js +0 -41
- package/src/commands/mcp/tools/run-target/options-serializer.js.map +0 -1
- package/src/commands/mcp/tools/run-target/run-target.d.ts +0 -34
- package/src/commands/mcp/tools/run-target/run-target.js +0 -69
- package/src/commands/mcp/tools/run-target/run-target.js.map +0 -1
- package/src/commands/mcp/tools/run-target/strategy.d.ts +0 -15
- package/src/commands/mcp/tools/run-target/strategy.js +0 -10
- package/src/commands/mcp/tools/run-target/strategy.js.map +0 -1
- package/src/commands/mcp/tools/run-target/types.d.ts +0 -39
- package/src/commands/mcp/tools/run-target/types.js +0 -41
- package/src/commands/mcp/tools/run-target/types.js.map +0 -1
- package/src/commands/mcp/tools/run-target/unit-test-strategy.d.ts +0 -14
- package/src/commands/mcp/tools/run-target/unit-test-strategy.js +0 -56
- package/src/commands/mcp/tools/run-target/unit-test-strategy.js.map +0 -1
- package/src/commands/mcp/tools/tool-registry.d.ts +0 -40
- package/src/commands/mcp/tools/tool-registry.js +0 -40
- package/src/commands/mcp/tools/tool-registry.js.map +0 -1
- package/src/commands/mcp/utils.d.ts +0 -25
- package/src/commands/mcp/utils.js +0 -44
- package/src/commands/mcp/utils.js.map +0 -1
- package/src/commands/mcp/workspace-utils.d.ts +0 -55
- package/src/commands/mcp/workspace-utils.js +0 -181
- package/src/commands/mcp/workspace-utils.js.map +0 -1
- package/src/commands/new/cli.d.ts +0 -27
- package/src/commands/new/cli.js +0 -76
- package/src/commands/new/cli.js.map +0 -1
- package/src/commands/new/long-description.md +0 -15
- package/src/commands/run/cli.d.ts +0 -25
- package/src/commands/run/cli.js +0 -89
- package/src/commands/run/cli.js.map +0 -1
- package/src/commands/run/long-description.md +0 -10
- package/src/commands/serve/cli.d.ts +0 -16
- package/src/commands/serve/cli.js +0 -20
- package/src/commands/serve/cli.js.map +0 -1
- package/src/commands/test/cli.d.ts +0 -16
- package/src/commands/test/cli.js +0 -21
- package/src/commands/test/cli.js.map +0 -1
- package/src/commands/test/long-description.md +0 -2
- package/src/commands/update/cli.d.ts +0 -50
- package/src/commands/update/cli.js +0 -586
- package/src/commands/update/cli.js.map +0 -1
- package/src/commands/update/long-description.md +0 -22
- package/src/commands/update/update-resolver.d.ts +0 -75
- package/src/commands/update/update-resolver.js +0 -918
- package/src/commands/update/update-resolver.js.map +0 -1
- package/src/commands/update/utilities/cli-version.d.ts +0 -48
- package/src/commands/update/utilities/cli-version.js +0 -196
- package/src/commands/update/utilities/cli-version.js.map +0 -1
- package/src/commands/update/utilities/constants.d.ts +0 -12
- package/src/commands/update/utilities/constants.js +0 -16
- package/src/commands/update/utilities/constants.js.map +0 -1
- package/src/commands/update/utilities/git.d.ts +0 -36
- package/src/commands/update/utilities/git.js +0 -148
- package/src/commands/update/utilities/git.js.map +0 -1
- package/src/commands/update/utilities/migration.d.ts +0 -32
- package/src/commands/update/utilities/migration.js +0 -271
- package/src/commands/update/utilities/migration.js.map +0 -1
- package/src/commands/version/cli.d.ts +0 -36
- package/src/commands/version/cli.js +0 -117
- package/src/commands/version/cli.js.map +0 -1
- package/src/commands/version/version-info.d.ts +0 -46
- package/src/commands/version/version-info.js +0 -101
- package/src/commands/version/version-info.js.map +0 -1
- package/src/package-managers/discovery.d.ts +0 -23
- package/src/package-managers/discovery.js +0 -104
- package/src/package-managers/discovery.js.map +0 -1
- package/src/package-managers/error.d.ts +0 -43
- package/src/package-managers/error.js +0 -41
- package/src/package-managers/error.js.map +0 -1
- package/src/package-managers/factory.d.ts +0 -30
- package/src/package-managers/factory.js +0 -137
- package/src/package-managers/factory.js.map +0 -1
- package/src/package-managers/host.d.ts +0 -86
- package/src/package-managers/host.js +0 -91
- package/src/package-managers/host.js.map +0 -1
- package/src/package-managers/index.d.ts +0 -13
- package/src/package-managers/index.js +0 -17
- package/src/package-managers/index.js.map +0 -1
- package/src/package-managers/logger.d.ts +0 -27
- package/src/package-managers/logger.js +0 -10
- package/src/package-managers/logger.js.map +0 -1
- package/src/package-managers/package-manager-descriptor.d.ts +0 -269
- package/src/package-managers/package-manager-descriptor.js +0 -210
- package/src/package-managers/package-manager-descriptor.js.map +0 -1
- package/src/package-managers/package-manager.d.ts +0 -200
- package/src/package-managers/package-manager.js +0 -720
- package/src/package-managers/package-manager.js.map +0 -1
- package/src/package-managers/package-metadata.d.ts +0 -91
- package/src/package-managers/package-metadata.js +0 -10
- package/src/package-managers/package-metadata.js.map +0 -1
- package/src/package-managers/package-tree.d.ts +0 -23
- package/src/package-managers/package-tree.js +0 -10
- package/src/package-managers/package-tree.js.map +0 -1
- package/src/package-managers/parsers.d.ts +0 -167
- package/src/package-managers/parsers.js +0 -674
- package/src/package-managers/parsers.js.map +0 -1
- package/src/utilities/color.d.ts +0 -23
- package/src/utilities/color.js +0 -41
- package/src/utilities/color.js.map +0 -1
- package/src/utilities/completion.d.ts +0 -30
- package/src/utilities/completion.js +0 -270
- package/src/utilities/completion.js.map +0 -1
- package/src/utilities/config.d.ts +0 -38
- package/src/utilities/config.js +0 -368
- package/src/utilities/config.js.map +0 -1
- package/src/utilities/environment-options.d.ts +0 -25
- package/src/utilities/environment-options.js +0 -60
- package/src/utilities/environment-options.js.map +0 -1
- package/src/utilities/eol.d.ts +0 -20
- package/src/utilities/eol.js +0 -35
- package/src/utilities/eol.js.map +0 -1
- package/src/utilities/error.d.ts +0 -18
- package/src/utilities/error.js +0 -41
- package/src/utilities/error.js.map +0 -1
- package/src/utilities/find-up.d.ts +0 -21
- package/src/utilities/find-up.js +0 -67
- package/src/utilities/find-up.js.map +0 -1
- package/src/utilities/json-file.d.ts +0 -24
- package/src/utilities/json-file.js +0 -179
- package/src/utilities/json-file.js.map +0 -1
- package/src/utilities/log-file.d.ts +0 -13
- package/src/utilities/log-file.js +0 -28
- package/src/utilities/log-file.js.map +0 -1
- package/src/utilities/memoize.d.ts +0 -15
- package/src/utilities/memoize.js +0 -64
- package/src/utilities/memoize.js.map +0 -1
- package/src/utilities/node-version.d.ts +0 -21
- package/src/utilities/node-version.js +0 -65
- package/src/utilities/node-version.js.map +0 -1
- package/src/utilities/prettier.d.ts +0 -19
- package/src/utilities/prettier.js +0 -105
- package/src/utilities/prettier.js.map +0 -1
- package/src/utilities/project.d.ts +0 -8
- package/src/utilities/project.js +0 -81
- package/src/utilities/project.js.map +0 -1
- package/src/utilities/prompt.d.ts +0 -17
- package/src/utilities/prompt.js +0 -90
- package/src/utilities/prompt.js.map +0 -1
- package/src/utilities/tty.d.ts +0 -16
- package/src/utilities/tty.js +0 -23
- package/src/utilities/tty.js.map +0 -1
- package/src/utilities/version.d.ts +0 -16
- package/src/utilities/version.js +0 -26
- package/src/utilities/version.js.map +0 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CommandModule,
|
|
3
|
+
CommandModuleError,
|
|
4
|
+
CommandScope,
|
|
5
|
+
EventCustomDimension,
|
|
6
|
+
EventCustomMetric,
|
|
7
|
+
askConfirmation,
|
|
8
|
+
askQuestion,
|
|
9
|
+
isPackageNameSafeForAnalytics,
|
|
10
|
+
isTTY,
|
|
11
|
+
parseJsonSchemaToOptions
|
|
12
|
+
} from "./chunk-YM7ILCS5.js";
|
|
13
|
+
import {
|
|
14
|
+
assertIsError
|
|
15
|
+
} from "./chunk-FZ5GFCWU.js";
|
|
16
|
+
|
|
17
|
+
// packages/angular/cli/src/command-builder/architect-base-command-module.js
|
|
18
|
+
import { Architect } from "@angular-devkit/architect";
|
|
19
|
+
import { WorkspaceNodeModulesArchitectHost } from "@angular-devkit/architect/node";
|
|
20
|
+
import { json } from "@angular-devkit/core";
|
|
21
|
+
import { createRequire } from "node:module";
|
|
22
|
+
var ArchitectBaseCommandModule = class extends CommandModule {
|
|
23
|
+
scope = CommandScope.In;
|
|
24
|
+
missingTargetChoices;
|
|
25
|
+
async runSingleTarget(target, options) {
|
|
26
|
+
const architectHost = this.getArchitectHost();
|
|
27
|
+
let builderName;
|
|
28
|
+
try {
|
|
29
|
+
builderName = await architectHost.getBuilderNameForTarget(target);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
assertIsError(e);
|
|
32
|
+
return this.onMissingTarget(e.message);
|
|
33
|
+
}
|
|
34
|
+
const isAngularBuild = builderName.startsWith("@angular/build:");
|
|
35
|
+
const { logger } = this.context;
|
|
36
|
+
const run = await this.getArchitect(isAngularBuild).scheduleTarget(target, options, {
|
|
37
|
+
logger
|
|
38
|
+
});
|
|
39
|
+
const analytics = isPackageNameSafeForAnalytics(builderName) ? await this.getAnalytics() : void 0;
|
|
40
|
+
let outputSubscription;
|
|
41
|
+
if (analytics) {
|
|
42
|
+
analytics.reportArchitectRunEvent({
|
|
43
|
+
[EventCustomDimension.BuilderTarget]: builderName
|
|
44
|
+
});
|
|
45
|
+
let firstRun = true;
|
|
46
|
+
outputSubscription = run.output.subscribe(({ stats }) => {
|
|
47
|
+
const parameters = this.builderStatsToAnalyticsParameters(stats, builderName);
|
|
48
|
+
if (!parameters) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (firstRun) {
|
|
52
|
+
firstRun = false;
|
|
53
|
+
analytics.reportBuildRunEvent(parameters);
|
|
54
|
+
} else {
|
|
55
|
+
analytics.reportRebuildRunEvent(parameters);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const { error, success } = await run.lastOutput;
|
|
61
|
+
if (error) {
|
|
62
|
+
logger.error(error);
|
|
63
|
+
}
|
|
64
|
+
return success ? 0 : 1;
|
|
65
|
+
} finally {
|
|
66
|
+
await run.stop();
|
|
67
|
+
outputSubscription?.unsubscribe();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
builderStatsToAnalyticsParameters(stats, builderName) {
|
|
71
|
+
if (!stats || typeof stats !== "object" || !("durationInMs" in stats)) {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
const { optimization, allChunksCount, aot, lazyChunksCount, initialChunksCount, durationInMs, changedChunksCount, cssSizeInBytes, jsSizeInBytes, ngComponentCount } = stats;
|
|
75
|
+
return {
|
|
76
|
+
[EventCustomDimension.BuilderTarget]: builderName,
|
|
77
|
+
[EventCustomDimension.Aot]: aot,
|
|
78
|
+
[EventCustomDimension.Optimization]: optimization,
|
|
79
|
+
[EventCustomMetric.AllChunksCount]: allChunksCount,
|
|
80
|
+
[EventCustomMetric.LazyChunksCount]: lazyChunksCount,
|
|
81
|
+
[EventCustomMetric.InitialChunksCount]: initialChunksCount,
|
|
82
|
+
[EventCustomMetric.ChangedChunksCount]: changedChunksCount,
|
|
83
|
+
[EventCustomMetric.DurationInMs]: durationInMs,
|
|
84
|
+
[EventCustomMetric.JsSizeInBytes]: jsSizeInBytes,
|
|
85
|
+
[EventCustomMetric.CssSizeInBytes]: cssSizeInBytes,
|
|
86
|
+
[EventCustomMetric.NgComponentCount]: ngComponentCount
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
_architectHost;
|
|
90
|
+
getArchitectHost() {
|
|
91
|
+
if (this._architectHost) {
|
|
92
|
+
return this._architectHost;
|
|
93
|
+
}
|
|
94
|
+
const workspace = this.getWorkspaceOrThrow();
|
|
95
|
+
return this._architectHost = new WorkspaceNodeModulesArchitectHost(workspace, workspace.basePath);
|
|
96
|
+
}
|
|
97
|
+
_architect;
|
|
98
|
+
getArchitect(skipUndefinedArrayTransform) {
|
|
99
|
+
if (this._architect) {
|
|
100
|
+
return this._architect;
|
|
101
|
+
}
|
|
102
|
+
const registry = new json.schema.CoreSchemaRegistry();
|
|
103
|
+
if (skipUndefinedArrayTransform) {
|
|
104
|
+
registry.addPostTransform(json.schema.transforms.addUndefinedObjectDefaults);
|
|
105
|
+
} else {
|
|
106
|
+
registry.addPostTransform(json.schema.transforms.addUndefinedDefaults);
|
|
107
|
+
}
|
|
108
|
+
registry.useXDeprecatedProvider((msg) => this.context.logger.warn(msg));
|
|
109
|
+
const architectHost = this.getArchitectHost();
|
|
110
|
+
return this._architect = new Architect(architectHost, registry);
|
|
111
|
+
}
|
|
112
|
+
async getArchitectTargetOptions(target) {
|
|
113
|
+
const architectHost = this.getArchitectHost();
|
|
114
|
+
let builderConf;
|
|
115
|
+
try {
|
|
116
|
+
builderConf = await architectHost.getBuilderNameForTarget(target);
|
|
117
|
+
} catch {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
let builderDesc;
|
|
121
|
+
try {
|
|
122
|
+
builderDesc = await architectHost.resolveBuilder(builderConf);
|
|
123
|
+
} catch (e) {
|
|
124
|
+
assertIsError(e);
|
|
125
|
+
if (e.code === "MODULE_NOT_FOUND") {
|
|
126
|
+
this.warnOnMissingNodeModules();
|
|
127
|
+
throw new CommandModuleError(`Could not find the '${builderConf}' builder's node package.`);
|
|
128
|
+
}
|
|
129
|
+
throw e;
|
|
130
|
+
}
|
|
131
|
+
return parseJsonSchemaToOptions(new json.schema.CoreSchemaRegistry(), builderDesc.optionSchema, true);
|
|
132
|
+
}
|
|
133
|
+
warnOnMissingNodeModules() {
|
|
134
|
+
const basePath = this.context.workspace?.basePath;
|
|
135
|
+
if (!basePath) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const workspaceResolve = createRequire(basePath + "/").resolve;
|
|
139
|
+
try {
|
|
140
|
+
workspaceResolve("@angular/core");
|
|
141
|
+
return;
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
this.context.logger.warn(`Node packages may not be installed. Try installing with '${this.context.packageManager.name} install'.`);
|
|
145
|
+
}
|
|
146
|
+
getArchitectTarget() {
|
|
147
|
+
return this.commandName;
|
|
148
|
+
}
|
|
149
|
+
async onMissingTarget(defaultMessage) {
|
|
150
|
+
const { logger } = this.context;
|
|
151
|
+
const choices = this.missingTargetChoices;
|
|
152
|
+
if (!choices?.length) {
|
|
153
|
+
logger.error(defaultMessage);
|
|
154
|
+
return 1;
|
|
155
|
+
}
|
|
156
|
+
const missingTargetMessage = `Cannot find "${this.getArchitectTarget()}" target for the specified project.
|
|
157
|
+
You can add a package that implements these capabilities.
|
|
158
|
+
|
|
159
|
+
For example:
|
|
160
|
+
` + choices.map(({ name, value }) => ` ${name}: ng add ${value}`).join("\n") + "\n";
|
|
161
|
+
if (isTTY()) {
|
|
162
|
+
logger.warn(missingTargetMessage);
|
|
163
|
+
const packageToInstall = await this.getMissingTargetPackageToInstall(choices);
|
|
164
|
+
if (packageToInstall) {
|
|
165
|
+
const AddCommandModule = (await import("./cli-PDCEX7HQ.js")).default;
|
|
166
|
+
await new AddCommandModule(this.context).run({
|
|
167
|
+
interactive: true,
|
|
168
|
+
force: false,
|
|
169
|
+
dryRun: false,
|
|
170
|
+
defaults: false,
|
|
171
|
+
collection: packageToInstall
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
logger.error(missingTargetMessage);
|
|
176
|
+
}
|
|
177
|
+
return 1;
|
|
178
|
+
}
|
|
179
|
+
async getMissingTargetPackageToInstall(choices) {
|
|
180
|
+
if (choices.length === 1) {
|
|
181
|
+
const { name, value } = choices[0];
|
|
182
|
+
if (await askConfirmation(`Would you like to add ${name} now?`, true, false)) {
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return askQuestion(`Would you like to add a package with "${this.getArchitectTarget()}" capabilities now?`, [
|
|
188
|
+
{
|
|
189
|
+
name: "No",
|
|
190
|
+
value: null
|
|
191
|
+
},
|
|
192
|
+
...choices
|
|
193
|
+
], 0, null);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export {
|
|
198
|
+
ArchitectBaseCommandModule
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* @license
|
|
202
|
+
* Copyright Google LLC All Rights Reserved.
|
|
203
|
+
*
|
|
204
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
205
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
206
|
+
*/
|
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
// packages/angular/cli/src/utilities/config.js
|
|
2
|
+
import { json, workspaces } from "@angular-devkit/core";
|
|
3
|
+
import { existsSync, promises as fs } from "node:fs";
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
|
|
7
|
+
// packages/angular/cli/src/utilities/find-up.js
|
|
8
|
+
import { stat } from "node:fs/promises";
|
|
9
|
+
import { dirname, join, resolve } from "node:path";
|
|
10
|
+
async function findUp(names, from) {
|
|
11
|
+
const filenames = Array.isArray(names) ? names : [names];
|
|
12
|
+
let currentDir = resolve(from);
|
|
13
|
+
while (true) {
|
|
14
|
+
for (const name of filenames) {
|
|
15
|
+
const p = join(currentDir, name);
|
|
16
|
+
try {
|
|
17
|
+
await stat(p);
|
|
18
|
+
return p;
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const parentDir = dirname(currentDir);
|
|
23
|
+
if (parentDir === currentDir) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
currentDir = parentDir;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// packages/angular/cli/src/utilities/json-file.js
|
|
32
|
+
import { applyEdits, findNodeAtLocation, getNodeValue, modify, parse, parseTree, printParseErrorCode } from "jsonc-parser";
|
|
33
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
34
|
+
|
|
35
|
+
// packages/angular/cli/src/utilities/eol.js
|
|
36
|
+
import { EOL } from "node:os";
|
|
37
|
+
var CRLF = "\r\n";
|
|
38
|
+
var LF = "\n";
|
|
39
|
+
function getEOL(content) {
|
|
40
|
+
const newlines = content.match(/(?:\r?\n)/g);
|
|
41
|
+
if (newlines?.length) {
|
|
42
|
+
const crlf = newlines.filter((l) => l === CRLF).length;
|
|
43
|
+
const lf = newlines.length - crlf;
|
|
44
|
+
return crlf > lf ? CRLF : LF;
|
|
45
|
+
}
|
|
46
|
+
return EOL;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// packages/angular/cli/src/utilities/error.js
|
|
50
|
+
import assert from "node:assert";
|
|
51
|
+
import { inspect } from "node:util";
|
|
52
|
+
function isError(value) {
|
|
53
|
+
return value instanceof Error || typeof value === "object" && value !== null && "name" in value && "message" in value;
|
|
54
|
+
}
|
|
55
|
+
function assertIsError(value) {
|
|
56
|
+
assert(isError(value), `Expected a value to be an Error-like object, but received: ${inspect(value)}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// packages/angular/cli/src/utilities/json-file.js
|
|
60
|
+
var JSONFile = class {
|
|
61
|
+
/** The raw content of the JSON file. */
|
|
62
|
+
#content;
|
|
63
|
+
/** The end-of-line sequence used in the file. */
|
|
64
|
+
#eol;
|
|
65
|
+
/** Whether the file uses spaces for indentation. */
|
|
66
|
+
#insertSpaces = true;
|
|
67
|
+
/** The number of spaces or tabs used for indentation. */
|
|
68
|
+
#tabSize = 2;
|
|
69
|
+
/** The path to the JSON file. */
|
|
70
|
+
#path;
|
|
71
|
+
/** The parsed JSON abstract syntax tree. */
|
|
72
|
+
#jsonAst;
|
|
73
|
+
/** The raw content of the JSON file. */
|
|
74
|
+
get content() {
|
|
75
|
+
return this.#content;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates an instance of JSONFile.
|
|
79
|
+
* @param path The path to the JSON file.
|
|
80
|
+
*/
|
|
81
|
+
constructor(path2) {
|
|
82
|
+
this.#path = path2;
|
|
83
|
+
try {
|
|
84
|
+
this.#content = readFileSync(this.#path, "utf-8");
|
|
85
|
+
} catch (e) {
|
|
86
|
+
assertIsError(e);
|
|
87
|
+
if (e.code !== "ENOENT") {
|
|
88
|
+
throw e;
|
|
89
|
+
}
|
|
90
|
+
this.#content = "";
|
|
91
|
+
}
|
|
92
|
+
this.#eol = getEOL(this.#content);
|
|
93
|
+
this.#detectIndentation();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Gets the parsed JSON abstract syntax tree.
|
|
97
|
+
* The AST is lazily parsed and cached.
|
|
98
|
+
*/
|
|
99
|
+
get JsonAst() {
|
|
100
|
+
if (this.#jsonAst) {
|
|
101
|
+
return this.#jsonAst;
|
|
102
|
+
}
|
|
103
|
+
const errors = [];
|
|
104
|
+
this.#jsonAst = parseTree(this.#content, errors, { allowTrailingComma: true });
|
|
105
|
+
if (errors.length) {
|
|
106
|
+
formatError(this.#path, errors);
|
|
107
|
+
}
|
|
108
|
+
return this.#jsonAst;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Gets a value from the JSON file at a specific path.
|
|
112
|
+
* @param jsonPath The path to the value.
|
|
113
|
+
* @returns The value at the given path, or `undefined` if not found.
|
|
114
|
+
*/
|
|
115
|
+
get(jsonPath) {
|
|
116
|
+
const jsonAstNode = this.JsonAst;
|
|
117
|
+
if (!jsonAstNode) {
|
|
118
|
+
return void 0;
|
|
119
|
+
}
|
|
120
|
+
if (jsonPath.length === 0) {
|
|
121
|
+
return getNodeValue(jsonAstNode);
|
|
122
|
+
}
|
|
123
|
+
const node = findNodeAtLocation(jsonAstNode, jsonPath);
|
|
124
|
+
return node === void 0 ? void 0 : getNodeValue(node);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Modifies a value in the JSON file.
|
|
128
|
+
* @param jsonPath The path to the value to modify.
|
|
129
|
+
* @param value The new value to insert.
|
|
130
|
+
* @param insertInOrder A function to determine the insertion index, or `false` to insert at the end.
|
|
131
|
+
* @returns `true` if the modification was successful, `false` otherwise.
|
|
132
|
+
*/
|
|
133
|
+
modify(jsonPath, value, insertInOrder) {
|
|
134
|
+
if (value === void 0 && this.get(jsonPath) === void 0) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
let getInsertionIndex;
|
|
138
|
+
if (insertInOrder === void 0) {
|
|
139
|
+
const property = jsonPath.slice(-1)[0];
|
|
140
|
+
getInsertionIndex = (properties) => [...properties, property].sort().findIndex((p) => p === property);
|
|
141
|
+
} else if (insertInOrder !== false) {
|
|
142
|
+
getInsertionIndex = insertInOrder;
|
|
143
|
+
}
|
|
144
|
+
const edits = modify(this.#content, jsonPath, value, {
|
|
145
|
+
getInsertionIndex,
|
|
146
|
+
formattingOptions: {
|
|
147
|
+
insertSpaces: this.#insertSpaces,
|
|
148
|
+
tabSize: this.#tabSize,
|
|
149
|
+
eol: this.#eol
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
if (edits.length === 0) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
this.#content = applyEdits(this.#content, edits);
|
|
156
|
+
this.#jsonAst = void 0;
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Deletes a value from the JSON file at a specific path.
|
|
161
|
+
* @param jsonPath The path to the value to delete.
|
|
162
|
+
* @returns `true` if the deletion was successful, `false` otherwise.
|
|
163
|
+
*/
|
|
164
|
+
delete(jsonPath) {
|
|
165
|
+
return this.modify(jsonPath, void 0);
|
|
166
|
+
}
|
|
167
|
+
/** Saves the modified content back to the file. */
|
|
168
|
+
save() {
|
|
169
|
+
writeFileSync(this.#path, this.#content);
|
|
170
|
+
}
|
|
171
|
+
/** Detects the indentation of the file. */
|
|
172
|
+
#detectIndentation() {
|
|
173
|
+
const match = this.#content.match(/^(?:( )+|\t+)\S/m);
|
|
174
|
+
if (match) {
|
|
175
|
+
this.#insertSpaces = !!match[1];
|
|
176
|
+
this.#tabSize = match[0].length - 1;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
function readAndParseJson(path2) {
|
|
181
|
+
const errors = [];
|
|
182
|
+
const content = parse(readFileSync(path2, "utf-8"), errors, { allowTrailingComma: true });
|
|
183
|
+
if (errors.length) {
|
|
184
|
+
formatError(path2, errors);
|
|
185
|
+
}
|
|
186
|
+
return content;
|
|
187
|
+
}
|
|
188
|
+
function formatError(path2, errors) {
|
|
189
|
+
const { error, offset } = errors[0];
|
|
190
|
+
throw new Error(`Failed to parse "${path2}" as JSON AST Object. ${printParseErrorCode(error)} at location: ${offset}.`);
|
|
191
|
+
}
|
|
192
|
+
function parseJson(content) {
|
|
193
|
+
return parse(content, void 0, { allowTrailingComma: true });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// packages/angular/cli/src/utilities/config.js
|
|
197
|
+
function isJsonObject(value) {
|
|
198
|
+
return value !== void 0 && json.isJsonObject(value);
|
|
199
|
+
}
|
|
200
|
+
function createWorkspaceHost() {
|
|
201
|
+
return {
|
|
202
|
+
readFile(path2) {
|
|
203
|
+
return fs.readFile(path2, "utf-8");
|
|
204
|
+
},
|
|
205
|
+
async writeFile(path2, data) {
|
|
206
|
+
await fs.writeFile(path2, data);
|
|
207
|
+
},
|
|
208
|
+
async isDirectory(path2) {
|
|
209
|
+
try {
|
|
210
|
+
const stats = await fs.stat(path2);
|
|
211
|
+
return stats.isDirectory();
|
|
212
|
+
} catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
async isFile(path2) {
|
|
217
|
+
try {
|
|
218
|
+
const stats = await fs.stat(path2);
|
|
219
|
+
return stats.isFile();
|
|
220
|
+
} catch {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
var currentDirectory = import.meta.dirname;
|
|
227
|
+
var bundledSchemaPath = path.join(currentDirectory, "config/schema.json");
|
|
228
|
+
var workspaceSchemaPath = existsSync(bundledSchemaPath) ? bundledSchemaPath : path.join(currentDirectory, "../../lib/config/schema.json");
|
|
229
|
+
var configNames = ["angular.json", ".angular.json"];
|
|
230
|
+
var globalFileName = ".angular-config.json";
|
|
231
|
+
var defaultGlobalFilePath = path.join(os.homedir(), globalFileName);
|
|
232
|
+
function xdgConfigHome(home, configFile) {
|
|
233
|
+
const xdgConfigHome2 = process.env["XDG_CONFIG_HOME"] || path.join(home, ".config");
|
|
234
|
+
const xdgAngularHome = path.join(xdgConfigHome2, "angular");
|
|
235
|
+
return configFile ? path.join(xdgAngularHome, configFile) : xdgAngularHome;
|
|
236
|
+
}
|
|
237
|
+
function xdgConfigHomeOld(home) {
|
|
238
|
+
const p = process.env["XDG_CONFIG_HOME"] || path.join(home, ".config", "angular");
|
|
239
|
+
return path.join(p, ".angular-config.json");
|
|
240
|
+
}
|
|
241
|
+
async function projectFilePath(projectPath) {
|
|
242
|
+
return projectPath && await findUp(configNames, projectPath) || await findUp(configNames, process.cwd()) || await findUp(configNames, currentDirectory);
|
|
243
|
+
}
|
|
244
|
+
function globalFilePath() {
|
|
245
|
+
const home = os.homedir();
|
|
246
|
+
if (!home) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
const xdgConfig = xdgConfigHome(home, "config.json");
|
|
250
|
+
if (existsSync(xdgConfig)) {
|
|
251
|
+
return xdgConfig;
|
|
252
|
+
}
|
|
253
|
+
const xdgConfigOld = xdgConfigHomeOld(home);
|
|
254
|
+
if (existsSync(xdgConfigOld)) {
|
|
255
|
+
console.warn(`Old configuration location detected: ${xdgConfigOld}
|
|
256
|
+
Please move the file to the new location ~/.config/angular/config.json`);
|
|
257
|
+
return xdgConfigOld;
|
|
258
|
+
}
|
|
259
|
+
if (existsSync(defaultGlobalFilePath)) {
|
|
260
|
+
return defaultGlobalFilePath;
|
|
261
|
+
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
var AngularWorkspace = class _AngularWorkspace {
|
|
265
|
+
workspace;
|
|
266
|
+
filePath;
|
|
267
|
+
basePath;
|
|
268
|
+
constructor(workspace, filePath) {
|
|
269
|
+
this.workspace = workspace;
|
|
270
|
+
this.filePath = filePath;
|
|
271
|
+
this.basePath = path.dirname(filePath);
|
|
272
|
+
}
|
|
273
|
+
get extensions() {
|
|
274
|
+
return this.workspace.extensions;
|
|
275
|
+
}
|
|
276
|
+
get projects() {
|
|
277
|
+
return this.workspace.projects;
|
|
278
|
+
}
|
|
279
|
+
// Temporary helper functions to support refactoring
|
|
280
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
281
|
+
getCli() {
|
|
282
|
+
return this.workspace.extensions["cli"];
|
|
283
|
+
}
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
285
|
+
getProjectCli(projectName) {
|
|
286
|
+
const project = this.workspace.projects.get(projectName);
|
|
287
|
+
return project?.extensions["cli"];
|
|
288
|
+
}
|
|
289
|
+
save() {
|
|
290
|
+
return workspaces.writeWorkspace(this.workspace, createWorkspaceHost(), this.filePath, workspaces.WorkspaceFormat.JSON);
|
|
291
|
+
}
|
|
292
|
+
static async load(workspaceFilePath) {
|
|
293
|
+
const result = await workspaces.readWorkspace(workspaceFilePath, createWorkspaceHost(), workspaces.WorkspaceFormat.JSON);
|
|
294
|
+
return new _AngularWorkspace(result.workspace, workspaceFilePath);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
var cachedWorkspaces = /* @__PURE__ */ new Map();
|
|
298
|
+
async function getWorkspace(level) {
|
|
299
|
+
if (cachedWorkspaces.has(level)) {
|
|
300
|
+
return cachedWorkspaces.get(level);
|
|
301
|
+
}
|
|
302
|
+
const configPath = level === "local" ? await projectFilePath() : globalFilePath();
|
|
303
|
+
if (!configPath) {
|
|
304
|
+
if (level === "global") {
|
|
305
|
+
const globalWorkspace = new AngularWorkspace({ extensions: {}, projects: new workspaces.ProjectDefinitionCollection() }, defaultGlobalFilePath);
|
|
306
|
+
cachedWorkspaces.set(level, globalWorkspace);
|
|
307
|
+
return globalWorkspace;
|
|
308
|
+
}
|
|
309
|
+
cachedWorkspaces.set(level, void 0);
|
|
310
|
+
return void 0;
|
|
311
|
+
}
|
|
312
|
+
try {
|
|
313
|
+
const workspace = await AngularWorkspace.load(configPath);
|
|
314
|
+
cachedWorkspaces.set(level, workspace);
|
|
315
|
+
return workspace;
|
|
316
|
+
} catch (error) {
|
|
317
|
+
throw new Error(`Workspace config file cannot be loaded: ${configPath}`, { cause: error });
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
async function getWorkspaceRaw(level = "local") {
|
|
321
|
+
let configPath = level === "local" ? await projectFilePath() : globalFilePath();
|
|
322
|
+
if (!configPath) {
|
|
323
|
+
if (level === "global") {
|
|
324
|
+
configPath = defaultGlobalFilePath;
|
|
325
|
+
const globalWorkspace = await getWorkspace("global");
|
|
326
|
+
await globalWorkspace.save();
|
|
327
|
+
} else {
|
|
328
|
+
return [null, null];
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return [new JSONFile(configPath), configPath];
|
|
332
|
+
}
|
|
333
|
+
async function validateWorkspace(data, isGlobal) {
|
|
334
|
+
const schema = readAndParseJson(workspaceSchemaPath);
|
|
335
|
+
if (!isJsonObject(schema)) {
|
|
336
|
+
throw new Error("Workspace schema is not a JSON object.");
|
|
337
|
+
}
|
|
338
|
+
const schemaToValidate = isGlobal ? {
|
|
339
|
+
"$ref": "#/definitions/global",
|
|
340
|
+
definitions: schema["definitions"]
|
|
341
|
+
} : schema;
|
|
342
|
+
const { formats } = await import("@angular-devkit/schematics");
|
|
343
|
+
const registry = new json.schema.CoreSchemaRegistry(formats.standardFormats);
|
|
344
|
+
const validator = await registry.compile(schemaToValidate);
|
|
345
|
+
const { success, errors } = await validator(data);
|
|
346
|
+
if (!success) {
|
|
347
|
+
throw new json.schema.SchemaValidationException(errors);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function findProjectByPath(workspace, location) {
|
|
351
|
+
const isInside = (base, potential) => {
|
|
352
|
+
const absoluteBase = path.resolve(workspace.basePath, base);
|
|
353
|
+
const absolutePotential = path.resolve(workspace.basePath, potential);
|
|
354
|
+
const relativePotential = path.relative(absoluteBase, absolutePotential);
|
|
355
|
+
if (!relativePotential.startsWith("..") && !path.isAbsolute(relativePotential)) {
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
return false;
|
|
359
|
+
};
|
|
360
|
+
const projects = Array.from(workspace.projects).map(([name, project]) => [project.root, name]).filter((tuple) => isInside(tuple[0], location)).sort((a, b) => b[0].length - a[0].length);
|
|
361
|
+
if (projects.length === 0) {
|
|
362
|
+
return null;
|
|
363
|
+
} else if (projects.length > 1) {
|
|
364
|
+
const found = /* @__PURE__ */ new Set();
|
|
365
|
+
const sameRoots = projects.filter((v) => {
|
|
366
|
+
if (!found.has(v[0])) {
|
|
367
|
+
found.add(v[0]);
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
return true;
|
|
371
|
+
});
|
|
372
|
+
if (sameRoots.length > 0) {
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return projects[0][1];
|
|
377
|
+
}
|
|
378
|
+
function getProjectByCwd(workspace) {
|
|
379
|
+
if (workspace.projects.size === 1) {
|
|
380
|
+
return Array.from(workspace.projects.keys())[0];
|
|
381
|
+
}
|
|
382
|
+
const project = findProjectByPath(workspace, process.cwd());
|
|
383
|
+
if (project) {
|
|
384
|
+
return project;
|
|
385
|
+
}
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
async function getConfiguredPackageManager() {
|
|
389
|
+
const getPackageManager = (source) => {
|
|
390
|
+
if (isJsonObject(source)) {
|
|
391
|
+
const value = source["packageManager"];
|
|
392
|
+
if (value && typeof value === "string") {
|
|
393
|
+
return value;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return null;
|
|
397
|
+
};
|
|
398
|
+
let result = null;
|
|
399
|
+
const workspace = await getWorkspace("local");
|
|
400
|
+
if (workspace) {
|
|
401
|
+
const project = getProjectByCwd(workspace);
|
|
402
|
+
if (project) {
|
|
403
|
+
result = getPackageManager(workspace.projects.get(project)?.extensions["cli"]);
|
|
404
|
+
}
|
|
405
|
+
result ??= getPackageManager(workspace.extensions["cli"]);
|
|
406
|
+
}
|
|
407
|
+
if (!result) {
|
|
408
|
+
const globalOptions = await getWorkspace("global");
|
|
409
|
+
result = getPackageManager(globalOptions?.extensions["cli"]);
|
|
410
|
+
}
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
413
|
+
async function getSchematicDefaults(collection, schematic, project) {
|
|
414
|
+
const result = {};
|
|
415
|
+
const mergeOptions = (source) => {
|
|
416
|
+
if (isJsonObject(source)) {
|
|
417
|
+
Object.assign(result, source[`${collection}:${schematic}`]);
|
|
418
|
+
const collectionOptions = source[collection];
|
|
419
|
+
if (isJsonObject(collectionOptions)) {
|
|
420
|
+
Object.assign(result, collectionOptions[schematic]);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
const globalOptions = await getWorkspace("global");
|
|
425
|
+
mergeOptions(globalOptions?.extensions["schematics"]);
|
|
426
|
+
const workspace = await getWorkspace("local");
|
|
427
|
+
if (workspace) {
|
|
428
|
+
mergeOptions(workspace.extensions["schematics"]);
|
|
429
|
+
project = project || getProjectByCwd(workspace);
|
|
430
|
+
if (project) {
|
|
431
|
+
mergeOptions(workspace.projects.get(project)?.extensions["schematics"]);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return result;
|
|
435
|
+
}
|
|
436
|
+
async function isWarningEnabled(warning) {
|
|
437
|
+
const getWarning = (source) => {
|
|
438
|
+
if (isJsonObject(source)) {
|
|
439
|
+
const warnings = source["warnings"];
|
|
440
|
+
if (isJsonObject(warnings)) {
|
|
441
|
+
const value = warnings[warning];
|
|
442
|
+
if (typeof value == "boolean") {
|
|
443
|
+
return value;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
let result;
|
|
449
|
+
const workspace = await getWorkspace("local");
|
|
450
|
+
if (workspace) {
|
|
451
|
+
const project = getProjectByCwd(workspace);
|
|
452
|
+
if (project) {
|
|
453
|
+
result = getWarning(workspace.projects.get(project)?.extensions["cli"]);
|
|
454
|
+
}
|
|
455
|
+
result = result ?? getWarning(workspace.extensions["cli"]);
|
|
456
|
+
}
|
|
457
|
+
if (result === void 0) {
|
|
458
|
+
const globalOptions = await getWorkspace("global");
|
|
459
|
+
result = getWarning(globalOptions?.extensions["cli"]);
|
|
460
|
+
}
|
|
461
|
+
return result ?? true;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export {
|
|
465
|
+
assertIsError,
|
|
466
|
+
parseJson,
|
|
467
|
+
workspaceSchemaPath,
|
|
468
|
+
AngularWorkspace,
|
|
469
|
+
getWorkspace,
|
|
470
|
+
getWorkspaceRaw,
|
|
471
|
+
validateWorkspace,
|
|
472
|
+
getProjectByCwd,
|
|
473
|
+
getConfiguredPackageManager,
|
|
474
|
+
getSchematicDefaults,
|
|
475
|
+
isWarningEnabled
|
|
476
|
+
};
|
|
477
|
+
/**
|
|
478
|
+
* @license
|
|
479
|
+
* Copyright Google LLC All Rights Reserved.
|
|
480
|
+
*
|
|
481
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
482
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
483
|
+
*/
|