@shijiu/jsview 1.9.888 → 1.9.909
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/dom/bin/jsview-dom-browser.min.js +1 -0
- package/dom/bin/jsview-dom-native.min.js +1 -0
- package/dom/bin/jsview-engine-js-browser.min.js +1 -1
- package/dom/bin/jsview-forge-define.min.js +1 -1
- package/dom/index.mjs +11 -8
- package/loader/jsview-loader.js +5 -4
- package/package.json +1 -2
- package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +17 -2
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js +202 -164
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-format.js +81 -326
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-types.js +67 -78
- package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +2 -2
- package/tools/{jsview-common.js → jsview-common.mjs} +36 -14
- package/tools/{jsview-post-build.js → jsview-post-build.mjs} +8 -7
- package/tools/{jsview-post-install.js → jsview-post-install.mjs} +5 -5
- package/tools/{jsview-run-android.js → jsview-run-android.mjs} +4 -5
- package/tools/jsview-upgrade.mjs +353 -0
- package/dom/bin/jsview-browser-debug-dom.min.js +0 -1
- package/dom/bin/jsview-dom.min.js +0 -1
- package/loader/jsview-browser-forgeapp.js +0 -13
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import childProcess from 'child_process';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
7
|
|
|
8
8
|
function printArgumentsUsages(requiredUsages, optionalUsages, helpUsages)
|
|
9
9
|
{
|
|
@@ -41,6 +41,7 @@ function parseArguments(requiredUsages = {},
|
|
|
41
41
|
optionalUsages = {},
|
|
42
42
|
withoutUnparsed = true)
|
|
43
43
|
{
|
|
44
|
+
const keySeparator = '|';
|
|
44
45
|
const formatKey = (key) => {
|
|
45
46
|
let formattedKey = key.trim().replace(/^-*/, '');
|
|
46
47
|
formattedKey = formattedKey.replace(/-(.)/g, (x) => x[1].toUpperCase())
|
|
@@ -57,9 +58,25 @@ function parseArguments(requiredUsages = {},
|
|
|
57
58
|
}
|
|
58
59
|
return formattedValue;
|
|
59
60
|
}
|
|
60
|
-
const
|
|
61
|
+
const hasKey = (usages, key) => {
|
|
62
|
+
const fmtKey = formatKey(key);
|
|
63
|
+
for (const checker in usages) {
|
|
64
|
+
const checkerList = checker.split(keySeparator);
|
|
65
|
+
for (const alias of checkerList) {
|
|
66
|
+
const fmtAlias = formatKey(alias);
|
|
67
|
+
if (fmtAlias === fmtKey) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const checkAliases = (checker, options) => {
|
|
76
|
+
const checkerList = checker.split(keySeparator);
|
|
77
|
+
|
|
61
78
|
const formattedAliases = [];
|
|
62
|
-
for (const alias of
|
|
79
|
+
for (const alias of checkerList) {
|
|
63
80
|
const fmtAlias = formatKey(alias);
|
|
64
81
|
formattedAliases.push(fmtAlias);
|
|
65
82
|
}
|
|
@@ -112,31 +129,35 @@ function parseArguments(requiredUsages = {},
|
|
|
112
129
|
}
|
|
113
130
|
}
|
|
114
131
|
|
|
132
|
+
if (hasKey(helpUsages, key) == false
|
|
133
|
+
&& hasKey(requiredUsages, key) == false
|
|
134
|
+
&& hasKey(optionalUsages, key) == false) {
|
|
135
|
+
console.error('JsView Error: Failed to parse usage: ' + argu);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
|
|
115
139
|
let formattedKey = formatKey(key);
|
|
116
140
|
let formattedValue = formatValue(value);
|
|
117
141
|
options[formattedKey] = formattedValue;
|
|
118
142
|
}
|
|
119
143
|
|
|
120
144
|
for (const checker in helpUsages) {
|
|
121
|
-
const
|
|
122
|
-
const aliasedOptions = checkAliases(checkerList, options);
|
|
145
|
+
const aliasedOptions = checkAliases(checker, options);
|
|
123
146
|
if (aliasedOptions) {
|
|
124
147
|
printArgumentsUsages(requiredUsages, optionalUsages, helpUsages);
|
|
125
148
|
process.exit(0);
|
|
126
149
|
}
|
|
127
150
|
}
|
|
128
151
|
for (const checker in requiredUsages) {
|
|
129
|
-
const
|
|
130
|
-
const aliasedOptions = checkAliases(checkerList, options);
|
|
152
|
+
const aliasedOptions = checkAliases(checker, options);
|
|
131
153
|
if (!aliasedOptions) {
|
|
132
|
-
console.log('JsView Error: Failed to find required option: ' +
|
|
154
|
+
console.log('JsView Error: Failed to find required option: ' + checker);
|
|
133
155
|
process.exit(-1);
|
|
134
156
|
}
|
|
135
157
|
options = { ...options, ...aliasedOptions };
|
|
136
158
|
}
|
|
137
159
|
for (const checker in optionalUsages) {
|
|
138
|
-
const
|
|
139
|
-
const aliasedOptions = checkAliases(checkerList, options);
|
|
160
|
+
const aliasedOptions = checkAliases(checker, options);
|
|
140
161
|
options = { ...options, ...aliasedOptions };
|
|
141
162
|
}
|
|
142
163
|
|
|
@@ -208,7 +229,8 @@ function getPackageObject(modulePath)
|
|
|
208
229
|
console.error('JsView Error: Failed to get ' + modulePath + ', file is not exists.');
|
|
209
230
|
process.exit(1);
|
|
210
231
|
}
|
|
211
|
-
|
|
232
|
+
let pkgContent = fs.readFileSync(pkgFullFile, 'utf8');
|
|
233
|
+
const pkgObj = JSON.parse(pkgContent);
|
|
212
234
|
|
|
213
235
|
return pkgObj;
|
|
214
236
|
}
|
|
@@ -298,7 +320,7 @@ function checkNodeVersion(minMajorVersion = 16)
|
|
|
298
320
|
}
|
|
299
321
|
}
|
|
300
322
|
|
|
301
|
-
|
|
323
|
+
export {
|
|
302
324
|
checkNodeVersion,
|
|
303
325
|
cpSync,
|
|
304
326
|
execCommand,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import crypto from 'crypto';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import url from 'url'
|
|
8
|
+
import {
|
|
9
9
|
checkNodeVersion,
|
|
10
10
|
getOptions,
|
|
11
11
|
parseArguments,
|
|
12
|
-
}
|
|
12
|
+
} from './jsview-common.mjs';
|
|
13
13
|
|
|
14
14
|
// npm run build 时检查jsview-dom是否处于Debug模式。
|
|
15
15
|
async function checkDomDebugDisabled(options) {
|
|
@@ -227,7 +227,8 @@ async function main(argv)
|
|
|
227
227
|
|
|
228
228
|
const vueConfigFile = path.resolve(options.projectDir, 'vue.config.js');
|
|
229
229
|
if (fs.existsSync(vueConfigFile)) {
|
|
230
|
-
|
|
230
|
+
let vueCfgContent = fs.readFileSync(vueConfigFile, 'utf8');
|
|
231
|
+
const vueCfgObj = JSON.parse(vueCfgContent);
|
|
231
232
|
if(vueCfgObj.outputDir) {
|
|
232
233
|
options.distDir = path.resolve(options.projectDir, vueCfgObj.outputDir);
|
|
233
234
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import url from 'url';
|
|
7
|
+
import {
|
|
8
8
|
checkNodeVersion,
|
|
9
9
|
cpSync,
|
|
10
10
|
execCommand,
|
|
@@ -14,7 +14,7 @@ const {
|
|
|
14
14
|
parseArguments,
|
|
15
15
|
symlinkSync,
|
|
16
16
|
rmSync
|
|
17
|
-
}
|
|
17
|
+
} from './jsview-common.mjs';
|
|
18
18
|
|
|
19
19
|
function checkNpmCommand()
|
|
20
20
|
{
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {
|
|
4
|
+
import childProcess from 'child_process';
|
|
5
|
+
import url from 'url';
|
|
6
|
+
import {
|
|
8
7
|
checkNodeVersion,
|
|
9
8
|
getOptions,
|
|
10
9
|
parseArguments
|
|
11
|
-
}
|
|
10
|
+
} from './jsview-common.mjs';
|
|
12
11
|
|
|
13
12
|
async function getExtraOptions(argv)
|
|
14
13
|
{
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import url from 'url';
|
|
7
|
+
import {
|
|
8
|
+
checkNodeVersion,
|
|
9
|
+
execCommand,
|
|
10
|
+
parseArguments
|
|
11
|
+
} from './jsview-common.mjs';
|
|
12
|
+
|
|
13
|
+
function askAndAnswer(question)
|
|
14
|
+
{
|
|
15
|
+
process.stdout.write(question)
|
|
16
|
+
let buffer = Buffer.alloc(100)
|
|
17
|
+
fs.readSync(0, buffer, 0, 100)
|
|
18
|
+
let answer = buffer.toString().toLowerCase().replace('\n', '');
|
|
19
|
+
answer = answer.substring(0, answer.indexOf('\0'));
|
|
20
|
+
return answer;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getArgument(argument, usage)
|
|
24
|
+
{
|
|
25
|
+
if (!argument) {
|
|
26
|
+
return argument;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (typeof (argument) != 'string') {
|
|
30
|
+
console.error('JsView Error: ' + usage + ' is not a valid path.');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
const argumentPath = path.resolve(process.cwd(), argument);
|
|
34
|
+
if (fs.existsSync(argumentPath) == false) {
|
|
35
|
+
console.error('JsView Error: ' + argument + ' is not exists.');
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return argumentPath;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getOptions(argv)
|
|
43
|
+
{
|
|
44
|
+
const options = {};
|
|
45
|
+
|
|
46
|
+
const scriptPath = path.resolve(process.cwd(), process.argv[1]);
|
|
47
|
+
options.rootDir = scriptPath.replaceAll(/node_modules\/@shijiu\/jsview.*/g, '');
|
|
48
|
+
|
|
49
|
+
options.jsviewVersion = argv.jsviewVersion;
|
|
50
|
+
|
|
51
|
+
options.stagePixel = getArgument(argv.stagePixel, '--stage-pixel');
|
|
52
|
+
options.stageAnimation = getArgument(argv.stageAnimation, '--stage-animation');
|
|
53
|
+
options.stagePkgJson = getArgument(argv.stagePkgJson, '--stage-pkg-json');
|
|
54
|
+
|
|
55
|
+
console.info();
|
|
56
|
+
console.info('Upgrade to JsView version: ' + options.jsviewVersion);
|
|
57
|
+
console.info(' Project folder: ' + options.rootDir);
|
|
58
|
+
console.info('=====================================');
|
|
59
|
+
console.info(' Stage pixel: ' + (options.stagePixel ?? false));
|
|
60
|
+
console.info(' Stage animation: ' + (options.stageAnimation ?? false));
|
|
61
|
+
console.info(' Stage package.json: ' + (options.stagePkgJson ?? false));
|
|
62
|
+
console.info('=====================================');
|
|
63
|
+
|
|
64
|
+
console.info();
|
|
65
|
+
console.info('Are you sure to upgrade it?');
|
|
66
|
+
const answer = askAndAnswer('(y/N) ');
|
|
67
|
+
if (answer.substring(0, 1) != 'y' && answer.substring(0, 3) != 'yes') {
|
|
68
|
+
console.error('JsView Info: User cancelled.')
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return options;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getFilesRecursive(dirPath) {
|
|
76
|
+
const ignoreFileList = [
|
|
77
|
+
'.git',
|
|
78
|
+
'.gitignore',
|
|
79
|
+
'node_modules',
|
|
80
|
+
'package.json',
|
|
81
|
+
'package-lock.json'
|
|
82
|
+
];
|
|
83
|
+
const fileExtList = [
|
|
84
|
+
'!.min.js',
|
|
85
|
+
'.css',
|
|
86
|
+
'.js',
|
|
87
|
+
'.json',
|
|
88
|
+
'.mjs',
|
|
89
|
+
'.vue',
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
let filePathList = [];
|
|
93
|
+
|
|
94
|
+
const fileNameList = fs.readdirSync(dirPath);
|
|
95
|
+
for (const fileName of fileNameList) {
|
|
96
|
+
if (ignoreFileList.includes(fileName)) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const filePath = path.join(dirPath, fileName);
|
|
101
|
+
if (fs.statSync(filePath).isDirectory()) {
|
|
102
|
+
const subFilePathList = getFilesRecursive(filePath);
|
|
103
|
+
filePathList = [...filePathList, ...subFilePathList];
|
|
104
|
+
} else {
|
|
105
|
+
let needUpgrade = false;
|
|
106
|
+
for (let fileExtName of fileExtList) {
|
|
107
|
+
if (fileExtName.startsWith('!')) { // 强制忽略该文件
|
|
108
|
+
fileExtName = fileExtName.substring(1);
|
|
109
|
+
if (filePath.endsWith(fileExtName)) {
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
if (filePath.endsWith(fileExtName)) {
|
|
114
|
+
needUpgrade = true;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (needUpgrade == false) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const fileExtName = path.extname(filePath);
|
|
124
|
+
if (fileExtList.includes(fileExtName) == false) {
|
|
125
|
+
continue;
|
|
126
|
+
} else if (fileExtList.includes('!' + fileExtName)) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
filePathList.push(filePath);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return filePathList;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function upgradeStagePixel(options) {
|
|
137
|
+
console.info('Upgrading stage pixel...');
|
|
138
|
+
|
|
139
|
+
const filePathList = getFilesRecursive(options.stagePixel);
|
|
140
|
+
|
|
141
|
+
for (const filePath of filePathList) {
|
|
142
|
+
try {
|
|
143
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
144
|
+
|
|
145
|
+
content = content.replaceAll(/([0-9])px/g, '$1');
|
|
146
|
+
|
|
147
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
148
|
+
} catch (ex) {
|
|
149
|
+
console.error('JsView Error: Failed to update pixel for file: ' + filePath);
|
|
150
|
+
console.error(ex);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
console.info('Upgraded stage pixel...');
|
|
156
|
+
|
|
157
|
+
return 0;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function upgradeStageAnimation(options)
|
|
161
|
+
{
|
|
162
|
+
console.info('Upgrading stage animation...');
|
|
163
|
+
|
|
164
|
+
if (typeof (options.stageAnimation) != 'string'
|
|
165
|
+
|| fs.existsSync(options.stageAnimation) == false) {
|
|
166
|
+
console.error('JsView Error: --stage-animation is not a valid path.');
|
|
167
|
+
process.exit(1);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const filePathList = getFilesRecursive(options.stageAnimation);
|
|
171
|
+
|
|
172
|
+
for (const filePath of filePathList) {
|
|
173
|
+
try {
|
|
174
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
175
|
+
|
|
176
|
+
content = content.replaceAll(':onAnimationEnd', '@animationend');
|
|
177
|
+
|
|
178
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
179
|
+
} catch (ex) {
|
|
180
|
+
console.error('JsView Error: Failed to update animation for file: ' + filePath);
|
|
181
|
+
console.error(ex);
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
console.info('Upgraded stage animation...');
|
|
187
|
+
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function getFramework(pkgJsonFilePath)
|
|
192
|
+
{
|
|
193
|
+
if (fs.existsSync(pkgJsonFilePath) == false) {
|
|
194
|
+
console.error('JsView Error: Failed to find package.json: ' + pkgJsonFilePath);
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
let framework = 'unknown';
|
|
199
|
+
|
|
200
|
+
const content = fs.readFileSync(pkgJsonFilePath, 'utf8');
|
|
201
|
+
const pkgObj = JSON.parse(content);
|
|
202
|
+
if (pkgObj.dependencies?.vue) {
|
|
203
|
+
framework = 'vue';
|
|
204
|
+
} else if (pkgObj.dependencies?.react) {
|
|
205
|
+
framework = 'react';
|
|
206
|
+
} else {
|
|
207
|
+
console.error('JsView Error: Failed to recognize framework.');
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return framework;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function upgradeVueStagePackageJson(options)
|
|
215
|
+
{
|
|
216
|
+
console.info('Upgrading stage package.json...');
|
|
217
|
+
|
|
218
|
+
const needRemovePkgs = [
|
|
219
|
+
// dependencies
|
|
220
|
+
'@shijiu/jsview-vue',
|
|
221
|
+
'core-js',
|
|
222
|
+
'deepmerge',
|
|
223
|
+
'fork-ts-checker-webpack-plugin',
|
|
224
|
+
'gifuct-js',
|
|
225
|
+
'qr.js',
|
|
226
|
+
'vue',
|
|
227
|
+
'vue-router',
|
|
228
|
+
|
|
229
|
+
// devDependencies
|
|
230
|
+
'@typescript-eslint/eslint-plugin',
|
|
231
|
+
'@typescript-eslint/parser',
|
|
232
|
+
'@vue/cli-plugin-babel',
|
|
233
|
+
'@vue/cli-plugin-eslint',
|
|
234
|
+
'@vue/cli-plugin-typescript',
|
|
235
|
+
'@vue/cli-service',
|
|
236
|
+
'@vue/compiler-sfc',
|
|
237
|
+
'@vue/eslint-config-typescript',
|
|
238
|
+
'babel-eslint',
|
|
239
|
+
'cache-loader',
|
|
240
|
+
'cosmiconfig',
|
|
241
|
+
'eslint',
|
|
242
|
+
'eslint-plugin-node',
|
|
243
|
+
'eslint-plugin-promise',
|
|
244
|
+
'eslint-plugin-standard',
|
|
245
|
+
'eslint-plugin-vue',
|
|
246
|
+
'fork-ts-checker-webpack-plugin-v5',
|
|
247
|
+
'postcss-import-sync',
|
|
248
|
+
'postcss-js',
|
|
249
|
+
'typescript',
|
|
250
|
+
'vue-class-component',
|
|
251
|
+
'webpack',
|
|
252
|
+
];
|
|
253
|
+
|
|
254
|
+
const needAppendPkgs = {
|
|
255
|
+
'@shijiu/jsview': '1.9.888',
|
|
256
|
+
'@shijiu/jsview-vue': '1.9.888',
|
|
257
|
+
'vue': '3.2.45',
|
|
258
|
+
'vue-router': '4.1.6',
|
|
259
|
+
};
|
|
260
|
+
const needAppendDevPkgs = {
|
|
261
|
+
'@vitejs/plugin-vue': '4.0.0',
|
|
262
|
+
'typescript': '4.9.3',
|
|
263
|
+
'vite': '4.0.0',
|
|
264
|
+
'vue-tsc': '1.0.11',
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
if (typeof (options.stagePkgJson) != 'string'
|
|
268
|
+
|| fs.existsSync(options.stagePkgJson) == false) {
|
|
269
|
+
console.error('JsView Error: --stage-pkg-json is not a valid path.');
|
|
270
|
+
process.exit(1);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
try {
|
|
274
|
+
let content = fs.readFileSync(options.stagePkgJson, 'utf8');
|
|
275
|
+
const pkgObj = JSON.parse(content);
|
|
276
|
+
|
|
277
|
+
// 删除旧内容
|
|
278
|
+
delete pkgObj.main;
|
|
279
|
+
delete pkgObj.eslintConfig;
|
|
280
|
+
delete pkgObj.scripts.lint;
|
|
281
|
+
delete pkgObj.scripts.serve;
|
|
282
|
+
for (const removePkg of needRemovePkgs) {
|
|
283
|
+
delete pkgObj.dependencies[removePkg];
|
|
284
|
+
delete pkgObj.devDependencies[removePkg];
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// 添加新内容
|
|
288
|
+
pkgObj.type = 'module';
|
|
289
|
+
pkgObj.scripts.android = 'node node_modules/@shijiu/jsview/tools/jsview-run-android.mjs --framework=vue';
|
|
290
|
+
pkgObj.scripts.build = 'vue-tsc && vite build && node node_modules/@shijiu/jsview/tools/jsview-post-build.mjs --framework=vue';
|
|
291
|
+
pkgObj.scripts.dev = 'vite';
|
|
292
|
+
pkgObj.scripts.postinstall = 'node node_modules/@shijiu/jsview/tools/jsview-post-install.mjs --framework=vue';
|
|
293
|
+
pkgObj.scripts.preview = 'vite preview';
|
|
294
|
+
pkgObj.scripts.start = 'vite';
|
|
295
|
+
pkgObj.browserslist = ['chrome 102', 'not dead'];
|
|
296
|
+
|
|
297
|
+
for (const [key, value] of Object.entries(needAppendPkgs)) {
|
|
298
|
+
pkgObj.dependencies[key] = value;
|
|
299
|
+
}
|
|
300
|
+
for (const [key, value] of Object.entries(needAppendDevPkgs)) {
|
|
301
|
+
pkgObj.devDependencies[key] = value;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
content = JSON.stringify(pkgObj, null, 2);
|
|
305
|
+
fs.writeFileSync(options.stagePkgJson, content, 'utf8');
|
|
306
|
+
} catch (ex) {
|
|
307
|
+
console.error('JsView Error: Failed to update package.json: ' + options.stagePkgJson);
|
|
308
|
+
console.error(ex);
|
|
309
|
+
process.exit(1);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
execCommand('npm install');
|
|
313
|
+
|
|
314
|
+
console.info('Upgraded stage package.json...');
|
|
315
|
+
|
|
316
|
+
return 0;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function main(argv)
|
|
320
|
+
{
|
|
321
|
+
checkNodeVersion();
|
|
322
|
+
|
|
323
|
+
const options = getOptions(argv);
|
|
324
|
+
|
|
325
|
+
if (options.stagePixel) {
|
|
326
|
+
upgradeStagePixel(options);
|
|
327
|
+
}
|
|
328
|
+
if (options.stageAnimation) {
|
|
329
|
+
upgradeStageAnimation(options);
|
|
330
|
+
}
|
|
331
|
+
if (options.stagePkgJson) {
|
|
332
|
+
const framework = getFramework(options.stagePkgJson);
|
|
333
|
+
if (framework == 'vue') {
|
|
334
|
+
upgradeVueStagePackageJson(options);
|
|
335
|
+
} else {
|
|
336
|
+
console.error('JsView Error: Upgrade ' + framework + ' package.json is not implementation.');
|
|
337
|
+
process.exit(1);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const requiredUsages = {
|
|
343
|
+
'--jsv | --jsview-version': 'The version of jsview that is expected to be upgraded.',
|
|
344
|
+
};
|
|
345
|
+
const optionalUsages = {
|
|
346
|
+
'--stage-animation': 'Fix animations, value is a directory.',
|
|
347
|
+
'--stage-app-config': 'Upgrade appConfig to new version.',
|
|
348
|
+
'--stage-main-js': 'Upgrade main.js to new version.',
|
|
349
|
+
'--stage-pixel': 'Fix pixels, value is a directory.',
|
|
350
|
+
'--stage-pkg-json': 'Upgrade package.json to new version.',
|
|
351
|
+
};
|
|
352
|
+
const argv = parseArguments(requiredUsages, optionalUsages, false);
|
|
353
|
+
main(argv)
|