hackerrun 0.1.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/.claude/settings.local.json +22 -0
- package/.env.example +9 -0
- package/CLAUDE.md +532 -0
- package/README.md +94 -0
- package/dist/index.js +2813 -0
- package/package.json +38 -0
- package/src/commands/app.ts +394 -0
- package/src/commands/builds.ts +314 -0
- package/src/commands/config.ts +129 -0
- package/src/commands/connect.ts +197 -0
- package/src/commands/deploy.ts +227 -0
- package/src/commands/env.ts +174 -0
- package/src/commands/login.ts +120 -0
- package/src/commands/logs.ts +97 -0
- package/src/index.ts +43 -0
- package/src/lib/app-config.ts +95 -0
- package/src/lib/cluster.ts +428 -0
- package/src/lib/config.ts +137 -0
- package/src/lib/platform-auth.ts +20 -0
- package/src/lib/platform-client.ts +637 -0
- package/src/lib/platform.ts +87 -0
- package/src/lib/ssh-cert.ts +264 -0
- package/src/lib/uncloud-runner.ts +342 -0
- package/src/lib/uncloud.ts +149 -0
- package/tsconfig.json +17 -0
- package/tsup.config.ts +17 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { platform } from 'os';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
|
|
6
|
+
export class UncloudManager {
|
|
7
|
+
/**
|
|
8
|
+
* Check if uncloud CLI is installed
|
|
9
|
+
*/
|
|
10
|
+
static isInstalled(): boolean {
|
|
11
|
+
try {
|
|
12
|
+
execSync('uc --version', { stdio: 'pipe' });
|
|
13
|
+
return true;
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get uncloud version
|
|
21
|
+
*/
|
|
22
|
+
static getVersion(): string | null {
|
|
23
|
+
try {
|
|
24
|
+
const version = execSync('uc --version', { encoding: 'utf-8' }).trim();
|
|
25
|
+
return version;
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Check if uncloud is installed, offer to install if not
|
|
33
|
+
*/
|
|
34
|
+
static async ensureInstalled(): Promise<void> {
|
|
35
|
+
if (this.isInstalled()) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log(chalk.yellow('\n⚠️ Uncloud CLI not found\n'));
|
|
40
|
+
console.log('Uncloud is required to deploy and manage your apps.');
|
|
41
|
+
console.log('Learn more: https://uncloud.run\n');
|
|
42
|
+
|
|
43
|
+
// Offer auto-installation on macOS/Linux
|
|
44
|
+
const os = platform();
|
|
45
|
+
if (os === 'darwin' || os === 'linux') {
|
|
46
|
+
this.showInstallInstructions();
|
|
47
|
+
|
|
48
|
+
console.log(chalk.cyan('Would you like to install uncloud now? (Y/n): '));
|
|
49
|
+
|
|
50
|
+
const answer = await this.promptUser();
|
|
51
|
+
|
|
52
|
+
if (answer === 'y' || answer === 'yes' || answer === '') {
|
|
53
|
+
try {
|
|
54
|
+
await this.autoInstall();
|
|
55
|
+
return; // Installation successful, continue
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.log(chalk.red('\nAuto-installation failed. Please install manually.\n'));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
console.log(chalk.yellow('\nPlease install uncloud manually and run hackerrun again.\n'));
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
this.showInstallInstructions();
|
|
66
|
+
console.log(chalk.red('Please install uncloud and run hackerrun again.\n'));
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Show installation instructions based on platform
|
|
73
|
+
*/
|
|
74
|
+
static showInstallInstructions(): void {
|
|
75
|
+
const os = platform();
|
|
76
|
+
|
|
77
|
+
console.log(chalk.cyan('Installation instructions:\n'));
|
|
78
|
+
|
|
79
|
+
if (os === 'darwin' || os === 'linux') {
|
|
80
|
+
console.log(chalk.bold('Option 1: Automated install (Recommended)'));
|
|
81
|
+
console.log(chalk.green(' curl -fsS https://get.uncloud.run/install.sh | sh\n'));
|
|
82
|
+
|
|
83
|
+
console.log(chalk.bold('Option 2: Homebrew'));
|
|
84
|
+
console.log(chalk.green(' brew install psviderski/tap/uncloud\n'));
|
|
85
|
+
|
|
86
|
+
console.log(chalk.bold('Option 3: Manual download'));
|
|
87
|
+
console.log(' Download from: https://github.com/psviderski/uncloud/releases/latest');
|
|
88
|
+
console.log(' Extract and move to /usr/local/bin\n');
|
|
89
|
+
} else if (os === 'win32') {
|
|
90
|
+
// This should only show if somehow WSL detection failed
|
|
91
|
+
console.log(chalk.bold('For Windows (via WSL):'));
|
|
92
|
+
console.log(' Open your WSL terminal and run:');
|
|
93
|
+
console.log(chalk.green(' curl -fsS https://get.uncloud.run/install.sh | sh\n'));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
console.log('Documentation: https://uncloud.run/docs/getting-started/install-cli\n');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Prompt user for input from stdin
|
|
101
|
+
*/
|
|
102
|
+
private static async promptUser(): Promise<string> {
|
|
103
|
+
return new Promise((resolve) => {
|
|
104
|
+
process.stdin.resume();
|
|
105
|
+
process.stdin.setEncoding('utf8');
|
|
106
|
+
|
|
107
|
+
const onData = (input: string) => {
|
|
108
|
+
process.stdin.pause();
|
|
109
|
+
process.stdin.removeListener('data', onData);
|
|
110
|
+
resolve(input.trim().toLowerCase());
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
process.stdin.on('data', onData);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Attempt to auto-install uncloud with user confirmation
|
|
119
|
+
*/
|
|
120
|
+
static async autoInstall(): Promise<void> {
|
|
121
|
+
const spinner = ora('Installing uncloud...').start();
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
execSync('curl -fsS https://get.uncloud.run/install.sh | sh', {
|
|
125
|
+
stdio: 'inherit',
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
spinner.succeed(chalk.green('Uncloud installed successfully!'));
|
|
129
|
+
|
|
130
|
+
// Verify installation
|
|
131
|
+
if (this.isInstalled()) {
|
|
132
|
+
const version = this.getVersion();
|
|
133
|
+
console.log(chalk.cyan(`✓ Uncloud ${version} is ready to use\n`));
|
|
134
|
+
} else {
|
|
135
|
+
spinner.warn(chalk.yellow('Installation completed but uc command not found in PATH'));
|
|
136
|
+
console.log(chalk.yellow('\nYou may need to:'));
|
|
137
|
+
console.log(' 1. Restart your terminal');
|
|
138
|
+
console.log(' 2. Or run: source ~/.bashrc (or ~/.zshrc)\n');
|
|
139
|
+
throw new Error('Please restart your terminal and try again');
|
|
140
|
+
}
|
|
141
|
+
} catch (error) {
|
|
142
|
+
spinner.fail(chalk.red('Failed to install uncloud'));
|
|
143
|
+
console.log(chalk.red(`\nError: ${(error as Error).message}\n`));
|
|
144
|
+
console.log(chalk.yellow('Please try manual installation:'));
|
|
145
|
+
console.log(' curl -fsS https://get.uncloud.run/install.sh | sh\n');
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"outDir": "./dist",
|
|
13
|
+
"rootDir": "./src"
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"],
|
|
16
|
+
"exclude": ["node_modules", "dist"]
|
|
17
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: ['src/index.ts'],
|
|
5
|
+
format: ['esm'],
|
|
6
|
+
dts: false,
|
|
7
|
+
splitting: false,
|
|
8
|
+
sourcemap: false,
|
|
9
|
+
clean: true,
|
|
10
|
+
minify: false,
|
|
11
|
+
shims: true,
|
|
12
|
+
banner: {
|
|
13
|
+
js: '#!/usr/bin/env node',
|
|
14
|
+
},
|
|
15
|
+
platform: 'node',
|
|
16
|
+
target: 'node18',
|
|
17
|
+
});
|