Skip to content

Commit

Permalink
Improve Gruntfile.js docs and ESM testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ronyeh committed Jan 18, 2022
1 parent 81f6ac0 commit cf87a62
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 30 deletions.
54 changes: 29 additions & 25 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/************************************************************************************************************
QUICK START
grunt
- Build the complete set of VexFlow libraries (with source-maps) for production and debug use.
This is the 'default' grunt task.
Expand All @@ -13,39 +15,21 @@ grunt reference
*************************************************************************************************************
DEVELOPMENT
DEVELOP
grunt watch
- The fastest way to iterate while working on VexFlow.
Watch for changes and produces the debug CJS libraries in build/cjs/.
grunt watch:prod
- Watch for changes and builds the production libraries. This can be slow!
- FAST: Watch for changes and produces the debug CJS libraries in build/cjs/.
grunt watch:esm
- Watch for changes and build the ESM libraries in build/esm/.
- FAST: Watch for changes and build the ESM libraries in build/esm/.
- Also see `grunt test:browser:esm` below.
*************************************************************************************************************
RELEASE A NEW VERSION
To automatically release to GitHub, you need to have a personal access token with "repo" rights.
Generate one here: https://github.com/settings/tokens/new?scopes=repo&description=release-it
Also, make sure your authenticator app is ready to generate a 2FA one time password for npm.
grunt && npm pack
- Create a *.tgz that can be emailed to a friend or uploaded to a test server.
npm install from the *.tgz file or test server URL to verify your project works with this build of VexFlow.
grunt release
- Run the release script to build, commit, and publish to npm and GitHub.
This assumes you have fully tested the build.
grunt watch:prod
- SLOW: Watch for changes and builds the production libraries.
*************************************************************************************************************
TESTING
TEST
grunt test:cmd
- Run the QUnit command line tests with 'tests/flow-headless-browser.html'.
Expand All @@ -69,6 +53,23 @@ Search this file for `// grunt` to see other supported grunt tasks.
*************************************************************************************************************
RELEASE
To automatically release to GitHub, you need to have a personal access token with "repo" rights.
Generate one here: https://github.com/settings/tokens/new?scopes=repo&description=release-it
Also, make sure your authenticator app is ready to generate a 2FA one time password for npm.
grunt && npm pack
- Create a *.tgz that can be emailed to a friend or uploaded to a test server.
npm install from the *.tgz file or test server URL to verify your project works with this build of VexFlow.
grunt release
- Run the release script to build, commit, and publish to npm and GitHub.
This assumes you have fully tested the build.
*************************************************************************************************************
ENVIRONMENT VARIABLES (optional):
VEX_DEBUG_CIRCULAR_DEPENDENCIES
Expand Down Expand Up @@ -481,7 +482,10 @@ module.exports = (grunt) => {
watch.on('started', () => {
console.log('Press CTRL + C to quit.');
});
watch.on('success', fixESM);
watch.on('success', () => {
versionInfo.update();
fixESM();
});
watch.start('-p', 'tsconfig.esm.json', '--noClear');
} else {
runCommand('tsc', '-p', 'tsconfig.esm.json');
Expand Down
1 change: 0 additions & 1 deletion src/bend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Element } from './element';
import { FontInfo } from './font';
import { Modifier } from './modifier';
import { ModifierContextState } from './modifiercontext';
import { Stave } from './stave';
import { Tables } from './tables';
import { TabNote } from './tabnote';
import { RuntimeError } from './util';
Expand Down
17 changes: 13 additions & 4 deletions tools/version_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ const path = require('path');
const fs = require('fs');
const { execSync } = require('child_process');

const PACKAGE_JSON = JSON.parse(fs.readFileSync('package.json'));
const VEXFLOW_VERSION = PACKAGE_JSON.version;
const GIT_COMMIT_ID = execSync('git rev-parse HEAD').toString().trim();
const DATE = new Date().toISOString();
let VEXFLOW_VERSION;
let GIT_COMMIT_ID;
let DATE;

function updateInfo() {
VEXFLOW_VERSION = JSON.parse(fs.readFileSync('package.json')).version;
GIT_COMMIT_ID = execSync('git rev-parse HEAD').toString().trim();
DATE = new Date().toISOString();
}

updateInfo();

module.exports = {
VERSION: VEXFLOW_VERSION,
Expand All @@ -24,4 +31,6 @@ module.exports = {
const D = `export const DATE = '${DATE}';`;
fs.writeFileSync(outputFile, `${V}\n${I}\n${D}`);
},

update: updateInfo,
};

0 comments on commit cf87a62

Please sign in to comment.