-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add @routes-gen/solid-start driver (#29)
* add @routes-gen/solid-start * move patch-package dependency to the root * publish script without solid-start But notice we need to merge the patch to solid-start or do some patching * ready to publish under @nirtamir2/routes-gen-solid-start * use @nirtamir2/solid-start and use publish script without removing solid-start * 0.0.2 * 0.0.3 * upgrade to solid-start 0.2.10 * v0.0.4 * 0.0.5 * change package name * remove useless path * filter * routes * v0.0.6 * Revert "v0.0.6" This reverts commit 85bb3ed. * fix typo * add solid-start as peer dependency
- Loading branch information
Showing
8 changed files
with
1,066 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @routes-gen/solid-start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# @routes-gen/solid-start | ||
|
||
This package is a [**routes-gen**](https://github.com/sandulat/routes-gen) driver for [SolidStart](https://github.com/solidjs/solid-start). | ||
|
||
## Installation | ||
|
||
``` | ||
yarn add routes-gen @routes-gen/solid-start | ||
``` | ||
|
||
## Usage | ||
|
||
``` | ||
yarn routes-gen -d @routes-gen/solid-start | ||
``` | ||
|
||
By default, it exports the routes to: `${appDirectory}/routes.d.ts`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "@routes-gen/routes-gen-solid-start", | ||
"version": "0.0.1", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"license": "MIT", | ||
"repository": { | ||
"url": "https://github.com/sandulat/routes-gen", | ||
"directory": "packages/routes-gen-solid-start" | ||
}, | ||
"scripts": { | ||
"build": "rollup -c", | ||
"dev": "rollup -c --watch", | ||
"test": "jest" | ||
}, | ||
"files": [ | ||
"dist/**", | ||
"package.json", | ||
"README.md" | ||
], | ||
"dependencies": { | ||
"routes-gen": "*", | ||
"solid-start": "^0.2.10" | ||
}, | ||
"devDependencies": { | ||
"config": "*" | ||
}, | ||
"peerDependencies": { | ||
"solid-start": "^0.2.10" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = require("config/rollup")({ | ||
input: "src/index.ts", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { exec } from "child_process"; | ||
import { Driver } from "routes-gen/src"; | ||
|
||
const appDirectory = "./src"; | ||
export const defaultOutputPath: Driver["defaultOutputPath"] = `${appDirectory}/routes.d.ts`; | ||
export const watchPaths: Driver["watchPaths"] = async () => [ | ||
`${appDirectory}/routes/**/*.{ts,tsx,js,jsx}`, | ||
]; | ||
|
||
type SolidStartRouteData = { | ||
id: string; | ||
path: string; | ||
componentPath: string; | ||
dataPath: string; | ||
}; | ||
export const routes: Driver["routes"] = async () => { | ||
const parsedRoutes = await new Promise<Array<SolidStartRouteData>>( | ||
async (resolve) => { | ||
exec(`npx solid-start routes`, (error, stdout) => { | ||
try { | ||
if (error != null) { | ||
console.error("error", error); | ||
resolve([]); | ||
} else { | ||
const routes = JSON.parse(stdout) as Array<SolidStartRouteData>; | ||
const filteredRoutes = routes.filter((route) => { | ||
return !route.path.includes("*"); | ||
}); | ||
resolve(filteredRoutes); | ||
} | ||
} catch (error) { | ||
resolve([]); | ||
} | ||
}); | ||
} | ||
); | ||
if (parsedRoutes.length === 0) { | ||
throw new Error( | ||
'Couldn\'t parse routes. This may be due to breaking changes in "solid-start".' | ||
); | ||
} | ||
return parsedRoutes; | ||
}; | ||
|
||
module.exports = { | ||
defaultOutputPath, | ||
watchPaths, | ||
routes, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "config/tsconfig.json", | ||
"include": ["./src"], | ||
"exclude": ["dist", "node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.