-
-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move build automation scripts into the /scripts folder
Closes #9
- Loading branch information
Showing
9 changed files
with
159 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* GraphQL Starter Kit (https://www.reactstarterkit.com/) | ||
* | ||
* Copyright © 2016-present Kriasoft, LLC. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const cp = require('child_process'); | ||
const pkg = require('../package.json'); | ||
const clean = require('./clean'); | ||
const task = require('./lib/task'); | ||
|
||
module.exports = task(() => Promise.resolve() | ||
.then(clean) | ||
.then(() => new Promise((resolve) => { | ||
cp.spawn('node', [ | ||
'node_modules/babel-cli/bin/babel.js', | ||
'src', | ||
'--out-dir', | ||
'build', | ||
'--source-maps', | ||
...(process.argv.includes('--watch') || process.argv.includes('-w') ? ['--watch'] : []), | ||
], { stdio: ['inherit', 'pipe', 'inherit'] }) | ||
.on('exit', resolve) | ||
.stdout.on('data', (data) => { | ||
if (data.toString().startsWith('src/server.js')) { | ||
const src = fs.readFileSync('build/server.js', 'utf8'); | ||
fs.writeFileSync('build/server.js', `require('source-map-support').install(); ${src}`, 'utf8'); | ||
} | ||
process.stdout.write(data); | ||
}); | ||
})) | ||
.then(() => new Promise((resolve) => { | ||
fs.writeFileSync('build/package.json', JSON.stringify({ | ||
engines: pkg.engines, | ||
dependencies: pkg.dependencies, | ||
scripts: { start: 'node server.js' }, | ||
}, null, ' '), 'utf8'); | ||
process.stdout.write('package.json -> build/package.json\n'); | ||
resolve(); | ||
}))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* GraphQL Starter Kit (https://www.reactstarterkit.com/) | ||
* | ||
* Copyright © 2016-present Kriasoft, LLC. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
const rimraf = require('rimraf'); | ||
const task = require('./lib/task'); | ||
|
||
module.exports = task(() => new Promise((resolve, reject) => { | ||
rimraf('build/*', { | ||
nosort: true, | ||
dot: true, | ||
ignore: ['build/.git'], | ||
}, (err) => { | ||
if (err) reject(err); | ||
resolve(); | ||
}); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* GraphQL Starter Kit (https://www.reactstarterkit.com/) | ||
* | ||
* Copyright © 2016-present Kriasoft, LLC. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
const path = require('path'); | ||
|
||
function run(task, action) { | ||
const start = new Date(); | ||
process.stdout.write(`Starting '${task}'...\n`); | ||
return Promise.resolve().then(() => action()).then(() => { | ||
process.stdout.write(`Finished '${task}' after ${new Date().getTime() - start.getTime()}ms\n`); | ||
}, err => process.stderr.write(`${err.stack}\n`)); | ||
} | ||
|
||
module.exports = (action) => { | ||
const task = path.basename(module.parent.filename, '.js'); | ||
return run.bind(undefined, task, action); | ||
}; | ||
|
||
process.nextTick(() => require.main.exports()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* GraphQL Starter Kit (https://www.reactstarterkit.com/) | ||
* | ||
* Copyright © 2016-present Kriasoft, LLC. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
const path = require('path'); | ||
const nodemon = require('nodemon'); | ||
require('./lib/task'); | ||
const config = require('../src/config'); | ||
|
||
module.exports = () => { | ||
process.stdout.write('\033c'); | ||
nodemon({ | ||
watch: [path.join(__dirname, 'src')], | ||
ignore: [], | ||
verbose: true, | ||
script: 'src/server.js', | ||
nodeArgs: ['--require', 'babel-register', ...process.argv.filter(x => x.startsWith('-'))], | ||
stdout: false, | ||
}) | ||
.on('stdout', data => { | ||
if (data.toString().includes(config.message)) { | ||
process.stdout.write('\033c'); | ||
} | ||
process.stdout.write(data); | ||
}) | ||
.on('stderr', data => process.stderr.write(data)) | ||
.on('start', () => process.stdout.write('\033cBuilding...')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters