From 889cafbdfb0ff3a9b0ac8c589295d39d9f7445a9 Mon Sep 17 00:00:00 2001 From: JaCoderX Date: Sun, 15 Feb 2026 01:54:54 +0200 Subject: [PATCH] chore: update version numbers to 1.0.0-alpha.11 and enhance release scripts This commit updates the version numbers in package.json and related files to 1.0.0-alpha.11, reflecting the latest changes in the project. Additionally, it introduces a new release preparation script to streamline the pre-publication process, ensuring proper version synchronization, ABI extraction, and package validation. The cleanup process after publishing has also been improved by removing the copied core directory. --- contracts/standards/behavior/ICopyable.sol | 6 +- package.json | 11 +- package/package.json | 2 +- package/scripts/postpublish-contracts.cjs | 6 + scripts/release-prepare.cjs | 307 +++++++++++++++++ scripts/test-packages.cjs | 383 --------------------- sdk/typescript/package.json | 4 +- 7 files changed, 322 insertions(+), 397 deletions(-) create mode 100644 scripts/release-prepare.cjs delete mode 100644 scripts/test-packages.cjs diff --git a/contracts/standards/behavior/ICopyable.sol b/contracts/standards/behavior/ICopyable.sol index 84a3326a..0102e07c 100644 --- a/contracts/standards/behavior/ICopyable.sol +++ b/contracts/standards/behavior/ICopyable.sol @@ -7,13 +7,11 @@ pragma solidity 0.8.33; * * Bloxes implementing this interface can be cloned by factory patterns (e.g. CopyBlox, * FactoryBlox) and initialized in one call with owner/broadcaster/recovery/timelock/ - * eventForwarder plus arbitrary init data, or have clone-specific data set via - * setCloneData. + * eventForwarder plus arbitrary init data, or have clone-specific data set * * Use cases: * - Clone and init in one step: factory calls initializeWithData(..., initData). - * - Clone with standard init then set clone data: factory calls initialize(...) - * then the deployer or factory calls setCloneData(initData). + * - Clone with standard init then set clone data: factory calls initializeWithData(...) */ interface ICopyable { /** diff --git a/package.json b/package.json index 9a8f6a6a..434d519a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Bloxchain", - "version": "1.0.0-alpha.8", + "version": "1.0.0-alpha.11", "description": "Library engine for building enterprise grade decentralized permissioned applications", "type": "module", "main": "truffle-config.cjs", @@ -38,17 +38,14 @@ "test:sanity-sdk:examples": "npx tsx --tsconfig scripts/sanity-sdk/tsconfig.json scripts/sanity-sdk/run-all-tests.ts --examples", "test:sanity-sdk:all": "npx tsx --tsconfig scripts/sanity-sdk/tsconfig.json scripts/sanity-sdk/run-all-tests.ts --all", "test:e2e": "npm run deploy:truffle && npm run test:sanity:core && npm run test:sanity-sdk:core", - "test:packages": "node scripts/test-packages.cjs", "extract-abi": "node scripts/extract-abi.cjs", "release:sync-versions": "node scripts/sync-versions.cjs", - "release:sync-versions:tag:alpha": "node scripts/sync-versions.cjs --tag alpha.8", "build:sdk": "cd sdk/typescript && npm run build", "build:sdk:clean": "cd sdk/typescript && npm run clean && npm run build", - "prepublish:sdk": "npm run release:sync-versions && npm run extract-abi && npm run build:sdk", - "prepublish:contracts": "npm run release:sync-versions", "generate:contracts-lock": "cd package && npm install --package-lock-only", - "publish:contracts": "npm run prepublish:contracts && cd package && npm publish --tag alpha.8", - "publish:sdk": "npm run prepublish:sdk && cd sdk/typescript && npm publish --tag alpha.8", + "release:prepare": "node scripts/release-prepare.cjs", + "publish:contracts": "npm run release:prepare && cd package && npm publish --tag alpha.11", + "publish:sdk": "npm run release:sync-versions && npm run extract-abi && npm run build:sdk && cd sdk/typescript && npm publish --tag alpha.11", "docgen": "npm run compile:hardhat && cd docgen && npm run docgen", "docgen:install": "cd docgen && npm install", "format": "prettier --config .prettierrc --write \"contracts/**/*.sol\"", diff --git a/package/package.json b/package/package.json index aaaa4947..754c59ff 100644 --- a/package/package.json +++ b/package/package.json @@ -1,6 +1,6 @@ { "name": "@bloxchain/contracts", - "version": "1.0.0-alpha.8", + "version": "1.0.0-alpha.11", "description": "Library engine for building enterprise grade decentralized permissioned applications", "files": [ "core", diff --git a/package/scripts/postpublish-contracts.cjs b/package/scripts/postpublish-contracts.cjs index c923900e..0ef26af2 100644 --- a/package/scripts/postpublish-contracts.cjs +++ b/package/scripts/postpublish-contracts.cjs @@ -9,6 +9,7 @@ const copiedContractsDir = path.join(contractsDir, 'contracts'); const copiedAbiDir = path.join(contractsDir, 'abi'); const copiedStandardsDir = path.join(contractsDir, 'standards'); const copiedComponentsDir = path.join(contractsDir, 'components'); +const copiedCoreDir = path.join(contractsDir, 'core'); console.log('๐Ÿงน Cleaning up after publish...\n'); @@ -32,4 +33,9 @@ if (fs.existsSync(copiedComponentsDir)) { console.log('โœ… Removed copied components directory'); } +if (fs.existsSync(copiedCoreDir)) { + fs.rmSync(copiedCoreDir, { recursive: true, force: true }); + console.log('โœ… Removed copied core directory'); +} + console.log('\nโœ… Cleanup complete!'); diff --git a/scripts/release-prepare.cjs b/scripts/release-prepare.cjs new file mode 100644 index 00000000..5bc3dd90 --- /dev/null +++ b/scripts/release-prepare.cjs @@ -0,0 +1,307 @@ +#!/usr/bin/env node +// release-prepare.cjs +// Single-command pre-publication: sync versions, extract ABIs, prepare package, test, verify. +// Usage: npm run release:prepare (from repo root) +// Env: SKIP_TESTS=1 | PREPARE_CONTRACTS_ONLY=1 | DEBUG=1 + +const fs = require('fs'); +const path = require('path'); +const { execSync } = require('child_process'); + +const rootDir = path.resolve(__dirname, '..'); +const contractsPackageDir = path.join(rootDir, 'package'); +const sdkPackageDir = path.join(rootDir, 'sdk', 'typescript'); + +const SKIP_TESTS = process.env.SKIP_TESTS === '1'; +const PREPARE_CONTRACTS_ONLY = process.env.PREPARE_CONTRACTS_ONLY === '1'; +const DEBUG = process.env.DEBUG === '1'; + +const colors = { + reset: '\x1b[0m', + bright: '\x1b[1m', + green: '\x1b[32m', + red: '\x1b[31m', + yellow: '\x1b[33m', + cyan: '\x1b[36m', +}; + +function log(message, color = 'reset') { + console.log(`${colors[color]}${message}${colors.reset}`); +} + +function logStep(step, message) { + log(`\n${step} ${message}`, 'cyan'); +} + +function logSuccess(message) { + log(`โœ… ${message}`, 'green'); +} + +function logError(message) { + log(`โŒ ${message}`, 'red'); +} + +function logWarning(message) { + log(`โš ๏ธ ${message}`, 'yellow'); +} + +function fail(message) { + logError(message); + throw new Error(message); +} + +const REQUIRED_PACKAGE_JSON_FIELDS = ['name', 'version', 'description', 'license']; + +function validatePackageJson(packagePath, packageName) { + const packageJsonPath = path.join(packagePath, 'package.json'); + if (!fs.existsSync(packageJsonPath)) { + fail(`${packageName}: package.json not found`); + } + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); + for (const field of REQUIRED_PACKAGE_JSON_FIELDS) { + if (!packageJson[field]) { + fail(`${packageName}: missing required field '${field}' in package.json`); + } + } + if (!/^\d+\.\d+\.\d+/.test(packageJson.version)) { + fail(`${packageName}: invalid version format '${packageJson.version}' (expected semver)`); + } + return packageJson; +} + +function exec(command, options = {}) { + const defaultOptions = { + cwd: rootDir, + stdio: 'inherit', + encoding: 'utf8', + shell: true, + }; + try { + execSync(command, { ...defaultOptions, ...options }); + return true; + } catch (error) { + if (DEBUG && error.stack) { + log('\n' + error.stack, 'yellow'); + } + throw error; + } +} + +function execInPackage(dir, command, options = {}) { + try { + execSync(command, { + cwd: dir, + stdio: 'inherit', + encoding: 'utf8', + shell: true, + ...options, + }); + return true; + } catch (error) { + if (DEBUG && error.stack) { + log('\n' + error.stack, 'yellow'); + } + throw error; + } +} + +function syncVersions() { + logStep('๐Ÿ“‹', 'Step 1: Syncing versions...'); + exec('npm run release:sync-versions'); + const rootPkg = JSON.parse(fs.readFileSync(path.join(rootDir, 'package.json'), 'utf8')); + const contractsPkg = JSON.parse(fs.readFileSync(path.join(contractsPackageDir, 'package.json'), 'utf8')); + if (rootPkg.version !== contractsPkg.version) { + fail(`Version mismatch: root ${rootPkg.version} vs package ${contractsPkg.version}`); + } + logSuccess('Versions synced and verified'); +} + +function extractAbi() { + logStep('๐Ÿ“‹', 'Step 2: Extracting ABIs...'); + exec('npm run extract-abi'); + const rootAbiDir = path.join(rootDir, 'abi'); + if (!fs.existsSync(rootAbiDir)) { + fail('abi/ directory not found after extract-abi'); + } + const abiFiles = fs.readdirSync(rootAbiDir).filter((f) => f.endsWith('.abi.json')); + if (abiFiles.length === 0) { + fail('No .abi.json files in abi/ after extract-abi'); + } + logSuccess('ABIs extracted and verified'); +} + +function getSolPathsRecursive(dir, baseDir, excludedDirs) { + const results = []; + const entries = fs.readdirSync(dir, { withFileTypes: true }); + for (const entry of entries) { + const fullPath = path.join(dir, entry.name); + const relPath = path.relative(baseDir, fullPath); + if (entry.isDirectory()) { + if (excludedDirs.includes(entry.name)) continue; + results.push(...getSolPathsRecursive(fullPath, baseDir, excludedDirs)); + } else if (entry.name.endsWith('.sol')) { + results.push(relPath); + } + } + return results; +} + +function prepareContractsPackage() { + logStep('๐Ÿ“‹', 'Step 3: Preparing @bloxchain/contracts package...'); + execInPackage(contractsPackageDir, 'node scripts/prepublish-contracts.cjs'); + const coreDir = path.join(contractsPackageDir, 'core'); + const abiDir = path.join(contractsPackageDir, 'abi'); + if (!fs.existsSync(coreDir)) { + fail('package/core/ not found after prepare'); + } + if (!fs.existsSync(abiDir)) { + fail('package/abi/ not found after prepare'); + } + if (fs.readdirSync(coreDir).length === 0) { + fail('package/core/ is empty after prepare'); + } + if (fs.readdirSync(abiDir).length === 0) { + fail('package/abi/ is empty after prepare'); + } + const sourceContractsDir = path.join(rootDir, 'contracts'); + const excludedDirs = ['examples', 'experimental']; + const expectedSolPaths = getSolPathsRecursive(sourceContractsDir, sourceContractsDir, excludedDirs); + const missing = expectedSolPaths.filter( + (rel) => !fs.existsSync(path.join(contractsPackageDir, rel)) + ); + if (missing.length > 0) { + fail( + 'Package layout mismatch: missing .sol files (expected from contracts/, excluding examples & experimental):\n ' + + missing.join('\n ') + ); + } + logSuccess('Contracts package prepared and verified (layout matches contracts/)'); +} + +function runTests() { + if (SKIP_TESTS) { + logWarning('Skipping tests (SKIP_TESTS=1)'); + return; + } + logStep('๐Ÿ“‹', 'Step 4: Running tests...'); + exec('npm run test:foundry'); + logSuccess('Foundry tests passed'); + // Sanity tests require deploy/chain; optional for prepare + log('Running sanity:core (may require deployed contracts)...', 'yellow'); + const sanityOk = exec('npm run test:sanity:core', { throwOnError: false }); + if (!sanityOk) { + logWarning('test:sanity:core failed or skipped; continuing. Run manually if needed.'); + } else { + logSuccess('Sanity core tests passed'); + } + log('Running sanity-sdk:core (may require deployed contracts)...', 'yellow'); + const sanitySdkOk = exec('npm run test:sanity-sdk:core', { throwOnError: false }); + if (!sanitySdkOk) { + logWarning('test:sanity-sdk:core failed or skipped; continuing. Run manually if needed.'); + } else { + logSuccess('Sanity SDK tests passed'); + } +} + +function verifyContractsPackage() { + logStep('๐Ÿ“‹', 'Step 5: Verifying @bloxchain/contracts package...'); + const packageJson = validatePackageJson(contractsPackageDir, '@bloxchain/contracts'); + const files = packageJson.files || []; + for (const name of files) { + if (name === 'README.md') continue; + const fullPath = path.join(contractsPackageDir, name); + if (!fs.existsSync(fullPath)) { + fail(`Required package file missing: ${name}`); + } + } + logSuccess('Required files present'); + let packOutput; + try { + packOutput = execSync('npm pack --dry-run 2>&1', { + cwd: contractsPackageDir, + encoding: 'utf8', + shell: true, + }); + } catch (error) { + fail('npm pack --dry-run failed: ' + error.message); + } + const requiredInPack = ['core', 'abi', 'standards']; + for (const dir of requiredInPack) { + if (!new RegExp(dir + '[/\\\\]').test(packOutput)) { + fail(`npm pack output missing ${dir}/`); + } + } + logSuccess('npm pack --dry-run OK'); +} + +function prepareSdk() { + if (PREPARE_CONTRACTS_ONLY) { + logWarning('Skipping SDK prepare (PREPARE_CONTRACTS_ONLY=1)'); + return; + } + logStep('๐Ÿ“‹', 'Step 6: Preparing @bloxchain/sdk...'); + exec('npm run build:sdk'); + validatePackageJson(sdkPackageDir, '@bloxchain/sdk'); + const distPath = path.join(sdkPackageDir, 'dist'); + if (!fs.existsSync(path.join(distPath, 'index.js'))) { + fail('SDK dist/index.js not found after build'); + } + if (!fs.existsSync(path.join(distPath, 'index.d.ts'))) { + fail('SDK dist/index.d.ts not found after build'); + } + let packOutput; + try { + packOutput = execSync('npm pack --dry-run 2>&1', { + cwd: sdkPackageDir, + encoding: 'utf8', + shell: true, + }); + } catch (error) { + fail('SDK npm pack --dry-run failed: ' + error.message); + } + const hasDist = /dist[/\\]/.test(packOutput); + if (!hasDist) fail('SDK npm pack output missing dist/'); + logSuccess('SDK prepared and verified'); +} + +function printSummary() { + log('\n' + '='.repeat(60), 'bright'); + log('โœ… Release prepare complete', 'green'); + log('='.repeat(60) + '\n', 'bright'); + log('Ready to publish. Run:', 'cyan'); + log(' npm login', 'yellow'); + log(' npm run publish:contracts', 'yellow'); + log(' npm run publish:sdk', 'yellow'); + log('\nOr manually:', 'cyan'); + log(' cd package && npm publish --tag alpha.11', 'yellow'); + log(' cd sdk/typescript && npm publish --tag alpha.11', 'yellow'); + log(''); +} + +function main() { + log('\n' + '='.repeat(60), 'bright'); + log('๐Ÿ“ฆ Release Prepare', 'bright'); + log('='.repeat(60), 'bright'); + try { + syncVersions(); + extractAbi(); + prepareContractsPackage(); + runTests(); + verifyContractsPackage(); + prepareSdk(); + printSummary(); + process.exit(0); + } catch (error) { + log('\n' + '='.repeat(60), 'bright'); + logError('Release prepare failed'); + log('='.repeat(60) + '\n', 'bright'); + logError(error.message); + process.exit(1); + } +} + +if (require.main === module) { + main(); +} + +module.exports = { main }; diff --git a/scripts/test-packages.cjs b/scripts/test-packages.cjs deleted file mode 100644 index 2a749e1b..00000000 --- a/scripts/test-packages.cjs +++ /dev/null @@ -1,383 +0,0 @@ -#!/usr/bin/env node -// test-packages.cjs -// Tests package readiness for both @bloxchain/contracts and @bloxchain/sdk -// This script cleans the root, prepares each package, and validates they're ready for publishing - -const fs = require('fs'); -const path = require('path'); -const { execSync } = require('child_process'); - -const rootDir = path.resolve(__dirname, '..'); -const contractsPackageDir = path.join(rootDir, 'package'); -const sdkPackageDir = path.join(rootDir, 'sdk', 'typescript'); - -// Colors for console output -const colors = { - reset: '\x1b[0m', - bright: '\x1b[1m', - green: '\x1b[32m', - red: '\x1b[31m', - yellow: '\x1b[33m', - blue: '\x1b[34m', - cyan: '\x1b[36m', -}; - -function log(message, color = 'reset') { - console.log(`${colors[color]}${message}${colors.reset}`); -} - -function logStep(step, message) { - log(`\n${step} ${message}`, 'cyan'); -} - -function logSuccess(message) { - log(`โœ… ${message}`, 'green'); -} - -function logError(message) { - log(`โŒ ${message}`, 'red'); -} - -function logWarning(message) { - log(`โš ๏ธ ${message}`, 'yellow'); -} - -function exec(command, options = {}) { - const defaultOptions = { - cwd: rootDir, - stdio: 'inherit', - encoding: 'utf8', - shell: true, // Use shell on Windows for better compatibility - }; - const mergedOptions = { ...defaultOptions, ...options }; - try { - execSync(command, mergedOptions); - return true; - } catch (error) { - if (options.throwOnError !== false) { - throw error; - } - return false; - } -} - -function cleanRoot() { - logStep('๐Ÿงน', 'Cleaning root directory...'); - - const nodeModulesPath = path.join(rootDir, 'node_modules'); - const packageLockPath = path.join(rootDir, 'package-lock.json'); - - let cleaned = false; - - if (fs.existsSync(nodeModulesPath)) { - log('Removing node_modules...', 'yellow'); - try { - fs.rmSync(nodeModulesPath, { recursive: true, force: true }); - logSuccess('Removed node_modules'); - cleaned = true; - } catch (error) { - logError(`Failed to remove node_modules: ${error.message}`); - logWarning('Continuing anyway...'); - } - } else { - log('node_modules not found, skipping...', 'yellow'); - } - - if (fs.existsSync(packageLockPath)) { - log('Removing package-lock.json...', 'yellow'); - try { - fs.unlinkSync(packageLockPath); - logSuccess('Removed package-lock.json'); - cleaned = true; - } catch (error) { - logError(`Failed to remove package-lock.json: ${error.message}`); - logWarning('Continuing anyway...'); - } - } else { - log('package-lock.json not found, skipping...', 'yellow'); - } - - if (cleaned) { - logSuccess('Root directory cleaned'); - } else { - log('Root directory was already clean', 'yellow'); - } -} - -function validatePackageJson(packagePath, packageName) { - log(`Validating ${packageName} package.json...`, 'yellow'); - - const packageJsonPath = path.join(packagePath, 'package.json'); - if (!fs.existsSync(packageJsonPath)) { - throw new Error(`${packageName}: package.json not found`); - } - - const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); - - // Required fields - const requiredFields = ['name', 'version', 'description', 'license']; - for (const field of requiredFields) { - if (!packageJson[field]) { - throw new Error(`${packageName}: Missing required field '${field}' in package.json`); - } - } - - // Check version format - if (!/^\d+\.\d+\.\d+/.test(packageJson.version)) { - throw new Error(`${packageName}: Invalid version format '${packageJson.version}'`); - } - - logSuccess(`${packageName} package.json is valid`); - return packageJson; -} - -function validatePackageFiles(packagePath, packageName, packageJson) { - log(`Validating ${packageName} files...`, 'yellow'); - - if (!packageJson.files || !Array.isArray(packageJson.files)) { - logWarning(`${packageName}: No 'files' field in package.json, all files will be included`); - return; - } - - const missingFiles = []; - for (const filePattern of packageJson.files) { - const filePath = path.join(packagePath, filePattern); - - // Handle glob patterns (simple check) - if (filePattern.includes('*')) { - // For now, just check if the directory exists - const dirPath = path.dirname(filePath); - if (!fs.existsSync(dirPath)) { - missingFiles.push(filePattern); - } - } else { - if (!fs.existsSync(filePath)) { - missingFiles.push(filePattern); - } - } - } - - if (missingFiles.length > 0) { - throw new Error( - `${packageName}: Missing required files: ${missingFiles.join(', ')}` - ); - } - - logSuccess(`${packageName} all required files are present`); -} - -function testContractsPackage() { - logStep('๐Ÿ“ฆ', 'Testing @bloxchain/contracts package...'); - - // Validate package.json - const packageJson = validatePackageJson(contractsPackageDir, '@bloxchain/contracts'); - - // Run prepublish script - log('Running prepublish script...', 'yellow'); - try { - exec('npm run prepublishOnly', { cwd: contractsPackageDir }); - logSuccess('Prepublish script completed'); - } catch (error) { - throw new Error('Prepublish script failed: ' + error.message); - } - - // Validate files - validatePackageFiles(contractsPackageDir, '@bloxchain/contracts', packageJson); - - // Test npm pack - log('Testing npm pack (dry-run)...', 'yellow'); - let packOutput; - try { - packOutput = execSync('npm pack --dry-run 2>&1', { - cwd: contractsPackageDir, - encoding: 'utf8', - shell: true, - }); - logSuccess('npm pack dry-run successful'); - - // Check that expected files are in the pack (core and abi at package root) - const hasCore = /core\//.test(packOutput); - const hasAbi = /abi\//.test(packOutput); - - if (!hasCore) { - logWarning('core/ directory not found in pack output'); - } - if (!hasAbi) { - logWarning('ABI directory not found in pack output'); - } - - logSuccess('Package structure looks good'); - } catch (error) { - throw new Error('npm pack dry-run failed: ' + error.message); - } - - logSuccess('@bloxchain/contracts package is ready for publishing'); -} - -function testSdkPackage() { - logStep('๐Ÿ“ฆ', 'Testing @bloxchain/sdk package...'); - - // Validate package.json - const packageJson = validatePackageJson(sdkPackageDir, '@bloxchain/sdk'); - - // Check if dist directory exists or needs to be built - const distPath = path.join(sdkPackageDir, 'dist'); - const sdkNodeModules = path.join(sdkPackageDir, 'node_modules'); - - if (!fs.existsSync(distPath)) { - log('dist directory not found, building SDK...', 'yellow'); - - // Install SDK dependencies if needed (for TypeScript compiler) - if (!fs.existsSync(sdkNodeModules)) { - log('Installing SDK dependencies...', 'yellow'); - try { - exec('npm install', { cwd: sdkPackageDir }); - logSuccess('SDK dependencies installed'); - } catch (error) { - throw new Error('Failed to install SDK dependencies: ' + error.message); - } - } else { - log('SDK node_modules found, skipping install...', 'yellow'); - } - - try { - exec('npm run build', { cwd: sdkPackageDir }); - logSuccess('SDK build completed'); - } catch (error) { - throw new Error('SDK build failed: ' + error.message); - } - } else { - log('dist directory found, skipping build...', 'yellow'); - } - - // Run prepublish script - log('Running prepublish script...', 'yellow'); - try { - exec('npm run prepublishOnly', { cwd: sdkPackageDir }); - logSuccess('Prepublish script completed'); - } catch (error) { - throw new Error('Prepublish script failed: ' + error.message); - } - - // Validate files - validatePackageFiles(sdkPackageDir, '@bloxchain/sdk', packageJson); - - // Check dist files - if (!fs.existsSync(path.join(distPath, 'index.js'))) { - throw new Error('@bloxchain/sdk: dist/index.js not found'); - } - if (!fs.existsSync(path.join(distPath, 'index.d.ts'))) { - throw new Error('@bloxchain/sdk: dist/index.d.ts not found'); - } - logSuccess('SDK dist files are present'); - - // Test npm pack - log('Testing npm pack (dry-run)...', 'yellow'); - try { - const packOutput = execSync('npm pack --dry-run 2>&1', { - cwd: sdkPackageDir, - encoding: 'utf8', - shell: true, - }); - logSuccess('npm pack dry-run successful'); - - // Check that expected files are in the pack - // Look for dist files (dist/index.js, dist/contracts/, etc.) - const hasDist = packOutput.includes('dist/') || packOutput.includes('dist\\'); - const hasAbi = packOutput.includes('abi/') || packOutput.includes('abi\\'); - - if (!hasDist) { - throw new Error('dist directory not found in pack output'); - } - if (!hasAbi) { - logWarning('ABI directory not found in pack output'); - } - - logSuccess('Package structure looks good'); - } catch (error) { - throw new Error('npm pack dry-run failed: ' + error.message); - } - - logSuccess('@bloxchain/sdk package is ready for publishing'); -} - -function checkPrerequisites() { - logStep('๐Ÿ”', 'Checking prerequisites...'); - - // Check npm - try { - const npmVersion = execSync('npm --version', { encoding: 'utf8' }).trim(); - logSuccess(`npm is available (version ${npmVersion})`); - } catch (error) { - throw new Error('npm is not available. Please install Node.js and npm.'); - } - - // Check node - try { - const nodeVersion = execSync('node --version', { encoding: 'utf8' }).trim(); - logSuccess(`Node.js is available (version ${nodeVersion})`); - } catch (error) { - throw new Error('Node.js is not available. Please install Node.js.'); - } - - // Check package directories exist - if (!fs.existsSync(contractsPackageDir)) { - throw new Error(`Contracts package directory not found: ${contractsPackageDir}`); - } - if (!fs.existsSync(sdkPackageDir)) { - throw new Error(`SDK package directory not found: ${sdkPackageDir}`); - } - - logSuccess('All prerequisites met'); -} - -function main() { - log('\n' + '='.repeat(60), 'bright'); - log('๐Ÿงช Package Readiness Test', 'bright'); - log('='.repeat(60) + '\n', 'bright'); - - try { - // Step 0: Check prerequisites - checkPrerequisites(); - - // Step 1: Clean root - cleanRoot(); - - // Step 2: Test contracts package - testContractsPackage(); - - // Step 3: Test SDK package - testSdkPackage(); - - // Summary - log('\n' + '='.repeat(60), 'bright'); - log('โœ… All packages are ready for publishing!', 'green'); - log('='.repeat(60) + '\n', 'bright'); - - log('Next steps:', 'cyan'); - log(' 1. Review the package contents above', 'yellow'); - log(' 2. Run: npm run publish:contracts', 'yellow'); - log(' 3. Run: npm run publish:sdk', 'yellow'); - log(''); - - process.exit(0); - } catch (error) { - log('\n' + '='.repeat(60), 'bright'); - logError('Package test failed!'); - log('='.repeat(60) + '\n', 'bright'); - logError(error.message); - if (error.stack && process.env.DEBUG) { - log('\nStack trace:', 'yellow'); - log(error.stack, 'yellow'); - } - log(''); - process.exit(1); - } -} - -// Run if called directly -if (require.main === module) { - main(); -} - -module.exports = { main, testContractsPackage, testSdkPackage, cleanRoot }; diff --git a/sdk/typescript/package.json b/sdk/typescript/package.json index 2b5cf2c1..7f1b4d62 100644 --- a/sdk/typescript/package.json +++ b/sdk/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@bloxchain/sdk", - "version": "1.0.0-alpha.8", + "version": "1.0.0-alpha.11", "description": "Library engine for building enterprise grade decentralized permissioned applications", "type": "module", "main": "./dist/index.js", @@ -61,7 +61,7 @@ "typescript": "^5.0.0" }, "peerDependencies": { - "@bloxchain/contracts": "^1.0.0-alpha.8", + "@bloxchain/contracts": "^1.0.0-alpha.11", "viem": "^2.0.0" }, "peerDependenciesMeta": {