@schematics/angular 14.0.1 → 14.1.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/e2e/index.js CHANGED
@@ -7,14 +7,22 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- const core_1 = require("@angular-devkit/core");
11
10
  const schematics_1 = require("@angular-devkit/schematics");
12
- const utility_1 = require("../utility");
13
- const dependencies_1 = require("../utility/dependencies");
11
+ const utility_1 = require("@schematics/angular/utility");
12
+ const path_1 = require("path");
14
13
  const json_file_1 = require("../utility/json-file");
15
14
  const latest_versions_1 = require("../utility/latest-versions");
16
- const paths_1 = require("../utility/paths");
17
- const workspace_models_1 = require("../utility/workspace-models");
15
+ /**
16
+ * The list of development dependencies used by the E2E protractor-based builder.
17
+ * The versions are sourced from the latest versions `../utility/latest-versions/package.json`
18
+ * file which is automatically updated via renovate.
19
+ */
20
+ const E2E_DEV_DEPENDENCIES = Object.freeze([
21
+ 'protractor',
22
+ 'jasmine-spec-reporter',
23
+ 'ts-node',
24
+ '@types/node',
25
+ ]);
18
26
  function addScriptsToPackageJson() {
19
27
  return (host) => {
20
28
  const pkgJson = new json_file_1.JSONFile(host, 'package.json');
@@ -25,64 +33,41 @@ function addScriptsToPackageJson() {
25
33
  };
26
34
  }
27
35
  function default_1(options) {
28
- return async (host) => {
29
- const appProject = options.relatedAppName;
30
- const workspace = await (0, utility_1.readWorkspace)(host);
31
- const project = workspace.projects.get(appProject);
36
+ const { relatedAppName } = options;
37
+ return (0, utility_1.updateWorkspace)((workspace) => {
38
+ const project = workspace.projects.get(relatedAppName);
32
39
  if (!project) {
33
- throw new schematics_1.SchematicsException(`Project name "${appProject}" doesn't not exist.`);
40
+ throw new schematics_1.SchematicsException(`Project name "${relatedAppName}" doesn't not exist.`);
34
41
  }
35
- const root = (0, core_1.join)((0, core_1.normalize)(project.root), 'e2e');
42
+ const e2eRootPath = path_1.posix.join(project.root, 'e2e');
36
43
  project.targets.add({
37
44
  name: 'e2e',
38
- builder: workspace_models_1.Builders.Protractor,
45
+ builder: utility_1.AngularBuilder.Protractor,
39
46
  defaultConfiguration: 'development',
40
47
  options: {
41
- protractorConfig: `${root}/protractor.conf.js`,
48
+ protractorConfig: path_1.posix.join(e2eRootPath, 'protractor.conf.js'),
42
49
  },
43
50
  configurations: {
44
51
  production: {
45
- devServerTarget: `${options.relatedAppName}:serve:production`,
52
+ devServerTarget: `${relatedAppName}:serve:production`,
46
53
  },
47
54
  development: {
48
- devServerTarget: `${options.relatedAppName}:serve:development`,
55
+ devServerTarget: `${relatedAppName}:serve:development`,
49
56
  },
50
57
  },
51
58
  });
52
- await (0, utility_1.writeWorkspace)(host, workspace);
53
59
  return (0, schematics_1.chain)([
54
60
  (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
55
61
  (0, schematics_1.applyTemplates)({
56
62
  utils: schematics_1.strings,
57
63
  ...options,
58
- relativePathToWorkspaceRoot: (0, paths_1.relativePathToWorkspaceRoot)(root),
64
+ relativePathToWorkspaceRoot: path_1.posix.relative(path_1.posix.join('/', e2eRootPath), '/'),
59
65
  }),
60
- (0, schematics_1.move)(root),
66
+ (0, schematics_1.move)(e2eRootPath),
61
67
  ])),
62
- (host) => [
63
- {
64
- type: dependencies_1.NodeDependencyType.Dev,
65
- name: 'protractor',
66
- version: '~7.0.0',
67
- },
68
- {
69
- type: dependencies_1.NodeDependencyType.Dev,
70
- name: 'jasmine-spec-reporter',
71
- version: '~7.0.0',
72
- },
73
- {
74
- type: dependencies_1.NodeDependencyType.Dev,
75
- name: 'ts-node',
76
- version: latest_versions_1.latestVersions['ts-node'],
77
- },
78
- {
79
- type: dependencies_1.NodeDependencyType.Dev,
80
- name: '@types/node',
81
- version: latest_versions_1.latestVersions['@types/node'],
82
- },
83
- ].forEach((dep) => (0, dependencies_1.addPackageJsonDependency)(host, dep)),
68
+ ...E2E_DEV_DEPENDENCIES.map((name) => (0, utility_1.addDependency)(name, latest_versions_1.latestVersions[name], { type: utility_1.DependencyType.Dev })),
84
69
  addScriptsToPackageJson(),
85
70
  ]);
86
- };
71
+ });
87
72
  }
