Contributing Guide
Thank you for your interest in contributing to n8n-nodes-substack! This guide will help you get started with contributing to the project.
Getting Started
Prerequisites
- Node.js: Version 20.15 or higher
- npm: Latest version
- Git: For version control
- TypeScript: Basic familiarity recommended
- n8n: Understanding of n8n workflows is helpful
Development Setup
Option 1: Quick Start with Dev Container (Recommended)
The fastest way to get started is using GitHub Codespaces or VS Code Dev Containers:
Or locally with VS Code: 1. Clone the repository 2. Open in VS Code with Dev Containers extension 3. VS Code will automatically set up the development environment
Option 2: Manual Setup
- Fork and clone the repository:
git clone https://github.com/YOUR_USERNAME/n8n-nodes-substack.git
cd n8n-nodes-substack
- Install dependencies:
npm install
- Build the project:
npm run build
- Run tests to verify setup:
npm test
Development Workflow
1. Before Making Changes
- Create a new branch for your feature or fix:
git checkout -b feature/your-feature-name
# or
git checkout -b fix/issue-description
- Understand the codebase by reading:
- Design and Architecture
- Testing Guide
-
Resource documentation in docs/resources/
-
Run existing tests to ensure everything works:
npm test
2. Making Changes
Code Quality Standards
- TypeScript: All code must be properly typed
- ESLint: Follow the configured linting rules
- Prettier: Use consistent code formatting
- Tests: Include tests for new functionality
Running Quality Checks
# Lint your code
npm run lint
# Fix linting issues automatically
npm run lintfix
# Format code with Prettier
npm run format
# Run tests
npm test
# Run tests in watch mode during development
npm run test:watch
3. Types of Contributions
Adding New Operations
If you want to add a new operation to an existing resource:
- Update the operation enum in
nodes/Substack/Resource.operations.ts - Add the operation configuration to the operations array
- Implement the operation function
- Add to the operation handlers mapping
- Add any new fields in
Resource.fields.tsif needed - Write comprehensive tests
- Update documentation
Example:
// 1. Add to enum
export enum PostOperation {
GetAll = 'getAll',
NewOperation = 'newOperation', // Add here
}
// 2. Add to UI options
{
name: 'New Operation',
value: PostOperation.NewOperation,
description: 'Description of the new operation',
action: 'Perform new operation'
}
// 3. Implement function
async function newOperation(
executeFunctions: IExecuteFunctions,
client: SubstackClient,
publicationAddress: string,
itemIndex: number,
): Promise<IStandardResponse> {
try {
// Implementation here
return {
success: true,
data: result,
metadata: { status: 'success' }
};
} catch (error) {
return SubstackUtils.formatErrorResponse({
message: error.message,
node: executeFunctions.getNode(),
itemIndex,
});
}
}
// 4. Add to handlers
export const postOperationHandlers = {
[PostOperation.GetAll]: getAll,
[PostOperation.NewOperation]: newOperation, // Add here
};
Adding New Resources
To add a completely new Substack resource:
- Create operation files:
NewResource.operations.tsandNewResource.fields.ts - Follow existing patterns from Profile, Post, Note, or Comment resources
- Add to main node in
Substack.node.ts - Update type definitions in
types.ts - Create comprehensive tests
- Add resource documentation in
docs/resources/newresource.md
Bug Fixes
- Identify the issue and create a failing test that reproduces it
- Fix the bug with minimal changes
- Ensure the test now passes
- Verify no other tests are broken
Documentation Improvements
- Update existing documentation for clarity
- Add examples and use cases
- Fix typos and formatting issues
- Improve API documentation
4. Testing Your Changes
Required Tests
All contributions must include appropriate tests:
# Run all tests
npm test
# Run specific test file
npm test -- post-operations.test.ts
# Run tests with coverage
npm test -- --coverage
Test Requirements
- Unit tests for new operations
- Integration tests for resource additions
- Error handling tests for edge cases
- Mock data for new API responses
Example Test Pattern
describe('New Operation', () => {
it('should handle successful operation', async () => {
const mockExecuteFunctions = createMockExecuteFunctions({
nodeParameters: {
resource: 'post',
operation: 'newOperation',
// ... parameters
},
credentials: mockCredentials,
});
const result = await substackNode.execute.call(mockExecuteFunctions);
expect(result[0]).toHaveLength(expectedLength);
expect(result[0][0].json).toMatchObject({
// Expected structure
});
});
it('should handle errors gracefully', async () => {
// Test error scenarios
});
});
5. Documentation Updates
When adding new functionality, update:
- Resource documentation in
docs/resources/if applicable - README.md if adding major features
- API reference documentation
- Code comments for complex logic
Submission Guidelines
Pull Request Process
- Ensure your branch is up to date:
git fetch origin
git rebase origin/main
- Run the full test suite:
npm test
npm run lint
npm run build
- Create a descriptive pull request:
- Clear title describing the change
- Detailed description of what was changed and why
- Reference any related issues
-
Include screenshots for UI changes (if applicable)
-
Ensure CI passes - all tests and linting checks must pass
Pull Request Template
## Description
Brief description of the changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Refactoring
## Changes Made
- List of specific changes
## Testing
- [ ] All existing tests pass
- [ ] New tests added for new functionality
- [ ] Manual testing completed
## Documentation
- [ ] Documentation updated (if applicable)
- [ ] Code comments added for complex logic
## Related Issues
Fixes #(issue number)
Code Review Process
What Reviewers Look For
- Functionality: Does the code work as intended?
- Tests: Are there adequate tests for the changes?
- Code Quality: Is the code clean, readable, and well-structured?
- Documentation: Is the code and functionality properly documented?
- Consistency: Does it follow existing patterns and conventions?
- Performance: Are there any performance implications?
Addressing Feedback
- Respond to all review comments
- Make requested changes in new commits
- Ask for clarification if feedback is unclear
- Update tests and documentation as needed
Coding Standards
TypeScript Guidelines
- Use explicit types where helpful for clarity
- Avoid
anytypes (use proper interfaces) - Use meaningful variable and function names
- Add JSDoc comments for public APIs
Code Organization
- Follow the established file structure
- Use consistent naming conventions
- Keep functions focused and single-purpose
- Separate concerns appropriately
Error Handling
- Use the standardized error handling patterns
- Provide user-friendly error messages
- Log appropriate debug information
- Handle edge cases gracefully
Community Guidelines
Communication
- Be respectful and inclusive
- Ask questions when unclear
- Provide constructive feedback
- Help others when possible
Issue Reporting
When reporting bugs: 1. Use the issue template 2. Provide clear reproduction steps 3. Include relevant error messages 4. Specify your environment details
Feature Requests
When requesting features: 1. Explain the use case clearly 2. Describe the expected behavior 3. Consider implementation complexity 4. Be open to alternative solutions
Getting Help
- Documentation: Check the existing docs first
- Issues: Search existing issues for similar problems
- Discussions: Use GitHub Discussions for questions
- n8n Community: Check the n8n Community Forum
Recognition
Contributors are recognized in: - Release notes for significant contributions - README acknowledgments - Project history and attribution
Thank you for contributing to n8n-nodes-substack! Your efforts help make workflow automation more accessible and powerful for everyone.