@memberjunction/cli 6.1.0-edge.3 → 6.1.0-edge.5
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 +81 -0
- package/dist/commands/ai/actions/list.d.ts +2 -1
- package/dist/commands/ai/actions/list.d.ts.map +1 -1
- package/dist/commands/ai/actions/list.js +12 -3
- package/dist/commands/ai/actions/list.js.map +1 -1
- package/dist/commands/ai/actions/run.d.ts +7 -6
- package/dist/commands/ai/actions/run.d.ts.map +1 -1
- package/dist/commands/ai/actions/run.js +15 -16
- package/dist/commands/ai/actions/run.js.map +1 -1
- package/dist/commands/ai/agents/list.d.ts +2 -1
- package/dist/commands/ai/agents/list.d.ts.map +1 -1
- package/dist/commands/ai/agents/list.js +12 -3
- package/dist/commands/ai/agents/list.js.map +1 -1
- package/dist/commands/ai/agents/run.d.ts +7 -6
- package/dist/commands/ai/agents/run.d.ts.map +1 -1
- package/dist/commands/ai/agents/run.js +27 -5
- package/dist/commands/ai/agents/run.js.map +1 -1
- package/dist/commands/ai/audit/agent-run.d.ts +15 -14
- package/dist/commands/ai/audit/agent-run.d.ts.map +1 -1
- package/dist/commands/ai/audit/agent-run.js +18 -6
- package/dist/commands/ai/audit/agent-run.js.map +1 -1
- package/dist/commands/ai/prompts/run.d.ts +10 -9
- package/dist/commands/ai/prompts/run.d.ts.map +1 -1
- package/dist/commands/ai/prompts/run.js +12 -3
- package/dist/commands/ai/prompts/run.js.map +1 -1
- package/dist/commands/ai/usage.d.ts +7 -0
- package/dist/commands/ai/usage.d.ts.map +1 -0
- package/dist/commands/ai/usage.js +10 -0
- package/dist/commands/ai/usage.js.map +1 -0
- package/dist/commands/app/check-updates.d.ts.map +1 -1
- package/dist/commands/app/check-updates.js +55 -17
- package/dist/commands/app/check-updates.js.map +1 -1
- package/dist/commands/app/remove.d.ts.map +1 -1
- package/dist/commands/app/remove.js +12 -4
- package/dist/commands/app/remove.js.map +1 -1
- package/dist/commands/app/usage.d.ts +7 -0
- package/dist/commands/app/usage.d.ts.map +1 -0
- package/dist/commands/app/usage.js +10 -0
- package/dist/commands/app/usage.js.map +1 -0
- package/dist/commands/artifacts/usage.d.ts +7 -0
- package/dist/commands/artifacts/usage.d.ts.map +1 -0
- package/dist/commands/artifacts/usage.js +10 -0
- package/dist/commands/artifacts/usage.js.map +1 -0
- package/dist/commands/baseline/usage.d.ts +7 -0
- package/dist/commands/baseline/usage.d.ts.map +1 -0
- package/dist/commands/baseline/usage.js +10 -0
- package/dist/commands/baseline/usage.js.map +1 -0
- package/dist/commands/bump/usage.d.ts +7 -0
- package/dist/commands/bump/usage.d.ts.map +1 -0
- package/dist/commands/bump/usage.js +10 -0
- package/dist/commands/bump/usage.js.map +1 -0
- package/dist/commands/bundle/usage.d.ts +7 -0
- package/dist/commands/bundle/usage.d.ts.map +1 -0
- package/dist/commands/bundle/usage.js +10 -0
- package/dist/commands/bundle/usage.js.map +1 -0
- package/dist/commands/clean/usage.d.ts +7 -0
- package/dist/commands/clean/usage.d.ts.map +1 -0
- package/dist/commands/clean/usage.js +10 -0
- package/dist/commands/clean/usage.js.map +1 -0
- package/dist/commands/dbdoc/usage.d.ts +7 -0
- package/dist/commands/dbdoc/usage.d.ts.map +1 -0
- package/dist/commands/dbdoc/usage.js +10 -0
- package/dist/commands/dbdoc/usage.js.map +1 -0
- package/dist/commands/dev/workspace/index.d.ts.map +1 -1
- package/dist/commands/dev/workspace/index.js +7 -2
- package/dist/commands/dev/workspace/index.js.map +1 -1
- package/dist/commands/doctor/usage.d.ts +7 -0
- package/dist/commands/doctor/usage.d.ts.map +1 -0
- package/dist/commands/doctor/usage.js +10 -0
- package/dist/commands/doctor/usage.js.map +1 -0
- package/dist/commands/install/index.d.ts +20 -0
- package/dist/commands/install/index.d.ts.map +1 -1
- package/dist/commands/install/index.js +80 -10
- package/dist/commands/install/index.js.map +1 -1
- package/dist/commands/install/usage.d.ts +7 -0
- package/dist/commands/install/usage.d.ts.map +1 -0
- package/dist/commands/install/usage.js +10 -0
- package/dist/commands/install/usage.js.map +1 -0
- package/dist/commands/migrate/convert.d.ts +26 -0
- package/dist/commands/migrate/convert.d.ts.map +1 -1
- package/dist/commands/migrate/convert.js +115 -13
- package/dist/commands/migrate/convert.js.map +1 -1
- package/dist/commands/migrate/index.d.ts +9 -0
- package/dist/commands/migrate/index.d.ts.map +1 -1
- package/dist/commands/migrate/index.js +41 -1
- package/dist/commands/migrate/index.js.map +1 -1
- package/dist/commands/migrate/rebake.d.ts +1 -0
- package/dist/commands/migrate/rebake.d.ts.map +1 -1
- package/dist/commands/migrate/rebake.js +16 -6
- package/dist/commands/migrate/rebake.js.map +1 -1
- package/dist/commands/migrate/usage.d.ts +7 -0
- package/dist/commands/migrate/usage.d.ts.map +1 -0
- package/dist/commands/migrate/usage.js +10 -0
- package/dist/commands/migrate/usage.js.map +1 -0
- package/dist/commands/plugin/usage.d.ts +7 -0
- package/dist/commands/plugin/usage.d.ts.map +1 -0
- package/dist/commands/plugin/usage.js +10 -0
- package/dist/commands/plugin/usage.js.map +1 -0
- package/dist/commands/querygen/usage.d.ts +7 -0
- package/dist/commands/querygen/usage.d.ts.map +1 -0
- package/dist/commands/querygen/usage.js +10 -0
- package/dist/commands/querygen/usage.js.map +1 -0
- package/dist/commands/sql-audit/usage.d.ts +7 -0
- package/dist/commands/sql-audit/usage.d.ts.map +1 -0
- package/dist/commands/sql-audit/usage.js +10 -0
- package/dist/commands/sql-audit/usage.js.map +1 -0
- package/dist/commands/sql-convert/usage.d.ts +7 -0
- package/dist/commands/sql-convert/usage.d.ts.map +1 -0
- package/dist/commands/sql-convert/usage.js +10 -0
- package/dist/commands/sql-convert/usage.js.map +1 -0
- package/dist/commands/standards/usage.d.ts +7 -0
- package/dist/commands/standards/usage.d.ts.map +1 -0
- package/dist/commands/standards/usage.js +10 -0
- package/dist/commands/standards/usage.js.map +1 -0
- package/dist/commands/sync/file-reset.d.ts +6 -6
- package/dist/commands/sync/file-reset.d.ts.map +1 -1
- package/dist/commands/sync/file-reset.js +151 -127
- package/dist/commands/sync/file-reset.js.map +1 -1
- package/dist/commands/sync/init.d.ts +10 -1
- package/dist/commands/sync/init.d.ts.map +1 -1
- package/dist/commands/sync/init.js +127 -78
- package/dist/commands/sync/init.js.map +1 -1
- package/dist/commands/test/compare.d.ts +11 -11
- package/dist/commands/test/compare.d.ts.map +1 -1
- package/dist/commands/test/compare.js +8 -7
- package/dist/commands/test/compare.js.map +1 -1
- package/dist/commands/test/history.d.ts +7 -7
- package/dist/commands/test/history.d.ts.map +1 -1
- package/dist/commands/test/history.js +8 -7
- package/dist/commands/test/history.js.map +1 -1
- package/dist/commands/test/list.d.ts +8 -8
- package/dist/commands/test/list.d.ts.map +1 -1
- package/dist/commands/test/list.js +8 -7
- package/dist/commands/test/list.js.map +1 -1
- package/dist/commands/test/regression/compare.d.ts.map +1 -1
- package/dist/commands/test/regression/compare.js +5 -7
- package/dist/commands/test/regression/compare.js.map +1 -1
- package/dist/commands/test/run.d.ts +9 -9
- package/dist/commands/test/run.d.ts.map +1 -1
- package/dist/commands/test/run.js +8 -7
- package/dist/commands/test/run.js.map +1 -1
- package/dist/commands/test/suite.d.ts +11 -11
- package/dist/commands/test/suite.d.ts.map +1 -1
- package/dist/commands/test/suite.js +8 -7
- package/dist/commands/test/suite.js.map +1 -1
- package/dist/commands/test/usage.d.ts +7 -0
- package/dist/commands/test/usage.d.ts.map +1 -0
- package/dist/commands/test/usage.js +10 -0
- package/dist/commands/test/usage.js.map +1 -0
- package/dist/commands/test/validate.d.ts +7 -7
- package/dist/commands/test/validate.d.ts.map +1 -1
- package/dist/commands/test/validate.js +8 -7
- package/dist/commands/test/validate.js.map +1 -1
- package/dist/commands/translate-sql/usage.d.ts +7 -0
- package/dist/commands/translate-sql/usage.d.ts.map +1 -0
- package/dist/commands/translate-sql/usage.js +10 -0
- package/dist/commands/translate-sql/usage.js.map +1 -0
- package/dist/commands/update/usage.d.ts +7 -0
- package/dist/commands/update/usage.d.ts.map +1 -0
- package/dist/commands/update/usage.js +10 -0
- package/dist/commands/update/usage.js.map +1 -0
- package/dist/commands/usage.d.ts.map +1 -1
- package/dist/commands/usage.js +9 -4
- package/dist/commands/usage.js.map +1 -1
- package/dist/hooks/prerun.d.ts.map +1 -1
- package/dist/hooks/prerun.js +63 -30
- package/dist/hooks/prerun.js.map +1 -1
- package/dist/lib/cli-plugins.d.ts +8 -1
- package/dist/lib/cli-plugins.d.ts.map +1 -1
- package/dist/lib/cli-plugins.js +17 -1
- package/dist/lib/cli-plugins.js.map +1 -1
- package/dist/lib/derived-usage.d.ts +68 -0
- package/dist/lib/derived-usage.d.ts.map +1 -0
- package/dist/lib/derived-usage.js +121 -0
- package/dist/lib/derived-usage.js.map +1 -0
- package/dist/lib/domain-profiles.d.ts +42 -0
- package/dist/lib/domain-profiles.d.ts.map +1 -0
- package/dist/lib/domain-profiles.js +118 -0
- package/dist/lib/domain-profiles.js.map +1 -0
- package/dist/lib/domain-usage-command.d.ts.map +1 -1
- package/dist/lib/domain-usage-command.js +9 -4
- package/dist/lib/domain-usage-command.js.map +1 -1
- package/dist/lib/format-compat.d.ts +68 -0
- package/dist/lib/format-compat.d.ts.map +1 -0
- package/dist/lib/format-compat.js +111 -0
- package/dist/lib/format-compat.js.map +1 -0
- package/dist/lib/interactive-guard.d.ts +56 -0
- package/dist/lib/interactive-guard.d.ts.map +1 -0
- package/dist/lib/interactive-guard.js +60 -0
- package/dist/lib/interactive-guard.js.map +1 -0
- package/dist/lib/legacy-install.d.ts.map +1 -1
- package/dist/lib/legacy-install.js +4 -0
- package/dist/lib/legacy-install.js.map +1 -1
- package/dist/lib/usage-render.d.ts +2 -2
- package/dist/lib/usage-render.d.ts.map +1 -1
- package/dist/lib/usage-render.js +2 -1
- package/dist/lib/usage-render.js.map +1 -1
- package/dist/light-commands.d.ts.map +1 -1
- package/dist/light-commands.js +43 -0
- package/dist/light-commands.js.map +1 -1
- package/dist/utils/open-app-context.d.ts +24 -0
- package/dist/utils/open-app-context.d.ts.map +1 -1
- package/dist/utils/open-app-context.js +21 -6
- package/dist/utils/open-app-context.js.map +1 -1
- package/dist/utils/update-check.d.ts +86 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +98 -0
- package/dist/utils/update-check.js.map +1 -0
- package/oclif.manifest.json +4099 -3239
- package/package.json +21 -21
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
2
|
import { confirm, checkbox } from '@inquirer/prompts';
|
|
3
|
+
import { NonInteractiveError, resolveOrPrompt, withNonInteractiveHandling } from '../../lib/interactive-guard.js';
|
|
3
4
|
import ora from 'ora-classic';
|
|
4
5
|
import chalk from 'chalk';
|
|
5
6
|
import * as path from 'path';
|
|
@@ -23,145 +24,168 @@ export default class FileReset extends Command {
|
|
|
23
24
|
const { FileResetService, loadMJConfig, initializeProvider, getSyncEngine, getSystemUser, resetSyncEngine, configManager, } = await import('@memberjunction/metadata-sync');
|
|
24
25
|
const { flags } = await this.parse(FileReset);
|
|
25
26
|
const spinner = ora();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// Initialize data provider
|
|
36
|
-
await initializeProvider(mjConfig);
|
|
37
|
-
// Initialize sync engine
|
|
38
|
-
const syncEngine = await getSyncEngine(getSystemUser());
|
|
39
|
-
// Show success after initialization
|
|
40
|
-
if (flags.verbose) {
|
|
41
|
-
spinner.succeed('Configuration and metadata loaded');
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
27
|
+
await withNonInteractiveHandling(this, async () => {
|
|
28
|
+
try {
|
|
29
|
+
// Load configuration
|
|
30
|
+
spinner.start('Loading configuration');
|
|
31
|
+
const mjConfig = loadMJConfig();
|
|
32
|
+
if (!mjConfig) {
|
|
33
|
+
this.error('No mj.config.cjs found in current directory or parent directories');
|
|
34
|
+
}
|
|
35
|
+
// Stop spinner before the input phase
|
|
44
36
|
spinner.stop();
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
sectionsToReset =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.error(`Invalid sections: ${invalidSections.join(', ')}. Valid sections are: ${availableSections.join(', ')}`);
|
|
37
|
+
// Everything from here to the confirmation is pure input gathering: which
|
|
38
|
+
// sections, which directory, and the go-ahead. None of it needs a database.
|
|
39
|
+
// Resolving it BEFORE initializeProvider means a run that is missing
|
|
40
|
+
// --sections/--all fails in milliseconds naming the flag, instead of opening
|
|
41
|
+
// a connection and loading the whole sync engine first only to refuse. That
|
|
42
|
+
// matters most for the caller who cannot answer a prompt — an agent or CI job
|
|
43
|
+
// gets the actionable error without ever touching the database.
|
|
44
|
+
// Determine sections to reset
|
|
45
|
+
let sectionsToReset = [];
|
|
46
|
+
const availableSections = ['primaryKey', 'sync'];
|
|
47
|
+
if (flags.all) {
|
|
48
|
+
sectionsToReset = availableSections;
|
|
58
49
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{ name: 'Sync metadata', value: 'sync', checked: false }
|
|
67
|
-
]
|
|
68
|
-
});
|
|
69
|
-
if (sectionsToReset.length === 0) {
|
|
70
|
-
this.log(chalk.yellow('No sections selected. Exiting.'));
|
|
71
|
-
return;
|
|
50
|
+
else if (flags.sections) {
|
|
51
|
+
sectionsToReset = flags.sections.split(',').map(s => s.trim());
|
|
52
|
+
// Validate sections
|
|
53
|
+
const invalidSections = sectionsToReset.filter(s => !availableSections.includes(s));
|
|
54
|
+
if (invalidSections.length > 0) {
|
|
55
|
+
this.error(`Invalid sections: ${invalidSections.join(', ')}. Valid sections are: ${availableSections.join(', ')}`);
|
|
56
|
+
}
|
|
72
57
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return;
|
|
58
|
+
else {
|
|
59
|
+
// No --all/--sections given: ask when allowed, else fail naming the flags.
|
|
60
|
+
sectionsToReset = await resolveOrPrompt({
|
|
61
|
+
flagValue: undefined,
|
|
62
|
+
what: 'A list of sections to reset',
|
|
63
|
+
suggestion: `Pass --sections=${availableSections.join(',')} or --all.`,
|
|
64
|
+
prompt: () => checkbox({
|
|
65
|
+
message: 'Select sections to reset:',
|
|
66
|
+
choices: [
|
|
67
|
+
{ name: 'Primary Key metadata', value: 'primaryKey', checked: false },
|
|
68
|
+
{ name: 'Sync metadata', value: 'sync', checked: false }
|
|
69
|
+
]
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
if (sectionsToReset.length === 0) {
|
|
73
|
+
this.log(chalk.yellow('No sections selected. Exiting.'));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
92
76
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.warn(message);
|
|
119
|
-
},
|
|
120
|
-
onLog: (message) => {
|
|
121
|
-
this.log(message);
|
|
77
|
+
// Determine target directory
|
|
78
|
+
const targetDir = flags.dir
|
|
79
|
+
? path.resolve(configManager.getOriginalCwd(), flags.dir)
|
|
80
|
+
: configManager.getOriginalCwd();
|
|
81
|
+
// Show what will be reset
|
|
82
|
+
this.log(chalk.bold('\nFile Reset Summary:'));
|
|
83
|
+
this.log(`Target directory: ${path.relative(process.cwd(), targetDir)}`);
|
|
84
|
+
this.log(`Sections to reset: ${sectionsToReset.join(', ')}`);
|
|
85
|
+
this.log(`Mode: ${flags['dry-run'] ? 'Dry run (no changes will be made)' : 'Live (files will be modified)'}`);
|
|
86
|
+
// Confirm unless forced or dry-run. Headless runs must pass --force explicitly:
|
|
87
|
+
// this rewrites files on disk, so silently assuming "yes" would be worse than failing.
|
|
88
|
+
if (!flags.force && !flags['dry-run']) {
|
|
89
|
+
const shouldContinue = await resolveOrPrompt({
|
|
90
|
+
flagValue: undefined,
|
|
91
|
+
what: 'Confirmation to reset metadata sections',
|
|
92
|
+
suggestion: 'Pass --force to proceed without confirmation, or --dry-run to preview.',
|
|
93
|
+
prompt: () => confirm({
|
|
94
|
+
message: 'This will reset the selected metadata sections. Continue?',
|
|
95
|
+
default: false
|
|
96
|
+
}),
|
|
97
|
+
});
|
|
98
|
+
if (!shouldContinue) {
|
|
99
|
+
this.log(chalk.yellow('\nFile reset cancelled.'));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
122
102
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (flags
|
|
128
|
-
|
|
103
|
+
// Input is settled and the user has agreed — only now is the database worth
|
|
104
|
+
// opening.
|
|
105
|
+
await initializeProvider(mjConfig);
|
|
106
|
+
await getSyncEngine(getSystemUser());
|
|
107
|
+
if (flags.verbose) {
|
|
108
|
+
spinner.succeed('Configuration and metadata loaded');
|
|
129
109
|
}
|
|
130
110
|
else {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
111
|
+
spinner.stop();
|
|
112
|
+
}
|
|
113
|
+
// Create file reset service and execute
|
|
114
|
+
const fileResetService = new FileResetService();
|
|
115
|
+
spinner.start('Resetting file metadata...');
|
|
116
|
+
// Map selected sections to service options
|
|
117
|
+
let serviceSection = 'both';
|
|
118
|
+
if (sectionsToReset.includes('primaryKey') && sectionsToReset.includes('sync')) {
|
|
119
|
+
serviceSection = 'both';
|
|
120
|
+
}
|
|
121
|
+
else if (sectionsToReset.includes('primaryKey')) {
|
|
122
|
+
serviceSection = 'primaryKey';
|
|
123
|
+
}
|
|
124
|
+
else if (sectionsToReset.includes('sync')) {
|
|
125
|
+
serviceSection = 'sync';
|
|
126
|
+
}
|
|
127
|
+
const result = await fileResetService.resetFiles({
|
|
128
|
+
sections: serviceSection,
|
|
129
|
+
dryRun: flags['dry-run'],
|
|
130
|
+
noBackup: false,
|
|
131
|
+
verbose: flags.verbose
|
|
132
|
+
}, {
|
|
133
|
+
onProgress: (message) => {
|
|
134
|
+
spinner.start(message);
|
|
135
|
+
},
|
|
136
|
+
onWarn: (message) => {
|
|
137
|
+
this.warn(message);
|
|
138
|
+
},
|
|
139
|
+
onLog: (message) => {
|
|
140
|
+
this.log(message);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
spinner.stop();
|
|
144
|
+
// Show summary
|
|
145
|
+
if (result.modifiedFiles > 0) {
|
|
146
|
+
if (flags['dry-run']) {
|
|
147
|
+
this.log(chalk.blue(`\n🔍 Dry run complete. ${result.modifiedFiles} file(s) would be reset.`));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this.log(chalk.green(`\n✅ Successfully reset ${result.modifiedFiles} file(s).`));
|
|
151
|
+
if (result.backupsCreated > 0) {
|
|
152
|
+
this.log(chalk.gray(` 📁 Created ${result.backupsCreated} backup(s).`));
|
|
153
|
+
}
|
|
134
154
|
}
|
|
135
155
|
}
|
|
156
|
+
else {
|
|
157
|
+
this.log(chalk.yellow('\n⚠️ No files needed resetting.'));
|
|
158
|
+
}
|
|
159
|
+
if (flags.verbose) {
|
|
160
|
+
this.log(`\n📊 Statistics:`);
|
|
161
|
+
this.log(` Files processed: ${result.processedFiles}`);
|
|
162
|
+
this.log(` Files with primaryKey: ${result.filesWithPrimaryKey}`);
|
|
163
|
+
this.log(` Files with sync: ${result.filesWithSync}`);
|
|
164
|
+
this.log(` Total primaryKeys removed: ${result.totalPrimaryKeys}`);
|
|
165
|
+
this.log(` Total syncs removed: ${result.totalSyncs}`);
|
|
166
|
+
}
|
|
136
167
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.log(
|
|
145
|
-
this.log(`
|
|
146
|
-
this.log(`
|
|
168
|
+
catch (error) {
|
|
169
|
+
// A refusal to prompt is not a file-reset failure — let it through so the
|
|
170
|
+
// caller sees the flag to pass rather than a stack trace.
|
|
171
|
+
if (error instanceof NonInteractiveError)
|
|
172
|
+
throw error;
|
|
173
|
+
spinner.fail('File reset failed');
|
|
174
|
+
// Enhanced error logging
|
|
175
|
+
this.log('\n=== File Reset Error Details ===');
|
|
176
|
+
this.log(`Error type: ${error?.constructor?.name || 'Unknown'}`);
|
|
177
|
+
this.log(`Error message: ${error instanceof Error ? error.message : String(error)}`);
|
|
178
|
+
if (error instanceof Error && error.stack) {
|
|
179
|
+
this.log(`\nStack trace:`);
|
|
180
|
+
this.log(error.stack);
|
|
181
|
+
}
|
|
182
|
+
this.error(error);
|
|
147
183
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
// Enhanced error logging
|
|
152
|
-
this.log('\n=== File Reset Error Details ===');
|
|
153
|
-
this.log(`Error type: ${error?.constructor?.name || 'Unknown'}`);
|
|
154
|
-
this.log(`Error message: ${error instanceof Error ? error.message : String(error)}`);
|
|
155
|
-
if (error instanceof Error && error.stack) {
|
|
156
|
-
this.log(`\nStack trace:`);
|
|
157
|
-
this.log(error.stack);
|
|
184
|
+
finally {
|
|
185
|
+
// Reset singletons
|
|
186
|
+
resetSyncEngine();
|
|
158
187
|
}
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
finally {
|
|
162
|
-
// Reset singletons
|
|
163
|
-
resetSyncEngine();
|
|
164
|
-
}
|
|
188
|
+
});
|
|
165
189
|
}
|
|
166
190
|
}
|
|
167
191
|
//# sourceMappingURL=file-reset.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-reset.js","sourceRoot":"","sources":["../../../src/commands/sync/file-reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,GAAG,MAAM,aAAa,CAAC;AAC9B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,OAAO;aACrC,gBAAW,GAAG,8BAA8B,CAAC;aAE7C,aAAQ,GAAG;QAChB,qCAAqC;QACrC,wDAAwD;QACxD,0EAA0E;QAC1E,2CAA2C;KAC5C,CAAC;aAEK,UAAK,GAAG;QACb,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;QACxE,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,oFAAoF,EAAE,CAAC;QAC7H,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;QAClE,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC;QAChG,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;QAClE,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;KAC3E,CAAC;IAEF,KAAK,CAAC,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CAAC;YAEH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,0EAA0E;gBAC1E,0DAA0D;gBAC1D,IAAI,KAAK,YAAY,mBAAmB;oBAAE,MAAM,KAAK,CAAC;gBAEtD,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;gBAElC,yBAAyB;gBACzB,IAAI,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;gBAC/C,IAAI,CAAC,GAAG,CAAC,eAAe,KAAK,EAAE,WAAW,EAAE,IAAI,IAAI,SAAS,EAAE,CAAC,CAAC;gBACjE,IAAI,CAAC,GAAG,CAAC,kBAAkB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAErF,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;oBAC1C,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;oBAC3B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACxB,CAAC;gBAED,IAAI,CAAC,KAAK,CAAC,KAAc,CAAC,CAAC;YAC7B,CAAC;oBAAS,CAAC;gBACT,mBAAmB;gBACnB,eAAe,EAAE,CAAC;YACpB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
export default class Init extends Command {
|
|
3
3
|
static description: string;
|
|
4
|
-
static examples:
|
|
4
|
+
static examples: {
|
|
5
|
+
command: string;
|
|
6
|
+
description: string;
|
|
7
|
+
}[];
|
|
8
|
+
static flags: {
|
|
9
|
+
'setup-entity': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
entity: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
dir: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
overwrite: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
5
14
|
run(): Promise<void>;
|
|
6
15
|
}
|
|
7
16
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAU7C,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SAG+C;IAEjE,MAAM,CAAC,QAAQ;;;QAWb;IAEF,MAAM,CAAC,KAAK;;;;;MAWV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA+H3B"}
|
|
@@ -1,96 +1,145 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
4
|
import { input, select } from '@inquirer/prompts';
|
|
3
5
|
import ora from 'ora-classic';
|
|
6
|
+
import { NonInteractiveError, isInteractiveRun, resolveOrPrompt, withNonInteractiveHandling, } from '../../lib/interactive-guard.js';
|
|
4
7
|
export default class Init extends Command {
|
|
5
|
-
static { this.description =
|
|
8
|
+
static { this.description = `Initialize a directory for metadata synchronization.
|
|
9
|
+
|
|
10
|
+
Prompts at a terminal; runs unattended when piped, spawned, or in CI. To script it,
|
|
11
|
+
pass --setup-entity (and --entity/--dir when setting up "other").`; }
|
|
6
12
|
static { this.examples = [
|
|
7
|
-
`<%= config.bin %> <%= command.id
|
|
13
|
+
{ command: `<%= config.bin %> <%= command.id %> --setup-entity=no`, description: 'Initialize with no entity directory' },
|
|
14
|
+
{
|
|
15
|
+
command: `<%= config.bin %> <%= command.id %> --setup-entity=ai-prompts`,
|
|
16
|
+
description: 'Initialize and set up the AI Prompts directory',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
command: `<%= config.bin %> <%= command.id %> --setup-entity=other --entity="MJ: AI Models" --dir=ai-models`,
|
|
20
|
+
description: 'Initialize for an arbitrary entity',
|
|
21
|
+
},
|
|
22
|
+
{ command: `<%= config.bin %> <%= command.id %> --no-interactive --setup-entity=no`, description: 'Never prompt, even at a terminal' },
|
|
8
23
|
]; }
|
|
24
|
+
static { this.flags = {
|
|
25
|
+
'setup-entity': Flags.string({
|
|
26
|
+
options: ['ai-prompts', 'other', 'no'],
|
|
27
|
+
description: 'Which entity directory to set up. Use "no" to skip.',
|
|
28
|
+
}),
|
|
29
|
+
entity: Flags.string({ description: 'Entity name when --setup-entity=other (e.g. "MJ: AI Models").' }),
|
|
30
|
+
dir: Flags.string({ description: 'Directory name when --setup-entity=other. Defaults to a slug of --entity.' }),
|
|
31
|
+
overwrite: Flags.boolean({
|
|
32
|
+
allowNo: true,
|
|
33
|
+
description: 'Overwrite an existing configuration. Without this, an initialized directory is left untouched.',
|
|
34
|
+
}),
|
|
35
|
+
}; }
|
|
9
36
|
async run() {
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const initService = new InitService();
|
|
15
|
-
// Build options from user input
|
|
16
|
-
const options = {};
|
|
17
|
-
// Check for existing configuration
|
|
37
|
+
const { flags } = await this.parse(Init);
|
|
38
|
+
await withNonInteractiveHandling(this, async () => {
|
|
39
|
+
const { InitService } = await import('@memberjunction/metadata-sync');
|
|
40
|
+
const spinner = ora();
|
|
18
41
|
try {
|
|
19
|
-
//
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
42
|
+
// Check if already initialized
|
|
43
|
+
const initService = new InitService();
|
|
44
|
+
// Build options from user input
|
|
45
|
+
const options = {};
|
|
46
|
+
// Only an ALREADY-initialized directory raises the overwrite question. The
|
|
47
|
+
// previous version asked unconditionally — harmless while the answer was a
|
|
48
|
+
// prompt a human could dismiss, but fatal once a missing answer became an
|
|
49
|
+
// error, since a first-time `mj sync init` has nothing to overwrite.
|
|
50
|
+
if (existsSync(path.join(process.cwd(), '.mj-sync.json'))) {
|
|
51
|
+
const overwrite = await resolveOrPrompt({
|
|
52
|
+
flagValue: flags.overwrite,
|
|
53
|
+
what: 'An overwrite decision (this directory is already initialized)',
|
|
54
|
+
suggestion: 'Pass --overwrite to replace the existing configuration, or --no-overwrite to leave it alone.',
|
|
55
|
+
prompt: () => select({
|
|
56
|
+
message: 'Directory already initialized. Overwrite configuration?',
|
|
57
|
+
choices: [
|
|
58
|
+
{ name: 'Yes', value: true },
|
|
59
|
+
{ name: 'No', value: false },
|
|
60
|
+
],
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
if (!overwrite) {
|
|
64
|
+
this.log('Initialization cancelled');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
options.overwrite = true;
|
|
68
|
+
}
|
|
69
|
+
// Ask if they want to set up an entity directory
|
|
70
|
+
const setupEntity = await resolveOrPrompt({
|
|
71
|
+
flagValue: flags['setup-entity'],
|
|
72
|
+
what: 'An entity-directory choice',
|
|
73
|
+
suggestion: 'Pass --setup-entity=ai-prompts|other|no.',
|
|
74
|
+
prompt: () => select({
|
|
75
|
+
message: 'Would you like to set up an entity directory now?',
|
|
76
|
+
choices: [
|
|
77
|
+
{ name: 'Yes - AI Prompts', value: 'ai-prompts' },
|
|
78
|
+
{ name: 'Yes - Other entity', value: 'other' },
|
|
79
|
+
{ name: "No - I'll set up later", value: 'no' },
|
|
80
|
+
],
|
|
81
|
+
}),
|
|
26
82
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
83
|
+
options.setupEntity = setupEntity;
|
|
84
|
+
if (setupEntity === 'other') {
|
|
85
|
+
options.entityName = await resolveOrPrompt({
|
|
86
|
+
flagValue: flags.entity,
|
|
87
|
+
what: 'An entity name',
|
|
88
|
+
suggestion: 'Pass --entity "MJ: AI Models".',
|
|
89
|
+
prompt: () => input({ message: 'Enter the entity name (e.g., "Templates", "MJ: AI Models"):' }),
|
|
90
|
+
});
|
|
91
|
+
const defaultDir = options.entityName.toLowerCase().replace(/\s+/g, '-');
|
|
92
|
+
options.dirName = await resolveOrPrompt({
|
|
93
|
+
// A directory name always has a sane default derived from the entity, so
|
|
94
|
+
// headless runs fall back to it rather than failing.
|
|
95
|
+
flagValue: flags.dir ?? (isInteractiveRun() ? undefined : defaultDir),
|
|
96
|
+
what: 'A directory name',
|
|
97
|
+
suggestion: `Pass --dir ${defaultDir}.`,
|
|
98
|
+
prompt: () => input({ message: 'Enter the directory name:', default: defaultDir }),
|
|
99
|
+
});
|
|
30
100
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{ name: 'No - I\'ll set up later', value: 'no' }
|
|
43
|
-
]
|
|
44
|
-
});
|
|
45
|
-
options.setupEntity = setupEntity;
|
|
46
|
-
if (setupEntity === 'other') {
|
|
47
|
-
options.entityName = await input({
|
|
48
|
-
message: 'Enter the entity name (e.g., "Templates", "MJ: AI Models"):'
|
|
101
|
+
// Initialize with callbacks
|
|
102
|
+
await initService.initialize(options, {
|
|
103
|
+
onProgress: (message) => {
|
|
104
|
+
spinner.start(message);
|
|
105
|
+
},
|
|
106
|
+
onSuccess: (message) => {
|
|
107
|
+
spinner.succeed(message);
|
|
108
|
+
},
|
|
109
|
+
onError: (message) => {
|
|
110
|
+
spinner.fail(message);
|
|
111
|
+
},
|
|
49
112
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
113
|
+
this.log('\n✅ Initialization complete!');
|
|
114
|
+
// Show next steps
|
|
115
|
+
const nextSteps = initService.getNextSteps();
|
|
116
|
+
this.log('\nNext steps:');
|
|
117
|
+
nextSteps.forEach((step, index) => {
|
|
118
|
+
this.log(`${index + 1}. ${step.replace('mj-sync', 'mj sync')}`);
|
|
53
119
|
});
|
|
54
120
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (error instanceof NonInteractiveError)
|
|
123
|
+
throw error;
|
|
124
|
+
spinner.fail('Initialization failed');
|
|
125
|
+
// Enhanced error logging
|
|
126
|
+
this.log('\n=== Initialization Error Details ===');
|
|
127
|
+
this.log(`Error type: ${error?.constructor?.name || 'Unknown'}`);
|
|
128
|
+
this.log(`Error message: ${error instanceof Error ? error.message : String(error)}`);
|
|
129
|
+
if (error instanceof Error && error.stack) {
|
|
130
|
+
this.log(`\nStack trace:`);
|
|
131
|
+
this.log(error.stack);
|
|
65
132
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.log(`${index + 1}. ${step.replace('mj-sync', 'mj sync')}`);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
spinner.fail('Initialization failed');
|
|
77
|
-
// Enhanced error logging
|
|
78
|
-
this.log('\n=== Initialization Error Details ===');
|
|
79
|
-
this.log(`Error type: ${error?.constructor?.name || 'Unknown'}`);
|
|
80
|
-
this.log(`Error message: ${error instanceof Error ? error.message : String(error)}`);
|
|
81
|
-
if (error instanceof Error && error.stack) {
|
|
82
|
-
this.log(`\nStack trace:`);
|
|
83
|
-
this.log(error.stack);
|
|
84
|
-
}
|
|
85
|
-
// Check for error hints
|
|
86
|
-
if (error instanceof Error) {
|
|
87
|
-
const hint = new InitService().getErrorHint(error);
|
|
88
|
-
if (hint) {
|
|
89
|
-
this.log(`\nHint: ${hint}`);
|
|
133
|
+
// Check for error hints
|
|
134
|
+
if (error instanceof Error) {
|
|
135
|
+
const hint = new InitService().getErrorHint(error);
|
|
136
|
+
if (hint) {
|
|
137
|
+
this.log(`\nHint: ${hint}`);
|
|
138
|
+
}
|
|
90
139
|
}
|
|
140
|
+
this.error(error);
|
|
91
141
|
}
|
|
92
|
-
|
|
93
|
-
}
|
|
142
|
+
});
|
|
94
143
|
}
|
|
95
144
|
}
|
|
96
145
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/sync/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/sync/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,GAAG,MAAM,aAAa,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,0BAA0B,GAC3B,MAAM,gCAAgC,CAAC;AAExC,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;aAChC,gBAAW,GAAG;;;kEAG2C,CAAC;aAE1D,aAAQ,GAAG;QAChB,EAAE,OAAO,EAAE,uDAAuD,EAAE,WAAW,EAAE,qCAAqC,EAAE;QACxH;YACE,OAAO,EAAE,+DAA+D;YACxE,WAAW,EAAE,gDA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