-
-
Notifications
You must be signed in to change notification settings - Fork 98
Fix @fedify/nuxt runtime packaging and fedify init scaffolding edge cases
#717
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9e26a4f
Bundle Nuxt runtime from dist
dahlia c1a3f22
Update generated Biome config
dahlia a9b67c5
Allow init in unborn Git repos
dahlia 8c78646
Add non-empty init option
dahlia fee5abc
Add PR links to the changelog
dahlia dc16653
Handle init review feedback
dahlia 53dc63c
Address init review followups
dahlia 11970a0
Reject stale Git metadata in init
dahlia ee83be1
Trim Nuxt declaration output
dahlia 26417ff
Clarify init non-empty limits
dahlia 5476af7
Refine Nuxt package metadata
dahlia dfbba38
Memoize init JSON config loading
dahlia c1f1726
Stabilize queue shutdown in tests
dahlia 79dfe11
Fix init JSON cache keying
dahlia 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,115 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import test from "node:test"; | ||
| import { message } from "@optique/core"; | ||
| import type { InitCommandData } from "../types.ts"; | ||
| import { | ||
| assertNoGeneratedFileConflicts, | ||
| GeneratedFileConflictError, | ||
| getJsonsCacheKey, | ||
| } from "./patch.ts"; | ||
|
|
||
| test("assertNoGeneratedFileConflicts allows unrelated files", async () => { | ||
| await withTempDir(async (dir) => { | ||
| await writeFile(join(dir, "README.md"), "# Example\n"); | ||
|
|
||
| await assert.doesNotReject(() => | ||
| assertNoGeneratedFileConflicts(createInitData(dir, true)) | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| test("assertNoGeneratedFileConflicts rejects existing generated files", async () => { | ||
| await withTempDir(async (dir) => { | ||
| await mkdir(join(dir, "src"), { recursive: true }); | ||
| await writeFile(join(dir, "package.json"), "{}\n"); | ||
| await writeFile(join(dir, "src", "main.ts"), ""); | ||
|
|
||
| await assert.rejects( | ||
| () => assertNoGeneratedFileConflicts(createInitData(dir, true)), | ||
| (error) => { | ||
| assert.ok(error instanceof GeneratedFileConflictError); | ||
| assert.deepEqual(error.conflicts, ["src/main.ts", "package.json"]); | ||
| assert.match(error.message, /src\/main\.ts/); | ||
| assert.match(error.message, /package\.json/); | ||
| return true; | ||
| }, | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| test("assertNoGeneratedFileConflicts skips checks without allowNonEmpty", async () => { | ||
| await withTempDir(async (dir) => { | ||
| await writeFile(join(dir, "package.json"), "{}\n"); | ||
|
|
||
| await assert.doesNotReject(() => | ||
| assertNoGeneratedFileConflicts(createInitData(dir, false)) | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| test("getJsonsCacheKey stays stable across pipeline clones", () => { | ||
| const data = createInitData("/tmp/example", true); | ||
| const cloned = { | ||
| ...data, | ||
| files: { "src/main.ts": "" }, | ||
| jsons: { "package.json": {} }, | ||
| }; | ||
|
|
||
| assert.equal(getJsonsCacheKey(cloned), getJsonsCacheKey(data)); | ||
| }); | ||
|
|
||
| function createInitData( | ||
| dir: string, | ||
| allowNonEmpty: boolean, | ||
| ): InitCommandData { | ||
| const data = { | ||
| command: "init", | ||
| projectName: "example", | ||
| packageManager: "npm", | ||
| webFramework: "bare-bones", | ||
| kvStore: "in-memory", | ||
| messageQueue: "in-process", | ||
| dryRun: false, | ||
| allowNonEmpty, | ||
| testMode: false, | ||
| dir, | ||
| initializer: { | ||
| federationFile: "src/federation.ts", | ||
| loggingFile: "src/logging.ts", | ||
| instruction: message`done`, | ||
| tasks: {}, | ||
| compilerOptions: {}, | ||
| files: { | ||
| "src/main.ts": "", | ||
| }, | ||
| }, | ||
| kv: { | ||
| label: "In-Memory", | ||
| packageManagers: ["npm"], | ||
| imports: {}, | ||
| object: "new MemoryKvStore()", | ||
| }, | ||
| mq: { | ||
| label: "In-Process", | ||
| packageManagers: ["npm"], | ||
| imports: {}, | ||
| object: "new InProcessMessageQueue()", | ||
| }, | ||
| env: {}, | ||
| } satisfies InitCommandData; | ||
| return data; | ||
| } | ||
|
|
||
| async function withTempDir( | ||
| fn: (dir: string) => Promise<void>, | ||
| ): Promise<void> { | ||
| const dir = await mkdtemp(join(tmpdir(), "fedify-init-patch-")); | ||
| try { | ||
| await fn(dir); | ||
| } finally { | ||
| await rm(dir, { recursive: true, force: true }); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.