@shijiu/jsview 2.0.1021 → 2.0.1073

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.
@@ -13,8 +13,9 @@ import {
13
13
  isSymlinkSync,
14
14
  parseArguments,
15
15
  symlinkSync,
16
- rmSync
17
- } from './jsview-common.mjs';
16
+ rmSync,
17
+ Logger,
18
+ } from "./jsview-common.mjs";
18
19
 
19
20
  function checkNpmCommand()
20
21
  {
@@ -26,10 +27,8 @@ function checkNpmCommand()
26
27
  return;
27
28
  }
28
29
 
29
- console.warn();
30
- console.warn(`!!! Warn: Not recommended for use 'npm ${process.env.npm_command} '.`);
31
- console.warn('Please use "npm ci" to install node modules.');
32
- console.warn();
30
+ Logger.Warn(`!!! Not recommended for use 'npm ${process.env.npm_command} '.`);
31
+ Logger.Warn('Please use "npm ci" to install node modules.');
33
32
  }
34
33
 
35
34
  function checkNpmLinkForDebug(options, linkablePkgNames)
@@ -68,7 +67,7 @@ function checkNpmLinkForDebug(options, linkablePkgNames)
68
67
  }
69
68
  }
70
69
  if (missingDepPkgs !== '') {
71
- console.log('Install missing dependencies')
70
+ Logger.Info('Install missing dependencies')
72
71
  execCommand('npm install --no-save ' + missingDepPkgs);
73
72
  }
74
73
 
@@ -93,28 +92,27 @@ function checkNpmLinkForDebug(options, linkablePkgNames)
93
92
 
94
93
  function checkPatches(options, pkgNeedPatch, skipCheckVersion)
95
94
  {
96
- console.info('Checking package:');
95
+ Logger.Info('Checking package:');
97
96
  for (const pkgName of pkgNeedPatch) {
98
97
  if (skipCheckVersion !== true) {
99
98
  const patchPkgDir = path.resolve(options.jsviewPatchModulesDir, pkgName);
100
99
  const patchPkgObj = getPackageObject(patchPkgDir);
101
- console.info(' ' + pkgName + ': ' + patchPkgObj.version);
100
+ Logger.Info(' ' + pkgName + ': ' + patchPkgObj.version);
102
101
 
103
102
  const modulePkgDir = path.resolve(options.modulesDir, pkgName);
104
103
  const modulePkgObj = getPackageObject(modulePkgDir);
105
104
  if (modulePkgObj.version != patchPkgObj.version) {
106
- console.error('JsView Error: ' + pkgName + '@' + modulePkgObj.version + ' is not supported, required version is ' + patchPkgObj.version);
107
- process.exit(1);
105
+ Logger.ErrorAndExit(pkgName + '@' + modulePkgObj.version + ' is not supported, required version is ' + patchPkgObj.version);
108
106
  }
109
107
  } else {
110
- console.info(' Skip ', pkgName);
108
+ Logger.Info(' Skip ', pkgName);
111
109
  }
112
110
  }
113
111
  }
114
112
 
115
113
  function installPatches(options, pkgNeedPatch)
116
114
  {
117
- console.info('\nPatching JsView:');
115
+ Logger.Info('Patching JsView:');
118
116
  for (const pkgName of pkgNeedPatch) {
119
117
  const patchSrc = path.resolve(options.jsviewPatchModulesDir, pkgName);
120
118
  const patchDest = path.resolve(options.modulesDir, pkgName);
@@ -122,7 +120,7 @@ function installPatches(options, pkgNeedPatch)
122
120
  cpSync(options.projectDir, patchSrc, patchDest, ['package.json']);
123
121
  }
124
122
 
125
- console.info('\nCleanup node_modules cache... ');
123
+ Logger.Info('Cleanup node_modules cache... ');
126
124
  rmSync(options.projectDir, options.cacheDir);
127
125
  }
128
126
 
@@ -131,11 +129,11 @@ async function printRevision(options)
131
129
  const jsviewVersionURL = url.pathToFileURL(options.jsviewDomRevisionFile);
132
130
  const { default: jsviewTargetVersion } = await import(jsviewVersionURL);
133
131
 
