-
-
Notifications
You must be signed in to change notification settings - Fork 19
fix(intent): walk up to meta/ instead of hardcoded depth #194
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
LadyBluenotes
merged 2 commits into
TanStack:main
from
SutuSebastian:fix/getmetadir-walk-up
Jul 3, 2026
+138
−3
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/intent': patch | ||
| --- | ||
|
|
||
| Fix `setup`, `setup-github-actions`, `meta`, and `scaffold` failing with "No templates directory found" / "Meta-skills directory not found" in the published package. `getMetaDir` hardcoded `../../meta`, which is correct for the `src/commands/` source layout but overshoots to `@tanstack/meta` from the flat `dist/` layout the build ships. Walk up to the first `meta/` directory instead so resolution works in both layouts (and symlinked installs). |
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,102 @@ | ||
| import { | ||
| existsSync, | ||
| mkdirSync, | ||
| mkdtempSync, | ||
| rmSync, | ||
| symlinkSync, | ||
| writeFileSync, | ||
| } from 'node:fs' | ||
| import { join } from 'node:path' | ||
| import { tmpdir } from 'node:os' | ||
| import { afterEach, beforeEach, describe, expect, it } from 'vitest' | ||
| import { findMetaDir, getMetaDir } from '../src/commands/support.js' | ||
|
|
||
| let root: string | ||
|
|
||
| beforeEach(() => { | ||
| root = mkdtempSync(join(tmpdir(), 'support-test-')) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| rmSync(root, { recursive: true, force: true }) | ||
| }) | ||
|
|
||
| function seedMeta(pkgDir: string): string { | ||
| const metaDir = join(pkgDir, 'meta', 'templates', 'workflows') | ||
| mkdirSync(metaDir, { recursive: true }) | ||
| writeFileSync( | ||
| join(metaDir, 'check-skills.yml'), | ||
| '# intent-workflow-version: 3\n', | ||
| ) | ||
| return join(pkgDir, 'meta') | ||
| } | ||
|
|
||
| describe('findMetaDir', () => { | ||
| it('resolves from the flat dist/ layout used by the published package', () => { | ||
| const pkgDir = join(root, 'pkg') | ||
| const metaDir = seedMeta(pkgDir) | ||
| // Bundled module lives flat at <pkg>/dist/support-*.mjs. | ||
| const startDir = join(pkgDir, 'dist') | ||
| mkdirSync(startDir, { recursive: true }) | ||
| expect(findMetaDir(startDir)).toBe(metaDir) | ||
| }) | ||
|
|
||
| it('resolves from the deep src/commands/ layout used in source', () => { | ||
| const pkgDir = join(root, 'pkg') | ||
| const metaDir = seedMeta(pkgDir) | ||
| // Source module lives at <pkg>/src/commands/support.ts (two levels deep). | ||
| const startDir = join(pkgDir, 'src', 'commands') | ||
| mkdirSync(startDir, { recursive: true }) | ||
| expect(findMetaDir(startDir)).toBe(metaDir) | ||
| }) | ||
|
|
||
| it('falls back to the historical ../../meta when no meta/ is found', () => { | ||
| const startDir = join(root, 'pkg', 'dist') | ||
| mkdirSync(startDir, { recursive: true }) | ||
| expect(findMetaDir(startDir)).toBe(join(startDir, '..', '..', 'meta')) | ||
| expect(existsSync(findMetaDir(startDir))).toBe(false) | ||
| }) | ||
|
|
||
| it('skips a stray file named meta and keeps walking', () => { | ||
| const pkgDir = join(root, 'pkg') | ||
| const metaDir = seedMeta(pkgDir) | ||
| const startDir = join(pkgDir, 'dist') | ||
| mkdirSync(startDir, { recursive: true }) | ||
| // A file (not a directory) named `meta` next to startDir must not short-circuit. | ||
| writeFileSync(join(startDir, 'meta'), '') | ||
| expect(findMetaDir(startDir)).toBe(metaDir) | ||
| }) | ||
|
|
||
| it('resolves through a symlinked install path (pnpm-style)', () => { | ||
| // Real package lives in a pnpm-style store; the consumer reaches it via a symlink. | ||
| const storePkg = join( | ||
| root, | ||
| 'store', | ||
| '@tanstack+intent', | ||
| 'node_modules', | ||
| '@tanstack', | ||
| 'intent', | ||
| ) | ||
| seedMeta(storePkg) | ||
| mkdirSync(join(storePkg, 'dist'), { recursive: true }) | ||
|
|
||
| const consumerTanstack = join(root, 'consumer', 'node_modules', '@tanstack') | ||
| mkdirSync(consumerTanstack, { recursive: true }) | ||
| symlinkSync(storePkg, join(consumerTanstack, 'intent'), 'dir') | ||
|
|
||
| const startDir = join(consumerTanstack, 'intent', 'dist') | ||
| const resolved = findMetaDir(startDir) | ||
| expect(resolved).toBe(join(consumerTanstack, 'intent', 'meta')) | ||
| expect(existsSync(resolved)).toBe(true) | ||
| }) | ||
| }) | ||
|
|
||
| describe('getMetaDir', () => { | ||
| it('resolves to a meta/ directory that ships the workflow template', () => { | ||
| const metaDir = getMetaDir() | ||
| expect(existsSync(metaDir)).toBe(true) | ||
| expect( | ||
| existsSync(join(metaDir, 'templates', 'workflows', 'check-skills.yml')), | ||
| ).toBe(true) | ||
| }) | ||
| }) |
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.