mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 11:03:53 +08:00
refactor(@angular/cli): re-organize the Angular CLI package folder structure
This commit is contained in:
parent
78683db870
commit
10cce2c86e
@ -14,7 +14,7 @@ if ('NG_CLI_ANALYTICS' in process.env) {
|
||||
}
|
||||
|
||||
try {
|
||||
var analytics = require('../../models/analytics');
|
||||
var analytics = require('../../src/analytics/analytics');
|
||||
|
||||
analytics
|
||||
.hasGlobalAnalyticsConfiguration()
|
||||
|
@ -9,14 +9,14 @@
|
||||
import { schema } from '@angular-devkit/core';
|
||||
import { createConsoleLogger } from '@angular-devkit/core/node';
|
||||
import { format } from 'util';
|
||||
import { colors, removeColor } from '../../utilities/color';
|
||||
import { CommandModuleError } from '../../utilities/command-builder/command-module';
|
||||
import { AngularWorkspace, getWorkspaceRaw } from '../../utilities/config';
|
||||
import { writeErrorToLogFile } from '../../utilities/log-file';
|
||||
import { findWorkspaceFile } from '../../utilities/project';
|
||||
import { runCommand } from './command-runner';
|
||||
import { CommandModuleError } from '../../src/command-builder/command-module';
|
||||
import { runCommand } from '../../src/command-builder/command-runner';
|
||||
import { colors, removeColor } from '../../src/utilities/color';
|
||||
import { AngularWorkspace, getWorkspaceRaw } from '../../src/utilities/config';
|
||||
import { writeErrorToLogFile } from '../../src/utilities/log-file';
|
||||
import { findWorkspaceFile } from '../../src/utilities/project';
|
||||
|
||||
export { VERSION } from '../../utilities/version';
|
||||
export { VERSION } from '../../src/utilities/version';
|
||||
|
||||
const debugEnv = process.env['NG_DEBUG'];
|
||||
const isDebug = debugEnv !== undefined && debugEnv !== '0' && debugEnv.toLowerCase() !== 'false';
|
||||
|
@ -11,9 +11,9 @@ import 'symbol-observable';
|
||||
import { promises as fs } from 'fs';
|
||||
import * as path from 'path';
|
||||
import { SemVer } from 'semver';
|
||||
import { colors } from '../utilities/color';
|
||||
import { isWarningEnabled } from '../utilities/config';
|
||||
import { VERSION } from '../utilities/version';
|
||||
import { colors } from '../src/utilities/color';
|
||||
import { isWarningEnabled } from '../src/utilities/config';
|
||||
import { VERSION } from '../src/utilities/version';
|
||||
|
||||
(async () => {
|
||||
/**
|
||||
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
import { analytics, logging } from '@angular-devkit/core';
|
||||
import { Option } from '../utilities/command-builder/json-schema';
|
||||
import { AngularWorkspace } from '../utilities/config';
|
||||
import { Option } from '../src/command-builder/utilities/json-schema';
|
||||
import { AngularWorkspace } from '../src/utilities/config';
|
||||
import { CommandContext } from './interface';
|
||||
|
||||
export interface BaseCommandOptions {
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import { analytics, logging } from '@angular-devkit/core';
|
||||
import { AngularWorkspace } from '../utilities/config';
|
||||
import { AngularWorkspace } from '../src/utilities/config';
|
||||
|
||||
/**
|
||||
* A command runner context.
|
||||
|
@ -16,12 +16,12 @@ import {
|
||||
} from '@angular-devkit/schematics/tools';
|
||||
import * as inquirer from 'inquirer';
|
||||
import * as systemPath from 'path';
|
||||
import { colors } from '../utilities/color';
|
||||
import { parseJsonSchemaToOptions } from '../utilities/command-builder/json-schema';
|
||||
import { getProjectByCwd, getSchematicDefaults, getWorkspace } from '../utilities/config';
|
||||
import { ensureCompatibleNpm, getPackageManager } from '../utilities/package-manager';
|
||||
import { isTTY } from '../utilities/tty';
|
||||
import { isPackageNameSafeForAnalytics } from './analytics';
|
||||
import { isPackageNameSafeForAnalytics } from '../src/analytics/analytics';
|
||||
import { parseJsonSchemaToOptions } from '../src/command-builder/utilities/json-schema';
|
||||
import { colors } from '../src/utilities/color';
|
||||
import { getProjectByCwd, getSchematicDefaults, getWorkspace } from '../src/utilities/config';
|
||||
import { ensureCompatibleNpm, getPackageManager } from '../src/utilities/package-manager';
|
||||
import { isTTY } from '../src/utilities/tty';
|
||||
import { BaseCommandOptions, Command } from './command';
|
||||
import { CommandContext } from './interface';
|
||||
import { SchematicEngineHost } from './schematic-engine-host';
|
||||
|
@ -9,13 +9,9 @@
|
||||
import { Architect, Target } from '@angular-devkit/architect';
|
||||
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
|
||||
import { json } from '@angular-devkit/core';
|
||||
import { existsSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { Argv } from 'yargs';
|
||||
import { isPackageNameSafeForAnalytics } from '../../models/analytics';
|
||||
import { getPackageManager } from '../package-manager';
|
||||
import { isPackageNameSafeForAnalytics } from '../analytics/analytics';
|
||||
import {
|
||||
CommandContext,
|
||||
CommandModule,
|
||||
CommandModuleError,
|
||||
CommandModuleImplementation,
|
||||
@ -23,7 +19,7 @@ import {
|
||||
Options,
|
||||
OtherOptions,
|
||||
} from './command-module';
|
||||
import { Option, parseJsonSchemaToOptions } from './json-schema';
|
||||
import { getArchitectTargetOptions } from './utilities/architect';
|
||||
|
||||
export interface ArchitectCommandArgs {
|
||||
configuration?: string;
|
||||
@ -234,63 +230,3 @@ export abstract class ArchitectCommandModule
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get architect target schema options.
|
||||
*/
|
||||
export async function getArchitectTargetOptions(
|
||||
context: CommandContext,
|
||||
target: Target,
|
||||
): Promise<Option[]> {
|
||||
const { workspace } = context;
|
||||
if (!workspace) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const architectHost = new WorkspaceNodeModulesArchitectHost(workspace, workspace.basePath);
|
||||
const builderConf = await architectHost.getBuilderNameForTarget(target);
|
||||
|
||||
let builderDesc;
|
||||
try {
|
||||
builderDesc = await architectHost.resolveBuilder(builderConf);
|
||||
} catch (e) {
|
||||
if (e.code === 'MODULE_NOT_FOUND') {
|
||||
await warnOnMissingNodeModules(context);
|
||||
throw new CommandModuleError(`Could not find the '${builderConf}' builder's node package.`);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
return parseJsonSchemaToOptions(
|
||||
new json.schema.CoreSchemaRegistry(),
|
||||
builderDesc.optionSchema as json.JsonObject,
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
export async function warnOnMissingNodeModules(context: CommandContext): Promise<void> {
|
||||
const basePath = context.workspace?.basePath;
|
||||
if (!basePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for a `node_modules` directory (npm, yarn non-PnP, etc.)
|
||||
if (existsSync(resolve(basePath, 'node_modules'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for yarn PnP files
|
||||
if (
|
||||
existsSync(resolve(basePath, '.pnp.js')) ||
|
||||
existsSync(resolve(basePath, '.pnp.cjs')) ||
|
||||
existsSync(resolve(basePath, '.pnp.mjs'))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const packageManager = await getPackageManager(basePath);
|
||||
context.logger.warn(
|
||||
`Node packages may not be installed. Try installing with '${packageManager} install'.`,
|
||||
);
|
||||
}
|
@ -16,9 +16,9 @@ import {
|
||||
CommandModule as YargsCommandModule,
|
||||
Options as YargsOptions,
|
||||
} from 'yargs';
|
||||
import { createAnalytics } from '../../models/analytics';
|
||||
import { AngularWorkspace } from '../config';
|
||||
import { Option } from './json-schema';
|
||||
import { createAnalytics } from '../analytics/analytics';
|
||||
import { AngularWorkspace } from '../utilities/config';
|
||||
import { Option } from './utilities/json-schema';
|
||||
|
||||
export type Options<T> = { [key in keyof T as CamelCaseKey<key>]: T[key] };
|
||||
|
@ -9,31 +9,27 @@
|
||||
import { logging } from '@angular-devkit/core';
|
||||
import yargs from 'yargs';
|
||||
import { Parser } from 'yargs/helpers';
|
||||
import { AddCommandModule } from '../../commands/add/cli';
|
||||
import { AnalyticsCommandModule } from '../../commands/analytics/cli';
|
||||
import { BuildCommandModule } from '../../commands/build/cli';
|
||||
import { ConfigCommandModule } from '../../commands/config/cli';
|
||||
import { DeployCommandModule } from '../../commands/deploy/cli';
|
||||
import { DocCommandModule } from '../../commands/doc/cli';
|
||||
import { E2eCommandModule } from '../../commands/e2e/cli';
|
||||
import { ExtractI18nCommandModule } from '../../commands/extract-i18n/cli';
|
||||
import { GenerateCommandModule } from '../../commands/generate/cli';
|
||||
import { LintCommandModule } from '../../commands/lint/cli';
|
||||
import { AwesomeCommandModule } from '../../commands/make-this-awesome/cli';
|
||||
import { NewCommandModule } from '../../commands/new/cli';
|
||||
import { RunCommandModule } from '../../commands/run/cli';
|
||||
import { ServeCommandModule } from '../../commands/serve/cli';
|
||||
import { TestCommandModule } from '../../commands/test/cli';
|
||||
import { UpdateCommandModule } from '../../commands/update/cli';
|
||||
import { VersionCommandModule } from '../../commands/version/cli';
|
||||
import { colors } from '../../utilities/color';
|
||||
import {
|
||||
CommandContext,
|
||||
CommandModuleError,
|
||||
CommandScope,
|
||||
} from '../../utilities/command-builder/command-module';
|
||||
import { jsonHelpUsage } from '../../utilities/command-builder/json-help';
|
||||
import { AngularWorkspace } from '../../utilities/config';
|
||||
import { AddCommandModule } from '../commands/add/cli';
|
||||
import { AnalyticsCommandModule } from '../commands/analytics/cli';
|
||||
import { BuildCommandModule } from '../commands/build/cli';
|
||||
import { ConfigCommandModule } from '../commands/config/cli';
|
||||
import { DeployCommandModule } from '../commands/deploy/cli';
|
||||
import { DocCommandModule } from '../commands/doc/cli';
|
||||
import { E2eCommandModule } from '../commands/e2e/cli';
|
||||
import { ExtractI18nCommandModule } from '../commands/extract-i18n/cli';
|
||||
import { GenerateCommandModule } from '../commands/generate/cli';
|
||||
import { LintCommandModule } from '../commands/lint/cli';
|
||||
import { AwesomeCommandModule } from '../commands/make-this-awesome/cli';
|
||||
import { NewCommandModule } from '../commands/new/cli';
|
||||
import { RunCommandModule } from '../commands/run/cli';
|
||||
import { ServeCommandModule } from '../commands/serve/cli';
|
||||
import { TestCommandModule } from '../commands/test/cli';
|
||||
import { UpdateCommandModule } from '../commands/update/cli';
|
||||
import { VersionCommandModule } from '../commands/version/cli';
|
||||
import { colors } from '../utilities/color';
|
||||
import { AngularWorkspace } from '../utilities/config';
|
||||
import { CommandContext, CommandModuleError, CommandScope } from './command-module';
|
||||
import { jsonHelpUsage } from './utilities/json-help';
|
||||
|
||||
const COMMANDS = [
|
||||
VersionCommandModule,
|
@ -14,9 +14,9 @@ import {
|
||||
} from '@angular-devkit/schematics/tools';
|
||||
import { Argv } from 'yargs';
|
||||
import { SchematicEngineHost } from '../../models/schematic-engine-host';
|
||||
import { getProjectByCwd, getWorkspace } from '../config';
|
||||
import { getProjectByCwd, getWorkspace } from '../utilities/config';
|
||||
import { CommandModule, CommandModuleImplementation, CommandScope } from './command-module';
|
||||
import { Option, parseJsonSchemaToOptions } from './json-schema';
|
||||
import { Option, parseJsonSchemaToOptions } from './utilities/json-schema';
|
||||
|
||||
const DEFAULT_SCHEMATICS_COLLECTION = '@schematics/angular';
|
||||
|
@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { Target } from '@angular-devkit/architect';
|
||||
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
|
||||
import { json } from '@angular-devkit/core';
|
||||
import { existsSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { getPackageManager } from '../../utilities/package-manager';
|
||||
import { CommandContext, CommandModuleError } from '../command-module';
|
||||
import { Option, parseJsonSchemaToOptions } from './json-schema';
|
||||
|
||||
export async function getArchitectTargetOptions(
|
||||
context: CommandContext,
|
||||
target: Target,
|
||||
): Promise<Option[]> {
|
||||
const { workspace } = context;
|
||||
if (!workspace) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const architectHost = new WorkspaceNodeModulesArchitectHost(workspace, workspace.basePath);
|
||||
const builderConf = await architectHost.getBuilderNameForTarget(target);
|
||||
|
||||
let builderDesc;
|
||||
try {
|
||||
builderDesc = await architectHost.resolveBuilder(builderConf);
|
||||
} catch (e) {
|
||||
if (e.code === 'MODULE_NOT_FOUND') {
|
||||
await warnOnMissingNodeModules(context);
|
||||
throw new CommandModuleError(`Could not find the '${builderConf}' builder's node package.`);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
return parseJsonSchemaToOptions(
|
||||
new json.schema.CoreSchemaRegistry(),
|
||||
builderDesc.optionSchema as json.JsonObject,
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
export async function warnOnMissingNodeModules(context: CommandContext): Promise<void> {
|
||||
const basePath = context.workspace?.basePath;
|
||||
if (!basePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for a `node_modules` directory (npm, yarn non-PnP, etc.)
|
||||
if (existsSync(resolve(basePath, 'node_modules'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for yarn PnP files
|
||||
if (
|
||||
existsSync(resolve(basePath, '.pnp.js')) ||
|
||||
existsSync(resolve(basePath, '.pnp.cjs')) ||
|
||||
existsSync(resolve(basePath, '.pnp.mjs'))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const packageManager = await getPackageManager(basePath);
|
||||
context.logger.warn(
|
||||
`Node packages may not be installed. Try installing with '${packageManager} install'.`,
|
||||
);
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import yargs from 'yargs';
|
||||
import { FullDescribe } from './command-module';
|
||||
import { FullDescribe } from '../command-module';
|
||||
|
||||
export interface JsonHelp {
|
||||
name: string;
|
@ -11,11 +11,11 @@ import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/
|
||||
import npa from 'npm-package-arg';
|
||||
import { dirname, join } from 'path';
|
||||
import { intersects, prerelease, rcompare, satisfies, valid, validRange } from 'semver';
|
||||
import { PackageManager } from '../../lib/config/workspace-schema';
|
||||
import { isPackageNameSafeForAnalytics } from '../../models/analytics';
|
||||
import { SchematicCommand } from '../../models/schematic-command';
|
||||
import { PackageManager } from '../../../lib/config/workspace-schema';
|
||||
import { SchematicCommand } from '../../../models/schematic-command';
|
||||
import { isPackageNameSafeForAnalytics } from '../../analytics/analytics';
|
||||
import { Options } from '../../command-builder/command-module';
|
||||
import { colors } from '../../utilities/color';
|
||||
import { Options } from '../../utilities/command-builder/command-module';
|
||||
import { installPackage, installTempPackage } from '../../utilities/install-package';
|
||||
import { ensureCompatibleNpm, getPackageManager } from '../../utilities/package-manager';
|
||||
import {
|
@ -12,11 +12,11 @@ import {
|
||||
CommandModuleImplementation,
|
||||
Options,
|
||||
OtherOptions,
|
||||
} from '../../utilities/command-builder/command-module';
|
||||
} from '../../command-builder/command-module';
|
||||
import {
|
||||
SchematicsCommandArgs,
|
||||
SchematicsCommandModule,
|
||||
} from '../../utilities/command-builder/schematics-command-module';
|
||||
} from '../../command-builder/schematics-command-module';
|
||||
import { AddCommandModule as OldCommandModule } from './add-impl';
|
||||
|
||||
export interface AddCommandArgs extends SchematicsCommandArgs {
|
@ -7,13 +7,13 @@
|
||||
*/
|
||||
|
||||
import { join } from 'path';
|
||||
import { Argv, string } from 'yargs';
|
||||
import { Argv } from 'yargs';
|
||||
import {
|
||||
promptGlobalAnalytics,
|
||||
promptProjectAnalytics,
|
||||
setAnalyticsConfig,
|
||||
} from '../../models/analytics';
|
||||
import { CommandModule, Options } from '../../utilities/command-builder/command-module';
|
||||
} from '../../analytics/analytics';
|
||||
import { CommandModule, Options } from '../../command-builder/command-module';
|
||||
|
||||
interface AnalyticsCommandArgs {
|
||||
'setting-or-project': 'on' | 'off' | 'ci' | 'project' | 'prompt' | string;
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
import { join } from 'path';
|
||||
import { ArchitectCommandModule } from '../../utilities/command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../utilities/command-builder/command-module';
|
||||
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../command-builder/command-module';
|
||||
|
||||
export class BuildCommandModule
|
||||
extends ArchitectCommandModule
|
@ -12,7 +12,7 @@ import {
|
||||
CommandModule,
|
||||
CommandModuleImplementation,
|
||||
Options,
|
||||
} from '../../utilities/command-builder/command-module';
|
||||
} from '../../command-builder/command-module';
|
||||
import { ConfigCommand } from './config-impl';
|
||||
|
||||
export interface ConfigCommandArgs {
|
@ -8,8 +8,8 @@
|
||||
|
||||
import { JsonValue } from '@angular-devkit/core';
|
||||
import { v4 as uuidV4 } from 'uuid';
|
||||
import { Command } from '../../models/command';
|
||||
import { Options } from '../../utilities/command-builder/command-module';
|
||||
import { Command } from '../../../models/command';
|
||||
import { Options } from '../../command-builder/command-module';
|
||||
import { getWorkspaceRaw, validateWorkspace } from '../../utilities/config';
|
||||
import { JSONFile, parseJson } from '../../utilities/json-file';
|
||||
import { ConfigCommandArgs } from './cli';
|
@ -9,5 +9,3 @@ except that in the configuration file, all names must use camelCase,
|
||||
while on the command line options can be given in either camelCase or dash-case.
|
||||
|
||||
For further details, see [Workspace Configuration](guide/workspace-config).
|
||||
|
||||
For configuration of CLI usage analytics, see [Gathering an Viewing CLI Usage Analytics](./usage-analytics-gathering).
|
@ -8,8 +8,8 @@
|
||||
|
||||
import { tags } from '@angular-devkit/core';
|
||||
import { join } from 'path';
|
||||
import { ArchitectCommandModule } from '../../utilities/command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../utilities/command-builder/command-module';
|
||||
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../command-builder/command-module';
|
||||
|
||||
export class DeployCommandModule
|
||||
extends ArchitectCommandModule
|
@ -12,7 +12,7 @@ import {
|
||||
CommandModule,
|
||||
CommandModuleImplementation,
|
||||
Options,
|
||||
} from '../../utilities/command-builder/command-module';
|
||||
} from '../../command-builder/command-module';
|
||||
|
||||
interface DocCommandArgs {
|
||||
keyword: string;
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
import { tags } from '@angular-devkit/core';
|
||||
import { ArchitectCommandModule } from '../../utilities/command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../utilities/command-builder/command-module';
|
||||
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../command-builder/command-module';
|
||||
|
||||
export class E2eCommandModule
|
||||
extends ArchitectCommandModule
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { ArchitectCommandModule } from '../../utilities/command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../utilities/command-builder/command-module';
|
||||
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../command-builder/command-module';
|
||||
|
||||
export class ExtractI18nCommandModule
|
||||
extends ArchitectCommandModule
|
@ -12,12 +12,12 @@ import {
|
||||
CommandModuleImplementation,
|
||||
Options,
|
||||
OtherOptions,
|
||||
} from '../../utilities/command-builder/command-module';
|
||||
import { Option } from '../../utilities/command-builder/json-schema';
|
||||
} from '../../command-builder/command-module';
|
||||
import {
|
||||
SchematicsCommandArgs,
|
||||
SchematicsCommandModule,
|
||||
} from '../../utilities/command-builder/schematics-command-module';
|
||||
} from '../../command-builder/schematics-command-module';
|
||||
import { Option } from '../../command-builder/utilities/json-schema';
|
||||
import { GenerateCommand } from './generate-impl';
|
||||
|
||||
export interface GenerateCommandArgs extends SchematicsCommandArgs {
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { SchematicCommand } from '../../models/schematic-command';
|
||||
import { Options, OtherOptions } from '../../utilities/command-builder/command-module';
|
||||
import { SchematicCommand } from '../../../models/schematic-command';
|
||||
import { Options, OtherOptions } from '../../command-builder/command-module';
|
||||
import { GenerateCommandArgs } from './cli';
|
||||
|
||||
type GenerateCommandOptions = Options<GenerateCommandArgs>;
|
@ -8,8 +8,8 @@
|
||||
|
||||
import { tags } from '@angular-devkit/core';
|
||||
import { join } from 'path';
|
||||
import { ArchitectCommandModule } from '../../utilities/command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../utilities/command-builder/command-module';
|
||||
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../command-builder/command-module';
|
||||
|
||||
export class LintCommandModule
|
||||
extends ArchitectCommandModule
|
@ -7,11 +7,8 @@
|
||||
*/
|
||||
|
||||
import { Argv } from 'yargs';
|
||||
import { CommandModule, CommandModuleImplementation } from '../../command-builder/command-module';
|
||||
import { colors } from '../../utilities/color';
|
||||
import {
|
||||
CommandModule,
|
||||
CommandModuleImplementation,
|
||||
} from '../../utilities/command-builder/command-module';
|
||||
|
||||
export class AwesomeCommandModule extends CommandModule implements CommandModuleImplementation {
|
||||
command = 'make-this-awesome';
|
@ -12,11 +12,11 @@ import {
|
||||
CommandScope,
|
||||
Options,
|
||||
OtherOptions,
|
||||
} from '../../utilities/command-builder/command-module';
|
||||
} from '../../command-builder/command-module';
|
||||
import {
|
||||
SchematicsCommandArgs,
|
||||
SchematicsCommandModule,
|
||||
} from '../../utilities/command-builder/schematics-command-module';
|
||||
} from '../../command-builder/schematics-command-module';
|
||||
import { NewCommand } from './new-impl';
|
||||
|
||||
export interface NewCommandArgs extends SchematicsCommandArgs {
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { SchematicCommand } from '../../models/schematic-command';
|
||||
import { Options, OtherOptions } from '../../utilities/command-builder/command-module';
|
||||
import { SchematicCommand } from '../../../models/schematic-command';
|
||||
import { Options, OtherOptions } from '../../command-builder/command-module';
|
||||
import { VERSION } from '../../utilities/version';
|
||||
import { NewCommandArgs } from './cli';
|
||||
|
@ -11,8 +11,7 @@ import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/nod
|
||||
import { json } from '@angular-devkit/core';
|
||||
import { join } from 'path';
|
||||
import { Argv } from 'yargs';
|
||||
import { isPackageNameSafeForAnalytics } from '../../models/analytics';
|
||||
import { getArchitectTargetOptions } from '../../utilities/command-builder/architect-command-module';
|
||||
import { isPackageNameSafeForAnalytics } from '../../analytics/analytics';
|
||||
import {
|
||||
CommandModule,
|
||||
CommandModuleError,
|
||||
@ -20,7 +19,8 @@ import {
|
||||
CommandScope,
|
||||
Options,
|
||||
OtherOptions,
|
||||
} from '../../utilities/command-builder/command-module';
|
||||
} from '../../command-builder/command-module';
|
||||
import { getArchitectTargetOptions } from '../../command-builder/utilities/architect';
|
||||
|
||||
export interface RunCommandArgs {
|
||||
target: string;
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { ArchitectCommandModule } from '../../utilities/command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../utilities/command-builder/command-module';
|
||||
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../command-builder/command-module';
|
||||
|
||||
export class ServeCommandModule
|
||||
extends ArchitectCommandModule
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
import { join } from 'path';
|
||||
import { ArchitectCommandModule } from '../../utilities/command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../utilities/command-builder/command-module';
|
||||
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
|
||||
import { CommandModuleImplementation } from '../../command-builder/command-module';
|
||||
|
||||
export class TestCommandModule
|
||||
extends ArchitectCommandModule
|
@ -12,7 +12,7 @@ import {
|
||||
CommandScope,
|
||||
Options,
|
||||
OtherOptions,
|
||||
} from '../../utilities/command-builder/command-module';
|
||||
} from '../../command-builder/command-module';
|
||||
import { UpdateCommand } from './update-impl';
|
||||
|
||||
export interface UpdateCommandArgs {
|
@ -10,11 +10,8 @@ import { logging, tags } from '@angular-devkit/core';
|
||||
import { Rule, SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics';
|
||||
import * as npa from 'npm-package-arg';
|
||||
import * as semver from 'semver';
|
||||
import { Dependency, JsonSchemaForNpmPackageJsonFiles } from '../../../../utilities/package-json';
|
||||
import {
|
||||
NpmRepositoryPackageJson,
|
||||
getNpmPackageJson,
|
||||
} from '../../../../utilities/package-metadata';
|
||||
import { Dependency, JsonSchemaForNpmPackageJsonFiles } from '../../../utilities/package-json';
|
||||
import { NpmRepositoryPackageJson, getNpmPackageJson } from '../../../utilities/package-metadata';
|
||||
import { Schema as UpdateSchema } from './schema';
|
||||
|
||||
type VersionRange = string & { __VERSION_RANGE: void };
|
||||
|
@ -14,11 +14,11 @@ import npa from 'npm-package-arg';
|
||||
import pickManifest from 'npm-pick-manifest';
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import { PackageManager } from '../../lib/config/workspace-schema';
|
||||
import { Command } from '../../models/command';
|
||||
import { SchematicEngineHost } from '../../models/schematic-engine-host';
|
||||
import { PackageManager } from '../../../lib/config/workspace-schema';
|
||||
import { Command } from '../../../models/command';
|
||||
import { SchematicEngineHost } from '../../../models/schematic-engine-host';
|
||||
import { Options } from '../../command-builder/command-module';
|
||||
import { colors } from '../../utilities/color';
|
||||
import { Options } from '../../utilities/command-builder/command-module';
|
||||
import { installAllPackages, runTempPackageBin } from '../../utilities/install-package';
|
||||
import { writeErrorToLogFile } from '../../utilities/log-file';
|
||||
import { ensureCompatibleNpm, getPackageManager } from '../../utilities/package-manager';
|
||||
@ -37,10 +37,7 @@ import {
|
||||
import { VERSION } from '../../utilities/version';
|
||||
import { UpdateCommandArgs } from './cli';
|
||||
|
||||
const UPDATE_SCHEMATIC_COLLECTION = path.join(
|
||||
__dirname,
|
||||
'../../src/commands/update/schematic/collection.json',
|
||||
);
|
||||
const UPDATE_SCHEMATIC_COLLECTION = path.join(__dirname, 'schematic/collection.json');
|
||||
|
||||
type UpdateCommandOptions = Options<UpdateCommandArgs>;
|
||||
|
@ -8,12 +8,10 @@
|
||||
|
||||
import { execSync } from 'child_process';
|
||||
import nodeModule from 'module';
|
||||
import { resolve } from 'path';
|
||||
import { Argv } from 'yargs';
|
||||
import { CommandModule, CommandModuleImplementation } from '../../command-builder/command-module';
|
||||
import { colors } from '../../utilities/color';
|
||||
import {
|
||||
CommandModule,
|
||||
CommandModuleImplementation,
|
||||
} from '../../utilities/command-builder/command-module';
|
||||
import { getPackageManager } from '../../utilities/package-manager';
|
||||
|
||||
interface PartialPackageInfo {
|
||||
@ -53,11 +51,11 @@ export class VersionCommandModule extends CommandModule implements CommandModule
|
||||
|
||||
async run(): Promise<void> {
|
||||
const logger = this.context.logger;
|
||||
const localRequire = nodeModule.createRequire(__filename);
|
||||
const localRequire = nodeModule.createRequire(resolve(__filename, '../../../'));
|
||||
// Trailing slash is used to allow the path to be treated as a directory
|
||||
const workspaceRequire = nodeModule.createRequire(this.context.root + '/');
|
||||
|
||||
const cliPackage: PartialPackageInfo = localRequire('../../package.json');
|
||||
const cliPackage: PartialPackageInfo = localRequire('./package.json');
|
||||
let workspacePackage: PartialPackageInfo | undefined;
|
||||
try {
|
||||
workspacePackage = workspaceRequire('./package.json');
|
@ -18,9 +18,9 @@ declare module 'ini' {
|
||||
|
||||
declare module 'npm-pick-manifest' {
|
||||
function pickManifest(
|
||||
metadata: import('../utilities/package-metadata').PackageMetadata,
|
||||
metadata: import('./utilities/package-metadata').PackageMetadata,
|
||||
selector: string,
|
||||
): import('../utilities/package-metadata').PackageManifest;
|
||||
): import('./utilities/package-metadata').PackageManifest;
|
||||
export = pickManifest;
|
||||
}
|
||||
|
||||
@ -33,5 +33,5 @@ declare module 'pacote' {
|
||||
export function packument(
|
||||
specifier: string,
|
||||
options: Record<string, unknown>,
|
||||
): Promise<import('../utilities/package-metadata').NpmRepositoryPackageJson>;
|
||||
): Promise<import('./utilities/package-metadata').NpmRepositoryPackageJson>;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import { json, workspaces } from '@angular-devkit/core';
|
||||
import { existsSync, readFileSync, statSync, writeFileSync } from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { PackageManager } from '../lib/config/workspace-schema';
|
||||
import { PackageManager } from '../../lib/config/workspace-schema';
|
||||
import { findUp } from './find-up';
|
||||
import { JSONFile, readAndParseJson } from './json-file';
|
||||
|
||||
@ -43,11 +43,7 @@ function createWorkspaceHost(): workspaces.WorkspaceHost {
|
||||
};
|
||||
}
|
||||
|
||||
function getSchemaLocation(): string {
|
||||
return path.join(__dirname, '../lib/config/schema.json');
|
||||
}
|
||||
|
||||
export const workspaceSchemaPath = getSchemaLocation();
|
||||
export const workspaceSchemaPath = path.join(__dirname, '../../lib/config/schema.json');
|
||||
|
||||
const configNames = ['angular.json', '.angular.json'];
|
||||
const globalFileName = '.angular-config.json';
|
||||
@ -214,9 +210,7 @@ export function getWorkspaceRaw(
|
||||
}
|
||||
|
||||
export async function validateWorkspace(data: json.JsonObject): Promise<void> {
|
||||
const schema = readAndParseJson(
|
||||
path.join(__dirname, '../lib/config/schema.json'),
|
||||
) as json.schema.JsonSchema;
|
||||
const schema = readAndParseJson(workspaceSchemaPath) as json.schema.JsonSchema;
|
||||
const { formats } = await import('@angular-devkit/schematics');
|
||||
const registry = new json.schema.CoreSchemaRegistry(formats.standardFormats);
|
||||
const validator = await registry.compile(schema).toPromise();
|
@ -10,8 +10,8 @@ import { spawn, spawnSync } from 'child_process';
|
||||
import { existsSync, mkdtempSync, readFileSync, realpathSync, rmdirSync, writeFileSync } from 'fs';
|
||||
import { tmpdir } from 'os';
|
||||
import { join, resolve } from 'path';
|
||||
import { PackageManager } from '../lib/config/workspace-schema';
|
||||
import { NgAddSaveDepedency } from '../utilities/package-metadata';
|
||||
import { PackageManager } from '../../lib/config/workspace-schema';
|
||||
import { NgAddSaveDepedency } from './package-metadata';
|
||||
import { Spinner } from './spinner';
|
||||
|
||||
interface PackageManagerOptions {
|
@ -11,7 +11,7 @@ import { constants, promises as fs } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { satisfies, valid } from 'semver';
|
||||
import { promisify } from 'util';
|
||||
import { PackageManager } from '../lib/config/workspace-schema';
|
||||
import { PackageManager } from '../../lib/config/workspace-schema';
|
||||
import { getConfiguredPackageManager } from './config';
|
||||
|
||||
const exec = promisify(execCb);
|
@ -27,6 +27,8 @@ class Version {
|
||||
// export const VERSION = new Version('0.0.0-PLACEHOLDER');
|
||||
export const VERSION = new Version(
|
||||
(
|
||||
JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf-8')) as { version: string }
|
||||
JSON.parse(readFileSync(resolve(__dirname, '../../package.json'), 'utf-8')) as {
|
||||
version: string;
|
||||
}
|
||||
).version,
|
||||
);
|
@ -10,7 +10,7 @@ import { logging } from '@angular-devkit/core';
|
||||
import { spawn } from 'child_process';
|
||||
import { promises as fs } from 'fs';
|
||||
import * as os from 'os';
|
||||
import { JsonHelp } from 'packages/angular/cli/utilities/command-builder/json-help';
|
||||
import { JsonHelp } from 'packages/angular/cli/src/command-builder/utilities/json-help';
|
||||
import * as path from 'path';
|
||||
import { packages } from '../lib/packages';
|
||||
import create from './create';
|
||||
|
Loading…
x
Reference in New Issue
Block a user