Skip to content

Commit

Permalink
Added an installer qustion to preserve the onboarding checklist.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Jan 31, 2025
1 parent f7f58a5 commit e9c3b84
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .vortex/installer/src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ protected function collectAnswers(): void {

$this->askForAnswer('preserve_renovatebot', 'Do you want to keep RenovateBot integration?');

$this->askForAnswer('preserve_onboarding', 'Do you want to keep onboarding checklist?');

$this->askForAnswer('preserve_doc_comments', 'Do you want to keep detailed documentation in comments?');
$this->askForAnswer('preserve_vortex_info', 'Do you want to keep all Vortex information?');

Expand Down Expand Up @@ -375,6 +377,7 @@ protected function replaceTokens(): void {
'preserve_lagoon',
'preserve_ftp',
'preserve_renovatebot',
'preserve_onboarding',
'string_tokens',
'preserve_doc_comments',
'demo_mode',
Expand Down
25 changes: 25 additions & 0 deletions .vortex/installer/src/Traits/PromptsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ protected function getDefaultValuePreserveRenovatebot(): string {
return self::ANSWER_YES;
}

protected function getDefaultValuePreserveOnboarding(): string {
return self::ANSWER_YES;
}

protected function getDefaultValuePreserveDocComments(): string {
return self::ANSWER_YES;
}
Expand Down Expand Up @@ -400,6 +404,13 @@ protected function processWebroot(string $dir): void {
}
}

protected function processPreserveOnboarding(string $dir): void {
if ($this->getAnswer('preserve_onboarding') !== self::ANSWER_YES) {
@unlink($dir . '/docs/onboarding.md');
File::removeTokenWithContent('ONBOARDING', $dir);
}
}

protected function processPreserveDocComments(string $dir): void {
if ($this->getAnswer('preserve_doc_comments') === self::ANSWER_YES) {
// Replace special "#: " comments with normal "#" comments.
Expand Down Expand Up @@ -648,6 +659,16 @@ protected function discoverValuePreserveRenovatebot(): ?string {
return is_readable($this->config->getDstDir() . '/renovate.json') ? self::ANSWER_YES : self::ANSWER_NO;
}

protected function discoverValuePreserveOnboarding(): ?string {
if ($this->isInstalled()) {
$file = $this->config->getDstDir() . '/docs/onboarding.md';

return is_readable($file) ? self::ANSWER_YES : self::ANSWER_NO;
}

return NULL;
}

protected function discoverValuePreserveDocComments(): ?string {
$file = $this->config->getDstDir() . '/.ahoy.yml';

Expand Down Expand Up @@ -818,6 +839,10 @@ protected function normaliseAnswerPreserveRenovatebot(string $value): string {
return strtolower($value) !== self::ANSWER_YES ? self::ANSWER_NO : self::ANSWER_YES;
}

protected function normaliseAnswerPreserveOnboarding(string $value): string {
return strtolower($value) !== self::ANSWER_YES ? self::ANSWER_NO : self::ANSWER_YES;
}

protected function normaliseAnswerPreserveDocComments(string $value): string {
return strtolower($value) !== self::ANSWER_YES ? self::ANSWER_NO : self::ANSWER_YES;
}
Expand Down
3 changes: 2 additions & 1 deletion .vortex/installer/src/Traits/TuiTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function ask(string $question, ?string $default, bool $close_handle =
return $default;
}

$this->out(sprintf('%s [%s] ', $this->formatColor('> ' . $question, 'green'), $this->formatColor($default, 'yellow')), NULL, FALSE);
$this->out(sprintf(PHP_EOL . '%s [%s] ', $this->formatColor('> ' . $question, 'green'), $this->formatColor($default, 'yellow')), NULL, FALSE);

$handle = $this->getStdinHandle();
$answer = fgets($handle);
Expand Down Expand Up @@ -198,6 +198,7 @@ protected function printSummary(): void {
$values['Acquia integration'] = $this->formatEnabled($this->getAnswer('preserve_acquia'));
$values['Lagoon integration'] = $this->formatEnabled($this->getAnswer('preserve_lagoon'));
$values['RenovateBot integration'] = $this->formatEnabled($this->getAnswer('preserve_renovatebot'));
$values['Preserve onboarding checklist'] = $this->formatYesNo($this->getAnswer('preserve_onboarding'));
$values['Preserve docs in comments'] = $this->formatYesNo($this->getAnswer('preserve_doc_comments'));
$values['Preserve Vortex comments'] = $this->formatYesNo($this->getAnswer('preserve_vortex_info'));

Expand Down
31 changes: 30 additions & 1 deletion .vortex/tests/bats/_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,34 @@ assert_files_present_no_integration_renovatebot() {
popd >/dev/null || exit 1
}

assert_files_present_onboarding() {
local dir="${1:-$(pwd)}"
local suffix="${2:-star_wars}"

pushd "${dir}" >/dev/null || exit 1

assert_file_contains "docs/README.md" "Onboarding"
assert_file_contains "README.md" "Onboarding"

assert_file_exists "docs/onboarding.md"

popd >/dev/null || exit 1
}

assert_files_present_no_onboarding() {
local dir="${1:-$(pwd)}"
local suffix="${2:-star_wars}"

pushd "${dir}" >/dev/null || exit 1

assert_file_not_contains "docs/README.md" "Onboarding"
assert_file_not_contains "README.md" "Onboarding"

assert_file_not_exists "docs/onboarding.md"

popd >/dev/null || exit 1
}

assert_webpage_contains() {
path="${1}"
content="${2}"
Expand Down Expand Up @@ -1121,6 +1149,7 @@ run_installer_quiet() {
# "nothing" # preserve_acquia
# "nothing" # preserve_lagoon
# "nothing" # preserve_renovatebot
# "nothing" # preserve_onboarding
# "nothing" # preserve_doc_comments
# "nothing" # preserve_vortex_info
# )
Expand All @@ -1143,7 +1172,7 @@ run_installer_interactive() {
done

# shellcheck disable=SC2059,SC2119
# ATTENTION! Questions change based on some answers, so using the same set of
# ATTENTION! Some questions change based on answers, so using the same set of
# answers for all tests will not work. Make sure that correct answers
# provided for specific tests.
printf "${input}" | run_installer_quiet
Expand Down
38 changes: 38 additions & 0 deletions .vortex/tests/bats/install.existing.bats
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ load _helper.bash
assert_files_present_no_integration_lagoon
assert_files_present_no_integration_ftp
assert_files_present_integration_renovatebot
assert_files_present_onboarding
}

@test "Install into existing: previously installed project; override_existing_db; discovery; quiet" {
Expand All @@ -406,6 +407,7 @@ load _helper.bash
assert_files_present_no_integration_lagoon
assert_files_present_no_integration_ftp
assert_files_present_integration_renovatebot
assert_files_present_onboarding

assert_files_present_override_existing_db
}
Expand Down Expand Up @@ -437,6 +439,7 @@ load _helper.bash
assert_files_present_no_integration_lagoon
assert_files_present_no_integration_ftp
assert_files_present_integration_renovatebot
assert_files_present_onboarding
}

@test "Install into existing: previously installed project; CI Provider - CircleCI; discovery; quiet" {
Expand Down Expand Up @@ -466,6 +469,7 @@ load _helper.bash
assert_files_present_no_integration_lagoon
assert_files_present_no_integration_ftp
assert_files_present_integration_renovatebot
assert_files_present_onboarding
}

@test "Install into existing: previously installed project; CI Provider - None; discovery; quiet" {
Expand Down Expand Up @@ -496,6 +500,7 @@ load _helper.bash
assert_files_present_no_integration_lagoon
assert_files_present_no_integration_ftp
assert_files_present_integration_renovatebot
assert_files_present_onboarding
}

@test "Install into existing: previously installed project; Deployment; discovery; quiet" {
Expand All @@ -517,6 +522,7 @@ load _helper.bash
assert_files_present_integration_lagoon
assert_files_present_no_integration_ftp
assert_files_present_integration_renovatebot
assert_files_present_onboarding
}

@test "Install into existing: previously installed project; Acquia; discovery; quiet" {
Expand Down Expand Up @@ -545,6 +551,7 @@ load _helper.bash
assert_files_present_no_integration_lagoon
assert_files_present_no_integration_ftp
assert_files_present_integration_renovatebot
assert_files_present_onboarding
}

@test "Install into existing: previously installed project; Lagoon; discovery; quiet" {
Expand Down Expand Up @@ -573,6 +580,7 @@ load _helper.bash
assert_files_present_integration_lagoon
assert_files_present_no_integration_ftp
assert_files_present_integration_renovatebot
assert_files_present_onboarding
}

@test "Install into existing: previously installed project; Renovate; discovery; quiet" {
Expand Down Expand Up @@ -601,4 +609,34 @@ load _helper.bash
assert_files_present_no_integration_lagoon
assert_files_present_no_integration_ftp
assert_files_present_no_integration_renovatebot
assert_files_present_onboarding
}

@test "Install into existing: previously installed project; Onboarding; discovery; quiet" {
# Populate current dir with a project at current version.
run_installer_quiet

# Assert files at current version.
assert_files_present
assert_git_repo

rm -Rf docs/onboarding.md

output=$(run_installer_quiet)
assert_output_contains "WELCOME TO VORTEX QUIET INSTALLER"
assert_output_contains "It looks like Vortex is already installed into this project"

assert_git_repo

install_dependencies_stub

assert_files_present_common
assert_files_present_no_provision_use_profile
assert_files_present_ci_provider_gha
assert_files_present_deployment
assert_files_present_no_integration_acquia
assert_files_present_no_integration_lagoon
assert_files_present_no_integration_ftp
assert_files_present_integration_renovatebot
assert_files_present_no_onboarding
}
3 changes: 3 additions & 0 deletions .vortex/tests/bats/install.initial.bats
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ load _helper.bash
"nothing" # preserve_acquia
"nothing" # preserve_lagoon
"nothing" # preserve_renovatebot
"nothing" # preserve_onboarding
"nothing" # preserve_doc_comments
"nothing" # preserve_vortex_info
)
Expand Down Expand Up @@ -147,6 +148,7 @@ load _helper.bash
"nothing" # preserve_acquia
"nothing" # preserve_lagoon
"nothing" # preserve_renovatebot
"nothing" # preserve_onboarding
"nothing" # preserve_doc_comments
"nothing" # preserve_vortex_info
)
Expand Down Expand Up @@ -189,6 +191,7 @@ load _helper.bash
"nothing" # preserve_acquia
"nothing" # preserve_lagoon
"nothing" # preserve_renovatebot
"nothing" # preserve_onboarding
"nothing" # preserve_doc_comments
"nothing" # preserve_vortex_info
)
Expand Down
5 changes: 5 additions & 0 deletions .vortex/tests/bats/install.integrations.bats
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ load _helper.bash
"no" # preserve_acquia
"no" # preserve_lagoon
"no" # preserve_renovatebot
"nothing" # preserve_onboarding
"nothing" # preserve_doc_comments
"nothing" # preserve_vortex_info
)
Expand Down Expand Up @@ -67,6 +68,7 @@ load _helper.bash
"y" # preserve_acquia
"y" # preserve_lagoon
"y" # preserve_renovatebot
"nothing" # preserve_onboarding
"nothing" # preserve_doc_comments
"nothing" # preserve_vortex_info
)
Expand Down Expand Up @@ -110,6 +112,7 @@ load _helper.bash
"y" # preserve_acquia
"y" # preserve_lagoon
"y" # preserve_renovatebot
"nothing" # preserve_onboarding
"nothing" # preserve_doc_comments
"nothing" # preserve_vortex_info
)
Expand Down Expand Up @@ -151,6 +154,7 @@ load _helper.bash
"n" # preserve_acquia
"n" # preserve_lagoon
"n" # preserve_renovatebot
"nothing" # preserve_onboarding
"nothing" # preserve_doc_comments
"nothing" # preserve_vortex_info
)
Expand Down Expand Up @@ -188,6 +192,7 @@ load _helper.bash
"n" # preserve_acquia
"y" # preserve_lagoon
"n" # preserve_renovatebot
"nothing" # preserve_onboarding
"nothing" # preserve_doc_comments
"nothing" # preserve_vortex_info
)
Expand Down
Loading

1 comment on commit e9c3b84

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.