@angular/cli 18.1.0-rc.1 → 18.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/cli",
3
- "version": "18.1.0-rc.1",
3
+ "version": "18.2.0-next.0",
4
4
  "description": "CLI tool for Angular",
5
5
  "main": "lib/cli/index.js",
6
6
  "bin": {
@@ -25,18 +25,18 @@
25
25
  },
26
26
  "homepage": "https://github.com/angular/angular-cli",
27
27
  "dependencies": {
28
- "@angular-devkit/architect": "0.1801.0-rc.1",
29
- "@angular-devkit/core": "18.1.0-rc.1",
30
- "@angular-devkit/schematics": "18.1.0-rc.1",
31
- "@inquirer/prompts": "5.0.7",
28
+ "@angular-devkit/architect": "0.1802.0-next.0",
29
+ "@angular-devkit/core": "18.2.0-next.0",
30
+ "@angular-devkit/schematics": "18.2.0-next.0",
31
+ "@inquirer/prompts": "5.1.2",
32
32
  "@listr2/prompt-adapter-inquirer": "2.0.13",
33
- "@schematics/angular": "18.1.0-rc.1",
33
+ "@schematics/angular": "18.2.0-next.0",
34
34
  "@yarnpkg/lockfile": "1.1.0",
35
35
  "ini": "4.1.3",
36
36
  "jsonc-parser": "3.3.1",
37
37
  "listr2": "8.2.3",
38
38
  "npm-package-arg": "11.0.2",
39
- "npm-pick-manifest": "9.0.1",
39
+ "npm-pick-manifest": "9.1.0",
40
40
  "pacote": "18.0.6",
41
41
  "resolve": "1.22.8",
42
42
  "semver": "7.6.2",
@@ -46,14 +46,14 @@
46
46
  "ng-update": {
47
47
  "migrations": "@schematics/angular/migrations/migration-collection.json",
48
48
  "packageGroup": {
49
- "@angular/cli": "18.1.0-rc.1",
50
- "@angular/build": "18.1.0-rc.1",
51
- "@angular/ssr": "18.1.0-rc.1",
52
- "@angular-devkit/architect": "0.1801.0-rc.1",
53
- "@angular-devkit/build-angular": "18.1.0-rc.1",
54
- "@angular-devkit/build-webpack": "0.1801.0-rc.1",
55
- "@angular-devkit/core": "18.1.0-rc.1",
56
- "@angular-devkit/schematics": "18.1.0-rc.1"
49
+ "@angular/cli": "18.2.0-next.0",
50
+ "@angular/build": "18.2.0-next.0",
51
+ "@angular/ssr": "18.2.0-next.0",
52
+ "@angular-devkit/architect": "0.1802.0-next.0",
53
+ "@angular-devkit/build-angular": "18.2.0-next.0",
54
+ "@angular-devkit/build-webpack": "0.1802.0-next.0",
55
+ "@angular-devkit/core": "18.2.0-next.0",
56
+ "@angular-devkit/schematics": "18.2.0-next.0"
57
57
  }
58
58
  },
59
59
  "packageManager": "yarn@4.3.0",
@@ -5,6 +5,8 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
+ import { Target } from '@angular-devkit/architect';
9
+ import { workspaces } from '@angular-devkit/core';
8
10
  import { Argv } from 'yargs';
9
11
  import { ArchitectBaseCommandModule } from './architect-base-command-module';
10
12
  import { CommandModuleImplementation, Options, OtherOptions } from './command-module';
@@ -14,6 +16,7 @@ export interface ArchitectCommandArgs {
14
16
  }
15
17
  export declare abstract class ArchitectCommandModule extends ArchitectBaseCommandModule<ArchitectCommandArgs> implements CommandModuleImplementation<ArchitectCommandArgs> {
16
18
  abstract readonly multiTarget: boolean;
19
+ findDefaultBuilderName?(project: workspaces.ProjectDefinition, target: Target): Promise<string | undefined>;
17
20
  builder(argv: Argv): Promise<Argv<ArchitectCommandArgs>>;
18
21
  run(options: Options<ArchitectCommandArgs> & OtherOptions): Promise<number | void>;
19
22
  private getArchitectProject;
@@ -58,6 +58,24 @@ let ArchitectCommandModule = (() => {
58
58
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
59
59
  }
60
60
  async builder(argv) {
61
+ const target = this.getArchitectTarget();
62
+ // Add default builder if target is not in project and a command default is provided
63
+ if (this.findDefaultBuilderName && this.context.workspace) {
64
+ for (const [project, projectDefinition] of this.context.workspace.projects) {
65
+ if (projectDefinition.targets.has(target)) {
66
+ continue;
67
+ }
68
+ const defaultBuilder = await this.findDefaultBuilderName(projectDefinition, {
69
+ project,
70
+ target,
71
+ });
72
+ if (defaultBuilder) {
73
+ projectDefinition.targets.set(target, {
74
+ builder: defaultBuilder,
75
+ });
76
+ }
77
+ }
78
+ }
61
79
  const project = this.getArchitectProject();
62
80
  const { jsonHelp, getYargsCompletions, help } = this.context.args.options;
63
81
  const localYargs = argv
@@ -84,7 +102,6 @@ let ArchitectCommandModule = (() => {
84
102
  if (!project) {
85
103
  return localYargs;
86
104
  }
87
- const target = this.getArchitectTarget();
88
105
  const schemaOptions = await this.getArchitectTargetOptions({
89
106
  project,
90
107
  target,
@@ -14,7 +14,6 @@ const fs_1 = require("fs");
14
14
  const jsonc_parser_1 = require("jsonc-parser");
15
15
  const module_1 = require("module");
16
16
  const path_1 = require("path");
17
- const util_1 = require("util");
18
17
  const vm_1 = require("vm");
19
18
  const error_1 = require("../../utilities/error");
20
19
  /**
@@ -165,34 +164,16 @@ function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
165
164
  };
166
165
  // Setup a wrapper function to capture the module's exports
167
166
  const schematicCode = (0, fs_1.readFileSync)(schematicFile, 'utf8');
168
- // `module` is required due to @angular/localize ng-add being in UMD format
169
- const headerCode = '(function() {\nvar exports = {};\nvar module = { exports };\n';
170
- const footerCode = exportName
171
- ? `\nreturn module.exports['${exportName}'];});`
172
- : '\nreturn module.exports;});';
173
- const script = new vm_1.Script(headerCode + schematicCode + footerCode, {
167
+ const script = new vm_1.Script(module_1.Module.wrap(schematicCode), {
174
168
  filename: schematicFile,
175
- lineOffset: 3,
169
+ lineOffset: 1,
176
170
  });
177
- const context = {
178
- __dirname: schematicDirectory,
179
- __filename: schematicFile,
180
- Buffer,
181
- // TextEncoder is used by the compiler to generate i18n message IDs. See:
182
- // https://github.com/angular/angular/blob/main/packages/compiler/src/i18n/digest.ts#L17
183
- // It is referenced globally, because it may be run either on the browser or the server.
184
- // Usually Node exposes it globally, but in order for it to work, our custom context
185
- // has to expose it too. Issue context: https://github.com/angular/angular/issues/48940.
186
- TextEncoder: util_1.TextEncoder,
187
- console,
188
- process,
189
- get global() {
190
- return this;
191
- },
192
- require: customRequire,
171
+ const schematicModule = new module_1.Module(schematicFile);
172
+ const moduleFactory = script.runInThisContext();
173
+ return () => {
174
+ moduleFactory(schematicModule.exports, customRequire, schematicModule, schematicFile, schematicDirectory);
175
+ return exportName ? schematicModule.exports[exportName] : schematicModule.exports;
193
176
  };
194
- const exportsFactory = script.runInNewContext(context);
195
- return exportsFactory;
196
177
  }
197
178
  function loadBuiltinModule(id) {
198
179
  return undefined;
@@ -5,6 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
+ import { workspaces } from '@angular-devkit/core';
8
9
  import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
9
10
  import { CommandModuleImplementation } from '../../command-builder/command-module';
10
11
  export default class ExtractI18nCommandModule extends ArchitectCommandModule implements CommandModuleImplementation {
@@ -12,4 +13,5 @@ export default class ExtractI18nCommandModule extends ArchitectCommandModule imp
12
13
  command: string;
13
14
  describe: string;
14
15
  longDescriptionPath?: string | undefined;
16
+ findDefaultBuilderName(project: workspaces.ProjectDefinition): Promise<string | undefined>;
15
17
  }
@@ -7,11 +7,41 @@
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
+ const node_module_1 = require("node:module");
11
+ const node_path_1 = require("node:path");
10
12
  const architect_command_module_1 = require("../../command-builder/architect-command-module");
11
13
  class ExtractI18nCommandModule extends architect_command_module_1.ArchitectCommandModule {
12
14
  multiTarget = false;
13
15
  command = 'extract-i18n [project]';
14
16
  describe = 'Extracts i18n messages from source code.';
15
17
  longDescriptionPath;
18
+ async findDefaultBuilderName(project) {
19
+ // Only application type projects have a default i18n extraction target
20
+ if (project.extensions['projectType'] !== 'application') {
21
+ return;
22
+ }
23
+ const buildTarget = project.targets.get('build');
24
+ if (!buildTarget) {
25
+ // No default if there is no build target
26
+ return;
27
+ }
28
+ // Provide a default based on the defined builder for the 'build' target
29
+ switch (buildTarget.builder) {
30
+ case '@angular-devkit/build-angular:application':
31
+ case '@angular-devkit/build-angular:browser-esbuild':
32
+ case '@angular-devkit/build-angular:browser':
33
+ return '@angular-devkit/build-angular:extract-i18n';
34
+ case '@angular/build:application':
35
+ return '@angular/build:extract-i18n';
36
+ }
37
+ // For other builders, check for `@angular-devkit/build-angular` and use if found.
38
+ // This package is safer to use since it supports both application builder types.
39
+ try {
40
+ const projectRequire = (0, node_module_1.createRequire)((0, node_path_1.join)(this.context.root, project.root) + '/');
41
+ projectRequire.resolve('@angular-devkit/build-angular');
42
+ return '@angular-devkit/build-angular:extract-i18n';
43
+ }
44
+ catch { }
45
+ }
16
46
  }
17
47
  exports.default = ExtractI18nCommandModule;
@@ -25,5 +25,5 @@ class Version {
25
25
  }
26
26
  }
27
27
  // TODO(bazel): Convert this to use build-time version stamping after flipping the build script to use bazel
28
- // export const VERSION = new Version('18.1.0-rc.1');
28
+ // export const VERSION = new Version('18.2.0-next.0');
29
29
  exports.VERSION = new Version(JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../package.json'), 'utf-8')).version);