-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update cli to use root folder
- Loading branch information
Showing
5 changed files
with
73 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,37 @@ | ||
#!/usr/bin/env node | ||
|
||
const chalk = require("chalk"); | ||
const { runCommand, cleanUpFolder } = require("./utils.js"); | ||
const chalk = require('chalk'); | ||
const { runCommand, cleanUpFolder, showMoreDetails } = require('./utils.js'); | ||
|
||
const createObytesApp = async () => { | ||
// get project name from command line | ||
const projectName = process.argv[2]; | ||
// check if project name is provided | ||
if (!projectName) { | ||
console.log(chalk.red("Please provide a project name")); | ||
console.log(chalk.red('Please provide a project name')); | ||
process.exit(1); | ||
} | ||
|
||
// create a new project based on obytes template | ||
const createRNProjectCommand = `npx -y react-native init ${projectName} --template https://github.com/obytes/react-native-template-obytes --skip-install`; | ||
const cloneStarter = `git clone --depth=1 -b new_structure https://github.com/obytes/react-native-template-obytes.git ${projectName}`; | ||
|
||
// run init command and clean up project folder | ||
await runCommand(createRNProjectCommand, { | ||
loading: "Download and extract template", | ||
success: "Template downloaded and extracted", | ||
error: "Failed to download and extract template", | ||
await runCommand(cloneStarter, { | ||
loading: 'Download and extract template', | ||
success: 'Template downloaded and extracted', | ||
error: 'Failed to download and extract template', | ||
}); | ||
|
||
await cleanUpFolder(projectName); | ||
|
||
// install dependencies | ||
await runCommand(`cd ${projectName} && yarn`, { | ||
loading: "Installing dependencies", | ||
success: "Dependencies installed", | ||
error: "Failed to install dependencies", | ||
loading: 'Installing dependencies', | ||
success: 'Dependencies installed', | ||
error: 'Failed to install dependencies', | ||
}); | ||
|
||
showMoreDetails(); | ||
}; | ||
|
||
createObytesApp(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters