Skip to content

Commit 1321ff6

Browse files
authored
chore: run format (#314)
1 parent 08b45ad commit 1321ff6

File tree

17 files changed

+225
-198
lines changed

17 files changed

+225
-198
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
indent_size = 2
6+
indent_style = space
7+
trim_trailing_whitespace = true

.github/workflows/stats.yml

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
1-
name: pkg.pr.new stats
2-
3-
on:
4-
push:
5-
6-
jobs:
7-
stats:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- name: Set up Node.js
11-
uses: actions/setup-node@v3
12-
with:
13-
node-version: '16'
14-
15-
- name: Fetch and Count Data Iteratively
16-
uses: actions/github-script@v6
17-
with:
18-
script: |
19-
async function fetchAndCountData(url) {
20-
const counts = {
21-
templates: 0,
22-
packages: 0,
23-
orgs: new Set(),
24-
repos: new Set(),
25-
commits: 0,
26-
prsAndBranches: 0,
27-
};
28-
let cursor = null;
29-
30-
do {
31-
try {
32-
// Construct the URL with cursor if available
33-
const fetchUrl = cursor ? `${url}?cursor=${encodeURIComponent(cursor)}` : url;
34-
35-
// Fetch the data from the API
36-
const response = await fetch(fetchUrl);
37-
38-
if (!response.ok) {
39-
throw new Error(`HTTP error! status: ${response.status}`);
40-
}
41-
42-
const responseData = await response.json();
43-
44-
// Process the current page of data
45-
if (responseData.data) {
46-
for (const item of responseData.data) {
47-
if (item.type === "template") {
48-
counts.templates += 1;
49-
} else if (item.type === "package") {
50-
counts.packages += 1;
51-
counts.orgs.add(item.org);
52-
counts.repos.add(item.repo);
53-
counts.commits += 1; // Count one commit per package
54-
} else if (item.type === "cursor") {
55-
counts.orgs.add(item.org);
56-
counts.repos.add(item.repo);
57-
58-
// Count PR numbers and branch names combined
59-
counts.prsAndBranches += 1;
60-
}
61-
}
62-
}
63-
64-
// Update the cursor for the next page
65-
cursor = responseData.nextCursor || null;
66-
} catch (error) {
67-
console.error(`Error fetching data: ${error.message}`);
68-
cursor = null; // Exit the loop on error
69-
}
70-
} while (cursor);
71-
72-
return {
73-
templates: counts.templates,
74-
packages: counts.packages,
75-
orgs: counts.orgs.size,
76-
repos: counts.repos.size,
77-
commits: counts.commits,
78-
prsAndBranches: counts.prsAndBranches,
79-
};
80-
}
81-
82-
const url = "https://pkg.pr.new/stats";
83-
const counts = await fetchAndCountData(url);
84-
85-
console.log("Counts:", counts);
1+
name: pkg.pr.new stats
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
stats:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Set up Node.js
11+
uses: actions/setup-node@v3
12+
with:
13+
node-version: "16"
14+
15+
- name: Fetch and Count Data Iteratively
16+
uses: actions/github-script@v6
17+
with:
18+
script: |
19+
async function fetchAndCountData(url) {
20+
const counts = {
21+
templates: 0,
22+
packages: 0,
23+
orgs: new Set(),
24+
repos: new Set(),
25+
commits: 0,
26+
prsAndBranches: 0,
27+
};
28+
let cursor = null;
29+
30+
do {
31+
try {
32+
// Construct the URL with cursor if available
33+
const fetchUrl = cursor ? `${url}?cursor=${encodeURIComponent(cursor)}` : url;
34+
35+
// Fetch the data from the API
36+
const response = await fetch(fetchUrl);
37+
38+
if (!response.ok) {
39+
throw new Error(`HTTP error! status: ${response.status}`);
40+
}
41+
42+
const responseData = await response.json();
43+
44+
// Process the current page of data
45+
if (responseData.data) {
46+
for (const item of responseData.data) {
47+
if (item.type === "template") {
48+
counts.templates += 1;
49+
} else if (item.type === "package") {
50+
counts.packages += 1;
51+
counts.orgs.add(item.org);
52+
counts.repos.add(item.repo);
53+
counts.commits += 1; // Count one commit per package
54+
} else if (item.type === "cursor") {
55+
counts.orgs.add(item.org);
56+
counts.repos.add(item.repo);
57+
58+
// Count PR numbers and branch names combined
59+
counts.prsAndBranches += 1;
60+
}
61+
}
62+
}
63+
64+
// Update the cursor for the next page
65+
cursor = responseData.nextCursor || null;
66+
} catch (error) {
67+
console.error(`Error fetching data: ${error.message}`);
68+
cursor = null; // Exit the loop on error
69+
}
70+
} while (cursor);
71+
72+
return {
73+
templates: counts.templates,
74+
packages: counts.packages,
75+
orgs: counts.orgs.size,
76+
repos: counts.repos.size,
77+
commits: counts.commits,
78+
prsAndBranches: counts.prsAndBranches,
79+
};
80+
}
81+
82+
const url = "https://pkg.pr.new/stats";
83+
const counts = await fetchAndCountData(url);
84+
85+
console.log("Counts:", counts);

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
- release
77
pull_request:
88

9-
109
jobs:
1110
ci:
1211
runs-on: [ubuntu-latest]

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm-lock.yaml

packages/backend/script/update-webhook-url.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ config({ path: ".dev.vars" });
77
const nitroSigner = createSigner({
88
algorithm: "RS256",
99
key: process.env.NITRO_PRIVATE_KEY!,
10-
})
10+
});
1111

