@node-cli/static-server 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/parse.js CHANGED
@@ -2,6 +2,7 @@ import { displayErrorMessages, meowOptionsHelper, meowParserHelper, shallowMerge
2
2
  import { defaults } from "./defaults.js";
3
3
  import fs from "fs-extra";
4
4
  import meow from "meow";
5
+ import path from "node:path";
5
6
  const { helpText , options } = meowOptionsHelper({
6
7
  flags: {
7
8
  cache: {
@@ -73,10 +74,7 @@ const customCfg = cli.flags;
73
74
  if (cli.input.length > 0) {
74
75
  let customPath = cli.input[0];
75
76
  if (fs.pathExistsSync(customPath)) {
76
- if (!customPath.endsWith("/")) {
77
- customPath += "/";
78
- }
79
- customCfg.path = customPath;
77
+ customCfg.path = path.resolve(customPath);
80
78
  } else {
81
79
  displayErrorMessages([
82
80
  `Folder ${customPath} does not exist!`
package/dist/parse.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import {\n\tdisplayErrorMessages,\n\tmeowOptionsHelper,\n\tmeowParserHelper,\n\tshallowMerge,\n} from \"./utilities.js\";\n\nimport { defaults } from \"./defaults.js\";\nimport fs from \"fs-extra\";\nimport meow from \"meow\";\n\nconst { helpText, options } = meowOptionsHelper({\n\tflags: {\n\t\tcache: {\n\t\t\tshortFlag: \"c\",\n\t\t\tdefault: defaults.cache,\n\t\t\tdescription: \"Time in seconds for caching files\",\n\t\t\ttype: \"number\",\n\t\t},\n\t\tcors: {\n\t\t\tshortFlag: \"C\",\n\t\t\tdefault: defaults.cors,\n\t\t\tdescription: \"Set CORS headers to * to allow requests from any origin\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tgzip: {\n\t\t\tshortFlag: \"g\",\n\t\t\tdefault: defaults.gzip,\n\t\t\tdescription: \"Enable GZIP compression\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\thelp: {\n\t\t\tshortFlag: \"h\",\n\t\t\tdescription: \"Display help instructions\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\thttp2: {\n\t\t\tshortFlag: \"H\",\n\t\t\tdefault: defaults.http2,\n\t\t\tdescription: \"Set HTTP to version 2\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tlogs: {\n\t\t\tshortFlag: \"l\",\n\t\t\tdefault: defaults.logs,\n\t\t\tdescription: \"Log HTTP requests at the prompt\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\topen: {\n\t\t\tshortFlag: \"o\",\n\t\t\tdefault: defaults.open,\n\t\t\tdescription: \"Open in your default browser\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tport: {\n\t\t\tshortFlag: \"p\",\n\t\t\tdefault: defaults.port,\n\t\t\tdescription: \"Port to listen on\",\n\t\t\ttype: \"number\",\n\t\t},\n\t\tversion: {\n\t\t\tshortFlag: \"v\",\n\t\t\tdescription: \"Output the current version\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t},\n\tparameters: {\n\t\tpath: {\n\t\t\tdefault: \"current folder\",\n\t\t\tdescription: \"the path to serve files from\",\n\t\t},\n\t},\n\tusage: true,\n});\nconst cli = meow(helpText, options);\nmeowParserHelper({ cli });\n\nconst customCfg = cli.flags;\nif (cli.input.length > 0) {\n\tlet customPath: string = cli.input[0];\n\tif (fs.pathExistsSync(customPath)) {\n\t\tif (!customPath.endsWith(\"/\")) {\n\t\t\tcustomPath += \"/\";\n\t\t}\n\t\tcustomCfg.path = customPath;\n\t} else {\n\t\tdisplayErrorMessages([`Folder ${customPath} does not exist!`]);\n\t}\n}\n\n/**\n * Merging default configuration with the\n * preferences shared by the user.\n */\nconst config: {\n\tcache?: number;\n\tcors?: boolean;\n\thttp2?: boolean;\n\tgzip?: boolean;\n\tlogs?: boolean;\n\topen?: boolean;\n\tpath?: string;\n\tport?: number;\n} = shallowMerge(defaults, customCfg);\n\nexport { config };\n"],"names":["displayErrorMessages","meowOptionsHelper","meowParserHelper","shallowMerge","defaults","fs","meow","helpText","options","flags","cache","shortFlag","default","description","type","cors","gzip","help","http2","logs","open","port","version","parameters","path","usage","cli","customCfg","input","length","customPath","pathExistsSync","endsWith","config"],"mappings":"AAAA,SACCA,oBAAoB,EACpBC,iBAAiB,EACjBC,gBAAgB,EAChBC,YAAY,QACN,iBAAiB;AAExB,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,UAAU,OAAO;AAExB,MAAM,EAAEC,SAAQ,EAAEC,QAAO,EAAE,GAAGP,kBAAkB;IAC/CQ,OAAO;QACNC,OAAO;YACNC,WAAW;YACXC,SAASR,SAASM,KAAK;YACvBG,aAAa;YACbC,MAAM;QACP;QACAC,MAAM;YACLJ,WAAW;YACXC,SAASR,SAASW,IAAI;YACtBF,aAAa;YACbC,MAAM;QACP;QACAE,MAAM;YACLL,WAAW;YACXC,SAASR,SAASY,IAAI;YACtBH,aAAa;YACbC,MAAM;QACP;QACAG,MAAM;YACLN,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;QACAI,OAAO;YACNP,WAAW;YACXC,SAASR,SAASc,KAAK;YACvBL,aAAa;YACbC,MAAM;QACP;QACAK,MAAM;YACLR,WAAW;YACXC,SAASR,SAASe,IAAI;YACtBN,aAAa;YACbC,MAAM;QACP;QACAM,MAAM;YACLT,WAAW;YACXC,SAASR,SAASgB,IAAI;YACtBP,aAAa;YACbC,MAAM;QACP;QACAO,MAAM;YACLV,WAAW;YACXC,SAASR,SAASiB,IAAI;YACtBR,aAAa;YACbC,MAAM;QACP;QACAQ,SAAS;YACRX,WAAW;YACXE,aAAa;YACbC,MAAM;QACP;IACD;IACAS,YAAY;QACXC,MAAM;YACLZ,SAAS;YACTC,aAAa;QACd;IACD;IACAY,OAAO,IAAI;AACZ;AACA,MAAMC,MAAMpB,KAAKC,UAAUC;AAC3BN,iBAAiB;IAAEwB;AAAI;AAEvB,MAAMC,YAAYD,IAAIjB,KAAK;AAC3B,IAAIiB,IAAIE,KAAK,CAACC,MAAM,GAAG,GAAG;IACzB,IAAIC,aAAqBJ,IAAIE,KAAK,CAAC,EAAE;IACrC,IAAIvB,GAAG0B,cAAc,CAACD,aAAa;QAClC,IAAI,CAACA,WAAWE,QAAQ,CAAC,MAAM;YAC9BF,cAAc;QACf,CAAC;QACDH,UAAUH,IAAI,GAAGM;IAClB,OAAO;QACN9B,qBAAqB;YAAC,CAAC,OAAO,EAAE8B,WAAW,gBAAgB,CAAC;SAAC;IAC9D,CAAC;AACF,CAAC;AAED;;;CAGC,GACD,MAAMG,SASF9B,aAAaC,UAAUuB;AAE3B,SAASM,MAAM,GAAG"}
1
+ {"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import {\n\tdisplayErrorMessages,\n\tmeowOptionsHelper,\n\tmeowParserHelper,\n\tshallowMerge,\n} from \"./utilities.js\";\n\nimport { defaults } from \"./defaults.js\";\nimport fs from \"fs-extra\";\nimport meow from \"meow\";\nimport path from \"node:path\";\n\nconst { helpText, options } = meowOptionsHelper({\n\tflags: {\n\t\tcache: {\n\t\t\tshortFlag: \"c\",\n\t\t\tdefault: defaults.cache,\n\t\t\tdescription: \"Time in seconds for caching files\",\n\t\t\ttype: \"number\",\n\t\t},\n\t\tcors: {\n\t\t\tshortFlag: \"C\",\n\t\t\tdefault: defaults.cors,\n\t\t\tdescription: \"Set CORS headers to * to allow requests from any origin\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tgzip: {\n\t\t\tshortFlag: \"g\",\n\t\t\tdefault: defaults.gzip,\n\t\t\tdescription: \"Enable GZIP compression\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\thelp: {\n\t\t\tshortFlag: \"h\",\n\t\t\tdescription: \"Display help instructions\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\thttp2: {\n\t\t\tshortFlag: \"H\",\n\t\t\tdefault: defaults.http2,\n\t\t\tdescription: \"Set HTTP to version 2\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tlogs: {\n\t\t\tshortFlag: \"l\",\n\t\t\tdefault: defaults.logs,\n\t\t\tdescription: \"Log HTTP requests at the prompt\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\topen: {\n\t\t\tshortFlag: \"o\",\n\t\t\tdefault: defaults.open,\n\t\t\tdescription: \"Open in your default browser\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tport: {\n\t\t\tshortFlag: \"p\",\n\t\t\tdefault: defaults.port,\n\t\t\tdescription: \"Port to listen on\",\n\t\t\ttype: \"number\",\n\t\t},\n\t\tversion: {\n\t\t\tshortFlag: \"v\",\n\t\t\tdescription: \"Output the current version\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t},\n\tparameters: {\n\t\tpath: {\n\t\t\tdefault: \"current folder\",\n\t\t\tdescription: \"the path to serve files from\",\n\t\t},\n\t},\n\tusage: true,\n});\nconst cli = meow(helpText, options);\nmeowParserHelper({ cli });\n\nconst customCfg = cli.flags;\nif (cli.input.length > 0) {\n\tlet customPath: string = cli.input[0];\n\tif (fs.pathExistsSync(customPath)) {\n\t\tcustomCfg.path = path.resolve(customPath);\n\t} else {\n\t\tdisplayErrorMessages([`Folder ${customPath} does not exist!`]);\n\t}\n}\n\n/**\n * Merging default configuration with the\n * preferences shared by the user.\n */\nconst config: {\n\tcache?: number;\n\tcors?: boolean;\n\thttp2?: boolean;\n\tgzip?: boolean;\n\tlogs?: boolean;\n\topen?: boolean;\n\tpath?: string;\n\tport?: number;\n} = shallowMerge(defaults, customCfg);\n\nexport { config };\n"],"names":["displayErrorMessages","meowOptionsHelper","meowParserHelper","shallowMerge","defaults","fs","meow","path","helpText","options","flags","cache","shortFlag","default","description","type","cors","gzip","help","http2","logs","open","port","version","parameters","usage","cli","customCfg","input","length","customPath","pathExistsSync","resolve","config"],"mappings":"AAAA,SACCA,oBAAoB,EACpBC,iBAAiB,EACjBC,gBAAgB,EAChBC,YAAY,QACN,iBAAiB;AAExB,SAASC,QAAQ,QAAQ,gBAAg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,CAAC,OAAO,EAAE8B,WAAW,gBAAgB,CAAC;SAAC;IAC9D,CAAC;AACF,CAAC;AAED;;;CAGC,GACD,MAAMG,SASF9B,aAAaC,UAAUuB;AAE3B,SAASM,MAAM,GAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-cli/static-server",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "description": "A simple, zero-configuration, command line HTTP server to serve static files locally",
@@ -19,7 +19,7 @@
19
19
  "@fastify/compress": "6.2.1",
20
20
  "@fastify/cors": "8.2.1",
21
21
  "@fastify/static": "6.10.1",
22
- "@node-cli/logger": "^0.0.7",
22
+ "@node-cli/logger": "^0.0.8",
23
23
  "boxen": "7.1.0",
24
24
  "cli-table3": "0.6.3",
25
25
  "fastify": "4.17.0",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "7642c241f8d85cb6eb05aa8a4f5d7c8a726b4aab"
48
+ "gitHead": "23fe76a185d8ff414348b2867dfddb793c2d3182"
49
49
  }