Skip to content

Commit

Permalink
feat(ts): adds several deprecated modules (#184)
Browse files Browse the repository at this point in the history
Needed to ensure cloudmos functionality which still relies on the relevant code.
  • Loading branch information
ygrishajev committed May 2, 2024
1 parent bee24ca commit 873447f
Show file tree
Hide file tree
Showing 28 changed files with 8,528 additions and 51 deletions.
26 changes: 7 additions & 19 deletions ts/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"ignorePatterns": ["node_modules/", "build/", "umd/"],
"env": {
"node": true,
"es2021": true
"es2021": true,
"jest": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
Expand All @@ -18,23 +22,7 @@
"ignoreRestSiblings": true
}
],
"simple-import-sort/imports": [
"error",
{
"groups": [
["^(@|src|@src)?\\w"],
[
"^(src|main|core|arc-storybook|viz|design-system|placement|reporting|onboarding)(/.*|$)",
"^\\u0000",
"^\\.\\.(?!/?$)",
"^\\.\\./?$",
"^\\./(?=.*/)(?!/?$)",
"^\\.(?!/?$)",
"^\\./?$"
]
]
}
]
"simple-import-sort/imports": "error"
},
"overrides": [
{
Expand Down
1 change: 1 addition & 0 deletions ts/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
collectCoverageFrom: [
'<rootDir>/src/**/*.{js,ts}',
'!<rootDir>/src/generated/**/*',
'!<rootDir>/src/deprecated/**/*',
'!<rootDir>/src/patch/index.*',
],
projects: [
Expand Down
91 changes: 91 additions & 0 deletions ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@typescript-eslint/eslint-plugin": "^7.2.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-simple-import-sort": "^12.0.0",
"jest": "^29.7.0",
"lint-staged": "^15.2.2",
Expand Down Expand Up @@ -62,4 +63,4 @@
},
"types": "dist/index.d.ts",
"version": "0.0.0"
}
}
44 changes: 14 additions & 30 deletions ts/script/generate-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,26 @@

const fs = require('fs');
const path = require('path');
const staticExports = require('../static-exports.json');

const distDir = path.resolve(__dirname, '../dist/generated');
const files = fs.readdirSync(distDir);
const TYPE_REGISTRY_PATH = './dist/generated/typeRegistry';
const paths = files.reduce(
(acc, file) => {
const match = file.match(/index.(.*)\.d\.ts/);
const paths = files.reduce((acc, file) => {
const match = file.match(/index.(.*)\.d\.ts/);

if (match) {
const dottedPath = match[1];
const slashedPath = dottedPath.replace(/\./g, '/');
const resolvedPath = fs.existsSync(`./dist/patch/index.${dottedPath}.js`)
? `./dist/patch/index.${dottedPath}`
: `./dist/generated/index.${dottedPath}`;
if (match) {
const dottedPath = match[1];
const slashedPath = dottedPath.replace(/\./g, '/');
const resolvedPath = fs.existsSync(`./dist/patch/index.${dottedPath}.js`)
? `./dist/patch/index.${dottedPath}`
: `./dist/generated/index.${dottedPath}`;

acc.tsconfig[`@akashnetwork/akash-api/${slashedPath}`] = [resolvedPath];
acc.package[`./${slashedPath}`] = `${resolvedPath}.js`;
}
acc.tsconfig[`@akashnetwork/akash-api/${slashedPath}`] = [resolvedPath];
acc.package[`./${slashedPath}`] = `${resolvedPath}.js`;
}

return acc;
},
{
package: {
'./': './dist/index.js',
'./typeRegistry': `${TYPE_REGISTRY_PATH}.js`,
'./akash/deployment/v1beta3/query':
'./dist/generated/akash/deployment/v1beta3/query.js',
},
tsconfig: {
'@akashnetwork/akash-api/typeRegistry': [TYPE_REGISTRY_PATH],
'@akashnetwork/akash-api/akash/deployment/v1beta3/query': [
'./dist/generated/akash/deployment/v1beta3/query',
],
},
},
);
return acc;
}, staticExports);

const tsconfigPaths = path.resolve(__dirname, '../tsconfig.paths.json');
fs.writeFileSync(
Expand Down
Loading

0 comments on commit 873447f

Please sign in to comment.