Skip to content

Commit 689977c

Browse files
authored
Merge pull request #2 from Omar-Belghaouti/chore/new-proj-structure
Chore: New Project Structure
2 parents 388287f + 8f7a86e commit 689977c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2363
-1401
lines changed

.github/workflows/npm-publish.yml

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,64 @@
1-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3-
4-
name: Node.js Package
1+
name: "🚀 publish"
52

63
on:
74
release:
85
types: [created]
96

107
jobs:
11-
build:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- uses: actions/checkout@v2
15-
- uses: actions/setup-node@v2
16-
with:
17-
node-version: 12
18-
- run: npm ci
19-
- run: npm test
20-
218
publish-npm:
22-
needs: build
9+
name: 🚀 NPM publish
2310
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
node-version: [14.x]
15+
2416
steps:
25-
- uses: actions/checkout@v2
26-
- uses: actions/setup-node@v2
17+
- name: ☄️ checkout
18+
uses: actions/checkout@v2
19+
20+
- name: 🐱‍🏍 node
21+
uses: actions/setup-node@v1
2722
with:
28-
node-version: 12
29-
registry-url: https://registry.npmjs.org/
30-
- run: npm ci
31-
- run: npm publish
23+
node-version: ${{ matrix.node-version }}
24+
registery-url: https://registry.npmjs.org/
25+
26+
- name: 📦 install dependencies
27+
run: npm install
28+
29+
- name: 🐱‍👤 create .npmrc
30+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NODE_AUTH_TOKEN }}" > .npmrc
31+
32+
- name: 🚀 publish
33+
run: npm publish --access public
3234
env:
33-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
35+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
3436

3537
publish-gpr:
36-
needs: build
38+
name: 🚀 GPR publish
3739
runs-on: ubuntu-latest
40+
41+
strategy:
42+
matrix:
43+
node-version: [14.x]
44+
3845
steps:
3946
- uses: actions/checkout@v2
40-
- uses: actions/setup-node@v2
47+
- uses: actions/setup-node@v1
4148
with:
42-
node-version: 12
49+
node-version: ${{ matrix.node-version }}
4350
registry-url: https://npm.pkg.github.com/
44-
- run: npm ci
45-
- run: npm publish
51+
52+
- name: 📦 install dependencies
53+
run: npm install
54+
55+
- name: 🐱‍👤 create .npmrc
56+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NODE_AUTH_TOKEN }}" > .npmrc
57+
58+
- name: 🐱‍🏍 prepare gpr
59+
run: node prepare-gpr.js
60+
61+
- name: 🚀 publish
62+
run: npm publish --access public
4663
env:
4764
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

DOC.md

Lines changed: 0 additions & 196 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,9 @@ This command line helps you create components, screens, navigations and even red
2020
</a>
2121
</p>
2222

23-
# Functionalities
24-
25-
- Works inside projects initialized with expo or react native cli.
26-
- Create and delete navigations with all types (stack, drawer or tab).
27-
- Delete entire folder that combines screens or components.
28-
- Delete multiple screens and components.
29-
- Create multiple screens and components to a specific folder if needed.
30-
- Combine components and screens in a specified folder.
31-
- Support for TypeScript and JavaScript.
32-
- Create components and check if already exists.
33-
- Create screens and check if already exists.
34-
- Create redux implementation and check if already exists.
35-
- Delete components after checking if exists.
36-
- Delete screens after checking if exists.
37-
- Delete redux implemnetation after checking if exists.
38-
3923
## How to install it?
4024

41-
- To install it globally in your operating system you should type on your shell the following
25+
- To install it globally in your system run:
4226

4327
```
4428
npm i react-native-help-create -g
@@ -50,7 +34,7 @@ Or
5034
yarn global add react-native-help-create
5135
```
5236

53-
- To install it as a dev dependency in your react native project run
37+
- To install it as a dev dependency in your react native project run:
5438

5539
```
5640
npm i react-native-help-create --save-dev
@@ -64,7 +48,7 @@ yarn add react-native-help-create --dev
6448

6549
## How to use it?
6650

67-
Please follow [this documentation](DOC.md) to see how to use this helper command.
51+
Please follow [this documentation](docs/TOC.md) to see how to use this helper command.
6852

6953
Or you can see [this medium article](https://omarbelghaouti.medium.com/react-native-help-create-a-friendly-tool-for-react-native-projects-f85cbcf64da5) that explains it.
7054

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const fs = require("file-system");
2+
3+
/**
4+
* @function combineComponents
5+
* @description this function is used to combine existed componets to a folder.
6+
* @param {Array} components - array of components to be combined.
7+
* @param {string} folder - folder path to contain the combined components.
8+
* @author [Omar Belghaouti](https://github.com/Omar-Belghaouti)
9+
*/
10+
exports.combineComponents = (components, folder) => {
11+
const path = "src/components/";
12+
const _path = `${path}${folder}/`;
13+
let folders = [];
14+
components.forEach((component) => {
15+
fs.readdirSync(path)
16+
.filter((f) => f === component)
17+
.forEach((f) => folders.push(f));
18+
});
19+
if (folders.length < components.length) {
20+
console.log("Check if all of these components exist");
21+
return;
22+
}
23+
if (!fs.existsSync(_path)) {
24+
fs.mkdirSync(_path);
25+
} else {
26+
console.log(`${_path} already exist`);
27+
console.log("Writing new files...");
28+
}
29+
folders.forEach((f) => {
30+
if (fs.existsSync(`${_path}${f}/`)) {
31+
console.log(`${_path}${f}/ already exist`);
32+
} else {
33+
fs.rename(`${path}${f}/`, `${_path}${f}`, (err) => {
34+
if (err) {
35+
console.log(`Cannot move ${f} component`);
36+
} else {
37+
console.log(`${f} component moved to ${_path}`);
38+
}
39+
});
40+
}
41+
});
42+
};

bin/combine/component/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { combineComponents } = require("./combine-components");
2+
3+
exports.combineComponents = combineComponents;

bin/combine/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const { combineComponents } = require("./component");
2+
const { combineScreens } = require("./screen");
3+
4+
exports.combineComponents = combineComponents;
5+
exports.combineScreens = combineScreens;

0 commit comments

Comments
 (0)