88
73
  exports.default = default_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "14.0.1",
3
+ "version": "14.1.0-next.0",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "schematics": "./collection.json",
25
25
  "dependencies": {
26
- "@angular-devkit/core": "14.0.1",
27
- "@angular-devkit/schematics": "14.0.1",
26
+ "@angular-devkit/core": "14.1.0-next.0",
27
+ "@angular-devkit/schematics": "14.1.0-next.0",
28
28
  "jsonc-parser": "3.0.0"
29
29
  },
30
30
  "repository": {
@@ -15,6 +15,29 @@ export declare enum DependencyType {
15
15
  Dev = "devDependencies",
16
16
  Peer = "peerDependencies"
17
17
  }
18
+ /**
19
+ * An enum used to specify the dependency installation behavior for the {@link addDependency}
20
+ * schematics rule. The installation behavior affects if and when {@link NodePackageInstallTask}
21
+ * will be scheduled when using the rule.
22
+ */
23
+ export declare enum InstallBehavior {
24
+ /**
25
+ * No installation will occur as a result of the rule when specified.
26
+ *
27
+ * NOTE: This does not prevent other rules from scheduling a {@link NodePackageInstallTask}
28
+ * which may install the dependency.
29
+ */
30
+ None = 0,
31
+ /**
32
+ * Automatically determine the need to schedule a {@link NodePackageInstallTask} based on
33
+ * previous usage of the {@link addDependency} within the schematic.
34
+ */
35
+ Auto = 1,
36
+ /**
37
+ * Always schedule a {@link NodePackageInstallTask} when the rule is executed.
38
+ */
39
+ Always = 2
40
+ }
18
41
  /**
19
42
  * Adds a package as a dependency to a `package.json`. By default the `package.json` located
20
43
  * at the schematic's root will be used. The `manifestPath` option can be used to explicitly specify
@@ -42,4 +65,10 @@ export declare function addDependency(name: string, specifier: string, options?:
42
65
  * Defaults to `/package.json`.
43
66
  */
44
67
  packageJsonPath?: string;
68
+ /**
69
+ * The dependency installation behavior to use to determine whether a
70
+ * {@link NodePackageInstallTask} should be scheduled after adding the dependency.
71
+ * Defaults to {@link InstallBehavior.Auto}.
72
+ */
73
+ install?: InstallBehavior;
45
74
  }): Rule;
@@ -30,7 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
30
30
  return result;
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.addDependency = exports.DependencyType = void 0;
33
+ exports.addDependency = exports.InstallBehavior = exports.DependencyType = void 0;
34
34
  const tasks_1 = require("@angular-devkit/schematics/tasks");
35
35
  const path = __importStar(require("path"));
36
36
  const installTasks = new WeakMap();
@@ -44,6 +44,30 @@ var DependencyType;
44
44
  DependencyType["Dev"] = "devDependencies";
45
45
  DependencyType["Peer"] = "peerDependencies";
46
46
  })(DependencyType = exports.DependencyType || (exports.DependencyType = {}));
47
+ /**
48
+ * An enum used to specify the dependency installation behavior for the {@link addDependency}
49
+ * schematics rule. The installation behavior affects if and when {@link NodePackageInstallTask}
50
+ * will be scheduled when using the rule.
51
+ */
52
+ var InstallBehavior;
53
+ (function (InstallBehavior) {
54
+ /**
55
+ * No installation will occur as a result of the rule when specified.
56
+ *
57
+ * NOTE: This does not prevent other rules from scheduling a {@link NodePackageInstallTask}
58
+ * which may install the dependency.
59
+ */
60
+ InstallBehavior[InstallBehavior["None"] = 0] = "None";
61
+ /**
62
+ * Automatically determine the need to schedule a {@link NodePackageInstallTask} based on
63
+ * previous usage of the {@link addDependency} within the schematic.
64
+ */
65
+ InstallBehavior[InstallBehavior["Auto"] = 1] = "Auto";
66
+ /**
67
+ * Always schedule a {@link NodePackageInstallTask} when the rule is executed.
68
+ */
69
+ InstallBehavior[InstallBehavior["Always"] = 2] = "Always";
70
+ })(InstallBehavior = exports.InstallBehavior || (exports.InstallBehavior = {}));
47
71
  /**
48
72
  * Adds a package as a dependency to a `package.json`. By default the `package.json` located
49
73
  * at the schematic's root will be used. The `manifestPath` option can be used to explicitly specify
@@ -61,7 +85,7 @@ var DependencyType;
61
85
  * @returns A Schematics {@link Rule}
62
86
  */
