@7nohe/openapi-react-query-codegen 0.1.3 → 0.2.0

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/README.md CHANGED
@@ -18,15 +18,20 @@ $ npm install -D @7nohe/openapi-react-query-codegen
18
18
  ```
19
19
  $ openapi-rq --help
20
20
 
21
- Usage: openapi-rq [options]
22
-
23
- Generate React Query code based on OpenAPI
24
-
25
- Options:
26
- -V, --version output the version number
27
- -p, --path <path> Path to OpenAPI file
28
- -o, --output-dir [directory] Directory to output the generated package (default: "openapi")
29
- -h, --help display help for command
21
+ Usage: openapi-rq [options]
22
+
23
+ Generate React Query code based on OpenAPI
24
+
25
+ Options:
26
+ -V, --version output the version number
27
+ -i, --input <value> OpenAPI specification, can be a path, url or string content (required)
28
+ -o, --output <value> Output directory (default: "openapi")
29
+ -c, --client <value> HTTP client to generate [fetch, xhr, node, axios, angular] (default: "fetch")
30
+ --exportSchemas <value> Write schemas to disk (default: false)
31
+ --indent <value> Indentation options [4, 2, tabs] (default: "4")
32
+ --postfix <value> Service name postfix (default: "Service")
33
+ --request <value> Path to custom request file
34
+ -h, --help display help for command
30
35
  ```
31
36
 
32
37
  ## Example Usage
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/Users/daiki/Documents/openapi-react-query-codegen/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="$NODE_PATH:/Users/daiki/Documents/openapi-react-query-codegen/node_modules/.pnpm/node_modules"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../node_modules/.pnpm/openapi-typescript-codegen@0.23.0/node_modules/openapi-typescript-codegen/bin/index.js" "$@"
15
+ else
16
+ exec node "$basedir/../../../node_modules/.pnpm/openapi-typescript-codegen@0.23.0/node_modules/openapi-typescript-codegen/bin/index.js" "$@"
17
+ fi
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/Users/daiki/Documents/openapi-react-query-codegen/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="$NODE_PATH:/Users/daiki/Documents/openapi-react-query-codegen/node_modules/.pnpm/node_modules"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/bin/tsc" "$@"
15
+ else
16
+ exec node "$basedir/../../../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/bin/tsc" "$@"
17
+ fi
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/Users/daiki/Documents/openapi-react-query-codegen/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="$NODE_PATH:/Users/daiki/Documents/openapi-react-query-codegen/node_modules/.pnpm/node_modules"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/bin/tsserver" "$@"
15
+ else
16
+ exec node "$basedir/../../../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/bin/tsserver" "$@"
17
+ fi
package/dist/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@7nohe/openapi-react-query-codegen",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "OpenAPI React Query Codegen",
5
5
  "bin": {
6
- "openapi-rq": "bin/cli.js"
6
+ "openapi-rq": "dist/src/cli.js"
7
7
  },
8
8
  "scripts": {
9
9
  "build": "tsc -p tsconfig.json",
@@ -32,14 +32,13 @@
32
32
  "author": "Daiki Urata (@7nohe)",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "commander": "^9.4.0"
36
- },
37
- "devDependencies": {
38
- "@types/glob": "^7.2.0",
39
- "@types/node": "^18.0.6",
35
+ "commander": "^9.4.0",
40
36
  "glob": "^8.0.3",
41
- "openapi-types": "^12.0.0",
42
37
  "openapi-typescript-codegen": "^0.23.0",
43
38
  "typescript": "^4.7.4"
39
+ },
40
+ "devDependencies": {
41
+ "@types/glob": "^7.2.0",
42
+ "@types/node": "^18.0.6"
44
43
  }
45
44
  }
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ exports.__esModule = true;
7
+ var generate_1 = require("./generate");
8
+ var commander_1 = require("commander");
9
+ var package_json_1 = __importDefault(require("../package.json"));
10
+ var program = new commander_1.Command();
11
+ program
12
+ .name("openapi-rq")
13
+ .version(package_json_1["default"].version)
14
+ .description("Generate React Query code based on OpenAPI")
15
+ .requiredOption("-i, --input <value>", "OpenAPI specification, can be a path, url or string content (required)")
16
+ .option("-o, --output <value>", "Output directory", "openapi")
17
+ .option("-c, --client <value>", "HTTP client to generate [fetch, xhr, node, axios, angular]", "fetch")
18
+ .option("--exportSchemas <value>", "Write schemas to disk", false)
19
+ .option("--indent <value>", "Indentation options [4, 2, tabs]", "4")
20
+ .option("--postfix <value>", "Service name postfix", "Service")
21
+ .option("--request <value>", "Path to custom request file")
22
+ .parse();
23
+ var options = program.opts();
24
+ console.log("Generating React Query code using OpenApi file ".concat(options.output));
25
+ (0, generate_1.generate)(options);
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.requestsOutputPath = exports.queriesOutputPath = exports.defaultOutputPath = void 0;
4
+ exports.defaultOutputPath = "openapi";
5
+ exports.queriesOutputPath = "queries";
6
+ exports.requestsOutputPath = "requests";
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -44,19 +55,18 @@ var openapi_typescript_codegen_1 = require("openapi-typescript-codegen");
44
55
  var print_1 = require("./print");
45
56
  var path_1 = __importDefault(require("path"));
