@vighnesh153/ftp-server
Advanced tools
Comparing version 0.4.0 to 0.4.1-alpha-01
#!/usr/bin/env node | ||
import { Command } from 'commander'; | ||
import B from 'express'; | ||
import H from 'morgan'; | ||
import i from 'path'; | ||
import L from 'archiver'; | ||
import y from 'chalk'; | ||
import a from 'fs'; | ||
import k from 'ip'; | ||
import G from 'morgan'; | ||
import s from 'path'; | ||
import M from 'archiver'; | ||
import w from 'chalk'; | ||
import l from 'fs'; | ||
import j from 'ip'; | ||
import { fileURLToPath } from 'url'; | ||
var p="__vighnesh153-ftp-client__",d=7878,m=".",f=i.join(p,"index.html");function s(u){return !u}function A(){return i.dirname(fileURLToPath(import.meta.url))}function D(u){return a.existsSync(u)}function E(u){return a.existsSync(u)&&a.lstatSync(u).isDirectory()}function g(u){return s(E(u))?[]:a.readdirSync(u).map(e=>{let r=i.resolve(u,e);return {name:e,type:E(r)?"directory":"file"}})}function C(u){let{directoryPath:t,port:e}=u;return ()=>{console.log(`Directory: ${i.resolve(t)}`),console.log(`Server is listening on port ${e}`),console.log(`On this machine: http://localhost:${e}/`),console.log(`On local network: http://${k.address()}:${e}/`);}}function F(u){let{port:t}=u;return e=>{if(e.code==="EADDRINUSE"){console.log(),console.log(e),console.log(),console.log(y.red(`Port ${t} already in use!`)),console.log("Please try with a different port. eg. --port=4200"),process.exit(1);return}throw e}}function v(){return B.static(A(),{immutable:!0,maxAge:"30000"})}function b(u){return (t,e,r)=>{let o=i.resolve(u,t.path.slice(1));if(D(o)){r();return}e.status(404).json({message:`This path is invalid: ${o}`});}}function O(u){return (t,e)=>{let r=i.resolve(u,`${t.query.path}`.slice(1)),o=i.basename(r),n=L("zip");n.on("end",()=>{console.log(y.green(`${n.pointer()} total bytes`));}),n.on("error",c=>{e.status(500).send({error:c});}),e.attachment(`${o}.zip`),n.pipe(e),n.directory(r,o),n.finalize().then(()=>{console.log(y.yellow("/zip: Configuration complete"));});}}function S(u){return (t,e,r)=>{let o=i.resolve(u,t.path.slice(1));if(s(E(o))){r();return}let c=a.readFileSync(i.resolve(A(),f),{encoding:"utf-8"}).replace("__REPLACEMENT__",JSON.stringify(g(o)));e.send(c);}}function x(){return (u,t)=>{t.status(405).json({message:`Method "${u.method}" is not allowed. Supported method is "GET"`});}}function R(u){return B.static(u,{dotfiles:"allow",setHeaders:t=>{t.setHeader("content-type","application/octet-stream");}})}function T(u){let{port:t,directoryPath:e}=u,r=B();r.use(H("tiny")),r.get(`/${p}*`,v()),r.get("/zip",O(e)),r.get("*",b(e)),r.get("*",S(e)),r.get("*",R(e)),r.use(x()),r.listen(t,C({directoryPath:e,port:t})).on("error",F({directoryPath:e,port:t}));}var l={name:"@vighnesh153/ftp-server",version:"0.4.0-alpha-07",description:"A simple ftp server cli tool for your local files",license:"MIT",type:"module",bin:"./dist/cli.js",private:!1,author:{name:"Vighnesh Raut",url:"https://vighnesh153.com",email:"me@vighnesh153.com"},publishConfig:{access:"public"},repository:{type:"git",url:"git@github.com:vighnesh153/vighnesh153-turbo.git"},scripts:{dev:"echo TODO","dev:backend":"tsup --watch","dev:frontend":"vite",copy:"cpy --cwd=./src/client/dist . ../../../dist/__vighnesh153-ftp-client__/",build:"tsup && vite build && npm run copy"},files:["dist","README.md"],dependencies:{archiver:"^5.3.1",chalk:"^5.2.0",commander:"^10.0.0",ejs:"^3.1.8",express:"^4.18.2",ip:"^2.0.0",morgan:"^1.10.0"},devDependencies:{"@emotion/react":"^11.10.6","@emotion/styled":"^11.10.6","@mui/material":"^5.11.11","@types/archiver":"^5.3.1","@types/express":"^4.17.17","@types/ip":"^1.1.0","@types/morgan":"^1.9.4","@types/node":"*","@types/react":"^18.0.27","@types/react-dom":"^18.0.10","@vighnesh153/tsconfig":"*","@vighnesh153/utils":"*","@vitejs/plugin-react":"^3.1.0","cpy-cli":"^4.2.0","eslint-config-vighnesh153":"*",react:"^18.2.0","react-dom":"^18.2.0",typescript:"^4.9.5",vite:"^4.1.0"},keywords:["ftp","file-transfer-protocol","server","serve","directory","local","localhost","network","vighnesh153","file","transfer","protocol"]};var w=new Command;w.name(l.name).description(l.description).version(l.version).option("-p, --port <port>","port number for the ftp server",`${d}`).option("-d, --directory <path-to-directory>","directory to be served",`${m}`).parse();var Y=w.opts(),{port:q,directory:Z}=Y,J=parseInt(`${q}`,10);T({port:J,directoryPath:Z}); | ||
var p="__vighnesh153-ftp-client__",d=7878,A=".",g=s.join(p,"index.html");function o(e){return !e}function m(){return s.dirname(fileURLToPath(import.meta.url))}function D(e){return l.existsSync(e)}function h(e){return l.existsSync(e)&&l.lstatSync(e).isDirectory()}function C(e){return o(h(e))?[]:l.readdirSync(e).map(t=>{let r=s.resolve(e,t);return {name:t,type:h(r)?"directory":"file"}})}function F(e){let{directoryPath:u,port:t}=e;return ()=>{console.log(`Directory: ${s.resolve(u)}`),console.log(`Server is listening on port ${t}`),console.log(`On this machine: http://localhost:${t}/`),console.log(`On local network: http://${j.address()}:${t}/`);}}function v(e){let{port:u}=e;return t=>{if(t.code==="EADDRINUSE"){console.log(),console.log(t),console.log(),console.log(w.red(`Port ${u} already in use!`)),console.log("Please try with a different port. eg. --port=4200"),process.exit(1);return}throw t}}function b(){return B.static(m(),{immutable:!0,maxAge:"30000"})}function T(e){return (u,t,r)=>{let n=s.resolve(e,u.path.slice(1));if(D(n)){r();return}t.status(404).json({message:`This path is invalid: ${n}`});}}function S(e){return (u,t)=>{let r=s.resolve(e,`${u.query.path}`.slice(1)),n=s.basename(r),i=M("zip");i.on("end",()=>{console.log(w.green(`${i.pointer()} total bytes`));}),i.on("error",E=>{t.status(500).send({error:E});}),t.attachment(`${n}.zip`),i.pipe(t),i.directory(r,n),i.finalize().then(()=>{console.log(w.yellow("/zip: Configuration complete"));});}}function I(e){return (u,t,r)=>{let n=s.resolve(e,u.path.slice(1));if(o(h(n))){r();return}let E=l.readFileSync(s.resolve(m(),g),{encoding:"utf-8"}).replace("__REPLACEMENT__",JSON.stringify(C(n)));t.send(E);}}function O(){return (e,u)=>{u.status(405).json({message:`Method "${e.method}" is not allowed. Supported method is "GET"`});}}function x(e){return B.static(e,{dotfiles:"allow",setHeaders:u=>{u.setHeader("content-type","application/octet-stream");}})}function P(e){let{port:u,directoryPath:t}=e,r=B();r.use(G("tiny")),r.get(`/${p}*`,b()),r.get("/zip",S(t)),r.get("*",T(t)),r.get("*",I(t)),r.get("*",x(t)),r.use(O()),r.listen(u,F({directoryPath:t,port:u})).on("error",v({directoryPath:t,port:u}));}var c={name:"@vighnesh153/ftp-server",version:"0.4.0",description:"A simple ftp server cli tool for your local files",license:"MIT",type:"module",bin:"./dist/cli.js",private:!1,author:{name:"Vighnesh Raut",url:"https://vighnesh153.com",email:"me@vighnesh153.com"},publishConfig:{access:"public"},repository:{type:"git",url:"git@github.com:vighnesh153/vighnesh153-turbo.git"},scripts:{dev:"npm-run-all --parallel dev:*","dev:backend":"tsup --watch","dev:frontend":"vite",copy:"cpy --cwd=./src/client/dist . ../../../dist/__vighnesh153-ftp-client__/",build:"tsup && vite build && npm run copy"},files:["dist","README.md"],dependencies:{archiver:"^5.3.1",chalk:"^5.2.0",commander:"^10.0.0",ejs:"^3.1.9",express:"^4.18.2",ip:"^2.0.0",morgan:"^1.10.0"},devDependencies:{"@emotion/react":"^11.10.6","@emotion/styled":"^11.10.6","@mui/material":"^5.11.15","@types/archiver":"^5.3.2","@types/express":"^4.17.17","@types/ip":"^1.1.0","@types/morgan":"^1.9.4","@types/node":"*","@types/react":"^18.0.31","@types/react-dom":"^18.0.11","@vighnesh153/tsconfig":"*","@vighnesh153/utils":"*","@vitejs/plugin-react":"^3.1.0","cpy-cli":"^4.2.0","eslint-config-vighnesh153":"*","npm-run-all":"^4.1.5",react:"^18.2.0","react-dom":"^18.2.0",typescript:"^5.0.3",vite:"^4.2.1"},keywords:["ftp","file-transfer-protocol","server","serve","directory","local","localhost","network","vighnesh153","file","transfer","protocol"]};var R=new Command;R.name(c.name).description(c.description).version(c.version).option("-p, --port <port>","port number for the ftp server",`${d}`).option("-d, --directory <path-to-directory>","directory to be served",`${A}`).parse();var Z=R.opts(),{port:V,directory:Q}=Z,X=parseInt(`${V}`,10);P({port:X,directoryPath:Q}); |
{ | ||
"name": "@vighnesh153/ftp-server", | ||
"version": "0.4.0", | ||
"version": "0.4.1-alpha-01", | ||
"description": "A simple ftp server cli tool for your local files", | ||
@@ -22,3 +22,3 @@ "license": "MIT", | ||
"scripts": { | ||
"dev": "echo TODO", | ||
"dev": "npm-run-all --parallel dev:*", | ||
"dev:backend": "tsup --watch", | ||
@@ -37,3 +37,3 @@ "dev:frontend": "vite", | ||
"commander": "^10.0.0", | ||
"ejs": "^3.1.8", | ||
"ejs": "^3.1.9", | ||
"express": "^4.18.2", | ||
@@ -46,4 +46,4 @@ "ip": "^2.0.0", | ||
"@emotion/styled": "^11.10.6", | ||
"@mui/material": "^5.11.11", | ||
"@types/archiver": "^5.3.1", | ||
"@mui/material": "^5.11.15", | ||
"@types/archiver": "^5.3.2", | ||
"@types/express": "^4.17.17", | ||
@@ -53,4 +53,4 @@ "@types/ip": "^1.1.0", | ||
"@types/node": "*", | ||
"@types/react": "^18.0.27", | ||
"@types/react-dom": "^18.0.10", | ||
"@types/react": "^18.0.31", | ||
"@types/react-dom": "^18.0.11", | ||
"@vighnesh153/tsconfig": "*", | ||
@@ -61,6 +61,7 @@ "@vighnesh153/utils": "*", | ||
"eslint-config-vighnesh153": "*", | ||
"npm-run-all": "^4.1.5", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"typescript": "^4.9.5", | ||
"vite": "^4.1.0" | ||
"typescript": "^5.0.3", | ||
"vite": "^4.2.1" | ||
}, | ||
@@ -67,0 +68,0 @@ "keywords": [ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
826253
1250
20
2
Updatedejs@^3.1.9