dryvPacks

@dryv/nextjs-appv0.1.0

Next.js App Router pages from views, typed API calls and schema-driven forms.

Next.js AppFrontendUnitPublished 7 days ago2 downloads

dryv pack add @dryv/nextjs-app
2.9 KBRaw ↗
yaml
version: dryv.pack/v1alpha1
key: unit.frontend.nextjs-app
layout: unit
source: templates

info:
  title: Next.js App
  version: 0.1.0
  description: Generates Next.js App Router pages from views, with typed API calls for HTTP operations and schema-driven forms and results.
  purpose: frontend
  summary: Next.js App Router pages from views, typed API calls and schema-driven forms.
  languages: [typescript]
  frameworks: [nextjs, react]
  tags: [frontend, pages, app-router, forms]

plugins:
  - name: jinja
    extensions: [.j2]

selections:
  enums:
    subject: property.enum
    scope: each

  models:
    subject: schema
    scope: each

  # Pages can only call operations that are reachable over HTTP.
  operations:
    subject: operation
    filter:
      all: { facet: http }
    scope: each

  pages:
    subject: view
    scope: each

templates:
  enum:
    $ref: '#/selections/enums'
    output:
      name: $(subject.name.kebab)
      symbol: $(subject.name.pascal)

  model:
    $ref: '#/selections/models'
    output:
      name: $(subject.name.kebab)
      symbol: $(subject.name.pascal)
    imports:
      - $ref: '#/templates/enum'
      - $ref: '#/templates/model'

  operation:
    $ref: '#/selections/operations'
    output:
      name: $(subject.name.kebab)
      path:
        - $(group.name.kebab)
      symbol: $(subject.name.camel)
    imports:
      - $ref: '#/templates/model'
      - $ref: '#/templates/enum'

  page:
    $ref: '#/selections/pages'
    output:
      path:
        - $(group.name.kebab)
        - $(subject.name.kebab)
      symbol: $(subject.name.pascal)Page
    imports:
      - $ref: '#/needs/operation.client'
      - $ref: '#/templates/operation'
      - $ref: '#/templates/model'

# Pages call operations through whichever pack the project binds here (for example
# clients/next-api-bridge). Unbound, they use this pack's own fetch-based calls.
needs:
  operation.client: { required: false }

# shared:js-package-manager:start
choose:
  js.package_manager: { options: [pnpm, npm, bun, yarn] }
# shared:js-package-manager:end

# The pages and components import these; install adds them to the app's package.json.
dependencies:
  runtime:
    next: ^16
    react: ^19
    react-dom: ^19
  dev:
    prettier: "*"

# shared:js-prettier-tsx-actions:start
actions:
  files:
    format:
      extensions: [.ts, .tsx]
      commands:
        - run: [(pnpm|yarn), dlx, [email protected], --ignore-path, .prettier-none, --write, $(files)]
        - run: [npm, exec, --yes, --package, [email protected], --, prettier, --ignore-path, .prettier-none, --write, $(files)]
        - run: [bun, x, [email protected], --ignore-path, .prettier-none, --write, $(files)]
  final:
    install:
      dependencies:
        args:
          - dev: { (pnpm|yarn): [-D], bun: [--dev], npm: [--save-dev] }
          - { pinned: "$(name)@$(version)", any: "$(name)" }
      commands:
        - run: [(pnpm|bun|yarn), add]
        - run: [npm, install]
# shared:js-prettier-tsx-actions:end