@memberjunction/testing-cli 0.0.1 → 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 +486 -29
- package/dist/commands/compare.d.ts +24 -0
- package/dist/commands/compare.d.ts.map +1 -0
- package/dist/commands/compare.js +50 -0
- package/dist/commands/compare.js.map +1 -0
- package/dist/commands/history.d.ts +23 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +47 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/list.d.ts +39 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +177 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/report.d.ts +22 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +46 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/run.d.ts +21 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +139 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/suite.d.ts +21 -0
- package/dist/commands/suite.d.ts.map +1 -0
- package/dist/commands/suite.js +105 -0
- package/dist/commands/suite.js.map +1 -0
- package/dist/commands/validate.d.ts +33 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +266 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/mj-provider.d.ts +10 -0
- package/dist/lib/mj-provider.d.ts.map +1 -0
- package/dist/lib/mj-provider.js +205 -0
- package/dist/lib/mj-provider.js.map +1 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/config-loader.d.ts +42 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +70 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/output-formatter.d.ts +64 -0
- package/dist/utils/output-formatter.d.ts.map +1 -0
- package/dist/utils/output-formatter.js +280 -0
- package/dist/utils/output-formatter.js.map +1 -0
- package/dist/utils/spinner-manager.d.ts +43 -0
- package/dist/utils/spinner-manager.d.ts.map +1 -0
- package/dist/utils/spinner-manager.js +89 -0
- package/dist/utils/spinner-manager.js.map +1 -0
- package/package.json +38 -7
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Validate command implementation
|
|
4
|
+
* @module @memberjunction/testing-cli
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.ValidateCommand = void 0;
|
|
34
|
+
const testing_engine_1 = require("@memberjunction/testing-engine");
|
|
35
|
+
const output_formatter_1 = require("../utils/output-formatter");
|
|
36
|
+
const spinner_manager_1 = require("../utils/spinner-manager");
|
|
37
|
+
const mj_provider_1 = require("../lib/mj-provider");
|
|
38
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
/**
|
|
41
|
+
* Validate command - Validate test definitions without executing
|
|
42
|
+
*/
|
|
43
|
+
class ValidateCommand {
|
|
44
|
+
constructor() {
|
|
45
|
+
this.spinner = new spinner_manager_1.SpinnerManager();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Execute the validate command
|
|
49
|
+
*
|
|
50
|
+
* @param testId - Optional test ID to validate
|
|
51
|
+
* @param flags - Command flags
|
|
52
|
+
* @param contextUser - Optional user context (will be fetched if not provided)
|
|
53
|
+
*/
|
|
54
|
+
async execute(testId, flags, contextUser) {
|
|
55
|
+
try {
|
|
56
|
+
// Initialize MJ provider (database connection and metadata)
|
|
57
|
+
await (0, mj_provider_1.initializeMJProvider)();
|
|
58
|
+
// Get context user after initialization if not provided
|
|
59
|
+
if (!contextUser) {
|
|
60
|
+
contextUser = await (0, mj_provider_1.getContextUser)();
|
|
61
|
+
}
|
|
62
|
+
const engine = testing_engine_1.TestEngine.Instance;
|
|
63
|
+
await engine.Config(false, contextUser);
|
|
64
|
+
let testsToValidate;
|
|
65
|
+
if (testId) {
|
|
66
|
+
// Validate specific test
|
|
67
|
+
const test = engine.GetTestByID(testId);
|
|
68
|
+
if (!test) {
|
|
69
|
+
console.error(output_formatter_1.OutputFormatter.formatError(`Test not found: ${testId}`));
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
testsToValidate = [test];
|
|
73
|
+
}
|
|
74
|
+
else if (flags.all) {
|
|
75
|
+
// Validate all tests
|
|
76
|
+
testsToValidate = engine.Tests;
|
|
77
|
+
}
|
|
78
|
+
else if (flags.type) {
|
|
79
|
+
// Validate tests by type
|
|
80
|
+
const type = engine.GetTestTypeByName(flags.type);
|
|
81
|
+
if (!type) {
|
|
82
|
+
console.error(output_formatter_1.OutputFormatter.formatError(`Test type not found: ${flags.type}`));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
testsToValidate = engine.Tests.filter(t => t.TypeID === type.ID);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.error(output_formatter_1.OutputFormatter.formatError('Must specify test ID, --all, or --type'));
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
// Validate tests
|
|
92
|
+
this.spinner.start(`Validating ${testsToValidate.length} test(s)...`);
|
|
93
|
+
const results = testsToValidate.map(test => this.validateTest(test, engine));
|
|
94
|
+
this.spinner.stop();
|
|
95
|
+
// Display results
|
|
96
|
+
this.displayResults(results);
|
|
97
|
+
// Save report if requested
|
|
98
|
+
if (flags.saveReport || flags.output) {
|
|
99
|
+
const reportPath = flags.output || 'validation-report.md';
|
|
100
|
+
this.saveReport(results, reportPath);
|
|
101
|
+
}
|
|
102
|
+
// Clean up resources
|
|
103
|
+
await (0, mj_provider_1.closeMJProvider)();
|
|
104
|
+
// Exit with appropriate code
|
|
105
|
+
const hasErrors = results.some(r => !r.valid);
|
|
106
|
+
process.exit(hasErrors ? 1 : 0);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
this.spinner.fail();
|
|
110
|
+
console.error(output_formatter_1.OutputFormatter.formatError('Failed to validate tests', error));
|
|
111
|
+
// Clean up resources before exit
|
|
112
|
+
try {
|
|
113
|
+
await (0, mj_provider_1.closeMJProvider)();
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// Ignore cleanup errors
|
|
117
|
+
}
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Validate a single test
|
|
123
|
+
*/
|
|
124
|
+
validateTest(test, engine) {
|
|
125
|
+
const result = {
|
|
126
|
+
testName: test.Name,
|
|
127
|
+
testId: test.ID,
|
|
128
|
+
valid: true,
|
|
129
|
+
warnings: [],
|
|
130
|
+
errors: []
|
|
131
|
+
};
|
|
132
|
+
// Check test type exists
|
|
133
|
+
const testType = engine.GetTestTypeByID(test.TypeID);
|
|
134
|
+
if (!testType) {
|
|
135
|
+
result.errors.push(`Test type not found: ${test.TypeID}`);
|
|
136
|
+
result.valid = false;
|
|
137
|
+
}
|
|
138
|
+
// Check status
|
|
139
|
+
if (test.Status !== 'Active') {
|
|
140
|
+
result.warnings.push(`Test is not active (status: ${test.Status})`);
|
|
141
|
+
}
|
|
142
|
+
// Validate InputDefinition
|
|
143
|
+
if (test.InputDefinition) {
|
|
144
|
+
try {
|
|
145
|
+
JSON.parse(test.InputDefinition);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
result.errors.push('InputDefinition is not valid JSON');
|
|
149
|
+
result.valid = false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
result.warnings.push('No InputDefinition provided');
|
|
154
|
+
}
|
|
155
|
+
// Validate ExpectedOutcomes
|
|
156
|
+
if (test.ExpectedOutcomes) {
|
|
157
|
+
try {
|
|
158
|
+
JSON.parse(test.ExpectedOutcomes);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
result.errors.push('ExpectedOutcomes is not valid JSON');
|
|
162
|
+
result.valid = false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
result.warnings.push('No ExpectedOutcomes defined');
|
|
167
|
+
}
|
|
168
|
+
// Validate Configuration (OracleConfiguration and TestConfiguration combined)
|
|
169
|
+
if (test.Configuration) {
|
|
170
|
+
try {
|
|
171
|
+
JSON.parse(test.Configuration);
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
result.errors.push('Configuration is not valid JSON');
|
|
175
|
+
result.valid = false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
result.warnings.push('No Configuration defined');
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Display validation results
|
|
185
|
+
*/
|
|
186
|
+
displayResults(results) {
|
|
187
|
+
console.log(chalk_1.default.bold('\nValidating Tests...\n'));
|
|
188
|
+
for (const result of results) {
|
|
189
|
+
const symbol = result.valid ? chalk_1.default.green('✓') : chalk_1.default.red('✗');
|
|
190
|
+
console.log(`${symbol} ${result.testName}`);
|
|
191
|
+
if (result.valid && result.warnings.length === 0) {
|
|
192
|
+
console.log(chalk_1.default.gray(' - No issues found'));
|
|
193
|
+
}
|
|
194
|
+
for (const error of result.errors) {
|
|
195
|
+
console.log(chalk_1.default.red(` ✗ Error: ${error}`));
|
|
196
|
+
}
|
|
197
|
+
for (const warning of result.warnings) {
|
|
198
|
+
console.log(chalk_1.default.yellow(` ⚠ Warning: ${warning}`));
|
|
199
|
+
}
|
|
200
|
+
console.log('');
|
|
201
|
+
}
|
|
202
|
+
// Summary
|
|
203
|
+
const validCount = results.filter(r => r.valid).length;
|
|
204
|
+
const warningCount = results.filter(r => r.warnings.length > 0).length;
|
|
205
|
+
console.log(chalk_1.default.bold('[SUMMARY]'));
|
|
206
|
+
if (validCount === results.length && warningCount === 0) {
|
|
207
|
+
console.log(chalk_1.default.green(`All ${results.length} test(s) are valid with no warnings`));
|
|
208
|
+
}
|
|
209
|
+
else if (validCount === results.length) {
|
|
210
|
+
console.log(chalk_1.default.yellow(`${validCount}/${results.length} test(s) valid, ${warningCount} with warnings`));
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
console.log(chalk_1.default.red(`${validCount}/${results.length} test(s) valid, ${results.length - validCount} with errors`));
|
|
214
|
+
}
|
|
215
|
+
console.log('');
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Save validation report to file
|
|
219
|
+
*/
|
|
220
|
+
saveReport(results, filePath) {
|
|
221
|
+
const lines = [];
|
|
222
|
+
lines.push('# Test Validation Report');
|
|
223
|
+
lines.push(`Generated: ${new Date().toISOString()}\n`);
|
|
224
|
+
lines.push('## Summary\n');
|
|
225
|
+
const validCount = results.filter(r => r.valid).length;
|
|
226
|
+
const warningCount = results.filter(r => r.warnings.length > 0).length;
|
|
227
|
+
lines.push(`- **Total Tests:** ${results.length}`);
|
|
228
|
+
lines.push(`- **Valid:** ${validCount}`);
|
|
229
|
+
lines.push(`- **Invalid:** ${results.length - validCount}`);
|
|
230
|
+
lines.push(`- **With Warnings:** ${warningCount}\n`);
|
|
231
|
+
lines.push('## Test Results\n');
|
|
232
|
+
for (const result of results) {
|
|
233
|
+
const status = result.valid ? '✓ Valid' : '✗ Invalid';
|
|
234
|
+
lines.push(`### ${result.testName}`);
|
|
235
|
+
lines.push(`**Status:** ${status}`);
|
|
236
|
+
lines.push(`**ID:** ${result.testId}\n`);
|
|
237
|
+
if (result.errors.length > 0) {
|
|
238
|
+
lines.push('**Errors:**');
|
|
239
|
+
for (const error of result.errors) {
|
|
240
|
+
lines.push(`- ${error}`);
|
|
241
|
+
}
|
|
242
|
+
lines.push('');
|
|
243
|
+
}
|
|
244
|
+
if (result.warnings.length > 0) {
|
|
245
|
+
lines.push('**Warnings:**');
|
|
246
|
+
for (const warning of result.warnings) {
|
|
247
|
+
lines.push(`- ${warning}`);
|
|
248
|
+
}
|
|
249
|
+
lines.push('');
|
|
250
|
+
}
|
|
251
|
+
if (result.valid && result.warnings.length === 0) {
|
|
252
|
+
lines.push('No issues found.\n');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const report = lines.join('\n');
|
|
256
|
+
try {
|
|
257
|
+
fs.writeFileSync(filePath, report, 'utf-8');
|
|
258
|
+
console.log(output_formatter_1.OutputFormatter.formatSuccess(`Validation report saved to ${filePath}`));
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
console.error(output_formatter_1.OutputFormatter.formatError(`Failed to save report to ${filePath}`, error));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
exports.ValidateCommand = ValidateCommand;
|
|
266
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mEAA4D;AAI5D,gEAA4D;AAC5D,8DAA0D;AAC1D,oDAA2F;AAC3F,kDAA0B;AAC1B,uCAAyB;AAazB;;GAEG;AACH,MAAa,eAAe;IAA5B;QACY,YAAO,GAAG,IAAI,gCAAc,EAAE,CAAC;IAuP3C,CAAC;IArPG;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,MAA0B,EAAE,KAAoB,EAAE,WAAsB;QAClF,IAAI,CAAC;YACD,4DAA4D;YAC5D,MAAM,IAAA,kCAAoB,GAAE,CAAC;YAE7B,wDAAwD;YACxD,IAAI,CAAC,WAAW,EAAE,CAAC;gBACf,WAAW,GAAG,MAAM,IAAA,4BAAc,GAAE,CAAC;YACzC,CAAC;YAED,MAAM,MAAM,GAAG,2BAAU,CAAC,QAAQ,CAAC;YACnC,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YAExC,IAAI,eAA6B,CAAC;YAElC,IAAI,MAAM,EAAE,CAAC;gBACT,yBAAyB;gBACzB,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBACxC,IAAI,CAAC,IAAI,EAAE,CAAC;oBACR,OAAO,CAAC,KAAK,CAAC,kCAAe,CAAC,WAAW,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC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7B,CAAC;gBACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACnB,CAAC;YAED,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7B,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAC5B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;oBACpC,KAAK,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;gBAC/B,CAAC;gBACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACnB,CAAC;YAED,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/C,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACrC,CAAC;QACL,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEhC,IAAI,CAAC;YACD,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,kCAAe,CAAC,aAAa,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC,CAAC;QACzF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,kCAAe,CAAC,WAAW,CAAC,4BAA4B,QAAQ,EAAE,EAAE,KAAc,CAAC,CAAC,CAAC;QACvG,CAAC;IACL,CAAC;CACJ;AAxPD,0CAwPC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemberJunction Testing CLI
|
|
3
|
+
*
|
|
4
|
+
* Command-line interface for the Testing Framework.
|
|
5
|
+
* Provides thin wrappers around Testing Engine for CLI execution.
|
|
6
|
+
*/
|
|
7
|
+
export { RunCommand } from './commands/run';
|
|
8
|
+
export { SuiteCommand } from './commands/suite';
|
|
9
|
+
export { ListCommand } from './commands/list';
|
|
10
|
+
export { ValidateCommand } from './commands/validate';
|
|
11
|
+
export { ReportCommand } from './commands/report';
|
|
12
|
+
export { HistoryCommand } from './commands/history';
|
|
13
|
+
export { CompareCommand } from './commands/compare';
|
|
14
|
+
export { OutputFormatter } from './utils/output-formatter';
|
|
15
|
+
export { loadCLIConfig } from './utils/config-loader';
|
|
16
|
+
export { SpinnerManager } from './utils/spinner-manager';
|
|
17
|
+
export { getContextUser } from './lib/mj-provider';
|
|
18
|
+
export * from './types';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MemberJunction Testing CLI
|
|
4
|
+
*
|
|
5
|
+
* Command-line interface for the Testing Framework.
|
|
6
|
+
* Provides thin wrappers around Testing Engine for CLI execution.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.getContextUser = exports.SpinnerManager = exports.loadCLIConfig = exports.OutputFormatter = exports.CompareCommand = exports.HistoryCommand = exports.ReportCommand = exports.ValidateCommand = exports.ListCommand = exports.SuiteCommand = exports.RunCommand = void 0;
|
|
24
|
+
// Command implementations
|
|
25
|
+
var run_1 = require("./commands/run");
|
|
26
|
+
Object.defineProperty(exports, "RunCommand", { enumerable: true, get: function () { return run_1.RunCommand; } });
|
|
27
|
+
var suite_1 = require("./commands/suite");
|
|
28
|
+
Object.defineProperty(exports, "SuiteCommand", { enumerable: true, get: function () { return suite_1.SuiteCommand; } });
|
|
29
|
+
var list_1 = require("./commands/list");
|
|
30
|
+
Object.defineProperty(exports, "ListCommand", { enumerable: true, get: function () { return list_1.ListCommand; } });
|
|
31
|
+
var validate_1 = require("./commands/validate");
|
|
32
|
+
Object.defineProperty(exports, "ValidateCommand", { enumerable: true, get: function () { return validate_1.ValidateCommand; } });
|
|
33
|
+
var report_1 = require("./commands/report");
|
|
34
|
+
Object.defineProperty(exports, "ReportCommand", { enumerable: true, get: function () { return report_1.ReportCommand; } });
|
|
35
|
+
var history_1 = require("./commands/history");
|
|
36
|
+
Object.defineProperty(exports, "HistoryCommand", { enumerable: true, get: function () { return history_1.HistoryCommand; } });
|
|
37
|
+
var compare_1 = require("./commands/compare");
|
|
38
|
+
Object.defineProperty(exports, "CompareCommand", { enumerable: true, get: function () { return compare_1.CompareCommand; } });
|
|
39
|
+
// Utilities
|
|
40
|
+
var output_formatter_1 = require("./utils/output-formatter");
|
|
41
|
+
Object.defineProperty(exports, "OutputFormatter", { enumerable: true, get: function () { return output_formatter_1.OutputFormatter; } });
|
|
42
|
+
var config_loader_1 = require("./utils/config-loader");
|
|
43
|
+
Object.defineProperty(exports, "loadCLIConfig", { enumerable: true, get: function () { return config_loader_1.loadCLIConfig; } });
|
|
44
|
+
var spinner_manager_1 = require("./utils/spinner-manager");
|
|
45
|
+
Object.defineProperty(exports, "SpinnerManager", { enumerable: true, get: function () { return spinner_manager_1.SpinnerManager; } });
|
|
46
|
+
var mj_provider_1 = require("./lib/mj-provider");
|
|
47
|
+
Object.defineProperty(exports, "getContextUser", { enumerable: true, get: function () { return mj_provider_1.getContextUser; } });
|
|
48
|
+
// Types
|
|
49
|
+
__exportStar(require("./types"), exports);
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;AAEH,0BAA0B;AAC1B,sCAA4C;AAAnC,iGAAA,UAAU,OAAA;AACnB,0CAAgD;AAAvC,qGAAA,YAAY,OAAA;AACrB,wCAA8C;AAArC,mGAAA,WAAW,OAAA;AACpB,gDAAsD;AAA7C,2GAAA,eAAe,OAAA;AACxB,4CAAkD;AAAzC,uGAAA,aAAa,OAAA;AACtB,8CAAoD;AAA3C,yGAAA,cAAc,OAAA;AACvB,8CAAoD;AAA3C,yGAAA,cAAc,OAAA;AAEvB,YAAY;AACZ,6DAA2D;AAAlD,mHAAA,eAAe,OAAA;AACxB,uDAAsD;AAA7C,8GAAA,aAAa,OAAA;AACtB,2DAAyD;AAAhD,iHAAA,cAAc,OAAA;AACvB,iDAAmD;AAA1C,6GAAA,cAAc,OAAA;AAEvB,QAAQ;AACR,0CAAwB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import sql from 'mssql';
|
|
2
|
+
export declare function initializeMJProvider(): Promise<void>;
|
|
3
|
+
export declare function getConnectionPool(): sql.ConnectionPool;
|
|
4
|
+
export declare function closeMJProvider(): Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Get a context user for CLI operations
|
|
7
|
+
* Tries to get the "System" user first, falls back to first available user
|
|
8
|
+
*/
|
|
9
|
+
export declare function getContextUser(): Promise<import('@memberjunction/core').UserInfo>;
|
|
10
|
+
//# sourceMappingURL=mj-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mj-provider.d.ts","sourceRoot":"","sources":["../../src/lib/mj-provider.ts"],"names":[],"mappings":"AAEA,OAAO,GAAG,MAAM,OAAO,CAAC;AAaxB,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAoJ1D;AAED,wBAAgB,iBAAiB,IAAI,GAAG,CAAC,cAAc,CAUtD;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAMrD;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,sBAAsB,EAAE,QAAQ,CAAC,CA4BvF"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getContextUser = exports.closeMJProvider = exports.getConnectionPool = exports.initializeMJProvider = void 0;
|
|
7
|
+
const core_1 = require("@memberjunction/core");
|
|
8
|
+
const sqlserver_dataprovider_1 = require("@memberjunction/sqlserver-dataprovider");
|
|
9
|
+
const mssql_1 = __importDefault(require("mssql"));
|
|
10
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const config_loader_1 = require("../utils/config-loader");
|
|
13
|
+
// Load environment variables from .env file
|
|
14
|
+
// Note: config-loader.ts also loads dotenv with override:true, but we include it here
|
|
15
|
+
// for completeness in case mj-provider is used standalone
|
|
16
|
+
dotenv_1.default.config({ path: path_1.default.resolve(process.cwd(), '.env'), override: true });
|
|
17
|
+
let isInitialized = false;
|
|
18
|
+
let connectionPool = null;
|
|
19
|
+
async function initializeMJProvider() {
|
|
20
|
+
if (isInitialized) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Check if MJ provider is already initialized
|
|
24
|
+
if (core_1.Metadata.Provider) {
|
|
25
|
+
console.log('MJ Provider already initialized');
|
|
26
|
+
isInitialized = true;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const config = await (0, config_loader_1.loadMJConfig)();
|
|
31
|
+
// Debug: Check what's in process.env and config
|
|
32
|
+
console.log(`process.env.DB_DATABASE: ${process.env.DB_DATABASE}`);
|
|
33
|
+
console.log(`config.dbDatabase: ${config.dbDatabase}`);
|
|
34
|
+
// Get database config from either legacy or new format
|
|
35
|
+
const dbName = config.database?.name || config.dbDatabase;
|
|
36
|
+
const dbHost = config.database?.host || config.dbHost;
|
|
37
|
+
const dbPort = config.database?.port || config.dbPort;
|
|
38
|
+
const dbUsername = config.database?.username || config.dbUsername;
|
|
39
|
+
const dbPassword = config.database?.password || config.dbPassword;
|
|
40
|
+
const dbSchema = config.database?.schema || config.coreSchema;
|
|
41
|
+
// Validate required configuration
|
|
42
|
+
if (!dbName) {
|
|
43
|
+
throw new Error(`❌ Database configuration missing
|
|
44
|
+
|
|
45
|
+
Problem: Database name not specified in configuration
|
|
46
|
+
Required: Database name must be set in mj.config.cjs
|
|
47
|
+
|
|
48
|
+
Next steps:
|
|
49
|
+
1. Check your mj.config.cjs file
|
|
50
|
+
2. Set dbDatabase property to your MJ database name
|
|
51
|
+
3. Verify other database settings (dbHost, dbUsername, dbPassword)
|
|
52
|
+
|
|
53
|
+
Example configuration:
|
|
54
|
+
module.exports = {
|
|
55
|
+
dbDatabase: 'MemberJunction_Dev',
|
|
56
|
+
dbHost: 'localhost',
|
|
57
|
+
dbUsername: process.env.DB_USERNAME,
|
|
58
|
+
dbPassword: process.env.DB_PASSWORD
|
|
59
|
+
}`);
|
|
60
|
+
}
|
|
61
|
+
if (!dbUsername || !dbPassword) {
|
|
62
|
+
throw new Error(`❌ Database credentials missing
|
|
63
|
+
|
|
64
|
+
Problem: Database username or password not configured
|
|
65
|
+
Required: Both dbUsername and dbPassword must be set
|
|
66
|
+
|
|
67
|
+
Next steps:
|
|
68
|
+
1. Check your mj.config.cjs file
|
|
69
|
+
2. Set dbUsername and dbPassword properties
|
|
70
|
+
3. Verify credentials are correct for your SQL Server
|
|
71
|
+
|
|
72
|
+
For security, use environment variables:
|
|
73
|
+
module.exports = {
|
|
74
|
+
dbUsername: process.env.DB_USERNAME,
|
|
75
|
+
dbPassword: process.env.DB_PASSWORD
|
|
76
|
+
}`);
|
|
77
|
+
}
|
|
78
|
+
// Create SQL Server connection
|
|
79
|
+
console.log(`Connecting to database: ${dbName} on ${dbHost || 'localhost'}`);
|
|
80
|
+
const sqlConfig = {
|
|
81
|
+
server: dbHost || 'localhost',
|
|
82
|
+
port: typeof dbPort === 'string' ? parseInt(dbPort) : (dbPort || 1433),
|
|
83
|
+
database: dbName,
|
|
84
|
+
user: dbUsername,
|
|
85
|
+
password: dbPassword,
|
|
86
|
+
options: {
|
|
87
|
+
encrypt: true,
|
|
88
|
+
trustServerCertificate: true,
|
|
89
|
+
enableArithAbort: true,
|
|
90
|
+
},
|
|
91
|
+
pool: {
|
|
92
|
+
max: 10,
|
|
93
|
+
min: 2,
|
|
94
|
+
idleTimeoutMillis: 30000,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
connectionPool = new mssql_1.default.ConnectionPool(sqlConfig);
|
|
98
|
+
await connectionPool.connect();
|
|
99
|
+
const providerConfig = new sqlserver_dataprovider_1.SQLServerProviderConfigData(connectionPool, dbSchema || '__mj', 180000);
|
|
100
|
+
await (0, sqlserver_dataprovider_1.setupSQLServerClient)(providerConfig);
|
|
101
|
+
// Debug: Log entity counts
|
|
102
|
+
const md = new core_1.Metadata();
|
|
103
|
+
console.log(`Total entities loaded: ${md.Entities.length}`);
|
|
104
|
+
const testEntities = md.Entities.filter(e => e.Name.toLowerCase().includes('test'));
|
|
105
|
+
console.log(`Test-related entities found: ${testEntities.length}`);
|
|
106
|
+
testEntities.forEach(e => console.log(` - ${e.Name}`));
|
|
107
|
+
// Show first 10 entities as sample
|
|
108
|
+
console.log(`First 10 entities loaded:`);
|
|
109
|
+
md.Entities.slice(0, 10).forEach(e => console.log(` - ${e.Name}`));
|
|
110
|
+
isInitialized = true;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (error?.message?.startsWith('❌')) {
|
|
114
|
+
// Already formatted error, re-throw as is
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
else if (error?.code === 'ECONNREFUSED') {
|
|
118
|
+
throw new Error(`❌ Failed to connect to database server
|
|
119
|
+
|
|
120
|
+
Problem: Connection refused to ${error.address}:${error.port}
|
|
121
|
+
Likely cause: Database server not running or incorrect host/port
|
|
122
|
+
|
|
123
|
+
Next steps:
|
|
124
|
+
1. Verify SQL Server is running on the specified host/port
|
|
125
|
+
2. Check firewall settings allow connections
|
|
126
|
+
3. Verify host and port in mj.config.cjs`);
|
|
127
|
+
}
|
|
128
|
+
else if (error?.code === 'ELOGIN') {
|
|
129
|
+
throw new Error(`❌ Database authentication failed
|
|
130
|
+
|
|
131
|
+
Problem: Invalid username or password
|
|
132
|
+
User: ${error.userName}
|
|
133
|
+
|
|
134
|
+
Next steps:
|
|
135
|
+
1. Verify username and password in mj.config.cjs
|
|
136
|
+
2. Check user has permission to access the database
|
|
137
|
+
3. Ensure SQL Server authentication is enabled`);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
throw new Error(`❌ Failed to initialize MJ data provider
|
|
141
|
+
|
|
142
|
+
Problem: ${error?.message || 'Unknown error'}
|
|
143
|
+
Context: Setting up SQL Server connection and MJ infrastructure
|
|
144
|
+
|
|
145
|
+
Next steps:
|
|
146
|
+
1. Check your mj.config.cjs database settings
|
|
147
|
+
2. Verify SQL Server is accessible
|
|
148
|
+
3. Ensure MJ core packages are built: npm run build
|
|
149
|
+
|
|
150
|
+
For debugging, run with --verbose flag for detailed error information.`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.initializeMJProvider = initializeMJProvider;
|
|
155
|
+
function getConnectionPool() {
|
|
156
|
+
if (!connectionPool) {
|
|
157
|
+
throw new Error(`❌ MJ Provider not initialized
|
|
158
|
+
|
|
159
|
+
Problem: Database connection not established
|
|
160
|
+
Likely cause: initializeMJProvider() was not called
|
|
161
|
+
|
|
162
|
+
This is an internal error. Please report this issue.`);
|
|
163
|
+
}
|
|
164
|
+
return connectionPool;
|
|
165
|
+
}
|
|
166
|
+
exports.getConnectionPool = getConnectionPool;
|
|
167
|
+
async function closeMJProvider() {
|
|
168
|
+
if (connectionPool) {
|
|
169
|
+
await connectionPool.close();
|
|
170
|
+
connectionPool = null;
|
|
171
|
+
isInitialized = false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.closeMJProvider = closeMJProvider;
|
|
175
|
+
/**
|
|
176
|
+
* Get a context user for CLI operations
|
|
177
|
+
* Tries to get the "System" user first, falls back to first available user
|
|
178
|
+
*/
|
|
179
|
+
async function getContextUser() {
|
|
180
|
+
// Try to get the System user like other CLIs do
|
|
181
|
+
let user = sqlserver_dataprovider_1.UserCache.Instance.UserByName("System", false);
|
|
182
|
+
if (!user) {
|
|
183
|
+
// Fallback to first available user if System user doesn't exist
|
|
184
|
+
if (!sqlserver_dataprovider_1.UserCache.Instance.Users || sqlserver_dataprovider_1.UserCache.Instance.Users.length === 0) {
|
|
185
|
+
throw new Error(`❌ No users found in UserCache
|
|
186
|
+
|
|
187
|
+
Problem: UserCache is empty or not properly initialized
|
|
188
|
+
Likely cause: Database connection or UserCache refresh issue
|
|
189
|
+
|
|
190
|
+
Next steps:
|
|
191
|
+
1. Verify database connection is working
|
|
192
|
+
2. Check that Users table has data
|
|
193
|
+
3. Ensure UserCache.Refresh() was called during initialization
|
|
194
|
+
|
|
195
|
+
This is typically a configuration or database setup issue.`);
|
|
196
|
+
}
|
|
197
|
+
user = sqlserver_dataprovider_1.UserCache.Instance.Users[0];
|
|
198
|
+
}
|
|
199
|
+
if (!user) {
|
|
200
|
+
throw new Error('No valid user found for execution context');
|
|
201
|
+
}
|
|
202
|
+
return user;
|
|
203
|
+
}
|
|
204
|
+
exports.getContextUser = getContextUser;
|
|
205
|
+
//# sourceMappingURL=mj-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mj-provider.js","sourceRoot":"","sources":["../../src/lib/mj-provider.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA6D;AAC7D,mFAAsH;AACtH,kDAAwB;AACxB,oDAA4B;AAC5B,gDAAwB;AACxB,0DAAsD;AAEtD,4CAA4C;AAC5C,sFAAsF;AACtF,0DAA0D;AAC1D,gBAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AAE7E,IAAI,aAAa,GAAG,K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