memex-cli 1.0.4 → 1.0.5

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.
Files changed (2) hide show
  1. package/bin.js +74 -2
  2. package/package.json +10 -6
package/bin.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { execFileSync } = require("child_process");
3
+ const { execFileSync, spawn } = require("child_process");
4
4
  const { join } = require("path");
5
+ const { existsSync } = require("fs");
5
6
 
6
7
  const PLATFORMS = {
7
8
  "darwin-arm64": "@memex-cli/darwin-arm64",
@@ -39,10 +40,81 @@ function getBinaryPath() {
39
40
  }
40
41
  }
41
42
 
43
+ function getMemexEnvScriptPath() {
44
+ const scriptExt = process.platform === "win32" ? ".ps1" : ".sh";
45
+ const scriptName = `memex-env${scriptExt}`;
46
+
47
+ try {
48
+ // Try to find script in main package
49
+ const mainPkgPath = require.resolve("memex-cli/package.json");
50
+ const scriptPath = join(mainPkgPath, "..", "scripts", scriptName);
51
+
52
+ if (existsSync(scriptPath)) {
53
+ return scriptPath;
54
+ }
55
+
56
+ // Fallback: try platform-specific package
57
+ const pkg = getPlatformPackage();
58
+ const pkgPath = require.resolve(`${pkg}/package.json`);
59
+ const fallbackPath = join(pkgPath, "..", "scripts", scriptName);
60
+
61
+ if (existsSync(fallbackPath)) {
62
+ return fallbackPath;
63
+ }
64
+
65
+ return null;
66
+ } catch (e) {
67
+ return null;
68
+ }
69
+ }
70
+
71
+ function runMemexEnv(args) {
72
+ const scriptPath = getMemexEnvScriptPath();
73
+
74
+ if (!scriptPath) {
75
+ console.error("⚠️ memex-env scripts not found in this package version");
76
+ console.error("💡 Reinstall with: npm install -g memex-cli@latest");
77
+ console.error("Or download manually from: https://github.com/chaorenex1/memex-cli");
78
+ process.exit(1);
79
+ }
80
+
81
+ const platform = process.platform;
82
+ let shellCmd, shellArgs;
83
+
84
+ if (platform === "win32") {
85
+ shellCmd = "powershell.exe";
86
+ shellArgs = ["-ExecutionPolicy", "Bypass", "-File", scriptPath, ...args];
87
+ } else {
88
+ shellCmd = "bash";
89
+ shellArgs = [scriptPath, ...args];
90
+ }
91
+
92
+ const child = spawn(shellCmd, shellArgs, {
93
+ stdio: "inherit",
94
+ shell: true
95
+ });
96
+
97
+ child.on("exit", code => {
98
+ process.exit(code || 0);
99
+ });
100
+
101
+ child.on("error", err => {
102
+ console.error(`Failed to run memex-env: ${err.message}`);
103
+ process.exit(1);
104
+ });
105
+ }
106
+
42
107
  function main() {
43
- const binaryPath = getBinaryPath();
44
108
  const args = process.argv.slice(2);
45
109
 
110
+ // Check if memex-env command is requested
111
+ if (args[0] === "env" || args[0] === "memex-env") {
112
+ runMemexEnv(args.slice(1));
113
+ return;
114
+ }
115
+
116
+ const binaryPath = getBinaryPath();
117
+
46
118
  try {
47
119
  execFileSync(binaryPath, args, {
48
120
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memex-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "CLI shell wrapper with memory, replay, and resume capabilities",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,13 +12,17 @@
12
12
  "memex-cli": "bin.js"
13
13
  },
14
14
  "files": [
15
- "bin.js"
15
+ "bin.js",
16
+ "scripts/"
16
17
  ],
18
+ "scripts": {
19
+ "postinstall": "node -e \"console.log('\\n💡 Tip: memex-env scripts available in node_modules/memex-cli/scripts/\\n')\""
20
+ },
17
21
  "optionalDependencies": {
18
- "@memex-cli/darwin-arm64": "1.0.4",
19
- "@memex-cli/darwin-x64": "1.0.4",
20
- "@memex-cli/linux-x64": "1.0.4",
21
- "@memex-cli/win32-x64": "1.0.4"
22
+ "@memex-cli/darwin-arm64": "1.0.5",
23
+ "@memex-cli/darwin-x64": "1.0.5",
24
+ "@memex-cli/linux-x64": "1.0.5",
25
+ "@memex-cli/win32-x64": "1.0.5"
22
26
  },
23
27
  "engines": {
24
28
  "node": ">=14"