(isLocalTemplate, {template, dir})
| 62 | } |
| 63 | |
| 64 | async function verifyProjectTemplate(isLocalTemplate, {template, dir}) { |
| 65 | let keywords; |
| 66 | if (isLocalTemplate) { |
| 67 | const packageManifest = path.join(dir, 'package.json'); |
| 68 | keywords = require(packageManifest).keywords; |
| 69 | } else { |
| 70 | try { |
| 71 | const {stdout} = await execa('npm', ['info', template, 'keywords', '--json']); |
| 72 | keywords = JSON.parse(stdout); |
| 73 | } catch (err) { |
| 74 | console.log(); |
| 75 | if (err.stderr) { |
| 76 | console.error( |
| 77 | `${errorAlert} Unable to find "${colors.cyan(template)}" in the npm registry.`, |
| 78 | ); |
| 79 | } else { |
| 80 | console.log(err); |
| 81 | } |
| 82 | console.error(`${errorAlert} Cannot continue safely. Exiting...`); |
| 83 | process.exit(1); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | if (!keywords || !keywords.includes('csa-template')) { |
| 88 | console.error( |
| 89 | `\n${errorAlert} The template is not a CSA template (missing "${colors.yellow( |
| 90 | 'csa-template', |
| 91 | )}" keyword in package.json), check the template name to make sure you are using the current template name.`, |
| 92 | ); |
| 93 | console.error(`${errorAlert} Cannot continue safely. Exiting...`); |
| 94 | process.exit(1); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | async function cleanProject(dir) { |
| 99 | const packageManifest = path.join(dir, 'package.json'); |
no test coverage detected