@bluestep-systems/b6p-core 0.9.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +264 -25
- package/dist/B6PCore.d.ts +7 -0
- package/dist/B6PCore.js +54 -1
- package/dist/B6PCore.js.map +1 -1
- package/dist/B6PUri.d.ts +6 -8
- package/dist/B6PUri.js +6 -8
- package/dist/B6PUri.js.map +1 -1
- package/dist/Err.d.ts +415 -0
- package/dist/Err.js +552 -0
- package/dist/Err.js.map +1 -1
- package/dist/auth/BearerAuthProvider.d.ts +32 -0
- package/dist/auth/BearerAuthProvider.js +49 -0
- package/dist/auth/BearerAuthProvider.js.map +1 -1
- package/dist/cache/OrgCache.js.map +1 -1
- package/dist/cache/ScriptMetaDataStore.js.map +1 -1
- package/dist/constants/ApiEndpoints.d.ts +1 -0
- package/dist/constants/ApiEndpoints.js +1 -0
- package/dist/constants/ApiEndpoints.js.map +1 -1
- package/dist/constants/AuthTypes.js.map +1 -1
- package/dist/constants/BlueHQ.js.map +1 -1
- package/dist/constants/CryptoAlgorithms.js.map +1 -1
- package/dist/constants/ExtensionConfig.js.map +1 -1
- package/dist/constants/FileExtensions.js.map +1 -1
- package/dist/constants/FolderNames.js.map +1 -1
- package/dist/constants/Gateway.d.ts +71 -0
- package/dist/constants/Gateway.js +79 -0
- package/dist/constants/Gateway.js.map +1 -0
- package/dist/constants/GitHubUrls.js.map +1 -1
- package/dist/constants/Http.js.map +1 -1
- package/dist/constants/MimeTypes.js.map +1 -1
- package/dist/constants/Numerical.js.map +1 -1
- package/dist/constants/OutputChannels.js.map +1 -1
- package/dist/constants/SettingsKeys.d.ts +5 -0
- package/dist/constants/SettingsKeys.js +5 -0
- package/dist/constants/SettingsKeys.js.map +1 -1
- package/dist/constants/SpecialFiles.js.map +1 -1
- package/dist/constants/WebDAVElements.js.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +3 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/data/DownstairsPathParser.js.map +1 -1
- package/dist/data/GlobMatcher.js.map +1 -1
- package/dist/data/IdUtility.js.map +1 -1
- package/dist/data/OrgWorker.js.map +1 -1
- package/dist/data/ScriptKey.js.map +1 -1
- package/dist/data/ScriptUrlParser.js.map +1 -1
- package/dist/data/ServerVersion.d.ts +76 -0
- package/dist/data/ServerVersion.js +111 -0
- package/dist/data/ServerVersion.js.map +1 -0
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.js +7 -1
- package/dist/data/index.js.map +1 -1
- package/dist/gateway/GatewayClient.d.ts +147 -0
- package/dist/gateway/GatewayClient.js +395 -0
- package/dist/gateway/GatewayClient.js.map +1 -0
- package/dist/gateway/GatewayContext.d.ts +43 -0
- package/dist/gateway/GatewayContext.js +3 -0
- package/dist/gateway/GatewayContext.js.map +1 -0
- package/dist/gateway/GatewayGit.d.ts +291 -0
- package/dist/gateway/GatewayGit.js +731 -0
- package/dist/gateway/GatewayGit.js.map +1 -0
- package/dist/gateway/GatewayKb.d.ts +173 -0
- package/dist/gateway/GatewayKb.js +354 -0
- package/dist/gateway/GatewayKb.js.map +1 -0
- package/dist/gateway/GatewayMarketplace.d.ts +116 -0
- package/dist/gateway/GatewayMarketplace.js +278 -0
- package/dist/gateway/GatewayMarketplace.js.map +1 -0
- package/dist/gateway/GatewayService.d.ts +47 -0
- package/dist/gateway/GatewayService.js +54 -0
- package/dist/gateway/GatewayService.js.map +1 -0
- package/dist/gateway/GatewayToken.d.ts +18 -0
- package/dist/gateway/GatewayToken.js +43 -0
- package/dist/gateway/GatewayToken.js.map +1 -0
- package/dist/gateway/GatewayTokenService.d.ts +101 -0
- package/dist/gateway/GatewayTokenService.js +465 -0
- package/dist/gateway/GatewayTokenService.js.map +1 -0
- package/dist/index.d.ts +24 -9
- package/dist/index.js +33 -7
- package/dist/index.js.map +1 -1
- package/dist/network/HttpClient.js.map +1 -1
- package/dist/network/HttpClientProvider.js.map +1 -1
- package/dist/network/StatusCodes.js.map +1 -1
- package/dist/persistence/PersistablePseudoMap.js.map +1 -1
- package/dist/persistence/PersistenceKeys.js.map +1 -1
- package/dist/persistence/PrivatePersistanceMap.js.map +1 -1
- package/dist/persistence/PseudoMap.js.map +1 -1
- package/dist/persistence/PublicPersistanceMap.js.map +1 -1
- package/dist/persistence/Serializable.js.map +1 -1
- package/dist/persistence/SharedFilePersistence.d.ts +22 -0
- package/dist/persistence/SharedFilePersistence.js +65 -14
- package/dist/persistence/SharedFilePersistence.js.map +1 -1
- package/dist/persistence/TypedMap.js.map +1 -1
- package/dist/persistence/TypedPersistable.js.map +1 -1
- package/dist/persistence/TypedPrivatePersistable.js.map +1 -1
- package/dist/persistence/dirLockdown.js.map +1 -1
- package/dist/providers.d.ts +36 -19
- package/dist/script/GitIdentity.js.map +1 -1
- package/dist/script/GitSync.d.ts +78 -11
- package/dist/script/GitSync.js +84 -17
- package/dist/script/GitSync.js.map +1 -1
- package/dist/script/ScriptContext.d.ts +1 -8
- package/dist/script/ScriptFactory.d.ts +1 -2
- package/dist/script/ScriptFactory.js +1 -2
- package/dist/script/ScriptFactory.js.map +1 -1
- package/dist/script/ScriptFile.js.map +1 -1
- package/dist/script/ScriptFolder.js.map +1 -1
- package/dist/script/ScriptNode.js.map +1 -1
- package/dist/script/ScriptRoot.d.ts +0 -63
- package/dist/script/ScriptRoot.js +0 -178
- package/dist/script/ScriptRoot.js.map +1 -1
- package/dist/script/ScriptService.d.ts +45 -11
- package/dist/script/ScriptService.js +44 -6
- package/dist/script/ScriptService.js.map +1 -1
- package/dist/script/ServerCompile.d.ts +35 -0
- package/dist/script/ServerCompile.js +40 -0
- package/dist/script/ServerCompile.js.map +1 -0
- package/dist/script/TsConfig.d.ts +2 -2
- package/dist/script/TsConfig.js +3 -3
- package/dist/script/TsConfig.js.map +1 -1
- package/dist/script/push.d.ts +117 -77
- package/dist/script/push.js +151 -170
- package/dist/script/push.js.map +1 -1
- package/dist/session/SessionManager.js.map +1 -1
- package/dist/testing/FakeGateway.d.ts +280 -0
- package/dist/testing/FakeGateway.js +627 -0
- package/dist/testing/FakeGateway.js.map +1 -0
- package/dist/testing/MockFileSystem.js.map +1 -1
- package/dist/types.d.ts +332 -0
- package/dist/update/UpdateService.js.map +1 -1
- package/package.json +8 -7
- package/dist/script/ScriptTranspiler.d.ts +0 -183
- package/dist/script/ScriptTranspiler.js +0 -425
- package/dist/script/ScriptTranspiler.js.map +0 -1
- package/dist/script/TsLibResolver.d.ts +0 -60
- package/dist/script/TsLibResolver.js +0 -134
- package/dist/script/TsLibResolver.js.map +0 -1
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.ScriptTranspiler = void 0;
|
|
40
|
-
exports.buildUncleanReasons = buildUncleanReasons;
|
|
41
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
42
|
-
const path = __importStar(require("path"));
|
|
43
|
-
const Err_1 = require("../Err");
|
|
44
|
-
const constants_1 = require("../constants");
|
|
45
|
-
const B6PUri_1 = require("../B6PUri");
|
|
46
|
-
const ScriptFactory_1 = require("./ScriptFactory");
|
|
47
|
-
const TsLibResolver_1 = require("./TsLibResolver");
|
|
48
|
-
/**
|
|
49
|
-
* Why a build is not fully clean (build manifest spec §6), empty when it is: a project reported an error diagnostic,
|
|
50
|
-
* has a tsconfig with configuration diagnostics, sets `noEmit`, had its emit skipped or withheld, emitted nothing, or
|
|
51
|
-
* wrote output outside the tree.
|
|
52
|
-
* @param draftRoot The draft folder every output must be under; when absent that check is skipped
|
|
53
|
-
* @lastreviewed null
|
|
54
|
-
*/
|
|
55
|
-
function buildUncleanReasons(reports, draftRoot) {
|
|
56
|
-
const reasons = [];
|
|
57
|
-
for (const r of reports) {
|
|
58
|
-
if (r.errorCount > 0) {
|
|
59
|
-
reasons.push(`${r.tsConfigPath}: ${r.errorCount} syntax or emit error(s)`);
|
|
60
|
-
}
|
|
61
|
-
if (r.configErrorCount > 0) {
|
|
62
|
-
reasons.push(`${r.tsConfigPath}: the tsconfig has ${r.configErrorCount} configuration diagnostic(s)`);
|
|
63
|
-
}
|
|
64
|
-
if (r.noEmit) {
|
|
65
|
-
reasons.push(`${r.tsConfigPath}: sets noEmit`);
|
|
66
|
-
}
|
|
67
|
-
if (r.emitSkipped) {
|
|
68
|
-
reasons.push(`${r.tsConfigPath}: its emit was skipped or withheld`);
|
|
69
|
-
}
|
|
70
|
-
if (!r.emitSkipped && !r.noEmit && r.emittedFiles.length === 0) {
|
|
71
|
-
reasons.push(`${r.tsConfigPath}: emitted nothing`);
|
|
72
|
-
}
|
|
73
|
-
if (draftRoot !== undefined) {
|
|
74
|
-
const root = path.resolve(draftRoot);
|
|
75
|
-
const outside = r.emittedFiles.filter((f) => {
|
|
76
|
-
const relative = path.relative(root, path.resolve(f));
|
|
77
|
-
return relative.startsWith("..") || path.isAbsolute(relative);
|
|
78
|
-
});
|
|
79
|
-
if (outside.length > 0) {
|
|
80
|
-
reasons.push(`${r.tsConfigPath}: wrote ${outside.length} output file(s) outside the draft folder`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return reasons;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Compiler for TypeScript files in script projects.
|
|
88
|
-
* Manages compilation of multiple TypeScript files organized by their tsconfig.json files.
|
|
89
|
-
* @lastreviewed 2025-10-01
|
|
90
|
-
*/
|
|
91
|
-
class ScriptTranspiler {
|
|
92
|
-
ctx;
|
|
93
|
-
projects = new Map();
|
|
94
|
-
static DEFAULT_TS_CONFIG = {
|
|
95
|
-
module: typescript_1.default.ModuleKind.ESNext,
|
|
96
|
-
target: typescript_1.default.ScriptTarget.ES2022,
|
|
97
|
-
outDir: constants_1.FolderNames.DOT_BUILD,
|
|
98
|
-
strict: true,
|
|
99
|
-
esModuleInterop: true,
|
|
100
|
-
skipLibCheck: true,
|
|
101
|
-
forceConsistentCasingInFileNames: true,
|
|
102
|
-
sourceMap: false,
|
|
103
|
-
inlineSourceMap: false,
|
|
104
|
-
allowJs: false,
|
|
105
|
-
noEmitOnError: false,
|
|
106
|
-
suppressOutputPathCheck: true,
|
|
107
|
-
declarationDir: undefined,
|
|
108
|
-
declaration: false,
|
|
109
|
-
listEmittedFiles: true,
|
|
110
|
-
};
|
|
111
|
-
constructor(ctx) {
|
|
112
|
-
this.ctx = ctx;
|
|
113
|
-
}
|
|
114
|
-
getDefaultOptions(sf) {
|
|
115
|
-
throw new Err_1.Err.InvalidStateError("did not find a tsconfig for " + sf.path() + ".");
|
|
116
|
-
const LOCAL_CONFIG = ScriptTranspiler.DEFAULT_TS_CONFIG;
|
|
117
|
-
LOCAL_CONFIG.rootDir = sf.getScriptRoot().getDraftFolder().path();
|
|
118
|
-
return LOCAL_CONFIG;
|
|
119
|
-
}
|
|
120
|
-
async getProjectConfig(sn) {
|
|
121
|
-
const tsConfigFile = await sn.getClosestTsConfigFile();
|
|
122
|
-
if (!tsConfigFile) {
|
|
123
|
-
this.ctx.logger.info("No tsconfig.json found, using default compiler options.");
|
|
124
|
-
return { options: this.getDefaultOptions(sn), declarationRootFiles: [], configErrorCount: 0 };
|
|
125
|
-
}
|
|
126
|
-
const tsconfigTextArray = await this.ctx.fs.readFile(B6PUri_1.B6PUri.fromFsPath(tsConfigFile.uri().fsPath));
|
|
127
|
-
const pseudoParsedConfig = typescript_1.default.parseConfigFileTextToJson(tsConfigFile.path(), Buffer.from(tsconfigTextArray).toString("utf-8"));
|
|
128
|
-
if (pseudoParsedConfig.error) {
|
|
129
|
-
const message = typescript_1.default.flattenDiagnosticMessageText(pseudoParsedConfig.error.messageText, "\n");
|
|
130
|
-
throw new Err_1.Err.CompilationError(`Error parsing tsconfig.json at ${tsConfigFile.path()}: ${message}`);
|
|
131
|
-
}
|
|
132
|
-
pseudoParsedConfig.config.compilerOptions = pseudoParsedConfig.config.compilerOptions ?? {};
|
|
133
|
-
pseudoParsedConfig.config.compilerOptions.rootDir = tsConfigFile.folder().path();
|
|
134
|
-
// Resolve the ambient declaration files the tsconfig's include/files pull in
|
|
135
|
-
// BEFORE the options-only parse below stubs out readDirectory. Without this
|
|
136
|
-
// the transpile can't see the platform globals and the type-check is a
|
|
137
|
-
// syntax check only (see resolveDeclarationRootFiles).
|
|
138
|
-
const declarationRootFiles = ScriptTranspiler.resolveDeclarationRootFiles(tsConfigFile.path(), pseudoParsedConfig.config);
|
|
139
|
-
if (declarationRootFiles.length > 0) {
|
|
140
|
-
this.ctx.logger.info(`Including ${declarationRootFiles.length} declaration file(s) in the type-check:\n` +
|
|
141
|
-
declarationRootFiles.join("\n"));
|
|
142
|
-
}
|
|
143
|
-
// The "no declarations resolved" case is NOT warned here: a client-bundle
|
|
144
|
-
// tsconfig (e.g. a MergeReport `static/`) legitimately pulls in none, so a
|
|
145
|
-
// per-project warning would fire on every such push. transpile() warns only
|
|
146
|
-
// for the gated draft-root project, where empty declarations really do mean
|
|
147
|
-
// an ineffective type-check.
|
|
148
|
-
const parsedConfig = typescript_1.default.parseJsonConfigFileContent(pseudoParsedConfig.config, {
|
|
149
|
-
...typescript_1.default.sys,
|
|
150
|
-
readDirectory: () => [],
|
|
151
|
-
}, tsConfigFile.folder().path(), undefined, tsConfigFile.path());
|
|
152
|
-
this.ctx.logger.info("Using tsconfig.json compiler options from:", tsConfigFile.path());
|
|
153
|
-
// TS18003 (no inputs) always appears here: the file list is supplied separately, the directory read is stubbed.
|
|
154
|
-
const configErrorCount = parsedConfig.errors.filter((e) => e.code !== 18003).length;
|
|
155
|
-
return {
|
|
156
|
-
options: ScriptTranspiler.applyTranspileInvariants(parsedConfig.options),
|
|
157
|
-
declarationRootFiles,
|
|
158
|
-
configErrorCount,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Resolve the ambient declaration files (`*.d.ts`) a tsconfig pulls in via its
|
|
163
|
-
* `include`/`files`. These carry the platform globals — `B`, `console`, the
|
|
164
|
-
* generated `MEFR_*`/`Record_*` types, the `Bluestep` namespace, imported
|
|
165
|
-
* query globals — declared in the component's sibling `declarations/` tree
|
|
166
|
-
* (a real draft tsconfig's `include` starts with `../declarations/index.d.ts`).
|
|
167
|
-
*
|
|
168
|
-
* The transpile builds its own root-file list by walking the `draft/` folder
|
|
169
|
-
* and parses the tsconfig with `readDirectory: () => []`, so the tsconfig's
|
|
170
|
-
* `include` — which points OUTSIDE `draft/` — is otherwise dropped. That left
|
|
171
|
-
* every platform global an unresolved "Cannot find name" and reduced the only
|
|
172
|
-
* pre-publish type-check to a syntax check, so a push shipped un-type-checked
|
|
173
|
-
* JavaScript while reporting success (ClickUp 86bbeb659). Ambient `.d.ts`
|
|
174
|
-
* emit no JavaScript, so adding them to the program's root files fixes the
|
|
175
|
-
* type-check without changing the emitted-file set — the same effect as a
|
|
176
|
-
* hand-written `/// <reference path="../../declarations/index.d.ts" />`.
|
|
177
|
-
*
|
|
178
|
-
* Resolution uses the real `ts.sys` (not the stubbed `readDirectory`) so
|
|
179
|
-
* globbed includes resolve, then keeps only existing `.d.ts` so a stale
|
|
180
|
-
* include entry cannot itself introduce a "file not found" diagnostic.
|
|
181
|
-
* @lastreviewed null
|
|
182
|
-
*/
|
|
183
|
-
static resolveDeclarationRootFiles(tsConfigPath, configJson) {
|
|
184
|
-
const parsed = typescript_1.default.parseJsonConfigFileContent(configJson, typescript_1.default.sys, path.dirname(tsConfigPath), undefined, tsConfigPath);
|
|
185
|
-
return parsed.fileNames.filter((f) => ScriptTranspiler.isDeclarationFile(f) && typescript_1.default.sys.fileExists(f));
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Whether a path is an ambient declaration file — matched broadly enough
|
|
189
|
-
* (`.d.ts`, `.d.mts`, `.d.cts`) that a future switch to a module-flavored
|
|
190
|
-
* declaration name cannot silently drop the platform globals and regress the
|
|
191
|
-
* type-check back to syntax-only.
|
|
192
|
-
* @lastreviewed null
|
|
193
|
-
*/
|
|
194
|
-
static isDeclarationFile(fsPath) {
|
|
195
|
-
return /\.d\.(ts|mts|cts)$/i.test(fsPath);
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Force the invariants this transpile step depends on onto a set of parsed
|
|
199
|
-
* compiler options, regardless of what the project's tsconfig.json specified.
|
|
200
|
-
*
|
|
201
|
-
* - `listEmittedFiles`: we return the emitted paths to the caller.
|
|
202
|
-
* - `skipLibCheck`: this step is a transpile/emit gate, not a full lib audit.
|
|
203
|
-
* Without it, a legitimate project `lib: ["dom", "WebWorker"]` (e.g. a
|
|
204
|
-
* MergeReport `static/` client bundle) produces 30+ lib-vs-lib conflicts
|
|
205
|
-
* (`ImportExportKind`, duplicate index signatures, `location` mismatch, ...)
|
|
206
|
-
* that have nothing to do with the project's own code.
|
|
207
|
-
* - `noEmitOnError`: emit must succeed even when type diagnostics exist —
|
|
208
|
-
* the platform never type-checks (it runs the emitted JS on GraalVM) and a
|
|
209
|
-
* component's local declarations may be incomplete, so a diagnostic must not
|
|
210
|
-
* block the emit a push depends on. This is NOT the same as swallowing the
|
|
211
|
-
* diagnostics: `transpile` returns their count so the push surfaces them
|
|
212
|
-
* loudly instead of reporting a clean success (ClickUp 86bbeb659).
|
|
213
|
-
* @lastreviewed null
|
|
214
|
-
*/
|
|
215
|
-
static applyTranspileInvariants(options) {
|
|
216
|
-
options.listEmittedFiles = true;
|
|
217
|
-
options.skipLibCheck = true;
|
|
218
|
-
options.noEmitOnError = false;
|
|
219
|
-
return options;
|
|
220
|
-
}
|
|
221
|
-
async addFile(sn) {
|
|
222
|
-
if (await sn.isFolder()) {
|
|
223
|
-
this.ctx.logger.warn("Ignoring folder node in ScriptCompiler.addFile:", sn.path());
|
|
224
|
-
return void 0;
|
|
225
|
-
}
|
|
226
|
-
if (!(await sn.isCopacetic())) {
|
|
227
|
-
throw new Err_1.Err.ScriptNotCopaceticError();
|
|
228
|
-
}
|
|
229
|
-
const newTsConfigFile = await sn.getClosestTsConfigFile();
|
|
230
|
-
const vals = this.projects.get(newTsConfigFile.path()) || [];
|
|
231
|
-
if (!vals.some((existingSn) => existingSn.path() === sn.path())) {
|
|
232
|
-
vals.push(sn);
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
this.ctx.logger.warn("Ignoring duplicate file in ScriptCompiler.addFile:", sn.path());
|
|
236
|
-
}
|
|
237
|
-
this.projects.set(newTsConfigFile.path(), vals);
|
|
238
|
-
}
|
|
239
|
-
async transpile(sharedRoot) {
|
|
240
|
-
const f = sharedRoot ? sharedRoot.factory : new ScriptFactory_1.ScriptFactory(this.ctx);
|
|
241
|
-
// The draft-root tsconfig governs the platform-compiled scripts (`scripts/*.ts`)
|
|
242
|
-
// — the ONLY code whose type-check gates the push. Nested tsconfigs are
|
|
243
|
-
// client bundles (e.g. a MergeReport `static/`) whose diagnostics stay
|
|
244
|
-
// advisory: they legitimately reference browser-only third-party globals the
|
|
245
|
-
// component declares nowhere, so gating on them would fail a push over benign
|
|
246
|
-
// noise (see the b6p-push skill's third-party-lib-type-noise gotcha). When no
|
|
247
|
-
// root is supplied we can't tell them apart, so we gate on everything.
|
|
248
|
-
const draftRootTsConfigPath = sharedRoot ? sharedRoot.getDraftTsConfigPath() : null;
|
|
249
|
-
const reports = [];
|
|
250
|
-
const emittedFiles = [];
|
|
251
|
-
const gatedDiagnostics = [];
|
|
252
|
-
// Whether the gated (draft-root) project was actually among the compiled
|
|
253
|
-
// projects. If a component's TS all lives under nested client bundles and
|
|
254
|
-
// nothing is governed by the draft-root tsconfig, no platform-code
|
|
255
|
-
// type-check ran — and `diagnosticCount: 0` would falsely read as "checked
|
|
256
|
-
// clean". We return `null` in that case instead (ClickUp 86bbeb659 review).
|
|
257
|
-
let gatedProjectCompiled = false;
|
|
258
|
-
for (const [tsConfigPath, sfList] of this.projects.entries()) {
|
|
259
|
-
if (sfList.length === 0) {
|
|
260
|
-
throw new Err_1.Err.NoFilesToCompileError(tsConfigPath);
|
|
261
|
-
}
|
|
262
|
-
const sf = f.createFile(B6PUri_1.B6PUri.fromFsPath(tsConfigPath), sharedRoot);
|
|
263
|
-
const { options: compilerOptions, declarationRootFiles, configErrorCount } = await this.getProjectConfig(sf);
|
|
264
|
-
const sfPaths = sfList.map((sf) => sf.uri().fsPath);
|
|
265
|
-
const isGated = draftRootTsConfigPath === null || path.normalize(tsConfigPath) === draftRootTsConfigPath;
|
|
266
|
-
if (isGated) {
|
|
267
|
-
gatedProjectCompiled = true;
|
|
268
|
-
// Only the gated draft-root project needs declarations to type-check
|
|
269
|
-
// meaningfully; an empty set here means the check is effectively a
|
|
270
|
-
// syntax pass, which is exactly the regression this guards against.
|
|
271
|
-
if (declarationRootFiles.length === 0) {
|
|
272
|
-
this.ctx.logger.warn(`No declaration files resolved from ${tsConfigPath} (include/files) — ` +
|
|
273
|
-
`platform globals may be unresolved and the type-check ineffective.`);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
const compiled = this.compileProject(tsConfigPath, sfPaths, declarationRootFiles, compilerOptions);
|
|
277
|
-
const { emittedFiles: projectEmitted, emitSkipped } = compiled;
|
|
278
|
-
// A diagnostic located in a declaration file is not the script's: the server's generated typings are outside its
|
|
279
|
-
// control, so they are ignored entirely.
|
|
280
|
-
const ownSources = (list) => list.filter((d) => !(d.file && ScriptTranspiler.isDeclarationFile(d.file.fileName)));
|
|
281
|
-
const allDiagnostics = ownSources(compiled.diagnostics);
|
|
282
|
-
const blockingErrors = ownSources(compiled.blockingDiagnostics).filter((d) => d.category === typescript_1.default.DiagnosticCategory.Error);
|
|
283
|
-
emittedFiles.push(...projectEmitted);
|
|
284
|
-
reports.push({
|
|
285
|
-
tsConfigPath,
|
|
286
|
-
errorCount: blockingErrors.length,
|
|
287
|
-
configErrorCount,
|
|
288
|
-
emittedFiles: projectEmitted,
|
|
289
|
-
noEmit: compilerOptions.noEmit === true,
|
|
290
|
-
emitSkipped,
|
|
291
|
-
});
|
|
292
|
-
// Contract: this step is an emit gate, not a hard type-audit gate. A
|
|
293
|
-
// genuine emit failure is FATAL — we throw so callers
|
|
294
|
-
// (ScriptRoot.compileDraftFolder → executePush) abort instead of pushing
|
|
295
|
-
// missing JavaScript. Type diagnostics do NOT block emit (the platform
|
|
296
|
-
// never type-checks — it runs the emitted JS on GraalVM, and local
|
|
297
|
-
// declarations may be incomplete). For the platform-compiled draft-root
|
|
298
|
-
// project they are NO LONGER silently advisory: the count is returned so
|
|
299
|
-
// the push reports loudly instead of claiming a clean success (ClickUp
|
|
300
|
-
// 86bbeb659). Client-bundle diagnostics stay advisory (logged, not gated).
|
|
301
|
-
if (emitSkipped) {
|
|
302
|
-
throw new Err_1.Err.CompilationError(`TypeScript emit was skipped for ${tsConfigPath}; no JavaScript was produced.` +
|
|
303
|
-
(allDiagnostics.length > 0 ? "\n" + this.formatDiagnostics(allDiagnostics) : ""));
|
|
304
|
-
}
|
|
305
|
-
else if (allDiagnostics.length > 0) {
|
|
306
|
-
if (isGated) {
|
|
307
|
-
gatedDiagnostics.push(...allDiagnostics);
|
|
308
|
-
this.ctx.logger.warn(`TypeScript reported ${allDiagnostics.length} diagnostic(s) for ${tsConfigPath}:\n` +
|
|
309
|
-
this.formatDiagnostics(allDiagnostics));
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
this.ctx.logger.warn(`TypeScript reported ${allDiagnostics.length} advisory diagnostic(s) for client bundle ` +
|
|
313
|
-
`${tsConfigPath} (not gated — client-side globals may be intentionally undeclared):\n` +
|
|
314
|
-
this.formatDiagnostics(allDiagnostics));
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
this.ctx.logger.info(`TypeScript type-checked ${tsConfigPath} cleanly.`);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
const uncleanReasons = buildUncleanReasons(reports, sharedRoot?.getDraftFolder().path());
|
|
322
|
-
return {
|
|
323
|
-
emittedFiles,
|
|
324
|
-
diagnosticCount: gatedProjectCompiled ? gatedDiagnostics.length : null,
|
|
325
|
-
diagnosticText: this.formatDiagnostics(gatedDiagnostics),
|
|
326
|
-
fullyClean: uncleanReasons.length === 0,
|
|
327
|
-
uncleanReasons,
|
|
328
|
-
typeCheckErrors: gatedDiagnostics.map((d) => this.locate(d, sharedRoot?.getDraftFolder().path())),
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Build the `ts.Program` for one tsconfig project and emit it, returning the
|
|
333
|
-
* emitted files and the combined pre-emit + emit diagnostics.
|
|
334
|
-
*
|
|
335
|
-
* The declaration files come FIRST so the type-check resolves platform
|
|
336
|
-
* globals; ambient `.d.ts` emit nothing, so adding them changes only what is
|
|
337
|
-
* type-checked, not the emitted-file set (the invariant the regression test
|
|
338
|
-
* pins). The `Set` dedupes only exact string matches — declaration paths come
|
|
339
|
-
* from `ts.sys` (forward slashes) and `sfPaths` from `B6PUri` (native
|
|
340
|
-
* separators), so on Windows a `.d.ts` also under the draft tree may appear
|
|
341
|
-
* twice; harmless (TypeScript canonicalizes internally, and a `.d.ts` still
|
|
342
|
-
* emits nothing), just not deduped here.
|
|
343
|
-
* @lastreviewed null
|
|
344
|
-
*/
|
|
345
|
-
compileProject(tsConfigPath, sfPaths, declarationRootFiles, options) {
|
|
346
|
-
const rootFiles = Array.from(new Set([...declarationRootFiles, ...sfPaths]));
|
|
347
|
-
const program = this.createProgram(rootFiles, options, tsConfigPath);
|
|
348
|
-
const emitResult = program.emit();
|
|
349
|
-
const diagnostics = typescript_1.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
350
|
-
// What makes a build unclean is told apart from the type warnings: syntax errors, emit errors, and global or option
|
|
351
|
-
// errors. Semantic (type) errors are warnings.
|
|
352
|
-
const blockingDiagnostics = [
|
|
353
|
-
...program.getSyntacticDiagnostics(),
|
|
354
|
-
...program.getOptionsDiagnostics(),
|
|
355
|
-
...program.getGlobalDiagnostics(),
|
|
356
|
-
...emitResult.diagnostics,
|
|
357
|
-
];
|
|
358
|
-
return {
|
|
359
|
-
emittedFiles: emitResult.emittedFiles ?? [],
|
|
360
|
-
diagnostics,
|
|
361
|
-
blockingDiagnostics,
|
|
362
|
-
emitSkipped: emitResult.emitSkipped,
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Create a `ts.Program` with a `CompilerHost` whose default-library resolution
|
|
367
|
-
* does NOT depend on `__filename`.
|
|
368
|
-
*
|
|
369
|
-
* b6p-core is bundled into the consumer's single-file CLI / SEA binary, so
|
|
370
|
-
* TypeScript's default `getDefaultLibLocation()` (= `dirname(__filename)`)
|
|
371
|
-
* points at the bundle directory, where no `lib.*.d.ts` exist. We resolve the
|
|
372
|
-
* lib directory via {@link TsLibResolver} and override the two host methods
|
|
373
|
-
* that steer lib lookup. If no lib directory can be found we fall back to the
|
|
374
|
-
* default host behavior rather than pointing it at a bogus path.
|
|
375
|
-
* @lastreviewed null
|
|
376
|
-
*/
|
|
377
|
-
createProgram(fileNames, options, tsConfigPath) {
|
|
378
|
-
const host = typescript_1.default.createCompilerHost(options);
|
|
379
|
-
const libDir = TsLibResolver_1.TsLibResolver.resolveLibDir({
|
|
380
|
-
explicitDirs: this.ctx.typescriptLibDirs,
|
|
381
|
-
projectDirs: [path.dirname(tsConfigPath), process.cwd()],
|
|
382
|
-
});
|
|
383
|
-
if (libDir) {
|
|
384
|
-
this.ctx.logger.info(`Resolved TypeScript lib directory: ${libDir}`);
|
|
385
|
-
host.getDefaultLibLocation = () => libDir;
|
|
386
|
-
host.getDefaultLibFileName = (o) => path.join(libDir, typescript_1.default.getDefaultLibFileName(o));
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
this.ctx.logger.warn("Could not resolve a TypeScript lib directory; falling back to default host resolution. " +
|
|
390
|
-
"If this run is bundled (CLI/SEA), lib diagnostics are expected — supply providers.typescriptLibDirs.");
|
|
391
|
-
}
|
|
392
|
-
return typescript_1.default.createProgram(fileNames, options, host);
|
|
393
|
-
}
|
|
394
|
-
locate(diagnostic, draftRoot) {
|
|
395
|
-
const message = typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
396
|
-
if (!diagnostic.file || diagnostic.start === undefined) {
|
|
397
|
-
return { file: "", line: 0, column: 0, code: diagnostic.code, message };
|
|
398
|
-
}
|
|
399
|
-
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
400
|
-
const relative = draftRoot ? path.relative(draftRoot, diagnostic.file.fileName) : diagnostic.file.fileName;
|
|
401
|
-
return {
|
|
402
|
-
file: relative.split(path.sep).join("/"),
|
|
403
|
-
line: line + 1,
|
|
404
|
-
column: character + 1,
|
|
405
|
-
code: diagnostic.code,
|
|
406
|
-
message,
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
formatDiagnostics(diagnostics) {
|
|
410
|
-
return diagnostics
|
|
411
|
-
.map((diagnostic) => {
|
|
412
|
-
if (diagnostic.file) {
|
|
413
|
-
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
414
|
-
const message = typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
415
|
-
return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`;
|
|
416
|
-
}
|
|
417
|
-
else {
|
|
418
|
-
return typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
419
|
-
}
|
|
420
|
-
})
|
|
421
|
-
.join("\n");
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
exports.ScriptTranspiler = ScriptTranspiler;
|
|
425
|
-
//# sourceMappingURL=ScriptTranspiler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptTranspiler.js","sourceRoot":"","sources":["../../src/script/ScriptTranspiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkGA,kDA8BC;AAhID,4DAA4B;AAC5B,2CAA6B;AAC7B,gCAA6B;AAG7B,4CAA2C;AAC3C,sCAAmC;AAEnC,mDAAgD;AAChD,mDAAgD;AAkFhD;;;;;;GAMG;AACH,SAAgB,mBAAmB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,SAAS,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,6BAA6B,CAAC,UAAU,CAAC,KAAM,CAAC,CAAC;gBAC7F,MAAM,OAAO,GAAG,oBAAE,CAAC,4BAA4B,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAC9E,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC,MAAM,OAAO,EAAE,CAAC;YAClF,CAAC;iBAAM,CAAC;gBACN,OAAO,oBAAE,CAAC,4BAA4B,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YACvE,CAAC;QACH,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;;AAlYH,4CAmYC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolves the directory that holds TypeScript's default library declaration
|
|
3
|
-
* files (`lib.d.ts`, `lib.es2022.d.ts`, `lib.dom.d.ts`, ...).
|
|
4
|
-
*
|
|
5
|
-
* WHY THIS EXISTS: b6p-core is bundled by its consumers (the b6p CLI's single
|
|
6
|
-
* `dist/cli.js` and its SEA binary). TypeScript's default `CompilerHost` locates
|
|
7
|
-
* the standard library via:
|
|
8
|
-
*
|
|
9
|
-
* getDefaultLibLocation() = getDirectoryPath(sys.getExecutingFilePath())
|
|
10
|
-
* getExecutingFilePath() = __filename
|
|
11
|
-
*
|
|
12
|
-
* Once bundled, `__filename` is the bundle path (or the standalone exe), so TS
|
|
13
|
-
* looks for `lib.*.d.ts` next to the bundle — where they never exist. The result
|
|
14
|
-
* is "File 'lib.esnext.d.ts' not found" cascading into "Cannot find global type
|
|
15
|
-
* 'Array'", "Cannot find name 'console'", etc., for every project.
|
|
16
|
-
*
|
|
17
|
-
* This resolver finds the lib directory WITHOUT relying on `__filename`, so the
|
|
18
|
-
* caller can override the host's lib resolution and compile correctly whether it
|
|
19
|
-
* runs from an npm install, a bundled CLI, or a SEA binary.
|
|
20
|
-
* @lastreviewed null
|
|
21
|
-
*/
|
|
22
|
-
export declare class TsLibResolver {
|
|
23
|
-
/**
|
|
24
|
-
* A file present in every TypeScript lib directory; used as the existence probe.
|
|
25
|
-
* @lastreviewed null
|
|
26
|
-
*/
|
|
27
|
-
private static readonly SENTINEL;
|
|
28
|
-
/**
|
|
29
|
-
* Return the first directory that actually contains TypeScript's default
|
|
30
|
-
* library files, or `undefined` if none is found (in which case the caller
|
|
31
|
-
* should leave the default host behavior untouched).
|
|
32
|
-
*
|
|
33
|
-
* Resolution order:
|
|
34
|
-
* 1. `explicitDirs` — supplied by the consumer (the CLI). Covers both the
|
|
35
|
-
* npm fallback (a `lib/` shipped next to the bundle) and the SEA binary
|
|
36
|
-
* (a temp dir the binary extracts its embedded libs into). Neither
|
|
37
|
-
* depends on `__filename`, so both stay correct under bundling.
|
|
38
|
-
* 2. `node_modules/typescript/lib`, walking up from each project dir — the
|
|
39
|
-
* typescript install of the workspace being pushed.
|
|
40
|
-
*
|
|
41
|
-
* Existence is probed with `ts.sys`, which reads the real filesystem — the
|
|
42
|
-
* same source the `CompilerHost` reads libs from — so a hit here guarantees
|
|
43
|
-
* the host can actually read the files.
|
|
44
|
-
* @lastreviewed null
|
|
45
|
-
*/
|
|
46
|
-
static resolveLibDir(opts: {
|
|
47
|
-
explicitDirs?: readonly string[];
|
|
48
|
-
projectDirs?: readonly string[];
|
|
49
|
-
}): string | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* True if `dir` contains TypeScript's default library files.
|
|
52
|
-
* @lastreviewed null
|
|
53
|
-
*/
|
|
54
|
-
private static hasLibFiles;
|
|
55
|
-
/**
|
|
56
|
-
* Walk up from `startDir` looking for `node_modules/typescript/lib`.
|
|
57
|
-
* @lastreviewed null
|
|
58
|
-
*/
|
|
59
|
-
private static findInNodeModules;
|
|
60
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.TsLibResolver = void 0;
|
|
40
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
41
|
-
const path = __importStar(require("path"));
|
|
42
|
-
/**
|
|
43
|
-
* Resolves the directory that holds TypeScript's default library declaration
|
|
44
|
-
* files (`lib.d.ts`, `lib.es2022.d.ts`, `lib.dom.d.ts`, ...).
|
|
45
|
-
*
|
|
46
|
-
* WHY THIS EXISTS: b6p-core is bundled by its consumers (the b6p CLI's single
|
|
47
|
-
* `dist/cli.js` and its SEA binary). TypeScript's default `CompilerHost` locates
|
|
48
|
-
* the standard library via:
|
|
49
|
-
*
|
|
50
|
-
* getDefaultLibLocation() = getDirectoryPath(sys.getExecutingFilePath())
|
|
51
|
-
* getExecutingFilePath() = __filename
|
|
52
|
-
*
|
|
53
|
-
* Once bundled, `__filename` is the bundle path (or the standalone exe), so TS
|
|
54
|
-
* looks for `lib.*.d.ts` next to the bundle — where they never exist. The result
|
|
55
|
-
* is "File 'lib.esnext.d.ts' not found" cascading into "Cannot find global type
|
|
56
|
-
* 'Array'", "Cannot find name 'console'", etc., for every project.
|
|
57
|
-
*
|
|
58
|
-
* This resolver finds the lib directory WITHOUT relying on `__filename`, so the
|
|
59
|
-
* caller can override the host's lib resolution and compile correctly whether it
|
|
60
|
-
* runs from an npm install, a bundled CLI, or a SEA binary.
|
|
61
|
-
* @lastreviewed null
|
|
62
|
-
*/
|
|
63
|
-
class TsLibResolver {
|
|
64
|
-
/**
|
|
65
|
-
* A file present in every TypeScript lib directory; used as the existence probe.
|
|
66
|
-
* @lastreviewed null
|
|
67
|
-
*/
|
|
68
|
-
static SENTINEL = "lib.d.ts";
|
|
69
|
-
/**
|
|
70
|
-
* Return the first directory that actually contains TypeScript's default
|
|
71
|
-
* library files, or `undefined` if none is found (in which case the caller
|
|
72
|
-
* should leave the default host behavior untouched).
|
|
73
|
-
*
|
|
74
|
-
* Resolution order:
|
|
75
|
-
* 1. `explicitDirs` — supplied by the consumer (the CLI). Covers both the
|
|
76
|
-
* npm fallback (a `lib/` shipped next to the bundle) and the SEA binary
|
|
77
|
-
* (a temp dir the binary extracts its embedded libs into). Neither
|
|
78
|
-
* depends on `__filename`, so both stay correct under bundling.
|
|
79
|
-
* 2. `node_modules/typescript/lib`, walking up from each project dir — the
|
|
80
|
-
* typescript install of the workspace being pushed.
|
|
81
|
-
*
|
|
82
|
-
* Existence is probed with `ts.sys`, which reads the real filesystem — the
|
|
83
|
-
* same source the `CompilerHost` reads libs from — so a hit here guarantees
|
|
84
|
-
* the host can actually read the files.
|
|
85
|
-
* @lastreviewed null
|
|
86
|
-
*/
|
|
87
|
-
static resolveLibDir(opts) {
|
|
88
|
-
const { explicitDirs = [], projectDirs = [] } = opts;
|
|
89
|
-
for (const dir of explicitDirs) {
|
|
90
|
-
if (dir && this.hasLibFiles(dir)) {
|
|
91
|
-
return dir;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
for (const projectDir of projectDirs) {
|
|
95
|
-
if (!projectDir) {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
const found = this.findInNodeModules(projectDir);
|
|
99
|
-
if (found) {
|
|
100
|
-
return found;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* True if `dir` contains TypeScript's default library files.
|
|
107
|
-
* @lastreviewed null
|
|
108
|
-
*/
|
|
109
|
-
static hasLibFiles(dir) {
|
|
110
|
-
// ts.sys is always defined under Node; guard anyway so a non-Node host that
|
|
111
|
-
// lacks it degrades to "not found" rather than throwing.
|
|
112
|
-
return !!typescript_1.default.sys?.fileExists(path.join(dir, this.SENTINEL));
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Walk up from `startDir` looking for `node_modules/typescript/lib`.
|
|
116
|
-
* @lastreviewed null
|
|
117
|
-
*/
|
|
118
|
-
static findInNodeModules(startDir) {
|
|
119
|
-
let current = path.resolve(startDir);
|
|
120
|
-
let prev = "";
|
|
121
|
-
// Loop terminates when `path.dirname` stops changing (filesystem root).
|
|
122
|
-
while (current !== prev) {
|
|
123
|
-
const candidate = path.join(current, "node_modules", "typescript", "lib");
|
|
124
|
-
if (this.hasLibFiles(candidate)) {
|
|
125
|
-
return candidate;
|
|
126
|
-
}
|
|
127
|
-
prev = current;
|
|
128
|
-
current = path.dirname(current);
|
|
129
|
-
}
|
|
130
|
-
return undefined;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
exports.TsLibResolver = TsLibResolver;
|
|
134
|
-
//# sourceMappingURL=TsLibResolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TsLibResolver.js","sourceRoot":"","sources":["../../src/script/TsLibResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA4B;AAC5B,2CAA6B;AAE7B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,aAAa;IACxB;;;OAGG;IACK,MAAM,CAAU,QAAQ,GAAG,UAAU,CAAC;IAE9C;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,aAAa,CAAC,IAGpB;QACC,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;QAErD,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;YAC/B,IAAI,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;gBACjC,OAAO,GAAG,CAAC;YACb,CAAC;QACH,CAAC;QAED,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,SAAS;YACX,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACjD,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IAC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