Skip to content

ref: align monorepo infrastructure with amplify-backend patterns - #22

Open
cabcookie wants to merge 47 commits into
alphafrom
ref/apply-amplify-monorepo-structure
Open

cabcookie wants to merge 47 commits into
alphafrom
ref/apply-amplify-monorepo-structure

Conversation

@cabcookie

Copy link
Copy Markdown
Member

Summary

  • Phase 1: Migrate from pnpm to npm workspaces, add husky + lint-staged, update amplify.yml, tighten biome rules (noDefaultExport, useNodejsImportProtocol, noStaticOnlyClass)
  • Phase 2: Replace tsup with tsc composite builds, switch output from dist/ to lib/ (ESM-only), add Microsoft API Extractor for public API tracking
  • Phase 3: Migrate all 12 test files (109 tests) from vitest to Node test runner (node:test + node:assert), add c8 coverage config with 85% thresholds
  • Phase 4: Port 30+ build infrastructure scripts from amplify-backend (validation, test runner, API change detection, publishing, verdaccio, utilities)
  • Phase 5: Add comprehensive GitHub Actions CI (health_checks.yml with 15+ jobs), composite actions for caching, 6 supporting workflows (canary, snapshot, deprecate/restore, E2E cleanup), CODEOWNERS, dependabot, issue/PR templates
  • Phase 6: Add multi-account E2E infrastructure (OIDC federation docs, E2E scripts, composite actions, wired into health_checks)
  • Phase 7: Update CLAUDE.md, Claude Code skills (commit, versioning, cdk-construct, cdk-testing), and Claude Code permissions for npm

Validation

  • All 109 unit/construct tests pass with Node test runner
  • Build succeeds for both publishable packages (tsc composite → lib/)
  • API Extractor generates API.api.md reports successfully
  • Pre-commit hook runs (update:tsconfig-refs, check:package-lock, lint-staged)
  • Alpha/beta branch workflow supported in CI triggers and publish jobs

Checklist

  • If this PR includes a functional change, I have added or updated automated test coverage.
  • If this PR requires a docs update, I have linked to that docs PR above.
  • If this PR modifies E2E tests or resource provisioning, I have set the run-e2e label.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

🤖 Generated with Claude Code

cabcookie and others added 30 commits April 16, 2026 08:51
Seven-phase plan to align amplify-overtone infrastructure with
amplify-backend patterns: npm workspaces, tsc, Node test runner,
API Extractor, comprehensive CI/CD, and multi-account E2E.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7-phase plan with 23 tasks covering npm migration, tsc builds,
Node test runner, scripts infrastructure, CI/CD overhaul,
multi-account E2E, and documentation updates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove pnpm-workspace.yaml and pnpm-lock.yaml. Replace root package.json
with npm workspace configuration including all monorepo scripts. Replace
workspace:* with * in integration-tests for npm resolution. Generate
package-lock.json.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Remove corepack/pnpm setup, use npm ci and npm run. Fix lint-staged
to remove yml (not supported by biome).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add useNodejsImportProtocol, noDefaultExport, noStaticOnlyClass.
Add overrides for config files and website. Update file ignores.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Node16 module resolution, strict mode, composite builds matching
amplify-backend patterns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Set rootDir/outDir for publishable packages. Set noEmit for private
packages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove tsup configs and dependency from both publishable packages.
Switch to ESM-only output in lib/. Update package.json exports and
files fields. Fix rootDir/include for test file exclusion. Fix
Node16 module resolution issues in test-infra, website, and docs
tsconfigs. Add missing tsconfig stubs for docs and test-import packages.

Co-Authored-By: Claude <noreply@anthropic.com>
Generate API.api.md files for amplify-overtone and amplify-overtone-client.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Convert all 12 test files to node:test + node:assert. Remove vitest
dependency. Use aws-sdk-client-mock directly in handler.test.ts instead
of vi.mock() to work with tsx's ESM loader.

Co-Authored-By: Claude <noreply@anthropic.com>
Port package_json, git_client, npm_client, github_client from
amplify-backend. Adapted for overtone package structure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port check_no_git_diff, check_package_json, check_package_lock,
check_package_versions, check_dependencies, check_pr_size, and
check_changeset_completeness from amplify-backend.

Co-Authored-By: Claude <noreply@anthropic.com>
Port run_tests.ts and get_unit_test_dir_list.ts from amplify-backend.
run_tests.ts wraps tsx --test with spec reporter and handles Node 21+
CLI flag differences. get_unit_test_dir_list.ts lists package dirs with
unit tests, excluding integration-tests, test-infra, and other non-test
packages.

Co-Authored-By: Claude <noreply@anthropic.com>
Port check_api_extract, check_api_changes, and api-changes-validator
module from amplify-backend.

Co-Authored-By: Claude <noreply@anthropic.com>
Port publish, version, verdaccio, deprecate, and restore scripts from
amplify-backend. Add verdaccio.config.yaml for local npm proxy.
Extend git_client with getNearestReleaseCommit and getPreviousReleaseTags.
Update npm_client to support local registry (null token).

