Skip to content

feat: Add craft init, validate commands and improve onboarding#732

Open
BYK wants to merge 5 commits intomasterfrom
feat/improve-onboarding
Open

feat: Add craft init, validate commands and improve onboarding#732
BYK wants to merge 5 commits intomasterfrom
feat/improve-onboarding

Conversation

@BYK
Copy link
Member

@BYK BYK commented Jan 23, 2026

Summary

Improves the Craft onboarding experience by reducing the trial-and-error typically required to set up Craft for a new project.

New Commands

  • craft init: Auto-detects project type and generates configuration

    • Detects targets: npm, pypi, crates, docker, gem, pub-dev, github
    • Generates .craft.yml with smart defaults (minVersion: 2.21.0)
    • Creates GitHub Actions workflows (release.yml, publish.yml, changelog-preview.yml)
    • Detects Node.js setup (package manager, version file)
    • Detects Python setup (version from .python-version or pyproject.toml)
  • craft validate: Validates configuration and workflows

    • Checks YAML syntax and schema validation
    • Validates target names and duplicate IDs
    • Validates regex patterns in includeNames/excludeNames
    • Warns about deprecated fields and missing best practices
    • Validates GitHub workflow files (uses proper semver comparison)

Smart Defaults

When minVersion >= 2.21.0:

  • changelog.policy defaults to auto (was none)
  • versioning.policy defaults to auto when >= 2.14.0 (was manual)

First Release Improvements

  • Defaults to version 0.1.0 when no git tags exist
  • Automatically creates CHANGELOG.md when using auto changelog policy

Documentation

  • Updated getting-started guide with craft init quick start
  • Documented smart defaults behavior in configuration reference
  • Added first release workflow guide
Cursor Bugbot reviewed your changes and found no issues for commit 227dfe7

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://craft.sentry.dev/pr-preview/pr-732/

Built to branch gh-pages at 2026-02-04 23:01 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@BYK BYK force-pushed the feat/improve-onboarding branch from 69ce415 to 6966b74 Compare January 31, 2026 00:19
@BYK BYK marked this pull request as ready for review January 31, 2026 00:31
@BYK
Copy link
Member Author

BYK commented Jan 31, 2026

@sentry review

@BYK
Copy link
Member Author

BYK commented Jan 31, 2026

@cursoragent review

@cursor
Copy link
Contributor

cursor bot commented Jan 31, 2026

Perfect! I've completed a comprehensive review of this PR. Let me provide my analysis.

Review Summary

Status: ✅ Approved - Ready to Merge

All tests are passing (841/842), the build is successful, and the linter shows no errors (only minor warnings about unused variables). The PR author has already addressed @BYK's review comments in the most recent commit.

Key Changes Validated

1. New Commands

  • craft init: Auto-detects project types (npm, pypi, crates, docker, gem, pub-dev, github) and generates .craft.yml + GitHub Actions workflows
  • craft validate: Validates configuration, target names, regex patterns, and workflow files

2. Smart Defaults

When minVersion >= 2.20.0:

  • changelog.policy defaults to auto (was none)
  • versioning.policy defaults to auto when >= 2.14.0 (was manual)

3. First Release Improvements

  • Defaults to 0.1.0 using a minor bump from 0.0.0 (not hardcoded)
  • Automatically creates CHANGELOG.md when using auto changelog policy
  • Works with explicit bump types (e.g., craft prepare major1.0.0)

4. PR Comments Addressed

Both of @BYK's comments were addressed in commit 6966b74:

  1. Documentation fix: Changed craft prepare auto to craft prepare in the quick start example
  2. Logic consolidation: Merged first release handling into the version calculation logic, making it more consistent and flexible
/** Default bump type for first release when using auto-versioning */
const DEFAULT_FIRST_RELEASE_BUMP: BumpType = 'minor';

The new approach is better because it:

  • Uses the same bump logic for first releases as subsequent releases
  • Allows explicit bump types to work (e.g., craft prepare major1.0.0 for first release)
  • More maintainable and consistent

Code Quality Assessment

Architecture: ✅ Excellent

  • Clean separation: detection logic, template generation, and validation are modular
  • Each target implements optional detect() method following the strategy pattern
  • Template generation uses structured approach instead of string concatenation

Testing: ✅ Comprehensive

  • 32 new tests for version bumping
  • 13 tests for validation command
  • 14 tests for template generation
  • 24 tests for detection logic
  • E2E tests for first release scenarios

Documentation: ✅ Thorough

  • Updated getting-started guide with craft init quick start
  • Documented smart defaults behavior
  • Added first release workflow guide
  • Clear examples throughout

Minor Observations (Non-blocking)

The linter shows 159 warnings but these are all pre-existing issues in the codebase (unused imports, unused variables in test files). None are introduced by this PR.

Recommendation

Approve and merge. This is a high-quality PR that significantly improves the onboarding experience for Craft. The implementation is solid, well-tested, and all review feedback has been addressed.

Open in Cursor Open in Web

BYK added 5 commits February 4, 2026 23:00
Add new commands and features to improve the onboarding experience:

- craft init: Auto-detect project type and generate configuration
  - Detects npm, pypi, crates, docker, gem, pub-dev targets
  - Generates .craft.yml with smart defaults
  - Creates GitHub Actions workflows (release, publish, changelog-preview)

- craft validate: Validate configuration and workflows
  - Checks YAML syntax and schema
  - Validates target names and regex patterns
  - Warns about deprecated fields and missing best practices

- Smart defaults for minVersion >= 2.20.0
  - changelog.policy defaults to 'auto'
  - versioning.policy defaults to 'auto' (>= 2.14.0)

- First release improvements
  - Defaults to version 0.1.0 when no tags exist
  - Creates CHANGELOG.md automatically with auto policy

- Documentation updates for all new features
- Fix docs: Change 'craft prepare auto' to 'craft prepare' in quick example
- Merge first release logic with version calculation:
  - Use default bump type (minor) instead of hardcoded version
  - Allow explicit bump types to work for first release (e.g., major -> 1.0.0)
  - More consistent code flow
Makes the test portable across environments with custom TMPDIR settings.
String comparison was incorrectly evaluating versions like '2.3.0' as
greater than '2.20.0'. Now uses parseVersion() and versionGreaterOrEqualThan()
for proper semver comparison.
Updates all references to the smart defaults minimum version across
source code, tests, and documentation.
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.

1 participant