From 93ceeff597a012c5cd6fc9d01b28f09b2930fe6f Mon Sep 17 00:00:00 2001 From: Futago-za Ryuu Date: Sun, 4 Nov 2018 10:01:56 +0000 Subject: [PATCH] General QOL changes - Added 'test/package.json' for dependencies used by spec tests - Changed package names of local tools to reflect actual usage - Removed bins for local tools (using files via 'node [file]' command) - Updated help text for the CLIs of local tools to reflect changes - Updated READMEs for tools - Moved babel dependencies to 'tools/bundle/package.json' - 'tools/bundle' now only logs created and watching - Updated scripts in root package.json --- package.json | 15 ++++----------- test/package.json | 10 ++++++++++ tools/benchmark/README.md | 2 +- tools/benchmark/node.js | 13 +++++-------- tools/benchmark/package.json | 5 ++--- tools/bundle/create-pegjs-dist.js | 2 -- tools/bundle/index.js | 10 ++++------ tools/bundle/package.json | 5 +++-- tools/impact/README.md | 4 ++-- tools/impact/index.js | 8 +++----- tools/impact/package.json | 3 +-- website/package.json | 2 +- website/server.js | 2 +- 13 files changed, 37 insertions(+), 44 deletions(-) create mode 100644 test/package.json diff --git a/package.json b/package.json index 3e9f383..1447b20 100644 --- a/package.json +++ b/package.json @@ -4,30 +4,23 @@ "workspaces": [ "packages/*", "tools/*", + "test", "website" ], "scripts": { "lint": "eslint .", "spec": "mocha --recursive", - "benchmark": "benchmark", + "benchmark": "node tools/benchmark/node", "build-parser": "pegjs -c src/pegjs.config.js", - "generate-dist": "bundle", + "generate-dist": "node tools/bundle/create-pegjs-dist", "clean": "rimraf packages/pegjs/dist website/js/*-bundle.js examples/*.js", - "impact": "impact master", + "impact": "node tools/impact master", "start": "node website/server.js", "test": "eslint . && nyc mocha --recursive", "coverage": "nyc report --reporter=text-lcov | coveralls" }, - "dependencies": { - "@babel/core": "~7.1.0", - "@babel/preset-env": "~7.1.0", - "chai": "4.2.0", - "chai-like": "1.1.1", - "sinon": "7.1.0" - }, "devDependencies": { "coveralls": "3.0.2", - "dedent": "0.7.0", "rimraf": "2.6.2", "eslint": "5", "eslint-config-futagozaryuu": "5", diff --git a/test/package.json b/test/package.json new file mode 100644 index 0000000..7c91200 --- /dev/null +++ b/test/package.json @@ -0,0 +1,10 @@ +{ + "name": "@pegjs/spec-suite", + "version": "0.11.0", + "private": true, + "dependencies": { + "chai": "4.2.0", + "chai-like": "1.1.1", + "sinon": "7.1.0" + } +} diff --git a/tools/benchmark/README.md b/tools/benchmark/README.md index a3a69f9..3fea73f 100644 --- a/tools/benchmark/README.md +++ b/tools/benchmark/README.md @@ -3,5 +3,5 @@ This directory contains the benchmark suite that measures the speed of parsers g From the root of the repository: ```sh -npx benchmark +node tools/benchmark/node ``` diff --git a/tools/benchmark/node.js b/tools/benchmark/node.js index 0f3f78e..5735bac 100644 --- a/tools/benchmark/node.js +++ b/tools/benchmark/node.js @@ -1,5 +1,3 @@ -#!/usr/bin/env node - "use strict"; const Runner = require( "./runner.js" ); @@ -91,15 +89,14 @@ function writeTableFooter() { function printHelp() { - console.log( "Usage: run [options]" ); + console.log( "Usage:" ); console.log( "" ); - console.log( "Runs PEG.js benchmark suite." ); + console.log( " node tools/benchmark [options]" ); console.log( "" ); console.log( "Options:" ); - console.log( " -n, --run-count number of runs (default: 10)" ); - console.log( " --cache make tested parsers cache results" ); - console.log( " -o, --optimize select optimization for speed or size (default:" ); - console.log( " speed)" ); + console.log( " -n, --run-count number of runs (default: 10)" ); + console.log( " --cache make tested parsers cache results" ); + console.log( " -o, --optimize select optimization for speed or size (default: speed)" ); } diff --git a/tools/benchmark/package.json b/tools/benchmark/package.json index d0d29f6..57ccb21 100644 --- a/tools/benchmark/package.json +++ b/tools/benchmark/package.json @@ -1,6 +1,5 @@ { - "name": "benchmark", + "name": "@pegjs/benchmark-suite", "version": "3.1.0", - "private": true, - "bin": "node.js" + "private": true } diff --git a/tools/bundle/create-pegjs-dist.js b/tools/bundle/create-pegjs-dist.js index 2e12a60..ac7683f 100644 --- a/tools/bundle/create-pegjs-dist.js +++ b/tools/bundle/create-pegjs-dist.js @@ -1,5 +1,3 @@ -#!/usr/bin/env node - "use strict"; const bundle = require( "./index" ); diff --git a/tools/bundle/index.js b/tools/bundle/index.js index 7f4ba3b..82d61a9 100644 --- a/tools/bundle/index.js +++ b/tools/bundle/index.js @@ -92,13 +92,11 @@ module.exports = bundle => { if ( bundle.watch !== true ) { - log( `@pegjs/bundle > bundling ${ pp( config.input ) }` ); - return rollup.rollup( config ) .then( bundle => bundle.write( config.output ) ) .then( () => { - log( `@pegjs/bundle > created ${ pp( bundle.target ) }` ); + log( `@pegjs/bundle-generator > created ${ pp( bundle.target ) }` ); } ) .catch( handleError ); @@ -113,11 +111,11 @@ module.exports = bundle => { switch ( event.code ) { case "BUNDLE_START": - log( `@pegjs/bundle > watching ${ pp( event.input ) }` ); + log( `@pegjs/bundle-generator > watching ${ pp( event.input ) }` ); break; case "BUNDLE_END": - log( `@pegjs/bundle > created ${ pp( event.output ) } in ${ ms( event.duration ) }` ); + log( `@pegjs/bundle-generator > created ${ pp( event.output ) } in ${ ms( event.duration ) }` ); break; case "ERROR": @@ -125,7 +123,7 @@ module.exports = bundle => { break; case "FATAL": - console.error( "@pegjs/bundle > Fatel Error!" ); + console.error( "@pegjs/bundle-generator > Fatel Error!" ); handleError( event.error ); break; diff --git a/tools/bundle/package.json b/tools/bundle/package.json index c74deea..a5fd417 100644 --- a/tools/bundle/package.json +++ b/tools/bundle/package.json @@ -1,10 +1,11 @@ { - "name": "bundle", + "name": "@pegjs/bundle-generator", "version": "2.1.0", "private": true, "main": "index.js", - "bin": "create-pegjs-dist.js", "dependencies": { + "@babel/core": "~7.1.0", + "@babel/preset-env": "~7.1.0", "dedent": "0.7.0", "pretty-ms": "4.0.0", "rollup": "0.66.6", diff --git a/tools/impact/README.md b/tools/impact/README.md index de43d9e..e830f54 100644 --- a/tools/impact/README.md +++ b/tools/impact/README.md @@ -3,6 +3,6 @@ This directory contains a tool used on the PEG.js repository that measures the i From the root of the repository: ```sh -npx impact -npx impact +node tools/impact +node tools/impact ``` diff --git a/tools/impact/index.js b/tools/impact/index.js index 3eb2985..67c961e 100644 --- a/tools/impact/index.js +++ b/tools/impact/index.js @@ -1,5 +1,3 @@ -#!/usr/bin/env node - // // Measures impact of a Git commit (or multiple commits) on generated parsers // speed and size. Makes sense to use only on PEG.js git repository checkout. @@ -132,8 +130,8 @@ if ( argv.length === 1 ) { Usage: - test/impact - test/impact + node tools/impact + node tools/impact Measures impact of a Git commit (or multiple commits) on generated parser's speed and size. Makes sense to use only on PEG.js Git repository checkout. @@ -170,7 +168,7 @@ print_empty_line(); console.log( dedent` - test/impact ${ commit_before } ${ commit_after } + node tools/impact ${ commit_before } ${ commit_after } Speed impact ------------ diff --git a/tools/impact/package.json b/tools/impact/package.json index 8bad388..261bfe6 100644 --- a/tools/impact/package.json +++ b/tools/impact/package.json @@ -1,8 +1,7 @@ { - "name": "impact", + "name": "@pegjs/commit-impact", "version": "2.1.0", "private": true, - "bin": "index.js", "dependencies": { "dedent": "0.7.0", "glob": "7.1.3" diff --git a/website/package.json b/website/package.json index 3defaf2..77ea8fd 100644 --- a/website/package.json +++ b/website/package.json @@ -1,5 +1,5 @@ { - "name": "pegjs-website", + "name": "@pegjs/website", "version": "1.3.0", "private": true, "dependencies": { diff --git a/website/server.js b/website/server.js index 8c1dbae..2770356 100644 --- a/website/server.js +++ b/website/server.js @@ -1,7 +1,7 @@ "use strict"; const bodyParser = require( "body-parser" ); -const bundle = require( "bundle" ); +const bundle = require( "@pegjs/bundle-generator" ); const express = require( "express" ); const layout = require( "express-layout" ); const logger = require( "morgan" );