nemonicon-cli 0.1.2 → 0.2.1
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/index.js +45 -23
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { Command as
|
|
4
|
+
import { Command as Command15 } from "commander";
|
|
5
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { dirname, join as join2 } from "path";
|
|
8
|
+
import updateNotifier from "update-notifier";
|
|
5
9
|
|
|
6
10
|
// src/commands/auth.ts
|
|
7
11
|
import { Command } from "commander";
|
|
@@ -123,9 +127,7 @@ var LOOPBACK_PORTS = [
|
|
|
123
127
|
33426,
|
|
124
128
|
33427
|
|
125
129
|
];
|
|
126
|
-
var REDIRECT_URIS =
|
|
127
|
-
(p) => `http://127.0.0.1:${p}/callback`
|
|
128
|
-
);
|
|
130
|
+
var REDIRECT_URIS = ["http://127.0.0.1/callback"];
|
|
129
131
|
var SCOPE = "mcp";
|
|
130
132
|
var CLIENT_NAME = "Nemonicon CLI";
|
|
131
133
|
var OauthError = class extends Error {
|
|
@@ -752,18 +754,7 @@ Config was saved to ~/.nemonicon/config.json \u2014 you can edit it manually.`
|
|
|
752
754
|
|
|
753
755
|
// src/commands/login.ts
|
|
754
756
|
import { Command as Command2 } from "commander";
|
|
755
|
-
import { createInterface as createInterface2 } from "readline";
|
|
756
757
|
var DEFAULT_API_URL2 = "https://app.nemonicon.com";
|
|
757
|
-
function prompt2(question, defaultValue) {
|
|
758
|
-
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
759
|
-
const suffix = defaultValue ? ` (${defaultValue})` : "";
|
|
760
|
-
return new Promise((resolve) => {
|
|
761
|
-
rl.question(`${question}${suffix}: `, (answer) => {
|
|
762
|
-
rl.close();
|
|
763
|
-
resolve(answer.trim() || defaultValue || "");
|
|
764
|
-
});
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
758
|
var loginCommand = new Command2("login").description(
|
|
768
759
|
"Sign in to Nemonicon via your browser using OAuth 2.1 + PKCE"
|
|
769
760
|
).option("--api-url <url>", "API server URL").option(
|
|
@@ -775,10 +766,7 @@ var loginCommand = new Command2("login").description(
|
|
|
775
766
|
).action(
|
|
776
767
|
async (options) => {
|
|
777
768
|
const existing = loadPartialConfig();
|
|
778
|
-
let apiUrl = options.apiUrl ?? existing?.apiUrl;
|
|
779
|
-
if (!apiUrl) {
|
|
780
|
-
apiUrl = await prompt2("API URL", DEFAULT_API_URL2);
|
|
781
|
-
}
|
|
769
|
+
let apiUrl = options.apiUrl ?? existing?.apiUrl ?? DEFAULT_API_URL2;
|
|
782
770
|
apiUrl = apiUrl.replace(/\/+$/, "");
|
|
783
771
|
const protectionBypass = options.protectionBypass ?? existing?.protectionBypass;
|
|
784
772
|
const apiUrlChanged = existing?.apiUrl !== void 0 && existing.apiUrl.replace(/\/+$/, "") !== apiUrl;
|
|
@@ -1180,9 +1168,9 @@ var updateCommand = new Command9("update").description("Update a single outline
|
|
|
1180
1168
|
|
|
1181
1169
|
// src/commands/delete.ts
|
|
1182
1170
|
import { Command as Command10 } from "commander";
|
|
1183
|
-
import { createInterface as
|
|
1171
|
+
import { createInterface as createInterface2 } from "readline";
|
|
1184
1172
|
function confirm(question) {
|
|
1185
|
-
const rl =
|
|
1173
|
+
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
1186
1174
|
return new Promise((resolve) => {
|
|
1187
1175
|
rl.question(`${question} [y/N] `, (answer) => {
|
|
1188
1176
|
rl.close();
|
|
@@ -1616,9 +1604,42 @@ var mcpCommand = new Command13("mcp").description(
|
|
|
1616
1604
|
await server.connect(transport);
|
|
1617
1605
|
});
|
|
1618
1606
|
|
|
1607
|
+
// src/commands/upgrade.ts
|
|
1608
|
+
import { Command as Command14 } from "commander";
|
|
1609
|
+
import { spawnSync } from "child_process";
|
|
1610
|
+
var upgradeCommand = new Command14("upgrade").description("Upgrade nemonicon-cli to the latest version from npm").action(() => {
|
|
1611
|
+
console.log("Upgrading nemonicon-cli to the latest version...");
|
|
1612
|
+
const result = spawnSync("npm", ["i", "-g", "nemonicon-cli@latest"], {
|
|
1613
|
+
stdio: "inherit",
|
|
1614
|
+
shell: process.platform === "win32"
|
|
1615
|
+
});
|
|
1616
|
+
if (result.error) {
|
|
1617
|
+
console.error("Failed to run npm:", result.error.message);
|
|
1618
|
+
process.exit(1);
|
|
1619
|
+
}
|
|
1620
|
+
if (typeof result.status === "number" && result.status !== 0) {
|
|
1621
|
+
process.exit(result.status);
|
|
1622
|
+
}
|
|
1623
|
+
console.log("Done. Run `nemonicon -V` to confirm the new version.");
|
|
1624
|
+
});
|
|
1625
|
+
|
|
1619
1626
|
// src/index.ts
|
|
1620
|
-
var
|
|
1621
|
-
|
|
1627
|
+
var __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
1628
|
+
var pkg = JSON.parse(
|
|
1629
|
+
readFileSync6(join2(__dirname2, "../package.json"), "utf-8")
|
|
1630
|
+
);
|
|
1631
|
+
var isMcp = process.argv[2] === "mcp";
|
|
1632
|
+
if (!isMcp) {
|
|
1633
|
+
updateNotifier({
|
|
1634
|
+
pkg,
|
|
1635
|
+
updateCheckInterval: 1e3 * 60 * 60 * 24
|
|
1636
|
+
}).notify({
|
|
1637
|
+
isGlobal: true,
|
|
1638
|
+
message: "Update available {currentVersion} \u2192 {latestVersion}\nRun `nemonicon upgrade` (or `npm i -g {packageName}@latest`)"
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
var program = new Command15();
|
|
1642
|
+
program.name("nemonicon").description("CLI tool for Nemonicon knowledge management").version(pkg.version);
|
|
1622
1643
|
program.addCommand(loginCommand);
|
|
1623
1644
|
program.addCommand(logoutCommand);
|
|
1624
1645
|
program.addCommand(authCommand);
|
|
@@ -1632,4 +1653,5 @@ program.addCommand(deleteCommand);
|
|
|
1632
1653
|
program.addCommand(moveCommand);
|
|
1633
1654
|
program.addCommand(bulkUpdateCommand);
|
|
1634
1655
|
program.addCommand(mcpCommand);
|
|
1656
|
+
program.addCommand(upgradeCommand);
|
|
1635
1657
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nemonicon-cli",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "CLI tool for Nemonicon knowledge management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
18
18
|
"commander": "^13.1.0",
|
|
19
|
+
"update-notifier": "^7.3.1",
|
|
19
20
|
"zod": "^3.23.8"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|