Skip to content

Commit 963d393

Browse files
committed
Merge branch 'main' into title-removal-fix
2 parents 3265021 + 4c4f18b commit 963d393

File tree

1,184 files changed

+7826
-21869
lines changed

Some content is hidden

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

1,184 files changed

+7826
-21869
lines changed

.changeset/empty-hairs-love.md

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

.changeset/polite-timers-tell.md

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

.changeset/selfish-chicken-argue.md

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

.changeset/silly-bulldogs-rest.md

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

.changeset/warm-eyes-protect.md

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

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [ ] Prefix your PR title with `feat:`, `fix:`, `chore:`, or `docs:`.
55
- [ ] This message body should clearly illustrate what problems it solves.
66
- [ ] Ideally, include a test that fails without this PR but passes with it.
7+
- [ ] If this PR changes code within `packages/svelte/src`, add a changeset (`npx changeset`).
78

89
### Tests and linting
910

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# https://github.com/sveltejs/svelte.dev/blob/main/apps/svelte.dev/scripts/sync-docs/README.md
2+
name: Docs preview create request
3+
4+
on:
5+
pull_request_target:
6+
branches:
7+
- main
8+
9+
jobs:
10+
dispatch:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Repository Dispatch
14+
uses: peter-evans/repository-dispatch@v3
15+
with:
16+
token: ${{ secrets.SYNC_REQUEST_TOKEN }}
17+
repository: sveltejs/svelte.dev
18+
event-type: docs-preview-create
19+
client-payload: |-
20+
{
21+
"package": "svelte",
22+
"repo": "${{ github.repository }}",
23+
"owner": "${{ github.event.pull_request.head.repo.owner.login }}",
24+
"branch": "${{ github.event.pull_request.head.ref }}",
25+
"pr": ${{ github.event.pull_request.number }}
26+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# https://github.com/sveltejs/svelte.dev/blob/main/apps/svelte.dev/scripts/sync-docs/README.md
2+
name: Docs preview delete request
3+
4+
on:
5+
pull_request_target:
6+
branches:
7+
- main
8+
types: [closed]
9+
10+
jobs:
11+
dispatch:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Repository Dispatch
15+
uses: peter-evans/repository-dispatch@v3
16+
with:
17+
token: ${{ secrets.SYNC_REQUEST_TOKEN }}
18+
repository: sveltejs/svelte.dev
19+
event-type: docs-preview-delete
20+
client-payload: |-
21+
{
22+
"package": "svelte",
23+
"repo": "${{ github.repository }}",
24+
"owner": "${{ github.event.pull_request.head.repo.owner.login }}",
25+
"branch": "${{ github.event.pull_request.head.ref }}",
26+
"pr": ${{ github.event.pull_request.number }}
27+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Update pkg.pr.new comment
2+
3+
on:
4+
workflow_run:
5+
workflows: ['Publish Any Commit']
6+
types:
7+
- completed
8+
9+
jobs:
10+
build:
11+
name: 'Update comment'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Download artifact
15+
uses: actions/download-artifact@v4
16+
with:
17+
name: output
18+
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
run-id: ${{ github.event.workflow_run.id }}
20+
21+
- run: ls -R .
22+
- name: 'Post or update comment'
23+
uses: actions/github-script@v6
24+
with:
25+
github-token: ${{ secrets.GITHUB_TOKEN }}
26+
script: |
27+
const fs = require('fs');
28+
const output = JSON.parse(fs.readFileSync('output.json', 'utf8'));
29+
30+
const bot_comment_identifier = `<!-- pkg.pr.new comment -->`;
31+
32+
const body = (number) => `${bot_comment_identifier}
33+
34+
[Playground](https://svelte.dev/playground?version=pr-${number})
35+
36+
\`\`\`
37+
${output.packages.map((p) => `pnpm add https://pkg.pr.new/${p.name}@${number}`).join('\n')}
38+
\`\`\`
39+
`;
40+
41+
async function find_bot_comment(issue_number) {
42+
if (!issue_number) return null;
43+
const comments = await github.rest.issues.listComments({
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
issue_number: issue_number,
47+
});
48+
return comments.data.find((comment) =>
49+
comment.body.includes(bot_comment_identifier)
50+
);
51+
}
52+
53+
async function create_or_update_comment(issue_number) {
54+
if (!issue_number) {
55+
console.log('No issue number provided. Cannot post or update comment.');
56+
return;
57+
}
58+
59+
const existing_comment = await find_bot_comment(issue_number);
60+
if (existing_comment) {
61+
await github.rest.issues.updateComment({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
comment_id: existing_comment.id,
65+
body: body(issue_number),
66+
});
67+
} else {
68+
await github.rest.issues.createComment({
69+
issue_number: issue_number,
70+
owner: context.repo.owner,
71+
repo: context.repo.repo,
72+
body: body(issue_number),
73+
});
74+
}
75+
}
76+
77+
async function log_publish_info() {
78+
const svelte_package = output.packages.find(p => p.name === 'svelte');
79+
const svelte_sha = svelte_package.url.replace(/^.+@([^@]+)$/, '$1');
80+
console.log('\n' + '='.repeat(50));
81+
console.log('Publish Information');
82+
console.log('='.repeat(50));
83+
console.log('\nPublished Packages:');
84+
console.log(output.packages.map((p) => `${p.name} - pnpm add https://pkg.pr.new/${p.name}@${p.url.replace(/^.+@([^@]+)$/, '$1')}`).join('\n'));
85+
if(svelte_sha){
86+
console.log('\nPlayground URL:');
87+
console.log(`\nhttps://svelte.dev/playground?version=commit-${svelte_sha}`)
88+
}
89+
console.log('\n' + '='.repeat(50));
90+
}
91+
92+
if (output.event_name === 'pull_request') {
93+
if (output.number) {
94+
await create_or_update_comment(output.number);
95+
}
96+
} else if (output.event_name === 'push') {
97+
const pull_requests = await github.rest.pulls.list({
98+
owner: context.repo.owner,
99+
repo: context.repo.repo,
100+
state: 'open',
101+
head: `${context.repo.owner}:${output.ref.replace('refs/heads/', '')}`,
102+
});
103+
104+
if (pull_requests.data.length > 0) {
105+
await create_or_update_comment(pull_requests.data[0].number);
106+
} else {
107+
console.log(
108+
'No open pull request found for this push. Logging publish information to console:'
109+
);
110+
await log_publish_info();
111+
}
112+
}

.github/workflows/pkg.pr.new.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,22 @@ jobs:
2121
- name: Build
2222
run: pnpm build
2323

24-
- run: pnpx pkg-pr-new publish --compact --no-template './packages/svelte'
24+
- run: pnpx pkg-pr-new publish --comment=off --json output.json --compact --no-template './packages/svelte'
25+
- name: Add metadata to output
26+
uses: actions/github-script@v6
27+
with:
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
script: |
30+
const fs = require('fs');
31+
const output = JSON.parse(fs.readFileSync('output.json', 'utf8'));
32+
output.number = context.issue.number;
33+
output.event_name = context.eventName;
34+
output.ref = context.ref;
35+
fs.writeFileSync('output.json', JSON.stringify(output), 'utf8');
36+
- name: Upload output
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: output
40+
path: ./output.json
41+
42+
- run: ls -R .

0 commit comments

Comments
 (0)