@makano/rew 1.2.46 → 1.2.47
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/rew/cli/utils.js +35 -21
- package/lib/rew/pkgs/conf.js +1 -1
- package/package.json +1 -1
package/lib/rew/cli/utils.js
CHANGED
@@ -64,15 +64,19 @@ module.exports = {
|
|
64
64
|
if (!fullPath || fullPath == 'list') {
|
65
65
|
return fs.readdirSync(con.CONFIG_PATH).join('\n');
|
66
66
|
} else {
|
67
|
-
|
68
|
-
|
67
|
+
let name = fullPath.indexOf('/') ? fullPath.split('/')[0] : fullPath;
|
68
|
+
let dpath = fullPath.indexOf('/') ? fullPath.split('/').slice(1).join('/') : '';
|
69
|
+
if(fullPath.startsWith('/')){
|
70
|
+
dpath = name;
|
71
|
+
name = '';
|
72
|
+
}
|
69
73
|
const root = con.create(name);
|
70
74
|
if (dpath) {
|
71
75
|
const fp = path.join(root.root, dpath);
|
72
|
-
if (fs.existsSync(fp) && fs.statSync(fp).isDirectory()) {
|
76
|
+
if (!fullPath.startsWith('/') && fs.existsSync(fp) && fs.statSync(fp).isDirectory()) {
|
73
77
|
return fs.readdirSync(fp).join('\n');
|
74
78
|
} else {
|
75
|
-
const o =
|
79
|
+
const o = dpath && dpath !== '/' ? root.optionCenter(dpath) : root.optionCenter('_default');
|
76
80
|
return key ? o.get(key) : o.getAll(true);
|
77
81
|
}
|
78
82
|
} else {
|
@@ -80,14 +84,18 @@ module.exports = {
|
|
80
84
|
}
|
81
85
|
}
|
82
86
|
} else {
|
83
|
-
|
84
|
-
|
85
|
-
if
|
87
|
+
let name = fullPath.indexOf('/') ? fullPath.split('/')[0] : fullPath;
|
88
|
+
let dpath = fullPath.indexOf('/') ? fullPath.split('/')[1] : '';
|
89
|
+
if(fullPath.startsWith('/')){
|
90
|
+
dpath = name == '/' ? '_default' : name;
|
91
|
+
name = '';
|
92
|
+
}
|
93
|
+
if (key) {
|
86
94
|
const root = con.create(name);
|
87
95
|
const o = dpath ? root.optionCenter(dpath) : root;
|
88
96
|
if (command == 'set') {
|
89
97
|
if (value) {
|
90
|
-
o.set(key, value);
|
98
|
+
o.set(key, value == 'false' || value == 'true' ? (value == 'true' ? true : false) : !isNaN(parseFloat(value)) ? parseFloat(value) : value);
|
91
99
|
} else {
|
92
100
|
log('Value not specified', ':end');
|
93
101
|
}
|
@@ -95,7 +103,7 @@ module.exports = {
|
|
95
103
|
o.remove(key);
|
96
104
|
}
|
97
105
|
} else {
|
98
|
-
log(
|
106
|
+
log('Key not specified', ':end');
|
99
107
|
}
|
100
108
|
}
|
101
109
|
},
|
@@ -222,7 +230,6 @@ module.exports = {
|
|
222
230
|
}
|
223
231
|
execSync(`cp -r ${apppath} ${installPath}`);
|
224
232
|
execSync(`chmod 444 ${installPath}/app.yaml`);
|
225
|
-
log(' Installed '.green + pname.cyan.bold, ':end');
|
226
233
|
if (c.install) {
|
227
234
|
if (c.install.commands) {
|
228
235
|
for (let command of c.install.commands) {
|
@@ -231,7 +238,7 @@ module.exports = {
|
|
231
238
|
} catch(e){
|
232
239
|
const logFile = path.join(logspath, 'logs-'+Date.now()+'.log');
|
233
240
|
fs.writeFileSync(logFile, e.toString() +'\n'+ e.stack);
|
234
|
-
log(` Command Failed: ${command}, check logs at ${logFile}
|
241
|
+
log(` Command Failed: ${command}, check logs at ${logFile}`);
|
235
242
|
}
|
236
243
|
}
|
237
244
|
}
|
@@ -243,18 +250,25 @@ module.exports = {
|
|
243
250
|
}
|
244
251
|
if (c.install.exec) {
|
245
252
|
// this.installReq(c);
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
253
|
+
if(conf({}).create('').get('executables') == false){
|
254
|
+
log(' Ignoring executables'.blue);
|
255
|
+
} else {
|
256
|
+
for (let i in c.install.exec) {
|
257
|
+
let iff = c.install.exec[i];
|
258
|
+
if (iff in c.exec) iff = c.exec[iff];
|
259
|
+
const file = path.join(installPath, iff);
|
260
|
+
const filepath = path.join(binpath, i);
|
261
|
+
const binfp = path.join(localBinPath, i);
|
262
|
+
if (!fs.existsSync(localBinPath)) fs.mkdirSync(localBinPath, { recursive: true });
|
263
|
+
fs.writeFileSync(filepath, `#!/usr/bin/env bash\n#@app.${pname}\nrew ${file} $*`);
|
264
|
+
fs.chmodSync(filepath, '755');
|
265
|
+
if(fs.existsSync(binfp)) fs.unlinkSync(binfp);
|
266
|
+
fs.linkSync(filepath, binfp);
|
267
|
+
}
|
256
268
|
}
|
257
269
|
}
|
270
|
+
|
271
|
+
log(' Installed '.green + pname.cyan.bold, ':end');
|
258
272
|
}
|
259
273
|
rl.close();
|
260
274
|
} else {
|
package/lib/rew/pkgs/conf.js
CHANGED
@@ -82,7 +82,7 @@ module.exports = (context) => ({
|
|
82
82
|
};
|
83
83
|
|
84
84
|
return {
|
85
|
-
get: (key, defaultValue) => getData(optionCenter, key)
|
85
|
+
get: (key, defaultValue) => getData(optionCenter, key) ?? defaultValue,
|
86
86
|
set: (key, value) => setData(optionCenter, key, value),
|
87
87
|
remove: (key) => removeData(optionCenter, key),
|
88
88
|
reset: () => fs.writeFileSync(optionCenter.root, dumpYaml(defaults)) && (conf[name] = defaults),
|