@mui/internal-code-infra 0.0.4-canary.50 → 0.0.4-canary.51

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
3
  Copyright (c) 2019 Material-UI SAS
4
4
 
@@ -2,6 +2,7 @@
2
2
  export type Args = {
3
3
  workspaces: string[];
4
4
  check?: boolean;
5
+ baseBranch?: string;
5
6
  };
6
7
  declare const _default: import('yargs').CommandModule<{}, Args>;
7
8
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-code-infra",
3
- "version": "0.0.4-canary.50",
3
+ "version": "0.0.4-canary.51",
4
4
  "author": "MUI Team",
5
5
  "description": "Infra scripts and configs to be used across MUI repos.",
6
6
  "license": "MIT",
@@ -139,8 +139,8 @@
139
139
  "unified-lint-rule": "^3.0.1",
140
140
  "unist-util-visit": "^5.1.0",
141
141
  "yargs": "^18.0.0",
142
- "@mui/internal-babel-plugin-display-name": "1.0.4-canary.20",
143
142
  "@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.27",
143
+ "@mui/internal-babel-plugin-display-name": "1.0.4-canary.20",
144
144
  "@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.36"
145
145
  },
146
146
  "peerDependencies": {
@@ -191,7 +191,7 @@
191
191
  "publishConfig": {
192
192
  "access": "public"
193
193
  },
194
- "gitSha": "4c409b3d174cfefb32e4a3fe633f9aa46f53bce3",
194
+ "gitSha": "07f5cf7dc82ab59819f83022d5ebc01c5d50c301",
195
195
  "scripts": {
196
196
  "build": "tsgo -p tsconfig.build.json",
197
197
  "typescript": "tsgo -noEmit",
@@ -6,6 +6,7 @@
6
6
  * @typedef {Object} Args
7
7
  * @property {string[]} workspaces - List of workspace names to process
8
8
  * @property {boolean} [check] - Check mode - error if the generated content differs from current
9
+ * @property {string} [baseBranch] - Branch to compare PRs against (default: master)
9
10
  */
10
11
 
11
12
  import * as fs from 'node:fs/promises';
@@ -15,16 +16,30 @@ import { toPosixPath } from '../utils/path.mjs';
15
16
  import { getTransitiveDependencies, getWorkspacePackages } from '../utils/pnpm.mjs';
16
17
 
17
18
  /**
18
- * Generate the ignore command string for netlify.toml
19
+ * Generate the ignore command string for netlify.toml.
20
+ *
21
+ * Production builds (Netlify's $CONTEXT === "production" — i.e. any branch
22
+ * configured as the site's production branch, whatever its name) always
23
+ * build, so downstream plugins (e.g. e2e triggers) run on every commit and
24
+ * catch regressions in external dependencies even when the commit doesn't
25
+ * touch the watched paths.
26
+ *
27
+ * Every other context (deploy-preview, branch-deploy) diffs against the
28
+ * merge-base with origin/<baseBranch>. This way a PR rebase whose head
29
+ * commit doesn't touch the watched paths still rebuilds when the PR as a
30
+ * whole introduces changes to them — otherwise downstream plugins silently
31
+ * never run.
32
+ *
19
33
  * @param {string[]} paths - Array of paths to include in the ignore command
20
34
  * @param {string} packagePath - Absolute path to the package directory
21
35
  * @param {string} workspaceRoot - Absolute path to the workspace root
36
+ * @param {string} baseBranch - Branch to compare PRs against
22
37
  * @returns {string} The ignore command string
23
38
  */
24
- function generateIgnoreCommand(paths, packagePath, workspaceRoot) {
39
+ function generateIgnoreCommand(paths, packagePath, workspaceRoot, baseBranch) {
25
40
  const relFromBase = `${toPosixPath(path.relative(packagePath, workspaceRoot))}/`;
26
41
  const pathsStr = paths.join(' ');
27
- return ` ignore = "cd ${relFromBase} && git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ${pathsStr}"`;
42
+ return ` ignore = """cd ${relFromBase} && [ "$CONTEXT" != "production" ] && git fetch origin ${baseBranch} --depth=500 -q && git diff --quiet FETCH_HEAD...$COMMIT_REF -- ${pathsStr}"""`;
28
43
  }
29
44
 
30
45
  /**
@@ -94,6 +109,12 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
94
109
  default: false,
95
110
  describe: 'Check if the netlify.toml needs updating without modifying it',
96
111
  })
112
+ .option('base-branch', {
113
+ type: 'string',
114
+ default: 'master',
115
+ describe:
116
+ "Branch to compare PRs against (the site's production branch on Netlify). Production builds always rebuild regardless of this value.",
117
+ })
97
118
  .example('$0 netlify-ignore @mui/internal-docs-infra', 'Update netlify.toml for a workspace')
98
119
  .example(
99
120
  '$0 netlify-ignore @mui/internal-docs-infra @mui/internal-code-infra',
@@ -105,7 +126,7 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
105
126
  );
106
127
  },
107
128
  handler: async (argv) => {
108
- const { workspaces, check = false } = argv;
129
+ const { workspaces, check = false, baseBranch = 'master' } = argv;
109
130
 
110
131
  // Get the workspace root
111
132
  const workspaceRoot = await findWorkspaceDir(process.cwd());
@@ -157,7 +178,12 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
157
178
  const allPaths = [...relativePaths, 'pnpm-lock.yaml'];
158
179
 
159
180
  // Generate the ignore command for this workspace
160
- const newIgnoreCommand = generateIgnoreCommand(allPaths, workspacePath, workspaceRoot);
181
+ const newIgnoreCommand = generateIgnoreCommand(
182
+ allPaths,
183
+ workspacePath,
184
+ workspaceRoot,
185
+ baseBranch,
186
+ );
161
187
 
162
188
  // Update or check the netlify.toml file
163
189
  await updateNetlifyToml(tomlPath, newIgnoreCommand, check);