Skip to content

Commit 4377a72

Browse files
committed
📚 (Readme): Upgrade readme
1 parent 1dbe97d commit 4377a72

File tree

1 file changed

+105
-2
lines changed

1 file changed

+105
-2
lines changed

README.md

Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,106 @@
1-
# rnb-toolbox
1+
# TheCodingMachine React Native boilerplate - Toolbox
2+
![React Native Boilerplate Toolbox License](https://img.shields.io/github/license/thecodingmachine/rnb-toolbox)
3+
![React Native Boilerplate Toolbox Version](https://flat.badgen.net/npm/v/@thecodingmachine/rnb-toolbox)
4+
![React Native Boilerplate Toolbox Release Date](https://img.shields.io/github/release-date/thecodingmachine/rnb-toolbox)
5+
![React Native Boilerplate Toolbox Download](https://flat.badgen.net/npm/dt/@thecodingmachine/rnb-toolbox)
6+
![React Native Boilerplate Toolbox Top Language](https://img.shields.io/github/languages/top/thecodingmachine/rnb-toolbox)
7+
[![CI](https://github.com/thecodingmachine/rnb-toolbox/actions/workflows/CI.yml/badge.svg)](https://github.com/thecodingmachine/rnb-toolbox/actions/workflows/CI.yml)
28

3-
Welcome to the rnb-toolbox repository. WIP.
9+
🚧 This is a work in progress documentation. 🚧
10+
11+
This project is part of our [React Native Boilerplate](https://github.com/thecodingmachine/react-native-boilerplate/) that can be used to kickstart a mobile application.
12+
13+
This boilerplate provides **an optimized architecture for building solid cross-platform mobile applications** through separation of concerns between the UI and business logic. It is fully documented so that each piece of code that lands in your application can be understood and re-used.
14+
15+
This toolbox allows you to build plugin modules that can be used to extend the functionality of the boilerplate.
16+
17+
## Quick start
18+
19+
The best way to get started is to use the template repository. It will provide you with a working project that you can start from scratch.
20+
21+
## Documentation
22+
23+
### Initialization
24+
25+
To initialize a plugin, you have to use the RNBPlugin constructor like this:
26+
27+
```javascript
28+
const { RNBPlugin } = require('@thecodingmachine/rnb-toolbox');
29+
30+
const plugin = new RNBPlugin({
31+
organisation: '<package-organisation>',
32+
packageName: '<package-name>',
33+
// version: 'latest | <package-version>', // default: latest
34+
promptsOptions: {
35+
type: 'confirm',
36+
color: 'blue',
37+
text: 'Do you want to use my custom plugin ?',
38+
initial: false,
39+
},
40+
});
41+
```
42+
#### PromptsOptions
43+
| Key name | default | type | description | required |
44+
|----------------|-----------|-----------------------------|---------------------------------------------------------------------------------------------------------------|----------|
45+
| organisation | | string | the organisation name on the npm registry | true |
46+
| packageName | | string | the package name on the npm registry | true |
47+
| version | 'latest' | string | the version of the plugin (use it when you make rc/beta/alpha version) | false |
48+
| promptsOptions | | PromptsOptionsWrapperParams | the prompt that will be printed for the final user ([Prompts doc](https://github.com/terkelg/prompts#readme)) | true |
49+
50+
#### PromptsOptionsWrapperParams:
51+
52+
| Key name | default | type | description |
53+
|----------|---------|--------|-----------------------------------------------------------|
54+
| type | | string | [Prompts type](https://github.com/terkelg/prompts#readme) |
55+
| color | 'white' | string | [Kleur colors](https://github.com/lukeed/kleur#api) |
56+
| text | | string | the prompt text to display |
57+
| initial | | any | the prompt default value |
58+
59+
### Life cycle
60+
A RNBPlugin as a defined lifecycle with two hooks:
61+
- onInstall
62+
- afterInstall
63+
64+
#### onInstall
65+
This hook is called right after the plugin is installed. It is called with the following parameters:
66+
67+
#### afterInstall
68+
This hook is called right after the plugin onInstall hook is finished and the plugin is removed from the boilerplate. It is called with the following parameters:
69+
70+
### Helper functions
71+
Generally, you will want to do some operation into life cycle hooks. For example, you will want to loop on plugin files to paste them into the boilerplate code base.
72+
Or you will want loop on the boilerplate files and rename them. To do that you can use the following helper functions:
73+
- loopOnPluginFiles
74+
- loopOnSourceFiles
75+
76+
#### loopOnPluginFiles & loopOnSourceFiles
77+
| Helper function | default | type | description | required |
78+
|------------------|---------------------------|----------|---------------------------------------------|----------|
79+
| accumulatedPath | '/' | string | the current path during the loop | false |
80+
| onDirectoryFound | () => Promise.resolve({}) | function | function to start when a directory is found | false |
81+
| onFileFound | () => Promise.resolve({}) | function | function to start when a file is found | false |
82+
| ...args | | any | custom arguments to give in each loop | false |
83+
84+
##### Example
85+
86+
```javascript
87+
plugin.lifecycle.onInstall = async () => {
88+
await plugin.helpers.loopOnSourceFiles({
89+
directoryCounter: false, // will be exposed in onFileFound() and onDirectoryFound()
90+
onDirectoryFound: async ({
91+
item, accumulatedPath, directoryCounter,
92+
}) => {
93+
// do something with the directory
94+
return Promise.resolve({ directoryCounter: directoryCounter + 1 });
95+
},
96+
});
97+
};
98+
```
99+
100+
## License
101+
102+
This project is released under the [MIT License](LICENSE).
103+
104+
## About us
105+
106+
[TheCodingMachine](https://www.thecodingmachine.com/) is a web and mobile agency based in Paris and Lyon, France. We are [constantly looking for new developers and team leaders](https://www.thecodingmachine.com/nous-rejoindre/) and we love [working with freelancers](https://coders.thecodingmachine.com/). You'll find [an overview of all our open source projects on our website](https://thecodingmachine.io/open-source) and on [Github](https://github.com/thecodingmachine).

0 commit comments

Comments
 (0)