https://github.com/eight04/userscript-meta-cli
  
  
    A CLI build tool for userscript metadata block 
    https://github.com/eight04/userscript-meta-cli
  
cli nodejs userscript userscript-meta userscript-metadata
        Last synced: 3 months ago 
        JSON representation
    
A CLI build tool for userscript metadata block
- Host: GitHub
- URL: https://github.com/eight04/userscript-meta-cli
- Owner: eight04
- License: mit
- Created: 2017-03-20T16:56:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-05T13:35:40.000Z (over 6 years ago)
- Last Synced: 2024-10-01T14:58:13.377Z (about 1 year ago)
- Topics: cli, nodejs, userscript, userscript-meta, userscript-metadata
- Language: JavaScript
- Size: 85.9 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
- License: LICENSE
 
Awesome Lists containing this project
README
          userscript-meta-cli
===================
[](https://travis-ci.org/eight04/userscript-meta-cli)
[](https://codecov.io/gh/eight04/userscript-meta-cli)
[](https://packagephobia.now.sh/result?p=userscript-meta-cli)
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=...] [--update=]
                  [--output=] [--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.
```json
{
	"userscript": {
		"include": ["http://example.com/*", "http://example2.com/*"]
	}
}
```
The metadata defined in `userscript` would overwrite the fields in package.json root.
API
----
### getMeta
```js
const metaObject = getMeta({
  findPackage?: Boolean,
  readFiles?: Array
});
```
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](https://www.npmjs.com/package/userscript-meta).
### parse
The `parse` method of [userscript-meta](https://www.npmjs.com/package/userscript-meta).
Todos
-----
* Integrate [browserslist](https://www.npmjs.com/package/browserslist) with compatible field.
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.