{"id":17241172,"url":"https://github.com/paulthompson/dnit","last_synced_at":"2025-10-03T21:40:59.322Z","repository":{"id":43858427,"uuid":"274000753","full_name":"PaulThompson/dnit","owner":"PaulThompson","description":"dnit: typescript (deno) task executor","archived":false,"fork":false,"pushed_at":"2025-04-06T02:32:53.000Z","size":315,"stargazers_count":9,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T03:12:31.792Z","etag":null,"topics":["deno","task-runner","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PaulThompson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-21T23:42:19.000Z","updated_at":"2025-02-28T05:01:09.000Z","dependencies_parsed_at":"2024-03-28T06:24:30.694Z","dependency_job_id":"48625e5d-03b4-46ff-a9db-44213a3796c1","html_url":"https://github.com/PaulThompson/dnit","commit_stats":{"total_commits":128,"total_committers":6,"mean_commits":"21.333333333333332","dds":0.1640625,"last_synced_commit":"64c1a82124be1dbc73d0cd2e991fe4a9c203a4e9"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulThompson%2Fdnit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulThompson%2Fdnit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulThompson%2Fdnit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulThompson%2Fdnit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PaulThompson","download_url":"https://codeload.github.com/PaulThompson/dnit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248813799,"owners_count":21165634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","task-runner","typescript"],"created_at":"2024-10-15T06:07:56.798Z","updated_at":"2025-10-03T21:40:54.286Z","avatar_url":"https://github.com/PaulThompson.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dnit - A typescript (deno) based task runner\n\nDnit is a task runner based on typescript and Deno. It uses typescript variables\nfor tasks and dependencies and is aimed at larger projects with tasks split\nacross many files or shared between projects.\n\n## Installation:\n\n### Pre-Requisites\n\n- [Deno](https://deno.land/#installation)\n- Requires deno v1.16.4 or greater\n\n### Install\n\nIt is recommended to use `deno install` to install the tool, which provides a\nconvenient entrypoint script and aliases the permission flags.\n\n```\ndeno install --global --allow-read --allow-write --allow-run -f --name dnit https://deno.land/x/dnit@dnit-v1.14.4/main.ts\n```\n\nInstall from source checkout:\n\n```\ndeno install --global --allow-read --allow-write --allow-run -f --name dnit ./main.ts\n```\n\n- Read, Write and Run permissions are required in order to operate on files and\n  execute tasks.\n\n## Sample Usage\n\n```ts\nimport {\n  file,\n  main,\n  task,\n} from \"https://deno.land/x/dnit@dnit-v1.14.4/dnit.ts\";\n\n/// A file to be tracked as a target and dependency:\nexport const msg = file({\n  path: \"./msg.txt\",\n});\n\n/// A task definition.  No side effect is incurred by creating a task.\nexport const helloWorld = task({\n  name: \"helloWorld\",\n  description: \"foo\",\n  action: async () =\u003e { /// Actions are typescript async ()=\u003e Promise\u003cvoid\u003e functions.\n    await Deno.run({\n      cmd: [\"./writeMsg.sh\"],\n    }).status();\n  },\n  deps: [\n    file({\n      path: \"./writeMsg.sh\",\n    }),\n  ],\n  targets: [\n    msg,\n  ],\n});\n\nexport const goodbye = task({\n  name: \"goodbye\",\n  action: async () =\u003e {\n    // use ordinary typescript idiomatically if several actions are required\n    const actions = [\n      async () =\u003e {\n        const txt = await Deno.readTextFile(msg.path);\n        console.log(txt);\n      },\n      async () =\u003e {\n        console.log(\"...\");\n      },\n    ];\n    for (const action of actions) {\n      await action();\n    }\n  },\n  deps: [msg], /// Dependency added as a typescript variable\n  ///   Dependencies can be file dependency or task dependencies.\n});\n\n/// Register cmdline args \u0026 tasks with the tool.\nmain(Deno.args, [helloWorld, goodbye]);\n```\n\n## Sample Usage - CLI\n\n- List tasks available:\n\n```\ndnit list\n```\n\n- Execute a task by name:\n\n```\ndnit helloWorld\n```\n\n- Verbose logging:\n\n```\ndnit list --verbose\n```\n\nIn verbose mode the tool logs to stderr (fd #2)\n\n## Tasks and Files in Detail\n\nFiles are tracked by the exported\n`export function file(fileParams: FileParams) : TrackedFile`\n\n```ts\n/** User params for a tracked file */\nexport type FileParams = {\n  /// File path\n  path: string;\n\n  /// Optional function for how to hash the file.   Defaults to the sha1 hash of the file contents.\n  /// A file is out of date if the file timestamp and the hash are different than that in the task manifest\n  gethash?: GetFileHash;\n};\n```\n\n`TrackedFile` objects are used in tasks, either as targets or dependencies.\n\nTasks are created by the exported `function task(taskParams: TaskParams): Task`\n\n```ts\n/** User definition of a task */\nexport type TaskParams = {\n  /// Name: (string) - The key used to initiate a task\n  name: A.TaskName;\n\n  /// Description (string) - Freeform text description shown on help\n  description?: string;\n\n  /// Action executed on execution of the task (async or sync)\n  action: Action;\n\n  /// Optional list of explicit task dependencies\n  task_deps?: Task[];\n\n  /// Optional list of explicit file dependencies\n  file_deps?: TrackedFile[];\n\n  /// Optional list of task or file dependencies\n  deps?: (Task | TrackedFile)[];\n\n  /// Targets (files which will be produced by execution of this task)\n  targets?: TrackedFile[];\n\n  /// Custom up-to-date definition - Can be used to make a task *less* up to date.  Eg; use uptodate: runAlways  to run always on request regardless of dependencies being up to date.\n  uptodate?: IsUpToDate;\n};\n```\n\nTasks are passed to the exported\n`export async function exec(cliArgs: string[], tasks: Task[]) : Promise\u003cvoid\u003e`\nThis exposes the tasks for execution by the CLI and executes them according to\nthe `cliArgs` passed in.\n\n```ts\nexec(Deno.args, tasks);\n```\n\n## Larger Scale use of tasks\n\nThis tool aims to support \"large\" projects with many tasks and even sharing task\ndefinitions across projects.\n\n- Tasks and dependencies are typescript variables, can be imported/exported and\n  used. This makes a large project of tasks and dependencies easy to navigate in\n  a typescript IDE.\n- User scripts are required to reside in a `dnit` directory. This provides a\n  place to have a (deno) typescript tree for the task scripting, which\n  encourages tasks to be separated into modules and generally organised as a\n  typescript project tree.\n- User scripts can have an `import_map.json` file in order to import tasks and\n  utils more flexibly.\n- The main `dnit` tool can be executed on its own (see section on\n  [Installation](#Installation) above)\n\n## Launching the tool\n\nThe `dnit` tool searches for a user script to execute, in order to support the\n[abovementioned](#Larger-Scale-use-of-tasks) directory of sources.\n\n- When `dnit` is the main it runs the `launch` function to run the user's\n  scripts.\n- It starts from the current working directory and runs `findUserSource`\n- `findUserSource` looks for subdirectory `dnit` and looks for sources `main.ts`\n  or `dnit.ts`\n  - It optionally looks for `import_map.json` or `.import_map.json` to use as\n    the import map.\n  - If found then it changes working directory and executes the user script.\n  - If not found then it recurses into `findUserSource` in the parent directory.\n\nEg: with a file layout:\n\n```\nrepo\n  dnit\n    main.ts\n    import_map.json\n  src\n    project.ts\n  package.json\n  tsconfig.json\n```\n\nExecuting `dnit` anywhere in a subdirectory of `repo` will execute the\n`main.ts`. Any relative paths used for dependencies and targets will resolve\nrelative to the `repo` root, since it is where the subdirectory and file\n`dnit/main.ts` was found.\n\nNote that the other directories can contain (non-deno) typescript project(s) and\nhaving the (deno) typescript sources in a nominal `dnit` tree helps prevent\nconfusion between the two.\n\n## Tab Completion\n\nFor those using the tool under bash, simply execute\n\n`dnit tabcompletion`\n\nThis will output a bash completion script that can be sourced in the current\nshell to provide tab completion for the relevant dnit tasks.\n\nor run `source \u003c(dnit tabcompletion)` to generate and source the tab completion\nin current shell.\n\n# References:\n\n- https://pydoit.org/\n  - A task runner written in python.\n- https://deno.land/x/drake/\n  - A deno task runner\n- https://deno.land/x/dunner\n  - A deno task runner\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulthompson%2Fdnit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulthompson%2Fdnit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulthompson%2Fdnit/lists"}