@mui/internal-code-infra 0.0.4-canary.98 → 0.1.1-canary.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 +4 -0
- package/build/babel-config.d.mts +4 -4
- package/build/babelPluginInlineEnvironmentVariables.d.mts +11 -0
- package/build/brokenLinksChecker/index.d.mts +147 -0
- package/build/changelog/fetchChangelogs.d.mts +3 -0
- package/build/cli/cmdArgosPush.d.mts +6 -0
- package/build/cli/cmdBuild.d.mts +45 -0
- package/build/cli/cmdCopyFiles.d.mts +12 -0
- package/build/cli/cmdGenerateChangelog.d.mts +15 -0
- package/build/cli/cmdListWorkspaces.d.mts +14 -2
- package/build/cli/cmdNetlifyIgnore.d.mts +9 -0
- package/build/cli/cmdPublish.d.mts +20 -2
- package/build/cli/cmdPublishCanary.d.mts +18 -0
- package/build/cli/cmdPublishNewPackage.d.mts +6 -0
- package/build/cli/cmdRenameScope.d.mts +18 -0
- package/build/cli/cmdSetVersionOverrides.d.mts +3 -0
- package/build/eslint/mui/rules/no-restricted-resolved-imports.d.mts +6 -0
- package/build/eslint/testConfig.d.mts +1 -7
- package/build/utils/babel.d.mts +6 -0
- package/build/utils/build.d.mts +3 -15
- package/build/utils/extractErrorCodes.d.mts +16 -0
- package/build/utils/git.d.mts +9 -0
- package/build/utils/github.d.mts +12 -0
- package/build/utils/pnpm.d.mts +147 -9
- package/build/utils/testUtils.d.mts +21 -0
- package/build/utils/typescript.d.mts +2 -2
- package/package.json +54 -56
- package/src/babel-config.mjs +21 -11
- package/src/babelPluginInlineEnvironmentVariables.mjs +45 -0
- package/src/brokenLinksChecker/index.mjs +3 -3
- package/src/cli/cmdArgosPush.mjs +2 -4
- package/src/cli/cmdBuild.mjs +8 -9
- package/src/cli/cmdCopyFiles.mjs +3 -3
- package/src/cli/cmdListWorkspaces.mjs +3 -31
- package/src/cli/cmdPublish.mjs +23 -29
- package/src/cli/cmdRenameScope.mjs +77 -0
- package/src/cli/cmdSetVersionOverrides.mjs +32 -25
- package/src/cli/cmdVale.mjs +3 -6
- package/src/cli/cmdValidateBuiltTypes.mjs +3 -4
- package/src/cli/index.mjs +2 -0
- package/src/eslint/testConfig.mjs +3 -31
- package/src/untyped-plugins.d.ts +11 -49
- package/src/utils/build.mjs +0 -39
- package/src/utils/extractErrorCodes.mjs +12 -7
- package/src/utils/pnpm.mjs +380 -16
- package/src/utils/testUtils.mjs +35 -0
- package/src/utils/typescript.mjs +60 -42
package/src/utils/typescript.mjs
CHANGED
|
@@ -9,26 +9,49 @@ import { globby } from 'globby';
|
|
|
9
9
|
import * as fs from 'node:fs/promises';
|
|
10
10
|
import * as os from 'node:os';
|
|
11
11
|
import * as path from 'node:path';
|
|
12
|
-
import {
|
|
12
|
+
import { mapAsync } from 'es-toolkit/array';
|
|
13
|
+
import { getOutExtension } from '../utils/build.mjs';
|
|
13
14
|
|
|
14
15
|
const $$ = $({ stdio: 'inherit' });
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {string}
|
|
19
|
-
* @
|
|
18
|
+
* Finds a CLI shim in a directory's node_modules/.bin.
|
|
19
|
+
* @param {string} dir
|
|
20
|
+
* @param {string} name
|
|
21
|
+
* @returns {Promise<string | null>}
|
|
20
22
|
*/
|
|
21
|
-
async function
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
const tsgoPath = path.join(workspaceDir, 'node_modules', '.bin', 'tsgo');
|
|
27
|
-
const exists = await fs.stat(tsgoPath).then(
|
|
23
|
+
async function findBin(dir, name) {
|
|
24
|
+
const binPath = path.join(dir, 'node_modules', '.bin', name);
|
|
25
|
+
const exists = await fs.stat(binPath).then(
|
|
28
26
|
(stat) => stat.isFile(),
|
|
29
27
|
() => false,
|
|
30
28
|
);
|
|
31
|
-
return exists ?
|
|
29
|
+
return exists ? binPath : null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the native/JS TypeScript CLI pair from the workspace root's
|
|
34
|
+
* `node_modules/.bin`: tsgo/tsc when the legacy `tsgo` shim exists, tsc/tsc6
|
|
35
|
+
* otherwise, with bare `tsc` from PATH as the JS fallback.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} cwd
|
|
38
|
+
* @returns {Promise<{ native: string | null, js: string }>}
|
|
39
|
+
*/
|
|
40
|
+
async function findTscPair(cwd) {
|
|
41
|
+
const workspaceDir = await findWorkspaceDir(cwd);
|
|
42
|
+
if (!workspaceDir) {
|
|
43
|
+
return { native: null, js: 'tsc' };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const [tsgo, tsc, tsc6] = await Promise.all([
|
|
47
|
+
findBin(workspaceDir, 'tsgo'),
|
|
48
|
+
findBin(workspaceDir, 'tsc'),
|
|
49
|
+
findBin(workspaceDir, 'tsc6'),
|
|
50
|
+
]);
|
|
51
|
+
if (tsgo) {
|
|
52
|
+
return { native: tsgo, js: 'tsc' };
|
|
53
|
+
}
|
|
54
|
+
return { native: tsc, js: tsc6 ?? 'tsc' };
|
|
32
55
|
}
|
|
33
56
|
|
|
34
57
|
/**
|
|
@@ -36,44 +59,38 @@ async function findTsgo(cwd) {
|
|
|
36
59
|
* @param {string} tsconfig - The path to the tsconfig.json file.
|
|
37
60
|
* @param {string} outDir - The output directory for the declaration files.
|
|
38
61
|
* @param {Object} options
|
|
39
|
-
* @param {boolean} [options.useTsgo] - Whether to use
|
|
62
|
+
* @param {boolean} [options.useTsgo] - Whether to use the native TypeScript compiler.
|
|
40
63
|
*/
|
|
41
64
|
export async function emitDeclarations(tsconfig, outDir, options) {
|
|
42
65
|
const { useTsgo = false } = options ?? {};
|
|
43
66
|
const tsconfigDir = path.dirname(tsconfig);
|
|
44
67
|
const rootDir = path.resolve(tsconfigDir, './src');
|
|
45
68
|
|
|
46
|
-
const
|
|
69
|
+
const pair = await findTscPair(tsconfigDir);
|
|
70
|
+
const tsgoPath = useTsgo ? pair.native : null;
|
|
47
71
|
if (useTsgo && !tsgoPath) {
|
|
48
72
|
throw new Error(
|
|
49
|
-
'--tsgo flag was passed
|
|
73
|
+
'--tsgo flag was passed but no native TypeScript cli was found. Either remove the flag to use the JS compiler or install TypeScript 7 at the workspace root, as "typescript@^7" or under an alias such as "@typescript/native".',
|
|
50
74
|
);
|
|
51
75
|
}
|
|
52
76
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
--declaration
|
|
71
|
-
--emitDeclarationOnly
|
|
72
|
-
--noEmit false
|
|
73
|
-
--composite false
|
|
74
|
-
--incremental false
|
|
75
|
-
--declarationMap false`;
|
|
76
|
-
}
|
|
77
|
+
const tscPath = tsgoPath ?? pair.js;
|
|
78
|
+
console.log(
|
|
79
|
+
tsgoPath
|
|
80
|
+
? `Using ts-native for declaration emit: ${tscPath}`
|
|
81
|
+
: `Using ${tscPath} for declaration emit`,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
await $$`${tscPath}
|
|
85
|
+
-p ${tsconfig}
|
|
86
|
+
--rootDir ${rootDir}
|
|
87
|
+
--outDir ${outDir}
|
|
88
|
+
--declaration
|
|
89
|
+
--emitDeclarationOnly
|
|
90
|
+
--noEmit false
|
|
91
|
+
--composite false
|
|
92
|
+
--incremental false
|
|
93
|
+
--declarationMap false`;
|
|
77
94
|
}
|
|
78
95
|
|
|
79
96
|
/**
|
|
@@ -129,7 +146,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
|
|
|
129
146
|
return;
|
|
130
147
|
}
|
|
131
148
|
|
|
132
|
-
await
|
|
149
|
+
await mapAsync(
|
|
133
150
|
dtsFiles,
|
|
134
151
|
async (dtsFile) => {
|
|
135
152
|
// Normalize to native separators to make path comparisons reliable on Windows
|
|
@@ -160,6 +177,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
|
|
|
160
177
|
const outFileRelative = relativePath.replace(/\.d\.ts$/, newFileExtension);
|
|
161
178
|
const outFilePath = path.join(buildDir, outFileRelative);
|
|
162
179
|
|
|
180
|
+
/** @type {import('@babel/core').PluginItem[]} */
|
|
163
181
|
const babelPlugins = [
|
|
164
182
|
[pluginTypescriptSyntax, { dts: true }],
|
|
165
183
|
[pluginResolveImports, { outExtension: importExtension }],
|
|
@@ -182,7 +200,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
|
|
|
182
200
|
await fs.unlink(nativeDtsFile);
|
|
183
201
|
}
|
|
184
202
|
},
|
|
185
|
-
30,
|
|
203
|
+
{ concurrency: 30 },
|
|
186
204
|
);
|
|
187
205
|
}
|
|
188
206
|
|
|
@@ -198,7 +216,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
|
|
|
198
216
|
* @param {string} param0.buildDir - The build directory.
|
|
199
217
|
* @param {string} param0.cwd - The current working directory.
|
|
200
218
|
* @param {boolean} param0.skipTsc - Whether to skip running TypeScript compiler (tsc) for building types.
|
|
201
|
-
* @param {boolean} [param0.useTsgo=false] - Whether to build types using
|
|
219
|
+
* @param {boolean} [param0.useTsgo=false] - Whether to build types using the native TypeScript compiler.
|
|
202
220
|
* @param {'module' | 'commonjs'} [param0.packageType] - The package.json type field.
|
|
203
221
|
*/
|
|
204
222
|
export async function createTypes({
|