react-fs-router 0.2.9 → 0.2.10

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/bin/index.js CHANGED
@@ -9,7 +9,13 @@ program.storeOptionsAsProperties(name);
9
9
 
10
10
  program.version(version, "-v --version", "Output the current version");
11
11
 
12
- program.requiredOption("-p,--path <path>", "Path to your pages folder");
12
+ program.requiredOption("-p,--page <page>", "Path to your pages folder");
13
+ program.requiredOption(
14
+ "-c,--configs <configs>",
15
+ "Path to store generated files"
16
+ );
13
17
  program.parse(process.argv);
14
18
 
15
- genPath(program.path);
19
+ genPath(program.page, program.configs);
20
+
21
+ module.exports = { configs_path: program.configs };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "react-fs-router",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "File-system based routing for React.",
5
5
  "main": "./bin/index.js",
6
6
  "git repository": "https://github.com/Mehran9675/react-filesystem-routing",
7
7
  "scripts": {
8
- "test": "node ./bin/index.js -p ./pages",
8
+ "test": "node ./bin/index.js -p ./pages -c ./configs",
9
9
  "build": "npx -p typescript tsc"
10
10
  },
11
11
  "keywords": [
@@ -19,7 +19,6 @@
19
19
  "dependencies": {
20
20
  "chokidar": "^3.5.2",
21
21
  "commander": "^8.2.0",
22
- "node": "^16.10.0",
23
22
  "react": "^17.0.2",
24
23
  "react-router-dom": "^5.3.0"
25
24
  },
@@ -28,7 +27,6 @@
28
27
  "rfr": "./bin/index.js"
29
28
  },
30
29
  "devDependencies": {
31
- "@types/node": "^16.10.5",
32
30
  "typescript": "^4.4.4",
33
31
  "prettier": "^2.4.1"
34
32
  }
package/src/Route.js CHANGED
@@ -1,5 +1,7 @@
1
- import { routes } from "./routeConfigs";
2
- import * as Pages from "./routes";
1
+ const { configs_path } = require("../bin/index");
2
+ const { routes } = require(configs_path + "/routeConfigs.js");
3
+ const Pages = require(configs_path + "/route.js");
4
+
3
5
  import React, { useState, useEffect } from "react";
4
6
  import { Route, Switch } from "react-router-dom";
5
7
 
package/src/genPath.js CHANGED
@@ -4,7 +4,7 @@ const chokidar = require("chokidar");
4
4
 
5
5
  let isNotThefirstTimeRunning = true;
6
6
 
7
- module.exports = (page_directory) => {
7
+ module.exports = (page_directory, configs_directory) => {
8
8
  const pathMaker = () => {
9
9
  const readDirectory = (directory, includeDirectory) => {
10
10
  const pages = {};
@@ -107,7 +107,7 @@ module.exports = (page_directory) => {
107
107
  .join("")}};`;
108
108
 
109
109
  fs.writeFileSync(
110
- "./node_modules/react-fs-router/dist/src/generated/routeConfigs.js",
110
+ configs_directory + "/routeConfigs.js",
111
111
  prettier.format(_config, { semi: false, parser: "babel" }),
112
112
  (err) => {
113
113
  if (err) return console.error(err);
@@ -115,7 +115,7 @@ module.exports = (page_directory) => {
115
115
  );
116
116
 
117
117
  fs.writeFileSync(
118
- "./node_modules/react-fs-router/dist/src/generated/route.js",
118
+ configs_directory + "/route.js",
119
119
  prettier.format(_routes, { semi: false, parser: "babel" }),
120
120
  (err) => {
121
121
  if (err) return console.error(err);