From 788f927d01d08a3609e74fce47164e57cf46fca8 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Tue, 11 Mar 2025 18:22:40 +0530 Subject: [PATCH] Add Analog and Angular detection --- README.md | 6 ++-- src/Detection/Framework/Analog.php | 44 +++++++++++++++++++++++++++++ src/Detection/Framework/Angular.php | 44 +++++++++++++++++++++++++++++ src/Detection/Rendering/SSR.php | 2 ++ tests/unit/DetectorTest.php | 9 +++++- 5 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 src/Detection/Framework/Analog.php create mode 100644 src/Detection/Framework/Angular.php diff --git a/README.md b/README.md index fede201..3f2ef88 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,8 @@ $detector ->addOption(new Flutter()) ->addOption(new Nuxt()) ->addOption(new Astro()) + ->addOption(new Analog()) + ->addOption(new Angular()) ->addOption(new Remix()) ->addOption(new SvelteKit()) ->addOption(new NextJs()); @@ -126,8 +128,8 @@ Framework Adapters: | Nuxt | ✅ | | Remix | ✅ | | SvelteKit | ✅ | -| Angular | 🛠 | -| Analog | 🛠 | +| Angular | ✅ | +| Analog | ✅ | Packager Adapters: diff --git a/src/Detection/Framework/Analog.php b/src/Detection/Framework/Analog.php new file mode 100644 index 0000000..4900c96 --- /dev/null +++ b/src/Detection/Framework/Analog.php @@ -0,0 +1,44 @@ + + */ + public function getFiles(): array + { + return ['vite.config.js', 'vite.config.ts', 'angular.json']; + } + + public function getInstallCommand(): string + { + return match ($this->packager) { + 'yarn' => 'yarn install', + 'pnpm' => 'pnpm install', + default => 'npm install', + }; + } + + public function getBuildCommand(): string + { + return match ($this->packager) { + 'yarn' => 'yarn build', + 'pnpm' => 'pnpm build', + default => 'npm run build', + }; + } + + public function getOutputDirectory(): string + { + return './dist/analog'; + } +} diff --git a/src/Detection/Framework/Angular.php b/src/Detection/Framework/Angular.php new file mode 100644 index 0000000..49fa032 --- /dev/null +++ b/src/Detection/Framework/Angular.php @@ -0,0 +1,44 @@ + + */ + public function getFiles(): array + { + return ['angular.json']; + } + + public function getInstallCommand(): string + { + return match ($this->packager) { + 'yarn' => 'yarn install', + 'pnpm' => 'pnpm install', + default => 'npm install', + }; + } + + public function getBuildCommand(): string + { + return match ($this->packager) { + 'yarn' => 'yarn build', + 'pnpm' => 'pnpm build', + default => 'npm run build', + }; + } + + public function getOutputDirectory(): string + { + return './dist/angular'; + } +} diff --git a/src/Detection/Rendering/SSR.php b/src/Detection/Rendering/SSR.php index be1def1..e4be83d 100644 --- a/src/Detection/Rendering/SSR.php +++ b/src/Detection/Rendering/SSR.php @@ -12,6 +12,8 @@ class SSR extends Rendering 'sveltekit' => ['handler.js'], 'astro' => ['server/entry.mjs'], 'remix' => ['build/server/index.js'], + 'angular' => ['server/server.mjs'], + 'analog' => ['server/index.mjs'], 'flutter' => [], ]; diff --git a/tests/unit/DetectorTest.php b/tests/unit/DetectorTest.php index 6478832..d8dc2eb 100644 --- a/tests/unit/DetectorTest.php +++ b/tests/unit/DetectorTest.php @@ -3,6 +3,8 @@ namespace Utopia\Tests; use PHPUnit\Framework\TestCase; +use Utopia\Detector\Detection\Framework\Analog; +use Utopia\Detector\Detection\Framework\Angular; use Utopia\Detector\Detection\Framework\Astro; use Utopia\Detector\Detection\Framework\Flutter; use Utopia\Detector\Detection\Framework\NextJs; @@ -259,7 +261,9 @@ public function testFrameworkDetection(array $files, ?string $framework, ?string ->addOption(new Astro()) ->addOption(new Remix()) ->addOption(new SvelteKit()) - ->addOption(new NextJs()); + ->addOption(new NextJs()) + ->addOption(new Angular()) + ->addOption(new Analog()); $detectedFramework = $detector->detect(); @@ -283,6 +287,7 @@ public function frameworkDataProvider(): array [['src', 'types', 'makefile', 'components.js', 'debug.js', 'package.json', 'svelte.config.js'], 'sveltekit', 'npm install', 'npm run build', './build'], [['app', 'backend', 'public', 'Dockerfile', 'docker-compose.yml', 'ecosystem.config.js', 'middleware.ts', 'next.config.js', 'package-lock.json', 'package.json', 'server.js', 'tsconfig.json'], 'nextjs', 'npm install', 'npm run build', './.next'], [['assets', 'components', 'layouts', 'pages', 'babel.config.js', 'error.vue', 'nuxt.config.js', 'yarn.lock'], 'nuxt', 'npm install', 'npm run build', './output'], + [['src', 'package.json', 'tsconfig.json', 'angular.json', 'logo.png'], 'angular', 'npm install', 'npm run build', './dist/angular'], [['app', 'public', 'remix.config.js', 'remix.env.d.ts', 'sandbox.config.js', 'tsconfig.json', 'package.json'], 'remix', 'npm install', 'npm run build', './build'], [['public', 'src', 'astro.config.mjs', 'package-lock.json', 'package.json', 'tsconfig.json'], 'astro', 'npm install', 'npm run build', './dist'], [['src', 'static', 'scripts', 'eslint.config.js', 'package.json', 'pnpm-lock.yaml', 'svelte.config.js', 'tsconfig.js', 'vite.config.js', 'vite.config.lib.js'], 'sveltekit', 'npm install', 'npm run build', './build'], @@ -320,6 +325,8 @@ public function renderingDataProvider(): array [['server/pages/index.html', 'server/pages/api/users.js', '.next/server/pages/_app.js'], 'nextjs', 'ssr', null], [['index.html', 'about.html', '404.html'], 'nextjs', 'static', null], [['nitro.json', 'server/index.mjs'], 'nuxt', 'ssr', null], + [['server/server.mjs'], 'angular', 'ssr', null], + [['server/index.mjs'], 'analog', 'ssr', null], [['index.html', '_nuxt/something.js'], 'nuxt', 'static', 'index.html'], [['server/pages/index.js', 'prerendered/about.html', 'handler.js'], 'sveltekit', 'ssr', null], [['index.html', 'about.html'], 'sveltekit', 'static', null],