tatethurston / nextjs-routes

Type safe routing for Next.js
MIT License
553 stars 20 forks source link

nxdev, Could not find a Next.js pages directory. #152

Closed airtonix closed 1 year ago

airtonix commented 1 year ago

because it is assumed that the plugin will find the app or pages directory relative to process.cwd(), this plugin doesn't work in a nxdev monorepo.

The solution is to:


edit:

airtonix commented 1 year ago

nvm i just discovered the undocumented cwd option

tatethurston commented 1 year ago

@airtonix are you using the configuration option described in the docs?

const withRoutes = require("nextjs-routes/config")({
  cwd: __dirname,
});

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
};

- module.exports = nextConfig;
+ module.exports = withRoutes(nextConfig);
airtonix commented 1 year ago

@tatethurston sorry, no i wasn't.

edit: I've collapsed all my comment spam.

//@ts-check
import * as path from 'path';
import compose from 'lodash/fp/compose.js';
import { withNx } from '@nrwl/next/plugins/with-nx.js';
import { createVanillaExtractPlugin } from '@vanilla-extract/next-plugin';
import { createContentlayerPlugin } from 'next-contentlayer';
import withRoutes from 'nextjs-routes/config';

/**
 * @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
 **/
const nextConfig = {
  nx: {
    // Set this to true if you would like to use SVGR
    // See: https://github.com/gregberge/svgr
    svgr: true,
  },
  swcMinify: true,
  experimental: { appDir: true },
};

export default compose(
  withNx,
  withRoutes(),
  createContentlayerPlugin({
    configPath: 'contentlayer.config.ts',
  }),
  createVanillaExtractPlugin({ identifiers: 'debug' })
)(nextConfig);
x yarn nx run website:serve

> nx run website:serve:development

warn  - You have enabled experimental feature (appDir) in next.config.mjs.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

Your tsconfig.json extends another configuration, which means we cannot add the Next.js TypeScript plugin automatically. To improve your development experience, we recommend adding the Next.js plugin (`"plugins": [{ "name": "next" }]`) manually to your TypeScript configuration. Learn more: https://beta.nextjs.org/docs/configuring/typescript#using-the-typescript-plugin

[nextjs-routes] Could not find a Next.js pages directory. Expected to find either 'pages' (1), 'src/pages' (2), or 'app' (3) in your project root.

  1. https://nextjs.org/docs/basic-features/pages
  2. https://nextjs.org/docs/advanced-features/src-directory
  3. https://nextjs.org/blog/next-13#app-directory-beta
