@eunjae/dots 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
File without changes
@@ -0,0 +1,30 @@
1
+ import{a as p,b as d}from"./chunk-BDBR3STW.js";import{exec as v}from"node:child_process";import{promisify as E}from"node:util";import{lstat as g,mkdir as R,readlink as h,rm as P,symlink as S}from"node:fs/promises";import{homedir as C}from"node:os";import{dirname as B,resolve as m}from"node:path";function w(t,e){return t.startsWith("~/")?m(C(),t.slice(2)):t.startsWith("./")||!t.startsWith("/")?m(e,t):t}async function y(t){try{return await g(t),!0}catch{return!1}}async function A(t){try{return(await g(t)).isSymbolicLink()}catch{return!1}}async function I(t,e,r){let n=w(t.src,e),s=w(t.dest,e);if(!await y(n))return{action:"skipped",src:n,dest:s,error:`Source does not exist: ${n}`};if(await y(s)){if(await A(s)&&await h(s)===n)return{action:"exists",src:n,dest:s};if(!t.force)return{action:"skipped",src:n,dest:s,error:"Destination exists and is not the correct symlink. Use force: true to overwrite."};r||await P(s,{recursive:!0})}return r||(await R(B(s),{recursive:!0}),await S(n,s)),{action:"created",src:n,dest:s}}async function u(t,e,r){let n=[];for(let s of t){let o=await I(s,e,r);n.push(o)}return n}var f=E(v);function D(t){return typeof t=="string"?{name:t}:t}async function H(){try{return await f("which brew"),!0}catch{return!1}}async function W(t,e){try{let r=e?`brew list --cask ${t}`:`brew list ${t}`;return await f(r),!0}catch{return!1}}async function F(t,e){let r=e?`brew install --cask ${t}`:`brew install ${t}`;await f(r)}async function L(t){return await H()?!0:t?(console.log("[dry-run] Would install Homebrew"),!1):(console.log("Installing Homebrew..."),await f('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'),!0)}async function T(t,e,r){let n=D(t),{name:s,cask:o=!1,symlinks:i}=n;if(await W(s,o)){let l={action:"exists",name:s,cask:o};return i&&i.length>0&&(l.symlinkResults=await u(i,e,r)),l}if(!r)try{await F(s,o)}catch(l){return{action:"skipped",name:s,cask:o,error:`Failed to install: ${l instanceof Error?l.message:String(l)}`}}let a={action:"installed",name:s,cask:o};return i&&i.length>0&&(a.symlinkResults=await u(i,e,r)),a}async function k(t,e,r){if(!await L(r)&&!r)throw new Error("Homebrew is not installed and could not be installed");let s=[];for(let o of t){let i=await T(o,e,r);s.push(i)}return s}import{exec as z}from"node:child_process";import{lstat as G,mkdir as N}from"node:fs/promises";import{homedir as U}from"node:os";import{resolve as $}from"node:path";import{promisify as j}from"node:util";var b=j(z);function q(t){return t.startsWith("~/")?$(U(),t.slice(2)):t}async function J(t){try{return await G(t),!0}catch{return!1}}async function K(t){try{return await b(`git -C "${t}" rev-parse --git-dir`),!0}catch{return!1}}async function M(t,e){let r=q(t.dest),{url:n}=t;if(await J(r))return await K(r)?{action:"exists",url:n,dest:r}:{action:"skipped",url:n,dest:r,error:`Destination exists but is not a git repository: ${r}`};if(!e){let s=$(r,"..");await N(s,{recursive:!0});try{await b(`git clone "${n}" "${r}"`)}catch(o){return{action:"skipped",url:n,dest:r,error:`Failed to clone: ${o instanceof Error?o.message:String(o)}`}}}return{action:"cloned",url:n,dest:r}}async function x(t,e){let r=[];for(let n of t){let s=await M(n,e);r.push(s)}return r}async function ft(t){let{process:e}=this,r=t.dry,n=d();r?e.stdout.write(`
2
+ \u{1F50D} Dry run mode - no changes will be made
3
+
4
+ `):e.stdout.write(`
5
+ \u{1F680} Applying configuration...
6
+
7
+ `);let s=await p(n);if(!s){e.stderr.write(`Error: No config file found. Create dots.config.ts in the current directory.
8
+ `),e.exit(1);return}if(s.repos&&s.repos.length>0){e.stdout.write(`\u{1F4E6} Repositories:
9
+ `);let o=await x(s.repos,r);for(let i of o){let a=r?"[dry-run] ":"";i.action==="cloned"?e.stdout.write(` ${a}\u2713 Cloned ${i.url} \u2192 ${i.dest}
10
+ `):i.action==="exists"?e.stdout.write(` ${a}\u2022 Already exists: ${i.dest}
11
+ `):i.action==="skipped"&&e.stdout.write(` ${a}\u2717 Skipped: ${i.error}
12
+ `)}e.stdout.write(`
13
+ `)}if(s.symlinks&&s.symlinks.length>0){e.stdout.write(`\u{1F517} Symlinks:
14
+ `);let o=await u(s.symlinks,n,r);for(let i of o){let a=r?"[dry-run] ":"";i.action==="created"?e.stdout.write(` ${a}\u2713 Created ${i.dest} \u2192 ${i.src}
15
+ `):i.action==="exists"?e.stdout.write(` ${a}\u2022 Already exists: ${i.dest}
16
+ `):i.action==="skipped"&&e.stdout.write(` ${a}\u2717 Skipped: ${i.error}
17
+ `)}e.stdout.write(`
18
+ `)}if(s.brew&&s.brew.length>0){e.stdout.write(`\u{1F37A} Homebrew packages:
19
+ `);let o=await k(s.brew,n,r);for(let i of o){let a=r?"[dry-run] ":"",l=i.cask?"(cask)":"";if(i.action==="installed"?e.stdout.write(` ${a}\u2713 Installed ${i.name} ${l}
20
+ `):i.action==="exists"?e.stdout.write(` ${a}\u2022 Already installed: ${i.name} ${l}
21
+ `):i.action==="skipped"&&e.stdout.write(` ${a}\u2717 Skipped ${i.name}: ${i.error}
22
+ `),i.symlinkResults)for(let c of i.symlinkResults)c.action==="created"?e.stdout.write(` ${a}\u2713 Symlink: ${c.dest} \u2192 ${c.src}
23
+ `):c.action==="exists"?e.stdout.write(` ${a}\u2022 Symlink exists: ${c.dest}
24
+ `):c.action==="skipped"&&e.stdout.write(` ${a}\u2717 Symlink skipped: ${c.error}
25
+ `)}e.stdout.write(`
26
+ `)}r?e.stdout.write(`\u2705 Dry run complete. Run without --dry to apply changes.
27
+
28
+ `):e.stdout.write(`\u2705 Configuration applied successfully!
29
+
30
+ `)}export{ft as default};
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{a as o,b as s}from"../chunk-KA6X4VA7.js";import"../chunk-M6CGD2MY.js";import{proposeCompletions as r}from"@stricli/core";var t=process.argv.slice(3);process.env.COMP_LINE?.endsWith(" ")&&t.push("");await r(o,t,s(process));try{for(let{completion:p}of await r(o,t,s(process)))process.stdout.write(`${p}
3
+ `)}catch{}
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{a as r,b as o}from"../chunk-KA6X4VA7.js";import"../chunk-M6CGD2MY.js";import{run as i}from"@stricli/core";await i(r,process.argv.slice(2),o(process));
@@ -0,0 +1 @@
1
+ import{resolve as r}from"node:path";var i=["dots.config.ts","dots.config.js"];async function e(o){for(let t of i){let n=r(o,t);try{return(await import(n)).default}catch{}}return null}function c(){return process.cwd()}export{e as a,c as b};
@@ -0,0 +1 @@
1
+ import{a as o,b as t,c as e}from"./chunk-M6CGD2MY.js";import{buildApplication as n,buildCommand as r,buildRouteMap as a}from"@stricli/core";var p=r({loader:async()=>import("./init.impl-TRNCU4YD.js"),parameters:{positional:{kind:"tuple",parameters:[{brief:"Git URL of the config repository (omit to create new project)",parse:String,placeholder:"repo-url",optional:!0}]},flags:{path:{kind:"parsed",brief:"Path for the dotfiles directory",parse:String,default:"~/.dots"}}},docs:{brief:"Initialize dots (clone existing repo or create new project)"}}),s=r({loader:async()=>import("./apply.impl-XFYGPQDM.js"),parameters:{flags:{dry:{kind:"boolean",brief:"Show what would be done without making changes",default:!1}}},docs:{brief:"Apply the configuration from the current directory"}}),c=a({routes:{init:p,apply:s},docs:{brief:t}}),C=n(c,{name:o,versionInfo:{currentVersion:e}});import l from"node:fs";import m from"node:os";import d from"node:path";function g(i){return{process:i,os:m,fs:l,path:d}}export{C as a,g as b};
@@ -0,0 +1 @@
1
+ var s="@eunjae/dots";var i="Declarative dotfiles and Mac setup manager";var n="0.0.0";export{s as a,i as b,n as c};
@@ -0,0 +1,26 @@
1
+ interface SymlinkConfig {
2
+ src: string;
3
+ dest: string;
4
+ force?: boolean;
5
+ }
6
+ interface BrewPackageConfig {
7
+ name: string;
8
+ cask?: boolean;
9
+ symlinks?: SymlinkConfig[];
10
+ }
11
+ type BrewItem = string | BrewPackageConfig;
12
+ interface RepoConfig {
13
+ url: string;
14
+ dest: string;
15
+ }
16
+ interface DotsConfig {
17
+ repos?: RepoConfig[];
18
+ symlinks?: SymlinkConfig[];
19
+ brew?: BrewItem[];
20
+ }
21
+ declare function defineConfig(config: DotsConfig): DotsConfig;
22
+
23
+ declare function loadConfig(dir: string): Promise<DotsConfig | null>;
24
+ declare function findConfigDir(): string;
25
+
26
+ export { BrewItem, BrewPackageConfig, DotsConfig, RepoConfig, SymlinkConfig, defineConfig, findConfigDir, loadConfig };
@@ -0,0 +1 @@
1
+ import{a as o,b as n}from"../chunk-BDBR3STW.js";function i(e){return e}export{i as defineConfig,n as findConfigDir,o as loadConfig};
@@ -0,0 +1,127 @@
1
+ import{c as l}from"./chunk-M6CGD2MY.js";import{exec as y}from"node:child_process";import{lstat as h,mkdir as p,readFile as f,writeFile as r}from"node:fs/promises";import{homedir as d}from"node:os";import{resolve as n}from"node:path";import{promisify as b}from"node:util";var c=e=>`{
2
+ "name": "dotfiles",
3
+ "private": true,
4
+ "type": "module",
5
+ "devDependencies": {
6
+ "@eunjae/dots": "^${e}"
7
+ }
8
+ }
9
+ `,w=`node_modules
10
+ `,g=`import { defineConfig } from "@eunjae/dots";
11
+
12
+ export default defineConfig({
13
+ // Clone additional repositories
14
+ // repos: [
15
+ // { url: "git@github.com:user/project.git", dest: "~/workspace/project" },
16
+ // ],
17
+
18
+ // Create symlinks
19
+ symlinks: [
20
+ // { src: "./zshrc", dest: "~/.zshrc" },
21
+ // { src: "./gitconfig", dest: "~/.gitconfig" },
22
+ ],
23
+
24
+ // Install Homebrew packages
25
+ brew: [
26
+ // "git",
27
+ // "ripgrep",
28
+ // {
29
+ // name: "neovim",
30
+ // symlinks: [{ src: "./nvim", dest: "~/.config/nvim" }],
31
+ // },
32
+ ],
33
+ });
34
+ `,m=`# Dotfiles
35
+
36
+ Managed with [@eunjae/dots](https://github.com/eunjae-lee/dots).
37
+
38
+ ## Setup on a new machine
39
+
40
+ \`\`\`bash
41
+ npx @eunjae/dots init git@github.com:YOUR_USERNAME/dotfiles.git
42
+ \`\`\`
43
+
44
+ ## Apply changes
45
+
46
+ \`\`\`bash
47
+ cd ~/.dots
48
+ npx @eunjae/dots apply
49
+ \`\`\`
50
+
51
+ ## Preview changes (dry run)
52
+
53
+ \`\`\`bash
54
+ npx @eunjae/dots apply --dry
55
+ \`\`\`
56
+ `;var s=b(y);async function u(e){try{return await h(e),!0}catch{return!1}}async function S(){try{return await s("which brew"),!0}catch{return!1}}async function k(){console.log("Installing Homebrew..."),await s('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"',{stdio:"inherit"})}async function x(e){try{return await s(`brew list ${e}`),!0}catch{return!1}}async function C(e){console.log(`Installing ${e}...`),await s(`brew install ${e}`)}async function H(){let e=n(d(),".ssh"),i=["id_ed25519","id_rsa","id_ecdsa"];for(let t of i)if(await u(n(e,t)))return!0;return!1}async function $(){let e=n(d(),".ssh","id_ed25519");return console.log("Generating SSH key..."),await s(`ssh-keygen -t ed25519 -f "${e}" -N ""`),(await f(`${e}.pub`,"utf-8")).trim()}async function j(){let e=n(d(),".ssh"),i=["id_ed25519.pub","id_rsa.pub","id_ecdsa.pub"];for(let t of i){let o=n(e,t);if(await u(o))return(await f(o,"utf-8")).trim()}throw new Error("No SSH public key found")}async function v(){try{await s("ssh -T git@github.com 2>&1 || true");let{stderr:e}=await s("ssh -T git@github.com 2>&1 || true");return e.includes("successfully authenticated")||e.includes("You've successfully authenticated")}catch{return!1}}async function E(e,i){if(i.stdout.write(`
57
+ \u{1F4C1} Creating new dotfiles project at ${e}
58
+
59
+ `),await u(e)){i.stderr.write(`Error: Directory already exists: ${e}
60
+ `),i.exit(1);return}await p(e,{recursive:!0}),await r(n(e,"package.json"),c(l)),await r(n(e,".gitignore"),w),await r(n(e,"dots.config.ts"),g),await r(n(e,"README.md"),m),i.stdout.write(` \u2713 Created package.json
61
+ `),i.stdout.write(` \u2713 Created .gitignore
62
+ `),i.stdout.write(` \u2713 Created dots.config.ts
63
+ `),i.stdout.write(` \u2713 Created README.md
64
+ `),await s(`git -C "${e}" init`),i.stdout.write(` \u2713 Initialized git repository
65
+ `),i.stdout.write(`
66
+ \u{1F4E6} Installing dependencies...
67
+ `);try{await s(`cd "${e}" && npm install`),i.stdout.write(` \u2713 Dependencies installed
68
+ `)}catch{i.stdout.write(` \u26A0 Could not install dependencies (package may not be published yet)
69
+ `),i.stdout.write(` Run 'npm install' manually after publishing @eunjae/dots
70
+ `)}i.stdout.write(`
71
+ \u2705 Project created!
72
+
73
+ `),i.stdout.write(`Next steps:
74
+ `),i.stdout.write(` cd ${e}
75
+ `),i.stdout.write(` # Edit dots.config.ts
76
+ `),i.stdout.write(` # Add your dotfiles (zshrc, gitconfig, etc.)
77
+ `),i.stdout.write(` git remote add origin git@github.com:YOUR_USERNAME/dotfiles.git
78
+ `),i.stdout.write(` npx @eunjae/dots apply --dry
79
+
80
+ `)}async function I(e,i,t){t.stdout.write(`
81
+ \u{1F680} Initializing dots with config repo: ${e}
82
+
83
+ `),t.stdout.write(`Step 1: Checking Homebrew...
84
+ `),await S()?t.stdout.write(` \u2713 Homebrew is installed
85
+ `):(await k(),t.stdout.write(` \u2713 Homebrew installed
86
+ `)),t.stdout.write(`
87
+ Step 2: Installing git and gh...
88
+ `);for(let a of["git","gh"])await x(a)?t.stdout.write(` \u2713 ${a} is installed
89
+ `):(await C(a),t.stdout.write(` \u2713 ${a} installed
90
+ `));t.stdout.write(`
91
+ Step 3: Setting up SSH key...
92
+ `);let o;if(await H()?(o=await j(),t.stdout.write(` \u2713 SSH key exists
93
+ `)):(o=await $(),t.stdout.write(` \u2713 SSH key generated
94
+ `)),t.stdout.write(`
95
+ Step 4: Checking GitHub SSH access...
96
+ `),await v())t.stdout.write(` \u2713 GitHub SSH access confirmed
97
+ `);else{t.stdout.write(`
98
+ \u26A0\uFE0F SSH key not added to GitHub yet.
99
+ `),t.stdout.write(`
100
+ Your public key:
101
+ `),t.stdout.write(` ${o}
102
+
103
+ `),t.stdout.write(` Please add this key to GitHub:
104
+ `),t.stdout.write(` 1. Go to https://github.com/settings/keys
105
+ `),t.stdout.write(` 2. Click 'New SSH key'
106
+ `),t.stdout.write(` 3. Paste the key above
107
+ `),t.stdout.write(` 4. Re-run this command after adding the key
108
+
109
+ `),t.stdout.write(` Or run: gh auth login
110
+
111
+ `);return}t.stdout.write(`
112
+ Step 5: Cloning config repo to ${i}...
113
+ `),await u(i)?t.stdout.write(` \u2713 Config repo already exists at ${i}
114
+ `):(await s(`git clone "${e}" "${i}"`),t.stdout.write(` \u2713 Config repo cloned
115
+ `)),t.stdout.write(`
116
+ Step 6: Installing dependencies...
117
+ `);try{await s(`cd "${i}" && npm install`),t.stdout.write(` \u2713 Dependencies installed
118
+ `)}catch{t.stdout.write(` \u26A0 Could not install dependencies
119
+ `),t.stdout.write(` Run 'npm install' manually in the config directory
120
+ `)}t.stdout.write(`
121
+ \u2705 Bootstrap complete!
122
+
123
+ `),t.stdout.write(`Next steps:
124
+ `),t.stdout.write(` cd ${i}
125
+ `),t.stdout.write(` npx @eunjae/dots apply
126
+
127
+ `)}async function K(e,i){let{process:t}=this,o=e.path.startsWith("~/")?n(d(),e.path.slice(2)):n(e.path);i?await I(i,o,t):await E(o,t)}export{K as default};
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@eunjae/dots",
3
+ "author": "Eunjae Lee",
4
+ "description": "Declarative dotfiles and Mac setup manager",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "version": "0.0.0",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/config/index.d.ts",
14
+ "import": "./dist/config/index.js"
15
+ }
16
+ },
17
+ "bin": {
18
+ "dots": "dist/cli.js",
19
+ "__dots_bash_complete": "dist/bash-complete.js"
20
+ },
21
+ "engines": {
22
+ "node": ">=22"
23
+ },
24
+ "scripts": {
25
+ "dev": "bun run src/bin/cli.ts",
26
+ "dev:watch": "bun --watch run src/bin/cli.ts",
27
+ "prebuild": "tsc -p src/tsconfig.json",
28
+ "build": "tsup --silent",
29
+ "prepublishOnly": "npm run build",
30
+ "postinstall": "npx @stricli/auto-complete@latest install dots --bash __dots_bash_complete",
31
+ "prepare": "husky",
32
+ "lint": "biome check src",
33
+ "lint:fix": "biome check --write src",
34
+ "format": "biome format --write src"
35
+ },
36
+ "lint-staged": {
37
+ "*.ts": [
38
+ "biome check --write --no-errors-on-unmatched"
39
+ ]
40
+ },
41
+ "tsup": {
42
+ "entry": [
43
+ "src/bin/cli.ts",
44
+ "src/bin/bash-complete.ts",
45
+ "src/config/index.ts"
46
+ ],
47
+ "dts": true,
48
+ "format": [
49
+ "esm"
50
+ ],
51
+ "tsconfig": "src/tsconfig.json",
52
+ "clean": true,
53
+ "splitting": true,
54
+ "minify": true
55
+ },
56
+ "dependencies": {
57
+ "@stricli/auto-complete": "^1.2.5",
58
+ "@stricli/core": "^1.2.5"
59
+ },
60
+ "devDependencies": {
61
+ "@biomejs/biome": "^2.3.13",
62
+ "@types/node": "22.x",
63
+ "husky": "^9.1.7",
64
+ "lint-staged": "^16.2.7",
65
+ "semantic-release": "^24.0.0",
66
+ "tsup": "^6.7.0",
67
+ "typescript": "5.6.x"
68
+ },
69
+ "repository": {
70
+ "type": "git",
71
+ "url": "https://github.com/eunjae-lee/dots.git"
72
+ }
73
+ }