@mui/internal-code-infra 0.0.3-canary.33 → 0.0.3-canary.34
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-code-infra",
|
|
3
|
-
"version": "0.0.3-canary.
|
|
3
|
+
"version": "0.0.3-canary.34",
|
|
4
4
|
"description": "Infra scripts and configs to be used across MUI repos.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"publishConfig": {
|
|
128
128
|
"access": "public"
|
|
129
129
|
},
|
|
130
|
-
"gitSha": "
|
|
130
|
+
"gitSha": "cd745406302402d14a0b96edf4e25c39602bd97e",
|
|
131
131
|
"scripts": {
|
|
132
132
|
"build": "tsc -p tsconfig.build.json",
|
|
133
133
|
"typescript": "tsc -p tsconfig.json",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { globby } from 'globby';
|
|
3
|
+
import * as fs from 'node:fs/promises';
|
|
4
|
+
import { findWorkspaceDir } from '@pnpm/find-workspace-dir';
|
|
5
|
+
|
|
6
|
+
import { mapConcurrently } from '../utils/build.mjs';
|
|
7
|
+
|
|
8
|
+
const DYNAMIC_PACKAGES_IMPORT_REGEX = /import\((['"])packages\//gm;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Validates if there are no missing exports from TS files that would
|
|
12
|
+
* result in an import from a local file.
|
|
13
|
+
*/
|
|
14
|
+
async function validateFiles() {
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
const workspaceRoot = await findWorkspaceDir(cwd);
|
|
17
|
+
const declarationFiles = await globby(['**/build/**/*.d.{ts,cts,mts}'], {
|
|
18
|
+
absolute: true,
|
|
19
|
+
ignore: ['node_modules'],
|
|
20
|
+
followSymbolicLinks: false,
|
|
21
|
+
cwd: workspaceRoot,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const invalidFiles = (
|
|
25
|
+
await mapConcurrently(
|
|
26
|
+
declarationFiles,
|
|
27
|
+
async (declarationFile) => {
|
|
28
|
+
const content = await fs.readFile(declarationFile, 'utf-8');
|
|
29
|
+
const matches = Array.from(content.matchAll(DYNAMIC_PACKAGES_IMPORT_REGEX));
|
|
30
|
+
return matches.length > 0 ? declarationFile : undefined;
|
|
31
|
+
},
|
|
32
|
+
20,
|
|
33
|
+
)
|
|
34
|
+
).filter((file) => typeof file === 'string');
|
|
35
|
+
|
|
36
|
+
if (invalidFiles.length > 0) {
|
|
37
|
+
console.error('❌ Found invalid imports in the following files:');
|
|
38
|
+
console.log(invalidFiles.join('\n'));
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log('✅ Found no invalid import statements in built declaration files.');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default /** @type {import('yargs').CommandModule<{}, {}>} */ ({
|
|
46
|
+
command: 'validate-built-types',
|
|
47
|
+
describe: 'Validate built TypeScript declaration files for invalid imports from local files.',
|
|
48
|
+
handler: validateFiles,
|
|
49
|
+
});
|
package/src/cli/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import cmdPublish from './cmdPublish.mjs';
|
|
|
12
12
|
import cmdPublishCanary from './cmdPublishCanary.mjs';
|
|
13
13
|
import cmdPublishNewPackage from './cmdPublishNewPackage.mjs';
|
|
14
14
|
import cmdSetVersionOverrides from './cmdSetVersionOverrides.mjs';
|
|
15
|
+
import cmdValidateBuiltTypes from './cmdValidateBuiltTypes.mjs';
|
|
15
16
|
|
|
16
17
|
const pkgJson = createRequire(import.meta.url)('../../package.json');
|
|
17
18
|
|
|
@@ -28,6 +29,7 @@ yargs()
|
|
|
28
29
|
.command(cmdPublishCanary)
|
|
29
30
|
.command(cmdPublishNewPackage)
|
|
30
31
|
.command(cmdSetVersionOverrides)
|
|
32
|
+
.command(cmdValidateBuiltTypes)
|
|
31
33
|
.demandCommand(1, 'You need at least one command before moving on')
|
|
32
34
|
.strict()
|
|
33
35
|
.help()
|