63
87
  function addDependency(name, specifier, options = {}) {
64
- const { type = DependencyType.Default, packageJsonPath = '/package.json' } = options;
88
+ const { type = DependencyType.Default, packageJsonPath = '/package.json', install = InstallBehavior.Auto, } = options;
65
89
  return (tree, context) => {
66
90
  var _a;
67
91
  const manifest = tree.readJson(packageJsonPath);
@@ -87,7 +111,8 @@ function addDependency(name, specifier, options = {}) {
87
111
  }
88
112
  tree.overwrite(packageJsonPath, JSON.stringify(manifest, null, 2));
89
113
  const installPaths = (_a = installTasks.get(context)) !== null && _a !== void 0 ? _a : new Set();
90
- if (!installPaths.has(packageJsonPath)) {
114
+ if (install === InstallBehavior.Always ||
115
+ (install === InstallBehavior.Auto && !installPaths.has(packageJsonPath))) {
91
116
  context.addTask(new tasks_1.NodePackageInstallTask({ workingDirectory: path.dirname(packageJsonPath) }));
92
117
  installPaths.add(packageJsonPath);
93
118
  installTasks.set(context, installPaths);
@@ -7,4 +7,4 @@
7
7
  */
8
8
  export { ProjectDefinition, TargetDefinition, WorkspaceDefinition, getWorkspace as readWorkspace, updateWorkspace, writeWorkspace, } from './workspace';
9
9
  export { Builders as AngularBuilder } from './workspace-models';
10
- export { DependencyType, addDependency } from './dependency';
10
+ export { DependencyType, InstallBehavior, addDependency } from './dependency';
package/utility/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.addDependency = exports.DependencyType = exports.AngularBuilder = exports.writeWorkspace = exports.updateWorkspace = exports.readWorkspace = void 0;
10
+ exports.addDependency = exports.InstallBehavior = exports.DependencyType = exports.AngularBuilder = exports.writeWorkspace = exports.updateWorkspace = exports.readWorkspace = void 0;
11
11
  // Workspace related rules and types
12
12
  var workspace_1 = require("./workspace");
13
13
  Object.defineProperty(exports, "readWorkspace", { enumerable: true, get: function () { return workspace_1.getWorkspace; } });
@@ -18,4 +18,5 @@ Object.defineProperty(exports, "AngularBuilder", { enumerable: true, get: functi
18
18
  // Package dependency related rules and types
19
19
  var dependency_1 = require("./dependency");
20
20
  Object.defineProperty(exports, "DependencyType", { enumerable: true, get: function () { return dependency_1.DependencyType; } });
21
+ Object.defineProperty(exports, "InstallBehavior", { enumerable: true, get: function () { return dependency_1.InstallBehavior; } });
21
22
  Object.defineProperty(exports, "addDependency", { enumerable: true, get: function () { return dependency_1.addDependency; } });
@@ -6,15 +6,17 @@
6
6
  "@types/jasmine": "~4.0.0",
7
7
  "@types/node": "^14.15.0",
8
8
  "jasmine-core": "~4.1.0",
9
+ "jasmine-spec-reporter": "~7.0.0",
9
10
  "karma-chrome-launcher": "~3.1.0",
10
11
  "karma-coverage": "~2.2.0",
11
- "karma-jasmine-html-reporter": "~1.7.0",
12
+ "karma-jasmine-html-reporter": "~2.0.0",
12
13
  "karma-jasmine": "~5.0.0",
13
14
  "karma": "~6.3.0",
14
- "ng-packagr": "^14.0.0",
15
+ "ng-packagr": "^14.0.0-next.8",
16
+ "protractor": "~7.0.0",
15
17
  "rxjs": "~7.5.0",
16
18
  "tslib": "^2.3.0",
17
- "ts-node": "~10.7.0",
19
+ "ts-node": "~10.8.0",
18
20
  "typescript": "~4.7.2",
19
21
  "zone.js": "~0.11.4"
20
22
  }
@@ -13,7 +13,7 @@ exports.latestVersions = {
13
13
  // but ts_library doesn't support JSON inputs.
14
14
  ...require('./latest-versions/package.json')['dependencies'],
15
15
  // As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
16
- Angular: '^14.0.0',
16
+ Angular: '^14.0.0-next.0',
17
17
  // Since @angular-devkit/build-angular and @schematics/angular are always
18
18
  // published together from the same monorepo, and they are both
19
19
  // non-experimental, they will always have the same version.