All files / src/tools deploy.ts

27.27% Statements 3/11
0% Branches 0/4
0% Functions 0/2
27.27% Lines 3/11

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 25 26 27 28 29 30 31 32 33 34 35 36 371x 1x       1x                                                              
import Auth0 from './auth0';
import log from '../logger';
import { ConfigFunction } from '../configFactory';
import { Assets, Auth0APIClient } from '../types';
 
export default async function deploy(
  assets: Assets,
  client: Auth0APIClient,
  config: ConfigFunction
) {
  // Setup log level
  log.level = process.env.AUTH0_DEBUG === 'true' ? 'debug' : 'info';
 
  log.info(
    `Getting access token for ${
      config('AUTH0_CLIENT_ID') !== undefined ? `${config('AUTH0_CLIENT_ID')}/` : ''
    }${config('AUTH0_DOMAIN')}`
  );
 
  const auth0 = new Auth0(client, assets, config);
 
  // Validate Assets
  await auth0.validate();
 
  // Process changes
  await auth0.processChanges();
 
  return auth0.handlers.reduce((accum, h) => {
    accum[h.type] = {
      deleted: h.deleted,
      created: h.created,
      updated: h.updated,
    };
    return accum;
  }, {});
}