diff --git a/.vortex/installer/src/Prompts/Handlers/Theme.php b/.vortex/installer/src/Prompts/Handlers/Theme.php index b66b20e5a..14dcef8c3 100644 --- a/.vortex/installer/src/Prompts/Handlers/Theme.php +++ b/.vortex/installer/src/Prompts/Handlers/Theme.php @@ -172,9 +172,6 @@ public function process(): void { $file_tmpl = static::findThemeFile($t, $w); if (!empty($file_tmpl) && is_readable($file_tmpl)) { File::remove(dirname($file_tmpl)); - - File::removeLineInFile($t . '/phpunit.xml', 'web/themes/custom'); - File::removeLineInFile($t . '/phpunit.xml', 'web/themes/custom/*/node_modules'); } } diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/.env b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/.env new file mode 100644 index 000000000..87210e92f --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/.env @@ -0,0 +1,9 @@ +@@ -160,7 +160,7 @@ + # Database dump file sourced from a URL. + # + # HTTP Basic Authentication credentials should be embedded into the value. +-VORTEX_DOWNLOAD_DB_URL= ++VORTEX_DOWNLOAD_DB_URL=https://github.com/drevops/vortex/releases/download/__VERSION__/db_d11.demo.sql + + # Environment to download the database from. + # diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.eslintrc.json b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.eslintrc.json new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.gitignore b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.npmrc b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.npmrc new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.prettierignore b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.prettierignore new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.prettierrc.json b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.prettierrc.json new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.stylelintrc.json b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-.stylelintrc.json new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-README.md b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-README.md new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-logo.svg b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-logo.svg new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-postcss.config.js b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-postcss.config.js new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-star_wars.libraries.yml b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-star_wars.libraries.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-star_wars.theme b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/-star_wars.theme new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/fonts/-.gitkeep b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/fonts/-.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/images/-.gitkeep b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/images/-.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/js/-star_wars.js b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/js/-star_wars.js new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/package.json b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/package.json new file mode 100644 index 000000000..a720e7be6 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/package.json @@ -0,0 +1,59 @@ +@@ -1,57 +1 @@ +-{ +- "name": "star_wars", +- "version": "__VERSION__", +- "private": true, +- "description": "NodeJS dependencies for star wars project", +- "devDependencies": { +- "@homer0/prettier-plugin-jsdoc": "__VERSION__", +- "autoprefixer": "__VERSION__", +- "chokidar-cli": "__VERSION__", +- "eslint": "__VERSION__", +- "eslint-config-airbnb-base": "__VERSION__", +- "eslint-config-prettier": "__VERSION__", +- "eslint-plugin-import": "__VERSION__", +- "eslint-plugin-jsdoc": "__VERSION__", +- "eslint-plugin-no-jquery": "__VERSION__", +- "eslint-plugin-prettier": "__VERSION__", +- "eslint-plugin-yml": "__VERSION__", +- "patch-package": "__VERSION__", +- "postcss": "__VERSION__", +- "postcss-cli": "__VERSION__", +- "prettier": "__VERSION__", +- "sass": "__VERSION__", +- "stylelint": "__VERSION__", +- "stylelint-config-standard": "__VERSION__", +- "stylelint-config-standard-scss": "__VERSION__", +- "stylelint-order": "__VERSION__", +- "stylelint-scss": "__VERSION__", +- "terser": "__VERSION__" +- }, +- "browserslist": [ +- "last 2 versions", +- "not ie <= 8", +- "iOS >= 7" +- ], +- "scripts": { +- "build": "npm run clean && mkdir -p build/js && npm run concat && npm run uglify && npm run sass:prod && npm run postcss:prod && npm run copy", +- "build-dev": "npm run clean && mkdir -p build/js && npm run concat && npm run sass:dev && npm run postcss:dev && npm run copy", +- "clean": "rm -rf build", +- "concat": "find js -name '*.js' ! -name '*.min.js' -exec cat {} + > build/js/star_wars.min.js", +- "copy": "npm run copy:images && npm run copy:fonts", +- "copy:fonts": "mkdir -p build/fonts && cp -r fonts/* build/fonts/ 2>/dev/null || true", +- "copy:images": "mkdir -p build/images && cp -r images/* build/images/ 2>/dev/null || true", +- "lint": "npm run lint-js && npm run lint-css", +- "lint-css": "stylelint 'scss/**/*.scss'", +- "lint-css-fix": "stylelint 'scss/**/*.scss' --fix", +- "lint-fix": "npm run lint-js-fix && npm run lint-css-fix", +- "lint-js": "eslint 'js/**/*.js' --ignore-pattern '*.min.js'", +- "lint-js-fix": "eslint 'js/**/*.js' --ignore-pattern '*.min.js' --fix", +- "postcss:dev": "postcss build/css/star_wars.min.css -o build/css/star_wars.min.css --map", +- "postcss:prod": "postcss build/css/star_wars.min.css -o build/css/star_wars.min.css --no-map", +- "postinstall": "patch-package", +- "sass:dev": "sass scss/styles.scss build/css/star_wars.min.css --source-map --style=expanded", +- "sass:prod": "sass scss/styles.scss build/css/star_wars.min.css --no-source-map --style=compressed", +- "uglify": "terser build/js/star_wars.min.js -o build/js/star_wars.min.js -c drop_console=true -m reserved=['jQuery','Drupal'] 2>/dev/null || true", +- "watch": "chokidar 'js/**/*.js' 'scss/**/*.scss' -c 'npm run build-dev'" +- } +-} ++{"name": "star_wars_custom"} diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/patches/-.gitkeep b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/patches/-.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-_components.scss b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-_components.scss new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-_fonts.scss b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-_fonts.scss new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-_mixins.scss b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-_mixins.scss new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-_rem.scss b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-_rem.scss new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-_variables.scss b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-_variables.scss new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-styles.scss b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/-styles.scss new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/components/-_header.scss b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/scss/components/-_header.scss new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/star_wars.info.yml b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/star_wars.info.yml new file mode 100644 index 000000000..71b9585df --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/star_wars.info.yml @@ -0,0 +1,25 @@ +@@ -1,23 +1,3 @@ +-name: star_wars ++name: Star Wars Custom + type: theme +-description: 'star wars theme.' + core_version_requirement: ^11 +-base theme: olivero +- +-libraries: +- - star_wars/global-styling +- +-regions: +- header: Header +- primary_menu: 'Primary menu' +- secondary_menu: 'Secondary menu' +- hero: 'Hero (full width)' +- highlighted: Highlighted +- breadcrumb: Breadcrumb +- social: Social Bar +- content_above: Content Above +- content: Content +- sidebar: 'Sidebar' +- content_below: 'Content Below' +- footer_top: 'Footer Top' +- footer_bottom: 'Footer Bottom' diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/styles.css b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/styles.css new file mode 100644 index 000000000..fe90f70dd --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/styles.css @@ -0,0 +1 @@ +.star-wars { color: blue; } diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Functional/-ExampleTest.php b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Functional/-ExampleTest.php new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Functional/-StarWarsFunctionalTestBase.php b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Functional/-StarWarsFunctionalTestBase.php new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/FunctionalJavascript/-ExampleTest.php b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/FunctionalJavascript/-ExampleTest.php new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/FunctionalJavascript/-StarWarsFunctionalJavascriptTestBase.php b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/FunctionalJavascript/-StarWarsFunctionalJavascriptTestBase.php new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Kernel/-ExampleTest.php b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Kernel/-ExampleTest.php new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Kernel/-StarWarsKernelTestBase.php b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Kernel/-StarWarsKernelTestBase.php new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Unit/-ExampleTest.php b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Unit/-ExampleTest.php new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Unit/-StarWarsUnitTestBase.php b/.vortex/installer/tests/Fixtures/handler_process/theme_custom_non_vortex/web/themes/custom/star_wars/tests/src/Unit/-StarWarsUnitTestBase.php new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Functional/Handlers/ThemeHandlerProcessTest.php b/.vortex/installer/tests/Functional/Handlers/ThemeHandlerProcessTest.php index e5a535880..78f6abc1c 100644 --- a/.vortex/installer/tests/Functional/Handlers/ThemeHandlerProcessTest.php +++ b/.vortex/installer/tests/Functional/Handlers/ThemeHandlerProcessTest.php @@ -7,6 +7,7 @@ use DrevOps\VortexInstaller\Prompts\Handlers\Theme; use DrevOps\VortexInstaller\Tests\Functional\FunctionalTestCase; use DrevOps\VortexInstaller\Utils\Env; +use DrevOps\VortexInstaller\Utils\File; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(Theme::class)] @@ -47,6 +48,38 @@ public static function dataProviderHandlerProcess(): \Iterator { static::cw(fn() => Env::put(Theme::envName(), 'light_saber')), static::cw(fn(FunctionalTestCase $test) => $test->assertDirectoryNotContainsString(static::$sut, 'your_site_theme')), ]; + yield 'theme_custom_non_vortex' => [ + static::cw(function (FunctionalTestCase $test): void { + Env::put(Theme::envName(), 'star_wars'); + + // Run a first install to create a proper Vortex project + // with a Vortex-sourced custom theme. + $test->runNonInteractiveInstall(); + + $theme_dir = static::$sut . '/web/themes/custom/star_wars'; + $test->assertFilesExist($theme_dir, ['star_wars.theme'], 'Vortex template theme files should be present'); + + // Replace the Vortex-installed theme files with custom + // non-Vortex theme files (simulating a project that replaced the + // Vortex theme scaffold with their own). + File::remove($theme_dir); + File::mkdir($theme_dir); + File::dump($theme_dir . '/star_wars.info.yml', 'name: Star Wars Custom' . PHP_EOL . 'type: theme' . PHP_EOL . 'core_version_requirement: ^11' . PHP_EOL); + File::dump($theme_dir . '/package.json', '{"name": "star_wars_custom"}' . PHP_EOL); + File::dump($theme_dir . '/styles.css', '.star-wars { color: blue; }' . PHP_EOL); + }), + static::cw(function (FunctionalTestCase $test): void { + // The project's own theme files must be preserved unchanged — + // Vortex must not overwrite them with its template theme files. + $theme_dir = static::$sut . '/web/themes/custom/star_wars'; + $test->assertDirectoryExists($theme_dir); + $test->assertStringEqualsFile($theme_dir . '/star_wars.info.yml', 'name: Star Wars Custom' . PHP_EOL . 'type: theme' . PHP_EOL . 'core_version_requirement: ^11' . PHP_EOL); + $test->assertStringEqualsFile($theme_dir . '/package.json', '{"name": "star_wars_custom"}' . PHP_EOL); + $test->assertStringEqualsFile($theme_dir . '/styles.css', '.star-wars { color: blue; }' . PHP_EOL); + + $test->assertFilesDoNotExist($theme_dir, ['star_wars.theme'], 'Vortex template theme files should not be present'); + }), + ]; } }