@shijiu/jsview 1.9.909 → 1.9.912

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shijiu/jsview",
3
- "version": "1.9.909",
3
+ "version": "1.9.912",
4
4
  "bin": {
5
5
  "jsview-post-build": "./tools/jsview-post-build.js",
6
6
  "jsview-post-install": "./tools/jsview-post-install.js"
@@ -0,0 +1,335 @@
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
+ askAndAnswer,
9
+ checkNodeVersion,
10
+ execCommand,
11
+ parseArguments
12
+ } from './jsview-common.mjs';
13
+
14
+ function getOptions(argv)
15
+ {
16
+ const options = {
17
+ stagePixels: '1',
18
+ stageAnimation: '2',
19
+ stageAudiotrack: '3',
20
+ stageImportPostfix: '4',
21
+ stageAppConfig: '5',
22
+ stageMainEntry: '6',
23
+ };
24
+
25
+ const scriptPath = path.resolve(process.cwd(), process.argv[1]);
26
+ options.rootDir = scriptPath.replaceAll(/node_modules\/@shijiu\/jsview.*/g, '');
27
+
28
+ options.stages = argv.stages?.split(',') ?? [];
29
+
30
+ const defaultUpgradeDir = path.resolve(options.rootDir, 'src');
31
+ options.upgradeDir = path.resolve(process.cwd(), argv.dir ?? defaultUpgradeDir);
32
+ if (fs.existsSync(options.upgradeDir) == false) {
33
+ console.error('JsView Error: Upgrade dir [' + options.upgradeDir + '] is not exists.');
34
+ process.exit(1);
35
+ }
36
+
37
+ console.info();
38
+ console.info('Upgrade JsView source: ');
39
+ console.info(' Project folder: ' + options.rootDir);
40
+ console.info('=====================================');
41
+ console.info(' Upgrade folder: ' + path.relative(options.rootDir, options.upgradeDir));
42
+ console.info(' Stages: [ ' + options.stages.join(', ') + ' ]');
43
+ console.info('=====================================');
44
+
45
+ console.info();
46
+ console.info('Are you sure to upgrade it?');
47
+ const answer = askAndAnswer('(y/N) ');
48
+ if (answer.substring(0, 1) != 'y' && answer.substring(0, 3) != 'yes') {
49
+ console.error('JsView Info: User cancelled.')
50
+ process.exit(1);
51
+ }
52
+
53
+ options.sourcePathList = getFilesRecursive(options.upgradeDir);
54
+
55
+ return options;
56
+ }
57
+
58
+ function getFilesRecursive(dirPath) {
59
+ const ignoreFileList = [
60
+ '.git',
61
+ '.gitignore',
62
+ 'node_modules',
63
+ 'package.json',
64
+ 'package-lock.json'
65
+ ];
66
+ const fileExtList = [
67
+ '!.d.ts',
68
+ '!.min.js',
69
+ '.css',
70
+ '.js',
71
+ '.json',
72
+ '.mjs',
73
+ '.ts',
74
+ '.tsx',
75
+ '.vue',
76
+ ];
77
+
78
+ let filePathList = [];
79
+
80
+ const fileNameList = fs.readdirSync(dirPath);
81
+ for (const fileName of fileNameList) {
82
+ if (ignoreFileList.includes(fileName)) {
83
+ continue;
84
+ }
85
+
86
+ const filePath = path.join(dirPath, fileName);
87
+ if (fs.statSync(filePath).isDirectory()) {
88
+ const subFilePathList = getFilesRecursive(filePath);
89
+ filePathList = [...filePathList, ...subFilePathList];
90
+ } else {
91
+ let needUpgrade = false;
92
+ for (let fileExtName of fileExtList) {
93
+ if (fileExtName.startsWith('!')) { // 强制忽略该文件
94
+ fileExtName = fileExtName.substring(1);
95
+ if (filePath.endsWith(fileExtName)) {
96
+ break;
97
+ }
98
+ } else {
99
+ if (filePath.endsWith(fileExtName)) {
100
+ needUpgrade = true;
101
+ break;
102
+ }
103
+ }
104
+ }
105
+ if (needUpgrade == false) {
106
+ continue;
107
+ }
108
+
109
+ const fileExtName = path.extname(filePath);
110
+ if (fileExtList.includes(fileExtName) == false) {
111
+ continue;
112
+ } else if (fileExtList.includes('!' + fileExtName)) {
113
+ continue;
114
+ }
115
+ filePathList.push(filePath);
116
+ }
117
+ }
118
+
119
+ return filePathList;
120
+ }
121
+
122
+ function replaceStageContent(options, sourcePathList, msgPrefix,
123
+ repleceRegExp, replaceto) {
124
+ for (const filePath of sourcePathList) {
125
+ const content = fs.readFileSync(filePath, 'utf8');
126
+
127
+ const fixedContent = content.replaceAll(repleceRegExp, replaceto);
128
+ if (fixedContent === content) {
129
+ continue;
130
+ }
131
+
132
+ fs.writeFileSync(filePath, fixedContent, 'utf8');
133
+ console.info(msgPrefix + ': Upgraded ' + path.relative(options.rootDir, filePath) + '.');
134
+ }
135
+
136
+ return 0;
137
+ }
138
+
139
+ function removeStageFile(options, sourcePathList, msgPrefix,
140
+ fromExtName, toExtName)
141
+ {
142
+ for (const filePath of sourcePathList) {
143
+ if (filePath.endsWith(fromExtName) == false) {
144
+ continue;
145
+ }
146
+
147
+ const toFilePath = filePath.replace(new RegExp(fromExtName + '$'), toExtName);
148
+ fs.renameSync(filePath, toFilePath)
149
+ console.info(msgPrefix + ': Upgraded ' + path.relative(options.rootDir, filePath) + '.');
150
+ }
151
+
152
+ return 0;
153
+ }
154
+
155
+ function upgradeStagePixel(options) {
156
+ const msgPrefix = 'Stage ' + options.stagePixels;
157
+ console.info(msgPrefix + ': Upgrading pixels...');
158
+
159
+ const ret = replaceStageContent(options, options.sourcePathList, msgPrefix,
160
+ /([0-9])px/g, '$1');
161
+ return ret;
162
+ }
163
+
164
+ function upgradeStageAnimation(options)
165
+ {
166
+ const msgPrefix = 'Stage ' + options.stageAnimation;
167
+ console.info(msgPrefix + ': Upgrading animation...');
168
+
169
+ const ret = replaceStageContent(options, options.sourcePathList, msgPrefix,
170
+ ':onAnimationEnd', '@animationend');
171
+
172
+ return ret;
173
+ }
174
+
175
+ function upgradeStageAudiotrack(options)
176
+ {
177
+ const msgPrefix = 'Stage ' + options.stageAudiotrack;
178
+ console.info(msgPrefix + ': Upgrading audiotrack...');
179
+
180
+ const ret = replaceStageContent(options, options.sourcePathList, msgPrefix,
181
+ '<audiotrack', '<jsv-audiotrack');
182
+
183
+ return ret;
184
+ }
185
+
186
+ function upgradeStageImportPostfix(options)
187
+ {
188
+ const msgPrefix = 'Stage ' + options.stageImportPostfix;
189
+ console.info(msgPrefix + ': upgrading import postfix...');
190
+
191
+ const amendImportPostfix = function(currentDir, content) {
192
+ if (content.trim().startsWith('import') == false) {
193
+ return content;
194
+ }
195
+
196
+ let importFromFile = content.replaceAll(/.*'(.*)'.*/g, '$1');
197
+ if (importFromFile === content) {
198
+ importFromFile = content.replaceAll(/.*"\(\)".*/g, "$1");
199
+ }
200
+ if (importFromFile === content) {
201
+ return content;
202
+ }
203
+ let importFilePath = path.resolve(currentDir, importFromFile);
204
+ importFilePath += '.vue';
205
+ if (fs.existsSync(importFilePath) == false) {
206
+ return content;
207
+ }
208
+
209
+ // 执行到此处,则需要给给import的文件加上vue尾缀。
210
+ const fixedContent = content.replace(importFromFile, importFromFile + '.vue');
211
+
212
+ return fixedContent;
213
+ }
214
+
215
+ for (const filePath of options.sourcePathList) {
216
+ const currentDir = path.dirname(filePath);
217
+ const content = fs.readFileSync(filePath, 'utf8');
218
+
219
+ const lineContentList = content.split('\n');
220
+ for (let idx = 0; idx < lineContentList.length; idx++) {
221
+ let lineContent = lineContentList[idx];
222
+ lineContent = amendImportPostfix(currentDir, lineContent);
223
+ lineContentList[idx] = lineContent;
224
+ }
225
+
226
+ const fixedContent = lineContentList.join('\n');
227
+ if (fixedContent == content) {
228
+ continue;
229
+ }
230
+
231
+ fs.writeFileSync(filePath, fixedContent, 'utf8');
232
+ console.info(msgPrefix + ': Upgraded ' + path.relative(options.rootDir, filePath) + '.');
233
+ }
234
+
235
+ return 0;
236
+ }
237
+
238
+ function upgradeStageAppConfig(options)
239
+ {
240
+ const msgPrefix = 'Stage ' + options.stageAppConfig;
241
+ console.info(msgPrefix + ': Upgrading appConfig...');
242
+
243
+
244
+ const appConfigDir = path.resolve(options.upgradeDir, 'appConfig');
245
+ if (fs.existsSync(appConfigDir) == false) {
246
+ console.error(msgPrefix + ': Failed to upgrading appConfig, appConfig folder is not found.');
247
+ process.exit(1);
248
+ }
249
+
250
+ const sourcePathList = getFilesRecursive(appConfigDir);
251
+
252
+ const ret = removeStageFile(options, sourcePathList, msgPrefix,
253
+ '.js', '.mjs');
254
+
255
+ return ret;
256
+ }
257
+
258
+ function upgradeStageMainEntry(options)
259
+ {
260
+ const msgPrefix = 'Stage ' + options.stageMainEntry;
261
+ console.info(msgPrefix + ': Upgrading main entry...');
262
+
263
+ const mainEntryFilePath = path.resolve(options.upgradeDir, 'main.ts');
264
+ const fixedMainEntryFilePath = path.resolve(options.upgradeDir, 'main.tsx');
265
+ if (fs.existsSync(mainEntryFilePath) == false
266
+ && fs.existsSync(fixedMainEntryFilePath) == false) {
267
+ console.error(msgPrefix + ': Failed to upgrading main entry, main.ts is not found.');
268
+ process.exit(1);
269
+ }
270
+
271
+ const ret = removeStageFile(options, [ mainEntryFilePath ], msgPrefix,
272
+ 'main.ts', 'main.tsx');
273
+
274
+ return ret;
275
+ }
276
+
277
+ function main(argv)
278
+ {
279
+ checkNodeVersion();
280
+
281
+ try {
282
+ const options = getOptions(argv);
283
+
284
+ // Stage 1
285
+ if (options.stages.includes(options.stagePixels)) {
286
+ upgradeStagePixel(options);
287
+ }
288
+
289
+ // Stage 2
290
+ if (options.stages.includes(options.stageAnimation)) {
291
+ upgradeStageAnimation(options);
292
+ }
293
+
294
+ // Stage 3
295
+ if (options.stages.includes(options.stageAudiotrack)) {
296
+ upgradeStageAudiotrack(options);
297
+ }
298
+
299
+ // Stage 4
300
+ if (options.stages.includes(options.stageImportPostfix)) {
301
+ upgradeStageImportPostfix(options);
302
+ }
303
+
304
+ // Stage 5
305
+ if (options.stages.includes(options.stageAppConfig)) {
306
+ upgradeStageAppConfig(options);
307
+ }
308
+
309
+ // Stage 6
310
+ if (options.stages.includes(options.stageMainEntry)) {
311
+ upgradeStageMainEntry(options);
312
+ }
313
+ } catch (ex) {
314
+ console.error('JsView Error: Failed to update jsview source!');
315
+ console.error(ex);
316
+ process.exit(1);
317
+ }
318
+
319
+ console.error('JsView Info: Done!');
320
+ }
321
+
322
+ const requiredUsages = {
323
+ '--stages': `Upgrade stages, separate by comma(,). The value means the following:
324
+ 1. Fix pixels.
325
+ 2. Fix animation.
326
+ 3. Fix audiotrack.
327
+ 4. Fix import postfix.
328
+ 5. Fix appConfig.
329
+ 6. Rename main.ts to main.tsx.`,
330
+ };
331
+ const optionalUsages = {
332
+ '--dir': 'Upgrade directory, default is [src].',
333
+ };
334
+ const argv = parseArguments(requiredUsages, optionalUsages, false);
335
+ main(argv)
@@ -320,7 +320,18 @@ function checkNodeVersion(minMajorVersion = 16)
320
320
  }
321
321
  }
322
322
 
323
+ function askAndAnswer(question)
324
+ {
325
+ process.stdout.write(question)
326
+ let buffer = Buffer.alloc(100)
327
+ fs.readSync(0, buffer, 0, 100)
328
+ let answer = buffer.toString().toLowerCase().replace('\n', '');
329
+ answer = answer.substring(0, answer.indexOf('\0'));
330
+ return answer;
331
+ }
332
+
323
333
  export {
334
+ askAndAnswer,
324
335
  checkNodeVersion,
325
336
  cpSync,
326
337
  execCommand,
@@ -1,353 +0,0 @@
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)