hackmud-script-manager 0.21.1-583d190 → 0.21.1-6d6aa5b

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 CHANGED
@@ -12,7 +12,7 @@ You can read about how HSM works [in my blog post](https://samual.uk/blog/js-cod
12
12
  ## Usage
13
13
  1. Run `#dir` in game, then `cd` to that folder
14
14
  2. Name your source script file to `<name>.src.js`
15
- 3. Run `hsm golf <name>.src.js` and it will create a minified script file called `<name>.js`
15
+ 3. Run `hsm minify <name>.src.js` and it will create a minified script file called `<name>.js`
16
16
 
17
17
  > **NOTE:** If you get an error message that looks like this:
18
18
  > ```
package/bin/hsm.js CHANGED
@@ -55,14 +55,16 @@ const pushModule = import("../push.js"),
55
55
  colourS = chalk.rgb(122, 178, 244),
56
56
  colourV = chalk.rgb(255, 0, 236),
57
57
  colourW = chalk.rgb(255, 150, 224)
58
- process.version.startsWith("v21.") &&
58
+ if (process.version.startsWith("v21.")) {
59
+ process.exitCode = 1
59
60
  console.warn(
60
61
  colourF(
61
62
  `${chalk.bold("Warning:")} Support for Node.js 21 will be dropped in the next minor version of HSM\n Your current version of Node.js is ${chalk.bold(process.version)}\n You should update your version of Node.js\n https://nodejs.org/en/download/package-manager\n`
62
63
  )
63
64
  )
65
+ }
64
66
  if ("v" == commands[0] || "version" == commands[0] || popOption("version", "v")?.value) {
65
- console.log("0.21.1-583d190")
67
+ console.log("0.21.1-6d6aa5b")
66
68
  process.exit()
67
69
  }
68
70
  let warnedDeprecatedEmitDtsAlias = !1