airtonix commented 1 year ago
.
├── apps
│   ├── storybook
│   │   ├── project.json
│   │   ├── tsconfig.json
│   │   └── tsconfig.spec.json
│   ├── website
│   │   ├── app
│   │   │   ├── components
│   │   │   │   └── Illustration
│   │   │   │       ├── Illustration.tsx
│   │   │   │       └── index.ts
│   │   │   ├── globalstyle.css.ts
│   │   │   ├── head.tsx
│   │   │   ├── layout.tsx
│   │   │   ├── page.tsx
│   │   │   ├── posts
│   │   │   │   └── [slug]
│   │   │   │       └── page.tsx
│   │   │   └── styles.css.ts
│   │   ├── components
│   │   │   ├── common
│   │   │   │   └── AppLayout
│   │   │   │       ├── applayout.css.ts
│   │   │   │       ├── AppLayout.tsx
│   │   │   │       ├── index.ts
│   │   │   │       └── styles.css.ts
│   │   │   └── home
│   │   │       ├── HomePage
│   │   │       │   ├── HomePageContainer.tsx
│   │   │       │   ├── HomePage.tsx
│   │   │       │   └── index.ts
│   │   │       ├── LandingCard
│   │   │       │   ├── index.ts
│   │   │       │   ├── LandingCardContainer.tsx
│   │   │       │   ├── LandingCard.tsx
│   │   │       │   └── styles.css.ts
│   │   │       └── PostCard
│   │   │           ├── PostCard.tsx
│   │   │           └── styles.css.ts
│   │   ├── contentlayer.config.ts
│   │   ├── index.d.ts
│   │   ├── jest.config.ts
│   │   ├── next.config.mjs
│   │   ├── next-env.d.ts
│   │   ├── project.json
│   │   ├── public
│   │   ├── services
│   │   │   └── Cms
│   │   │       ├── Collections
│   │   │       │   └── Posts
│   │   │       │       └── PostCollectionModel.ts
│   │   │       ├── index.ts
│   │   │       └── Server.ts
│   │   ├── tsconfig.json
│   │   └── tsconfig.spec.json
│   └── website-e2e
│       ├── cypress.config.ts
│       ├── project.json
│       ├── src
│       │   ├── e2e
│       │   │   └── app.cy.ts
│       │   ├── fixtures
│       │   │   └── example.json
│       │   └── support
│       │       ├── app.po.ts
│       │       ├── commands.ts
│       │       └── e2e.ts
│       └── tsconfig.json
├── babel.config.json
├── CODEOWNERS
├── designs
│   ├── github-profile.svg
│   ├── README.md
│   ├── website.png
│   └── website.svg
├── jest.config.ts
├── jest.preset.js
├── justfile
├── node_modules
│   ├── @babel
│   │   ├── core -> ../.store/@babel-core-npm-7.12.13-63c8ede804/node_modules/@babel/core
│   │   ├── preset-react -> ../.store/@babel-preset-react-virtual-a5b987b2e2/node_modules/@babel/preset-react
│   │   └── preset-typescript -> ../.store/@babel-preset-typescript-virtual-230981365d/node_modules/@babel/preset-typescript
│   ├── babel-jest -> .store/babel-jest-virtual-dee3cd8961/node_modules/babel-jest
│   ├── babel-loader -> .store/babel-loader-virtual-6b1a35c1e9/node_modules/babel-loader
│   ├── @capsizecss
│   │   └── vanilla-extract -> ../.store/@capsizecss-vanilla-extract-virtual-dd106bb7f1/node_modules/@capsizecss/vanilla-extract
│   ├── chroma-js -> .store/chroma-js-npm-2.4.2-76dd14218f/node_modules/chroma-js
│   ├── classnames -> .store/classnames-npm-2.3.2-d2fdae468d/node_modules/classnames
│   ├── clsx -> .store/clsx-npm-1.2.1-77792dc182/node_modules/clsx
│   ├── contentlayer -> .store/contentlayer-npm-0.3.1-47866d7c31/node_modules/contentlayer
│   ├── contentlayer-source-notion -> .store/contentlayer-source-notion-npm-0.0.1-alpha.24-6e56557fc6/node_modules/contentlayer-source-notion
│   ├── core-js -> .store/core-js-npm-3.30.0-42482538d7/node_modules/core-js
│   ├── css-loader -> .store/css-loader-virtual-b92e79e2fc/node_modules/css-loader
│   ├── csstype -> .store/csstype-npm-3.1.2-cead7d99b2/node_modules/csstype
│   ├── cypress -> .store/cypress-npm-12.9.0-0c9e067ccc/node_modules/cypress
│   ├── date-fns -> .store/date-fns-npm-2.29.3-fef7e3c72c/node_modules/date-fns
│   ├── emery -> .store/emery-npm-1.4.2-4dfc48712a/node_modules/emery
│   ├── eslint -> .store/eslint-npm-8.38.0-552d805c27/node_modules/eslint
│   ├── eslint-config-next -> .store/eslint-config-next-virtual-6cec41fdd8/node_modules/eslint-config-next
│   ├── eslint-config-prettier -> .store/eslint-config-prettier-virtual-7eee863a1c/node_modules/eslint-config-prettier
│   ├── eslint-plugin-cypress -> .store/eslint-plugin-cypress-virtual-45435d4432/node_modules/eslint-plugin-cypress
│   ├── eslint-plugin-import -> .store/eslint-plugin-import-virtual-810bbabe73/node_modules/eslint-plugin-import
│   ├── eslint-plugin-jsx-a11y -> .store/eslint-plugin-jsx-a11y-virtual-d902424f9b/node_modules/eslint-plugin-jsx-a11y
│   ├── eslint-plugin-react -> .store/eslint-plugin-react-virtual-ef0c2b538d/node_modules/eslint-plugin-react
│   ├── eslint-plugin-react-hooks -> .store/eslint-plugin-react-hooks-virtual-44a52b52e3/node_modules/eslint-plugin-react-hooks
│   ├── @faker-js
│   │   └── faker -> ../.store/@faker-js-faker-npm-7.6.0-fa135883e9/node_modules/@faker-js/faker
│   ├── file-loader -> .store/file-loader-virtual-564427dc49/node_modules/file-loader
│   ├── html-webpack-plugin -> .store/html-webpack-plugin-virtual-8bce548f85/node_modules/html-webpack-plugin
│   ├── husky -> .store/husky-npm-8.0.3-b0b59c5127/node_modules/husky
│   ├── @iconify
│   │   └── react -> ../.store/@iconify-react-virtual-27b56a69d7/node_modules/@iconify/react
│   ├── jest -> .store/jest-virtual-67bfa6b930/node_modules/jest
│   ├── jest-environment-jsdom -> .store/jest-environment-jsdom-virtual-9391bc0c52/node_modules/jest-environment-jsdom
│   ├── lint-staged -> .store/lint-staged-npm-13.2.0-204330f6dc/node_modules/lint-staged
│   ├── lodash -> .store/lodash-npm-4.17.21-6382451519/node_modules/lodash
│   ├── markdown-wasm -> .store/markdown-wasm-npm-1.2.0-6360ed1a80/node_modules/markdown-wasm
│   ├── @mdx-js
│   │   ├── loader -> ../.store/@mdx-js-loader-virtual-510ebeac68/node_modules/@mdx-js/loader
│   │   └── react -> ../.store/@mdx-js-react-virtual-8244acd674/node_modules/@mdx-js/react
│   ├── mini-css-extract-plugin -> .store/mini-css-extract-plugin-virtual-e444546587/node_modules/mini-css-extract-plugin
│   ├── @next
│   │   ├── font -> ../.store/@next-font-npm-13.0.6-1eb20fd7e9/node_modules/@next/font
│   │   └── mdx -> ../.store/@next-mdx-virtual-8974a14f79/node_modules/@next/mdx
│   ├── next -> .store/next-virtual-928c6c43ab/node_modules/next
│   ├── next-contentlayer -> .store/next-contentlayer-virtual-366c9deefb/node_modules/next-contentlayer
│   ├── nextjs-routes -> .store/nextjs-routes-virtual-a8cec29a8b/node_modules/nextjs-routes
│   ├── @notionhq
│   │   └── client -> ../.store/@notionhq-client-npm-2.2.4-6b81fa0e0e/node_modules/@notionhq/client
│   ├── @notion-render
│   │   └── client -> ../.store/@notion-render-client-npm-1.0.0-rc.1-6806ddbe24/node_modules/@notion-render/client
│   ├── npm-run-all -> .store/npm-run-all-npm-4.1.5-3281f1c563/node_modules/npm-run-all
│   ├── @nrwl
│   │   ├── cypress -> ../.store/@nrwl-cypress-virtual-f9e486c8af/node_modules/@nrwl/cypress
│   │   ├── devkit -> ../.store/@nrwl-devkit-virtual-53e37190bb/node_modules/@nrwl/devkit
│   │   ├── eslint-plugin-nx -> ../.store/@nrwl-eslint-plugin-nx-virtual-e6f6fda462/node_modules/@nrwl/eslint-plugin-nx
│   │   ├── jest -> ../.store/@nrwl-jest-npm-15.9.2-b185348efe/node_modules/@nrwl/jest
│   │   ├── js -> ../.store/@nrwl-js-npm-15.9.2-35780de22b/node_modules/@nrwl/js
│   │   ├── linter -> ../.store/@nrwl-linter-virtual-e621dc3edc/node_modules/@nrwl/linter
│   │   ├── next -> ../.store/@nrwl-next-virtual-8028dded9e/node_modules/@nrwl/next
│   │   ├── nx-plugin -> ../.store/@nrwl-nx-plugin-npm-15.9.2-de0455b545/node_modules/@nrwl/nx-plugin
│   │   ├── react -> ../.store/@nrwl-react-npm-15.9.2-c80086e39d/node_modules/@nrwl/react
│   │   ├── storybook -> ../.store/@nrwl-storybook-npm-15.9.2-6c69b43d70/node_modules/@nrwl/storybook
│   │   ├── web -> ../.store/@nrwl-web-npm-15.9.2-4a784d61cc/node_modules/@nrwl/web
│   │   ├── webpack -> ../.store/@nrwl-webpack-npm-15.9.2-fd28063591/node_modules/@nrwl/webpack
│   │   └── workspace -> ../.store/@nrwl-workspace-npm-15.9.2-b61cd9fa68/node_modules/@nrwl/workspace
│   ├── nx -> .store/nx-virtual-bb192f4592/node_modules/nx
│   ├── polished -> .store/polished-npm-4.2.2-eb3d423b8d/node_modules/polished
│   ├── prettier -> .store/prettier-npm-2.8.7-1962ac9483/node_modules/prettier
│   ├── @radix-ui
│   │   ├── colors -> ../.store/@radix-ui-colors-npm-0.1.8-351c651cab/node_modules/@radix-ui/colors
│   │   └── react-slot -> ../.store/@radix-ui-react-slot-virtual-6a9431d7f2/node_modules/@radix-ui/react-slot
│   ├── rainbow-sprinkles -> .store/rainbow-sprinkles-virtual-3a56ab8e6f/node_modules/rainbow-sprinkles
│   ├── react -> .store/react-npm-18.2.0-1eae08fee2/node_modules/react
│   ├── react-dom -> .store/react-dom-virtual-cdc029d6b3/node_modules/react-dom
│   ├── react-image -> .store/react-image-virtual-1e19c90fd0/node_modules/react-image
│   ├── react-imgix -> .store/react-imgix-virtual-3250fab9f0/node_modules/react-imgix
│   ├── react-test-renderer -> .store/react-test-renderer-virtual-6d25ebbf4f/node_modules/react-test-renderer
│   ├── @storybook
│   │   ├── addon-actions -> ../.store/@storybook-addon-actions-virtual-fd9b948840/node_modules/@storybook/addon-actions
│   │   ├── addon-essentials -> ../.store/@storybook-addon-essentials-virtual-1e32814f2f/node_modules/@storybook/addon-essentials
│   │   ├── addon-styling -> ../.store/@storybook-addon-styling-virtual-9bbf171096/node_modules/@storybook/addon-styling
│   │   ├── builder-webpack5 -> ../.store/@storybook-builder-webpack5-virtual-e1b694b263/node_modules/@storybook/builder-webpack5
│   │   ├── core-common -> ../.store/@storybook-core-common-npm-7.0.2-e9feab48c2/node_modules/@storybook/core-common
│   │   ├── core-server -> ../.store/@storybook-core-server-npm-7.0.2-aaf1f7f67f/node_modules/@storybook/core-server
│   │   ├── nextjs -> ../.store/@storybook-nextjs-virtual-de727f8d1f/node_modules/@storybook/nextjs
│   │   └── react -> ../.store/@storybook-react-virtual-1692b8f361/node_modules/@storybook/react
│   ├── storybook-addon-next -> .store/storybook-addon-next-virtual-b34616e50c/node_modules/storybook-addon-next
│   ├── storybook-addon-swc -> .store/storybook-addon-swc-virtual-48b61f8f2b/node_modules/storybook-addon-swc
│   ├── storybook-dark-mode -> .store/storybook-dark-mode-virtual-e0629413fe/node_modules/storybook-dark-mode
│   ├── styled-jsx -> .store/styled-jsx-virtual-b8bd6398aa/node_modules/styled-jsx
│   ├── @svgr
│   │   └── webpack -> ../.store/@svgr-webpack-npm-7.0.0-7d5f3db08e/node_modules/@svgr/webpack
│   ├── @swc
│   │   ├── cli -> ../.store/@swc-cli-virtual-f5d1e4b4e4/node_modules/@swc/cli
│   │   ├── core -> ../.store/@swc-core-virtual-91e7f496a8/node_modules/@swc/core
│   │   ├── helpers -> ../.store/@swc-helpers-npm-0.4.14-f806c3fb16/node_modules/@swc/helpers
│   │   └── jest -> ../.store/@swc-jest-virtual-40af8e9334/node_modules/@swc/jest
│   ├── syncpack -> .store/syncpack-npm-9.8.4-9f99e1a628/node_modules/syncpack
│   ├── tailwindcss -> .store/tailwindcss-virtual-38755a9d84/node_modules/tailwindcss
│   ├── @testing-library
│   │   └── react -> ../.store/@testing-library-react-virtual-f1187c0973/node_modules/@testing-library/react
│   ├── ts-deepmerge -> .store/ts-deepmerge-npm-6.0.3-1f27e1dfcd/node_modules/ts-deepmerge
│   ├── ts-jest -> .store/ts-jest-virtual-1ddb989f27/node_modules/ts-jest
│   ├── tslib -> .store/tslib-npm-2.5.0-bb364efebd/node_modules/tslib
│   ├── ts-node -> .store/ts-node-virtual-12b0408854/node_modules/ts-node
│   ├── @types
│   │   ├── chroma-js -> ../.store/@types-chroma-js-npm-2.4.0-b20bbff611/node_modules/@types/chroma-js
│   │   ├── jest -> ../.store/@types-jest-npm-29.5.0-18eef6c3cc/node_modules/@types/jest
│   │   ├── lodash -> ../.store/@types-lodash-npm-4.14.192-07db4ce649/node_modules/@types/lodash
│   │   ├── node -> ../.store/@types-node-npm-18.14.2-ba0496d563/node_modules/@types/node
│   │   ├── react -> ../.store/@types-react-npm-18.0.28-c6157151cc/node_modules/@types/react
│   │   ├── react-dom -> ../.store/@types-react-dom-npm-18.0.11-27f8db2995/node_modules/@types/react-dom
│   │   └── react-imgix -> ../.store/@types-react-imgix-npm-9.5.0-49fda41b13/node_modules/@types/react-imgix
│   ├── typescript -> .store/typescript-patch-72dc6f164f/node_modules/typescript
│   ├── @typescript-eslint
│   │   ├── eslint-plugin -> ../.store/@typescript-eslint-eslint-plugin-virtual-7c6e2b8337/node_modules/@typescript-eslint/eslint-plugin
│   │   └── parser -> ../.store/@typescript-eslint-parser-virtual-9f5d973467/node_modules/@typescript-eslint/parser
│   ├── url-loader -> .store/url-loader-virtual-3b82107004/node_modules/url-loader
│   ├── usehooks-ts -> .store/usehooks-ts-virtual-455e28ac9e/node_modules/usehooks-ts
│   ├── util -> .store/util-npm-0.12.5-3668276f26/node_modules/util
│   ├── @vanilla-extract
│   │   ├── css -> ../.store/@vanilla-extract-css-npm-1.11.0-85c0e923bd/node_modules/@vanilla-extract/css
│   │   ├── css-utils -> ../.store/@vanilla-extract-css-utils-npm-0.1.3-5d3d0d7795/node_modules/@vanilla-extract/css-utils
│   │   ├── dynamic -> ../.store/@vanilla-extract-dynamic-npm-2.0.3-5224c4cda8/node_modules/@vanilla-extract/dynamic
│   │   ├── next-plugin -> ../.store/@vanilla-extract-next-plugin-virtual-af045a766a/node_modules/@vanilla-extract/next-plugin
│   │   ├── recipes -> ../.store/@vanilla-extract-recipes-virtual-2fc518c369/node_modules/@vanilla-extract/recipes
│   │   ├── sprinkles -> ../.store/@vanilla-extract-sprinkles-virtual-58c2b84fd7/node_modules/@vanilla-extract/sprinkles
│   │   ├── vite-plugin -> ../.store/@vanilla-extract-vite-plugin-virtual-1271416eee/node_modules/@vanilla-extract/vite-plugin
│   │   └── webpack-plugin -> ../.store/@vanilla-extract-webpack-plugin-virtual-f14e7ec9f1/node_modules/@vanilla-extract/webpack-plugin
│   └── webpack -> .store/webpack-virtual-aeea1a4b4b/node_modules/webpack
├── nx.json
├── package.json
├── pkg
│   ├── ds
│   │   ├── box
│   │   │   ├── jest.config.ts
│   │   │   ├── project.json
│   │   │   ├── README.md
│   │   │   ├── src
│   │   │   │   ├── index.ts
│   │   │   │   └── lib
│   │   │   │       ├── ds-box.spec.tsx
│   │   │   │       ├── ds-box.stories.tsx
│   │   │   │       └── ds-box.tsx
│   │   │   ├── tsconfig.json
│   │   │   ├── tsconfig.lib.json
│   │   │   └── tsconfig.spec.json
│   │   ├── button
│   │   │   ├── jest.config.ts
│   │   │   ├── project.json
│   │   │   ├── README.md
│   │   │   ├── src
│   │   │   │   ├── index.ts
│   │   │   │   └── lib
│   │   │   │       ├── ds-button.css.ts
│   │   │   │       ├── ds-button.spec.tsx
│   │   │   │       └── ds-button.tsx
│   │   │   ├── tsconfig.json
│   │   │   ├── tsconfig.lib.json
│   │   │   └── tsconfig.spec.json
│   │   ├── card
│   │   │   ├── jest.config.ts
│   │   │   ├── project.json
│   │   │   ├── README.md
│   │   │   ├── src
│   │   │   │   ├── index.ts
│   │   │   │   └── lib
│   │   │   │       ├── CardBody.tsx
│   │   │   │       ├── CardHeader.tsx
│   │   │   │       ├── Card.spec.tsx
│   │   │   │       ├── Card.stories.tsx
│   │   │   │       ├── CardThemeProvider.tsx
│   │   │   │       ├── Card.tsx
│   │   │   │       └── styles.css.ts
│   │   │   ├── tsconfig.json
│   │   │   ├── tsconfig.lib.json
│   │   │   └── tsconfig.spec.json
│   │   ├── core
│   │   │   ├── jest.config.ts
│   │   │   ├── project.json
│   │   │   ├── README.md
│   │   │   ├── src
│   │   │   │   ├── index.ts
│   │   │   │   └── lib
│   │   │   │       ├── ds-core.spec.ts
│   │   │   │       └── ds-core.ts
│   │   │   ├── tsconfig.json
│   │   │   ├── tsconfig.lib.json
│   │   │   └── tsconfig.spec.json
│   │   ├── icons
│   │   │   ├── jest.config.ts
│   │   │   ├── project.json
│   │   │   ├── README.md
│   │   │   ├── src
│   │   │   │   ├── index.ts
│   │   │   │   └── lib
│   │   │   │       ├── ds-icons.css.ts
│   │   │   │       ├── ds-icons.spec.tsx
│   │   │   │       ├── ds-icons.stories.tsx
│   │   │   │       └── ds-icons.tsx
│   │   │   ├── tsconfig.json
│   │   │   ├── tsconfig.lib.json
│   │   │   └── tsconfig.spec.json
│   │   ├── stack
│   │   │   ├── jest.config.ts
│   │   │   ├── project.json
│   │   │   ├── README.md
│   │   │   ├── src
│   │   │   │   ├── index.ts
│   │   │   │   └── lib
│   │   │   │       ├── ds-stack.module.css
│   │   │   │       ├── ds-stack.spec.tsx
│   │   │   │       ├── ds-stack.stories.tsx
│   │   │   │       └── ds-stack.tsx
│   │   │   ├── tsconfig.json
│   │   │   ├── tsconfig.lib.json
│   │   │   └── tsconfig.spec.json
│   │   └── theme
│   │       ├── jest.config.ts
│   │       ├── project.json
│   │       ├── README.md
│   │       ├── src
│   │       │   ├── index.ts
│   │       │   ├── lib
│   │       │   │   ├── constants.ts
│   │       │   │   ├── css
│   │       │   │   │   ├── generateTheme.ts
│   │       │   │   │   ├── globals.css.ts
│   │       │   │   │   ├── index.ts
│   │       │   │   │   ├── normalize.css.ts
│   │       │   │   │   ├── responsiveStyle.ts
│   │       │   │   │   ├── sprinkles.css.ts
│   │       │   │   │   ├── utilityClasses.css.ts
│   │       │   │   │   ├── utils.ts
│   │       │   │   │   └── vars.css.ts
│   │       │   │   ├── FontsProvider.tsx
│   │       │   │   ├── helpers.ts
│   │       │   │   ├── ThemeContext.tsx
│   │       │   │   ├── ThemeProvider.stories.tsx
│   │       │   │   ├── ThemeProvider.tsx
│   │       │   │   ├── ThemeScript.tsx
│   │       │   │   ├── Theme.tsx
│   │       │   │   ├── tokens
│   │       │   │   │   ├── animation.ts
│   │       │   │   │   ├── border.ts
│   │       │   │   │   ├── breakpoints.ts
│   │       │   │   │   ├── colors
│   │       │   │   │   │   ├── base.ts
│   │       │   │   │   │   ├── core.ts
│   │       │   │   │   │   ├── index.ts
│   │       │   │   │   │   └── modes.ts
│   │       │   │   │   ├── index.ts
│   │       │   │   │   ├── opacity.ts
│   │       │   │   │   ├── palettes
│   │       │   │   │   │   ├── basic.ts
│   │       │   │   │   │   ├── composePalette.ts
│   │       │   │   │   │   ├── composeScheme.ts
│   │       │   │   │   │   ├── index.ts
│   │       │   │   │   │   └── slate.ts
│   │       │   │   │   ├── shadows.ts
│   │       │   │   │   ├── space.ts
│   │       │   │   │   └── typography.ts
│   │       │   │   ├── types.ts
│   │       │   │   ├── useFont.ts
│   │       │   │   └── useTheme.tsx
│   │       │   └── tokens.ts
│   │       ├── tsconfig.json
│   │       ├── tsconfig.lib.json
│   │       └── tsconfig.spec.json
│   └── tools
│       └── faker
│           ├── jest.config.ts
│           ├── project.json
│           ├── README.md
│           ├── src
│           │   ├── index.ts
│           │   └── lib
│           │       └── Lorem.tsx
│           ├── tsconfig.json
│           ├── tsconfig.lib.json
│           └── tsconfig.spec.json
├── README.md
├── runbooks
│   ├── README.md
│   ├── setup.md
│   └── setup.meta.md
├── tools
│   ├── generators
│   └── tsconfig.tools.json
├── tree.txt
├── tsconfig.base.json
└── yarn.lock

195 directories, 180 files
airtonix commented 1 year ago

ok it's not cwd as mentioned here: https://github.com/tatethurston/nextjs-routes/blob/main/src/config.ts#L25-L31

but rather dir as mentioned here: https://github.com/tatethurston/nextjs-routes/blob/v2.0.0/src/core.ts#L296-L324

also the generated file gets created in process.cwd when it should be in the location described by image

  withRoutes({
    cwd: 'apps/website',
  }),

The types or the documentation for the configuration need updating

Screencast from 2023-04-25 13-02-14.webm

and so now when i specifiy the above, it generates the types, but in the wrong location:

Screencast from 2023-04-25 13-07-52.webm

So two things need fixing:

airtonix commented 1 year ago

@tatethurston So now that I'm using the cwd|dir option.

is it right that my generated types looks like:

specifically:

...
  export type Route =
    never;
...
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
// This file will be automatically regenerated when your Next.js server is running.
// nextjs-routes version: 2.0.0
/* eslint-disable */

// prettier-ignore
declare module "nextjs-routes" {
  import type {
    GetServerSidePropsContext as NextGetServerSidePropsContext,
    GetServerSidePropsResult as NextGetServerSidePropsResult
  } from "nextjs";

  export type Route =
    never;

  interface StaticRoute<Pathname> {
    pathname: Pathname;
    query?: Query | undefined;
    hash?: string | null | undefined;
  }

