hackmud-script-manager 0.20.4-550e28d → 0.20.4-6a2a079

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/bin/hsm.js +36 -24
  2. package/package.json +1 -1
package/bin/hsm.js CHANGED
@@ -13,7 +13,8 @@ import { syncMacros } from "../syncMacros.js"
13
13
  import "@samual/lib/readDirectoryWithStats"
14
14
  import "path/posix"
15
15
  import "@samual/lib/copyFilePersistent"
16
- const version = "0.20.4-550e28d",
16
+ const version = "0.20.4-6a2a079",
17
+ formatOption = name => colourN(`-${1 == name.length ? "" : "-"}${name}`),
17
18
  options = new Map(),
18
19
  commands = [],
19
20
  userColours = new Cache(user => {
@@ -83,7 +84,7 @@ switch (commands[0]) {
83
84
  noMinifyIncompatibleOption = mangleNamesOption || forceQuineCheatsOption
84
85
  if (noMinifyOption && noMinifyIncompatibleOption) {
85
86
  logError(
86
- `Options ${colourN(noMinifyOption.name)} and ${colourN(noMinifyIncompatibleOption.name)} are incompatible\n`
87
+ `Options ${formatOption(noMinifyOption.name)} and ${formatOption(noMinifyIncompatibleOption.name)} are incompatible\n`
87
88
  )
88
89
  logHelp()
89
90
  process.exit(1)
@@ -106,6 +107,7 @@ switch (commands[0]) {
106
107
  )
107
108
  process.exit(1)
108
109
  }
110
+ complainAboutUnrecognisedOptions()
109
111
  const { processScript } = await processScriptModule,
110
112
  fileBaseName = basename(target, fileExtension),
111
113
  fileBaseNameEndsWithDotSrc = fileBaseName.endsWith(".src"),
@@ -178,15 +180,15 @@ switch (commands[0]) {
178
180
  }
179
181
  } else scripts.push("*.*")
180
182
  if ("push" == commands[0]) {
181
- const { push, MissingSourceFolderError, MissingHackmudFolderError, NoUsersError } =
182
- await pushModule,
183
- infos = await push(sourcePath, hackmudPath, {
184
- scripts,
185
- onPush: info => logInfo(info, hackmudPath),
186
- minify: noMinifyOption && !noMinifyOption.value,
187
- mangleNames: mangleNamesOption?.value,
188
- forceQuineCheats: forceQuineCheatsOption?.value
189
- })
183
+ const { push, MissingSourceFolderError, MissingHackmudFolderError, NoUsersError } = await pushModule
184
+ complainAboutUnrecognisedOptions()
185
+ const infos = await push(sourcePath, hackmudPath, {
186
+ scripts,
187
+ onPush: info => logInfo(info, hackmudPath),
188
+ minify: noMinifyOption && !noMinifyOption.value,
189
+ mangleNames: mangleNamesOption?.value,
190
+ forceQuineCheats: forceQuineCheatsOption?.value
191
+ })
190
192
  if (infos instanceof Error) {
191
193
  logError(infos.message)
192
194
  if (infos instanceof MissingSourceFolderError || infos instanceof NoUsersError) {
@@ -200,12 +202,13 @@ switch (commands[0]) {
200
202
  } else infos.length || logError("Could not find any scripts to push")
201
203
  } else {
202
204
  const typeDeclarationPathOption = popOption(
203
- "type-declaration-path",
204
- "type-declaration",
205
- "dts",
206
- "gen-types"
207
- ),
208
- { watch } = await watchModule
205
+ "type-declaration-path",
206
+ "type-declaration",
207
+ "dts",
208
+ "gen-types"
209
+ )
210
+ complainAboutUnrecognisedOptions()
211
+ const { watch } = await watchModule
209
212
  watch(sourcePath, hackmudPath, {
210
213
  scripts,
211
214
  onPush: info => logInfo(info, hackmudPath),
@@ -229,6 +232,7 @@ switch (commands[0]) {
229
232
  logHelp()
230
233
  process.exit(1)
231
234
  }
235
+ complainAboutUnrecognisedOptions()
232
236
  const sourcePath = commands[2] || "."
233
237
  await pull(sourcePath, hackmudPath, script).catch(error => {
234
238
  console.error(error)
@@ -238,8 +242,9 @@ switch (commands[0]) {
238
242
  break
239
243
  case "sync-macros":
240
244
  {
241
- const hackmudPath = getHackmudPath(),
242
- { macrosSynced, usersSynced } = await syncMacros(hackmudPath)
245
+ const hackmudPath = getHackmudPath()
246
+ complainAboutUnrecognisedOptions()
247
+ const { macrosSynced, usersSynced } = await syncMacros(hackmudPath)
243
248
  log(`Synced ${macrosSynced} macros to ${usersSynced} users`)
244
249
  }
245
250
  break
@@ -255,12 +260,13 @@ switch (commands[0]) {
255
260
  logHelp()
256
261
  process.exit(1)
257
262
  }
263
+ complainAboutUnrecognisedOptions()
258
264
  const sourcePath = resolve(target),
259
265
  outputPath = commands[2] || "./player.d.ts",
260
266
  typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
261
267
  let typeDeclarationPath = resolve(outputPath)
262
268
  await writeFile(typeDeclarationPath, typeDeclaration).catch(error => {
263
- assert(error instanceof Error, "src/bin/hsm.ts:330:35")
269
+ assert(error instanceof Error, "src/bin/hsm.ts:343:35")
264
270
  if ("EISDIR" != error.code) throw error
265
271
  typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
266
272
  return writeFile(typeDeclarationPath, typeDeclaration)
@@ -359,7 +365,7 @@ function getHackmudPath() {
359
365
  }
360
366
  function assertOptionIsBoolean(option) {
361
367
  if ("boolean" != typeof option.value) {
362
- logError(`The value for ${colourN(option.name)} must be ${colourV("true")} or ${colourV("false")}\n`)
368
+ logError(`The value for ${formatOption(option.name)} must be ${colourV("true")} or ${colourV("false")}\n`)
363
369
  logHelp()
364
370
  process.exit(1)
365
371
  }
@@ -367,9 +373,7 @@ function assertOptionIsBoolean(option) {
367
373
  function popOption(...names) {
368
374
  const presentOptionNames = names.filter(name => options.has(name))
369
375
  if (!presentOptionNames.length) return
370
- const presentOptionNamesWithDashDash = presentOptionNames.map(name =>
371
- colourN(`-${1 == name.length ? "" : "-"}${name}`)
372
- )
376
+ const presentOptionNamesWithDashDash = presentOptionNames.map(formatOption)
373
377
  if (presentOptionNames.length > 1) {
374
378
  logError(
375
379
  `The options ${presentOptionNamesWithDashDash.join(", ")} are aliases for each other. Please only specify one`
@@ -380,3 +384,11 @@ function popOption(...names) {
380
384
  options.delete(presentOptionNames[0])
381
385
  return { name: presentOptionNamesWithDashDash[0], value }
382
386
  }
387
+ function complainAboutUnrecognisedOptions() {
388
+ if (options.size) {
389
+ logError(
390
+ `Unrecognised option${options.size > 1 ? "s" : ""}: ${[...options.keys()].map(formatOption).join(", ")}`
391
+ )
392
+ process.exit(1)
393
+ }
394
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hackmud-script-manager",
3
- "version": "0.20.4-550e28d",
3
+ "version": "0.20.4-6a2a079",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",