diff options
author | Nevena Bojovic <nenabojov@gmail.com> | 2022-03-01 20:05:50 +0100 |
---|---|---|
committer | Nevena Bojovic <nenabojov@gmail.com> | 2022-03-01 20:05:50 +0100 |
commit | 291803c31f829fe0d32bb3207bc11def95a7408c (patch) | |
tree | c7d43107d79291b19d8c9eceefbe91c9f9a52acf /sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow | |
parent | 1fa69862057db4db53cfda5be9c24b4228ef63f7 (diff) |
Urađena test aplikacija. Povezan front i back.
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow')
6 files changed, 255 insertions, 0 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/base.d.ts b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/base.d.ts new file mode 100644 index 00000000..532f88e6 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/base.d.ts @@ -0,0 +1,51 @@ +/** + * @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 { schema, virtualFs } from '@angular-devkit/core'; +import { Observable, Subject } from 'rxjs'; +import { Engine, EngineHost } from '../engine'; +import { DryRunEvent } from '../sink/dryrun'; +import { Sink } from '../sink/sink'; +import { LifeCycleEvent, RequiredWorkflowExecutionContext, Workflow, WorkflowExecutionContext } from './interface'; +export interface BaseWorkflowOptions { + host: virtualFs.Host; + engineHost: EngineHost<{}, {}>; + registry?: schema.CoreSchemaRegistry; + force?: boolean; + dryRun?: boolean; +} +/** + * Base class for workflows. Even without abstract methods, this class should not be used without + * surrounding some initialization for the registry and host. This class only adds life cycle and + * dryrun/force support. You need to provide any registry and task executors that you need to + * support. + * See {@see NodeWorkflow} implementation for how to make a specialized subclass of this. + * TODO: add default set of CoreSchemaRegistry transforms. Once the job refactor is done, use that + * as the support for tasks. + * + * @public + */ +export declare abstract class BaseWorkflow implements Workflow { + protected _engine: Engine<{}, {}>; + protected _engineHost: EngineHost<{}, {}>; + protected _registry: schema.CoreSchemaRegistry; + protected _host: virtualFs.Host; + protected _reporter: Subject<DryRunEvent>; + protected _lifeCycle: Subject<LifeCycleEvent>; + protected _context: WorkflowExecutionContext[]; + protected _force: boolean; + protected _dryRun: boolean; + constructor(options: BaseWorkflowOptions); + get context(): Readonly<WorkflowExecutionContext>; + get engine(): Engine<{}, {}>; + get engineHost(): EngineHost<{}, {}>; + get registry(): schema.SchemaRegistry; + get reporter(): Observable<DryRunEvent>; + get lifeCycle(): Observable<LifeCycleEvent>; + protected _createSinks(): Sink[]; + execute(options: Partial<WorkflowExecutionContext> & RequiredWorkflowExecutionContext): Observable<void>; +} diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/base.js b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/base.js new file mode 100644 index 00000000..5847c0dc --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/base.js @@ -0,0 +1,138 @@ +"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.BaseWorkflow = void 0; +const core_1 = require("@angular-devkit/core"); +const rxjs_1 = require("rxjs"); +const operators_1 = require("rxjs/operators"); +const engine_1 = require("../engine"); +const exception_1 = require("../exception/exception"); +const formats_1 = require("../formats"); +const dryrun_1 = require("../sink/dryrun"); +const host_1 = require("../sink/host"); +const host_tree_1 = require("../tree/host-tree"); +/** + * Base class for workflows. Even without abstract methods, this class should not be used without + * surrounding some initialization for the registry and host. This class only adds life cycle and + * dryrun/force support. You need to provide any registry and task executors that you need to + * support. + * See {@see NodeWorkflow} implementation for how to make a specialized subclass of this. + * TODO: add default set of CoreSchemaRegistry transforms. Once the job refactor is done, use that + * as the support for tasks. + * + * @public + */ +class BaseWorkflow { + constructor(options) { + this._reporter = new rxjs_1.Subject(); + this._lifeCycle = new rxjs_1.Subject(); + this._host = options.host; + this._engineHost = options.engineHost; + if (options.registry) { + this._registry = options.registry; + } + else { + this._registry = new core_1.schema.CoreSchemaRegistry(formats_1.standardFormats); + this._registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults); + } + this._engine = new engine_1.SchematicEngine(this._engineHost, this); + this._context = []; + this._force = options.force || false; + this._dryRun = options.dryRun || false; + } + get context() { + const maybeContext = this._context[this._context.length - 1]; + if (!maybeContext) { + throw new Error('Cannot get context when workflow is not executing...'); + } + return maybeContext; + } + get engine() { + return this._engine; + } + get engineHost() { + return this._engineHost; + } + get registry() { + return this._registry; + } + get reporter() { + return this._reporter.asObservable(); + } + get lifeCycle() { + return this._lifeCycle.asObservable(); + } + _createSinks() { + let error = false; + const dryRunSink = new dryrun_1.DryRunSink(this._host, this._force); + const dryRunSubscriber = dryRunSink.reporter.subscribe((event) => { + this._reporter.next(event); + error = error || event.kind == 'error'; + }); + // We need two sinks if we want to output what will happen, and actually do the work. + return [ + dryRunSink, + // Add a custom sink that clean ourselves and throws an error if an error happened. + { + commit() { + dryRunSubscriber.unsubscribe(); + if (error) { + return (0, rxjs_1.throwError)(new exception_1.UnsuccessfulWorkflowExecution()); + } + return (0, rxjs_1.of)(); + }, + }, + // Only add a HostSink if this is not a dryRun. + ...(!this._dryRun ? [new host_1.HostSink(this._host, this._force)] : []), + ]; + } + execute(options) { + const parentContext = this._context[this._context.length - 1]; + if (!parentContext) { + this._lifeCycle.next({ kind: 'start' }); + } + /** Create the collection and the schematic. */ + const collection = this._engine.createCollection(options.collection); + // Only allow private schematics if called from the same collection. + const allowPrivate = options.allowPrivate || (parentContext && parentContext.collection === options.collection); + const schematic = collection.createSchematic(options.schematic, allowPrivate); + const sinks = this._createSinks(); + this._lifeCycle.next({ kind: 'workflow-start' }); + const context = { + ...options, + debug: options.debug || false, + logger: options.logger || (parentContext && parentContext.logger) || new core_1.logging.NullLogger(), + parentContext, + }; + this._context.push(context); + return schematic + .call(options.options, (0, rxjs_1.of)(new host_tree_1.HostTree(this._host)), { logger: context.logger }) + .pipe((0, operators_1.concatMap)((tree) => { + // Process all sinks. + return (0, rxjs_1.concat)((0, rxjs_1.from)(sinks).pipe((0, operators_1.concatMap)((sink) => sink.commit(tree)), (0, operators_1.ignoreElements)()), (0, rxjs_1.of)(tree)); + }), (0, operators_1.concatMap)(() => { + if (this._dryRun) { + return rxjs_1.EMPTY; + } + this._lifeCycle.next({ kind: 'post-tasks-start' }); + return this._engine + .executePostTasks() + .pipe((0, operators_1.tap)({ complete: () => this._lifeCycle.next({ kind: 'post-tasks-end' }) }), (0, operators_1.defaultIfEmpty)(), (0, operators_1.last)()); + }), (0, operators_1.tap)({ + complete: () => { + this._lifeCycle.next({ kind: 'workflow-end' }); + this._context.pop(); + if (this._context.length == 0) { + this._lifeCycle.next({ kind: 'end' }); + } + }, + })); + } +} +exports.BaseWorkflow = BaseWorkflow; diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/index.d.ts b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/index.d.ts new file mode 100644 index 00000000..3abed265 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/index.d.ts @@ -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 './base'; +export * from './interface'; diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/index.js b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/index.js new file mode 100644 index 00000000..5bb1e71d --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/index.js @@ -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("./base"), exports); +__exportStar(require("./interface"), exports); diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/interface.d.ts b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/interface.d.ts new file mode 100644 index 00000000..a1b71c37 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/interface.d.ts @@ -0,0 +1,27 @@ +/** + * @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 { logging } from '@angular-devkit/core'; +import { Observable } from 'rxjs'; +export interface RequiredWorkflowExecutionContext { + collection: string; + schematic: string; + options: object; +} +export interface WorkflowExecutionContext extends RequiredWorkflowExecutionContext { + debug: boolean; + logger: logging.Logger; + parentContext?: Readonly<WorkflowExecutionContext>; + allowPrivate?: boolean; +} +export interface LifeCycleEvent { + kind: 'start' | 'end' | 'workflow-start' | 'workflow-end' | 'post-tasks-start' | 'post-tasks-end'; +} +export interface Workflow { + readonly context: Readonly<WorkflowExecutionContext>; + execute(options: Partial<WorkflowExecutionContext> & RequiredWorkflowExecutionContext): Observable<void>; +} diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/interface.js b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/interface.js new file mode 100644 index 00000000..b599b96d --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/workflow/interface.js @@ -0,0 +1,9 @@ +"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 }); |