@wirecat/notion-cli 0.0.0-stage → 0.2.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.
- package/CHANGELOG.md +73 -0
- package/LICENSE +204 -0
- package/README.md +42 -2
- package/contracts/wirecat.json +1964 -0
- package/dist/bin/notion.d.ts +3 -0
- package/dist/bin/notion.d.ts.map +1 -0
- package/dist/bin/notion.js +40 -0
- package/dist/bin/notion.js.map +1 -0
- package/dist/bundle/all-profiles-JGYLQZ5C.js +278 -0
- package/dist/bundle/anthropic-S2VSMIKQ.js +91 -0
- package/dist/bundle/app-server-SASYDBCA.js +240 -0
- package/dist/bundle/bun-LU5LP3JI.js +169 -0
- package/dist/bundle/bun-sqlite-JBSINB4O.js +76 -0
- package/dist/bundle/chunk-22QQUKWA.js +53 -0
- package/dist/bundle/chunk-2F4QQ7WB.js +73 -0
- package/dist/bundle/chunk-2F6VO5HA.js +73 -0
- package/dist/bundle/chunk-2LWO3PDX.js +726 -0
- package/dist/bundle/chunk-3AL7QUS3.js +2778 -0
- package/dist/bundle/chunk-3Z4YTSRY.js +731 -0
- package/dist/bundle/chunk-4HWJOU7N.js +38 -0
- package/dist/bundle/chunk-4IPURN72.js +1221 -0
- package/dist/bundle/chunk-4ZTVJHWU.js +206 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5IYKVRH2.js +44811 -0
- package/dist/bundle/chunk-5NFK5EM2.js +362 -0
- package/dist/bundle/chunk-5QIQEUOG.js +188 -0
- package/dist/bundle/chunk-5RDNBG7D.js +72 -0
- package/dist/bundle/chunk-5RSC54NA.js +1328 -0
- package/dist/bundle/chunk-6EVKHZKN.js +158 -0
- package/dist/bundle/chunk-6RA3EABS.js +4012 -0
- package/dist/bundle/chunk-AOCUKEAX.js +131 -0
- package/dist/bundle/chunk-B26TQZKZ.js +217 -0
- package/dist/bundle/chunk-B7ON6KPT.js +1197 -0
- package/dist/bundle/chunk-BNPTZ5ZB.js +161 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-D7QSEEYW.js +274 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DH5PRHT4.js +392 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-EUIVXFLJ.js +259 -0
- package/dist/bundle/chunk-FPY6EJ7B.js +9568 -0
- package/dist/bundle/chunk-FT3LN3HP.js +6848 -0
- package/dist/bundle/chunk-FWVBPRL4.js +4436 -0
- package/dist/bundle/chunk-FXEJY4OL.js +12538 -0
- package/dist/bundle/chunk-G3EZFRSS.js +1297 -0
- package/dist/bundle/chunk-GZOUFX3C.js +230 -0
- package/dist/bundle/chunk-HL52XXZX.js +78 -0
- package/dist/bundle/chunk-KCLOUUYF.js +100 -0
- package/dist/bundle/chunk-KFVDL2QS.js +146 -0
- package/dist/bundle/chunk-KGERXYTV.js +24 -0
- package/dist/bundle/chunk-KM6WHPHI.js +288 -0
- package/dist/bundle/chunk-LAYPFBOM.js +95 -0
- package/dist/bundle/chunk-LLG2POQ7.js +170 -0
- package/dist/bundle/chunk-M3KB25D3.js +1392 -0
- package/dist/bundle/chunk-M7S2NDWB.js +76 -0
- package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
- package/dist/bundle/chunk-MY742GAD.js +1977 -0
- package/dist/bundle/chunk-MZU2YFBZ.js +823 -0
- package/dist/bundle/chunk-NOQ7B5N7.js +58 -0
- package/dist/bundle/chunk-NQWV4WQO.js +300 -0
- package/dist/bundle/chunk-ODBZNSZ6.js +1028 -0
- package/dist/bundle/chunk-OTV53F34.js +370 -0
- package/dist/bundle/chunk-P7CUM5IB.js +18 -0
- package/dist/bundle/chunk-RV64YUQX.js +185 -0
- package/dist/bundle/chunk-SHJQ6JKG.js +106 -0
- package/dist/bundle/chunk-SWAOWNKW.js +52 -0
- package/dist/bundle/chunk-SZOVLP44.js +29 -0
- package/dist/bundle/chunk-TPX2M45D.js +385 -0
- package/dist/bundle/chunk-TSDBSIFM.js +66 -0
- package/dist/bundle/chunk-VBHETQVV.js +64146 -0
- package/dist/bundle/chunk-VCIALTEM.js +3139 -0
- package/dist/bundle/chunk-VKE77B3F.js +2 -0
- package/dist/bundle/chunk-WCSOH4JS.js +142 -0
- package/dist/bundle/chunk-WF4D56CA.js +54 -0
- package/dist/bundle/chunk-WJHZMR2W.js +335 -0
- package/dist/bundle/chunk-X4TIMMKJ.js +16 -0
- package/dist/bundle/chunk-XF26XKTS.js +82 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-XYIT2XB3.js +1372 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YMYUBZWT.js +1068 -0
- package/dist/bundle/chunk-YNTLT3Z3.js +2310 -0
- package/dist/bundle/chunk-YVI5SQPY.js +46 -0
- package/dist/bundle/chunk-Z56QFOBR.js +63 -0
- package/dist/bundle/chunk-ZKAEZXUP.js +787 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/chunk-ZZ32DXTH.js +23 -0
- package/dist/bundle/command-contract-JS5V27NX.js +38 -0
- package/dist/bundle/command-server-entry-UFSG7KRO.js +167 -0
- package/dist/bundle/decode-7LLWTSPT.js +297 -0
- package/dist/bundle/definitions-M3U4UYHN.js +45607 -0
- package/dist/bundle/dispatch-2GY6JIJH.js +411 -0
- package/dist/bundle/dist-ILNOLGYN.js +7577 -0
- package/dist/bundle/echarts-BXX4OQWC.js +42501 -0
- package/dist/bundle/embed-JXFNBTKH.js +38 -0
- package/dist/bundle/embedder-57YZ44KO.js +111 -0
- package/dist/bundle/failure-MYT4HPE3.js +25 -0
- package/dist/bundle/first-run-3PF7T74J.js +29 -0
- package/dist/bundle/first-screen-7BEROEQR.js +36 -0
- package/dist/bundle/instructions-2VECIDXF.js +11 -0
- package/dist/bundle/mcp-O6ACR2DX.js +167 -0
- package/dist/bundle/mdast-util-from-markdown-R66F4HZA.js +1958 -0
- package/dist/bundle/mdast-util-gfm-LN2ELINH.js +2699 -0
- package/dist/bundle/meeting-combined-PPUQ3KBR.js +24 -0
- package/dist/bundle/meeting-model-ZNMYKMCD.js +26 -0
- package/dist/bundle/meeting-semantic-ETN3A4BJ.js +22 -0
- package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-MPEQSFI3.js +176 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-WA32MYSJ.js +74 -0
- package/dist/bundle/notion.js +185 -0
- package/dist/bundle/oauth-IAFZG3IR.js +20 -0
- package/dist/bundle/open-M3JQUC5G.js +23 -0
- package/dist/bundle/openai-HXUEHUSD.js +240 -0
- package/dist/bundle/process-F6TKXWWA.js +91 -0
- package/dist/bundle/program-Y7JAB6TG.js +33219 -0
- package/dist/bundle/prompt-IMUQLZD2.js +17 -0
- package/dist/bundle/recognize-2MZAYHAA.js +26 -0
- package/dist/bundle/remote-OV4LB6VR.js +32 -0
- package/dist/bundle/rerank-ZIULUS34.js +52 -0
- package/dist/bundle/schemas-DIVZS6TU.js +12214 -0
- package/dist/bundle/serve-YU7QBP6L.js +199 -0
- package/dist/bundle/server-FKQET4ZO.js +71 -0
- package/dist/bundle/server-LGMNONSB.js +202 -0
- package/dist/bundle/services-5WY4DCPJ.js +581 -0
- package/dist/bundle/sqlite-runtime-5MXZDETH.js +20 -0
- package/dist/bundle/state-LWMZH2KI.js +36 -0
- package/dist/bundle/store-EPZYV4VW.js +168 -0
- package/dist/bundle/store-QE6FEIZD.js +286 -0
- package/dist/bundle/store-maintenance-command-ZUUUFCHL.js +62 -0
- package/dist/commands/api.d.ts +4 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +140 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/databases.d.ts +3 -0
- package/dist/commands/databases.d.ts.map +1 -0
- package/dist/commands/databases.js +65 -0
- package/dist/commands/databases.js.map +1 -0
- package/dist/commands/documents.d.ts +4 -0
- package/dist/commands/documents.d.ts.map +1 -0
- package/dist/commands/documents.js +41 -0
- package/dist/commands/documents.js.map +1 -0
- package/dist/commands/library.d.ts +10 -0
- package/dist/commands/library.d.ts.map +1 -0
- package/dist/commands/library.js +468 -0
- package/dist/commands/library.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +105 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +51 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +67 -0
- package/dist/context.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +45603 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +3 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +2089 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/metadata.d.ts +6 -0
- package/dist/generated/metadata.d.ts.map +1 -0
- package/dist/generated/metadata.js +24 -0
- package/dist/generated/metadata.js.map +1 -0
- package/dist/generated/schemas.d.ts +1223 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +11557 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +11120 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/identity.d.ts +7 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +30 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge.d.ts +27 -0
- package/dist/knowledge.d.ts.map +1 -0
- package/dist/knowledge.js +87 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/library.d.ts +44 -0
- package/dist/library.d.ts.map +1 -0
- package/dist/library.js +149 -0
- package/dist/library.js.map +1 -0
- package/dist/notion/client.d.ts +45 -0
- package/dist/notion/client.d.ts.map +1 -0
- package/dist/notion/client.js +121 -0
- package/dist/notion/client.js.map +1 -0
- package/dist/notion/errors.d.ts +24 -0
- package/dist/notion/errors.d.ts.map +1 -0
- package/dist/notion/errors.js +127 -0
- package/dist/notion/errors.js.map +1 -0
- package/dist/notion/ids.d.ts +7 -0
- package/dist/notion/ids.d.ts.map +1 -0
- package/dist/notion/ids.js +37 -0
- package/dist/notion/ids.js.map +1 -0
- package/dist/notion/links.d.ts +6 -0
- package/dist/notion/links.d.ts.map +1 -0
- package/dist/notion/links.js +22 -0
- package/dist/notion/links.js.map +1 -0
- package/dist/notion/notion.d.ts +95 -0
- package/dist/notion/notion.d.ts.map +1 -0
- package/dist/notion/notion.js +269 -0
- package/dist/notion/notion.js.map +1 -0
- package/dist/notion/port.d.ts +13 -0
- package/dist/notion/port.d.ts.map +1 -0
- package/dist/notion/port.js +60 -0
- package/dist/notion/port.js.map +1 -0
- package/dist/notion/read-posts.d.ts +36 -0
- package/dist/notion/read-posts.d.ts.map +1 -0
- package/dist/notion/read-posts.js +24 -0
- package/dist/notion/read-posts.js.map +1 -0
- package/dist/notion/reads.d.ts +331 -0
- package/dist/notion/reads.d.ts.map +1 -0
- package/dist/notion/reads.js +18 -0
- package/dist/notion/reads.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +62 -0
- package/dist/program.js.map +1 -0
- package/dist/sync/cursor.d.ts +135 -0
- package/dist/sync/cursor.d.ts.map +1 -0
- package/dist/sync/cursor.js +113 -0
- package/dist/sync/cursor.js.map +1 -0
- package/dist/sync/files.d.ts +77 -0
- package/dist/sync/files.d.ts.map +1 -0
- package/dist/sync/files.js +12 -0
- package/dist/sync/files.js.map +1 -0
- package/dist/sync/front-matter.d.ts +10 -0
- package/dist/sync/front-matter.d.ts.map +1 -0
- package/dist/sync/front-matter.js +114 -0
- package/dist/sync/front-matter.js.map +1 -0
- package/dist/sync/markdown.d.ts +11 -0
- package/dist/sync/markdown.d.ts.map +1 -0
- package/dist/sync/markdown.js +42 -0
- package/dist/sync/markdown.js.map +1 -0
- package/dist/sync/source.d.ts +11 -0
- package/dist/sync/source.d.ts.map +1 -0
- package/dist/sync/source.js +995 -0
- package/dist/sync/source.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/package.json +85 -4
- package/skills/notion-cli/SKILL.md +45 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
singleLine
|
|
5
|
+
} from "./chunk-5RDNBG7D.js";
|
|
6
|
+
import {
|
|
7
|
+
__name
|
|
8
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
9
|
+
|
|
10
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/names.js
|
|
11
|
+
var FIRST_PARTY_TOOLS = [
|
|
12
|
+
{ name: "tg", package: "@wirecat/tg-cli" },
|
|
13
|
+
{ name: "max", package: "@wirecat/max-cli" },
|
|
14
|
+
{ name: "wa", package: "@wirecat/whatsapp-cli" },
|
|
15
|
+
{ name: "zm", package: "@wirecat/zoom-cli" },
|
|
16
|
+
{ name: "drive", package: "@wirecat/drive-cli" },
|
|
17
|
+
{ name: "memo", package: "@wirecat/cli-memo" },
|
|
18
|
+
{ name: "mail", package: "@wirecat/mail-cli" },
|
|
19
|
+
// memo reads email today; the name is held for a tool of its own.
|
|
20
|
+
{ name: "email" }
|
|
21
|
+
];
|
|
22
|
+
var BUILT_IN_COMMANDS = ["help", "version", "shortcuts", "doctor", "update", "upgrade", "app"];
|
|
23
|
+
var RESERVED_NAMES = [
|
|
24
|
+
...FIRST_PARTY_TOOLS.map((tool) => tool.name),
|
|
25
|
+
...BUILT_IN_COMMANDS,
|
|
26
|
+
"wcat"
|
|
27
|
+
];
|
|
28
|
+
var TOOL_NAME = /^[a-z][a-z0-9-]{0,39}$/;
|
|
29
|
+
var PROGRAM_PREFIX = "wcat-";
|
|
30
|
+
var DESCRIBE_FLAG = "--wcat-describe";
|
|
31
|
+
var DESCRIBE_MAX_BYTES = 64 * 1024;
|
|
32
|
+
var DISPATCH_FLAG = "--wcat-dispatch";
|
|
33
|
+
|
|
34
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/describe.js
|
|
35
|
+
var DESCRIBE_FORMAT = 1;
|
|
36
|
+
var DESCRIBE_MANIFEST_FORMAT = 2;
|
|
37
|
+
var describeAnswer = /* @__PURE__ */ __name((tool, manifest) => {
|
|
38
|
+
const answer = {
|
|
39
|
+
wcat_describe: DESCRIBE_FORMAT,
|
|
40
|
+
name: tool.command,
|
|
41
|
+
version: tool.version,
|
|
42
|
+
description: tool.description,
|
|
43
|
+
...tool.docs ? { docs_url: tool.docs } : {}
|
|
44
|
+
};
|
|
45
|
+
if (!manifest)
|
|
46
|
+
return answer;
|
|
47
|
+
const full = {
|
|
48
|
+
...answer,
|
|
49
|
+
wcat_describe: DESCRIBE_MANIFEST_FORMAT,
|
|
50
|
+
desktop: manifest.desktop,
|
|
51
|
+
manifest_sha256: manifest.sha256
|
|
52
|
+
};
|
|
53
|
+
return Buffer.byteLength(`${JSON.stringify(full)}
|
|
54
|
+
`) > DESCRIBE_MAX_BYTES ? answer : full;
|
|
55
|
+
}, "describeAnswer");
|
|
56
|
+
var MAX_TEXT = 200;
|
|
57
|
+
var clean = /* @__PURE__ */ __name((value) => typeof value === "string" && value.trim() !== "" ? singleLine(value.trim()).slice(0, MAX_TEXT) : void 0, "clean");
|
|
58
|
+
var parseDescribe = /* @__PURE__ */ __name((text) => {
|
|
59
|
+
let answer;
|
|
60
|
+
try {
|
|
61
|
+
answer = JSON.parse(text);
|
|
62
|
+
} catch {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
if (typeof answer !== "object" || answer === null || !("wcat_describe" in answer))
|
|
66
|
+
return void 0;
|
|
67
|
+
const { version, description, docs_url: docs, manifest_sha256: sha } = answer;
|
|
68
|
+
const url = clean(docs);
|
|
69
|
+
return {
|
|
70
|
+
version: clean(version) ?? "",
|
|
71
|
+
description: clean(description) ?? "",
|
|
72
|
+
...url && /^https?:\/\//.test(url) ? { docs: url } : {},
|
|
73
|
+
...typeof sha === "string" && /^[0-9a-f]{64}$/.test(sha) ? { manifestSha256: sha } : {}
|
|
74
|
+
};
|
|
75
|
+
}, "parseDescribe");
|
|
76
|
+
|
|
77
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/shim.js
|
|
78
|
+
import { lstatSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
79
|
+
import { join } from "node:path";
|
|
80
|
+
var SHIM_FORMAT = 2;
|
|
81
|
+
var MARK = /^(?:#|REM) wirecat-shim (\d+) (launcher|shortcut) (\S+)\r?$/m;
|
|
82
|
+
var NOTE = {
|
|
83
|
+
launcher: "Written by @wirecat/cli-base. Any WireCat tool rewrites it when it breaks; it is safe to delete.",
|
|
84
|
+
shortcut: "Made by `wcat shortcuts add`; `wcat shortcuts remove` takes it out."
|
|
85
|
+
};
|
|
86
|
+
var shellQuote = /* @__PURE__ */ __name((text) => `'${text.replaceAll("'", `'\\''`)}'`, "shellQuote");
|
|
87
|
+
var launcherBody = /* @__PURE__ */ __name((dir, target, name) => [
|
|
88
|
+
'ok() { [ -f "$1" ] && [ -x "$1" ]; }',
|
|
89
|
+
`dir=${shellQuote(dir)}`,
|
|
90
|
+
`target=${shellQuote(join(dir, target))}`,
|
|
91
|
+
'if ! ok "$target"; then',
|
|
92
|
+
' for t in "$dir"/wcat-*; do',
|
|
93
|
+
' if ok "$t"; then target=$t; break; fi',
|
|
94
|
+
" done",
|
|
95
|
+
"fi",
|
|
96
|
+
`if ok "$target"; then exec "$target" ${DISPATCH_FLAG} "$@"; fi`,
|
|
97
|
+
'if [ -z "$WIRECAT_LAUNCHER_SKIP" ]; then',
|
|
98
|
+
" WIRECAT_LAUNCHER_SKIP=1; export WIRECAT_LAUNCHER_SKIP",
|
|
99
|
+
" set -f; oldifs=$IFS; IFS=:",
|
|
100
|
+
" for d in $PATH; do",
|
|
101
|
+
` if [ -n "$d" ] && [ "$d" != "$dir" ] && ok "$d/${name}"; then IFS=$oldifs; exec "$d/${name}" "$@"; fi`,
|
|
102
|
+
" done",
|
|
103
|
+
" IFS=$oldifs; set +f",
|
|
104
|
+
"fi",
|
|
105
|
+
`printf '%s\\n' "${name}: $target is missing and no other ${name}-* program was found in $dir or on PATH." \\`,
|
|
106
|
+
` "This launcher is safe to delete: $dir/${name}" >&2`,
|
|
107
|
+
"exit 127"
|
|
108
|
+
], "launcherBody");
|
|
109
|
+
var shimFiles = /* @__PURE__ */ __name((kind, { dir, name, target, platform }) => {
|
|
110
|
+
const mark = `wirecat-shim ${SHIM_FORMAT} ${kind} ${target}`;
|
|
111
|
+
const extra = kind === "launcher" ? ` ${DISPATCH_FLAG}` : "";
|
|
112
|
+
if (platform !== "win32")
|
|
113
|
+
return [
|
|
114
|
+
{
|
|
115
|
+
path: join(dir, name),
|
|
116
|
+
text: [
|
|
117
|
+
"#!/bin/sh",
|
|
118
|
+
`# ${mark}`,
|
|
119
|
+
`# ${NOTE[kind]}`,
|
|
120
|
+
...kind === "launcher" ? launcherBody(dir, target, name) : [`exec ${shellQuote(join(dir, target))} "$@"`],
|
|
121
|
+
""
|
|
122
|
+
].join("\n")
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
return [
|
|
126
|
+
{
|
|
127
|
+
path: join(dir, `${name}.cmd`),
|
|
128
|
+
text: ["@ECHO off", `REM ${mark}`, `REM ${NOTE[kind]}`, `"%~dp0${target}"${extra} %*`, ""].join("\r\n")
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
path: join(dir, `${name}.ps1`),
|
|
132
|
+
text: [
|
|
133
|
+
`# ${mark}`,
|
|
134
|
+
`# ${NOTE[kind]}`,
|
|
135
|
+
// PowerShell hands a .cmd its arguments unquoted, so `a&b` would run `b`; npm and pnpm write a .ps1 beside
|
|
136
|
+
// their .cmd, and it is started instead whenever it is there.
|
|
137
|
+
`$stem = Join-Path $PSScriptRoot "${target.replace(/\.(cmd|exe|bat)$/i, "")}"`,
|
|
138
|
+
`$target = if (Test-Path -LiteralPath "$stem.ps1") { "$stem.ps1" } else { Join-Path $PSScriptRoot "${target}" }`,
|
|
139
|
+
"if ($MyInvocation.ExpectingInput) {",
|
|
140
|
+
` $input | & $target${extra} @args`,
|
|
141
|
+
"} else {",
|
|
142
|
+
` & $target${extra} @args`,
|
|
143
|
+
"}",
|
|
144
|
+
"exit $LASTEXITCODE",
|
|
145
|
+
""
|
|
146
|
+
].join("\r\n")
|
|
147
|
+
}
|
|
148
|
+
];
|
|
149
|
+
}, "shimFiles");
|
|
150
|
+
var parseShim = /* @__PURE__ */ __name((text) => {
|
|
151
|
+
const found = MARK.exec(text.split("\n", 3).join("\n"));
|
|
152
|
+
if (!found)
|
|
153
|
+
return void 0;
|
|
154
|
+
return { format: Number(found[1]), kind: found[2], target: found[3] };
|
|
155
|
+
}, "parseShim");
|
|
156
|
+
var MAX_SHIM_BYTES = 4096;
|
|
157
|
+
var fileState = /* @__PURE__ */ __name((path) => {
|
|
158
|
+
let stat;
|
|
159
|
+
try {
|
|
160
|
+
stat = lstatSync(path);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
return error.code === "ENOENT" ? { state: "missing" } : { state: "foreign" };
|
|
163
|
+
}
|
|
164
|
+
if (!stat.isFile() || stat.size > MAX_SHIM_BYTES)
|
|
165
|
+
return { state: "foreign" };
|
|
166
|
+
try {
|
|
167
|
+
const text = readFileSync(path, "utf8");
|
|
168
|
+
const mark = parseShim(text);
|
|
169
|
+
return mark ? { state: "ours", mark, text } : { state: "foreign" };
|
|
170
|
+
} catch {
|
|
171
|
+
return { state: "foreign" };
|
|
172
|
+
}
|
|
173
|
+
}, "fileState");
|
|
174
|
+
var exists = /* @__PURE__ */ __name((path) => {
|
|
175
|
+
try {
|
|
176
|
+
return statSync(path).isFile();
|
|
177
|
+
} catch {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
}, "exists");
|
|
181
|
+
var writeShim = /* @__PURE__ */ __name(({ path, text }) => {
|
|
182
|
+
const temporary = `${path}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
183
|
+
try {
|
|
184
|
+
writeFileSync(temporary, text, { mode: 493 });
|
|
185
|
+
renameSync(temporary, path);
|
|
186
|
+
} finally {
|
|
187
|
+
rmSync(temporary, { force: true });
|
|
188
|
+
}
|
|
189
|
+
}, "writeShim");
|
|
190
|
+
|
|
191
|
+
export {
|
|
192
|
+
FIRST_PARTY_TOOLS,
|
|
193
|
+
BUILT_IN_COMMANDS,
|
|
194
|
+
TOOL_NAME,
|
|
195
|
+
PROGRAM_PREFIX,
|
|
196
|
+
DESCRIBE_FLAG,
|
|
197
|
+
DESCRIBE_MAX_BYTES,
|
|
198
|
+
DISPATCH_FLAG,
|
|
199
|
+
describeAnswer,
|
|
200
|
+
parseDescribe,
|
|
201
|
+
SHIM_FORMAT,
|
|
202
|
+
shimFiles,
|
|
203
|
+
fileState,
|
|
204
|
+
exists,
|
|
205
|
+
writeShim
|
|
206
|
+
};
|