@ecmaos/coreutils 0.2.1 → 0.3.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +37 -0
- package/LICENSE +1 -1
- package/dist/commands/cal.js +2 -2
- package/dist/commands/cal.js.map +1 -1
- package/dist/commands/cat.js +2 -2
- package/dist/commands/cd.js +2 -2
- package/dist/commands/chmod.d.ts.map +1 -1
- package/dist/commands/chmod.js +16 -11
- package/dist/commands/chmod.js.map +1 -1
- package/dist/commands/cp.js +2 -2
- package/dist/commands/cp.js.map +1 -1
- package/dist/commands/cron.d.ts +4 -0
- package/dist/commands/cron.d.ts.map +1 -0
- package/dist/commands/cron.js +439 -0
- package/dist/commands/cron.js.map +1 -0
- package/dist/commands/date.js +2 -2
- package/dist/commands/date.js.map +1 -1
- package/dist/commands/echo.js +2 -2
- package/dist/commands/echo.js.map +1 -1
- package/dist/commands/false.js +2 -2
- package/dist/commands/fetch.d.ts +4 -0
- package/dist/commands/fetch.d.ts.map +1 -0
- package/dist/commands/fetch.js +210 -0
- package/dist/commands/fetch.js.map +1 -0
- package/dist/commands/format.d.ts +4 -0
- package/dist/commands/format.d.ts.map +1 -0
- package/dist/commands/format.js +178 -0
- package/dist/commands/format.js.map +1 -0
- package/dist/commands/hash.d.ts +4 -0
- package/dist/commands/hash.d.ts.map +1 -0
- package/dist/commands/hash.js +200 -0
- package/dist/commands/hash.js.map +1 -0
- package/dist/commands/head.js +2 -2
- package/dist/commands/id.js +2 -2
- package/dist/commands/id.js.map +1 -1
- package/dist/commands/less.d.ts.map +1 -1
- package/dist/commands/less.js +53 -2
- package/dist/commands/less.js.map +1 -1
- package/dist/commands/ls.d.ts.map +1 -1
- package/dist/commands/ls.js +41 -15
- package/dist/commands/ls.js.map +1 -1
- package/dist/commands/man.d.ts +4 -0
- package/dist/commands/man.d.ts.map +1 -0
- package/dist/commands/man.js +564 -0
- package/dist/commands/man.js.map +1 -0
- package/dist/commands/mkdir.js +2 -2
- package/dist/commands/mkdir.js.map +1 -1
- package/dist/commands/mktemp.d.ts +4 -0
- package/dist/commands/mktemp.d.ts.map +1 -0
- package/dist/commands/mktemp.js +229 -0
- package/dist/commands/mktemp.js.map +1 -0
- package/dist/commands/nc.js +2 -2
- package/dist/commands/nc.js.map +1 -1
- package/dist/commands/open.d.ts +4 -0
- package/dist/commands/open.d.ts.map +1 -0
- package/dist/commands/open.js +74 -0
- package/dist/commands/open.js.map +1 -0
- package/dist/commands/passkey.js +3 -3
- package/dist/commands/play.d.ts +4 -0
- package/dist/commands/play.d.ts.map +1 -0
- package/dist/commands/play.js +231 -0
- package/dist/commands/play.js.map +1 -0
- package/dist/commands/pwd.js +2 -2
- package/dist/commands/pwd.js.map +1 -1
- package/dist/commands/rm.d.ts.map +1 -1
- package/dist/commands/rm.js +57 -12
- package/dist/commands/rm.js.map +1 -1
- package/dist/commands/rmdir.js +2 -2
- package/dist/commands/rmdir.js.map +1 -1
- package/dist/commands/sockets.js +1 -1
- package/dist/commands/stat.d.ts.map +1 -1
- package/dist/commands/stat.js +37 -15
- package/dist/commands/stat.js.map +1 -1
- package/dist/commands/tail.js +2 -2
- package/dist/commands/tar.d.ts +4 -0
- package/dist/commands/tar.d.ts.map +1 -0
- package/dist/commands/tar.js +743 -0
- package/dist/commands/tar.js.map +1 -0
- package/dist/commands/touch.js +2 -2
- package/dist/commands/touch.js.map +1 -1
- package/dist/commands/true.js +2 -2
- package/dist/commands/unzip.d.ts +4 -0
- package/dist/commands/unzip.d.ts.map +1 -0
- package/dist/commands/unzip.js +443 -0
- package/dist/commands/unzip.js.map +1 -0
- package/dist/commands/user.js +1 -1
- package/dist/commands/video.d.ts +4 -0
- package/dist/commands/video.d.ts.map +1 -0
- package/dist/commands/video.js +250 -0
- package/dist/commands/video.js.map +1 -0
- package/dist/commands/view.d.ts +4 -0
- package/dist/commands/view.d.ts.map +1 -0
- package/dist/commands/view.js +488 -0
- package/dist/commands/view.js.map +1 -0
- package/dist/commands/web.d.ts +4 -0
- package/dist/commands/web.d.ts.map +1 -0
- package/dist/commands/web.js +348 -0
- package/dist/commands/web.js.map +1 -0
- package/dist/commands/whoami.js +2 -2
- package/dist/commands/whoami.js.map +1 -1
- package/dist/commands/zip.d.ts +4 -0
- package/dist/commands/zip.d.ts.map +1 -0
- package/dist/commands/zip.js +264 -0
- package/dist/commands/zip.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
- package/src/commands/cal.ts +2 -2
- package/src/commands/cat.ts +2 -2
- package/src/commands/cd.ts +2 -2
- package/src/commands/chmod.ts +19 -11
- package/src/commands/cp.ts +2 -2
- package/src/commands/cron.ts +499 -0
- package/src/commands/date.ts +2 -2
- package/src/commands/echo.ts +2 -2
- package/src/commands/false.ts +2 -2
- package/src/commands/fetch.ts +205 -0
- package/src/commands/format.ts +204 -0
- package/src/commands/hash.ts +215 -0
- package/src/commands/head.ts +2 -2
- package/src/commands/id.ts +2 -2
- package/src/commands/less.ts +50 -2
- package/src/commands/ls.ts +40 -14
- package/src/commands/man.ts +651 -0
- package/src/commands/mkdir.ts +2 -2
- package/src/commands/mktemp.ts +235 -0
- package/src/commands/nc.ts +2 -2
- package/src/commands/open.ts +84 -0
- package/src/commands/passkey.ts +3 -3
- package/src/commands/play.ts +249 -0
- package/src/commands/pwd.ts +2 -2
- package/src/commands/rm.ts +54 -12
- package/src/commands/rmdir.ts +2 -2
- package/src/commands/sockets.ts +1 -1
- package/src/commands/stat.ts +44 -16
- package/src/commands/tail.ts +2 -2
- package/src/commands/tar.ts +780 -0
- package/src/commands/touch.ts +2 -2
- package/src/commands/true.ts +2 -2
- package/src/commands/unzip.ts +517 -0
- package/src/commands/user.ts +1 -1
- package/src/commands/video.ts +267 -0
- package/src/commands/view.ts +526 -0
- package/src/commands/web.ts +377 -0
- package/src/commands/whoami.ts +2 -2
- package/src/commands/zip.ts +319 -0
- package/src/index.ts +44 -2
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import * as zipjs from '@zip.js/zip.js'
|
|
3
|
+
import type { Kernel, Process, Shell, Terminal } from '@ecmaos/types'
|
|
4
|
+
import { TerminalCommand } from '../shared/terminal-command.js'
|
|
5
|
+
import { writelnStdout, writelnStderr } from '../shared/helpers.js'
|
|
6
|
+
import chalk from 'chalk'
|
|
7
|
+
|
|
8
|
+
function printUsage(process: Process | undefined, terminal: Terminal): void {
|
|
9
|
+
const usage = `Usage: zip [OPTION]... ZIPFILE FILE...
|
|
10
|
+
Create a zip archive containing the specified files and directories.
|
|
11
|
+
|
|
12
|
+
-r, --recurse recurse into directories
|
|
13
|
+
-l, --list list contents of zip file
|
|
14
|
+
-v, --verbose verbose mode
|
|
15
|
+
-h, --help display this help and exit
|
|
16
|
+
|
|
17
|
+
Examples:
|
|
18
|
+
zip archive.zip file1.txt file2.txt
|
|
19
|
+
zip -r archive.zip directory/
|
|
20
|
+
zip -l archive.zip`
|
|
21
|
+
writelnStderr(process, terminal, usage)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ZipOptions {
|
|
25
|
+
recurse: boolean
|
|
26
|
+
list: boolean
|
|
27
|
+
verbose: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function parseArgs(argv: string[]): { options: ZipOptions; zipfile: string | null; files: string[] } {
|
|
31
|
+
const options: ZipOptions = {
|
|
32
|
+
recurse: false,
|
|
33
|
+
list: false,
|
|
34
|
+
verbose: false
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const files: string[] = []
|
|
38
|
+
let zipfile: string | null = null
|
|
39
|
+
let i = 0
|
|
40
|
+
|
|
41
|
+
while (i < argv.length) {
|
|
42
|
+
const arg = argv[i]
|
|
43
|
+
if (!arg) {
|
|
44
|
+
i++
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (arg === '--help' || arg === '-h') {
|
|
49
|
+
i++
|
|
50
|
+
continue
|
|
51
|
+
} else if (arg === '-r' || arg === '--recurse') {
|
|
52
|
+
options.recurse = true
|
|
53
|
+
i++
|
|
54
|
+
} else if (arg === '-l' || arg === '--list') {
|
|
55
|
+
options.list = true
|
|
56
|
+
i++
|
|
57
|
+
} else if (arg === '-v' || arg === '--verbose') {
|
|
58
|
+
options.verbose = true
|
|
59
|
+
i++
|
|
60
|
+
} else if (arg.startsWith('-')) {
|
|
61
|
+
// Handle combined flags like -rv
|
|
62
|
+
const flags = arg.slice(1).split('')
|
|
63
|
+
for (const flag of flags) {
|
|
64
|
+
if (flag === 'r') options.recurse = true
|
|
65
|
+
else if (flag === 'l') options.list = true
|
|
66
|
+
else if (flag === 'v') options.verbose = true
|
|
67
|
+
}
|
|
68
|
+
i++
|
|
69
|
+
} else {
|
|
70
|
+
// First non-option argument is the zipfile
|
|
71
|
+
if (!zipfile) {
|
|
72
|
+
zipfile = arg
|
|
73
|
+
} else {
|
|
74
|
+
files.push(arg)
|
|
75
|
+
}
|
|
76
|
+
i++
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return { options, zipfile, files }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function addDirectory(
|
|
84
|
+
zipWriter: zipjs.ZipWriter<Blob>,
|
|
85
|
+
dirPath: string,
|
|
86
|
+
basePath: string,
|
|
87
|
+
shell: Shell,
|
|
88
|
+
terminal: Terminal,
|
|
89
|
+
process: Process | undefined,
|
|
90
|
+
verbose: boolean
|
|
91
|
+
): Promise<void> {
|
|
92
|
+
const entries = await shell.context.fs.promises.readdir(dirPath)
|
|
93
|
+
|
|
94
|
+
for (const entry of entries) {
|
|
95
|
+
const entryPath = path.join(dirPath, entry)
|
|
96
|
+
const relativePath = path.relative(basePath, entryPath)
|
|
97
|
+
const entryStat = await shell.context.fs.promises.stat(entryPath)
|
|
98
|
+
|
|
99
|
+
if (entryStat.isFile()) {
|
|
100
|
+
const fileData = await shell.context.fs.promises.readFile(entryPath)
|
|
101
|
+
const reader = new zipjs.Uint8ArrayReader(fileData)
|
|
102
|
+
await zipWriter.add(relativePath, reader)
|
|
103
|
+
if (verbose) {
|
|
104
|
+
await writelnStdout(process, terminal, ` adding: ${relativePath}`)
|
|
105
|
+
}
|
|
106
|
+
} else if (entryStat.isDirectory()) {
|
|
107
|
+
await addDirectory(zipWriter, entryPath, basePath, shell, terminal, process, verbose)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function listZipContents(
|
|
113
|
+
zipfilePath: string,
|
|
114
|
+
shell: Shell,
|
|
115
|
+
terminal: Terminal,
|
|
116
|
+
process: Process | undefined
|
|
117
|
+
): Promise<number> {
|
|
118
|
+
try {
|
|
119
|
+
const zipData = await shell.context.fs.promises.readFile(zipfilePath)
|
|
120
|
+
const blob = new Blob([new Uint8Array(zipData)])
|
|
121
|
+
const zipReader = new zipjs.ZipReader(new zipjs.BlobReader(blob))
|
|
122
|
+
const entries = await zipReader.getEntries()
|
|
123
|
+
|
|
124
|
+
if (entries.length === 0) {
|
|
125
|
+
await writelnStdout(process, terminal, 'Archive: ' + path.basename(zipfilePath))
|
|
126
|
+
await writelnStdout(process, terminal, ' Empty archive')
|
|
127
|
+
await zipReader.close()
|
|
128
|
+
return 0
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Calculate column widths
|
|
132
|
+
let maxLength = 0
|
|
133
|
+
let maxSize = 0
|
|
134
|
+
for (const entry of entries) {
|
|
135
|
+
if (entry.filename.length > maxLength) maxLength = entry.filename.length
|
|
136
|
+
const size = entry.uncompressedSize || 0
|
|
137
|
+
if (size > maxSize) maxSize = size
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const sizeWidth = Math.max(12, String(maxSize).length)
|
|
141
|
+
const nameWidth = Math.max(20, maxLength)
|
|
142
|
+
|
|
143
|
+
await writelnStdout(process, terminal, `Archive: ${path.basename(zipfilePath)}`)
|
|
144
|
+
await writelnStdout(process, terminal, '')
|
|
145
|
+
await writelnStdout(process, terminal,
|
|
146
|
+
` Length Date Time Name`.padEnd(nameWidth + sizeWidth + 20)
|
|
147
|
+
)
|
|
148
|
+
await writelnStdout(process, terminal,
|
|
149
|
+
` ${'-'.repeat(sizeWidth)} ${'-'.repeat(10)} ${'-'.repeat(5)} ${'-'.repeat(nameWidth)}`
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
let totalLength = 0
|
|
153
|
+
for (const entry of entries) {
|
|
154
|
+
const length = entry.uncompressedSize || 0
|
|
155
|
+
totalLength += length
|
|
156
|
+
|
|
157
|
+
let date = '--'
|
|
158
|
+
let time = '--'
|
|
159
|
+
|
|
160
|
+
if (entry.lastModDate) {
|
|
161
|
+
const d = new Date(entry.lastModDate)
|
|
162
|
+
const month = String(d.getMonth() + 1).padStart(2, '0')
|
|
163
|
+
const day = String(d.getDate()).padStart(2, '0')
|
|
164
|
+
const year = String(d.getFullYear()).slice(-2)
|
|
165
|
+
date = `${month}-${day}-${year}`
|
|
166
|
+
|
|
167
|
+
const hours = String(d.getHours()).padStart(2, '0')
|
|
168
|
+
const minutes = String(d.getMinutes()).padStart(2, '0')
|
|
169
|
+
time = `${hours}:${minutes}`
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const name = entry.directory ? entry.filename + '/' : entry.filename
|
|
173
|
+
const lengthStr = entry.directory ? '' : String(length).padStart(sizeWidth)
|
|
174
|
+
|
|
175
|
+
await writelnStdout(process, terminal,
|
|
176
|
+
` ${lengthStr.padEnd(sizeWidth)} ${date.padEnd(10)} ${time.padEnd(5)} ${name}`
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
await writelnStdout(process, terminal,
|
|
181
|
+
` ${'-'.repeat(sizeWidth)} ${'-'.repeat(10)} ${'-'.repeat(5)} ${'-'.repeat(nameWidth)}`
|
|
182
|
+
)
|
|
183
|
+
await writelnStdout(process, terminal,
|
|
184
|
+
` ${String(totalLength).padStart(sizeWidth)} ${entries.length} file${entries.length !== 1 ? 's' : ''}`
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
await zipReader.close()
|
|
188
|
+
return 0
|
|
189
|
+
} catch (error) {
|
|
190
|
+
await writelnStderr(process, terminal,
|
|
191
|
+
chalk.red(`zip error: ${error instanceof Error ? error.message : 'Unknown error'}`)
|
|
192
|
+
)
|
|
193
|
+
return 1
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function createCommand(kernel: Kernel, shell: Shell, terminal: Terminal): TerminalCommand {
|
|
198
|
+
return new TerminalCommand({
|
|
199
|
+
command: 'zip',
|
|
200
|
+
description: 'Create zip archives',
|
|
201
|
+
kernel,
|
|
202
|
+
shell,
|
|
203
|
+
terminal,
|
|
204
|
+
run: async (pid: number, argv: string[]) => {
|
|
205
|
+
const process = kernel.processes.get(pid) as Process | undefined
|
|
206
|
+
|
|
207
|
+
if (argv.length > 0 && (argv[0] === '--help' || argv[0] === '-h')) {
|
|
208
|
+
printUsage(process, terminal)
|
|
209
|
+
return 0
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const { options, zipfile, files } = parseArgs(argv)
|
|
213
|
+
|
|
214
|
+
// List mode
|
|
215
|
+
if (options.list) {
|
|
216
|
+
if (!zipfile) {
|
|
217
|
+
await writelnStderr(process, terminal, chalk.red('zip error: zipfile name required'))
|
|
218
|
+
await writelnStderr(process, terminal, "Try 'zip --help' for more information.")
|
|
219
|
+
return 1
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const zipfilePath = path.resolve(shell.cwd, zipfile)
|
|
223
|
+
const exists = await shell.context.fs.promises.exists(zipfilePath)
|
|
224
|
+
if (!exists) {
|
|
225
|
+
await writelnStderr(process, terminal, chalk.red(`zip error: ${zipfile}: No such file or directory`))
|
|
226
|
+
return 1
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return await listZipContents(zipfilePath, shell, terminal, process)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Create mode
|
|
233
|
+
if (!zipfile) {
|
|
234
|
+
await writelnStderr(process, terminal, chalk.red('zip error: zipfile name required'))
|
|
235
|
+
await writelnStderr(process, terminal, "Try 'zip --help' for more information.")
|
|
236
|
+
return 1
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (files.length === 0) {
|
|
240
|
+
await writelnStderr(process, terminal, chalk.red('zip error: nothing to do'))
|
|
241
|
+
await writelnStderr(process, terminal, "Try 'zip --help' for more information.")
|
|
242
|
+
return 1
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const outputPath = path.resolve(shell.cwd, zipfile)
|
|
246
|
+
let zipWriter: zipjs.ZipWriter<Blob> | null = null
|
|
247
|
+
let hasError = false
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
zipWriter = new zipjs.ZipWriter(new zipjs.BlobWriter())
|
|
251
|
+
|
|
252
|
+
for (const inputPath of files) {
|
|
253
|
+
const fullPath = path.resolve(shell.cwd, inputPath)
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
const exists = await shell.context.fs.promises.exists(fullPath)
|
|
257
|
+
if (!exists) {
|
|
258
|
+
await writelnStderr(process, terminal, chalk.red(`zip warning: ${inputPath}: No such file or directory`))
|
|
259
|
+
hasError = true
|
|
260
|
+
continue
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const fileStat = await shell.context.fs.promises.stat(fullPath)
|
|
264
|
+
|
|
265
|
+
if (fileStat.isFile()) {
|
|
266
|
+
// Add single file
|
|
267
|
+
const relativePath = path.relative(shell.cwd, fullPath)
|
|
268
|
+
const fileData = await shell.context.fs.promises.readFile(fullPath)
|
|
269
|
+
const reader = new zipjs.Uint8ArrayReader(fileData)
|
|
270
|
+
await zipWriter.add(relativePath, reader)
|
|
271
|
+
if (options.verbose) {
|
|
272
|
+
await writelnStdout(process, terminal, ` adding: ${relativePath}`)
|
|
273
|
+
}
|
|
274
|
+
} else if (fileStat.isDirectory()) {
|
|
275
|
+
if (options.recurse) {
|
|
276
|
+
// Add directory and contents recursively
|
|
277
|
+
await addDirectory(zipWriter, fullPath, shell.cwd, shell, terminal, process, options.verbose)
|
|
278
|
+
if (options.verbose) {
|
|
279
|
+
await writelnStdout(process, terminal, ` adding: ${path.relative(shell.cwd, fullPath)}/`)
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
await writelnStderr(process, terminal, chalk.yellow(`zip warning: ${inputPath}: is a directory (not added). Use -r to recurse into directories`))
|
|
283
|
+
hasError = true
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
await writelnStderr(process, terminal, chalk.red(`zip error: ${inputPath}: Not a file or directory`))
|
|
287
|
+
hasError = true
|
|
288
|
+
}
|
|
289
|
+
} catch (err: unknown) {
|
|
290
|
+
await writelnStderr(process, terminal,
|
|
291
|
+
chalk.red(`zip error: ${inputPath}: ${err instanceof Error ? err.message : 'Unknown error'}`)
|
|
292
|
+
)
|
|
293
|
+
hasError = true
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Write the zip file
|
|
298
|
+
const blob = await zipWriter.close()
|
|
299
|
+
zipWriter = null // Clear reference after closing
|
|
300
|
+
await shell.context.fs.promises.writeFile(outputPath, new Uint8Array(await blob.arrayBuffer()))
|
|
301
|
+
|
|
302
|
+
if (options.verbose) {
|
|
303
|
+
await writelnStdout(process, terminal, ` zipfile: ${zipfile}`)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return hasError ? 1 : 0
|
|
307
|
+
} catch (err: unknown) {
|
|
308
|
+
await writelnStderr(process, terminal,
|
|
309
|
+
chalk.red(`zip error: ${err instanceof Error ? err.message : 'Unknown error'}`)
|
|
310
|
+
)
|
|
311
|
+
return 1
|
|
312
|
+
} finally {
|
|
313
|
+
if (zipWriter) {
|
|
314
|
+
await zipWriter.close()
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -11,14 +11,20 @@ import { createCommand as createCat } from './commands/cat.js'
|
|
|
11
11
|
import { createCommand as createCd } from './commands/cd.js'
|
|
12
12
|
import { createCommand as createChmod } from './commands/chmod.js'
|
|
13
13
|
import { createCommand as createCp } from './commands/cp.js'
|
|
14
|
+
import { createCommand as createCron } from './commands/cron.js'
|
|
14
15
|
import { createCommand as createEcho } from './commands/echo.js'
|
|
16
|
+
import { createCommand as createFetch } from './commands/fetch.js'
|
|
15
17
|
import { createCommand as createGrep } from './commands/grep.js'
|
|
18
|
+
import { createCommand as createHash } from './commands/hash.js'
|
|
16
19
|
import { createCommand as createHead } from './commands/head.js'
|
|
17
20
|
import { createCommand as createLn } from './commands/ln.js'
|
|
18
21
|
import { createCommand as createLs } from './commands/ls.js'
|
|
19
22
|
import { createCommand as createMkdir } from './commands/mkdir.js'
|
|
23
|
+
import { createCommand as createMktemp } from './commands/mktemp.js'
|
|
20
24
|
import { createCommand as createMv } from './commands/mv.js'
|
|
21
25
|
import { createCommand as createNc } from './commands/nc.js'
|
|
26
|
+
import { createCommand as createOpen } from './commands/open.js'
|
|
27
|
+
import { createCommand as createPlay } from './commands/play.js'
|
|
22
28
|
import { createCommand as createPwd } from './commands/pwd.js'
|
|
23
29
|
import { createCommand as createSockets } from './commands/sockets.js'
|
|
24
30
|
import { createCommand as createRm } from './commands/rm.js'
|
|
@@ -27,10 +33,12 @@ import { createCommand as createStat } from './commands/stat.js'
|
|
|
27
33
|
import { createCommand as createTouch } from './commands/touch.js'
|
|
28
34
|
import { createCommand as createHex } from './commands/hex.js'
|
|
29
35
|
import { createCommand as createLess } from './commands/less.js'
|
|
36
|
+
import { createCommand as createMan } from './commands/man.js'
|
|
30
37
|
import { createCommand as createPasskey } from './commands/passkey.js'
|
|
31
38
|
import { createCommand as createSed } from './commands/sed.js'
|
|
32
39
|
import { createCommand as createTee } from './commands/tee.js'
|
|
33
40
|
import { createCommand as createTail } from './commands/tail.js'
|
|
41
|
+
import { createCommand as createTar } from './commands/tar.js'
|
|
34
42
|
import { createCommand as createBasename } from './commands/basename.js'
|
|
35
43
|
import { createCommand as createCal } from './commands/cal.js'
|
|
36
44
|
import { createCommand as createComm } from './commands/comm.js'
|
|
@@ -40,6 +48,7 @@ import { createCommand as createDiff } from './commands/diff.js'
|
|
|
40
48
|
import { createCommand as createDirname } from './commands/dirname.js'
|
|
41
49
|
import { createCommand as createFalse } from './commands/false.js'
|
|
42
50
|
import { createCommand as createFind } from './commands/find.js'
|
|
51
|
+
import { createCommand as createFormat } from './commands/format.js'
|
|
43
52
|
import { createCommand as createId } from './commands/id.js'
|
|
44
53
|
import { createCommand as createJoin } from './commands/join.js'
|
|
45
54
|
import { createCommand as createNl } from './commands/nl.js'
|
|
@@ -53,20 +62,31 @@ import { createCommand as createTrue } from './commands/true.js'
|
|
|
53
62
|
import { createCommand as createUniq } from './commands/uniq.js'
|
|
54
63
|
import { createCommand as createUser } from './commands/user.js'
|
|
55
64
|
import { createCommand as createWc } from './commands/wc.js'
|
|
65
|
+
import { createCommand as createWeb } from './commands/web.js'
|
|
56
66
|
import { createCommand as createWhich } from './commands/which.js'
|
|
57
67
|
import { createCommand as createWhoami } from './commands/whoami.js'
|
|
68
|
+
import { createCommand as createZip } from './commands/zip.js'
|
|
69
|
+
import { createCommand as createUnzip } from './commands/unzip.js'
|
|
70
|
+
import { createCommand as createVideo } from './commands/video.js'
|
|
71
|
+
import { createCommand as createView } from './commands/view.js'
|
|
58
72
|
|
|
59
73
|
// Export individual command factories
|
|
60
74
|
export { createCommand as createCat } from './commands/cat.js'
|
|
61
75
|
export { createCommand as createCd } from './commands/cd.js'
|
|
62
76
|
export { createCommand as createChmod } from './commands/chmod.js'
|
|
63
77
|
export { createCommand as createCp } from './commands/cp.js'
|
|
78
|
+
export { createCommand as createCron } from './commands/cron.js'
|
|
64
79
|
export { createCommand as createEcho } from './commands/echo.js'
|
|
80
|
+
export { createCommand as createFetch } from './commands/fetch.js'
|
|
65
81
|
export { createCommand as createGrep } from './commands/grep.js'
|
|
82
|
+
export { createCommand as createHash } from './commands/hash.js'
|
|
66
83
|
export { createCommand as createLn } from './commands/ln.js'
|
|
67
84
|
export { createCommand as createLs } from './commands/ls.js'
|
|
68
85
|
export { createCommand as createMkdir } from './commands/mkdir.js'
|
|
86
|
+
export { createCommand as createMktemp } from './commands/mktemp.js'
|
|
69
87
|
export { createCommand as createMv } from './commands/mv.js'
|
|
88
|
+
export { createCommand as createOpen } from './commands/open.js'
|
|
89
|
+
export { createCommand as createPlay } from './commands/play.js'
|
|
70
90
|
export { createCommand as createPwd } from './commands/pwd.js'
|
|
71
91
|
export { createCommand as createRm } from './commands/rm.js'
|
|
72
92
|
export { createCommand as createRmdir } from './commands/rmdir.js'
|
|
@@ -74,23 +94,31 @@ export { createCommand as createStat } from './commands/stat.js'
|
|
|
74
94
|
export { createCommand as createTouch } from './commands/touch.js'
|
|
75
95
|
export { createCommand as createHex } from './commands/hex.js'
|
|
76
96
|
export { createCommand as createLess } from './commands/less.js'
|
|
97
|
+
export { createCommand as createMan } from './commands/man.js'
|
|
77
98
|
export { createCommand as createSed } from './commands/sed.js'
|
|
78
99
|
export { createCommand as createTee } from './commands/tee.js'
|
|
79
100
|
export { createCommand as createTail } from './commands/tail.js'
|
|
101
|
+
export { createCommand as createTar } from './commands/tar.js'
|
|
80
102
|
export { createCommand as createBasename } from './commands/basename.js'
|
|
81
103
|
export { createCommand as createCut } from './commands/cut.js'
|
|
82
104
|
export { createCommand as createDate } from './commands/date.js'
|
|
83
105
|
export { createCommand as createDiff } from './commands/diff.js'
|
|
84
106
|
export { createCommand as createDirname } from './commands/dirname.js'
|
|
85
107
|
export { createCommand as createFind } from './commands/find.js'
|
|
108
|
+
export { createCommand as createFormat } from './commands/format.js'
|
|
86
109
|
export { createCommand as createSort } from './commands/sort.js'
|
|
87
110
|
export { createCommand as createTest } from './commands/test.js'
|
|
88
111
|
export { createCommand as createTr } from './commands/tr.js'
|
|
89
112
|
export { createCommand as createUniq } from './commands/uniq.js'
|
|
90
113
|
export { createCommand as createUser } from './commands/user.js'
|
|
91
114
|
export { createCommand as createWc } from './commands/wc.js'
|
|
115
|
+
export { createCommand as createWeb } from './commands/web.js'
|
|
92
116
|
export { createCommand as createWhich } from './commands/which.js'
|
|
93
117
|
export { createCommand as createSockets } from './commands/sockets.js'
|
|
118
|
+
export { createCommand as createZip } from './commands/zip.js'
|
|
119
|
+
export { createCommand as createUnzip } from './commands/unzip.js'
|
|
120
|
+
export { createCommand as createVideo } from './commands/video.js'
|
|
121
|
+
export { createCommand as createView } from './commands/view.js'
|
|
94
122
|
|
|
95
123
|
/**
|
|
96
124
|
* Creates all coreutils commands.
|
|
@@ -102,15 +130,21 @@ export function createAllCommands(kernel: Kernel, shell: Shell, terminal: Termin
|
|
|
102
130
|
cd: createCd(kernel, shell, terminal),
|
|
103
131
|
chmod: createChmod(kernel, shell, terminal),
|
|
104
132
|
cp: createCp(kernel, shell, terminal),
|
|
133
|
+
cron: createCron(kernel, shell, terminal),
|
|
105
134
|
echo: createEcho(kernel, shell, terminal),
|
|
135
|
+
fetch: createFetch(kernel, shell, terminal),
|
|
106
136
|
grep: createGrep(kernel, shell, terminal),
|
|
137
|
+
hash: createHash(kernel, shell, terminal),
|
|
107
138
|
head: createHead(kernel, shell, terminal),
|
|
108
139
|
ln: createLn(kernel, shell, terminal),
|
|
109
140
|
ls: createLs(kernel, shell, terminal),
|
|
110
141
|
mkdir: createMkdir(kernel, shell, terminal),
|
|
142
|
+
mktemp: createMktemp(kernel, shell, terminal),
|
|
111
143
|
mv: createMv(kernel, shell, terminal),
|
|
112
|
-
pwd: createPwd(kernel, shell, terminal),
|
|
113
144
|
nc: createNc(kernel, shell, terminal),
|
|
145
|
+
open: createOpen(kernel, shell, terminal),
|
|
146
|
+
play: createPlay(kernel, shell, terminal),
|
|
147
|
+
pwd: createPwd(kernel, shell, terminal),
|
|
114
148
|
sockets: createSockets(kernel, shell, terminal),
|
|
115
149
|
rm: createRm(kernel, shell, terminal),
|
|
116
150
|
rmdir: createRmdir(kernel, shell, terminal),
|
|
@@ -118,6 +152,7 @@ export function createAllCommands(kernel: Kernel, shell: Shell, terminal: Termin
|
|
|
118
152
|
touch: createTouch(kernel, shell, terminal),
|
|
119
153
|
hex: createHex(kernel, shell, terminal),
|
|
120
154
|
less: createLess(kernel, shell, terminal),
|
|
155
|
+
man: createMan(kernel, shell, terminal),
|
|
121
156
|
passkey: createPasskey(kernel, shell, terminal),
|
|
122
157
|
sed: createSed(kernel, shell, terminal),
|
|
123
158
|
tail: createTail(kernel, shell, terminal),
|
|
@@ -131,6 +166,7 @@ export function createAllCommands(kernel: Kernel, shell: Shell, terminal: Termin
|
|
|
131
166
|
dirname: createDirname(kernel, shell, terminal),
|
|
132
167
|
false: createFalse(kernel, shell, terminal),
|
|
133
168
|
find: createFind(kernel, shell, terminal),
|
|
169
|
+
format: createFormat(kernel, shell, terminal),
|
|
134
170
|
id: createId(kernel, shell, terminal),
|
|
135
171
|
join: createJoin(kernel, shell, terminal),
|
|
136
172
|
nl: createNl(kernel, shell, terminal),
|
|
@@ -138,14 +174,20 @@ export function createAllCommands(kernel: Kernel, shell: Shell, terminal: Termin
|
|
|
138
174
|
seq: createSeq(kernel, shell, terminal),
|
|
139
175
|
sort: createSort(kernel, shell, terminal),
|
|
140
176
|
split: createSplit(kernel, shell, terminal),
|
|
177
|
+
tar: createTar(kernel, shell, terminal),
|
|
141
178
|
test: createTest(kernel, shell, terminal),
|
|
142
179
|
tr: createTr(kernel, shell, terminal),
|
|
143
180
|
true: createTrue(kernel, shell, terminal),
|
|
144
181
|
uniq: createUniq(kernel, shell, terminal),
|
|
145
182
|
user: createUser(kernel, shell, terminal),
|
|
146
183
|
wc: createWc(kernel, shell, terminal),
|
|
184
|
+
web: createWeb(kernel, shell, terminal),
|
|
147
185
|
which: createWhich(kernel, shell, terminal),
|
|
148
|
-
whoami: createWhoami(kernel, shell, terminal)
|
|
186
|
+
whoami: createWhoami(kernel, shell, terminal),
|
|
187
|
+
zip: createZip(kernel, shell, terminal),
|
|
188
|
+
unzip: createUnzip(kernel, shell, terminal),
|
|
189
|
+
video: createVideo(kernel, shell, terminal),
|
|
190
|
+
view: createView(kernel, shell, terminal)
|
|
149
191
|
}
|
|
150
192
|
}
|
|
151
193
|
|