@angular/cli 14.0.0-rc.3 → 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/lib/cli/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.VERSION = void 0;
11
- const node_1 = require("@angular-devkit/core/node");
11
+ const core_1 = require("@angular-devkit/core");
12
12
  const util_1 = require("util");
13
13
  const command_module_1 = require("../../src/command-builder/command-module");
14
14
  const command_runner_1 = require("../../src/command-builder/command-runner");
@@ -17,22 +17,44 @@ const environment_options_1 = require("../../src/utilities/environment-options")
17
17
  const log_file_1 = require("../../src/utilities/log-file");
18
18
  var version_1 = require("../../src/utilities/version");
19
19
  Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
20
+ const MIN_NODEJS_VERISON = [14, 15];
20
21
  /* eslint-disable no-console */
21
22
  async function default_1(options) {
22
23
  // This node version check ensures that the requirements of the project instance of the CLI are met
23
24
  const [major, minor] = process.versions.node.split('.').map((part) => Number(part));
24
- if (major < 14 || (major === 14 && minor < 15)) {
25
+ if (major < MIN_NODEJS_VERISON[0] ||
26
+ (major === MIN_NODEJS_VERISON[0] && minor < MIN_NODEJS_VERISON[1])) {
25
27
  process.stderr.write(`Node.js version ${process.version} detected.\n` +
26
- 'The Angular CLI requires a minimum v14.15.\n\n' +
28
+ `The Angular CLI requires a minimum of v${MIN_NODEJS_VERISON[0]}.${MIN_NODEJS_VERISON[1]}.\n\n` +
27
29
  'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n');
28
30
  return 3;
29
31
  }
30
- const logger = (0, node_1.createConsoleLogger)(environment_options_1.ngDebug, process.stdout, process.stderr, {
31
- info: (s) => (color_1.colors.enabled ? s : (0, color_1.removeColor)(s)),
32
- debug: (s) => (color_1.colors.enabled ? s : (0, color_1.removeColor)(s)),
33
- warn: (s) => (color_1.colors.enabled ? color_1.colors.bold.yellow(s) : (0, color_1.removeColor)(s)),
34
- error: (s) => (color_1.colors.enabled ? color_1.colors.bold.red(s) : (0, color_1.removeColor)(s)),
35
- fatal: (s) => (color_1.colors.enabled ? color_1.colors.bold.red(s) : (0, color_1.removeColor)(s)),
32
+ const colorLevels = {
33
+ info: (s) => s,
34
+ debug: (s) => s,
35
+ warn: (s) => color_1.colors.bold.yellow(s),
36
+ error: (s) => color_1.colors.bold.red(s),
37
+ fatal: (s) => color_1.colors.bold.red(s),
38
+ };
39
+ const logger = new core_1.logging.IndentLogger('cli-main-logger');
40
+ const logInfo = console.log;
41
+ const logError = console.error;
42
+ const loggerFinished = logger.forEach((entry) => {
43
+ if (!environment_options_1.ngDebug && entry.level === 'debug') {
44
+ return;
45
+ }
46
+ const color = color_1.colors.enabled ? colorLevels[entry.level] : color_1.removeColor;
47
+ const message = color(entry.message);
48
+ switch (entry.level) {
49
+ case 'warn':
50
+ case 'fatal':
51
+ case 'error':
52
+ logError(message);
53
+ break;
54
+ default:
55
+ logInfo(message);
56
+ break;
57
+ }
36
58
  });
37
59
  // Redirect console to logger
38
60
  console.info = console.log = function (...args) {
@@ -77,5 +99,9 @@ async function default_1(options) {
77
99
  }
78
100
  return 1;
79
101
  }
102
+ finally {
103
+ logger.complete();
104
+ await loggerFinished;
105
+ }
80
106
  }
81
107
  exports.default = default_1;
package/lib/init.js CHANGED
@@ -39,6 +39,13 @@ const color_1 = require("../src/utilities/color");
39
39
  const config_1 = require("../src/utilities/config");
40
40
  const environment_options_1 = require("../src/utilities/environment-options");
41
41
  const version_1 = require("../src/utilities/version");
42
+ /**
43
+ * Angular CLI versions prior to v14 may not exit correctly if not forcibly exited
44
+ * via `process.exit()`. When bootstrapping, `forceExit` will be set to `true`
45
+ * if the local CLI version is less than v14 to prevent the CLI from hanging on
46
+ * exit in those cases.
47
+ */
48
+ let forceExit = false;
42
49
  (async () => {
43
50
  var _a;
44
51
  /**
@@ -74,6 +81,10 @@ const version_1 = require("../src/utilities/version");
74
81
  console.error('Version mismatch check skipped. Unable to retrieve local version: ' + error);
75
82
  }
76
83
  }
84
+ // Ensure older versions of the CLI fully exit
85
+ if ((0, semver_1.major)(localVersion) < 14) {
86
+ forceExit = true;
87
+ }
77
88
  let isGlobalGreater = false;
78
89
  try {
79
90
  isGlobalGreater = !!localVersion && globalVersion.compare(localVersion) > 0;
@@ -120,6 +131,9 @@ const version_1 = require("../src/utilities/version");
120
131
  });
121
132
  })
122
133
  .then((exitCode) => {
134
+ if (forceExit) {
135
+ process.exit(exitCode);
136
+ }
123
137
  process.exitCode = exitCode;
124
138
  })
125
139
  .catch((err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/cli",
3
- "version": "14.0.0-rc.3",
3
+ "version": "14.1.0-next.0",
4
4
  "description": "CLI tool for Angular",
5
5
  "main": "lib/cli/index.js",
6
6
  "bin": {
@@ -25,12 +25,12 @@
25
25
  },
26
26
  "homepage": "https://github.com/angular/angular-cli",
27
27
  "dependencies": {
28
- "@angular-devkit/architect": "0.1400.0-rc.3",
29
- "@angular-devkit/core": "14.0.0-rc.3",
30
- "@angular-devkit/schematics": "14.0.0-rc.3",
31
- "@schematics/angular": "14.0.0-rc.3",
28
+ "@angular-devkit/architect": "0.1401.0-next.0",
29
+ "@angular-devkit/core": "14.1.0-next.0",
30
+ "@angular-devkit/schematics": "14.1.0-next.0",
31
+ "@schematics/angular": "14.1.0-next.0",
32
32
  "@yarnpkg/lockfile": "1.1.0",
33
- "ansi-colors": "4.1.1",
33
+ "ansi-colors": "4.1.3",
34
34
  "debug": "4.3.4",
35
35
  "ini": "3.0.0",
36
36
  "inquirer": "8.2.4",
@@ -39,22 +39,22 @@
39
39
  "npm-pick-manifest": "7.0.1",
40
40
  "open": "8.4.0",
41
41
  "ora": "5.4.1",
42
- "pacote": "13.3.0",
42
+ "pacote": "13.6.0",
43
43
  "resolve": "1.22.0",
44
44
  "semver": "7.3.7",
45
45
  "symbol-observable": "4.0.0",
46
46
  "uuid": "8.3.2",
47
- "yargs": "17.4.1"
47
+ "yargs": "17.5.1"
48
48
  },
49
49
  "ng-update": {
50
50
  "migrations": "@schematics/angular/migrations/migration-collection.json",
51
51
  "packageGroup": {
52
- "@angular/cli": "14.0.0-rc.3",
53
- "@angular-devkit/architect": "0.1400.0-rc.3",
54
- "@angular-devkit/build-angular": "14.0.0-rc.3",
55
- "@angular-devkit/build-webpack": "0.1400.0-rc.3",
56
- "@angular-devkit/core": "14.0.0-rc.3",
57
- "@angular-devkit/schematics": "14.0.0-rc.3"
52
+ "@angular/cli": "14.1.0-next.0",
53
+ "@angular-devkit/architect": "0.1401.0-next.0",
54
+ "@angular-devkit/build-angular": "14.1.0-next.0",
55
+ "@angular-devkit/build-webpack": "0.1401.0-next.0",
56
+ "@angular-devkit/core": "14.1.0-next.0",
57
+ "@angular-devkit/schematics": "14.1.0-next.0"
58
58
  }
59
59
  },
60
60
  "engines": {
@@ -104,7 +104,7 @@ class ArchitectBaseCommandModule extends command_module_1.CommandModule {
104
104
  (0, fs_1.existsSync)((0, path_1.resolve)(basePath, '.pnp.mjs'))) {
105
105
  return;
106
106
  }
107
- this.context.logger.warn(`Node packages may not be installed. Try installing with '${this.context.packageManager} install'.`);
107
+ this.context.logger.warn(`Node packages may not be installed. Try installing with '${this.context.packageManager.name} install'.`);
108
108
  }
109
109
  getArchitectTarget() {
110
110
  return this.commandName;
@@ -17,6 +17,7 @@ exports.ArchitectCommandModule = void 0;
17
17
  const config_1 = require("../utilities/config");
18
18
  const memoize_1 = require("../utilities/memoize");
19
19
  const architect_base_command_module_1 = require("./architect-base-command-module");
20
+ const command_module_1 = require("./command-module");
20
21
  class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBaseCommandModule {
21
22
  async builder(argv) {
22
23
  const project = this.getArchitectProject();
@@ -73,13 +74,14 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
73
74
  }
74
75
  }
75
76
  getArchitectProject() {
76
- const workspace = this.context.workspace;
77
- if (!workspace) {
78
- return undefined;
79
- }
80
- const [, projectName] = this.context.args.positional;
77
+ const { options, positional } = this.context.args;
78
+ const [, projectName] = positional;
81
79
  if (projectName) {
82
- return workspace.projects.has(projectName) ? projectName : undefined;
80
+ return projectName;
81
+ }
82
+ // Yargs allows positional args to be used as flags.
83
+ if (typeof options['project'] === 'string') {
84
+ return options['project'];
83
85
  }
84
86
  const target = this.getArchitectTarget();
85
87
  const projectFromTarget = this.getProjectNamesByTarget(target);
@@ -105,8 +107,14 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
105
107
  return allProjectsForTargetName;
106
108
  }
107
109
  const maybeProject = (0, config_1.getProjectByCwd)(workspace);
108
- if (maybeProject && allProjectsForTargetName.includes(maybeProject)) {
109
- return [maybeProject];
110
+ if (maybeProject) {
111
+ return allProjectsForTargetName.includes(maybeProject) ? [maybeProject] : undefined;
112
+ }
113
+ const { getYargsCompletions, help } = this.context.args.options;
114
+ if (!getYargsCompletions && !help) {
115
+ // Only issue the below error when not in help / completion mode.
116
+ throw new command_module_1.CommandModuleError('Cannot determine project for command. ' +
117
+ 'Pass the project name as a command line argument or change the current working directory to a project directory.');
110
118
  }
111
119
  }
112
120
  return undefined;
@@ -25,7 +25,7 @@ export interface CommandContext {
25
25
  currentDirectory: string;
26
26
  root: string;
27
27
  workspace?: AngularWorkspace;
28
- globalConfiguration?: AngularWorkspace;
28
+ globalConfiguration: AngularWorkspace;
29
29
  logger: logging.Logger;
30
30
  packageManager: PackageManagerUtils;
31
31
  /** Arguments parsed in free-from without parser configuration. */
@@ -143,6 +143,7 @@ async function runCommand(args, logger) {
143
143
  'deprecated: %s': color_1.colors.yellow('deprecated:') + ' %s',
144
144
  'Did you mean %s?': 'Unknown command. Did you mean %s?',
145
145
  })
146
+ .epilogue(color_1.colors.gray(getEpilogue(!!workspace)))
146
147
  .demandCommand(1, command_1.demandCommandFailureMessage)
147
148
  .recommendCommands()
148
149
  .middleware(normalize_options_middleware_1.normalizeOptionsMiddleware)
@@ -161,3 +162,17 @@ async function runCommand(args, logger) {
161
162
  return (_b = process.exitCode) !== null && _b !== void 0 ? _b : 0;
162
163
  }
163
164
  exports.runCommand = runCommand;
165
+ function getEpilogue(isInsideWorkspace) {
166
+ let message;
167
+ if (isInsideWorkspace) {
168
+ message =
169
+ 'The above commands are available when running the Angular CLI inside a workspace.' +
170
+ 'More commands are available when running outside a workspace.\n';
171
+ }
172
+ else {
173
+ message =
174
+ 'The above commands are available when running the Angular CLI outside a workspace.' +
175
+ 'More commands are available when running inside a workspace.\n';
176
+ }
177
+ return message + 'For more information, see https://angular.io/cli/.\n';
178
+ }
@@ -261,7 +261,7 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
261
261
  }
262
262
  }
263
263
  }
264
- const value = (_a = getSchematicCollections(workspace === null || workspace === void 0 ? void 0 : workspace.getCli())) !== null && _a !== void 0 ? _a : getSchematicCollections(globalConfiguration === null || globalConfiguration === void 0 ? void 0 : globalConfiguration.getCli());
264
+ const value = (_a = getSchematicCollections(workspace === null || workspace === void 0 ? void 0 : workspace.getCli())) !== null && _a !== void 0 ? _a : getSchematicCollections(globalConfiguration.getCli());
265
265
  if (value) {
266
266
  return value;
267
267
  }
@@ -11,7 +11,7 @@ export declare class CacheCleanModule extends CommandModule implements CommandMo
11
11
  command: string;
12
12
  describe: string;
13
13
  longDescriptionPath: string | undefined;
14
- static scope: CommandScope.In;
14
+ static scope: CommandScope;
15
15
  builder(localYargs: Argv): Argv;
16
16
  run(): Promise<void>;
17
17
  }
