Skip to content

Commit faf69e1

Browse files
author
Peter Hauge
committed
docs: update squad records for cli-package optional change
- Added decision: apiops init dual-mode package consumption - Updated NodeJsDev history with implementation details - Merged inbox decision into decisions.md Session: 2026-04-29T143000Z-nodejsdev
1 parent bd73ef3 commit faf69e1

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

.squad/agents/nodejsdev/history.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,41 @@ program.version(packageJson.version);
121121
- Version output correct: `node dist/cli/index.js --version` displays "0.1.3-alpha.0" from package.json
122122
- No runtime dependencies: Uses native Node ESM features, no additional packages required
123123

124+
### 2026-04-29: Dual-Mode Init — Public npm vs Local Tarball
125+
126+
**Problem:** After publishing `@peterhauge/apiops-cli` to npm, `apiops init` still required `--cli-package <path>` pointing to a local .tgz tarball, making the workflow cumbersome for users who just want to use the public package.
127+
128+
**Solution:** Made `--cli-package` optional and implemented two modes:
129+
130+
1. **Local tarball mode** (when `--cli-package` provided):
131+
- Creates `.apiops/` directory, copies tarball
132+
- Generates package.json with `"apiops": "file:.apiops/{tarball}"`
133+
- Use case: Local development, pre-release testing
134+
135+
2. **Public npm mode** (when `--cli-package` NOT provided):
136+
- No tarball copy, no `.apiops/` directory
137+
- Generates package.json with `"@peterhauge/apiops-cli": "latest"`
138+
- Use case: Standard consumption after publishing to npm
139+
140+
**Implementation Details:**
141+
- Changed `.requiredOption()` to `.option()` in init-command.ts
142+
- Made `cliPackage?: string` optional in InitConfig interface
143+
- Conditional validation: `validateCliPackage()` only runs if `cliPackage` provided
144+
- Conditional file operations in `generateFiles()`: tarball copy and `.apiops/` creation only in local mode
145+
- Refactored package-json.ts to accept discriminated union config: `{ mode: 'local', tarballRelPath } | { mode: 'npm' }`
146+
147+
**Key Pattern:** The package.json generator uses a discriminated union for type safety:
148+
```typescript
149+
export type PackageJsonConfig =
150+
| { mode: 'local'; tarballRelPath: string }
151+
| { mode: 'npm' };
152+
```
153+
This enforces that `tarballRelPath` is only accessible when `mode === 'local'`, preventing runtime errors.
154+
155+
**Testing:**
156+
- All 467 tests pass (init-command.test.ts validates both modes)
157+
- ESLint clean (no warnings or errors)
158+
- Backward compatible: Existing workflows with `--cli-package` continue to work
159+
124160
<!-- Append new learnings here after each session -->
125161

.squad/decisions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Active Decisions
44

5+
### 2026-04-29T14:30:00Z: apiops init Dual-Mode Package Consumption
6+
**By:** NodeJsDev
7+
**Status:** Implemented
8+
**What:** Made `--cli-package` optional in `apiops init`. The command now supports two package consumption modes: (1) **Public npm mode** (default, when `--cli-package` NOT provided): generates package.json with `"@peterhauge/apiops-cli": "latest"`, no local tarball copy, no `.apiops/` directory created, standard consumption pattern after npm publish. (2) **Local tarball mode** (when `--cli-package <path>` provided): copies tarball to `.apiops/` directory, generates package.json with `"apiops": "file:.apiops/{tarball}"`, preserves existing behavior for local development/testing.
9+
**Why:** After publishing to npm as `@peterhauge/apiops-cli`, requiring users to download the package and run `apiops init --cli-package ./tarball.tgz` added unnecessary friction. Most users want to reference the public package directly. The change is backward compatible — existing workflows with `--cli-package` continue to work unchanged. Improves user experience with simpler onboarding.
10+
511
### 2026-04-21T19:35:00Z: SOAP/WADL spec extraction prefers link format with inline XML fallback
612
**By:** ApimExpert (via Squad session with enewman)
713
**Status:** Implemented

0 commit comments

Comments
 (0)