Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an installer qustion to preserve the onboarding checklist. #1531

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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

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

Check warning on line 311 in .vortex/installer/src/Command/InstallCommand.php

View check run for this annotation

Codecov / codecov/patch

.vortex/installer/src/Command/InstallCommand.php#L311

Added line #L311 was not covered by tests

$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 @@
'preserve_lagoon',
'preserve_ftp',
'preserve_renovatebot',
'preserve_onboarding',

Check warning on line 380 in .vortex/installer/src/Command/InstallCommand.php

View check run for this annotation

Codecov / codecov/patch

.vortex/installer/src/Command/InstallCommand.php#L380

Added line #L380 was not covered by tests
'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 @@
return self::ANSWER_YES;
}

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

Check warning on line 109 in .vortex/installer/src/Traits/PromptsTrait.php

View check run for this annotation

Codecov / codecov/patch

.vortex/installer/src/Traits/PromptsTrait.php#L109

Added line #L109 was not covered by tests
}

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

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

Check warning on line 410 in .vortex/installer/src/Traits/PromptsTrait.php

View check run for this annotation

Codecov / codecov/patch

.vortex/installer/src/Traits/PromptsTrait.php#L408-L410

Added lines #L408 - L410 were not covered by tests
}
}

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 @@
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';

Check warning on line 664 in .vortex/installer/src/Traits/PromptsTrait.php

View check run for this annotation

Codecov / codecov/patch

.vortex/installer/src/Traits/PromptsTrait.php#L663-L664

Added lines #L663 - L664 were not covered by tests

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

Check warning on line 666 in .vortex/installer/src/Traits/PromptsTrait.php

View check run for this annotation

Codecov / codecov/patch

.vortex/installer/src/Traits/PromptsTrait.php#L666

Added line #L666 was not covered by tests
}

return NULL;

Check warning on line 669 in .vortex/installer/src/Traits/PromptsTrait.php

View check run for this annotation

Codecov / codecov/patch

.vortex/installer/src/Traits/PromptsTrait.php#L669

Added line #L669 was not covered by tests
}

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

Expand Down Expand Up @@ -818,6 +839,10 @@
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;

Check warning on line 843 in .vortex/installer/src/Traits/PromptsTrait.php

View check run for this annotation

Codecov / codecov/patch

.vortex/installer/src/Traits/PromptsTrait.php#L843

Added line #L843 was not covered by tests
}

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 @@
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);

Check warning on line 45 in .vortex/installer/src/Traits/TuiTrait.php

View check run for this annotation

Codecov / codecov/patch

.vortex/installer/src/Traits/TuiTrait.php#L45

Added line #L45 was not covered by tests

$handle = $this->getStdinHandle();
$answer = fgets($handle);
Expand Down Expand Up @@ -198,6 +198,7 @@
$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'));

Check warning on line 201 in .vortex/installer/src/Traits/TuiTrait.php

View check run for this annotation

Codecov / codecov/patch

.vortex/installer/src/Traits/TuiTrait.php#L201

Added line #L201 was not covered by tests
$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
Loading