46
57
  var createSource_1 = require("./createSource");
58
+ var constants_1 = require("./constants");
47
59
  function generate(options) {
60
+ var _a;
48
61
  return __awaiter(this, void 0, void 0, function () {
49
62
  var openApiOutputPath, source;
50
- return __generator(this, function (_a) {
51
- switch (_a.label) {
63
+ return __generator(this, function (_b) {
64
+ switch (_b.label) {
52
65
  case 0:
53
- openApiOutputPath = path_1["default"].join(options.outputDir, "requests");
54
- return [4 /*yield*/, (0, openapi_typescript_codegen_1.generate)({
55
- input: options.path,
56
- output: openApiOutputPath
57
- })];
66
+ openApiOutputPath = path_1["default"].join((_a = options.output) !== null && _a !== void 0 ? _a : constants_1.defaultOutputPath, constants_1.requestsOutputPath);
67
+ return [4 /*yield*/, (0, openapi_typescript_codegen_1.generate)(__assign(__assign({}, options), { httpClient: options.client, output: openApiOutputPath }))];
58
68
  case 1:
59
- _a.sent();
69
+ _b.sent();
60
70
  source = (0, createSource_1.createSource)(openApiOutputPath);
61
71
  (0, print_1.print)(source, options);
62
72
  return [2 /*return*/];
package/dist/src/print.js CHANGED
@@ -6,16 +6,20 @@ exports.__esModule = true;
6
6
  exports.print = void 0;
7
7
  var fs_1 = __importDefault(require("fs"));
8
8
  var path_1 = __importDefault(require("path"));
9
+ var constants_1 = require("./constants");
9
10
  function printGeneratedTS(result, options) {
10
- var dir = path_1["default"].join(options.outputDir, "queries");
11
+ var _a;
12
+ var dir = path_1["default"].join((_a = options.output) !== null && _a !== void 0 ? _a : constants_1.defaultOutputPath, constants_1.queriesOutputPath);
11
13
  if (!fs_1["default"].existsSync(dir)) {
12
14
  fs_1["default"].mkdirSync(dir, { recursive: true });
13
15
  }
14
- fs_1["default"].writeFileSync(path_1["default"].join(dir, 'index.ts'), result);
16
+ fs_1["default"].writeFileSync(path_1["default"].join(dir, "index.ts"), result);
15
17
  }
16
18
  function print(result, options) {
17
- if (!fs_1["default"].existsSync(options.outputDir)) {
18
- fs_1["default"].mkdirSync(options.outputDir);
19
+ var _a;
20
+ var outputPath = (_a = options.output) !== null && _a !== void 0 ? _a : constants_1.defaultOutputPath;
21
+ if (!fs_1["default"].existsSync(outputPath)) {
22
+ fs_1["default"].mkdirSync(outputPath);
19
23
  }
20
24
  printGeneratedTS(result, options);
21
25
  }
package/package.json CHANGED
@@ -1,15 +1,9 @@
1
1
  {
2
2
  "name": "@7nohe/openapi-react-query-codegen",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "OpenAPI React Query Codegen",
5
5
  "bin": {
6
- "openapi-rq": "bin/cli.js"
7
- },
8
- "scripts": {
9
- "build": "tsc -p tsconfig.json",
10
- "preview": "npm run build && npm -C examples/react-app run generate:api",
11
- "prepublishOnly": "npm run build",
12
- "release": "npx git-ensure -a && npx bumpp --commit --tag --push"
6
+ "openapi-rq": "dist/src/cli.js"
13
7
  },
14
8
  "repository": {
15
9
  "type": "git",
@@ -32,14 +26,18 @@
32
26
  "author": "Daiki Urata (@7nohe)",
33
27
  "license": "MIT",
34
28
  "dependencies": {
35
- "commander": "^9.4.0"
36
- },
37
- "devDependencies": {
38
- "@types/glob": "^7.2.0",
39
- "@types/node": "^18.0.6",
29
+ "commander": "^9.4.0",
40
30
  "glob": "^8.0.3",
41
- "openapi-types": "^12.0.0",
42
31
  "openapi-typescript-codegen": "^0.23.0",
43
32
  "typescript": "^4.7.4"
33
+ },
34
+ "devDependencies": {
35
+ "@types/glob": "^7.2.0",
36
+ "@types/node": "^18.0.6"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc -p tsconfig.json",
40
+ "preview": "npm run build && npm -C examples/react-app run generate:api",
41
+ "release": "npx git-ensure -a && npx bumpp --commit --tag --push"
44
42
  }
45
- }
43
+ }
package/dist/bin/cli.js DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- exports.__esModule = true;
7
- var generate_1 = require("../src/generate");
8
- var commander_1 = require("commander");
9
- var package_json_1 = __importDefault(require("../package.json"));
10
- var program = new commander_1.Command();
11
- program
12
- .name('openapi-rq')
13
- .version(package_json_1["default"].version)
14
- .description("Generate React Query code based on OpenAPI")
15
- .requiredOption("-p, --path <path>", "Path to OpenAPI file")
16
- .option("-o, --output-dir [directory]", "Directory to output the generated package", "openapi")
17
- .parse();
18
- var options = program.opts();
19
- console.log("Generating React Query code using OpenApi file ".concat(options.path));
20
- (0, generate_1.generate)(options);