remix-flat-routes
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "remix-flat-routes", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Package for generating routes using flat convention", | ||
"main": "dist/src/index.js", | ||
"main": "dist/cli.js", | ||
"bin": { | ||
"migrate-flat-routes": "dist/cli.js" | ||
}, | ||
"files": [ | ||
@@ -14,7 +17,8 @@ "dist", | ||
"clean": "rimraf dist", | ||
"build": "npm run clean && tsc --project tsconfig.json --module CommonJS --outDir ./dist", | ||
"build": "npm run clean && esbuild --format=cjs --outdir=./dist ./src/*.ts", | ||
"test": "jest", | ||
"contributors:add": "all-contributors add", | ||
"contributors:generate": "all-contributors generate", | ||
"prepublish": "npm run build" | ||
"prepublish": "npm run build", | ||
"migrate": "rm -rf ./app/flat-files ./app/flat-folders && npm run build && node ./dist/cli.js" | ||
}, | ||
@@ -21,0 +25,0 @@ "keywords": [ |
@@ -36,2 +36,17 @@ # Remix Flat Routes | ||
## 🚚 Migrating Existing Routes | ||
You can now migrate your existing routes to the new flat-routes convention. Simply run: | ||
```bash | ||
npx migrate-flat-routes <sourceDir> <targetDir> [options] | ||
Options: | ||
--convention=<convention> | ||
The convention to use when migrating. | ||
flat-files - Migrates all files to a flat directory structure. | ||
flat-folders - Migrates all files to a flat directory structure, but | ||
creates folders for each route. | ||
``` | ||
## 🔨 Flat Routes Convention | ||
@@ -38,0 +53,0 @@ |
@@ -1,3 +0,3 @@ | ||
import * as fs from 'fs' | ||
import * as path from 'path' | ||
import { visitFiles } from './util' | ||
@@ -23,3 +23,3 @@ export default function flatRoutes( | ||
// setup parent map | ||
for (let [name, route] of routeMap) { | ||
for (let [_name, route] of routeMap) { | ||
let parentRoute = route.parent | ||
@@ -190,19 +190,2 @@ if (parentRoute) { | ||
function visitFiles( | ||
dir: string, | ||
visitor: (file: string) => void, | ||
baseDir = dir, | ||
) { | ||
for (let filename of fs.readdirSync(dir)) { | ||
let file = path.resolve(dir, filename) | ||
let stat = fs.lstatSync(file) | ||
if (stat.isDirectory()) { | ||
visitFiles(file, visitor, baseDir) | ||
} else if (stat.isFile()) { | ||
visitor(path.relative(baseDir, file)) | ||
} | ||
} | ||
} | ||
export { flatRoutes } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32291
11
226
616
2
1