@blu1606/create-walrus-app 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context.js +1 -0
- package/dist/generator/layers.js +3 -0
- package/dist/index.js +1 -0
- package/dist/post-install/index.js +5 -0
- package/dist/post-install/walrus-deploy.d.ts +6 -0
- package/dist/post-install/walrus-deploy.js +77 -0
- package/dist/prompts.js +17 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/presets/react-mysten-gallery/README.md +60 -0
- package/presets/react-mysten-gallery/package.json +2 -1
- package/presets/react-mysten-gallery/scripts/setup-walrus-deploy.sh +282 -0
- package/presets/react-mysten-simple-upload/README.md +60 -0
- package/presets/react-mysten-simple-upload/package.json +2 -1
- package/presets/react-mysten-simple-upload/scripts/setup-walrus-deploy.sh +286 -0
- package/presets/react-mysten-simple-upload-enoki/.env.example +40 -0
- package/presets/react-mysten-simple-upload-enoki/.gitkeep +4 -0
- package/presets/react-mysten-simple-upload-enoki/README.md +332 -0
- package/presets/react-mysten-simple-upload-enoki/index.html +13 -0
- package/presets/react-mysten-simple-upload-enoki/package.json +37 -0
- package/presets/react-mysten-simple-upload-enoki/scripts/setup-walrus-deploy.sh +286 -0
- package/presets/react-mysten-simple-upload-enoki/src/App.tsx +27 -0
- package/presets/react-mysten-simple-upload-enoki/src/components/features/enoki-auth-button.tsx +29 -0
- package/presets/react-mysten-simple-upload-enoki/src/components/features/file-preview.tsx +73 -0
- package/presets/react-mysten-simple-upload-enoki/src/components/features/upload-form.tsx +61 -0
- package/presets/react-mysten-simple-upload-enoki/src/components/features/wallet-connect.tsx +38 -0
- package/presets/react-mysten-simple-upload-enoki/src/components/layout/app-layout.tsx +21 -0
- package/presets/react-mysten-simple-upload-enoki/src/hooks/use-download.ts +24 -0
- package/presets/react-mysten-simple-upload-enoki/src/hooks/use-enoki-auth.ts +52 -0
- package/presets/react-mysten-simple-upload-enoki/src/hooks/use-upload.ts +45 -0
- package/presets/react-mysten-simple-upload-enoki/src/hooks/use-wallet.ts +32 -0
- package/presets/react-mysten-simple-upload-enoki/src/index.css +322 -0
- package/presets/react-mysten-simple-upload-enoki/src/index.ts +24 -0
- package/presets/react-mysten-simple-upload-enoki/src/lib/enoki/constants.ts +23 -0
- package/presets/react-mysten-simple-upload-enoki/src/lib/enoki/index.ts +6 -0
- package/presets/react-mysten-simple-upload-enoki/src/lib/enoki/storage-adapter.ts +31 -0
- package/presets/react-mysten-simple-upload-enoki/src/lib/walrus/adapter.ts +197 -0
- package/presets/react-mysten-simple-upload-enoki/src/lib/walrus/client.ts +87 -0
- package/presets/react-mysten-simple-upload-enoki/src/lib/walrus/index.ts +4 -0
- package/presets/react-mysten-simple-upload-enoki/src/lib/walrus/types.ts +92 -0
- package/presets/react-mysten-simple-upload-enoki/src/main.tsx +19 -0
- package/presets/react-mysten-simple-upload-enoki/src/providers/EnokiProvider.tsx +23 -0
- package/presets/react-mysten-simple-upload-enoki/src/providers/QueryProvider.tsx +18 -0
- package/presets/react-mysten-simple-upload-enoki/src/providers/WalletProvider.tsx +52 -0
- package/presets/react-mysten-simple-upload-enoki/src/providers/index.ts +7 -0
- package/presets/react-mysten-simple-upload-enoki/src/utils/env.ts +41 -0
- package/presets/react-mysten-simple-upload-enoki/src/utils/mime-type.ts +97 -0
- package/presets/react-mysten-simple-upload-enoki/tsconfig.json +39 -0
- package/presets/react-mysten-simple-upload-enoki/tsconfig.node.json +10 -0
- package/presets/react-mysten-simple-upload-enoki/vite.config.ts +19 -0
package/dist/context.js
CHANGED
|
@@ -39,6 +39,7 @@ export function buildContext(args, promptResults) {
|
|
|
39
39
|
// Temporarily disabled until templates are implemented
|
|
40
40
|
analytics: false, // Boolean(merged.analytics),
|
|
41
41
|
tailwind: false, // Boolean(merged.tailwind),
|
|
42
|
+
useZkLogin: Boolean(merged.useZkLogin),
|
|
42
43
|
packageManager: packageManager,
|
|
43
44
|
};
|
|
44
45
|
}
|
package/dist/generator/layers.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ program
|
|
|
26
26
|
// TODO: Re-enable when templates are implemented
|
|
27
27
|
// .option('--analytics', 'Include Blockberry analytics', false)
|
|
28
28
|
// .option('--no-tailwind', 'Exclude Tailwind CSS')
|
|
29
|
+
.option('--use-zk-login', 'Use zkLogin (Enoki) authentication', false)
|
|
29
30
|
.option('--skip-install', 'Skip dependency installation', false)
|
|
30
31
|
.option('--skip-git', '[DEPRECATED] No longer used - git initialization removed', false)
|
|
31
32
|
.option('--skip-validation', 'Skip project validation', false)
|
|
@@ -2,6 +2,7 @@ import { logger } from '../utils/logger.js';
|
|
|
2
2
|
import { installDependencies } from './package-manager.js';
|
|
3
3
|
import { validateProject } from './validator.js';
|
|
4
4
|
import { displaySuccess, displayError } from './messages.js';
|
|
5
|
+
import { setupWalrusDeploy } from './walrus-deploy.js';
|
|
5
6
|
export async function runPostInstall(options) {
|
|
6
7
|
const { context, projectPath, skipInstall = false, skipValidation = false, } = options;
|
|
7
8
|
const result = {
|
|
@@ -30,6 +31,10 @@ export async function runPostInstall(options) {
|
|
|
30
31
|
validationResult.errors.forEach((err) => logger.warn(` - ${err}`));
|
|
31
32
|
}
|
|
32
33
|
}
|
|
34
|
+
// Step 3: Setup Walrus deployment (interactive prompt)
|
|
35
|
+
if (result.installed) {
|
|
36
|
+
await setupWalrusDeploy(projectPath, context);
|
|
37
|
+
}
|
|
33
38
|
// Display success message
|
|
34
39
|
displaySuccess(context);
|
|
35
40
|
return result;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import prompts from 'prompts';
|
|
2
|
+
import { spawn } from 'cross-spawn';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { existsSync, chmodSync } from 'node:fs';
|
|
5
|
+
import { logger } from '../utils/logger.js';
|
|
6
|
+
/**
|
|
7
|
+
* Prompts user to setup Walrus Sites deployment
|
|
8
|
+
* Runs setup-walrus-deploy.sh script if user confirms
|
|
9
|
+
*/
|
|
10
|
+
export async function setupWalrusDeploy(projectPath, _context) {
|
|
11
|
+
try {
|
|
12
|
+
const isInteractive = Boolean(process.stdin.isTTY);
|
|
13
|
+
// Skip in non-interactive mode
|
|
14
|
+
if (!isInteractive) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
console.log(''); // Newline for better spacing
|
|
18
|
+
const response = await prompts({
|
|
19
|
+
type: 'confirm',
|
|
20
|
+
name: 'setup',
|
|
21
|
+
message: 'Setup Walrus Sites deployment? (testnet)',
|
|
22
|
+
initial: false,
|
|
23
|
+
}, {
|
|
24
|
+
onCancel: () => {
|
|
25
|
+
logger.info('Skipping Walrus deployment setup');
|
|
26
|
+
return false;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (!response.setup) {
|
|
30
|
+
logger.info('You can setup later by running: pnpm setup-walrus-deploy');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Run the setup script
|
|
34
|
+
const scriptPath = join(projectPath, 'scripts', 'setup-walrus-deploy.sh');
|
|
35
|
+
if (!existsSync(scriptPath)) {
|
|
36
|
+
logger.warn('⚠️ setup-walrus-deploy.sh not found in project scripts/');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// Make script executable (Unix/macOS)
|
|
40
|
+
try {
|
|
41
|
+
chmodSync(scriptPath, 0o755);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
// Ignore on Windows
|
|
45
|
+
}
|
|
46
|
+
logger.info('🦭 Running Walrus deployment setup...\n');
|
|
47
|
+
// Execute setup script
|
|
48
|
+
const child = spawn('bash', [scriptPath, projectPath], {
|
|
49
|
+
cwd: projectPath,
|
|
50
|
+
stdio: 'inherit', // Show output in real-time
|
|
51
|
+
shell: true,
|
|
52
|
+
});
|
|
53
|
+
await new Promise((resolve, reject) => {
|
|
54
|
+
child.on('close', (code) => {
|
|
55
|
+
if (code === 0) {
|
|
56
|
+
logger.success('\n✅ Walrus deployment setup complete!');
|
|
57
|
+
resolve();
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
logger.warn(`\n⚠️ Setup exited with code ${code}. You can retry with: pnpm setup-walrus-deploy`);
|
|
61
|
+
resolve(); // Don't fail the whole installation
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
child.on('error', (error) => {
|
|
65
|
+
logger.error(`Setup script error: ${error.message}`);
|
|
66
|
+
reject(error);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
// Non-fatal: log and continue
|
|
72
|
+
logger.warn('⚠️ Walrus deployment setup skipped due to error');
|
|
73
|
+
if (error instanceof Error) {
|
|
74
|
+
logger.warn(error.message);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
package/dist/prompts.js
CHANGED
|
@@ -86,6 +86,23 @@ export async function runPrompts(initial = {}) {
|
|
|
86
86
|
message: 'Include Tailwind CSS?',
|
|
87
87
|
initial: false, // Changed to false to prevent layer lookup
|
|
88
88
|
},
|
|
89
|
+
{
|
|
90
|
+
type: (prev, answers) => {
|
|
91
|
+
// Only show zkLogin prompt for mysten SDK with simple-upload or gallery
|
|
92
|
+
const sdk = initial.sdk || answers.sdk;
|
|
93
|
+
const useCase = answers.useCase;
|
|
94
|
+
if (sdk !== 'mysten')
|
|
95
|
+
return null;
|
|
96
|
+
if (!['simple-upload', 'gallery'].includes(useCase))
|
|
97
|
+
return null;
|
|
98
|
+
if (initial.useZkLogin !== undefined)
|
|
99
|
+
return null;
|
|
100
|
+
return 'confirm';
|
|
101
|
+
},
|
|
102
|
+
name: 'useZkLogin',
|
|
103
|
+
message: 'Use zkLogin (Enoki) authentication? (Web2 login with Google/Apple)',
|
|
104
|
+
initial: false,
|
|
105
|
+
},
|
|
89
106
|
{
|
|
90
107
|
type: initial.packageManager ? null : 'select',
|
|
91
108
|
name: 'packageManager',
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -45,3 +45,63 @@ The gallery maintains a local index in localStorage:
|
|
|
45
45
|
"lastModified": 1705449600000
|
|
46
46
|
}
|
|
47
47
|
```
|
|
48
|
+
|
|
49
|
+
## Deploy to Walrus Sites
|
|
50
|
+
|
|
51
|
+
### First-time Setup
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pnpm setup-walrus-deploy
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This will automatically:
|
|
58
|
+
- Install Bun (if not already installed)
|
|
59
|
+
- Download site-builder binary for your OS
|
|
60
|
+
- Clone Walrus Sites portal to `~/.walrus/portal`
|
|
61
|
+
- Add deployment scripts to package.json
|
|
62
|
+
|
|
63
|
+
### Configure SUI Private Key
|
|
64
|
+
|
|
65
|
+
Edit the portal configuration:
|
|
66
|
+
|
|
67
|
+
**Linux/macOS:**
|
|
68
|
+
```bash
|
|
69
|
+
nano ~/.walrus/portal/.env
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Windows:**
|
|
73
|
+
```bash
|
|
74
|
+
notepad %USERPROFILE%\.walrus\portal\.env
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Add your private key:
|
|
78
|
+
```env
|
|
79
|
+
SUI_PRIVATE_KEY=0x...
|
|
80
|
+
WALRUS_NETWORK=testnet
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Build & Deploy
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Build production bundle
|
|
87
|
+
pnpm build
|
|
88
|
+
|
|
89
|
+
# Deploy to Walrus Sites (testnet, 10 epochs)
|
|
90
|
+
pnpm deploy:walrus
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Preview Locally
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pnpm walrus:portal
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
This starts the local portal server to preview your deployed site.
|
|
100
|
+
|
|
101
|
+
## Available Scripts
|
|
102
|
+
|
|
103
|
+
- `pnpm dev` - Start development server
|
|
104
|
+
- `pnpm build` - Build for production
|
|
105
|
+
- `pnpm setup-walrus-deploy` - One-time deployment setup
|
|
106
|
+
- `pnpm deploy:walrus` - Deploy to Walrus Sites
|
|
107
|
+
- `pnpm walrus:portal` - Start local portal preview
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"dev": "vite",
|
|
10
10
|
"lint": "eslint . --ext .ts,.tsx",
|
|
11
11
|
"preview": "vite preview",
|
|
12
|
-
"type-check": "tsc --noEmit"
|
|
12
|
+
"type-check": "tsc --noEmit",
|
|
13
|
+
"setup-walrus-deploy": "bash scripts/setup-walrus-deploy.sh"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@mysten/dapp-kit": "^0.14.0",
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# setup-walrus-deploy.sh - Zero-config Walrus Sites deployment setup (testnet)
|
|
3
|
+
# Auto-installs dependencies, downloads tools, clones portal
|
|
4
|
+
# Supports: Linux, macOS, Windows (Git Bash/WSL)
|
|
5
|
+
|
|
6
|
+
set -e # Exit on error
|
|
7
|
+
|
|
8
|
+
echo "🦭 Walrus Sites Zero-Config Setup (testnet)"
|
|
9
|
+
echo ""
|
|
10
|
+
|
|
11
|
+
# ============================================================================
|
|
12
|
+
# 1. Detect OS & Architecture
|
|
13
|
+
# ============================================================================
|
|
14
|
+
detect_os() {
|
|
15
|
+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
16
|
+
ARCH=$(uname -m)
|
|
17
|
+
|
|
18
|
+
case "$OS" in
|
|
19
|
+
linux*) OS_TYPE="linux" ;;
|
|
20
|
+
darwin*) OS_TYPE="macos" ;;
|
|
21
|
+
mingw*|msys*|cygwin*) OS_TYPE="windows" ;;
|
|
22
|
+
*)
|
|
23
|
+
echo "❌ Unsupported OS: $OS"
|
|
24
|
+
exit 1
|
|
25
|
+
;;
|
|
26
|
+
esac
|
|
27
|
+
|
|
28
|
+
echo "✅ Detected: $OS_TYPE ($ARCH)"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# ============================================================================
|
|
32
|
+
# 2. Auto-install Bun (if not exists)
|
|
33
|
+
# ============================================================================
|
|
34
|
+
setup_bun() {
|
|
35
|
+
if command -v bun &>/dev/null; then
|
|
36
|
+
echo "✅ Bun already installed: $(bun --version)"
|
|
37
|
+
return 0
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
echo "📥 Installing Bun..."
|
|
41
|
+
if [ "$OS_TYPE" = "windows" ]; then
|
|
42
|
+
# Windows (PowerShell install via Git Bash)
|
|
43
|
+
powershell -c "irm bun.sh/install.ps1 | iex"
|
|
44
|
+
else
|
|
45
|
+
# Linux/macOS
|
|
46
|
+
curl -fsSL https://bun.sh/install | bash
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# Add to PATH for current session
|
|
50
|
+
if [ "$OS_TYPE" = "windows" ]; then
|
|
51
|
+
export PATH="$USERPROFILE/.bun/bin:$PATH"
|
|
52
|
+
else
|
|
53
|
+
export BUN_INSTALL="$HOME/.bun"
|
|
54
|
+
export PATH="$BUN_INSTALL/bin:$PATH"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# Verify installation
|
|
58
|
+
if command -v bun &>/dev/null; then
|
|
59
|
+
echo "✅ Bun installed: $(bun --version)"
|
|
60
|
+
else
|
|
61
|
+
echo "⚠️ Bun installed but not in PATH. Restart terminal or run:"
|
|
62
|
+
echo " export PATH=\"\$HOME/.bun/bin:\$PATH\""
|
|
63
|
+
fi
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
# ============================================================================
|
|
67
|
+
# 3. Download site-builder binary (if not exists)
|
|
68
|
+
# ============================================================================
|
|
69
|
+
setup_site_builder() {
|
|
70
|
+
# Set install directory based on OS
|
|
71
|
+
if [ "$OS_TYPE" = "windows" ]; then
|
|
72
|
+
WALRUS_BIN="$USERPROFILE/bin"
|
|
73
|
+
SITE_BUILDER="$WALRUS_BIN/site-builder.exe"
|
|
74
|
+
else
|
|
75
|
+
WALRUS_BIN="$HOME/bin"
|
|
76
|
+
SITE_BUILDER="$WALRUS_BIN/site-builder"
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# Check if already exists
|
|
80
|
+
if [ -f "$SITE_BUILDER" ]; then
|
|
81
|
+
echo "✅ site-builder already exists: $SITE_BUILDER"
|
|
82
|
+
chmod +x "$SITE_BUILDER" 2>/dev/null || true
|
|
83
|
+
return 0
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
echo "📥 Downloading site-builder for $OS_TYPE..."
|
|
87
|
+
mkdir -p "$WALRUS_BIN"
|
|
88
|
+
|
|
89
|
+
# Select binary based on OS
|
|
90
|
+
case "$OS_TYPE" in
|
|
91
|
+
linux) BINARY_NAME="site-builder-linux" ;;
|
|
92
|
+
macos) BINARY_NAME="site-builder-macos" ;;
|
|
93
|
+
windows) BINARY_NAME="site-builder-windows.exe" ;;
|
|
94
|
+
esac
|
|
95
|
+
|
|
96
|
+
SYSTEM=ubuntu-x86_64
|
|
97
|
+
curl https://storage.googleapis.com/mysten-walrus-binaries/site-builder-testnet-latest-$SYSTEM -o site-builder
|
|
98
|
+
chmod +x site-builder
|
|
99
|
+
|
|
100
|
+
chmod +x "$SITE_BUILDER"
|
|
101
|
+
echo "✅ site-builder installed: $SITE_BUILDER"
|
|
102
|
+
|
|
103
|
+
# Add to PATH hint (won't persist after script)
|
|
104
|
+
if [ "$OS_TYPE" = "windows" ]; then
|
|
105
|
+
export PATH="$USERPROFILE/bin:$PATH"
|
|
106
|
+
else
|
|
107
|
+
export PATH="$HOME/bin:$PATH"
|
|
108
|
+
fi
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
# ============================================================================
|
|
112
|
+
# 4. Clone Walrus Portal (if not exists)
|
|
113
|
+
# ============================================================================
|
|
114
|
+
setup_portal() {
|
|
115
|
+
if [ "$OS_TYPE" = "windows" ]; then
|
|
116
|
+
PORTAL_DIR="$USERPROFILE/portal"
|
|
117
|
+
else
|
|
118
|
+
PORTAL_DIR="$HOME/portal"
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
if [ -d "$PORTAL_DIR" ]; then
|
|
122
|
+
echo "✅ Portal already exists: $PORTAL_DIR"
|
|
123
|
+
echo " Updating..."
|
|
124
|
+
cd "$PORTAL_DIR"
|
|
125
|
+
git pull --quiet || echo "⚠️ Git pull failed (may be offline)"
|
|
126
|
+
else
|
|
127
|
+
echo "📂 Cloning Walrus Sites portal..."
|
|
128
|
+
mkdir -p "$(dirname "$PORTAL_DIR")"
|
|
129
|
+
|
|
130
|
+
# Clone with depth=1 for faster download
|
|
131
|
+
if ! git clone --depth=1 https://github.com/ManTT-Data/portal.git "$PORTAL_DIR"; then
|
|
132
|
+
echo "❌ Failed to clone portal repository"
|
|
133
|
+
exit 1
|
|
134
|
+
fi
|
|
135
|
+
|
|
136
|
+
cd "$PORTAL_DIR"
|
|
137
|
+
echo "✅ Portal cloned to: $PORTAL_DIR"
|
|
138
|
+
fi
|
|
139
|
+
|
|
140
|
+
# Setup .env if not exists
|
|
141
|
+
if [ ! -f ".env" ]; then
|
|
142
|
+
if [ -f ".env.example" ]; then
|
|
143
|
+
cp .env.example .env
|
|
144
|
+
echo "✅ Created .env from .env.example"
|
|
145
|
+
else
|
|
146
|
+
# Create minimal .env
|
|
147
|
+
cat > .env << 'EOF'
|
|
148
|
+
# Walrus Portal Configuration (Testnet)
|
|
149
|
+
WALRUS_NETWORK=testnet
|
|
150
|
+
SUI_PRIVATE_KEY=
|
|
151
|
+
|
|
152
|
+
# Optional: Uncomment to customize
|
|
153
|
+
# PORTAL_PORT=3000
|
|
154
|
+
EOF
|
|
155
|
+
echo "✅ Created .env template"
|
|
156
|
+
fi
|
|
157
|
+
|
|
158
|
+
echo ""
|
|
159
|
+
echo "⚠️ ACTION REQUIRED:"
|
|
160
|
+
echo " Edit $PORTAL_DIR/.env"
|
|
161
|
+
echo " Add your SUI_PRIVATE_KEY=0x..."
|
|
162
|
+
echo ""
|
|
163
|
+
else
|
|
164
|
+
echo "✅ .env already configured"
|
|
165
|
+
fi
|
|
166
|
+
|
|
167
|
+
# Install portal dependencies
|
|
168
|
+
echo "📦 Installing portal dependencies..."
|
|
169
|
+
if ! bun install --silent; then
|
|
170
|
+
echo "❌ Bun install failed"
|
|
171
|
+
exit 1
|
|
172
|
+
fi
|
|
173
|
+
|
|
174
|
+
echo "✅ Portal dependencies installed"
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# ============================================================================
|
|
178
|
+
# 5. Add npm scripts to project package.json
|
|
179
|
+
# ============================================================================
|
|
180
|
+
add_project_scripts() {
|
|
181
|
+
PROJECT_DIR="${1:-.}" # Default to current directory
|
|
182
|
+
cd "$PROJECT_DIR" || { echo "❌ Invalid project directory"; exit 1; }
|
|
183
|
+
|
|
184
|
+
if [ ! -f "package.json" ]; then
|
|
185
|
+
echo "❌ No package.json found in $PROJECT_DIR"
|
|
186
|
+
exit 1
|
|
187
|
+
fi
|
|
188
|
+
|
|
189
|
+
echo "📝 Adding Walrus deploy scripts to package.json..."
|
|
190
|
+
|
|
191
|
+
# Use Node.js to safely modify package.json (guaranteed to exist in Node projects)
|
|
192
|
+
node -e "
|
|
193
|
+
const fs = require('fs');
|
|
194
|
+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
195
|
+
|
|
196
|
+
pkg.scripts = pkg.scripts || {};
|
|
197
|
+
|
|
198
|
+
// Add scripts (only if not already exists)
|
|
199
|
+
if (!pkg.scripts['setup-walrus-deploy']) {
|
|
200
|
+
pkg.scripts['setup-walrus-deploy'] = 'bash scripts/setup-walrus-deploy.sh';
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (!pkg.scripts['deploy:walrus']) {
|
|
204
|
+
const siteBuilderPath = process.platform === 'win32'
|
|
205
|
+
? '%USERPROFILE%/bin/site-builder.exe'
|
|
206
|
+
: '~/bin/site-builder';
|
|
207
|
+
pkg.scripts['deploy:walrus'] = siteBuilderPath + ' --context=testnet deploy ./dist --epochs 10';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (!pkg.scripts['walrus:portal']) {
|
|
211
|
+
const portalPath = process.platform === 'win32'
|
|
212
|
+
? 'cd %USERPROFILE%/portal'
|
|
213
|
+
: 'cd ~/portal';
|
|
214
|
+
pkg.scripts['walrus:portal'] = portalPath + ' && bun run server';
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\\n');
|
|
218
|
+
" || {
|
|
219
|
+
echo "❌ Failed to update package.json"
|
|
220
|
+
exit 1
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
echo "✅ Scripts added to package.json:"
|
|
224
|
+
echo " - setup-walrus-deploy"
|
|
225
|
+
echo " - deploy:walrus"
|
|
226
|
+
echo " - walrus:portal"
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
# ============================================================================
|
|
230
|
+
# Main Execution
|
|
231
|
+
# ============================================================================
|
|
232
|
+
main() {
|
|
233
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
234
|
+
|
|
235
|
+
# Trap errors
|
|
236
|
+
trap 'echo "❌ Setup failed at line $LINENO"' ERR
|
|
237
|
+
|
|
238
|
+
# Prerequisites check
|
|
239
|
+
if ! command -v git &>/dev/null; then
|
|
240
|
+
echo "❌ Git not found. Install: https://git-scm.com"
|
|
241
|
+
exit 1
|
|
242
|
+
fi
|
|
243
|
+
|
|
244
|
+
if ! command -v node &>/dev/null; then
|
|
245
|
+
echo "❌ Node.js not found. Install: https://nodejs.org"
|
|
246
|
+
exit 1
|
|
247
|
+
fi
|
|
248
|
+
|
|
249
|
+
# Run setup steps
|
|
250
|
+
detect_os
|
|
251
|
+
setup_bun
|
|
252
|
+
setup_site_builder
|
|
253
|
+
setup_portal
|
|
254
|
+
add_project_scripts "$@"
|
|
255
|
+
|
|
256
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
257
|
+
echo ""
|
|
258
|
+
echo "🎉 Setup Complete!"
|
|
259
|
+
echo ""
|
|
260
|
+
echo "Next Steps:"
|
|
261
|
+
echo " 1. Configure your SUI private key:"
|
|
262
|
+
if [ "$OS_TYPE" = "windows" ]; then
|
|
263
|
+
echo " notepad %USERPROFILE%\\portal\\.env"
|
|
264
|
+
else
|
|
265
|
+
echo " nano ~/portal/.env"
|
|
266
|
+
fi
|
|
267
|
+
echo " Add: SUI_PRIVATE_KEY=0x..."
|
|
268
|
+
echo ""
|
|
269
|
+
echo " 2. Build your project:"
|
|
270
|
+
echo " pnpm build"
|
|
271
|
+
echo ""
|
|
272
|
+
echo " 3. Deploy to Walrus Sites:"
|
|
273
|
+
echo " pnpm deploy:walrus"
|
|
274
|
+
echo ""
|
|
275
|
+
echo " 4. (Optional) Preview locally:"
|
|
276
|
+
echo " pnpm walrus:portal"
|
|
277
|
+
echo ""
|
|
278
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
# Run main with all script arguments
|
|
282
|
+
main "$@"
|
|
@@ -22,3 +22,63 @@ This is a Simple Upload Walrus application.
|
|
|
22
22
|
- `UploadForm.tsx` - File upload UI
|
|
23
23
|
- `FilePreview.tsx` - Download UI
|
|
24
24
|
- `App.tsx` - Main app layout
|
|
25
|
+
|
|
26
|
+
## Deploy to Walrus Sites
|
|
27
|
+
|
|
28
|
+
### First-time Setup
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm setup-walrus-deploy
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
This will automatically:
|
|
35
|
+
- Install Bun (if not already installed)
|
|
36
|
+
- Download site-builder binary for your OS
|
|
37
|
+
- Clone Walrus Sites portal to `~/.walrus/portal`
|
|
38
|
+
- Add deployment scripts to package.json
|
|
39
|
+
|
|
40
|
+
### Configure SUI Private Key
|
|
41
|
+
|
|
42
|
+
Edit the portal configuration:
|
|
43
|
+
|
|
44
|
+
**Linux/macOS:**
|
|
45
|
+
```bash
|
|
46
|
+
nano ~/.walrus/portal/.env
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Windows:**
|
|
50
|
+
```bash
|
|
51
|
+
notepad %USERPROFILE%\.walrus\portal\.env
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Add your private key:
|
|
55
|
+
```env
|
|
56
|
+
SUI_PRIVATE_KEY=0x...
|
|
57
|
+
WALRUS_NETWORK=testnet
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Build & Deploy
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Build production bundle
|
|
64
|
+
pnpm build
|
|
65
|
+
|
|
66
|
+
# Deploy to Walrus Sites (testnet, 10 epochs)
|
|
67
|
+
pnpm deploy:walrus
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Preview Locally
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pnpm walrus:portal
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This starts the local portal server to preview your deployed site.
|
|
77
|
+
|
|
78
|
+
## Available Scripts
|
|
79
|
+
|
|
80
|
+
- `pnpm dev` - Start development server
|
|
81
|
+
- `pnpm build` - Build for production
|
|
82
|
+
- `pnpm setup-walrus-deploy` - One-time deployment setup
|
|
83
|
+
- `pnpm deploy:walrus` - Deploy to Walrus Sites
|
|
84
|
+
- `pnpm walrus:portal` - Start local portal preview
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"dev": "vite",
|
|
10
10
|
"lint": "eslint . --ext .ts,.tsx",
|
|
11
11
|
"preview": "vite preview",
|
|
12
|
-
"type-check": "tsc --noEmit"
|
|
12
|
+
"type-check": "tsc --noEmit",
|
|
13
|
+
"setup-walrus-deploy": "bash scripts/setup-walrus-deploy.sh"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@mysten/dapp-kit": "^0.14.0",
|