mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-04 02:01:58 -05:00
Added support to yarn dev
for --search
to launch Sodo-Search
refs https://github.com/TryGhost/Toolbox/issues/400 - this makes development more fluid by allowing developers to use the local Sodo-Search code
This commit is contained in:
parent
680e3bf270
commit
3302f4125e
3 changed files with 16 additions and 46 deletions
14
.github/dev.js
vendored
14
.github/dev.js
vendored
|
@ -17,7 +17,7 @@ let commands = [];
|
|||
|
||||
const COMMAND_GHOST = {
|
||||
name: 'ghost',
|
||||
command: 'yarn nodemon -q -i ghost/admin -i ghost/core/content -i ghost/core/core/built -i ghost/portal',
|
||||
command: 'yarn nodemon -q -i ghost/admin -i ghost/core/content -i ghost/core/core/built -i ghost/portal -i ghost/sodo-search',
|
||||
prefixColor: 'blue',
|
||||
env: {}
|
||||
};
|
||||
|
@ -49,6 +49,18 @@ if (DASH_DASH_ARGS.includes('portal')) {
|
|||
COMMAND_GHOST.env['portal__url'] = 'http://localhost:5368/umd/portal.min.js';
|
||||
}
|
||||
|
||||
if (DASH_DASH_ARGS.includes('search')) {
|
||||
commands.push({
|
||||
name: 'search',
|
||||
command: 'yarn dev',
|
||||
cwd: path.resolve(__dirname, '../ghost/sodo-search'),
|
||||
prefixColor: '#23de43',
|
||||
env: {}
|
||||
});
|
||||
COMMAND_GHOST.env['sodoSearch__url'] = 'http://localhost:5370/umd/sodo-search.min.js';
|
||||
COMMAND_GHOST.env['sodoSearch__styles'] = 'http://localhost:5370/umd/main.css';
|
||||
}
|
||||
|
||||
(async () => {
|
||||
if (DASH_DASH_ARGS.includes('stripe')) {
|
||||
console.log('Fetching Stripe secret token..');
|
||||
|
|
|
@ -30,9 +30,8 @@
|
|||
"start": "BROWSER=none react-scripts start",
|
||||
"start:combined": "BROWSER=none node ./scripts/start-combined.js",
|
||||
"start:dev": "node ./scripts/start-mode.js",
|
||||
"dev": "node ./scripts/start-mode.js",
|
||||
"tailwind": "npx tailwindcss -i ./src/index.css -o ./public/main.css --watch --minify",
|
||||
"old:dev": "node ./scripts/dev-mode.js",
|
||||
"dev": "node ./scripts/dev-mode.js",
|
||||
"build": "npm run build:combined",
|
||||
"build:original": "react-scripts build",
|
||||
"build:combined": "node ./scripts/build-combined.js",
|
||||
|
|
|
@ -20,16 +20,6 @@ const {v, verbose, port = 5370, basic, b} = minimist(process.argv.slice(2));
|
|||
const showVerbose = !!(v || verbose);
|
||||
const showBasic = !!(b || basic);
|
||||
|
||||
function clearConsole({withHistory = true} = {}) {
|
||||
if (!withHistory) {
|
||||
process.stdout.write('\x1Bc');
|
||||
return;
|
||||
}
|
||||
process.stdout.write(
|
||||
process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'
|
||||
);
|
||||
}
|
||||
|
||||
function maybePluralize(count, noun, suffix = 's') {
|
||||
return `${count} ${noun}${count !== 1 ? suffix : ''}`;
|
||||
}
|
||||
|
@ -88,33 +78,6 @@ function printBuildComplete(code) {
|
|||
log();
|
||||
}
|
||||
|
||||
function printConfigInstruction() {
|
||||
const data = {
|
||||
portal: {
|
||||
url: `http://localhost:${port}/sodo-search`
|
||||
}
|
||||
};
|
||||
const stringifedData = JSON.stringify(data, null, 2);
|
||||
const splitData = stringifedData.split('\n');
|
||||
log();
|
||||
splitData.forEach((_data, idx, arr) => {
|
||||
if (idx === 0 || idx === arr.length - 1) {
|
||||
log(chalk.grey(_data));
|
||||
} else {
|
||||
log(chalk.bold.whiteBright(_data));
|
||||
}
|
||||
});
|
||||
log();
|
||||
}
|
||||
|
||||
function printInstructions() {
|
||||
log();
|
||||
log(chalk.yellowBright.underline(`Add portal to your local Ghost config`));
|
||||
printConfigInstruction();
|
||||
log(chalk.cyanBright('='.repeat(50)));
|
||||
log();
|
||||
}
|
||||
|
||||
function printBuildStart() {
|
||||
if (showVerbose) {
|
||||
log(chalk.bold.greenBright.bgBlackBright(`${'-'.repeat(32)}Building${'-'.repeat(32)}`));
|
||||
|
@ -131,8 +94,6 @@ function onBuildComplete(code) {
|
|||
stdOutChunks = [];
|
||||
if (fileChanges.length > 0) {
|
||||
buildPortal();
|
||||
} else {
|
||||
log(chalk.yellowBright.bold.underline(`Watching file changes...\n`));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +133,7 @@ function buildPortal() {
|
|||
|
||||
function watchFiles() {
|
||||
const watcher = chokidar.watch('.', {
|
||||
ignored: /build|node_modules|.git|public|umd|scripts|(^|[\/\\])\../
|
||||
ignored: /build|node_modules|.git|public|umd|scripts|(^|[/])\../
|
||||
});
|
||||
|
||||
watcher.on('ready', () => {
|
||||
|
@ -210,11 +171,9 @@ function startDevServer() {
|
|||
});
|
||||
|
||||
server.listen(port, () => {
|
||||
log(chalk.whiteBright(`Portal dev server is running on http://localhost:${port}`));
|
||||
printInstructions();
|
||||
log(chalk.whiteBright(`Sodo-Search dev server is running on http://localhost:${port}`));
|
||||
watchFiles();
|
||||
});
|
||||
}
|
||||
|
||||
clearConsole({withHistory: false});
|
||||
startDevServer();
|
||||
|
|
Loading…
Add table
Reference in a new issue