All files / src/scripts/createProject index.ts

100% Statements 19/19
100% Branches 2/2
100% Functions 2/2
100% Lines 18/18

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 301x 1x 1x 1x 1x 1x   2x       2x 2x   2x 2x   2x 2x     2x 2x   2x 2x     1x  
import path from 'path';
import log from '../../utils/log';
import copyIntegrationTheme from './copyIntegrationTheme';
import copyAgnosticTheme from './copyAgnosticTheme';
import processMagicComments from './processMagicComments';
import updatePackageJson from './updatePackageJson';
 
const getProjectDirectoryName = (targetPath: string): string => targetPath.split('/').pop();
 
async function createProject(integration: string, targetPath: string): Promise<void> {
 
  log.info(`Coppying ${integration}-theme to ${targetPath}`);
  await copyIntegrationTheme(integration, targetPath, ['_theme', '.nuxt', 'node_modules']);
 
  log.info(`Coppying agnostic theme to ${targetPath}`);
  await copyAgnosticTheme(integration, targetPath);
 
  log.info('Updating Nuxt config');
  const absoluteTargetPath = path.isAbsolute(targetPath)
    ? targetPath
    : path.join(__dirname, targetPath);
  const nuxtConfigPath = path.join(absoluteTargetPath, 'nuxt.config.js');
  await processMagicComments(nuxtConfigPath);
 
  const packageJsonPath = path.join(absoluteTargetPath, 'package.json');
  await updatePackageJson(packageJsonPath, getProjectDirectoryName(targetPath));
}
 
export default createProject;