@ludeo/cli 1.0.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/README.md ADDED
@@ -0,0 +1,252 @@
1
+ # Ludeo CLI
2
+
3
+ A command-line tool for studios to upload game builds and manage content on the Ludeo platform.
4
+
5
+ ## Features
6
+
7
+ - **Complete Build Uploads**: Upload both build metadata and all build files in one command
8
+ - **Multipart File Uploads**: Automatically handles large files (>100MB) using multipart uploads
9
+ - **Concurrent Uploads**: Uploads multiple files simultaneously for faster processing
10
+ - **Progress Tracking**: Real-time progress updates during file uploads
11
+ - **Authentication**: Secure access token-based authentication
12
+ - **Environment Support**: Staging and production environment support
13
+
14
+ ## Quick Start
15
+
16
+ ### Option 1: NPM Installation (Recommended for most users)
17
+ ```bash
18
+ # Install globally
19
+ npm install -g @ludeo/cli
20
+
21
+ # Verify installation
22
+ ludeo --version
23
+
24
+ # Authenticate
25
+ ludeo auth login --access-token YOUR_ACCESS_TOKEN
26
+ ```
27
+
28
+ ### Option 2: Build from Source
29
+ #### 1. Build the CLI
30
+ ```bash
31
+ make build
32
+ ```
33
+
34
+ #### 2. Authenticate
35
+ ```bash
36
+ ./build/ludeo auth login --access-token YOUR_ACCESS_TOKEN
37
+ ```
38
+
39
+ ### 3. Upload a Complete Build
40
+ ```bash
41
+ ./build/ludeo builds upload \
42
+ --game-version-id YOUR_GAME_VERSION_ID \
43
+ --base-path ./builds \
44
+ --exec-path ./builds/game.exe \
45
+ --local-directory ./builds
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ ### Authentication Commands
51
+ ```bash
52
+ # Login with access token
53
+ ludeo auth login --access-token <token>
54
+
55
+ # Check authentication status
56
+ ludeo auth status
57
+
58
+ # Validate current access token
59
+ ludeo auth validate
60
+
61
+ # Logout and clear credentials
62
+ ludeo auth logout
63
+ ```
64
+
65
+ ### Builds Commands
66
+ ```bash
67
+ # Upload a complete build (metadata + files)
68
+ ludeo builds upload [flags]
69
+
70
+ # List builds for a game version
71
+ ludeo builds list --game-version-id <id>
72
+
73
+ # Get build details
74
+ ludeo builds get --game-version-id <id> --build-id <id>
75
+ ```
76
+
77
+ #### Upload Required Flags
78
+ - `--game-version-id`: Game version ID
79
+ - `--exec-path`: Path to the executable (full path)
80
+ - `--local-directory`: Local directory containing all build files
81
+
82
+ #### Upload Optional Flags
83
+ - `--game-version`: Game version (e.g., 1.2.3)
84
+ - `--sdk-version`: SDK version (e.g., 2.0.0)
85
+ - `--runtime-environment`: Runtime environment (e.g., windows, linux)
86
+ - `--changes-description`: Description of changes in this build
87
+ - `--base-build-id`: Base build ID for modification builds
88
+ - `--major-build-id`: Major build ID for minor builds
89
+ - `--request-id`: Request ID for tracking
90
+
91
+ ## Authentication Flow
92
+
93
+ The CLI implements a secure authentication flow that validates access tokens before any upload operation:
94
+
95
+ 1. **Token Storage**: Access tokens are stored securely in `~/.ludeo/config.json`
96
+ 2. **Pre-upload Validation**: Every upload operation automatically validates the token first
97
+ 3. **API Endpoint**: Calls `{{baseUrl}}/v3/authentication/cli/:accessToken` to validate tokens
98
+ 4. **Session Management**: Creates/validates session for the token if it doesn't exist
99
+ 5. **Secure Uploads**: All subsequent uploads use the validated token
100
+
101
+ ### Security Features
102
+ - **Automatic Validation**: Tokens are validated before every API operation
103
+ - **Session Persistence**: Valid sessions are maintained for the duration of the token
104
+ - **Secure Storage**: Tokens are stored in user's home directory with appropriate permissions
105
+ - **No Token Logging**: Only first/last 4 characters of tokens are displayed in logs
106
+
107
+ ## Examples
108
+
109
+ ### Basic Complete Upload
110
+ ```bash
111
+ ludeo builds upload \
112
+ --game-version-id 123 \
113
+ --exec-path ./builds/game.exe \
114
+ --local-directory ./builds
115
+ ```
116
+
117
+ ### Upload with Optional Parameters
118
+ ```bash
119
+ ludeo builds upload \
120
+ --game-version-id 123 \
121
+ --exec-path ./builds/game.exe \
122
+ --local-directory ./builds \
123
+ --game-version "1.2.3" \
124
+ --sdk-version "2.1.0" \
125
+ --changes-description "Bug fixes and performance improvements" \
126
+ --runtime-environment "windows"
127
+ ```
128
+
129
+ ### List Builds
130
+ ```bash
131
+ ludeo builds list --game-version-id 123
132
+ ```
133
+
134
+ ## How It Works
135
+
136
+ ### Complete Upload Process
137
+ The CLI performs a complete upload in the following steps:
138
+
139
+ 1. **Validation**: Validates the local directory and build parameters
140
+ 2. **Base Path Derivation**: Automatically derives `basePath` from the root folder name of `--local-directory`
141
+ - Example: `--local-directory ./builds` → `basePath = "builds"`
142
+ - Example: `--local-directory ./game-assets` → `basePath = "game-assets"`
143
+ 3. **Build Creation**: Creates build metadata via the sonic-server API with the derived `basePath`
144
+ 4. **File Upload**: Uploads all files to S3 via the cloud-builds service
145
+ - Small files (<100MB): Direct upload
146
+ - Large files (≥100MB): Multipart upload with concurrent parts
147
+ 5. **File Registration**: Registers uploaded files with the cloud-builds service
148
+ 6. **Completion**: Marks the upload as complete
149
+
150
+ ### Base Path Derivation
151
+ The CLI automatically derives the `basePath` from your `--local-directory`:
152
+
153
+ ```bash
154
+ # If you specify:
155
+ --local-directory ./builds
156
+
157
+ # The CLI will derive:
158
+ basePath = "builds"
159
+
160
+ # And send to the API:
161
+ {
162
+ "basePath": "builds",
163
+ "execPath": "./builds/game.exe", # Your input unchanged
164
+ "localDirectory": "./builds" # Your input unchanged
165
+ }
166
+ ```
167
+
168
+ This matches exactly how the UI works - the system derives the base path from the uploaded directory structure.
169
+
170
+ ### File Upload Features
171
+ - **Automatic Multipart**: Files over 100MB automatically use multipart uploads
172
+ - **Concurrent Processing**: Up to 4 files uploaded simultaneously
173
+ - **Progress Tracking**: Real-time progress updates for large uploads
174
+ - **Error Handling**: Automatic retry and failure marking
175
+ - **Cross-Platform**: Handles Windows and Unix path separators
176
+
177
+ ### Performance
178
+ - **Concurrent Uploads**: Multiple files uploaded simultaneously
179
+ - **Multipart Optimization**: Large files split into 100MB parts for optimal performance
180
+ - **Connection Reuse**: HTTP connections reused for better performance
181
+ - **Progress Reporting**: Real-time feedback during long uploads
182
+
183
+ ## Configuration
184
+
185
+ The CLI stores configuration in `~/.ludeo/config.json`. You can also use environment variables:
186
+
187
+ - `LUDEO_ACCESS_TOKEN`: Your Ludeo access token
188
+ - `LUDEO_ENVIRONMENT`: Target environment (staging, production)
189
+ - `LUDEO_API_BASE_URL`: Sonic-server API base URL
190
+ - `LUDEO_CLOUD_BUILDS_URL`: Cloud-builds API base URL
191
+
192
+ ### Default Configuration
193
+ ```json
194
+ {
195
+ "environment": "staging",
196
+ "api_base_url": "https://services.stg.use1.ludeo.com/api/v3/sonic-server",
197
+ "cloud_builds_url": "https://services.stg.use1.ludeo.com/api/v3/cloud-builds"
198
+ }
199
+ ```
200
+
201
+ ## Development
202
+
203
+ ### Building
204
+ ```bash
205
+ make build
206
+ ```
207
+
208
+ ### Testing
209
+ ```bash
210
+ make test
211
+ ```
212
+
213
+ ### Local Development
214
+ ```bash
215
+ go run main.go builds upload --help
216
+ ```
217
+
218
+ ## Troubleshooting
219
+
220
+ ### Common Issues
221
+
222
+ 1. **Authentication Errors**
223
+ - Ensure access token is valid and not expired
224
+ - Check that the access token has upload permissions
225
+
226
+ 2. **File Upload Failures**
227
+ - Verify local directory exists and is readable
228
+ - Check network connectivity to S3 endpoints
229
+ - Ensure files are not corrupted or locked
230
+
231
+ 3. **Large File Issues**
232
+ - Multipart uploads require stable network connections
233
+ - Very large files (>1GB) may take significant time
234
+ - Monitor progress output for upload status
235
+
236
+ 4. **Path Issues**
237
+ - Use forward slashes (/) in paths for cross-platform compatibility
238
+ - Ensure executable path is relative to base path
239
+
240
+ ### Debug Mode
241
+ Enable debug output by setting the log level:
242
+ ```bash
243
+ export LUDEO_LOG_LEVEL=debug
244
+ ludeo builds upload [flags]
245
+ ```
246
+
247
+ ## Support
248
+
249
+ For issues and questions:
250
+ - Check the troubleshooting section above
251
+ - Review the CLI output for error details
252
+ - Contact the Ludeo platform team
package/bin/ludeo.js ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const os = require('os');
6
+ const fs = require('fs');
7
+
8
+ // Determine the correct binary path based on platform and architecture
9
+ function getBinaryPath() {
10
+ const platform = os.platform();
11
+ const arch = os.arch();
12
+
13
+ // Map Node.js arch to Go arch
14
+ const archMap = {
15
+ 'x64': 'amd64',
16
+ 'arm64': 'arm64'
17
+ };
18
+
19
+ const goArch = archMap[arch] || arch;
20
+
21
+ // Map platform names
22
+ const platformMap = {
23
+ 'win32': 'windows',
24
+ 'darwin': 'darwin',
25
+ 'linux': 'linux'
26
+ };
27
+
28
+ const goPlatform = platformMap[platform] || platform;
29
+
30
+ // Construct binary name
31
+ const binaryName = platform === 'win32'
32
+ ? `ludeo-${goPlatform}-${goArch}.exe`
33
+ : `ludeo-${goPlatform}-${goArch}`;
34
+
35
+ // Look for binary in dist/ directory (created by postinstall)
36
+ const distPath = path.join(__dirname, '..', 'dist', binaryName);
37
+
38
+ if (fs.existsSync(distPath)) {
39
+ return distPath;
40
+ }
41
+
42
+ // Fallback to build/ directory for development
43
+ const buildPath = path.join(__dirname, '..', 'build', binaryName);
44
+
45
+ if (fs.existsSync(buildPath)) {
46
+ return buildPath;
47
+ }
48
+
49
+ throw new Error(`Binary not found for ${platform}-${arch}. Expected: ${binaryName}`);
50
+ }
51
+
52
+ // Execute the Go binary with all arguments
53
+ function main() {
54
+ try {
55
+ const binaryPath = getBinaryPath();
56
+ const args = process.argv.slice(2);
57
+
58
+ // Spawn the Go binary with all arguments
59
+ const child = spawn(binaryPath, args, {
60
+ stdio: 'inherit',
61
+ cwd: process.cwd()
62
+ });
63
+
64
+ child.on('error', (error) => {
65
+ console.error(`Failed to start Ludeo CLI: ${error.message}`);
66
+ process.exit(1);
67
+ });
68
+
69
+ child.on('exit', (code) => {
70
+ process.exit(code);
71
+ });
72
+
73
+ } catch (error) {
74
+ console.error(`Error: ${error.message}`);
75
+ console.error('');
76
+ console.error('This usually means the CLI binary for your platform is missing.');
77
+ console.error('Try running: npm rebuild @ludeo/cli');
78
+ process.exit(1);
79
+ }
80
+ }
81
+
82
+ main();
83
+
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@ludeo/cli",
3
+ "version": "1.0.0",
4
+ "description": "Ludeo CLI - Upload game builds and manage content on the Ludeo platform",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "ludeo": "./bin/ludeo.js"
8
+ },
9
+ "scripts": {
10
+ "build": "make build-all",
11
+ "postinstall": "node scripts/postinstall.js",
12
+ "prepublishOnly": "npm run build"
13
+ },
14
+ "keywords": [
15
+ "ludeo",
16
+ "cli",
17
+ "game",
18
+ "build",
19
+ "upload",
20
+ "gaming"
21
+ ],
22
+ "author": "Ludeo Team",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/ludeo/cli.git"
27
+ },
28
+ "engines": {
29
+ "node": ">=16.0.0"
30
+ },
31
+ "files": [
32
+ "bin/",
33
+ "dist/",
34
+ "README.md",
35
+ "LICENSE"
36
+ ],
37
+ "os": [
38
+ "win32",
39
+ "darwin",
40
+ "linux"
41
+ ],
42
+ "cpu": [
43
+ "x64",
44
+ "arm64"
45
+ ]
46
+ }
47
+