mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 12:57:46 +00:00
[examples][frameworks] add tests for all examples being detected (#9197)
This PR adds tests (under `packages/fs-detectors`) that ensure are `./examples` get detected as the appropriate framework.
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-auto": "next",
|
"@sveltejs/adapter-auto": "next",
|
||||||
"@sveltejs/kit": "next",
|
"@sveltejs/kit": "1.0.0-next.589",
|
||||||
"@types/cookie": "^0.5.1",
|
"@types/cookie": "^0.5.1",
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"prettier-plugin-svelte": "^2.7.0",
|
"prettier-plugin-svelte": "^2.7.0",
|
||||||
|
|||||||
@@ -954,6 +954,7 @@ export const frameworks = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// TODO: fix detected as "sveltekit-1"
|
||||||
name: 'SvelteKit (Legacy Beta)',
|
name: 'SvelteKit (Legacy Beta)',
|
||||||
slug: 'sveltekit',
|
slug: 'sveltekit',
|
||||||
demo: 'https://sveltekit-template.vercel.app',
|
demo: 'https://sveltekit-template.vercel.app',
|
||||||
@@ -1671,6 +1672,44 @@ export const frameworks = [
|
|||||||
getOutputDirName: async () => 'public',
|
getOutputDirName: async () => 'public',
|
||||||
defaultVersion: '0.13.0', // Must match the build image
|
defaultVersion: '0.13.0', // Must match the build image
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Hydrogen',
|
||||||
|
slug: 'hydrogen',
|
||||||
|
demo: 'https://hydrogen-template.vercel.app',
|
||||||
|
logo: 'https://api-frameworks.vercel.sh/framework-logos/hydrogen.svg',
|
||||||
|
tagline: 'React framework for headless commerce',
|
||||||
|
description: 'React framework for headless commerce',
|
||||||
|
website: 'https://hydrogen.shopify.dev',
|
||||||
|
useRuntime: { src: 'package.json', use: '@vercel/hydrogen' },
|
||||||
|
detectors: {
|
||||||
|
some: [
|
||||||
|
{
|
||||||
|
path: 'hydrogen.config.js',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'hydrogen.config.ts',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
installCommand: {
|
||||||
|
placeholder: '`yarn install`, `pnpm install`, or `npm install`',
|
||||||
|
},
|
||||||
|
buildCommand: {
|
||||||
|
value: 'shopify hydrogen build',
|
||||||
|
placeholder: '`npm run build` or `shopify hydrogen build`',
|
||||||
|
},
|
||||||
|
devCommand: {
|
||||||
|
value: 'shopify hydrogen dev',
|
||||||
|
placeholder: 'shopify hydrogen dev',
|
||||||
|
},
|
||||||
|
outputDirectory: {
|
||||||
|
value: 'dist',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependency: '@shopify/hydrogen',
|
||||||
|
getOutputDirName: async () => 'dist',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Vite',
|
name: 'Vite',
|
||||||
slug: 'vite',
|
slug: 'vite',
|
||||||
@@ -1871,44 +1910,6 @@ export const frameworks = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'Hydrogen',
|
|
||||||
slug: 'hydrogen',
|
|
||||||
demo: 'https://hydrogen-template.vercel.app',
|
|
||||||
logo: 'https://api-frameworks.vercel.sh/framework-logos/hydrogen.svg',
|
|
||||||
tagline: 'React framework for headless commerce',
|
|
||||||
description: 'React framework for headless commerce',
|
|
||||||
website: 'https://hydrogen.shopify.dev',
|
|
||||||
useRuntime: { src: 'package.json', use: '@vercel/hydrogen' },
|
|
||||||
detectors: {
|
|
||||||
some: [
|
|
||||||
{
|
|
||||||
path: 'hydrogen.config.js',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'hydrogen.config.ts',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
installCommand: {
|
|
||||||
placeholder: '`yarn install`, `pnpm install`, or `npm install`',
|
|
||||||
},
|
|
||||||
buildCommand: {
|
|
||||||
value: 'shopify hydrogen build',
|
|
||||||
placeholder: '`npm run build` or `shopify hydrogen build`',
|
|
||||||
},
|
|
||||||
devCommand: {
|
|
||||||
value: 'shopify hydrogen dev',
|
|
||||||
placeholder: 'shopify hydrogen dev',
|
|
||||||
},
|
|
||||||
outputDirectory: {
|
|
||||||
value: 'dist',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
dependency: '@shopify/hydrogen',
|
|
||||||
getOutputDirName: async () => 'dist',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'Other',
|
name: 'Other',
|
||||||
slug: null,
|
slug: null,
|
||||||
|
|||||||
35
packages/fs-detectors/test/unit.examples.test.ts
vendored
Normal file
35
packages/fs-detectors/test/unit.examples.test.ts
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import frameworkList from '@vercel/frameworks';
|
||||||
|
import { detectFramework } from '../src';
|
||||||
|
import { FixtureFilesystem } from './utils/fixture-filesystem';
|
||||||
|
import { readdirSync, lstatSync } from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
function getExamples() {
|
||||||
|
const root = join(__dirname, '..', '..', '..');
|
||||||
|
const examplesPath = join(root, 'examples');
|
||||||
|
const examples = readdirSync(examplesPath);
|
||||||
|
|
||||||
|
const exampleDirs = examples.filter(example => {
|
||||||
|
const examplePath = join(examplesPath, example);
|
||||||
|
const stat = lstatSync(examplePath);
|
||||||
|
return stat.isDirectory();
|
||||||
|
});
|
||||||
|
|
||||||
|
return exampleDirs.map(exampleDirName => {
|
||||||
|
return [exampleDirName, join(examplesPath, exampleDirName)];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('examples should be detected', () => {
|
||||||
|
const examples = getExamples();
|
||||||
|
|
||||||
|
it.each(examples)('%s', async (example, examplePath) => {
|
||||||
|
const fs = new FixtureFilesystem(examplePath);
|
||||||
|
const framework = await detectFramework({ fs, frameworkList });
|
||||||
|
if (!framework) {
|
||||||
|
throw new Error(`Framework not detected for example "${example}".`);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(framework).toBe(example);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user