-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPonfile.dev.js
210 lines (208 loc) · 6.07 KB
/
Ponfile.dev.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/**
* Pon tasks for development
* @file Ponfile
* @see https://github.com/realglobe-Inc/pon
*/
'use strict'
const pon = require('pon')
const {
command: {
spawn: { git, npm, npx },
},
fs: { del },
open,
} = require('pon-task-basic')
const changelog = require('pon-task-changelog')
const { eslint, fmtjson, mocha, pondoc } = require('pon-task-dev')
const docker = require('pon-task-docker')
const theCode = require('@the-/code/pon')
const icon = require('@the-/icon/pon')
const jsdoc = require('@the-/jsdoc/pon')
const theLint = require('@the-/lint/pon')
const theSpell = require('@the-/spell/pon')
const theSupport = require('@the-/support/pon')
const locales = require('./conf/locales')
const Containers = require('./misc/docker/Containers')
const Drawings = require('./misc/icon/Drawings')
const Rules = require('./misc/lint/Rules.json')
const PondocDev = require('./misc/project/Pondoc.dev.json')
const Words = require('./misc/spell/Words.json')
const { cwd, doc, tasks } = require('./Ponfile')
const { DockerPorts, WebApps } = require('./server/constants')
module.exports = pon(
/** Tasks of Ponfile.dev */
{
$cwd: cwd,
$dev: true,
$doc: { ...doc, ...PondocDev },
...tasks,
'analyze:ui': ['ui:*/analyze'],
'clean:cache': del(['tmp/cache/**/*.*', 'node_modules/.cache/**/*.*']),
/** Cleanup public files */
'clean:public': del(['public/build/*.*']),
/** Cleanup shim files */
'clean:shim': del(['shim/**/*.*', 'client/shim/**/*.*']),
'debug:server': [
'ps:debug',
'env:debug',
npx(
'nodemon',
'--config',
'misc/dev/Nodemon.json',
`--inspect=${WebApps.Default.INSPECT_PORT}`,
'bin/app.js',
),
],
/** Watch files for debug */
'debug:watch': ['env:debug', 'ui:*/watch'],
'doc:jsdoc': jsdoc(__dirname, 'doc/jsdoc', {
ignore: '**/shim/**/*.*',
jsonFile: 'jsdoc.json',
mdFile: 'jsdoc.md',
patterns: '+(conf|client|server)/**/*.js',
}),
/** Generate pondoc file */
'doc:pondoc': pondoc('Ponfile.js', 'misc/project/Pondoc.json'),
'doc:pondoc:dev': pondoc('Ponfile.dev.js', 'misc/project/Pondoc.dev.json'),
'docker:mysql': docker.mysql(
Containers.mysql.name,
Containers.mysql.options,
),
'eslint:check': eslint(__dirname, { ext: '.js,.bud,.jsx,.json' }),
'eslint:fix': eslint(__dirname, { ext: '.js,.bud,.jsx,.json', fix: true }),
'format:client': theCode(
[
'client/ui/**/*.pcss',
'client/ui/**/*.jsx',
'client/**/.*.bud',
'client/**/*.js',
],
{
ignore: ['client/**/index.*', 'client/shim/**/*.*'],
},
),
/** Format conf files */
'format:conf': theCode(
[
'*.yml',
'.*.yml',
'Ponfile.js',
'Ponfile.*.js',
'conf/*.js',
'conf/.*.bud',
'.*.bud',
],
{ ignore: 'conf/index.js' },
),
/** Format json files */
'format:json': fmtjson(
[
'conf/**/*.json',
'client/**/*.json',
'server/**/*.json',
'misc/**/*.json',
'secrets.json',
],
{ sort: true },
),
/** Format server files */
'format:misc': theCode(['misc/**/*.js', 'server/**/.*.bud'], {}),
'format:server': theCode(['server/**/*.js', 'server/**/.*.bud'], {}),
'git:changelog': [changelog(), git('add', 'CHANGELOG.md')],
'icon:gen': [
Drawings.appIcon && icon('assets/images/app-icon.png', Drawings.appIcon),
].filter(Boolean),
'lint:loc': () => locales.validate(),
/** Lint by rules */
'lint:rules': theLint(Rules),
/** Run spell check */
'lint:spell': theSpell(
['client/**/+(*.jsx|*.js)', 'server/**/*.js', 'conf/*.js'],
{
ignore: ['client/shim/**/*.*'],
words: Words,
},
),
'lint:types': npx('tsc'),
'open:app': open(`http://localhost:${DockerPorts.NGINX_CONTAINER_PORT}`),
/** Open homepage field in package.json */
'open:repo': npm('docs'),
'test:client': mocha('client/test/**/*.js', { timeout: 3000 }),
/** Run server tests */
'test:server': mocha('server/test/**/*.js', { timeout: 3000 }),
/** Check compatibility */
'test:support': theSupport('public/**/*.js'),
analyze: ['analyze:*'],
/** Build project */
build: [...tasks.build, 'format'],
c: 'clean',
/** Clean all */
clean: ['clean:shim', 'clean:public', 'clean:cache'],
/** Shortcut for `debug` task */
d: 'debug',
/** Start debugging */
debug: ['ps:debug', 'env:debug', 'build', 'debug:*'],
/** Deploy project on development */
deploy: [
'maint:on',
'stop',
'git:catchup',
'pkg:install',
'b',
'db:seed',
'db:migrate',
'start',
'maint:off',
],
/** Docker tasks */
docker: ['docker:redis/run', 'docker:mysql/run', 'docker:nginx/run'],
/** Shortcut for `debug:server` task */
ds: 'debug:server',
eslint: ['eslint:fix', 'eslint:check'],
/** Shortcut for `format` task */
f: 'format',
/** Format source codes */
format: [
'format:conf',
'format:json',
'format:client',
'format:server',
'format:misc',
],
/** Shortcut for `lint` task */
l: 'lint',
/** Apply lint */
lint: ['lint:loc', 'lint:rules', 'eslint', 'lint:spell', 'lint:types'],
/** Shortcut for `open` task */
o: 'open',
/** Open project */
open: 'open:app',
/** Shortcut for `open` task */
or: 'open:repo',
/** Prepare project */
prepare: [
...tasks.prepare,
'format',
'pkg:fix',
'doc',
'test:support',
'analyze',
],
/** Start server */
start: ['debug:server'],
/** Stop server */
stop: [],
/** Shortcut for `test` task */
t: 'test',
/** Run all tess */
test: ['env:test', 'test:support', 'test:client', 'test:server'],
/** Shortcut for `upgrade` task */
u: 'upgrade',
/** Upgrade package */
upgrade: ['pkg:upg', 'pkg:install:force', 'pkg:link', 'build'],
/** Shortcut for `watch` task */
w: 'watch',
/** Run watches */
watch: ['ui:*', 'ui:*/watch'],
},
)