vxrn 2.13.7 → 2.13.9

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 (119) hide show
  1. package/dist/cli.mjs +3 -2
  2. package/dist/cli.mjs.map +1 -1
  3. package/dist/cli.native.js +5 -2
  4. package/dist/cli.native.js.map +1 -1
  5. package/dist/config/getBaseViteConfigOnly.mjs +3 -3
  6. package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
  7. package/dist/config/getBaseViteConfigOnly.native.js +3 -3
  8. package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
  9. package/dist/config/getOptionsFilled.mjs +24 -2
  10. package/dist/config/getOptionsFilled.mjs.map +1 -1
  11. package/dist/config/getOptionsFilled.native.js +25 -2
  12. package/dist/config/getOptionsFilled.native.js.map +1 -1
  13. package/dist/config/getServerOptionsFilled.mjs +119 -1
  14. package/dist/config/getServerOptionsFilled.mjs.map +1 -1
  15. package/dist/config/getServerOptionsFilled.native.js +137 -1
  16. package/dist/config/getServerOptionsFilled.native.js.map +1 -1
  17. package/dist/exports/build.mjs +6 -9
  18. package/dist/exports/build.mjs.map +1 -1
  19. package/dist/exports/build.native.js +6 -9
  20. package/dist/exports/build.native.js.map +1 -1
  21. package/dist/exports/dev.mjs +4 -6
  22. package/dist/exports/dev.mjs.map +1 -1
  23. package/dist/exports/dev.native.js +6 -6
  24. package/dist/exports/dev.native.js.map +1 -1
  25. package/dist/exports/prebuild.mjs +4 -4
  26. package/dist/exports/prebuild.mjs.map +1 -1
  27. package/dist/exports/prebuild.native.js +4 -4
  28. package/dist/exports/prebuild.native.js.map +1 -1
  29. package/dist/exports/prebuildWithoutExpo.mjs +95 -88
  30. package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
  31. package/dist/exports/prebuildWithoutExpo.native.js +95 -88
  32. package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
  33. package/dist/plugins/autoDepOptimizePlugin.mjs +3 -3
  34. package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
  35. package/dist/plugins/autoDepOptimizePlugin.native.js +3 -3
  36. package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
  37. package/dist/plugins/reactNativeDevAssetPlugin.mjs +4 -4
  38. package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
  39. package/dist/plugins/reactNativeDevAssetPlugin.native.js +4 -4
  40. package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
  41. package/dist/rn-commands/bundle/buildBundle.mjs +18 -5
  42. package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
  43. package/dist/rn-commands/bundle/buildBundle.native.js +18 -5
  44. package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
  45. package/dist/user-interface/index.mjs +1 -1
  46. package/dist/user-interface/index.mjs.map +1 -1
  47. package/dist/user-interface/index.native.js +1 -1
  48. package/dist/user-interface/index.native.js.map +1 -1
  49. package/dist/utils/env-editor.mjs +198 -0
  50. package/dist/utils/env-editor.mjs.map +1 -0
  51. package/dist/utils/env-editor.native.js +266 -0
  52. package/dist/utils/env-editor.native.js.map +1 -0
  53. package/dist/utils/fs.mjs +48 -0
  54. package/dist/utils/fs.mjs.map +1 -0
  55. package/dist/utils/fs.native.js +48 -0
  56. package/dist/utils/fs.native.js.map +1 -0
  57. package/dist/utils/getVitePath.mjs +2 -2
  58. package/dist/utils/getVitePath.mjs.map +1 -1
  59. package/dist/utils/getVitePath.native.js +2 -2
  60. package/dist/utils/getVitePath.native.js.map +1 -1
  61. package/dist/utils/patches.mjs +38 -29
  62. package/dist/utils/patches.mjs.map +1 -1
  63. package/dist/utils/patches.native.js +38 -29
  64. package/dist/utils/patches.native.js.map +1 -1
  65. package/dist/utils/scanDepsToOptimize.mjs +12 -11
  66. package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
  67. package/dist/utils/scanDepsToOptimize.native.js +12 -11
  68. package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
  69. package/dist/utils/state.mjs +5 -5
  70. package/dist/utils/state.mjs.map +1 -1
  71. package/dist/utils/state.native.js +5 -5
  72. package/dist/utils/state.native.js.map +1 -1
  73. package/dist/utils/utils.mjs +4 -3
  74. package/dist/utils/utils.mjs.map +1 -1
  75. package/dist/utils/utils.native.js +4 -3
  76. package/dist/utils/utils.native.js.map +1 -1
  77. package/package.json +12 -18
  78. package/src/cli.ts +5 -4
  79. package/src/config/getBaseViteConfigOnly.ts +3 -3
  80. package/src/config/getOptionsFilled.ts +35 -2
  81. package/src/config/getServerOptionsFilled.test.ts +37 -0
  82. package/src/config/getServerOptionsFilled.ts +57 -1
  83. package/src/exports/build.ts +5 -12
  84. package/src/exports/clean.test.ts +1 -1
  85. package/src/exports/dev.ts +5 -6
  86. package/src/exports/prebuild.ts +4 -4
  87. package/src/exports/prebuildWithoutExpo.ts +102 -89
  88. package/src/plugins/autoDepOptimizePlugin.ts +3 -3
  89. package/src/plugins/reactNativeDevAssetPlugin.ts +4 -4
  90. package/src/rn-commands/bundle/buildBundle.ts +15 -5
  91. package/src/user-interface/index.ts +1 -1
  92. package/src/utils/env-editor.LICENSE +9 -0
  93. package/src/utils/env-editor.ts +214 -0
  94. package/src/utils/fs.ts +59 -0
  95. package/src/utils/getVitePath.ts +2 -2
  96. package/src/utils/patches.test.ts +36 -36
  97. package/src/utils/patches.ts +39 -27
  98. package/src/utils/scanDepsToOptimize.test.ts +2 -2
  99. package/src/utils/scanDepsToOptimize.ts +6 -5
  100. package/src/utils/state.ts +5 -7
  101. package/src/utils/utils.ts +5 -5
  102. package/types/config/getOptionsFilled.d.ts +9 -2
  103. package/types/config/getOptionsFilled.d.ts.map +1 -1
  104. package/types/config/getServerOptionsFilled.d.ts.map +1 -1
  105. package/types/exports/build.d.ts +1 -1
  106. package/types/exports/build.d.ts.map +1 -1
  107. package/types/exports/dev.d.ts.map +1 -1
  108. package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
  109. package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
  110. package/types/user-interface/index.d.ts.map +1 -1
  111. package/types/utils/env-editor.d.ts +9 -0
  112. package/types/utils/env-editor.d.ts.map +1 -0
  113. package/types/utils/fs.d.ts +9 -0
  114. package/types/utils/fs.d.ts.map +1 -0
  115. package/types/utils/patches.d.ts.map +1 -1
  116. package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
  117. package/types/utils/state.d.ts.map +1 -1
  118. package/types/utils/utils.d.ts +2 -2
  119. package/types/utils/utils.d.ts.map +1 -1
