New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

converter-toless-plugin

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

converter-toless-plugin - npm Package Compare versions

Comparing version 0.0.45 to 0.0.51

1

lib/components/utils.d.ts

@@ -7,3 +7,4 @@ import type { Compiler } from "../../d/types";

export declare function deleteFile(filePath: string): void;
export declare function deleteDirectory(dirPath: string): Promise<unknown>;
export declare function deleteAllFilesInDirectory(dir: string): void;
export declare function getNameOf(arry: Compiler[], name: string): number;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNameOf = exports.deleteAllFilesInDirectory = exports.deleteFile = exports.getProps = void 0;
exports.getNameOf = exports.deleteAllFilesInDirectory = exports.deleteDirectory = exports.deleteFile = exports.getProps = void 0;
const path = require("path");

@@ -23,2 +23,8 @@ const fs = require("fs");

exports.deleteFile = deleteFile;
function deleteDirectory(dirPath) {
return new Promise((solve) => {
fs.rmdir(dirPath, { recursive: true }, solve);
});
}
exports.deleteDirectory = deleteDirectory;
function deleteAllFilesInDirectory(dir) {

@@ -25,0 +31,0 @@ fs.readdir(dir, (err, files) => {

@@ -33,4 +33,8 @@ import { Compiler, converterOptions, Dirs, Router } from "../d/types";

* @const {compilerCommand}
*
* #{CompeleteInputFilePath} is the path + filename +.+ fileType
* #{CompeleteOutputFilePath} is the outputdirectory + filename +.+ filetype
* #{CompeleteOutputFilePath} is the outputdirectory + filename +.+
* #{CompeleteOutputDirectory} is the output directory
*
* filetype
* #{ComepeleteFileName} is the file name with type

@@ -45,2 +49,3 @@ * #{name} is the file name without type

compileFile(FileNameWT: string, compileIndex: number): Promise<unknown>;
zipTheOutputDirectory(name: string): Promise<unknown>;
/** this function download the file to the server **DEPRICATED** */

@@ -47,0 +52,0 @@ uploadTheFile(file: any, uploadpath: string): Promise<unknown>;

@@ -17,2 +17,4 @@ "use strict";

const multer_config_js_1 = require("./config/multer.config.js");
// for archiving
const archiver = require("archive");
const defaultProps = {

@@ -145,2 +147,3 @@ PORT: 3000,

const uploadpath = Path.join(this.inputdir, nameWT);
const outputDirPath = Path.join(this.outputdir, name);
const downloadpath = Path.join(this.outputdir, newnameWT);

@@ -153,2 +156,6 @@ const URLFILE = `/files/${newnameWT}`;

await utils_js_1.deleteFile(uploadpath);
// zip the output folder
await this.zipTheOutputDirectory(name);
// delete the the output folder
await utils_js_1.deleteDirectory(outputDirPath);
// making url for the file

@@ -187,4 +194,8 @@ await this.makeGetReqForTheFile(URLFILE, downloadpath);

* @const {compilerCommand}
*
* #{CompeleteInputFilePath} is the path + filename +.+ fileType
* #{CompeleteOutputFilePath} is the outputdirectory + filename +.+ filetype
* #{CompeleteOutputFilePath} is the outputdirectory + filename +.+
* #{CompeleteOutputDirectory} is the output directory
*
* filetype
* #{ComepeleteFileName} is the file name with type

@@ -199,4 +210,4 @@ * #{name} is the file name without type

const path = this.inputdir;
const pathtoOutput = this.outputdir;
const name = utils_js_1.getProps(FileNameWT).name;
const pathtoOutput = Path.join(this.outputdir, name);
const path_name_type = `${Path.join(path, FileNameWT)}`;

@@ -208,2 +219,3 @@ const opath_name_type = `${Path.join(pathtoOutput, name)}.${compiler.outputT}`;

compilerCommand = compilerCommand.replace(/#{CompeleteOutputFilePath}/gi, opath_name_type);
compilerCommand = compilerCommand.replace(/#{CompeleteOutputDirectory}/gi, pathtoOutput);
compilerCommand = compilerCommand.replace(/#{ComepeleteFileName}/gi, FileNameWT);

@@ -222,2 +234,17 @@ compilerCommand = compilerCommand.replace(/#{outputT}/gi, compiler.outputT);

}
async zipTheOutputDirectory(name) {
return new Promise((solve, reject) => {
// input directory
const output_dir = path_1.join(this.outputdir, name);
// output file
const output = fs.createWriteStream(`${output_dir}.zip`);
// ziping technic
const archive = archiver('zip');
archive.pipe(output);
archive.directory(output_dir, false);
output.on('close', solve);
archive.on('error', reject);
archive.finalize();
});
}
/** this function download the file to the server **DEPRICATED** */

@@ -224,0 +251,0 @@ uploadTheFile(file, uploadpath) {

7

package.json
{
"name": "converter-toless-plugin",
"version": "0.0.45",
"version": "0.0.51",
"description": "this is a plugin",

@@ -22,2 +22,3 @@ "main": "./lib/index.js",

"@types/randomstring": "^1.1.6",
"@types/rimraf": "^3.0.0",
"typescript": "^4.1.3"

@@ -27,2 +28,3 @@ },

"app-root-path": "^3.0.0",
"archive": "0.0.2",
"child_process": "^1.0.2",

@@ -32,3 +34,4 @@ "express": "^4.17.1",

"multer": "^1.4.2",
"randomstring": "^1.1.5"
"randomstring": "^1.1.5",
"rimraf": "^3.0.2"
},

@@ -35,0 +38,0 @@ "publishConfig": {

@@ -5,6 +5,8 @@ import * as path from "path"

import type { Compiler } from "../../d/types"
import { Request } from "express";
export function getProps(name: string) {

@@ -27,2 +29,10 @@ const n = name.split(".");

export function deleteDirectory(dirPath: string) {
return new Promise((solve) => {
fs.rmdir(dirPath, { recursive: true }, solve)
})
}
export function deleteAllFilesInDirectory(dir: string) {

@@ -29,0 +39,0 @@ fs.readdir(dir, (err, files) => {

@@ -20,3 +20,3 @@ // for running commands

// for utils
import { getNameOf, getProps, deleteFile, deleteAllFilesInDirectory } from "./components/utils.js";
import { getNameOf, getProps, deleteFile, deleteAllFilesInDirectory, deleteDirectory } from "./components/utils.js";

@@ -32,3 +32,7 @@ // for filtering names

// for archiving
const archiver = require("archive")
const defaultProps = {

@@ -232,2 +236,3 @@ PORT: 3000,

const uploadpath: string = Path.join(this.inputdir, nameWT);
const outputDirPath: string = Path.join(this.outputdir, name);
const downloadpath: string = Path.join(this.outputdir, newnameWT);

@@ -245,2 +250,8 @@ const URLFILE = `/files/${newnameWT}`;

// zip the output folder
await this.zipTheOutputDirectory(name)
// delete the the output folder
await deleteDirectory(outputDirPath);
// making url for the file

@@ -282,4 +293,8 @@ await this.makeGetReqForTheFile(URLFILE, downloadpath);

* @const {compilerCommand}
*
* #{CompeleteInputFilePath} is the path + filename +.+ fileType
* #{CompeleteOutputFilePath} is the outputdirectory + filename +.+ filetype
* #{CompeleteOutputFilePath} is the outputdirectory + filename +.+
* #{CompeleteOutputDirectory} is the output directory
*
* filetype
* #{ComepeleteFileName} is the file name with type

@@ -292,15 +307,35 @@ * #{name} is the file name without type

Command(FileNameWT: string, compilerIndex: number): string {
const compiler = this.compilers[compilerIndex];
const path = this.inputdir;
const pathtoOutput = this.outputdir;
const name = getProps(FileNameWT).name
const name = getProps(FileNameWT).name;
const pathtoOutput = Path.join(this.outputdir, name);
const path_name_type = `${Path.join(path, FileNameWT)}`
const opath_name_type = `${Path.join(pathtoOutput, name)}.${compiler.outputT}`;
// commands are at top
let compilerCommand = compiler.command.replace(/#{iPath}/gi, pathtoOutput)//.replace("#{Ipath}", path)
compilerCommand = compilerCommand.replace(/#{CompeleteInputFilePath}/gi, path_name_type)
compilerCommand = compilerCommand.replace(/#{CompeleteOutputFilePath}/gi, opath_name_type)
compilerCommand = compilerCommand.replace(/#{CompeleteOutputDirectory}/gi, pathtoOutput)
compilerCommand = compilerCommand.replace(/#{ComepeleteFileName}/gi, FileNameWT)
compilerCommand = compilerCommand.replace(/#{outputT}/gi, compiler.outputT)
compilerCommand = compilerCommand.replace(/#{name}/gi, name)
compilerCommand = compilerCommand.replace(/#{oPath}/gi, pathtoOutput)

@@ -310,2 +345,3 @@ return compilerCommand

/** this function compiles a file*/

@@ -322,2 +358,26 @@ compileFile(FileNameWT: string, compileIndex: number) {

async zipTheOutputDirectory(name: string) {
return new Promise((solve, reject) => {
// input directory
const output_dir = join(this.outputdir, name)
// output file
const output = fs.createWriteStream(`${output_dir}.zip`);
// ziping technic
const archive = archiver('zip');
archive.pipe(output);
archive.directory(output_dir, false);
output.on('close', solve);
archive.on('error', reject);
archive.finalize();
})
}
/** this function download the file to the server **DEPRICATED** */

@@ -324,0 +384,0 @@ uploadTheFile(file: any, uploadpath: string) {

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