  interface DynamicRoute<Pathname, Parameters> {
    pathname: Pathname;
    query: Parameters & Query;
    hash?: string | null | undefined;
  }

  interface Query {
    [key: string]: string | string[] | undefined;
  };

  export type RoutedQuery<P extends Route["pathname"]> = Extract<
    Route,
    { pathname: P }
  >["query"];

  export type Locale = undefined;

  /**
   * A typesafe utility function for generating paths in your application.
   *
   * route({ pathname: "/foos/[foo]", query: { foo: "bar" }}) will produce "/foos/bar".
   */
  export declare function route(r: Route): string;

  /**
   * Nearly identical to GetServerSidePropsContext from next, but further narrows
   * types based on nextjs-route's route data.
   */
  export type GetServerSidePropsContext<
    Pathname extends Route["pathname"] = Route["pathname"],
    Preview extends NextGetServerSidePropsContext["previewData"] = NextGetServerSidePropsContext["previewData"]
  > = Omit<NextGetServerSidePropsContext, 'params' | 'query' | 'defaultLocale' | 'locale' | 'locales'> & {
    params: Extract<Route, { pathname: Pathname }>["query"];
    query: Query;
    defaultLocale?: undefined;
    locale?: Locale;
    locales?: undefined;
  };

  /**
   * Nearly identical to GetServerSideProps from next, but further narrows
   * types based on nextjs-route's route data.
   */
  export type GetServerSideProps<
    Props extends { [key: string]: any } = { [key: string]: any },
    Pathname extends Route["pathname"] = Route["pathname"],
    Preview extends NextGetServerSideProps["previewData"] = NextGetServerSideProps["previewData"]
  > = (
    context: GetServerSidePropsContext<Pathname, Preview>
  ) => Promise<NextGetServerSidePropsResult<Props>>
}

