Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tanstack/router-generator

Package Overview
Dependencies
Maintainers
2
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/router-generator - npm Package Compare versions

Comparing version 1.32.10 to 1.33.8

79

dist/esm/generator.js

@@ -418,6 +418,7 @@ import path from "path";

var _a, _b;
const filePathId = removeTrailingUnderscores(routeNode.routePath);
const id = removeGroups(filePathId ?? "");
const [filePathId, routeId] = getFilePathIdAndRouteIdFromPath(
routeNode.routePath
);
return `'${filePathId}': {
id: '${id}'
id: '${routeId}'
path: '${inferPath(routeNode)}'

@@ -436,10 +437,49 @@ fullPath: '${inferFullPath(routeNode)}'

].filter(Boolean).join("\n\n");
const routeConfigFileContent = await prettier.format(routeImports, {
semi: config.semicolons,
singleQuote: config.quoteStyle === "single",
parser: "typescript"
});
const routeTreeContent = await fsp.readFile(path.resolve(config.generatedRouteTree), "utf-8").catch((err) => {
const routeManifest = JSON.stringify(
{
routes: {
__root__: {
filePath: rootRouteNode == null ? void 0 : rootRouteNode.filePath,
children: routeTree.map(
(d) => getFilePathIdAndRouteIdFromPath(d.routePath)[1]
)
},
...Object.fromEntries(
routeNodes.map((d) => {
var _a, _b;
const [filePathId, routeId] = getFilePathIdAndRouteIdFromPath(
d.routePath
);
return [
routeId,
{
filePath: d.filePath,
parent: ((_a = d.parent) == null ? void 0 : _a.routePath) ? getFilePathIdAndRouteIdFromPath(d.parent.routePath)[1] : void 0,
children: (_b = d.children) == null ? void 0 : _b.map(
(childRoute) => getFilePathIdAndRouteIdFromPath(childRoute.routePath)[1]
)
}
];
})
)
}
},
null,
2
);
const routeConfigFileContent = [
await prettier.format(routeImports, {
semi: config.semicolons,
singleQuote: config.quoteStyle === "single",
parser: "typescript"
}),
["/* ROUTE_MANIFEST_START", routeManifest, "ROUTE_MANIFEST_END */"].join(
"\n"
)
].join("\n\n");
if (!checkLatest())
return;
const existingRouteTreeContent = await fsp.readFile(path.resolve(config.generatedRouteTree), "utf-8").catch((err) => {
if (err.code === "ENOENT") {
return void 0;
return "";
}

@@ -450,8 +490,8 @@ throw err;

return;
if (routeTreeContent !== routeConfigFileContent) {
await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {
recursive: true
});
if (!checkLatest())
return;
await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {
recursive: true
});
if (!checkLatest())
return;
if (existingRouteTreeContent !== routeConfigFileContent) {
await fsp.writeFile(

@@ -461,2 +501,4 @@ path.resolve(config.generatedRouteTree),

);
if (!checkLatest())
return;
}

@@ -557,2 +599,7 @@ logger.log(

};
function getFilePathIdAndRouteIdFromPath(pathname) {
const filePathId = removeTrailingUnderscores(pathname);
const id = removeGroups(filePathId ?? "");
return [filePathId, id];
}
export {

@@ -559,0 +606,0 @@ generator,

{
"name": "@tanstack/router-generator",
"version": "1.32.10",
"version": "1.33.8",
"description": "",

@@ -5,0 +5,0 @@ "author": "Tanner Linsley",

@@ -586,7 +586,8 @@ import path from 'path'

.map((routeNode) => {
const filePathId = removeTrailingUnderscores(routeNode.routePath)
const id = removeGroups(filePathId ?? '')
const [filePathId, routeId] = getFilePathIdAndRouteIdFromPath(
routeNode.routePath!,
)
return `'${filePathId}': {
id: '${id}'
id: '${routeId}'
path: '${inferPath(routeNode)}'

@@ -615,14 +616,58 @@ fullPath: '${inferFullPath(routeNode)}'

const routeConfigFileContent = await prettier.format(routeImports, {
semi: config.semicolons,
singleQuote: config.quoteStyle === 'single',
parser: 'typescript',
})
const routeManifest = JSON.stringify(
{
routes: {
__root__: {
filePath: rootRouteNode?.filePath,
children: routeTree.map(
(d) => getFilePathIdAndRouteIdFromPath(d.routePath!)[1],
),
},
...Object.fromEntries(
routeNodes.map((d) => {
const [filePathId, routeId] = getFilePathIdAndRouteIdFromPath(
d.routePath!,
)
const routeTreeContent = await fsp
return [
routeId,
{
filePath: d.filePath,
parent: d.parent?.routePath
? getFilePathIdAndRouteIdFromPath(d.parent.routePath)[1]
: undefined,
children: d.children?.map(
(childRoute) =>
getFilePathIdAndRouteIdFromPath(childRoute.routePath!)[1],
),
},
]
}),
),
},
},
null,
2,
)
const routeConfigFileContent = [
await prettier.format(routeImports, {
semi: config.semicolons,
singleQuote: config.quoteStyle === 'single',
parser: 'typescript',
}),
['/* ROUTE_MANIFEST_START', routeManifest, 'ROUTE_MANIFEST_END */'].join(
'\n',
),
].join('\n\n')
if (!checkLatest()) return
const existingRouteTreeContent = await fsp
.readFile(path.resolve(config.generatedRouteTree), 'utf-8')
.catch((err: any) => {
.catch((err) => {
if (err.code === 'ENOENT') {
return undefined
return ''
}
throw err

@@ -633,7 +678,11 @@ })

if (routeTreeContent !== routeConfigFileContent) {
await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {
recursive: true,
})
if (!checkLatest()) return
// Ensure the directory exists
await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {
recursive: true,
})
if (!checkLatest()) return
// Write the route tree file, if it has changed
if (existingRouteTreeContent !== routeConfigFileContent) {
await fsp.writeFile(

@@ -643,2 +692,3 @@ path.resolve(config.generatedRouteTree),

)
if (!checkLatest()) return
}

@@ -819,1 +869,8 @@

}
function getFilePathIdAndRouteIdFromPath(pathname: string) {
const filePathId = removeTrailingUnderscores(pathname)
const id = removeGroups(filePathId ?? '')
return [filePathId, id] as const
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc