From c75e816cb500a225202e52f1de3199fb23aa4b66 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Wed, 2 Mar 2022 15:31:42 -0800 Subject: [PATCH] Meta: publish biblio to npm (#2393) --- .github/workflows/publish-biblio.yml | 27 +++++++++++++++++++++++++++ biblio/README.md | 9 +++++++++ biblio/package.json | 21 +++++++++++++++++++++ scripts/check-form.js | 2 +- scripts/publish-biblio.sh | 20 ++++++++++++++++++++ 5 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-biblio.yml create mode 100644 biblio/README.md create mode 100644 biblio/package.json create mode 100755 scripts/publish-biblio.sh diff --git a/.github/workflows/publish-biblio.yml b/.github/workflows/publish-biblio.yml new file mode 100644 index 00000000000..783c3b62d47 --- /dev/null +++ b/.github/workflows/publish-biblio.yml @@ -0,0 +1,27 @@ +name: 'ecma-262-biblio' + +on: + push: + branches: + - main + +jobs: + publish: + name: 'publish ecma262-biblio' + runs-on: ubuntu-latest + if: ${{ github.repository == 'tc39/ecma262' }} + + steps: + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: 'lts/*' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Publish biblio + run: scripts/publish-biblio.sh + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_FOR_TC39_USER }} diff --git a/biblio/README.md b/biblio/README.md new file mode 100644 index 00000000000..b54ce9586d3 --- /dev/null +++ b/biblio/README.md @@ -0,0 +1,9 @@ +# ECMA-262 Bibliography + +This package, available on npm as `@tc39/ecma262-biblio`, contains a machine-readable representation of the terms, clauses, grammar, and abstract operations defined in ECMA-262. This will primarily be of use to people working with the specification itself. + +If added as a dependency to a project using ecmarkup, you can load it by passing `--load-biblio @tc39/ecma262-biblio`. + +It is automatically updated whenever ECMA-262 is. It is inherently unstable: editorial changes to the specification may add, remove, or modify the biblio, which may break your build (for example, if using ecmarkup with `--lint-spec --strict`). As such, **the usual semver guarantees do not hold**. You should pin a precise version of this package. + +Major version bumps may be used for breaking changes to the format of the biblio itself. Minor version bumps may be used for non-breaking additions to the biblio format. diff --git a/biblio/package.json b/biblio/package.json new file mode 100644 index 00000000000..830e1ed633f --- /dev/null +++ b/biblio/package.json @@ -0,0 +1,21 @@ +{ + "name": "@tc39/ecma262-biblio", + "version": "VERSIONED-DURING-PUBLISH", + "description": "Machine-readable representation of the internals of the ecma-262 spec", + "keywords": [ + "ecmascript" + ], + "author": "TC39", + "main": "biblio.json", + "exports": { + ".": "./biblio.json", + "./package.json": "./package.json" + }, + "files": [ + "biblio.json" + ], + "license": "SEE LICENSE IN LICENSE.md", + "publishConfig": { + "access": "public" + } +} diff --git a/scripts/check-form.js b/scripts/check-form.js index 29d68b5bd76..35229eb6fc7 100644 --- a/scripts/check-form.js +++ b/scripts/check-form.js @@ -74,7 +74,7 @@ const authors = request(branchURL).then((json) => JSON.parse(json)).then(data => const teamURL = 'https://api.github.com/orgs/tc39/teams/delegates'; function getMembers(teamID, page = 1) { - const memberURL = `https://api.github.com/teams/${teamID}/members?per_page=100&page=${page}`; + const memberURL = `https://api.github.com/organizations/tc39/teams/${teamID}/members?per_page=100&page=${page}`; const data = request(memberURL).then((json) => JSON.parse(json)); return data.then((data) => { if (data.length > 0) { diff --git a/scripts/publish-biblio.sh b/scripts/publish-biblio.sh new file mode 100755 index 00000000000..46cae7c82df --- /dev/null +++ b/scripts/publish-biblio.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -euxo pipefail + + +$(npm bin)/ecmarkup --verbose spec.html --write-biblio biblio/biblio.json /dev/null + +cp LICENSE.md biblio/ + +cd biblio + +COMMIT_COUNT=$(git rev-list --count HEAD) +npm version --no-git-tag-version "1.0.${COMMIT_COUNT}" + +SHORT_COMMIT=$(git rev-parse --short HEAD) +LONG_COMMIT=$(git rev-parse --verify HEAD) +echo " +This version was built from commit [${SHORT_COMMIT}](https://github.com/tc39/ecma262/tree/${LONG_COMMIT})." >> README.md + +npm publish --access public