@makano/rew 1.2.0 → 1.2.1

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,22 @@ 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
+ describe: 'Remove the configs as well',
247
+ type: 'boolean',
248
+ });
249
+ },
250
+ async (argv) => {
251
+ utils.uninstall(argv.package, argv.all);
252
+ },
253
+ )
238
254
  .command(
239
255
  'version',
240
256
  'Rew Version',
@@ -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
 
@@ -184,7 +185,7 @@ module.exports = {
184
185
  rl.close();
185
186
  } else {
186
187
  if (rmidiri) {
187
- execSync(`rm -r ${apppath}`);
188
+ execSync(`rm -rf ${apppath}`);
188
189
  }
189
190
  log(' Canceled install'.red.bold, ':end');
190
191
  rl.close();
@@ -292,6 +293,20 @@ module.exports = {
292
293
  else if(path.startsWith('@')) this.fromRepo(path);
293
294
  else this.installApp(path);
294
295
  },
296
+ uninstall(packageName, all){
297
+ const confPath = path.join(CONFIG_PATH, packageName);
298
+ const apppath = path.resolve(confPath, 'app');
299
+ const appConfpath = path.join(apppath, 'app.yaml');
300
+ if(!fs.existsSync(appConfpath) && fs.existsSync(confPath) && !all){
301
+ log(` App ${packageName.green}`.red.bold, `not found`.red.bold, `but configs are found.`.green.bold);
302
+ return log(`Use the`.cyan, '--all'.green, 'flag to remove them.'.cyan, ':end');
303
+ } else if(!fs.existsSync(appConfpath) && !all){
304
+ return log(` App ${packageName.green}`.red.bold, `not found.`.red.bold, ':end');
305
+ }
306
+ log('Uninstalling'.cyan, packageName.green);
307
+ execSync('rm -rf '+(all ? confPath : apppath));
308
+ log('Uninstalled'.cyan, ':end');
309
+ },
295
310
  async getRepoJson(repoUrl){
296
311
  try{
297
312
  const text = (await req(repoUrl.startsWith('//.') ? 'http://'+repoUrl.slice(3) : repoUrl.startsWith('//') ? 'https://'+repoUrl : repoUrl)).data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "lib/rew/main.js",
6
6
  "directories": {