hackmud-script-manager 0.20.4-9596502 → 0.20.4-abe4703
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/hsm.js +6 -7
- package/env.d.ts +20 -52
- package/package.json +1 -1
- package/push.d.ts +1 -5
- package/push.js +8 -22
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-abe4703",
|
16
16
|
options = new Map(),
|
17
17
|
commands = [],
|
18
18
|
userColours = new Cache(user => {
|
@@ -119,17 +119,16 @@ switch (commands[0]) {
|
|
119
119
|
logHelp()
|
120
120
|
break
|
121
121
|
}
|
122
|
-
const { push } = await pushModule
|
123
|
-
|
122
|
+
const { push } = await pushModule
|
123
|
+
;(
|
124
|
+
await push(sourcePath, hackmudPath, {
|
124
125
|
scripts,
|
125
126
|
onPush: info => logInfo(info, hackmudPath),
|
126
127
|
minify: shouldMinify,
|
127
128
|
mangleNames: shouldMangleNames,
|
128
129
|
forceQuineCheats: shouldforceQuineCheats
|
129
130
|
})
|
130
|
-
|
131
|
-
logError(infos.message)
|
132
|
-
: infos.length || logError("Could not find any scripts to push")
|
131
|
+
).length || logError("Could not find any scripts to push")
|
133
132
|
}
|
134
133
|
break
|
135
134
|
case "dev":
|
@@ -246,7 +245,7 @@ switch (commands[0]) {
|
|
246
245
|
typeDeclaration = await generateTypeDeclaration(sourcePath, getHackmudPath())
|
247
246
|
let typeDeclarationPath = resolve(outputPath)
|
248
247
|
await writeFile(typeDeclarationPath, typeDeclaration).catch(error => {
|
249
|
-
assert(error instanceof Error, "src/bin/hsm.ts:
|
248
|
+
assert(error instanceof Error, "src/bin/hsm.ts:327:35")
|
250
249
|
if ("EISDIR" != error.code) throw error
|
251
250
|
typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
|
252
251
|
return writeFile(typeDeclarationPath, typeDeclaration)
|
package/env.d.ts
CHANGED
@@ -4,13 +4,6 @@ type ScriptFailure = { ok: false, msg?: string }
|
|
4
4
|
type ScriptResponse<T = object> = ScriptSuccess<T> | ScriptFailure
|
5
5
|
type ErrorScripts = Record<string, () => ScriptFailure>
|
6
6
|
|
7
|
-
type AllOptional<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? true : false }[keyof T]
|
8
|
-
|
9
|
-
type Scriptor<Args = unknown, Ret = unknown> = {
|
10
|
-
name: string
|
11
|
-
call: AllOptional<Args> extends true ? (args?: Args) => Ret : (args: Args) => Ret
|
12
|
-
}
|
13
|
-
|
14
7
|
type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
|
15
8
|
accts: ErrorScripts
|
16
9
|
autos: ErrorScripts
|
@@ -33,27 +26,23 @@ interface PlayerMidsec {}
|
|
33
26
|
interface PlayerLowsec {}
|
34
27
|
interface PlayerNullsec {}
|
35
28
|
|
36
|
-
type
|
37
|
-
type UpgradeRarityNumber = 0 | 1 | 2 | 3 | 4 | 5;
|
38
|
-
type UpgradeRarity = UpgradeRarityString | UpgradeRarityNumber;
|
39
|
-
|
40
|
-
type UpgradeBase = {
|
29
|
+
type UpgradeCore = {
|
41
30
|
name: string
|
42
31
|
type: "lock" | "script_space" | "chat" | "script" | "tool" | "bot_brain" | "glam"
|
43
32
|
up_class?: -1 | 0 | 1 | 2 | 3
|
44
33
|
tier: 1 | 2 | 3 | 4
|
45
|
-
rarity:
|
34
|
+
rarity: 0 | 1 | 2 | 3 | 4 | 5
|
46
35
|
i: number
|
47
36
|
loaded: boolean
|
48
37
|
sn: string
|
49
38
|
description: string
|
50
39
|
}
|
51
40
|
|
52
|
-
type Upgrade =
|
41
|
+
type Upgrade = UpgradeCore & Record<string, null | boolean | number | string>
|
53
42
|
|
54
|
-
type
|
43
|
+
type CLIUpgrade = Omit<UpgradeCore, `rarity`> & {
|
55
44
|
[x: string]: null | boolean | number | string
|
56
|
-
rarity:
|
45
|
+
rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
|
57
46
|
}
|
58
47
|
|
59
48
|
type UsersTopItem<R> = { rank: R, name: string, last_activity: string, balance: string }
|
@@ -151,7 +140,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
151
140
|
market: {
|
152
141
|
/** **FULLSEC** */ browse: {
|
153
142
|
(args:
|
154
|
-
Partial<{ seller: string, listed_before: number, listed_after: number, cost: number | string } & Omit<
|
143
|
+
Partial<{ seller: string, listed_before: number, listed_after: number, cost: number | string } & Omit<CLIUpgrade, "rarity">>
|
155
144
|
): { i: string, name: string, rarity: Upgrade["rarity"], cost: number }[] | ScriptFailure
|
156
145
|
|
157
146
|
<I extends string>(args: { i: I }): {
|
@@ -420,17 +409,17 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
420
409
|
upgrades_of_owner: {
|
421
410
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: { filter?: F, full?: false }): (
|
422
411
|
Omit<
|
423
|
-
Pick<
|
412
|
+
Pick<UpgradeCore, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
|
424
413
|
keyof F
|
425
414
|
> & Pick<F, "tier" | "rarity" | "name" | "type" | "i" | "loaded">
|
426
415
|
)[] | ScriptFailure
|
427
416
|
|
428
417
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args: { filter?: F, full: true }): (
|
429
|
-
Omit<
|
418
|
+
Omit<UpgradeCore, keyof F> & F & Record<string, null | boolean | number | string>
|
430
419
|
)[] | ScriptFailure
|
431
420
|
|
432
421
|
<I extends number>(args: { i: I }): (
|
433
|
-
Omit<
|
422
|
+
Omit<UpgradeCore, "i"> & { [x: string]: null | boolean | number | string, i: I }
|
434
423
|
) | ScriptFailure
|
435
424
|
}
|
436
425
|
|
@@ -507,7 +496,7 @@ type Highsec = Fullsec & PlayerHighsec & {
|
|
507
496
|
/** **HIGHSEC** */
|
508
497
|
upgrades: {
|
509
498
|
<I extends number>(args: { i: I }): (
|
510
|
-
Omit<
|
499
|
+
Omit<UpgradeCore, "i"> & { [x: string]: null | boolean | number | string, i: I }
|
511
500
|
) | ScriptFailure
|
512
501
|
|
513
502
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: {
|
@@ -515,22 +504,22 @@ type Highsec = Fullsec & PlayerHighsec & {
|
|
515
504
|
is_script?: true
|
516
505
|
full?: false
|
517
506
|
}): (
|
518
|
-
Omit<Pick<
|
507
|
+
Omit<Pick<UpgradeCore, "tier" | "rarity" | "name" | "type" | "i" | "loaded">, keyof F> & F &
|
519
508
|
Record<string, null | boolean | number | string>
|
520
509
|
)[] | ScriptFailure
|
521
510
|
|
522
511
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?:
|
523
512
|
{ filter?: F, is_script?: true, full: true }
|
524
|
-
): (Omit<
|
513
|
+
): (Omit<UpgradeCore, keyof F> & F & Record<string, null | boolean | number | string>)[] | ScriptFailure
|
525
514
|
|
526
515
|
(args?: { filter?: Partial<Upgrade & { loaded: boolean }>, is_script: false, full?: false }):
|
527
516
|
{ msg: string, upgrades: string[] } | ScriptFailure
|
528
517
|
|
529
518
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(
|
530
519
|
args?: { filter?: F, is_script: false, full: true }
|
531
|
-
): (Omit<
|
520
|
+
): (Omit<UpgradeCore, keyof F | `rarity`> & F & {
|
532
521
|
[x: string]: null | boolean | number | string
|
533
|
-
rarity:
|
522
|
+
rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
|
534
523
|
})[] | ScriptFailure
|
535
524
|
}
|
536
525
|
}
|
@@ -762,7 +751,7 @@ type Cursor = {
|
|
762
751
|
ObjectId: () => any
|
763
752
|
}
|
764
753
|
|
765
|
-
type
|
754
|
+
type CLIContext = {
|
766
755
|
/** The name of the user who is calling the script. */ caller: string
|
767
756
|
/** The name of this script. */ this_script: string
|
768
757
|
/** The number of columns in the caller’s terminal. */ cols: number
|
@@ -770,23 +759,17 @@ type CliContext = {
|
|
770
759
|
|
771
760
|
/** The name of the script that directly called this script, or null if called on the command line or as a
|
772
761
|
* scriptor. */ calling_script: null
|
773
|
-
is_scriptor?: undefined
|
774
|
-
is_brain?: undefined
|
775
762
|
}
|
776
763
|
|
777
|
-
type SubscriptContext = Replace<
|
764
|
+
type SubscriptContext = Replace<CLIContext, {
|
778
765
|
/** The name of the script that directly called this script, or null if called on the command line or as a scriptor.
|
779
766
|
*/
|
780
767
|
calling_script: string
|
781
768
|
}>
|
782
769
|
|
783
|
-
type ScriptorContext =
|
784
|
-
|
785
|
-
|
786
|
-
type BrainContext =
|
787
|
-
Replace<CliContext, { /** Whether the script is being run via a bot brain. */ is_brain: true }>
|
788
|
-
|
789
|
-
type Context = CliContext | SubscriptContext | ScriptorContext | BrainContext
|
770
|
+
type ScriptorContext = CLIContext & { /** Whether the script is being run as a scriptor. */ is_scriptor: true }
|
771
|
+
type BrainContext = CLIContext & { /** Whether the script is being run via a bot brain. */ is_brain: true }
|
772
|
+
type Context = CLIContext | SubscriptContext | ScriptorContext | BrainContext
|
790
773
|
|
791
774
|
/** Subscript space that can call FULLSEC scripts. */ declare const $fs: Fullsec
|
792
775
|
|
@@ -829,8 +812,6 @@ declare const $0s: typeof $ns
|
|
829
812
|
* } */
|
830
813
|
declare const $s: Nullsec
|
831
814
|
|
832
|
-
type ObjectId = { $oid: string }
|
833
|
-
|
834
815
|
declare const $db: {
|
835
816
|
/** Insert a document or documents into a collection.
|
836
817
|
* @param documents A document or array of documents to insert into the collection. */
|
@@ -924,8 +905,6 @@ declare const $db: {
|
|
924
905
|
signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
|
925
906
|
}
|
926
907
|
}
|
927
|
-
|
928
|
-
ObjectId: () => ObjectId
|
929
908
|
}
|
930
909
|
|
931
910
|
/** Debug Log.
|
@@ -962,7 +941,7 @@ declare const $FMCL: undefined | true
|
|
962
941
|
* @example
|
963
942
|
* if (!$G.dbCache)
|
964
943
|
* $G.dbCache = $db.f({ whatever: true }).first() */
|
965
|
-
declare const $G:
|
944
|
+
declare const $G: any
|
966
945
|
|
967
946
|
/** This contains a JS timestamp (not Date) set immediately before your code begins running.
|
968
947
|
* @example
|
@@ -1011,14 +990,3 @@ declare const _FULL_SCRIPT_NAME: string
|
|
1011
990
|
*
|
1012
991
|
* In rare cases where it's not known at build time, it's `-1`. */
|
1013
992
|
declare const _SECLEVEL: -1 | 0 | 1 | 2 | 3 | 4
|
1014
|
-
|
1015
|
-
type DeepFreeze<T> = { readonly [P in keyof T]: DeepFreeze<T[P]> }
|
1016
|
-
|
1017
|
-
/** Recursively
|
1018
|
-
* [`Object.freeze()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
|
1019
|
-
* an object and its properties' objects and its properties' objects and so on.
|
1020
|
-
*
|
1021
|
-
* [Official Hackmud Wiki](https://wiki.hackmud.com/scripting/extensions/deep_freeze) */
|
1022
|
-
declare const DEEP_FREEZE: <T>(value: T) => DeepFreeze<T>
|
1023
|
-
|
1024
|
-
declare const _RUN_ID: string
|
package/package.json
CHANGED
package/push.d.ts
CHANGED
@@ -18,10 +18,6 @@ export type PushOptions = LaxPartial<{
|
|
18
18
|
*/
|
19
19
|
forceQuineCheats: boolean;
|
20
20
|
}>;
|
21
|
-
export declare class MissingSourceFolderError extends Error {
|
22
|
-
}
|
23
|
-
export declare class MissingHackmudFolderError extends Error {
|
24
|
-
}
|
25
21
|
/** Push scripts from a source directory to the hackmud directory.
|
26
22
|
*
|
27
23
|
* Pushes files directly in the source folder to all users
|
@@ -29,4 +25,4 @@ export declare class MissingHackmudFolderError extends Error {
|
|
29
25
|
* @param hackmudPath directory created by hackmud containing user data including scripts
|
30
26
|
* @param options {@link PushOptions details}
|
31
27
|
* @returns array of info on pushed scripts */
|
32
|
-
export declare function push(sourcePath: string, hackmudPath: string, { scripts, onPush, minify, mangleNames, forceQuineCheats }?: PushOptions): Promise<
|
28
|
+
export declare function push(sourcePath: string, hackmudPath: string, { scripts, onPush, minify, mangleNames, forceQuineCheats }?: PushOptions): Promise<Info[]>;
|
package/push.js
CHANGED
@@ -42,33 +42,19 @@ import "./processScript/preprocess.js"
|
|
42
42
|
import "import-meta-resolve"
|
43
43
|
import "./processScript/transform.js"
|
44
44
|
import "@samual/lib/clearObject"
|
45
|
-
class MissingSourceFolderError extends Error {}
|
46
|
-
Object.defineProperty(MissingSourceFolderError.prototype, "name", { value: "MissingSourceFolderError" })
|
47
|
-
class MissingHackmudFolderError extends Error {}
|
48
|
-
Object.defineProperty(MissingHackmudFolderError.prototype, "name", { value: "MissingHackmudFolderError" })
|
49
45
|
async function push(
|
50
46
|
sourcePath,
|
51
47
|
hackmudPath,
|
52
48
|
{ scripts = ["*.*"], onPush = () => {}, minify = !0, mangleNames = !1, forceQuineCheats } = {}
|
53
49
|
) {
|
54
50
|
const [sourceFolder, hackmudFolder] = await Promise.all([
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
}),
|
60
|
-
readDirectoryWithStats(hackmudPath).catch(error => {
|
61
|
-
if (error && "ENOENT" == error.code)
|
62
|
-
return new MissingHackmudFolderError("There is no folder at " + hackmudPath)
|
63
|
-
throw error
|
64
|
-
})
|
65
|
-
])
|
66
|
-
if (sourceFolder instanceof Error) return sourceFolder
|
67
|
-
if (hackmudFolder instanceof Error) return hackmudFolder
|
68
|
-
const sourceFolderFolders = sourceFolder.filter(({ stats }) => stats.isDirectory()),
|
51
|
+
readDirectoryWithStats(sourcePath),
|
52
|
+
readDirectoryWithStats(hackmudPath)
|
53
|
+
]),
|
54
|
+
sourceFolderFolders = sourceFolder.filter(({ stats }) => stats.isDirectory()),
|
69
55
|
allUsers = new Set([
|
70
56
|
...scripts
|
71
|
-
.map(scriptName => ensure(scriptName.split(".")[0], "src/push.ts:
|
57
|
+
.map(scriptName => ensure(scriptName.split(".")[0], "src/push.ts:52:65"))
|
72
58
|
.filter(name => "*" != name),
|
73
59
|
...sourceFolderFolders.map(({ name }) => name),
|
74
60
|
...hackmudFolder.filter(({ stats }) => stats.isDirectory()).map(({ name }) => name),
|
@@ -82,8 +68,8 @@ async function push(
|
|
82
68
|
scriptNamesToUsers = new Cache(_scriptName => new Set())
|
83
69
|
for (const script of scripts) {
|
84
70
|
const [user, scriptName] = script.split(".")
|
85
|
-
assert(user, "src/push.ts:
|
86
|
-
assert(scriptName, "src/push.ts:
|
71
|
+
assert(user, "src/push.ts:72:16")
|
72
|
+
assert(scriptName, "src/push.ts:73:22")
|
87
73
|
"*" == user ? scriptNamesToUsers.set(scriptName, allUsers) : scriptNamesToUsers.get(scriptName).add(user)
|
88
74
|
}
|
89
75
|
const sourceFolderFiles = sourceFolder.filter(({ stats }) => stats.isFile()),
|
@@ -151,4 +137,4 @@ async function push(
|
|
151
137
|
)
|
152
138
|
return allInfo
|
153
139
|
}
|
154
|
-
export {
|
140
|
+
export { push }
|