pinokiod 7.1.78 → 7.1.79

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/kernel/shell.js CHANGED
@@ -16,6 +16,7 @@ const sudo = require("sudo-prompt-programfiles-x86");
16
16
  const unparse = require('yargs-unparser-custom-flag');
17
17
  const Util = require('./util')
18
18
  const Environment = require('./environment')
19
+ const { applyWindowsNodePackageManagerEnv } = require('./windows_node_package_manager_env')
19
20
  const ShellParser = require('./shell_parser')
20
21
  const AnsiStreamTracker = require('./ansi_stream_tracker')
21
22
  const ShellStateSync = require('./shell_state_sync')
@@ -179,10 +180,6 @@ class Shell {
179
180
  this.env.CONDA_SHORTCUTS = 0
180
181
  this.env.CONDA_CONSOLE = 'json'
181
182
 
182
- if (this.platform === "win32") {
183
- this.env.npm_config_symlink = "false"
184
- }
185
-
186
183
  // this.env.TCELL_MINIMIZE=1
187
184
  this.env.CMAKE_OBJECT_PATH_MAX = 1024
188
185
  this.env.PYTORCH_ENABLE_MPS_FALLBACK = 1
@@ -305,6 +302,12 @@ class Shell {
305
302
  delete this.env[key]
306
303
  }
307
304
  }
305
+
306
+ if (this.platform === "win32") {
307
+ await applyWindowsNodePackageManagerEnv(this.env, {
308
+ targetPath: params && params.path ? params.path : this.kernel.homedir,
309
+ })
310
+ }
308
311
  }
309
312
  isCmdShell(shellName=this.shell) {
310
313
  const name = (shellName || '').toLowerCase()
@@ -0,0 +1,92 @@
1
+ const fs = require('fs')
2
+ const os = require('os')
3
+ const path = require('path')
4
+
5
+ const windowsDirectoryLinkCache = new Map()
6
+
7
+ async function findExistingAncestor(targetPath) {
8
+ let current = path.resolve(targetPath)
9
+ while (true) {
10
+ const exists = await fs.promises.access(current, fs.constants.F_OK).then(() => true).catch(() => false)
11
+ if (exists) {
12
+ return current
13
+ }
14
+ const parent = path.dirname(current)
15
+ if (!parent || parent === current) {
16
+ return null
17
+ }
18
+ current = parent
19
+ }
20
+ }
21
+
22
+ async function windowsDirectoryLinksWork(targetPath) {
23
+ const ancestor = await findExistingAncestor(targetPath || os.homedir())
24
+ if (!ancestor) {
25
+ return true
26
+ }
27
+
28
+ const cacheKey = path.parse(path.resolve(ancestor)).root.toLowerCase()
29
+ if (windowsDirectoryLinkCache.has(cacheKey)) {
30
+ return windowsDirectoryLinkCache.get(cacheKey)
31
+ }
32
+
33
+ const probePromise = (async () => {
34
+ let probeDir = null
35
+ try {
36
+ probeDir = await fs.promises.mkdtemp(path.join(ancestor, ".pinokio-link-probe-"))
37
+ const sourceDir = path.resolve(probeDir, "source")
38
+ const linkDir = path.resolve(probeDir, "link")
39
+ await fs.promises.mkdir(sourceDir)
40
+ await fs.promises.symlink(path.resolve(sourceDir), linkDir, "junction")
41
+ return true
42
+ } catch (_) {
43
+ return false
44
+ } finally {
45
+ if (probeDir) {
46
+ await fs.promises.rm(probeDir, { recursive: true, force: true }).catch(() => {})
47
+ }
48
+ }
49
+ })()
50
+
51
+ windowsDirectoryLinkCache.set(cacheKey, probePromise)
52
+ return probePromise
53
+ }
54
+
55
+ function getFirstDefinedEnv(env, keys) {
56
+ for (const key of keys) {
57
+ const value = env[key]
58
+ if (typeof value === "string" && value.trim()) {
59
+ return value.trim()
60
+ }
61
+ }
62
+ return null
63
+ }
64
+
65
+ async function applyWindowsNodePackageManagerEnv(env, options = {}) {
66
+ delete env.npm_config_symlink
67
+ delete env.NPM_CONFIG_SYMLINK
68
+ delete env.pnpm_config_symlink
69
+ delete env.PNPM_CONFIG_SYMLINK
70
+
71
+ const explicitNodeLinker = getFirstDefinedEnv(env, [
72
+ "npm_config_node_linker",
73
+ "NPM_CONFIG_NODE_LINKER",
74
+ "pnpm_config_node_linker",
75
+ "PNPM_CONFIG_NODE_LINKER",
76
+ ])
77
+ if (explicitNodeLinker) {
78
+ return
79
+ }
80
+
81
+ const targetPath = options.targetPath || os.homedir()
82
+ if (await windowsDirectoryLinksWork(targetPath)) {
83
+ return
84
+ }
85
+
86
+ env.npm_config_node_linker = "hoisted"
87
+ env.NPM_CONFIG_NODE_LINKER = "hoisted"
88
+ }
89
+
90
+ module.exports = {
91
+ applyWindowsNodePackageManagerEnv,
92
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "7.1.78",
3
+ "version": "7.1.79",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {