@pnpm/workspace.injected-deps-syncer 1100.0.22 → 1100.0.24

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/CHANGELOG.md ADDED
@@ -0,0 +1,424 @@
1
+ # @pnpm/workspace.injected-deps-syncer
2
+
3
+ ## 1100.0.24
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @pnpm/bins.linker@1100.0.18
9
+ - @pnpm/fetching.directory-fetcher@1100.0.21
10
+ - @pnpm/workspace.projects-reader@1101.0.15
11
+
12
+ ## 1100.0.23
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies:
17
+ - @pnpm/bins.linker@1100.0.17
18
+ - @pnpm/fetching.directory-fetcher@1100.0.20
19
+ - @pnpm/installing.modules-yaml@1100.0.10
20
+ - @pnpm/pkg-manifest.reader@1100.0.10
21
+ - @pnpm/types@1101.4.0
22
+ - @pnpm/workspace.projects-reader@1101.0.14
23
+
24
+ ## 1100.0.22
25
+
26
+ ### Patch Changes
27
+
28
+ - @pnpm/fetching.directory-fetcher@1100.0.19
29
+
30
+ ## 1100.0.21
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [852d537]
35
+ - @pnpm/error@1100.0.1
36
+ - @pnpm/fetching.directory-fetcher@1100.0.18
37
+ - @pnpm/bins.linker@1100.0.16
38
+ - @pnpm/workspace.projects-reader@1101.0.13
39
+ - @pnpm/pkg-manifest.reader@1100.0.9
40
+
41
+ ## 1100.0.20
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies [3d1fd20]
46
+ - @pnpm/bins.linker@1100.0.15
47
+
48
+ ## 1100.0.19
49
+
50
+ ### Patch Changes
51
+
52
+ - a31faa7: Updated dependency ranges. Notably:
53
+
54
+ - `@pnpm/logger` peer dependency range moved to `^1100.0.0`.
55
+ - `msgpackr` 1.11.8 → 2.0.4 (store index files remain byte-compatible in both directions).
56
+ - `open` ^7.4.2 → ^11.0.0, `memoize` ^10 → ^11, `cli-truncate` ^5 → ^6, `pidtree` ^0.6 → ^1.
57
+ - `@yarnpkg/core` 4.5.0 → 4.8.0, `@rushstack/worker-pool` 0.7.7 → 0.7.18, `@cyclonedx/cyclonedx-library` 10.0.0 → 10.1.0, `@pnpm/config.nerf-dart` ^1 → ^2, `@pnpm/log.group` 3.0.2 → 4.0.1, `@pnpm/util.lex-comparator` ^3 → ^4.
58
+
59
+ - Updated dependencies [61810aa]
60
+ - Updated dependencies [681b593]
61
+ - Updated dependencies [a31faa7]
62
+ - Updated dependencies [cd8348c]
63
+ - @pnpm/bins.linker@1100.0.14
64
+ - @pnpm/types@1101.3.2
65
+ - @pnpm/fetching.directory-fetcher@1100.0.17
66
+ - @pnpm/workspace.projects-reader@1101.0.12
67
+ - @pnpm/installing.modules-yaml@1100.0.9
68
+ - @pnpm/pkg-manifest.reader@1100.0.8
69
+
70
+ ## 1100.0.18
71
+
72
+ ### Patch Changes
73
+
74
+ - @pnpm/bins.linker@1100.0.13
75
+ - @pnpm/workspace.projects-reader@1101.0.11
76
+ - @pnpm/fetching.directory-fetcher@1100.0.16
77
+
78
+ ## 1100.0.17
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [bf1b731]
83
+ - @pnpm/types@1101.3.1
84
+ - @pnpm/bins.linker@1100.0.12
85
+ - @pnpm/fetching.directory-fetcher@1100.0.15
86
+ - @pnpm/installing.modules-yaml@1100.0.8
87
+ - @pnpm/pkg-manifest.reader@1100.0.7
88
+ - @pnpm/workspace.projects-reader@1101.0.10
89
+
90
+ ## 1100.0.16
91
+
92
+ ### Patch Changes
93
+
94
+ - Updated dependencies [a017bf3]
95
+ - @pnpm/types@1101.3.0
96
+ - @pnpm/bins.linker@1100.0.11
97
+ - @pnpm/fetching.directory-fetcher@1100.0.14
98
+ - @pnpm/installing.modules-yaml@1100.0.7
99
+ - @pnpm/pkg-manifest.reader@1100.0.6
100
+ - @pnpm/workspace.projects-reader@1101.0.9
101
+
102
+ ## 1100.0.15
103
+
104
+ ### Patch Changes
105
+
106
+ - Updated dependencies [e8b3ae1]
107
+ - Updated dependencies [35d2355]
108
+ - @pnpm/workspace.projects-reader@1101.0.8
109
+ - @pnpm/types@1101.2.0
110
+ - @pnpm/bins.linker@1100.0.10
111
+ - @pnpm/fetching.directory-fetcher@1100.0.13
112
+ - @pnpm/installing.modules-yaml@1100.0.6
113
+ - @pnpm/pkg-manifest.reader@1100.0.5
114
+
115
+ ## 1100.0.14
116
+
117
+ ### Patch Changes
118
+
119
+ - @pnpm/bins.linker@1100.0.9
120
+ - @pnpm/fetching.directory-fetcher@1100.0.12
121
+ - @pnpm/workspace.projects-reader@1101.0.7
122
+
123
+ ## 1100.0.13
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies [64afc92]
128
+ - @pnpm/types@1101.1.1
129
+ - @pnpm/fetching.directory-fetcher@1100.0.11
130
+ - @pnpm/bins.linker@1100.0.8
131
+ - @pnpm/installing.modules-yaml@1100.0.5
132
+ - @pnpm/pkg-manifest.reader@1100.0.4
133
+ - @pnpm/workspace.projects-reader@1101.0.6
134
+
135
+ ## 1100.0.12
136
+
137
+ ### Patch Changes
138
+
139
+ - @pnpm/fetching.directory-fetcher@1100.0.10
140
+ - @pnpm/bins.linker@1100.0.7
141
+ - @pnpm/workspace.projects-reader@1101.0.5
142
+
143
+ ## 1100.0.11
144
+
145
+ ### Patch Changes
146
+
147
+ - @pnpm/bins.linker@1100.0.6
148
+ - @pnpm/workspace.projects-reader@1101.0.4
149
+ - @pnpm/fetching.directory-fetcher@1100.0.9
150
+
151
+ ## 1100.0.10
152
+
153
+ ### Patch Changes
154
+
155
+ - Updated dependencies [b4f8f47]
156
+ - @pnpm/bins.linker@1100.0.5
157
+
158
+ ## 1100.0.9
159
+
160
+ ### Patch Changes
161
+
162
+ - Updated dependencies [b61e268]
163
+ - @pnpm/types@1101.1.0
164
+ - @pnpm/bins.linker@1100.0.4
165
+ - @pnpm/fetching.directory-fetcher@1100.0.8
166
+ - @pnpm/installing.modules-yaml@1100.0.4
167
+ - @pnpm/pkg-manifest.reader@1100.0.3
168
+ - @pnpm/workspace.projects-reader@1101.0.3
169
+
170
+ ## 1100.0.8
171
+
172
+ ### Patch Changes
173
+
174
+ - @pnpm/fetching.directory-fetcher@1100.0.7
175
+
176
+ ## 1100.0.7
177
+
178
+ ### Patch Changes
179
+
180
+ - Updated dependencies [12313f1]
181
+ - @pnpm/installing.modules-yaml@1100.0.3
182
+ - @pnpm/fetching.directory-fetcher@1100.0.6
183
+
184
+ ## 1100.0.6
185
+
186
+ ### Patch Changes
187
+
188
+ - Updated dependencies [184ce26]
189
+ - @pnpm/fetching.directory-fetcher@1100.0.5
190
+ - @pnpm/workspace.projects-reader@1101.0.2
191
+ - @pnpm/installing.modules-yaml@1100.0.2
192
+ - @pnpm/pkg-manifest.reader@1100.0.2
193
+ - @pnpm/bins.linker@1100.0.3
194
+
195
+ ## 1100.0.5
196
+
197
+ ### Patch Changes
198
+
199
+ - @pnpm/workspace.projects-reader@1101.0.1
200
+
201
+ ## 1100.0.4
202
+
203
+ ### Patch Changes
204
+
205
+ - @pnpm/fetching.directory-fetcher@1100.0.4
206
+
207
+ ## 1100.0.3
208
+
209
+ ### Patch Changes
210
+
211
+ - Updated dependencies [e03e8f4]
212
+ - @pnpm/fetching.directory-fetcher@1100.0.3
213
+
214
+ ## 1100.0.2
215
+
216
+ ### Patch Changes
217
+
218
+ - Updated dependencies [cee550a]
219
+ - @pnpm/workspace.projects-reader@1101.0.0
220
+ - @pnpm/bins.linker@1100.0.2
221
+ - @pnpm/fetching.directory-fetcher@1100.0.2
222
+
223
+ ## 1100.0.1
224
+
225
+ ### Patch Changes
226
+
227
+ - Updated dependencies [ff28085]
228
+ - @pnpm/types@1101.0.0
229
+ - @pnpm/bins.linker@1100.0.1
230
+ - @pnpm/fetching.directory-fetcher@1100.0.1
231
+ - @pnpm/installing.modules-yaml@1100.0.1
232
+ - @pnpm/pkg-manifest.reader@1100.0.1
233
+ - @pnpm/workspace.projects-reader@1100.0.1
234
+
235
+ ## 1001.0.0
236
+
237
+ ### Major Changes
238
+
239
+ - 491a84f: This package is now pure ESM.
240
+ - 7d2fd48: Node.js v18, 19, 20, and 21 support discontinued.
241
+
242
+ ### Patch Changes
243
+
244
+ - Updated dependencies [449dacf]
245
+ - Updated dependencies [76718b3]
246
+ - Updated dependencies [a8f016c]
247
+ - Updated dependencies [cc1b8e3]
248
+ - Updated dependencies [3cfffaa]
249
+ - Updated dependencies [05fb1ae]
250
+ - Updated dependencies [491a84f]
251
+ - Updated dependencies [62f760e]
252
+ - Updated dependencies [6e9cad3]
253
+ - Updated dependencies [cb228c9]
254
+ - Updated dependencies [7d2fd48]
255
+ - Updated dependencies [efb48dc]
256
+ - Updated dependencies [4a36b9a]
257
+ - Updated dependencies [cb367b9]
258
+ - Updated dependencies [7b1c189]
259
+ - Updated dependencies [8ffb1a7]
260
+ - Updated dependencies [05fb1ae]
261
+ - Updated dependencies [f40177f]
262
+ - Updated dependencies [71de2b3]
263
+ - Updated dependencies [10bc391]
264
+ - Updated dependencies [831f574]
265
+ - Updated dependencies [2df8b71]
266
+ - Updated dependencies [15549a9]
267
+ - Updated dependencies [cc7c0d2]
268
+ - Updated dependencies [3cfffaa]
269
+ - Updated dependencies [efb48dc]
270
+ - @pnpm/bins.linker@1001.0.0
271
+ - @pnpm/types@1001.0.0
272
+ - @pnpm/installing.modules-yaml@1001.0.0
273
+ - @pnpm/pkg-manifest.reader@1001.0.0
274
+ - @pnpm/fetching.directory-fetcher@1001.0.0
275
+ - @pnpm/workspace.projects-reader@1001.0.0
276
+ - @pnpm/error@1001.0.0
277
+
278
+ ## 1000.0.17
279
+
280
+ ### Patch Changes
281
+
282
+ - @pnpm/workspace.find-packages@1000.0.43
283
+
284
+ ## 1000.0.16
285
+
286
+ ### Patch Changes
287
+
288
+ - Updated dependencies [7c1382f]
289
+ - Updated dependencies [dee39ec]
290
+ - @pnpm/types@1000.9.0
291
+ - @pnpm/directory-fetcher@1000.1.14
292
+ - @pnpm/link-bins@1000.2.6
293
+ - @pnpm/modules-yaml@1000.3.6
294
+ - @pnpm/read-package-json@1000.1.2
295
+ - @pnpm/workspace.find-packages@1000.0.42
296
+
297
+ ## 1000.0.15
298
+
299
+ ### Patch Changes
300
+
301
+ - 6089939: Sync bin links after injected dependencies are updated by build scripts. This ensures that binaries created during build processes are properly linked and accessible to consuming projects [#10057](https://github.com/pnpm/pnpm/issues/10057).
302
+ - Updated dependencies [a8797c4]
303
+ - @pnpm/link-bins@1000.2.5
304
+ - @pnpm/workspace.find-packages@1000.0.41
305
+
306
+ ## 1000.0.14
307
+
308
+ ### Patch Changes
309
+
310
+ - @pnpm/directory-fetcher@1000.1.13
311
+
312
+ ## 1000.0.13
313
+
314
+ ### Patch Changes
315
+
316
+ - @pnpm/error@1000.0.5
317
+ - @pnpm/directory-fetcher@1000.1.12
318
+
319
+ ## 1000.0.12
320
+
321
+ ### Patch Changes
322
+
323
+ - @pnpm/directory-fetcher@1000.1.11
324
+ - @pnpm/modules-yaml@1000.3.5
325
+
326
+ ## 1000.0.11
327
+
328
+ ### Patch Changes
329
+
330
+ - @pnpm/error@1000.0.4
331
+ - @pnpm/directory-fetcher@1000.1.10
332
+
333
+ ## 1000.0.10
334
+
335
+ ### Patch Changes
336
+
337
+ - @pnpm/directory-fetcher@1000.1.9
338
+ - @pnpm/modules-yaml@1000.3.4
339
+ - @pnpm/error@1000.0.3
340
+
341
+ ## 1000.0.9
342
+
343
+ ### Patch Changes
344
+
345
+ - @pnpm/directory-fetcher@1000.1.8
346
+
347
+ ## 1000.0.8
348
+
349
+ ### Patch Changes
350
+
351
+ - 09cf46f: Update `@pnpm/logger` in peer dependencies.
352
+ - Updated dependencies [09cf46f]
353
+ - @pnpm/directory-fetcher@1000.1.7
354
+ - @pnpm/modules-yaml@1000.3.3
355
+
356
+ ## 1000.0.7
357
+
358
+ ### Patch Changes
359
+
360
+ - Updated dependencies [8a9f3a4]
361
+ - @pnpm/logger@1001.0.0
362
+ - @pnpm/directory-fetcher@1000.1.6
363
+ - @pnpm/modules-yaml@1000.3.2
364
+
365
+ ## 1000.0.6
366
+
367
+ ### Patch Changes
368
+
369
+ - @pnpm/directory-fetcher@1000.1.5
370
+
371
+ ## 1000.0.5
372
+
373
+ ### Patch Changes
374
+
375
+ - @pnpm/directory-fetcher@1000.1.4
376
+ - @pnpm/modules-yaml@1000.3.1
377
+
378
+ ## 1000.0.4
379
+
380
+ ### Patch Changes
381
+
382
+ - Updated dependencies [64f6b4f]
383
+ - @pnpm/modules-yaml@1000.3.0
384
+ - @pnpm/directory-fetcher@1000.1.3
385
+
386
+ ## 1000.0.3
387
+
388
+ ### Patch Changes
389
+
390
+ - Updated dependencies [d612dcf]
391
+ - Updated dependencies [d612dcf]
392
+ - @pnpm/modules-yaml@1000.2.0
393
+ - @pnpm/directory-fetcher@1000.1.2
394
+
395
+ ## 1000.0.2
396
+
397
+ ### Patch Changes
398
+
399
+ - 9904675: `@pnpm/logger` should be a peer dependency.
400
+
401
+ ## 1000.0.1
402
+
403
+ ### Patch Changes
404
+
405
+ - @pnpm/directory-fetcher@1000.1.1
406
+ - @pnpm/modules-yaml@1000.1.4
407
+
408
+ ## 1000.0.0
409
+
410
+ ### Major Changes
411
+
412
+ - e32b1a2: Added support for automatically syncing files of injected workspace packages after `pnpm run` [#9081](https://github.com/pnpm/pnpm/issues/9081). Use the `sync-injected-deps-after-scripts` setting to specify which scripts build the workspace package. This tells pnpm when syncing is needed. The setting should be defined in a `.npmrc` file at the root of the workspace. Example:
413
+
414
+ ```ini
415
+ sync-injected-deps-after-scripts[]=compile
416
+ ```
417
+
418
+ - e32b1a2: Initial Release.
419
+
420
+ ### Patch Changes
421
+
422
+ - Updated dependencies [e32b1a2]
423
+ - @pnpm/directory-fetcher@1000.1.0
424
+ - @pnpm/modules-yaml@1000.1.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/workspace.injected-deps-syncer",
3
- "version": "1100.0.22",
3
+ "version": "1100.0.24",
4
4
  "description": "Update all injected replica of a workspace package",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -27,16 +27,16 @@
27
27
  "!*.map"
28
28
  ],
29
29
  "dependencies": {
30
+ "@pnpm/bins.linker": "1100.0.18",
31
+ "@pnpm/error": "1100.0.1",
32
+ "@pnpm/fetching.directory-fetcher": "1100.0.21",
33
+ "@pnpm/installing.modules-yaml": "1100.0.10",
34
+ "@pnpm/pkg-manifest.reader": "1100.0.10",
35
+ "@pnpm/types": "1101.4.0",
30
36
  "@pnpm/util.lex-comparator": "^4.0.1",
37
+ "@pnpm/workspace.projects-reader": "1101.0.15",
31
38
  "@types/normalize-path": "^3.0.2",
32
- "normalize-path": "^3.0.0",
33
- "@pnpm/bins.linker": "1100.0.16",
34
- "@pnpm/error": "1100.0.1",
35
- "@pnpm/installing.modules-yaml": "1100.0.9",
36
- "@pnpm/fetching.directory-fetcher": "1100.0.19",
37
- "@pnpm/types": "1101.3.2",
38
- "@pnpm/workspace.projects-reader": "1101.0.13",
39
- "@pnpm/pkg-manifest.reader": "1100.0.9"
39
+ "normalize-path": "^3.0.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@pnpm/logger": "^1100.0.0"
@@ -44,8 +44,8 @@
44
44
  "devDependencies": {
45
45
  "@jest/globals": "30.4.1",
46
46
  "@pnpm/logger": "1100.0.0",
47
- "@pnpm/prepare": "1100.0.18",
48
- "@pnpm/workspace.injected-deps-syncer": "1100.0.22"
47
+ "@pnpm/prepare": "1100.0.20",
48
+ "@pnpm/workspace.injected-deps-syncer": "1100.0.24"
49
49
  },
50
50
  "engines": {
51
51
  "node": ">=22.13"
@@ -1,66 +0,0 @@
1
- import fs from 'node:fs';
2
- export declare const DIR: unique symbol;
3
- export type File = number;
4
- export type Dir = typeof DIR;
5
- export type Value = File | Dir;
6
- export type InodeMap = Record<string, Value>;
7
- export interface DiffItemBase {
8
- path: string;
9
- oldValue?: Value;
10
- newValue?: Value;
11
- }
12
- export interface AddedItem extends DiffItemBase {
13
- path: string;
14
- oldValue?: undefined;
15
- newValue: Value;
16
- }
17
- export interface RemovedItem extends DiffItemBase {
18
- path: string;
19
- oldValue: Value;
20
- newValue?: undefined;
21
- }
22
- export interface ModifiedItem extends DiffItemBase {
23
- path: string;
24
- oldValue: Value;
25
- newValue: Value;
26
- }
27
- export interface DirDiff {
28
- added: AddedItem[];
29
- removed: RemovedItem[];
30
- modified: ModifiedItem[];
31
- }
32
- /**
33
- * Get the difference between 2 files tree.
34
- *
35
- * The arrays in the resulting object are sorted in such a way that every directory paths are placed before
36
- * the files it contains. This way, it would allow optimization for operations upon this diff.
37
- * Note that when performing removal of removed files according to this diff, the `removed` array should be reversed first.
38
- */
39
- export declare function diffDir(oldIndex: InodeMap, newIndex: InodeMap): DirDiff;
40
- /**
41
- * Apply a patch on a directory.
42
- *
43
- * The {@link optimizedDirPatch} is assumed to be already optimized (i.e. `removed` is already reversed).
44
- */
45
- export declare function applyPatch(optimizedDirPatch: DirDiff, sourceDir: string, targetDir: string): Promise<void>;
46
- export type ExtendFilesMapStats = Pick<fs.Stats, 'ino' | 'isFile' | 'isDirectory'>;
47
- export interface ExtendFilesMapOptions {
48
- /** Map relative path of each file to their real path */
49
- filesMap: Map<string, string>;
50
- /** Map relative path of each file to their stats */
51
- filesStats?: Record<string, ExtendFilesMapStats | null>;
52
- }
53
- /**
54
- * Convert a pair of a files index map, which is a map from relative path of each file to their real paths,
55
- * and an optional file stats map, which is a map from relative path of each file to their stats,
56
- * into an inodes map, which is a map from relative path of every file and directory to their inode type.
57
- */
58
- export declare function extendFilesMap({ filesMap, filesStats }: ExtendFilesMapOptions): Promise<InodeMap>;
59
- export declare class DirPatcher {
60
- private readonly sourceDir;
61
- private readonly targetDir;
62
- private readonly patch;
63
- private constructor();
64
- static fromMultipleTargets(sourceDir: string, targetDirs: string[]): Promise<DirPatcher[]>;
65
- apply(): Promise<void>;
66
- }
package/lib/DirPatcher.js DELETED
@@ -1,141 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import util from 'node:util';
4
- import { PnpmError } from '@pnpm/error';
5
- import { fetchFromDir } from '@pnpm/fetching.directory-fetcher';
6
- export const DIR = Symbol('Path is a directory');
7
- // length comparison should place every directory before the files it contains because
8
- // a directory path is always shorter than any file path it contains
9
- const comparePaths = (a, b) => (a.split(/\\|\//).length - b.split(/\\|\//).length) || a.localeCompare(b);
10
- /**
11
- * Get the difference between 2 files tree.
12
- *
13
- * The arrays in the resulting object are sorted in such a way that every directory paths are placed before
14
- * the files it contains. This way, it would allow optimization for operations upon this diff.
15
- * Note that when performing removal of removed files according to this diff, the `removed` array should be reversed first.
16
- */
17
- export function diffDir(oldIndex, newIndex) {
18
- const oldPaths = Object.keys(oldIndex).sort(comparePaths);
19
- const newPaths = Object.keys(newIndex).sort(comparePaths);
20
- const removed = oldPaths
21
- .filter(path => !(path in newIndex))
22
- .map(path => ({ path, oldValue: oldIndex[path] }));
23
- const added = newPaths
24
- .filter(path => !(path in oldIndex))
25
- .map(path => ({ path, newValue: newIndex[path] }));
26
- const modified = oldPaths
27
- .filter(path => path in newIndex && oldIndex[path] !== newIndex[path])
28
- .map(path => ({ path, oldValue: oldIndex[path], newValue: newIndex[path] }));
29
- return { added, removed, modified };
30
- }
31
- /**
32
- * Apply a patch on a directory.
33
- *
34
- * The {@link optimizedDirPatch} is assumed to be already optimized (i.e. `removed` is already reversed).
35
- */
36
- export async function applyPatch(optimizedDirPatch, sourceDir, targetDir) {
37
- async function addRecursive(sourcePath, targetPath, value) {
38
- if (value === DIR) {
39
- await fs.promises.mkdir(targetPath, { recursive: true });
40
- }
41
- else if (typeof value === 'number') {
42
- fs.mkdirSync(path.dirname(targetPath), { recursive: true });
43
- await fs.promises.link(sourcePath, targetPath);
44
- }
45
- else {
46
- const _ = value; // static type guard
47
- }
48
- }
49
- async function removeRecursive(targetPath) {
50
- try {
51
- await fs.promises.rm(targetPath, { recursive: true, force: true });
52
- }
53
- catch (error) {
54
- if (!util.types.isNativeError(error) || !('code' in error) || (error.code !== 'ENOENT')) {
55
- throw error;
56
- }
57
- }
58
- }
59
- const adding = Promise.all(optimizedDirPatch.added.map(async (item) => {
60
- const sourcePath = path.join(sourceDir, item.path);
61
- const targetPath = path.join(targetDir, item.path);
62
- await addRecursive(sourcePath, targetPath, item.newValue);
63
- }));
64
- const removing = Promise.all(optimizedDirPatch.removed.map(async (item) => {
65
- const targetPath = path.join(targetDir, item.path);
66
- await removeRecursive(targetPath);
67
- }));
68
- const modifying = Promise.all(optimizedDirPatch.modified.map(async (item) => {
69
- const sourcePath = path.join(sourceDir, item.path);
70
- const targetPath = path.join(targetDir, item.path);
71
- if (item.oldValue === item.newValue)
72
- return;
73
- await removeRecursive(targetPath);
74
- await addRecursive(sourcePath, targetPath, item.newValue);
75
- }));
76
- await Promise.all([adding, removing, modifying]);
77
- }
78
- /**
79
- * Convert a pair of a files index map, which is a map from relative path of each file to their real paths,
80
- * and an optional file stats map, which is a map from relative path of each file to their stats,
81
- * into an inodes map, which is a map from relative path of every file and directory to their inode type.
82
- */
83
- export async function extendFilesMap({ filesMap, filesStats }) {
84
- const result = {
85
- '.': DIR,
86
- };
87
- function addInodeAndAncestors(relativePath, value) {
88
- if (relativePath && relativePath !== '.' && !result[relativePath]) {
89
- result[relativePath] = value;
90
- addInodeAndAncestors(path.dirname(relativePath), DIR);
91
- }
92
- }
93
- await Promise.all(Array.from(filesMap.entries()).map(async ([relativePath, realPath]) => {
94
- const stats = filesStats?.[relativePath] ?? await fs.promises.stat(realPath);
95
- if (stats.isFile()) {
96
- addInodeAndAncestors(relativePath, stats.ino);
97
- }
98
- else if (stats.isDirectory()) {
99
- addInodeAndAncestors(relativePath, DIR);
100
- }
101
- else {
102
- throw new PnpmError('UNSUPPORTED_INODE_TYPE', `Filesystem inode at ${realPath} is neither a file, a directory, or a symbolic link`);
103
- }
104
- }));
105
- return result;
106
- }
107
- export class DirPatcher {
108
- sourceDir;
109
- targetDir;
110
- patch;
111
- constructor(patch, sourceDir, targetDir) {
112
- this.patch = patch;
113
- this.sourceDir = sourceDir;
114
- this.targetDir = targetDir;
115
- }
116
- static async fromMultipleTargets(sourceDir, targetDirs) {
117
- const fetchOptions = {
118
- resolveSymlinks: false,
119
- };
120
- async function loadMap(dir) {
121
- const fetchResult = await fetchFromDir(dir, fetchOptions);
122
- return [await extendFilesMap(fetchResult), dir];
123
- }
124
- const [[sourceMap], targetPairs] = await Promise.all([
125
- loadMap(sourceDir),
126
- Promise.all(targetDirs.map(loadMap)),
127
- ]);
128
- return targetPairs.map(([targetMap, targetDir]) => {
129
- const diff = diffDir(targetMap, sourceMap);
130
- // Before reversal, every directory in `diff.removed` are placed before its files.
131
- // After reversal, every file is place before its ancestors,
132
- // leading to children being deleted before parents, optimizing performance.
133
- diff.removed.reverse();
134
- return new this(diff, sourceDir, targetDir);
135
- });
136
- }
137
- async apply() {
138
- await applyPatch(this.patch, this.sourceDir, this.targetDir);
139
- }
140
- }
141
- //# sourceMappingURL=DirPatcher.js.map
package/lib/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export interface SyncInjectedDepsOptions {
2
- pkgName: string | undefined;
3
- pkgRootDir: string;
4
- workspaceDir: string | undefined;
5
- }
6
- export declare function syncInjectedDeps(opts: SyncInjectedDepsOptions): Promise<void>;