zmp-cli 3.11.0-rc.2 → 3.11.0-rc.3
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.
- package/create/index.js +5 -0
- package/create/{init-zaui.js → init-zmp-ui.js} +1 -5
- package/create/templates/copy-assets.js +2 -2
- package/create/templates/generate-index.js +2 -2
- package/create/templates/generate-scripts.js +2 -2
- package/create/templates/generate-styles.js +10 -12
- package/create/templates/zaui/components/user-card.jsx +8 -10
- package/create/templates/zaui/copy-assets.js +0 -4
- package/create/templates/zaui/generate-home-page.js +29 -12
- package/create/templates/zaui/generate-root.js +17 -11
- package/create/templates/zaui/generate-scripts.js +2 -2
- package/create/templates/zaui/pages/about.js +39 -19
- package/create/templates/zaui/pages/form.js +13 -15
- package/create/templates/zaui/pages/user.js +41 -30
- package/create/utils/generate-package-json.js +6 -11
- package/create/utils/get-options.js +66 -128
- package/create/utils/string.js +13 -0
- package/index.js +0 -24
- package/package.json +1 -1
- package/create/templates/zaui/config/index.js +0 -10
package/create/index.js
CHANGED
|
@@ -17,6 +17,7 @@ const generateReadme = require('./utils/generate-readme');
|
|
|
17
17
|
const generateGitignore = require('./utils/generate-gitignore');
|
|
18
18
|
const log = require('../utils/log');
|
|
19
19
|
const config = require('../config');
|
|
20
|
+
const initZMPUI = require('./init-zmp-ui');
|
|
20
21
|
|
|
21
22
|
const waitText = chalk.gray('(Please wait, it can take a while)');
|
|
22
23
|
|
|
@@ -25,6 +26,10 @@ module.exports = async (
|
|
|
25
26
|
logger,
|
|
26
27
|
{ exitOnError = true, iconFile = null } = {}
|
|
27
28
|
) => {
|
|
29
|
+
if (options.newProject && options.package === 'zmp-ui') {
|
|
30
|
+
await initZMPUI(options, logger);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
28
33
|
const cwd = options.cwd || process.cwd();
|
|
29
34
|
const isRunningInCwd = cwd === process.cwd();
|
|
30
35
|
function errorExit(err) {
|
|
@@ -91,16 +91,11 @@ module.exports = async (
|
|
|
91
91
|
)} && npm install ${packageJson.dependencies.join(' ')} --save`,
|
|
92
92
|
true
|
|
93
93
|
);
|
|
94
|
-
await exec.promise(
|
|
95
|
-
`cd ${cwd.replace(/ /g, '\\ ')} && npm install --save`,
|
|
96
|
-
true
|
|
97
|
-
);
|
|
98
94
|
} else {
|
|
99
95
|
await exec.promise(
|
|
100
96
|
`npm install ${packageJson.dependencies.join(' ')} --save`,
|
|
101
97
|
true
|
|
102
98
|
);
|
|
103
|
-
await exec.promise(`npm install --save`, true);
|
|
104
99
|
}
|
|
105
100
|
} catch (err) {
|
|
106
101
|
logger.statusError('Error installing NPM Dependencies');
|
|
@@ -157,6 +152,7 @@ module.exports = async (
|
|
|
157
152
|
// Create Project Files
|
|
158
153
|
logger.statusStart('Creating project files');
|
|
159
154
|
const filesToCopy = copyAssets(options, iconFile);
|
|
155
|
+
console.log(filesToCopy);
|
|
160
156
|
try {
|
|
161
157
|
// eslint-disable-next-line
|
|
162
158
|
await Promise.all(
|
|
@@ -17,7 +17,7 @@ const copyZauiAssets = require('./zaui/copy-assets');
|
|
|
17
17
|
module.exports = (options, iconFile) => {
|
|
18
18
|
const cwd = options.cwd || process.cwd();
|
|
19
19
|
const {
|
|
20
|
-
|
|
20
|
+
package,
|
|
21
21
|
framework,
|
|
22
22
|
theming,
|
|
23
23
|
cssPreProcessor,
|
|
@@ -35,7 +35,7 @@ module.exports = (options, iconFile) => {
|
|
|
35
35
|
if (framework === 'react-typescript') {
|
|
36
36
|
toCopy.push(...copyReactTsAssets(options));
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
38
|
+
if (package === 'zmp-ui') {
|
|
39
39
|
toCopy.push(...copyZauiAssets(options));
|
|
40
40
|
}
|
|
41
41
|
if (theming.iconFonts) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const generateCoreRoot = require('./core/generate-root.js');
|
|
3
3
|
|
|
4
4
|
module.exports = (options) => {
|
|
5
|
-
const { name, framework, theming,
|
|
5
|
+
const { name, framework, theming, package } = options;
|
|
6
6
|
const srcFolder = '/src/';
|
|
7
7
|
const iconsAssetsFolder = 'static';
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ module.exports = (options) => {
|
|
|
10
10
|
const scripts = `
|
|
11
11
|
<!-- built script files will be auto injected -->
|
|
12
12
|
${
|
|
13
|
-
|
|
13
|
+
package === 'zmp-ui' || framework === 'react' || framework === 'vue'
|
|
14
14
|
? `<script type="module" src="${srcFolder}app.js"></script>`
|
|
15
15
|
: ''
|
|
16
16
|
}
|
|
@@ -5,12 +5,12 @@ const generateSvelteScripts = require('./svelte/generate-scripts');
|
|
|
5
5
|
const generateReactTsScripts = require('./react-typescript/generate-scripts');
|
|
6
6
|
const generateZauiScripts = require('./zaui/generate-scripts');
|
|
7
7
|
module.exports = (options) => {
|
|
8
|
-
const { framework,
|
|
8
|
+
const { framework, package } = options;
|
|
9
9
|
if (framework === 'core') return generateCoreScripts(options);
|
|
10
10
|
if (framework === 'vue') return generateVueScripts(options);
|
|
11
11
|
if (framework === 'react') return generateReactScripts(options);
|
|
12
12
|
if (framework === 'svelte') return generateSvelteScripts(options);
|
|
13
13
|
if (framework === 'react-typescript') return generateReactTsScripts(options);
|
|
14
|
-
if (
|
|
14
|
+
if (package === 'zmp-ui') return generateZauiScripts(options);
|
|
15
15
|
return '';
|
|
16
16
|
};
|
|
@@ -2,25 +2,23 @@ const indent = require('../utils/indent');
|
|
|
2
2
|
const { colorThemeCSSProperties } = require('../utils/colors');
|
|
3
3
|
|
|
4
4
|
module.exports = (options) => {
|
|
5
|
-
const { template, theming,
|
|
5
|
+
const { template, theming, package } = options;
|
|
6
6
|
const { customColor, color, fillBars } = theming;
|
|
7
7
|
|
|
8
8
|
let styles = '';
|
|
9
9
|
|
|
10
|
-
if (
|
|
10
|
+
if (package === 'zmp-ui') {
|
|
11
11
|
return `
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
.page {
|
|
13
|
+
padding: 16px 16px 96px 16px;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
height: 100%;
|
|
18
|
-
}
|
|
19
|
-
.page{
|
|
15
|
+
|
|
16
|
+
.section-container {
|
|
20
17
|
padding: 16px;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
background: #ffffff;
|
|
19
|
+
border-radius: 8px;
|
|
20
|
+
margin-bottom: 24px;
|
|
21
|
+
}
|
|
24
22
|
`;
|
|
25
23
|
}
|
|
26
24
|
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Avatar } from '
|
|
2
|
+
import { Avatar, Box, Text } from 'zmp-ui';
|
|
3
3
|
|
|
4
4
|
const UserCard = ({ user }) => {
|
|
5
5
|
return (
|
|
6
|
-
<
|
|
7
|
-
<Avatar story online src={user.avatar.startsWith('http') ? user.avatar : null}>{user.avatar}</Avatar>
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
</
|
|
12
|
-
</
|
|
6
|
+
<Box flex>
|
|
7
|
+
<Avatar story='default' online src={user.avatar.startsWith('http') ? user.avatar : null}>{user.avatar}</Avatar>
|
|
8
|
+
<Box ml={4}>
|
|
9
|
+
<Text.Title>{user.name}</Text.Title>
|
|
10
|
+
<Text>{user.id}</Text>
|
|
11
|
+
</Box>
|
|
12
|
+
</Box>
|
|
13
13
|
)
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
UserCard.displayName = 'zmp-user-card'
|
|
17
|
-
|
|
18
16
|
export default UserCard;
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
const indent = require('../../utils/indent');
|
|
2
2
|
module.exports = (options) => {
|
|
3
3
|
const { name, template, theming, stateManagement } = options;
|
|
4
|
-
const { fillBars } = theming;
|
|
5
|
-
|
|
6
|
-
let description = '';
|
|
7
|
-
if (template === 'single-view' || template === 'blank') {
|
|
8
|
-
description = `
|
|
9
|
-
<p>Here is your blank ZMP app. Let's see what we have here.</p>
|
|
10
|
-
`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
4
|
return indent(
|
|
14
5
|
0,
|
|
15
6
|
`
|
|
@@ -17,23 +8,49 @@ module.exports = (options) => {
|
|
|
17
8
|
${
|
|
18
9
|
template === 'blank'
|
|
19
10
|
? `
|
|
11
|
+
import {
|
|
12
|
+
Page
|
|
13
|
+
} from 'zmp-ui';
|
|
20
14
|
`.trim()
|
|
21
15
|
: `
|
|
22
16
|
import {
|
|
23
17
|
List,
|
|
24
|
-
|
|
18
|
+
Page,
|
|
19
|
+
Icon
|
|
20
|
+
} from 'zmp-ui';${stateManagement === 'recoil' ? `
|
|
25
21
|
import { useRecoilValue } from 'recoil';
|
|
26
22
|
import { userState } from '../state';` : ''}
|
|
23
|
+
${template !=='blank' ?`
|
|
27
24
|
import UserCard from '../components/user-card';
|
|
25
|
+
import { useNavigate } from 'react-router-dom'
|
|
26
|
+
`:''}
|
|
28
27
|
`.trim()
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
const HomePage = () => {
|
|
32
31
|
${template !== 'blank' ? (stateManagement === 'recoil' ? "const user = useRecoilValue(userState);" : "const user = useStore('user');") : ''}
|
|
32
|
+
${template !=='blank' && `const navigate = useNavigate();`}
|
|
33
33
|
return (
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
${template==='blank' ?`<Page name="home" className="page">
|
|
35
|
+
Hello Zalo Mini App
|
|
36
|
+
</Page> `.trim():
|
|
37
|
+
`
|
|
38
|
+
<Page name="home" className="page">
|
|
39
|
+
<div className="section-container">
|
|
40
|
+
<UserCard user={user}/>
|
|
41
|
+
</div>
|
|
42
|
+
<div className="section-container">
|
|
43
|
+
<List >
|
|
44
|
+
<List.Item suffix={<Icon icon="zi-arrow-right"/>}>
|
|
45
|
+
<div onClick={()=>navigate('/about')}>About</div>
|
|
46
|
+
</List.Item>
|
|
47
|
+
<List.Item suffix={<Icon icon="zi-arrow-right"/>}>
|
|
48
|
+
<div onClick={()=>navigate('/user')}>User</div>
|
|
49
|
+
</List.Item>
|
|
50
|
+
</List>
|
|
36
51
|
</div>
|
|
52
|
+
</Page>`.trim()
|
|
53
|
+
}
|
|
37
54
|
);
|
|
38
55
|
}
|
|
39
56
|
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
const templateIf = require('../../utils/template-if');
|
|
2
2
|
const indent = require('../../utils/indent');
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const { capitalize } = require('../../utils/string')
|
|
5
4
|
module.exports = (options) => {
|
|
6
5
|
const { template, theming, stateManagement } = options;
|
|
7
6
|
|
|
8
7
|
// Views
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
const routes = []
|
|
10
|
+
if(template ==='single-view'){
|
|
11
|
+
routes.push('about','form','user')
|
|
12
|
+
}
|
|
11
13
|
return indent(
|
|
12
14
|
0,
|
|
13
15
|
`
|
|
14
16
|
import React from 'react';
|
|
15
|
-
import {
|
|
17
|
+
import { Route} from 'react-router-dom'
|
|
16
18
|
import HomePage from '../pages';
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
+
${routes.length && routes.map((route) => ` import ${capitalize(route)} from '../pages/${route}';\n`).join('').trim()}
|
|
19
20
|
${['blank', 'single-view'].indexOf(template) >= 0
|
|
20
21
|
&& `
|
|
21
|
-
import { App } from '
|
|
22
|
+
import { App, ZMPRouter, AnimationRoutes } from 'zmp-ui';
|
|
22
23
|
`.trim()
|
|
23
24
|
}
|
|
24
25
|
${templateIf(stateManagement === 'recoil', () => `import { RecoilRoot } from 'recoil';`,'')}
|
|
@@ -29,11 +30,16 @@ module.exports = (options) => {
|
|
|
29
30
|
return (${stateManagement === 'recoil' ? `
|
|
30
31
|
<RecoilRoot>` : ''}
|
|
31
32
|
${indent(stateManagement === 'recoil' ? 2 : 0, `<App ${theming.darkTheme ? 'themeDark' : ''}>`)}
|
|
32
|
-
<
|
|
33
|
-
<
|
|
33
|
+
<ZMPRouter>
|
|
34
|
+
<AnimationRoutes>
|
|
34
35
|
<Route path="/" element={<HomePage></HomePage>}></Route>
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
${routes.length && routes.map((route) =>{
|
|
37
|
+
const pageName = capitalize(route)
|
|
38
|
+
return ` <Route path="/${route}" element={<${pageName}></${pageName}>}></Route>\n`
|
|
39
|
+
}).join('').trim()
|
|
40
|
+
}
|
|
41
|
+
</AnimationRoutes>
|
|
42
|
+
</ZMPRouter>
|
|
37
43
|
${indent(stateManagement === 'recoil' ? 2 : 0, `</App>`)}${stateManagement === 'recoil' ? `
|
|
38
44
|
</RecoilRoot>` : ''}
|
|
39
45
|
);
|
|
@@ -2,7 +2,7 @@ const indent = require('../../utils/indent');
|
|
|
2
2
|
const stylesExtension = require('../../utils/styles-extension');
|
|
3
3
|
|
|
4
4
|
module.exports = (options) => {
|
|
5
|
-
const { cssPreProcessor,
|
|
5
|
+
const { cssPreProcessor, includeTailwind } = options;
|
|
6
6
|
|
|
7
7
|
let scripts = '';
|
|
8
8
|
|
|
@@ -17,7 +17,7 @@ module.exports = (options) => {
|
|
|
17
17
|
// Import tailwind styles
|
|
18
18
|
import './css/tailwind.css';` : ''}
|
|
19
19
|
|
|
20
|
-
import '
|
|
20
|
+
import 'zmp-ui/zaui.css';
|
|
21
21
|
|
|
22
22
|
import './css/app.${stylesExtension(cssPreProcessor)}';
|
|
23
23
|
|
|
@@ -5,14 +5,18 @@ module.exports = (options) => {
|
|
|
5
5
|
return indent(
|
|
6
6
|
0,
|
|
7
7
|
`
|
|
8
|
-
import React from
|
|
9
|
-
import { Sheet, Button } from
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { Sheet, Button, Page, Text } from "zmp-ui";
|
|
10
|
+
import { useNavigate } from 'react-router-dom'
|
|
10
11
|
|
|
11
12
|
const AboutPage = (props) => {
|
|
12
13
|
const [actionSheetOpened, setActionSheetOpened] = React.useState(false);
|
|
13
|
-
|
|
14
|
+
const navigate = useNavigate()
|
|
14
15
|
return (
|
|
15
|
-
<
|
|
16
|
+
<Page className="page">
|
|
17
|
+
<div className="section-container">
|
|
18
|
+
<Text>This mini app was generated by zmp-cli</Text>
|
|
19
|
+
</div>
|
|
16
20
|
<div>
|
|
17
21
|
<Button
|
|
18
22
|
type="secondary"
|
|
@@ -22,26 +26,42 @@ module.exports = (options) => {
|
|
|
22
26
|
Back
|
|
23
27
|
</Button>
|
|
24
28
|
</div>
|
|
25
|
-
<Sheet
|
|
29
|
+
<Sheet.Actions
|
|
26
30
|
visible={actionSheetOpened}
|
|
27
31
|
onClose={() => setActionSheetOpened(false)}
|
|
28
32
|
id="actions-two-groups"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
actions={[
|
|
34
|
+
[
|
|
35
|
+
{
|
|
36
|
+
text: "Go back",
|
|
37
|
+
onClick: () => {
|
|
38
|
+
navigate(-1);
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
text: "Action 1",
|
|
43
|
+
close: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
text: "Action 2",
|
|
47
|
+
close: true,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
{
|
|
52
|
+
text: "Close",
|
|
53
|
+
close: true,
|
|
54
|
+
danger: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
]}
|
|
58
|
+
></Sheet.Actions>
|
|
59
|
+
</Page>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
43
62
|
|
|
44
63
|
export default AboutPage;
|
|
64
|
+
|
|
45
65
|
`
|
|
46
66
|
).trim();
|
|
47
67
|
};
|
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
const indent = require('../../../utils/indent');
|
|
2
2
|
|
|
3
3
|
module.exports = (options) => {
|
|
4
|
-
const { template } = options
|
|
5
4
|
return indent(
|
|
6
5
|
0,
|
|
7
6
|
`
|
|
8
7
|
import React from 'react';
|
|
9
|
-
import { Button,Input } from '
|
|
8
|
+
import { Button,Input, Box, Page } from 'zmp-ui';
|
|
10
9
|
import { useRecoilState } from 'recoil';
|
|
11
10
|
import { userState } from '../state';
|
|
12
|
-
|
|
11
|
+
|
|
13
12
|
const FormPage = () => {
|
|
14
13
|
const [user, setUser] = useRecoilState(userState)
|
|
15
|
-
|
|
14
|
+
|
|
16
15
|
const [form, setForm] = React.useState({ ...user });
|
|
17
|
-
|
|
16
|
+
|
|
18
17
|
const handleChangeInput = (field, value) => {
|
|
19
18
|
setForm({ ...form, [field]: value })
|
|
20
19
|
}
|
|
21
|
-
|
|
20
|
+
|
|
22
21
|
const handleSubmit = () => {
|
|
23
22
|
alert('saved');
|
|
24
23
|
setUser(form);
|
|
25
|
-
toast.current.open()
|
|
26
24
|
}
|
|
27
|
-
|
|
25
|
+
|
|
28
26
|
return (
|
|
29
|
-
<
|
|
30
|
-
<div>
|
|
31
|
-
<
|
|
27
|
+
<Page className="page">
|
|
28
|
+
<div className='section-container'>
|
|
29
|
+
<Box >
|
|
32
30
|
<Input
|
|
33
31
|
id="name"
|
|
34
32
|
label="Name"
|
|
@@ -44,17 +42,17 @@ module.exports = (options) => {
|
|
|
44
42
|
value={form?.avatar}
|
|
45
43
|
onChange={(e) => handleChangeInput('avatar', e.target.value)}
|
|
46
44
|
/>
|
|
47
|
-
<
|
|
45
|
+
<Box mt={4}>
|
|
48
46
|
<Button size="full-width" type="primary" onClick={handleSubmit}>
|
|
49
47
|
Submit
|
|
50
48
|
</Button>
|
|
51
49
|
</Box>
|
|
52
|
-
</
|
|
50
|
+
</Box>
|
|
53
51
|
</div>
|
|
54
|
-
</
|
|
52
|
+
</Page>
|
|
55
53
|
)
|
|
56
54
|
}
|
|
57
|
-
|
|
55
|
+
|
|
58
56
|
export default FormPage;
|
|
59
57
|
`
|
|
60
58
|
).trim();
|
|
@@ -2,43 +2,54 @@ const indent = require('../../../utils/indent');
|
|
|
2
2
|
|
|
3
3
|
module.exports = (options) => {
|
|
4
4
|
const { template, stateManagement } = options;
|
|
5
|
-
const
|
|
6
|
-
template === 'tabs'
|
|
7
|
-
? `
|
|
8
|
-
onPageBeforeIn={()=>{
|
|
9
|
-
//hide navbar
|
|
10
|
-
zmp.toolbar.hide('#app-tab-bar')
|
|
11
|
-
}}`
|
|
12
|
-
: '';
|
|
13
|
-
const modules = ['Avatar', 'List'];
|
|
5
|
+
const modules = ['Avatar', 'List', 'Page', 'Box', 'Text'];
|
|
14
6
|
|
|
15
7
|
return indent(
|
|
16
8
|
0,
|
|
17
9
|
`
|
|
18
|
-
import React from
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
import { useRecoilValue } from
|
|
22
|
-
import { userState } from
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { Avatar, List, Text, Box, Page, Button, Icon } from "zmp-ui";
|
|
12
|
+
import {useNavigate} from 'react-router-dom';
|
|
13
|
+
import { useRecoilValue } from "recoil";
|
|
14
|
+
import { userState } from "../state";
|
|
23
15
|
|
|
24
16
|
const UserPage = () => {
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
const user = useRecoilValue(userState);
|
|
18
|
+
const navigate = useNavigate()
|
|
27
19
|
return (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
20
|
+
<Page className="page">
|
|
21
|
+
<Box flex flexDirection="column" justifyContent="center" alignItems="center">
|
|
22
|
+
<Box>
|
|
23
|
+
<Avatar
|
|
24
|
+
story
|
|
25
|
+
size={96}
|
|
26
|
+
online
|
|
27
|
+
src={user.avatar.startsWith("http") ? user.avatar : null}
|
|
28
|
+
>
|
|
29
|
+
{user.avatar}
|
|
30
|
+
</Avatar>
|
|
31
|
+
</Box>
|
|
32
|
+
<Box flex flexDirection="row" alignItems="center" ml={8}>
|
|
33
|
+
<Box>
|
|
34
|
+
<Text.Title >{user.name}</Text.Title>
|
|
35
|
+
</Box>
|
|
36
|
+
<Box ml={4}>
|
|
37
|
+
<Button onClick={()=>{navigate('/form')}} size='small' icon={<Icon icon="zi-edit"/>}/>
|
|
38
|
+
</Box>
|
|
39
|
+
</Box>
|
|
40
|
+
</Box>
|
|
41
|
+
<Box m={0} p={0} mt={4}>
|
|
42
|
+
<div className="section-container">
|
|
43
|
+
<List>
|
|
44
|
+
<List.Item title="Display name" subTitle={user.name} />
|
|
45
|
+
<List.Item title="ID" subTitle={user.id} />
|
|
46
|
+
</List>
|
|
47
|
+
</div>
|
|
48
|
+
</Box>
|
|
49
|
+
|
|
50
|
+
</Page>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
42
53
|
|
|
43
54
|
export default UserPage;
|
|
44
55
|
`
|
|
@@ -4,15 +4,16 @@ const { generateTailWindScripts } = require('./generate-npm-scripts');
|
|
|
4
4
|
module.exports = function generatePackageJson(options) {
|
|
5
5
|
const {
|
|
6
6
|
name,
|
|
7
|
+
package,
|
|
7
8
|
framework,
|
|
8
9
|
cssPreProcessor,
|
|
9
10
|
includeTailwind,
|
|
10
11
|
stateManagement,
|
|
11
|
-
zaui,
|
|
12
12
|
} = options;
|
|
13
13
|
|
|
14
14
|
// Dependencies
|
|
15
|
-
const dependencies =
|
|
15
|
+
const dependencies =
|
|
16
|
+
package === 'zmp-ui' ? ['zmp-ui'] : ['zmp-framework', 'zmp-sdk', 'swiper'];
|
|
16
17
|
const dependenciesVue = ['vue@3', 'zmp-framework'];
|
|
17
18
|
const dependenciesReact = ['react', 'react-dom', 'prop-types'];
|
|
18
19
|
const dependenciesReactTs = ['@types/react', '@types/react-dom'];
|
|
@@ -67,8 +68,8 @@ module.exports = function generatePackageJson(options) {
|
|
|
67
68
|
...(includeTailwind ? tailwindDependencies : [])
|
|
68
69
|
);
|
|
69
70
|
|
|
70
|
-
if (
|
|
71
|
-
dependencies.push('
|
|
71
|
+
if (package === 'zmp-ui') {
|
|
72
|
+
dependencies.push('recoil');
|
|
72
73
|
devDependencies.push(
|
|
73
74
|
...[devDependenciesReact],
|
|
74
75
|
...(includeTailwind ? tailwindDependencies : [])
|
|
@@ -112,13 +113,7 @@ module.exports = function generatePackageJson(options) {
|
|
|
112
113
|
"Samsung >= 5"
|
|
113
114
|
],
|
|
114
115
|
"scripts" : ${JSON.stringify(scripts)},
|
|
115
|
-
"dependencies": {
|
|
116
|
-
${
|
|
117
|
-
zaui
|
|
118
|
-
? `"zaui": "https://stc-zmp.zadn.vn/zaui/zaui-1.0.0-alpha.1.tgz"`
|
|
119
|
-
: ''
|
|
120
|
-
}
|
|
121
|
-
},
|
|
116
|
+
"dependencies": {},
|
|
122
117
|
"devDependencies": {}
|
|
123
118
|
}
|
|
124
119
|
`.trim();
|
|
@@ -27,11 +27,27 @@ const questions = [
|
|
|
27
27
|
});
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
|
+
{
|
|
31
|
+
type: 'list',
|
|
32
|
+
name: 'package',
|
|
33
|
+
when: (opts) => opts.newProject,
|
|
34
|
+
message: 'Choose an UI library / UI framework:',
|
|
35
|
+
choices: [
|
|
36
|
+
{
|
|
37
|
+
name: 'zmp-framework',
|
|
38
|
+
value: 'zmp-framework',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'zmp-ui (beta)',
|
|
42
|
+
value: 'zmp-ui',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
30
46
|
// Framework
|
|
31
47
|
{
|
|
32
48
|
type: 'list',
|
|
33
49
|
name: 'framework',
|
|
34
|
-
when: (opts) => opts.
|
|
50
|
+
when: (opts) => opts.package == 'zmp-framework',
|
|
35
51
|
message: 'What type of framework do you prefer?',
|
|
36
52
|
choices: [
|
|
37
53
|
{
|
|
@@ -53,10 +69,28 @@ const questions = [
|
|
|
53
69
|
},
|
|
54
70
|
],
|
|
55
71
|
},
|
|
72
|
+
{
|
|
73
|
+
type: 'list',
|
|
74
|
+
name: 'language',
|
|
75
|
+
when: (opts) => opts.package == 'zmp-ui',
|
|
76
|
+
message: 'What language do you prefer?',
|
|
77
|
+
choices: [
|
|
78
|
+
{
|
|
79
|
+
name: 'ReactJS',
|
|
80
|
+
value: 'react',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'React (TypeScript)',
|
|
84
|
+
value: 'typescript',
|
|
85
|
+
disabled: true,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
56
89
|
{
|
|
57
90
|
type: 'list',
|
|
58
91
|
name: 'useUIKits',
|
|
59
|
-
when: (opts) =>
|
|
92
|
+
when: (opts) =>
|
|
93
|
+
opts.package === 'zmp-framework' && opts.framework !== 'vue',
|
|
60
94
|
message: 'Do you want to use Zalo UI kits style?',
|
|
61
95
|
default: true,
|
|
62
96
|
choices: [
|
|
@@ -70,13 +104,15 @@ const questions = [
|
|
|
70
104
|
},
|
|
71
105
|
],
|
|
72
106
|
},
|
|
73
|
-
|
|
74
107
|
// Template
|
|
75
108
|
{
|
|
76
109
|
type: 'list',
|
|
77
110
|
name: 'template',
|
|
78
111
|
when: (opts) =>
|
|
79
|
-
opts.newProject &&
|
|
112
|
+
opts.newProject &&
|
|
113
|
+
opts.package === 'zmp-framework' &&
|
|
114
|
+
opts.useUIKits &&
|
|
115
|
+
opts.framework !== 'vue',
|
|
80
116
|
message: 'Choose starter template:',
|
|
81
117
|
choices: [
|
|
82
118
|
{
|
|
@@ -98,7 +134,10 @@ const questions = [
|
|
|
98
134
|
type: 'list',
|
|
99
135
|
name: 'template',
|
|
100
136
|
when: (opts) =>
|
|
101
|
-
opts.newProject &&
|
|
137
|
+
opts.newProject &&
|
|
138
|
+
opts.package === 'zmp-framework' &&
|
|
139
|
+
!opts.useUIKits &&
|
|
140
|
+
opts.framework !== 'vue',
|
|
102
141
|
message: 'Choose starter template:',
|
|
103
142
|
choices: [
|
|
104
143
|
{
|
|
@@ -132,12 +171,28 @@ const questions = [
|
|
|
132
171
|
},
|
|
133
172
|
],
|
|
134
173
|
},
|
|
135
|
-
|
|
174
|
+
// Template
|
|
175
|
+
{
|
|
176
|
+
type: 'list',
|
|
177
|
+
name: 'template',
|
|
178
|
+
when: (opts) => opts.package === 'zmp-ui',
|
|
179
|
+
message: 'Choose starter template:',
|
|
180
|
+
choices: [
|
|
181
|
+
{
|
|
182
|
+
name: 'Blank',
|
|
183
|
+
value: 'blank',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: 'Single View',
|
|
187
|
+
value: 'single-view',
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
},
|
|
136
191
|
// Color
|
|
137
192
|
{
|
|
138
193
|
type: 'list',
|
|
139
194
|
name: 'themingCustomColor',
|
|
140
|
-
when: (opts) => opts.newProject,
|
|
195
|
+
when: (opts) => opts.newProject && opts.package !== 'zmp-ui',
|
|
141
196
|
message: 'Do you want to specify custom theme color?',
|
|
142
197
|
choices: [
|
|
143
198
|
{
|
|
@@ -169,7 +224,7 @@ const questions = [
|
|
|
169
224
|
{
|
|
170
225
|
type: 'list',
|
|
171
226
|
name: 'themingIconFonts',
|
|
172
|
-
when: (opts) => opts.newProject,
|
|
227
|
+
when: (opts) => opts.newProject && opts.package !== 'zmp-ui',
|
|
173
228
|
message: 'Do you want to include ZMP Icons and Material Icons icon fonts?',
|
|
174
229
|
default: true,
|
|
175
230
|
choices: [
|
|
@@ -238,126 +293,9 @@ const questions = [
|
|
|
238
293
|
],
|
|
239
294
|
},
|
|
240
295
|
];
|
|
241
|
-
const zauiQuestions = [
|
|
242
|
-
{
|
|
243
|
-
type: 'list',
|
|
244
|
-
name: 'newProject',
|
|
245
|
-
message: 'What action you want to do?',
|
|
246
|
-
choices: [
|
|
247
|
-
{ name: 'Create a new ZMP project', value: true },
|
|
248
|
-
{ name: 'Using ZMP to deploy only', value: false },
|
|
249
|
-
],
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
type: 'input',
|
|
253
|
-
name: 'name',
|
|
254
|
-
message: 'App (project) name:',
|
|
255
|
-
default: 'My App',
|
|
256
|
-
validate(input) {
|
|
257
|
-
return new Promise((resolve, reject) => {
|
|
258
|
-
if (!input) reject(new Error('App name is required'));
|
|
259
|
-
else resolve(true);
|
|
260
|
-
});
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
// Framework
|
|
264
|
-
{
|
|
265
|
-
type: 'list',
|
|
266
|
-
name: 'zaui',
|
|
267
|
-
when: (opts) => opts.newProject,
|
|
268
|
-
message: 'What type of framework do you prefer?',
|
|
269
|
-
choices: [
|
|
270
|
-
{
|
|
271
|
-
name: 'ZMP with React',
|
|
272
|
-
value: 'react',
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
name: 'ZMP with React (TypeScript)',
|
|
276
|
-
value: 'react-typescript',
|
|
277
|
-
disabled: true,
|
|
278
|
-
},
|
|
279
|
-
],
|
|
280
|
-
},
|
|
281
296
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
type: 'list',
|
|
285
|
-
name: 'template',
|
|
286
|
-
when: (opts) => opts.newProject,
|
|
287
|
-
message: 'Choose starter template:',
|
|
288
|
-
choices: [
|
|
289
|
-
{
|
|
290
|
-
name: 'Blank',
|
|
291
|
-
value: 'blank',
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
name: 'Single View',
|
|
295
|
-
value: 'single-view',
|
|
296
|
-
},
|
|
297
|
-
],
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
type: 'list',
|
|
301
|
-
name: 'cssPreProcessor',
|
|
302
|
-
when: (opts) => opts.newProject,
|
|
303
|
-
message: 'Do you want to setup CSS Pre-Processor',
|
|
304
|
-
default: false,
|
|
305
|
-
choices: [
|
|
306
|
-
{
|
|
307
|
-
name: 'No, i am good with CSS',
|
|
308
|
-
value: false,
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
name: 'Less',
|
|
312
|
-
value: 'less',
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
name: 'SCSS (SASS)',
|
|
316
|
-
value: 'scss',
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
name: 'Stylus',
|
|
320
|
-
value: 'stylus',
|
|
321
|
-
},
|
|
322
|
-
],
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
type: 'list',
|
|
326
|
-
name: 'moreOptions',
|
|
327
|
-
when: (opts) => opts.newProject,
|
|
328
|
-
message: `More Options?\n${moreOptionsText}`,
|
|
329
|
-
default: false,
|
|
330
|
-
choices: [
|
|
331
|
-
{
|
|
332
|
-
name: 'No, I want to complete initializing process now',
|
|
333
|
-
value: false,
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
name: 'Yes, I want to get more options',
|
|
337
|
-
value: true,
|
|
338
|
-
},
|
|
339
|
-
],
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
type: 'list',
|
|
343
|
-
name: 'includeTailwind',
|
|
344
|
-
when: (opts) => opts.moreOptions,
|
|
345
|
-
message: 'Do you want to include Tailwind CSS?',
|
|
346
|
-
default: true,
|
|
347
|
-
choices: [
|
|
348
|
-
{
|
|
349
|
-
name: 'Yes, I want to iclude Tailwind CSS',
|
|
350
|
-
value: true,
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
name: 'No',
|
|
354
|
-
value: false,
|
|
355
|
-
},
|
|
356
|
-
],
|
|
357
|
-
},
|
|
358
|
-
];
|
|
359
|
-
module.exports = function getOptions(zaui = false) {
|
|
360
|
-
const listQuestion = zaui ? zauiQuestions : questions;
|
|
297
|
+
module.exports = function getOptions() {
|
|
298
|
+
const listQuestion = questions;
|
|
361
299
|
return inquirer.prompt(listQuestion).then((options) => {
|
|
362
300
|
options.theming = {
|
|
363
301
|
customColor: options.themingCustomColor,
|
|
@@ -375,7 +313,7 @@ module.exports = function getOptions(zaui = false) {
|
|
|
375
313
|
if (!options.stateManagement) {
|
|
376
314
|
options.stateManagement = 'store';
|
|
377
315
|
}
|
|
378
|
-
if (options.
|
|
316
|
+
if (options.package === 'zmp-ui') {
|
|
379
317
|
options.stateManagement = 'recoil';
|
|
380
318
|
}
|
|
381
319
|
delete options.themingCustomColor;
|
package/index.js
CHANGED
|
@@ -25,7 +25,6 @@ const os = require('os');
|
|
|
25
25
|
// const server = require('./ui/server');
|
|
26
26
|
const pkg = require('./package.json');
|
|
27
27
|
const config = require('./config');
|
|
28
|
-
const createAppUsingZaui = require('./create/init-zaui');
|
|
29
28
|
|
|
30
29
|
const cwd = process.cwd();
|
|
31
30
|
|
|
@@ -82,29 +81,6 @@ program
|
|
|
82
81
|
process.exit(0);
|
|
83
82
|
});
|
|
84
83
|
|
|
85
|
-
program
|
|
86
|
-
.version(pkg.version)
|
|
87
|
-
.usage('<command> [options]')
|
|
88
|
-
.command('init-zaui')
|
|
89
|
-
.option('--skipUpdate', 'Skip checking for update of zmp-cli')
|
|
90
|
-
.description('Init ZMP project using Zaui UI library')
|
|
91
|
-
.action(async (options) => {
|
|
92
|
-
if (!options.skipUpdate) await checkUpdate();
|
|
93
|
-
|
|
94
|
-
const currentProject = getCurrentProject(cwd);
|
|
95
|
-
if (currentProject) {
|
|
96
|
-
log.text(
|
|
97
|
-
`${logSymbols.error} ZMP project already set up in current directory`
|
|
98
|
-
);
|
|
99
|
-
process.exit(1);
|
|
100
|
-
}
|
|
101
|
-
const optsLogin = await getLoginOptions();
|
|
102
|
-
await loginApp({ cwd, ...optsLogin }, logger);
|
|
103
|
-
const opts = await getOptions(true);
|
|
104
|
-
await createAppUsingZaui({ cwd, ...opts }, logger);
|
|
105
|
-
process.exit(0);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
84
|
program
|
|
109
85
|
.usage('<command> [options]')
|
|
110
86
|
.command('login')
|
package/package.json
CHANGED