@makano/rew 1.2.0 → 1.2.2

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.
@@ -227,7 +227,7 @@ yargs(hideBin(process.argv))
227
227
  'Install an app',
228
228
  (yargs) => {
229
229
  yargs.positional('path', {
230
- describe: 'Path of the app to install',
230
+ describe: 'Path or github or repo id of the app to install',
231
231
  type: 'string',
232
232
  });
233
233
  },
@@ -235,6 +235,23 @@ yargs(hideBin(process.argv))
235
235
  utils.installAppFrom(argv.path);
236
236
  },
237
237
  )
238
+ .command(
239
+ 'uninstall <package>',
240
+ 'Unnstall an app',
241
+ (yargs) => {
242
+ yargs.positional('package', {
243
+ describe: 'Package of the app to uninstall',
244
+ type: 'string',
245
+ }).option('all', {
246
+ alias: 'a',
247
+ describe: 'Remove the configs as well',
248
+ type: 'boolean',
249
+ });
250
+ },
251
+ async (argv) => {
252
+ utils.uninstall(argv.package, argv.all);
253
+ },
254
+ )
238
255
  .command(
239
256
  'version',
240
257
  'Rew Version',
@@ -294,6 +311,11 @@ yargs(hideBin(process.argv))
294
311
  describe: 'Translate to js',
295
312
  type: 'boolean',
296
313
  })
314
+ .option('single', {
315
+ alias: 's',
316
+ describe: 'Build single file(don\'t build imports)',
317
+ type: 'boolean',
318
+ })
297
319
  .option('remove', {
298
320
  alias: 'r',
299
321
  describe: 'Remove all coffee',
@@ -11,6 +11,7 @@ const { compile } = require('../modules/compiler');
11
11
  const { to_qrew } = require('../qrew/compile');
12
12
  const { findAppInfo } = require('../misc/findAppInfo');
13
13
  const { req } = require('../misc/req');
14
+ const { CONFIG_PATH } = require('../const/config_path');
14
15
 
15
16
  const npm_package_name = '@makano/rew';
16
17
 
@@ -180,11 +181,19 @@ module.exports = {
180
181
  file: path.join(installPath, c.install.build.file)
181
182
  });
182
183
  }
184
+ if(c.install.commands){
185
+ for(let command of c.install.commands){
186
+ execSync(command.replace(/\$installPath/g, installPath));
187
+ }
188
+ }
189
+ if(c.install.file){
190
+ run(path.join(installPath, c.install.file));
191
+ }
183
192
  }
184
193
  rl.close();
185
194
  } else {
186
195
  if (rmidiri) {
187
- execSync(`rm -r ${apppath}`);
196
+ execSync(`rm -rf ${apppath}`);
188
197
  }
189
198
  log(' Canceled install'.red.bold, ':end');
190
199
  rl.close();
@@ -235,7 +244,7 @@ module.exports = {
235
244
 
236
245
  function processFile(filePath, importsArray) {
237
246
  const content = readFile(filePath);
238
- const imports = extractImports(content);
247
+ const imports = argv.single ? [] : extractImports(content);
239
248
 
240
249
  imports.forEach((importStatement) => {
241
250
  const importedFilePath = path.resolve(path.dirname(filePath), importStatement.url);
@@ -292,6 +301,20 @@ module.exports = {
292
301
  else if(path.startsWith('@')) this.fromRepo(path);
293
302
  else this.installApp(path);
294
303
  },
304
+ uninstall(packageName, all){
305
+ const confPath = path.join(CONFIG_PATH, packageName);
306
+ const apppath = path.resolve(confPath, 'app');
307
+ const appConfpath = path.join(apppath, 'app.yaml');
308
+ if(!fs.existsSync(appConfpath) && fs.existsSync(confPath) && !all){
309
+ log(` App ${packageName.green}`.red.bold, `not found`.red.bold, `but configs are found.`.green.bold);
310
+ return log(`Use the`.cyan, '--all'.green, 'flag to remove them.'.cyan, ':end');
311
+ } else if(!fs.existsSync(appConfpath) && !all){
312
+ return log(` App ${packageName.green}`.red.bold, `not found.`.red.bold, ':end');
313
+ }
314
+ log('Uninstalling'.cyan, packageName.green);
315
+ execSync('rm -rf '+(all ? confPath : apppath));
316
+ log('Uninstalled'.cyan, ':end');
317
+ },
295
318
  async getRepoJson(repoUrl){
296
319
  try{
297
320
  const text = (await req(repoUrl.startsWith('//.') ? 'http://'+repoUrl.slice(3) : repoUrl.startsWith('//') ? 'https://'+repoUrl : repoUrl)).data;
@@ -346,7 +369,7 @@ module.exports = {
346
369
  if(json.packages) Object.keys(json.packages).forEach(name => log(name)) || log(`${Object.keys(json.packages).length} Packages in ${key}`, ':end');
347
370
  else log('None'.blue, ':end')
348
371
  } else {
349
- console.log(Object.keys(repos).join('\n'));
372
+ console.log(Object.keys(confInstance.getAll()).join('\n'));
350
373
  }
351
374
  } else if (command === 'delete') {
352
375
  confInstance.remove('repos');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "lib/rew/main.js",
6
6
  "directories": {