Repository navigation
fix: keep store stories and Jest mocks out of the .faststore type-check - #3477
Conversation
…e-check `next build` type-checks everything the `.faststore/tsconfig.json` includes. Stores keep `*.stories.tsx` and `__mocks__/` next to their components under `src/`, which is copied into `.faststore/src/customizations/src`, so the build compiled them against dev-only dependencies (`@storybook/*`, `@jest/globals`) and failed. Validated with the Whirlpool monorepo: 316 of the 331 type errors in its v4 build came from its own stories. Extend the exclude globs added in #3459 for test files to cover stories and manual mocks as well.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (2)
Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. WalkthroughThe storefront TypeScript configuration now excludes Storybook story files and Jest manual-mock directories. Tests verify these exclusions and preserve the configured exclude list. ChangesStorefront test exclusions
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized CLI change excludes store stories and Jest mocks from the Faststore type-check while preserving them for store tooling; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
) ## What's the purpose of this pull request? A store cloned under a directory whose name contains a space (e.g. `/Users/me/My Store/store`, `C:\Users\John Doe\...`) cannot run `faststore build` / `faststore dev` / `faststore generate`: ``` [STARTED] Load GraphQL documents [FAILED] Failed to load documents from /Users/me/My Store/store/.faststore/src/**/*.{ts,tsx},!/Users/me/My Store/store/.faststore/@generated/: [FAILED] Failed to parse the GraphQL document. Syntax Error: Unexpected character: "/". ``` This had been assumed fixed by #3454 — it is not: #3454 fixed the `next` binary resolution, this is a different failure in the GraphQL codegen step. Reproduced on `4.6.0` and on `dev` (`4.7.1-dev.2`) with a real Yarn 1 workspaces store cloned under a path with a space. Root cause: `generate-types.ts` passed the codegen `documents` glob and the `generates` output dir as **absolute paths**. `@graphql-tools/load` (`isDocumentString`) treats any pointer that contains whitespace and is not parseable SDL as a broken inline document and throws instead of falling through to the glob loader. The `@graphql-codegen/client-preset` also appends `!<outputDir>` to the documents, so the output dir hit the same check. ## How it works? - New `getCodegenPointers(root, cwd = process.cwd())` builds the `documents` glob, the `schema` path and the output dir **relative to the directory codegen resolves pointers from**, so the parent directories (where the space lives) are never part of the pointer: - `.faststore/src/**/*.{ts,tsx}` / `.faststore/@generated/schema.graphql` / `.faststore/@generated/` - Glob-special characters in the relative segments are still escaped (`globby.convertPathToPattern`, same approach as #3454 for the typeDefs glob); the schema and output dir are plain paths, not globs, so they are not escaped. - Symlinks are resolved on both sides (`/var` → `/private/var` on macOS) so the relative path does not climb back through the parents. - `genTsTypes` now awaits the codegen run (it was fire-and-forget). - CLI `vitest.config.ts`: alias `graphql` to its CJS build. The code under test and the externalized `@graphql-tools/*` otherwise load two `graphql` instances and fail `instanceof` checks ("Duplicate graphql modules"), which made an end-to-end test of the generator impossible. No behaviour change for paths without spaces: the same files are matched and written, only the pointer form changes. ## How to test it? - `cd packages/cli && pnpm test` — 177 tests. New in `generate-types.test.ts`: - `getCodegenPointers` never embeds the absolute project path, targets `.faststore` when present, escapes glob-special characters only in the glob. - `genTsTypes` end-to-end from a store under `<tmp>/faststore gen (x86) XXXX/store`: merges a custom `thirdParty` typeDef and generates `graphql.ts` containing the query type. - Manual: clone any store into a directory with a space, install this CLI build and run `yarn build`. On `dev` it fails at "Load GraphQL documents"; with this branch the generate step completes. ### Starters Deploy Preview Pending CodeSandbox / pkg.pr.new build for this PR. ## References - #3454 (`next` binary resolution — different issue, same symptom family) - Companion PRs (independent): #3474, #3475, #3477 Made with [Cursor](https://cursor.com) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved CLI TypeScript type generation for projects located in paths containing spaces, special characters, or symlinks. * Ensured type generation completes reliably before the CLI proceeds. * **Tests** * Expanded automated coverage for schema discovery, path handling, and generated TypeScript output. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
## What's the purpose of this pull request? Graduation of the `dev` prerelease cycle (`4.8.0-dev.8`) into a stable `4.8.0` release on `main`. Merging this PR triggers the `release` CD workflow, which runs `lerna version --conventional-graduate --force-conventional-graduate` and publishes all 8 `@faststore/*` packages under the `latest` dist-tag. The bump is decided by the Conventional Commits accumulated on `dev` (`feat:` → **minor** `4.8.0`). No unmerged hotfixes on `main`. ## How it works? No new product code in this PR itself — it is the merge of `dev` into `main`. After merge, CD graduates `4.8.0-dev.8` → `4.8.0`. ### Highlights (features) * feat(core): add mini cart recommendation shelf ([#3466](#3466)) * feat(api): export `validateUserAuthentication` and `getAuthCookie` ([#3481](#3481)) ### Fixes * fix(core): align the saved-cards list with the design reference ([#3487](#3487)) * fix: stop retrying upstream 429 responses ([#3453](#3453)) * fix: normalize outputFileTracingRoot to forward slashes on Windows ([#3484](#3484)) * fix: forward contentSource.project as --storeId in cms-sync CP flow ([#3482](#3482)) * fix: generate GraphQL types when the project path contains spaces ([#3476](#3476)) * fix: keep store stories and Jest mocks out of the .faststore type-check ([#3477](#3477)) * fix(api): export Resolver, GraphqlContext and helper types from the public entry ([#3474](#3474)) * fix: stop forwarding unvalidated ni output to the shell in the CLI ([#3422](#3422)) * fix: point localized canonical and hreflang at the rendered locale ([#3470](#3470)) ## Packages published (latest) `@faststore/{api,cli,components,core,diagnostics,lighthouse,sdk,ui}` → `4.8.0` ## How to test it? * CI green on this PR * After merge, `release` workflow succeeds on `main` * All 8 packages report `4.8.0` under the `latest` dist-tag on npm * Back-merge `main` → `dev` to open the next dev cycle ## Checklist **PR Title and Commit Messages** * PR title and commit messages follow the Conventional Commits specification **PR Description** * Added a label according to the PR goal **Dependencies** * No extra lockfile changes in this graduation PR <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added configurable product recommendations to the cart drawer, including campaign selection, carousel options, titles, and product-card customization. * Added public authentication utilities, GraphQL types, and resolver typings. * **Bug Fixes** * Improved localized canonical and hreflang URLs across storefront pages. * Prevented automatic retries for rate-limit responses. * Improved CLI handling of package managers, Windows paths, spaces, and CMS Sync store IDs. * **Documentation** * Updated package changelogs and recommendation-shelf guidance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Válber Laux <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Thiago Pereira <[email protected]> Co-authored-by: eduardoformiga <[email protected]> Co-authored-by: vtexgithubbot <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Larícia Mota <[email protected]> Co-authored-by: Arthur Andrade <[email protected]>