@@ -30,3 +30,4 @@ class CacheCleanModule extends command_module_1.CommandModule {
30
30
  }
31
31
  }
32
32
  exports.CacheCleanModule = CacheCleanModule;
33
+ CacheCleanModule.scope = command_module_1.CommandScope.In;
@@ -11,7 +11,7 @@ export declare class CacheCommandModule extends CommandModule implements Command
11
11
  command: string;
12
12
  describe: string;
13
13
  longDescriptionPath: string;
14
- static scope: CommandScope.In;
14
+ static scope: CommandScope;
15
15
  builder(localYargs: Argv): Argv;
16
16
  run(_options: Options<{}>): void;
17
17
  }
@@ -36,3 +36,4 @@ class CacheCommandModule extends command_module_1.CommandModule {
36
36
  run(_options) { }
37
37
  }
38
38
  exports.CacheCommandModule = CacheCommandModule;
39
+ CacheCommandModule.scope = command_module_1.CommandScope.In;
@@ -11,7 +11,7 @@ export declare class CacheInfoCommandModule extends CommandModule implements Com
11
11
  command: string;
12
12
  describe: string;
13
13
  longDescriptionPath?: string | undefined;
14
- static scope: CommandScope.In;
14
+ static scope: CommandScope;
15
15
  builder(localYargs: Argv): Argv;
