Skip to content

Commit

Permalink
chore: upgrade yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Sep 13, 2024
1 parent ce972db commit 467279b
Show file tree
Hide file tree
Showing 33 changed files with 4,453 additions and 4,282 deletions.
5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint --edit $1
yarn commitlint --edit $1
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
yarn lint-staged
5 changes: 1 addition & 4 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test
yarn test
Binary file modified .yarn/install-state.gz
Binary file not shown.
1,232 changes: 884 additions & 348 deletions .yarn/releases/yarn-1.22.21.cjs → .yarn/releases/yarn-1.22.22.cjs

Large diffs are not rendered by default.

925 changes: 925 additions & 0 deletions .yarn/releases/yarn-4.4.1.cjs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


yarn-path ".yarn/releases/yarn-1.22.22.cjs"
3 changes: 0 additions & 3 deletions .yarnrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion commons/interfaces/SameSiteContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const sameSiteContext = ['none', 'strict', 'lax'] as const;

type SameSiteContext = typeof sameSiteContext[number];
type SameSiteContext = (typeof sameSiteContext)[number];

export function isSameSiteContext(type: string): boolean {
return sameSiteContext.includes(type as any);
Expand Down
1 change: 0 additions & 1 deletion commons/lib/Callsite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default class Callsite {
}
stack = stack.slice(startIndex);


if (endFilename) {
let lastIdx = -1;
for (let i = stack.length - 1; i >= 0; i -= 1) {
Expand Down
1 change: 0 additions & 1 deletion commons/lib/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ export function translateToPrintable(

const logLevels = { stats: 0, info: 1, warn: 2, error: 3 };


if (!global.UlixeeLogCreator) {
global.UlixeeLogCreator = (module: NodeModule): { log: ILog } => {
const log: ILog = new Log(module);
Expand Down
5 changes: 4 additions & 1 deletion commons/lib/Timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export default class Timer {
private timeoutMessage = 'Timeout waiting';
private readonly expirePromise = new Resolvable<void>();

constructor(readonly timeoutMillis: number, readonly registry?: IRegistry[]) {
constructor(
readonly timeoutMillis: number,
readonly registry?: IRegistry[],
) {
// NOTE: A zero value will NOT timeout. This is to give users an ability to not timeout certain requests
this.timeout =
timeoutMillis > 0 ? setTimeout(this.expire.bind(this), timeoutMillis).unref() : null;
Expand Down
4 changes: 3 additions & 1 deletion commons/lib/TypeSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ export default class TypeSerializer {
};
}
if (value instanceof ArrayBuffer) {
const binary = Array.from(new Uint8Array(value)).map(byte => String.fromCharCode(byte)).join('');
const binary = Array.from(new Uint8Array(value))
.map(byte => String.fromCharCode(byte))
.join('');
return {
__type: Types.ArrayBuffer64,
value: globalThis.btoa(binary),
Expand Down
8 changes: 6 additions & 2 deletions commons/lib/TypedEventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class TypedEventEmitter<T> extends EventEmitter implements ITyped
): this {
super.on(eventType, listenerFn);
// if we're adding an error logger, we can remove the default logger
if (eventType === 'error' && listenerFn !== this.defaultErrorLogger as any) {
if (eventType === 'error' && listenerFn !== (this.defaultErrorLogger as any)) {
super.off('error', this.defaultErrorLogger);
}
this.onEventListenerAdded?.(eventType);
Expand All @@ -126,7 +126,11 @@ export default class TypedEventEmitter<T> extends EventEmitter implements ITyped
listenerFn: (this: this, event?: T[K]) => any,
): this {
// if we're removing an error logger, we should add back the default logger
if (eventType === 'error' && listenerFn !== this.defaultErrorLogger as any && super.listenerCount(eventType) === 1) {
if (
eventType === 'error' &&
listenerFn !== (this.defaultErrorLogger as any) &&
super.listenerCount(eventType) === 1
) {
super.on('error', this.defaultErrorLogger);
}
return super.off(eventType, listenerFn);
Expand Down
2 changes: 1 addition & 1 deletion commons/lib/VersionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import * as semver from 'semver';
export function isSemverSatisfied(version: string, isSatisfiedByVersion: string): boolean {
return semver.satisfies(isSatisfiedByVersion, `~${version}`, { includePrerelease: true });
}
export function nextVersion(version :string): string {
export function nextVersion(version: string): string {
return semver.inc(version, 'patch');
}
40 changes: 39 additions & 1 deletion commons/lib/dirUtils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,50 @@
import * as Fs from 'fs';
import * as os from 'os';
import * as Path from 'path';
import { fileURLToPath } from 'url';
import { parseEnvPath } from './envUtils';
import { existsAsync } from './fileUtils';

export function getDirname(dirnameOrUrl: string): string {
if (typeof dirnameOrUrl === 'string') {
// handle file:// urls like import.meta.url
if (dirnameOrUrl.startsWith('file://')) {
const filename = fileURLToPath(dirnameOrUrl);
return Path.dirname(filename);
}
return dirnameOrUrl;
}
throw new Error('Invalid argument passed to getDirname');
}

export function getSourcedir(dirnameOrUrl: string, buildDir = 'build'): string | null {
const dirname = getDirname(dirnameOrUrl);
let rootBuildDir = dirname;
while (!rootBuildDir.endsWith(`${Path.sep}${buildDir}`)) {
rootBuildDir = Path.dirname(rootBuildDir);
if (!rootBuildDir || rootBuildDir === Path.sep) {
return null;
}
}
const relativePath = Path.relative(rootBuildDir, dirname);
return Path.join(buildDir, '..', relativePath);
}

export function getClosestPackageJson(path: string): any | undefined {
while (!Fs.existsSync(Path.join(path, 'package.json'))) {
const next = Path.dirname(path);
if (next === path || !next) {
return null;
}
path = next;
}
return JSON.parse(Fs.readFileSync(Path.join(path, 'package.json'), 'utf8'));
}

export function getDataDirectory(): string {
if (process.env.ULX_DATA_DIR) {
return parseEnvPath(process.env.ULX_DATA_DIR);
const envPath = parseEnvPath(process.env.ULX_DATA_DIR);
if (envPath) return envPath;
}
if (process.platform === 'linux') {
return process.env.XDG_DATA_HOME || Path.join(os.homedir(), '.local', 'share');
Expand Down
2 changes: 1 addition & 1 deletion commons/lib/downloadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function getRequestOptionsWithProxy(url: string): RequestOptions {
port: proxyURL.port,
};
}
options.agent = new HttpsProxyAgent(proxyURL.href);
options.agent = new HttpsProxyAgent(proxyURL);
options.rejectUnauthorized = false;
}
return options;
Expand Down
6 changes: 4 additions & 2 deletions commons/lib/envUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getDataDirectory } from './dirUtils';
* Will load env files with this precedence (.env.defaults, .env.<NODE_ENV>, .env)
*/
export function loadEnv(baseDir: string, overwriteSetValues = false): void {
if (baseDir.endsWith('dist')) baseDir = Path.resolve(baseDir, '..');
const envName = process.env.NODE_ENV?.toLowerCase() ?? 'development';
const env: Record<string, string> = {};
for (const envFile of ['.env.defaults', `.env.${envName}`, '.env']) {
Expand All @@ -31,9 +32,10 @@ export function applyEnvironmentVariables(path: string, env: Record<string, stri
const LineRegex =
/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;

let match: RegExpExecArray;
let match: RegExpExecArray | null;
// eslint-disable-next-line no-cond-assign
while ((match = LineRegex.exec(lines))) {
if (!match) continue;
// eslint-disable-next-line prefer-const
let [, key, value] = match;

Expand Down Expand Up @@ -67,7 +69,7 @@ export function parseEnvInt(envvar: string): number | null {
return parseInt(envvar, 10);
}

export function parseEnvPath(envvar: string, relativeTo?: string): string {
export function parseEnvPath(envvar: string, relativeTo?: string): string | undefined {
if (!envvar) return undefined;
if (envvar?.startsWith('~')) envvar = Path.join(Os.homedir(), envvar.slice(1));
if (envvar?.startsWith('<DATA>')) envvar = envvar.replace('<DATA>', getDataDirectory());
Expand Down
12 changes: 10 additions & 2 deletions commons/lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import addGlobalInstance from './addGlobalInstance';
import { registerSerializableErrorType } from './TypeSerializer';

class UlixeeError extends Error {
constructor(override message, public code, public data?: object) {
constructor(
override message,
public code,
public data?: object,
) {
// Calling parent constructor of base Error class.
super(message);

Expand Down Expand Up @@ -49,7 +53,11 @@ class AbortError extends Error {
class CodeError<T extends Record<string, any> = Record<string, never>> extends Error {
public readonly props: T;

constructor(message: string, public readonly code: string, props?: T) {
constructor(
message: string,
public readonly code: string,
props?: T,
) {
super(message);

this.name = props?.name ?? 'CodeError';
Expand Down
2 changes: 1 addition & 1 deletion commons/lib/fileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function copyDir(fromDir: string, toDir: string): Promise<void> {
}
}

export async function readFileAsJson<T>(path: string): Promise<T> {
export async function readFileAsJson<T>(path: string): Promise<T | null> {
const buffer = await Fs.readFile(path, 'utf8').catch(() => null);
if (!buffer) return null;
return JSON.parse(buffer) as T;
Expand Down
3 changes: 1 addition & 2 deletions commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"version": "2.0.0-alpha.29",
"private": true,
"description": "Common utilities for Ulixee",
"license": "MIT",
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.18",
"bech32": "^2.0.0",
"devtools-protocol": "^0.0.1137505",
"https-proxy-agent": "^5.0.0",
"https-proxy-agent": "^7.0.5",
"semver": "^7.3.7"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion commons/test/SourceLoader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ it('can lookup source code', () => {
return callsite;
}
const site = loadCallsite();
expect(SourceLoader.getSource(site[0]).code).toBe(` callsite ??= Callsite.getSourceCodeLocation();`);
expect(SourceLoader.getSource(site[0]).code).toBe(
` callsite ??= Callsite.getSourceCodeLocation();`,
);
expect(SourceLoader.getSource(site[1]).code).toBe(` const site = loadCallsite();`);
});
36 changes: 20 additions & 16 deletions commons/test/SourceMapSupport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@ it('finds source maps with charset specified', () => {
const file = `./.generated-${counter}.js`;
fs.writeFileSync(
path.join(__dirname, file),
`${'exports.test = function() {' +
`${
'exports.test = function() {' +
'throw new Error("test");' +
'};//@ sourceMappingURL=data:application/json;charset=utf8;base64,'}${
Buffer.from(sourceMap.toString()).toString('base64')}`,
'};//@ sourceMappingURL=data:application/json;charset=utf8;base64,'
}${Buffer.from(sourceMap.toString()).toString('base64')}`,
);
try {
// eslint-disable-next-line import/no-dynamic-require
Expand All @@ -196,11 +197,13 @@ it('allows code/comments after sourceMappingURL', () => {
const file = `./.generated-${counter}.js`;
fs.writeFileSync(
path.join(__dirname, file),
`${'exports.test = function() {' +
`${
'exports.test = function() {' +
'throw new Error("test");' +
'};//# sourceMappingURL=data:application/json;base64,'}${
Buffer.from(sourceMap.toString()).toString('base64')
}\n// Some comment below the sourceMappingURL\nvar foo = 0;`,
'};//# sourceMappingURL=data:application/json;base64,'
}${Buffer.from(sourceMap.toString()).toString(
'base64',
)}\n// Some comment below the sourceMappingURL\nvar foo = 0;`,
);
try {
// eslint-disable-next-line import/no-dynamic-require
Expand Down Expand Up @@ -238,7 +241,7 @@ function createMultiLineSourceMap(): SourceMapGenerator {
sourceMap.addMapping({
generated: { line: i, column: 0 },
original: { line: 1000 + i, column: 99 + i },
source: `line${ i }.js`,
source: `line${i}.js`,
});
}
return sourceMap;
Expand All @@ -253,7 +256,7 @@ function createMultiLineSourceMapWithSourcesContent(): SourceMapGenerator {
original: { line: 1000 + i, column: 4 },
source: 'original.js',
});
original += ` line ${ i }\n`;
original += ` line ${i}\n`;
}
sourceMap.setSourceContent('original.js', original);
return sourceMap;
Expand All @@ -267,9 +270,9 @@ function createStackTraces(
fs.writeFileSync(`${__dirname}/.generated-${counter}.js.map`, sourceMap.toString());
fs.writeFileSync(
`${__dirname}/.generated-${counter}.js`,
`exports.test = function() {${
source.join('\n')
}};//@ sourceMappingURL=.generated-${counter}.js.map`,
`exports.test = function() {${source.join(
'\n',
)}};//@ sourceMappingURL=.generated-${counter}.js.map`,
);
const response = { full: null, inline: null };
try {
Expand All @@ -284,10 +287,11 @@ function createStackTraces(
// Check again with an inline source map (in a data URL)
fs.writeFileSync(
`${__dirname}/.generated-${counter}-inline.js`,
`exports.test = function() {${
source.join('\n')
}};//@ sourceMappingURL=data:application/json;base64,${
Buffer.from(sourceMap.toString()).toString('base64')}`,
`exports.test = function() {${source.join(
'\n',
)}};//@ sourceMappingURL=data:application/json;base64,${Buffer.from(
sourceMap.toString(),
).toString('base64')}`,
);
try {
// eslint-disable-next-line import/no-dynamic-require
Expand Down
5 changes: 4 additions & 1 deletion net/errors/DisconnectedError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import addGlobalInstance from '@ulixee/commons/lib/addGlobalInstance';

export default class DisconnectedError extends CanceledPromiseError {
public code = 'DisconnectedError';
constructor(readonly host: string, message?: string) {
constructor(
readonly host: string,
message?: string,
) {
super(message ?? `This transport has been disconnected (host: ${host})`);
this.name = 'DisconnectedError';
}
Expand Down
8 changes: 7 additions & 1 deletion net/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ import WsTransportToCore from './lib/WsTransportToCore';
import WsTransportToClient from './lib/WsTransportToClient';
import TransportBridge from './lib/TransportBridge';

export { ConnectionToCore, WsTransportToClient, WsTransportToCore, ConnectionToClient, TransportBridge };
export {
ConnectionToCore,
WsTransportToClient,
WsTransportToCore,
ConnectionToClient,
TransportBridge,
};
5 changes: 4 additions & 1 deletion net/lib/ConnectionToClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export default class ConnectionToClient<
public handlerMetadata?: IHandlerMetadata;

private events = new EventSubscriber();
constructor(readonly transport: ITransport, readonly apiHandlers: IClientApiHandlers) {
constructor(
readonly transport: ITransport,
readonly apiHandlers: IClientApiHandlers,
) {
super();

if (transport) {
Expand Down
5 changes: 4 additions & 1 deletion net/lib/ConnectionToCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export default class ConnectionToCore<
private isSendingConnect = false;
private isSendingDisconnect = false;

constructor(public transport: ITransport, skipConnect = false) {
constructor(
public transport: ITransport,
skipConnect = false,
) {
super();
bindFunctions(this);

Expand Down
5 changes: 4 additions & 1 deletion net/lib/HttpTransportToClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export default class HttpTransportToClient
public remoteId: string;
public isConnected = true;

constructor(public request: IncomingMessage, private response: ServerResponse) {
constructor(
public request: IncomingMessage,
private response: ServerResponse,
) {
super();
this.remoteId = `${request.socket.remoteAddress}:${request.socket.remotePort}`;
}
Expand Down
Loading

0 comments on commit 467279b

Please sign in to comment.