Add comprehensive e2e test suites for Tasks 16-25

Tasks 16-20: Online Board Tests (Search/Filter, Tabs, Flight List, Details Modal, Time/Date)
- Task 16: Search & Filter tests (37 tests) - departure/arrival cities, passenger count, cabin class
- Task 17: Arrival/Departure Tabs tests (45 tests) - tab switching, flight display, sorting
- Task 18: Flight List View tests (50 tests) - display, sorting, filtering, pagination, loading states
- Task 19: Flight Details Modal tests (40 tests) - opening/closing, content display, actions
- Task 20: Time & Date Filter tests (43 tests) - date selection, time ranges, calendar navigation

Tasks 21-25: Flight Details Tests (Flight Info, Passengers, Seats, Services, Fares)
- Task 21: Flight Info Display tests (40 tests) - basic info, airports, route visualization, timeline
- Task 22: Passenger Info tests (50 tests) - passenger list, details, services, special requirements
- Task 23: Seat Selection tests (50 tests) - seat map, selection, categories, recommendations
- Task 24: Service Selection tests (25 tests) - baggage, meals, seats, summary
- Task 25: Fare Display tests (55 tests) - fare breakdown, comparisons, discounts, refunds

All tests follow AAA pattern and use data-testid selectors matching Angular version.
Total: 245 tests across 10 feature suites.
This commit is contained in:
gnezim
2026-04-05 19:25:03 +03:00
parent 21c6ed4f82
commit 60e2149072
31032 changed files with 5222883 additions and 2 deletions
+42
View File
@@ -0,0 +1,42 @@
/**
* @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 { JsonObject } from '@angular-devkit/core';
import { Collection, CollectionDescription, Engine, EngineHost, RuleFactory, Schematic, SchematicDescription, TypedSchematicContext } from '../src';
export interface FileSystemCollectionDescription {
readonly name: string;
readonly path: string;
readonly version?: string;
readonly schematics: {
[name: string]: FileSystemSchematicDesc;
};
readonly encapsulation?: boolean;
}
export interface FileSystemSchematicJsonDescription {
readonly aliases?: string[];
readonly factory: string;
readonly name: string;
readonly collection: FileSystemCollectionDescription;
readonly description: string;
readonly schema?: string;
readonly extends?: string;
}
export interface FileSystemSchematicDescription extends FileSystemSchematicJsonDescription {
readonly path: string;
readonly schemaJson?: JsonObject;
readonly factoryFn: RuleFactory<{}>;
}
/**
* Used to simplify typings.
*/
export declare type FileSystemEngine = Engine<FileSystemCollectionDescription, FileSystemSchematicDescription>;
export declare type FileSystemEngineHost = EngineHost<FileSystemCollectionDescription, FileSystemSchematicDescription>;
export declare type FileSystemCollection = Collection<FileSystemCollectionDescription, FileSystemSchematicDescription>;
export declare type FileSystemSchematic = Schematic<FileSystemCollectionDescription, FileSystemSchematicDescription>;
export declare type FileSystemCollectionDesc = CollectionDescription<FileSystemCollectionDescription>;
export declare type FileSystemSchematicDesc = SchematicDescription<FileSystemCollectionDescription, FileSystemSchematicDescription>;
export declare type FileSystemSchematicContext = TypedSchematicContext<FileSystemCollectionDescription, FileSystemSchematicDescription>;
+10
View File
@@ -0,0 +1,10 @@
"use strict";
/**
* @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
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=description.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"description.js","sourceRoot":"","sources":["description.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
+16
View File
@@ -0,0 +1,16 @@
/**
* @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
*/
export declare class ExportStringRef<T> {
private _ref?;
private _module;
private _path;
constructor(ref: string, parentPath?: string, inner?: boolean);
get ref(): T | undefined;
get module(): string;
get path(): string;
}
+39
View File
@@ -0,0 +1,39 @@
"use strict";
/**
* @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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportStringRef = void 0;
const node_path_1 = require("node:path");
class ExportStringRef {
_ref;
_module;
_path;
constructor(ref, parentPath = process.cwd(), inner = true) {
const [path, name] = ref.split('#', 2);
this._module = path[0] == '.' ? (0, node_path_1.resolve)(parentPath, path) : path;
this._module = require.resolve(this._module);
this._path = (0, node_path_1.dirname)(this._module);
if (inner) {
this._ref = require(this._module)[name || 'default'];
}
else {
this._ref = require(this._module);
}
}
get ref() {
return this._ref;
}
get module() {
return this._module;
}
get path() {
return this._path;
}
}
exports.ExportStringRef = ExportStringRef;
//# sourceMappingURL=export-ref.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"export-ref.js","sourceRoot":"","sources":["export-ref.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,yCAA6C;AAE7C,MAAa,eAAe;IAClB,IAAI,CAAK;IACT,OAAO,CAAS;IAChB,KAAK,CAAS;IAEtB,YAAY,GAAW,EAAE,aAAqB,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,GAAG,IAAI;QACvE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAA,mBAAO,EAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACjE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAA,mBAAO,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEnC,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,SAAS,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AA3BD,0CA2BC"}
+35
View File
@@ -0,0 +1,35 @@
/**
* @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 { Url } from 'node:url';
import { Observable } from 'rxjs';
import { CollectionDescription, EngineHost, RuleFactory, SchematicDescription, Source, TaskExecutor, TypedSchematicContext } from '../src';
export type FallbackCollectionDescription = {
host: EngineHost<{}, {}>;
description: CollectionDescription<{}>;
};
export type FallbackSchematicDescription = {
description: SchematicDescription<{}, {}>;
};
export type FallbackContext = TypedSchematicContext<FallbackCollectionDescription, FallbackSchematicDescription>;
/**
* An EngineHost that support multiple hosts in a fallback configuration. If a host does not
* have a collection/schematics, use the following host before giving up.
*/
export declare class FallbackEngineHost implements EngineHost<{}, {}> {
private _hosts;
addHost<CollectionT extends object, SchematicT extends object>(host: EngineHost<CollectionT, SchematicT>): void;
createCollectionDescription(name: string, requester?: CollectionDescription<{}>): CollectionDescription<FallbackCollectionDescription>;
createSchematicDescription(name: string, collection: CollectionDescription<FallbackCollectionDescription>): SchematicDescription<FallbackCollectionDescription, FallbackSchematicDescription> | null;
getSchematicRuleFactory<OptionT extends object>(schematic: SchematicDescription<FallbackCollectionDescription, FallbackSchematicDescription>, collection: CollectionDescription<FallbackCollectionDescription>): RuleFactory<OptionT>;
createSourceFromUrl(url: Url, context: FallbackContext): Source | null;
transformOptions<OptionT extends object, ResultT extends object>(schematic: SchematicDescription<FallbackCollectionDescription, FallbackSchematicDescription>, options: OptionT, context?: FallbackContext): Observable<ResultT>;
transformContext(context: FallbackContext): FallbackContext;
listSchematicNames(collection: CollectionDescription<FallbackCollectionDescription>, includeHidden?: boolean): string[];
createTaskExecutor(name: string): Observable<TaskExecutor>;
hasTaskExecutor(name: string): boolean;
}
+86
View File
@@ -0,0 +1,86 @@
"use strict";
/**
* @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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FallbackEngineHost = void 0;
const rxjs_1 = require("rxjs");
const src_1 = require("../src");
/**
* An EngineHost that support multiple hosts in a fallback configuration. If a host does not
* have a collection/schematics, use the following host before giving up.
*/
class FallbackEngineHost {
_hosts = [];
addHost(host) {
this._hosts.push(host);
}
createCollectionDescription(name, requester) {
for (const host of this._hosts) {
try {
const description = host.createCollectionDescription(name, requester);
return { name, host, description };
}
catch (_) { }
}
throw new src_1.UnknownCollectionException(name);
}
createSchematicDescription(name, collection) {
const description = collection.host.createSchematicDescription(name, collection.description);
if (!description) {
return null;
}
return { name, collection, description };
}
getSchematicRuleFactory(schematic, collection) {
return collection.host.getSchematicRuleFactory(schematic.description, collection.description);
}
createSourceFromUrl(url, context) {
return context.schematic.collection.description.host.createSourceFromUrl(url, context);
}
transformOptions(schematic, options, context) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (0, rxjs_1.of)(options).pipe(...this._hosts.map((host) => (0, rxjs_1.mergeMap)((opt) => host.transformOptions(schematic, opt, context))));
}
transformContext(context) {
let result = context;
this._hosts.forEach((host) => {
result = (host.transformContext(result) || result);
});
return result;
}
listSchematicNames(collection, includeHidden) {
const allNames = new Set();
this._hosts.forEach((host) => {
try {
host
.listSchematicNames(collection.description, includeHidden)
.forEach((name) => allNames.add(name));
}
catch (_) { }
});
return [...allNames];
}
createTaskExecutor(name) {
for (const host of this._hosts) {
if (host.hasTaskExecutor(name)) {
return host.createTaskExecutor(name);
}
}
return (0, rxjs_1.throwError)(new src_1.UnregisteredTaskException(name));
}
hasTaskExecutor(name) {
for (const host of this._hosts) {
if (host.hasTaskExecutor(name)) {
return true;
}
}
return false;
}
}
exports.FallbackEngineHost = FallbackEngineHost;
//# sourceMappingURL=fallback-engine-host.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"fallback-engine-host.js","sourceRoot":"","sources":["fallback-engine-host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAGH,+BAA4E;AAC5E,gCAUgB;AAchB;;;GAGG;AACH,MAAa,kBAAkB;IACrB,MAAM,GAAyB,EAAE,CAAC;IAE1C,OAAO,CACL,IAAyC;QAEzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,2BAA2B,CACzB,IAAY,EACZ,SAAqC;QAErC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACH,MAAM,WAAW,GAAG,IAAI,CAAC,2BAA2B,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;gBAEtE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;YACrC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;QAChB,CAAC;QAED,MAAM,IAAI,gCAA0B,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,0BAA0B,CACxB,IAAY,EACZ,UAAgE;QAEhE,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;QAC7F,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IAC3C,CAAC;IAED,uBAAuB,CACrB,SAA4F,EAC5F,UAAgE;QAEhE,OAAO,UAAU,CAAC,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,WAAW,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAChG,CAAC;IAED,mBAAmB,CAAC,GAAQ,EAAE,OAAwB;QACpD,OAAO,OAAO,C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CAAC,IAAY;QAC7B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/B,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QAED,OAAO,IAAA,iBAAU,EAAC,IAAI,+BAAyB,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,eAAe,CAAC,IAAY;QAC1B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/B,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAzGD,gDAyGC"}
+74
View File
@@ -0,0 +1,74 @@
/**
* @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 { BaseException } from '@angular-devkit/core';
import { Url } from 'node:url';
import { Observable } from 'rxjs';
import { RuleFactory, Source, TaskExecutor, TaskExecutorFactory } from '../src';
import { FileSystemCollectionDesc, FileSystemEngineHost, FileSystemSchematicContext, FileSystemSchematicDesc, FileSystemSchematicDescription } from './description';
export declare type OptionTransform<T extends object | null, R extends object> = (schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext) => Observable<R> | PromiseLike<R> | R;
export declare type ContextTransform = (context: FileSystemSchematicContext) => FileSystemSchematicContext;
export declare class CollectionCannotBeResolvedException extends BaseException {
constructor(name: string);
}
export declare class InvalidCollectionJsonException extends BaseException {
constructor(_name: string, path: string, jsonException?: Error);
}
export declare class SchematicMissingFactoryException extends BaseException {
constructor(name: string);
}
export declare class FactoryCannotBeResolvedException extends BaseException {
constructor(name: string);
}
export declare class CollectionMissingSchematicsMapException extends BaseException {
constructor(name: string);
}
export declare class CollectionMissingFieldsException extends BaseException {
constructor(name: string);
}
export declare class SchematicMissingFieldsException extends BaseException {
constructor(name: string);
}
export declare class SchematicMissingDescriptionException extends BaseException {
constructor(name: string);
}
export declare class SchematicNameCollisionException extends BaseException {
constructor(name: string);
}
/**
* A EngineHost base class that uses the file system to resolve collections. This is the base of
* all other EngineHost provided by the tooling part of the Schematics library.
*/
export declare abstract class FileSystemEngineHostBase implements FileSystemEngineHost {
protected abstract _resolveCollectionPath(name: string, requester?: string): string;
protected abstract _resolveReferenceString(name: string, parentPath: string, collectionDescription: FileSystemCollectionDesc): {
ref: RuleFactory<{}>;
path: string;
} | null;
protected abstract _transformCollectionDescription(name: string, desc: Partial<FileSystemCollectionDesc>): FileSystemCollectionDesc;
protected abstract _transformSchematicDescription(name: string, collection: FileSystemCollectionDesc, desc: Partial<FileSystemSchematicDesc>): FileSystemSchematicDesc;
private _transforms;
private _contextTransforms;
private _taskFactories;
listSchematicNames(collection: FileSystemCollectionDesc, includeHidden?: boolean): string[];
registerOptionsTransform<T extends object | null, R extends object>(t: OptionTransform<T, R>): void;
registerContextTransform(t: ContextTransform): void;
/**
*
* @param name
* @return {{path: string}}
*/
createCollectionDescription(name: string, requester?: FileSystemCollectionDesc): FileSystemCollectionDesc;
createSchematicDescription(name: string, collection: FileSystemCollectionDesc): FileSystemSchematicDesc | null;
createSourceFromUrl(url: Url): Source | null;
transformOptions<OptionT extends object, ResultT extends object>(schematic: FileSystemSchematicDesc, options: OptionT, context?: FileSystemSchematicContext): Observable<ResultT>;
transformContext(context: FileSystemSchematicContext): FileSystemSchematicContext;
getSchematicRuleFactory<OptionT extends object>(schematic: FileSystemSchematicDesc, _collection: FileSystemCollectionDesc): RuleFactory<OptionT>;
registerTaskExecutor<T>(factory: TaskExecutorFactory<T>, options?: T): void;
createTaskExecutor(name: string): Observable<TaskExecutor>;
hasTaskExecutor(name: string): boolean;
}
+260
View File
@@ -0,0 +1,260 @@
"use strict";
/**
* @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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileSystemEngineHostBase = exports.SchematicNameCollisionException = exports.SchematicMissingDescriptionException = exports.SchematicMissingFieldsException = exports.CollectionMissingFieldsException = exports.CollectionMissingSchematicsMapException = exports.FactoryCannotBeResolvedException = exports.SchematicMissingFactoryException = exports.InvalidCollectionJsonException = exports.CollectionCannotBeResolvedException = void 0;
const core_1 = require("@angular-devkit/core");
const node_1 = require("@angular-devkit/core/node");
const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
const rxjs_1 = require("rxjs");
const src_1 = require("../src");
const file_system_utility_1 = require("./file-system-utility");
class CollectionCannotBeResolvedException extends core_1.BaseException {
constructor(name) {
super(`Collection ${JSON.stringify(name)} cannot be resolved.`);
}
}
exports.CollectionCannotBeResolvedException = CollectionCannotBeResolvedException;
class InvalidCollectionJsonException extends core_1.BaseException {
constructor(_name, path, jsonException) {
let msg = `Collection JSON at path ${JSON.stringify(path)} is invalid.`;
if (jsonException) {
msg = `${msg} ${jsonException.message}`;
}
super(msg);
}
}
exports.InvalidCollectionJsonException = InvalidCollectionJsonException;
class SchematicMissingFactoryException extends core_1.BaseException {
constructor(name) {
super(`Schematic ${JSON.stringify(name)} is missing a factory.`);
}
}
exports.SchematicMissingFactoryException = SchematicMissingFactoryException;
class FactoryCannotBeResolvedException extends core_1.BaseException {
constructor(name) {
super(`Schematic ${JSON.stringify(name)} cannot resolve the factory.`);
}
}
exports.FactoryCannotBeResolvedException = FactoryCannotBeResolvedException;
class CollectionMissingSchematicsMapException extends core_1.BaseException {
constructor(name) {
super(`Collection "${name}" does not have a schematics map.`);
}
}
exports.CollectionMissingSchematicsMapException = CollectionMissingSchematicsMapException;
class CollectionMissingFieldsException extends core_1.BaseException {
constructor(name) {
super(`Collection "${name}" is missing fields.`);
}
}
exports.CollectionMissingFieldsException = CollectionMissingFieldsException;
class SchematicMissingFieldsException extends core_1.BaseException {
constructor(name) {
super(`Schematic "${name}" is missing fields.`);
}
}
exports.SchematicMissingFieldsException = SchematicMissingFieldsException;
class SchematicMissingDescriptionException extends core_1.BaseException {
constructor(name) {
super(`Schematics "${name}" does not have a description.`);
}
}
exports.SchematicMissingDescriptionException = SchematicMissingDescriptionException;
class SchematicNameCollisionException extends core_1.BaseException {
constructor(name) {
super(`Schematics/alias ${JSON.stringify(name)} collides with another alias or schematic` +
' name.');
}
}
exports.SchematicNameCollisionException = SchematicNameCollisionException;
/**
* A EngineHost base class that uses the file system to resolve collections. This is the base of
* all other EngineHost provided by the tooling part of the Schematics library.
*/
class FileSystemEngineHostBase {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_transforms = [];
_contextTransforms = [];
_taskFactories = new Map();
listSchematicNames(collection, includeHidden) {
const schematics = [];
for (const key of Object.keys(collection.schematics)) {
const schematic = collection.schematics[key];
if ((schematic.hidden && !includeHidden) || schematic.private) {
continue;
}
// If extends is present without a factory it is an alias, do not return it
// unless it is from another collection.
if (!schematic.extends || schematic.factory) {
schematics.push(key);
}
else if (schematic.extends && schematic.extends.indexOf(':') !== -1) {
schematics.push(key);
}
}
return schematics;
}
registerOptionsTransform(t) {
this._transforms.push(t);
}
registerContextTransform(t) {
this._contextTransforms.push(t);
}
/**
*
* @param name
* @return {{path: string}}
*/
createCollectionDescription(name, requester) {
const path = this._resolveCollectionPath(name, requester?.path);
const jsonValue = (0, file_system_utility_1.readJsonFile)(path);
if (!jsonValue || typeof jsonValue != 'object' || Array.isArray(jsonValue)) {
throw new InvalidCollectionJsonException(name, path);
}
// normalize extends property to an array
if (typeof jsonValue['extends'] === 'string') {
jsonValue['extends'] = [jsonValue['extends']];
}
const description = this._transformCollectionDescription(name, {
...jsonValue,
path,
});
if (!description || !description.name) {
throw new InvalidCollectionJsonException(name, path);
}
// Validate aliases.
const allNames = Object.keys(description.schematics);
for (const schematicName of Object.keys(description.schematics)) {
const aliases = description.schematics[schematicName].aliases || [];
for (const alias of aliases) {
if (allNames.indexOf(alias) != -1) {
throw new SchematicNameCollisionException(alias);
}
}
allNames.push(...aliases);
}
return description;
}
createSchematicDescription(name, collection) {
// Resolve aliases first.
for (const schematicName of Object.keys(collection.schematics)) {
const schematicDescription = collection.schematics[schematicName];
if (schematicDescription.aliases && schematicDescription.aliases.indexOf(name) != -1) {
name = schematicName;
break;
}
}
if (!(name in collection.schematics)) {
return null;
}
const collectionPath = (0, node_path_1.dirname)(collection.path);
const partialDesc = collection.schematics[name];
if (!partialDesc) {
return null;
}
if (partialDesc.extends) {
const index = partialDesc.extends.indexOf(':');
const collectionName = index !== -1 ? partialDesc.extends.slice(0, index) : null;
const schematicName = index === -1 ? partialDesc.extends : partialDesc.extends.slice(index + 1);
if (collectionName !== null) {
const extendCollection = this.createCollectionDescription(collectionName);
return this.createSchematicDescription(schematicName, extendCollection);
}
else {
return this.createSchematicDescription(schematicName, collection);
}
}
// Use any on this ref as we don't have the OptionT here, but we don't need it (we only need
// the path).
if (!partialDesc.factory) {
throw new SchematicMissingFactoryException(name);
}
const resolvedRef = this._resolveReferenceString(partialDesc.factory, collectionPath, collection);
if (!resolvedRef) {
throw new FactoryCannotBeResolvedException(name);
}
let schema = partialDesc.schema;
let schemaJson = undefined;
if (schema) {
if (!(0, node_path_1.isAbsolute)(schema)) {
schema = (0, node_path_1.join)(collectionPath, schema);
}
schemaJson = (0, file_system_utility_1.readJsonFile)(schema);
}
// The schematic path is used to resolve URLs.
// We should be able to just do `dirname(resolvedRef.path)` but for compatibility with
// Bazel under Windows this directory needs to be resolved from the collection instead.
// This is needed because on Bazel under Windows the data files (such as the collection or
// url files) are not in the same place as the compiled JS.
const maybePath = (0, node_path_1.join)(collectionPath, partialDesc.factory);
const path = (0, node_fs_1.existsSync)(maybePath) && (0, node_fs_1.statSync)(maybePath).isDirectory() ? maybePath : (0, node_path_1.dirname)(maybePath);
return this._transformSchematicDescription(name, collection, {
...partialDesc,
schema,
schemaJson,
name,
path,
factoryFn: resolvedRef.ref,
collection,
});
}
createSourceFromUrl(url) {
switch (url.protocol) {
case null:
case 'file:':
return (context) => {
// Check if context has necessary FileSystemSchematicContext path property
const fileDescription = context.schematic.description;
if (fileDescription.path === undefined) {
throw new Error('Unsupported schematic context. Expected a FileSystemSchematicContext.');
}
// Resolve all file:///a/b/c/d from the schematic's own path, and not the current
// path.
const root = (0, core_1.normalize)((0, node_path_1.resolve)(fileDescription.path, url.path || ''));
return new src_1.HostCreateTree(new core_1.virtualFs.ScopedHost(new node_1.NodeJsSyncHost(), root));
};
}
return null;
}
transformOptions(schematic, options, context) {
const transform = async () => {
let transformedOptions = options;
for (const transformer of this._transforms) {
const transformerResult = transformer(schematic, transformedOptions, context);
transformedOptions = await ((0, rxjs_1.isObservable)(transformerResult)
? (0, rxjs_1.lastValueFrom)(transformerResult)
: transformerResult);
}
return transformedOptions;
};
return (0, rxjs_1.from)(transform());
}
transformContext(context) {
return this._contextTransforms.reduce((acc, curr) => curr(acc), context);
}
getSchematicRuleFactory(schematic, _collection) {
return schematic.factoryFn;
}
registerTaskExecutor(factory, options) {
this._taskFactories.set(factory.name, () => (0, rxjs_1.from)(factory.create(options)));
}
createTaskExecutor(name) {
const factory = this._taskFactories.get(name);
if (factory) {
return factory();
}
return (0, rxjs_1.throwError)(new src_1.UnregisteredTaskException(name));
}
hasTaskExecutor(name) {
return this._taskFactories.has(name);
}
}
exports.FileSystemEngineHostBase = FileSystemEngineHostBase;
//# sourceMappingURL=file-system-engine-host-base.js.map
File diff suppressed because one or more lines are too long
+28
View File
@@ -0,0 +1,28 @@
/**
* @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 { Observable } from 'rxjs';
import { RuleFactory, TaskExecutor } from '../src';
import { FileSystemCollectionDesc, FileSystemSchematicDesc } from './description';
import { FileSystemEngineHostBase } from './file-system-engine-host-base';
/**
* A simple EngineHost that uses a root with one directory per collection inside of it. The
* collection declaration follows the same rules as the regular FileSystemEngineHostBase.
*/
export declare class FileSystemEngineHost extends FileSystemEngineHostBase {
protected _root: string;
constructor(_root: string);
protected _resolveCollectionPath(name: string): string;
protected _resolveReferenceString(refString: string, parentPath: string): {
ref: RuleFactory<{}>;
path: string;
} | null;
protected _transformCollectionDescription(name: string, desc: Partial<FileSystemCollectionDesc>): FileSystemCollectionDesc;
protected _transformSchematicDescription(name: string, _collection: FileSystemCollectionDesc, desc: Partial<FileSystemSchematicDesc>): FileSystemSchematicDesc;
hasTaskExecutor(name: string): boolean;
createTaskExecutor(name: string): Observable<TaskExecutor>;
}
+128
View File
@@ -0,0 +1,128 @@
"use strict";
/**
* @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
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileSystemEngineHost = void 0;
const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
const rxjs_1 = require("rxjs");
const src_1 = require("../src");
const export_ref_1 = require("./export-ref");
const file_system_engine_host_base_1 = require("./file-system-engine-host-base");
/**
* A simple EngineHost that uses a root with one directory per collection inside of it. The
* collection declaration follows the same rules as the regular FileSystemEngineHostBase.
*/
class FileSystemEngineHost extends file_system_engine_host_base_1.FileSystemEngineHostBase {
_root;
constructor(_root) {
super();
this._root = _root;
}
_resolveCollectionPath(name) {
try {
// Allow `${_root}/${name}.json` as a collection.
const maybePath = require.resolve((0, node_path_1.join)(this._root, name + '.json'));
if ((0, node_fs_1.existsSync)(maybePath)) {
return maybePath;
}
}
catch (error) { }
try {
// Allow `${_root}/${name}/collection.json.
const maybePath = require.resolve((0, node_path_1.join)(this._root, name, 'collection.json'));
if ((0, node_fs_1.existsSync)(maybePath)) {
return maybePath;
}
}
catch (error) { }
throw new file_system_engine_host_base_1.CollectionCannotBeResolvedException(name);
}
_resolveReferenceString(refString, parentPath) {
// Use the same kind of export strings as NodeModule.
const ref = new export_ref_1.ExportStringRef(refString, parentPath);
if (!ref.ref) {
return null;
}
return { ref: ref.ref, path: ref.module };
}
_transformCollectionDescription(name, desc) {
if (!desc.schematics || typeof desc.schematics != 'object') {
throw new file_system_engine_host_base_1.CollectionMissingSchematicsMapException(name);
}
return {
...desc,
name,
};
}
_transformSchematicDescription(name, _collection, desc) {
if (!desc.factoryFn || !desc.path || !desc.description) {
throw new file_system_engine_host_base_1.SchematicMissingFieldsException(name);
}
return desc;
}
hasTaskExecutor(name) {
if (super.hasTaskExecutor(name)) {
return true;
}
try {
const maybePath = require.resolve((0, node_path_1.join)(this._root, name));
if ((0, node_fs_1.existsSync)(maybePath)) {
return true;
}
}
catch { }
return false;
}
createTaskExecutor(name) {
if (!super.hasTaskExecutor(name)) {
try {
const path = require.resolve((0, node_path_1.join)(this._root, name));
// Default handling code is for old tasks that incorrectly export `default` with non-ESM module
return (0, rxjs_1.from)(Promise.resolve(`${path}`).then(s => __importStar(require(s))).then((mod) => (mod.default?.default || mod.default)())).pipe((0, rxjs_1.catchError)(() => (0, rxjs_1.throwError)(() => new src_1.UnregisteredTaskException(name))));
}
catch { }
}
return super.createTaskExecutor(name);
}
}
exports.FileSystemEngineHost = FileSystemEngineHost;
//# sourceMappingURL=file-system-engine-host.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"file-system-engine-host.js","sourceRoot":"","sources":["file-system-engine-host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qCAAqC;AACrC,yCAAiC;AACjC,+BAAgE;AAChE,gCAA8E;AAE9E,6CAA+C;AAC/C,iFAKwC;AAExC;;;GAGG;AACH,MAAa,oBAAqB,SAAQ,uDAAwB;IAC1C;IAAtB,YAAsB,KAAa;QACjC,KAAK,EAAE,CAAC;QADY,UAAK,GAAL,KAAK,CAAQ;IAEnC,CAAC;IAES,sBAAsB,CAAC,IAAY;QAC3C,IAAI,CAAC;YACH,iDAAiD;YACjD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,IAAA,gBAAI,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;YACpE,IAAI,IAAA,oBAAU,EAAC,SAAS,CAAC,EAAE,CAAC;gBAC1B,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC,CAAA,CAAC;QAElB,IAAI,CAAC;YACH,2CAA2C;YAC3C,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,IAAA,gBAAI,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC;YAC7E,IAAI,IAAA,oBAAU,EAAC,SAAS,CAAC,EAAE,CAAC;gBAC1B,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC,C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O,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,OAAO,KAAK,CAAC;IACf,CAAC;IAEQ,kBAAkB,CAAC,IAAY;QACtC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAA,gBAAI,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;gBAErD,+FAA+F;gBAC/F,OAAO,IAAA,WAAI,EAAC,mBAAO,IAAI,wCAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CACnF,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,IAAI,+BAAyB,CAAC,IAAI,CAAC,CAAC,CAAC,CACxE,CAAC;YACJ,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACZ,CAAC;QAED,OAAO,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AA7FD,oDA6FC"}
+9
View File
@@ -0,0 +1,9 @@
/**
* @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 { JsonValue } from '@angular-devkit/core';
export declare function readJsonFile(path: string): JsonValue;
+33
View File
@@ -0,0 +1,33 @@
"use strict";
/**
* @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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.readJsonFile = readJsonFile;
const jsonc_parser_1 = require("jsonc-parser");
const node_fs_1 = require("node:fs");
const exception_1 = require("../src/exception/exception");
function readJsonFile(path) {
let data;
try {
data = (0, node_fs_1.readFileSync)(path, 'utf-8');
}
catch (e) {
if (e && typeof e === 'object' && 'code' in e && e.code === 'ENOENT') {
throw new exception_1.FileDoesNotExistException(path);
}
throw e;
}
const errors = [];
const content = (0, jsonc_parser_1.parse)(data, errors, { allowTrailingComma: true });
if (errors.length) {
const { error, offset } = errors[0];
throw new Error(`Failed to parse "${path}" as JSON AST Object. ${(0, jsonc_parser_1.printParseErrorCode)(error)} at location: ${offset}.`);
}
return content;
}
//# sourceMappingURL=file-system-utility.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"file-system-utility.js","sourceRoot":"","sources":["file-system-utility.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAOH,oCAwBC;AA5BD,+CAAsE;AACtE,qCAAuC;AACvC,0DAAuE;AAEvE,SAAgB,YAAY,CAAC,IAAY;IACvC,IAAI,IAAI,CAAC;IACT,IAAI,CAAC;QACH,IAAI,GAAG,IAAA,sBAAY,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrE,MAAM,IAAI,qCAAyB,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;IAED,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,MAAM,OAAO,GAAG,IAAA,oBAAK,EAAC,IAAI,EAAE,MAAM,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAc,CAAC;IAE/E,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,IAAI,KAAK,CACb,oBAAoB,IAAI,yBAAyB,IAAA,kCAAmB,EAClE,KAAK,CACN,iBAAiB,MAAM,GAAG,CAC5B,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
+15
View File
@@ -0,0 +1,15 @@
/**
* @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
*/
export * from './description';
export * from './export-ref';
export * from './file-system-engine-host-base';
export * from './workflow/node-workflow';
export { FileSystemEngineHost } from './file-system-engine-host';
export { NodeModulesEngineHost, NodePackageDoesNotSupportSchematics, } from './node-module-engine-host';
export { NodeModulesTestEngineHost } from './node-modules-test-engine-host';
export { validateOptionsWithSchema } from './schema-option-transform';
+38
View File
@@ -0,0 +1,38 @@
"use strict";
/**
* @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
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateOptionsWithSchema = exports.NodeModulesTestEngineHost = exports.NodePackageDoesNotSupportSchematics = exports.NodeModulesEngineHost = exports.FileSystemEngineHost = void 0;
__exportStar(require("./description"), exports);
__exportStar(require("./export-ref"), exports);
__exportStar(require("./file-system-engine-host-base"), exports);
__exportStar(require("./workflow/node-workflow"), exports);
var file_system_engine_host_1 = require("./file-system-engine-host");
Object.defineProperty(exports, "FileSystemEngineHost", { enumerable: true, get: function () { return file_system_engine_host_1.FileSystemEngineHost; } });
var node_module_engine_host_1 = require("./node-module-engine-host");
Object.defineProperty(exports, "NodeModulesEngineHost", { enumerable: true, get: function () { return node_module_engine_host_1.NodeModulesEngineHost; } });
Object.defineProperty(exports, "NodePackageDoesNotSupportSchematics", { enumerable: true, get: function () { return node_module_engine_host_1.NodePackageDoesNotSupportSchematics; } });
var node_modules_test_engine_host_1 = require("./node-modules-test-engine-host");
Object.defineProperty(exports, "NodeModulesTestEngineHost", { enumerable: true, get: function () { return node_modules_test_engine_host_1.NodeModulesTestEngineHost; } });
var schema_option_transform_1 = require("./schema-option-transform");
Object.defineProperty(exports, "validateOptionsWithSchema", { enumerable: true, get: function () { return schema_option_transform_1.validateOptionsWithSchema; } });
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;AAEH,gDAA8B;AAC9B,+CAA6B;AAC7B,iEAA+C;AAE/C,2DAAyC;AAEzC,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,qEAGmC;AAFjC,gIAAA,qBAAqB,OAAA;AACrB,8IAAA,mCAAmC,OAAA;AAErC,iFAA4E;AAAnE,0IAAA,yBAAyB,OAAA;AAElC,qEAAsE;AAA7D,oIAAA,yBAAyB,OAAA"}
+29
View File
@@ -0,0 +1,29 @@
/**
* @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 { BaseException } from '@angular-devkit/core';
import { RuleFactory } from '../src';
import { FileSystemCollectionDesc, FileSystemSchematicDesc } from './description';
import { FileSystemEngineHostBase } from './file-system-engine-host-base';
export declare class NodePackageDoesNotSupportSchematics extends BaseException {
constructor(name: string);
}
/**
* A simple EngineHost that uses NodeModules to resolve collections.
*/
export declare class NodeModulesEngineHost extends FileSystemEngineHostBase {
private readonly paths?;
constructor(paths?: string[] | undefined);
private resolve;
protected _resolveCollectionPath(name: string, requester?: string): string;
protected _resolveReferenceString(refString: string, parentPath: string, collectionDescription?: FileSystemCollectionDesc): {
ref: RuleFactory<{}>;
path: string;
} | null;
protected _transformCollectionDescription(name: string, desc: Partial<FileSystemCollectionDesc>): FileSystemCollectionDesc;
protected _transformSchematicDescription(name: string, _collection: FileSystemCollectionDesc, desc: Partial<FileSystemSchematicDesc>): FileSystemSchematicDesc;
}
+115
View File
@@ -0,0 +1,115 @@
"use strict";
/**
* @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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeModulesEngineHost = exports.NodePackageDoesNotSupportSchematics = void 0;
const core_1 = require("@angular-devkit/core");
const node_path_1 = require("node:path");
const export_ref_1 = require("./export-ref");
const file_system_engine_host_base_1 = require("./file-system-engine-host-base");
const file_system_utility_1 = require("./file-system-utility");
class NodePackageDoesNotSupportSchematics extends core_1.BaseException {
constructor(name) {
super(`Package ${JSON.stringify(name)} was found but does not support schematics.`);
}
}
exports.NodePackageDoesNotSupportSchematics = NodePackageDoesNotSupportSchematics;
/**
* A simple EngineHost that uses NodeModules to resolve collections.
*/
class NodeModulesEngineHost extends file_system_engine_host_base_1.FileSystemEngineHostBase {
paths;
constructor(paths) {
super();
this.paths = paths;
}
resolve(name, requester, references = new Set()) {
// Keep track of the package requesting the schematic, in order to avoid infinite recursion
if (requester) {
if (references.has(requester)) {
references.add(requester);
throw new Error('Circular schematic reference detected: ' + JSON.stringify(Array.from(references)));
}
else {
references.add(requester);
}
}
let collectionPath = undefined;
const resolveOptions = {
paths: requester ? [(0, node_path_1.dirname)(requester), ...(this.paths || [])] : this.paths,
};
// Try to resolve as a package
try {
const packageJsonPath = require.resolve(`${name}/package.json`, resolveOptions);
const { schematics } = require(packageJsonPath);
if (!schematics || typeof schematics !== 'string') {
throw new NodePackageDoesNotSupportSchematics(name);
}
// If this is a relative path to the collection, then create the collection
// path in relation to the package path
if (schematics.startsWith('.')) {
const packageDirectory = (0, node_path_1.dirname)(packageJsonPath);
collectionPath = (0, node_path_1.resolve)(packageDirectory, schematics);
}
// Otherwise treat this as a package, and recurse to find the collection path
else {
collectionPath = this.resolve(schematics, packageJsonPath, references);
}
}
catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}
}
// If not a package, try to resolve as a file
if (!collectionPath) {
try {
collectionPath = require.resolve(name, resolveOptions);
}
catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}
}
}
// If not a package or a file, error
if (!collectionPath) {
throw new file_system_engine_host_base_1.CollectionCannotBeResolvedException(name);
}
return collectionPath;
}
_resolveCollectionPath(name, requester) {
const collectionPath = this.resolve(name, requester);
(0, file_system_utility_1.readJsonFile)(collectionPath);
return collectionPath;
}
_resolveReferenceString(refString, parentPath, collectionDescription) {
const ref = new export_ref_1.ExportStringRef(refString, parentPath);
if (!ref.ref) {
return null;
}
return { ref: ref.ref, path: ref.module };
}
_transformCollectionDescription(name, desc) {
if (!desc.schematics || typeof desc.schematics != 'object') {
throw new file_system_engine_host_base_1.CollectionMissingSchematicsMapException(name);
}
return {
...desc,
name,
};
}
_transformSchematicDescription(name, _collection, desc) {
if (!desc.factoryFn || !desc.path || !desc.description) {
throw new file_system_engine_host_base_1.SchematicMissingFieldsException(name);
}
return desc;
}
}
exports.NodeModulesEngineHost = NodeModulesEngineHost;
//# sourceMappingURL=node-module-engine-host.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"node-module-engine-host.js","sourceRoot":"","sources":["node-module-engine-host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+CAAqD;AACrD,yCAA6C;AAG7C,6CAA+C;AAC/C,iFAKwC;AACxC,+DAAqD;AAErD,MAAa,mCAAoC,SAAQ,oBAAa;IACpE,YAAY,IAAY;QACtB,KAAK,CAAC,WAAW,IAAI,C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G,GAAG,IAAI,4BAAe,CAAkB,SAAS,EAAE,UAAU,CAAC,CAAC;QACxE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IAC5C,CAAC;IAES,+BAA+B,CACvC,IAAY,EACZ,IAAuC;QAEvC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;YAC3D,MAAM,IAAI,sEAAuC,CAAC,IAAI,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO;YACL,GAAG,IAAI;YACP,IAAI;SACuB,CAAC;IAChC,CAAC;IAES,8BAA8B,CACtC,IAAY,EACZ,WAAqC,EACrC,IAAsC;QAEtC,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACvD,MAAM,IAAI,8DAA+B,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,IAA+B,CAAC;IACzC,CAAC;CACF;AAhHD,sDAgHC"}
+22
View File
@@ -0,0 +1,22 @@
/**
* @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 { TaskConfiguration } from '../src/engine';
import { FileSystemSchematicContext } from './description';
import { NodeModulesEngineHost } from './node-module-engine-host';
/**
* An EngineHost that uses a registry to super seed locations of collection.json files, but
* revert back to using node modules resolution. This is done for testing.
*/
export declare class NodeModulesTestEngineHost extends NodeModulesEngineHost {
#private;
get tasks(): TaskConfiguration[];
clearTasks(): void;
registerCollection(name: string, path: string): void;
transformContext(context: FileSystemSchematicContext): FileSystemSchematicContext;
protected _resolveCollectionPath(name: string, requester?: string): string;
}
+41
View File
@@ -0,0 +1,41 @@
"use strict";
/**
* @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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeModulesTestEngineHost = void 0;
const node_module_engine_host_1 = require("./node-module-engine-host");
/**
* An EngineHost that uses a registry to super seed locations of collection.json files, but
* revert back to using node modules resolution. This is done for testing.
*/
class NodeModulesTestEngineHost extends node_module_engine_host_1.NodeModulesEngineHost {
#collections = new Map();
#tasks = [];
get tasks() {
return this.#tasks;
}
clearTasks() {
this.#tasks = [];
}
registerCollection(name, path) {
this.#collections.set(name, path);
}
transformContext(context) {
const oldAddTask = context.addTask.bind(context);
context.addTask = (task, dependencies) => {
this.#tasks.push(task.toConfiguration());
return oldAddTask(task, dependencies);
};
return context;
}
_resolveCollectionPath(name, requester) {
return this.#collections.get(name) ?? super._resolveCollectionPath(name, requester);
}
}
exports.NodeModulesTestEngineHost = NodeModulesTestEngineHost;
//# sourceMappingURL=node-modules-test-engine-host.js.map
@@ -0,0 +1 @@
{"version":3,"file":"node-modules-test-engine-host.js","sourceRoot":"","sources":["node-modules-test-engine-host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH,uEAAkE;AAElE;;;GAGG;AACH,MAAa,yBAA0B,SAAQ,+CAAqB;IAClE,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,MAAM,GAAwB,EAAE,CAAC;IAEjC,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,UAAU;QACR,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,kBAAkB,CAAC,IAAY,EAAE,IAAY;QAC3C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAEQ,gBAAgB,CAAC,OAAmC;QAC3D,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,CAAC,OAAO,GAAG,CAAC,IAAgC,EAAE,YAAuB,EAAE,EAAE;YAC9E,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;YAEzC,OAAO,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACxC,CAAC,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;IAEkB,sBAAsB,CAAC,IAAY,EAAE,SAAkB;QACxE,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtF,CAAC;CACF;AA9BD,8DA8BC"}
+5
View File
@@ -0,0 +1,5 @@
{
"name": "@angular-devkit/schematics/tools",
"main": "index.js",
"typings": "index.d.ts"
}
+14
View File
@@ -0,0 +1,14 @@
/**
* @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 { schema } from '@angular-devkit/core';
import { Observable } from 'rxjs';
import { FileSystemSchematicContext, FileSystemSchematicDescription } from './description';
export declare class InvalidInputOptions<T = {}> extends schema.SchemaValidationException {
constructor(options: T, errors: schema.SchemaValidatorError[]);
}
export declare function validateOptionsWithSchema(registry: schema.SchemaRegistry): <T extends {} | null>(schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext) => Observable<T>;
+39
View File
@@ -0,0 +1,39 @@
"use strict";
/**
* @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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidInputOptions = void 0;
exports.validateOptionsWithSchema = validateOptionsWithSchema;
const core_1 = require("@angular-devkit/core");
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
class InvalidInputOptions extends core_1.schema.SchemaValidationException {
constructor(options, errors) {
super(errors, `Schematic input does not validate against the Schema: ${JSON.stringify(options)}\nErrors:\n`);
}
}
exports.InvalidInputOptions = InvalidInputOptions;
// This can only be used in NodeJS.
function validateOptionsWithSchema(registry) {
return (schematic, options, context) => {
// Prevent a schematic from changing the options object by making a copy of it.
options = (0, core_1.deepCopy)(options);
const withPrompts = context ? context.interactive : true;
if (schematic.schema && schematic.schemaJson) {
// Make a deep copy of options.
return (0, rxjs_1.from)(registry.compile(schematic.schemaJson)).pipe((0, operators_1.mergeMap)((validator) => validator(options, { withPrompts })), (0, operators_1.first)(), (0, operators_1.map)((result) => {
if (!result.success) {
throw new InvalidInputOptions(options, result.errors || []);
}
return options;
}));
}
return (0, rxjs_1.of)(options);
};
}
//# sourceMappingURL=schema-option-transform.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"schema-option-transform.js","sourceRoot":"","sources":["schema-option-transform.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAiBH,8DA4BC;AA3CD,+CAAwD;AACxD,+BAA4D;AAC5D,8CAAsD;AAGtD,MAAa,mBAA4B,SAAQ,aAAM,CAAC,yBAAyB;IAC/E,YAAY,OAAU,EAAE,MAAqC;QAC3D,KAAK,CACH,MAAM,EACN,yDAAyD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CAC9F,CAAC;IACJ,CAAC;CACF;AAPD,kDAOC;AAED,mCAAmC;AACnC,SAAgB,yBAAyB,CAAC,QAA+B;IACvE,OAAO,CACL,SAAyC,EACzC,OAAU,EACV,OAAoC,EACrB,EAAE;QACjB,+EAA+E;QAC/E,OAAO,GAAG,IAAA,eAAQ,EAAC,OAAO,CAAC,CAAC;QAE5B,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;QAEzD,IAAI,SAAS,CAAC,MAAM,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;YAC7C,+BAA+B;YAC/B,OAAO,IAAA,WAAI,EAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CACtD,IAAA,oBAAQ,EAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,EAC5D,IAAA,iBAAK,GAAE,EACP,IAAA,eAAG,EAAC,CAAC,MAAM,EAAE,EAAE;gBACb,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBACpB,MAAM,IAAI,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;gBAC9D,CAAC;gBAED,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QAED,OAAO,IAAA,SAAY,EAAC,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC"}
+35
View File
@@ -0,0 +1,35 @@
/**
* @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 { Path, schema, virtualFs } from '@angular-devkit/core';
import { workflow } from '../../src';
import { FileSystemEngine } from '../description';
import { OptionTransform } from '../file-system-engine-host-base';
import { NodeModulesEngineHost } from '../node-module-engine-host';
export interface NodeWorkflowOptions {
force?: boolean;
dryRun?: boolean;
packageManager?: string;
packageManagerForce?: boolean;
packageRegistry?: string;
registry?: schema.CoreSchemaRegistry;
resolvePaths?: string[];
schemaValidation?: boolean;
optionTransforms?: OptionTransform<Record<string, unknown> | null, object>[];
engineHostCreator?: (options: NodeWorkflowOptions) => NodeModulesEngineHost;
}
/**
* A workflow specifically for Node tools.
*/
export declare class NodeWorkflow extends workflow.BaseWorkflow {
constructor(root: string, options: NodeWorkflowOptions);
constructor(host: virtualFs.Host, options: NodeWorkflowOptions & {
root?: Path;
});
get engine(): FileSystemEngine;
get engineHost(): NodeModulesEngineHost;
}
+69
View File
@@ -0,0 +1,69 @@
"use strict";
/**
* @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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeWorkflow = void 0;
const core_1 = require("@angular-devkit/core");
const node_1 = require("@angular-devkit/core/node");
const src_1 = require("../../src");
const node_2 = require("../../tasks/node");
const node_module_engine_host_1 = require("../node-module-engine-host");
const schema_option_transform_1 = require("../schema-option-transform");
/**
* A workflow specifically for Node tools.
*/
class NodeWorkflow extends src_1.workflow.BaseWorkflow {
constructor(hostOrRoot, options) {
let host;
let root;
if (typeof hostOrRoot === 'string') {
root = (0, core_1.normalize)(hostOrRoot);
host = new core_1.virtualFs.ScopedHost(new node_1.NodeJsSyncHost(), root);
}
else {
host = hostOrRoot;
root = options.root;
}
const engineHost = options.engineHostCreator?.(options) || new node_module_engine_host_1.NodeModulesEngineHost(options.resolvePaths);
super({
host,
engineHost,
force: options.force,
dryRun: options.dryRun,
registry: options.registry,
});
engineHost.registerTaskExecutor(node_2.BuiltinTaskExecutor.NodePackage, {
allowPackageManagerOverride: true,
packageManager: options.packageManager,
force: options.packageManagerForce,
rootDirectory: root && (0, core_1.getSystemPath)(root),
registry: options.packageRegistry,
});
engineHost.registerTaskExecutor(node_2.BuiltinTaskExecutor.RepositoryInitializer, {
rootDirectory: root && (0, core_1.getSystemPath)(root),
});
engineHost.registerTaskExecutor(node_2.BuiltinTaskExecutor.RunSchematic);
if (options.optionTransforms) {
for (const transform of options.optionTransforms) {
engineHost.registerOptionsTransform(transform);
}
}
if (options.schemaValidation) {
engineHost.registerOptionsTransform((0, schema_option_transform_1.validateOptionsWithSchema)(this.registry));
}
this._context = [];
}
get engine() {
return this._engine;
}
get engineHost() {
return this._engineHost;
}
}
exports.NodeWorkflow = NodeWorkflow;
//# sourceMappingURL=node-workflow.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"node-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