Skip to content

Commit 05329a9

Browse files
committed
Project -> Repository
1 parent b752b6c commit 05329a9

19 files changed

+255
-334
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/cache@v4
1414
with:
1515
path: repositories
16-
key: ${{ hashFiles('projects.json') }}
16+
key: ${{ hashFiles('repositories.json') }}
1717
- uses: actions/setup-node@v6
1818
- name: configure git
1919
run: |
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: "Update projects.json"
1+
name: "Update repositories.json"
22

33
on:
44
workflow_dispatch:
55
schedule:
66
- cron: "00 01 1 * *"
77

88
jobs:
9-
update-project-json:
9+
update-repositories:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
@@ -18,12 +18,12 @@ jobs:
1818
- name: Install Dependencies
1919
run: yarn
2020

21-
- name: Run update-projects-json.mjs
22-
run: node ./scripts/update-projects-json.mjs
21+
- name: Run update-repositories.mjs
22+
run: node ./scripts/update-repositories.mjs
2323

2424
- uses: peter-evans/create-pull-request@v7
2525
with:
26-
commit-message: "Update projects.json"
27-
branch: automated-update-projects
26+
commit-message: "Update repositories.json"
27+
branch: automated-update-repositories
2828
branch-suffix: timestamp
29-
title: "Update projects.json"
29+
title: "Update repositories.json"

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,16 @@ RUN sosukesuzuki/prettier#fix-foo VS 1.0.0
5555

5656
Optional.
5757

58-
Run [all repositories](./projects.json) by default.
58+
Run [all repositories](./repositories.json) by default.
5959

60-
Comma separated repository or name list. (Currently only allow repositories defined in `projects.json`)
60+
Comma separated repository or name list. (Currently only allow repositories defined in `repositories.json`)
6161

6262
```
6363
RUN #110168 ON babel/babel
64-
RUN #110168 ON https://github.com/babel/babel.git
6564
RUN #110168 ON babel/babel,prettier/prettier
6665
RUN #110168 VS 1.0.0 ON babel/babel,prettier/prettier
6766
```
6867

69-
## Add new project
68+
## Add new repository
7069

71-
Add a project info to `projects.json`.
70+
Run `yarn add-repository`

