Skip to content

Commit

Permalink
fix(create-remix): only update "*" versions for Remix dependencies (#…
Browse files Browse the repository at this point in the history
…8458)

Co-authored-by: Mark Dalgleish <mark.john.dalgleish@gmail.com>
  • Loading branch information
ahuth and markdalgleish authored Jan 9, 2024
1 parent 40b20c1 commit 579f8e1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-suits-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-remix": patch
---

Only update `*` versions for Remix dependencies
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- ahabhgk
- ahbruns
- ahmedeldessouki
- ahuth
- aiji42
- airjp73
- airondumael
Expand Down
26 changes: 26 additions & 0 deletions packages/create-remix/__tests__/create-remix-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,32 @@ describe("create-remix CLI", () => {
}
});

it("changes star dependencies for only Remix packages", async () => {
let projectDir = getProjectDir("local-directory");

let { status } = await execCreateRemix({
args: [
projectDir,
"--template",
path.join(__dirname, "fixtures", "stack"),
"--no-git-init",
"--no-install",
],
});

expect(status).toBe(0);

let packageJsonPath = path.join(projectDir, "package.json");
let packageJson = JSON.parse(String(fse.readFileSync(packageJsonPath)));
let dependencies = packageJson.dependencies;

expect(dependencies).toMatchObject({
"@remix-run/react": expect.any(String),
remix: expect.any(String),
"not-remix": "*",
});
});

describe("when project directory contains files", () => {
describe("interactive shell", () => {
let interactive = true;
Expand Down
6 changes: 5 additions & 1 deletion packages/create-remix/__tests__/fixtures/stack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"dev": "remix dev",
"start": "remix-serve build/index.js"
},
"dependencies": {},
"dependencies": {
"@remix-run/react": "*",
"not-remix": "*",
"remix": "*"
},
"devDependencies": {},
"engines": {
"node": ">=18.0.0"
Expand Down
5 changes: 4 additions & 1 deletion packages/create-remix/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,10 @@ async function updatePackageJSON(ctx: Context) {

for (let dependency in dependencies) {
let version = dependencies[dependency];
if (version === "*") {
if (
(dependency.startsWith("@remix-run/") || dependency === "remix") &&
version === "*"
) {
dependencies[dependency] = semver.prerelease(ctx.remixVersion)
? // Templates created from prereleases should pin to a specific version
ctx.remixVersion
Expand Down

0 comments on commit 579f8e1

Please sign in to comment.