nsgm-cli 2.0.11 → 2.0.14

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.
Files changed (65) hide show
  1. package/.babelrc +12 -12
  2. package/LICENSE +201 -201
  3. package/README.md +161 -161
  4. package/client/layout/index.tsx +248 -248
  5. package/client/redux/reducers.ts +4 -4
  6. package/client/redux/store.ts +50 -50
  7. package/client/redux/template/manage/actions.ts +190 -190
  8. package/client/redux/template/manage/reducers.ts +118 -118
  9. package/client/redux/template/manage/types.ts +24 -24
  10. package/client/service/template/manage.ts +96 -96
  11. package/client/styled/common.ts +60 -60
  12. package/client/styled/layout/index.ts +25 -25
  13. package/client/styled/template/manage.ts +51 -51
  14. package/client/utils/common.ts +89 -89
  15. package/client/utils/cookie.ts +51 -51
  16. package/client/utils/fetch.ts +25 -25
  17. package/client/utils/menu.tsx +27 -27
  18. package/client/utils/sso.ts +205 -205
  19. package/generation/.babelrc +10 -10
  20. package/generation/README.md +19 -19
  21. package/generation/app.js +2 -2
  22. package/generation/client/redux/reducers.ts +4 -4
  23. package/generation/client/utils/menu.tsx +27 -27
  24. package/generation/gitignore +4 -4
  25. package/generation/mysql.config.js +12 -12
  26. package/generation/next.config.js +6 -6
  27. package/generation/package.json +24 -24
  28. package/generation/project.config.js +13 -13
  29. package/generation/server/rest.js +23 -23
  30. package/generation/server/utils/common.js +6 -6
  31. package/generation/tsconfig.json +30 -30
  32. package/index.js +10 -10
  33. package/lib/args.d.ts +6 -6
  34. package/lib/args.js +53 -53
  35. package/lib/generate.d.ts +3 -3
  36. package/lib/generate.js +751 -751
  37. package/lib/index.d.ts +2 -2
  38. package/lib/index.js +272 -272
  39. package/lib/server/db.d.ts +5 -5
  40. package/lib/server/db.js +110 -110
  41. package/lib/server/graphql.d.ts +7 -7
  42. package/lib/server/graphql.js +119 -119
  43. package/lib/server/plugins/date.d.ts +5 -5
  44. package/lib/server/plugins/date.js +16 -16
  45. package/lib/tsconfig.build.tsbuildinfo +1 -1
  46. package/mysql.config.js +14 -14
  47. package/next-env.d.ts +5 -5
  48. package/next.config.js +231 -231
  49. package/package.json +127 -126
  50. package/pages/_app.tsx +54 -54
  51. package/pages/_document.tsx +55 -55
  52. package/pages/index.tsx +68 -68
  53. package/pages/login.tsx +78 -78
  54. package/pages/template/manage.tsx +299 -278
  55. package/project.config.js +16 -16
  56. package/public/slbhealthcheck.html +9 -9
  57. package/scripts/shutdown.sh +9 -9
  58. package/scripts/startup.sh +34 -34
  59. package/server/apis/sso.js +43 -43
  60. package/server/apis/template.js +37 -17
  61. package/server/modules/template/resolver.js +225 -225
  62. package/server/modules/template/schema.js +33 -33
  63. package/server/rest.js +24 -24
  64. package/server/sql/template.sql +8 -8
  65. package/server/utils/common.js +6 -6
