Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions goldens/circular-deps/packages.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[
[
"packages/angular_devkit/build_angular/src/builders/dev-server/builder.ts",
"packages/angular_devkit/build_angular/src/builders/dev-server/options.ts"
],
[
"packages/angular/build/src/tools/esbuild/angular/component-stylesheets.ts",
"packages/angular/build/src/tools/esbuild/bundler-context.ts",
Expand Down Expand Up @@ -30,9 +26,5 @@
[
"packages/angular/build/src/tools/esbuild/utils.ts",
"packages/angular/build/src/utils/server-rendering/manifest.ts"
],
[
"packages/angular/cli/src/analytics/analytics.ts",
"packages/angular/cli/src/command-builder/command-module.ts"
]
]
2 changes: 1 addition & 1 deletion packages/angular/cli/src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { json, tags } from '@angular-devkit/core';
import { randomUUID } from 'node:crypto';
import type { CommandContext } from '../command-builder/command-module';
import type { CommandContext } from '../command-builder/definitions';
import { colors } from '../utilities/color';
import { getWorkspace } from '../utilities/config';
import { analyticsDisabled } from '../utilities/environment-options';
Expand Down
44 changes: 4 additions & 40 deletions packages/angular/cli/src/command-builder/command-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
import { logging, schema } from '@angular-devkit/core';
import { readFileSync } from 'node:fs';
import * as path from 'node:path';
import type {
ArgumentsCamelCase,
Argv,
CamelCaseKey,
CommandModule as YargsCommandModule,
} from 'yargs';
import type { ArgumentsCamelCase, Argv, CommandModule as YargsCommandModule } from 'yargs';
import { Parser as yargsParser } from 'yargs/helpers';
import { getAnalyticsUserId } from '../analytics/analytics';
import { AnalyticsCollector } from '../analytics/analytics-collector';
Expand All @@ -23,42 +18,11 @@ import { considerSettingUpAutocompletion } from '../utilities/completion';
import { AngularWorkspace } from '../utilities/config';
import { memoize } from '../utilities/memoize';
import { PackageManagerUtils } from '../utilities/package-manager';
import { CommandContext, CommandScope, Options, OtherOptions } from './definitions';
import { Option, addSchemaOptionsToCommand } from './utilities/json-schema';

export type Options<T> = { [key in keyof T as CamelCaseKey<key>]: T[key] };

export enum CommandScope {
/** Command can only run inside an Angular workspace. */
In,

/** Command can only run outside an Angular workspace. */
Out,

/** Command can run inside and outside an Angular workspace. */
Both,
}

export interface CommandContext {
currentDirectory: string;
root: string;
workspace?: AngularWorkspace;
globalConfiguration: AngularWorkspace;
logger: logging.Logger;
packageManager: PackageManagerUtils;
yargsInstance: Argv<{}>;

/** Arguments parsed in free-from without parser configuration. */
args: {
positional: string[];
options: {
help: boolean;
jsonHelp: boolean;
getYargsCompletions: boolean;
} & Record<string, unknown>;
};
}

export type OtherOptions = Record<string, unknown>;
export { CommandScope };
export type { CommandContext, Options, OtherOptions };

export interface CommandModuleImplementation<T extends {} = {}> extends Omit<
YargsCommandModule<{}, T>,
Expand Down
47 changes: 47 additions & 0 deletions packages/angular/cli/src/command-builder/definitions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @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.dev/license
*/

import { logging } from '@angular-devkit/core';
import type { Argv, CamelCaseKey } from 'yargs';
import { AngularWorkspace } from '../utilities/config';
import { PackageManagerUtils } from '../utilities/package-manager';

export enum CommandScope {
/** Command can only run inside an Angular workspace. */
In,

/** Command can only run outside an Angular workspace. */
Out,

/** Command can run inside and outside an Angular workspace. */
Both,
}

export interface CommandContext {
currentDirectory: string;
root: string;
workspace?: AngularWorkspace;
globalConfiguration: AngularWorkspace;
logger: logging.Logger;
packageManager: PackageManagerUtils;
yargsInstance: Argv<{}>;

/** Arguments parsed in free-from without parser configuration. */
args: {
positional: string[];
options: {
help: boolean;
jsonHelp: boolean;
getYargsCompletions: boolean;
} & Record<string, unknown>;
};
}

export type Options<T> = { [key in keyof T as CamelCaseKey<key>]: T[key] };

export type OtherOptions = Record<string, unknown>;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { Plugin } from 'esbuild';
import type http from 'node:http';
import { EMPTY, Observable, defer, switchMap } from 'rxjs';
import type { ExecutionTransformer } from '../../transforms';
import { normalizeOptions } from './options';
import { isEsbuildBased, normalizeOptions } from './options';
import type { Schema as DevServerBuilderOptions } from './schema';

/**
Expand Down Expand Up @@ -194,23 +194,6 @@ case.
};
}

export function isEsbuildBased(
builderName: string,
): builderName is
| '@angular/build:application'
| '@angular-devkit/build-angular:application'
| '@angular-devkit/build-angular:browser-esbuild' {
if (
builderName === '@angular/build:application' ||
builderName === '@angular-devkit/build-angular:application' ||
builderName === '@angular-devkit/build-angular:browser-esbuild'
) {
return true;
}

return false;
}

interface BuilderSelectorInfo {
builderName: string;
forceEsbuild: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,27 @@ import { BuilderContext, targetFromTargetString } from '@angular-devkit/architec
import path from 'node:path';
import { normalizeCacheOptions } from '../../utils/normalize-cache';
import { normalizeOptimization } from '../../utils/normalize-optimization';
import { isEsbuildBased } from './builder';
import { Schema as DevServerOptions } from './schema';

export type NormalizedDevServerOptions = Awaited<ReturnType<typeof normalizeOptions>>;

export function isEsbuildBased(
builderName: string,
): builderName is
| '@angular/build:application'
| '@angular-devkit/build-angular:application'
| '@angular-devkit/build-angular:browser-esbuild' {
if (
builderName === '@angular/build:application' ||
builderName === '@angular-devkit/build-angular:application' ||
builderName === '@angular-devkit/build-angular:browser-esbuild'
) {
return true;
}

return false;
}

/**
* Normalize the user provided options by creating full paths for all path based options
* and converting multi-form options into a single form that can be directly used
Expand Down