nestia 2.0.1-dev.20220413-2 → 2.0.2

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,13 +1,12 @@
1
1
  {
2
2
  "name": "nestia",
3
- "version": "2.0.1-dev.20220413-2",
3
+ "version": "2.0.2",
4
4
  "description": "Automatic SDK and Document generator for the NestJS",
5
5
  "main": "src/index.ts",
6
6
  "bin": {
7
- "nestia": "./src/bin/nestia.js"
7
+ "nestia": "./src/bin/nestia.ts"
8
8
  },
9
9
  "scripts": {
10
- "build": "tsc src/bin/nestia.ts",
11
10
  "dev": "tsc --watch",
12
11
  "test": "cd test && bash script.sh",
13
12
  "test:default": "cd test/default && rimraf -rf src/api/functional && ts-node ../../src/bin/nestia sdk src/controllers --out src/api"
@@ -37,10 +36,10 @@
37
36
  "cli": "^1.0.1",
38
37
  "del": "^6.0.0",
39
38
  "glob": "^7.2.0",
40
- "ts-node": "^9.1.1",
39
+ "ts-node": "^10.4.0",
41
40
  "tstl": "^2.5.3",
42
41
  "ttypescript": "^1.5.13",
43
- "typescript": "^4.5.3",
42
+ "typescript": "^4.6.3",
44
43
  "typescript-is": "^0.19.0",
45
44
  "typescript-transform-paths": "^3.3.1"
46
45
  },
package/src/bin/nestia.ts CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env ts-node
2
+
1
3
  import * as cp from "child_process";
2
4
  import * as fs from "fs";
3
5
 
package/tsconfig.json CHANGED
@@ -17,7 +17,7 @@
17
17
  // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
18
18
  // "sourceMap": true, /* Generates corresponding '.map' file. */
19
19
  // "outFile": "./", /* Concatenate and emit output to single file. */
20
- "outDir": "./lib", /* Redirect output structure to the directory. */
20
+ // "outDir": "./lib", /* Redirect output structure to the directory. */
21
21
  // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
22
22
  // "composite": true, /* Enable project compilation */
23
23
  // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
package/src/bin/nestia.js DELETED
@@ -1,160 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
43
- }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
46
- };
47
- exports.__esModule = true;
48
- var cp = require("child_process");
49
- var fs = require("fs");
50
- var CompilerOptions_1 = require("../internal/CompilerOptions");
51
- var stripJsonComments_1 = require("../utils/stripJsonComments");
52
- function install() {
53
- // INSTALL DEPENDENCIES
54
- for (var _i = 0, _a = ["nestia-fetcher", "typescript-is"]; _i < _a.length; _i++) {
55
- var lib = _a[_i];
56
- var command = "npm install ".concat(lib);
57
- cp.execSync(command, { stdio: "inherit" });
58
- }
59
- }
60
- function sdk() {
61
- // PREPARE COMMAND
62
- var parameters = __spreadArray([
63
- "npx ts-node -C ttypescript",
64
- __dirname + "/../executable/sdk"
65
- ], process.argv.slice(3), true);
66
- var command = parameters.join(" ");
67
- // EXECUTE THE COMMAND, BUT IGNORE WARNINGS
68
- cp.execSync(command, {
69
- stdio: "inherit",
70
- env: { "NODE_NO_WARNINGS": "1" }
71
- });
72
- }
73
- function configure(config) {
74
- if (!config.compilerOptions) {
75
- config.compilerOptions = CompilerOptions_1.CompilerOptions.DEFAULT;
76
- return true;
77
- }
78
- else
79
- return CompilerOptions_1.CompilerOptions.emend(config.compilerOptions);
80
- }
81
- function tsconfig(task) {
82
- return __awaiter(this, void 0, void 0, function () {
83
- var prepare, restore, config_1, content_1, config_2, changed, error;
84
- return __generator(this, function (_a) {
85
- switch (_a.label) {
86
- case 0:
87
- prepare = null;
88
- restore = null;
89
- if (!(fs.existsSync("tsconfig.json") === false)) return [3 /*break*/, 1];
90
- config_1 = {
91
- compilerOptions: CompilerOptions_1.CompilerOptions.DEFAULT
92
- };
93
- prepare = function () { return fs.promises.writeFile("tsconfig.json", JSON.stringify(config_1, null, 2), "utf8"); };
94
- restore = function () { return fs.promises.unlink("tsconfig.json"); };
95
- return [3 /*break*/, 3];
96
- case 1: return [4 /*yield*/, fs.promises.readFile("tsconfig.json", "utf8")];
97
- case 2:
98
- content_1 = _a.sent();
99
- config_2 = JSON.parse((0, stripJsonComments_1.stripJsonComments)(content_1));
100
- changed = configure(config_2);
101
- if (changed === true) {
102
- // NEED TO ADD TRANSFORM PLUGINS
103
- prepare = function () { return fs.promises.writeFile("tsconfig.json", JSON.stringify(config_2, null, 2), "utf8"); };
104
- restore = function () { return fs.promises.writeFile("tsconfig.json", content_1, "utf8"); };
105
- }
106
- _a.label = 3;
107
- case 3:
108
- if (!(prepare !== null)) return [3 /*break*/, 5];
109
- return [4 /*yield*/, prepare()];
110
- case 4:
111
- _a.sent();
112
- _a.label = 5;
113
- case 5:
114
- error = null;
115
- try {
116
- task();
117
- }
118
- catch (exp) {
119
- error = exp;
120
- }
121
- if (!(restore !== null)) return [3 /*break*/, 7];
122
- return [4 /*yield*/, restore()];
123
- case 6:
124
- _a.sent();
125
- _a.label = 7;
126
- case 7:
127
- // THROW ERROR IF EXISTS
128
- if (error)
129
- throw error;
130
- return [2 /*return*/];
131
- }
132
- });
133
- });
134
- }
135
- function main() {
136
- return __awaiter(this, void 0, void 0, function () {
137
- return __generator(this, function (_a) {
138
- switch (_a.label) {
139
- case 0:
140
- if (!(process.argv[2] === "install")) return [3 /*break*/, 2];
141
- return [4 /*yield*/, install()];
142
- case 1:
143
- _a.sent();
144
- return [3 /*break*/, 5];
145
- case 2:
146
- if (!(process.argv[2] === "sdk")) return [3 /*break*/, 4];
147
- return [4 /*yield*/, tsconfig(sdk)];
148
- case 3:
149
- _a.sent();
150
- return [3 /*break*/, 5];
151
- case 4: throw new Error("nestia supports only two commands; install and sdk, however you typed ".concat(process.argv[2]));
152
- case 5: return [2 /*return*/];
153
- }
154
- });
155
- });
156
- }
157
- main()["catch"](function (exp) {
158
- console.log(exp.message);
159
- process.exit(-1);
160
- });
@@ -1,94 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.CompilerOptions = void 0;
4
- var CompilerOptions;
5
- (function (CompilerOptions) {
6
- CompilerOptions.DEPENDENCIES = [
7
- "nestia-fetcher",
8
- "typescript-is"
9
- ];
10
- CompilerOptions.TRANSFORMERS = [
11
- "typescript-is/lib/transform-inline/transformer",
12
- "typescript-transform-paths"
13
- ];
14
- CompilerOptions.TYPES = [];
15
- CompilerOptions.DEFAULT = {
16
- target: "es5",
17
- module: "commonjs",
18
- lib: [
19
- "DOM",
20
- "ES2015"
21
- ],
22
- strict: true,
23
- downlevelIteration: true,
24
- esModuleInterop: true,
25
- plugins: CompilerOptions.TRANSFORMERS.map(function (transform) { return ({ transform: transform }); }),
26
- types: [
27
- "node",
28
- "reflect-metadata"
29
- ],
30
- experimentalDecorators: true,
31
- emitDecoratorMetadata: true
32
- };
33
- function emend(options) {
34
- // FILL ARRAY DATA
35
- if (!options.plugins)
36
- options.plugins = [];
37
- if (!options.types)
38
- options.types = [];
39
- // CONSTRUCT CHECKERS
40
- var emended = options;
41
- var checkers = [
42
- function () {
43
- var changed = false;
44
- var _loop_1 = function (transform) {
45
- if (emended.plugins.find(function (elem) { return elem.transform === transform; }) !== undefined)
46
- return "continue";
47
- changed = true;
48
- emended.plugins.push({ transform: transform });
49
- };
50
- for (var _i = 0, _a = CompilerOptions.TRANSFORMERS; _i < _a.length; _i++) {
51
- var transform = _a[_i];
52
- _loop_1(transform);
53
- }
54
- return changed;
55
- },
56
- function () {
57
- var changed = false;
58
- var _loop_2 = function (type) {
59
- if (emended.types.find(function (elem) { return elem === type; }) !== undefined)
60
- return "continue";
61
- changed = true;
62
- emended.types.push(type);
63
- };
64
- for (var _i = 0, _a = CompilerOptions.TYPES; _i < _a.length; _i++) {
65
- var type = _a[_i];
66
- _loop_2(type);
67
- }
68
- return changed;
69
- },
70
- function () {
71
- var changed = emended.experimentalDecorators !== true;
72
- if (changed)
73
- emended.experimentalDecorators = true;
74
- return changed;
75
- },
76
- function () {
77
- var changed = emended.emitDecoratorMetadata !== true;
78
- if (changed)
79
- emended.emitDecoratorMetadata = true;
80
- return changed;
81
- },
82
- function () {
83
- var changed = emended.esModuleInterop !== true;
84
- if (changed)
85
- emended.esModuleInterop = true;
86
- return changed;
87
- }
88
- ];
89
- // DO CHECK IT
90
- var checks = checkers.map(function (func) { return func(); });
91
- return checks.some(function (flag) { return flag; });
92
- }
93
- CompilerOptions.emend = emend;
94
- })(CompilerOptions = exports.CompilerOptions || (exports.CompilerOptions = {}));
@@ -1,75 +0,0 @@
1
- "use strict";
2
- // https://github.com/sindresorhus/strip-json-comments
3
- exports.__esModule = true;
4
- exports.stripJsonComments = void 0;
5
- var singleComment = Symbol('singleComment');
6
- var multiComment = Symbol('multiComment');
7
- var stripWithoutWhitespace = function () { return ''; };
8
- var stripWithWhitespace = function (string, start, end) { return string.slice(start, end).replace(/\S/g, ' '); };
9
- var isEscaped = function (jsonString, quotePosition) {
10
- var index = quotePosition - 1;
11
- var backslashCount = 0;
12
- while (jsonString[index] === '\\') {
13
- index -= 1;
14
- backslashCount += 1;
15
- }
16
- return Boolean(backslashCount % 2);
17
- };
18
- function stripJsonComments(jsonString, _a) {
19
- var _b = _a === void 0 ? {} : _a, _c = _b.whitespace, whitespace = _c === void 0 ? true : _c;
20
- if (typeof jsonString !== 'string') {
21
- throw new TypeError("Expected argument `jsonString` to be a `string`, got `".concat(typeof jsonString, "`"));
22
- }
23
- var strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
24
- var isInsideString = false;
25
- var isInsideComment = false;
26
- var offset = 0;
27
- var result = '';
28
- for (var index = 0; index < jsonString.length; index++) {
29
- var currentCharacter = jsonString[index];
30
- var nextCharacter = jsonString[index + 1];
31
- if (!isInsideComment && currentCharacter === '"') {
32
- var escaped = isEscaped(jsonString, index);
33
- if (!escaped) {
34
- isInsideString = !isInsideString;
35
- }
36
- }
37
- if (isInsideString) {
38
- continue;
39
- }
40
- if (!isInsideComment && currentCharacter + nextCharacter === '//') {
41
- result += jsonString.slice(offset, index);
42
- offset = index;
43
- isInsideComment = singleComment;
44
- index++;
45
- }
46
- else if (isInsideComment === singleComment && currentCharacter + nextCharacter === '\r\n') {
47
- index++;
48
- isInsideComment = false;
49
- result += strip(jsonString, offset, index);
50
- offset = index;
51
- continue;
52
- }
53
- else if (isInsideComment === singleComment && currentCharacter === '\n') {
54
- isInsideComment = false;
55
- result += strip(jsonString, offset, index);
56
- offset = index;
57
- }
58
- else if (!isInsideComment && currentCharacter + nextCharacter === '/*') {
59
- result += jsonString.slice(offset, index);
60
- offset = index;
61
- isInsideComment = multiComment;
62
- index++;
63
- continue;
64
- }
65
- else if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
66
- index++;
67
- isInsideComment = false;
68
- result += strip(jsonString, offset, index + 1);
69
- offset = index + 1;
70
- continue;
71
- }
72
- }
73
- return result + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
74
- }
75
- exports.stripJsonComments = stripJsonComments;