Skip to content

Commit a58b597

Browse files
committed
feat(cli): use our repository as template
1 parent af7be68 commit a58b597

File tree

6 files changed

+27
-23
lines changed

6 files changed

+27
-23
lines changed

.github/workflows/sonar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT }}
4141
-Dsonar.sonar.sourceEncoding=UTF-8
4242
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
43-
-Dsonar.coverage.exclusions=**/storage/**,**/**.config.js,**/*.test.tsx,**/icons/**,**/docs/**,**/cli/**,**/__mocks__/**,**/android/**,**/ios/**
43+
-Dsonar.coverage.exclusions=**/storage/**,**/**.config.js,**/*.test.tsx,**/icons/**,**/docs/**,**/cli/**,**/__mocks__/**,**/android/**,**/ios/**,env.js

cli/clone-repo.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const { runCommand } = require('./utils.js');
22
const { consola } = require('consola');
33

4+
const repository = "rootstrap/react-native-template";
5+
46
const getLatestRelease = async () => {
57
try {
68
const repoData = await fetch(
7-
'https://api.github.com/repos/obytes/react-native-template-obytes/releases/latest'
9+
`https://api.github.com/repos/${repository}/releases/latest`
810
);
911
const releaseData = await repoData.json();
1012
return releaseData.tag_name || 'master';
@@ -19,13 +21,13 @@ const getLatestRelease = async () => {
1921
const cloneLastTemplateRelease = async (projectName) => {
2022
consola.start('Extracting last release number 👀');
2123
const latest_release = await getLatestRelease();
22-
consola.info(`Using Obytes starter ${latest_release}`);
24+
consola.info(`Using Rootstrap's Template ${latest_release}`);
2325

24-
// create a new project based on obytes template
25-
const cloneStarter = `git clone -b ${latest_release} --depth=1 https://github.com/obytes/react-native-template-obytes.git ${projectName}`;
26+
// create a new project based on Rootstrap template
27+
const cloneStarter = `git clone -b ${latest_release} --depth=1 https://github.com/${repository}.git ${projectName}`;
2628
await runCommand(cloneStarter, {
27-
loading: 'Extracting the starter template...',
28-
success: 'Starter extracted successfully',
29+
loading: 'Extracting the template...',
30+
success: 'Template extracted successfully',
2931
error: 'Failed to download and extract template',
3032
});
3133
};

cli/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ const { consola } = require('consola');
44
const { showMoreDetails } = require('./utils.js');
55
const { cloneLastTemplateRelease } = require('./clone-repo.js');
66
const { setupProject, installDeps } = require('./setup-project.js');
7+
const pkg = require('./package.json');
78

8-
const createObytesApp = async () => {
9-
consola.box('Obytes Starter\nPerfect React Native App Kickstart 🚀!');
9+
const { name: packageName } = pkg;
10+
const createRootstrapApp = async () => {
11+
consola.box("Rootstrap's React Native Template\nPerfect React Native App Kickstart 🚀!");
1012
// get project name from command line
1113
const projectName = process.argv[2];
1214
// check if project name is provided
1315
if (!projectName) {
1416
consola.error(
15-
'Please provide a name for your project: `npx create-rootstrap-rn-app@latest <project-name>`'
17+
`Please provide a name for your project: \`npx ${packageName}@latest <project-name>\``
1618
);
1719
process.exit(1);
1820
}
@@ -29,4 +31,4 @@ const createObytesApp = async () => {
2931
showMoreDetails(projectName);
3032
};
3133

32-
createObytesApp();
34+
createRootstrapApp();

cli/setup-project.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const initGit = async (projectName) => {
99

1010
const installDeps = async (projectName) => {
1111
await runCommand(`cd ${projectName} && pnpm install`, {
12-
loading: 'Installing project dependencies',
12+
loading: 'Installing project dependencies',
1313
success: 'Dependencies installed',
1414
error: 'Failed to install dependencies, Make sure you have pnpm installed',
1515
});
@@ -55,9 +55,9 @@ const updateProjectConfig = async (projectName) => {
5555
encoding: 'utf-8',
5656
});
5757
const replaced = contents
58-
.replace(/ObytesApp/gi, projectName)
59-
.replace(/com.obytes/gi, `com.${projectName.toLowerCase()}`)
60-
.replace(/obytes/gi, 'expo-owner');
58+
.replace(/RootstrapApp/gi, projectName)
59+
.replace(/com.rootstrap/gi, `com.${projectName.toLowerCase()}`)
60+
.replace(/rootstrap/gi, 'expo-owner');
6161

6262
fs.writeFileSync(configPath, replaced, { spaces: 2 });
6363
const readmeFilePath = path.join(

cli/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const showMoreDetails = (projectName) => {
3333
'Your project is ready to go! \n\n\n',
3434
'🚀 To get started, run the following commands: \n\n',
3535
` \`cd ${projectName}\` \n`,
36-
' IOS : `pnpm ios` \n',
36+
' iOS : `pnpm ios` \n',
3737
' Android : `pnpm android` \n\n',
38-
'📚 Starter Documentation: https://starter.obytes.com'
38+
'📚 Template Documentation: https://rootstrap.github.io/react-native-template'
3939
);
4040
};
4141

env.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ require('dotenv').config({
2828
* Such as: bundle id, package name, app name.
2929
*
3030
* You can add them to the .env file but we think it's better to keep them here as as we use prefix to generate this values based on the APP_ENV
31-
* for example: if the APP_ENV is staging, the bundle id will be com.obytes.staging
31+
* for example: if the APP_ENV is staging, the bundle id will be com.rootstrap.staging
3232
*/
3333

3434
// TODO: Replace these values with your own
3535

36-
const BUNDLE_ID = 'com.rs.mobile'; // ios bundle id
37-
const PACKAGE = 'com.rs.mobile'; // android package name
38-
const NAME = 'react-native-template'; // app name
39-
const EXPO_ACCOUNT_OWNER = 'rsdevs'; // expo account owner
36+
const BUNDLE_ID = 'com.rootstrap'; // ios bundle id
37+
const PACKAGE = 'com.rootstrap'; // android package name
38+
const NAME = 'RootstrapApp'; // app name
39+
const EXPO_ACCOUNT_OWNER = 'rootstrap'; // expo account owner
4040
const EAS_PROJECT_ID = 'c3e1075b-6fe7-4686-aa49-35b46a229044'; // eas project id
41-
const SCHEME = 'react-native-template'; // app scheme
41+
const SCHEME = 'rootstrapApp'; // app scheme
4242

4343
/**
4444
* We declare a function withEnvSuffix that will add a suffix to the variable name based on the APP_ENV

0 commit comments

Comments
 (0)