@levimc/lip 0.34.3 → 0.34.4-beta.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/darwin-arm64/lip +0 -0
- package/darwin-arm64/lipd +0 -0
- package/darwin-x64/lip +0 -0
- package/darwin-x64/lipd +0 -0
- package/dotnet-bootstrap.js +142 -0
- package/linux-arm64/lip +0 -0
- package/linux-arm64/lipd +0 -0
- package/linux-x64/lip +0 -0
- package/linux-x64/lipd +0 -0
- package/lip.js +8 -1
- package/lipd.js +8 -1
- package/package.json +6 -1
- package/postinstall.js +45 -0
- package/win32-arm64/lip.exe +0 -0
- package/win32-arm64/lipd.exe +0 -0
- package/win32-x64/lip.exe +0 -0
- package/win32-x64/lipd.exe +0 -0
package/darwin-arm64/lip
CHANGED
|
Binary file
|
package/darwin-arm64/lipd
CHANGED
|
Binary file
|
package/darwin-x64/lip
CHANGED
|
Binary file
|
package/darwin-x64/lipd
CHANGED
|
Binary file
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
const fs = require("node:fs");
|
|
2
|
+
const os = require("node:os");
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
|
|
5
|
+
const DOTNET_CHANNEL = "10.0";
|
|
6
|
+
const DOTNET_MAJOR = 10;
|
|
7
|
+
|
|
8
|
+
function getDefaultDotnetRoot(options = {}) {
|
|
9
|
+
const platform = options.platform ?? process.platform;
|
|
10
|
+
const env = options.env ?? process.env;
|
|
11
|
+
const homedir = options.homedir ?? os.homedir();
|
|
12
|
+
const join = platform === "win32" ? path.win32.join : path.join;
|
|
13
|
+
|
|
14
|
+
if (env.DOTNET_INSTALL_DIR) {
|
|
15
|
+
return env.DOTNET_INSTALL_DIR;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (platform === "win32") {
|
|
19
|
+
const localAppData =
|
|
20
|
+
env.LocalAppData ??
|
|
21
|
+
env.LOCALAPPDATA ??
|
|
22
|
+
join(homedir, "AppData", "Local");
|
|
23
|
+
return join(localAppData, "Microsoft", "dotnet");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return join(homedir, ".dotnet");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getSharedRuntimeDir(rootDir) {
|
|
30
|
+
return path.join(rootDir, "shared", "Microsoft.NETCore.App");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function hasNetCoreAppMajor(rootDir, major = DOTNET_MAJOR) {
|
|
34
|
+
const runtimeDir = getSharedRuntimeDir(rootDir);
|
|
35
|
+
if (!fs.existsSync(runtimeDir)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return fs
|
|
40
|
+
.readdirSync(runtimeDir, { withFileTypes: true })
|
|
41
|
+
.some(
|
|
42
|
+
(entry) =>
|
|
43
|
+
entry.isDirectory() &&
|
|
44
|
+
entry.name.startsWith(`${major}.`) &&
|
|
45
|
+
/^\d+\./.test(entry.name)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function maybeAddDotnetRootEnv(targetEnv, major = DOTNET_MAJOR, options = {}) {
|
|
50
|
+
const root =
|
|
51
|
+
options.defaultRootOverride ??
|
|
52
|
+
getDefaultDotnetRoot({
|
|
53
|
+
platform: options.platform,
|
|
54
|
+
env: options.env,
|
|
55
|
+
homedir: options.homedir
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (hasNetCoreAppMajor(root, major)) {
|
|
59
|
+
targetEnv.DOTNET_ROOT = root;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return targetEnv;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function hasMajorRuntimeInListRuntimesOutput(output, major = DOTNET_MAJOR) {
|
|
66
|
+
if (!output) return false;
|
|
67
|
+
|
|
68
|
+
return output
|
|
69
|
+
.split(/\r?\n/)
|
|
70
|
+
.some((line) => line.startsWith(`Microsoft.NETCore.App ${major}.`));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function isRuntimeInstalled(major = DOTNET_MAJOR, options = {}) {
|
|
74
|
+
const env = options.env ?? process.env;
|
|
75
|
+
|
|
76
|
+
// Respect explicit DOTNET_ROOT if provided by the user or the environment.
|
|
77
|
+
if (env.DOTNET_ROOT && hasNetCoreAppMajor(env.DOTNET_ROOT, major)) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const defaultRoot = getDefaultDotnetRoot({
|
|
82
|
+
platform: options.platform,
|
|
83
|
+
env: options.env,
|
|
84
|
+
homedir: options.homedir
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (hasNetCoreAppMajor(defaultRoot, major)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Best-effort: if `dotnet` is already available, ask it directly.
|
|
92
|
+
const spawnSync = options.spawnSync ?? require("node:child_process").spawnSync;
|
|
93
|
+
const result = spawnSync("dotnet", ["--list-runtimes"], {
|
|
94
|
+
encoding: "utf8",
|
|
95
|
+
windowsHide: true
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if (result && result.status === 0) {
|
|
99
|
+
return hasMajorRuntimeInListRuntimesOutput(result.stdout, major);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function getInstallCommandSpec(options = {}) {
|
|
106
|
+
const platform = options.platform ?? process.platform;
|
|
107
|
+
|
|
108
|
+
if (platform === "win32") {
|
|
109
|
+
return {
|
|
110
|
+
command: "powershell.exe",
|
|
111
|
+
args: [
|
|
112
|
+
"-NoLogo",
|
|
113
|
+
"-NoProfile",
|
|
114
|
+
"-NonInteractive",
|
|
115
|
+
"-ExecutionPolicy",
|
|
116
|
+
"Bypass",
|
|
117
|
+
"-Command",
|
|
118
|
+
"& ([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing https://dot.net/v1/dotnet-install.ps1).Content)) -Runtime dotnet -Channel 10.0 -NoPath"
|
|
119
|
+
]
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
command: "bash",
|
|
125
|
+
args: [
|
|
126
|
+
"-c",
|
|
127
|
+
"curl -fsSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --runtime dotnet --channel 10.0 --no-path"
|
|
128
|
+
]
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = {
|
|
133
|
+
DOTNET_CHANNEL,
|
|
134
|
+
DOTNET_MAJOR,
|
|
135
|
+
getDefaultDotnetRoot,
|
|
136
|
+
getInstallCommandSpec,
|
|
137
|
+
getSharedRuntimeDir,
|
|
138
|
+
hasMajorRuntimeInListRuntimesOutput,
|
|
139
|
+
hasNetCoreAppMajor,
|
|
140
|
+
isRuntimeInstalled,
|
|
141
|
+
maybeAddDotnetRootEnv
|
|
142
|
+
};
|
package/linux-arm64/lip
CHANGED
|
Binary file
|
package/linux-arm64/lipd
CHANGED
|
Binary file
|
package/linux-x64/lip
CHANGED
|
Binary file
|
package/linux-x64/lipd
CHANGED
|
Binary file
|
package/lip.js
CHANGED
|
@@ -4,6 +4,7 @@ const { spawn } = require("node:child_process");
|
|
|
4
4
|
const fs = require("node:fs");
|
|
5
5
|
const path = require("node:path");
|
|
6
6
|
const process = require("node:process");
|
|
7
|
+
const { maybeAddDotnetRootEnv, DOTNET_MAJOR } = require("./dotnet-bootstrap");
|
|
7
8
|
|
|
8
9
|
const target = `${process.platform}:${process.arch}`;
|
|
9
10
|
const supportedTargets = new Set([
|
|
@@ -31,7 +32,13 @@ if (!fs.existsSync(binaryPath)) {
|
|
|
31
32
|
process.exit(1);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
const
|
|
35
|
+
const childEnv = { ...process.env };
|
|
36
|
+
maybeAddDotnetRootEnv(childEnv, DOTNET_MAJOR);
|
|
37
|
+
|
|
38
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
39
|
+
stdio: "inherit",
|
|
40
|
+
env: childEnv
|
|
41
|
+
});
|
|
35
42
|
child.on("error", (error) => {
|
|
36
43
|
console.error(error.message);
|
|
37
44
|
process.exit(1);
|
package/lipd.js
CHANGED
|
@@ -4,6 +4,7 @@ const { spawn } = require("node:child_process");
|
|
|
4
4
|
const fs = require("node:fs");
|
|
5
5
|
const path = require("node:path");
|
|
6
6
|
const process = require("node:process");
|
|
7
|
+
const { maybeAddDotnetRootEnv, DOTNET_MAJOR } = require("./dotnet-bootstrap");
|
|
7
8
|
|
|
8
9
|
const target = `${process.platform}:${process.arch}`;
|
|
9
10
|
const supportedTargets = new Set([
|
|
@@ -31,7 +32,13 @@ if (!fs.existsSync(binaryPath)) {
|
|
|
31
32
|
process.exit(1);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
const
|
|
35
|
+
const childEnv = { ...process.env };
|
|
36
|
+
maybeAddDotnetRootEnv(childEnv, DOTNET_MAJOR);
|
|
37
|
+
|
|
38
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
39
|
+
stdio: "inherit",
|
|
40
|
+
env: childEnv
|
|
41
|
+
});
|
|
35
42
|
child.on("error", (error) => {
|
|
36
43
|
console.error(error.message);
|
|
37
44
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levimc/lip",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.4-beta.1",
|
|
4
4
|
"license": "GPL-3.0-only",
|
|
5
5
|
"description": "A general package installer",
|
|
6
6
|
"homepage": "https://github.com/futrime/lip",
|
|
@@ -15,9 +15,14 @@
|
|
|
15
15
|
"lip": "lip.js",
|
|
16
16
|
"lipd": "lipd.js"
|
|
17
17
|
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"postinstall": "node postinstall.js"
|
|
20
|
+
},
|
|
18
21
|
"files": [
|
|
22
|
+
"dotnet-bootstrap.js",
|
|
19
23
|
"lip.js",
|
|
20
24
|
"lipd.js",
|
|
25
|
+
"postinstall.js",
|
|
21
26
|
"linux-*/*",
|
|
22
27
|
"darwin-*/*",
|
|
23
28
|
"win32-*/*"
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
const process = require("node:process");
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
DOTNET_CHANNEL,
|
|
8
|
+
DOTNET_MAJOR,
|
|
9
|
+
getDefaultDotnetRoot,
|
|
10
|
+
getInstallCommandSpec,
|
|
11
|
+
hasNetCoreAppMajor,
|
|
12
|
+
isRuntimeInstalled
|
|
13
|
+
} = require("./dotnet-bootstrap");
|
|
14
|
+
|
|
15
|
+
const root = getDefaultDotnetRoot();
|
|
16
|
+
|
|
17
|
+
if (isRuntimeInstalled(DOTNET_MAJOR)) {
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const spec = getInstallCommandSpec();
|
|
22
|
+
console.log(
|
|
23
|
+
`Installing .NET Runtime ${DOTNET_CHANNEL} via the official dotnet-install script...`
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const result = spawnSync(spec.command, spec.args, {
|
|
27
|
+
stdio: "inherit",
|
|
28
|
+
env: process.env
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (result.error) {
|
|
32
|
+
console.error(`Failed to launch .NET installer: ${result.error.message}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (result.status !== 0) {
|
|
37
|
+
process.exit(result.status ?? 1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!hasNetCoreAppMajor(root, DOTNET_MAJOR)) {
|
|
41
|
+
console.error(
|
|
42
|
+
`The installer finished but .NET Runtime ${DOTNET_MAJOR}.x was not detected under ${root}.`
|
|
43
|
+
);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
package/win32-arm64/lip.exe
CHANGED
|
Binary file
|
package/win32-arm64/lipd.exe
CHANGED
|
Binary file
|
package/win32-x64/lip.exe
CHANGED
|
Binary file
|
package/win32-x64/lipd.exe
CHANGED
|
Binary file
|