nsgm-cli 1.0.25 → 1.0.27

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 (51) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +162 -162
  3. package/generation/.babelrc +9 -9
  4. package/generation/README.md +18 -18
  5. package/generation/app.js +2 -2
  6. package/generation/client/layout/index.tsx +223 -223
  7. package/generation/client/redux/reducers.ts +5 -5
  8. package/generation/client/redux/store.ts +44 -44
  9. package/generation/client/redux/template/manage/actions.ts +190 -190
  10. package/generation/client/redux/template/manage/reducers.ts +118 -118
  11. package/generation/client/redux/template/manage/types.ts +24 -24
  12. package/generation/client/service/template/manage.ts +73 -73
  13. package/generation/client/styled/common.ts +28 -28
  14. package/generation/client/styled/layout/index.ts +13 -13
  15. package/generation/client/styled/template/manage.ts +51 -51
  16. package/generation/client/utils/common.ts +45 -45
  17. package/generation/client/utils/fetch.ts +25 -25
  18. package/generation/client/utils/menu.tsx +26 -26
  19. package/generation/gitignore +3 -3
  20. package/generation/mysql.config.js +12 -12
  21. package/generation/next-env.d.ts +2 -2
  22. package/generation/next.config.js +6 -6
  23. package/generation/package.json +20 -20
  24. package/generation/pages/_app.tsx +44 -44
  25. package/generation/pages/_document.tsx +53 -53
  26. package/generation/pages/index.tsx +54 -54
  27. package/generation/pages/template/manage.tsx +280 -280
  28. package/generation/project.config.js +12 -12
  29. package/generation/server/apis/template.js +18 -18
  30. package/generation/server/modules/template/resolver.js +231 -231
  31. package/generation/server/modules/template/schema.js +33 -33
  32. package/generation/server/rest.js +20 -20
  33. package/generation/server/sql/template.sql +8 -8
  34. package/generation/tsconfig.json +29 -29
  35. package/index.js +10 -10
  36. package/lib/args.d.ts +6 -6
  37. package/lib/args.js +47 -47
  38. package/lib/generate.d.ts +3 -3
  39. package/lib/generate.js +590 -590
  40. package/lib/index.d.ts +2 -2
  41. package/lib/index.js +182 -182
  42. package/lib/server/db.d.ts +5 -5
  43. package/lib/server/db.js +47 -47
  44. package/lib/server/graphql.d.ts +7 -7
  45. package/lib/server/graphql.js +119 -119
  46. package/lib/server/plugins/date.d.ts +5 -5
  47. package/lib/server/plugins/date.js +16 -16
  48. package/mysql.config.js +14 -14
  49. package/next.config.js +210 -210
  50. package/package.json +113 -113
  51. package/project.config.js +14 -14
