Skip to content

Conversation

@PaulThompson
Copy link
Owner

No description provided.

- Extract Task class and related types to core/task.ts
- Move CLI functionality to cli.ts
- Keep dnit.ts as clean export module for backward compatibility
- Fix circular imports with TaskInterface
- All tests passing, functionality preserved
These tasks are no longer needed after migrating from ADL to Zod
- Fix test task: remove wrong cwd, add missing --allow-run flag
- Fix check/lint tasks: update entry points from main.ts/mod.ts to launch.ts/dnit.ts
- Remove unused file import after removing genadl/updategenadlfix tasks
…zation

- Created interfaces/ directory with clean interface definitions
- Broke circular dependencies between Task/Manifest and Context/Task
- Split large files: task.ts (452→270 lines), cli.ts (252→3 lines)
- Extracted TrackedFile and TrackedFilesAsync to core/file/
- Created core/factories.ts for factory functions
- Split cli.ts into cli/, logging, builtinTasks, and utils modules
- Created mod.ts as new main export with organized categories
- Updated dnit.ts to re-export from mod.ts for backward compatibility
- All tests passing, no circular imports remaining
- Move task() to core/task.ts
- Move file(), trackFile() to core/file/TrackedFile.ts
- Move asyncFiles() to core/file/TrackedFilesAsync.ts
- Remove core/factories.ts
- Update all imports to use functions from their respective files
- Better colocation of related functionality
- Create IExecContext interface and ExecContext implements it
- Break up deps.ts and use direct JSR imports from deno.json
- Move isTrackedFile() to TrackedFile.ts and isTrackedFileAsync() to TrackedFilesAsync.ts
- Move TaskContext interface and taskContext() function to separate TaskContext.ts file
- Rename context.ts to execContext.ts for better clarity
- Update all imports to use new locations
- All tests passing, better module organization maintained
- Remove unused log import from task.ts
- Remove unused type imports (TrackedFileName, TrackedFileData)
- Use proper type imports with 'type' keyword for verbatim module syntax
- Auto-fix remaining lint issues
- All lint checks now clean (37 files checked)
- Created tools/import-analyzer.ts to detect circular import dependencies
- Eliminated 3 circular dependencies:
  1. Removed duplicate core/taskInterface.ts (redundant with interfaces/core/ITask.ts)
  2. Consolidated ITask and IExecContext into interfaces/core/ICoreInterfaces.ts
  3. Updated TrackedFile to use ITask interface instead of concrete Task class
- All TypeScript files now use consistent interface imports
- Tests pass and build succeeds
- Zero circular dependencies remain
- Document consolidation of ITask and IExecContext into ICoreInterfaces.ts
- Remove references to deleted core/taskInterface.ts
- Update interface file listings to match actual structure
- Add import hierarchy diagram
- Document zero circular dependencies achievement
- Note backward compatibility through re-exports
- Add details about new tools/import-analyzer.ts
- Clarify actual file names vs outdated references in REFACTORING_PLAN.md
- Rename core/types.ts to interfaces/core/IManifestTypes.ts
- Better organization: manifest-related types and Zod schemas now in interfaces
- Update all imports throughout codebase to use new location
- Maintain zero circular dependencies (verified by analyzer)
- All tests continue to pass
- Improved separation: core/ contains only implementations, interfaces/ contains types
1. Move utils/process.test.ts to tests/ directory for consistency
2. Move textTable.ts and asyncQueue.ts to utils/ directory
   - Update all imports in core/execContext.ts, cli/utils.ts, tests/asyncQueue.test.ts
3. Standardize imports to use @std instead of deno.land/std
   - Add @std/assert to deno.json imports
   - Update tests/process.test.ts and tests/asyncQueue.test.ts to use @std/assert
4. Verify example still works and all tests pass (5/5)
5. Maintain zero circular dependencies (confirmed by import analyzer)

