Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .reactserverrc to generator #231

Merged
merged 1 commit into from
May 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/generator-react-server/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ module.exports = yeoman.Base.extend({

[
'_babelrc',
'_gitignore'
'_gitignore',
'_reactserverrc'
].forEach(function (filename) {
var fn = filename.replace('_', '.');
_this.fs.copyTpl(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the only down-side of having all of the config defaults listed here is we need to make sure it stays in sync with the actual defaults. 😛

"routes": "./routes.js"
"host": "localhost",
"port": 3000,
"js-port": 3001,
"hot": false,
"minify": false,
"long-term-caching": false,
"compile-only": false,
"js-url": undefined,
"https": false,
"https-key": undefined,
"https-cert": undefined,
"https-ca": undefined,
"https-pfx": undefined,
"https-passphrase": undefined,
"log-level": debug,
"env": {
"staging": {
"port": "4000"
},
"production": {
"port": "80"
}
}
20 changes: 12 additions & 8 deletions packages/generator-react-server/test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test('generator-react-server:app creates default files', async t => {
.toPromise();
t.true(await exists('.babelrc', testDir));
t.true(await exists('.gitignore', testDir));
t.true(await exists('.reactserverrc', testDir));
t.true(await exists('hello-world-page.js', testDir));
t.true(await exists('hello-world.js', testDir));
t.true(await exists('package.json', testDir));
Expand All @@ -33,6 +34,7 @@ test('generator-react-server:app creates docker files', async t => {
.toPromise();
t.true(await exists('.babelrc', testDir));
t.true(await exists('.gitignore', testDir));
t.true(await exists('.reactserverrc', testDir));
t.true(await exists('hello-world-page.js', testDir));
t.true(await exists('hello-world.js', testDir));
t.true(await exists('package.json', testDir));
Expand All @@ -51,10 +53,10 @@ test('generator-react-server:app passes the test target', async t => {
.withPrompts({name: 'foo', dockerCfg: false})
.toPromise();
await installDeps();
t.true(await runsSuccessfully('npm test'));
t.true(await runsSuccessfully('npm test', testDir));
});

async function exists(filename, dir) {
function exists(filename, dir) {
filename = path.join(dir, filename);
return new Promise((resolve) => {
fs.access(filename, fs.F_OK, (err) => {
Expand All @@ -63,22 +65,24 @@ async function exists(filename, dir) {
});
}

async function runsSuccessfully(command) {
function runsSuccessfully(command, dir) {
return new Promise((resolve) => {
cp.exec(command, (error) => {
cp.exec(command, {
cwd: dir
}, (error) => {
resolve(!error);
})
});
});
}

async function installDeps() {
return new Promise((resolve) => {
function installDeps() {
return new Promise((resolve, reject) => {
cp.exec('npm install', (error) => {
if (error) {
reject(error);
} else {
resolve();
}
})
});
});
}