hackmud-script-manager 0.19.1-bf4dc4a → 0.19.1-cb8d65f

Sign up to get free protection for your applications and to get access to all the features.
package/bin/hsm.js CHANGED
@@ -25,118 +25,7 @@ const configDirectoryPath = resolve(homedir(), ".config"),
25
25
  for (const char of user) hash += (hash >> 1) + hash + "xi1_8ratvsw9hlbgm02y5zpdcn7uekof463qj".indexOf(char) + 1
26
26
  return [colourJ, colourK, colourM, colourW, colourL, colourB][hash % 6](user)
27
27
  }),
28
- logNeedHackmudPathMessage = () =>
29
- console.error(
30
- colourS(
31
- `${colourD("You need to set hackmudPath in config before you can use this command")}\n\n${colourA("To fix this:")}\nOpen hackmud and run "${colourC("#dir")}"\nThis will open a file browser and print your hackmud user's script directory\nGo up 2 directories and then copy the path\nThen in a terminal run "${colourC("hsm")} ${colourL("config set")} ${colourV("hackmudPath")} ${colourB("<the path you copied>")}"`
32
- )
33
- ),
34
- logHelp = () => {
35
- const pushCommandDescription = "Push scripts from a directory to hackmud user's scripts directories",
36
- forceQuineCheatsOptionDescription = `Force quine cheats on. Use ${colourN("--force-quine-cheats")}=${colourV("false")} to force off`
37
- console.log(colourN("Version") + colourS(": ") + colourV("0.19.1-bf4dc4a"))
38
- switch (commands[0]) {
39
- case "config":
40
- switch (commands[1]) {
41
- case "get":
42
- console.log(
43
- `\n${colourJ("Retrieve a value from the config file")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(`${commands[0]} ${commands[1]}`)} ${colourB("<key>")}`
44
- )
45
- break
46
- case "set":
47
- console.log(
48
- `\n${colourJ("Assign a value to the config file")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(`${commands[0]} ${commands[1]}`)} ${colourB("<key> <value>")}`
49
- )
50
- break
51
- case "delete":
52
- console.log(
53
- `\n${colourJ("Remove a key and value from the config file")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(`${commands[0]} ${commands[1]}`)} ${colourB("<key>")}`
54
- )
55
- break
56
- default:
57
- console.log(
58
- colourS(
59
- `${colourN("Config path")}: ${colourV(configFilePath)}\n\n${colourJ("Modify the config file")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0] + " get")} ${colourB("<key>")}\n Retrieve a value from the config file\n${colourC("hsm")} ${colourL(commands[0] + " set")} ${colourB("<key> <value>")}\n Assign a value to the config file\n${colourC("hsm")} ${colourL(commands[0] + " delete")} ${colourB("<key>")}\n Remove a key and value from the config file`
60
- )
61
- )
62
- }
63
- break
64
- case "dev":
65
- case "watch":
66
- case "push":
67
- console.log(
68
- colourS(
69
- `\n${colourJ("push" == commands[0] ? pushCommandDescription : "Watch a directory and push a script when modified")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB('<directory> ["<script user>.<script name>"...]')}\n\n${colourA("Arguments:")}\n${colourB("<directory>")}\n The source directory containing your scripts\n${colourB("<script user>")}\n A user to push script(s) to. Can be set to wild card (${colourV("*")}) which will try\n and discover users to push to\n${colourB("<script name>")}\n Name of a script to push. Can be set to wild card (${colourV("*")}) to find all scripts\n\n${colourA("Options:")}\n${colourN("--no-minify")}\n Skip minification to produce a "readable" script\n${colourN("--mangle-names")}\n Reduce character count further but lose function names in error call stacks\n${colourN("--force-quine-cheats")}\n ${forceQuineCheatsOptionDescription}\n${"push" == commands[0] ? "" : `${colourN("--type-declaration-path")}=${colourB("<path>")}\n Path to generate a type declaration file for the scripts\n`}\n${colourA("Examples:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")}\n\tPushes all scripts found in ${colourV("src")} folder to all users\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("bar")}\n Pushes a script named ${colourL("bar")} found in ${colourV("src")} folder to user ${userColours.get("foo")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("bar")} ${colourC("baz")}${colourV(".")}${colourL("qux")}\n Multiple can be specified.\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("*")}\n\tPushes all scripts found in ${colourV("src")} folder to user ${userColours.get("foo")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("*")}${colourV(".")}${colourL("foo")}\n\tPushes all scripts named ${colourL("foo")} found in ${colourV("src")} folder to all user\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("*")}${colourV(".")}${colourL("*")}\n\tPushes all scripts found in ${colourV("src")} folder to all users`
70
- )
71
- )
72
- break
73
- case "pull":
74
- console.log(
75
- colourS(
76
- `\n${colourJ("Pull a script a from a hackmud user's script directory")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<script user>")}${colourV(".")}${colourB("<script name>")}`
77
- )
78
- )
79
- break
80
- case "minify":
81
- case "golf":
82
- console.log(
83
- colourS(
84
- `\n${colourJ("Minify a script file on the spot")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<target> [output path]")}\n\n${colourA("Options:")}\n${colourN("--no-minify")}\n Skip minification to produce a "readable" script\n${colourN("--mangle-names")}\n Reduce character count further but lose function names in error call stacks\n${colourN("--force-quine-cheats")}\n ${forceQuineCheatsOptionDescription}\n${colourN("--watch")}\n Watch for changes`
85
- )
86
- )
87
- break
88
- case "generate-type-declaration":
89
- case "gen-type-declaration":
90
- case "gen-dts":
91
- case "gen-types":
92
- console.log(
93
- colourS(
94
- `${colourJ("Generate a type declaration file for a directory of scripts")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<directory> [output path]")}`
95
- )
96
- )
97
- break
98
- case "sync-macros":
99
- console.log("\n" + colourJ("Sync macros across all hackmud users"))
100
- break
101
- default:
102
- console.log(
103
- colourS(
104
- `\n${colourJ("Hackmud Script Manager")}\n\n${colourA("Commands:")}\n${colourL("push")}\n ${pushCommandDescription}\n${colourL("dev")}\n Watch a directory and push a script when modified\n${colourL("golf")}\n Minify a script file on the spot\n${colourL("gen-dts")}\n Generate a type declaration file for a directory of scripts\n${colourL("sync-macros")}\n Sync macros across all hackmud users\n${colourL("config")}\n Modify and view the config file\n${colourL("pull")}\n Pull a script a from a hackmud user's script directory`
105
- )
106
- )
107
- }
108
- },
109
- updateConfig = async config => {
110
- const json = JSON.stringify(config, void 0, "\t")
111
- configDidNotExist && log("Creating config file at " + configFilePath)
112
- await writeFile(configFilePath, json).catch(async error => {
113
- switch (error.code) {
114
- case "EISDIR":
115
- await rmdir(configFilePath)
116
- break
117
- case "ENOENT":
118
- await mkdir(configDirectoryPath)
119
- break
120
- default:
121
- throw error
122
- }
123
- await writeFile(configFilePath, json)
124
- })
125
- },
126
- logInfo = ({ file, users, minLength, error }, hackmudPath) => {
127
- error ?
128
- logError(`error "${chalk.bold(error.message)}" in ${chalk.bold(file)}`)
129
- : console.log(
130
- `pushed ${chalk.bold(file)} to ${users.map(user => chalk.bold(userColours.get(user))).join(", ")} | ${chalk.bold(minLength + "")} chars | ${chalk.bold(resolve(hackmudPath, users[0], "scripts", basename(file, extname(file))) + ".js")}`
131
- )
132
- },
133
- log = message => {
134
- console.log(colourS(message))
135
- },
136
- logError = message => {
137
- console.error(colourD(message))
138
- process.exitCode = 1
139
- }
28
+ log = message => console.log(colourS(message))
140
29
  for (const argument of process.argv.slice(2))
