@hexabot-ai/cli 3.0.0-alpha.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/.prettierrc +5 -0
- package/AGENTS.md +64 -0
- package/README.md +192 -0
- package/dist/cli.js +31 -0
- package/dist/commands/__tests__/check.test.js +97 -0
- package/dist/commands/__tests__/config.test.js +80 -0
- package/dist/commands/__tests__/dev.test.js +105 -0
- package/dist/commands/__tests__/docker.test.js +132 -0
- package/dist/commands/__tests__/env.test.js +72 -0
- package/dist/commands/__tests__/migrate.test.js +42 -0
- package/dist/commands/__tests__/start.test.js +120 -0
- package/dist/commands/check.js +73 -0
- package/dist/commands/config.js +76 -0
- package/dist/commands/create.js +131 -0
- package/dist/commands/dev.js +72 -0
- package/dist/commands/docker.js +119 -0
- package/dist/commands/env.js +44 -0
- package/dist/commands/migrate.js +22 -0
- package/dist/commands/start.js +76 -0
- package/dist/core/__tests__/config.test.js +88 -0
- package/dist/core/__tests__/docker.test.js +43 -0
- package/dist/core/__tests__/env.test.js +71 -0
- package/dist/core/__tests__/package-manager.test.js +95 -0
- package/dist/core/__tests__/project.test.js +49 -0
- package/dist/core/config.js +78 -0
- package/dist/core/docker.js +66 -0
- package/dist/core/env.js +50 -0
- package/dist/core/package-manager.js +87 -0
- package/dist/core/prerequisites.js +80 -0
- package/dist/core/project.js +58 -0
- package/dist/index.js +16 -0
- package/dist/services/templates.js +27 -0
- package/dist/ui/banner.js +14 -0
- package/dist/utils/__tests__/services.test.js +18 -0
- package/dist/utils/__tests__/validation.test.js +17 -0
- package/dist/utils/__tests__/version.test.js +27 -0
- package/dist/utils/services.js +11 -0
- package/dist/utils/validation.js +9 -0
- package/dist/utils/version.js +22 -0
- package/eslint.config-staged.cjs +10 -0
- package/eslint.config.cjs +104 -0
- package/jest.config.ts +24 -0
- package/package.json +63 -0
- package/src/cli.ts +37 -0
- package/src/commands/__tests__/check.test.ts +116 -0
- package/src/commands/__tests__/config.test.ts +97 -0
- package/src/commands/__tests__/dev.test.ts +151 -0
- package/src/commands/__tests__/docker.test.ts +168 -0
- package/src/commands/__tests__/env.test.ts +95 -0
- package/src/commands/__tests__/migrate.test.ts +64 -0
- package/src/commands/__tests__/start.test.ts +166 -0
- package/src/commands/check.ts +102 -0
- package/src/commands/config.ts +90 -0
- package/src/commands/create.ts +201 -0
- package/src/commands/dev.ts +122 -0
- package/src/commands/docker.ts +190 -0
- package/src/commands/env.ts +62 -0
- package/src/commands/migrate.ts +27 -0
- package/src/commands/start.ts +126 -0
- package/src/core/__tests__/config.test.ts +114 -0
- package/src/core/__tests__/docker.test.ts +59 -0
- package/src/core/__tests__/env.test.ts +97 -0
- package/src/core/__tests__/package-manager.test.ts +121 -0
- package/src/core/__tests__/project.test.ts +68 -0
- package/src/core/config.ts +127 -0
- package/src/core/docker.ts +91 -0
- package/src/core/env.ts +90 -0
- package/src/core/package-manager.ts +126 -0
- package/src/core/prerequisites.ts +117 -0
- package/src/core/project.ts +97 -0
- package/src/index.ts +21 -0
- package/src/services/templates.ts +33 -0
- package/src/ui/banner.ts +18 -0
- package/src/utils/__tests__/services.test.ts +21 -0
- package/src/utils/__tests__/validation.test.ts +21 -0
- package/src/utils/__tests__/version.test.ts +35 -0
- package/src/utils/services.ts +12 -0
- package/src/utils/validation.ts +11 -0
- package/src/utils/version.ts +28 -0
- package/test/__mocks__/chalk.ts +13 -0
- package/tsconfig.json +15 -0
package/src/ui/banner.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2025 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import figlet from 'figlet';
|
|
9
|
+
|
|
10
|
+
import { getCliVersion } from '../utils/version.js';
|
|
11
|
+
|
|
12
|
+
export const printBanner = () => {
|
|
13
|
+
const bannerText = chalk.blue(figlet.textSync('Hexabot'));
|
|
14
|
+
const versionText = chalk.gray(`CLI v${getCliVersion()}`);
|
|
15
|
+
|
|
16
|
+
console.log(bannerText);
|
|
17
|
+
console.log(versionText);
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2025 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { parseServices } from '../services.js';
|
|
8
|
+
|
|
9
|
+
describe('parseServices', () => {
|
|
10
|
+
it('splits and trims comma separated values', () => {
|
|
11
|
+
expect(parseServices('api, postgres,worker')).toEqual([
|
|
12
|
+
'api',
|
|
13
|
+
'postgres',
|
|
14
|
+
'worker',
|
|
15
|
+
]);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('filters out empty service values', () => {
|
|
19
|
+
expect(parseServices(' , , ')).toEqual([]);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2025 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { validateProjectName } from '../validation.js';
|
|
8
|
+
|
|
9
|
+
describe('validateProjectName', () => {
|
|
10
|
+
it('accepts lowercase alphanumeric names with dashes', () => {
|
|
11
|
+
expect(validateProjectName('hexabot-bot01')).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('rejects names that do not start with a letter', () => {
|
|
15
|
+
expect(validateProjectName('1hexabot')).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('rejects names containing uppercase characters or spaces', () => {
|
|
19
|
+
expect(validateProjectName('Hexabot Agent')).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2025 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
|
|
10
|
+
import { jest } from '@jest/globals';
|
|
11
|
+
|
|
12
|
+
import { getCliVersion } from '../version.js';
|
|
13
|
+
|
|
14
|
+
describe('getCliVersion', () => {
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
jest.restoreAllMocks();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('returns the version from the package.json file', () => {
|
|
20
|
+
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
|
|
21
|
+
const { version } = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
22
|
+
|
|
23
|
+
expect(getCliVersion()).toBe(version);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('falls back to the default version when package.json cannot be read', () => {
|
|
27
|
+
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
28
|
+
const failingReader: typeof fs.readFileSync = () => {
|
|
29
|
+
throw new Error('file error');
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
expect(getCliVersion(failingReader)).toBe('3.0.0');
|
|
33
|
+
expect(errorSpy).toHaveBeenCalled();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2025 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const parseServices = (serviceString: string): string[] => {
|
|
8
|
+
return serviceString
|
|
9
|
+
.split(',')
|
|
10
|
+
.map((service) => service.trim())
|
|
11
|
+
.filter((s) => s);
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2025 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const validateProjectName = (projectName: string) => {
|
|
8
|
+
const regex = /^[a-z][a-z0-9\-]+$/;
|
|
9
|
+
|
|
10
|
+
return regex.test(projectName);
|
|
11
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2025 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
|
|
11
|
+
const INITIAL_CLI_VERSION = '3.0.0';
|
|
12
|
+
|
|
13
|
+
export const getCliVersion = (
|
|
14
|
+
readFile: typeof fs.readFileSync = fs.readFileSync,
|
|
15
|
+
) => {
|
|
16
|
+
try {
|
|
17
|
+
const filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = path.dirname(filename);
|
|
19
|
+
const packageJsonPath = path.join(__dirname, '../../package.json');
|
|
20
|
+
const packageJson = JSON.parse(readFile(packageJsonPath, 'utf-8'));
|
|
21
|
+
|
|
22
|
+
return packageJson.version;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error('Error reading package.json:', error);
|
|
25
|
+
|
|
26
|
+
return INITIAL_CLI_VERSION;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const passthrough = (value: string) => value;
|
|
2
|
+
|
|
3
|
+
const chalkMock = {
|
|
4
|
+
blue: passthrough,
|
|
5
|
+
yellow: passthrough,
|
|
6
|
+
cyan: passthrough,
|
|
7
|
+
red: passthrough,
|
|
8
|
+
green: passthrough,
|
|
9
|
+
bgYellow: passthrough,
|
|
10
|
+
gray: passthrough,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default chalkMock;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ES2020", // Change to ES2020 or ESNext
|
|
5
|
+
"moduleResolution": "node", // Ensure module resolution is node
|
|
6
|
+
"rootDir": "./src",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"],
|
|
14
|
+
"exclude": ["node_modules", "dist"]
|
|
15
|
+
}
|