Skip to content

Commit 8b5cdce

Browse files
Fix tests, fix dependabot issues, 0.8.8
1 parent 39d1669 commit 8b5cdce

65 files changed

Lines changed: 1457 additions & 1615 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
node-version: [20.x, 22.x, 24.x]
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
cache: npm
20+
- run: npm ci
21+
- run: npm test

lib/LoginHandler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import type { BotOptionFlags } from './enums/BotOptionFlags';
1212
import { URL } from 'url';
1313
import * as os from 'os';
1414

15-
const packageJsonPath = path.join(__dirname, '..', '..', 'package.json');
15+
// Resolves from lib/ when running from source, or dist/lib/ when compiled
16+
const packageJsonCandidates = [
17+
path.join(__dirname, '..', 'package.json'),
18+
path.join(__dirname, '..', '..', 'package.json')
19+
];
20+
const packageJsonPath = packageJsonCandidates.find((p) => fs.existsSync(p)) ?? packageJsonCandidates[1];
1621
// eslint-disable-next-line @typescript-eslint/no-require-imports
1722
const packageJson = require(packageJsonPath);
1823
const version = packageJson.version;

lib/classes/EventQueueClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { LandStatsEvent } from '../events/LandStatsEvent';
2222
import * as LLSD from '@caspertech/llsd';
2323
import type { CancelableRequest, Response as GotResponse } from 'got';
2424
import got from 'got';
25-
import * as Long from 'long';
25+
import { Long } from './LongUtil';
2626

2727
export class EventQueueClient
2828
{

lib/classes/LLSettings.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import { describe, expect, it } from 'vitest';
2-
import * as fg from 'fast-glob';
32
import * as fs from 'fs';
43
import * as path from 'path';
54
import { LLSettings } from './LLSettings';
6-
import { toDeeplyMatch } from '../../testing/TestingUtils.util.spec';
5+
import { toDeeplyMatch } from '../../testing/TestingUtils.util';
76

87
expect.extend({
98
toDeeplyMatch,
109
});
1110

1211
describe('LLSettings', () =>
1312
{
14-
const filePath = path.join(__dirname, '..', '..', '..', '..', 'assets');
15-
const filteredFileNames = fg.sync(filePath + '/*.bin');
13+
const filePath = path.join(__dirname, '..', '..', 'testing');
14+
const filteredFileNames = fs.readdirSync(filePath).filter((f) => f.endsWith('.bin')).map((f) => path.join(filePath, f));
1615
for(const file of filteredFileNames)
1716
{
1817
const baseName = path.basename(file);

lib/classes/LoginResponse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { UUID } from './UUID';
22
import { Agent } from './Agent';
33
import { Region } from './Region';
44
import { Vector3 } from './Vector3';
5-
import * as Long from 'long';
5+
import { Long } from './LongUtil';
66
import type { ClientEvents } from './ClientEvents';
77
import { InventoryFolder } from './InventoryFolder';
88
import type { BotOptionFlags} from '..';

lib/classes/LongUtil.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as LongImport from 'long';
2+
3+
// The 'long' package is CommonJS: tsc's CommonJS output binds the constructor
4+
// directly, while ESM-based tooling (such as vitest) exposes it on `default`.
5+
const LongCtor: LongImport.LongConstructor =
6+
(LongImport as unknown as { default?: LongImport.LongConstructor }).default ?? LongImport;
7+
8+
export { LongCtor as Long };
9+
export type Long = LongImport;

lib/classes/UUID.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import validator from 'validator';
2-
import * as Long from 'long';
2+
import { Long } from './LongUtil';
33
import type { XMLNode } from 'xmlbuilder';
44
import * as uuid from 'uuid';
55

lib/classes/Utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as Long from 'long';
1+
import { Long } from './LongUtil';
22
import type { Subscription } from 'rxjs';
33
import { Subject } from 'rxjs';
44
import * as xml2js from 'xml2js';

lib/classes/llsd/LLSD.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ describe('LLSD', () =>
9797
expect(parsed.arr[12]).toBeInstanceOf(LLSDReal);
9898
expect(parsed.arr[12].valueOf()).toBe(-0);
9999

100-
const rebuilt = LLSD.toNotation(parsed as unknown as LLSDType);
100+
const rebuilt = LLSD.toNotation(parsed as unknown as LLSDType, false);
101101
expect(rebuilt).toBe('{"string":"Hello!","map":{"nestedMap":{"nestedArray":["one",i2,r3.14,u00000000-1111-2222-3333-444444444444,l"https://www.blahblah.com",{"date":d"2024-11-22T20:35:36.638Z"},!]}},"arr":[1,0,!,!,d"2024-11-22T20:35:36.638Z",b64"dGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==",b64"UGVlcGVycyBqZWVwZXJzIQ==",rNaN,rNaN,r-Infinity,rInfinity,r0,r-0]}');
102102
});
103103

104104
it('escapes special characters', () =>
105105
{
106106
const str = '\'"ⳑ⣺⋺➍⣋▎⊻™⿨₀⏆⨣⑬⛪␹⩯\0⁇⯒';
107-
const encoded= LLSD.toNotation(str);
107+
const encoded = LLSD.toNotation(str, false);
108108
expect(encoded.valueOf()).toBe('"\'\\"ⳑ⣺⋺➍⣋▎⊻™⿨₀⏆⨣⑬⛪␹⩯\\x00⁇⯒"');
109109

110110
const parsed = LLSD.parseNotation(encoded);

lib/classes/messages/AbortXfer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file has been automatically generated by writeMessageClasses.js
22

3-
import * as Long from 'long';
3+
import { Long } from '../LongUtil';
44
import { MessageFlags } from '../../enums/MessageFlags';
55
import { MessageBase } from '../MessageBase';
66
import { Message } from '../../enums/Message';

0 commit comments

Comments
 (0)