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.57.9 to 1.57.13

76

dist/esm/generator.js

@@ -5,3 +5,3 @@ import path from "node:path";

import * as prettier from "prettier";
import { logging, multiSortBy, replaceBackslash, removeExt, removeUnderscores, removeTrailingSlash, determineInitialRoutePath, trimPathLeft, routePathToVariable } from "./utils.js";
import { logging, multiSortBy, replaceBackslash, removeExt, writeIfDifferent, removeUnderscores, removeTrailingSlash, determineInitialRoutePath, trimPathLeft, routePathToVariable } from "./utils.js";
import { getRouteNodes as getRouteNodes$1 } from "./filesystem/physical/getRouteNodes.js";

@@ -155,6 +155,13 @@ import { getRouteNodes } from "./filesystem/virtual/getRouteNodes.js";

}
if (replaced !== routeCode) {
logger.log(`🟡 Updating ${node.fullPath}`);
await fsp.writeFile(node.fullPath, replaced);
}
await writeIfDifferent(
node.fullPath,
prettierOptions,
routeCode,
replaced,
{
beforeWrite: () => {
logger.log(`🟡 Updating ${node.fullPath}`);
}
}
);
}

@@ -252,13 +259,16 @@ if (!node.isVirtual && (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent || node.isLazy)) {

} else {
const copied = routeCode.replace(
/(createAPIFileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
(_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`
await writeIfDifferent(
node.fullPath,
prettierOptions,
routeCode,
routeCode.replace(
/(createAPIFileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
(_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`
),
{
beforeWrite: () => {
logger.log(`🟡 Updating ${node.fullPath}`);
}
}
);
if (copied !== routeCode) {
logger.log(`🟡 Updating ${node.fullPath}`);
await fsp.writeFile(
node.fullPath,
await prettier.format(copied, prettierOptions)
);
}
}

@@ -507,12 +517,9 @@ };

};
const routeConfigFileContent = await prettier.format(
config.disableManifestGeneration ? routeImports : [
routeImports,
"\n",
"/* ROUTE_MANIFEST_START",
createRouteManifest(),
"ROUTE_MANIFEST_END */"
].join("\n"),
prettierOptions
);
const routeConfigFileContent = config.disableManifestGeneration ? routeImports : [
routeImports,
"\n",
"/* ROUTE_MANIFEST_START",
createRouteManifest(),
"ROUTE_MANIFEST_END */"
].join("\n");
if (!checkLatest()) return;

