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.
This commit is contained in:
Alan Agius 2022-02-03 09:12:50 +01:00 committed by Filipe Silva
parent 9e69331fa6
commit 73746faee9
6 changed files with 7 additions and 108 deletions

View File

@ -60,7 +60,7 @@ Before you submit an issue, please search the issue tracker, maybe an issue for
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:
- version of Angular CLI used
- `.angular-cli.json` or `angular.json` configuration
- `angular.json` configuration
- version of Angular DevKit used
- 3rd-party libraries and their versions
- and most importantly - a use-case that fails

View File

@ -6,11 +6,11 @@
* found in the LICENSE file at https://angular.io/license
*/
import { JsonValue, tags } from '@angular-devkit/core';
import { JsonValue } from '@angular-devkit/core';
import { v4 as uuidV4 } from 'uuid';
import { Command } from '../models/command';
import { Arguments, CommandScope } from '../models/interface';
import { getWorkspaceRaw, migrateLegacyGlobalConfig, validateWorkspace } from '../utilities/config';
import { getWorkspaceRaw, validateWorkspace } from '../utilities/config';
import { JSONFile, parseJson } from '../utilities/json-file';
import { Schema as ConfigCommandSchema } from './config';
@ -103,18 +103,7 @@ export class ConfigCommand extends Command<ConfigCommandSchema> {
await this.validateScope(CommandScope.InProject);
}
let [config] = getWorkspaceRaw(level);
if (options.global && !config) {
try {
if (migrateLegacyGlobalConfig()) {
config = getWorkspaceRaw(level)[0];
this.logger.info(tags.oneLine`
We found a global configuration that was used in Angular CLI 1.
It has been automatically migrated.`);
}
} catch {}
}
const [config] = getWorkspaceRaw(level);
if (options.value == undefined) {
if (!config) {

View File

@ -144,16 +144,6 @@ export class AngularWorkspace {
}
static async load(workspaceFilePath: string): Promise<AngularWorkspace> {
const oldConfigFileNames = ['.angular-cli.json', 'angular-cli.json'];
if (oldConfigFileNames.includes(path.basename(workspaceFilePath))) {
// 1.x file format
// Create an empty workspace to allow update to be used
return new AngularWorkspace(
{ extensions: {}, projects: new workspaces.ProjectDefinitionCollection() },
workspaceFilePath,
);
}
const result = await workspaces.readWorkspace(
workspaceFilePath,
createWorkspaceHost(),
@ -330,57 +320,6 @@ export async function getConfiguredPackageManager(): Promise<PackageManager | nu
return result;
}
export function migrateLegacyGlobalConfig(): boolean {
const homeDir = os.homedir();
if (homeDir) {
const legacyGlobalConfigPath = path.join(homeDir, '.angular-cli.json');
if (existsSync(legacyGlobalConfigPath)) {
const legacy = readAndParseJson(legacyGlobalConfigPath);
if (!isJsonObject(legacy)) {
return false;
}
const cli: json.JsonObject = {};
if (
legacy.packageManager &&
typeof legacy.packageManager == 'string' &&
legacy.packageManager !== 'default'
) {
cli['packageManager'] = legacy.packageManager;
}
if (
isJsonObject(legacy.defaults) &&
isJsonObject(legacy.defaults.schematics) &&
typeof legacy.defaults.schematics.collection == 'string'
) {
cli['defaultCollection'] = legacy.defaults.schematics.collection;
}
if (isJsonObject(legacy.warnings)) {
const warnings: json.JsonObject = {};
if (typeof legacy.warnings.versionMismatch == 'boolean') {
warnings['versionMismatch'] = legacy.warnings.versionMismatch;
}
if (Object.getOwnPropertyNames(warnings).length > 0) {
cli['warnings'] = warnings;
}
}
if (Object.getOwnPropertyNames(cli).length > 0) {
const globalPath = path.join(homeDir, globalFileName);
writeFileSync(globalPath, JSON.stringify({ version: 1, cli }, null, 2));
return true;
}
}
}
return false;
}
export async function getSchematicDefaults(
collection: string,
schematic: string,
@ -452,27 +391,3 @@ export async function isWarningEnabled(warning: string): Promise<boolean> {
// All warnings are enabled by default
return result ?? true;
}
// Fallback, check for packageManager in config file in v1.* global config.
function getLegacyPackageManager(): string | null {
const homeDir = os.homedir();
if (homeDir) {
const legacyGlobalConfigPath = path.join(homeDir, '.angular-cli.json');
if (existsSync(legacyGlobalConfigPath)) {
const legacy = readAndParseJson(legacyGlobalConfigPath);
if (!isJsonObject(legacy)) {
return null;
}
if (
legacy.packageManager &&
typeof legacy.packageManager === 'string' &&
legacy.packageManager !== 'default'
) {
return legacy.packageManager;
}
}
}
return null;
}

View File

@ -13,12 +13,7 @@ import * as path from 'path';
import { findUp } from './find-up';
export function findWorkspaceFile(currentDirectory = process.cwd()): string | null {
const possibleConfigFiles = [
'angular.json',
'.angular.json',
'angular-cli.json',
'.angular-cli.json',
];
const possibleConfigFiles = ['angular.json', '.angular.json'];
const configFilePath = findUp(possibleConfigFiles, currentDirectory);
if (configFilePath === null) {
return null;

View File

@ -9,7 +9,7 @@
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
// The list of which env maps to which file can be found in `angular.json`.
export const environment = {
production: false,

View File

@ -60,7 +60,7 @@ Before you submit an issue, please search the issue tracker, maybe an issue for
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:
- version of Angular CLI used
- `.angular-cli.json` or `angular.json` configuration
- `angular.json` configuration
- version of Angular DevKit used
- 3rd-party libraries and their versions
- and most importantly - a use-case that fails