-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmantra.yaml
218 lines (188 loc) · 5.25 KB
/
mantra.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
root: src
panes:
- name: Module
structure:
- directory: actions
structure:
- file: index.js
template: actionIndex
- directory: components
- directory: containers
- directory: forms
- file: index.js
template: module
- name: Configs
structure:
- directory: client/configs
- directory: lib
- file: client/configs/context.js
template: context
- file: client/configs/app.js
template: appConfig
- file: client/index.js
template: client
templates:
- name: appConfig
text: |
const remote = 'ws://localhost:3000/websocket';
export default {
remote
};
# Module action template
- name: actions
text: |
export default {
$1({ Meteor }, param1) {
}
};
placeholders:
- Action name
actions:
- type: replace
path: index.js
what: /* IMPORTS */
replace: import $name from './$name';\n/* IMPORTS */
- type: replace
path: index.js
what: /* CALLS */
replace: $name,\n /* CALLS */
- type: create
path: tests/$name.js
text: |
const { describe, it } = global;
import { expect } from 'chai';
import { spy, stub } from 'sinon';
import actions from '../$name';
describe('MODULE_NAME.actions.$name', () => {
describe('ACTION_NAME', () => {
it('should reject if title is not there', () => {
const LocalState = {set: spy()};
actions.create({LocalState}, null, 'content');
const args = LocalState.set.args[0];
expect(args[0]).to.be.equal('SAVING_ERROR');
expect(args[1]).to.match(/required/);
});
});
});
- name: actionIndex
create: true
text: |
/* IMPORTS */
export default {
/* CALLS */
};
# Module component template
- name: components
text: |
import React, { Component } from 'react';
import { View, StyleSheet } from 'react-native';
export default class $1 extends Component {
render() {
return null;
}
}
const styles = StyleSheet.create({
});
placeholders:
- Component Name
actions:
- type: create
path: tests/$name.js
text: |
const { describe, it } = global;
import { expect } from 'chai';
import { shallow } from 'enzyme';
import Component from '../$name';
describe('MODULE_NAME.components.$name', () => {
it('should not be null', () => {
const el = shallow(<Component />);
expect(el).not.to.be.null;
});
});
# Module container template
- name: containers
text: |
import { useDeps, composeAll } from 'mantra-core';
import { composeWithTracker } from 'react-native-meteor';
import L from '../../core/components/loading';
import E from '../../core/components/error';
import Login from '../components/login';
export const composer = ({context}, onData) => {
const { Meteor } = context();
onData(null, {});
};
export const depsMapper = (context, actions) => ({
context: () => context
});
export default composeAll(
composeWithTracker(composer, L, E),
useDeps(depsMapper)
)(Login);
placeholders:
- Component Name
actions:
- type: replace
path: $name.js
what: _____name_____';
replace: $name';
- type: create
path: tests/$name.js
text: |
const { describe, it } = global;
import { expect } from 'chai';
import { spy, stub } from 'sinon';
import { composer, depsMapper } from '../$name';
describe('MODULE_NAME.containers.$name', () => {
describe('composer', () => {
it('should ', () => {
});
});
});
# Module index template
- name: module
show: true
create: true
text: |
import actions from './actions';
export default {
actions
};
# context template
- name: context
create: true
text: |
import Meteor, { Accounts } from 'react-native-meteor';
export default function () {
return {
Meteor,
Accounts
};
}
# client index template
- name: client
create: true
show: true
text: |
import './configs/config';
import {createApp} from 'mantra-core';
import coreModule from './modules/core/index';
import initContext from './configs/context';
// init context
const context = initContext();
// create app
const app = createApp(context);
app.loadModule(coreModule);
app.init();
actions:
- type: replace
path: ../index.js
what: import {createApp} from 'mantra-core';
replace: |
import {createApp} from 'mantra-core';
import $nameModule from './modules/$name';
- type: replace
path: ../index.js
what: app.init();
replace: |
app.loadModule($nameModule);
app.init()