Skip to content

Commit 6147c3d

Browse files
Merge branch 'master' into chore/eslint_rules
2 parents 30113bd + ee73269 commit 6147c3d

15 files changed

+238
-145
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ module.exports = {
8080
],
8181
'object-shorthand': 'error',
8282
'arrow-body-style': ["error", "as-needed"],
83-
'no-console': ['error', {allow: ['error']}]
83+
'no-console': ['error', {allow: ['error']}],
84+
'guard-for-in': 'error'
8485
},
8586
overrides: [
8687
// Configuration for translations files (i18next)

.github/workflows/e2e-android-eas-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🔗 Links:
22
# Source file: https://github.com/rootstrap/react-native-template/blob/master/.github/workflows/e2e-android-eas-build.yml
3-
# End-to-end testing: https://starter.obytes.com/testing/end-to-end-testing/
3+
# End-to-end testing: https://rootstrap.github.io/react-native-template/testing/end-to-end-testing/
44

55
# ✍️ Description:
66
# This workflow is used to run end-to-end tests for EAS build on Android.

.github/workflows/e2e-android-maestro.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🔗 Links:
22
# Source file: https://github.com/rootstrap/react-native-template/blob/master/.github/workflows/e2e-android.yml
3-
# End-to-end testing: https://starter.obytes.com/testing/end-to-end-testing/
3+
# End-to-end testing: https://rootstrap.github.io/react-native-template/testing/end-to-end-testing/
44

55
# ✍️ Description:
66
# This workflow is used to run end-to-end tests on Android using Maestro Cloud.

.github/workflows/e2e-android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🔗 Links:
22
# Source file: https://github.com/rootstrap/react-native-template/blob/master/.github/workflows/e2e-android.yml
3-
# End-to-end testing: https://starter.obytes.com/testing/end-to-end-testing/
3+
# End-to-end testing: https://rootstrap.github.io/react-native-template/testing/end-to-end-testing/
44

55
# ✍️ Description:
66
# This workflow is used to run end-to-end tests on Android using Maestro.

.github/workflows/new-template-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🔗 Links:
22
# Source file: https://github.com/rootstrap/react-native-template/blob/master/.github/workflows/lint-ts.yml
3-
# Starter releasing process: https://starter.obytes.com/ci-cd/app-releasing-process/
3+
# Starter releasing process: https://rootstrap.github.io/react-native-template/ci-cd/app-releasing-process/
44

55
# ✍️ Description:
66
# This workflow is used to create a new version of the template and push a new tag to the repo.

README-project.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ SonarQube is an open-source platform for continuous inspection of code quality.
4747

4848
## ✍️ Documentation
4949

50-
- [Rules and Conventions](https://starter.obytes.com/getting-started/rules-and-conventions/)
51-
- [Project structure](https://starter.obytes.com/getting-started/project-structure)
52-
- [Environment vars and config](https://starter.obytes.com/getting-started/environment-vars-config)
53-
- [UI and Theming](https://starter.obytes.com/ui-and-theme/ui-theming)
54-
- [Components](https://starter.obytes.com/ui-and-theme/components)
55-
- [Forms](https://starter.obytes.com/ui-and-theme/Forms)
56-
- [Data fetching](https://starter.obytes.com/guides/data-fetching)
57-
- [Contribute to starter](https://starter.obytes.com/how-to-contribute/)
50+
- [Rules and Conventions](https://rootstrap.github.io/react-native-template/getting-started/rules-and-conventions/)
51+
- [Project structure](https://rootstrap.github.io/react-native-template/getting-started/project-structure)
52+
- [Environment vars and config](https://rootstrap.github.io/react-native-template/getting-started/environment-vars-config)
53+
- [UI and Theming](https://rootstrap.github.io/react-native-template/ui-and-theme/ui-theming)
54+
- [Components](https://rootstrap.github.io/react-native-template/ui-and-theme/components)
55+
- [Forms](https://rootstrap.github.io/react-native-template/ui-and-theme/forms/)
56+
- [Data fetching](https://rootstrap.github.io/react-native-template/guides/data-fetching)
57+
- [Contribute to starter](https://rootstrap.github.io/react-native-template/how-to-contribute/)
5858
- [Distribute using EAS](/EAS.md)

cli/clone-repo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const getLatestRelease = async () => {
1616
}
1717
};
1818

19-
const cloneLastTemplateRelease = async (projectName) => {
19+
const cloneLatestTemplateRelease = async (projectName) => {
2020
consola.start('Extracting last release number 👀');
2121
const latest_release = await getLatestRelease();
2222
consola.info(`Using Rootstrap's Template ${latest_release}`);
@@ -31,5 +31,5 @@ const cloneLastTemplateRelease = async (projectName) => {
3131
};
3232

3333
module.exports = {
34-
cloneLastTemplateRelease,
34+
cloneLatestTemplateRelease,
3535
};

cli/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
const { consola } = require('consola');
44
const { showMoreDetails } = require('./utils.js');
5-
const { cloneLastTemplateRelease } = require('./clone-repo.js');
6-
const { setupProject, installDeps } = require('./setup-project.js');
5+
const { cloneLatestTemplateRelease } = require('./clone-repo.js');
6+
const { setupProject, installDependencies } = require('./setup-project.js');
77
const pkg = require('./package.json');
88

99
const { name: packageName } = pkg;
@@ -18,14 +18,14 @@ const createRootstrapApp = async () => {
1818
);
1919
process.exit(1);
2020
}
21-
// clone the last release of the template from github
22-
await cloneLastTemplateRelease(projectName);
21+
// clone the latest release of the template from github
22+
await cloneLatestTemplateRelease(projectName);
2323

24-
// setup the project: remove unnecessary files, update package.json infos, name and set version to 0.0.1 + add initial version to osMetadata
24+
// setup the project
2525
await setupProject(projectName);
2626

2727
// install project dependencies using pnpm
28-
await installDeps(projectName);
28+
await installDependencies(projectName);
2929

3030
// show instructions to run the project + link to the documentation
3131
showMoreDetails(projectName);

cli/project-files-manager.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
const fs = require('fs-extra');
2+
const path = require('path');
3+
4+
class ProjectFilesManager {
5+
#projectName;
6+
7+
constructor(
8+
/**
9+
* @type {string}
10+
*/
11+
projectName
12+
) {
13+
this.#projectName = projectName;
14+
}
15+
16+
static withProjectName(
17+
/**
18+
* @type {string}
19+
*/
20+
projectName
21+
) {
22+
return new this(projectName);
23+
}
24+
25+
getAbsoluteFilePath(
26+
/**
27+
* A file path relative to project's root path
28+
* @type {string}
29+
*/
30+
relativeFilePath
31+
) {
32+
return path.join(process.cwd(), `${this.#projectName}/${relativeFilePath}`);
33+
}
34+
35+
removeFiles(
36+
/**
37+
* An array of file paths relative to project's root path
38+
* @type {Array<string>}
39+
*/
40+
files
41+
) {
42+
files.forEach((fileName) => {
43+
const absoluteFilePath = this.getAbsoluteFilePath(fileName);
44+
45+
fs.removeSync(absoluteFilePath);
46+
});
47+
}
48+
49+
renameFiles(
50+
/**
51+
* An array of objects containing the old and the new file names
52+
* relative to project's root path
53+
*
54+
* @type {Array<{
55+
* oldFileName: string;
56+
* newFileName: string;
57+
* }>}
58+
*/
59+
files
60+
) {
61+
files.forEach(({ oldFileName, newFileName }) => {
62+
const oldAbsoluteFilePath = this.getAbsoluteFilePath(oldFileName);
63+
const newAbsoluteFilePath = this.getAbsoluteFilePath(newFileName);
64+
65+
fs.renameSync(oldAbsoluteFilePath, newAbsoluteFilePath);
66+
});
67+
}
68+
69+
replaceFilesContent(
70+
/**
71+
* An array of objects containing the file name relative to project's
72+
* root path and the replacement patterns to be applied
73+
*
74+
* @type {Array<{
75+
* fileName: string;
76+
* replacements: Array<{
77+
* searchValue: string;
78+
* replaceValue: string;
79+
* }>
80+
* }>}
81+
*/
82+
files
83+
) {
84+
files.forEach(({ fileName, replacements }) => {
85+
const absoluteFilePath = this.getAbsoluteFilePath(fileName);
86+
87+
const contents = fs.readFileSync(absoluteFilePath, {
88+
encoding: 'utf-8',
89+
});
90+
91+
let replaced = contents;
92+
93+
replacements.forEach(({ searchValue, replaceValue }) => {
94+
replaced = replaced.replace(searchValue, replaceValue);
95+
});
96+
97+
fs.writeFileSync(absoluteFilePath, replaced, { spaces: 2 });
98+
});
99+
}
100+
}
101+
102+
module.exports = ProjectFilesManager;

0 commit comments

Comments
 (0)