Skip to content

Conversation

@kwadwoatta
Copy link

Description

Introduces a dynamic 'student' template option for the create-mn-app CLI. This template allows users to select a specific example project (e.g., 'Counter') and sets up a learning environment by cloning the repo and stripping out the contract implementation while preserving tests.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test update
  • Build/CI update
  • Other (please describe):

Related Issues

Motivation and Context

To support the Midnight Academy curriculum, students need a way to start with a working environment that has the "answers" removed, forcing them to implement the contract code themselves while having the safety net of existing tests and CLI infrastructure.

Changes Made

  • Added StudentExample interface and studentExamples list in src/utils/templates.ts.
  • Implemented interactive example selection prompt in src/create-app.ts
  • Added logic to selectively strip contract/src (preserving test/) in src/create-app.ts
  • Implemented dynamic contract/README.md generation with correct index.ts boilerplate.

Testing Performed

Manual Testing

  • Tested on macOS
  • Tested with npm

Test Commands

# Generated a student project to verify structure
npm run build
node bin/create-midnight-app.js my-student-project --template student --skip-install

Test Results

Verified that:

  • The example selection prompt appears.
  • The project is cloned successfully.
  • contract/src contains only the test directory.
  • contract/README.md contains the correct instructions and boilerplate.

Breaking Changes

  • This PR introduces breaking changes

Documentation

  • README.md updated (if needed)
  • CHANGELOG.md updated
  • Code comments updated
  • API documentation updated (if applicable)
  • Examples updated (if applicable)

Checklist

Code Quality

  • My code follows the project's coding standards
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Licensing

  • I have added SPDX license headers to any new files
  • I have signed the Contributor License Agreement (CLA)
  • I have read and agree to the Code of Conduct

Dependencies

  • I have checked that no unnecessary dependencies were added
  • Dependencies are up to date and secure
  • package.json and package-lock.json are in sync

…election

## Description

Introduces a dynamic 'student' template option for the `create-mn-app` CLI. This template allows users to select a specific example project (e.g., 'Counter') and sets up a learning environment by cloning the repo and stripping out the contract implementation while preserving tests.

## Type of Change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [ ] Test update
- [ ] Build/CI update
- [ ] Other (please describe):

## Related Issues

<!-- Link to related issues using #issue_number -->

## Motivation and Context

To support the Midnight Academy curriculum, students need a way to start with a working environment that has the "answers" removed, forcing them to implement the contract code themselves while having the safety net of existing tests and CLI infrastructure.

## Changes Made

- Added `StudentExample` interface and `studentExamples` list in \[src/utils/templates.ts\](cci:7://file:///Users/princeofori/midnight/create-mn-app/src/utils/templates.ts:0:0-0:0).
- Implemented interactive example selection prompt in \[src/create-app.ts\](cci:7://file:///Users/princeofori/midnight/create-mn-app/src/create-app.ts:0:0-0:0).
- Added logic to selectively strip `contract/src` (preserving `test/`) in \[src/create-app.ts\](cci:7://file:///Users/princeofori/midnight/create-mn-app/src/create-app.ts:0:0-0:0).
- Implemented dynamic `contract/README.md` generation with correct `index.ts` boilerplate.

## Testing Performed

### Manual Testing

- [x] Tested on macOS
- [x] Tested with npm

### Test Commands

```bash
# Generated a student project to verify structure
npm run build
node bin/create-midnight-app.js my-student-project --template student --skip-install
```

### Test Results

Verified that:
- The example selection prompt appears.
- The project is cloned successfully.
- `contract/src` contains only the `test` directory.
- `contract/README.md` contains the correct instructions and boilerplate.

## Breaking Changes

- [ ] This PR introduces breaking changes

## Documentation

- [ ] README.md updated (if needed)
- [ ] CHANGELOG.md updated
- [x] Code comments updated
- [ ] API documentation updated (if applicable)
- [ ] Examples updated (if applicable)

## Checklist

### Code Quality

- [x] My code follows the project's coding standards
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings or errors
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published

### Licensing

- [x] I have added SPDX license headers to any new files
- [x] I have signed the Contributor License Agreement (CLA)
- [x] I have read and agree to the [Code of Conduct](CODE_OF_CONDUCT.md)

### Dependencies

- [x] I have checked that no unnecessary dependencies were added
- [x] Dependencies are up to date and secure
- [x] package.json and package-lock.json are in sync
@kwadwoatta kwadwoatta force-pushed the feat/dynamic-student-template branch from ddda5ef to c5c6805 Compare December 23, 2025 17:46
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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