Skip to content

Commit

Permalink
chore: npm-compatible placeholder name, readme instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
webketje committed Jan 15, 2022
1 parent e531d7e commit d56163e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
4 changes: 2 additions & 2 deletions release-it.json → .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
},
"github": {
"release": true,
"releaseName": "@metalsmith/%core-plugin% ${version}",
"releaseName": "@metalsmith/~core-plugin~ ${version}",
"tokenRef": "GITHUB_TOKEN",
"assets": ["metalsmith-%core-plugin%-${version}.tgz"]
"assets": ["metalsmith-~core-plugin~-${version}.tgz"]
}
}
47 changes: 27 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# @metalsmith/%core-plugin%
---
Note: This is a template repository
Usage:
- step1: Click "Use this template", see also https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template, fill in new plugin details
- step2: Search and replace all `core-plugin` `CorePlugin` and `corePlugin` matches with the name of the plugin
- step3: Delete the front-matter in this file
---
# @metalsmith/~core-plugin~

A metalsmith core plugin boilerplate
A metalsmith plugin to...

[![metalsmith: core plugin][metalsmith-badge]][metalsmith-url]
[![npm: version][npm-badge]][npm-url]
Expand All @@ -14,22 +21,22 @@ A metalsmith core plugin boilerplate

NPM:
```
npm install @metalsmith/%core-plugin%
npm install @metalsmith/~core-plugin~
```
Yarn:
```
yarn add @metalsmith/%core-plugin%
yarn add @metalsmith/~core-plugin~
```

## Usage

Pass `@metalsmith/%core-plugin%` to `metalsmith.use` :
Pass `@metalsmith/~core-plugin~` to `metalsmith.use` :

```js
const %corePlugin% = require('@metalsmith/%core-plugin%')
const ~corePlugin~ = require('@metalsmith/~core-plugin~')

metalsmith.use(corePlugin()) // defaults
metalsmith.use(corePlugin({ // explicit defaults
metalsmith.use(~corePlugin~()) // defaults
metalsmith.use(~corePlugin~({ // explicit defaults
...
}))
```
Expand All @@ -48,28 +55,28 @@ Document a second specific usage example

### Debug

To enable debug logs, set the `DEBUG` environment variable to `@metalsmith/%core-plugin%`:
To enable debug logs, set the `DEBUG` environment variable to `@metalsmith/~core-plugin~`:

Linux/Mac:
```
DEBUG=@metalsmith/%core-plugin%
DEBUG=@metalsmith/~core-plugin~
```
Windows:
```
set "DEBUG=@metalsmith/%core-plugin%"
set "DEBUG=@metalsmith/~core-plugin~"
```

Alternatively you can set `DEBUG` to `@metalsmith/*` to debug all Metalsmith core plugins.

### CLI usage

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

```json
{
"plugins": [
{
"@metalsmith/%core-plugin%": {}
"@metalsmith/~core-plugin~": {}
}
]
}
Expand All @@ -83,13 +90,13 @@ Special thanks to ... for ...

[MIT](LICENSE)

[npm-badge]: https://img.shields.io/npm/v/@metalsmith/%core-plugin%.svg
[npm-url]: https://www.npmjs.com/package/@metalsmith/%core-plugin%
[ci-badge]: https://app.travis-ci.com/metalsmith/%core-plugin%.svg?branch=master
[ci-url]: https://app.travis-ci.com/github/metalsmith/%core-plugin%
[npm-badge]: https://img.shields.io/npm/v/@metalsmith/~core-plugin~.svg
[npm-url]: https://www.npmjs.com/package/@metalsmith/~core-plugin~
[ci-badge]: https://app.travis-ci.com/metalsmith/~core-plugin~.svg?branch=master
[ci-url]: https://app.travis-ci.com/github/metalsmith/~core-plugin~
[metalsmith-badge]: https://img.shields.io/badge/metalsmith-core_plugin-green.svg?longCache=true
[metalsmith-url]: https://metalsmith.io
[codecov-badge]: https://img.shields.io/coveralls/github/metalsmith/%core-plugin%
[codecov-url]: https://coveralls.io/github/metalsmith/%core-plugin%
[license-badge]: https://img.shields.io/github/license/metalsmith/%core-plugin%
[codecov-badge]: https://img.shields.io/coveralls/github/metalsmith/~core-plugin~
[codecov-url]: https://coveralls.io/github/metalsmith/~core-plugin~
[license-badge]: https://img.shields.io/github/license/metalsmith/~core-plugin~
[license-url]: LICENSE
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@metalsmith/%core-plugin%",
"name": "@metalsmith/~core-plugin~",
"private": true,
"version": "0.1.0",
"description": "A Metalsmith %core-plugin% boilerplate",
"description": "A Metalsmith plugin to ...",
"keywords": [
"%core-plugin%",
"~core-plugin~",
"metalsmith-plugin",
"metalsmith",
"static-site"
],
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/metalsmith/%core-plugin%.git"
"url": "git+https://github.com/metalsmith/~core-plugin~.git"
},
"files": [
"lib",
Expand All @@ -25,9 +25,9 @@
"author": "Kevin Van Lierde (https://webketje.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/metalsmith/%core-plugin%/issues"
"url": "https://github.com/metalsmith/~core-plugin~/issues"
},
"homepage": "https://github.com/metalsmith/%core-plugin%#readme",
"homepage": "https://github.com/metalsmith/~core-plugin~#readme",
"dependencies": {
"debug": "^4.3.3"
},
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ function fixture(p) {
return require('path').resolve(__dirname, 'fixtures', p)
}

describe('@metalsmith/core-plugin', function() {
describe('@metalsmith/~core-plugin~', function() {
it('should export a named plugin function matching package.json name', function() {
const namechars = name.split('/')[1]
const camelCased = namechars.split('')
.reduce((str, char, i) => {
str += namechars[i - 1] === '-' ? char.toUpperCase() : char === '-' ? '' : char
return str
}, '')
assert.strictEqual(plugin().name, camelCased)
assert.strictEqual(plugin().name, camelCased.replace(/~/g, ''))
})
it('should not crash the metalsmith build when using default options', function(done) {
Metalsmith(fixture('default'))
Expand Down

0 comments on commit d56163e

Please sign in to comment.