Publish to pegjs@dev on every CI run

This adds a new local package called '@pegjs/publish-dev' that will be run by the CI after all other tasks.

'@pegjs/publish-dev' will, as the name implies, publish a new release of pegjs on NPM under the dev tag.
master
Futago-za Ryuu 5 years ago
parent d7c11c54e8
commit baf8b3a339

1
.gitignore vendored

@ -1,5 +1,6 @@
/.idea
/packages/pegjs/dist
/packages/pegjs/.npmrc
/docs/.vuepress/dist
/dist
/examples/*.js

@ -23,6 +23,7 @@ PEG.js is a simple parser generator for JavaScript that produces fast parsers wi
| [~/tools/benchmark][L004] | [![dependencies][L005]][L006] |
| [~/tools/bundler][L007] | [![dependencies][L008]][L009] |
| [~/tools/impact][L010] | [![dependencies][L011]][L012] |
| [~/tools/publish-dev][L016] | [![dependencies][L017]][L018] |
[<img src="website/img/CBT_OS-logo_Black-H.png" width="500" />](https://crossbrowsertesting.com/)
@ -59,3 +60,8 @@ PEG.js is a simple parser generator for JavaScript that produces fast parsers wi
[L010]: https://github.com/pegjs/pegjs/tree/master/tools/impact
[L011]: https://img.shields.io/david/pegjs/pegjs.svg?path=tools/impact
[L012]: https://david-dm.org/pegjs/pegjs?path=tools/impact
<!-- tools/publish-dev -->
[L016]: https://github.com/pegjs/pegjs/tree/master/tools/publish-dev
[L017]: https://img.shields.io/david/pegjs/pegjs.svg?path=tools/publish-dev
[L018]: https://david-dm.org/pegjs/pegjs?path=tools/publish-dev

@ -42,5 +42,14 @@ jobs:
env:
CC_TEST_REPORTER_ID: $(CC_TEST_REPORTER_ID)
CODECOV_TOKEN: $(CODECOV_TOKEN)
afterAll:
- script: |
npm run build-dist
node tools/publish-dev
displayName: 'publish pegjs@dev'
variables:
GIT_BRANCH: $(Build.SourceBranchName)
GIT_COMMIT_SHA: $(Build.SourceVersion)
NPM_TOKEN: $(NPM_TOKEN)
publish_test_results_to_pipelines: True
publish_code_coverage_to_pipelines: True

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -13,8 +13,8 @@
"build-docs": "vuepress build docs",
"watch-docs": "vuepress dev docs",
"build-parser": "pegjs -c src/pegjs.config.js",
"build-bundles": "bundle",
"watch-bundles": "bundle --watch",
"build-dist": "bundle",
"watch-dist": "bundle --watch",
"clean": "rimraf packages/pegjs/dist examples/*.js",
"impact": "node tools/impact master",
"now-build": "npm run build-docs",

@ -0,0 +1 @@
dist/*-bundle.min.js

@ -1,6 +1,6 @@
{
"name": "pegjs",
"version": "0.11.0-dev",
"version": "0.11.0",
"description": "Parser generator for JavaScript",
"keywords": [
"PEG.js",

@ -0,0 +1,59 @@
"use strict";
const cp = require( "child_process" );
const fs = require( "fs" );
const path = require( "path" );
// paths
const packagejson = require.resolve( "pegjs/package.json" );
const pegjs = path.dirname( packagejson );
const npmignore = path.join( pegjs, ".npmignore" );
const npmrc = path.join( pegjs, ".npmrc" );
// variabes
const APP = require( "./package.json" ).name;
const { GIT_BRANCH, GIT_COMMIT_SHA, NPM_TOKEN } = process.env;
const VERSION = require( packagejson ).version;
// local helpers
function die( err ) {
console.error( err );
process.exit( 1 );
}
function exec( command, print = true ) {
const result = cp.execSync( command, {
cwd: pegjs,
stdio: print ? "inherit" : void 0,
} );
return print ? void 0 : result.toString( "utf8" );
}
// assertions
if ( ! GIT_BRANCH ) die( "`process.env.GIT_BRANCH` is required by " + APP );
if ( ! NPM_TOKEN ) die( "`process.env.NPM_TOKEN` is required by " + APP );
// update version field in `pegjs/package.json`
const GIT_COMMIT_SHORT_SHA = exec( "git rev-parse --short " + GIT_COMMIT_SHA || GIT_BRANCH, false );
const dev = `${ VERSION }-${ GIT_BRANCH }.${ GIT_COMMIT_SHORT_SHA }`;
exec( `npm --no-git-tag-version -f version ${ dev }` );
// publish pegjs@dev
fs.writeFileSync( npmrc, `//registry.npmjs.org/:_authToken=${ NPM_TOKEN }` );
fs.unlinkSync( npmignore );
exec( "npm publish --tag=dev" );
fs.unlinkSync( npmrc );

@ -0,0 +1,5 @@
{
"name": "@pegjs/publish-dev",
"version": "2.0.0",
"private": true
}

@ -4,7 +4,7 @@ const target = require( "@pegjs/bundler/target" );
module.exports = [
/* packages/pegjs/dist/peg.js */
/* https://unpkg.com/pegjs@latest/dist/peg.js */
target( {
entry: require.resolve( "pegjs" ),
@ -13,7 +13,7 @@ module.exports = [
} ),
/* packages/pegjs/dist/peg.min.js */
/* https://unpkg.com/pegjs@latest/dist/peg.min.js */
target( {
entry: require.resolve( "pegjs" ),
@ -22,7 +22,7 @@ module.exports = [
} ),
/* https://pegjs.org/*-bundle.min.js */
/* https://unpkg.com/pegjs@dev/dist/*-bundle.min.js */
target( {
entry: {
@ -30,7 +30,7 @@ module.exports = [
"test": require.resolve( "@pegjs/spec-suite/browser.stub.js" ),
},
library: [ "peg", "[name]" ],
output: "docs/.vuepress/public/[name]-bundle.min.js",
output: "packages/pegjs/dist/[name]-bundle.min.js",
} ),

Loading…
Cancel
Save