Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commitbb58add

Browse files
committed
generators update
1 parente333a4e commitbb58add

File tree

12 files changed

+125
-54
lines changed

12 files changed

+125
-54
lines changed

‎utils/scripts/generators/component/class.js.hbs‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import PropTypes from 'prop-types'
99

1010
// import { inject, observer } from 'mobx-react'
1111
// import Link from 'next/link'
12+
// import styled from 'styled-components'
1213

1314
{{#ifwantMessages}}
1415
import { FormattedMessage } from 'react-intl'
1516
import messages from './messages'
1617
{{/if}}
1718

19+
// @inject('')
20+
// @observer
1821
class{{properCasename}} extends React.Component {
1922
componentDidMount() {}
2023

@@ -23,19 +26,19 @@ class {{ properCase name }} extends React.Component {
2326
render() {
2427
return (
2528
<div>
26-
<h3>{{properCasename}}classcomponent!</h3>
27-
{{#ifwantMessages}}
28-
<FormattedMessage {...messages.header} />
29-
{{/if}}
29+
{{properCasename}} component
30+
{{#ifwantMessages}}
31+
<FormattedMessage {...messages.header} />
32+
{{/if}}
3033
</div>
3134
)
3235
}
3336
}
3437

3538
export default{{properCasename}}
3639

37-
{{properCasename}}.propTypes = {
40+
Index.propTypes = {
3841
// https://www.npmjs.com/package/prop-types
3942
}
4043

41-
{{properCasename}}.defaultProps = {}
44+
Index.defaultProps = {}

‎utils/scripts/generators/component/index.js‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ module.exports = {
3939
default:true,
4040
message:'Do you want i18n messages (i.e. will this component use text)?',
4141
},
42-
{
43-
type:'confirm',
44-
name:'wantLoadable',
45-
default:false,
46-
message:'Do you want to load the component asynchronously?',
47-
},
4842
],
4943
actions:data=>{
5044
// Generate index.js and index.test.js
@@ -85,16 +79,6 @@ module.exports = {
8579
})
8680
}
8781

88-
// If want Loadable.js to load the component asynchronously
89-
if(data.wantLoadable){
90-
actions.push({
91-
type:'add',
92-
path:'../../../components/{{properCase name}}/Loadable.js',
93-
templateFile:'./component/loadable.js.hbs',
94-
abortOnFail:true,
95-
})
96-
}
97-
9882
returnactions
9983
},
10084
}

‎utils/scripts/generators/component/stateless.js.hbs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const debug = makeDebugger('c:{{ properCase name }}:index')
1919

2020
const{{properCasename}} = (props) => {
2121
return (
22-
<div>
22+
<div>
23+
{{properCasename}} component
2324
{{#ifwantI18n}}
2425
<I18n {...lang.header} />
2526
{{/if}}

‎utils/scripts/generators/container/class.js.hbs‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import { inject, observer } from 'mobx-react'
1313
import messages from './messages'
1414
{{/if}}
1515

16+
// import { } from './styles'
17+
1618
import { makeDebugger, storePlug } from '../../utils'
19+
20+
// import S from './schema'
1721
import * as logic from './logic'
1822

1923
/* eslint-disable no-unused-vars */
@@ -22,22 +26,21 @@ const debug = makeDebugger('C:{{ properCase name }}')
2226

2327
class{{properCasename}}Container extends React.Component {
2428
componentWillMount() {
25-
logic.init(this.props.{{camelCasename}})
29+
const{{preCurly""}}{{camelCasename}}{{afterCurly""}} = this.props
30+
logic.init({{camelCasename}})
2631
}
2732

2833
render() {
2934
return (
3035
<div>
31-
<h2>coderplanets</h2>
32-
{{properCasename}} container!
36+
<h2>{{properCasename}} container!</h2>
37+
<div>impress me!</div>
38+
{{#ifwantMessages}}
39+
<FormattedMessage {...messages.header} />
40+
{{/if}}
3341
</div>
34-
{{#ifwantMessages}}
35-
<FormattedMessage {...messages.header} />
36-
{{/if}}
3742
)
3843
}
3944
}
4045

41-
export default inject(storePlug('{{camelCasename}}'))(
42-
observer({{properCasename}}Container)
43-
)
46+
export default inject(storePlug('{{camelCasename}}'))(observer({{properCasename}}Container))

‎utils/scripts/generators/container/index.js‎

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ module.exports = {
2828
},
2929
{
3030
type:'confirm',
31-
name:'wantI18n',
31+
name:'wantSchema',
3232
default:true,
33-
message:'Do you wanti18n messages (i.e. will this container use text)?',
33+
message:'Do you wantGraphQL schema?',
3434
},
3535
{
3636
type:'confirm',
37-
name:'wantLoadable',
38-
default:false,
39-
message:'Do you wantto load thecontainerasynchronously?',
37+
name:'wantI18n',
38+
default:true,
39+
message:'Do you wanti18n messages (i.e. will thiscontaineruse text)?',
4040
},
4141
],
4242
actions:data=>{
@@ -56,8 +56,8 @@ module.exports = {
5656
},
5757
{
5858
type:'add',
59-
path:'../../../containers/{{properCase name}}/tests/index.test.js',
60-
templateFile:'./container/test.js.hbs',
59+
path:'../../../containers/{{properCase name}}/store.js',
60+
templateFile:'./container/store.js.hbs',
6161
abortOnFail:true,
6262
},
6363
{
@@ -66,24 +66,35 @@ module.exports = {
6666
templateFile:'./container/styles.js.hbs',
6767
abortOnFail:true,
6868
},
69+
{
70+
type:'add',
71+
path:'../../../containers/{{properCase name}}/tests/index.test.js',
72+
templateFile:'./container/test.js.hbs',
73+
abortOnFail:true,
74+
},
75+
{
76+
type:'add',
77+
path:'../../../containers/{{properCase name}}/tests/store.test.js',
78+
templateFile:'./container/store.test.js.hbs',
79+
abortOnFail:true,
80+
},
6981
]
7082

71-
// If they want a i18n messages file
72-
if(data.wantI18n){
83+
if(data.wantSchema){
7384
actions.push({
7485
type:'add',
75-
path:'../../../containers/{{properCase name}}/lang.js',
76-
templateFile:'./container/lang.js.hbs',
86+
path:'../../../containers/{{properCase name}}/schema.js',
87+
templateFile:'./container/schema.js.hbs',
7788
abortOnFail:true,
7889
})
7990
}
8091

81-
// If wantLoadable.js to load the component asynchronously
82-
if(data.wantLoadable){
92+
// Iftheywanta i18n messages file
93+
if(data.wantI18n){
8394
actions.push({
8495
type:'add',
85-
path:'../../../containers/{{properCase name}}/Loadable.js',
86-
templateFile:'./container/loadable.js.hbs',
96+
path:'../../../containers/{{properCase name}}/lang.js',
97+
templateFile:'./container/lang.js.hbs',
8798
abortOnFail:true,
8899
})
89100
}

‎utils/scripts/generators/container/logic.js.hbs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let sub$ = null
1010
const debug = makeDebugger('L:{{properCasename}}')
1111
/* eslint-enable no-unused-vars */
1212

13-
let{{camelCasename}} = null
13+
letstore = null
1414

1515
export function someMethod() {}
1616

@@ -21,9 +21,11 @@ export function someMethod() {}
2121
const DataSolver = []
2222
const ErrSolver = []
2323

24-
export function init(selectedStore) {
25-
{{camelCasename}} = selectedStore
26-
debug({{camelCasename}})
24+
export function init(_store) {
25+
if (store) return false
26+
store = _store
27+
28+
debug(store)
2729
if (sub$) sub$.unsubscribe()
2830
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
2931
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import gql from 'graphql-tag'
2+
3+
const simpleMutation = gql`
4+
mutation($id: ID!) {
5+
post(id: $id) {
6+
id
7+
}
8+
}
9+
`
10+
const simpleQuery = gql`
11+
query($filter: filter!) {
12+
post(id: $id) {
13+
id
14+
}
15+
}
16+
`
17+
18+
const schema = {
19+
simpleMutation,
20+
simpleQuery,
21+
}
22+
23+
export default schema
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
*{{properCasename}} store
3+
*
4+
*/
5+
6+
import { types as t, getParent } from 'mobx-state-tree'
7+
// import R from 'ramda'
8+
9+
import { markStates, makeDebugger } from '../../utils'
10+
/* eslint-disable no-unused-vars */
11+
const debug = makeDebugger('S:{{properCasename}}')
12+
/* eslint-enable no-unused-vars */
13+
14+
const{{properCasename}} = t
15+
.model('{{properCasename}}', {})
16+
.views(self => ({
17+
get root() {
18+
return getParent(self)
19+
},
20+
}))
21+
.actions(self => ({
22+
markState(sobj) {
23+
markStates(sobj, self)
24+
},
25+
}))
26+
27+
export default{{properCasename}}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
*{{properCasename}} store test
3+
*
4+
*/
5+
6+
// import R from 'ramda'
7+
8+
// import{{properCasename}} from '../index'
9+
10+
it('TODO: store test{{properCasename}}', () => {
11+
expect(1 + 1).toBe(2)
12+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
// import styled from 'styled-components'
2+
// import { theme } from '../../../utils'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp