Skip to content

Commit

Permalink
Fixes peggyjs#72. Use correct version information and correct URL in …
Browse files Browse the repository at this point in the history
…generated code
  • Loading branch information
hildjj committed Apr 19, 2021
1 parent 33b7dd9 commit b3e957e
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 213 deletions.
18 changes: 14 additions & 4 deletions docs/js/benchmark-bundle.min.js

Large diffs are not rendered by default.

387 changes: 199 additions & 188 deletions docs/js/test-bundle.min.js

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions docs/vendor/peggy/peggy.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions lib/compiler/passes/generate-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const asts = require("../asts");
const js = require("../js");
const op = require("../opcodes");
const VERSION = require('../../version')

// Generates parser JavaScript code.
function generateJS(ast, options) {
Expand Down Expand Up @@ -1203,9 +1204,9 @@ function generateJS(ast, options) {
function generateWrapper(toplevelCode) {
function generateGeneratedByComment() {
return [
"// Generated by Peggy 0.11.0.",
`// Generated by Peggy ${VERSION}.`,
"//",
"// https://github.com/peggyjs/peggy"
"// https://peggyjs.org/"
].join("\n");
}

Expand Down
4 changes: 2 additions & 2 deletions lib/parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/peg.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
const GrammarError = require("./grammar-error");
const compiler = require("./compiler");
const parser = require("./parser");
const VERSION = require("./version");

const peg = {
// Peggy version (filled in by /tools/release).
VERSION: "1.0.0",
VERSION,
GrammarError: GrammarError,
parser: parser,
compiler: compiler,
Expand Down
3 changes: 3 additions & 0 deletions lib/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = "1.0.0";
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"prebrowser:build": "npm run parser",
"browser:build": "browserify lib/peg.js -s peggy -o browser/peggy.min.js",
"postbrowser:build": "tools/header browser/* && cp browser/peggy.min.js docs/vendor/peggy/peggy.min.js",
"benchmark:build": "browserify benchmark/browser.stub.js -o docs/js/benchmark-bundle.min.js",
"test:build": "browserify test/browser.stub.js -o docs/js/test-bundle.min.js",
"benchmark:build": "browserify benchmark/browser.stub.js -o docs/js/benchmark-bundle.min.js && tools/header docs/js/benchmark-bundle.min.js",
"test:build": "browserify test/browser.stub.js -o docs/js/test-bundle.min.js && tools/header docs/js/test-bundle.min.js",
"parser": "bin/peggy -o lib/parser.js --format commonjs src/parser.pegjs"
},
"devDependencies": {
Expand Down Expand Up @@ -68,4 +68,4 @@
]
]
}
}
}
6 changes: 3 additions & 3 deletions tools/header
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// Pass list of files on command line.

const fs = require("fs");
const pkg = require("../package.json");
const version = require("../lib/version.js");

const header = `\
// peggy ${pkg.version}
// peggy ${version}
//
// https://github.com/peggyjs/peggy
// https://peggyjs.org/
//
// Copyright (c) ${new Date().getFullYear()}- the Peggy authors
// Licensed under the MIT License.
Expand Down
12 changes: 7 additions & 5 deletions tools/release
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ async function main() {
await fs.writeFile(pkg, JSON.stringify(pjson, null, 2));

// update VERSION in lib/peg.js
const pn = path.join(root, "lib", "peg.js");
let pegTxt = await fs.readFile(pn, "utf8");
pegTxt = pegTxt.replace(/^(\s+)VERSION: "[^"]*",$/m, `$1VERSION: "${VERSION}",`);
await fs.writeFile(pn, pegTxt);
const vjs = path.join(root, 'lib', 'version.js');
await fs.writeFile(vjs, `\
"use strict";
module.exports = "${VERSION}";
`)

// build
await e("npm run build");
Expand All @@ -70,7 +72,7 @@ async function main() {
await e("npm run test:node");

// add files
await e(`git add ${pkg} ${pn} docs/js/benchmark-bundle.min.js docs/js/test-bundle.min.js docs/vendor/peggy/peggy.min.js`);
await e(`git add ${pkg} ${vjs} docs/js/benchmark-bundle.min.js docs/js/test-bundle.min.js docs/vendor/peggy/peggy.min.js`);

// check in
await e(`git commit -m "Update for v${VERSION}"`);
Expand Down

1 comment on commit b3e957e

@hildjj
Copy link
Owner Author

@hildjj hildjj commented on b3e957e Apr 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leaves @StoneCypher's offer of something standard to replace the VERSION file as a TODO.

Please sign in to comment.