hackmud-script-manager 0.21.1-5970667 → 0.21.1-628a731

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/bin/hsm.js CHANGED
@@ -1,26 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import { AutoMap } from "@samual/lib/AutoMap"
3
- import { assert } from "@samual/lib/assert"
4
- import { countHackmudCharacters } from "@samual/lib/countHackmudCharacters"
5
- import { writeFilePersistent } from "@samual/lib/writeFilePersistent"
6
2
  import { writeFile, readFile } from "fs/promises"
7
3
  import { homedir } from "os"
8
4
  import { resolve, extname, basename, dirname, relative } from "path"
5
+ import { assert } from "@samual/lib/assert"
6
+ import { AutoMap } from "@samual/lib/AutoMap"
7
+ import { countHackmudCharacters } from "@samual/lib/countHackmudCharacters"
8
+ import { writeFilePersistent } from "@samual/lib/writeFilePersistent"
9
9
  import { supportedExtensions } from "../constants.js"
10
10
  import { generateTypeDeclaration } from "../generateTypeDeclaration.js"
11
11
  import { pull } from "../pull.js"
12
12
  import { syncMacros } from "../syncMacros.js"
13
13
  import "@samual/lib/readDirectoryWithStats"
14
14
  import "@samual/lib/copyFilePersistent"
15
- const formatOption = name => colourN(`-${1 == name.length ? "" : "-"}${name}`),
16
- options = new Map(),
17
- commands = [],
18
- userColours = new AutoMap(user => {
19
- let hash = 0
20
- for (const char of user) hash += (hash >> 1) + hash + "xi1_8ratvsw9hlbgm02y5zpdcn7uekof463qj".indexOf(char) + 1
21
- return [colourJ, colourK, colourM, colourW, colourL, colourB][hash % 6](user)
22
- }),
23
- log = message => console.log(colourS(message))
15
+ const options = new Map(),
16
+ commands = []
24
17
  for (const argument of process.argv.slice(2))
