Skip to content

Commit a7e28d5

Browse files
authored
Merge branch 'main' into ballot-summary-web
2 parents e0ef942 + 3535a04 commit a7e28d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1178
-1199
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2222

23-
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
23+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2424
with:
2525
node-version: lts/*
2626

@@ -29,7 +29,7 @@ jobs:
2929
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
3030
shell: bash
3131

32-
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
32+
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
3333
with:
3434
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
3535
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}

.github/workflows/publish.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ on:
55
branches: [main]
66

77
permissions:
8-
contents: write
9-
pull-requests: write
8+
contents: read
109

1110
env:
1211
YARN_ENABLE_GLOBAL_CACHE: false
1312

1413
jobs:
1514
release-please:
1615
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
pull-requests: write
1719
outputs:
1820
release_created: ${{ steps.release.outputs.release_created }}
1921
release_tag: ${{ steps.release.outputs.tag_name }}
2022
steps:
21-
- uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4.1.3
23+
- uses: googleapis/release-please-action@a02a34c4d625f9be7cb89156071d8567266a2445 # v4.2.0
2224
id: release
2325
with:
2426
config-file: release-please-config.json
@@ -27,10 +29,13 @@ jobs:
2729
needs: release-please
2830
if: ${{ needs.release-please.outputs.release_created }}
2931
runs-on: ubuntu-latest
32+
permissions:
33+
contents: read
34+
id-token: write
3035
steps:
31-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
36+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3237

33-
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
38+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
3439
with:
3540
node-version: lts/*
3641

@@ -39,7 +44,7 @@ jobs:
3944
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
4045
shell: bash
4146

42-
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
47+
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
4348
with:
4449
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
4550
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
@@ -55,6 +60,6 @@ jobs:
5560
run: |
5661
corepack yarn install --immutable
5762
corepack yarn build
58-
corepack yarn workspaces foreach --all --no-private npm publish --access public
63+
corepack yarn workspaces foreach --all --no-private npm publish --provenance --access public
5964
env:
6065
YARN_NPM_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

eslint.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import js from "@eslint/js";
22
import tsPlugin from "typescript-eslint";
3+
import stylistic from "@stylistic/eslint-plugin";
34

45
export default [
56
js.configs.recommended,
67
...tsPlugin.configs.recommended,
8+
stylistic.configs.customize({
9+
braceStyle: "1tbs",
10+
quotes: "double",
11+
quoteProps: "as-needed",
12+
semi: true,
13+
}),
714
{
815
files: ["**/*.ts"],
916
languageOptions: {
@@ -15,6 +22,7 @@ export default [
1522
},
1623
plugins: {
1724
"@typescript-eslint": tsPlugin.plugin,
25+
"@stylistic": stylistic,
1826
},
1927
},
2028
{ ignores: ["node_modules/", "**/dist/"] },

