yanki 0.2.2 → 0.2.3
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.
- package/dist/bin/cli.js +1 -1
- package/package.json +3 -3
- package/readme.md +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var $=Object.defineProperty;var u=(e,t)=>$(e,"name",{value:t,configurable:!0});import{y as P,u as y,k as Y,i as J,l as L,b as D,c as M,f as T,s as U,g as I}from"../sync-CNzgYCr4.js";import i from"chalk";import{globby as F}from"globby";import H from"node:fs/promises";import j from"node:path";import z from"node:os";import W from"yargs";import{hideBin as q}from"yargs/helpers";import"rehype-mathjax";var B="0.2.
|
|
2
|
+
var $=Object.defineProperty;var u=(e,t)=>$(e,"name",{value:t,configurable:!0});import{y as P,u as y,k as Y,i as J,l as L,b as D,c as M,f as T,s as U,g as I}from"../sync-CNzgYCr4.js";import i from"chalk";import{globby as F}from"globby";import H from"node:fs/promises";import j from"node:path";import z from"node:os";import W from"yargs";import{hideBin as q}from"yargs/helpers";import"rehype-mathjax";var B="0.2.3";const C=process?.versions?.node!==void 0,p={verbose:!1,log(...e){if(!this.verbose)return;const t=i.gray("[Log]");C?console.warn(t,...e):console.log(t,...e)},logPrefixed(e,...t){this.info(i.blue(`[${e}]`),...t)},info(...e){if(!this.verbose)return;const t=i.green("[Info]");C?console.warn(t,...e):console.info(t,...e)},infoPrefixed(e,...t){this.info(i.blue(`[${e}]`),...t)},warn(...e){console.warn(i.yellow("[Warning]"),...e)},warnPrefixed(e,...t){this.warn(i.blue(`[${e}]`),...t)},error(...e){console.error(i.red("[Error]"),...e)},errorPrefixed(e,...t){this.error(i.blue(`[${e}]`),...t)}},h={"anki-auto-launch":{alias:"l",default:!1,describe:"Attempt to open the Anki desktop app if it's not already running. (Experimental, macOS only.)",type:"boolean"}},b={"anki-web":{alias:"w",default:!0,describe:'Automatically sync any changes to AnkiWeb after Yanki has finished syncing locally. If false, only local Anki data is updated and you must manually invoke a sync to AnkiWeb. This is the equivalent of pushing the "sync" button in the Anki app.',type:"boolean"}},k={"anki-connect":{default:"http://127.0.0.1:8765",describe:"Host and port of the Anki-Connect server. The default is usually fine. See the Anki-Connect documentation for more information.",type:"string"}},v={verbose:{default:!1,describe:"Enable verbose logging.",type:"boolean"}};function w(e){return{json:{default:!1,describe:e,type:"boolean"}}}u(w,"jsonOption");const S={"dry-run":{alias:"d",default:!1,describe:"Run without making any changes to the Anki database. See a report of what would have been done.",type:"boolean"}};function A(e){return{namespace:{alias:"n",default:P,describe:e,type:"string"}}}u(A,"namespaceOption");const N=z.homedir();function G(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return N?e.replace(/^~(?=$|\/|\\)/,N):e}u(G,"untildify");const g=u(e=>{const{code:t}=e.cause;throw t==="ECONNREFUSED"&&(p.error("Failed to connect to Anki. Make sure Anki is running and AnkiConnect is installed."),process.exitCode=1,process.exit()),e instanceof Error?e:new Error("Unknown error")},"ankiNotRunningErrorHandler"),x=W(q(process.argv));await x.scriptName("yanki").usage("$0 [command]","Run a Yanki command. Defaults to `sync` if a command is not provided.").command(["$0 <directory> [options]","sync <directory> [options]"],"Perform a one-way synchronization from a local directory of Markdown files to the Anki database. Any Markdown files in subdirectories are included as well.",e=>e.positional("directory",{demandOption:!0,describe:"The path to the local directory of Markdown files to sync.",type:"string"}).option(S).option(A("Advanced option for managing multiple Yanki synchronization groups. Case insensitive. See the readme for more information.")).option(k).option(h).option(b).option(w("Output the sync report as JSON.")).option(v),async({ankiAutoLaunch:e,ankiConnect:t,ankiWeb:r,directory:o,dryRun:a,json:c,namespace:s,recursive:f=!0,verbose:l})=>{p.verbose=l;const n=G(o),m=f?`${n}/**/*.md`:`${n}/*.md`,d=await F(m,{absolute:!0});if(d.length===0){p.error(`No Markdown files found in "${n}".`),process.exitCode=1;return}const{host:R,port:E}=y(t),O=await Y(d,{ankiConnectOptions:{autoLaunch:e,host:R,port:E},ankiWeb:r,dryRun:a,namespace:s}).catch(g);c?(process.stdout.write(JSON.stringify(O,void 0,2)),process.stdout.write(`
|
|
3
3
|
`)):(process.stderr.write(J(O,l)),process.stderr.write(`
|
|
4
4
|
`))}).command("list [options]","Utility command to list Yanki-created notes in the Anki database.",e=>e.option(A("Advanced option to list notes in a specific namespace. Case insensitive. Notes from the default internal namespace are listed by default. Pass `'*'` to list all Yanki-created notes in the Anki database.")).options(k).options(h).option(w("Output the list of notes as JSON to stdout.")),async({ankiAutoLaunch:e,ankiConnect:t,json:r,namespace:o})=>{const{host:a,port:c}=y(t),s=await L({ankiConnectOptions:{autoLaunch:e,host:a,port:c},namespace:o}).catch(g);r?(process.stdout.write(JSON.stringify(s,void 0,2)),process.stdout.write(`
|
|
5
5
|
`)):(process.stdout.write(D(s)),process.stdout.write(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yanki",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "An ultra-simple CLI tool and TypeScript library for syncing Markdown to Anki flashcards.",
|
|
6
6
|
"repository": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"remark-wiki-link": "^2.0.1",
|
|
83
83
|
"sort-keys": "^5.0.0",
|
|
84
84
|
"string-strip-html": "^13.4.8",
|
|
85
|
-
"tsx": "^4.
|
|
85
|
+
"tsx": "^4.13.0",
|
|
86
86
|
"type-fest": "^4.19.0",
|
|
87
87
|
"typescript": "^5.4.5",
|
|
88
88
|
"unified": "^11.0.4",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"vite": "^5.2.12",
|
|
93
93
|
"vitest": "^1.6.0",
|
|
94
94
|
"yaml": "^2.4.3",
|
|
95
|
-
"yanki-connect": "^1.0.
|
|
95
|
+
"yanki-connect": "^1.0.3"
|
|
96
96
|
},
|
|
97
97
|
"publishConfig": {
|
|
98
98
|
"access": "public"
|
package/readme.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
Yanki simply syncs a folder of Markdown notes to Anki. The primary novelty of its approach is in how Markdown is translated into Anki notes. The **structure** of a Markdown note determines the **type** of Anki note it becomes, so no extra syntax or Anki-specific markup is required — just pure Markdown.
|
|
28
28
|
|
|
29
|
-
This library leverages the [`yanki-connect`](https://github.com/kitschpatrol/yanki-connect) library, and powers the
|
|
29
|
+
This library leverages the [`yanki-connect`](https://github.com/kitschpatrol/yanki-connect) library, and powers the [`yanki-obsidian`](https://github.com/kitschpatrol/yanki-obsidian) plugin.
|
|
30
30
|
|
|
31
31
|
The "Y" prefix in "Yanki" is in the "Yet another" naming tradition; a nod to Anki's robust and occasionally duplicative ecosystem of third-party tools. (Also, appropriately, Yankī are a variety of [truant youth](https://en.wikipedia.org/wiki/Yankee#/media/File:ヤンキー.jpg).)
|
|
32
32
|
|