Skip to content

Conversation

@kingston
Copy link
Collaborator

@kingston kingston commented Apr 1, 2025

Allow tasks to export output providers that will be used consumed when the task has finished building. This replaces the need for task dependencies.

Summary by CodeRabbit

  • New Features

    • Introduced an enhanced output provider system and new setup tasks for generators. These changes simplify configuration management and improve the consistency of outputs across multiple frameworks.
  • Refactor / Improvements

    • Streamlined dependency resolution and generator configuration for improved stability and performance.
    • Enhanced type safety and overall clarity in task management.
  • Documentation

    • Clarified the naming conventions in testing instructions to ensure proper import statements.

@changeset-bot
Copy link

changeset-bot bot commented Apr 1, 2025

🦋 Changeset detected

Latest commit: 3856e84

The changes in this PR will be included in the next version bump.

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

@coderabbitai
Copy link

coderabbitai bot commented Apr 1, 2025

Walkthrough

This pull request introduces a new output provider concept that replaces task dependencies across multiple generator packages. The changes include the integration of a new setup task via a dedicated createSetupTask utility and the reorganization of configuration handling for Node, TypeScript, authentication, Fastify, Prisma, Yoga, and React generators. Several provider types have been updated—often renamed from “setup” to “config” or switched from a standard to an output provider—and redundant providers objects have been removed. In addition, type definitions, dependency resolution logic, and testing–including new Vitest settings and a comprehensive field-map module—have been enhanced.

Changes

File(s) Change Summary
.changeset/bright-seals-rescue.md, packages/core-generators/src/generators/node/*, .../typescript/index.ts, packages/sync/src/utils/create-setup-task.ts Introduced output providers to replace task dependencies and integrated a new setup mechanism using createSetupTask to streamline configuration in Node and TypeScript generators.
packages/fastify-generators/src/generators/auth/*, packages/fastify-generators/src/generators/core/*, packages/fastify-generators/src/generators/prisma/*, packages/fastify-generators/src/generators/yoga/*, packages/fastify-generators/src/generators/pothos/* Renamed provider identifiers (e.g., from authSetupProvider to authConfigProvider), removed redundant providers objects from return statements, applied createOutputProviderType for output handling, and updated dependency resolution (using methods like parentScopeOnly).
packages/react-generators/src/generators/* Updated React generators to replace typescriptConfig with typescriptSetup, incorporated a new output provider for embedded forms, refined dependency declarations (e.g., for react routes), and adjusted configuration via property setters.
packages/sync/src/generators/*, packages/sync/src/providers/*, packages/sync/src/runner/*, packages/sync/src/utils/* Enhanced the provider system with a new createOutputProviderType, updated type definitions to support optional outputs, reworked dependency mapping and sorting for output providers, and expanded tests and factory helpers for generator tasks.
packages/tools/eslint-configs/typescript.js Enabled Vitest type‐checking by adding a new settings.vitest.typecheck configuration.
packages/utils/src/field-map/*, packages/utils/src/index.ts Added a new field-map module that introduces several container classes (Scalar, Array, Object, Map), schema builders, and unit tests for type-safe field management; re-exported these utilities in the main utils index.
.cursor/rules/writing-vitest-tests.mdc Revised documentation to clarify that the .js filename requirement applies only to import statements.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant GR as Generator Runner
    participant TT as Task (Setup/Build)
    participant OP as Output Provider

    U->>GR: Trigger generator execution
    GR->>TT: Invoke task run method
    TT->>OP: Generate outputs via createSetupTask / createOutputProviderType
    OP-->>TT: Return configured output object
    TT-->>GR: Return outputs and dependencies
    GR->>GR: Validate outputs and resolve dependencies
    GR->>U: Complete execution with generated output
Loading

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (10)
packages/sync/src/utils/create-generator.unit.test.ts (1)

120-122: Well-implemented callback pattern for task outputs

The modification from returning a value to using a callback pattern (addTaskOutput) aligns well with the introduced output provider concept. This is a good architectural shift that decouples how tasks produce outputs from how those outputs are consumed.

For better clarity and type safety in the test on line 140, consider replacing the empty object cast to GeneratorTaskOutputBuilder with a properly mocked object:

- await build?.({} as unknown as GeneratorTaskOutputBuilder);
+ await build?.({} as unknown as GeneratorTaskOutputBuilder, (output) => {
+   // The output handling happens in the callback
+ });
packages/sync/src/runner/generator-runner.unit.test.ts (1)

205-253: Consider using interfaces instead of type assertions

The test correctly validates output provider functionality, but uses type assertions which could be improved.

Instead of using type assertions like (deps.outputDep as { generate: () => void }), consider defining proper interfaces:

+ interface OutputProvider {
+   generate: () => void;
+ }

  it('handles output providers correctly', async () => {
    const outputProviderType = createOutputProviderType<{
      generate: () => void;
    }>('output-provider');
    const outputProvider = { generate: vi.fn() };
    // ...
-   (deps.outputDep as { generate: () => void }).generate();
+   (deps.outputDep as OutputProvider).generate();
    // ...
  });
packages/sync/src/runner/dependency-sort.ts (1)

40-47: Strong improvement to dependency management for output providers.

The new condition properly handles output provider dependencies by ensuring the dependent task must be built before the current task can initialize. This directly supports the PR's objective of introducing output providers as an alternative to task dependencies.

Consider adding a comment explaining the distinction between output dependencies and regular dependencies for future maintainability:

  // check if the dependency is to an output provider and if so,
  // we need to wait until the dependent task has been built before
  // we can build the current task
+ // Output providers require a stronger dependency - the dependent task's
+ // build phase must complete before the current task can even initialize
  if (dependent.options?.isOutput) {
    return [[dependentBuild, entryInit] as [string, string]];
  }
packages/sync/src/generators/build-generator-entry.unit.test.ts (1)

1-181: Test suite needs expansion for output providers.

While the tests have been updated to reflect the new structure, I don't see explicit tests for the new output provider functionality introduced in this PR.

Consider adding a new test case that validates the behavior of output providers, ensuring they're properly handled by the buildGeneratorEntry function. For example:

it('handles output providers correctly', async () => {
  // Setup test environment...
  
  const outputProvidingTask = {
    name: 'output-provider-task',
    dependencies: {},
    exports: {},
    taskDependencies: [],
    run: () => ({
      providers: {},
      outputs: {
        someOutput: { /* output provider details */ }
      },
      build: () => ({})
    }),
  };
  
  const bundle = buildTestGeneratorBundle({
    name: 'test-generator',
    directory: '/test',
    tasks: [outputProvidingTask],
  });
  
  const entry = await buildGeneratorEntry(bundle, { logger });
  
  // Verify the output provider is correctly included in the entry
  expect(entry.tasks[0]).toHaveProperty('outputs.someOutput');
});
packages/sync/src/runner/dependency-map.ts (3)

40-40: Comment clarity.

This line merely documents the process of adding scoped exports and outputs. Make sure the comment stays updated if logic evolves.


75-78: Error handling approach is consistent.

Throwing an error for missing generatorEntry is sensible. It ensures no silent misconfiguration. Consider adding guidance or context in the error to help developers troubleshoot faster.


180-183: Storing isReadOnly and isOutput as undefined vs false.

Conditions map booleans to either true or undefined. This can simplify usage, but watch out if code depends on an explicit false value. Overall, it’s consistent with optional properties.

packages/sync/src/providers/providers.ts (1)

106-109: Slight naming nitpick.

parentScopeOnly() is descriptive, but you may consider a name like resolveFromParent() or skipLocalScope() for clarity.

packages/sync/src/generators/generators.ts (2)

61-70: Interface for provider exports.

Defining GeneratorTaskResultProviders to accept an optional ExportMap type is a good step. Just ensure that any consumer properly checks for undefined when using providers.


72-83: Potential improvement for error handling in build.

GeneratorTaskResultBuildersWithOutputs permits both synchronous and asynchronous returns. Consider clarifying how errors should be bubbled up or handled in the promise to maintain consistency across tasks.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between e1517d0 and 3856e84.

