Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tplant

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tplant - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

5

dist/generateDocumentation.js

@@ -20,6 +20,3 @@ "use strict";

function generateDocumentation(fileNames, options) {
if (options === void 0) { options = {
module: typescript_1.default.ModuleKind.CommonJS,
target: typescript_1.default.ScriptTarget.ES2015
}; }
if (options === void 0) { options = typescript_1.default.getDefaultCompilerOptions(); }
var program = typescript_1.default.createProgram(fileNames, options);

@@ -26,0 +23,0 @@ var checker = program.getTypeChecker();

69

dist/index.js

@@ -8,16 +8,22 @@ #!/usr/bin/env node

var commander_1 = __importDefault(require("commander"));
var fs_1 = require("fs");
var fs_1 = __importDefault(require("fs"));
var glob_1 = __importDefault(require("glob"));
var os_1 = __importDefault(require("os"));
var path_1 = __importDefault(require("path"));
var typescript_1 = __importDefault(require("typescript"));
var convertToPlant_1 = require("./convertToPlant");
var generateDocumentation_1 = require("./generateDocumentation");
commander_1.default
.version('2.1.1')
.version('2.1.2')
.usage('[options]')
.option('-i, --input <path>', 'input file')
.option('-o, --output <path>', 'output file')
.option('-c, --compositions', 'create not heritage compositions')
.option('-I, --only-interfaces', 'only output interfaces')
.option('-i, --input <path>', 'Define the path of the Typescript file')
.option('-o, --output <path>', 'Define the path of the output file. If not defined, it\'ll output on the STDOUT')
.option('-p, --project <path>', 'Compile a project given a valid configuration file.' +
' The argument can be a file path to a valid JSON configuration file,' +
' or a directory path to a directory containing a tsconfig.json file.')
.option('-C, --compositions', 'Create not heritage compositions')
.option('-I, --only-interfaces', 'Only output interfaces')
.parse(process.argv);
if (!commander_1.default.input) {
console.error('missing input file');
console.error('Missing input file');
process.exit(1);

@@ -30,3 +36,4 @@ }

}
var output = convertToPlant_1.convertToPlant(generateDocumentation_1.generateDocumentation(matches), {
var tsConfigFile = findTsConfigFile(commander_1.default.input, commander_1.default.tsconfig);
var output = convertToPlant_1.convertToPlant(generateDocumentation_1.generateDocumentation(matches, getCompilerOptions(tsConfigFile)), {
compositions: commander_1.default.compositions,

@@ -39,3 +46,3 @@ onlyInterfaces: commander_1.default.onlyInterfaces

}
fs_1.writeFile(commander_1.default.output, output, function (errNoException) {
fs_1.default.writeFile(commander_1.default.output, output, function (errNoException) {
if (errNoException !== null) {

@@ -48,1 +55,45 @@ console.error(errNoException);

});
function findTsConfigFile(inputPath, tsConfigPath) {
if (tsConfigPath !== undefined) {
var tsConfigStats = fs_1.default.statSync(tsConfigPath);
if (tsConfigStats.isFile()) {
return tsConfigPath;
}
if (tsConfigStats.isDirectory()) {
var tsConfigFilePath = path_1.default.resolve(tsConfigPath, 'tsconfig.json');
if (fs_1.default.existsSync(tsConfigFilePath)) {
return tsConfigFilePath;
}
}
}
var localTsConfigFile = path_1.default.resolve(path_1.default.dirname(inputPath), 'tsconfig.json');
if (fs_1.default.existsSync(localTsConfigFile)) {
return localTsConfigFile;
}
var cwdTsConfigFile = path_1.default.resolve(process.cwd(), 'tsconfig.json');
if (fs_1.default.existsSync(cwdTsConfigFile)) {
return cwdTsConfigFile;
}
}
function getCompilerOptions(tsConfigFilePath) {
if (tsConfigFilePath === undefined) {
return typescript_1.default.getDefaultCompilerOptions();
}
var reader = function (filePath) { return fs_1.default.readFileSync(filePath, 'utf8'); };
var configFile = typescript_1.default.readConfigFile(tsConfigFilePath, reader);
if (configFile.error !== undefined && configFile.error.category === typescript_1.default.DiagnosticCategory.Error) {
throw new Error("unable to read tsconfig.json file at: " + tsConfigFilePath + ".\n Error: " + typescript_1.default.flattenDiagnosticMessageText(configFile.error.messageText, os_1.default.EOL));
}
else if (configFile.config === undefined) {
throw new Error("unable to read tsconfig.json file at: " + tsConfigFilePath + ".");
}
var convertedCompilerOptions = typescript_1.default.convertCompilerOptionsFromJson(configFile.config.compilerOptions, path_1.default.dirname(tsConfigFilePath));
if (convertedCompilerOptions.errors.length > 0) {
convertedCompilerOptions.errors.forEach(function (error) {
if (error.category === typescript_1.default.DiagnosticCategory.Error) {
throw new Error("unable to read tsconfig.json file at: " + tsConfigFilePath + ".\n Error: " + typescript_1.default.flattenDiagnosticMessageText(error.messageText, os_1.default.EOL));
}
});
}
return convertedCompilerOptions.options;
}
{
"name": "tplant",
"version": "2.1.1",
"version": "2.1.2",
"description": "Typescript to PlantUML",

@@ -5,0 +5,0 @@ "keywords": [

@@ -21,3 +21,7 @@ # tplant

### -c, --compositions
### -p, --project <path>
Compile a project given a valid configuration file.
The argument can be a file path to a valid JSON configuration file, or a directory path to a directory containing a tsconfig.json file.
### -C, --compositions
Create not heritage compositions.

@@ -41,3 +45,3 @@ Example:

}
Car o-- Wheel
Car *-- Wheel
@enduml

@@ -49,2 +53,2 @@ ```

# References
https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API
https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc