mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
[cli] Use detectFrameworks() during vc link --repo (#10203)
Allows for multiple frameworks to be detectable within the same root directory. This is basically specifically for Storybook. <img width="700" alt="Screenshot 2023-07-12 at 6 04 37 PM" src="https://github.com/vercel/vercel/assets/71256/5a240f1e-b000-42ad-b36f-3c151d3cd449">
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { join } from 'path';
|
||||
import type { Framework } from '@vercel/frameworks';
|
||||
import { detectProjects } from '../../../../src/util/projects/detect-projects';
|
||||
|
||||
const REPO_ROOT = join(__dirname, '../../../../../..');
|
||||
@@ -8,23 +9,35 @@ const FS_DETECTORS_FIXTURES = join(
|
||||
'packages/fs-detectors/test/fixtures'
|
||||
);
|
||||
|
||||
function mapDetected(
|
||||
detected: Map<string, Framework[]>
|
||||
): Array<[string, string[]]> {
|
||||
return [...detected.entries()]
|
||||
.sort((a, b) => a[0].localeCompare(b[0]))
|
||||
.map(([dir, frameworks]) => [dir, frameworks.map(f => f.slug as string)]);
|
||||
}
|
||||
|
||||
describe('detectProjects()', () => {
|
||||
it('should match "nextjs" example', async () => {
|
||||
it('should match 1 Project in "nextjs" example', async () => {
|
||||
const dir = join(EXAMPLES_DIR, 'nextjs');
|
||||
const detected = await detectProjects(dir);
|
||||
expect([...detected.entries()]).toEqual([['', 'nextjs']]);
|
||||
expect(mapDetected(detected)).toEqual([['', ['nextjs']]]);
|
||||
});
|
||||
|
||||
it('should match 2 Projects in "storybook" example', async () => {
|
||||
const dir = join(EXAMPLES_DIR, 'storybook');
|
||||
const detected = await detectProjects(dir);
|
||||
expect(mapDetected(detected)).toEqual([['', ['nextjs', 'storybook']]]);
|
||||
});
|
||||
|
||||
it('should match "30-double-nested-workspaces"', async () => {
|
||||
const dir = join(FS_DETECTORS_FIXTURES, '30-double-nested-workspaces');
|
||||
const detected = await detectProjects(dir);
|
||||
expect(
|
||||
[...detected.entries()].sort((a, b) => a[0].localeCompare(b[0]))
|
||||
).toEqual([
|
||||
['packages/backend/c', 'remix'],
|
||||
['packages/backend/d', 'nextjs'],
|
||||
['packages/frontend/a', 'hexo'],
|
||||
['packages/frontend/b', 'ember'],
|
||||
expect(mapDetected(detected)).toEqual([
|
||||
['packages/backend/c', ['remix']],
|
||||
['packages/backend/d', ['nextjs']],
|
||||
['packages/frontend/a', ['hexo']],
|
||||
['packages/frontend/b', ['ember']],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user