📒 Files selected for processing (55)
  • .changeset/bright-seals-rescue.md (1 hunks)
  • .cursor/rules/writing-vitest-tests.mdc (1 hunks)
  • packages/core-generators/src/generators/docker/docker-compose/index.ts (0 hunks)
  • packages/core-generators/src/generators/node/node/index.ts (2 hunks)
  • packages/core-generators/src/generators/node/typescript/index.ts (5 hunks)
  • packages/fastify-generators/src/generators/auth/auth-context/index.ts (4 hunks)
  • packages/fastify-generators/src/generators/auth/auth-plugin/index.ts (0 hunks)
  • packages/fastify-generators/src/generators/auth/auth-roles/index.ts (3 hunks)
  • packages/fastify-generators/src/generators/auth/auth/index.ts (2 hunks)
  • packages/fastify-generators/src/generators/auth0/auth0-module/index.ts (4 hunks)
  • packages/fastify-generators/src/generators/core/app-module/index.ts (1 hunks)
  • packages/fastify-generators/src/generators/core/fastify-server/index.ts (2 hunks)
  • packages/fastify-generators/src/generators/core/fastify/index.ts (6 hunks)
  • packages/fastify-generators/src/generators/core/fastify/setup-fastify-typescript.ts (1 hunks)
  • packages/fastify-generators/src/generators/core/readme/index.ts (0 hunks)
  • packages/fastify-generators/src/generators/core/request-service-context/index.ts (4 hunks)
  • packages/fastify-generators/src/generators/core/root-module/index.ts (6 hunks)
  • packages/fastify-generators/src/generators/core/service-context/index.ts (3 hunks)
  • packages/fastify-generators/src/generators/core/service-file/index.ts (4 hunks)
  • packages/fastify-generators/src/generators/pothos/pothos-sentry/index.ts (2 hunks)
  • packages/fastify-generators/src/generators/pothos/pothos/index.ts (11 hunks)
  • packages/fastify-generators/src/generators/prisma/prisma-crud-create/index.ts (0 hunks)
  • packages/fastify-generators/src/generators/prisma/prisma-crud-delete/index.ts (1 hunks)
  • packages/fastify-generators/src/generators/prisma/prisma-crud-service/index.ts (4 hunks)
  • packages/fastify-generators/src/generators/prisma/prisma-crud-update/index.ts (0 hunks)
  • packages/fastify-generators/src/generators/prisma/prisma-enum/index.ts (1 hunks)
  • packages/fastify-generators/src/generators/prisma/prisma-field/index.ts (1 hunks)
  • packages/fastify-generators/src/generators/prisma/prisma/index.ts (6 hunks)
  • packages/fastify-generators/src/generators/yoga/yoga-plugin/index.ts (4 hunks)
  • packages/react-generators/src/generators/admin/admin-crud-embedded-form/index.ts (2 hunks)
  • packages/react-generators/src/generators/core/react-routes/index.ts (1 hunks)
  • packages/react-generators/src/generators/core/react-typescript/index.ts (2 hunks)
  • packages/react-generators/src/generators/core/react/index.ts (1 hunks)
  • packages/sync/src/generators/build-generator-entry.ts (2 hunks)
  • packages/sync/src/generators/build-generator-entry.unit.test.ts (2 hunks)
  • packages/sync/src/generators/generators.ts (3 hunks)
  • packages/sync/src/generators/generators.unit.test.ts (1 hunks)
  • packages/sync/src/providers/providers.ts (10 hunks)
  • packages/sync/src/runner/dependency-map.ts (8 hunks)
  • packages/sync/src/runner/dependency-map.unit.test.ts (3 hunks)
  • packages/sync/src/runner/dependency-sort.ts (1 hunks)
  • packages/sync/src/runner/dependency-sort.unit.test.ts (2 hunks)
  • packages/sync/src/runner/generator-runner.ts (2 hunks)
  • packages/sync/src/runner/generator-runner.unit.test.ts (5 hunks)
  • packages/sync/src/runner/tests/factories.test-helper.ts (1 hunks)
  • packages/sync/src/utils/create-generator-types.ts (8 hunks)
  • packages/sync/src/utils/create-generator.ts (3 hunks)
  • packages/sync/src/utils/create-generator.unit.test.ts (1 hunks)
  • packages/sync/src/utils/create-setup-task.ts (1 hunks)
  • packages/sync/src/utils/index.ts (1 hunks)
  • packages/tools/eslint-configs/typescript.js (1 hunks)
  • packages/utils/src/field-map/field-map.ts (1 hunks)
  • packages/utils/src/field-map/field-map.unit.test.ts (1 hunks)
  • packages/utils/src/field-map/index.ts (1 hunks)
  • packages/utils/src/index.ts (1 hunks)
💤 Files with no reviewable changes (5)
  • packages/fastify-generators/src/generators/core/readme/index.ts
  • packages/fastify-generators/src/generators/prisma/prisma-crud-create/index.ts
  • packages/fastify-generators/src/generators/prisma/prisma-crud-update/index.ts
  • packages/fastify-generators/src/generators/auth/auth-plugin/index.ts
  • packages/core-generators/src/generators/docker/docker-compose/index.ts
🧰 Additional context used
🧬 Code Definitions (22)
packages/sync/src/generators/build-generator-entry.ts (1)
packages/sync/src/generators/generators.ts (1)
  • ProviderExportMap (32-34)
packages/fastify-generators/src/generators/core/app-module/index.ts (1)
packages/fastify-generators/src/generators/core/root-module/index.ts (1)
  • appModuleProvider (64-65)
packages/fastify-generators/src/generators/core/fastify-server/index.ts (2)
packages/fastify-generators/src/generators/core/root-module/index.ts (2)
  • rootModuleConfigProvider (43-43)
  • rootModuleImportProvider (50-55)
packages/core-generators/src/writers/typescript/code-entries.ts (1)
  • TypescriptCodeUtils (336-597)
packages/sync/src/generators/generators.unit.test.ts (2)
packages/sync/src/generators/generators.ts (5)
  • ProviderExportMap (32-34)
  • ProviderDependencyMap (39-41)
  • GeneratorTask (121-161)
  • InferExportProviderMap (46-50)
  • InferDependencyProviderMap (55-59)
packages/sync/src/providers/providers.ts (1)
  • createProviderType (164-225)
packages/fastify-generators/src/generators/auth/auth-roles/index.ts (1)
packages/fastify-generators/src/generators/auth/auth/index.ts (1)
  • authConfigProvider (29-29)
packages/sync/src/utils/create-generator.ts (3)
packages/sync/src/utils/create-generator-types.ts (2)
  • SimpleGeneratorTaskConfig (73-107)
  • GeneratorTaskBuilder (182-209)
packages/sync/src/generators/generators.ts (1)
  • GeneratorTask (121-161)
packages/sync/src/providers/providers.ts (1)
  • Provider (11-11)
packages/fastify-generators/src/generators/auth/auth-context/index.ts (1)
packages/fastify-generators/src/generators/auth/auth/index.ts (1)
  • authConfigProvider (29-29)
packages/sync/src/utils/create-setup-task.ts (3)
packages/utils/src/field-map/field-map.ts (4)
  • FieldMapSchema (152-152)
  • FieldMapValues (155-157)
  • FieldMapSchemaBuilder (165-212)
  • createFieldMap (227-246)
packages/sync/src/utils/create-generator-types.ts (1)
  • SimpleGeneratorTaskConfig (73-107)
packages/sync/src/providers/providers.ts (3)
  • ProviderType (17-45)
  • createProviderType (164-225)
  • createOutputProviderType (234-239)
packages/fastify-generators/src/generators/auth0/auth0-module/index.ts (1)
packages/fastify-generators/src/generators/auth/auth/index.ts (1)
  • authConfigProvider (29-29)
packages/fastify-generators/src/generators/yoga/yoga-plugin/index.ts (3)
packages/utils/src/field-map/field-map.ts (3)
  • createFieldMapSchemaBuilder (214-218)
  • FieldMapValues (155-157)
  • createFieldMap (227-246)
packages/sync/src/providers/providers.ts (2)
  • createProviderType (164-225)
  • createOutputProviderType (234-239)
packages/sync/src/utils/create-generator.ts (1)
  • createGenerator (84-162)
packages/react-generators/src/generators/admin/admin-crud-embedded-form/index.ts (8)
packages/sync/src/providers/providers.ts (1)
  • createOutputProviderType (234-239)
packages/react-generators/src/generators/admin/admin-crud-edit/index.ts (1)
  • adminCrudEditProvider (43-44)
packages/react-generators/src/generators/admin/admin-components/index.ts (1)
  • adminComponentsProvider (19-20)
packages/react-generators/src/generators/core/react-components/index.ts (1)
  • reactComponentsProvider (68-69)
packages/react-generators/src/generators/core/react-error/index.ts (1)
  • reactErrorProvider (26-27)
packages/core-generators/src/generators/node/typescript/index.ts (1)
  • typescriptProvider (107-108)
packages/react-generators/src/generators/admin/admin-crud-section/index.ts (1)
  • adminCrudSectionScope (15-18)
packages/react-generators/src/writers/graphql/index.ts (1)
  • GraphQLField (34-34)
packages/react-generators/src/generators/core/react-typescript/index.ts (2)
packages/core-generators/src/generators/node/typescript/index.ts (1)
  • typescriptSetupProvider (165-165)
packages/core-generators/src/generators/node/eslint/index.ts (1)
  • eslintProvider (27-27)
packages/fastify-generators/src/generators/core/fastify/setup-fastify-typescript.ts (1)
packages/core-generators/src/generators/node/typescript/index.ts (1)
  • TypescriptSetupProvider (171-173)
packages/core-generators/src/generators/node/typescript/index.ts (5)
packages/core-generators/src/constants/core-packages.ts (1)
  • CORE_PACKAGES (1-27)
packages/sync/src/providers/providers.ts (1)
  • InferProviderType (47-47)
packages/sync/src/utils/create-generator.ts (1)
  • createGenerator (84-162)
