hackmud-script-manager 0.20.4-23a791c → 0.20.4-3354314
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/hsm.js +1 -1
- package/env.d.ts +43 -26
- package/package.json +1 -1
- package/push.js +6 -4
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-3354314",
|
16
16
|
options = new Map(),
|
17
17
|
commands = [],
|
18
18
|
userColours = new Cache(user => {
|
package/env.d.ts
CHANGED
@@ -1,18 +1,14 @@
|
|
1
|
-
type Replace<
|
1
|
+
type Replace<A, B> = Omit<A, keyof B> & B
|
2
2
|
type ScriptSuccess<T = object> = { ok: true } & T
|
3
3
|
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> = {
|
8
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? true : false
|
9
|
-
}[keyof T]
|
7
|
+
type AllOptional<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? true : false }[keyof T]
|
10
8
|
|
11
9
|
type Scriptor<Args = unknown, Ret = unknown> = {
|
12
|
-
name: string
|
13
|
-
call: AllOptional<Args> extends true
|
14
|
-
? (args?: Args) => Ret
|
15
|
-
: (args: Args) => Ret
|
10
|
+
name: string
|
11
|
+
call: AllOptional<Args> extends true ? (args?: Args) => Ret : (args: Args) => Ret
|
16
12
|
}
|
17
13
|
|
18
14
|
type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
|
@@ -41,7 +37,7 @@ type UpgradeRarityString = "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`"
|
|
41
37
|
type UpgradeRarityNumber = 0 | 1 | 2 | 3 | 4 | 5;
|
42
38
|
type UpgradeRarity = UpgradeRarityString | UpgradeRarityNumber;
|
43
39
|
|
44
|
-
type
|
40
|
+
type UpgradeBase = {
|
45
41
|
name: string
|
46
42
|
type: "lock" | "script_space" | "chat" | "script" | "tool" | "bot_brain" | "glam"
|
47
43
|
up_class?: -1 | 0 | 1 | 2 | 3
|
@@ -53,9 +49,9 @@ type UpgradeCore = {
|
|
53
49
|
description: string
|
54
50
|
}
|
55
51
|
|
56
|
-
type Upgrade =
|
52
|
+
type Upgrade = UpgradeBase & Record<string, null | boolean | number | string>
|
57
53
|
|
58
|
-
type
|
54
|
+
type CliUpgrade = Omit<UpgradeBase, `rarity`> & {
|
59
55
|
[x: string]: null | boolean | number | string
|
60
56
|
rarity: UpgradeRarityString
|
61
57
|
}
|
@@ -155,7 +151,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
155
151
|
market: {
|
156
152
|
/** **FULLSEC** */ browse: {
|
157
153
|
(args:
|
158
|
-
Partial<{ seller: string, listed_before: number, listed_after: number, cost: number | string } & Omit<
|
154
|
+
Partial<{ seller: string, listed_before: number, listed_after: number, cost: number | string } & Omit<CliUpgrade, "rarity">>
|
159
155
|
): { i: string, name: string, rarity: Upgrade["rarity"], cost: number }[] | ScriptFailure
|
160
156
|
|
161
157
|
<I extends string>(args: { i: I }): {
|
@@ -357,7 +353,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
357
353
|
* const arr = [ 1, 2, 2, 3, 2 ]
|
358
354
|
*
|
359
355
|
* $D(uniq(arr)) // [ 1, 2, 3, 2 ] */
|
360
|
-
uniq: (array: T[]) => T[]
|
356
|
+
uniq: <T>(array: T[]) => T[]
|
361
357
|
|
362
358
|
/** Sorts an array of numbers or number-coercible strings in descending order. */
|
363
359
|
u_sort_num_arr_desc: <T>(array: T[]) => T[]
|
@@ -424,17 +420,17 @@ type Fullsec = Subscripts & PlayerFullsec & {
|
|
424
420
|
upgrades_of_owner: {
|
425
421
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: { filter?: F, full?: false }): (
|
426
422
|
Omit<
|
427
|
-
Pick<
|
423
|
+
Pick<UpgradeBase, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
|
428
424
|
keyof F
|
429
425
|
> & Pick<F, "tier" | "rarity" | "name" | "type" | "i" | "loaded">
|
430
426
|
)[] | ScriptFailure
|
431
427
|
|
432
428
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args: { filter?: F, full: true }): (
|
433
|
-
Omit<
|
429
|
+
Omit<UpgradeBase, keyof F> & F & Record<string, null | boolean | number | string>
|
434
430
|
)[] | ScriptFailure
|
435
431
|
|
436
432
|
<I extends number>(args: { i: I }): (
|
437
|
-
Omit<
|
433
|
+
Omit<UpgradeBase, "i"> & { [x: string]: null | boolean | number | string, i: I }
|
438
434
|
) | ScriptFailure
|
439
435
|
}
|
440
436
|
|
@@ -511,7 +507,7 @@ type Highsec = Fullsec & PlayerHighsec & {
|
|
511
507
|
/** **HIGHSEC** */
|
512
508
|
upgrades: {
|
513
509
|
<I extends number>(args: { i: I }): (
|
514
|
-
Omit<
|
510
|
+
Omit<UpgradeBase, "i"> & { [x: string]: null | boolean | number | string, i: I }
|
515
511
|
) | ScriptFailure
|
516
512
|
|
517
513
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: {
|
@@ -519,20 +515,20 @@ type Highsec = Fullsec & PlayerHighsec & {
|
|
519
515
|
is_script?: true
|
520
516
|
full?: false
|
521
517
|
}): (
|
522
|
-
Omit<Pick<
|
518
|
+
Omit<Pick<UpgradeBase, "tier" | "rarity" | "name" | "type" | "i" | "loaded">, keyof F> & F &
|
523
519
|
Record<string, null | boolean | number | string>
|
524
520
|
)[] | ScriptFailure
|
525
521
|
|
526
522
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(args?:
|
527
523
|
{ filter?: F, is_script?: true, full: true }
|
528
|
-
): (Omit<
|
524
|
+
): (Omit<UpgradeBase, keyof F> & F & Record<string, null | boolean | number | string>)[] | ScriptFailure
|
529
525
|
|
530
526
|
(args?: { filter?: Partial<Upgrade & { loaded: boolean }>, is_script: false, full?: false }):
|
531
527
|
{ msg: string, upgrades: string[] } | ScriptFailure
|
532
528
|
|
533
529
|
<F extends Partial<Upgrade & { loaded: boolean }> = object>(
|
534
530
|
args?: { filter?: F, is_script: false, full: true }
|
535
|
-
): (Omit<
|
531
|
+
): (Omit<UpgradeBase, keyof F | `rarity`> & F & {
|
536
532
|
[x: string]: null | boolean | number | string
|
537
533
|
rarity: UpgradeRarityString
|
538
534
|
})[] | ScriptFailure
|
@@ -766,7 +762,7 @@ type Cursor = {
|
|
766
762
|
ObjectId: () => any
|
767
763
|
}
|
768
764
|
|
769
|
-
type
|
765
|
+
type CliContext = {
|
770
766
|
/** The name of the user who is calling the script. */ caller: string
|
771
767
|
/** The name of this script. */ this_script: string
|
772
768
|
/** The number of columns in the caller’s terminal. */ cols: number
|
@@ -774,17 +770,23 @@ type CLIContext = {
|
|
774
770
|
|
775
771
|
/** The name of the script that directly called this script, or null if called on the command line or as a
|
776
772
|
* scriptor. */ calling_script: null
|
773
|
+
is_scriptor?: undefined
|
774
|
+
is_brain?: undefined
|
777
775
|
}
|
778
776
|
|
779
|
-
type SubscriptContext = Replace<
|
777
|
+
type SubscriptContext = Replace<CliContext, {
|
780
778
|
/** The name of the script that directly called this script, or null if called on the command line or as a scriptor.
|
781
779
|
*/
|
782
780
|
calling_script: string
|
783
781
|
}>
|
784
782
|
|
785
|
-
type ScriptorContext =
|
786
|
-
|
787
|
-
|
783
|
+
type ScriptorContext =
|
784
|
+
Replace<CliContext, { /** Whether the script is being run as a scriptor. */ is_scriptor: true }>
|
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
|
788
790
|
|
789
791
|
/** Subscript space that can call FULLSEC scripts. */ declare const $fs: Fullsec
|
790
792
|
|
@@ -827,6 +829,8 @@ declare const $0s: typeof $ns
|
|
827
829
|
* } */
|
828
830
|
declare const $s: Nullsec
|
829
831
|
|
832
|
+
type ObjectId = { $oid: string }
|
833
|
+
|
830
834
|
declare const $db: {
|
831
835
|
/** Insert a document or documents into a collection.
|
832
836
|
* @param documents A document or array of documents to insert into the collection. */
|
@@ -920,6 +924,8 @@ declare const $db: {
|
|
920
924
|
signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
|
921
925
|
}
|
922
926
|
}
|
927
|
+
|
928
|
+
ObjectId: () => ObjectId
|
923
929
|
}
|
924
930
|
|
925
931
|
/** Debug Log.
|
@@ -956,7 +962,7 @@ declare const $FMCL: undefined | true
|
|
956
962
|
* @example
|
957
963
|
* if (!$G.dbCache)
|
958
964
|
* $G.dbCache = $db.f({ whatever: true }).first() */
|
959
|
-
declare const $G: any
|
965
|
+
declare const $G: Record<string | symbol, any>
|
960
966
|
|
961
967
|
/** This contains a JS timestamp (not Date) set immediately before your code begins running.
|
962
968
|
* @example
|
@@ -1005,3 +1011,14 @@ declare const _FULL_SCRIPT_NAME: string
|
|
1005
1011
|
*
|
1006
1012
|
* In rare cases where it's not known at build time, it's `-1`. */
|
1007
1013
|
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.js
CHANGED
@@ -61,13 +61,15 @@ async function push(
|
|
61
61
|
...hackmudFolder
|
62
62
|
.filter(({ stats, name }) => stats.isFile() && name.endsWith(".key"))
|
63
63
|
.map(({ name }) => name.slice(0, -4))
|
64
|
-
])
|
65
|
-
|
64
|
+
])
|
65
|
+
if (!allUsers.size)
|
66
|
+
throw Error("Could not find any users. Either provide the names of your users or log into a user in hackmud.")
|
67
|
+
const usersToScriptsToPush = new Cache(_user => new Map()),
|
66
68
|
scriptNamesToUsers = new Cache(_scriptName => new Set())
|
67
69
|
for (const script of scripts) {
|
68
70
|
const [user, scriptName] = script.split(".")
|
69
|
-
assert(user, "src/push.ts:
|
70
|
-
assert(scriptName, "src/push.ts:
|
71
|
+
assert(user, "src/push.ts:72:16")
|
72
|
+
assert(scriptName, "src/push.ts:73:22")
|
71
73
|
"*" == user ? scriptNamesToUsers.set(scriptName, allUsers) : scriptNamesToUsers.get(scriptName).add(user)
|
72
74
|
}
|
73
75
|
const sourceFolderFiles = sourceFolder.filter(({ stats }) => stats.isFile()),
|