All files / src/commands/unlink unlink.command.js

71.42% Statements 15/21
100% Branches 1/1
0% Functions 0/1
71.42% Lines 15/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x             193x 193x  
import { defineCommand } from '../../lib/define-command.js';
import { styleText } from '../../lib/style-text.js';
import { Logger } from '../../logger.js';
import * as AppConfig from '../../models/app_configuration.js';
import * as Application from '../../models/application.js';
import { aliasArg } from '../global.args.js';
 
export const unlinkCommand = defineCommand({
  description: 'Unlink this repo from an existing application',
  since: '0.2.0',
  options: {},
  args: [aliasArg],
  async handler(_options, alias) {
    const app = await AppConfig.getAppDetails({ alias });

    await Application.unlinkRepo(app.alias);
    Logger.printSuccess(
      `Application ${styleText('green', app.appId)} has been successfully unlinked from local alias ${styleText('green', app.alias)}!`,
    );
  },
});