From d13ace8bfd9e2e0be16775c4e038a7a8bef438fc Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 1 Nov 2018 08:46:52 +0100 Subject: [PATCH 01/11] refactor: fix `import` and `export` paths to work with classic resolution `ts-api-guardian` only support classic module resolution which means that we need to specify `index` so that the resolution works. --- packages/angular_devkit/core/src/experimental.ts | 2 +- packages/angular_devkit/core/src/index.ts | 12 ++++++------ packages/angular_devkit/core/src/json/index.ts | 2 +- packages/angular_devkit/core/src/json/parser.ts | 2 +- packages/angular_devkit/core/src/virtual-fs/index.ts | 2 +- packages/angular_devkit/schematics/src/index.ts | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/angular_devkit/core/src/experimental.ts b/packages/angular_devkit/core/src/experimental.ts index 9e2f0199cf67..5e3dcf689ed7 100644 --- a/packages/angular_devkit/core/src/experimental.ts +++ b/packages/angular_devkit/core/src/experimental.ts @@ -5,6 +5,6 @@ * 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 * as workspace from './workspace'; +import * as workspace from './workspace/index'; export { workspace }; diff --git a/packages/angular_devkit/core/src/index.ts b/packages/angular_devkit/core/src/index.ts index 874421822d83..e292e8e9ff42 100644 --- a/packages/angular_devkit/core/src/index.ts +++ b/packages/angular_devkit/core/src/index.ts @@ -6,14 +6,14 @@ * found in the LICENSE file at https://angular.io/license */ import * as experimental from './experimental'; -import * as json from './json'; -import * as logging from './logger'; -import * as terminal from './terminal'; +import * as json from './json/index'; +import * as logging from './logger/index'; +import * as terminal from './terminal/index'; export * from './exception/exception'; -export * from './json'; -export * from './utils'; -export * from './virtual-fs'; +export * from './json/index'; +export * from './utils/index'; +export * from './virtual-fs/index'; export { experimental, diff --git a/packages/angular_devkit/core/src/json/index.ts b/packages/angular_devkit/core/src/json/index.ts index 4109871211e3..16bc0d1ff55c 100644 --- a/packages/angular_devkit/core/src/json/index.ts +++ b/packages/angular_devkit/core/src/json/index.ts @@ -8,5 +8,5 @@ export * from './interface'; export * from './parser'; -import * as schema from './schema'; +import * as schema from './schema/index'; export { schema }; diff --git a/packages/angular_devkit/core/src/json/parser.ts b/packages/angular_devkit/core/src/json/parser.ts index b89b6ccc92dd..cdf83e20771d 100644 --- a/packages/angular_devkit/core/src/json/parser.ts +++ b/packages/angular_devkit/core/src/json/parser.ts @@ -864,7 +864,7 @@ export function parseJsonAst(input: string, mode = JsonParseMode.Default): JsonA /** * Options for the parseJson() function. */ -interface ParseJsonOptions { +export interface ParseJsonOptions { /** * If omitted, will only emit errors related to the content of the JSON. If specified, any * JSON errors will also include the path of the file that caused the error. diff --git a/packages/angular_devkit/core/src/virtual-fs/index.ts b/packages/angular_devkit/core/src/virtual-fs/index.ts index ab9ccf25fcd1..988c3b40d449 100644 --- a/packages/angular_devkit/core/src/virtual-fs/index.ts +++ b/packages/angular_devkit/core/src/virtual-fs/index.ts @@ -7,5 +7,5 @@ */ export * from './path'; -import * as virtualFs from './host'; +import * as virtualFs from './host/index'; export { virtualFs }; diff --git a/packages/angular_devkit/schematics/src/index.ts b/packages/angular_devkit/schematics/src/index.ts index 31333a014f09..52c8b314e8eb 100644 --- a/packages/angular_devkit/schematics/src/index.ts +++ b/packages/angular_devkit/schematics/src/index.ts @@ -12,7 +12,7 @@ import { branch, empty, merge, optimize, partition } from './tree/static'; export { SchematicsException } from './exception/exception'; export * from './tree/action'; -export * from './engine'; +export * from './engine/index'; export * from './exception/exception'; export * from './tree/interface'; export * from './rules/base'; @@ -34,10 +34,10 @@ export * from './sink/filesystem'; export * from './sink/host'; export * from './sink/sink'; -import * as formats from './formats'; +import * as formats from './formats/index'; export { formats }; -import * as workflow from './workflow'; +import * as workflow from './workflow/index'; export { workflow }; export interface TreeConstructor { From 6cca037cd1a9c989885a6bfc2991d691cd0f9b03 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 1 Nov 2018 08:47:10 +0100 Subject: [PATCH 02/11] build: add `npm_package` to packages --- packages/angular_devkit/architect/BUILD | 31 +++++++++++++++++++ packages/angular_devkit/benchmark/BUILD | 9 +++++- packages/angular_devkit/build_optimizer/BUILD | 9 +++++- packages/angular_devkit/core/BUILD | 11 ++++++- packages/angular_devkit/schematics/BUILD | 12 ++++++- 5 files changed, 68 insertions(+), 4 deletions(-) diff --git a/packages/angular_devkit/architect/BUILD b/packages/angular_devkit/architect/BUILD index 64928bd9c268..49dc46ed8807 100644 --- a/packages/angular_devkit/architect/BUILD +++ b/packages/angular_devkit/architect/BUILD @@ -6,6 +6,7 @@ licenses(["notice"]) # MIT load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") +load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package") package(default_visibility = ["//visibility:public"]) @@ -30,3 +31,33 @@ ts_library( "@npm//@types/node", ], ) + +ts_library( + name = "testing", + srcs = glob( + include = ["testing/**/*.ts"], + exclude = [ + "**/*_spec.ts", + "**/*_spec_large.ts", + ], + ), + module_name = "@angular-devkit/architect/testing", + module_root = "testing/index.d.ts", + deps = [ + ":architect", + "//packages/angular_devkit/core", + "//packages/angular_devkit/core:node", + "@rxjs", + "@rxjs//operators", + "@npm//@types/node", + ], +) + + +npm_package( + name = "npm_package", + deps = [ + ":architect", + ":testing" + ], +) diff --git a/packages/angular_devkit/benchmark/BUILD b/packages/angular_devkit/benchmark/BUILD index cf7fb65dd27b..06b7c3028362 100644 --- a/packages/angular_devkit/benchmark/BUILD +++ b/packages/angular_devkit/benchmark/BUILD @@ -6,7 +6,7 @@ licenses(["notice"]) # MIT load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") -load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test") +load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test", "npm_package") package(default_visibility = ["//visibility:public"]) @@ -73,3 +73,10 @@ jasmine_node_test( "@npm//temp", ], ) + +npm_package( + name = "npm_package", + deps = [ + ":benchmark", + ], +) diff --git a/packages/angular_devkit/build_optimizer/BUILD b/packages/angular_devkit/build_optimizer/BUILD index 84c0a9383635..9a38a79b4376 100644 --- a/packages/angular_devkit/build_optimizer/BUILD +++ b/packages/angular_devkit/build_optimizer/BUILD @@ -6,7 +6,7 @@ licenses(["notice"]) # MIT load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") -load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test") +load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test", "npm_package") package(default_visibility = ["//visibility:public"]) @@ -58,5 +58,12 @@ jasmine_node_test( deps = [ "@npm//jasmine", "@npm//source-map", + ] +) + +npm_package( + name = "npm_package", + deps = [ + ":build_optimizer", ], ) diff --git a/packages/angular_devkit/core/BUILD b/packages/angular_devkit/core/BUILD index 0ef5a3aea99d..39faa08980ec 100644 --- a/packages/angular_devkit/core/BUILD +++ b/packages/angular_devkit/core/BUILD @@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"]) load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") -load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test") +load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test", "npm_package") licenses(["notice"]) # MIT License @@ -157,3 +157,12 @@ ts_library( "@npm//@types/jasmine", ], ) + +npm_package( + name = "npm_package", + deps = [ + ":core", + ":node", + ":node_testing", + ], +) diff --git a/packages/angular_devkit/schematics/BUILD b/packages/angular_devkit/schematics/BUILD index f69847984252..46fd94b6ae28 100644 --- a/packages/angular_devkit/schematics/BUILD +++ b/packages/angular_devkit/schematics/BUILD @@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"]) load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") -load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test") +load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test", "npm_package") licenses(["notice"]) # MIT License @@ -250,3 +250,13 @@ ts_library( "@npm//@types/node", ], ) + +npm_package( + name = "npm_package", + deps = [ + ":schematics", + ":tasks", + ":tools", + ":testing" + ], +) From 72c770ab4ab28523d850bd35c8a10d719cb4a398 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 1 Nov 2018 08:47:29 +0100 Subject: [PATCH 03/11] build: add ts-api-guardian to repo --- .circleci/config.yml | 2 +- WORKSPACE | 23 +++++++++++++++-- etc/api/BUILD | 59 ++++++++++++++++++++++++++++++++++++++++++++ tsconfig.json | 1 + 4 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 etc/api/BUILD diff --git a/.circleci/config.yml b/.circleci/config.yml index ad4b1b8f30bd..98faf1532252 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -126,7 +126,7 @@ jobs: steps: - attach_workspace: *attach_options - run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc - - run: bazel test //packages/... + - run: bazel test ... snapshot_publish: <<: *defaults diff --git a/WORKSPACE b/WORKSPACE index 275af432ac1d..acab0f554a47 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,5 +1,13 @@ workspace(name = "angular_cli") +# This is required by Angular Workspace +http_archive( + name = "bazel_skylib", + url = "https://github.com/bazelbuild/bazel-skylib/archive/0.5.0.zip", + strip_prefix = "bazel-skylib-0.5.0", + sha256 = "ca4e3b8e4da9266c3a9101c8f4704fe2e20eb5625b2a6a7d2d7d45e3dd4efffd", +) + # We get Buildifier from here. http_archive( name = "com_github_bazelbuild_buildtools", @@ -11,8 +19,8 @@ http_archive( # Load the TypeScript rules, its dependencies, and setup the workspace. http_archive( name = "build_bazel_rules_typescript", - url = "https://github.com/bazelbuild/rules_typescript/archive/0.20.3.zip", - strip_prefix = "rules_typescript-0.20.3", + url = "https://github.com/bazelbuild/rules_typescript/archive/8ea1a55cf5cf8be84ddfeefc0940769b80da792f.zip", + strip_prefix = "rules_typescript-8ea1a55cf5cf8be84ddfeefc0940769b80da792f", ) load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies") @@ -26,6 +34,17 @@ load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_depen go_rules_dependencies() go_register_toolchains() +# TS API Guardian resides in Angular +http_archive( + name = "angular", + url = "https://github.com/angular/angular/archive/e026a2792a6a7ae7f51f4008c3e8e994ec4f0200.zip", + strip_prefix = "angular-e026a2792a6a7ae7f51f4008c3e8e994ec4f0200", + sha256 = "f9426a9e32b82ac30158632053a23bb15fc309dd2c78bf98872b735961117391", +) + +load("@angular//:index.bzl", "ng_setup_workspace") +ng_setup_workspace() + load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace") ts_setup_workspace() diff --git a/etc/api/BUILD b/etc/api/BUILD new file mode 100644 index 000000000000..9c11dca0eabb --- /dev/null +++ b/etc/api/BUILD @@ -0,0 +1,59 @@ +load("@angular//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test") + +[ts_api_guardian_test( + name = "%s_%s_%sapi" % ( + bundle[0], + bundle[1], + bundle[2].replace("src/", "").replace("index", "").replace("/", "_"), + ), + actual = "angular_cli/packages/%s/%s/npm_package/%s.d.ts" % ( + bundle[0], + bundle[1], + bundle[2], + ), + data = glob([ + "%s/%s/**/*.d.ts" % ( + bundle[0], + bundle[1], + ), + ]) + [ + "//packages/%s/%s:npm_package" % ( + bundle[0], + bundle[1], + ), + ], + golden = "angular_cli/etc/api/%s/%s/%s.d.ts" % ( + bundle[0], + bundle[1], + bundle[2], + ), + # We don't want to analyse these exports nor add them to the golden files + # in most cases it's because Ts API Guardian doesn't support Symbol Aliases. + strip_export_pattern = [ + # @angular-devkit/core + "^json$", + "^schema$", + "^experimental$", + "^logging$", + "^strings$", + "^tags$", + "^virtualFs$", + "^terminal$", + "^fs$", + # @angular-devkit/schematics + "^workflow$", + "^engine$", + "^formats$", + # @angular-devkit/build-optimizer + "^buildOptimizerLoader$", + ], + allow_module_identifiers = [ + "fs", + "ts", + "Symbol", + ], + # At the moment using this will ignore a big change + use_angular_tag_rules = False, +) for bundle in [b[:-len(".d.ts")].split("/", 2) for b in glob( + ["**/*.d.ts"], +)]] diff --git a/tsconfig.json b/tsconfig.json index 33867eb4ba63..1b04987d77f1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -72,5 +72,6 @@ "tests/**/*", "tools/**/*", "benchmark/**/*", + "etc/api/**/*" ] } From 1dc4bb9a330c8a63942c4781bc21e01357b527d9 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Sat, 3 Nov 2018 07:56:39 +0100 Subject: [PATCH 04/11] test: add api golden files --- .../angular_devkit/architect/src/index.d.ts | 102 +++ .../architect/testing/index.d.ts | 28 + .../angular_devkit/benchmark/src/index.d.ts | 91 +++ .../build_optimizer/src/index.d.ts | 21 + etc/api/angular_devkit/core/node/index.d.ts | 52 ++ .../core/node/testing/index.d.ts | 8 + etc/api/angular_devkit/core/src/index.d.ts | 344 ++++++++++ .../angular_devkit/schematics/src/index.d.ts | 645 ++++++++++++++++++ .../schematics/tasks/index.d.ts | 42 ++ .../schematics/testing/index.d.ts | 16 + .../schematics/tools/index.d.ts | 150 ++++ 11 files changed, 1499 insertions(+) create mode 100644 etc/api/angular_devkit/architect/src/index.d.ts create mode 100644 etc/api/angular_devkit/architect/testing/index.d.ts create mode 100644 etc/api/angular_devkit/benchmark/src/index.d.ts create mode 100644 etc/api/angular_devkit/build_optimizer/src/index.d.ts create mode 100644 etc/api/angular_devkit/core/node/index.d.ts create mode 100644 etc/api/angular_devkit/core/node/testing/index.d.ts create mode 100644 etc/api/angular_devkit/core/src/index.d.ts create mode 100644 etc/api/angular_devkit/schematics/src/index.d.ts create mode 100644 etc/api/angular_devkit/schematics/tasks/index.d.ts create mode 100644 etc/api/angular_devkit/schematics/testing/index.d.ts create mode 100644 etc/api/angular_devkit/schematics/tools/index.d.ts diff --git a/etc/api/angular_devkit/architect/src/index.d.ts b/etc/api/angular_devkit/architect/src/index.d.ts new file mode 100644 index 000000000000..d20842d03b88 --- /dev/null +++ b/etc/api/angular_devkit/architect/src/index.d.ts @@ -0,0 +1,102 @@ +export declare class Architect { + constructor(_workspace: experimental.workspace.Workspace); + getBuilder(builderDescription: BuilderDescription, context: BuilderContext): Builder; + getBuilderConfiguration(targetSpec: TargetSpecifier): BuilderConfiguration; + getBuilderDescription(builderConfig: BuilderConfiguration): Observable; + listProjectTargets(projectName: string): string[]; + loadArchitect(): Observable; + run(builderConfig: BuilderConfiguration, partialContext?: Partial): Observable; + validateBuilderOptions(builderConfig: BuilderConfiguration, builderDescription: BuilderDescription): Observable>; +} + +export declare class ArchitectNotYetLoadedException extends BaseException { + constructor(); +} + +export interface Builder { + run(builderConfig: BuilderConfiguration>): Observable; +} + +export declare class BuilderCannotBeResolvedException extends BaseException { + constructor(builder: string); +} + +export interface BuilderConfiguration { + builder: string; + options: OptionsT; + projectType: string; + root: Path; + sourceRoot?: Path; +} + +export interface BuilderConstructor { + new (context: BuilderContext): Builder; +} + +export interface BuilderContext { + architect: Architect; + host: virtualFs.Host<{}>; + logger: logging.Logger; + workspace: experimental.workspace.Workspace; +} + +export interface BuilderDescription { + description: string; + name: string; + schema: JsonObject; +} + +export declare class BuilderNotFoundException extends BaseException { + constructor(builder: string); +} + +export interface BuilderPaths { + class: Path; + description: string; + schema: Path; +} + +export interface BuilderPathsMap { + builders: { + [k: string]: BuilderPaths; + }; +} + +export interface BuildEvent { + success: boolean; +} + +export declare class ConfigurationNotFoundException extends BaseException { + constructor(projectName: string, configurationName: string); +} + +export declare class ProjectNotFoundException extends BaseException { + constructor(projectName: string); +} + +export interface Target { + builder: string; + configurations?: { + [k: string]: TargetConfiguration; + }; + options: TargetOptions; +} + +export declare type TargetConfiguration = Partial; + +export interface TargetMap { + [k: string]: Target; +} + +export declare class TargetNotFoundException extends BaseException { + constructor(projectName: string, targetName: string); +} + +export declare type TargetOptions = T; + +export interface TargetSpecifier { + configuration?: string; + overrides?: Partial; + project: string; + target: string; +} diff --git a/etc/api/angular_devkit/architect/testing/index.d.ts b/etc/api/angular_devkit/architect/testing/index.d.ts new file mode 100644 index 000000000000..df6a94e5de15 --- /dev/null +++ b/etc/api/angular_devkit/architect/testing/index.d.ts @@ -0,0 +1,28 @@ +export declare const DefaultTimeout = 45000; + +export declare function request(url: string, headers?: {}): Promise; + +export declare function runTargetSpec(host: TestProjectHost, targetSpec: TargetSpecifier, overrides?: {}, timeout?: number, logger?: logging.Logger): Observable; + +export declare class TestLogger extends logging.Logger { + constructor(name: string, parent?: logging.Logger | null); + clear(): void; + includes(message: string): boolean; + test(re: RegExp): boolean; +} + +export declare class TestProjectHost extends NodeJsSyncHost { + protected _templateRoot: Path; + constructor(_templateRoot: Path); + appendToFile(path: string, str: string): void; + copyFile(from: string, to: string): void; + fileMatchExists(dir: string, regex: RegExp): PathFragment | undefined; + initialize(): Observable; + replaceInFile(path: string, match: RegExp | string, replacement: string): void; + restore(): Observable; + root(): Path; + scopedSync(): virtualFs.SyncDelegateHost; + writeMultipleFiles(files: { + [path: string]: string | ArrayBufferLike | Buffer; + }): void; +} diff --git a/etc/api/angular_devkit/benchmark/src/index.d.ts b/etc/api/angular_devkit/benchmark/src/index.d.ts new file mode 100644 index 000000000000..9c3713d1a78b --- /dev/null +++ b/etc/api/angular_devkit/benchmark/src/index.d.ts @@ -0,0 +1,91 @@ +export interface AggregatedMetric extends Metric { + componentValues: number[]; +} + +export interface AggregatedProcessStats { + cpu: number; + ctime: number; + elapsed: number; + memory: number; + pid: number; + ppid: number; + processes: number; + timestamp: number; +} + +export declare const aggregateMetricGroups: (g1: MetricGroup, g2: MetricGroup) => MetricGroup; + +export declare const aggregateMetrics: (m1: Metric | AggregatedMetric, m2: Metric | AggregatedMetric) => AggregatedMetric; + +export declare type BenchmarkReporter = (command: Command, groups: MetricGroup[]) => void; + +export declare type Capture = (process: MonitoredProcess) => Observable; + +export declare class Command { + args: string[]; + cmd: string; + cwd: string; + expectedExitCode: number; + constructor(cmd: string, args?: string[], cwd?: string, expectedExitCode?: number); + toString(): string; +} + +export declare const cumulativeMovingAverage: (acc: number, val: number, accSize: number) => number; + +export declare const defaultReporter: (logger: logging.Logger) => BenchmarkReporter; + +export declare const defaultStatsCapture: Capture; + +export declare class LocalMonitoredProcess implements MonitoredProcess { + stats$: Observable; + stderr$: Observable; + stdout$: Observable; + constructor(command: Command); + run(): Observable; +} + +export declare function main({ args, stdout, stderr, }: MainOptions): Promise<0 | 1>; + +export interface MainOptions { + args: string[]; + stderr?: ProcessOutput; + stdout?: ProcessOutput; +} + +export declare const max: (v1: number, v2: number) => number; + +export declare class MaximumRetriesExceeded extends BaseException { + constructor(retries: number); +} + +export interface Metric { + componentValues?: number[]; + name: string; + unit: string; + value: number; +} + +export interface MetricGroup { + metrics: (Metric | AggregatedMetric)[]; + name: string; +} + +export interface MonitoredProcess { + stats$: Observable; + stderr$: Observable; + stdout$: Observable; + run(): Observable; + toString(): string; +} + +export declare function runBenchmark({ command, captures, reporters, iterations, retries, logger, }: RunBenchmarkOptions): Observable; + +export interface RunBenchmarkOptions { + captures: Capture[]; + command: Command; + expectedExitCode?: number; + iterations?: number; + logger?: logging.Logger; + reporters: BenchmarkReporter[]; + retries?: number; +} diff --git a/etc/api/angular_devkit/build_optimizer/src/index.d.ts b/etc/api/angular_devkit/build_optimizer/src/index.d.ts new file mode 100644 index 000000000000..6250388f8804 --- /dev/null +++ b/etc/api/angular_devkit/build_optimizer/src/index.d.ts @@ -0,0 +1,21 @@ +export declare function buildOptimizer(options: BuildOptimizerOptions): TransformJavascriptOutput; + +export declare function getFoldFileTransformer(program: ts.Program): ts.TransformerFactory; + +export declare function getImportTslibTransformer(): ts.TransformerFactory; + +export declare function getPrefixClassesTransformer(): ts.TransformerFactory; + +export declare function getPrefixFunctionsTransformer(): ts.TransformerFactory; + +export declare function getScrubFileTransformer(program: ts.Program): ts.TransformerFactory; + +export declare function getWrapEnumsTransformer(): ts.TransformerFactory; + +export declare function testImportTslib(content: string): boolean; + +export declare function testPrefixClasses(content: string): boolean; + +export declare function testScrubFile(content: string): boolean; + +export declare function transformJavascript(options: TransformJavascriptOptions): TransformJavascriptOutput; diff --git a/etc/api/angular_devkit/core/node/index.d.ts b/etc/api/angular_devkit/core/node/index.d.ts new file mode 100644 index 000000000000..334e05edaf53 --- /dev/null +++ b/etc/api/angular_devkit/core/node/index.d.ts @@ -0,0 +1,52 @@ +export declare function createConsoleLogger(verbose?: boolean, stdout?: ProcessOutput, stderr?: ProcessOutput): logging.Logger; + +export declare class ModuleNotFoundException extends BaseException { + readonly basePath: string; + readonly code: string; + readonly moduleName: string; + constructor(moduleName: string, basePath: string); +} + +export declare class NodeJsAsyncHost implements virtualFs.Host { + readonly capabilities: virtualFs.HostCapabilities; + delete(path: Path): Observable; + exists(path: Path): Observable; + isDirectory(path: Path): Observable; + isFile(path: Path): Observable; + list(path: Path): Observable; + read(path: Path): Observable; + rename(from: Path, to: Path): Observable; + stat(path: Path): Observable> | null; + watch(path: Path, _options?: virtualFs.HostWatchOptions): Observable | null; + write(path: Path, content: virtualFs.FileBuffer): Observable; +} + +export declare class NodeJsSyncHost implements virtualFs.Host { + readonly capabilities: virtualFs.HostCapabilities; + delete(path: Path): Observable; + exists(path: Path): Observable; + isDirectory(path: Path): Observable; + isFile(path: Path): Observable; + list(path: Path): Observable; + read(path: Path): Observable; + rename(from: Path, to: Path): Observable; + stat(path: Path): Observable>; + watch(path: Path, _options?: virtualFs.HostWatchOptions): Observable | null; + write(path: Path, content: virtualFs.FileBuffer): Observable; +} + +export interface ProcessOutput { + write(buffer: string | Buffer): boolean; +} + +export declare function resolve(x: string, options: ResolveOptions): string; + +export interface ResolveOptions { + basedir: string; + checkGlobal?: boolean; + checkLocal?: boolean; + extensions?: string[]; + paths?: string[]; + preserveSymlinks?: boolean; + resolvePackageJson?: boolean; +} diff --git a/etc/api/angular_devkit/core/node/testing/index.d.ts b/etc/api/angular_devkit/core/node/testing/index.d.ts new file mode 100644 index 000000000000..0c9c161d0878 --- /dev/null +++ b/etc/api/angular_devkit/core/node/testing/index.d.ts @@ -0,0 +1,8 @@ +export declare class TempScopedNodeJsSyncHost extends virtualFs.ScopedHost { + protected _root: Path; + protected _sync: virtualFs.SyncDelegateHost; + readonly files: Path[]; + readonly root: Path; + readonly sync: virtualFs.SyncDelegateHost; + constructor(); +} diff --git a/etc/api/angular_devkit/core/src/index.d.ts b/etc/api/angular_devkit/core/src/index.d.ts new file mode 100644 index 000000000000..0551251629ce --- /dev/null +++ b/etc/api/angular_devkit/core/src/index.d.ts @@ -0,0 +1,344 @@ +export declare function asPosixPath(path: Path): PosixPath; + +export declare function asWindowsPath(path: Path): WindowsPath; + +export declare class BaseException extends Error { + constructor(message?: string); +} + +export declare function basename(path: Path): PathFragment; + +export declare class CircularDependencyFoundException extends BaseException { + constructor(); +} + +export declare function clean(array: Array): Array; + +export declare class ContentHasMutatedException extends BaseException { + constructor(path: string); +} + +export declare function deepCopy(value: T): T; + +export declare class DependencyNotFoundException extends BaseException { + constructor(); +} + +export declare function dirname(path: Path): Path; + +export declare function extname(path: Path): string; + +export declare class FileAlreadyExistException extends BaseException { + constructor(path: string); +} + +export declare class FileDoesNotExistException extends BaseException { + constructor(path: string); +} + +export declare function fragment(path: string): PathFragment; + +export declare function getSystemPath(path: Path): string; + +export declare class InvalidJsonCharacterException extends JsonException { + character: number; + invalidChar: string; + line: number; + offset: number; + constructor(context: JsonParserContext); +} + +export declare class InvalidPathException extends BaseException { + constructor(path: string); +} + +export declare class InvalidUpdateRecordException extends BaseException { + constructor(); +} + +export declare function isAbsolute(p: Path): boolean; + +export declare function isJsonArray(value: JsonValue): value is JsonArray; + +export declare function isJsonObject(value: JsonValue): value is JsonObject; + +export declare function isObservable(obj: any | Observable): obj is Observable; + +export declare function isPromise(obj: any): obj is Promise; + +export declare function join(p1: Path, ...others: string[]): Path; + +export interface JsonArray extends Array { +} + +export interface JsonAstArray extends JsonAstNodeBase { + readonly elements: JsonAstNode[]; + readonly kind: 'array'; + readonly value: JsonArray; +} + +export interface JsonAstComment extends JsonAstNodeBase { + readonly content: string; + readonly kind: 'comment'; +} + +export interface JsonAstConstantFalse extends JsonAstNodeBase { + readonly kind: 'false'; + readonly value: false; +} + +export interface JsonAstConstantNull extends JsonAstNodeBase { + readonly kind: 'null'; + readonly value: null; +} + +export interface JsonAstConstantTrue extends JsonAstNodeBase { + readonly kind: 'true'; + readonly value: true; +} + +export interface JsonAstIdentifier extends JsonAstNodeBase { + readonly kind: 'identifier'; + readonly value: string; +} + +export interface JsonAstKeyValue extends JsonAstNodeBase { + readonly key: JsonAstString | JsonAstIdentifier; + readonly kind: 'keyvalue'; + readonly value: JsonAstNode; +} + +export interface JsonAstMultilineComment extends JsonAstNodeBase { + readonly content: string; + readonly kind: 'multicomment'; +} + +export declare type JsonAstNode = JsonAstNumber | JsonAstString | JsonAstIdentifier | JsonAstArray | JsonAstObject | JsonAstConstantFalse | JsonAstConstantNull | JsonAstConstantTrue; + +export interface JsonAstNodeBase { + readonly comments?: (JsonAstComment | JsonAstMultilineComment)[]; + readonly end: Position; + readonly start: Position; + readonly text: string; +} + +export interface JsonAstNumber extends JsonAstNodeBase { + readonly kind: 'number'; + readonly value: number; +} + +export interface JsonAstObject extends JsonAstNodeBase { + readonly kind: 'object'; + readonly properties: JsonAstKeyValue[]; + readonly value: JsonObject; +} + +export interface JsonAstString extends JsonAstNodeBase { + readonly kind: 'string'; + readonly value: string; +} + +export declare class JsonException extends BaseException { +} + +export interface JsonObject { + [prop: string]: JsonValue; +} + +export declare enum JsonParseMode { + Strict = 0, + CommentsAllowed = 1, + SingleQuotesAllowed = 2, + IdentifierKeyNamesAllowed = 4, + TrailingCommasAllowed = 8, + HexadecimalNumberAllowed = 16, + MultiLineStringAllowed = 32, + LaxNumberParsingAllowed = 64, + NumberConstantsAllowed = 128, + Default = 0, + Loose = 255, + Json = 0, + Json5 = 255 +} + +export interface JsonParserContext { + readonly mode: JsonParseMode; + readonly original: string; + position: Position; + previous: Position; +} + +export declare type JsonValue = JsonAstNode['value']; + +export declare function mapObject(obj: { + [k: string]: T; +}, mapper: (k: string, v: T) => V): { + [k: string]: V; +}; + +export declare class MergeConflictException extends BaseException { + constructor(path: string); +} + +export declare function noCacheNormalize(path: string): Path; + +export declare function normalize(path: string): Path; + +export declare const NormalizedRoot: Path; + +export declare const NormalizedSep: Path; + +export declare function parseJson(input: string, mode?: JsonParseMode, options?: ParseJsonOptions): JsonValue; + +export declare function parseJsonAst(input: string, mode?: JsonParseMode): JsonAstNode; + +export interface ParseJsonOptions { + path?: string; +} + +export declare class PartiallyOrderedSet implements Set { + readonly [Symbol.toStringTag]: 'Set'; + readonly size: number; + [Symbol.iterator](): IterableIterator; + protected _checkCircularDependencies(item: T, deps: Set): void; + add(item: T, deps?: (Set | T[])): this; + clear(): void; + delete(item: T): boolean; + entries(): IterableIterator<[T, T]>; + forEach(callbackfn: (value: T, value2: T, set: PartiallyOrderedSet) => void, thisArg?: any): void; + has(item: T): boolean; + keys(): IterableIterator; + values(): IterableIterator; +} + +export declare const path: TemplateTag; + +export declare type Path = string & { + __PRIVATE_DEVKIT_PATH: void; +}; + +export declare class PathCannotBeFragmentException extends BaseException { + constructor(path: string); +} + +export declare type PathFragment = Path & { + __PRIVATE_DEVKIT_PATH_FRAGMENT: void; +}; + +export declare class PathIsDirectoryException extends BaseException { + constructor(path: string); +} + +export declare class PathIsFileException extends BaseException { + constructor(path: string); +} + +export declare class PathMustBeAbsoluteException extends BaseException { + constructor(path: string); +} + +export declare class PathSpecificJsonException extends JsonException { + exception: JsonException; + path: string; + constructor(path: string, exception: JsonException); +} + +export interface Position { + readonly character: number; + readonly line: number; + readonly offset: number; +} + +export declare type PosixPath = string & { + __PRIVATE_DEVKIT_POSIX_PATH: void; +}; + +export declare class PriorityQueue { + readonly size: number; + constructor(_comparator: (x: T, y: T) => number); + clear(): void; + peek(): T | undefined; + pop(): T | undefined; + push(item: T): void; + toArray(): Array; +} + +export declare function relative(from: Path, to: Path): Path; + +export declare function resetNormalizeCache(): void; + +export declare function resolve(p1: Path, p2: Path): Path; + +export declare function split(path: Path): PathFragment[]; + +export declare function template(content: string, options?: TemplateOptions): (input: T) => string; + +export interface TemplateAst { + children: TemplateAstNode[]; + content: string; + fileName: string; +} + +export interface TemplateAstBase { + end: Position; + start: Position; +} + +export interface TemplateAstComment extends TemplateAstBase { + kind: 'comment'; + text: string; +} + +export interface TemplateAstContent extends TemplateAstBase { + content: string; + kind: 'content'; +} + +export interface TemplateAstEscape extends TemplateAstBase { + expression: string; + kind: 'escape'; +} + +export interface TemplateAstEvaluate extends TemplateAstBase { + expression: string; + kind: 'evaluate'; +} + +export interface TemplateAstInterpolate extends TemplateAstBase { + expression: string; + kind: 'interpolate'; +} + +export declare type TemplateAstNode = TemplateAstContent | TemplateAstEvaluate | TemplateAstComment | TemplateAstEscape | TemplateAstInterpolate; + +export interface TemplateOptions { + fileName?: string; + module?: boolean | { + exports: {}; + }; + sourceMap?: boolean; + sourceRoot?: string; + sourceURL?: string; +} + +export declare function templateParser(sourceText: string, fileName: string): TemplateAst; + +export declare class UnexpectedEndOfInputException extends JsonException { + constructor(_context: JsonParserContext); +} + +export declare class UnimplementedException extends BaseException { + constructor(); +} + +export declare class UnknownException extends Error { + constructor(message: string); +} + +export declare class UnsupportedPlatformException extends BaseException { + constructor(); +} + +export declare type WindowsPath = string & { + __PRIVATE_DEVKIT_WINDOWS_PATH: void; +}; diff --git a/etc/api/angular_devkit/schematics/src/index.d.ts b/etc/api/angular_devkit/schematics/src/index.d.ts new file mode 100644 index 000000000000..00774b7e1084 --- /dev/null +++ b/etc/api/angular_devkit/schematics/src/index.d.ts @@ -0,0 +1,645 @@ +export declare type Action = CreateFileAction | OverwriteFileAction | RenameFileAction | DeleteFileAction; + +export interface ActionBase { + readonly id: number; + readonly parent: number; + readonly path: Path; +} + +export declare class ActionList implements Iterable { + readonly length: number; + [Symbol.iterator](): IterableIterator; + protected _action(action: Partial): void; + create(path: Path, content: Buffer): void; + delete(path: Path): void; + find(predicate: (value: Action) => boolean): Action | null; + forEach(fn: (value: Action, index: number, array: Action[]) => void, thisArg?: {}): void; + get(i: number): Action; + has(action: Action): boolean; + optimize(): void; + overwrite(path: Path, content: Buffer): void; + push(action: Action): void; + rename(path: Path, to: Path): void; +} + +export declare function apply(source: Source, rules: Rule[]): Source; + +export declare function applyContentTemplate(options: T): FileOperator; + +export declare function applyPathTemplate(data: T, options?: PathTemplateOptions): FileOperator; + +export declare function applyTemplates(options: T): Rule; + +export declare function asSource(rule: Rule): Source; + +export declare type AsyncFileOperator = (tree: FileEntry) => Observable; + +export declare function branchAndMerge(rule: Rule, strategy?: MergeStrategy): Rule; + +export declare function callRule(rule: Rule, input: Observable, context: SchematicContext): Observable; + +export declare function callSource(source: Source, context: SchematicContext): Observable; + +export declare function chain(rules: Rule[]): Rule; + +export declare class CircularCollectionException extends BaseException { + constructor(name: string); +} + +export interface Collection { + readonly baseDescriptions?: Array>; + readonly description: CollectionDescription; + createSchematic(name: string, allowPrivate?: boolean): Schematic; + listSchematicNames(): string[]; +} + +export declare type CollectionDescription = CollectionMetadataT & { + readonly name: string; + readonly extends?: string[]; +}; + +export declare class CollectionImpl implements Collection { + readonly baseDescriptions?: CollectionDescription[] | undefined; + readonly description: CollectionDescription; + readonly name: string; + constructor(_description: CollectionDescription, _engine: SchematicEngine, baseDescriptions?: CollectionDescription[] | undefined); + createSchematic(name: string, allowPrivate?: boolean): Schematic; + listSchematicNames(): string[]; +} + +export declare function composeFileOperators(operators: FileOperator[]): FileOperator; + +export declare class ContentHasMutatedException extends BaseException { + constructor(path: string); +} + +export declare function contentTemplate(options: T): Rule; + +export interface CreateFileAction extends ActionBase { + readonly content: Buffer; + readonly kind: 'c'; +} + +export declare class DelegateTree implements Tree { + protected _other: Tree; + readonly actions: Action[]; + readonly root: DirEntry; + constructor(_other: Tree); + apply(action: Action, strategy?: MergeStrategy): void; + beginUpdate(path: string): UpdateRecorder; + branch(): Tree; + commitUpdate(record: UpdateRecorder): void; + create(path: string, content: Buffer | string): void; + delete(path: string): void; + exists(path: string): boolean; + get(path: string): FileEntry | null; + getDir(path: string): DirEntry; + merge(other: Tree, strategy?: MergeStrategy): void; + overwrite(path: string, content: Buffer | string): void; + read(path: string): Buffer | null; + rename(from: string, to: string): void; + visit(visitor: FileVisitor): void; +} + +export interface DeleteFileAction extends ActionBase { + readonly kind: 'd'; +} + +export interface DirEntry { + readonly parent: DirEntry | null; + readonly path: Path; + readonly subdirs: PathFragment[]; + readonly subfiles: PathFragment[]; + dir(name: PathFragment): DirEntry; + file(name: PathFragment): FileEntry | null; + visit(visitor: FileVisitor): void; +} + +export interface DryRunCreateEvent { + content: Buffer; + kind: 'create'; + path: string; +} + +export interface DryRunDeleteEvent { + kind: 'delete'; + path: string; +} + +export interface DryRunErrorEvent { + description: 'alreadyExist' | 'doesNotExist'; + kind: 'error'; + path: string; +} + +export declare type DryRunEvent = DryRunErrorEvent | DryRunDeleteEvent | DryRunCreateEvent | DryRunUpdateEvent | DryRunRenameEvent; + +export interface DryRunRenameEvent { + kind: 'rename'; + path: string; + to: string; +} + +export declare class DryRunSink extends HostSink { + protected _fileAlreadyExistExceptionSet: Set; + protected _fileDoesNotExistExceptionSet: Set; + protected _subject: Subject; + readonly reporter: Observable; + constructor(dir: string, force?: boolean); + constructor(host: virtualFs.Host, force?: boolean); + _done(): Observable; + protected _fileAlreadyExistException(path: string): void; + protected _fileDoesNotExistException(path: string): void; +} + +export interface DryRunUpdateEvent { + content: Buffer; + kind: 'update'; + path: string; +} + +export declare function empty(): Source; + +export declare class EmptyTree extends HostTree { + constructor(); +} + +export interface Engine { + readonly defaultMergeStrategy: MergeStrategy; + readonly workflow: Workflow | null; + createCollection(name: string): Collection; + createContext(schematic: Schematic, parent?: Partial>, executionOptions?: Partial): TypedSchematicContext; + createSchematic(name: string, collection: Collection): Schematic; + createSourceFromUrl(url: Url, context: TypedSchematicContext): Source; + executePostTasks(): Observable; + transformOptions(schematic: Schematic, options: OptionT, context?: TypedSchematicContext): Observable; +} + +export interface EngineHost { + readonly defaultMergeStrategy?: MergeStrategy; + createCollectionDescription(name: string): CollectionDescription; + createSchematicDescription(name: string, collection: CollectionDescription): SchematicDescription | null; + createSourceFromUrl(url: Url, context: TypedSchematicContext): Source | null; + createTaskExecutor(name: string): Observable; + getSchematicRuleFactory(schematic: SchematicDescription, collection: CollectionDescription): RuleFactory; + hasTaskExecutor(name: string): boolean; + listSchematicNames(collection: CollectionDescription): string[]; + listSchematics(collection: Collection): string[]; + transformContext(context: TypedSchematicContext): TypedSchematicContext | void; + transformOptions(schematic: SchematicDescription, options: OptionT, context?: TypedSchematicContext): Observable; +} + +export interface ExecutionOptions { + interactive: boolean; +} + +export declare function externalSchematic(collectionName: string, schematicName: string, options: OptionT, executionOptions?: Partial): Rule; + +export declare class FileAlreadyExistException extends BaseException { + constructor(path: string); +} + +export declare class FileDoesNotExistException extends BaseException { + constructor(path: string); +} + +export interface FileEntry { + readonly content: Buffer; + readonly path: Path; +} + +export declare type FileOperator = (entry: FileEntry) => FileEntry | null; + +export interface FilePredicate { + (path: Path, entry?: Readonly | null): T; +} + +export declare class FileSystemCreateTree extends FileSystemTree { + constructor(host: virtualFs.Host); +} + +export declare class FileSystemDirEntry extends VirtualDirEntry { + protected _host: virtualFs.SyncDelegateHost<{}>; + readonly parent: DirEntry | null; + readonly subdirs: PathFragment[]; + readonly subfiles: PathFragment[]; + constructor(_host: virtualFs.SyncDelegateHost<{}>, tree: FileSystemTree, path?: Path); + protected _createDir(name: PathFragment): DirEntry; + file(name: PathFragment): FileEntry | null; +} + +export declare class FileSystemSink extends HostSink { + constructor(dir: string, force?: boolean); +} + +export declare class FileSystemTree extends VirtualTree { + protected _host: virtualFs.SyncDelegateHost<{}>; + protected _initialized: boolean; + readonly tree: Map; + constructor(host: virtualFs.Host); + protected _copyTo(tree: T): void; + protected _recursiveFileList(): Path[]; + branch(): Tree; + get(path: string): FileEntry | null; +} + +export declare type FileVisitor = FilePredicate; + +export declare const FileVisitorCancelToken: symbol; + +export declare function filter(predicate: FilePredicate): Rule; + +export declare class FilterHostTree extends HostTree { + constructor(tree: HostTree, filter?: FilePredicate); +} + +export declare function forEach(operator: FileOperator): Rule; + +export declare class HostCreateTree extends HostTree { + constructor(host: virtualFs.ReadonlyHost); +} + +export declare class HostDirEntry implements DirEntry { + protected _host: virtualFs.SyncDelegateHost; + protected _tree: Tree; + readonly parent: DirEntry | null; + readonly path: Path; + readonly subdirs: PathFragment[]; + readonly subfiles: PathFragment[]; + constructor(parent: DirEntry | null, path: Path, _host: virtualFs.SyncDelegateHost, _tree: Tree); + dir(name: PathFragment): DirEntry; + file(name: PathFragment): FileEntry | null; + visit(visitor: FileVisitor): void; +} + +export declare class HostSink extends SimpleSinkBase { + protected _filesToCreate: Map; + protected _filesToDelete: Set; + protected _filesToRename: Set<[Path, Path]>; + protected _filesToUpdate: Map; + protected _force: boolean; + protected _host: virtualFs.Host; + constructor(_host: virtualFs.Host, _force?: boolean); + protected _createFile(path: Path, content: Buffer): Observable; + protected _deleteFile(path: Path): Observable; + _done(): Observable; + protected _overwriteFile(path: Path, content: Buffer): Observable; + protected _renameFile(from: Path, to: Path): Observable; + protected _validateCreateAction(action: CreateFileAction): Observable; + protected _validateFileExists(p: Path): Observable; +} + +export declare class HostTree implements Tree { + protected _backend: virtualFs.ReadonlyHost<{}>; + readonly actions: Action[]; + readonly root: DirEntry; + constructor(_backend?: virtualFs.ReadonlyHost<{}>); + protected _normalizePath(path: string): Path; + protected _willCreate(path: Path): boolean; + protected _willDelete(path: Path): boolean; + protected _willOverwrite(path: Path): boolean; + protected _willRename(path: Path): boolean; + apply(action: Action, strategy?: MergeStrategy): void; + beginUpdate(path: string): UpdateRecorder; + branch(): Tree; + commitUpdate(record: UpdateRecorder): void; + create(path: string, content: Buffer | string): void; + delete(path: string): void; + exists(path: string): boolean; + get(path: string): FileEntry | null; + getDir(path: string): DirEntry; + merge(other: Tree, strategy?: MergeStrategy): void; + optimize(): this; + overwrite(path: string, content: Buffer | string): void; + read(path: string): Buffer | null; + rename(from: string, to: string): void; + visit(visitor: FileVisitor): void; + static isHostTree(tree: Tree): tree is HostTree; +} + +export declare class InvalidPipeException extends BaseException { + constructor(name: string); +} + +export declare class InvalidRuleResultException extends BaseException { + constructor(value?: {}); +} + +export declare class InvalidSchematicsNameException extends BaseException { + constructor(name: string); +} + +export declare class InvalidSourceResultException extends BaseException { + constructor(value?: {}); +} + +export declare class InvalidUpdateRecordException extends BaseException { + constructor(); +} + +export declare function isAction(action: any): action is Action; + +export declare function isContentAction(action: Action): action is CreateFileAction | OverwriteFileAction; + +export declare class MergeConflictException extends BaseException { + constructor(path: string); +} + +export declare enum MergeStrategy { + AllowOverwriteConflict = 2, + AllowCreationConflict = 4, + AllowDeleteConflict = 8, + Default = 0, + Error = 1, + ContentOnly = 2, + Overwrite = 14 +} + +export declare function mergeWith(source: Source, strategy?: MergeStrategy): Rule; + +export declare function move(from: string, to?: string): Rule; + +export declare function noop(): Rule; + +export declare class OptionIsNotDefinedException extends BaseException { + constructor(name: string); +} + +export interface OverwriteFileAction extends ActionBase { + readonly content: Buffer; + readonly kind: 'o'; +} + +export declare function partitionApplyMerge(predicate: FilePredicate, ruleYes: Rule, ruleNo?: Rule): Rule; + +export declare function pathTemplate(options: T): Rule; + +export declare type PathTemplateData = { + [key: string]: PathTemplateValue | PathTemplateData | PathTemplatePipeFunction; +}; + +export interface PathTemplateOptions { + interpolationEnd: string; + interpolationStart: string; + pipeSeparator?: string; +} + +export declare type PathTemplatePipeFunction = (x: string) => PathTemplateValue; + +export declare type PathTemplateValue = boolean | string | number | undefined; + +export declare class PrivateSchematicException extends BaseException { + constructor(name: string, collection: CollectionDescription<{}>); +} + +export interface RandomOptions { + multi?: boolean | number; + multiFiles?: boolean | number; + root?: string; +} + +export interface RenameFileAction extends ActionBase { + readonly kind: 'r'; + readonly to: Path; +} + +export declare function renameTemplateFiles(): Rule; + +export declare type Rule = (tree: Tree, context: SchematicContext) => Tree | Observable | Rule | void; + +export declare type RuleFactory = (options: T) => Rule; + +export declare function schematic(schematicName: string, options: OptionT, executionOptions?: Partial): Rule; + +export interface Schematic { + readonly collection: Collection; + readonly description: SchematicDescription; + call(options: OptionT, host: Observable, parentContext?: Partial>, executionOptions?: Partial): Observable; +} + +export declare type SchematicContext = TypedSchematicContext<{}, {}>; + +export declare type SchematicDescription = SchematicMetadataT & { + readonly collection: CollectionDescription; + readonly name: string; + readonly private?: boolean; + readonly hidden?: boolean; +}; + +export declare class SchematicEngine implements Engine { + protected _workflow?: Workflow | undefined; + readonly defaultMergeStrategy: MergeStrategy; + readonly workflow: Workflow | null; + constructor(_host: EngineHost, _workflow?: Workflow | undefined); + createCollection(name: string): Collection; + createContext(schematic: Schematic, parent?: Partial>, executionOptions?: Partial): TypedSchematicContext; + createSchematic(name: string, collection: Collection, allowPrivate?: boolean): Schematic; + createSourceFromUrl(url: Url, context: TypedSchematicContext): Source; + executePostTasks(): Observable; + listSchematicNames(collection: Collection): string[]; + transformOptions(schematic: Schematic, options: OptionT, context?: TypedSchematicContext): Observable; +} + +export declare class SchematicEngineConflictingException extends BaseException { + constructor(); +} + +export declare class SchematicImpl implements Schematic { + readonly collection: Collection; + readonly description: SchematicDescription; + constructor(_description: SchematicDescription, _factory: RuleFactory<{}>, _collection: Collection, _engine: Engine); + call(options: OptionT, host: Observable, parentContext?: Partial>, executionOptions?: Partial): Observable; +} + +export declare class SchematicsException extends BaseException { +} + +export declare abstract class SimpleSinkBase implements Sink { + postCommit: () => void | Observable; + postCommitAction: (action: Action) => void | Observable; + preCommit: () => void | Observable; + preCommitAction: (action: Action) => void | Action | PromiseLike | Observable; + protected abstract _createFile(path: string, content: Buffer): Observable; + protected abstract _deleteFile(path: string): Observable; + protected abstract _done(): Observable; + protected _fileAlreadyExistException(path: string): void; + protected _fileDoesNotExistException(path: string): void; + protected abstract _overwriteFile(path: string, content: Buffer): Observable; + protected abstract _renameFile(path: string, to: string): Observable; + protected _validateCreateAction(action: CreateFileAction): Observable; + protected _validateDeleteAction(action: DeleteFileAction): Observable; + protected abstract _validateFileExists(p: string): Observable; + protected _validateOverwriteAction(action: OverwriteFileAction): Observable; + protected _validateRenameAction(action: RenameFileAction): Observable; + commit(tree: Tree): Observable; + commitSingleAction(action: Action): Observable; + validateSingleAction(action: Action): Observable; +} + +export interface Sink { + commit(tree: Tree): Observable; +} + +export declare function source(tree: Tree): Source; + +export declare type Source = (context: SchematicContext) => Tree | Observable; + +export interface TaskConfiguration { + dependencies?: Array; + name: string; + options?: T; +} + +export interface TaskConfigurationGenerator { + toConfiguration(): TaskConfiguration; +} + +export declare type TaskExecutor = (options: T | undefined, context: SchematicContext) => Promise | Observable; + +export interface TaskExecutorFactory { + readonly name: string; + create(options?: T): Promise | Observable; +} + +export interface TaskId { + readonly id: number; +} + +export interface TaskInfo { + readonly configuration: TaskConfiguration; + readonly context: SchematicContext; + readonly id: number; + readonly priority: number; +} + +export declare class TaskScheduler { + constructor(_context: SchematicContext); + finalize(): ReadonlyArray; + schedule(taskConfiguration: TaskConfiguration): TaskId; +} + +export declare function template(options: T): Rule; + +export declare const TEMPLATE_FILENAME_RE: RegExp; + +export declare const Tree: TreeConstructor; + +export interface TreeConstructor { + branch(tree: TreeInterface): TreeInterface; + empty(): TreeInterface; + merge(tree: TreeInterface, other: TreeInterface, strategy?: MergeStrategy): TreeInterface; + optimize(tree: TreeInterface): TreeInterface; + partition(tree: TreeInterface, predicate: FilePredicate): [TreeInterface, TreeInterface]; +} + +export declare const TreeSymbol: symbol; + +export interface TypedSchematicContext { + readonly debug: boolean; + readonly engine: Engine; + readonly interactive: boolean; + readonly logger: logging.LoggerApi; + readonly schematic: Schematic; + readonly strategy: MergeStrategy; + addTask(task: TaskConfigurationGenerator, dependencies?: Array): TaskId; +} + +export declare class UnimplementedException extends BaseException { + constructor(); +} + +export declare class UnknownActionException extends BaseException { + constructor(action: Action); +} + +export declare class UnknownCollectionException extends BaseException { + constructor(name: string); +} + +export declare class UnknownPipeException extends BaseException { + constructor(name: string); +} + +export declare class UnknownSchematicException extends BaseException { + constructor(name: string, collection: CollectionDescription<{}>); +} + +export declare class UnknownTaskDependencyException extends BaseException { + constructor(id: TaskId); +} + +export declare class UnknownUrlSourceProtocol extends BaseException { + constructor(url: string); +} + +export declare class UnregisteredTaskException extends BaseException { + constructor(name: string, schematic?: SchematicDescription<{}, {}>); +} + +export declare class UnsuccessfulWorkflowExecution extends BaseException { + constructor(); +} + +export interface UpdateRecorder { + insertLeft(index: number, content: Buffer | string): UpdateRecorder; + insertRight(index: number, content: Buffer | string): UpdateRecorder; + remove(index: number, length: number): UpdateRecorder; +} + +export declare function url(urlString: string): Source; + +export declare class VirtualDirEntry implements DirEntry { + protected _path: Path; + protected _subdirs: Map; + protected _tree: VirtualTree; + readonly parent: DirEntry | null; + readonly path: Path; + readonly subdirs: PathFragment[]; + readonly subfiles: PathFragment[]; + constructor(_tree: VirtualTree, _path?: Path); + protected _createDir(name: PathFragment): DirEntry; + dir(name: PathFragment): DirEntry; + file(name: PathFragment): FileEntry | null; + visit(visitor: FileVisitor): void; +} + +export declare class VirtualTree implements Tree { + protected _actions: ActionList; + protected _cacheMap: Map; + protected _root: VirtualDirEntry; + protected _tree: Map; + readonly actions: Action[]; + readonly files: Path[]; + readonly root: DirEntry; + readonly staging: ReadonlyMap; + protected readonly tree: ReadonlyMap; + protected _copyTo(tree: T): void; + protected _create(path: Path, content: Buffer, action?: Action): void; + protected _delete(path: Path, action?: Action): void; + protected _normalizePath(path: string): Path; + protected _overwrite(path: Path, content: Buffer, action?: Action): void; + protected _rename(path: Path, to: Path, action?: Action, force?: boolean): void; + apply(action: Action, strategy: MergeStrategy): void; + beginUpdate(path: string): UpdateRecorder; + branch(): Tree; + commitUpdate(record: UpdateRecorder): void; + create(path: string, content: Buffer | string): void; + delete(path: string): void; + exists(path: string): boolean; + get(path: string): FileEntry | null; + getDir(path: string): DirEntry; + has(path: string): boolean; + merge(other: Tree, strategy?: MergeStrategy): void; + optimize(): void; + overwrite(path: string, content: Buffer | string): void; + read(path: string): Buffer | null; + rename(path: string, to: string): void; + set(entry: FileEntry): Map; + visit(visitor: FileVisitor): void; + static branch(tree: Tree): Tree; + static isVirtualTree(tree: Tree): tree is VirtualTree; + static merge(tree: Tree, other: Tree, strategy?: MergeStrategy): Tree; + static optimize(tree: Tree): VirtualTree; +} + +export declare function when(predicate: FilePredicate, operator: FileOperator): FileOperator; diff --git a/etc/api/angular_devkit/schematics/tasks/index.d.ts b/etc/api/angular_devkit/schematics/tasks/index.d.ts new file mode 100644 index 000000000000..f802db93d246 --- /dev/null +++ b/etc/api/angular_devkit/schematics/tasks/index.d.ts @@ -0,0 +1,42 @@ +export declare class NodePackageInstallTask implements TaskConfigurationGenerator { + packageManager?: string; + packageName?: string; + quiet: boolean; + workingDirectory?: string; + constructor(options: Partial); + constructor(workingDirectory?: string); + toConfiguration(): TaskConfiguration; +} + +export declare class NodePackageLinkTask implements TaskConfigurationGenerator { + packageName?: string | undefined; + quiet: boolean; + workingDirectory?: string | undefined; + constructor(packageName?: string | undefined, workingDirectory?: string | undefined); + toConfiguration(): TaskConfiguration; +} + +export declare class RepositoryInitializerTask implements TaskConfigurationGenerator { + commitOptions?: CommitOptions | undefined; + workingDirectory?: string | undefined; + constructor(workingDirectory?: string | undefined, commitOptions?: CommitOptions | undefined); + toConfiguration(): TaskConfiguration; +} + +export declare class RunSchematicTask implements TaskConfigurationGenerator> { + protected _collection: string | null; + protected _options: T; + protected _schematic: string; + constructor(c: string, s: string, o: T); + constructor(s: string, o: T); + toConfiguration(): TaskConfiguration>; +} + +export declare class TslintFixTask implements TaskConfigurationGenerator { + protected _configOrPath: null | string | JsonObject; + protected _options: TslintFixTaskOptionsBase; + constructor(config: JsonObject, options: TslintFixTaskOptionsBase); + constructor(options: TslintFixTaskOptionsBase); + constructor(path: string, options: TslintFixTaskOptionsBase); + toConfiguration(): TaskConfiguration; +} diff --git a/etc/api/angular_devkit/schematics/testing/index.d.ts b/etc/api/angular_devkit/schematics/testing/index.d.ts new file mode 100644 index 000000000000..b2fd06c700a4 --- /dev/null +++ b/etc/api/angular_devkit/schematics/testing/index.d.ts @@ -0,0 +1,16 @@ +export declare class SchematicTestRunner { + readonly engine: SchematicEngine<{}, {}>; + readonly logger: logging.Logger; + readonly tasks: TaskConfiguration[]; + constructor(_collectionName: string, collectionPath: string); + callRule(rule: Rule, tree: Tree, parentContext?: Partial): Observable; + runExternalSchematic(collectionName: string, schematicName: string, opts?: SchematicSchemaT, tree?: Tree): UnitTestTree; + runExternalSchematicAsync(collectionName: string, schematicName: string, opts?: SchematicSchemaT, tree?: Tree): Observable; + runSchematic(schematicName: string, opts?: SchematicSchemaT, tree?: Tree): UnitTestTree; + runSchematicAsync(schematicName: string, opts?: SchematicSchemaT, tree?: Tree): Observable; +} + +export declare class UnitTestTree extends DelegateTree { + readonly files: string[]; + readContent(path: string): string; +} diff --git a/etc/api/angular_devkit/schematics/tools/index.d.ts b/etc/api/angular_devkit/schematics/tools/index.d.ts new file mode 100644 index 000000000000..785039f4c799 --- /dev/null +++ b/etc/api/angular_devkit/schematics/tools/index.d.ts @@ -0,0 +1,150 @@ +export declare class CollectionCannotBeResolvedException extends BaseException { + constructor(name: string); +} + +export declare class CollectionMissingFieldsException extends BaseException { + constructor(name: string); +} + +export declare class CollectionMissingSchematicsMapException extends BaseException { + constructor(name: string); +} + +export declare class ExportStringRef { + readonly module: string; + readonly path: string; + readonly ref: T | undefined; + constructor(ref: string, parentPath?: string, inner?: boolean); +} + +export declare class FactoryCannotBeResolvedException extends BaseException { + constructor(name: string); +} + +export declare type FileSystemCollection = Collection; + +export declare type FileSystemCollectionDesc = CollectionDescription; + +export interface FileSystemCollectionDescription { + readonly path: string; + readonly schematics: { + [name: string]: FileSystemSchematicDesc; + }; + readonly version?: string; +} + +export declare class FileSystemEngineHost extends FileSystemEngineHostBase { + protected _root: string; + constructor(_root: string); + protected _resolveCollectionPath(name: string): string; + protected _resolveReferenceString(refString: string, parentPath: string): { + ref: RuleFactory<{}>; + path: string; + } | null; + protected _transformCollectionDescription(name: string, desc: Partial): FileSystemCollectionDesc; + protected _transformSchematicDescription(name: string, _collection: FileSystemCollectionDesc, desc: Partial): FileSystemSchematicDesc; +} + +export declare abstract class FileSystemEngineHostBase implements EngineHost { + protected abstract _resolveCollectionPath(name: string): string; + protected abstract _resolveReferenceString(name: string, parentPath: string): { + ref: RuleFactory<{}>; + path: string; + } | null; + protected abstract _transformCollectionDescription(name: string, desc: Partial): FileSystemCollectionDesc; + protected abstract _transformSchematicDescription(name: string, collection: FileSystemCollectionDesc, desc: Partial): FileSystemSchematicDesc; + createCollectionDescription(name: string): FileSystemCollectionDesc; + createSchematicDescription(name: string, collection: FileSystemCollectionDesc): FileSystemSchematicDesc | null; + createSourceFromUrl(url: Url): Source | null; + createTaskExecutor(name: string): Observable; + getSchematicRuleFactory(schematic: FileSystemSchematicDesc, _collection: FileSystemCollectionDesc): RuleFactory; + hasTaskExecutor(name: string): boolean; + listSchematicNames(collection: FileSystemCollectionDesc): string[]; + listSchematics(collection: FileSystemCollection): string[]; + registerOptionsTransform(t: OptionTransform): void; + registerTaskExecutor(factory: TaskExecutorFactory, options?: T): void; + transformContext(context: FileSystemSchematicContext): FileSystemSchematicContext; + transformOptions(schematic: FileSystemSchematicDesc, options: OptionT, context?: FileSystemSchematicContext): Observable; +} + +export declare class FileSystemHost extends virtualFs.ScopedHost<{}> { + constructor(dir: string); +} + +export declare type FileSystemSchematic = Schematic; + +export declare type FileSystemSchematicContext = TypedSchematicContext; + +export declare type FileSystemSchematicDesc = SchematicDescription; + +export interface FileSystemSchematicDescription extends FileSystemSchematicJsonDescription { + readonly factoryFn: RuleFactory<{}>; + readonly path: string; + readonly schemaJson?: JsonObject; +} + +export interface FileSystemSchematicJsonDescription { + readonly aliases?: string[]; + readonly description: string; + readonly extends?: string; + readonly factory: string; + readonly schema?: string; +} + +export declare class InvalidCollectionJsonException extends BaseException { + constructor(_name: string, path: string, jsonException?: UnexpectedEndOfInputException | InvalidJsonCharacterException); +} + +export declare class NodeModulesEngineHost extends FileSystemEngineHostBase { + constructor(); + protected _resolveCollectionPath(name: string): string; + protected _resolvePackageJson(name: string, basedir?: string): string; + protected _resolvePath(name: string, basedir?: string): string; + protected _resolveReferenceString(refString: string, parentPath: string): { + ref: RuleFactory<{}>; + path: string; + } | null; + protected _transformCollectionDescription(name: string, desc: Partial): FileSystemCollectionDesc; + protected _transformSchematicDescription(name: string, _collection: FileSystemCollectionDesc, desc: Partial): FileSystemSchematicDesc; +} + +export declare class NodeModulesTestEngineHost extends NodeModulesEngineHost { + readonly tasks: TaskConfiguration<{}>[]; + protected _resolveCollectionPath(name: string): string; + clearTasks(): void; + registerCollection(name: string, path: string): void; + transformContext(context: FileSystemSchematicContext): FileSystemSchematicContext; +} + +export declare class NodePackageDoesNotSupportSchematics extends BaseException { + constructor(name: string); +} + +export declare class NodeWorkflow extends workflow.BaseWorkflow { + constructor(host: virtualFs.Host, options: { + force?: boolean; + dryRun?: boolean; + root?: Path; + packageManager?: string; + }); +} + +export declare type OptionTransform = (schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext) => Observable; + +export declare class SchematicMissingDescriptionException extends BaseException { + constructor(name: string); +} + +export declare class SchematicMissingFactoryException extends BaseException { + constructor(name: string); +} + +export declare class SchematicMissingFieldsException extends BaseException { + constructor(name: string); +} + +export declare class SchematicNameCollisionException extends BaseException { + constructor(name: string); +} + +export declare function validateOptionsWithSchema(registry: schema.SchemaRegistry): (schematic: FileSystemSchematicDescription, options: T, context?: import("@angular-devkit/schematics/src/engine/interface").TypedSchematicContext | undefined) => Observable; From 1f2357ca4217d59a608b4549ee779deb56730d82 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 21 Nov 2018 13:43:19 +0100 Subject: [PATCH 05/11] refactor: use proper namespace instead of alias export --- .../core/src/virtual-fs/host/test.ts | 203 +++++++++--------- .../core/src/virtual-fs/host/test_spec.ts | 4 +- 2 files changed, 105 insertions(+), 102 deletions(-) diff --git a/packages/angular_devkit/core/src/virtual-fs/host/test.ts b/packages/angular_devkit/core/src/virtual-fs/host/test.ts index 4efdae796f4b..55179384b5f6 100644 --- a/packages/angular_devkit/core/src/virtual-fs/host/test.ts +++ b/packages/angular_devkit/core/src/virtual-fs/host/test.ts @@ -12,10 +12,11 @@ import { FileBuffer, HostWatchEvent, HostWatchOptions, Stats } from './interface import { SimpleMemoryHost, SimpleMemoryHostStats } from './memory'; import { SyncDelegateHost } from './sync'; +export namespace test { -export type TestLogRecord = { + export type TestLogRecord = { kind: 'write' | 'read' | 'delete' | 'list' | 'exists' | 'isDirectory' | 'isFile' | 'stat' - | 'watch'; + | 'watch'; path: Path; } | { kind: 'rename'; @@ -24,130 +25,132 @@ export type TestLogRecord = { }; -export class TestHost extends SimpleMemoryHost { - protected _records: TestLogRecord[] = []; - protected _sync: SyncDelegateHost<{}>; + export class TestHost extends SimpleMemoryHost { + protected _records: TestLogRecord[] = []; + protected _sync: SyncDelegateHost<{}>; - constructor(map: { [path: string]: string } = {}) { - super(); + constructor(map: { [path: string]: string } = {}) { + super(); - for (const filePath of Object.getOwnPropertyNames(map)) { - this._write(normalize(filePath), stringToFileBuffer(map[filePath])); + for (const filePath of Object.getOwnPropertyNames(map)) { + this._write(normalize(filePath), stringToFileBuffer(map[filePath])); + } } - } - get records(): TestLogRecord[] { - return [...this._records]; - } - clearRecords() { - this._records = []; - } + get records(): TestLogRecord[] { + return [...this._records]; + } + clearRecords() { + this._records = []; + } - get files(): Path[] { - const sync = this.sync; - function _visit(p: Path): Path[] { - return sync.list(p) - .map(fragment => join(p, fragment)) - .reduce((files, path) => { - if (sync.isDirectory(path)) { - return files.concat(_visit(path)); - } else { - return files.concat(path); - } - }, [] as Path[]); - } - - return _visit(normalize('/')); - } + get files(): Path[] { + const sync = this.sync; + function _visit(p: Path): Path[] { + return sync.list(p) + .map(fragment => join(p, fragment)) + .reduce((files, path) => { + if (sync.isDirectory(path)) { + return files.concat(_visit(path)); + } else { + return files.concat(path); + } + }, [] as Path[]); + } + + return _visit(normalize('/')); + } + + get sync() { + if (!this._sync) { + this._sync = new SyncDelegateHost<{}>(this); + } - get sync() { - if (!this._sync) { - this._sync = new SyncDelegateHost<{}>(this); + return this._sync; } - return this._sync; - } + clone() { + const newHost = new TestHost(); + newHost._cache = new Map(this._cache); - clone() { - const newHost = new TestHost(); - newHost._cache = new Map(this._cache); + return newHost; + } - return newHost; - } + // Override parents functions to keep a record of all operators that were done. + protected _write(path: Path, content: FileBuffer) { + this._records.push({ kind: 'write', path }); - // Override parents functions to keep a record of all operators that were done. - protected _write(path: Path, content: FileBuffer) { - this._records.push({ kind: 'write', path }); + return super._write(path, content); + } + protected _read(path: Path) { + this._records.push({ kind: 'read', path }); - return super._write(path, content); - } - protected _read(path: Path) { - this._records.push({ kind: 'read', path }); + return super._read(path); + } + protected _delete(path: Path) { + this._records.push({ kind: 'delete', path }); - return super._read(path); - } - protected _delete(path: Path) { - this._records.push({ kind: 'delete', path }); + return super._delete(path); + } + protected _rename(from: Path, to: Path) { + this._records.push({ kind: 'rename', from, to }); - return super._delete(path); - } - protected _rename(from: Path, to: Path) { - this._records.push({ kind: 'rename', from, to }); + return super._rename(from, to); + } + protected _list(path: Path): PathFragment[] { + this._records.push({ kind: 'list', path }); - return super._rename(from, to); - } - protected _list(path: Path): PathFragment[] { - this._records.push({ kind: 'list', path }); + return super._list(path); + } + protected _exists(path: Path) { + this._records.push({ kind: 'exists', path }); - return super._list(path); - } - protected _exists(path: Path) { - this._records.push({ kind: 'exists', path }); + return super._exists(path); + } + protected _isDirectory(path: Path) { + this._records.push({ kind: 'isDirectory', path }); - return super._exists(path); - } - protected _isDirectory(path: Path) { - this._records.push({ kind: 'isDirectory', path }); + return super._isDirectory(path); + } + protected _isFile(path: Path) { + this._records.push({ kind: 'isFile', path }); - return super._isDirectory(path); - } - protected _isFile(path: Path) { - this._records.push({ kind: 'isFile', path }); + return super._isFile(path); + } + protected _stat(path: Path): Stats | null { + this._records.push({ kind: 'stat', path }); - return super._isFile(path); - } - protected _stat(path: Path): Stats | null { - this._records.push({ kind: 'stat', path }); + return super._stat(path); + } + protected _watch(path: Path, options?: HostWatchOptions): Observable { + this._records.push({ kind: 'watch', path }); - return super._stat(path); - } - protected _watch(path: Path, options?: HostWatchOptions): Observable { - this._records.push({ kind: 'watch', path }); + return super._watch(path, options); + } - return super._watch(path, options); - } + $write(path: string, content: string) { + return super._write(normalize(path), stringToFileBuffer(content)); + } - $write(path: string, content: string) { - return super._write(normalize(path), stringToFileBuffer(content)); - } + $read(path: string): string { + return fileBufferToString(super._read(normalize(path))); + } - $read(path: string): string { - return fileBufferToString(super._read(normalize(path))); - } + $list(path: string): PathFragment[] { + return super._list(normalize(path)); + } - $list(path: string): PathFragment[] { - return super._list(normalize(path)); - } + $exists(path: string) { + return super._exists(normalize(path)); + } - $exists(path: string) { - return super._exists(normalize(path)); - } + $isDirectory(path: string) { + return super._isDirectory(normalize(path)); + } - $isDirectory(path: string) { - return super._isDirectory(normalize(path)); + $isFile(path: string) { + return super._isFile(normalize(path)); + } } - $isFile(path: string) { - return super._isFile(normalize(path)); - } } diff --git a/packages/angular_devkit/core/src/virtual-fs/host/test_spec.ts b/packages/angular_devkit/core/src/virtual-fs/host/test_spec.ts index dc8556054ab6..4e0cb296a155 100644 --- a/packages/angular_devkit/core/src/virtual-fs/host/test_spec.ts +++ b/packages/angular_devkit/core/src/virtual-fs/host/test_spec.ts @@ -5,7 +5,7 @@ * 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 { TestHost } from './test'; +import { test } from './test'; // Yes, we realize the irony of testing a test host. @@ -19,7 +19,7 @@ describe('TestHost', () => { '/x/y/b': '', }; - const host = new TestHost(files); + const host = new test.TestHost(files); expect(host.files.sort() as string[]).toEqual(Object.keys(files).sort()); }); From 1c336e69f02df12a349d4e9e52a3d9ae09e008a3 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 21 Nov 2018 13:43:39 +0100 Subject: [PATCH 06/11] refactor: use proper namspace einstead of alias export --- .../core/src/terminal/colors.ts | 55 ++++++++++--------- .../angular_devkit/core/src/terminal/index.ts | 4 +- .../angular_devkit/core/src/terminal/text.ts | 55 +++++++++---------- 3 files changed, 56 insertions(+), 58 deletions(-) diff --git a/packages/angular_devkit/core/src/terminal/colors.ts b/packages/angular_devkit/core/src/terminal/colors.ts index 6f509446efd3..1494ec04bcb6 100644 --- a/packages/angular_devkit/core/src/terminal/colors.ts +++ b/packages/angular_devkit/core/src/terminal/colors.ts @@ -44,32 +44,33 @@ const kColorFunctions = mapObject(kColors, (_, v) => { return mapObject(v, (_, vv) => (x: string) => `\u001b[${vv[0]}m${x}\u001b[${vv[1]}m`); }); +export namespace colors { + export const reset = kColorFunctions.modifiers.reset; + export const bold = kColorFunctions.modifiers.bold; + export const dim = kColorFunctions.modifiers.dim; + export const italic = kColorFunctions.modifiers.italic; + export const underline = kColorFunctions.modifiers.underline; + export const inverse = kColorFunctions.modifiers.inverse; + export const hidden = kColorFunctions.modifiers.hidden; + export const strikethrough = kColorFunctions.modifiers.strikethrough; -export const reset = kColorFunctions.modifiers.reset; -export const bold = kColorFunctions.modifiers.bold; -export const dim = kColorFunctions.modifiers.dim; -export const italic = kColorFunctions.modifiers.italic; -export const underline = kColorFunctions.modifiers.underline; -export const inverse = kColorFunctions.modifiers.inverse; -export const hidden = kColorFunctions.modifiers.hidden; -export const strikethrough = kColorFunctions.modifiers.strikethrough; + export const black = kColorFunctions.colors.black; + export const red = kColorFunctions.colors.red; + export const green = kColorFunctions.colors.green; + export const yellow = kColorFunctions.colors.yellow; + export const blue = kColorFunctions.colors.blue; + export const magenta = kColorFunctions.colors.magenta; + export const cyan = kColorFunctions.colors.cyan; + export const white = kColorFunctions.colors.white; + export const grey = kColorFunctions.colors.gray; + export const gray = kColorFunctions.colors.gray; -export const black = kColorFunctions.colors.black; -export const red = kColorFunctions.colors.red; -export const green = kColorFunctions.colors.green; -export const yellow = kColorFunctions.colors.yellow; -export const blue = kColorFunctions.colors.blue; -export const magenta = kColorFunctions.colors.magenta; -export const cyan = kColorFunctions.colors.cyan; -export const white = kColorFunctions.colors.white; -export const grey = kColorFunctions.colors.gray; -export const gray = kColorFunctions.colors.gray; - -export const bgBlack = kColorFunctions.bgColors.bgBlack; -export const bgRed = kColorFunctions.bgColors.bgRed; -export const bgGreen = kColorFunctions.bgColors.bgGreen; -export const bgYellow = kColorFunctions.bgColors.bgYellow; -export const bgBlue = kColorFunctions.bgColors.bgBlue; -export const bgMagenta = kColorFunctions.bgColors.bgMagenta; -export const bgCyan = kColorFunctions.bgColors.bgCyan; -export const bgWhite = kColorFunctions.bgColors.bgWhite; + export const bgBlack = kColorFunctions.bgColors.bgBlack; + export const bgRed = kColorFunctions.bgColors.bgRed; + export const bgGreen = kColorFunctions.bgColors.bgGreen; + export const bgYellow = kColorFunctions.bgColors.bgYellow; + export const bgBlue = kColorFunctions.bgColors.bgBlue; + export const bgMagenta = kColorFunctions.bgColors.bgMagenta; + export const bgCyan = kColorFunctions.bgColors.bgCyan; + export const bgWhite = kColorFunctions.bgColors.bgWhite; +} diff --git a/packages/angular_devkit/core/src/terminal/index.ts b/packages/angular_devkit/core/src/terminal/index.ts index e4bcae665520..a33a3ba65ac9 100644 --- a/packages/angular_devkit/core/src/terminal/index.ts +++ b/packages/angular_devkit/core/src/terminal/index.ts @@ -6,6 +6,4 @@ * found in the LICENSE file at https://angular.io/license */ export * from './text'; - -import * as colors from './colors'; -export { colors }; +export * from './colors'; diff --git a/packages/angular_devkit/core/src/terminal/text.ts b/packages/angular_devkit/core/src/terminal/text.ts index bf4f9e7ebae2..3636270a62a1 100644 --- a/packages/angular_devkit/core/src/terminal/text.ts +++ b/packages/angular_devkit/core/src/terminal/text.ts @@ -6,34 +6,33 @@ * found in the LICENSE file at https://angular.io/license */ import * as caps from './caps'; -import * as ansi from './colors'; +import { colors } from './colors'; +export const reset = caps.stdout.colors ? colors.reset : (x: string) => x; +export const bold = caps.stdout.colors ? colors.bold : (x: string) => x; +export const dim = caps.stdout.colors ? colors.dim : (x: string) => x; +export const italic = caps.stdout.colors ? colors.italic : (x: string) => x; +export const underline = caps.stdout.colors ? colors.underline : (x: string) => x; +export const inverse = caps.stdout.colors ? colors.inverse : (x: string) => x; +export const hidden = caps.stdout.colors ? colors.hidden : (x: string) => x; +export const strikethrough = caps.stdout.colors ? colors.strikethrough : (x: string) => x; -export const reset = caps.stdout.colors ? ansi.reset : (x: string) => x; -export const bold = caps.stdout.colors ? ansi.bold : (x: string) => x; -export const dim = caps.stdout.colors ? ansi.dim : (x: string) => x; -export const italic = caps.stdout.colors ? ansi.italic : (x: string) => x; -export const underline = caps.stdout.colors ? ansi.underline : (x: string) => x; -export const inverse = caps.stdout.colors ? ansi.inverse : (x: string) => x; -export const hidden = caps.stdout.colors ? ansi.hidden : (x: string) => x; -export const strikethrough = caps.stdout.colors ? ansi.strikethrough : (x: string) => x; +export const black = caps.stdout.colors ? colors.black : (x: string) => x; +export const red = caps.stdout.colors ? colors.red : (x: string) => x; +export const green = caps.stdout.colors ? colors.green : (x: string) => x; +export const yellow = caps.stdout.colors ? colors.yellow : (x: string) => x; +export const blue = caps.stdout.colors ? colors.blue : (x: string) => x; +export const magenta = caps.stdout.colors ? colors.magenta : (x: string) => x; +export const cyan = caps.stdout.colors ? colors.cyan : (x: string) => x; +export const white = caps.stdout.colors ? colors.white : (x: string) => x; +export const grey = caps.stdout.colors ? colors.gray : (x: string) => x; +export const gray = caps.stdout.colors ? colors.gray : (x: string) => x; -export const black = caps.stdout.colors ? ansi.black : (x: string) => x; -export const red = caps.stdout.colors ? ansi.red : (x: string) => x; -export const green = caps.stdout.colors ? ansi.green : (x: string) => x; -export const yellow = caps.stdout.colors ? ansi.yellow : (x: string) => x; -export const blue = caps.stdout.colors ? ansi.blue : (x: string) => x; -export const magenta = caps.stdout.colors ? ansi.magenta : (x: string) => x; -export const cyan = caps.stdout.colors ? ansi.cyan : (x: string) => x; -export const white = caps.stdout.colors ? ansi.white : (x: string) => x; -export const grey = caps.stdout.colors ? ansi.gray : (x: string) => x; -export const gray = caps.stdout.colors ? ansi.gray : (x: string) => x; - -export const bgBlack = caps.stdout.colors ? ansi.bgBlack : (x: string) => x; -export const bgRed = caps.stdout.colors ? ansi.bgRed : (x: string) => x; -export const bgGreen = caps.stdout.colors ? ansi.bgGreen : (x: string) => x; -export const bgYellow = caps.stdout.colors ? ansi.bgYellow : (x: string) => x; -export const bgBlue = caps.stdout.colors ? ansi.bgBlue : (x: string) => x; -export const bgMagenta = caps.stdout.colors ? ansi.bgMagenta : (x: string) => x; -export const bgCyan = caps.stdout.colors ? ansi.bgCyan : (x: string) => x; -export const bgWhite = caps.stdout.colors ? ansi.bgWhite : (x: string) => x; +export const bgBlack = caps.stdout.colors ? colors.bgBlack : (x: string) => x; +export const bgRed = caps.stdout.colors ? colors.bgRed : (x: string) => x; +export const bgGreen = caps.stdout.colors ? colors.bgGreen : (x: string) => x; +export const bgYellow = caps.stdout.colors ? colors.bgYellow : (x: string) => x; +export const bgBlue = caps.stdout.colors ? colors.bgBlue : (x: string) => x; +export const bgMagenta = caps.stdout.colors ? colors.bgMagenta : (x: string) => x; +export const bgCyan = caps.stdout.colors ? colors.bgCyan : (x: string) => x; +export const bgWhite = caps.stdout.colors ? colors.bgWhite : (x: string) => x; From d34c58e476f01d7a0eca63b2a73d9941428a17f3 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 21 Nov 2018 13:45:19 +0100 Subject: [PATCH 07/11] build: add `_golden_api` files At the moment ts api guardian doesn't support aliased symbols as namespaces, this is a workaround to still have namespaced symbols in the final golden file. --- etc/api/BUILD | 15 +- .../src/{index.d.ts => _golden-api.d.ts} | 2 + .../angular_devkit/core/src/_golden-api.d.ts | 1059 +++++++++++++++++ etc/api/angular_devkit/core/src/index.d.ts | 344 ------ .../src/{index.d.ts => _golden-api.d.ts} | 55 + .../build_optimizer/src/_golden-api.ts | 9 + .../angular_devkit/core/src/_golden-api.ts | 53 + .../core/src/virtual-fs/host/index.ts | 5 +- .../schematics/src/_golden-api.ts | 13 + 9 files changed, 1195 insertions(+), 360 deletions(-) rename etc/api/angular_devkit/build_optimizer/src/{index.d.ts => _golden-api.d.ts} (87%) create mode 100644 etc/api/angular_devkit/core/src/_golden-api.d.ts delete mode 100644 etc/api/angular_devkit/core/src/index.d.ts rename etc/api/angular_devkit/schematics/src/{index.d.ts => _golden-api.d.ts} (93%) create mode 100644 packages/angular_devkit/build_optimizer/src/_golden-api.ts create mode 100644 packages/angular_devkit/core/src/_golden-api.ts create mode 100644 packages/angular_devkit/schematics/src/_golden-api.ts diff --git a/etc/api/BUILD b/etc/api/BUILD index 9c11dca0eabb..fb66f90a6ad0 100644 --- a/etc/api/BUILD +++ b/etc/api/BUILD @@ -4,7 +4,7 @@ load("@angular//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test") name = "%s_%s_%sapi" % ( bundle[0], bundle[1], - bundle[2].replace("src/", "").replace("index", "").replace("/", "_"), + bundle[2].replace("src/", "").replace("index", "").replace("_golden-api", "").replace("/", "_"), ), actual = "angular_cli/packages/%s/%s/npm_package/%s.d.ts" % ( bundle[0], @@ -30,19 +30,8 @@ load("@angular//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test") # We don't want to analyse these exports nor add them to the golden files # in most cases it's because Ts API Guardian doesn't support Symbol Aliases. strip_export_pattern = [ - # @angular-devkit/core - "^json$", - "^schema$", - "^experimental$", - "^logging$", - "^strings$", - "^tags$", - "^virtualFs$", - "^terminal$", - "^fs$", # @angular-devkit/schematics "^workflow$", - "^engine$", "^formats$", # @angular-devkit/build-optimizer "^buildOptimizerLoader$", @@ -50,7 +39,9 @@ load("@angular//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test") allow_module_identifiers = [ "fs", "ts", + "ajv", "Symbol", + "webpack", ], # At the moment using this will ignore a big change use_angular_tag_rules = False, diff --git a/etc/api/angular_devkit/build_optimizer/src/index.d.ts b/etc/api/angular_devkit/build_optimizer/src/_golden-api.d.ts similarity index 87% rename from etc/api/angular_devkit/build_optimizer/src/index.d.ts rename to etc/api/angular_devkit/build_optimizer/src/_golden-api.d.ts index 6250388f8804..e3e9a7ef1a8d 100644 --- a/etc/api/angular_devkit/build_optimizer/src/index.d.ts +++ b/etc/api/angular_devkit/build_optimizer/src/_golden-api.d.ts @@ -1,5 +1,7 @@ export declare function buildOptimizer(options: BuildOptimizerOptions): TransformJavascriptOutput; +export default function buildOptimizerLoader(this: webpack.loader.LoaderContext, content: string, previousSourceMap: RawSourceMap): void; + export declare function getFoldFileTransformer(program: ts.Program): ts.TransformerFactory; export declare function getImportTslibTransformer(): ts.TransformerFactory; diff --git a/etc/api/angular_devkit/core/src/_golden-api.d.ts b/etc/api/angular_devkit/core/src/_golden-api.d.ts new file mode 100644 index 000000000000..aa1dfa19aabe --- /dev/null +++ b/etc/api/angular_devkit/core/src/_golden-api.d.ts @@ -0,0 +1,1059 @@ +export interface AdditionalPropertiesValidatorError extends SchemaValidatorErrorBase { + keyword: 'additionalProperties'; + params: { + additionalProperty: string; + }; +} + +export declare function addUndefinedDefaults(value: JsonValue, _pointer: JsonPointer, schema?: JsonObject): JsonValue; + +export declare class AliasHost extends ResolverHost { + protected _aliases: Map; + readonly aliases: Map; + protected _resolve(path: Path): Path; +} + +export declare class AmbiguousProjectPathException extends BaseException { + readonly path: Path; + readonly projects: ReadonlyArray; + constructor(path: Path, projects: ReadonlyArray); +} + +export declare function asPosixPath(path: Path): PosixPath; + +export declare function asWindowsPath(path: Path): WindowsPath; + +export declare class BaseException extends Error { + constructor(message?: string); +} + +export declare function basename(path: Path): PathFragment; + +export declare const bgBlack: (x: string) => string; + +export declare const bgBlue: (x: string) => string; + +export declare const bgCyan: (x: string) => string; + +export declare const bgGreen: (x: string) => string; + +export declare const bgMagenta: (x: string) => string; + +export declare const bgRed: (x: string) => string; + +export declare const bgWhite: (x: string) => string; + +export declare const bgYellow: (x: string) => string; + +export declare const black: (x: string) => string; + +export declare const blue: (x: string) => string; + +export declare const bold: (x: string) => string; + +export declare function buildJsonPointer(fragments: string[]): JsonPointer; + +export declare function camelize(str: string): string; + +export declare function capitalize(str: string): string; + +export declare class CircularDependencyFoundException extends BaseException { + constructor(); +} + +export declare function classify(str: string): string; + +export declare function clean(array: Array): Array; + +export declare namespace colors { + const reset: (x: string) => string; + const bold: (x: string) => string; + const dim: (x: string) => string; + const italic: (x: string) => string; + const underline: (x: string) => string; + const inverse: (x: string) => string; + const hidden: (x: string) => string; + const strikethrough: (x: string) => string; + const black: (x: string) => string; + const red: (x: string) => string; + const green: (x: string) => string; + const yellow: (x: string) => string; + const blue: (x: string) => string; + const magenta: (x: string) => string; + const cyan: (x: string) => string; + const white: (x: string) => string; + const grey: (x: string) => string; + const gray: (x: string) => string; + const bgBlack: (x: string) => string; + const bgRed: (x: string) => string; + const bgGreen: (x: string) => string; + const bgYellow: (x: string) => string; + const bgBlue: (x: string) => string; + const bgMagenta: (x: string) => string; + const bgCyan: (x: string) => string; + const bgWhite: (x: string) => string; +} + +export declare class ContentHasMutatedException extends BaseException { + constructor(path: string); +} + +export declare class CordHost extends SimpleMemoryHost { + protected _back: ReadonlyHost; + protected _filesToCreate: Set; + protected _filesToDelete: Set; + protected _filesToOverwrite: Set; + protected _filesToRename: Map; + protected _filesToRenameRevert: Map; + readonly backend: ReadonlyHost; + readonly capabilities: HostCapabilities; + constructor(_back: ReadonlyHost); + clone(): CordHost; + commit(host: Host, force?: boolean): Observable; + create(path: Path, content: FileBuffer): Observable; + delete(path: Path): Observable; + exists(path: Path): Observable; + isDirectory(path: Path): Observable; + isFile(path: Path): Observable; + list(path: Path): Observable; + overwrite(path: Path, content: FileBuffer): Observable; + read(path: Path): Observable; + records(): CordHostRecord[]; + rename(from: Path, to: Path): Observable; + stat(path: Path): Observable | null; + watch(path: Path, options?: HostWatchOptions): null; + willCreate(path: Path): boolean; + willDelete(path: Path): boolean; + willOverwrite(path: Path): boolean; + willRename(path: Path): boolean; + willRenameTo(path: Path, to: Path): boolean; + write(path: Path, content: FileBuffer): Observable; +} + +export interface CordHostCreate { + content: FileBuffer; + kind: 'create'; + path: Path; +} + +export interface CordHostDelete { + kind: 'delete'; + path: Path; +} + +export interface CordHostOverwrite { + content: FileBuffer; + kind: 'overwrite'; + path: Path; +} + +export declare type CordHostRecord = CordHostCreate | CordHostOverwrite | CordHostRename | CordHostDelete; + +export interface CordHostRename { + from: Path; + kind: 'rename'; + to: Path; +} + +export declare class CoreSchemaRegistry implements SchemaRegistry { + constructor(formats?: SchemaFormat[]); + protected _resolver(ref: string, validate: ajv.ValidateFunction): { + context?: ajv.ValidateFunction; + schema?: JsonObject; + }; + addFormat(format: SchemaFormat): void; + addPostTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void; + addPreTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void; + addSmartDefaultProvider(source: string, provider: SmartDefaultProvider): void; + compile(schema: JsonObject): Observable; + flatten(schema: JsonObject): Observable; + registerUriHandler(handler: UriHandler): void; + usePromptProvider(provider: PromptProvider): void; +} + +export declare const cyan: (x: string) => string; + +export declare function dasherize(str: string): string; + +export declare function decamelize(str: string): string; + +export declare function deepCopy(value: T): T; + +export declare class DependencyNotFoundException extends BaseException { + constructor(); +} + +export declare const dim: (x: string) => string; + +export declare function dirname(path: Path): Path; + +export declare class Empty implements ReadonlyHost { + readonly capabilities: HostCapabilities; + exists(path: Path): Observable; + isDirectory(path: Path): Observable; + isFile(path: Path): Observable; + list(path: Path): Observable; + read(path: Path): Observable; + stat(path: Path): Observable | null>; +} + +export declare function extname(path: Path): string; + +export declare class FileAlreadyExistException extends BaseException { + constructor(path: string); +} + +export declare const fileBuffer: TemplateTag; + +export declare type FileBuffer = ArrayBuffer; + +export declare type FileBufferLike = ArrayBufferLike; + +export declare function fileBufferToString(fileBuffer: FileBuffer): string; + +export declare class FileDoesNotExistException extends BaseException { + constructor(path: string); +} + +export interface FormatValidatorError extends SchemaValidatorErrorBase { + keyword: 'format'; + params: { + format: string; + }; +} + +export declare function fragment(path: string): PathFragment; + +export declare function getSystemPath(path: Path): string; + +export declare function getTypesOfSchema(schema: JsonObject | true): Set; + +export declare const gray: (x: string) => string; + +export declare const green: (x: string) => string; + +export declare const grey: (x: string) => string; + +export declare const hidden: (x: string) => string; + +export interface Host extends ReadonlyHost { + delete(path: Path): Observable; + rename(from: Path, to: Path): Observable; + watch(path: Path, options?: HostWatchOptions): Observable | null; + write(path: Path, content: FileBufferLike): Observable; +} + +export interface HostCapabilities { + synchronous: boolean; +} + +export interface HostWatchEvent { + readonly path: Path; + readonly time: Date; + readonly type: HostWatchEventType; +} + +export declare const enum HostWatchEventType { + Changed = 0, + Created = 1, + Deleted = 2, + Renamed = 3 +} + +export interface HostWatchOptions { + readonly persistent?: boolean; + readonly recursive?: boolean; +} + +export declare function indentBy(indentations: number): TemplateTag; + +export declare class IndentLogger extends Logger { + constructor(name: string, parent?: Logger | null, indentation?: string); +} + +export declare class InvalidJsonCharacterException extends JsonException { + character: number; + invalidChar: string; + line: number; + offset: number; + constructor(context: JsonParserContext); +} + +export declare class InvalidPathException extends BaseException { + constructor(path: string); +} + +export declare class InvalidUpdateRecordException extends BaseException { + constructor(); +} + +export declare const inverse: (x: string) => string; + +export declare function isAbsolute(p: Path): boolean; + +export declare function isJsonArray(value: JsonValue): value is JsonArray; + +export declare function isJsonObject(value: JsonValue): value is JsonObject; + +export declare function isObservable(obj: any | Observable): obj is Observable; + +export declare function isPromise(obj: any): obj is Promise; + +export declare const italic: (x: string) => string; + +export declare function join(p1: Path, ...others: string[]): Path; + +export declare function joinJsonPointer(root: JsonPointer, ...others: string[]): JsonPointer; + +export interface JsonArray extends Array { +} + +export interface JsonAstArray extends JsonAstNodeBase { + readonly elements: JsonAstNode[]; + readonly kind: 'array'; + readonly value: JsonArray; +} + +export interface JsonAstComment extends JsonAstNodeBase { + readonly content: string; + readonly kind: 'comment'; +} + +export interface JsonAstConstantFalse extends JsonAstNodeBase { + readonly kind: 'false'; + readonly value: false; +} + +export interface JsonAstConstantNull extends JsonAstNodeBase { + readonly kind: 'null'; + readonly value: null; +} + +export interface JsonAstConstantTrue extends JsonAstNodeBase { + readonly kind: 'true'; + readonly value: true; +} + +export interface JsonAstIdentifier extends JsonAstNodeBase { + readonly kind: 'identifier'; + readonly value: string; +} + +export interface JsonAstKeyValue extends JsonAstNodeBase { + readonly key: JsonAstString | JsonAstIdentifier; + readonly kind: 'keyvalue'; + readonly value: JsonAstNode; +} + +export interface JsonAstMultilineComment extends JsonAstNodeBase { + readonly content: string; + readonly kind: 'multicomment'; +} + +export declare type JsonAstNode = JsonAstNumber | JsonAstString | JsonAstIdentifier | JsonAstArray | JsonAstObject | JsonAstConstantFalse | JsonAstConstantNull | JsonAstConstantTrue; + +export interface JsonAstNodeBase { + readonly comments?: (JsonAstComment | JsonAstMultilineComment)[]; + readonly end: Position; + readonly start: Position; + readonly text: string; +} + +export interface JsonAstNumber extends JsonAstNodeBase { + readonly kind: 'number'; + readonly value: number; +} + +export interface JsonAstObject extends JsonAstNodeBase { + readonly kind: 'object'; + readonly properties: JsonAstKeyValue[]; + readonly value: JsonObject; +} + +export interface JsonAstString extends JsonAstNodeBase { + readonly kind: 'string'; + readonly value: string; +} + +export declare class JsonException extends BaseException { +} + +export interface JsonObject { + [prop: string]: JsonValue; +} + +export declare enum JsonParseMode { + Strict = 0, + CommentsAllowed = 1, + SingleQuotesAllowed = 2, + IdentifierKeyNamesAllowed = 4, + TrailingCommasAllowed = 8, + HexadecimalNumberAllowed = 16, + MultiLineStringAllowed = 32, + LaxNumberParsingAllowed = 64, + NumberConstantsAllowed = 128, + Default = 0, + Loose = 255, + Json = 0, + Json5 = 255 +} + +export interface JsonParserContext { + readonly mode: JsonParseMode; + readonly original: string; + position: Position; + previous: Position; +} + +export declare type JsonPointer = string & { + __PRIVATE_DEVKIT_JSON_POINTER: void; +}; + +export interface JsonSchemaVisitor { + (current: JsonObject | JsonArray, pointer: JsonPointer, parentSchema?: JsonObject | JsonArray, index?: string): void; +} + +export declare type JsonValue = JsonAstNode['value']; + +export interface JsonVisitor { + (value: JsonValue, pointer: JsonPointer, schema?: JsonObject, root?: JsonObject | JsonArray): Observable | JsonValue; +} + +export declare class LevelCapLogger extends LevelTransformLogger { + readonly levelCap: LogLevel; + readonly name: string; + readonly parent: Logger | null; + constructor(name: string, parent: Logger | null, levelCap: LogLevel); + static levelMap: { + [cap: string]: { + [level: string]: string; + }; + }; +} + +export declare class LevelTransformLogger extends Logger { + readonly levelTransform: (level: LogLevel) => LogLevel; + readonly name: string; + readonly parent: Logger | null; + constructor(name: string, parent: Logger | null, levelTransform: (level: LogLevel) => LogLevel); + createChild(name: string): Logger; + log(level: LogLevel, message: string, metadata?: JsonObject): void; +} + +export declare function levenshtein(a: string, b: string): number; + +export interface LimitValidatorError extends SchemaValidatorErrorBase { + keyword: 'maxItems' | 'minItems' | 'maxLength' | 'minLength' | 'maxProperties' | 'minProperties'; + params: { + limit: number; + }; +} + +export interface LogEntry extends LoggerMetadata { + level: LogLevel; + message: string; + timestamp: number; +} + +export declare class Logger extends Observable implements LoggerApi { + protected _metadata: LoggerMetadata; + protected _observable: Observable; + protected readonly _subject: Subject; + readonly name: string; + readonly parent: Logger | null; + constructor(name: string, parent?: Logger | null); + asApi(): LoggerApi; + complete(): void; + createChild(name: string): Logger; + debug(message: string, metadata?: JsonObject): void; + error(message: string, metadata?: JsonObject): void; + fatal(message: string, metadata?: JsonObject): void; + forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise; + info(message: string, metadata?: JsonObject): void; + lift(operator: Operator): Observable; + log(level: LogLevel, message: string, metadata?: JsonObject): void; + subscribe(): Subscription; + subscribe(observer: PartialObserver): Subscription; + subscribe(next?: (value: LogEntry) => void, error?: (error: Error) => void, complete?: () => void): Subscription; + toString(): string; + warn(message: string, metadata?: JsonObject): void; +} + +export interface LoggerApi { + createChild(name: string): Logger; + debug(message: string, metadata?: JsonObject): void; + error(message: string, metadata?: JsonObject): void; + fatal(message: string, metadata?: JsonObject): void; + info(message: string, metadata?: JsonObject): void; + log(level: LogLevel, message: string, metadata?: JsonObject): void; + warn(message: string, metadata?: JsonObject): void; +} + +export interface LoggerMetadata extends JsonObject { + name: string; + path: string[]; +} + +export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal'; + +export declare const magenta: (x: string) => string; + +export declare function mapObject(obj: { + [k: string]: T; +}, mapper: (k: string, v: T) => V): { + [k: string]: V; +}; + +export declare class MergeConflictException extends BaseException { + constructor(path: string); +} + +export declare function noCacheNormalize(path: string): Path; + +export declare function normalize(path: string): Path; + +export declare const NormalizedRoot: Path; + +export declare const NormalizedSep: Path; + +export declare class NullLogger extends Logger { + constructor(parent?: Logger | null); + asApi(): LoggerApi; +} + +export declare function oneLine(strings: TemplateStringsArray, ...values: any[]): string; + +export declare function parseJson(input: string, mode?: JsonParseMode, options?: ParseJsonOptions): JsonValue; + +export declare function parseJsonAst(input: string, mode?: JsonParseMode): JsonAstNode; + +export interface ParseJsonOptions { + path?: string; +} + +export declare function parseJsonPointer(pointer: JsonPointer): string[]; + +export declare class PartiallyOrderedSet implements Set { + readonly [Symbol.toStringTag]: 'Set'; + readonly size: number; + [Symbol.iterator](): IterableIterator; + protected _checkCircularDependencies(item: T, deps: Set): void; + add(item: T, deps?: (Set | T[])): this; + clear(): void; + delete(item: T): boolean; + entries(): IterableIterator<[T, T]>; + forEach(callbackfn: (value: T, value2: T, set: PartiallyOrderedSet) => void, thisArg?: any): void; + has(item: T): boolean; + keys(): IterableIterator; + values(): IterableIterator; +} + +export declare const path: TemplateTag; + +export declare type Path = string & { + __PRIVATE_DEVKIT_PATH: void; +}; + +export declare class PathCannotBeFragmentException extends BaseException { + constructor(path: string); +} + +export declare type PathFragment = Path & { + __PRIVATE_DEVKIT_PATH_FRAGMENT: void; +}; + +export declare class PathIsDirectoryException extends BaseException { + constructor(path: string); +} + +export declare class PathIsFileException extends BaseException { + constructor(path: string); +} + +export declare class PathMustBeAbsoluteException extends BaseException { + constructor(path: string); +} + +export declare class PathSpecificJsonException extends JsonException { + exception: JsonException; + path: string; + constructor(path: string, exception: JsonException); +} + +export declare class PatternMatchingHost extends ResolverHost { + protected _patterns: Map; + protected _resolve(path: Path): Path; + addPattern(pattern: string | string[], replacementFn: ReplacementFunction): void; +} + +export interface Position { + readonly character: number; + readonly line: number; + readonly offset: number; +} + +export declare type PosixPath = string & { + __PRIVATE_DEVKIT_POSIX_PATH: void; +}; + +export declare class PriorityQueue { + readonly size: number; + constructor(_comparator: (x: T, y: T) => number); + clear(): void; + peek(): T | undefined; + pop(): T | undefined; + push(item: T): void; + toArray(): Array; +} + +export declare class ProjectNotFoundException extends BaseException { + constructor(name: string); +} + +export declare class ProjectToolNotFoundException extends BaseException { + constructor(name: string); +} + +export interface PromptDefinition { + default?: string | number | boolean | null; + id: string; + items?: Array; + message: string; + priority: number; + raw?: string | JsonObject; + type: string; + validator?: (value: string) => boolean | string | Promise; +} + +export declare type PromptProvider = (definitions: Array) => SubscribableOrPromise<{ + [id: string]: JsonValue; +}>; + +export interface ReadonlyHost { + readonly capabilities: HostCapabilities; + exists(path: Path): Observable; + isDirectory(path: Path): Observable; + isFile(path: Path): Observable; + list(path: Path): Observable; + read(path: Path): Observable; + stat(path: Path): Observable | null> | null; +} + +export declare const red: (x: string) => string; + +export interface ReferenceResolver { + (ref: string, context?: ContextT): { + context?: ContextT; + schema?: JsonObject; + }; +} + +export interface RefValidatorError extends SchemaValidatorErrorBase { + keyword: '$ref'; + params: { + ref: string; + }; +} + +export declare function relative(from: Path, to: Path): Path; + +export declare type ReplacementFunction = (path: Path) => Path; + +export interface RequiredValidatorError extends SchemaValidatorErrorBase { + keyword: 'required'; + params: { + missingProperty: string; + }; +} + +export declare const reset: (x: string) => string; + +export declare function resetNormalizeCache(): void; + +export declare function resolve(p1: Path, p2: Path): Path; + +export declare abstract class ResolverHost implements Host { + protected _delegate: Host; + readonly capabilities: HostCapabilities; + constructor(_delegate: Host); + protected abstract _resolve(path: Path): Path; + delete(path: Path): Observable; + exists(path: Path): Observable; + isDirectory(path: Path): Observable; + isFile(path: Path): Observable; + list(path: Path): Observable; + read(path: Path): Observable; + rename(from: Path, to: Path): Observable; + stat(path: Path): Observable | null> | null; + watch(path: Path, options?: HostWatchOptions): Observable | null; + write(path: Path, content: FileBuffer): Observable; +} + +export declare class SafeReadonlyHost implements ReadonlyHost { + readonly capabilities: HostCapabilities; + constructor(_delegate: ReadonlyHost); + exists(path: Path): Observable; + isDirectory(path: Path): Observable; + isFile(path: Path): Observable; + list(path: Path): Observable; + read(path: Path): Observable; + stat(path: Path): Observable | null> | null; +} + +export interface SchemaFormat { + formatter: SchemaFormatter; + name: string; +} + +export interface SchemaFormatter { + readonly async: boolean; + validate(data: any): boolean | Observable; +} + +export interface SchemaKeywordValidator { + (data: JsonValue, schema: JsonValue, parent: JsonObject | JsonArray | undefined, parentProperty: string | number | undefined, pointer: JsonPointer, rootData: JsonValue): boolean | Observable; +} + +export interface SchemaRegistry { + addFormat(format: SchemaFormat): void; + addPostTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void; + addPreTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void; + addSmartDefaultProvider(source: string, provider: SmartDefaultProvider): void; + compile(schema: Object): Observable; + flatten(schema: JsonObject | string): Observable; + usePromptProvider(provider: PromptProvider): void; +} + +export declare class SchemaValidationException extends BaseException { + readonly errors: SchemaValidatorError[]; + constructor(errors?: SchemaValidatorError[], baseMessage?: string); + static createMessages(errors?: SchemaValidatorError[]): string[]; +} + +export interface SchemaValidator { + (data: JsonValue, options?: SchemaValidatorOptions): Observable; +} + +export declare type SchemaValidatorError = RefValidatorError | LimitValidatorError | AdditionalPropertiesValidatorError | FormatValidatorError | RequiredValidatorError; + +export interface SchemaValidatorErrorBase { + data?: JsonValue; + dataPath: string; + keyword: string; + message?: string; +} + +export interface SchemaValidatorOptions { + applyPostTransforms?: boolean; + applyPreTransforms?: boolean; + withPrompts?: boolean; +} + +export interface SchemaValidatorResult { + data: JsonValue; + errors?: SchemaValidatorError[]; + success: boolean; +} + +export declare class ScopedHost extends ResolverHost { + protected _root: Path; + constructor(delegate: Host, _root?: Path); + protected _resolve(path: Path): Path; +} + +export declare class SimpleMemoryHost implements Host<{}> { + protected _cache: Map>; + readonly capabilities: HostCapabilities; + constructor(); + protected _delete(path: Path): void; + protected _exists(path: Path): boolean; + protected _isDirectory(path: Path): boolean; + protected _isFile(path: Path): boolean; + protected _list(path: Path): PathFragment[]; + protected _newDirStats(): { + inspect(): string; + isFile(): boolean; + isDirectory(): boolean; + size: number; + atime: Date; + ctime: Date; + mtime: Date; + birthtime: Date; + content: null; + }; + protected _newFileStats(content: FileBuffer, oldStats?: Stats): { + inspect(): string; + isFile(): boolean; + isDirectory(): boolean; + size: number; + atime: Date; + ctime: Date; + mtime: Date; + birthtime: Date; + content: ArrayBuffer; + }; + protected _read(path: Path): FileBuffer; + protected _rename(from: Path, to: Path): void; + protected _stat(path: Path): Stats | null; + protected _toAbsolute(path: Path): Path; + protected _updateWatchers(path: Path, type: HostWatchEventType): void; + protected _watch(path: Path, options?: HostWatchOptions): Observable; + protected _write(path: Path, content: FileBuffer): void; + delete(path: Path): Observable; + exists(path: Path): Observable; + isDirectory(path: Path): Observable; + isFile(path: Path): Observable; + list(path: Path): Observable; + read(path: Path): Observable; + rename(from: Path, to: Path): Observable; + stat(path: Path): Observable | null> | null; + watch(path: Path, options?: HostWatchOptions): Observable | null; + write(path: Path, content: FileBuffer): Observable; +} + +export interface SimpleMemoryHostStats { + readonly content: FileBuffer | null; +} + +export interface SmartDefaultProvider { + (schema: JsonObject): T | Observable; +} + +export declare function split(path: Path): PathFragment[]; + +export declare type Stats = T & { + isFile(): boolean; + isDirectory(): boolean; + readonly size: number; + readonly atime: Date; + readonly mtime: Date; + readonly ctime: Date; + readonly birthtime: Date; +}; + +export declare const strikethrough: (x: string) => string; + +export declare function stringToFileBuffer(str: string): FileBuffer; + +export declare function stripIndent(strings: TemplateStringsArray, ...values: any[]): string; + +export declare function stripIndents(strings: TemplateStringsArray, ...values: any[]): string; + +export declare class SyncDelegateHost { + protected _delegate: Host; + readonly capabilities: HostCapabilities; + readonly delegate: Host; + constructor(_delegate: Host); + protected _doSyncCall(observable: Observable): ResultT; + delete(path: Path): void; + exists(path: Path): boolean; + isDirectory(path: Path): boolean; + isFile(path: Path): boolean; + list(path: Path): PathFragment[]; + read(path: Path): FileBuffer; + rename(from: Path, to: Path): void; + stat(path: Path): Stats | null; + watch(path: Path, options?: HostWatchOptions): Observable | null; + write(path: Path, content: FileBufferLike): void; +} + +export declare class SynchronousDelegateExpectedException extends BaseException { + constructor(); +} + +export declare function template(content: string, options?: TemplateOptions): (input: T) => string; + +export interface TemplateAst { + children: TemplateAstNode[]; + content: string; + fileName: string; +} + +export interface TemplateAstBase { + end: Position; + start: Position; +} + +export interface TemplateAstComment extends TemplateAstBase { + kind: 'comment'; + text: string; +} + +export interface TemplateAstContent extends TemplateAstBase { + content: string; + kind: 'content'; +} + +export interface TemplateAstEscape extends TemplateAstBase { + expression: string; + kind: 'escape'; +} + +export interface TemplateAstEvaluate extends TemplateAstBase { + expression: string; + kind: 'evaluate'; +} + +export interface TemplateAstInterpolate extends TemplateAstBase { + expression: string; + kind: 'interpolate'; +} + +export declare type TemplateAstNode = TemplateAstContent | TemplateAstEvaluate | TemplateAstComment | TemplateAstEscape | TemplateAstInterpolate; + +export interface TemplateOptions { + fileName?: string; + module?: boolean | { + exports: {}; + }; + sourceMap?: boolean; + sourceRoot?: string; + sourceURL?: string; +} + +export declare function templateParser(sourceText: string, fileName: string): TemplateAst; + +export interface TemplateTag { + (template: TemplateStringsArray, ...substitutions: any[]): R; +} + +export declare namespace test { + type TestLogRecord = { + kind: 'write' | 'read' | 'delete' | 'list' | 'exists' | 'isDirectory' | 'isFile' | 'stat' | 'watch'; + path: Path; + } | { + kind: 'rename'; + from: Path; + to: Path; + }; + class TestHost extends SimpleMemoryHost { + protected _records: TestLogRecord[]; + protected _sync: SyncDelegateHost<{}>; + readonly files: Path[]; + readonly records: TestLogRecord[]; + readonly sync: SyncDelegateHost<{}>; + constructor(map?: { + [path: string]: string; + }); + $exists(path: string): boolean; + $isDirectory(path: string): boolean; + $isFile(path: string): boolean; + $list(path: string): PathFragment[]; + $read(path: string): string; + $write(path: string, content: string): void; + protected _delete(path: Path): void; + protected _exists(path: Path): boolean; + protected _isDirectory(path: Path): boolean; + protected _isFile(path: Path): boolean; + protected _list(path: Path): PathFragment[]; + protected _read(path: Path): ArrayBuffer; + protected _rename(from: Path, to: Path): void; + protected _stat(path: Path): Stats | null; + protected _watch(path: Path, options?: HostWatchOptions): Observable; + protected _write(path: Path, content: FileBuffer): void; + clearRecords(): void; + clone(): TestHost; + } +} + +export declare class TransformLogger extends Logger { + constructor(name: string, transform: (stream: Observable) => Observable, parent?: Logger | null); +} + +export declare function trimNewlines(strings: TemplateStringsArray, ...values: any[]): string; + +export declare const underline: (x: string) => string; + +export declare function underscore(str: string): string; + +export declare class UnexpectedEndOfInputException extends JsonException { + constructor(_context: JsonParserContext); +} + +export declare class UnimplementedException extends BaseException { + constructor(); +} + +export declare class UnknownException extends Error { + constructor(message: string); +} + +export declare class UnsupportedPlatformException extends BaseException { + constructor(); +} + +export declare type UriHandler = (uri: string) => Observable | Promise | null | undefined; + +export declare function visitJson(json: JsonValue, visitor: JsonVisitor, schema?: JsonObject, refResolver?: ReferenceResolver, context?: ContextT): Observable; + +export declare function visitJsonSchema(schema: JsonObject, visitor: JsonSchemaVisitor): void; + +export declare const white: (x: string) => string; + +export declare type WindowsPath = string & { + __PRIVATE_DEVKIT_WINDOWS_PATH: void; +}; + +export declare class Workspace { + readonly host: virtualFs.Host<{}>; + readonly newProjectRoot: string | undefined; + readonly root: Path; + readonly version: number; + constructor(_root: Path, _host: virtualFs.Host<{}>); + getCli(): WorkspaceTool; + getDefaultProjectName(): string | null; + getProject(projectName: string): WorkspaceProject; + getProjectByPath(path: Path): string | null; + getProjectCli(projectName: string): WorkspaceTool; + getProjectSchematics(projectName: string): WorkspaceTool; + getProjectTargets(projectName: string): WorkspaceTool; + getSchematics(): WorkspaceTool; + getTargets(): WorkspaceTool; + listProjectNames(): string[]; + loadWorkspaceFromHost(workspacePath: Path): Observable; + loadWorkspaceFromJson(json: {}): Observable; + validateAgainstSchema(contentJson: {}, schemaJson: JsonObject): Observable; +} + +export declare class WorkspaceNotYetLoadedException extends BaseException { + constructor(); +} + +export interface WorkspaceProject { + architect?: WorkspaceTool; + cli?: WorkspaceTool; + prefix: string; + projectType: "application" | "library"; + root: string; + schematics?: WorkspaceTool; + sourceRoot?: string; + targets?: WorkspaceTool; +} + +export interface WorkspaceSchema { + $schema?: string; + architect?: WorkspaceTool; + cli?: WorkspaceTool; + defaultProject?: string; + newProjectRoot?: string; + projects: { + [k: string]: WorkspaceProject; + }; + schematics?: WorkspaceTool; + targets?: WorkspaceTool; + version: number; +} + +export interface WorkspaceTool { + $schema?: string; + [k: string]: any; +} + +export declare class WorkspaceToolNotFoundException extends BaseException { + constructor(name: string); +} + +export declare const yellow: (x: string) => string; diff --git a/etc/api/angular_devkit/core/src/index.d.ts b/etc/api/angular_devkit/core/src/index.d.ts deleted file mode 100644 index 0551251629ce..000000000000 --- a/etc/api/angular_devkit/core/src/index.d.ts +++ /dev/null @@ -1,344 +0,0 @@ -export declare function asPosixPath(path: Path): PosixPath; - -export declare function asWindowsPath(path: Path): WindowsPath; - -export declare class BaseException extends Error { - constructor(message?: string); -} - -export declare function basename(path: Path): PathFragment; - -export declare class CircularDependencyFoundException extends BaseException { - constructor(); -} - -export declare function clean(array: Array): Array; - -export declare class ContentHasMutatedException extends BaseException { - constructor(path: string); -} - -export declare function deepCopy(value: T): T; - -export declare class DependencyNotFoundException extends BaseException { - constructor(); -} - -export declare function dirname(path: Path): Path; - -export declare function extname(path: Path): string; - -export declare class FileAlreadyExistException extends BaseException { - constructor(path: string); -} - -export declare class FileDoesNotExistException extends BaseException { - constructor(path: string); -} - -export declare function fragment(path: string): PathFragment; - -export declare function getSystemPath(path: Path): string; - -export declare class InvalidJsonCharacterException extends JsonException { - character: number; - invalidChar: string; - line: number; - offset: number; - constructor(context: JsonParserContext); -} - -export declare class InvalidPathException extends BaseException { - constructor(path: string); -} - -export declare class InvalidUpdateRecordException extends BaseException { - constructor(); -} - -export declare function isAbsolute(p: Path): boolean; - -export declare function isJsonArray(value: JsonValue): value is JsonArray; - -export declare function isJsonObject(value: JsonValue): value is JsonObject; - -export declare function isObservable(obj: any | Observable): obj is Observable; - -export declare function isPromise(obj: any): obj is Promise; - -export declare function join(p1: Path, ...others: string[]): Path; - -export interface JsonArray extends Array { -} - -export interface JsonAstArray extends JsonAstNodeBase { - readonly elements: JsonAstNode[]; - readonly kind: 'array'; - readonly value: JsonArray; -} - -export interface JsonAstComment extends JsonAstNodeBase { - readonly content: string; - readonly kind: 'comment'; -} - -export interface JsonAstConstantFalse extends JsonAstNodeBase { - readonly kind: 'false'; - readonly value: false; -} - -export interface JsonAstConstantNull extends JsonAstNodeBase { - readonly kind: 'null'; - readonly value: null; -} - -export interface JsonAstConstantTrue extends JsonAstNodeBase { - readonly kind: 'true'; - readonly value: true; -} - -export interface JsonAstIdentifier extends JsonAstNodeBase { - readonly kind: 'identifier'; - readonly value: string; -} - -export interface JsonAstKeyValue extends JsonAstNodeBase { - readonly key: JsonAstString | JsonAstIdentifier; - readonly kind: 'keyvalue'; - readonly value: JsonAstNode; -} - -export interface JsonAstMultilineComment extends JsonAstNodeBase { - readonly content: string; - readonly kind: 'multicomment'; -} - -export declare type JsonAstNode = JsonAstNumber | JsonAstString | JsonAstIdentifier | JsonAstArray | JsonAstObject | JsonAstConstantFalse | JsonAstConstantNull | JsonAstConstantTrue; - -export interface JsonAstNodeBase { - readonly comments?: (JsonAstComment | JsonAstMultilineComment)[]; - readonly end: Position; - readonly start: Position; - readonly text: string; -} - -export interface JsonAstNumber extends JsonAstNodeBase { - readonly kind: 'number'; - readonly value: number; -} - -export interface JsonAstObject extends JsonAstNodeBase { - readonly kind: 'object'; - readonly properties: JsonAstKeyValue[]; - readonly value: JsonObject; -} - -export interface JsonAstString extends JsonAstNodeBase { - readonly kind: 'string'; - readonly value: string; -} - -export declare class JsonException extends BaseException { -} - -export interface JsonObject { - [prop: string]: JsonValue; -} - -export declare enum JsonParseMode { - Strict = 0, - CommentsAllowed = 1, - SingleQuotesAllowed = 2, - IdentifierKeyNamesAllowed = 4, - TrailingCommasAllowed = 8, - HexadecimalNumberAllowed = 16, - MultiLineStringAllowed = 32, - LaxNumberParsingAllowed = 64, - NumberConstantsAllowed = 128, - Default = 0, - Loose = 255, - Json = 0, - Json5 = 255 -} - -export interface JsonParserContext { - readonly mode: JsonParseMode; - readonly original: string; - position: Position; - previous: Position; -} - -export declare type JsonValue = JsonAstNode['value']; - -export declare function mapObject(obj: { - [k: string]: T; -}, mapper: (k: string, v: T) => V): { - [k: string]: V; -}; - -export declare class MergeConflictException extends BaseException { - constructor(path: string); -} - -export declare function noCacheNormalize(path: string): Path; - -export declare function normalize(path: string): Path; - -export declare const NormalizedRoot: Path; - -export declare const NormalizedSep: Path; - -export declare function parseJson(input: string, mode?: JsonParseMode, options?: ParseJsonOptions): JsonValue; - -export declare function parseJsonAst(input: string, mode?: JsonParseMode): JsonAstNode; - -export interface ParseJsonOptions { - path?: string; -} - -export declare class PartiallyOrderedSet implements Set { - readonly [Symbol.toStringTag]: 'Set'; - readonly size: number; - [Symbol.iterator](): IterableIterator; - protected _checkCircularDependencies(item: T, deps: Set): void; - add(item: T, deps?: (Set | T[])): this; - clear(): void; - delete(item: T): boolean; - entries(): IterableIterator<[T, T]>; - forEach(callbackfn: (value: T, value2: T, set: PartiallyOrderedSet) => void, thisArg?: any): void; - has(item: T): boolean; - keys(): IterableIterator; - values(): IterableIterator; -} - -export declare const path: TemplateTag; - -export declare type Path = string & { - __PRIVATE_DEVKIT_PATH: void; -}; - -export declare class PathCannotBeFragmentException extends BaseException { - constructor(path: string); -} - -export declare type PathFragment = Path & { - __PRIVATE_DEVKIT_PATH_FRAGMENT: void; -}; - -export declare class PathIsDirectoryException extends BaseException { - constructor(path: string); -} - -export declare class PathIsFileException extends BaseException { - constructor(path: string); -} - -export declare class PathMustBeAbsoluteException extends BaseException { - constructor(path: string); -} - -export declare class PathSpecificJsonException extends JsonException { - exception: JsonException; - path: string; - constructor(path: string, exception: JsonException); -} - -export interface Position { - readonly character: number; - readonly line: number; - readonly offset: number; -} - -export declare type PosixPath = string & { - __PRIVATE_DEVKIT_POSIX_PATH: void; -}; - -export declare class PriorityQueue { - readonly size: number; - constructor(_comparator: (x: T, y: T) => number); - clear(): void; - peek(): T | undefined; - pop(): T | undefined; - push(item: T): void; - toArray(): Array; -} - -export declare function relative(from: Path, to: Path): Path; - -export declare function resetNormalizeCache(): void; - -export declare function resolve(p1: Path, p2: Path): Path; - -export declare function split(path: Path): PathFragment[]; - -export declare function template(content: string, options?: TemplateOptions): (input: T) => string; - -export interface TemplateAst { - children: TemplateAstNode[]; - content: string; - fileName: string; -} - -export interface TemplateAstBase { - end: Position; - start: Position; -} - -export interface TemplateAstComment extends TemplateAstBase { - kind: 'comment'; - text: string; -} - -export interface TemplateAstContent extends TemplateAstBase { - content: string; - kind: 'content'; -} - -export interface TemplateAstEscape extends TemplateAstBase { - expression: string; - kind: 'escape'; -} - -export interface TemplateAstEvaluate extends TemplateAstBase { - expression: string; - kind: 'evaluate'; -} - -export interface TemplateAstInterpolate extends TemplateAstBase { - expression: string; - kind: 'interpolate'; -} - -export declare type TemplateAstNode = TemplateAstContent | TemplateAstEvaluate | TemplateAstComment | TemplateAstEscape | TemplateAstInterpolate; - -export interface TemplateOptions { - fileName?: string; - module?: boolean | { - exports: {}; - }; - sourceMap?: boolean; - sourceRoot?: string; - sourceURL?: string; -} - -export declare function templateParser(sourceText: string, fileName: string): TemplateAst; - -export declare class UnexpectedEndOfInputException extends JsonException { - constructor(_context: JsonParserContext); -} - -export declare class UnimplementedException extends BaseException { - constructor(); -} - -export declare class UnknownException extends Error { - constructor(message: string); -} - -export declare class UnsupportedPlatformException extends BaseException { - constructor(); -} - -export declare type WindowsPath = string & { - __PRIVATE_DEVKIT_WINDOWS_PATH: void; -}; diff --git a/etc/api/angular_devkit/schematics/src/index.d.ts b/etc/api/angular_devkit/schematics/src/_golden-api.d.ts similarity index 93% rename from etc/api/angular_devkit/schematics/src/index.d.ts rename to etc/api/angular_devkit/schematics/src/_golden-api.d.ts index 00774b7e1084..026a5893cfcf 100644 --- a/etc/api/angular_devkit/schematics/src/index.d.ts +++ b/etc/api/angular_devkit/schematics/src/_golden-api.d.ts @@ -34,6 +34,33 @@ export declare function asSource(rule: Rule): Source; export declare type AsyncFileOperator = (tree: FileEntry) => Observable; +export declare abstract class BaseWorkflow implements Workflow { + protected _context: WorkflowExecutionContext[]; + protected _dryRun: boolean; + protected _engine: SchematicEngine<{}, {}>; + protected _engineHost: EngineHost<{}, {}>; + protected _force: boolean; + protected _host: virtualFs.Host; + protected _lifeCycle: Subject; + protected _registry: schema.CoreSchemaRegistry; + protected _reporter: Subject; + readonly context: Readonly; + readonly lifeCycle: Observable; + readonly registry: schema.SchemaRegistry; + readonly reporter: Observable; + constructor(options: BaseWorkflowOptions); + protected _createSinks(): Sink[]; + execute(options: Partial & RequiredWorkflowExecutionContext): Observable; +} + +export interface BaseWorkflowOptions { + dryRun?: boolean; + engineHost: EngineHost<{}, {}>; + force?: boolean; + host: virtualFs.Host; + registry?: schema.CoreSchemaRegistry; +} + export declare function branchAndMerge(rule: Rule, strategy?: MergeStrategy): Rule; export declare function callRule(rule: Rule, input: Observable, context: SchematicContext): Observable; @@ -317,6 +344,8 @@ export declare class HostTree implements Tree { static isHostTree(tree: Tree): tree is HostTree; } +export declare const htmlSelectorFormat: schema.SchemaFormat; + export declare class InvalidPipeException extends BaseException { constructor(name: string); } @@ -341,6 +370,10 @@ export declare function isAction(action: any): action is Action; export declare function isContentAction(action: Action): action is CreateFileAction | OverwriteFileAction; +export interface LifeCycleEvent { + kind: 'start' | 'end' | 'workflow-start' | 'workflow-end' | 'post-tasks-start' | 'post-tasks-end'; +} + export declare class MergeConflictException extends BaseException { constructor(path: string); } @@ -372,6 +405,8 @@ export interface OverwriteFileAction extends ActionBase { export declare function partitionApplyMerge(predicate: FilePredicate, ruleYes: Rule, ruleNo?: Rule): Rule; +export declare const pathFormat: schema.SchemaFormat; + export declare function pathTemplate(options: T): Rule; export declare type PathTemplateData = { @@ -405,6 +440,12 @@ export interface RenameFileAction extends ActionBase { export declare function renameTemplateFiles(): Rule; +export interface RequiredWorkflowExecutionContext { + collection: string; + options: object; + schematic: string; +} + export declare type Rule = (tree: Tree, context: SchematicContext) => Tree | Observable | Rule | void; export declare type RuleFactory = (options: T) => Rule; @@ -484,6 +525,8 @@ export declare function source(tree: Tree): Source; export declare type Source = (context: SchematicContext) => Tree | Observable; +export declare const standardFormats: schema.SchemaFormat[]; + export interface TaskConfiguration { dependencies?: Array; name: string; @@ -643,3 +686,15 @@ export declare class VirtualTree implements Tree { } export declare function when(predicate: FilePredicate, operator: FileOperator): FileOperator; + +export interface Workflow { + readonly context: Readonly; + execute(options: Partial & RequiredWorkflowExecutionContext): Observable; +} + +export interface WorkflowExecutionContext extends RequiredWorkflowExecutionContext { + allowPrivate?: boolean; + debug: boolean; + logger: logging.Logger; + parentContext?: Readonly; +} diff --git a/packages/angular_devkit/build_optimizer/src/_golden-api.ts b/packages/angular_devkit/build_optimizer/src/_golden-api.ts new file mode 100644 index 000000000000..06e63e7a2c84 --- /dev/null +++ b/packages/angular_devkit/build_optimizer/src/_golden-api.ts @@ -0,0 +1,9 @@ +/** + * @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 './index'; +export { default } from './build-optimizer/webpack-loader'; diff --git a/packages/angular_devkit/core/src/_golden-api.ts b/packages/angular_devkit/core/src/_golden-api.ts new file mode 100644 index 000000000000..d6916e0f9b62 --- /dev/null +++ b/packages/angular_devkit/core/src/_golden-api.ts @@ -0,0 +1,53 @@ +/** + * @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 './exception/exception'; + + // Start experimental namespace +export * from './workspace/index'; +// End experimental namespace + +// Start json namespace +export * from './json/interface'; +export * from './json/parser'; +export * from './json/schema/interface'; +export * from './json/schema/pointer'; +export * from './json/schema/registry'; +export * from './json/schema/visitor'; +export * from './json/schema/utility'; +export * from './json/schema/transforms'; +// End json namespace + +// Start logging namespace +export * from './logger/indent'; +export * from './logger/level'; +export * from './logger/logger'; +export * from './logger/null-logger'; +export * from './logger/transform-logger'; +// End logging namespace + +// Start terminal namespace +export * from './terminal/text'; +export * from './terminal/colors'; +// End terminal namespace + +// Start utils namespace +export * from './utils/literals'; +export * from './utils/strings'; +export * from './utils/array'; +export * from './utils/object'; +export * from './utils/template'; +export * from './utils/partially-ordered-set'; +export * from './utils/priority-queue'; +export * from './utils/lang'; +// End utils namespace + +// Start virtualFs namespace +export * from './virtual-fs/path'; +export * from './virtual-fs/host/index'; +// End virtualFs namespace diff --git a/packages/angular_devkit/core/src/virtual-fs/host/index.ts b/packages/angular_devkit/core/src/virtual-fs/host/index.ts index f7c963dcfc86..c17b0c50f952 100644 --- a/packages/angular_devkit/core/src/virtual-fs/host/index.ts +++ b/packages/angular_devkit/core/src/virtual-fs/host/index.ts @@ -17,7 +17,4 @@ export * from './safe'; export * from './scoped'; export * from './sync'; export * from './resolver'; - -import * as test from './test'; - -export { test }; +export * from './test'; diff --git a/packages/angular_devkit/schematics/src/_golden-api.ts b/packages/angular_devkit/schematics/src/_golden-api.ts new file mode 100644 index 000000000000..9d9ea4ddacbe --- /dev/null +++ b/packages/angular_devkit/schematics/src/_golden-api.ts @@ -0,0 +1,13 @@ +/** + * @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 './index'; + +export * from './formats/index'; + +export * from './workflow/index'; From c1b47bda85ae599a2d1e0977d2f235b7196ebdaf Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 21 Nov 2018 13:54:37 +0100 Subject: [PATCH 08/11] build: update angular archive for workspace --- WORKSPACE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index acab0f554a47..406f14f95d7e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -37,9 +37,9 @@ go_register_toolchains() # TS API Guardian resides in Angular http_archive( name = "angular", - url = "https://github.com/angular/angular/archive/e026a2792a6a7ae7f51f4008c3e8e994ec4f0200.zip", - strip_prefix = "angular-e026a2792a6a7ae7f51f4008c3e8e994ec4f0200", - sha256 = "f9426a9e32b82ac30158632053a23bb15fc309dd2c78bf98872b735961117391", + url = "https://github.com/angular/angular/archive/7.1.0-rc.0.zip", + strip_prefix = "angular-7.1.0-rc.0", + sha256 = "dbf3ae2d60b5384715bc002c695be0141f8c9219396ac1edbdc7023bd400c8a1", ) load("@angular//:index.bzl", "ng_setup_workspace") From a1d9ba2759048be1c32a276aeb69e09c38e1d39f Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 21 Nov 2018 13:55:03 +0100 Subject: [PATCH 09/11] test: fix reference to `TestHost` to use namespace --- .../angular_devkit/core/src/virtual-fs/host/record_spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/angular_devkit/core/src/virtual-fs/host/record_spec.ts b/packages/angular_devkit/core/src/virtual-fs/host/record_spec.ts index 96b6b0e43eaa..2500cc66bb5d 100644 --- a/packages/angular_devkit/core/src/virtual-fs/host/record_spec.ts +++ b/packages/angular_devkit/core/src/virtual-fs/host/record_spec.ts @@ -9,10 +9,11 @@ import { path } from '../path'; import { fileBuffer } from './buffer'; import { CordHost } from './record'; -import { TestHost } from './test'; +import { test } from './test'; describe('CordHost', () => { + const TestHost = test.TestHost; const mutatingTestRecord = ['write', 'delete', 'rename']; it('works (create)', done => { From ee6a8b282eb0696978249da4e15ae89c8ab635b2 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 21 Nov 2018 14:21:31 +0100 Subject: [PATCH 10/11] refactor: create `fs` namespace instead of aliased export --- packages/angular_devkit/core/node/fs.ts | 46 ++++++++++---------- packages/angular_devkit/core/node/index.ts | 5 +-- packages/angular_devkit/core/node/resolve.ts | 8 ++-- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/packages/angular_devkit/core/node/fs.ts b/packages/angular_devkit/core/node/fs.ts index f5ca187a415a..7f37baef6a8d 100644 --- a/packages/angular_devkit/core/node/fs.ts +++ b/packages/angular_devkit/core/node/fs.ts @@ -5,34 +5,36 @@ * 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 * as fs from 'fs'; +import { statSync } from 'fs'; - -export function isFile(filePath: string): boolean { - let stat; - try { - stat = fs.statSync(filePath); - } catch (e) { - if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) { - return false; +export namespace fs { + export function isFile(filePath: string): boolean { + let stat; + try { + stat = statSync(filePath); + } catch (e) { + if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) { + return false; + } + throw e; } - throw e; - } - return stat.isFile() || stat.isFIFO(); -} + return stat.isFile() || stat.isFIFO(); + } -export function isDirectory(filePath: string): boolean { - let stat; - try { - stat = fs.statSync(filePath); - } catch (e) { - if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) { - return false; + export function isDirectory(filePath: string): boolean { + let stat; + try { + stat = statSync(filePath); + } catch (e) { + if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) { + return false; + } + throw e; } - throw e; + + return stat.isDirectory(); } - return stat.isDirectory(); } diff --git a/packages/angular_devkit/core/node/index.ts b/packages/angular_devkit/core/node/index.ts index 51a3944ba3b5..1008bfa1c3c9 100644 --- a/packages/angular_devkit/core/node/index.ts +++ b/packages/angular_devkit/core/node/index.ts @@ -5,10 +5,7 @@ * 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 * as fs from './fs'; - +export * from './fs'; export * from './cli-logger'; export * from './host'; export { ModuleNotFoundException, ResolveOptions, resolve } from './resolve'; - -export { fs }; diff --git a/packages/angular_devkit/core/node/resolve.ts b/packages/angular_devkit/core/node/resolve.ts index 5a3e0712e6f6..1faaf247e052 100644 --- a/packages/angular_devkit/core/node/resolve.ts +++ b/packages/angular_devkit/core/node/resolve.ts @@ -8,7 +8,7 @@ import * as fs from 'fs'; import * as path from 'path'; import { BaseException } from '../src'; -import { isFile } from './fs'; +import { fs as devkitFs } from './fs'; /** * Exception thrown when a module could not be resolved. @@ -204,16 +204,16 @@ export function resolve(x: string, options: ResolveOptions): string { throw new ModuleNotFoundException(x, basePath); function loadAsFileSync(x: string): string | null { - if (isFile(x)) { + if (devkitFs.isFile(x)) { return x; } - return extensions.map(ex => x + ex).find(f => isFile(f)) || null; + return extensions.map(ex => x + ex).find(f => devkitFs.isFile(f)) || null; } function loadAsDirectorySync(x: string): string | null { const pkgfile = path.join(x, 'package.json'); - if (isFile(pkgfile)) { + if (devkitFs.isFile(pkgfile)) { if (options.resolvePackageJson) { return pkgfile; } From ea43163db738c9e7ad9a53837ab332c1a23ec6b6 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 21 Nov 2018 14:28:05 +0100 Subject: [PATCH 11/11] test: update api golden file for `@angular-devkit/core/node` --- etc/api/angular_devkit/core/node/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/etc/api/angular_devkit/core/node/index.d.ts b/etc/api/angular_devkit/core/node/index.d.ts index 334e05edaf53..6c2e882fc1cc 100644 --- a/etc/api/angular_devkit/core/node/index.d.ts +++ b/etc/api/angular_devkit/core/node/index.d.ts @@ -1,5 +1,10 @@ export declare function createConsoleLogger(verbose?: boolean, stdout?: ProcessOutput, stderr?: ProcessOutput): logging.Logger; +export declare namespace fs { + function isFile(filePath: string): boolean; + function isDirectory(filePath: string): boolean; +} + export declare class ModuleNotFoundException extends BaseException { readonly basePath: string; readonly code: string;