zmp-cli 3.9.0-rc.0 → 3.10.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.
- package/assets/index.js +0 -0
- package/build/index.js +1 -1
- package/config/index.js +0 -0
- package/create/index.js +0 -0
- package/create/templates/generate-styles.js +1 -10
- package/create/templates/react/generate-scripts.js +1 -2
- package/create/templates/react-typescript/generate-scripts.js +1 -2
- package/create/templates/vue/generate-scripts.js +5 -1
- package/create/utils/generate-package-json.js +7 -2
- package/create/utils/get-options.js +1 -1
- package/deploy/index.js +0 -0
- package/index.js +3 -3
- package/login/index.js +2 -6
- package/login/utils/zalo-login.js +3 -1
- package/migrate/index.js +0 -0
- package/package.json +3 -4
- package/start/index.js +25 -18
- package/utils/env.js +8 -1
package/assets/index.js
CHANGED
|
File without changes
|
package/build/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const envUtils = require('../utils/env');
|
|
|
14
14
|
const config = require('../config');
|
|
15
15
|
const generatePagesMap = require('../utils/generate-pages-map');
|
|
16
16
|
|
|
17
|
-
const env =
|
|
17
|
+
const env = envUtils.getEnv('NODE_ENV') || 'production';
|
|
18
18
|
|
|
19
19
|
const waitText = chalk.gray('Building... (Please wait, it can take a while)');
|
|
20
20
|
const frameworkWarning = chalk.yellow(
|
package/config/index.js
CHANGED
|
File without changes
|
package/create/index.js
CHANGED
|
File without changes
|
|
@@ -2,7 +2,7 @@ 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 } = options;
|
|
6
6
|
const { customColor, color, fillBars } = theming;
|
|
7
7
|
|
|
8
8
|
let styles = '';
|
|
@@ -44,15 +44,6 @@ module.exports = (options) => {
|
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
if (includeTailwind) {
|
|
48
|
-
styles += indent(
|
|
49
|
-
0,
|
|
50
|
-
`
|
|
51
|
-
@import "./tailwind.css";
|
|
52
|
-
`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
47
|
if (template === 'split-view') {
|
|
57
48
|
styles += indent(
|
|
58
49
|
0,
|
|
@@ -7,6 +7,7 @@ module.exports = (options) => {
|
|
|
7
7
|
cssPreProcessor,
|
|
8
8
|
theming,
|
|
9
9
|
customBuild,
|
|
10
|
+
includeTailwind
|
|
10
11
|
} = options;
|
|
11
12
|
|
|
12
13
|
let scripts = '';
|
|
@@ -19,7 +20,10 @@ module.exports = (options) => {
|
|
|
19
20
|
import ZMP from '${customBuild ? './zmp-custom.js' : 'zmp-framework/core/lite-bundle'}';
|
|
20
21
|
|
|
21
22
|
// Import ZMP-Vue Plugin
|
|
22
|
-
import ZMPVue, { registerComponents } from 'zmp-vue/bundle'
|
|
23
|
+
import ZMPVue, { registerComponents } from 'zmp-vue/bundle';${includeTailwind ? `
|
|
24
|
+
|
|
25
|
+
// Import tailwind styles
|
|
26
|
+
import './css/tailwind.css';` : ''}
|
|
23
27
|
|
|
24
28
|
// Import ZMP Styles
|
|
25
29
|
${templateIf(customBuild, () => `
|
|
@@ -2,7 +2,8 @@ const generateNpmScripts = require('./generate-npm-scripts');
|
|
|
2
2
|
const { generateTailWindScripts } = require('./generate-npm-scripts');
|
|
3
3
|
|
|
4
4
|
module.exports = function generatePackageJson(options) {
|
|
5
|
-
const { name, framework, cssPreProcessor, includeTailwind, stateManagement } =
|
|
5
|
+
const { name, framework, cssPreProcessor, includeTailwind, stateManagement } =
|
|
6
|
+
options;
|
|
6
7
|
|
|
7
8
|
// Dependencies
|
|
8
9
|
const dependencies = ['zmp-framework', 'zmp-sdk', 'swiper'];
|
|
@@ -29,7 +30,11 @@ module.exports = function generatePackageJson(options) {
|
|
|
29
30
|
if (framework === 'react-typescript') {
|
|
30
31
|
dependencies.push(...dependenciesReactTs);
|
|
31
32
|
}
|
|
32
|
-
const devDependencies = [
|
|
33
|
+
const devDependencies = [
|
|
34
|
+
'cross-env',
|
|
35
|
+
'postcss-preset-env@6.7.0',
|
|
36
|
+
'vite@2.6.14',
|
|
37
|
+
];
|
|
33
38
|
// CSS PreProcessor
|
|
34
39
|
if (cssPreProcessor === 'stylus') devDependencies.push(...['stylus']);
|
|
35
40
|
else if (cssPreProcessor === 'less') devDependencies.push(...['less']);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const inquirer = require('inquirer');
|
|
3
3
|
var chalk = require('chalk');
|
|
4
4
|
|
|
5
|
-
const moreOptionsText = chalk.italic(`\t- Including Tailwind CSS`);
|
|
5
|
+
const moreOptionsText = chalk.italic(`\t- Including Tailwind CSS\n\t- Including Recoil (React only)`);
|
|
6
6
|
const questions = [
|
|
7
7
|
{
|
|
8
8
|
type: 'list',
|
package/deploy/index.js
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
@@ -26,8 +26,6 @@ const os = require('os');
|
|
|
26
26
|
const pkg = require('./package.json');
|
|
27
27
|
const config = require('./config');
|
|
28
28
|
|
|
29
|
-
require('dotenv').config({ path: config.root_env() });
|
|
30
|
-
|
|
31
29
|
const cwd = process.cwd();
|
|
32
30
|
|
|
33
31
|
const logger = {
|
|
@@ -117,8 +115,9 @@ program
|
|
|
117
115
|
'Specify server port. By default it is 3000',
|
|
118
116
|
parseInt
|
|
119
117
|
)
|
|
120
|
-
.option('-Z, --zalo-app', 'Preview on
|
|
118
|
+
.option('-Z, --zalo-app', 'Preview on Zalo')
|
|
121
119
|
.option('-ios, --ios', 'Run on ios')
|
|
120
|
+
.option('-nF, --no-frame', 'Run without Zalo frame')
|
|
122
121
|
.option('-D, --dev', 'Development environment')
|
|
123
122
|
.description('Start a ZMP project')
|
|
124
123
|
.action(async (options) => {
|
|
@@ -147,6 +146,7 @@ program
|
|
|
147
146
|
showMobileUI: (options && options.showMobileUi) || false,
|
|
148
147
|
previewOnZalo: (options && options.zaloApp) || false,
|
|
149
148
|
ios: (options && options.ios) || false,
|
|
149
|
+
frame: (options && options.frame) ?? true,
|
|
150
150
|
},
|
|
151
151
|
logger
|
|
152
152
|
);
|
package/login/index.js
CHANGED
|
@@ -11,16 +11,12 @@ const envUtils = require('../utils/env');
|
|
|
11
11
|
const log = require('../utils/log');
|
|
12
12
|
const zaloLogin = require('./utils/zalo-login');
|
|
13
13
|
|
|
14
|
-
const env =
|
|
14
|
+
const env = envUtils.getEnv('NODE_ENV') || 'production';
|
|
15
15
|
|
|
16
16
|
const waitText = chalk.gray('Login...');
|
|
17
17
|
const spinner = ora(waitText);
|
|
18
18
|
|
|
19
|
-
module.exports = async (
|
|
20
|
-
options = {},
|
|
21
|
-
logger,
|
|
22
|
-
{ exitOnError = true, iconFile = null } = {}
|
|
23
|
-
) => {
|
|
19
|
+
module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
|
|
24
20
|
function errorExit(err) {
|
|
25
21
|
log.error(err.stderr || err);
|
|
26
22
|
if (exitOnError) process.exit(1);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const axios = require('axios');
|
|
2
|
+
const envUtils = require('../../utils/env');
|
|
2
3
|
const config = require('../../config');
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
const env = envUtils.getEnv('NODE_ENV') || 'production';
|
|
4
6
|
|
|
5
7
|
module.exports = (function () {
|
|
6
8
|
const apiRequestLogin =
|
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.
|
|
3
|
+
"version": "3.10.0-rc.0",
|
|
4
4
|
"description": "ZMP command line utility (CLI)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
"copy-webpack-plugin": "^7.0.0",
|
|
56
56
|
"cpy": "^7.3.0",
|
|
57
57
|
"css-minimizer-webpack-plugin": "^1.2.0",
|
|
58
|
-
"dotenv": "^8.2.0",
|
|
59
58
|
"envfile": "^6.14.0",
|
|
60
59
|
"exec-sh": "^0.3.2",
|
|
61
60
|
"express": "^4.17.1",
|
|
@@ -94,7 +93,7 @@
|
|
|
94
93
|
},
|
|
95
94
|
"devDependencies": {
|
|
96
95
|
"babel-eslint": "^10.1.0",
|
|
97
|
-
"eslint": "^
|
|
96
|
+
"eslint": "^7.32.0",
|
|
98
97
|
"eslint-config-airbnb-base": "^14.0.0",
|
|
99
98
|
"eslint-config-prettier": "^7.2.0",
|
|
100
99
|
"eslint-plugin-import": "^2.18.2",
|
|
@@ -103,4 +102,4 @@
|
|
|
103
102
|
"eslint-plugin-promise": "^4.2.1",
|
|
104
103
|
"eslint-plugin-standard": "^5.0.0"
|
|
105
104
|
}
|
|
106
|
-
}
|
|
105
|
+
}
|
package/start/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
const chalk = require('chalk');
|
|
4
4
|
const ora = require('ora');
|
|
5
5
|
const path = require('path');
|
|
6
|
-
const os = require('os');
|
|
7
6
|
const qrcode = require('qrcode-terminal');
|
|
8
7
|
const logSymbols = require('log-symbols');
|
|
9
8
|
const { createServer } = require('vite');
|
|
@@ -36,6 +35,7 @@ module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
|
|
|
36
35
|
const previewOnZalo = options.previewOnZalo;
|
|
37
36
|
const isIOS = options.ios;
|
|
38
37
|
const iosHostName = options.iosHostName;
|
|
38
|
+
const usingFrame = options.frame;
|
|
39
39
|
const host = isIOS ? iosHostName : 'localhost';
|
|
40
40
|
const port = options.port;
|
|
41
41
|
try {
|
|
@@ -84,29 +84,36 @@ module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
|
|
|
84
84
|
'process.env.previewOnZalo': previewOnZalo,
|
|
85
85
|
},
|
|
86
86
|
server: {
|
|
87
|
-
port: port - 1,
|
|
87
|
+
port: usingFrame ? port - 1 : port,
|
|
88
88
|
...(previewOnZalo ? publicServer : localServer),
|
|
89
89
|
},
|
|
90
90
|
});
|
|
91
91
|
const app = await server.listen();
|
|
92
92
|
|
|
93
93
|
if (!previewOnZalo) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
94
|
+
if (usingFrame) {
|
|
95
|
+
//run frame server
|
|
96
|
+
const serverFrame = await createServer({
|
|
97
|
+
// any valid user config options, plus `mode` and `configFile`
|
|
98
|
+
configFile: false,
|
|
99
|
+
root: __dirname + '/frame',
|
|
100
|
+
server: {
|
|
101
|
+
port: app.httpServer.address().port + 1,
|
|
102
|
+
strictPort: true,
|
|
103
|
+
open: true,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
spinner.stop();
|
|
107
|
+
await serverFrame.listen();
|
|
108
|
+
const info = serverFrame.config.logger.info;
|
|
109
|
+
info(chalk.green(`Zalo Mini App dev server is running at:\n`));
|
|
110
|
+
serverFrame.printUrls();
|
|
111
|
+
} else {
|
|
112
|
+
spinner.stop();
|
|
113
|
+
const info = server.config.logger.info;
|
|
114
|
+
info(chalk.green(`Zalo Mini App dev server is running at:\n`));
|
|
115
|
+
server.printUrls();
|
|
116
|
+
}
|
|
110
117
|
}
|
|
111
118
|
|
|
112
119
|
spinner.stop();
|
package/utils/env.js
CHANGED
|
@@ -9,7 +9,14 @@ const { parse, stringify } = require('envfile');
|
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
11
|
function getEnv(key) {
|
|
12
|
-
|
|
12
|
+
const value = process.env[key];
|
|
13
|
+
if (value) return value;
|
|
14
|
+
const rootENV = config.root_env();
|
|
15
|
+
const exists = fse.existsSync(rootENV);
|
|
16
|
+
if (!exists) return undefined;
|
|
17
|
+
const data = fse.readFileSync(rootENV, 'utf8');
|
|
18
|
+
const result = parse(data);
|
|
19
|
+
return result[key];
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
/**
|