setup - saltict/Demo-Docs GitHub Wiki
Detailed guide for setting up the development environment for the SubWallet Services SDK.
š Navigation
- System Requirements
- Development Environment Setup
- IDE Configuration
- Project Installation
- Environment Verification
- Troubleshooting Setup Issues
- macOS: 10.15 (Catalina) or later
- Windows: 10/11 with WSL2 recommended
- Linux: Ubuntu 18.04+, Debian 10+, or equivalent
- Version: 18.0.0 or higher (LTS recommended)
- Download: nodejs.org
Verification:
node --version # Should output v18.x.x or higher
npm --version # Should output 8.x.x or higher
Choose one of the following:
npm (included with Node.js):
npm --version
Yarn (optional, but recommended):
# Install Yarn globally
npm install -g yarn
# Verify installation
yarn --version # Should output 1.22.x or higher
pnpm (optional, fastest option):
# Install pnpm globally
npm install -g pnpm
# Verify installation
pnpm --version # Should output 7.x.x or higher
- Version: 2.30.0 or higher
- Download: git-scm.com
Verification:
git --version # Should output git version 2.30.x or higher
# Install Nx CLI globally
npm install -g @nx/cli
# Verify installation
nx --version
# Install TypeScript globally (optional, project includes local version)
npm install -g typescript
# Verify installation
tsc --version
Create environment configuration for development:
# Create .env file in project root
touch .env
Add the following environment variables:
# .env
NODE_ENV=development
SUBWALLET_API_URL=https://sw-services.subwallet.app
SUBWALLET_PLATFORM=webapp
SUBWALLET_CHAIN_LIST_VERSION=0.2.108
Configure Git for development:
# Set global Git configuration
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
# Configure line endings (important for cross-platform development)
git config --global core.autocrlf input # macOS/Linux
git config --global core.autocrlf true # Windows
Install these extensions for optimal development experience:
# Install VS Code extensions via command line
code --install-extension ms-vscode.vscode-typescript-next
code --install-extension esbenp.prettier-vscode
code --install-extension ms-vscode.vscode-eslint
code --install-extension nrwl.angular-console
code --install-extension bradlc.vscode-tailwindcss
Manual Installation:
- TypeScript and JavaScript Language Features - Enhanced TypeScript support
- Prettier - Code formatter - Code formatting
- ESLint - Linting and code quality
- Nx Console - Nx workspace management
- GitLens - Enhanced Git capabilities
Create or update .vscode/settings.json
in the project root:
{
"typescript.preferences.useAliasesForRenames": false,
"typescript.preferences.renameShorthandProperties": false,
"typescript.suggest.includeCompletionsForImportStatements": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
},
"files.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/.nx": true
},
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/.nx": true
}
}
Create .vscode/launch.json
for debugging:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--runInBand",
"--testPathPattern=subwallet-services-sdk"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"env": {
"NODE_ENV": "test"
}
}
]
}
- Import Project: Open the monorepo root directory
- Enable TypeScript Service: File ā Settings ā Languages & Frameworks ā TypeScript
- Configure Node.js: File ā Settings ā Languages & Frameworks ā Node.js
- Setup Run Configurations: Run ā Edit Configurations
- Nx Support - Nx workspace support
- Prettier - Code formatting
- ESLint - Code quality
# Clone the repository
git clone https://github.com/SubWallet/subwallet-monorepos.git
# Navigate to project directory
cd subwallet-monorepos
# Install all dependencies
npm install
# Verify installation
npm list --depth=0
# Install all dependencies
yarn install
# Verify installation
yarn list --depth=0
# Install all dependencies
pnpm install
# Verify installation
pnpm list --depth=0
# Build the SubWallet Services SDK
nx build subwallet-services-sdk
# Verify build success
ls -la dist/libs/subwallet-services-sdk/
# Run all tests for the SDK
nx test subwallet-services-sdk
# Run tests in watch mode
nx test subwallet-services-sdk --watch
# Lint the SDK code
nx lint subwallet-services-sdk
# Auto-fix linting issues
nx lint subwallet-services-sdk --fix
Create a verification script to ensure everything is set up correctly:
// scripts/verify-setup.ts
import { execSync } from 'child_process';
import { existsSync } from 'fs';
interface CheckResult {
name: string;
status: 'pass' | 'fail';
message: string;
}
const checks: CheckResult[] = [];
// Check Node.js version
try {
const nodeVersion = execSync('node --version', { encoding: 'utf8' }).trim();
const majorVersion = parseInt(nodeVersion.slice(1).split('.')[0]);
checks.push({
name: 'Node.js Version',
status: majorVersion >= 18 ? 'pass' : 'fail',
message: `${nodeVersion} ${majorVersion >= 18 ? 'ā' : 'ā (requires v18+)'}`
});
} catch {
checks.push({
name: 'Node.js Version',
status: 'fail',
message: 'Node.js not found'
});
}
// Check npm version
try {
const npmVersion = execSync('npm --version', { encoding: 'utf8' }).trim();
checks.push({
name: 'npm Version',
status: 'pass',
message: `${npmVersion} ā`
});
} catch {
checks.push({
name: 'npm Version',
status: 'fail',
message: 'npm not found'
});
}
// Check if node_modules exists
checks.push({
name: 'Dependencies Installed',
status: existsSync('node_modules') ? 'pass' : 'fail',
message: existsSync('node_modules') ? 'node_modules found ā' : 'node_modules not found ā'
});
// Check if SDK can be built
try {
execSync('nx build subwallet-services-sdk', { stdio: 'ignore' });
checks.push({
name: 'SDK Build',
status: 'pass',
message: 'Build successful ā'
});
} catch {
checks.push({
name: 'SDK Build',
status: 'fail',
message: 'Build failed ā'
});
}
// Check if tests pass
try {
execSync('nx test subwallet-services-sdk --passWithNoTests', { stdio: 'ignore' });
checks.push({
name: 'Tests',
status: 'pass',
message: 'All tests pass ā'
});
} catch {
checks.push({
name: 'Tests',
status: 'fail',
message: 'Tests failed ā'
});
}
// Display results
console.log('\nš Environment Verification Results\n');
checks.forEach(check => {
const status = check.status === 'pass' ? 'ā
' : 'ā';
console.log(`${status} ${check.name}: ${check.message}`);
});
const failedChecks = checks.filter(check => check.status === 'fail');
if (failedChecks.length === 0) {
console.log('\nš All checks passed! Your environment is ready for development.');
} else {
console.log(`\nā ļø ${failedChecks.length} check(s) failed. Please fix the issues above.`);
process.exit(1);
}
Run the verification:
# Run verification script
npx ts-node scripts/verify-setup.ts
# Verify SDK directory structure
ls -la libs/subwallet-services-sdk/
# Should show: src/, docs/, package.json, project.json, etc.
# Check if SDK dependencies are installed
npm list @subwallet-monorepos/subwallet-services-sdk
# Create a simple test file
cat > test-sdk.js << 'EOF'
const sdk = require('./dist/libs/subwallet-services-sdk');
console.log('SDK loaded successfully');
console.log('SDK version:', sdk.default?.version || 'unknown');
EOF
# Run the test
node test-sdk.js
# Clean up
rm test-sdk.js
# If using nvm (Node Version Manager)
nvm install 18
nvm use 18
# If using Homebrew (macOS)
brew install node@18
brew link node@18
# Fix npm permissions (macOS/Linux)
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules
# Or use a Node version manager like nvm
# Clear caches and reinstall
npm run clean # or yarn clean
rm -rf node_modules
rm -rf dist
npm install
# Restart TypeScript service in VS Code
# Command Palette: "TypeScript: Restart TS Server"
# Or reinstall TypeScript
npm uninstall -g typescript
npm install -g typescript@latest
# Configure Git for proper line endings
git config --global core.autocrlf true
git config --global core.eol lf
# Re-clone the repository if necessary
# Install WSL2 Ubuntu
wsl --install -d Ubuntu
# In WSL2, install Node.js via nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 18
nvm use 18
# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Node.js
brew install node@18
brew link node@18
# Install Node.js via NodeSource repository
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# Verify installation
node --version
npm --version
š Related Documentation