nemonicon-cli 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +48 -9
- 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";
|
|
@@ -28,7 +32,7 @@ function loadPartialConfig() {
|
|
|
28
32
|
if (envToken) {
|
|
29
33
|
return {
|
|
30
34
|
token: envToken,
|
|
31
|
-
apiUrl: envUrl ?? "https://
|
|
35
|
+
apiUrl: envUrl ?? "https://app.nemonicon.com",
|
|
32
36
|
protectionBypass: process.env.NEMONICON_PROTECTION_BYPASS || void 0,
|
|
33
37
|
authMethod: "static"
|
|
34
38
|
};
|
|
@@ -705,7 +709,7 @@ Run \`nemonicon login\` to sign in again.`
|
|
|
705
709
|
|
|
706
710
|
// src/commands/auth.ts
|
|
707
711
|
import { createInterface } from "readline";
|
|
708
|
-
var DEFAULT_API_URL = "https://
|
|
712
|
+
var DEFAULT_API_URL = "https://app.nemonicon.com";
|
|
709
713
|
function prompt(question, defaultValue) {
|
|
710
714
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
711
715
|
const suffix = defaultValue ? ` (${defaultValue})` : "";
|
|
@@ -753,7 +757,7 @@ Config was saved to ~/.nemonicon/config.json \u2014 you can edit it manually.`
|
|
|
753
757
|
// src/commands/login.ts
|
|
754
758
|
import { Command as Command2 } from "commander";
|
|
755
759
|
import { createInterface as createInterface2 } from "readline";
|
|
756
|
-
var DEFAULT_API_URL2 = "https://
|
|
760
|
+
var DEFAULT_API_URL2 = "https://app.nemonicon.com";
|
|
757
761
|
function prompt2(question, defaultValue) {
|
|
758
762
|
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
759
763
|
const suffix = defaultValue ? ` (${defaultValue})` : "";
|
|
@@ -781,9 +785,10 @@ var loginCommand = new Command2("login").description(
|
|
|
781
785
|
}
|
|
782
786
|
apiUrl = apiUrl.replace(/\/+$/, "");
|
|
783
787
|
const protectionBypass = options.protectionBypass ?? existing?.protectionBypass;
|
|
788
|
+
const apiUrlChanged = existing?.apiUrl !== void 0 && existing.apiUrl.replace(/\/+$/, "") !== apiUrl;
|
|
784
789
|
console.log(`Discovering OAuth endpoints at ${apiUrl}...`);
|
|
785
790
|
const endpoints = await discoverEndpoints(apiUrl, protectionBypass);
|
|
786
|
-
let clientId = existing?.clientId;
|
|
791
|
+
let clientId = apiUrlChanged ? void 0 : existing?.clientId;
|
|
787
792
|
if (!clientId) {
|
|
788
793
|
console.log("Registering CLI as an OAuth client...");
|
|
789
794
|
clientId = await registerClient(
|
|
@@ -794,8 +799,8 @@ var loginCommand = new Command2("login").description(
|
|
|
794
799
|
apiUrl,
|
|
795
800
|
clientId,
|
|
796
801
|
protectionBypass,
|
|
797
|
-
|
|
798
|
-
|
|
802
|
+
...!apiUrlChanged && existing?.token ? { token: existing.token } : {},
|
|
803
|
+
...!apiUrlChanged && existing?.authMethod ? { authMethod: existing.authMethod } : {}
|
|
799
804
|
};
|
|
800
805
|
saveConfig(next);
|
|
801
806
|
}
|
|
@@ -1615,9 +1620,42 @@ var mcpCommand = new Command13("mcp").description(
|
|
|
1615
1620
|
await server.connect(transport);
|
|
1616
1621
|
});
|
|
1617
1622
|
|
|
1623
|
+
// src/commands/upgrade.ts
|
|
1624
|
+
import { Command as Command14 } from "commander";
|
|
1625
|
+
import { spawnSync } from "child_process";
|
|
1626
|
+
var upgradeCommand = new Command14("upgrade").description("Upgrade nemonicon-cli to the latest version from npm").action(() => {
|
|
1627
|
+
console.log("Upgrading nemonicon-cli to the latest version...");
|
|
1628
|
+
const result = spawnSync("npm", ["i", "-g", "nemonicon-cli@latest"], {
|
|
1629
|
+
stdio: "inherit",
|
|
1630
|
+
shell: process.platform === "win32"
|
|
1631
|
+
});
|
|
1632
|
+
if (result.error) {
|
|
1633
|
+
console.error("Failed to run npm:", result.error.message);
|
|
1634
|
+
process.exit(1);
|
|
1635
|
+
}
|
|
1636
|
+
if (typeof result.status === "number" && result.status !== 0) {
|
|
1637
|
+
process.exit(result.status);
|
|
1638
|
+
}
|
|
1639
|
+
console.log("Done. Run `nemonicon -V` to confirm the new version.");
|
|
1640
|
+
});
|
|
1641
|
+
|
|
1618
1642
|
// src/index.ts
|
|
1619
|
-
var
|
|
1620
|
-
|
|
1643
|
+
var __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
1644
|
+
var pkg = JSON.parse(
|
|
1645
|
+
readFileSync6(join2(__dirname2, "../package.json"), "utf-8")
|
|
1646
|
+
);
|
|
1647
|
+
var isMcp = process.argv[2] === "mcp";
|
|
1648
|
+
if (!isMcp) {
|
|
1649
|
+
updateNotifier({
|
|
1650
|
+
pkg,
|
|
1651
|
+
updateCheckInterval: 1e3 * 60 * 60 * 24
|
|
1652
|
+
}).notify({
|
|
1653
|
+
isGlobal: true,
|
|
1654
|
+
message: "Update available {currentVersion} \u2192 {latestVersion}\nRun `nemonicon upgrade` (or `npm i -g {packageName}@latest`)"
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
var program = new Command15();
|
|
1658
|
+
program.name("nemonicon").description("CLI tool for Nemonicon knowledge management").version(pkg.version);
|
|
1621
1659
|
program.addCommand(loginCommand);
|
|
1622
1660
|
program.addCommand(logoutCommand);
|
|
1623
1661
|
program.addCommand(authCommand);
|
|
@@ -1631,4 +1669,5 @@ program.addCommand(deleteCommand);
|
|
|
1631
1669
|
program.addCommand(moveCommand);
|
|
1632
1670
|
program.addCommand(bulkUpdateCommand);
|
|
1633
1671
|
program.addCommand(mcpCommand);
|
|
1672
|
+
program.addCommand(upgradeCommand);
|
|
1634
1673
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nemonicon-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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": {
|