Primeiro commit do projeto Angular
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @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 './schematic-test-runner';
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"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 });
|
||||
__exportStar(require("./schematic-test-runner"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH,0DAAwC"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "@angular-devkit/schematics/testing",
|
||||
"main": "index.js",
|
||||
"typings": "index.d.ts"
|
||||
}
|
||||
+29
@@ -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 { logging } from '@angular-devkit/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DelegateTree, Rule, SchematicContext, SchematicEngine, TaskConfiguration, Tree } from '../src';
|
||||
export declare class UnitTestTree extends DelegateTree {
|
||||
get files(): string[];
|
||||
readContent(path: string): string;
|
||||
}
|
||||
export declare class SchematicTestRunner {
|
||||
private _collectionName;
|
||||
private _engineHost;
|
||||
private _engine;
|
||||
private _collection;
|
||||
private _logger;
|
||||
constructor(_collectionName: string, collectionPath: string);
|
||||
get engine(): SchematicEngine<{}, {}>;
|
||||
get logger(): logging.Logger;
|
||||
get tasks(): TaskConfiguration[];
|
||||
registerCollection(collectionName: string, collectionPath: string): void;
|
||||
runSchematic<SchematicSchemaT extends object>(schematicName: string, opts?: SchematicSchemaT, tree?: Tree): Promise<UnitTestTree>;
|
||||
runExternalSchematic<SchematicSchemaT extends object>(collectionName: string, schematicName: string, opts?: SchematicSchemaT, tree?: Tree): Promise<UnitTestTree>;
|
||||
callRule(rule: Rule, tree: Tree, parentContext?: Partial<SchematicContext>): Observable<Tree>;
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
"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.SchematicTestRunner = exports.UnitTestTree = void 0;
|
||||
const core_1 = require("@angular-devkit/core");
|
||||
const rxjs_1 = require("rxjs");
|
||||
const src_1 = require("../src");
|
||||
const call_1 = require("../src/rules/call");
|
||||
const node_1 = require("../tasks/node");
|
||||
const tools_1 = require("../tools");
|
||||
class UnitTestTree extends src_1.DelegateTree {
|
||||
get files() {
|
||||
const result = [];
|
||||
this.visit((path) => result.push(path));
|
||||
return result;
|
||||
}
|
||||
readContent(path) {
|
||||
const buffer = this.read(path);
|
||||
if (buffer === null) {
|
||||
return '';
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
exports.UnitTestTree = UnitTestTree;
|
||||
class SchematicTestRunner {
|
||||
_collectionName;
|
||||
_engineHost;
|
||||
_engine;
|
||||
_collection;
|
||||
_logger;
|
||||
constructor(_collectionName, collectionPath) {
|
||||
this._collectionName = _collectionName;
|
||||
this._engineHost = new tools_1.NodeModulesTestEngineHost([
|
||||
// Leverage the specified collection path as an additional base for resolving other
|
||||
// collections by name. This is useful in e.g. pnpm workspaces where `@angular-devkit/schematics`
|
||||
// doesn't necessarily have access to e.g. `@schematics/angular`.
|
||||
collectionPath,
|
||||
]);
|
||||
this._engine = new src_1.SchematicEngine(this._engineHost);
|
||||
this._engineHost.registerCollection(_collectionName, collectionPath);
|
||||
this._logger = new core_1.logging.Logger('test');
|
||||
const registry = new core_1.schema.CoreSchemaRegistry(src_1.formats.standardFormats);
|
||||
registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
|
||||
this._engineHost.registerOptionsTransform((0, tools_1.validateOptionsWithSchema)(registry));
|
||||
this._engineHost.registerTaskExecutor(node_1.BuiltinTaskExecutor.NodePackage);
|
||||
this._engineHost.registerTaskExecutor(node_1.BuiltinTaskExecutor.RepositoryInitializer);
|
||||
this._engineHost.registerTaskExecutor(node_1.BuiltinTaskExecutor.RunSchematic);
|
||||
this._collection = this._engine.createCollection(this._collectionName);
|
||||
}
|
||||
get engine() {
|
||||
return this._engine;
|
||||
}
|
||||
get logger() {
|
||||
return this._logger;
|
||||
}
|
||||
get tasks() {
|
||||
return [...this._engineHost.tasks];
|
||||
}
|
||||
registerCollection(collectionName, collectionPath) {
|
||||
this._engineHost.registerCollection(collectionName, collectionPath);
|
||||
}
|
||||
async runSchematic(schematicName, opts, tree) {
|
||||
const schematic = this._collection.createSchematic(schematicName, true);
|
||||
const host = (0, rxjs_1.of)(tree || new src_1.HostTree());
|
||||
this._engineHost.clearTasks();
|
||||
const newTree = await (0, rxjs_1.lastValueFrom)(schematic.call(opts || {}, host, { logger: this._logger }));
|
||||
return new UnitTestTree(newTree);
|
||||
}
|
||||
async runExternalSchematic(collectionName, schematicName, opts, tree) {
|
||||
const externalCollection = this._engine.createCollection(collectionName);
|
||||
const schematic = externalCollection.createSchematic(schematicName, true);
|
||||
const host = (0, rxjs_1.of)(tree || new src_1.HostTree());
|
||||
this._engineHost.clearTasks();
|
||||
const newTree = await (0, rxjs_1.lastValueFrom)(schematic.call(opts || {}, host, { logger: this._logger }));
|
||||
return new UnitTestTree(newTree);
|
||||
}
|
||||
callRule(rule, tree, parentContext) {
|
||||
const context = this._engine.createContext({}, parentContext);
|
||||
return (0, call_1.callRule)(rule, (0, rxjs_1.of)(tree), context);
|
||||
}
|
||||
}
|
||||
exports.SchematicTestRunner = SchematicTestRunner;
|
||||
//# sourceMappingURL=schematic-test-runner.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schematic-test-runner.js","sourceRoot":"","sources":["schematic-test-runner.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+CAAuD;AACvD,+BAAqE;AACrE,gCAWgB;AAChB,4CAA6C;AAC7C,wCAAoD;AACpD,oCAAgF;AAEhF,MAAa,YAAa,SAAQ,kBAAY;IAC5C,IAAI,KAAK;QACP,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAExC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC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