packages/core-generators/src/generators/node/node/index.ts (1)
  • nodeProvider (44-44)
packages/core-generators/src/writers/typescript/imports.ts (1)
  • PathMapEntry (36-39)
packages/fastify-generators/src/generators/core/fastify/index.ts (3)
packages/sync/src/providers/providers.ts (1)
  • createOutputProviderType (234-239)
packages/core-generators/src/generators/node/typescript/index.ts (1)
  • typescriptSetupProvider (165-165)
packages/fastify-generators/src/generators/core/fastify/setup-fastify-typescript.ts (1)
  • setupFastifyTypescript (8-41)
packages/fastify-generators/src/generators/pothos/pothos-sentry/index.ts (3)
packages/fastify-generators/src/generators/yoga/yoga-plugin/index.ts (1)
  • yogaPluginConfigProvider (71-72)
packages/core-generators/src/generators/node/typescript/index.ts (1)
  • typescriptProvider (107-108)
packages/core-generators/src/generators/node/node/index.ts (1)
  • nodeProvider (44-44)
packages/fastify-generators/src/generators/pothos/pothos/index.ts (3)
packages/sync/src/providers/providers.ts (1)
  • createOutputProviderType (234-239)
packages/fastify-generators/src/writers/pothos/options.ts (1)
  • PothosTypeReferenceContainer (46-142)
packages/fastify-generators/src/generators/yoga/yoga-plugin/index.ts (1)
  • yogaPluginConfigProvider (71-72)
packages/sync/src/runner/dependency-map.ts (1)
packages/sync/src/providers/providers.ts (1)
  • ProviderDependencyOptions (49-75)
packages/sync/src/generators/generators.ts (2)
packages/sync/src/providers/providers.ts (1)
  • Provider (11-11)
packages/sync/src/output/generator-task-output.ts (1)
  • GeneratorTaskOutputBuilder (105-224)
packages/sync/src/utils/create-generator-types.ts (3)
packages/sync/src/providers/providers.ts (1)
  • Provider (11-11)
packages/sync/src/output/generator-task-output.ts (1)
  • GeneratorTaskOutputBuilder (105-224)
packages/sync/src/generators/generators.ts (4)
  • ProviderExportMap (32-34)
  • ProviderDependencyMap (39-41)
  • InferDependencyProviderMap (55-59)
  • InferExportProviderMap (46-50)
packages/utils/src/field-map/field-map.unit.test.ts (1)
packages/utils/src/field-map/field-map.ts (1)
  • createFieldMap (227-246)
packages/sync/src/runner/dependency-map.unit.test.ts (3)
packages/sync/src/providers/providers.ts (1)
  • createProviderType (164-225)
packages/sync/src/runner/tests/factories.test-helper.ts (2)
  • buildTestGeneratorEntry (50-75)
  • buildTestGeneratorTaskEntry (26-48)
packages/sync/src/runner/dependency-map.ts (1)
  • resolveTaskDependencies (253-266)
🔇 Additional comments (214)
packages/tools/eslint-configs/typescript.js (1)

216-220: Good enhancement to enable typechecking in Vitest!

Adding typechecking for Vitest tests will help catch type errors during testing, improving overall code quality and preventing potential runtime issues. This aligns well with the PR's focus on enhancing generator configurations.

packages/sync/src/runner/generator-runner.unit.test.ts (5)

15-18: Import changes reflect new output provider concept

The addition of createOutputProviderType import aligns well with the PR objective of introducing output providers to replace task dependencies.


31-39: Return type expansion provides necessary flexibility

The expanded return type for the build function now supports void, Record<string, unknown>, or Promises of either, which is essential for supporting output providers that may return different types of data.


52-53: Output map handling is properly implemented

The changes correctly initialize an empty outputMap when not provided and pass it to the task object, ensuring proper integration of output providers into the generator entry structure.

Also applies to: 63-64, 69-70


255-302: Test for multiple exports and dependencies looks robust

This test effectively validates that multiple providers can be exported and consumed correctly, which is an important scenario for the output provider concept.


304-322: Good error handling test

The test for handling missing providers is important for ensuring robust dependency resolution. It correctly verifies that an appropriate error is thrown when a required provider is not exported.

.cursor/rules/writing-vitest-tests.mdc (1)

6-6: Documentation clarification looks good.

This clarification specifies that the .js extension requirement applies specifically to import statements rather than all files in the project. This is an important distinction that helps developers understand when this requirement applies.

packages/utils/src/field-map/index.ts (1)

1-2: Proper module export structure.

This barrel file correctly exports all entities from the field-map.js module, making them accessible through a single import. This follows good module organization practices.

packages/sync/src/utils/index.ts (1)

3-3: New setup task utility export looks good.

This export makes the create-setup-task.js module available through the utils index, which aligns with the PR objective of introducing output providers. The createSetupTask function likely plays a key role in eliminating task dependencies.

packages/utils/src/index.ts (1)

3-3: Good integration of the new field-map module.

The new export makes the field-map functionality available through the main utils index. This is important for enabling the output provider concept throughout the codebase. The field-map module appears to provide type-safe container management that will support the new provider architecture.

packages/fastify-generators/src/generators/prisma/prisma-enum/index.ts (1)

27-27: Simplified return value in alignment with output provider pattern

This change removes the empty providers object from the return statement, aligning with the PR's objective of introducing output providers to replace task dependencies. The simplified return is appropriate since no actual provider data was being returned.

packages/fastify-generators/src/generators/core/app-module/index.ts (1)

30-30:

Details

✅ Verification successful

Modified dependency resolution to use parentScopeOnly

The change restricts the appModule dependency resolution to only look in the parent scope, which is a more precise specification of the dependency's context. This modification aligns with the PR's objective of refining provider handling.


🏁 Script executed:

#!/bin/bash
# Check for other usages of parentScopeOnly() to verify consistency
rg -A 2 "parentScopeOnly()" --type ts

Length of output: 1745


Verified: Consistent Dependency Resolution with parentScopeOnly()

The update to use parentScopeOnly() in the appModule dependency resolution is consistent with its usage throughout the repository. Our verification shows that similar patterns are applied in several files, including:

  • Fastify Generators: packages/fastify-generators/src/generators/core/app-module/index.ts
  • React Generators: packages/react-generators/src/generators/core/react-routes/index.ts
  • Sync Modules: Test files and provider definitions in packages/sync/src/runner/ and packages/sync/src/providers/

These findings confirm that the modification correctly refines the dependency resolution to target only the parent scope, aligning with the PR's objective.

packages/react-generators/src/generators/core/react/index.ts (1)

199-199:

Details

✅ Verification successful

Updated ESM configuration API to use output provider pattern

The change replaces the direct setIsEsm method call with a property-based approach that includes the generator name for better context tracking. This is in line with the PR objective of introducing output providers.


🏁 Script executed:

#!/bin/bash
# Check for other usages of isEsm to confirm consistency of the new pattern
rg "isEsm\.set\(" --type ts

# Also check if there are any remaining uses of the old pattern that might need updating
rg "setIsEsm\(" --type ts

Length of output: 308


ESM configuration API update verified and approved.
The new property-based approach (using nodeSetup.isEsm.set(...) with the generator name) is applied consistently in both the React generator and the Fastify generator. The search confirmed that there are no remaining instances of the old setIsEsm API.

  • React Generator:
    • File: packages/react-generators/src/generators/core/react/index.ts
    • Code: nodeSetup.isEsm.set(true, taskBuilder.generatorName);
  • Fastify Generator:
    • File: packages/fastify-generators/src/generators/core/fastify/index.ts
    • Code: nodeSetup.isEsm.set(false, taskBuilder.generatorName);

The changes meet the PR objectives.

packages/fastify-generators/src/generators/prisma/prisma-crud-delete/index.ts (1)

144-144: Simplified return statement by removing empty providers object

This change removes the unused prismaDeleteMethod provider from the return statement, consistent with the PR's goal of refactoring the provider pattern. The empty object return is sufficient since no data needs to be provided back to the caller.

packages/sync/src/generators/build-generator-entry.ts (2)

29-32: Adds the outputs property to the GeneratorTaskEntry interface.

This is a good addition aligned with the PR objective of introducing output providers. It extends the task entry data structure with the same type as exports (ProviderExportMap), providing a clear separation between exported providers and output providers.


101-101: Correctly initializes the outputs property for each task entry.

The implementation appropriately adds the outputs property to the task entry object, defaulting to an empty object if task.outputs is undefined. This approach is consistent with how other properties like dependencies and exports are handled.

.changeset/bright-seals-rescue.md (1)

1-10: Properly documents changeset for the output providers feature.

The changeset correctly identifies all affected packages that need patch updates as a result of introducing the output providers concept. The description clearly states the purpose of the change: replacing task dependencies with output providers.

packages/react-generators/src/generators/core/react-routes/index.ts (1)

35-35: Added scope restriction to reactRoutes dependency.

The addition of .parentScopeOnly() to the reactRoutes dependency ensures that the dependency is resolved only from the parent scope, which is a good practice when transitioning to output providers. This helps in controlling the dependency resolution flow.

