jsir 2.0.2 → 2.0.4
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/cmd/oaa.js +17 -2
- package/evalCode.js +2 -3
- package/package.json +3 -26
- package/util.js +15 -20
package/cmd/oaa.js
CHANGED
|
@@ -31,7 +31,22 @@ let _haveWrapperInput = true
|
|
|
31
31
|
let _workspaceConfigFile = 'workspace.json';
|
|
32
32
|
let _exit = false
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const _data = {}
|
|
35
|
+
const $data = {
|
|
36
|
+
get: (key, val) => {
|
|
37
|
+
if (!(key in _data) && val !== undefined) {
|
|
38
|
+
_data[key] = val
|
|
39
|
+
}
|
|
40
|
+
return _data[key]
|
|
41
|
+
},
|
|
42
|
+
set: (key, val) => {
|
|
43
|
+
_data[key] = val
|
|
44
|
+
},
|
|
45
|
+
del: (key) => {
|
|
46
|
+
delete _data[key]
|
|
47
|
+
},
|
|
48
|
+
keys: () => Object.keys(_data)
|
|
49
|
+
}
|
|
35
50
|
const $homeDir = getLibDataDir()
|
|
36
51
|
const $lib = {...require('../util')}
|
|
37
52
|
|
|
@@ -372,7 +387,7 @@ function rename(dir, oldName, newName) {
|
|
|
372
387
|
if (_fs.existsSync(_new)) {
|
|
373
388
|
warn(`${_new} already exist`)
|
|
374
389
|
} else {
|
|
375
|
-
_fs.
|
|
390
|
+
_fs.renameSync(old, _new)
|
|
376
391
|
info(`${_new} renamed`)
|
|
377
392
|
}
|
|
378
393
|
_cmdMap = {
|
package/evalCode.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const {info: $info, msg: $msg, warn: $warn, error: $error,
|
|
2
2
|
infoStr: $infoStr, msgStr: $msgStr, warnStr: $warnStr, errorStr: $errorStr,
|
|
3
3
|
tableStr: $tableStr, nableStr: $nableStr,
|
|
4
|
-
errorMsg: $errorMsg, errorStack: $errorStack
|
|
5
|
-
importG: $import} = require("./util");
|
|
4
|
+
errorMsg: $errorMsg, errorStack: $errorStack} = require("./util");
|
|
6
5
|
require = require("./util").requireG;
|
|
7
6
|
module.exports = async ($text = '', $cmdName = '', $args = [],
|
|
8
7
|
$data,
|
|
@@ -16,7 +15,7 @@ module.exports = async ($text = '', $cmdName = '', $args = [],
|
|
|
16
15
|
const $defArgs = () => $args;
|
|
17
16
|
const $context = {
|
|
18
17
|
global, $data,
|
|
19
|
-
$require, $requires,
|
|
18
|
+
$require, $requires,
|
|
20
19
|
$info, $msg, $warn, $error,
|
|
21
20
|
$infoStr, $msgStr, $warnStr, $errorStr,
|
|
22
21
|
$tableStr, $nableStr,
|
package/package.json
CHANGED
|
@@ -1,47 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsir",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "js script manager tool",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "
|
|
7
|
+
"test": "cmd/oaa.js"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
|
-
"jsir-see": "cmd/see.js",
|
|
11
|
-
"jsir-sc": "cmd/solComplie.js",
|
|
12
|
-
"jsir-sd": "cmd/solDeploy.js",
|
|
13
|
-
"jsir-st": "cmd/solTest.js",
|
|
14
|
-
"jsir-scd": "cmd/solCd.js",
|
|
15
|
-
"jsir-stt": "cmd/solTt.js",
|
|
16
|
-
"jsir-cleanLog": "cmd/cleanLog.js",
|
|
17
|
-
"jsir-staticServer": "cmd/staticServer.js",
|
|
18
|
-
"jsir-dirServer": "cmd/dirServer.js",
|
|
19
|
-
"jsir-stop": "cmd/stop.js",
|
|
20
|
-
"jsir-mock": "cmd/mockServer.js",
|
|
21
|
-
"jsir-ethDataServer": "cmd/ethDataServer.js",
|
|
22
|
-
"jsir-configServer": "cmd/configServer.js",
|
|
23
10
|
"jsir": "cmd/oaa.js"
|
|
24
11
|
},
|
|
25
12
|
"keywords": [],
|
|
26
13
|
"author": "",
|
|
27
14
|
"license": "ISC",
|
|
28
15
|
"dependencies": {
|
|
29
|
-
"abi-decoder": "^2.4.0",
|
|
30
|
-
"address": "^1.1.2",
|
|
31
16
|
"axios": "^0.20.0",
|
|
32
17
|
"bignumber.js": "^9.0.0",
|
|
33
18
|
"chokidar": "^3.5.2",
|
|
34
19
|
"console.table": "^0.10.0",
|
|
35
20
|
"dayjs": "^1.10.4",
|
|
36
|
-
"ethereumjs-tx": "^1.3.7",
|
|
37
|
-
"ethereumjs-util": "^7.1.3",
|
|
38
|
-
"ethers": "^5.1.0",
|
|
39
21
|
"global-dirs": "^3.0.0",
|
|
40
|
-
"
|
|
41
|
-
"pad": "^3.2.0",
|
|
42
|
-
"server": "^1.0.30",
|
|
43
|
-
"urlencode": "^1.1.0",
|
|
44
|
-
"web3": "^1.6.1",
|
|
45
|
-
"web3-eth-contract": "^1.6.1"
|
|
22
|
+
"pad": "^3.2.0"
|
|
46
23
|
}
|
|
47
24
|
}
|
package/util.js
CHANGED
|
@@ -394,20 +394,6 @@ function requireG(module){
|
|
|
394
394
|
return require(path);
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
async function importG(module) {
|
|
398
|
-
try {
|
|
399
|
-
let result = await import(module);
|
|
400
|
-
if (result) {
|
|
401
|
-
return result
|
|
402
|
-
}
|
|
403
|
-
} catch (e) {}
|
|
404
|
-
let path = globalDirectories.npm.packages + '/' + module + '/index.js';
|
|
405
|
-
if (!fs.existsSync(path)) {
|
|
406
|
-
throw `ERROR: ${module} not found, use [npm install -g ${module}] to install it`;
|
|
407
|
-
}
|
|
408
|
-
return await import(path);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
397
|
function validStr(str, name) {
|
|
412
398
|
if (!vl(str) || typeof str !== 'string') {
|
|
413
399
|
throw "invalid cipher " + name;
|
|
@@ -448,7 +434,7 @@ function aesDecipher(str, key){
|
|
|
448
434
|
}
|
|
449
435
|
}
|
|
450
436
|
|
|
451
|
-
function getConfig(key, defaultVal) {
|
|
437
|
+
function getConfig(key, defaultVal = '') {
|
|
452
438
|
let configInit = {}
|
|
453
439
|
if (key) {
|
|
454
440
|
configInit[key] = ''
|
|
@@ -459,7 +445,7 @@ function getConfig(key, defaultVal) {
|
|
|
459
445
|
}
|
|
460
446
|
|
|
461
447
|
let config = JSON.parse(String(fs.readFileSync(configFile)))
|
|
462
|
-
if (
|
|
448
|
+
if (key === undefined) {
|
|
463
449
|
return config
|
|
464
450
|
}
|
|
465
451
|
let actConfigKeys = Object.keys(config);
|
|
@@ -473,12 +459,22 @@ function getConfig(key, defaultVal) {
|
|
|
473
459
|
if (writeFlag) {
|
|
474
460
|
fs.writeFileSync(configFile, JSON.stringify(config, null, 2))
|
|
475
461
|
}
|
|
476
|
-
|
|
477
|
-
|
|
462
|
+
let val
|
|
463
|
+
if (!(key in config)) {
|
|
464
|
+
val = defaultVal
|
|
465
|
+
} else {
|
|
466
|
+
val = config[key]
|
|
467
|
+
}
|
|
468
|
+
if (typeof val === "string") {
|
|
469
|
+
val = trim(val)
|
|
470
|
+
}
|
|
471
|
+
return val
|
|
478
472
|
}
|
|
479
473
|
|
|
480
474
|
function setConfig(key, val) {
|
|
481
|
-
val
|
|
475
|
+
if (typeof val === "string") {
|
|
476
|
+
val = trim(val)
|
|
477
|
+
}
|
|
482
478
|
let configInit = {}
|
|
483
479
|
if (key) {
|
|
484
480
|
configInit[key] = val
|
|
@@ -1314,6 +1310,5 @@ module.exports = {
|
|
|
1314
1310
|
iarrayDataFile,
|
|
1315
1311
|
isArgsMatch,
|
|
1316
1312
|
draftQuery,
|
|
1317
|
-
importG,
|
|
1318
1313
|
getTextComments
|
|
1319
1314
|
}
|