1 | # Sharec
|
2 |
|
3 | > 📦 Share your configs between projects without pain
|
4 |
|
5 | ## Installation
|
6 |
|
7 | Install **sharec** into your configuration package with npm:
|
8 |
|
9 | ```
|
10 | npm i --save-dev sharec
|
11 | ```
|
12 |
|
13 | Or with yarn:
|
14 |
|
15 | ```
|
16 | yarn add -D sharec
|
17 | ```
|
18 |
|
19 | ## Usage
|
20 |
|
21 | If you want to share you configs – initialize new package and install `sharec`,
|
22 | than you must create `configs` directory and move to it all your configuration
|
23 | files with `package.json`. In `package.json` you can define required dependecies,
|
24 | `sharec` will install them.
|
25 |
|
26 | `sharec` implements similar flow:
|
27 |
|
28 | 1. Searching `configs`
|
29 | 2. Copying configuration files
|
30 | 3. Merging target project's `package.json` with `package.json` from configuration package
|
31 | 4. Install dependencies from configuration package's `package.json`
|
32 |
|
33 | 3 and 4 steps possibly only if you create `package.json` file in `configs` directory
|
34 | of your configuration package.
|
35 |
|
36 | ## Examples
|
37 |
|
38 | _You can see example [here](https://www.npmjs.com/package/sharec-demo-config) – install it or just look at sources._
|
39 |
|
40 | So, you want to share your configuration files between projects.
|
41 |
|
42 | ### 1. Initialize new package
|
43 |
|
44 | Create new directory and initialize it:
|
45 |
|
46 | ```
|
47 | mkdir my-awesome-configs
|
48 | cd my-awesome-configs
|
49 | npm init -y
|
50 | ```
|
51 |
|
52 | ### 2. Install `sharec`
|
53 |
|
54 | Install `sharec` in the created package:
|
55 |
|
56 | ```
|
57 | npm i --save sharec
|
58 | ```
|
59 |
|
60 | ### 3. Add `sharec` to npm `postinstall` stript
|
61 |
|
62 | You can easily inatall your config with `postinstall` script, just add following
|
63 | line into your `package.json` `sciprts` section:
|
64 |
|
65 | ```
|
66 | "postinstall": "sharec"
|
67 | ```
|
68 |
|
69 | After this it should looks like:
|
70 |
|
71 | ```json
|
72 | {
|
73 | "name": "my-awesome-configs",
|
74 | "scripts": {
|
75 | "postinstall": "sharec"
|
76 | },
|
77 | "dependencies": {
|
78 | "sharec": "1.0.0"
|
79 | }
|
80 | }
|
81 | ```
|
82 |
|
83 | ### 4. Publish your configs package
|
84 |
|
85 | Congrats, you are ready for starting configuration sharing. You can publish it
|
86 | with `npm publish` or just push it to github.
|
87 |
|
88 | ### 5. Share it!
|
89 |
|
90 | For example you have publish your `my-awesome-configs` into npm, now you ready
|
91 | to install it.
|
92 |
|
93 | Navigate to your existing or new project and makes:
|
94 |
|
95 | ```
|
96 | npm i --save-dev my-awesome-configs
|
97 | ```
|
98 |
|
99 | Here we are! Configs were successfully installed 🙌
|