@levimc/lip 0.0.0-stage → 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.
Binary file
Binary file
package/darwin-x64/lip ADDED
Binary file
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
+ };
Binary file
Binary file
package/linux-x64/lip ADDED
Binary file
package/linux-x64/lipd ADDED
Binary file
package/lip.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require("node:child_process");
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
6
+ const process = require("node:process");
7
+ const { maybeAddDotnetRootEnv, DOTNET_MAJOR } = require("./dotnet-bootstrap");
8
+
9
+ const target = `${process.platform}:${process.arch}`;
10
+ const supportedTargets = new Set([
11
+ "linux:x64",
12
+ "linux:arm64",
13
+ "darwin:x64",
14
+ "darwin:arm64",
15
+ "win32:x64",
16
+ "win32:arm64"
17
+ ]);
18
+
19
+ if (!supportedTargets.has(target)) {
20
+ console.error(`Unsupported platform: ${target}`);
21
+ process.exit(1);
22
+ }
23
+
24
+ const binaryPath = path.join(
25
+ __dirname,
26
+ `${process.platform}-${process.arch}`,
27
+ process.platform === "win32" ? "lip.exe" : "lip"
28
+ );
29
+
30
+ if (!fs.existsSync(binaryPath)) {
31
+ console.error(`Missing bundled binary for ${target}: ${binaryPath}`);
32
+ process.exit(1);
33
+ }
34
+
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
+ });
42
+ child.on("error", (error) => {
43
+ console.error(error.message);
44
+ process.exit(1);
45
+ });
46
+ child.on("exit", (code, signal) => {
47
+ if (signal) {
48
+ process.kill(process.pid, signal);
49
+ return;
50
+ }
51
+ process.exit(code ?? 1);
52
+ });
package/lipd.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require("node:child_process");
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
6
+ const process = require("node:process");
7
+ const { maybeAddDotnetRootEnv, DOTNET_MAJOR } = require("./dotnet-bootstrap");
8
+
9
+ const target = `${process.platform}:${process.arch}`;
10
+ const supportedTargets = new Set([
11
+ "linux:x64",
12
+ "linux:arm64",
13
+ "darwin:x64",
14
+ "darwin:arm64",
15
+ "win32:x64",
16
+ "win32:arm64"
17
+ ]);
18
+
19
+ if (!supportedTargets.has(target)) {
20
+ console.error(`Unsupported platform: ${target}`);
21
+ process.exit(1);
22
+ }
23
+
24
+ const binaryPath = path.join(
25
+ __dirname,
26
+ `${process.platform}-${process.arch}`,
27
+ process.platform === "win32" ? "lipd.exe" : "lipd"
28
+ );
29
+
30
+ if (!fs.existsSync(binaryPath)) {
31
+ console.error(`Missing bundled binary for ${target}: ${binaryPath}`);
32
+ process.exit(1);
33
+ }
34
+
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
+ });
42
+ child.on("error", (error) => {
43
+ console.error(error.message);
44
+ process.exit(1);
45
+ });
46
+ child.on("exit", (code, signal) => {
47
+ if (signal) {
48
+ process.kill(process.pid, signal);
49
+ return;
50
+ }
51
+ process.exit(code ?? 1);
52
+ });
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "@levimc/lip",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.34.4-beta.1",
4
+ "license": "GPL-3.0-only",
5
+ "description": "A general package installer",
6
+ "homepage": "https://github.com/futrime/lip",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/futrime/lip.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/futrime/lip/issues"
13
+ },
14
+ "bin": {
15
+ "lip": "lip.js",
16
+ "lipd": "lipd.js"
17
+ },
18
+ "scripts": {
19
+ "postinstall": "node postinstall.js"
20
+ },
21
+ "files": [
22
+ "dotnet-bootstrap.js",
23
+ "lip.js",
24
+ "lipd.js",
25
+ "postinstall.js",
26
+ "linux-*/*",
27
+ "darwin-*/*",
28
+ "win32-*/*"
29
+ ],
30
+ "engines": {
31
+ "node": ">=18"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ }
36
+ }
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
+ }
Binary file
Binary file
Binary file
Binary file
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.