diff --git a/.gitignore b/.gitignore index f276a6cbd..f74edbed1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules dist lib +src/versionInfo.ts .idea diff --git a/package.json b/package.json index c05683706..36acc1abf 100644 --- a/package.json +++ b/package.json @@ -9,15 +9,17 @@ "dist" ], "scripts": { - "build": "npm run build-lib && npm run build-types", + "build": "npm run clean && npm run build-version && npm run build-lib && npm run build-types", "build-lib": "babel src -d lib --source-maps --extensions '.ts,.js'", "build-types": "tsc --emitDeclarationOnly", - "postversion": "git push origin master --follow-tags", - "prepublishOnly": "npm run build", + "build-version": "./timestamp.sh > src/versionInfo.ts && eslint 'src/versionInfo.ts' --fix", + "watch": "npm run build-version && babel src --out-dir lib --watch --source-maps --extensions '.ts,.js'", + "clean": "rm -rf lib", "lint": "eslint 'src/**/*.js' 'src/**/*.ts'", "lint-fix": "eslint 'src/**/*.js' 'src/**/*.ts' --fix", "test": "npm run lint", - "watch": "babel src --out-dir lib --watch --source-maps --extensions '.ts,.js'" + "prepublishOnly": "npm test && npm run build", + "postpublish": "git push origin master --follow-tags" }, "repository": { "type": "git", @@ -71,7 +73,8 @@ }, "husky": { "hooks": { - "pre-commit": "lint-staged" + "pre-commit": "lint-staged", + "pre-push": "npm test" } }, "lint-staged": { diff --git a/src/index.ts b/src/index.ts index 09cda98ce..9ccad1231 100755 --- a/src/index.ts +++ b/src/index.ts @@ -75,6 +75,7 @@ import tabs from './tabs' // @ts-ignore import utils from './utils' import widgets from './widgets' +import versionInfo from './versionInfo' const dom = window ? window.document : null // Idea that UI.dom can be adapted in non-browser environments @@ -100,7 +101,8 @@ if (typeof window !== 'undefined') { table, tabs, utils, - widgets + widgets, + versionInfo } // Simpler access by non-node scripts } @@ -125,5 +127,6 @@ export { table, tabs, utils, - widgets + widgets, + versionInfo } diff --git a/timestamp.sh b/timestamp.sh new file mode 100755 index 000000000..408b864c1 --- /dev/null +++ b/timestamp.sh @@ -0,0 +1,7 @@ +# Timestamp a git/npm project in node JS +echo "export default {" +date -u '+buildTime: "%Y-%m-%dT%H:%M:%SZ",' +git log | grep commit | head -1 | sed -e 's/ /: "/' | sed -e 's/$/",/' +echo npmInfo: +npm version +echo "};"