From 291803c31f829fe0d32bb3207bc11def95a7408c Mon Sep 17 00:00:00 2001 From: Nevena Bojovic Date: Tue, 1 Mar 2022 20:05:50 +0100 Subject: Urađena test aplikacija. Povezan front i back. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schematics/src/sink/dryrun.d.ts | 50 +++++++++ .../@angular-devkit/schematics/src/sink/dryrun.js | 80 ++++++++++++++ .../@angular-devkit/schematics/src/sink/host.d.ts | 29 ++++++ .../@angular-devkit/schematics/src/sink/host.js | 76 ++++++++++++++ .../@angular-devkit/schematics/src/sink/sink.d.ts | 35 +++++++ .../@angular-devkit/schematics/src/sink/sink.js | 116 +++++++++++++++++++++ 6 files changed, 386 insertions(+) create mode 100644 sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/dryrun.d.ts create mode 100644 sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/dryrun.js create mode 100644 sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/host.d.ts create mode 100644 sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/host.js create mode 100644 sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/sink.d.ts create mode 100644 sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/sink.js (limited to 'sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink') diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/dryrun.d.ts b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/dryrun.d.ts new file mode 100644 index 00000000..bb7ab7d1 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/dryrun.d.ts @@ -0,0 +1,50 @@ +/** + * @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 { virtualFs } from '@angular-devkit/core'; +import { Observable, Subject } from 'rxjs'; +import { HostSink } from './host'; +export interface DryRunErrorEvent { + kind: 'error'; + description: 'alreadyExist' | 'doesNotExist'; + path: string; +} +export interface DryRunDeleteEvent { + kind: 'delete'; + path: string; +} +export interface DryRunCreateEvent { + kind: 'create'; + path: string; + content: Buffer; +} +export interface DryRunUpdateEvent { + kind: 'update'; + path: string; + content: Buffer; +} +export interface DryRunRenameEvent { + kind: 'rename'; + path: string; + to: string; +} +export declare type DryRunEvent = DryRunErrorEvent | DryRunDeleteEvent | DryRunCreateEvent | DryRunUpdateEvent | DryRunRenameEvent; +export declare class DryRunSink extends HostSink { + protected _subject: Subject; + protected _fileDoesNotExistExceptionSet: Set; + protected _fileAlreadyExistExceptionSet: Set; + readonly reporter: Observable; + /** + * @param {host} dir The host to use to output. This should be scoped. + * @param {boolean} force Whether to force overwriting files that already exist. + */ + constructor(host: virtualFs.Host, force?: boolean); + protected _fileAlreadyExistException(path: string): void; + protected _fileDoesNotExistException(path: string): void; + _done(): Observable; +} diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/dryrun.js b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/dryrun.js new file mode 100644 index 00000000..7ff91540 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/dryrun.js @@ -0,0 +1,80 @@ +"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.DryRunSink = void 0; +const core_1 = require("@angular-devkit/core"); +const node_1 = require("@angular-devkit/core/node"); +const rxjs_1 = require("rxjs"); +const host_1 = require("./host"); +class DryRunSink extends host_1.HostSink { + constructor(host, force = false) { + super(typeof host == 'string' + ? new core_1.virtualFs.ScopedHost(new node_1.NodeJsSyncHost(), (0, core_1.normalize)(host)) + : host, force); + this._subject = new rxjs_1.Subject(); + this._fileDoesNotExistExceptionSet = new Set(); + this._fileAlreadyExistExceptionSet = new Set(); + this.reporter = this._subject.asObservable(); + } + _fileAlreadyExistException(path) { + this._fileAlreadyExistExceptionSet.add(path); + } + _fileDoesNotExistException(path) { + this._fileDoesNotExistExceptionSet.add(path); + } + _done() { + this._fileAlreadyExistExceptionSet.forEach((path) => { + this._subject.next({ + kind: 'error', + description: 'alreadyExist', + path, + }); + }); + this._fileDoesNotExistExceptionSet.forEach((path) => { + this._subject.next({ + kind: 'error', + description: 'doesNotExist', + path, + }); + }); + this._filesToDelete.forEach((path) => { + // Check if this is a renaming. + for (const [from] of this._filesToRename) { + if (from == path) { + // The event is sent later on. + return; + } + } + this._subject.next({ kind: 'delete', path }); + }); + this._filesToRename.forEach(([path, to]) => { + this._subject.next({ kind: 'rename', path, to }); + }); + this._filesToCreate.forEach((content, path) => { + // Check if this is a renaming. + for (const [, to] of this._filesToRename) { + if (to == path) { + // The event is sent later on. + return; + } + } + if (this._fileAlreadyExistExceptionSet.has(path) || + this._fileDoesNotExistExceptionSet.has(path)) { + return; + } + this._subject.next({ kind: 'create', path, content: content.generate() }); + }); + this._filesToUpdate.forEach((content, path) => { + this._subject.next({ kind: 'update', path, content: content.generate() }); + }); + this._subject.complete(); + return (0, rxjs_1.of)(undefined); + } +} +exports.DryRunSink = DryRunSink; diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/host.d.ts b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/host.d.ts new file mode 100644 index 00000000..3f2934c4 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/host.d.ts @@ -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.io/license + */ +/// +import { Path, virtualFs } from '@angular-devkit/core'; +import { Observable } from 'rxjs'; +import { CreateFileAction } from '../tree/action'; +import { UpdateBufferBase } from '../utility/update-buffer'; +import { SimpleSinkBase } from './sink'; +export declare class HostSink extends SimpleSinkBase { + protected _host: virtualFs.Host; + protected _force: boolean; + protected _filesToDelete: Set; + protected _filesToRename: Set<[Path, Path]>; + protected _filesToCreate: Map; + protected _filesToUpdate: Map; + constructor(_host: virtualFs.Host, _force?: boolean); + protected _validateCreateAction(action: CreateFileAction): Observable; + protected _validateFileExists(p: Path): Observable; + protected _overwriteFile(path: Path, content: Buffer): Observable; + protected _createFile(path: Path, content: Buffer): Observable; + protected _renameFile(from: Path, to: Path): Observable; + protected _deleteFile(path: Path): Observable; + _done(): Observable; +} diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/host.js b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/host.js new file mode 100644 index 00000000..a5bb10b3 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/host.js @@ -0,0 +1,76 @@ +"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.HostSink = void 0; +const rxjs_1 = require("rxjs"); +const operators_1 = require("rxjs/operators"); +const update_buffer_1 = require("../utility/update-buffer"); +const sink_1 = require("./sink"); +class HostSink extends sink_1.SimpleSinkBase { + constructor(_host, _force = false) { + super(); + this._host = _host; + this._force = _force; + this._filesToDelete = new Set(); + this._filesToRename = new Set(); + this._filesToCreate = new Map(); + this._filesToUpdate = new Map(); + } + _validateCreateAction(action) { + return this._force ? rxjs_1.EMPTY : super._validateCreateAction(action); + } + _validateFileExists(p) { + if (this._filesToCreate.has(p) || this._filesToUpdate.has(p)) { + return (0, rxjs_1.of)(true); + } + if (this._filesToDelete.has(p)) { + return (0, rxjs_1.of)(false); + } + for (const [from, to] of this._filesToRename.values()) { + switch (p) { + case from: + return (0, rxjs_1.of)(false); + case to: + return (0, rxjs_1.of)(true); + } + } + return this._host.exists(p); + } + _overwriteFile(path, content) { + this._filesToUpdate.set(path, update_buffer_1.UpdateBufferBase.create(content)); + return rxjs_1.EMPTY; + } + _createFile(path, content) { + this._filesToCreate.set(path, update_buffer_1.UpdateBufferBase.create(content)); + return rxjs_1.EMPTY; + } + _renameFile(from, to) { + this._filesToRename.add([from, to]); + return rxjs_1.EMPTY; + } + _deleteFile(path) { + if (this._filesToCreate.has(path)) { + this._filesToCreate.delete(path); + this._filesToUpdate.delete(path); + } + else { + this._filesToDelete.add(path); + } + return rxjs_1.EMPTY; + } + _done() { + // Really commit everything to the actual filesystem. + return (0, rxjs_1.concat)((0, rxjs_1.from)([...this._filesToDelete.values()]).pipe((0, operators_1.concatMap)((path) => this._host.delete(path))), (0, rxjs_1.from)([...this._filesToRename.entries()]).pipe((0, operators_1.concatMap)(([_, [path, to]]) => this._host.rename(path, to))), (0, rxjs_1.from)([...this._filesToCreate.entries()]).pipe((0, operators_1.concatMap)(([path, buffer]) => { + return this._host.write(path, buffer.generate()); + })), (0, rxjs_1.from)([...this._filesToUpdate.entries()]).pipe((0, operators_1.concatMap)(([path, buffer]) => { + return this._host.write(path, buffer.generate()); + }))).pipe((0, operators_1.reduce)(() => { })); + } +} +exports.HostSink = HostSink; diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/sink.d.ts b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/sink.d.ts new file mode 100644 index 00000000..9e441f2a --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/sink.d.ts @@ -0,0 +1,35 @@ +/** + * @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 { Observable } from 'rxjs'; +import { Action, CreateFileAction, DeleteFileAction, OverwriteFileAction, RenameFileAction } from '../tree/action'; +import { Tree } from '../tree/interface'; +export interface Sink { + commit(tree: Tree): Observable; +} +export declare abstract class SimpleSinkBase implements Sink { + preCommitAction: (action: Action) => void | Action | PromiseLike | Observable; + postCommitAction: (action: Action) => void | Observable; + preCommit: () => void | Observable; + postCommit: () => void | Observable; + protected abstract _validateFileExists(p: string): Observable; + protected abstract _overwriteFile(path: string, content: Buffer): Observable; + protected abstract _createFile(path: string, content: Buffer): Observable; + protected abstract _renameFile(path: string, to: string): Observable; + protected abstract _deleteFile(path: string): Observable; + protected abstract _done(): Observable; + protected _fileAlreadyExistException(path: string): void; + protected _fileDoesNotExistException(path: string): void; + protected _validateOverwriteAction(action: OverwriteFileAction): Observable; + protected _validateCreateAction(action: CreateFileAction): Observable; + protected _validateRenameAction(action: RenameFileAction): Observable; + protected _validateDeleteAction(action: DeleteFileAction): Observable; + validateSingleAction(action: Action): Observable; + commitSingleAction(action: Action): Observable; + commit(tree: Tree): Observable; +} diff --git a/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/sink.js b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/sink.js new file mode 100644 index 00000000..80b42052 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@angular-devkit/schematics/src/sink/sink.js @@ -0,0 +1,116 @@ +"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.SimpleSinkBase = void 0; +const rxjs_1 = require("rxjs"); +const operators_1 = require("rxjs/operators"); +const exception_1 = require("../exception/exception"); +const action_1 = require("../tree/action"); +const Noop = function () { }; +class SimpleSinkBase { + constructor() { + this.preCommitAction = Noop; + this.postCommitAction = Noop; + this.preCommit = Noop; + this.postCommit = Noop; + } + _fileAlreadyExistException(path) { + throw new exception_1.FileAlreadyExistException(path); + } + _fileDoesNotExistException(path) { + throw new exception_1.FileDoesNotExistException(path); + } + _validateOverwriteAction(action) { + return this._validateFileExists(action.path).pipe((0, operators_1.map)((b) => { + if (!b) { + this._fileDoesNotExistException(action.path); + } + })); + } + _validateCreateAction(action) { + return this._validateFileExists(action.path).pipe((0, operators_1.map)((b) => { + if (b) { + this._fileAlreadyExistException(action.path); + } + })); + } + _validateRenameAction(action) { + return this._validateFileExists(action.path).pipe((0, operators_1.map)((b) => { + if (!b) { + this._fileDoesNotExistException(action.path); + } + }), (0, operators_1.mergeMap)(() => this._validateFileExists(action.to)), (0, operators_1.map)((b) => { + if (b) { + this._fileAlreadyExistException(action.to); + } + })); + } + _validateDeleteAction(action) { + return this._validateFileExists(action.path).pipe((0, operators_1.map)((b) => { + if (!b) { + this._fileDoesNotExistException(action.path); + } + })); + } + validateSingleAction(action) { + switch (action.kind) { + case 'o': + return this._validateOverwriteAction(action); + case 'c': + return this._validateCreateAction(action); + case 'r': + return this._validateRenameAction(action); + case 'd': + return this._validateDeleteAction(action); + default: + throw new action_1.UnknownActionException(action); + } + } + commitSingleAction(action) { + return (0, rxjs_1.concat)(this.validateSingleAction(action), new rxjs_1.Observable((observer) => { + let committed = null; + switch (action.kind) { + case 'o': + committed = this._overwriteFile(action.path, action.content); + break; + case 'c': + committed = this._createFile(action.path, action.content); + break; + case 'r': + committed = this._renameFile(action.path, action.to); + break; + case 'd': + committed = this._deleteFile(action.path); + break; + } + if (committed) { + committed.subscribe(observer); + } + else { + observer.complete(); + } + })).pipe((0, operators_1.ignoreElements)()); + } + commit(tree) { + const actions = (0, rxjs_1.from)(tree.actions); + return (0, rxjs_1.concat)(this.preCommit() || (0, rxjs_1.of)(null), (0, rxjs_1.defer)(() => actions).pipe((0, operators_1.concatMap)((action) => { + const maybeAction = this.preCommitAction(action); + if ((0, rxjs_1.isObservable)(maybeAction) || isPromiseLike(maybeAction)) { + return maybeAction; + } + return (0, rxjs_1.of)(maybeAction || action); + }), (0, operators_1.concatMap)((action) => { + return (0, rxjs_1.concat)(this.commitSingleAction(action).pipe((0, operators_1.ignoreElements)()), (0, rxjs_1.of)(action)); + }), (0, operators_1.concatMap)((action) => this.postCommitAction(action) || (0, rxjs_1.of)(null))), (0, rxjs_1.defer)(() => this._done()), (0, rxjs_1.defer)(() => this.postCommit() || (0, rxjs_1.of)(null))).pipe((0, operators_1.ignoreElements)()); + } +} +exports.SimpleSinkBase = SimpleSinkBase; +function isPromiseLike(value) { + return !!value && typeof value.then === 'function'; +} -- cgit v1.2.3