mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-21 22:34:21 +08:00
refactor(@angular/cli): correct various uncaught code style issues
This change cleans up some of the code by removing unused variables/imports, unnecessary double negation, and some long line lengths.
This commit is contained in:
parent
ee86327167
commit
203f9626df
@ -131,7 +131,7 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
|
|||||||
// 'latest' is invalid so search for most recent matching package
|
// 'latest' is invalid so search for most recent matching package
|
||||||
const versionManifests = Object.values(packageMetadata.versions).filter(
|
const versionManifests = Object.values(packageMetadata.versions).filter(
|
||||||
(value: PackageManifest) => !prerelease(value.version) && !value.deprecated,
|
(value: PackageManifest) => !prerelease(value.version) && !value.deprecated,
|
||||||
) as PackageManifest[];
|
);
|
||||||
|
|
||||||
versionManifests.sort((a, b) => rcompare(a.version, b.version, true));
|
versionManifests.sort((a, b) => rcompare(a.version, b.version, true));
|
||||||
|
|
||||||
|
@ -16,15 +16,19 @@ export class ExtractI18nCommand extends ArchitectCommand<ExtractI18nCommandSchem
|
|||||||
const version = process.version.substr(1).split('.');
|
const version = process.version.substr(1).split('.');
|
||||||
if (Number(version[0]) === 12 && Number(version[1]) === 0) {
|
if (Number(version[0]) === 12 && Number(version[1]) === 0) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
'Due to a defect in Node.js 12.0, the command is not supported on this Node.js version. '
|
'Due to a defect in Node.js 12.0, the command is not supported on this Node.js version. ' +
|
||||||
+ 'Please upgrade to Node.js 12.1 or later.');
|
'Please upgrade to Node.js 12.1 or later.',
|
||||||
|
);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const commandName = process.argv[2];
|
const commandName = process.argv[2];
|
||||||
if (['xi18n', 'i18n-extract'].includes(commandName)) {
|
if (['xi18n', 'i18n-extract'].includes(commandName)) {
|
||||||
this.logger.warn(`Warning: "ng ${commandName}" has been deprecated and will be removed in a future major version. Please use "ng extract-i18n" instead.`);
|
this.logger.warn(
|
||||||
|
`Warning: "ng ${commandName}" has been deprecated and will be removed in a future major version. ` +
|
||||||
|
'Please use "ng extract-i18n" instead.',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.runArchitectTarget(options);
|
return this.runArchitectTarget(options);
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
import { Arguments } from '../models/interface';
|
import { Arguments } from '../models/interface';
|
||||||
import { SchematicCommand } from '../models/schematic-command';
|
import { SchematicCommand } from '../models/schematic-command';
|
||||||
import { ensureCompatibleNpm } from '../utilities/package-manager';
|
|
||||||
import { Schema as NewCommandSchema } from './new';
|
import { Schema as NewCommandSchema } from './new';
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import { Schema as ServeCommandSchema } from './serve';
|
|||||||
export class ServeCommand extends ArchitectCommand<ServeCommandSchema> {
|
export class ServeCommand extends ArchitectCommand<ServeCommandSchema> {
|
||||||
public readonly target = 'serve';
|
public readonly target = 'serve';
|
||||||
|
|
||||||
public validate(_options: ArchitectCommandOptions & Arguments) {
|
public validate() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import 'symbol-observable';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { SemVer } from 'semver';
|
import { SemVer } from 'semver';
|
||||||
import { Duplex } from 'stream';
|
|
||||||
import { colors } from '../utilities/color';
|
import { colors } from '../utilities/color';
|
||||||
import { isWarningEnabled } from '../utilities/config';
|
import { isWarningEnabled } from '../utilities/config';
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ export abstract class Command<T extends BaseCommandOptions = BaseCommandOptions>
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
async printJsonHelp(_options: T & Arguments): Promise<number> {
|
async printJsonHelp(): Promise<number> {
|
||||||
const replacer = (key: string, value: string) => key === 'name'
|
const replacer = (key: string, value: string) => key === 'name'
|
||||||
? strings.dasherize(value)
|
? strings.dasherize(value)
|
||||||
: value;
|
: value;
|
||||||
@ -176,7 +176,7 @@ export abstract class Command<T extends BaseCommandOptions = BaseCommandOptions>
|
|||||||
if (options.help === true) {
|
if (options.help === true) {
|
||||||
return this.printHelp();
|
return this.printHelp();
|
||||||
} else if (options.help === 'json' || options.help === 'JSON') {
|
} else if (options.help === 'json' || options.help === 'JSON') {
|
||||||
return this.printJsonHelp(options);
|
return this.printJsonHelp();
|
||||||
} else {
|
} else {
|
||||||
const startTime = +new Date();
|
const startTime = +new Date();
|
||||||
if (this.useReportAnalytics) {
|
if (this.useReportAnalytics) {
|
||||||
|
@ -243,7 +243,7 @@ export abstract class SchematicCommand<
|
|||||||
packageRegistry: options.packageRegistry,
|
packageRegistry: options.packageRegistry,
|
||||||
// A schema registry is required to allow customizing addUndefinedDefaults
|
// A schema registry is required to allow customizing addUndefinedDefaults
|
||||||
registry: new schema.CoreSchemaRegistry(formats.standardFormats),
|
registry: new schema.CoreSchemaRegistry(formats.standardFormats),
|
||||||
resolvePaths: !!this.workspace
|
resolvePaths: this.workspace
|
||||||
// Workspace
|
// Workspace
|
||||||
? this.collectionName === this.defaultCollectionName
|
? this.collectionName === this.defaultCollectionName
|
||||||
// Favor __dirname for @schematics/angular to use the build-in version
|
// Favor __dirname for @schematics/angular to use the build-in version
|
||||||
|
@ -46,6 +46,9 @@
|
|||||||
"symbol-observable": "4.0.0",
|
"symbol-observable": "4.0.0",
|
||||||
"uuid": "8.3.2"
|
"uuid": "8.3.2"
|
||||||
},
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"rxjs": "6.6.7"
|
||||||
|
},
|
||||||
"ng-update": {
|
"ng-update": {
|
||||||
"migrations": "@schematics/angular/migrations/migration-collection.json",
|
"migrations": "@schematics/angular/migrations/migration-collection.json",
|
||||||
"packageGroup": {
|
"packageGroup": {
|
||||||
|
@ -435,7 +435,7 @@ function _usageMessage(
|
|||||||
target,
|
target,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter(({ name, info, version, target }) => {
|
.filter(({ info, version, target }) => {
|
||||||
return (target && semver.compare(info.installed.version, version) < 0);
|
return (target && semver.compare(info.installed.version, version) < 0);
|
||||||
})
|
})
|
||||||
.filter(({ target }) => {
|
.filter(({ target }) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user