@useeventstack/cli 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.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import chalk from 'chalk';
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import archiver from 'archiver';
7
+ import { EventStackClient } from '@useeventstack/sdk';
8
+ const program = new Command();
9
+ program
10
+ .name('eventstack')
11
+ .description('EventStack Slice CLI')
12
+ .version('0.1.0');
13
+ program.command('validate')
14
+ .description('Validate a slice manifest and handlers')
15
+ .option('-p, --path <path>', 'Path to slice directory', '.')
16
+ .action(async (options) => {
17
+ console.log(chalk.blue('Validating slice...'));
18
+ const slicePath = path.resolve(options.path);
19
+ const manifestPath = path.join(slicePath, 'slice.config.js');
20
+ if (!fs.existsSync(manifestPath)) {
21
+ console.error(chalk.red(`Error: slice.config.js not found at ${slicePath}`));
22
+ process.exit(1);
23
+ }
24
+ try {
25
+ const config = (await import(`file://${manifestPath}`)).default;
26
+ const { manifest } = config;
27
+ if (!manifest.id || !manifest.name || !manifest.version) {
28
+ throw new Error('Manifest missing required fields: id, name, version');
29
+ }
30
+ console.log(chalk.green(`✓ Slice "${manifest.name}" (${manifest.id}) is valid.`));
31
+ }
32
+ catch (err) {
33
+ console.error(chalk.red(`Validation failed: ${err.message}`));
34
+ process.exit(1);
35
+ }
36
+ });
37
+ program.command('package')
38
+ .description('Package a slice for distribution')
39
+ .option('-p, --path <path>', 'Path to slice directory', '.')
40
+ .option('-o, --out <out>', 'Output zip file', 'slice.zip')
41
+ .action(async (options) => {
42
+ console.log(chalk.blue('Packaging slice...'));
43
+ const slicePath = path.resolve(options.path);
44
+ const output = fs.createWriteStream(path.resolve(options.out));
45
+ const archive = archiver('zip', { zlib: { level: 9 } });
46
+ output.on('close', () => {
47
+ console.log(chalk.green(`✓ Slice packaged: ${options.out} (${archive.pointer()} total bytes)`));
48
+ });
49
+ archive.on('error', (err) => {
50
+ throw err;
51
+ });
52
+ archive.pipe(output);
53
+ archive.directory(slicePath, false);
54
+ await archive.finalize();
55
+ });
56
+ program.command('publish')
57
+ .description('Publish a slice to EventStack')
58
+ .requiredOption('-k, --api-key <key>', 'EventStack API Key')
59
+ .option('-p, --package <zip>', 'Path to packaged zip', 'slice.zip')
60
+ .option('-u, --url <url>', 'EventStack API URL', 'http://localhost:3001')
61
+ .action(async (options) => {
62
+ console.log(chalk.blue('Publishing slice...'));
63
+ // In a real implementation, we'd upload the zip to a bucket and then call the API.
64
+ // For MVP, we'll assume the API can receive the zip or we provide a URL.
65
+ const client = new EventStackClient({
66
+ apiKey: options.apiKey,
67
+ baseUrl: options.url,
68
+ });
69
+ try {
70
+ console.log(chalk.yellow('Uploading package...'));
71
+ // Mocking the upload for now as we don't have a real bucket integration
72
+ console.log(chalk.gray(`Reading package ${options.package}...`));
73
+ const manifestPath = path.resolve(process.cwd(), 'manifest.json');
74
+ if (!fs.existsSync(manifestPath)) {
75
+ throw new Error('manifest.json not found in current directory.');
76
+ }
77
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
78
+ await client.request('/slices/package', {
79
+ method: 'POST',
80
+ headers: { 'Content-Type': 'application/json' },
81
+ body: JSON.stringify({
82
+ manifest,
83
+ zip_url: `s3://eventstack-slices-mock/${options.package}`
84
+ }),
85
+ });
86
+ console.log(chalk.green('✓ Slice submitted for review.'));
87
+ }
88
+ catch (err) {
89
+ console.error(chalk.red(`Publish failed: ${err.message}`));
90
+ process.exit(1);
91
+ }
92
+ });
93
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@useeventstack/cli",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "type": "module",
12
+ "bin": {
13
+ "eventstack": "./dist/index.js"
14
+ },
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "typecheck": "tsc --noEmit"
18
+ },
19
+ "dependencies": {
20
+ "@useeventstack/sdk": "*",
21
+ "archiver": "^7.0.1",
22
+ "chalk": "^5.4.1",
23
+ "commander": "^13.1.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/archiver": "^7.0.0",
27
+ "@types/node": "^24.10.1",
28
+ "typescript": "^5.9.3"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/useeventstack/eventstack.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/useeventstack/eventstack/issues"
36
+ },
37
+ "homepage": "https://github.com/useeventstack/eventstack#readme",
38
+ "license": "MIT"
39
+ }