@mui/internal-code-infra 0.0.4-canary.116 → 0.0.4-canary.118
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/build/utils/build.d.mts +0 -15
- package/package.json +3 -3
- package/src/cli/cmdBuild.mjs +3 -3
- package/src/cli/cmdCopyFiles.mjs +3 -3
- package/src/cli/cmdVale.mjs +3 -6
- package/src/cli/cmdValidateBuiltTypes.mjs +3 -4
- package/src/utils/build.mjs +0 -39
- package/src/utils/extractErrorCodes.mjs +4 -3
- package/src/utils/typescript.mjs +4 -3
package/build/utils/build.d.mts
CHANGED
|
@@ -107,18 +107,3 @@ export declare function markFn<F extends () => Promise<any>>(label: string, fn:
|
|
|
107
107
|
* @param {string} label
|
|
108
108
|
*/
|
|
109
109
|
export declare function measureFn(label: string): PerformanceMeasure;
|
|
110
|
-
/**
|
|
111
|
-
* A utility to map a function over an array of items in a worker pool.
|
|
112
|
-
*
|
|
113
|
-
* This function will create a pool of workers and distribute the items to be processed among them.
|
|
114
|
-
* Each worker will process items sequentially, but multiple workers will run in parallel.
|
|
115
|
-
*
|
|
116
|
-
* @function
|
|
117
|
-
* @template T
|
|
118
|
-
* @template R
|
|
119
|
-
* @param {T[]} items
|
|
120
|
-
* @param {(item: T) => Promise<R>} mapper
|
|
121
|
-
* @param {number} concurrency
|
|
122
|
-
* @returns {Promise<(R|Error)[]>}
|
|
123
|
-
*/
|
|
124
|
-
export declare function mapConcurrently<T, R>(items: T[], mapper: (item: T) => Promise<R>, concurrency: number): Promise<(R | Error)[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-code-infra",
|
|
3
|
-
"version": "0.0.4-canary.
|
|
3
|
+
"version": "0.0.4-canary.118",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Infra scripts and configs to be used across MUI repos.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@mui/internal-babel-plugin-display-name": "1.0.4-canary.24",
|
|
71
71
|
"@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.31",
|
|
72
72
|
"@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.44",
|
|
73
|
-
"@napi-rs/keyring": "^
|
|
73
|
+
"@napi-rs/keyring": "^2.0.0",
|
|
74
74
|
"@octokit/auth-action": "^6.0.3",
|
|
75
75
|
"@octokit/oauth-methods": "^6.0.5",
|
|
76
76
|
"@octokit/rest": "^22.0.1",
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
"publishConfig": {
|
|
188
188
|
"access": "public"
|
|
189
189
|
},
|
|
190
|
-
"gitSha": "
|
|
190
|
+
"gitSha": "846b7b8f4d88160e7afd463516f4b8b2d97d2326",
|
|
191
191
|
"scripts": {
|
|
192
192
|
"build": "tsc -p tsconfig.build.json",
|
|
193
193
|
"typescript": "tsc -noEmit",
|
package/src/cli/cmdBuild.mjs
CHANGED
|
@@ -5,13 +5,13 @@ import * as fs from 'node:fs/promises';
|
|
|
5
5
|
import * as path from 'node:path';
|
|
6
6
|
import { sep as posixSep } from 'node:path/posix';
|
|
7
7
|
import * as semver from 'semver';
|
|
8
|
+
import { mapAsync } from 'es-toolkit/array';
|
|
8
9
|
|
|
9
10
|
import {
|
|
10
11
|
createPackageBin,
|
|
11
12
|
createPackageExports,
|
|
12
13
|
createPackageImports,
|
|
13
14
|
getOutExtension,
|
|
14
|
-
mapConcurrently,
|
|
15
15
|
validatePkgJson,
|
|
16
16
|
} from '../utils/build.mjs';
|
|
17
17
|
import { readPnpmConfig } from '../utils/pnpm.mjs';
|
|
@@ -478,7 +478,7 @@ async function copyHandler({ cwd, globs = [], buildDir, verbose = false }) {
|
|
|
478
478
|
console.log('⓿ No files to copy.');
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
await
|
|
481
|
+
await mapAsync(
|
|
482
482
|
defaultFiles,
|
|
483
483
|
async (file) => {
|
|
484
484
|
if (typeof file === 'string') {
|
|
@@ -491,7 +491,7 @@ async function copyHandler({ cwd, globs = [], buildDir, verbose = false }) {
|
|
|
491
491
|
await recursiveCopy({ source: file.sourcePath, target: file.targetPath, verbose });
|
|
492
492
|
}
|
|
493
493
|
},
|
|
494
|
-
20,
|
|
494
|
+
{ concurrency: 20 },
|
|
495
495
|
);
|
|
496
496
|
console.log(`📋 Copied ${defaultFiles.length} files.`);
|
|
497
497
|
}
|
package/src/cli/cmdCopyFiles.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { findWorkspaceDir } from '@pnpm/find-workspace-dir';
|
|
|
2
2
|
import { globby } from 'globby';
|
|
3
3
|
import fs from 'node:fs/promises';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import { mapAsync } from 'es-toolkit/array';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {Object} Args
|
|
@@ -106,12 +106,12 @@ async function processGlobs({ globs, cwd, silent = true, buildDir }) {
|
|
|
106
106
|
});
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
await
|
|
109
|
+
await mapAsync(
|
|
110
110
|
filesToProcess,
|
|
111
111
|
async (file) => {
|
|
112
112
|
await recursiveCopy({ source: file.sourcePath, target: file.targetPath, silent });
|
|
113
113
|
},
|
|
114
|
-
50,
|
|
114
|
+
{ concurrency: 50 },
|
|
115
115
|
);
|
|
116
116
|
return filesToProcess.length;
|
|
117
117
|
}
|
package/src/cli/cmdVale.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import * as path from 'node:path';
|
|
|
7
7
|
import { pipeline } from 'node:stream/promises';
|
|
8
8
|
import { findWorkspaceDir } from '@pnpm/find-workspace-dir';
|
|
9
9
|
import { $ } from 'execa';
|
|
10
|
-
import {
|
|
10
|
+
import { mapAsync } from 'es-toolkit/array';
|
|
11
11
|
|
|
12
12
|
const LATEST_RELEASE_URL = 'https://api.github.com/repos/vale-cli/vale/releases/latest';
|
|
13
13
|
|
|
@@ -342,7 +342,7 @@ export function getReplacementText(alert) {
|
|
|
342
342
|
export async function applyFixes(results, fixLevel) {
|
|
343
343
|
const entries = Object.entries(results);
|
|
344
344
|
|
|
345
|
-
const perFileResults = await
|
|
345
|
+
const perFileResults = await mapAsync(
|
|
346
346
|
entries,
|
|
347
347
|
async ([filePath, alerts]) => {
|
|
348
348
|
const content = await fs.readFile(filePath, 'utf-8');
|
|
@@ -406,15 +406,12 @@ export async function applyFixes(results, fixLevel) {
|
|
|
406
406
|
|
|
407
407
|
return { fixed: fileFixed, skipped: alerts.length - fixableAlerts.length };
|
|
408
408
|
},
|
|
409
|
-
10,
|
|
409
|
+
{ concurrency: 10 },
|
|
410
410
|
);
|
|
411
411
|
|
|
412
412
|
let fixed = 0;
|
|
413
413
|
let skipped = 0;
|
|
414
414
|
for (const result of perFileResults) {
|
|
415
|
-
if (result instanceof Error) {
|
|
416
|
-
throw result;
|
|
417
|
-
}
|
|
418
415
|
fixed += result.fixed;
|
|
419
416
|
skipped += result.skipped;
|
|
420
417
|
}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
import { globby } from 'globby';
|
|
3
3
|
import * as fs from 'node:fs/promises';
|
|
4
4
|
import { findWorkspaceDir } from '@pnpm/find-workspace-dir';
|
|
5
|
-
|
|
6
|
-
import { mapConcurrently } from '../utils/build.mjs';
|
|
5
|
+
import { mapAsync } from 'es-toolkit/array';
|
|
7
6
|
|
|
8
7
|
const DYNAMIC_PACKAGES_IMPORT_REGEX = /import\((['"])packages\//gm;
|
|
9
8
|
|
|
@@ -22,14 +21,14 @@ async function validateFiles() {
|
|
|
22
21
|
});
|
|
23
22
|
|
|
24
23
|
const invalidFiles = (
|
|
25
|
-
await
|
|
24
|
+
await mapAsync(
|
|
26
25
|
declarationFiles,
|
|
27
26
|
async (declarationFile) => {
|
|
28
27
|
const content = await fs.readFile(declarationFile, 'utf-8');
|
|
29
28
|
const matches = Array.from(content.matchAll(DYNAMIC_PACKAGES_IMPORT_REGEX));
|
|
30
29
|
return matches.length > 0 ? declarationFile : undefined;
|
|
31
30
|
},
|
|
32
|
-
20,
|
|
31
|
+
{ concurrency: 20 },
|
|
33
32
|
)
|
|
34
33
|
).filter((file) => typeof file === 'string');
|
|
35
34
|
|
package/src/utils/build.mjs
CHANGED
|
@@ -894,42 +894,3 @@ export function measureFn(label) {
|
|
|
894
894
|
const endMark = `${label}-end`;
|
|
895
895
|
return performance.measure(label, startMark, endMark);
|
|
896
896
|
}
|
|
897
|
-
|
|
898
|
-
/**
|
|
899
|
-
* A utility to map a function over an array of items in a worker pool.
|
|
900
|
-
*
|
|
901
|
-
* This function will create a pool of workers and distribute the items to be processed among them.
|
|
902
|
-
* Each worker will process items sequentially, but multiple workers will run in parallel.
|
|
903
|
-
*
|
|
904
|
-
* @function
|
|
905
|
-
* @template T
|
|
906
|
-
* @template R
|
|
907
|
-
* @param {T[]} items
|
|
908
|
-
* @param {(item: T) => Promise<R>} mapper
|
|
909
|
-
* @param {number} concurrency
|
|
910
|
-
* @returns {Promise<(R|Error)[]>}
|
|
911
|
-
*/
|
|
912
|
-
export async function mapConcurrently(items, mapper, concurrency) {
|
|
913
|
-
if (!items.length) {
|
|
914
|
-
return Promise.resolve([]); // nothing to do
|
|
915
|
-
}
|
|
916
|
-
const itemIterator = items.entries();
|
|
917
|
-
const count = Math.min(concurrency, items.length);
|
|
918
|
-
const workers = [];
|
|
919
|
-
/**
|
|
920
|
-
* @type {(R|Error)[]}
|
|
921
|
-
*/
|
|
922
|
-
const results = new Array(items.length);
|
|
923
|
-
for (let i = 0; i < count; i += 1) {
|
|
924
|
-
const worker = Promise.resolve().then(async () => {
|
|
925
|
-
for (const [index, item] of itemIterator) {
|
|
926
|
-
// eslint-disable-next-line no-await-in-loop
|
|
927
|
-
const res = await mapper(item);
|
|
928
|
-
results[index] = res;
|
|
929
|
-
}
|
|
930
|
-
});
|
|
931
|
-
workers.push(worker);
|
|
932
|
-
}
|
|
933
|
-
await Promise.all(workers);
|
|
934
|
-
return results;
|
|
935
|
-
}
|
|
@@ -6,9 +6,10 @@ import minifyErrorsPlugin from '@mui/internal-babel-plugin-minify-errors';
|
|
|
6
6
|
import { globby } from 'globby';
|
|
7
7
|
import * as fs from 'node:fs/promises';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
|
+
import { mapAsync } from 'es-toolkit/array';
|
|
9
10
|
|
|
10
11
|
import { getWorkspacePackages } from './pnpm.mjs';
|
|
11
|
-
import { BASE_IGNORES
|
|
12
|
+
import { BASE_IGNORES } from './build.mjs';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @typedef {Object} Args
|
|
@@ -52,7 +53,7 @@ async function getFilesForPackage(pkg) {
|
|
|
52
53
|
* @param {import('@mui/internal-babel-plugin-minify-errors').Options['detection']} [detection='opt-in']
|
|
53
54
|
*/
|
|
54
55
|
async function extractErrorCodesForWorkspace(files, errors, detection = 'opt-in') {
|
|
55
|
-
await
|
|
56
|
+
await mapAsync(
|
|
56
57
|
files,
|
|
57
58
|
async (fullPath) => {
|
|
58
59
|
const code = await fs.readFile(fullPath, 'utf8');
|
|
@@ -71,7 +72,7 @@ async function extractErrorCodesForWorkspace(files, errors, detection = 'opt-in'
|
|
|
71
72
|
code: false,
|
|
72
73
|
});
|
|
73
74
|
},
|
|
74
|
-
30,
|
|
75
|
+
{ concurrency: 30 },
|
|
75
76
|
);
|
|
76
77
|
}
|
|
77
78
|
|
package/src/utils/typescript.mjs
CHANGED
|
@@ -9,7 +9,8 @@ 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
|
|
|
@@ -145,7 +146,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
|
|
|
145
146
|
return;
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
await
|
|
149
|
+
await mapAsync(
|
|
149
150
|
dtsFiles,
|
|
150
151
|
async (dtsFile) => {
|
|
151
152
|
// Normalize to native separators to make path comparisons reliable on Windows
|
|
@@ -198,7 +199,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
|
|
|
198
199
|
await fs.unlink(nativeDtsFile);
|
|
199
200
|
}
|
|
200
201
|
},
|
|
201
|
-
30,
|
|
202
|
+
{ concurrency: 30 },
|
|
202
203
|
);
|
|
203
204
|
}
|
|
204
205
|
|