Skip to content

Commit 4ed8949

Browse files
author
Dan Clayton
committed
test
1 parent 969b9ac commit 4ed8949

80 files changed

Lines changed: 4068 additions & 2138 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
globs: package.json,tsconfig.json,vitest.config.ts,packages/*/package.json
3+
---
4+
5+
# Build and Deployment Patterns
6+
7+
## Build System
8+
9+
- Use Bun as the primary runtime and package manager
10+
- TypeScript compilation with strict settings
11+
- Monorepo workspace management
12+
- Changesets for version management
13+
14+
## Package Configuration
15+
16+
Each package should have:
17+
- Proper `main` and `types` fields pointing to `dist/` directory
18+
- Correct `engines` field for Bun version requirements
19+
- Proper `publishConfig` for GitHub Packages registry
20+
- Workspace dependencies using `workspace:*`
21+
22+
## Development Workflow
23+
24+
- Use `bun run build` to build all packages
25+
- Use `bun run test` for running tests
26+
- Use `bun run test:watch` for development
27+
- Use `bun run test:coverage` for coverage reports
28+
29+
## Publishing
30+
31+
- Use Changesets for version management
32+
- Publish to GitHub Packages registry
33+
- Follow semantic versioning
34+
- Update CHANGELOG.md files automatically
35+
36+
## TypeScript Configuration
37+
38+
- Use strict TypeScript settings
39+
- Enable all recommended compiler options
40+
- Use path mapping for monorepo imports
41+
- Configure proper module resolution
42+
43+
## Example Package.json Structure
44+
45+
```json
46+
{
47+
"name": "@dotgithub/package-name",
48+
"version": "0.1.1",
49+
"type": "module",
50+
"main": "dist/index.js",
51+
"types": "dist/index.d.ts",
52+
"engines": {
53+
"bun": ">=1.2.19"
54+
},
55+
"publishConfig": {
56+
"registry": "https://npm.pkg.github.com",
57+
"access": "public"
58+
}
59+
}
60+
```

.cursor/rules/cli-commands.mdc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
globs: packages/cli/src/commands/*.ts
3+
---
4+
5+
# CLI Command Patterns
6+
7+
## Command Structure
8+
9+
All CLI commands should follow the pattern established in [packages/cli/src/index.ts](mdc:packages/cli/src/index.ts):
10+
11+
- Export a `create*Command` function that takes a context factory
12+
- Use Commander.js for argument parsing
13+
- Implement proper error handling and logging
14+
- Use the global options pattern
15+
16+
## Context Usage
17+
18+
Commands receive a `DotGithubContext` factory function:
19+
20+
```typescript
21+
export function createMyCommand(
22+
createContext: () => DotGithubContext
23+
): Command {
24+
const command = new Command('my-command');
25+
26+
command.action(async (options) => {
27+
const context = createContext();
28+
// Use context for operations
29+
});
30+
31+
return command;
32+
}
33+
```
34+
35+
## Error Handling
36+
37+
- Use the logger from `@dotgithub/core` for consistent output
38+
- Handle configuration errors gracefully
39+
- Provide helpful error messages with suggestions
40+
- Use appropriate exit codes
41+
42+
## Global Options
43+
44+
Commands inherit these global options:
45+
- `--config, -c` - Path to config file
46+
- `--verbose, -v` - Verbose logging
47+
- `--debug` - Debug logging
48+
- `--quiet` - Suppress output except errors
49+
- `--token, -t` - GitHub token override
50+
51+
## Testing Commands
52+
53+
- Use Vitest for command testing
54+
- Mock external dependencies (GitHub API, file system)
55+
- Test both success and error cases
56+
- Verify proper logging output
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
globs: packages/core/src/config.ts,*.json
3+
---
4+
5+
# Configuration Management Patterns
6+
7+
## Configuration Structure
8+
9+
The main configuration is managed through [packages/core/src/config.ts](mdc:packages/core/src/config.ts):
10+
11+
- Use `DotGithubConfig` interface for type safety
12+
- Support both JSON and programmatic configuration
13+
- Validate configuration on load
14+
- Provide helpful error messages for invalid config
15+
16+
## Configuration Loading
17+
18+
- Use `readConfig()` to load configuration from file
19+
- Support multiple configuration file formats
20+
- Handle missing configuration gracefully
21+
- Provide configuration validation and fixing
22+
23+
## Action Management
24+
25+
- Use `addActionToConfig()` for adding actions
26+
- Use `removeActionFromConfig()` for removing actions
27+
- Use `getActionsFromConfig()` for retrieving actions
28+
- Support action pinning and version management
29+
30+
## Construct Configuration
31+
32+
- Use `getConstructsFromConfig()` for construct configuration
33+
- Support construct-specific configuration sections
34+
- Validate construct configuration schemas
35+
- Handle construct loading errors
36+
37+
## Stack Configuration
38+
39+
- Use `getStacksFromConfig()` for stack definitions
40+
- Support multiple stacks per configuration
41+
- Validate stack configuration
42+
- Handle stack synthesis errors
43+
44+
## Configuration Validation
45+
46+
- Use Zod schemas for runtime validation
47+
- Provide detailed error messages
48+
- Support configuration migration
49+
- Handle backward compatibility
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
description: Guidelines for developing GitHub constructs and extending DotGitHub functionality
3+
---
4+
5+
# Construct Development Guidelines
6+
7+
## Construct Architecture
8+
9+
Constructs in DotGitHub follow a specific pattern for extending functionality:
10+
11+
- Constructs (loadable modules) are located in `packages/core/src/plugins/`
12+
- Each construct should export a main class and any helper classes
13+
- Constructs receive configuration through the stack context
14+
- Use dependency injection for better testability
15+
16+
## Construct Interface
17+
18+
```typescript
19+
export abstract class GitHubConstruct {
20+
readonly name: string;
21+
readonly version?: string;
22+
23+
validate?(stack: GitHubStack): void;
24+
synthesize(stack: GitHubStack): Promise<void> | void;
25+
describe?(): ConstructDescription | Promise<ConstructDescription>;
26+
}
27+
```
28+
29+
## Action Collection Constructs
30+
31+
For constructs that provide actions, extend [ActionCollection](mdc:packages/core/src/plugins/action-collection.ts):
32+
33+
- Use `invokeAction()` for type-safe action invocation
34+
- Use `createOutputs()` for output management
35+
- Access the stack via `this.stack`
36+
- Implement proper error handling
37+
38+
## Construct Configuration
39+
40+
- Constructs receive configuration through `stack.config`
41+
- Use Zod schemas for configuration validation
42+
- Provide sensible defaults for optional configuration
43+
- Document all configuration options
44+
45+
## Construct Registration
46+
47+
- Constructs are registered in the configuration file under `constructs`
48+
- Use the construct manager for loading and initialization
49+
- Support construct dependencies and ordering
50+
- Handle construct loading errors gracefully
51+
52+
## Testing Constructs
53+
54+
- Create comprehensive unit tests for construct logic
55+
- Test configuration validation
56+
- Test construct integration with the stack
57+
- Use mocks for external dependencies
58+
- Test error conditions and edge cases
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
globs: packages/core/src/constructs/*.ts,packages/core/src/plugins/*.ts
3+
---
4+
5+
# Constructs and GitHub Construct Patterns
6+
7+
## Construct Base Classes
8+
9+
All constructs should extend from [Construct](mdc:packages/core/src/constructs/base.ts) and follow CDK patterns:
10+
11+
- Use `super(scope, id)` in constructor
12+
- Implement proper resource management
13+
- Use `this.node` for construct tree operations
14+
- Follow naming conventions: `GitHub*` for GitHub-specific constructs
15+
16+
## Action Collection Pattern
17+
18+
Action collections should extend [ActionCollection](mdc:packages/core/src/plugins/action-collection.ts):
19+
20+
```typescript
21+
export class MyActionCollection extends ActionCollection {
22+
// Use invokeAction() for type-safe action invocation
23+
// Use createOutputs() for output management
24+
// Access stack via this.stack
25+
}
26+
```
27+
28+
## GitHub Construct Development
29+
30+
- Constructs (loadable modules) live in `packages/core/src/plugins/`
31+
- Export main construct class and any helper classes
32+
- Use dependency injection for configuration
33+
- Follow the GitHubConstruct interface patterns
34+
35+
## Resource Management
36+
37+
- Use `addWorkflow()` for GitHub workflows
38+
- Use `addResource()` for file resources
39+
- Use `addFileResource()` for simple file content
40+
- Use `addDirectoryResource()` for directory structures
41+
42+
## Stack Synthesis
43+
44+
- Implement `synth()` method for file generation
45+
- Use YAML formatting for workflow files
46+
- Maintain proper file structure in output
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
globs: docs/*.md,*.md
3+
---
4+
5+
# Documentation Standards
6+
7+
## Documentation Structure
8+
9+
The project uses comprehensive documentation in the `docs/` directory:
10+
11+
- [README.md](mdc:README.md) - Main project overview and quick start
12+
- [docs/getting-started.md](mdc:docs/getting-started.md) - Detailed getting started guide
13+
- [docs/user-guide.md](mdc:docs/user-guide.md) - Comprehensive user guide
14+
- [docs/api-reference.md](mdc:docs/api-reference.md) - API documentation
15+
- [docs/construct-development.md](mdc:docs/construct-development.md) - Construct development guide
16+
17+
## Code Documentation
18+
19+
- Use JSDoc comments for all public APIs
20+
- Include parameter descriptions and return types
21+
- Document complex algorithms and business logic
22+
- Provide usage examples in comments
23+
24+
## Markdown Standards
25+
26+
- Use proper heading hierarchy
27+
- Include table of contents for long documents
28+
- Use code blocks with language specification
29+
- Include links to related documentation
30+
31+
## API Documentation
32+
33+
- Document all public methods and properties
34+
- Include parameter types and descriptions
35+
- Provide usage examples
36+
- Document error conditions and exceptions
37+
38+
## Example Documentation
39+
40+
```typescript
41+
/**
42+
* Creates a new GitHub workflow with the specified configuration.
43+
*
44+
* @param config - The workflow configuration
45+
* @returns A new GitHubWorkflow instance
46+
* @throws {ValidationError} When the configuration is invalid
47+
*
48+
* @example
49+
* ```typescript
50+
* const workflow = createWorkflow({
51+
* name: 'CI',
52+
* on: { push: { branches: ['main'] } }
53+
* });
54+
* ```
55+
*/
56+
export function createWorkflow(config: WorkflowConfig): GitHubWorkflow {
57+
// Implementation
58+
}
59+
```
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
globs: examples/**/*.ts,examples/**/*.json
3+
---
4+
5+
# Example Development Guidelines
6+
7+
## Example Structure
8+
9+
Examples should be located in the `examples/` directory and demonstrate real-world usage patterns:
10+
11+
- Each example should be a complete, runnable project
12+
- Include a `dotgithub.json` configuration file
13+
- Provide TypeScript source code in `src/` directory
14+
- Include generated workflows in `workflows/` directory
15+
16+
## Example Configuration
17+
18+
Use the example in [examples/example/](mdc:examples/example/) as a template:
19+
20+
- [examples/example/dotgithub.json](mdc:examples/example/dotgithub.json) - Main configuration
21+
- [examples/example/src/index.ts](mdc:examples/example/src/index.ts) - Main entry point
22+
- [examples/example/src/actions/](mdc:examples/example/src/actions/) - Generated action wrappers
23+
- [examples/example/workflows/](mdc:examples/example/workflows/) - Generated workflow files
24+
25+
## Example Development
26+
27+
- Start with a simple configuration
28+
- Build up complexity gradually
29+
- Show different patterns and use cases
30+
- Include comments explaining the approach
31+
- Test that examples can be synthesized successfully
32+
33+
## Example Documentation
34+
35+
- Include a README.md explaining the example
36+
- Document the configuration options used
37+
- Show the expected output
38+
- Provide step-by-step instructions
39+
40+
## Example Testing
41+
42+
- Ensure examples can be built and run
43+
- Test synthesis produces valid workflows
44+
- Verify examples work with the CLI
45+
- Update examples when APIs change
46+
47+
## Best Practices
48+
49+
- Use realistic but simple scenarios
50+
- Show both basic and advanced features
51+
- Include error handling examples
52+
- Demonstrate construct usage
53+
- Show integration with external services

0 commit comments

Comments
 (0)