Skip to content

Commit 73746fa

Browse files
alan-agius4filipesilva
authored andcommitted
refactor(@angular/cli): remove support for legacy Angular CLI version 1 configurations
Remove references to legacy Angular CLI version 1 configurations. By now users should have been migrated to use the new configuration.
1 parent 9e69331 commit 73746fa

File tree

6 files changed

+7
-108
lines changed

6 files changed

+7
-108
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Before you submit an issue, please search the issue tracker, maybe an issue for
6060
We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. Having a reproducible scenario gives us wealth of important information without going back & forth to you with additional questions like:
6161

6262
- version of Angular CLI used
63-
- `.angular-cli.json` or `angular.json` configuration
63+
- `angular.json` configuration
6464
- version of Angular DevKit used
6565
- 3rd-party libraries and their versions
6666
- and most importantly - a use-case that fails

packages/angular/cli/commands/config-impl.ts

+3-14
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { JsonValue, tags } from '@angular-devkit/core';
9+
import { JsonValue } from '@angular-devkit/core';
1010
import { v4 as uuidV4 } from 'uuid';
1111
import { Command } from '../models/command';
1212
import { Arguments, CommandScope } from '../models/interface';
13-
import { getWorkspaceRaw, migrateLegacyGlobalConfig, validateWorkspace } from '../utilities/config';
13+
import { getWorkspaceRaw, validateWorkspace } from '../utilities/config';
1414
import { JSONFile, parseJson } from '../utilities/json-file';
1515
import { Schema as ConfigCommandSchema } from './config';
1616

@@ -103,18 +103,7 @@ export class ConfigCommand extends Command<ConfigCommandSchema> {
103103
await this.validateScope(CommandScope.InProject);
104104
}
105105

106-
let [config] = getWorkspaceRaw(level);
107-
108-
if (options.global && !config) {
109-
try {
110-
if (migrateLegacyGlobalConfig()) {
111-
config = getWorkspaceRaw(level)[0];
112-
this.logger.info(tags.oneLine`
113-
We found a global configuration that was used in Angular CLI 1.
114-
It has been automatically migrated.`);
115-
}
116-
} catch {}
117-
}
106+
const [config] = getWorkspaceRaw(level);
118107

119108
if (options.value == undefined) {
120109
if (!config) {

packages/angular/cli/utilities/config.ts

-85
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,6 @@ export class AngularWorkspace {
144144
}
145145

146146
static async load(workspaceFilePath: string): Promise<AngularWorkspace> {
147-
const oldConfigFileNames = ['.angular-cli.json', 'angular-cli.json'];
148-
if (oldConfigFileNames.includes(path.basename(workspaceFilePath))) {
149-
// 1.x file format
150-
// Create an empty workspace to allow update to be used
151-
return new AngularWorkspace(
152-
{ extensions: {}, projects: new workspaces.ProjectDefinitionCollection() },
153-
workspaceFilePath,
154-
);
155-
}
156-
157147
const result = await workspaces.readWorkspace(
158148
workspaceFilePath,
159149
createWorkspaceHost(),
@@ -330,57 +320,6 @@ export async function getConfiguredPackageManager(): Promise<PackageManager | nu
330320
return result;
331321
}
332322

333-
export function migrateLegacyGlobalConfig(): boolean {
334-
const homeDir = os.homedir();
335-
if (homeDir) {
336-
const legacyGlobalConfigPath = path.join(homeDir, '.angular-cli.json');
337-
if (existsSync(legacyGlobalConfigPath)) {
338-
const legacy = readAndParseJson(legacyGlobalConfigPath);
339-
if (!isJsonObject(legacy)) {
340-
return false;
341-
}
342-
343-
const cli: json.JsonObject = {};
344-
345-
if (
346-
legacy.packageManager &&
347-
typeof legacy.packageManager == 'string' &&
348-
legacy.packageManager !== 'default'
349-
) {
350-
cli['packageManager'] = legacy.packageManager;
351-
}
352-
353-
if (
354-
isJsonObject(legacy.defaults) &&
355-
isJsonObject(legacy.defaults.schematics) &&
356-
typeof legacy.defaults.schematics.collection == 'string'
357-
) {
358-
cli['defaultCollection'] = legacy.defaults.schematics.collection;
359-
}
360-
361-
if (isJsonObject(legacy.warnings)) {
362-
const warnings: json.JsonObject = {};
363-
if (typeof legacy.warnings.versionMismatch == 'boolean') {
364-
warnings['versionMismatch'] = legacy.warnings.versionMismatch;
365-
}
366-
367-
if (Object.getOwnPropertyNames(warnings).length > 0) {
368-
cli['warnings'] = warnings;
369-
}
370-
}
371-
372-
if (Object.getOwnPropertyNames(cli).length > 0) {
373-
const globalPath = path.join(homeDir, globalFileName);
374-
writeFileSync(globalPath, JSON.stringify({ version: 1, cli }, null, 2));
375-
376-
return true;
377-
}
378-
}
379-
}
380-
381-
return false;
382-
}
383-
384323
export async function getSchematicDefaults(
385324
collection: string,
386325
schematic: string,
@@ -452,27 +391,3 @@ export async function isWarningEnabled(warning: string): Promise<boolean> {
452391
// All warnings are enabled by default
453392
return result ?? true;
454393
}
455-
456-
// Fallback, check for packageManager in config file in v1.* global config.
457-
function getLegacyPackageManager(): string | null {
458-
const homeDir = os.homedir();
459-
if (homeDir) {
460-
const legacyGlobalConfigPath = path.join(homeDir, '.angular-cli.json');
461-
if (existsSync(legacyGlobalConfigPath)) {
462-
const legacy = readAndParseJson(legacyGlobalConfigPath);
463-
if (!isJsonObject(legacy)) {
464-
return null;
465-
}
466-
467-
if (
468-
legacy.packageManager &&
469-
typeof legacy.packageManager === 'string' &&
470-
legacy.packageManager !== 'default'
471-
) {
472-
return legacy.packageManager;
473-
}
474-
}
475-
}
476-
477-
return null;
478-
}

packages/angular/cli/utilities/project.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ import * as path from 'path';
1313
import { findUp } from './find-up';
1414

1515
export function findWorkspaceFile(currentDirectory = process.cwd()): string | null {
16-
const possibleConfigFiles = [
17-
'angular.json',
18-
'.angular.json',
19-
'angular-cli.json',
20-
'.angular-cli.json',
21-
];
16+
const possibleConfigFiles = ['angular.json', '.angular.json'];
2217
const configFilePath = findUp(possibleConfigFiles, currentDirectory);
2318
if (configFilePath === null) {
2419
return null;

packages/angular_devkit/build_angular/test/hello-world-app/src/environments/environment.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// The file contents for the current environment will overwrite these during build.
1010
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
1111
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
12-
// The list of which env maps to which file can be found in `.angular-cli.json`.
12+
// The list of which env maps to which file can be found in `angular.json`.
1313

1414
export const environment = {
1515
production: false,

scripts/templates/contributing.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Before you submit an issue, please search the issue tracker, maybe an issue for
6060
We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. Having a reproducible scenario gives us wealth of important information without going back & forth to you with additional questions like:
6161

6262
- version of Angular CLI used
63-
- `.angular-cli.json` or `angular.json` configuration
63+
- `angular.json` configuration
6464
- version of Angular DevKit used
6565
- 3rd-party libraries and their versions
6666
- and most importantly - a use-case that fails

0 commit comments

Comments
 (0)