Skip to content

feat(pkgmgr,cli): support scriptgo add, direct file execution, and scg alias - #28

Merged
phamtanminhtien merged 2 commits into
mainfrom
feat/pkgmgr-add-and-direct-execution
Sep 24, 2026
Merged

phamtanminhtien merged 2 commits into
mainfrom
feat/pkgmgr-add-and-direct-execution

Conversation

@phamtanminhtien

Copy link
Copy Markdown
Contributor

Summary

This PR implements three major features and usability enhancements for ScriptGo:

  1. scriptgo add Package Manager Command:

    • Supports adding dependencies, devDependencies (-D, --dev), optionalDependencies (-O, --optional), and peerDependencies (--peer).
    • Supports exact version pinning with -E / --exact.
    • Supports offline installation (--offline) against cached packages.
    • Resolves package specs (pkg, pkg@version, pkg@tag, @scope/pkg) via npm registry or workspace packages.
    • Updates package.json with formatting and key order preservation, followed by updating scriptgo.lock and installing packages into node_modules.
    • Features transactional rollback of package.json and scriptgo.lock if any installation step fails.
  2. Direct CLI Execution:

    • Users can directly run files without prefixing run:
      • scriptgo file.ts
      • scriptgo -e "console.log('hello')"
      • scriptgo --eval "code"
    • Preserves all flags and arguments passed after the source target.
  3. scg Alias:

    • scg is interchangeable with scriptgo.
    • Dynamic program name detection in CLI usage/help output (os.Args[0]).
    • Added cmd/scg delegator binary and updated Makefile to symlink scg -> scriptgo.
  4. Architecture & Refactoring:

    • Adhered strictly to AGENTS.md line length guidelines (< 500-650 lines per file):
      • Split binary linking into internal/pkgmgr/bins.go from install.go.
      • Split handleEmit into cmd/scriptgo/emit_cmd.go and handleCoverage into cmd/scriptgo/coverage_cmd.go from main.go.
    • Comprehensive test suites in internal/pkgmgr/add_test.go, cmd/scriptgo/add_test.go, and cmd/scriptgo/main_test.go.
    • Synchronized documentation in CHANGELOG.md, docs/package-manager-architecture.md, docs/roadmap.md, and docs/typescript-parity-report.md.

Verification

  • go test -count=1 ./... (All packages pass 100%)
  • go test -count=1 ./internal/typescriptgo/...
  • go build ./cmd/scriptgo & go build ./cmd/scg

…g alias

- implement 'scriptgo add' with support for dependencies, devDependencies (-D), optionalDependencies (-O), peerDependencies (--peer), exact pinning (-E), and --offline
- support transactional rollback of package.json and scriptgo.lock on add failure
- support direct CLI execution without typing run: 'scriptgo <file.ts>' and 'scriptgo -e <code>'
- provide 'scg' alias for 'scriptgo' via cmd/scg delegator, Makefile symlink, and dynamic program name in usage/help
- refactor long files in cmd/scriptgo and internal/pkgmgr into focused units to maintain architectural guidelines (< 500-650 lines)
- update tests, documentation, changelog, roadmap, and parity report
@phamtanminhtien
phamtanminhtien merged commit e813adc into main Sep 24, 2026
7 checks passed
@phamtanminhtien
phamtanminhtien deleted the feat/pkgmgr-add-and-direct-execution branch September 24, 2026 13:29
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