@memberjunction/cli 2.117.0 → 2.119.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/README.md +358 -55
- package/dist/commands/clean/index.js +2 -4
- package/dist/commands/dbdoc/analyze.d.ts +3 -3
- package/dist/commands/dbdoc/analyze.js +25 -48
- package/dist/commands/dbdoc/export.d.ts +11 -4
- package/dist/commands/dbdoc/export.js +72 -75
- package/dist/commands/dbdoc/generate-queries.d.ts +13 -0
- package/dist/commands/dbdoc/generate-queries.js +82 -0
- package/dist/commands/dbdoc/init.d.ts +1 -4
- package/dist/commands/dbdoc/init.js +7 -118
- package/dist/commands/dbdoc/reset.d.ts +9 -0
- package/dist/commands/dbdoc/reset.js +53 -0
- package/dist/commands/dbdoc/status.d.ts +9 -0
- package/dist/commands/dbdoc/status.js +52 -0
- package/dist/commands/migrate/index.js +3 -5
- package/dist/commands/sync/push.d.ts +2 -0
- package/dist/commands/sync/push.js +18 -1
- package/dist/commands/sync/status.d.ts +2 -0
- package/dist/commands/sync/status.js +14 -1
- package/dist/commands/test/compare.d.ts +18 -0
- package/dist/commands/test/compare.js +73 -0
- package/dist/commands/test/history.d.ts +15 -0
- package/dist/commands/test/history.js +66 -0
- package/dist/commands/test/index.d.ts +6 -0
- package/dist/commands/test/index.js +31 -0
- package/dist/commands/test/list.d.ts +16 -0
- package/dist/commands/test/list.js +73 -0
- package/dist/commands/test/run.d.ts +17 -0
- package/dist/commands/test/run.js +69 -0
- package/dist/commands/test/suite.d.ts +15 -0
- package/dist/commands/test/suite.js +58 -0
- package/dist/commands/test/validate.d.ts +17 -0
- package/dist/commands/test/validate.js +70 -0
- package/dist/config.d.ts +16 -12
- package/dist/config.js +45 -9
- package/oclif.manifest.json +791 -85
- package/package.json +12 -9
- package/dist/commands/dbdoc/review.d.ts +0 -10
- package/dist/commands/dbdoc/review.js +0 -81
package/dist/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFlywayConfig = exports.createFlywayUrl = exports.updatedConfig = exports.config = void 0;
|
|
3
|
+
exports.getFlywayConfig = exports.createFlywayUrl = exports.updatedConfig = exports.getOptionalConfig = exports.getValidatedConfig = exports.config = void 0;
|
|
4
4
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
6
|
const node_os_1 = require("node:os");
|
|
@@ -9,6 +9,7 @@ const zod_1 = require("zod");
|
|
|
9
9
|
const MJ_REPO_URL = 'https://github.com/MemberJunction/MJ.git';
|
|
10
10
|
const explorer = (0, cosmiconfig_1.cosmiconfigSync)('mj', { searchStrategy: 'global' });
|
|
11
11
|
const result = explorer.search(process.cwd());
|
|
12
|
+
// Schema for database-dependent config (required fields)
|
|
12
13
|
const mjConfigSchema = zod_1.z.object({
|
|
13
14
|
dbHost: zod_1.z.string().default('localhost'),
|
|
14
15
|
dbDatabase: zod_1.z.string(),
|
|
@@ -21,16 +22,51 @@ const mjConfigSchema = zod_1.z.object({
|
|
|
21
22
|
cleanDisabled: zod_1.z.boolean().optional().default(true),
|
|
22
23
|
mjRepoUrl: zod_1.z.string().url().catch(MJ_REPO_URL),
|
|
23
24
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
// Schema for non-database commands (all fields optional)
|
|
26
|
+
const mjConfigSchemaOptional = zod_1.z.object({
|
|
27
|
+
dbHost: zod_1.z.string().optional(),
|
|
28
|
+
dbDatabase: zod_1.z.string().optional(),
|
|
29
|
+
dbPort: zod_1.z.number({ coerce: true }).optional(),
|
|
30
|
+
codeGenLogin: zod_1.z.string().optional(),
|
|
31
|
+
codeGenPassword: zod_1.z.string().optional(),
|
|
32
|
+
migrationsLocation: zod_1.z.string().optional().default('filesystem:./migrations'),
|
|
33
|
+
dbTrustServerCertificate: zod_1.z.coerce.boolean().default(false),
|
|
34
|
+
coreSchema: zod_1.z.string().optional().default('__mj'),
|
|
35
|
+
cleanDisabled: zod_1.z.boolean().optional().default(true),
|
|
36
|
+
mjRepoUrl: zod_1.z.string().url().catch(MJ_REPO_URL),
|
|
37
|
+
});
|
|
38
|
+
// Don't validate at module load - let commands decide when they need validated config
|
|
39
|
+
exports.config = result?.config;
|
|
40
|
+
/**
|
|
41
|
+
* Get validated config for commands that require database connection.
|
|
42
|
+
* Throws error if config is invalid.
|
|
43
|
+
*/
|
|
44
|
+
const getValidatedConfig = () => {
|
|
45
|
+
const parsedConfig = mjConfigSchema.safeParse(result?.config);
|
|
46
|
+
if (!parsedConfig.success) {
|
|
47
|
+
throw new Error(`Invalid or missing mj.config.cjs file. Database commands require valid configuration.\n` +
|
|
48
|
+
`Missing fields: ${parsedConfig.error.issues.map(i => i.path.join('.')).join(', ')}`);
|
|
49
|
+
}
|
|
50
|
+
return parsedConfig.data;
|
|
51
|
+
};
|
|
52
|
+
exports.getValidatedConfig = getValidatedConfig;
|
|
53
|
+
/**
|
|
54
|
+
* Get optional config for commands that don't require database connection.
|
|
55
|
+
* Returns undefined if no config exists, or partial config if it exists.
|
|
56
|
+
*/
|
|
57
|
+
const getOptionalConfig = () => {
|
|
58
|
+
const parsedConfig = mjConfigSchemaOptional.safeParse(result?.config);
|
|
59
|
+
return parsedConfig.success ? parsedConfig.data : undefined;
|
|
60
|
+
};
|
|
61
|
+
exports.getOptionalConfig = getOptionalConfig;
|
|
62
|
+
/**
|
|
63
|
+
* Legacy function for backward compatibility with codegen.
|
|
64
|
+
* Validates and returns updated config.
|
|
65
|
+
* Returns undefined silently if config is invalid (command will handle the error).
|
|
66
|
+
*/
|
|
29
67
|
const updatedConfig = () => {
|
|
30
68
|
const maybeConfig = mjConfigSchema.safeParse(explorer.search(process.cwd())?.config);
|
|
31
|
-
|
|
32
|
-
console.error('Error parsing config file', JSON.stringify(maybeConfig.error.issues, null, 2));
|
|
33
|
-
}
|
|
69
|
+
// Don't log errors here - let the calling command handle validation
|
|
34
70
|
return maybeConfig.success ? maybeConfig.data : undefined;
|
|
35
71
|
};
|
|
36
72
|
exports.updatedConfig = updatedConfig;
|