Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

Commit be1db21

Browse files
committed
Feat: add ability to import container from page generator
1 parent 4ef956d commit be1db21

File tree

11 files changed

+36
-18
lines changed

11 files changed

+36
-18
lines changed

app/src/components/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Assemble all components for export */
1+
/* GENERATOR: Assemble all components for export */
22
export Contributor from './Contributor';
33
export Avatar from './Avatar';
44
export WelcomeModal from './WelcomeModal';

app/src/containers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
/* Assemble all containers for export */
1+
/* GENERATOR: Assemble all containers for export */
22
export LandingContainer from './LandingContainer';
33
export AppContainer from './AppContainer';

app/src/pages/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
/* Assemble all pages for export */
1+
/* GENERATOR: Assemble all pages for export */
2+
export HelloPage from './HelloPage/index';
23
export NotFoundPage from './NotFoundPage/index';
34
export LandingPage from './LandingPage/index';

app/src/reducers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { routerReducer } from 'react-router-redux';
33
import { reducer as formReducer } from 'redux-form';
44
import client from './apolloClient';
55

6-
/* Import all of your reducers */
6+
/* GENERATOR: Import all of your reducers */
77
import landing from './containers/LandingContainer/reducer';
88
import app from './containers/AppContainer/reducer';
99

1010
const rootReducer = combineReducers({
1111
app,
12-
/* Compile all of your reducers */
12+
/* GENERATOR: Compile all of your reducers */
1313
landing,
1414
routing: routerReducer,
1515
form: formReducer,

app/src/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const routes = {
2121
});
2222
},
2323
},
24-
/* Newly generated Routes go here */
2524
childRoutes: [
2625
{
2726
path: '*',
@@ -32,6 +31,7 @@ export const routes = {
3231
});
3332
},
3433
},
34+
/* GENERATOR: Newly generated Routes go here */
3535
],
3636
};
3737

app/src/store.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import client from './apolloClient';
88
const isClient = typeof document !== 'undefined';
99
const isDeveloping = process.env.NODE_ENV !== 'production';
1010

11-
/* Import all of your initial state */
11+
/* GENERATOR: Import all of your initial state */
1212
import { initialState as landing } from './containers/LandingContainer/reducer';
1313
import { initialState as app } from './containers/AppContainer/reducer';
1414

1515
const initialState = {
1616
app,
17-
/* Compile all of your initial state */
17+
/* GENERATOR: Compile all of your initial state */
1818
landing,
1919
};
2020

config/generators/component/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = {
7272
actions.push({
7373
type: 'modify',
7474
path: '../../app/src/components/index.js',
75-
pattern: /(\/\* Assemble all components for export \*\/)/g,
75+
pattern: /(\/\* GENERATOR: Assemble all components for export \*\/)/g,
7676
template: trimTemplateFile('config/generators/component/export.js.hbs'),
7777
});
7878

config/generators/container/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = {
5353
actions.push({
5454
type: 'modify',
5555
path: '../../app/src/containers/index.js',
56-
pattern: /(\/\* Assemble all containers for export \*\/)/g,
56+
pattern: /(\/\* GENERATOR: Assemble all containers for export \*\/)/g,
5757
template: trimTemplateFile('config/generators/container/export.js.hbs'),
5858
});
5959

@@ -86,28 +86,28 @@ module.exports = {
8686
actions.push({
8787
type: 'modify',
8888
path: '../../app/src/store.js',
89-
pattern: /(\/\* Import all of your initial state \*\/)/g,
89+
pattern: /(\/\* GENERATOR: Import all of your initial state \*\/)/g,
9090
template: trimTemplateFile('config/generators/container/store.import.js.hbs'),
9191
});
9292

9393
actions.push({
9494
type: 'modify',
9595
path: '../../app/src/store.js',
96-
pattern: /(\/\* Compile all of your initial state \*\/)/g,
96+
pattern: /(\/\* GENERATOR: Compile all of your initial state \*\/)/g,
9797
template: trimTemplateFile('config/generators/container/store.usage.js.hbs'),
9898
});
9999

100100
actions.push({
101101
type: 'modify',
102102
path: '../../app/src/reducers.js',
103-
pattern: /(\/\* Import all of your reducers \*\/)/g,
103+
pattern: /(\/\* GENERATOR: Import all of your reducers \*\/)/g,
104104
template: trimTemplateFile('config/generators/container/reducers.import.js.hbs'),
105105
});
106106

107107
actions.push({
108108
type: 'modify',
109109
path: '../../app/src/reducers.js',
110-
pattern: /(\/\* Compile all of your reducers \*\/)/g,
110+
pattern: /(\/\* GENERATOR: Compile all of your reducers \*\/)/g,
111111
template: trimTemplateFile('config/generators/container/reducers.usage.js.hbs'),
112112
});
113113

config/generators/container/index.js.hbs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ const Container = {{ properCase name }}Container;
5151
{{#if wantGraphQL}}
5252
const {{ camelCase name }}Query = gql`
5353
query {{ camelCase name }} {
54-
id
54+
{{ camelCase name }} {
55+
__typename
56+
}
5557
}
5658
`;
5759

@@ -65,7 +67,9 @@ const ContainerWithData = graphql({{ camelCase name }}Query, {
6567

6668
const {{ camelCase name }}Mutation = gql`
6769
mutation {{ camelCase name }} {
68-
id
70+
{{ camelCase name }} {
71+
__typename
72+
}
6973
}
7074
`;
7175

config/generators/page/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ module.exports = {
3232
return 'path is required';
3333
},
3434
},
35+
{
36+
type: 'confirm',
37+
name: 'wantContainer',
38+
default: true,
39+
message: 'Do you want to import a container by the same name?',
40+
},
3541
],
3642

3743

@@ -55,12 +61,12 @@ module.exports = {
5561
actions.push({
5662
type: 'modify',
5763
path: '../../app/src/routes.js',
58-
pattern: /(\/\* Newly generated Routes go here \*\/)/g,
64+
pattern: /(\/\* GENERATOR: Newly generated Routes go here \*\/)/g,
5965
template: trimTemplateFile('config/generators/page/route.js.hbs'),
6066
}, {
6167
type: 'modify',
6268
path: '../../app/src/pages/index.js',
63-
pattern: /(\/\* Assemble all pages for export \*\/)/g,
69+
pattern: /(\/\* GENERATOR: Assemble all pages for export \*\/)/g,
6470
template: trimTemplateFile('config/generators/page/export.js.hbs'),
6571
});
6672

0 commit comments

Comments
 (0)