@robinpath/cli 1.86.0 → 1.88.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 +224 -140
- 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.88.0" : "1.88.0";
|
|
18602
18602
|
var FLAG_QUIET = false;
|
|
18603
18603
|
var FLAG_VERBOSE = false;
|
|
18604
18604
|
var FLAG_AUTO_ACCEPT = false;
|
|
@@ -24253,6 +24253,8 @@ function Markdown({ children }) {
|
|
|
24253
24253
|
// src/ink-repl.tsx
|
|
24254
24254
|
import { 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 = {
|
|
@@ -24347,7 +24349,69 @@ function InputArea({ onSubmit, placeholder }) {
|
|
|
24347
24349
|
/* @__PURE__ */ jsx2(Box2, { paddingX: 2, children: /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "enter send \xB7 \\ newline \xB7 / commands \xB7 @/ files" }) })
|
|
24348
24350
|
] });
|
|
24349
24351
|
}
|
|
24352
|
+
function TrustPrompt({ cwd, onAccept, onReject }) {
|
|
24353
|
+
const [selected, setSelected] = useState(0);
|
|
24354
|
+
useInput((ch, key) => {
|
|
24355
|
+
if (key.upArrow) setSelected(0);
|
|
24356
|
+
if (key.downArrow) setSelected(1);
|
|
24357
|
+
if (key.return) {
|
|
24358
|
+
if (selected === 0) onAccept();
|
|
24359
|
+
else onReject();
|
|
24360
|
+
}
|
|
24361
|
+
if (key.escape) onReject();
|
|
24362
|
+
if (ch === "1") {
|
|
24363
|
+
setSelected(0);
|
|
24364
|
+
onAccept();
|
|
24365
|
+
}
|
|
24366
|
+
if (ch === "2") {
|
|
24367
|
+
setSelected(1);
|
|
24368
|
+
onReject();
|
|
24369
|
+
}
|
|
24370
|
+
});
|
|
24371
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingY: 1, children: [
|
|
24372
|
+
/* @__PURE__ */ jsx2(Box2, { marginBottom: 1, paddingX: 1, children: /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24373
|
+
/* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u25C6" }),
|
|
24374
|
+
" ",
|
|
24375
|
+
/* @__PURE__ */ jsx2(Text2, { bold: true, children: "RobinPath" }),
|
|
24376
|
+
" ",
|
|
24377
|
+
/* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
24378
|
+
"v",
|
|
24379
|
+
CLI_VERSION
|
|
24380
|
+
] })
|
|
24381
|
+
] }) }),
|
|
24382
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "\u2500".repeat(Math.max(process.stdout.columns || 80, 40)) }),
|
|
24383
|
+
/* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
24384
|
+
/* @__PURE__ */ jsx2(Text2, { bold: true, children: "Workspace:" }),
|
|
24385
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24386
|
+
/* @__PURE__ */ jsx2(Text2, { color: "cyan", children: cwd }),
|
|
24387
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24388
|
+
/* @__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." }),
|
|
24389
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24390
|
+
/* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24391
|
+
selected === 0 ? /* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u276F " }) : /* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24392
|
+
/* @__PURE__ */ jsx2(Text2, { bold: selected === 0, children: "Yes, I trust this folder" })
|
|
24393
|
+
] }),
|
|
24394
|
+
/* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24395
|
+
selected === 1 ? /* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u276F " }) : /* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
24396
|
+
/* @__PURE__ */ jsx2(Text2, { bold: selected === 1, children: "No, exit" })
|
|
24397
|
+
] })
|
|
24398
|
+
] }),
|
|
24399
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "\u2500".repeat(Math.max(process.stdout.columns || 80, 40)) }),
|
|
24400
|
+
/* @__PURE__ */ jsx2(Box2, { paddingX: 2, children: /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "\u2191\u2193 select \xB7 enter confirm \xB7 esc cancel" }) })
|
|
24401
|
+
] });
|
|
24402
|
+
}
|
|
24350
24403
|
function ChatApp({ engine }) {
|
|
24404
|
+
const [trusted, setTrusted] = useState(() => {
|
|
24405
|
+
try {
|
|
24406
|
+
const trustFile = join12(getRobinPathHome(), "trusted-dirs.json");
|
|
24407
|
+
if (existsSync11(trustFile)) {
|
|
24408
|
+
const dirs = JSON.parse(readFileSync10(trustFile, "utf-8"));
|
|
24409
|
+
return dirs.includes(process.cwd());
|
|
24410
|
+
}
|
|
24411
|
+
} catch {
|
|
24412
|
+
}
|
|
24413
|
+
return false;
|
|
24414
|
+
});
|
|
24351
24415
|
const [messages, setMessages] = useState([]);
|
|
24352
24416
|
const [streaming, setStreaming] = useState("");
|
|
24353
24417
|
const [loading, setLoading] = useState(false);
|
|
@@ -24386,8 +24450,28 @@ function ChatApp({ engine }) {
|
|
|
24386
24450
|
engine.updateStatus();
|
|
24387
24451
|
}, [engine]);
|
|
24388
24452
|
const isFirst = messages.length === 0;
|
|
24453
|
+
if (!trusted) {
|
|
24454
|
+
return /* @__PURE__ */ jsx2(
|
|
24455
|
+
TrustPrompt,
|
|
24456
|
+
{
|
|
24457
|
+
cwd: process.cwd(),
|
|
24458
|
+
onAccept: () => {
|
|
24459
|
+
setTrusted(true);
|
|
24460
|
+
try {
|
|
24461
|
+
const trustFile = join12(getRobinPathHome(), "trusted-dirs.json");
|
|
24462
|
+
let dirs = [];
|
|
24463
|
+
if (existsSync11(trustFile)) dirs = JSON.parse(readFileSync10(trustFile, "utf-8"));
|
|
24464
|
+
if (!dirs.includes(process.cwd())) dirs.push(process.cwd());
|
|
24465
|
+
writeFileSync6(trustFile, JSON.stringify(dirs, null, 2));
|
|
24466
|
+
} catch {
|
|
24467
|
+
}
|
|
24468
|
+
},
|
|
24469
|
+
onReject: () => process.exit(0)
|
|
24470
|
+
}
|
|
24471
|
+
);
|
|
24472
|
+
}
|
|
24389
24473
|
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingY: 1, children: [
|
|
24390
|
-
/* @__PURE__ */ jsx2(Box2, { marginBottom: 1, children: /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24474
|
+
/* @__PURE__ */ jsx2(Box2, { marginBottom: 1, paddingX: 1, children: /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24391
24475
|
/* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u25C6" }),
|
|
24392
24476
|
" ",
|
|
24393
24477
|
/* @__PURE__ */ jsx2(Text2, { bold: true, children: "RobinPath" }),
|
|
@@ -24411,7 +24495,7 @@ function ChatApp({ engine }) {
|
|
|
24411
24495
|
InputArea,
|
|
24412
24496
|
{
|
|
24413
24497
|
onSubmit: handleSubmit,
|
|
24414
|
-
placeholder:
|
|
24498
|
+
placeholder: "Message RobinPath..."
|
|
24415
24499
|
}
|
|
24416
24500
|
),
|
|
24417
24501
|
status ? /* @__PURE__ */ jsx2(Box2, { marginTop: 1, paddingX: 1, children: /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: status }) }) : null
|
|
@@ -24709,17 +24793,17 @@ async function startInkREPL(initialPrompt, resumeSessionId, opts = {}) {
|
|
|
24709
24793
|
// src/commands-modules.ts
|
|
24710
24794
|
import { createInterface as createInterface3 } from "node:readline";
|
|
24711
24795
|
import {
|
|
24712
|
-
readFileSync as
|
|
24713
|
-
existsSync as
|
|
24714
|
-
mkdirSync as
|
|
24796
|
+
readFileSync as readFileSync11,
|
|
24797
|
+
existsSync as existsSync12,
|
|
24798
|
+
mkdirSync as mkdirSync7,
|
|
24715
24799
|
copyFileSync as copyFileSync2,
|
|
24716
24800
|
rmSync as rmSync2,
|
|
24717
|
-
writeFileSync as
|
|
24718
|
-
readdirSync as
|
|
24719
|
-
statSync as
|
|
24801
|
+
writeFileSync as writeFileSync7,
|
|
24802
|
+
readdirSync as readdirSync7,
|
|
24803
|
+
statSync as statSync7,
|
|
24720
24804
|
unlinkSync as unlinkSync5
|
|
24721
24805
|
} from "node:fs";
|
|
24722
|
-
import { resolve as resolve8, join as
|
|
24806
|
+
import { resolve as resolve8, join as join13, dirname as dirname4, basename as basename4 } from "node:path";
|
|
24723
24807
|
import { execSync as execSync2 } from "node:child_process";
|
|
24724
24808
|
import { homedir as homedir9, platform as platform8, tmpdir as tmpdir3 } from "node:os";
|
|
24725
24809
|
import { createHash as createHash3 } from "node:crypto";
|
|
@@ -24810,18 +24894,18 @@ async function handleAdd(args) {
|
|
|
24810
24894
|
process.exit(1);
|
|
24811
24895
|
}
|
|
24812
24896
|
const integrity = "sha256-" + createHash3("sha256").update(tarballBuffer).digest("hex");
|
|
24813
|
-
if (!
|
|
24814
|
-
|
|
24897
|
+
if (!existsSync12(CACHE_DIR)) {
|
|
24898
|
+
mkdirSync7(CACHE_DIR, { recursive: true });
|
|
24815
24899
|
}
|
|
24816
|
-
const cacheFile =
|
|
24817
|
-
|
|
24900
|
+
const cacheFile = join13(CACHE_DIR, `${scope}-${name}-${resolvedVersion}.tar.gz`);
|
|
24901
|
+
writeFileSync7(cacheFile, tarballBuffer);
|
|
24818
24902
|
const modDir = getModulePath(fullName);
|
|
24819
|
-
if (
|
|
24903
|
+
if (existsSync12(modDir)) {
|
|
24820
24904
|
rmSync2(modDir, { recursive: true, force: true });
|
|
24821
24905
|
}
|
|
24822
|
-
|
|
24823
|
-
const tmpFile =
|
|
24824
|
-
|
|
24906
|
+
mkdirSync7(modDir, { recursive: true });
|
|
24907
|
+
const tmpFile = join13(tmpdir3(), `robinpath-add-${Date.now()}.tar.gz`);
|
|
24908
|
+
writeFileSync7(tmpFile, tarballBuffer);
|
|
24825
24909
|
try {
|
|
24826
24910
|
execSync2(`tar xzf "${toTarPath(tmpFile)}" --strip-components=1 -C "${toTarPath(modDir)}"`, { stdio: "pipe" });
|
|
24827
24911
|
} catch (err) {
|
|
@@ -24837,15 +24921,15 @@ async function handleAdd(args) {
|
|
|
24837
24921
|
unlinkSync5(tmpFile);
|
|
24838
24922
|
} catch {
|
|
24839
24923
|
}
|
|
24840
|
-
const distDir =
|
|
24841
|
-
const srcDir =
|
|
24842
|
-
if (!
|
|
24924
|
+
const distDir = join13(modDir, "dist");
|
|
24925
|
+
const srcDir = join13(modDir, "src");
|
|
24926
|
+
if (!existsSync12(distDir) && existsSync12(srcDir) && existsSync12(join13(srcDir, "index.ts"))) {
|
|
24843
24927
|
log(color.dim(" Compiling module..."));
|
|
24844
|
-
|
|
24845
|
-
const tsFiles =
|
|
24928
|
+
mkdirSync7(distDir, { recursive: true });
|
|
24929
|
+
const tsFiles = readdirSync7(srcDir).filter((f) => f.endsWith(".ts"));
|
|
24846
24930
|
for (const file of tsFiles) {
|
|
24847
|
-
const srcFile =
|
|
24848
|
-
const outFile =
|
|
24931
|
+
const srcFile = join13(srcDir, file);
|
|
24932
|
+
const outFile = join13(distDir, file.replace(".ts", ".js"));
|
|
24849
24933
|
try {
|
|
24850
24934
|
const stripScript = `
|
|
24851
24935
|
const fs = require('fs');
|
|
@@ -24861,17 +24945,17 @@ async function handleAdd(args) {
|
|
|
24861
24945
|
}
|
|
24862
24946
|
}
|
|
24863
24947
|
let installedVersion = resolvedVersion;
|
|
24864
|
-
const pkgJsonPath =
|
|
24865
|
-
if (
|
|
24948
|
+
const pkgJsonPath = join13(modDir, "package.json");
|
|
24949
|
+
if (existsSync12(pkgJsonPath)) {
|
|
24866
24950
|
try {
|
|
24867
|
-
const pkg = JSON.parse(
|
|
24951
|
+
const pkg = JSON.parse(readFileSync11(pkgJsonPath, "utf-8"));
|
|
24868
24952
|
installedVersion = pkg.version || installedVersion;
|
|
24869
24953
|
} catch {
|
|
24870
24954
|
}
|
|
24871
24955
|
}
|
|
24872
|
-
if (
|
|
24956
|
+
if (existsSync12(pkgJsonPath)) {
|
|
24873
24957
|
try {
|
|
24874
|
-
const pkg = JSON.parse(
|
|
24958
|
+
const pkg = JSON.parse(readFileSync11(pkgJsonPath, "utf-8"));
|
|
24875
24959
|
const depends = pkg.robinpath?.depends || [];
|
|
24876
24960
|
for (const dep of depends) {
|
|
24877
24961
|
if (!manifest[dep]) {
|
|
@@ -24890,12 +24974,12 @@ async function handleAdd(args) {
|
|
|
24890
24974
|
};
|
|
24891
24975
|
writeModulesManifest(updatedManifest);
|
|
24892
24976
|
const projectFile = resolve8("robinpath.json");
|
|
24893
|
-
if (
|
|
24977
|
+
if (existsSync12(projectFile)) {
|
|
24894
24978
|
try {
|
|
24895
|
-
const config = JSON.parse(
|
|
24979
|
+
const config = JSON.parse(readFileSync11(projectFile, "utf-8"));
|
|
24896
24980
|
if (!config.modules) config.modules = {};
|
|
24897
24981
|
config.modules[fullName] = `^${installedVersion}`;
|
|
24898
|
-
|
|
24982
|
+
writeFileSync7(projectFile, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
24899
24983
|
} catch {
|
|
24900
24984
|
}
|
|
24901
24985
|
}
|
|
@@ -24920,12 +25004,12 @@ async function handleRemove(args) {
|
|
|
24920
25004
|
process.exit(1);
|
|
24921
25005
|
}
|
|
24922
25006
|
const modDir = getModulePath(fullName);
|
|
24923
|
-
if (
|
|
25007
|
+
if (existsSync12(modDir)) {
|
|
24924
25008
|
rmSync2(modDir, { recursive: true, force: true });
|
|
24925
25009
|
}
|
|
24926
25010
|
const scopeDir = dirname4(modDir);
|
|
24927
25011
|
try {
|
|
24928
|
-
const remaining =
|
|
25012
|
+
const remaining = readdirSync7(scopeDir);
|
|
24929
25013
|
if (remaining.length === 0) {
|
|
24930
25014
|
rmSync2(scopeDir, { recursive: true, force: true });
|
|
24931
25015
|
}
|
|
@@ -24934,12 +25018,12 @@ async function handleRemove(args) {
|
|
|
24934
25018
|
delete manifest[fullName];
|
|
24935
25019
|
writeModulesManifest(manifest);
|
|
24936
25020
|
const projectFile = resolve8("robinpath.json");
|
|
24937
|
-
if (
|
|
25021
|
+
if (existsSync12(projectFile)) {
|
|
24938
25022
|
try {
|
|
24939
|
-
const config = JSON.parse(
|
|
25023
|
+
const config = JSON.parse(readFileSync11(projectFile, "utf-8"));
|
|
24940
25024
|
if (config.modules && config.modules[fullName]) {
|
|
24941
25025
|
delete config.modules[fullName];
|
|
24942
|
-
|
|
25026
|
+
writeFileSync7(projectFile, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
24943
25027
|
}
|
|
24944
25028
|
} catch {
|
|
24945
25029
|
}
|
|
@@ -25109,14 +25193,14 @@ async function handleModulesInit() {
|
|
|
25109
25193
|
const targetDir = resolve8(moduleName);
|
|
25110
25194
|
log("");
|
|
25111
25195
|
log(`Creating ${color.cyan(fullName)}...`);
|
|
25112
|
-
if (
|
|
25196
|
+
if (existsSync12(targetDir)) {
|
|
25113
25197
|
console.error(color.red("Error:") + ` Directory already exists: ${moduleName}/`);
|
|
25114
25198
|
process.exit(1);
|
|
25115
25199
|
}
|
|
25116
|
-
|
|
25117
|
-
|
|
25118
|
-
|
|
25119
|
-
|
|
25200
|
+
mkdirSync7(join13(targetDir, "src"), { recursive: true });
|
|
25201
|
+
mkdirSync7(join13(targetDir, "tests"), { recursive: true });
|
|
25202
|
+
writeFileSync7(
|
|
25203
|
+
join13(targetDir, "package.json"),
|
|
25120
25204
|
JSON.stringify(
|
|
25121
25205
|
{
|
|
25122
25206
|
name: fullName,
|
|
@@ -25139,8 +25223,8 @@ async function handleModulesInit() {
|
|
|
25139
25223
|
) + "\n",
|
|
25140
25224
|
"utf-8"
|
|
25141
25225
|
);
|
|
25142
|
-
|
|
25143
|
-
|
|
25226
|
+
writeFileSync7(
|
|
25227
|
+
join13(targetDir, "src", "index.ts"),
|
|
25144
25228
|
`import type { ModuleAdapter } from "@wiredwp/robinpath";
|
|
25145
25229
|
import {
|
|
25146
25230
|
${pascalName}Functions,
|
|
@@ -25161,8 +25245,8 @@ export { ${pascalName}Module };
|
|
|
25161
25245
|
`,
|
|
25162
25246
|
"utf-8"
|
|
25163
25247
|
);
|
|
25164
|
-
|
|
25165
|
-
|
|
25248
|
+
writeFileSync7(
|
|
25249
|
+
join13(targetDir, "src", `${moduleName}.ts`),
|
|
25166
25250
|
`import type {
|
|
25167
25251
|
BuiltinHandler,
|
|
25168
25252
|
FunctionMetadata,
|
|
@@ -25232,8 +25316,8 @@ export const ${pascalName}ModuleMetadata: ModuleMetadata = {
|
|
|
25232
25316
|
`,
|
|
25233
25317
|
"utf-8"
|
|
25234
25318
|
);
|
|
25235
|
-
|
|
25236
|
-
|
|
25319
|
+
writeFileSync7(
|
|
25320
|
+
join13(targetDir, "tsconfig.json"),
|
|
25237
25321
|
JSON.stringify(
|
|
25238
25322
|
{
|
|
25239
25323
|
compilerOptions: {
|
|
@@ -25256,8 +25340,8 @@ export const ${pascalName}ModuleMetadata: ModuleMetadata = {
|
|
|
25256
25340
|
) + "\n",
|
|
25257
25341
|
"utf-8"
|
|
25258
25342
|
);
|
|
25259
|
-
|
|
25260
|
-
|
|
25343
|
+
writeFileSync7(
|
|
25344
|
+
join13(targetDir, "tests", `${moduleName}.test.rp`),
|
|
25261
25345
|
`# ${displayName} module tests
|
|
25262
25346
|
# Run: robinpath test tests/
|
|
25263
25347
|
|
|
@@ -25275,8 +25359,8 @@ enddo
|
|
|
25275
25359
|
`,
|
|
25276
25360
|
"utf-8"
|
|
25277
25361
|
);
|
|
25278
|
-
|
|
25279
|
-
|
|
25362
|
+
writeFileSync7(
|
|
25363
|
+
join13(targetDir, "README.md"),
|
|
25280
25364
|
`# ${fullName}
|
|
25281
25365
|
|
|
25282
25366
|
${description}
|
|
@@ -25319,8 +25403,8 @@ ${license}
|
|
|
25319
25403
|
`,
|
|
25320
25404
|
"utf-8"
|
|
25321
25405
|
);
|
|
25322
|
-
|
|
25323
|
-
|
|
25406
|
+
writeFileSync7(
|
|
25407
|
+
join13(targetDir, ".gitignore"),
|
|
25324
25408
|
`node_modules/
|
|
25325
25409
|
dist/
|
|
25326
25410
|
*.tgz
|
|
@@ -25350,14 +25434,14 @@ dist/
|
|
|
25350
25434
|
async function handlePack(args) {
|
|
25351
25435
|
const targetArg = args.find((a) => !a.startsWith("-")) || ".";
|
|
25352
25436
|
const targetDir = resolve8(targetArg);
|
|
25353
|
-
const pkgPath =
|
|
25354
|
-
if (!
|
|
25437
|
+
const pkgPath = join13(targetDir, "package.json");
|
|
25438
|
+
if (!existsSync12(pkgPath)) {
|
|
25355
25439
|
console.error(color.red("Error:") + ` No package.json found in ${targetDir}`);
|
|
25356
25440
|
process.exit(2);
|
|
25357
25441
|
}
|
|
25358
25442
|
let pkg;
|
|
25359
25443
|
try {
|
|
25360
|
-
pkg = JSON.parse(
|
|
25444
|
+
pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
25361
25445
|
} catch (err) {
|
|
25362
25446
|
console.error(color.red("Error:") + ` Invalid package.json: ${err.message}`);
|
|
25363
25447
|
process.exit(2);
|
|
@@ -25378,12 +25462,12 @@ async function handlePack(args) {
|
|
|
25378
25462
|
{ stdio: "pipe" }
|
|
25379
25463
|
);
|
|
25380
25464
|
} catch (err) {
|
|
25381
|
-
if (!
|
|
25465
|
+
if (!existsSync12(outputPath)) {
|
|
25382
25466
|
console.error(color.red("Error:") + ` Failed to create tarball: ${err.message}`);
|
|
25383
25467
|
process.exit(1);
|
|
25384
25468
|
}
|
|
25385
25469
|
}
|
|
25386
|
-
const size =
|
|
25470
|
+
const size = statSync7(outputPath).size;
|
|
25387
25471
|
log(color.green("Created") + ` ${outputFile} (${(size / 1024).toFixed(1)}KB)`);
|
|
25388
25472
|
}
|
|
25389
25473
|
function formatCompactNumber(n) {
|
|
@@ -25532,9 +25616,9 @@ async function handleInfo(args) {
|
|
|
25532
25616
|
path: getModulePath(packageName)
|
|
25533
25617
|
};
|
|
25534
25618
|
try {
|
|
25535
|
-
const pkgPath =
|
|
25536
|
-
if (
|
|
25537
|
-
const pkg = JSON.parse(
|
|
25619
|
+
const pkgPath = join13(getModulePath(packageName), "package.json");
|
|
25620
|
+
if (existsSync12(pkgPath)) {
|
|
25621
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
25538
25622
|
if (pkg.description) entry.description = pkg.description;
|
|
25539
25623
|
if (pkg.keywords) entry.keywords = pkg.keywords;
|
|
25540
25624
|
}
|
|
@@ -25558,9 +25642,9 @@ async function handleInfo(args) {
|
|
|
25558
25642
|
modules_manifest: MODULES_MANIFEST,
|
|
25559
25643
|
cache: CACHE_DIR,
|
|
25560
25644
|
auth: getAuthPath(),
|
|
25561
|
-
history:
|
|
25562
|
-
env:
|
|
25563
|
-
docs:
|
|
25645
|
+
history: join13(homedir9(), ".robinpath", "history"),
|
|
25646
|
+
env: join13(homedir9(), ".robinpath", "env"),
|
|
25647
|
+
docs: join13(getRobinPathHome(), "DOCUMENTATION.md")
|
|
25564
25648
|
},
|
|
25565
25649
|
native_modules: modulesInfo,
|
|
25566
25650
|
installed_modules: installedModulesInfo,
|
|
@@ -25949,14 +26033,14 @@ async function handleInfo(args) {
|
|
|
25949
26033
|
}
|
|
25950
26034
|
|
|
25951
26035
|
// src/commands-project.ts
|
|
25952
|
-
import { readFileSync as
|
|
25953
|
-
import { resolve as resolve9, join as
|
|
26036
|
+
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";
|
|
26037
|
+
import { resolve as resolve9, join as join14, basename as basename5 } from "node:path";
|
|
25954
26038
|
import { createInterface as createInterface4 } from "node:readline";
|
|
25955
26039
|
import { platform as platform9 } from "node:os";
|
|
25956
26040
|
var PLATFORM_URL3 = process.env.ROBINPATH_PLATFORM_URL || "https://api.robinpath.com";
|
|
25957
26041
|
async function handleInit(args) {
|
|
25958
26042
|
const projectFile = resolve9("robinpath.json");
|
|
25959
|
-
if (
|
|
26043
|
+
if (existsSync13(projectFile) && !args.includes("--force")) {
|
|
25960
26044
|
console.error(color.red("Error:") + " robinpath.json already exists. Use --force to overwrite.");
|
|
25961
26045
|
process.exit(1);
|
|
25962
26046
|
}
|
|
@@ -25985,10 +26069,10 @@ async function handleInit(args) {
|
|
|
25985
26069
|
modules: {},
|
|
25986
26070
|
env: {}
|
|
25987
26071
|
};
|
|
25988
|
-
|
|
26072
|
+
writeFileSync8(projectFile, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
25989
26073
|
const mainPath = resolve9(mainFile);
|
|
25990
|
-
if (!
|
|
25991
|
-
|
|
26074
|
+
if (!existsSync13(mainPath)) {
|
|
26075
|
+
writeFileSync8(
|
|
25992
26076
|
mainPath,
|
|
25993
26077
|
`# ${projectName}
|
|
25994
26078
|
# Run: robinpath ${mainFile}
|
|
@@ -25998,8 +26082,8 @@ log "Hello from RobinPath!"
|
|
|
25998
26082
|
"utf-8"
|
|
25999
26083
|
);
|
|
26000
26084
|
}
|
|
26001
|
-
if (!
|
|
26002
|
-
|
|
26085
|
+
if (!existsSync13(resolve9(".env"))) {
|
|
26086
|
+
writeFileSync8(
|
|
26003
26087
|
resolve9(".env"),
|
|
26004
26088
|
`# Add your secrets here
|
|
26005
26089
|
# SLACK_TOKEN=xoxb-...
|
|
@@ -26008,8 +26092,8 @@ log "Hello from RobinPath!"
|
|
|
26008
26092
|
"utf-8"
|
|
26009
26093
|
);
|
|
26010
26094
|
}
|
|
26011
|
-
if (!
|
|
26012
|
-
|
|
26095
|
+
if (!existsSync13(resolve9(".gitignore"))) {
|
|
26096
|
+
writeFileSync8(
|
|
26013
26097
|
resolve9(".gitignore"),
|
|
26014
26098
|
`.env
|
|
26015
26099
|
.robinpath/
|
|
@@ -26021,7 +26105,7 @@ node_modules/
|
|
|
26021
26105
|
log("");
|
|
26022
26106
|
log(color.green("Created project:"));
|
|
26023
26107
|
log(` robinpath.json`);
|
|
26024
|
-
if (!
|
|
26108
|
+
if (!existsSync13(mainPath)) log(` ${mainFile}`);
|
|
26025
26109
|
log(` .env`);
|
|
26026
26110
|
log(` .gitignore`);
|
|
26027
26111
|
log("");
|
|
@@ -26030,13 +26114,13 @@ node_modules/
|
|
|
26030
26114
|
}
|
|
26031
26115
|
async function handleProjectInstall() {
|
|
26032
26116
|
const projectFile = resolve9("robinpath.json");
|
|
26033
|
-
if (!
|
|
26117
|
+
if (!existsSync13(projectFile)) {
|
|
26034
26118
|
handleInstall();
|
|
26035
26119
|
return;
|
|
26036
26120
|
}
|
|
26037
26121
|
let config;
|
|
26038
26122
|
try {
|
|
26039
|
-
config = JSON.parse(
|
|
26123
|
+
config = JSON.parse(readFileSync12(projectFile, "utf-8"));
|
|
26040
26124
|
} catch (err) {
|
|
26041
26125
|
console.error(color.red("Error:") + ` Invalid robinpath.json: ${err.message}`);
|
|
26042
26126
|
process.exit(2);
|
|
@@ -26088,7 +26172,7 @@ async function handleProjectInstall() {
|
|
|
26088
26172
|
};
|
|
26089
26173
|
}
|
|
26090
26174
|
}
|
|
26091
|
-
|
|
26175
|
+
writeFileSync8(lockFile, JSON.stringify(lockData, null, 2) + "\n", "utf-8");
|
|
26092
26176
|
log("");
|
|
26093
26177
|
const parts = [];
|
|
26094
26178
|
if (installed > 0) parts.push(color.green(`${installed} installed`));
|
|
@@ -26107,7 +26191,7 @@ async function handleDoctor() {
|
|
|
26107
26191
|
const installDir = getInstallDir();
|
|
26108
26192
|
const isWindows = platform9() === "win32";
|
|
26109
26193
|
const binaryName = isWindows ? "robinpath.exe" : "robinpath";
|
|
26110
|
-
if (
|
|
26194
|
+
if (existsSync13(join14(installDir, binaryName))) {
|
|
26111
26195
|
log(color.green(" \u2713") + ` Installed: ${installDir}`);
|
|
26112
26196
|
} else {
|
|
26113
26197
|
log(color.yellow(" !") + ` Not installed to PATH. Run ${color.cyan("robinpath install")}`);
|
|
@@ -26134,21 +26218,21 @@ async function handleDoctor() {
|
|
|
26134
26218
|
log(color.green(" \u2713") + ` ${moduleCount} module${moduleCount !== 1 ? "s" : ""} installed`);
|
|
26135
26219
|
for (const [name, info] of Object.entries(manifest)) {
|
|
26136
26220
|
const modDir = getModulePath(name);
|
|
26137
|
-
const pkgPath =
|
|
26138
|
-
if (!
|
|
26221
|
+
const pkgPath = join14(modDir, "package.json");
|
|
26222
|
+
if (!existsSync13(modDir)) {
|
|
26139
26223
|
log(color.red(" \u2717") + ` ${name}: directory missing`);
|
|
26140
26224
|
issues++;
|
|
26141
|
-
} else if (!
|
|
26225
|
+
} else if (!existsSync13(pkgPath)) {
|
|
26142
26226
|
log(color.red(" \u2717") + ` ${name}: package.json missing`);
|
|
26143
26227
|
issues++;
|
|
26144
26228
|
} else {
|
|
26145
26229
|
let entryPoint = "dist/index.js";
|
|
26146
26230
|
try {
|
|
26147
|
-
const pkg = JSON.parse(
|
|
26231
|
+
const pkg = JSON.parse(readFileSync12(pkgPath, "utf-8"));
|
|
26148
26232
|
if (pkg.main) entryPoint = pkg.main;
|
|
26149
26233
|
} catch {
|
|
26150
26234
|
}
|
|
26151
|
-
if (!
|
|
26235
|
+
if (!existsSync13(join14(modDir, entryPoint))) {
|
|
26152
26236
|
log(color.red(" \u2717") + ` ${name}: entry point ${entryPoint} missing`);
|
|
26153
26237
|
issues++;
|
|
26154
26238
|
}
|
|
@@ -26158,9 +26242,9 @@ async function handleDoctor() {
|
|
|
26158
26242
|
log(color.dim(" -") + ` No modules installed`);
|
|
26159
26243
|
}
|
|
26160
26244
|
const projectFile = resolve9("robinpath.json");
|
|
26161
|
-
if (
|
|
26245
|
+
if (existsSync13(projectFile)) {
|
|
26162
26246
|
try {
|
|
26163
|
-
const config = JSON.parse(
|
|
26247
|
+
const config = JSON.parse(readFileSync12(projectFile, "utf-8"));
|
|
26164
26248
|
log(color.green(" \u2713") + ` Project: ${config.name || "unnamed"} v${config.version || "?"}`);
|
|
26165
26249
|
const projectModules = Object.keys(config.modules || {});
|
|
26166
26250
|
for (const mod of projectModules) {
|
|
@@ -26174,12 +26258,12 @@ async function handleDoctor() {
|
|
|
26174
26258
|
issues++;
|
|
26175
26259
|
}
|
|
26176
26260
|
}
|
|
26177
|
-
if (
|
|
26261
|
+
if (existsSync13(CACHE_DIR)) {
|
|
26178
26262
|
try {
|
|
26179
|
-
const cacheFiles =
|
|
26263
|
+
const cacheFiles = readdirSync8(CACHE_DIR);
|
|
26180
26264
|
const cacheSize = cacheFiles.reduce((total, f) => {
|
|
26181
26265
|
try {
|
|
26182
|
-
return total +
|
|
26266
|
+
return total + statSync8(join14(CACHE_DIR, f)).size;
|
|
26183
26267
|
} catch {
|
|
26184
26268
|
return total;
|
|
26185
26269
|
}
|
|
@@ -26197,12 +26281,12 @@ async function handleDoctor() {
|
|
|
26197
26281
|
log("");
|
|
26198
26282
|
}
|
|
26199
26283
|
async function handleEnv(args) {
|
|
26200
|
-
const envPath =
|
|
26284
|
+
const envPath = join14(getRobinPathHome(), "env");
|
|
26201
26285
|
const sub = args[0];
|
|
26202
26286
|
function readEnvFile() {
|
|
26203
26287
|
try {
|
|
26204
|
-
if (!
|
|
26205
|
-
const lines =
|
|
26288
|
+
if (!existsSync13(envPath)) return {};
|
|
26289
|
+
const lines = readFileSync12(envPath, "utf-8").split("\n");
|
|
26206
26290
|
const env = {};
|
|
26207
26291
|
for (const line of lines) {
|
|
26208
26292
|
const trimmed = line.trim();
|
|
@@ -26219,9 +26303,9 @@ async function handleEnv(args) {
|
|
|
26219
26303
|
}
|
|
26220
26304
|
function writeEnvFile(env) {
|
|
26221
26305
|
const dir = getRobinPathHome();
|
|
26222
|
-
if (!
|
|
26306
|
+
if (!existsSync13(dir)) mkdirSync8(dir, { recursive: true });
|
|
26223
26307
|
const content = Object.entries(env).map(([k2, v]) => `${k2}=${v}`).join("\n") + "\n";
|
|
26224
|
-
|
|
26308
|
+
writeFileSync8(envPath, content, "utf-8");
|
|
26225
26309
|
if (platform9() !== "win32") {
|
|
26226
26310
|
try {
|
|
26227
26311
|
chmodSync3(envPath, 384);
|
|
@@ -26283,12 +26367,12 @@ async function handleEnv(args) {
|
|
|
26283
26367
|
async function handleCache(args) {
|
|
26284
26368
|
const sub = args[0];
|
|
26285
26369
|
if (sub === "list") {
|
|
26286
|
-
if (!
|
|
26370
|
+
if (!existsSync13(CACHE_DIR)) {
|
|
26287
26371
|
log("Cache is empty.");
|
|
26288
26372
|
return;
|
|
26289
26373
|
}
|
|
26290
26374
|
try {
|
|
26291
|
-
const files =
|
|
26375
|
+
const files = readdirSync8(CACHE_DIR);
|
|
26292
26376
|
if (files.length === 0) {
|
|
26293
26377
|
log("Cache is empty.");
|
|
26294
26378
|
return;
|
|
@@ -26298,7 +26382,7 @@ async function handleCache(args) {
|
|
|
26298
26382
|
log(color.dim(" " + "\u2500".repeat(50)));
|
|
26299
26383
|
let totalSize = 0;
|
|
26300
26384
|
for (const file of files) {
|
|
26301
|
-
const size =
|
|
26385
|
+
const size = statSync8(join14(CACHE_DIR, file)).size;
|
|
26302
26386
|
totalSize += size;
|
|
26303
26387
|
log(` ${file.padEnd(45)} ${color.dim((size / 1024).toFixed(1) + "KB")}`);
|
|
26304
26388
|
}
|
|
@@ -26314,15 +26398,15 @@ async function handleCache(args) {
|
|
|
26314
26398
|
process.exit(1);
|
|
26315
26399
|
}
|
|
26316
26400
|
} else if (sub === "clean") {
|
|
26317
|
-
if (!
|
|
26401
|
+
if (!existsSync13(CACHE_DIR)) {
|
|
26318
26402
|
log("Cache is already empty.");
|
|
26319
26403
|
return;
|
|
26320
26404
|
}
|
|
26321
26405
|
try {
|
|
26322
|
-
const files =
|
|
26406
|
+
const files = readdirSync8(CACHE_DIR);
|
|
26323
26407
|
let totalSize = 0;
|
|
26324
26408
|
for (const file of files) {
|
|
26325
|
-
totalSize +=
|
|
26409
|
+
totalSize += statSync8(join14(CACHE_DIR, file)).size;
|
|
26326
26410
|
}
|
|
26327
26411
|
rmSync3(CACHE_DIR, { recursive: true, force: true });
|
|
26328
26412
|
log(
|
|
@@ -26437,8 +26521,8 @@ async function handleDeprecate(args) {
|
|
|
26437
26521
|
}
|
|
26438
26522
|
|
|
26439
26523
|
// src/commands-snippets.ts
|
|
26440
|
-
import { readFileSync as
|
|
26441
|
-
import { resolve as resolve10, basename as basename6, extname as extname4, join as
|
|
26524
|
+
import { readFileSync as readFileSync13, existsSync as existsSync14, mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
|
|
26525
|
+
import { resolve as resolve10, basename as basename6, extname as extname4, join as join15 } from "node:path";
|
|
26442
26526
|
import { homedir as homedir10, platform as platform10 } from "node:os";
|
|
26443
26527
|
import { createInterface as createInterface5 } from "node:readline";
|
|
26444
26528
|
var PLATFORM_URL4 = process.env.ROBINPATH_PLATFORM_URL || "https://api.robinpath.com";
|
|
@@ -26674,11 +26758,11 @@ async function snippetCreate(args) {
|
|
|
26674
26758
|
defaultName = "untitled";
|
|
26675
26759
|
} else {
|
|
26676
26760
|
const filePath = resolve10(fileArg);
|
|
26677
|
-
if (!
|
|
26761
|
+
if (!existsSync14(filePath)) {
|
|
26678
26762
|
console.error(color.red("Error:") + ` File not found: ${fileArg}`);
|
|
26679
26763
|
process.exit(1);
|
|
26680
26764
|
}
|
|
26681
|
-
code =
|
|
26765
|
+
code = readFileSync13(filePath, "utf-8");
|
|
26682
26766
|
defaultName = basename6(filePath, extname4(filePath));
|
|
26683
26767
|
}
|
|
26684
26768
|
if (!code || !code.trim()) {
|
|
@@ -26700,8 +26784,8 @@ async function snippetCreate(args) {
|
|
|
26700
26784
|
if (flags.version) payload.version = flags.version;
|
|
26701
26785
|
if (flags.readme) {
|
|
26702
26786
|
const readmePath = resolve10(flags.readme);
|
|
26703
|
-
if (
|
|
26704
|
-
payload.readme =
|
|
26787
|
+
if (existsSync14(readmePath)) {
|
|
26788
|
+
payload.readme = readFileSync13(readmePath, "utf-8");
|
|
26705
26789
|
}
|
|
26706
26790
|
}
|
|
26707
26791
|
try {
|
|
@@ -26784,12 +26868,12 @@ async function snippetInit(args) {
|
|
|
26784
26868
|
code = codeLines.join("\n");
|
|
26785
26869
|
} else {
|
|
26786
26870
|
const filePath = await ask("File path", "");
|
|
26787
|
-
if (!filePath || !
|
|
26871
|
+
if (!filePath || !existsSync14(resolve10(filePath))) {
|
|
26788
26872
|
console.error(color.red("Error:") + " File not found.");
|
|
26789
26873
|
rl.close();
|
|
26790
26874
|
process.exit(1);
|
|
26791
26875
|
}
|
|
26792
|
-
code =
|
|
26876
|
+
code = readFileSync13(resolve10(filePath), "utf-8");
|
|
26793
26877
|
}
|
|
26794
26878
|
rl.close();
|
|
26795
26879
|
if (!code.trim()) {
|
|
@@ -26946,16 +27030,16 @@ async function snippetUpdate(args) {
|
|
|
26946
27030
|
payload.tags = flags.tags.split(",").map((t) => t.trim()).filter(Boolean);
|
|
26947
27031
|
if (flags.code) {
|
|
26948
27032
|
const codePath = resolve10(flags.code);
|
|
26949
|
-
if (!
|
|
27033
|
+
if (!existsSync14(codePath)) {
|
|
26950
27034
|
console.error(color.red("Error:") + ` Code file not found: ${flags.code}`);
|
|
26951
27035
|
process.exit(1);
|
|
26952
27036
|
}
|
|
26953
|
-
payload.code =
|
|
27037
|
+
payload.code = readFileSync13(codePath, "utf-8");
|
|
26954
27038
|
}
|
|
26955
27039
|
if (flags.readme) {
|
|
26956
27040
|
const readmePath = resolve10(flags.readme);
|
|
26957
|
-
if (
|
|
26958
|
-
payload.readme =
|
|
27041
|
+
if (existsSync14(readmePath)) {
|
|
27042
|
+
payload.readme = readFileSync13(readmePath, "utf-8");
|
|
26959
27043
|
}
|
|
26960
27044
|
}
|
|
26961
27045
|
if (Object.keys(payload).length === 0) {
|
|
@@ -27331,16 +27415,16 @@ async function snippetCopy(args) {
|
|
|
27331
27415
|
process.exit(1);
|
|
27332
27416
|
}
|
|
27333
27417
|
}
|
|
27334
|
-
var SNIPPET_CACHE_DIR =
|
|
27418
|
+
var SNIPPET_CACHE_DIR = join15(homedir10(), ".robinpath", "cache", "snippets");
|
|
27335
27419
|
var SNIPPET_CACHE_TTL = 5 * 60 * 1e3;
|
|
27336
27420
|
function getSnippetCachePath(id) {
|
|
27337
|
-
return
|
|
27421
|
+
return join15(SNIPPET_CACHE_DIR, `${id}.json`);
|
|
27338
27422
|
}
|
|
27339
27423
|
function readSnippetCache(id) {
|
|
27340
27424
|
try {
|
|
27341
27425
|
const cachePath = getSnippetCachePath(id);
|
|
27342
|
-
if (!
|
|
27343
|
-
const raw = JSON.parse(
|
|
27426
|
+
if (!existsSync14(cachePath)) return null;
|
|
27427
|
+
const raw = JSON.parse(readFileSync13(cachePath, "utf-8"));
|
|
27344
27428
|
if (Date.now() - (raw._cachedAt || 0) > SNIPPET_CACHE_TTL) return null;
|
|
27345
27429
|
return raw;
|
|
27346
27430
|
} catch {
|
|
@@ -27349,10 +27433,10 @@ function readSnippetCache(id) {
|
|
|
27349
27433
|
}
|
|
27350
27434
|
function writeSnippetCache(id, data) {
|
|
27351
27435
|
try {
|
|
27352
|
-
if (!
|
|
27353
|
-
|
|
27436
|
+
if (!existsSync14(SNIPPET_CACHE_DIR)) {
|
|
27437
|
+
mkdirSync9(SNIPPET_CACHE_DIR, { recursive: true });
|
|
27354
27438
|
}
|
|
27355
|
-
|
|
27439
|
+
writeFileSync9(getSnippetCachePath(id), JSON.stringify({ ...data, _cachedAt: Date.now() }), "utf-8");
|
|
27356
27440
|
} catch {
|
|
27357
27441
|
}
|
|
27358
27442
|
}
|
|
@@ -27435,7 +27519,7 @@ async function snippetPull(args) {
|
|
|
27435
27519
|
const sanitizedName = (s.name || "snippet").replace(/[^a-zA-Z0-9_\-]/g, "_").toLowerCase();
|
|
27436
27520
|
const fileName = outputFile || `${sanitizedName}.rp`;
|
|
27437
27521
|
const filePath = resolve10(fileName);
|
|
27438
|
-
|
|
27522
|
+
writeFileSync9(filePath, code, "utf-8");
|
|
27439
27523
|
if (flags.json) {
|
|
27440
27524
|
console.log(JSON.stringify({ id, name: s.name, file: filePath, bytes: Buffer.byteLength(code) }, null, 2));
|
|
27441
27525
|
return;
|
|
@@ -27463,11 +27547,11 @@ async function snippetPush(args) {
|
|
|
27463
27547
|
}
|
|
27464
27548
|
id = await resolveSnippetId(id);
|
|
27465
27549
|
const filePath = resolve10(fileArg);
|
|
27466
|
-
if (!
|
|
27550
|
+
if (!existsSync14(filePath)) {
|
|
27467
27551
|
console.error(color.red("Error:") + ` File not found: ${fileArg}`);
|
|
27468
27552
|
process.exit(1);
|
|
27469
27553
|
}
|
|
27470
|
-
const code =
|
|
27554
|
+
const code = readFileSync13(filePath, "utf-8");
|
|
27471
27555
|
if (!code.trim()) {
|
|
27472
27556
|
console.error(color.red("Error:") + " File is empty.");
|
|
27473
27557
|
process.exit(1);
|
|
@@ -27551,11 +27635,11 @@ async function snippetDiff(args) {
|
|
|
27551
27635
|
}
|
|
27552
27636
|
id = await resolveSnippetId(id);
|
|
27553
27637
|
const filePath = resolve10(fileArg);
|
|
27554
|
-
if (!
|
|
27638
|
+
if (!existsSync14(filePath)) {
|
|
27555
27639
|
console.error(color.red("Error:") + ` File not found: ${fileArg}`);
|
|
27556
27640
|
process.exit(1);
|
|
27557
27641
|
}
|
|
27558
|
-
const localCode =
|
|
27642
|
+
const localCode = readFileSync13(filePath, "utf-8");
|
|
27559
27643
|
try {
|
|
27560
27644
|
const res = await fetchSnippet(id);
|
|
27561
27645
|
if (!res.ok) {
|
|
@@ -27657,7 +27741,7 @@ async function snippetExport(args) {
|
|
|
27657
27741
|
if (flags.json || !flags.format || flags.format === "json") {
|
|
27658
27742
|
const outputFile = flags.positional[0] || "snippets-export.json";
|
|
27659
27743
|
const filePath = resolve10(outputFile);
|
|
27660
|
-
|
|
27744
|
+
writeFileSync9(filePath, JSON.stringify(exportData, null, 2), "utf-8");
|
|
27661
27745
|
log(
|
|
27662
27746
|
color.green("\u2713") + ` Exported ${allSnippets.length} snippet${allSnippets.length !== 1 ? "s" : ""} to: ${color.cyan(outputFile)}`
|
|
27663
27747
|
);
|
|
@@ -27675,13 +27759,13 @@ async function snippetImport(args) {
|
|
|
27675
27759
|
process.exit(2);
|
|
27676
27760
|
}
|
|
27677
27761
|
const filePath = resolve10(fileArg);
|
|
27678
|
-
if (!
|
|
27762
|
+
if (!existsSync14(filePath)) {
|
|
27679
27763
|
console.error(color.red("Error:") + ` File not found: ${fileArg}`);
|
|
27680
27764
|
process.exit(1);
|
|
27681
27765
|
}
|
|
27682
27766
|
let importData;
|
|
27683
27767
|
try {
|
|
27684
|
-
importData = JSON.parse(
|
|
27768
|
+
importData = JSON.parse(readFileSync13(filePath, "utf-8"));
|
|
27685
27769
|
} catch {
|
|
27686
27770
|
console.error(color.red("Error:") + " Invalid JSON file.");
|
|
27687
27771
|
process.exit(1);
|
|
@@ -27748,8 +27832,8 @@ async function snippetImport(args) {
|
|
|
27748
27832
|
|
|
27749
27833
|
// src/commands-cloud.ts
|
|
27750
27834
|
import { createServer as createServer4 } from "node:http";
|
|
27751
|
-
import { readFileSync as
|
|
27752
|
-
import { resolve as resolve11, join as
|
|
27835
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync10, unlinkSync as unlinkSync6, existsSync as existsSync15 } from "node:fs";
|
|
27836
|
+
import { resolve as resolve11, join as join16, dirname as dirname5, basename as basename7 } from "node:path";
|
|
27753
27837
|
import { execSync as execSync3 } from "node:child_process";
|
|
27754
27838
|
import { tmpdir as tmpdir4, hostname as hostname3 } from "node:os";
|
|
27755
27839
|
var CLOUD_URL2 = process.env.ROBINPATH_CLOUD_URL || "https://dev.robinpath.com";
|
|
@@ -27885,14 +27969,14 @@ async function handlePublish(args) {
|
|
|
27885
27969
|
const isDryRun = args.includes("--dry-run");
|
|
27886
27970
|
const targetArg = args.find((a) => !a.startsWith("-") && !a.startsWith("--org")) || ".";
|
|
27887
27971
|
const targetDir = resolve11(targetArg);
|
|
27888
|
-
const pkgPath =
|
|
27889
|
-
if (!
|
|
27972
|
+
const pkgPath = join16(targetDir, "package.json");
|
|
27973
|
+
if (!existsSync15(pkgPath)) {
|
|
27890
27974
|
console.error(color.red("Error:") + ` No package.json found in ${targetDir}`);
|
|
27891
27975
|
process.exit(2);
|
|
27892
27976
|
}
|
|
27893
27977
|
let pkg;
|
|
27894
27978
|
try {
|
|
27895
|
-
pkg = JSON.parse(
|
|
27979
|
+
pkg = JSON.parse(readFileSync14(pkgPath, "utf-8"));
|
|
27896
27980
|
} catch (err) {
|
|
27897
27981
|
console.error(color.red("Error:") + ` Invalid package.json: ${err.message}`);
|
|
27898
27982
|
process.exit(2);
|
|
@@ -27910,7 +27994,7 @@ async function handlePublish(args) {
|
|
|
27910
27994
|
if (args.includes("--major")) pkg.version = `${major + 1}.0.0`;
|
|
27911
27995
|
else if (args.includes("--minor")) pkg.version = `${major}.${minor + 1}.0`;
|
|
27912
27996
|
else pkg.version = `${major}.${minor}.${patch + 1}`;
|
|
27913
|
-
|
|
27997
|
+
writeFileSync10(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
27914
27998
|
log(`Bumped version to ${color.cyan(pkg.version)}`);
|
|
27915
27999
|
}
|
|
27916
28000
|
let visibility = "public";
|
|
@@ -27936,7 +28020,7 @@ async function handlePublish(args) {
|
|
|
27936
28020
|
scope = emailPrefix;
|
|
27937
28021
|
name = pkg.name;
|
|
27938
28022
|
}
|
|
27939
|
-
const tmpFile =
|
|
28023
|
+
const tmpFile = join16(tmpdir4(), `robinpath-publish-${Date.now()}.tar.gz`);
|
|
27940
28024
|
const parentDir = dirname5(targetDir);
|
|
27941
28025
|
const dirName = basename7(targetDir);
|
|
27942
28026
|
log(`Packing @${scope}/${name}@${pkg.version} (${visibility})...`);
|
|
@@ -27953,7 +28037,7 @@ async function handlePublish(args) {
|
|
|
27953
28037
|
console.error(color.red("Error:") + ` Failed to create tarball: ${err.message}`);
|
|
27954
28038
|
process.exit(1);
|
|
27955
28039
|
}
|
|
27956
|
-
const tarball =
|
|
28040
|
+
const tarball = readFileSync14(tmpFile);
|
|
27957
28041
|
const maxSize = 50 * 1024 * 1024;
|
|
27958
28042
|
if (tarball.length > maxSize) {
|
|
27959
28043
|
unlinkSync6(tmpFile);
|
|
@@ -28265,7 +28349,7 @@ async function main() {
|
|
|
28265
28349
|
return;
|
|
28266
28350
|
}
|
|
28267
28351
|
if (command === "install") {
|
|
28268
|
-
|
|
28352
|
+
existsSync16(resolve12("robinpath.json")) ? await handleProjectInstall() : handleInstall();
|
|
28269
28353
|
return;
|
|
28270
28354
|
}
|
|
28271
28355
|
if (command === "uninstall") {
|
|
@@ -28384,7 +28468,7 @@ async function main() {
|
|
|
28384
28468
|
}
|
|
28385
28469
|
process.exit(2);
|
|
28386
28470
|
}
|
|
28387
|
-
const script =
|
|
28471
|
+
const script = readFileSync15(filePath, "utf-8");
|
|
28388
28472
|
const hasWatch = args.includes("--watch");
|
|
28389
28473
|
const hasShortWatch = args.includes("-w") && command !== "fmt";
|
|
28390
28474
|
if (hasWatch || hasShortWatch) {
|