@@ -1,74 +1,74 @@
1
- import { getLocalGraphql } from '../../utils/fetch'
2
- import _ from 'lodash'
3
-
4
- export const getTemplateService = (page=0, pageSize=10) => {
5
- const getTemplateQuery = `query { template(page:` + page + `, pageSize:` + pageSize + `) {
6
- totalCounts items {
7
- id name
8
- }
9
- }
10
- }`
11
- return getLocalGraphql(getTemplateQuery)
12
- }
13
-
14
- export const searchTemplateByIdService = (id: number) => {
15
- const searchTemplateByIdQuery = `query { templateGet(id:` + id + `) {
16
- id name
17
- }
18
- }`
19
- return getLocalGraphql(searchTemplateByIdQuery)
20
- }
21
-
22
- export const searchTemplateService = (page = 0, pageSize = 10, data: any) => {
23
- const { name } = data
24
- const searchTemplateQuery = `query { templateSearch(page:` + page + `, pageSize:` + pageSize + `, data: { name: "` + name + `" }) {
25
- totalCounts items {
26
- id name
27
- }
28
- }
29
- }`
30
- return getLocalGraphql(searchTemplateQuery)
31
- }
32
-
33
- export const addTemplateService = (data: any) => {
34
- const { name } = data
35
-
36
- const addTemplateQuery = `mutation { templateAdd(data: { name: "` + name + `"}) }`
37
-
38
- return getLocalGraphql(addTemplateQuery)
39
- }
40
-
41
- export const updateTemplateService = (id: number, data: any) => {
42
- const { name } = data
43
-
44
- const updateTemplateQuery = `mutation { templateUpdate(id: ` + id + `, data: { name: "` + name + `"}) }`
45
-
46
- return getLocalGraphql(updateTemplateQuery)
47
- }
48
-
49
- export const deleteTemplateService = (id: number) => {
50
- const deleteTemplateQuery = `mutation { templateDelete(id: ` + id + `) }`
51
-
52
- return getLocalGraphql(deleteTemplateQuery)
53
- }
54
-
55
- export const batchAddTemplateService = (datas: any) => {
56
- let batchStr = ''
57
- _.each(datas, (item, index) => {
58
- const { name } = item
59
- batchStr += `{ name: "` + name + `" },`
60
- })
61
- batchStr = batchStr.substring(0, batchStr.length - 1)
62
-
63
- const batchAddTemplateQuery = `mutation { templateBatchAdd(datas: [` + batchStr + `]) }`
64
-
65
- return getLocalGraphql(batchAddTemplateQuery)
66
- }
67
-
68
- export const batchDeleteTemplateService = (ids: any) => {
69
- const batchStr = ids.join(',')
70
-
71
- const batchDeleteTemplateQuery = `mutation { templateBatchDelete(ids: [` + batchStr + `]) }`
72
-
73
- return getLocalGraphql(batchDeleteTemplateQuery)
1
+ import { getLocalGraphql } from '../../utils/fetch'
2
+ import _ from 'lodash'
3
+
4
+ export const getTemplateService = (page=0, pageSize=10) => {
5
+ const getTemplateQuery = `query { template(page:` + page + `, pageSize:` + pageSize + `) {
6
+ totalCounts items {
7
+ id name
8
+ }
9
+ }
10
+ }`
11
+ return getLocalGraphql(getTemplateQuery)
12
+ }
13
+
14
+ export const searchTemplateByIdService = (id: number) => {
15
+ const searchTemplateByIdQuery = `query { templateGet(id:` + id + `) {
16
+ id name
17
+ }
18
+ }`
19
+ return getLocalGraphql(searchTemplateByIdQuery)
20
+ }
21
+
22
+ export const searchTemplateService = (page = 0, pageSize = 10, data: any) => {
23
+ const { name } = data
24
+ const searchTemplateQuery = `query { templateSearch(page:` + page + `, pageSize:` + pageSize + `, data: { name: "` + name + `" }) {
25
+ totalCounts items {
26
+ id name
27
+ }
28
+ }
29
+ }`
30
+ return getLocalGraphql(searchTemplateQuery)
31
+ }
32
+
33
+ export const addTemplateService = (data: any) => {
34
+ const { name } = data
35
+
36
+ const addTemplateQuery = `mutation { templateAdd(data: { name: "` + name + `"}) }`
37
+
38
+ return getLocalGraphql(addTemplateQuery)
39
+ }
40
+
41
+ export const updateTemplateService = (id: number, data: any) => {
42
+ const { name } = data
43
+
44
+ const updateTemplateQuery = `mutation { templateUpdate(id: ` + id + `, data: { name: "` + name + `"}) }`
45
+
46
+ return getLocalGraphql(updateTemplateQuery)
47
+ }
48
+
49
+ export const deleteTemplateService = (id: number) => {
50
+ const deleteTemplateQuery = `mutation { templateDelete(id: ` + id + `) }`
51
+
52
+ return getLocalGraphql(deleteTemplateQuery)
53
+ }
54
+
55
+ export const batchAddTemplateService = (datas: any) => {
56
+ let batchStr = ''
57
+ _.each(datas, (item, index) => {
58
+ const { name } = item
59
+ batchStr += `{ name: "` + name + `" },`
60
+ })
61
+ batchStr = batchStr.substring(0, batchStr.length - 1)
62
+
63
+ const batchAddTemplateQuery = `mutation { templateBatchAdd(datas: [` + batchStr + `]) }`
64
+
65
+ return getLocalGraphql(batchAddTemplateQuery)
66
+ }
67
+
68
+ export const batchDeleteTemplateService = (ids: any) => {
69
+ const batchStr = ids.join(',')
70
+
71
+ const batchDeleteTemplateQuery = `mutation { templateBatchDelete(ids: [` + batchStr + `]) }`
72
+
73
+ return getLocalGraphql(batchDeleteTemplateQuery)
74
74
  }
@@ -1,28 +1,28 @@
1
- import styled, { createGlobalStyle } from 'styled-components'
2
-
3
- export const GlobalStyle = createGlobalStyle`
4
- html,body,#__next {
5
- height: 100%;
6
- border: 1px solid white;
7
- }
8
-
9
- body {
10
- background-color: ${(props: any) => (props.whiteColor ? 'white' : 'black')};
11
- font-family: Helvetica;
12
- margin: 0;
13
- }
14
- `
15
-
16
- export const Container = styled.div`
17
- margin: 20px;
18
- `
19
-
20
- export const Loading = styled.div`
21
- display: flex;
22
- flex: 1;
23
- flex-direction: row;
24
- justify-content: center;
25
- align-items: center;
26
- margin-top: 100px;
27
- `
28
-
1
+ import styled, { createGlobalStyle } from 'styled-components'
2
+
3
+ export const GlobalStyle = createGlobalStyle`
4
+ html,body,#__next {
5
+ height: 100%;
6
+ border: 1px solid white;
7
+ }
8
+
9
+ body {
10
+ background-color: ${(props: any) => (props.whiteColor ? 'white' : 'black')};
11
+ font-family: Helvetica;
12
+ margin: 0;
13
+ }
14
+ `
15
+
16
+ export const Container = styled.div`
17
+ margin: 20px;
18
+ `
19
+
20
+ export const Loading = styled.div`
21
+ display: flex;
22
+ flex: 1;
23
+ flex-direction: row;
24
+ justify-content: center;
25
+ align-items: center;
26
+ margin-top: 100px;
27
+ `
28
+
@@ -1,14 +1,14 @@
1
- import styled from 'styled-components'
2
-
3
- export const Container = styled.div`
4
- .logo {
5
- float: left;
6
- width: 120px;
7
- height: 31px;
8
- margin: 16px 24px 16px 0;
9
- }
10
-
11
- .site-layout-background {
12
- background: #fff;
13
- }
1
+ import styled from 'styled-components'
2
+
3
+ export const Container = styled.div`
4
+ .logo {
5
+ float: left;
6
+ width: 120px;
7
+ height: 31px;
8
+ margin: 16px 24px 16px 0;
9
+ }
10
+
11
+ .site-layout-background {
12
+ background: #fff;
13
+ }
14
14
  `
@@ -1,52 +1,52 @@
1
- import styled from 'styled-components'
2
-
3
- export const Container = styled.div`
4
- margin: 20px;
5
- `
6
-
7
- export const SearchRow = styled.div`
8
- margin: 10px;
9
- display: flex;
10
- flex: 1;
11
- flex-direction: row;
12
- justify-content: space-between;
13
- align-items: center;
14
- `
15
-
16
- export const ModalContainer = styled.div`
17
- .line {
18
- display: flex;
19
- flex: 1;
20
- flex-direction: row;
21
- justify-content: flex-start;
22
- align-items: flex-start;
23
- height: 50px;
24
-
25
- label {
26
- display: flex;
27
- flex-direction: column;
28
- justify-content: center;
29
- align-items: flex-start;
30
- width: 80px;
31
- height: 32px;
32
- margin-right: 5px;
33
- }
34
-
35
- input {
36
- flex: 1;
37
- }
38
-
39
- .row {
40
- display: flex;
41
- flex-direction: row;
42
- justify-content: center;
43
- align-items: center;
44
-
45
- .item {
46
- flex-direction: row;
47
- justify-content: flex-start;
48
- align-items: center;
49
- }
50
- }
51
- }
1
+ import styled from 'styled-components'
2
+
3
+ export const Container = styled.div`
4
+ margin: 20px;
5
+ `
6
+
7
+ export const SearchRow = styled.div`
8
+ margin: 10px;
9
+ display: flex;
10
+ flex: 1;
11
+ flex-direction: row;
12
+ justify-content: space-between;
13
+ align-items: center;
14
+ `
15
+
16
+ export const ModalContainer = styled.div`
17
+ .line {
18
+ display: flex;
19
+ flex: 1;
20
+ flex-direction: row;
21
+ justify-content: flex-start;
22
+ align-items: flex-start;
23
+ height: 50px;
24
+
25
+ label {
26
+ display: flex;
27
+ flex-direction: column;
28
+ justify-content: center;
29
+ align-items: flex-start;
30
+ width: 80px;
31
+ height: 32px;
32
+ margin-right: 5px;
33
+ }
34
+
35
+ input {
36
+ flex: 1;
37
+ }
38
+
39
+ .row {
40
+ display: flex;
41
+ flex-direction: row;
42
+ justify-content: center;
43
+ align-items: center;
44
+
45
+ .item {
46
+ flex-direction: row;
47
+ justify-content: flex-start;
48
+ align-items: center;
49
+ }
50
+ }
51
+ }
52
52
  `
@@ -1,45 +1,45 @@
1
- import getConfig from 'next/config'
2
- import _ from 'lodash'
3
-
4
- export const getLocalApiPrefix = () => {
5
- const nextConfig = getConfig()
6
- const { publicRuntimeConfig } = nextConfig
7
- let { protocol, host, port } = publicRuntimeConfig
8
-
9
- if (typeof window !== 'undefined') {
10
- const location = window.location
11
- // console.log('location', location)
12
- protocol = location.protocol
13
- if (protocol.indexOf(':') !== -1) {
14
- protocol = protocol.split(':')[0]
15
- }
16
- host = location.hostname
17
- port = location.port
18
- }
19
-
20
- const localApiPrefix = protocol + '://' + host + ':' + port
21
- // console.log('localApiPrefix', localApiPrefix)
22
- return localApiPrefix
23
- }
24
-
25
- export const handleXSS = (content: string) => {
26
- content = content || ''
27
- return content.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g, '&quot;').replace(/\'/g, '&#x27;')
28
- }
29
-
30
- export const checkModalObj = (modalObj: {}, ignoreKeys: any = []) => {
31
- let result: any = null
32
- _.each(modalObj, (value: any, key: string) => {
33
- // console.log('checkModalObj', ignoreKeys, key, ignoreKeys.join('.').indexOf(key))
34
- if (ignoreKeys.length === 0 || (ignoreKeys.length !== 0 && ignoreKeys.join('.').indexOf(key) === -1)) {
35
- if (_.trim(value) === '') {
36
- result = {
37
- key,
38
- reason: '不能为空'
39
- }
40
- return false
41
- }
42
- }
43
- })
44
- return result
45
- }
1
+ import getConfig from 'next/config'
2
+ import _ from 'lodash'
3
+
4
+ export const getLocalApiPrefix = () => {
5
+ const nextConfig = getConfig()
6
+ const { publicRuntimeConfig } = nextConfig
7
+ let { protocol, host, port } = publicRuntimeConfig
8
+
9
+ if (typeof window !== 'undefined') {
10
+ const location = window.location
11
+ // console.log('location', location)
12
+ protocol = location.protocol
13
+ if (protocol.indexOf(':') !== -1) {
14
+ protocol = protocol.split(':')[0]
15
+ }
16
+ host = location.hostname
17
+ port = location.port
18
+ }
19
+
20
+ const localApiPrefix = protocol + '://' + host + ':' + port
21
+ // console.log('localApiPrefix', localApiPrefix)
22
+ return localApiPrefix
23
+ }
24
+
25
+ export const handleXSS = (content: string) => {
26
+ content = content || ''
27
+ return content.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g, '&quot;').replace(/\'/g, '&#x27;')
28
+ }
29
+
30
+ export const checkModalObj = (modalObj: {}, ignoreKeys: any = []) => {
31
+ let result: any = null
32
+ _.each(modalObj, (value: any, key: string) => {
33
+ // console.log('checkModalObj', ignoreKeys, key, ignoreKeys.join('.').indexOf(key))
34
+ if (ignoreKeys.length === 0 || (ignoreKeys.length !== 0 && ignoreKeys.join('.').indexOf(key) === -1)) {
35
+ if (_.trim(value) === '') {
36
+ result = {
37
+ key,
38
+ reason: '不能为空'
39
+ }
40
+ return false
41
+ }
42
+ }
43
+ })
44
+ return result
45
+ }
@@ -1,25 +1,25 @@
1
- import axios from 'axios'
2
- import { getLocalApiPrefix } from './common'
3
-
4
- export const getLocalGraphql = (query: string, variables: any = {}) => {
5
- return new Promise((resolve, reject) => {
6
- axios
7
- .post(getLocalApiPrefix() + '/graphql', {
8
- query,
9
- variables
10
- })
11
- .then((res) => {
12
- // console.log('axios_res', res)
13
- if (res) {
14
- const { data } = res
15
- resolve(data)
16
- } else {
17
- reject()
18
- }
19
- })
20
- .catch((_e) => {
21
- // console.error('axios_e', _e)
22
- reject(_e)
23
- })
24
- })
25
- }
1
+ import axios from 'axios'
2
+ import { getLocalApiPrefix } from './common'
3
+
4
+ export const getLocalGraphql = (query: string, variables: any = {}) => {
5
+ return new Promise((resolve, reject) => {
6
+ axios
7
+ .post(getLocalApiPrefix() + '/graphql', {
8
+ query,
9
+ variables
10
+ })
11
+ .then((res) => {
12
+ // console.log('axios_res', res)
13
+ if (res) {
14
+ const { data } = res
15
+ resolve(data)
16
+ } else {
17
+ reject()
18
+ }
19
+ })
20
+ .catch((_e) => {
21
+ // console.error('axios_e', _e)
22
+ reject(_e)
23
+ })
24
+ })
25
+ }
@@ -1,26 +1,26 @@
1
- import { BookOutlined, SolutionOutlined } from '@ant-design/icons'
2
-
3
- let key = 0
4
-
5
- export default [
6
- {
7
- key: (++key).toString(),
8
- text: '介绍',
9
- url: '/',
10
- icon: <BookOutlined />,
11
- subMenus: null
12
- }
13
- /*{
14
- key: (++key).toString(),
15
- text: '模板',
16
- url: '/template/manage',
17
- icon: <SolutionOutlined />,
18
- subMenus: [
19
- {
20
- key: key + '_1',
21
- text: '模板1',
22
- url: '/template/manage'
23
- }
24
- ]
25
- },*/
26
- ]
1
+ import { BookOutlined, SolutionOutlined } from '@ant-design/icons'
2
+
3
+ let key = 0
4
+
5
+ export default [
6
+ {
7
+ key: (++key).toString(),
8
+ text: '介绍',
9
+ url: '/',
10
+ icon: <BookOutlined />,
11
+ subMenus: null
12
+ }
13
+ /*{
14
+ key: (++key).toString(),
15
+ text: '模板',
16
+ url: '/template/manage',
17
+ icon: <SolutionOutlined />,
18
+ subMenus: [
19
+ {
20
+ key: key + '_1',
21
+ text: '模板1',
22
+ url: '/template/manage'
23
+ }
24
+ ]
25
+ },*/
26
+ ]
@@ -1,4 +1,4 @@
1
- node_modules
2
- .next
3
- out
1
+ node_modules
2
+ .next
3
+ out
4
4
  build
@@ -1,13 +1,13 @@
1
- const { mysqlConfig } = require('nsgm-cli')
2
- const { mysqlOptions } = mysqlConfig
3
- const { user, password, host, port, database } = mysqlOptions
4
-
5
- module.exports = {
6
- mysqlOptions: {
7
- user: 'root',
8
- password: 'password',
9
- host: '127.0.0.1',
10
- port: 3306,
11
- database: 'crm_demo'
12
- }
1
+ const { mysqlConfig } = require('nsgm-cli')
2
+ const { mysqlOptions } = mysqlConfig
3
+ const { user, password, host, port, database } = mysqlOptions
4
+
5
+ module.exports = {
6
+ mysqlOptions: {
7
+ user: 'root',
8
+ password: 'password',
9
+ host: '127.0.0.1',
10
+ port: 3306,
11
+ database: 'crm_demo'
12
+ }
13
13
  }
@@ -1,2 +1,2 @@
1
- /// <reference types="next" />
2
- /// <reference types="next/types/global" />
1
+ /// <reference types="next" />
2
+ /// <reference types="next/types/global" />
@@ -1,7 +1,7 @@
1
- const { nextConfig } = require('nsgm-cli')
2
-
3
- module.exports = (phase, defaultConfig) => {
4
- let configObj = nextConfig(phase, defaultConfig)
5
-
6
- return configObj
1
+ const { nextConfig } = require('nsgm-cli')
2
+
3
+ module.exports = (phase, defaultConfig) => {
4
+ let configObj = nextConfig(phase, defaultConfig)
5
+
6
+ return configObj
7
7
  }
@@ -1,20 +1,20 @@
1
- {
2
- "name": "nsgm-cli-project",
3
- "version": "1.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "dev": "nsgm dev",
8
- "build": "next build",
9
- "start": "nsgm start",
10
- "export": "nsgm export",
11
- "init": "nsgm init",
12
- "upgrade": "nsgm upgrade",
13
- "create": "nsgm create",
14
- "delete": "nsgm delete",
15
- "postversion": "git push && git push --tags",
16
- "test": "echo \"Error: no test specified\" && exit 1"
17
- },
18
- "author": "",
19
- "license": "ISC"
20
- }
1
+ {
2
+ "name": "nsgm-cli-project",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "dev": "nsgm dev",
8
+ "build": "next build",
9
+ "start": "nsgm start",
10
+ "export": "nsgm export",
11
+ "init": "nsgm init",
12
+ "upgrade": "nsgm upgrade",
13
+ "create": "nsgm create",
14
+ "delete": "nsgm delete",
15
+ "postversion": "git push && git push --tags",
16
+ "test": "echo \"Error: no test specified\" && exit 1"
17
+ },
18
+ "author": "",
19
+ "license": "ISC"
20
+ }