@tanstack/router-cli 1.85.3 → 1.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/generate.cjs +2 -2
- package/dist/cjs/generate.cjs.map +1 -1
- package/dist/cjs/generate.d.cts +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/watch.cjs +4 -6
- package/dist/cjs/watch.cjs.map +1 -1
- package/dist/cjs/watch.d.cts +1 -1
- package/dist/esm/generate.d.ts +1 -1
- package/dist/esm/generate.js +2 -2
- package/dist/esm/generate.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/watch.d.ts +1 -1
- package/dist/esm/watch.js +4 -6
- package/dist/esm/watch.js.map +1 -1
- package/package.json +2 -2
- package/src/generate.ts +2 -2
- package/src/index.ts +2 -2
- package/src/watch.ts +4 -6
package/dist/cjs/generate.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const routerGenerator = require("@tanstack/router-generator");
|
|
4
|
-
async function generate(config) {
|
|
4
|
+
async function generate(config, root) {
|
|
5
5
|
try {
|
|
6
|
-
await routerGenerator.generator(config);
|
|
6
|
+
await routerGenerator.generator(config, root);
|
|
7
7
|
process.exit(0);
|
|
8
8
|
} catch (err) {
|
|
9
9
|
console.error(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.cjs","sources":["../../src/generate.ts"],"sourcesContent":["import { generator } from '@tanstack/router-generator'\nimport type { Config } from '@tanstack/router-generator'\n\nexport async function generate(config: Config) {\n try {\n await generator(config)\n process.exit(0)\n } catch (err) {\n console.error(err)\n process.exit(1)\n }\n}\n"],"names":["generator"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"generate.cjs","sources":["../../src/generate.ts"],"sourcesContent":["import { generator } from '@tanstack/router-generator'\nimport type { Config } from '@tanstack/router-generator'\n\nexport async function generate(config: Config, root: string) {\n try {\n await generator(config, root)\n process.exit(0)\n } catch (err) {\n console.error(err)\n process.exit(1)\n }\n}\n"],"names":["generator"],"mappings":";;;AAGsB,eAAA,SAAS,QAAgB,MAAc;AACvD,MAAA;AACI,UAAAA,gBAAA,UAAU,QAAQ,IAAI;AAC5B,YAAQ,KAAK,CAAC;AAAA,WACP,KAAK;AACZ,YAAQ,MAAM,GAAG;AACjB,YAAQ,KAAK,CAAC;AAAA,EAAA;AAElB;;"}
|
package/dist/cjs/generate.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Config } from '@tanstack/router-generator';
|
|
2
|
-
export declare function generate(config: Config): Promise<void>;
|
|
2
|
+
export declare function generate(config: Config, root: string): Promise<void>;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -25,12 +25,12 @@ main();
|
|
|
25
25
|
function main() {
|
|
26
26
|
yargs__namespace.scriptName("tsr").usage("$0 <cmd> [args]").command("generate", "Generate the routes for a project", async () => {
|
|
27
27
|
const config = routerGenerator.getConfig();
|
|
28
|
-
await generate.generate(config);
|
|
28
|
+
await generate.generate(config, process.cwd());
|
|
29
29
|
}).command(
|
|
30
30
|
"watch",
|
|
31
31
|
"Continuously watch and generate the routes for a project",
|
|
32
32
|
() => {
|
|
33
|
-
watch.watch();
|
|
33
|
+
watch.watch(process.cwd());
|
|
34
34
|
}
|
|
35
35
|
).help().argv;
|
|
36
36
|
}
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import * as yargs from 'yargs'\nimport { getConfig } from '@tanstack/router-generator'\nimport { generate } from './generate'\nimport { watch } from './watch'\n\nmain()\n\nexport function main() {\n yargs\n // @ts-expect-error\n .scriptName('tsr')\n .usage('$0 <cmd> [args]')\n .command('generate', 'Generate the routes for a project', async () => {\n const config = getConfig()\n await generate(config)\n })\n .command(\n 'watch',\n 'Continuously watch and generate the routes for a project',\n () => {\n watch()\n },\n )\n .help().argv\n}\n"],"names":["yargs","getConfig","generate","watch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKA,KAAK;AAEE,SAAS,OAAO;AAGlBA,mBAAA,WAAW,KAAK,EAChB,MAAM,iBAAiB,EACvB,QAAQ,YAAY,qCAAqC,YAAY;AACpE,UAAM,SAASC,gBAAAA,UAAU;AACzB,UAAMC,
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import * as yargs from 'yargs'\nimport { getConfig } from '@tanstack/router-generator'\nimport { generate } from './generate'\nimport { watch } from './watch'\n\nmain()\n\nexport function main() {\n yargs\n // @ts-expect-error\n .scriptName('tsr')\n .usage('$0 <cmd> [args]')\n .command('generate', 'Generate the routes for a project', async () => {\n const config = getConfig()\n await generate(config, process.cwd())\n })\n .command(\n 'watch',\n 'Continuously watch and generate the routes for a project',\n () => {\n watch(process.cwd())\n },\n )\n .help().argv\n}\n"],"names":["yargs","getConfig","generate","watch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKA,KAAK;AAEE,SAAS,OAAO;AAGlBA,mBAAA,WAAW,KAAK,EAChB,MAAM,iBAAiB,EACvB,QAAQ,YAAY,qCAAqC,YAAY;AACpE,UAAM,SAASC,gBAAAA,UAAU;AACzB,UAAMC,kBAAS,QAAQ,QAAQ,IAAA,CAAK;AAAA,EACrC,CAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,IACA,MAAM;AACEC,kBAAA,QAAQ,KAAK;AAAA,IAAA;AAAA,EACrB,EAED,KAAO,EAAA;AACZ;;"}
|
package/dist/cjs/watch.cjs
CHANGED
|
@@ -3,10 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const path = require("node:path");
|
|
4
4
|
const chokidar = require("chokidar");
|
|
5
5
|
const routerGenerator = require("@tanstack/router-generator");
|
|
6
|
-
function watch() {
|
|
7
|
-
const configWatcher = chokidar.watch(
|
|
8
|
-
path.resolve(process.cwd(), "tsr.config.json")
|
|
9
|
-
);
|
|
6
|
+
function watch(root) {
|
|
7
|
+
const configWatcher = chokidar.watch(path.resolve(root, "tsr.config.json"));
|
|
10
8
|
let watcher = new chokidar.FSWatcher({});
|
|
11
9
|
const generatorWatcher = () => {
|
|
12
10
|
const config = routerGenerator.getConfig();
|
|
@@ -16,7 +14,7 @@ function watch() {
|
|
|
16
14
|
watcher.on("ready", async () => {
|
|
17
15
|
const handle = async () => {
|
|
18
16
|
try {
|
|
19
|
-
await routerGenerator.generator(config);
|
|
17
|
+
await routerGenerator.generator(config, root);
|
|
20
18
|
} catch (err) {
|
|
21
19
|
console.error(err);
|
|
22
20
|
console.info();
|
|
@@ -24,7 +22,7 @@ function watch() {
|
|
|
24
22
|
};
|
|
25
23
|
await handle();
|
|
26
24
|
let timeout;
|
|
27
|
-
const deduped = (
|
|
25
|
+
const deduped = (_file) => {
|
|
28
26
|
if (timeout) {
|
|
29
27
|
clearTimeout(timeout);
|
|
30
28
|
}
|
package/dist/cjs/watch.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.cjs","sources":["../../src/watch.ts"],"sourcesContent":["import path from 'node:path'\nimport chokidar from 'chokidar'\nimport { generator, getConfig } from '@tanstack/router-generator'\n\nexport function watch() {\n const configWatcher = chokidar.watch(
|
|
1
|
+
{"version":3,"file":"watch.cjs","sources":["../../src/watch.ts"],"sourcesContent":["import path from 'node:path'\nimport chokidar from 'chokidar'\nimport { generator, getConfig } from '@tanstack/router-generator'\n\nexport function watch(root: string) {\n const configWatcher = chokidar.watch(path.resolve(root, 'tsr.config.json'))\n\n let watcher = new chokidar.FSWatcher({})\n\n const generatorWatcher = () => {\n const config = getConfig()\n\n watcher.close()\n\n console.info(`TSR: Watching routes (${config.routesDirectory})...`)\n watcher = chokidar.watch(config.routesDirectory)\n\n watcher.on('ready', async () => {\n const handle = async () => {\n try {\n await generator(config, root)\n } catch (err) {\n console.error(err)\n console.info()\n }\n }\n\n await handle()\n\n let timeout: ReturnType<typeof setTimeout> | undefined\n\n const deduped = (_file: string) => {\n if (timeout) {\n clearTimeout(timeout)\n }\n\n timeout = setTimeout(handle, 10)\n }\n\n watcher.on('change', deduped)\n watcher.on('add', deduped)\n watcher.on('unlink', deduped)\n })\n }\n\n configWatcher.on('ready', generatorWatcher)\n configWatcher.on('change', generatorWatcher)\n}\n"],"names":["getConfig","generator"],"mappings":";;;;;AAIO,SAAS,MAAM,MAAc;AAClC,QAAM,gBAAgB,SAAS,MAAM,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE1E,MAAI,UAAU,IAAI,SAAS,UAAU,CAAA,CAAE;AAEvC,QAAM,mBAAmB,MAAM;AAC7B,UAAM,SAASA,gBAAAA,UAAU;AAEzB,YAAQ,MAAM;AAEd,YAAQ,KAAK,yBAAyB,OAAO,eAAe,MAAM;AACxD,cAAA,SAAS,MAAM,OAAO,eAAe;AAEvC,YAAA,GAAG,SAAS,YAAY;AAC9B,YAAM,SAAS,YAAY;AACrB,YAAA;AACI,gBAAAC,gBAAA,UAAU,QAAQ,IAAI;AAAA,iBACrB,KAAK;AACZ,kBAAQ,MAAM,GAAG;AACjB,kBAAQ,KAAK;AAAA,QAAA;AAAA,MAEjB;AAEA,YAAM,OAAO;AAET,UAAA;AAEE,YAAA,UAAU,CAAC,UAAkB;AACjC,YAAI,SAAS;AACX,uBAAa,OAAO;AAAA,QAAA;AAGZ,kBAAA,WAAW,QAAQ,EAAE;AAAA,MACjC;AAEQ,cAAA,GAAG,UAAU,OAAO;AACpB,cAAA,GAAG,OAAO,OAAO;AACjB,cAAA,GAAG,UAAU,OAAO;AAAA,IAAA,CAC7B;AAAA,EACH;AAEc,gBAAA,GAAG,SAAS,gBAAgB;AAC5B,gBAAA,GAAG,UAAU,gBAAgB;AAC7C;;"}
|
package/dist/cjs/watch.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function watch(): void;
|
|
1
|
+
export declare function watch(root: string): void;
|
package/dist/esm/generate.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Config } from '@tanstack/router-generator';
|
|
2
|
-
export declare function generate(config: Config): Promise<void>;
|
|
2
|
+
export declare function generate(config: Config, root: string): Promise<void>;
|
package/dist/esm/generate.js
CHANGED
package/dist/esm/generate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sources":["../../src/generate.ts"],"sourcesContent":["import { generator } from '@tanstack/router-generator'\nimport type { Config } from '@tanstack/router-generator'\n\nexport async function generate(config: Config) {\n try {\n await generator(config)\n process.exit(0)\n } catch (err) {\n console.error(err)\n process.exit(1)\n }\n}\n"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"generate.js","sources":["../../src/generate.ts"],"sourcesContent":["import { generator } from '@tanstack/router-generator'\nimport type { Config } from '@tanstack/router-generator'\n\nexport async function generate(config: Config, root: string) {\n try {\n await generator(config, root)\n process.exit(0)\n } catch (err) {\n console.error(err)\n process.exit(1)\n }\n}\n"],"names":[],"mappings":";AAGsB,eAAA,SAAS,QAAgB,MAAc;AACvD,MAAA;AACI,UAAA,UAAU,QAAQ,IAAI;AAC5B,YAAQ,KAAK,CAAC;AAAA,WACP,KAAK;AACZ,YAAQ,MAAM,GAAG;AACjB,YAAQ,KAAK,CAAC;AAAA,EAAA;AAElB;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -6,12 +6,12 @@ main();
|
|
|
6
6
|
function main() {
|
|
7
7
|
yargs.scriptName("tsr").usage("$0 <cmd> [args]").command("generate", "Generate the routes for a project", async () => {
|
|
8
8
|
const config = getConfig();
|
|
9
|
-
await generate(config);
|
|
9
|
+
await generate(config, process.cwd());
|
|
10
10
|
}).command(
|
|
11
11
|
"watch",
|
|
12
12
|
"Continuously watch and generate the routes for a project",
|
|
13
13
|
() => {
|
|
14
|
-
watch();
|
|
14
|
+
watch(process.cwd());
|
|
15
15
|
}
|
|
16
16
|
).help().argv;
|
|
17
17
|
}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import * as yargs from 'yargs'\nimport { getConfig } from '@tanstack/router-generator'\nimport { generate } from './generate'\nimport { watch } from './watch'\n\nmain()\n\nexport function main() {\n yargs\n // @ts-expect-error\n .scriptName('tsr')\n .usage('$0 <cmd> [args]')\n .command('generate', 'Generate the routes for a project', async () => {\n const config = getConfig()\n await generate(config)\n })\n .command(\n 'watch',\n 'Continuously watch and generate the routes for a project',\n () => {\n watch()\n },\n )\n .help().argv\n}\n"],"names":[],"mappings":";;;;AAKA,KAAK;AAEE,SAAS,OAAO;AAGlB,QAAA,WAAW,KAAK,EAChB,MAAM,iBAAiB,EACvB,QAAQ,YAAY,qCAAqC,YAAY;AACpE,UAAM,SAAS,UAAU;AACzB,UAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import * as yargs from 'yargs'\nimport { getConfig } from '@tanstack/router-generator'\nimport { generate } from './generate'\nimport { watch } from './watch'\n\nmain()\n\nexport function main() {\n yargs\n // @ts-expect-error\n .scriptName('tsr')\n .usage('$0 <cmd> [args]')\n .command('generate', 'Generate the routes for a project', async () => {\n const config = getConfig()\n await generate(config, process.cwd())\n })\n .command(\n 'watch',\n 'Continuously watch and generate the routes for a project',\n () => {\n watch(process.cwd())\n },\n )\n .help().argv\n}\n"],"names":[],"mappings":";;;;AAKA,KAAK;AAEE,SAAS,OAAO;AAGlB,QAAA,WAAW,KAAK,EAChB,MAAM,iBAAiB,EACvB,QAAQ,YAAY,qCAAqC,YAAY;AACpE,UAAM,SAAS,UAAU;AACzB,UAAM,SAAS,QAAQ,QAAQ,IAAA,CAAK;AAAA,EACrC,CAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,IACA,MAAM;AACE,YAAA,QAAQ,KAAK;AAAA,IAAA;AAAA,EACrB,EAED,KAAO,EAAA;AACZ;"}
|
package/dist/esm/watch.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function watch(): void;
|
|
1
|
+
export declare function watch(root: string): void;
|
package/dist/esm/watch.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import chokidar from "chokidar";
|
|
3
3
|
import { getConfig, generator } from "@tanstack/router-generator";
|
|
4
|
-
function watch() {
|
|
5
|
-
const configWatcher = chokidar.watch(
|
|
6
|
-
path.resolve(process.cwd(), "tsr.config.json")
|
|
7
|
-
);
|
|
4
|
+
function watch(root) {
|
|
5
|
+
const configWatcher = chokidar.watch(path.resolve(root, "tsr.config.json"));
|
|
8
6
|
let watcher = new chokidar.FSWatcher({});
|
|
9
7
|
const generatorWatcher = () => {
|
|
10
8
|
const config = getConfig();
|
|
@@ -14,7 +12,7 @@ function watch() {
|
|
|
14
12
|
watcher.on("ready", async () => {
|
|
15
13
|
const handle = async () => {
|
|
16
14
|
try {
|
|
17
|
-
await generator(config);
|
|
15
|
+
await generator(config, root);
|
|
18
16
|
} catch (err) {
|
|
19
17
|
console.error(err);
|
|
20
18
|
console.info();
|
|
@@ -22,7 +20,7 @@ function watch() {
|
|
|
22
20
|
};
|
|
23
21
|
await handle();
|
|
24
22
|
let timeout;
|
|
25
|
-
const deduped = (
|
|
23
|
+
const deduped = (_file) => {
|
|
26
24
|
if (timeout) {
|
|
27
25
|
clearTimeout(timeout);
|
|
28
26
|
}
|
package/dist/esm/watch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sources":["../../src/watch.ts"],"sourcesContent":["import path from 'node:path'\nimport chokidar from 'chokidar'\nimport { generator, getConfig } from '@tanstack/router-generator'\n\nexport function watch() {\n const configWatcher = chokidar.watch(
|
|
1
|
+
{"version":3,"file":"watch.js","sources":["../../src/watch.ts"],"sourcesContent":["import path from 'node:path'\nimport chokidar from 'chokidar'\nimport { generator, getConfig } from '@tanstack/router-generator'\n\nexport function watch(root: string) {\n const configWatcher = chokidar.watch(path.resolve(root, 'tsr.config.json'))\n\n let watcher = new chokidar.FSWatcher({})\n\n const generatorWatcher = () => {\n const config = getConfig()\n\n watcher.close()\n\n console.info(`TSR: Watching routes (${config.routesDirectory})...`)\n watcher = chokidar.watch(config.routesDirectory)\n\n watcher.on('ready', async () => {\n const handle = async () => {\n try {\n await generator(config, root)\n } catch (err) {\n console.error(err)\n console.info()\n }\n }\n\n await handle()\n\n let timeout: ReturnType<typeof setTimeout> | undefined\n\n const deduped = (_file: string) => {\n if (timeout) {\n clearTimeout(timeout)\n }\n\n timeout = setTimeout(handle, 10)\n }\n\n watcher.on('change', deduped)\n watcher.on('add', deduped)\n watcher.on('unlink', deduped)\n })\n }\n\n configWatcher.on('ready', generatorWatcher)\n configWatcher.on('change', generatorWatcher)\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,MAAM,MAAc;AAClC,QAAM,gBAAgB,SAAS,MAAM,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE1E,MAAI,UAAU,IAAI,SAAS,UAAU,CAAA,CAAE;AAEvC,QAAM,mBAAmB,MAAM;AAC7B,UAAM,SAAS,UAAU;AAEzB,YAAQ,MAAM;AAEd,YAAQ,KAAK,yBAAyB,OAAO,eAAe,MAAM;AACxD,cAAA,SAAS,MAAM,OAAO,eAAe;AAEvC,YAAA,GAAG,SAAS,YAAY;AAC9B,YAAM,SAAS,YAAY;AACrB,YAAA;AACI,gBAAA,UAAU,QAAQ,IAAI;AAAA,iBACrB,KAAK;AACZ,kBAAQ,MAAM,GAAG;AACjB,kBAAQ,KAAK;AAAA,QAAA;AAAA,MAEjB;AAEA,YAAM,OAAO;AAET,UAAA;AAEE,YAAA,UAAU,CAAC,UAAkB;AACjC,YAAI,SAAS;AACX,uBAAa,OAAO;AAAA,QAAA;AAGZ,kBAAA,WAAW,QAAQ,EAAE;AAAA,MACjC;AAEQ,cAAA,GAAG,UAAU,OAAO;AACpB,cAAA,GAAG,OAAO,OAAO;AACjB,cAAA,GAAG,UAAU,OAAO;AAAA,IAAA,CAC7B;AAAA,EACH;AAEc,gBAAA,GAAG,SAAS,gBAAgB;AAC5B,gBAAA,GAAG,UAAU,gBAAgB;AAC7C;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/router-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.86.0",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"chokidar": "^3.6.0",
|
|
56
56
|
"yargs": "^17.7.2",
|
|
57
|
-
"@tanstack/router-generator": "1.
|
|
57
|
+
"@tanstack/router-generator": "^1.86.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/yargs": "^17.0.33"
|
package/src/generate.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { generator } from '@tanstack/router-generator'
|
|
2
2
|
import type { Config } from '@tanstack/router-generator'
|
|
3
3
|
|
|
4
|
-
export async function generate(config: Config) {
|
|
4
|
+
export async function generate(config: Config, root: string) {
|
|
5
5
|
try {
|
|
6
|
-
await generator(config)
|
|
6
|
+
await generator(config, root)
|
|
7
7
|
process.exit(0)
|
|
8
8
|
} catch (err) {
|
|
9
9
|
console.error(err)
|
package/src/index.ts
CHANGED
|
@@ -12,13 +12,13 @@ export function main() {
|
|
|
12
12
|
.usage('$0 <cmd> [args]')
|
|
13
13
|
.command('generate', 'Generate the routes for a project', async () => {
|
|
14
14
|
const config = getConfig()
|
|
15
|
-
await generate(config)
|
|
15
|
+
await generate(config, process.cwd())
|
|
16
16
|
})
|
|
17
17
|
.command(
|
|
18
18
|
'watch',
|
|
19
19
|
'Continuously watch and generate the routes for a project',
|
|
20
20
|
() => {
|
|
21
|
-
watch()
|
|
21
|
+
watch(process.cwd())
|
|
22
22
|
},
|
|
23
23
|
)
|
|
24
24
|
.help().argv
|
package/src/watch.ts
CHANGED
|
@@ -2,10 +2,8 @@ import path from 'node:path'
|
|
|
2
2
|
import chokidar from 'chokidar'
|
|
3
3
|
import { generator, getConfig } from '@tanstack/router-generator'
|
|
4
4
|
|
|
5
|
-
export function watch() {
|
|
6
|
-
const configWatcher = chokidar.watch(
|
|
7
|
-
path.resolve(process.cwd(), 'tsr.config.json'),
|
|
8
|
-
)
|
|
5
|
+
export function watch(root: string) {
|
|
6
|
+
const configWatcher = chokidar.watch(path.resolve(root, 'tsr.config.json'))
|
|
9
7
|
|
|
10
8
|
let watcher = new chokidar.FSWatcher({})
|
|
11
9
|
|
|
@@ -20,7 +18,7 @@ export function watch() {
|
|
|
20
18
|
watcher.on('ready', async () => {
|
|
21
19
|
const handle = async () => {
|
|
22
20
|
try {
|
|
23
|
-
await generator(config)
|
|
21
|
+
await generator(config, root)
|
|
24
22
|
} catch (err) {
|
|
25
23
|
console.error(err)
|
|
26
24
|
console.info()
|
|
@@ -31,7 +29,7 @@ export function watch() {
|
|
|
31
29
|
|
|
32
30
|
let timeout: ReturnType<typeof setTimeout> | undefined
|
|
33
31
|
|
|
34
|
-
const deduped = (
|
|
32
|
+
const deduped = (_file: string) => {
|
|
35
33
|
if (timeout) {
|
|
36
34
|
clearTimeout(timeout)
|
|
37
35
|
}
|