Co-Authored-By: Claude <noreply@anthropic.com>
Generalize tsconfig.tsbuildinfo ignore pattern for all packages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port copy_template, update_tsconfig_refs, concurrent_workspace_script,
setup_test_project. Wire pre-commit to run tsconfig-refs check and
package-lock validation.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Comprehensive CI workflow with install/build caching, test matrix,
lint, dependency review, API validation, CodeQL, version management,
and npm publishing. Weekly schedule.

Co-Authored-By: Claude <noreply@anthropic.com>
Add canary_checks (every other day), snapshot_release, deprecate/restore
release, e2e_resource_cleanup placeholder, and issue-pending-response.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
OIDC federation, dual role pattern, IAM policies, and step-by-step
preparation for multi-account E2E testing.

Co-Authored-By: Claude <noreply@anthropic.com>
Port select_e2e_test_account, cleanup_e2e_resources,
generate_sparse_test_matrix, do_include_e2e from amplify-backend.
Also adds sparse_test_matrix_generator component and registers
required AWS SDK clients as root devDependencies.

Co-Authored-By: Claude <noreply@anthropic.com>
Add empty references arrays from update_tsconfig_refs script.
Apply biome formatting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Add do_include_e2e gate, e2e_tests job matrix, and daily resource
cleanup across regions.

Co-Authored-By: Claude <noreply@anthropic.com>
Reflect npm, tsc, Node test runner, API Extractor, verdaccio, and
updated script conventions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update commit, versioning, cdk-construct-development, cdk-testing,
and amplify-custom-resources skills to reflect npm, tsc, Node test
runner, and API Extractor.

Co-Authored-By: Claude <noreply@anthropic.com>
cabcookie and others added 8 commits April 16, 2026 08:51
Replace pnpm permissions with npm equivalents. Add api-extractor,
c8, changeset, husky, tsx permissions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
JSON.stringify uses expanded formatting (e.g. single-element arrays on
multiple lines) that differs from Biome's canonical output. This caused
tsconfig.json files to flip-flop on every commit as the pre-commit hook
ran the update script then lint-staged reformatted staged files.

Run Biome format on all written tsconfig files after updating references
so the script output matches the project formatter.

Co-Authored-By: Claude <noreply@anthropic.com>
Add alpha and beta to PR and push triggers. Add publish_prerelease
job for alpha/beta pushes (runs changeset publish directly).
Update versioning skill CI references.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Export emailAction and userId from the public entry point with @internal
tags so api-extractor can resolve their types without raising
ae-forgotten-export warnings. Both functions remain implementation
details of the n namespace and are excluded from the public API surface.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update construct.ts comment (dist→lib, pnpm→npm/pnpm/yarn),
test_infra_config.ts error messages, READMEs (show npm/pnpm/yarn
install options), CONTRIBUTING.md (full npm migration), and
AWS access docs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extend copy-docs.mjs to also transform API Extractor reports from both
published packages into Fumadocs-compatible markdown pages under
public/docs/api-reference/. Normalizes CRLF line endings before parsing
the TypeScript code fence, strips trailing comment lines, and prepends
YAML frontmatter with title and description.

Co-Authored-By: Claude <noreply@anthropic.com>
@cabcookie
cabcookie force-pushed the ref/apply-amplify-monorepo-structure branch from 521d72b to 94af0c8 Compare April 16, 2026 06:57
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.


// Persist updated cache.
hashCache[commandCacheKey] = commandHashCache;
await fsp.writeFile(cacheFilePath, `${JSON.stringify(hashCache, null, 2)}\n`);
throw new Error("E2E_TEST_ACCOUNTS must be a non-empty JSON array");
}

const selectedAccount = accounts[Math.floor(Math.random() * accounts.length)];

const selectedAccount = accounts[Math.floor(Math.random() * accounts.length)];

console.log(JSON.stringify(selectedAccount));
cabcookie and others added 9 commits April 16, 2026 09:08
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Update fumadocs-core/content import to fumadocs-core/content/md
  (subpath changed in fumadocs-core v16)
- Write transformed API docs to packages/docs/api-reference/ so
  Fumadocs discovers them for route generation, not just public/docs/
- Run transform before copy so generated files are included in the
  static copy pass
- Gitignore generated API reference markdown files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Combine comment and blank line removal into a single loop so
interleaved blank lines between comment blocks are handled.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Exclude test-projects/*/amplify from integration-tests typecheck
(template callbacks have implicit any from schema type inference).
Add hasPackageJson helper and filter package globs in check scripts
to skip directories without package.json (e.g. docs). Remove stale
test-import exclusion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TODO: Revert to 1000 after this PR is merged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix lint-staged to exclude lockfile from biome formatting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
test-infra, website, docs, and integration-tests have composite: false
and depend on generated files ($amplify/env) or framework-specific
types (fumadocs) that don't exist in CI. Only build the two
publishable packages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
npm ls exits non-zero for extraneous/invalid hoisted packages in
workspaces but still produces valid JSON. Use reject: false so
execa doesn't throw — the script only needs the dependency tree,
not the exit code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants