0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Extracted dev tooling to separate script

refs https://github.com/TryGhost/Toolbox/issues/426

- we're going to need to support more complex combinations of dev
  commands soon, with other packages optionally running and env
  variables being altered
- this command pulls out a lot of the dev env scripting into a single
  scripts
- also cleans up the use of grunt-shell so we can remove the dependency
This commit is contained in:
Daniel Lockyer 2022-09-23 14:30:23 +02:00
parent 3056e3cb51
commit 2bff2a22e0
No known key found for this signature in database
5 changed files with 53 additions and 46 deletions

50
.github/dev.js vendored Normal file
View file

@ -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);
}
})();

View file

@ -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');
};

View file

@ -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",

View file

@ -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",

View file

@ -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"