Socket
Socket
Sign inDemoInstall

tsrpc-cli

Package Overview
Dependencies
64
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.0 to 0.4.0

18

index.js

@@ -57,2 +57,3 @@ #!/usr/bin/env node

var tsbuffer_1 = require("tsbuffer");
var ts = __importStar(require("typescript"));
require('node-json-color-stringify');

@@ -131,3 +132,3 @@ var colorJson = function (json) {

return __awaiter(this, void 0, void 0, function () {
var originalCwd, exp, fileList, oldProtoPath, oldProto, services, typeProto, _i, fileList_1, filepath, match, typePath, req, res, msg, encodeIds, _loop_1, _a, encodeIds_1, item, proto, imports_1, apis, msgs, usedNames_1, getAsName_1, addImport, _b, services_1, svc, match, lastName, importPath, op, op, importStr, reqStr, resStr, msgStr, fileContent;
var originalCwd, exp, fileList, oldProtoPath, oldProto, services, typeProto, _i, fileList_1, filepath, match, typePath, src, compileResult, mod, conf, req, res, msg, encodeIds, _loop_1, _a, encodeIds_1, item, proto, imports_1, apis, msgs, usedNames_1, getAsName_1, addImport, _b, services_1, svc, match, lastName, importPath, op, op, importStr, reqStr, resStr, msgStr, fileContent;
return __generator(this, function (_c) {

@@ -186,2 +187,9 @@ switch (_c.label) {

typePath = filepath.replace(/\.ts$/, '');
src = fs.readFileSync(filepath).toString();
compileResult = ts.transpileModule(src, {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2015 }
});
mod = {};
eval("(function(exports){" + compileResult.outputText + "})")(mod);
conf = mod ? mod.conf : undefined;
// Ptl 检测 Req 和 Res 类型齐全

@@ -197,3 +205,4 @@ if (match[2] === 'Ptl') {

req: req,
res: res
res: res,
conf: conf
});

@@ -214,3 +223,4 @@ }

type: 'msg',
msg: msg
msg: msg,
conf: conf
});

@@ -302,3 +312,3 @@ }

msgStr = msgs.map(function (v) { return " " + JSON.stringify(v.name) + ": " + v.msg; }).join(',\n');
fileContent = ("\nimport { ServiceProto } from 'tsrpc-proto';\n" + importStr + "\n\nexport interface ServiceType {\n req: {\n" + reqStr + "\n },\n res: {\n" + resStr + "\n },\n msg: {\n" + msgStr + "\n }\n}\n\nexport const serviceProto: ServiceProto<ServiceType> = " + JSON.stringify(proto, null, 4) + ";\n").trim();
fileContent = ("\nimport { ServiceProto } from 'tsrpc-proto';\nimport { conf } from './test1';\n" + importStr + "\n\nexport interface ServiceType {\n req: {\n" + reqStr + "\n },\n res: {\n" + resStr + "\n },\n msg: {\n" + msgStr + "\n }\n}\n\nexport const serviceProto: ServiceProto<ServiceType> = " + JSON.stringify(proto, null, 4) + ";\n").trim();
process.chdir(originalCwd);

@@ -305,0 +315,0 @@ fs.writeFileSync(output, fileContent);

{
"name": "tsrpc-cli",
"version": "0.3.0",
"version": "0.4.0",
"description": "TSRPC CLI Tools",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc