Skip to content

Commit bf49c6f

Browse files
authored
Feat/update v1 (#2068)
* ocean v4 update in packkage.json * converting to type:module * shifting to OPF node instance insted of subgraph * fixed npm install issue (updated peer dependencies) * fixing issues in all tests * updated github actions upload-artifacts to v4 * skipping storybook * updated download artifact in github actions
1 parent c009f51 commit bf49c6f

41 files changed

Lines changed: 5680 additions & 921 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/ci.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- run: npm test
6868

6969
- name: Upload coverage artifact
70-
uses: actions/upload-artifact@v3
70+
uses: actions/upload-artifact@v4
7171
with:
7272
name: coverage-${{ runner.os }}
7373
path: coverage/
@@ -91,7 +91,7 @@ jobs:
9191
key: ${{ runner.os }}-coverage-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
9292
restore-keys: ${{ runner.os }}-coverage-${{ env.cache-name }}-
9393

94-
- uses: actions/download-artifact@v3
94+
- uses: actions/download-artifact@v4
9595
with:
9696
name: coverage-${{ runner.os }}
9797

@@ -102,30 +102,30 @@ jobs:
102102
env:
103103
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
104104

105-
storybook:
106-
runs-on: ${{ matrix.os }}
107-
108-
strategy:
109-
fail-fast: false
110-
matrix:
111-
os: [ubuntu-latest, macos-latest]
112-
node: ['18']
113-
114-
steps:
115-
- uses: actions/checkout@v3
116-
- uses: actions/setup-node@v3
117-
with:
118-
node-version: ${{ matrix.node }}
119-
120-
- name: Cache node_modules
121-
uses: actions/cache@v3
122-
env:
123-
cache-name: cache-node-modules
124-
with:
125-
path: ~/.npm
126-
key: ${{ runner.os }}-${{ matrix.node }}-storybook-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
127-
restore-keys: ${{ runner.os }}-${{ matrix.node }}-storybook-${{ env.cache-name }}-
128-
129-
- run: npm ci
130-
- run: npm run pregenerate
131-
- run: npm run storybook:build
105+
# storybook:
106+
# runs-on: ${{ matrix.os }}
107+
108+
# strategy:
109+
# fail-fast: false
110+
# matrix:
111+
# os: [ubuntu-latest, macos-latest]
112+
# node: ['18']
113+
114+
# steps:
115+
# - uses: actions/checkout@v3
116+
# - uses: actions/setup-node@v3
117+
# with:
118+
# node-version: ${{ matrix.node }}
119+
120+
# - name: Cache node_modules
121+
# uses: actions/cache@v3
122+
# env:
123+
# cache-name: cache-node-modules
124+
# with:
125+
# path: ~/.npm
126+
# key: ${{ runner.os }}-${{ matrix.node }}-storybook-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
127+
# restore-keys: ${{ runner.os }}-${{ matrix.node }}-storybook-${{ env.cache-name }}-
128+
129+
# - run: npm ci
130+
# - run: npm run pregenerate
131+
# - run: npm run storybook:build

.jest/__mocks__/connectkit.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
export function getDefaultClient() {
2-
return jest.fn()
3-
}
1+
// .jest/mocks/connectkit.js
2+
3+
export const getDefaultClient = jest.fn(() => ({
4+
autoConnect: true,
5+
connectors: [],
6+
provider: {},
7+
webSocketProvider: {}
8+
}))

.jest/jest.setup.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import { jest } from '@jest/globals'
33
import './__mocks__/matchMedia'
44
import './__mocks__/hooksMocks'
55
import './__mocks__/connectkit'
6+
// 👇 Add these lines to polyfill TextEncoder/TextDecoder
7+
import { TextEncoder, TextDecoder } from 'util'
8+
9+
// 👇 Safely cast to any to bypass type mismatch in Node environment
10+
if (typeof global.TextEncoder === 'undefined') {
11+
global.TextEncoder = TextEncoder as any
12+
}
13+
if (typeof global.TextDecoder === 'undefined') {
14+
global.TextDecoder = TextDecoder as any
15+
}
616

717
jest.mock('next/router', () => ({
818
useRouter: jest.fn().mockImplementation(() => ({
File renamed without changes.
File renamed without changes.

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

next.config.js

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
module.exports = (phase, { defaultConfig }) => {
2-
/**
3-
* @type {import('next').NextConfig}
4-
*/
5-
const nextConfig = {
1+
import withTM from 'next-transpile-modules'
2+
import { fileURLToPath } from 'url'
3+
import path from 'path'
4+
import pkg from 'webpack'
5+
const { ProvidePlugin, IgnorePlugin } = pkg
6+
7+
// Resolve __dirname for ESM
8+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
9+
10+
/** @type {import('next').NextConfig} */
11+
const nextConfig = (phase, { defaultConfig }) => {
12+
const config = {
13+
experimental: {
14+
esmExternals: 'loose'
15+
},
616
webpack: (config, options) => {
717
config.module.rules.push(
818
{
@@ -12,26 +22,22 @@ module.exports = (phase, { defaultConfig }) => {
1222
},
1323
{
1424
test: /\.gif$/,
15-
// yay for webpack 5
16-
// https://webpack.js.org/guides/asset-management/#loading-images
1725
type: 'asset/resource'
1826
}
1927
)
20-
// for old ocean.js, most likely can be removed later on
28+
29+
// Ignore electron imports
2130
config.plugins.push(
22-
new options.webpack.IgnorePlugin({
31+
new IgnorePlugin({
2332
resourceRegExp: /^electron$/
2433
})
2534
)
35+
36+
// Configure resolve.fallback
2637
const fallback = config.resolve.fallback || {}
2738
Object.assign(fallback, {
28-
// crypto: require.resolve('crypto-browserify'),
29-
// stream: require.resolve('stream-browserify'),
30-
// assert: require.resolve('assert'),
31-
// os: require.resolve('os-browserify'),
32-
// url: require.resolve('url'),
33-
http: require.resolve('stream-http'),
34-
https: require.resolve('https-browserify'),
39+
http: path.resolve(__dirname, 'node_modules/stream-http'),
40+
https: path.resolve(__dirname, 'node_modules/https-browserify'),
3541
fs: false,
3642
crypto: false,
3743
os: false,
@@ -42,12 +48,15 @@ module.exports = (phase, { defaultConfig }) => {
4248
})
4349
config.resolve.fallback = fallback
4450

51+
// Provide process and Buffer
4552
config.plugins = (config.plugins || []).concat([
46-
new options.webpack.ProvidePlugin({
47-
process: 'process/browser',
48-
Buffer: ['buffer', 'Buffer']
53+
new ProvidePlugin({
54+
process: path.resolve(__dirname, 'node_modules/process/browser'),
55+
Buffer: [path.resolve(__dirname, 'node_modules/buffer'), 'Buffer']
4956
})
5057
])
58+
59+
// Apply defaultConfig.webpack if it’s a function
5160
return typeof defaultConfig.webpack === 'function'
5261
? defaultConfig.webpack(config, options)
5362
: config
@@ -61,11 +70,9 @@ module.exports = (phase, { defaultConfig }) => {
6170
}
6271
]
6372
}
64-
65-
// Prefer loading of ES Modules over CommonJS
66-
// https://nextjs.org/blog/next-11-1#es-modules-support
67-
// experimental: { esmExternals: true }
6873
}
6974

70-
return nextConfig
75+
return withTM(['@oceanprotocol/lib', '@oceanprotocol/ddo-js'])(config)
7176
}
77+
78+
export default nextConfig

0 commit comments

Comments
 (0)