@kokiito0926/fmeditor 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -0
  3. package/index.js +34 -0
  4. package/package.json +43 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Koki Ito
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ ## fmeditor
2
+
3
+ fmeditorは、フロントマターを編集することができるコマンドラインのツールです。
4
+ 標準入力からマークダウンを受け取り、フロントマターのフィールドをコマンドライン引数から編集することができます。
5
+
6
+ ## インストール
7
+
8
+ ```bash
9
+ $ npm install --global @kokiito0926/fmeditor
10
+ ```
11
+
12
+ ## 使用方法
13
+
14
+ curlなどで取得したマークダウンをパイプでfmeditorに流し込みます。
15
+
16
+ ```bash
17
+ $ curl -fsSL https://raw.githubusercontent.com/Kernix13/markdown-cheatsheet/refs/heads/master/frontmatter.md | fmeditor --draft true
18
+ ```
19
+
20
+ ```bash
21
+ $ curl -fsSL https://raw.githubusercontent.com/Kernix13/markdown-cheatsheet/refs/heads/master/frontmatter.md | fmeditor --tags '["markdown", "frontmatter", "yaml"]'
22
+ ```
23
+
24
+ ## ライセンス
25
+
26
+ [MIT](LICENSE)
package/index.js ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ // >> $ curl -fsSL https://raw.githubusercontent.com/Kernix13/markdown-cheatsheet/refs/heads/master/frontmatter.md | ./index.js --draft true
4
+ // >> $ curl -fsSL https://raw.githubusercontent.com/Kernix13/markdown-cheatsheet/refs/heads/master/frontmatter.md | ./index.js --tags '["markdown", "frontmatter", "yaml"]'
5
+
6
+ import { stdin, argv } from "zx";
7
+ import matter from "gray-matter";
8
+
9
+ if (process.stdin.isTTY) {
10
+ process.exit(1);
11
+ }
12
+
13
+ const input = await stdin();
14
+ if (!input) {
15
+ process.exit(1);
16
+ }
17
+
18
+ const { _, ...flags } = argv;
19
+
20
+ const processedData = {};
21
+ for (const [key, value] of Object.entries(flags)) {
22
+ try {
23
+ processedData[key] = JSON.parse(value);
24
+ } catch (err) {
25
+ processedData[key] = value;
26
+ }
27
+ }
28
+
29
+ const doc = matter(input || "");
30
+
31
+ doc.data = { ...doc.data, ...processedData };
32
+
33
+ const text = matter.stringify(doc.content, doc.data);
34
+ console.log(text);
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@kokiito0926/fmeditor",
3
+ "version": "0.0.0",
4
+ "private": false,
5
+ "description": "フロントマターを編集することができるコマンドラインのツールです。",
6
+ "keywords": [
7
+ "cli",
8
+ "bash",
9
+ "shell",
10
+ "script",
11
+ "nodejs",
12
+ "fmeditor",
13
+ "markdown",
14
+ "frontmatter"
15
+ ],
16
+ "homepage": "https://github.com/kokiito0926/fmeditor#readme",
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "bin": {
21
+ "fmeditor": "index.js"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/kokiito0926/fmeditor/issues"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/kokiito0926/fmeditor.git"
29
+ },
30
+ "license": "MIT",
31
+ "author": "Koki Ito <kokiito0926@gmail.com>",
32
+ "type": "module",
33
+ "scripts": {
34
+ "test": "node --test"
35
+ },
36
+ "dependencies": {
37
+ "zx": "^8.8.4",
38
+ "gray-matter": "^4.0.3"
39
+ },
40
+ "engines": {
41
+ "node": ">=24.0.0"
42
+ }
43
+ }