@jsenv/github-pull-request-impact 1.6.10 → 1.6.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/github-pull-request-impact",
3
- "version": "1.6.10",
3
+ "version": "1.6.11",
4
4
  "description": "Report pull request impact on something",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -34,24 +34,13 @@
34
34
  ],
35
35
  "scripts": {
36
36
  "eslint": "npx eslint . --ext=.js,.mjs",
37
- "importmap": "node ./script/importmap/importmap.mjs",
38
37
  "test": "node ./script/test/test.mjs",
39
38
  "test-with-coverage": "npm run test -- --coverage",
40
39
  "prettier": "prettier --write ."
41
40
  },
42
41
  "dependencies": {
43
- "@jsenv/filesystem": "2.7.1",
42
+ "@jsenv/filesystem": "3.1.0",
44
43
  "@jsenv/logger": "4.0.1",
45
44
  "node-fetch": "2.6.7"
46
- },
47
- "devDependencies": {
48
- "@jsenv/assert": "2.4.1",
49
- "@jsenv/core": "25.3.0",
50
- "@jsenv/eslint-config": "16.0.9",
51
- "@jsenv/importmap-eslint-resolver": "5.2.5",
52
- "@jsenv/importmap-node-module": "5.1.3",
53
- "eslint": "8.7.0",
54
- "eslint-plugin-import": "2.25.4",
55
- "prettier": "2.5.1"
56
45
  }
57
46
  }
