Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup-runtime/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Prepare Runtime in GitHub Actions
inputs:
node-version:
description: Version of Node to use
default: 20.x
default: 22.x

eas-version:
description: Version of EAS CLI to use
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-snackager/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Prepare Snackager in GitHub Actions
inputs:
node-version:
description: Version of Node to use
default: 20.x
default: 22.x

runs:
using: composite
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-snackpub/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Prepare Snackpub in GitHub Actions
inputs:
node-version:
description: Version of Node to use
default: 20.x
default: 22.x

runs:
using: composite
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-website/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Prepare Website in GitHub Actions
inputs:
node-version:
description: Version of Node to use
default: 20.x
default: 22.x

runs:
using: composite
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: 🏗 Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
cache: yarn

- name: 📦 Install monorepo dependencies
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "Expo",
"license": "MIT",
"volta": {
"node": "20.19.4"
"node": "22.21.1"
},
"scripts": {
"start": "turbo build --filter '{./packages/snack-term}...' && yarn --cwd ./packages/snack-term start",
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-babel-standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"author": "Expo <[email protected]>",
"license": "MIT",
"volta": {
"node": "20.19.4"
"node": "22.21.1"
},
"scripts": {
"test": "echo 'No tests yet'",
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"author": "Expo <[email protected]>",
"license": "MIT",
"volta": {
"node": "20.19.4"
"node": "22.21.1"
},
"dependencies": {
"semver": "^7.3.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-eslint-standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@
"snack-babel-standalone": "^3.0.1"
},
"volta": {
"node": "20.19.4"
"node": "22.21.1"
}
}
2 changes: 1 addition & 1 deletion packages/snack-proxies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build": "tsc"
},
"volta": {
"node": "20.19.4"
"node": "22.21.1"
},
"dependencies": {
"chalk": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-require-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"author": "Expo <[email protected]>",
"license": "MIT",
"volta": {
"node": "20.19.4"
"node": "22.21.1"
},
"scripts": {
"test": "jest",
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"author": "Expo <[email protected]>",
"license": "MIT",
"volta": {
"node": "20.19.4"
"node": "22.21.1"
},
"scripts": {
"test": "jest",
Expand Down
11 changes: 10 additions & 1 deletion packages/snack-sdk/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
/** @type {import('jest').Config} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
modulePathIgnorePatterns: ['<rootDir>/build/'],
testPathIgnorePatterns: ['/node_modules/', '/build/'],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: 'tsconfig.json',
},
],
},
};
4 changes: 1 addition & 3 deletions packages/snack-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"author": "Expo <[email protected]>",
"license": "MIT",
"volta": {
"node": "20.19.4"
"node": "22.21.1"
},
"devDependencies": {
"@expo/spawn-async": "^1.5.0",
Expand All @@ -45,7 +45,6 @@
"@types/koa__router": "^8.0.3",
"@types/lodash.isequal": "^4.5.5",
"@types/lodash.mapvalues": "^4.6.6",
"@types/node-fetch": "^2.5.7",
"@types/pubnub": "^7.2.0",
"@types/semver": "^7.3.4",
"@types/ua-parser-js": "^0.7.33",
Expand All @@ -65,7 +64,6 @@
},
"dependencies": {
"diff": "^4.0.2",
"fetch-ponyfill": "^7.0.0",
"lodash": "^4.17.20",
"nanoid": "^3.1.20",
"nullthrows": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-sdk/src/DependencyResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class DependencyResolver {
return;
}
if (res.status === 200) {
const data = await res.json();
const data: any = await res.json();
if (data.pending) {
this.logger?.module('Dependency is still being bundled', key, 'trying again shortly');
await new Promise((resolve) => setTimeout(resolve, 5000));
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-sdk/src/DevSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class DevSession {
throw Error(response.statusText);
}

const json = await response.json();
const json: any = await response.json();
this.onSendBeaconCloseRequest({
url: this.getRequest(true, undefined, deviceId).url,
data: new Blob(
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-sdk/src/FileUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default class FileUploader {
const text = await response.text();
throw new Error(text);
}
const result = await response.json();
const result: any = await response.json();
const resultURL = result.url;

if (this.status[path]?.file === file) {
Expand Down
4 changes: 2 additions & 2 deletions packages/snack-sdk/src/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export default class Snack {
...(options?.ignoreUser ? {} : createUserHeader(user)),
},
});
const data = await response.json();
const data: any = await response.json();
if (!data?.id) {
throw new Error(data.errors?.[0]?.message || 'Failed to save');
}
Expand Down Expand Up @@ -483,7 +483,7 @@ export default class Snack {
'Content-Type': 'application/json',
},
});
const data = await response.json();
const data: any = await response.json();
if (data.id) {
this.logger?.info('Uploaded preview', data);
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-sdk/src/WantedVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class WantedDependencyVersions {
const urlVersion = encodeURIComponent(sdkVersion);
return fetch(`https://cdn.jsdelivr.net/npm/expo@${urlVersion}/bundledNativeModules.json`)
.then((response) => response.json())
.then((data) => data || {});
.then((data) => data || {}) as Promise<Record<string, string>>;
}

/**
Expand Down
58 changes: 58 additions & 0 deletions packages/snack-sdk/src/__mocks__/fetch-mock-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type { Server } from 'http';

import createSnackager from './snackager';
import createVersions from './versions';
import createWww from './www';
import { defaultConfig } from '..';

const actualFetch = globalThis.fetch;

const mockFetch = jest.fn(async (url: string, options: Request) => {
let server: Server | undefined;

if (!process.env.SNACK_ENV || process.env.SNACK_ENV === 'mock') {
// Snackager
if (url.startsWith(defaultConfig.snackagerURL)) {
const path = url.substring(defaultConfig.snackagerURL.length);
server = createSnackager().listen(0);
// @ts-ignore: Property port does not exist on type AddressInfo | string
url = `http://127.0.0.1:${server.address().port}${path}`;

// BundledNativeModules.json
} else if (url.startsWith('https://cdn.jsdelivr.net/npm/expo@')) {
const path = url.substring('https://cdn.jsdelivr.net/npm'.length);
server = createVersions().listen(0);
// @ts-ignore: Property port does not exist on type AddressInfo | string
url = `http://127.0.0.1:${server.address().port}${path}`;

// www
} else if (url.startsWith(defaultConfig.apiURL)) {
const path = url.substring(defaultConfig.apiURL.length);
server = createWww().listen(0);
// @ts-ignore: Property port does not exist on type AddressInfo | string
url = `http://127.0.0.1:${server.address().port}${path}`;
// console.log('WWW: ', path);
} else {
console.log('UNKNOWN: ', url);
}
}

try {
return await actualFetch(url, options);
} catch (e) {
throw e;
} finally {
server?.close();
}
});

beforeEach(() => {
// @ts-ignore mock only accepts string and Request arguments
globalThis.fetch = mockFetch;
});

afterEach(() => {
globalThis.fetch = actualFetch;
});

export default mockFetch;
12 changes: 12 additions & 0 deletions packages/snack-sdk/src/__mocks__/fetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const actualFetch = globalThis.fetch;

export const mockFetch = jest.fn();

beforeEach(() => {
globalThis.fetch = mockFetch;
mockFetch.mockClear();
});

afterEach(() => {
globalThis.fetch = actualFetch;
});
55 changes: 0 additions & 55 deletions packages/snack-sdk/src/__mocks__/node-fetch.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/snack-sdk/src/__tests__/code-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint @typescript-eslint/no-unused-vars: 0 */
import formData from 'form-data';

import '../__mocks__/node-fetch';
import '../__mocks__/fetch-mock-server';
import Snack, { SnackFile } from './snack-sdk';
import {
ProtocolCodeMessage,
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-sdk/src/__tests__/connections-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../__mocks__/node-fetch';
import '../__mocks__/fetch-mock-server';
import Snack from './snack-sdk';
import { ProtocolErrorMessage } from '../transports/Protocol';
import Transport from '../transports/__mocks__/TestTransport';
Expand Down
2 changes: 1 addition & 1 deletion packages/snack-sdk/src/__tests__/dependencies-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../__mocks__/node-fetch';
import '../__mocks__/fetch-mock-server';
import { defaultSdkVersion, newestSdkVersion, oldestSdkVersion, SDKVersion } from 'snack-content';

import Snack from './snack-sdk';
Expand Down
Loading
Loading