16
16
  run(): Promise<void>;
17
17
  private getSizeOfDirectory;
@@ -80,3 +80,4 @@ class CacheInfoCommandModule extends command_module_1.CommandModule {
80
80
  }
81
81
  }
82
82
  exports.CacheInfoCommandModule = CacheInfoCommandModule;
83
+ CacheInfoCommandModule.scope = command_module_1.CommandScope.In;
@@ -12,7 +12,7 @@ export declare class CacheDisableModule extends CommandModule implements Command
12
12
  aliases: string;
13
13
  describe: string;
14
14
  longDescriptionPath: string | undefined;
15
- static scope: CommandScope.In;
15
+ static scope: CommandScope;
16
16
  builder(localYargs: Argv): Argv;
17
17
  run(): Promise<void>;
18
18
  }
@@ -21,7 +21,7 @@ export declare class CacheEnableModule extends CommandModule implements CommandM
21
21
  aliases: string;
22
22
  describe: string;
23
23
  longDescriptionPath: string | undefined;
24
- static scope: CommandScope.In;
24
+ static scope: CommandScope;
25
25
  builder(localYargs: Argv): Argv;
26
26
  run(): Promise<void>;
27
27
  }
@@ -25,6 +25,7 @@ class CacheDisableModule extends command_module_1.CommandModule {
25
25
  }