@@ -1,8 +1,9 @@
1
- import FSExtra from 'fs-extra'
2
1
  import { clearTransformCache } from '@vxrn/compiler'
3
2
  import type { BundleCommandArgs } from '@vxrn/vite-plugin-metro/rn-commands'
3
+ import { cpSync, existsSync, mkdirSync, renameSync, rmSync } from 'node:fs'
4
4
  import { resolveConfig } from 'vite'
5
5
  import { dirname, join, resolve } from 'node:path'
6
+ import { outputFileSync } from '../../utils/fs'
6
7
  import { loadEnv } from '../../exports/loadEnv'
7
8
  import { buildNativeBundle } from '../../utils/createNativeDevEngine'
8
9
 
@@ -99,18 +100,27 @@ export async function buildBundle(
99
100
  const source = join(assetsDest, 'one-dom')
100
101
  const destination = join(dirname(bundleOutput), 'one-dom')
101
102
  if (resolve(source) !== resolve(destination)) {
102
- FSExtra.removeSync(destination)
103
- if (FSExtra.existsSync(source)) FSExtra.moveSync(source, destination)
103
+ rmSync(destination, { recursive: true, force: true })
104
+ if (existsSync(source)) {
105
+ mkdirSync(dirname(destination), { recursive: true })
106
+ try {
107
+ renameSync(source, destination)
108
+ } catch (error) {
109
+ if ((error as NodeJS.ErrnoException).code !== 'EXDEV') throw error
110
+ cpSync(source, destination, { recursive: true })
111
+ rmSync(source, { recursive: true })
112
+ }
113
+ }
104
114
  }
105
115
  }
106
116
 
107
117
  // write sourcemap if available and requested
