first docs
This commit is contained in:
0
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/.ready
generated
vendored
Normal file
0
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/.ready
generated
vendored
Normal file
510
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/CHANGELOG.md
generated
vendored
Normal file
510
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,510 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
This project adheres to [Semantic Versioning](http://semver.org).
|
||||
|
||||
This document follows the guidelines of [Keep A Changelog](http://keepachangelog.com).
|
||||
|
||||
## [2.5.1] - 2022-10-07
|
||||
|
||||
### Updated
|
||||
|
||||
- **Dependencies:** [`774a164`](https://github.com/metalsmith/metalsmith/commit/774a164)
|
||||
- `debug`: 4.3.3 ▶︎ 4.3.4
|
||||
- Clarified semver policy in README.md
|
||||
- Added SECURITY.md
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixes [#373](https://github.com/metalsmith/metalsmith/issues/374): do not crash when postinstall script fails in specific environments
|
||||
|
||||
## [2.5.0] - 2022-06-10
|
||||
|
||||
Important note to [metalsmith-watch](https://github.com/FWeinb/metalsmith-watch#readme) users:
|
||||
Although 2.5.0 is a semver-minor release, it breaks compatibility with metalsmith-watch, which relies on the Metalsmith < 2.4.x private method signature using the outdated unyield package. See [issue #374](https://github.com/metalsmith/metalsmith/issues/374) for more details.
|
||||
|
||||
### Added
|
||||
|
||||
- [#354] Added `Metalsmith#env` method. Supports passing `DEBUG` and `DEBUG_LOG` amongst others. Sets `CLI: true` when run from the metalsmith CLI. [`b42df8c`](https://github.com/metalsmith/metalsmith/commit/b42df8c), [`446c676`](https://github.com/metalsmith/metalsmith/commit/446c676), [`33d936b`](https://github.com/metalsmith/metalsmith/commit/33d936b), [`4c483a3`](https://github.com/metalsmith/metalsmith/commit/4c483a3)
|
||||
- [#356] Added `Metalsmith#debug` method for creating plugin debuggers
|
||||
- [#362] Upgraded all generator-based methods (`Metalsmith#read`,`Metalsmith#readFile`,`Metalsmith#write`,`Metalsmith#writeFile`, `Metalsmith#run` and `Metalsmith#process`) to dual callback-/ promise-based methods [`16a91c5`](https://github.com/metalsmith/metalsmith/commit/16a91c5), [`faf6ab6`](https://github.com/metalsmith/metalsmith/commit/faf6ab6), [`6cb6229`](https://github.com/metalsmith/metalsmith/commit/6cb6229)
|
||||
- Added org migration notification to postinstall script to encourage users to upgrade [`3a11a24`](https://github.com/metalsmith/metalsmith/commit/3a11a24)
|
||||
|
||||
### Removed
|
||||
|
||||
- [#231] Dropped support for Node < 12 [`0a53007`](https://github.com/metalsmith/metalsmith/commit/0a53007)
|
||||
- **Dependencies:**
|
||||
- `thunkify`: replaced with promise-based implementation [`faf6ab6`](https://github.com/metalsmith/metalsmith/commit/faf6ab6)
|
||||
- `unyield` replaced with promise-based implementation [`faf6ab6`](https://github.com/metalsmith/metalsmith/commit/faf6ab6)
|
||||
- `co-fs-extra`: replaced with native Node.js methods [`faf6ab6`](https://github.com/metalsmith/metalsmith/commit/faf6ab6)
|
||||
- `chalk`: not necessary for the few colors used by Metalsmith CLI [`1dae1cb`](https://github.com/metalsmith/metalsmith/commit/a1dae1cb)
|
||||
- `clone`: see [#247] [`a871af6`](https://github.com/metalsmith/metalsmith/commit/a871af6)
|
||||
|
||||
### Updated
|
||||
|
||||
- Restructured and updated `README.md` [`0da0c4d`](https://github.com/metalsmith/metalsmith/commit/0da0c4d)
|
||||
- [#247] Calling `Metalsmith#metadata` no longer clones the object passed to it, overwriting the previous metadata, but merges it into existing metadata.
|
||||
|
||||
[#362]: https://github.com/metalsmith/metalsmith/issues/362
|
||||
[#354]: https://github.com/metalsmith/metalsmith/issues/354
|
||||
[#355]: https://github.com/metalsmith/metalsmith/issues/355
|
||||
[#356]: https://github.com/metalsmith/metalsmith/issues/356
|
||||
[#247]: https://github.com/metalsmith/metalsmith/issues/247
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#355] Proper path resolution for edge-cases using CLI, running metalsmith from outside or subfolder of `metalsmith.directory()`[`5d75539`](https://github.com/metalsmith/metalsmith/commit/5d75539)
|
||||
|
||||
## [2.4.3] - 2022-05-16
|
||||
|
||||
### Updated
|
||||
|
||||
- **Dependencies:** [`774a164`](https://github.com/metalsmith/metalsmith/commit/774a164)
|
||||
- `micromatch`: 4.0.4 ▶︎ 4.0.5
|
||||
- Updated README.md
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixes repeat `metalsmith.match` file cache in repeat runs without re-read, see https://github.com/metalsmith/layouts/issues/183 [`a727309`](https://github.com/metalsmith/metalsmith/commit/a727309)
|
||||
|
||||
## [2.4.2] - 2022-02-13
|
||||
|
||||
### Updated
|
||||
|
||||
- **Dependencies:** [`af9dec0`](https://github.com/metalsmith/metalsmith/commit/af9dec0)
|
||||
- `chalk`: 3.0.0 ▶︎ 4.1.2
|
||||
- Updated README.md
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Metalsmith JSDoc type hints in VS code [`ebf82f4`](https://github.com/metalsmith/metalsmith/commit/ebf82f4)
|
||||
- Added package integrity test [`c539c67`](https://github.com/metalsmith/metalsmith/commit/c539c67)
|
||||
|
||||
## [2.4.1] - 2022-01-31
|
||||
|
||||
### Fixed
|
||||
|
||||
Bugfix: include index.js in package.json files
|
||||
|
||||
## [2.4.0] - 2022-01-31
|
||||
|
||||
### Added
|
||||
|
||||
- [#338] Added `Metalsmith#match` method. Plugins no longer need to require a matching library [`705c4bb`](https://github.com/metalsmith/metalsmith/commit/705c4bb), [`f01c724`](https://github.com/metalsmith/metalsmith/commit/f01c724)
|
||||
- [#358] Added TS-style JSdocs [`828b17e`](https://github.com/metalsmith/metalsmith/commit/828b17e)
|
||||
- Use native `fs.rm` instead of `rimraf` when available (Node 14.4+) [`fcbb76e`](https://github.com/metalsmith/metalsmith/commit/fcbb76e), [`66e4376`](https://github.com/metalsmith/metalsmith/commit/66e4376)
|
||||
- [#226] Allow passing a gray-matter options object to `Metalsmith#frontmatter` [`a6438d2`](https://github.com/metalsmith/metalsmith/commit/a6438d2)
|
||||
- Modernized dev setup [`ef7b781`](https://github.com/metalsmith/metalsmith/commit/ef7b781)
|
||||
- Added 8 new tests (match method, front-matter options, path & symbolic link handling)
|
||||
- Files object file paths are now guaranteed to be sorted aphabetically. [`4eb1184`](https://github.com/metalsmith/metalsmith/commit/4eb1184)
|
||||
- [#211] `Metalsmith#build` now returns a promise which you can attach a `then/catch` to or `await`. The build callback model is still available. [`6d5a42d`](https://github.com/metalsmith/metalsmith/commit/6d5a42d)
|
||||
|
||||
### Removed
|
||||
|
||||
- [#231] Dropped support for Node < 8 [`2db47f5`](https://github.com/metalsmith/metalsmith/commit/75e6878), [`75e6878`](https://github.com/metalsmith/metalsmith/commit/75e6878)
|
||||
- **Dependencies:**
|
||||
- `has-generators`: obsolete in supported Node versions [`2db47f5`](https://github.com/metalsmith/metalsmith/commit/2db47f5)
|
||||
- `absolute` replaced with native Node `path.isAbsolute` [`c05f9e2`](https://github.com/metalsmith/metalsmith/commit/c05f9e2) (@Zearin)
|
||||
- `is` replaced with own implementation [`7eaac9e2`](https://github.com/metalsmith/metalsmith/commit/7eaac9e2), [`54dba0c1`](https://github.com/metalsmith/metalsmith/commit/54dba0c1) (@Zearin)
|
||||
- `recursive-readdir`: replaced with own implementation [`4eb1184`](https://github.com/metalsmith/metalsmith/commit/4eb1184)
|
||||
|
||||
### Updated
|
||||
|
||||
- **Dependencies:** [`75e6878`](https://github.com/metalsmith/metalsmith/commit/75e6878)
|
||||
|
||||
- `chalk`: 1.1.3 ▶︎ 3.0.0
|
||||
- `gray-matter`: 2.0.0 ▶︎ 4.0.3
|
||||
- `stat-mode`: 0.2.0 ▶︎ 1.0.0
|
||||
- `rimraf`: 2.2.8 ▶︎ 3.0.2
|
||||
- `ware`: 1.2.0 ▶︎ 1.3.0
|
||||
- `commander` (used in CLI): 2.15.1 ▶︎ 6.2.1
|
||||
- `win-fork` (used in CLI): replaced with `cross-spawn`:7.0.3
|
||||
|
||||
- Updated `CHANGELOG.md` format to follow “[Keep A Changelog](http://keepachangelog.com)” (#266) (@Zearin)
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#206] `Metalsmith#ignore` now only matches paths relative to `Metalsmith#source` (as it should). See linked issue for details [`4eb1184`](https://github.com/metalsmith/metalsmith/commit/4eb1184)
|
||||
- [#226] Metalsmith will no longer 'swallow' errors on invalid front-matter, they will be passed to `Metalsmith#build` [`a6438d2`](https://github.com/metalsmith/metalsmith/commit/a6438d2)
|
||||
- Fix test error on Windows [#158] (@moozzyk)
|
||||
- [#281] Metalsmith now properly handles symbolic links (will throw an ENOENT error or they can be `Metalsmith#ignore`'d) [`4eb1184`](https://github.com/metalsmith/metalsmith/commit/4eb1184)
|
||||
- [#178] `Metalsmith#ignore` now removes the matched files _before_ they are `statted` for glob-based ignores (saving some perf & potential errors).
|
||||
- [#295] Metalsmith now catches all FS errors and passes them to the build callback/ thenable appropriately.
|
||||
|
||||
### Security
|
||||
|
||||
- Replace all occurences of `new Buffer` with `Buffer.from`
|
||||
|
||||
#### `npm audit` vulnerability fixes
|
||||
|
||||
- **Development Dependencies:**
|
||||
- `coveralls`: 2.11.6 ▶︎ 3.0.1 (#308) (@Zearin)
|
||||
Fix 5 “Moderate” vulnerabilities
|
||||
- `metalsmith-markdown`: 0.2.1 ▶︎ 0.2.2 (#312) (@Zearin)
|
||||
Fix 1 “Low” vulnerability
|
||||
|
||||
[#158]: https://github.com/metalsmith/metalsmith/issues/158
|
||||
[#178]: https://github.com/metalsmith/metalsmith/issues/178
|
||||
[#206]: https://github.com/metalsmith/metalsmith/issues/206#issuecomment-1008289480
|
||||
[#211]: https://github.com/metalsmith/metalsmith/issues/211
|
||||
[#226]: https://github.com/metalsmith/metalsmith/issues/226
|
||||
[#231]: https://github.com/metalsmith/metalsmith/issues/231
|
||||
[#281]: https://github.com/metalsmith/metalsmith/issues/281
|
||||
[#295]: https://github.com/metalsmith/metalsmith/issues/295
|
||||
[#338]: https://github.com/metalsmith/metalsmith/issues/338
|
||||
[#358]: https://github.com/metalsmith/metalsmith/issues/358
|
||||
|
||||
## [2.3.0] - 2016-10-28
|
||||
|
||||
### Added
|
||||
|
||||
- Add packaging metadata to build the metalsmith snap ([#249])
|
||||
|
||||
### Updated
|
||||
|
||||
- Update dependencies ([#246])
|
||||
|
||||
### Removed
|
||||
|
||||
- Remove unused dependencies
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix error when reading a symbolic link to a dir ([#229])
|
||||
|
||||
### Security
|
||||
|
||||
- Upgrade dependency to include security fix ([#258])
|
||||
|
||||
[#229]: https://github.com/metalsmith/metalsmith/pull/229
|
||||
[#246]: https://github.com/metalsmith/metalsmith/pull/246
|
||||
[#249]: https://github.com/metalsmith/metalsmith/pull/249
|
||||
[#258]: https://github.com/metalsmith/metalsmith/pull/258
|
||||
|
||||
## [2.2.2] - 2016-10-28
|
||||
|
||||
This version is the same as 2.2.0, and was released to counteract the accidental
|
||||
release of 2.2.1. (See 2.2.1 for details.)
|
||||
|
||||
## [2.2.1] - 2016-10-27 [YANKED]
|
||||
|
||||
This release is identical to 2.3.0, but was mistakenly released as a
|
||||
SemVer-patch version when it should have been released as a SemVer-minor
|
||||
version. **Please use versions `<= 2.2.0` or `>= 2.2.2` instead.**
|
||||
|
||||
## [2.2.0] - 2016-08-11
|
||||
|
||||
### Added
|
||||
|
||||
- Add ability to use functions for `ignore` matchers ([#179])
|
||||
- Add CLI option: `ignore` ([#232])
|
||||
- Add `process` to process files and plugins without writing files ([#244])
|
||||
|
||||
### Changed
|
||||
|
||||
- Only remove the contents of the `destination` directory (not the directory itself) when `clean` is `true` ([#221])
|
||||
|
||||
[#179]: https://github.com/metalsmith/metalsmith/issues/179
|
||||
[#221]: https://github.com/metalsmith/metalsmith/pull/221
|
||||
[#232]: https://github.com/metalsmith/metalsmith/pull/232
|
||||
[#244]: https://github.com/metalsmith/metalsmith/pull/244
|
||||
|
||||
## [2.1.0] - 2015-09-24
|
||||
|
||||
### Added
|
||||
|
||||
- Add CLI option: `frontmatter`
|
||||
|
||||
## [2.0.1] - 2015-07-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- META: bump patch because `2.0.0` was mistakenly already published
|
||||
|
||||
## [2.0.0] - 2015-07-14
|
||||
|
||||
### Added
|
||||
|
||||
- CLI: Add separate `_metalsmith` bin (to allow custom transpilers)
|
||||
|
||||
### Removed
|
||||
|
||||
- Drop support for Node 0.10 (native and tests)
|
||||
|
||||
## [1.7.0] - 2015-04-30
|
||||
|
||||
### Added
|
||||
|
||||
- Add `ignore`
|
||||
|
||||
## [1.6.0] - 2015-04-14
|
||||
|
||||
### Added
|
||||
|
||||
- Add `concurrency`
|
||||
|
||||
## [1.5.0] - 2015-03-29
|
||||
|
||||
### Added
|
||||
|
||||
- Add ability to pass in plugins to `#run`
|
||||
|
||||
## [1.4.5] - 2015-03-27
|
||||
|
||||
### Changed
|
||||
|
||||
- Improve plugin error handling
|
||||
|
||||
## [1.4.4] - 2015-03-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- Workaround the absence of `isAbsolute` from Node 0.10
|
||||
|
||||
## [1.4.3] - 2015-03-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix typo in variable name
|
||||
|
||||
## [1.4.2] - 2015-03-26
|
||||
|
||||
### Changed
|
||||
|
||||
- Use `gray-matter` to parse frontmatter
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix bug in frontmatter parser
|
||||
|
||||
## [1.4.1] - 2015-03-25
|
||||
|
||||
### Changed
|
||||
|
||||
- Nicer errors for invalid frontmatter
|
||||
|
||||
## [1.4.0] - 2015-03-25
|
||||
|
||||
### Added
|
||||
|
||||
- Add ability to override the read and write directory
|
||||
|
||||
## [1.3.0] - 2015-02-06
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for local (non-npm, but still node) plugins
|
||||
|
||||
## [1.2.0] - 2015-02-04
|
||||
|
||||
### Added
|
||||
|
||||
- Add stack trace to CLI output
|
||||
|
||||
## [1.1.1] - 2015-01-25
|
||||
|
||||
### Fixed
|
||||
|
||||
- Update `recursive-readdir` to `1.2.1` to fix [#110]
|
||||
|
||||
[#110]: https://github.com/metalsmith/metalsmith/pull/110
|
||||
|
||||
## [1.1.0] - 2015-01-25
|
||||
|
||||
### Added
|
||||
|
||||
- Add type checking to getter/setters
|
||||
- Add support for alternate config file path
|
||||
- Add file-specific errors on writing and reading
|
||||
|
||||
## [1.0.1] - 2014-09-30
|
||||
|
||||
### Changed
|
||||
|
||||
- Move `gnode` to regular dependencies
|
||||
|
||||
## [1.0.0] - 2014-09-29
|
||||
|
||||
### Added
|
||||
|
||||
- Add generator support for Node 0.11
|
||||
- Add absolute path support for `source` and `directory`
|
||||
- Add `#directory` getter and setter method
|
||||
- Add `#readFile` method to expose the core reading logic
|
||||
- Add `#writeFile` method to expose the core writing logic
|
||||
|
||||
### Changed
|
||||
|
||||
- Change `#join` to `#path` and use `path.resolve`
|
||||
|
||||
### Fixed
|
||||
|
||||
- CLI: Fix default `clean` setting
|
||||
|
||||
## [0.11.0] - 2014-09-12
|
||||
|
||||
### Changed
|
||||
|
||||
- Move `clean` logic to happen at the beginning of a build
|
||||
|
||||
## [0.10.0] - 2014-08-19
|
||||
|
||||
### Added
|
||||
|
||||
- Expose `stats` on files
|
||||
|
||||
## [0.9.0] - 2014-070-13
|
||||
|
||||
### Added
|
||||
|
||||
- Add `frontmatter` option (to disable frontmatter parsing, if desired)
|
||||
|
||||
## [0.8.1] - 2014-070-07
|
||||
|
||||
### Changed
|
||||
|
||||
- Update dependencies
|
||||
|
||||
## [0.8.0] - 2014-05-06
|
||||
|
||||
### Added
|
||||
|
||||
- Add `clean` option
|
||||
|
||||
## [0.7.0] - 2014-04-29
|
||||
|
||||
### Changed
|
||||
|
||||
- In `metalsmith.json`: Allow `plugins` be an array
|
||||
|
||||
## [0.6.1] - 2014-04-24
|
||||
|
||||
### Changed
|
||||
|
||||
- Update `ware` to `0.3.0` for passing arrays
|
||||
|
||||
## [0.6.0] - 2014-04-02
|
||||
|
||||
### Added
|
||||
|
||||
- `mode` handling for files
|
||||
|
||||
## [0.5.0] - 2014-03-21
|
||||
|
||||
### Added
|
||||
|
||||
- Remove `destination` directory when writing
|
||||
- Expose `#run` to run middleware stack
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix jade examples
|
||||
|
||||
## [0.4.0] - 2014-03-14
|
||||
|
||||
### Changed
|
||||
|
||||
- Change `#metadata` to set a clone
|
||||
|
||||
## [0.3.0] - 2014-03-08
|
||||
|
||||
### Changed
|
||||
|
||||
- File contents are no longer trimmed
|
||||
|
||||
## [0.2.3] - 2014-03-07
|
||||
|
||||
### Added
|
||||
|
||||
- Add setting back to `#metadata`
|
||||
|
||||
## [0.2.2] - 2014-03-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix installation error
|
||||
|
||||
## [0.2.1] - 2014-03-07
|
||||
|
||||
### Changed
|
||||
|
||||
- CLI: use `chalk` instead of `colors`
|
||||
|
||||
## [0.2.0] - 2014-03-06
|
||||
|
||||
### Changed
|
||||
|
||||
- `#metadata` is now just a getter
|
||||
|
||||
## [0.1.0] - 2014-02-05
|
||||
|
||||
### Changed
|
||||
|
||||
- `contents` are now always a `Buffer`
|
||||
|
||||
## [0.0.4] - 2014-02-05
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix corrupted non-utf8 files
|
||||
|
||||
## [0.0.3] - 2014-02-05
|
||||
|
||||
### Added
|
||||
|
||||
- Expose `files` dictionary to `build` callback
|
||||
|
||||
## [0.0.2] - 2014-02-05
|
||||
|
||||
### Changed
|
||||
|
||||
- Do not mix in global metadata; leave it up to plugins
|
||||
|
||||
## 0.0.1 - 2014-02-04
|
||||
|
||||
:sparkles:
|
||||
|
||||
[unreleased]: https://github.com/metalsmith/metalsmith/compare/v2.3.0...HEAD
|
||||
[2.4.0]: https://github.com/metalsmith/metalsmith/compare/v2.3.0...v2.4.0
|
||||
[2.3.0]: https://github.com/metalsmith/metalsmith/compare/v2.2.2...v2.3.0
|
||||
[2.2.2]: https://github.com/metalsmith/metalsmith/compare/v2.2.0...v2.2.2
|
||||
[2.2.1]: https://github.com/metalsmith/metalsmith/compare/v2.2.0...v2.2.1
|
||||
[2.2.0]: https://github.com/metalsmith/metalsmith/compare/v2.1.0...v2.2.0
|
||||
[2.1.0]: https://github.com/metalsmith/metalsmith/compare/v2.0.1...v2.1.0
|
||||
[2.0.1]: https://github.com/metalsmith/metalsmith/compare/v2.0.0...v2.0.1
|
||||
[2.0.0]: https://github.com/metalsmith/metalsmith/compare/v1.7.0...v2.0.0
|
||||
[1.7.0]: https://github.com/metalsmith/metalsmith/compare/v1.6.0...v1.7.0
|
||||
[1.6.0]: https://github.com/metalsmith/metalsmith/compare/v1.5.0...v1.6.0
|
||||
[1.5.0]: https://github.com/metalsmith/metalsmith/compare/v1.4.5...v1.5.0
|
||||
[1.4.5]: https://github.com/metalsmith/metalsmith/compare/v1.4.4...v1.4.5
|
||||
[1.4.4]: https://github.com/metalsmith/metalsmith/compare/v1.4.3...v1.4.4
|
||||
[1.4.3]: https://github.com/metalsmith/metalsmith/compare/v1.4.2...v1.4.3
|
||||
[1.4.2]: https://github.com/metalsmith/metalsmith/compare/v1.4.1...v1.4.2
|
||||
[1.4.1]: https://github.com/metalsmith/metalsmith/compare/v1.4.0...v1.4.1
|
||||
[1.4.0]: https://github.com/metalsmith/metalsmith/compare/v1.3.0...v1.4.0
|
||||
[1.3.0]: https://github.com/metalsmith/metalsmith/compare/v1.2.0...v1.3.0
|
||||
[1.2.0]: https://github.com/metalsmith/metalsmith/compare/v1.1.1...v1.2.0
|
||||
[1.1.1]: https://github.com/metalsmith/metalsmith/compare/v1.1.0...v1.1.1
|
||||
[1.1.0]: https://github.com/metalsmith/metalsmith/compare/v1.0.1...v1.1.0
|
||||
[1.0.1]: https://github.com/metalsmith/metalsmith/compare/v1.0.0...v1.0.1
|
||||
[1.0.0]: https://github.com/metalsmith/metalsmith/compare/v0.11.0...v1.0.0
|
||||
[0.11.0]: https://github.com/metalsmith/metalsmith/compare/v0.10.0...v0.11.0
|
||||
[0.10.0]: https://github.com/metalsmith/metalsmith/compare/v0.9.0...v0.10.0
|
||||
[0.9.0]: https://github.com/metalsmith/metalsmith/compare/v0.8.1...v0.9.0
|
||||
[0.8.1]: https://github.com/metalsmith/metalsmith/compare/v0.8.0...v0.8.1
|
||||
[0.8.0]: https://github.com/metalsmith/metalsmith/compare/v0.7.0...v0.8.0
|
||||
[0.7.0]: https://github.com/metalsmith/metalsmith/compare/v0.6.1...v0.7.0
|
||||
[0.6.1]: https://github.com/metalsmith/metalsmith/compare/v0.6.0...v0.6.1
|
||||
[0.6.0]: https://github.com/metalsmith/metalsmith/compare/v0.5.0...v0.6.0
|
||||
[0.5.0]: https://github.com/metalsmith/metalsmith/compare/v0.4.0...v0.5.0
|
||||
[0.4.0]: https://github.com/metalsmith/metalsmith/compare/v0.3.0...v0.4.0
|
||||
[0.3.0]: https://github.com/metalsmith/metalsmith/compare/v0.2.3...v0.3.0
|
||||
[0.2.3]: https://github.com/metalsmith/metalsmith/compare/v0.2.2...v0.2.3
|
||||
[0.2.2]: https://github.com/metalsmith/metalsmith/compare/v0.2.1...v0.2.2
|
||||
[0.2.1]: https://github.com/metalsmith/metalsmith/compare/v0.2.0...v0.2.1
|
||||
[0.2.0]: https://github.com/metalsmith/metalsmith/compare/v0.1.0...v0.2.0
|
||||
[0.1.0]: https://github.com/metalsmith/metalsmith/compare/v0.0.4...v0.1.0
|
||||
[0.0.4]: https://github.com/metalsmith/metalsmith/compare/v0.0.3...v0.0.4
|
||||
[0.0.3]: https://github.com/metalsmith/metalsmith/compare/v0.0.2...v0.0.3
|
||||
[0.0.2]: https://github.com/metalsmith/metalsmith/compare/v0.0.1...v0.0.2
|
||||
10
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/LICENSE
generated
vendored
Normal file
10
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2021 webketje
|
||||
Copyright © 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 in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
247
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/README.md
generated
vendored
Normal file
247
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/README.md
generated
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
# Metalsmith
|
||||
|
||||
[![npm: version][npm-badge]][npm-url]
|
||||
[![ci: build][ci-badge]][ci-url]
|
||||
[![code coverage][codecov-badge]][codecov-url]
|
||||
[![license: MIT][license-badge]][license-url]
|
||||
[![Gitter chat][gitter-badge]][gitter-url]
|
||||
|
||||
> An extremely simple, _pluggable_ static site generator.
|
||||
|
||||
In Metalsmith, all of the logic is handled by plugins. You simply chain them together.
|
||||
|
||||
Here's what the simplest blog looks like:
|
||||
|
||||
```js
|
||||
const Metalsmith = require('metalsmith')
|
||||
const layouts = require('@metalsmith/layouts')
|
||||
const markdown = require('@metalsmith/markdown')
|
||||
|
||||
Metalsmith(__dirname)
|
||||
.use(markdown())
|
||||
.use(layouts())
|
||||
.build(function (err) {
|
||||
if (err) throw err
|
||||
console.log('Build finished!')
|
||||
})
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
NPM:
|
||||
|
||||
```
|
||||
npm install metalsmith
|
||||
```
|
||||
|
||||
Yarn:
|
||||
|
||||
```
|
||||
yarn add metalsmith
|
||||
```
|
||||
|
||||
## Quickstart
|
||||
|
||||
What if you want to get fancier by hiding unfinished drafts, grouping posts in collections, and using custom permalinks? Just add plugins...
|
||||
|
||||
```js
|
||||
const Metalsmith = require('metalsmith')
|
||||
const collections = require('@metalsmith/collections')
|
||||
const layouts = require('@metalsmith/layouts')
|
||||
const markdown = require('@metalsmith/markdown')
|
||||
const permalinks = require('@metalsmith/permalinks')
|
||||
|
||||
Metalsmith(__dirname)
|
||||
.source('./src')
|
||||
.destination('./build')
|
||||
.clean(true)
|
||||
.frontmatter({
|
||||
excerpt: true
|
||||
})
|
||||
.env({
|
||||
NAME: process.env.NODE_ENV,
|
||||
DEBUG: '@metalsmith/*',
|
||||
DEBUG_LOG: 'metalsmith.log'
|
||||
})
|
||||
.metadata({
|
||||
sitename: 'My Static Site & Blog',
|
||||
siteurl: 'https://example.com/',
|
||||
description: "It's about saying »Hello« to the world.",
|
||||
generatorname: 'Metalsmith',
|
||||
generatorurl: 'https://metalsmith.io/'
|
||||
})
|
||||
.use(
|
||||
collections({
|
||||
posts: 'posts/*.md'
|
||||
})
|
||||
)
|
||||
.use(markdown())
|
||||
.use(
|
||||
permalinks({
|
||||
relative: false
|
||||
})
|
||||
)
|
||||
.use(layouts())
|
||||
.build(function (err) {
|
||||
if (err) throw err
|
||||
})
|
||||
```
|
||||
|
||||
## How does it work?
|
||||
|
||||
Metalsmith works in three simple steps:
|
||||
|
||||
1. Read all the files in a source directory.
|
||||
2. Invoke a series of plugins that manipulate the files.
|
||||
3. Write the results to a destination directory!
|
||||
|
||||
Each plugin is invoked with the contents of the source directory, and each file can contain YAML front-matter that will be attached as metadata, so a simple file like...
|
||||
|
||||
```
|
||||
---
|
||||
title: A Catchy Title
|
||||
date: 2021-12-01
|
||||
---
|
||||
|
||||
An informative article.
|
||||
```
|
||||
|
||||
...would be parsed into...
|
||||
|
||||
```
|
||||
{
|
||||
'path/to/my-file.md': {
|
||||
title: 'A Catchy Title',
|
||||
date: <Date >,
|
||||
contents: <Buffer 7a 66 7a 67...>,
|
||||
stats: {
|
||||
...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
...which any of the plugins can then manipulate however they want. Writing plugins is incredibly simple, just take a look at the [example drafts plugin](examples/drafts-plugin/index.js).
|
||||
|
||||
Of course they can get a lot more complicated too. That's what makes Metalsmith powerful; the plugins can do anything you want!
|
||||
|
||||
## Plugins
|
||||
|
||||
A [Metalsmith plugin](https://metalsmith.io/api/#Plugin) is a function that is passed the file list, the metalsmith instance, and a done callback.
|
||||
It is often wrapped in a plugin initializer that accepts configuration options.
|
||||
|
||||
Check out the official plugin registry at: https://metalsmith.io/plugins.
|
||||
Find all the core plugins at: https://github.com/search?q=org%3Ametalsmith+metalsmith-plugin
|
||||
See [the draft plugin](examples/drafts-plugin) for a simple plugin example.
|
||||
|
||||
## API
|
||||
|
||||
Check out the full API reference at: https://metalsmith.io/api.
|
||||
|
||||
## CLI
|
||||
|
||||
In addition to a simple [Javascript API](#api), the Metalsmith CLI can read configuration from a `metalsmith.json` file, so that you can build static-site generators similar to [Jekyll](https://jekyllrb.com) or [Hexo](https://hexo.io) easily. The example blog above would be configured like this:
|
||||
|
||||
`metalsmith.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"source": "src",
|
||||
"destination": "build",
|
||||
"clean": true,
|
||||
"metadata": {
|
||||
"sitename": "My Static Site & Blog",
|
||||
"siteurl": "https://example.com/",
|
||||
"description": "It's about saying »Hello« to the world.",
|
||||
"generatorname": "Metalsmith",
|
||||
"generatorurl": "https://metalsmith.io/"
|
||||
},
|
||||
"plugins": [
|
||||
{ "@metalsmith/drafts": true },
|
||||
{ "@metalsmith/collections": { "posts": "posts/*.md" } },
|
||||
{ "@metalsmith/markdown": true },
|
||||
{ "@metalsmith/permalinks": "posts/:title" },
|
||||
{ "@metalsmith/layouts": true }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Then run:
|
||||
|
||||
```bash
|
||||
metalsmith
|
||||
|
||||
# Metalsmith · reading configuration from: /path/to/metalsmith.json
|
||||
# Metalsmith · successfully built to: /path/to/build
|
||||
```
|
||||
|
||||
Options recognised by `metalsmith.json` are `source`, `destination`, `concurrency`, `metadata`, `clean` and `frontmatter`.
|
||||
Checkout the [static site](examples/static-site), [Jekyll](examples/jekyll) examples to see the CLI in action.
|
||||
|
||||
### Local plugins
|
||||
|
||||
If you want to use a custom plugin, but feel like it's too domain-specific to be published to the world, you can include plugins as local npm modules: (simply use a relative path from your root directory)
|
||||
|
||||
```json
|
||||
{
|
||||
"plugins": [{ "./lib/metalsmith/plugin.js": true }]
|
||||
}
|
||||
```
|
||||
|
||||
## The secret...
|
||||
|
||||
We often refer to Metalsmith as a "static site generator", but it's a lot more than that. Since everything is a plugin, the core library is just an abstraction for manipulating a directory of files.
|
||||
|
||||
Which means you could just as easily use it to make...
|
||||
|
||||
- [A project scaffolder.](examples/project-scaffolder)
|
||||
- [A build tool for Sass files.](examples/build-tool)
|
||||
- [A simple static site generator.](examples/static-site)
|
||||
- [A Jekyll-like static site generator.](examples/jekyll)
|
||||
|
||||
## Resources
|
||||
|
||||
- [Gitter community chat](https://gitter.im/metalsmith/community) for chat, questions
|
||||
- [Twitter announcements](https://twitter.com/@metalsmithio) and the [metalsmith.io news page](https://metalsmith.io/news) for updates
|
||||
- [Awesome Metalsmith](https://github.com/metalsmith/awesome-metalsmith) - great collection of resources, examples, and tutorials
|
||||
- [emmer.dev on metalsmith](https://emmer.dev/blog/tag/metalsmith/) - A good collection of various how to's for metalsmith
|
||||
- [glinka.co on metalsmith](https://www.glinka.co/blog/) - Another great collection of advanced approaches for developing metalsmith
|
||||
- [Getting to Know Metalsmith](http://robinthrift.com/post/getting-to-know-metalsmith/) - a great series about how to use Metalsmith for your static site.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Use [debug](https://github.com/debug-js/debug/) to debug your build with `export DEBUG=metalsmith-*,@metalsmith/*` (Linux) or `set DEBUG=metalsmith-*,@metalsmith/*` for Windows.
|
||||
Use the excellent [metalsmith-debug-ui plugin](https://github.com/leviwheatcroft/metalsmith-debug-ui) to get a snapshot UI for every build step.
|
||||
|
||||
### Node Version Requirements
|
||||
|
||||
Future Metalsmith releases will at least support the oldest supported Node LTS versions.
|
||||
|
||||
Metalsmith 2.5.x supports NodeJS versions 12 and higher.
|
||||
Metalsmith 2.4.x supports NodeJS versions 8 and higher.
|
||||
Metalsmith 2.3.0 and below support NodeJS versions all the way back to 0.12.
|
||||
|
||||
### Compatibility & support policy
|
||||
|
||||
Metalsmith is supported on all common operating systems (Windows, Linux, Mac).
|
||||
Metalsmith releases adhere to [semver (semantic versioning)](https://semver.org/) with 2 minor gray-area exceptions for what could be considered breaking changes:
|
||||
|
||||
- Major Node version support for EOL (End of Life) versions can be dropped in minor releases
|
||||
- If a change represents a major improvement that is backwards-compatible with 99% of use cases (not considering outdated plugins), they will be considered eligible for inclusion in minor version updates.
|
||||
|
||||
## Credits
|
||||
|
||||
Special thanks to [Ian Storm Taylor](https://github.com/ianstormtaylor), [Andrew Meyer](https://github.com/Ajedi32), [Dominic Barnes](https://github.com/dominicbarnes), [Andrew Goodricke](https://github.com/woodyrew), [Ismay Wolff](https://github.com/ismay), [Kevin Van Lierde](https://github.com/webketje) and [others](https://github.com/segmentio/metalsmith/graphs/contributors) for their contributions!
|
||||
|
||||
## [License](LICENSE)
|
||||
|
||||
[npm-badge]: https://img.shields.io/npm/v/metalsmith.svg
|
||||
[npm-url]: https://www.npmjs.com/package/metalsmith
|
||||
[ci-badge]: https://github.com/metalsmith/metalsmith/actions/workflows/test.yml/badge.svg
|
||||
[ci-url]: https://github.com/metalsmith/metalsmith/actions/workflows/test.yml
|
||||
[codecov-badge]: https://coveralls.io/repos/github/metalsmith/metalsmith/badge.svg?branch=master
|
||||
[codecov-url]: https://coveralls.io/github/metalsmith/metalsmith?branch=master
|
||||
[license-badge]: https://img.shields.io/github/license/metalsmith/metalsmith
|
||||
[license-url]: LICENSE
|
||||
[gitter-badge]: https://img.shields.io/badge/GITTER-Join-blue.svg
|
||||
[gitter-url]: https://gitter.im/metalsmith/community
|
||||
188
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/bin/_metalsmith
generated
vendored
Executable file
188
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/bin/_metalsmith
generated
vendored
Executable file
@@ -0,0 +1,188 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/* eslint-disable no-console */
|
||||
|
||||
const exists = require('fs').existsSync
|
||||
const Metalsmith = require('..')
|
||||
const program = require('commander')
|
||||
const { resolve, isAbsolute, dirname } = require('path')
|
||||
const { isString, isObject } = require('../lib/helpers')
|
||||
|
||||
const color = {
|
||||
error: '\x1b[31m',
|
||||
warn: '\x1b[33m',
|
||||
info: '\x1b[36m',
|
||||
success: '\x1b[32m',
|
||||
log: '\x1b[0m'
|
||||
}
|
||||
|
||||
/**
|
||||
* Usage.
|
||||
*/
|
||||
|
||||
program
|
||||
.version(require('../package.json').version)
|
||||
.option('-c, --config <path>', 'configuration file location', 'metalsmith.json')
|
||||
|
||||
/**
|
||||
* Examples.
|
||||
*/
|
||||
|
||||
program.on('--help', function () {
|
||||
console.log(' Examples:')
|
||||
console.log()
|
||||
console.log(' # build from metalsmith.json:')
|
||||
console.log(' $ metalsmith')
|
||||
console.log()
|
||||
console.log(' # build from lib/config.json:')
|
||||
console.log(' $ metalsmith --config lib/config.json')
|
||||
console.log()
|
||||
})
|
||||
|
||||
/**
|
||||
* Parse.
|
||||
*/
|
||||
|
||||
program.parse(process.argv)
|
||||
|
||||
/**
|
||||
* Config.
|
||||
*/
|
||||
|
||||
const dir = process.cwd()
|
||||
const config = program.config
|
||||
const path = isAbsolute(config) ? config : resolve(dir, config)
|
||||
|
||||
// Important addition of 2.5.x. Given local plugins with a relative path are written with __dirname in mind,
|
||||
// having a config-relative dir path makes sure the CLI runs properly
|
||||
// when the command is executed from a subfolder or outside of the ms directory
|
||||
const confRelativeDir = dirname(path)
|
||||
if (!exists(path)) fatal(`could not find a ${config} configuration file.`)
|
||||
|
||||
let json
|
||||
try {
|
||||
// requiring json is incompatible with ESM, however given the metalsmith CLI is not meant to be "imported" or used in an ESM flow,
|
||||
// it is ok to keep it here for now
|
||||
json = require(path)
|
||||
} catch (e) {
|
||||
fatal(`it seems like ${config} is malformed.`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Metalsmith.
|
||||
*/
|
||||
|
||||
const metalsmith = new Metalsmith(confRelativeDir)
|
||||
if (json.source) metalsmith.source(json.source)
|
||||
if (json.destination) metalsmith.destination(json.destination)
|
||||
if (json.concurrency) metalsmith.concurrency(json.concurrency)
|
||||
if (json.metadata) metalsmith.metadata(json.metadata)
|
||||
if (json.clean != null) metalsmith.clean(json.clean)
|
||||
if (json.frontmatter != null) metalsmith.frontmatter(json.frontmatter)
|
||||
if (json.ignore != null) metalsmith.ignore(json.ignore)
|
||||
if (isObject(json.env)) metalsmith.env(expandEnvVars(json.env, process.env))
|
||||
|
||||
// set a flag plugins can check to target CLI-specific behavior
|
||||
metalsmith.env('CLI', true)
|
||||
|
||||
/**
|
||||
* Plugins.
|
||||
*/
|
||||
|
||||
normalize(json.plugins).forEach(function (plugin) {
|
||||
for (const name in plugin) {
|
||||
const opts = plugin[name]
|
||||
let mod
|
||||
|
||||
try {
|
||||
const local = resolve(confRelativeDir, name)
|
||||
const npm = resolve(confRelativeDir, 'node_modules', name)
|
||||
|
||||
if (exists(local) || exists(`${local}.js`)) {
|
||||
mod = require(local)
|
||||
} else if (exists(npm)) {
|
||||
mod = require(npm)
|
||||
} else {
|
||||
mod = require(name)
|
||||
}
|
||||
} catch (e) {
|
||||
fatal(`failed to require plugin "${name}".`)
|
||||
}
|
||||
|
||||
try {
|
||||
metalsmith.use(mod(opts))
|
||||
} catch (e) {
|
||||
fatal(`error using plugin "${name}"...`, `${e.message}\n\n${e.stack}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Build.
|
||||
*/
|
||||
|
||||
metalsmith.build(function (err) {
|
||||
if (err) fatal(err.message, err.stack)
|
||||
log('success', `successfully built to ${metalsmith.destination()}`)
|
||||
})
|
||||
|
||||
/**
|
||||
* Log an error and then exit the process.
|
||||
*
|
||||
* @param {String} msg
|
||||
* @param {String} [stack] Optional stack trace to print.
|
||||
*/
|
||||
|
||||
function fatal(msg, stack) {
|
||||
log('error', msg)
|
||||
if (stack) {
|
||||
log('error', stack)
|
||||
}
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
function log(type, msg) {
|
||||
if (!msg) {
|
||||
msg = type
|
||||
}
|
||||
const fn = console[type] || console.log
|
||||
let args = [`Metalsmith · ${msg}`,'\x1b[0m']
|
||||
if (color[type]) args = [color[type], ...args]
|
||||
fn(...args)
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize an `obj` of plugins.
|
||||
*
|
||||
* @param {Array or Object} obj
|
||||
* @return {Array}
|
||||
*/
|
||||
|
||||
function normalize(obj) {
|
||||
if (obj instanceof Array) return obj
|
||||
const ret = []
|
||||
|
||||
for (const key in obj) {
|
||||
const plugin = {}
|
||||
plugin[key] = obj[key]
|
||||
ret.push(plugin)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand env var values in env with values in expansionSource
|
||||
* @param {Object} env
|
||||
* @param {Object} expansionSource
|
||||
* @returns {Object}
|
||||
*/
|
||||
function expandEnvVars(env, expansionSource) {
|
||||
Object.entries(env).forEach(([name, value]) => {
|
||||
if (isString(value) && value.startsWith('$')) {
|
||||
env[name] = expansionSource[value.slice(1)]
|
||||
}
|
||||
}, env)
|
||||
return env
|
||||
}
|
||||
35
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/bin/metalsmith
generated
vendored
Executable file
35
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/bin/metalsmith
generated
vendored
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
const spawn = require('cross-spawn')
|
||||
const resolve = require('path').resolve
|
||||
|
||||
/**
|
||||
* Resolve.
|
||||
*/
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
|
||||
/**
|
||||
* If we're not talking about a sub-command, fall back on `_metalsmith`.
|
||||
*/
|
||||
|
||||
args.unshift(resolve(__dirname, '_metalsmith'))
|
||||
|
||||
/**
|
||||
* Spawn.
|
||||
*/
|
||||
|
||||
const proc = spawn(process.execPath, args, { stdio: 'inherit' })
|
||||
|
||||
/**
|
||||
* Exit.
|
||||
*/
|
||||
|
||||
proc.on('exit', function (code) {
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(code)
|
||||
})
|
||||
7
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/index.js
generated
vendored
Normal file
7
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Export `Metalsmith`.
|
||||
*/
|
||||
|
||||
const Metalsmith = require('./lib')
|
||||
|
||||
module.exports = Metalsmith
|
||||
109
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/lib/debug.js
generated
vendored
Normal file
109
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/lib/debug.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
const debug = require('debug')
|
||||
const utf8 = require('is-utf8')
|
||||
const { isString } = require('./helpers')
|
||||
|
||||
const streamLogHandler =
|
||||
(stream) =>
|
||||
(...args) =>
|
||||
stream.write(require('util').format(...args) + '\n')
|
||||
debug.log = streamLogHandler(process.stderr)
|
||||
|
||||
const options = {}
|
||||
Object.defineProperties(options, {
|
||||
colors: {
|
||||
get() {
|
||||
return debug.inspectOpts.colors
|
||||
},
|
||||
set(v) {
|
||||
debug.inspectOpts.colors = v
|
||||
}
|
||||
},
|
||||
handle: {
|
||||
get() {
|
||||
return debug.log
|
||||
},
|
||||
set(v) {
|
||||
debug.log = v
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// add a %b buffer formatter to print buffer contents.
|
||||
// useful for checking whether the contents match rendering expectations
|
||||
debug.formatters.b = function (buffer) {
|
||||
if (buffer instanceof Buffer && utf8(buffer)) {
|
||||
return `${buffer.toString().slice(0, 200)}...`
|
||||
}
|
||||
return buffer
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {import('debug').Debugger} Debugger
|
||||
* @property {import('debug').Debugger} info
|
||||
* @property {import('debug').Debugger} warn
|
||||
* @property {import('debug').Debugger} error
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new [debug](https://github.com/debug-js/debug#readme) debugger
|
||||
* @param {string} namespace Debugger namespace
|
||||
* @returns {Debugger}
|
||||
* @example
|
||||
* ```js
|
||||
* const debug = metalsmith.debug('metalsmith-myplugin')
|
||||
* debug('a debug log') // logs 'metalsmith-myplugin a debug log'
|
||||
* debug.warn('A warning') // logs 'metalsmith-myplugin:warn A warning'
|
||||
* ```
|
||||
*/
|
||||
function Debugger(namespace) {
|
||||
if (!isString(namespace)) {
|
||||
const err = new Error(`invalid debugger namespace "${namespace}"`)
|
||||
err.code = 'invalid_debugger_namespace'
|
||||
throw err
|
||||
}
|
||||
// ANSI colors, see https://tintin.mudhalla.net/info/256color/
|
||||
// the colors have been chosen to best integrate with dark & light bg
|
||||
// and provide consistent coloring of debug/error/warn/info channel messages
|
||||
// debug only supports these colors if an extra module is installed, but these are already available in most terminals
|
||||
// to be tested on Windows Batch
|
||||
|
||||
const namespacedDebug = debug(namespace)
|
||||
|
||||
namespacedDebug.log = (...args) => options.handle(...args)
|
||||
namespacedDebug.color = 247
|
||||
|
||||
const warn = namespacedDebug.extend('warn')
|
||||
warn.color = 178
|
||||
|
||||
const info = namespacedDebug.extend('info')
|
||||
info.color = 51
|
||||
|
||||
const error = namespacedDebug.extend('error')
|
||||
error.color = 196
|
||||
|
||||
const dbugger = Object.assign(namespacedDebug, { warn, info, error })
|
||||
return dbugger
|
||||
}
|
||||
|
||||
// We need to proxy some properties through Debugger to get access to them through metalsmith.debug.<option>
|
||||
function proxy(host, target, option) {
|
||||
Object.defineProperty(host, option, {
|
||||
get() {
|
||||
return target[option]
|
||||
},
|
||||
set(v) {
|
||||
target[option] = v
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
proxy(Debugger, options, 'handle')
|
||||
proxy(Debugger, options, 'colors')
|
||||
proxy(Debugger, debug, 'enabled')
|
||||
proxy(Debugger, debug, 'enable')
|
||||
proxy(Debugger, debug, 'disable')
|
||||
|
||||
module.exports = {
|
||||
Debugger,
|
||||
fileLogHandler: streamLogHandler
|
||||
}
|
||||
192
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/lib/helpers.js
generated
vendored
Normal file
192
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/lib/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
const fs = require('fs')
|
||||
const { promisify } = require('util')
|
||||
const { resolve, relative, normalize, dirname } = require('path')
|
||||
const stat = promisify(fs.stat)
|
||||
const readFile = promisify(fs.readFile)
|
||||
const writeFile = promisify(fs.writeFile)
|
||||
const mkdir = promisify(fs.mkdir)
|
||||
const fsreaddir = promisify(fs.readdir)
|
||||
const chmod = promisify(fs.chmod)
|
||||
const rmrf = require('rimraf')
|
||||
const micromatch = require('micromatch')
|
||||
|
||||
/**
|
||||
* Type-checkers
|
||||
*/
|
||||
function isBoolean(b) {
|
||||
return typeof b === 'boolean'
|
||||
}
|
||||
function isNumber(n) {
|
||||
return typeof n === 'number' && !Number.isNaN(n)
|
||||
}
|
||||
function isObject(o) {
|
||||
return o !== null && typeof o === 'object'
|
||||
}
|
||||
function isString(s) {
|
||||
return typeof s === 'string'
|
||||
}
|
||||
function isUndefined(u) {
|
||||
return typeof u === 'undefined'
|
||||
}
|
||||
function isFunction(f) {
|
||||
return typeof f === 'function'
|
||||
}
|
||||
|
||||
function match(input, patterns, options) {
|
||||
input = input || Object.keys(this._files)
|
||||
if (!(input && input.length)) return []
|
||||
options = Object.assign({ dot: true }, options || {}, {
|
||||
// required to convert forward to backslashes on Windows and match the file keys properly
|
||||
format: normalize
|
||||
})
|
||||
return micromatch(input, patterns, options).sort()
|
||||
}
|
||||
|
||||
function writeStream(path) {
|
||||
return fs.createWriteStream(path, 'utf-8')
|
||||
}
|
||||
/**
|
||||
* Recursively remove a directory
|
||||
* @param {string} p
|
||||
* @returns Promise
|
||||
*/
|
||||
function rm(p) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
/* istanbul ignore else */
|
||||
if (Object.prototype.hasOwnProperty.call(fs, 'rm')) {
|
||||
fs.rm(
|
||||
p,
|
||||
{
|
||||
recursive: true,
|
||||
force: true
|
||||
},
|
||||
(err) => {
|
||||
if (err) reject(err)
|
||||
else resolve()
|
||||
}
|
||||
)
|
||||
} else {
|
||||
// Node 14.14- compat
|
||||
rmrf(p, { glob: { dot: true } }, (err) => {
|
||||
if (err) reject(err)
|
||||
else resolve()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive readdir with support for ignores
|
||||
* @private
|
||||
* @param {String} dir
|
||||
* @param {Array<String|Function>} ignores
|
||||
*/
|
||||
function readdir(dir, ignores) {
|
||||
if (Array.isArray(ignores)) {
|
||||
ignores = {
|
||||
str: ignores.filter(isString),
|
||||
fn: ignores.filter(isFunction)
|
||||
}
|
||||
}
|
||||
|
||||
if (isString(dir)) {
|
||||
dir = {
|
||||
current: dir,
|
||||
root: dir
|
||||
}
|
||||
}
|
||||
const result = fsreaddir(dir.current)
|
||||
.then((children) => {
|
||||
const filtered = []
|
||||
|
||||
children.forEach((child) => {
|
||||
const res = resolve(dir.current, child)
|
||||
const rel = relative(dir.root, res)
|
||||
|
||||
if (!match(rel, ignores.str).length) {
|
||||
filtered.push(
|
||||
stat(res).then((stat) => {
|
||||
// it would be better to put this check together with the previous if,
|
||||
// but that would break backwards-compatibility with Metalsmith 2.3.0
|
||||
// as the stat object needs to be passed to ignore fns
|
||||
if (ignores.fn.some((fn) => fn(rel, stat))) {
|
||||
return null
|
||||
}
|
||||
if (stat.isDirectory()) {
|
||||
return readdir({ current: res, root: dir.root }, ignores)
|
||||
}
|
||||
return res
|
||||
})
|
||||
)
|
||||
}
|
||||
})
|
||||
return Promise.all(filtered)
|
||||
})
|
||||
.then((files) => {
|
||||
const result = files
|
||||
// @TODO: this is a catch-all & can probably be finetuned with some more tests
|
||||
.filter((file) => !(file instanceof Error) && file !== null)
|
||||
.reduce((all, file) => all.concat(file), [])
|
||||
.sort()
|
||||
return result
|
||||
})
|
||||
.catch((err) => {
|
||||
throw err
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Run `fn` in parallel on #`concurrency` number of `items`, spread over #`items / concurrency` sequential batches
|
||||
* @private
|
||||
* @param {() => Promise} fn
|
||||
* @param {*[]} items
|
||||
* @param {number} concurrency
|
||||
* @returns {Promise<*[]>}
|
||||
*/
|
||||
function batchAsync(fn, items, concurrency) {
|
||||
let batches = Promise.resolve([])
|
||||
items = [...items]
|
||||
|
||||
while (items.length) {
|
||||
const slice = items.splice(0, concurrency)
|
||||
batches = batches.then((previousBatch) => {
|
||||
return Promise.all(slice.map((...args) => fn(...args))).then((currentBatch) => [
|
||||
...previousBatch,
|
||||
...currentBatch
|
||||
])
|
||||
})
|
||||
}
|
||||
|
||||
return batches
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a file and create any non-existing directories in the process
|
||||
* @private
|
||||
**/
|
||||
function outputFile(file, data, mode) {
|
||||
return mkdir(dirname(file), { recursive: true })
|
||||
.then(() => writeFile(file, data))
|
||||
.then(() => (mode ? chmod(file, mode) : Promise.resolve()))
|
||||
}
|
||||
|
||||
const helpers = {
|
||||
isBoolean,
|
||||
isNumber,
|
||||
isString,
|
||||
isObject,
|
||||
isUndefined,
|
||||
isFunction,
|
||||
match,
|
||||
rm,
|
||||
readdir,
|
||||
outputFile,
|
||||
stat,
|
||||
readFile,
|
||||
batchAsync,
|
||||
writeStream
|
||||
}
|
||||
|
||||
module.exports = helpers
|
||||
666
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/lib/index.js
generated
vendored
Normal file
666
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,666 @@
|
||||
'use strict'
|
||||
|
||||
const assert = require('assert')
|
||||
const matter = require('gray-matter')
|
||||
const Mode = require('stat-mode')
|
||||
const path = require('path')
|
||||
const {
|
||||
readdir,
|
||||
batchAsync,
|
||||
isFunction,
|
||||
outputFile,
|
||||
stat,
|
||||
readFile,
|
||||
writeStream,
|
||||
rm,
|
||||
isString,
|
||||
isBoolean,
|
||||
isObject,
|
||||
isNumber,
|
||||
isUndefined,
|
||||
match
|
||||
} = require('./helpers')
|
||||
const utf8 = require('is-utf8')
|
||||
const Ware = require('ware')
|
||||
const { Debugger, fileLogHandler } = require('./debug')
|
||||
|
||||
const symbol = {
|
||||
env: Symbol('env'),
|
||||
log: Symbol('log')
|
||||
}
|
||||
|
||||
/**
|
||||
* Metalsmith representation of the files in `metalsmith.source()`.
|
||||
* The keys represent the file paths and the values are {@link File} objects
|
||||
* @typedef {Object.<string, File>} Files
|
||||
*/
|
||||
|
||||
/**
|
||||
* Metalsmith file. Defines `mode`, `stats` and `contents` properties by default, but may be altered by plugins
|
||||
*
|
||||
* @typedef File
|
||||
* @property {Buffer} contents - A NodeJS [buffer](https://nodejs.org/api/buffer.html) that can be `.toString`'ed to obtain its human-readable contents
|
||||
* @property {import('fs').Stats} stats - A NodeJS [fs.Stats object](https://nodejs.org/api/fs.html#fs_class_fs_stats) object with extra filesystem metadata and methods
|
||||
* @property {string} mode - Octal permission mode, see https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation
|
||||
*/
|
||||
|
||||
/**
|
||||
* A callback to run when the Metalsmith build is done
|
||||
*
|
||||
* @callback BuildCallback
|
||||
* @param {Error} [error]
|
||||
* @param {Files} files
|
||||
* @this {Metalsmith}
|
||||
*
|
||||
* @example
|
||||
* function onBuildEnd(error, files) {
|
||||
* if (error) throw error
|
||||
* console.log('Build success')
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
* A callback to indicate that a plugin's work is done
|
||||
*
|
||||
* @callback DoneCallback
|
||||
* @param {Error} [error]
|
||||
*
|
||||
* @example
|
||||
* function plugin(files, metalsmith, done) {
|
||||
* // ..do stuff
|
||||
* done()
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Metalsmith plugin is a function that is passed the file list, the metalsmith instance, and a `done` callback.
|
||||
* Calling the callback is required for asynchronous plugins, and optional for synchronous plugins.
|
||||
*
|
||||
* @callback Plugin
|
||||
* @param {Files} files
|
||||
* @param {Metalsmith} metalsmith
|
||||
* @param {DoneCallback} done
|
||||
*
|
||||
* @example
|
||||
* function drafts(files, metalsmith) {
|
||||
* Object.keys(files).forEach(path => {
|
||||
* if (files[path].draft) {
|
||||
* delete files[path]
|
||||
* }
|
||||
* })
|
||||
* }
|
||||
*
|
||||
* metalsmith.use(drafts)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Export `Metalsmith`.
|
||||
*/
|
||||
|
||||
module.exports = Metalsmith
|
||||
|
||||
/**
|
||||
* Initialize a new `Metalsmith` builder with a working `directory`.
|
||||
*
|
||||
* @callback Metalsmith
|
||||
* @param {string} directory
|
||||
* @property {Plugin[]} plugins
|
||||
* @property {string[]} ignores
|
||||
* @return {Metalsmith}
|
||||
*/
|
||||
|
||||
function Metalsmith(directory) {
|
||||
if (!(this instanceof Metalsmith)) return new Metalsmith(directory)
|
||||
assert(directory, 'You must pass a working directory path.')
|
||||
this.plugins = []
|
||||
this.ignores = []
|
||||
this.directory(directory)
|
||||
this.metadata({})
|
||||
this.source('src')
|
||||
this.destination('build')
|
||||
this.concurrency(Infinity)
|
||||
this.clean(true)
|
||||
this.frontmatter(true)
|
||||
Object.defineProperty(this, symbol.env, {
|
||||
value: Object.create(null),
|
||||
enumerable: false
|
||||
})
|
||||
Object.defineProperty(this, symbol.log, {
|
||||
value: null,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a `plugin` function to the stack.
|
||||
* @param {Plugin} plugin
|
||||
* @return {Metalsmith}
|
||||
*
|
||||
* @example
|
||||
* metalsmith
|
||||
* .use(drafts()) // use the drafts plugin
|
||||
* .use(markdown()) // use the markdown plugin
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.use = function (plugin) {
|
||||
this.plugins.push(plugin)
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set the working `directory`.
|
||||
*
|
||||
* @param {string} [directory]
|
||||
* @return {string|Metalsmith}
|
||||
*
|
||||
* @example
|
||||
* new Metalsmith('.') // set the path of the working directory through the constructor
|
||||
* metalsmith.directory() // returns '.'
|
||||
* metalsmith.directory('./other/path') // set the path of the working directory
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.directory = function (directory) {
|
||||
if (!arguments.length) return path.resolve(this._directory)
|
||||
assert(isString(directory), 'You must pass a directory path string.')
|
||||
this._directory = directory
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set the global `metadata`.
|
||||
*
|
||||
* @param {Object} [metadata]
|
||||
* @return {Object|Metalsmith}
|
||||
*
|
||||
* @example
|
||||
* metalsmith.metadata({ sitename: 'My blog' }); // set metadata
|
||||
* metalsmith.metadata() // returns { sitename: 'My blog' }
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.metadata = function (metadata) {
|
||||
if (isUndefined(metadata)) return this._metadata
|
||||
assert(isObject(metadata), 'You must pass a metadata object.')
|
||||
this._metadata = Object.assign(this._metadata || {}, metadata)
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set the source directory.
|
||||
*
|
||||
* @param {string} [path]
|
||||
* @return {string|Metalsmith}
|
||||
*
|
||||
* @example
|
||||
* metalsmith.source('./src'); // set source directory
|
||||
* metalsmith.source() // returns './src'
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.source = function (path) {
|
||||
if (isUndefined(path)) return this.path(this._source)
|
||||
assert(isString(path), 'You must pass a source path string.')
|
||||
this._source = path
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set the destination directory.
|
||||
*
|
||||
* @param {string} [path]
|
||||
* @return {string|Metalsmith}
|
||||
*
|
||||
* @example
|
||||
* metalsmith.destination('build'); // set destination
|
||||
* metalsmith.destination() // returns 'build'
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.destination = function (path) {
|
||||
if (!arguments.length) return this.path(this._destination)
|
||||
assert(isString(path), 'You must pass a destination path string.')
|
||||
this._destination = path
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set the maximum number of files to open at once.
|
||||
*
|
||||
* @param {number} [max]
|
||||
* @returns {number|Metalsmith}
|
||||
*
|
||||
* @example
|
||||
* metalsmith.concurrency(20) // set concurrency to max 20
|
||||
* metalsmith.concurrency() // returns 20
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.concurrency = function (max) {
|
||||
if (isUndefined(max)) return this._concurrency
|
||||
assert(isNumber(max), 'You must pass a number for concurrency.')
|
||||
this._concurrency = max
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set whether the destination directory will be removed before writing.
|
||||
*
|
||||
* @param {boolean} [clean]
|
||||
* @return {boolean|Metalsmith}
|
||||
*
|
||||
* @example
|
||||
* metalsmith.clean(true) // clean the destination directory
|
||||
* metalsmith.clean() // returns true
|
||||
*/
|
||||
Metalsmith.prototype.clean = function (clean) {
|
||||
if (isUndefined(clean)) return this._clean
|
||||
assert(isBoolean(clean), 'You must pass a boolean.')
|
||||
this._clean = clean
|
||||
return this
|
||||
}
|
||||
|
||||
/** @typedef {Object} GrayMatterOptions */
|
||||
|
||||
/**
|
||||
* Optionally turn off frontmatter parsing or pass a [gray-matter options object](https://github.com/jonschlinkert/gray-matter/tree/4.0.2#option)
|
||||
*
|
||||
* @param {boolean|GrayMatterOptions} [frontmatter]
|
||||
* @return {boolean|Metalsmith}
|
||||
*
|
||||
* @example
|
||||
* metalsmith.frontmatter(false) // turn off front-matter parsing
|
||||
* metalsmith.frontmatter() // returns false
|
||||
* metalsmith.frontmatter({ excerpt: true })
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.frontmatter = function (frontmatter) {
|
||||
if (isUndefined(frontmatter)) return this._frontmatter
|
||||
assert(
|
||||
isBoolean(frontmatter) || isObject(frontmatter),
|
||||
'You must pass a boolean or a gray-matter options object: https://github.com/jonschlinkert/gray-matter/tree/4.0.2#options'
|
||||
)
|
||||
this._frontmatter = frontmatter
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set the list of filepaths or glob patterns to ignore
|
||||
*
|
||||
* @method Metalsmith#ignore
|
||||
* @param {string|string[]} [files] - The names or glob patterns of files or directories to ignore.
|
||||
* @return {Metalsmith|string[]}
|
||||
*
|
||||
* @example
|
||||
* metalsmith.ignore() // return a list of ignored file paths
|
||||
* metalsmith.ignore('layouts') // ignore the layouts directory
|
||||
* metalsmith.ignore(['.*', 'data.json']) // ignore dot files & a data file
|
||||
*/
|
||||
Metalsmith.prototype.ignore = function (files) {
|
||||
if (isUndefined(files)) return this.ignores.slice()
|
||||
this.ignores = this.ignores.concat(files)
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve `paths` relative to the metalsmith `directory`.
|
||||
*
|
||||
* @param {...string} paths
|
||||
* @return {string}
|
||||
*
|
||||
* @example
|
||||
* metalsmith.path('./path','to/file.ext')
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.path = function (...paths) {
|
||||
return path.resolve.apply(path, [this.directory(), ...paths])
|
||||
}
|
||||
|
||||
/**
|
||||
* Match filepaths in the source directory by [glob](https://en.wikipedia.org/wiki/Glob_(programming)) pattern.
|
||||
* If `input` is not specified, patterns are matched against `Object.keys(files)`
|
||||
*
|
||||
* @param {string|string[]} patterns - one or more glob patterns
|
||||
* @param {string[]} [input] array of strings to match against
|
||||
* @param {import('micromatch').Options} options - [micromatch options](https://github.com/micromatch/micromatch#options), except `format`
|
||||
* @returns {string[]} An array of matching file paths
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.match = function (patterns, input, options) {
|
||||
input = input || Object.keys(this._files)
|
||||
if (!(input && input.length)) return []
|
||||
return match(input, patterns, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set one or multiple metalsmith environment variables. Metalsmith env vars are case-insensitive.
|
||||
* @param {string|Object} [vars] name of the environment variable, or an object with `{ name: 'value' }` pairs
|
||||
* @param {string|number|boolean} [value] value of the environment variable
|
||||
* @returns {string|number|boolean|Object|Metalsmith}
|
||||
* @example
|
||||
* // pass all Node env variables
|
||||
* metalsmith.env(process.env)
|
||||
* // get all env variables
|
||||
* metalsmith.env()
|
||||
* // get DEBUG env variable
|
||||
* metalsmith.env('DEBUG')
|
||||
* // set DEBUG env variable (chainable)
|
||||
* metalsmith.env('DEBUG', '*')
|
||||
* // set multiple env variables at once (chainable)
|
||||
* // this does not clear previously set variables
|
||||
* metalsmith.env({
|
||||
* DEBUG: false,
|
||||
* ENV: 'development'
|
||||
* })
|
||||
*/
|
||||
Metalsmith.prototype.env = function (vars, value) {
|
||||
if (isString(vars)) {
|
||||
if (arguments.length === 1) {
|
||||
return this[symbol.env][vars.toUpperCase()]
|
||||
}
|
||||
if (!(isFunction(value) || isObject(value))) {
|
||||
this[symbol.env][vars.toUpperCase()] = value
|
||||
return this
|
||||
}
|
||||
throw new TypeError('Environment variable values can only be primitive: Number, Boolean, String or null')
|
||||
}
|
||||
if (isObject(vars)) {
|
||||
Object.entries(vars).forEach(([key, value]) => this.env(key, value))
|
||||
return this
|
||||
}
|
||||
if (isUndefined(vars)) return Object.assign(Object.create(null), this[symbol.env])
|
||||
}
|
||||
|
||||
Metalsmith.prototype.debug = Debugger
|
||||
|
||||
/**
|
||||
* Build with the current settings to the destination directory.
|
||||
*
|
||||
* @param {BuildCallback} [callback]
|
||||
* @return {Promise<Files>}
|
||||
* @fulfills {Files}
|
||||
* @rejects {Error}
|
||||
*
|
||||
* @example
|
||||
* metalsmith.build(function(error, files) {
|
||||
* if (error) throw error
|
||||
* console.log('Build success!')
|
||||
* })
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.build = function (callback) {
|
||||
const clean = this.clean()
|
||||
const dest = this.destination()
|
||||
|
||||
const result = (clean ? rm(dest) : Promise.resolve())
|
||||
.then(() => {
|
||||
if (this.debug.enabled && this.env('DEBUG_LOG')) {
|
||||
this[symbol.log] = writeStream(this.path(this.env('DEBUG_LOG')))
|
||||
this.debug.handle = fileLogHandler(this[symbol.log])
|
||||
this.debug.colors = false
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this[symbol.log].on('error', (err) => {
|
||||
let error = err
|
||||
if (error.code === 'ENOENT') {
|
||||
error = new Error(
|
||||
`Inexistant directory path "${path.dirname(this.env('DEBUG_LOG'))}" given for DEBUG_LOG`
|
||||
)
|
||||
error.code = 'invalid_logpath'
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
if (this[symbol.log].pending) {
|
||||
this[symbol.log].on('ready', () => resolve())
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
.then(this.process.bind(this))
|
||||
.then((files) => {
|
||||
return this.write(files).then(() => {
|
||||
if (this[symbol.log]) this[symbol.log].end()
|
||||
return files
|
||||
})
|
||||
})
|
||||
|
||||
/* block required for Metalsmith 2.x callback-flow compat */
|
||||
if (isFunction(callback)) {
|
||||
result.then((files) => callback(null, files), callback)
|
||||
} else {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process files through plugins without writing out files.
|
||||
*
|
||||
* @method Metalsmith#process
|
||||
* @param {BuildCallback} [callback]
|
||||
* @return {Promise<Files>|void}
|
||||
*
|
||||
* @example
|
||||
* metalsmith.process((err, files) => {
|
||||
* if (err) throw err
|
||||
* console.log('Success')
|
||||
* console.log(this.metadata())
|
||||
* })
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.process = function (callback) {
|
||||
const result = this.read(this.source()).then((files) => {
|
||||
return this.run(files, this.plugins)
|
||||
})
|
||||
|
||||
/* block required for Metalsmith 2.x callback-flow compat */
|
||||
if (callback) {
|
||||
result.then((files) => callback(null, files), callback)
|
||||
} else {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a set of `files` through the plugins stack.
|
||||
*
|
||||
* @method Metalsmith#run
|
||||
* @package
|
||||
* @param {Files} files
|
||||
* @param {Plugin[]} plugins
|
||||
* @return {Promise<Files>|void}
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.run = function (files, plugins, callback) {
|
||||
let debugValue = this.env('DEBUG')
|
||||
if (debugValue === false) {
|
||||
this.debug.disable()
|
||||
} else {
|
||||
if (debugValue === true) debugValue = '*'
|
||||
this.debug.enable(debugValue)
|
||||
}
|
||||
|
||||
/* block required for Metalsmith 2.x callback-flow compat */
|
||||
const last = arguments[arguments.length - 1]
|
||||
callback = isFunction(last) ? last : undefined
|
||||
plugins = Array.isArray(plugins) ? plugins : this.plugins
|
||||
|
||||
this._files = files
|
||||
|
||||
const ware = new Ware(plugins)
|
||||
const run = ware.run.bind(ware)
|
||||
|
||||
const result = new Promise((resolve, reject) => {
|
||||
run(files, this, (err, files) => {
|
||||
if (err) reject(err)
|
||||
else resolve(files)
|
||||
})
|
||||
})
|
||||
|
||||
/* block required for Metalsmith 2.x callback-flow compat */
|
||||
if (callback) {
|
||||
result.then((files) => callback(null, files, this), callback)
|
||||
} else {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a dictionary of files from a `dir`, parsing frontmatter. If no directory
|
||||
* is provided, it will default to the source directory.
|
||||
*
|
||||
* @method Metalsmith#read
|
||||
* @package
|
||||
* @param {string} [dir]
|
||||
* @return {Promise<Files>|void}
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.read = function (dir, callback) {
|
||||
/* block required for Metalsmith 2.x callback-flow compat */
|
||||
if (isFunction(dir) || !arguments.length) {
|
||||
callback = dir
|
||||
dir = this.source()
|
||||
}
|
||||
const read = this.readFile.bind(this)
|
||||
const concurrency = this.concurrency()
|
||||
const ignores = this.ignores || null
|
||||
const result = readdir(dir, ignores).then((paths) => {
|
||||
return batchAsync((p) => read(p), paths, concurrency).then((files) => {
|
||||
const result = paths.reduce((memo, file, i) => {
|
||||
file = path.relative(dir, file)
|
||||
memo[file] = files[i]
|
||||
return memo
|
||||
}, {})
|
||||
return result
|
||||
})
|
||||
})
|
||||
|
||||
/* block required for Metalsmith 2.x callback-flow compat */
|
||||
if (callback) {
|
||||
result.then((files) => callback(null, files), callback)
|
||||
} else {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a `file` by path. If the path is not absolute, it will be resolved
|
||||
* relative to the source directory.
|
||||
*
|
||||
* @method Metalsmith#readFile
|
||||
* @package
|
||||
* @param {string} file
|
||||
* @returns {Promise<File>|void}
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.readFile = function (file, callback) {
|
||||
const src = this.source()
|
||||
if (!path.isAbsolute(file)) file = path.resolve(src, file)
|
||||
const frontmatter = this.frontmatter()
|
||||
|
||||
const result = Promise.all([
|
||||
// @TODO: this stat should be passed from the readdir function, not done twice
|
||||
stat(file),
|
||||
readFile(file)
|
||||
])
|
||||
.then(([stats, buffer]) => {
|
||||
let ret = {}
|
||||
if (frontmatter && utf8(buffer)) {
|
||||
try {
|
||||
const parsed = matter(buffer.toString(), this._frontmatter)
|
||||
ret = parsed.data
|
||||
if (parsed.excerpt) {
|
||||
ret.excerpt = parsed.excerpt
|
||||
}
|
||||
ret.contents = Buffer.from(parsed.content)
|
||||
} catch (e) {
|
||||
const err = new Error('Invalid frontmatter in the file at: ' + file)
|
||||
err.code = 'invalid_frontmatter'
|
||||
return Promise.reject(err)
|
||||
}
|
||||
} else {
|
||||
ret.contents = buffer
|
||||
}
|
||||
ret.mode = Mode(stats).toOctal()
|
||||
ret.stats = stats
|
||||
return ret
|
||||
})
|
||||
.catch((e) => {
|
||||
if (e.code == 'invalid_frontmatter') return Promise.reject(e)
|
||||
e.message = 'Failed to read the file at: ' + file + '\n\n' + e.message
|
||||
e.code = 'failed_read'
|
||||
return Promise.reject(e)
|
||||
})
|
||||
|
||||
if (isFunction(callback)) {
|
||||
result.then(
|
||||
(file) => callback(null, file),
|
||||
(err) => callback(err)
|
||||
)
|
||||
} else {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a dictionary of `files` to a destination `dir`. If no directory is
|
||||
* provided, it will default to the destination directory.
|
||||
*
|
||||
* @method Metalsmith#write
|
||||
* @package
|
||||
* @param {Files} files
|
||||
* @param {string} [dir]
|
||||
* @returns {Promise<null>|void}
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.write = function (files, dir, callback) {
|
||||
/* block required for Metalsmith 2.x callback-flow compat */
|
||||
const last = arguments[arguments.length - 1]
|
||||
callback = isFunction(last) ? last : undefined
|
||||
dir = dir && !isFunction(dir) ? dir : this.destination()
|
||||
|
||||
const write = this.writeFile.bind(this)
|
||||
const concurrency = this.concurrency()
|
||||
const keys = Object.keys(files)
|
||||
|
||||
const operation = batchAsync(
|
||||
(key) => {
|
||||
return write(key, files[key])
|
||||
},
|
||||
keys,
|
||||
concurrency
|
||||
)
|
||||
|
||||
/* block required for Metalsmith 2.x callback-flow compat */
|
||||
if (callback) {
|
||||
operation.then(() => callback(null), callback)
|
||||
} else {
|
||||
return operation
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a `file` by path with `data`. If the path is not absolute, it will be
|
||||
* resolved relative to the destination directory.
|
||||
*
|
||||
* @method Metalsmith#writeFile
|
||||
* @package
|
||||
* @param {string} file
|
||||
* @param {File} data
|
||||
* @returns {Promise<void>|void}
|
||||
*/
|
||||
|
||||
Metalsmith.prototype.writeFile = function (file, data, callback) {
|
||||
const dest = this.destination()
|
||||
if (!path.isAbsolute(file)) file = path.resolve(dest, file)
|
||||
|
||||
const result = outputFile(file, data.contents, data.mode).catch((e) => {
|
||||
e.code = 'failed_write'
|
||||
e.message = 'Failed to write the file at: ' + file + '\n\n' + e.message
|
||||
return Promise.reject(e)
|
||||
})
|
||||
|
||||
/* block required for Metalsmith 2.x callback-flow compat */
|
||||
if (callback) {
|
||||
result.then(callback, callback)
|
||||
} else {
|
||||
return result
|
||||
}
|
||||
}
|
||||
77
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/metalsmith-migrated-plugins.js
generated
vendored
Normal file
77
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/metalsmith-migrated-plugins.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
const { join } = require('path')
|
||||
const { readFile } = require('fs')
|
||||
const { isObject } = require('./lib/helpers')
|
||||
|
||||
const outdatedPlugins = [
|
||||
'markdown',
|
||||
'in-place',
|
||||
'layouts',
|
||||
'collections',
|
||||
'drafts',
|
||||
'ignore',
|
||||
'postcss',
|
||||
'permalinks',
|
||||
'default-values',
|
||||
'metadata',
|
||||
'excerpts',
|
||||
'autotoc'
|
||||
]
|
||||
|
||||
const renamedPlugins = {
|
||||
ignore: 'remove',
|
||||
autotoc: 'table-of-contents'
|
||||
}
|
||||
|
||||
// only provided when running npm scripts
|
||||
// otherwise default to working directory
|
||||
const projectDir = process.env.INIT_CWD || process.cwd()
|
||||
|
||||
// when reading package.json
|
||||
// always fail silently as to not interrupt the install DX
|
||||
readFile(join(projectDir, 'package.json'), 'utf-8', (err, data) => {
|
||||
if (err) return
|
||||
let parsed = false
|
||||
try {
|
||||
parsed = JSON.parse(data)
|
||||
} catch (err) {
|
||||
return
|
||||
}
|
||||
if (!parsed) return
|
||||
|
||||
const toCheck = []
|
||||
|
||||
if (isObject(parsed.devDependencies)) {
|
||||
toCheck.push.apply(toCheck, Object.keys(parsed.devDependencies))
|
||||
}
|
||||
if (isObject(parsed.dependencies)) {
|
||||
toCheck.push.apply(toCheck, Object.keys(parsed.dependencies))
|
||||
}
|
||||
|
||||
const pluginMap = toCheck.reduce((all, fullname) => {
|
||||
if (!fullname.startsWith('metalsmith-')) return all
|
||||
const name = fullname.replace(/^metalsmith-/, '')
|
||||
if (outdatedPlugins.includes(name)) {
|
||||
const newName = renamedPlugins[name] ? renamedPlugins[name] : name
|
||||
all[`metalsmith-${name}`] = `@metalsmith/${newName}`
|
||||
}
|
||||
return all
|
||||
}, {})
|
||||
|
||||
if (Object.keys(pluginMap).length) {
|
||||
process.stdout.write(
|
||||
`\x1b[43m\x1b[30m WARN \x1b[0m\x1b[49m\x1b[33m Metalsmith has detected deprecated core plugins that have moved to the @metalsmith org on NPM:\n\n`
|
||||
)
|
||||
Object.entries(pluginMap).forEach(([oldName, newName]) => {
|
||||
process.stdout.write(`· ${oldName} -> ${newName}\n`)
|
||||
})
|
||||
process.stdout.write(
|
||||
[
|
||||
'\nRun the commands below to migrate:',
|
||||
` npm remove ${Object.keys(pluginMap).join(' ')}`,
|
||||
` npm i ${Object.values(pluginMap).join(' ')}\n`,
|
||||
'For all available core plugins, see https://github.com/search?q=topic%3Ametalsmith-plugin+org%3Ametalsmith&type=Repositories',
|
||||
'\x1b[0m'
|
||||
].join('\n')
|
||||
)
|
||||
}
|
||||
})
|
||||
86
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/package.json
generated
vendored
Normal file
86
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/package.json
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"name": "metalsmith",
|
||||
"version": "2.5.1",
|
||||
"description": "An extremely simple, pluggable static site generator.",
|
||||
"keywords": [
|
||||
"static",
|
||||
"jamstack",
|
||||
"file",
|
||||
"site",
|
||||
"website",
|
||||
"blog",
|
||||
"generator",
|
||||
"markdown",
|
||||
"jekyll",
|
||||
"metalsmith",
|
||||
"yaml"
|
||||
],
|
||||
"homepage": "https://metalsmith.io",
|
||||
"bugs": "https://github.com/metalsmith/metalsmith/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/metalsmith/metalsmith.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"_metalsmith": "bin/_metalsmith",
|
||||
"metalsmith": "bin/metalsmith"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
"test": "test"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/index.js",
|
||||
"lib/debug.js",
|
||||
"lib/helpers.js",
|
||||
"metalsmith-migrated-plugins.js",
|
||||
"bin/**",
|
||||
"CHANGELOG.md",
|
||||
"snapcraft.yaml"
|
||||
],
|
||||
"scripts": {
|
||||
"coverage": "nyc report --reporter=text-lcov > ./coverage.info",
|
||||
"lint:check": "eslint --cache --fix-dry-run index.js lib/* bin/* test/*.js",
|
||||
"lint": "eslint --fix index.js lib/* bin/* test/*.js",
|
||||
"format:check": "prettier --list-different \"**/*.{yml,md,js,json}\"",
|
||||
"format": "prettier --write \"**/*.{yml,md,js,json}\"",
|
||||
"test": "nyc mocha",
|
||||
"release": "release-it",
|
||||
"postinstall": "node metalsmith-migrated-plugins.js || exit 0"
|
||||
},
|
||||
"mocha": {
|
||||
"reporter": "spec",
|
||||
"slow": 500,
|
||||
"timeout": 3000
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": "^6.2.1",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"debug": "^4.3.4",
|
||||
"gray-matter": "^4.0.3",
|
||||
"is-utf8": "~0.2.0",
|
||||
"micromatch": "^4.0.5",
|
||||
"rimraf": "^3.0.2",
|
||||
"stat-mode": "^1.0.0",
|
||||
"ware": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@metalsmith/drafts": "^1.2.0",
|
||||
"@metalsmith/markdown": "^1.5.0",
|
||||
"assert-dir-equal": "^1.1.0",
|
||||
"eslint": "^8.24.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"mocha": "^9.2.2",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier": "^2.7.1",
|
||||
"release-it": "^15.5.0",
|
||||
"toml": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
21
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/snapcraft.yaml
generated
vendored
Normal file
21
.yarn/unplugged/metalsmith-npm-2.5.1-131e5add51/node_modules/metalsmith/snapcraft.yaml
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: metalsmith
|
||||
version: master
|
||||
summary: An extremely simple, pluggable static site generator
|
||||
description: |
|
||||
Metalsmith works in three simple steps:
|
||||
1. Read all the files in a source directory.
|
||||
2. Invoke a series of plugins that manipulate the files.
|
||||
3. Write the results to a destination directory!
|
||||
|
||||
grade: devel
|
||||
confinement: strict
|
||||
|
||||
apps:
|
||||
metalsmith:
|
||||
command: metalsmith
|
||||
plugs: [home]
|
||||
|
||||
parts:
|
||||
metalsmith:
|
||||
source: .
|
||||
plugin: nodejs
|
||||
Reference in New Issue
Block a user