isolate-package 1.3.0-rc1 → 1.3.0
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/README.md +65 -1
- package/dist/index.mjs +115 -97
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,38 @@ Isolate a monorepo workspace package so that it can be deployed as a completely
|
|
|
4
4
|
self-contained directory with the sources of all its local dependencies
|
|
5
5
|
included.
|
|
6
6
|
|
|
7
|
+
<!-- TOC -->
|
|
8
|
+
|
|
9
|
+
- [Motivation](#motivation)
|
|
10
|
+
- [Features](#features)
|
|
11
|
+
- [Firebase Deployment Quickstart](#firebase-deployment-quickstart)
|
|
12
|
+
- [Prerequisites](#prerequisites)
|
|
13
|
+
- [Define shared package dependencies in the manifest](#define-shared-package-dependencies-in-the-manifest)
|
|
14
|
+
- [Define "files" and "version" in each manifest](#define-files-and-version-in-each-manifest)
|
|
15
|
+
- [Use a flat structure inside your packages folders](#use-a-flat-structure-inside-your-packages-folders)
|
|
16
|
+
- [Usage](#usage)
|
|
17
|
+
- [Deploying to Firebase](#deploying-to-firebase)
|
|
18
|
+
- [Deploying to Firebase from the root](#deploying-to-firebase-from-the-root)
|
|
19
|
+
- [Configuration Options](#configuration-options)
|
|
20
|
+
- [buildDirName](#builddirname)
|
|
21
|
+
- [excludeLockfile](#excludelockfile)
|
|
22
|
+
- [includeDevDependencies](#includedevdependencies)
|
|
23
|
+
- [isolateDirName](#isolatedirname)
|
|
24
|
+
- [logLevel](#loglevel)
|
|
25
|
+
- [targetPackagePath](#targetpackagepath)
|
|
26
|
+
- [tsconfigPath](#tsconfigpath)
|
|
27
|
+
- [workspacePackages](#workspacepackages)
|
|
28
|
+
- [workspaceRoot](#workspaceroot)
|
|
29
|
+
- [Troubleshooting](#troubleshooting)
|
|
30
|
+
- [Lockfiles](#lockfiles)
|
|
31
|
+
- [NPM](#npm)
|
|
32
|
+
- [PNPM Lockfiles disabled for now](#pnpm-lockfiles-disabled-for-now)
|
|
33
|
+
- [Different Package Managers](#different-package-managers)
|
|
34
|
+
- [Yarn v1 and v3](#yarn-v1-and-v3)
|
|
35
|
+
- [Using the Firebase Functions Emulator](#using-the-firebase-functions-emulator)
|
|
36
|
+
|
|
37
|
+
<!-- /TOC -->
|
|
38
|
+
|
|
7
39
|
## Motivation
|
|
8
40
|
|
|
9
41
|
This solution was developed out of a desire to deploy to
|
|
@@ -152,7 +184,8 @@ You will probably want to add the output directory to your `.gitignore` file.
|
|
|
152
184
|
You can deploy to Firebase from multiple packages in your monorepo, so I advise
|
|
153
185
|
you to co-locate your `firebase.json` file with the source code, and not place
|
|
154
186
|
it in the root of the monorepo. If you do want to keep the firebase config in
|
|
155
|
-
the root,
|
|
187
|
+
the root, read the instructions for [deploying to Firebase from the
|
|
188
|
+
root](#deploying-to-firebase-from-the-root).
|
|
156
189
|
|
|
157
190
|
In order to deploy to Firebase, the `functions.source` setting in
|
|
158
191
|
`firebase.json` needs to point to the isolated output folder, which would be
|
|
@@ -404,3 +437,34 @@ that, because the `.yarnrc` file and `.yarn` folder are located in the root of
|
|
|
404
437
|
your monorepo, and the version is not recorded as part of the lockfile. Therefor
|
|
405
438
|
the Firebase deploy cloud pipeline will use Yarn 1 to install your dependencies.
|
|
406
439
|
I don't think that is an issue but it might be good to know.
|
|
440
|
+
|
|
441
|
+
## Using the Firebase Functions Emulator
|
|
442
|
+
|
|
443
|
+
The Firebase functions emulator runs on the code that firebase.json `source`
|
|
444
|
+
points to. Unfortunately, this is the same location as is used for uploading the
|
|
445
|
+
code for deployment, which means the emulator is forced to use the isolated
|
|
446
|
+
output.
|
|
447
|
+
|
|
448
|
+
As a result, any changes to your code first need to go through the isolate
|
|
449
|
+
process in order to be picked up by the emulator. In other words, changes do not
|
|
450
|
+
propagate automatically while the emulator is running.
|
|
451
|
+
|
|
452
|
+
The strategy I use at the moment is to create a "emulate" script in your
|
|
453
|
+
manifest which does the same as the Firebase predeploy, and then starts the
|
|
454
|
+
emulator. For example:
|
|
455
|
+
|
|
456
|
+
`turbo build && isolate && firebase emulators:start --only functions`
|
|
457
|
+
|
|
458
|
+
But you will still have to stop and restart the emulator on every code change,
|
|
459
|
+
which is a bummer.
|
|
460
|
+
|
|
461
|
+
The real solution to this, I think, involves changing the firebase-tools CLI. I
|
|
462
|
+
see two options:
|
|
463
|
+
|
|
464
|
+
1. Give the firebase config an extra field to distinguish between code that is
|
|
465
|
+
used by the emulator and code that is bundled for deployment.
|
|
466
|
+
2. Integrate the isolate process into the firebase-tools deploy command, so it
|
|
467
|
+
is only used as part of the deployment and the `source` property can still
|
|
468
|
+
point to the original code.
|
|
469
|
+
|
|
470
|
+
I plan to take this up in the near future.
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import
|
|
4
|
+
import fs14 from "fs-extra";
|
|
5
5
|
import assert5 from "node:assert";
|
|
6
|
-
import
|
|
6
|
+
import path14 from "node:path";
|
|
7
7
|
import sourceMaps from "source-map-support";
|
|
8
8
|
|
|
9
9
|
// src/helpers/adapt-manifest-files.ts
|
|
@@ -35,6 +35,12 @@ function filterObjectUndefined(object) {
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// src/utils/get-dirname.ts
|
|
39
|
+
import { fileURLToPath } from "url";
|
|
40
|
+
function getDirname(importMetaUrl) {
|
|
41
|
+
return fileURLToPath(new URL(".", importMetaUrl));
|
|
42
|
+
}
|
|
43
|
+
|
|
38
44
|
// src/utils/get-error-message.ts
|
|
39
45
|
function getErrorMessage(error) {
|
|
40
46
|
return toErrorWithMessage(error).message;
|
|
@@ -53,12 +59,12 @@ function toErrorWithMessage(maybeError) {
|
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
// src/utils/get-relative-path.ts
|
|
56
|
-
function getRootRelativePath(
|
|
57
|
-
const strippedPath =
|
|
62
|
+
function getRootRelativePath(path15, rootPath) {
|
|
63
|
+
const strippedPath = path15.replace(rootPath, "");
|
|
58
64
|
return strippedPath.startsWith("/") ? `(root)${strippedPath}` : `(root)/${strippedPath}`;
|
|
59
65
|
}
|
|
60
|
-
function getIsolateRelativePath(
|
|
61
|
-
const strippedPath =
|
|
66
|
+
function getIsolateRelativePath(path15, isolatePath) {
|
|
67
|
+
const strippedPath = path15.replace(isolatePath, "");
|
|
62
68
|
return strippedPath.startsWith("/") ? `(isolate)${strippedPath}` : `(isolate)/${strippedPath}`;
|
|
63
69
|
}
|
|
64
70
|
|
|
@@ -120,66 +126,61 @@ function createLogger(logLevel) {
|
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
// src/utils/pack.ts
|
|
129
|
+
import fs3 from "fs-extra";
|
|
123
130
|
import { exec } from "node:child_process";
|
|
124
131
|
import path2 from "node:path";
|
|
125
|
-
async function pack(srcDir,
|
|
132
|
+
async function pack(srcDir, dstDir, usePnpmPack = false) {
|
|
126
133
|
const log2 = createLogger(getConfig().logLevel);
|
|
127
|
-
const
|
|
134
|
+
const previousCwd = process.cwd();
|
|
128
135
|
process.chdir(srcDir);
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
(err
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
resolve(stdout2);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
const packedFileName = stdout.trim();
|
|
160
|
-
log2.debug("Packed", packedFileName);
|
|
161
|
-
process.chdir(cwd);
|
|
162
|
-
return path2.join(destDir, packedFileName);
|
|
163
|
-
}
|
|
136
|
+
const stdout = usePnpmPack ? await new Promise((resolve, reject) => {
|
|
137
|
+
exec(
|
|
138
|
+
`pnpm pack --pack-destination ${dstDir}`,
|
|
139
|
+
(err, stdout2, stderr) => {
|
|
140
|
+
if (err) {
|
|
141
|
+
log2.error(stderr);
|
|
142
|
+
return reject(err);
|
|
143
|
+
}
|
|
144
|
+
resolve(stdout2);
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}) : await new Promise((resolve, reject) => {
|
|
148
|
+
exec(`npm pack --pack-destination ${dstDir}`, (err, stdout2) => {
|
|
149
|
+
if (err) {
|
|
150
|
+
return reject(err);
|
|
151
|
+
}
|
|
152
|
+
resolve(stdout2);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
const fileName = path2.basename(stdout.trim());
|
|
156
|
+
const filePath = path2.join(dstDir, fileName);
|
|
157
|
+
if (!fs3.existsSync(filePath)) {
|
|
158
|
+
log2.error(
|
|
159
|
+
`The response from pack could not be resolved to an existing file: ${filePath}`
|
|
160
|
+
);
|
|
161
|
+
} else {
|
|
162
|
+
log2.debug(`Packed (temp)/${fileName}`);
|
|
164
163
|
}
|
|
164
|
+
process.chdir(previousCwd);
|
|
165
|
+
return filePath;
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
// src/utils/unpack.ts
|
|
168
|
-
import
|
|
169
|
+
import fs4 from "fs-extra";
|
|
169
170
|
import tar from "tar-fs";
|
|
170
171
|
import { createGunzip } from "zlib";
|
|
171
172
|
async function unpack(filePath, unpackDir) {
|
|
172
173
|
await new Promise((resolve, reject) => {
|
|
173
|
-
|
|
174
|
+
fs4.createReadStream(filePath).pipe(createGunzip()).pipe(tar.extract(unpackDir)).on("finish", () => resolve()).on("error", (err) => reject(err));
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
// src/utils/yaml.ts
|
|
178
|
-
import
|
|
179
|
+
import fs5 from "fs-extra";
|
|
179
180
|
import yaml from "yaml";
|
|
180
181
|
function readTypedYamlSync(filePath) {
|
|
181
182
|
try {
|
|
182
|
-
const rawContent =
|
|
183
|
+
const rawContent = fs5.readFileSync(filePath, "utf-8");
|
|
183
184
|
const data = yaml.parse(rawContent);
|
|
184
185
|
return data;
|
|
185
186
|
} catch (err) {
|
|
@@ -189,7 +190,7 @@ function readTypedYamlSync(filePath) {
|
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
function writeTypedYamlSync(filePath, content) {
|
|
192
|
-
|
|
193
|
+
fs5.writeFileSync(filePath, yaml.stringify(content), "utf-8");
|
|
193
194
|
}
|
|
194
195
|
|
|
195
196
|
// src/helpers/adapt-manifest-workspace-deps.ts
|
|
@@ -216,7 +217,7 @@ function adaptManifestWorkspaceDeps({
|
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
// src/helpers/adapt-target-package-manifest.ts
|
|
219
|
-
import
|
|
220
|
+
import fs6 from "fs-extra";
|
|
220
221
|
import path3 from "node:path";
|
|
221
222
|
async function adaptTargetPackageManifest(manifest, packagesRegistry, isolateDir) {
|
|
222
223
|
const outputManifest = adaptManifestWorkspaceDeps(
|
|
@@ -226,14 +227,14 @@ async function adaptTargetPackageManifest(manifest, packagesRegistry, isolateDir
|
|
|
226
227
|
},
|
|
227
228
|
{ includeDevDependencies: getConfig().includeDevDependencies }
|
|
228
229
|
);
|
|
229
|
-
await
|
|
230
|
+
await fs6.writeFile(
|
|
230
231
|
path3.join(isolateDir, "package.json"),
|
|
231
232
|
JSON.stringify(outputManifest, null, 2)
|
|
232
233
|
);
|
|
233
234
|
}
|
|
234
235
|
|
|
235
236
|
// src/helpers/config.ts
|
|
236
|
-
import
|
|
237
|
+
import fs7 from "fs-extra";
|
|
237
238
|
import { isEmpty } from "lodash-es";
|
|
238
239
|
import path4 from "node:path";
|
|
239
240
|
var configDefaults = {
|
|
@@ -245,7 +246,8 @@ var configDefaults = {
|
|
|
245
246
|
tsconfigPath: "./tsconfig.json",
|
|
246
247
|
workspacePackages: void 0,
|
|
247
248
|
workspaceRoot: "../..",
|
|
248
|
-
excludeLockfile: false
|
|
249
|
+
excludeLockfile: false,
|
|
250
|
+
avoidPnpmPack: false
|
|
249
251
|
};
|
|
250
252
|
var __config;
|
|
251
253
|
var validConfigKeys = Object.keys(configDefaults);
|
|
@@ -259,7 +261,7 @@ function getConfig() {
|
|
|
259
261
|
);
|
|
260
262
|
const configFilePath = path4.join(process.cwd(), CONFIG_FILE_NAME);
|
|
261
263
|
log2.debug(`Attempting to load config from ${configFilePath}`);
|
|
262
|
-
const configFromFile =
|
|
264
|
+
const configFromFile = fs7.existsSync(configFilePath) ? readTypedJsonSync(configFilePath) : {};
|
|
263
265
|
const foreignKeys = Object.keys(configFromFile).filter(
|
|
264
266
|
(key) => !validConfigKeys.includes(key)
|
|
265
267
|
);
|
|
@@ -277,7 +279,7 @@ function getConfig() {
|
|
|
277
279
|
}
|
|
278
280
|
|
|
279
281
|
// src/helpers/create-packages-registry.ts
|
|
280
|
-
import
|
|
282
|
+
import fs10 from "fs-extra";
|
|
281
283
|
import { globSync } from "glob";
|
|
282
284
|
import { set } from "lodash-es";
|
|
283
285
|
import path8 from "node:path";
|
|
@@ -287,13 +289,13 @@ import assert3 from "node:assert";
|
|
|
287
289
|
import path7 from "node:path";
|
|
288
290
|
|
|
289
291
|
// src/helpers/detect-package-manager.ts
|
|
290
|
-
import
|
|
292
|
+
import fs9 from "fs-extra";
|
|
291
293
|
import assert2 from "node:assert";
|
|
292
294
|
import { execSync } from "node:child_process";
|
|
293
295
|
import path6 from "node:path";
|
|
294
296
|
|
|
295
297
|
// src/helpers/process-lockfile.ts
|
|
296
|
-
import
|
|
298
|
+
import fs8 from "fs-extra";
|
|
297
299
|
import assert from "node:assert";
|
|
298
300
|
import path5 from "node:path";
|
|
299
301
|
function getLockfileFileName(name) {
|
|
@@ -325,22 +327,17 @@ function processLockfile({
|
|
|
325
327
|
"npm-shrinkwrap.json"
|
|
326
328
|
);
|
|
327
329
|
const shrinkwrapDstPath = path5.join(isolateDir, "npm-shrinkwrap.json");
|
|
328
|
-
if (
|
|
329
|
-
|
|
330
|
+
if (fs8.existsSync(shrinkwrapSrcPath)) {
|
|
331
|
+
fs8.copyFileSync(shrinkwrapSrcPath, shrinkwrapDstPath);
|
|
330
332
|
log2.debug("Copied shrinkwrap to", shrinkwrapDstPath);
|
|
331
333
|
} else {
|
|
332
|
-
|
|
334
|
+
fs8.copyFileSync(lockfileSrcPath, lockfileDstPath);
|
|
333
335
|
log2.debug("Copied lockfile to", lockfileDstPath);
|
|
334
336
|
}
|
|
335
|
-
const npmrcPath = path5.join(workspaceRootDir, ".npmrc");
|
|
336
|
-
if (fs7.existsSync(npmrcPath)) {
|
|
337
|
-
fs7.copyFileSync(npmrcPath, path5.join(isolateDir, ".npmrc"));
|
|
338
|
-
log2.debug("Copied .npmrc file to the isolate output");
|
|
339
|
-
}
|
|
340
337
|
return;
|
|
341
338
|
}
|
|
342
339
|
case "yarn": {
|
|
343
|
-
|
|
340
|
+
fs8.copyFileSync(lockfileSrcPath, lockfileDstPath);
|
|
344
341
|
log2.debug("Copied lockfile to", lockfileDstPath);
|
|
345
342
|
return;
|
|
346
343
|
}
|
|
@@ -372,11 +369,11 @@ function detectPackageManager(workspaceRoot) {
|
|
|
372
369
|
function inferFromFiles(workspaceRoot) {
|
|
373
370
|
for (const name of supportedPackageManagerNames) {
|
|
374
371
|
const lockfileName = getLockfileFileName(name);
|
|
375
|
-
if (
|
|
372
|
+
if (fs9.existsSync(path6.join(workspaceRoot, lockfileName))) {
|
|
376
373
|
return { name, version: getVersion(name) };
|
|
377
374
|
}
|
|
378
375
|
}
|
|
379
|
-
if (
|
|
376
|
+
if (fs9.existsSync(path6.join(workspaceRoot, "npm-shrinkwrap.json"))) {
|
|
380
377
|
return { name: "npm", version: getVersion("npm") };
|
|
381
378
|
}
|
|
382
379
|
throw new Error(`Failed to detect package manager`);
|
|
@@ -445,11 +442,11 @@ async function createPackagesRegistry(workspaceRootDir, workspacePackagesOverrid
|
|
|
445
442
|
const packagesGlobs = workspacePackagesOverride ?? findPackagesGlobs(workspaceRootDir);
|
|
446
443
|
const cwd = process.cwd();
|
|
447
444
|
process.chdir(workspaceRootDir);
|
|
448
|
-
const allPackages = packagesGlobs.flatMap((glob) => globSync(glob)).filter((dir) =>
|
|
445
|
+
const allPackages = packagesGlobs.flatMap((glob) => globSync(glob)).filter((dir) => fs10.lstatSync(dir).isDirectory());
|
|
449
446
|
const registry = (await Promise.all(
|
|
450
447
|
allPackages.map(async (rootRelativeDir) => {
|
|
451
448
|
const manifestPath = path8.join(rootRelativeDir, "package.json");
|
|
452
|
-
if (!
|
|
449
|
+
if (!fs10.existsSync(manifestPath)) {
|
|
453
450
|
log2.warn(
|
|
454
451
|
`Ignoring directory ./${rootRelativeDir} because it does not contain a package.json file`
|
|
455
452
|
);
|
|
@@ -475,7 +472,7 @@ async function createPackagesRegistry(workspaceRootDir, workspacePackagesOverrid
|
|
|
475
472
|
}
|
|
476
473
|
|
|
477
474
|
// src/helpers/get-build-output-dir.ts
|
|
478
|
-
import
|
|
475
|
+
import fs11 from "fs-extra";
|
|
479
476
|
import path9 from "node:path";
|
|
480
477
|
import outdent from "outdent";
|
|
481
478
|
async function getBuildOutputDir(targetPackageDir) {
|
|
@@ -486,8 +483,8 @@ async function getBuildOutputDir(targetPackageDir) {
|
|
|
486
483
|
return path9.join(targetPackageDir, config2.buildDirName);
|
|
487
484
|
}
|
|
488
485
|
const tsconfigPath = path9.join(targetPackageDir, config2.tsconfigPath);
|
|
489
|
-
|
|
490
|
-
|
|
486
|
+
if (fs11.existsSync(tsconfigPath)) {
|
|
487
|
+
log2.debug("Found tsconfig at:", config2.tsconfigPath);
|
|
491
488
|
const tsconfig = await readTypedJson(tsconfigPath);
|
|
492
489
|
const outDir = tsconfig.compilerOptions?.outDir;
|
|
493
490
|
if (outDir) {
|
|
@@ -498,6 +495,7 @@ async function getBuildOutputDir(targetPackageDir) {
|
|
|
498
495
|
`);
|
|
499
496
|
}
|
|
500
497
|
} else {
|
|
498
|
+
log2.warn("Failed to find tsconfig at:", tsconfigPath);
|
|
501
499
|
throw new Error(outdent`
|
|
502
500
|
Failed to infer the build output directory from either the isolate config buildDirName or a Typescript config file. See the documentation on how to configure one of these options.
|
|
503
501
|
`);
|
|
@@ -546,15 +544,25 @@ async function packDependencies({
|
|
|
546
544
|
const config2 = getConfig();
|
|
547
545
|
const log2 = createLogger(config2.logLevel);
|
|
548
546
|
const packedFileByName = {};
|
|
547
|
+
const { name, version } = usePackageManager();
|
|
548
|
+
const versionMajor = parseInt(version.split(".")[0], 10);
|
|
549
|
+
const usePnpmPack = !config2.avoidPnpmPack && name === "pnpm" && versionMajor >= 8;
|
|
550
|
+
if (usePnpmPack) {
|
|
551
|
+
log2.debug("Using PNPM pack instead of NPM pack");
|
|
552
|
+
}
|
|
549
553
|
for (const dependency of localDependencies) {
|
|
550
554
|
const def = packagesRegistry[dependency];
|
|
551
555
|
assert4(dependency, `Failed to find package definition for ${dependency}`);
|
|
552
|
-
const { name } = def.manifest;
|
|
553
|
-
if (packedFileByName[
|
|
554
|
-
log2.debug(`Skipping ${
|
|
556
|
+
const { name: name2 } = def.manifest;
|
|
557
|
+
if (packedFileByName[name2]) {
|
|
558
|
+
log2.debug(`Skipping ${name2} because it has already been packed`);
|
|
555
559
|
continue;
|
|
556
560
|
}
|
|
557
|
-
packedFileByName[
|
|
561
|
+
packedFileByName[name2] = await pack(
|
|
562
|
+
def.absoluteDir,
|
|
563
|
+
packDestinationDir,
|
|
564
|
+
usePnpmPack
|
|
565
|
+
);
|
|
558
566
|
}
|
|
559
567
|
return packedFileByName;
|
|
560
568
|
}
|
|
@@ -580,7 +588,7 @@ function patchWorkspaceEntries(dependencies, packagesRegistry, parentRootRelativ
|
|
|
580
588
|
}
|
|
581
589
|
|
|
582
590
|
// src/helpers/process-build-output-files.ts
|
|
583
|
-
import
|
|
591
|
+
import fs12 from "fs-extra";
|
|
584
592
|
import path12 from "node:path";
|
|
585
593
|
var TIMEOUT_MS = 5e3;
|
|
586
594
|
async function processBuildOutputFiles({
|
|
@@ -593,7 +601,7 @@ async function processBuildOutputFiles({
|
|
|
593
601
|
const unpackDir = path12.join(tmpDir, "target");
|
|
594
602
|
const now = Date.now();
|
|
595
603
|
let isWaitingYet = false;
|
|
596
|
-
while (!
|
|
604
|
+
while (!fs12.existsSync(packedFilePath) && Date.now() - now < TIMEOUT_MS) {
|
|
597
605
|
if (!isWaitingYet) {
|
|
598
606
|
log2.debug(`Waiting for ${packedFilePath} to become available...`);
|
|
599
607
|
}
|
|
@@ -601,23 +609,23 @@ async function processBuildOutputFiles({
|
|
|
601
609
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
602
610
|
}
|
|
603
611
|
await unpack(packedFilePath, unpackDir);
|
|
604
|
-
await
|
|
612
|
+
await fs12.copy(path12.join(unpackDir, "package"), isolateDir);
|
|
605
613
|
}
|
|
606
614
|
|
|
607
615
|
// src/helpers/unpack-dependencies.ts
|
|
608
|
-
import
|
|
609
|
-
import { join } from "node:path";
|
|
616
|
+
import fs13 from "fs-extra";
|
|
617
|
+
import path13, { join } from "node:path";
|
|
610
618
|
async function unpackDependencies(packedFilesByName, packagesRegistry, tmpDir, isolateDir) {
|
|
611
619
|
const log2 = createLogger(getConfig().logLevel);
|
|
612
620
|
await Promise.all(
|
|
613
621
|
Object.entries(packedFilesByName).map(async ([packageName, filePath]) => {
|
|
614
622
|
const dir = packagesRegistry[packageName].rootRelativeDir;
|
|
615
623
|
const unpackDir = join(tmpDir, dir);
|
|
616
|
-
log2.debug("Unpacking", filePath);
|
|
624
|
+
log2.debug("Unpacking", `(temp)/${path13.basename(filePath)}`);
|
|
617
625
|
await unpack(filePath, unpackDir);
|
|
618
626
|
const destinationDir = join(isolateDir, dir);
|
|
619
|
-
await
|
|
620
|
-
await
|
|
627
|
+
await fs13.ensureDir(destinationDir);
|
|
628
|
+
await fs13.move(join(unpackDir, "package"), destinationDir, {
|
|
621
629
|
overwrite: true
|
|
622
630
|
});
|
|
623
631
|
log2.debug(
|
|
@@ -635,32 +643,37 @@ var config = getConfig();
|
|
|
635
643
|
var log = createLogger(config.logLevel);
|
|
636
644
|
sourceMaps.install();
|
|
637
645
|
async function start() {
|
|
638
|
-
const
|
|
639
|
-
const
|
|
646
|
+
const __dirname = getDirname(import.meta.url);
|
|
647
|
+
const thisPackageManifest = await readTypedJson(
|
|
648
|
+
path14.join(path14.join(__dirname, "..", "package.json"))
|
|
649
|
+
);
|
|
650
|
+
log.debug("Running isolate-package version", thisPackageManifest.version);
|
|
651
|
+
const targetPackageDir = config.targetPackagePath ? path14.join(process.cwd(), config.targetPackagePath) : process.cwd();
|
|
652
|
+
const workspaceRootDir = config.targetPackagePath ? process.cwd() : path14.join(targetPackageDir, config.workspaceRoot);
|
|
640
653
|
const buildOutputDir = await getBuildOutputDir(targetPackageDir);
|
|
641
654
|
assert5(
|
|
642
|
-
|
|
655
|
+
fs14.existsSync(buildOutputDir),
|
|
643
656
|
`Failed to find build output path at ${buildOutputDir}. Please make sure you build the source before isolating it.`
|
|
644
657
|
);
|
|
645
|
-
log.debug("Workspace root", workspaceRootDir);
|
|
658
|
+
log.debug("Workspace root resolved to", workspaceRootDir);
|
|
646
659
|
log.debug(
|
|
647
660
|
"Isolate target package",
|
|
648
661
|
getRootRelativePath(targetPackageDir, workspaceRootDir)
|
|
649
662
|
);
|
|
650
|
-
const isolateDir =
|
|
663
|
+
const isolateDir = path14.join(targetPackageDir, config.isolateDirName);
|
|
651
664
|
log.debug(
|
|
652
665
|
"Isolate output directory",
|
|
653
666
|
getRootRelativePath(isolateDir, workspaceRootDir)
|
|
654
667
|
);
|
|
655
|
-
if (
|
|
656
|
-
await
|
|
668
|
+
if (fs14.existsSync(isolateDir)) {
|
|
669
|
+
await fs14.remove(isolateDir);
|
|
657
670
|
log.debug("Cleaned the existing isolate output directory");
|
|
658
671
|
}
|
|
659
|
-
await
|
|
660
|
-
const tmpDir =
|
|
661
|
-
await
|
|
672
|
+
await fs14.ensureDir(isolateDir);
|
|
673
|
+
const tmpDir = path14.join(isolateDir, "__tmp");
|
|
674
|
+
await fs14.ensureDir(tmpDir);
|
|
662
675
|
const targetPackageManifest = await readTypedJson(
|
|
663
|
-
|
|
676
|
+
path14.join(targetPackageDir, "package.json")
|
|
664
677
|
);
|
|
665
678
|
const packageManager2 = detectPackageManager(workspaceRootDir);
|
|
666
679
|
log.debug(
|
|
@@ -714,11 +727,16 @@ async function start() {
|
|
|
714
727
|
packagesRegistry
|
|
715
728
|
});
|
|
716
729
|
}
|
|
730
|
+
const npmrcPath = path14.join(workspaceRootDir, ".npmrc");
|
|
731
|
+
if (fs14.existsSync(npmrcPath)) {
|
|
732
|
+
fs14.copyFileSync(npmrcPath, path14.join(isolateDir, ".npmrc"));
|
|
733
|
+
log.debug("Copied .npmrc file to the isolate output");
|
|
734
|
+
}
|
|
717
735
|
log.debug(
|
|
718
|
-
"Deleting
|
|
736
|
+
"Deleting temp directory",
|
|
719
737
|
getRootRelativePath(tmpDir, workspaceRootDir)
|
|
720
738
|
);
|
|
721
|
-
await
|
|
739
|
+
await fs14.remove(tmpDir);
|
|
722
740
|
log.info("Isolate completed at", isolateDir);
|
|
723
741
|
}
|
|
724
742
|
start().catch((err) => {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/helpers/adapt-manifest-files.ts","../src/helpers/adapt-manifest-workspace-deps.ts","../src/utils/filter-object-undefined.ts","../src/utils/get-error-message.ts","../src/utils/get-relative-path.ts","../src/utils/inspect-value.ts","../src/utils/json.ts","../src/utils/logger.ts","../src/utils/pack.ts","../src/utils/unpack.ts","../src/utils/yaml.ts","../src/helpers/adapt-target-package-manifest.ts","../src/helpers/config.ts","../src/helpers/create-packages-registry.ts","../src/helpers/find-packages-globs.ts","../src/helpers/detect-package-manager.ts","../src/helpers/process-lockfile.ts","../src/helpers/get-build-output-dir.ts","../src/helpers/list-local-dependencies.ts","../src/helpers/manifest.ts","../src/helpers/pack-dependencies.ts","../src/helpers/patch-workspace-entries.ts","../src/helpers/process-build-output-files.ts","../src/helpers/unpack-dependencies.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * For PNPM the hashbang at the top of the script was not required, but Yarn 3\n * did not seem to execute without it.\n */\n\n/**\n * A word about used terminology:\n *\n * The various package managers, while being very similar, seem to use a\n * different definition for the term \"workspace\". If you want to read the code\n * it might be good to know that I consider the workspace to be the monorepo\n * itself, in other words, the overall structure that holds all the packages.\n */\nimport fs from \"fs-extra\";\nimport assert from \"node:assert\";\nimport path from \"node:path\";\nimport sourceMaps from \"source-map-support\";\nimport {\n PackageManifest,\n adaptManifestFiles,\n adaptTargetPackageManifest,\n createPackagesRegistry,\n detectPackageManager,\n getBuildOutputDir,\n getConfig,\n listLocalDependencies,\n packDependencies,\n processBuildOutputFiles,\n processLockfile,\n unpackDependencies,\n} from \"~/helpers\";\nimport { createLogger, getRootRelativePath, readTypedJson } from \"~/utils\";\n\nconst config = getConfig();\nconst log = createLogger(config.logLevel);\n\nsourceMaps.install();\n\nasync function start() {\n /**\n * If a targetPackagePath is set, we assume the configuration lives in the\n * root of the workspace. If targetPackagePath is undefined (the default), we\n * assume that the configuration lives in the target package directory.\n */\n const targetPackageDir = config.targetPackagePath\n ? path.join(process.cwd(), config.targetPackagePath)\n : process.cwd();\n\n /**\n * We want a trailing slash here. Functionally it doesn't matter, but it makes\n * the relative paths more correct in the debug output.\n */\n const workspaceRootDir = config.targetPackagePath\n ? process.cwd()\n : path.join(targetPackageDir, config.workspaceRoot);\n\n const buildOutputDir = await getBuildOutputDir(targetPackageDir);\n\n assert(\n fs.existsSync(buildOutputDir),\n `Failed to find build output path at ${buildOutputDir}. Please make sure you build the source before isolating it.`\n );\n\n log.debug(\"Workspace root\", workspaceRootDir);\n log.debug(\n \"Isolate target package\",\n getRootRelativePath(targetPackageDir, workspaceRootDir)\n );\n\n const isolateDir = path.join(targetPackageDir, config.isolateDirName);\n\n log.debug(\n \"Isolate output directory\",\n getRootRelativePath(isolateDir, workspaceRootDir)\n );\n\n if (fs.existsSync(isolateDir)) {\n await fs.remove(isolateDir);\n log.debug(\"Cleaned the existing isolate output directory\");\n }\n\n await fs.ensureDir(isolateDir);\n\n const tmpDir = path.join(isolateDir, \"__tmp\");\n await fs.ensureDir(tmpDir);\n\n const targetPackageManifest = await readTypedJson<PackageManifest>(\n path.join(targetPackageDir, \"package.json\")\n );\n\n const packageManager = detectPackageManager(workspaceRootDir);\n\n log.debug(\n \"Detected package manager\",\n packageManager.name,\n packageManager.version\n );\n\n /**\n * Disable lock files for PNPM because they are not yet supported.\n */\n if (packageManager.name === \"pnpm\") {\n config.excludeLockfile = true;\n }\n\n /**\n * Build a packages registry so we can find the workspace packages by name and\n * have access to their manifest files and relative paths.\n */\n const packagesRegistry = await createPackagesRegistry(\n workspaceRootDir,\n config.workspacePackages\n );\n\n const localDependencies = listLocalDependencies(\n targetPackageManifest,\n packagesRegistry,\n {\n includeDevDependencies: config.includeDevDependencies,\n }\n );\n\n const packedFilesByName = await packDependencies({\n localDependencies,\n packagesRegistry,\n packDestinationDir: tmpDir,\n });\n\n await unpackDependencies(\n packedFilesByName,\n packagesRegistry,\n tmpDir,\n isolateDir\n );\n\n /**\n * Adapt the manifest files for all the unpacked local dependencies\n */\n await adaptManifestFiles(localDependencies, packagesRegistry, isolateDir);\n\n /**\n * Pack the target package directory, and unpack it in the isolate location\n */\n await processBuildOutputFiles({\n targetPackageDir,\n tmpDir,\n isolateDir,\n });\n\n /**\n * Copy the target manifest file to the isolate location and adapt its\n * workspace dependencies to point to the isolated packages.\n */\n await adaptTargetPackageManifest(\n targetPackageManifest,\n packagesRegistry,\n isolateDir\n );\n\n if (config.excludeLockfile) {\n log.warn(\"Excluding the lockfile from the isolate output\");\n } else {\n /**\n * Copy and adapt the lockfile\n */\n await processLockfile({\n workspaceRootDir,\n targetPackageName: targetPackageManifest.name,\n isolateDir,\n packagesRegistry,\n });\n }\n\n /**\n * Clean up. Only so this in the happy path, so we can look at the temp folder\n * when thing go wrong.\n */\n log.debug(\n \"Deleting temporary directory\",\n getRootRelativePath(tmpDir, workspaceRootDir)\n );\n await fs.remove(tmpDir);\n\n log.info(\"Isolate completed at\", isolateDir);\n}\n\nstart().catch((err) => {\n if (err instanceof Error) {\n log.error(err.stack);\n process.exit(1);\n } else {\n console.error(err);\n }\n});\n\nprocess.on(\"unhandledRejection\", log.error);\n","import fs from \"fs-extra\";\nimport path from \"node:path\";\nimport {\n PackagesRegistry,\n adaptManifestWorkspaceDeps,\n getConfig,\n} from \"~/helpers\";\nimport { createLogger } from \"~/utils\";\n\nexport async function adaptManifestFiles(\n localDependencies: string[],\n packagesRegistry: PackagesRegistry,\n isolateDir: string\n) {\n await Promise.all(\n localDependencies.map(async (packageName) => {\n const { manifest, rootRelativeDir } = packagesRegistry[packageName];\n\n const outputManifest = adaptManifestWorkspaceDeps(\n { manifest, packagesRegistry, parentRootRelativeDir: rootRelativeDir },\n { includeDevDependencies: getConfig().includeDevDependencies }\n );\n\n await fs.writeFile(\n path.join(isolateDir, rootRelativeDir, \"package.json\"),\n JSON.stringify(outputManifest, null, 2)\n );\n })\n );\n}\n","import { omit } from \"lodash-es\";\nimport { filterObjectUndefined } from \"~/utils\";\nimport { PackageManifest, PackagesRegistry, patchWorkspaceEntries } from \".\";\n\nexport function adaptManifestWorkspaceDeps(\n {\n manifest,\n packagesRegistry,\n parentRootRelativeDir,\n }: {\n manifest: PackageManifest;\n packagesRegistry: PackagesRegistry;\n parentRootRelativeDir?: string;\n },\n opts: { includeDevDependencies?: boolean } = {}\n): PackageManifest {\n return Object.assign(\n omit(manifest, [\"scripts\", \"devDependencies\"]),\n filterObjectUndefined({\n dependencies: manifest.dependencies\n ? patchWorkspaceEntries(\n manifest.dependencies,\n packagesRegistry,\n parentRootRelativeDir\n )\n : undefined,\n devDependencies:\n opts.includeDevDependencies && manifest.devDependencies\n ? patchWorkspaceEntries(\n manifest.devDependencies,\n packagesRegistry,\n parentRootRelativeDir\n )\n : undefined,\n })\n );\n}\n","export function filterObjectUndefined(object: Record<string, unknown>) {\n return Object.fromEntries(\n Object.entries(object).filter(([_, value]) => value !== undefined)\n );\n}\n","type ErrorWithMessage = {\n message: string;\n};\n\nexport function getErrorMessage(error: unknown) {\n return toErrorWithMessage(error).message;\n}\n\nfunction isErrorWithMessage(error: unknown): error is ErrorWithMessage {\n return typeof error === \"object\" && error !== null && \"message\" in error;\n}\n\nfunction toErrorWithMessage(maybeError: unknown): ErrorWithMessage {\n if (isErrorWithMessage(maybeError)) return maybeError;\n\n try {\n return new Error(JSON.stringify(maybeError));\n } catch {\n /**\n * Fallback in case there’s an error stringifying the maybeError\n * like with circular references.\n */\n return new Error(String(maybeError));\n }\n}\n","export function getRootRelativePath(path: string, rootPath: string) {\n const strippedPath = path.replace(rootPath, \"\");\n\n return strippedPath.startsWith(\"/\")\n ? `(root)${strippedPath}`\n : `(root)/${strippedPath}`;\n}\n\nexport function getIsolateRelativePath(path: string, isolatePath: string) {\n const strippedPath = path.replace(isolatePath, \"\");\n\n return strippedPath.startsWith(\"/\")\n ? `(isolate)${strippedPath}`\n : `(isolate)/${strippedPath}`;\n}\n","import { inspect } from \"node:util\";\nimport { JsonValue } from \"type-fest\";\n\nexport function inspectValue(value: JsonValue) {\n return inspect(value, false, 4, true);\n}\n","import fs from \"fs-extra\";\nimport stripJsonComments from \"strip-json-comments\";\nimport { getErrorMessage } from \"./get-error-message\";\n\n/**\n * @TODO pass in zod schema and validate\n */\nexport function readTypedJsonSync<T>(filePath: string) {\n try {\n const rawContent = fs.readFileSync(filePath, \"utf-8\");\n const data = JSON.parse(stripJsonComments(rawContent)) as T;\n return data;\n } catch (err) {\n throw new Error(\n `Failed to read JSON from ${filePath}: ${getErrorMessage(err)}`\n );\n }\n}\n\nexport async function readTypedJson<T>(filePath: string) {\n try {\n const rawContent = await fs.readFile(filePath, \"utf-8\");\n const data = JSON.parse(rawContent) as T;\n return data;\n } catch (err) {\n throw new Error(\n `Failed to read JSON from ${filePath}: ${getErrorMessage(err)}`\n );\n }\n}\n","import chalk from \"chalk\";\nimport { IsolateConfigResolved } from \"~/helpers\";\n\nexport type Logger = {\n debug(...args: any[]): void;\n info(...args: any[]): void;\n warn(...args: any[]): void;\n error(...args: any[]): void;\n};\n\nexport function createLogger(\n logLevel: IsolateConfigResolved[\"logLevel\"]\n): Logger {\n return {\n debug(...args: any[]) {\n if (logLevel === \"debug\") {\n console.log(chalk.blue(\"debug\"), ...args);\n }\n },\n info(...args: any[]) {\n if (logLevel === \"debug\" || logLevel === \"info\") {\n console.log(chalk.green(\"info\"), ...args);\n }\n },\n warn(...args: any[]) {\n if (logLevel === \"debug\" || logLevel === \"info\" || logLevel === \"warn\") {\n console.log(chalk.yellow(\"warning\"), ...args);\n }\n },\n error(...args: any[]) {\n console.log(chalk.red(\"error\"), ...args);\n },\n };\n}\n","import { exec } from \"node:child_process\";\nimport path from \"node:path\";\nimport { getConfig, usePackageManager } from \"~/helpers\";\nimport { createLogger } from \"./logger\";\n\nexport async function pack(srcDir: string, destDir: string) {\n const log = createLogger(getConfig().logLevel);\n const cwd = process.cwd();\n process.chdir(srcDir);\n\n const { name } = usePackageManager();\n\n /**\n * PNPM pack seems to be a lot faster than NPM pack, so when PNPM is detected\n * we use that instead.\n */\n switch (name) {\n case \"pnpm\": {\n const stdout = await new Promise<string>((resolve, reject) => {\n exec(\n `pnpm pack --pack-destination ${destDir}`,\n (err, stdout, stderr) => {\n if (err) {\n log.error(stderr);\n return reject(err);\n }\n\n resolve(stdout);\n }\n );\n });\n\n /**\n * @TODO use a regex to see if the result from stdout is a valid file\n * path. It could be that other output like warnings are printed. In that\n * case we can to log the stdout.\n */\n\n /**\n * Trim newlines and whitespace\n */\n const packedFilePath = stdout.trim();\n\n // log.debug(\"Packed\", path.basename(packedFilePath));\n log.debug(\"Packed\", packedFilePath);\n\n process.chdir(cwd);\n return packedFilePath;\n }\n\n case \"yarn\":\n case \"npm\": {\n const stdout = await new Promise<string>((resolve, reject) => {\n exec(`npm pack --pack-destination ${destDir}`, (err, stdout) => {\n if (err) {\n return reject(err);\n }\n\n resolve(stdout);\n });\n });\n\n /**\n * Trim newlines and whitespace\n */\n const packedFileName = stdout.trim();\n\n log.debug(\"Packed\", packedFileName);\n\n process.chdir(cwd);\n return path.join(destDir, packedFileName);\n }\n }\n}\n","import fs from \"fs-extra\";\nimport tar from \"tar-fs\";\nimport { createGunzip } from \"zlib\";\n\nexport async function unpack(filePath: string, unpackDir: string) {\n await new Promise<void>((resolve, reject) => {\n fs.createReadStream(filePath)\n .pipe(createGunzip())\n .pipe(tar.extract(unpackDir))\n .on(\"finish\", () => resolve())\n .on(\"error\", (err) => reject(err));\n });\n}\n","import fs from \"fs-extra\";\nimport yaml from \"yaml\";\nimport { getErrorMessage } from \"./get-error-message\";\n\nexport function readTypedYamlSync<T>(filePath: string) {\n try {\n const rawContent = fs.readFileSync(filePath, \"utf-8\");\n const data = yaml.parse(rawContent);\n /**\n * @TODO add some zod validation maybe\n */\n return data as T;\n } catch (err) {\n throw new Error(\n `Failed to read YAML from ${filePath}: ${getErrorMessage(err)}`\n );\n }\n}\n\nexport function writeTypedYamlSync<T>(filePath: string, content: T) {\n /**\n * @TODO add some zod validation maybe\n */\n fs.writeFileSync(filePath, yaml.stringify(content), \"utf-8\");\n}\n","import fs from \"fs-extra\";\nimport path from \"node:path\";\nimport {\n PackageManifest,\n PackagesRegistry,\n adaptManifestWorkspaceDeps,\n getConfig,\n} from \"~/helpers\";\n\nexport async function adaptTargetPackageManifest(\n manifest: PackageManifest,\n packagesRegistry: PackagesRegistry,\n isolateDir: string\n) {\n const outputManifest = adaptManifestWorkspaceDeps(\n {\n manifest,\n packagesRegistry,\n },\n { includeDevDependencies: getConfig().includeDevDependencies }\n );\n\n await fs.writeFile(\n path.join(isolateDir, \"package.json\"),\n JSON.stringify(outputManifest, null, 2)\n );\n}\n","import fs from \"fs-extra\";\nimport { isEmpty } from \"lodash-es\";\nimport path from \"node:path\";\nimport { createLogger, inspectValue, readTypedJsonSync } from \"~/utils\";\n\nexport type IsolateConfigResolved = {\n buildDirName?: string;\n includeDevDependencies: boolean;\n isolateDirName: string;\n logLevel: \"info\" | \"debug\" | \"warn\" | \"error\";\n targetPackagePath?: string;\n tsconfigPath: string;\n workspacePackages?: string[];\n workspaceRoot: string;\n excludeLockfile: boolean;\n};\n\nexport type IsolateConfig = Partial<IsolateConfigResolved>;\n\nconst configDefaults: IsolateConfigResolved = {\n buildDirName: undefined,\n includeDevDependencies: false,\n isolateDirName: \"isolate\",\n logLevel: \"info\",\n targetPackagePath: undefined,\n tsconfigPath: \"./tsconfig.json\",\n workspacePackages: undefined,\n workspaceRoot: \"../..\",\n excludeLockfile: false,\n};\n\n/**\n * Only initialize the configuration once, and keeping it here for subsequent\n * calls to getConfig.\n */\nlet __config: IsolateConfigResolved | undefined;\n\nconst validConfigKeys = Object.keys(configDefaults);\n\nconst CONFIG_FILE_NAME = \"isolate.config.json\";\n\ntype LogLevel = IsolateConfigResolved[\"logLevel\"];\n\nexport function getConfig(): IsolateConfigResolved {\n if (__config) {\n return __config;\n }\n\n /**\n * Since the logLevel is set via config we can't use it to determine if we\n * should output verbose logging as part of the config loading process. Using\n * the env var ISOLATE_CONFIG_LOG_LEVEL you have the option to log debug\n * output.\n */\n const log = createLogger(\n (process.env.ISOLATE_CONFIG_LOG_LEVEL as LogLevel) ?? \"warn\"\n );\n\n const configFilePath = path.join(process.cwd(), CONFIG_FILE_NAME);\n\n log.debug(`Attempting to load config from ${configFilePath}`);\n\n const configFromFile = fs.existsSync(configFilePath)\n ? readTypedJsonSync<IsolateConfig>(configFilePath)\n : {};\n\n const foreignKeys = Object.keys(configFromFile).filter(\n (key) => !validConfigKeys.includes(key)\n );\n\n if (!isEmpty(foreignKeys)) {\n log.warn(`Found invalid config settings:`, foreignKeys.join(\", \"));\n }\n\n const config = Object.assign(\n {},\n configDefaults,\n configFromFile\n ) satisfies IsolateConfigResolved;\n\n log.debug(\"Using configuration:\", inspectValue(config));\n\n __config = config;\n return config;\n}\n","import fs from \"fs-extra\";\nimport { globSync } from \"glob\";\nimport { set } from \"lodash-es\";\nimport path from \"node:path\";\nimport { createLogger, readTypedJson } from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { findPackagesGlobs } from \"./find-packages-globs\";\n\nexport type PackageManifest = {\n name: string;\n packageManager?: string;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n main: string;\n module?: string;\n exports?: Record<string, { require: string; import: string }>;\n files: string[];\n version?: string;\n typings?: string;\n scripts?: Record<string, string>;\n};\n\nexport type WorkspacePackageInfo = {\n absoluteDir: string;\n /**\n * The path of the package relative to the workspace root. This is the path\n * referenced in the lock file.\n */\n rootRelativeDir: string;\n /**\n * The package.json file contents\n */\n manifest: PackageManifest;\n};\n\nexport type PackagesRegistry = Record<string, WorkspacePackageInfo>;\n\n/**\n * Build a list of all packages in the workspace, depending on the package\n * manager used, with a possible override from the config file. The list contains\n * the manifest with some directory info mapped by module name.\n */\nexport async function createPackagesRegistry(\n workspaceRootDir: string,\n workspacePackagesOverride: string[] | undefined\n): Promise<PackagesRegistry> {\n const log = createLogger(getConfig().logLevel);\n\n if (workspacePackagesOverride) {\n log.debug(\n `Override workspace packages via config: ${workspacePackagesOverride}`\n );\n }\n\n const packagesGlobs =\n workspacePackagesOverride ?? findPackagesGlobs(workspaceRootDir);\n\n const cwd = process.cwd();\n process.chdir(workspaceRootDir);\n\n const allPackages = packagesGlobs\n .flatMap((glob) => globSync(glob))\n /**\n * Make sure to filter any loose files that might hang around.\n */\n .filter((dir) => fs.lstatSync(dir).isDirectory());\n\n const registry: PackagesRegistry = (\n await Promise.all(\n allPackages.map(async (rootRelativeDir) => {\n const manifestPath = path.join(rootRelativeDir, \"package.json\");\n\n if (!fs.existsSync(manifestPath)) {\n log.warn(\n `Ignoring directory ./${rootRelativeDir} because it does not contain a package.json file`\n );\n return;\n } else {\n log.debug(`Registering package ./${rootRelativeDir}`);\n\n const manifest = await readTypedJson<PackageManifest>(\n path.join(rootRelativeDir, \"package.json\")\n );\n\n return {\n manifest,\n rootRelativeDir,\n absoluteDir: path.join(workspaceRootDir, rootRelativeDir),\n };\n }\n })\n )\n ).reduce<PackagesRegistry>(\n (acc, info) => (info ? set(acc, info.manifest.name, info) : acc),\n {}\n );\n\n process.chdir(cwd);\n\n return registry;\n}\n","import assert from \"node:assert\";\nimport path from \"node:path\";\nimport {\n createLogger,\n inspectValue,\n readTypedJsonSync,\n readTypedYamlSync,\n} from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { usePackageManager } from \"./detect-package-manager\";\n\n/**\n * Find the globs that define where the packages are located within the\n * monorepo. This configuration is dependent on the package manager used, and I\n * don't know if we're covering all cases yet...\n */\nexport function findPackagesGlobs(workspaceRootDir: string) {\n const log = createLogger(getConfig().logLevel);\n\n const packageManager = usePackageManager();\n\n switch (packageManager.name) {\n case \"pnpm\": {\n const { packages: globs } = readTypedYamlSync<{ packages: string[] }>(\n path.join(workspaceRootDir, \"pnpm-workspace.yaml\")\n );\n\n log.debug(\"Detected pnpm packages globs:\", inspectValue(globs));\n return globs;\n }\n case \"yarn\":\n case \"npm\": {\n const workspaceRootManifestPath = path.join(\n workspaceRootDir,\n \"package.json\"\n );\n\n const { workspaces } = readTypedJsonSync<{ workspaces: string[] }>(\n workspaceRootManifestPath\n );\n\n if (!workspaces) {\n throw new Error(\n `No workspaces field found in ${workspaceRootManifestPath}`\n );\n }\n\n if (Array.isArray(workspaces)) {\n return workspaces;\n } else {\n /**\n * For Yarn, workspaces could be defined as an object with { packages: [],\n * nohoist: [] }. See https://classic.yarnpkg.com/blog/2018/02/15/nohoist/\n */\n const workspacesObject = workspaces as { packages?: string[] };\n\n assert(\n workspacesObject.packages,\n \"workspaces.packages must be an array\"\n );\n\n return workspacesObject.packages;\n }\n }\n }\n}\n","import fs from \"fs-extra\";\nimport assert from \"node:assert\";\nimport { execSync } from \"node:child_process\";\nimport path from \"node:path\";\nimport { createLogger, readTypedJsonSync } from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { PackageManifest } from \"./create-packages-registry\";\nimport { getLockfileFileName } from \"./process-lockfile\";\n\nconst supportedPackageManagerNames = [\"pnpm\", \"yarn\", \"npm\"] as const;\n\nexport type PackageManagerName = (typeof supportedPackageManagerNames)[number];\n\nexport type PackageManager = {\n name: PackageManagerName;\n version: string;\n};\n\nlet packageManager: PackageManager | undefined;\n\n/**\n * First we check if the package manager is declared in the manifest. If it is,\n * we get the name and version from there. Otherwise we'll search for the\n * different lockfiles and ask the OS to report the installed version.\n */\nexport function detectPackageManager(workspaceRoot: string): PackageManager {\n /**\n * Disable infer from manifest for now. I doubt it is useful after all but\n * I'll keep the code as a reminder.\n */\n // packageManager =\n // inferFromManifest(workspaceRoot) ?? inferFromFiles(workspaceRoot);\n\n packageManager = inferFromFiles(workspaceRoot);\n return packageManager;\n}\n\nfunction inferFromManifest(workspaceRoot: string) {\n const log = createLogger(getConfig().logLevel);\n\n const rootManifest = readTypedJsonSync<PackageManifest>(\n path.join(workspaceRoot, \"package.json\")\n );\n\n if (!rootManifest.packageManager) {\n log.debug(\"No packageManager field found in root manifest\");\n return;\n }\n\n const [name, version = \"*\"] = rootManifest.packageManager.split(\"@\") as [\n PackageManagerName,\n string,\n ];\n\n assert(\n supportedPackageManagerNames.includes(name),\n `Package manager \"${name}\" is not currently supported`\n );\n\n const lockfileName = getLockfileFileName(name);\n\n assert(\n fs.existsSync(path.join(workspaceRoot, lockfileName)),\n `Manifest declares ${name} to be the packageManager, but failed to find ${lockfileName} in workspace root`\n );\n\n return { name, version };\n}\n\nfunction inferFromFiles(workspaceRoot: string): PackageManager {\n for (const name of supportedPackageManagerNames) {\n const lockfileName = getLockfileFileName(name);\n\n if (fs.existsSync(path.join(workspaceRoot, lockfileName))) {\n return { name, version: getVersion(name) };\n }\n }\n\n /**\n * If no lockfile was found, it could be that there is an npm shrinkwrap file.\n */\n if (fs.existsSync(path.join(workspaceRoot, \"npm-shrinkwrap.json\"))) {\n return { name: \"npm\", version: getVersion(\"npm\") };\n }\n\n throw new Error(`Failed to detect package manager`);\n}\n\nfunction getVersion(packageManagerName: PackageManagerName): string {\n const buffer = execSync(`${packageManagerName} --version`);\n return buffer.toString().trim();\n}\n\nexport function usePackageManager() {\n if (!packageManager) {\n throw Error(\n \"No package manager detected. Make sure to call detectPackageManager() before usePackageManager()\"\n );\n }\n\n return packageManager;\n}\n","import fs from \"fs-extra\";\nimport assert from \"node:assert\";\nimport path from \"node:path\";\nimport { createLogger, readTypedYamlSync, writeTypedYamlSync } from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { PackagesRegistry } from \"./create-packages-registry\";\nimport {\n PackageManagerName,\n usePackageManager,\n} from \"./detect-package-manager\";\n\ntype PackagePath = string;\n\ntype PnpmLockfile = {\n lockfileVersion: string;\n importers: Record<\n PackagePath,\n {\n dependencies?: Record<string, unknown>;\n devDependencies?: Record<string, unknown>;\n }\n >;\n};\n\nexport function getLockfileFileName(name: PackageManagerName) {\n switch (name) {\n case \"pnpm\":\n return \"pnpm-lock.yaml\";\n case \"yarn\":\n return \"yarn.lock\";\n case \"npm\":\n return \"package-lock.json\";\n }\n}\n\n/**\n * Adapt the lockfile and write it to the isolate directory. Because we keep the\n * structure of packages in the isolate directory the same as they were in the\n * monorepo, the lockfile is largely still correct. The only things that need to\n * be done is to remove the root dependencies and devDependencies, and rename\n * the path to the target package to act as the new root.\n */\nexport function processLockfile({\n workspaceRootDir,\n targetPackageName,\n packagesRegistry,\n isolateDir,\n}: {\n workspaceRootDir: string;\n targetPackageName: string;\n packagesRegistry: PackagesRegistry;\n isolateDir: string;\n}) {\n const log = createLogger(getConfig().logLevel);\n\n const targetPackageRelativeDir =\n packagesRegistry[targetPackageName].rootRelativeDir;\n\n const { name } = usePackageManager();\n\n const fileName = getLockfileFileName(name);\n\n const lockfileSrcPath = path.join(workspaceRootDir, fileName);\n const lockfileDstPath = path.join(isolateDir, fileName);\n\n switch (name) {\n case \"npm\": {\n /**\n * If there is a shrinkwrap file we copy that instead of the lockfile\n */\n const shrinkwrapSrcPath = path.join(\n workspaceRootDir,\n \"npm-shrinkwrap.json\"\n );\n const shrinkwrapDstPath = path.join(isolateDir, \"npm-shrinkwrap.json\");\n\n if (fs.existsSync(shrinkwrapSrcPath)) {\n fs.copyFileSync(shrinkwrapSrcPath, shrinkwrapDstPath);\n log.debug(\"Copied shrinkwrap to\", shrinkwrapDstPath);\n } else {\n fs.copyFileSync(lockfileSrcPath, lockfileDstPath);\n log.debug(\"Copied lockfile to\", lockfileDstPath);\n }\n\n /**\n * If there is an .npmrc file in the workspace root, copy it to the\n * isolate because the settings there could affect how the lockfile is\n * resolved.\n *\n * Also see https://github.com/npm/cli/issues/5113\n */\n const npmrcPath = path.join(workspaceRootDir, \".npmrc\");\n\n if (fs.existsSync(npmrcPath)) {\n fs.copyFileSync(npmrcPath, path.join(isolateDir, \".npmrc\"));\n log.debug(\"Copied .npmrc file to the isolate output\");\n }\n\n return;\n }\n case \"yarn\": {\n fs.copyFileSync(lockfileSrcPath, lockfileDstPath);\n log.debug(\"Copied lockfile to\", lockfileDstPath);\n return;\n }\n case \"pnpm\": {\n const origLockfile = readTypedYamlSync<PnpmLockfile>(lockfileSrcPath);\n\n log.debug(\"Read PNPM lockfile, version:\", origLockfile.lockfileVersion);\n\n const adaptedLockfile = structuredClone(origLockfile);\n\n const targetPackageDef =\n adaptedLockfile.importers[targetPackageRelativeDir];\n\n assert(\n targetPackageDef,\n `Failed to find target package in lockfile at importers[${targetPackageRelativeDir}]`\n );\n /**\n * Overwrite the root importer with the target package importer contents\n */\n adaptedLockfile.importers[\".\"] = targetPackageDef;\n\n /**\n * Delete the target package original importer. Not really necessary.\n */\n delete adaptedLockfile.importers[targetPackageRelativeDir];\n\n writeTypedYamlSync(lockfileDstPath, adaptedLockfile);\n\n log.debug(\"Stored adapted lockfile at\", lockfileDstPath);\n\n return;\n }\n }\n}\n","import fs from \"fs-extra\";\nimport path from \"node:path\";\nimport outdent from \"outdent\";\nimport { getConfig } from \"~/helpers\";\nimport { createLogger, readTypedJson } from \"~/utils\";\n\nexport async function getBuildOutputDir(targetPackageDir: string) {\n const config = getConfig();\n const log = createLogger(getConfig().logLevel);\n\n if (config.buildDirName) {\n log.debug(\"Using buildDirName from config:\", config.buildDirName);\n return path.join(targetPackageDir, config.buildDirName);\n }\n\n const tsconfigPath = path.join(targetPackageDir, config.tsconfigPath);\n\n log.debug(\"Looking for tsconfig at:\", tsconfigPath);\n\n if (fs.existsSync(tsconfigPath)) {\n const tsconfig = await readTypedJson<{\n compilerOptions?: { outDir?: string };\n }>(tsconfigPath);\n\n const outDir = tsconfig.compilerOptions?.outDir;\n\n if (outDir) {\n return path.join(targetPackageDir, outDir);\n } else {\n throw new Error(outdent`\n Failed to find outDir in tsconfig. If you are executing isolate from the root of a monorepo you should specify the buildDirName in isolate.config.json.\n `);\n }\n } else {\n throw new Error(outdent`\n Failed to infer the build output directory from either the isolate config buildDirName or a Typescript config file. See the documentation on how to configure one of these options.\n `);\n }\n}\n","import { PackageManifest, PackagesRegistry } from \"./create-packages-registry\";\n\n/**\n * Recursively list the packages from dependencies (and optionally\n * devDependencies) that are found in the workspace.\n *\n * Here we do not need to rely on packages being declared as \"workspace:\" in the\n * manifest. We can simply compare the package names with the list of packages\n * that were found via the workspace glob patterns and added to the registry.\n */\nexport function listLocalDependencies(\n manifest: PackageManifest,\n packagesRegistry: PackagesRegistry,\n { includeDevDependencies = false } = {}\n): string[] {\n const allWorkspacePackageNames = Object.keys(packagesRegistry);\n\n const localDependencyPackageNames = (\n includeDevDependencies\n ? [\n ...Object.keys(manifest.dependencies ?? {}),\n ...Object.keys(manifest.devDependencies ?? {}),\n ]\n : Object.keys(manifest.dependencies ?? {})\n ).filter((name) => allWorkspacePackageNames.includes(name));\n\n const nestedLocalDependencies = localDependencyPackageNames.flatMap(\n (packageName) =>\n listLocalDependencies(\n packagesRegistry[packageName].manifest,\n packagesRegistry,\n { includeDevDependencies }\n )\n );\n\n return localDependencyPackageNames.concat(nestedLocalDependencies);\n}\n","import path from \"node:path\";\nimport { readTypedJson } from \"~/utils\";\nimport { PackageManifest } from \"./create-packages-registry\";\n\nexport async function importManifest(packageDir: string) {\n return readTypedJson<PackageManifest>(path.join(packageDir, \"package.json\"));\n}\n","import assert from \"node:assert\";\nimport { createLogger, pack } from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { PackagesRegistry } from \"./create-packages-registry\";\n\n/**\n * Pack dependencies so that we extract only the files that are supposed to be\n * published by the packages.\n *\n * @returns A map of package names to the path of the packed file\n */\nexport async function packDependencies({\n /**\n * All packages found in the monorepo by workspaces declaration\n */\n packagesRegistry,\n /**\n * The package names that appear to be local dependencies\n */\n localDependencies,\n /**\n * The directory where the isolated package and all its dependencies will end\n * up. This is also the directory from where the package will be deployed. By\n * default it is a subfolder in targetPackageDir called \"isolate\" but you can\n * configure it.\n */\n packDestinationDir,\n}: {\n packagesRegistry: PackagesRegistry;\n localDependencies: string[];\n packDestinationDir: string;\n}) {\n const config = getConfig();\n const log = createLogger(config.logLevel);\n\n const packedFileByName: Record<string, string> = {};\n\n for (const dependency of localDependencies) {\n const def = packagesRegistry[dependency];\n\n assert(dependency, `Failed to find package definition for ${dependency}`);\n\n const { name } = def.manifest;\n\n /**\n * If this dependency has already been packed, we skip it. It could happen\n * because we are packing workspace dependencies recursively.\n */\n if (packedFileByName[name]) {\n log.debug(`Skipping ${name} because it has already been packed`);\n continue;\n }\n\n packedFileByName[name] = await pack(def.absoluteDir, packDestinationDir);\n\n /**\n * @TODO call recursively\n */\n }\n\n return packedFileByName;\n}\n","import path from \"node:path\";\nimport { createLogger } from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { PackagesRegistry } from \"./create-packages-registry\";\n\nexport function patchWorkspaceEntries(\n dependencies: Record<string, string>,\n packagesRegistry: PackagesRegistry,\n parentRootRelativeDir?: string\n) {\n const log = createLogger(getConfig().logLevel);\n const allWorkspacePackageNames = Object.keys(packagesRegistry);\n\n return Object.fromEntries(\n Object.entries(dependencies).map(([key, value]) => {\n if (allWorkspacePackageNames.includes(key)) {\n const def = packagesRegistry[key];\n\n /**\n * When nested shared dependencies are used (local deps linking to other\n * local deps), the parentRootRelativeDir will be passed in, and we\n * store the relative path to the isolate/packages directory, as is\n * required by some package managers.\n *\n * For consistency we also write the other file paths starting with\n * ./, but it doesn't seem to be necessary for any package manager.\n */\n const relativePath = parentRootRelativeDir\n ? path.relative(parentRootRelativeDir, `./${def.rootRelativeDir}`)\n : `./${def.rootRelativeDir}`;\n\n const linkPath = `file:${relativePath}`;\n\n log.debug(`Linking dependency ${key} to ${linkPath}`);\n\n return [key, linkPath];\n } else {\n return [key, value];\n }\n })\n );\n}\n","import fs from \"fs-extra\";\nimport path from \"node:path\";\nimport { createLogger, pack, unpack } from \"~/utils\";\nimport { getConfig } from \"./config\";\n\nconst TIMEOUT_MS = 5000;\n\nexport async function processBuildOutputFiles({\n targetPackageDir,\n tmpDir,\n isolateDir,\n}: {\n targetPackageDir: string;\n tmpDir: string;\n isolateDir: string;\n}) {\n const log = createLogger(getConfig().logLevel);\n const packedFilePath = await pack(targetPackageDir, tmpDir);\n const unpackDir = path.join(tmpDir, \"target\");\n\n const now = Date.now();\n let isWaitingYet = false;\n\n while (!fs.existsSync(packedFilePath) && Date.now() - now < TIMEOUT_MS) {\n if (!isWaitingYet) {\n log.debug(`Waiting for ${packedFilePath} to become available...`);\n }\n isWaitingYet = true;\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n\n await unpack(packedFilePath, unpackDir);\n await fs.copy(path.join(unpackDir, \"package\"), isolateDir);\n}\n","import fs from \"fs-extra\";\nimport { join } from \"node:path\";\nimport { getIsolateRelativePath } from \"~/utils\";\nimport { createLogger } from \"~/utils/logger\";\nimport { PackagesRegistry, getConfig } from \".\";\nimport { unpack } from \"../utils/unpack\";\n\nexport async function unpackDependencies(\n packedFilesByName: Record<string, string>,\n packagesRegistry: PackagesRegistry,\n tmpDir: string,\n isolateDir: string\n) {\n const log = createLogger(getConfig().logLevel);\n\n await Promise.all(\n Object.entries(packedFilesByName).map(async ([packageName, filePath]) => {\n const dir = packagesRegistry[packageName].rootRelativeDir;\n const unpackDir = join(tmpDir, dir);\n\n log.debug(\"Unpacking\", filePath);\n\n await unpack(filePath, unpackDir);\n\n const destinationDir = join(isolateDir, dir);\n\n await fs.ensureDir(destinationDir);\n\n await fs.move(join(unpackDir, \"package\"), destinationDir, {\n overwrite: true,\n });\n\n log.debug(\n `Moved package files to ${getIsolateRelativePath(\n destinationDir,\n isolateDir\n )}`\n );\n })\n );\n}\n"],"mappings":";;;AAcA,OAAOA,UAAQ;AACf,OAAOC,aAAY;AACnB,OAAOC,YAAU;AACjB,OAAO,gBAAgB;;;ACjBvB,OAAO,QAAQ;AACf,OAAO,UAAU;AAQjB,eAAsB,mBACpB,mBACA,kBACA,YACA;AACA,QAAM,QAAQ;AAAA,IACZ,kBAAkB,IAAI,OAAO,gBAAgB;AAC3C,YAAM,EAAE,UAAU,gBAAgB,IAAI,iBAAiB,WAAW;AAElE,YAAM,iBAAiB;AAAA,QACrB,EAAE,UAAU,kBAAkB,uBAAuB,gBAAgB;AAAA,QACrE,EAAE,wBAAwB,UAAU,EAAE,uBAAuB;AAAA,MAC/D;AAEA,YAAM,GAAG;AAAA,QACP,KAAK,KAAK,YAAY,iBAAiB,cAAc;AAAA,QACrD,KAAK,UAAU,gBAAgB,MAAM,CAAC;AAAA,MACxC;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;AC7BA,SAAS,YAAY;;;ACAd,SAAS,sBAAsB,QAAiC;AACrE,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,KAAK,MAAM,UAAU,MAAS;AAAA,EACnE;AACF;;;ACAO,SAAS,gBAAgB,OAAgB;AAC9C,SAAO,mBAAmB,KAAK,EAAE;AACnC;AA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,QAAM,oBAAoB,MAAM,iBAAiB;AAAA,IAC/C;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,EACtB,CAAC;AAED,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAKA,QAAM,mBAAmB,mBAAmB,kBAAkB,UAAU;AAKxE,QAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAMD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,OAAO,iBAAiB;AAC1B,QAAI,KAAK,gDAAgD;AAAA,EAC3D,OAAO;AAIL,UAAM,gBAAgB;AAAA,MACpB;AAAA,MACA,mBAAmB,sBAAsB;AAAA,MACzC;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAMA,MAAI;AAAA,IACF;AAAA,IACA,oBAAoB,QAAQ,gBAAgB;AAAA,EAC9C;AACA,QAAMD,KAAG,OAAO,MAAM;AAEtB,MAAI,KAAK,wBAAwB,UAAU;AAC7C;AAEA,MAAM,EAAE,MAAM,CAAC,QAAQ;AACrB,MAAI,eAAe,OAAO;AACxB,QAAI,MAAM,IAAI,KAAK;AACnB,YAAQ,KAAK,CAAC;AAAA,EAChB,OAAO;AACL,YAAQ,MAAM,GAAG;AAAA,EACnB;AACF,CAAC;AAED,QAAQ,GAAG,sBAAsB,IAAI,KAAK;","names":["fs","assert","path","path","fs","fs","path","log","stdout","path","fs","fs","fs","fs","path","fs","path","fs","path","log","path","fs","config","fs","path","assert","path","fs","assert","path","fs","path","log","path","fs","fs","path","log","packageManager","path","assert","log","fs","path","fs","path","config","log","path","fs","path","assert","config","log","assert","path","log","path","fs","path","log","path","fs","fs","log","fs","path","assert","fs","packageManager"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/helpers/adapt-manifest-files.ts","../src/helpers/adapt-manifest-workspace-deps.ts","../src/utils/filter-object-undefined.ts","../src/utils/get-dirname.ts","../src/utils/get-error-message.ts","../src/utils/get-relative-path.ts","../src/utils/inspect-value.ts","../src/utils/json.ts","../src/utils/logger.ts","../src/utils/pack.ts","../src/utils/unpack.ts","../src/utils/yaml.ts","../src/helpers/adapt-target-package-manifest.ts","../src/helpers/config.ts","../src/helpers/create-packages-registry.ts","../src/helpers/find-packages-globs.ts","../src/helpers/detect-package-manager.ts","../src/helpers/process-lockfile.ts","../src/helpers/get-build-output-dir.ts","../src/helpers/list-local-dependencies.ts","../src/helpers/manifest.ts","../src/helpers/pack-dependencies.ts","../src/helpers/patch-workspace-entries.ts","../src/helpers/process-build-output-files.ts","../src/helpers/unpack-dependencies.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * For PNPM the hashbang at the top of the script was not required, but Yarn 3\n * did not seem to execute without it.\n */\n\n/**\n * A word about used terminology:\n *\n * The various package managers, while being very similar, seem to use a\n * different definition for the term \"workspace\". If you want to read the code\n * it might be good to know that I consider the workspace to be the monorepo\n * itself, in other words, the overall structure that holds all the packages.\n */\nimport fs from \"fs-extra\";\nimport assert from \"node:assert\";\nimport path from \"node:path\";\nimport sourceMaps from \"source-map-support\";\nimport {\n PackageManifest,\n adaptManifestFiles,\n adaptTargetPackageManifest,\n createPackagesRegistry,\n detectPackageManager,\n getBuildOutputDir,\n getConfig,\n listLocalDependencies,\n packDependencies,\n processBuildOutputFiles,\n processLockfile,\n unpackDependencies,\n} from \"~/helpers\";\nimport {\n createLogger,\n getDirname,\n getRootRelativePath,\n readTypedJson,\n} from \"~/utils\";\n\nconst config = getConfig();\nconst log = createLogger(config.logLevel);\n\nsourceMaps.install();\n\nasync function start() {\n const __dirname = getDirname(import.meta.url);\n\n const thisPackageManifest = await readTypedJson<PackageManifest>(\n path.join(path.join(__dirname, \"..\", \"package.json\"))\n );\n\n log.debug(\"Running isolate-package version\", thisPackageManifest.version);\n\n /**\n * If a targetPackagePath is set, we assume the configuration lives in the\n * root of the workspace. If targetPackagePath is undefined (the default), we\n * assume that the configuration lives in the target package directory.\n */\n const targetPackageDir = config.targetPackagePath\n ? path.join(process.cwd(), config.targetPackagePath)\n : process.cwd();\n\n /**\n * We want a trailing slash here. Functionally it doesn't matter, but it makes\n * the relative paths more correct in the debug output.\n */\n const workspaceRootDir = config.targetPackagePath\n ? process.cwd()\n : path.join(targetPackageDir, config.workspaceRoot);\n\n const buildOutputDir = await getBuildOutputDir(targetPackageDir);\n\n assert(\n fs.existsSync(buildOutputDir),\n `Failed to find build output path at ${buildOutputDir}. Please make sure you build the source before isolating it.`\n );\n\n log.debug(\"Workspace root resolved to\", workspaceRootDir);\n log.debug(\n \"Isolate target package\",\n getRootRelativePath(targetPackageDir, workspaceRootDir)\n );\n\n const isolateDir = path.join(targetPackageDir, config.isolateDirName);\n\n log.debug(\n \"Isolate output directory\",\n getRootRelativePath(isolateDir, workspaceRootDir)\n );\n\n if (fs.existsSync(isolateDir)) {\n await fs.remove(isolateDir);\n log.debug(\"Cleaned the existing isolate output directory\");\n }\n\n await fs.ensureDir(isolateDir);\n\n const tmpDir = path.join(isolateDir, \"__tmp\");\n await fs.ensureDir(tmpDir);\n\n const targetPackageManifest = await readTypedJson<PackageManifest>(\n path.join(targetPackageDir, \"package.json\")\n );\n\n const packageManager = detectPackageManager(workspaceRootDir);\n\n log.debug(\n \"Detected package manager\",\n packageManager.name,\n packageManager.version\n );\n\n /**\n * Disable lock files for PNPM because they are not yet supported.\n */\n if (packageManager.name === \"pnpm\") {\n config.excludeLockfile = true;\n }\n\n /**\n * Build a packages registry so we can find the workspace packages by name and\n * have access to their manifest files and relative paths.\n */\n const packagesRegistry = await createPackagesRegistry(\n workspaceRootDir,\n config.workspacePackages\n );\n\n const localDependencies = listLocalDependencies(\n targetPackageManifest,\n packagesRegistry,\n {\n includeDevDependencies: config.includeDevDependencies,\n }\n );\n\n const packedFilesByName = await packDependencies({\n localDependencies,\n packagesRegistry,\n packDestinationDir: tmpDir,\n });\n\n await unpackDependencies(\n packedFilesByName,\n packagesRegistry,\n tmpDir,\n isolateDir\n );\n\n /**\n * Adapt the manifest files for all the unpacked local dependencies\n */\n await adaptManifestFiles(localDependencies, packagesRegistry, isolateDir);\n\n /**\n * Pack the target package directory, and unpack it in the isolate location\n */\n await processBuildOutputFiles({\n targetPackageDir,\n tmpDir,\n isolateDir,\n });\n\n /**\n * Copy the target manifest file to the isolate location and adapt its\n * workspace dependencies to point to the isolated packages.\n */\n await adaptTargetPackageManifest(\n targetPackageManifest,\n packagesRegistry,\n isolateDir\n );\n\n if (config.excludeLockfile) {\n log.warn(\"Excluding the lockfile from the isolate output\");\n } else {\n /**\n * Copy and adapt the lockfile\n */\n await processLockfile({\n workspaceRootDir,\n targetPackageName: targetPackageManifest.name,\n isolateDir,\n packagesRegistry,\n });\n }\n\n /**\n * If there is an .npmrc file in the workspace root, copy it to the\n * isolate because the settings there could affect how the lockfile is\n * resolved. Note that .npmrc is used by both NPM and PNPM for configuration.\n *\n * See also: https://pnpm.io/npmrc\n */\n const npmrcPath = path.join(workspaceRootDir, \".npmrc\");\n\n if (fs.existsSync(npmrcPath)) {\n fs.copyFileSync(npmrcPath, path.join(isolateDir, \".npmrc\"));\n log.debug(\"Copied .npmrc file to the isolate output\");\n }\n\n /**\n * Clean up. Only so this in the happy path, so we can look at the temp folder\n * when thing go wrong.\n */\n log.debug(\n \"Deleting temp directory\",\n getRootRelativePath(tmpDir, workspaceRootDir)\n );\n await fs.remove(tmpDir);\n\n log.info(\"Isolate completed at\", isolateDir);\n}\n\nstart().catch((err) => {\n if (err instanceof Error) {\n log.error(err.stack);\n process.exit(1);\n } else {\n console.error(err);\n }\n});\n\nprocess.on(\"unhandledRejection\", log.error);\n","import fs from \"fs-extra\";\nimport path from \"node:path\";\nimport {\n PackagesRegistry,\n adaptManifestWorkspaceDeps,\n getConfig,\n} from \"~/helpers\";\nimport { createLogger } from \"~/utils\";\n\nexport async function adaptManifestFiles(\n localDependencies: string[],\n packagesRegistry: PackagesRegistry,\n isolateDir: string\n) {\n await Promise.all(\n localDependencies.map(async (packageName) => {\n const { manifest, rootRelativeDir } = packagesRegistry[packageName];\n\n const outputManifest = adaptManifestWorkspaceDeps(\n { manifest, packagesRegistry, parentRootRelativeDir: rootRelativeDir },\n { includeDevDependencies: getConfig().includeDevDependencies }\n );\n\n await fs.writeFile(\n path.join(isolateDir, rootRelativeDir, \"package.json\"),\n JSON.stringify(outputManifest, null, 2)\n );\n })\n );\n}\n","import { omit } from \"lodash-es\";\nimport { filterObjectUndefined } from \"~/utils\";\nimport { PackageManifest, PackagesRegistry, patchWorkspaceEntries } from \".\";\n\nexport function adaptManifestWorkspaceDeps(\n {\n manifest,\n packagesRegistry,\n parentRootRelativeDir,\n }: {\n manifest: PackageManifest;\n packagesRegistry: PackagesRegistry;\n parentRootRelativeDir?: string;\n },\n opts: { includeDevDependencies?: boolean } = {}\n): PackageManifest {\n return Object.assign(\n omit(manifest, [\"scripts\", \"devDependencies\"]),\n filterObjectUndefined({\n dependencies: manifest.dependencies\n ? patchWorkspaceEntries(\n manifest.dependencies,\n packagesRegistry,\n parentRootRelativeDir\n )\n : undefined,\n devDependencies:\n opts.includeDevDependencies && manifest.devDependencies\n ? patchWorkspaceEntries(\n manifest.devDependencies,\n packagesRegistry,\n parentRootRelativeDir\n )\n : undefined,\n })\n );\n}\n","export function filterObjectUndefined(object: Record<string, unknown>) {\n return Object.fromEntries(\n Object.entries(object).filter(([_, value]) => value !== undefined)\n );\n}\n","import { fileURLToPath } from \"url\";\n\n/**\n * Calling context should pass in import.meta.url and the function will return\n * the equivalent of __dirname in Node/CommonJs.\n */\nexport function getDirname(importMetaUrl: string) {\n return fileURLToPath(new URL(\".\", importMetaUrl));\n}\n","type ErrorWithMessage = {\n message: string;\n};\n\nexport function getErrorMessage(error: unknown) {\n return toErrorWithMessage(error).message;\n}\n\nfunction isErrorWithMessage(error: unknown): error is ErrorWithMessage {\n return typeof error === \"object\" && error !== null && \"message\" in error;\n}\n\nfunction toErrorWithMessage(maybeError: unknown): ErrorWithMessage {\n if (isErrorWithMessage(maybeError)) return maybeError;\n\n try {\n return new Error(JSON.stringify(maybeError));\n } catch {\n /**\n * Fallback in case there’s an error stringifying the maybeError\n * like with circular references.\n */\n return new Error(String(maybeError));\n }\n}\n","export function getRootRelativePath(path: string, rootPath: string) {\n const strippedPath = path.replace(rootPath, \"\");\n\n return strippedPath.startsWith(\"/\")\n ? `(root)${strippedPath}`\n : `(root)/${strippedPath}`;\n}\n\nexport function getIsolateRelativePath(path: string, isolatePath: string) {\n const strippedPath = path.replace(isolatePath, \"\");\n\n return strippedPath.startsWith(\"/\")\n ? `(isolate)${strippedPath}`\n : `(isolate)/${strippedPath}`;\n}\n","import { inspect } from \"node:util\";\nimport { JsonValue } from \"type-fest\";\n\nexport function inspectValue(value: JsonValue) {\n return inspect(value, false, 4, true);\n}\n","import fs from \"fs-extra\";\nimport stripJsonComments from \"strip-json-comments\";\nimport { getErrorMessage } from \"./get-error-message\";\n\n/**\n * @TODO pass in zod schema and validate\n */\nexport function readTypedJsonSync<T>(filePath: string) {\n try {\n const rawContent = fs.readFileSync(filePath, \"utf-8\");\n const data = JSON.parse(stripJsonComments(rawContent)) as T;\n return data;\n } catch (err) {\n throw new Error(\n `Failed to read JSON from ${filePath}: ${getErrorMessage(err)}`\n );\n }\n}\n\nexport async function readTypedJson<T>(filePath: string) {\n try {\n const rawContent = await fs.readFile(filePath, \"utf-8\");\n const data = JSON.parse(rawContent) as T;\n return data;\n } catch (err) {\n throw new Error(\n `Failed to read JSON from ${filePath}: ${getErrorMessage(err)}`\n );\n }\n}\n","import chalk from \"chalk\";\nimport { IsolateConfigResolved } from \"~/helpers\";\n\nexport type Logger = {\n debug(...args: any[]): void;\n info(...args: any[]): void;\n warn(...args: any[]): void;\n error(...args: any[]): void;\n};\n\nexport function createLogger(\n logLevel: IsolateConfigResolved[\"logLevel\"]\n): Logger {\n return {\n debug(...args: any[]) {\n if (logLevel === \"debug\") {\n console.log(chalk.blue(\"debug\"), ...args);\n }\n },\n info(...args: any[]) {\n if (logLevel === \"debug\" || logLevel === \"info\") {\n console.log(chalk.green(\"info\"), ...args);\n }\n },\n warn(...args: any[]) {\n if (logLevel === \"debug\" || logLevel === \"info\" || logLevel === \"warn\") {\n console.log(chalk.yellow(\"warning\"), ...args);\n }\n },\n error(...args: any[]) {\n console.log(chalk.red(\"error\"), ...args);\n },\n };\n}\n","import fs from \"fs-extra\";\nimport { exec } from \"node:child_process\";\nimport path from \"node:path\";\nimport { getConfig } from \"~/helpers\";\nimport { createLogger } from \"./logger\";\n\nexport async function pack(\n srcDir: string,\n dstDir: string,\n usePnpmPack = false\n) {\n const log = createLogger(getConfig().logLevel);\n\n const previousCwd = process.cwd();\n process.chdir(srcDir);\n\n /**\n * PNPM pack seems to be a lot faster than NPM pack, so when PNPM is detected\n * we use that instead.\n */\n const stdout = usePnpmPack\n ? await new Promise<string>((resolve, reject) => {\n exec(\n `pnpm pack --pack-destination ${dstDir}`,\n (err, stdout, stderr) => {\n if (err) {\n log.error(stderr);\n return reject(err);\n }\n\n resolve(stdout);\n }\n );\n })\n : await new Promise<string>((resolve, reject) => {\n exec(`npm pack --pack-destination ${dstDir}`, (err, stdout) => {\n if (err) {\n return reject(err);\n }\n\n resolve(stdout);\n });\n });\n\n const fileName = path.basename(stdout.trim());\n\n const filePath = path.join(dstDir, fileName);\n\n if (!fs.existsSync(filePath)) {\n log.error(\n `The response from pack could not be resolved to an existing file: ${filePath}`\n );\n } else {\n log.debug(`Packed (temp)/${fileName}`);\n }\n\n process.chdir(previousCwd);\n\n /**\n * Return the path anyway even if it doesn't validate. A later stage will wait\n * for the file to occur still. Not sure if this makes sense. Maybe we should\n * stop at the validation error...\n */\n return filePath;\n}\n","import fs from \"fs-extra\";\nimport tar from \"tar-fs\";\nimport { createGunzip } from \"zlib\";\n\nexport async function unpack(filePath: string, unpackDir: string) {\n await new Promise<void>((resolve, reject) => {\n fs.createReadStream(filePath)\n .pipe(createGunzip())\n .pipe(tar.extract(unpackDir))\n .on(\"finish\", () => resolve())\n .on(\"error\", (err) => reject(err));\n });\n}\n","import fs from \"fs-extra\";\nimport yaml from \"yaml\";\nimport { getErrorMessage } from \"./get-error-message\";\n\nexport function readTypedYamlSync<T>(filePath: string) {\n try {\n const rawContent = fs.readFileSync(filePath, \"utf-8\");\n const data = yaml.parse(rawContent);\n /**\n * @TODO add some zod validation maybe\n */\n return data as T;\n } catch (err) {\n throw new Error(\n `Failed to read YAML from ${filePath}: ${getErrorMessage(err)}`\n );\n }\n}\n\nexport function writeTypedYamlSync<T>(filePath: string, content: T) {\n /**\n * @TODO add some zod validation maybe\n */\n fs.writeFileSync(filePath, yaml.stringify(content), \"utf-8\");\n}\n","import fs from \"fs-extra\";\nimport path from \"node:path\";\nimport {\n PackageManifest,\n PackagesRegistry,\n adaptManifestWorkspaceDeps,\n getConfig,\n} from \"~/helpers\";\n\nexport async function adaptTargetPackageManifest(\n manifest: PackageManifest,\n packagesRegistry: PackagesRegistry,\n isolateDir: string\n) {\n const outputManifest = adaptManifestWorkspaceDeps(\n {\n manifest,\n packagesRegistry,\n },\n { includeDevDependencies: getConfig().includeDevDependencies }\n );\n\n await fs.writeFile(\n path.join(isolateDir, \"package.json\"),\n JSON.stringify(outputManifest, null, 2)\n );\n}\n","import fs from \"fs-extra\";\nimport { isEmpty } from \"lodash-es\";\nimport path from \"node:path\";\nimport { createLogger, inspectValue, readTypedJsonSync } from \"~/utils\";\n\nexport type IsolateConfigResolved = {\n buildDirName?: string;\n includeDevDependencies: boolean;\n isolateDirName: string;\n logLevel: \"info\" | \"debug\" | \"warn\" | \"error\";\n targetPackagePath?: string;\n tsconfigPath: string;\n workspacePackages?: string[];\n workspaceRoot: string;\n excludeLockfile: boolean;\n avoidPnpmPack: boolean;\n};\n\nexport type IsolateConfig = Partial<IsolateConfigResolved>;\n\nconst configDefaults: IsolateConfigResolved = {\n buildDirName: undefined,\n includeDevDependencies: false,\n isolateDirName: \"isolate\",\n logLevel: \"info\",\n targetPackagePath: undefined,\n tsconfigPath: \"./tsconfig.json\",\n workspacePackages: undefined,\n workspaceRoot: \"../..\",\n excludeLockfile: false,\n avoidPnpmPack: false,\n};\n\n/**\n * Only initialize the configuration once, and keeping it here for subsequent\n * calls to getConfig.\n */\nlet __config: IsolateConfigResolved | undefined;\n\nconst validConfigKeys = Object.keys(configDefaults);\n\nconst CONFIG_FILE_NAME = \"isolate.config.json\";\n\ntype LogLevel = IsolateConfigResolved[\"logLevel\"];\n\nexport function getConfig(): IsolateConfigResolved {\n if (__config) {\n return __config;\n }\n\n /**\n * Since the logLevel is set via config we can't use it to determine if we\n * should output verbose logging as part of the config loading process. Using\n * the env var ISOLATE_CONFIG_LOG_LEVEL you have the option to log debug\n * output.\n */\n const log = createLogger(\n (process.env.ISOLATE_CONFIG_LOG_LEVEL as LogLevel) ?? \"warn\"\n );\n\n const configFilePath = path.join(process.cwd(), CONFIG_FILE_NAME);\n\n log.debug(`Attempting to load config from ${configFilePath}`);\n\n const configFromFile = fs.existsSync(configFilePath)\n ? readTypedJsonSync<IsolateConfig>(configFilePath)\n : {};\n\n const foreignKeys = Object.keys(configFromFile).filter(\n (key) => !validConfigKeys.includes(key)\n );\n\n if (!isEmpty(foreignKeys)) {\n log.warn(`Found invalid config settings:`, foreignKeys.join(\", \"));\n }\n\n const config = Object.assign(\n {},\n configDefaults,\n configFromFile\n ) satisfies IsolateConfigResolved;\n\n log.debug(\"Using configuration:\", inspectValue(config));\n\n __config = config;\n return config;\n}\n","import fs from \"fs-extra\";\nimport { globSync } from \"glob\";\nimport { set } from \"lodash-es\";\nimport path from \"node:path\";\nimport { createLogger, readTypedJson } from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { findPackagesGlobs } from \"./find-packages-globs\";\n\nexport type PackageManifest = {\n name: string;\n packageManager?: string;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n main: string;\n module?: string;\n exports?: Record<string, { require: string; import: string }>;\n files: string[];\n version?: string;\n typings?: string;\n scripts?: Record<string, string>;\n};\n\nexport type WorkspacePackageInfo = {\n absoluteDir: string;\n /**\n * The path of the package relative to the workspace root. This is the path\n * referenced in the lock file.\n */\n rootRelativeDir: string;\n /**\n * The package.json file contents\n */\n manifest: PackageManifest;\n};\n\nexport type PackagesRegistry = Record<string, WorkspacePackageInfo>;\n\n/**\n * Build a list of all packages in the workspace, depending on the package\n * manager used, with a possible override from the config file. The list contains\n * the manifest with some directory info mapped by module name.\n */\nexport async function createPackagesRegistry(\n workspaceRootDir: string,\n workspacePackagesOverride: string[] | undefined\n): Promise<PackagesRegistry> {\n const log = createLogger(getConfig().logLevel);\n\n if (workspacePackagesOverride) {\n log.debug(\n `Override workspace packages via config: ${workspacePackagesOverride}`\n );\n }\n\n const packagesGlobs =\n workspacePackagesOverride ?? findPackagesGlobs(workspaceRootDir);\n\n const cwd = process.cwd();\n process.chdir(workspaceRootDir);\n\n const allPackages = packagesGlobs\n .flatMap((glob) => globSync(glob))\n /**\n * Make sure to filter any loose files that might hang around.\n */\n .filter((dir) => fs.lstatSync(dir).isDirectory());\n\n const registry: PackagesRegistry = (\n await Promise.all(\n allPackages.map(async (rootRelativeDir) => {\n const manifestPath = path.join(rootRelativeDir, \"package.json\");\n\n if (!fs.existsSync(manifestPath)) {\n log.warn(\n `Ignoring directory ./${rootRelativeDir} because it does not contain a package.json file`\n );\n return;\n } else {\n log.debug(`Registering package ./${rootRelativeDir}`);\n\n const manifest = await readTypedJson<PackageManifest>(\n path.join(rootRelativeDir, \"package.json\")\n );\n\n return {\n manifest,\n rootRelativeDir,\n absoluteDir: path.join(workspaceRootDir, rootRelativeDir),\n };\n }\n })\n )\n ).reduce<PackagesRegistry>(\n (acc, info) => (info ? set(acc, info.manifest.name, info) : acc),\n {}\n );\n\n process.chdir(cwd);\n\n return registry;\n}\n","import assert from \"node:assert\";\nimport path from \"node:path\";\nimport {\n createLogger,\n inspectValue,\n readTypedJsonSync,\n readTypedYamlSync,\n} from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { usePackageManager } from \"./detect-package-manager\";\n\n/**\n * Find the globs that define where the packages are located within the\n * monorepo. This configuration is dependent on the package manager used, and I\n * don't know if we're covering all cases yet...\n */\nexport function findPackagesGlobs(workspaceRootDir: string) {\n const log = createLogger(getConfig().logLevel);\n\n const packageManager = usePackageManager();\n\n switch (packageManager.name) {\n case \"pnpm\": {\n const { packages: globs } = readTypedYamlSync<{ packages: string[] }>(\n path.join(workspaceRootDir, \"pnpm-workspace.yaml\")\n );\n\n log.debug(\"Detected pnpm packages globs:\", inspectValue(globs));\n return globs;\n }\n case \"yarn\":\n case \"npm\": {\n const workspaceRootManifestPath = path.join(\n workspaceRootDir,\n \"package.json\"\n );\n\n const { workspaces } = readTypedJsonSync<{ workspaces: string[] }>(\n workspaceRootManifestPath\n );\n\n if (!workspaces) {\n throw new Error(\n `No workspaces field found in ${workspaceRootManifestPath}`\n );\n }\n\n if (Array.isArray(workspaces)) {\n return workspaces;\n } else {\n /**\n * For Yarn, workspaces could be defined as an object with { packages: [],\n * nohoist: [] }. See https://classic.yarnpkg.com/blog/2018/02/15/nohoist/\n */\n const workspacesObject = workspaces as { packages?: string[] };\n\n assert(\n workspacesObject.packages,\n \"workspaces.packages must be an array\"\n );\n\n return workspacesObject.packages;\n }\n }\n }\n}\n","import fs from \"fs-extra\";\nimport assert from \"node:assert\";\nimport { execSync } from \"node:child_process\";\nimport path from \"node:path\";\nimport { createLogger, readTypedJsonSync } from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { PackageManifest } from \"./create-packages-registry\";\nimport { getLockfileFileName } from \"./process-lockfile\";\n\nconst supportedPackageManagerNames = [\"pnpm\", \"yarn\", \"npm\"] as const;\n\nexport type PackageManagerName = (typeof supportedPackageManagerNames)[number];\n\nexport type PackageManager = {\n name: PackageManagerName;\n version: string;\n};\n\nlet packageManager: PackageManager | undefined;\n\n/**\n * First we check if the package manager is declared in the manifest. If it is,\n * we get the name and version from there. Otherwise we'll search for the\n * different lockfiles and ask the OS to report the installed version.\n */\nexport function detectPackageManager(workspaceRoot: string): PackageManager {\n /**\n * Disable infer from manifest for now. I doubt it is useful after all but\n * I'll keep the code as a reminder.\n */\n // packageManager =\n // inferFromManifest(workspaceRoot) ?? inferFromFiles(workspaceRoot);\n\n packageManager = inferFromFiles(workspaceRoot);\n return packageManager;\n}\n\nfunction inferFromManifest(workspaceRoot: string) {\n const log = createLogger(getConfig().logLevel);\n\n const rootManifest = readTypedJsonSync<PackageManifest>(\n path.join(workspaceRoot, \"package.json\")\n );\n\n if (!rootManifest.packageManager) {\n log.debug(\"No packageManager field found in root manifest\");\n return;\n }\n\n const [name, version = \"*\"] = rootManifest.packageManager.split(\"@\") as [\n PackageManagerName,\n string,\n ];\n\n assert(\n supportedPackageManagerNames.includes(name),\n `Package manager \"${name}\" is not currently supported`\n );\n\n const lockfileName = getLockfileFileName(name);\n\n assert(\n fs.existsSync(path.join(workspaceRoot, lockfileName)),\n `Manifest declares ${name} to be the packageManager, but failed to find ${lockfileName} in workspace root`\n );\n\n return { name, version };\n}\n\nfunction inferFromFiles(workspaceRoot: string): PackageManager {\n for (const name of supportedPackageManagerNames) {\n const lockfileName = getLockfileFileName(name);\n\n if (fs.existsSync(path.join(workspaceRoot, lockfileName))) {\n return { name, version: getVersion(name) };\n }\n }\n\n /**\n * If no lockfile was found, it could be that there is an npm shrinkwrap file.\n */\n if (fs.existsSync(path.join(workspaceRoot, \"npm-shrinkwrap.json\"))) {\n return { name: \"npm\", version: getVersion(\"npm\") };\n }\n\n throw new Error(`Failed to detect package manager`);\n}\n\nfunction getVersion(packageManagerName: PackageManagerName): string {\n const buffer = execSync(`${packageManagerName} --version`);\n return buffer.toString().trim();\n}\n\nexport function usePackageManager() {\n if (!packageManager) {\n throw Error(\n \"No package manager detected. Make sure to call detectPackageManager() before usePackageManager()\"\n );\n }\n\n return packageManager;\n}\n","import fs from \"fs-extra\";\nimport assert from \"node:assert\";\nimport path from \"node:path\";\nimport { createLogger, readTypedYamlSync, writeTypedYamlSync } from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { PackagesRegistry } from \"./create-packages-registry\";\nimport {\n PackageManagerName,\n usePackageManager,\n} from \"./detect-package-manager\";\n\ntype PackagePath = string;\n\ntype PnpmLockfile = {\n lockfileVersion: string;\n importers: Record<\n PackagePath,\n {\n dependencies?: Record<string, unknown>;\n devDependencies?: Record<string, unknown>;\n }\n >;\n};\n\nexport function getLockfileFileName(name: PackageManagerName) {\n switch (name) {\n case \"pnpm\":\n return \"pnpm-lock.yaml\";\n case \"yarn\":\n return \"yarn.lock\";\n case \"npm\":\n return \"package-lock.json\";\n }\n}\n\n/**\n * Adapt the lockfile and write it to the isolate directory. Because we keep the\n * structure of packages in the isolate directory the same as they were in the\n * monorepo, the lockfile is largely still correct. The only things that need to\n * be done is to remove the root dependencies and devDependencies, and rename\n * the path to the target package to act as the new root.\n */\nexport function processLockfile({\n workspaceRootDir,\n targetPackageName,\n packagesRegistry,\n isolateDir,\n}: {\n workspaceRootDir: string;\n targetPackageName: string;\n packagesRegistry: PackagesRegistry;\n isolateDir: string;\n}) {\n const log = createLogger(getConfig().logLevel);\n\n const targetPackageRelativeDir =\n packagesRegistry[targetPackageName].rootRelativeDir;\n\n const { name } = usePackageManager();\n\n const fileName = getLockfileFileName(name);\n\n const lockfileSrcPath = path.join(workspaceRootDir, fileName);\n const lockfileDstPath = path.join(isolateDir, fileName);\n\n switch (name) {\n case \"npm\": {\n /**\n * If there is a shrinkwrap file we copy that instead of the lockfile\n */\n const shrinkwrapSrcPath = path.join(\n workspaceRootDir,\n \"npm-shrinkwrap.json\"\n );\n const shrinkwrapDstPath = path.join(isolateDir, \"npm-shrinkwrap.json\");\n\n if (fs.existsSync(shrinkwrapSrcPath)) {\n fs.copyFileSync(shrinkwrapSrcPath, shrinkwrapDstPath);\n log.debug(\"Copied shrinkwrap to\", shrinkwrapDstPath);\n } else {\n fs.copyFileSync(lockfileSrcPath, lockfileDstPath);\n log.debug(\"Copied lockfile to\", lockfileDstPath);\n }\n\n return;\n }\n case \"yarn\": {\n fs.copyFileSync(lockfileSrcPath, lockfileDstPath);\n log.debug(\"Copied lockfile to\", lockfileDstPath);\n return;\n }\n case \"pnpm\": {\n const origLockfile = readTypedYamlSync<PnpmLockfile>(lockfileSrcPath);\n\n log.debug(\"Read PNPM lockfile, version:\", origLockfile.lockfileVersion);\n\n const adaptedLockfile = structuredClone(origLockfile);\n\n const targetPackageDef =\n adaptedLockfile.importers[targetPackageRelativeDir];\n\n assert(\n targetPackageDef,\n `Failed to find target package in lockfile at importers[${targetPackageRelativeDir}]`\n );\n /**\n * Overwrite the root importer with the target package importer contents\n */\n adaptedLockfile.importers[\".\"] = targetPackageDef;\n\n /**\n * Delete the target package original importer. Not really necessary.\n */\n delete adaptedLockfile.importers[targetPackageRelativeDir];\n\n writeTypedYamlSync(lockfileDstPath, adaptedLockfile);\n\n log.debug(\"Stored adapted lockfile at\", lockfileDstPath);\n\n return;\n }\n }\n}\n","import fs from \"fs-extra\";\nimport path from \"node:path\";\nimport outdent from \"outdent\";\nimport { getConfig } from \"~/helpers\";\nimport { createLogger, readTypedJson } from \"~/utils\";\n\nexport async function getBuildOutputDir(targetPackageDir: string) {\n const config = getConfig();\n const log = createLogger(getConfig().logLevel);\n\n if (config.buildDirName) {\n log.debug(\"Using buildDirName from config:\", config.buildDirName);\n return path.join(targetPackageDir, config.buildDirName);\n }\n\n const tsconfigPath = path.join(targetPackageDir, config.tsconfigPath);\n\n if (fs.existsSync(tsconfigPath)) {\n log.debug(\"Found tsconfig at:\", config.tsconfigPath);\n\n const tsconfig = await readTypedJson<{\n compilerOptions?: { outDir?: string };\n }>(tsconfigPath);\n\n const outDir = tsconfig.compilerOptions?.outDir;\n\n if (outDir) {\n return path.join(targetPackageDir, outDir);\n } else {\n throw new Error(outdent`\n Failed to find outDir in tsconfig. If you are executing isolate from the root of a monorepo you should specify the buildDirName in isolate.config.json.\n `);\n }\n } else {\n log.warn(\"Failed to find tsconfig at:\", tsconfigPath);\n\n throw new Error(outdent`\n Failed to infer the build output directory from either the isolate config buildDirName or a Typescript config file. See the documentation on how to configure one of these options.\n `);\n }\n}\n","import { PackageManifest, PackagesRegistry } from \"./create-packages-registry\";\n\n/**\n * Recursively list the packages from dependencies (and optionally\n * devDependencies) that are found in the workspace.\n *\n * Here we do not need to rely on packages being declared as \"workspace:\" in the\n * manifest. We can simply compare the package names with the list of packages\n * that were found via the workspace glob patterns and added to the registry.\n */\nexport function listLocalDependencies(\n manifest: PackageManifest,\n packagesRegistry: PackagesRegistry,\n { includeDevDependencies = false } = {}\n): string[] {\n const allWorkspacePackageNames = Object.keys(packagesRegistry);\n\n const localDependencyPackageNames = (\n includeDevDependencies\n ? [\n ...Object.keys(manifest.dependencies ?? {}),\n ...Object.keys(manifest.devDependencies ?? {}),\n ]\n : Object.keys(manifest.dependencies ?? {})\n ).filter((name) => allWorkspacePackageNames.includes(name));\n\n const nestedLocalDependencies = localDependencyPackageNames.flatMap(\n (packageName) =>\n listLocalDependencies(\n packagesRegistry[packageName].manifest,\n packagesRegistry,\n { includeDevDependencies }\n )\n );\n\n return localDependencyPackageNames.concat(nestedLocalDependencies);\n}\n","import path from \"node:path\";\nimport { readTypedJson } from \"~/utils\";\nimport { PackageManifest } from \"./create-packages-registry\";\n\nexport async function importManifest(packageDir: string) {\n return readTypedJson<PackageManifest>(path.join(packageDir, \"package.json\"));\n}\n","import assert from \"node:assert\";\nimport { createLogger, pack } from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { PackagesRegistry } from \"./create-packages-registry\";\nimport { usePackageManager } from \"./detect-package-manager\";\n\n/**\n * Pack dependencies so that we extract only the files that are supposed to be\n * published by the packages.\n *\n * @returns A map of package names to the path of the packed file\n */\nexport async function packDependencies({\n /**\n * All packages found in the monorepo by workspaces declaration\n */\n packagesRegistry,\n /**\n * The package names that appear to be local dependencies\n */\n localDependencies,\n /**\n * The directory where the isolated package and all its dependencies will end\n * up. This is also the directory from where the package will be deployed. By\n * default it is a subfolder in targetPackageDir called \"isolate\" but you can\n * configure it.\n */\n packDestinationDir,\n}: {\n packagesRegistry: PackagesRegistry;\n localDependencies: string[];\n packDestinationDir: string;\n}) {\n const config = getConfig();\n const log = createLogger(config.logLevel);\n\n const packedFileByName: Record<string, string> = {};\n\n const { name, version } = usePackageManager();\n\n const versionMajor = parseInt(version.split(\".\")[0], 10);\n\n const usePnpmPack =\n !config.avoidPnpmPack && name === \"pnpm\" && versionMajor >= 8;\n\n if (usePnpmPack) {\n log.debug(\"Using PNPM pack instead of NPM pack\");\n }\n\n for (const dependency of localDependencies) {\n const def = packagesRegistry[dependency];\n\n assert(dependency, `Failed to find package definition for ${dependency}`);\n\n const { name } = def.manifest;\n\n /**\n * If this dependency has already been packed, we skip it. It could happen\n * because we are packing workspace dependencies recursively.\n */\n if (packedFileByName[name]) {\n log.debug(`Skipping ${name} because it has already been packed`);\n continue;\n }\n\n packedFileByName[name] = await pack(\n def.absoluteDir,\n packDestinationDir,\n usePnpmPack\n );\n }\n\n return packedFileByName;\n}\n","import path from \"node:path\";\nimport { createLogger } from \"~/utils\";\nimport { getConfig } from \"./config\";\nimport { PackagesRegistry } from \"./create-packages-registry\";\n\nexport function patchWorkspaceEntries(\n dependencies: Record<string, string>,\n packagesRegistry: PackagesRegistry,\n parentRootRelativeDir?: string\n) {\n const log = createLogger(getConfig().logLevel);\n const allWorkspacePackageNames = Object.keys(packagesRegistry);\n\n return Object.fromEntries(\n Object.entries(dependencies).map(([key, value]) => {\n if (allWorkspacePackageNames.includes(key)) {\n const def = packagesRegistry[key];\n\n /**\n * When nested shared dependencies are used (local deps linking to other\n * local deps), the parentRootRelativeDir will be passed in, and we\n * store the relative path to the isolate/packages directory, as is\n * required by some package managers.\n *\n * For consistency we also write the other file paths starting with\n * ./, but it doesn't seem to be necessary for any package manager.\n */\n const relativePath = parentRootRelativeDir\n ? path.relative(parentRootRelativeDir, `./${def.rootRelativeDir}`)\n : `./${def.rootRelativeDir}`;\n\n const linkPath = `file:${relativePath}`;\n\n log.debug(`Linking dependency ${key} to ${linkPath}`);\n\n return [key, linkPath];\n } else {\n return [key, value];\n }\n })\n );\n}\n","import fs from \"fs-extra\";\nimport path from \"node:path\";\nimport { createLogger, pack, unpack } from \"~/utils\";\nimport { getConfig } from \"./config\";\n\nconst TIMEOUT_MS = 5000;\n\nexport async function processBuildOutputFiles({\n targetPackageDir,\n tmpDir,\n isolateDir,\n}: {\n targetPackageDir: string;\n tmpDir: string;\n isolateDir: string;\n}) {\n const log = createLogger(getConfig().logLevel);\n const packedFilePath = await pack(targetPackageDir, tmpDir);\n const unpackDir = path.join(tmpDir, \"target\");\n\n const now = Date.now();\n let isWaitingYet = false;\n\n while (!fs.existsSync(packedFilePath) && Date.now() - now < TIMEOUT_MS) {\n if (!isWaitingYet) {\n log.debug(`Waiting for ${packedFilePath} to become available...`);\n }\n isWaitingYet = true;\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n\n await unpack(packedFilePath, unpackDir);\n await fs.copy(path.join(unpackDir, \"package\"), isolateDir);\n}\n","import fs from \"fs-extra\";\nimport path, { join } from \"node:path\";\nimport { getIsolateRelativePath } from \"~/utils\";\nimport { createLogger } from \"~/utils/logger\";\nimport { PackagesRegistry, getConfig } from \".\";\nimport { unpack } from \"../utils/unpack\";\n\nexport async function unpackDependencies(\n packedFilesByName: Record<string, string>,\n packagesRegistry: PackagesRegistry,\n tmpDir: string,\n isolateDir: string\n) {\n const log = createLogger(getConfig().logLevel);\n\n await Promise.all(\n Object.entries(packedFilesByName).map(async ([packageName, filePath]) => {\n const dir = packagesRegistry[packageName].rootRelativeDir;\n const unpackDir = join(tmpDir, dir);\n\n log.debug(\"Unpacking\", `(temp)/${path.basename(filePath)}`);\n\n await unpack(filePath, unpackDir);\n\n const destinationDir = join(isolateDir, dir);\n\n await fs.ensureDir(destinationDir);\n\n await fs.move(join(unpackDir, \"package\"), destinationDir, {\n overwrite: true,\n });\n\n log.debug(\n `Moved package files to ${getIsolateRelativePath(\n destinationDir,\n isolateDir\n )}`\n );\n })\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,IACA;AAAA,IACA,oBAAoB;AAAA,EACtB,CAAC;AAED,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAKA,QAAM,mBAAmB,mBAAmB,kBAAkB,UAAU;AAKxE,QAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAMD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,OAAO,iBAAiB;AAC1B,QAAI,KAAK,gDAAgD;AAAA,EAC3D,OAAO;AAIL,UAAM,gBAAgB;AAAA,MACpB;AAAA,MACA,mBAAmB,sBAAsB;AAAA,MACzC;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AASA,QAAM,YAAYH,OAAK,KAAK,kBAAkB,QAAQ;AAEtD,MAAIE,KAAG,WAAW,SAAS,GAAG;AAC5B,IAAAA,KAAG,aAAa,WAAWF,OAAK,KAAK,YAAY,QAAQ,CAAC;AAC1D,QAAI,MAAM,0CAA0C;AAAA,EACtD;AAMA,MAAI;AAAA,IACF;AAAA,IACA,oBAAoB,QAAQ,gBAAgB;AAAA,EAC9C;AACA,QAAME,KAAG,OAAO,MAAM;AAEtB,MAAI,KAAK,wBAAwB,UAAU;AAC7C;AAEA,MAAM,EAAE,MAAM,CAAC,QAAQ;AACrB,MAAI,eAAe,OAAO;AACxB,QAAI,MAAM,IAAI,KAAK;AACnB,YAAQ,KAAK,CAAC;AAAA,EAChB,OAAO;AACL,YAAQ,MAAM,GAAG;AAAA,EACnB;AACF,CAAC;AAED,QAAQ,GAAG,sBAAsB,IAAI,KAAK;","names":["fs","assert","path","path","fs","fs","fs","path","log","stdout","path","fs","fs","fs","fs","fs","path","fs","path","fs","path","log","path","fs","config","fs","path","assert","path","fs","assert","path","fs","path","log","path","fs","fs","path","log","packageManager","path","assert","log","fs","path","fs","path","config","log","path","fs","path","assert","config","log","assert","name","path","log","path","fs","path","log","path","fs","fs","path","log","path","fs","path","assert","fs","packageManager"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isolate-package",
|
|
3
|
-
"version": "1.3.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Isolate a monorepo package by bundling the build output with its shared workspace packages and lock file to form a self-contained directory.",
|
|
5
5
|
"author": "Thijs Koerselman",
|
|
6
6
|
"license": "MIT",
|