-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: Enable better unit testing of generators #485
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
refactor: Enable better unit testing of generators #485
Conversation
- Also refatored Node generator and adding testing to make it more ergonomic
ENG-604 Create a testing framework for Baseplate generators
Right now we don't have a good system for unit/integration testing Baseplate generators meaning we have to run it before we can test it. We should help create a testing harness to allow easier testing of Baseplate generators. |
🦋 Changeset detectedLatest commit: 570a282 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe changes span multiple packages and generators. They introduce new documentation files and refactor a variety of generator methods to remove direct manipulation of a node provider. In their place, new task-based functions (e.g., Changes
Sequence Diagram(s)sequenceDiagram
participant GT as Generator Task
participant NPTask as createNodePackagesTask
participant EPS as extractPackageVersions
participant NC as Node Config/Script Manager
GT->>NPTask: Invoke dependency management task
NPTask->>EPS: Request package versions for dependencies
EPS-->>NPTask: Return extracted version info
NPTask->>NC: Pass dependency info for merging scripts/packages
NC-->>GT: Updated configuration for generator task
This diagram illustrates the new task flow where a generator task delegates package version extraction and merging to dedicated functions, streamlining the dependency management process. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (12)
packages/sync/src/utils/exec.ts (1)
17-25: Well-implemented environment variables handlingThe implementation properly merges filtered process environment variables with user-provided ones, ensuring user variables take precedence.
Minor suggestion regarding type safety: Consider handling potential undefined values from
process.env[key]in the mapping function.- .map((key) => [key, process.env[key]]), + .map((key) => [key, process.env[key] ?? '']),packages/sync/src/generators/build-generator-entry.ts (1)
113-113: Type safety consideration with explicit castingThe explicit cast to
GeneratorTaskmight indicate a potential type inference issue. While the casting works, consider whether a stronger type definition for the tasks object structure could eliminate the need for this explicit cast.packages/core-generators/src/utils/extract-packages.ts (1)
7-14: Consider adding validation for non-existent keysThe current implementation silently ignores keys that don't exist in the packages record. While this might be the intended behavior, consider either:
- Adding a comment to document this behavior explicitly
- Adding validation that throws an error when non-existent keys are requested
- Adding a parameter to control this behavior
This would make the function more robust and self-documenting.
export function extractPackageVersions<T extends Record<string, string>>( packages: T, keys: (keyof T)[], + // Note: Keys that don't exist in packages will be silently ignored ): Record<keyof T, string> { return Object.fromEntries( Object.entries(packages).filter(([key]) => keys.includes(key)), ) as Record<keyof T, string>; }packages/sync/src/utils/create-config-provider-task-with-info.ts (3)
18-47: Provide additional clarity on naming conventions.
TheprefixandtaskNamefields are useful for preventing naming collisions. However, consider clearly documenting or enforcing constraints (e.g., character restrictions, uniqueness checks) so that generated provider names don’t accidentally conflict with other similarly prefixed providers.
108-114: Validate provider naming strategy.
When creating provider names like${prefix}-${taskName}-configand${prefix}-${taskName}-config-values, ensure that there are no conflicts within the broader codebase. This is especially relevant in large generators that might re-use the same prefix or taskName.
115-137: Potential overhead of combining config and info objects.
In line 127–129, the config containers and the “info” object are spread together. For large descriptors, this may result in performance overhead or overshadowing logic if repeated multiple times. Consider returning them as distinct properties (e.g.,{ config, info }) to keep them logically separated, unless merging is explicitly desired.packages/sync/src/utils/create-generator.ts (2)
58-58: Clarify return type for buildTasks.
buildTasksreturning either an array of tasks or a record can lead to dynamic branching logic. For maintainability, ensure that consumers are aware of this dual interface. Adding JSDoc examples of both usage patterns could help.
108-113: Encourage thorough testing around descriptor usage.
SincecreateGeneratorvalidates the descriptor usingzod, ensure that any downstream references to typed descriptor properties are also thoroughly tested, especially if the descriptor schema is large or complex.packages/utils/src/field-map/field-map.ts (1)
43-70: Consider exposing a “set by source” get method.
ArrayContainertracks duplicates and their sources internally. If debugging or auditing is needed, exposing a read-only method or property for_stripDuplicatesor origin sources could add transparency at runtime.packages/core-generators/src/generators/node/node/package-dependencies-container.ts (3)
36-57: Error message could be more informative for version conflicts.When incompatible versions are detected, the error message only includes the existing version, not the new version that caused the conflict. This makes debugging more difficult.
throw new Error( - `Could not merge incompatible versions for dependency "${name}": existing "${oldVersion}"`, + `Could not merge incompatible versions for dependency "${name}": existing "${oldVersion}" vs new "${version}"`, );
98-102: Documentation includes parameter that doesn't exist in method signature.The JSDoc for
addPackagesmentions atypeparameter, but this parameter is not part of the method signature. The method instead takes dependencies of both types through thepackagesparameter./** * Add multiple dependencies to the container * @param packages - The dependencies to add - * @param type - The type of the dependencies (dev or prod) */
1-134: Consider adding version string validation.There's currently no validation to ensure that the version strings passed to the
addmethod are valid semver strings before attempting to use them with the semver library. This could lead to runtime errors if invalid version strings are provided.You could add validation by checking if the version strings are valid before performing comparisons:
add(name: string, version: string, type: NodePackageDependencyType): void { + if (!semver.valid(semver.coerce(version)) && !semver.validRange(version)) { + throw new Error(`Invalid version format for dependency "${name}": "${version}"`); + } const existingEntry = this._value.get(name); if (existingEntry) { const oldVersion = existingEntry.version; + if (!semver.valid(semver.coerce(oldVersion)) && !semver.validRange(oldVersion)) { + throw new Error(`Invalid existing version format for dependency "${name}": "${oldVersion}"`); + } // ...rest of the method
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite
📒 Files selected for processing (89)
.changeset/hot-trees-take.md(1 hunks).changeset/shaky-spoons-add.md(1 hunks)packages/core-generators/package.json(0 hunks)packages/core-generators/src/constants/node.ts(1 hunks)packages/core-generators/src/generators/node/_composers/node.ts(1 hunks)packages/core-generators/src/generators/node/eslint/index.ts(4 hunks)packages/core-generators/src/generators/node/index.ts(1 hunks)packages/core-generators/src/generators/node/node/index.ts(0 hunks)packages/core-generators/src/generators/node/node/node.generator.ts(1 hunks)packages/core-generators/src/generators/node/node/node.generator.unit.test.ts(1 hunks)packages/core-generators/src/generators/node/node/package-dependencies-container.ts(1 hunks)packages/core-generators/src/generators/node/node/package-dependencies-container.unit.test.ts(1 hunks)packages/core-generators/src/generators/node/prettier/index.ts(4 hunks)packages/core-generators/src/generators/node/typescript/index.ts(6 hunks)packages/core-generators/src/generators/node/vitest/index.ts(3 hunks)packages/core-generators/src/index.ts(1 hunks)packages/core-generators/src/providers/project.ts(1 hunks)packages/core-generators/src/utils/extract-packages.ts(1 hunks)packages/core-generators/src/utils/index.ts(1 hunks)packages/core-generators/src/writers/index.ts(1 hunks)packages/core-generators/src/writers/json.ts(1 hunks)packages/fastify-generators/src/constants/fastify-packages.ts(3 hunks)packages/fastify-generators/src/generators/auth/auth-plugin/index.ts(2 hunks)packages/fastify-generators/src/generators/auth/auth/index.ts(1 hunks)packages/fastify-generators/src/generators/auth/password-hasher-service/index.ts(2 hunks)packages/fastify-generators/src/generators/auth0/auth0-module/index.ts(3 hunks)packages/fastify-generators/src/generators/bull/bull-mq/index.ts(5 hunks)packages/fastify-generators/src/generators/bull/fastify-bull-board/index.ts(4 hunks)packages/fastify-generators/src/generators/core/axios/index.ts(2 hunks)packages/fastify-generators/src/generators/core/config-service/index.ts(2 hunks)packages/fastify-generators/src/generators/core/fastify-cookie-context/index.ts(2 hunks)packages/fastify-generators/src/generators/core/fastify-redis/index.ts(3 hunks)packages/fastify-generators/src/generators/core/fastify-scripts/index.ts(1 hunks)packages/fastify-generators/src/generators/core/fastify-sentry/index.ts(5 hunks)packages/fastify-generators/src/generators/core/fastify-server/index.ts(3 hunks)packages/fastify-generators/src/generators/core/fastify/index.ts(5 hunks)packages/fastify-generators/src/generators/core/fastify/setup-fastify-typescript.ts(1 hunks)packages/fastify-generators/src/generators/core/logger-service/index.ts(2 hunks)packages/fastify-generators/src/generators/core/request-context/index.ts(2 hunks)packages/fastify-generators/src/generators/core/root-module/index.ts(2 hunks)packages/fastify-generators/src/generators/email/fastify-postmark/index.ts(2 hunks)packages/fastify-generators/src/generators/email/fastify-sendgrid/index.ts(2 hunks)packages/fastify-generators/src/generators/pothos/pothos-prisma/index.ts(2 hunks)packages/fastify-generators/src/generators/pothos/pothos-scalar/index.ts(1 hunks)packages/fastify-generators/src/generators/pothos/pothos-sentry/index.ts(2 hunks)packages/fastify-generators/src/generators/pothos/pothos/index.ts(3 hunks)packages/fastify-generators/src/generators/prisma/prisma/index.ts(2 hunks)packages/fastify-generators/src/generators/stripe/fastify-stripe/index.ts(2 hunks)packages/fastify-generators/src/generators/vitest/fastify-vitest/index.ts(2 hunks)packages/fastify-generators/src/generators/vitest/prisma-vitest/index.ts(3 hunks)packages/fastify-generators/src/generators/yoga/yoga-plugin/index.ts(4 hunks)packages/react-generators/src/constants/react-packages.ts(1 hunks)packages/react-generators/src/generators/admin/admin-components/index.ts(2 hunks)packages/react-generators/src/generators/apollo/react-apollo/index.ts(3 hunks)packages/react-generators/src/generators/auth/auth-hooks/index.ts(2 hunks)packages/react-generators/src/generators/auth0/react-auth0/index.ts(2 hunks)packages/react-generators/src/generators/core/react-components/index.ts(2 hunks)packages/react-generators/src/generators/core/react-config/index.ts(2 hunks)packages/react-generators/src/generators/core/react-datadog/index.ts(2 hunks)packages/react-generators/src/generators/core/react-error-boundary/index.ts(3 hunks)packages/react-generators/src/generators/core/react-logger/index.ts(2 hunks)packages/react-generators/src/generators/core/react-router/index.ts(3 hunks)packages/react-generators/src/generators/core/react-sentry/index.ts(2 hunks)packages/react-generators/src/generators/core/react-tailwind/index.ts(2 hunks)packages/react-generators/src/generators/core/react-typescript/index.ts(2 hunks)packages/react-generators/src/generators/core/react/index.ts(3 hunks)packages/react-generators/src/generators/core/react/node.ts(1 hunks)packages/sync/src/actions/index.ts(0 hunks)packages/sync/src/actions/write-json-action.ts(0 hunks)packages/sync/src/generators/build-generator-entry.ts(1 hunks)packages/sync/src/generators/build-generator-entry.unit.test.ts(6 hunks)packages/sync/src/generators/generators.ts(3 hunks)packages/sync/src/index.ts(1 hunks)packages/sync/src/output/post-write-commands/run-commands.ts(1 hunks)packages/sync/src/output/post-write-commands/types.ts(1 hunks)packages/sync/src/runner/tests/factories.test-helper.ts(1 hunks)packages/sync/src/test-runners/index.ts(1 hunks)packages/sync/src/test-runners/test-runner.ts(1 hunks)packages/sync/src/utils/create-config-provider-task-with-info.ts(1 hunks)packages/sync/src/utils/create-config-provider-task.ts(1 hunks)packages/sync/src/utils/create-generator.ts(5 hunks)packages/sync/src/utils/create-generator.unit.test.ts(2 hunks)packages/sync/src/utils/create-setup-task-with-info.ts(0 hunks)packages/sync/src/utils/create-setup-task.ts(0 hunks)packages/sync/src/utils/exec.ts(2 hunks)packages/sync/src/utils/index.ts(1 hunks)packages/utils/src/field-map/field-map.ts(8 hunks)plugins/baseplate-plugin-storage/src/generators/fastify/storage-module/index.ts(2 hunks)plugins/baseplate-plugin-storage/src/generators/react/upload-components/index.ts(3 hunks)
💤 Files with no reviewable changes (6)
- packages/sync/src/actions/index.ts
- packages/core-generators/package.json
- packages/sync/src/actions/write-json-action.ts
- packages/sync/src/utils/create-setup-task.ts
- packages/core-generators/src/generators/node/node/index.ts
- packages/sync/src/utils/create-setup-task-with-info.ts
🧰 Additional context used
🧬 Code Definitions (53)
packages/core-generators/src/generators/node/node/package-dependencies-container.unit.test.ts (1)
packages/core-generators/src/generators/node/node/package-dependencies-container.ts (1)
NodePackageDependenciesContainer(21-128)
packages/react-generators/src/generators/core/react-typescript/index.ts (1)
packages/core-generators/src/writers/json.ts (1)
writeJsonToBuilder(25-42)
packages/sync/src/generators/build-generator-entry.ts (1)
packages/sync/src/generators/generators.ts (1)
GeneratorTask(132-185)
packages/fastify-generators/src/generators/email/fastify-postmark/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/react-generators/src/generators/core/react-tailwind/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
packages/react-generators/src/generators/core/react-logger/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
packages/fastify-generators/src/generators/vitest/fastify-vitest/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodeTask(76-86)packages/sync/src/generators/generators.ts (1)
createGeneratorTask(193-201)packages/core-generators/src/generators/node/vitest/index.ts (1)
vitestProvider(36-36)
packages/react-generators/src/generators/core/react-config/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
plugins/baseplate-plugin-storage/src/generators/react/upload-components/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/constants/core-packages.ts (1)
CORE_PACKAGES(1-27)plugins/baseplate-plugin-storage/src/constants/storage-packages.ts (1)
STORAGE_PACKAGES(1-10)
packages/react-generators/src/generators/core/react-sentry/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
packages/fastify-generators/src/generators/vitest/prisma-vitest/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/fastify-generators/src/generators/prisma/prisma/index.ts (6)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
nodeProvider(69-69)packages/fastify-generators/src/generators/core/fastify/index.ts (1)
fastifyOutputProvider(63-64)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/generators/core/config-service/index.ts (1)
configServiceProvider(47-48)packages/fastify-generators/src/generators/core/fastify-health-check/index.ts (1)
fastifyHealthCheckProvider(24-25)packages/core-generators/src/generators/node/typescript/index.ts (1)
typescriptProvider(113-114)
packages/react-generators/src/generators/core/react-datadog/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
packages/fastify-generators/src/generators/core/fastify-server/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/fastify-generators/src/generators/auth/password-hasher-service/index.ts (4)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)packages/fastify-generators/src/generators/core/root-module/index.ts (1)
appModuleProvider(65-66)
packages/fastify-generators/src/generators/bull/bull-mq/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/fastify-generators/src/generators/core/logger-service/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/react-generators/src/generators/auth/auth-hooks/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
packages/sync/src/generators/build-generator-entry.unit.test.ts (1)
packages/sync/src/generators/generators.ts (1)
GeneratorBundle(213-248)
packages/react-generators/src/generators/core/react-error-boundary/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
plugins/baseplate-plugin-storage/src/generators/fastify/storage-module/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)plugins/baseplate-plugin-storage/src/constants/storage-packages.ts (1)
STORAGE_PACKAGES(1-10)
packages/fastify-generators/src/generators/core/config-service/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/core-generators/src/generators/node/node/node.generator.unit.test.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
nodeGenerator(114-188)packages/sync/src/test-runners/test-runner.ts (1)
createTaskTestRunner(47-107)packages/core-generators/src/constants/node.ts (2)
NODE_VERSION(1-1)PNPM_VERSION(2-2)
packages/core-generators/src/generators/node/vitest/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/core-generators/src/constants/core-packages.ts (1)
CORE_PACKAGES(1-27)
packages/fastify-generators/src/generators/core/fastify-redis/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/fastify-generators/src/generators/pothos/pothos-prisma/index.ts (5)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)packages/fastify-generators/src/generators/pothos/pothos/index.ts (1)
pothosSetupProvider(51-52)packages/fastify-generators/src/generators/prisma/prisma/index.ts (1)
prismaOutputProvider(66-67)
packages/fastify-generators/src/generators/core/fastify-cookie-context/index.ts (4)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)packages/fastify-generators/src/generators/core/fastify-server/index.ts (1)
fastifyServerProvider(53-54)
packages/fastify-generators/src/generators/yoga/yoga-plugin/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/fastify-generators/src/generators/bull/fastify-bull-board/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/fastify-generators/src/generators/core/fastify-sentry/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/react-generators/src/generators/core/react-components/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
packages/fastify-generators/src/generators/email/fastify-sendgrid/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/sync/src/test-runners/test-runner.ts (3)
packages/sync/src/generators/generators.ts (6)
ProviderExportMap(33-35)InferExportProviderMap(47-51)ProviderDependencyMap(40-42)InferDependencyProviderMap(56-60)GeneratorTask(132-185)GeneratorTaskResult(102-116)packages/sync/src/output/post-write-commands/types.ts (1)
PostWriteCommand(52-61)packages/sync/src/generators/build-generator-entry.ts (1)
GeneratorInfo(9-22)
packages/fastify-generators/src/generators/core/root-module/index.ts (1)
packages/sync/src/utils/create-config-provider-task.ts (1)
createConfigProviderTask(88-122)
packages/core-generators/src/generators/node/prettier/index.ts (2)
packages/core-generators/src/constants/core-packages.ts (1)
CORE_PACKAGES(1-27)packages/core-generators/src/writers/json.ts (1)
writeJsonToBuilder(25-42)
packages/sync/src/utils/create-config-provider-task.ts (2)
packages/utils/src/field-map/field-map.ts (5)
FieldMapSchema(163-163)FieldMap(171-173)FieldMapValues(166-168)FieldMapSchemaBuilder(176-223)createFieldMap(238-257)packages/sync/src/generators/generators.ts (2)
GeneratorTask(132-185)createGeneratorTask(193-201)
packages/fastify-generators/src/generators/auth/auth/index.ts (1)
packages/sync/src/utils/create-config-provider-task.ts (1)
createConfigProviderTask(88-122)
packages/sync/src/utils/create-config-provider-task-with-info.ts (2)
packages/utils/src/field-map/field-map.ts (4)
FieldMapSchema(163-163)FieldMapValues(166-168)FieldMapSchemaBuilder(176-223)createFieldMap(238-257)packages/sync/src/generators/generators.ts (2)
GeneratorTask(132-185)createGeneratorTask(193-201)
packages/react-generators/src/generators/core/react-router/index.ts (2)
packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
packages/core-generators/src/generators/node/node/node.generator.ts (7)
packages/core-generators/src/constants/node.ts (2)
NODE_VERSION(1-1)PNPM_VERSION(2-2)packages/core-generators/src/generators/node/node/package-dependencies-container.ts (1)
NodePackageDependencies(13-16)packages/sync/src/generators/generators.ts (3)
TaskRunContext(121-126)AnyGeneratorTask(191-191)createGeneratorTask(193-201)packages/sync/src/utils/create-config-provider-task.ts (1)
createConfigProviderTask(88-122)packages/sync/src/utils/create-generator.ts (1)
createGenerator(108-152)packages/core-generators/src/providers/project.ts (1)
projectProvider(7-8)packages/sync/src/output/post-write-commands/types.ts (1)
POST_WRITE_COMMAND_PRIORITY(6-19)
packages/fastify-generators/src/generators/core/fastify/setup-fastify-typescript.ts (2)
packages/sync/src/generators/generators.ts (2)
createGeneratorTask(193-201)AnyGeneratorTask(191-191)packages/core-generators/src/generators/node/typescript/index.ts (1)
typescriptSetupProvider(174-174)
packages/fastify-generators/src/generators/pothos/pothos/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (2)
createNodePackagesTask(93-104)nodeProvider(69-69)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/react-generators/src/generators/admin/admin-components/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
packages/fastify-generators/src/generators/stripe/fastify-stripe/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/react-generators/src/generators/apollo/react-apollo/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (2)
createNodePackagesTask(93-104)createNodeTask(76-86)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
packages/fastify-generators/src/generators/auth/auth-plugin/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/fastify-generators/src/generators/pothos/pothos-sentry/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/fastify-generators/src/generators/core/axios/index.ts (5)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/core-generators/src/constants/core-packages.ts (1)
CORE_PACKAGES(1-27)packages/fastify-generators/src/generators/core/error-handler-service/index.ts (1)
errorHandlerServiceSetupProvider(45-48)packages/core-generators/src/generators/node/typescript/index.ts (1)
typescriptProvider(113-114)
packages/fastify-generators/src/generators/auth0/auth0-module/index.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodePackagesTask(93-104)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
packages/react-generators/src/generators/core/react/node.ts (3)
packages/core-generators/src/generators/node/node/node.generator.ts (1)
createNodeTask(76-86)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/react-generators/src/constants/react-packages.ts (1)
REACT_PACKAGES(1-64)
packages/sync/src/utils/create-generator.ts (1)
packages/sync/src/generators/generators.ts (2)
AnyGeneratorTask(191-191)GeneratorBundle(213-248)
packages/core-generators/src/generators/node/node/package-dependencies-container.ts (1)
packages/utils/src/field-map/field-map.ts (1)
FieldContainer(4-6)
packages/fastify-generators/src/generators/core/fastify/index.ts (4)
packages/core-generators/src/generators/node/node/node.generator.ts (2)
nodeConfigProvider(112-112)createNodeTask(76-86)packages/fastify-generators/src/generators/core/fastify/setup-fastify-typescript.ts (1)
fastifyTypescriptTask(6-36)packages/core-generators/src/utils/extract-packages.ts (1)
extractPackageVersions(7-14)packages/fastify-generators/src/constants/fastify-packages.ts (1)
FASTIFY_PACKAGES(1-95)
🔇 Additional comments (252)
packages/core-generators/src/utils/index.ts (1)
1-3: LGTM - Good barrel file patternThis is a clean implementation of a barrel file pattern that consolidates exports from multiple utility modules. This approach makes imports cleaner in consumer code and centralizes utility exports in a single location.
packages/core-generators/src/index.ts (1)
6-6: Approval: Good consolidation of utility exportsThe change simplifies the export structure by importing from the new consolidated utils index file, making the codebase more maintainable. This approach is consistent with the module organization pattern used throughout the codebase.
packages/fastify-generators/src/constants/fastify-packages.ts (3)
69-71: LGTM - Added Pothos tracing plugins for Sentry integrationThese additions align well with the Sentry packages already in the codebase, providing tracing capabilities for Pothos GraphQL.
82-82: LGTM - Added Auth0 verification packageThis addition complements the existing Auth0 package and enhances authentication capabilities.
92-94: LGTM - Added BullMQ for job queue managementGood addition of BullMQ which works with the existing Bull Board packages and enables better job queue management.
packages/sync/src/utils/create-generator.unit.test.ts (2)
93-93: Consistent with earlier task structure changeThis change aligns with the other task structure modifications in this file, ensuring consistency across the test.
41-45:Details
❓ Verification inconclusive
Approval: Data structure refactoring from array to object
Changing the tasks structure from an array to an object with task names as keys improves lookup performance and better supports the unit testing improvements mentioned in the PR objectives.
🏁 Script executed:
#!/bin/bash # Check for any other instances of the old tasks array structure that might have been missed in the refactoring rg -A 2 -B 2 "tasks: \[" --type tsLength of output: 8438
Action Required: Verify Consistency of Tasks Data Structure
The refactoring in
packages/sync/src/utils/create-generator.unit.test.ts—changing the tasks structure from an array to an object—is solid and indeed improves lookup performance as intended. However, our search has surfaced several instances in other test files where the tasks are still defined as arrays. Please verify whether these discrepancies are intentional (e.g., serving different testing contexts) or if they should be updated for consistency across the codebase.
- Affected Files:
packages/sync/src/generators/build-generator-entry.unit.test.tspackages/sync/src/runner/generator-runner.unit.test.tspackages/sync/src/runner/dependency-map.unit.test.tspackages/fastify-generators/src/generators/auth/auth/index.ts (1)
6-29: Good refactoring to the task-based approach!The change from
createSetupTasktocreateConfigProviderTaskaligns well with the PR objectives of improving testability. This approach allows for more isolated testing of generator functionality by encapsulating configuration in a dedicated provider. The schema definition remains the same, ensuring backward compatibility while providing a clearer separation of concerns.packages/fastify-generators/src/generators/core/fastify/setup-fastify-typescript.ts (1)
1-36: Excellent refactoring to task-based approach!This change significantly improves testability by:
- Explicitly declaring dependencies on
typescriptSetup- Focusing the task on TypeScript configuration only, removing package installation logic
- Using a consistent task pattern that can be tested in isolation
The task pattern makes it much easier to unit test this functionality by allowing dependencies to be mocked and assertions to be made on the specific changes to the TypeScript configuration.
packages/sync/src/index.ts (1)
7-7: Great addition of test runner exports!Adding the test runners export directly supports the PR's goal of enabling better unit testing of generators. This makes testing utilities accessible from the main package, improving the developer experience when writing tests for generators.
packages/core-generators/src/writers/index.ts (1)
1-1: Helpful addition of JSON writer exports!Adding JSON writer exports enhances the toolkit available for generators and testing. This addition likely supports the overall goal of improving testability by providing utilities to serialize/deserialize test fixtures, configurations, or comparison outputs when testing generators.
packages/core-generators/src/constants/node.ts (3)
1-2:Details
✅ Verification successful
Node and PNPM version constants added.
These constants define specific versions for Node.js and PNPM, which helps standardize versions across generators and improves testability by centralizing version references.
🏁 Script executed:
#!/bin/bash # Verify if these constants are referenced elsewhere in the codebase echo "Checking usage of NODE_VERSION and PNPM_VERSION constants..." rg -A 2 "NODE_VERSION|PNPM_VERSION" --type tsLength of output: 2214
Constants are correctly defined and consistently referenced across the codebase.
- The constants in
packages/core-generators/src/constants/node.tsare properly defined.- They are imported and used in both the generator (
packages/core-generators/src/generators/node/node/node.generator.ts) and its corresponding unit tests (packages/core-generators/src/generators/node/node/node.generator.unit.test.ts).No changes are needed based on the current verification.
1-1:Details
✅ Verification successful
Verify if this is a valid Node.js version.
The Node.js version specified (22.14.0) appears quite high, as Node.js versioning typically doesn't reach minor versions this high.
🌐 Web query:
What is the latest version of Node.js as of April 2025?💡 Result:
The latest version of Node.js as of April 2025 is Node.js 23.11.0, released on April 1, 2025. This version is part of the Current release line, which receives regular updates until its end-of-life in June 2025[8].
Key details about recent Node.js versions:
- Node.js 22 (LTS): Latest version 22.14.0 (released February 11, 2025), supported until April 2027[4]
- Node.js 20 (LTS): Latest version 20.19.0 (released March 13, 2025), supported until April 2026[4]
- Node.js 18: Final version 18.20.8 (March 27, 2025)[3][10], scheduled for end-of-life on April 30, 2025[4][7]
For production environments, Node.js 22.x (LTS) remains the recommended choice due to its long-term support until 2027[4][8]. However, developers should plan upgrades from Node.js 18 before its April 2025 end-of-life date to maintain security updates[3][7].
Citations:
- 1: https://devblogs.microsoft.com/azure-sdk/announcing-the-end-of-support-for-node-js-18-x-in-the-azure-sdk-for-javascript/
- 2: https://docs.snowflake.com/en/release-notes/clients-drivers/nodejs-2025
- 3: https://nodejs.org/en/blog/release/v18.20.8
- 4: https://www.herodevs.com/blog-posts/node-js-end-of-life-dates-you-should-be-aware-of
- 5: https://nodejs.org/en/blog/vulnerability/january-2025-security-releases
- 6: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/which-node-js-version-is-supported-by-aem-cloud/m-p/731176
- 7: https://nodejs.org/en/blog/announcements/v18-release-announce
- 8: https://en.wikipedia.org/wiki/Node.js
- 9: https://community.auth0.com/t/node-js-22-or-20-for-running-actions/153963
- 10: https://nodejs.org/blog/release/v18.20.8
Verified: Node.js Version is Correct
After checking the latest releases as of April 2025, it's confirmed that Node.js 22.14.0 is the current LTS version (released February 11, 2025) and remains the recommended version for long-term support. No changes are needed for the constant defined in
packages/core-generators/src/constants/node.ts.
2-2:Details
❓ Verification inconclusive
Verify PNPM version compatibility.
Ensure this PNPM version is compatible with the specified Node.js version.
🌐 Web query:
What is the latest version of PNPM as of April 2025 and which Node.js versions does it support?💡 Result:
As of April 2025, the latest version of pnpm is 10.7.1, released on April 1, 2025[7]. This version maintains compatibility with Node.js 18, 20, and 22, as shown in pnpm's support table[1][4].
Key details about compatibility:
- pnpm 10.x officially supports:
- Node.js 18 (minimum v18.12)[1][3]
- Node.js 20[1][6]
- Node.js 22[1][4]
- Older Node.js versions like 14 and 16 are unsupported[1][4]
For optimal performance and security, the pnpm team recommends using Node.js 20 (Maintenance LTS) or Node.js 22 (Active LTS)[6][9]. Projects encountering "Unsupported Node.js version" errors typically need to upgrade Node.js to v18.12 or newer[3].
Citations:
- 1: https://pnpm.io/installation
- 2: https://www.joshfinnie.com/blog/switching-to-pnpm-for-everything-nodejs/
- 3: https://answers.netlify.com/t/deployment-using-node-js-version-different-from-the-settings/116874
- 4: https://endoflife.date/pnpm
- 5: https://prateeksha.com/blog/pnpm-vs-npm-vs-yarn-key-differences-and-which-one-you-should-use-in-2025
- 6: https://devcenter.heroku.com/articles/nodejs-support
- 7: https://github.com/pnpm/pnpm/releases
- 8: https://pnpm.io/package_json
- 9: https://nodejs.org/en/about/previous-releases
- 10: https://community.chocolatey.org/packages/pnpm
Action: Confirm PNPM Version Compatibility and Consider an Update
The constant
PNPM_VERSIONinpackages/core-generators/src/constants/node.tsis set to'10.6.5'. Our research indicates that pnpm 10.x officially supports Node.js 18 (minimum v18.12), Node.js 20, and Node.js 22. As of April 2025, the latest release is 10.7.1. Please verify that the Node.js version used in your project meets these requirements, and consider updating the version to'10.7.1'if there’s no conflict with your current setup.packages/sync/src/test-runners/index.ts (1)
1-1:Details
✅ Verification successful
Export added for test runner.
This export statement makes the test runner functionality available through the index file, providing a cleaner import interface for consumers and aligning with the PR's goal of improving generator testing.
🏁 Script executed:
#!/bin/bash # Check the implementation of the test-runner.js file to understand what's being exported echo "Checking the test-runner.js implementation..." cat packages/sync/src/test-runners/test-runner.js 2>/dev/null || cat packages/sync/src/test-runners/test-runner.ts 2>/dev/null || echo "Test runner file not found in expected location"Length of output: 3497
Test Runner Export Verified and Approved
The export in
packages/sync/src/test-runners/index.tscorrectly re-exports the test runner functionality (from the compiled output file) as intended. The implementation intest-runner.tsconfirms that the interface exposed via the index is consistent with the desired functionality for improving generator testing. No further changes are required.packages/core-generators/src/generators/node/_composers/node.ts (1)
8-8:Details
✅ Verification successful
Import path updated for nodeGenerator.
The import path has been updated to reflect a more specific file location, changing from the generic index file to a dedicated generator file. This improves code organization and makes dependencies more explicit.
🏁 Script executed:
#!/bin/bash # Verify that the node.generator.js file exists and exports nodeGenerator echo "Checking for nodeGenerator export in the new location..." rg -A 3 "export const nodeGenerator" packages/core-generators/src/generators/node/node/node.generator.ts # Check if any other imports of nodeGenerator need to be updated echo "Checking for any other imports that might need updating..." rg -A 1 "import.*nodeGenerator.*from.*node/index" --type tsLength of output: 543
Verified: The updated import path for nodeGenerator is correct.
- The file at
packages/core-generators/src/generators/node/node/node.generator.tscorrectly exportsnodeGenerator, confirming that the dedicated generator file is in use.- No outdated import references to
node/indexwere found in the codebase.packages/sync/src/output/post-write-commands/run-commands.ts (1)
41-41:Details
✅ Verification successful
Added environment variables support to command execution.
The addition of the
envproperty allows passing environment variables to post-write commands, enhancing flexibility when executing commands with specific environment requirements. This improvement supports the PR's goal of better testability.
🏁 Script executed:
#!/bin/bash # Verify the PostWriteCommand type definition includes the env property echo "Checking if PostWriteCommand type includes env property..." rg -A 20 "type PostWriteCommand" --type ts # Check the executeCommand function to ensure it handles the env property echo "Checking if executeCommand function handles the env property..." rg -A 10 "function executeCommand" --type tsLength of output: 11073
Environment Variables Enhancement Verified
The changes introduce and utilize the
envproperty as intended:
- The PostWriteCommand type now supports the
envproperty (verified in the tests).- The executeCommand function in
packages/sync/src/utils/exec.tsproperly handles the environment variables passed viacommand.options?.env.These modifications align with the goal of enhancing flexibility and testability for post-write command execution.
packages/sync/src/output/post-write-commands/types.ts (1)
43-46: Good addition of environment variable support for post-write commandsThis feature enhances the flexibility of post-write commands by allowing them to run with specific environment variables, which will be useful for testing across different environments.
.changeset/hot-trees-take.md (1)
1-9: Good documentation of the patch updatesThe changeset correctly documents the patch updates for the affected packages, with a clear description of the purpose: refactoring the node generator for more ergonomic usage.
.changeset/shaky-spoons-add.md (1)
1-8: Changeset aligns well with PR objectivesThis changeset clearly documents the refactoring of generation methods to enable better unit testing of generator tasks, which directly aligns with the PR title and objectives.
packages/core-generators/src/generators/node/index.ts (1)
4-4:Details
✅ Verification successful
Export path updated to reflect restructured code
The export path now points to
node.generator.jsinstead of a potential previousindex.jsfile. This change reflects the reorganization of the Node generator code to improve testability.
🏁 Script executed:
#!/bin/bash # Verify that node.generator.js exists and check what it exports find packages/core-generators/src/generators/node -name "*.ts" | grep -E 'node(\.generator)?\.ts'Length of output: 231
The export path correctly reflects the new folder structure.
- Verified that the source file is now located at
packages/core-generators/src/generators/node/node/node.generator.ts, which aligns with the updated export statement inpackages/core-generators/src/generators/node/index.ts.- The change from a potential previous
index.jstonode.generator.jsis appropriate given the reorganization for improved testability.packages/react-generators/src/constants/react-packages.ts (1)
33-37: Well-structured addition of date picker packagesThe date picker packages have been properly added with appropriate versions and are well-organized under a clear comment heading.
packages/fastify-generators/src/generators/pothos/pothos-scalar/index.ts (1)
108-111: Improved package dependency managementThis refactoring consolidates dependency management into a single, more structured method call with explicit separation between production and development dependencies. This is a cleaner approach that's likely more maintainable and easier to test.
The change is part of the broader refactoring to improve generator testability mentioned in the PR objectives.
packages/sync/src/utils/exec.ts (1)
6-6: Enhanced flexibility with custom environment variablesAdding an optional environment variables property to the ExecOptions interface improves flexibility for command execution, especially useful for testing scenarios.
packages/sync/src/generators/build-generator-entry.ts (1)
110-110: Structural change from array to object improves flexibilityChanging from
tasks.maptoObject.values(tasks).mapindicates tasks are now stored as an object rather than an array. This provides more flexibility in how tasks are organized and referenced, which aligns well with the PR objective of improving unit testing capabilities.packages/core-generators/src/providers/project.ts (1)
1-1: Improved provider type specificityChanging from
createProviderTypetocreateOutputProviderTypeenhances type safety and clarifies the provider's role as an output provider. This is a positive change that makes the code more self-documenting and aligns with the refactoring goal of improving testability by being more explicit about component behaviors.Also applies to: 7-8
packages/sync/src/utils/index.ts (1)
3-4:Details
❓ Verification inconclusive
Architectural shift from setup tasks to config provider tasks
The replacement of setup task exports with config provider task exports represents a positive architectural change toward more modular and testable configuration management. This aligns well with the PR objective of improving testing capabilities.
However, ensure that any existing code depending on the removed setup task exports has been properly migrated to use the new config provider tasks to maintain backward compatibility.
🏁 Script executed:
#!/bin/bash # Check if there are any remaining references to the removed setup task exports echo "Checking for references to removed setup task exports..." rg "createSetupTask|createSetupTaskWithInfo" --type tsLength of output: 179
Architectural shift from setup tasks to config provider tasks
The updated exports in
packages/sync/src/utils/index.tsclearly reflect a move toward a more modular and testable design, aligning well with the PR’s objective of improving unit testing. Although our initial check in TypeScript files revealed no lingering references to the removed setup task exports, please ensure—using the above full-repository search—that no usages remain in non-TypeScript files (or elsewhere). This is to safeguard backward compatibility across the codebase.
🏁 Script executed:
#!/bin/bash echo "Searching for references to removed setup task exports across the entire repository..." rg -i "create[-]?setup[-]?task" .Length of output: 340
Architectural shift from setup tasks to config provider tasks
The changes in
packages/sync/src/utils/index.tsclearly enhance modularity and testability in line with the PR’s intent. Our repository-wide searches for references to the removed setup task exports (e.g., looking for "createSetupTask" patterns) returned no results, indicating that the migration appears complete.However, since the automated searches produced minimal output and to ensure no indirect dependencies are overlooked (especially in non-TypeScript files), please perform a final manual verification of any potential usages that might not be caught by the tooling.
packages/core-generators/src/utils/extract-packages.ts (1)
1-14: Well-designed utility function with strong typingThis utility function provides a clean and type-safe way to extract specific package versions, which supports the PR objective of better testability by enabling more modular package management. The use of generics preserves type information effectively.
packages/fastify-generators/src/generators/core/fastify-scripts/index.ts (2)
40-40: Method signature updated to include taskId parameterThe
runmethod now accepts ataskIdparameter, which is destructured from the second argument. This enhances the generator's testability by providing a way to track and identify task operations.
44-53: Improved script management with taskId trackingThe implementation has been improved by replacing
node.addScriptswithnode.scripts.mergeObj, which now includes thetaskIdparameter. This change provides better tracking of script additions by associating them with specific task identifiers, which facilitates testing and debugging.packages/sync/src/generators/generators.ts (3)
187-191: Added AnyGeneratorTask type for better flexibilityGood addition of the
AnyGeneratorTasktype, which enhances flexibility when working with generator tasks without needing to specify exact generic types. This will be particularly useful in contexts where the precise types aren't required but type safety is still maintained.
213-218: Enhanced GeneratorBundle interface with generic TaskConfigsThe
GeneratorBundleinterface has been improved with a generic parameterTaskConfigsthat defaults to a record ofAnyGeneratorTask. This change provides better type safety and flexibility when working with different task configurations.
242-242: Changed tasks from array to record for better accessTasks property has been changed from an array to a record (dictionary) with string keys. This enables direct access to specific tasks by name, which significantly improves testability by allowing tests to target individual tasks precisely.
packages/fastify-generators/src/generators/vitest/prisma-vitest/index.ts (3)
3-12: Added package management utility importsGood addition of
createNodePackagesTaskandextractPackageVersionsimports. These utilities will improve package dependency management by providing dedicated functionality rather than handling it within the generator tasks directly.
39-44: Improved separation of concerns with dedicated package management taskExcellent refactoring by adding a dedicated task for package management using
createNodePackagesTask. This approach:
- Separates package management concerns from the main generator logic
- Makes the code more maintainable and testable
- Provides a consistent pattern for managing dependencies
This is in line with the PR's goal of improving generator testing ergonomics.
57-57: Simplified run method by removing node parameterAppropriately removed the
nodeparameter from therunmethod since package management has been moved to a dedicated task. This simplifies the method signature and reduces the responsibility of the main generator task.packages/fastify-generators/src/generators/auth/password-hasher-service/index.ts (3)
3-9: Added package management utility importsGood addition of
createNodePackagesTaskandextractPackageVersionsimports to provide dedicated functionality for package management.
35-37: Added dedicated task for package dependency managementWell-structured implementation of a dedicated task for managing the
@node-rs/argon2package dependency usingcreateNodePackagesTask. This approach:
- Centralizes package management outside the main generator task
- Makes dependencies more explicit and traceable
- Follows a consistent pattern with other generators
This refactoring improves testability and maintainability of the code.
48-48: Simplified run method by removing node parameterThe
runmethod has been appropriately simplified by removing thenodeparameter, as package management has been moved to a separate dedicated task. This separation of concerns makes the generator easier to test and maintain.packages/react-generators/src/generators/core/react-typescript/index.ts (2)
4-4: Updated imports to support the refactored generator pattern.The imports have been appropriately updated to use the new
writeJsonToBuilderutility and explicit imports ofcreateGeneratorandcreateGeneratorTask.Also applies to: 6-6
63-74: Good refactoring of thebuildfunction.The function has been simplified from an async function to a synchronous one, which makes it more testable. The addition of the
idparameter provides better traceability when writing files.packages/core-generators/src/writers/json.ts (2)
1-20: Well-defined interface with clear documentation.The
WriteJsonToBuilderOptionsinterface is properly typed and includes helpful JSDoc comments explaining each property's purpose.
25-42: Clean implementation of the JSON writer.This function effectively encapsulates the logic for writing formatted JSON to a file through the builder pattern. The implementation correctly:
- Extracts required properties
- Formats the JSON with proper indentation
- Sets
shouldFormat: truefor consistent formattingThis approach improves testability by removing side effects from the previous implementation.
packages/core-generators/src/generators/node/node/package-dependencies-container.unit.test.ts (5)
1-12: Well-structured test initialization.Good use of the Vitest framework with proper test organization and setup.
14-30: Comprehensive testing of basic functionality.These tests effectively verify the container's ability to add production and development dependencies correctly.
32-40: Good edge case testing for version compatibility.This test verifies that the container correctly merges compatible versions of the same dependency, demonstrating how it handles semantic versioning.
42-50: Important validation of error handling.This test ensures that the container correctly rejects incompatible package versions, which is critical for preventing dependency conflicts.
52-88: Thorough testing of advanced functionality.These tests cover important edge cases:
- Upgrading dependencies from dev to prod
- Adding multiple dependencies at once
- Merging complex dependency sets
This comprehensive test coverage will help ensure the container maintains its contract during future refactoring.
plugins/baseplate-plugin-storage/src/generators/fastify/storage-module/index.ts (2)
4-5: Added new utility imports for package management.The addition of
createNodePackagesTaskandextractPackageVersionsimports prepares for the refactoring of Node package handling.
67-75: Improved dependency management with task-based approach.This change replaces direct manipulation of node packages with a declarative task-based approach, which:
- Makes the code more testable by isolating package management logic
- Improves maintainability by centralizing dependency specification
- Uses
extractPackageVersionsto selectively pull from the constants fileThis aligns perfectly with the PR objective of enabling better unit testing of generators.
packages/fastify-generators/src/generators/core/root-module/index.ts (2)
12-12: Import update aligns with task creation refactoringThe import statement has been updated to use
createConfigProviderTaskinstead of the previouscreateSetupTask, which aligns with the task-based approach mentioned in the PR objectives.
33-42: Task creation approach updated for better testingThe function call has been changed to use
createConfigProviderTaskwhich provides a more consistent approach for configuration tasks throughout the codebase. This supports the PR's goal of enabling better unit testing by standardizing how configuration providers are created.packages/fastify-generators/src/generators/email/fastify-postmark/index.ts (3)
2-3: New imports support package management refactoringThese new imports support the task-based approach for package management that's being implemented across the codebase.
29-31: Package management moved to dedicated taskMoving the Postmark package dependency to a dedicated task using
createNodePackagesTaskis a good refactoring step. This separates package management concerns from the main task logic, which improves testability.
41-41: Removed node dependency from run parametersThe
nodeparameter has been removed from the run function signature since package management is now handled by the dedicated task above. This simplifies the function and makes it more focused on its core responsibility.packages/react-generators/src/generators/auth/auth-hooks/index.ts (3)
4-5: New imports for task-based package managementThe addition of these imports supports the new approach to package management using dedicated tasks.
42-45: Dedicated task for package dependenciesThis new task clearly separates production and development dependencies. Using
extractPackageVersionsensures consistent versioning by referencing the central package constants.
59-66: Simplified run function signatureThe removal of the
nodeparameter from the run function enhances testability by eliminating direct manipulation of the node provider. The function is now more focused on its core responsibilities rather than package management.plugins/baseplate-plugin-storage/src/generators/react/upload-components/index.ts (3)
5-5: Import for task-based package managementThe addition of this import supports the new approach to package management using dedicated tasks.
40-47: Centralized package management taskThis implementation of
createNodePackagesTaskorganizes multiple package dependencies from different sources into a single dedicated task. This makes package dependencies explicit and separates concerns effectively.
59-59: Streamlined run function signatureThe removal of the
nodeparameter from the run function improves testability by removing direct manipulation of external services, allowing the function to focus on its core responsibilities.packages/react-generators/src/generators/core/react-datadog/index.ts (3)
2-3: Added essential utility imports for improved package managementThe addition of
createNodePackagesTaskandextractPackageVersionsimports indicates a shift toward a more modular approach for package management, aligning with the PR's goal of enabling better unit testing.
35-37: Improved package management with targeted dependency extractionThe implementation now uses a task-based approach with
createNodePackagesTaskand selectively extracts only the Datadog package fromREACT_PACKAGESusingextractPackageVersions. This is a significant improvement over directly manipulating the node provider.
49-49: Signature simplified by removing node dependencyThe
runmethod signature has been updated to remove thenodeparameter, which is consistent with the migration to task-based package management. This simplifies the function signature and makes the code more testable.packages/core-generators/src/generators/node/eslint/index.ts (5)
14-14: Updated import path to reflect new module structureThe import path for
nodeProviderhas been updated to referencenode.generator.jsinstead ofindex.js, reflecting a more organized and explicit module structure.
42-42: Enhanced run method with task traceabilityThe
runmethod now includes ataskIdparameter, which improves traceability and allows for better identification of task-specific operations in logs and debugging.
75-92: Updated package management to use structured APIPackage management has been updated to use
node.packages.addDevPackagesinstead ofnode.addDevPackages, indicating a more structured and namespaced API that improves testability and modularity.
93-97: Script management updated with task ID for traceabilityThe script setting mechanism has been updated to use
node.scripts.setwith an additionaltaskIdparameter, which enhances traceability and allows for better identification of which task created which script.
99-99: Simplified ESM detection with property accessThe code now uses
node.isEsmas a property rather than a method callnode.isEsm(), resulting in cleaner, more concise code that follows modern JavaScript property access patterns.packages/core-generators/src/generators/node/vitest/index.ts (4)
15-15: Added package extraction utility importThe addition of the
extractPackageVersionsimport provides a cleaner way to selectively include only the necessary packages, improving code maintainability.
19-22: Enhanced import organization with task-based approachThe imports now include
createNodePackagesTaskalong withnodeProvider, reflecting the shift towards a task-based package management approach that improves testability.
43-48: Implemented task-based package managementAdded
createNodePackagesTaskwith selective package extraction forvitestandvite-tsconfig-paths, which simplifies package management and improves modularity.
68-68: Simplified ESM detection with property accessChanged from
node.isEsm()method call tonode.isEsmproperty access, resulting in more concise code that follows modern JavaScript property access patterns.packages/fastify-generators/src/generators/core/request-context/index.ts (3)
5-6: Added essential utilities for package managementThe addition of
createNodePackagesTaskandextractPackageVersionsimports enables a more declarative and modular approach to package management.
64-68: Implemented task-based package management for better testabilityAdded a dedicated task using
createNodePackagesTaskthat extracts only the@fastify/request-contextpackage fromFASTIFY_PACKAGES. This approach separates concerns and improves testability by moving package management to a dedicated task.
78-78: Simplified dependency injection by removing node parameterThe
runmethod no longer requires thenodeparameter since package management has been moved to a dedicated task. This simplifies the function signature and improves testability by reducing dependencies.packages/fastify-generators/src/generators/bull/fastify-bull-board/index.ts (4)
2-3: Well-structured import of new utility functionsThe introduction of
createNodePackagesTaskandextractPackageVersionsimports aligns with the PR's goal of improving testability by modularizing dependency management.
38-48: Good refactoring of package managementUsing the dedicated
createNodePackagesTaskfunction to manage dependencies improves modularity and testability by extracting specific packages from the centralizedFASTIFY_PACKAGESconstant.
61-61: Appropriate signature update with dependency removalRemoving the
nodeparameter from the task's run function signature is consistent with the shift away from direct node provider manipulation, and improves the testability of the generator.
125-127: Improved package version managementUsing
extractPackageVersionsto retrieve specific package versions creates a more consistent and maintainable approach to dependency management across generators.packages/fastify-generators/src/generators/vitest/fastify-vitest/index.ts (3)
2-2: Good import refactoringReplacing the
nodeProviderimport withcreateNodeTaskaligns with the PR's goal of improving testability by providing a more task-oriented approach to managing node operations.
28-36: Well-structured script management taskThe new task created with
createNodeTaskencapsulates script management logic in a dedicated, testable unit. This improves modularity and makes the code's intent clearer.
45-45: Appropriate parameter removalRemoving the
nodeparameter from the run method signature is consistent with the shift towards task-based dependency management and improves the generator's testability.packages/fastify-generators/src/generators/auth/auth-plugin/index.ts (2)
2-3: Well-structured import of utility functionsThe introduction of
createNodePackagesTaskandextractPackageVersionsimproves modularity and aligns with the PR's goal of enhancing testability through more isolated and focused tasks.
25-29: Good package management refactoringThe new task created with
createNodePackagesTaskprovides a cleaner, more testable approach to managing package dependencies by isolating this concern in a dedicated task.packages/react-generators/src/generators/core/react-sentry/index.ts (3)
4-5: Well-structured import of utility functionsThe introduction of
createNodePackagesTaskandextractPackageVersionsaligns with the PR's goal of enhancing testability by providing focused utilities for package management.
39-41: Good package management refactoringUsing
createNodePackagesTaskwithextractPackageVersionsto manage the Sentry package dependency improves modularity and testability by isolating package management concerns.
53-53: Appropriate parameter removalRemoving the
nodeparameter from the run method signature reflects the shift away from direct node provider manipulation and improves the testability of the generator.packages/fastify-generators/src/generators/stripe/fastify-stripe/index.ts (2)
2-3: Good addition of utility imports for package management.These imports support the new task-based approach for managing package dependencies, which aligns with the PR's goal of improving unit testing capabilities.
35-40: Great refactoring to use task-based package management.The implementation properly uses the
createNodePackagesTaskwithextractPackageVersionsto specify Stripe dependencies. This approach removes direct manipulation of the node provider, which enables better unit testing of generators as mentioned in the PR objectives.packages/react-generators/src/generators/core/react-tailwind/index.ts (3)
2-4: Good addition of utility imports for package management.These imports support the new task-based approach for managing package dependencies, which improves testability.
39-46: Well-implemented task-based dependency management.The code correctly extracts Tailwind-related development dependencies using the new task-based approach, which improves unit testing capabilities by isolating package management.
57-57: Correctly simplified method signature.The
nodeparameter has been removed from therunmethod since package management is now handled by a dedicated task, which is a cleaner separation of concerns.packages/fastify-generators/src/generators/core/logger-service/index.ts (3)
8-10: Good addition of utility imports for task-based package management.These imports support the new approach for managing package dependencies, aligning with the PR's goal to improve unit testing capabilities.
61-64: Effective implementation of package management task.The code properly separates production and development dependencies for the logger service, using
createNodePackagesTaskwithextractPackageVersions. This approach enhances testability by isolating package management logic.
74-74: Correctly simplified method signature.Removing the
nodeparameter from therunmethod is appropriate since package management is now handled by a dedicated task, improving code organization and testability.packages/react-generators/src/generators/core/react-config/index.ts (3)
8-9: Good addition of utility imports for package management.These imports support the task-based approach for managing package dependencies, which aligns with the PR objective of improving generator testing.
48-50: Effective implementation of Zod dependency management.The code correctly adds the 'zod' package as a production dependency using the task-based approach, which is consistent with the refactoring pattern used throughout the PR.
59-59: Correctly simplified method signature.The method signature has been appropriately simplified by removing the
nodeparameter since package management is now handled by a dedicated task, which improves separation of concerns and testability.packages/fastify-generators/src/generators/core/fastify-redis/index.ts (3)
4-5: Well-structured import additions for package managementThese imports add support for the new task-based approach to manage package dependencies, enhancing modularity.
40-43: Good separation of package management concernsThe implementation correctly replaces direct node manipulation with a dedicated task for package management. This makes the generator more testable by isolating dependency installation logic.
55-55: Appropriately removed node parameter from run methodThe parameter removal reflects the shift from direct node manipulation to task-based package management, making the function more focused on its core responsibilities.
packages/sync/src/utils/create-config-provider-task.ts (5)
1-21: Well-organized imports with appropriate typesThe import structure follows good practices, clearly separating type imports from function imports.
22-44: Well-documented configuration options interfaceThe ConfigProviderTaskOptions interface is properly documented with JSDoc comments that explain each property's purpose.
46-53: Clear type definition with meaningful commentsThe ConfigProviderTaskResult type is well-structured with helpful comments explaining each component of the tuple.
55-87: Excellent documentation with practical examplesThe JSDoc comments provide comprehensive documentation including purpose, behavior, parameter details, return information, and a practical usage example that enhances developer understanding.
88-122: Well-implemented function with clean separation of concernsThe createConfigProviderTask function follows good practices:
- Creates properly named providers with prefixes
- Returns a logically structured tuple
- Implements clean separation between modifiable config and read-only values
- Uses appropriate dependency injection pattern
This implementation enhances testability by making configuration management more modular.
packages/fastify-generators/src/generators/core/fastify-server/index.ts (3)
5-6: Appropriate imports for the package management approachThese imports support the refactored task-based dependency management approach.
77-84: Effective extraction of specific package versionsThe implementation correctly uses extractPackageVersions to manage Fastify-related dependencies. This approach improves testability by isolating package management in a dedicated task.
96-96: Correctly updated run method signatureThe removal of the node parameter from the run method signature aligns with the refactoring pattern to separate package management from core generator logic.
packages/react-generators/src/generators/auth0/react-auth0/index.ts (3)
2-3: Consistent import pattern across generatorsThe imports follow the same pattern as other generator files, maintaining consistency throughout the codebase.
22-24: Clean implementation of package management taskThe createNodePackagesTask implementation correctly extracts the Auth0 React package from the constants file, following the consistent pattern established in other generators.
31-31: Properly refactored method signatureThe run method signature has been correctly updated to remove the node parameter, consistent with the pattern applied across all generators in this refactoring.
packages/react-generators/src/generators/core/react-router/index.ts (3)
7-8: Good addition of utility functions for package management.These new imports bring in functions that centralize package management logic, making the code more maintainable and testable.
53-55: Well-implemented task-based approach for package management.The new task using
createNodePackagesTaskandextractPackageVersionseffectively separates package dependency management from other concerns. This decoupled approach improves testability by allowing package management to be tested independently.
68-68: Clean signature simplification.Removing the
nodeparameter from the function signature is a good refactoring step that aligns with the separation of package management into its own task.packages/sync/src/generators/build-generator-entry.unit.test.ts (7)
11-11: Good update to import requirements.Adding
GeneratorBundleto the imports allows for proper type checking with thesatisfiesoperator.
40-56: Well-structured task object format.Converting from an array to a named object structure makes tasks more identifiable and accessible by key, which enhances testing capabilities. The structure now matches the
GeneratorBundleinterface expectations.
51-53: Improved no-op implementation.Using a comment to indicate a no-operation is clearer than returning an empty object. This explicit approach helps with code readability.
102-112: Consistent task structure in child bundle.This maintains the same pattern as the parent bundle, using a named object structure instead of an array for tasks. The consistency across the codebase improves maintainability.
113-113: Good use of type assertion.Adding
satisfies GeneratorBundleensures type safety and catches potential errors at compile time, which is especially valuable for testing.
126-127: Appropriate empty task object and type assertion.Using an empty object instead of an empty array and adding type assertion maintains consistency with the updated
GeneratorBundleinterface.
198-198: Consistent type assertion throughout.Consistently using type assertions across all bundle definitions ensures type safety throughout the codebase.
packages/fastify-generators/src/generators/yoga/yoga-plugin/index.ts (4)
8-9: Good addition of utility functions for package management.These new imports centralize package management logic, making the code more maintainable and testable.
128-141: Well-structured task for package management.The dedicated task for package management properly separates concerns and improves testability. The comprehensive list of dependencies is well-organized into production and development packages.
247-251: Improved package versioning consistency.Using
extractPackageVersionsensures consistent versioning across the application and improves maintainability. This approach allows for centralized version management.
285-290: Consistent package management approach.This follows the same pattern as other package additions in the file, using
extractPackageVersionsto maintain version consistency across the application.packages/react-generators/src/generators/core/react-error-boundary/index.ts (3)
2-3: Good addition of utility functions for package management.These new imports centralize package management logic, making the code more maintainable and testable.
34-36: Well-implemented task-based approach for package management.The new task using
createNodePackagesTaskandextractPackageVersionseffectively separates package dependency management from other concerns, improving testability.
48-48: Clean signature simplification.Removing the
nodeparameter from the function signature is a good refactoring step that aligns with the separation of package management into its own task.packages/fastify-generators/src/generators/email/fastify-sendgrid/index.ts (3)
2-3: Good addition of utilities for package management.The new imports
createNodePackagesTaskandextractPackageVersionssupport the separation of package management from generator logic, which improves testability.
30-32: Well-implemented package management task.Creating a dedicated task for node package management is a good refactoring approach. Using
extractPackageVersionsto pull specific versions fromFASTIFY_PACKAGESensures consistency across the project.
43-43: Correctly simplified function signature.Removing the
nodeparameter from the run method signature is appropriate since package management has been extracted to a separate task, making this generator easier to test in isolation.packages/fastify-generators/src/generators/prisma/prisma/index.ts (3)
8-8: Good addition of package extraction utility.Adding the
extractPackageVersionsimport supports the refactoring to separate package management concerns.
84-109: Well-structured Node configuration task.This new 'node' task properly encapsulates all Node.js package management and script configuration:
- It correctly handles Prisma client and dev dependencies using
extractPackageVersions- The postinstall script addresses a specific Prisma/pnpm issue (good comment explaining why)
- The seed script configuration is properly integrated with fastifyOutput flags
This separation of concerns improves testability and maintainability.
111-121: Well-refactored schema task.The 'schema' task has been properly simplified by moving node-related operations to the dedicated 'node' task. This separation of concerns enhances testability and clarity.
packages/react-generators/src/generators/admin/admin-components/index.ts (3)
4-5: Good addition of package management utilities.The imports for
createNodePackagesTaskandextractPackageVersionssupport the refactoring to separate package management concerns.
32-34: Well-implemented package management task.Creating a dedicated task for managing the
nanoiddependency is a good approach. UsingextractPackageVersionsto pull the version fromREACT_PACKAGESensures consistency.
44-44: Correctly simplified function signature.Removing the
nodeparameter from the run method signature is appropriate since package management has been extracted to a separate task. This makes the generator easier to test in isolation.packages/fastify-generators/src/generators/core/config-service/index.ts (3)
8-9: Good addition of package management utilities.The imports for
createNodePackagesTaskandextractPackageVersionssupport the refactoring to separate package management concerns.
72-75: Well-implemented package management task.Creating a dedicated task for managing package dependencies is a good approach:
- Production dependencies (
zod,cross-env) are properly specified- Development dependency (
dotenv) is correctly separated- Using
extractPackageVersionsensures version consistency with other parts of the applicationThis separation of concerns improves testability and maintainability.
83-83: Correctly simplified function signature.Removing the
nodeparameter from the run method signature is appropriate since package management has been extracted to a separate task. This makes the generator easier to test in isolation.packages/fastify-generators/src/generators/bull/bull-mq/index.ts (3)
2-3: Properly extracted package management to a dedicated taskThe refactoring extracts package management from the run method to a dedicated task, which improves testability by decoupling concerns. This makes it easier to test both the package management and the main generator task independently.
Also applies to: 16-16, 33-35
49-59: Added taskId parameter for improved task identificationThe run method now accepts a taskId parameter, which is used when merging scripts. This change allows for better tracking of task operations during testing and execution.
70-76: Replaced direct script management with mergeObj methodThe script management is now using
node.scripts.mergeObj()with the taskId parameter, which provides better encapsulation and clarity compared to the previous approach (likely direct manipulation).packages/fastify-generators/src/generators/core/axios/index.ts (2)
2-4: Properly extracted package dependencies to a dedicated taskThe axios package dependency management has been extracted to a separate task using
createNodePackagesTaskandextractPackageVersions. This improves testability and maintains consistency with the new pattern being established across generators.Also applies to: 21-23
26-30: Simplified dependencies by removing nodeProviderThe node parameter has been removed from the dependencies, which simplifies the generator task. Package management is now handled by the dedicated task, allowing the main task to focus on its core responsibilities.
packages/react-generators/src/generators/core/react-logger/index.ts (2)
6-9: Consistently applied the node packages task patternThe refactoring follows the same pattern applied across generators, extracting package management to a dedicated task using
createNodePackagesTaskandextractPackageVersions. This improves testability and maintains consistency.Also applies to: 42-44
46-54: Simplified run method by removing node dependencyThe run method no longer needs to handle package management, which simplifies its implementation and improves testability by reducing its responsibilities.
packages/core-generators/src/generators/node/node/node.generator.unit.test.ts (6)
1-7: Good setup for unit testing the node generatorThe test file properly imports the necessary testing utilities and the generator under test. Using vitest for testing is a good choice for TypeScript projects.
8-19: Well-structured test for project name retrievalThis test properly verifies that the project task correctly returns the project name. The test structure is clean and follows best practices by using a describe block for context and an it block for the specific test case.
21-57: Comprehensive test for package.json generation with default valuesThis test thoroughly validates that the generator creates a package.json with the expected default values. The test checks both the provider exports and the actual file content, which provides good coverage of the generator's functionality.
59-102: Good test coverage for custom configuration valuesThis test ensures that custom configuration values are properly applied to the generated package.json. Testing with a variety of custom values provides confidence that the generator handles different configurations correctly.
104-123: Proper validation of post-write commandsThis test verifies that the generator correctly adds a post-write command for package installation. Checking the command details ensures that the installation will be triggered correctly after file generation.
126-168: Good test for package management through node providerThis test verifies that packages can be added to the node provider and that they appear correctly in the generated package.json. The test demonstrates how the new pattern of using the provider for package management works in practice.
packages/fastify-generators/src/generators/core/fastify-cookie-context/index.ts (3)
2-3: New package management utilities added.The code now imports
createNodePackagesTaskandextractPackageVersionsto enable a more modular approach to package management.
25-27: Improved package management with dedicated task.Package management has been extracted into a dedicated task using
createNodePackagesTask, which enhances testability and separation of concerns. The task extracts the@fastify/cookiepackage version from the centralizedFASTIFY_PACKAGESconstant.
34-34: Simplified run method signature.The
runmethod no longer requires thenodeparameter since package management has been moved to its own dedicated task. This simplifies the function and makes it more focused on its core responsibility.packages/react-generators/src/generators/core/react/node.ts (2)
1-4: Updated imports for task-based approach.The imports have been updated to include
createNodeTaskandextractPackageVersions, enabling the transition to a task-based approach for node operations.
8-42: Refactored node setup to use task-based approach.The original
setupViteNodefunction has been replaced with a constantviteNodeTaskthat usescreateNodeTask. This change:
- Consolidates package management into a single
node.packages.addPackagescall- Uses
extractPackageVersionsto efficiently manage package versions- Updates script handling to use
node.scripts.mergeObjinstead of direct script addition- Updates extra properties handling to use
node.extraProperties.mergeThis refactoring improves testability by encapsulating node setup in a dedicated task, making it easier to mock and verify in unit tests.
packages/react-generators/src/generators/core/react-components/index.ts (3)
4-5: Added package management utilities.The imports for
createNodePackagesTaskandextractPackageVersionshave been added to support the new task-based approach for package management.
78-105: Enhanced dependency management with dedicated tasks.Package management has been refactored to use dedicated tasks:
- A base task that handles common React component dependencies
- A conditional task for date picker packages when
includeDatePickeris trueThis approach:
- Separates package management from the component logic
- Makes dependencies explicit and centralized
- Improves testability by isolating package management
- Maintains conditional logic for optional dependencies
The use of
extractPackageVersionsensures consistent version management from the centralizedREACT_PACKAGESconstant.
116-116: Simplified run method signature.The
runmethod signature has been updated to remove thenodeparameter, as package management has been extracted to dedicated tasks. This creates a cleaner separation of concerns.packages/fastify-generators/src/generators/auth0/auth0-module/index.ts (4)
2-3: Added package management utilities.The imports for
createNodePackagesTaskandextractPackageVersionshave been added to support the task-based approach for package management.
45-54: Conditional package management with dedicated task.A conditional task has been added to manage the
auth0package dependency whenincludeManagementis true. This:
- Improves testability by isolating package management
- Maintains the conditional logic for optional dependencies
- Uses
extractPackageVersionsto get the version from the centralizedFASTIFY_PACKAGESconstantThis separation of concerns makes the code more modular and easier to test.
188-190: Added dedicated task for auth0 verify package.A new dedicated task has been added to manage the
fastify-auth0-verifypackage dependency. This extraction:
- Separates package management from plugin registration
- Improves testability
- Uses
extractPackageVersionsto maintain consistent version managementThis change follows the pattern of separation of concerns applied throughout the PR.
197-197: Simplified plugin registration task.The
runmethod signature of thefastifyAuth0Plugintask has been simplified by removing thenodeparameter, as package management has been moved to a dedicated task. The plugin registration now focuses solely on its core responsibility.packages/fastify-generators/src/generators/pothos/pothos-prisma/index.ts (3)
2-3: Good addition of utility imports.The new imports for
createNodePackagesTaskandextractPackageVersionsset the stage for improved package management.
35-37: Excellent refactoring to decouple package management.This change improves testability by moving package dependency management to a dedicated task. The
createNodePackagesTaskapproach is more modular than directly manipulating the node provider in the main task.
47-47: Clean function signature update.Removing the unused
nodeparameter from the run function signature is a good practice. This reflects the improved architecture where package management has been moved to a dedicated task.packages/fastify-generators/src/generators/core/fastify-sentry/index.ts (5)
9-10: Good addition of utility imports.Adding the
createNodePackagesTaskandextractPackageVersionsimports is consistent with the refactoring pattern across the project.
62-62: Property access instead of method call.Changed from method call
node.isEsm()to property accessnode.isEsm. This is a good consistency improvement ifisEsmis now defined as a property rather than a method.
87-87: Property access instead of method call.Similar to line 62, this change ensures consistent use of
node.isEsmas a property.
117-125: Well-structured package dependency management.This is a good refactoring that:
- Separates production and development dependencies
- Extracts only the needed packages from FASTIFY_PACKAGES
- Improves testability by encapsulating package management in a dedicated task
The approach is more maintainable than directly manipulating the node provider in task run functions.
137-137: Clean function signature update.Removing the unused
nodeparameter from the run function signature is appropriate since package management has been moved to a dedicated task.packages/fastify-generators/src/generators/pothos/pothos-sentry/index.ts (4)
2-3: Good addition of utility imports.Adding the
createNodePackagesTaskandextractPackageVersionsimports is consistent with the refactoring pattern across the project.
12-12: Improved imports organization.Maintaining the FASTIFY_PACKAGES import to extract specific package versions needed by this generator.
26-31: Well-structured package dependency management.Excellent refactoring to move package management to a dedicated task. This approach:
- Makes the code more testable by isolating package installation logic
- Clearly specifies exactly which packages this generator needs
- Maintains consistency with the refactoring pattern across the project
39-39: Clean function signature update.Removing the unused
nodeparameter from the run function signature reflects the improved architecture where package management has been moved to a dedicated task.packages/react-generators/src/generators/core/react/index.ts (6)
9-9: Streamlined node configuration imports.Good replacement of node-related imports with
nodeConfigProvider, which suggests a more centralized approach to node configuration.
26-26: Improved task organization.Importing a pre-defined task
viteNodeTaskinstead of creating it inline improves code organization and reusability.
56-56: Updated dependency management.Changing the dependency from (likely)
nodeSetuptonodeConfigaligns with the architectural changes made to node configuration management.
59-59: Improved ESM configuration.Using
nodeConfig.isEsm.set(true, taskId)provides better traceability with the taskId parameter, which can help with debugging and tracking configuration changes.
63-63: Enhanced task composition.Using the imported
viteNodeTaskdirectly in the tasks array improves modularity and reusability compared to inline task creation.
74-74: Clean function signature update.Removing the unused
nodeparameter from the run function signature is appropriate as node configuration is now handled through the dedicated tasks.packages/react-generators/src/generators/apollo/react-apollo/index.ts (5)
4-7: New imports for task-based approachThese new imports enable the task-based approach for managing node packages and extracting package versions, which aligns with the PR objective of improving unit testing capabilities.
83-95: Good modular approach to dependency managementUsing
createNodePackagesTaskto handle both production and development dependencies makes the code more testable and maintainable by separating concerns. The use ofextractPackageVersionsensures version consistency from a central source.
96-104: Well-structured script management with createNodeTaskThis approach nicely encapsulates script management in a dedicated task, making it easier to test and maintain. The
mergeObjmethod with the 'graphql-codegen' identifier provides good organization of related scripts.
105-114: Clean conditional task handling for subscriptionsGood use of conditional task creation based on feature flags. The additional packages are only added when subscriptions are enabled, which keeps dependencies minimal.
129-129: Simplified function signatureRemoving the
nodeparameter from the run method signature is consistent with the refactoring approach, as node operations have been moved to dedicated tasks.packages/sync/src/test-runners/test-runner.ts (6)
17-26: Well-defined result interface for test runsThis interface clearly defines the shape of test runner results, including exports, outputs, and utility methods for retrieving file contents and post-write commands. This provides a good foundation for testing generator tasks.
28-39: Comprehensive test runner interfaceThe
TaskTestRunnerinterface provides a clean API for running tasks with dependencies and optionally executing code on the generated providers. The Promise-based approach handles async operations appropriately.
41-45: Flexible options for test runner creationThe options interface allows for customization of task and generator identifiers, which is helpful for testing in different contexts.
47-61: Type-safe function signature for test runner creationGood use of TypeScript generics to maintain type safety across the different maps involved in generator tasks. This ensures that the test runner will work correctly with various task configurations.
62-87: Properly executed task initialization and provider manipulationThe implementation correctly handles task execution, including initialization and running the provided function on the exported providers. The use of
Promise.resolve()ensures proper handling of both synchronous and asynchronous operations.
88-104: Comprehensive result object with utility methodsThe returned result object includes all necessary data from the task execution and provides utility methods for accessing file contents and post-write commands. The handling of binary file contents is particularly good.
packages/fastify-generators/src/generators/core/fastify/index.ts (6)
4-7: Updated imports for task-based approachThese imports enable the new task-based approach and node configuration, replacing the direct node manipulation approach. The
extractPackageVersionsfunction is particularly useful for managing package versions from a central source.
20-22: Added imports for packages and typescript setupThe inclusion of
FASTIFY_PACKAGESand the externalfastifyTypescriptTaskimproves modularity by separating concerns and making the code more testable.
74-77: Updated dependency and configuration for ESMThe change from
nodeSetupProvidertonodeConfigProviderand the updated method for setting ESM mode aligns with the new approach to configuration management.
81-97: Well-structured package and configuration setupUsing
fastifyTypescriptTaskandcreateNodeTaskfor setting up packages and node properties improves the organization of the code and makes it more testable. The task approach properly separates different aspects of node configuration.
110-110: Updated function signature to include taskIdAdding
taskIdto the function signature is important for tracking which task is making changes to shared resources, improving traceability and debugging capabilities.
149-156: Improved script management with mergeObjUsing
node.scripts.mergeObjwith a taskId provides better organization and tracking of script additions, making it easier to test and debug script configurations.packages/core-generators/src/generators/node/typescript/index.ts (8)
10-10: Updated import for config provider taskThe change from
createSetupTaskWithInfotocreateConfigProviderTaskWithInforepresents an improvement in how configuration tasks are created and named.
35-35: Added import for package version extractionThe import of
extractPackageVersionsenables a more modular approach to managing package dependencies, aligning with the overall refactoring goals.
45-48: Updated imports for TypeScript code handlingThe restructured imports improve readability by grouping related functionality and introducing the new
writeJsonToBuilderfunction that simplifies JSON file creation.
51-51: Added import for node package task creationThis import enables the task-based approach for managing node packages, which is consistent with the refactoring pattern seen in other files.
152-166: Updated configuration provider creationThe change from
createSetupTaskWithInfotocreateConfigProviderTaskWithInfoand the rename ofoutputScopetoconfigValuesScopeprovides more clarity about the purpose of these parameters.
242-244: Added task for TypeScript package managementThe addition of
createNodePackagesTaskto handle the TypeScript development dependency is consistent with the task-based approach and improves testability.
251-251: Simplified function signatureRemoving the
nodeparameter from the run method signature aligns with the refactoring approach, as node operations have been moved to dedicated tasks.
335-345: Improved JSON file creation with dedicated functionUsing the
writeJsonToBuilderfunction instead of creating a custom action improves code consistency and readability. This approach is more declarative and easier to test.packages/core-generators/src/generators/node/prettier/index.ts (7)
25-25: New import for JSON writer looks good.
No issues in importingwriteJsonToBuilder.
27-27: New import ofnodeProvideris consistent with usage.
No concerns — confirmed usage at line 131.
131-131: IntroducedtaskIdparameter for the task runner.
This ensures tasks can be identified or referenced consistently.
160-160: Newbuildfunction structure.
Implementation aligns with the broader generator pattern. No immediate issues seen.
257-263: Refactored to add dev packages vianode.packages.addDevPackages.
Modern usage ofObject.fromEntriesis clear. Good approach for dynamic plugin version handling.
264-270: Usingnode.scripts.mergeObjto add Prettier scripts.
This is consistent with the new script management approach. Looks good.
272-280: Replaced direct action withwriteJsonToBuilderfor Prettier config.
Writing to.prettierrcwith plugin references is clean and maintainable.packages/fastify-generators/src/generators/pothos/pothos/index.ts (5)
8-8: ImportingcreateNodePackagesTask.
No issues with adding this utility for package management.
10-10: ImportingextractPackageVersions.
No concerns — used to slice out relevant package versions.
156-162: Introducing thecreateNodePackagesTaskfor Pothos deps.
Specifying Pothos packages underprodis correct, given these are runtime dependencies.
363-363: Renaming the task togenerate-schema-script.
Adds clarity to the task name.
368-379: AddedtaskIdparameter and usingnode.scripts.set.
This neatly registers thegenerate:schemascript. Confirm that'src/index.ts'path is correct for schema generation.packages/core-generators/src/generators/node/node/node.generator.ts (10)
1-3: Type imports for generator tasks.
Straightforward usage of types from@halfdomelabs/syncand@halfdomelabs/utils.
4-14: Core imports for config and generator utilities.
These look appropriate and align with typical usage of@halfdomelabs/syncfunctions.
19-26: Importing Node & PNPM constants, project scope, and JSON writer.
All relevant references for Node config. No concerns.
28-38: Descriptor schema for Node project metadata.
Defining fields such asnodeVersionandpnpmVersionensures easy customization. Consider validating exact semver strings.
40-55:nodePackageJsonFieldsSchemadefining packages, scripts, and extra props.
Pattern ensures structured package.json management. Usingpreinstallscript to enforce PNPM usage is neat.
57-69:NodeProviderinterface.
Provides typed access to Node/ESM configuration. This helps keep project setup consistent.
71-86:createNodeTaskhelper function.
Allows modular extension of Node config. The approach to receive the provider and context is flexible.
88-104:createNodePackagesTaskhelper function.
Cleanly handles adding partial packages to Node’s dependency container. Straightforward usage.
106-111: Config provider for Node “isEsm” setting.
This approach is scalable if more Node config flags are needed.
114-189:nodeGeneratordefinition.
Generates package.json, manages post-write command for dependencies, sets up Node environment. Implementation is coherent and user-friendly.packages/sync/src/utils/create-config-provider-task-with-info.ts (1)
94-107: Ensure safe merging of descriptor-derived info.
Consider the possibility that fields ininfoFromDescriptor(descriptor)might inadvertently override keys within the config’s field map schema. If overriding is intentional, explicitly document this behavior and confirm it’s acceptable. Otherwise, you may want to namespace the descriptor-derived info to avoid collisions (e.g., store under aninfo: { ... }key).packages/sync/src/utils/create-generator.ts (5)
17-22: Type flexibility is beneficial.
AllowingTaskConfigsto be a record ofAnyGeneratorTaskprovides good extensibility for different generator tasks. This design effectively supports a variety of custom tasks without additional overhead.
73-79: Great extension of GeneratorBundleCreator.
This expanded type signature adds clarity and flexibility by incorporatingTaskConfigs. It better captures the shape of a generator’s tasks.
98-101: Well-structured utility type.
InferTaskConfigsFromGeneratoreffectively extractsTaskConfigsfrom theGeneratorBundleCreatortype. Coupled withInferDescriptorFromGenerator, these generics significantly improve type safety.
123-140: Robust duplicate task check.
Throwing an error on duplicate task names is a helpful safeguard that should prevent hidden collisions. This logic looks sound and ensures that tasks remain uniquely identified.
148-148: Good final assignment of tasks into the generator bundle.
By normalizing both array-based and object-based tasks intotaskConfigs, you provide a consistent interface to the rest of the system.packages/utils/src/field-map/field-map.ts (7)
1-7: Well-defined base interface.
IntroducingFieldContainer<T>as a lightweight interface clarifies the contract for all container implementations, improving reusability and readability across different container types.
9-40: Prevent value overwrites with helpful error messages.
ScalarContainerenforces single-set semantics with a detailed error message if code attempts an overwrite. This design is excellent for defending against accidental reassignments.
72-110: Robust approach forObjectContainer.
Storing key-value pairs alongside which source last set them is practical for config merges. Themergemethod is intuitive, although you might consider a blueprint method for merging deeply nested objects in future expansions.
113-158: Map merging is comprehensive.
MapContainersupports merges from bothMapandRecord, providing flexibility. The set-once logic is consistent with other containers.
201-206: Logical creation of ArrayContainer.
PassinginitialValueandoptionsdirectly into the constructor is a clean approach. The optionalstripDuplicatesis an excellent configuration detail.
214-222: Great convenience method for map initialization.
mapFromObjimproves ergonomics by allowing direct object-to-map usage. It simplifies many common setup flows.
251-251: Efficient iteration for building values.
By iterating over each schema key and callinggetValue(),createFieldMapremains consistent and type-safe. This approach unifies container-based logic with minimal overhead.packages/core-generators/src/generators/node/node/package-dependencies-container.ts (7)
1-17: Well-structured type definitions and imports.The type definitions for
NodePackageDependencyType,NodePackageDependencyInfo, andNodePackageDependenciesare clear and appropriate for managing package dependencies. The use of TypeScript interfaces provides good type safety for the container implementation.
21-28: Good implementation of the FieldContainer interface.The class correctly implements the
FieldContainerinterface from the utils package and uses a private Map for efficient dependency storage. This makes lookups by package name O(1), which is ideal for dependency management.
43-57: Excellent semver compatibility logic.The algorithm for determining version compatibility and selecting the most appropriate version is well-implemented:
- Keeps existing version if it's more specific or equal
- Uses new version if it's more specific than existing
- Throws an error for incompatible versions
This ensures consistent and reliable dependency management.
59-67: Appropriate type precedence handling.Production dependencies correctly take precedence over development dependencies, which is the expected behavior since a package used in production should be treated as a production dependency even if also needed for development.
78-96: Well-implemented convenience methods for adding packages by type.The
addProdPackagesandaddDevPackagesmethods provide a clean API for bulk-adding dependencies of a specific type, improving the usability of the container class.
112-127: Clean implementation of getValue method.The
getValuemethod efficiently transforms the internal Map representation into the expected output format with separate dev and prod categories, using functional programming concepts. The use of a nested function for code reuse is elegant.
130-133: Useful helper function for container creation.The
createNodePackageDependenciesContainerfactory function provides a convenient way to instantiate the container, which could be useful for dependency injection or when using the builder pattern mentioned in the comment.
| scopes: [], | ||
| children: {}, | ||
| tasks: [], | ||
| tasks: {}, |
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.
💡 Verification agent
🧩 Analysis chain
Change from array to object for tasks aligns with refactoring goal
This change from tasks: [] to tasks: {} represents a shift from an array-based to an object-based representation of tasks, which aligns with the overall PR objective of improving generator testing.
However, I noticed that the buildTestGeneratorEntry function (lines 65-76) still handles tasks as an array. Consider reviewing to ensure consistency across the codebase.
🏁 Script executed:
#!/bin/bash
# Check for other occurrences of task representations in the codebase
echo "Searching for task array vs object representations..."
rg -A 3 -B 3 "tasks: \[\]" --type ts
rg -A 3 -B 3 "tasks: {}" --type tsLength of output: 799
Action Required: Align Task Representation in Generator Entry Function
The refactoring in packages/sync/src/runner/tests/factories.test-helper.ts now correctly sets tasks as an object (tasks: {}), which aligns with the overall PR goal. However, our search confirms that in packages/sync/src/runner/dependency-map.unit.test.ts (and specifically within the buildTestGeneratorEntry function, lines 65–76), tasks are still initialized as an array (tasks: []).
- File Affected:
packages/sync/src/runner/dependency-map.unit.test.ts - Issue: The use of an array for tasks conflicts with the recently refactored object-based approach.
Please update the buildTestGeneratorEntry function (or related test setup) to handle tasks as an object for consistency across the codebase.
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.
Actionable comments posted: 0
🧹 Nitpick comments (4)
packages/core-generators/src/generators/node/node/package-dependencies-container.ts (4)
5-16: Consider refining the dev/prod type representation.
The current union-basedNodePackageDependencyTypeis concise. Optionally, you might consider a literal or enum approach if you foresee expansions (e.g., test, peer).
78-96: Reduce repetitive logic between addProdPackages and addDevPackages.
Both methods share a similar structure. Consider extracting the iteration logic into a helper or unifying them in a single method that accepts the dependency type.
98-110: Streamline addPackages if adding large sets.
Current approach is clear, but an optional single pass could reduce iteration overhead if you frequently add large dev and prod sets concurrently.
112-127: Optimize getValue for large dependency sets.
Constructing two filtered objects on every call can be slightly inefficient for very large sets. This is minor, so consider caching or storing the results if performance demands scale.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
packages/core-generators/src/generators/node/node/package-dependencies-container.ts(1 hunks)packages/sync/src/utils/index.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/sync/src/utils/index.ts
🧰 Additional context used
🧬 Code Definitions (1)
packages/core-generators/src/generators/node/node/package-dependencies-container.ts (1)
packages/utils/src/field-map/field-map.ts (1)
FieldContainer(4-6)
🔇 Additional comments (4)
packages/core-generators/src/generators/node/node/package-dependencies-container.ts (4)
1-2: Ensure proper usage of type imports.
Usingimport typeis a nice approach for tree-shaking in TypeScript. No issues detected here.
21-28: Implementation of FieldContainer looks solid.
Clear adherence to theFieldContainerinterface. LGTM.
130-133: Helper function name is sufficiently descriptive.
Great addition for easier container creation. This fosters consistency in code usage.
30-76:Details
❓ Verification inconclusive
Confirm semver merging behavior.
The approach of merging versions usingsemver.subsetis advanced. Suggest verifying with sample inputs to ensure correct range resolution and error handling.
🏁 Script executed:
#!/bin/bash # Verify semver merging logic with sample version inputs # Expected: Each scenario merges or rejects versions as intended. cat <<EOF > /tmp/versions.txt 1) "existing=^2.0.0" "new=^2.1.0" 2) "existing=~1.2.3" "new=^1.2.0" 3) "existing=2.0.0" "new=3.0.0" 4) "existing=^2.0.0" "new=3.0.0" EOF while read -r line; do echo "Testing scenario: $line" # Hypothetical check: refer to your test or harness that uses semver.subset done < /tmp/versions.txtLength of output: 526
Confirm semver merging behavior and add assertions to the test harness.
While the current test script executes and logs four sample scenarios, it only prints the test scenarios without asserting expected outcomes. Please ensure that:
- For scenarios 1 and 2, the merged version is correctly determined (e.g., scenario 1 should retain the existing
^2.0.0if it is a subset of the new^2.1.0).- For scenarios 3 and 4, the function properly throws an error for incompatible ranges.
- Consider updating the test harness to include explicit assertions that verify both the merged version outcomes and error messages, ensuring robust verification of the
semver.subsetlogic.
Summary by CodeRabbit
New Features
Refactor
Tests