@uxf/scripts 10.0.0-beta.49 → 10.0.0-beta.56

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/scripts",
3
- "version": "10.0.0-beta.49",
3
+ "version": "10.0.0-beta.56",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -3,22 +3,24 @@ const { argv, env } = require("process");
3
3
  module.exports = async () => {
4
4
  const cli = require("yargs")
5
5
  .command("$0", "UXF i18n namespaces generator", (yargs) => {
6
- yargs.demandCommand(0, 0).usage(`UXF i18n namespaces generator
7
- Usage:
6
+ yargs.demandCommand(0, 0).usage(`
7
+ Usage:
8
8
  uxf-i18n-namespaces-gen [options]`);
9
9
  })
10
- .option("h", { alias: "help", group: "Options" })
10
+ .option("i", { alias: "include", array: true, default: [] })
11
+ .option("o", { alias: "output", default: "i18n-pages.json" })
12
+ .option("h", { alias: "help" })
11
13
  .strict(false)
12
14
  .exitProcess(false);
13
15
 
14
16
  try {
15
- const { help, ...options } = cli.parse(argv.slice(2));
17
+ const { help, include, output } = cli.parse(argv.slice(2));
16
18
 
17
19
  if (Boolean(help)) {
18
20
  return 0;
19
21
  }
20
22
 
21
- await require("./index");
23
+ await require("./index")(include, output);
22
24
  } catch (e) {
23
25
  console.error(e);
24
26
  return 1;
@@ -71,10 +71,10 @@ const filePathToRoute = (filePath) => {
71
71
  return removeTrailingSlash(route);
72
72
  };
73
73
 
74
- function main() {
74
+ function main(includes, output) {
75
75
  // Negative lookahead – ignore searching for any files
76
76
  // that aren't part of our include list
77
- const searchDirs = new RegExp(`^(?!(${INCLUDE.join("|")}))`, "i");
77
+ const searchDirs = new RegExp(`^(?!(${[...INCLUDE, includes].join("|")}))`, "i");
78
78
 
79
79
  const pages = walk("src/pages").flat(Number.POSITIVE_INFINITY);
80
80
 
@@ -108,14 +108,10 @@ function main() {
108
108
  }
109
109
  }
110
110
 
111
- writeFileSync(path.resolve(process.cwd(), "i18n-pages.json"), JSON.stringify(result, null, 4));
111
+ writeFileSync(path.resolve(process.cwd(), output), JSON.stringify(result, null, 4));
112
112
 
113
113
  console.log("Namespaces generated!");
114
114
  });
115
115
  }
116
116
 
117
- try {
118
- main();
119
- } catch (e) {
120
- console.error("Error:", e);
121
- }
117
+ module.exports = main;