@codapult/cli 0.5.0 → 0.6.1

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.
@@ -1,6 +1,6 @@
1
- interface SetupOptions {
1
+ import { type ProjectEnvOptions } from '../utils/project-env.js';
2
+ interface SetupOptions extends Pick<ProjectEnvOptions, 'envFile'> {
2
3
  preset?: string;
3
- noEnvFile?: boolean;
4
4
  }
5
5
  export declare function setupCommand(options: SetupOptions): Promise<void>;
6
6
  export {};
@@ -2,7 +2,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'node
2
2
  import { resolve, relative, join } from 'node:path';
3
3
  import { createInterface } from 'node:readline';
4
4
  import { findProjectRoot } from '../utils/project.js';
5
- import { ENV_EXAMPLE_FILE_NAME, ENV_FILE_NAME } from '../utils/project-env.js';
5
+ import { ENV_EXAMPLE_FILE_NAME, ENV_FILE_NAME, } from '../utils/project-env.js';
6
6
  import { heading, success, fail, info, dim } from '../utils/ui.js';
7
7
  const rl = () => createInterface({ input: process.stdin, output: process.stdout });
8
8
  function ask(iface, question, defaultValue) {
@@ -153,11 +153,16 @@ const MODULE_REMOVALS = [
153
153
  `${APP}/admin`,
154
154
  `${APP}/invite`,
155
155
  'src/app/api/auth',
156
- 'src/lib/auth/better-auth.ts',
157
- 'src/lib/auth/kinde.ts',
156
+ // 'src/lib/auth/better-auth.ts',
157
+ // 'src/lib/auth/kinde.ts',
158
158
  'src/components/auth',
159
159
  'src/components/dashboard',
160
160
  'src/components/admin',
161
+ 'src/app/api/admin',
162
+ 'src/lib/actions/admin.ts',
163
+ 'src/lib/actions/admin.test.ts',
164
+ 'src/lib/actions/impersonation.ts',
165
+ 'src/lib/actions/impersonation.test.ts',
161
166
  'src/components/ImpersonationBanner.tsx',
162
167
  ],
163
168
  label: 'Authentication & Dashboard',
@@ -172,7 +177,7 @@ const MODULE_REMOVALS = [
172
177
  paths: [
173
178
  `${APP}/(marketing)/blog`,
174
179
  'src/components/blog',
175
- 'src/lib/blog',
180
+ // 'src/lib/blog',
176
181
  'content/blog',
177
182
  'src/app/rss.xml',
178
183
  ],
@@ -188,6 +193,12 @@ const MODULE_REMOVALS = [
188
193
  'src/components/dashboard/AcceptInvitationButton.tsx',
189
194
  'src/lib/db/organizations.ts',
190
195
  'src/lib/actions/organizations.ts',
196
+ 'src/lib/actions/organizations.test.ts',
197
+ 'src/lib/payments/seats.ts',
198
+ 'src/lib/payments/seats.test.ts',
199
+ 'src/lib/guards.ts',
200
+ 'src/lib/guards.test.ts',
201
+ 'src/app/api/scim',
191
202
  ],
192
203
  label: 'Teams',
193
204
  },
@@ -223,6 +234,7 @@ const MODULE_REMOVALS = [
223
234
  `${APP}/(marketing)/docs/api`,
224
235
  'src/lib/api-docs.ts',
225
236
  'src/lib/openapi.ts',
237
+ 'src/app/api/openapi',
226
238
  'src/components/docs/ApiReference.tsx',
227
239
  ],
228
240
  label: 'API Docs',
@@ -281,12 +293,12 @@ const MODULE_REMOVALS = [
281
293
  paths: ['src/lib/event-store', 'src/app/api/admin/events'],
282
294
  label: 'Event Store',
283
295
  },
284
- { key: 'enableOtel', paths: ['src/lib/telemetry'], label: 'OpenTelemetry' },
296
+ // { key: 'enableOtel', paths: ['src/lib/telemetry'], label: 'OpenTelemetry' },
285
297
  {
286
298
  key: 'enableDripCampaigns',
287
299
  paths: [
288
300
  `${APP}/admin/drip-campaigns`,
289
- 'src/lib/drip-campaigns',
301
+ // 'src/lib/drip-campaigns',
290
302
  'src/app/api/admin/drip-campaigns',
291
303
  'src/components/admin/DripCampaignManager.tsx',
292
304
  ],
@@ -339,7 +351,7 @@ const MODULE_REMOVALS = [
339
351
  'src/lib/ai/chunker.ts',
340
352
  'src/lib/ai/embeddings.ts',
341
353
  'src/lib/ai/vector-store.ts',
342
- 'src/lib/ai/rag.ts',
354
+ // 'src/lib/ai/rag.ts',
343
355
  'src/app/api/ai',
344
356
  ],
345
357
  label: 'RAG Pipeline',
@@ -350,7 +362,7 @@ const MODULE_REMOVALS = [
350
362
  `${APP}/(dashboard)/dashboard/webhooks`,
351
363
  `${APP}/admin/webhooks`,
352
364
  'src/app/api/webhooks',
353
- 'src/lib/outgoing-webhooks',
365
+ // 'src/lib/outgoing-webhooks',
354
366
  'src/lib/webhook-log.ts',
355
367
  'src/lib/webhook-log.test.ts',
356
368
  'src/components/dashboard/OutgoingWebhooks.tsx',
@@ -373,7 +385,7 @@ const MODULE_REMOVALS = [
373
385
  paths: [
374
386
  `${APP}/(dashboard)/dashboard/reports`,
375
387
  'src/app/api/reports',
376
- 'src/lib/scheduled-reports',
388
+ // 'src/lib/scheduled-reports',
377
389
  'src/components/dashboard/ReportSchedules.tsx',
378
390
  ],
379
391
  label: 'Scheduled Reports',
@@ -609,7 +621,7 @@ export async function setupCommand(options) {
609
621
  config = await interactiveSetup();
610
622
  }
611
623
  heading('Generating configuration');
612
- if (options.noEnvFile) {
624
+ if (options.envFile === false) {
613
625
  dim(`Skipped ${ENV_FILE_NAME} generation`);
614
626
  }
615
627
  else {
@@ -624,7 +636,7 @@ export async function setupCommand(options) {
624
636
  info('Preset applied. Proceeding to build.');
625
637
  }
626
638
  else {
627
- if (options.noEnvFile) {
639
+ if (options.envFile === false) {
628
640
  printProcessEnvNextSteps();
629
641
  }
630
642
  else {
@@ -2,7 +2,8 @@ import { existsSync, readdirSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
3
  import { z } from 'zod';
4
4
  import { findProjectRoot, readProjectFile } from '../../utils/project.js';
5
- import { loadProjectEnv } from '../../utils/project-env.js';
5
+ import { getProjectEnvOptions, loadProjectEnv } from '../../utils/project-env.js';
6
+ import { envSourceSchema } from './schemas.js';
6
7
  function getRoot() {
7
8
  const root = findProjectRoot();
8
9
  if (!root)
@@ -102,10 +103,12 @@ export function registerDbTools(server) {
102
103
  server.registerTool('codapult_db_status', {
103
104
  title: 'Database Status',
104
105
  description: 'Get database provider, table count, and migration count',
105
- inputSchema: {},
106
- }, () => {
106
+ inputSchema: {
107
+ env_source: envSourceSchema.optional(),
108
+ },
109
+ }, ({ env_source }) => {
107
110
  const root = getRoot();
108
- const envContent = loadProjectEnv(root).content;
111
+ const envContent = loadProjectEnv(root, getProjectEnvOptions(env_source)).content;
109
112
  const providerMatch = /^DB_PROVIDER\s*=\s*"?(\w+)"?/m.exec(envContent);
110
113
  const provider = providerMatch?.[1] ?? 'turso';
111
114
  const schemaContent = readProjectFile(root, 'src/lib/db/schema.ts') ?? '';
@@ -150,5 +150,20 @@ export const user = sqliteTable('user', {
150
150
  const parsed = JSON.parse(result.content[0].text);
151
151
  expect(parsed.provider).toBe('turso');
152
152
  });
153
+ it('can read provider from process env', () => {
154
+ const server = createMockServer();
155
+ registerDbTools(server);
156
+ vi.stubEnv('DB_PROVIDER', 'postgres');
157
+ mockedReadProject.mockImplementation((_root, path) => {
158
+ if (path === 'src/lib/db/schema.ts')
159
+ return '';
160
+ return null;
161
+ });
162
+ mockedExists.mockReturnValue(false);
163
+ const handler = server.tools.find((t) => t.name === 'codapult_db_status').handler;
164
+ const result = handler({ env_source: 'process' });
165
+ const parsed = JSON.parse(result.content[0].text);
166
+ expect(parsed.provider).toBe('postgres');
167
+ });
153
168
  });
154
169
  });
@@ -2,7 +2,8 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
3
  import { z } from 'zod';
4
4
  import { findProjectRoot, readProjectFile } from '../../utils/project.js';
5
- import { ENV_EXAMPLE_FILE_NAME, ENV_FILE_NAME } from '../../utils/project-env.js';
5
+ import { ENV_EXAMPLE_FILE_NAME, ENV_FILE_NAME, getProjectEnvOptions, loadProjectEnv, } from '../../utils/project-env.js';
6
+ import { envSourceSchema } from './schemas.js';
6
7
  function getRoot() {
7
8
  const root = findProjectRoot();
8
9
  if (!root)
@@ -68,11 +69,13 @@ export function registerEnvTools(server) {
68
69
  .boolean()
69
70
  .default(false)
70
71
  .describe('When true, show full values for sensitive keys (use with caution)'),
72
+ env_source: envSourceSchema.optional(),
71
73
  },
72
- }, ({ show_secrets }) => {
74
+ }, ({ show_secrets, env_source }) => {
73
75
  const root = getRoot();
74
- const localContent = readProjectFile(root, ENV_FILE_NAME);
75
- if (!localContent)
76
+ const env = loadProjectEnv(root, getProjectEnvOptions(env_source));
77
+ const localContent = env.content;
78
+ if (!localContent && env.source === 'file')
76
79
  return {
77
80
  content: [{ type: 'text', text: `${ENV_FILE_NAME} not found` }],
78
81
  isError: true,
@@ -107,8 +110,9 @@ export function registerEnvTools(server) {
107
110
  inputSchema: {
108
111
  key: z.string().describe('Variable name (e.g. "STRIPE_SECRET_KEY")'),
109
112
  value: z.string().describe('Variable value'),
113
+ env_source: envSourceSchema.optional(),
110
114
  },
111
- }, ({ key, value }) => {
115
+ }, ({ key, value, env_source }) => {
112
116
  if (!ENV_KEY_REGEX.test(key)) {
113
117
  return {
114
118
  content: [
@@ -121,6 +125,17 @@ export function registerEnvTools(server) {
121
125
  };
122
126
  }
123
127
  const root = getRoot();
128
+ if (env_source === 'process') {
129
+ return {
130
+ content: [
131
+ {
132
+ type: 'text',
133
+ text: 'Updating process.env via MCP is not supported; use env_source="file"',
134
+ },
135
+ ],
136
+ isError: true,
137
+ };
138
+ }
124
139
  const envPath = resolve(root, ENV_FILE_NAME);
125
140
  if (!existsSync(envPath)) {
126
141
  return {
@@ -75,9 +75,9 @@ DATABASE_URL=sqlite://local.db
75
75
  registerEnvTools(server);
76
76
  const envLocal = `AUTH_PROVIDER=better-auth\nSTRIPE_SECRET_KEY=your-key-here\n`;
77
77
  const envExample = `AUTH_PROVIDER=better-auth\nSTRIPE_SECRET_KEY=\nDATABASE_URL=\n`;
78
+ mockedExists.mockReturnValue(true);
79
+ mockedRead.mockReturnValue(envLocal);
78
80
  mockedReadProject.mockImplementation((_root, path) => {
79
- if (path === ENV_FILE_NAME)
80
- return envLocal;
81
81
  if (path === ENV_EXAMPLE_FILE_NAME)
82
82
  return envExample;
83
83
  return null;
@@ -88,6 +88,21 @@ DATABASE_URL=sqlite://local.db
88
88
  expect(parsed.missing).toContain('DATABASE_URL');
89
89
  expect(parsed.unconfigured).toContain('STRIPE_SECRET_KEY');
90
90
  });
91
+ it('can read from process env', () => {
92
+ const server = createMockServer();
93
+ registerEnvTools(server);
94
+ vi.stubEnv('AUTH_PROVIDER', 'better-auth');
95
+ vi.stubEnv('STRIPE_SECRET_KEY', 'sk_live_123');
96
+ mockedReadProject.mockImplementation((_root, path) => {
97
+ if (path === ENV_EXAMPLE_FILE_NAME)
98
+ return `AUTH_PROVIDER=better-auth\nSTRIPE_SECRET_KEY=\nDATABASE_URL=\n`;
99
+ return null;
100
+ });
101
+ const handler = server.tools.find((t) => t.name === 'codapult_env_read').handler;
102
+ const result = handler({ env_source: 'process' });
103
+ const parsed = JSON.parse(result.content[0].text);
104
+ expect(parsed.variables.some((v) => v.key === 'AUTH_PROVIDER')).toBe(true);
105
+ });
91
106
  it(`returns error when ${ENV_FILE_NAME} not found`, () => {
92
107
  const server = createMockServer();
93
108
  registerEnvTools(server);
@@ -128,5 +143,12 @@ DATABASE_URL=sqlite://local.db
128
143
  const result = handler({ key: 'X', value: 'Y' });
129
144
  expect(result.isError).toBe(true);
130
145
  });
146
+ it('returns error for process env updates', () => {
147
+ const server = createMockServer();
148
+ registerEnvTools(server);
149
+ const handler = server.tools.find((t) => t.name === 'codapult_env_update').handler;
150
+ const result = handler({ key: 'X', value: 'Y', env_source: 'process' });
151
+ expect(result.isError).toBe(true);
152
+ });
131
153
  });
132
154
  });
@@ -2,9 +2,10 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
3
  import { z } from 'zod';
4
4
  import { findProjectRoot } from '../../utils/project.js';
5
- import { ENV_FILE_NAME, getProjectEnvSource } from '../../utils/project-env.js';
5
+ import { ENV_FILE_NAME } from '../../utils/project-env.js';
6
6
  import { resolveManifest } from '../../utils/manifest.js';
7
7
  import { patchSchemaImports, patchSchemaTables, patchDbReExports, patchNextConfig, createPluginRegistration, patchPages, findPageConflicts, patchEnvFile, patchPackageJson, } from '../../utils/patchers.js';
8
+ import { envSourceSchema } from './schemas.js';
8
9
  function getRoot() {
9
10
  const root = findProjectRoot();
10
11
  if (!root)
@@ -43,8 +44,9 @@ export function registerPluginTools(server) {
43
44
  description: 'Install a Codapult plugin by name. Patches schema, config, pages, and env automatically.',
44
45
  inputSchema: {
45
46
  name: z.string().describe('Plugin name (e.g. "ai-kit", "video-player")'),
47
+ env_source: envSourceSchema.optional(),
46
48
  },
47
- }, ({ name }) => {
49
+ }, ({ name, env_source }) => {
48
50
  const root = getRoot();
49
51
  const result = resolveManifest(root, name);
50
52
  if (!result) {
@@ -89,7 +91,7 @@ export function registerPluginTools(server) {
89
91
  createPluginRegistration(root, manifest.name, manifest.package, 'add');
90
92
  steps.push('Plugin registered');
91
93
  if (manifest.install.env && Object.keys(manifest.install.env).length > 0) {
92
- if (getProjectEnvSource() === 'process') {
94
+ if (env_source === 'process') {
93
95
  steps.push('Project uses process.env; add plugin env vars outside the CLI');
94
96
  }
95
97
  else {
@@ -115,8 +117,9 @@ export function registerPluginTools(server) {
115
117
  description: 'Uninstall a Codapult plugin by name. Reverts all patches.',
116
118
  inputSchema: {
117
119
  name: z.string().describe('Plugin name to remove'),
120
+ env_source: envSourceSchema.optional(),
118
121
  },
119
- }, ({ name }) => {
122
+ }, ({ name, env_source }) => {
120
123
  const root = getRoot();
121
124
  const result = resolveManifest(root, name);
122
125
  const manifest = result?.manifest ?? {
@@ -152,7 +155,7 @@ export function registerPluginTools(server) {
152
155
  steps.push('next.config.ts reverted');
153
156
  }
154
157
  if (manifest.install.env && Object.keys(manifest.install.env).length > 0) {
155
- if (getProjectEnvSource() === 'process') {
158
+ if (env_source === 'process') {
156
159
  steps.push(`Project uses process.env; no ${ENV_FILE_NAME} env vars were removed`);
157
160
  }
158
161
  else {
@@ -3,8 +3,9 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs';
3
3
  import { resolve } from 'node:path';
4
4
  import { z } from 'zod';
5
5
  import { findProjectRoot, readProjectFile } from '../../utils/project.js';
6
- import { ENV_FILE_NAME, getProjectEnvSource, loadProjectEnv } from '../../utils/project-env.js';
6
+ import { ENV_FILE_NAME, getProjectEnvOptions, loadProjectEnv } from '../../utils/project-env.js';
7
7
  import { getAdapters, getAuthMethods, getFeatures, getOauthProviders, } from '../../utils/env-config.js';
8
+ import { envSourceSchema } from './schemas.js';
8
9
  function getRoot() {
9
10
  const root = findProjectRoot();
10
11
  if (!root)
@@ -15,11 +16,13 @@ export function registerProjectTools(server) {
15
16
  server.registerTool('codapult_project_status', {
16
17
  title: 'Project Status',
17
18
  description: 'Get Codapult project status: variant, adapters, installed plugins, enabled features, git status',
18
- inputSchema: {},
19
- }, () => {
19
+ inputSchema: {
20
+ env_source: envSourceSchema.optional(),
21
+ },
22
+ }, ({ env_source }) => {
20
23
  const root = getRoot();
21
24
  const pkg = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf-8'));
22
- const envContent = loadProjectEnv(root).content;
25
+ const envContent = loadProjectEnv(root, getProjectEnvOptions(env_source)).content;
23
26
  const pluginsDir = resolve(root, 'src/plugins');
24
27
  const plugins = existsSync(pluginsDir)
25
28
  ? readdirSync(pluginsDir)
@@ -59,7 +62,6 @@ export function registerProjectTools(server) {
59
62
  server.registerTool('codapult_project_config', {
60
63
  title: 'Project Config',
61
64
  description: 'Read the app configuration from src/config/app.ts (brand, auth, features)',
62
- inputSchema: {},
63
65
  }, () => {
64
66
  const root = getRoot();
65
67
  const content = readProjectFile(root, 'src/config/app.ts') ?? 'Config file not found';
@@ -103,8 +105,10 @@ export function registerProjectTools(server) {
103
105
  server.registerTool('codapult_doctor', {
104
106
  title: 'Doctor',
105
107
  description: 'Run project health checks: file structure, env vars, dependencies, TypeScript, git',
106
- inputSchema: {},
107
- }, () => {
108
+ inputSchema: {
109
+ env_source: envSourceSchema.optional(),
110
+ },
111
+ }, ({ env_source }) => {
108
112
  const root = getRoot();
109
113
  const checks = [];
110
114
  const requiredFiles = [
@@ -122,8 +126,7 @@ export function registerProjectTools(server) {
122
126
  detail: existsSync(resolve(root, f)) ? 'exists' : 'missing',
123
127
  });
124
128
  }
125
- const envSource = getProjectEnvSource();
126
- if (envSource === 'process') {
129
+ if (env_source === 'process') {
127
130
  checks.push({
128
131
  name: 'Environment source',
129
132
  status: 'ok',
@@ -8,7 +8,8 @@ vi.mock('../../utils/project.js', () => ({
8
8
  }));
9
9
  vi.mock('../../utils/project-env.js', () => ({
10
10
  ENV_FILE_NAME: '.env.local',
11
- getProjectEnvSource: vi.fn(() => 'file'),
11
+ getProjectEnvOptions: vi.fn((envSource) => ({ envFile: envSource !== 'process' })),
12
+ getProjectEnvSource: vi.fn((options) => options?.envFile === false ? 'process' : 'file'),
12
13
  loadProjectEnv: vi.fn(),
13
14
  }));
14
15
  const { existsSync, readFileSync, readdirSync } = await import('node:fs');
@@ -96,6 +97,24 @@ describe('registerProjectTools', () => {
96
97
  expect(parsed.git.branch).toBe('main');
97
98
  expect(parsed.git.dirty).toBe(false);
98
99
  });
100
+ it('uses process env when requested', () => {
101
+ const server = createMockServer();
102
+ registerProjectTools(server);
103
+ mockedRead.mockReturnValue(JSON.stringify({ name: 'codapult', version: '1.0.0' }));
104
+ mockedLoadProjectEnv.mockReturnValue({
105
+ source: 'process',
106
+ filePath: `/project/${ENV_FILE_NAME}`,
107
+ fileExists: false,
108
+ content: 'AUTH_PROVIDER=none\nENABLE_BLOG=false',
109
+ });
110
+ mockedExists.mockReturnValue(true);
111
+ mockedReaddir.mockReturnValue([]);
112
+ const handler = server.tools.find((t) => t.name === 'codapult_project_status').handler;
113
+ const result = handler({ env_source: 'process' });
114
+ const parsed = JSON.parse(result.content[0].text);
115
+ expect(parsed.adapters.auth).toBe('none');
116
+ expect(mockedLoadProjectEnv).toHaveBeenCalledWith('/project', { envFile: false });
117
+ });
99
118
  });
100
119
  describe('codapult_project_config', () => {
101
120
  it('returns app.ts content', () => {
@@ -142,5 +161,16 @@ describe('registerProjectTools', () => {
142
161
  const failedChecks = parsed.filter((c) => c.status === 'fail');
143
162
  expect(failedChecks.length).toBeGreaterThan(0);
144
163
  });
164
+ it('reports process env source when requested', () => {
165
+ const server = createMockServer();
166
+ registerProjectTools(server);
167
+ mockedExists.mockReturnValue(true);
168
+ mockedExec.mockReturnValue(Buffer.from(''));
169
+ const handler = server.tools.find((t) => t.name === 'codapult_doctor').handler;
170
+ const result = handler({ env_source: 'process' });
171
+ const parsed = JSON.parse(result.content[0].text);
172
+ const envCheck = parsed.find((c) => c.name === 'Environment source');
173
+ expect(envCheck?.detail).toBe('process.env');
174
+ });
145
175
  });
146
176
  });
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export declare const envSourceSchema: z.ZodDefault<z.ZodEnum<{
3
+ file: "file";
4
+ process: "process";
5
+ }>>;
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export const envSourceSchema = z
3
+ .enum(['file', 'process'])
4
+ .default('file')
5
+ .describe('Where to read environment variables from');
@@ -1,6 +1,6 @@
1
1
  export type ProjectEnvSource = 'file' | 'process';
2
2
  export interface ProjectEnvOptions {
3
- noEnvFile?: boolean;
3
+ envFile?: boolean;
4
4
  }
5
5
  export interface LoadedProjectEnv {
6
6
  source: ProjectEnvSource;
@@ -12,4 +12,5 @@ export declare const ENV_EXAMPLE_FILE_NAME = ".env.example";
12
12
  export declare const ENV_FILE_NAME = ".env.local";
13
13
  export declare function getProjectEnvFilePath(projectRoot: string): string;
14
14
  export declare function getProjectEnvSource(options?: ProjectEnvOptions): ProjectEnvSource;
15
+ export declare function getProjectEnvOptions(envSource?: ProjectEnvSource): ProjectEnvOptions;
15
16
  export declare function loadProjectEnv(projectRoot: string, options?: ProjectEnvOptions): LoadedProjectEnv;
@@ -6,7 +6,10 @@ export function getProjectEnvFilePath(projectRoot) {
6
6
  return resolve(projectRoot, ENV_FILE_NAME);
7
7
  }
8
8
  export function getProjectEnvSource(options) {
9
- return options?.noEnvFile ? 'process' : 'file';
9
+ return options?.envFile === false ? 'process' : 'file';
10
+ }
11
+ export function getProjectEnvOptions(envSource) {
12
+ return envSource === 'process' ? { envFile: false } : { envFile: true };
10
13
  }
11
14
  function serializeProcessEnv(env) {
12
15
  return Object.entries(env)
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { ENV_FILE_NAME, getProjectEnvFilePath, getProjectEnvSource, loadProjectEnv, } from './project-env.js';
2
+ import { ENV_FILE_NAME, getProjectEnvFilePath, getProjectEnvOptions, getProjectEnvSource, loadProjectEnv, } from './project-env.js';
3
3
  vi.mock('node:fs');
4
4
  const { existsSync, readFileSync } = await import('node:fs');
5
5
  const mockedExists = vi.mocked(existsSync);
@@ -12,8 +12,13 @@ describe('project-env', () => {
12
12
  it('defaults to file env source', () => {
13
13
  expect(getProjectEnvSource()).toBe('file');
14
14
  });
15
- it('uses process env source when noEnvFile is enabled', () => {
16
- expect(getProjectEnvSource({ noEnvFile: true })).toBe('process');
15
+ it('uses process env source when envFile is disabled', () => {
16
+ expect(getProjectEnvSource({ envFile: false })).toBe('process');
17
+ });
18
+ it('maps env source to options', () => {
19
+ expect(getProjectEnvOptions('process')).toEqual({ envFile: false });
20
+ expect(getProjectEnvOptions('file')).toEqual({ envFile: true });
21
+ expect(getProjectEnvOptions()).toEqual({ envFile: true });
17
22
  });
18
23
  it(`loads env content from ${ENV_FILE_NAME} in file mode`, () => {
19
24
  mockedExists.mockImplementation((path) => path === `/project/${ENV_FILE_NAME}`);
@@ -29,7 +34,7 @@ describe('project-env', () => {
29
34
  mockedExists.mockReturnValue(false);
30
35
  vi.stubEnv('AUTH_PROVIDER', 'better-auth');
31
36
  vi.stubEnv('DB_PROVIDER', 'postgres');
32
- const env = loadProjectEnv('/project', { noEnvFile: true });
37
+ const env = loadProjectEnv('/project', { envFile: false });
33
38
  expect(env.source).toBe('process');
34
39
  expect(env.filePath).toBe(`/project/${ENV_FILE_NAME}`);
35
40
  expect(env.fileExists).toBe(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codapult/cli",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Codapult CLI — manage, update, and diagnose your Codapult SaaS project",
5
5
  "license": "MIT",
6
6
  "type": "module",