mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
### Related Issues https://nx.dev/more-concepts/folder-structure#integrated-repo-folder-structure Nx monorepo has an option to use Nx workspaces. Nx workspace is defined within the root `workspace.json` file Within this `workspace.json` file the workspace packages are under projects ```{ "$schema": "./node_modules/nx/schemas/workspace-schema.json", "version": 2, "projects": { "myblog": "apps/myblog", "svelte-app": "apps/svelte-app", } } ``` Within `getNxWorkspacePackagePaths` get the projects object values for the paths Nx is listed as the last workspace manager within `workspace-managers.ts` because other workspace managers could exist to check for before Nx workspaces because the `workspace.json` could exist but not be the correct workspace manager Nx workspace file can exist when yarn/npm workspaces exist. When this happens, the workspace.json file is empty with no projects so it will not add any package paths to the list to look through for projects. ### 📋 Checklist <!-- Please keep your PR as a Draft until the checklist is complete --> #### Tests - [ ] The code changed/added as part of this PR has been covered with tests - [ ] All tests pass locally with `yarn test-unit` #### Code Review - [ ] This PR has a concise title and thorough description useful to a reviewer - [ ] Issue from task tracker has a link to this PR
66 lines
1.8 KiB
TypeScript
Vendored
66 lines
1.8 KiB
TypeScript
Vendored
import path from 'path';
|
|
import fs from 'fs-extra';
|
|
import {
|
|
testDeployment,
|
|
// @ts-ignore
|
|
} from '../../../test/lib/deployment/test-deployment';
|
|
|
|
jest.setTimeout(4 * 60 * 1000);
|
|
|
|
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
|
|
|
// Fixtures that have separate tests and should be skipped in the loop
|
|
const skipFixtures: string[] = [
|
|
'01-zero-config-api',
|
|
'02-zero-config-api',
|
|
'03-zero-config-angular',
|
|
'04-zero-config-brunch',
|
|
'05-zero-config-gatsby',
|
|
'06-zero-config-hugo',
|
|
'07-zero-config-jekyll',
|
|
'08-zero-config-middleman',
|
|
'21-npm-workspaces',
|
|
'23-pnpm-workspaces',
|
|
'41-nx-monorepo',
|
|
'42-npm-workspace-with-nx',
|
|
];
|
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
for (const fixture of fs.readdirSync(fixturesPath)) {
|
|
if (skipFixtures.includes(fixture)) {
|
|
continue; // eslint-disable-line no-continue
|
|
}
|
|
|
|
// eslint-disable-next-line no-loop-func
|
|
it(`Should build "${fixture}"`, async () => {
|
|
await expect(
|
|
testDeployment(path.join(fixturesPath, fixture))
|
|
).resolves.toBeDefined();
|
|
});
|
|
}
|
|
|
|
// few foreign tests
|
|
|
|
const buildersToTestWith = ['node'];
|
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
for (const builder of buildersToTestWith) {
|
|
const fixturesPath2 = path.resolve(
|
|
__dirname,
|
|
`../../${builder}/test/fixtures`
|
|
);
|
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
for (const fixture of fs.readdirSync(fixturesPath2)) {
|
|
// don't run all foreign fixtures, just some
|
|
if (['01-cowsay', '01-cache-headers', '03-env-vars'].includes(fixture)) {
|
|
// eslint-disable-next-line no-loop-func
|
|
it(`Should build "${builder}/${fixture}"`, async () => {
|
|
await expect(
|
|
testDeployment(path.join(fixturesPath2, fixture))
|
|
).resolves.toBeDefined();
|
|
});
|
|
}
|
|
}
|
|
}
|