@codapult/cli 0.4.2 → 0.5.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.
- package/dist/commands/config-show.d.ts +2 -1
- package/dist/commands/config-show.js +12 -8
- package/dist/commands/db.d.ts +6 -5
- package/dist/commands/db.js +15 -17
- package/dist/commands/deploy.d.ts +5 -4
- package/dist/commands/deploy.js +28 -10
- package/dist/commands/doctor.d.ts +2 -1
- package/dist/commands/doctor.js +13 -7
- package/dist/commands/env.d.ts +3 -2
- package/dist/commands/env.js +27 -18
- package/dist/commands/plugins.d.ts +4 -3
- package/dist/commands/plugins.js +18 -6
- package/dist/commands/setup.d.ts +1 -0
- package/dist/commands/setup.js +28 -9
- package/dist/index.js +21 -27
- package/dist/mcp/resources.js +4 -3
- package/dist/mcp/tools/db.js +2 -1
- package/dist/mcp/tools/db.test.js +3 -2
- package/dist/mcp/tools/deploy.js +2 -1
- package/dist/mcp/tools/env.js +12 -11
- package/dist/mcp/tools/env.test.js +8 -7
- package/dist/mcp/tools/plugins.js +15 -4
- package/dist/mcp/tools/project.js +17 -2
- package/dist/mcp/tools/project.test.js +26 -11
- package/dist/utils/env-config.d.ts +4 -4
- package/dist/utils/env-config.js +4 -4
- package/dist/utils/patchers.js +3 -2
- package/dist/utils/patchers.test.js +2 -1
- package/dist/utils/project-env.d.ts +15 -0
- package/dist/utils/project-env.js +35 -0
- package/dist/utils/project-env.test.d.ts +1 -0
- package/dist/utils/project-env.test.js +42 -0
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { ENV_FILE_NAME, getProjectEnvFilePath, getProjectEnvSource, loadProjectEnv, } from './project-env.js';
|
|
3
|
+
vi.mock('node:fs');
|
|
4
|
+
const { existsSync, readFileSync } = await import('node:fs');
|
|
5
|
+
const mockedExists = vi.mocked(existsSync);
|
|
6
|
+
const mockedRead = vi.mocked(readFileSync);
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
vi.resetAllMocks();
|
|
9
|
+
vi.unstubAllEnvs();
|
|
10
|
+
});
|
|
11
|
+
describe('project-env', () => {
|
|
12
|
+
it('defaults to file env source', () => {
|
|
13
|
+
expect(getProjectEnvSource()).toBe('file');
|
|
14
|
+
});
|
|
15
|
+
it('uses process env source when noEnvFile is enabled', () => {
|
|
16
|
+
expect(getProjectEnvSource({ noEnvFile: true })).toBe('process');
|
|
17
|
+
});
|
|
18
|
+
it(`loads env content from ${ENV_FILE_NAME} in file mode`, () => {
|
|
19
|
+
mockedExists.mockImplementation((path) => path === `/project/${ENV_FILE_NAME}`);
|
|
20
|
+
mockedRead.mockReturnValue('AUTH_PROVIDER=better-auth\nDB_PROVIDER=postgres');
|
|
21
|
+
expect(loadProjectEnv('/project')).toEqual({
|
|
22
|
+
source: 'file',
|
|
23
|
+
content: 'AUTH_PROVIDER=better-auth\nDB_PROVIDER=postgres',
|
|
24
|
+
filePath: `/project/${ENV_FILE_NAME}`,
|
|
25
|
+
fileExists: true,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
it('loads env content from process.env in process mode', () => {
|
|
29
|
+
mockedExists.mockReturnValue(false);
|
|
30
|
+
vi.stubEnv('AUTH_PROVIDER', 'better-auth');
|
|
31
|
+
vi.stubEnv('DB_PROVIDER', 'postgres');
|
|
32
|
+
const env = loadProjectEnv('/project', { noEnvFile: true });
|
|
33
|
+
expect(env.source).toBe('process');
|
|
34
|
+
expect(env.filePath).toBe(`/project/${ENV_FILE_NAME}`);
|
|
35
|
+
expect(env.fileExists).toBe(false);
|
|
36
|
+
expect(env.content).toContain('AUTH_PROVIDER=better-auth');
|
|
37
|
+
expect(env.content).toContain('DB_PROVIDER=postgres');
|
|
38
|
+
});
|
|
39
|
+
it(`returns ${ENV_FILE_NAME} path helper`, () => {
|
|
40
|
+
expect(getProjectEnvFilePath('/project')).toBe(`/project/${ENV_FILE_NAME}`);
|
|
41
|
+
});
|
|
42
|
+
});
|