Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a hint about available package managers in --help, add test that covers using npm in case of typo. #9236

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Expand Up @@ -671,3 +671,4 @@
- zainfathoni
- zayenz
- zhe
- mic-sob
32 changes: 31 additions & 1 deletion packages/create-remix/__tests__/create-remix-test.ts
Expand Up @@ -82,7 +82,7 @@ describe("create-remix CLI", () => {

--template <name> The project template to use
--[no-]install Whether or not to install dependencies after creation
--package-manager The package manager to use
--package-manager The package manager to use (npm, pnpm, yarn, bun)
--show-install-output Whether to show the output of the install process
--[no-]init-script Whether or not to run the template's remix.init script, if present
--[no-]git-init Whether or not to initialize a Git repository
Expand Down Expand Up @@ -900,6 +900,36 @@ describe("create-remix CLI", () => {
process.env.npm_config_user_agent = originalUserAgent;
});

it("uses npm when package manager is unknown", async () => {
let projectDir = getProjectDir("pnpm-create-override");

let execa = require("execa");
execa.mockImplementation(async () => {});

// Suppress terminal output
let stdoutMock = jest
.spyOn(process.stdout, "write")
.mockImplementation(() => true);

await createRemix([
projectDir,
"--template",
path.join(__dirname, "fixtures", "blank"),
"--no-git-init",
"--yes",
"--package-manager",
"notSupportedPackageManagerOrTypo",
]);

stdoutMock.mockReset();

expect(execa).toHaveBeenCalledWith(
"npm",
expect.arrayContaining(["install"]),
expect.anything()
);
});

it("works when creating an app in the current dir", async () => {
let emptyDir = getProjectDir("current-dir-if-empty");
fse.mkdirSync(emptyDir);
Expand Down
2 changes: 1 addition & 1 deletion packages/create-remix/index.ts
Expand Up @@ -782,7 +782,7 @@ ${color.arg("--no-motion")} ${color.dim(`Disable animations in console o

${color.arg("--template <name>")} ${color.dim(`The project template to use`)}
${color.arg("--[no-]install")} ${color.dim(`Whether or not to install dependencies after creation`)}
${color.arg("--package-manager")} ${color.dim(`The package manager to use`)}
${color.arg("--package-manager")} ${color.dim(`The package manager to use (npm, pnpm, yarn, bun)`)}
${color.arg("--show-install-output")} ${color.dim(`Whether to show the output of the install process`)}
${color.arg("--[no-]init-script")} ${color.dim(`Whether or not to run the template's remix.init script, if present`)}
${color.arg("--[no-]git-init")} ${color.dim(`Whether or not to initialize a Git repository`)}
Expand Down