// prettier-ignore
declare module "next/link" {
  import type { Route } from "nextjs-routes";
  import type { LinkProps as NextLinkProps } from "next/dist/client/link";
  import type {
    AnchorHTMLAttributes,
    DetailedReactHTMLElement,
    MouseEventHandler,
    PropsWithChildren,
  } from "react";
  export * from "next/dist/client/link";

  type StaticRoute = Exclude<Route, { query: any }>["pathname"];

  export interface LinkProps
    extends Omit<NextLinkProps, "href" | "locale">,
      AnchorHTMLAttributes<HTMLAnchorElement> {
    href: Route | StaticRoute | Omit<Route, "pathname">
    locale?: false;
  }

  type LinkReactElement = DetailedReactHTMLElement<
    {
      onMouseEnter?: MouseEventHandler<Element> | undefined;
      onClick: MouseEventHandler;
      href?: string | undefined;
      ref?: any;
    },
    HTMLElement
  >;

  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;

  export default Link;
}

// prettier-ignore
declare module "next/router" {
  import type { Locale, Route, RoutedQuery } from "nextjs-routes";
  import type { NextRouter as Router } from "next/dist/client/router";
  export * from "next/dist/client/router";
  export { default } from "next/dist/client/router";

  type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
  type StaticRoute = Exclude<Route, { query: any }>["pathname"];

  interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
    locale?: false;
  }

  type PathnameAndQuery<Pathname> = Required<
    Pick<Extract<Route, { pathname: Pathname }>, "pathname" | "query">
  >;

  type AutomaticStaticOptimizedQuery<PaQ> = Omit<PaQ, "query"> & {
    query: Partial<PaQ["query"]>;
  };

  type BaseRouter<PaQ> =
    | ({ isReady: false } & AutomaticStaticOptimizedQuery<PaQ>)
    | ({ isReady: true } & PaQ);

  export type NextRouter<P extends Route["pathname"] = Route["pathname"]> =
    BaseRouter<PathnameAndQuery<P>> &
      Omit<
        Router,
        | "defaultLocale"
        | "domainLocales"
        | "isReady"
        | "locale"
        | "locales"
        | "pathname"
        | "push"
        | "query"
        | "replace"
        | "route"
      > & {
        defaultLocale?: undefined;
        domainLocales?: undefined;
        locale?: Locale;
        locales?: undefined;
        push(
          url: Route | StaticRoute | Omit<Route, "pathname">,
          as?: string,
          options?: TransitionOptions
        ): Promise<boolean>;
        replace(
          url: Route | StaticRoute | Omit<Route, "pathname">,
          as?: string,
          options?: TransitionOptions
        ): Promise<boolean>;
        route: P;
      };

  export function useRouter<P extends Route["pathname"]>(): NextRouter<P>;
}
tatethurston commented 1 year ago

