@rnx-kit/cli 0.12.4 → 0.12.5
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/CHANGELOG.md +6 -0
- package/coverage/clover.xml +82 -73
- package/coverage/coverage-final.json +2 -2
- package/coverage/lcov-report/index.html +22 -22
- package/coverage/lcov-report/src/bundle/index.html +1 -1
- package/coverage/lcov-report/src/bundle/kit-config.ts.html +1 -1
- package/coverage/lcov-report/src/bundle/metro.ts.html +1 -1
- package/coverage/lcov-report/src/bundle/overrides.ts.html +1 -1
- package/coverage/lcov-report/src/copy-assets.ts.html +1 -1
- package/coverage/lcov-report/src/index.html +16 -16
- package/coverage/lcov-report/src/metro-config.ts.html +40 -22
- package/coverage/lcov-report/src/typescript/index.html +13 -13
- package/coverage/lcov-report/src/typescript/project-cache.ts.html +97 -16
- package/coverage/lcov.info +133 -116
- package/lib/metro-config.d.ts.map +1 -1
- package/lib/metro-config.js +17 -8
- package/lib/metro-config.js.map +1 -1
- package/lib/typescript/project-cache.d.ts +1 -1
- package/lib/typescript/project-cache.d.ts.map +1 -1
- package/lib/typescript/project-cache.js +26 -4
- package/lib/typescript/project-cache.js.map +1 -1
- package/package.json +1 -1
- package/src/metro-config.ts +17 -11
- package/src/typescript/project-cache.ts +35 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-cache.js","sourceRoot":"","sources":["../../src/typescript/project-cache.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAqD;AACrD,mEAG8C;AAC9C,gGAA+F;AAC/F,oEAIqC;AACrC,gDAAwB;AACxB,4DAA4B;
|
|
1
|
+
{"version":3,"file":"project-cache.js","sourceRoot":"","sources":["../../src/typescript/project-cache.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAqD;AACrD,mEAG8C;AAC9C,gGAA+F;AAC/F,oEAIqC;AACrC,4CAAoB;AACpB,gDAAwB;AACxB,4DAA4B;AAwC5B;;;;;GAKG;AACH,SAAgB,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SerializerHook(options: TypeScriptValidationOptions) {
|
|
|
62
62
|
excludeNodeModules
|
|
63
63
|
);
|
|
64
64
|
|
|
65
|
-
//
|
|
65
|
+
// Try to map each file to a TypeScript project, and apply its delta operation.
|
|
66
|
+
// Some projects may not actually be TypeScript projects (ignore those).
|
|
66
67
|
const tsprojectsToValidate: Set<Project> = new Set();
|
|
67
68
|
adds.concat(updates).forEach((sourceFile) => {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const projectInfo = projectCache.getProjectInfo(sourceFile, platform);
|
|
70
|
+
if (projectInfo) {
|
|
71
|
+
// This is a TypeScript project. Validate it.
|
|
72
|
+
const { tsproject, tssourceFiles } = projectInfo;
|
|
73
|
+
if (tssourceFiles.has(sourceFile)) {
|
|
74
|
+
tsproject.setFile(sourceFile);
|
|
75
|
+
tsprojectsToValidate.add(tsproject);
|
|
76
|
+
}
|
|
75
77
|
}
|
|
76
78
|
});
|
|
77
79
|
deletes.forEach((sourceFile) => {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
const projectInfo = projectCache.getProjectInfo(sourceFile, platform);
|
|
81
|
+
if (projectInfo) {
|
|
82
|
+
// This is a TypeScript project. Validate it.
|
|
83
|
+
const { tsproject } = projectInfo;
|
|
84
|
+
tsproject.removeFile(sourceFile);
|
|
85
|
+
tsprojectsToValidate.add(tsproject);
|
|
86
|
+
}
|
|
81
87
|
});
|
|
82
88
|
|
|
83
89
|
// Validate all projects which changed, printing all type errors.
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Project,
|
|
10
10
|
readConfigFile,
|
|
11
11
|
} from "@rnx-kit/typescript-service";
|
|
12
|
+
import fs from "fs";
|
|
12
13
|
import path from "path";
|
|
13
14
|
import ts from "typescript";
|
|
14
15
|
|
|
@@ -44,7 +45,10 @@ export interface ProjectCache {
|
|
|
44
45
|
* @param sourceFile Source file
|
|
45
46
|
* @returns Project targeting the given platform and containing the given source file
|
|
46
47
|
*/
|
|
47
|
-
getProjectInfo(
|
|
48
|
+
getProjectInfo(
|
|
49
|
+
sourceFile: string,
|
|
50
|
+
platform: AllPlatforms
|
|
51
|
+
): ProjectInfo | undefined;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
/**
|
|
@@ -84,8 +88,19 @@ export function createProjectCache(
|
|
|
84
88
|
return root;
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
function readTSConfig(root: string): ts.ParsedCommandLine {
|
|
91
|
+
function readTSConfig(root: string): ts.ParsedCommandLine | undefined {
|
|
88
92
|
const configFileName = path.join(root, "tsconfig.json");
|
|
93
|
+
if (!fs.existsSync(configFileName)) {
|
|
94
|
+
// Allow for packages that aren't TypeScript.
|
|
95
|
+
//
|
|
96
|
+
// Example: Users who enable bundling with all the config defaults will
|
|
97
|
+
// have type validation enabled automatically. They may not actually be
|
|
98
|
+
// using TypeScript.
|
|
99
|
+
//
|
|
100
|
+
// We shouldn't break them. We should use TS validation only for TS packages.
|
|
101
|
+
//
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
89
104
|
|
|
90
105
|
const cmdLine = readConfigFile(configFileName);
|
|
91
106
|
if (!cmdLine) {
|
|
@@ -102,9 +117,13 @@ export function createProjectCache(
|
|
|
102
117
|
function createProjectInfo(
|
|
103
118
|
root: string,
|
|
104
119
|
platform: AllPlatforms
|
|
105
|
-
): ProjectInfo {
|
|
120
|
+
): ProjectInfo | undefined {
|
|
106
121
|
// Load the TypeScript configuration file for this project.
|
|
107
122
|
const cmdLine = readTSConfig(root);
|
|
123
|
+
if (!cmdLine) {
|
|
124
|
+
// Not a TypeScript project
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
108
127
|
|
|
109
128
|
// Trim down the list of source files found by TypeScript. This ensures
|
|
110
129
|
// that only explicitly added files are loaded and parsed by TypeScript.
|
|
@@ -151,15 +170,23 @@ export function createProjectCache(
|
|
|
151
170
|
function getProjectInfo(
|
|
152
171
|
sourceFile: string,
|
|
153
172
|
platform: AllPlatforms
|
|
154
|
-
): ProjectInfo {
|
|
173
|
+
): ProjectInfo | undefined {
|
|
155
174
|
const root = findProjectRoot(sourceFile);
|
|
156
175
|
projects[root] ||= {};
|
|
157
176
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
177
|
+
const platforms = projects[root];
|
|
178
|
+
|
|
179
|
+
// Have we seen the project/platform for this source file before,
|
|
180
|
+
// even if what we saw is 'undefined' (e.g. not a TS project)?
|
|
181
|
+
if (Object.prototype.hasOwnProperty.call(platforms, platform)) {
|
|
182
|
+
return platforms[platform];
|
|
162
183
|
}
|
|
184
|
+
|
|
185
|
+
// We haven't seen this project/platform before. Try to load it,
|
|
186
|
+
// even if it isn't a TS project. Cache the result so we don't
|
|
187
|
+
// do this again.
|
|
188
|
+
const info = createProjectInfo(root, platform);
|
|
189
|
+
platforms[platform] = info;
|
|
163
190
|
return info;
|
|
164
191
|
}
|
|
165
192
|
|