{"_id":"@danieltanfh95/sirv-cli","_rev":"1-92b170f2d0172fe9ca4d9e843b60e00b","name":"@danieltanfh95/sirv-cli","dist-tags":{"latest":"1.0.15"},"versions":{"1.0.15":{"name":"@danieltanfh95/sirv-cli","version":"1.0.15","description":"A lightweight CLI program to serve static sites~!","repository":{"type":"git","url":"git+https://github.com/danieltanfh95/sirv.git"},"main":"index.js","license":"MIT","bin":{"sirv":"bin.js"},"author":{"name":"Daniel Tan","email":"danieltanfh95@gmail.com"},"engines":{"node":">= 10"},"dependencies":{"console-clear":"^1.1.0","get-port":"^3.2.0","kleur":"^3.0.0","local-access":"^1.0.1","sade":"^1.6.0","semiver":"^1.0.0","sirv":"^1.0.13","tinydate":"^1.0.0"},"bugs":{"url":"https://github.com/danieltanfh95/sirv/issues"},"homepage":"https://github.com/danieltanfh95/sirv#readme","_id":"@danieltanfh95/sirv-cli@1.0.15","_nodeVersion":"15.3.0","_npmVersion":"7.0.14","dist":{"integrity":"sha512-1REoidMIDfaCDqeh4qyi+yanu3bp/jLM5PxgvJMzKfFtdZ4BgfVMgXEymVnGPH2HEZFp4Ds3e5bSELYu1eIJkQ==","shasum":"84f4ebbb44f92ea669ddcff53150d478c2126f3e","tarball":"https://registry.npmjs.org/@danieltanfh95/sirv-cli/-/sirv-cli-1.0.15.tgz","fileCount":4,"unpackedSize":11927,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhQD4oCRA9TVsSAnZWagAAY8oQAIqyeb8bGAtfjOFDqZQH\nkDwd2eGEtbKBjibwLL9hQp6fqhxDJ9C4WlT7hrE/oz4uvomROnFQGfVZ8VNp\nQD8CqSzWynVL5LDWEse3Bjvk2ozUwq7TuKOrhTYXVquiLERE/hNkGlyxGUTo\ndlYyF6CCo6QmV4I9W5Apt3iXGJ+k5Y6lvX3Iww55b3lcY9Bq/mp9Q2tdPhqh\nhqmRtVvV6RPBplLxJG+ripzw0bmS6sA24/LphgEdL7zEijezluJrIbwRrySl\nGMl+jn4GAf+2vQ2Exfq7XOf7tGYTyl5c1LDOQtLWeRprzeOwMZySCfH1EnTu\nTcbWE/BRlwlVnTuBJqPrDjpaZ42i3nawsxFD31oE3wJuPpGv718a6lsUjZRR\n2qbymBtanczq/HtI/FG2MncUEjrWM/7yuqp7zwyzq1eMEO3RJLn99WwTB9WA\n6kyo6FSiDpwoZhZWMkg5xVkrEf8L9svqmWC9ppVxK3eh2UteLShmZ+D0D8S5\nTbKMqziLdvquEkZ6uzn6I+FTt02G/8m0L4YjOtbmxswuKZAuxMLf5dlujie8\nejCBGIDzhK5SToLQyBCti8vocm8LmY2bBzGtmt3+Fklu7YN/Ct29+ieNBEzl\n97mev8c2LWAzyZzVnKlJNTgNEc5FV7yu+F5ZtOB54aey9pr461q8R9IA9wdZ\nzd08\r\n=LadX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA96mILXSP1Dn/V+wg5y1hIUNv7ufetCC/aranAQ3Q1WAiBhsC6eGi/kAC6vsXBhg3xQPy6lwqCuVnfdwFVhYzt6UA=="}]},"_npmUser":{"name":"danieltanfh95","email":"danieltanfh95@gmail.com"},"directories":{},"maintainers":[{"name":"danieltanfh95","email":"danieltanfh95@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sirv-cli_1.0.15_1631600168355_0.6360606154775492"},"_hasShrinkwrap":false}},"time":{"created":"2021-09-14T06:16:08.289Z","1.0.15":"2021-09-14T06:16:08.542Z","modified":"2022-04-05T02:41:33.247Z"},"maintainers":[{"name":"danieltanfh95","email":"danieltanfh95@gmail.com"}],"description":"A lightweight CLI program to serve static sites~!","homepage":"https://github.com/danieltanfh95/sirv#readme","repository":{"type":"git","url":"git+https://github.com/danieltanfh95/sirv.git"},"author":{"name":"Daniel Tan","email":"danieltanfh95@gmail.com"},"bugs":{"url":"https://github.com/danieltanfh95/sirv/issues"},"license":"MIT","readme":"<div align=\"center\">\n  <img src=\"https://github.com/lukeed/sirv/raw/master/sirv-cli.png\" alt=\"sirv-cli\" width=\"350\" />\n</div>\n\n<h1 align=\"center\">sirv-cli</h1>\n\n<div align=\"center\">\n  <a href=\"https://npmjs.org/package/sirv-cli\">\n    <img src=\"https://img.shields.io/npm/v/sirv-cli.svg\" alt=\"version\" />\n  </a>\n  <a href=\"https://github.com/lukeed/sirv/actions?query=workflow%3ACI+branch%3Anext\">\n    <img src=\"https://github.com/lukeed/sirv/workflows/CI/badge.svg\" alt=\"CI\" />\n  </a>\n  <a href=\"https://npmjs.org/package/sirv-cli\">\n    <img src=\"https://img.shields.io/npm/dm/sirv-cli.svg\" alt=\"downloads\" />\n  </a>\n</div>\n\n<div align=\"center\">A lightweight CLI program to serve static sites~!</div>\n\n<br />\n\nQuickly start a server to preview the assets of _any_ directory!\n\n\n## Install\n\n```\n$ npm install --save sirv-cli\n```\n\n> **Note:** This module can also be installed and used globally~!\n\n## Usage\n\n> **Important:** The `HOST` and `PORT` environment variables will override the `--host` and `--port` flags, respectively.\n\n```\n$ sirv --help\n\n  Description\n    Run a static file server\n\n  Usage\n    $ sirv [dir] [options]\n\n  Options\n    -D, --dev          Enable \"dev\" mode\n    -e, --etag         Enable \"ETag\" header\n    -d, --dotfiles     Enable dotfile asset requests\n    -c, --cors         Enable \"CORS\" headers to allow any origin requestor\n    -G, --gzip         Send precompiled \"*.gz\" files when \"gzip\" is supported  (default true)\n    -B, --brotli       Send precompiled \"*.br\" files when \"brotli\" is supported  (default true)\n    -m, --maxage       Enable \"Cache-Control\" header & define its \"max-age\" value (sec)\n    -i, --immutable    Enable the \"immutable\" directive for \"Cache-Control\" header\n    -k, --http2        Enable the HTTP/2 protocol. Requires Node.js 8.4.0+\n    -C, --cert         Path to certificate file for HTTP/2 server\n    -K, --key          Path to certificate key for HTTP/2 server\n    -P, --pass         Passphrase to decrypt a certificate key\n    -s, --single       Serve as single-page application with \"index.html\" fallback\n    -I, --ignores      Any URL pattern(s) to ignore \"index.html\" assumptions\n    -q, --quiet        Disable logging to terminal\n    -H, --host         Hostname to bind  (default localhost)\n    -p, --port         Port to bind  (default 5000)\n    -v, --version      Displays current version\n    -h, --help         Displays this message\n\n  Examples\n    $ sirv build --cors --port 8080\n    $ sirv public --quiet --etag --maxage 31536000 --immutable\n    $ sirv public --http2 --key priv.pem --cert cert.pem\n    $ sirv public -qeim 31536000\n    $ sirv --port 8080 --etag\n    $ sirv --host --dev\n\n```\n\n## Network Access\n\nFor security reasons, `sirv-cli` **does not** expose your server to the network by default.\nThis means that your machine, _and only your machine_, will be able to access the `localhost` server.\n\nIf, however, your coworker wants to access the server from their computer, or you want to preview your work on a mobile device, you must use the `--host` flag. Only _then_ will your server be accessible to other devices on the same network.\n\nUsing `--host` without a value is equivalent to `--host 0.0.0.0`, which is makes it discoverable publicly. You may customize this by passing a different value – but you probably don't need to!\n\n> **Important:** Only the `Network:` address is accessible to others. The `Local:` address is still private to you.\n\n\n## HTTP/2\n\n> **Note:** Requires Node.js v8.4.0 or later.\n\nThe `--key` and `--cert` flags are required since no browsers support [unencrypted HTTP/2](https://http2.github.io/faq/#does-http2-require-encryption).<br>These must be valid file paths (resolved from `process.cwd()`), which are read and passed into [`http2.createSecureServer`](https://nodejs.org/api/http2.html#http2_http2_createsecureserver_options_onrequesthandler).\n\nYou can generate a certificate and key for local development quickly with:\n\n```sh\n$ openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \\\n  -keyout localhost-key.pem -out localhost-cert.pem\n\n# Now we can run a HTTP/2 server\n$ sirv --http2 --key localhost-key.pem --cert localhost-cert.pem\n```\n\nTo bypass the \"third party verification\" error page, you may use [`mkcert`](https://github.com/FiloSottile/mkcert) to generate a locally-trusted development certificate:\n\n```sh\n$ mkcert -install\n$ mkcert -key-file localhost-key.pem -cert-file localhost-cert.pem localhost 127.0.0.1\n\n# Now we can run a HTTP/2 server with verified SSL\n$ sirv --http2 --key localhost-key.pem --cert localhost-cert.pem\n```\n\n\n## Single Page Applications\n\nYou must pass the `--single` flag to enable single-page application (\"SPA\") mode. This will, for example, serve your directory's `index.html` file when an unknown _path_ (eg; `/foo/bar`) does not resolve to another page.\n\n> **Note:** Please refer to [`opts.single`](https://github.com/lukeed/sirv/tree/master/packages/sirv#optssingle) for the lookup sequence.\n\nAny asset requests (URLs that end with an extension) ignore `--single` behavior and will send a `404` response instead of the \"index.html\" fallback. To ignore additional paths, pass URL patterns to the `--ignores` argument.\n\n```sh\n# Don't include \"/blog*\" or \"/portfolio*\" pages into SPA\n$ sirv public --single --ignores \"^/blog\" --ignores \"^/portfolio\"\n```\n\nYou may pass a string to customize which file should be sent as fallback.<br>In other words, `--single shell.html` will send the directory's `shell.html` file instead of its `index.html` file.\n\n\n## Production\n\nWhen using `sirv-cli` for production file-serving, you should:\n\n1) Ensure `--dev` is not used\n2) Enable HTTP/2 (`--http2`) with valid key and cert\n3) Precompile brotli and/or gzip file variants\n4) Enable `--gzip` and/or `--brotli` flags\n\nFor maximum performance, you should also use `--quiet` to disable the I/O from logging.\n\n> **Notice:**<br>\nWhile `sirv-cli` is certainly \"production ready\", using a CDN in production is always recommended.<br>\nEspecially when performance is a concern, there are much better solutions than using Node.js as a file server.<br>\nMost everything has HTTP/2 and \"SPA\" support nowadays – consider NGINX or [h2o](https://h2o.examp1e.net/).\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","readmeFilename":"readme.md"}