@angular-devkit/schematics 9.0.0-rc.6 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-devkit/schematics",
3
- "version": "9.0.0-rc.6",
3
+ "version": "9.0.0",
4
4
  "description": "Angular Schematics - Library",
5
5
  "main": "src/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "schematics"
19
19
  ],
20
20
  "dependencies": {
21
- "@angular-devkit/core": "9.0.0-rc.6",
21
+ "@angular-devkit/core": "9.0.0",
22
22
  "ora": "4.0.2",
23
23
  "rxjs": "6.5.3"
24
24
  },
@@ -29,7 +29,6 @@
29
29
  "engines": {
30
30
  "node": ">= 10.13.0",
31
31
  "npm": ">= 6.11.0",
32
- "pnpm": ">= 3.2.0",
33
32
  "yarn": ">= 1.13.0"
34
33
  },
35
34
  "author": "Angular Authors",
@@ -41,8 +41,8 @@ export declare class CollectionImpl<CollectionT extends object, SchematicT exten
41
41
  private _engine;
42
42
  readonly baseDescriptions?: CollectionDescription<CollectionT>[] | undefined;
43
43
  constructor(_description: CollectionDescription<CollectionT>, _engine: SchematicEngine<CollectionT, SchematicT>, baseDescriptions?: CollectionDescription<CollectionT>[] | undefined);
44
- readonly description: CollectionDescription<CollectionT>;
45
- readonly name: string;
44
+ get description(): CollectionDescription<CollectionT>;
45
+ get name(): string;
46
46
  createSchematic(name: string, allowPrivate?: boolean): Schematic<CollectionT, SchematicT>;
47
47
  listSchematicNames(): string[];
48
48
  }
@@ -64,8 +64,8 @@ export declare class SchematicEngine<CollectionT extends object, SchematicT exte
64
64
  private _schematicCache;
65
65
  private _taskSchedulers;
66
66
  constructor(_host: EngineHost<CollectionT, SchematicT>, _workflow?: Workflow | undefined);
67
- readonly workflow: Workflow | null;
68
- readonly defaultMergeStrategy: MergeStrategy;
67
+ get workflow(): Workflow | null;
68
+ get defaultMergeStrategy(): MergeStrategy;
69
69
  createCollection(name: string): Collection<CollectionT, SchematicT>;
70
70
  private _createCollectionDescription;
71
71
  createContext(schematic: Schematic<CollectionT, SchematicT>, parent?: Partial<TypedSchematicContext<CollectionT, SchematicT>>, executionOptions?: Partial<ExecutionOptions>): TypedSchematicContext<CollectionT, SchematicT>;
@@ -18,7 +18,7 @@ export declare class SchematicImpl<CollectionT extends object, SchematicT extend
18
18
  private _collection;
19
19
  private _engine;
20
20
  constructor(_description: SchematicDescription<CollectionT, SchematicT>, _factory: RuleFactory<{}>, _collection: Collection<CollectionT, SchematicT>, _engine: Engine<CollectionT, SchematicT>);
21
- readonly description: SchematicDescription<CollectionT, SchematicT>;
22
- readonly collection: Collection<CollectionT, SchematicT>;
21
+ get description(): SchematicDescription<CollectionT, SchematicT>;
22
+ get collection(): Collection<CollectionT, SchematicT>;
23
23
  call<OptionT extends object>(options: OptionT, host: Observable<Tree>, parentContext?: Partial<TypedSchematicContext<CollectionT, SchematicT>>, executionOptions?: Partial<ExecutionOptions>): Observable<Tree>;
24
24
  }
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  * found in the LICENSE file at https://angular.io/license
9
9
  */
10
10
  const core_1 = require("@angular-devkit/core");
11
+ const util_1 = require("util");
11
12
  const base_1 = require("./base");
12
13
  const rename_1 = require("./rename");
13
- const is_binary_1 = require("./utils/is-binary");
14
14
  exports.TEMPLATE_FILENAME_RE = /\.template$/;