packages/fastify-generators/src/generators/prisma/prisma-field/index.ts (1)

82-82: Removes unnecessary providers object from return value.

This change aligns with the transition to output providers. The empty providers object is no longer needed since the task has already done its work of adding the field to the prisma model. Simplifying the return value makes the code cleaner.

packages/sync/src/runner/tests/factories.test-helper.ts (2)

34-34: Added support for output providers in test helper function

The outputs: {} property has been added to the return type of buildTestGeneratorTaskEntry to support the new output provider concept being introduced in this PR.


41-41: Added outputs field to task object structure

The addition of outputs: {} to the task object structure ensures consistency with the real task implementations that will now support output providers.

packages/fastify-generators/src/generators/pothos/pothos-sentry/index.ts (4)

13-13: Updated import to use the new provider name

The import has been changed from yogaPluginSetupProvider to yogaPluginConfigProvider, reflecting the shift toward more specific provider naming and responsibilities.


22-23: Updated dependency to use the new config provider

Changed from yogaPluginSetup: yogaPluginSetupProvider to yogaPluginConfig: yogaPluginConfigProvider to match the renamed provider.


27-27: Updated function parameter to match the new provider name

The function parameter has been updated from yogaPluginSetup to yogaPluginConfig to maintain consistency with the provider renaming.


32-36:

Details

❓ Verification inconclusive

Simplified API for plugin registration

The code has been refactored from using yogaPluginSetup.getConfig().appendUnique(...) to directly pushing to yogaPluginConfig.envelopPlugins.push(...), which simplifies the API by removing one level of method chaining.


🏁 Script executed:

#!/bin/bash
# Check if all usages of the old yogaPluginSetup API have been updated
echo "Checking for remaining usages of yogaPluginSetup.getConfig().appendUnique..."
rg -l "yogaPluginSetup.getConfig\(\).appendUnique" --type ts

Length of output: 225


Simplified API for Plugin Registration – Manual Verification Recommended

  • The change in file packages/fastify-generators/src/generators/pothos/pothos-sentry/index.ts (lines 32-36) now directly pushes the plugin into yogaPluginConfig.envelopPlugins instead of using yogaPluginSetup.getConfig().appendUnique(...).
  • A repository-wide search for "yogaPluginSetup.getConfig().appendUnique" produced no results, which suggests that all usages of the old API have been removed.
  • However, because the verification output was minimal, please perform a manual verification to ensure no residual references to the old API remain.

Code snippet (final state):

yogaPluginConfig.envelopPlugins.push(
  new TypescriptCodeExpression(`useSentry()`, [
    `import { useSentry } from '${pluginImport}'`,
  ]),
);
packages/sync/src/runner/generator-runner.ts (2)

40-40: Added outputs to destructuring assignment

The destructuring assignment now includes outputs from taskEntriesById[taskId], allowing the function to access the outputs associated with each task.


105-129: Implemented output provider validation and mapping

This new block implements the core functionality of the output provider concept:

  1. It checks if a task's build function produces output providers
  2. Validates that all expected output providers are present
  3. Updates the provider map to associate outputs with their corresponding providers

This is a critical part of the new output provider architecture that eliminates the need for task dependencies as mentioned in the PR objectives.

packages/fastify-generators/src/generators/core/fastify-server/index.ts (3)

24-27: Split root module provider into config and import providers

The previous rootModuleProvider has been split into more specialized providers:

  • rootModuleConfigProvider: For configuring the root module
  • rootModuleImportProvider: For importing/accessing the root module

This change improves separation of concerns and aligns with the output provider concept being introduced.


59-74: Added new task for root module configuration

A new task root-module-config has been added that configures the plugins field in the root module. This task uses the new rootModuleConfigProvider to set up the module field.

This separation allows for more focused tasks with clearer responsibilities, with this task handling configuration aspects while other tasks handle importing/using the module.


81-81: Updated dependency to use the new import provider

The dependency has been updated from rootModuleProvider to rootModuleImportProvider to match the new provider structure that separates configuration from import functionality.

packages/fastify-generators/src/generators/auth/auth-context/index.ts (4)

24-24: Updated authentication provider naming.

The import has been changed from authSetupProvider to authConfigProvider, aligning with the refactoring approach for provider naming across the codebase.


42-42: Updated dependency name.

The dependency has been renamed from authSetup to authConfig to maintain consistency with the import change.


54-54: Updated parameter name.

The parameter has been renamed from authSetup to authConfig to maintain consistency with the dependency change.


87-93:

Details

❓ Verification inconclusive

Improved API structure for authentication configuration.

The configuration approach has been changed from method-based (authSetup.getConfig().set()) to a more direct property-based approach (authConfig.contextUtilsImport.set()). Also added the module identifier as a second parameter.

Verify this pattern is consistently applied across all authentication configuration uses:


🏁 Script executed:

#!/bin/bash
# Check if all instances of authSetup have been refactored to authConfig
rg "authSetup" --type typescript --glob "packages/fastify-generators/**"

# Check if the new pattern with module identifier is used consistently
rg "authConfig\.[a-zA-Z]+\.set\([^,]+,[^)]+\)" --type typescript --glob "packages/fastify-generators/**"

Length of output: 249


Action Required: Re-verify API Consistency Across Authentication Configuration

The authentication configuration update—migrating from the method-based pattern (authSetup.getConfig().set()) to a direct property-based approach (authConfig.contextUtilsImport.set()) with an added module identifier—appears sound based on the code snippet. However, the initial automated checks returned errors due to the use of an unrecognized file type flag for TypeScript. Please run the updated verification commands below to ensure consistency across the codebase:

  • Verify no lingering references to the old API:

    rg -t ts "authSetup" packages/fastify-generators/
  • Confirm that the new pattern using a module identifier is applied consistently:

    rg -t ts "authConfig\.[a-zA-Z]+\.set\([^,]+,\s*['\"][^'\"]+['\"]\)" packages/fastify-generators/

Once these commands run without unexpected output, we can confidently conclude that the improved pattern has been uniformly applied across all authentication configuration instances.

packages/fastify-generators/src/generators/auth0/auth0-module/index.ts (4)

20-20: Updated authentication provider import.

The import has been changed from authSetupProvider to authConfigProvider, consistent with the changes in other files.


51-51: Updated dependency name.

The dependency has been renamed from authSetup to authConfig to maintain consistency with the import change.


66-66: Updated parameter name.

The parameter has been renamed from authSetup to authConfig to maintain consistency with the dependency change.


99-105: Improved API structure for user session service import configuration.

The approach has been changed from method-based (authSetup.getConfig().set()) to a more direct property-based approach (authConfig.userSessionServiceImport.set()). Also added the module identifier 'auth0/auth0-module' as a second parameter to provide context.

packages/sync/src/generators/build-generator-entry.unit.test.ts (2)

50-53: Enhanced task return structure in tests.

The test has been updated to reflect the new output provider model, now properly returning both providers and a build function from the task's run method.


99-102: Enhanced task return structure in tests.

Similar to the other task, this test has been updated to reflect the new output provider model by returning both providers and a build function.

packages/core-generators/src/generators/node/node/index.ts (4)

4-8: New utility import for improved setup task creation

The addition of createSetupTask from '@halfdomelabs/sync' aligns with the PR's objective of introducing output providers to eliminate the need for task dependencies.


54-60: Effective transition to output provider model

The implementation of createSetupTask is clean and well-structured. This approach:

  1. Creates a setup task with a boolean property isEsm
  2. Returns a tuple with the task, provider, and output provider
  3. Properly scopes the configuration to the project

This is a good implementation of the output provider concept described in the PR objectives.


70-76: Task dependency replaced with output provider

The setup task is now properly added to the task builder, and the main task effectively uses the output provider as a dependency. This implementation correctly follows the new pattern of using output providers instead of direct task dependencies.


81-81: Simplified parameter destructuring

The run method now elegantly destructures the isEsm property directly from the setup object, making the code more concise and easier to follow.

packages/fastify-generators/src/generators/auth/auth-roles/index.ts (4)

15-15: Provider renamed to reflect its purpose

Renaming from authSetupProvider to authConfigProvider improves clarity by better describing its role as a configuration provider rather than a setup provider.


47-47: Dependency naming updated for consistency

The dependency name has been updated from authSetup to authConfig to maintain consistency with the import change, ensuring the code remains coherent.


52-52: Run parameter updated to match dependency

The run parameter has been appropriately updated to use authConfig instead of authSetup, maintaining consistency throughout the task definition.


78-78: Improved configuration API

The method for setting auth roles import has been changed from a nested method call authSetup.getConfig().set(...) to a more direct property access authConfig.authRolesImport.set(...). This change:

  1. Makes the code more readable
  2. Provides better property access patterns
  3. Includes the source identifier 'auth/auth-roles' for better traceability

This is a good example of the streamlined workflow mentioned in the PR objectives.

packages/fastify-generators/src/generators/core/service-context/index.ts (5)

15-15: New output provider type utility imported