26
26
  }
27
27
  exports.CacheDisableModule = CacheDisableModule;
28
+ CacheDisableModule.scope = command_module_1.CommandScope.In;
28
29
  class CacheEnableModule extends command_module_1.CommandModule {
29
30
  constructor() {
30
31
  super(...arguments);
@@ -40,3 +41,4 @@ class CacheEnableModule extends command_module_1.CommandModule {
40
41
  }
41
42
  }
42
43
  exports.CacheEnableModule = CacheEnableModule;
44
+ CacheEnableModule.scope = command_module_1.CommandScope.In;
@@ -41,7 +41,7 @@ class ConfigCommandModule extends command_module_1.CommandModule {
41
41
  }
42
42
  async run(options) {
43
43
  const level = options.global ? 'global' : 'local';
44
- const [config] = (0, config_1.getWorkspaceRaw)(level);
44
+ const [config] = await (0, config_1.getWorkspaceRaw)(level);
45
45
  if (options.value == undefined) {
46
46
  if (!config) {
47
47
  this.context.logger.error('No config found.');
@@ -90,7 +90,7 @@ class ConfigCommandModule extends command_module_1.CommandModule {
90
90
  !validGlobalCliPaths.has(options.jsonPath)) {
91
91
  throw new command_module_1.CommandModuleError('Invalid Path.');
92
92
  }
93
- const [config, configPath] = (0, config_1.getWorkspaceRaw)(options.global ? 'global' : 'local');
93
+ const [config, configPath] = await (0, config_1.getWorkspaceRaw)(options.global ? 'global' : 'local');
94
94
  const { logger } = this.context;
95
95
  if (!config || !configPath) {
96
96
  throw new command_module_1.CommandModuleError('Confguration file cannot be found.');
@@ -19,10 +19,6 @@ class DeployCommandModule extends architect_command_module_1.ArchitectCommandMod
19
19
  name: 'Amazon S3',
20
20
  value: '@jefiozie/ngx-aws-deploy',
21
21
  },
22
- {
23
- name: 'Azure',
24
- value: '@azure/ng-deploy',
25
- },
26
22
  {
27
23
  name: 'Firebase',
28
24
  value: '@angular/fire',
@@ -510,7 +510,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
510
510
  });
511
511
  }
512
512
  catch { }
513
- let forceInstall = options.force;
513
+ let forceInstall = false;
514
514
  // npm 7+ can fail due to it incorrectly resolving peer dependencies that have valid SemVer
515
515
  // ranges during an update. Update will set correct versions of dependencies within the
516
516
  // package.json file. The force option is set to workaround these errors.
@@ -21,9 +21,16 @@ export declare class AngularWorkspace {
21
21
  save(): Promise<void>;
22
22
  static load(workspaceFilePath: string): Promise<AngularWorkspace>;
23
23
  }
24
- export declare function getWorkspace(level?: 'local' | 'global'): Promise<AngularWorkspace | undefined>;
25
- export declare function createGlobalSettings(): string;
26
- export declare function getWorkspaceRaw(level?: 'local' | 'global'): [JSONFile | null, string | null];
24
+ export declare function getWorkspace(level: 'global'): Promise<AngularWorkspace>;
25
+ export declare function getWorkspace(level: 'local'): Promise<AngularWorkspace | undefined>;
26
+ export declare function getWorkspace(level: 'local' | 'global'): Promise<AngularWorkspace | undefined>;
27
+ /**
28
+ * This method will load the workspace configuration in raw JSON format.
29
+ * When `level` is `global` and file doesn't exists, it will be created.
30
+ *
31
+ * NB: This method is intended to be used only for `ng config`.
32
+ */
33
+ export declare function getWorkspaceRaw(level?: 'local' | 'global'): Promise<[JSONFile | null, string | null]>;
27
34
  export declare function validateWorkspace(data: json.JsonObject): Promise<void>;
28
35
  export declare function getProjectByCwd(workspace: AngularWorkspace): string | null;
29
36
  export declare function getConfiguredPackageManager(): Promise<PackageManager | null>;
@@ -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.isWarningEnabled = exports.getSchematicDefaults = exports.getConfiguredPackageManager = exports.getProjectByCwd = exports.validateWorkspace = exports.getWorkspaceRaw = exports.createGlobalSettings = exports.getWorkspace = exports.AngularWorkspace = exports.workspaceSchemaPath = void 0;
33
+ exports.isWarningEnabled = exports.getSchematicDefaults = exports.getConfiguredPackageManager = exports.getProjectByCwd = exports.validateWorkspace = exports.getWorkspaceRaw = exports.getWorkspace = exports.AngularWorkspace = exports.workspaceSchemaPath = void 0;
34
34
  const core_1 = require("@angular-devkit/core");
35
35
  const fs_1 = require("fs");
36
36
  const os = __importStar(require("os"));
@@ -71,6 +71,7 @@ function createWorkspaceHost() {
71
71
  exports.workspaceSchemaPath = path.join(__dirname, '../../lib/config/schema.json');
72
72
  const configNames = ['angular.json', '.angular.json'];
73
73
  const globalFileName = '.angular-config.json';
74
+ const defaultGlobalFilePath = path.join(os.homedir(), globalFileName);
74
75
  function xdgConfigHome(home, configFile) {
75
76
  // https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
76
77
  const xdgConfigHome = process.env['XDG_CONFIG_HOME'] || path.join(home, '.config');
@@ -113,9 +114,8 @@ function globalFilePath() {
113
114
  `Please move the file to the new location ~/.config/angular/config.json`);
114
115
  return xdgConfigOld;
115
116
  }
116
- const p = path.join(home, globalFileName);
117
- if ((0, fs_1.existsSync)(p)) {
118
- return p;
117
+ if ((0, fs_1.existsSync)(defaultGlobalFilePath)) {
118
+ return defaultGlobalFilePath;
119
119
  }
120
120
  return null;
121
121
  }
@@ -142,7 +142,7 @@ class AngularWorkspace {
142
142
  return project === null || project === void 0 ? void 0 : project.extensions['cli'];
143
143
  }
144
144
  save() {
145
- return core_1.workspaces.writeWorkspace(this.workspace, createWorkspaceHost(), this.filePath);
145
+ return core_1.workspaces.writeWorkspace(this.workspace, createWorkspaceHost(), this.filePath, core_1.workspaces.WorkspaceFormat.JSON);
146
146
  }
147
147
  static async load(workspaceFilePath) {
148
148
  const result = await core_1.workspaces.readWorkspace(workspaceFilePath, createWorkspaceHost(), core_1.workspaces.WorkspaceFormat.JSON);
@@ -151,17 +151,21 @@ class AngularWorkspace {
151
151
  }
152
152
  exports.AngularWorkspace = AngularWorkspace;
153
153
  const cachedWorkspaces = new Map();
154
- async function getWorkspace(level = 'local') {
154
+ async function getWorkspace(level) {
155
155
  if (cachedWorkspaces.has(level)) {
156
156
  return cachedWorkspaces.get(level);
157
157
  }
158
- let configPath = level === 'local' ? projectFilePath() : globalFilePath();
158
+ const configPath = level === 'local' ? projectFilePath() : globalFilePath();
159
159
  if (!configPath) {
160
- if (level === 'local') {
161
- cachedWorkspaces.set(level, undefined);
162
- return undefined;
160
+ if (level === 'global') {
161
+ // Unlike a local config, a global config is not mandatory.
162
+ // So we create an empty one in memory and keep it as such until it has been modified and saved.
163
+ const globalWorkspace = new AngularWorkspace({ extensions: {}, projects: new core_1.workspaces.ProjectDefinitionCollection() }, defaultGlobalFilePath);
164
+ cachedWorkspaces.set(level, globalWorkspace);
165
+ return globalWorkspace;
163
166
  }
164
- configPath = createGlobalSettings();
167
+ cachedWorkspaces.set(level, undefined);
168
+ return undefined;
165
169
  }
166
170
  try {
167
171
  const workspace = await AngularWorkspace.load(configPath);
@@ -174,21 +178,20 @@ async function getWorkspace(level = 'local') {
174
178
  }
175
179
  }
176
180
  exports.getWorkspace = getWorkspace;
177
- function createGlobalSettings() {
178
- const home = os.homedir();
179
- if (!home) {
180
- throw new Error('No home directory found.');
181
- }
182
- const globalPath = path.join(home, globalFileName);
183
- (0, fs_1.writeFileSync)(globalPath, JSON.stringify({ version: 1 }));
184
- return globalPath;
185
- }
186
- exports.createGlobalSettings = createGlobalSettings;
187
- function getWorkspaceRaw(level = 'local') {
181
+ /**
182
+ * This method will load the workspace configuration in raw JSON format.
183
+ * When `level` is `global` and file doesn't exists, it will be created.
184
+ *
185
+ * NB: This method is intended to be used only for `ng config`.
186
+ */
187
+ async function getWorkspaceRaw(level = 'local') {
188
188
  let configPath = level === 'local' ? projectFilePath() : globalFilePath();
189
189
  if (!configPath) {
190
190
  if (level === 'global') {
191
- configPath = createGlobalSettings();
191
+ configPath = defaultGlobalFilePath;
192
+ // Config doesn't exist, force create it.
193
+ const globalWorkspace = await getWorkspace('global');
194
+ await globalWorkspace.save();
192
195
  }
193
196
  else {
194
197
  return [null, null];
@@ -8,7 +8,7 @@
8
8
  import { PackageManager } from '../../lib/config/workspace-schema';
9
9
  import { AngularWorkspace } from './config';
10
10
  export interface PackageManagerUtilsContext {
11
- globalConfiguration?: AngularWorkspace;
11
+ globalConfiguration: AngularWorkspace;
12
12
  workspace?: AngularWorkspace;
13
13
  root: string;
14
14
  }
@@ -82,7 +82,7 @@ class PackageManagerUtils {
82
82
  // clean up temp directory on process exit
83
83
  process.on('exit', () => {
84
84
  try {
85
- (0, fs_1.rmdirSync)(tempPath, { recursive: true, maxRetries: 3 });
85
+ (0, fs_1.rmSync)(tempPath, { recursive: true, maxRetries: 3 });
86
86
  }
87
87
  catch { }
88
88
  });
@@ -268,7 +268,7 @@ class PackageManagerUtils {
268
268
  result !== null && result !== void 0 ? result : (result = getPackageManager(localWorkspace.extensions['cli']));
269
269
  }
270
270
  if (!result) {
271
- result = getPackageManager(globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.extensions['cli']);
271
+ result = getPackageManager(globalWorkspace.extensions['cli']);
272
272
  }
273
273
  return result;
274
274
  }