@@ -530,8 +537,15 @@ const existingRouteTreeContent = await fsp.readFile(path.resolve(config.generatedRouteTree), "utf-8").catch((err) => {

if (!checkLatest()) return;
if (existingRouteTreeContent !== routeConfigFileContent) {
await fsp.writeFile(
path.resolve(config.generatedRouteTree),
routeConfigFileContent
);
if (!checkLatest()) return;
const routeTreeWriteResult = await writeIfDifferent(
path.resolve(config.generatedRouteTree),
prettierOptions,
existingRouteTreeContent,
routeConfigFileContent,
{
beforeWrite: () => {
logger.log(`🟡 Updating ${config.generatedRouteTree}`);
}
}
);
if (routeTreeWriteResult && !checkLatest()) {
return;
}

@@ -538,0 +552,0 @@ logger.log(

@@ -0,1 +1,2 @@

import * as prettier from 'prettier';
export declare function multiSortBy<T>(arr: Array<T>, accessors?: Array<(item: T) => any>): Array<T>;

@@ -21,1 +22,15 @@ export declare function cleanPath(path: string): string;

export declare function removeExt(d: string, keepExtension?: boolean): string;
/**
* This function writes to a file if the content is different.
*
* @param filepath The path to the file
* @param prettierOptions Prettier options
* @param content Original content
* @param incomingContent New content
* @param callbacks Callbacks to run before and after writing
* @returns Whether the file was written
*/
export declare function writeIfDifferent(filepath: string, prettierOptions: prettier.Options, content: string, incomingContent: string, callbacks?: {
beforeWrite?: () => void;
afterWrite?: () => void;
}): Promise<boolean>;

@@ -0,1 +1,3 @@

import * as fs from "node:fs";
import * as prettier from "prettier";
function multiSortBy(arr, accessors = [(d) => d]) {

@@ -71,2 +73,16 @@ return arr.map((d, i) => [d, i]).sort(([a, ai], [b, bi]) => {

}
async function writeIfDifferent(filepath, prettierOptions, content, incomingContent, callbacks) {
var _a, _b;
const [formattedContent, updatedContent] = await Promise.all([
prettier.format(content, prettierOptions),
prettier.format(incomingContent, prettierOptions)
]);
if (formattedContent !== updatedContent) {
(_a = callbacks == null ? void 0 : callbacks.beforeWrite) == null ? void 0 : _a.call(callbacks);
fs.writeFileSync(filepath, updatedContent);
(_b = callbacks == null ? void 0 : callbacks.afterWrite) == null ? void 0 : _b.call(callbacks);
return true;
}
return false;
}
export {

@@ -84,4 +100,5 @@ capitalize,

routePathToVariable,
trimPathLeft
trimPathLeft,
writeIfDifferent
};
//# sourceMappingURL=utils.js.map
{
"name": "@tanstack/router-generator",
"version": "1.57.9",
"version": "1.57.13",
"description": "Modern and scalable routing for React applications",

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

@@ -15,2 +15,3 @@ import path from 'node:path'

trimPathLeft,
writeIfDifferent,
} from './utils'

@@ -230,6 +231,13 @@ import { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes'

if (replaced !== routeCode) {
logger.log(`🟡 Updating ${node.fullPath}`)
await fsp.writeFile(node.fullPath, replaced)
}
await writeIfDifferent(
node.fullPath,
prettierOptions,
routeCode,
replaced,
{
beforeWrite: () => {
logger.log(`🟡 Updating ${node.fullPath}`)
},
},
)
}

@@ -366,14 +374,16 @@

} else {
const copied = routeCode.replace(
/(createAPIFileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
(_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,
await writeIfDifferent(
node.fullPath,
prettierOptions,
routeCode,
routeCode.replace(
/(createAPIFileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
(_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,
),
{
beforeWrite: () => {
logger.log(`🟡 Updating ${node.fullPath}`)
},
},
)
if (copied !== routeCode) {
logger.log(`🟡 Updating ${node.fullPath}`)
await fsp.writeFile(
node.fullPath,
await prettier.format(copied, prettierOptions),
)
}
}

@@ -679,14 +689,11 @@ }

const routeConfigFileContent = await prettier.format(
config.disableManifestGeneration
? routeImports
: [
routeImports,
'\n',
'/* ROUTE_MANIFEST_START',
createRouteManifest(),
'ROUTE_MANIFEST_END */',
].join('\n'),
prettierOptions,
)
const routeConfigFileContent = config.disableManifestGeneration
? routeImports
: [
routeImports,
'\n',
'/* ROUTE_MANIFEST_START',
createRouteManifest(),
'ROUTE_MANIFEST_END */',
].join('\n')

@@ -715,8 +722,15 @@ if (!checkLatest()) return

// Write the route tree file, if it has changed
if (existingRouteTreeContent !== routeConfigFileContent) {
await fsp.writeFile(
path.resolve(config.generatedRouteTree),
routeConfigFileContent,
)
if (!checkLatest()) return
const routeTreeWriteResult = await writeIfDifferent(
path.resolve(config.generatedRouteTree),
prettierOptions,
existingRouteTreeContent,
routeConfigFileContent,
{
beforeWrite: () => {
logger.log(`🟡 Updating ${config.generatedRouteTree}`)
},
},
)
if (routeTreeWriteResult && !checkLatest()) {
return
}

@@ -723,0 +737,0 @@

@@ -0,1 +1,4 @@

import * as fs from 'node:fs'
import * as prettier from 'prettier'
export function multiSortBy<T>(

@@ -102,1 +105,33 @@ arr: Array<T>,

}
/**
* This function writes to a file if the content is different.
*
* @param filepath The path to the file
* @param prettierOptions Prettier options
* @param content Original content
* @param incomingContent New content
* @param callbacks Callbacks to run before and after writing
* @returns Whether the file was written
*/
export async function writeIfDifferent(
filepath: string,
prettierOptions: prettier.Options,
content: string,
incomingContent: string,
callbacks?: { beforeWrite?: () => void; afterWrite?: () => void },
): Promise<boolean> {
const [formattedContent, updatedContent] = await Promise.all([
prettier.format(content, prettierOptions),
prettier.format(incomingContent, prettierOptions),
])
if (formattedContent !== updatedContent) {
callbacks?.beforeWrite?.()
fs.writeFileSync(filepath, updatedContent)
callbacks?.afterWrite?.()
return true
}
return false
}

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

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

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