0 New Issues
0 Fixed Issues
0 Accepted Issues
No data about coverage (37.40% Estimated after merge)
What's the purpose of this pull request?
Follow-up to #3459 (test files being type-checked inside
.faststore).next buildtype-checks everything included by.faststore/tsconfig.json. #3459 stopped copying the core unit tests and excluded*.test.*/__tests__, but stores also keep Storybook stories (*.stories.tsx) and Jest manual mocks (__mocks__/) next to their components undersrc/. That folder is copied into.faststore/src/customizations/src, so the build compiled those files against dev-only dependencies (@storybook/*,@jest/globals) and failed.Validated against a real v3 store being migrated to v4 (on top of #3476): 331 type errors → 13; the 316 removed were all in the store's own
*.stories.tsx/__mocks__. The remaining 13 are genuine v3 → v4 migration items in the store code (deep@faststore/sdk/dist/...imports, changed core internals,@types/react19 hoisted).How it works?
STOREFRONT_TEST_EXCLUDE_GLOBS(merged into theexcludeof the tsconfig written to.faststore) gains**/*.stories.ts,**/*.stories.tsxand**/__mocks__/**. Files are still copied — nothing changes for the store's own tooling — they just stop being part of the Next type-check program. Story files are never imported by application code, so no build output changes.How to test it?
cd packages/cli && pnpm test(storefrontCopy.test.tsasserts the new globs).src/**/*.stories.tsximporting@storybook/react, runyarn buildwith this CLI: the generated.faststore/tsconfig.jsonlists the new excludes andRunning TypeScript ...no longer reports the stories.Starters Deploy Preview
Pending CodeSandbox / pkg.pr.new build for this PR.
References
generate)Made with Cursor
Summary by CodeRabbit