The addition of createOutputProviderType from '@halfdomelabs/sync' supports the PR's objective of introducing output providers to replace task dependencies.


49-49: Provider type updated to output provider

Changing serviceContextProvider to use createOutputProviderType instead of createProviderType is a key implementation of the output provider concept. This change supports the goal of eliminating task dependencies as mentioned in the PR objectives.


56-58: Task naming simplified

Renaming the task from 'setup' to 'main' simplifies the task structure and fits well with the new output provider pattern.


64-66: Output mechanism properly configured

The addition of the outputs property to export the serviceContextProvider is a key aspect of implementing the output provider pattern. This allows other tasks to consume the service context without creating direct dependencies.


179-189: Return structure improved for output provider

The return statement has been effectively updated to directly return a serviceContext object with all necessary methods. This structure is cleaner and more aligned with the output provider pattern:

  1. Provides getImportMap, getContextPath, and getServiceContextType methods
  2. Makes the service context type available via TypescriptCodeUtils.createExpression
  3. Properly references the context import path

This implementation follows good practices for structuring output providers.

packages/react-generators/src/generators/core/react-typescript/index.ts (4)

3-3: Provider renamed to reflect its purpose

Renaming from typescriptConfigProvider to typescriptSetupProvider improves clarity by better describing its role in setting up TypeScript rather than just configuring it.


18-19: Dependency naming updated for consistency

The dependency has been appropriately renamed from typescriptConfig to typescriptSetup to match the import change, ensuring code consistency.


21-54: Improved TypeScript configuration API

The method for setting TypeScript configuration has been updated from method-based calls to a more structured property-based approach:

  1. typescriptSetup.version.set(...) instead of typescriptConfig.setTypescriptVersion(...)
  2. typescriptSetup.compilerOptions.set(...) instead of typescriptConfig.setTypescriptCompilerOptions(...)

This property-based approach is more intuitive and makes the configuration more readable. The second parameter 'react' also helps with traceability by indicating the source of the configuration.

The compiler options themselves are well-structured with clear sections for Compilation, Linting, Resolution, Output, and Paths.


55-58: Array manipulation API improved

The methods for adding includes and references have been changed from:

  • typescriptConfig.addInclude(...) to typescriptSetup.include.push(...)
  • typescriptConfig.addReference(...) to typescriptSetup.references.push(...)

This is more intuitive as it directly manipulates arrays rather than using custom methods, making the code more aligned with standard JavaScript practices.

packages/fastify-generators/src/generators/core/fastify/setup-fastify-typescript.ts (3)

3-3: Updated import type aligned with output provider concept

The change from TypescriptConfigProvider to TypescriptSetupProvider is aligned with the PR objective of introducing output providers.


10-10: Updated parameter type consistent with import change

This parameter type update keeps the function signature consistent with the imported type.


12-34: Improved TypeScript configuration with structured approach

The function now uses a more structured approach to TypeScript configuration:

  1. Uses version.set instead of setTypescriptVersion
  2. Uses compilerOptions.set instead of setTypescriptCompilerOptions
  3. Passes a context string 'fastify' to both methods

This implementation successfully adopts the new output provider pattern while maintaining the same functionality.

packages/sync/src/utils/create-setup-task.ts (5)

21-40: Well-documented interface with clear purpose

The CreateSetupTaskOptions interface provides a clear structure for setup task configuration with comprehensive JSDoc comments.


42-49: Type-safe result tuple with clear component roles

The SetupTaskResult type provides a well-structured tuple that preserves type information and clearly identifies the purpose of each component.


58-66: Clean function signature with good parameter handling

The function signature with a schema builder function and destructured options provides a clean, expressive API. The default taskName parameter is a nice touch for convenience.


67-72: Effective provider type creation with consistent naming

The implementation creates two provider types with consistent naming conventions, clearly distinguishing between configuration and output providers.


74-91: Clean task implementation with field map integration

The task implementation successfully:

  1. Creates a task with appropriate exports and outputs
  2. Uses field maps for configuration
  3. Provides a build method that extracts values from the field map

This approach creates a clear separation between configuration and output, aligning with the PR objective of introducing output providers.

packages/fastify-generators/src/generators/prisma/prisma-crud-service/index.ts (4)

5-5: Added output provider type import

This import adds support for creating explicit output providers.


30-31: Switched to output provider type for clear intent

Changing to createOutputProviderType makes it explicit that this provider is intended for output generation, aligning with the PR objective of introducing output providers.


38-45: Improved task structure with explicit outputs

The task definition now:

  1. Uses a more descriptive 'main' task name
  2. Explicitly defines outputs for the prismaCrudService provider
  3. Exports the provider at both default and project scopes

This change makes the provider's role as an output clearer and aligns with the PR's output provider concept.


65-75: Simplified build method with focused output

The build method now returns a more concise structure focused solely on the prismaCrudService provider, which aligns with the output provider pattern.

packages/fastify-generators/src/generators/core/root-module/index.ts (9)

14-14: Added createSetupTask import

This import enables the creation of standardized setup tasks using the new utility.


32-42: Used createSetupTask for consistent task creation

The implementation creates a setup task using the new createSetupTask utility, which:

  1. Initializes a map for module fields
  2. Specifies the appropriate prefix and configScope
  3. Returns both config and output providers

This change adopts the new standardized approach for creating setup tasks.


43-43: Exported rootModuleConfigProvider for external use

Exporting the config provider allows other modules to interact with the configuration.


72-72: Added setup task to the task builder

This line adds the newly created setup task to the task builder.


103-106: Updated dependencies to include rootModuleSetup

Adding the dependency on rootModuleSetup ensures the setup task runs before the app module task and provides access to the moduleFields map.


108-109: Updated run function to use moduleFields from rootModuleSetup

The run function now:

  1. Destructures to access moduleFields from rootModuleSetup
  2. Uses a standard Map instead of a custom non-overwriteable map

This change simplifies the implementation while maintaining the same functionality.


116-116: Updated field validation to reference moduleFieldsMap

This change ensures field validation is performed against the moduleFields map provided by the setup task.


121-126: Simplified entry management logic

The entry management logic now:

  1. Validates field names against moduleFieldsMap
  2. Uses a more concise approach for appending entries

This makes the code easier to read and maintain.


152-154: Streamlined module field processing

The module field processing has been simplified to directly map over moduleFieldsMap entries, making the code more concise and readable.

packages/sync/src/runner/dependency-sort.unit.test.ts (6)

3-6: Good addition of the required imports for output provider testing.

The updated imports correctly include both createOutputProviderType and createProviderType, which are essential for the new tests you've added.


56-63: Well-structured test suite for provider dependencies.

This new test suite appropriately defines different provider types (regular, output, and read-only) that will be used throughout the tests. The setup is clean and follows good testing practices.


64-88: Good test for output provider dependency sorting.

This test correctly verifies that tasks with output provider dependencies are sorted so that producer tasks complete their build phase before consumer tasks can start. This is a critical behavior for the output provider concept.


90-127: Comprehensive test for mixed provider dependencies.

This test effectively validates the sorting behavior when a consumer has dependencies on both output providers and regular providers. The expected steps ensure that output producers complete their build before the consumer is initialized, which is the correct behavior.


129-153: Good coverage of read-only provider dependencies.

This test validates that read-only providers are handled correctly in the dependency sorting logic. The comment on line 149 correctly explains that the build order doesn't matter for read-only providers, which is helpful documentation.


155-205: Excellent test for complex dependency chains.

This test thoroughly validates how the dependency sorting logic handles complex scenarios with multiple types of providers and dependency relationships. The expected build order correctly respects all types of dependencies.

packages/sync/src/runner/dependency-map.unit.test.ts (6)

20-22: Good addition of outputOnlyProvider for tests.

Creating a provider specifically for testing output providers with the isOutput: true option is a good approach. This will help test the unique behavior of output providers.


367-411: Thorough test for recursive dependencies.

This test effectively validates that the task dependency resolution works correctly across multiple levels of entries (root, middle, leaf). The use of parentScopeOnly() tests an important aspect of scope inheritance.


464-500: Good test coverage for output-only providers.

This test verifies that output-only providers are correctly handled in the dependency map, ensuring that the isOutput: true option is properly passed through to dependent tasks.


502-531: Important test for intra-generator task dependencies.

This test validates an important use case: tasks within the same generator entry can have producer-consumer relationships. This is essential for complex generators that need to sequence their internal operations.


533-552: Good validation of output provider constraint.

This test ensures that the system correctly prevents using regular (non-output) providers in task outputs, which is an important validation to maintain the integrity of the output provider concept.


554-572: Good validation of non-output provider constraint in exports.

This complementary test ensures that output-only providers cannot be used in regular exports, completing the validation of provider type constraints. This helps prevent misuse of the API.

packages/fastify-generators/src/generators/core/service-file/index.ts (4)

12-13: Good import of the new output provider creator function.

Adding the import for createOutputProviderType while keeping the existing createProviderType is appropriate for the changes in this file.


50-51: Correctly updated serviceFileOutputProvider to use output provider type.

