|
1 | 1 | #!/usr/bin/env node |
2 | 2 |
|
3 | | -const chalk = require('chalk'); |
4 | | -const { runCommand, cleanUpFolder, showMoreDetails } = require('./utils.js'); |
| 3 | +const { consola } = require('consola'); |
| 4 | +const { showMoreDetails } = require('./utils.js'); |
| 5 | +const { cloneLastTemplateRelease } = require('./clone-repo.js'); |
| 6 | +const { setupProject, installDeps } = require('./setup-project.js'); |
5 | 7 |
|
6 | 8 | const createObytesApp = async () => { |
| 9 | + consola.box('Obytes Starter\nPerfect React Native App Kickstart 🚀!'); |
7 | 10 | // get project name from command line |
8 | 11 | const projectName = process.argv[2]; |
9 | 12 | // check if project name is provided |
10 | 13 | if (!projectName) { |
11 | | - console.log(chalk.red('Please provide a project name')); |
| 14 | + consola.error( |
| 15 | + 'Please provide a name for your project: `npx create-obytes-app@latest <project-name>`' |
| 16 | + ); |
12 | 17 | process.exit(1); |
13 | 18 | } |
| 19 | + // clone the last release of the template from github |
| 20 | + await cloneLastTemplateRelease(projectName); |
14 | 21 |
|
15 | | - // create a new project based on obytes template |
16 | | - const cloneStarter = `git clone --depth=1 https://github.com/obytes/react-native-template-obytes.git ${projectName}`; |
| 22 | + // setup the project: remove unnecessary files, update package.json infos, name and set version to 0.0.1 + add initial version to osMetadata |
| 23 | + await setupProject(projectName); |
17 | 24 |
|
18 | | - // run init command and clean up project folder |
19 | | - await runCommand(cloneStarter, { |
20 | | - loading: 'Download and extract template', |
21 | | - success: 'Template downloaded and extracted', |
22 | | - error: 'Failed to download and extract template', |
23 | | - }); |
| 25 | + // install project dependencies using pnpm |
| 26 | + await installDeps(projectName); |
24 | 27 |
|
25 | | - await cleanUpFolder(projectName); |
26 | | - |
27 | | - // install dependencies |
28 | | - await runCommand(`cd ${projectName} && pnpm install`, { |
29 | | - loading: 'Installing dependencies', |
30 | | - success: 'Dependencies installed', |
31 | | - error: 'Failed to install dependencies, Make sure you have pnpm installed', |
32 | | - }); |
33 | | - |
34 | | - showMoreDetails(); |
| 28 | + // show instructions to run the project + link to the documentation |
| 29 | + showMoreDetails(projectName); |
35 | 30 | }; |
36 | 31 |
|
37 | 32 | createObytesApp(); |
0 commit comments