15
15
  class OptionIsNotDefinedException extends core_1.BaseException {
16
16
  constructor(name) { super(`Option "${name}" is not defined.`); }
@@ -24,16 +24,23 @@ class InvalidPipeException extends core_1.BaseException {
24
24
  constructor(name) { super(`Pipe "${name}" is invalid.`); }
25
25
  }
26
26
  exports.InvalidPipeException = InvalidPipeException;
27
+ const decoder = new util_1.TextDecoder('utf-8', { fatal: true });
27
28
  function applyContentTemplate(options) {
28
29
  return (entry) => {
29
30
  const { path, content } = entry;
30
- if (is_binary_1.isBinary(content)) {
31
- return entry;
31
+ try {
32
+ const decodedContent = decoder.decode(content);
33
+ return {
34
+ path,
35
+ content: Buffer.from(core_1.template(decodedContent, {})(options)),
36
+ };
37
+ }
38
+ catch (e) {
39
+ if (e.code === 'ERR_ENCODING_INVALID_ENCODED_DATA') {
40
+ return entry;
41
+ }
42
+ throw e;
32
43
  }
33
- return {
34
- path: path,
35
- content: Buffer.from(core_1.template(content.toString('utf-8'), {})(options)),
36
- };
37
44
  };
38
45
  }
39
46
  exports.applyContentTemplate = applyContentTemplate;
@@ -29,7 +29,7 @@ export declare class ActionList implements Iterable<Action> {
29
29
  has(action: Action): boolean;
30
30
  find(predicate: (value: Action) => boolean): Action | null;
31
31
  forEach(fn: (value: Action, index: number, array: Action[]) => void, thisArg?: {}): void;
32
- readonly length: number;
32
+ get length(): number;
33
33
  [Symbol.iterator](): IterableIterator<Action>;
34
34
  }
35
35
  export declare function isContentAction(action: Action): action is CreateFileAction | OverwriteFileAction;
@@ -13,7 +13,7 @@ export declare class DelegateTree implements Tree {
13
13
  constructor(_other: Tree);
14
14
  branch(): Tree;
15
15
  merge(other: Tree, strategy?: MergeStrategy): void;
16
- readonly root: DirEntry;
16
+ get root(): DirEntry;
17
17
  read(path: string): Buffer | null;
18
18
  exists(path: string): boolean;
19
19
  get(path: string): FileEntry | null;
@@ -26,5 +26,5 @@ export declare class DelegateTree implements Tree {
26
26
  delete(path: string): void;
27
27
  rename(from: string, to: string): void;
28
28
  apply(action: Action, strategy?: MergeStrategy): void;
29
- readonly actions: Action[];
29
+ get actions(): Action[];
30
30
  }
@@ -12,14 +12,14 @@ export declare class SimpleFileEntry implements FileEntry {
12
12
  private _path;
13
13
  private _content;
14
14
  constructor(_path: Path, _content: Buffer);
15
- readonly path: Path;
16
- readonly content: Buffer;
15
+ get path(): Path;
16
+ get content(): Buffer;
17
17
  }
18
18
  export declare class LazyFileEntry implements FileEntry {
19
19
  private _path;
20
20
  private _load;
21
21
  private _content;
22
22
  constructor(_path: Path, _load: (path?: Path) => Buffer);
23
- readonly path: Path;
24
- readonly content: Buffer;
23
+ get path(): Path;
24
+ get content(): Buffer;
25
25
  }
@@ -15,8 +15,8 @@ export declare class HostDirEntry implements DirEntry {
15
15
  protected _host: virtualFs.SyncDelegateHost;
16
16
  protected _tree: Tree;
17
17
  constructor(parent: DirEntry | null, path: Path, _host: virtualFs.SyncDelegateHost, _tree: Tree);
18
- readonly subdirs: PathFragment[];
19
- readonly subfiles: PathFragment[];
18
+ get subdirs(): PathFragment[];
19
+ get subfiles(): PathFragment[];
20
20
  dir(name: PathFragment): DirEntry;
21
21
  file(name: PathFragment): FileEntry | null;
22
22
  visit(visitor: FileVisitor): void;
@@ -38,7 +38,7 @@ export declare class HostTree implements Tree {
38
38
  protected _willRename(path: Path): boolean;
39
39
  branch(): Tree;
40
40
  merge(other: Tree, strategy?: MergeStrategy): void;
41
- readonly root: DirEntry;
41
+ get root(): DirEntry;
42
42
  read(path: string): Buffer | null;
43
43
  exists(path: string): boolean;
44
44
  get(path: string): FileEntry | null;
@@ -51,7 +51,7 @@ export declare class HostTree implements Tree {
51
51
  delete(path: string): void;
52
52
  rename(from: string, to: string): void;
53
53
  apply(action: Action, strategy?: MergeStrategy): void;
54
- readonly actions: Action[];
54
+ get actions(): Action[];
55
55
  }
56
56
  export declare class HostCreateTree extends HostTree {
57
57
  constructor(host: virtualFs.ReadonlyHost);
@@ -14,7 +14,7 @@ export declare class CannotCreateFileException extends BaseException {
14
14
  }
15
15
  export declare class NullTreeDirEntry implements DirEntry {
16
16
  readonly path: Path;
17
- readonly parent: DirEntry | null;
17
+ get parent(): DirEntry | null;
18
18
  constructor(path: Path);
19
19
  readonly subdirs: PathFragment[];
20
20
  readonly subfiles: PathFragment[];
@@ -39,5 +39,5 @@ export declare class NullTree implements Tree {
39
39
  rename(path: string, _to: string): never;
40
40
  overwrite(path: string, _content: Buffer | string): never;
41
41
  apply(_action: Action, _strategy?: MergeStrategy): void;
42
- readonly actions: Action[];
42
+ get actions(): Action[];
43
43
  }
@@ -7,7 +7,7 @@ export declare class UpdateRecorderBase implements UpdateRecorder {
7
7
  protected _content: UpdateBuffer;
8
8
  constructor(entry: FileEntry);
9
9
  static createFromFileEntry(entry: FileEntry): UpdateRecorderBase;
10
- readonly path: string;
10
+ get path(): string;
11
11
  insertLeft(index: number, content: Buffer | string): UpdateRecorder;
12
12
  insertRight(index: number, content: Buffer | string): UpdateRecorder;
13
13
  remove(index: number, length: number): UpdateRecorder;
@@ -13,10 +13,10 @@ declare class ScopedDirEntry implements DirEntry {
13
13
  private _base;
14
14
  readonly scope: Path;
15
15
  constructor(_base: DirEntry, scope: Path);
16
- readonly parent: DirEntry | null;
17
- readonly path: Path;
18
- readonly subdirs: PathFragment[];
19
- readonly subfiles: PathFragment[];
16
+ get parent(): DirEntry | null;
17
+ get path(): Path;
18
+ get subdirs(): PathFragment[];
19
+ get subfiles(): PathFragment[];
20
20
  dir(name: PathFragment): DirEntry;
21
21
  file(name: PathFragment): FileEntry | null;
22
22
  visit(visitor: FileVisitor): void;
@@ -25,7 +25,7 @@ export declare class ScopedTree implements Tree {
25
25
  private _base;
26
26
  readonly _root: ScopedDirEntry;
27
27
  constructor(_base: Tree, scope: string);
28
- readonly root: DirEntry;
28
+ get root(): DirEntry;
29
29
  branch(): Tree;
30
30
  merge(other: Tree, strategy?: MergeStrategy): void;
31
31
  read(path: string): Buffer | null;
@@ -40,7 +40,7 @@ export declare class ScopedTree implements Tree {
40
40
  delete(path: string): void;
41
41
  rename(from: string, to: string): void;
42
42
  apply(action: Action, strategy?: MergeStrategy): void;
43
- readonly actions: Action[];
43
+ get actions(): Action[];
44
44
  private _fullPath;
45
45
  private _fullPathAction;
46
46
  }
@@ -11,8 +11,8 @@ export declare class LinkedList<T extends {
11
11
  private _head;
12
12
  constructor(_head: T);
13
13
  get(l: number): T | null;
14
- readonly head: T;
15
- readonly length: number;
14
+ get head(): T;
15
+ get length(): number;
16
16
  reduce<R>(accumulator: (acc: R, value: T, index?: number) => R, seed: R): R;
17
17
  find(predicate: (value: T, index?: number) => boolean): T | null;
18
18
  forEach(visitor: (value: T, index?: number) => void): void;
@@ -32,7 +32,7 @@ export declare class Chunk {
32
32
  private _assertRight;
33
33
  next: Chunk | null;
34
34
  constructor(start: number, end: number, originalContent: Buffer);
35
- readonly length: number;
35
+ get length(): number;
36
36
  toString(encoding?: string): string;
37
37
  slice(start: number): Chunk;
38
38
  append(buffer: Buffer, essential: boolean): void;
@@ -63,8 +63,8 @@ export declare class UpdateBuffer {
63
63
  * string functions.
64
64
  */
65
65
  protected _getTextPosition(index: number): number;
66
- readonly length: number;
67
- readonly original: Buffer;
66
+ get length(): number;
67
+ get original(): Buffer;
68
68
  toString(encoding?: string): string;
69
69
  generate(): Buffer;
70
70
  insertLeft(index: number, content: Buffer, assert?: boolean): void;
@@ -40,12 +40,12 @@ export declare abstract class BaseWorkflow implements Workflow {
40
40
  protected _force: boolean;
41
41
  protected _dryRun: boolean;
42
42
  constructor(options: BaseWorkflowOptions);
43
- readonly context: Readonly<WorkflowExecutionContext>;
44
- readonly engine: Engine<{}, {}>;
45
- readonly engineHost: EngineHost<{}, {}>;
46
- readonly registry: schema.SchemaRegistry;
47
- readonly reporter: Observable<DryRunEvent>;
48
- readonly lifeCycle: Observable<LifeCycleEvent>;
43
+ get context(): Readonly<WorkflowExecutionContext>;
44
+ get engine(): Engine<{}, {}>;
45
+ get engineHost(): EngineHost<{}, {}>;
46
+ get registry(): schema.SchemaRegistry;
47
+ get reporter(): Observable<DryRunEvent>;
48
+ get lifeCycle(): Observable<LifeCycleEvent>;
49
49
  protected _createSinks(): Sink[];
50
50
  execute(options: Partial<WorkflowExecutionContext> & RequiredWorkflowExecutionContext): Observable<void>;
51
51
  }
@@ -9,7 +9,7 @@ import { logging } from '@angular-devkit/core';
9
9
  import { Observable } from 'rxjs';
10
10
  import { DelegateTree, Rule, SchematicContext, SchematicEngine, TaskConfiguration, Tree } from '../src';
11
11
  export declare class UnitTestTree extends DelegateTree {
12
- readonly files: string[];
12
+ get files(): string[];
13
13
  readContent(path: string): string;
14
14
  }
15
15
  export declare class SchematicTestRunner {
@@ -19,9 +19,9 @@ export declare class SchematicTestRunner {
19
19
  private _collection;
20
20
  private _logger;
21
21
  constructor(_collectionName: string, collectionPath: string);
22
- readonly engine: SchematicEngine<{}, {}>;
23
- readonly logger: logging.Logger;
24
- readonly tasks: TaskConfiguration[];
22
+ get engine(): SchematicEngine<{}, {}>;
23
+ get logger(): logging.Logger;
24
+ get tasks(): TaskConfiguration[];
25
25
  registerCollection(collectionName: string, collectionPath: string): void;
26
26
  runSchematicAsync<SchematicSchemaT>(schematicName: string, opts?: SchematicSchemaT, tree?: Tree): Observable<UnitTestTree>;
27
27
  /**
@@ -3,7 +3,7 @@ export declare class ExportStringRef<T> {
3
3
  private _module;
4
4
  private _path;
5
5
  constructor(ref: string, parentPath?: string, inner?: boolean);
6
- readonly ref: T | undefined;
7
- readonly module: string;
8
- readonly path: string;
6
+ get ref(): T | undefined;
7
+ get module(): string;
8
+ get path(): string;
9
9
  }
@@ -15,7 +15,7 @@ import { NodeModulesEngineHost } from './node-module-engine-host';
15
15
  export declare class NodeModulesTestEngineHost extends NodeModulesEngineHost {
16
16
  private _collections;
17
17
  private _tasks;
18
- readonly tasks: TaskConfiguration<{}>[];
18
+ get tasks(): TaskConfiguration<{}>[];
19
19
  clearTasks(): void;
20
20
  registerCollection(name: string, path: string): void;
21
21
  transformContext(context: FileSystemSchematicContext): FileSystemSchematicContext;
@@ -7,8 +7,8 @@
7
7
  */
8
8
  import { schema } from '@angular-devkit/core';
9
9
  import { Observable } from 'rxjs';
10
- import { FileSystemSchematicDescription } from './description';
10
+ import { FileSystemSchematicContext, FileSystemSchematicDescription } from './description';
11
11
  export declare class InvalidInputOptions<T = {}> extends schema.SchemaValidationException {
12
12
  constructor(options: T, errors: schema.SchemaValidatorError[]);
13
13
  }
14
- export declare function validateOptionsWithSchema(registry: schema.SchemaRegistry): <T extends {}>(schematic: FileSystemSchematicDescription, options: T, context?: import("../src").TypedSchematicContext<import("./description").FileSystemCollectionDescription, FileSystemSchematicDescription> | undefined) => Observable<T>;
14
+ export declare function validateOptionsWithSchema(registry: schema.SchemaRegistry): <T extends {}>(schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext | undefined) => Observable<T>;
@@ -21,6 +21,6 @@ export declare class NodeWorkflow extends workflow.BaseWorkflow {
21
21
  registry?: schema.CoreSchemaRegistry;
22
22
  resolvePaths?: string[];
23
23
  });
24
- readonly engine: FileSystemEngine;
25
- readonly engineHost: NodeModulesEngineHost;
24
+ get engine(): FileSystemEngine;
25
+ get engineHost(): NodeModulesEngineHost;
26
26
  }
@@ -1,9 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- /// <reference types="node" />
9
- export declare function isBinary(buffer: Buffer): boolean;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google Inc. All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- function isBinary(buffer) {
11
- const chunkLength = 24;
12
- const chunkBegin = 0;
13
- const chunkEnd = Math.min(buffer.length, chunkBegin + chunkLength);
14
- const contentChunkUTF8 = buffer.toString('utf-8', chunkBegin, chunkEnd);
15
- // Detect encoding
16
- for (let i = 0; i < contentChunkUTF8.length; ++i) {
17
- const charCode = contentChunkUTF8.charCodeAt(i);
18
- if (charCode === 65533 || charCode <= 8) {
19
- // 8 and below are control characters (e.g. backspace, null, eof, etc.).
20
- // 65533 is the unknown character.
21
- return true;
22
- }
23
- }
24
- // Return
25
- return false;
26
- }
27
- exports.isBinary = isBinary;