@@ -79,13 +81,14 @@ switch (commands[0]) {
79
81
  case "minify":
80
82
  {
81
83
  const noMinifyOption = popOption("no-minify", "skip-minify")
82
- noMinifyOption &&
83
- "no-minify" != noMinifyOption.name &&
84
+ if (noMinifyOption && "no-minify" != noMinifyOption.name) {
85
+ process.exitCode = 1
84
86
  console.warn(
85
87
  colourF(
86
88
  `${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`
87
89
  )
88
90
  )
91
+ }
89
92
  const mangleNamesOption = popOption("mangle-names"),
90
93
  forceQuineCheatsOption = popOption("force-quine-cheats"),
91
94
  noQuineCheatsOptions = popOption("no-quine-cheats"),
@@ -131,19 +134,19 @@ switch (commands[0]) {
131
134
  fileBaseNameEndsWithDotSrc = fileBaseName.endsWith(".src"),
132
135
  scriptName = fileBaseNameEndsWithDotSrc ? fileBaseName.slice(0, -4) : fileBaseName,
133
136
  scriptUser =
134
- (
135
- "scripts" == basename(resolve(target, "..")) &&
136
- "hackmud" == basename(resolve(target, "../../.."))
137
- ) ?
138
- basename(resolve(target, "../.."))
139
- : void 0
137
+ "scripts" == basename(resolve(target, "..")) &&
138
+ "hackmud" == basename(resolve(target, "../../.."))
139
+ ? basename(resolve(target, "../.."))
140
+ : void 0
140
141
  let outputPath =
141
142
  commands[2] ||
142
143
  resolve(
143
144
  dirname(target),
144
- fileBaseNameEndsWithDotSrc ? scriptName + ".js"
145
- : ".js" == fileExtension ? fileBaseName + ".min.js"
146
- : fileBaseName + ".js"
145
+ fileBaseNameEndsWithDotSrc
146
+ ? scriptName + ".js"
147
+ : ".js" == fileExtension
148
+ ? fileBaseName + ".min.js"
149
+ : fileBaseName + ".js"
147
150
  )
148
151
  const golfFile = () =>
149
152
  readFile(target, { encoding: "utf8" }).then(async source => {
@@ -158,6 +161,7 @@ switch (commands[0]) {
158
161
  rootFolderPath
159
162
  }),
160
163
  timeTook = performance.now() - timeStart
164
+ warnings.length && (process.exitCode = 1)
161
165
  for (const { message } of warnings)
162
166
  console.warn(colourF(`${chalk.bold("Warning:")} ${message}`))
163
167
  await writeFilePersistent(outputPath, script)
@@ -207,14 +211,18 @@ switch (commands[0]) {
207
211
  "dts",
208
212
  "gen-types"
209
213
  )
210
- dtsPathOption &&
214
+ if (
215
+ dtsPathOption &&
211
216
  "dts-path" != dtsPathOption.name &&
212
- "type-declaration-path" != dtsPathOption.name &&
217
+ "type-declaration-path" != dtsPathOption.name
218
+ ) {
219
+ process.exitCode = 1
213
220
  console.warn(
214
221
  colourF(
215
222
  `${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`
216
223
  )
217
224
  )
225
+ }
218
226
  complainAboutUnrecognisedOptions()
219
227
  const { watch } = await watchModule
220
228
  watch(sourcePath, hackmudPath, {
@@ -244,7 +252,7 @@ switch (commands[0]) {
244
252
  const typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
245
253
  declarationPathPromise = writeFile(typeDeclarationPath, typeDeclaration)
246
254
  .catch(error => {
247
- assert(error instanceof Error, "src/bin/hsm.ts:292:38")
255
+ assert(error instanceof Error, "src/bin/hsm.ts:299:38")
248
256
  if ("EISDIR" != error.code) throw error
249
257
  typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
250
258
  return writeFile(typeDeclarationPath, typeDeclaration)
@@ -311,6 +319,7 @@ switch (commands[0]) {
311
319
  {
312
320
  if ("emit-dts" != commands[0] && "gen-dts" != commands[0]) {
313
321
  warnedDeprecatedEmitDtsAlias = !0
322
+ process.exitCode = 1
314
323
  console.warn(
315
324
  colourF(
316
325
  `${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`
@@ -330,7 +339,7 @@ switch (commands[0]) {
330
339
  typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
331
340
  let typeDeclarationPath = resolve(outputPath)
332
341
  await writeFile(typeDeclarationPath, typeDeclaration).catch(error => {
333
- assert(error instanceof Error, "src/bin/hsm.ts:428:35")
342
+ assert(error instanceof Error, "src/bin/hsm.ts:438:35")
334
343
  if ("EISDIR" != error.code) throw error
335
344
  typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
336
345
  return writeFile(typeDeclarationPath, typeDeclaration)
@@ -379,14 +388,14 @@ function logHelp() {
379
388
  case "gen-dts":
380
389
  case "gen-types":
381
390
  case "emit-dts":
382
- warnedDeprecatedEmitDtsAlias ||
383
- "emit-dts" == commands[0] ||
384
- "gen-dts" == commands[0] ||
391
+ if (!warnedDeprecatedEmitDtsAlias && "emit-dts" != commands[0] && "gen-dts" != commands[0]) {
392
+ process.exitCode = 1
385
393
  console.warn(
386
394
  colourF(
387
395
  `${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`
388
396
  )
389
397
  )
398
+ }
390
399
  console.log(
391
400
  colourS(
392
401
  `${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]")}\n\n${colourA("Options:")}\n${hackmudPathOption}`
@@ -403,7 +412,7 @@ function logHelp() {
403
412
  default:
404
413
  console.log(
405
414
  colourS(
406
- `${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-583d190")}\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
+ `${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-6d6aa5b")}\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`
407
416
  )
408
417
  )
409
418
  }
@@ -412,6 +421,7 @@ function logInfo({ path, users, characterCount, error, warnings }, hackmudPath)
412
421
  path = relative(".", path)
413
422
  if (error) logError(`Error "${chalk.bold(error.message)}" in ${chalk.bold(path)}`)
414
423
  else {
424
+ warnings.length && (process.exitCode = 1)
415
425
  for (const warning of warnings) console.warn(colourF(`${chalk.bold("Warning:")} ${warning.message}`))
416
426
  log(
417
427
  `Pushed ${chalk.bold(path)} to ${users.map(user => chalk.bold(userColours.get(user))).join(", ")} | ${chalk.bold(characterCount + "")} chars | ${chalk.bold(resolve(hackmudPath, users[0], "scripts", basename(path, extname(path))) + ".js")}`
package/env.d.ts CHANGED
@@ -189,7 +189,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
189
189
 
190
190
  /** @returns A random element from `array`, selected with a random number generated using `rng`
191
191
  * (defaults to `Math.random`). */
192
- sample: (array: any[], rng?: ()=>number) => any
192
+ sample: <T>(array: T[], rng?: ()=>number) => T
193
193
 
194
194
  /** @returns Whether two MongoDB `ObjectId`s are equivalent. */ are_ids_eq: (id1: any, id2: any) => boolean
195
195
  /** Convert a MongoDB `ObjectId` to a string. */ id_to_str: (id: string | {$oid: string}) => any
@@ -270,7 +270,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
270
270
  map: <T, U>(array: T[], callback: (index: number, value: T) => U) => U[]
271
271
 
272
272
  /** @returns A new object derived from `obj` with only the keys specified in `keys`. */
273
- pick: (obj: object, keys: string[]) => any
273
+ pick: <TObj extends object, TKeys extends keyof TObj>(obj: TObj, keys: TKeys[]) => { [K in TKeys]: TObj[K] }
274
274
 
275
275
  /** @returns An array with the elements from `array` in a random order. */ shuffle: <T>(array: T[]) => T[]
276
276
 
@@ -298,7 +298,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
298
298
  security_level_names: [ "NULLSEC", "LOWSEC", "MIDSEC", "HIGHSEC", "FULLSEC" ]
299
299
 
300
300
  /** @returns The string name of a numeric security level. */
301
- get_security_level_name: (security_level: number) => any
301
+ get_security_level_name: (security_level: number) => string
302
302
 
303
303
  /** @param result The return value of a call to `$db.i()` or `$db.r()`.
304
304
  * @param nModified The expected value of `result.nModified`.
@@ -699,18 +699,18 @@ type Nullsec = Lowsec & PlayerNullsec & {
699
699
  // database
700
700
  type MongoPrimitive = null | boolean | number | Date | string
701
701
  type MongoValue = MongoPrimitive | MongoValue[] | MongoObject
702
- type MongoObject = { [k: string]: MongoValue, [k: `$${string}`]: never }
702
+ type MongoObject = { [k: string]: MongoValue }
703
703
  type MongoQueryValue = MongoPrimitive | MongoQueryValue[] | MongoQueryObject
704
704
 
705
705
  type MongoQueryObject =
706
- { [k: string]: MongoQueryValue, [k: `$${string}`]: MongoValue, $type?: keyof MongoTypeStringsToTypes | (string & {}) }
706
+ { [k: string]: MongoQueryValue, [k: `$${string}`]: MongoValue } & { $type?: keyof MongoTypeStringsToTypes | (string & {}) }
707
707
 
708
708
  type MongoTypeStringsToTypes = {
709
709
  double: number
710
710
  string: string
711
711
  object: MongoObject
712
712
  array: MongoValue[]
713
- objectId: ObjectId
713
+ objectId: MongoObjectId
714
714
  bool: boolean
715
715
  date: Date
716
716
  null: null
@@ -720,8 +720,8 @@ type MongoTypeStringsToTypes = {
720
720
 
721
721
  type MongoTypeString = keyof MongoTypeStringsToTypes
722
722
  type MongoTypeNumber = -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 127
723
- type MongoId = Exclude<MongoPrimitive, null> | MongoObject
724
- type MongoQueryId = Exclude<MongoPrimitive, null> | MongoQueryObject
723
+ type MongoId = Exclude<MongoPrimitive, null | false> | MongoObjectId | MongoObject
724
+ type MongoQueryId = Exclude<MongoPrimitive, null | false> | MongoObjectId | MongoQueryObject
725
725
  type MongoDocument = MongoObject & { _id?: MongoId }
726
726
 
727
727
  type MongoQueryType<TQuery extends MongoQueryObject> = {
@@ -755,11 +755,16 @@ type MongoQuerySelector<T extends MongoValue> = Partial<
755
755
 
756
756
  type MongoQuery<T extends MongoObject> = { [K in keyof T]?: T[K] | MongoQuerySelector<T[K]> } & { _id?: MongoId }
757
757
 
758
- type MongoUpdateOperators<T extends MongoObject> = Partial<{
758
+ type MongoUpdateArrayOperatorUniversalModifiers<T> = { $each?: T extends [] ? T : T[] }
759
+
760
+ type MongoUpdateArrayOperatorModifiers<T> = MongoUpdateArrayOperatorUniversalModifiers<T> &
761
+ { $position?: number, $slice?: number, $sort?: 1 | -1 }
762
+
763
+ type MongoUpdateCommand<T extends MongoObject> = Partial<{
759
764
  /* Universal operators */
760
- $set: Partial<Record<string, MongoCommandValue> & T>
761
- $setOnInsert: Partial<Record<string, MongoCommandValue> & T>
762
- $unset: Partial<Record<string, ""> & T>
765
+ $set: Partial<Record<(string & {}) | keyof T, MongoCommandValue>>
766
+ $setOnInsert: Partial<Record<(string & {}) | keyof T, MongoCommandValue>>
767
+ $unset: Partial<Record<(string & {}) | keyof T, "">>
763
768
 
764
769
  $rename: Partial<Record<string, string> & { [key in keyof T]: string }>
765
770
 
@@ -792,13 +797,6 @@ type MongoUpdateOperators<T extends MongoObject> = Partial<{
792
797
  $pullAll: Record<string, MongoCommandValue> & { [K in keyof T as T[K] extends [] ? K : never]?: T[K] }
793
798
  }>
794
799
 
795
- type MongoUpdateArrayOperatorUniversalModifiers<T> = { $each?: T extends [] ? T : T[] }
796
-
797
- type MongoUpdateArrayOperatorModifiers<T> = MongoUpdateArrayOperatorUniversalModifiers<T> &
798
- { $position?: number, $slice?: number, $sort?: 1 | -1 }
799
-
800
- type MongoUpdateCommand<Schema extends MongoObject> = MongoUpdateOperators<Schema>
801
-
802
800
  type SortOrder = { [key: string]: 1 | -1 | SortOrder }
803
801
 
804
802
  type Cursor<T> = {
@@ -865,8 +863,8 @@ type BrainContext = Replace<CliContext, { /** Whether the script is being run vi
865
863
  // when anyField: true is given, other fields (except _id) are omitted
866
864
 
867
865
  type MongoProject<TDocument, TProjection> =
868
- true extends (1 extends TProjection[keyof TProjection] ? true : TProjection[keyof TProjection]) ?
869
- (TProjection extends { _id: false | 0 } ? {} : { _id: TDocument extends { _id: infer TId } ? TId : MongoId }) &
866
+ (TProjection extends { _id: false | 0 } ? {} : { _id: TDocument extends { _id: infer TId } ? TId : MongoId }) & (
867
+ true extends (1 extends TProjection[keyof TProjection] ? true : TProjection[keyof TProjection]) ?
870
868
  {
871
869
  [K in
872
870
  keyof TDocument as K extends keyof TProjection ? TProjection[K] extends true | 1 ? K : never : never
@@ -877,7 +875,8 @@ type MongoProject<TDocument, TProjection> =
877
875
  keyof TProjection as TProjection[K] extends true | 1 ? K extends keyof TDocument ? never : K : never
878
876
  ]?: MongoValue
879
877
  }
880
- : { [k: string]: MongoValue } & { [K in keyof TDocument as K extends keyof TProjection ? never : K]: TDocument[K] }
878
+ : { [k: string]: MongoValue } & { [K in keyof TDocument as K extends keyof TProjection ? never : K]: TDocument[K] }
879
+ )
881
880
 
882
881
  type DeepFreeze<T> = { readonly [P in keyof T]: DeepFreeze<T[P]> }
883
882
 
@@ -885,9 +884,9 @@ declare global {
885
884
  type ScriptSuccess<T = unknown> = { ok: true } & T
886
885
  type ScriptFailure = { ok: false, msg?: string }
887
886
  type ScriptResponse<T = unknown> = ScriptSuccess<T> | ScriptFailure
888
- type Scriptor<TArgs extends any[] = any[]> = { name: string, call: (...args: TArgs) => unknown }
887
+ type Scriptor<TArgs = any> = { name: string, call: (args: TArgs) => unknown }
889
888
  type Context = CliContext | SubscriptContext | ScriptorContext | BrainContext
890
- type ObjectId = { $oid: string }
889
+ type MongoObjectId = { $oid: string }
891
890
 
892
891
  interface PlayerFullsec {}
893
892
  interface PlayerHighsec {}
@@ -978,7 +977,7 @@ declare global {
978
977
  us: <T extends MongoDocument>(query: MongoQuery<T> | MongoQuery<T>[], command: MongoUpdateCommand<T>) =>
979
978
  { n: number, ok: 0 | 1, opTime: { t: number }, nModified: number }[]
980
979
 
981
- ObjectId: () => ObjectId
980
+ ObjectId: () => MongoObjectId
982
981
  }
983
982
 
984
983
  /** Debug Log.
@@ -11,24 +11,26 @@ async function generateTypeDeclaration(sourceDirectory, hackmudPath) {
11
11
  allScripts = {},
12
12
  allAnyScripts = {}
13
13
  await Promise.all(
14
- (await readDirectoryWithStats(sourceDirectory)).map(async ({ stats, name }) => {
15
- if (stats.isFile())
16
- name.endsWith(".ts") ?
17
- name.endsWith(".d.ts") || wildScripts.push(basename(name, ".ts"))
18
- : name.endsWith(".js") && wildAnyScripts.push(basename(name, ".js"))
19
- else if (stats.isDirectory()) {
20
- const scripts = [],
21
- anyScripts = []
22
- allScripts[name] = scripts
23
- allAnyScripts[name] = anyScripts
24
- users.add(name)
25
- for (const child of await readDirectoryWithStats(resolve(sourceDirectory, name)))
26
- child.stats.isFile() &&
27
- (child.name.endsWith(".ts") ?
28
- name.endsWith(".d.ts") || scripts.push(basename(child.name, ".ts"))
29
- : child.name.endsWith(".js") && anyScripts.push(basename(child.name, ".js")))
30
- }
31
- })
14
+ (await readDirectoryWithStats(sourceDirectory))
15
+ .filter(({ stats, name }) => !stats.isDirectory() || /^[a-z_][a-z\d_]{0,24}$/.test(name))
16
+ .map(async ({ stats, name }) => {
17
+ if (stats.isFile())
18
+ name.endsWith(".ts")
19
+ ? name.endsWith(".d.ts") || wildScripts.push(basename(name, ".ts"))
20
+ : name.endsWith(".js") && wildAnyScripts.push(basename(name, ".js"))
21
+ else if (stats.isDirectory()) {
22
+ const scripts = [],
23
+ anyScripts = []
24
+ allScripts[name] = scripts
25
+ allAnyScripts[name] = anyScripts
26
+ users.add(name)
27
+ for (const child of await readDirectoryWithStats(resolve(sourceDirectory, name)))
28
+ child.stats.isFile() &&
29
+ (child.name.endsWith(".ts")
30
+ ? name.endsWith(".d.ts") || scripts.push(basename(child.name, ".ts"))
31
+ : child.name.endsWith(".js") && anyScripts.push(basename(child.name, ".js")))
32
+ }
33
+ })
32
34
  )
33
35
  sourceDirectory = PathPosix.resolve(sourceDirectory)
34
36
  let o = ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hackmud-script-manager",
3
- "version": "0.21.1-583d190",
3
+ "version": "0.21.1-6d6aa5b",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",
@@ -23,7 +23,8 @@
23
23
  "author": "Samual Norman <me@samual.uk> (https://samual.uk/)",
24
24
  "contributors": [
25
25
  "Daniel Swann (https://github.com/danswann)",
26
- "Longboyy"
26
+ "Longboyy",
27
+ "Helloman892"
27
28
  ],
28
29
  "main": "index.js",
29
30
  "repository": {
@@ -210,7 +210,8 @@ async function processScript(
210
210
  {
211
211
  name: "hackmud-script-manager",
212
212
  async transform(code, id) {
213
- if (!id.includes("/node_modules/")) return (await preprocess(code, { uniqueId })).code
213
+ if (id.startsWith("/") && !id.includes("/node_modules/"))
214
+ return (await preprocess(code, { uniqueId })).code
214
215
  let program
215
216
  traverse(parse(code, { sourceType: "module" }), {
216
217
  Program(path) {
@@ -221,10 +222,10 @@ async function processScript(
221
222
  for (const referencePath of getReferencePathsToGlobal("JSON", program))
222
223
  "MemberExpression" == referencePath.parentPath.node.type &&
223
224
  "Identifier" == referencePath.parentPath.node.property.type &&
224
- ("parse" == referencePath.parentPath.node.property.name ?
225
- (referencePath.parentPath.node.property.name = "oparse")
226
- : "stringify" == referencePath.parentPath.node.property.name &&
227
- (referencePath.parentPath.node.property.name = "ostringify"))
225
+ ("parse" == referencePath.parentPath.node.property.name
226
+ ? (referencePath.parentPath.node.property.name = "oparse")
227
+ : "stringify" == referencePath.parentPath.node.property.name &&
228
+ (referencePath.parentPath.node.property.name = "ostringify"))
228
229
  return generate(program.node).code
229
230
  }
230
231
  },
@@ -359,12 +359,9 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
359
359
  }
360
360
  if (1 == forceQuineCheats) return code
361
361
  assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:485:43")
362
- return (
363
- countHackmudCharacters(scriptBeforeJSONValueReplacement) <=
364
- countHackmudCharacters(code) + Number(hasComment)
365
- ) ?
366
- scriptBeforeJSONValueReplacement
367
- : code
362
+ return countHackmudCharacters(scriptBeforeJSONValueReplacement) <= countHackmudCharacters(code) + Number(hasComment)
363
+ ? scriptBeforeJSONValueReplacement
364
+ : code
368
365
  }
369
366
  function parseObjectExpression(node, o) {
370
367
  if (!node.properties.length) return !1
@@ -80,14 +80,14 @@ async function preprocess(code, { uniqueId = "00000000000" } = {}) {
80
80
  ;(needRecord || needTuple) &&
81
81
  file.program.body.unshift(
82
82
  t.importDeclaration(
83
- needRecord ?
84
- needTuple ?
85
- [
86
- t.importSpecifier(t.identifier("Record"), t.identifier("Record")),
87
- t.importSpecifier(t.identifier("Tuple"), t.identifier("Tuple"))
88
- ]
89
- : [t.importSpecifier(t.identifier("Record"), t.identifier("Record"))]
90
- : [t.importSpecifier(t.identifier("Tuple"), t.identifier("Tuple"))],
83
+ needRecord
84
+ ? needTuple
85
+ ? [
86
+ t.importSpecifier(t.identifier("Record"), t.identifier("Record")),
87
+ t.importSpecifier(t.identifier("Tuple"), t.identifier("Tuple"))
88
+ ]
89
+ : [t.importSpecifier(t.identifier("Record"), t.identifier("Record"))]
90
+ : [t.importSpecifier(t.identifier("Tuple"), t.identifier("Tuple"))],
91
91
  t.stringLiteral("@bloomberg/record-tuple-polyfill")
92
92
  )
93
93
  )
@@ -253,29 +253,29 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
253
253
  mainFunction = t.functionDeclaration(
254
254
  t.identifier(topFunctionName),
255
255
  declarator.init.params,
256
- "BlockStatement" == declarator.init.body.type ?
257
- declarator.init.body
258
- : t.blockStatement([t.returnStatement(declarator.init.body)])
256
+ "BlockStatement" == declarator.init.body.type
257
+ ? declarator.init.body
258
+ : t.blockStatement([t.returnStatement(declarator.init.body)])
259
259
  )
260
260
  else
261
- "FunctionDeclaration" == statement.type ?
262
- statement.id.name == exportDefaultName ?
263
- (mainFunction = statement)
264
- : globalBlock.body.push(
265
- t.variableDeclaration("let", [
266
- t.variableDeclarator(
267
- statement.id,
268
- t.functionExpression(
269
- void 0,
270
- statement.params,
271
- statement.body,
272
- statement.generator,
273
- statement.async
261
+ "FunctionDeclaration" == statement.type
262
+ ? statement.id.name == exportDefaultName
263
+ ? (mainFunction = statement)
264
+ : globalBlock.body.push(
265
+ t.variableDeclaration("let", [
266
+ t.variableDeclarator(
267
+ statement.id,
268
+ t.functionExpression(
269
+ void 0,
270
+ statement.params,
271
+ statement.body,
272
+ statement.generator,
273
+ statement.async
274
+ )
274
275
  )
275
- )
276
- ])
277
- )
278
- : globalBlock.body.push(statement)
276
+ ])
277
+ )
278
+ : globalBlock.body.push(statement)
279
279
  mainFunction ||= t.functionDeclaration(
280
280
  t.identifier(topFunctionName),
281
281
  [t.identifier("context"), t.identifier("args")],
@@ -515,9 +515,11 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
515
515
  "let",
516
516
  [...neededDbMethodLets].map(name => {
517
517
  const getArgs = () =>
518
- "ObjectId" == name ? []
519
- : "i" == name || "r" == name ? [t.identifier("a")]
520
- : [t.identifier("a"), t.identifier("b")]
518
+ "ObjectId" == name
519
+ ? []
520
+ : "i" == name || "r" == name
521
+ ? [t.identifier("a")]
522
+ : [t.identifier("a"), t.identifier("b")]
521
523
  return t.variableDeclarator(
522
524
  t.identifier(`_${uniqueId}_CONSOLE_METHOD_${name}_`),
523
525
  t.arrowFunctionExpression(
@@ -663,9 +665,9 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
663
665
  const bigIntAsNumber = Number(path.node.value)
664
666
  path.replaceWith(
665
667
  t.callExpression(t.identifier("BigInt"), [
666
- BigInt(bigIntAsNumber) == BigInt(path.node.value) ?
667
- t.numericLiteral(bigIntAsNumber)
668
- : t.stringLiteral(path.node.value)
668
+ BigInt(bigIntAsNumber) == BigInt(path.node.value)
669
+ ? t.numericLiteral(bigIntAsNumber)
670
+ : t.stringLiteral(path.node.value)
669
671
  ])
670
672
  )
671
673
  }
package/push.js CHANGED
@@ -70,7 +70,9 @@ async function push(
70
70
  ])
71
71
  if (sourceFolder instanceof Error) return sourceFolder
72
72
  if (hackmudFolder instanceof Error) return hackmudFolder
73
- const sourceFolderFolders = sourceFolder.filter(({ stats }) => stats.isDirectory()),
73
+ const sourceFolderFolders = sourceFolder.filter(
74
+ ({ name, stats }) => stats.isDirectory() && /^[a-z_][a-z\d_]{0,24}$/.test(name)
75
+ ),
74
76
  allUsers = new Set([
75
77
  ...scripts
76
78
  .map(scriptName => ensure(scriptName.split(".")[0], "src/push.ts:85:65"))
package/watch.js CHANGED
@@ -68,12 +68,13 @@ async function watch(
68
68
  let pushEverything = !1
69
69
  for (const fullScriptName of scripts) {
70
70
  const [user, scriptName] = fullScriptName.split(".")
71
- user && "*" != user ?
72
- scriptName && "*" != scriptName ?
73
- scriptNamesToUsers.get(scriptName).add(user)
74
- : wildScriptUsers.add(user)
75
- : scriptName && "*" != scriptName ? wildUserScripts.add(scriptName)
76
- : (pushEverything = !0)
71
+ user && "*" != user
72
+ ? scriptName && "*" != scriptName
73
+ ? scriptNamesToUsers.get(scriptName).add(user)
74
+ : wildScriptUsers.add(user)
75
+ : scriptName && "*" != scriptName
76
+ ? wildUserScripts.add(scriptName)
77
+ : (pushEverything = !0)
77
78
  }
78
79
  const watcher = watch$1(".", {
79
80
  cwd: sourceDirectory,
@@ -112,9 +113,9 @@ async function watch(
112
113
  for (const { stats, name } of await readDirectoryWithStats(sourceDirectory))
113
114
  stats.isDirectory() && usersToPushToSet.add(name)
114
115
  for (const { stats, name } of await readDirectoryWithStats(hackmudDirectory))
115
- stats.isDirectory() ?
116
- usersToPushToSet.add(name)
117
- : stats.isFile() && name.endsWith(".key") && usersToPushToSet.add(name.slice(0, -4))
116
+ stats.isDirectory()
117
+ ? usersToPushToSet.add(name)
118
+ : stats.isFile() && name.endsWith(".key") && usersToPushToSet.add(name.slice(0, -4))
118
119
  for (const users of scriptNamesToUsers.values()) for (const user of users) usersToPushToSet.add(user)
119
120
  }
120
121
  for (const user of wildScriptUsers) usersToPushToSet.add(user)
@@ -132,10 +133,19 @@ async function watch(
132
133
  try {
133
134
  ;({ script: minifiedCode, warnings } = await processScript(
134
135
  await readFile(filePath, { encoding: "utf8" }),
135
- { minify, scriptUser: !0, scriptName, uniqueId, filePath, mangleNames, forceQuineCheats }
136
+ {
137
+ minify,
138
+ scriptUser: !0,
139
+ scriptName,
140
+ uniqueId,
141
+ filePath,
142
+ mangleNames,
143
+ forceQuineCheats,
144
+ rootFolderPath
145
+ }
136
146
  ))
137
147
  } catch (error) {
138
- assert(error instanceof Error, "src/watch.ts:151:36")
148
+ assert(error instanceof Error, "src/watch.ts:160:36")
139
149
  onPush?.({ path, users: [], characterCount: 0, error, warnings: [] })
140
150
  return
141
151
  }
@@ -183,7 +193,7 @@ async function watch(
183
193
  rootFolderPath
184
194
  }))
185
195
  } catch (error) {
186
- assert(error instanceof Error, "src/watch.ts:198:35")
196
+ assert(error instanceof Error, "src/watch.ts:207:35")
187
197
  onPush?.({ path, users: [], characterCount: 0, error, warnings: [] })
188
198
  return
189
199
  }
@@ -198,7 +208,7 @@ async function watch(
198
208
  try {
199
209
  await writeFile(typeDeclarationPath, typeDeclaration)
200
210
  } catch (error) {
201
- assert(error instanceof Error, "src/watch.ts:231:35")
211
+ assert(error instanceof Error, "src/watch.ts:240:35")
202
212
  if ("EISDIR" != error.code) throw error
203
213
  typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
204
214
  await writeFile(typeDeclarationPath, typeDeclaration)