Skip to content

Commit 4438b26

Browse files
authored
Initial commit
0 parents  commit 4438b26

File tree

11 files changed

+566
-0
lines changed

11 files changed

+566
-0
lines changed

.github/workflows/publish-main.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: ljharb/actions/node/install@main
14+
name: 'nvm install lts/* && npm install'
15+
with:
16+
node-version: lts/*
17+
- run: npm run build
18+
- name: Publish to gh-pages
19+
uses: JamesIves/github-pages-deploy-action@v4
20+
with:
21+
branch: gh-pages
22+
folder: build
23+
clean-exclude: |
24+
pr

.github/workflows/publish-pr.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Publish PR
2+
run-name: ${{ github.event.workflow_run.display_title }}
3+
4+
on:
5+
workflow_run:
6+
workflows: ['Render PR']
7+
types: [completed]
8+
9+
env:
10+
# Must match ./render-pr.yml
11+
ARTIFACT_NAME: ${{ vars.ARTIFACT_NAME || 'result' }}
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
if: >
17+
${{
18+
!github.event.repository.fork
19+
&& github.event.workflow_run.event == 'pull_request'
20+
&& github.event.workflow_run.conclusion == 'success'
21+
}}
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: ljharb/actions/node/install@main
25+
name: 'nvm install lts/* && npm install'
26+
with:
27+
node-version: lts/*
28+
- name: Print event info
29+
uses: actions/github-script@v7
30+
with:
31+
script: 'console.log(${{ toJson(github.event) }});'
32+
- name: Download zipball
33+
uses: actions/github-script@v7
34+
with:
35+
script: |
36+
const { owner, repo } = context.repo;
37+
const run_id = ${{ github.event.workflow_run.id }};
38+
const name = process.env.ARTIFACT_NAME;
39+
const listArtifactsQuery = { owner, repo, run_id, name };
40+
const listArtifactsResponse = await github.rest.actions.listWorkflowRunArtifacts(listArtifactsQuery);
41+
const { total_count, artifacts } = listArtifactsResponse.data;
42+
if (total_count !== 1) {
43+
const summary = artifacts?.map(({ name, size_in_bytes, url }) => ({ name, size_in_bytes, url }));
44+
const detail = JSON.stringify(summary ?? []);
45+
throw new RangeError(`Expected 1 ${name} artifact, got ${total_count} ${detail}`);
46+
}
47+
const artifact_id = artifacts[0].id;
48+
console.log(`downloading artifact ${artifact_id}`);
49+
const downloadResponse = await github.rest.actions.downloadArtifact({
50+
owner,
51+
repo,
52+
artifact_id,
53+
archive_format: 'zip',
54+
});
55+
const fs = require('fs');
56+
fs.writeFileSync('${{ github.workspace }}/result.zip', Buffer.from(downloadResponse.data));
57+
- name: Provide result directory
58+
run: rm -rf result && mkdir -p result
59+
- run: unzip -o result.zip -d result
60+
- run: ls result
61+
- name: Extract PR data
62+
run: |
63+
cd result
64+
awk -v ok=1 '
65+
NR == 1 && match($0, /^[1-9][0-9]* [0-9a-fA-F]{7,}$/) {
66+
print "PR=" $1;
67+
print "COMMIT=" $2;
68+
next;
69+
}
70+
{ ok = 0; }
71+
END { exit !ok; }
72+
' pr-data.txt >> "$GITHUB_ENV"
73+
rm pr-data.txt
74+
- name: Insert preview warning
75+
run: |
76+
tmp="$(mktemp -u XXXXXXXX.json)"
77+
export REPO_URL="https://github.com/$GITHUB_REPOSITORY"
78+
jq -n '
79+
def repo_link($args): $args as [$path, $contents]
80+
| (env.REPO_URL + ($path // "")) as $url
81+
| "<a href=\"\($url | @html)\">\($contents // $url)</a>";
82+
{
83+
SUMMARY: "PR #\(env.PR)",
84+
REPO_LINK: repo_link([]),
85+
PR_LINK: repo_link(["/pull/" + env.PR, "PR #\(env.PR)"]),
86+
COMMIT_LINK: ("commit " + repo_link(["/commit/" + env.COMMIT, "<code>\(env.COMMIT)</code>"])),
87+
}
88+
' > "$tmp"
89+
find result -name '*.html' -exec \
90+
node scripts/insert_warning.mjs scripts/pr_preview_warning.html "$tmp" '{}' '+'
91+
- name: Publish to gh-pages
92+
uses: JamesIves/github-pages-deploy-action@v4
93+
with:
94+
branch: gh-pages
95+
folder: result
96+
target-folder: pr/${{ env.PR }}
97+
- name: Determine gh-pages url
98+
id: get-pages-url
99+
run: |
100+
gh_pages_url="https://$(printf '%s' "$GITHUB_REPOSITORY" \
101+
| sed 's#/#.github.io/#; s#^tc39.github.io/#tc39.es/#')"
102+
echo "url=$gh_pages_url" >> $GITHUB_OUTPUT
103+
- name: Provide PR comment
104+
uses: phulsechinmay/[email protected]
105+
with:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
ISSUE_ID: ${{ env.PR }}
108+
message: >
109+
The rendered spec for this PR is available at
110+
${{ steps.get-pages-url.outputs.url }}/pr/${{ env.PR }}.

.github/workflows/render-pr.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Render PR
2+
3+
on: [pull_request]
4+
5+
env:
6+
# Must match ./publish-pr.yml
7+
ARTIFACT_NAME: ${{ vars.ARTIFACT_NAME || 'result' }}
8+
9+
jobs:
10+
render:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.pull_request }}
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: '[node LTS] npm install'
16+
uses: ljharb/actions/node/install@main
17+
with:
18+
node-version: lts/*
19+
- run: npm run build
20+
- name: Save PR data
21+
env:
22+
PR: ${{ github.event.number }}
23+
run: echo "$PR $(git rev-parse --verify HEAD)" > build/pr-data.txt
24+
- uses: actions/upload-artifact@v4
25+
id: upload
26+
if: ${{ !github.event.repository.fork }}
27+
with:
28+
name: ${{ env.ARTIFACT_NAME }}
29+
path: build/
30+
- name: Echo artifact ID
31+
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
32+
- name: Verify artifact discoverability
33+
uses: actions/github-script@v7
34+
with:
35+
script: |
36+
const { owner, repo } = context.repo;
37+
const run_id = ${{ github.run_id }};
38+
const listArtifactsResponse = await github.rest.actions.listWorkflowRunArtifacts({ owner, repo, run_id });
39+
console.log(`artifacts for run id ${run_id}`, listArtifactsResponse?.data);

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# node-waf configuration
24+
.lock-wscript
25+
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
29+
# Dependency directories
30+
node_modules
31+
jspm_packages
32+
33+
# Optional npm cache directory
34+
.npm
35+
36+
# Optional REPL history
37+
.node_repl_history
38+
39+
# Only apps should have lockfiles
40+
yarn.lock
41+
package-lock.json
42+
npm-shrinkwrap.json
43+
pnpm-lock.yaml
44+
45+
# Build directory
46+
build

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 ECMA TC39 and contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# template-for-proposals
2+
3+
A repository template for ECMAScript proposals.
4+
5+
## Before creating a proposal
6+
7+
Please ensure the following:
8+
1. You have read the [process document](https://tc39.github.io/process-document/)
9+
1. You have reviewed the [existing proposals](https://github.com/tc39/proposals/)
10+
1. You are aware that your proposal requires being a member of TC39, or locating a TC39 delegate to “champion” your proposal
11+
12+
## Create your proposal repo
13+
14+
Follow these steps:
15+
1. Click the green [“use this template”](https://github.com/tc39/template-for-proposals/generate) button in the repo header. (Note: Do not fork this repo in GitHub's web interface, as that will later prevent transfer into the TC39 organization)
16+
1. Update ecmarkup and the biblio to the latest version: `npm install --save-dev ecmarkup@latest && npm install --save-dev --save-exact @tc39/ecma262-biblio@latest`.
17+
1. Go to your repo settings page:
18+
1. Under “General”, under “Features”, ensure “Issues” is checked, and disable “Wiki”, and “Projects” (unless you intend to use Projects)
19+
1. Under “Pull Requests”, check “Always suggest updating pull request branches” and “automatically delete head branches”
20+
1. Under the “Pages” section on the left sidebar, and set the source to “deploy from a branch”, select “gh-pages” in the branch dropdown, and then ensure that “Enforce HTTPS” is checked.
21+
1. Under the “Actions” section on the left sidebar, under “General”, select “Read and write permissions” under “Workflow permissions” and click “Save”
22+
1. [“How to write a good explainer”][explainer] explains how to make a good first impression.
23+
24+
> Each TC39 proposal should have a `README.md` file which explains the purpose
25+
> of the proposal and its shape at a high level.
26+
>
27+
> ...
28+
>
29+
> The rest of this page can be used as a template ...
30+
31+
Your explainer can point readers to the `index.html` generated from `spec.emu`
32+
via markdown like
33+
34+
```markdown
35+
You can browse the [ecmarkup output](https://ACCOUNT.github.io/PROJECT/)
36+
or browse the [source](https://github.com/ACCOUNT/PROJECT/blob/HEAD/spec.emu).
37+
```
38+
39+
where *ACCOUNT* and *PROJECT* are the first two path elements in your project's Github URL.
40+
For example, for github.com/**tc39**/**template-for-proposals**, *ACCOUNT* is “tc39”
41+
and *PROJECT* is “template-for-proposals”.
42+
43+
44+
## Maintain your proposal repo
45+
46+
1. Make your changes to `spec.emu` (ecmarkup uses HTML syntax, but is not HTML, so I strongly suggest not naming it “.html”)
47+
1. Any commit that makes meaningful changes to the spec, should run `npm run build` to verify that the build will succeed and the output looks as expected.
48+
1. Whenever you update `ecmarkup`, run `npm run build` to verify that the build will succeed and the output looks as expected.
49+
50+
[explainer]: https://github.com/tc39/how-we-work/blob/HEAD/explainer.md

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"private": true,
3+
"name": "template-for-proposals",
4+
"description": "A repository template for ECMAScript proposals.",
5+
"scripts": {
6+
"start": "npm run build-loose -- --watch",
7+
"build": "npm run build-loose -- --strict",
8+
"build-loose": "node -e 'fs.mkdirSync(\"build\", { recursive: true })' && ecmarkup --load-biblio @tc39/ecma262-biblio --verbose spec.emu build/index.html --lint-spec"
9+
},
10+
"homepage": "https://github.com/tc39/template-for-proposals#readme",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/tc39/template-for-proposals.git"
14+
},
15+
"license": "MIT",
16+
"devDependencies": {
17+
"@tc39/ecma262-biblio": "^2.1.2895",
18+
"ecmarkup": "^21.3.0",
19+
"jsdom": "^26.1.0",
20+
"parse5-html-rewriting-stream": "^7.1.0",
21+
"tmp": "^0.2.3"
22+
},
23+
"engines": {
24+
"node": ">= 18"
25+
}
26+
}

0 commit comments

Comments
 (0)