touch-all 1.2.1 → 2.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 +45 -10
- package/dist/lib/index.js +824 -44
- package/dist/lib/src/_commonTypes.d.ts +10 -3
- package/dist/lib/src/cli.d.ts +1 -1
- package/dist/lib/src/fsGenerator.d.ts +2 -2
- package/dist/lib/src/fsNormalizator.d.ts +2 -1
- package/dist/slim/touch-all.js +896 -75
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,8 @@ It behaves like `mkdir -p` and `touch` combined, creating directories and files
|
|
|
10
10
|
|
|
11
11
|
- Accepts tree strings in **box-drawing** (`├──`, `└──`, `│`) or **indentation** (spaces) format
|
|
12
12
|
- Trailing slash `/` marks a directory; no trailing `/` marks a file
|
|
13
|
-
- Inline comments stripped automatically (`#
|
|
13
|
+
- Inline comments stripped automatically (`# ...`, `// ...`, `<- ...`, `← ...`)
|
|
14
|
+
- Symlink creation with `link-name -> target` syntax
|
|
14
15
|
- `--dry-run` parses and validates without touching the file system
|
|
15
16
|
- `--verbose` prints every created path
|
|
16
17
|
- Path traversal protection — no item can escape the target directory
|
|
@@ -66,6 +67,13 @@ touch-all "..." --verbose
|
|
|
66
67
|
touch-all "..." -v
|
|
67
68
|
```
|
|
68
69
|
|
|
70
|
+
- `--yes` , `-y` – skips the confirmation prompt when symlinks point outside the project root. Required in non-interactive environments (scripts, CI).
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
touch-all "..." --yes
|
|
74
|
+
touch-all "..." -y
|
|
75
|
+
```
|
|
76
|
+
|
|
69
77
|
- `--completions` – generates a completion script for a specific shell. Supported shells: `sh`, `bash`, `fish`, `zsh`.
|
|
70
78
|
- `--log-level` – sets the minimum log level for a command. Supported levels: `all`, `trace`, `debug`, `info`, `warning`, `error`, `fatal`, `none`. The default log level is `warning`.
|
|
71
79
|
- `--help` , `-h` – shows the help documentation for a command.
|
|
@@ -114,9 +122,30 @@ Both formats produce identical results.
|
|
|
114
122
|
| `dir/sub/file.ts` | file at an explicit subpath |
|
|
115
123
|
| `... # comment` | ignored (stripped) |
|
|
116
124
|
| `... // comment` | ignored (stripped) |
|
|
125
|
+
| `... <- comment` | ignored (stripped) |
|
|
126
|
+
| `... ← comment` | ignored (stripped) |
|
|
127
|
+
| `name -> target` | symlink pointing to `target` |
|
|
117
128
|
|
|
118
129
|
Items at the root level (no indentation / no parent) are created directly inside the target directory.
|
|
119
130
|
|
|
131
|
+
### Symlinks
|
|
132
|
+
|
|
133
|
+
Use `link-name -> target` to create a symlink. The target is passed as-is to the OS — use paths relative to the symlink's location, just as you would in a shell.
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
my-project/
|
|
137
|
+
src/
|
|
138
|
+
index.ts
|
|
139
|
+
utils -> ../shared/utils.ts # symlink to a sibling directory
|
|
140
|
+
shared/
|
|
141
|
+
utils.ts
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
If `target` ends with `/`, the symlink is created as a directory symlink (relevant on Windows). The link name's suffix is ignored.
|
|
145
|
+
|
|
146
|
+
> [!WARNING]
|
|
147
|
+
> If any symlink target resolves outside the project root (`--path`), `touch-all` will prompt for confirmation before proceeding. Use `--yes` to skip the prompt in scripts or CI.
|
|
148
|
+
|
|
120
149
|
## Library API
|
|
121
150
|
|
|
122
151
|
```bash
|
|
@@ -136,21 +165,27 @@ import type { ParserResult, ParserResultLineItem } from 'touch-all'
|
|
|
136
165
|
|
|
137
166
|
### `parserFolderStructure(tree: string): ParserResult`
|
|
138
167
|
|
|
139
|
-
Parses a tree string into a flat list of
|
|
168
|
+
Parses a tree string into a flat list of items. Pure function, no I/O.
|
|
169
|
+
|
|
170
|
+
Each item is one of:
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
type ParserResultLineItem =
|
|
174
|
+
| { type: 'file'; path: string }
|
|
175
|
+
| { type: 'folder'; path: string }
|
|
176
|
+
| { type: 'symlink'; path: string; target: string }
|
|
177
|
+
```
|
|
140
178
|
|
|
141
179
|
```ts
|
|
142
180
|
const items = parserFolderStructure(`
|
|
143
181
|
src/
|
|
144
182
|
index.ts
|
|
183
|
+
link -> ../shared.ts
|
|
145
184
|
`)
|
|
146
185
|
// [
|
|
147
|
-
//
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
// }, {
|
|
151
|
-
// path: 'src/index.ts',
|
|
152
|
-
// isFile: true
|
|
153
|
-
// }
|
|
186
|
+
// { type: 'folder', path: 'src' },
|
|
187
|
+
// { type: 'file', path: 'src/index.ts' },
|
|
188
|
+
// { type: 'symlink', path: 'src/link', target: '../shared.ts' },
|
|
154
189
|
// ]
|
|
155
190
|
```
|
|
156
191
|
|
|
@@ -180,7 +215,7 @@ Resolves `projectPath` relative to `basePath` and rejects any path that would es
|
|
|
180
215
|
| Class | `_tag` | When thrown |
|
|
181
216
|
| -------------------- | ---------------------- | --------------------------------------------------------------- |
|
|
182
217
|
| `PathTraversalError` | `'PathTraversalError'` | Resolved path escapes `basePath`, or `basePath` is not absolute |
|
|
183
|
-
| `FsError` | `'FsError'` | `mkdirSync` or `
|
|
218
|
+
| `FsError` | `'FsError'` | `mkdirSync`, `writeFileSync`, or `symlinkSync` fails |
|
|
184
219
|
|
|
185
220
|
## License
|
|
186
221
|
|