touch-all 0.0.1

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
@@ -0,0 +1,175 @@
1
+ # touch-all
2
+
3
+ CLI tool to create folder structures from markdown tree representations.
4
+
5
+ Pass a tree string — drawn with box-drawing characters or plain indentation — and `touch-all` creates every directory and file on disk.
6
+
7
+ ## Features
8
+
9
+ - Accepts tree strings in **box-drawing** (`├──`, `└──`, `│`) or **indentation** (spaces) format
10
+ - Trailing `/` marks a directory; no trailing `/` marks a file
11
+ - Inline comments stripped automatically (`# ...` and `// ...`)
12
+ - `--dry-run` parses and validates without touching the file system
13
+ - `--verbose` prints every created path
14
+ - Path traversal protection — no item can escape the target directory
15
+ - Importable as a Node.js library with full TypeScript types
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install -g touch-all
21
+ ```
22
+
23
+ Or run without installing:
24
+
25
+ ```bash
26
+ npx touch-all "..."
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ### Basic (current directory)
32
+
33
+ ```bash
34
+ touch-all "
35
+ my-project/
36
+ ├── src/
37
+ │ ├── index.ts
38
+ │ └── index.test.ts
39
+ ├── package.json
40
+ └── README.md
41
+ "
42
+ ```
43
+
44
+ ### Specify target directory
45
+
46
+ ```bash
47
+ touch-all "..." --path ./my-project
48
+ touch-all "..." -p ./my-project
49
+ ```
50
+
51
+ ### Dry run — parse and validate, no files created
52
+
53
+ ```bash
54
+ touch-all "..." --dry-run
55
+ touch-all "..." -n
56
+ ```
57
+
58
+ ### Verbose output
59
+
60
+ ```bash
61
+ touch-all "..." --verbose
62
+ touch-all "..." -v
63
+ ```
64
+
65
+ ### Help
66
+
67
+ ```bash
68
+ touch-all --help
69
+ ```
70
+
71
+ ## Tree Format
72
+
73
+ Both formats produce identical results.
74
+
75
+ ### Box-drawing characters
76
+
77
+ ```
78
+ my-project/
79
+ ├── .config/
80
+ │ ├── tsconfig.json
81
+ │ └── vite.config.ts
82
+ ├── src/
83
+ │ ├── index.ts
84
+ │ └── index.test.ts
85
+ ├── package.json
86
+ └── README.md
87
+ ```
88
+
89
+ ### Indentation (spaces)
90
+
91
+ ```
92
+ my-project/
93
+ .config/
94
+ tsconfig.json
95
+ vite.config.ts
96
+ src/
97
+ index.ts
98
+ index.test.ts
99
+ package.json
100
+ README.md
101
+ ```
102
+
103
+ ### Rules
104
+
105
+ | Syntax | Meaning |
106
+ |--------|---------|
107
+ | `name/` | directory |
108
+ | `name` | file |
109
+ | `dir/sub/` | directory at an explicit subpath |
110
+ | `dir/sub/file.ts` | file at an explicit subpath |
111
+ | `# comment` | ignored (stripped) |
112
+ | `// comment` | ignored (stripped) |
113
+
114
+ Items at the root level (no indentation / no parent) are created directly inside the target directory.
115
+
116
+ ## Library API
117
+
118
+ ```bash
119
+ npm install touch-all
120
+ ```
121
+
122
+ ```ts
123
+ import {
124
+ parserFolderStructure,
125
+ fileStructureCreator,
126
+ resolveProjectPathToBase,
127
+ PathTraversalError,
128
+ FsError,
129
+ cli,
130
+ } from 'touch-all'
131
+ import type { ParserResult, ParserResultLineItem } from 'touch-all'
132
+ ```
133
+
134
+ ### `parserFolderStructure(tree: string): ParserResult`
135
+
136
+ Parses a tree string into a flat list of `{ path, isFile }` items. Pure function, no I/O.
137
+
138
+ ```ts
139
+ const items = parserFolderStructure(`
140
+ src/
141
+ index.ts
142
+ `)
143
+ // [{ path: 'src', isFile: false }, { path: 'src/index.ts', isFile: true }]
144
+ ```
145
+
146
+ ### `fileStructureCreator(items: ParserResult, basePath: string): Effect<void, FsError | PathTraversalError>`
147
+
148
+ Creates the parsed structure on disk under `basePath`. Returns an [Effect](https://effect.website/).
149
+
150
+ ```ts
151
+ import { Effect } from 'effect'
152
+ import { NodeContext, NodeRuntime } from '@effect/platform-node'
153
+
154
+ const items = parserFolderStructure(tree)
155
+
156
+ fileStructureCreator(items, '/absolute/target/path').pipe(
157
+ Effect.provide(NodeContext.layer),
158
+ NodeRuntime.runMain,
159
+ )
160
+ ```
161
+
162
+ ### `resolveProjectPathToBase(projectPath: string, basePath: string): Effect<string, PathTraversalError>`
163
+
164
+ Resolves `projectPath` relative to `basePath` and rejects any path that would escape `basePath` (path traversal protection).
165
+
166
+ ### Error types
167
+
168
+ | Class | `_tag` | When thrown |
169
+ |-------|--------|-------------|
170
+ | `PathTraversalError` | `'PathTraversalError'` | Resolved path escapes `basePath`, or `basePath` is not absolute |
171
+ | `FsError` | `'FsError'` | `mkdirSync` or `writeFileSync` fails |
172
+
173
+ ## License
174
+
175
+ [GPL-3.0-or-later](https://www.gnu.org/licenses/gpl-3.0.html)