Skip to content

Commit a82cf94

Browse files
committed
build: script to install forked polkadot-js
1 parent 0a210bf commit a82cf94

File tree

4 files changed

+564
-543
lines changed

4 files changed

+564
-543
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ build/Release
4141
# Dependency directories
4242
node_modules/
4343
jspm_packages/
44+
.polkadot-js-api
4445

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
"@headlessui/react": "^1.7.18",
3535
"@heroicons/react": "^1.0.6",
3636
"@polkadot/api": "15.8.1",
37-
"@polkadot/api-contract": "file:/Users/peter/dev/dot-repos/api/packages/api-contract/build",
37+
"@polkadot/api-contract": "file:./.polkadot-js-api/packages/api-contract/build",
3838
"@polkadot/extension-dapp": "^0.58.6",
39-
"@polkadot/types": "file:/Users/peter/dev/dot-repos/api/packages/types/build",
39+
"@polkadot/types": "15.8.1",
4040
"@polkadot/ui-keyring": "^3.12.2",
4141
"@polkadot/ui-shared": "^3.12.2",
4242
"big.js": "^6.2.1",

scripts/build-polkadot-api.cjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const { execSync } = require('child_process');
2+
const fs = require('fs');
3+
const path = require('path');
4+
5+
// Define paths
6+
const repoUrl = 'https://github.com/use-ink/polkadot-js-api.git';
7+
const cloneDir = path.resolve(__dirname, '../.polkadot-js-api'); // Clone to a local folder in project
8+
const packageBuildDir = path.resolve(cloneDir, 'packages/api-contract/build');
9+
10+
// Function to run shell commands
11+
function runCommand(command, cwd) {
12+
try {
13+
execSync(command, { cwd, stdio: 'inherit' });
14+
} catch (error) {
15+
console.error(`Error executing command: ${command}`);
16+
process.exit(1);
17+
}
18+
}
19+
20+
// Check if the repo is already cloned
21+
if (!fs.existsSync(cloneDir)) {
22+
console.log(`Cloning repository from ${repoUrl}...`);
23+
runCommand(`git clone --branch peter/api-revive ${repoUrl} "${cloneDir}"`, __dirname);
24+
} else {
25+
console.log(`Repository already cloned at ${cloneDir}. Pulling latest changes...`);
26+
runCommand('git pull', cloneDir);
27+
}
28+
29+
// Install dependencies and build
30+
console.log('Installing dependencies...');
31+
runCommand('yarn install', cloneDir);
32+
33+
console.log('Building @polkadot/api-contract...');
34+
runCommand('yarn build', cloneDir);
35+
36+
// Verify build output
37+
if (!fs.existsSync(packageBuildDir)) {
38+
console.error(`Build failed: ${packageBuildDir} does not exist.`);
39+
process.exit(1);
40+
}
41+
42+
console.log(`Build completed successfully. Built files are in ${packageBuildDir}.`);

0 commit comments

Comments
 (0)