{"id":21013885,"url":"https://github.com/kat0h/dfm","last_synced_at":"2025-05-15T04:34:40.416Z","repository":{"id":38679851,"uuid":"506682858","full_name":"kat0h/dfm","owner":"kat0h","description":"A dotfliles manager [NO DSL] [Deno] [NO INSTALL]","archived":false,"fork":false,"pushed_at":"2023-12-26T12:17:44.000Z","size":63,"stargazers_count":23,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-27T16:04:43.976Z","etag":null,"topics":["deno","dotfiles-manager"],"latest_commit_sha":null,"homepage":"https://deno.land/x/dfm","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/kat0h.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":"2022-06-23T14:54:45.000Z","updated_at":"2023-09-25T01:18:52.000Z","dependencies_parsed_at":"2024-11-19T09:57:39.507Z","dependency_job_id":null,"html_url":"https://github.com/kat0h/dfm","commit_stats":{"total_commits":57,"total_committers":3,"mean_commits":19.0,"dds":"0.22807017543859653","last_synced_commit":"ac6edf82fcd187b269acbfcd402255cf1d6ed12b"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kat0h%2Fdfm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kat0h%2Fdfm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kat0h%2Fdfm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kat0h%2Fdfm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kat0h","download_url":"https://codeload.github.com/kat0h/dfm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254274696,"owners_count":22043568,"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","dotfiles-manager"],"created_at":"2024-11-19T09:44:26.332Z","updated_at":"2025-05-15T04:34:40.054Z","avatar_url":"https://github.com/kat0h.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dfm (Dotfiles Manager written in TypeScript)\n\n\u003cimg src=\"https://user-images.githubusercontent.com/45391880/184128345-ab2ed635-c9e8-466e-b9a1-d8b0d05e68a7.png\" width=\"50%\"\u003e\n\nExample: [My settings is here](https://github.com/kat0h/dotfiles/blob/master/bin/dot)\n\n```typescript\n#!/usr/bin/env -S deno run -A --ext ts\nimport Dfm from \"https://deno.land/x/dfm/mod.ts\";\nimport { Shell, Repository, Symlink } from \"https://deno.land/x/dfm/plugin/mod.ts\";\nimport { fromFileUrl } from \"https://deno.land/std@0.149.0/path/mod.ts\";\nimport { os } from \"https://deno.land/x/dfm/util/mod.ts\";\n\nconst dfm = new Dfm({\n  dotfilesDir: \"~/dotfiles\",\n  dfmFilePath: fromFileUrl(import.meta.url),\n});\n\nconst links: [string, string][] = [\n  [\"zshrc\", \"~/.zshrc\"],\n  [\"tmux.conf\", \"~/.tmux.conf\"],\n  [\"vimrc\", \"~/.vimrc\"],\n  [\"vim\", \"~/.vim\"],\n  [\"config/alacritty\", \"~/.config/alacritty\"],\n];\n\nconst cmds: string[] = [\n  \"vim\",\n  \"nvim\",\n  \"clang\",\n  \"curl\",\n  \"wget\",\n];\n\nlet path: string[] = [\n  \"~/.deno/bin\",\n]\n\nif (os() == \"darwin\") {\n  path = path.concat([\n    \"~/mybin\",\n    \"/usr/local/opt/ruby/bin\"\n  ])\n\n} else if (os() == \"linux\") {\n  path = path.concat([])\n}\n\n\ndfm.use(\n  new Symlink(dfm, links),\n  new Shell({\n    env_path: \"~/.cache/env\",\n    cmds: cmds,\n    path: path\n  }),\n  new Repository(dfm),\n);\ndfm.end();\n// vim:filetype=typescript\n```\n\n**WARNING** DFM is a experimental implementation based on my idea\n\nDFM is a dotfiles manager framework written in deno. This library is based on a\nnew (?) design.\n\n- not a command just library\n- no DSL\n- declarative setting (?)\n- do not depends on your memory\n\nI had the following complaints with my previous Dotfiles manager\n\n- I always forget command arguments.\n- It is difficult to learn complex DSLs.\n- The installation is complicated and requires many dependencies.\n\nDeno's dependency resolution system has solved these problems brilliantly.\n\nA single file manages the configuration settings and the commands to execute.\nDeno automatically resolves dependencies. Since all configuration settings are\nwritten in Typescript, conditional branching by the OS can be easily described\nin a familiar way.\n\n```typescript\n#!/usr/bin/env deno run -A\nimport Dfm from \"https://deno.land/x/dfm/mod.ts\";\nimport { fromFileUrl } from \"https://deno.land/std/path/mod.ts\";\n\nconst dfm = new Dfm({\n  dotfilesDir: \"~/dotfiles\",\n  dfmFilePath: fromFileUrl(import.meta.url),\n});\n\ndfm.end();\n```\n\n1. Import Dfm module from deno.land\n2. make instance of Dfm manager\n3. run command with `Dfm.prototype.end()`\n\nSave the script as command.sh and run then you would get this help.\n\n```\n$ ./command.sh\n\ndfm(3) v0.3\n\tA dotfiles manager written in deno (typescript)\n\nUSAGE:\n\tdeno run -A [filename] [SUBCOMMANDS]\n\nSUBCOMMANDS:\n\tstat\tshow status of settings\n\tlist\tshow list of settings\n\tsync\tapply settings\n\thelp\tshow this help\n```\n\nAs it is, it cannot be used as a Dotfiles manager. DFM provides the following\nfunctions as plugins.\n\n- symlink.ts\n  - Paste the specified symbolic link starting from the path specified by the\n    dotfilesDir option.\n- cmdcheck.ts\n  - Checks if the specified command exists in $PATH.\n- repository.ts\n  - It provides a subcommand that executes git commands starting from\n    dotfilesDir, a dir command that outputs dotfilesDir, and an edit command\n    that opens the configuration file itself in $EDITOR.\n\nPlease check the examples at the top of the page for specific usage.\n\n## Command\n\nSuppose the configuration file described above is placed as dfm in a directory\nwith $PATH.\n\n```\n$ dfm\n$ dfm help    # Display help. All subcommands are listed here\n\n$ dfm stat    # The stat() function implemented in Plugin is executed. For example, the Symlink Plugin checks if the link is properly posted and then calls the\n$ dfm list    # The list of all loaded Plugins and the list() function implemented in the Plugin are called.\n$ dfm sync    # Synchronizes the settings described in the configuration file with the actual PC; the sync() function implemented in the plugin is called\n```\n\n![](https://user-images.githubusercontent.com/45391880/181022336-b752eecf-4c1c-495d-98b0-8d0c96f6ae50.png)\nIf the configuration is correctly described, the `$ dfm list` command returns\noutput similar to the above.\n\n## Utility functions\n\nYou can import these functions from `https://deno.land/x/dfm/util/mod.ts`\n\n- `expandTilde()`\n  - expand \"~/\"\n- `resolvePath(path: string, basedir?: string)`\n  - ~ $BASEDIR -\u003e $HOME\n  - ../ $BASEDIR -\u003e $BASEDIR/../\n  - ./ $BASEDIR -\u003e $BASEDIR\n  - a $BASEDIR -\u003e $BASEDIR/a\n  - ./hoge/hugo -\u003e join($(pwd), \"./hoge/hugo\")\n  - /hoge/hugo -\u003e \"/hoge/hugo\"\n  - ~/hoge -\u003e \"$HOME/hugo\"\n- `isatty()`\n  - Same as isatty() in c language\n- `os()`\n  - Determines for which OS Deno was built\n\n## Security\n\nDeno imports and executes URLs described in the source code as is. While this\nfeature is convenient, it can easily lead to a supply chain attack if used\nincorrectly, so care must be taken. In the case of `deno.land/x/`, since\ndeno.land guarantees that the source code returned by the URL with a version\nnumber is immutable, you can ensure safety by specifying @ in the URL. In the\nabove example, the version number is not attached to the URL for the sake of\nsimplicity, but when actually using the URL, be sure to specify the version and\nimport it.\n\n## Author\n\nkotakato (@kat0h)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkat0h%2Fdfm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkat0h%2Fdfm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkat0h%2Fdfm/lists"}