buildx-cli 1.0.9 ā 1.0.10
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/.github/workflows/auto-publish.yml +254 -0
- package/.github/workflows/create-pr.yml +182 -0
- package/.prettierrc +8 -0
- package/README.md +316 -36
- package/eslint.config.mjs +115 -0
- package/jest.config.cjs +16 -0
- package/package.json +23 -1
- package/rollup.config.mjs +64 -0
- package/scripts/prepare-publish.js +12 -0
- package/src/__tests__/config.test.ts +102 -0
- package/src/__tests__/schema-types-convert.test.ts +147 -0
- package/src/commands/auth/login.ts +148 -0
- package/src/commands/auth/logout.ts +16 -0
- package/src/commands/auth/status.ts +52 -0
- package/src/commands/config/clear.ts +16 -0
- package/src/commands/config/index.ts +14 -0
- package/src/commands/config/setup.ts +108 -0
- package/src/commands/config/show.ts +96 -0
- package/src/commands/functions.ts +703 -0
- package/src/commands/projects/current.ts +36 -0
- package/src/commands/projects/list.ts +61 -0
- package/src/commands/projects/set-default.ts +59 -0
- package/src/commands/sync.ts +778 -0
- package/src/config/index.ts +169 -0
- package/src/index.ts +62 -0
- package/src/services/api.ts +198 -0
- package/src/services/schema-generator.ts +132 -0
- package/src/services/schema-types-convert.ts +361 -0
- package/src/types/index.ts +91 -0
- package/src/utils/env.ts +117 -0
- package/src/utils/logger.ts +29 -0
- package/src/utils/sync.ts +70 -0
- package/test.env +2 -0
- package/tsconfig.json +29 -0
- package/index.cjs +0 -21
- package/index.d.ts +0 -1
- package/index.js +0 -21
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { configManager } from '../../config/index';
|
|
4
|
+
import { loadEnvConfig } from '../../utils/env';
|
|
5
|
+
|
|
6
|
+
export const configShowCommand = new Command('config:show')
|
|
7
|
+
.description('Show current configuration')
|
|
8
|
+
.action(() => {
|
|
9
|
+
try {
|
|
10
|
+
const apiConfig = configManager.getApiConfig();
|
|
11
|
+
const authConfig = configManager.getAuth();
|
|
12
|
+
const projectsConfig = configManager.getProjects();
|
|
13
|
+
const syncConfig = configManager.getSyncConfig();
|
|
14
|
+
const envConfig = loadEnvConfig();
|
|
15
|
+
|
|
16
|
+
console.log(chalk.blue('š§ BuildX CLI Configuration'));
|
|
17
|
+
console.log(chalk.gray('='.repeat(50)));
|
|
18
|
+
|
|
19
|
+
// API Configuration
|
|
20
|
+
console.log(chalk.yellow('\nš” API Configuration:'));
|
|
21
|
+
if (apiConfig) {
|
|
22
|
+
console.log(chalk.green(' ā
Configured'));
|
|
23
|
+
console.log(chalk.gray(` Endpoint: ${apiConfig.endpoint}`));
|
|
24
|
+
// Show only 2 first characters of the api key
|
|
25
|
+
const slicedApiKey = apiConfig.apiKey.substring(0, 2);
|
|
26
|
+
console.log(chalk.gray(` API Key: ${slicedApiKey}${'*'.repeat(Math.min(apiConfig.apiKey.length - slicedApiKey.length, 8))}...`));
|
|
27
|
+
|
|
28
|
+
// Show source
|
|
29
|
+
const storedConfig = configManager['config'].get("api");
|
|
30
|
+
if (storedConfig?.endpoint && storedConfig?.apiKey) {
|
|
31
|
+
console.log(chalk.gray(' Source: Stored configuration'));
|
|
32
|
+
} else if (envConfig.BUILDX_API_ENDPOINT && envConfig.BUILDX_API_KEY) {
|
|
33
|
+
console.log(chalk.gray(' Source: Environment variables'));
|
|
34
|
+
if (envConfig.BUILDX_API_ENDPOINT) {
|
|
35
|
+
const endpointKey = envConfig._sources?.endpointKey || "BUILDX_API_ENDPOINT";
|
|
36
|
+
console.log(chalk.gray(` Env: ${endpointKey}=${envConfig.BUILDX_API_ENDPOINT}`));
|
|
37
|
+
}
|
|
38
|
+
if (envConfig.BUILDX_API_KEY) {
|
|
39
|
+
const slicedApiKey = envConfig.BUILDX_API_KEY.substring(0, 2);
|
|
40
|
+
const apiKeyKey = envConfig._sources?.apiKeyKey || "BUILDX_API_KEY";
|
|
41
|
+
console.log(chalk.gray(` Env: ${apiKeyKey}=${slicedApiKey}${'*'.repeat(Math.min(envConfig.BUILDX_API_KEY.length - slicedApiKey.length, 8))}...`));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
console.log(chalk.red(' ā Not configured'));
|
|
46
|
+
console.log(chalk.gray(' Run "buildx config setup" to configure'));
|
|
47
|
+
console.log(chalk.gray(' Or set BUILDX_API_ENDPOINT and BUILDX_API_KEY environment variables'));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Authentication
|
|
51
|
+
console.log(chalk.yellow('\nš Authentication:'));
|
|
52
|
+
if (authConfig && configManager.isAuthenticated()) {
|
|
53
|
+
console.log(chalk.green(' ā
Authenticated'));
|
|
54
|
+
console.log(chalk.gray(` Token: ${authConfig.token.substring(0, 20)}...`));
|
|
55
|
+
if (authConfig.expiresAt) {
|
|
56
|
+
console.log(chalk.gray(` Expires: ${new Date(authConfig.expiresAt).toLocaleString()}`));
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
console.log(chalk.red(' ā Not authenticated'));
|
|
60
|
+
console.log(chalk.gray(' Run "buildx auth:login" to authenticate'));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Projects
|
|
64
|
+
console.log(chalk.yellow('\nš Projects:'));
|
|
65
|
+
if (projectsConfig?.list && projectsConfig.list.length > 0) {
|
|
66
|
+
console.log(chalk.green(` ā
${projectsConfig.list.length} project(s) available`));
|
|
67
|
+
if (projectsConfig.default) {
|
|
68
|
+
const defaultProject = projectsConfig.list.find(p => p.project_id === projectsConfig.default);
|
|
69
|
+
console.log(chalk.gray(` Default: ${defaultProject?.name || projectsConfig.default}`));
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
console.log(chalk.red(' ā No projects available'));
|
|
73
|
+
console.log(chalk.gray(' Run "buildx projects:list" to fetch projects'));
|
|
74
|
+
if (envConfig.BUILDX_PROJECT_ID) {
|
|
75
|
+
const projectIdKey = envConfig._sources?.projectIdKey || "BUILDX_PROJECT_ID";
|
|
76
|
+
console.log(chalk.gray(` Env default candidate: ${projectIdKey}=${envConfig.BUILDX_PROJECT_ID}`));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Sync Configuration
|
|
81
|
+
console.log(chalk.yellow('\nš Sync Configuration:'));
|
|
82
|
+
if (syncConfig) {
|
|
83
|
+
console.log(chalk.gray(` Output Path: ${syncConfig.outputPath}`));
|
|
84
|
+
} else {
|
|
85
|
+
console.log(chalk.gray(' Using default sync configuration'));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Configuration file location
|
|
89
|
+
console.log(chalk.yellow('\nš Configuration File:'));
|
|
90
|
+
console.log(chalk.gray(` ${configManager.getConfigPath()}`));
|
|
91
|
+
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error(chalk.red('ā Failed to show configuration:'), error instanceof Error ? error.message : 'Unknown error');
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
});
|