|
| 1 | +/** |
| 2 | + * Canonical list of workspace packages that are bundled into the CLI npm package. |
| 3 | + * |
| 4 | + * This module is the single source of truth consumed by both the build step |
| 5 | + * (`buildSharedDeps.mjs`) and the bundle step (`bundleWorkspaceDeps.mjs`). |
| 6 | + * Adding or removing a package here automatically keeps both steps in sync. |
| 7 | + */ |
| 8 | + |
1 | 9 | import { resolve } from 'node:path'; |
2 | 10 |
|
| 11 | +/** |
| 12 | + * Frozen array of all workspace packages that must be compiled and bundled |
| 13 | + * during `yarn prepack`. Each entry is itself frozen to prevent accidental |
| 14 | + * mutation that could desync the derived exports. |
| 15 | + * |
| 16 | + * @type {ReadonlyArray<{dirName: string, packageName: string}>} |
| 17 | + */ |
3 | 18 | export const bundledWorkspacePackages = Object.freeze([ |
4 | | - { dirName: 'agents', packageName: '@happier-dev/agents' }, |
5 | | - { dirName: 'cli-common', packageName: '@happier-dev/cli-common' }, |
6 | | - { dirName: 'protocol', packageName: '@happier-dev/protocol' }, |
7 | | - { dirName: 'release-runtime', packageName: '@happier-dev/release-runtime' }, |
| 19 | + Object.freeze({ dirName: 'agents', packageName: '@happier-dev/agents' }), |
| 20 | + Object.freeze({ dirName: 'cli-common', packageName: '@happier-dev/cli-common' }), |
| 21 | + Object.freeze({ dirName: 'protocol', packageName: '@happier-dev/protocol' }), |
| 22 | + Object.freeze({ dirName: 'release-runtime', packageName: '@happier-dev/release-runtime' }), |
8 | 23 | ]); |
9 | 24 |
|
| 25 | +/** |
| 26 | + * Frozen array of directory names derived from {@link bundledWorkspacePackages}. |
| 27 | + * Matches the subdirectory names under `packages/` in the monorepo root. |
| 28 | + * |
| 29 | + * @type {ReadonlyArray<string>} |
| 30 | + */ |
10 | 31 | export const bundledWorkspaceDirNames = Object.freeze( |
11 | 32 | bundledWorkspacePackages.map(({ dirName }) => dirName), |
12 | 33 | ); |
13 | 34 |
|
| 35 | +/** |
| 36 | + * Frozen array of npm package names derived from {@link bundledWorkspacePackages}. |
| 37 | + * Must stay in sync with the `bundledDependencies` field in `apps/cli/package.json`. |
| 38 | + * |
| 39 | + * @type {ReadonlyArray<string>} |
| 40 | + */ |
14 | 41 | export const bundledWorkspacePackageNames = Object.freeze( |
15 | 42 | bundledWorkspacePackages.map(({ packageName }) => packageName), |
16 | 43 | ); |
17 | 44 |
|
| 45 | +/** |
| 46 | + * Creates the bundle descriptor objects used by `bundleWorkspaceDeps.mjs`. |
| 47 | + * Each descriptor maps a workspace package to its source directory (in the |
| 48 | + * monorepo) and the destination directory under `apps/cli/node_modules`. |
| 49 | + * |
| 50 | + * @param {{ repoRoot: string, happyCliDir: string }} opts |
| 51 | + * @returns {Array<{ packageName: string, srcDir: string, destDir: string }>} |
| 52 | + */ |
18 | 53 | export function createBundledWorkspaceBundles({ repoRoot, happyCliDir }) { |
19 | 54 | return bundledWorkspacePackages.map(({ dirName, packageName }) => ({ |
20 | 55 | packageName, |
|
0 commit comments