@@ -77,8 +77,6 @@ Before contributing, ensure you have the following installed:
7777- ** Node.js** ` 20+ ` - [ Download] ( https://nodejs.org/ )
7878- ** npm** ` 10+ ` (comes with Node.js)
7979- ** Rust** ` 1.86+ ` - [ Install via rustup] ( https://rustup.rs )
80- - ** Git** - [ Install] ( https://git-scm.com/downloads )
81- - ** just** (optional, for running justfiles) - [ Install] ( https://github.com/casey/just )
8280
8381### Setting Up Your Development Environment
8482
@@ -441,302 +439,27 @@ docs: update CONTRIBUTING.md with testing guidelines
441439test(zero-to-hero): add integration tests for pallets
442440```
443441
444- ## Advanced Topics
442+ ## Additional Resources
445443
446- ### Tutorial Configuration
444+ For more detailed information, see:
447445
448- The ` tutorial.config.yml ` file controls how your tutorial is built and tested.
449-
450- #### Basic Configuration
451-
452- ``` yaml
453- name : My Tutorial Title
454- slug : my-tutorial
455- category : polkadot-sdk-cookbook
456- needs_node : true
457- description : Learn how to build a custom pallet
458- type : sdk
459- ` ` `
460-
461- #### Advanced Configuration with Manifest
462-
463- For tutorials with runtime/parachain code:
464-
465- ` ` ` yaml
466- name : My Tutorial Title
467- slug : my-tutorial
468- category : polkadot-sdk-cookbook
469- needs_node : true
470- description : Build a custom parachain
471- type : sdk
472-
473- manifest :
474- build :
475- project_dir : src
476- commands :
477- - cargo build --release
478-
479- runtime :
480- wasm_path : ./target/release/wbuild/my-runtime/my_runtime.compact.compressed.wasm
481-
482- network :
483- relay_chain : paseo
484- para_id : 1000
485-
486- tests :
487- framework : vitest
488- files :
489- - tests/my-tutorial-e2e.test.ts
490-
491- scripts_dir : scripts
492- zombienet_dir : zombienet
493- ` ` `
494-
495- #### When to Update
496-
497- Update ` tutorial.config.yml` when:
498- - Changing build process or commands
499- - Modifying runtime WASM output paths
500- - Updating network configuration
501- - Changing test file locations
502- - Toggling `needs_node` flag
503-
504- # ## Justfiles and Scripts
505-
506- # ### Tutorial Justfiles
507-
508- Each tutorial can have a `justfile` for common development tasks :
509-
510- ` ` ` justfile
511- # List available commands
512- default:
513- @just --list
514-
515- # Setup Rust toolchain
516- setup-rust:
517- rustup install 1.86.0
518- rustup default 1.86.0
519-
520- # Build the runtime
521- build:
522- cd src && cargo build --release
523-
524- # Run tests
525- test:
526- npm test
527-
528- # Start local node
529- start-node:
530- ./scripts/start-node.sh
531- ` ` `
532-
533- **Usage**:
534- ` ` ` bash
535- cd tutorials/my-tutorial
536- just # List commands
537- just build # Run build
538- just test # Run tests
539- ` ` `
540-
541- # ### Global vs Tutorial Scripts
542-
543- **Global scripts** (`/scripts/`):
544- - Shared across multiple tutorials
545- - Common setup procedures
546- - Reusable utilities
547-
548- **Tutorial scripts** (`/tutorials/<slug>/scripts/`):
549- - Tutorial-specific workflows
550- - Auto-generated versioned scripts (post-merge)
551- - Custom setup unique to this tutorial
552-
553- **When to use which**:
554- - Use global scripts for common patterns
555- - Use tutorial scripts for unique workflows
556- - Propose migration to global if script is reused 3+ times
557-
558- # ## CI/CD Pipeline
559-
560- # ### Automated Checks on PR
561-
562- When you submit a PR, the following checks run automatically :
563-
564- 1. **Tutorial Tests** (`.github/workflows/test-tutorials.yml`)
565- - Runs if new tutorial folder is added
566- - Installs dependencies
567- - Runs `npm test` for affected tutorials
568- - Tests must pass or skip gracefully
569-
570- 2. **Build Verification**
571- - Validates `tutorial.config.yml` syntax
572- - Checks for required files
573- - Verifies test files exist
574-
575- # ### Post-Merge Workflow
576-
577- After your PR is merged, maintainers will :
578-
579- 1. **Generate versioned scripts** via `/generate-scripts` command
580- - Creates pinned setup scripts in `tutorials/<slug>/scripts/`
581- - Commits scripts to repository
582-
583- 2. **Create tutorial tag** in format `tutorial/<slug>/vYYYYMMDD-HHMMSS`
584- - Enables stable snippet extraction for documentation
585-
586- 3. **Optionally create GitHub release** for major tutorials
587-
588- # ### Version Management
589-
590- Tutorial versions are managed in `versions.yml` :
591-
592- ` ` ` yaml
593- versions:
594- rust: "1.86.0"
595- chain_spec_builder: "0.20.0"
596- polkadot_omni_node: "0.4.1"
597-
598- # Tutorial-specific overrides (optional)
599- my_tutorial:
600- rust: "1.85.0"
601- ` ` `
602-
603- Maintainers handle version updates. If your tutorial requires specific versions, note this in your proposal.
604-
605- # # SDK Architecture
606-
607- The Polkadot Cookbook uses a modular SDK architecture consisting of two main components :
608-
609- # ## Polkadot Cookbook Core (`polkadot-cookbook-core`)
610-
611- The core library provides the business logic for tutorial creation and management. It can be used programmatically by other tools.
612-
613- **Key modules:**
614- - ` config` - Type-safe project and tutorial configuration
615- - ` error` - Comprehensive error types with serialization support
616- - ` git` - Async git operations
617- - ` templates` - Template generation for scaffolding
618- - ` scaffold` - Project creation and directory structure
619- - ` bootstrap` - Test environment setup (npm, dependencies, config files)
620-
621- **Features:**
622- - Async-first API using Tokio
623- - Structured logging with `tracing`
624- - Serializable errors for tooling integration
625- - Comprehensive test coverage (80%+)
626- - No terminal dependencies (pure library)
627-
628- **Example programmatic usage:**
629- ` ` ` rust
630- use polkadot_cookbook_core::{config::ProjectConfig, Scaffold};
631- use std::path::PathBuf;
632-
633- #[tokio::main]
634- async fn main() -> Result<(), Box<dyn std::error::Error>> {
635- let config = ProjectConfig::new("my-tutorial")
636- .with_destination(PathBuf::from("./tutorials"))
637- .with_git_init(true)
638- .with_skip_install(false);
639-
640- let scaffold = Scaffold::new();
641- let project_info = scaffold.create_project(config).await?;
642-
643- println!("Created: {}", project_info.project_path.display());
644- Ok(())
645- }
646- ` ` `
647-
648- For more information, see [`polkadot-cookbook-core/README.md`](polkadot-cookbook-core/README.md).
649-
650- # ## Polkadot Cookbook CLI (`polkadot-cookbook-cli`)
651-
652- A thin CLI wrapper around the core library that provides a command-line interface.
653-
654- **Features:**
655- - Beautiful colored output
656- - Progress indicators
657- - Error handling with helpful messages
658- - Command-line flags for customization
659-
660- **Usage:**
661- ` ` ` bash
662- # Create a new tutorial
663- cargo run --package polkadot-cookbook-cli -- my-tutorial
664-
665- # With options
666- cargo run --package polkadot-cookbook-cli -- my-tutorial --skip-install --no-git
667-
668- # Show help
669- cargo run --package polkadot-cookbook-cli -- --help
670- ` ` `
671-
672- # ## Why This Architecture?
673-
674- The SDK architecture provides several benefits :
675-
676- 1. **Separation of Concerns**
677- - Core library has zero UI/terminal dependencies
678- - CLI is a thin presentation layer
679- - Business logic is testable and reusable
680-
681- 2. **Programmatic Access**
682- - Other tools can use the core library directly
683- - IDE extensions can integrate the functionality
684- - CI/CD pipelines can automate tutorial creation
685-
686- 3. **Better Testing**
687- - Unit tests for business logic
688- - Integration tests for workflows
689- - CLI can be tested separately
690-
691- 4. **Easier Maintenance**
692- - Clear module boundaries
693- - Async-first for better performance
694- - Structured logging for observability
695-
696- # ## Contributing to the SDK
697-
698- If you want to contribute to the SDK itself (not just tutorials) :
699-
700- 1. **Core library changes** go in `polkadot-cookbook-core/`
701- - Add features to appropriate modules
702- - Write comprehensive tests
703- - Use structured logging (`tracing`)
704- - Ensure no terminal dependencies
705-
706- 2. **CLI changes** go in `polkadot-cookbook-cli/`
707- - Keep it thin (mostly UI/formatting)
708- - Delegate logic to core library
709- - Use colored output for better UX
710-
711- 3. **Run tests** :
712- ` ` ` bash
713- # Test core library
714- cargo test --package polkadot-cookbook-core
715-
716- # Test CLI
717- cargo run --package polkadot-cookbook-cli -- test-project --skip-install --no-git
718-
719- # Test entire workspace
720- cargo test --workspace
721- ` ` `
722-
723- 4. **Check formatting and lints** :
724- ` ` ` bash
725- cargo fmt --check
726- cargo clippy --workspace -- -D warnings
727- ` ` `
446+ - ** [ Advanced Topics] ( docs/ADVANCED_TOPICS.md ) ** - Tutorial configuration, justfiles, and CI/CD pipeline details
447+ - ** [ SDK Architecture] ( docs/SDK_ARCHITECTURE.md ) ** - Core library and CLI architecture for contributors
728448
729449## Getting Help
730450
731451### Resources
732452
733- - **Visual Guide**: [Tutorial Creation Workflow](docs/TUTORIAL_WORKFLOW.md)
734- - **Workflow Documentation**: [docs/WORKFLOWS.md](docs/WORKFLOWS.md)
453+ - ** [ Tutorial Creation Workflow] ( docs/TUTORIAL_WORKFLOW.md ) ** - Visual workflow diagram
454+ - ** [ Advanced Topics] ( docs/ADVANCED_TOPICS.md ) ** - Configuration and CI/CD details
455+ - ** [ SDK Architecture] ( docs/SDK_ARCHITECTURE.md ) ** - Core library and CLI documentation
735456- ** Example Tutorial** : ` tutorials/zero-to-hero/ `
736- - **Polkadot Documentation**: [docs.polkadot.com ](https://docs.polkadot.com)
457+ - ** [ Polkadot Documentation] ( https://docs.polkadot.com ) **
737458
738459### Communication
739460
740461- ** Questions** : Open an [ issue] ( https://github.com/polkadot-developers/polkadot-cookbook/issues )
741462
463+ ---
464+
742465Thank you for contributing to Polkadot Cookbook!
0 commit comments