hackmud-script-manager 0.20.4-769c77c → 0.20.4-7c74974
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 +16 -7
- package/env.d.ts +709 -1293
- package/package.json +6 -2
- package/processScript/minify.js +11 -8
- package/processScript/transform.js +8 -6
- package/push.d.ts +9 -1
- package/push.js +33 -11
- package/syncMacros.js +1 -1
package/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Hackmud Script Manager
|
2
|
-
Command made for [
|
2
|
+
Command made for [Hackmud Scripting Environment](https://github.com/samualtnorman/hackmud-environment), which is a scripting environment for hackmud with minification, autocompletes / intellisense, and TypeScript support.
|
3
3
|
|
4
4
|
[](https://ko-fi.com/R6R0XN5CX)
|
5
5
|
|
package/bin/hsm.js
CHANGED
@@ -12,7 +12,7 @@ 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 version = "0.20.4-
|
15
|
+
const version = "0.20.4-7c74974",
|
16
16
|
options = new Map(),
|
17
17
|
commands = [],
|
18
18
|
userColours = new Cache(user => {
|
@@ -119,16 +119,25 @@ switch (commands[0]) {
|
|
119
119
|
logHelp()
|
120
120
|
break
|
121
121
|
}
|
122
|
-
const { push } = await pushModule
|
123
|
-
|
124
|
-
await push(sourcePath, hackmudPath, {
|
122
|
+
const { push, MissingSourceFolderError, MissingHackmudFolderError, NoUsersError } = await pushModule,
|
123
|
+
infos = await push(sourcePath, hackmudPath, {
|
125
124
|
scripts,
|
126
125
|
onPush: info => logInfo(info, hackmudPath),
|
127
126
|
minify: shouldMinify,
|
128
127
|
mangleNames: shouldMangleNames,
|
129
128
|
forceQuineCheats: shouldforceQuineCheats
|
130
129
|
})
|
131
|
-
|
130
|
+
if (infos instanceof Error) {
|
131
|
+
logError(infos.message)
|
132
|
+
if (infos instanceof MissingSourceFolderError || infos instanceof NoUsersError) {
|
133
|
+
console.log()
|
134
|
+
logHelp()
|
135
|
+
} else
|
136
|
+
infos instanceof MissingHackmudFolderError &&
|
137
|
+
log(
|
138
|
+
`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`
|
139
|
+
)
|
140
|
+
} else infos.length || logError("Could not find any scripts to push")
|
132
141
|
}
|
133
142
|
break
|
134
143
|
case "dev":
|
@@ -245,7 +254,7 @@ switch (commands[0]) {
|
|
245
254
|
typeDeclaration = await generateTypeDeclaration(sourcePath, getHackmudPath())
|
246
255
|
let typeDeclarationPath = resolve(outputPath)
|
247
256
|
await writeFile(typeDeclarationPath, typeDeclaration).catch(error => {
|
248
|
-
assert(error instanceof Error, "src/bin/hsm.ts:
|
257
|
+
assert(error instanceof Error, "src/bin/hsm.ts:340:35")
|
249
258
|
if ("EISDIR" != error.code) throw error
|
250
259
|
typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
|
251
260
|
return writeFile(typeDeclarationPath, typeDeclaration)
|
@@ -366,7 +375,7 @@ function logHelp() {
|
|
366
375
|
case "push":
|
367
376
|
console.log(
|
368
377
|
colourS(
|
369
|
-
`\n${colourJ("push" == commands[0] ? pushCommandDescription : "Watch a directory and push a script when modified")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB('<directory> ["<script user>.<script name>"...]')}\n\n${colourA("Arguments:")}\n${colourB("<directory>")}\n The source directory containing your scripts\n${colourB("<script user>")}\n A user to push script(s) to. Can be set to wild card (${colourV("*")}) which will try\n and discover users to push to\n${colourB("<script name>")}\n Name of a script to push. Can be set to wild card (${colourV("*")}) to find all scripts\n\n${colourA("Options:")}\n${colourN("--no-minify")}\n Skip minification to produce a "readable" script\n${colourN("--mangle-names")}\n Reduce character count further but lose function names in error call stacks\n${colourN("--force-quine-cheats")}\n ${forceQuineCheatsOptionDescription}\n${hackmudPathOption}\n${"push" == commands[0] ? "" : `${colourN("--type-declaration-path")}=${colourB("<path>")}\n Path to generate a type declaration file for the scripts\n`}\n${colourA("Examples:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")}\n
|
378
|
+
`\n${colourJ("push" == commands[0] ? pushCommandDescription : "Watch a directory and push a script when modified")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB('<directory> ["<script user>.<script name>"...]')}\n\n${colourA("Arguments:")}\n${colourB("<directory>")}\n The source directory containing your scripts\n${colourB("<script user>")}\n A user to push script(s) to. Can be set to wild card (${colourV("*")}) which will try\n and discover users to push to\n${colourB("<script name>")}\n Name of a script to push. Can be set to wild card (${colourV("*")}) to find all scripts\n\n${colourA("Options:")}\n${colourN("--no-minify")}\n Skip minification to produce a "readable" script\n${colourN("--mangle-names")}\n Reduce character count further but lose function names in error call stacks\n${colourN("--force-quine-cheats")}\n ${forceQuineCheatsOptionDescription}\n${hackmudPathOption}\n${"push" == commands[0] ? "" : `${colourN("--type-declaration-path")}=${colourB("<path>")}\n Path to generate a type declaration file for the scripts\n`}\n${colourA("Examples:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")}\n Pushes all scripts found in ${colourV("src")} folder to all users\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("bar")}\n Pushes a script named ${colourL("bar")} found in ${colourV("src")} folder to user ${userColours.get("foo")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("bar")} ${colourC("baz")}${colourV(".")}${colourL("qux")}\n Multiple can be specified\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("*")}\n Pushes all scripts found in ${colourV("src")} folder to user ${userColours.get("foo")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("*")}${colourV(".")}${colourL("foo")}\n Pushes all scripts named ${colourL("foo")} found in ${colourV("src")} folder to all user\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("*")}${colourV(".")}${colourL("*")}\n Pushes all scripts found in ${colourV("src")} folder to all users`
|
370
379
|
)
|
371
380
|
)
|
372
381
|
break
|