141
30
  if ("-" == argument[0]) {
142
31
  const [key, valueRaw] = argument.split("=")
@@ -153,20 +42,14 @@ for (const argument of process.argv.slice(2))
153
42
  else for (const option of key.slice(1)) options.set(option, value)
154
43
  } else commands.push(argument)
155
44
  if ("v" == commands[0] || "version" == commands[0] || options.get("version") || options.get("v")) {
156
- console.log("0.19.1-bf4dc4a")
45
+ console.log("0.19.1-cb8d65f")
157
46
  process.exit()
158
47
  }
159
48
  let configDidNotExist = !1
160
49
  const configPromise = readFile(configFilePath, { encoding: "utf-8" }).then(
161
50
  configFile => {
162
- let temporaryConfig
163
- try {
164
- temporaryConfig = JSON.parse(configFile)
165
- } catch {
166
- log("Config file was corrupted, resetting")
167
- return {}
168
- }
169
- if (!temporaryConfig || "object" != typeof temporaryConfig) {
51
+ const [temporaryConfig, error] = catchError(() => JSON.parse(configFile))
52
+ if (error || !isRecord(temporaryConfig)) {
170
53
  log("Config file was corrupted, resetting")
171
54
  return {}
172
55
  }
@@ -203,15 +86,13 @@ if (options.get("help") || options.get("h")) {
203
86
  process.exit()
204
87
  }
205
88
  let autoExit = !0
89
+ const getDefaultHackmudPath = () =>
90
+ "win32" == process.platform ? resolve(process.env.APPDATA, "hackmud") : resolve(homedir(), ".config/hackmud")
206
91
  switch (commands[0]) {
207
92
  case "push":
208
93
  {
209
- const { hackmudPath } = await configPromise
210
- if (!hackmudPath) {
211
- logNeedHackmudPathMessage()
212
- break
213
- }
214
- const sourcePath = commands[1]
94
+ const { hackmudPath = getDefaultHackmudPath() } = await configPromise,
95
+ sourcePath = commands[1]
215
96
  if (!sourcePath) {
216
97
  logError("Must provide the directory to push from\n")
217
98
  logHelp()
@@ -279,12 +160,8 @@ switch (commands[0]) {
279
160
  case "dev":
280
161
  case "watch":
281
162
  {
282
- const { hackmudPath } = await configPromise
283
- if (!hackmudPath) {
284
- logNeedHackmudPathMessage()
285
- break
286
- }
287
- const sourcePath = commands[1]
163
+ const { hackmudPath = getDefaultHackmudPath() } = await configPromise,
164
+ sourcePath = commands[1]
288
165
  if (!sourcePath) {
289
166
  logError("Must provide the directory to watch\n")
290
167
  logHelp()
@@ -357,34 +234,24 @@ switch (commands[0]) {
357
234
  break
358
235
  case "pull":
359
236
  {
360
- const { hackmudPath } = await configPromise
361
- if (!hackmudPath) {
362
- logNeedHackmudPathMessage()
363
- break
364
- }
365
- const script = commands[1]
237
+ const { hackmudPath = getDefaultHackmudPath() } = await configPromise,
238
+ script = commands[1]
366
239
  if (!script) {
367
240
  logError("Must provide the script to pull\n")
368
241
  logHelp()
369
242
  break
370
243
  }
371
244
  const sourcePath = commands[2] || "."
372
- try {
373
- await pull(sourcePath, hackmudPath, script)
374
- } catch (error) {
245
+ await pull(sourcePath, hackmudPath, script).catch(error => {
375
246
  console.error(error)
376
247
  logError(`Something went wrong, did you forget to ${colourC("#down")} the script?`)
377
- }
248
+ })
378
249
  }
379
250
  break
380
251
  case "sync-macros":
381
252
  {
382
- const { hackmudPath } = await configPromise
383
- if (!hackmudPath) {
384
- logNeedHackmudPathMessage()
385
- break
386
- }
387
- const { macrosSynced, usersSynced } = await syncMacros(hackmudPath)
253
+ const { hackmudPath = getDefaultHackmudPath() } = await configPromise,
254
+ { macrosSynced, usersSynced } = await syncMacros(hackmudPath)
388
255
  log(`Synced ${macrosSynced} macros to ${usersSynced} users`)
389
256
  }
390
257
  break
@@ -401,16 +268,17 @@ switch (commands[0]) {
401
268
  }
402
269
  const sourcePath = resolve(target),
403
270
  outputPath = commands[2] || "./player.d.ts",
404
- typeDeclaration = await generateTypeDeclaration(sourcePath, (await configPromise).hackmudPath)
271
+ typeDeclaration = await generateTypeDeclaration(
272
+ sourcePath,
273
+ (await configPromise).hackmudPath || getDefaultHackmudPath()
274
+ )
405
275
  let typeDeclarationPath = resolve(outputPath)
406
- try {
407
- await writeFile(typeDeclarationPath, typeDeclaration)
408
- } catch (error) {
409
- assert(error instanceof Error)
276
+ await writeFile(typeDeclarationPath, typeDeclaration).catch(error => {
277
+ assert(error instanceof Error, "src/bin/hsm.ts:365:35")
410
278
  if ("EISDIR" != error.code) throw error
411
279
  typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
412
- await writeFile(typeDeclarationPath, typeDeclaration)
413
- }
280
+ return writeFile(typeDeclarationPath, typeDeclaration)
281
+ })
414
282
  log("Wrote type declaration to " + chalk.bold(typeDeclarationPath))
415
283
  }
416
284
  break
@@ -537,36 +405,31 @@ switch (commands[0]) {
537
405
  : fileBaseName + ".js"
538
406
  )
539
407
  const golfFile = () =>
540
- readFile(target, { encoding: "utf-8" }).then(
541
- async source => {
542
- const timeStart = performance.now(),
543
- { script, warnings } = await processScript(source, {
544
- minify: !(options.get("no-minify") || options.get("skip-minify")),
545
- scriptUser,
546
- scriptName,
547
- filePath: target,
548
- mangleNames,
549
- forceQuineCheats
550
- }),
551
- timeTook = performance.now() - timeStart
552
- for (const { message, line } of warnings)
553
- log(`Warning "${chalk.bold(message)}" on line ${chalk.bold(line + "")}`)
554
- await writeFilePersistent(outputPath, script)
555
- .catch(async error => {
556
- if (!commands[2] || "EISDIR" != error.code) throw error
557
- outputPath = resolve(outputPath, basename(target, fileExtension) + ".js")
558
- await writeFilePersistent(outputPath, script)
559
- })
560
- .then(
561
- () =>
562
- log(
563
- `Wrote ${chalk.bold(countHackmudCharacters(script))} chars to ${chalk.bold(relative(".", outputPath))} | took ${Math.round(100 * timeTook) / 100}ms`
564
- ),
565
- error => logError(error.message)
408
+ readFile(target, { encoding: "utf-8" }).then(async source => {
409
+ const timeStart = performance.now(),
410
+ { script, warnings } = await processScript(source, {
411
+ minify: !(options.get("no-minify") || options.get("skip-minify")),
412
+ scriptUser,
413
+ scriptName,
414
+ filePath: target,
415
+ mangleNames,
416
+ forceQuineCheats
417
+ }),
418
+ timeTook = performance.now() - timeStart
419
+ for (const { message, line } of warnings)
420
+ log(`Warning "${chalk.bold(message)}" on line ${chalk.bold(line + "")}`)
421
+ await writeFilePersistent(outputPath, script)
422
+ .catch(error => {
423
+ if (!commands[2] || "EISDIR" != error.code) throw error
424
+ outputPath = resolve(outputPath, basename(target, fileExtension) + ".js")
425
+ return writeFilePersistent(outputPath, script)
426
+ })
427
+ .then(() =>
428
+ log(
429
+ `Wrote ${chalk.bold(countHackmudCharacters(script))} chars to ${chalk.bold(relative(".", outputPath))} | took ${Math.round(100 * timeTook) / 100}ms`
566
430
  )
567
- },
568
- error => logError(error.message)
569
- )
431
+ )
432
+ })
570
433
  if (options.get("watch")) {
571
434
  const { watch: watchFile } = await chokidarModule
572
435
  watchFile(target, { awaitWriteFinish: { stabilityThreshold: 100 } })
@@ -581,3 +444,106 @@ switch (commands[0]) {
581
444
  logHelp()
582
445
  }
583
446
  autoExit && process.exit()
447
+ function logHelp() {
448
+ const pushCommandDescription = "Push scripts from a directory to hackmud user's scripts directories",
449
+ forceQuineCheatsOptionDescription = `Force quine cheats on. Use ${colourN("--force-quine-cheats")}=${colourV("false")} to force off`
450
+ console.log(colourN("Version") + colourS(": ") + colourV("0.19.1-cb8d65f"))
451
+ switch (commands[0]) {
452
+ case "config":
453
+ switch (commands[1]) {
454
+ case "get":
455
+ console.log(
456
+ `\n${colourJ("Retrieve a value from the config file")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(`${commands[0]} ${commands[1]}`)} ${colourB("<key>")}`
457
+ )
458
+ break
459
+ case "set":
460
+ console.log(
461
+ `\n${colourJ("Assign a value to the config file")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(`${commands[0]} ${commands[1]}`)} ${colourB("<key> <value>")}`
462
+ )
463
+ break
464
+ case "delete":
465
+ console.log(
466
+ `\n${colourJ("Remove a key and value from the config file")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(`${commands[0]} ${commands[1]}`)} ${colourB("<key>")}`
467
+ )
468
+ break
469
+ default:
470
+ console.log(
471
+ colourS(
472
+ `${colourN("Config path")}: ${colourV(configFilePath)}\n\n${colourJ("Modify the config file")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0] + " get")} ${colourB("<key>")}\n Retrieve a value from the config file\n${colourC("hsm")} ${colourL(commands[0] + " set")} ${colourB("<key> <value>")}\n Assign a value to the config file\n${colourC("hsm")} ${colourL(commands[0] + " delete")} ${colourB("<key>")}\n Remove a key and value from the config file`
473
+ )
474
+ )
475
+ }
476
+ break
477
+ case "dev":
478
+ case "watch":
479
+ case "push":
480
+ console.log(
481
+ colourS(
482
+ `\n${colourJ("push" == commands[0] ? pushCommandDescription : "Watch a directory and push a script when modified")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB('<directory> ["<script user>.<script name>"...]')}\n\n${colourA("Arguments:")}\n${colourB("<directory>")}\n The source directory containing your scripts\n${colourB("<script user>")}\n A user to push script(s) to. Can be set to wild card (${colourV("*")}) which will try\n and discover users to push to\n${colourB("<script name>")}\n Name of a script to push. Can be set to wild card (${colourV("*")}) to find all scripts\n\n${colourA("Options:")}\n${colourN("--no-minify")}\n Skip minification to produce a "readable" script\n${colourN("--mangle-names")}\n Reduce character count further but lose function names in error call stacks\n${colourN("--force-quine-cheats")}\n ${forceQuineCheatsOptionDescription}\n${"push" == commands[0] ? "" : `${colourN("--type-declaration-path")}=${colourB("<path>")}\n Path to generate a type declaration file for the scripts\n`}\n${colourA("Examples:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")}\n\tPushes all scripts found in ${colourV("src")} folder to all users\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("bar")}\n Pushes a script named ${colourL("bar")} found in ${colourV("src")} folder to user ${userColours.get("foo")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("bar")} ${colourC("baz")}${colourV(".")}${colourL("qux")}\n Multiple can be specified.\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("*")}\n\tPushes all scripts found in ${colourV("src")} folder to user ${userColours.get("foo")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("*")}${colourV(".")}${colourL("foo")}\n\tPushes all scripts named ${colourL("foo")} found in ${colourV("src")} folder to all user\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("*")}${colourV(".")}${colourL("*")}\n\tPushes all scripts found in ${colourV("src")} folder to all users`
483
+ )
484
+ )
485
+ break
486
+ case "pull":
487
+ console.log(
488
+ colourS(
489
+ `\n${colourJ("Pull a script a from a hackmud user's script directory")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<script user>")}${colourV(".")}${colourB("<script name>")}`
490
+ )
491
+ )
492
+ break
493
+ case "minify":
494
+ case "golf":
495
+ console.log(
496
+ colourS(
497
+ `\n${colourJ("Minify a script file on the spot")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<target> [output path]")}\n\n${colourA("Options:")}\n${colourN("--no-minify")}\n Skip minification to produce a "readable" script\n${colourN("--mangle-names")}\n Reduce character count further but lose function names in error call stacks\n${colourN("--force-quine-cheats")}\n ${forceQuineCheatsOptionDescription}\n${colourN("--watch")}\n Watch for changes`
498
+ )
499
+ )
500
+ break
501
+ case "generate-type-declaration":
502
+ case "gen-type-declaration":
503
+ case "gen-dts":
504
+ case "gen-types":
505
+ console.log(
506
+ colourS(
507
+ `${colourJ("Generate a type declaration file for a directory of scripts")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<directory> [output path]")}`
508
+ )
509
+ )
510
+ break
511
+ case "sync-macros":
512
+ console.log("\n" + colourJ("Sync macros across all hackmud users"))
513
+ break
514
+ default:
515
+ console.log(
516
+ colourS(
517
+ `\n${colourJ("Hackmud Script Manager")}\n\n${colourA("Commands:")}\n${colourL("push")}\n ${pushCommandDescription}\n${colourL("dev")}\n Watch a directory and push a script when modified\n${colourL("golf")}\n Minify a script file on the spot\n${colourL("gen-dts")}\n Generate a type declaration file for a directory of scripts\n${colourL("sync-macros")}\n Sync macros across all hackmud users\n${colourL("config")}\n Modify and view the config file\n${colourL("pull")}\n Pull a script a from a hackmud user's script directory`
518
+ )
519
+ )
520
+ }
521
+ }
522
+ async function updateConfig(config) {
523
+ const json = JSON.stringify(config, void 0, "\t")
524
+ configDidNotExist && log("Creating config file at " + configFilePath)
525
+ await writeFile(configFilePath, json).catch(async error => {
526
+ switch (error.code) {
527
+ case "EISDIR":
528
+ await rmdir(configFilePath)
529
+ break
530
+ case "ENOENT":
531
+ await mkdir(configDirectoryPath)
532
+ break
533
+ default:
534
+ throw error
535
+ }
536
+ await writeFile(configFilePath, json)
537
+ })
538
+ }
539
+ function logInfo({ file, users, minLength, error }, hackmudPath) {
540
+ error ?
541
+ logError(`error "${chalk.bold(error.message)}" in ${chalk.bold(file)}`)
542
+ : console.log(
543
+ `pushed ${chalk.bold(file)} to ${users.map(user => chalk.bold(userColours.get(user))).join(", ")} | ${chalk.bold(minLength + "")} chars | ${chalk.bold(resolve(hackmudPath, users[0], "scripts", basename(file, extname(file))) + ".js")}`
544
+ )
545
+ }
546
+ function logError(message) {
547
+ console.error(colourD(message))
548
+ process.exitCode = 1
549
+ }
@@ -1,6 +1,6 @@
1
1
  import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
2
2
  import { basename, resolve } from "path"
3
- const generateTypeDeclaration = async (sourceDirectory, hackmudPath) => {
3
+ async function generateTypeDeclaration(sourceDirectory, hackmudPath) {
4
4
  const users = new Set()
5
5
  if (hackmudPath)
6
6
  for (const { stats, name } of await readDirectoryWithStats(hackmudPath))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hackmud-script-manager",
3
- "version": "0.19.1-bf4dc4a",
3
+ "version": "0.19.1-cb8d65f",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",
@@ -69,17 +69,12 @@
69
69
  "rollup": "^4.14.2",
70
70
  "terser": "^5.30.3"
71
71
  },
72
- "engines": {
73
- "node": "^18 || >=20",
74
- "pnpm": "^9.0.1"
75
- },
76
72
  "type": "module",
77
73
  "exports": {
78
74
  "./*": "./*.js",
79
75
  "./*.js": "./*.js"
80
76
  },
81
- "bin": {
82
- "hsm.d": "bin/hsm.d.ts",
83
- "hsm": "bin/hsm.js"
77
+ "engines": {
78
+ "node": "^18 || >=20"
84
79
  }
85
80
  }