1212
function generateJWT() {
1313
const payload = {

packages/backend/server/routes/[owner]/[repo]/[packageAndRefOrSha].get.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import { WorkflowData } from "../../../types";
22
import { abbreviateCommitHash } from "@pkg-pr-new/utils";
3-
import { normalizeKey } from 'unstorage'
3+
import { normalizeKey } from "unstorage";
44

55
type Params = Omit<WorkflowData, "sha" | "ref"> & {
66
packageAndRefOrSha: string;
77
};
88

99
export default eventHandler(async (event) => {
1010
const params = getRouterParams(event) as Params;
11-
let [encodedPackageName, longerRefOrSha] = params.packageAndRefOrSha.split("@");
11+
let [encodedPackageName, longerRefOrSha] =
12+
params.packageAndRefOrSha.split("@");
1213
const packageName = decodeURIComponent(encodedPackageName);
13-
longerRefOrSha = longerRefOrSha.split('.tgz')[0] // yarn support
14+
longerRefOrSha = longerRefOrSha.split(".tgz")[0]; // yarn support
1415
const isSha = isValidGitHash(longerRefOrSha);
15-
const refOrSha = isSha ? abbreviateCommitHash(longerRefOrSha) : longerRefOrSha;
16+
const refOrSha = isSha
17+
? abbreviateCommitHash(longerRefOrSha)
18+
: longerRefOrSha;
1619

1720
let base = `${params.owner}:${params.repo}:${refOrSha}`;
1821
let packageKey = `${base}:${packageName}`;
@@ -35,7 +38,9 @@ export default eventHandler(async (event) => {
3538

3639
// longer sha support with precision
3740
const binding = useBinding(event);
38-
const { objects } = await binding.list({ prefix: `${usePackagesBucket.base}:${base}` })
41+
const { objects } = await binding.list({
42+
prefix: `${usePackagesBucket.base}:${base}`,
43+
});
3944
for (const { key } of objects) {
4045
// bucket:package:stackblitz-labs:pkg.pr.new:ded05e838c418096e5dd77a29101c8af9e73daea:playground-b
4146
const trimmedKey = key.slice(usePackagesBucket.base.length + 1);

packages/backend/server/routes/multipart/create.post.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default eventHandler(async (event) => {
1111
});
1212
}
1313
const workflowsBucket = useWorkflowsBucket(event);
14-
14+
1515
if (!(await workflowsBucket.hasItem(workflowKey))) {
1616
throw createError({
1717
statusCode: 401,
@@ -37,7 +37,7 @@ export default eventHandler(async (event) => {
3737

3838
const binding = useBinding(event);
3939

40-
const base = `${workflowData.owner}:${workflowData.repo}:${workflowData.sha}`
40+
const base = `${workflowData.owner}:${workflowData.repo}:${workflowData.sha}`;
4141
const packageKey = `${base}:${packageName}`;
4242

4343
const key = joinKeys(usePackagesBucket.base, packageKey);

packages/backend/server/routes/publish.post.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
Comment,
3-
isPullRequest,
4-
isWhitelisted,
5-
} from "@pkg-pr-new/utils";
1+
import { Comment, isPullRequest, isWhitelisted } from "@pkg-pr-new/utils";
62
import { randomUUID } from "uncrypto";
73
import { setItemStream, useTemplatesBucket } from "~/utils/bucket";
84
import { useOctokitInstallation } from "~/utils/octokit";

0 commit comments

Comments
 (0)