@robinpath/cli 1.87.0 → 1.89.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/dist/cli.mjs +276 -146
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -18561,7 +18561,7 @@ var init_modules = __esm({
|
|
|
18561
18561
|
});
|
|
18562
18562
|
|
|
18563
18563
|
// src/index.ts
|
|
18564
|
-
import { readFileSync as
|
|
18564
|
+
import { readFileSync as readFileSync15, existsSync as existsSync16 } from "node:fs";
|
|
18565
18565
|
import { resolve as resolve12, extname as extname5, basename as basename8 } from "node:path";
|
|
18566
18566
|
|
|
18567
18567
|
// src/runtime.ts
|
|
@@ -18598,7 +18598,7 @@ function getNativeModules() {
|
|
|
18598
18598
|
import { join as join3, basename as basename2 } from "node:path";
|
|
18599
18599
|
import { homedir as homedir2, platform as platform2 } from "node:os";
|
|
18600
18600
|
import { existsSync as existsSync2 } from "node:fs";
|
|
18601
|
-
var CLI_VERSION = true ? "1.
|
|
18601
|
+
var CLI_VERSION = true ? "1.89.0" : "1.89.0";
|
|
18602
18602
|
var FLAG_QUIET = false;
|
|
18603
18603
|
var FLAG_VERBOSE = false;
|
|
18604
18604
|
var FLAG_AUTO_ACCEPT = false;
|
|
@@ -24251,8 +24251,10 @@ function Markdown({ children }) {
|
|
|
24251
24251
|
}
|
|
24252
24252
|
|
|
24253
24253
|
// src/ink-repl.tsx
|
|
24254
|
-
import { platform as platform7 } from "node:os";
|
|
24254
|
+
import { homedir as homedir8, platform as platform7 } from "node:os";
|
|
24255
24255
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
24256
|
+
import { existsSync as existsSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "node:fs";
|
|
24257
|
+
import { join as join12 } from "node:path";
|
|
24256
24258
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
24257
24259
|
var nextId = 0;
|
|
24258
24260
|
var COMMANDS = {
|
|
@@ -24271,7 +24273,7 @@ var COMMANDS = {
|
|
|
24271
24273
|
"/shell": "Switch shell",
|
|
24272
24274
|
"/help": "All commands"
|
|
24273
24275
|
};
|
|
24274
|
-
function InputArea({ onSubmit, placeholder }) {
|
|
24276
|
+
function InputArea({ onSubmit, placeholder, statusText }) {
|
|
24275
24277
|
const [value, setValue] = useState("");
|
|
24276
24278
|
const { exit } = useApp();
|
|
24277
24279
|
const matchingCommands = useMemo(() => {
|
|
@@ -24344,10 +24346,75 @@ function InputArea({ onSubmit, placeholder }) {
|
|
|
24344
24346
|
] }, i)) }),
|
|
24345
24347
|
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "\u2500".repeat(Math.max(process.stdout.columns || 80, 40)) })
|
|
24346
24348
|
] }),
|
|
24347
|
-
/* @__PURE__ */
|
|
24349
|
+
/* @__PURE__ */ jsxs2(Box2, { paddingX: 2, justifyContent: "space-between", children: [
|
|
24350
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "/ for commands" }),
|
|
24351
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: statusText || "" })
|
|
24352
|
+
] })
|
|
24353
|
+
] });
|
|
24354
|
+
}
|
|
24355
|
+
function TrustPrompt({ cwd, onAccept, onReject }) {
|
|
24356
|
+
const [selected, setSelected] = useState(0);
|
|
24357
|
+
useInput((ch, key) => {
|
|
24358
|
+
if (key.upArrow) setSelected(0);
|
|
24359
|
+
if (key.downArrow) setSelected(1);
|
|
24360
|
+
if (key.return) {
|
|
24361
|
+
if (selected === 0) onAccept();
|
|
24362
|
+
else onReject();
|
|
24363
|
+
}
|
|
24364
|
+
if (key.escape) onReject();
|
|
24365
|
+
if (ch === "1") {
|
|
24366
|
+
setSelected(0);
|
|
24367
|
+
onAccept();
|
|
24368
|
+
}
|
|
24369
|
+
if (ch === "2") {
|
|
24370
|
+
setSelected(1);
|
|
24371
|
+
onReject();
|
|
24372
|
+
}
|
|
24373
|
+
});
|
|
24374
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingY: 1, children: [
|
|
24375
|
+
/* @__PURE__ */ jsx2(Box2, { marginBottom: 1, paddingX: 1, children: /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24376
|
+
/* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u25C6" }),
|
|
24377
|
+
" ",
|
|
24378
|
+
/* @__PURE__ */ jsx2(Text2, { bold: true, children: "RobinPath" }),
|
|
24379
|
+
" ",
|
|
24380
|
+
/* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
24381
|
+
"v",
|
|
24382
|
+
CLI_VERSION
|
|
24383
|
+
] })
|
|
24384
|
+
] }) }),
|
|
24385
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "\u2500".repeat(Math.max(process.stdout.columns || 80, 40)) }),
|
|
24386
|
+
/* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
24387
|
+
/* @__PURE__ */ jsx2(Text2, { bold: true, children: "Workspace:" }),
|
|
24388
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24389
|
+
/* @__PURE__ */ jsx2(Text2, { color: "cyan", children: cwd }),
|
|
24390
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24391
|
+
/* @__PURE__ */ jsx2(Text2, { wrap: "wrap", dimColor: true, children: "RobinPath can read, edit, and execute files in this folder. Make sure this is a project you created or trust." }),
|
|
24392
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24393
|
+
/* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24394
|
+
selected === 0 ? /* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u276F " }) : /* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24395
|
+
/* @__PURE__ */ jsx2(Text2, { bold: selected === 0, children: "Yes, I trust this folder" })
|
|
24396
|
+
] }),
|
|
24397
|
+
/* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24398
|
+
selected === 1 ? /* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u276F " }) : /* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24399
|
+
/* @__PURE__ */ jsx2(Text2, { bold: selected === 1, children: "No, exit" })
|
|
24400
|
+
] })
|
|
24401
|
+
] }),
|
|
24402
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "\u2500".repeat(Math.max(process.stdout.columns || 80, 40)) }),
|
|
24403
|
+
/* @__PURE__ */ jsx2(Box2, { paddingX: 2, children: /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "\u2191\u2193 select \xB7 enter confirm \xB7 esc cancel" }) })
|
|
24348
24404
|
] });
|
|
24349
24405
|
}
|
|
24350
24406
|
function ChatApp({ engine }) {
|
|
24407
|
+
const [trusted, setTrusted] = useState(() => {
|
|
24408
|
+
try {
|
|
24409
|
+
const trustFile = join12(getRobinPathHome(), "trusted-dirs.json");
|
|
24410
|
+
if (existsSync11(trustFile)) {
|
|
24411
|
+
const dirs = JSON.parse(readFileSync10(trustFile, "utf-8"));
|
|
24412
|
+
return dirs.includes(process.cwd());
|
|
24413
|
+
}
|
|
24414
|
+
} catch {
|
|
24415
|
+
}
|
|
24416
|
+
return false;
|
|
24417
|
+
});
|
|
24351
24418
|
const [messages, setMessages] = useState([]);
|
|
24352
24419
|
const [streaming, setStreaming] = useState("");
|
|
24353
24420
|
const [loading, setLoading] = useState(false);
|
|
@@ -24385,9 +24452,72 @@ function ChatApp({ engine }) {
|
|
|
24385
24452
|
setStreaming("");
|
|
24386
24453
|
engine.updateStatus();
|
|
24387
24454
|
}, [engine]);
|
|
24455
|
+
if (!trusted) {
|
|
24456
|
+
return /* @__PURE__ */ jsx2(
|
|
24457
|
+
TrustPrompt,
|
|
24458
|
+
{
|
|
24459
|
+
cwd: process.cwd(),
|
|
24460
|
+
onAccept: () => {
|
|
24461
|
+
setTrusted(true);
|
|
24462
|
+
try {
|
|
24463
|
+
const trustFile = join12(getRobinPathHome(), "trusted-dirs.json");
|
|
24464
|
+
let dirs = [];
|
|
24465
|
+
if (existsSync11(trustFile)) dirs = JSON.parse(readFileSync10(trustFile, "utf-8"));
|
|
24466
|
+
if (!dirs.includes(process.cwd())) dirs.push(process.cwd());
|
|
24467
|
+
writeFileSync6(trustFile, JSON.stringify(dirs, null, 2));
|
|
24468
|
+
} catch {
|
|
24469
|
+
}
|
|
24470
|
+
},
|
|
24471
|
+
onReject: () => process.exit(0)
|
|
24472
|
+
}
|
|
24473
|
+
);
|
|
24474
|
+
}
|
|
24475
|
+
const modelName = engine.model.includes("/") ? engine.model.split("/").pop() : engine.model;
|
|
24476
|
+
const cwdShort = process.cwd().replace(homedir8(), "~");
|
|
24388
24477
|
const isFirst = messages.length === 0;
|
|
24389
24478
|
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingY: 1, children: [
|
|
24390
|
-
/* @__PURE__ */
|
|
24479
|
+
isFirst && !loading ? /* @__PURE__ */ jsxs2(Box2, { borderStyle: "round", borderColor: "gray", marginBottom: 1, paddingX: 2, paddingY: 1, children: [
|
|
24480
|
+
/* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", width: "50%", children: [
|
|
24481
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24482
|
+
/* @__PURE__ */ jsx2(Text2, { bold: true, children: " Welcome to RobinPath!" }),
|
|
24483
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24484
|
+
/* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24485
|
+
" ",
|
|
24486
|
+
/* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u25C6" }),
|
|
24487
|
+
" ",
|
|
24488
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: modelName })
|
|
24489
|
+
] }),
|
|
24490
|
+
/* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24491
|
+
" ",
|
|
24492
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: cwdShort })
|
|
24493
|
+
] }),
|
|
24494
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " })
|
|
24495
|
+
] }),
|
|
24496
|
+
/* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", width: "50%", children: [
|
|
24497
|
+
/* @__PURE__ */ jsx2(Text2, { bold: true, children: "Tips" }),
|
|
24498
|
+
/* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
24499
|
+
"Type ",
|
|
24500
|
+
/* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "/" }),
|
|
24501
|
+
" to see all commands"
|
|
24502
|
+
] }),
|
|
24503
|
+
/* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
24504
|
+
"Use ",
|
|
24505
|
+
/* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "@/file" }),
|
|
24506
|
+
" to include files"
|
|
24507
|
+
] }),
|
|
24508
|
+
/* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
24509
|
+
"Use ",
|
|
24510
|
+
/* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "\\" }),
|
|
24511
|
+
" at end for multiline"
|
|
24512
|
+
] }),
|
|
24513
|
+
/* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
24514
|
+
"Type ",
|
|
24515
|
+
/* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "exit" }),
|
|
24516
|
+
" to quit"
|
|
24517
|
+
] })
|
|
24518
|
+
] })
|
|
24519
|
+
] }) : null,
|
|
24520
|
+
!isFirst || loading ? /* @__PURE__ */ jsx2(Box2, { marginBottom: 1, paddingX: 1, children: /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24391
24521
|
/* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u25C6" }),
|
|
24392
24522
|
" ",
|
|
24393
24523
|
/* @__PURE__ */ jsx2(Text2, { bold: true, children: "RobinPath" }),
|
|
@@ -24396,7 +24526,7 @@ function ChatApp({ engine }) {
|
|
|
24396
24526
|
"v",
|
|
24397
24527
|
CLI_VERSION
|
|
24398
24528
|
] })
|
|
24399
|
-
] }) }),
|
|
24529
|
+
] }) }) : null,
|
|
24400
24530
|
/* @__PURE__ */ jsx2(Static, { items: messages, children: (msg) => /* @__PURE__ */ jsx2(Box2, { paddingX: 1, marginBottom: msg.text.startsWith("\u276F") ? 0 : 1, flexDirection: "column", children: msg.text.startsWith("\u276F") ? /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24401
24531
|
/* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u276F" }),
|
|
24402
24532
|
/* @__PURE__ */ jsx2(Text2, { bold: true, children: msg.text.slice(1) })
|
|
@@ -24411,10 +24541,10 @@ function ChatApp({ engine }) {
|
|
|
24411
24541
|
InputArea,
|
|
24412
24542
|
{
|
|
24413
24543
|
onSubmit: handleSubmit,
|
|
24414
|
-
placeholder: "Message RobinPath..."
|
|
24544
|
+
placeholder: "Message RobinPath...",
|
|
24545
|
+
statusText: status
|
|
24415
24546
|
}
|
|
24416
|
-
)
|
|
24417
|
-
status ? /* @__PURE__ */ jsx2(Box2, { marginTop: 1, paddingX: 1, children: /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: status }) }) : null
|
|
24547
|
+
)
|
|
24418
24548
|
] });
|
|
24419
24549
|
}
|
|
24420
24550
|
var ReplEngine = class {
|
|
@@ -24709,17 +24839,17 @@ async function startInkREPL(initialPrompt, resumeSessionId, opts = {}) {
|
|
|
24709
24839
|
// src/commands-modules.ts
|
|
24710
24840
|
import { createInterface as createInterface3 } from "node:readline";
|
|
24711
24841
|
import {
|
|
24712
|
-
readFileSync as
|
|
24713
|
-
existsSync as
|
|
24714
|
-
mkdirSync as
|
|
24842
|
+
readFileSync as readFileSync11,
|
|
24843
|
+
existsSync as existsSync12,
|
|
24844
|
+
mkdirSync as mkdirSync7,
|
|
24715
24845
|
copyFileSync as copyFileSync2,
|
|
24716
24846
|
rmSync as rmSync2,
|
|
24717
|
-
writeFileSync as
|
|
24718
|
-
readdirSync as
|
|
24719
|
-
statSync as
|
|
24847
|
+
writeFileSync as writeFileSync7,
|
|
24848
|
+
readdirSync as readdirSync7,
|
|
24849
|
+
statSync as statSync7,
|
|
24720
24850
|
unlinkSync as unlinkSync5
|
|
24721
24851
|
} from "node:fs";
|
|
24722
|
-
import { resolve as resolve8, join as
|
|
24852
|
+
import { resolve as resolve8, join as join13, dirname as dirname4, basename as basename4 } from "node:path";
|
|
24723
24853
|
import { execSync as execSync2 } from "node:child_process";
|
|
24724
24854
|
import { homedir as homedir9, platform as platform8, tmpdir as tmpdir3 } from "node:os";
|
|
24725
24855
|
import { createHash as createHash3 } from "node:crypto";
|
|
@@ -24810,18 +24940,18 @@ async function handleAdd(args) {
|
|
|
24810
24940
|
process.exit(1);
|
|
24811
24941
|
}
|
|
24812
24942
|
const integrity = "sha256-" + createHash3("sha256").update(tarballBuffer).digest("hex");
|
|
24813
|
-
if (!
|
|
24814
|
-
|
|
24943
|
+
if (!existsSync12(CACHE_DIR)) {
|
|
24944
|
+
mkdirSync7(CACHE_DIR, { recursive: true });
|
|
24815
24945
|
}
|
|
24816
|
-
const cacheFile =
|
|
24817
|
-
|
|
24946
|
+
const cacheFile = join13(CACHE_DIR, `${scope}-${name}-${resolvedVersion}.tar.gz`);
|
|
24947
|
+
writeFileSync7(cacheFile, tarballBuffer);
|
|
24818
24948
|
const modDir = getModulePath(fullName);
|
|
24819
|
-
if (
|
|
24949
|
+
if (existsSync12(modDir)) {
|
|
24820
24950
|
rmSync2(modDir, { recursive: true, force: true });
|
|
24821
24951
|
}
|
|
24822
|
-
|
|
24823
|
-
const tmpFile =
|
|
24824
|
-
|
|
24952
|
+
mkdirSync7(modDir, { recursive: true });
|
|
24953
|
+
const tmpFile = join13(tmpdir3(), `robinpath-add-${Date.now()}.tar.gz`);
|
|
24954
|
+
writeFileSync7(tmpFile, tarballBuffer);
|
|
24825
24955
|
try {
|
|
24826
24956
|
execSync2(`tar xzf "${toTarPath(tmpFile)}" --strip-components=1 -C "${toTarPath(modDir)}"`, { stdio: "pipe" });
|
|
24827
24957
|
} catch (err) {
|
|
@@ -24837,15 +24967,15 @@ async function handleAdd(args) {
|
|
|
24837
24967
|
unlinkSync5(tmpFile);
|
|
24838
24968
|
} catch {
|
|
24839
24969
|
}
|
|
24840
|
-
const distDir =
|
|
24841
|
-
const srcDir =
|
|
24842
|
-
if (!
|
|
24970
|
+
const distDir = join13(modDir, "dist");
|
|
24971
|
+
const srcDir = join13(modDir, "src");
|
|
24972
|
+
if (!existsSync12(distDir) && existsSync12(srcDir) && existsSync12(join13(srcDir, "index.ts"))) {
|
|
24843
24973
|
log(color.dim(" Compiling module..."));
|
|
24844
|
-
|
|
24845
|
-
const tsFiles =
|
|
24974
|
+
mkdirSync7(distDir, { recursive: true });
|
|
24975
|
+
const tsFiles = readdirSync7(srcDir).filter((f) => f.endsWith(".ts"));
|
|
24846
24976
|
for (const file of tsFiles) {
|
|
24847
|
-
const srcFile =
|
|
24848
|
-
const outFile =
|
|
24977
|
+
const srcFile = join13(srcDir, file);
|
|
24978
|
+
const outFile = join13(distDir, file.replace(".ts", ".js"));
|
|
24849
24979
|
try {
|
|
24850
24980
|
const stripScript = `
|
|
24851
24981
|
const fs = require('fs');
|
|
@@ -24861,17 +24991,17 @@ async function handleAdd(args) {
|
|
|
24861
24991
|
}
|
|
24862
24992
|
}
|
|
24863
24993
|
let installedVersion = resolvedVersion;
|
|
24864
|
-
const pkgJsonPath =
|
|
24865
|
-
if (
|
|
24994
|
+
const pkgJsonPath = join13(modDir, "package.json");
|
|
24995
|
+
if (existsSync12(pkgJsonPath)) {
|
|
24866
24996
|
try {
|
|
24867
|
-
const pkg = JSON.parse(
|
|
24997
|
+
const pkg = JSON.parse(readFileSync11(pkgJsonPath, "utf-8"));
|
|
24868
24998
|
installedVersion = pkg.version || installedVersion;
|
|
24869
24999
|
} catch {
|
|
24870
25000
|
}
|
|
24871
25001
|
}
|
|
24872
|
-
if (
|
|
25002
|
+
if (existsSync12(pkgJsonPath)) {
|
|
24873
25003
|
try {
|
|
24874
|
-
const pkg = JSON.parse(
|
|
25004
|
+
const pkg = JSON.parse(readFileSync11(pkgJsonPath, "utf-8"));
|
|
24875
25005
|
const depends = pkg.robinpath?.depends || [];
|
|
24876
25006
|
for (const dep of depends) {
|
|
24877
25007
|
if (!manifest[dep]) {
|
|
@@ -24890,12 +25020,12 @@ async function handleAdd(args) {
|
|
|
24890
25020
|
};
|
|
24891
25021
|
writeModulesManifest(updatedManifest);
|
|
24892
25022
|
const projectFile = resolve8("robinpath.json");
|
|
24893
|
-
if (
|
|
25023
|
+
if (existsSync12(projectFile)) {
|
|
24894
25024
|
try {
|
|
24895
|
-
const config = JSON.parse(
|
|
25025
|
+
const config = JSON.parse(readFileSync11(projectFile, "utf-8"));
|
|
24896
25026
|
if (!config.modules) config.modules = {};
|
|
24897
25027
|
config.modules[fullName] = `^${installedVersion}`;
|
|
24898
|
-
|
|
25028
|
+
writeFileSync7(projectFile, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
24899
25029
|
} catch {
|
|
24900
25030
|
}
|
|
24901
25031
|
}
|
|
@@ -24920,12 +25050,12 @@ async function handleRemove(args) {
|
|
|
24920
25050
|
process.exit(1);
|
|
24921
25051
|
}
|
|
24922
25052
|
const modDir = getModulePath(fullName);
|
|
24923
|
-
if (
|
|
25053
|
+
if (existsSync12(modDir)) {
|
|
24924
25054
|
rmSync2(modDir, { recursive: true, force: true });
|
|
24925
25055
|
}
|
|
24926
25056
|
const scopeDir = dirname4(modDir);
|
|
24927
25057
|
try {
|
|
24928
|
-
const remaining =
|
|
25058
|
+
const remaining = readdirSync7(scopeDir);
|
|
24929
25059
|
if (remaining.length === 0) {
|
|
24930
25060
|
rmSync2(scopeDir, { recursive: true, force: true });
|
|
24931
25061
|
}
|
|
@@ -24934,12 +25064,12 @@ async function handleRemove(args) {
|
|
|
24934
25064
|
delete manifest[fullName];
|
|
24935
25065
|
writeModulesManifest(manifest);
|
|
24936
25066
|
const projectFile = resolve8("robinpath.json");
|
|
24937
|
-
if (
|
|
25067
|
+
if (existsSync12(projectFile)) {
|
|
24938
25068
|
try {
|
|
24939
|
-
const config = JSON.parse(
|
|
25069
|
+
const config = JSON.parse(readFileSync11(projectFile, "utf-8"));
|
|
24940
25070
|
if (config.modules && config.modules[fullName]) {
|
|
24941
25071
|
delete config.modules[fullName];
|
|
24942
|
-
|
|
25072
|
+
writeFileSync7(projectFile, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
24943
25073
|
}
|
|
24944
25074
|
} catch {
|
|
24945
25075
|
}
|
|
@@ -25109,14 +25239,14 @@ async function handleModulesInit() {
|
|
|
25109
25239
|
const targetDir = resolve8(moduleName);
|
|
25110
25240
|
log("");
|
|
25111
25241
|
log(`Creating ${color.cyan(fullName)}...`);
|
|
25112
|
-
if (
|
|
25242
|
+
if (existsSync12(targetDir)) {
|
|
25113
25243
|
console.error(color.red("Error:") + ` Directory already exists: ${moduleName}/`);
|
|
25114
25244
|
process.exit(1);
|
|
25115
25245
|
}
|
|
25116
|
-
|
|
25117
|
-
|
|
25118
|
-
|
|
25119
|
-
|
|
25246
|
+
mkdirSync7(join13(targetDir, "src"), { recursive: true });
|
|
25247
|
+
mkdirSync7(join13(targetDir, "tests"), { recursive: true });
|
|
25248
|
+
writeFileSync7(
|
|
25249
|
+
join13(targetDir, "package.json"),
|
|
25120
25250
|
JSON.stringify(
|
|
25121
25251
|
{
|
|
25122
25252
|
name: fullName,
|
|
@@ -25139,8 +25269,8 @@ async function handleModulesInit() {
|
|
|
25139
25269
|
) + "\n",
|
|
25140
25270
|
"utf-8"
|
|
25141
25271
|
);
|
|
25142
|
-
|
|
25143
|
-
|
|
25272
|
+
writeFileSync7(
|
|
25273
|
+
join13(targetDir, "src", "index.ts"),
|
|
25144
25274
|
`import type { ModuleAdapter } from "@wiredwp/robinpath";
|
|
25145
25275
|
import {
|
|
25146
25276
|
${pascalName}Functions,
|
|
@@ -25161,8 +25291,8 @@ export { ${pascalName}Module };
|
|
|
25161
25291
|
`,
|
|
25162
25292
|
"utf-8"
|
|
25163
25293
|
);
|
|
25164
|
-
|
|
25165
|
-
|
|
25294
|
+
writeFileSync7(
|
|
25295
|
+
join13(targetDir, "src", `${moduleName}.ts`),
|
|
25166
25296
|
`import type {
|
|
25167
25297
|
BuiltinHandler,
|
|
25168
25298
|
FunctionMetadata,
|
|
@@ -25232,8 +25362,8 @@ export const ${pascalName}ModuleMetadata: ModuleMetadata = {
|
|
|
25232
25362
|
`,
|
|
25233
25363
|
"utf-8"
|
|
25234
25364
|
);
|
|
25235
|
-
|
|
25236
|
-
|
|
25365
|
+
writeFileSync7(
|
|
25366
|
+
join13(targetDir, "tsconfig.json"),
|
|
25237
25367
|
JSON.stringify(
|
|
25238
25368
|
{
|
|
25239
25369
|
compilerOptions: {
|
|
@@ -25256,8 +25386,8 @@ export const ${pascalName}ModuleMetadata: ModuleMetadata = {
|
|
|
25256
25386
|
) + "\n",
|
|
25257
25387
|
"utf-8"
|
|
25258
25388
|
);
|
|
25259
|
-
|
|
25260
|
-
|
|
25389
|
+
writeFileSync7(
|
|
25390
|
+
join13(targetDir, "tests", `${moduleName}.test.rp`),
|
|
25261
25391
|
`# ${displayName} module tests
|
|
25262
25392
|
# Run: robinpath test tests/
|
|
25263
25393
|
|
|
@@ -25275,8 +25405,8 @@ enddo
|
|
|
25275
25405
|
`,
|
|
25276
25406
|
"utf-8"
|
|
25277
25407
|
);
|
|
25278
|
-
|
|
25279
|
-
|
|
25408
|
+
writeFileSync7(
|
|
25409
|
+
join13(targetDir, "README.md"),
|
|
25280
25410
|
`# ${fullName}
|
|
25281
25411
|
|
|
25282
25412
|
${description}
|
|
@@ -25319,8 +25449,8 @@ ${license}
|
|
|
25319
25449
|
`,
|
|
25320
25450
|
"utf-8"
|
|
25321
25451
|
);
|
|
25322
|
-
|
|
25323
|
-
|
|
25452
|
+
writeFileSync7(
|
|
25453
|
+
join13(targetDir, ".gitignore"),
|
|
25324
25454
|
`node_modules/
|
|
25325
25455
|
dist/
|
|
25326
25456
|
*.tgz
|
|
@@ -25350,14 +25480,14 @@ dist/
|
|
|
25350
25480
|
async function handlePack(args) {
|
|
25351
25481
|
const targetArg = args.find((a) => !a.startsWith("-")) || ".";
|
|
25352
25482
|
const targetDir = resolve8(targetArg);
|
|
25353
|
-
const pkgPath =
|
|
25354
|
-
if (!
|
|
25483
|
+
const pkgPath = join13(targetDir, "package.json");
|
|
25484
|
+
if (!existsSync12(pkgPath)) {
|
|
25355
25485
|
console.error(color.red("Error:") + ` No package.json found in ${targetDir}`);
|
|
25356
25486
|
process.exit(2);
|
|
25357
25487
|
}
|
|
25358
25488
|
let pkg;
|
|
25359
25489
|
try {
|
|
25360
|
-
pkg = JSON.parse(
|
|
25490
|
+
pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
25361
25491
|
} catch (err) {
|
|
25362
25492
|
console.error(color.red("Error:") + ` Invalid package.json: ${err.message}`);
|
|
25363
25493
|
process.exit(2);
|
|
@@ -25378,12 +25508,12 @@ async function handlePack(args) {
|
|
|
25378
25508
|
{ stdio: "pipe" }
|
|
25379
25509
|
);
|
|
25380
25510
|
} catch (err) {
|
|
25381
|
-
if (!
|
|
25511
|
+
if (!existsSync12(outputPath)) {
|
|
25382
25512
|
console.error(color.red("Error:") + ` Failed to create tarball: ${err.message}`);
|
|
25383
25513
|
process.exit(1);
|
|
25384
25514
|
}
|
|
25385
25515
|
}
|
|
25386
|
-
const size =
|
|
25516
|
+
const size = statSync7(outputPath).size;
|
|
25387
25517
|
log(color.green("Created") + ` ${outputFile} (${(size / 1024).toFixed(1)}KB)`);
|
|
25388
25518
|
}
|
|
25389
25519
|
function formatCompactNumber(n) {
|
|
@@ -25532,9 +25662,9 @@ async function handleInfo(args) {
|
|
|
25532
25662
|
path: getModulePath(packageName)
|
|
25533
25663
|
};
|
|
25534
25664
|
try {
|
|
25535
|
-
const pkgPath =
|
|
25536
|
-
if (
|
|
25537
|
-
const pkg = JSON.parse(
|
|
25665
|
+
const pkgPath = join13(getModulePath(packageName), "package.json");
|
|
25666
|
+
if (existsSync12(pkgPath)) {
|
|
25667
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
25538
25668
|
if (pkg.description) entry.description = pkg.description;
|
|
25539
25669
|
if (pkg.keywords) entry.keywords = pkg.keywords;
|
|
25540
25670
|
}
|
|
@@ -25558,9 +25688,9 @@ async function handleInfo(args) {
|
|
|
25558
25688
|
modules_manifest: MODULES_MANIFEST,
|
|
25559
25689
|
cache: CACHE_DIR,
|
|
25560
25690
|
auth: getAuthPath(),
|
|
25561
|
-
history:
|
|
25562
|
-
env:
|
|
25563
|
-
docs:
|
|
25691
|
+
history: join13(homedir9(), ".robinpath", "history"),
|
|
25692
|
+
env: join13(homedir9(), ".robinpath", "env"),
|
|
25693
|
+
docs: join13(getRobinPathHome(), "DOCUMENTATION.md")
|
|
25564
25694
|
},
|
|
25565
25695
|
native_modules: modulesInfo,
|
|
25566
25696
|
installed_modules: installedModulesInfo,
|
|
@@ -25949,14 +26079,14 @@ async function handleInfo(args) {
|
|
|
25949
26079
|
}
|
|
25950
26080
|
|
|
25951
26081
|
// src/commands-project.ts
|
|
25952
|
-
import { readFileSync as
|
|
25953
|
-
import { resolve as resolve9, join as
|
|
26082
|
+
import { readFileSync as readFileSync12, existsSync as existsSync13, mkdirSync as mkdirSync8, writeFileSync as writeFileSync8, readdirSync as readdirSync8, statSync as statSync8, rmSync as rmSync3, chmodSync as chmodSync3 } from "node:fs";
|
|
26083
|
+
import { resolve as resolve9, join as join14, basename as basename5 } from "node:path";
|
|
25954
26084
|
import { createInterface as createInterface4 } from "node:readline";
|
|
25955
26085
|
import { platform as platform9 } from "node:os";
|
|
25956
26086
|
var PLATFORM_URL3 = process.env.ROBINPATH_PLATFORM_URL || "https://api.robinpath.com";
|
|
25957
26087
|
async function handleInit(args) {
|
|
25958
26088
|
const projectFile = resolve9("robinpath.json");
|
|
25959
|
-
if (
|
|
26089
|
+
if (existsSync13(projectFile) && !args.includes("--force")) {
|
|
25960
26090
|
console.error(color.red("Error:") + " robinpath.json already exists. Use --force to overwrite.");
|
|
25961
26091
|
process.exit(1);
|
|
25962
26092
|
}
|
|
@@ -25985,10 +26115,10 @@ async function handleInit(args) {
|
|
|
25985
26115
|
modules: {},
|
|
25986
26116
|
env: {}
|
|
25987
26117
|
};
|
|
25988
|
-
|
|
26118
|
+
writeFileSync8(projectFile, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
25989
26119
|
const mainPath = resolve9(mainFile);
|
|
25990
|
-
if (!
|
|
25991
|
-
|
|
26120
|
+
if (!existsSync13(mainPath)) {
|
|
26121
|
+
writeFileSync8(
|
|
25992
26122
|
mainPath,
|
|
25993
26123
|
`# ${projectName}
|
|
25994
26124
|
# Run: robinpath ${mainFile}
|
|
@@ -25998,8 +26128,8 @@ log "Hello from RobinPath!"
|
|
|
25998
26128
|
"utf-8"
|
|
25999
26129
|
);
|
|
26000
26130
|
}
|
|
26001
|
-
if (!
|
|
26002
|
-
|
|
26131
|
+
if (!existsSync13(resolve9(".env"))) {
|
|
26132
|
+
writeFileSync8(
|
|
26003
26133
|
resolve9(".env"),
|
|
26004
26134
|
`# Add your secrets here
|
|
26005
26135
|
# SLACK_TOKEN=xoxb-...
|
|
@@ -26008,8 +26138,8 @@ log "Hello from RobinPath!"
|
|
|
26008
26138
|
"utf-8"
|
|
26009
26139
|
);
|
|
26010
26140
|
}
|
|
26011
|
-
if (!
|
|
26012
|
-
|
|
26141
|
+
if (!existsSync13(resolve9(".gitignore"))) {
|
|
26142
|
+
writeFileSync8(
|
|
26013
26143
|
resolve9(".gitignore"),
|
|
26014
26144
|
`.env
|
|
26015
26145
|
.robinpath/
|
|
@@ -26021,7 +26151,7 @@ node_modules/
|
|
|
26021
26151
|
log("");
|
|
26022
26152
|
log(color.green("Created project:"));
|
|
26023
26153
|
log(` robinpath.json`);
|
|
26024
|
-
if (!
|
|
26154
|
+
if (!existsSync13(mainPath)) log(` ${mainFile}`);
|
|
26025
26155
|
log(` .env`);
|
|
26026
26156
|
log(` .gitignore`);
|
|
26027
26157
|
log("");
|
|
@@ -26030,13 +26160,13 @@ node_modules/
|
|
|
26030
26160
|
}
|
|
26031
26161
|
async function handleProjectInstall() {
|
|
26032
26162
|
const projectFile = resolve9("robinpath.json");
|
|
26033
|
-
if (!
|
|
26163
|
+
if (!existsSync13(projectFile)) {
|
|
26034
26164
|
handleInstall();
|
|
26035
26165
|
return;
|
|
26036
26166
|
}
|
|
26037
26167
|
let config;
|
|
26038
26168
|
try {
|
|
26039
|
-
config = JSON.parse(
|
|
26169
|
+
config = JSON.parse(readFileSync12(projectFile, "utf-8"));
|
|
26040
26170
|
} catch (err) {
|
|
26041
26171
|
console.error(color.red("Error:") + ` Invalid robinpath.json: ${err.message}`);
|
|
26042
26172
|
process.exit(2);
|
|
@@ -26088,7 +26218,7 @@ async function handleProjectInstall() {
|
|
|
26088
26218
|
};
|
|
26089
26219
|
}
|
|
26090
26220
|
}
|
|
26091
|
-
|
|
26221
|
+
writeFileSync8(lockFile, JSON.stringify(lockData, null, 2) + "\n", "utf-8");
|
|
26092
26222
|
log("");
|
|
26093
26223
|
const parts = [];
|
|
26094
26224
|
if (installed > 0) parts.push(color.green(`${installed} installed`));
|
|
@@ -26107,7 +26237,7 @@ async function handleDoctor() {
|
|
|
26107
26237
|
const installDir = getInstallDir();
|
|
26108
26238
|
const isWindows = platform9() === "win32";
|
|
26109
26239
|
const binaryName = isWindows ? "robinpath.exe" : "robinpath";
|
|
26110
|
-
if (
|
|
26240
|
+
if (existsSync13(join14(installDir, binaryName))) {
|
|
26111
26241
|
log(color.green(" \u2713") + ` Installed: ${installDir}`);
|
|
26112
26242
|
} else {
|
|
26113
26243
|
log(color.yellow(" !") + ` Not installed to PATH. Run ${color.cyan("robinpath install")}`);
|
|
@@ -26134,21 +26264,21 @@ async function handleDoctor() {
|
|
|
26134
26264
|
log(color.green(" \u2713") + ` ${moduleCount} module${moduleCount !== 1 ? "s" : ""} installed`);
|
|
26135
26265
|
for (const [name, info] of Object.entries(manifest)) {
|
|
26136
26266
|
const modDir = getModulePath(name);
|
|
26137
|
-
const pkgPath =
|
|
26138
|
-
if (!
|
|
26267
|
+
const pkgPath = join14(modDir, "package.json");
|
|
26268
|
+
if (!existsSync13(modDir)) {
|
|
26139
26269
|
log(color.red(" \u2717") + ` ${name}: directory missing`);
|
|
26140
26270
|
issues++;
|
|
26141
|
-
} else if (!
|
|
26271
|
+
} else if (!existsSync13(pkgPath)) {
|
|
26142
26272
|
log(color.red(" \u2717") + ` ${name}: package.json missing`);
|
|
26143
26273
|
issues++;
|
|
26144
26274
|
} else {
|
|
26145
26275
|
let entryPoint = "dist/index.js";
|
|
26146
26276
|
try {
|
|
26147
|
-
const pkg = JSON.parse(
|
|
26277
|
+
const pkg = JSON.parse(readFileSync12(pkgPath, "utf-8"));
|
|
26148
26278
|
if (pkg.main) entryPoint = pkg.main;
|
|
26149
26279
|
} catch {
|
|
26150
26280
|
}
|
|
26151
|
-
if (!
|
|
26281
|
+
if (!existsSync13(join14(modDir, entryPoint))) {
|
|
26152
26282
|
log(color.red(" \u2717") + ` ${name}: entry point ${entryPoint} missing`);
|
|
26153
26283
|
issues++;
|
|
26154
26284
|
}
|
|
@@ -26158,9 +26288,9 @@ async function handleDoctor() {
|
|
|
26158
26288
|
log(color.dim(" -") + ` No modules installed`);
|
|
26159
26289
|
}
|
|
26160
26290
|
const projectFile = resolve9("robinpath.json");
|
|
26161
|
-
if (
|
|
26291
|
+
if (existsSync13(projectFile)) {
|
|
26162
26292
|
try {
|
|
26163
|
-
const config = JSON.parse(
|
|
26293
|
+
const config = JSON.parse(readFileSync12(projectFile, "utf-8"));
|
|
26164
26294
|
log(color.green(" \u2713") + ` Project: ${config.name || "unnamed"} v${config.version || "?"}`);
|
|
26165
26295
|
const projectModules = Object.keys(config.modules || {});
|
|
26166
26296
|
for (const mod of projectModules) {
|
|
@@ -26174,12 +26304,12 @@ async function handleDoctor() {
|
|
|
26174
26304
|
issues++;
|
|
26175
26305
|
}
|
|
26176
26306
|
}
|
|
26177
|
-
if (
|
|
26307
|
+
if (existsSync13(CACHE_DIR)) {
|
|
26178
26308
|
try {
|
|
26179
|
-
const cacheFiles =
|
|
26309
|
+
const cacheFiles = readdirSync8(CACHE_DIR);
|
|
26180
26310
|
const cacheSize = cacheFiles.reduce((total, f) => {
|
|
26181
26311
|
try {
|
|
26182
|
-
return total +
|
|
26312
|
+
return total + statSync8(join14(CACHE_DIR, f)).size;
|
|
26183
26313
|
} catch {
|
|
26184
26314
|
return total;
|
|
26185
26315
|
}
|
|
@@ -26197,12 +26327,12 @@ async function handleDoctor() {
|
|
|
26197
26327
|
log("");
|
|
26198
26328
|
}
|
|
26199
26329
|
async function handleEnv(args) {
|
|
26200
|
-
const envPath =
|
|
26330
|
+
const envPath = join14(getRobinPathHome(), "env");
|
|
26201
26331
|
const sub = args[0];
|
|
26202
26332
|
function readEnvFile() {
|
|
26203
26333
|
try {
|
|
26204
|
-
if (!
|
|
26205
|
-
const lines =
|
|
26334
|
+
if (!existsSync13(envPath)) return {};
|
|
26335
|
+
const lines = readFileSync12(envPath, "utf-8").split("\n");
|
|
26206
26336
|
const env = {};
|
|
26207
26337
|
for (const line of lines) {
|
|
26208
26338
|
const trimmed = line.trim();
|
|
@@ -26219,9 +26349,9 @@ async function handleEnv(args) {
|
|
|
26219
26349
|
}
|
|
26220
26350
|
function writeEnvFile(env) {
|
|
26221
26351
|
const dir = getRobinPathHome();
|
|
26222
|
-
if (!
|
|
26352
|
+
if (!existsSync13(dir)) mkdirSync8(dir, { recursive: true });
|
|
26223
26353
|
const content = Object.entries(env).map(([k2, v]) => `${k2}=${v}`).join("\n") + "\n";
|
|
26224
|
-
|
|
26354
|
+
writeFileSync8(envPath, content, "utf-8");
|
|
26225
26355
|
if (platform9() !== "win32") {
|
|
26226
26356
|
try {
|
|
26227
26357
|
chmodSync3(envPath, 384);
|
|
@@ -26283,12 +26413,12 @@ async function handleEnv(args) {
|
|
|
26283
26413
|
async function handleCache(args) {
|
|
26284
26414
|
const sub = args[0];
|
|
26285
26415
|
if (sub === "list") {
|
|
26286
|
-
if (!
|
|
26416
|
+
if (!existsSync13(CACHE_DIR)) {
|
|
26287
26417
|
log("Cache is empty.");
|
|
26288
26418
|
return;
|
|
26289
26419
|
}
|
|
26290
26420
|
try {
|
|
26291
|
-
const files =
|
|
26421
|
+
const files = readdirSync8(CACHE_DIR);
|
|
26292
26422
|
if (files.length === 0) {
|
|
26293
26423
|
log("Cache is empty.");
|
|
26294
26424
|
return;
|
|
@@ -26298,7 +26428,7 @@ async function handleCache(args) {
|
|
|
26298
26428
|
log(color.dim(" " + "\u2500".repeat(50)));
|
|
26299
26429
|
let totalSize = 0;
|
|
26300
26430
|
for (const file of files) {
|
|
26301
|
-
const size =
|
|
26431
|
+
const size = statSync8(join14(CACHE_DIR, file)).size;
|
|
26302
26432
|
totalSize += size;
|
|
26303
26433
|
log(` ${file.padEnd(45)} ${color.dim((size / 1024).toFixed(1) + "KB")}`);
|
|
26304
26434
|
}
|
|
@@ -26314,15 +26444,15 @@ async function handleCache(args) {
|
|
|
26314
26444
|
process.exit(1);
|
|
26315
26445
|
}
|
|
26316
26446
|
} else if (sub === "clean") {
|
|
26317
|
-
if (!
|
|
26447
|
+
if (!existsSync13(CACHE_DIR)) {
|
|
26318
26448
|
log("Cache is already empty.");
|
|
26319
26449
|
return;
|
|
26320
26450
|
}
|
|
26321
26451
|
try {
|
|
26322
|
-
const files =
|
|
26452
|
+
const files = readdirSync8(CACHE_DIR);
|
|
26323
26453
|
let totalSize = 0;
|
|
26324
26454
|
for (const file of files) {
|
|
26325
|
-
totalSize +=
|
|
26455
|
+
totalSize += statSync8(join14(CACHE_DIR, file)).size;
|
|
26326
26456
|
}
|
|
26327
26457
|
rmSync3(CACHE_DIR, { recursive: true, force: true });
|
|
26328
26458
|
log(
|
|
@@ -26437,8 +26567,8 @@ async function handleDeprecate(args) {
|
|
|
26437
26567
|
}
|
|
26438
26568
|
|
|
26439
26569
|
// src/commands-snippets.ts
|
|
26440
|
-
import { readFileSync as
|
|
26441
|
-
import { resolve as resolve10, basename as basename6, extname as extname4, join as
|
|
26570
|
+
import { readFileSync as readFileSync13, existsSync as existsSync14, mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
|
|
26571
|
+
import { resolve as resolve10, basename as basename6, extname as extname4, join as join15 } from "node:path";
|
|
26442
26572
|
import { homedir as homedir10, platform as platform10 } from "node:os";
|
|
26443
26573
|
import { createInterface as createInterface5 } from "node:readline";
|
|
26444
26574
|
var PLATFORM_URL4 = process.env.ROBINPATH_PLATFORM_URL || "https://api.robinpath.com";
|
|
@@ -26674,11 +26804,11 @@ async function snippetCreate(args) {
|
|
|
26674
26804
|
defaultName = "untitled";
|
|
26675
26805
|
} else {
|
|
26676
26806
|
const filePath = resolve10(fileArg);
|
|
26677
|
-
if (!
|
|
26807
|
+
if (!existsSync14(filePath)) {
|
|
26678
26808
|
console.error(color.red("Error:") + ` File not found: ${fileArg}`);
|
|
26679
26809
|
process.exit(1);
|
|
26680
26810
|
}
|
|
26681
|
-
code =
|
|
26811
|
+
code = readFileSync13(filePath, "utf-8");
|
|
26682
26812
|
defaultName = basename6(filePath, extname4(filePath));
|
|
26683
26813
|
}
|
|
26684
26814
|
if (!code || !code.trim()) {
|
|
@@ -26700,8 +26830,8 @@ async function snippetCreate(args) {
|
|
|
26700
26830
|
if (flags.version) payload.version = flags.version;
|
|
26701
26831
|
if (flags.readme) {
|
|
26702
26832
|
const readmePath = resolve10(flags.readme);
|
|
26703
|
-
if (
|
|
26704
|
-
payload.readme =
|
|
26833
|
+
if (existsSync14(readmePath)) {
|
|
26834
|
+
payload.readme = readFileSync13(readmePath, "utf-8");
|
|
26705
26835
|
}
|
|
26706
26836
|
}
|
|
26707
26837
|
try {
|
|
@@ -26784,12 +26914,12 @@ async function snippetInit(args) {
|
|
|
26784
26914
|
code = codeLines.join("\n");
|
|
26785
26915
|
} else {
|
|
26786
26916
|
const filePath = await ask("File path", "");
|
|
26787
|
-
if (!filePath || !
|
|
26917
|
+
if (!filePath || !existsSync14(resolve10(filePath))) {
|
|
26788
26918
|
console.error(color.red("Error:") + " File not found.");
|
|
26789
26919
|
rl.close();
|
|
26790
26920
|
process.exit(1);
|
|
26791
26921
|
}
|
|
26792
|
-
code =
|
|
26922
|
+
code = readFileSync13(resolve10(filePath), "utf-8");
|
|
26793
26923
|
}
|
|
26794
26924
|
rl.close();
|
|
26795
26925
|
if (!code.trim()) {
|
|
@@ -26946,16 +27076,16 @@ async function snippetUpdate(args) {
|
|
|
26946
27076
|
payload.tags = flags.tags.split(",").map((t) => t.trim()).filter(Boolean);
|
|
26947
27077
|
if (flags.code) {
|
|
26948
27078
|
const codePath = resolve10(flags.code);
|
|
26949
|
-
if (!
|
|
27079
|
+
if (!existsSync14(codePath)) {
|
|
26950
27080
|
console.error(color.red("Error:") + ` Code file not found: ${flags.code}`);
|
|
26951
27081
|
process.exit(1);
|
|
26952
27082
|
}
|
|
26953
|
-
payload.code =
|
|
27083
|
+
payload.code = readFileSync13(codePath, "utf-8");
|
|
26954
27084
|
}
|
|
26955
27085
|
if (flags.readme) {
|
|
26956
27086
|
const readmePath = resolve10(flags.readme);
|
|
26957
|
-
if (
|
|
26958
|
-
payload.readme =
|
|
27087
|
+
if (existsSync14(readmePath)) {
|
|
27088
|
+
payload.readme = readFileSync13(readmePath, "utf-8");
|
|
26959
27089
|
}
|
|
26960
27090
|
}
|
|
26961
27091
|
if (Object.keys(payload).length === 0) {
|
|
@@ -27331,16 +27461,16 @@ async function snippetCopy(args) {
|
|
|
27331
27461
|
process.exit(1);
|
|
27332
27462
|
}
|
|
27333
27463
|
}
|
|
27334
|
-
var SNIPPET_CACHE_DIR =
|
|
27464
|
+
var SNIPPET_CACHE_DIR = join15(homedir10(), ".robinpath", "cache", "snippets");
|
|
27335
27465
|
var SNIPPET_CACHE_TTL = 5 * 60 * 1e3;
|
|
27336
27466
|
function getSnippetCachePath(id) {
|
|
27337
|
-
return
|
|
27467
|
+
return join15(SNIPPET_CACHE_DIR, `${id}.json`);
|
|
27338
27468
|
}
|
|
27339
27469
|
function readSnippetCache(id) {
|
|
27340
27470
|
try {
|
|
27341
27471
|
const cachePath = getSnippetCachePath(id);
|
|
27342
|
-
if (!
|
|
27343
|
-
const raw = JSON.parse(
|
|
27472
|
+
if (!existsSync14(cachePath)) return null;
|
|
27473
|
+
const raw = JSON.parse(readFileSync13(cachePath, "utf-8"));
|
|
27344
27474
|
if (Date.now() - (raw._cachedAt || 0) > SNIPPET_CACHE_TTL) return null;
|
|
27345
27475
|
return raw;
|
|
27346
27476
|
} catch {
|
|
@@ -27349,10 +27479,10 @@ function readSnippetCache(id) {
|
|
|
27349
27479
|
}
|
|
27350
27480
|
function writeSnippetCache(id, data) {
|
|
27351
27481
|
try {
|
|
27352
|
-
if (!
|
|
27353
|
-
|
|
27482
|
+
if (!existsSync14(SNIPPET_CACHE_DIR)) {
|
|
27483
|
+
mkdirSync9(SNIPPET_CACHE_DIR, { recursive: true });
|
|
27354
27484
|
}
|
|
27355
|
-
|
|
27485
|
+
writeFileSync9(getSnippetCachePath(id), JSON.stringify({ ...data, _cachedAt: Date.now() }), "utf-8");
|
|
27356
27486
|
} catch {
|
|
27357
27487
|
}
|
|
27358
27488
|
}
|
|
@@ -27435,7 +27565,7 @@ async function snippetPull(args) {
|
|
|
27435
27565
|
const sanitizedName = (s.name || "snippet").replace(/[^a-zA-Z0-9_\-]/g, "_").toLowerCase();
|
|
27436
27566
|
const fileName = outputFile || `${sanitizedName}.rp`;
|
|
27437
27567
|
const filePath = resolve10(fileName);
|
|
27438
|
-
|
|
27568
|
+
writeFileSync9(filePath, code, "utf-8");
|
|
27439
27569
|
if (flags.json) {
|
|
27440
27570
|
console.log(JSON.stringify({ id, name: s.name, file: filePath, bytes: Buffer.byteLength(code) }, null, 2));
|
|
27441
27571
|
return;
|
|
@@ -27463,11 +27593,11 @@ async function snippetPush(args) {
|
|
|
27463
27593
|
}
|
|
27464
27594
|
id = await resolveSnippetId(id);
|
|
27465
27595
|
const filePath = resolve10(fileArg);
|
|
27466
|
-
if (!
|
|
27596
|
+
if (!existsSync14(filePath)) {
|
|
27467
27597
|
console.error(color.red("Error:") + ` File not found: ${fileArg}`);
|
|
27468
27598
|
process.exit(1);
|
|
27469
27599
|
}
|
|
27470
|
-
const code =
|
|
27600
|
+
const code = readFileSync13(filePath, "utf-8");
|
|
27471
27601
|
if (!code.trim()) {
|
|
27472
27602
|
console.error(color.red("Error:") + " File is empty.");
|
|
27473
27603
|
process.exit(1);
|
|
@@ -27551,11 +27681,11 @@ async function snippetDiff(args) {
|
|
|
27551
27681
|
}
|
|
27552
27682
|
id = await resolveSnippetId(id);
|
|
27553
27683
|
const filePath = resolve10(fileArg);
|
|
27554
|
-
if (!
|
|
27684
|
+
if (!existsSync14(filePath)) {
|
|
27555
27685
|
console.error(color.red("Error:") + ` File not found: ${fileArg}`);
|
|
27556
27686
|
process.exit(1);
|
|
27557
27687
|
}
|
|
27558
|
-
const localCode =
|
|
27688
|
+
const localCode = readFileSync13(filePath, "utf-8");
|
|
27559
27689
|
try {
|
|
27560
27690
|
const res = await fetchSnippet(id);
|
|
27561
27691
|
if (!res.ok) {
|
|
@@ -27657,7 +27787,7 @@ async function snippetExport(args) {
|
|
|
27657
27787
|
if (flags.json || !flags.format || flags.format === "json") {
|
|
27658
27788
|
const outputFile = flags.positional[0] || "snippets-export.json";
|
|
27659
27789
|
const filePath = resolve10(outputFile);
|
|
27660
|
-
|
|
27790
|
+
writeFileSync9(filePath, JSON.stringify(exportData, null, 2), "utf-8");
|
|
27661
27791
|
log(
|
|
27662
27792
|
color.green("\u2713") + ` Exported ${allSnippets.length} snippet${allSnippets.length !== 1 ? "s" : ""} to: ${color.cyan(outputFile)}`
|
|
27663
27793
|
);
|
|
@@ -27675,13 +27805,13 @@ async function snippetImport(args) {
|
|
|
27675
27805
|
process.exit(2);
|
|
27676
27806
|
}
|
|
27677
27807
|
const filePath = resolve10(fileArg);
|
|
27678
|
-
if (!
|
|
27808
|
+
if (!existsSync14(filePath)) {
|
|
27679
27809
|
console.error(color.red("Error:") + ` File not found: ${fileArg}`);
|
|
27680
27810
|
process.exit(1);
|
|
27681
27811
|
}
|
|
27682
27812
|
let importData;
|
|
27683
27813
|
try {
|
|
27684
|
-
importData = JSON.parse(
|
|
27814
|
+
importData = JSON.parse(readFileSync13(filePath, "utf-8"));
|
|
27685
27815
|
} catch {
|
|
27686
27816
|
console.error(color.red("Error:") + " Invalid JSON file.");
|
|
27687
27817
|
process.exit(1);
|
|
@@ -27748,8 +27878,8 @@ async function snippetImport(args) {
|
|
|
27748
27878
|
|
|
27749
27879
|
// src/commands-cloud.ts
|
|
27750
27880
|
import { createServer as createServer4 } from "node:http";
|
|
27751
|
-
import { readFileSync as
|
|
27752
|
-
import { resolve as resolve11, join as
|
|
27881
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync10, unlinkSync as unlinkSync6, existsSync as existsSync15 } from "node:fs";
|
|
27882
|
+
import { resolve as resolve11, join as join16, dirname as dirname5, basename as basename7 } from "node:path";
|
|
27753
27883
|
import { execSync as execSync3 } from "node:child_process";
|
|
27754
27884
|
import { tmpdir as tmpdir4, hostname as hostname3 } from "node:os";
|
|
27755
27885
|
var CLOUD_URL2 = process.env.ROBINPATH_CLOUD_URL || "https://dev.robinpath.com";
|
|
@@ -27885,14 +28015,14 @@ async function handlePublish(args) {
|
|
|
27885
28015
|
const isDryRun = args.includes("--dry-run");
|
|
27886
28016
|
const targetArg = args.find((a) => !a.startsWith("-") && !a.startsWith("--org")) || ".";
|
|
27887
28017
|
const targetDir = resolve11(targetArg);
|
|
27888
|
-
const pkgPath =
|
|
27889
|
-
if (!
|
|
28018
|
+
const pkgPath = join16(targetDir, "package.json");
|
|
28019
|
+
if (!existsSync15(pkgPath)) {
|
|
27890
28020
|
console.error(color.red("Error:") + ` No package.json found in ${targetDir}`);
|
|
27891
28021
|
process.exit(2);
|
|
27892
28022
|
}
|
|
27893
28023
|
let pkg;
|
|
27894
28024
|
try {
|
|
27895
|
-
pkg = JSON.parse(
|
|
28025
|
+
pkg = JSON.parse(readFileSync14(pkgPath, "utf-8"));
|
|
27896
28026
|
} catch (err) {
|
|
27897
28027
|
console.error(color.red("Error:") + ` Invalid package.json: ${err.message}`);
|
|
27898
28028
|
process.exit(2);
|
|
@@ -27910,7 +28040,7 @@ async function handlePublish(args) {
|
|
|
27910
28040
|
if (args.includes("--major")) pkg.version = `${major + 1}.0.0`;
|
|
27911
28041
|
else if (args.includes("--minor")) pkg.version = `${major}.${minor + 1}.0`;
|
|
27912
28042
|
else pkg.version = `${major}.${minor}.${patch + 1}`;
|
|
27913
|
-
|
|
28043
|
+
writeFileSync10(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
27914
28044
|
log(`Bumped version to ${color.cyan(pkg.version)}`);
|
|
27915
28045
|
}
|
|
27916
28046
|
let visibility = "public";
|
|
@@ -27936,7 +28066,7 @@ async function handlePublish(args) {
|
|
|
27936
28066
|
scope = emailPrefix;
|
|
27937
28067
|
name = pkg.name;
|
|
27938
28068
|
}
|
|
27939
|
-
const tmpFile =
|
|
28069
|
+
const tmpFile = join16(tmpdir4(), `robinpath-publish-${Date.now()}.tar.gz`);
|
|
27940
28070
|
const parentDir = dirname5(targetDir);
|
|
27941
28071
|
const dirName = basename7(targetDir);
|
|
27942
28072
|
log(`Packing @${scope}/${name}@${pkg.version} (${visibility})...`);
|
|
@@ -27953,7 +28083,7 @@ async function handlePublish(args) {
|
|
|
27953
28083
|
console.error(color.red("Error:") + ` Failed to create tarball: ${err.message}`);
|
|
27954
28084
|
process.exit(1);
|
|
27955
28085
|
}
|
|
27956
|
-
const tarball =
|
|
28086
|
+
const tarball = readFileSync14(tmpFile);
|
|
27957
28087
|
const maxSize = 50 * 1024 * 1024;
|
|
27958
28088
|
if (tarball.length > maxSize) {
|
|
27959
28089
|
unlinkSync6(tmpFile);
|
|
@@ -28265,7 +28395,7 @@ async function main() {
|
|
|
28265
28395
|
return;
|
|
28266
28396
|
}
|
|
28267
28397
|
if (command === "install") {
|
|
28268
|
-
|
|
28398
|
+
existsSync16(resolve12("robinpath.json")) ? await handleProjectInstall() : handleInstall();
|
|
28269
28399
|
return;
|
|
28270
28400
|
}
|
|
28271
28401
|
if (command === "uninstall") {
|
|
@@ -28384,7 +28514,7 @@ async function main() {
|
|
|
28384
28514
|
}
|
|
28385
28515
|
process.exit(2);
|
|
28386
28516
|
}
|
|
28387
|
-
const script =
|
|
28517
|
+
const script = readFileSync15(filePath, "utf-8");
|
|
28388
28518
|
const hasWatch = args.includes("--watch");
|
|
28389
28519
|
const hasShortWatch = args.includes("-w") && command !== "fmt";
|
|
28390
28520
|
if (hasWatch || hasShortWatch) {
|