@tatethurston So now that I'm using the cwd|dir option.

is it right that my generated types looks like:

specifically:

...
  export type Route =
    never;
...
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
// This file will be automatically regenerated when your Next.js server is running.
// nextjs-routes version: 2.0.0
/* eslint-disable */

// prettier-ignore
declare module "nextjs-routes" {
  import type {
    GetServerSidePropsContext as NextGetServerSidePropsContext,
    GetServerSidePropsResult as NextGetServerSidePropsResult
  } from "nextjs";

  export type Route =
    never;

  interface StaticRoute<Pathname> {
    pathname: Pathname;
    query?: Query | undefined;
    hash?: string | null | undefined;
  }

  interface DynamicRoute<Pathname, Parameters> {
    pathname: Pathname;
    query: Parameters & Query;
    hash?: string | null | undefined;
  }

  interface Query {
    [key: string]: string | string[] | undefined;
  };

  export type RoutedQuery<P extends Route["pathname"]> = Extract<
    Route,
    { pathname: P }
  >["query"];

  export type Locale = undefined;

  /**
   * A typesafe utility function for generating paths in your application.
   *
   * route({ pathname: "/foos/[foo]", query: { foo: "bar" }}) will produce "/foos/bar".
   */
  export declare function route(r: Route): string;

  /**
   * Nearly identical to GetServerSidePropsContext from next, but further narrows
   * types based on nextjs-route's route data.
   */
  export type GetServerSidePropsContext<
    Pathname extends Route["pathname"] = Route["pathname"],
    Preview extends NextGetServerSidePropsContext["previewData"] = NextGetServerSidePropsContext["previewData"]
  > = Omit<NextGetServerSidePropsContext, 'params' | 'query' | 'defaultLocale' | 'locale' | 'locales'> & {
    params: Extract<Route, { pathname: Pathname }>["query"];
    query: Query;
    defaultLocale?: undefined;
    locale?: Locale;
    locales?: undefined;
  };

