Commit d1bb1ff9 authored by Tomislav Pree's avatar Tomislav Pree
Browse files

Merge branch 'debug' of https://gitlab.rlp.net/plmz/sturdy into debug

parents b322af67 d74169f9
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const src_1 = require("../src");
exports.default = src_1.createBuilder((options, context) => {
const allRuns = [];
context.reportProgress(0, (options.targets ? options.targets.length : 0)
+ (options.builders ? options.builders.length : 0));
if (options.targets) {
allRuns.push(...options.targets.map(({ target: targetStr, overrides }) => {
const [project, target, configuration] = targetStr.split(/:/g, 3);
return () => context.scheduleTarget({ project, target, configuration }, overrides || {});
}));
}
if (options.builders) {
allRuns.push(...options.builders.map(({ builder, options }) => {
return () => context.scheduleBuilder(builder, options || {});
}));
}
let stop = null;
let i = 0;
context.reportProgress(i++, allRuns.length);
return rxjs_1.from(allRuns).pipe(operators_1.concatMap(fn => stop ? rxjs_1.of(null) : rxjs_1.from(fn()).pipe(operators_1.switchMap(run => run === null ? rxjs_1.of(null) : run.output.pipe(operators_1.first())))), operators_1.map(output => {
context.reportProgress(i++, allRuns.length);
if (output === null || stop !== null) {
return stop || { success: false };
}
else if (output.success === false) {
return stop = output;
}
else {
return output;
}
}), operators_1.last());
});
declare const _default: import("../src/internal").Builder<import("../../core/src").JsonObject>;
export default _default;
"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 src_1 = require("../src");
exports.default = src_1.createBuilder(() => ({
success: false,
error: 'False builder always errors.',
}));
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
// tslint:disable:no-global-tslint-disable
// tslint:disable
{
"$schema": "http://json-schema.org/schema",
"type": "object"
}
\ No newline at end of file
/**
* All input types of builders that perform operations on one or multiple sub-builders.
*/
export interface Schema {
builders?: Builder[];
targets?: Target[];
}
export interface Builder {
builder: string;
options?: {
[key: string]: any;
};
}
export interface Target {
overrides?: {
[key: string]: any;
};
target: string;
}
"use strict";
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
Object.defineProperty(exports, "__esModule", { value: true });
{
"$schema": "http://json-schema.org/schema",
"description": "All input types of builders that perform operations on one or multiple sub-builders.",
"type": "object",
"properties": {
"builders": {
"type": "array",
"items": {
"type": "object",
"properties": {
"builder": {
"type": "string",
"pattern": ".*:.*"
},
"options": {
"type": "object"
}
},
"required": [
"builder"
]
},
"minItems": 1
},
"targets": {
"type": "array",
"items": {
"type": "object",
"properties": {
"target": {
"type": "string",
"pattern": ".*:.*"
},
"overrides": {
"type": "object"
}
},
"required": [
"target"
]
},
"minItems": 1
}
}
}
declare const _default: import("../src/internal").Builder<import("../../core/src").JsonObject>;
export default _default;
"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 src_1 = require("../src");
exports.default = src_1.createBuilder(() => ({ success: true }));
# 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
licenses(["notice"]) # MIT
package(default_visibility = ["//visibility:public"])
ts_library(
name = "node",
srcs = glob(
include = ["**/*.ts"],
exclude = ["**/*_spec.ts"],
),
module_name = "@angular-devkit/architect/node",
module_root = "index.d.ts",
# strict_checks = False,
deps = [
"//packages/angular_devkit/architect",
"//packages/angular_devkit/core",
"//packages/angular_devkit/core/node",
"@npm//@types/node",
"@npm//rxjs",
],
)
/**
* @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
*/
export * from './node-modules-architect-host';
"use strict";
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" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
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
*/
__exportStar(require("./node-modules-architect-host"), exports);
/**
* @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
*/
import { json, workspaces } from '@angular-devkit/core';
import { BuilderInfo } from '../src';
import { Target } from '../src/input-schema';
import { ArchitectHost, Builder } from '../src/internal';
export declare type NodeModulesBuilderInfo = BuilderInfo & {
import: string;
};
export declare class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModulesBuilderInfo> {
protected _workspace: workspaces.WorkspaceDefinition;
protected _root: string;
constructor(_workspace: workspaces.WorkspaceDefinition, _root: string);
getBuilderNameForTarget(target: Target): Promise<string>;
/**
* Resolve a builder. This needs to be 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 builderStr The name of the builder to be used.
* @returns All the info needed for the builder itself.
*/
resolveBuilder(builderStr: string): Promise<NodeModulesBuilderInfo>;
getCurrentDirectory(): Promise<string>;
getWorkspaceRoot(): Promise<string>;
getOptionsForTarget(target: Target): Promise<json.JsonObject | null>;
getProjectMetadata(target: Target | string): Promise<json.JsonObject | null>;
loadBuilder(info: NodeModulesBuilderInfo): Promise<Builder>;
private findProjectTarget;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WorkspaceNodeModulesArchitectHost = void 0;
const path = require("path");
const v8 = require("v8");
const internal_1 = require("../src/internal");
function clone(obj) {
const serialize = v8.serialize;
const deserialize = v8.deserialize;
try {
return deserialize(serialize(obj));
}
catch (_a) {
return JSON.parse(JSON.stringify(obj));
}
}
// TODO: create a base class for all workspace related hosts.
class WorkspaceNodeModulesArchitectHost {
constructor(_workspace, _root) {
this._workspace = _workspace;
this._root = _root;
}
async getBuilderNameForTarget(target) {
const targetDefinition = this.findProjectTarget(target);
if (!targetDefinition) {
throw new Error('Project target does not exist.');
}
return targetDefinition.builder;
}
/**
* Resolve a builder. This needs to be 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 builderStr The name of the builder to be used.
* @returns All the info needed for the builder itself.
*/
resolveBuilder(builderStr) {
const [packageName, builderName] = builderStr.split(':', 2);
if (!builderName) {
throw new Error('No builder name specified.');
}
const packageJsonPath = require.resolve(packageName + '/package.json', {
paths: [this._root],
});
const packageJson = require(packageJsonPath);
if (!packageJson['builders']) {
throw new Error(`Package ${JSON.stringify(packageName)} has no builders defined.`);
}
const builderJsonPath = path.resolve(path.dirname(packageJsonPath), packageJson['builders']);
const builderJson = require(builderJsonPath);
const builder = builderJson.builders && builderJson.builders[builderName];
if (!builder) {
throw new Error(`Cannot find builder ${JSON.stringify(builderStr)}.`);
}
const importPath = builder.implementation;
if (!importPath) {
throw new Error('Could not find the implementation for builder ' + builderStr);
}
return Promise.resolve({
name: builderStr,
builderName,
description: builder['description'],
optionSchema: require(path.resolve(path.dirname(builderJsonPath), builder.schema)),
import: path.resolve(path.dirname(builderJsonPath), importPath),
});
}
async getCurrentDirectory() {
return process.cwd();
}
async getWorkspaceRoot() {
return this._root;
}
async getOptionsForTarget(target) {
const targetSpec = this.findProjectTarget(target);
if (targetSpec === undefined) {
return null;
}
let additionalOptions = {};
if (target.configuration) {
const configurations = target.configuration.split(',').map(c => c.trim());
for (const configuration of configurations) {
if (!(targetSpec['configurations'] && targetSpec['configurations'][configuration])) {
throw new Error(`Configuration '${configuration}' is not set in the workspace.`);
}
else {
additionalOptions = {
...additionalOptions,
...targetSpec['configurations'][configuration],
};
}
}
}
const options = {
...targetSpec['options'],
...additionalOptions,
};
return clone(options);
}
async getProjectMetadata(target) {
const projectName = typeof target === 'string' ? target : target.project;
const projectDefinition = this._workspace.projects.get(projectName);
if (!projectDefinition) {
throw new Error('Project does not exist.');
}
const metadata = {
root: projectDefinition.root,
sourceRoot: projectDefinition.sourceRoot,
prefix: projectDefinition.prefix,
...clone(projectDefinition.extensions),
};
return metadata;
}
async loadBuilder(info) {
const builder = (await Promise.resolve().then(() => require(info.import))).default;
if (builder[internal_1.BuilderSymbol]) {
return builder;
}
throw new Error('Builder is not a builder');
}
findProjectTarget(target) {
const projectDefinition = this._workspace.projects.get(target.project);
if (!projectDefinition) {
throw new Error('Project does not exist.');
}
return projectDefinition.targets.get(target.target);
}
}
exports.WorkspaceNodeModulesArchitectHost = WorkspaceNodeModulesArchitectHost;
{
"_args": [
[
"@angular-devkit/architect@0.1000.1",
"/home/tomislav/Documents/sturdy/scheme/src/Debug/client"
]
],
"_development": true,
"_from": "@angular-devkit/architect@0.1000.1",
"_id": "@angular-devkit/architect@0.1000.1",
"_inBundle": false,
"_integrity": "sha512-GpoJ+p38feerxwfpJgrjwv/2c47qIX+TMdfKVqbswxLnzK21hXjd0zn6UfovAFwLeL1hRu2O00NDsmQn01gdoA==",
"_location": "/@angular-devkit/architect",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@angular-devkit/architect@0.1000.1",
"name": "@angular-devkit/architect",
"escapedName": "@angular-devkit%2farchitect",
"scope": "@angular-devkit",
"rawSpec": "0.1000.1",
"saveSpec": null,
"fetchSpec": "0.1000.1"
},
"_requiredBy": [
"/@angular-devkit/build-angular",
"/@angular-devkit/build-webpack",
"/@angular/cli"
],
"_resolved": "https://registry.npmjs.org/@angular-devkit/architect/-/architect-0.1000.1.tgz",
"_spec": "0.1000.1",
"_where": "/home/tomislav/Documents/sturdy/scheme/src/Debug/client",
"author": {
"name": "Angular Authors"
},
"bugs": {
"url": "https://github.com/angular/angular-cli/issues"
},
"builders": "./builders/builders.json",
"dependencies": {
"@angular-devkit/core": "10.0.1",
"rxjs": "6.5.5"
},
"description": "Angular Build Facade",
"engines": {
"node": ">= 10.13.0",
"npm": ">= 6.11.0",
"yarn": ">= 1.13.0"
},
"experimental": true,
"homepage": "https://github.com/angular/angular-cli",
"husky": {
"hooks": {
"pre-push": "node ./bin/devkit-admin hooks/pre-push"
}
},
"keywords": [
"angular",
"Angular CLI",
"devkit",
"sdk",
"Angular DevKit"
],
"license": "MIT",
"main": "src/index.js",
"name": "@angular-devkit/architect",
"repository": {
"type": "git",
"url": "git+https://github.com/angular/angular-cli.git"
},
"typings": "src/index.d.ts",
"version": "0.1000.1"
}
/**
* @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
*/
import { analytics, experimental, json, logging } from '@angular-devkit/core';
import { Observable, SubscribableOrPromise } from 'rxjs';
import { Schema as RealBuilderInput, Target as RealTarget } from './input-schema';
import { Schema as RealBuilderOutput } from './output-schema';
import { Schema as RealBuilderProgress, State as BuilderProgressState } from './progress-schema';
export declare type Target = json.JsonObject & RealTarget;
export { BuilderProgressState, };
export declare type BuilderRegistry = experimental.jobs.Registry<json.JsonObject, BuilderInput, BuilderOutput>;
/**
* An API typed BuilderProgress. The interface generated from the schema is too permissive,
* so this API is the one we show in our API. Please note that not all fields are in there; this
* is in addition to fields in the schema.
*/
export declare type TypedBuilderProgress = ({
state: BuilderProgressState.Stopped;
} | {
state: BuilderProgressState.Error;
error: json.JsonValue;
} | {
state: BuilderProgressState.Waiting;
status?: string;
} | {
state: BuilderProgressState.Running;
status?: string;
current: number;
total?: number;
});
/**
* Declaration of those types as JsonObject compatible. JsonObject is not compatible with
* optional members, so those wouldn't be directly assignable to our internal Json typings.
* Forcing the type to be both a JsonObject and the type from the Schema tells Typescript they
* are compatible (which they are).
* These types should be used everywhere.
*/
export declare type BuilderInput = json.JsonObject & RealBuilderInput;
export declare type BuilderOutput = json.JsonObject & RealBuilderOutput;
export declare type BuilderProgress = json.JsonObject & RealBuilderProgress & TypedBuilderProgress;
/**
* A progress report is what the tooling will receive. It contains the builder info and the target.
* Although these are serializable, they are only exposed through the tooling interface, not the
* builder interface. The watch dog sends BuilderProgress and the Builder has a set of functions
* to manage the state.
*/
export declare type BuilderProgressReport = BuilderProgress & ({
target?: Target;
builder: BuilderInfo;
});
/**
* A Run, which is what is returned by scheduleBuilder or scheduleTarget functions. This should
* be reconstructed across memory boundaries (it's not serializable but all internal information
* are).
*/
export interface BuilderRun {
/**
* Unique amongst runs. This is the same ID as the context generated for the run. It can be
* used to identify multiple unique runs. There is no guarantee that a run is a single output;
* a builder can rebuild on its own and will generate multiple outputs.
*/
id: number;
/**
* The builder information.
*/
info: BuilderInfo;
/**
* The next output from a builder. This is recommended when scheduling a builder and only being
* interested in the result of that single run, not of a watch-mode builder.
*/
result: Promise<BuilderOutput>;
/**
* The output(s) from the builder. A builder can have multiple outputs.
* This always replay the last output when subscribed.
*/
output: Observable<BuilderOutput>;
/**
* The progress report. A progress also contains an ID, which can be different than this run's
* ID (if the builder calls scheduleBuilder or scheduleTarget).
* This will always replay the last progress on new subscriptions.
*/
progress: Observable<BuilderProgressReport>;
/**
* Stop the builder from running. Returns a promise that resolves when the builder is stopped.