package/next.config.js CHANGED
@@ -1,231 +1,231 @@
1
- /**
2
- * Created by lei_sun on 2019/7/9.
3
- */
4
- const { PHASE_DEVELOPMENT_SERVER, PHASE_EXPORT } = require('next/constants')
5
- const fs = require('fs')
6
- const { promisify } = require('util')
7
- const { join } = require('path')
8
- const copyFile = promisify(fs.copyFile)
9
- const SimpleProgressPlugin = require('webpack-simple-progress-plugin')
10
- const TerserPlugin = require('terser-webpack-plugin')
11
-
12
- module.exports = (phase, defaultConfig, options) => {
13
- let projectConfig = null
14
- let pkg = null
15
-
16
- const curFolder = process.cwd()
17
- const curProjectConfigPath = curFolder + '/project.config.js'
18
- const curPkgPath = curFolder + '/package.json'
19
-
20
- if (fs.existsSync(curProjectConfigPath)) {
21
- projectConfig = require(curProjectConfigPath)
22
- } else {
23
- projectConfig = require('./project.config.js')
24
- }
25
-
26
- if (fs.existsSync(curPkgPath)) {
27
- pkg = require(curPkgPath)
28
- } else {
29
- pkg = require('./package.json')
30
- }
31
-
32
- // const env = (pkg && pkg.config && pkg.config.env && pkg.config.env.toUpperCase()) || 'PROD'
33
-
34
- // console.log('projectConfig', projectConfig)
35
- let { env, version, prefix, protocol, host, port } = projectConfig
36
-
37
- // console.log('options', options)
38
- if (options != undefined) {
39
- version = options.version
40
- prefix = options.prefix
41
- protocol = options.protocol
42
- host = options.host
43
- port = options.port
44
- }
45
-
46
- if (phase === PHASE_DEVELOPMENT_SERVER) {
47
- prefix = ''
48
- }
49
-
50
- // console.log('phase', phase, version, prefix, protocol, host, port)
51
-
52
- let configObj = {
53
- //target: 'serverless',
54
- // crossOrign: 'anonymous',
55
- serverRuntimeConfig: {},
56
- publicRuntimeConfig: {
57
- version,
58
- prefix,
59
- protocol,
60
- host,
61
- port,
62
- env,
63
- phase,
64
- isExport: (phase === PHASE_EXPORT)
65
- },
66
- generateBuildId: async () => {
67
- return 'nsgm-cli-' + version
68
- },
69
- exportPathMap: async function (defaultPathMap, { dev, dir, outDir }) {
70
- if (dev) {
71
- return defaultPathMap
72
- }
73
-
74
- return defaultPathMap
75
- },
76
- generateEtags: false,
77
- useFileSystemPublicRoutes: true,
78
- webpack: (config, { dev, isServer }) => {
79
- //console.log('dev', dev, isServer)
80
-
81
- if (!dev) {
82
- if (!isServer) {
83
- config.optimization.splitChunks = {
84
- cacheGroups: {
85
- default: false,
86
- vendors: false,
87
- framework: {
88
- //将react和react-dom打入framework当中
89
- name: 'framework',
90
- chunks: 'all',
91
- test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/, //匹配库当中的react和react-dom
92
- priority: 40 //权重为40 最大权重
93
- },
94
- lib: {
95
- test(module) {
96
- //匹配包大于160000的
97
- return module.size() > 160000
98
- },
99
- name(module) {
100
- //名字就是包当中的名字
101
- return (
102
- /[\\/]node_modules[\\/](.*)/.exec(module.identifier()) &&
103
- /[\\/]node_modules[\\/](.*)/.exec(module.identifier()).length &&
104
- /[\\/]node_modules[\\/](.*)/.exec(module.identifier())[1].replace(/\/|\\/g, '_')
105
- )
106
- },
107
- priority: 30, //权重为30
108
- minChunks: 1, //最小共用次数为1时就使用
109
- reuseExistingChunk: true
110
- },
111
- commons: {
112
- name: 'commons',
113
- chunks: 'all',
114
- minChunks: 20,
115
- maxSize: 30720,
116
- priority: 20
117
- },
118
- shared: {
119
- priority: 10,
120
- minChunks: 2,
121
- reuseExistingChunk: true
122
- },
123
- styles: {
124
- name: 'styles',
125
- test: /\.css$/,
126
- chunks: 'all',
127
- maxSize: 30720,
128
- enforce: true,
129
- },
130
- less: {
131
- name: 'less',
132
- test: /\.less$/,
133
- chunks: 'all',
134
- maxSize: 30720,
135
- enforce: true,
136
- },
137
- }
138
- }
139
- config.output.chunkFilename = `static/chunks/[name].${version}.js`
140
-
141
- config.output.filename = ({ chunk }) => {
142
- const { name } = chunk
143
- //console.log('name', name)
144
-
145
- if (name === 'main') {
146
- return `static/main.${version}.js`
147
- } else if (name === 'polyfills') {
148
- return `static/polyfills.${version}.js`
149
- } else if (name.indexOf('webpack') != -1) {
150
- return `[name]`
151
- }
152
-
153
- return `static/[name].${version}.js`
154
- }
155
-
156
- config.optimization.runtimeChunk = {
157
- name: `static/runtime/webpack.${version}.js`
158
- }
159
- }
160
-
161
- config.plugins.map((plugin) => {
162
- //console.log('plugin.constructor.name', plugin.constructor.name)
163
- if ('NextMiniCssExtractPlugin' == plugin.constructor.name) {
164
- plugin.options = {
165
- filename: `static/css/[name].${version}.css`,
166
- chunkFilename: `static/css/[name].${version}.css`,
167
- moduleFilename: ({ name }) => {
168
- //console.log('name', name)
169
- return `static/css/${name}.${version}.css`
170
- }
171
- }
172
- }
173
- })
174
-
175
- config.plugins.push(new SimpleProgressPlugin())
176
-
177
- config.optimization.minimizer = [
178
- new TerserPlugin({
179
- parallel: true,
180
- terserOptions: {
181
- ecma: 6
182
- },
183
- minify: (file, sourceMap) => {
184
- // https://github.com/mishoo/UglifyJS2#minify-options
185
- const uglifyJsOptions = {
186
- /* your `uglify-js` package options */
187
- compress: {
188
- // warnings: true,
189
- drop_console: true,
190
- drop_debugger: true
191
- }
192
- }
193
-
194
- if (sourceMap) {
195
- uglifyJsOptions.sourceMap = {
196
- content: sourceMap
197
- }
198
- }
199
-
200
- return require('uglify-js').minify(file, uglifyJsOptions)
201
- }
202
- })
203
- ]
204
- }
205
-
206
- return config
207
- }
208
- }
209
-
210
- if (phase !== PHASE_DEVELOPMENT_SERVER) {
211
- configObj = {
212
- ...configObj,
213
- distDir: 'build',
214
- assetPrefix: prefix,
215
- async rewrites() {
216
- return [
217
- {
218
- source: prefix === '' ? '/' : prefix,
219
- destination: '/'
220
- },
221
- {
222
- source: prefix + '/:slug*',
223
- destination: '/:slug*'
224
- }
225
- ]
226
- }
227
- }
228
- }
229
-
230
- return configObj
231
- }
1
+ /**
2
+ * Created by lei_sun on 2019/7/9.
3
+ */
4
+ const { PHASE_DEVELOPMENT_SERVER, PHASE_EXPORT } = require('next/constants')
5
+ const fs = require('fs')
6
+ const { promisify } = require('util')
7
+ const { join } = require('path')
8
+ const copyFile = promisify(fs.copyFile)
9
+ const SimpleProgressPlugin = require('webpack-simple-progress-plugin')
10
+ const TerserPlugin = require('terser-webpack-plugin')
11
+
12
+ module.exports = (phase, defaultConfig, options) => {
13
+ let projectConfig = null
14
+ let pkg = null
15
+
16
+ const curFolder = process.cwd()
17
+ const curProjectConfigPath = curFolder + '/project.config.js'
18
+ const curPkgPath = curFolder + '/package.json'
19
+
20
+ if (fs.existsSync(curProjectConfigPath)) {
21
+ projectConfig = require(curProjectConfigPath)
22
+ } else {
23
+ projectConfig = require('./project.config.js')
24
+ }
25
+
26
+ if (fs.existsSync(curPkgPath)) {
27
+ pkg = require(curPkgPath)
28
+ } else {
29
+ pkg = require('./package.json')
30
+ }
31
+
32
+ // const env = (pkg && pkg.config && pkg.config.env && pkg.config.env.toUpperCase()) || 'PROD'
33
+
34
+ // console.log('projectConfig', projectConfig)
35
+ let { env, version, prefix, protocol, host, port } = projectConfig
36
+
37
+ // console.log('options', options)
38
+ if (options != undefined) {
39
+ version = options.version
40
+ prefix = options.prefix
41
+ protocol = options.protocol
42
+ host = options.host
43
+ port = options.port
44
+ }
45
+
46
+ if (phase === PHASE_DEVELOPMENT_SERVER) {
47
+ prefix = ''
48
+ }
49
+
50
+ // console.log('phase', phase, version, prefix, protocol, host, port)
51
+
52
+ let configObj = {
53
+ //target: 'serverless',
54
+ // crossOrign: 'anonymous',
55
+ serverRuntimeConfig: {},
56
+ publicRuntimeConfig: {
57
+ version,
58
+ prefix,
59
+ protocol,
60
+ host,
61
+ port,
62
+ env,
63
+ phase,
64
+ isExport: (phase === PHASE_EXPORT)
65
+ },
66
+ generateBuildId: async () => {
67
+ return 'nsgm-cli-' + version
68
+ },
69
+ exportPathMap: async function (defaultPathMap, { dev, dir, outDir }) {
70
+ if (dev) {
71
+ return defaultPathMap
72
+ }
73
+
74
+ return defaultPathMap
75
+ },
76
+ generateEtags: false,
77
+ useFileSystemPublicRoutes: true,
78
+ webpack: (config, { dev, isServer }) => {
79
+ //console.log('dev', dev, isServer)
80
+
81
+ if (!dev) {
82
+ if (!isServer) {
83
+ config.optimization.splitChunks = {
84
+ cacheGroups: {
85
+ default: false,
86
+ vendors: false,
87
+ framework: {
88
+ //将react和react-dom打入framework当中
89
+ name: 'framework',
90
+ chunks: 'all',
91
+ test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/, //匹配库当中的react和react-dom
92
+ priority: 40 //权重为40 最大权重
93
+ },
94
+ lib: {
95
+ test(module) {
96
+ //匹配包大于160000的
97
+ return module.size() > 160000
98
+ },
99
+ name(module) {
100
+ //名字就是包当中的名字
101
+ return (
102
+ /[\\/]node_modules[\\/](.*)/.exec(module.identifier()) &&
103
+ /[\\/]node_modules[\\/](.*)/.exec(module.identifier()).length &&
104
+ /[\\/]node_modules[\\/](.*)/.exec(module.identifier())[1].replace(/\/|\\/g, '_')
105
+ )
106
+ },
107
+ priority: 30, //权重为30
108
+ minChunks: 1, //最小共用次数为1时就使用
109
+ reuseExistingChunk: true
110
+ },
111
+ commons: {
112
+ name: 'commons',
113
+ chunks: 'all',
114
+ minChunks: 20,
115
+ maxSize: 30720,
116
+ priority: 20
117
+ },
118
+ shared: {
119
+ priority: 10,
120
+ minChunks: 2,
121
+ reuseExistingChunk: true
122
+ },
123
+ styles: {
124
+ name: 'styles',
125
+ test: /\.css$/,
126
+ chunks: 'all',
127
+ maxSize: 30720,
128
+ enforce: true,
129
+ },
130
+ less: {
131
+ name: 'less',
132
+ test: /\.less$/,
133
+ chunks: 'all',
134
+ maxSize: 30720,
135
+ enforce: true,
136
+ },
137
+ }
138
+ }
139
+ config.output.chunkFilename = `static/chunks/[name].${version}.js`
140
+
141
+ config.output.filename = ({ chunk }) => {
142
+ const { name } = chunk
143
+ //console.log('name', name)
144
+
145
+ if (name === 'main') {
146
+ return `static/main.${version}.js`
147
+ } else if (name === 'polyfills') {
148
+ return `static/polyfills.${version}.js`
149
+ } else if (name.indexOf('webpack') != -1) {
150
+ return `[name]`
151
+ }
152
+
153
+ return `static/[name].${version}.js`
154
+ }
155
+
156
+ config.optimization.runtimeChunk = {
157
+ name: `static/runtime/webpack.${version}.js`
158
+ }
159
+ }
160
+
161
+ config.plugins.map((plugin) => {
162
+ //console.log('plugin.constructor.name', plugin.constructor.name)
163
+ if ('NextMiniCssExtractPlugin' == plugin.constructor.name) {
164
+ plugin.options = {
165
+ filename: `static/css/[name].${version}.css`,
166
+ chunkFilename: `static/css/[name].${version}.css`,
167
+ moduleFilename: ({ name }) => {
168
+ //console.log('name', name)
169
+ return `static/css/${name}.${version}.css`
170
+ }
171
+ }
172
+ }
173
+ })
174
+
175
+ config.plugins.push(new SimpleProgressPlugin())
176
+
177
+ config.optimization.minimizer = [
178
+ new TerserPlugin({
179
+ parallel: true,
180
+ terserOptions: {
181
+ ecma: 6
182
+ },
183
+ minify: (file, sourceMap) => {
184
+ // https://github.com/mishoo/UglifyJS2#minify-options
185
+ const uglifyJsOptions = {
186
+ /* your `uglify-js` package options */
187
+ compress: {
188
+ // warnings: true,
189
+ drop_console: true,
190
+ drop_debugger: true
191
+ }
192
+ }
193
+
194
+ if (sourceMap) {
195
+ uglifyJsOptions.sourceMap = {
196
+ content: sourceMap
197
+ }
198
+ }
199
+
200
+ return require('uglify-js').minify(file, uglifyJsOptions)
201
+ }
202
+ })
203
+ ]
204
+ }
205
+
206
+ return config
207
+ }
208
+ }
209
+
210
+ if (phase !== PHASE_DEVELOPMENT_SERVER) {
211
+ configObj = {
212
+ ...configObj,
213
+ distDir: 'build',
214
+ assetPrefix: prefix,
215
+ async rewrites() {
216
+ return [
217
+ {
218
+ source: prefix === '' ? '/' : prefix,
219
+ destination: '/'
220
+ },
221
+ {
222
+ source: prefix + '/:slug*',
223
+ destination: '/:slug*'
224
+ }
225
+ ]
226
+ }
227
+ }
228
+ }
229
+
230
+ return configObj
231
+ }