This repository has been archived by the owner on Aug 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from beabee-communityrm/feat/easier-onboarding
feat: new and update tools for a simpler setup process
- Loading branch information
Showing
2 changed files
with
81 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import "module-alias/register"; | ||
|
||
import inquirer, { QuestionCollection } from "inquirer"; | ||
import { getRepository } from "typeorm"; | ||
|
||
import * as db from "@core/database"; | ||
|
||
import OptionsService from "@core/services/OptionsService"; | ||
|
||
import Content from "@models/Content"; | ||
|
||
function notEmpty(msg: string) { | ||
return (s: string) => { | ||
return s.trim() === "" ? msg : true; | ||
}; | ||
} | ||
|
||
const questions: QuestionCollection[] = []; | ||
|
||
questions.push({ | ||
type: "input", | ||
name: "emailDomain", | ||
message: "Email Domain", | ||
validate: notEmpty("You must enter an email domain") | ||
}); | ||
|
||
questions.push({ | ||
type: "checkbox", | ||
name: "paymentProviders", | ||
message: "Payment Methods", | ||
choices: [ | ||
{ name: "Credit card (Stripe)", value: "s_card" }, | ||
{ name: "SEPA direct debit (Stripe)", value: "s_sepa" }, | ||
{ name: "BACS (Stripe)", value: "s_bacs" }, | ||
{ name: "Direct debit (GoCardless)", value: "gc_direct-debit" } | ||
] | ||
}); | ||
|
||
db.connect().then(async () => { | ||
const answers = await inquirer.prompt(questions); | ||
|
||
await OptionsService.set("support-email", "support@" + answers.emailDomain); | ||
|
||
await getRepository(Content).update("join", { | ||
data: () => | ||
`jsonb_set(data, \'{paymentMethods}\', \'${JSON.stringify( | ||
answers.paymentProviders | ||
)}\')` | ||
}); | ||
|
||
await db.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters