zmp-cli 3.7.1 → 3.8.0-0

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 (33) hide show
  1. package/assets/index.js +0 -0
  2. package/build/index.js +0 -0
  3. package/config/index.js +0 -0
  4. package/create/index.js +0 -0
  5. package/create/templates/react/copy-assets.js +13 -4
  6. package/create/templates/react/generate-home-page.js +25 -8
  7. package/create/templates/react/generate-root.js +26 -176
  8. package/create/templates/react/generate-routes.js +1 -1
  9. package/create/templates/react/pages/catalog.jsx +18 -16
  10. package/create/templates/react/pages/form-tabs.jsx +64 -0
  11. package/create/templates/react/pages/settings.jsx +16 -163
  12. package/create/templates/react/pages/user-tabs.jsx +31 -0
  13. package/create/templates/react-typescript/copy-assets.js +8 -0
  14. package/create/templates/react-typescript/generate-home-page.js +26 -8
  15. package/create/templates/react-typescript/generate-root.js +43 -2
  16. package/create/templates/react-typescript/generate-routes.js +3 -1
  17. package/create/templates/react-typescript/pages/404.js +2 -1
  18. package/create/templates/react-typescript/pages/about.js +1 -0
  19. package/create/templates/react-typescript/pages/catalog.js +60 -0
  20. package/create/templates/react-typescript/pages/dynamic-route.js +1 -0
  21. package/create/templates/react-typescript/pages/form.js +13 -1
  22. package/create/templates/react-typescript/pages/index.js +4 -0
  23. package/create/templates/react-typescript/pages/settings.js +39 -0
  24. package/create/templates/react-typescript/pages/user.js +17 -2
  25. package/create/utils/generate-package-json.js +4 -4
  26. package/create/utils/get-options.js +5 -9
  27. package/deploy/index.js +0 -0
  28. package/login/index.js +0 -0
  29. package/migrate/index.js +0 -0
  30. package/package.json +2 -2
  31. package/scripts/dist/release.dev.js +105 -0
  32. package/start/frame/index.html +255 -129
  33. package/start/index.js +0 -0
@@ -0,0 +1,31 @@
1
+ import React from 'react'
2
+
3
+ import { Avatar, zmp, List, ListItem, Page, Title, useStore } from 'zmp-framework/react'
4
+ import NavbarBack from '../components/navbar-back'
5
+
6
+ const UserPage = () => {
7
+ const user = useStore('user')
8
+
9
+ return (
10
+ <Page name="user" onPageBeforeIn={()=>{
11
+ // hide navbar
12
+ zmp.toolbar.hide('#app-tab-bar')
13
+ }}>
14
+ <NavbarBack
15
+ title="User info"
16
+ linkRight="/form"
17
+ labelRight="Edit"
18
+ />
19
+ <div style={{ textAlign: 'center', marginTop: 32 }}>
20
+ <Avatar story online size={96}>{user.avatar}</Avatar>
21
+ <Title style={{ marginTop: 8 }}>{user.displayName}</Title>
22
+ </div>
23
+ <List>
24
+ <ListItem title="Display name" after={user.displayName} />
25
+ <ListItem title="Email" after={user.email} />
26
+ </List>
27
+ </Page>
28
+ )
29
+ }
30
+
31
+ export default UserPage;
@@ -23,6 +23,14 @@ module.exports = (options) => {
23
23
  { fileName: 'form', content: 'copyForm' },
24
24
  ]
25
25
  );
26
+ if (template === 'tabs') {
27
+ pages.push(
28
+ ...[
29
+ { fileName: 'catalog', content: 'copyCatalog' },
30
+ { fileName: 'settings', content: 'copySettings' },
31
+ ]
32
+ );
33
+ }
26
34
 
