diff --git a/.github/dev.js b/.github/dev.js new file mode 100644 index 0000000000..584fc2ed70 --- /dev/null +++ b/.github/dev.js @@ -0,0 +1,50 @@ +const path = require('path'); +const concurrently = require('concurrently'); + +const config = require('../ghost/core/core/shared/config'); +const liveReloadBaseUrl = config.getSubdir() || '/ghost/'; + +const DASH_DASH_ARGS = process.argv.filter(a => a.startsWith('--')).map(a => a.slice(2)); + +let commands = []; + +const COMMAND_GHOST = { + name: 'ghost', + command: 'yarn nodemon -q -i ghost/admin -i ghost/core/content -i ghost/core/core/built', + prefixColor: 'blue', + env: {} +}; + +const COMMAND_ADMIN = { + name: 'admin', + command: `yarn start --live-reload-base-url=${liveReloadBaseUrl} --live-reload-port=4201`, + cwd: path.resolve(__dirname, '../ghost/admin'), + prefixColor: 'green', + env: {} +}; + +if (DASH_DASH_ARGS.includes('ghost')) { + commands = [COMMAND_GHOST]; +} else if (DASH_DASH_ARGS.includes('admin')) { + commands = [COMMAND_ADMIN]; +} else { + commands = [COMMAND_GHOST, COMMAND_ADMIN]; +} + +if (!commands.length) { + console.log(`No commands provided`); + process.exit(0); +} + +(async () => { + const {result} = concurrently(commands, { + prefix: 'name', + killOthers: ['failure', 'success'] + }); + + try { + await result; + } catch (err) { + console.error(err); + } +})(); diff --git a/ghost/core/Gruntfile.js b/ghost/core/Gruntfile.js index 5ad4ab3d93..e54059c712 100644 --- a/ghost/core/Gruntfile.js +++ b/ghost/core/Gruntfile.js @@ -1,30 +1,6 @@ -const config = require('./core/shared/config'); - module.exports = function (grunt) { // --- Configuration grunt.initConfig({ - shell: { - ember: { - command: function (mode) { - const liveReloadBaseUrl = config.getSubdir() || '/ghost/'; - - switch (mode) { - case 'watch': - return `yarn start --live-reload-base-url=${liveReloadBaseUrl} --live-reload-port=4201`; - } - }, - options: { - execOptions: { - cwd: '../admin' - } - } - }, - - options: { - preferLocal: true - } - }, - // grunt-contrib-symlink // Create symlink for git hooks symlink: { @@ -44,5 +20,4 @@ module.exports = function (grunt) { // Load all grunt tasks grunt.loadNpmTasks('grunt-contrib-symlink'); - grunt.loadNpmTasks('grunt-shell'); }; diff --git a/ghost/core/package.json b/ghost/core/package.json index be05954d61..898e162168 100644 --- a/ghost/core/package.json +++ b/ghost/core/package.json @@ -197,7 +197,6 @@ "eslint": "8.23.1", "grunt": "1.5.3", "grunt-contrib-symlink": "1.0.0", - "grunt-shell": "4.0.0", "html-validate": "7.5.0", "inquirer": "8.2.4", "jwks-rsa": "2.1.4", diff --git a/package.json b/package.json index 77bc5d4bc9..327503ccf7 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,9 @@ ], "scripts": { "dev:debug": "DEBUG_COLORS=true DEBUG=@tryghost*,ghost:* yarn dev", - "dev:admin": "yarn workspace ghost run grunt shell:ember:watch", - "dev:ghost": "nodemon -q -i ghost/admin -i ghost/core/content -i ghost/core/core/built", - "dev": "concurrently -c \"blue,green\" --kill-others -n ghost,admin \"yarn dev:ghost\" \"yarn dev:admin\"", + "dev:admin": "node .github/dev.js --admin", + "dev:ghost": "node .github/dev.js --ghost", + "dev": "node .github/dev.js", "fix": "yarn cache clean && rm -rf node_modules && yarn", "knex-migrator": "yarn workspace ghost run knex-migrator", "lint": "yarn workspaces run lint", diff --git a/yarn.lock b/yarn.lock index a32e8a66c5..894937a8d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7717,14 +7717,6 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4 escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" - integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - character-entities-html4@^1.0.0: version "1.1.4" resolved "https://registry.yarnpkg.com/character-entities-html4/-/character-entities-html4-1.1.4.tgz#0e64b0a3753ddbf1fdc044c5fd01d0199a02e125" @@ -13225,15 +13217,6 @@ grunt-legacy-util@~2.0.1: underscore.string "~3.3.5" which "~2.0.2" -grunt-shell@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/grunt-shell/-/grunt-shell-4.0.0.tgz#9b04a18a59c3113f24391a3fb5625320538cbd1c" - integrity sha512-dHFy8VZDfWGYLTeNvIHze4PKXGvIlDWuN0UE7hUZstTQeiEyv1VmW1MaDYQ3X5tE3bCi3bEia1gGKH8z/f1czQ== - dependencies: - chalk "^3.0.0" - npm-run-path "^2.0.0" - strip-ansi "^6.0.1" - grunt@1.5.3: version "1.5.3" resolved "https://registry.yarnpkg.com/grunt/-/grunt-1.5.3.tgz#3214101d11257b7e83cf2b38ea173b824deab76a"