From 93adeeb798f1ae4d88478b447ded862909cc7475 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 7 Oct 2022 14:24:06 +0000 Subject: [PATCH] refactor: move experimental `jobs` API from `@angular-devkit/core` to `@angular-devkit/architect` With this change we move `jobs` APIs to `@angular-devkit/architect` as this are intended to used with `@angular-devkit/architect`. --- .../angular_devkit/architect/index.md | 387 ++++++++++++++++- .../public-api/angular_devkit/core/index.md | 399 ------------------ .../angular_devkit/core/node/index.md | 19 - .../angular_devkit/architect/node/BUILD.bazel | 30 ++ .../angular_devkit/architect/node/index.ts | 4 + .../node}/jobs/job-registry.ts | 10 +- .../node}/jobs/job-registry_spec.ts | 9 +- packages/angular_devkit/architect/src/api.ts | 9 +- .../angular_devkit/architect/src/architect.ts | 54 ++- .../architect/src/create-builder.ts | 9 +- .../angular_devkit/architect/src/index.ts | 4 + .../angular_devkit/architect/src/internal.ts | 11 +- .../src}/jobs/README.md | 4 +- .../src}/jobs/api.ts | 16 +- .../src}/jobs/architecture.md | 0 .../src}/jobs/create-job-handler.ts | 7 +- .../src}/jobs/dispatcher.ts | 8 +- .../src}/jobs/dispatcher_spec.ts | 2 +- .../src}/jobs/exception.ts | 2 +- .../src}/jobs/fallback-registry.ts | 9 +- .../src}/jobs/index.ts | 0 .../src}/jobs/simple-registry.ts | 19 +- .../src}/jobs/simple-registry_spec.ts | 0 .../src}/jobs/simple-scheduler.ts | 11 +- .../src}/jobs/simple-scheduler_spec.ts | 0 .../src}/jobs/strategy.ts | 2 +- .../src}/jobs/strategy_spec.ts | 0 .../architect/src/jobs/types.ts | 26 ++ .../architect/src/schedule-by-name.ts | 11 +- packages/angular_devkit/core/BUILD.bazel | 2 - packages/angular_devkit/core/node/BUILD.bazel | 1 - .../core/node/experimental/index.ts | 11 - .../core/node/experimental/jobs/index.ts | 9 - packages/angular_devkit/core/node/index.ts | 4 - .../angular_devkit/core/src/experimental.ts | 11 - packages/angular_devkit/core/src/index.ts | 3 +- .../angular_devkit/core/src/utils/index.ts | 20 - .../{core => architect}/node/jobs/BUILD.bazel | 2 +- .../angular_devkit/architect/node/jobs/add.ts | 20 + tests/angular_devkit/core/node/jobs/add.ts | 19 - 40 files changed, 570 insertions(+), 594 deletions(-) rename packages/angular_devkit/{core/node/experimental => architect/node}/jobs/job-registry.ts (85%) rename packages/angular_devkit/{core/node/experimental => architect/node}/jobs/job-registry_spec.ts (66%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/README.md (99%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/api.ts (97%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/architecture.md (100%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/create-job-handler.ts (96%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/dispatcher.ts (93%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/dispatcher_spec.ts (96%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/exception.ts (91%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/fallback-registry.ts (86%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/index.ts (100%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/simple-registry.ts (89%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/simple-registry_spec.ts (100%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/simple-scheduler.ts (98%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/simple-scheduler_spec.ts (100%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/strategy.ts (98%) rename packages/angular_devkit/{core/src/experimental => architect/src}/jobs/strategy_spec.ts (100%) create mode 100644 packages/angular_devkit/architect/src/jobs/types.ts delete mode 100644 packages/angular_devkit/core/node/experimental/index.ts delete mode 100644 packages/angular_devkit/core/node/experimental/jobs/index.ts delete mode 100644 packages/angular_devkit/core/src/experimental.ts rename tests/angular_devkit/{core => architect}/node/jobs/BUILD.bazel (90%) create mode 100644 tests/angular_devkit/architect/node/jobs/add.ts delete mode 100644 tests/angular_devkit/core/node/jobs/add.ts diff --git a/goldens/public-api/angular_devkit/architect/index.md b/goldens/public-api/angular_devkit/architect/index.md index 3c61b83eb5..0a7756b87f 100644 --- a/goldens/public-api/angular_devkit/architect/index.md +++ b/goldens/public-api/angular_devkit/architect/index.md @@ -5,17 +5,21 @@ ```ts import { analytics } from '@angular-devkit/core'; -import { experimental } from '@angular-devkit/core'; +import { BaseException } from '@angular-devkit/core'; import { json } from '@angular-devkit/core'; +import { JsonObject } from '@angular-devkit/core'; +import { JsonValue } from '@angular-devkit/core'; import { logging } from '@angular-devkit/core'; import { Observable } from 'rxjs'; +import { Observer } from 'rxjs'; +import { schema } from '@angular-devkit/core'; import { SubscribableOrPromise } from 'rxjs'; // @public (undocumented) export class Architect { - constructor(_host: ArchitectHost, registry?: json.schema.SchemaRegistry, additionalJobRegistry?: experimental.jobs.Registry); + constructor(_host: ArchitectHost, registry?: json.schema.SchemaRegistry, additionalJobRegistry?: Registry); // (undocumented) - has(name: experimental.jobs.JobName): Observable; + has(name: JobName): Observable; // (undocumented) scheduleBuilder(name: string, options: json.JsonObject, scheduleOptions?: ScheduleOptions): Promise; // (undocumented) @@ -89,7 +93,7 @@ export enum BuilderProgressState { } // @public (undocumented) -export type BuilderRegistry = experimental.jobs.Registry; +export type BuilderRegistry = Registry; // @public export interface BuilderRun { @@ -101,15 +105,334 @@ export interface BuilderRun { stop(): Promise; } +// @public (undocumented) +class ChannelAlreadyExistException extends BaseException { + constructor(name: string); +} + // @public (undocumented) export function createBuilder(fn: BuilderHandlerFn): Builder; +// @public +function createDispatcher(options?: Partial>): JobDispatcher; + +// @public +function createJobFactory(loader: () => Promise>, options?: Partial): JobHandler; + +// @public +function createJobHandler(fn: SimpleJobHandlerFn, options?: Partial): JobHandler; + +// @public +function createLoggerJob(job: JobHandler, logger: logging.LoggerApi): JobHandler; + +// @public +class FallbackRegistry implements Registry { + constructor(_fallbacks?: Registry[]); + // (undocumented) + addFallback(registry: Registry): void; + // (undocumented) + protected _fallbacks: Registry[]; + // (undocumented) + get(name: JobName): Observable | null>; +} + // @public (undocumented) export function fromAsyncIterable(iterable: AsyncIterable): Observable; // @public (undocumented) export function isBuilderOutput(obj: any): obj is BuilderOutput; +// @public (undocumented) +function isJobHandler(value: unknown): value is JobHandler; + +// @public +interface Job { + readonly argument: ArgumentT; + readonly description: Observable; + getChannel(name: string, schema?: schema.JsonSchema): Observable; + readonly inboundBus: Observer>; + readonly input: Observer; + readonly outboundBus: Observable>; + readonly output: Observable; + ping(): Observable; + readonly state: JobState; + stop(): void; +} + +// @public (undocumented) +class JobArgumentSchemaValidationError extends schema.SchemaValidationException { + constructor(errors?: schema.SchemaValidatorError[]); +} + +// @public +interface JobDescription extends JsonObject { + // (undocumented) + readonly argument: DeepReadonly; + // (undocumented) + readonly input: DeepReadonly; + // (undocumented) + readonly name: JobName; + // (undocumented) + readonly output: DeepReadonly; +} + +// @public +interface JobDispatcher extends JobHandler { + addConditionalJob(predicate: (args: A) => boolean, name: string): void; + setDefaultJob(name: JobName | null | JobHandler): void; +} + +// @public (undocumented) +class JobDoesNotExistException extends BaseException { + constructor(name: JobName); +} + +// @public +interface JobHandler { + // (undocumented) + (argument: ArgT, context: JobHandlerContext): Observable>; + // (undocumented) + jobDescription: Partial; +} + +// @public +interface JobHandlerContext { + // (undocumented) + readonly dependencies: Job[]; + // (undocumented) + readonly description: JobDescription; + // (undocumented) + readonly inboundBus: Observable>; + // (undocumented) + readonly scheduler: Scheduler; +} + +// @public (undocumented) +type JobInboundMessage = JobInboundMessagePing | JobInboundMessageStop | JobInboundMessageInput; + +// @public +interface JobInboundMessageBase extends JsonObject { + readonly kind: JobInboundMessageKind; +} + +// @public +interface JobInboundMessageInput extends JobInboundMessageBase { + // (undocumented) + readonly kind: JobInboundMessageKind.Input; + readonly value: InputT; +} + +// @public +enum JobInboundMessageKind { + // (undocumented) + Input = "in", + // (undocumented) + Ping = "ip", + // (undocumented) + Stop = "is" +} + +// @public +interface JobInboundMessagePing extends JobInboundMessageBase { + readonly id: number; + // (undocumented) + readonly kind: JobInboundMessageKind.Ping; +} + +// @public (undocumented) +class JobInboundMessageSchemaValidationError extends schema.SchemaValidationException { + constructor(errors?: schema.SchemaValidatorError[]); +} + +// @public +interface JobInboundMessageStop extends JobInboundMessageBase { + // (undocumented) + readonly kind: JobInboundMessageKind.Stop; +} + +// @public +type JobName = string; + +// @public (undocumented) +class JobNameAlreadyRegisteredException extends BaseException { + constructor(name: JobName); +} + +// @public +type JobOutboundMessage = JobOutboundMessageOnReady | JobOutboundMessageStart | JobOutboundMessageOutput | JobOutboundMessageChannelCreate | JobOutboundMessageChannelMessage | JobOutboundMessageChannelError | JobOutboundMessageChannelComplete | JobOutboundMessageEnd | JobOutboundMessagePong; + +// @public +interface JobOutboundMessageBase { + readonly description: JobDescription; + readonly kind: JobOutboundMessageKind; +} + +// @public +interface JobOutboundMessageChannelBase extends JobOutboundMessageBase { + readonly name: string; +} + +// @public +interface JobOutboundMessageChannelComplete extends JobOutboundMessageChannelBase { + // (undocumented) + readonly kind: JobOutboundMessageKind.ChannelComplete; +} + +// @public +interface JobOutboundMessageChannelCreate extends JobOutboundMessageChannelBase { + // (undocumented) + readonly kind: JobOutboundMessageKind.ChannelCreate; +} + +// @public +interface JobOutboundMessageChannelError extends JobOutboundMessageChannelBase { + readonly error: JsonValue; + // (undocumented) + readonly kind: JobOutboundMessageKind.ChannelError; +} + +// @public +interface JobOutboundMessageChannelMessage extends JobOutboundMessageChannelBase { + // (undocumented) + readonly kind: JobOutboundMessageKind.ChannelMessage; + readonly message: JsonValue; +} + +// @public +interface JobOutboundMessageEnd extends JobOutboundMessageBase { + // (undocumented) + readonly kind: JobOutboundMessageKind.End; +} + +// @public +enum JobOutboundMessageKind { + // (undocumented) + ChannelComplete = "cc", + // (undocumented) + ChannelCreate = "cn", + // (undocumented) + ChannelError = "ce", + // (undocumented) + ChannelMessage = "cm", + // (undocumented) + End = "e", + // (undocumented) + OnReady = "c", + // (undocumented) + Output = "o", + // (undocumented) + Pong = "p", + // (undocumented) + Start = "s" +} + +// @public +interface JobOutboundMessageOnReady extends JobOutboundMessageBase { + // (undocumented) + readonly kind: JobOutboundMessageKind.OnReady; +} + +// @public +interface JobOutboundMessageOutput extends JobOutboundMessageBase { + // (undocumented) + readonly kind: JobOutboundMessageKind.Output; + readonly value: OutputT; +} + +// @public +interface JobOutboundMessagePong extends JobOutboundMessageBase { + readonly id: number; + // (undocumented) + readonly kind: JobOutboundMessageKind.Pong; +} + +// @public +interface JobOutboundMessageStart extends JobOutboundMessageBase { + // (undocumented) + readonly kind: JobOutboundMessageKind.Start; +} + +// @public (undocumented) +class JobOutputSchemaValidationError extends schema.SchemaValidationException { + constructor(errors?: schema.SchemaValidatorError[]); +} + +declare namespace jobs { + export { + isJobHandler, + JobName, + JobHandler, + JobHandlerContext, + JobDescription, + JobInboundMessageKind, + JobInboundMessageBase, + JobInboundMessagePing, + JobInboundMessageStop, + JobInboundMessageInput, + JobInboundMessage, + JobOutboundMessageKind, + JobOutboundMessageBase, + JobOutboundMessageOnReady, + JobOutboundMessageStart, + JobOutboundMessageOutput, + JobOutboundMessageChannelBase, + JobOutboundMessageChannelMessage, + JobOutboundMessageChannelError, + JobOutboundMessageChannelCreate, + JobOutboundMessageChannelComplete, + JobOutboundMessageEnd, + JobOutboundMessagePong, + JobOutboundMessage, + JobState, + Job, + ScheduleJobOptions, + Registry, + Scheduler, + createJobHandler, + createJobFactory, + createLoggerJob, + ChannelAlreadyExistException, + SimpleJobHandlerContext, + SimpleJobHandlerFn, + JobNameAlreadyRegisteredException, + JobDoesNotExistException, + createDispatcher, + JobDispatcher, + FallbackRegistry, + RegisterJobOptions, + SimpleJobRegistry, + JobArgumentSchemaValidationError, + JobInboundMessageSchemaValidationError, + JobOutputSchemaValidationError, + SimpleScheduler, + strategy + } +} +export { jobs } + +// @public +enum JobState { + Ended = "ended", + Errored = "errored", + Queued = "queued", + Ready = "ready", + Started = "started" +} + +// @public +interface RegisterJobOptions extends Partial { +} + +// @public (undocumented) +interface Registry { + get(name: JobName): Observable | null>; +} + +// @public +interface ScheduleJobOptions { + dependencies?: Job | Job[]; +} + // @public (undocumented) export interface ScheduleOptions { // (undocumented) @@ -118,9 +441,65 @@ export interface ScheduleOptions { logger?: logging.Logger; } +// @public +interface Scheduler { + getDescription(name: JobName): Observable; + has(name: JobName): Observable; + pause(): () => void; + schedule(name: JobName, argument: A, options?: ScheduleJobOptions): Job; +} + // @public export function scheduleTargetAndForget(context: BuilderContext, target: Target, overrides?: json.JsonObject, scheduleOptions?: ScheduleOptions_2): Observable; +// @public +interface SimpleJobHandlerContext extends JobHandlerContext { + // (undocumented) + createChannel: (name: string) => Observer; + // (undocumented) + input: Observable; +} + +// @public +type SimpleJobHandlerFn = (input: A, context: SimpleJobHandlerContext) => O | Promise | Observable; + +// @public +class SimpleJobRegistry implements Registry { + // (undocumented) + get(name: JobName): Observable | null>; + getJobNames(): JobName[]; + register(name: JobName, handler: JobHandler, options?: RegisterJobOptions): void; + register(handler: JobHandler, options?: RegisterJobOptions & { + name: string; + }): void; + // (undocumented) + protected _register(name: JobName, handler: JobHandler, options: RegisterJobOptions): void; +} + +// @public +class SimpleScheduler implements Scheduler { + constructor(_jobRegistry: Registry, _schemaRegistry?: schema.SchemaRegistry); + getDescription(name: JobName): Observable; + has(name: JobName): Observable; + // (undocumented) + protected _jobRegistry: Registry; + pause(): () => void; + schedule(name: JobName, argument: A, options?: ScheduleJobOptions): Job; + // (undocumented) + protected _scheduleJob(name: JobName, argument: A, options: ScheduleJobOptions, waitable: Observable): Job; + // (undocumented) + protected _schemaRegistry: schema.SchemaRegistry; +} + +// @public (undocumented) +namespace strategy { + // (undocumented) + type JobStrategy = (handler: JobHandler, options?: Partial>) => JobHandler; + function memoize(replayMessages?: boolean): JobStrategy; + function reuse(replayMessages?: boolean): JobStrategy; + function serialize(): JobStrategy; +} + // @public (undocumented) export type Target = json.JsonObject & Target_2; diff --git a/goldens/public-api/angular_devkit/core/index.md b/goldens/public-api/angular_devkit/core/index.md index 37c432c8db..386dc9b364 100644 --- a/goldens/public-api/angular_devkit/core/index.md +++ b/goldens/public-api/angular_devkit/core/index.md @@ -7,7 +7,6 @@ import { ErrorObject } from 'ajv'; import { Format } from 'ajv'; import { Observable } from 'rxjs'; -import { Observer } from 'rxjs'; import { Operator } from 'rxjs'; import { PartialObserver } from 'rxjs'; import { Position } from 'source-map'; @@ -176,11 +175,6 @@ function camelize(str: string): string; // @public function capitalize(str: string): string; -// @public (undocumented) -class ChannelAlreadyExistException extends BaseException { - constructor(name: string); -} - // @public (undocumented) export class CircularDependencyFoundException extends BaseException { constructor(); @@ -318,18 +312,6 @@ class CoreSchemaRegistry implements SchemaRegistry { useXDeprecatedProvider(onUsage: (message: string) => void): void; } -// @public -function createDispatcher(options?: Partial>): JobDispatcher; - -// @public -function createJobFactory(loader: () => Promise>, options?: Partial): JobHandler; - -// @public -function createJobHandler(fn: SimpleJobHandlerFn, options?: Partial): JobHandler; - -// @public -function createLoggerJob(job: JobHandler, logger: LoggerApi): JobHandler; - // @public (undocumented) function createSyncHost(handler: SyncHostHandler): Host; @@ -353,18 +335,6 @@ function decamelize(str: string): string; // @public export function deepCopy(value: T): T; -// @public (undocumented) -export type DeepReadonly = T extends (infer R)[] ? DeepReadonlyArray : T extends Function ? T : T extends object ? DeepReadonlyObject : T; - -// @public (undocumented) -export interface DeepReadonlyArray extends Array> { -} - -// @public (undocumented) -export type DeepReadonlyObject = { - readonly [P in keyof T]: DeepReadonly; -}; - // @public (undocumented) type DefinitionCollectionListener = (name: string, newValue: V | undefined, collection: DefinitionCollection) => void; @@ -402,27 +372,9 @@ interface EventOptions extends CustomDimensionsAndMetricsOptions { value?: string; } -declare namespace experimental { - export { - jobs - } -} -export { experimental } - // @public (undocumented) export function extname(path: Path): string; -// @public -class FallbackRegistry implements Registry { - constructor(_fallbacks?: Registry[]); - // (undocumented) - addFallback(registry: Registry): void; - // (undocumented) - protected _fallbacks: Registry[]; - // (undocumented) - get(name: JobName): Observable | null>; -} - // @public (undocumented) export class FileAlreadyExistException extends BaseException { constructor(path: string); @@ -540,9 +492,6 @@ export class InvalidUpdateRecordException extends BaseException { // @public export function isAbsolute(p: Path): boolean; -// @public (undocumented) -function isJobHandler(value: unknown): value is JobHandler; - // @public (undocumented) export function isJsonArray(value: JsonValue): value is JsonArray; @@ -555,279 +504,6 @@ function isJsonSchema(value: unknown): value is JsonSchema; // @public export function isPromise(obj: any): obj is Promise; -// @public -interface Job { - readonly argument: ArgumentT; - readonly description: Observable; - getChannel(name: string, schema?: schema.JsonSchema): Observable; - readonly inboundBus: Observer>; - readonly input: Observer; - readonly outboundBus: Observable>; - readonly output: Observable; - ping(): Observable; - readonly state: JobState; - stop(): void; -} - -// @public (undocumented) -class JobArgumentSchemaValidationError extends schema.SchemaValidationException { - constructor(errors?: schema.SchemaValidatorError[]); -} - -// @public -interface JobDescription extends JsonObject { - // (undocumented) - readonly argument: DeepReadonly; - // (undocumented) - readonly input: DeepReadonly; - // (undocumented) - readonly name: JobName; - // (undocumented) - readonly output: DeepReadonly; -} - -// @public -interface JobDispatcher extends JobHandler { - addConditionalJob(predicate: (args: A) => boolean, name: string): void; - setDefaultJob(name: JobName | null | JobHandler): void; -} - -// @public (undocumented) -class JobDoesNotExistException extends BaseException { - constructor(name: JobName); -} - -// @public -interface JobHandler { - // (undocumented) - (argument: ArgT, context: JobHandlerContext): Observable>; - // (undocumented) - jobDescription: Partial; -} - -// @public -interface JobHandlerContext { - // (undocumented) - readonly dependencies: Job[]; - // (undocumented) - readonly description: JobDescription; - // (undocumented) - readonly inboundBus: Observable>; - // (undocumented) - readonly scheduler: Scheduler; -} - -// @public (undocumented) -type JobInboundMessage = JobInboundMessagePing | JobInboundMessageStop | JobInboundMessageInput; - -// @public -interface JobInboundMessageBase extends JsonObject { - readonly kind: JobInboundMessageKind; -} - -// @public -interface JobInboundMessageInput extends JobInboundMessageBase { - // (undocumented) - readonly kind: JobInboundMessageKind.Input; - readonly value: InputT; -} - -// @public -enum JobInboundMessageKind { - // (undocumented) - Input = "in", - // (undocumented) - Ping = "ip", - // (undocumented) - Stop = "is" -} - -// @public -interface JobInboundMessagePing extends JobInboundMessageBase { - readonly id: number; - // (undocumented) - readonly kind: JobInboundMessageKind.Ping; -} - -// @public (undocumented) -class JobInboundMessageSchemaValidationError extends schema.SchemaValidationException { - constructor(errors?: schema.SchemaValidatorError[]); -} - -// @public -interface JobInboundMessageStop extends JobInboundMessageBase { - // (undocumented) - readonly kind: JobInboundMessageKind.Stop; -} - -// @public -type JobName = string; - -// @public (undocumented) -class JobNameAlreadyRegisteredException extends BaseException { - constructor(name: JobName); -} - -// @public -type JobOutboundMessage = JobOutboundMessageOnReady | JobOutboundMessageStart | JobOutboundMessageOutput | JobOutboundMessageChannelCreate | JobOutboundMessageChannelMessage | JobOutboundMessageChannelError | JobOutboundMessageChannelComplete | JobOutboundMessageEnd | JobOutboundMessagePong; - -// @public -interface JobOutboundMessageBase { - readonly description: JobDescription; - readonly kind: JobOutboundMessageKind; -} - -// @public -interface JobOutboundMessageChannelBase extends JobOutboundMessageBase { - readonly name: string; -} - -// @public -interface JobOutboundMessageChannelComplete extends JobOutboundMessageChannelBase { - // (undocumented) - readonly kind: JobOutboundMessageKind.ChannelComplete; -} - -// @public -interface JobOutboundMessageChannelCreate extends JobOutboundMessageChannelBase { - // (undocumented) - readonly kind: JobOutboundMessageKind.ChannelCreate; -} - -// @public -interface JobOutboundMessageChannelError extends JobOutboundMessageChannelBase { - readonly error: JsonValue; - // (undocumented) - readonly kind: JobOutboundMessageKind.ChannelError; -} - -// @public -interface JobOutboundMessageChannelMessage extends JobOutboundMessageChannelBase { - // (undocumented) - readonly kind: JobOutboundMessageKind.ChannelMessage; - readonly message: JsonValue; -} - -// @public -interface JobOutboundMessageEnd extends JobOutboundMessageBase { - // (undocumented) - readonly kind: JobOutboundMessageKind.End; -} - -// @public -enum JobOutboundMessageKind { - // (undocumented) - ChannelComplete = "cc", - // (undocumented) - ChannelCreate = "cn", - // (undocumented) - ChannelError = "ce", - // (undocumented) - ChannelMessage = "cm", - // (undocumented) - End = "e", - // (undocumented) - OnReady = "c", - // (undocumented) - Output = "o", - // (undocumented) - Pong = "p", - // (undocumented) - Start = "s" -} - -// @public -interface JobOutboundMessageOnReady extends JobOutboundMessageBase { - // (undocumented) - readonly kind: JobOutboundMessageKind.OnReady; -} - -// @public -interface JobOutboundMessageOutput extends JobOutboundMessageBase { - // (undocumented) - readonly kind: JobOutboundMessageKind.Output; - readonly value: OutputT; -} - -// @public -interface JobOutboundMessagePong extends JobOutboundMessageBase { - readonly id: number; - // (undocumented) - readonly kind: JobOutboundMessageKind.Pong; -} - -// @public -interface JobOutboundMessageStart extends JobOutboundMessageBase { - // (undocumented) - readonly kind: JobOutboundMessageKind.Start; -} - -// @public (undocumented) -class JobOutputSchemaValidationError extends schema.SchemaValidationException { - constructor(errors?: schema.SchemaValidatorError[]); -} - -declare namespace jobs { - export { - isJobHandler, - JobName, - JobHandler, - JobHandlerContext, - JobDescription, - JobInboundMessageKind, - JobInboundMessageBase, - JobInboundMessagePing, - JobInboundMessageStop, - JobInboundMessageInput, - JobInboundMessage, - JobOutboundMessageKind, - JobOutboundMessageBase, - JobOutboundMessageOnReady, - JobOutboundMessageStart, - JobOutboundMessageOutput, - JobOutboundMessageChannelBase, - JobOutboundMessageChannelMessage, - JobOutboundMessageChannelError, - JobOutboundMessageChannelCreate, - JobOutboundMessageChannelComplete, - JobOutboundMessageEnd, - JobOutboundMessagePong, - JobOutboundMessage, - JobState, - Job, - ScheduleJobOptions, - Registry, - Scheduler, - createJobHandler, - createJobFactory, - createLoggerJob, - ChannelAlreadyExistException, - SimpleJobHandlerContext, - SimpleJobHandlerFn, - JobNameAlreadyRegisteredException, - JobDoesNotExistException, - createDispatcher, - JobDispatcher, - FallbackRegistry, - RegisterJobOptions, - SimpleJobRegistry, - JobArgumentSchemaValidationError, - JobInboundMessageSchemaValidationError, - JobOutputSchemaValidationError, - SimpleScheduler, - strategy - } -} - -// @public -enum JobState { - Ended = "ended", - Errored = "errored", - Queued = "queued", - Ready = "ready", - Started = "started" -} - // @public export function join(p1: Path, ...others: string[]): Path; @@ -1343,11 +1019,6 @@ function readWorkspace(path: string, host: WorkspaceHost, format?: WorkspaceForm workspace: WorkspaceDefinition; }>; -// @public (undocumented) -export type Readwrite = { - -readonly [P in keyof T]: T[P]; -}; - // @public (undocumented) interface ReferenceResolver { // (undocumented) @@ -1357,15 +1028,6 @@ interface ReferenceResolver { }; } -// @public -interface RegisterJobOptions extends Partial { -} - -// @public (undocumented) -interface Registry { - get(name: JobName): Observable | null>; -} - // @public export function relative(from: Path, to: Path): Path; @@ -1428,19 +1090,6 @@ class SafeReadonlyHost implements ReadonlyHost | null> | null; } -// @public -interface ScheduleJobOptions { - dependencies?: Job | Job[]; -} - -// @public -interface Scheduler { - getDescription(name: JobName): Observable; - has(name: JobName): Observable; - pause(): () => void; - schedule(name: JobName, argument: A, options?: ScheduleJobOptions): Job; -} - declare namespace schema { export { transforms, @@ -1567,30 +1216,6 @@ interface ScreenviewOptions extends CustomDimensionsAndMetricsOptions { appVersion?: string; } -// @public -interface SimpleJobHandlerContext extends JobHandlerContext { - // (undocumented) - createChannel: (name: string) => Observer; - // (undocumented) - input: Observable; -} - -// @public -type SimpleJobHandlerFn = (input: A, context: SimpleJobHandlerContext) => O | Promise | Observable; - -// @public -class SimpleJobRegistry implements Registry { - // (undocumented) - get(name: JobName): Observable | null>; - getJobNames(): JobName[]; - register(name: JobName, handler: JobHandler, options?: RegisterJobOptions): void; - register(handler: JobHandler, options?: RegisterJobOptions & { - name: string; - }): void; - // (undocumented) - protected _register(name: JobName, handler: JobHandler, options: RegisterJobOptions): void; -} - // @public (undocumented) class SimpleMemoryHost implements Host<{}> { constructor(); @@ -1675,21 +1300,6 @@ interface SimpleMemoryHostStats { readonly content: FileBuffer | null; } -// @public -class SimpleScheduler implements Scheduler { - constructor(_jobRegistry: Registry, _schemaRegistry?: schema.SchemaRegistry); - getDescription(name: JobName): Observable; - has(name: JobName): Observable; - // (undocumented) - protected _jobRegistry: Registry; - pause(): () => void; - schedule(name: JobName, argument: A, options?: ScheduleJobOptions): Job; - // (undocumented) - protected _scheduleJob(name: JobName, argument: A, options: ScheduleJobOptions, waitable: Observable): Job; - // (undocumented) - protected _schemaRegistry: schema.SchemaRegistry; -} - // @public (undocumented) interface SmartDefaultProvider { // (undocumented) @@ -1710,15 +1320,6 @@ type Stats = T & { readonly birthtime: Date; }; -// @public (undocumented) -namespace strategy { - // (undocumented) - type JobStrategy = (handler: JobHandler, options?: Partial>) => JobHandler; - function memoize(replayMessages?: boolean): JobStrategy; - function reuse(replayMessages?: boolean): JobStrategy; - function serialize(): JobStrategy; -} - declare namespace strings { export { decamelize, diff --git a/goldens/public-api/angular_devkit/core/node/index.md b/goldens/public-api/angular_devkit/core/node/index.md index 00edd946a8..59cda60a3a 100644 --- a/goldens/public-api/angular_devkit/core/node/index.md +++ b/goldens/public-api/angular_devkit/core/node/index.md @@ -6,28 +6,16 @@ /// -import { ErrorObject } from 'ajv'; -import { Format } from 'ajv'; import { Observable } from 'rxjs'; -import { Observer } from 'rxjs'; import { Operator } from 'rxjs'; import { PartialObserver } from 'rxjs'; import { Stats as Stats_2 } from 'fs'; import { Subject } from 'rxjs'; -import { SubscribableOrPromise } from 'rxjs'; import { Subscription } from 'rxjs'; -import { ValidateFunction } from 'ajv'; // @public export function createConsoleLogger(verbose?: boolean, stdout?: ProcessOutput, stderr?: ProcessOutput, colors?: Partial string>>): logging.Logger; -declare namespace experimental { - export { - NodeModuleJobRegistry - } -} -export { experimental } - // @public export class NodeJsAsyncHost implements virtualFs.Host { // (undocumented) @@ -80,13 +68,6 @@ export class NodeJsSyncHost implements virtualFs.Host { write(path: Path, content: virtualFs.FileBuffer): Observable; } -// @public (undocumented) -class NodeModuleJobRegistry implements experimental_2.jobs.Registry { - get(name: experimental_2.jobs.JobName): Observable | null>; - // (undocumented) - protected _resolve(name: string): string | null; -} - // @public (undocumented) export interface ProcessOutput { // (undocumented) diff --git a/packages/angular_devkit/architect/node/BUILD.bazel b/packages/angular_devkit/architect/node/BUILD.bazel index 91a53d8938..ab98536ca7 100644 --- a/packages/angular_devkit/architect/node/BUILD.bazel +++ b/packages/angular_devkit/architect/node/BUILD.bazel @@ -3,7 +3,9 @@ # 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 +load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test") load("//tools:defaults.bzl", "ts_library") +load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS") licenses(["notice"]) @@ -21,7 +23,35 @@ ts_library( "//packages/angular_devkit/architect", "//packages/angular_devkit/core", "//packages/angular_devkit/core/node", + "//tests/angular_devkit/architect/node/jobs:jobs_test_lib", "@npm//@types/node", "@npm//rxjs", ], ) + +ts_library( + name = "node_test_lib", + testonly = True, + srcs = glob( + include = [ + "**/*_spec.ts", + ], + ), + deps = [ + ":node", + "//packages/angular_devkit/architect", + ], +) + +[ + jasmine_node_test( + name = "node_test_" + toolchain_name, + srcs = [":node_test_lib"], + tags = [toolchain_name], + toolchain = toolchain, + ) + for toolchain_name, toolchain in zip( + TOOLCHAINS_NAMES, + TOOLCHAINS_VERSIONS, + ) +] diff --git a/packages/angular_devkit/architect/node/index.ts b/packages/angular_devkit/architect/node/index.ts index 8170933075..4c320e5753 100644 --- a/packages/angular_devkit/architect/node/index.ts +++ b/packages/angular_devkit/architect/node/index.ts @@ -6,4 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ +import * as jobs from './jobs/job-registry'; + export * from './node-modules-architect-host'; + +export { jobs }; diff --git a/packages/angular_devkit/core/node/experimental/jobs/job-registry.ts b/packages/angular_devkit/architect/node/jobs/job-registry.ts similarity index 85% rename from packages/angular_devkit/core/node/experimental/jobs/job-registry.ts rename to packages/angular_devkit/architect/node/jobs/job-registry.ts index 84a8cda51a..76b0e7b8f6 100644 --- a/packages/angular_devkit/core/node/experimental/jobs/job-registry.ts +++ b/packages/angular_devkit/architect/node/jobs/job-registry.ts @@ -6,15 +6,15 @@ * found in the LICENSE file at https://angular.io/license */ +import { jobs } from '@angular-devkit/architect'; +import { JsonValue, schema } from '@angular-devkit/core'; import { Observable, of } from 'rxjs'; -import { JsonValue, experimental as core_experimental, schema } from '../../../src'; export class NodeModuleJobRegistry< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue, -> implements - core_experimental.jobs.Registry +> implements jobs.Registry { protected _resolve(name: string): string | null { try { @@ -34,8 +34,8 @@ export class NodeModuleJobRegistry< * @returns A description, or null if the job is not registered. */ get( - name: core_experimental.jobs.JobName, - ): Observable | null> { + name: jobs.JobName, + ): Observable | null> { const [moduleName, exportName] = name.split(/#/, 2); const resolvedPath = this._resolve(moduleName); diff --git a/packages/angular_devkit/core/node/experimental/jobs/job-registry_spec.ts b/packages/angular_devkit/architect/node/jobs/job-registry_spec.ts similarity index 66% rename from packages/angular_devkit/core/node/experimental/jobs/job-registry_spec.ts rename to packages/angular_devkit/architect/node/jobs/job-registry_spec.ts index 087f38109b..38e3d07c25 100644 --- a/packages/angular_devkit/core/node/experimental/jobs/job-registry_spec.ts +++ b/packages/angular_devkit/architect/node/jobs/job-registry_spec.ts @@ -6,19 +6,16 @@ * found in the LICENSE file at https://angular.io/license */ +import { jobs } from '@angular-devkit/architect'; import * as path from 'path'; -import { experimental as core_experimental } from '../../../src'; import { NodeModuleJobRegistry } from './job-registry'; -const root = path.join( - path.dirname(require.resolve(__filename)), - '../../../../../../tests/angular_devkit/core/node/jobs', -); +const root = path.join(__dirname, '../../../../../tests/angular_devkit/architect/node/jobs'); describe('NodeModuleJobScheduler', () => { it('works', async () => { const registry = new NodeModuleJobRegistry(); - const scheduler = new core_experimental.jobs.SimpleScheduler(registry); + const scheduler = new jobs.SimpleScheduler(registry); const job = scheduler.schedule(path.join(root, 'add'), [1, 2, 3]); expect(await job.output.toPromise()).toBe(6); diff --git a/packages/angular_devkit/architect/src/api.ts b/packages/angular_devkit/architect/src/api.ts index 4156668924..ebe538a99d 100644 --- a/packages/angular_devkit/architect/src/api.ts +++ b/packages/angular_devkit/architect/src/api.ts @@ -6,10 +6,11 @@ * found in the LICENSE file at https://angular.io/license */ -import { analytics, experimental, json, logging } from '@angular-devkit/core'; +import { analytics, json, logging } from '@angular-devkit/core'; import { Observable, SubscribableOrPromise, Subscriber, from } from 'rxjs'; import { switchMap } from 'rxjs/operators'; import { Schema as RealBuilderInput, Target as RealTarget } from './input-schema'; +import { Registry } from './jobs'; import { Schema as RealBuilderOutput } from './output-schema'; import { State as BuilderProgressState, Schema as RealBuilderProgress } from './progress-schema'; @@ -17,11 +18,7 @@ export type Target = json.JsonObject & RealTarget; export { BuilderProgressState }; // Type short hands. -export type BuilderRegistry = experimental.jobs.Registry< - json.JsonObject, - BuilderInput, - BuilderOutput ->; +export type BuilderRegistry = Registry; /** * An API typed BuilderProgress. The interface generated from the schema is too permissive, diff --git a/packages/angular_devkit/architect/src/architect.ts b/packages/angular_devkit/architect/src/architect.ts index d852a3113c..d8ced621b0 100644 --- a/packages/angular_devkit/architect/src/architect.ts +++ b/packages/angular_devkit/architect/src/architect.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import { analytics, experimental, json, logging } from '@angular-devkit/core'; +import { analytics, json, logging } from '@angular-devkit/core'; import { Observable, from, merge, of, onErrorResumeNext } from 'rxjs'; import { concatMap, @@ -28,6 +28,20 @@ import { targetStringFromTarget, } from './api'; import { ArchitectHost, BuilderDescription, BuilderJobHandler } from './internal'; +import { + FallbackRegistry, + JobHandler, + JobHandlerContext, + JobInboundMessage, + JobInboundMessageKind, + JobName, + JobOutboundMessageKind, + Registry, + Scheduler, + SimpleJobRegistry, + SimpleScheduler, + createJobHandler, +} from './jobs'; import { scheduleByName, scheduleByTarget } from './schedule-by-name'; const inputSchema = require('./input-schema.json'); @@ -48,11 +62,11 @@ function _createJobHandlerFromBuilderInfo( info, }; - function handler(argument: json.JsonObject, context: experimental.jobs.JobHandlerContext) { + function handler(argument: json.JsonObject, context: JobHandlerContext) { // Add input validation to the inbound bus. const inboundBusWithInputValidation = context.inboundBus.pipe( concatMap((message) => { - if (message.kind === experimental.jobs.JobInboundMessageKind.Input) { + if (message.kind === JobInboundMessageKind.Input) { const v = message.value as BuilderInput; const options = { ...baseOptions, @@ -73,7 +87,7 @@ function _createJobHandlerFromBuilderInfo( map((value) => ({ ...message, value })), ); } else { - return of(message as experimental.jobs.JobInboundMessage); + return of(message as JobInboundMessage); } }), // Using a share replay because the job might be synchronously sending input, but @@ -93,7 +107,7 @@ function _createJobHandlerFromBuilderInfo( return builder.handler(argument, { ...context, inboundBus }).pipe( map((output) => { - if (output.kind === experimental.jobs.JobOutboundMessageKind.Output) { + if (output.kind === JobOutboundMessageKind.Output) { // Add target to it. return { ...output, @@ -198,7 +212,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry { get( name: string, - ): Observable | null> { + ): Observable | null> { const m = name.match(/^([^:]+):([^:]+)$/i); if (!m) { return of(null); @@ -207,7 +221,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry { return from(this._resolveBuilder(name)).pipe( concatMap((builderInfo) => (builderInfo ? this._createBuilder(builderInfo) : of(null))), first(null, null), - ) as Observable | null>; + ) as Observable | null>; } } @@ -217,7 +231,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry { class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry { override get( name: string, - ): Observable | null> { + ): Observable | null> { const m = name.match(/^{([^:]+):([^:]+)(?::([^:]*))?}$/i); if (!m) { return of(null); @@ -251,12 +265,12 @@ class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry { ); }), first(null, null), - ) as Observable | null>; + ) as Observable | null>; } } function _getTargetOptionsFactory(host: ArchitectHost) { - return experimental.jobs.createJobHandler( + return createJobHandler( (target) => { return host.getOptionsForTarget(target).then((options) => { if (options === null) { @@ -275,7 +289,7 @@ function _getTargetOptionsFactory(host: ArchitectHost) { } function _getProjectMetadataFactory(host: ArchitectHost) { - return experimental.jobs.createJobHandler( + return createJobHandler( (target) => { return host.getProjectMetadata(target).then((options) => { if (options === null) { @@ -296,7 +310,7 @@ function _getProjectMetadataFactory(host: ArchitectHost) { } function _getBuilderNameForTargetFactory(host: ArchitectHost) { - return experimental.jobs.createJobHandler( + return createJobHandler( async (target) => { const builderName = await host.getBuilderNameForTarget(target); if (!builderName) { @@ -314,7 +328,7 @@ function _getBuilderNameForTargetFactory(host: ArchitectHost) { } function _validateOptionsFactory(host: ArchitectHost, registry: json.schema.SchemaRegistry) { - return experimental.jobs.createJobHandler<[string, json.JsonObject], never, json.JsonObject>( + return createJobHandler<[string, json.JsonObject], never, json.JsonObject>( async ([builderName, options]) => { // Get option schema from the host. const builderInfo = await host.resolveBuilder(builderName); @@ -348,33 +362,33 @@ function _validateOptionsFactory(host: ArchitectHost, registry: json.schema.Sche } export class Architect { - private readonly _scheduler: experimental.jobs.Scheduler; + private readonly _scheduler: Scheduler; private readonly _jobCache = new Map>(); private readonly _infoCache = new Map>(); constructor( private _host: ArchitectHost, registry: json.schema.SchemaRegistry = new json.schema.CoreSchemaRegistry(), - additionalJobRegistry?: experimental.jobs.Registry, + additionalJobRegistry?: Registry, ) { - const privateArchitectJobRegistry = new experimental.jobs.SimpleJobRegistry(); + const privateArchitectJobRegistry = new SimpleJobRegistry(); // Create private jobs. privateArchitectJobRegistry.register(_getTargetOptionsFactory(_host)); privateArchitectJobRegistry.register(_getBuilderNameForTargetFactory(_host)); privateArchitectJobRegistry.register(_validateOptionsFactory(_host, registry)); privateArchitectJobRegistry.register(_getProjectMetadataFactory(_host)); - const jobRegistry = new experimental.jobs.FallbackRegistry([ + const jobRegistry = new FallbackRegistry([ new ArchitectTargetJobRegistry(_host, registry, this._jobCache, this._infoCache), new ArchitectBuilderJobRegistry(_host, registry, this._jobCache, this._infoCache), privateArchitectJobRegistry, ...(additionalJobRegistry ? [additionalJobRegistry] : []), - ] as experimental.jobs.Registry[]); + ] as Registry[]); - this._scheduler = new experimental.jobs.SimpleScheduler(jobRegistry, registry); + this._scheduler = new SimpleScheduler(jobRegistry, registry); } - has(name: experimental.jobs.JobName) { + has(name: JobName) { return this._scheduler.has(name); } diff --git a/packages/angular_devkit/architect/src/create-builder.ts b/packages/angular_devkit/architect/src/create-builder.ts index 6aa83bd36c..ad1ad50739 100644 --- a/packages/angular_devkit/architect/src/create-builder.ts +++ b/packages/angular_devkit/architect/src/create-builder.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import { analytics, experimental, json, logging } from '@angular-devkit/core'; +import { analytics, json, logging } from '@angular-devkit/core'; import { Observable, Subscription, from, isObservable, of, throwError } from 'rxjs'; import { mergeMap, tap } from 'rxjs/operators'; import { @@ -24,13 +24,14 @@ import { targetStringFromTarget, } from './api'; import { Builder, BuilderSymbol, BuilderVersionSymbol } from './internal'; +import { JobInboundMessageKind, createJobHandler } from './jobs'; import { scheduleByName, scheduleByTarget } from './schedule-by-name'; // eslint-disable-next-line max-lines-per-function export function createBuilder( fn: BuilderHandlerFn, ): Builder { - const cjh = experimental.jobs.createJobHandler; + const cjh = createJobHandler; // eslint-disable-next-line max-lines-per-function const handler = cjh((options, context) => { const scheduler = context.scheduler; @@ -73,7 +74,7 @@ export function createBuilder { switch (i.kind) { - case experimental.jobs.JobInboundMessageKind.Stop: + case JobInboundMessageKind.Stop: // Run teardown logic then complete. tearingDown = true; Promise.all(teardownLogics.map((fn) => fn() || Promise.resolve())).then( @@ -81,7 +82,7 @@ export function createBuilder observer.error(err), ); break; - case experimental.jobs.JobInboundMessageKind.Input: + case JobInboundMessageKind.Input: if (!tearingDown) { onInput(i.value); } diff --git a/packages/angular_devkit/architect/src/index.ts b/packages/angular_devkit/architect/src/index.ts index 210a7b794a..fa7faa55c2 100644 --- a/packages/angular_devkit/architect/src/index.ts +++ b/packages/angular_devkit/architect/src/index.ts @@ -6,6 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ +import * as jobs from './jobs'; + export * from './api'; export { Architect, ScheduleOptions } from './architect'; export { createBuilder } from './create-builder'; + +export { jobs }; diff --git a/packages/angular_devkit/architect/src/internal.ts b/packages/angular_devkit/architect/src/internal.ts index 0d4d972f15..72bf285fe5 100644 --- a/packages/angular_devkit/architect/src/internal.ts +++ b/packages/angular_devkit/architect/src/internal.ts @@ -6,8 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import { experimental, json } from '@angular-devkit/core'; +import { json } from '@angular-devkit/core'; import { BuilderInfo, BuilderInput, BuilderOutput, Target } from './api'; +import { JobDescription, JobHandler } from './jobs'; // Internal types that should not be exported directly. These are used by the host and architect // itself. Host implementations should import the host.ts file. @@ -35,14 +36,14 @@ export const BuilderVersionSymbol = Symbol.for('@angular-devkit/architect:versio export type BuilderJobHandler< A extends json.JsonObject = json.JsonObject, I extends BuilderInput = BuilderInput, - O extends BuilderOutput = BuilderOutput -> = experimental.jobs.JobHandler & { jobDescription: BuilderDescription }; + O extends BuilderOutput = BuilderOutput, +> = JobHandler & { jobDescription: BuilderDescription }; /** * A Builder description, which is used internally. Adds the builder info which is the * metadata attached to a builder in Architect. */ -export interface BuilderDescription extends experimental.jobs.JobDescription { +export interface BuilderDescription extends JobDescription { info: BuilderInfo; } @@ -51,7 +52,7 @@ export interface BuilderDescription extends experimental.jobs.JobDescription { */ export interface Builder { // A fully compatible job handler. - handler: experimental.jobs.JobHandler; + handler: JobHandler; // Metadata associated with this builder. [BuilderSymbol]: true; diff --git a/packages/angular_devkit/core/src/experimental/jobs/README.md b/packages/angular_devkit/architect/src/jobs/README.md similarity index 99% rename from packages/angular_devkit/core/src/experimental/jobs/README.md rename to packages/angular_devkit/architect/src/jobs/README.md index ebb0f90a05..8620e877dc 100644 --- a/packages/angular_devkit/core/src/experimental/jobs/README.md +++ b/packages/angular_devkit/architect/src/jobs/README.md @@ -205,9 +205,7 @@ declare const scheduler: jobs.Scheduler; const job = scheduler.schedule('count', 0); job.getChannel('side').subscribe((x) => console.log(x)); // You can type a channel too. Messages will be filtered out. -job - .getChannel('progress', { type: 'number' }) - .subscribe((x) => console.log(x)); +job.getChannel('progress', { type: 'number' }).subscribe((x) => console.log(x)); ``` ## Communicating With Jobs diff --git a/packages/angular_devkit/core/src/experimental/jobs/api.ts b/packages/angular_devkit/architect/src/jobs/api.ts similarity index 97% rename from packages/angular_devkit/core/src/experimental/jobs/api.ts rename to packages/angular_devkit/architect/src/jobs/api.ts index d46c34c4ed..c7696b0076 100644 --- a/packages/angular_devkit/core/src/experimental/jobs/api.ts +++ b/packages/angular_devkit/architect/src/jobs/api.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ +import { JsonObject, JsonValue, schema } from '@angular-devkit/core'; import { Observable, Observer } from 'rxjs'; -import { JsonObject, JsonValue, schema } from '../../json/index'; -import { DeepReadonly } from '../../utils/index'; +import { DeepReadonly } from './types'; /** * A job name is just a string (needs to be serializable). @@ -21,7 +21,7 @@ export type JobName = string; export interface JobHandler< ArgT extends JsonValue, InputT extends JsonValue, - OutputT extends JsonValue + OutputT extends JsonValue, > { (argument: ArgT, context: JobHandlerContext): Observable< JobOutboundMessage @@ -36,7 +36,7 @@ export interface JobHandler< export interface JobHandlerContext< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, - MinimumOutputValueT extends JsonValue = JsonValue + MinimumOutputValueT extends JsonValue = JsonValue, > { readonly description: JobDescription; readonly scheduler: Scheduler; @@ -300,7 +300,7 @@ export enum JobState { export interface Job< ArgumentT extends JsonValue = JsonValue, InputT extends JsonValue = JsonValue, - OutputT extends JsonValue = JsonValue + OutputT extends JsonValue = JsonValue, > { /** * Description of the job. Resolving the job's description can be done asynchronously, so this @@ -371,7 +371,7 @@ export interface ScheduleJobOptions { export interface Registry< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, - MinimumOutputValueT extends JsonValue = JsonValue + MinimumOutputValueT extends JsonValue = JsonValue, > { /** * Get a job handler. @@ -388,7 +388,7 @@ export interface Registry< export interface Scheduler< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, - MinimumOutputValueT extends JsonValue = JsonValue + MinimumOutputValueT extends JsonValue = JsonValue, > { /** * Get a job description for a named job. @@ -429,7 +429,7 @@ export interface Scheduler< schedule< A extends MinimumArgumentValueT, I extends MinimumInputValueT, - O extends MinimumOutputValueT + O extends MinimumOutputValueT, >( name: JobName, argument: A, diff --git a/packages/angular_devkit/core/src/experimental/jobs/architecture.md b/packages/angular_devkit/architect/src/jobs/architecture.md similarity index 100% rename from packages/angular_devkit/core/src/experimental/jobs/architecture.md rename to packages/angular_devkit/architect/src/jobs/architecture.md diff --git a/packages/angular_devkit/core/src/experimental/jobs/create-job-handler.ts b/packages/angular_devkit/architect/src/jobs/create-job-handler.ts similarity index 96% rename from packages/angular_devkit/core/src/experimental/jobs/create-job-handler.ts rename to packages/angular_devkit/architect/src/jobs/create-job-handler.ts index 98fd40323b..ba5684741c 100644 --- a/packages/angular_devkit/core/src/experimental/jobs/create-job-handler.ts +++ b/packages/angular_devkit/architect/src/jobs/create-job-handler.ts @@ -6,12 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ +import { BaseException, JsonValue, isPromise, logging } from '@angular-devkit/core'; import { Observable, Observer, Subject, Subscription, from, isObservable, of } from 'rxjs'; import { switchMap, tap } from 'rxjs/operators'; -import { BaseException } from '../../exception'; -import { JsonValue } from '../../json/index'; -import { LoggerApi } from '../../logger'; -import { isPromise } from '../../utils/index'; import { JobDescription, JobHandler, @@ -182,7 +179,7 @@ export function createJobFactory( job: JobHandler, - logger: LoggerApi, + logger: logging.LoggerApi, ): JobHandler { const handler = (argument: A, context: JobHandlerContext) => { context.inboundBus diff --git a/packages/angular_devkit/core/src/experimental/jobs/dispatcher.ts b/packages/angular_devkit/architect/src/jobs/dispatcher.ts similarity index 93% rename from packages/angular_devkit/core/src/experimental/jobs/dispatcher.ts rename to packages/angular_devkit/architect/src/jobs/dispatcher.ts index ff43cd35fa..00ffecc310 100644 --- a/packages/angular_devkit/core/src/experimental/jobs/dispatcher.ts +++ b/packages/angular_devkit/architect/src/jobs/dispatcher.ts @@ -6,10 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import { JsonValue } from '../../json/index'; -import { Readwrite } from '../../utils/index'; +import { JsonValue } from '@angular-devkit/core'; import { Job, JobDescription, JobHandler, JobHandlerContext, JobName, isJobHandler } from './api'; import { JobDoesNotExistException } from './exception'; +import { Readwrite } from './types'; /** * A JobDispatcher can be used to dispatch between multiple jobs. @@ -62,7 +62,7 @@ export function createDispatcher) { if (isJobHandler(name)) { name = name.jobDescription.name === undefined ? null : name.jobDescription.name; @@ -74,5 +74,5 @@ export function createDispatcher; + }) as unknown as JobDispatcher; } diff --git a/packages/angular_devkit/core/src/experimental/jobs/dispatcher_spec.ts b/packages/angular_devkit/architect/src/jobs/dispatcher_spec.ts similarity index 96% rename from packages/angular_devkit/core/src/experimental/jobs/dispatcher_spec.ts rename to packages/angular_devkit/architect/src/jobs/dispatcher_spec.ts index 86f121c791..641c8d835c 100644 --- a/packages/angular_devkit/core/src/experimental/jobs/dispatcher_spec.ts +++ b/packages/angular_devkit/architect/src/jobs/dispatcher_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import { JsonValue } from '../../json'; +import { JsonValue } from '@angular-devkit/core'; import { JobHandler } from './api'; import { createJobHandler } from './create-job-handler'; import { createDispatcher } from './dispatcher'; diff --git a/packages/angular_devkit/core/src/experimental/jobs/exception.ts b/packages/angular_devkit/architect/src/jobs/exception.ts similarity index 91% rename from packages/angular_devkit/core/src/experimental/jobs/exception.ts rename to packages/angular_devkit/architect/src/jobs/exception.ts index 266cc512ce..67ce61a104 100644 --- a/packages/angular_devkit/core/src/experimental/jobs/exception.ts +++ b/packages/angular_devkit/architect/src/jobs/exception.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import { BaseException } from '../../exception'; +import { BaseException } from '@angular-devkit/core'; import { JobName } from './api'; export class JobNameAlreadyRegisteredException extends BaseException { diff --git a/packages/angular_devkit/core/src/experimental/jobs/fallback-registry.ts b/packages/angular_devkit/architect/src/jobs/fallback-registry.ts similarity index 86% rename from packages/angular_devkit/core/src/experimental/jobs/fallback-registry.ts rename to packages/angular_devkit/architect/src/jobs/fallback-registry.ts index 899912275e..ce6d980a0b 100644 --- a/packages/angular_devkit/core/src/experimental/jobs/fallback-registry.ts +++ b/packages/angular_devkit/architect/src/jobs/fallback-registry.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ +import { JsonValue } from '@angular-devkit/core'; import { Observable, from } from 'rxjs'; import { concatMap, first } from 'rxjs/operators'; -import { JsonValue } from '../../json'; import { JobHandler, JobName, Registry } from './api'; /** @@ -17,8 +17,9 @@ import { JobHandler, JobName, Registry } from './api'; export class FallbackRegistry< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, - MinimumOutputValueT extends JsonValue = JsonValue -> implements Registry { + MinimumOutputValueT extends JsonValue = JsonValue, +> implements Registry +{ constructor( protected _fallbacks: Registry< MinimumArgumentValueT, @@ -34,7 +35,7 @@ export class FallbackRegistry< get< A extends MinimumArgumentValueT = MinimumArgumentValueT, I extends MinimumInputValueT = MinimumInputValueT, - O extends MinimumOutputValueT = MinimumOutputValueT + O extends MinimumOutputValueT = MinimumOutputValueT, >(name: JobName): Observable | null> { return from(this._fallbacks).pipe( concatMap((fb) => fb.get(name)), diff --git a/packages/angular_devkit/core/src/experimental/jobs/index.ts b/packages/angular_devkit/architect/src/jobs/index.ts similarity index 100% rename from packages/angular_devkit/core/src/experimental/jobs/index.ts rename to packages/angular_devkit/architect/src/jobs/index.ts diff --git a/packages/angular_devkit/core/src/experimental/jobs/simple-registry.ts b/packages/angular_devkit/architect/src/jobs/simple-registry.ts similarity index 89% rename from packages/angular_devkit/core/src/experimental/jobs/simple-registry.ts rename to packages/angular_devkit/architect/src/jobs/simple-registry.ts index b2f89a65c8..e77c4331a6 100644 --- a/packages/angular_devkit/core/src/experimental/jobs/simple-registry.ts +++ b/packages/angular_devkit/architect/src/jobs/simple-registry.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ +import { JsonValue, schema } from '@angular-devkit/core'; import { Observable, of } from 'rxjs'; -import { JsonValue, schema } from '../../json'; import { JobDescription, JobHandler, JobName, Registry, isJobHandler } from './api'; import { JobNameAlreadyRegisteredException } from './exception'; @@ -23,8 +23,9 @@ export interface RegisterJobOptions extends Partial {} export class SimpleJobRegistry< MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, - MinimumOutputValueT extends JsonValue = JsonValue -> implements Registry { + MinimumOutputValueT extends JsonValue = JsonValue, +> implements Registry +{ private _jobNames = new Map< JobName, JobHandler @@ -33,9 +34,9 @@ export class SimpleJobRegistry< get< A extends MinimumArgumentValueT = MinimumArgumentValueT, I extends MinimumInputValueT = MinimumInputValueT, - O extends MinimumOutputValueT = MinimumOutputValueT + O extends MinimumOutputValueT = MinimumOutputValueT, >(name: JobName): Observable | null> { - return of(((this._jobNames.get(name) as unknown) as JobHandler | null) || null); + return of((this._jobNames.get(name) as unknown as JobHandler | null) || null); } /** @@ -48,7 +49,7 @@ export class SimpleJobRegistry< register< A extends MinimumArgumentValueT, I extends MinimumInputValueT, - O extends MinimumOutputValueT + O extends MinimumOutputValueT, >(name: JobName, handler: JobHandler, options?: RegisterJobOptions): void; /** @@ -96,7 +97,7 @@ export class SimpleJobRegistry< protected _register< ArgumentT extends JsonValue, InputT extends JsonValue, - OutputT extends JsonValue + OutputT extends JsonValue, >( name: JobName, handler: JobHandler, @@ -120,9 +121,9 @@ export class SimpleJobRegistry< input, }; - const jobHandler = (Object.assign(handler.bind(undefined), { + const jobHandler = Object.assign(handler.bind(undefined), { jobDescription, - }) as unknown) as JobHandler; + }) as unknown as JobHandler; this._jobNames.set(name, jobHandler); } diff --git a/packages/angular_devkit/core/src/experimental/jobs/simple-registry_spec.ts b/packages/angular_devkit/architect/src/jobs/simple-registry_spec.ts similarity index 100% rename from packages/angular_devkit/core/src/experimental/jobs/simple-registry_spec.ts rename to packages/angular_devkit/architect/src/jobs/simple-registry_spec.ts diff --git a/packages/angular_devkit/core/src/experimental/jobs/simple-scheduler.ts b/packages/angular_devkit/architect/src/jobs/simple-scheduler.ts similarity index 98% rename from packages/angular_devkit/core/src/experimental/jobs/simple-scheduler.ts rename to packages/angular_devkit/architect/src/jobs/simple-scheduler.ts index 2c3e673d4d..b2c4058e38 100644 --- a/packages/angular_devkit/core/src/experimental/jobs/simple-scheduler.ts +++ b/packages/angular_devkit/architect/src/jobs/simple-scheduler.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +import { JsonValue, schema } from '@angular-devkit/core'; import { EMPTY, MonoTypeOperatorFunction, @@ -28,7 +29,6 @@ import { switchMap, tap, } from 'rxjs/operators'; -import { JsonValue, schema } from '../../json'; import { Job, JobDescription, @@ -121,8 +121,9 @@ function _jobShare(): MonoTypeOperatorFunction { export class SimpleScheduler< MinimumArgumentT extends JsonValue = JsonValue, MinimumInputT extends JsonValue = JsonValue, - MinimumOutputT extends JsonValue = JsonValue -> implements Scheduler { + MinimumOutputT extends JsonValue = JsonValue, +> implements Scheduler +{ private _internalJobDescriptionMap = new Map(); private _queue: (() => void)[] = []; private _pauseCounter = 0; @@ -447,7 +448,7 @@ export class SimpleScheduler< let maybeObservable = channels.get(name); if (!maybeObservable) { const s = new Subject(); - channelsSubject.set(name, (s as unknown) as Subject); + channelsSubject.set(name, s as unknown as Subject); channels.set(name, s.asObservable()); maybeObservable = s.asObservable(); @@ -486,7 +487,7 @@ export class SimpleScheduler< protected _scheduleJob< A extends MinimumArgumentT, I extends MinimumInputT, - O extends MinimumOutputT + O extends MinimumOutputT, >( name: JobName, argument: A, diff --git a/packages/angular_devkit/core/src/experimental/jobs/simple-scheduler_spec.ts b/packages/angular_devkit/architect/src/jobs/simple-scheduler_spec.ts similarity index 100% rename from packages/angular_devkit/core/src/experimental/jobs/simple-scheduler_spec.ts rename to packages/angular_devkit/architect/src/jobs/simple-scheduler_spec.ts diff --git a/packages/angular_devkit/core/src/experimental/jobs/strategy.ts b/packages/angular_devkit/architect/src/jobs/strategy.ts similarity index 98% rename from packages/angular_devkit/core/src/experimental/jobs/strategy.ts rename to packages/angular_devkit/architect/src/jobs/strategy.ts index 92f8c6995f..cbd9ad1353 100644 --- a/packages/angular_devkit/core/src/experimental/jobs/strategy.ts +++ b/packages/angular_devkit/architect/src/jobs/strategy.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ +import { JsonObject, JsonValue, isJsonObject } from '@angular-devkit/core'; import { Observable, Subject, concat, of } from 'rxjs'; import { finalize, ignoreElements, share, shareReplay, tap } from 'rxjs/operators'; -import { JsonObject, JsonValue, isJsonObject } from '../../json'; import { JobDescription, JobHandler, diff --git a/packages/angular_devkit/core/src/experimental/jobs/strategy_spec.ts b/packages/angular_devkit/architect/src/jobs/strategy_spec.ts similarity index 100% rename from packages/angular_devkit/core/src/experimental/jobs/strategy_spec.ts rename to packages/angular_devkit/architect/src/jobs/strategy_spec.ts diff --git a/packages/angular_devkit/architect/src/jobs/types.ts b/packages/angular_devkit/architect/src/jobs/types.ts new file mode 100644 index 0000000000..457d79c06e --- /dev/null +++ b/packages/angular_devkit/architect/src/jobs/types.ts @@ -0,0 +1,26 @@ +/** + * @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 + */ + +export type DeepReadonly = T extends (infer R)[] + ? DeepReadonlyArray + : T extends Function + ? T + : T extends object + ? DeepReadonlyObject + : T; + +// This should be ReadonlyArray but it has implications. +export type DeepReadonlyArray = Array>; + +export type DeepReadonlyObject = { + readonly [P in keyof T]: DeepReadonly; +}; + +export type Readwrite = { + -readonly [P in keyof T]: T[P]; +}; diff --git a/packages/angular_devkit/architect/src/schedule-by-name.ts b/packages/angular_devkit/architect/src/schedule-by-name.ts index f583a77215..8e86aa8360 100644 --- a/packages/angular_devkit/architect/src/schedule-by-name.ts +++ b/packages/angular_devkit/architect/src/schedule-by-name.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import { analytics, experimental, json, logging } from '@angular-devkit/core'; +import { analytics, json, logging } from '@angular-devkit/core'; import { EMPTY, Subscription } from 'rxjs'; import { catchError, first, ignoreElements, map, shareReplay } from 'rxjs/operators'; import { @@ -18,6 +18,7 @@ import { Target, targetStringFromTarget, } from './api'; +import { JobOutboundMessageKind, JobState, Scheduler } from './jobs'; const progressSchema = require('./progress-schema.json'); @@ -28,7 +29,7 @@ export async function scheduleByName( buildOptions: json.JsonObject, options: { target?: Target; - scheduler: experimental.jobs.Scheduler; + scheduler: Scheduler; logger: logging.LoggerApi; workspaceRoot: string | Promise; currentDirectory: string | Promise; @@ -57,10 +58,10 @@ export async function scheduleByName( }; // Wait for the job to be ready. - if (job.state !== experimental.jobs.JobState.Started) { + if (job.state !== JobState.Started) { stateSubscription = job.outboundBus.subscribe( (event) => { - if (event.kind === experimental.jobs.JobOutboundMessageKind.Start) { + if (event.kind === JobOutboundMessageKind.Start) { job.input.next(message); } }, @@ -139,7 +140,7 @@ export async function scheduleByTarget( target: Target, overrides: json.JsonObject, options: { - scheduler: experimental.jobs.Scheduler; + scheduler: Scheduler; logger: logging.LoggerApi; workspaceRoot: string | Promise; currentDirectory: string | Promise; diff --git a/packages/angular_devkit/core/BUILD.bazel b/packages/angular_devkit/core/BUILD.bazel index b791f6d058..8592428c20 100644 --- a/packages/angular_devkit/core/BUILD.bazel +++ b/packages/angular_devkit/core/BUILD.bazel @@ -87,8 +87,6 @@ pkg_npm( ":README.md", ":core", ":license", - ":src/experimental/jobs/README.md", - ":src/experimental/jobs/architecture.md", "//packages/angular_devkit/core/node", "//packages/angular_devkit/core/node:package.json", "//packages/angular_devkit/core/node/testing", diff --git a/packages/angular_devkit/core/node/BUILD.bazel b/packages/angular_devkit/core/node/BUILD.bazel index 9d89f0f7e2..68bd7f28d2 100644 --- a/packages/angular_devkit/core/node/BUILD.bazel +++ b/packages/angular_devkit/core/node/BUILD.bazel @@ -48,7 +48,6 @@ ts_library( deps = [ ":node", "//packages/angular_devkit/core", - "//tests/angular_devkit/core/node/jobs:jobs_test_lib", "@npm//rxjs", ], ) diff --git a/packages/angular_devkit/core/node/experimental/index.ts b/packages/angular_devkit/core/node/experimental/index.ts deleted file mode 100644 index 5e70f7eeba..0000000000 --- a/packages/angular_devkit/core/node/experimental/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @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 * as jobs from './jobs'; - -export { jobs }; diff --git a/packages/angular_devkit/core/node/experimental/jobs/index.ts b/packages/angular_devkit/core/node/experimental/jobs/index.ts deleted file mode 100644 index 1038877cd0..0000000000 --- a/packages/angular_devkit/core/node/experimental/jobs/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @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 - */ - -export * from './job-registry'; diff --git a/packages/angular_devkit/core/node/index.ts b/packages/angular_devkit/core/node/index.ts index b80139dc67..faedea608b 100644 --- a/packages/angular_devkit/core/node/index.ts +++ b/packages/angular_devkit/core/node/index.ts @@ -6,9 +6,5 @@ * found in the LICENSE file at https://angular.io/license */ -import * as experimental from './experimental/jobs/job-registry'; - export * from './cli-logger'; export * from './host'; - -export { experimental }; diff --git a/packages/angular_devkit/core/src/experimental.ts b/packages/angular_devkit/core/src/experimental.ts deleted file mode 100644 index 628c78be71..0000000000 --- a/packages/angular_devkit/core/src/experimental.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @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 * as jobs from './experimental/jobs/index'; - -export { jobs }; diff --git a/packages/angular_devkit/core/src/index.ts b/packages/angular_devkit/core/src/index.ts index 1e5747ead3..d06b06019d 100644 --- a/packages/angular_devkit/core/src/index.ts +++ b/packages/angular_devkit/core/src/index.ts @@ -7,7 +7,6 @@ */ import * as analytics from './analytics'; -import * as experimental from './experimental'; import * as json from './json/index'; import * as logging from './logger/index'; import * as workspaces from './workspace'; @@ -17,4 +16,4 @@ export * from './json/index'; export * from './utils/index'; export * from './virtual-fs/index'; -export { analytics, experimental, json, logging, workspaces }; +export { analytics, json, logging, workspaces }; diff --git a/packages/angular_devkit/core/src/utils/index.ts b/packages/angular_devkit/core/src/utils/index.ts index 72da748049..f5873285e4 100644 --- a/packages/angular_devkit/core/src/utils/index.ts +++ b/packages/angular_devkit/core/src/utils/index.ts @@ -16,23 +16,3 @@ export * from './priority-queue'; export * from './lang'; export { tags, strings }; - -export type DeepReadonly = T extends (infer R)[] - ? DeepReadonlyArray - : T extends Function - ? T - : T extends object - ? DeepReadonlyObject - : T; - -// This should be ReadonlyArray but it has implications. -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface DeepReadonlyArray extends Array> {} - -export type DeepReadonlyObject = { - readonly [P in keyof T]: DeepReadonly; -}; - -export type Readwrite = { - -readonly [P in keyof T]: T[P]; -}; diff --git a/tests/angular_devkit/core/node/jobs/BUILD.bazel b/tests/angular_devkit/architect/node/jobs/BUILD.bazel similarity index 90% rename from tests/angular_devkit/core/node/jobs/BUILD.bazel rename to tests/angular_devkit/architect/node/jobs/BUILD.bazel index 5af4057d3d..a1cc494784 100644 --- a/tests/angular_devkit/core/node/jobs/BUILD.bazel +++ b/tests/angular_devkit/architect/node/jobs/BUILD.bazel @@ -16,7 +16,7 @@ ts_library( ], ), deps = [ - "//packages/angular_devkit/core", + "//packages/angular_devkit/architect", "@npm//@types/node", ], ) diff --git a/tests/angular_devkit/architect/node/jobs/add.ts b/tests/angular_devkit/architect/node/jobs/add.ts new file mode 100644 index 0000000000..d5d9f27cfb --- /dev/null +++ b/tests/angular_devkit/architect/node/jobs/add.ts @@ -0,0 +1,20 @@ +/** + * @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 { jobs } from '@angular-devkit/architect'; + +// Export the job using a createJob. We use our own spec file here to do the job. +export default jobs.createJobHandler( + (input) => { + return input.reduce((a, c) => a + c, 0); + }, + { + input: { items: { type: 'number' } }, + output: { type: 'number' }, + }, +); diff --git a/tests/angular_devkit/core/node/jobs/add.ts b/tests/angular_devkit/core/node/jobs/add.ts deleted file mode 100644 index 1529ab48ba..0000000000 --- a/tests/angular_devkit/core/node/jobs/add.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @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 - */ - -// tslint:disable:no-global-tslint-disable -// tslint:disable:no-implicit-dependencies -import { experimental } from '@angular-devkit/core'; - -// Export the job using a createJob. We use our own spec file here to do the job. -export default experimental.jobs.createJobHandler(input => { - return input.reduce((a, c) => a + c, 0); -}, { - input: { items: { type: 'number' } }, - output: { type: 'number' }, -});