hackmud-script-manager 0.21.1-583d190 → 0.21.1-8ea4b63
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 +1 -1
- package/bin/hsm.js +31 -21
- package/env.d.ts +9 -8
- package/generateTypeDeclaration.js +6 -6
- package/package.json +1 -1
- package/processScript/index.js +4 -4
- package/processScript/minify.js +3 -6
- package/processScript/preprocess.js +23 -11
- package/processScript/transform.js +28 -26
- package/watch.js +10 -9
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
|
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-
|
67
|
+
console.log("0.21.1-8ea4b63")
|
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
|
-
|
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
|
-
|
136
|
-
|
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
|
145
|
-
|
146
|
-
|
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
|
-
|
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:
|
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:
|
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
|
-
|
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-
|
415
|
+
`${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-8ea4b63")}\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
@@ -710,7 +710,7 @@ type MongoTypeStringsToTypes = {
|
|
710
710
|
string: string
|
711
711
|
object: MongoObject
|
712
712
|
array: MongoValue[]
|
713
|
-
objectId:
|
713
|
+
objectId: MongoObjectId
|
714
714
|
bool: boolean
|
715
715
|
date: Date
|
716
716
|
null: null
|
@@ -720,7 +720,7 @@ 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
|
723
|
+
type MongoId = Exclude<MongoPrimitive, null> | MongoObjectId | MongoObject
|
724
724
|
type MongoQueryId = Exclude<MongoPrimitive, null> | MongoQueryObject
|
725
725
|
type MongoDocument = MongoObject & { _id?: MongoId }
|
726
726
|
|
@@ -865,8 +865,8 @@ type BrainContext = Replace<CliContext, { /** Whether the script is being run vi
|
|
865
865
|
// when anyField: true is given, other fields (except _id) are omitted
|
866
866
|
|
867
867
|
type MongoProject<TDocument, TProjection> =
|
868
|
-
|
869
|
-
|
868
|
+
(TProjection extends { _id: false | 0 } ? {} : { _id: TDocument extends { _id: infer TId } ? TId : MongoId }) & (
|
869
|
+
true extends (1 extends TProjection[keyof TProjection] ? true : TProjection[keyof TProjection]) ?
|
870
870
|
{
|
871
871
|
[K in
|
872
872
|
keyof TDocument as K extends keyof TProjection ? TProjection[K] extends true | 1 ? K : never : never
|
@@ -877,7 +877,8 @@ type MongoProject<TDocument, TProjection> =
|
|
877
877
|
keyof TProjection as TProjection[K] extends true | 1 ? K extends keyof TDocument ? never : K : never
|
878
878
|
]?: MongoValue
|
879
879
|
}
|
880
|
-
|
880
|
+
: { [k: string]: MongoValue } & { [K in keyof TDocument as K extends keyof TProjection ? never : K]: TDocument[K] }
|
881
|
+
)
|
881
882
|
|
882
883
|
type DeepFreeze<T> = { readonly [P in keyof T]: DeepFreeze<T[P]> }
|
883
884
|
|
@@ -885,9 +886,9 @@ declare global {
|
|
885
886
|
type ScriptSuccess<T = unknown> = { ok: true } & T
|
886
887
|
type ScriptFailure = { ok: false, msg?: string }
|
887
888
|
type ScriptResponse<T = unknown> = ScriptSuccess<T> | ScriptFailure
|
888
|
-
type Scriptor<TArgs
|
889
|
+
type Scriptor<TArgs = any> = { name: string, call: (args: TArgs) => unknown }
|
889
890
|
type Context = CliContext | SubscriptContext | ScriptorContext | BrainContext
|
890
|
-
type
|
891
|
+
type MongoObjectId = { $oid: string }
|
891
892
|
|
892
893
|
interface PlayerFullsec {}
|
893
894
|
interface PlayerHighsec {}
|
@@ -978,7 +979,7 @@ declare global {
|
|
978
979
|
us: <T extends MongoDocument>(query: MongoQuery<T> | MongoQuery<T>[], command: MongoUpdateCommand<T>) =>
|
979
980
|
{ n: number, ok: 0 | 1, opTime: { t: number }, nModified: number }[]
|
980
981
|
|
981
|
-
ObjectId: () =>
|
982
|
+
ObjectId: () => MongoObjectId
|
982
983
|
}
|
983
984
|
|
984
985
|
/** Debug Log.
|
@@ -13,9 +13,9 @@ async function generateTypeDeclaration(sourceDirectory, hackmudPath) {
|
|
13
13
|
await Promise.all(
|
14
14
|
(await readDirectoryWithStats(sourceDirectory)).map(async ({ stats, name }) => {
|
15
15
|
if (stats.isFile())
|
16
|
-
name.endsWith(".ts")
|
17
|
-
name.endsWith(".d.ts") || wildScripts.push(basename(name, ".ts"))
|
18
|
-
|
16
|
+
name.endsWith(".ts")
|
17
|
+
? name.endsWith(".d.ts") || wildScripts.push(basename(name, ".ts"))
|
18
|
+
: name.endsWith(".js") && wildAnyScripts.push(basename(name, ".js"))
|
19
19
|
else if (stats.isDirectory()) {
|
20
20
|
const scripts = [],
|
21
21
|
anyScripts = []
|
@@ -24,9 +24,9 @@ async function generateTypeDeclaration(sourceDirectory, hackmudPath) {
|
|
24
24
|
users.add(name)
|
25
25
|
for (const child of await readDirectoryWithStats(resolve(sourceDirectory, name)))
|
26
26
|
child.stats.isFile() &&
|
27
|
-
(child.name.endsWith(".ts")
|
28
|
-
name.endsWith(".d.ts") || scripts.push(basename(child.name, ".ts"))
|
29
|
-
|
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
30
|
}
|
31
31
|
})
|
32
32
|
)
|
package/package.json
CHANGED
package/processScript/index.js
CHANGED
@@ -221,10 +221,10 @@ async function processScript(
|
|
221
221
|
for (const referencePath of getReferencePathsToGlobal("JSON", program))
|
222
222
|
"MemberExpression" == referencePath.parentPath.node.type &&
|
223
223
|
"Identifier" == referencePath.parentPath.node.property.type &&
|
224
|
-
("parse" == referencePath.parentPath.node.property.name
|
225
|
-
(referencePath.parentPath.node.property.name = "oparse")
|
226
|
-
|
227
|
-
|
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"))
|
228
228
|
return generate(program.node).code
|
229
229
|
}
|
230
230
|
},
|
package/processScript/minify.js
CHANGED
@@ -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
|
-
|
364
|
-
|
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
|
@@ -4,11 +4,23 @@ import babelTraverse from "@babel/traverse"
|
|
4
4
|
import t from "@babel/types"
|
5
5
|
import { assert } from "@samual/lib/assert"
|
6
6
|
import { spliceString } from "@samual/lib/spliceString"
|
7
|
+
import { tokenizer, tokTypes } from "acorn"
|
7
8
|
import { resolve } from "import-meta-resolve"
|
8
9
|
const { default: traverse } = babelTraverse,
|
9
|
-
{ default: generate } = babelGenerator
|
10
|
+
{ default: generate } = babelGenerator,
|
11
|
+
SUBSCRIPT_PREFIXES = ["s", "fs", "4s", "hs", "3s", "ms", "2s", "ls", "1s", "ns", "0s"]
|
10
12
|
async function preprocess(code, { uniqueId = "00000000000" } = {}) {
|
11
|
-
assert(/^\w{11}$/.test(uniqueId), "src/processScript/preprocess.ts:
|
13
|
+
assert(/^\w{11}$/.test(uniqueId), "src/processScript/preprocess.ts:26:36")
|
14
|
+
const tokensIterable = tokenizer(code, { ecmaVersion: "latest" })
|
15
|
+
for (const token of tokensIterable) {
|
16
|
+
assert("value" in token, "src/processScript/preprocess.ts:31:28")
|
17
|
+
if (token.type != tokTypes.privateId) continue
|
18
|
+
assert("string" == typeof token.value, "src/processScript/preprocess.ts:36:42")
|
19
|
+
if (!SUBSCRIPT_PREFIXES.includes(token.value)) continue
|
20
|
+
const nextToken = tokensIterable.getToken()
|
21
|
+
if (nextToken.type != tokTypes._in && nextToken.type != tokTypes.dot)
|
22
|
+
throw SyntaxError("Subscripts must be in the form of #fs.foo.bar")
|
23
|
+
}
|
12
24
|
const sourceCode = code
|
13
25
|
let lengthBefore, file, program
|
14
26
|
do {
|
@@ -47,7 +59,7 @@ async function preprocess(code, { uniqueId = "00000000000" } = {}) {
|
|
47
59
|
})
|
48
60
|
break
|
49
61
|
} catch (error_) {
|
50
|
-
assert(error_ instanceof SyntaxError, "src/processScript/preprocess.ts:
|
62
|
+
assert(error_ instanceof SyntaxError, "src/processScript/preprocess.ts:89:42")
|
51
63
|
error = error_
|
52
64
|
}
|
53
65
|
if ("BABEL_PARSER_SYNTAX_ERROR" != error.code || "PrivateInExpectedIn" != error.reasonCode) {
|
@@ -80,14 +92,14 @@ async function preprocess(code, { uniqueId = "00000000000" } = {}) {
|
|
80
92
|
;(needRecord || needTuple) &&
|
81
93
|
file.program.body.unshift(
|
82
94
|
t.importDeclaration(
|
83
|
-
needRecord
|
84
|
-
needTuple
|
85
|
-
[
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
95
|
+
needRecord
|
96
|
+
? needTuple
|
97
|
+
? [
|
98
|
+
t.importSpecifier(t.identifier("Record"), t.identifier("Record")),
|
99
|
+
t.importSpecifier(t.identifier("Tuple"), t.identifier("Tuple"))
|
100
|
+
]
|
101
|
+
: [t.importSpecifier(t.identifier("Record"), t.identifier("Record"))]
|
102
|
+
: [t.importSpecifier(t.identifier("Tuple"), t.identifier("Tuple"))],
|
91
103
|
t.stringLiteral("@bloomberg/record-tuple-polyfill")
|
92
104
|
)
|
93
105
|
)
|
@@ -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
|
-
|
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
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
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
|
-
|
520
|
-
|
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
|
-
|
668
|
+
BigInt(bigIntAsNumber) == BigInt(path.node.value)
|
669
|
+
? t.numericLiteral(bigIntAsNumber)
|
670
|
+
: t.stringLiteral(path.node.value)
|
669
671
|
])
|
670
672
|
)
|
671
673
|
}
|
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
|
-
|
75
|
-
|
76
|
-
|
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
|
-
|
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)
|