@tanstack/router-cli 1.121.0-alpha.22 → 1.121.0-alpha.27
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 +5 -1
- package/dist/cjs/generate.cjs.map +1 -1
- package/dist/cjs/watch.cjs +19 -10
- package/dist/cjs/watch.cjs.map +1 -1
- package/dist/esm/generate.js +6 -2
- package/dist/esm/generate.js.map +1 -1
- package/dist/esm/watch.js +20 -11
- package/dist/esm/watch.js.map +1 -1
- package/package.json +2 -2
- package/src/generate.ts +6 -2
- package/src/watch.ts +21 -14
package/dist/cjs/generate.cjs
CHANGED
|
@@ -3,7 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const routerGenerator = require("@tanstack/router-generator");
|
|
4
4
|
async function generate(config, root) {
|
|
5
5
|
try {
|
|
6
|
-
|
|
6
|
+
const generator = new routerGenerator.Generator({
|
|
7
|
+
config,
|
|
8
|
+
root
|
|
9
|
+
});
|
|
10
|
+
await generator.run();
|
|
7
11
|
process.exit(0);
|
|
8
12
|
} catch (err) {
|
|
9
13
|
console.error(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.cjs","sources":["../../src/generate.ts"],"sourcesContent":["import {
|
|
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 const generator = new Generator({\n config,\n root,\n })\n await generator.run()\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,UAAA,YAAY,IAAIA,0BAAU;AAAA,MAC9B;AAAA,MACA;AAAA,IAAA,CACD;AACD,UAAM,UAAU,IAAI;AACpB,YAAQ,KAAK,CAAC;AAAA,WACP,KAAK;AACZ,YAAQ,MAAM,GAAG;AACjB,YAAQ,KAAK,CAAC;AAAA,EAAA;AAElB;;"}
|
package/dist/cjs/watch.cjs
CHANGED
|
@@ -10,29 +10,38 @@ function watch(root) {
|
|
|
10
10
|
let watcher = new chokidar.FSWatcher({});
|
|
11
11
|
const generatorWatcher = () => {
|
|
12
12
|
const config = routerGenerator.getConfig();
|
|
13
|
+
const generator = new routerGenerator.Generator({ config, root });
|
|
13
14
|
watcher.close();
|
|
14
15
|
console.info(`TSR: Watching routes (${config.routesDirectory})...`);
|
|
15
16
|
watcher = chokidar.watch(config.routesDirectory);
|
|
16
17
|
watcher.on("ready", async () => {
|
|
17
18
|
const handle = async () => {
|
|
18
19
|
try {
|
|
19
|
-
await
|
|
20
|
+
await generator.run();
|
|
20
21
|
} catch (err) {
|
|
21
22
|
console.error(err);
|
|
22
23
|
console.info();
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
await handle();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
watcher.on("all", (event, path) => {
|
|
28
|
+
let type;
|
|
29
|
+
switch (event) {
|
|
30
|
+
case "add":
|
|
31
|
+
type = "create";
|
|
32
|
+
break;
|
|
33
|
+
case "change":
|
|
34
|
+
type = "update";
|
|
35
|
+
break;
|
|
36
|
+
case "unlink":
|
|
37
|
+
type = "delete";
|
|
38
|
+
break;
|
|
30
39
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
if (type) {
|
|
41
|
+
return generator.run({ path, type });
|
|
42
|
+
}
|
|
43
|
+
return generator.run();
|
|
44
|
+
});
|
|
36
45
|
});
|
|
37
46
|
};
|
|
38
47
|
configWatcher.on("ready", generatorWatcher);
|
package/dist/cjs/watch.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.cjs","sources":["../../src/watch.ts"],"sourcesContent":["import chokidar from 'chokidar'\nimport {\n
|
|
1
|
+
{"version":3,"file":"watch.cjs","sources":["../../src/watch.ts"],"sourcesContent":["import chokidar from 'chokidar'\nimport {\n Generator,\n getConfig,\n resolveConfigPath,\n} from '@tanstack/router-generator'\nimport type { FileEventType } from '@tanstack/router-generator'\n\nexport function watch(root: string) {\n const configPath = resolveConfigPath({\n configDirectory: root,\n })\n const configWatcher = chokidar.watch(configPath)\n\n let watcher = new chokidar.FSWatcher({})\n\n const generatorWatcher = () => {\n const config = getConfig()\n const generator = new Generator({ config, root })\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.run()\n } catch (err) {\n console.error(err)\n console.info()\n }\n }\n\n await handle()\n\n watcher.on('all', (event, path) => {\n let type: FileEventType | undefined\n switch (event) {\n case 'add':\n type = 'create'\n break\n case 'change':\n type = 'update'\n break\n case 'unlink':\n type = 'delete'\n break\n }\n if (type) {\n return generator.run({ path, type })\n }\n return generator.run()\n })\n })\n }\n\n configWatcher.on('ready', generatorWatcher)\n configWatcher.on('change', generatorWatcher)\n}\n"],"names":["resolveConfigPath","getConfig","Generator"],"mappings":";;;;AAQO,SAAS,MAAM,MAAc;AAClC,QAAM,aAAaA,gBAAAA,kBAAkB;AAAA,IACnC,iBAAiB;AAAA,EAAA,CAClB;AACK,QAAA,gBAAgB,SAAS,MAAM,UAAU;AAE/C,MAAI,UAAU,IAAI,SAAS,UAAU,CAAA,CAAE;AAEvC,QAAM,mBAAmB,MAAM;AAC7B,UAAM,SAASC,gBAAAA,UAAU;AACzB,UAAM,YAAY,IAAIC,gBAAAA,UAAU,EAAE,QAAQ,MAAM;AAEhD,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;AACF,gBAAM,UAAU,IAAI;AAAA,iBACb,KAAK;AACZ,kBAAQ,MAAM,GAAG;AACjB,kBAAQ,KAAK;AAAA,QAAA;AAAA,MAEjB;AAEA,YAAM,OAAO;AAEb,cAAQ,GAAG,OAAO,CAAC,OAAO,SAAS;AAC7B,YAAA;AACJ,gBAAQ,OAAO;AAAA,UACb,KAAK;AACI,mBAAA;AACP;AAAA,UACF,KAAK;AACI,mBAAA;AACP;AAAA,UACF,KAAK;AACI,mBAAA;AACP;AAAA,QAAA;AAEJ,YAAI,MAAM;AACR,iBAAO,UAAU,IAAI,EAAE,MAAM,MAAM;AAAA,QAAA;AAErC,eAAO,UAAU,IAAI;AAAA,MAAA,CACtB;AAAA,IAAA,CACF;AAAA,EACH;AAEc,gBAAA,GAAG,SAAS,gBAAgB;AAC5B,gBAAA,GAAG,UAAU,gBAAgB;AAC7C;;"}
|
package/dist/esm/generate.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Generator } from "@tanstack/router-generator";
|
|
2
2
|
async function generate(config, root) {
|
|
3
3
|
try {
|
|
4
|
-
|
|
4
|
+
const generator = new Generator({
|
|
5
|
+
config,
|
|
6
|
+
root
|
|
7
|
+
});
|
|
8
|
+
await generator.run();
|
|
5
9
|
process.exit(0);
|
|
6
10
|
} catch (err) {
|
|
7
11
|
console.error(err);
|
package/dist/esm/generate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sources":["../../src/generate.ts"],"sourcesContent":["import {
|
|
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 const generator = new Generator({\n config,\n root,\n })\n await generator.run()\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,YAAY,IAAI,UAAU;AAAA,MAC9B;AAAA,MACA;AAAA,IAAA,CACD;AACD,UAAM,UAAU,IAAI;AACpB,YAAQ,KAAK,CAAC;AAAA,WACP,KAAK;AACZ,YAAQ,MAAM,GAAG;AACjB,YAAQ,KAAK,CAAC;AAAA,EAAA;AAElB;"}
|
package/dist/esm/watch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chokidar from "chokidar";
|
|
2
|
-
import { resolveConfigPath, getConfig,
|
|
2
|
+
import { resolveConfigPath, getConfig, Generator } from "@tanstack/router-generator";
|
|
3
3
|
function watch(root) {
|
|
4
4
|
const configPath = resolveConfigPath({
|
|
5
5
|
configDirectory: root
|
|
@@ -8,29 +8,38 @@ function watch(root) {
|
|
|
8
8
|
let watcher = new chokidar.FSWatcher({});
|
|
9
9
|
const generatorWatcher = () => {
|
|
10
10
|
const config = getConfig();
|
|
11
|
+
const generator = new Generator({ config, root });
|
|
11
12
|
watcher.close();
|
|
12
13
|
console.info(`TSR: Watching routes (${config.routesDirectory})...`);
|
|
13
14
|
watcher = chokidar.watch(config.routesDirectory);
|
|
14
15
|
watcher.on("ready", async () => {
|
|
15
16
|
const handle = async () => {
|
|
16
17
|
try {
|
|
17
|
-
await generator(
|
|
18
|
+
await generator.run();
|
|
18
19
|
} catch (err) {
|
|
19
20
|
console.error(err);
|
|
20
21
|
console.info();
|
|
21
22
|
}
|
|
22
23
|
};
|
|
23
24
|
await handle();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
watcher.on("all", (event, path) => {
|
|
26
|
+
let type;
|
|
27
|
+
switch (event) {
|
|
28
|
+
case "add":
|
|
29
|
+
type = "create";
|
|
30
|
+
break;
|
|
31
|
+
case "change":
|
|
32
|
+
type = "update";
|
|
33
|
+
break;
|
|
34
|
+
case "unlink":
|
|
35
|
+
type = "delete";
|
|
36
|
+
break;
|
|
28
37
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
if (type) {
|
|
39
|
+
return generator.run({ path, type });
|
|
40
|
+
}
|
|
41
|
+
return generator.run();
|
|
42
|
+
});
|
|
34
43
|
});
|
|
35
44
|
};
|
|
36
45
|
configWatcher.on("ready", generatorWatcher);
|
package/dist/esm/watch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sources":["../../src/watch.ts"],"sourcesContent":["import chokidar from 'chokidar'\nimport {\n
|
|
1
|
+
{"version":3,"file":"watch.js","sources":["../../src/watch.ts"],"sourcesContent":["import chokidar from 'chokidar'\nimport {\n Generator,\n getConfig,\n resolveConfigPath,\n} from '@tanstack/router-generator'\nimport type { FileEventType } from '@tanstack/router-generator'\n\nexport function watch(root: string) {\n const configPath = resolveConfigPath({\n configDirectory: root,\n })\n const configWatcher = chokidar.watch(configPath)\n\n let watcher = new chokidar.FSWatcher({})\n\n const generatorWatcher = () => {\n const config = getConfig()\n const generator = new Generator({ config, root })\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.run()\n } catch (err) {\n console.error(err)\n console.info()\n }\n }\n\n await handle()\n\n watcher.on('all', (event, path) => {\n let type: FileEventType | undefined\n switch (event) {\n case 'add':\n type = 'create'\n break\n case 'change':\n type = 'update'\n break\n case 'unlink':\n type = 'delete'\n break\n }\n if (type) {\n return generator.run({ path, type })\n }\n return generator.run()\n })\n })\n }\n\n configWatcher.on('ready', generatorWatcher)\n configWatcher.on('change', generatorWatcher)\n}\n"],"names":[],"mappings":";;AAQO,SAAS,MAAM,MAAc;AAClC,QAAM,aAAa,kBAAkB;AAAA,IACnC,iBAAiB;AAAA,EAAA,CAClB;AACK,QAAA,gBAAgB,SAAS,MAAM,UAAU;AAE/C,MAAI,UAAU,IAAI,SAAS,UAAU,CAAA,CAAE;AAEvC,QAAM,mBAAmB,MAAM;AAC7B,UAAM,SAAS,UAAU;AACzB,UAAM,YAAY,IAAI,UAAU,EAAE,QAAQ,MAAM;AAEhD,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;AACF,gBAAM,UAAU,IAAI;AAAA,iBACb,KAAK;AACZ,kBAAQ,MAAM,GAAG;AACjB,kBAAQ,KAAK;AAAA,QAAA;AAAA,MAEjB;AAEA,YAAM,OAAO;AAEb,cAAQ,GAAG,OAAO,CAAC,OAAO,SAAS;AAC7B,YAAA;AACJ,gBAAQ,OAAO;AAAA,UACb,KAAK;AACI,mBAAA;AACP;AAAA,UACF,KAAK;AACI,mBAAA;AACP;AAAA,UACF,KAAK;AACI,mBAAA;AACP;AAAA,QAAA;AAEJ,YAAI,MAAM;AACR,iBAAO,UAAU,IAAI,EAAE,MAAM,MAAM;AAAA,QAAA;AAErC,eAAO,UAAU,IAAI;AAAA,MAAA,CACtB;AAAA,IAAA,CACF;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.121.0-alpha.
|
|
3
|
+
"version": "1.121.0-alpha.27",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"chokidar": "^3.6.0",
|
|
57
57
|
"yargs": "^17.7.2",
|
|
58
|
-
"@tanstack/router-generator": "^1.121.0-alpha.
|
|
58
|
+
"@tanstack/router-generator": "^1.121.0-alpha.27"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/yargs": "^17.0.33"
|
package/src/generate.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Generator } from '@tanstack/router-generator'
|
|
2
2
|
import type { Config } from '@tanstack/router-generator'
|
|
3
3
|
|
|
4
4
|
export async function generate(config: Config, root: string) {
|
|
5
5
|
try {
|
|
6
|
-
|
|
6
|
+
const generator = new Generator({
|
|
7
|
+
config,
|
|
8
|
+
root,
|
|
9
|
+
})
|
|
10
|
+
await generator.run()
|
|
7
11
|
process.exit(0)
|
|
8
12
|
} catch (err) {
|
|
9
13
|
console.error(err)
|
package/src/watch.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import chokidar from 'chokidar'
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
Generator,
|
|
4
4
|
getConfig,
|
|
5
5
|
resolveConfigPath,
|
|
6
6
|
} from '@tanstack/router-generator'
|
|
7
|
+
import type { FileEventType } from '@tanstack/router-generator'
|
|
7
8
|
|
|
8
9
|
export function watch(root: string) {
|
|
9
10
|
const configPath = resolveConfigPath({
|
|
@@ -15,6 +16,7 @@ export function watch(root: string) {
|
|
|
15
16
|
|
|
16
17
|
const generatorWatcher = () => {
|
|
17
18
|
const config = getConfig()
|
|
19
|
+
const generator = new Generator({ config, root })
|
|
18
20
|
|
|
19
21
|
watcher.close()
|
|
20
22
|
|
|
@@ -24,7 +26,7 @@ export function watch(root: string) {
|
|
|
24
26
|
watcher.on('ready', async () => {
|
|
25
27
|
const handle = async () => {
|
|
26
28
|
try {
|
|
27
|
-
await generator(
|
|
29
|
+
await generator.run()
|
|
28
30
|
} catch (err) {
|
|
29
31
|
console.error(err)
|
|
30
32
|
console.info()
|
|
@@ -33,19 +35,24 @@ export function watch(root: string) {
|
|
|
33
35
|
|
|
34
36
|
await handle()
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
watcher.on('all', (event, path) => {
|
|
39
|
+
let type: FileEventType | undefined
|
|
40
|
+
switch (event) {
|
|
41
|
+
case 'add':
|
|
42
|
+
type = 'create'
|
|
43
|
+
break
|
|
44
|
+
case 'change':
|
|
45
|
+
type = 'update'
|
|
46
|
+
break
|
|
47
|
+
case 'unlink':
|
|
48
|
+
type = 'delete'
|
|
49
|
+
break
|
|
41
50
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
watcher.on('add', deduped)
|
|
48
|
-
watcher.on('unlink', deduped)
|
|
51
|
+
if (type) {
|
|
52
|
+
return generator.run({ path, type })
|
|
53
|
+
}
|
|
54
|
+
return generator.run()
|
|
55
|
+
})
|
|
49
56
|
})
|
|
50
57
|
}
|
|
51
58
|
|