@output.ai/cli 0.7.1 → 0.7.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.
|
@@ -61,11 +61,8 @@ const promptForProjectName = async (defaultProjectName) => {
|
|
|
61
61
|
default: defaultProjectName
|
|
62
62
|
}) || defaultProjectName;
|
|
63
63
|
};
|
|
64
|
-
const
|
|
65
|
-
return
|
|
66
|
-
message: 'What is your project description? (optional)',
|
|
67
|
-
default: `An Output SDK workflow for ${kebabCase(projectName)}`
|
|
68
|
-
}) || `An Output SDK workflow for ${kebabCase(projectName)}`;
|
|
64
|
+
const generateProjectDescription = (projectName) => {
|
|
65
|
+
return `An Output SDK workflow for ${kebabCase(projectName)}`;
|
|
69
66
|
};
|
|
70
67
|
/**
|
|
71
68
|
* Get project configuration from user input
|
|
@@ -80,7 +77,7 @@ export const getProjectConfig = async (userFolderNameArg) => {
|
|
|
80
77
|
const folderName = userFolderNameArg ?
|
|
81
78
|
userFolderNameArg :
|
|
82
79
|
await promptForFolderName(projectName);
|
|
83
|
-
const description =
|
|
80
|
+
const description = generateProjectDescription(projectName);
|
|
84
81
|
return {
|
|
85
82
|
projectName,
|
|
86
83
|
folderName,
|
|
@@ -39,35 +39,27 @@ describe('project_scaffold', () => {
|
|
|
39
39
|
vi.clearAllMocks();
|
|
40
40
|
});
|
|
41
41
|
describe('getProjectConfig', () => {
|
|
42
|
-
it('should skip
|
|
42
|
+
it('should skip all prompts when folderName is provided', async () => {
|
|
43
43
|
const { input } = await import('@inquirer/prompts');
|
|
44
|
-
vi.mocked(input).mockResolvedValueOnce('Test description');
|
|
45
44
|
const config = await getProjectConfig('my-project');
|
|
46
45
|
expect(config.folderName).toBe('my-project');
|
|
47
46
|
expect(config.projectName).toBe('my-project');
|
|
48
|
-
|
|
49
|
-
expect(input).toHaveBeenCalledTimes(1);
|
|
47
|
+
expect(input).not.toHaveBeenCalled();
|
|
50
48
|
});
|
|
51
|
-
it('should
|
|
52
|
-
const { input } = await import('@inquirer/prompts');
|
|
53
|
-
vi.mocked(input).mockResolvedValueOnce('My custom description');
|
|
49
|
+
it('should auto-generate description when folderName provided', async () => {
|
|
54
50
|
const config = await getProjectConfig('test-folder');
|
|
55
|
-
expect(config.description).toBe('
|
|
56
|
-
expect(input).toHaveBeenCalledWith(expect.objectContaining({
|
|
57
|
-
message: expect.stringContaining('description')
|
|
58
|
-
}));
|
|
51
|
+
expect(config.description).toBe('An Output SDK workflow for test-folder');
|
|
59
52
|
});
|
|
60
|
-
it('should prompt for
|
|
53
|
+
it('should prompt for project name and folder name when not provided', async () => {
|
|
61
54
|
const { input } = await import('@inquirer/prompts');
|
|
62
55
|
vi.mocked(input)
|
|
63
56
|
.mockResolvedValueOnce('Test Project')
|
|
64
|
-
.mockResolvedValueOnce('test-project')
|
|
65
|
-
.mockResolvedValueOnce('A test project');
|
|
57
|
+
.mockResolvedValueOnce('test-project');
|
|
66
58
|
const config = await getProjectConfig();
|
|
67
59
|
expect(config.projectName).toBe('Test Project');
|
|
68
60
|
expect(config.folderName).toBe('test-project');
|
|
69
|
-
expect(config.description).toBe('
|
|
70
|
-
expect(input).toHaveBeenCalledTimes(
|
|
61
|
+
expect(config.description).toBe('An Output SDK workflow for test-project');
|
|
62
|
+
expect(input).toHaveBeenCalledTimes(2);
|
|
71
63
|
});
|
|
72
64
|
});
|
|
73
65
|
describe('checkDependencies', () => {
|
package/dist/utils/env_loader.js
CHANGED
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
7
|
import { resolve } from 'node:path';
|
|
8
8
|
import * as dotenv from 'dotenv';
|
|
9
|
+
import debugFactory from 'debug';
|
|
10
|
+
const debug = debugFactory('output-cli:env-loader');
|
|
9
11
|
export function loadEnvironment() {
|
|
10
12
|
const cwd = process.cwd();
|
|
11
13
|
const envFile = process.env.OUTPUT_CLI_ENV || '.env';
|
|
12
14
|
const envPath = resolve(cwd, envFile);
|
|
13
15
|
if (!existsSync(envPath)) {
|
|
14
|
-
|
|
16
|
+
debug(`Warning: Env file not found: ${envPath}`);
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
debug(`Loading env from: ${envPath}`);
|
|
18
20
|
dotenv.config({ path: envPath });
|
|
19
21
|
}
|
|
@@ -28,18 +28,8 @@ describe('loadEnvironment', () => {
|
|
|
28
28
|
vi.mocked(dotenv.config).mockReturnValue({ parsed: { API_URL: 'https://prod.api.com' } });
|
|
29
29
|
const { loadEnvironment } = await import('./env_loader.js');
|
|
30
30
|
loadEnvironment();
|
|
31
|
-
expect(console.log).toHaveBeenCalledWith(`Loading env from: ${expectedPath}`);
|
|
32
31
|
expect(dotenv.config).toHaveBeenCalledWith({ path: expectedPath });
|
|
33
32
|
});
|
|
34
|
-
it('should warn when OUTPUT_CLI_ENV file does not exist', async () => {
|
|
35
|
-
process.env.OUTPUT_CLI_ENV = '.env.missing';
|
|
36
|
-
const expectedPath = resolve(mockCwd, '.env.missing');
|
|
37
|
-
vi.mocked(existsSync).mockReturnValue(false);
|
|
38
|
-
const { loadEnvironment } = await import('./env_loader.js');
|
|
39
|
-
loadEnvironment();
|
|
40
|
-
expect(console.warn).toHaveBeenCalledWith(`Warning: Env file not found: ${expectedPath}`);
|
|
41
|
-
expect(dotenv.config).not.toHaveBeenCalled();
|
|
42
|
-
});
|
|
43
33
|
it('should load .env by default and log', async () => {
|
|
44
34
|
delete process.env.OUTPUT_CLI_ENV;
|
|
45
35
|
const envPath = resolve(mockCwd, '.env');
|
|
@@ -47,17 +37,7 @@ describe('loadEnvironment', () => {
|
|
|
47
37
|
vi.mocked(dotenv.config).mockReturnValue({ parsed: {} });
|
|
48
38
|
const { loadEnvironment } = await import('./env_loader.js');
|
|
49
39
|
loadEnvironment();
|
|
50
|
-
expect(console.log).toHaveBeenCalledWith(`Loading env from: ${envPath}`);
|
|
51
40
|
expect(dotenv.config).toHaveBeenCalledTimes(1);
|
|
52
41
|
expect(dotenv.config).toHaveBeenCalledWith({ path: envPath });
|
|
53
42
|
});
|
|
54
|
-
it('should warn when default .env does not exist', async () => {
|
|
55
|
-
delete process.env.OUTPUT_CLI_ENV;
|
|
56
|
-
const envPath = resolve(mockCwd, '.env');
|
|
57
|
-
vi.mocked(existsSync).mockReturnValue(false);
|
|
58
|
-
const { loadEnvironment } = await import('./env_loader.js');
|
|
59
|
-
loadEnvironment();
|
|
60
|
-
expect(console.warn).toHaveBeenCalledWith(`Warning: Env file not found: ${envPath}`);
|
|
61
|
-
expect(dotenv.config).not.toHaveBeenCalled();
|
|
62
|
-
});
|
|
63
43
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@output.ai/cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "CLI for Output.ai workflow generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"cli-progress": "3.12.0",
|
|
33
33
|
"cli-table3": "0.6.5",
|
|
34
34
|
"date-fns": "4.1.0",
|
|
35
|
+
"debug": "4.4.3",
|
|
35
36
|
"dotenv": "16.4.7",
|
|
36
37
|
"handlebars": "4.7.8",
|
|
37
38
|
"json-schema-library": "10.3.0",
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@types/cli-progress": "3.11.6",
|
|
45
|
+
"@types/debug": "4.1.12",
|
|
44
46
|
"@types/handlebars": "4.1.0",
|
|
45
47
|
"copyfiles": "2.4.1",
|
|
46
48
|
"orval": "7.13.2"
|