mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 12:57:47 +00:00
[fs-detectors] getMonorepoDefaultSettings: Fix settings (#9315)
1. `commandForIgnoringBuildStep` should be run at the project directory level not the monorepo root level 2. Simplifying the `installCommand` because doesn't need the relative root unless it is `npm`
This commit is contained in:
@@ -1229,13 +1229,13 @@ describe('build', () => {
|
|||||||
turbo: {
|
turbo: {
|
||||||
name: 'Turbo',
|
name: 'Turbo',
|
||||||
buildCommand: 'cd ../.. && npx turbo run build --filter=app-1...',
|
buildCommand: 'cd ../.. && npx turbo run build --filter=app-1...',
|
||||||
installCommand: 'cd ../.. && yarn install',
|
installCommand: 'yarn install',
|
||||||
ignoreCommand: 'cd ../.. && npx turbo-ignore',
|
ignoreCommand: 'npx turbo-ignore',
|
||||||
},
|
},
|
||||||
nx: {
|
nx: {
|
||||||
name: 'Nx',
|
name: 'Nx',
|
||||||
buildCommand: 'cd ../.. && npx nx build app-1',
|
buildCommand: 'cd ../.. && npx nx build app-1',
|
||||||
installCommand: 'cd ../.. && yarn install',
|
installCommand: 'yarn install',
|
||||||
},
|
},
|
||||||
// rush: {
|
// rush: {
|
||||||
// name: 'Rush',
|
// name: 'Rush',
|
||||||
|
|||||||
@@ -67,8 +67,11 @@ export async function getMonorepoDefaultSettings(
|
|||||||
return {
|
return {
|
||||||
monorepoManager: 'turbo',
|
monorepoManager: 'turbo',
|
||||||
buildCommand: `cd ${relativeToRoot} && npx turbo run build --filter={${projectPath}}...`,
|
buildCommand: `cd ${relativeToRoot} && npx turbo run build --filter={${projectPath}}...`,
|
||||||
installCommand: `cd ${relativeToRoot} && ${packageManager} install`,
|
installCommand:
|
||||||
commandForIgnoringBuildStep: `cd ${relativeToRoot} && npx turbo-ignore`,
|
packageManager === 'npm'
|
||||||
|
? `${packageManager} install --prefix=${relativeToRoot}`
|
||||||
|
: `${packageManager} install`,
|
||||||
|
commandForIgnoringBuildStep: `npx turbo-ignore`,
|
||||||
};
|
};
|
||||||
} else if (monorepoManager === 'nx') {
|
} else if (monorepoManager === 'nx') {
|
||||||
// No ENOENT handling required here since conditional wouldn't be `true` unless `nx.json` was found.
|
// No ENOENT handling required here since conditional wouldn't be `true` unless `nx.json` was found.
|
||||||
@@ -111,7 +114,10 @@ export async function getMonorepoDefaultSettings(
|
|||||||
return {
|
return {
|
||||||
monorepoManager: 'nx',
|
monorepoManager: 'nx',
|
||||||
buildCommand: `cd ${relativeToRoot} && npx nx build ${projectName}`,
|
buildCommand: `cd ${relativeToRoot} && npx nx build ${projectName}`,
|
||||||
installCommand: `cd ${relativeToRoot} && ${packageManager} install`,
|
installCommand:
|
||||||
|
packageManager === 'npm'
|
||||||
|
? `${packageManager} install --prefix=${relativeToRoot}`
|
||||||
|
: `${packageManager} install`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// TODO (@Ethan-Arrowood) - Revisit rush support when we can test it better
|
// TODO (@Ethan-Arrowood) - Revisit rush support when we can test it better
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "app-1",
|
"name": "app-11",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"nx": {
|
"nx": {
|
||||||
"targets": {
|
"targets": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "app-1",
|
"name": "app-10",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"nx": {
|
"nx": {
|
||||||
"targets": {}
|
"targets": {}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "app-1",
|
"name": "app-9",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"nx": {
|
"nx": {
|
||||||
"targets": {
|
"targets": {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"name": "app-1",
|
"name": "app-8",
|
||||||
"version": "0.0.1"
|
"version": "0.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"name": "app-1",
|
"name": "app-12",
|
||||||
"version": "0.0.1"
|
"version": "0.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
1
packages/fs-detectors/test/fixtures/get-monorepo-default-settings/turbo-npm/package-lock.json
generated
vendored
Normal file
1
packages/fs-detectors/test/fixtures/get-monorepo-default-settings/turbo-npm/package-lock.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
9
packages/fs-detectors/test/fixtures/get-monorepo-default-settings/turbo-npm/package.json
vendored
Normal file
9
packages/fs-detectors/test/fixtures/get-monorepo-default-settings/turbo-npm/package.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"workspaces": [
|
||||||
|
"packages/*"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"turbo": "1.6.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"name": "app-15",
|
||||||
|
"version": "0.0.1"
|
||||||
|
}
|
||||||
1
packages/fs-detectors/test/fixtures/get-monorepo-default-settings/turbo-npm/turbo.json
vendored
Normal file
1
packages/fs-detectors/test/fixtures/get-monorepo-default-settings/turbo-npm/turbo.json
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{ "pipeline": { "build": { "dependsOn": ["^build"], "outputs": ["dist/**"] } } }
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"name": "app-1",
|
"name": "app-13",
|
||||||
"version": "0.0.1"
|
"version": "0.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"name": "app-1",
|
"name": "app-14",
|
||||||
"version": "0.0.1"
|
"version": "0.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,26 +26,27 @@ describe('getMonorepoDefaultSettings', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test.each([
|
test.each([
|
||||||
['turbo', 'turbo'],
|
['turbo', 'turbo', false, 'app-14'],
|
||||||
['turbo-package-config', 'turbo'],
|
['turbo-package-config', 'turbo', false, 'app-13'],
|
||||||
['nx', 'nx'],
|
['turbo-npm', 'turbo', true, 'app-15'],
|
||||||
['nx-package-config', 'nx'],
|
['nx', 'nx', false, 'app-12'],
|
||||||
['nx-project-and-package-config-1', 'nx'],
|
['nx-package-config', 'nx', false, 'app-11'],
|
||||||
['nx-project-and-package-config-2', 'nx'],
|
['nx-project-and-package-config-1', 'nx', false, 'app-10'],
|
||||||
['nx-project-config', 'nx'],
|
['nx-project-and-package-config-2', 'nx', false, 'app-9'],
|
||||||
])('fixture %s', async (fixture, expectedResultKey) => {
|
['nx-project-config', 'nx', false, 'app-8'],
|
||||||
|
])('fixture %s', async (fixture, expectedResultKey, isNpm, packageName) => {
|
||||||
const expectedResultMap: Record<string, Record<string, string>> = {
|
const expectedResultMap: Record<string, Record<string, string>> = {
|
||||||
turbo: {
|
turbo: {
|
||||||
monorepoManager: 'turbo',
|
monorepoManager: 'turbo',
|
||||||
buildCommand:
|
buildCommand:
|
||||||
'cd ../.. && npx turbo run build --filter={packages/app-1}...',
|
'cd ../.. && npx turbo run build --filter={packages/app-1}...',
|
||||||
installCommand: 'cd ../.. && yarn install',
|
installCommand: isNpm ? 'npm install --prefix=../..' : 'yarn install',
|
||||||
commandForIgnoringBuildStep: 'cd ../.. && npx turbo-ignore',
|
commandForIgnoringBuildStep: 'npx turbo-ignore',
|
||||||
},
|
},
|
||||||
nx: {
|
nx: {
|
||||||
monorepoManager: 'nx',
|
monorepoManager: 'nx',
|
||||||
buildCommand: 'cd ../.. && npx nx build app-1',
|
buildCommand: `cd ../.. && npx nx build ${packageName}`,
|
||||||
installCommand: 'cd ../.. && yarn install',
|
installCommand: 'yarn install',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ describe('getMonorepoDefaultSettings', () => {
|
|||||||
path.join(__dirname, 'fixtures', 'get-monorepo-default-settings', fixture)
|
path.join(__dirname, 'fixtures', 'get-monorepo-default-settings', fixture)
|
||||||
);
|
);
|
||||||
const result = await getMonorepoDefaultSettings(
|
const result = await getMonorepoDefaultSettings(
|
||||||
'app-1',
|
packageName,
|
||||||
'packages/app-1',
|
'packages/app-1',
|
||||||
'../..',
|
'../..',
|
||||||
ffs
|
ffs
|
||||||
|
|||||||
Reference in New Issue
Block a user