package.json

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
11
{
22
"name": "caritat",
33
"private": true,
4-
"packageManager": "yarn@4.3.1+sha224.934d21773e22af4b69a7032a2d3b4cb38c1f7c019624777cc9916b23",
4+
"packageManager": "yarn@4.9.2+sha224.b8e0b161ae590950fbda696e6f3ca071362768e5280c5fbfdadf064b",
55
"version": "1.6.0",
66
"license": "MIT",
77
"repository": {
88
"type": "git",
99
"url": "https://github.com/nodejs/caritat.git"
1010
},
1111
"devDependencies": {
12-
"@types/eslint": "^8",
12+
"@stylistic/eslint-plugin": "^4.4.1",
13+
"@types/eslint": "^9",
1314
"@types/js-yaml": "^4.0.5",
1415
"@types/node": "^20.0.0",
1516
"eslint": "^9.2.0",
16-
"typescript": "^5.1.3",
17-
"typescript-eslint": "^7.8.0"
17+
"typescript": "^5.8.3",
18+
"typescript-eslint": "^8.34.0"
19+
},
20+
"devEngines": {
21+
"packageManager": {
22+
"name": "yarn",
23+
"version": "4.9.2"
24+
},
25+
"runtime": {
26+
"name": "nodejs",
27+
"version": ">=22.6.0"
28+
}
1829
},
1930
"imports": {
2031
"#ts-loader": "./packages/ts-loader/loader.js"
2132
},
2233
"scripts": {
2334
"test:lint": "eslint .",
24-
"test:types": "tsc --noEmit",
35+
"test:types": "tsc --build --emitDeclarationOnly",
2536
"test:unit": "node --experimental-global-webcrypto --loader '#ts-loader' test/index.ts",
2637
"test": "yarn test:lint && yarn test:types && yarn test:unit",
2738
"build": "tsc --build",

packages/cli/src/bin/countBallotsFromGit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ const parsedArgs = await parseArgs().options({
2222

2323
const { repo: repoURL, branch, path: subPath } = parsedArgs;
2424

25-
const privateKey =
26-
parsedArgs.key === "-"
25+
const privateKey
26+
= parsedArgs.key === "-"
2727
? await readStdIn(false)
28-
: parsedArgs.key && (await fs.readFile(parsedArgs.key as string));
28+
: parsedArgs.key && (await fs.readFile(parsedArgs.key));
2929

3030
const { result, privateKeyAsArmoredString } = await countFromGit({
3131
...(await getEnv(parsedArgs)),

packages/cli/src/bin/countBallotsFromGitHub.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const parsedArgs = await parseArgs()
1919

2020
protocol: {
2121
describe:
22-
"the protocol to use to pull the remote repository, either SSH or " +
23-
"HTTP (defaults to SSH if a public SSH key is found for the current " +
24-
"user, otherwise default to HTTP)",
22+
"the protocol to use to pull the remote repository, either SSH or "
23+
+ "HTTP (defaults to SSH if a public SSH key is found for the current "
24+
+ "user, otherwise default to HTTP)",
2525
string: true,
2626
},
2727
login: {
@@ -50,8 +50,8 @@ const parsedArgs = await parseArgs()
5050
["key-part"]: {
5151
...cliArgs["key-part"],
5252
describe:
53-
cliArgs["key-part"].describe +
54-
" If not provided, it will be extracted from the PR comments.",
53+
cliArgs["key-part"].describe
54+
+ " If not provided, it will be extracted from the PR comments.",
5555
},
5656
})
5757
.command(
@@ -63,16 +63,16 @@ const parsedArgs = await parseArgs()
6363
type: "string",
6464
describe: "URL to the GitHub pull request",
6565
});
66-
}
66+
},
6767
).argv;
6868

69-
const privateKey =
70-
parsedArgs.key === "-"
69+
const privateKey
70+
= parsedArgs.key === "-"
7171
? await readStdIn(false)
7272
: parsedArgs.key && (await fs.readFile(parsedArgs.key));
7373

7474
const prUrlInfo = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)$/.exec(
75-
parsedArgs["pr-url"] as string
75+
parsedArgs["pr-url"] as string,
7676
);
7777

