-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmantra.yaml
327 lines (283 loc) · 7.9 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
root: src
templates:
# 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: storiesIndex
create: true
text: |
// imports
- name: components
text: |
import React, { Component } from "react";
export default class $1 extends Component {
render() {
return null;
}
}
placeholders:
- Component Name
actions:
- type: create
path: tests/$name.js
text: |
import React from 'react';
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;
});
});
- type: create
path: stories/$name_stories.js
text: |
import React from 'react';
import { storiesOf, action } from '@kadira/storybook';
import Component from '../$name';
storiesOf('module.$name', module)
.add('default view', () => {
return (
<Component />
);
})
- type: replace
path: stories/index.js
what: // imports
replace: |
// imports
import $name from "./$name_stories";
# Module container template
- name: containers
text: |
import { useDeps, composeAll, composeWithTracker } from 'mantra-core';
import $1 from '../components/_____name_____.jsx';
export const composer = ({context}, onData) => {
const { Meteor } = context();
onData(null, {});
};
export const depsMapper = (context, actions) => ({
context: () => context
});
export default composeAll(
composeWithTracker(composer),
useDeps(depsMapper)
)($1);
placeholders:
- Component Name
actions:
- type: replace
path: $name.js
what: _____name_____.jsx';
replace: $name.jsx';
- 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 route template
- name: route
show: true
create: true
text: |
import React from "react";
import { mount } from "mantra-core";
export default function (injectDeps) {
// const MainLayoutCtx = injectDeps(MainLayout);
// Move these as a module and call this from a main file
// FlowRouter.route("/", {
// name: "ei.list",
// action() {
// mount(MainLayoutCtx, {
// content: () => (<EiList />)
// });
// }
// });
}
# Module index template
- name: module
show: true
create: true
text: |
import actions from "./actions";
import routes from "./routes";
export default {
actions,
routes
};
# Server publication template
- name: server/publications
text: |
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { $2 } from '../../lib/collections';
export default function () {
Meteor.publish("$1", function () {
const selector = {};
const options = {
// fields: {_id: 1, title: 1},
// sort: {createdAt: -1},
// limit: 10
};
return $2.find(selector, options);
});
}
placeholders:
- Publication Name
- Collection
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 */
# Method template
- name: server/methods
text: |
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
export default function () {
Meteor.methods({
$1($2) {
check($2, String);
}
});
}
placeholders:
- Method Name
- Parameters
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 */
- name: server
create: true
show: true
text: |
import addInitialData from './configs/initial_adds.js';
addInitialData();
// import publications and methods
import publications from './publications/index';
import methods from './methods/index';
publications();
methods();
- name: publicationIndex
create: true
text: |
/* IMPORTS */
export default function () {
/* CALLS */
}
- name: methodIndex
create: true
text: |
/* IMPORTS */
export default function () {
/* CALLS */
}
# context template
- name: context
create: true
text: |
import * as Collections from 'lib/collections';
import { Meteor } from 'meteor/meteor';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { ReactiveDict } from 'meteor/reactive-dict';
import { Accounts } from 'meteor/accounts-base';
export default function () {
return {
Meteor,
FlowRouter,
Collections,
LocalState: new ReactiveDict(),
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()