@s-ui/bundler 9.39.0-typescript.102 → 9.39.0-typescript.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/scripts/postinstall.js +44 -0
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s-ui/bundler",
|
|
3
|
-
"version": "9.39.0-typescript.
|
|
3
|
+
"version": "9.39.0-typescript.104",
|
|
4
4
|
"description": "Config-free bundler for ES6 React apps.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sui-bundler": "./bin/sui-bundler.js"
|
|
7
7
|
},
|
|
8
8
|
"main": "./bin/sui-bundler.js",
|
|
9
9
|
"scripts": {
|
|
10
|
+
"postinstall": "./scripts/postinstall.js",
|
|
10
11
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
12
|
},
|
|
12
13
|
"keywords": [],
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const crypto = require('crypto')
|
|
4
|
+
const fs = require('fs-extra')
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const {writeFile} = require('@s-ui/helpers/file.js')
|
|
7
|
+
|
|
8
|
+
const tsConfigTemplate = `\
|
|
9
|
+
{
|
|
10
|
+
"extends": "@s-ui/bundler/tsconfig.json",
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
"rootDir": "./components"
|
|
13
|
+
},
|
|
14
|
+
"include": ["**/*"]
|
|
15
|
+
}`
|
|
16
|
+
|
|
17
|
+
const md5 = str => crypto.createHash('md5').update(str).digest('hex')
|
|
18
|
+
const TS_CONFIG_PATH = path.join(process.cwd(), 'tsconfig.json')
|
|
19
|
+
|
|
20
|
+
const shouldGenerateTSConfig = () => {
|
|
21
|
+
try {
|
|
22
|
+
if (!fs.existsSync(TS_CONFIG_PATH)) return true
|
|
23
|
+
|
|
24
|
+
const tsConfigLocal = fs.readFileSync(TS_CONFIG_PATH, {encoding: 'utf8'})
|
|
25
|
+
return md5(tsConfigLocal) !== md5(tsConfigTemplate)
|
|
26
|
+
} catch (err) {
|
|
27
|
+
return true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function main() {
|
|
32
|
+
console.log(
|
|
33
|
+
'🔍 [sui-bundler postinstall] Checking if tsconfig.json is up to date...'
|
|
34
|
+
)
|
|
35
|
+
if (!shouldGenerateTSConfig()) {
|
|
36
|
+
console.log('✅ [sui-bundler postinstall] tsconfig.json is up to date')
|
|
37
|
+
process.exit(0)
|
|
38
|
+
}
|
|
39
|
+
await writeFile(TS_CONFIG_PATH, tsConfigTemplate)
|
|
40
|
+
console.log(
|
|
41
|
+
'❌ [sui-bundler postinstall] tsconfig.json was not up to date, so we updated it'
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
main()
|