-
Notifications
You must be signed in to change notification settings - Fork 19
Prepare the Nuxt app to move from nuxt/ to the repository root #5871
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
Open
ZJvandeWeg
wants to merge
9
commits into
main
Choose a base branch
from
prep-flatten-nuxt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+303
−421
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f09fbae
handbook changes: survive the move out of nuxt/
ZJvandeWeg 75258f0
repo root: find it instead of counting ../ from nuxt/
ZJvandeWeg 0e947b4
search index: move the helpers into nuxt/lib and switch the scripts t…
ZJvandeWeg b03f0ec
css: keep the Tailwind config next to the stylesheet that loads it
ZJvandeWeg 4e9c5a3
package.json: fold the nuxt workspace into the root
ZJvandeWeg d74455b
gitignore: merge nuxt/.gitignore into the root one
ZJvandeWeg 186f4e0
guides sync test: build the expected edit URL from GUIDES_SOURCE
ZJvandeWeg 4540855
css: import the vendor stylesheets by package name
ZJvandeWeg f6cb696
guides sync: date a guide by its last edit, not by a move
ZJvandeWeg 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
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 |
|---|---|---|
| @@ -1,21 +1,39 @@ | ||
| .DS_Store | ||
| node_modules | ||
| .env | ||
|
|
||
| # Nuxt build output | ||
| nuxt/.nuxt/ | ||
| nuxt/.output/ | ||
| nuxt/dist/ | ||
| nuxt/.data/ | ||
|
|
||
| # Local Netlify folder | ||
| .netlify | ||
|
|
||
| # Synced at build time by nuxt/modules/docs-source.ts (from FlowFuse/flowfuse) and | ||
| # nuxt/modules/blueprints-source.ts (from FlowFuse/blueprint-library). | ||
| nuxt/content/docs/ | ||
| # Synced from FlowFuse/blueprint-library by nuxt/modules/blueprints-source.ts. | ||
| nuxt/public/docs/ | ||
| nuxt/content/blueprints/ | ||
| nuxt/public/blueprints/ | ||
|
|
||
| # nuxt/public/ is a tracked asset tree. Only these parts of it are generated during a build: | ||
| nuxt/public/css/ | ||
| nuxt/public/js/cc.min.js | ||
| nuxt/public/js/flowrenderer.min.js | ||
|
|
||
| # Left in existing checkouts by the retired Eleventy build: its output and its | ||
| # eleventy-fetch cache. Nothing writes these any more. | ||
| # Left in existing checkouts by the retired Eleventy build: its output, its eleventy-fetch | ||
| # cache, and what it wrote into nuxt/public/. Nothing writes these any more. | ||
| _site | ||
| .cache | ||
| nuxt/public/img/ | ||
| nuxt/public/_includes/ | ||
| nuxt/public/sitemap-legacy.xml | ||
| nuxt/public/js/ai-expert-modal.js | ||
| nuxt/public/js/hm-promo-banner.js | ||
|
|
||
| # Local development config | ||
| .vscode/ | ||
|
|
||
| .env | ||
|
|
||
| # Local Netlify folder | ||
| .netlify | ||
|
|
||
|
|
||
| deno.lock | ||
| deno.lock |
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 was deleted.
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
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 | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||
| import { test } from 'node:test' | ||||||
| import { execFileSync } from 'node:child_process' | ||||||
| import assert from 'node:assert/strict' | ||||||
| import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs' | ||||||
| import { tmpdir } from 'node:os' | ||||||
|
|
@@ -10,6 +11,7 @@ import { | |||||
| injectFrontmatter, | ||||||
| listGuideFiles, | ||||||
| syncGuides, | ||||||
| writeGuideFile, | ||||||
| } from './guides-sync.mjs' | ||||||
|
|
||||||
| const silent = { info: () => {}, warn: () => {}, error: () => {} } | ||||||
|
|
@@ -88,7 +90,7 @@ test('the whole guides tree lands in the docs content tree, stamped with an edit | |||||
|
|
||||||
| assert.equal(count, 3) | ||||||
| const index = readFileSync(join(contentDocsDir, 'application-guide/index.md'), 'utf8') | ||||||
| assert.match(index, /editUrl: https:\/\/github\.com\/FlowFuse\/website\/edit\/main\/nuxt\/content-guides\/application-guide\/README\.md/) | ||||||
| assert.ok(index.includes(`editUrl: https://github.com/FlowFuse/website/edit/main/${GUIDES_SOURCE}/application-guide/README.md\n`)) | ||||||
| assert.match(index, /title: Guide/) | ||||||
| assert.ok(readFileSync(join(contentDocsDir, 'application-guide/architectures/it.md'), 'utf8')) | ||||||
| assert.equal(readFileSync(join(publicDocsDir, 'application-guide/diagram.svg'), 'utf8'), '<svg/>') | ||||||
|
|
@@ -139,3 +141,38 @@ test('listGuideFiles walks nested directories and skips dotfiles', () => { | |||||
| cleanup() | ||||||
| } | ||||||
| }) | ||||||
|
|
||||||
| test('updated is the last change to a guide, not the commit that moved it', () => { | ||||||
| const { root, contentDocsDir, publicDocsDir, cleanup } = scratch() | ||||||
| const git = (date, ...args) => execFileSync('git', args, { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
Suggested change
|
||||||
| cwd: root, | ||||||
| env: { ...process.env, GIT_AUTHOR_DATE: date, GIT_COMMITTER_DATE: date }, | ||||||
| stdio: ['ignore', 'pipe', 'ignore'], | ||||||
| }) | ||||||
| const commit = (date, message) => git(date, '-c', 'user.name=t', '-c', 'user.email=t@t', 'commit', '-q', '-m', message) | ||||||
| try { | ||||||
| git('2026-01-01T00:00:00Z', 'init', '-q') | ||||||
| write(join(root, 'old', 'a.md'), '# A\n') | ||||||
| write(join(root, 'old', 'b.md'), '# B\n') | ||||||
| git('2026-01-01T00:00:00Z', 'add', '-A') | ||||||
| commit('2026-01-01T00:00:00Z', 'add') | ||||||
| write(join(root, 'old', 'a.md'), '# A, edited\n') | ||||||
| git('2026-02-01T00:00:00Z', 'add', '-A') | ||||||
| commit('2026-02-01T00:00:00Z', 'edit a') | ||||||
| // Move the tree to where GUIDES_SOURCE says the guides live now, editing b on the way. | ||||||
| mkdirSync(dirname(join(root, GUIDES_SOURCE)), { recursive: true }) | ||||||
| git('2026-03-01T00:00:00Z', 'mv', 'old', GUIDES_SOURCE) | ||||||
| write(join(root, GUIDES_SOURCE, 'b.md'), '# B, edited while moving\n') | ||||||
| git('2026-03-01T00:00:00Z', 'add', '-A') | ||||||
| commit('2026-03-01T00:00:00Z', 'move') | ||||||
|
|
||||||
| const updated = relPath => { | ||||||
| const dest = writeGuideFile({ guidesDir: join(root, GUIDES_SOURCE), repoRoot: root, contentDocsDir, publicDocsDir, relPath }) | ||||||
| return readFileSync(dest, 'utf8').match(/^updated: (\S+)/m)?.[1] | ||||||
| } | ||||||
| assert.equal(updated('a.md'), '2026-02-01', 'a pure move keeps the date of the last edit') | ||||||
| assert.equal(updated('b.md'), '2026-03-01', 'a move that also edited the file counts as the edit') | ||||||
| } finally { | ||||||
| cleanup() | ||||||
| } | ||||||
| }) | ||||||
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,20 @@ | ||
| import { existsSync } from 'node:fs' | ||
| import { dirname, join } from 'node:path' | ||
| import { fileURLToPath } from 'node:url' | ||
|
|
||
| // The root of the checkout: the closest directory at or above `start` that holds | ||
| // package-lock.json. Found rather than written as a fixed run of `..`, so a caller keeps | ||
| // working when the file it lives in moves up or down a level. Closest rather than | ||
| // furthest, so a git worktree nested inside another checkout (.claude/worktrees/) | ||
| // resolves to itself and not to the checkout around it. | ||
| export function findRepoRoot (start) { | ||
| let dir = start | ||
| while (!existsSync(join(dir, 'package-lock.json'))) { | ||
| const parent = dirname(dir) | ||
| if (parent === dir) throw new Error(`No package-lock.json at or above ${start}`) | ||
| dir = parent | ||
| } | ||
| return dir | ||
| } | ||
|
|
||
| export const REPO_ROOT = findRepoRoot(dirname(fileURLToPath(import.meta.url))) |
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,27 @@ | ||
| import { test } from 'node:test' | ||
| import assert from 'node:assert/strict' | ||
| import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' | ||
| import { tmpdir } from 'node:os' | ||
| import { join } from 'node:path' | ||
|
|
||
| import { findRepoRoot } from './repo-root.mjs' | ||
|
|
||
| test('findRepoRoot returns the closest directory holding package-lock.json', (t) => { | ||
| const root = mkdtempSync(join(tmpdir(), 'repo-root-')) | ||
| t.after(() => rmSync(root, { recursive: true, force: true })) | ||
| // An outer checkout with a worktree nested inside it, as .claude/worktrees/ does. | ||
| const worktree = join(root, '.claude', 'worktrees', 'topic') | ||
| mkdirSync(join(worktree, 'nuxt', 'lib'), { recursive: true }) | ||
| writeFileSync(join(root, 'package-lock.json'), '{}') | ||
| writeFileSync(join(worktree, 'package-lock.json'), '{}') | ||
|
|
||
| assert.equal(findRepoRoot(join(worktree, 'nuxt', 'lib')), worktree) | ||
| assert.equal(findRepoRoot(worktree), worktree) | ||
| assert.equal(findRepoRoot(join(root, '.claude')), root) | ||
| }) | ||
|
|
||
| test('findRepoRoot fails loudly when there is no package-lock.json above', (t) => { | ||
| const root = mkdtempSync(join(tmpdir(), 'repo-root-')) | ||
| t.after(() => rmSync(root, { recursive: true, force: true })) | ||
| assert.throws(() => findRepoRoot(root), /No package-lock.json/) | ||
| }) |
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.
nuxt/lib/git-lastmod.mjs'sgetGitLastmod()already solves this exact problem with one memoized whole-repo walk, could this reuse it instead of a per-filegit log --follow?