-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display next steps after running the adders (#409)
* initial implementation * changeset * apply suggestions * add more context for next steps execution * fix imports * fix type * add next step message to `drizzle` * fix wording * changeset
- Loading branch information
1 parent
1802786
commit 0a20a35
Showing
6 changed files
with
64 additions
and
5 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,5 @@ | ||
--- | ||
"@svelte-add/drizzle": minor | ||
--- | ||
|
||
feat: display next steps after running the drizzle |
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,5 @@ | ||
--- | ||
"@svelte-add/core": minor | ||
--- | ||
|
||
feat: display next steps after running the adders |
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
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
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
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,37 @@ | ||
import { messagePrompt } from "../utils/prompts"; | ||
import type { InlineAdderConfig } from "./config"; | ||
import type { AdderDetails, AddersExecutionPlan } from "./execute"; | ||
import type { OptionDefinition, OptionValues } from "./options"; | ||
import pc from "picocolors"; | ||
|
||
export function displayNextSteps<Args extends OptionDefinition>( | ||
adderDetails: AdderDetails<Args>[], | ||
multipleAdders: boolean, | ||
executionPlan: AddersExecutionPlan, | ||
) { | ||
const allAddersMessage = adderDetails | ||
.filter((x) => x.config.integrationType == "inline" && x.config.nextSteps) | ||
.map((x) => x.config as InlineAdderConfig<Args>) | ||
.map((x) => { | ||
// only doing this to narrow the type, `nextSteps` should already exist here | ||
if (!x.nextSteps) return ""; | ||
const metadata = x.metadata; | ||
let adderMessage = ""; | ||
if (multipleAdders) { | ||
adderMessage = `${pc.green(metadata.name)}:\n`; | ||
} | ||
|
||
const options = executionPlan.cliOptionsByAdderId[x.metadata.id] as OptionValues<Args>; | ||
|
||
const adderNextSteps = x.nextSteps({ | ||
options, | ||
cwd: executionPlan.workingDirectory, | ||
colors: pc, | ||
docs: x.metadata.website?.documentation, | ||
}); | ||
adderMessage += `- ${adderNextSteps.join("\n- ")}`; | ||
return adderMessage; | ||
}) | ||
.join("\n\n"); | ||
messagePrompt("Next steps", allAddersMessage); | ||
} |