@output.ai/cli 0.7.1 → 0.7.2
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/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.2",
|
|
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"
|