Skip to content

Commit

Permalink
Merge pull request #2 from Omar-Belghaouti/chore/new-proj-structure
Browse files Browse the repository at this point in the history
Chore: New Project Structure
  • Loading branch information
omdxp authored Nov 16, 2021
2 parents 388287f + 8f7a86e commit 689977c
Show file tree
Hide file tree
Showing 55 changed files with 2,363 additions and 1,401 deletions.
71 changes: 44 additions & 27 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,64 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package
name: "🚀 publish"

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm ci
- run: npm test

publish-npm:
needs: build
name: 🚀 NPM publish
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: ☄️ checkout
uses: actions/checkout@v2

- name: 🐱‍🏍 node
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
node-version: ${{ matrix.node-version }}
registery-url: https://registry.npmjs.org/

- name: 📦 install dependencies
run: npm install

- name: 🐱‍👤 create .npmrc
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NODE_AUTH_TOKEN }}" > .npmrc

- name: 🚀 publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}

publish-gpr:
needs: build
name: 🚀 GPR publish
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: ${{ matrix.node-version }}
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish

- name: 📦 install dependencies
run: npm install

- name: 🐱‍👤 create .npmrc
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NODE_AUTH_TOKEN }}" > .npmrc

- name: 🐱‍🏍 prepare gpr
run: node prepare-gpr.js

- name: 🚀 publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
196 changes: 0 additions & 196 deletions DOC.md

This file was deleted.

22 changes: 3 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,9 @@ This command line helps you create components, screens, navigations and even red
</a>
</p>

# Functionalities

- Works inside projects initialized with expo or react native cli.
- Create and delete navigations with all types (stack, drawer or tab).
- Delete entire folder that combines screens or components.
- Delete multiple screens and components.
- Create multiple screens and components to a specific folder if needed.
- Combine components and screens in a specified folder.
- Support for TypeScript and JavaScript.
- Create components and check if already exists.
- Create screens and check if already exists.
- Create redux implementation and check if already exists.
- Delete components after checking if exists.
- Delete screens after checking if exists.
- Delete redux implemnetation after checking if exists.

## How to install it?

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

```
npm i react-native-help-create -g
Expand All @@ -50,7 +34,7 @@ Or
yarn global add react-native-help-create
```

- To install it as a dev dependency in your react native project run
- To install it as a dev dependency in your react native project run:

```
npm i react-native-help-create --save-dev
Expand All @@ -64,7 +48,7 @@ yarn add react-native-help-create --dev

## How to use it?

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

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.

Expand Down
42 changes: 42 additions & 0 deletions bin/combine/component/combine-components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs = require("file-system");

/**
* @function combineComponents
* @description this function is used to combine existed componets to a folder.
* @param {Array} components - array of components to be combined.
* @param {string} folder - folder path to contain the combined components.
* @author [Omar Belghaouti](https://github.com/Omar-Belghaouti)
*/
exports.combineComponents = (components, folder) => {
const path = "src/components/";
const _path = `${path}${folder}/`;
let folders = [];
components.forEach((component) => {
fs.readdirSync(path)
.filter((f) => f === component)
.forEach((f) => folders.push(f));
});
if (folders.length < components.length) {
console.log("Check if all of these components exist");
return;
}
if (!fs.existsSync(_path)) {
fs.mkdirSync(_path);
} else {
console.log(`${_path} already exist`);
console.log("Writing new files...");
}
folders.forEach((f) => {
if (fs.existsSync(`${_path}${f}/`)) {
console.log(`${_path}${f}/ already exist`);
} else {
fs.rename(`${path}${f}/`, `${_path}${f}`, (err) => {
if (err) {
console.log(`Cannot move ${f} component`);
} else {
console.log(`${f} component moved to ${_path}`);
}
});
}
});
};
3 changes: 3 additions & 0 deletions bin/combine/component/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { combineComponents } = require("./combine-components");

exports.combineComponents = combineComponents;
5 changes: 5 additions & 0 deletions bin/combine/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { combineComponents } = require("./component");
const { combineScreens } = require("./screen");

exports.combineComponents = combineComponents;
exports.combineScreens = combineScreens;
Loading

0 comments on commit 689977c

Please sign in to comment.