|
| 1 | +--- |
| 2 | +name: makage-overview |
| 3 | +description: Reference for the makage CLI tool — build helper, asset management, workspace updates, and cross-repo dependency synchronization. Use when asked about makage commands, monorepo builds, update-deps, or cross-repo dependency workflows. |
| 4 | +--- |
| 5 | + |
| 6 | +# makage |
| 7 | + |
| 8 | +Tiny, zero-dependency build helper for monorepo packages. Replaces `cpy`, `rimraf`, and `copyfiles` with a single CLI. |
| 9 | + |
| 10 | +**Source:** <https://github.com/constructive-io/makage> |
| 11 | +**npm:** `makage` (published from `packages/makage/dist`) |
| 12 | + |
| 13 | +## CLI Commands |
| 14 | + |
| 15 | +| Command | Description | |
| 16 | +|---------|-------------| |
| 17 | +| `makage build [--dev]` | Full build: clean + build-ts + assets. `--dev` adds `--declarationMap` | |
| 18 | +| `makage clean [path...]` | Remove directories (defaults to `dist`) | |
| 19 | +| `makage build-ts [--dev]` | TypeScript compilation for CJS + ESM | |
| 20 | +| `makage copy [...sources] <dest> [--flat] [--footer]` | Copy files with glob support | |
| 21 | +| `makage assets` | Copy LICENSE + package.json + README+FOOTER to dist | |
| 22 | +| `makage readme-footer --source <f> --footer <f> --dest <f>` | Concatenate README with footer | |
| 23 | +| `makage update-workspace` | Convert internal deps to `workspace:*` protocol | |
| 24 | +| `makage update-deps --from <source> --in <target>` | Cross-repo dependency detection (JSON output) | |
| 25 | + |
| 26 | +## Cross-Repo Dependency Updates (`update-deps`) |
| 27 | + |
| 28 | +### Purpose |
| 29 | + |
| 30 | +Deterministic, version-aware dependency synchronization across repositories. This is the engine behind the [constructive-hub update-constructive-deps workflow](https://github.com/constructive-io/constructive-hub/blob/main/.github/workflows/update-constructive-deps.yml). |
| 31 | + |
| 32 | +### Usage |
| 33 | + |
| 34 | +```bash |
| 35 | +makage update-deps --from <path-to-source-workspace> --in <path-to-target-repo> |
| 36 | +``` |
| 37 | + |
| 38 | +### Algorithm |
| 39 | + |
| 40 | +1. Reads `pnpm-workspace.yaml` from `--from` to discover all packages + versions |
| 41 | +2. Scans all `package.json` files in `--in` (supports workspace and non-workspace repos) |
| 42 | +3. Cross-references dependencies/devDependencies/peerDependencies/optionalDependencies |
| 43 | +4. Strips `^`/`~`/`>=` prefixes and compares semver parts numerically |
| 44 | +5. Skips `workspace:` protocol deps (always in sync) |
| 45 | +6. Outputs structured JSON to stdout; logs to stderr |
| 46 | + |
| 47 | +### JSON Output Schema |
| 48 | + |
| 49 | +```json |
| 50 | +{ |
| 51 | + "sourcePackages": [{ "name": "string", "version": "string", "path": "string" }], |
| 52 | + "matchedPackages": [{ |
| 53 | + "name": "string", |
| 54 | + "currentVersion": "string", |
| 55 | + "availableVersion": "string", |
| 56 | + "depType": "dependencies | devDependencies | peerDependencies | optionalDependencies", |
| 57 | + "consumer": "string", |
| 58 | + "outdated": "boolean" |
| 59 | + }], |
| 60 | + "outdatedPackages": [/* subset of matchedPackages where outdated=true */], |
| 61 | + "has_dep_changes": "boolean" |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +### CI Workflow Integration |
| 66 | + |
| 67 | +The `update-constructive-deps` workflow in `constructive-hub` runs per target repo: |
| 68 | + |
| 69 | +1. Checks out target repo + `constructive` workspace side by side |
| 70 | +2. Runs `makage update-deps --from ./constructive --in .` |
| 71 | +3. Parses JSON → extracts outdated package names |
| 72 | +4. **Workspace repos** (`constructive-db`, `dashboard`, `pgpm-modules`, `dev-utils`): |
| 73 | + - `echo "$OUTDATED_NAMES" | xargs pnpm update -r --latest` |
| 74 | + - `pnpm install --no-frozen-lockfile` (sync lockfile) |
| 75 | + - `pnpm -r build` (rebuild) |
| 76 | +5. **Non-workspace repos** (`sandbox-templates`, `pgpm-boilerplates`): |
| 77 | + - Per-directory: if lockfile exists → `pnpm update --latest $name` |
| 78 | + - If no lockfile → `jq` to set `^<version>` directly in `package.json` |
| 79 | +6. Creates branch `deps-update/<name-or-timestamp>` and opens PR |
| 80 | +7. For `constructive-db`: chains schema propagation via `repository_dispatch` |
| 81 | + |
| 82 | +### Triggers |
| 83 | + |
| 84 | +- **Manual** (`workflow_dispatch`): select which repos to update, optional PR name |
| 85 | +- **Automatic** (`repository_dispatch: constructive-published`): fires when constructive publishes |
| 86 | + |
| 87 | +### Target Repos |
| 88 | + |
| 89 | +| Repo | Type | Default | |
| 90 | +|------|------|---------| |
| 91 | +| `constructive-db` | workspace | enabled (also triggers schema propagation) | |
| 92 | +| `dashboard` | workspace | disabled | |
| 93 | +| `pgpm-modules` | workspace | disabled | |
| 94 | +| `dev-utils` | workspace | disabled | |
| 95 | +| `sandbox-templates` | non-workspace | disabled | |
| 96 | +| `pgpm-boilerplates` | non-workspace | disabled | |
| 97 | + |
| 98 | +## Monorepo Conventions |
| 99 | + |
| 100 | +makage assumes the following structure: |
| 101 | + |
| 102 | +- Build output in `dist/` |
| 103 | +- pnpm workspace protocol for internal dependencies |
| 104 | +- `publishConfig.directory` set to `dist` in `package.json` |
| 105 | +- Shared `LICENSE` at monorepo root |
| 106 | +- Optional `FOOTER.md` per package (appended to README before publish) |
| 107 | + |
| 108 | +## Key Files |
| 109 | + |
| 110 | +| Path | Purpose | |
| 111 | +|------|---------| |
| 112 | +| `packages/makage/src/cli.ts` | CLI entrypoint and command dispatch | |
| 113 | +| `packages/makage/src/commands/updateDeps.ts` | Cross-repo dependency detection logic | |
| 114 | +| `packages/makage/src/commands/updateWorkspace.ts` | Workspace protocol updater | |
| 115 | +| `packages/makage/src/commands/build.ts` | Build orchestration | |
| 116 | +| `packages/makage/src/commands/copy.ts` | File copy with glob + flatten | |
| 117 | +| `packages/makage/src/commands/clean.ts` | Directory removal | |
| 118 | +| `packages/makage/src/commands/assets.ts` | Asset copy helper | |
| 119 | +| `packages/makage/src/commands/buildTs.ts` | TypeScript CJS + ESM compilation | |
| 120 | +| `packages/makage/src/commands/readmeFooter.ts` | README + FOOTER concatenation | |
0 commit comments