Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Update scripts for release (fixes #475) #478

Merged
merged 3 commits into from Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install dependencies
run: npm install
- name: Build commonjs
run: npm run rollup
run: npm run build
- name: Lint files
run: npm run lint
test:
Expand All @@ -46,7 +46,7 @@ jobs:
run: npm install --legacy-peer-deps
if: ${{ startswith(matrix.node, '15') }}
- name: Build commonjs
run: npm run rollup
run: npm run build
- name: Run tests
run: npm run unit
testNode10:
Expand All @@ -64,6 +64,6 @@ jobs:
- name: Install dependencies
run: npm install
- name: Build commonjs
run: npm run rollup
run: npm run build
- name: Run tests
run: npm run unit:cjs
2 changes: 1 addition & 1 deletion lib/version.js
@@ -1,3 +1,3 @@
const version = "7.3.1";
const version = "main";

export default version;
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -74,7 +74,10 @@
"test": "npm-run-all -p unit lint",
"lint": "eslint \"*.?(c)js\" lib/ tests/lib/",
"fixlint": "npm run lint -- --fix",
"rollup": "rollup -c rollup.config.js",
"build": "rollup -c rollup.config.js",
Copy link
Member

Choose a reason for hiding this comment

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

We should update ci.yml, it uses npm run rollup.

"update-version": "node tools/update-version.js",
"pretest": "npm run build",
"prepublishOnly": "npm run update-version && npm run build",
"sync-docs": "node sync-docs.js",
"generate-release": "eslint-generate-release",
"generate-alpharelease": "eslint-generate-prerelease alpha",
Expand Down
9 changes: 0 additions & 9 deletions rollup.config.js
@@ -1,15 +1,6 @@
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import json from "@rollup/plugin-json";
import fs from "fs";


// the espree package version is exported from the module (i.e., import { version } from "espree")
// read version from the package.json metadata and write it into lib/version.js at build time,
// since esm cannot import json by default
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"));

fs.writeFileSync("lib/version.js", `const version = "${pkg.version}";\n\nexport default version;\n`);

export default {
input: "espree.js",
Expand Down
17 changes: 17 additions & 0 deletions tools/update-version.js
@@ -0,0 +1,17 @@
/**
* @fileoverview Script to update lib/version.js to the value in package.json
* @author Nicholas C. Zakas
*/

import fs from "fs";

/*
* IMPORTANT: This must be run *before* Rollup so the built package will have
* the correct version number exported.
*
* This is necessary because ESM can't import JSON files directly and we want
* this value to be available in the browser as well as in Node.js.
*/

const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"));
fs.writeFileSync("lib/version.js", `const version = "${pkg.version}";\n\nexport default version;\n`);