Skip to content

Commit

Permalink
feat(chain-registry): ✨ add chain-registry package
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideSegullo committed Oct 23, 2023
1 parent 1348282 commit 9687838
Show file tree
Hide file tree
Showing 24 changed files with 3,977 additions and 80 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
35 changes: 35 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
}
]
}
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
/.nx/cache
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
28 changes: 28 additions & 0 deletions .verdaccio/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# path to a directory with all packages
storage: ../tmp/local-registry/storage

# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
maxage: 60m

packages:
'**':
# give all users (including non-authenticated users) full access
# because it is a local registry
access: $all
publish: $all
unpublish: $all

# if package is not available locally, proxy requests to npm registry
proxy: npmjs

# log settings
logs:
type: stdout
format: pretty
level: warn

publish:
allow_offline: true # set offline to true to allow publish offline
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"recommendations": [

"nrwl.angular-console",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"typescript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.importModuleSpecifierEnding": "minimal"
}
31 changes: 17 additions & 14 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,34 @@
"targetDefaults": {
"build": {
"cache": true,
"dependsOn": [
"^build"
],
"inputs": [
"production",
"^production"
]
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"lint": {
"cache": true
"cache": true,
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore",
"{workspaceRoot}/eslint.config.js"
]
},
"test": {
"cache": true
"cache": true,
"inputs": ["default", "^production"]
},
"e2e": {
"cache": true
}
},
"namedInputs": {
"default": [
"{projectRoot}/**/*",
"sharedGlobals"
],
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default"
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/eslint.config.js"
],
"sharedGlobals": []
}
Expand Down
25 changes: 23 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,31 @@
"license": "MIT",
"scripts": {},
"private": true,
"dependencies": {},
"devDependencies": {
"@nx/eslint": "17.0.1",
"@nx/eslint-plugin": "17.0.1",
"@nx/js": "17.0.1",
"@nx/vite": "^17.0.1",
"@nx/workspace": "17.0.1",
"nx": "17.0.1"
"@swc-node/register": "~1.6.7",
"@swc/core": "~1.3.85",
"@types/node": "18.7.1",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"@vitest/coverage-c8": "~0.32.0",
"@vitest/ui": "~0.32.0",
"eslint": "~8.46.0",
"eslint-config-prettier": "^9.0.0",
"nx": "17.0.1",
"prettier": "^2.6.2",
"tslib": "^2.6.2",
"typescript": "~5.1.3",
"verdaccio": "^5.0.4",
"vite": "~4.3.9",
"vite-plugin-dts": "~2.3.0",
"vitest": "~0.32.0"
},
"nx": {
"includedScripts": []
}
}
30 changes: 30 additions & 0 deletions packages/chain-registry/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["{projectRoot}/vite.config.{js,ts,mjs,mts}"]
}
]
}
}
]
}
11 changes: 11 additions & 0 deletions packages/chain-registry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# chain-registry

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build chain-registry` to build the library.

## Running unit tests

Run `nx test chain-registry` to execute the unit tests via [Jest](https://jestjs.io).
8 changes: 8 additions & 0 deletions packages/chain-registry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@nabla-studio/chain-registry",
"version": "0.0.1",
"dependencies": {},
"main": "./index.js",
"module": "./index.mjs",
"typings": "./index.d.ts"
}
38 changes: 38 additions & 0 deletions packages/chain-registry/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "chain-registry",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/chain-registry/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/vite:build",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/chain-registry"
}
},
"publish": {
"command": "node tools/scripts/publish.mjs chain-registry {args.ver} {args.tag}",
"dependsOn": ["build"]
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{options.reportsDirectory}"],
"options": {
"passWithNoTests": true,
"reportsDirectory": "../../coverage/packages/chain-registry"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"packages/chain-registry/**/*.ts",
"packages/chain-registry/package.json"
]
}
}
},
"tags": []
}
1 change: 1 addition & 0 deletions packages/chain-registry/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/chain-registry';
7 changes: 7 additions & 0 deletions packages/chain-registry/src/lib/chain-registry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { chainRegistry } from './chain-registry';

describe('chainRegistry', () => {
it('should work', () => {
expect(chainRegistry()).toEqual('chain-registry');
});
});
3 changes: 3 additions & 0 deletions packages/chain-registry/src/lib/chain-registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function chainRegistry(): string {
return 'chain-registry';
}
22 changes: 22 additions & 0 deletions packages/chain-registry/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions packages/chain-registry/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node", "vite/client"]
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
25 changes: 25 additions & 0 deletions packages/chain-registry/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
},
"include": [
"vite.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
50 changes: 50 additions & 0 deletions packages/chain-registry/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/// <reference types='vitest' />
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import * as path from 'path';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

export default defineConfig({
cacheDir: '../../node_modules/.vite/chain-registry',

plugins: [
nxViteTsPaths(),
dts({
entryRoot: 'src',
tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
skipDiagnostics: true,
}),
],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

// Configuration for building your library.
// See: https://vitejs.dev/guide/build.html#library-mode
build: {
lib: {
// Could also be a dictionary or array of multiple entry points.
entry: 'src/index.ts',
name: 'chain-registry',
fileName: 'index',
// Change this to the formats you want to support.
// Don't forget to update your package.json as well.
formats: ['es', 'cjs'],
},
rollupOptions: {
// External packages that should not be bundled into your library.
external: [],
},
},

test: {
globals: true,
cache: {
dir: '../../node_modules/.vitest',
},
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
},
});
Loading

0 comments on commit 9687838

Please sign in to comment.