The codebase now has optimal organization:
- All tests in tests/ directory
- All utilities in utils/ directory
- All interfaces in interfaces/ directory
- All core implementations in core/ directory
- Consistent @std imports throughout
- Clean dependency graph with zero cycles
- Updated 6 dependencies via 'deno outdated --update':
  - @std/cli: 1.0.15 → 1.0.21
  - @std/crypto: 1.0.4 → 1.0.5
  - @std/fs: 1.0.15 → 1.0.19
  - @std/path: 1.0.8 → 1.1.1
  - @std/semver: 1.0.4 → 1.0.5
  - zod: 3.24.2 → 3.25.76
- Manually updated @std/assert: 1.0.10 → 1.0.13
- All tests pass (5/5) with updated dependencies
- TypeScript compilation successful

Only major version update remaining: zod 3.x → 4.x (breaking changes)
- Successfully upgraded from Zod 3.25.76 to 4.0.16 (major version)
- All tests pass (5/5) with Zod 4
- TypeScript compilation successful
- Example works correctly
- All dependencies now at latest versions (confirmed by 'deno outdated')

Benefits of Zod 4:
- Significant performance improvements (14.71x faster parsing)
- Better error customization APIs
- Production-ready and stable despite major version bump
- Update hardcoded JSR imports to use @std/* from import map:
  - jsr:@std/cli@1.0.21/parse-args → @std/cli/parse-args
  - jsr:@std/fs@1.0.19 → @std/fs
  - jsr:@std/semver@1.0.5 → @std/semver
- This ensures dnit's own build tasks use the same versions as main project
- Verified dnit's build tasks still work correctly
- All imports now consistently use the import map approach
- Replace https://deno.land/std@0.221.0/testing/asserts.ts with @std/assert
- All tests continue to pass (5/5)
- No hardcoded dependency versions remain in source code
- All imports now consistently use the import map approach

Complete dependency standardization achieved:
- All @std packages use import map (@std/*)
- All versions managed centrally in deno.json
- All dependencies at latest versions
- Ignore .manifest.json files (dnit's build state)
- Prevents tracking of local build artifacts
- Standard practice for build tools to ignore state files
- Remove dnit/deps.ts re-export pattern (outdated Deno practice)
- Import dependencies directly where used:
  - Import from ../mod.ts for dnit core functions
  - Import @std/semver and @std/cli directly using import map
  - Import runConsole directly from ../utils.ts
- Replace all utils.runConsole calls with direct runConsole calls
- Update type references: cli.Args → CliArgs from @std/cli
- All dnit build tasks continue to work correctly
- Follows modern Deno best practices with centralized version management
- Add CircularDependency type and detectCircularDependencies function
- Use iterative DFS to detect cycles after dynamic dependency resolution
- Detection runs after async file deps and file->task deps are resolved
- Throw descriptive error with exact cycle path when circular dependency found
- Update tests to use assertRejects for proper async error handling
- All 67 tests pass including 3 comprehensive circular dependency test cases

Fixes Make-style behavior: detect circular dependencies early and report them
clearly, preventing infinite loops during task execution.
- Export detectCircularDependencies function and CircularDependency type for testing
- Add 8 comprehensive unit tests covering various scenarios:
  - No circular dependency (simple and complex cases)
  - Self-referencing task (A->A)
  - Simple cycle (A->B->A)
  - Complex cycle (A->B->C->A)
  - Linear chain with no cycle
  - Multiple dependencies with no cycle
  - Diamond dependency pattern with no cycle
- Tests verify exact cycle paths and lengths
- All direct tests pass, providing better coverage of the detection algorithm
- Created analyze_asserts.ts script to identify assertion improvement opportunities
- Created fix_asserts.ts script to automatically fix common assertion patterns
- Replaced 42 assertEquals(x.includes(y), true) with assertStringIncludes()
- Fixed instanceof checks with assertInstanceOf/assertNotInstanceOf (4 instances)
- Replaced null checks with assert() (3 instances)
- Fixed comparison operators with assertGreater() (1 instance)
- Updated imports in all modified test files to include new assertion functions
- All 75 tests pass with improved, more readable assertions

The new assertions provide better error messages and clearer test intent.
- Removed typeof pattern from improvement suggestions
- Added comment explaining typeof checks are appropriate for primitives
- assertEquals(typeof x, 'string') is the correct pattern for runtime type validation
- Script now reports 'No assertion improvements found' for current test suite
The script was incorrectly flagging assert(collection.has(item)) patterns as
comparison operators. These are actually appropriate assertions for checking
Set/Map membership and should not be changed to assertLess/assertGreater.
Applied automated script to replace generic assertions with more specific ones:
- assertEquals(expr, true) → assert(expr)
- assertEquals(expr, false) → assertFalse(expr)
- assertEquals(x < y, true) → assertLess(x, y)
- assertEquals(x.includes(y), true) → assertStringIncludes(x, y)
- assert(x <= y) → assertLessOrEqual(x, y)

Total improvements: 97+ assertion patterns across 6 test files
All 75 tests continue to pass
- Add plainTextTable function for simple space-aligned output
- Update showTaskList to use plainTextTable instead of textTable
- Add comprehensive tests for plainTextTable functionality
- Maintain backward compatibility by keeping textTable function
…with false

Replace assertEquals(result.includes(...), false) with proper assertFalse assertions
for better readability and clearer test intent.
- Update plainTextTable function to output only data rows
- Update all related tests to expect no header row
- Clean output now shows just task names and descriptions
- Add showHelp function in cli/utils.ts to display comprehensive help
- Modify execCli in cli/cli.ts to handle --help flag early
- Add fallback help in launch.ts for cases without dnit project
- Help shows usage, flags (verbose, quiet), and available tasks
- Includes built-in tasks (clean, list, tabcompletion) and user tasks
- Extract common help logic into showHelpCommon function
- Create showHelpBasic for cases without dnit project
- Use consistent logger interface for all help output
- Remove duplicated help text between launch.ts and cli/utils.ts
- Maintain same functionality with cleaner code structure
- Drop github link from showHelpBasic
- Remove 'For more information, run: dnit list' from showHelp
- Cleaner help output without unnecessary footer text
- Change description to mention TypeScript task definitions in dnit/main.ts
- Add GitHub link to both showHelp and showHelpBasic functions
- More accurate description of dnit's requirements and usage
- Create shared helpFooter function to deduplicate GitHub link
- Use helpFooter in both showHelp and showHelpBasic functions
- Consistent footer formatting across help outputs
- Move 'Run dnit without arguments to see available tasks' to common section
- This instruction applies whether dnit project exists or not
- Remove duplicate text from showHelpBasic description
- Change DESCRIPTION to ERROR section for clearer messaging
- Explain that no dnit/ directory was found and what user needs to do
- More actionable error message for getting started
- Remove manual 'deno cache deps.ts' step (deps.ts doesn't exist)
- Add cache: true to denoland/setup-deno@v2 actions for automatic caching
- Caching now based on deno.json imports and deno.lock files
Maintains proper separation between interface contracts (ITaskContext)
and concrete implementations (TaskContext).
The file contained only re-exports that are already available through mod.ts.
No external code imports from cli.ts, making it safe to remove.
- Remove unused 'assert' import from asyncQueue.test.ts
- Remove unused 'assertEquals' import from basic.test.ts
- Remove unused 'TaskContext' type import from task.ts
- Remove unused 'assertGreater' and 'CircularDependency' imports from task.test.ts
- Make trackFile() the primary function implementation
- Mark file() as deprecated with @deprecated JSDoc comments
- Update README examples to use trackFile() consistently
- Maintain backward compatibility by keeping file() export
- Change from 'v2.1 or greater' to 'Deno 2.x (tested on recent versions in CI)'
- Avoids need to keep specific version numbers in sync with CI matrix
- Add git utilities to mod.ts: gitLatestTag, gitLastCommitMessage, gitIsClean, fetchTags, requireCleanGit
- Add process utilities to mod.ts: run, runConsole
- Keep utils.ts for backward compatibility with explanatory comments
- Creates consistent API where all utilities are available through main module
- Add Promise<string> return type to gitLatestTag()
- Add Promise<boolean> return type to gitIsClean()
- Add Task type annotations to fetchTags and requireCleanGit constants
- Fixes linter errors for public API type requirements
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.

2 participants