@dugararchit/cdk 0.0.0-dugararchit
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_index.scss +8 -0
- package/a11y/_index.import.scss +2 -0
- package/a11y/_index.scss +102 -0
- package/a11y/a11y-prebuilt.scss +3 -0
- package/fesm2022/stagefright5-cdk-a11y.mjs +2381 -0
- package/fesm2022/stagefright5-cdk-a11y.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-accordion.mjs +267 -0
- package/fesm2022/stagefright5-cdk-accordion.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-bidi.mjs +185 -0
- package/fesm2022/stagefright5-cdk-bidi.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-clipboard.mjs +250 -0
- package/fesm2022/stagefright5-cdk-clipboard.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-coercion.mjs +128 -0
- package/fesm2022/stagefright5-cdk-coercion.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-collections.mjs +472 -0
- package/fesm2022/stagefright5-cdk-collections.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-drag-drop.mjs +3690 -0
- package/fesm2022/stagefright5-cdk-drag-drop.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-keycodes.mjs +159 -0
- package/fesm2022/stagefright5-cdk-keycodes.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-layout.mjs +246 -0
- package/fesm2022/stagefright5-cdk-layout.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-observers.mjs +203 -0
- package/fesm2022/stagefright5-cdk-observers.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-overlay.mjs +3033 -0
- package/fesm2022/stagefright5-cdk-overlay.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-platform.mjs +375 -0
- package/fesm2022/stagefright5-cdk-platform.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-portal.mjs +672 -0
- package/fesm2022/stagefright5-cdk-portal.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-scrolling.mjs +1399 -0
- package/fesm2022/stagefright5-cdk-scrolling.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-stepper.mjs +624 -0
- package/fesm2022/stagefright5-cdk-stepper.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-table.mjs +2346 -0
- package/fesm2022/stagefright5-cdk-table.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-protractor.mjs +324 -0
- package/fesm2022/stagefright5-cdk-testing-protractor.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs +364 -0
- package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-testbed.mjs +806 -0
- package/fesm2022/stagefright5-cdk-testing-testbed.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing.mjs +740 -0
- package/fesm2022/stagefright5-cdk-testing.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-text-field.mjs +453 -0
- package/fesm2022/stagefright5-cdk-text-field.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-tree.mjs +945 -0
- package/fesm2022/stagefright5-cdk-tree.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk.mjs +26 -0
- package/fesm2022/stagefright5-cdk.mjs.map +1 -0
- package/overlay/_index-deprecated.scss +13 -0
- package/overlay/_index.import.scss +13 -0
- package/overlay/_index.scss +148 -0
- package/overlay/overlay-prebuilt.scss +3 -0
- package/package.json +159 -0
- package/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
- package/schematics/schematics/BUILD.bazel +104 -0
- package/schematics/schematics/README.md +4 -0
- package/schematics/schematics/collection.json +18 -0
- package/schematics/schematics/index.ts +22 -0
- package/schematics/schematics/migration.json +50 -0
- package/schematics/schematics/ng-add/index.spec.ts +50 -0
- package/schematics/schematics/ng-add/index.ts +39 -0
- package/schematics/schematics/ng-add/package-config.ts +62 -0
- package/schematics/schematics/ng-add/schema.json +16 -0
- package/schematics/schematics/ng-add/schema.ts +12 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template +53 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +17 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +29 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts.template +43 -0
- package/schematics/schematics/ng-generate/drag-drop/index.spec.ts +205 -0
- package/schematics/schematics/ng-generate/drag-drop/index.ts +35 -0
- package/schematics/schematics/ng-generate/drag-drop/schema.json +93 -0
- package/schematics/schematics/ng-generate/drag-drop/schema.ts +11 -0
- package/schematics/schematics/ng-update/data/attribute-selectors.ts +29 -0
- package/schematics/schematics/ng-update/data/class-names.ts +50 -0
- package/schematics/schematics/ng-update/data/constructor-checks.ts +75 -0
- package/schematics/schematics/ng-update/data/css-selectors.ts +33 -0
- package/schematics/schematics/ng-update/data/element-selectors.ts +21 -0
- package/schematics/schematics/ng-update/data/index.ts +18 -0
- package/schematics/schematics/ng-update/data/input-names.ts +118 -0
- package/schematics/schematics/ng-update/data/method-call-checks.ts +63 -0
- package/schematics/schematics/ng-update/data/output-names.ts +42 -0
- package/schematics/schematics/ng-update/data/property-names.ts +151 -0
- package/schematics/schematics/ng-update/data/symbol-removal.ts +22 -0
- package/schematics/schematics/ng-update/devkit-file-system.ts +87 -0
- package/schematics/schematics/ng-update/devkit-migration-rule.ts +185 -0
- package/schematics/schematics/ng-update/devkit-migration.ts +47 -0
- package/schematics/schematics/ng-update/find-stylesheets.ts +43 -0
- package/schematics/schematics/ng-update/html-parsing/angular.ts +49 -0
- package/schematics/schematics/ng-update/html-parsing/elements.ts +66 -0
- package/schematics/schematics/ng-update/index.ts +113 -0
- package/schematics/schematics/ng-update/migrations/attribute-selectors.ts +83 -0
- package/schematics/schematics/ng-update/migrations/class-inheritance.ts +63 -0
- package/schematics/schematics/ng-update/migrations/class-names.ts +107 -0
- package/schematics/schematics/ng-update/migrations/constructor-signature.ts +170 -0
- package/schematics/schematics/ng-update/migrations/css-selectors.ts +83 -0
- package/schematics/schematics/ng-update/migrations/element-selectors.ts +75 -0
- package/schematics/schematics/ng-update/migrations/input-names.ts +83 -0
- package/schematics/schematics/ng-update/migrations/method-call-arguments.ts +70 -0
- package/schematics/schematics/ng-update/migrations/misc-template.ts +36 -0
- package/schematics/schematics/ng-update/migrations/output-names.ts +61 -0
- package/schematics/schematics/ng-update/migrations/property-names.ts +61 -0
- package/schematics/schematics/ng-update/migrations/symbol-removal.ts +51 -0
- package/schematics/schematics/ng-update/migrations/tilde-import-v13/tilde-import-migration.ts +40 -0
- package/schematics/schematics/ng-update/public-api.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/index.spec.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution.spec.ts +32 -0
- package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution_input.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets.spec.ts +50 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets_input.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/misc/method-call-checks.spec.ts +20 -0
- package/schematics/schematics/ng-update/test-cases/misc/method-call-checks_input.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/misc/module-resolution.spec.ts +27 -0
- package/schematics/schematics/ng-update/test-cases/v13/misc/tilde-import-v13.spec.ts +149 -0
- package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_expected_output.ts +36 -0
- package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_input.ts +36 -0
- package/schematics/schematics/ng-update/test-cases/v6/class-names_expected_output.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/v6/class-names_input.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/v6/input-names_expected_output.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/v6/input-names_input.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/v6/property-names_expected_output.ts +64 -0
- package/schematics/schematics/ng-update/test-cases/v6/property-names_input.ts +64 -0
- package/schematics/schematics/ng-update/test-cases/v7/property-names_expected_output.ts +28 -0
- package/schematics/schematics/ng-update/test-cases/v7/property-names_input.ts +28 -0
- package/schematics/schematics/ng-update/typescript/base-types.ts +22 -0
- package/schematics/schematics/ng-update/typescript/imports.ts +54 -0
- package/schematics/schematics/ng-update/typescript/literal.ts +32 -0
- package/schematics/schematics/ng-update/typescript/module-specifiers.ts +39 -0
- package/schematics/schematics/ng-update/update-schematic.md +209 -0
- package/schematics/schematics/ng-update/upgrade-data.ts +79 -0
- package/schematics/schematics/paths.ts +15 -0
- package/schematics/schematics/testing/BUILD.bazel +27 -0
- package/schematics/schematics/testing/file-content.ts +20 -0
- package/schematics/schematics/testing/index.ts +14 -0
- package/schematics/schematics/testing/post-scheduled-tasks.ts +45 -0
- package/schematics/schematics/testing/resolve-bazel-path.ts +46 -0
- package/schematics/schematics/testing/test-app.ts +21 -0
- package/schematics/schematics/testing/test-case-setup.ts +236 -0
- package/schematics/schematics/testing/test-library.ts +21 -0
- package/schematics/schematics/testing/test-project.ts +40 -0
- package/schematics/schematics/testing/tsconfig.json +7 -0
- package/schematics/schematics/tsconfig.json +28 -0
- package/schematics/schematics/update-tool/BUILD.bazel +19 -0
- package/schematics/schematics/update-tool/component-resource-collector.ts +195 -0
- package/schematics/schematics/update-tool/file-system.ts +78 -0
- package/schematics/schematics/update-tool/index.ts +191 -0
- package/schematics/schematics/update-tool/logger.ts +23 -0
- package/schematics/schematics/update-tool/migration.ts +88 -0
- package/schematics/schematics/update-tool/public-api.ts +16 -0
- package/schematics/schematics/update-tool/target-version.ts +31 -0
- package/schematics/schematics/update-tool/tsconfig.json +7 -0
- package/schematics/schematics/update-tool/update-recorder.ts +14 -0
- package/schematics/schematics/update-tool/utils/decorators.ts +54 -0
- package/schematics/schematics/update-tool/utils/functions.ts +18 -0
- package/schematics/schematics/update-tool/utils/imports.ts +128 -0
- package/schematics/schematics/update-tool/utils/line-mappings.ts +84 -0
- package/schematics/schematics/update-tool/utils/parse-tsconfig.ts +25 -0
- package/schematics/schematics/update-tool/utils/property-name.ts +28 -0
- package/schematics/schematics/update-tool/utils/virtual-host.ts +116 -0
- package/schematics/schematics/update-tool/version-changes.ts +49 -0
- package/schematics/schematics/utils/ast/ng-module-imports.spec.ts +43 -0
- package/schematics/schematics/utils/ast/ng-module-imports.ts +102 -0
- package/schematics/schematics/utils/ast.ts +88 -0
- package/schematics/schematics/utils/build-component.ts +252 -0
- package/schematics/schematics/utils/get-project.ts +27 -0
- package/schematics/schematics/utils/html-manipulation.ts +105 -0
- package/schematics/schematics/utils/index.ts +19 -0
- package/schematics/schematics/utils/parse5-element.ts +34 -0
- package/schematics/schematics/utils/project-index-file.ts +21 -0
- package/schematics/schematics/utils/project-main-file.ts +26 -0
- package/schematics/schematics/utils/project-style-file.ts +53 -0
- package/schematics/schematics/utils/project-targets.ts +43 -0
- package/schematics/schematics/utils/project-tsconfig-paths.spec.ts +91 -0
- package/schematics/schematics/utils/project-tsconfig-paths.ts +49 -0
- package/schematics/schematics/utils/schematic-options.ts +65 -0
- package/schematics/schematics/utils/vendored-ast-utils/index.ts +599 -0
- package/scrolling/virtual-scroll-viewport.scss +87 -0
- package/table/table.scss +3 -0
- package/text-field/_index.import.scss +2 -0
- package/text-field/_index.scss +89 -0
- package/text-field/text-field-prebuilt.scss +4 -0
- package/types/stagefright5-cdk-a11y.d.ts +1160 -0
- package/types/stagefright5-cdk-accordion.d.ts +95 -0
- package/types/stagefright5-cdk-bidi.d.ts +95 -0
- package/types/stagefright5-cdk-clipboard.d.ts +116 -0
- package/types/stagefright5-cdk-coercion.d.ts +101 -0
- package/types/stagefright5-cdk-collections.d.ts +405 -0
- package/types/stagefright5-cdk-drag-drop.d.ts +1471 -0
- package/types/stagefright5-cdk-keycodes.d.ts +142 -0
- package/types/stagefright5-cdk-layout.d.ts +96 -0
- package/types/stagefright5-cdk-observers.d.ts +91 -0
- package/types/stagefright5-cdk-overlay.d.ts +1258 -0
- package/types/stagefright5-cdk-platform.d.ts +130 -0
- package/types/stagefright5-cdk-portal.d.ts +327 -0
- package/types/stagefright5-cdk-scrolling.d.ts +631 -0
- package/types/stagefright5-cdk-stepper.d.ts +302 -0
- package/types/stagefright5-cdk-table.d.ts +1128 -0
- package/types/stagefright5-cdk-testing-protractor.d.ts +146 -0
- package/types/stagefright5-cdk-testing-selenium-webdriver.d.ts +161 -0
- package/types/stagefright5-cdk-testing-testbed.d.ts +168 -0
- package/types/stagefright5-cdk-testing.d.ts +735 -0
- package/types/stagefright5-cdk-text-field.d.ts +171 -0
- package/types/stagefright5-cdk-tree.d.ts +522 -0
- package/types/stagefright5-cdk.d.ts +14 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {parse} from 'jsonc-parser';
|
|
10
|
+
import {getSystemPath, Path} from '@angular-devkit/core';
|
|
11
|
+
import {HostTree, Tree} from '@angular-devkit/schematics';
|
|
12
|
+
import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing';
|
|
13
|
+
import {readFileSync} from 'fs-extra';
|
|
14
|
+
import {sync as globSync} from 'glob';
|
|
15
|
+
import {basename, extname, join, relative, sep} from 'path';
|
|
16
|
+
import {EMPTY} from 'rxjs';
|
|
17
|
+
import {createTestApp} from './test-app';
|
|
18
|
+
|
|
19
|
+
/** Suffix that indicates whether a given file is a test case input. */
|
|
20
|
+
const TEST_CASE_INPUT_SUFFIX = '_input.ts';
|
|
21
|
+
|
|
22
|
+
/** Suffix that indicates whether a given file is an expected output of a test case. */
|
|
23
|
+
const TEST_CASE_OUTPUT_SUFFIX = '_expected_output.ts';
|
|
24
|
+
|
|
25
|
+
/** Name of the folder that can contain test case files which should not run automatically. */
|
|
26
|
+
const MISC_FOLDER_NAME = 'misc';
|
|
27
|
+
|
|
28
|
+
/** Reads the UTF8 content of the specified file. Normalizes the path and ensures that */
|
|
29
|
+
export function readFileContent(filePath: string): string {
|
|
30
|
+
return readFileSync(filePath, 'utf8');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a test app schematic tree that will be copied over to a real filesystem location.
|
|
35
|
+
* This is necessary because otherwise the TypeScript compiler API would not be able to
|
|
36
|
+
* find source files within the tsconfig project.
|
|
37
|
+
* TODO(devversion): we should be able to make the TypeScript config parsing respect the
|
|
38
|
+
* schematic tree. This would allow us to fully take advantage of the virtual file system.
|
|
39
|
+
*/
|
|
40
|
+
export async function createFileSystemTestApp(runner: SchematicTestRunner) {
|
|
41
|
+
const hostTree = new HostTree();
|
|
42
|
+
const appTree: UnitTestTree = await createTestApp(runner, {name: 'cdk-testing'}, hostTree);
|
|
43
|
+
|
|
44
|
+
// Since the TypeScript compiler API expects all files to be present on the real file system, we
|
|
45
|
+
// map every file in the app tree to a temporary location on the file system.
|
|
46
|
+
appTree.files.forEach(f => writeFile(f, appTree.readContent(f)));
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
appTree,
|
|
50
|
+
writeFile,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function writeFile(filePath: string, content: string) {
|
|
54
|
+
// Update the temp file system host to reflect the changes in the real file system.
|
|
55
|
+
// This is still necessary since we depend on the real file system for parsing the
|
|
56
|
+
// TypeScript project.
|
|
57
|
+
if (hostTree.exists(filePath)) {
|
|
58
|
+
hostTree.overwrite(filePath, content);
|
|
59
|
+
} else {
|
|
60
|
+
hostTree.create(filePath, content);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function createTestCaseSetup(
|
|
66
|
+
migrationName: string,
|
|
67
|
+
collectionPath: string,
|
|
68
|
+
inputFiles: string[],
|
|
69
|
+
) {
|
|
70
|
+
const runner = new SchematicTestRunner('schematics', collectionPath);
|
|
71
|
+
|
|
72
|
+
let logOutput = '';
|
|
73
|
+
runner.logger.subscribe(entry => (logOutput += `${entry.message}\n`));
|
|
74
|
+
const {appTree, writeFile} = await createFileSystemTestApp(runner);
|
|
75
|
+
|
|
76
|
+
_patchTypeScriptDefaultLib(appTree);
|
|
77
|
+
|
|
78
|
+
// Write each test-case input to the file-system. This is necessary because otherwise
|
|
79
|
+
// TypeScript compiler API won't be able to pick up the test cases.
|
|
80
|
+
inputFiles.forEach(inputFilePath => {
|
|
81
|
+
const inputTestName = basename(inputFilePath, extname(inputFilePath));
|
|
82
|
+
const relativePath = `projects/cdk-testing/src/test-cases/${inputTestName}.ts`;
|
|
83
|
+
const inputContent = readFileContent(inputFilePath);
|
|
84
|
+
|
|
85
|
+
writeFile(relativePath, inputContent);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const testAppTsconfigPath = 'projects/cdk-testing/tsconfig.app.json';
|
|
89
|
+
// Parse TypeScript configuration files with JSONC (like the CLI does) as the
|
|
90
|
+
// config files could contain comments or trailing commas
|
|
91
|
+
const testAppTsconfig = parse(appTree.readContent(testAppTsconfigPath), [], {
|
|
92
|
+
allowTrailingComma: true,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// include all TypeScript files in the project. Otherwise all test input
|
|
96
|
+
// files won't be part of the program and cannot be migrated.
|
|
97
|
+
testAppTsconfig.include.push('src/**/*.ts');
|
|
98
|
+
|
|
99
|
+
writeFile(testAppTsconfigPath, JSON.stringify(testAppTsconfig, null, 2));
|
|
100
|
+
|
|
101
|
+
const runFixers = async function () {
|
|
102
|
+
// Patch "executePostTasks" to do nothing. This is necessary since
|
|
103
|
+
// we cannot run the node install task in unit tests. Rather we just
|
|
104
|
+
// assert that certain async post tasks are scheduled.
|
|
105
|
+
// TODO(devversion): RxJS version conflicts between angular-devkit and our dev deps.
|
|
106
|
+
runner.engine.executePostTasks = () => EMPTY as any;
|
|
107
|
+
|
|
108
|
+
await runner.runSchematicAsync(migrationName, {}, appTree).toPromise();
|
|
109
|
+
|
|
110
|
+
return {logOutput};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return {runner, appTree, writeFile, runFixers};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Resolves all test cases for specified path using Bazel's runfile manifest. Note that we
|
|
118
|
+
* cannot just use "glob" since the test case files are not copied to the Bazel bin directory
|
|
119
|
+
* and are just runfiles.
|
|
120
|
+
*/
|
|
121
|
+
export function findBazelVersionTestCases(basePath: string) {
|
|
122
|
+
const testCasesMap = new Map<string, string[]>();
|
|
123
|
+
const manifestPath = process.env['RUNFILES_MANIFEST_FILE']!;
|
|
124
|
+
const runfilesDir = process.env['RUNFILES'];
|
|
125
|
+
|
|
126
|
+
// In case we are not on Windows where runfiles are symlinked, we just find all
|
|
127
|
+
// test case files by using "glob" and store them in our result map.
|
|
128
|
+
if (!manifestPath) {
|
|
129
|
+
const runfilesBaseDir = join(runfilesDir!, basePath);
|
|
130
|
+
const inputFiles = globSync(`**/!(${MISC_FOLDER_NAME})/*${TEST_CASE_INPUT_SUFFIX}`, {
|
|
131
|
+
cwd: runfilesBaseDir,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
inputFiles.forEach(inputFile => {
|
|
135
|
+
// The target version of an input file will be determined from the first
|
|
136
|
+
// path segment. (e.g. "v6/my_rule_input.ts" will be for "v6")
|
|
137
|
+
const targetVersion = inputFile.split(sep)[0];
|
|
138
|
+
const resolvedInputPath = join(runfilesBaseDir, inputFile);
|
|
139
|
+
|
|
140
|
+
testCasesMap.set(
|
|
141
|
+
targetVersion,
|
|
142
|
+
(testCasesMap.get(targetVersion) || []).concat(resolvedInputPath),
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return testCasesMap;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// In case runfiles are not symlinked (e.g. on Windows), we resolve all test case files using
|
|
150
|
+
// the Bazel runfiles manifest. Read more about the manifest here:
|
|
151
|
+
// https://github.com/bazelbuild/bazel/blob/701913139adc0eba49a7a9963fea4f555fcd844f/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java#L214-L221
|
|
152
|
+
readFileSync(manifestPath, 'utf8')
|
|
153
|
+
.split('\n')
|
|
154
|
+
.forEach(line => {
|
|
155
|
+
const [runfilePath, realPath] = line.split(' ');
|
|
156
|
+
|
|
157
|
+
// In case the mapped runfile starts with the specified base path and ends with "_input.ts",
|
|
158
|
+
// we store it in our result map because we assume that this is a test case.
|
|
159
|
+
if (runfilePath.startsWith(basePath) && runfilePath.endsWith(TEST_CASE_INPUT_SUFFIX)) {
|
|
160
|
+
const pathSegments = relative(basePath, runfilePath).split(sep);
|
|
161
|
+
if (pathSegments.includes(MISC_FOLDER_NAME)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// The target version of an input file will be determined from the first
|
|
165
|
+
// path segment. (e.g. "v6/my_rule_input.ts" will be for "v6")
|
|
166
|
+
const targetVersion = pathSegments[0];
|
|
167
|
+
testCasesMap.set(targetVersion, (testCasesMap.get(targetVersion) || []).concat(realPath));
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return testCasesMap;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Sets up the specified test cases using Jasmine by creating the appropriate jasmine
|
|
176
|
+
* spec definitions. This should be used within a "describe" jasmine closure.
|
|
177
|
+
*/
|
|
178
|
+
export function defineJasmineTestCases(
|
|
179
|
+
versionName: string,
|
|
180
|
+
collectionFile: string,
|
|
181
|
+
inputFiles: string[] | undefined,
|
|
182
|
+
) {
|
|
183
|
+
// No test cases for the given version are available. Skip setting up tests for that
|
|
184
|
+
// version.
|
|
185
|
+
if (!inputFiles) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
let appTree: UnitTestTree;
|
|
190
|
+
let testCasesOutputPath: string;
|
|
191
|
+
|
|
192
|
+
beforeAll(async () => {
|
|
193
|
+
const {appTree: _tree, runFixers} = await createTestCaseSetup(
|
|
194
|
+
`migration-${versionName}`,
|
|
195
|
+
collectionFile,
|
|
196
|
+
inputFiles,
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
await runFixers();
|
|
200
|
+
|
|
201
|
+
appTree = _tree;
|
|
202
|
+
testCasesOutputPath = '/projects/cdk-testing/src/test-cases/';
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// Iterates through every test case directory and generates a jasmine test block that will
|
|
206
|
+
// verify that the update schematics properly updated the test input to the expected output.
|
|
207
|
+
inputFiles.forEach(inputFile => {
|
|
208
|
+
const inputTestName = basename(inputFile, extname(inputFile));
|
|
209
|
+
|
|
210
|
+
it(`should apply update schematics to test case: ${inputTestName}`, () => {
|
|
211
|
+
expect(appTree.readContent(join(testCasesOutputPath, `${inputTestName}.ts`))).toBe(
|
|
212
|
+
readFileContent(inputFile.replace(TEST_CASE_INPUT_SUFFIX, TEST_CASE_OUTPUT_SUFFIX)),
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Patches the specified virtual file system tree to be able to read the TypeScript
|
|
220
|
+
* default library typings. These need to be readable in unit tests because otherwise
|
|
221
|
+
* type checking within migration rules is not working as in real applications.
|
|
222
|
+
*/
|
|
223
|
+
export function _patchTypeScriptDefaultLib(tree: Tree) {
|
|
224
|
+
const _originalRead = tree.read;
|
|
225
|
+
tree.read = function (filePath: Path) {
|
|
226
|
+
// In case a file within the TypeScript package is requested, we read the file from
|
|
227
|
+
// the real file system. This is necessary because within unit tests, the "typeScript"
|
|
228
|
+
// package from within the Bazel "@npm" repository is used. The virtual tree can't be
|
|
229
|
+
// used because the "@npm" repository directory is not part of the virtual file system.
|
|
230
|
+
if (filePath.match(/node_modules[/\\]typescript/)) {
|
|
231
|
+
return readFileSync(getSystemPath(filePath));
|
|
232
|
+
} else {
|
|
233
|
+
return _originalRead.call(this, filePath);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {Tree} from '@angular-devkit/schematics';
|
|
10
|
+
import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing';
|
|
11
|
+
|
|
12
|
+
import {createTestProject} from './test-project';
|
|
13
|
+
|
|
14
|
+
/** Create a base library used for testing. */
|
|
15
|
+
export async function createTestLibrary(
|
|
16
|
+
runner: SchematicTestRunner,
|
|
17
|
+
appOptions = {},
|
|
18
|
+
tree?: Tree,
|
|
19
|
+
): Promise<UnitTestTree> {
|
|
20
|
+
return createTestProject(runner, 'library', appOptions, tree);
|
|
21
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {Tree} from '@angular-devkit/schematics';
|
|
10
|
+
import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing';
|
|
11
|
+
|
|
12
|
+
/** Create a base project used for testing. */
|
|
13
|
+
export async function createTestProject(
|
|
14
|
+
runner: SchematicTestRunner,
|
|
15
|
+
projectType: 'application' | 'library',
|
|
16
|
+
appOptions = {},
|
|
17
|
+
tree?: Tree,
|
|
18
|
+
): Promise<UnitTestTree> {
|
|
19
|
+
const workspaceTree = await runner
|
|
20
|
+
.runExternalSchematicAsync(
|
|
21
|
+
'@schematics/angular',
|
|
22
|
+
'workspace',
|
|
23
|
+
{
|
|
24
|
+
name: 'workspace',
|
|
25
|
+
version: '6.0.0',
|
|
26
|
+
newProjectRoot: 'projects',
|
|
27
|
+
},
|
|
28
|
+
tree,
|
|
29
|
+
)
|
|
30
|
+
.toPromise();
|
|
31
|
+
|
|
32
|
+
return runner
|
|
33
|
+
.runExternalSchematicAsync(
|
|
34
|
+
'@schematics/angular',
|
|
35
|
+
projectType,
|
|
36
|
+
{name: 'material', ...appOptions},
|
|
37
|
+
workspaceTree,
|
|
38
|
+
)
|
|
39
|
+
.toPromise();
|
|
40
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"declaration": true,
|
|
4
|
+
"lib": ["es2017"],
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"outDir": "../../../dist/packages/cdk/schematics",
|
|
8
|
+
"noEmitOnError": false,
|
|
9
|
+
"strictNullChecks": true,
|
|
10
|
+
"useUnknownInCatchVariables": true,
|
|
11
|
+
"noImplicitOverride": true,
|
|
12
|
+
"noImplicitReturns": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"skipDefaultLibCheck": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": true,
|
|
16
|
+
"noUnusedLocals": false,
|
|
17
|
+
"noImplicitThis": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"strictFunctionTypes": true,
|
|
20
|
+
"sourceMap": true,
|
|
21
|
+
"target": "es2015",
|
|
22
|
+
"types": ["jasmine", "node"]
|
|
23
|
+
},
|
|
24
|
+
"exclude": ["**/files/**/*", "**/*.spec.ts", "ng-update/test-cases/**/*", "testing/**/*.ts"],
|
|
25
|
+
"bazelOptions": {
|
|
26
|
+
"suppressTsconfigOverrideWarnings": true
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
load("//tools:defaults.bzl", "ts_library")
|
|
2
|
+
|
|
3
|
+
package(default_visibility = ["//visibility:public"])
|
|
4
|
+
|
|
5
|
+
ts_library(
|
|
6
|
+
name = "update-tool",
|
|
7
|
+
srcs = glob(["**/*.ts"]),
|
|
8
|
+
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
|
|
9
|
+
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
|
|
10
|
+
devmode_module = "commonjs",
|
|
11
|
+
devmode_target = "es2015",
|
|
12
|
+
prodmode_module = "commonjs",
|
|
13
|
+
prodmode_target = "es2015",
|
|
14
|
+
tsconfig = ":tsconfig.json",
|
|
15
|
+
deps = [
|
|
16
|
+
"@npm//@types/node",
|
|
17
|
+
"@npm//typescript",
|
|
18
|
+
],
|
|
19
|
+
)
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {dirname} from 'path';
|
|
10
|
+
import * as ts from 'typescript';
|
|
11
|
+
import {FileSystem, WorkspacePath} from './file-system';
|
|
12
|
+
import {getAngularDecorators} from './utils/decorators';
|
|
13
|
+
import {unwrapExpression} from './utils/functions';
|
|
14
|
+
import {
|
|
15
|
+
computeLineStartsMap,
|
|
16
|
+
getLineAndCharacterFromPosition,
|
|
17
|
+
LineAndCharacter,
|
|
18
|
+
} from './utils/line-mappings';
|
|
19
|
+
import {getPropertyNameText} from './utils/property-name';
|
|
20
|
+
|
|
21
|
+
export interface ResolvedResource {
|
|
22
|
+
/** Class declaration that contains this resource. */
|
|
23
|
+
container: ts.ClassDeclaration | null;
|
|
24
|
+
/** File content of the given template. */
|
|
25
|
+
content: string;
|
|
26
|
+
/** Start offset of the resource content (e.g. in the inline source file) */
|
|
27
|
+
start: number;
|
|
28
|
+
/** Whether the given resource is inline or not. */
|
|
29
|
+
inline: boolean;
|
|
30
|
+
/** Path to the file that contains this resource. */
|
|
31
|
+
filePath: WorkspacePath;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the character and line of a given position index in the resource.
|
|
34
|
+
* If the resource is declared inline within a TypeScript source file, the line and
|
|
35
|
+
* character are based on the full source file content.
|
|
36
|
+
*/
|
|
37
|
+
getCharacterAndLineOfPosition: (pos: number) => LineAndCharacter;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Collector that can be used to find Angular templates and stylesheets referenced within
|
|
42
|
+
* given TypeScript source files (inline or external referenced files)
|
|
43
|
+
*/
|
|
44
|
+
export class ComponentResourceCollector {
|
|
45
|
+
resolvedTemplates: ResolvedResource[] = [];
|
|
46
|
+
resolvedStylesheets: ResolvedResource[] = [];
|
|
47
|
+
|
|
48
|
+
constructor(public typeChecker: ts.TypeChecker, private _fileSystem: FileSystem) {}
|
|
49
|
+
|
|
50
|
+
visitNode(node: ts.Node) {
|
|
51
|
+
if (node.kind === ts.SyntaxKind.ClassDeclaration) {
|
|
52
|
+
this._visitClassDeclaration(node as ts.ClassDeclaration);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private _visitClassDeclaration(node: ts.ClassDeclaration) {
|
|
57
|
+
if (!node.decorators || !node.decorators.length) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const ngDecorators = getAngularDecorators(this.typeChecker, node.decorators);
|
|
62
|
+
const componentDecorator = ngDecorators.find(dec => dec.name === 'Component');
|
|
63
|
+
|
|
64
|
+
// In case no "@Component" decorator could be found on the current class, skip.
|
|
65
|
+
if (!componentDecorator) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const decoratorCall = componentDecorator.node.expression;
|
|
70
|
+
|
|
71
|
+
// In case the component decorator call is not valid, skip this class declaration.
|
|
72
|
+
if (decoratorCall.arguments.length !== 1) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const componentMetadata = unwrapExpression(decoratorCall.arguments[0]);
|
|
77
|
+
|
|
78
|
+
// Ensure that the component metadata is an object literal expression.
|
|
79
|
+
if (!ts.isObjectLiteralExpression(componentMetadata)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const sourceFile = node.getSourceFile();
|
|
84
|
+
const filePath = this._fileSystem.resolve(sourceFile.fileName);
|
|
85
|
+
const sourceFileDirPath = dirname(sourceFile.fileName);
|
|
86
|
+
|
|
87
|
+
// Walk through all component metadata properties and determine the referenced
|
|
88
|
+
// HTML templates (either external or inline)
|
|
89
|
+
componentMetadata.properties.forEach(property => {
|
|
90
|
+
if (!ts.isPropertyAssignment(property)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const propertyName = getPropertyNameText(property.name);
|
|
95
|
+
|
|
96
|
+
if (propertyName === 'styles' && ts.isArrayLiteralExpression(property.initializer)) {
|
|
97
|
+
property.initializer.elements.forEach(el => {
|
|
98
|
+
if (ts.isStringLiteralLike(el)) {
|
|
99
|
+
// Need to add an offset of one to the start because the template quotes are
|
|
100
|
+
// not part of the template content.
|
|
101
|
+
const templateStartIdx = el.getStart() + 1;
|
|
102
|
+
this.resolvedStylesheets.push({
|
|
103
|
+
filePath,
|
|
104
|
+
container: node,
|
|
105
|
+
content: el.text,
|
|
106
|
+
inline: true,
|
|
107
|
+
start: templateStartIdx,
|
|
108
|
+
getCharacterAndLineOfPosition: pos =>
|
|
109
|
+
ts.getLineAndCharacterOfPosition(sourceFile, pos + templateStartIdx),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// In case there is an inline template specified, ensure that the value is statically
|
|
116
|
+
// analyzable by checking if the initializer is a string literal-like node.
|
|
117
|
+
if (propertyName === 'template' && ts.isStringLiteralLike(property.initializer)) {
|
|
118
|
+
// Need to add an offset of one to the start because the template quotes are
|
|
119
|
+
// not part of the template content.
|
|
120
|
+
const templateStartIdx = property.initializer.getStart() + 1;
|
|
121
|
+
this.resolvedTemplates.push({
|
|
122
|
+
filePath,
|
|
123
|
+
container: node,
|
|
124
|
+
content: property.initializer.text,
|
|
125
|
+
inline: true,
|
|
126
|
+
start: templateStartIdx,
|
|
127
|
+
getCharacterAndLineOfPosition: pos =>
|
|
128
|
+
ts.getLineAndCharacterOfPosition(sourceFile, pos + templateStartIdx),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (propertyName === 'styleUrls' && ts.isArrayLiteralExpression(property.initializer)) {
|
|
133
|
+
property.initializer.elements.forEach(el => {
|
|
134
|
+
if (ts.isStringLiteralLike(el)) {
|
|
135
|
+
const stylesheetPath = this._fileSystem.resolve(sourceFileDirPath, el.text);
|
|
136
|
+
const stylesheet = this.resolveExternalStylesheet(stylesheetPath, node);
|
|
137
|
+
|
|
138
|
+
if (stylesheet) {
|
|
139
|
+
this.resolvedStylesheets.push(stylesheet);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (propertyName === 'templateUrl' && ts.isStringLiteralLike(property.initializer)) {
|
|
146
|
+
const templateUrl = property.initializer.text;
|
|
147
|
+
const templatePath = this._fileSystem.resolve(sourceFileDirPath, templateUrl);
|
|
148
|
+
|
|
149
|
+
// In case the template does not exist in the file system, skip this
|
|
150
|
+
// external template.
|
|
151
|
+
if (!this._fileSystem.fileExists(templatePath)) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const fileContent = this._fileSystem.read(templatePath);
|
|
156
|
+
|
|
157
|
+
if (fileContent) {
|
|
158
|
+
const lineStartsMap = computeLineStartsMap(fileContent);
|
|
159
|
+
|
|
160
|
+
this.resolvedTemplates.push({
|
|
161
|
+
filePath: templatePath,
|
|
162
|
+
container: node,
|
|
163
|
+
content: fileContent,
|
|
164
|
+
inline: false,
|
|
165
|
+
start: 0,
|
|
166
|
+
getCharacterAndLineOfPosition: p => getLineAndCharacterFromPosition(lineStartsMap, p),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Resolves an external stylesheet by reading its content and computing line mappings. */
|
|
174
|
+
resolveExternalStylesheet(
|
|
175
|
+
filePath: WorkspacePath,
|
|
176
|
+
container: ts.ClassDeclaration | null,
|
|
177
|
+
): ResolvedResource | null {
|
|
178
|
+
const fileContent = this._fileSystem.read(filePath);
|
|
179
|
+
|
|
180
|
+
if (!fileContent) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const lineStartsMap = computeLineStartsMap(fileContent);
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
filePath: filePath,
|
|
188
|
+
container: container,
|
|
189
|
+
content: fileContent,
|
|
190
|
+
inline: false,
|
|
191
|
+
start: 0,
|
|
192
|
+
getCharacterAndLineOfPosition: pos => getLineAndCharacterFromPosition(lineStartsMap, pos),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {UpdateRecorder} from './update-recorder';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A workspace path semantically is equivalent to the `Path` type provided by the
|
|
13
|
+
* Angular devkit. Paths denoted with such a type are guaranteed to be representing
|
|
14
|
+
* paths of a given virtual file system. This means that the root of a path can be
|
|
15
|
+
* different, and does not necessarily need to match the root in the real file system.
|
|
16
|
+
*
|
|
17
|
+
* For example: Consider we have a project in `/home/<..>/my-project`. Then a path
|
|
18
|
+
* like `/package.json` could actually refer to the `package.json` file in `my-project`.
|
|
19
|
+
* Note that in the real file system this would not match though.
|
|
20
|
+
*
|
|
21
|
+
* One wonder why another type has been declared for such paths, when there already
|
|
22
|
+
* is the `Path` type provided by the devkit. We do this for a couple of reasons:
|
|
23
|
+
*
|
|
24
|
+
* 1. The update-tool cannot have a dependency on the Angular devkit as that one
|
|
25
|
+
* is not synced into g3. We want to be able to run migrations in g3 if needed.
|
|
26
|
+
*/
|
|
27
|
+
export type WorkspacePath = string & {
|
|
28
|
+
// Brand signature matches the devkit paths so that existing path
|
|
29
|
+
// utilities from the Angular devkit can be conveniently used.
|
|
30
|
+
__PRIVATE_DEVKIT_PATH: void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** Interface that describes a directory. */
|
|
34
|
+
export interface DirectoryEntry {
|
|
35
|
+
/** List of directories inside the directory. */
|
|
36
|
+
directories: string[];
|
|
37
|
+
/** List of files inside the directory. */
|
|
38
|
+
files: string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Abstraction of the file system that migrations can use to record and apply
|
|
43
|
+
* changes. This is necessary to support virtual file systems as used in the CLI devkit.
|
|
44
|
+
*/
|
|
45
|
+
export abstract class FileSystem {
|
|
46
|
+
/** Checks whether the given file exists. */
|
|
47
|
+
abstract fileExists(path: WorkspacePath): boolean;
|
|
48
|
+
/** Checks whether the given directory exists. */
|
|
49
|
+
abstract directoryExists(path: WorkspacePath): boolean;
|
|
50
|
+
/** Gets the contents of the given file. */
|
|
51
|
+
abstract read(filePath: WorkspacePath): string | null;
|
|
52
|
+
/** Reads the given directory to retrieve children. */
|
|
53
|
+
abstract readDirectory(dirPath: WorkspacePath): DirectoryEntry;
|
|
54
|
+
/**
|
|
55
|
+
* Creates an update recorder for the given file. Edits can be recorded and
|
|
56
|
+
* committed in batches. Changes are not applied automatically because otherwise
|
|
57
|
+
* migrations would need to re-read files, or account for shifted file contents.
|
|
58
|
+
*/
|
|
59
|
+
abstract edit(filePath: WorkspacePath): UpdateRecorder;
|
|
60
|
+
/** Applies all changes which have been recorded in update recorders. */
|
|
61
|
+
abstract commitEdits(): void;
|
|
62
|
+
/** Creates a new file with the given content. */
|
|
63
|
+
abstract create(filePath: WorkspacePath, content: string): void;
|
|
64
|
+
/** Overwrites an existing file with the given content. */
|
|
65
|
+
abstract overwrite(filePath: WorkspacePath, content: string): void;
|
|
66
|
+
/** Deletes the given file. */
|
|
67
|
+
abstract delete(filePath: WorkspacePath): void;
|
|
68
|
+
/**
|
|
69
|
+
* Resolves given paths to a resolved path in the file system. For example, the devkit
|
|
70
|
+
* tree considers the actual workspace directory as file system root.
|
|
71
|
+
*
|
|
72
|
+
* Follows the same semantics as the native path `resolve` method. i.e. segments
|
|
73
|
+
* are processed in reverse. The last segment is considered the target and the
|
|
74
|
+
* function will iterate from the target through other segments until it finds an
|
|
75
|
+
* absolute path segment.
|
|
76
|
+
*/
|
|
77
|
+
abstract resolve(...segments: string[]): WorkspacePath;
|
|
78
|
+
}
|