Repository: tatethurston/nextjs-routes
Pull request #112 (2023-01-04 09:36:05)

include version in generated file


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5e9c2bb..a7cef25 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## 1.0.5
+
+- The version of `nextjs-routes` is now included in the generated `nextjs-routes.d.ts` file.
+
 ## 1.0.4
 
 - `LinkProps` now accept path strings for static routes:
diff --git a/examples/typescript/types/nextjs-routes.d.ts b/examples/typescript/types/nextjs-routes.d.ts
index 89d976d..a547023 100644
--- a/examples/typescript/types/nextjs-routes.d.ts
+++ b/examples/typescript/types/nextjs-routes.d.ts
@@ -1,5 +1,6 @@
 // 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore
diff --git a/package-lock.json b/package-lock.json
index 8c748e5..1553cb4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,10 +1,12 @@
 {
   "name": "nextjs-routes-development",
+  "version": "1.0.4",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "nextjs-routes-development",
+      "version": "1.0.4",
       "license": "MIT",
       "devDependencies": {
         "@babel/preset-env": "^7.18.6",
diff --git a/package.json b/package.json
index 99be500..34c510d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,7 @@
 {
   "private": true,
   "name": "nextjs-routes-development",
+  "version": "1.0.4",
   "license": "MIT",
   "author": "Tate <tatethurston@gmail.com>",
   "repository": {
diff --git a/src/core.ts b/src/core.ts
index 22296f3..db98b5b 100644
--- a/src/core.ts
+++ b/src/core.ts
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, writeFileSync } from "fs";
 import { I18NConfig } from "next/dist/server/config-shared.js";
 import { join, parse, sep } from "path";
 import { findFiles, getAppDirectory, getPagesDirectory } from "./utils.js";
+import * as pkg from "../package.json";
 
 type QueryType = "dynamic" | "catch-all" | "optional-catch-all";
 
@@ -81,6 +82,7 @@ function generate(routes: Route[], config: NextJSRoutesOptions): string {
   return `\
 // 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: ${pkg.version}
 /* eslint-disable */
 
 // prettier-ignore
diff --git a/tsconfig.json b/tsconfig.json
index 25f1c65..0d79ced 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -8,12 +8,12 @@
     "noEmitOnError": false,
     "outDir": "dist",
     "resolveJsonModule": true,
-    "rootDir": "src",
+    "rootDir": ".",
     "skipLibCheck": true,
     "sourceMap": false,
     "strict": true,
     "declaration": true,
     "target": "ES2020"
   },
-  "include": ["src/**/*"]
+  "include": ["package.json", "src/**/*"]
 }


Test patch:
diff --git a/e2e/nextjs-routes.d.ts b/e2e/nextjs-routes.d.ts
index e1e634b..827dc8a 100644
--- a/e2e/nextjs-routes.d.ts
+++ b/e2e/nextjs-routes.d.ts
@@ -1,5 +1,6 @@
 // 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore
diff --git a/src/__snapshots__/core.test.ts.snap b/src/__snapshots__/core.test.ts.snap
index 572d299..b2ae4f4 100644
--- a/src/__snapshots__/core.test.ts.snap
+++ b/src/__snapshots__/core.test.ts.snap
@@ -6,6 +6,7 @@ exports[`route generation app directory (experimental) 1`] = `
     "nextjs-routes.d.ts",
     "// 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore
@@ -139,6 +140,7 @@ exports[`route generation configuration i18n 1`] = `
     "nextjs-routes.d.ts",
     "// 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore
@@ -290,6 +292,7 @@ exports[`route generation configuration outDir 1`] = `
     "src/nextjs-routes.d.ts",
     "// 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore
@@ -421,6 +424,7 @@ exports[`route generation configuration pageExtensions configured 1`] = `
     "nextjs-routes.d.ts",
     "// 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore
@@ -554,6 +558,7 @@ exports[`route generation configuration pageExtensions default 1`] = `
     "nextjs-routes.d.ts",
     "// 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore
@@ -685,6 +690,7 @@ exports[`route generation dedupes 1`] = `
     "nextjs-routes.d.ts",
     "// 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore
@@ -816,6 +822,7 @@ exports[`route generation no routes 1`] = `
     "nextjs-routes.d.ts",
     "// 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore
@@ -947,6 +954,7 @@ exports[`route generation transforms windows paths 1`] = `
     "nextjs-routes.d.ts",
     "// 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore
@@ -1078,6 +1086,7 @@ exports[`route generation typescript 1`] = `
     "nextjs-routes.d.ts",
     "// 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: 1.0.4
 /* eslint-disable */
 
 // prettier-ignore