@mui/internal-code-infra 0.0.4-canary.4 → 0.0.4-canary.41
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 +19 -8
- package/build/babel-config.d.mts +11 -3
- package/build/brokenLinksChecker/crawlWorker.d.mts +1 -0
- package/build/brokenLinksChecker/index.d.mts +45 -2
- package/build/changelog/types.d.ts +1 -1
- package/build/cli/cmdArgosPush.d.mts +2 -2
- package/build/cli/cmdBuild.d.mts +2 -2
- package/build/cli/cmdCopyFiles.d.mts +2 -2
- package/build/cli/cmdExtractErrorCodes.d.mts +2 -2
- package/build/cli/cmdGenerateChangelog.d.mts +2 -2
- package/build/cli/cmdGithubAuth.d.mts +2 -2
- package/build/cli/cmdListWorkspaces.d.mts +4 -2
- package/build/cli/cmdNetlifyIgnore.d.mts +2 -2
- package/build/cli/cmdPublish.d.mts +4 -2
- package/build/cli/cmdPublishCanary.d.mts +3 -2
- package/build/cli/cmdPublishNewPackage.d.mts +4 -2
- package/build/cli/cmdSetVersionOverrides.d.mts +2 -2
- package/build/cli/cmdVale.d.mts +46 -0
- package/build/cli/cmdValidateBuiltTypes.d.mts +2 -2
- package/build/eslint/baseConfig.d.mts +3 -1
- package/build/eslint/mui/rules/disallow-react-api-in-server-components.d.mts +2 -2
- package/build/eslint/mui/rules/docgen-ignore-before-comment.d.mts +2 -2
- package/build/eslint/mui/rules/no-guarded-throw.d.mts +31 -0
- package/build/eslint/mui/rules/no-restricted-resolved-imports.d.mts +2 -2
- package/build/eslint/mui/rules/nodeEnvUtils.d.mts +18 -0
- package/build/markdownlint/duplicate-h1.d.mts +1 -1
- package/build/markdownlint/git-diff.d.mts +1 -1
- package/build/markdownlint/index.d.mts +1 -1
- package/build/markdownlint/straight-quotes.d.mts +1 -1
- package/build/markdownlint/table-alignment.d.mts +1 -1
- package/build/markdownlint/terminal-language.d.mts +1 -1
- package/build/remark/config.d.mts +43 -0
- package/build/remark/createLintTester.d.mts +10 -0
- package/build/remark/firstBlockHeading.d.mts +4 -0
- package/build/remark/gitDiff.d.mts +2 -0
- package/build/remark/noSpaceInLinks.d.mts +2 -0
- package/build/remark/straightQuotes.d.mts +2 -0
- package/build/remark/tableAlignment.d.mts +2 -0
- package/build/remark/terminalLanguage.d.mts +2 -0
- package/build/utils/build.d.mts +3 -3
- package/build/utils/github.d.mts +1 -1
- package/build/utils/pnpm.d.mts +68 -2
- package/build/utils/testUtils.d.mts +7 -0
- package/package.json +59 -32
- package/src/babel-config.mjs +9 -3
- package/src/brokenLinksChecker/__fixtures__/static-site/index.html +1 -0
- package/src/brokenLinksChecker/__fixtures__/static-site/invalid-html.html +15 -0
- package/src/brokenLinksChecker/crawlWorker.mjs +212 -0
- package/src/brokenLinksChecker/index.mjs +215 -164
- package/src/brokenLinksChecker/index.test.ts +43 -13
- package/src/changelog/categorizeCommits.test.ts +5 -5
- package/src/changelog/fetchChangelogs.mjs +6 -2
- package/src/changelog/parseCommitLabels.test.ts +5 -5
- package/src/changelog/renderChangelog.mjs +1 -1
- package/src/changelog/types.ts +1 -1
- package/src/cli/cmdListWorkspaces.mjs +9 -2
- package/src/cli/cmdNetlifyIgnore.mjs +4 -88
- package/src/cli/cmdPublish.mjs +51 -14
- package/src/cli/cmdPublishCanary.mjs +139 -107
- package/src/cli/cmdPublishNewPackage.mjs +27 -6
- package/src/cli/cmdVale.mjs +513 -0
- package/src/cli/cmdVale.test.mjs +644 -0
- package/src/cli/index.mjs +2 -0
- package/src/eslint/baseConfig.mjs +45 -20
- package/src/eslint/docsConfig.mjs +2 -1
- package/src/eslint/jsonConfig.mjs +2 -1
- package/src/eslint/mui/config.mjs +20 -1
- package/src/eslint/mui/index.mjs +2 -0
- package/src/eslint/mui/rules/no-guarded-throw.mjs +115 -0
- package/src/eslint/mui/rules/no-guarded-throw.test.mjs +206 -0
- package/src/eslint/mui/rules/nodeEnvUtils.mjs +52 -0
- package/src/eslint/mui/rules/require-dev-wrapper.mjs +25 -40
- package/src/eslint/testConfig.mjs +2 -1
- package/src/estree-typescript.d.ts +1 -1
- package/src/remark/config.mjs +157 -0
- package/src/remark/createLintTester.mjs +19 -0
- package/src/remark/firstBlockHeading.mjs +87 -0
- package/src/remark/firstBlockHeading.test.mjs +107 -0
- package/src/remark/gitDiff.mjs +43 -0
- package/src/remark/gitDiff.test.mjs +45 -0
- package/src/remark/noSpaceInLinks.mjs +42 -0
- package/src/remark/noSpaceInLinks.test.mjs +22 -0
- package/src/remark/straightQuotes.mjs +31 -0
- package/src/remark/straightQuotes.test.mjs +25 -0
- package/src/remark/tableAlignment.mjs +23 -0
- package/src/remark/tableAlignment.test.mjs +28 -0
- package/src/remark/terminalLanguage.mjs +19 -0
- package/src/remark/terminalLanguage.test.mjs +17 -0
- package/src/untyped-plugins.d.ts +11 -11
- package/src/utils/build.test.mjs +546 -575
- package/src/utils/pnpm.mjs +192 -3
- package/src/utils/pnpm.test.mjs +580 -0
- package/src/utils/testUtils.mjs +18 -0
- package/src/utils/typescript.test.mjs +249 -272
- package/vale/.vale.ini +1 -0
- package/vale/styles/MUI/CorrectReferenceAllCases.yml +43 -0
- package/vale/styles/MUI/CorrectRererenceCased.yml +14 -0
- package/vale/styles/MUI/GoogleLatin.yml +11 -0
- package/vale/styles/MUI/MuiBrandName.yml +22 -0
- package/vale/styles/MUI/NoBritish.yml +112 -0
- package/vale/styles/MUI/NoCompanyName.yml +17 -0
package/src/utils/pnpm.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { findWorkspaceDir } from '@pnpm/find-workspace-dir';
|
|
3
4
|
import { $ } from 'execa';
|
|
4
5
|
import * as fs from 'node:fs/promises';
|
|
5
6
|
import * as path from 'node:path';
|
|
@@ -48,6 +49,7 @@ import * as semver from 'semver';
|
|
|
48
49
|
* @property {boolean} [publicOnly=false] - Whether to filter to only public packages
|
|
49
50
|
* @property {boolean} [nonPublishedOnly=false] - Whether to filter to only non-published packages. It by default means public packages yet to be published.
|
|
50
51
|
* @property {string} [cwd] - Current working directory to run pnpm command in
|
|
52
|
+
* @property {string[]} [filter] - Same as filtering packages with --filter in pnpm. Only include packages matching the filter. See https://pnpm.io/filtering.
|
|
51
53
|
*/
|
|
52
54
|
|
|
53
55
|
/**
|
|
@@ -73,10 +75,15 @@ import * as semver from 'semver';
|
|
|
73
75
|
* @returns {Promise<(PrivatePackage | PublicPackage)[]>} Array of packages
|
|
74
76
|
*/
|
|
75
77
|
export async function getWorkspacePackages(options = {}) {
|
|
76
|
-
const { sinceRef = null, publicOnly = false, nonPublishedOnly = false } = options;
|
|
78
|
+
const { sinceRef = null, publicOnly = false, nonPublishedOnly = false, filter = [] } = options;
|
|
77
79
|
|
|
78
80
|
// Build command with conditional filter
|
|
79
81
|
const filterArg = sinceRef ? ['--filter', `...[${sinceRef}]`] : [];
|
|
82
|
+
if (filter.length > 0) {
|
|
83
|
+
filter.forEach((f) => {
|
|
84
|
+
filterArg.push('--filter', f);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
80
87
|
const result = options.cwd
|
|
81
88
|
? await $({ cwd: options.cwd })`pnpm ls -r --json --depth -1 ${filterArg}`
|
|
82
89
|
: await $`pnpm ls -r --json --depth -1 ${filterArg}`;
|
|
@@ -148,11 +155,17 @@ export async function getPackageVersionInfo(packageName, baseVersion) {
|
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
157
|
|
|
158
|
+
/**
|
|
159
|
+
* @typedef {Object} PublishSummaryEntry
|
|
160
|
+
* @property {string} name
|
|
161
|
+
* @property {string} version
|
|
162
|
+
*/
|
|
163
|
+
|
|
151
164
|
/**
|
|
152
165
|
* Publish packages with the given options
|
|
153
166
|
* @param {PublicPackage[]} packages - Packages to publish
|
|
154
167
|
* @param {PublishOptions} [options={}] - Publishing options
|
|
155
|
-
* @returns {Promise<
|
|
168
|
+
* @returns {Promise<PublishSummaryEntry[]>}
|
|
156
169
|
*/
|
|
157
170
|
export async function publishPackages(packages, options = {}) {
|
|
158
171
|
const args = [];
|
|
@@ -172,7 +185,183 @@ export async function publishPackages(packages, options = {}) {
|
|
|
172
185
|
args.push('--no-git-checks');
|
|
173
186
|
}
|
|
174
187
|
|
|
175
|
-
|
|
188
|
+
const workspaceDir = await findWorkspaceDir(process.cwd());
|
|
189
|
+
if (!workspaceDir) {
|
|
190
|
+
throw new Error('Could not find pnpm workspace root');
|
|
191
|
+
}
|
|
192
|
+
const summaryPath = path.join(workspaceDir, 'pnpm-publish-summary.json');
|
|
193
|
+
|
|
194
|
+
// Clean up any leftover summary file from a previous run
|
|
195
|
+
await fs.rm(summaryPath, { force: true });
|
|
196
|
+
|
|
197
|
+
await $({
|
|
198
|
+
stdio: 'inherit',
|
|
199
|
+
env: { npm_config_loglevel: 'warn' },
|
|
200
|
+
})`pnpm -r publish --access public --tag=${tag} --report-summary ${args}`;
|
|
201
|
+
|
|
202
|
+
const summary = JSON.parse(await fs.readFile(summaryPath, 'utf-8'));
|
|
203
|
+
await fs.rm(summaryPath, { force: true });
|
|
204
|
+
return /** @type {PublishSummaryEntry[]} */ (summary.publishedPackages);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @typedef {Object} GetTransitiveDependenciesOptions
|
|
209
|
+
* @property {Map<string, string>} [workspacePathByName] - Map of workspace package name to directory path
|
|
210
|
+
* @property {boolean} [includeDev=true] - Whether to include devDependencies in the traversal
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Get all transitive workspace dependencies for a set of packages.
|
|
215
|
+
*
|
|
216
|
+
* Only follows deps whose version spec starts with `workspace:` (e.g. `workspace:*`
|
|
217
|
+
* or `workspace:^`), meaning they are sourced directly from the monorepo. Pinned
|
|
218
|
+
* external versions (e.g. `^1.0.0`) are ignored even when the package name exists
|
|
219
|
+
* in the workspace. Traverses `dependencies` and optionally `devDependencies`.
|
|
220
|
+
* Results are cached per package so each package is read from disk at most once
|
|
221
|
+
* regardless of how many roots depend on it.
|
|
222
|
+
*
|
|
223
|
+
* @param {string[]} packageNames - Package names to start the traversal from
|
|
224
|
+
* @param {GetTransitiveDependenciesOptions} [options]
|
|
225
|
+
* @returns {Promise<Set<string>>} All reachable workspace package names, including the input packages themselves
|
|
226
|
+
*/
|
|
227
|
+
export async function getTransitiveDependencies(packageNames, options = {}) {
|
|
228
|
+
const { includeDev = true, workspacePathByName = new Map() } = options;
|
|
229
|
+
|
|
230
|
+
/** @type {Map<string, Promise<Set<string>>>} */
|
|
231
|
+
const cache = new Map();
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @param {string} packageName
|
|
235
|
+
* @returns {Promise<Set<string>>}
|
|
236
|
+
*/
|
|
237
|
+
function collectDeps(packageName) {
|
|
238
|
+
const cached = cache.get(packageName);
|
|
239
|
+
if (cached) {
|
|
240
|
+
return cached;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const promise = (async () => {
|
|
244
|
+
const packagePath = workspacePathByName.get(packageName);
|
|
245
|
+
if (!packagePath) {
|
|
246
|
+
throw new Error(`Workspace "${packageName}" not found`);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const pkgJson = await readPackageJson(packagePath);
|
|
250
|
+
const allDepEntries = [
|
|
251
|
+
...Object.entries(pkgJson.dependencies ?? {}),
|
|
252
|
+
...(includeDev ? Object.entries(pkgJson.devDependencies ?? {}) : []),
|
|
253
|
+
];
|
|
254
|
+
const workspaceDeps = allDepEntries
|
|
255
|
+
.filter(
|
|
256
|
+
([dep, spec]) =>
|
|
257
|
+
workspacePathByName.has(dep) &&
|
|
258
|
+
typeof spec === 'string' &&
|
|
259
|
+
spec.startsWith('workspace:'),
|
|
260
|
+
)
|
|
261
|
+
.map(([dep]) => dep);
|
|
262
|
+
|
|
263
|
+
const recursiveResults = await Promise.all(workspaceDeps.map(collectDeps));
|
|
264
|
+
return new Set([...workspaceDeps, ...recursiveResults.flatMap((s) => [...s])]);
|
|
265
|
+
})();
|
|
266
|
+
|
|
267
|
+
cache.set(packageName, promise);
|
|
268
|
+
return promise;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
for (const name of packageNames) {
|
|
272
|
+
if (!workspacePathByName.has(name)) {
|
|
273
|
+
throw new Error(`Workspace "${name}" not found`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const results = await Promise.all(packageNames.map(collectDeps));
|
|
278
|
+
return new Set([...packageNames, ...results.flatMap((s) => [...s])]);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Pure validation logic: given a publish set and workspace maps, checks that all
|
|
283
|
+
* transitive hard workspace dependencies are covered and none are private.
|
|
284
|
+
*
|
|
285
|
+
* A hard dependency is one listed in `dependencies` (not `peerDependencies` or
|
|
286
|
+
* `devDependencies`) using a `workspace:` version specifier (e.g. `workspace:*` or
|
|
287
|
+
* `workspace:^`). Peer dependencies are never bundled and dev dependencies are not installed
|
|
288
|
+
* on consumer devices - both are excluded regardless of version specifier. Pinned-version
|
|
289
|
+
* references in `dependencies` are also excluded - they resolve from the registry and do
|
|
290
|
+
* not need to be co-published.
|
|
291
|
+
*
|
|
292
|
+
* @param {PublicPackage[]} packages - The packages intended for publishing
|
|
293
|
+
* @param {Map<string, PublicPackage | PrivatePackage>} workspacePackageByName - All workspace packages by name
|
|
294
|
+
* @param {Map<string, string>} workspacePathByName - Map of workspace package name to directory path
|
|
295
|
+
* @returns {Promise<{issues: string[]}>}
|
|
296
|
+
* List of human-readable issue strings. Empty when the dependency set is valid.
|
|
297
|
+
* @internal
|
|
298
|
+
*/
|
|
299
|
+
export async function checkPublishDependencies(
|
|
300
|
+
packages,
|
|
301
|
+
workspacePackageByName,
|
|
302
|
+
workspacePathByName,
|
|
303
|
+
) {
|
|
304
|
+
const publishedNames = new Set(packages.map((pkg) => pkg.name));
|
|
305
|
+
|
|
306
|
+
const transitiveDeps = await getTransitiveDependencies(
|
|
307
|
+
packages.map((pkg) => pkg.name),
|
|
308
|
+
{ includeDev: false, workspacePathByName },
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
/** @type {Set<string>} */
|
|
312
|
+
const privateButRequired = new Set();
|
|
313
|
+
/** @type {Set<string>} */
|
|
314
|
+
const missingFromPublish = new Set();
|
|
315
|
+
|
|
316
|
+
for (const depName of transitiveDeps) {
|
|
317
|
+
if (publishedNames.has(depName)) {
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
const workspacePkg = workspacePackageByName.get(depName);
|
|
321
|
+
if (workspacePkg?.isPrivate) {
|
|
322
|
+
privateButRequired.add(depName);
|
|
323
|
+
} else {
|
|
324
|
+
missingFromPublish.add(depName);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** @type {string[]} */
|
|
329
|
+
const issues = [];
|
|
330
|
+
|
|
331
|
+
if (privateButRequired.size > 0) {
|
|
332
|
+
issues.push(
|
|
333
|
+
`The following private workspace packages are required as dependencies but cannot be published: ${[...privateButRequired].join(', ')}`,
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (missingFromPublish.size > 0) {
|
|
338
|
+
issues.push(
|
|
339
|
+
`The following workspace packages are required as dependencies but are not included in the publish set: ${[...missingFromPublish].join(', ')}. Add them to the --filter list.`,
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return { issues };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Validate that a set of packages covers all of their transitive hard workspace dependencies,
|
|
348
|
+
* and that none of those dependencies are private (which would make them unpublishable).
|
|
349
|
+
*
|
|
350
|
+
* @param {PublicPackage[]} packages - The packages intended for publishing
|
|
351
|
+
* @returns {Promise<{issues: string[]}>}
|
|
352
|
+
* List of human-readable issue strings. Empty when the dependency set is valid.
|
|
353
|
+
*/
|
|
354
|
+
export async function validatePublishDependencies(packages) {
|
|
355
|
+
const allWorkspacePackages = await getWorkspacePackages();
|
|
356
|
+
|
|
357
|
+
const workspacePackageByName = /** @type {Map<string, PublicPackage | PrivatePackage>} */ (
|
|
358
|
+
new Map(allWorkspacePackages.flatMap((pkg) => (pkg.name ? [[pkg.name, pkg]] : [])))
|
|
359
|
+
);
|
|
360
|
+
const workspacePathByName = new Map(
|
|
361
|
+
allWorkspacePackages.flatMap((pkg) => (pkg.name ? [[pkg.name, pkg.path]] : [])),
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
return checkPublishDependencies(packages, workspacePackageByName, workspacePathByName);
|
|
176
365
|
}
|
|
177
366
|
|
|
178
367
|
/**
|