Skip to content

Commit 6b5ebbc

Browse files
authored
Add oxfmt to the repo (#100)
* chore: add formatter * chore(deps-dev): add vite as dev dependency to avoid peer warnings * ci: separate lint job from test job
1 parent be84759 commit 6b5ebbc

File tree

13 files changed

+861
-811
lines changed

13 files changed

+861
-811
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,25 @@ jobs:
3030
- name: Run test
3131
run: yarn test
3232

33+
lint:
34+
name: Lint
35+
runs-on: ubuntu-latest
36+
timeout-minutes: 20
37+
steps:
38+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
39+
with:
40+
persist-credentials: false
41+
42+
- uses: ./.github/actions/ci-setup
43+
44+
- name: Run format:check
45+
run: yarn format:check
46+
3347
ci-ok:
3448
name: CI OK
3549
runs-on: ubuntu-latest
3650
if: always()
37-
needs: [test]
51+
needs: [test, lint]
3852
steps:
3953
- name: Exit with error if some jobs are not successful
4054
run: exit 1

.oxfmtrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"ignorePatterns": ["CHANGELOG.md"],
4+
"sortImports": {
5+
"groups": [
6+
"builtin",
7+
"external",
8+
["internal", "subpath"],
9+
"parent",
10+
"sibling",
11+
"index",
12+
"side_effect",
13+
"unknown"
14+
],
15+
"newlinesBetween": true
16+
}
17+
}

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"typescript.tsdk": "node_modules/typescript/lib"
3-
}
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
55
## Install the bot at https://github.com/apps/changeset-bot
66

7-
8-
97
This bot will comment on PRs saying that either a user might need to add a changeset(note that PRs changing things like documentation generally don't need a changeset)or say that the PR is good and already has a changeset.
108

119
<img width="1552" alt="screenshot of changeset bot message from https://github.com/mitchellhamilton/manypkg/pull/18 before a changeset was added" src="https://user-images.githubusercontent.com/11481355/66183943-dc418680-e6bd-11e9-998d-e43f90a974bd.png">
1210

1311
<img width="1552" alt="screenshot of the changeset bot message from https://github.com/mitchellhamilton/manypkg/pull/18 showing the changeset good to go message" src="https://user-images.githubusercontent.com/11481355/66184229-cf716280-e6be-11e9-950e-0f64a31dbf15.png">
1412

15-
1613
Sometimes, a contributor won't add a changeset to a PR but you might want to merge in the PR without having to wait on them to add it. To address this, this bot adds a link with the filename pre-filled to add a changeset so all you have to do is write the changeset and click commit.
1714

1815
<img width="1552" alt="screenshot of the changeset bot message from https://github.com/mitchellhamilton/manypkg/pull/18 focused on the create a changeset link" src="https://user-images.githubusercontent.com/11481355/66184052-3a6e6980-e6be-11e9-8e62-8fd9d49af587.png">
@@ -27,17 +24,17 @@ When writing the changeset, it should look something like this with the packages
2724

2825
```markdown
2926
---
30-
'@changesets/cli': major
31-
'@changesets/read': minor
27+
"@changesets/cli": major
28+
"@changesets/read": minor
3229
---
3330

3431
A very helpful description of the changes
3532
```
33+
3634
---
3735

3836
The information below is for contributing to the bot.
3937

40-
4138
## Setup
4239

4340
```sh

app.yml

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@
1313
# The list of events the GitHub App subscribes to.
1414
# Uncomment the event names below to enable them.
1515
default_events:
16-
# - check_run
17-
# - check_suite
18-
# - commit_comment
19-
# - create
20-
# - delete
21-
# - deployment
22-
# - deployment_status
23-
# - fork
24-
# - gollum
25-
# - issue_comment
26-
- issues
27-
# - label
28-
# - milestone
29-
# - member
30-
# - membership
31-
# - org_block
32-
# - organization
33-
# - page_build
34-
# - project
35-
# - project_card
36-
# - project_column
37-
# - public
38-
- pull_request
39-
# - pull_request_review
40-
# - pull_request_review_comment
41-
# - push
42-
# - release
43-
# - repository
44-
# - repository_import
45-
# - status
46-
# - team
47-
# - team_add
48-
# - watch
16+
# - check_run
17+
# - check_suite
18+
# - commit_comment
19+
# - create
20+
# - delete
21+
# - deployment
22+
# - deployment_status
23+
# - fork
24+
# - gollum
25+
# - issue_comment
26+
- issues
27+
# - label
28+
# - milestone
29+
# - member
30+
# - membership
31+
# - org_block
32+
# - organization
33+
# - page_build
34+
# - project
35+
# - project_card
36+
# - project_column
37+
# - public
38+
- pull_request
39+
# - pull_request_review
40+
# - pull_request_review_comment
41+
# - push
42+
# - release
43+
# - repository
44+
# - repository_import
45+
# - status
46+
# - team
47+
# - team_add
48+
# - watch
4949

5050
# The set of permissions needed by the GitHub App. The format of the object uses
5151
# the permission name for the key (for example, issues) and the access type for
@@ -82,7 +82,7 @@ default_permissions:
8282

8383
# Pull requests and related comments, assignees, labels, milestones, and merges.
8484
# https://developer.github.com/v3/apps/permissions/#permission-on-pull-requests
85-
pull_requests: write
85+
pull_requests: write
8686

8787
# Manage the post-receive hooks for a repository.
8888
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-hooks
@@ -124,7 +124,6 @@ default_permissions:
124124
# https://developer.github.com/v3/apps/permissions/
125125
# organization_administration: read
126126

127-
128127
# The name of the GitHub App. Defaults to the name specified in package.json
129128
# name: My Probot App
130129

get-changed-packages.ts

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import nodePath from "path";
2-
import micromatch from "micromatch";
3-
import { ProbotOctokit } from "probot";
4-
import fetch from "node-fetch";
5-
import { safeLoad } from "js-yaml";
6-
import { Packages, Tool } from "@manypkg/get-packages";
2+
73
import assembleReleasePlan from "@changesets/assemble-release-plan";
84
import { parse as parseConfig } from "@changesets/config";
9-
import { PreState, NewChangeset } from "@changesets/types";
105
import parseChangeset from "@changesets/parse";
6+
import { PreState, NewChangeset } from "@changesets/types";
7+
import { Packages, Tool } from "@manypkg/get-packages";
8+
import { safeLoad } from "js-yaml";
9+
import micromatch from "micromatch";
10+
import fetch from "node-fetch";
11+
import { ProbotOctokit } from "probot";
1112

1213
export let getChangedPackages = async ({
1314
owner,
@@ -25,19 +26,14 @@ export let getChangedPackages = async ({
2526
installationToken: string;
2627
}) => {
2728
let hasErrored = false;
28-
let encodedCredentials = Buffer.from(
29-
`x-access-token:${installationToken}`
30-
).toString("base64");
29+
let encodedCredentials = Buffer.from(`x-access-token:${installationToken}`).toString("base64");
3130

3231
function fetchFile(path: string) {
33-
return fetch(
34-
`https://raw.githubusercontent.com/${owner}/${repo}/${ref}/${path}`,
35-
{
36-
headers: {
37-
Authorization: `Basic ${encodedCredentials}`,
38-
},
39-
}
40-
);
32+
return fetch(`https://raw.githubusercontent.com/${owner}/${repo}/${ref}/${path}`, {
33+
headers: {
34+
Authorization: `Basic ${encodedCredentials}`,
35+
},
36+
});
4137
}
4238

