@textmode/tsconfig 0.2.1 → 0.3.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/LICENSE +21 -121
- package/README.md +12 -9
- package/dist/cli/textmode-types.d.ts +3 -0
- package/dist/cli/textmode-types.d.ts.map +1 -0
- package/dist/cli/textmode-types.js +95 -0
- package/dist/cli/textmode-types.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/check-project.d.ts +52 -0
- package/dist/internal/check-project.d.ts.map +1 -0
- package/dist/internal/check-project.js +65 -0
- package/dist/internal/check-project.js.map +1 -0
- package/dist/internal/declaration-doc-tags.d.ts +45 -0
- package/dist/internal/declaration-doc-tags.d.ts.map +1 -0
- package/dist/internal/declaration-doc-tags.js +210 -0
- package/dist/internal/declaration-doc-tags.js.map +1 -0
- package/dist/internal/declarations.d.ts +20 -0
- package/dist/internal/declarations.d.ts.map +1 -0
- package/dist/internal/declarations.js +136 -0
- package/dist/internal/declarations.js.map +1 -0
- package/dist/internal/project.d.ts +68 -0
- package/dist/internal/project.d.ts.map +1 -0
- package/dist/internal/project.js +100 -0
- package/dist/internal/project.js.map +1 -0
- package/dist/internal/typescript-compiler.d.ts +25 -0
- package/dist/internal/typescript-compiler.d.ts.map +1 -0
- package/dist/internal/typescript-compiler.js +43 -0
- package/dist/internal/typescript-compiler.js.map +1 -0
- package/package.json +70 -50
- package/src/cli/textmode-types.mjs +0 -99
- package/src/internal/project.mjs +0 -268
package/package.json
CHANGED
|
@@ -1,51 +1,71 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
2
|
+
"name": "@textmode/tsconfig",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Shared TypeScript presets and declaration verification tooling for the textmode.js ecosystem.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"textmode",
|
|
9
|
+
"typescript",
|
|
10
|
+
"tsconfig",
|
|
11
|
+
"types",
|
|
12
|
+
"declarations"
|
|
13
|
+
],
|
|
14
|
+
"author": "humanbydefinition <hello@textmode.art> (https://code.textmode.art)",
|
|
15
|
+
"homepage": "https://code.textmode.art",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/textmode-art/tooling.git",
|
|
19
|
+
"directory": "packages/tsconfig"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": "^24.15.0 || >=26.0.0"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./strict.json": "./strict.json",
|
|
30
|
+
"./browser.json": "./browser.json",
|
|
31
|
+
"./browser-library.json": "./browser-library.json",
|
|
32
|
+
"./node.json": "./node.json",
|
|
33
|
+
"./node-tooling.json": "./node-tooling.json",
|
|
34
|
+
"./base.json": "./base.json",
|
|
35
|
+
"./typecheck.json": "./typecheck.json",
|
|
36
|
+
"./build.json": "./build.json",
|
|
37
|
+
"./dist.json": "./dist.json",
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"bin": {
|
|
41
|
+
"textmode-types": "dist/cli/textmode-types.js"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"strict.json",
|
|
46
|
+
"browser.json",
|
|
47
|
+
"browser-library.json",
|
|
48
|
+
"node.json",
|
|
49
|
+
"node-tooling.json",
|
|
50
|
+
"base.json",
|
|
51
|
+
"typecheck.json",
|
|
52
|
+
"build.json",
|
|
53
|
+
"dist.json",
|
|
54
|
+
"README.md"
|
|
55
|
+
],
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"typescript": ">=6 <7"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/node": "^24.0.0",
|
|
61
|
+
"typescript": "^6.0.3",
|
|
62
|
+
"vitest": "^5.1.0"
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"build": "tsc -b",
|
|
69
|
+
"test": "vitest run"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import process from 'node:process';
|
|
5
|
-
import { parseArgs } from 'node:util';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
ProjectError,
|
|
9
|
-
buildDeclarations,
|
|
10
|
-
checkProject,
|
|
11
|
-
describeProject,
|
|
12
|
-
resolveProject,
|
|
13
|
-
verifyDeclarations,
|
|
14
|
-
} from '../internal/project.mjs';
|
|
15
|
-
|
|
16
|
-
const PACKAGE_JSON = JSON.parse(fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
17
|
-
const COMMANDS = new Set(['check', 'build', 'verify', 'show-config']);
|
|
18
|
-
|
|
19
|
-
function printHelp() {
|
|
20
|
-
console.log(`@textmode/tsconfig ${PACKAGE_JSON.version}`);
|
|
21
|
-
console.log('');
|
|
22
|
-
console.log('Usage: textmode-types <command> [options]');
|
|
23
|
-
console.log('');
|
|
24
|
-
console.log('Commands:');
|
|
25
|
-
console.log(' check Type-check the authored project and reject unclaimed TypeScript files');
|
|
26
|
-
console.log(' build Emit production declarations to dist/types');
|
|
27
|
-
console.log(' verify Resolve every package export from an isolated declaration consumer');
|
|
28
|
-
console.log(' show-config Print the resolved authoring and declaration programs');
|
|
29
|
-
console.log('');
|
|
30
|
-
console.log('Options:');
|
|
31
|
-
console.log(' --cwd <dir> Project root containing package.json');
|
|
32
|
-
console.log(' --project <file> TypeScript config relative to the project root');
|
|
33
|
-
console.log(' --help, -h Show help');
|
|
34
|
-
console.log(' --version Show version');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function parseCli(argv) {
|
|
38
|
-
const parsed = parseArgs({
|
|
39
|
-
args: argv,
|
|
40
|
-
allowPositionals: true,
|
|
41
|
-
strict: true,
|
|
42
|
-
options: {
|
|
43
|
-
cwd: { type: 'string' },
|
|
44
|
-
project: { type: 'string' },
|
|
45
|
-
help: { type: 'boolean', short: 'h' },
|
|
46
|
-
version: { type: 'boolean' },
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
if (parsed.values.version) return { action: 'version' };
|
|
50
|
-
if (parsed.values.help && parsed.positionals.length === 0) return { action: 'help' };
|
|
51
|
-
if (parsed.positionals.length !== 1 || !COMMANDS.has(parsed.positionals[0])) {
|
|
52
|
-
throw new ProjectError('Expected one command: check, build, verify, or show-config.');
|
|
53
|
-
}
|
|
54
|
-
if (parsed.values.help) return { action: 'help' };
|
|
55
|
-
return { action: 'run', command: parsed.positionals[0], values: parsed.values };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function run(argv) {
|
|
59
|
-
let cli;
|
|
60
|
-
try {
|
|
61
|
-
cli = parseCli(argv);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
64
|
-
process.exitCode = 2;
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (cli.action === 'help') {
|
|
68
|
-
printHelp();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (cli.action === 'version') {
|
|
72
|
-
console.log(PACKAGE_JSON.version);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
const project = resolveProject({ cwd: cli.values.cwd, project: cli.values.project });
|
|
77
|
-
let ok = true;
|
|
78
|
-
switch (cli.command) {
|
|
79
|
-
case 'check':
|
|
80
|
-
ok = checkProject(project);
|
|
81
|
-
break;
|
|
82
|
-
case 'build':
|
|
83
|
-
ok = buildDeclarations(project);
|
|
84
|
-
break;
|
|
85
|
-
case 'verify':
|
|
86
|
-
ok = verifyDeclarations(project);
|
|
87
|
-
break;
|
|
88
|
-
case 'show-config':
|
|
89
|
-
console.log(JSON.stringify(describeProject(project), null, 2));
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
if (!ok) process.exitCode = 1;
|
|
93
|
-
} catch (error) {
|
|
94
|
-
console.error(error instanceof Error ? (error.stack ?? error.message) : String(error));
|
|
95
|
-
process.exitCode = error instanceof ProjectError ? 2 : 1;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
run(process.argv.slice(2));
|
package/src/internal/project.mjs
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import os from 'node:os';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
|
|
7
|
-
const SOURCE_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.cts']);
|
|
8
|
-
const DISCOVERED_DIRECTORIES = ['src', 'tests', 'typedoc-entrypoints', 'vite-plugins'];
|
|
9
|
-
const ROOT_CONFIG_PATTERN = /^(?:vite|vitest)\.config\.(?:ts|mts|cts)$/;
|
|
10
|
-
|
|
11
|
-
export class ProjectError extends Error {}
|
|
12
|
-
|
|
13
|
-
function readJson(filePath, label) {
|
|
14
|
-
try {
|
|
15
|
-
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
16
|
-
} catch (error) {
|
|
17
|
-
throw new ProjectError(`Could not read ${label} at ${filePath}.`, { cause: error });
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function requireFile(filePath, label) {
|
|
22
|
-
if (!fs.existsSync(filePath)) {
|
|
23
|
-
throw new ProjectError(`Missing ${label}: ${filePath}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function resolveProject({ cwd = process.cwd(), project = 'tsconfig.json' } = {}) {
|
|
28
|
-
const root = path.resolve(cwd);
|
|
29
|
-
const manifestPath = path.join(root, 'package.json');
|
|
30
|
-
const configPath = path.resolve(root, project);
|
|
31
|
-
requireFile(manifestPath, 'package.json');
|
|
32
|
-
requireFile(configPath, 'TypeScript config');
|
|
33
|
-
const manifest = readJson(manifestPath, 'package.json');
|
|
34
|
-
if (typeof manifest.name !== 'string' || manifest.name.length === 0) {
|
|
35
|
-
throw new ProjectError(`package.json#name must be a non-empty string in ${manifestPath}.`);
|
|
36
|
-
}
|
|
37
|
-
const textmodeTypes = manifest.textmodeTypes ?? {};
|
|
38
|
-
if (typeof textmodeTypes !== 'object' || Array.isArray(textmodeTypes)) {
|
|
39
|
-
throw new ProjectError(`package.json#textmodeTypes must be an object in ${manifestPath}.`);
|
|
40
|
-
}
|
|
41
|
-
if (textmodeTypes.stripInternal !== undefined && typeof textmodeTypes.stripInternal !== 'boolean') {
|
|
42
|
-
throw new ProjectError(`package.json#textmodeTypes.stripInternal must be a boolean in ${manifestPath}.`);
|
|
43
|
-
}
|
|
44
|
-
const sourceDir = path.join(root, 'src');
|
|
45
|
-
requireFile(sourceDir, 'source directory');
|
|
46
|
-
return {
|
|
47
|
-
root,
|
|
48
|
-
manifest,
|
|
49
|
-
manifestPath,
|
|
50
|
-
configPath,
|
|
51
|
-
sourceDir,
|
|
52
|
-
declarationDir: path.join(root, 'dist', 'types'),
|
|
53
|
-
declarationOptions: {
|
|
54
|
-
stripInternal: textmodeTypes.stripInternal ?? false,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function resolveTypeScript(project) {
|
|
60
|
-
try {
|
|
61
|
-
const require = createRequire(project.manifestPath);
|
|
62
|
-
return require.resolve('typescript/bin/tsc');
|
|
63
|
-
} catch (error) {
|
|
64
|
-
throw new ProjectError(`Could not resolve TypeScript from ${project.root}.`, { cause: error });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function runTypeScript(project, args, { capture = false } = {}) {
|
|
69
|
-
const result = spawnSync(process.execPath, [resolveTypeScript(project), ...args], {
|
|
70
|
-
cwd: project.root,
|
|
71
|
-
encoding: 'utf8',
|
|
72
|
-
stdio: capture ? 'pipe' : 'inherit',
|
|
73
|
-
});
|
|
74
|
-
if (result.error) {
|
|
75
|
-
throw new ProjectError(`Could not start TypeScript: ${result.error.message}`, { cause: result.error });
|
|
76
|
-
}
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function visitTypeScriptFiles(directory, output) {
|
|
81
|
-
if (!fs.existsSync(directory)) return;
|
|
82
|
-
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
83
|
-
if (entry.isSymbolicLink()) continue;
|
|
84
|
-
const filePath = path.join(directory, entry.name);
|
|
85
|
-
if (entry.isDirectory()) {
|
|
86
|
-
visitTypeScriptFiles(filePath, output);
|
|
87
|
-
} else if (SOURCE_EXTENSIONS.has(path.extname(entry.name))) {
|
|
88
|
-
output.add(path.resolve(filePath));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function discoverAuthoredFiles(project) {
|
|
94
|
-
const files = new Set();
|
|
95
|
-
for (const directory of DISCOVERED_DIRECTORIES) {
|
|
96
|
-
visitTypeScriptFiles(path.join(project.root, directory), files);
|
|
97
|
-
}
|
|
98
|
-
for (const entry of fs.readdirSync(project.root, { withFileTypes: true })) {
|
|
99
|
-
if (entry.isFile() && ROOT_CONFIG_PATTERN.test(entry.name)) {
|
|
100
|
-
files.add(path.join(project.root, entry.name));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return files;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function readEffectiveConfig(project) {
|
|
107
|
-
const result = runTypeScript(project, ['--showConfig', '-p', project.configPath], { capture: true });
|
|
108
|
-
if (result.status !== 0) {
|
|
109
|
-
throw new ProjectError(
|
|
110
|
-
result.stderr.trim() || result.stdout.trim() || 'TypeScript could not resolve the config.'
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
try {
|
|
114
|
-
return JSON.parse(result.stdout);
|
|
115
|
-
} catch (error) {
|
|
116
|
-
throw new ProjectError('TypeScript returned invalid JSON from --showConfig.', { cause: error });
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function findUnclaimedFiles(project, effectiveConfig = readEffectiveConfig(project)) {
|
|
121
|
-
const claimed = new Set((effectiveConfig.files ?? []).map((file) => path.resolve(project.root, file)));
|
|
122
|
-
return [...discoverAuthoredFiles(project)].filter((file) => !claimed.has(file)).sort();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function checkProject(project) {
|
|
126
|
-
const effectiveConfig = readEffectiveConfig(project);
|
|
127
|
-
const unclaimed = findUnclaimedFiles(project, effectiveConfig);
|
|
128
|
-
if (unclaimed.length > 0) {
|
|
129
|
-
console.error('TypeScript config does not claim every authored TypeScript file:');
|
|
130
|
-
for (const file of unclaimed) {
|
|
131
|
-
console.error(`- ${path.relative(project.root, file)}`);
|
|
132
|
-
}
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
const result = runTypeScript(project, ['--noEmit', '-p', project.configPath]);
|
|
136
|
-
if (result.status === 0) {
|
|
137
|
-
console.log(`TypeScript check passed (${effectiveConfig.files.length} files).`);
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function withTemporaryConfig(config, callback) {
|
|
144
|
-
const temporaryDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'textmode-types-'));
|
|
145
|
-
const configPath = path.join(temporaryDirectory, 'tsconfig.json');
|
|
146
|
-
try {
|
|
147
|
-
fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`);
|
|
148
|
-
return callback(configPath);
|
|
149
|
-
} finally {
|
|
150
|
-
fs.rmSync(temporaryDirectory, { recursive: true, force: true });
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function declarationConfig(project) {
|
|
155
|
-
return {
|
|
156
|
-
extends: project.configPath,
|
|
157
|
-
compilerOptions: {
|
|
158
|
-
noEmit: false,
|
|
159
|
-
declaration: true,
|
|
160
|
-
declarationMap: false,
|
|
161
|
-
emitDeclarationOnly: true,
|
|
162
|
-
stripInternal: project.declarationOptions.stripInternal,
|
|
163
|
-
rootDir: project.sourceDir,
|
|
164
|
-
declarationDir: project.declarationDir,
|
|
165
|
-
noEmitOnError: true,
|
|
166
|
-
types: [],
|
|
167
|
-
},
|
|
168
|
-
include: [path.join(project.sourceDir, '**/*')],
|
|
169
|
-
exclude: [
|
|
170
|
-
path.join(project.sourceDir, '**/*.test.ts'),
|
|
171
|
-
path.join(project.sourceDir, '**/*.test.tsx'),
|
|
172
|
-
path.join(project.sourceDir, '**/*.spec.ts'),
|
|
173
|
-
path.join(project.sourceDir, '**/*.spec.tsx'),
|
|
174
|
-
],
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export function buildDeclarations(project) {
|
|
179
|
-
const config = declarationConfig(project);
|
|
180
|
-
fs.rmSync(project.declarationDir, { recursive: true, force: true });
|
|
181
|
-
const result = withTemporaryConfig(config, (configPath) => runTypeScript(project, ['-p', configPath]));
|
|
182
|
-
if (result.status === 0) {
|
|
183
|
-
console.log(`Declarations written to ${path.relative(project.root, project.declarationDir)}.`);
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function exportedSpecifiers(manifest) {
|
|
190
|
-
if (!manifest.exports || typeof manifest.exports !== 'object') return [manifest.name];
|
|
191
|
-
return Object.keys(manifest.exports)
|
|
192
|
-
.filter((key) => key === '.' || key.startsWith('./'))
|
|
193
|
-
.map((key) => (key === '.' ? manifest.name : `${manifest.name}/${key.slice(2)}`));
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function linkPackage(project, consumerRoot) {
|
|
197
|
-
const packagePath = path.join(consumerRoot, 'node_modules', ...project.manifest.name.split('/'));
|
|
198
|
-
fs.mkdirSync(path.dirname(packagePath), { recursive: true });
|
|
199
|
-
fs.symlinkSync(project.root, packagePath, 'dir');
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function verifyDeclarations(project) {
|
|
203
|
-
requireFile(project.declarationDir, 'built declaration directory');
|
|
204
|
-
const temporaryDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'textmode-types-consumer-'));
|
|
205
|
-
try {
|
|
206
|
-
linkPackage(project, temporaryDirectory);
|
|
207
|
-
const imports = exportedSpecifiers(project.manifest)
|
|
208
|
-
.map((specifier) => `import '${specifier}';`)
|
|
209
|
-
.join('\n');
|
|
210
|
-
fs.writeFileSync(path.join(temporaryDirectory, 'consumer.ts'), `${imports}\n`);
|
|
211
|
-
fs.writeFileSync(
|
|
212
|
-
path.join(temporaryDirectory, 'tsconfig.json'),
|
|
213
|
-
`${JSON.stringify(
|
|
214
|
-
{
|
|
215
|
-
compilerOptions: {
|
|
216
|
-
target: 'ES2022',
|
|
217
|
-
module: 'ESNext',
|
|
218
|
-
lib: ['ES2022', 'DOM', 'DOM.Iterable'],
|
|
219
|
-
moduleResolution: 'bundler',
|
|
220
|
-
// Keep dependency resolution anchored to the isolated consumer, not the symlink target.
|
|
221
|
-
preserveSymlinks: true,
|
|
222
|
-
strict: true,
|
|
223
|
-
noEmit: true,
|
|
224
|
-
types: [],
|
|
225
|
-
skipLibCheck: false,
|
|
226
|
-
},
|
|
227
|
-
files: ['consumer.ts'],
|
|
228
|
-
},
|
|
229
|
-
null,
|
|
230
|
-
2
|
|
231
|
-
)}\n`
|
|
232
|
-
);
|
|
233
|
-
const consumerProject = {
|
|
234
|
-
...project,
|
|
235
|
-
root: temporaryDirectory,
|
|
236
|
-
manifestPath: project.manifestPath,
|
|
237
|
-
configPath: path.join(temporaryDirectory, 'tsconfig.json'),
|
|
238
|
-
};
|
|
239
|
-
const result = runTypeScript(consumerProject, ['-p', consumerProject.configPath]);
|
|
240
|
-
if (result.status === 0) {
|
|
241
|
-
console.log(`Published declarations resolve for ${exportedSpecifiers(project.manifest).length} export(s).`);
|
|
242
|
-
return true;
|
|
243
|
-
}
|
|
244
|
-
return false;
|
|
245
|
-
} finally {
|
|
246
|
-
fs.rmSync(temporaryDirectory, { recursive: true, force: true });
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export function describeProject(project) {
|
|
251
|
-
const effectiveConfig = readEffectiveConfig(project);
|
|
252
|
-
return {
|
|
253
|
-
projectRoot: project.root,
|
|
254
|
-
packageName: project.manifest.name,
|
|
255
|
-
config: path.relative(project.root, project.configPath),
|
|
256
|
-
files: effectiveConfig.files.map((file) => path.relative(project.root, path.resolve(project.root, file))),
|
|
257
|
-
unclaimedFiles: findUnclaimedFiles(project, effectiveConfig).map((file) => path.relative(project.root, file)),
|
|
258
|
-
compilerOptions: effectiveConfig.compilerOptions,
|
|
259
|
-
declarations: {
|
|
260
|
-
sourceDir: path.relative(project.root, project.sourceDir),
|
|
261
|
-
declarationDir: path.relative(project.root, project.declarationDir),
|
|
262
|
-
excludedTests: true,
|
|
263
|
-
declarationMap: false,
|
|
264
|
-
stripInternal: project.declarationOptions.stripInternal,
|
|
265
|
-
types: [],
|
|
266
|
-
},
|
|
267
|
-
};
|
|
268
|
-
}
|