nsgm-cli 2.0.6 → 2.0.7

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 (59) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +161 -161
  3. package/client/layout/index.tsx +248 -245
  4. package/client/redux/reducers.ts +4 -4
  5. package/client/redux/store.ts +50 -50
  6. package/client/redux/template/manage/actions.ts +190 -190
  7. package/client/redux/template/manage/reducers.ts +118 -118
  8. package/client/redux/template/manage/types.ts +24 -24
  9. package/client/service/template/manage.ts +96 -96
  10. package/client/styled/common.ts +30 -26
  11. package/client/styled/layout/index.ts +25 -25
  12. package/client/styled/template/manage.ts +51 -51
  13. package/client/utils/common.ts +89 -86
  14. package/client/utils/cookie.ts +51 -51
  15. package/client/utils/fetch.ts +25 -25
  16. package/client/utils/menu.tsx +27 -27
  17. package/client/utils/sso.ts +205 -0
  18. package/generation/README.md +19 -19
  19. package/generation/app.js +2 -2
  20. package/generation/client/redux/reducers.ts +4 -4
  21. package/generation/client/utils/menu.tsx +27 -27
  22. package/generation/gitignore +4 -4
  23. package/generation/mysql.config.js +12 -13
  24. package/generation/next.config.js +6 -6
  25. package/generation/package.json +21 -26
  26. package/generation/project.config.js +13 -12
  27. package/generation/server/rest.js +23 -20
  28. package/generation/tsconfig.json +30 -30
  29. package/index.js +10 -10
  30. package/lib/args.d.ts +6 -6
  31. package/lib/args.js +53 -53
  32. package/lib/generate.d.ts +3 -3
  33. package/lib/generate.js +751 -736
  34. package/lib/index.d.ts +2 -2
  35. package/lib/index.js +272 -272
  36. package/lib/server/db.d.ts +5 -5
  37. package/lib/server/db.js +110 -110
  38. package/lib/server/graphql.d.ts +7 -7
  39. package/lib/server/graphql.js +119 -119
  40. package/lib/server/plugins/date.d.ts +5 -5
  41. package/lib/server/plugins/date.js +16 -16
  42. package/lib/tsconfig.build.tsbuildinfo +1 -1
  43. package/mysql.config.js +14 -14
  44. package/next-env.d.ts +6 -6
  45. package/next.config.js +2 -2
  46. package/package.json +126 -126
  47. package/pages/_app.tsx +54 -44
  48. package/pages/login.tsx +65 -0
  49. package/pages/template/manage.tsx +278 -278
  50. package/project.config.js +16 -14
  51. package/public/slbhealthcheck.html +9 -9
  52. package/scripts/shutdown.sh +9 -9
  53. package/scripts/startup.sh +34 -34
  54. package/server/apis/sso.js +44 -0
  55. package/server/apis/template.js +17 -17
  56. package/server/modules/template/schema.js +33 -33
  57. package/server/rest.js +24 -20
  58. package/server/sql/template.sql +8 -8
  59. package/generation/.DS_Store +0 -0
