@mnemon-dev/mnemon 0.2.13 → 0.2.14-win32-x64
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/LICENSE.memory-agent +21 -0
- package/LICENSE.v8 +73 -0
- package/README.md +2 -17
- package/bin/mnemon.exe +0 -0
- package/package.json +11 -32
- package/bin/mnemon.js +0 -48
- package/lib/child.js +0 -38
- package/lib/targets.js +0 -42
- package/lib/update.js +0 -178
- package/targets.json +0 -56
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-external contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/LICENSE.v8
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Mnemon's internal/records/jslog.go contains a Go port of the log operation
|
|
2
|
+
from V8's src/base/ieee754.cc, based on fdlibm. The notices for that code are:
|
|
3
|
+
|
|
4
|
+
Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
5
|
+
Developed at SunSoft, a Sun Microsystems, Inc. business.
|
|
6
|
+
Permission to use, copy, modify, and distribute this software is freely
|
|
7
|
+
granted, provided that this notice is preserved.
|
|
8
|
+
Modified significantly by Google Inc. Copyright 2016 the V8 project authors.
|
|
9
|
+
All rights reserved.
|
|
10
|
+
|
|
11
|
+
The upstream V8 license follows.
|
|
12
|
+
|
|
13
|
+
This license applies to all parts of V8 that are not externally
|
|
14
|
+
maintained libraries. The externally maintained libraries used by V8
|
|
15
|
+
are:
|
|
16
|
+
|
|
17
|
+
- PCRE test suite, located in
|
|
18
|
+
test/mjsunit/third_party/regexp-pcre/regexp-pcre.js. This is based on the
|
|
19
|
+
test suite from PCRE-7.3, which is copyrighted by the University
|
|
20
|
+
of Cambridge and Google, Inc. The copyright notice and license
|
|
21
|
+
are embedded in regexp-pcre.js.
|
|
22
|
+
|
|
23
|
+
- Layout tests, located in test/mjsunit/third_party/object-keys. These are
|
|
24
|
+
based on layout tests from webkit.org which are copyrighted by
|
|
25
|
+
Apple Computer, Inc. and released under a 3-clause BSD license.
|
|
26
|
+
|
|
27
|
+
- Strongtalk assembler, the basis of the files assembler-arm-inl.h,
|
|
28
|
+
assembler-arm.cc, assembler-arm.h, assembler-ia32-inl.h,
|
|
29
|
+
assembler-ia32.cc, assembler-ia32.h, assembler-x64-inl.h,
|
|
30
|
+
assembler-x64.cc, assembler-x64.h, assembler.cc and assembler.h.
|
|
31
|
+
This code is copyrighted by Sun Microsystems Inc. and released
|
|
32
|
+
under a 3-clause BSD license.
|
|
33
|
+
|
|
34
|
+
- Valgrind client API header, located at third_party/valgrind/valgrind.h
|
|
35
|
+
This is released under the BSD license.
|
|
36
|
+
|
|
37
|
+
- The Wasm C/C++ API headers, located at third_party/wasm-api/wasm.{h,hh}
|
|
38
|
+
This is released under the Apache license. The API's upstream prototype
|
|
39
|
+
implementation also formed the basis of V8's implementation in
|
|
40
|
+
src/wasm/c-api.cc.
|
|
41
|
+
|
|
42
|
+
These libraries have their own licenses; we recommend you read them,
|
|
43
|
+
as their terms may differ from the terms below.
|
|
44
|
+
|
|
45
|
+
Further license information can be found in LICENSE files located in
|
|
46
|
+
sub-directories.
|
|
47
|
+
|
|
48
|
+
Copyright 2014, the V8 project authors. All rights reserved.
|
|
49
|
+
Redistribution and use in source and binary forms, with or without
|
|
50
|
+
modification, are permitted provided that the following conditions are
|
|
51
|
+
met:
|
|
52
|
+
|
|
53
|
+
* Redistributions of source code must retain the above copyright
|
|
54
|
+
notice, this list of conditions and the following disclaimer.
|
|
55
|
+
* Redistributions in binary form must reproduce the above
|
|
56
|
+
copyright notice, this list of conditions and the following
|
|
57
|
+
disclaimer in the documentation and/or other materials provided
|
|
58
|
+
with the distribution.
|
|
59
|
+
* Neither the name of Google Inc. nor the names of its
|
|
60
|
+
contributors may be used to endorse or promote products derived
|
|
61
|
+
from this software without specific prior written permission.
|
|
62
|
+
|
|
63
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
64
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
65
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
66
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
67
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
68
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
69
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
70
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
71
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
72
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
73
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
# Mnemon
|
|
1
|
+
# Mnemon win32-x64
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
peer-to-peer work. This npm package installs the native Mnemon executable for
|
|
5
|
-
the current operating system and CPU architecture.
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install --global @mnemon-dev/mnemon
|
|
9
|
-
mnemon --version
|
|
10
|
-
mnemon update
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
The launcher supports 64-bit Intel and ARM systems on macOS, Linux, and
|
|
14
|
-
Windows. Windows currently supports the Memory commands; Agency remains
|
|
15
|
-
unavailable until its local authority boundary has native Windows security.
|
|
16
|
-
|
|
17
|
-
Project documentation and source code are available at
|
|
18
|
-
<https://github.com/mnemon-dev/mnemon>.
|
|
3
|
+
Native win32/x64 artifact for `@mnemon-dev/mnemon@0.2.14-win32-x64`. Install `@mnemon-dev/mnemon` instead of this platform artifact directly.
|
package/bin/mnemon.exe
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,48 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mnemon-dev/mnemon",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
"version": "0.2.14-win32-x64",
|
|
4
|
+
"description": "Mnemon native binary for win32/x64",
|
|
5
|
+
"os": [
|
|
6
|
+
"win32"
|
|
7
|
+
],
|
|
8
|
+
"cpu": [
|
|
9
|
+
"x64"
|
|
10
|
+
],
|
|
9
11
|
"files": [
|
|
10
12
|
"bin",
|
|
11
|
-
"lib",
|
|
12
|
-
"targets.json",
|
|
13
13
|
"README.md",
|
|
14
|
-
"LICENSE"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"test": "node --experimental-test-module-mocks --test test/*.test.mjs"
|
|
18
|
-
},
|
|
19
|
-
"engines": {
|
|
20
|
-
"node": ">=22"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [
|
|
23
|
-
"mnemon",
|
|
24
|
-
"agent-memory",
|
|
25
|
-
"llm",
|
|
26
|
-
"cli"
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"LICENSE.v8",
|
|
16
|
+
"LICENSE.memory-agent"
|
|
27
17
|
],
|
|
28
18
|
"repository": {
|
|
29
19
|
"type": "git",
|
|
30
20
|
"url": "git+https://github.com/mnemon-dev/mnemon.git"
|
|
31
21
|
},
|
|
32
22
|
"homepage": "https://github.com/mnemon-dev/mnemon",
|
|
33
|
-
"bugs": {
|
|
34
|
-
"url": "https://github.com/mnemon-dev/mnemon/issues"
|
|
35
|
-
},
|
|
36
23
|
"license": "Apache-2.0",
|
|
37
24
|
"publishConfig": {
|
|
38
25
|
"access": "public"
|
|
39
|
-
},
|
|
40
|
-
"optionalDependencies": {
|
|
41
|
-
"@mnemon-dev/mnemon-darwin-x64": "npm:@mnemon-dev/mnemon@0.2.13-darwin-x64",
|
|
42
|
-
"@mnemon-dev/mnemon-darwin-arm64": "npm:@mnemon-dev/mnemon@0.2.13-darwin-arm64",
|
|
43
|
-
"@mnemon-dev/mnemon-linux-x64": "npm:@mnemon-dev/mnemon@0.2.13-linux-x64",
|
|
44
|
-
"@mnemon-dev/mnemon-linux-arm64": "npm:@mnemon-dev/mnemon@0.2.13-linux-arm64",
|
|
45
|
-
"@mnemon-dev/mnemon-win32-x64": "npm:@mnemon-dev/mnemon@0.2.13-win32-x64",
|
|
46
|
-
"@mnemon-dev/mnemon-win32-arm64": "npm:@mnemon-dev/mnemon@0.2.13-win32-arm64"
|
|
47
26
|
}
|
|
48
27
|
}
|
package/bin/mnemon.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { existsSync, realpathSync } from "node:fs";
|
|
4
|
-
import { createRequire } from "node:module";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
|
|
8
|
-
import { runChild, settle } from "../lib/child.js";
|
|
9
|
-
import { selectTarget } from "../lib/targets.js";
|
|
10
|
-
import { updateNpmInstall } from "../lib/update.js";
|
|
11
|
-
|
|
12
|
-
const require = createRequire(import.meta.url);
|
|
13
|
-
|
|
14
|
-
async function main() {
|
|
15
|
-
const packageRoot = realpathSync(path.join(path.dirname(fileURLToPath(import.meta.url)), ".."));
|
|
16
|
-
const args = process.argv.slice(2);
|
|
17
|
-
if (args.length === 1 && args[0] === "update") {
|
|
18
|
-
settle(await updateNpmInstall({ packageRoot }));
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const target = selectTarget(process.platform, process.arch);
|
|
23
|
-
let platformRoot;
|
|
24
|
-
try {
|
|
25
|
-
platformRoot = path.dirname(require.resolve(`${target.alias}/package.json`));
|
|
26
|
-
} catch {
|
|
27
|
-
throw new Error(
|
|
28
|
-
`Missing optional dependency ${target.alias}. Reinstall Mnemon with: ` +
|
|
29
|
-
"npm install --global --include=optional @mnemon-dev/mnemon@latest",
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const binary = path.join(platformRoot, target.binary);
|
|
34
|
-
if (!existsSync(binary)) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
`Mnemon native binary is missing for ${target.id}. Reinstall with: ` +
|
|
37
|
-
"npm install --global --include=optional @mnemon-dev/mnemon@latest",
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
settle(await runChild(binary, args));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
await main();
|
|
45
|
-
} catch (error) {
|
|
46
|
-
process.stderr.write(`mnemon: ${error.message}\n`);
|
|
47
|
-
process.exitCode = 1;
|
|
48
|
-
}
|
package/lib/child.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
|
|
3
|
-
export async function runChild(command, args, options = {}) {
|
|
4
|
-
const child = spawn(command, args, { stdio: "inherit", windowsHide: true, ...options });
|
|
5
|
-
const forward = (signal) => {
|
|
6
|
-
if (!child.killed) {
|
|
7
|
-
try {
|
|
8
|
-
child.kill(signal);
|
|
9
|
-
} catch {
|
|
10
|
-
// The child may have settled between the check and signal delivery.
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const handlers = new Map();
|
|
15
|
-
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
16
|
-
const handler = () => forward(signal);
|
|
17
|
-
handlers.set(signal, handler);
|
|
18
|
-
process.on(signal, handler);
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
return await new Promise((resolve, reject) => {
|
|
22
|
-
child.once("error", reject);
|
|
23
|
-
child.once("exit", (code, signal) => resolve({ code, signal }));
|
|
24
|
-
});
|
|
25
|
-
} finally {
|
|
26
|
-
for (const [signal, handler] of handlers) {
|
|
27
|
-
process.off(signal, handler);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function settle(result) {
|
|
33
|
-
if (result.signal) {
|
|
34
|
-
process.kill(process.pid, result.signal);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
process.exitCode = result.code ?? 1;
|
|
38
|
-
}
|
package/lib/targets.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
|
|
3
|
-
const targetFile = new URL("../targets.json", import.meta.url);
|
|
4
|
-
const parsedTargets = JSON.parse(readFileSync(targetFile, "utf8"));
|
|
5
|
-
|
|
6
|
-
export const targets = validateTargets(parsedTargets);
|
|
7
|
-
|
|
8
|
-
export function selectTarget(platform, arch) {
|
|
9
|
-
const target = targets.find(
|
|
10
|
-
(candidate) => candidate.platform === platform && candidate.arch === arch,
|
|
11
|
-
);
|
|
12
|
-
if (!target) {
|
|
13
|
-
throw new Error(`Unsupported platform: ${platform} (${arch})`);
|
|
14
|
-
}
|
|
15
|
-
return target;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function validateTargets(value) {
|
|
19
|
-
if (!Array.isArray(value) || value.length === 0) {
|
|
20
|
-
throw new Error("Mnemon target registry is empty");
|
|
21
|
-
}
|
|
22
|
-
const ids = new Set();
|
|
23
|
-
const runtimes = new Set();
|
|
24
|
-
const aliases = new Set();
|
|
25
|
-
return Object.freeze(
|
|
26
|
-
value.map((target) => {
|
|
27
|
-
for (const field of ["id", "platform", "arch", "goos", "goarch", "alias", "binary"]) {
|
|
28
|
-
if (typeof target[field] !== "string" || target[field].length === 0) {
|
|
29
|
-
throw new Error(`Mnemon target has invalid ${field}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const runtime = `${target.platform}/${target.arch}`;
|
|
33
|
-
if (ids.has(target.id) || runtimes.has(runtime) || aliases.has(target.alias)) {
|
|
34
|
-
throw new Error(`Mnemon target registry contains a duplicate: ${target.id}`);
|
|
35
|
-
}
|
|
36
|
-
ids.add(target.id);
|
|
37
|
-
runtimes.add(runtime);
|
|
38
|
-
aliases.add(target.alias);
|
|
39
|
-
return Object.freeze({ ...target });
|
|
40
|
-
}),
|
|
41
|
-
);
|
|
42
|
-
}
|
package/lib/update.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { constants } from "node:fs";
|
|
2
|
-
import { access, readFile, realpath } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { spawnSync } from "node:child_process";
|
|
5
|
-
|
|
6
|
-
import { runChild } from "./child.js";
|
|
7
|
-
|
|
8
|
-
const packageName = "@mnemon-dev/mnemon";
|
|
9
|
-
|
|
10
|
-
export async function updateNpmInstall({
|
|
11
|
-
packageRoot,
|
|
12
|
-
runner = productionRunner(),
|
|
13
|
-
stdout = process.stdout,
|
|
14
|
-
}) {
|
|
15
|
-
const currentRoot = await canonicalPath(packageRoot);
|
|
16
|
-
const current = await readPackage(currentRoot);
|
|
17
|
-
const npm = await resolveNpmInvocation();
|
|
18
|
-
|
|
19
|
-
const globalRoot = await npmPath(runner, npm, ["root", "--global"]);
|
|
20
|
-
let expectedRoot;
|
|
21
|
-
try {
|
|
22
|
-
expectedRoot = await canonicalPath(path.join(globalRoot, ...packageName.split("/")));
|
|
23
|
-
} catch (error) {
|
|
24
|
-
throw notManagedError(`cannot resolve the package in npm's global root: ${error.message}`);
|
|
25
|
-
}
|
|
26
|
-
if (!samePath(expectedRoot, currentRoot)) {
|
|
27
|
-
throw notManagedError("npm on PATH owns a different global installation");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const prefix = await npmPath(runner, npm, ["prefix", "--global"]);
|
|
31
|
-
if (!pathWithin(prefix, globalRoot)) {
|
|
32
|
-
throw notManagedError("npm's global package root is outside its prefix");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const result = await runner.run(npm.command, [
|
|
36
|
-
...npm.args,
|
|
37
|
-
"install",
|
|
38
|
-
"--global",
|
|
39
|
-
"--prefix",
|
|
40
|
-
prefix,
|
|
41
|
-
"--include=optional",
|
|
42
|
-
`${packageName}@latest`,
|
|
43
|
-
]);
|
|
44
|
-
if (result.signal) {
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
if (result.code !== 0) {
|
|
48
|
-
throw new Error(`npm install exited with status ${result.code ?? "unknown"}`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const updated = await readPackage(currentRoot);
|
|
52
|
-
if (current.version === updated.version) {
|
|
53
|
-
stdout.write(`Mnemon is already up to date (${updated.version}).\n`);
|
|
54
|
-
} else {
|
|
55
|
-
stdout.write(`Updated Mnemon ${current.version} -> ${updated.version}.\n`);
|
|
56
|
-
}
|
|
57
|
-
return { code: 0, signal: null };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function productionRunner() {
|
|
61
|
-
return {
|
|
62
|
-
output(command, args) {
|
|
63
|
-
const result = spawnSync(command, args, { encoding: "utf8", windowsHide: true });
|
|
64
|
-
if (result.error) {
|
|
65
|
-
throw result.error;
|
|
66
|
-
}
|
|
67
|
-
if (result.status !== 0) {
|
|
68
|
-
throw new Error(
|
|
69
|
-
`${command} ${args.join(" ")} exited with status ${result.status ?? "unknown"}: ` +
|
|
70
|
-
(result.stderr ?? "").trim(),
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
return result.stdout;
|
|
74
|
-
},
|
|
75
|
-
run(command, args) {
|
|
76
|
-
return runChild(command, args);
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function npmPath(runner, npm, args) {
|
|
82
|
-
try {
|
|
83
|
-
const value = runner.output(npm.command, [...npm.args, ...args]).trim();
|
|
84
|
-
return await canonicalPath(value);
|
|
85
|
-
} catch (error) {
|
|
86
|
-
throw new Error(`cannot inspect npm ${args[0]}: ${error.message}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async function resolveNpmInvocation() {
|
|
91
|
-
if (process.platform !== "win32") {
|
|
92
|
-
return { command: "npm", args: [] };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const pathValue = Object.entries(process.env).find(
|
|
96
|
-
([name]) => name.toLowerCase() === "path",
|
|
97
|
-
)?.[1];
|
|
98
|
-
for (let entry of pathValue?.split(path.delimiter) ?? []) {
|
|
99
|
-
if (entry.startsWith('"') && entry.endsWith('"')) {
|
|
100
|
-
entry = entry.slice(1, -1);
|
|
101
|
-
}
|
|
102
|
-
if (entry === "") {
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
const npmExecutable = path.join(entry, "npm.exe");
|
|
106
|
-
try {
|
|
107
|
-
await access(npmExecutable, constants.F_OK);
|
|
108
|
-
return { command: npmExecutable, args: [] };
|
|
109
|
-
} catch {
|
|
110
|
-
// Standard Node.js installations expose npm through npm.cmd instead.
|
|
111
|
-
}
|
|
112
|
-
const npmCommand = path.join(entry, "npm.cmd");
|
|
113
|
-
const npmCLI = path.join(entry, "node_modules", "npm", "bin", "npm-cli.js");
|
|
114
|
-
try {
|
|
115
|
-
await Promise.all([
|
|
116
|
-
access(npmCommand, constants.F_OK),
|
|
117
|
-
access(npmCLI, constants.F_OK),
|
|
118
|
-
]);
|
|
119
|
-
// A .cmd file cannot be spawned directly without a shell. Invoke npm's
|
|
120
|
-
// JavaScript entry point with the already-running Node executable.
|
|
121
|
-
return { command: process.execPath, args: [npmCLI] };
|
|
122
|
-
} catch {
|
|
123
|
-
// Keep searching PATH for a complete Node.js/npm installation.
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
throw new Error("npm is required to update Mnemon but was not found on PATH");
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async function canonicalPath(value) {
|
|
130
|
-
if (typeof value !== "string" || value.trim() !== value || !path.isAbsolute(value)) {
|
|
131
|
-
throw new Error("path is not absolute and clean");
|
|
132
|
-
}
|
|
133
|
-
const cleaned = path.normalize(value);
|
|
134
|
-
if (cleaned !== value) {
|
|
135
|
-
throw new Error("path is not absolute and clean");
|
|
136
|
-
}
|
|
137
|
-
return realpath(value);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async function readPackage(root) {
|
|
141
|
-
let metadata;
|
|
142
|
-
try {
|
|
143
|
-
metadata = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
|
|
144
|
-
} catch (error) {
|
|
145
|
-
throw notManagedError(`cannot read package metadata: ${error.message}`);
|
|
146
|
-
}
|
|
147
|
-
if (
|
|
148
|
-
metadata.name !== packageName ||
|
|
149
|
-
typeof metadata.version !== "string" ||
|
|
150
|
-
metadata.version.trim() === ""
|
|
151
|
-
) {
|
|
152
|
-
throw notManagedError("package name or version is invalid");
|
|
153
|
-
}
|
|
154
|
-
return metadata;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function pathWithin(root, candidate) {
|
|
158
|
-
const relative = path.relative(root, candidate);
|
|
159
|
-
return (
|
|
160
|
-
relative !== "" &&
|
|
161
|
-
relative !== ".." &&
|
|
162
|
-
!relative.startsWith(`..${path.sep}`) &&
|
|
163
|
-
!path.isAbsolute(relative)
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function samePath(left, right) {
|
|
168
|
-
return process.platform === "win32"
|
|
169
|
-
? left.toLowerCase() === right.toLowerCase()
|
|
170
|
-
: left === right;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function notManagedError(reason) {
|
|
174
|
-
return new Error(
|
|
175
|
-
`this Mnemon installation is not managed by npm: ${reason}; ` +
|
|
176
|
-
`migrate once with: npm install --global ${packageName}@latest`,
|
|
177
|
-
);
|
|
178
|
-
}
|
package/targets.json
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "darwin-x64",
|
|
4
|
-
"platform": "darwin",
|
|
5
|
-
"arch": "x64",
|
|
6
|
-
"goos": "darwin",
|
|
7
|
-
"goarch": "amd64",
|
|
8
|
-
"alias": "@mnemon-dev/mnemon-darwin-x64",
|
|
9
|
-
"binary": "bin/mnemon"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"id": "darwin-arm64",
|
|
13
|
-
"platform": "darwin",
|
|
14
|
-
"arch": "arm64",
|
|
15
|
-
"goos": "darwin",
|
|
16
|
-
"goarch": "arm64",
|
|
17
|
-
"alias": "@mnemon-dev/mnemon-darwin-arm64",
|
|
18
|
-
"binary": "bin/mnemon"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"id": "linux-x64",
|
|
22
|
-
"platform": "linux",
|
|
23
|
-
"arch": "x64",
|
|
24
|
-
"goos": "linux",
|
|
25
|
-
"goarch": "amd64",
|
|
26
|
-
"alias": "@mnemon-dev/mnemon-linux-x64",
|
|
27
|
-
"binary": "bin/mnemon"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"id": "linux-arm64",
|
|
31
|
-
"platform": "linux",
|
|
32
|
-
"arch": "arm64",
|
|
33
|
-
"goos": "linux",
|
|
34
|
-
"goarch": "arm64",
|
|
35
|
-
"alias": "@mnemon-dev/mnemon-linux-arm64",
|
|
36
|
-
"binary": "bin/mnemon"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"id": "win32-x64",
|
|
40
|
-
"platform": "win32",
|
|
41
|
-
"arch": "x64",
|
|
42
|
-
"goos": "windows",
|
|
43
|
-
"goarch": "amd64",
|
|
44
|
-
"alias": "@mnemon-dev/mnemon-win32-x64",
|
|
45
|
-
"binary": "bin/mnemon.exe"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"id": "win32-arm64",
|
|
49
|
-
"platform": "win32",
|
|
50
|
-
"arch": "arm64",
|
|
51
|
-
"goos": "windows",
|
|
52
|
-
"goarch": "arm64",
|
|
53
|
-
"alias": "@mnemon-dev/mnemon-win32-arm64",
|
|
54
|
-
"binary": "bin/mnemon.exe"
|
|
55
|
-
}
|
|
56
|
-
]
|