Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @license
* Copyright Google Inc. 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
*/
const core_1 = require("@angular-devkit/core");
// Used by schematics to throw exceptions.
class SchematicsException extends core_1.BaseException {
}
exports.SchematicsException = SchematicsException;
// Exceptions
class FileDoesNotExistException extends core_1.BaseException {
constructor(path) { super(`Path "${path}" does not exist.`); }
}
exports.FileDoesNotExistException = FileDoesNotExistException;
class FileAlreadyExistException extends core_1.BaseException {
constructor(path) { super(`Path "${path}" already exist.`); }
}
exports.FileAlreadyExistException = FileAlreadyExistException;
class ContentHasMutatedException extends core_1.BaseException {
constructor(path) {
super(`Content at path "${path}" has changed between the start and the end of an update.`);
}
}
exports.ContentHasMutatedException = ContentHasMutatedException;
class InvalidUpdateRecordException extends core_1.BaseException {
constructor() { super(`Invalid record instance.`); }
}
}
else {
return 'Unknown Object';
}
}
}
/**
* When a rule or source returns an invalid value.
*/
class InvalidRuleResultException extends core_1.BaseException {
constructor(value) {
super(`Invalid rule result: ${_getTypeOfResult(value)}.`);
}
}
exports.InvalidRuleResultException = InvalidRuleResultException;
class InvalidSourceResultException extends core_1.BaseException {
constructor(value) {
super(`Invalid source result: ${_getTypeOfResult(value)}.`);
}
}
exports.InvalidSourceResultException = InvalidSourceResultException;
function callSource(source, context) {
const result = source(context);
if (core_1.isObservable(result)) {
// Only return the last Tree, and make sure it's a Tree.
return result.pipe(operators_1.defaultIfEmpty(), operators_1.last(), operators_1.tap(inner => {
if (!inner || !(interface_1.TreeSymbol in inner)) {
throw new InvalidSourceResultException(inner);
}
}));
}
else if (result && interface_1.TreeSymbol in result) {
}
exports.ProjectNotFoundException = ProjectNotFoundException;
class TargetNotFoundException extends core_1.BaseException {
constructor(projectName, targetName) {
super(`Target '${targetName}' could not be found in project '${projectName}'.`);
}
}
exports.TargetNotFoundException = TargetNotFoundException;
class ConfigurationNotFoundException extends core_1.BaseException {
constructor(projectName, configurationName) {
super(`Configuration '${configurationName}' could not be found in project '${projectName}'.`);
}
}
exports.ConfigurationNotFoundException = ConfigurationNotFoundException;
// TODO: break this exception apart into more granular ones.
class BuilderCannotBeResolvedException extends core_1.BaseException {
constructor(builder) {
super(`Builder '${builder}' cannot be resolved.`);
}
}
exports.BuilderCannotBeResolvedException = BuilderCannotBeResolvedException;
class ArchitectNotYetLoadedException extends core_1.BaseException {
constructor() { super(`Architect needs to be loaded before Architect is used.`); }
}
exports.ArchitectNotYetLoadedException = ArchitectNotYetLoadedException;
class BuilderNotFoundException extends core_1.BaseException {
constructor(builder) {
super(`Builder ${builder} could not be found.`);
}
}
exports.BuilderNotFoundException = BuilderNotFoundException;
class Architect {
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.');
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @license
* Copyright Google Inc. 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
*/
const core_1 = require("@angular-devkit/core");
const base_1 = require("./base");
const rename_1 = require("./rename");
const is_binary_1 = require("./utils/is-binary");
exports.TEMPLATE_FILENAME_RE = /\.template$/;
class OptionIsNotDefinedException extends core_1.BaseException {
constructor(name) { super(`Option "${name}" is not defined.`); }
}
exports.OptionIsNotDefinedException = OptionIsNotDefinedException;
class UnknownPipeException extends core_1.BaseException {
constructor(name) { super(`Pipe "${name}" is not defined.`); }
}
exports.UnknownPipeException = UnknownPipeException;
class InvalidPipeException extends core_1.BaseException {
constructor(name) { super(`Pipe "${name}" is invalid.`); }
}
exports.InvalidPipeException = InvalidPipeException;
function applyContentTemplate(options) {
return (entry) => {
const { path, content } = entry;
if (is_binary_1.isBinary(content)) {
return entry;
const path_1 = require("path");
const file_system_host_1 = require("./file-system-host");
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) {
super(`Collection JSON at path ${JSON.stringify(path)} is invalid.`);
}
}
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 {
}
}
exports.CollectionCannotBeResolvedException = CollectionCannotBeResolvedException;
class InvalidCollectionJsonException extends core_1.BaseException {
constructor(_name, path) {
super(`Collection JSON at path ${JSON.stringify(path)} is invalid.`);
}
}
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.`); }
}
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 {
constructor() {
this._transforms = [];
}
listSchematics(collection) {
const schematics = [];
constructor(name) {
super(`Circular collection reference "${name}".`);
}
}
exports.CircularCollectionException = CircularCollectionException;
class UnknownSchematicException extends core_1.BaseException {
constructor(name, collection) {
super(`Schematic "${name}" not found in collection "${collection.name}".`);
}
}
exports.UnknownSchematicException = UnknownSchematicException;
class SchematicEngineConflictingException extends core_1.BaseException {
constructor() { super(`A schematic was called from a different engine as its parent.`); }
}
exports.SchematicEngineConflictingException = SchematicEngineConflictingException;
class UnregisteredTaskException extends core_1.BaseException {
constructor(name, schematic) {
const addendum = schematic ? ` in schematic "${schematic.name}"` : '';
super(`Unregistered task "${name}"${addendum}.`);
}
}
exports.UnregisteredTaskException = UnregisteredTaskException;
class SchematicEngine {
constructor(_host) {
this._host = _host;
this._collectionCache = new Map();
this._schematicCache = new Map();
this._taskSchedulers = new Array();
}
get defaultMergeStrategy() { return this._host.defaultMergeStrategy || interface_1.MergeStrategy.Default; }
createCollection(name) {
let collection = this._collectionCache.get(name);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @license
* Copyright Google Inc. 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
*/
const core_1 = require("@angular-devkit/core");
class UnknownActionException extends core_1.BaseException {
constructor(action) { super(`Unknown action: "${action.kind}".`); }
}
exports.UnknownActionException = UnknownActionException;
let _id = 1;
class ActionList {
constructor() {
this._actions = [];
}
_action(action) {
this._actions.push(Object.assign({
id: _id++,
parent: this._actions[this._actions.length - 1] || 0,
}, action));
}
create(path, content) {
this._action({ kind: 'c', path, content });