package/README.md CHANGED
@@ -1,161 +1,161 @@
1
- # NSGM CLI
2
- - 技术栈: [Next](https://github.com/vercel/next.js), [Styled-components](https://github.com/styled-components/styled-components), [Graphql](https://graphql.org/), [Mysql](https://www.mysql.com/)
3
- - 全栈架构,代码模板生成,快速开发
4
- - 数据库采用 Mysql, 配置见 mysql.config.js
5
- - 项目配置见 project.config.js
6
- - Next 框架配置见 next.config.js
7
- - [DEMO 链接](https://nsgm.erisl.top/)
8
- ## 命令
9
- - nsgm init 初始化项目
10
- - nsgm upgrade 升级项目基础文件
11
- - nsgm create 创建模板页面
12
- - nsgm delete 删除模板页面
13
- - nsgm deletedb 删除模板页面及数据库表
14
- - nsgm dev 开发模式
15
- - nsgm start 生产模式
16
- - nsgm build 编译
17
- - nsgm export 导出静态页面
18
-
19
- ## 参数
20
- - dictionary: 在 export/init 的时候使用, 默认 webapp, 譬如: nsgm init|export dictionary=webapp 或者 nsgm init|export webapp
21
- - controller: 在 create/delete 的时候使用, 必须有。譬如:nsgm create|delete math
22
- - action: 在 create/delete 的时候使用, 默认 manage, 跟在 controller 后面, 譬如 nsgm create|delete math test
23
-
24
- ## 根目录新增 next.config.js
25
- ```
26
- const { nextConfig } = require('nsgm-cli')
27
- const projectConfig = require('./project.config')
28
-
29
- const { version, prefix, protocol, host } = projectConfig
30
-
31
- module.exports = (phase, defaultConfig) => {
32
- let configObj = nextConfig(phase, defaultConfig, {
33
- version, prefix, protocol, host
34
- })
35
-
36
- return configObj
37
- }
38
- ```
39
-
40
- ## 根目录新增 mysql.config.js
41
- ```
42
- const { mysqlConfig } = require('nsgm-cli')
43
- const { mysqlOptions } = mysqlConfig
44
- const { user, password, host, port, database } = mysqlOptions
45
-
46
- module.exports = {
47
- mysqlOptions: {
48
- user,
49
- password,
50
- host,
51
- port,
52
- database
53
- }
54
- }
55
- ```
56
-
57
- ## 根目录新增 project.config.js
58
- ```
59
- const { projectConfig } = require('nsgm-cli')
60
- const pkg = require('./package.json')
61
-
62
- const { prefix, protocol, host, port } = projectConfig
63
- const { version } = pkg
64
-
65
- module.exports = {
66
- version,
67
- prefix,
68
- protocol,
69
- host,
70
- port
71
- }
72
- ```
73
-
74
- ## 根目录新增 server
75
- - apis 存放 Rest Api
76
- - modules 存放 graphql 的 resolver 和 schema
77
- - plugins 存放 graphql 的 plugin
78
- - *.js 举例: test.js => 用于响应 /test/*, ${prefix}/test/* 请求
79
-
80
- ```
81
- const express = require('express')
82
- const moment = require('moment')
83
-
84
- const router = express.Router()
85
-
86
- router.use((req, res, next) => {
87
- const fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl
88
- console.log(moment().format('YYYY-MM-DD HH:mm:ss') + ' ' + fullUrl)
89
- next()
90
- })
91
-
92
- router.get('/*', (req, res) => {
93
- res.statusCode = 200
94
- res.json({ name: 'TEST' })
95
- })
96
-
97
- module.exports = router
98
- ```
99
-
100
- - apis/hello.js
101
- ```
102
- const express = require('express')
103
- const router = express.Router()
104
-
105
- router.get('/*', (req, res) => {
106
- res.statusCode = 200
107
- res.json({ name: 'Hello' })
108
- })
109
-
110
- module.exports = router
111
- ```
112
-
113
- - modules/link/schema.js
114
- ```
115
- module.exports = {
116
- query: `
117
- link: String
118
- `,
119
- mutation: `
120
- linkUpdate(link: Date): String
121
- `,
122
- subscription: ``,
123
- type: ``
124
- }
125
- ```
126
-
127
- - modules/link/resolver.js
128
- ```
129
- let localLink = ''
130
-
131
- module.exports = {
132
- link: () => {
133
- return localLink
134
- },
135
- linkUpdate: ({ link }) =>{
136
- console.log('link', link)
137
- localLink = link
138
- return localLink
139
- }
140
- }
141
- ```
142
-
143
- - plugins/date.js
144
- ```
145
- const moment = require('moment')
146
- const { Kind } = require('graphql/language')
147
- const { GraphQLScalarType } = require('graphql')
148
-
149
- const customScalarDate = new GraphQLScalarType({
150
- name: 'Date',
151
- description: 'Date custom scalar type',
152
- parseValue: value => moment(value).valueOf(),
153
- serialize: value => moment(value).format('YYYY-MM-DD HH:mm:ss:SSS'),
154
- parseLiteral: ast => (ast.kind === Kind.INT)
155
- ? parseInt(ast.value, 10)
156
- : null
157
- })
158
-
159
- module.exports = { Date: customScalarDate }
160
- ```
161
-
1
+ # NSGM CLI
2
+ - 技术栈: [Next](https://github.com/vercel/next.js), [Styled-components](https://github.com/styled-components/styled-components), [Graphql](https://graphql.org/), [Mysql](https://www.mysql.com/)
3
+ - 全栈架构,代码模板生成,快速开发
4
+ - 数据库采用 Mysql, 配置见 mysql.config.js
5
+ - 项目配置见 project.config.js
6
+ - Next 框架配置见 next.config.js
7
+ - [DEMO 链接](https://nsgm.erisl.top/)
8
+ ## 命令
9
+ - nsgm init 初始化项目
10
+ - nsgm upgrade 升级项目基础文件
11
+ - nsgm create 创建模板页面
12
+ - nsgm delete 删除模板页面
13
+ - nsgm deletedb 删除模板页面及数据库表
14
+ - nsgm dev 开发模式
15
+ - nsgm start 生产模式
16
+ - nsgm build 编译
17
+ - nsgm export 导出静态页面
18
+
19
+ ## 参数
20
+ - dictionary: 在 export/init 的时候使用, 默认 webapp, 譬如: nsgm init|export dictionary=webapp 或者 nsgm init|export webapp
21
+ - controller: 在 create/delete 的时候使用, 必须有。譬如:nsgm create|delete math
22
+ - action: 在 create/delete 的时候使用, 默认 manage, 跟在 controller 后面, 譬如 nsgm create|delete math test
23
+
24
+ ## 根目录新增 next.config.js
25
+ ```
26
+ const { nextConfig } = require('nsgm-cli')
27
+ const projectConfig = require('./project.config')
28
+
29
+ const { version, prefix, protocol, host } = projectConfig
30
+
31
+ module.exports = (phase, defaultConfig) => {
32
+ let configObj = nextConfig(phase, defaultConfig, {
33
+ version, prefix, protocol, host
34
+ })
35
+
36
+ return configObj
37
+ }
38
+ ```
39
+
40
+ ## 根目录新增 mysql.config.js
41
+ ```
42
+ const { mysqlConfig } = require('nsgm-cli')
43
+ const { mysqlOptions } = mysqlConfig
44
+ const { user, password, host, port, database } = mysqlOptions
45
+
46
+ module.exports = {
47
+ mysqlOptions: {
48
+ user,
49
+ password,
50
+ host,
51
+ port,
52
+ database
53
+ }
54
+ }
55
+ ```
56
+
57
+ ## 根目录新增 project.config.js
58
+ ```
59
+ const { projectConfig } = require('nsgm-cli')
60
+ const pkg = require('./package.json')
61
+
62
+ const { prefix, protocol, host, port } = projectConfig
63
+ const { version } = pkg
64
+
65
+ module.exports = {
66
+ version,
67
+ prefix,
68
+ protocol,
69
+ host,
70
+ port
71
+ }
72
+ ```
73
+
74
+ ## 根目录新增 server
75
+ - apis 存放 Rest Api
76
+ - modules 存放 graphql 的 resolver 和 schema
77
+ - plugins 存放 graphql 的 plugin
78
+ - *.js 举例: test.js => 用于响应 /test/*, ${prefix}/test/* 请求
79
+
80
+ ```
81
+ const express = require('express')
82
+ const moment = require('moment')
83
+
84
+ const router = express.Router()
85
+
86
+ router.use((req, res, next) => {
87
+ const fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl
88
+ console.log(moment().format('YYYY-MM-DD HH:mm:ss') + ' ' + fullUrl)
89
+ next()
90
+ })
91
+
92
+ router.get('/*', (req, res) => {
93
+ res.statusCode = 200
94
+ res.json({ name: 'TEST' })
95
+ })
96
+
97
+ module.exports = router
98
+ ```
99
+
100
+ - apis/hello.js
101
+ ```
102
+ const express = require('express')
103
+ const router = express.Router()
104
+
105
+ router.get('/*', (req, res) => {
106
+ res.statusCode = 200
107
+ res.json({ name: 'Hello' })
108
+ })
109
+
110
+ module.exports = router
111
+ ```
112
+
113
+ - modules/link/schema.js
114
+ ```
115
+ module.exports = {
116
+ query: `
117
+ link: String
118
+ `,
119
+ mutation: `
120
+ linkUpdate(link: Date): String
121
+ `,
122
+ subscription: ``,
123
+ type: ``
124
+ }
125
+ ```
126
+
127
+ - modules/link/resolver.js
128
+ ```
129
+ let localLink = ''
130
+
131
+ module.exports = {
132
+ link: () => {
133
+ return localLink
134
+ },
135
+ linkUpdate: ({ link }) =>{
136
+ console.log('link', link)
137
+ localLink = link
138
+ return localLink
139
+ }
140
+ }
141
+ ```
142
+
143
+ - plugins/date.js
144
+ ```
145
+ const moment = require('moment')
146
+ const { Kind } = require('graphql/language')
147
+ const { GraphQLScalarType } = require('graphql')
148
+
149
+ const customScalarDate = new GraphQLScalarType({
150
+ name: 'Date',
151
+ description: 'Date custom scalar type',
152
+ parseValue: value => moment(value).valueOf(),
153
+ serialize: value => moment(value).format('YYYY-MM-DD HH:mm:ss:SSS'),
154
+ parseLiteral: ast => (ast.kind === Kind.INT)
155
+ ? parseInt(ast.value, 10)
156
+ : null
157
+ })
158
+
159
+ module.exports = { Date: customScalarDate }
160
+ ```
161
+