__tests__/projects.spec.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
"test": "vitest",
1717
"build": "tsc",
1818
"execute": "yarn build && node ./build/index.js",
19-
"add-project": "node scripts/add-project.mjs",
20-
"update-projects": "node scripts/update-projects-json.mjs"
19+
"add-repository": "node scripts/add-repository.mjs",
20+
"update-repositories": "node scripts/update-repositories.mjs"
2121
},
2222
"dependencies": {
2323
"@actions/artifact": "4.0.0",
2424
"@actions/core": "1.11.1",
2525
"@actions/github": "4.0.0",
26-
"ajv": "8.17.1",
2726
"nano-spawn": "2.0.0"
2827
},
2928
"devDependencies": {

projects.json renamed to repositories.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
[
22
{
3-
"repository": "https://github.com/babel/babel.git",
3+
"repository": "babel/babel",
44
"commit": "7958603449cf9b17296f6bce58801a832bc55b09"
55
},
66
{
7-
"repository": "https://github.com/vuejs/eslint-plugin-vue.git",
7+
"repository": "vuejs/eslint-plugin-vue",
88
"commit": "701bb0931778a63b1b0a85f0d68d4390a222f359"
99
},
1010
{
11-
"repository": "https://github.com/excalidraw/excalidraw.git",
11+
"repository": "excalidraw/excalidraw",
1212
"commit": "210dc85c8cd43da0f78b84b59b650de7db1a00a8",
1313
"ignoreFile": ".eslintignore"
1414
},
1515
{
16-
"repository": "https://github.com/mdn/content.git",
16+
"repository": "mdn/content",
1717
"commit": "ca26363fcc6fc861103d40ac0205e5c5b79eb2fa"
1818
},
1919
{
20-
"repository": "https://github.com/prettier/prettier.git",
20+
"repository": "prettier/prettier",
2121
"commit": "363a20e1c182784de7664d8c782137daf5548312"
2222
},
2323
{
24-
"repository": "https://github.com/marmelab/react-admin.git",
24+
"repository": "marmelab/react-admin",
2525
"commit": "905f248948e443a75c91da82bf28efe446117b79",
2626
"glob": [
2727
"packages/*/src/**/*.{js,json,ts,tsx,css,md}",
@@ -30,20 +30,20 @@
3030
]
3131
},
3232
{
33-
"repository": "https://github.com/typescript-eslint/typescript-eslint.git",
33+
"repository": "typescript-eslint/typescript-eslint",
3434
"commit": "906cc3c892cbd7cc929a797557a234f64e8bf539",
3535
"ignore": ["**/fixtures/**/*"]
3636
},
3737
{
38-
"repository": "https://github.com/vega/vega-lite.git",
38+
"repository": "vega/vega-lite",
3939
"commit": "e7f55118e7c149c42436c800d053423cdd10bb1a"
4040
},
4141
{
42-
"repository": "https://github.com/vuejs/core.git",
42+
"repository": "vuejs/core",
4343
"commit": "25ebe3a42cd80ac0256355c2740a0258cdd7419d"
4444
},
4545
{
46-
"repository": "https://github.com/microsoft/vscode.git",
46+
"repository": "microsoft/vscode",
4747
"commit": "9bd6a8310aea6ada3e02a307c31ed05e5e4dabec",
4848
"ignore": [
4949
"**/build/*/**/*.js",
@@ -93,7 +93,7 @@
9393
]
9494
},
9595
{
96-
"repository": "https://github.com/vitejs/vite.git",
96+
"repository": "vitejs/vite",
9797
"commit": "df5a30d2690a2ebc4824a79becdcef30538dc602"
9898
}
9999
]

scripts/add-project.mjs

Lines changed: 0 additions & 54 deletions
This file was deleted.

scripts/add-repository.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import * as readline from "node:readline/promises";
2+
import process from "node:process";
3+
import { getRepositoryCommitHash, updatedRepositories } from "./utilities.mjs";
4+
5+
const GITHUB_DOMAIN = "https://github.com/";
6+
7+
async function addProject() {
8+
const rl = new readline.Interface({
9+
input: process.stdin,
10+
output: process.stdout,
11+
});
12+
let input = await rl.question(
13+
"Which repository are you going to add? Example: prettier/prettier\n",
14+
);
15+
16+
let repository = input.trim();
17+
18+
if (repository.startsWith(GITHUB_DOMAIN)) {
19+
repository = repository.slice(GITHUB_DOMAIN.length);
20+
21+
if (repository.endsWith("/")) {
22+
repository = repository.slice(0, -1);
23+
}
24+
}
25+
26+
if (!/^[\w]+\/[\w]+$/.test(repository)) {
27+
throw new Error(`Unsupported repository '${input}'.`);
28+
}
29+
30+
await updatedRepositories(async (repositories) => {
31+
if (repositories.some((project) => project.repository === repository)) {
32+
throw new Error(`Repository '${repository}' already exists.`);
33+
}
34+
35+
const commit = await getRepositoryCommitHash(repository);
36+
return [
37+
repositories,
38+
{
39+
repository,
40+
commit,
41+
glob: ".",
42+
},
43+
];
44+
});
45+
}
46+
47+
await addProject();
48+
49+
console.log("done");

scripts/update-projects-json.mjs

Lines changed: 0 additions & 30 deletions
This file was deleted.

scripts/update-repositories.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { getRepositoryCommitHash, updatedRepositories } from "./utilities.mjs";
2+
3+
await updatedRepositories((repositories) =>
4+
Promise.all(
5+
repositories.map(async (repository) => ({
6+
...repository,
7+
commit: await getRepositoryCommitHash(repository.repository),
8+
})),
9+
),
10+
);
11+
12+
console.log("done");

0 commit comments

Comments
 (0)