🎨 Updates for Gruntfile (#8158)

* grunt docs did not work
  - the option "extras" did not work
  - https://github.com/jbt/docker/blob/v0.2.14/src/docker.js#L1280
  - there is a bug in docker docs
  - i removed it for now
* grunt watch-docs typo + remove old config
* remove client testing and client linting
* optimise grunt validate
  - validate is just a wrapper command for `npm test`
  - it will either run lint or the server tests
  - no build - why should validate build ember?
* config updates
  - we don't have a config.js anymore
  - use new config notation
* Update grunt dev
  - livereload for Ghost wasn't working correct, the server wasn't stopped correctly and after reload an address in use error was visibile
  - that is because the "spawn" option has changed to "nospawn"
  - add stdout/stderr info to the bgshell watch command
This commit is contained in:
Katharina Irrgang 2017-03-14 14:51:32 +01:00 committed by Kevin Ansfield
parent 974adee932
commit b5cdc01ad1
2 changed files with 22 additions and 49 deletions

View File

@ -22,7 +22,6 @@ env:
global: global:
- GITHUB_OAUTH_KEY=003a44d58f12089d0c0261338298af3813330949 - GITHUB_OAUTH_KEY=003a44d58f12089d0c0261338298af3813330949
- GHOST_NODE_VERSION_CHECK=false - GHOST_NODE_VERSION_CHECK=false
- TEST_SUITE=server
matrix: matrix:
- DB=sqlite3 NODE_ENV=testing - DB=sqlite3 NODE_ENV=testing
- DB=mysql NODE_ENV=testing-mysql - DB=mysql NODE_ENV=testing-mysql

View File

@ -69,10 +69,11 @@ var overrides = require('./core/server/overrides'),
} }
}, },
express: { express: {
files: ['core/ghost-server.js', 'core/server/**/*.js'], files: ['core/ghost-server.js', 'core/server/**/*.js', 'config.*.json'],
tasks: ['express:dev'], tasks: ['express:dev'],
options: { options: {
spawn: false nospawn: true,
livereload: true
} }
} }
}, },
@ -105,7 +106,7 @@ var overrides = require('./core/server/overrides'),
server: [ server: [
'*.js', '*.js',
'!config*.js', // note: i added this, do we want this linted? '!config.*.json', // note: i added this, do we want this linted?
'core/*.js', 'core/*.js',
'core/server/**/*.js', 'core/server/**/*.js',
'core/test/**/*.js', 'core/test/**/*.js',
@ -123,7 +124,7 @@ var overrides = require('./core/server/overrides'),
files: { files: {
src: [ src: [
'*.js', '*.js',
'!config*.js', // note: i added this, do we want this linted? '!config.*.json', // note: i added this, do we want this linted?
'core/*.js', 'core/*.js',
'core/server/**/*.js', 'core/server/**/*.js',
'core/test/**/*.js', 'core/test/**/*.js',
@ -217,7 +218,9 @@ var overrides = require('./core/server/overrides'),
bgShell: { bgShell: {
client: { client: {
cmd: 'grunt subgrunt:watch', cmd: 'grunt subgrunt:watch',
bg: true bg: true,
stdout: true,
stderr: true
} }
}, },
@ -246,8 +249,8 @@ var overrides = require('./core/server/overrides'),
options: { options: {
onlyUpdated: true, onlyUpdated: true,
exclude: 'node_modules,bower_components,content,core/client,*test,*doc*,' + exclude: 'node_modules,bower_components,content,core/client,*test,*doc*,' +
'*vendor,config.js,*buil*,.dist*,.idea,.git*,.travis.yml,.bower*,.editorconfig,.js*,*.md', '*vendor,config.*.json,*buil*,.dist*,.idea,.git*,.travis.yml,.bower*,.editorconfig,.js*,*.md,' +
extras: ['fileSearch'] 'MigratorConfig.js'
} }
} }
}, },
@ -317,6 +320,7 @@ var overrides = require('./core/server/overrides'),
options: { options: {
npmInstall: false npmInstall: false
}, },
init: { init: {
options: { options: {
npmInstall: true npmInstall: true
@ -335,15 +339,7 @@ var overrides = require('./core/server/overrides'),
}, },
watch: { watch: {
'core/client': ['bgShell:ember', 'watch'] 'core/client': 'shell:ember:watch'
},
lint: {
'core/client': 'lint'
},
test: {
'core/client': 'shell:test'
} }
} }
}; };
@ -376,12 +372,12 @@ var overrides = require('./core/server/overrides'),
// Run `grunt docs` to generate annotated source code using the documentation described in the code comments. // Run `grunt docs` to generate annotated source code using the documentation described in the code comments.
grunt.registerTask('docs', 'Generate Docs', ['docker']); grunt.registerTask('docs', 'Generate Docs', ['docker']);
// Runun `grunt watch-docs` to setup livereload & watch whilst you're editing the docs // Run `grunt watch-docs` to setup livereload & watch whilst you're editing the docs
grunt.registerTask('watch-docs', function () { grunt.registerTask('watch-docs', function () {
grunt.config.merge({ grunt.config.merge({
watch: { watch: {
docs: { docs: {
files: ['core/server/**/*', 'index.js', 'Gruntfile.js', 'config.example.js'], files: ['core/server/**/*', 'index.js', 'Gruntfile.js'],
tasks: ['docker'], tasks: ['docker'],
options: { options: {
livereload: true livereload: true
@ -462,42 +458,24 @@ var overrides = require('./core/server/overrides'),
// ### Validate // ### Validate
// **Main testing task** // **Main testing task**
// //
// `grunt validate` will build, lint and test your local Ghost codebase. // `grunt validate` will either run all tests or run linting
//
// `grunt validate` is one of the most important and useful grunt tasks that we have available to use. It
// manages the build of your environment and then calls `grunt test`
//
// `grunt validate` is called by `npm test` and is used by Travis. // `grunt validate` is called by `npm test` and is used by Travis.
grunt.registerTask('validate', 'Run tests and lint code', function () { grunt.registerTask('validate', 'Run tests or lint code', function () {
if (process.env.TEST_SUITE === 'server') { if (process.env.TEST_SUITE === 'lint') {
grunt.task.run(['stubClientFiles', 'test-server']); return grunt.task.run(['lint']);
} else if (process.env.TEST_SUITE === 'lint') {
grunt.task.run(['lint']);
} else {
grunt.task.run(['validate-all']);
} }
});
grunt.registerTask('validate-all', 'Lint code and run all tests', grunt.task.run(['stubClientFiles', 'test-all']);
['init', 'lint', 'test-all']); });
// ### Test-All // ### Test-All
// **Main testing task** // **Main testing task**
// //
// `grunt test-all` will lint and test your pre-built local Ghost codebase. // `grunt test-all` will lint and test your pre-built local Ghost codebase.
// //
// `grunt test-all` runs all 6 test suites. See the individual sub tasks below for grunt.registerTask('test-all', 'Run all server tests',
// details of each of the test suites.
//
grunt.registerTask('test-all', 'Run tests for both server and client',
['test-server', 'test-client']);
grunt.registerTask('test-server', 'Run server tests',
['test-routes', 'test-module', 'test-unit', 'test-integration']); ['test-routes', 'test-module', 'test-unit', 'test-integration']);
grunt.registerTask('test-client', 'Run client tests',
['subgrunt:test']);
// ### Lint // ### Lint
// //
// `grunt lint` will run the linter and the code style checker so you can make sure your code is pretty // `grunt lint` will run the linter and the code style checker so you can make sure your code is pretty
@ -505,10 +483,6 @@ var overrides = require('./core/server/overrides'),
['jshint', 'jscs'] ['jshint', 'jscs']
); );
grunt.registerTask('lint-all', 'Run the code style checks and linter for server and client',
['lint', 'subgrunt:lint']
);
// ### test-setup *(utility)( // ### test-setup *(utility)(
// `grunt test-setup` will run all the setup tasks required for running tests // `grunt test-setup` will run all the setup tasks required for running tests
grunt.registerTask('test-setup', 'Setup ready to run tests', grunt.registerTask('test-setup', 'Setup ready to run tests',
@ -537,7 +511,7 @@ var overrides = require('./core/server/overrides'),
// ### Integration tests *(sub task)* // ### Integration tests *(sub task)*
// `grunt test-integration` will run just the integration tests // `grunt test-integration` will run just the integration tests
// //
// Provided you already have a `config.js` file, you can run just the model integration tests by running: // Provided you already have a `config.*.json` file, you can run just the model integration tests by running:
// //
// `grunt test:integration/model` // `grunt test:integration/model`
// //