Converting serviceFileOutputProvider from a regular provider to an output provider using createOutputProviderType aligns with the PR objective of introducing output providers.


58-70: Good implementation of task outputs.

The addition of the outputs property to the task definition properly implements the output provider concept. The conditional export based on descriptor.id is a nice touch that allows for flexible scoping.


120-133: Streamlined return structure from run method.

The simplified return structure from the run method removes unnecessary complexity while maintaining the same functionality. This is a good refactoring that makes the code more maintainable.

packages/sync/src/generators/generators.unit.test.ts (5)

1-24: Good helper function for type testing.

The createTask helper function is well-designed to allow for proper type inference in the tests. The imports and type definitions are appropriately set up for comprehensive type testing.


25-60: Thorough type inference testing.

This test suite effectively validates that the type inference system works correctly with provider export and dependency maps. The use of expectTypeOf assertions ensures the type system behaves as expected.


62-73: Good coverage of basic task case with no exports.

This test verifies the most basic case of a generator task with no exports, ensuring the return type is correctly inferred and the task is properly created.


75-91: Good test for tasks with output providers only.

This test validates the case where a task has output providers but no regular exports, which is an important case to test with the new output provider concept.


93-113: Complete test for tasks with both exports and outputs.

This test ensures that the most complex case (tasks with both regular exports and output providers) works correctly, which is crucial for fully validating the type system for the new feature.

packages/sync/src/utils/create-generator.ts (4)

12-12: Updated provider imports to support output providers

The addition of Provider and ProviderExportScope types from the providers module enhances type safety and supports the new output provider functionality.


96-96: Simplified type signature for better maintainability

The task configuration type has been simplified from a complex generic type to just SimpleGeneratorTaskConfig[]. This aligns with the PR objective of streamlining the generator framework by eliminating the need for explicit task dependencies.


99-99: Added generatorName to taskBuilder

Including the generator name in the task builder provides better context awareness for tasks, which is useful for debugging and logging.


118-152: Restructured task implementation to support output providers

The task implementation has been updated to include:

  1. Support for the new outputs property (line 124)
  2. Improved return handling in the build method to return an empty object instead of undefined
  3. Simplified taskDependencies extraction

These changes correctly implement the output provider concept mentioned in the PR objectives, allowing tasks to export outputs that will be utilized once they complete building.

packages/fastify-generators/src/generators/core/request-service-context/index.ts (4)

16-17: Added createOutputProviderType to support the output provider concept

Added import of createOutputProviderType while maintaining backward compatibility by keeping the existing createProviderType import. This supports the implementation of the new output provider concept.


56-59: Changed requestServiceContextProvider to use output provider pattern

Updated requestServiceContextProvider to use createOutputProviderType instead of createProviderType. This converts it to follow the new output provider pattern, allowing it to be properly utilized by consumers after the task has completed building.


77-80: Added output configuration to setup task

Added an outputs property to the task configuration, which exports the requestServiceContext provider. This enables other tasks to consume this provider as an output rather than through task dependencies.


170-175: Simplified return structure of the build method

The build method now directly returns the requestServiceContext object, which streamlines the code and makes it more clear what output the task is producing. This is in line with the PR objective of eliminating the necessity for task dependencies.

packages/fastify-generators/src/generators/pothos/pothos/index.ts (7)

21-22: Added createOutputProviderType and updated imports

Added import for createOutputProviderType and updated yogaPluginSetupProvider to yogaPluginConfigProvider. This change supports the new output provider pattern and normalizes the naming convention to use "config" instead of "setup".

Also applies to: 31-31


51-55: Created pothosSetupOutputProvider for encapsulating configuration

Created a new output provider type using createOutputProviderType that encapsulates configuration, schema files, and Pothos types. This follows the output provider pattern, making these objects available as outputs to dependent tasks.


65-67: Added pothosSchemaOutputProvider for schema files

Created a dedicated output provider for schema files, following the same pattern as the setup output provider. This separation of concerns makes it clearer which outputs are available from different tasks.


78-85: Updated setup task to use output providers

The setup task now:

  1. Uses an inline task definition instead of a separate variable
  2. Includes outputs property with pothosSetupOutput
  3. Has a simplified build method that returns the output directly

These changes align with the PR's goal of streamlining task outputs and dependencies.

Also applies to: 114-116


121-151: Refactored schema task to use output providers

The schema task now directly consumes the pothosSetupOutput and produces a pothosSchemaOutput. This demonstrates how the output provider pattern enables cleaner data flow between tasks, as outputs from one task become direct inputs to another.


164-167: Updated main task dependencies to use output providers

The main task now:

  1. Uses yogaPluginConfig instead of yogaPluginSetup
  2. Depends on pothosSetupOutput and pothosSchemaOutput
  3. Destructures these outputs directly in the parameters

This simplifies the dependency chain and makes the data flow between tasks more explicit.

Also applies to: 172-182


296-324: Updated yoga configuration handling

The code now uses yogaPluginConfig to manage schema settings and post-schema blocks. This is more consistent with the updated pattern of using config providers instead of setup providers throughout the codebase.

packages/fastify-generators/src/generators/auth/auth/index.ts (6)

9-9: Added createSetupTask utility

Imported createSetupTask, which provides a more structured way to create setup tasks with configuration schemas.


15-28: Replaced manual provider definitions with createSetupTask

Implemented a cleaner approach using createSetupTask to define the configuration schema with properly typed fields. This utility creates both the task and the associated providers in one operation, reducing boilerplate and improving type safety.


29-31: Simplified provider exports and type definition

Exported both authConfigProvider and authSetupProvider directly from the createSetupTask result and simplified the AuthProvider to just extend ImportMapper. This reduces redundancy and improves consistency with the rest of the codebase.


42-43: Simplified task builder by using setupTask directly

Instead of manually implementing the setup task, the code now directly adds the generated setup task to the task builder. This standardizes how setup tasks are created across the codebase.


46-56: Updated main task dependencies and parameter destructuring

The main task now depends on authSetup and directly destructures the imported configuration properties in the parameters. This makes the code more concise and clearer about which configuration properties are being used.


57-80: Improved error handling and import usage

The error checking now directly validates the destructured imports, and the import map uses these imports directly. This approach is more straightforward and makes the relationship between configuration and usage clearer.

packages/core-generators/src/generators/node/typescript/index.ts (13)

130-143: Evaluate target-library mismatch in compiler settings.

The target: 'es2022' combined with lib: ['es2023'] might lead to subtle compatibility issues or transpilation discrepancies for certain newer features.

Would you like to check the official TypeScript documentation or run a web search to confirm that this mismatch won’t cause problems in your environment?


146-164: Setup task creation looks sound.

Defining both compilerOptions and references within a single setup task is a concise approach. Ensuring these options are consistently applied across multiple tasks will streamline TypeScript configuration management.


165-166: Clean export statements.

Exporting both typescriptConfigProvider and typescriptSetupProvider together clarifies their relationship and makes them straightforward to import.


167-169: Type inference strategy is correct.

Using InferProviderType to define TypescriptConfigProvider ensures types remain in sync with the underlying provider.


171-173: Seamless inference of setup provider type.

Similarly, the TypescriptSetupProvider type effectively ties the type information to the provider creation.


180-180: Setup task invocation.

Adding taskBuilder.addTask(setupTask) ensures that compiler configuration is established before other tasks run. No issues spotted.


184-187: New dependency injection.

Defining typescriptConfig as a dependency aligns well with the newly introduced providers, standardizing task usage.


190-190: Destructuring for clarity.

Pulling out compilerOptions from typescriptConfig improves readability and focuses the subsequent logic on the relevant properties.


193-193: Helper function extraction.

Moving path resolution logic into getPathEntries() is an elegant way to keep the main task function succinct.


195-195: Conditional path logic.

Checking for no paths and a minimal baseUrl provides a good fallback for simpler projects.


224-224: Fallback to 'node' resolution.

Defaulting module resolution to 'node' if not explicitly configured is sensible for Node-based projects.


270-271: Destructuring multiple config properties.

Extracting additional fields (include, exclude, etc.) from typescriptConfig keeps build logic modular.


299-302: Default destructuring for missing compiler options.

Providing fallback values (baseUrl = '.', paths = {}, moduleResolution = 'node') prevents runtime errors if omitted.

packages/react-generators/src/generators/admin/admin-crud-embedded-form/index.ts (4)

11-11: New output provider import.

Introducing createOutputProviderType suggests you’re leveraging the new output provider concept to streamline how this generator exports results.


131-134: Clear embedded form setup provider.

Defining an output provider for inputFields and tableColumns is a great approach to separate read/write responsibilities from the rest of the generator.


136-179: Well-structured 'setupForm' task.

This task accumulates embedded form inputs and columns, then cleanly exports them via adminCrudEmbeddedFormSetup. Using separate containers for input and column logic keeps the code decoupled and modular.


