hackmud-script-manager 0.21.1-f88f20e → 0.21.1
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 -3
- package/bin/hsm.js +31 -21
- package/env.d.ts +8 -7
- 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 +8 -8
- package/processScript/transform.js +28 -26
- package/push.js +3 -1
- package/watch.js +23 -13
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
|
> ```
|
@@ -60,8 +60,6 @@ You can read about how HSM works [in my blog post](https://samual.uk/blog/js-cod
|
|
60
60
|
- Subscript and `#db` methods names are verified.
|
61
61
|
- All references to preprocessor syntax functions not being called are turned into arrow function wrappers e.g. `let debug = #D;` -> `let debug = v => #D(v);`.
|
62
62
|
- `_SECLEVEL` is replaced with a number (`0` to `4`) representing the seclevel of the script.
|
63
|
-
- When `export`s are present in the script, it becomes a script that returns an object of the `export`ed values.
|
64
|
-
- `_EXPORTS` becomes an array of the names of the exported values.
|
65
63
|
- And Neat Weird Fixes
|
66
64
|
- Like `.__proto__` and `.prototype` being converted to `["__proto__"]` and `["prototype"]`.
|
67
65
|
- Illegal and unsafe strings.
|
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")
|
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")}\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
@@ -1,4 +1,4 @@
|
|
1
|
-
type Replace<A, B> = Omit<A, keyof B> &
|
1
|
+
type Replace<A, B> = Omit<A, keyof B> & B
|
2
2
|
type ErrorScripts = Record<string, () => ScriptFailure>
|
3
3
|
|
4
4
|
type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
|
@@ -703,7 +703,7 @@ type MongoObject = { [k: string]: MongoValue, [k: `$${string}`]: never }
|
|
703
703
|
type MongoQueryValue = MongoPrimitive | MongoQueryValue[] | MongoQueryObject
|
704
704
|
|
705
705
|
type MongoQueryObject =
|
706
|
-
{ [k: string]: MongoQueryValue, [k: `$${string}`]: MongoValue
|
706
|
+
{ [k: string]: MongoQueryValue, [k: `$${string}`]: MongoValue } & { $type?: keyof MongoTypeStringsToTypes | (string & {}) }
|
707
707
|
|
708
708
|
type MongoTypeStringsToTypes = {
|
709
709
|
double: number
|
@@ -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> | ObjectId | MongoObject
|
724
|
+
type MongoQueryId = Exclude<MongoPrimitive, null | false> | ObjectId | MongoQueryObject
|
725
725
|
type MongoDocument = MongoObject & { _id?: MongoId }
|
726
726
|
|
727
727
|
type MongoQueryType<TQuery extends MongoQueryObject> = {
|
@@ -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
|
|
@@ -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
|
@@ -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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
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/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(
|
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
|
-
|
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)
|
@@ -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
|
-
{
|
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:
|
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:
|
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:
|
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)
|