7878
if (prUrlInfo == null) {
@@ -81,7 +81,7 @@ if (prUrlInfo == null) {
8181

8282
const [, owner, repo, prNumber] = prUrlInfo;
8383
console.warn(
84-
`Looking into GitHub pull request ${owner}/${repo}#${prNumber}...`
84+
`Looking into GitHub pull request ${owner}/${repo}#${prNumber}...`,
8585
);
8686

8787
const query = `query PR($prid: Int!, $owner: String!, $repo: String!) {
@@ -126,8 +126,8 @@ const { data } = JSON.parse(
126126
"-f",
127127
`query=${query}`,
128128
],
129-
{ captureStdout: true }
130-
)
129+
{ captureStdout: true },
130+
),
131131
);
132132

133133
const { pullRequest } = data.repository;
@@ -154,31 +154,31 @@ const files = await runChildProcessAsync(
154154
"--jq",
155155
".files.[] | .filename",
156156
],
157-
{ captureStdout: true }
157+
{ captureStdout: true },
158158
);
159159

160160
const voteFileCanonicalName = "vote.yml";
161161
const subPath = files
162162
.split("\n")
163163
.find(
164-
(path) =>
165-
path === voteFileCanonicalName ||
166-
path.endsWith(`/${voteFileCanonicalName}`)
164+
path =>
165+
path === voteFileCanonicalName
166+
|| path.endsWith(`/${voteFileCanonicalName}`),
167167
)
168168
?.slice(0, -voteFileCanonicalName.length);
169169

170170
const handle = parsedArgs.login || data.viewer.login;
171171

172-
const protocol =
173-
parsedArgs.protocol ?? (data.viewer.publicKeys.totalCount ? "ssh" : "http");
172+
const protocol
173+
= parsedArgs.protocol ?? (data.viewer.publicKeys.totalCount ? "ssh" : "http");
174174

175175
function getHTTPRepoURL(repoURL: string, login: string) {
176176
const url = new URL(repoURL + ".git");
177177
url.username = login;
178178
return url.toString();
179179
}
180-
const repoURL =
181-
protocol === "ssh"
180+
const repoURL
181+
= protocol === "ssh"
182182
? data.repository.sshUrl
183183
: getHTTPRepoURL(data.repository.url, handle);
184184

@@ -191,14 +191,14 @@ console.warn("All relevant information has been retrieved:", {
191191
});
192192

193193
async function getKeyPartsFromComments() {
194-
const shamirKeyPartComment =
195-
/\n-----BEGIN SHAMIR KEY PART-----\n([a-zA-Z0-9+/\s]+={0,2})\n-----END SHAMIR KEY PART-----\n/;
194+
const shamirKeyPartComment
195+
= /\n-----BEGIN SHAMIR KEY PART-----\n([a-zA-Z0-9+/\s]+={0,2})\n-----END SHAMIR KEY PART-----\n/;
196196
const { comments } = JSON.parse(
197197
await runChildProcessAsync(
198198
parsedArgs["gh-binary"] as string,
199199
["pr", "view", parsedArgs["pr-url"], "--json", "comments"],
200-
{ captureStdout: true }
201-
)
200+
{ captureStdout: true },
201+
),
202202
);
203203

204204
const results = [];
@@ -237,12 +237,12 @@ if (parsedArgs["post-comment"]) {
237237
]);
238238
} else {
239239
console.log(
240-
"To publish the results, you should use `--post-comment --commit-json-summary` CLI flags."
240+
"To publish the results, you should use `--post-comment --commit-json-summary` CLI flags.",
241241
);
242242
console.log(
243243
"Participation:",
244244
Math.round(summary.participation * 100_00) / 1_00,
245-
"%"
245+
"%",
246246
);
247247
console.log("Raw results:", summary.result);
248248
}

packages/cli/src/bin/decryptBallot.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

33
import fs from "fs";
4-
4+
55
import parseArgs from "../utils/parseArgs.js";
66
import decryptData from "@node-core/caritat-crypto/decrypt";
77

@@ -25,7 +25,7 @@ const parsedArgs = await parseArgs().options({
2525
const { data: filePath, key: privateKeyPath } = parsedArgs;
2626

2727
const { encryptedSecret, data } = JSON.parse(
28-
fs.readFileSync(filePath, "utf8").replace(/^\uFEFF/, "")
28+
fs.readFileSync(filePath, "utf8").replace(/^\uFEFF/, ""),
2929
);
3030

3131
console.log(
@@ -34,8 +34,8 @@ console.log(
3434
await decryptData(
3535
Buffer.from(data, "base64"),
3636
Buffer.from(encryptedSecret, "base64"),
37-
fs.readFileSync(privateKeyPath)
38-
)
39-
)
40-
).toString("utf8")
37+
fs.readFileSync(privateKeyPath),
38+
),
39+
),
40+
).toString("utf8"),
4141
);

0 commit comments

Comments
 (0)