buildx-cli 1.0.0 → 1.0.2
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 +0 -1
- package/{dist/index.cjs → index.cjs} +1 -1
- package/{dist/index.js → index.js} +1 -1
- package/package.json +4 -14
- package/.github/workflows/auto-publish.yml +0 -242
- package/.github/workflows/create-pr.yml +0 -182
- package/.prettierrc +0 -8
- package/eslint.config.mjs +0 -119
- package/jest.config.js +0 -16
- package/rollup.config.mjs +0 -64
- package/src/__tests__/config.test.ts +0 -102
- package/src/commands/auth/login.ts +0 -148
- package/src/commands/auth/logout.ts +0 -16
- package/src/commands/auth/status.ts +0 -52
- package/src/commands/config/clear.ts +0 -16
- package/src/commands/config/index.ts +0 -10
- package/src/commands/config/setup.ts +0 -75
- package/src/commands/config/show.ts +0 -70
- package/src/commands/projects/current.ts +0 -36
- package/src/commands/projects/list.ts +0 -61
- package/src/commands/projects/set-default.ts +0 -33
- package/src/commands/sync.ts +0 -64
- package/src/config/index.ts +0 -154
- package/src/index.ts +0 -49
- package/src/services/api.ts +0 -132
- package/src/services/schema-generator.ts +0 -132
- package/src/types/index.ts +0 -91
- package/src/utils/logger.ts +0 -29
- package/tsconfig.json +0 -29
- /package/{dist/index.d.ts → index.d.ts} +0 -0
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { ConfigManager } from '../config';
|
|
2
|
-
|
|
3
|
-
describe('ConfigManager', () => {
|
|
4
|
-
let configManager: ConfigManager;
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
configManager = new ConfigManager();
|
|
8
|
-
configManager.clear();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
configManager.clear();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe('Authentication', () => {
|
|
16
|
-
it('should store and retrieve auth token', () => {
|
|
17
|
-
const auth = {
|
|
18
|
-
token: 'test-token',
|
|
19
|
-
expiresAt: new Date().toISOString()
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
configManager.setAuth(auth);
|
|
23
|
-
const retrieved = configManager.getAuth();
|
|
24
|
-
|
|
25
|
-
expect(retrieved).toEqual(auth);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should clear auth token', () => {
|
|
29
|
-
const auth = {
|
|
30
|
-
token: 'test-token',
|
|
31
|
-
expiresAt: new Date().toISOString()
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
configManager.setAuth(auth);
|
|
35
|
-
configManager.clearAuth();
|
|
36
|
-
|
|
37
|
-
expect(configManager.getAuth()).toBeUndefined();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should check if authenticated', () => {
|
|
41
|
-
expect(configManager.isAuthenticated()).toBe(false);
|
|
42
|
-
|
|
43
|
-
const auth = {
|
|
44
|
-
token: 'test-token',
|
|
45
|
-
expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString() // 1 day from now
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
configManager.setAuth(auth);
|
|
49
|
-
expect(configManager.isAuthenticated()).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should handle expired token', () => {
|
|
53
|
-
const auth = {
|
|
54
|
-
token: 'test-token',
|
|
55
|
-
expiresAt: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString() // 1 day ago
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
configManager.setAuth(auth);
|
|
59
|
-
expect(configManager.isAuthenticated()).toBe(false);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('Projects', () => {
|
|
64
|
-
it('should store and retrieve projects', () => {
|
|
65
|
-
const projects = {
|
|
66
|
-
default: 'project-1',
|
|
67
|
-
list: [
|
|
68
|
-
{ id: 'project-1', name: 'Project 1' },
|
|
69
|
-
{ id: 'project-2', name: 'Project 2' }
|
|
70
|
-
]
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
configManager.setProjects(projects);
|
|
74
|
-
const retrieved = configManager.getProjects();
|
|
75
|
-
|
|
76
|
-
expect(retrieved).toEqual(projects);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should set default project', () => {
|
|
80
|
-
const projects = {
|
|
81
|
-
list: [
|
|
82
|
-
{ id: 'project-1', name: 'Project 1' },
|
|
83
|
-
{ id: 'project-2', name: 'Project 2' }
|
|
84
|
-
]
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
configManager.setProjects(projects);
|
|
88
|
-
configManager.setDefaultProject('project-2');
|
|
89
|
-
|
|
90
|
-
const updated = configManager.getProjects();
|
|
91
|
-
expect(updated?.default).toBe('project-2');
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should add project', () => {
|
|
95
|
-
const project = { id: 'project-1', name: 'Project 1' };
|
|
96
|
-
configManager.addProject(project);
|
|
97
|
-
|
|
98
|
-
const retrieved = configManager.getProject('project-1');
|
|
99
|
-
expect(retrieved).toEqual(project);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import inquirer from 'inquirer';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import ora from 'ora';
|
|
5
|
-
import { configManager } from '../../config/index';
|
|
6
|
-
import { apiService } from '../../services/api';
|
|
7
|
-
import { LoginOptions } from '../../types/index';
|
|
8
|
-
|
|
9
|
-
export const loginCommand = new Command('login')
|
|
10
|
-
.description('Authenticate with BuildX API')
|
|
11
|
-
.option('-t, --token <token>', 'API token for authentication')
|
|
12
|
-
.option('-u, --username <username>', 'Username for authentication')
|
|
13
|
-
.option('-p, --password <password>', 'Password for authentication')
|
|
14
|
-
.option('-i, --interactive', 'Interactive login mode')
|
|
15
|
-
.action(async (options: LoginOptions) => {
|
|
16
|
-
try {
|
|
17
|
-
// Check if API is configured
|
|
18
|
-
if (!apiService.isConfigured()) {
|
|
19
|
-
console.error(chalk.red('❌ API not configured'));
|
|
20
|
-
console.log(chalk.yellow('Please configure your API endpoint and API key first:'));
|
|
21
|
-
console.log(chalk.cyan(' buildx config setup'));
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let token = options.token;
|
|
26
|
-
let username = options.username;
|
|
27
|
-
let password = options.password;
|
|
28
|
-
|
|
29
|
-
// If no credentials provided, prompt for them
|
|
30
|
-
if (!token && !username && !password) {
|
|
31
|
-
const answers = await inquirer.prompt([
|
|
32
|
-
{
|
|
33
|
-
type: 'list',
|
|
34
|
-
name: 'authMethod',
|
|
35
|
-
message: 'Choose authentication method:',
|
|
36
|
-
choices: [
|
|
37
|
-
{ name: 'Username & Password', value: 'credentials' },
|
|
38
|
-
{ name: 'API Token', value: 'token' }
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
if (answers.authMethod === 'credentials') {
|
|
44
|
-
const credentialAnswers = await inquirer.prompt([
|
|
45
|
-
{
|
|
46
|
-
type: 'input',
|
|
47
|
-
name: 'username',
|
|
48
|
-
message: 'Enter your username:',
|
|
49
|
-
validate: (input: string) => {
|
|
50
|
-
if (!input || input.trim().length === 0) {
|
|
51
|
-
return 'Username is required';
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
type: 'password',
|
|
58
|
-
name: 'password',
|
|
59
|
-
message: 'Enter your password:',
|
|
60
|
-
validate: (input: string) => {
|
|
61
|
-
if (!input || input.trim().length === 0) {
|
|
62
|
-
return 'Password is required';
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
]);
|
|
68
|
-
username = credentialAnswers.username;
|
|
69
|
-
password = credentialAnswers.password;
|
|
70
|
-
} else {
|
|
71
|
-
const tokenAnswer = await inquirer.prompt([
|
|
72
|
-
{
|
|
73
|
-
type: 'password',
|
|
74
|
-
name: 'token',
|
|
75
|
-
message: 'Enter your API token:',
|
|
76
|
-
validate: (input: string) => {
|
|
77
|
-
if (!input || input.trim().length === 0) {
|
|
78
|
-
return 'Token is required';
|
|
79
|
-
}
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
]);
|
|
84
|
-
token = tokenAnswer.token;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const spinner = ora('Authenticating...').start();
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
// Only support username/password authentication
|
|
92
|
-
if (!username || !password) {
|
|
93
|
-
const credentialAnswers = await inquirer.prompt([
|
|
94
|
-
{
|
|
95
|
-
type: 'input',
|
|
96
|
-
name: 'username',
|
|
97
|
-
message: 'Enter your username:',
|
|
98
|
-
validate: (input: string) => {
|
|
99
|
-
if (!input || input.trim().length === 0) {
|
|
100
|
-
return 'Username is required';
|
|
101
|
-
}
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
type: 'password',
|
|
107
|
-
name: 'password',
|
|
108
|
-
message: 'Enter your password:',
|
|
109
|
-
validate: (input: string) => {
|
|
110
|
-
if (!input || input.trim().length === 0) {
|
|
111
|
-
return 'Password is required';
|
|
112
|
-
}
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
]);
|
|
117
|
-
username = credentialAnswers.username;
|
|
118
|
-
password = credentialAnswers.password;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Username/password authentication only
|
|
122
|
-
const loginResponse = await apiService.login({ username, password });
|
|
123
|
-
let authToken = loginResponse.token;
|
|
124
|
-
let expiresAt = loginResponse.expiresAt;
|
|
125
|
-
username = username ?? '';
|
|
126
|
-
authToken = authToken ?? '';
|
|
127
|
-
expiresAt = expiresAt ?? new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();
|
|
128
|
-
configManager.setAuth({
|
|
129
|
-
token: authToken,
|
|
130
|
-
expiresAt: expiresAt,
|
|
131
|
-
username: username
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
spinner.succeed('Successfully authenticated!');
|
|
135
|
-
console.log(chalk.green('✓ Authentication stored securely'));
|
|
136
|
-
console.log(chalk.blue('You can now use other BuildX CLI commands'));
|
|
137
|
-
|
|
138
|
-
} catch (error) {
|
|
139
|
-
spinner.fail('Authentication failed');
|
|
140
|
-
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
141
|
-
process.exit(1);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
} catch (error) {
|
|
145
|
-
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
146
|
-
process.exit(1);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { configManager } from '../../config/index';
|
|
4
|
-
|
|
5
|
-
export const logoutCommand = new Command('logout')
|
|
6
|
-
.description('Logout and clear stored authentication')
|
|
7
|
-
.action(() => {
|
|
8
|
-
try {
|
|
9
|
-
configManager.clearAuth();
|
|
10
|
-
console.log(chalk.green('✓ Successfully logged out'));
|
|
11
|
-
console.log(chalk.blue('Authentication token has been cleared'));
|
|
12
|
-
} catch (error) {
|
|
13
|
-
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { configManager } from '../../config/index';
|
|
4
|
-
import { apiService } from '../../services/api';
|
|
5
|
-
import ora from 'ora';
|
|
6
|
-
|
|
7
|
-
export const authStatusCommand = new Command('auth:status')
|
|
8
|
-
.description('Check authentication status')
|
|
9
|
-
.action(async () => {
|
|
10
|
-
try {
|
|
11
|
-
// Check API configuration
|
|
12
|
-
if (!apiService.isConfigured()) {
|
|
13
|
-
console.error(chalk.red('❌ API not configured'));
|
|
14
|
-
console.log(chalk.yellow('Please configure your API endpoint and API key first:'));
|
|
15
|
-
console.log(chalk.cyan(' buildx config setup'));
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
const isAuthenticated = configManager.isAuthenticated();
|
|
19
|
-
const auth = configManager.getAuth();
|
|
20
|
-
|
|
21
|
-
if (isAuthenticated && auth) {
|
|
22
|
-
const spinner = ora('Validating session...').start();
|
|
23
|
-
try {
|
|
24
|
-
// Call /auth/me endpoint
|
|
25
|
-
const me = await apiService.getMe();
|
|
26
|
-
spinner.succeed('Authenticated');
|
|
27
|
-
console.log(chalk.green('✓ Authenticated'));
|
|
28
|
-
console.log(chalk.blue('Username:'), me.username);
|
|
29
|
-
if (auth.token) {
|
|
30
|
-
console.log(chalk.blue('Token:'), auth.token.substring(0, 8) + '...');
|
|
31
|
-
}
|
|
32
|
-
if (auth.expiresAt) {
|
|
33
|
-
console.log(chalk.blue('Expires:'), new Date(auth.expiresAt).toLocaleString());
|
|
34
|
-
}
|
|
35
|
-
// console.log(chalk.gray('Raw response:'), JSON.stringify(me, null, 2));
|
|
36
|
-
if (me.username) {
|
|
37
|
-
console.log(chalk.blue(`You are authenticated as ${me.source}:${me.username}`));
|
|
38
|
-
}
|
|
39
|
-
} catch (error) {
|
|
40
|
-
spinner.fail('Session invalid');
|
|
41
|
-
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
console.log(chalk.red('✗ Not authenticated'));
|
|
46
|
-
console.log(chalk.yellow('Run "buildx login" to authenticate'));
|
|
47
|
-
}
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { configManager } from '../../config/index';
|
|
4
|
-
|
|
5
|
-
export const configClearCommand = new Command('clear')
|
|
6
|
-
.description('Clear all CLI configuration (API, auth, projects, sync)')
|
|
7
|
-
.action(() => {
|
|
8
|
-
try {
|
|
9
|
-
configManager.clear();
|
|
10
|
-
console.log(chalk.green('✅ All configuration cleared.'));
|
|
11
|
-
console.log(chalk.yellow('You must run "buildx config setup" before using the CLI again.'));
|
|
12
|
-
} catch (error) {
|
|
13
|
-
console.error(chalk.red('❌ Failed to clear configuration:'), error instanceof Error ? error.message : 'Unknown error');
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { setupCommand } from './setup';
|
|
3
|
-
import { configShowCommand } from './show';
|
|
4
|
-
import { configClearCommand } from './clear';
|
|
5
|
-
|
|
6
|
-
export const configCommand = new Command('config')
|
|
7
|
-
.description('Manage CLI configuration')
|
|
8
|
-
.addCommand(setupCommand)
|
|
9
|
-
.addCommand(configShowCommand)
|
|
10
|
-
.addCommand(configClearCommand);
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import inquirer from 'inquirer';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { configManager } from '../../config/index';
|
|
5
|
-
|
|
6
|
-
export const setupCommand = new Command('setup')
|
|
7
|
-
.description('Configure API endpoint and API key')
|
|
8
|
-
.option('-e, --endpoint <endpoint>', 'API endpoint URL')
|
|
9
|
-
.option('-k, --api-key <apiKey>', 'API key')
|
|
10
|
-
.action(async (options) => {
|
|
11
|
-
try {
|
|
12
|
-
let endpoint = options.endpoint;
|
|
13
|
-
let apiKey = options.apiKey;
|
|
14
|
-
|
|
15
|
-
// If not provided via options, prompt interactively
|
|
16
|
-
if (!endpoint || !apiKey) {
|
|
17
|
-
console.log(chalk.blue('🔧 BuildX CLI Setup'));
|
|
18
|
-
console.log(chalk.gray('Configure your API endpoint and API key to get started.\n'));
|
|
19
|
-
|
|
20
|
-
const currentConfig = configManager.getApiConfig();
|
|
21
|
-
|
|
22
|
-
const answers = await inquirer.prompt([
|
|
23
|
-
{
|
|
24
|
-
type: 'input',
|
|
25
|
-
name: 'endpoint',
|
|
26
|
-
message: 'Enter your API endpoint URL:',
|
|
27
|
-
default: currentConfig?.endpoint || 'https://api.buildx.com',
|
|
28
|
-
validate: (input: string) => {
|
|
29
|
-
if (!input.trim()) {
|
|
30
|
-
return 'Endpoint URL is required';
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
new URL(input);
|
|
34
|
-
return true;
|
|
35
|
-
} catch {
|
|
36
|
-
return 'Please enter a valid URL';
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
type: 'password',
|
|
42
|
-
name: 'apiKey',
|
|
43
|
-
message: 'Enter your API key:',
|
|
44
|
-
default: currentConfig?.apiKey || '',
|
|
45
|
-
validate: (input: string) => {
|
|
46
|
-
if (!input.trim()) {
|
|
47
|
-
return 'API key is required';
|
|
48
|
-
}
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
]);
|
|
53
|
-
|
|
54
|
-
endpoint = answers.endpoint;
|
|
55
|
-
apiKey = answers.apiKey;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Save the configuration
|
|
59
|
-
configManager.setApiConfig({
|
|
60
|
-
endpoint: endpoint.trim(),
|
|
61
|
-
apiKey: apiKey.trim()
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
console.log(chalk.green('✅ Configuration saved successfully!'));
|
|
65
|
-
console.log(chalk.gray(`Endpoint: ${endpoint}`));
|
|
66
|
-
console.log(chalk.gray(`API Key: ${'*'.repeat(Math.min(apiKey.length, 8))}...`));
|
|
67
|
-
console.log(chalk.blue('\nYou can now use the CLI commands. Start with:'));
|
|
68
|
-
console.log(chalk.cyan(' buildx login'));
|
|
69
|
-
console.log(chalk.cyan(' buildx projects:list'));
|
|
70
|
-
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.error(chalk.red('❌ Setup failed:'), error instanceof Error ? error.message : 'Unknown error');
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { configManager } from '../../config/index';
|
|
4
|
-
|
|
5
|
-
export const configShowCommand = new Command('show')
|
|
6
|
-
.description('Show current configuration')
|
|
7
|
-
.action(() => {
|
|
8
|
-
try {
|
|
9
|
-
const apiConfig = configManager.getApiConfig();
|
|
10
|
-
const authConfig = configManager.getAuth();
|
|
11
|
-
const projectsConfig = configManager.getProjects();
|
|
12
|
-
const syncConfig = configManager.getSyncConfig();
|
|
13
|
-
|
|
14
|
-
console.log(chalk.blue('🔧 BuildX CLI Configuration'));
|
|
15
|
-
console.log(chalk.gray('='.repeat(50)));
|
|
16
|
-
|
|
17
|
-
// API Configuration
|
|
18
|
-
console.log(chalk.yellow('\n📡 API Configuration:'));
|
|
19
|
-
if (apiConfig) {
|
|
20
|
-
console.log(chalk.green(' ✅ Configured'));
|
|
21
|
-
console.log(chalk.gray(` Endpoint: ${apiConfig.endpoint}`));
|
|
22
|
-
console.log(chalk.gray(` API Key: ${'*'.repeat(Math.min(apiConfig.apiKey.length, 8))}...`));
|
|
23
|
-
} else {
|
|
24
|
-
console.log(chalk.red(' ❌ Not configured'));
|
|
25
|
-
console.log(chalk.gray(' Run "buildx setup" to configure'));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Authentication
|
|
29
|
-
console.log(chalk.yellow('\n🔐 Authentication:'));
|
|
30
|
-
if (authConfig && configManager.isAuthenticated()) {
|
|
31
|
-
console.log(chalk.green(' ✅ Authenticated'));
|
|
32
|
-
console.log(chalk.gray(` Token: ${authConfig.token.substring(0, 20)}...`));
|
|
33
|
-
if (authConfig.expiresAt) {
|
|
34
|
-
console.log(chalk.gray(` Expires: ${new Date(authConfig.expiresAt).toLocaleString()}`));
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
console.log(chalk.red(' ❌ Not authenticated'));
|
|
38
|
-
console.log(chalk.gray(' Run "buildx login" to authenticate'));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Projects
|
|
42
|
-
console.log(chalk.yellow('\n📁 Projects:'));
|
|
43
|
-
if (projectsConfig?.list && projectsConfig.list.length > 0) {
|
|
44
|
-
console.log(chalk.green(` ✅ ${projectsConfig.list.length} project(s) available`));
|
|
45
|
-
if (projectsConfig.default) {
|
|
46
|
-
const defaultProject = projectsConfig.list.find(p => p.id === projectsConfig.default);
|
|
47
|
-
console.log(chalk.gray(` Default: ${defaultProject?.name || projectsConfig.default}`));
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
console.log(chalk.red(' ❌ No projects available'));
|
|
51
|
-
console.log(chalk.gray(' Run "buildx projects:list" to fetch projects'));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Sync Configuration
|
|
55
|
-
console.log(chalk.yellow('\n🔄 Sync Configuration:'));
|
|
56
|
-
if (syncConfig) {
|
|
57
|
-
console.log(chalk.gray(` Output Path: ${syncConfig.outputPath}`));
|
|
58
|
-
} else {
|
|
59
|
-
console.log(chalk.gray(' Using default sync configuration'));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Configuration file location
|
|
63
|
-
console.log(chalk.yellow('\n📂 Configuration File:'));
|
|
64
|
-
console.log(chalk.gray(` ${configManager.getConfigPath()}`));
|
|
65
|
-
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error(chalk.red('❌ Failed to show configuration:'), error instanceof Error ? error.message : 'Unknown error');
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { configManager } from '../../config/index';
|
|
4
|
-
|
|
5
|
-
export const projectsCurrentCommand = new Command('projects:current')
|
|
6
|
-
.description('Show current default project')
|
|
7
|
-
.action(() => {
|
|
8
|
-
try {
|
|
9
|
-
const defaultProjectId = configManager.getDefaultProject();
|
|
10
|
-
|
|
11
|
-
if (!defaultProjectId) {
|
|
12
|
-
console.log(chalk.yellow('No default project set'));
|
|
13
|
-
console.log(chalk.blue('Use "buildx projects:set-default <project-id>" to set a default project'));
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const project = configManager.getProject(defaultProjectId);
|
|
18
|
-
|
|
19
|
-
if (!project) {
|
|
20
|
-
console.log(chalk.red('Error: Default project not found in configuration'));
|
|
21
|
-
console.log(chalk.blue('Project ID:'), defaultProjectId);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
console.log(chalk.green('Current default project:'));
|
|
26
|
-
console.log(chalk.blue('Name:'), project.name);
|
|
27
|
-
console.log(chalk.blue('ID:'), project.id);
|
|
28
|
-
if (project.apiUrl) {
|
|
29
|
-
console.log(chalk.blue('API URL:'), project.apiUrl);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
import { configManager } from '../../config/index';
|
|
5
|
-
import { apiService } from '../../services/api';
|
|
6
|
-
|
|
7
|
-
export const projectsListCommand = new Command('projects:list')
|
|
8
|
-
.description('List available projects')
|
|
9
|
-
.action(async () => {
|
|
10
|
-
try {
|
|
11
|
-
// Check API configuration
|
|
12
|
-
if (!apiService.isConfigured()) {
|
|
13
|
-
console.error(chalk.red('❌ API not configured'));
|
|
14
|
-
console.log(chalk.yellow('Please configure your API endpoint and API key first:'));
|
|
15
|
-
console.log(chalk.cyan(' buildx config setup'));
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
// Check authentication
|
|
19
|
-
if (!configManager.isAuthenticated()) {
|
|
20
|
-
console.error(chalk.red('Error: Not authenticated'));
|
|
21
|
-
console.log(chalk.yellow('Run "buildx login" to authenticate first'));
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const spinner = ora('Fetching projects...').start();
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
const projects = await apiService.getProjects();
|
|
29
|
-
spinner.succeed(`Found ${projects.length} projects`);
|
|
30
|
-
|
|
31
|
-
if (projects.length === 0) {
|
|
32
|
-
console.log(chalk.yellow('No projects found'));
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const defaultProject = configManager.getDefaultProject();
|
|
37
|
-
|
|
38
|
-
console.log('\n' + chalk.blue.bold('Available Projects:'));
|
|
39
|
-
projects.forEach(project => {
|
|
40
|
-
const isDefault = project.id === defaultProject;
|
|
41
|
-
const prefix = isDefault ? chalk.green('★ ') : ' ';
|
|
42
|
-
console.log(`${prefix}${chalk.bold(project.name)} (${project.id})`);
|
|
43
|
-
if (project.apiUrl) {
|
|
44
|
-
console.log(` API: ${chalk.gray(project.apiUrl)}`);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
if (defaultProject) {
|
|
49
|
-
console.log(chalk.green('\n★ Default project'));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
} catch (error) {
|
|
53
|
-
spinner.fail('Failed to fetch projects');
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { configManager } from '../../config/index';
|
|
4
|
-
|
|
5
|
-
export const projectsSetDefaultCommand = new Command('projects:set-default')
|
|
6
|
-
.description('Set default project')
|
|
7
|
-
.argument('<project-id>', 'Project ID to set as default')
|
|
8
|
-
.action(async (projectId: string) => {
|
|
9
|
-
try {
|
|
10
|
-
// Check authentication
|
|
11
|
-
if (!configManager.isAuthenticated()) {
|
|
12
|
-
console.error(chalk.red('Error: Not authenticated'));
|
|
13
|
-
console.log(chalk.yellow('Run "buildx login" to authenticate first'));
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Check if project exists in config
|
|
18
|
-
const project = configManager.getProject(projectId);
|
|
19
|
-
if (!project) {
|
|
20
|
-
console.error(chalk.red('Error: Project not found in configuration'));
|
|
21
|
-
console.log(chalk.yellow('Run "buildx projects:list" to see available projects'));
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
configManager.setDefaultProject(projectId);
|
|
26
|
-
console.log(chalk.green('✓ Default project set to:'), project.name);
|
|
27
|
-
console.log(chalk.blue('Project ID:'), projectId);
|
|
28
|
-
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
});
|