@makano/rew 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/rew/cli/cli.js +46 -18
- package/lib/rew/cli/miscUtils.js +3 -1
- package/lib/rew/cli/utils.js +5 -4
- package/lib/rew/pkgs/conf.js +1 -1
- package/package.json +1 -1
package/lib/rew/cli/cli.js
CHANGED
@@ -6,7 +6,6 @@ const path = require('path');
|
|
6
6
|
const { hideBin } = require('yargs/helpers');
|
7
7
|
const { existsSync, readFileSync, writeFileSync, statSync, unlinkSync } = require('fs');
|
8
8
|
const { log } = require('./log');
|
9
|
-
const rune = require('../pkgs/rune');
|
10
9
|
const { to_qrew, from_qrew } = require('../qrew/compile');
|
11
10
|
const { findAppInfo } = require('../misc/findAppInfo');
|
12
11
|
const { input } = require('../functions/stdout');
|
@@ -74,7 +73,11 @@ yargs(hideBin(process.argv))
|
|
74
73
|
alias: 'c',
|
75
74
|
describe: 'Compile and output the javascript',
|
76
75
|
type: 'boolean',
|
77
|
-
})
|
76
|
+
})
|
77
|
+
.example('rew exec "print \'hi\'"', "Executes code")
|
78
|
+
.example('echo "print \\hi\'" | rew exec', "Executes code from pipe")
|
79
|
+
.example('rew exec "print \'hi\'" -- arg1', "Executes code with arguments")
|
80
|
+
.example('echo "print \\hi\'" | rew exec -- arg1', "Executes code from pipe with arguments");
|
78
81
|
},
|
79
82
|
async (argv) => {
|
80
83
|
const replFile = '/tmp/rew-'+generateRandomID()+'-'+Date.now()+'.coffee';
|
@@ -116,7 +119,17 @@ yargs(hideBin(process.argv))
|
|
116
119
|
describe: 'Value to set (only used with "set" command)',
|
117
120
|
type: 'string',
|
118
121
|
default: '',
|
119
|
-
})
|
122
|
+
})
|
123
|
+
.example('rew conf get', 'Get all the possible conf-sets')
|
124
|
+
.example('rew conf get app.package', 'Get all files for app.package')
|
125
|
+
.example('rew conf get app.package/_default', 'Get all default configs for app.package')
|
126
|
+
.example('rew conf get app.package/[optionGroup]', 'Get all configs for app.package/[optionGroup]')
|
127
|
+
.example('rew conf get app.package/[optionGroup] [key]', 'Get value of \'key\' for app.package/[optionGroup]')
|
128
|
+
.example('rew conf get app.package/app', 'List all files for the app if the app is installed')
|
129
|
+
.example('rew conf get app.package/path/to/file', 'Reads file or lists directory')
|
130
|
+
|
131
|
+
.example('rew conf set app.package/[optionGroup] [key] "[value]"', "Sets 'key' to 'value' for app.package/[optionGroup]")
|
132
|
+
.example('rew conf remove app.package/[optionGroup] [key]', "Removes 'key' from app.package/[optionGroup]");
|
120
133
|
},
|
121
134
|
(argv) => {
|
122
135
|
const { command, path, key, value } = argv;
|
@@ -152,21 +165,20 @@ yargs(hideBin(process.argv))
|
|
152
165
|
describe: `Use default options`,
|
153
166
|
type: 'boolean',
|
154
167
|
default: false
|
155
|
-
})
|
168
|
+
})
|
169
|
+
.example('rew create /path/to/project', 'Open interactive shell to create app at path')
|
170
|
+
.example('rew create -i /path/to/project', 'Create without interactive shell')
|
171
|
+
.example('rew create -n package.name /path/to/project', 'Create with "-n" as a package name')
|
172
|
+
.example('rew create -t /path/to/project', 'Enable types')
|
173
|
+
.example('rew create -c /path/to/project', 'Enable civet for main')
|
174
|
+
.example('rew create -g /path/to/project', 'Setup git')
|
175
|
+
.example('rew create -git /path/to/project', '(Recommended) Setup git, no interactive shell, enable types.')
|
176
|
+
.example('rew create -gitn package.name /path/to/project', '(Recommended) Setup git, no interactive shell, enable types, set package name.');
|
156
177
|
},
|
157
178
|
(argv) => {
|
158
179
|
require('./utils').createProject(argv.path, argv);
|
159
180
|
},
|
160
181
|
)
|
161
|
-
.command(
|
162
|
-
'rune-keygen',
|
163
|
-
'Generate a rune encryption key',
|
164
|
-
(yargs) => {
|
165
|
-
},
|
166
|
-
(argv) => {
|
167
|
-
console.log('Encryption Key:', rune({}).genKey(input('Secret Value: ') || null));
|
168
|
-
},
|
169
|
-
)
|
170
182
|
.command(
|
171
183
|
'run <path | package>',
|
172
184
|
'Run an app',
|
@@ -193,7 +205,12 @@ yargs(hideBin(process.argv))
|
|
193
205
|
alias: 't',
|
194
206
|
describe: 'Builds to a .js before running, only used when --build is passed',
|
195
207
|
type: 'boolean',
|
196
|
-
})
|
208
|
+
})
|
209
|
+
.example('rew run .', "Run the current directory as an app")
|
210
|
+
.example('rew run package.name', "Run 'package.name' if it's installed")
|
211
|
+
.example('rew run . -b', "Build files into .qrew before running")
|
212
|
+
.example('rew run . --dev -b', `If current entry file ends with .qrew it changes it to .coffee or ${REW_FILE_TYPE.EXTENSION} instead, and builds it before running the build`)
|
213
|
+
.example('rew run . -e test', "Runs the 'test' entry from the 'app.yaml' if exists")
|
197
214
|
},
|
198
215
|
(argv) => {
|
199
216
|
require('./utils').runApp(argv.path, argv);
|
@@ -289,7 +306,14 @@ yargs(hideBin(process.argv))
|
|
289
306
|
alias: 'y',
|
290
307
|
describe: 'Auto yes',
|
291
308
|
type: 'boolean',
|
292
|
-
})
|
309
|
+
})
|
310
|
+
.example('rew install /path/to/app', "Installs path into the rew conf directory.")
|
311
|
+
.example('rew install -r /path/to/app', "Installs all the required libraries/apps for the specified app.")
|
312
|
+
.example('rew install github:username/repo', "Clones the repo and installs it to rew")
|
313
|
+
.example('rew install -yu github:username/repo', "Installs from github without asking for confirmation and auto updates")
|
314
|
+
.example('rew install github:username/repo@branch', "Installs a specific branch from github(default is main)")
|
315
|
+
.example('rew install github:username/repo#commit', "Installs a specific commit from github(default is latest)")
|
316
|
+
.example('rew install github:username/repo@branch#commit', "Installs a specific commit from a branch in a github repository");
|
293
317
|
},
|
294
318
|
async (argv) => {
|
295
319
|
if (argv.requirements) require('./utils').installReq(argv.path, argv);
|
@@ -307,7 +331,9 @@ yargs(hideBin(process.argv))
|
|
307
331
|
alias: 'a',
|
308
332
|
describe: 'Remove the configs as well',
|
309
333
|
type: 'boolean',
|
310
|
-
})
|
334
|
+
})
|
335
|
+
.example('rew uninstall package.name', "Uninstalls app package.name, but keeps the data/configs")
|
336
|
+
.example('rew uninstall -a package.name', "Uninstalls app package.name entirely");
|
311
337
|
},
|
312
338
|
async (argv) => {
|
313
339
|
require('./utils').uninstall(argv.package, argv.all);
|
@@ -373,10 +399,12 @@ yargs(hideBin(process.argv))
|
|
373
399
|
yargs.positional('command', {
|
374
400
|
describe: 'Misc command name',
|
375
401
|
type: 'string',
|
376
|
-
})
|
402
|
+
})
|
403
|
+
.example('rew misc types', 'Fixes types for libraries and rew runtime')
|
404
|
+
.example('rew misc keygen', 'Generate a rune encryption key')
|
377
405
|
},
|
378
406
|
(argv) => {
|
379
|
-
require('./miscUtils')[argv.command](...argv._.slice(1));
|
407
|
+
require('./miscUtils')[argv.command]?.(...argv._.slice(1));
|
380
408
|
},
|
381
409
|
)
|
382
410
|
.command(
|
package/lib/rew/cli/miscUtils.js
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
const { findAppInfo } = require("../misc/findAppInfo");
|
2
2
|
const { log } = require("./log");
|
3
3
|
const colors = require('colors');
|
4
|
+
const { input } = require('../functions/stdout');
|
4
5
|
const path = require('path');
|
5
6
|
const fs = require('fs');
|
6
7
|
const { CONFIG_PATH } = require("../const/config_path");
|
8
|
+
const rune = require("../pkgs/rune");
|
7
9
|
|
8
10
|
module.exports = {
|
9
11
|
types(projectPath){
|
@@ -37,5 +39,5 @@ module.exports = {
|
|
37
39
|
if(fs.existsSync(p)) fs.copyFileSync(p, path.join(projectPath, 'node_modules/@types/rew/'+filename));
|
38
40
|
});
|
39
41
|
},
|
40
|
-
|
42
|
+
'keygen': () => console.log('Encryption Key:', rune({}).genKey(input('Secret Value: ') || null))
|
41
43
|
}
|
package/lib/rew/cli/utils.js
CHANGED
@@ -4,9 +4,7 @@ const conf = require('../pkgs/conf');
|
|
4
4
|
const jsYaml = require('js-yaml');
|
5
5
|
const readline = require('readline');
|
6
6
|
const { log, logget } = require('./log');
|
7
|
-
const {
|
8
|
-
const { run } = require('../main');
|
9
|
-
const { generateRandomID } = require('../functions/id');
|
7
|
+
const { execSync } = require('child_process');
|
10
8
|
const { compile } = require('../modules/compiler');
|
11
9
|
const { to_qrew } = require('../qrew/compile');
|
12
10
|
const { findAppInfo } = require('../misc/findAppInfo');
|
@@ -100,7 +98,10 @@ module.exports = {
|
|
100
98
|
confObj.types = ['rew'];
|
101
99
|
}
|
102
100
|
fs.writeFileSync(confPath, jsYaml.dump(confObj));
|
103
|
-
fs.writeFileSync(entryFile, `
|
101
|
+
fs.writeFileSync(entryFile, `using namespace std::ns ->
|
102
|
+
define Main class
|
103
|
+
@main: (argv) ->
|
104
|
+
print 'Hello, World!'`);
|
104
105
|
fs.mkdirSync(path.join(projectPath, 'assets'), { recursive: true });
|
105
106
|
if (project.git) {
|
106
107
|
fs.writeFileSync(path.join(projectPath, '.gitignore'), `node_modules/\npackage-lock.json`);
|
package/lib/rew/pkgs/conf.js
CHANGED
@@ -66,7 +66,7 @@ module.exports = (context) => ({
|
|
66
66
|
};
|
67
67
|
|
68
68
|
const createOptionCenter = (name, defaults = {}) => {
|
69
|
-
const optionRoot = path.join(rootPath, name + '.yaml');
|
69
|
+
const optionRoot = path.join(rootPath, name.endsWith('.yaml') ? name : name + '.yaml');
|
70
70
|
if (!fs.existsSync(path.dirname(optionRoot))) fs.mkdirSync(path.dirname(optionRoot), { recursive: true });
|
71
71
|
if (!fs.existsSync(optionRoot)) {
|
72
72
|
conf[name] = defaults;
|