Skip to content

Commit 785b491

Browse files
authored
feat: support PR target setups (#95)
When using a PR target trigger, the `context.sha` is `main`, while the `pull_request.head.sha` is the PR.
1 parent c5df012 commit 785b491

File tree

4 files changed

+187
-30
lines changed

4 files changed

+187
-30
lines changed

build/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24783,8 +24783,8 @@ function comparePackSizes(basePacks, sourcePacks, threshold) {
2478324783

2478424784
// src/checks/replacements.ts
2478524785
import nativeManifest from "./native-O77SEK3D.json" with { type: "json" };
24786-
import microUtilsManifest from "./micro-utilities-74AZJTCK.json" with { type: "json" };
24787-
import preferredManifest from "./preferred-UDJHBJAQ.json" with { type: "json" };
24786+
import microUtilsManifest from "./micro-utilities-N7NZTMHQ.json" with { type: "json" };
24787+
import preferredManifest from "./preferred-S3MZM3ZJ.json" with { type: "json" };
2478824788
var allReplacements = [
2478924789
...nativeManifest.moduleReplacements,
2479024790
...microUtilsManifest.moduleReplacements,
@@ -25180,7 +25180,7 @@ async function run() {
2518025180
const workspacePath = join2(baseWorkspace, workDir);
2518125181
core7.info(`Workspace path is ${workspacePath}`);
2518225182
const baseRef = getBaseRef();
25183-
const currentRef = github2.context.sha;
25183+
const currentRef = github2.context.payload.pull_reuqest?.head.sha ?? github2.context.sha;
2518425184
const lockfileFilename = detectLockfile(workspacePath);
2518525185
core7.info(`Detected lockfile ${lockfileFilename}`);
2518625186
const token = core7.getInput("github-token", { required: true });
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
{
22
"moduleReplacements": [
3+
{
4+
"type": "simple",
5+
"moduleName": "arr-diff",
6+
"replacement": "Use a.filter((item) => !b.includes(item))",
7+
"category": "micro-utilities"
8+
},
9+
{
10+
"type": "simple",
11+
"moduleName": "array-last",
12+
"replacement": "Use arr.at(-1) or arr[arr.length - 1]",
13+
"category": "micro-utilities"
14+
},
15+
{
16+
"type": "simple",
17+
"moduleName": "array-union",
18+
"replacement": "Use [...new Set([...a, ...b])]",
19+
"category": "micro-utilities"
20+
},
21+
{
22+
"type": "simple",
23+
"moduleName": "array-uniq",
24+
"replacement": "Use [...new Set(arr)]",
25+
"category": "micro-utilities"
26+
},
27+
{
28+
"type": "simple",
29+
"moduleName": "array-unique",
30+
"replacement": "Use [...new Set(arr)]",
31+
"category": "micro-utilities"
32+
},
33+
{
34+
"type": "simple",
35+
"moduleName": "arrify",
36+
"replacement": "Use (v == null ? [] : Array.isArray(v) ? v : [v])",
37+
"category": "micro-utilities"
38+
},
339
{
440
"type": "simple",
541
"moduleName": "call-bind",
@@ -24,6 +60,18 @@
2460
"replacement": "Use Object.defineProperty(target, Symbol.toStringTag, { value, configurable: true })",
2561
"category": "micro-utilities"
2662
},
63+
{
64+
"type": "simple",
65+
"moduleName": "filter-obj",
66+
"replacement": "Use Object.fromEntries(Object.entries(obj).filter(fn))",
67+
"category": "micro-utilities"
68+
},
69+
{
70+
"type": "simple",
71+
"moduleName": "has-flag",
72+
"replacement": "Use process.argv.includes('--flag')",
73+
"category": "micro-utilities"
74+
},
2775
{
2876
"type": "simple",
2977
"moduleName": "is-array-buffer",
@@ -36,6 +84,12 @@
3684
"replacement": "Use Object.prototype.toString.call(v) === \"[object Boolean]\"",
3785
"category": "micro-utilities"
3886
},
87+
{
88+
"type": "simple",
89+
"moduleName": "is-ci",
90+
"replacement": "Use Boolean(process.env.CI)",
91+
"category": "micro-utilities"
92+
},
3993
{
4094
"type": "simple",
4195
"moduleName": "is-date-object",
@@ -48,6 +102,12 @@
48102
"replacement": "Use (n % 2) === 0",
49103
"category": "micro-utilities"
50104
},
105+
{
106+
"type": "simple",
107+
"moduleName": "is-finite",
108+
"replacement": "Use Number.isFinite(v)",
109+
"category": "micro-utilities"
110+
},
51111
{
52112
"type": "simple",
53113
"moduleName": "is-negative",
@@ -126,11 +186,47 @@
126186
"replacement": "Use process.platform === \"win32\"",
127187
"category": "micro-utilities"
128188
},
189+
{
190+
"type": "simple",
191+
"moduleName": "kind-of",
192+
"replacement": "Use typeof v, or Object.prototype.toString.call(v) to get the internal [[Class]]",
193+
"category": "micro-utilities"
194+
},
195+
{
196+
"type": "simple",
197+
"moduleName": "lower-case",
198+
"replacement": "Use str.toLocaleLowerCase() or str.toLowerCase()",
199+
"category": "micro-utilities"
200+
},
201+
{
202+
"type": "simple",
203+
"moduleName": "repeat-string",
204+
"replacement": "Use str.repeat(n)",
205+
"category": "micro-utilities"
206+
},
207+
{
208+
"type": "simple",
209+
"moduleName": "slash",
210+
"replacement": "Use path.startsWith('\\\\?\\') ? path : path.replace(/\\/g, '/')",
211+
"category": "micro-utilities"
212+
},
129213
{
130214
"type": "simple",
131215
"moduleName": "split-lines",
132216
"replacement": "Use str.split(/\\r?\\n/)",
133217
"category": "micro-utilities"
218+
},
219+
{
220+
"type": "simple",
221+
"moduleName": "uniq",
222+
"replacement": "Use [...new Set(arr)]",
223+
"category": "micro-utilities"
224+
},
225+
{
226+
"type": "simple",
227+
"moduleName": "upper-case",
228+
"replacement": "Use str.toLocaleUpperCase() or str.toUpperCase()",
229+
"category": "micro-utilities"
134230
}
135231
]
136232
}

0 commit comments

Comments
 (0)