zmp-cli 3.12.1-rc.2 → 3.14.0-rc.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.
@@ -1,21 +1,18 @@
1
1
  {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "pwa-node",
9
- "request": "launch",
10
- "name": "Launch Program",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "program": "${workspaceFolder}/index.js",
15
- "args": [
16
- "init"
17
- ],
18
- "console": "integratedTerminal"
19
- }
20
- ]
21
- }
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "type": "pwa-node",
9
+ "request": "launch",
10
+ "name": "Launch Program",
11
+ "skipFiles": ["<node_internals>/**"],
12
+ "program": "${workspaceFolder}/index.js",
13
+ "args": ["sync-config", "--root-element", "#__next", "out/index.html"],
14
+ "cwd": "${workspaceFolder}/../next-mini-app/",
15
+ "console": "integratedTerminal"
16
+ }
17
+ ]
18
+ }
@@ -0,0 +1,217 @@
1
+ #!/usr/bin/env node
2
+
3
+ /* eslint no-console: off */
4
+ "use strict";
5
+
6
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
7
+
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
9
+
10
+ function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
11
+
12
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
13
+
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
+
18
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+
20
+ var chalk = require('chalk');
21
+
22
+ var ora = require('ora');
23
+
24
+ var path = require('path');
25
+
26
+ var _require = require('vite'),
27
+ build = _require.build;
28
+
29
+ var dynamicImportVars = require('@rollup/plugin-dynamic-import-vars')["default"];
30
+
31
+ var _ = require('lodash');
32
+
33
+ var replace = require('@rollup/plugin-replace');
34
+
35
+ var log = require('../utils/log');
36
+
37
+ var fse = require('../utils/fs-extra');
38
+
39
+ var getAppInfo = require('../utils/get-app-info');
40
+
41
+ var envUtils = require('../utils/env');
42
+
43
+ var config = require('../config');
44
+
45
+ var generatePagesMap = require('../utils/generate-pages-map');
46
+
47
+ var env = envUtils.getEnv('NODE_ENV') || 'production';
48
+ var waitText = chalk.gray('Building... (Please wait, it can take a while)');
49
+ var frameworkWarning = chalk.yellow('Warning: This CLI version will work better with zmp-framework version 1.5.0 or higher');
50
+ var spinner = ora(env === 'production' ? 'Building for production...' : 'Building development version...');
51
+
52
+ module.exports = function _callee() {
53
+ var options,
54
+ logger,
55
+ _ref,
56
+ _ref$exitOnError,
57
+ exitOnError,
58
+ cwd,
59
+ resolvePath,
60
+ appConfig,
61
+ errorExit,
62
+ appId,
63
+ nextVersion,
64
+ appInfo,
65
+ currentVersion,
66
+ viteConfig,
67
+ isTypeScriptProject,
68
+ res,
69
+ output,
70
+ jsFiles,
71
+ cssFiles,
72
+ appConfigJson,
73
+ _args = arguments;
74
+
75
+ return regeneratorRuntime.async(function _callee$(_context) {
76
+ while (1) {
77
+ switch (_context.prev = _context.next) {
78
+ case 0:
79
+ errorExit = function _ref2(err) {
80
+ log.error(err.stderr || err);
81
+ if (exitOnError) process.exit(1);
82
+ };
83
+
84
+ options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
85
+ logger = _args.length > 1 ? _args[1] : undefined;
86
+ _ref = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}, _ref$exitOnError = _ref.exitOnError, exitOnError = _ref$exitOnError === void 0 ? true : _ref$exitOnError;
87
+ cwd = options.cwd || process.cwd();
88
+
89
+ resolvePath = function resolvePath(dir) {
90
+ return path.join(cwd, dir);
91
+ };
92
+
93
+ appConfig = options.appConfigJson || require(resolvePath(config.filename.appConfig));
94
+
95
+ if (!logger) {
96
+ // eslint-disable-next-line
97
+ logger = {
98
+ statusStart: function statusStart() {},
99
+ statusDone: function statusDone() {},
100
+ statusError: function statusError() {},
101
+ text: function text() {},
102
+ error: function error() {}
103
+ };
104
+ }
105
+
106
+ logger.text(frameworkWarning);
107
+ spinner.start();
108
+ logger.statusStart(waitText);
109
+ _context.prev = 11;
110
+ appId = envUtils.getEnv(config.env.appId);
111
+ nextVersion = options.nextVersion;
112
+
113
+ if (nextVersion) {
114
+ _context.next = 21;
115
+ break;
116
+ }
117
+
118
+ _context.next = 17;
119
+ return regeneratorRuntime.awrap(getAppInfo(appId, options));
120
+
121
+ case 17:
122
+ appInfo = _context.sent;
123
+ currentVersion = appInfo && appInfo.latestVersion && Number(appInfo.latestVersion);
124
+
125
+ if (currentVersion === undefined || currentVersion === null) {
126
+ currentVersion = 0;
127
+ }
128
+
129
+ nextVersion = currentVersion + 1;
130
+
131
+ case 21:
132
+ viteConfig = 'vite.config.js';
133
+ isTypeScriptProject = fse.existsSync(path.join(cwd, 'vite.config.ts'));
134
+
135
+ if (isTypeScriptProject) {
136
+ viteConfig = 'vite.config.ts';
137
+ } // eslint-disable-next-line
138
+
139
+
140
+ _context.next = 26;
141
+ return regeneratorRuntime.awrap(build({
142
+ configFile: path.join(cwd, viteConfig),
143
+ root: cwd,
144
+ base: "".concat(config.zdn_url).concat(appId, "/").concat(nextVersion, "/"),
145
+ css: {
146
+ modules: {
147
+ scopeBehaviour: 'local'
148
+ }
149
+ },
150
+ build: {
151
+ target: 'es2015',
152
+ outDir: path.join(cwd, 'www'),
153
+ assetsInlineLimit: 0,
154
+ cssCodeSplit: false,
155
+ cssTarget: ['es2015', 'safari13.1'],
156
+ rollupOptions: {
157
+ plugins: [replace({
158
+ values: {
159
+ ZMP_IMPORT_PAGES: function ZMP_IMPORT_PAGES() {
160
+ return generatePagesMap(cwd);
161
+ }
162
+ }
163
+ }), dynamicImportVars({
164
+ warnOnError: true
165
+ })],
166
+ output: {
167
+ entryFileNames: 'assets/[name].[hash].module.js',
168
+ chunkFileNames: 'assets/[name].[hash].module.js'
169
+ }
170
+ }
171
+ },
172
+ logLevel: 'error'
173
+ }));
174
+
175
+ case 26:
176
+ res = _context.sent;
177
+ output = res.output.map(function (obj) {
178
+ return _.pick(obj, ['fileName', 'type', 'isEntry', 'isImplicitEntry', 'isDynamicEntry']);
179
+ });
180
+ jsFiles = output.filter(function (file) {
181
+ if (file.type !== 'chunk') return false;
182
+ return file.isEntry || !file.isDynamicEntry;
183
+ });
184
+ cssFiles = output.filter(function (file) {
185
+ if (file.type !== 'asset' || !file.fileName.endsWith('.css')) return false; // const name = file.fileName.replace(/\.([a-z0-9]{8})\.css$/, '');
186
+ // if (!jsFiles.find((js) => js.fileName.startsWith(name))) return false;
187
+
188
+ return true;
189
+ });
190
+ appConfigJson = _objectSpread({}, appConfig, {
191
+ listCSS: [].concat(_toConsumableArray(Array.isArray(appConfig.listCSS) ? appConfig.listCSS : []), _toConsumableArray(cssFiles.map(function (f) {
192
+ return f.fileName;
193
+ }))),
194
+ listSyncJS: [].concat(_toConsumableArray(Array.isArray(appConfig.listSyncJS) ? appConfig.listSyncJS : []), _toConsumableArray(jsFiles.map(function (f) {
195
+ return f.fileName;
196
+ }))),
197
+ listAsyncJS: _toConsumableArray(Array.isArray(appConfig.listAsyncJS) ? appConfig.listAsyncJS : [])
198
+ });
199
+ fse.writeFileSync(resolvePath("www/".concat(config.filename.appConfig)), JSON.stringify(appConfigJson));
200
+ logger.statusDone("".concat(chalk.bold.green('Build Done!\n')));
201
+ return _context.abrupt("return", appConfigJson);
202
+
203
+ case 36:
204
+ _context.prev = 36;
205
+ _context.t0 = _context["catch"](11);
206
+ logger.statusError('Error building project'); // if (err) logger.error(err.stderr || err);
207
+
208
+ errorExit(_context.t0);
209
+ return _context.abrupt("return");
210
+
211
+ case 41:
212
+ case "end":
213
+ return _context.stop();
214
+ }
215
+ }
216
+ }, null, null, [[11, 36]]);
217
+ };
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ filename: {
5
+ appConfig: 'app-config.json',
6
+ zmpConfig: 'zmp-cli.json',
7
+ packageJson: 'package.json'
8
+ },
9
+ api_domain: 'https://zmp-api.developers.zalo.me/',
10
+ zdn_url: '//h5.zdn.vn/zapps/',
11
+ path: {
12
+ login: 'admin/login',
13
+ requestLogin: 'admin/request-login',
14
+ checkLoginStatus: 'admin/get-login-status',
15
+ // uploadApp: 'admin/upload-app',
16
+ uploadAppByChunk: 'app/upload-chunk',
17
+ requestUploadResumable: 'app/request-upload',
18
+ getAppInfo: 'app/get-info'
19
+ },
20
+ dirname: __dirname,
21
+ root_env: function root_env() {
22
+ return "".concat(process.cwd(), "/.env");
23
+ },
24
+ env: {
25
+ appId: 'APP_ID',
26
+ token: 'ZMP_TOKEN',
27
+ accessToken: 'VITE_ACCESS_TOKEN'
28
+ },
29
+ error_code: {
30
+ app_config_not_found: -1400,
31
+ permission_denied: -2001,
32
+ request_timeout: -2003
33
+ },
34
+ error_msg: {
35
+ app_config_not_found: "App config not found. Please re-init project. (Tips: Run 'zmp init')",
36
+ permission_denied: "Permission denied. Please login again. (Tips: Run 'zmp login')",
37
+ request_timeout: 'Request Timeout'
38
+ },
39
+ resumable_option: {
40
+ chunkSize: 512 * 1000,
41
+ // bytes -> 512kb/chunk
42
+ simultaneousUploads: 4,
43
+ testChunks: true,
44
+ throttleProgressCallbacks: 1,
45
+ method: 'octet',
46
+ forceChunkSize: false
47
+ }
48
+ };
package/config/index.js CHANGED
@@ -20,7 +20,6 @@ module.exports = {
20
20
  env: {
21
21
  appId: 'APP_ID',
22
22
  token: 'ZMP_TOKEN',
23
- accessToken: 'VITE_ACCESS_TOKEN',
24
23
  },
25
24
  error_code: {
26
25
  app_config_not_found: -1400,
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var indent = require('../utils/indent');
4
+
5
+ var _require = require('../utils/colors'),
6
+ colorThemeCSSProperties = _require.colorThemeCSSProperties;
7
+
8
+ module.exports = function (options) {
9
+ var template = options.template,
10
+ theming = options.theming;
11
+ var customColor = theming.customColor,
12
+ color = theming.color,
13
+ fillBars = theming.fillBars;
14
+ var styles = '';
15
+ var themeRgb = [0, 122, 255];
16
+
17
+ if (customColor && color) {
18
+ var customProps = colorThemeCSSProperties("".concat(color));
19
+ themeRgb = customProps['--zmp-theme-color-rgb'].split(',').map(function (n) {
20
+ return n.trim();
21
+ });
22
+ styles += indent(0, "\n /* Custom color theme properties */\n :root {\n ".concat(Object.keys(customProps).filter(function (prop) {
23
+ return prop !== '--zmp-tabbar-fill-link-active-color' && prop !== '--zmp-tabbar-fill-link-active-border-color';
24
+ }).map(function (prop) {
25
+ return "".concat(prop, ": ").concat(customProps[prop], ";");
26
+ }).join('\n '), "\n }\n :root.theme-dark,:root .theme-dark {\n ").concat(Object.keys(customProps).map(function (prop) {
27
+ return "".concat(prop, ": ").concat(customProps[prop], ";");
28
+ }).join('\n '), "\n }\n "));
29
+ }
30
+
31
+ if (fillBars) {
32
+ styles += indent(0, "\n /* Invert navigation bars to fill style */\n ");
33
+ }
34
+
35
+ if (includeTailwind) {
36
+ styles += indent(0, "\n @import \"./tailwind.css\";\n ");
37
+ }
38
+
39
+ if (template === 'split-view') {
40
+ styles += indent(0, "\n /* Left Panel right border when it is visible by breakpoint */\n .panel-left.panel-in-breakpoint:before {\n position: absolute;\n right: 0;\n top: 0;\n height: 100%;\n width: 1px;\n background: rgba(0,0,0,0.1);\n content: '';\n z-index: 6000;\n }\n\n /* Hide navbar link which opens left panel when it is visible by breakpoint */\n .panel-left.panel-in-breakpoint ~ .view .navbar .panel-open[data-panel=\"left\"] {\n display: none;\n }\n\n /*\n Extra borders for main view and left panel for iOS theme when it behaves as panel (before breakpoint size)\n */\n .ios .panel-left:not(.panel-in-breakpoint).panel-in ~ .view-main:before,\n .ios .panel-left:not(.panel-in-breakpoint).panel-closing ~ .view-main:before {\n position: absolute;\n left: 0;\n top: 0;\n height: 100%;\n width: 1px;\n background: rgba(0,0,0,0.1);\n content: '';\n z-index: 6000;\n }\n ");
41
+ } else {
42
+ styles += indent(0, "\n /* Your app custom styles here */\n ");
43
+ }
44
+
45
+ return styles.trim();
46
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var templateIf = require('../../utils/template-if');
4
+
5
+ var indent = require('../../utils/indent');
6
+
7
+ var stylesExtension = require('../../utils/styles-extension');
8
+
9
+ module.exports = function (options) {
10
+ var cssPreProcessor = options.cssPreProcessor,
11
+ theming = options.theming,
12
+ customBuild = options.customBuild,
13
+ includeTailwind = options.includeTailwind;
14
+ var scripts = '';
15
+ scripts += indent(0, "\n // Import React and ReactDOM\n import React from 'react';\n import { createRoot } from 'react-dom/client';\n\n // Import ZMP\n import ZMP from '".concat(customBuild ? './zmp-custom.js' : 'zmp-framework/core/lite-bundle', "';\n\n // Import ZMP-React Plugin\n import ZMPReact from 'zmp-framework/react';").concat(includeTailwind ? "\n\n // Import tailwind styles\n import './css/tailwind.css';\n " : '', "\n\n // Import ZMP Styles\n ").concat(templateIf(customBuild, function () {
16
+ return "\n import './css/zmp-custom.less';\n ";
17
+ }, function () {
18
+ return "\n import 'zmp-framework/".concat(theming.useUiKits ? 'zmp-bundle.min.css' : 'zmp.min.css', "';\n ");
19
+ }), "\n\n // Import Icons and App Custom Styles\n ").concat(templateIf(theming.iconFonts, function () {
20
+ return "\n import './css/icons.css';\n ";
21
+ }), "\n import './css/app.").concat(stylesExtension(cssPreProcessor), "';\n\n // Import App Component\n import App from './components/app.jsx';\n import appConfig from '../app-config.json';\n\n if (!window.APP_CONFIG) {\n window.APP_CONFIG = appConfig;\n }\n\n // Init ZMP React Plugin\n ZMP.use(ZMPReact)\n\n // Mount React App\n const root = createRoot(document.getElementById('app'));\n root.render(React.createElement(App));\n "));
22
+ return scripts.trim();
23
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var templateIf = require('../../utils/template-if');
4
+
5
+ var indent = require('../../utils/indent');
6
+
7
+ var stylesExtension = require('../../utils/styles-extension');
8
+
9
+ module.exports = function (options) {
10
+ var cssPreProcessor = options.cssPreProcessor,
11
+ theming = options.theming,
12
+ customBuild = options.customBuild,
13
+ includeTailwind = options.includeTailwind;
14
+ var scripts = '';
15
+ scripts += indent(0, "\n // Import React and ReactDOM\n import React from 'react';\n import { createRoot } from 'react-dom/client';\n\n // Import ZMP\n import ZMP from '".concat(customBuild ? './zmp-custom.js' : 'zmp-framework/core/lite-bundle', "';\n\n // Import ZMP-React Plugin\n import ZMPReact from 'zmp-framework/react';").concat(includeTailwind ? "\n\n // Import tailwind styles\n import './css/tailwind.css';\n " : '', "\n\n // Import ZMP Styles\n ").concat(templateIf(customBuild, function () {
16
+ return "\n import './css/zmp-custom.less';\n ";
17
+ }, function () {
18
+ return "\n import 'zmp-framework/".concat(theming.useUiKits ? 'zmp-bundle.min.css' : 'zmp.min.css', "';\n ");
19
+ }), "\n\n // Import Icons and App Custom Styles\n ").concat(templateIf(theming.iconFonts, function () {
20
+ return "\n import './css/icons.css';\n ";
21
+ }), "\n import './css/app.").concat(stylesExtension(cssPreProcessor), "';\n\n // Import App Component\n import App from './components/app';\n import appConfig from '../app-config.json';\n\n if (!(window as any).APP_CONFIG) {\n (window as any).APP_CONFIG = appConfig\n }\n\n // Init ZMP React Plugin\n ZMP.use(ZMPReact)\n\n // Mount React App\n const root = createRoot(document.getElementById('app')!);\n root.render(React.createElement(App));\n "));
22
+ return scripts.trim();
23
+ };
@@ -0,0 +1,277 @@
1
+ "use strict";
2
+
3
+ /* eslint no-param-reassign: ["off"] */
4
+ var inquirer = require('inquirer');
5
+
6
+ var chalk = require('chalk');
7
+
8
+ var moreOptionsText = chalk.italic("\t- Including Tailwind CSS\n\t- Including Recoil (React only)");
9
+ var questions = [{
10
+ type: 'list',
11
+ name: 'newProject',
12
+ message: 'What action you want to do?',
13
+ choices: [{
14
+ name: 'Create a new ZMP project',
15
+ value: true
16
+ }, {
17
+ name: 'Using ZMP to deploy only',
18
+ value: false
19
+ }]
20
+ }, {
21
+ type: 'input',
22
+ name: 'name',
23
+ message: 'App (project) name:',
24
+ "default": 'My App',
25
+ validate: function validate(input) {
26
+ return new Promise(function (resolve, reject) {
27
+ if (!input) reject(new Error('App name is required'));else resolve(true);
28
+ });
29
+ }
30
+ }, {
31
+ type: 'list',
32
+ name: 'package',
33
+ when: function when(opts) {
34
+ return opts.newProject;
35
+ },
36
+ message: 'Choose an UI library / UI framework:',
37
+ choices: [{
38
+ name: 'zmp-ui',
39
+ value: 'zmp-ui'
40
+ }]
41
+ }, // Framework
42
+ {
43
+ type: 'list',
44
+ name: 'framework',
45
+ when: function when(opts) {
46
+ return opts["package"] == 'zmp-framework';
47
+ },
48
+ message: 'What type of framework do you prefer?',
49
+ choices: [{
50
+ name: 'ZMP with React',
51
+ value: 'react'
52
+ }, {
53
+ name: 'ZMP with React (TypeScript)',
54
+ value: 'react-typescript'
55
+ }, {
56
+ name: 'ZMP with Vue.js',
57
+ value: 'vue'
58
+ }, {
59
+ name: 'ZMP Core',
60
+ value: 'core',
61
+ disabled: true
62
+ }]
63
+ }, {
64
+ type: 'list',
65
+ name: 'language',
66
+ when: function when(opts) {
67
+ return opts["package"] == 'zmp-ui';
68
+ },
69
+ message: 'What language do you prefer?',
70
+ choices: [{
71
+ name: 'ReactJS',
72
+ value: 'react'
73
+ }]
74
+ }, {
75
+ type: 'list',
76
+ name: 'useUIKits',
77
+ when: function when(opts) {
78
+ return opts["package"] === 'zmp-framework' && opts.framework !== 'vue';
79
+ },
80
+ message: 'Do you want to use Zalo UI kits style?',
81
+ "default": true,
82
+ choices: [{
83
+ name: 'Yes, i want to use UI kits style',
84
+ value: true
85
+ }, {
86
+ name: 'No, i want to use only styles with minimal required set of components',
87
+ value: false
88
+ }]
89
+ }, // Template
90
+ {
91
+ type: 'list',
92
+ name: 'template',
93
+ when: function when(opts) {
94
+ return opts.newProject && opts["package"] === 'zmp-framework' && opts.useUIKits && opts.framework !== 'vue';
95
+ },
96
+ message: 'Choose starter template:',
97
+ choices: [{
98
+ name: 'Blank',
99
+ value: 'blank'
100
+ }, {
101
+ name: 'Single View',
102
+ value: 'single-view'
103
+ }, {
104
+ name: 'Tabs Layout',
105
+ value: 'tabs'
106
+ }]
107
+ }, // Template
108
+ {
109
+ type: 'list',
110
+ name: 'template',
111
+ when: function when(opts) {
112
+ return opts.newProject && opts["package"] === 'zmp-framework' && !opts.useUIKits && opts.framework !== 'vue';
113
+ },
114
+ message: 'Choose starter template:',
115
+ choices: [{
116
+ name: 'Blank',
117
+ value: 'blank'
118
+ }]
119
+ }, {
120
+ type: 'list',
121
+ name: 'cssPreProcessor',
122
+ when: function when(opts) {
123
+ return opts.newProject;
124
+ },
125
+ message: 'Do you want to setup CSS Pre-Processor',
126
+ "default": false,
127
+ choices: [{
128
+ name: 'No, i am good with CSS',
129
+ value: false
130
+ }, {
131
+ name: 'Less',
132
+ value: 'less'
133
+ }, {
134
+ name: 'SCSS (SASS)',
135
+ value: 'scss'
136
+ }, {
137
+ name: 'Stylus',
138
+ value: 'stylus'
139
+ }]
140
+ }, // Template
141
+ {
142
+ type: 'list',
143
+ name: 'template',
144
+ when: function when(opts) {
145
+ return opts["package"] === 'zmp-ui';
146
+ },
147
+ message: 'Choose starter template:',
148
+ choices: [{
149
+ name: 'Blank',
150
+ value: 'blank'
151
+ }, {
152
+ name: 'Single View',
153
+ value: 'single-view'
154
+ }]
155
+ }, // Color
156
+ {
157
+ type: 'list',
158
+ name: 'themingCustomColor',
159
+ when: function when(opts) {
160
+ return opts.newProject && opts["package"] !== 'zmp-ui';
161
+ },
162
+ message: 'Do you want to specify custom theme color?',
163
+ choices: [{
164
+ name: 'No, use default color theme',
165
+ value: false
166
+ }, {
167
+ name: 'Yes, i want to specify my brand color',
168
+ value: true
169
+ }]
170
+ }, {
171
+ type: 'input',
172
+ name: 'themingColor',
173
+ message: 'Enter custom theme color in HEX format (e.g. ff0000)',
174
+ when: function when(opts) {
175
+ return opts.themingCustomColor === true;
176
+ },
177
+ validate: function validate(input) {
178
+ return new Promise(function (resolve, reject) {
179
+ var num = input.replace(/#/g, '');
180
+ if (num.length === 3 || num.length === 6) resolve(true);else reject(new Error("It doesn't look like a correct HEX number"));
181
+ });
182
+ },
183
+ filter: function filter(input) {
184
+ return input.replace(/#/g, '');
185
+ }
186
+ }, {
187
+ type: 'list',
188
+ name: 'themingIconFonts',
189
+ when: function when(opts) {
190
+ return opts.newProject && opts["package"] !== 'zmp-ui';
191
+ },
192
+ message: 'Do you want to include ZMP Icons and Material Icons icon fonts?',
193
+ "default": true,
194
+ choices: [{
195
+ name: 'Yes, include icon fonts',
196
+ value: true
197
+ }, {
198
+ name: 'No, i want to use my own custom icons',
199
+ value: false
200
+ }]
201
+ }, {
202
+ type: 'list',
203
+ name: 'moreOptions',
204
+ when: function when(opts) {
205
+ return opts.newProject;
206
+ },
207
+ message: "More Options?\n".concat(moreOptionsText),
208
+ "default": false,
209
+ choices: [{
210
+ name: 'No, I want to complete initializing process now',
211
+ value: false
212
+ }, {
213
+ name: 'Yes, I want to get more options',
214
+ value: true
215
+ }]
216
+ }, {
217
+ type: 'list',
218
+ name: 'includeTailwind',
219
+ when: function when(opts) {
220
+ return opts.moreOptions;
221
+ },
222
+ message: 'Do you want to include Tailwind CSS?',
223
+ "default": true,
224
+ choices: [{
225
+ name: 'Yes, I want to iclude Tailwind CSS',
226
+ value: true
227
+ }, {
228
+ name: 'No',
229
+ value: false
230
+ }]
231
+ }, {
232
+ type: 'list',
233
+ name: 'stateManagement',
234
+ when: function when(opts) {
235
+ return opts.moreOptions && (opts.framework === 'react' || opts.framework === 'react-typescript');
236
+ },
237
+ message: 'Which state management library would you like to use?',
238
+ "default": 'store',
239
+ choices: [{
240
+ name: 'ZMP Store (Redux pattern)',
241
+ value: 'store'
242
+ }, {
243
+ name: 'Recoil',
244
+ value: 'recoil'
245
+ }]
246
+ }];
247
+
248
+ module.exports = function getOptions() {
249
+ var listQuestion = questions;
250
+ return inquirer.prompt(listQuestion).then(function (options) {
251
+ options.theming = {
252
+ customColor: options.themingCustomColor,
253
+ color: options.themingCustomColor && options.themingColor ? "#".concat(options.themingColor) : '#007aff',
254
+ darkTheme: false,
255
+ iconFonts: options.themingIconFonts,
256
+ fillBars: false,
257
+ useUiKits: options.useUIKits
258
+ };
259
+ options.customBuild = false;
260
+ options.includeTailwind = options.moreOptions && options.includeTailwind;
261
+
262
+ if (!options.stateManagement) {
263
+ options.stateManagement = 'store';
264
+ }
265
+
266
+ if (options["package"] === 'zmp-ui') {
267
+ options.stateManagement = 'recoil';
268
+ }
269
+
270
+ delete options.themingCustomColor;
271
+ delete options.themingColor;
272
+ delete options.themingIconFonts;
273
+ delete options.useUIKits;
274
+ delete options.moreOptions;
275
+ return Promise.resolve(options);
276
+ });
277
+ };