Skip to content

refactor(@angular-devkit/architect): update to support building with isolated declarations #30618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/angular_devkit/architect/builders/all-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { json } from '@angular-devkit/core';
import { EMPTY, from, map, mergeMap, of } from 'rxjs';
import { BuilderOutput, BuilderRun, createBuilder } from '../src';
import { Builder, BuilderOutput, BuilderRun, createBuilder } from '../src';
import { Schema as OperatorSchema } from './operator-schema';

export default createBuilder<json.JsonObject & OperatorSchema>((options, context) => {
const builder: Builder<OperatorSchema> = createBuilder((options, context) => {
const allRuns: Promise<[number, BuilderRun]>[] = [];

context.reportProgress(
Expand Down Expand Up @@ -66,3 +65,5 @@ export default createBuilder<json.JsonObject & OperatorSchema>((options, context
}),
);
});

export default builder;
7 changes: 4 additions & 3 deletions packages/angular_devkit/architect/builders/concat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { json } from '@angular-devkit/core';
import { concatMap, first, from, last, map, of, switchMap } from 'rxjs';
import { BuilderOutput, BuilderRun, createBuilder } from '../src';
import { Builder, BuilderOutput, BuilderRun, createBuilder } from '../src';
import { Schema as OperatorSchema } from './operator-schema';

export default createBuilder<json.JsonObject & OperatorSchema>((options, context) => {
const builder: Builder<OperatorSchema> = createBuilder((options, context) => {
const allRuns: (() => Promise<BuilderRun>)[] = [];

context.reportProgress(
Expand Down Expand Up @@ -61,3 +60,5 @@ export default createBuilder<json.JsonObject & OperatorSchema>((options, context
last(),
);
});

export default builder;
6 changes: 4 additions & 2 deletions packages/angular_devkit/architect/builders/false.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { createBuilder } from '../src';
import { type Builder, createBuilder } from '../src';

export default createBuilder(() => ({
const builder: Builder<{}> = createBuilder(() => ({
success: false,
error: 'False builder always errors.',
}));

export default builder;
6 changes: 4 additions & 2 deletions packages/angular_devkit/architect/builders/true.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { createBuilder } from '../src';
import { type Builder, createBuilder } from '../src';

export default createBuilder(() => ({ success: true }));
const builder: Builder<{}> = createBuilder(() => ({ success: true }));

export default builder;
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
}
}

async getBuilderNameForTarget(target: Target) {
async getBuilderNameForTarget(target: Target): Promise<string> {
return this.workspaceHost.getBuilderName(target.project, target.target);
}

Expand All @@ -134,7 +134,7 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
*/
resolveBuilder(
builderStr: string,
basePath = this._root,
basePath: string = this._root,
seenBuilders?: Set<string>,
): Promise<NodeModulesBuilderInfo> {
if (seenBuilders?.has(builderStr)) {
Expand Down Expand Up @@ -228,11 +228,11 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
});
}

async getCurrentDirectory() {
async getCurrentDirectory(): Promise<string> {
return process.cwd();
}

async getWorkspaceRoot() {
async getWorkspaceRoot(): Promise<string> {
return this._root;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/architect/src/architect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export class Architect {
this._scheduler = new SimpleScheduler(jobRegistry, registry);
}

has(name: JobName) {
has(name: JobName): Observable<boolean> {
return this._scheduler.has(name);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/angular_devkit/architect/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import { JobDescription, JobHandler } from './jobs';
* Using Symbol.for() as it's a global registry that's the same for all installations of
* Architect (if some libraries depends directly on architect instead of sharing the files).
*/
export const BuilderSymbol = Symbol.for('@angular-devkit/architect:builder');
export const BuilderSymbol: unique symbol = Symbol.for('@angular-devkit/architect:builder');

/**
* BuilderVersionSymbol used for knowing which version of the library createBuilder() came from.
* This is to make sure we don't try to use an incompatible builder.
* Using Symbol.for() as it's a global registry that's the same for all installations of
* Architect (if some libraries depends directly on architect instead of sharing the files).
*/
export const BuilderVersionSymbol = Symbol.for('@angular-devkit/architect:version');
export const BuilderVersionSymbol: unique symbol = Symbol.for('@angular-devkit/architect:version');

/**
* A Specialization of the JobHandler type. This exposes BuilderDescription as the job description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class FallbackRegistry<
>[] = [],
) {}

addFallback(registry: Registry) {
addFallback(registry: Registry): void {
this._fallbacks.push(registry);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class SimpleScheduler<
* @param name The name of the job.
* @returns A description, or null if the job is not registered.
*/
getDescription(name: JobName) {
getDescription(name: JobName): Observable<JobDescription | null> {
return concat(
this._getInternalDescription(name).pipe(map((x) => x && x.jobDescription)),
of(null),
Expand All @@ -197,7 +197,7 @@ export class SimpleScheduler<
* @param name The name of the job.
* @returns True if the job exists, false otherwise.
*/
has(name: JobName) {
has(name: JobName): Observable<boolean> {
return this.getDescription(name).pipe(map((x) => x !== null));
}

Expand All @@ -209,7 +209,7 @@ export class SimpleScheduler<
*
* Jobs already running are NOT paused. This is pausing the scheduler only.
*/
pause() {
pause(): () => void {
let called = false;
this._pauseCounter++;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ export class TestProjectHost extends NodeJsSyncHost {
});
}

replaceInFile(path: string, match: RegExp | string, replacement: string) {
replaceInFile(path: string, match: RegExp | string, replacement: string): void {
const content = virtualFs.fileBufferToString(this.scopedSync().read(normalize(path)));
this.scopedSync().write(
normalize(path),
virtualFs.stringToFileBuffer(content.replace(match, replacement)),
);
}

appendToFile(path: string, str: string) {
appendToFile(path: string, str: string): void {
const content = virtualFs.fileBufferToString(this.scopedSync().read(normalize(path)));
this.scopedSync().write(normalize(path), virtualFs.stringToFileBuffer(content.concat(str)));
}
Expand All @@ -147,7 +147,7 @@ export class TestProjectHost extends NodeJsSyncHost {
return fileName || undefined;
}

copyFile(from: string, to: string) {
copyFile(from: string, to: string): void {
const content = this.scopedSync().read(normalize(from));
this.scopedSync().write(normalize(to), content);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class TestingArchitectHost implements ArchitectHost {
*/
constructor(
public workspaceRoot = '',
public currentDirectory = workspaceRoot,
public currentDirectory: string = workspaceRoot,
private _backendHost: ArchitectHost | null = null,
) {}

Expand All @@ -32,11 +32,11 @@ export class TestingArchitectHost implements ArchitectHost {
builder: Builder,
description = 'Testing only builder.',
optionSchema: json.schema.JsonSchema = { type: 'object' },
) {
): void {
this._builderImportMap.set(builderName, builder);
this._builderMap.set(builderName, { builderName, description, optionSchema });
}
async addBuilderFromPackage(packageName: string) {
async addBuilderFromPackage(packageName: string): Promise<void> {
const packageJson = await import(packageName + '/package.json');
if (!('builders' in packageJson)) {
throw new Error('Invalid package.json, builders key not found.');
Expand Down Expand Up @@ -64,7 +64,7 @@ export class TestingArchitectHost implements ArchitectHost {
this.addBuilder(`${packageJson.name}:${builderName}`, handler, b.description, optionsSchema);
}
}
addTarget(target: Target, builderName: string, options: json.JsonObject = {}) {
addTarget(target: Target, builderName: string, options: json.JsonObject = {}): void {
this._targetMap.set(targetStringFromTarget(target), { builderName, options });
}

Expand Down
Loading