Skip to content

Commit

Permalink
fix: repository setup
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Sep 26, 2024
1 parent aafd1ad commit 0cd3cc9
Show file tree
Hide file tree
Showing 15 changed files with 18,874 additions and 1,269 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*.{js,ts,json}]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@stacks/eslint-config'],
};
1 change: 1 addition & 0 deletions .github/.husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx @commitlint/cli --extends @commitlint/config-conventional --edit $1
176 changes: 176 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Created by https://www.toptal.com/developers/gitignore/api/Node,macOS
# Edit at https://www.toptal.com/developers/gitignore?templates=Node,macOS

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit

# End of https://www.toptal.com/developers/gitignore/api/Node,macOS
Expand Down
2 changes: 2 additions & 0 deletions config/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const fetchMock = require('jest-fetch-mock');
fetchMock.enableFetchMocks();
13 changes: 13 additions & 0 deletions config/semantic-release.version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @type {import('semantic-release').GlobalConfig}
*/
export default {
dryRun: true,
debug: true,
branches: ['main', { name: 'next', prerelease: true }],
plugins: [
'@semantic-release/release-notes-generator',
// '@semantic-release/npm',
// '@semantic-release/github',
],
};
51 changes: 51 additions & 0 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const webpack = require('webpack');
const path = require('path');

// Run with ANALYZE ENV to show bundle size (only works with cjs)
// e.g.: ANALYZE=true npm run build
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const { DuplicatesPlugin } = require('inspectpack/plugin');

const NODE_ENV_PRODUCTION = 'production';
const NODE_ENV_DEVELOPMENT = 'development';

const isAnalyze = !!process.env.ANALYZE;
const isProduction = process.env.NODE_ENV === NODE_ENV_PRODUCTION;

module.exports = {
mode: isProduction ? NODE_ENV_PRODUCTION : NODE_ENV_DEVELOPMENT,
entry: ['./src/index.ts'],
output: {
library: {
name: 'StacksRpcClient',
type: isAnalyze ? 'commonjs' : 'umd',
},
filename: 'index.js',
path: path.resolve(process.cwd(), 'dist/umd'),
globalObject: 'this', // recommended for umd bundles in webpack
},
plugins: [
isAnalyze && new DuplicatesPlugin(),
isAnalyze && new BundleAnalyzerPlugin({ analyzerMode: 'static' }),
].filter(Boolean),
optimization: {
minimize: isProduction,
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'esbuild-loader',
options: {
target: 'es2017',
tsconfig: 'tsconfig.build.json',
},
},
],
},
],
},
};
26 changes: 24 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
const makeJestConfig = require('../../configs/jestConfig');
if (process.env.SKIP_TESTS) {
console.log('Skipping tests...');
process.exit(0);
}

module.exports = makeJestConfig(__dirname);
module.exports = packageDirname => {
return {
rootDir: packageDirname,
preset: 'ts-jest',
testEnvironment: 'node',
coverageDirectory: './coverage/',
collectCoverage: true,
globals: {
'ts-jest': {
tsconfig: './tsconfig.json',
diagnostics: {
ignoreCodes: ['TS151001'],
},
},
},
moduleFileExtensions: ['js', 'ts', 'd.ts'],
setupFilesAfterEnv: ['./config/jest.setup.js'],
testTimeout: 10_000,
};
};
Loading

0 comments on commit 0cd3cc9

Please sign in to comment.