@mui/internal-code-infra 0.1.1-canary.13 → 0.1.1-canary.15
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 +3 -3
- package/build/utils/build.d.mts +14 -0
- package/package.json +3 -2
- package/src/cli/cmdBuild.mjs +2 -0
- package/src/utils/build.mjs +34 -0
package/README.md
CHANGED
|
@@ -14,9 +14,9 @@ This is stored in the `docs` top-level directory.
|
|
|
14
14
|
|
|
15
15
|
1. Go to the publish action -
|
|
16
16
|
|
|
17
|
-
- [Base
|
|
17
|
+
- [Base UI](https://github.com/mui/base-ui/actions/workflows/publish.yml)
|
|
18
18
|
- [Core](https://github.com/mui/material-ui/actions/workflows/publish.yml)
|
|
19
|
-
- [MUI
|
|
19
|
+
- [MUI X](https://github.com/mui/mui-x/actions/workflows/publish.yml)
|
|
20
20
|
|
|
21
21
|
2. Choose "Run workflow" dropdown
|
|
22
22
|
|
|
@@ -59,7 +59,7 @@ If publishing fails with npm asking for `otp`, run the command again with 6 digi
|
|
|
59
59
|
pnpm code-infra publish-new-package --otp=123456
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
3. Go to the settings link for each package,
|
|
62
|
+
3. Go to the settings link for each package, for example, `https://www.npmjs.com/package/<pkg-name>/access`, and setup `Trusted Publisher`.
|
|
63
63
|
4. In the `Select your publisher` step in the above link, click on the `GitHub Actions` button to configure GitHub Actions-based trusted publishing.
|
|
64
64
|
5. Fill in the details of the repo -
|
|
65
65
|
1. `Organization or user` as `mui`,
|
package/build/utils/build.d.mts
CHANGED
|
@@ -93,6 +93,20 @@ export declare function validatePkgJson(packageJson: Record<string, any>, option
|
|
|
93
93
|
skipMainCheck?: boolean;
|
|
94
94
|
enableReactCompiler?: boolean;
|
|
95
95
|
}): void;
|
|
96
|
+
/**
|
|
97
|
+
* Validates that "engines.node" in package.json doesn't allow Node.js versions older than the
|
|
98
|
+
* "node" browserslist environment, which the CommonJS bundle is compiled for. Otherwise the
|
|
99
|
+
* build can emit syntax that the oldest supported Node.js version can't run.
|
|
100
|
+
* Targets are resolved the same way `@babel/preset-env` resolves them during the build.
|
|
101
|
+
* @param {{ name?: string; engines?: { node?: string } }} packageJson
|
|
102
|
+
* @param {string} cwd - The package directory, used to find the browserslist config.
|
|
103
|
+
*/
|
|
104
|
+
export declare function validateEnginesNode(packageJson: {
|
|
105
|
+
name?: string;
|
|
106
|
+
engines?: {
|
|
107
|
+
node?: string;
|
|
108
|
+
};
|
|
109
|
+
}, cwd: string): void;
|
|
96
110
|
/**
|
|
97
111
|
* Marks the start and end of a function execution for performance measurement.
|
|
98
112
|
* Uses the Performance API to create marks and measure the duration.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-code-infra",
|
|
3
|
-
"version": "0.1.1-canary.
|
|
3
|
+
"version": "0.1.1-canary.15",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Infra scripts and configs to be used across MUI repos.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"@argos-ci/core": "6.8.7",
|
|
57
57
|
"@babel/cli": "^8.0.6",
|
|
58
58
|
"@babel/core": "^8.0.7",
|
|
59
|
+
"@babel/helper-compilation-targets": "^8.0.7",
|
|
59
60
|
"@babel/plugin-syntax-jsx": "^8.0.1",
|
|
60
61
|
"@babel/plugin-syntax-typescript": "^8.0.3",
|
|
61
62
|
"@babel/plugin-transform-react-pure-annotations": "^8.0.1",
|
|
@@ -189,7 +190,7 @@
|
|
|
189
190
|
"publishConfig": {
|
|
190
191
|
"access": "public"
|
|
191
192
|
},
|
|
192
|
-
"gitSha": "
|
|
193
|
+
"gitSha": "4ee02d8d0a78249ef9aadb30f919489c56b89ebe",
|
|
193
194
|
"scripts": {
|
|
194
195
|
"build": "tsc -p tsconfig.build.json",
|
|
195
196
|
"typescript": "tsc -noEmit",
|
package/src/cli/cmdBuild.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
createPackageExports,
|
|
13
13
|
createPackageImports,
|
|
14
14
|
getOutExtension,
|
|
15
|
+
validateEnginesNode,
|
|
15
16
|
validatePkgJson,
|
|
16
17
|
} from '../utils/build.mjs';
|
|
17
18
|
import { readPnpmConfig } from '../utils/pnpm.mjs';
|
|
@@ -266,6 +267,7 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
|
|
|
266
267
|
const pkgJsonPath = path.join(cwd, 'package.json');
|
|
267
268
|
const packageJson = JSON.parse(await fs.readFile(pkgJsonPath, { encoding: 'utf8' }));
|
|
268
269
|
validatePkgJson(packageJson, { skipMainCheck: args.skipMainCheck, enableReactCompiler });
|
|
270
|
+
validateEnginesNode(packageJson, cwd);
|
|
269
271
|
|
|
270
272
|
const buildDirBase = /** @type {string} */ (packageJson.publishConfig?.directory);
|
|
271
273
|
const buildDir = path.join(cwd, buildDirBase);
|
package/src/utils/build.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
+
import getTargets from '@babel/helper-compilation-targets';
|
|
3
4
|
import { globby } from 'globby';
|
|
4
5
|
import * as semver from 'semver';
|
|
5
6
|
|
|
@@ -867,6 +868,39 @@ export function validatePkgJson(packageJson, options = {}) {
|
|
|
867
868
|
}
|
|
868
869
|
}
|
|
869
870
|
|
|
871
|
+
/**
|
|
872
|
+
* Validates that "engines.node" in package.json doesn't allow Node.js versions older than the
|
|
873
|
+
* "node" browserslist environment, which the CommonJS bundle is compiled for. Otherwise the
|
|
874
|
+
* build can emit syntax that the oldest supported Node.js version can't run.
|
|
875
|
+
* Targets are resolved the same way `@babel/preset-env` resolves them during the build.
|
|
876
|
+
* @param {{ name?: string; engines?: { node?: string } }} packageJson
|
|
877
|
+
* @param {string} cwd - The package directory, used to find the browserslist config.
|
|
878
|
+
*/
|
|
879
|
+
export function validateEnginesNode(packageJson, cwd) {
|
|
880
|
+
const enginesNode = packageJson.engines?.node;
|
|
881
|
+
if (!enginesNode) {
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
const minEnginesVersion = semver.minVersion(enginesNode);
|
|
886
|
+
if (!minEnginesVersion) {
|
|
887
|
+
throw new Error(
|
|
888
|
+
`Unable to determine the minimum Node.js version from "engines.node" in "${packageJson.name}" package.json: "${enginesNode}".`,
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
const targetNode = getTargets(undefined, { configPath: cwd, browserslistEnv: 'node' }).node;
|
|
893
|
+
if (!targetNode) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
if (semver.gt(targetNode, minEnginesVersion)) {
|
|
898
|
+
throw new Error(
|
|
899
|
+
`"engines.node" in "${packageJson.name}" package.json allows Node.js ${minEnginesVersion.version}, but the "node" browserslist environment compiles for Node.js ${targetNode} and up. Raise "engines.node" to at least ${targetNode}, or lower the "node" browserslist target.`,
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
870
904
|
/**
|
|
871
905
|
* Marks the start and end of a function execution for performance measurement.
|
|
872
906
|
* Uses the Performance API to create marks and measure the duration.
|