Giter Site home page Giter Site logo

userscript-meta-cli's Introduction

userscript-meta-cli

Build Status codecov install size

A CLI build tool for userscript metadata block

Features

  • Build metadata block with information inside package.json.
  • Merge multiple metadata files.
  • Update metablock inside userscripts.

Install

npm install -D userscript-meta-cli

Usage

usage:
  userscript-meta [--no-package] [--read=<file>...] [--update=<file>]
                  [--output=<file>] [--json]
  
options:
  -n --no-package Don't extract data from package.json
  
  -r --read       Read metadata from files. Support json or any text file
                  containing userscript metadata block.
				  
  -u --update     Update the metadata block in the file, instead of writing to
                  output.
				  
  -o --output     Write output meta block to file. If not provided, writing to
                  stdout.
				  
  --json          Output json format.
				  
  -v --version    Print version number.
  -h --help       Print help screen.

Reconized fields in package.json

  • name
  • title - an alias of name
  • version
  • description
  • homepage - homepageURL
  • bugs - supportURL
  • license
  • author
  • contributors - contributor
  • repository - if homepage is missing and repository is provided, it will try to guess homepageURL according to this field.
  • engines - compatible

Other fields like include, exclude, etc, could be set in userscript field.

{
	"userscript": {
		"include": ["http://example.com/*", "http://example2.com/*"]
	}
}

The metadata defined in userscript would overwrite the fields in package.json root.

API

getMeta

const metaObject = getMeta({
  findPackage?: Boolean,
  readFiles?: Array<String>
});

If findPackage is true then extract metadata from package.json. Default: true.

readFiles is an array of filenames.

stringify

The stringify method of userscript-meta.

parse

The parse method of userscript-meta.

Todos

Changelog

  • 0.4.2 (Aug 5, 2018)

    • Fix: missing cli.
  • 0.4.1 (Aug 5, 2018)

    • Fix: missing files in package.json.
  • 0.4.0 (Aug 5, 2018)

    • Add: getMeta API.
    • Add: Node dependency node>=7.
  • 0.3.0 (Mar 16, 2018)

    • Add: @include * when there is no include/match rule is found.
    • Add: a better way to find package.json. Now the tool would read package.json file from the parent/ancestor folder.
  • 0.2.0 (Jul 29, 2017)

    • Add: generate supportURL from repository.
    • Add: warning message to --update help screen.
    • Fix: new line issue with --update.
    • Fix: doesn't work under linux due to CRLF issue.
  • 0.1.0 (Mar 19, 2017)

    • First release.

userscript-meta-cli's People

Contributors

eight04 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

jeniex

userscript-meta-cli's Issues

Failed to --read json file from parent directory

D:\Dev\textarea-plus\src>userscript-meta
module.js:559
    throw err;
    ^

Error: Cannot find module 'D:\Dev\textarea-plus\src/package.json'
    at Function.Module._resolveFilename (module.js:557:15)
    at Function.Module._load (module.js:484:25)
    at Module.require (module.js:606:17)
    at require (internal/module.js:11:18)
    at packageToMeta (D:\Dev\userscript-meta-builder\index.js:1:92)
    at Object.<anonymous> (D:\Dev\userscript-meta-builder\cli.js:36:22)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)

D:\Dev\textarea-plus\src>userscript-meta -n
// ==UserScript==
// @grant none
// ==/UserScript==

D:\Dev\textarea-plus\src>userscript-meta -n -r ../package.json
module.js:559
    throw err;
    ^

Error: Cannot find module '../package.json'
    at Function.Module._resolveFilename (module.js:557:15)
    at Function.Module._load (module.js:484:25)
    at Module.require (module.js:606:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\Dev\userscript-meta-builder\cli.js:41:24)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)
    at Function.Module._load (module.js:507:3)

Failed to run the tool inside the subdirectory

D:\Dev\textarea-plus\src>userscript-meta
module.js:559
    throw err;
    ^

Error: Cannot find module 'D:\Dev\textarea-plus\src/package.json'
    at Function.Module._resolveFilename (module.js:557:15)
    at Function.Module._load (module.js:484:25)
    at Module.require (module.js:606:17)
    at require (internal/module.js:11:18)
    at packageToMeta (D:\Dev\userscript-meta-builder\index.js:1:92)
    at Object.<anonymous> (D:\Dev\userscript-meta-builder\cli.js:36:22)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)

Need a better way to lookup package.json.

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.