-
-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathbundleWorkspaceDeps.mjs
More file actions
42 lines (35 loc) · 1.22 KB
/
bundleWorkspaceDeps.mjs
File metadata and controls
42 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { resolve } from 'node:path';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import {
bundleWorkspacePackages,
findRepoRoot,
vendorBundledPackageRuntimeDependencies,
} from '../../../packages/cli-common/dist/workspaces/index.js';
import { createBundledWorkspaceBundles } from './workspaceBundleManifest.mjs';
const __dirname = dirname(fileURLToPath(import.meta.url));
export function bundleWorkspaceDeps(opts = {}) {
const repoRoot = opts.repoRoot ?? findRepoRoot(__dirname);
const happyCliDir = opts.happyCliDir ?? resolve(repoRoot, 'apps', 'cli');
const bundles = createBundledWorkspaceBundles({ repoRoot, targetRoot: happyCliDir });
bundleWorkspacePackages({ bundles });
for (const b of bundles) {
vendorBundledPackageRuntimeDependencies({
srcPackageJsonPath: resolve(b.srcDir, 'package.json'),
destPackageDir: b.destDir,
});
}
}
const invokedAsMain = (() => {
const argv1 = process.argv[1];
if (!argv1) return false;
return resolve(argv1) === fileURLToPath(import.meta.url);
})();
if (invokedAsMain) {
try {
bundleWorkspaceDeps();
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exit(1);
}
}