mohyung 0.1.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/LICENSE +21 -0
- package/README.md +177 -0
- package/dist/cli.js +816 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +340 -0
- package/dist/index.js +804 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cbcruk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# mohyung
|
|
2
|
+
|
|
3
|
+
Snapshot and restore node_modules as a single SQLite file.
|
|
4
|
+
|
|
5
|
+
## Why?
|
|
6
|
+
|
|
7
|
+
- **Single file backup**: Manage as one `.db` file instead of tens of thousands of files
|
|
8
|
+
- **Fast restoration**: Quick node_modules restoration with compression + deduplication
|
|
9
|
+
- **Version control friendly**: SQLite format enables binary diff
|
|
10
|
+
- **Content-addressable**: Identical files are stored only once (deduplication)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g mohyung
|
|
16
|
+
# or
|
|
17
|
+
pnpm add -g mohyung
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### pack - Snapshot node_modules into DB
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
mohyung pack [options]
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
-s, --source <path> node_modules path (default: "./node_modules")
|
|
29
|
+
-o, --output <path> output DB file path (default: "./node_modules.db")
|
|
30
|
+
-c, --compression <level> compression level 1-9 (default: "6")
|
|
31
|
+
--include-lockfile include package-lock.json hash
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Examples:**
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Basic usage
|
|
38
|
+
mohyung pack
|
|
39
|
+
|
|
40
|
+
# Custom paths
|
|
41
|
+
mohyung pack -s ./my-project/node_modules -o ./backup.db
|
|
42
|
+
|
|
43
|
+
# Maximum compression
|
|
44
|
+
mohyung pack -c 9
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### unpack - Restore node_modules from DB
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
mohyung unpack [options]
|
|
51
|
+
|
|
52
|
+
Options:
|
|
53
|
+
-i, --input <path> input DB file path (default: "./node_modules.db")
|
|
54
|
+
-o, --output <path> output directory (default: "./node_modules")
|
|
55
|
+
-f, --force overwrite existing node_modules
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Examples:**
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Basic restoration
|
|
62
|
+
mohyung unpack
|
|
63
|
+
|
|
64
|
+
# Force overwrite
|
|
65
|
+
mohyung unpack -f
|
|
66
|
+
|
|
67
|
+
# Restore to different location
|
|
68
|
+
mohyung unpack -o ./restored_modules
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### status - Compare DB with current state
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
mohyung status [options]
|
|
75
|
+
|
|
76
|
+
Options:
|
|
77
|
+
--db <path> DB file path (default: "./node_modules.db")
|
|
78
|
+
-n, --node-modules <path> node_modules path (default: "./node_modules")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Examples:**
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
mohyung status
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Output:**
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
┌─ Status ─────────────────────────────┐
|
|
91
|
+
│ Unchanged: 12,345 │
|
|
92
|
+
│ Modified: 3 │
|
|
93
|
+
│ Only in DB: 1 │
|
|
94
|
+
│ │
|
|
95
|
+
│ Modified files: │
|
|
96
|
+
│ M lodash/index.js │
|
|
97
|
+
│ M express/lib/router.js │
|
|
98
|
+
└──────────────────────────────────────┘
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## DB Schema
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
105
|
+
│ SQLite DB │
|
|
106
|
+
├─────────────┬───────────────────────────────────────────────┤
|
|
107
|
+
│ metadata │ created_at, node_version, schema_version, ... │
|
|
108
|
+
├─────────────┼───────────────────────────────────────────────┤
|
|
109
|
+
│ packages │ id, name, version, path │
|
|
110
|
+
├─────────────┼───────────────────────────────────────────────┤
|
|
111
|
+
│ blobs │ hash (PK), content (compressed), sizes │
|
|
112
|
+
├─────────────┼───────────────────────────────────────────────┤
|
|
113
|
+
│ files │ package_id, relative_path, blob_hash, mode │
|
|
114
|
+
└─────────────┴───────────────────────────────────────────────┘
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Content-addressable Storage:**
|
|
118
|
+
|
|
119
|
+
- Uses SHA-256 hash of file content as key
|
|
120
|
+
- Identical files are stored only once
|
|
121
|
+
- zlib compression for storage efficiency
|
|
122
|
+
|
|
123
|
+
## Requirements
|
|
124
|
+
|
|
125
|
+
- Node.js >= 18.0.0
|
|
126
|
+
- Supports npm, yarn, and pnpm
|
|
127
|
+
|
|
128
|
+
## Library Usage
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { pack, unpack, status, Store } from 'mohyung'
|
|
132
|
+
|
|
133
|
+
// Pack
|
|
134
|
+
await pack({
|
|
135
|
+
source: './node_modules',
|
|
136
|
+
output: './node_modules.db',
|
|
137
|
+
compressionLevel: 6,
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
// Unpack
|
|
141
|
+
await unpack({
|
|
142
|
+
input: './node_modules.db',
|
|
143
|
+
output: './node_modules',
|
|
144
|
+
force: true,
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
// Status
|
|
148
|
+
const result = await status({
|
|
149
|
+
db: './node_modules.db',
|
|
150
|
+
nodeModules: './node_modules',
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
console.log(result.unchanged, result.modified, result.onlyInDb)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Development
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Install dependencies
|
|
160
|
+
pnpm install
|
|
161
|
+
|
|
162
|
+
# Development mode (watch)
|
|
163
|
+
pnpm dev
|
|
164
|
+
|
|
165
|
+
# Build
|
|
166
|
+
pnpm build
|
|
167
|
+
|
|
168
|
+
# Test
|
|
169
|
+
pnpm test
|
|
170
|
+
|
|
171
|
+
# Type check
|
|
172
|
+
pnpm typecheck
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT
|