Skip to content

Commit 29587d3

Browse files
authored
Merge pull request #164 from solid/standardize-scripts
Adding versionInfo + standardizing scripts
2 parents 0bf5a45 + 1ab0640 commit 29587d3

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
dist
33
lib
4+
src/versionInfo.ts
45
.idea

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99
"dist"
1010
],
1111
"scripts": {
12-
"build": "npm run build-lib && npm run build-types",
12+
"build": "npm run clean && npm run build-version && npm run build-lib && npm run build-types",
1313
"build-lib": "babel src -d lib --source-maps --extensions '.ts,.js'",
1414
"build-types": "tsc --emitDeclarationOnly",
15-
"postversion": "git push origin master --follow-tags",
16-
"prepublishOnly": "npm run build",
15+
"build-version": "./timestamp.sh > src/versionInfo.ts && eslint 'src/versionInfo.ts' --fix",
16+
"watch": "npm run build-version && babel src --out-dir lib --watch --source-maps --extensions '.ts,.js'",
17+
"clean": "rm -rf lib",
1718
"lint": "eslint 'src/**/*.js' 'src/**/*.ts'",
1819
"lint-fix": "eslint 'src/**/*.js' 'src/**/*.ts' --fix",
1920
"test": "npm run lint",
20-
"watch": "babel src --out-dir lib --watch --source-maps --extensions '.ts,.js'"
21+
"prepublishOnly": "npm test && npm run build",
22+
"postpublish": "git push origin master --follow-tags"
2123
},
2224
"repository": {
2325
"type": "git",
@@ -71,7 +73,8 @@
7173
},
7274
"husky": {
7375
"hooks": {
74-
"pre-commit": "lint-staged"
76+
"pre-commit": "lint-staged",
77+
"pre-push": "npm test"
7578
}
7679
},
7780
"lint-staged": {

src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import tabs from './tabs'
7575
// @ts-ignore
7676
import utils from './utils'
7777
import widgets from './widgets'
78+
import versionInfo from './versionInfo'
7879

7980
const dom = window ? window.document : null // Idea that UI.dom can be adapted in non-browser environments
8081

@@ -100,7 +101,8 @@ if (typeof window !== 'undefined') {
100101
table,
101102
tabs,
102103
utils,
103-
widgets
104+
widgets,
105+
versionInfo
104106
} // Simpler access by non-node scripts
105107
}
106108

@@ -125,5 +127,6 @@ export {
125127
table,
126128
tabs,
127129
utils,
128-
widgets
130+
widgets,
131+
versionInfo
129132
}

timestamp.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Timestamp a git/npm project in node JS
2+
echo "export default {"
3+
date -u '+buildTime: "%Y-%m-%dT%H:%M:%SZ",'
4+
git log | grep commit | head -1 | sed -e 's/ /: "/' | sed -e 's/$/",/'
5+
echo npmInfo:
6+
npm version
7+
echo "};"

0 commit comments

Comments
 (0)