skuba 4.2.0-beta.0 → 4.2.0-beta.1
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/lib/cli/lint/autofix.js
CHANGED
|
@@ -39,44 +39,42 @@ const prettier_1 = require("../../cli/adapter/prettier");
|
|
|
39
39
|
const env_1 = require("../../utils/env");
|
|
40
40
|
const logging_1 = require("../../utils/logging");
|
|
41
41
|
const AUTOFIX_COMMIT_MESSAGE = 'Run `skuba format`';
|
|
42
|
-
const shouldPush = (dir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
const shouldPush = ({ currentBranch, dir, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
43
|
if (!(0, env_1.isCiEnv)()) {
|
|
44
44
|
// We're not running in a CI environment so we don't need to push autofixes.
|
|
45
45
|
// Ideally we'd drive this off of repository write permissions, but that is
|
|
46
46
|
// non-trivial to infer without attempting an actual write.
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
|
+
const isDefaultBuildkiteBranch = currentBranch &&
|
|
50
|
+
[process.env.BUILDKITE_PIPELINE_DEFAULT_BRANCH, 'master', 'main'].includes(currentBranch);
|
|
51
|
+
const isProtectedGitHubBranch = process.env.GITHUB_REF_PROTECTED === 'true';
|
|
52
|
+
if (isDefaultBuildkiteBranch || isProtectedGitHubBranch) {
|
|
53
|
+
// The current branch is a protected branch.
|
|
54
|
+
// We respect GitHub Flow; avoid pushing directly to the default branch.
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
let headCommitMessage;
|
|
49
58
|
try {
|
|
50
|
-
|
|
51
|
-
const isDefaultBuildkiteBranch = currentBranch &&
|
|
52
|
-
[
|
|
53
|
-
process.env.BUILDKITE_PIPELINE_DEFAULT_BRANCH,
|
|
54
|
-
'master',
|
|
55
|
-
'main',
|
|
56
|
-
].includes(currentBranch);
|
|
57
|
-
const isProtectedGitHubBranch = process.env.GITHUB_REF_PROTECTED === 'true';
|
|
58
|
-
if (isDefaultBuildkiteBranch || isProtectedGitHubBranch) {
|
|
59
|
-
// The current branch is a protected branch.
|
|
60
|
-
// We respect GitHub Flow; avoid pushing directly to the default branch.
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
59
|
+
headCommitMessage = yield Git.getHeadCommitMessage({ dir });
|
|
63
60
|
}
|
|
64
61
|
catch (_a) { }
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// Repeating the same operation is unlikely to correct outstanding issues.
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
62
|
+
if (headCommitMessage === AUTOFIX_COMMIT_MESSAGE) {
|
|
63
|
+
// Short circuit when the head commit appears to be one of our autofixes.
|
|
64
|
+
// Repeating the same operation is unlikely to correct outstanding issues.
|
|
65
|
+
return false;
|
|
72
66
|
}
|
|
73
|
-
catch (_b) { }
|
|
74
67
|
// Allow the push attempt to go ahead if our guards have been cleared.
|
|
75
68
|
return true;
|
|
76
69
|
});
|
|
77
70
|
const autofix = (input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
71
|
const dir = process.cwd();
|
|
79
|
-
|
|
72
|
+
let currentBranch;
|
|
73
|
+
try {
|
|
74
|
+
currentBranch = yield Git.currentBranch({ dir });
|
|
75
|
+
}
|
|
76
|
+
catch (_b) { }
|
|
77
|
+
if (!(yield shouldPush({ currentBranch, dir }))) {
|
|
80
78
|
return;
|
|
81
79
|
}
|
|
82
80
|
// Naively try to autofix issues as we can't tell from ESLint output.
|
|
@@ -101,6 +99,7 @@ const autofix = (input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
101
99
|
auth: { type: 'gitHubApp' },
|
|
102
100
|
dir: process.cwd(),
|
|
103
101
|
ref,
|
|
102
|
+
remoteRef: currentBranch,
|
|
104
103
|
}));
|
|
105
104
|
logging_1.log.warn(`Pushed fix commit ${ref}.`);
|
|
106
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autofix.js","sourceRoot":"","sources":["../../../src/cli/lint/autofix.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAmC;AAEnC,mDAAqC;AACrC,qDAAqD;AACrD,yDAAyD;AACzD,yCAA0C;AAC1C,iDAAwD;AAIxD,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAEpD,MAAM,UAAU,GAAG,CAAO,
|
|
1
|
+
{"version":3,"file":"autofix.js","sourceRoot":"","sources":["../../../src/cli/lint/autofix.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAmC;AAEnC,mDAAqC;AACrC,qDAAqD;AACrD,yDAAyD;AACzD,yCAA0C;AAC1C,iDAAwD;AAIxD,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAEpD,MAAM,UAAU,GAAG,CAAO,EACxB,aAAa,EACb,GAAG,GAIJ,EAAE,EAAE;IACH,IAAI,CAAC,IAAA,aAAO,GAAE,EAAE;QACd,4EAA4E;QAC5E,2EAA2E;QAC3E,2DAA2D;QAC3D,OAAO,KAAK,CAAC;KACd;IAED,MAAM,wBAAwB,GAC5B,aAAa;QACb,CAAC,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CACxE,aAAa,CACd,CAAC;IAEJ,MAAM,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,MAAM,CAAC;IAE5E,IAAI,wBAAwB,IAAI,uBAAuB,EAAE;QACvD,4CAA4C;QAC5C,wEAAwE;QACxE,OAAO,KAAK,CAAC;KACd;IAED,IAAI,iBAAiB,CAAC;IACtB,IAAI;QACF,iBAAiB,GAAG,MAAM,GAAG,CAAC,oBAAoB,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;KAC7D;IAAC,WAAM,GAAE;IAEV,IAAI,iBAAiB,KAAK,sBAAsB,EAAE;QAChD,yEAAyE;QACzE,0EAA0E;Q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ClB,GAAG;oBACH,SAAS,EAAE,aAAa;iBACzB,CAAC,CAAC,CAAC;QAER,aAAG,CAAC,IAAI,CAAC,qBAAqB,GAAG,GAAG,CAAC,CAAC;KACvC;IAAC,OAAO,GAAG,EAAE;QACZ,aAAG,CAAC,IAAI,CAAC,aAAG,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC;QACjD,aAAG,CAAC,IAAI,CACN,aAAG,CAAC,IAAI,CACN,oEAAoE,CACrE,CACF,CAAC;QACF,aAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KACjB;AACH,CAAC,CAAA,CAAC;AApDW,QAAA,OAAO,WAoDlB"}
|
package/package.json
CHANGED
|
@@ -6,21 +6,22 @@ on:
|
|
|
6
6
|
- beta
|
|
7
7
|
- master
|
|
8
8
|
|
|
9
|
+
permissions: {}
|
|
10
|
+
|
|
9
11
|
jobs:
|
|
10
12
|
release:
|
|
11
13
|
name: Publish & Deploy
|
|
14
|
+
permissions:
|
|
15
|
+
contents: write
|
|
12
16
|
runs-on: ubuntu-latest
|
|
13
|
-
env:
|
|
14
|
-
CI: true
|
|
15
17
|
steps:
|
|
16
18
|
- name: Check out repo
|
|
17
|
-
uses: actions/checkout@
|
|
19
|
+
uses: actions/checkout@v3
|
|
18
20
|
with:
|
|
19
21
|
fetch-depth: 0
|
|
20
|
-
lfs: true
|
|
21
22
|
|
|
22
23
|
- name: Set up Node.js 16.x
|
|
23
|
-
uses: actions/setup-node@
|
|
24
|
+
uses: actions/setup-node@v2
|
|
24
25
|
with:
|
|
25
26
|
node-version: 16.x
|
|
26
27
|
|
|
@@ -4,20 +4,20 @@ on:
|
|
|
4
4
|
- pull_request
|
|
5
5
|
- push
|
|
6
6
|
|
|
7
|
+
permissions: {}
|
|
8
|
+
|
|
7
9
|
jobs:
|
|
8
10
|
validate:
|
|
9
11
|
name: Lint & Test
|
|
12
|
+
permissions:
|
|
13
|
+
checks: write
|
|
10
14
|
runs-on: ubuntu-latest
|
|
11
|
-
env:
|
|
12
|
-
CI: true
|
|
13
15
|
steps:
|
|
14
16
|
- name: Check out repo
|
|
15
|
-
uses: actions/checkout@
|
|
16
|
-
with:
|
|
17
|
-
lfs: true
|
|
17
|
+
uses: actions/checkout@v3
|
|
18
18
|
|
|
19
19
|
- name: Set up Node.js 16.x
|
|
20
|
-
uses: actions/setup-node@
|
|
20
|
+
uses: actions/setup-node@v2
|
|
21
21
|
with:
|
|
22
22
|
node-version: 16.x
|
|
23
23
|
|