auto-update get-product-name
This commit is contained in:
parent
96588d0690
commit
b379c5ba41
5 changed files with 105 additions and 5 deletions
|
@ -68,7 +68,7 @@ PORT=80
|
|||
|
||||
## Startup
|
||||
```sh
|
||||
yarn start
|
||||
npm start
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
|
40
manager.js
Normal file
40
manager.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
const { exec } = require('child-process-promise')
|
||||
const { spawn } = require('child_process')
|
||||
|
||||
const PACKAGENAME = 'get-product-name'
|
||||
|
||||
async function isOutdated() {
|
||||
const command = `npm outdated ${PACKAGENAME} --json`
|
||||
const npm = await exec(command)
|
||||
const data = JSON.parse(npm.stdout)
|
||||
return data[PACKAGENAME]?.current !== data[PACKAGENAME]?.wanted
|
||||
}
|
||||
|
||||
async function updateGPD() {
|
||||
const command = `npm update ${PACKAGENAME}`
|
||||
await exec(command)
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
let cc = null
|
||||
function spawnCC() {
|
||||
cc = spawn('node', [ 'index.js' ], { env: process.env })
|
||||
cc.on('exit', spawnCC)
|
||||
cc.stdout.pipe(process.stdout)
|
||||
cc.stderr.pipe(process.stderr)
|
||||
}
|
||||
|
||||
if (process.env.UPDATE_GPD !== 'false') {
|
||||
async function update() {
|
||||
if (await isOutdated()) {
|
||||
await updateGPD()
|
||||
if (cc) cc.kill('sigint')
|
||||
cc.once('exit', () => console.log(`Updated ${PACKAGENAME}`))
|
||||
}
|
||||
}
|
||||
update()
|
||||
setInterval(update, 1000 * 60 * 60) // 1 hour
|
||||
}
|
||||
|
||||
spawnCC()
|
||||
})()
|
|
@ -6,7 +6,7 @@
|
|||
"scripts": {
|
||||
"postinstall": "cp patched-express-response.js node_modules/express/lib/response.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node index.js"
|
||||
"start": "node manager.js"
|
||||
},
|
||||
"author": "Wingysam <wingysam+git@gmail.com>",
|
||||
"license": "AGPL-3.0",
|
||||
|
@ -18,12 +18,13 @@
|
|||
"bcrypt-nodejs": "^0.0.3",
|
||||
"body-parser": "^1.18.3",
|
||||
"chalk": "^4.1.0",
|
||||
"child-process-promise": "^2.2.1",
|
||||
"connect-flash": "^0.1.1",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "4.17.1",
|
||||
"express-session": "^1.15.6",
|
||||
"express-session-level": "^1.0.0",
|
||||
"get-product-name": "^1.5.0",
|
||||
"get-product-name": "1",
|
||||
"level": "^6.0.0",
|
||||
"moment": "^2.29.1",
|
||||
"nanoid": "^3.1.16",
|
||||
|
|
|
@ -23,4 +23,6 @@ block content
|
|||
input.button.is-primary(type='submit' value='Add User')
|
||||
h3 Version Info
|
||||
p Christmas Community: v#{_CC.require('./package.json').version}
|
||||
p Get Product Data: v#{_CC.require('get-product-name/package.json').version}
|
||||
p Node: #{process.version}
|
||||
p PID: #{process.pid}
|
59
yarn.lock
59
yarn.lock
|
@ -215,6 +215,15 @@
|
|||
"lodash" "^4.15.0"
|
||||
"parse5" "^3.0.1"
|
||||
|
||||
"child-process-promise@^2.2.1":
|
||||
"integrity" "sha1-RzChHvYQ+tRQuPIjx50x172tgHQ="
|
||||
"resolved" "https://registry.npmjs.org/child-process-promise/-/child-process-promise-2.2.1.tgz"
|
||||
"version" "2.2.1"
|
||||
dependencies:
|
||||
"cross-spawn" "^4.0.2"
|
||||
"node-version" "^1.0.0"
|
||||
"promise-polyfill" "^6.0.1"
|
||||
|
||||
"clone-buffer@1.0.0":
|
||||
"integrity" "sha1-4+JbIHrE5wGvch4staFnksrD3Fg="
|
||||
"resolved" "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz"
|
||||
|
@ -272,6 +281,14 @@
|
|||
"resolved" "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
|
||||
"version" "1.0.2"
|
||||
|
||||
"cross-spawn@^4.0.2":
|
||||
"integrity" "sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE="
|
||||
"resolved" "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz"
|
||||
"version" "4.0.2"
|
||||
dependencies:
|
||||
"lru-cache" "^4.0.1"
|
||||
"which" "^1.2.9"
|
||||
|
||||
"css-select@~1.2.0":
|
||||
"integrity" "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg="
|
||||
"resolved" "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz"
|
||||
|
@ -542,7 +559,7 @@
|
|||
"resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"
|
||||
"version" "1.1.1"
|
||||
|
||||
"get-product-name@^1.5.0":
|
||||
"get-product-name@^1.0.0":
|
||||
"integrity" "sha512-8obi2ibxRgrL3JRMkMdTPYUt88OMlYwXJqlsP6OnAD8barlrUwf1D4xft7prfcAbVIdES/M/zAfW3BF2uP1lwA=="
|
||||
"resolved" "https://registry.npmjs.org/get-product-name/-/get-product-name-1.6.0.tgz"
|
||||
"version" "1.6.0"
|
||||
|
@ -668,6 +685,11 @@
|
|||
"resolved" "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz"
|
||||
"version" "0.0.1"
|
||||
|
||||
"isexe@^2.0.0":
|
||||
"integrity" "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
|
||||
"resolved" "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
|
||||
"version" "2.0.0"
|
||||
|
||||
"js-stringify@^1.0.2":
|
||||
"integrity" "sha1-Fzb939lyTyijaCrcYjCufk6Weds="
|
||||
"resolved" "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz"
|
||||
|
@ -832,6 +854,14 @@
|
|||
"resolved" "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz"
|
||||
"version" "4.17.20"
|
||||
|
||||
"lru-cache@^4.0.1":
|
||||
"integrity" "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g=="
|
||||
"resolved" "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz"
|
||||
"version" "4.1.5"
|
||||
dependencies:
|
||||
"pseudomap" "^1.0.2"
|
||||
"yallist" "^2.1.2"
|
||||
|
||||
"ltgt@^2.1.2", "ltgt@2.2.1":
|
||||
"integrity" "sha1-81ypHEk/e3PaDgdJUwTxezH4fuU="
|
||||
"resolved" "https://registry.npmjs.org/ltgt/-/ltgt-2.2.1.tgz"
|
||||
|
@ -924,6 +954,11 @@
|
|||
"resolved" "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.1.1.tgz"
|
||||
"version" "4.1.1"
|
||||
|
||||
"node-version@^1.0.0":
|
||||
"integrity" "sha512-ma6oU4Sk0qOoKEAymVoTvk8EdXEobdS7m/mAGhDJ8Rouugho48crHBORAmy5BoOcv8wraPM6xumapQp5hl4iIQ=="
|
||||
"resolved" "https://registry.npmjs.org/node-version/-/node-version-1.2.0.tgz"
|
||||
"version" "1.2.0"
|
||||
|
||||
"nth-check@~1.0.1":
|
||||
"integrity" "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg=="
|
||||
"resolved" "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz"
|
||||
|
@ -1026,6 +1061,11 @@
|
|||
"resolved" "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz"
|
||||
"version" "1.0.7"
|
||||
|
||||
"promise-polyfill@^6.0.1":
|
||||
"integrity" "sha1-36lpQ+qcEh/KTem1hoyznTRy4Fc="
|
||||
"resolved" "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-6.1.0.tgz"
|
||||
"version" "6.1.0"
|
||||
|
||||
"promise@^7.0.1":
|
||||
"integrity" "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg=="
|
||||
"resolved" "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz"
|
||||
|
@ -1051,6 +1091,11 @@
|
|||
"resolved" "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz"
|
||||
"version" "1.0.1"
|
||||
|
||||
"pseudomap@^1.0.2":
|
||||
"integrity" "sha1-8FKijacOYYkX7wqKw0wa5aaChrM="
|
||||
"resolved" "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz"
|
||||
"version" "1.0.2"
|
||||
|
||||
"psl@^1.1.33":
|
||||
"integrity" "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ=="
|
||||
"resolved" "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz"
|
||||
|
@ -1432,6 +1477,13 @@
|
|||
"resolved" "https://registry.npmjs.org/vuvuzela/-/vuvuzela-1.0.3.tgz"
|
||||
"version" "1.0.3"
|
||||
|
||||
"which@^1.2.9":
|
||||
"integrity" "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ=="
|
||||
"resolved" "https://registry.npmjs.org/which/-/which-1.3.1.tgz"
|
||||
"version" "1.3.1"
|
||||
dependencies:
|
||||
"isexe" "^2.0.0"
|
||||
|
||||
"with@^7.0.0":
|
||||
"integrity" "sha512-RNGKj82nUPg3g5ygxkQl0R937xLyho1J24ItRCBTr/m1YnZkzJy1hUiHUJrc/VlsDQzsCnInEGSg3bci0Lmd4w=="
|
||||
"resolved" "https://registry.npmjs.org/with/-/with-7.0.2.tgz"
|
||||
|
@ -1464,6 +1516,11 @@
|
|||
"resolved" "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz"
|
||||
"version" "3.0.0"
|
||||
|
||||
"yallist@^2.1.2":
|
||||
"integrity" "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI="
|
||||
"resolved" "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz"
|
||||
"version" "2.1.2"
|
||||
|
||||
"yes-no@^0.0.1":
|
||||
"integrity" "sha1-yFnZu8ZVfZnE2GdrYamSgM7tbuE="
|
||||
"resolved" "https://registry.npmjs.org/yes-no/-/yes-no-0.0.1.tgz"
|
||||
|
|
Loading…
Reference in a new issue