27
35
  pages.forEach(({ fileName, content }) => {
28
36
  const dest = path.resolve(cwd, 'src', 'pages', `${fileName}.tsx`);
@@ -1,5 +1,4 @@
1
1
  const indent = require('../../utils/indent');
2
-
3
2
  module.exports = (options) => {
4
3
  const { name, template, theming } = options;
5
4
  const { fillBars } = theming;
@@ -21,9 +20,7 @@ module.exports = (options) => {
21
20
  }
22
21
  if (template === 'tabs') {
23
22
  description = `
24
- <p>This is an example of tabs-layout application. The main point of such tabbed layout is that each tab contains independent view with its own routing and navigation.</p>
25
-
26
- <p>Each tab/view may have different layout, different navbar type (dynamic, fixed or static) or without navbar like this tab.</p>
23
+ <p>Here is your blank ZMP app with tabs-layout. Let's see what we have here.</p>
27
24
  `;
28
25
  }
29
26
 
@@ -59,17 +56,21 @@ module.exports = (options) => {
59
56
  const HomePage = () => {
60
57
  ${template !== 'blank' ? "const user = useStore('user');" : ''}
61
58
  return (
62
- <Page name="home" navbarLarge>
63
- {/* Top Navbar */}
59
+ <Page name="home" ${template === 'tabs' ? '' : 'navbarLarge'}>
60
+ ${
61
+ template !== 'tabs'
62
+ ? `{/* Top Navbar */}
64
63
  <Navbar ${fillBars ? 'fill' : ''}>
65
64
  <NavTitleLarge>${name}</NavTitleLarge>
66
- </Navbar>
65
+ </Navbar>`
66
+ : ''
67
+ }
67
68
  {/* Page content */}
68
69
  <Card inset>
69
70
  ${description.trim()}
70
71
  </Card>
71
72
  ${
72
- template !== 'blank'
73
+ template !== 'blank' && template !== 'tabs'
73
74
  ? `
74
75
  {/* User info */}
75
76
  <List>
@@ -84,6 +85,22 @@ module.exports = (options) => {
84
85
  {/* Route */}
85
86
  <List>
86
87
  <ListItem title="Dynamic (Component) Route" link="/dynamic-route/?blog=45&post=125&foo=bar" />
88
+ <ListItem title="Default Route (404)" link="/something-that-doesnt-exist" />
89
+ <ListItem title="About" link="/about/" />
90
+ </List>
91
+ `.trim()
92
+ : ''
93
+ }
94
+ ${
95
+ template === 'tabs'
96
+ ? `
97
+ {/* Grid apps */}
98
+ <AppItems />
99
+
100
+ {/* Route */}
101
+ <List>
102
+ <ListItem title="Dynamic (Component) Route" link="/dynamic-route/?blog=45&post=125&foo=bar" />
103
+ <ListItem title="Default Route (404)" link="/something-that-doesnt-exist" />
87
104
  <ListItem title="About" link="/about/" />
88
105
  </List>
89
106
  `.trim()
@@ -92,6 +109,7 @@ module.exports = (options) => {
92
109
  </Page>
93
110
  );
94
111
  }
112
+
95
113
  export default HomePage;
96
114
  `
97
115
  ).trim();
@@ -18,18 +18,59 @@ module.exports = (options) => {
18
18
  `
19
19
  ).trim();
20
20
  }
21
+ if (template === 'tabs') {
22
+ views = indent(
23
+ 12,
24
+ `
25
+ {/* TabView container */}
26
+ <TabView className="safe-areas">
27
+ {/* Tabbar for switching Tab*/}
28
+ <Tabbar bottom id="app-tab-bar">
29
+ <Link tabLink="#view-home" iconZMP="zi-home" tabLinkActive>
30
+ Home
31
+ </Link>
32
+ <Link tabLink="#view-catalog" iconZMP="zi-list-1">
33
+ Catalog
34
+ </Link>
35
+ <Link tabLink="#view-settings" iconZMP="zi-setting">
36
+ Settings
37
+ </Link>
38
+ </Tabbar>
39
+
40
+ <View id="view-home" main tab tabActive url="/" />
41
+ <View id="view-catalog" name="catalog" tab url="/catalog/" />
42
+ <View id="view-settings" name="settings" tab url="/settings/" />
43
+ </TabView>
44
+ `
45
+ );
46
+ }
47
+
21
48
  return indent(
22
49
  0,
23
50
  `
24
51
  import React from 'react';
25
- ${`
52
+ ${
53
+ ['blank', 'single-view'].indexOf(template) >= 0
54
+ ? `
55
+ import {
56
+ zmp,
57
+ zmpready,
58
+ App,
59
+ View,
60
+ } from 'zmp-framework/react';
61
+ `.trim()
62
+ : `
26
63
  import {
27
64
  zmp,
28
65
  zmpready,
29
66
  App,
67
+ TabView,
30
68
  View,
69
+ Tabbar,
70
+ Link,
31
71
  } from 'zmp-framework/react';
32
- `.trim()}
72
+ `.trim()
73
+ }
33
74
  import store from '../store';
34
75
 
35
76
  const MyApp = () => {
@@ -5,6 +5,8 @@ module.exports = (options) => {
5
5
  return [];
6
6
  }
7
7
  const routes = ['/user', '/form', '/dynamic-route', '/about', '/404'];
8
-
8
+ if (template === 'tabs') {
9
+ routes.push(...['/catalog', '/settings']);
10
+ }
9
11
  return routes;
10
12
  };
@@ -1,5 +1,6 @@
1
1
  const indent = require('../../../utils/indent');
2
2
 
3
+ // eslint-disable-next-line no-unused-vars
3
4
  module.exports = (options) => {
4
5
  return indent(
5
6
  0,
@@ -11,7 +12,7 @@ module.exports = (options) => {
11
12
  const NotFoundPage = () => (
12
13
  <Page>
13
14
  <NavbarBack title="Not found" />
14
- <Box mt={2}>
15
+ <Box mt="2">
15
16
  <Card inset>
16
17
  <Title>Sorry</Title>
17
18
  <p>Requested content not found.</p>
@@ -1,5 +1,6 @@
1
1
  const indent = require('../../../utils/indent');
2
2
 
3
+ // eslint-disable-next-line no-unused-vars
3
4
  module.exports = (options) => {
4
5
  return indent(
5
6
  0,
@@ -0,0 +1,60 @@
1
+ const indent = require('../../../utils/indent');
2
+
3
+ // eslint-disable-next-line no-unused-vars
4
+ module.exports = (options) => {
5
+ return indent(
6
+ 0,
7
+ `
8
+ import React from "react";
9
+ import {
10
+ Page,
11
+ Title,
12
+ List,
13
+ ListItem,
14
+ Box,
15
+ Button,
16
+ useStore
17
+ } from "zmp-framework/react";
18
+ import store from "../store";
19
+
20
+ const CatalogPage = () => {
21
+ const products = useStore("products");
22
+
23
+ const addProduct = () => {
24
+ store.dispatch("addProduct", {
25
+ id: "4",
26
+ title: "Apple iPhone 12",
27
+ description:
28
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi tempora similique reiciendis, error nesciunt vero, blanditiis pariatur dolor, minima sed sapiente rerum, dolorem corrupti hic modi praesentium unde saepe perspiciatis."
29
+ });
30
+ };
31
+
32
+ return (
33
+ <Page name="catalog">
34
+ <Box m="0" p="4">
35
+ <Title>Catalog</Title>
36
+ <List>
37
+ {products.map((product) => (
38
+ <ListItem
39
+ key={product.id}
40
+ title={product.title}
41
+ link={\`/product/\${product.id}/\`}
42
+ />
43
+ ))}
44
+ </List>
45
+ {products.length === 3 && (
46
+ <Box>
47
+ <Button responsive typeName="secondary" onClick={addProduct}>
48
+ Add Product
49
+ </Button>
50
+ </Box>
51
+ )}
52
+ </Box>
53
+ </Page>
54
+ );
55
+ };
56
+
57
+ export default CatalogPage;
58
+ `
59
+ ).trim();
60
+ };
@@ -1,5 +1,6 @@
1
1
  const indent = require('../../../utils/indent');
2
2
 
3
+ // eslint-disable-next-line no-unused-vars
3
4
  module.exports = (options) => {
4
5
  return indent(
5
6
  0,
@@ -1,6 +1,15 @@
1
1
  const indent = require('../../../utils/indent');
2
2
 
3
3
  module.exports = (options) => {
4
+ const { template } = options;
5
+ const hideNavBar =
6
+ template === 'tabs'
7
+ ? ` onPageBeforeIn={()=>{
8
+ //hide navbar
9
+ zmp.toolbar.hide('#app-tab-bar')
10
+ }}`
11
+ : '';
12
+
4
13
  return indent(
5
14
  0,
6
15
  `
@@ -36,7 +45,10 @@ module.exports = (options) => {
36
45
  }
37
46
 
38
47
  return (
39
- <Page name="user-form">
48
+ <Page
49
+ name="user-form"
50
+ ${hideNavBar}
51
+ >
40
52
  <NavbarBack title="Update user info" />
41
53
  <Box>
42
54
  <Card inset>
@@ -3,6 +3,8 @@ const copyForm = require('./form');
3
3
  const copyDynamicRoute = require('./dynamic-route');
4
4
  const copyAbout = require('./about');
5
5
  const copy404 = require('./404');
6
+ const copySettings = require('./settings');
7
+ const copyCatalog = require('./catalog');
6
8
 
7
9
  module.exports = {
8
10
  copyUser,
@@ -10,4 +12,6 @@ module.exports = {
10
12
  copyDynamicRoute,
11
13
  copyAbout,
12
14
  copy404,
15
+ copySettings,
16
+ copyCatalog,
13
17
  };
@@ -0,0 +1,39 @@
1
+ const indent = require('../../../utils/indent');
2
+
3
+ // eslint-disable-next-line no-unused-vars
4
+ module.exports = (options) => {
5
+ return indent(
6
+ 0,
7
+ `
8
+ import React from "react";
9
+ import {
10
+ Page,
11
+ List,
12
+ ListItem,
13
+ useStore,
14
+ Title,
15
+ Box
16
+ } from "zmp-framework/react";
17
+ import UserCard from "../components/user-card";
18
+
19
+ const SettingsPage = () => {
20
+ const user = useStore("user");
21
+
22
+ return (
23
+ <Page name="settings">
24
+ <Box m="0" p="4">
25
+ <Title>Settings</Title>
26
+ <List className="m-0">
27
+ <ListItem link="/user/">
28
+ <UserCard user={user} />
29
+ </ListItem>
30
+ </List>
31
+ </Box>
32
+ </Page>
33
+ );
34
+ };
35
+
36
+ export default SettingsPage;
37
+ `
38
+ ).trim();
39
+ };
@@ -1,18 +1,33 @@
1
1
  const indent = require('../../../utils/indent');
2
2
 
3
3
  module.exports = (options) => {
4
+ const { template } = options;
5
+ const hideNavBar =
6
+ template === 'tabs'
7
+ ? ` onPageBeforeIn={()=>{
8
+ //hide navbar
9
+ zmp.toolbar.hide('#app-tab-bar')
10
+ }}`
11
+ : '';
12
+ const modules = ['Avatar', 'List', 'ListItem', 'Page', 'Title', 'useStore'];
13
+ if (template === 'tabs') {
14
+ modules.push('zmp');
15
+ }
4
16
  return indent(
5
17
  0,
6
18
  `
7
19
  import React from 'react'
8
- import { Avatar , List, ListItem, Page, Title, useStore } from 'zmp-framework/react'
20
+ import { ${modules.join(', ')} } from 'zmp-framework/react'
9
21
  import NavbarBack from '../components/navbar-back'
10
22
 
11
23
  const UserPage = () => {
12
24
  const user = useStore('user')
13
25
 
14
26
  return (
15
- <Page name="user">
27
+ <Page
28
+ name="user"
29
+ ${hideNavBar}
30
+ >
16
31
  <NavbarBack
17
32
  title="User info"
18
33
  linkRight="/form"
@@ -5,7 +5,7 @@ module.exports = function generatePackageJson(options) {
5
5
  const { name, framework, cssPreProcessor, includeTailwind } = options;
6
6
 
7
7
  // Dependencies
8
- const dependencies = ['zmp-framework', 'zmp-sdk', 'swiper'];
8
+ const dependencies = ['zmp-framework@1.7.0-0', 'zmp-sdk', 'swiper'];
9
9
  const dependenciesVue = ['vue@3', 'zmp-framework@next'];
10
10
  const dependenciesReact = ['react', 'react-dom', 'prop-types'];
11
11
  const dependenciesReactTs = ['@types/react', '@types/react-dom'];
@@ -72,9 +72,9 @@ module.exports = function generatePackageJson(options) {
72
72
  const content = `
73
73
  {
74
74
  "name": "${name
75
- .toLowerCase()
76
- .replace(/[ ]{2,}/, ' ')
77
- .replace(/ /g, '-')}",
75
+ .toLowerCase()
76
+ .replace(/[ ]{2,}/, ' ')
77
+ .replace(/ /g, '-')}",
78
78
  "private": true,
79
79
  "version": "1.0.0",
80
80
  "description": "${name}",
@@ -73,7 +73,8 @@ const questions = [
73
73
  {
74
74
  type: 'list',
75
75
  name: 'template',
76
- when: (opts) => opts.newProject && opts.useUIKits && opts.framework !== 'vue',
76
+ when: (opts) =>
77
+ opts.newProject && opts.useUIKits && opts.framework !== 'vue',
77
78
  message: 'Choose starter template:',
78
79
  choices: [
79
80
  {
@@ -85,14 +86,8 @@ const questions = [
85
86
  value: 'single-view',
86
87
  },
87
88
  {
88
- name: 'Tabbed Views (Tabs)',
89
+ name: 'Tabs Layout',
89
90
  value: 'tabs',
90
- disabled: true,
91
- },
92
- {
93
- name: 'Split View (Split Panel)',
94
- value: 'split-view',
95
- disabled: true,
96
91
  },
97
92
  ],
98
93
  },
@@ -100,7 +95,8 @@ const questions = [
100
95
  {
101
96
  type: 'list',
102
97
  name: 'template',
103
- when: (opts) => opts.newProject && !opts.useUIKits && opts.framework !== 'vue',
98
+ when: (opts) =>
99
+ opts.newProject && !opts.useUIKits && opts.framework !== 'vue',
104
100
  message: 'Choose starter template:',
105
101
  choices: [
106
102
  {
package/deploy/index.js CHANGED
File without changes
package/login/index.js CHANGED
File without changes
package/migrate/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmp-cli",
3
- "version": "3.7.1",
3
+ "version": "3.8.0-0",
4
4
  "description": "ZMP command line utility (CLI)",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -103,4 +103,4 @@
103
103
  "eslint-plugin-promise": "^4.2.1",
104
104
  "eslint-plugin-standard": "^5.0.0"
105
105
  }
106
- }
106
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ var exec = require('exec-sh');
4
+
5
+ var inquirer = require('inquirer');
6
+
7
+ var fs = require('fs');
8
+
9
+ var path = require('path');
10
+
11
+ var pkg = require('../package.json');
12
+
13
+ function release() {
14
+ var options;
15
+ return regeneratorRuntime.async(function release$(_context) {
16
+ while (1) {
17
+ switch (_context.prev = _context.next) {
18
+ case 0:
19
+ _context.next = 2;
20
+ return regeneratorRuntime.awrap(inquirer.prompt([{
21
+ type: 'input',
22
+ name: 'version',
23
+ message: 'Version:',
24
+ "default": pkg.version
25
+ }, {
26
+ type: 'list',
27
+ name: 'beta',
28
+ message: 'Beta?',
29
+ when: function when(opts) {
30
+ return opts.version.indexOf('-') >= 0;
31
+ },
32
+ choices: [{
33
+ name: 'YES',
34
+ value: true
35
+ }, {
36
+ name: 'NO',
37
+ value: false
38
+ }]
39
+ }, {
40
+ type: 'input',
41
+ name: 'branch',
42
+ message: 'Branch Name:',
43
+ when: function when(opts) {
44
+ return opts.beta;
45
+ },
46
+ "default": 'next'
47
+ }]));
48
+
49
+ case 2:
50
+ options = _context.sent;
51
+ pkg.version = options.version;
52
+ fs.writeFileSync(path.resolve(__dirname, '../package.json'), JSON.stringify(pkg, null, 2));
53
+ _context.next = 7;
54
+ return regeneratorRuntime.awrap(exec.promise('git pull'));
55
+
56
+ case 7:
57
+ _context.next = 9;
58
+ return regeneratorRuntime.awrap(exec.promise('npm i'));
59
+
60
+ case 9:
61
+ _context.next = 11;
62
+ return regeneratorRuntime.awrap(exec.promise('git add .'));
63
+
64
+ case 11:
65
+ _context.next = 13;
66
+ return regeneratorRuntime.awrap(exec.promise("git commit -m \"".concat(pkg.version, " release\"")));
67
+
68
+ case 13:
69
+ _context.next = 15;
70
+ return regeneratorRuntime.awrap(exec.promise('git push'));
71
+
72
+ case 15:
73
+ _context.next = 17;
74
+ return regeneratorRuntime.awrap(exec.promise("git tag v".concat(pkg.version)));
75
+
76
+ case 17:
77
+ _context.next = 19;
78
+ return regeneratorRuntime.awrap(exec.promise('git push origin --tags'));
79
+
80
+ case 19:
81
+ if (!options.beta) {
82
+ _context.next = 24;
83
+ break;
84
+ }
85
+
86
+ _context.next = 22;
87
+ return regeneratorRuntime.awrap(exec.promise("npm publish --tag ".concat(options.branch)));
88
+
89
+ case 22:
90
+ _context.next = 26;
91
+ break;
92
+
93
+ case 24:
94
+ _context.next = 26;
95
+ return regeneratorRuntime.awrap(exec.promise('npm publish'));
96
+
97
+ case 26:
98
+ case "end":
99
+ return _context.stop();
100
+ }
101
+ }
102
+ });
103
+ }
104
+
105
+ release();