108
118
  if (result.map && args.sourcemapOutput) {
109
- FSExtra.outputFileSync(args.sourcemapOutput, result.map, { encoding: 'utf8' })
119
+ outputFileSync(args.sourcemapOutput, result.map, { encoding: 'utf8' })
110
120
  }
111
121
 
112
122
  console.info(`Writing bundle to ${bundleOutput}...`)
113
- FSExtra.outputFileSync(bundleOutput, builtBundle, { encoding: bundleEncoding })
123
+ outputFileSync(bundleOutput, builtBundle, { encoding: bundleEncoding })
114
124
  console.info('Done.')
115
125
 
116
126
  // Prevent the process not getting exited for some unknown reason.
@@ -1,3 +1,4 @@
1
+ import { defaultEditor } from '../utils/env-editor'
1
2
  import { exec } from 'node:child_process'
2
3
  import type { ViteDevServer } from 'vite'
3
4
  import { getBoundPort } from '../utils/getBoundPort'
@@ -50,7 +51,6 @@ const COMMANDS = [
50
51
  label: 'open editor',
51
52
  terminalLabel: '\x1b[1mo\x1b[0mpen \x1b[1me\x1b[0mditor',
52
53
  action: async (ctx) => {
53
- const { defaultEditor } = await import('env-editor')
54
54
  exec(`${defaultEditor().binary} .`)
55
55
  },
56
56
  },
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,214 @@
1
+ // vendored from env-editor 1.3.0 by Sindre Sorhus (MIT); see env-editor.LICENSE.
2
+ import process from 'node:process'
3
+ import path from 'node:path'
4
+
5
+ function allEditors() {
6
+ return [
7
+ {
8
+ id: 'sublime',
9
+ name: 'Sublime Text',
10
+ binary: 'subl',
11
+ isTerminalEditor: false,
12
+ paths: [
13
+ '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl',
14
+ '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl',
15
+ ],
16
+ keywords: [],
17
+ },
18
+ {
19
+ id: 'atom',
20
+ name: 'Atom',
21
+ binary: 'atom',
22
+ isTerminalEditor: false,
23
+ paths: ['/Applications/Atom.app/Contents/Resources/app/atom.sh'],
24
+ keywords: [],
25
+ },
26
+ {
27
+ id: 'vscode-insiders',
28
+ name: 'Visual Studio Code - Insiders',
29
+ binary: 'code-insiders',
30
+ isTerminalEditor: false,
31
+ paths: [
32
+ '/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code-insiders',
33
+ ],
34
+ keywords: ['vs code insiders', 'code insiders', 'insiders'],
35
+ },
36
+ {
37
+ id: 'vscode',
38
+ name: 'Visual Studio Code',
39
+ binary: 'code',
40
+ isTerminalEditor: false,
41
+ paths: ['/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code'],
42
+ keywords: ['vs code'],
43
+ },
44
+ {
45
+ id: 'vscodium',
46
+ name: 'VSCodium',
47
+ binary: 'codium',
48
+ isTerminalEditor: false,
49
+ paths: ['/Applications/VSCodium.app/Contents/Resources/app/bin/codium'],
50
+ keywords: [],
51
+ },
52
+ {
53
+ id: 'webstorm',
54
+ name: 'WebStorm',
55
+ binary: 'webstorm',
56
+ isTerminalEditor: false,
57
+ paths: [],
58
+ keywords: ['wstorm'],
59
+ },
60
+ {
61
+ id: 'phpstorm',
62
+ name: 'PhpStorm',
63
+ binary: 'pstorm',
64
+ isTerminalEditor: false,
65
+ paths: [],
66
+ keywords: ['php'],
67
+ },
68
+ {
69
+ id: 'textmate',
70
+ name: 'TextMate',
71
+ binary: 'mate',
72
+ isTerminalEditor: false,
73
+ paths: [],
74
+ keywords: [],
75
+ },
76
+ {
77
+ id: 'vim',
78
+ name: 'Vim',
79
+ binary: 'vim',
80
+ isTerminalEditor: true,
81
+ paths: [],
82
+ keywords: ['vi'],
83
+ },
84
+ {
85
+ id: 'neovim',
86
+ name: 'NeoVim',
87
+ binary: 'nvim',
88
+ isTerminalEditor: true,
89
+ paths: [],
90
+ keywords: ['vim'],
91
+ },
92
+ {
93
+ id: 'intellij',
94
+ name: 'IntelliJ IDEA',
95
+ binary: 'idea',
96
+ isTerminalEditor: false,
97
+ paths: [],
98
+ keywords: ['idea', 'java', 'jetbrains', 'ide'],
99
+ },
100
+ {
101
+ id: 'nano',
102
+ name: 'GNU nano',
103
+ binary: 'nano',
104
+ isTerminalEditor: true,
105
+ paths: [],
106
+ keywords: [],
107
+ },
108
+ {
109
+ id: 'emacs',
110
+ name: 'GNU Emacs',
111
+ binary: 'emacs',
112
+ isTerminalEditor: true,
113
+ paths: [],
114
+ keywords: [],
115
+ },
116
+ {
117
+ id: 'emacsforosx',
118
+ name: 'GNU Emacs for Mac OS X',
119
+ binary: 'Emacs',
120
+ isTerminalEditor: false,
121
+ paths: ['/Applications/Emacs.app/Contents/MacOS/Emacs'],
122
+ keywords: [],
123
+ },
124
+ {
125
+ id: 'android-studio',
126
+ name: 'Android Studio',
127
+ binary: 'studio',
128
+ isTerminalEditor: false,
129
+ paths: [
130
+ '/Applications/Android Studio.app/Contents/MacOS/studio',
131
+ '/usr/local/Android/android-studio/bin/studio.sh',
132
+ 'C:\\Program Files (x86)\\Android\\android-studio\\bin\\studio.exe',
133
+ 'C:\\Program Files\\Android\\android-studio\\bin\\studio64.exe',
134
+ ],
135
+ keywords: ['studio'],
136
+ },
137
+ {
138
+ id: 'xcode',
139
+ name: 'Xcode',
140
+ binary: 'xed',
141
+ isTerminalEditor: false,
142
+ paths: [
143
+ '/Applications/Xcode.app/Contents/MacOS/Xcode',
144
+ '/Applications/Xcode-beta.app/Contents/MacOS/Xcode',
145
+ ],
146
+ keywords: ['xed'],
147
+ },
148
+ ]
149
+ }
150
+
151
+ function getEditor(editor: string) {
152
+ editor = editor.trim()
153
+
154
+ const needle = editor.toLowerCase()
155
+ const id = needle.split(/[/\\]/).pop()!.replace(/\s/g, '-')
156
+ const binary = id.split('-')[0]
157
+
158
+ for (const editor of allEditors()) {
159
+ // Check for exact id, name, or full binary match first
160
+ if (
161
+ needle === editor.id ||
162
+ needle === editor.name.toLowerCase() ||
163
+ id === editor.binary
164
+ ) {
165
+ return editor
166
+ }
167
+
168
+ for (const editorPath of editor.paths) {
169
+ if (path.normalize(needle) === path.normalize(editorPath.toLowerCase())) {
170
+ return editor
171
+ }
172
+ }
173
+
174
+ for (const keyword of editor.keywords) {
175
+ if (needle === keyword) {
176
+ return editor
177
+ }
178
+ }
179
+ }
180
+
181
+ // Fallback to checking the shortened binary if no exact match found
182
+ for (const editor of allEditors()) {
183
+ if (binary === editor.binary) {
184
+ return editor
185
+ }
186
+ }
187
+
188
+ return {
189
+ id,
190
+ name: editor,
191
+ binary,
192
+ isTerminalEditor: false,
193
+ paths: [],
194
+ keywords: [],
195
+ }
196
+ }
197
+
198
+ export function defaultEditor() {
199
+ const editor = process.env.EDITOR || process.env.VISUAL
200
+
201
+ if (!editor) {
202
+ throw new Error(
203
+ // eslint-disable-next-line indent
204
+ `
205
+ Your $EDITOR environment variable is not set.
206
+ Set it to the command/path of your editor in ~/.zshenv or ~/.bashrc:
207
+
208
+ export EDITOR=atom
209
+ `
210
+ )
211
+ }
212
+
213
+ return getEditor(editor)
214
+ }
@@ -0,0 +1,59 @@
1
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
2
+ import { access, mkdir, readFile, writeFile } from 'node:fs/promises'
3
+ import { dirname } from 'node:path'
4
+
5
+ // small fs helpers over node builtins, matching the fs-extra surface vxrn used:
6
+ // read errors propagate as-is, json parse errors are prefixed with the file
7
+ // path, and json writes are compact with a trailing newline.
8
+
9
+ export async function pathExists(path: string): Promise<boolean> {
10
+ try {
11
+ await access(path)
12
+ return true
13
+ } catch {
14
+ return false
15
+ }
16
+ }
17
+
18
+ function stripBom(content: string): string {
19
+ return content.replace(/^\uFEFF/, '')
20
+ }
21
+
22
+ function parseJSON<T>(path: string, content: string): T {
23
+ try {
24
+ return JSON.parse(stripBom(content))
25
+ } catch (err) {
26
+ ;(err as Error).message = `${path}: ${(err as Error).message}`
27
+ throw err
28
+ }
29
+ }
30
+
31
+ export async function readJSON<T = any>(path: string): Promise<T> {
32
+ return parseJSON(path, await readFile(path, 'utf8'))
33
+ }
34
+
35
+ export function readJSONSync<T = any>(path: string): T {
36
+ return parseJSON(path, readFileSync(path, 'utf8'))
37
+ }
38
+
39
+ function stringifyJSON(data: unknown): string {
40
+ return `${JSON.stringify(data)}\n`
41
+ }
42
+
43
+ export async function writeJSON(path: string, data: unknown): Promise<void> {
44
+ await writeFile(path, stringifyJSON(data))
45
+ }
46
+
47
+ export async function outputJSON(path: string, data: unknown): Promise<void> {
48
+ await mkdir(dirname(path), { recursive: true })
49
+ await writeJSON(path, data)
50
+ }
51
+
52
+ export function outputFileSync(
53
+ path: string,
54
+ data: string | Uint8Array,
55
+ options?: { encoding?: BufferEncoding }
56
+ ): void {
57
+ mkdirSync(dirname(path), { recursive: true })
58
+ writeFileSync(path, data, options)
59
+ }
@@ -1,6 +1,6 @@
1
1
  import { dirname, join } from 'node:path'
