dynamically create package.json for deployment

This commit is contained in:
HF 2020-01-05 20:47:59 +01:00
parent 7d7839679f
commit a8987604f3
5 changed files with 41 additions and 42 deletions

38
package-lock.json generated
View File

@ -4855,12 +4855,6 @@
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
},
"eventemitter3": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz",
"integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==",
"dev": true
},
"events": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/events/-/events-3.0.0.tgz",
@ -5375,15 +5369,6 @@
"readable-stream": "^2.3.6"
}
},
"follow-redirects": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.9.0.tgz",
"integrity": "sha512-CRcPzsSIbXyVDl0QI01muNDu69S8trU4jArW9LpOt2WtC6LyUJetcIrmfHsRBx7/Jb6GHJUiuqyYxPooFfNt6A==",
"dev": true,
"requires": {
"debug": "^3.0.0"
}
},
"for-in": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
@ -6086,6 +6071,12 @@
"is-property": "^1.0.2"
}
},
"generate-package-json-webpack-plugin": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/generate-package-json-webpack-plugin/-/generate-package-json-webpack-plugin-1.0.1.tgz",
"integrity": "sha512-UYAnqJbxsoRhH9VqP0RbME2RHzG6SdCAoRqPpPeKcWHMmyWW0J1R0/tWjj3HmXvf+KcRy0QksIq2u8ir0YDV7Q==",
"dev": true
},
"get-caller-file": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",
@ -6495,17 +6486,6 @@
}
}
},
"http-proxy": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.0.tgz",
"integrity": "sha512-84I2iJM/n1d4Hdgc6y2+qY5mDaz2PUVjlg9znE9byl+q0uC3DeByqBGReQu5tpLK0TAqTIXScRUV+dg7+bUPpQ==",
"dev": true,
"requires": {
"eventemitter3": "^4.0.0",
"follow-redirects": "^1.0.0",
"requires-port": "^1.0.0"
}
},
"http-proxy-agent": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-3.0.0.tgz",
@ -9932,12 +9912,6 @@
"integrity": "sha1-wR6XJ2tluOKSP3Xav1+y7ww4Qbk=",
"dev": true
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=",
"dev": true
},
"resolve": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.14.1.tgz",

View File

@ -123,7 +123,7 @@
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.0.1",
"flow-bin": "^0.115.0",
"http-proxy": "^1.16.2",
"generate-package-json-webpack-plugin": "^1.0.1",
"json-loader": "^0.5.4",
"npm-check": "^5.9.0",
"react-hot-loader": "^4.12.14",

View File

@ -12,16 +12,9 @@ import pkg from '../package.json';
async function copy() {
await makeDir('build');
await Promise.all([
writeFile('build/package.json', JSON.stringify({
private: true,
engines: pkg.engines,
dependencies: pkg.dependencies,
scripts: {
start: 'node --nouse-idle-notification --expose-gc web.js',
},
}, null, 2)),
copyFile('LICENSE', 'build/LICENSE'),
copyDir('public', 'build/public'),
copyFile('tools/example-ecosystem.yml', 'build/ecosystem.example.yml'),
]);
}

View File

@ -0,0 +1,14 @@
apps:
- script : ./web.js
name : 'web'
node_args: --nouse-idle-notification --expose-gc
env:
HOSTURL: "http://localhost"
ASSET_SERVER: "http://localhost"
PORT: 80
REDIS_URL: 'redis://localhost:6379'
MYSQL_HOST: "localhost"
MYSQL_USER: "pixelplanet"
MYSQL_DATABASE: "pixelplanet"
MYSQL_PW: "sqlpassword"
SESSION_SECRET: "ayyylmao"

View File

@ -5,12 +5,27 @@ import path from 'path';
import webpack from 'webpack';
import AssetsPlugin from 'assets-webpack-plugin';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import GeneratePackageJsonPlugin from 'generate-package-json-webpack-plugin';
import pkg from '../package.json';
const isDebug = process.argv.includes('--debug');
const isVerbose = process.argv.includes('--verbose');
const isAnalyze = process.argv.includes('--analyze') || process.argv.includes('--analyse');
const basePackageValues = {
name: pkg.name,
version: pkg.version,
private: true,
engines: pkg.engines,
scripts: {
start: 'node --nouse-idle-notification --expose-gc web.js',
},
dependencies: {
"mysql2": "^2.1.0",
}
}
const versionsPackageFilename = path.resolve(__dirname, '../package.json');
const config = {
context: path.resolve(__dirname, '..'),
@ -288,7 +303,8 @@ const webConfig = {
output: {
...config.output,
filename: '../../web.js',
path: path.resolve(__dirname, '../build'),
filename: './web.js',
libraryTarget: 'commonjs2',
},
@ -331,6 +347,8 @@ const webConfig = {
'process.env.BROWSER': false,
__DEV__: isDebug,
}),
// create package.json for deployment
new GeneratePackageJsonPlugin(basePackageValues, versionsPackageFilename),
],
node: {