Giter Club home page Giter Club logo

appcache-manifest's Introduction

appcache-manifest

npm version Downloads/month Build Status Coverage Status Dependency Status

A CLI tool to generate HTML5 Application Cache Manifest.

  • appcache-manifest command generates the manifest file of given files.
    • The manifest file includes the md5 hash which is calculated from the content of the files.
    • You can regenerate the manifest file when the files are changed by --watch option.

๐Ÿ’ฟ Installation

$ npm install appcache-manifest
  • Requires Node.js 4 or later.

๐Ÿ“– Usage

This provides 2 commands; appcache-manifest and appcache-manifest-fixer.

  • appcache-manifest is the command to generate manifest files.
  • appcache-manifest-fixer is the command to add manifest attribute into a HTML file.
Usage: appcache-manifest [OPTIONS] [FILES...]

    FILES: File globs that includes into manifest.

Options:
    -o, --output <FILE_PATH>    The path of an output file.
                                Prints to stdout by default.
    -p, --prefix <PATH>         The prefix part of each path in cache section.
    -P, --postfile <FILE_PATH>  The path of a postfix file.  The file will be
                                concatinated after generated contents.
    -h, --help                  Prints this text.
    -v, --verbose               Prints detail messages in progress. This option
                                must be used together with '--output' option.
    -V, --version               Prints version number.
    -w, --watch                 This command would be watching target files and
                                directories if --watch option is specified.
                                Then it regenerates the manifest file when those
                                files are added, removed, or changed.
    --network-star              Adds "NETWORK:\n*" after generated contents.
    --stamp                     Stamps the output with the date/time instead
                                of an md5 hash.
Usage: appcache-manifest-fixer [FILE_PATH] [OPTIONS]

    This command would add "manifest" attribute into <html> tag.

    FILE_PATH: The target HTML file path.
               Reading from stdin by default

Options:
    -o, --output <FILE_PATH>  The path of an output file.
                              Writing to stdout by default.
    -h, --help                Prints this text.
    -m, --manifest <PATH>     The path of a manifest file. The path will be set
                              to the value of "manifest" attribute.
                              "index.appcache" by default.
    -v, --version             Prints version number.

Examples

appcache-manifest "app/index.{html,css,js}" "app/lib/**/*.{css,js}" --network-star -o app/index.appcache
appcache-manifest "app/**/*.{html,css,js}" --postfile src/api.txt --postfile src/fallback.txt -o app/index.appcache

๐Ÿข Node.js API

var am = require("appcache-manifest");

am.generate(fileGlobs, options)

Generate a manifest file content; path list and a md5 hash comment.

  • fileGlobs string|string[] -- Globs that includes into CACHE section of the manifest.
  • options object
    • options.prefix string -- The prefix part of each path in cache section.
    • options.postfile string|string[] -- Paths of a postfix file. The file will be concatinated after generated contents.
    • options.networkStar boolean -- A flag to add "NETWORK:\n*" after generated contents.
    • options.stamp boolean -- Stamps the output with the date/time instead of an md5 hash.

This function returns stream.Readable. The stream outputs generated contents.

am.createFixer(options)

Add a "manifest" attribute into <html> tag.

  • options object
    • options.manifest string -- A path to a manifest file. By default, "index.appcache".

This function returns stream.Transform. The stream detect <html> tag from inputs, and add a manifest attribute.

๐Ÿ“ฐ Changelog

๐Ÿ’ช Contributing

Welcome contributing!

Please use GitHub's Issues/PRs.

Development Tools

  • npm test runs tests and measures coverage.
  • npm run coverage shows the coverage result of npm test command with the default browser.
  • npm run clean removes the coverage result of npm test command.
  • npm run lint runs ESLint.
  • npm run watch runs tests with --watch option.

appcache-manifest's People

Contributors

mysticatea avatar virtualpatterns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

virtualpatterns

appcache-manifest's Issues

Never Exits

appcache-manifest-fixer never exits when the output file is specified.

Fixer cannot overwrite source file

The appcache-manifest-fixer cannot overwrite the source file. If you attempt to do it, the source file will be empty afterwards.

I call the appcache-manifest-fixer like this:

appcache-manifest-fixer index.html -o index.html

Instead of adding the manifest-attribute, index.html is now completely empty.

Getting error mesage

bash-3.2$ appcache-manifest './dist/**.{png,svg,jpg,js,html,css,json,woff,ttf,woff2,eot}' -o ./index.appcache
/Users/jkarttunen/.nvm/versions/node/v4.2.3/bin/appcache-manifest: line 1: use strict: command not found
/Users/jkarttunen/.nvm/versions/node/v4.2.3/bin/appcache-manifest: line 3: syntax error near unexpected token `exports,'
/Users/jkarttunen/.nvm/versions/node/v4.2.3/bin/appcache-manifest: line 3: `Object.defineProperty(exports, "__esModule", {'

Add a method using a Readable Stream interface

When using the library inside a bundler or workflow plugin, the bundler might have its own representation of the files that should be put into the appcache manifest. Example: parcel bundler.
For these us cases it would be nice to have a method that receives stream interfaces instead of string globs.

Prefix doesn't have to start with '/'

I wan't my paths in the manifest to be relative. They should start with './' or nothing at all. However, I can't do this since the default is '/' and passing any other value than that doesn't work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.