2
2
 
3
- import FSExtra from 'fs-extra'
3
+ import { realpath } from 'node:fs/promises'
4
4
  import { normalizePath } from 'vite'
5
5
 
6
6
  export async function getVitePath(
@@ -65,7 +65,7 @@ export async function getVitePath(
65
65
  )
66
66
  }
67
67
 
68
- const real = await FSExtra.realpath(resolved)
68
+ const real = await realpath(resolved)
69
69
 
70
70
  let id = real
71
71
 
@@ -1,6 +1,6 @@
1
- import FSExtra from 'fs-extra'
2
1
  import { join } from 'node:path'
3
- import { mkdtemp, rm, symlink } from 'node:fs/promises'
2
+ import { mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises'
3
+ import { readJSON } from './fs'
4
4
  import { tmpdir } from 'node:os'
5
5
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
6
6
 
@@ -56,7 +56,7 @@ describe('applyDependencyPatches', () => {
56
56
  setupFs: (nmDir: string) => Promise<void>
57
57
  }) {
58
58
  const nmDir = join(tmpDir, 'node_modules')
59
- await FSExtra.ensureDir(nmDir)
59
+ await mkdir(nmDir, { recursive: true })
60
60
  await opts.setupFs(nmDir)
61
61
  await applyDependencyPatches(opts.patches, { root: tmpDir })
62
62
  return nmDir
@@ -91,8 +91,8 @@ describe('applyDependencyPatches', () => {
91
91
  '@react-navigation',
92
92
  'core'
93
93
  )
94
- await FSExtra.ensureDir(storePkgDir)
95
- await FSExtra.writeFile(
94
+ await mkdir(storePkgDir, { recursive: true })
95
+ await writeFile(
96
96
  join(storePkgDir, 'package.json'),
97
97
  makePkg('@react-navigation/core', '7.16.1')
98
98
  )
@@ -100,7 +100,7 @@ describe('applyDependencyPatches', () => {
100
100
  })
101
101
 
102
102
  // verify the patch was applied in the store
103
- const patchedPkg = await FSExtra.readJSON(
103
+ const patchedPkg = await readJSON(
104
104
  join(
105
105
  nmDir,
106
106
  '.pnpm',
@@ -136,12 +136,12 @@ describe('applyDependencyPatches', () => {
136
136
  setupFs: async (nm) => {
137
137
  // create the real package in pnpm store
138
138
  const storeDir = join(nm, '.pnpm', 'test-pkg@1.0.0', 'node_modules', 'test-pkg')
139
- await FSExtra.ensureDir(storeDir)
140
- await FSExtra.writeFile(
139
+ await mkdir(storeDir, { recursive: true })
140
+ await writeFile(
141
141
  join(storeDir, 'package.json'),
142
142
  makePkg('test-pkg', '1.0.0')
143
143
  )
144
- await FSExtra.writeFile(join(storeDir, 'index.js'), 'module.exports = {}')
144
+ await writeFile(join(storeDir, 'index.js'), 'module.exports = {}')
145
145
 
146
146
  // create symlink at top-level node_modules (like pnpm does when hoisted)
147
147
  const symlinkTarget = join(nm, 'test-pkg')
@@ -149,7 +149,7 @@ describe('applyDependencyPatches', () => {
149
149
 
150
150
  // also create .pnpm/node_modules hoisted symlink
151
151
  const pnpmHoisted = join(nm, '.pnpm', 'node_modules', 'test-pkg')
152
- await FSExtra.ensureDir(join(nm, '.pnpm', 'node_modules'))
152
+ await mkdir(join(nm, '.pnpm', 'node_modules'), { recursive: true })
153
153
  await symlink(storeDir, pnpmHoisted, 'junction')
154
154
  },
155
155
  })
@@ -175,16 +175,16 @@ describe('applyDependencyPatches', () => {
175
175
  setupFs: async (nm) => {
176
176
  // standard flat node_modules layout, no .pnpm
177
177
  const pkgDir = join(nm, 'test-pkg')
178
- await FSExtra.ensureDir(pkgDir)
179
- await FSExtra.writeFile(
178
+ await mkdir(pkgDir, { recursive: true })
179
+ await writeFile(
180
180
  join(pkgDir, 'package.json'),
181
181
  makePkg('test-pkg', '1.0.0')
182
182
  )
183
- await FSExtra.writeFile(join(pkgDir, 'index.js'), 'module.exports = {}')
183
+ await writeFile(join(pkgDir, 'index.js'), 'module.exports = {}')
184
184
  },
185
185
  })
186
186
 
187
- const content = await FSExtra.readFile(join(nmDir, 'test-pkg', 'index.js'), 'utf-8')
187
+ const content = await readFile(join(nmDir, 'test-pkg', 'index.js'), 'utf-8')
188
188
  expect(content).toContain('// patched')
189
189
  })
190
190
 
@@ -204,29 +204,29 @@ describe('applyDependencyPatches', () => {
204
204
  setupFs: async (nm) => {
205
205
  // v1 store entry
206
206
  const v1Dir = join(nm, '.pnpm', 'test-pkg@1.0.0', 'node_modules', 'test-pkg')
207
- await FSExtra.ensureDir(v1Dir)
208
- await FSExtra.writeFile(join(v1Dir, 'package.json'), makePkg('test-pkg', '1.0.0'))
209
- await FSExtra.writeFile(join(v1Dir, 'index.js'), 'module.exports = "v1"')
207
+ await mkdir(v1Dir, { recursive: true })
208
+ await writeFile(join(v1Dir, 'package.json'), makePkg('test-pkg', '1.0.0'))
209
+ await writeFile(join(v1Dir, 'index.js'), 'module.exports = "v1"')
210
210
 
211
211
  // v2 store entry
212
212
  const v2Dir = join(nm, '.pnpm', 'test-pkg@2.0.0', 'node_modules', 'test-pkg')
213
- await FSExtra.ensureDir(v2Dir)
214
- await FSExtra.writeFile(join(v2Dir, 'package.json'), makePkg('test-pkg', '2.0.0'))
215
- await FSExtra.writeFile(join(v2Dir, 'index.js'), 'module.exports = "v2"')
213
+ await mkdir(v2Dir, { recursive: true })
214
+ await writeFile(join(v2Dir, 'package.json'), makePkg('test-pkg', '2.0.0'))
215
+ await writeFile(join(v2Dir, 'index.js'), 'module.exports = "v2"')
216
216
  },
217
217
  })
218
218
 
219
219
  const nmDir = join(tmpDir, 'node_modules')
220
220
 
221
221
  // v1 should be patched
222
- const v1Content = await FSExtra.readFile(
222
+ const v1Content = await readFile(
223
223
  join(nmDir, '.pnpm', 'test-pkg@1.0.0', 'node_modules', 'test-pkg', 'index.js'),
224
224
  'utf-8'
225
225
  )
226
226
  expect(v1Content).toBe('// v1 patched')
227
227
 
228
228
  // v2 should NOT be patched
229
- const v2Content = await FSExtra.readFile(
229
+ const v2Content = await readFile(
230
230
  join(nmDir, '.pnpm', 'test-pkg@2.0.0', 'node_modules', 'test-pkg', 'index.js'),
231
231
  'utf-8'
232
232
  )
@@ -253,15 +253,15 @@ describe('applyDependencyPatches', () => {
253
253
  setupFs: async (nm) => {
254
254
  // real package in store
255
255
  const storeDir = join(nm, '.pnpm', 'test-pkg@1.0.0', 'node_modules', 'test-pkg')
256
- await FSExtra.ensureDir(storeDir)
257
- await FSExtra.writeFile(
256
+ await mkdir(storeDir, { recursive: true })
257
+ await writeFile(
258
258
  join(storeDir, 'package.json'),
259
259
  makePkg('test-pkg', '1.0.0')
260
260
  )
261
- await FSExtra.writeFile(join(storeDir, 'index.js'), 'module.exports = {}')
261
+ await writeFile(join(storeDir, 'index.js'), 'module.exports = {}')
262
262
 
263
263
  // hoisted symlink in .pnpm/node_modules
264
- await FSExtra.ensureDir(join(nm, '.pnpm', 'node_modules'))
264
+ await mkdir(join(nm, '.pnpm', 'node_modules'), { recursive: true })
265
265
  await symlink(storeDir, join(nm, '.pnpm', 'node_modules', 'test-pkg'), 'junction')
266
266
  },
267
267
  })
@@ -269,7 +269,7 @@ describe('applyDependencyPatches', () => {
269
269
  expect(patchCallCount).toBe(1)
270
270
 
271
271
  // verify the file was actually patched
272
- const content = await FSExtra.readFile(
272
+ const content = await readFile(
273
273
  join(nmDir, '.pnpm', 'test-pkg@1.0.0', 'node_modules', 'test-pkg', 'index.js'),
274
274
  'utf-8'
275
275
  )
@@ -296,12 +296,12 @@ describe('applyDependencyPatches', () => {
296
296
  patches: stale,
297
297
  setupFs: async (nm) => {
298
298
  const pkgDir = join(nm, 'test-pkg')
299
- await FSExtra.ensureDir(pkgDir)
300
- await FSExtra.writeFile(
299
+ await mkdir(pkgDir, { recursive: true })
300
+ await writeFile(
301
301
  join(pkgDir, 'package.json'),
302
302
  makePkg('test-pkg', '1.0.0')
303
303
  )
304
- await FSExtra.writeFile(join(pkgDir, 'index.js'), 'module.exports = {}')
304
+ await writeFile(join(pkgDir, 'index.js'), 'module.exports = {}')
305
305
  },
306
306
  })
307
307
 
@@ -326,12 +326,12 @@ describe('applyDependencyPatches', () => {
326
326
  patches: applies,
327
327
  setupFs: async (nm) => {
328
328
  const pkgDir = join(nm, 'test-pkg')
329
- await FSExtra.ensureDir(pkgDir)
330
- await FSExtra.writeFile(
329
+ await mkdir(pkgDir, { recursive: true })
330
+ await writeFile(
331
331
  join(pkgDir, 'package.json'),
332
332
  makePkg('test-pkg', '1.0.0')
333
333
  )
334
- await FSExtra.writeFile(join(pkgDir, 'index.js'), 'module.exports = {}')
334
+ await writeFile(join(pkgDir, 'index.js'), 'module.exports = {}')
335
335
  },
336
336
  })
337
337
 
@@ -384,12 +384,12 @@ describe('applyDependencyPatches', () => {
384
384
  patches: [{ module: 'test-pkg', patchFiles: { 'index.js': ['swc'] } }],
385
385
  setupFs: async (nm) => {
386
386
  const pkgDir = join(nm, 'test-pkg')
387
- await FSExtra.ensureDir(pkgDir)
388
- await FSExtra.writeFile(
387
+ await mkdir(pkgDir, { recursive: true })
388
+ await writeFile(
389
389
  join(pkgDir, 'package.json'),
390
390
  makePkg('test-pkg', '1.0.0')
391
391
  )
392
- await FSExtra.writeFile(join(pkgDir, 'index.js'), 'export default () => <div />')
392
+ await writeFile(join(pkgDir, 'index.js'), 'export default () => <div />')
393
393
  },
394
394
  })
395
395