Comparing version 0.14.0 to 0.14.1
@@ -1,3 +0,4 @@ | ||
declare const _default: (target: string, indent: string, importName: string, newUrl: string, trailingSlash: boolean) => string; | ||
import { InterfaceDeclaration } from 'ts-morph'; | ||
declare const _default: (methodsInterface: InterfaceDeclaration, indent: string, importName: string, newUrl: string, trailingSlash: boolean) => string; | ||
export default _default; | ||
//# sourceMappingURL=createMethodsString.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ts_morph_1 = require("ts-morph"); | ||
var typescript_1 = require("typescript"); | ||
exports.default = (function (target, indent, importName, newUrl, trailingSlash) { | ||
var source = new ts_morph_1.Project().addSourceFileAtPath(target); | ||
var chanks = []; | ||
var methodsInterface = source.getInterface('Methods'); | ||
if (!methodsInterface) | ||
return ''; | ||
methodsInterface.getProperties().forEach(function (method) { | ||
exports.default = (function (methodsInterface, indent, importName, newUrl, trailingSlash) { | ||
return methodsInterface | ||
.getProperties() | ||
.map(function (method) { | ||
var methodName = method.getName(); | ||
@@ -68,6 +64,6 @@ var typeInfo = {}; | ||
]; | ||
chanks.push(indent + " " + methodName + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ",\n" + indent + " $" + methodName + ": async " + tmpChanks[0] + "\n" + indent + " (await " + tmpChanks[1] + ").data"); | ||
}); | ||
return chanks.join(',\n'); | ||
return indent + " " + methodName + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ",\n" + indent + " $" + methodName + ": async " + tmpChanks[0] + "\n" + indent + " (await " + tmpChanks[1] + ").data"; | ||
}) | ||
.join(',\n'); | ||
}); | ||
//# sourceMappingURL=createMethodsString.js.map |
@@ -24,17 +24,25 @@ "use strict"; | ||
var path_1 = __importDefault(require("path")); | ||
var ts_morph_1 = require("ts-morph"); | ||
var createMethodsString_1 = __importDefault(require("./createMethodsString")); | ||
exports.default = (function (input, trailingSlash) { | ||
var project = new ts_morph_1.Project(); | ||
project.addSourceFilesAtPaths(input.replace(/\/$/, '') + "/**/*.ts"); | ||
project.resolveSourceFileDependencies(); | ||
var imports = []; | ||
var getMethodsString = function (file, target, indent, newUrl) { | ||
var _a; | ||
var methodsInterface = (_a = project.getSourceFile(target)) === null || _a === void 0 ? void 0 : _a.getInterface('Methods'); | ||
if (!methodsInterface) | ||
return ''; | ||
var importName = "Methods" + imports.length; | ||
imports.push("import { Methods as " + importName + " } from '" + file + "'"); | ||
return createMethodsString_1.default(target, indent, importName, newUrl, trailingSlash); | ||
return createMethodsString_1.default(methodsInterface, indent, importName, newUrl, trailingSlash); | ||
}; | ||
var valCount = 0; | ||
var createApiString = function (targetDir, importBasePath, indent, url, text, methodsOfIndexTsFile) { | ||
var props = []; | ||
indent += ' '; | ||
fs_1.default.readdirSync(targetDir) | ||
var props = fs_1.default | ||
.readdirSync(targetDir) | ||
.sort() | ||
.forEach(function (file, _, dirList) { | ||
.map(function (file, _, dirList) { | ||
if (file.startsWith('$') || file.startsWith('@')) | ||
@@ -59,7 +67,7 @@ return; | ||
var indexPath = path_1.default.posix.join(target, 'index.ts'); | ||
props.push(createApiString(target, importBasePath + "/" + file, indent, newUrl, valFn.replace('<% next %>', '<% props %>'), dirList.includes(file + ".ts") | ||
return createApiString(target, importBasePath + "/" + file, indent, newUrl, valFn.replace('<% next %>', '<% props %>'), dirList.includes(file + ".ts") | ||
? getMethodsString(importBasePath + "/" + file, target + ".ts", indent, newUrl) | ||
: fs_1.default.existsSync(indexPath) | ||
? getMethodsString(importBasePath + "/" + file + "/index", indexPath, indent, newUrl) | ||
: undefined)); | ||
: undefined); | ||
} | ||
@@ -69,5 +77,6 @@ else if (path_1.default.extname(file) === '.ts' && | ||
!dirList.includes(basename)) { | ||
props.push(valFn.replace('<% next %>', getMethodsString(importBasePath + "/" + basename, target, indent, newUrl))); | ||
return valFn.replace('<% next %>', getMethodsString(importBasePath + "/" + basename, target, indent, newUrl)); | ||
} | ||
}); | ||
}) | ||
.filter(function (p) { return !!p; }); | ||
return text.replace('<% props %>', "" + props.join(',\n') + (methodsOfIndexTsFile ? "" + (props.length ? ',\n' : '') + methodsOfIndexTsFile : '')); | ||
@@ -74,0 +83,0 @@ }; |
{ | ||
"name": "aspida", | ||
"version": "0.14.0", | ||
"version": "0.14.1", | ||
"description": "TypeScript friendly HTTP client wrapper for the browser and node.js", | ||
@@ -5,0 +5,0 @@ "author": "m-mitsuhide <m.mitsuhide@amatelus.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51553
542