4339
function fetchJsonFile(path: string) {
@@ -107,7 +103,7 @@ export let getChangedPackages = async ({
107103
changesetPromises.push(
108104
fetchTextFile(item.path).then((text) => {
109105
return { ...parseChangeset(text), id };
110-
})
106+
}),
111107
);
112108
}
113109
}
@@ -138,10 +134,7 @@ export let getChangedPackages = async ({
138134
globs: rootPackageJsonContent.workspaces,
139135
};
140136
}
141-
} else if (
142-
rootPackageJsonContent.bolt &&
143-
rootPackageJsonContent.bolt.workspaces
144-
) {
137+
} else if (rootPackageJsonContent.bolt && rootPackageJsonContent.bolt.workspaces) {
145138
tool = {
146139
tool: "bolt",
147140
globs: rootPackageJsonContent.bolt.workspaces,
@@ -161,17 +154,12 @@ export let getChangedPackages = async ({
161154
};
162155

163156
if (tool) {
164-
if (
165-
!Array.isArray(tool.globs) ||
166-
!tool.globs.every((x) => typeof x === "string")
167-
) {
157+
if (!Array.isArray(tool.globs) || !tool.globs.every((x) => typeof x === "string")) {
168158
throw new Error("globs are not valid: " + JSON.stringify(tool.globs));
169159
}
170160
let matches = micromatch(potentialWorkspaceDirectories, tool.globs);
171161

172-
packages.packages = await Promise.all(
173-
matches.map((dir) => getPackage(dir))
174-
);
162+
packages.packages = await Promise.all(matches.map((dir) => getPackage(dir)));
175163
} else {
176164
packages.packages.push(packages.root);
177165
}
@@ -183,14 +171,14 @@ export let getChangedPackages = async ({
183171
await Promise.all(changesetPromises),
184172
packages,
185173
await configPromise.then((rawConfig) => parseConfig(rawConfig, packages)),
186-
await preStatePromise
174+
await preStatePromise,
187175
);
188176

189177
return {
190178
changedPackages: (packages.tool === "root"
191179
? packages.packages
192180
: packages.packages.filter((pkg) =>
193-
changedFiles.some((changedFile) => changedFile.startsWith(`${pkg.dir}/`))
181+
changedFiles.some((changedFile) => changedFile.startsWith(`${pkg.dir}/`)),
194182
)
195183
).map((x) => x.packageJson.name),
196184
releasePlan,

0 commit comments

Comments
 (0)