180-420: Comprehensive main task logic.

  1. Dynamic schema generation: Dynamically builds a Zod schema based on inputFields and optional idField.
  2. Reusable data dependencies: Merging data dependencies for both form inputs and table columns ensures consistent data loading.
  3. Conditional path: Handling the “list” vs. “object” scenario for embedded forms is neatly implemented, and generating extra props where needed is clean.
  4. Output file creation: Rendering the final TSX file with time-saving utility methods (like mergeExpressions) is clear and maintainable.

Overall, this main task is robustly structured for an admin CRUD embedded form flow.

packages/fastify-generators/src/generators/core/fastify/index.ts (8)

8-8: Switched to correct TypeScript provider import.

Importing typescriptSetupProvider ensures the new setup-based config is accessible.


13-13: Output provider creation import.

Bringing in createOutputProviderType aligns with the push toward more standardized output-based providers.


60-60: Fastify output provider defined.

Creating fastifyOutputProvider as an output clarifies its usage for exposing final flags and dev output formatting.


73-73: Disabling ESM effectively.

Using nodeSetup.isEsm.set(false, taskBuilder.generatorName); is a clean, centralized toggle for ESM usage, reducing confusion in Node-based workflows.


83-83: Swapping 'typescriptConfig' for 'typescriptSetup'.

Renaming to typescriptSetup keeps it consistent with the newly introduced setup-based approach across the codebase.


85-85: Applying TypeScript configuration.

setupFastifyTypescript(node, typescriptSetup); is neatly encapsulated, letting you configure TypeScript specifics for Fastify in one place.


100-102: Explicit fastify output export.

Adding the fastifyOutput export clarifies how other tasks or projects can consume output specifics (e.g., node flags).


152-173: Final output object.

Exposing getNodeFlags(), getNodeFlagsDev(), getNodeFlagsProd(), and getDevOutputFormatter() in the build step makes runtime configuration easily discoverable. This pattern is a clear demonstration of output providers in practice.

packages/sync/src/runner/dependency-map.ts (12)

11-21: Consider validating partial entries at runtime.

Marking GeneratorIdToScopesMap as a Partial<Record<...>> implies that some generator IDs may be missing from the map. Ensure that all consumers handle absent or undefined entries safely to avoid runtime errors or silent failures.

Would you like me to generate a quick script to grep for unchecked generatorIdToScopesMap[...] accesses that might cause undefined errors?


43-63: Robust checks for exports and outputs.

These validations properly ensure that exports aren't accidentally marked as output providers, and vice versa. The error messages are clear and will help maintain correct configurations.


71-71: Potential null reference for scope.name.

When calling includes(scope.name), confirm scope is never null or undefined, or handle it gracefully to avoid runtime errors.


84-84: Destructuring for clarity.

Extracting providers from generatorEntry clarifies usage. Continue verifying that providers is always defined before use.


132-132: Renaming parameter.

parentEntryIdsWithSelf clarifies that the current task’s own ID is included. The naming is a welcome improvement for readability.


142-142: Expanded dependency options.

Destructuring isOutput et al. from normalizedDep.options is consistent with the new output provider paradigm.


145-145: Provider ID construction.

Creating a unique string identifier for each provider/export pair is a solid approach to preventing collisions. No concerns here.


152-155: Use of findLast.

findLast is a modern ECMAScript feature. Verify that the target environment or build chain supports it. Otherwise, a polyfill or alternative approach may be needed.

Do you want a script to grep the codebase for other instances of findLast to verify environment support?


160-160: Optional chain usage.

generatorIdToScopesMap[parentEntryId]?.providers is appropriate for uncertain references. Good defensive coding against undefined lookups.


170-177: Circular dependency detection.

This error check prevents infinite loops and subtle runtime confusion. The recommended “.parentScopeOnly()” usage is helpful guidance.


178-178: Return statement clarity.

Returning the newly resolved object keeps the function self-contained and clear. No issues noted.


193-195: Extended EntryDependencyMap type.

Allowing options to store 'isReadOnly' | 'isOutput' helps track dependency metadata. This is well-aligned with the new output provider approach.

packages/fastify-generators/src/generators/prisma/prisma/index.ts (6)

16-16: Introducing output provider for Prisma.

Replacing createProviderType with createOutputProviderType aligns well with the new output-based usage.


65-65: Defining the Prisma output provider.

createOutputProviderType<PrismaOutputProvider>('prisma-output') is consistent with the pattern of identifying specialized providers. Looks good.


81-81: Refactored task creation.

This updated setup for the Prisma generator tasks better reflects the new “outputs” approach in the codebase.


92-92: Adding Prisma outputs.

Declaring { prismaOutput: prismaOutputProvider.export(projectScope) } cleanly exposes the output provider from this task. Straightforward and in line with the PR objective.


175-178: New signature with addTaskOutput.

Passing { schemaFile } back via addTaskOutput clarifies how to share build results. This is a positive improvement toward encapsulated build steps.


221-221: Calling addTaskOutput.

Using the newly introduced callback ensures that the schemaFile is properly exposed to downstream tasks. Good consistency with the API.

packages/fastify-generators/src/generators/yoga/yoga-plugin/index.ts (11)

2-5: Importing field-map utilities.

You’re leveraging FieldMapValues and InferFieldMapSchemaFromBuilder to define typed schema configurations. This import is consistent with the new approach to typed config.


17-17: Adopting createOutputProviderType.

Replacing a standard provider with an output provider clarifies that this plugin setup is intended to produce final outputs rather than internal dependencies.


20-23: Field map creation methods.

Importing createFieldMap and createFieldMapSchemaBuilder indicates a move toward applying typed schema definitions for plugin configuration. This is a strong approach for type safety.


46-65: Building schema for plugin configuration.

Defining a new field map schema using arrays and scalars fosters clarity. This approach is beneficial for ensuring typed plugin settings.


66-67: Extending configuration interface.

YogaPluginConfigProvider extends the typed schema builder and adds isSubscriptionEnabled(). Clean separation of logic.


71-72: Dedicated config provider.

yogaPluginConfigProvider neatly centralizes this plugin’s config, supporting the new design pattern.


74-77: Setting up a specialized output provider.

yogaPluginSetupProvider uses createOutputProviderType for returning the final field map values. This ensures tasks can register them as outputs.


85-89: Export vs. outputs usage.

The setup task exports yogaPluginConfig but also provides yogaPluginSetup as an output. This aligns perfectly with the new approach of splitting internal vs. final providers.

Also applies to: 91-91


94-94: Creating the config field map.

createFieldMap(schemaBuilder) is a succinct approach to building and retrieving typed configuration values. Straightforward and effective.


104-106: Returning getValues() as setup output.

Exposing configMap.getValues() ensures the final output remains immutable from outside, aligning with read-only provider principles.


138-138: Referencing yogaPluginSetup in main.

The updated dependencies reference yogaPluginSetupProvider and retrieve config for build. This centralizes the plugin’s final configurations, clarifying the pipeline flow.

Also applies to: 140-148

packages/sync/src/providers/providers.ts (11)

8-11: Consider verifying widened Provider type.

Changing from a function-based record to a record of unknown values may reduce type safety. If this is deliberate (to store additional non-function data), please confirm no unintended usage conflicts or type mismatches across the codebase.


33-36: Good addition of the isOutput property.

This clarifies that the provider is used as a read-only output provider, helping readers differentiate output providers from other provider types.


47-47: Inference helper looks good.

Using conditional types to infer the provider interface is a clean approach for type safety.


58-65: Check duplication of isOutput in ProviderDependencyOptions.

isOutput is declared both here and in ProviderType. If these flags can differ, it may cause confusion. Otherwise, consider consolidating or clarifying their usage.

Also applies to: 70-75


118-118: Consistent usage of isOutput.

Enforcing a non-optional boolean here ensures clarity that all exports declare whether they are an output provider or not.


142-146: Property isOutput in ProviderTypeOptions is consistent.

Defining isOutput at the options level mirrors other new fields and maintains alignment with the broader provider concept.


182-185: Passing isReadOnly and isOutput into dependency options.

This maintains consistency across dependencies and the overarching provider metadata.


206-208: Implementation of parentScopeOnly aligns well with the new flag.

Straightforward usage of toMerged to set useParentScope keeps the dependency logic clean.


215-215: Defaulting isOutput to false is a solid fallback.

Ensuring a sensible default helps avoid accidental classification as an output provider.


226-226: No meaningful change here.


227-239: createOutputProviderType implementation is straightforward.

Neatly wraps createProviderType with isOutput: true, simplifying the creation of output providers.

packages/utils/src/field-map/field-map.ts (12)

1-19: Base FieldContainer design looks solid.

The approach of storing a private _value, a default value, and a setValue method is clear and encapsulates state well.


21-34: ScalarContainer enforcement of single assignment is well done.

Providing a source string is especially helpful for debugging overwrite attempts.


36-59: ArrayContainer is flexible, with optional de-duplication.

Allowing separate toggles for duplicate removal can cover a wide variety of use cases.


61-100: ObjectContainer merges default values with newly set keys effectively.

The merge() method elegantly reuses set(), simplifying the setting logic.


102-147: MapContainer nicely extends the container concept to maps.