25
18
  if ("-" == argument[0]) {
26
19
  const argumentEqualsIndex = argument.indexOf("=")
@@ -53,7 +46,14 @@ const pushModule = import("../push.js"),
53
46
  colourN = chalk.rgb(0, 255, 255),
54
47
  colourS = chalk.rgb(122, 178, 244),
55
48
  colourV = chalk.rgb(255, 0, 236),
56
- colourW = chalk.rgb(255, 150, 224)
49
+ colourW = chalk.rgb(255, 150, 224),
50
+ formatOption = name => colourN(`-${1 == name.length ? "" : "-"}${name}`),
51
+ userColours = new AutoMap(user => {
52
+ let hash = 0
53
+ for (const char of user) hash += (hash >> 1) + hash + "xi1_8ratvsw9hlbgm02y5zpdcn7uekof463qj".indexOf(char) + 1
54
+ return [colourJ, colourK, colourM, colourW, colourL, colourB][hash % 6](user)
55
+ }),
56
+ log = message => console.log(colourS(message))
57
57
  if (process.version.startsWith("v21.")) {
58
58
  process.exitCode = 1
59
59
  console.warn(
@@ -63,7 +63,7 @@ if (process.version.startsWith("v21.")) {
63
63
  )
64
64
  }
65
65
  if ("v" == commands[0] || "version" == commands[0] || popOption("version", "v")?.value) {
66
- console.log("0.21.1-5970667")
66
+ console.log("0.21.1-628a731")
67
67
  process.exit()
68
68
  }
69
69
  let warnedDeprecatedEmitDtsAlias = !1
@@ -77,275 +77,267 @@ switch (commands[0]) {
77
77
  case "dev":
78
78
  case "watch":
79
79
  case "golf":
80
- case "minify":
81
- {
82
- const noMinifyOption = popOption("no-minify", "skip-minify")
83
- if (noMinifyOption && "no-minify" != noMinifyOption.name) {
84
- process.exitCode = 1
85
- console.warn(
86
- colourF(
87
- `${chalk.bold("Warning:")} ${formatOption(noMinifyOption.name)} is deprecated and will be removed in the next minor\n release of HSM\n You should switch to using its alias ${colourN("--no-minify")}\n`
88
- )
80
+ case "minify": {
81
+ const noMinifyOption = popOption("no-minify", "skip-minify")
82
+ if (noMinifyOption && "no-minify" != noMinifyOption.name) {
83
+ process.exitCode = 1
84
+ console.warn(
85
+ colourF(
86
+ `${chalk.bold("Warning:")} ${formatOption(noMinifyOption.name)} is deprecated and will be removed in the next minor\n release of HSM\n You should switch to using its alias ${colourN("--no-minify")}\n`
89
87
  )
88
+ )
89
+ }
90
+ const mangleNamesOption = popOption("mangle-names"),
91
+ forceQuineCheatsOption = popOption("force-quine-cheats"),
92
+ noQuineCheatsOptions = popOption("no-quine-cheats"),
93
+ noMinifyIncompatibleOption = mangleNamesOption || forceQuineCheatsOption || noQuineCheatsOptions
94
+ if (noMinifyOption && noMinifyIncompatibleOption) {
95
+ logError(
96
+ `Options ${formatOption(noMinifyOption.name)} and ${formatOption(noMinifyIncompatibleOption.name)} are incompatible\n`
97
+ )
98
+ logHelp()
99
+ process.exit(1)
100
+ }
101
+ if (forceQuineCheatsOption && noQuineCheatsOptions) {
102
+ logError(
103
+ `Options ${formatOption(forceQuineCheatsOption.name)} and ${formatOption(noQuineCheatsOptions.name)} are incompatible\n`
104
+ )
105
+ logHelp()
106
+ process.exit(1)
107
+ }
108
+ noMinifyOption && assertOptionIsBoolean(noMinifyOption)
109
+ mangleNamesOption && assertOptionIsBoolean(mangleNamesOption)
110
+ forceQuineCheatsOption && assertOptionIsBoolean(forceQuineCheatsOption)
111
+ noQuineCheatsOptions && assertOptionIsBoolean(noQuineCheatsOptions)
112
+ const rootFolderPathOption = popOption("root-folder-path"),
113
+ rootFolderPath = rootFolderPathOption && resolve(rootFolderPathOption.value + "")
114
+ if ("golf" == commands[0] || "minify" == commands[0]) {
115
+ const watchOption = popOption("watch"),
116
+ target = commands[1]
117
+ if (!target) {
118
+ logError("Must provide target\n")
119
+ logHelp()
120
+ process.exit(1)
90
121
  }
91
- const mangleNamesOption = popOption("mangle-names"),
92
- forceQuineCheatsOption = popOption("force-quine-cheats"),
93
- noQuineCheatsOptions = popOption("no-quine-cheats"),
94
- noMinifyIncompatibleOption = mangleNamesOption || forceQuineCheatsOption || noQuineCheatsOptions
95
- if (noMinifyOption && noMinifyIncompatibleOption) {
122
+ const fileExtension = extname(target)
123
+ if (!supportedExtensions.includes(fileExtension)) {
96
124
  logError(
97
- `Options ${formatOption(noMinifyOption.name)} and ${formatOption(noMinifyIncompatibleOption.name)} are incompatible\n`
125
+ `Unsupported file extension "${chalk.bold(fileExtension)}"\nSupported extensions are "${supportedExtensions.map(extension => chalk.bold(extension)).join('", "')}"`
98
126
  )
99
- logHelp()
100
127
  process.exit(1)
101
128
  }
102
- if (forceQuineCheatsOption && noQuineCheatsOptions) {
103
- logError(
104
- `Options ${formatOption(forceQuineCheatsOption.name)} and ${formatOption(noQuineCheatsOptions.name)} are incompatible\n`
129
+ complainAboutUnrecognisedOptions()
130
+ const { processScript } = await processScriptModule,
131
+ fileBaseName = basename(target, fileExtension),
132
+ fileBaseNameEndsWithDotSrc = fileBaseName.endsWith(".src"),
133
+ scriptName = fileBaseNameEndsWithDotSrc ? fileBaseName.slice(0, -4) : fileBaseName,
134
+ scriptUser =
135
+ "scripts" == basename(resolve(target, "..")) && "hackmud" == basename(resolve(target, "../../.."))
136
+ ? basename(resolve(target, "../.."))
137
+ : void 0
138
+ let outputPath =
139
+ commands[2] ||
140
+ resolve(
141
+ dirname(target),
142
+ fileBaseNameEndsWithDotSrc
143
+ ? scriptName + ".js"
144
+ : ".js" == fileExtension
145
+ ? fileBaseName + ".min.js"
146
+ : fileBaseName + ".js"
105
147
  )
148
+ const golfFile = () =>
149
+ readFile(target, { encoding: "utf8" }).then(async source => {
150
+ const timeStart = performance.now(),
151
+ { script, warnings } = await processScript(source, {
152
+ minify: noMinifyOption && !noMinifyOption.value,
153
+ scriptUser,
154
+ scriptName,
155
+ filePath: target,
156
+ mangleNames: mangleNamesOption?.value,
157
+ forceQuineCheats: forceQuineCheatsOption?.value ?? !noQuineCheatsOptions?.value,
158
+ rootFolderPath
159
+ }),
160
+ timeTook = performance.now() - timeStart
161
+ warnings.length && (process.exitCode = 1)
162
+ for (const { message } of warnings) console.warn(colourF(`${chalk.bold("Warning:")} ${message}`))
163
+ await writeFilePersistent(outputPath, script)
164
+ .catch(error => {
165
+ if (!commands[2] || "EISDIR" != error.code) throw error
166
+ outputPath = resolve(outputPath, basename(target, fileExtension) + ".js")
167
+ return writeFilePersistent(outputPath, script)
168
+ })
169
+ .then(() =>
170
+ log(
171
+ `Wrote ${chalk.bold(countHackmudCharacters(script))} chars to ${chalk.bold(relative(".", outputPath))} | took ${Math.round(100 * timeTook) / 100}ms`
172
+ )
173
+ )
174
+ })
175
+ if (watchOption) {
176
+ const { watch: watchFile } = await chokidarModule
177
+ watchFile(target, { awaitWriteFinish: { stabilityThreshold: 100 } })
178
+ .on("ready", () => log("Watching " + target))
179
+ .on("change", golfFile)
180
+ autoExit = !1
181
+ } else await golfFile()
182
+ } else {
183
+ const hackmudPath = getHackmudPath(),
184
+ sourcePath = commands[1]
185
+ if (!sourcePath) {
186
+ logError(`Must provide the directory to ${"push" == commands[0] ? "push from" : "watch"}\n`)
106
187
  logHelp()
107
188
  process.exit(1)
108
189
  }
109
- noMinifyOption && assertOptionIsBoolean(noMinifyOption)
110
- mangleNamesOption && assertOptionIsBoolean(mangleNamesOption)
111
- forceQuineCheatsOption && assertOptionIsBoolean(forceQuineCheatsOption)
112
- noQuineCheatsOptions && assertOptionIsBoolean(noQuineCheatsOptions)
113
- const rootFolderPathOption = popOption("root-folder-path"),
114
- rootFolderPath = rootFolderPathOption && resolve(rootFolderPathOption.value + "")
115
- if ("golf" == commands[0] || "minify" == commands[0]) {
116
- const watchOption = popOption("watch"),
117
- target = commands[1]
118
- if (!target) {
119
- logError("Must provide target\n")
190
+ const scripts = commands.slice(2)
191
+ if (scripts.length) {
192
+ const invalidScript = scripts.find(
193
+ script => !/^(?:[a-z_][a-z\d_]{0,24}|\*)\.(?:[a-z_][a-z\d_]{0,24}|\*)$/.test(script)
194
+ )
195
+ if (invalidScript) {
196
+ logError(`Invalid script name: ${JSON.stringify(invalidScript)}\n`)
120
197
  logHelp()
121
198
  process.exit(1)
122
199
  }
123
- const fileExtension = extname(target)
124
- if (!supportedExtensions.includes(fileExtension)) {
125
- logError(
126
- `Unsupported file extension "${chalk.bold(fileExtension)}"\nSupported extensions are "${supportedExtensions.map(extension => chalk.bold(extension)).join('", "')}"`
200
+ } else scripts.push("*.*")
201
+ const watchOption = popOption("watch")
202
+ if ("push" != commands[0] || watchOption?.value) {
203
+ const dtsPathOption = popOption(
204
+ "dts-path",
205
+ "type-declaration-path",
206
+ "type-declaration",
207
+ "dts",
208
+ "gen-types"
209
+ )
210
+ if (
211
+ dtsPathOption &&
212
+ "dts-path" != dtsPathOption.name &&
213
+ "type-declaration-path" != dtsPathOption.name
214
+ ) {
215
+ process.exitCode = 1
216
+ console.warn(
217
+ colourF(
218
+ `${chalk.bold("Warning:")} ${formatOption(dtsPathOption.name)} is deprecated and will be removed in the\n next minor release of HSM\n You should switch to using its alias ${colourN("--dts-path")}\n`
219
+ )
127
220
  )
128
- process.exit(1)
129
221
  }
130
222
  complainAboutUnrecognisedOptions()
131
- const { processScript } = await processScriptModule,
132
- fileBaseName = basename(target, fileExtension),
133
- fileBaseNameEndsWithDotSrc = fileBaseName.endsWith(".src"),
134
- scriptName = fileBaseNameEndsWithDotSrc ? fileBaseName.slice(0, -4) : fileBaseName,
135
- scriptUser =
136
- "scripts" == basename(resolve(target, "..")) &&
137
- "hackmud" == basename(resolve(target, "../../.."))
138
- ? basename(resolve(target, "../.."))
139
- : void 0
140
- let outputPath =
141
- commands[2] ||
142
- resolve(
143
- dirname(target),
144
- fileBaseNameEndsWithDotSrc
145
- ? scriptName + ".js"
146
- : ".js" == fileExtension
147
- ? fileBaseName + ".min.js"
148
- : fileBaseName + ".js"
149
- )
150
- const golfFile = () =>
151
- readFile(target, { encoding: "utf8" }).then(async source => {
152
- const timeStart = performance.now(),
153
- { script, warnings } = await processScript(source, {
154
- minify: noMinifyOption && !noMinifyOption.value,
155
- scriptUser,
156
- scriptName,
157
- filePath: target,
158
- mangleNames: mangleNamesOption?.value,
159
- forceQuineCheats: forceQuineCheatsOption?.value ?? !noQuineCheatsOptions?.value,
160
- rootFolderPath
161
- }),
162
- timeTook = performance.now() - timeStart
163
- warnings.length && (process.exitCode = 1)
164
- for (const { message } of warnings)
165
- console.warn(colourF(`${chalk.bold("Warning:")} ${message}`))
166
- await writeFilePersistent(outputPath, script)
167
- .catch(error => {
168
- if (!commands[2] || "EISDIR" != error.code) throw error
169
- outputPath = resolve(outputPath, basename(target, fileExtension) + ".js")
170
- return writeFilePersistent(outputPath, script)
171
- })
172
- .then(() =>
173
- log(
174
- `Wrote ${chalk.bold(countHackmudCharacters(script))} chars to ${chalk.bold(relative(".", outputPath))} | took ${Math.round(100 * timeTook) / 100}ms`
175
- )
176
- )
177
- })
178
- if (watchOption) {
179
- const { watch: watchFile } = await chokidarModule
180
- watchFile(target, { awaitWriteFinish: { stabilityThreshold: 100 } })
181
- .on("ready", () => log("Watching " + target))
182
- .on("change", golfFile)
183
- autoExit = !1
184
- } else await golfFile()
223
+ const { watch } = await watchModule
224
+ watch(sourcePath, hackmudPath, {
225
+ scripts,
226
+ onPush: info => logInfo(info, hackmudPath),
227
+ typeDeclarationPath: dtsPathOption?.value.toString(),
228
+ minify: noMinifyOption && !noMinifyOption.value,
229
+ mangleNames: mangleNamesOption?.value,
230
+ onReady: () => log("Watching"),
231
+ forceQuineCheats: forceQuineCheatsOption?.value ?? !noQuineCheatsOptions?.value,
232
+ rootFolderPath
233
+ })
234
+ autoExit = !1
185
235
  } else {
186
- const hackmudPath = getHackmudPath(),
187
- sourcePath = commands[1]
188
- if (!sourcePath) {
189
- logError(`Must provide the directory to ${"push" == commands[0] ? "push from" : "watch"}\n`)
190
- logHelp()
191
- process.exit(1)
192
- }
193
- const scripts = commands.slice(2)
194
- if (scripts.length) {
195
- const invalidScript = scripts.find(
196
- script => !/^(?:[a-z_][a-z\d_]{0,24}|\*)\.(?:[a-z_][a-z\d_]{0,24}|\*)$/.test(script)
197
- )
198
- if (invalidScript) {
199
- logError(`Invalid script name: ${JSON.stringify(invalidScript)}\n`)
236
+ const dtsPathOption = popOption("dts-path")
237
+ complainAboutUnrecognisedOptions()
238
+ let declarationPathPromise
239
+ if (dtsPathOption) {
240
+ if ("string" != typeof dtsPathOption.value) {
241
+ logError(
242
+ `Option ${formatOption(dtsPathOption.name)} must be a string, got ${colourV(dtsPathOption.value)}\n`
243
+ )
200
244
  logHelp()
201
245
  process.exit(1)
202
246
  }
203
- } else scripts.push("*.*")
204
- const watchOption = popOption("watch")
205
- if ("push" != commands[0] || watchOption?.value) {
206
- const dtsPathOption = popOption(
207
- "dts-path",
208
- "type-declaration-path",
209
- "type-declaration",
210
- "dts",
211
- "gen-types"
212
- )
213
- if (
214
- dtsPathOption &&
215
- "dts-path" != dtsPathOption.name &&
216
- "type-declaration-path" != dtsPathOption.name
217
- ) {
218
- process.exitCode = 1
219
- console.warn(
220
- colourF(
221
- `${chalk.bold("Warning:")} ${formatOption(dtsPathOption.name)} is deprecated and will be removed in the\n next minor release of HSM\n You should switch to using its alias ${colourN("--dts-path")}\n`
222
- )
223
- )
224
- }
225
- complainAboutUnrecognisedOptions()
226
- const { watch } = await watchModule
227
- watch(sourcePath, hackmudPath, {
247
+ let typeDeclarationPath = resolve(dtsPathOption.value)
248
+ const typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
249
+ declarationPathPromise = writeFile(typeDeclarationPath, typeDeclaration)
250
+ .catch(error => {
251
+ assert(error instanceof Error, "src/bin/hsm.ts:300:38")
252
+ if ("EISDIR" != error.code) throw error
253
+ typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
254
+ return writeFile(typeDeclarationPath, typeDeclaration)
255
+ })
256
+ .then(() => typeDeclarationPath)
257
+ }
258
+ const { push, MissingSourceFolderError, MissingHackmudFolderError, NoUsersError } = await pushModule,
259
+ infos = await push(sourcePath, hackmudPath, {
228
260
  scripts,
229
261
  onPush: info => logInfo(info, hackmudPath),
230
- typeDeclarationPath: dtsPathOption?.value.toString(),
231
262
  minify: noMinifyOption && !noMinifyOption.value,
232
263
  mangleNames: mangleNamesOption?.value,
233
- onReady: () => log("Watching"),
234
264
  forceQuineCheats: forceQuineCheatsOption?.value ?? !noQuineCheatsOptions?.value,
235
265
  rootFolderPath
236
266
  })
237
- autoExit = !1
238
- } else {
239
- const dtsPathOption = popOption("dts-path")
240
- complainAboutUnrecognisedOptions()
241
- let declarationPathPromise
242
- if (dtsPathOption) {
243
- if ("string" != typeof dtsPathOption.value) {
244
- logError(
245
- `Option ${formatOption(dtsPathOption.name)} must be a string, got ${colourV(dtsPathOption.value)}\n`
267
+ if (infos instanceof Error) {
268
+ logError(infos.message)
269
+ if (infos instanceof MissingSourceFolderError || infos instanceof NoUsersError) {
270
+ console.log()
271
+ logHelp()
272
+ } else
273
+ infos instanceof MissingHackmudFolderError &&
274
+ log(
275
+ `If this is not where your hackmud folder is, you can specify it with the\n${colourN("--hackmud-path")}=${colourB("<path>")} option or ${colourN("HSM_HACKMUD_PATH")} environment variable`
246
276
  )
247
- logHelp()
248
- process.exit(1)
249
- }
250
- let typeDeclarationPath = resolve(dtsPathOption.value)
251
- const typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
252
- declarationPathPromise = writeFile(typeDeclarationPath, typeDeclaration)
253
- .catch(error => {
254
- assert(error instanceof Error, "src/bin/hsm.ts:299:38")
255
- if ("EISDIR" != error.code) throw error
256
- typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
257
- return writeFile(typeDeclarationPath, typeDeclaration)
258
- })
259
- .then(() => typeDeclarationPath)
260
- }
261
- const { push, MissingSourceFolderError, MissingHackmudFolderError, NoUsersError } =
262
- await pushModule,
263
- infos = await push(sourcePath, hackmudPath, {
264
- scripts,
265
- onPush: info => logInfo(info, hackmudPath),
266
- minify: noMinifyOption && !noMinifyOption.value,
267
- mangleNames: mangleNamesOption?.value,
268
- forceQuineCheats: forceQuineCheatsOption?.value ?? !noQuineCheatsOptions?.value,
269
- rootFolderPath
270
- })
271
- if (infos instanceof Error) {
272
- logError(infos.message)
273
- if (infos instanceof MissingSourceFolderError || infos instanceof NoUsersError) {
274
- console.log()
275
- logHelp()
276
- } else
277
- infos instanceof MissingHackmudFolderError &&
278
- log(
279
- `If this is not where your hackmud folder is, you can specify it with the\n${colourN("--hackmud-path")}=${colourB("<path>")} option or ${colourN("HSM_HACKMUD_PATH")} environment variable`
280
- )
281
- } else infos.length || logError("Could not find any scripts to push")
282
- declarationPathPromise &&
283
- log("Wrote type declaration to " + chalk.bold(await declarationPathPromise))
284
- }
277
+ } else infos.length || logError("Could not find any scripts to push")
278
+ declarationPathPromise && log("Wrote type declaration to " + chalk.bold(await declarationPathPromise))
285
279
  }
286
280
  }
287
281
  break
288
- case "pull":
289
- {
290
- const hackmudPath = getHackmudPath(),
291
- script = commands[1]
292
- if (!script) {
293
- logError("Must provide the script to pull\n")
294
- logHelp()
295
- process.exit(1)
296
- }
297
- complainAboutUnrecognisedOptions()
298
- const sourcePath = commands[2] || "."
299
- await pull(sourcePath, hackmudPath, script).catch(error => {
300
- console.error(error)
301
- logError(`Something went wrong, did you forget to ${colourC("#down")} the script?`)
302
- })
282
+ }
283
+ case "pull": {
284
+ const hackmudPath = getHackmudPath(),
285
+ script = commands[1]
286
+ if (!script) {
287
+ logError("Must provide the script to pull\n")
288
+ logHelp()
289
+ process.exit(1)
303
290
  }
291
+ complainAboutUnrecognisedOptions()
292
+ const sourcePath = commands[2] || "."
293
+ await pull(sourcePath, hackmudPath, script).catch(error => {
294
+ console.error(error)
295
+ logError(`Something went wrong, did you forget to ${colourC("#down")} the script?`)
296
+ })
304
297
  break
305
- case "sync-macros":
306
- {
307
- const hackmudPath = getHackmudPath()
308
- complainAboutUnrecognisedOptions()
309
- const { macrosSynced, usersSynced } = await syncMacros(hackmudPath)
310
- log(`Synced ${macrosSynced} macros to ${usersSynced} users`)
311
- }
298
+ }
299
+ case "sync-macros": {
300
+ const hackmudPath = getHackmudPath()
301
+ complainAboutUnrecognisedOptions()
302
+ const { macrosSynced, usersSynced } = await syncMacros(hackmudPath)
303
+ log(`Synced ${macrosSynced} macros to ${usersSynced} users`)
312
304
  break
305
+ }
313
306
  case "generate-type-declaration":
314
307
  case "gen-type-declaration":
315
308
  case "gen-dts":
316
309
  case "gen-types":
317
- case "emit-dts":
318
- {
319
- if ("emit-dts" != commands[0] && "gen-dts" != commands[0]) {
320
- warnedDeprecatedEmitDtsAlias = !0
321
- process.exitCode = 1
322
- console.warn(
323
- colourF(
324
- `${chalk.bold("Warning:")} ${colourC("hsm")} ${colourL(commands[0])} is deprecated and will be removed\n in the next minor release of HSM\n You should switch to using its alias ${colourC("hsm")} ${colourL("emit-dts")}\n`
325
- )
310
+ case "emit-dts": {
311
+ if ("emit-dts" != commands[0] && "gen-dts" != commands[0]) {
312
+ warnedDeprecatedEmitDtsAlias = !0
313
+ process.exitCode = 1
314
+ console.warn(
315
+ colourF(
316
+ `${chalk.bold("Warning:")} ${colourC("hsm")} ${colourL(commands[0])} is deprecated and will be removed\n in the next minor release of HSM\n You should switch to using its alias ${colourC("hsm")} ${colourL("emit-dts")}\n`
326
317
  )
327
- }
328
- const hackmudPath = getHackmudPath(),
329
- target = commands[1]
330
- if (!target) {
331
- logError("Must provide target directory\n")
332
- logHelp()
333
- process.exit(1)
334
- }
335
- complainAboutUnrecognisedOptions()
336
- const sourcePath = resolve(target),
337
- outputPath = commands[2] || "./player.d.ts",
338
- typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
339
- let typeDeclarationPath = resolve(outputPath)
340
- await writeFile(typeDeclarationPath, typeDeclaration).catch(error => {
341
- assert(error instanceof Error, "src/bin/hsm.ts:438:35")
342
- if ("EISDIR" != error.code) throw error
343
- typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
344
- return writeFile(typeDeclarationPath, typeDeclaration)
345
- })
346
- log("Wrote type declaration to " + chalk.bold(typeDeclarationPath))
318
+ )
319
+ }
320
+ const hackmudPath = getHackmudPath(),
321
+ target = commands[1]
322
+ if (!target) {
323
+ logError("Must provide target directory\n")
324
+ logHelp()
325
+ process.exit(1)
347
326
  }
327
+ complainAboutUnrecognisedOptions()
328
+ const sourcePath = resolve(target),
329
+ outputPath = commands[2] || "./player.d.ts",
330
+ typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
331
+ let typeDeclarationPath = resolve(outputPath)
332
+ await writeFile(typeDeclarationPath, typeDeclaration).catch(error => {
333
+ assert(error instanceof Error, "src/bin/hsm.ts:444:35")
334
+ if ("EISDIR" != error.code) throw error
335
+ typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
336
+ return writeFile(typeDeclarationPath, typeDeclaration)
337
+ })
338
+ log("Wrote type declaration to " + chalk.bold(typeDeclarationPath))
348
339
  break
340
+ }
349
341
  case "help":
350
342
  logHelp()
351
343
  break
@@ -411,7 +403,7 @@ function logHelp() {
411
403
  default:
412
404
  console.log(
413
405
  colourS(
414
- `${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-5970667")}\n\n${colourA("Commands:")}\n${colourL("push")}\n ${pushCommandDescription}\n${colourL("minify")}\n Minify a script file on the spot\n${colourL("emit-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("pull")}\n Pull a script a from a hackmud user's script directory\n\n${colourA("Options:")}\n${colourN("--help")}\n Can be used on any command e.g. ${colourC("hsm")} ${colourL("push")} ${colourN("--help")} to show helpful information`
406
+ `${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-628a731")}\n\n${colourA("Commands:")}\n${colourL("push")}\n ${pushCommandDescription}\n${colourL("minify")}\n Minify a script file on the spot\n${colourL("emit-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("pull")}\n Pull a script a from a hackmud user's script directory\n\n${colourA("Options:")}\n${colourN("--help")}\n Can be used on any command e.g. ${colourC("hsm")} ${colourL("push")} ${colourN("--help")} to show helpful information`
415
407
  )
416
408
  )
417
409
  }