Conexio amb la api
This commit is contained in:
parent
207c0ba819
commit
b12369cb47
48513 changed files with 7391639 additions and 7 deletions
27
node_modules/@angular-devkit/architect/testing/BUILD.bazel
generated
vendored
Executable file
27
node_modules/@angular-devkit/architect/testing/BUILD.bazel
generated
vendored
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
# 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
|
||||
|
||||
load("//tools:defaults.bzl", "ts_library")
|
||||
|
||||
licenses(["notice"]) # MIT
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
ts_library(
|
||||
name = "testing",
|
||||
srcs = glob(
|
||||
include = ["**/*.ts"],
|
||||
exclude = ["**/*_spec.ts"],
|
||||
),
|
||||
module_name = "@angular-devkit/architect/testing",
|
||||
module_root = "index.d.ts",
|
||||
deps = [
|
||||
"//packages/angular_devkit/architect",
|
||||
"//packages/angular_devkit/core",
|
||||
"//packages/angular_devkit/core/node",
|
||||
"@npm//@types/node",
|
||||
"@npm//rxjs",
|
||||
],
|
||||
)
|
||||
9
node_modules/@angular-devkit/architect/testing/index.d.ts
generated
vendored
Executable file
9
node_modules/@angular-devkit/architect/testing/index.d.ts
generated
vendored
Executable 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.io/license
|
||||
*/
|
||||
export * from './testing-architect-host';
|
||||
export * from './test-project-host';
|
||||
21
node_modules/@angular-devkit/architect/testing/index.js
generated
vendored
Executable file
21
node_modules/@angular-devkit/architect/testing/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
"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.io/license
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (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("./testing-architect-host"), exports);
|
||||
__exportStar(require("./test-project-host"), exports);
|
||||
33
node_modules/@angular-devkit/architect/testing/test-project-host.d.ts
generated
vendored
Executable file
33
node_modules/@angular-devkit/architect/testing/test-project-host.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* @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
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { Path, PathFragment, virtualFs } from '@angular-devkit/core';
|
||||
import { NodeJsSyncHost } from '@angular-devkit/core/node';
|
||||
import { Stats } from 'fs';
|
||||
import { Observable } from 'rxjs';
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export declare class TestProjectHost extends NodeJsSyncHost {
|
||||
protected _templateRoot: Path;
|
||||
private _currentRoot;
|
||||
private _scopedSyncHost;
|
||||
constructor(_templateRoot: Path);
|
||||
root(): Path;
|
||||
scopedSync(): virtualFs.SyncDelegateHost<Stats>;
|
||||
initialize(): Observable<void>;
|
||||
restore(): Observable<void>;
|
||||
writeMultipleFiles(files: {
|
||||
[path: string]: string | ArrayBufferLike | Buffer;
|
||||
}): void;
|
||||
replaceInFile(path: string, match: RegExp | string, replacement: string): void;
|
||||
appendToFile(path: string, str: string): void;
|
||||
fileMatchExists(dir: string, regex: RegExp): PathFragment | undefined;
|
||||
copyFile(from: string, to: string): void;
|
||||
private findUniqueFolderPath;
|
||||
}
|
||||
109
node_modules/@angular-devkit/architect/testing/test-project-host.js
generated
vendored
Executable file
109
node_modules/@angular-devkit/architect/testing/test-project-host.js
generated
vendored
Executable file
|
|
@ -0,0 +1,109 @@
|
|||
"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.io/license
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TestProjectHost = void 0;
|
||||
const core_1 = require("@angular-devkit/core");
|
||||
const node_1 = require("@angular-devkit/core/node");
|
||||
const rxjs_1 = require("rxjs");
|
||||
const operators_1 = require("rxjs/operators");
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
class TestProjectHost extends node_1.NodeJsSyncHost {
|
||||
constructor(_templateRoot) {
|
||||
super();
|
||||
this._templateRoot = _templateRoot;
|
||||
this._currentRoot = null;
|
||||
this._scopedSyncHost = null;
|
||||
}
|
||||
root() {
|
||||
if (this._currentRoot === null) {
|
||||
throw new Error('TestProjectHost must be initialized before being used.');
|
||||
}
|
||||
return this._currentRoot;
|
||||
}
|
||||
scopedSync() {
|
||||
if (this._currentRoot === null || this._scopedSyncHost === null) {
|
||||
throw new Error('TestProjectHost must be initialized before being used.');
|
||||
}
|
||||
return this._scopedSyncHost;
|
||||
}
|
||||
initialize() {
|
||||
const recursiveList = (path) => this.list(path).pipe(
|
||||
// Emit each fragment individually.
|
||||
operators_1.concatMap((fragments) => rxjs_1.from(fragments)),
|
||||
// Join the path with fragment.
|
||||
operators_1.map((fragment) => core_1.join(path, fragment)),
|
||||
// Emit directory content paths instead of the directory path.
|
||||
operators_1.mergeMap((path) => this.isDirectory(path).pipe(operators_1.concatMap((isDir) => (isDir ? recursiveList(path) : rxjs_1.of(path))))));
|
||||
// Find a unique folder that we can write to to use as current root.
|
||||
return this.findUniqueFolderPath().pipe(
|
||||
// Save the path and create a scoped host for it.
|
||||
operators_1.tap((newFolderPath) => {
|
||||
this._currentRoot = newFolderPath;
|
||||
this._scopedSyncHost = new core_1.virtualFs.SyncDelegateHost(new core_1.virtualFs.ScopedHost(this, this.root()));
|
||||
}),
|
||||
// List all files in root.
|
||||
operators_1.concatMap(() => recursiveList(this._templateRoot)),
|
||||
// Copy them over to the current root.
|
||||
operators_1.concatMap((from) => {
|
||||
const to = core_1.join(this.root(), core_1.relative(this._templateRoot, from));
|
||||
return this.read(from).pipe(operators_1.concatMap((buffer) => this.write(to, buffer)));
|
||||
}), operators_1.map(() => { }));
|
||||
}
|
||||
restore() {
|
||||
if (this._currentRoot === null) {
|
||||
return rxjs_1.EMPTY;
|
||||
}
|
||||
// Delete the current root and clear the variables.
|
||||
// Wait 50ms and retry up to 10 times, to give time for file locks to clear.
|
||||
return this.exists(this.root()).pipe(operators_1.delay(50), operators_1.concatMap((exists) => (exists ? this.delete(this.root()) : rxjs_1.EMPTY)), operators_1.retry(10), operators_1.finalize(() => {
|
||||
this._currentRoot = null;
|
||||
this._scopedSyncHost = null;
|
||||
}));
|
||||
}
|
||||
writeMultipleFiles(files) {
|
||||
Object.keys(files).forEach((fileName) => {
|
||||
let content = files[fileName];
|
||||
if (typeof content == 'string') {
|
||||
content = core_1.virtualFs.stringToFileBuffer(content);
|
||||
}
|
||||
else if (content instanceof Buffer) {
|
||||
content = content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength);
|
||||
}
|
||||
this.scopedSync().write(core_1.normalize(fileName), content);
|
||||
});
|
||||
}
|
||||
replaceInFile(path, match, replacement) {
|
||||
const content = core_1.virtualFs.fileBufferToString(this.scopedSync().read(core_1.normalize(path)));
|
||||
this.scopedSync().write(core_1.normalize(path), core_1.virtualFs.stringToFileBuffer(content.replace(match, replacement)));
|
||||
}
|
||||
appendToFile(path, str) {
|
||||
const content = core_1.virtualFs.fileBufferToString(this.scopedSync().read(core_1.normalize(path)));
|
||||
this.scopedSync().write(core_1.normalize(path), core_1.virtualFs.stringToFileBuffer(content.concat(str)));
|
||||
}
|
||||
fileMatchExists(dir, regex) {
|
||||
const [fileName] = this.scopedSync()
|
||||
.list(core_1.normalize(dir))
|
||||
.filter((name) => name.match(regex));
|
||||
return fileName || undefined;
|
||||
}
|
||||
copyFile(from, to) {
|
||||
const content = this.scopedSync().read(core_1.normalize(from));
|
||||
this.scopedSync().write(core_1.normalize(to), content);
|
||||
}
|
||||
findUniqueFolderPath() {
|
||||
// 11 character alphanumeric string.
|
||||
const randomString = Math.random().toString(36).slice(2);
|
||||
const newFolderName = `test-project-host-${core_1.basename(this._templateRoot)}-${randomString}`;
|
||||
const newFolderPath = core_1.join(core_1.dirname(this._templateRoot), newFolderName);
|
||||
return this.exists(newFolderPath).pipe(operators_1.concatMap((exists) => (exists ? this.findUniqueFolderPath() : rxjs_1.of(newFolderPath))));
|
||||
}
|
||||
}
|
||||
exports.TestProjectHost = TestProjectHost;
|
||||
42
node_modules/@angular-devkit/architect/testing/testing-architect-host.d.ts
generated
vendored
Executable file
42
node_modules/@angular-devkit/architect/testing/testing-architect-host.d.ts
generated
vendored
Executable 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.io/license
|
||||
*/
|
||||
import { json } from '@angular-devkit/core';
|
||||
import { BuilderInfo, Target } from '../src';
|
||||
import { ArchitectHost, Builder } from '../src/internal';
|
||||
export declare class TestingArchitectHost implements ArchitectHost {
|
||||
workspaceRoot: string;
|
||||
currentDirectory: string;
|
||||
private _backendHost;
|
||||
private _builderImportMap;
|
||||
private _builderMap;
|
||||
private _targetMap;
|
||||
/**
|
||||
* Can provide a backend host, in case of integration tests.
|
||||
* @param workspaceRoot The workspace root to use.
|
||||
* @param currentDirectory The current directory to use.
|
||||
* @param _backendHost A host to defer calls that aren't resolved here.
|
||||
*/
|
||||
constructor(workspaceRoot?: string, currentDirectory?: string, _backendHost?: ArchitectHost | null);
|
||||
addBuilder(builderName: string, builder: Builder, description?: string, optionSchema?: json.schema.JsonSchema): void;
|
||||
addBuilderFromPackage(packageName: string): Promise<void>;
|
||||
addTarget(target: Target, builderName: string, options?: json.JsonObject): void;
|
||||
getBuilderNameForTarget(target: Target): Promise<string | null>;
|
||||
/**
|
||||
* Resolve a builder. This needs to return a string which will be used in a dynamic `import()`
|
||||
* clause. This should throw if no builder can be found. The dynamic import will throw if
|
||||
* it is unsupported.
|
||||
* @param builderName The name of the builder to be used.
|
||||
* @returns All the info needed for the builder itself.
|
||||
*/
|
||||
resolveBuilder(builderName: string): Promise<BuilderInfo | null>;
|
||||
getCurrentDirectory(): Promise<string>;
|
||||
getWorkspaceRoot(): Promise<string>;
|
||||
getOptionsForTarget(target: Target): Promise<json.JsonObject | null>;
|
||||
getProjectMetadata(target: Target | string): Promise<json.JsonObject | null>;
|
||||
loadBuilder(info: BuilderInfo): Promise<Builder | null>;
|
||||
}
|
||||
119
node_modules/@angular-devkit/architect/testing/testing-architect-host.js
generated
vendored
Executable file
119
node_modules/@angular-devkit/architect/testing/testing-architect-host.js
generated
vendored
Executable file
|
|
@ -0,0 +1,119 @@
|
|||
"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.io/license
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TestingArchitectHost = void 0;
|
||||
const src_1 = require("../src");
|
||||
class TestingArchitectHost {
|
||||
/**
|
||||
* Can provide a backend host, in case of integration tests.
|
||||
* @param workspaceRoot The workspace root to use.
|
||||
* @param currentDirectory The current directory to use.
|
||||
* @param _backendHost A host to defer calls that aren't resolved here.
|
||||
*/
|
||||
constructor(workspaceRoot = '', currentDirectory = workspaceRoot, _backendHost = null) {
|
||||
this.workspaceRoot = workspaceRoot;
|
||||
this.currentDirectory = currentDirectory;
|
||||
this._backendHost = _backendHost;
|
||||
this._builderImportMap = new Map();
|
||||
this._builderMap = new Map();
|
||||
this._targetMap = new Map();
|
||||
}
|
||||
addBuilder(builderName, builder, description = 'Testing only builder.', optionSchema = { type: 'object' }) {
|
||||
this._builderImportMap.set(builderName, builder);
|
||||
this._builderMap.set(builderName, { builderName, description, optionSchema });
|
||||
}
|
||||
async addBuilderFromPackage(packageName) {
|
||||
const packageJson = await Promise.resolve().then(() => __importStar(require(packageName + '/package.json')));
|
||||
if (!('builders' in packageJson)) {
|
||||
throw new Error('Invalid package.json, builders key not found.');
|
||||
}
|
||||
if (!packageJson.name) {
|
||||
throw new Error('Invalid package name');
|
||||
}
|
||||
const builderJsonPath = packageName + '/' + packageJson['builders'];
|
||||
const builderJson = await Promise.resolve().then(() => __importStar(require(builderJsonPath)));
|
||||
const builders = builderJson['builders'];
|
||||
if (!builders) {
|
||||
throw new Error('Invalid builders.json, builders key not found.');
|
||||
}
|
||||
for (const builderName of Object.keys(builders)) {
|
||||
const b = builders[builderName];
|
||||
// TODO: remove this check as v1 is not supported anymore.
|
||||
if (!b.implementation) {
|
||||
continue;
|
||||
}
|
||||
const handler = (await Promise.resolve().then(() => __importStar(require(builderJsonPath + '/../' + b.implementation)))).default;
|
||||
const optionsSchema = await Promise.resolve().then(() => __importStar(require(builderJsonPath + '/../' + b.schema)));
|
||||
this.addBuilder(`${packageJson.name}:${builderName}`, handler, b.description, optionsSchema);
|
||||
}
|
||||
}
|
||||
addTarget(target, builderName, options = {}) {
|
||||
this._targetMap.set(src_1.targetStringFromTarget(target), { builderName, options });
|
||||
}
|
||||
async getBuilderNameForTarget(target) {
|
||||
const name = src_1.targetStringFromTarget(target);
|
||||
const maybeTarget = this._targetMap.get(name);
|
||||
if (!maybeTarget) {
|
||||
return this._backendHost && this._backendHost.getBuilderNameForTarget(target);
|
||||
}
|
||||
return maybeTarget.builderName;
|
||||
}
|
||||
/**
|
||||
* Resolve a builder. This needs to return a string which will be used in a dynamic `import()`
|
||||
* clause. This should throw if no builder can be found. The dynamic import will throw if
|
||||
* it is unsupported.
|
||||
* @param builderName The name of the builder to be used.
|
||||
* @returns All the info needed for the builder itself.
|
||||
*/
|
||||
async resolveBuilder(builderName) {
|
||||
return (this._builderMap.get(builderName) ||
|
||||
(this._backendHost && this._backendHost.resolveBuilder(builderName)));
|
||||
}
|
||||
async getCurrentDirectory() {
|
||||
return this.currentDirectory;
|
||||
}
|
||||
async getWorkspaceRoot() {
|
||||
return this.workspaceRoot;
|
||||
}
|
||||
async getOptionsForTarget(target) {
|
||||
const name = src_1.targetStringFromTarget(target);
|
||||
const maybeTarget = this._targetMap.get(name);
|
||||
if (!maybeTarget) {
|
||||
return this._backendHost && this._backendHost.getOptionsForTarget(target);
|
||||
}
|
||||
return maybeTarget.options;
|
||||
}
|
||||
async getProjectMetadata(target) {
|
||||
return this._backendHost && this._backendHost.getProjectMetadata(target);
|
||||
}
|
||||
async loadBuilder(info) {
|
||||
return (this._builderImportMap.get(info.builderName) ||
|
||||
(this._backendHost && this._backendHost.loadBuilder(info)));
|
||||
}
|
||||
}
|
||||
exports.TestingArchitectHost = TestingArchitectHost;
|
||||
Loading…
Add table
Add a link
Reference in a new issue