Support of both merge() and mergeObj() covers typical use cases for map-based data structures.


149-150: InferFieldContainer type is succinct.

Extracting the inner value type from any container ensures consistent usage in larger type definitions.


151-158: FieldMapSchema and FieldMapValues support typed retrieval.

This design ensures that calling getValues() returns the correct shape of data.


159-162: FieldMap type extends the schema with a user-friendly interface.

Including getValues() on the returned map fosters clarity in data handling.


164-212: FieldMapSchemaBuilder systematically provides typed containers.

Provisioning methods for scalar, array, object, etc., yields a fluent API for complex field definitions.


214-218: createFieldMapSchemaBuilder is a clean factory approach.

Delegating schema construction to a builder function is consistent and portable.


220-223: InferFieldMapSchemaFromBuilder utility type is well-defined.

Promotes reusability when we need to infer schema types from custom builders.


227-246: createFieldMap final assembly is well-structured.

Wrapping the schema with a getValues() method completes the fluent approach, allowing easy data retrieval.

packages/utils/src/field-map/field-map.unit.test.ts (1)

1-175: Comprehensive test suite for FieldMap functionality.

Tests cover scalar, array, object, and map containers thoroughly, verifying default values, single vs. multiple assignments, and merging behaviors. This ensures robust validation of the new field containers.

packages/sync/src/generators/generators.ts (8)

46-50: Type consistency for handling undefined.

This updated conditional type properly returns undefined if T is undefined, enhancing clarity and correctness in usage.


55-59: Aligns with InferExportProviderMap.

Similarly, this definition cleanly mirrors the logic above, ensuring undefined is returned when the type parameter is undefined.


85-85: Interface naming is consistent.

GeneratorTaskResultBuildersWithNoOutputs complements the “with outputs” interface. No issues found.


92-97: Neat utility type.

IsEmpty is helpful for building conditional types. This looks fine, but keep in mind how optional or index-signature properties might affect the detection of an “empty” object.


122-128: Optional output bridging.

Adding OutputMap to the type parameters on GeneratorTask allows more flexible usage without forcing outputs on every task.


138-141: Introducing outputs property.

Exposing outputs?: OutputMap clarifies that a generator task may produce providers beyond its exports, aligning with the new output provider concept.


157-160: Return type updated for new structure.

Tying run into GeneratorTaskResult respects both exports and outputs. The changes appear consistent with the rest of the file.


98-116:

Details

❓ Verification inconclusive

Verify “OutputMap extends true” usage.

This intersection type logic is well-structured overall. However, the condition OutputMap extends true in line 111 is unusual—please confirm if this is intended, or if you meant to check OutputMap differently.

Please run the following command to locate references and confirm usage:


🏁 Script executed:

#!/bin/bash
rg "OutputMap extends true"

Length of output: 98


Clarify the Intent of the OutputMap extends true Check

  • The intersection type logic is well-organized, but the condition OutputMap extends true in line 111 appears unusual.
  • The grep search confirms this is the only instance of this pattern in the repository.
  • Please confirm whether this usage is intentional—for example, to signal that no output builders should be generated—or if it should be replaced by a check (such as using IsEmpty<OutputMap>) similar to how ExportMap is handled.
  • If the current logic is correct, consider adding an inline comment to clarify its purpose for future maintainers.
packages/sync/src/utils/create-generator-types.ts (8)

48-64: Flexible type parameters for optional outputs.

Enabling ExportMap and OutputMap to be undefined helps in tasks that may not export or produce any providers. The build function signature is now more expressive, accommodating additional task outputs.


74-107: Extended configuration for outputs.

SimpleGeneratorTaskConfig now supports an OutputMap, providing stronger typing for generator outputs. This design should streamline tasks that only sometimes produce outputs.


109-112: Refined TaskConfigBuilder type.

Allowing OutputMap to be optional here is consistent with the rest of the changes, permitting tasks to declare outputs only if needed.


131-131: Extracting task output.

The reference to ProviderExportMap in ExtractTaskOutputFromBuilder cleanly extends the existing pattern for extracting typed outputs.


138-142: Task builder map flexible outputs.

This extension ensures each builder can declare its own exports and outputs. No immediate issues identified.


153-157: createTaskConfigBuilder with optional outputs.

Providing defaults for ExportMap and OutputMap further refines tasks that might only produce side effects. The approach seems well-integrated.


183-184: Explicit generatorName usage.

Introducing a generatorName property into the builder interface clarifies the source or identity of the tasks being built. Looks good.


185-209: Extended addTask signature.

Allowing each task to independently specify whether it uses an OutputMap fosters modular, reusable creations without imposing outputs on every task configuration.

Comment on lines +242 to +243
id: 'simple:output',
contents: 'output',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Check ID consistency in test expectations

There appears to be a mismatch between the IDs used in builder.writeFile() calls ('output', 'consumer') and the expected IDs in the test assertions ('simple:output', 'simple:consumer').

Verify that this is intentional behavior or if there might be a mistake in the test expectations:

Also applies to: 247-248


🏁 Script executed:

#!/bin/bash
# Search for any code that might explain ID transformation logic
rg -A 2 "id: '.*?'" --glob "*.ts" | grep -v "file_id" | head -n 20

Length of output: 1703


Action Required: Confirm and Fix ID Prefix Mismatch

Our search did not reveal any transformation logic that would add a "simple:" prefix to file IDs. In other parts of the codebase (e.g., in the generators for eslint, prettier, etc.), IDs are defined without any such prefix. Meanwhile, the test in packages/sync/src/runner/generator-runner.unit.test.ts (lines 242‑243 and 247‑248) expects IDs like "simple:output" and "simple:consumer", suggesting an inconsistency between the generated file IDs (e.g., "output" and "consumer") and what the tests assert.

Please verify if the test expectations should be updated to match the actual IDs from builder.writeFile() or if the generator should apply the "simple:" prefix as intended. Reviewing and resolving this inconsistency will prevent potential assertion failures in future test runs.

Comment on lines +224 to +273
prismaOutput: {
getImportMap: () => ({
'%prisma-service': {
path: '@/src/services/prisma.js',
allowedImports: ['prisma'],
},
}),
getPrismaServicePath: () => '@/src/services/prisma.js',
getPrismaClient: () =>
TypescriptCodeUtils.createExpression(
'prisma',
"import { prisma } from '@/src/services/prisma.js'",
),
getPrismaModel: (modelName) => {
const modelBlock = schemaFile.getModelBlock(modelName);
if (!modelBlock) {
throw new Error(`Model ${modelName} not found`);
}
return modelBlock;
},
}),
getPrismaServicePath: () => '@/src/services/prisma.js',
getPrismaClient: () =>
TypescriptCodeUtils.createExpression(
'prisma',
"import { prisma } from '@/src/services/prisma.js'",
),
getPrismaModel: (modelName) => {
const modelBlock = schemaFile.getModelBlock(modelName);
if (!modelBlock) {
throw new Error(`Model ${modelName} not found`);
}
return modelBlock;
},
getServiceEnum: (name) => {
const block = schemaFile.getEnum(name);
if (!block) {
throw new Error(`Enum ${name} not found`);
}
return {
name: block.name,
values: block.values,
expression: TypescriptCodeUtils.createExpression(
block.name,
`import { ${block.name} } from '@prisma/client'`,
getServiceEnum: (name) => {
const block = schemaFile.getEnum(name);
if (!block) {
throw new Error(`Enum ${name} not found`);
}
return {
name: block.name,
values: block.values,
expression: TypescriptCodeUtils.createExpression(
block.name,
`import { ${block.name} } from '@prisma/client'`,
),
};
},
getPrismaModelExpression: (modelName) => {
const modelExport =
modelName.charAt(0).toLocaleLowerCase() +
modelName.slice(1);
return TypescriptCodeUtils.createExpression(
`prisma.${modelExport}`,
"import { prisma } from '@/src/services/prisma.js'",
);
},
getModelTypeExpression: (modelName) =>
TypescriptCodeUtils.createExpression(
modelName,
`import { ${modelName} } from '@prisma/client'`,
),
};
},
getPrismaModelExpression: (modelName) => {
const modelExport =
modelName.charAt(0).toLocaleLowerCase() + modelName.slice(1);
return TypescriptCodeUtils.createExpression(
`prisma.${modelExport}`,
"import { prisma } from '@/src/services/prisma.js'",
);
},
getModelTypeExpression: (modelName) =>
TypescriptCodeUtils.createExpression(
modelName,
`import { ${modelName} } from '@prisma/client'`,
),
},
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Comprehensive Prisma output methods.

This block provides complete model, enum, and client references. The additional error handling for missing models/enums is good. Consider unit tests to ensure coverage of all these getters.

Would you like me to propose a small test suite demonstrating usage and error conditions for these methods?

@kingston kingston merged commit 24fed42 into main Apr 1, 2025
7 checks passed
@kingston kingston deleted the kingston/eng-590-introduce-output-provider-system-to-replace-task branch April 1, 2025 13:39
@github-actions github-actions bot mentioned this pull request Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants