Skip to content

Commit

Permalink
ci(examples): test every package manager in Support Policy on basic (
Browse files Browse the repository at this point in the history
…#9593)

### Description

Recently, I updated external dependencies for the `basic` example and
tested it with pnpm. Everything looked good - but our CI _only_ tests
`basic` for pnpm. I hadn't realized that I broke one of the other
package managers.

Instead of relying on making sure that we hand-test every package
manager, let's test each one in CI.

This PR also removes a few of the examples from the test suite since we
are not maintaining them. Because they are community maintained, we
won't rely on them for our CI.

### Testing Instructions

CI 🙏

---------

Co-authored-by: Chris Olszewski <chris.olszewski@vercel.com>
  • Loading branch information
anthonyshew and chris-olszewski authored Dec 13, 2024
1 parent 59e2a3e commit 9fad9cb
Show file tree
Hide file tree
Showing 26 changed files with 80 additions and 303 deletions.
3 changes: 2 additions & 1 deletion packages/turbo-types/scripts/generate-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { createGenerator } from "ts-json-schema-generator";

const __dirname = new URL(".", import.meta.url).pathname;
const __dirname = fileURLToPath(new URL(".", import.meta.url));
const packageRoot = join(__dirname, "..", "src");

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/turbo-workspaces/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ workspacesCli
"Do not run a package manager install after conversion",
false
)
.option(
"--ignore-unchanged-package-manager",
"Prevent script failure if the package manager is unchanged",
false
)
.option("--dry", "Dry run (no changes are made to files)", false)
.option(
"--force",
Expand Down
45 changes: 25 additions & 20 deletions packages/turbo-workspaces/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,38 @@ export async function convertProject({
`Converting project from ${project.packageManager} to ${convertTo.name}.`
);

if (project.packageManager === convertTo.name) {
throw new ConvertError("You are already using this package manager", {
type: "package_manager-already_in_use",
});
}
if (!options?.ignoreUnchangedPackageManager) {
if (project.packageManager === convertTo.name) {
throw new ConvertError("You are already using this package manager", {
type: "package_manager-already_in_use",
});
}

if (!convertTo.version) {
throw new ConvertError(
`${convertTo.name} is not installed, or could not be located`,
{
type: "package_manager-could_not_be_found",
}
);
if (!convertTo.version) {
throw new ConvertError(
`${convertTo.name} is not installed, or could not be located`,
{
type: "package_manager-could_not_be_found",
}
);
}
}

// this cast is safe since we've just verified that the version exists above
const to = convertTo as AvailablePackageManagerDetails;

// remove old workspace data
await MANAGERS[project.packageManager].remove({
project,
to,
logger,
options,
});
if (!options?.ignoreUnchangedPackageManager) {
await MANAGERS[project.packageManager].remove({
project,
to,
logger,
options,
});
}

// create new workspace data
await MANAGERS[to.name].create({ project, to, logger, options });

logger.mainStep("Installing dependencies");
if (!options?.skipInstall) {
await MANAGERS[to.name].convertLock({ project, to, logger, options });
Expand All @@ -74,5 +77,7 @@ export async function convertProject({
}

logger.mainStep(`Cleaning up ${project.packageManager} workspaces`);
await MANAGERS[project.packageManager].clean({ project, logger });
if (project.packageManager !== convertTo.name) {
await MANAGERS[project.packageManager].clean({ project, logger });
}
}
1 change: 1 addition & 0 deletions packages/turbo-workspaces/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export interface Options {
dry?: boolean;
skipInstall?: boolean;
interactive?: boolean;
ignoreUnchangedPackageManager?: boolean;
}

export interface PackageManagerInstallDetails {
Expand Down
Loading

0 comments on commit 9fad9cb

Please sign in to comment.