@@ -19,7 +19,7 @@ export const commentGitHubPullRequestImpact = async ({
19
19
  logLevel,
20
20
  commandLogs = false,
21
21
  infoLogs = true,
22
- projectDirectoryUrl,
22
+ rootDirectoryUrl,
23
23
 
24
24
  githubToken,
25
25
  repositoryOwner,
@@ -41,7 +41,7 @@ export const commentGitHubPullRequestImpact = async ({
41
41
 
42
42
  catchError = false,
43
43
  }) => {
44
- projectDirectoryUrl = assertAndNormalizeDirectoryUrl(projectDirectoryUrl)
44
+ rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl)
45
45
  if (typeof collectInfo !== "function") {
46
46
  throw new TypeError(
47
47
  `collectInfo must be a function but received ${collectInfo}`,
@@ -83,7 +83,7 @@ export const commentGitHubPullRequestImpact = async ({
83
83
  logger,
84
84
  commandLogs,
85
85
  infoLogs,
86
- projectDirectoryUrl,
86
+ rootDirectoryUrl,
87
87
 
88
88
  githubToken,
89
89
  repositoryOwner,
@@ -111,7 +111,7 @@ const commentPrImpact = async ({
111
111
  logger,
112
112
  infoLogs,
113
113
  commandLogs,
114
- projectDirectoryUrl,
114
+ rootDirectoryUrl,
115
115
 
116
116
  githubToken,
117
117
  repositoryOwner,
@@ -130,10 +130,10 @@ const commentPrImpact = async ({
130
130
 
131
131
  catchError,
132
132
  }) => {
133
- const execCommandInProjectDirectory = (command) => {
133
+ const execCommandInRootDirectory = (command) => {
134
134
  logger.info(`> ${command}`)
135
135
  return exec(command, {
136
- cwd: urlToFileSystemPath(projectDirectoryUrl),
136
+ cwd: urlToFileSystemPath(rootDirectoryUrl),
137
137
  onLog: (string) => {
138
138
  if (commandLogs) {
139
139
  logger.info(string)
@@ -254,15 +254,15 @@ const commentPrImpact = async ({
254
254
  let beforeMergeInfo
255
255
  try {
256
256
  // cannot use depth=1 arg otherwise git merge might have merge conflicts
257
- await execCommandInProjectDirectory(
257
+ await execCommandInRootDirectory(
258
258
  `git fetch --no-tags --prune origin ${pullRequestBase}`,
259
259
  )
260
- await execCommandInProjectDirectory(
260
+ await execCommandInRootDirectory(
261
261
  `git reset --hard origin/${pullRequestBase}`,
262
262
  )
263
263
  beforeMergeInfo = await collectInfo({
264
264
  beforeMerge: true,
265
- execCommandInProjectDirectory,
265
+ execCommandInRootDirectory,
266
266
  })
267
267
  if (infoLogs) {
268
268
  logger.debug(debugBeforeMergeInfo(beforeMergeInfo))
@@ -285,13 +285,13 @@ const commentPrImpact = async ({
285
285
  try {
286
286
  // buildCommand might generate files that could conflict when doing the merge
287
287
  // reset to avoid potential merge conflicts
288
- await execCommandInProjectDirectory(
288
+ await execCommandInRootDirectory(
289
289
  `git reset --hard origin/${pullRequestBase}`,
290
290
  )
291
291
  // Avoid "The following untracked working tree files would be overwritten by merge" error
292
- await execCommandInProjectDirectory(`git clean -d -f .`)
292
+ await execCommandInRootDirectory(`git clean -d -f .`)
293
293
  // cannot use depth=1 arg otherwise git merge might have merge conflicts
294
- await execCommandInProjectDirectory(
294
+ await execCommandInRootDirectory(
295
295
  `git fetch --no-tags --prune origin ${headRef}`,
296
296
  )
297
297
  // ensure there is user.email + user.name required to perform git merge command
@@ -299,15 +299,15 @@ const commentPrImpact = async ({
299
299
 
300
300
  const restoreGitUserEmail = await ensureGitConfig("user.email", {
301
301
  valueIfMissing: "you@example.com",
302
- execCommandInProjectDirectory,
302
+ execCommandInRootDirectory,
303
303
  })
304
304
  const restoreGitUserName = await ensureGitConfig("user.name", {
305
305
  valueIfMissing: "Your Name",
306
- execCommandInProjectDirectory,
306
+ execCommandInRootDirectory,
307
307
  })
308
308
  // could we use https://stackoverflow.com/a/6283843 ?
309
309
  try {
310
- await execCommandInProjectDirectory(
310
+ await execCommandInRootDirectory(
311
311
  `git merge FETCH_HEAD --allow-unrelated-histories --no-ff --no-commit`,
312
312
  )
313
313
  } catch (e) {
@@ -317,7 +317,7 @@ const commentPrImpact = async ({
317
317
  await restoreGitUserName()
318
318
  afterMergeInfo = await collectInfo({
319
319
  afterMerge: true,
320
- execCommandInProjectDirectory,
320
+ execCommandInRootDirectory,
321
321
  })
322
322
  if (infoLogs) {
323
323
  logger.debug(debugAfterMergeInfo(afterMergeInfo))
@@ -364,17 +364,17 @@ const commentPrImpact = async ({
364
364
 
365
365
  const ensureGitConfig = async (
366
366
  name,
367
- { execCommandInProjectDirectory, valueIfMissing },
367
+ { execCommandInRootDirectory, valueIfMissing },
368
368
  ) => {
369
369
  try {
370
- await execCommandInProjectDirectory(`git config ${name}`)
370
+ await execCommandInRootDirectory(`git config ${name}`)
371
371
  return () => {}
372
372
  } catch (e) {
373
- await execCommandInProjectDirectory(
373
+ await execCommandInRootDirectory(
374
374
  `git config ${name} "${valueIfMissing}"`,
375
375
  )
376
376
  return async () => {
377
- await execCommandInProjectDirectory(`git config --unset ${name}`)
377
+ await execCommandInRootDirectory(`git config --unset ${name}`)
378
378
  }
379
379
  }
380
380
  }
@@ -28,7 +28,7 @@ export const readGitHubWorkflowEnv = () => {
28
28
  }
29
29
  : undefined
30
30
  return {
31
- projectDirectoryUrl: process.env.GITHUB_WORKSPACE,
31
+ rootDirectoryUrl: process.env.GITHUB_WORKSPACE,
32
32
  githubToken,
33
33
  repositoryOwner,
34
34
  repositoryName,