-
Notifications
You must be signed in to change notification settings - Fork 734
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
Fix relative project root #7285
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
577f4b9
Fix relative project root
penalosa d94a80a
Create sixty-news-relax.md
penalosa 1f0d1ae
Make tests clearer
penalosa d875dc0
rename directory to projectRoot
penalosa c1ceac2
fix windows
penalosa 61353fe
windows?
penalosa 17af36f
different template
penalosa 512b9a9
- only
penalosa 79d10d0
fix
penalosa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
Rename `directory` to `projectRoot` and ensure it's relative to the `wrangler.toml`. This fixes a regression which meant that `.wrangler` temporary folders were inadvertently generated relative to `process.cwd()` rather than the location of the `wrangler.toml` file. It also renames `directory` to `projectRoot`, which affects the `unstable_startWorker() interface. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import path from "path"; | ||
import dedent from "ts-dedent"; | ||
import { defaultWranglerConfig } from "../config/config"; | ||
import { getEntry } from "../deployment-bundle/entry"; | ||
import { mockConsoleMethods } from "./helpers/mock-console"; | ||
import { runInTempDir } from "./helpers/run-in-tmp"; | ||
import { seed } from "./helpers/seed"; | ||
import type { Entry } from "../deployment-bundle/entry"; | ||
|
||
function normalize(entry: Entry): Entry { | ||
const tmpDir = process.cwd(); | ||
const tmpDirName = path.basename(tmpDir); | ||
|
||
return Object.fromEntries( | ||
Object.entries(entry).map(([k, v]) => [ | ||
k, | ||
typeof v === "string" | ||
? v | ||
.replaceAll("\\", "/") | ||
.replace(new RegExp(`(.*${tmpDirName})`), `/tmp/dir`) | ||
: v, | ||
]) | ||
) as Entry; | ||
} | ||
|
||
describe("getEntry()", () => { | ||
runInTempDir(); | ||
mockConsoleMethods(); | ||
|
||
it("--script index.ts", async () => { | ||
await seed({ | ||
"index.ts": dedent/* javascript */ ` | ||
export default { | ||
fetch() { | ||
|
||
} | ||
} | ||
`, | ||
}); | ||
const entry = await getEntry( | ||
{ script: "index.ts" }, | ||
defaultWranglerConfig, | ||
"deploy" | ||
); | ||
expect(normalize(entry)).toMatchObject({ | ||
projectRoot: "/tmp/dir", | ||
file: "/tmp/dir/index.ts", | ||
moduleRoot: "/tmp/dir", | ||
}); | ||
}); | ||
|
||
it("--script src/index.ts", async () => { | ||
await seed({ | ||
"src/index.ts": dedent/* javascript */ ` | ||
export default { | ||
fetch() { | ||
|
||
} | ||
} | ||
`, | ||
}); | ||
const entry = await getEntry( | ||
{ script: "src/index.ts" }, | ||
defaultWranglerConfig, | ||
"deploy" | ||
); | ||
expect(normalize(entry)).toMatchObject({ | ||
projectRoot: "/tmp/dir", | ||
file: "/tmp/dir/src/index.ts", | ||
moduleRoot: "/tmp/dir/src", | ||
}); | ||
}); | ||
|
||
it("main = index.ts", async () => { | ||
await seed({ | ||
"index.ts": dedent/* javascript */ ` | ||
export default { | ||
fetch() { | ||
|
||
} | ||
} | ||
`, | ||
}); | ||
const entry = await getEntry( | ||
{}, | ||
{ ...defaultWranglerConfig, main: "index.ts" }, | ||
"deploy" | ||
); | ||
expect(normalize(entry)).toMatchObject({ | ||
projectRoot: "/tmp/dir", | ||
file: "/tmp/dir/index.ts", | ||
moduleRoot: "/tmp/dir", | ||
}); | ||
}); | ||
|
||
it("main = src/index.ts", async () => { | ||
await seed({ | ||
"src/index.ts": dedent/* javascript */ ` | ||
export default { | ||
fetch() { | ||
|
||
} | ||
} | ||
`, | ||
}); | ||
const entry = await getEntry( | ||
{}, | ||
{ ...defaultWranglerConfig, main: "src/index.ts" }, | ||
"deploy" | ||
); | ||
expect(normalize(entry)).toMatchObject({ | ||
projectRoot: "/tmp/dir", | ||
file: "/tmp/dir/src/index.ts", | ||
moduleRoot: "/tmp/dir/src", | ||
}); | ||
}); | ||
|
||
it("main = src/index.ts w/ configPath", async () => { | ||
await seed({ | ||
"other-worker/src/index.ts": dedent/* javascript */ ` | ||
export default { | ||
fetch() { | ||
|
||
} | ||
} | ||
`, | ||
}); | ||
const entry = await getEntry( | ||
{}, | ||
{ | ||
...defaultWranglerConfig, | ||
main: "src/index.ts", | ||
configPath: "other-worker/wrangler.toml", | ||
}, | ||
"deploy" | ||
); | ||
expect(normalize(entry)).toMatchObject({ | ||
projectRoot: "/tmp/dir/other-worker", | ||
file: "/tmp/dir/other-worker/src/index.ts", | ||
moduleRoot: "/tmp/dir/other-worker/src", | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏 🙇♥️