···1+import { defineCommand, renderUsage, runMain } from "citty";
2+import consola from "consola";
3+import { colorize } from "consola/utils";
4+import { configCmd } from "./commands/config-cmd.ts";
5+import { syncCmd } from "./commands/sync-cmd.ts";
6+import { filesCmd } from "./commands/files-cmd.ts";
7+import { version } from "../package.json" with { type: "json" };
8+9+import dotenv from "dotenv";
10+if (!("Bun" in globalThis)) dotenv.config({ quiet: true });
11+12+const consolaOptions = consola.options;
13+consolaOptions.formatOptions.date = false;
14+consola.options = consolaOptions;
15+16+const main = defineCommand({
17+ meta: {
18+ name: "leaflet-md",
19+ version: version,
20+ description: "CLI tool to transplant (sync) your Markdown to Leaflet ",
21+ },
22+ subCommands: {
23+ sync: syncCmd,
24+ config: configCmd,
25+ files: filesCmd,
26+ },
27+});
28+29+runMain(main, {
30+ async showUsage(cmd, parent) {
31+ consola.log(
32+ colorize("green", colorize("bold", "Leaflet MD")) +
33+ " | " +
34+ colorize("dim", "CLI tool to transplant (sync) your Markdown to Leaflet")
35+ );
36+37+ const defaultUsage = await renderUsage(cmd, parent);
38+ const usageSplit = defaultUsage.split("\n");
39+40+ consola.log(usageSplit.slice(1, usageSplit.length).join("\n"));
41+ },
42+});
+1-2
src/commands/config-cmd.ts
···4import { colorize, leftAlign, type ColorName } from "consola/utils";
5import type { Config } from "../config";
6import type { Did } from "@atcute/lexicons";
7-import { exists } from "../utils.ts";
8-import { jiti } from "../index.ts";
910export const configCmd = defineCommand({
11 async run(context) {
···4import { colorize, leftAlign, type ColorName } from "consola/utils";
5import type { Config } from "../config";
6import type { Did } from "@atcute/lexicons";
7+import { exists, jiti } from "../utils.ts";
089export const configCmd = defineCommand({
10 async run(context) {
+1-2
src/commands/files-cmd.ts
···4import type { Config } from "../config";
5import { consola } from "consola";
6import { colorize } from "consola/utils";
7-import { readJson, exists } from "../utils";
8-import { jiti } from "../index.ts";
910const ListTypeValues = ["all", "uploaded", "to-upload", "not-found"] as const;
11type ListTypes = (typeof ListTypeValues)[number];
···4import type { Config } from "../config";
5import { consola } from "consola";
6import { colorize } from "consola/utils";
7+import { readJson, exists, jiti } from "../utils";
089const ListTypeValues = ["all", "uploaded", "to-upload", "not-found"] as const;
10type ListTypes = (typeof ListTypeValues)[number];
+1-2
src/commands/sync-cmd.ts
···20import { generateDoc } from "../doc.ts";
21import yoctoSpinner from "yocto-spinner";
22import { consola } from "consola";
23-import { exists, readJson } from "../utils.ts";
24-import { jiti } from "../index.ts";
25import { parse } from "yaml";
2627export const syncCmd = defineCommand({
···20import { generateDoc } from "../doc.ts";
21import yoctoSpinner from "yocto-spinner";
22import { consola } from "consola";
23+import { exists, readJson, jiti } from "../utils.ts";
024import { parse } from "yaml";
2526export const syncCmd = defineCommand({
+1-45
src/index.ts
···1-import { defineCommand, renderUsage, runMain } from "citty";
2-import consola from "consola";
3-import { colorize } from "consola/utils";
4-import { configCmd } from "./commands/config-cmd.ts";
5-import { syncCmd } from "./commands/sync-cmd.ts";
6-import { filesCmd } from "./commands/files-cmd.ts";
7-import { version } from "../package.json" with { type: "json" };
8-import { createJiti } from "jiti";
9-10-import dotenv from "dotenv";
11-if (!("Bun" in globalThis)) dotenv.config({ quiet: true });
12-13-const consolaOptions = consola.options;
14-consolaOptions.formatOptions.date = false;
15-consola.options = consolaOptions;
16-17-export const jiti = createJiti(import.meta.url);
18-19-const main = defineCommand({
20- meta: {
21- name: "leaflet-md",
22- version: version,
23- description: "CLI tool to transplant (sync) your Markdown to Leaflet ",
24- },
25- subCommands: {
26- sync: syncCmd,
27- config: configCmd,
28- files: filesCmd,
29- },
30-});
31-32-runMain(main, {
33- async showUsage(cmd, parent) {
34- consola.log(
35- colorize("green", colorize("bold", "Leaflet MD")) +
36- " | " +
37- colorize("dim", "CLI tool to transplant (sync) your Markdown to Leaflet")
38- );
39-40- const defaultUsage = await renderUsage(cmd, parent);
41- const usageSplit = defaultUsage.split("\n");
42-43- consola.log(usageSplit.slice(1, usageSplit.length).join("\n"));
44- },
45-});
···1+export * from "./config";
00000000000000000000000000000000000000000000
+3
src/utils.ts
···1import { readFile, access } from "node:fs/promises";
00023export async function exists(path: string | URL) {
4 try {
···1import { readFile, access } from "node:fs/promises";
2+import { createJiti } from "jiti";
3+4+export const jiti = createJiti(import.meta.url);
56export async function exists(path: string | URL) {
7 try {