Skip to content

Commit

Permalink
Merge pull request #184 from skalenetwork/new-metaport-architecture-r…
Browse files Browse the repository at this point in the history
…ollup

New metaport architecture
  • Loading branch information
dmytrotkk authored Sep 25, 2023
2 parents e83075e + 53c91ae commit 4b601c2
Show file tree
Hide file tree
Showing 231 changed files with 7,978 additions and 10,640 deletions.
16 changes: 0 additions & 16 deletions .babelrc.json

This file was deleted.

20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: ['plugin:react/recommended', 'standard-with-typescript', 'prettier', 'plugin:storybook/recommended'],
overrides: [],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['react'],
rules: {
'react/jsx-key': 'off',
'react/react-in-jsx-scope': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'no-console': 'warn',
},
}
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Update submodules
run: |
git submodule update --remote
- name: Prepare metadata
run: |
bash prepare_meta.sh
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ test.mjs


src/meta/
src/icons/index.ts

metaportConfig.json
metaportConfigMainnet.json

storybook-static/
.vercel
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
[submodule "skale-network"]
path = skale-network
url = https://github.com/skalenetwork/skale-network.git
branch = add-additional-metadata
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": false,
"trailingComma": "none",
"singleQuote": true,
"printWidth": 100,
"endOfLine": "auto",
"bracketSpacing": true
}
96 changes: 15 additions & 81 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,88 +1,22 @@
const path = require("path");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
import type { StorybookConfig } from "@storybook/react-webpack5";
import type { StorybookConfig } from '@storybook/react-vite'
const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
core: {},
addons: ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/preset-create-react-app", "@storybook/addon-interactions"],
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-styling',
],
framework: {
name: "@storybook/react-webpack5",
name: '@storybook/react-vite',
options: {
builder: {
lazyCompilation: true
}
}
viteConfigPath: '.storybook/vite.config.ts',
},
},
},
docs: {
autodocs: "tag"
autodocs: 'tag',
},
staticDirs: ["../build"],
webpackFinal: async config => {
if (config.resolve && config.resolve.alias) {
const {
global,
...alias
} = config.resolve.alias;
// config.resolve.alias['global'] = undefined;
// const { ...alias } = config.resolve.alias
config.resolve.alias = alias;
}
if (config.module && config.module.rules) {
config.module.rules.push({
test: /\.scss$/,
use: ["style-loader", {
loader: 'css-loader',
options: {
modules: true,
sourceMap: true,
importLoaders: 2,
esModule: false
}
}, "sass-loader"],
include: path.resolve(__dirname, "../")
});
config.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve("babel-loader"),
options: {
presets: [["react-app", {
flow: false,
typescript: true,
runtime: 'automatic'
}]]
}
});
config.module.rules.push({
test: /\.svg$/,
use: [{
loader: 'svg-url-loader',
options: {
limit: 10000
}
}]
});
}
if (config.plugins) {
config.plugins.push(new NodePolyfillPlugin());
}
if (config.resolve && config.resolve.extensions) {
config.resolve.extensions.push(".ts", ".tsx");
}
if (config.resolve && config.resolve.fallback) {
config.resolve.fallback = {
path: require.resolve('path-browserify'),
os: "os-browserify/browser",
"fs": false,
"https": require.resolve("https-browserify"),
"http": require.resolve("stream-http"),
"crypto": require.resolve("crypto-browserify"),
"stream": require.resolve("stream-browserify"),
"buffer": require.resolve("buffer")
//...config.resolve.fallback,
};
}

return config;
}
};
export default config;
}
export default config
7 changes: 0 additions & 7 deletions .storybook/manager.js

This file was deleted.

18 changes: 14 additions & 4 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import type { Preview } from "@storybook/react";
import type { Preview } from '@storybook/react'

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
grid: true,
backgrounds: {
default: 'dark',
values: [
{
name: 'dark',
value: '#222425',
}
]
},
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
};
}

export default preview;
export default preview
16 changes: 16 additions & 0 deletions .storybook/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vitest/config'
import { UserConfigExport } from 'vite'

const app = async (): Promise<UserConfigExport> => {
return defineConfig({
plugins: [react()],
css: {
postcss: {
plugins: [],
},
},
})
}
// https://vitejs.dev/config/
export default app
44 changes: 44 additions & 0 deletions generate-imports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const fs = require('fs');
const path = require('path');

const rootDir = process.argv[2];

if (!rootDir) {
console.error('Please provide a root directory as an argument.');
process.exit(1);
}

const getSvgFilesInDir = (dir) => {
return fs.readdirSync(dir).filter(file => path.extname(file) === '.svg').map(file => path.join(dir, file));
};

const generateNamespaceExportsForDir = (dir) => {
const svgFiles = getSvgFilesInDir(dir);

if (svgFiles.length === 0) return; // Skip folders without SVGs

const namespaceExports = svgFiles.map(file => {
const variableName = path.basename(file, '.svg').replace(/-([a-z])/g, (_, g) => g.toUpperCase()); // Convert kebab-case to camelCase
return `export * as ${variableName} from './${path.basename(file)}';`;
}).join('\n');

const outputPath = path.join(dir, 'index.ts');
fs.writeFileSync(outputPath, namespaceExports, 'utf-8');
};

const walkDirectories = (dir) => {
const items = fs.readdirSync(dir);

for (const item of items) {
const itemPath = path.join(dir, item);
const stat = fs.statSync(itemPath);

if (stat && stat.isDirectory()) {
generateNamespaceExportsForDir(itemPath);
walkDirectories(itemPath);
}
}
};

generateNamespaceExportsForDir(rootDir); // Generate for rootDir itself
walkDirectories(rootDir); // Then walk its subdirectories
2 changes: 1 addition & 1 deletion helper-scripts
Loading

0 comments on commit 4b601c2

Please sign in to comment.