1 | # Allons-y Architecture
|
2 |
|
3 | ## Install
|
4 |
|
5 | When you install one of the allons-y modules, the main allons-y module adds automatically to your project:
|
6 | - The `allons-y.js` file.
|
7 | - The `start` and `stop` scripts to your `package.json` file.
|
8 |
|
9 | With the `allons-y.js` file, you are able to call any command with `node allons-y [my command] [my args, ...]` ([read more on the CLI](https://github.com/CodeCorico/allons-y/blob/master/docs/cli.md)).
|
10 |
|
11 | With the scripts, you can start and stop the Allons-y processes of your project (and those installed in your node_modules).
|
12 |
|
13 | ## Linked features
|
14 |
|
15 | In Allons-y, we use specific naming files to inject code when an action is called. For example, if you have a file named `*-allons-y-start.js` in one of your features, it will be automatically used when you'll start `npm start`. They are many file names availables, depends on wich allons-y modules you are using.
|
16 |
|
17 | By default, features are located in these directories:
|
18 | - Each directory in your project `features` folder (like `features/my-feature/`).
|
19 | - Each directory in an `allons-y-*` module inside your `node_modules` folder.
|
20 |
|
21 | ## Find files in features
|
22 |
|
23 | In your modules, you have access to the `$allonsy` [injected dependency](#dependencies-injection). You can use its `$allonsy.findInFeatures()` (or `$allonsy.findInFeaturesSync()`) method to get every file available in features. When you start `npm start`, Allons-y uses `$allonsy.findInFeaturesSync('*-allons-y-start.js')` to get every process to start.
|
24 |
|
25 | This system is the first step to make your features totally independent. [read the $allonsy API](https://github.com/CodeCorico/allons-y/blob/master/docs/api-allonsy.md) for more useful methods.
|
26 |
|
27 | ## Add more feature directory patterns
|
28 |
|
29 | Any node module started with "allons-y-" is used by Allons-y but you can add you own patterns.
|
30 | Simply add the file `.allons-y-paths` in the root directory of your project and write each pattern per line:
|
31 | ```
|
32 | ./node_modules/myproject-module-*
|
33 | ../direct-another-project
|
34 | /etc/other-module
|
35 | ```
|
36 |
|
37 | ## Dependencies injection
|
38 |
|
39 | Allons-y is using the Dependencies injection pattern in every file required in your project. Your modules are able to use some variables like `$allonsy` or `$glob` for example:
|
40 | ```javascript
|
41 | // myfeature-allons-y-start.js
|
42 |
|
43 | module.exports = function($allonsy) {
|
44 | $allonsy.log('file called!');
|
45 | }
|
46 | ```
|
47 |
|
48 | You can add your own dependecies with the `DependencyInjection` global variable. It uses the [MVW Injection](https://github.com/XavierBoubert/mvw-injection) module with the MVC pattern.
|