blok0 0.1.1 โ 0.1.3
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/handlers/add-block.js +29 -36
- package/dist/handlers/generate.js +18 -35
- package/dist/handlers/login.js +20 -29
- package/dist/index.js +25 -18
- package/dist/ui.d.ts +77 -0
- package/dist/ui.js +222 -0
- package/package.json +37 -33
- package/src/detectors.ts +22 -22
- package/src/handlers/add-block.ts +53 -40
- package/src/handlers/generate.ts +59 -62
- package/src/handlers/login.ts +40 -29
- package/src/index.ts +34 -18
- package/src/ui.ts +234 -0
- package/tsconfig.json +16 -16
|
@@ -40,35 +40,32 @@ const api_1 = require("../api");
|
|
|
40
40
|
const registry_1 = require("../registry");
|
|
41
41
|
const blocks_1 = require("../blocks");
|
|
42
42
|
const ast_1 = require("../ast");
|
|
43
|
+
const ui_1 = require("../ui");
|
|
43
44
|
/**
|
|
44
45
|
* Handle add block command
|
|
45
46
|
*/
|
|
46
47
|
async function handleAddBlock(blockUrl, options = {}) {
|
|
47
|
-
|
|
48
|
-
console.log('====================');
|
|
49
|
-
console.log('');
|
|
48
|
+
(0, ui_1.showSection)('๐ฆ Adding Blok0 Block', ui_1.EMOJIS.PACKAGE);
|
|
50
49
|
try {
|
|
51
50
|
// Step 1: Authentication check
|
|
52
|
-
|
|
53
|
-
const authenticated = await (0, auth_1.isAuthenticated)();
|
|
51
|
+
const authenticated = await (0, ui_1.withSpinner)('Checking authentication', () => (0, auth_1.isAuthenticated)(), { emoji: ui_1.EMOJIS.LOCK });
|
|
54
52
|
if (!authenticated) {
|
|
55
|
-
|
|
53
|
+
ui_1.log.error('You are not logged in. Please run `blok0 login` first.');
|
|
56
54
|
process.exit(1);
|
|
57
55
|
}
|
|
58
56
|
// Step 2: Fetch block data from API
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
console.log(`โ
Found block: "${metadata.name}" (${metadata.slug})`);
|
|
57
|
+
const { metadata, files } = await (0, ui_1.withSpinner)(`Fetching block from ${blockUrl}`, () => api_1.apiClient.fetchBlockData(blockUrl), { emoji: ui_1.EMOJIS.SEARCH });
|
|
58
|
+
ui_1.log.success(`Found block: "${metadata.name}" (${metadata.slug})`);
|
|
62
59
|
// Step 3: Check if block is already registered
|
|
63
60
|
if ((0, registry_1.isBlockRegistered)(metadata.slug)) {
|
|
64
61
|
if (!options.force) {
|
|
65
|
-
|
|
62
|
+
ui_1.log.error(`Block "${metadata.slug}" is already installed. Use --force to reinstall.`);
|
|
66
63
|
process.exit(1);
|
|
67
64
|
}
|
|
68
|
-
|
|
65
|
+
ui_1.log.warning('Block already exists, reinstalling...');
|
|
69
66
|
}
|
|
70
67
|
if (options.dryRun) {
|
|
71
|
-
|
|
68
|
+
ui_1.log.info('Dry run mode - would perform the following actions:');
|
|
72
69
|
console.log(` - Create directory: src/blocks/${metadata.slug}`);
|
|
73
70
|
console.log(` - Download ${files.length} files`);
|
|
74
71
|
console.log(' - Update Payload config');
|
|
@@ -79,13 +76,12 @@ async function handleAddBlock(blockUrl, options = {}) {
|
|
|
79
76
|
// Step 4: Ensure blocks directory exists
|
|
80
77
|
const blocksDir = (0, blocks_1.ensureBlocksDirectory)();
|
|
81
78
|
// Step 5: Create block directory and files
|
|
82
|
-
console.log('๐ Creating block directory and files...');
|
|
83
79
|
const { dir, configPath, componentPath } = (0, blocks_1.createBlockDirectory)(blocksDir, metadata.slug, files);
|
|
84
|
-
|
|
80
|
+
ui_1.log.success(`Created block directory: ${path.relative(process.cwd(), dir)}`);
|
|
85
81
|
// Step 6: Validate created block
|
|
86
82
|
const validation = (0, blocks_1.validateBlockDirectory)(dir);
|
|
87
83
|
if (!validation.valid) {
|
|
88
|
-
|
|
84
|
+
ui_1.log.error('Block validation failed:');
|
|
89
85
|
validation.errors.forEach(error => console.error(` - ${error}`));
|
|
90
86
|
// Cleanup on failure
|
|
91
87
|
require('fs').rmSync(dir, { recursive: true, force: true });
|
|
@@ -103,37 +99,34 @@ async function handleAddBlock(blockUrl, options = {}) {
|
|
|
103
99
|
// Step 9: Update Pages collection (AST manipulation)
|
|
104
100
|
const pagesCollectionPath = (0, ast_1.findPagesCollection)();
|
|
105
101
|
if (pagesCollectionPath) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
await (0, ui_1.withSpinner)('Updating Pages collection', async () => {
|
|
103
|
+
const blockIdentifier = (0, blocks_1.slugToIdentifier)(metadata.slug);
|
|
104
|
+
const relativeConfigPath = `@/blocks/${metadata.slug}/config`;
|
|
105
|
+
(0, ast_1.updatePageCollectionConfig)(pagesCollectionPath, relativeConfigPath, blockIdentifier);
|
|
106
|
+
}, { emoji: ui_1.EMOJIS.GEAR, successText: `Added ${(0, blocks_1.slugToIdentifier)(metadata.slug)} to Pages collection` });
|
|
111
107
|
}
|
|
112
108
|
else {
|
|
113
|
-
|
|
109
|
+
ui_1.log.warning('Could not find Pages collection file. You may need to manually add the block to your collections.');
|
|
114
110
|
}
|
|
115
111
|
// Step 10: Update RenderBlocks component (AST manipulation)
|
|
116
112
|
const renderBlocksPath = (0, ast_1.findRenderBlocksComponent)();
|
|
117
113
|
if (renderBlocksPath) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
await (0, ui_1.withSpinner)('Updating RenderBlocks component', async () => {
|
|
115
|
+
const relativeComponentPath = `./${metadata.slug}/Component`;
|
|
116
|
+
(0, ast_1.updateRenderBlocksComponent)(renderBlocksPath, metadata.slug, relativeComponentPath);
|
|
117
|
+
}, { emoji: ui_1.EMOJIS.GEAR, successText: `Added ${metadata.slug} component to RenderBlocks` });
|
|
122
118
|
}
|
|
123
119
|
else {
|
|
124
|
-
|
|
120
|
+
ui_1.log.warning('Could not find RenderBlocks component. You may need to manually add the block component.');
|
|
125
121
|
}
|
|
126
122
|
// Step 11: Register block in registry
|
|
127
|
-
|
|
128
|
-
(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
console.log('1. Review the installed files in src/blocks/' + metadata.slug);
|
|
135
|
-
console.log('2. Test your application to ensure the block works correctly');
|
|
136
|
-
console.log('3. Commit the changes to your repository');
|
|
123
|
+
await (0, ui_1.withSpinner)('Registering block', async () => (0, registry_1.addBlockToRegistry)(blockEntry), { emoji: ui_1.EMOJIS.CHECK, successText: 'Block registered successfully' });
|
|
124
|
+
ui_1.log.success('Block installation complete!');
|
|
125
|
+
(0, ui_1.showNextSteps)([
|
|
126
|
+
`Review the installed files in src/blocks/${metadata.slug}`,
|
|
127
|
+
'Test your application to ensure the block works correctly',
|
|
128
|
+
'Commit the changes to your repository'
|
|
129
|
+
]);
|
|
137
130
|
}
|
|
138
131
|
catch (error) {
|
|
139
132
|
console.error('โ Failed to add block:', error.message);
|
|
@@ -4,6 +4,7 @@ exports.generateStarter = generateStarter;
|
|
|
4
4
|
const readline_1 = require("readline");
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
6
|
const util_1 = require("util");
|
|
7
|
+
const ui_1 = require("../ui");
|
|
7
8
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
8
9
|
const repoUrl = 'https://github.com/blok0-payload/starter.git';
|
|
9
10
|
function prompt(question) {
|
|
@@ -19,45 +20,27 @@ function prompt(question) {
|
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
async function generateStarter() {
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
ui_1.log.header('๐ Setting up Blok0 starter project...');
|
|
24
|
+
// Clone repository with spinner
|
|
25
|
+
await (0, ui_1.withSpinner)('Cloning starter repository', async () => {
|
|
24
26
|
await execAsync(`git clone --depth 1 ${repoUrl} .`);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
// Prompt for bun install
|
|
31
|
-
const installDeps = await prompt('Run \'bun install\' to install dependencies? (y/n): ');
|
|
32
|
-
if (installDeps) {
|
|
33
|
-
console.log('Installing dependencies...');
|
|
34
|
-
try {
|
|
35
|
-
await new Promise((resolve, reject) => {
|
|
36
|
-
const child = (0, child_process_1.spawn)('bun', ['install'], { stdio: 'inherit' });
|
|
37
|
-
child.on('close', (code) => {
|
|
38
|
-
if (code === 0)
|
|
39
|
-
resolve();
|
|
40
|
-
else
|
|
41
|
-
reject(new Error('Failed to install dependencies'));
|
|
42
|
-
});
|
|
43
|
-
child.on('error', reject);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
console.error('Failed to install dependencies:', error);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
27
|
+
}, {
|
|
28
|
+
emoji: ui_1.EMOJIS.DOWNLOAD,
|
|
29
|
+
successText: 'Repository cloned successfully'
|
|
30
|
+
});
|
|
50
31
|
// Prompt for git init
|
|
51
32
|
const initGit = await prompt('Initialize git repository? (y/n): ');
|
|
52
33
|
if (initGit) {
|
|
53
|
-
|
|
54
|
-
try {
|
|
34
|
+
await (0, ui_1.withSpinner)('Initializing git repository', async () => {
|
|
55
35
|
await execAsync('git init');
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
36
|
+
}, {
|
|
37
|
+
emoji: ui_1.EMOJIS.GEAR,
|
|
38
|
+
successText: 'Git repository initialized'
|
|
39
|
+
});
|
|
61
40
|
}
|
|
62
|
-
|
|
41
|
+
ui_1.log.success('Starter project ready!');
|
|
42
|
+
(0, ui_1.showNextSteps)([
|
|
43
|
+
'Run \'npm install\' or \'bun install\' to install dependencies',
|
|
44
|
+
'Start developing your Blok0 x PayloadCMS project'
|
|
45
|
+
]);
|
|
63
46
|
}
|
package/dist/handlers/login.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.handleLogout = handleLogout;
|
|
|
8
8
|
const auth_1 = require("../auth");
|
|
9
9
|
const server_1 = require("../auth/server");
|
|
10
10
|
const open_1 = __importDefault(require("open"));
|
|
11
|
+
const ui_1 = require("../ui");
|
|
11
12
|
// Add SIGINT handler for graceful cleanup
|
|
12
13
|
process.on('SIGINT', () => {
|
|
13
14
|
console.log('\n\nโ ๏ธ Authentication cancelled by user.');
|
|
@@ -20,14 +21,12 @@ async function handleLogin(token, manual) {
|
|
|
20
21
|
// Direct token authentication (CI/CD)
|
|
21
22
|
if (token) {
|
|
22
23
|
try {
|
|
23
|
-
|
|
24
|
-
await (0, auth_1.storeAccessToken)(token);
|
|
25
|
-
console.log('โ
Successfully authenticated!');
|
|
24
|
+
await (0, ui_1.withSpinner)('Saving authentication token', () => (0, auth_1.storeAccessToken)(token), { emoji: ui_1.EMOJIS.LOCK, successText: 'Successfully authenticated!' });
|
|
26
25
|
console.log('');
|
|
27
|
-
|
|
26
|
+
ui_1.log.info('You can now use blok0 commands that require authentication.');
|
|
28
27
|
}
|
|
29
28
|
catch (error) {
|
|
30
|
-
|
|
29
|
+
ui_1.log.error('Failed to save authentication token: ' + error.message);
|
|
31
30
|
process.exit(1);
|
|
32
31
|
}
|
|
33
32
|
return;
|
|
@@ -53,29 +52,24 @@ async function handleLogin(token, manual) {
|
|
|
53
52
|
* Handle browser-based authentication flow
|
|
54
53
|
*/
|
|
55
54
|
async function handleBrowserLogin() {
|
|
56
|
-
|
|
57
|
-
console.log('======================');
|
|
58
|
-
console.log('');
|
|
55
|
+
(0, ui_1.showSection)('๐ Blok0 Authentication', ui_1.EMOJIS.LOCK);
|
|
59
56
|
// Create authentication server
|
|
60
57
|
const authServer = new server_1.AuthServer();
|
|
61
58
|
try {
|
|
62
59
|
// Initialize server (find available port)
|
|
63
|
-
|
|
64
|
-
await authServer.initialize();
|
|
60
|
+
await (0, ui_1.withSpinner)('Starting authentication server', () => authServer.initialize(), { emoji: ui_1.EMOJIS.ROCKET });
|
|
65
61
|
// Get the authorization URL (now port is available)
|
|
66
62
|
const authUrl = authServer.getAuthorizationUrl();
|
|
67
|
-
|
|
63
|
+
ui_1.log.info('Opening browser for authentication...');
|
|
68
64
|
await (0, open_1.default)(authUrl);
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
ui_1.log.info('Please complete authentication in your browser.');
|
|
66
|
+
ui_1.log.plain('โณ Waiting for authentication to complete...');
|
|
71
67
|
// Start server and wait for callback
|
|
72
68
|
const authCallback = await authServer.start();
|
|
73
69
|
// Store the token
|
|
74
|
-
|
|
75
|
-
await (0, auth_1.storeAccessToken)(authCallback.token);
|
|
76
|
-
console.log('โ
Successfully authenticated!');
|
|
70
|
+
await (0, ui_1.withSpinner)('Saving authentication token', () => (0, auth_1.storeAccessToken)(authCallback.token), { emoji: ui_1.EMOJIS.LOCK, successText: 'Successfully authenticated!' });
|
|
77
71
|
console.log('');
|
|
78
|
-
|
|
72
|
+
ui_1.log.info('You can now use blok0 commands that require authentication.');
|
|
79
73
|
}
|
|
80
74
|
catch (error) {
|
|
81
75
|
authServer.stop();
|
|
@@ -86,39 +80,36 @@ async function handleBrowserLogin() {
|
|
|
86
80
|
* Show manual authentication instructions
|
|
87
81
|
*/
|
|
88
82
|
function showManualInstructions() {
|
|
89
|
-
|
|
90
|
-
console.log('==============================');
|
|
91
|
-
console.log('');
|
|
83
|
+
(0, ui_1.showSection)('๐ Blok0 Manual Authentication', ui_1.EMOJIS.LOCK);
|
|
92
84
|
console.log('To authenticate with the Blok0 API, make a POST request to:');
|
|
93
85
|
console.log('https://www.blok0.xyz/api/customers/login');
|
|
94
86
|
console.log('');
|
|
95
|
-
|
|
87
|
+
ui_1.log.info('Example using curl:');
|
|
96
88
|
console.log('curl -X POST https://www.blok0.xyz/api/customers/login \\');
|
|
97
89
|
console.log(' -H "Content-Type: application/json" \\');
|
|
98
90
|
console.log(' -d \'{"email": "your-email@example.com", "password": "your-password"}\'');
|
|
99
91
|
console.log('');
|
|
100
|
-
|
|
92
|
+
ui_1.log.info('Then copy the access token and run:');
|
|
101
93
|
console.log('blok0 login --token <your-token>');
|
|
102
94
|
console.log('');
|
|
103
|
-
|
|
95
|
+
ui_1.log.info('For CI/CD environments, set the BLOK0_TOKEN environment variable.');
|
|
104
96
|
console.log('');
|
|
105
|
-
|
|
97
|
+
ui_1.log.info('For browser-based login, run: blok0 login');
|
|
106
98
|
}
|
|
107
99
|
/**
|
|
108
100
|
* Handle logout command
|
|
109
101
|
*/
|
|
110
102
|
async function handleLogout() {
|
|
111
103
|
try {
|
|
112
|
-
const wasAuthenticated = await (0, auth_1.isAuthenticated)();
|
|
104
|
+
const wasAuthenticated = await (0, ui_1.withSpinner)('Checking authentication status', () => (0, auth_1.isAuthenticated)());
|
|
113
105
|
if (!wasAuthenticated) {
|
|
114
|
-
|
|
106
|
+
ui_1.log.warning('You are not currently logged in.');
|
|
115
107
|
return;
|
|
116
108
|
}
|
|
117
|
-
await (0, auth_1.clearCredentials)();
|
|
118
|
-
console.log('โ
Successfully logged out and cleared stored credentials.');
|
|
109
|
+
await (0, ui_1.withSpinner)('Clearing stored credentials', () => (0, auth_1.clearCredentials)(), { emoji: ui_1.EMOJIS.LOCK, successText: 'Successfully logged out and cleared stored credentials.' });
|
|
119
110
|
}
|
|
120
111
|
catch (error) {
|
|
121
|
-
|
|
112
|
+
ui_1.log.error('Failed to logout: ' + error.message);
|
|
122
113
|
process.exit(1);
|
|
123
114
|
}
|
|
124
115
|
}
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,7 @@ const generate_1 = require("./handlers/generate");
|
|
|
41
41
|
const login_1 = require("./handlers/login");
|
|
42
42
|
const add_block_1 = require("./handlers/add-block");
|
|
43
43
|
const registry_1 = require("./registry");
|
|
44
|
+
const ui_1 = require("./ui");
|
|
44
45
|
function prompt(question) {
|
|
45
46
|
return new Promise((resolve) => {
|
|
46
47
|
const rl = (0, readline_1.createInterface)({
|
|
@@ -75,27 +76,37 @@ OPTIONS:
|
|
|
75
76
|
--version, -v Show version information
|
|
76
77
|
--verbose Enable verbose logging
|
|
77
78
|
--dry-run Preview changes without applying them
|
|
79
|
+
--no-animation Disable animations and spinners
|
|
80
|
+
--no-emoji Disable emoji in output
|
|
81
|
+
--ci Optimize for CI environments (implies --no-animation and --no-emoji)
|
|
78
82
|
|
|
79
83
|
EXAMPLES:
|
|
80
84
|
blok0 login
|
|
81
85
|
blok0 generate starter my-project
|
|
82
|
-
blok0 add block https://
|
|
86
|
+
blok0 add block https://www.blok0.com/api/cli/sections/123
|
|
83
87
|
|
|
84
88
|
For more information, visit: https://github.com/blok0-payload/cli
|
|
85
89
|
`);
|
|
86
90
|
}
|
|
87
91
|
async function main() {
|
|
88
92
|
const args = process.argv.slice(2);
|
|
89
|
-
|
|
93
|
+
// Parse global UI flags
|
|
94
|
+
const noAnimation = args.includes('--no-animation');
|
|
95
|
+
const noEmoji = args.includes('--no-emoji');
|
|
96
|
+
const ciMode = args.includes('--ci');
|
|
97
|
+
(0, ui_1.setUIFlags)({ noAnimation, noEmoji, ci: ciMode });
|
|
98
|
+
// Filter out global flags from args
|
|
99
|
+
const filteredArgs = args.filter(arg => !['--no-animation', '--no-emoji', '--ci'].includes(arg));
|
|
100
|
+
if (filteredArgs.length === 0 || filteredArgs.includes('--help') || filteredArgs.includes('-h')) {
|
|
90
101
|
showHelp();
|
|
91
102
|
process.exit(0);
|
|
92
103
|
}
|
|
93
|
-
if (
|
|
104
|
+
if (filteredArgs.includes('--version') || filteredArgs.includes('-v')) {
|
|
94
105
|
const pkg = require('../package.json');
|
|
95
106
|
console.log(`blok0 v${pkg.version}`);
|
|
96
107
|
process.exit(0);
|
|
97
108
|
}
|
|
98
|
-
const [command, ...restArgs] =
|
|
109
|
+
const [command, ...restArgs] = filteredArgs;
|
|
99
110
|
try {
|
|
100
111
|
switch (command) {
|
|
101
112
|
case 'generate':
|
|
@@ -132,9 +143,9 @@ async function main() {
|
|
|
132
143
|
case 'add':
|
|
133
144
|
const [addSubcommand, ...addRestArgs] = restArgs;
|
|
134
145
|
if (addSubcommand === 'block') {
|
|
135
|
-
const blockUrl = addRestArgs[0]
|
|
146
|
+
const blockUrl = `https://www.blok0.com/api/cli/sections/${addRestArgs[0]}`;
|
|
136
147
|
if (!blockUrl) {
|
|
137
|
-
console.error('Error: Block
|
|
148
|
+
console.error('Error: Block Slug is required. Use: blok0 add block <slug>');
|
|
138
149
|
process.exit(1);
|
|
139
150
|
}
|
|
140
151
|
const options = {
|
|
@@ -144,7 +155,7 @@ async function main() {
|
|
|
144
155
|
await (0, add_block_1.handleAddBlock)(blockUrl, options);
|
|
145
156
|
}
|
|
146
157
|
else {
|
|
147
|
-
console.error('Error: Invalid subcommand. Use: blok0 add block <
|
|
158
|
+
console.error('Error: Invalid subcommand. Use: blok0 add block <slug>');
|
|
148
159
|
process.exit(1);
|
|
149
160
|
}
|
|
150
161
|
break;
|
|
@@ -187,37 +198,33 @@ async function handleGenerateStarter(args) {
|
|
|
187
198
|
}
|
|
188
199
|
}
|
|
189
200
|
async function handleDebug() {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
console.log('');
|
|
201
|
+
const { showSection, log, withSpinner, EMOJIS } = await Promise.resolve().then(() => __importStar(require('./ui')));
|
|
202
|
+
showSection('๐ Blok0 CLI Debug Information', EMOJIS.SEARCH);
|
|
193
203
|
// Check stored token
|
|
194
204
|
const { getAccessToken, isAuthenticated } = await Promise.resolve().then(() => __importStar(require('./auth')));
|
|
195
205
|
const token = await getAccessToken();
|
|
196
206
|
const isAuth = await isAuthenticated();
|
|
197
|
-
|
|
207
|
+
log.header('๐ Authentication Status:');
|
|
198
208
|
console.log(` Authenticated: ${isAuth ? 'โ
Yes' : 'โ No'}`);
|
|
199
209
|
console.log(` Token Stored: ${token ? 'โ
Yes' : 'โ No'}`);
|
|
200
210
|
if (token) {
|
|
201
211
|
console.log(` Token Preview: ${token.substring(0, 20)}...`);
|
|
202
212
|
console.log(` Authorization Header: Bearer ${token}`);
|
|
203
213
|
}
|
|
204
|
-
|
|
205
|
-
console.log('๐ API Configuration:');
|
|
214
|
+
log.header('๐ API Configuration:');
|
|
206
215
|
console.log(' Base URL: https://www.blok0.xyz');
|
|
207
216
|
console.log(' User Agent: blok0-cli/1.0.0');
|
|
208
|
-
|
|
209
|
-
console.log('๐งช Test API Connection:');
|
|
217
|
+
log.header('๐งช Test API Connection:');
|
|
210
218
|
// Test API connection
|
|
211
219
|
const { apiClient } = await Promise.resolve().then(() => __importStar(require('./api')));
|
|
212
220
|
try {
|
|
213
|
-
const connectionTest = await apiClient.testConnection();
|
|
221
|
+
const connectionTest = await withSpinner('Testing API connection', () => apiClient.testConnection());
|
|
214
222
|
console.log(` Connection Test: ${connectionTest ? 'โ
Passed' : 'โ Failed'}`);
|
|
215
223
|
}
|
|
216
224
|
catch (error) {
|
|
217
225
|
console.log(` Connection Test: โ Failed - ${error.message}`);
|
|
218
226
|
}
|
|
219
|
-
|
|
220
|
-
console.log('๐ก Next Steps:');
|
|
227
|
+
log.header('๐ก Next Steps:');
|
|
221
228
|
console.log(' 1. If no token, run: blok0 login');
|
|
222
229
|
console.log(' 2. Test API with: blok0 add block <url>');
|
|
223
230
|
console.log(' 3. Check server logs for detailed request info');
|
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export declare const EMOJIS: {
|
|
2
|
+
readonly SUCCESS: "โ
";
|
|
3
|
+
readonly ERROR: "โ";
|
|
4
|
+
readonly WARNING: "โ ๏ธ";
|
|
5
|
+
readonly INFO: "โน๏ธ";
|
|
6
|
+
readonly LOCK: "๐";
|
|
7
|
+
readonly PACKAGE: "๐ฆ";
|
|
8
|
+
readonly FOLDER: "๐";
|
|
9
|
+
readonly GEAR: "๐ง";
|
|
10
|
+
readonly SEARCH: "๐";
|
|
11
|
+
readonly ROCKET: "๐";
|
|
12
|
+
readonly DOWNLOAD: "๐ฅ";
|
|
13
|
+
readonly PARTY: "๐";
|
|
14
|
+
readonly WRENCH: "๐ง";
|
|
15
|
+
readonly CHECK: "โ
";
|
|
16
|
+
readonly CROSS: "โ";
|
|
17
|
+
readonly ARROW: "โ";
|
|
18
|
+
};
|
|
19
|
+
export declare const colors: {
|
|
20
|
+
success: import("chalk").ChalkInstance;
|
|
21
|
+
error: import("chalk").ChalkInstance;
|
|
22
|
+
warning: import("chalk").ChalkInstance;
|
|
23
|
+
info: import("chalk").ChalkInstance;
|
|
24
|
+
accent: import("chalk").ChalkInstance;
|
|
25
|
+
muted: import("chalk").ChalkInstance;
|
|
26
|
+
};
|
|
27
|
+
export declare const isTTY: boolean;
|
|
28
|
+
export declare let noAnimation: boolean;
|
|
29
|
+
export declare let noEmoji: boolean;
|
|
30
|
+
export declare let ciMode: boolean;
|
|
31
|
+
export declare function setUIFlags(flags: {
|
|
32
|
+
noAnimation?: boolean;
|
|
33
|
+
noEmoji?: boolean;
|
|
34
|
+
ci?: boolean;
|
|
35
|
+
}): void;
|
|
36
|
+
export declare class Spinner {
|
|
37
|
+
private text;
|
|
38
|
+
private emoji?;
|
|
39
|
+
private spinner;
|
|
40
|
+
private startTime;
|
|
41
|
+
constructor(text: string, emoji?: string | undefined);
|
|
42
|
+
start(): this;
|
|
43
|
+
update(text: string, emoji?: string): this;
|
|
44
|
+
succeed(text?: string): this;
|
|
45
|
+
fail(text?: string): this;
|
|
46
|
+
stop(): this;
|
|
47
|
+
private getDuration;
|
|
48
|
+
}
|
|
49
|
+
export declare function withSpinner<T>(text: string, operation: () => Promise<T>, options?: {
|
|
50
|
+
emoji?: string;
|
|
51
|
+
successText?: string;
|
|
52
|
+
failText?: string;
|
|
53
|
+
}): Promise<T>;
|
|
54
|
+
export declare class ProgressBar {
|
|
55
|
+
private options;
|
|
56
|
+
private bar;
|
|
57
|
+
constructor(options: {
|
|
58
|
+
title?: string;
|
|
59
|
+
total: number;
|
|
60
|
+
format?: string;
|
|
61
|
+
});
|
|
62
|
+
start(): this;
|
|
63
|
+
update(current: number): this;
|
|
64
|
+
increment(amount?: number): this;
|
|
65
|
+
stop(): this;
|
|
66
|
+
}
|
|
67
|
+
export declare const log: {
|
|
68
|
+
success: (text: string) => void;
|
|
69
|
+
error: (text: string) => void;
|
|
70
|
+
warning: (text: string) => void;
|
|
71
|
+
info: (text: string) => void;
|
|
72
|
+
plain: (text: string) => void;
|
|
73
|
+
header: (text: string) => void;
|
|
74
|
+
step: (step: number, total: number, text: string) => void;
|
|
75
|
+
};
|
|
76
|
+
export declare function showSection(title: string, emoji?: string): void;
|
|
77
|
+
export declare function showNextSteps(steps: string[]): void;
|