-
Notifications
You must be signed in to change notification settings - Fork 0
Issue240 #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue240 #13
Conversation
- Added a depth argument to the git clone command for a shallow clone to enhance performance.
Remove CLI entry point from create-gen-app package to make it a pure library API. The CLI implementation and tests are now housed in the create-gen-app-test package for integration testing purposes. Changes: - Remove src/cli.ts and __tests__/cli.test.ts from create-gen-app - Remove bin field and minimist dependencies from create-gen-app/package.json - Update README.md to clarify that the published package is API-only - Port CLI code to create-gen-app-test/src/cli.ts - Add CLI tests to create-gen-app-test/src/__tests__/cli.test.ts - Add minimist and inquirerer dependencies to create-gen-app-test - Update CLI imports to use create-gen-app library APIs This separation ensures create-gen-app remains focused on its core template generation functionality while maintaining CLI testing capabilities in the dedicated test harness package.
…rootDir error Move integration-helpers.ts from create-gen-app/test-utils to create-gen-app-test/src/test-utils to resolve TS6059 error where files outside rootDir cannot be imported during build. Changes: - Copy integration-helpers.ts to create-gen-app-test/src/test-utils/ - Update cli.test.ts import path to use local test-utils - Update cached-template.test.ts.snap to reflect latest template structure This ensures all source files are within the package's rootDir boundary, fixing the CI build error: "File is not under 'rootDir'".
Relocate the development helper script from create-gen-app to create-gen-app-test to keep the main package API-only. The dev script now lives alongside other CLI tooling in the test harness package. Changes: - Move dev/index.ts and dev/README.md to create-gen-app-test/dev/ - Update dev script imports to use create-gen-app workspace package - Remove dev script from create-gen-app/package.json - Add dev script to create-gen-app-test/package.json - Update create-gen-app README to remove dev/README reference This ensures create-gen-app remains focused on its core library functionality while development tooling is consolidated in the test package.
Add built-in template caching to avoid repeated git clones from GitHub. Templates are cached locally using appstash, significantly speeding up subsequent runs when using the same repository and branch. Changes: - Add cache.ts helper with getCachedRepo/cloneToCache/prepareTemplateDirectory - Extend CreateGenOptions with optional cache configuration (toolName, baseDir, enabled) - Update cloneRepo to support cache-aware cloning - Integrate caching into createGen pipeline with cache-first logic - Add cache.test.ts with isolated temp baseDir to avoid touching user's home - Update README with caching documentation and usage examples - Add appstash dependency to package.json The cache is enabled by default and stores repositories under ~/.<toolName>/cache/repos. Tests use temporary directories (via baseDir) to prevent pollution of the developer's home directory, following the pattern from appstash tests.
Fix test assertions to align with camelCase variable extraction (e.g., projectName instead of PROJECT_NAME). Also fix cache test spy issue. Changes: - Update extractVariables tests to expect camelCase variable names - Fix promptUser tests to use correct answer key names (fullName, moduleDesc) - Update cloneRepo tests to allow --depth 1 flag in git clone commands - Fix replaceVariables tests to use camelCase answer keys - Replace execSync spy in cache.test.ts with console.log assertion to avoid "Cannot redefine property" error All tests now correctly validate the camelCase variable naming convention used throughout the codebase.
| MODULENAME: `Test Module ${suffix}`, | ||
| MODULEDESC: `Integration test module ${suffix}`, | ||
| REPONAME: `integration-${safeSuffix}`, | ||
| USERNAME: `tester-${safeSuffix}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these ALL CAPS?
| import { CacheOptions } from "./types"; | ||
| import { cloneRepo, normalizeGitUrl } from "./clone"; | ||
|
|
||
| const DEFAULT_TOOL = "pgpm"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be configured in a constructor or similar
| 'Unknown Author'; | ||
| getAnswer(answers, [ | ||
| "USERFULLNAME", | ||
| "AUTHOR", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ALL CAPS again?
| /** | ||
| * Options that control template caching behavior | ||
| */ | ||
| export interface CacheOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually envisioning some of this in another package, but I think we may be able to make it work
Summary
This PR refactors
create-gen-appto be a pure API library by moving all CLI tooling tocreate-gen-app-test, and adds built-in template caching usingappstashto improve performance.Changes
Architecture Refactoring
Separate CLI from library: Moved CLI implementation (
src/cli.ts) and tests fromcreate-gen-apptocreate-gen-app-testpackagecreate-gen-appis now API-only, suitable for programmatic usecreate-gen-app-testfor integration testingbinfield andminimistdependency fromcreate-gen-appMove dev helper script: Relocated
dev/index.tsanddev/README.mdtocreate-gen-app-test/dev/Fix TypeScript build errors: Moved
integration-helpers.tstocreate-gen-app-test/src/test-utils/to resolverootDirboundary issuesNew Features
Template caching with appstash: Added built-in caching to avoid repeated
git cloneoperations~/.<toolName>/cache/reposusingappstashCreateGenOptions.cache(toolName, baseDir, enabled)Git clone optimizations:
--depth 1for shallow clones (already implemented)--single-branchwhen branch is specifiedBug Fixes
PROJECT_NAMEtoprojectNameformatcloneRepotests to allow--depth 1flagexecSyncspy in cache tests with console.log assertionsTesting
create-gen-app-testpackageBreaking Changes
create-gen-appno longer provides CLI binaries (create-gen-app/cga)create-gen-app-testpackage (internal use)Migration Guide
For programmatic usage, continue using
createGen()API as before. For CLI access, use thecreate-gen-app-testpackage internally (not published).Related Issues
https://github.com/hyperweb-io/projects-issues/issues/240