All files / src/commands/domain domain.favourite.set.command.js

79.16% Statements 19/24
100% Branches 1/1
0% Functions 0/1
79.16% Lines 19/24

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 22 23 24 25193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x           193x 193x  
import { markFavouriteDomain } from '@clevercloud/client/esm/api/v2/application.js';
import { defineCommand } from '../../lib/define-command.js';
import { Logger } from '../../logger.js';
import * as Application from '../../models/application.js';
import { sendToApi } from '../../models/send-to-api.js';
import { aliasOption, appIdOrNameOption } from '../global.options.js';
import { fqdnArg } from './domain.args.js';
 
export const domainFavouriteSetCommand = defineCommand({
  description: 'Set the favourite domain for an application',
  since: '2.7.0',
  options: {
    alias: aliasOption,
    app: appIdOrNameOption,
  },
  args: [fqdnArg],
  async handler(options, fqdn) {
    const { alias, app: appIdOrName } = options;
    const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);

    await markFavouriteDomain({ id: ownerId, appId }, { fqdn }).then(sendToApi);
    Logger.println('Your favourite domain has been successfully set');
  },
});