134
- console.log('**************************************************');
135
- console.log('* Update revision to:');
136
- console.log('* CORE: ' + jsviewTargetVersion.CoreRevisionAndBranch);
137
- console.log('* ENGINE JS URL: ' + jsviewTargetVersion.JseUrl);
138
- console.log('* PLUGIN LIST: ');
132
+ Logger.Info('**************************************************');
133
+ Logger.Info('* Update revision to:');
134
+ Logger.Info('* CORE: ' + jsviewTargetVersion.CoreRevisionAndBranch);
135
+ Logger.Info('* ENGINE JS URL: ' + jsviewTargetVersion.JseUrl);
136
+ Logger.Info('* PLUGIN LIST: ');
139
137
 
140
138
  // print plugin info
141
139
  let pluginCount = 0;
@@ -150,7 +148,7 @@ async function printRevision(options)
150
148
  if (fs.existsSync(versionFilePath)) {
151
149
  const versionFileURL = url.pathToFileURL(versionFilePath);
152
150
  const { default: targetVersion } = await import(versionFileURL);
153
- console.log(`* [${path.basename
151
+ Logger.Info(`* [${path.basename
154
152
  (pathname)}] : ${targetVersion.packageName
155
153
  } : ${targetVersion.version}`);
156
154
  pluginCount++;
@@ -159,9 +157,9 @@ async function printRevision(options)
159
157
  }
160
158
  }
161
159
  }
162
- console.log(`* total:${pluginCount}`);
160
+ Logger.Info(`* total:${pluginCount}`);
163
161
 
164
- console.log('**************************************************');
162
+ Logger.Info('**************************************************');
165
163
  }
166
164
 
167
165
  function doPostInstall(framework, pkgNeedPatch, skipCheckVersion)
@@ -216,7 +214,7 @@ function main(argv)
216
214
  ];
217
215
  break;
218
216
  default:
219
- throw new Error('JsView Error: Failed to support framework: ' + framework);
217
+ Logger.ErrorAndExit('Failed to support framework: ' + framework);
220
218
  }
221
219
 
222
220
  doPostInstall(argv.framework, pkgNeedPatch, argv.skipCheckVersion);
@@ -6,7 +6,8 @@ import url from 'url';
6
6
  import {
7
7
  checkNodeVersion,
8
8
  getOptions,
9
- parseArguments
9
+ parseArguments,
10
+ Logger,
10
11
  } from './jsview-common.mjs';
11
12
 
12
13
  function getDefaultApp() {
@@ -44,12 +45,12 @@ async function getExtraOptions(argv)
44
45
 
45
46
  function printRevision(options)
46
47
  {
47
- console.log('**************************************************');
48
- console.log('* Android Package: ' + options.androidPackage);
49
- console.log('* Core: ' + options.jsviewCoreRevision);
50
- console.log('* Engine JS url: ' + options.jsviewEngineUrl);
51
- console.log('* Homepage url: ' + options.entryUrl);
52
- console.log('**************************************************');
48
+ Logger.Info('**************************************************');
49
+ Logger.Info('* Android Package: ' + options.androidPackage);
50
+ Logger.Info('* Core: ' + options.jsviewCoreRevision);
51
+ Logger.Info('* Engine JS url: ' + options.jsviewEngineUrl);
52
+ Logger.Info('* Homepage url: ' + options.entryUrl);
53
+ Logger.Info('**************************************************');
53
54
  }
54
55
 
55
56
  function androidStartActivity(options)
@@ -59,11 +60,11 @@ function androidStartActivity(options)
59
60
  cmdline += ` --es COREVERSIONRANGE "${options.jsviewCoreRevision}"`;
60
61
  cmdline += ` --es ENGINE "${options.jsviewEngineUrl}"`;
61
62
  cmdline += ` --es URL "${options.entryUrl}"`;
62
- console.log(`Run command: ${cmdline}\n`);
63
+ Logger.Info(`Run command: ${cmdline}\n`);
63
64
  try {
64
65
  childProcess.execSync(cmdline, {stdio: [0, 1, 2]});
65
66
  } catch (e) {
66
- // console.log(e);
67
+ Logger.Error("Failed to exec command.");
67
68
  }
68
69
  }
69
70