Skip to content

Commit

Permalink
Align core plugin setup, add test, run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
webketje committed Dec 21, 2021
1 parent 328c911 commit 29b03ff
Show file tree
Hide file tree
Showing 36 changed files with 5,900 additions and 263 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

25 changes: 0 additions & 25 deletions .eslintrc

This file was deleted.

8 changes: 8 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
env:
node: true
es6: true
extends:
- 'eslint:recommended'
- 'prettier'
parserOptions:
ecmaVersion: 2017
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Automatically normalize line endings for all text-based files
# http://git-scm.com/docs/gitattributes#_end_of_line_conversion
* text=auto eol=lf

# For binary file types, prevent converting CRLF chars
*.jpg -text
*.png -text
27 changes: 0 additions & 27 deletions .github/workflows/test.yml

This file was deleted.

41 changes: 5 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
# Logs
logs
*.log
npm-debug.log*
.nyc_output

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
build

# Dependency directory
node_modules
package-lock.json

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# ESLint Cache
*.tgz
.eslintcache
.nyc_output
coverage.info
test/fixtures/*/build
node_modules
6 changes: 3 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package-lock.json
package.json
test/**/*.md
test/fixtures/**
.nyc_output/**
package-lock.json
3 changes: 0 additions & 3 deletions .prettierrc

This file was deleted.

7 changes: 7 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
trailingComma: none
tabWidth: 2
semi: false
singleQuote: true
bracketSpacing: true
arrowParens: always
printWidth: 120
24 changes: 24 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"hooks": {
"before:init": ["npm run lint", "npm test"],
"after:bump": "auto-changelog -p --starting-date 2021-07-17 --commit-limit false --ignore-commit-pattern '^((dev|chore|ci):|Release|skip changelog)'",
"after:npm:bump": "npm pack",
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
},
"git": {
"commitMessage": "Release ${version}",
"commitArgs": ["-S"],
"tagAnnotation": "Release ${version}",
"tagArgs": ["-s"],
"changelog": "auto-changelog -u --starting-date 2021-07-17 --commit-limit false --ignore-commit-pattern '^((dev|chore|ci):|Release|skip changelog)' --stdout -t https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs"
},
"npm": {
"publish": false
},
"github": {
"release": true,
"releaseName": "@metalsmith/drafts ${version}",
"tokenRef": "GITHUB_TOKEN",
"assets": ["metalsmith-drafts-${version}.tgz"]
}
}
43 changes: 43 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
language: node_js
dist: xenial

node_js:
- 8
- 12
- 14
- 16

os:
- linux

stages:
- lint
- test_windows
- test
- codecov

jobs:
include:
- stage: lint
name: ESlint
node_js: node
os: linux
script: npm run lint
- stage: test_windows
name: Oldest supported version on Windows
node_js: 8
os: windows
- stage: codecov
name: Coveralls
node_js: node
os: linux
script: npm run test && npm run coveralls

script: npm run test

notifications:
email: false
webhooks:
urls:
- https://webhooks.gitter.im/e/de552aa9082bfddb180d
on_cancel: never
11 changes: 9 additions & 2 deletions History.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Latest
### Changelog

Check for [unreleased][] changes.
All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [Unreleased](https://github.com/metalsmith/drafts/compare/v1.1.0...HEAD)

- Align core plugin setup, add test, run prettier [`303ab60`](https://github.com/metalsmith/drafts/commit/303ab6002e930a3b2d549c8a0e152b7eeb24a900)

<!-- auto-changelog-above -->
## [1.1.0][] - 2021-07-13

- Finalize move to @metalsmith/drafts
Expand Down
4 changes: 3 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
MIT License

Copyright (c) 2014 Metalsmith

Copyright (c) 2021 webketje
Copyright (c) 2014-2021 Segment

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# @metalsmith/drafts

A metalsmith plugin to hide drafts.

[![metalsmith: core plugin][metalsmith-badge]][metalsmith-url]
[![npm: version][npm-badge]][npm-url]
[![ci: build][ci-badge]][ci-url]
[![code coverage][codecov-badge]][codecov-url]
[![license: MIT][license-badge]][license-url]

## Installation

NPM:

```bash
npm install @metalsmith/drafts
```

Yarn:

```bash
yarn add @metalsmith/drafts
```

## Usage

Pass the plugin with any options to `Metalsmith.use`.

```js
const drafts = require('@metalsmith/drafts')

metalsmith.use(drafts())
metalsmith.use(drafts({ default: false })) // same as default
```

Add `draft: true` to your files' YAML front-matter to mark them as drafts:

```yaml
---
title: My post
draft: true
---
```

### Default value for `draft`

You can instruct `@metalsmith/drafts` to mark files as `draft` by default if they don't have a `draft` property in their front-matter:

```js
const drafts = require('@metalsmith/drafts')

metalsmith.use(
drafts({
default: true
})
)
```

### CLI Usage

To use this plugin with the Metalsmith CLI, add `@metalsmith/drafts` to the `plugins` key in your `metalsmith.json` file:

```json
{
"plugins": [
{
"@metalsmith/drafts": {
"default": false
}
}
]
}
```

## License

[MIT](LICENSE)

[npm-badge]: https://img.shields.io/npm/v/@metalsmith/drafts.svg
[npm-url]: https://www.npmjs.com/package/@metalsmith/drafts
[ci-badge]: https://app.travis-ci.com/metalsmith/drafts.svg?branch=master
[ci-url]: https://app.travis-ci.com/github/metalsmith/drafts
[metalsmith-badge]: https://img.shields.io/badge/metalsmith-core_plugin-green.svg?longCache=true
[metalsmith-url]: http://metalsmith.io
[codecov-badge]: https://img.shields.io/coveralls/github/metalsmith/drafts
[codecov-url]: https://coveralls.io/github/metalsmith/drafts
[license-badge]: https://img.shields.io/github/license/metalsmith/drafts
[license-url]: LICENSE
Loading

0 comments on commit 29b03ff

Please sign in to comment.