cli/lib/demo-config.js

93 lines
1.4 KiB
JavaScript

/**
* {}
* @author yutent<yutent.io@gmail.com>
* @date 2022/10/10 16:49:07
*/
import fs from 'iofs'
export function writePackageJson(file, name) {
fs.echo(
JSON.stringify(
{
name: name || 'gm5-app',
type: 'module',
main: 'app.js',
dependencies: {
'@gm5/core': '^1.1.4'
}
},
null,
2
),
file
)
}
export function writeGitIgnore(file) {
fs.echo(
`
*.sublime-project
*.sublime-workspace
node_modules
package-lock.json
data/logs
public/upload/
._*
.idea
.vscode
.Spotlight-V100
.Trashes
.DS_Store
.AppleDouble
.LSOverride
`,
file
)
}
export function writePrettierrc(file) {
fs.echo(
`
jsxBracketSameLine: true
jsxSingleQuote: true
semi: false
singleQuote: true
printWidth: 100
useTabs: false
tabWidth: 2
trailingComma: none
bracketSpacing: true
arrowParens: avoid
`,
file
)
}
export function writePm2File(file, { env = 'production', name = 'gm5-app', cluster = true }) {
fs.echo(
`
script: node --experimental-json-modules ./app.js
cwd: ./
watch: true
name: ${name}
ignore_watch: [data, public, package.json, package-lock.json, node_modules, .git, .gitignore, app.yaml]
exec_mode: ${cluster ? 'cluster' : 'fork'}
${cluster ? 'instances: max' : ''}
error_file: ./data/logs/error.log
out_file: ./data/logs/out.log
merge_logs: true
min_uptime: 60s
max_restarts: 1
max_memory_restart: 300M
env:
NODE_ENV: ${env}
`,
file
)
}
Five.js框架控制台工具
JavaScript 100%