@codapult/cli 0.19.1 → 0.20.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/deploy.js +8 -5
- package/dist/commands/plugins.js +16 -13
- package/dist/commands/update.js +31 -14
- package/dist/utils/env-config.d.ts +2 -1
- package/dist/utils/env-config.js +1 -0
- package/dist/utils/manifest.js +51 -5
- package/package.json +13 -13
package/dist/commands/deploy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import { checkProjectRoot } from '../utils/project.js';
|
|
@@ -50,7 +50,7 @@ export async function deployVercelCommand(options = {}) {
|
|
|
50
50
|
// 4. Build check
|
|
51
51
|
info('Running build check...');
|
|
52
52
|
try {
|
|
53
|
-
|
|
53
|
+
execFileSync('pnpm', ['build'], { cwd: root, stdio: 'pipe' });
|
|
54
54
|
success('Build passed');
|
|
55
55
|
}
|
|
56
56
|
catch {
|
|
@@ -66,7 +66,7 @@ export async function deployVercelCommand(options = {}) {
|
|
|
66
66
|
}
|
|
67
67
|
info('Deploying...');
|
|
68
68
|
try {
|
|
69
|
-
|
|
69
|
+
execFileSync('vercel', ['--prod'], { cwd: root, stdio: 'inherit' });
|
|
70
70
|
success('Deployed to Vercel');
|
|
71
71
|
}
|
|
72
72
|
catch {
|
|
@@ -113,7 +113,10 @@ export async function deployDockerCommand(opts = {}) {
|
|
|
113
113
|
// 5. Build
|
|
114
114
|
info('Building Docker image...');
|
|
115
115
|
try {
|
|
116
|
-
|
|
116
|
+
execFileSync('docker', ['build', '-t', imageName, '.'], {
|
|
117
|
+
cwd: root,
|
|
118
|
+
stdio: 'inherit',
|
|
119
|
+
});
|
|
117
120
|
success(`Image built: ${imageName}`);
|
|
118
121
|
}
|
|
119
122
|
catch {
|
|
@@ -134,7 +137,7 @@ export async function deployDockerCommand(opts = {}) {
|
|
|
134
137
|
info('Starting container...');
|
|
135
138
|
dim(`docker run -p 3000:3000 --env-file ${ENV_FILE_NAME} ${imageName}`);
|
|
136
139
|
try {
|
|
137
|
-
|
|
140
|
+
execFileSync('docker', ['run', '-p', '3000:3000', '--env-file', ENV_FILE_NAME, imageName], {
|
|
138
141
|
cwd: root,
|
|
139
142
|
stdio: 'inherit',
|
|
140
143
|
});
|
package/dist/commands/plugins.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
2
2
|
import { existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import { checkProjectRoot } from '../utils/project.js';
|
|
@@ -7,10 +7,9 @@ import { resolveManifest } from '../utils/manifest.js';
|
|
|
7
7
|
import { clonePlugin } from '../utils/git.js';
|
|
8
8
|
import { patchSchemaImports, patchSchemaImportsPg, patchSchemaTables, patchSchemaTablesPg, patchDbReExports, patchNextConfig, createPluginRegistration, patchPages, findPageConflicts, patchEnvFile, patchPackageJson, } from '../utils/patchers.js';
|
|
9
9
|
import { heading, success, fail, warn, info, dim, confirm } from '../utils/ui.js';
|
|
10
|
-
function execQuiet(
|
|
10
|
+
function execQuiet(args, cwd) {
|
|
11
11
|
try {
|
|
12
|
-
|
|
13
|
-
return true;
|
|
12
|
+
return spawnSync('pnpm', args, { cwd, stdio: 'pipe' }).status === 0;
|
|
14
13
|
}
|
|
15
14
|
catch {
|
|
16
15
|
return false;
|
|
@@ -165,7 +164,7 @@ export async function pluginsAddCommand(name, options = {}) {
|
|
|
165
164
|
}
|
|
166
165
|
// 10. pnpm install
|
|
167
166
|
info('Installing dependencies...');
|
|
168
|
-
if (!execQuiet('
|
|
167
|
+
if (!execQuiet(['install', '--no-frozen-lockfile'], root)) {
|
|
169
168
|
warn('pnpm install failed — run manually: pnpm install --no-frozen-lockfile');
|
|
170
169
|
}
|
|
171
170
|
else {
|
|
@@ -181,7 +180,7 @@ export async function pluginsAddCommand(name, options = {}) {
|
|
|
181
180
|
// 11. pnpm db:push
|
|
182
181
|
if (manifest.install.schemaTables) {
|
|
183
182
|
info('Applying database schema...');
|
|
184
|
-
if (!execQuiet('
|
|
183
|
+
if (!execQuiet(['db:push'], root)) {
|
|
185
184
|
warn('db:push failed — run manually: pnpm db:push');
|
|
186
185
|
}
|
|
187
186
|
else {
|
|
@@ -197,9 +196,13 @@ export async function pluginsAddCommand(name, options = {}) {
|
|
|
197
196
|
}
|
|
198
197
|
const installOptional = await confirm('Install optional dependencies?', false);
|
|
199
198
|
if (installOptional) {
|
|
200
|
-
const pkgs = Object.keys(manifest.install.optionalDeps)
|
|
201
|
-
execQuiet(
|
|
202
|
-
|
|
199
|
+
const pkgs = Object.keys(manifest.install.optionalDeps);
|
|
200
|
+
if (execQuiet(['add', ...pkgs], root)) {
|
|
201
|
+
success('Optional dependencies installed');
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
warn('Optional dependency installation failed');
|
|
205
|
+
}
|
|
203
206
|
}
|
|
204
207
|
}
|
|
205
208
|
heading('Done!');
|
|
@@ -297,7 +300,7 @@ export async function pluginsRemoveCommand(name, options = {}) {
|
|
|
297
300
|
success('Dependency removed');
|
|
298
301
|
// 10. pnpm install
|
|
299
302
|
info('Updating dependencies...');
|
|
300
|
-
execQuiet('
|
|
303
|
+
execQuiet(['install', '--no-frozen-lockfile'], root);
|
|
301
304
|
success('Dependencies updated');
|
|
302
305
|
heading('Done!');
|
|
303
306
|
success(`Plugin "${name}" removed.`);
|
|
@@ -371,7 +374,7 @@ export async function pluginsMigrateCommand(name, options) {
|
|
|
371
374
|
console.log();
|
|
372
375
|
if (options.push) {
|
|
373
376
|
info('Applying schema changes (db:push)...');
|
|
374
|
-
if (!execQuiet('
|
|
377
|
+
if (!execQuiet(['db:push'], root)) {
|
|
375
378
|
fail('db:push failed — run manually: pnpm db:push');
|
|
376
379
|
process.exit(1);
|
|
377
380
|
}
|
|
@@ -380,7 +383,7 @@ export async function pluginsMigrateCommand(name, options) {
|
|
|
380
383
|
else {
|
|
381
384
|
info('Generating migration...');
|
|
382
385
|
try {
|
|
383
|
-
|
|
386
|
+
execFileSync('pnpm', ['db:generate'], { cwd: root, stdio: 'inherit' });
|
|
384
387
|
success('Migration generated');
|
|
385
388
|
}
|
|
386
389
|
catch {
|
|
@@ -391,7 +394,7 @@ export async function pluginsMigrateCommand(name, options) {
|
|
|
391
394
|
const apply = await confirm('Apply the migration now (pnpm db:migrate)?');
|
|
392
395
|
if (apply) {
|
|
393
396
|
try {
|
|
394
|
-
|
|
397
|
+
execFileSync('pnpm', ['db:migrate'], { cwd: root, stdio: 'inherit' });
|
|
395
398
|
success('Migration applied');
|
|
396
399
|
}
|
|
397
400
|
catch {
|
package/dist/commands/update.js
CHANGED
|
@@ -1,45 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { checkProjectRoot } from '../utils/project.js';
|
|
3
3
|
import { heading, success, fail, warn, info, dim, confirm, label } from '../utils/ui.js';
|
|
4
4
|
const UPSTREAM_REMOTE = 'codapult-upstream';
|
|
5
5
|
const UPSTREAM_URL = 'https://github.com/codapult/codapult.git';
|
|
6
|
-
function
|
|
6
|
+
function runGit(args, cwd, silent = false) {
|
|
7
7
|
const stdio = silent ? 'pipe' : 'inherit';
|
|
8
|
-
const result =
|
|
8
|
+
const result = execFileSync('git', args, { cwd, encoding: 'utf-8', stdio });
|
|
9
9
|
return typeof result === 'string' ? result : '';
|
|
10
10
|
}
|
|
11
|
-
function execQuiet(
|
|
11
|
+
function execQuiet(args, cwd) {
|
|
12
12
|
try {
|
|
13
|
-
return
|
|
13
|
+
return runGit(args, cwd, true).trim();
|
|
14
14
|
}
|
|
15
15
|
catch {
|
|
16
16
|
return '';
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
function isSafeGitRef(value) {
|
|
20
|
+
return (/^[A-Za-z0-9._/@-]+$/.test(value) &&
|
|
21
|
+
!value.startsWith('-') &&
|
|
22
|
+
!value.endsWith('.') &&
|
|
23
|
+
!value.includes('..') &&
|
|
24
|
+
!value.includes('@{'));
|
|
25
|
+
}
|
|
19
26
|
function hasUncommittedChanges(cwd) {
|
|
20
|
-
const status = execQuiet('
|
|
27
|
+
const status = execQuiet(['status', '--porcelain'], cwd);
|
|
21
28
|
return status.length > 0;
|
|
22
29
|
}
|
|
23
30
|
function ensureUpstreamRemote(cwd) {
|
|
24
|
-
const remotes = execQuiet('
|
|
31
|
+
const remotes = execQuiet(['remote'], cwd);
|
|
25
32
|
if (!remotes.split('\n').includes(UPSTREAM_REMOTE)) {
|
|
26
33
|
info(`Adding upstream remote "${UPSTREAM_REMOTE}"...`);
|
|
27
|
-
|
|
34
|
+
runGit(['remote', 'add', UPSTREAM_REMOTE, UPSTREAM_URL], cwd, true);
|
|
28
35
|
success(`Remote "${UPSTREAM_REMOTE}" added`);
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
function fetchUpstream(cwd) {
|
|
32
39
|
info('Fetching upstream releases...');
|
|
33
|
-
execQuiet(
|
|
40
|
+
execQuiet(['fetch', UPSTREAM_REMOTE, '--tags'], cwd);
|
|
34
41
|
}
|
|
35
42
|
function getAvailableTags(cwd) {
|
|
36
|
-
const raw = execQuiet(
|
|
43
|
+
const raw = execQuiet(['tag', '-l', 'v*', '--sort=-v:refname'], cwd);
|
|
37
44
|
if (!raw)
|
|
38
45
|
return [];
|
|
39
46
|
return raw.split('\n').filter(Boolean);
|
|
40
47
|
}
|
|
41
48
|
function getCurrentVersion(cwd) {
|
|
42
|
-
const tag = execQuiet('
|
|
49
|
+
const tag = execQuiet(['describe', '--tags', '--abbrev=0'], cwd);
|
|
43
50
|
return tag || '(no version tag)';
|
|
44
51
|
}
|
|
45
52
|
const SAFE_ZONE_PATTERNS = [
|
|
@@ -52,7 +59,7 @@ const SAFE_ZONE_PATTERNS = [
|
|
|
52
59
|
'.env',
|
|
53
60
|
];
|
|
54
61
|
function classifyConflicts(cwd) {
|
|
55
|
-
const raw = execQuiet('
|
|
62
|
+
const raw = execQuiet(['diff', '--name-only', '--diff-filter=U'], cwd);
|
|
56
63
|
if (!raw)
|
|
57
64
|
return { safe: [], caution: [], core: [] };
|
|
58
65
|
const files = raw.split('\n').filter(Boolean);
|
|
@@ -106,12 +113,22 @@ export async function updateCommand(version, options) {
|
|
|
106
113
|
fail('No target version found. Run with --list to see available versions.');
|
|
107
114
|
process.exit(1);
|
|
108
115
|
}
|
|
116
|
+
if (!isSafeGitRef(target)) {
|
|
117
|
+
fail(`Invalid version or Git ref: ${target}`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
109
120
|
label('Target version', target);
|
|
110
121
|
console.log();
|
|
111
122
|
if (options.dryRun) {
|
|
112
123
|
info('Dry run — showing changes without applying:');
|
|
113
124
|
console.log();
|
|
114
|
-
|
|
125
|
+
const currentRef = isSafeGitRef(current) ? current : 'HEAD';
|
|
126
|
+
try {
|
|
127
|
+
runGit(['log', '--oneline', `${currentRef}..${UPSTREAM_REMOTE}/${target}`], root);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
runGit(['log', '--oneline', `..${target}`], root);
|
|
131
|
+
}
|
|
115
132
|
console.log();
|
|
116
133
|
dim('Run without --dry-run to apply the update.');
|
|
117
134
|
return;
|
|
@@ -124,7 +141,7 @@ export async function updateCommand(version, options) {
|
|
|
124
141
|
info(`Merging ${target}...`);
|
|
125
142
|
console.log();
|
|
126
143
|
try {
|
|
127
|
-
|
|
144
|
+
runGit(['merge', target, '--no-edit'], root);
|
|
128
145
|
success('Update merged successfully!');
|
|
129
146
|
}
|
|
130
147
|
catch {
|
|
@@ -34,6 +34,7 @@ export declare const FEATURE_ENV: {
|
|
|
34
34
|
readonly aiPlayground: 'ENABLE_AI_PLAYGROUND';
|
|
35
35
|
readonly teams: 'ENABLE_TEAMS';
|
|
36
36
|
readonly referrals: 'ENABLE_REFERRALS';
|
|
37
|
+
readonly promotions: 'ENABLE_PROMOTIONS';
|
|
37
38
|
readonly analytics: 'ENABLE_ANALYTICS';
|
|
38
39
|
readonly workflows: 'ENABLE_WORKFLOWS';
|
|
39
40
|
readonly webhooks: 'ENABLE_WEBHOOKS';
|
|
@@ -52,7 +53,7 @@ export declare const FEATURE_ENV: {
|
|
|
52
53
|
* the template therefore produces an actionable doctor warning until the CLI
|
|
53
54
|
* mirror is reviewed.
|
|
54
55
|
*/
|
|
55
|
-
export declare const ENV_SCHEMA_KEYS: readonly ["NEXT_PUBLIC_APP_URL", "NEXT_PUBLIC_APP_NAME", "APP_MODE", "DEMO_URL", "LOG_LEVEL", "DB_PROVIDER", "AUTH_PROVIDER", "PAYMENT_PROVIDER", "STORAGE_PROVIDER", "JOB_PROVIDER", "SSO_PROVIDER", "NOTIFICATION_TRANSPORT", "EMBEDDING_PROVIDER", "VECTOR_STORE_PROVIDER", "SUPPORT_PROVIDER", "TURSO_DATABASE_URL", "TURSO_AUTH_TOKEN", "DATABASE_URL", "ENABLE_TWO_FACTOR", "AUTH_MAGIC_LINK", "AUTH_PASSKEYS", "BETTER_AUTH_SECRET", "BETTER_AUTH_URL", "KINDE_CLIENT_ID", "KINDE_CLIENT_SECRET", "KINDE_ISSUER_URL", "GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET", "GITHUB_CLIENT_ID", "GITHUB_CLIENT_SECRET", "APPLE_CLIENT_ID", "APPLE_CLIENT_SECRET", "DISCORD_CLIENT_ID", "DISCORD_CLIENT_SECRET", "TWITTER_CLIENT_ID", "TWITTER_CLIENT_SECRET", "MICROSOFT_CLIENT_ID", "MICROSOFT_CLIENT_SECRET", "STRIPE_SECRET_KEY", "STRIPE_WEBHOOK_SECRET", "STRIPE_CONNECT_FEE_PERCENT", "STRIPE_CONNECT_ONBOARDING_RETURN_URL", "STRIPE_CONNECT_ONBOARDING_REFRESH_URL", "LEMONSQUEEZY_API_KEY", "LEMONSQUEEZY_STORE_ID", "LEMONSQUEEZY_WEBHOOK_SECRET", "POLAR_ACCESS_TOKEN", "POLAR_WEBHOOK_SECRET", "S3_BUCKET", "S3_REGION", "S3_ENDPOINT", "S3_ACCESS_KEY_ID", "S3_SECRET_ACCESS_KEY", "S3_PUBLIC_URL", "JOB_QUEUE_NAME", "REDIS_URL", "CODAPULT_WORKER_MODE", "CODAPULT_DISABLE_IN_PROCESS_JOBS", "CUSTOM_DOMAIN_CNAME_TARGET", "REFERRAL_REWARD_AMOUNT", "REFERRAL_REWARD_TYPE", "SSO_PRODUCT", "SSO_DB_ENGINE", "SSO_DB_TYPE", "SSO_DB_URL", "NOTIFICATION_WS_URL", "NOTIFICATION_WS_PORT", "OPENAI_API_KEY", "ANTHROPIC_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY", "GROQ_API_KEY", "TOGETHER_AI_API_KEY", "CUSTOM_AI_BASE_URL", "CUSTOM_AI_API_KEY", "SERPER_API_KEY", "TAVILY_API_KEY", "AI_DEFAULT_MODEL", "AI_ALLOWED_MODELS", "AI_FALLBACK_CHAIN", "AI_MAX_RETRIES", "AI_DEFAULT_TEMPERATURE", "AI_DEFAULT_MAX_TOKENS", "AI_DEFAULT_TOP_P", "AI_DAILY_BUDGET_USD", "AI_MONTHLY_BUDGET_USD", "AI_HTTP_ALLOWLIST", "AI_RAG_MAX_DOCUMENT_SIZE", "AI_RAG_MAX_BATCH_DOCUMENTS", "AI_RAG_MAX_CHUNKS_PER_QUERY", "AI_RAG_MIN_SCORE", "OLLAMA_BASE_URL", "OLLAMA_EMBEDDING_MODEL", "RESEND_API_KEY", "EMAIL_FROM", "CRISP_WEBSITE_ID", "INTERCOM_APP_ID", "DEFAULT_MONTHLY_CREDITS", "OTEL_EXPORTER_OTLP_ENDPOINT", "OTEL_SERVICE_NAME", "OTEL_TRACES_SAMPLE_RATE", "OTEL_EXPORTER_OTLP_HEADERS", "POSTHOG_TOKEN", "POSTHOG_HOST", "POSTHOG_UI_HOST", ...("ENABLE_AI_AGENTS" | "ENABLE_AI_BATCH" | "ENABLE_AI_CHAT" | "ENABLE_AI_CORE" | "ENABLE_AI_PLAYGROUND" | "ENABLE_AI_RAG" | "ENABLE_ANALYTICS" | "ENABLE_API_DOCS" | "ENABLE_AUDIT_LOG" | "ENABLE_BLOG" | "ENABLE_BRANDING" | "ENABLE_CHANGELOG" | "ENABLE_COMPARE" | "ENABLE_DRIP_CAMPAIGNS" | "ENABLE_EXPERIMENTS" | "ENABLE_FEATURE_REQUESTS" | "ENABLE_HELP_CENTER" | "ENABLE_ONBOARDING" | "ENABLE_PLUGINS" | "ENABLE_REFERRALS" | "ENABLE_REPORTS" | "ENABLE_TEAMS" | "ENABLE_WAITLIST" | "ENABLE_WEBHOOKS" | "ENABLE_WORKFLOWS")[]];
|
|
56
|
+
export declare const ENV_SCHEMA_KEYS: readonly ["NEXT_PUBLIC_APP_URL", "NEXT_PUBLIC_APP_NAME", "APP_MODE", "DEMO_URL", "LOG_LEVEL", "DB_PROVIDER", "AUTH_PROVIDER", "PAYMENT_PROVIDER", "STORAGE_PROVIDER", "JOB_PROVIDER", "SSO_PROVIDER", "NOTIFICATION_TRANSPORT", "EMBEDDING_PROVIDER", "VECTOR_STORE_PROVIDER", "SUPPORT_PROVIDER", "TURSO_DATABASE_URL", "TURSO_AUTH_TOKEN", "DATABASE_URL", "ENABLE_TWO_FACTOR", "AUTH_MAGIC_LINK", "AUTH_PASSKEYS", "BETTER_AUTH_SECRET", "BETTER_AUTH_URL", "KINDE_CLIENT_ID", "KINDE_CLIENT_SECRET", "KINDE_ISSUER_URL", "GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET", "GITHUB_CLIENT_ID", "GITHUB_CLIENT_SECRET", "APPLE_CLIENT_ID", "APPLE_CLIENT_SECRET", "DISCORD_CLIENT_ID", "DISCORD_CLIENT_SECRET", "TWITTER_CLIENT_ID", "TWITTER_CLIENT_SECRET", "MICROSOFT_CLIENT_ID", "MICROSOFT_CLIENT_SECRET", "STRIPE_SECRET_KEY", "STRIPE_WEBHOOK_SECRET", "STRIPE_CONNECT_FEE_PERCENT", "STRIPE_CONNECT_ONBOARDING_RETURN_URL", "STRIPE_CONNECT_ONBOARDING_REFRESH_URL", "LEMONSQUEEZY_API_KEY", "LEMONSQUEEZY_STORE_ID", "LEMONSQUEEZY_WEBHOOK_SECRET", "POLAR_ACCESS_TOKEN", "POLAR_WEBHOOK_SECRET", "S3_BUCKET", "S3_REGION", "S3_ENDPOINT", "S3_ACCESS_KEY_ID", "S3_SECRET_ACCESS_KEY", "S3_PUBLIC_URL", "JOB_QUEUE_NAME", "REDIS_URL", "CODAPULT_WORKER_MODE", "CODAPULT_DISABLE_IN_PROCESS_JOBS", "CUSTOM_DOMAIN_CNAME_TARGET", "REFERRAL_REWARD_AMOUNT", "REFERRAL_REWARD_TYPE", "SSO_PRODUCT", "SSO_DB_ENGINE", "SSO_DB_TYPE", "SSO_DB_URL", "NOTIFICATION_WS_URL", "NOTIFICATION_WS_PORT", "OPENAI_API_KEY", "ANTHROPIC_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY", "GROQ_API_KEY", "TOGETHER_AI_API_KEY", "CUSTOM_AI_BASE_URL", "CUSTOM_AI_API_KEY", "SERPER_API_KEY", "TAVILY_API_KEY", "AI_DEFAULT_MODEL", "AI_ALLOWED_MODELS", "AI_FALLBACK_CHAIN", "AI_MAX_RETRIES", "AI_DEFAULT_TEMPERATURE", "AI_DEFAULT_MAX_TOKENS", "AI_DEFAULT_TOP_P", "AI_DAILY_BUDGET_USD", "AI_MONTHLY_BUDGET_USD", "AI_HTTP_ALLOWLIST", "AI_RAG_MAX_DOCUMENT_SIZE", "AI_RAG_MAX_BATCH_DOCUMENTS", "AI_RAG_MAX_CHUNKS_PER_QUERY", "AI_RAG_MIN_SCORE", "OLLAMA_BASE_URL", "OLLAMA_EMBEDDING_MODEL", "RESEND_API_KEY", "EMAIL_FROM", "CRISP_WEBSITE_ID", "INTERCOM_APP_ID", "DEFAULT_MONTHLY_CREDITS", "OTEL_EXPORTER_OTLP_ENDPOINT", "OTEL_SERVICE_NAME", "OTEL_TRACES_SAMPLE_RATE", "OTEL_EXPORTER_OTLP_HEADERS", "POSTHOG_TOKEN", "POSTHOG_HOST", "POSTHOG_UI_HOST", ...("ENABLE_AI_AGENTS" | "ENABLE_AI_BATCH" | "ENABLE_AI_CHAT" | "ENABLE_AI_CORE" | "ENABLE_AI_PLAYGROUND" | "ENABLE_AI_RAG" | "ENABLE_ANALYTICS" | "ENABLE_API_DOCS" | "ENABLE_AUDIT_LOG" | "ENABLE_BLOG" | "ENABLE_BRANDING" | "ENABLE_CHANGELOG" | "ENABLE_COMPARE" | "ENABLE_DRIP_CAMPAIGNS" | "ENABLE_EXPERIMENTS" | "ENABLE_FEATURE_REQUESTS" | "ENABLE_HELP_CENTER" | "ENABLE_ONBOARDING" | "ENABLE_PLUGINS" | "ENABLE_PROMOTIONS" | "ENABLE_REFERRALS" | "ENABLE_REPORTS" | "ENABLE_TEAMS" | "ENABLE_WAITLIST" | "ENABLE_WEBHOOKS" | "ENABLE_WORKFLOWS")[]];
|
|
56
57
|
/** Auth-gated features: when AUTH_PROVIDER=none, these are forced off. */
|
|
57
58
|
export declare const AUTH_GATED_FEATURES: ReadonlySet<string>;
|
|
58
59
|
/** OAuth provider → [client id env, client secret env]. Mirrors oauth-providers.ts. */
|
package/dist/utils/env-config.js
CHANGED
|
@@ -24,6 +24,7 @@ export const FEATURE_ENV = {
|
|
|
24
24
|
aiPlayground: 'ENABLE_AI_PLAYGROUND',
|
|
25
25
|
teams: 'ENABLE_TEAMS',
|
|
26
26
|
referrals: 'ENABLE_REFERRALS',
|
|
27
|
+
promotions: 'ENABLE_PROMOTIONS',
|
|
27
28
|
analytics: 'ENABLE_ANALYTICS',
|
|
28
29
|
workflows: 'ENABLE_WORKFLOWS',
|
|
29
30
|
webhooks: 'ENABLE_WEBHOOKS',
|
package/dist/utils/manifest.js
CHANGED
|
@@ -1,7 +1,48 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
2
2
|
import { resolve, join, isAbsolute, relative } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
import { getCacheDir } from './git.js';
|
|
4
5
|
const MANIFEST_FILENAME = 'codapult-plugin.json';
|
|
6
|
+
const nonEmptyString = z.string().trim().min(1);
|
|
7
|
+
const packageName = z.string().regex(/^@?[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)?$/);
|
|
8
|
+
const relativePluginPath = nonEmptyString.refine((value) => !isAbsolute(value) && !value.split(/[\\/]+/).includes('..'), 'Plugin paths must stay inside the plugin directory');
|
|
9
|
+
const pluginManifestSchema = z.object({
|
|
10
|
+
name: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
11
|
+
package: packageName,
|
|
12
|
+
version: nonEmptyString,
|
|
13
|
+
description: z.string(),
|
|
14
|
+
install: z
|
|
15
|
+
.object({
|
|
16
|
+
schemaImports: z.array(nonEmptyString).optional(),
|
|
17
|
+
schemaImportsPg: z.array(nonEmptyString).optional(),
|
|
18
|
+
dbReExports: z.array(nonEmptyString).optional(),
|
|
19
|
+
schemaTables: relativePluginPath.optional(),
|
|
20
|
+
schemaTablesPg: relativePluginPath.optional(),
|
|
21
|
+
transpilePackages: z.array(packageName).optional(),
|
|
22
|
+
serverExternalPackages: z.array(packageName).optional(),
|
|
23
|
+
shadcnComponents: z.array(z.string().regex(/^[a-z][a-z0-9-]*$/)).optional(),
|
|
24
|
+
// Keys are project-relative page paths; values are package import specifiers.
|
|
25
|
+
pages: z.record(nonEmptyString, nonEmptyString).optional(),
|
|
26
|
+
env: z
|
|
27
|
+
.record(z.string().regex(/^[A-Z][A-Z0-9_]*$/), z.object({
|
|
28
|
+
default: z.string().optional(),
|
|
29
|
+
required: z.boolean(),
|
|
30
|
+
description: z.string().optional(),
|
|
31
|
+
}))
|
|
32
|
+
.optional(),
|
|
33
|
+
optionalDeps: z.record(packageName, z.string()).optional(),
|
|
34
|
+
})
|
|
35
|
+
.default({}),
|
|
36
|
+
});
|
|
37
|
+
function realPathOrOriginal(path) {
|
|
38
|
+
try {
|
|
39
|
+
const resolved = realpathSync(path);
|
|
40
|
+
return typeof resolved === 'string' ? resolved : path;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return path;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
5
46
|
/**
|
|
6
47
|
* Verifies the resolved directory stays within expected boundaries
|
|
7
48
|
* (sibling of projectRoot or inside .codapult/plugins/).
|
|
@@ -9,8 +50,11 @@ const MANIFEST_FILENAME = 'codapult-plugin.json';
|
|
|
9
50
|
function isWithinAllowedScope(dir, projectRoot) {
|
|
10
51
|
const parentDir = resolve(projectRoot, '..');
|
|
11
52
|
const cacheDir = getCacheDir(projectRoot);
|
|
12
|
-
const
|
|
13
|
-
const
|
|
53
|
+
const resolvedDir = existsSync(dir) ? realPathOrOriginal(dir) : dir;
|
|
54
|
+
const resolvedParent = existsSync(parentDir) ? realPathOrOriginal(parentDir) : parentDir;
|
|
55
|
+
const resolvedCache = existsSync(cacheDir) ? realPathOrOriginal(cacheDir) : cacheDir;
|
|
56
|
+
const relToParent = relative(resolvedParent, resolvedDir);
|
|
57
|
+
const relToCache = relative(resolvedCache, resolvedDir);
|
|
14
58
|
const isUnderParent = !relToParent.startsWith('..') && !isAbsolute(relToParent);
|
|
15
59
|
const isUnderCache = !relToCache.startsWith('..') && !isAbsolute(relToCache);
|
|
16
60
|
return isUnderParent || isUnderCache;
|
|
@@ -38,8 +82,10 @@ export function resolveManifest(projectRoot, nameOrPath) {
|
|
|
38
82
|
if (existsSync(manifestPath)) {
|
|
39
83
|
try {
|
|
40
84
|
const content = readFileSync(manifestPath, 'utf-8');
|
|
41
|
-
const
|
|
42
|
-
|
|
85
|
+
const parsed = pluginManifestSchema.safeParse(JSON.parse(content));
|
|
86
|
+
if (parsed.success) {
|
|
87
|
+
return { manifest: parsed.data, pluginDir: dir };
|
|
88
|
+
}
|
|
43
89
|
}
|
|
44
90
|
catch {
|
|
45
91
|
// Invalid JSON
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codapult/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Open-source CLI and MCP server for Codapult SaaS projects, with architecture guardrails for AI-assisted development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"packageManager": "pnpm@11.22.0+sha512.1ff870c4c6133dfd88fb2afc46dd13d47f09c9794b438c6fdb47ca98caf3bc16381ee0be93a091b8e3824cf01f889f46d7d9e20910fb0be1ab0fb5baa80dd621",
|
|
@@ -52,28 +52,28 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
55
|
+
"@codapult/guard": "^0.5.0",
|
|
56
|
+
"@modelcontextprotocol/sdk": "^1.30.1",
|
|
57
57
|
"commander": "^15.0.0",
|
|
58
58
|
"picocolors": "^1.1.1",
|
|
59
59
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
60
|
-
"zod": "^4.
|
|
60
|
+
"zod": "^4.6.5"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@js-toolkit/config-utils": "^1.0.1",
|
|
64
|
-
"@js-toolkit/eslint-config": "^1.
|
|
64
|
+
"@js-toolkit/eslint-config": "^1.3.2",
|
|
65
65
|
"@js-toolkit/prettier-config": "^1.0.1",
|
|
66
66
|
"@js-toolkit/tsconfig": "^1.0.1",
|
|
67
|
-
"@release-it/conventional-changelog": "^12.0.
|
|
68
|
-
"@types/node": "^26.2
|
|
67
|
+
"@release-it/conventional-changelog": "^12.0.2",
|
|
68
|
+
"@types/node": "^26.6.2",
|
|
69
69
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
70
|
-
"@vitest/coverage-v8": "^
|
|
71
|
-
"eslint": "^
|
|
70
|
+
"@vitest/coverage-v8": "^5.0.1",
|
|
71
|
+
"eslint": "^10.11.0",
|
|
72
72
|
"eslint-config-prettier": "^10.1.8",
|
|
73
73
|
"eslint-plugin-prettier": "^5.5.6",
|
|
74
|
-
"prettier": "^3.9.
|
|
75
|
-
"release-it": "^21.0
|
|
76
|
-
"typescript-eslint": "^8.
|
|
77
|
-
"vitest": "^
|
|
74
|
+
"prettier": "^3.9.9",
|
|
75
|
+
"release-it": "^21.1.0",
|
|
76
|
+
"typescript-eslint": "^8.70.1",
|
|
77
|
+
"vitest": "^5.0.1"
|
|
78
78
|
}
|
|
79
79
|
}
|