  /**
   * Nearly identical to GetServerSideProps from next, but further narrows
   * types based on nextjs-route's route data.
   */
  export type GetServerSideProps<
    Props extends { [key: string]: any } = { [key: string]: any },
    Pathname extends Route["pathname"] = Route["pathname"],
    Preview extends NextGetServerSideProps["previewData"] = NextGetServerSideProps["previewData"]
  > = (
    context: GetServerSidePropsContext<Pathname, Preview>
  ) => Promise<NextGetServerSidePropsResult<Props>>
}

// prettier-ignore
declare module "next/link" {
  import type { Route } from "nextjs-routes";
  import type { LinkProps as NextLinkProps } from "next/dist/client/link";
  import type {
    AnchorHTMLAttributes,
    DetailedReactHTMLElement,
    MouseEventHandler,
    PropsWithChildren,
  } from "react";
  export * from "next/dist/client/link";

  type StaticRoute = Exclude<Route, { query: any }>["pathname"];

  export interface LinkProps
    extends Omit<NextLinkProps, "href" | "locale">,
      AnchorHTMLAttributes<HTMLAnchorElement> {
    href: Route | StaticRoute | Omit<Route, "pathname">
    locale?: false;
  }

  type LinkReactElement = DetailedReactHTMLElement<
    {
      onMouseEnter?: MouseEventHandler<Element> | undefined;
      onClick: MouseEventHandler;
      href?: string | undefined;
      ref?: any;
    },
    HTMLElement
  >;

  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;

  export default Link;
}

// prettier-ignore
declare module "next/router" {
  import type { Locale, Route, RoutedQuery } from "nextjs-routes";
  import type { NextRouter as Router } from "next/dist/client/router";
  export * from "next/dist/client/router";
  export { default } from "next/dist/client/router";

  type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
  type StaticRoute = Exclude<Route, { query: any }>["pathname"];

  interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
    locale?: false;
  }

  type PathnameAndQuery<Pathname> = Required<
    Pick<Extract<Route, { pathname: Pathname }>, "pathname" | "query">
  >;

  type AutomaticStaticOptimizedQuery<PaQ> = Omit<PaQ, "query"> & {
    query: Partial<PaQ["query"]>;
  };

  type BaseRouter<PaQ> =
    | ({ isReady: false } & AutomaticStaticOptimizedQuery<PaQ>)
    | ({ isReady: true } & PaQ);

  export type NextRouter<P extends Route["pathname"] = Route["pathname"]> =
    BaseRouter<PathnameAndQuery<P>> &
      Omit<
        Router,
        | "defaultLocale"
        | "domainLocales"
        | "isReady"
        | "locale"
        | "locales"
        | "pathname"
        | "push"
        | "query"
        | "replace"
        | "route"
      > & {
        defaultLocale?: undefined;
        domainLocales?: undefined;
        locale?: Locale;
        locales?: undefined;
        push(
          url: Route | StaticRoute | Omit<Route, "pathname">,
          as?: string,
          options?: TransitionOptions
        ): Promise<boolean>;
        replace(
          url: Route | StaticRoute | Omit<Route, "pathname">,
          as?: string,
          options?: TransitionOptions
        ): Promise<boolean>;
        route: P;
      };

  export function useRouter<P extends Route["pathname"]>(): NextRouter<P>;
}

@airtonix No, that indicates to me that your page files are not being located. What are you running to generate your routes file?

tatethurston commented 1 year ago

@airtonix this plugin doesn't support the app directory: https://github.com/tatethurston/nextjs-routes/issues/142. It looks like you don't have a pages directory?

airtonix commented 1 year ago

@tatethurston yeah, no pages dir, I've also just moved over to the new experimental support in nextjs