0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Added --stripe support to yarn dev

refs https://ghost.slack.com/archives/C02G9E68C/p1665043198507819?thread_ts=1664955131.950719&cid=C02G9E68C

- this adds support for `yarn dev --stripe` which will spin up the
  Stripe CLI to listen for webhooks, and configures Ghost with the
  secret key it needs to communicate
- also fixes a minor typing error with a missing `env: {}`
This commit is contained in:
Daniel Lockyer 2022-10-06 15:32:08 +07:00
parent 12aaaa6d6e
commit 28cc88c2cd
No known key found for this signature in database

39
.github/dev.js vendored
View file

@ -1,8 +1,12 @@
const path = require('path');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const concurrently = require('concurrently');
const config = require('../ghost/core/core/shared/config');
const liveReloadBaseUrl = config.getSubdir() || '/ghost/';
const siteUrl = config.getSiteUrl();
const DASH_DASH_ARGS = process.argv.filter(a => a.startsWith('--')).map(a => a.slice(2));
@ -36,17 +40,40 @@ if (DASH_DASH_ARGS.includes('portal')) {
name: 'portal',
command: 'yarn dev',
cwd: path.resolve(__dirname, '../ghost/portal'),
prefixColor: 'magenta'
prefixColor: 'magenta',
env: {}
});
COMMAND_GHOST.env['portal__url'] = 'http://localhost:5368/umd/portal.min.js';
}
if (!commands.length) {
console.log(`No commands provided`);
process.exit(0);
}
(async () => {
if (DASH_DASH_ARGS.includes('stripe')) {
let stripeSecret;
try {
stripeSecret = await exec('stripe listen --print-secret');
} catch (err) {
console.error('Failed to fetch Stripe secret token, do you need to connect Stripe CLI?', err);
}
if (!stripeSecret || !stripeSecret.stdout) {
console.error('No Stripe secret was present');
return;
}
COMMAND_GHOST.env['WEBHOOK_SECRET'] = stripeSecret.stdout.trim();
commands.push({
name: 'stripe',
command: `stripe listen --forward-to ${siteUrl}members/webhooks/stripe/`,
prefixColor: 'yellow',
env: {}
});
}
if (!commands.length) {
console.log(`No commands provided`);
process.exit(0);
}
const {result} = concurrently(commands, {
prefix: 'name',
killOthers: ['failure', 'success']