@deessejs/cli 0.6.43 → 0.6.45
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/bin/deesse.js +3 -2
- package/dist/commands/db/index.d.ts +2 -0
- package/dist/commands/db/index.d.ts.map +1 -1
- package/dist/commands/db/index.js +8 -142
- package/dist/commands/db/index.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +18 -164
- package/dist/index.js.map +1 -1
- package/dist/utils/config.d.ts +8 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +10 -0
- package/dist/utils/config.js.map +1 -0
- package/package.json +54 -53
- package/dist/commands/admin/create.d.ts.map +0 -1
- package/dist/commands/admin/create.js +0 -166
- package/dist/commands/admin/create.js.map +0 -1
- package/dist/commands/admin.d.ts.map +0 -1
- package/dist/commands/admin.js +0 -22
- package/dist/commands/admin.js.map +0 -1
- package/dist/commands/db/generate.d.ts +0 -19
- package/dist/commands/db/generate.d.ts.map +0 -1
- package/dist/commands/db/generate.js +0 -59
- package/dist/commands/db/generate.js.map +0 -1
- package/dist/commands/db/migrate.d.ts.map +0 -1
- package/dist/commands/db/migrate.js +0 -75
- package/dist/commands/db/migrate.js.map +0 -1
- package/dist/commands/db/push.d.ts.map +0 -1
- package/dist/commands/db/push.js +0 -39
- package/dist/commands/db/push.js.map +0 -1
- package/dist/lib/admin/create.d.ts +0 -29
- package/dist/lib/admin/create.d.ts.map +0 -1
- package/dist/lib/admin/create.js +0 -54
- package/dist/lib/admin/create.js.map +0 -1
- package/dist/lib/config/loader.d.ts +0 -77
- package/dist/lib/config/loader.d.ts.map +0 -1
- package/dist/lib/config/loader.js +0 -199
- package/dist/lib/config/loader.js.map +0 -1
- package/dist/lib/db/auth-schema.d.ts +0 -28
- package/dist/lib/db/auth-schema.d.ts.map +0 -1
- package/dist/lib/db/auth-schema.js +0 -116
- package/dist/lib/db/auth-schema.js.map +0 -1
- package/dist/lib/db/schema.d.ts.map +0 -1
- package/dist/lib/db/schema.js +0 -144
- package/dist/lib/db/schema.js.map +0 -1
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -6
- package/dist/lib/index.js.map +0 -1
- package/dist/utils/schema-loader.d.ts.map +0 -1
- package/dist/utils/schema-loader.js +0 -46
- package/dist/utils/schema-loader.js.map +0 -1
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Admin create command - CLI interface
|
|
3
|
-
*
|
|
4
|
-
* Handles user interaction and delegates to backend logic.
|
|
5
|
-
*/
|
|
6
|
-
import * as p from '@clack/prompts';
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
import { loadMinimalConfig, ConfigLoaderError } from '../../lib/config/loader.js';
|
|
9
|
-
import { createAdminUser, AdminCreationError } from '../../lib/admin/create.js';
|
|
10
|
-
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
11
|
-
// Load environment variables
|
|
12
|
-
import 'dotenv/config';
|
|
13
|
-
const AdminSchema = z.object({
|
|
14
|
-
email: z.string().email('Invalid email format'),
|
|
15
|
-
password: z.string().min(8, 'Password must be at least 8 characters'),
|
|
16
|
-
name: z.string().min(1, 'Name is required').default('Admin'),
|
|
17
|
-
});
|
|
18
|
-
// Public email domains that should warn users
|
|
19
|
-
const PUBLIC_EMAIL_DOMAINS = [
|
|
20
|
-
'gmail.com',
|
|
21
|
-
'yahoo.com',
|
|
22
|
-
'hotmail.com',
|
|
23
|
-
'outlook.com',
|
|
24
|
-
'icloud.com',
|
|
25
|
-
'mail.com',
|
|
26
|
-
'aol.com',
|
|
27
|
-
];
|
|
28
|
-
function isPublicEmailDomain(email) {
|
|
29
|
-
const domain = email.split('@')[1]?.toLowerCase();
|
|
30
|
-
return PUBLIC_EMAIL_DOMAINS.includes(domain);
|
|
31
|
-
}
|
|
32
|
-
function validateEmail(value) {
|
|
33
|
-
if (!value)
|
|
34
|
-
return 'Email is required';
|
|
35
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
36
|
-
if (!emailRegex.test(value))
|
|
37
|
-
return 'Invalid email format';
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
function validatePassword(value) {
|
|
41
|
-
if (value.length < 8)
|
|
42
|
-
return 'Password must be at least 8 characters';
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
async function promptForAdminDetails() {
|
|
46
|
-
p.intro('Creating admin user');
|
|
47
|
-
const emailResult = await p.text({
|
|
48
|
-
message: 'Admin email:',
|
|
49
|
-
validate: validateEmail,
|
|
50
|
-
});
|
|
51
|
-
if (p.isCancel(emailResult)) {
|
|
52
|
-
p.cancel('Operation cancelled.');
|
|
53
|
-
process.exit(0);
|
|
54
|
-
}
|
|
55
|
-
if (isPublicEmailDomain(emailResult)) {
|
|
56
|
-
p.log.warn(`Warning: ${emailResult} is a public email domain.\n` +
|
|
57
|
-
' Admin accounts should use organizational email addresses.');
|
|
58
|
-
}
|
|
59
|
-
const passwordResult = await p.password({
|
|
60
|
-
message: 'Admin password:',
|
|
61
|
-
mask: true,
|
|
62
|
-
validate: validatePassword,
|
|
63
|
-
});
|
|
64
|
-
if (p.isCancel(passwordResult)) {
|
|
65
|
-
p.cancel('Operation cancelled.');
|
|
66
|
-
process.exit(0);
|
|
67
|
-
}
|
|
68
|
-
const nameResult = await p.text({
|
|
69
|
-
message: 'Admin display name:',
|
|
70
|
-
defaultValue: 'Admin',
|
|
71
|
-
});
|
|
72
|
-
if (p.isCancel(nameResult)) {
|
|
73
|
-
p.cancel('Operation cancelled.');
|
|
74
|
-
process.exit(0);
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
email: emailResult,
|
|
78
|
-
password: passwordResult,
|
|
79
|
-
name: nameResult || 'Admin',
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function validateInput(options) {
|
|
83
|
-
const result = AdminSchema.safeParse(options);
|
|
84
|
-
if (!result.success) {
|
|
85
|
-
const error = result.error.errors[0];
|
|
86
|
-
throw new Error(`${error.path.join('.')}: ${error.message}`);
|
|
87
|
-
}
|
|
88
|
-
return result.data;
|
|
89
|
-
}
|
|
90
|
-
function handleError(error) {
|
|
91
|
-
if (error instanceof AdminCreationError) {
|
|
92
|
-
p.log.error(error.message);
|
|
93
|
-
if (error.suggestion) {
|
|
94
|
-
p.log.info(error.suggestion);
|
|
95
|
-
}
|
|
96
|
-
process.exit(1);
|
|
97
|
-
}
|
|
98
|
-
if (error instanceof ConfigLoaderError) {
|
|
99
|
-
p.log.error(error.message);
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
// Fallback for unknown errors
|
|
103
|
-
p.log.error('Unexpected error: ' + (error instanceof Error ? error.message : String(error)));
|
|
104
|
-
process.exit(1);
|
|
105
|
-
}
|
|
106
|
-
function printSuccess(result) {
|
|
107
|
-
p.log.success('Admin user created successfully!');
|
|
108
|
-
p.log.info(`Email: ${result.user.email}`);
|
|
109
|
-
p.log.info(`Name: ${result.user.name}`);
|
|
110
|
-
p.log.info(`ID: ${result.user.id.slice(0, 8)}...`);
|
|
111
|
-
}
|
|
112
|
-
export async function adminCreate(options) {
|
|
113
|
-
try {
|
|
114
|
-
const cwd = options.cwd || process.cwd();
|
|
115
|
-
// Load minimal config (does not execute config, only extracts secret and auth.baseURL)
|
|
116
|
-
p.log.info('Loading config...');
|
|
117
|
-
const { config } = await loadMinimalConfig(cwd);
|
|
118
|
-
// Validate DATABASE_URL
|
|
119
|
-
if (!process.env['DATABASE_URL']) {
|
|
120
|
-
p.log.error('DATABASE_URL not found in environment. Check your .env file.');
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
// Create database directly from env
|
|
124
|
-
// @ts-expect-error - pg module does not have TypeScript declarations
|
|
125
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
126
|
-
const pg = await import('pg');
|
|
127
|
-
const database = drizzle({
|
|
128
|
-
client: new pg.Pool({
|
|
129
|
-
connectionString: process.env['DATABASE_URL'],
|
|
130
|
-
}),
|
|
131
|
-
});
|
|
132
|
-
// Get admin input
|
|
133
|
-
let adminInput;
|
|
134
|
-
if (options.email && options.password) {
|
|
135
|
-
p.log.info('Creating admin user with provided credentials...');
|
|
136
|
-
adminInput = validateInput({
|
|
137
|
-
email: options.email,
|
|
138
|
-
password: options.password,
|
|
139
|
-
name: options.name || 'Admin',
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
adminInput = await promptForAdminDetails();
|
|
144
|
-
}
|
|
145
|
-
// Warn about public email
|
|
146
|
-
if (isPublicEmailDomain(adminInput.email)) {
|
|
147
|
-
p.log.warn(`Warning: ${adminInput.email} is a public email domain.\n` +
|
|
148
|
-
' Admin accounts should use organizational email addresses.');
|
|
149
|
-
}
|
|
150
|
-
// Create admin user via backend logic
|
|
151
|
-
const result = await createAdminUser({
|
|
152
|
-
email: adminInput.email,
|
|
153
|
-
password: adminInput.password,
|
|
154
|
-
name: adminInput.name,
|
|
155
|
-
database,
|
|
156
|
-
secret: config.secret,
|
|
157
|
-
baseURL: config.auth?.baseURL,
|
|
158
|
-
plugins: config.auth?.plugins || [],
|
|
159
|
-
});
|
|
160
|
-
printSuccess(result);
|
|
161
|
-
}
|
|
162
|
-
catch (error) {
|
|
163
|
-
handleError(error);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
//# sourceMappingURL=create.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/admin/create.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAChF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AAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;CAexB,CAAC"}
|
package/dist/commands/admin.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Admin command for managing admin users
|
|
3
|
-
*
|
|
4
|
-
* Usage: deesse admin create [options]
|
|
5
|
-
*/
|
|
6
|
-
export const adminCommand = {
|
|
7
|
-
name: 'admin',
|
|
8
|
-
description: 'Manage admin users',
|
|
9
|
-
subcommands: [
|
|
10
|
-
{
|
|
11
|
-
name: 'create',
|
|
12
|
-
description: 'Create an admin user',
|
|
13
|
-
options: [
|
|
14
|
-
{ name: '--email <email>', description: 'Admin email address' },
|
|
15
|
-
{ name: '--password <password>', description: 'Admin password (min 8 characters)' },
|
|
16
|
-
{ name: '--name <name>', description: 'Admin display name', default: 'Admin' },
|
|
17
|
-
{ name: '--cwd <path>', description: 'Working directory', default: process.cwd() },
|
|
18
|
-
],
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=admin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/commands/admin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,OAAgB;IACtB,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE;QACX;YACE,IAAI,EAAE,QAAiB;YACvB,WAAW,EAAE,sBAAsB;YACnC,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EAAE;gBAC/D,EAAE,IAAI,EAAE,uBAAuB,EAAE,WAAW,EAAE,mCAAmC,EAAE;gBACnF,EAAE,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,oBAAoB,EAAE,OAAO,EAAE,OAAO,EAAE;gBAC9E,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE;aACnF;SACF;KACF;CACF,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* db:generate command
|
|
3
|
-
*
|
|
4
|
-
* Generates auth schema and user migrations with drizzle-kit.
|
|
5
|
-
* Always recreates drizzle config to ensure correct schema path.
|
|
6
|
-
*/
|
|
7
|
-
export interface DbGenerateOptions {
|
|
8
|
-
cwd?: string;
|
|
9
|
-
config?: string;
|
|
10
|
-
name?: string;
|
|
11
|
-
breakpoints?: boolean;
|
|
12
|
-
custom?: boolean;
|
|
13
|
-
prefix?: 'index' | 'timestamp';
|
|
14
|
-
casing?: 'camelCase' | 'snake_case';
|
|
15
|
-
dialect?: 'postgresql' | 'mysql' | 'sqlite' | 'singlestore' | 'turso';
|
|
16
|
-
verbose?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare function dbGenerate(options?: DbGenerateOptions): Promise<void>;
|
|
19
|
-
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/commands/db/generate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC/B,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC;IACpC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,GAAG,OAAO,CAAC;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsE/E"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* db:generate command
|
|
3
|
-
*
|
|
4
|
-
* Generates auth schema and user migrations with drizzle-kit.
|
|
5
|
-
* Always recreates drizzle config to ensure correct schema path.
|
|
6
|
-
*/
|
|
7
|
-
import { execSync } from 'node:child_process';
|
|
8
|
-
import { createDrizzleConfig } from '../../lib/db/schema.js';
|
|
9
|
-
import { generateAuthSchema } from '../../lib/db/auth-schema.js';
|
|
10
|
-
export async function dbGenerate(options = {}) {
|
|
11
|
-
const { cwd = process.cwd(), config, name, breakpoints = true, custom = false, prefix, casing, dialect, verbose = false, } = options;
|
|
12
|
-
// Step 1: Generate auth schema
|
|
13
|
-
await generateAuthSchema(cwd);
|
|
14
|
-
// Step 2: Ensure drizzle.config.ts exists
|
|
15
|
-
await createDrizzleConfig(cwd);
|
|
16
|
-
// Step 3: Build drizzle-kit generate command
|
|
17
|
-
const args = ['npx drizzle-kit', 'generate'];
|
|
18
|
-
if (config) {
|
|
19
|
-
args.push('--config', config);
|
|
20
|
-
}
|
|
21
|
-
if (name) {
|
|
22
|
-
args.push('--name', name);
|
|
23
|
-
}
|
|
24
|
-
if (!breakpoints) {
|
|
25
|
-
args.push('--no-breakpoints');
|
|
26
|
-
}
|
|
27
|
-
if (custom) {
|
|
28
|
-
args.push('--custom');
|
|
29
|
-
}
|
|
30
|
-
if (prefix) {
|
|
31
|
-
args.push('--prefix', prefix);
|
|
32
|
-
}
|
|
33
|
-
if (casing) {
|
|
34
|
-
args.push('--casing', casing);
|
|
35
|
-
}
|
|
36
|
-
if (dialect) {
|
|
37
|
-
args.push('--dialect', dialect);
|
|
38
|
-
}
|
|
39
|
-
if (verbose) {
|
|
40
|
-
args.push('--verbose');
|
|
41
|
-
}
|
|
42
|
-
console.warn('Generating migrations with drizzle-kit...');
|
|
43
|
-
try {
|
|
44
|
-
execSync(args.join(' '), {
|
|
45
|
-
cwd,
|
|
46
|
-
stdio: 'inherit',
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
// Detect "no schema changes" — drizzle-kit exits with code 0 but prints this message
|
|
51
|
-
// We can't easily detect this from execSync output since stdio: 'inherit'
|
|
52
|
-
// So just forward the error
|
|
53
|
-
if (error.code === 'ENOENT') {
|
|
54
|
-
throw new Error('drizzle-kit not found. Please install it: npm install drizzle-kit');
|
|
55
|
-
}
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=generate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/db/generate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAcjE,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAA6B,EAAE;IAC9D,MAAM,EACJ,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EACnB,MAAM,EACN,IAAI,EACJ,WAAW,GAAG,IAAI,EAClB,MAAM,GAAG,KAAK,EACd,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,GAAG,KAAK,GAChB,GAAG,OAAO,CAAC;IAEZ,+BAA+B;IAC/B,MAAM,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAE9B,0CAA0C;IAC1C,MAAM,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAE/B,6CAA6C;IAC7C,MAAM,IAAI,GAAG,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAE7C,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,CAAC,IAAI,CAAC,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/commands/db/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiE7E"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* db:migrate command
|
|
3
|
-
*
|
|
4
|
-
* Verifies schema and config exist, then delegates to drizzle-kit CLI.
|
|
5
|
-
*
|
|
6
|
-
* Requirements:
|
|
7
|
-
* - src/db/schema.ts: Your Drizzle tables
|
|
8
|
-
* - drizzle.config.ts: Standard drizzle-kit config with schema and dbCredentials
|
|
9
|
-
* - .env: Should contain DATABASE_URL
|
|
10
|
-
*/
|
|
11
|
-
import { spawn } from 'node:child_process';
|
|
12
|
-
import { verifySchemaPath, DEFAULT_SCHEMA_PATH } from '../../lib/db/schema.js';
|
|
13
|
-
import * as fs from 'node:fs/promises';
|
|
14
|
-
import * as path from 'node:path';
|
|
15
|
-
import * as dotenv from 'dotenv';
|
|
16
|
-
const DRIZZLE_CONFIG_PATH = './drizzle.config.ts';
|
|
17
|
-
const SCHEMA_PATH = DEFAULT_SCHEMA_PATH;
|
|
18
|
-
export async function dbMigrate(options = {}) {
|
|
19
|
-
const { cwd = process.cwd(), dryRun = false } = options;
|
|
20
|
-
// Verify schema file exists
|
|
21
|
-
try {
|
|
22
|
-
await verifySchemaPath(cwd);
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
throw new Error(`db:migrate requires ${SCHEMA_PATH} to exist.\n` +
|
|
26
|
-
`Please create this file and export your Drizzle tables.`);
|
|
27
|
-
}
|
|
28
|
-
// Verify drizzle.config.ts exists
|
|
29
|
-
const drizzleConfigPath = path.join(cwd, DRIZZLE_CONFIG_PATH);
|
|
30
|
-
try {
|
|
31
|
-
await fs.access(drizzleConfigPath);
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
throw new Error(`db:migrate requires ${DRIZZLE_CONFIG_PATH} to exist.\n` +
|
|
35
|
-
`Please create this file with your drizzle-kit configuration.\n\n` +
|
|
36
|
-
`Example:\n` +
|
|
37
|
-
`import { defineConfig } from 'drizzle-kit';\n` +
|
|
38
|
-
`export default defineConfig({\n` +
|
|
39
|
-
` schema: './src/db/schema.ts',\n` +
|
|
40
|
-
` out: './src/db/migrations',\n` +
|
|
41
|
-
` dialect: 'postgresql',\n` +
|
|
42
|
-
` dbCredentials: {\n` +
|
|
43
|
-
` url: process.env.DATABASE_URL!,\n` +
|
|
44
|
-
` },\n` +
|
|
45
|
-
`});`);
|
|
46
|
-
}
|
|
47
|
-
console.warn('Applying migrations with drizzle-kit...');
|
|
48
|
-
// Load .env file
|
|
49
|
-
dotenv.config();
|
|
50
|
-
// Build command
|
|
51
|
-
const cmd = dryRun ? 'npx drizzle-kit migrate --dry' : 'npx drizzle-kit migrate';
|
|
52
|
-
// Use spawn with shell:true so .env is inherited
|
|
53
|
-
return new Promise((resolve, reject) => {
|
|
54
|
-
const child = spawn(cmd, {
|
|
55
|
-
cwd,
|
|
56
|
-
stdio: 'inherit',
|
|
57
|
-
shell: true,
|
|
58
|
-
});
|
|
59
|
-
child.on('close', (code) => {
|
|
60
|
-
if (code === 0) {
|
|
61
|
-
resolve();
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
reject(new Error(`Command failed: npx drizzle-kit migrate${dryRun ? ' --dry' : ''}`));
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
child.on('error', (error) => {
|
|
68
|
-
if (error.code === 'ENOENT') {
|
|
69
|
-
reject(new Error('drizzle-kit not found. Please install it: npm install drizzle-kit'));
|
|
70
|
-
}
|
|
71
|
-
reject(error);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=migrate.js.map
|
|
@@ -1 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,CAAC;CACd;AAED,wBAAsB,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCvE"}
|
package/dist/commands/db/push.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* db:push command
|
|
3
|
-
*
|
|
4
|
-
* Generates auth schema and pushes to database with drizzle-kit.
|
|
5
|
-
* Always recreates drizzle config to ensure correct schema path.
|
|
6
|
-
*/
|
|
7
|
-
import { execSync } from 'node:child_process';
|
|
8
|
-
import { createDrizzleConfig } from '../../lib/db/schema.js';
|
|
9
|
-
import { generateAuthSchema } from '../../lib/db/auth-schema.js';
|
|
10
|
-
import * as dotenv from 'dotenv';
|
|
11
|
-
export async function dbPush(options = {}) {
|
|
12
|
-
const { force = false, cwd = process.cwd() } = options;
|
|
13
|
-
// Generate auth schema (mandatory in DeesseJS)
|
|
14
|
-
await generateAuthSchema(cwd);
|
|
15
|
-
// Always recreate drizzle config to ensure correct schema path
|
|
16
|
-
console.warn('Setting up drizzle.config.ts...');
|
|
17
|
-
await createDrizzleConfig(cwd);
|
|
18
|
-
console.warn('Pushing schema to database with drizzle-kit...');
|
|
19
|
-
// Load .env file if it exists
|
|
20
|
-
dotenv.config();
|
|
21
|
-
const args = ['npx drizzle-kit', 'push'];
|
|
22
|
-
if (force) {
|
|
23
|
-
args.push('--force');
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
execSync(args.join(' '), {
|
|
27
|
-
cwd,
|
|
28
|
-
stdio: 'inherit',
|
|
29
|
-
env: process.env,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
if (error.code === 'ENOENT') {
|
|
34
|
-
throw new Error('drizzle-kit not found. Please install it: npm install drizzle-kit');
|
|
35
|
-
}
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=push.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
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CAAC;AACH,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backend logic for creating admin users
|
|
3
|
-
*
|
|
4
|
-
* This module contains the pure business logic for creating an admin user
|
|
5
|
-
* via better-auth. It has no CLI dependencies (@clack/prompts, etc.).
|
|
6
|
-
*/
|
|
7
|
-
export interface CreateAdminOptions {
|
|
8
|
-
email: string;
|
|
9
|
-
password: string;
|
|
10
|
-
name: string;
|
|
11
|
-
database: unknown;
|
|
12
|
-
secret: string;
|
|
13
|
-
baseURL?: string;
|
|
14
|
-
plugins?: unknown[];
|
|
15
|
-
}
|
|
16
|
-
export interface CreateAdminResult {
|
|
17
|
-
user: {
|
|
18
|
-
id: string;
|
|
19
|
-
email: string;
|
|
20
|
-
name: string;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export declare class AdminCreationError extends Error {
|
|
24
|
-
readonly code?: string | undefined;
|
|
25
|
-
readonly suggestion?: string | undefined;
|
|
26
|
-
constructor(message: string, code?: string | undefined, suggestion?: string | undefined);
|
|
27
|
-
}
|
|
28
|
-
export declare function createAdminUser(options: CreateAdminOptions): Promise<CreateAdminResult>;
|
|
29
|
-
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/lib/admin/create.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,qBAAa,kBAAmB,SAAQ,KAAK;aAGzB,IAAI,CAAC,EAAE,MAAM;aACb,UAAU,CAAC,EAAE,MAAM;gBAFnC,OAAO,EAAE,MAAM,EACC,IAAI,CAAC,EAAE,MAAM,YAAA,EACb,UAAU,CAAC,EAAE,MAAM,YAAA;CAKtC;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAyC7F"}
|
package/dist/lib/admin/create.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backend logic for creating admin users
|
|
3
|
-
*
|
|
4
|
-
* This module contains the pure business logic for creating an admin user
|
|
5
|
-
* via better-auth. It has no CLI dependencies (@clack/prompts, etc.).
|
|
6
|
-
*/
|
|
7
|
-
export class AdminCreationError extends Error {
|
|
8
|
-
code;
|
|
9
|
-
suggestion;
|
|
10
|
-
constructor(message, code, suggestion) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.code = code;
|
|
13
|
-
this.suggestion = suggestion;
|
|
14
|
-
this.name = 'AdminCreationError';
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export async function createAdminUser(options) {
|
|
18
|
-
const { email, password, name, database, secret, baseURL, plugins } = options;
|
|
19
|
-
// Require better-auth packages
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-explicit-any
|
|
21
|
-
const betterAuth = require('better-auth');
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-explicit-any
|
|
23
|
-
const betterAuthDrizzleAdapter = require('@better-auth/drizzle-adapter');
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-explicit-any
|
|
25
|
-
const pg = require('pg');
|
|
26
|
-
const Pool = pg.Pool;
|
|
27
|
-
// Create database client
|
|
28
|
-
const pool = new Pool({
|
|
29
|
-
connectionString: process.env['DATABASE_URL'],
|
|
30
|
-
});
|
|
31
|
-
try {
|
|
32
|
-
// Create better-auth instance with the config's database and auth settings
|
|
33
|
-
const auth = betterAuth.betterAuth({
|
|
34
|
-
database: betterAuthDrizzleAdapter.drizzleAdapter(database),
|
|
35
|
-
baseURL,
|
|
36
|
-
secret,
|
|
37
|
-
plugins: plugins || [],
|
|
38
|
-
});
|
|
39
|
-
// Create admin user via better-auth API
|
|
40
|
-
const result = await auth.api.createUser({
|
|
41
|
-
body: {
|
|
42
|
-
email,
|
|
43
|
-
password,
|
|
44
|
-
name,
|
|
45
|
-
role: 'admin',
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
await pool.end();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=create.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/lib/admin/create.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAGzB;IACA;IAHlB,YACE,OAAe,EACC,IAAa,EACb,UAAmB;QAEnC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAS;QACb,eAAU,GAAV,UAAU,CAAS;QAGnC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAA2B;IAC/D,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE9E,+BAA+B;IAC/B,qGAAqG;IACrG,MAAM,UAAU,GAAQ,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/C,qGAAqG;IACrG,MAAM,wBAAwB,GAAQ,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAC9E,qGAAqG;IACrG,MAAM,EAAE,GAAQ,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;IAErB,yBAAyB;IACzB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;QACpB,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;KAC9C,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,2EAA2E;QAC3E,MAAM,IAAI,GAAG,UAAU,CAAC,UAAU,CAAC;YACjC,QAAQ,EAAE,wBAAwB,CAAC,cAAc,CAAC,QAAQ,CAAC;YAC3D,OAAO;YACP,MAAM;YACN,OAAO,EAAE,OAAO,IAAI,EAAE;SACvB,CAAC,CAAC;QAEH,wCAAwC;QACxC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YACvC,IAAI,EAAE;gBACJ,KAAK;gBACL,QAAQ;gBACR,IAAI;gBACJ,IAAI,EAAE,OAAO;aACd;SACF,CAAC,CAAC;QAEH,OAAO,MAA2B,CAAC;IACrC,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration loader for Deesse projects
|
|
3
|
-
*
|
|
4
|
-
* Handles loading and processing of deesse.config.ts files.
|
|
5
|
-
* Uses tsx to support TypeScript imports natively.
|
|
6
|
-
*/
|
|
7
|
-
interface Config {
|
|
8
|
-
name?: string;
|
|
9
|
-
database?: unknown;
|
|
10
|
-
plugins?: unknown[];
|
|
11
|
-
pages?: unknown[];
|
|
12
|
-
secret?: string;
|
|
13
|
-
auth?: {
|
|
14
|
-
baseURL?: string;
|
|
15
|
-
plugins?: unknown[];
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
interface InternalConfig extends Config {
|
|
19
|
-
auth?: {
|
|
20
|
-
baseURL: string;
|
|
21
|
-
plugins: unknown[];
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export declare class ConfigLoaderError extends Error {
|
|
25
|
-
readonly code?: string | undefined;
|
|
26
|
-
constructor(message: string, code?: string | undefined);
|
|
27
|
-
}
|
|
28
|
-
export interface MinimalConfig {
|
|
29
|
-
secret: string;
|
|
30
|
-
auth?: {
|
|
31
|
-
baseURL?: string;
|
|
32
|
-
plugins?: unknown[];
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export interface LoadConfigResult {
|
|
36
|
-
rawConfig: Config;
|
|
37
|
-
processedConfig: InternalConfig;
|
|
38
|
-
configPath: string;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Load the raw config from a deesse.config.ts file using tsx
|
|
42
|
-
*
|
|
43
|
-
* Uses tsx to execute the config file directly and export the config object.
|
|
44
|
-
* This properly handles TypeScript imports and module context.
|
|
45
|
-
*/
|
|
46
|
-
export declare function loadRawConfig(cwd: string): Promise<{
|
|
47
|
-
config: Config;
|
|
48
|
-
configPath: string;
|
|
49
|
-
}>;
|
|
50
|
-
/**
|
|
51
|
-
* Process raw config via defineConfig to get InternalConfig
|
|
52
|
-
*/
|
|
53
|
-
export declare function processConfig(rawConfig: Config): InternalConfig;
|
|
54
|
-
/**
|
|
55
|
-
* Load and process a deesse config
|
|
56
|
-
*/
|
|
57
|
-
export declare function loadConfig(cwd: string): Promise<LoadConfigResult>;
|
|
58
|
-
/**
|
|
59
|
-
* Load minimal config without executing the config file
|
|
60
|
-
*
|
|
61
|
-
* Extracts only secret and auth.baseURL via regex to avoid loading
|
|
62
|
-
* pages and other runtime-only config that would fail during CLI use.
|
|
63
|
-
*/
|
|
64
|
-
export declare function loadMinimalConfig(cwd: string): Promise<{
|
|
65
|
-
config: MinimalConfig;
|
|
66
|
-
configPath: string;
|
|
67
|
-
}>;
|
|
68
|
-
/**
|
|
69
|
-
* Check if the admin plugin is configured in the config
|
|
70
|
-
*/
|
|
71
|
-
export declare function hasAdminPlugin(config: InternalConfig): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Verify admin plugin is configured, throw if not
|
|
74
|
-
*/
|
|
75
|
-
export declare function verifyAdminPlugin(config: InternalConfig): void;
|
|
76
|
-
export {};
|
|
77
|
-
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/lib/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,UAAU,MAAM;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;KACrB,CAAC;CACH;AAED,UAAU,cAAe,SAAQ,MAAM;IACrC,IAAI,CAAC,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,OAAO,EAAE,CAAC;KACpB,CAAC;CACH;AAED,qBAAa,iBAAkB,SAAQ,KAAK;aACG,IAAI,CAAC,EAAE,MAAM;gBAA9C,OAAO,EAAE,MAAM,EAAkB,IAAI,CAAC,EAAE,MAAM,YAAA;CAI3D;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,cAAc,CAAC;IA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