@magentrix-corp/magentrix-cli 1.3.16 → 1.3.17
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/LICENSE +25 -25
- package/README.md +1166 -1166
- package/actions/autopublish.old.js +293 -293
- package/actions/config.js +182 -182
- package/actions/create.js +466 -466
- package/actions/help.js +164 -164
- package/actions/iris/buildStage.js +874 -874
- package/actions/iris/delete.js +256 -256
- package/actions/iris/dev.js +391 -391
- package/actions/iris/index.js +6 -6
- package/actions/iris/link.js +375 -375
- package/actions/iris/recover.js +268 -268
- package/actions/main.js +80 -80
- package/actions/publish.js +1420 -1420
- package/actions/pull.js +684 -684
- package/actions/setup.js +148 -148
- package/actions/status.js +17 -17
- package/actions/update.js +248 -248
- package/bin/magentrix.js +393 -393
- package/package.json +55 -55
- package/utils/assetPaths.js +158 -158
- package/utils/autopublishLock.js +77 -77
- package/utils/cacher.js +206 -206
- package/utils/cli/checkInstanceUrl.js +76 -74
- package/utils/cli/helpers/compare.js +282 -282
- package/utils/cli/helpers/ensureApiKey.js +63 -63
- package/utils/cli/helpers/ensureCredentials.js +68 -68
- package/utils/cli/helpers/ensureInstanceUrl.js +75 -75
- package/utils/cli/writeRecords.js +262 -262
- package/utils/compare.js +135 -135
- package/utils/compress.js +17 -17
- package/utils/config.js +527 -527
- package/utils/debug.js +144 -144
- package/utils/diagnostics/testPublishLogic.js +96 -96
- package/utils/diff.js +49 -49
- package/utils/downloadAssets.js +291 -291
- package/utils/filetag.js +115 -115
- package/utils/hash.js +14 -14
- package/utils/iris/backup.js +411 -411
- package/utils/iris/builder.js +541 -541
- package/utils/iris/config-reader.js +664 -664
- package/utils/iris/deleteHelper.js +150 -150
- package/utils/iris/errors.js +537 -537
- package/utils/iris/linker.js +601 -601
- package/utils/iris/lock.js +360 -360
- package/utils/iris/validation.js +360 -360
- package/utils/iris/validator.js +281 -281
- package/utils/iris/zipper.js +248 -248
- package/utils/logger.js +291 -291
- package/utils/magentrix/api/assets.js +220 -220
- package/utils/magentrix/api/auth.js +107 -107
- package/utils/magentrix/api/createEntity.js +61 -61
- package/utils/magentrix/api/deleteEntity.js +55 -55
- package/utils/magentrix/api/iris.js +251 -251
- package/utils/magentrix/api/meqlQuery.js +36 -36
- package/utils/magentrix/api/retrieveEntity.js +86 -86
- package/utils/magentrix/api/updateEntity.js +66 -66
- package/utils/magentrix/fetch.js +168 -168
- package/utils/merge.js +22 -22
- package/utils/permissionError.js +70 -70
- package/utils/preferences.js +40 -40
- package/utils/progress.js +469 -469
- package/utils/spinner.js +43 -43
- package/utils/template.js +52 -52
- package/utils/updateFileBase.js +121 -121
- package/utils/workspaces.js +108 -108
- package/vars/config.js +11 -11
- package/vars/global.js +50 -50
package/actions/help.js
CHANGED
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { ensureValidCredentials } from "../utils/cli/helpers/ensureCredentials.js";
|
|
3
|
-
|
|
4
|
-
/* ─────────────────────────────
|
|
5
|
-
🎨 COLOR & STYLE SHORTCUTS
|
|
6
|
-
───────────────────────────── */
|
|
7
|
-
const style = {
|
|
8
|
-
header: chalk.bold.magenta,
|
|
9
|
-
section: chalk.underline.bold,
|
|
10
|
-
label: chalk.gray,
|
|
11
|
-
command: chalk.cyan,
|
|
12
|
-
highlight: chalk.yellow,
|
|
13
|
-
bullet: chalk.green("●"),
|
|
14
|
-
dim: chalk.dim,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/* ─────────────────────────────
|
|
18
|
-
📋 DATA SOURCES
|
|
19
|
-
───────────────────────────── */
|
|
20
|
-
|
|
21
|
-
/** All CLI commands with their one-line descriptions. */
|
|
22
|
-
const COMMANDS = [
|
|
23
|
-
{ command: "magentrix", description: "Show current environment and status" },
|
|
24
|
-
{ command: "magentrix setup", description: "Configure / update URL & API key" },
|
|
25
|
-
{ command: "magentrix pull", description: "Fetch all code into this folder" },
|
|
26
|
-
{ command: "magentrix lint", description: "Check for stale files or conflicts" },
|
|
27
|
-
{ command: "magentrix autopublish", description: "Automatically push local file changes safely to Magentrix" },
|
|
28
|
-
{ command: "magentrix status", description: "Show local vs remote differences" },
|
|
29
|
-
{ command: "magentrix create", description: "Interactive wizard for new files" },
|
|
30
|
-
{ command: "magentrix --help", description: "Show this comprehensive help guide" },
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
/** Key folders that appear after a successful `magentrix pull`. */
|
|
34
|
-
const FOLDERS = [
|
|
35
|
-
{ path: "src/pages", note: "Active Pages (.aspx)" },
|
|
36
|
-
{ path: "src/controllers", note: "Controller_*.cls files" },
|
|
37
|
-
{ path: "src/classes", note: "Utility / helper .cls files" },
|
|
38
|
-
{ path: "src/triggers", note: "Trigger_*.cls files" },
|
|
39
|
-
{ path: ".magentrix/index.json", note: "Mapping & metadata" },
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
/* ─────────────────────────────
|
|
43
|
-
🖨️ PRINT HELPERS
|
|
44
|
-
───────────────────────────── */
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Renders the comprehensive help header with current environment info.
|
|
48
|
-
*
|
|
49
|
-
* @param {string} maskedKey – API key with only last 4 chars visible.
|
|
50
|
-
* @param {string} hostname – Magentrix instance hostname.
|
|
51
|
-
*/
|
|
52
|
-
const printHelpHeader = (maskedKey, hostname) => {
|
|
53
|
-
console.log(style.header("\n📚 Magentrix CLI - Help & Usage Guide"));
|
|
54
|
-
console.log(style.dim("─────────────────────────────────────────────"));
|
|
55
|
-
console.log(
|
|
56
|
-
`${style.label("API Key:")} ${style.highlight(maskedKey)} ` +
|
|
57
|
-
`${style.label("Environment:")} ${style.highlight(hostname)}\n`,
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/** Prints a comprehensive description of what this tool does. */
|
|
62
|
-
const printDescription = () => {
|
|
63
|
-
console.log(
|
|
64
|
-
style.section("What is Magentrix CLI?"),
|
|
65
|
-
"\n" +
|
|
66
|
-
chalk.cyanBright(
|
|
67
|
-
"Sync Active Pages & Classes between Magentrix and your editor—",
|
|
68
|
-
) +
|
|
69
|
-
"edit locally, lint, then publish back safely.\n" +
|
|
70
|
-
style.dim("No built-in Git hooks—manage Git however you like.\n"),
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/** Prints the 5-step recommended workflow. */
|
|
75
|
-
const printWorkflow = () => {
|
|
76
|
-
console.log(style.section("Typical Workflow:"));
|
|
77
|
-
const STEPS = [
|
|
78
|
-
{ label: "Setup", cmd: "magentrix setup", detail: "Enter URL & API key (one-time)" },
|
|
79
|
-
{ label: "Pull", cmd: "magentrix pull", detail: "Fetch code locally" },
|
|
80
|
-
{ label: "Edit", cmd: "—", detail: "Use any code editor" },
|
|
81
|
-
{ label: "Lint", cmd: "magentrix lint", detail: "Check for conflicts" },
|
|
82
|
-
{ label: "Publish", cmd: "magentrix publish", detail: "Push changes safely" },
|
|
83
|
-
];
|
|
84
|
-
STEPS.forEach(({ label, cmd, detail }) => {
|
|
85
|
-
console.log(
|
|
86
|
-
` ${style.bullet} ${label.padEnd(7)} ${style.command(cmd.padEnd(20))} ${style.dim(detail)}`,
|
|
87
|
-
);
|
|
88
|
-
});
|
|
89
|
-
console.log(); // blank line
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/** Prints the local folder overview in an uncluttered list. */
|
|
93
|
-
const printFolders = () => {
|
|
94
|
-
console.log(style.section("Local Folder Structure:"));
|
|
95
|
-
FOLDERS.forEach(({ path, note }) => {
|
|
96
|
-
console.log(` ${style.command(path.padEnd(22))} ${style.dim(note)}`);
|
|
97
|
-
});
|
|
98
|
-
console.log();
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/** Prints the full command table. */
|
|
102
|
-
const printCommands = () => {
|
|
103
|
-
console.log(style.section("Available Commands:"));
|
|
104
|
-
COMMANDS.forEach(({ command, description }) => {
|
|
105
|
-
console.log(` ${style.command(command.padEnd(22))} ${description}`);
|
|
106
|
-
});
|
|
107
|
-
console.log();
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/** Prints quick best-practice reminders. */
|
|
111
|
-
const printTips = () => {
|
|
112
|
-
console.log(style.section("Best Practices:"));
|
|
113
|
-
[
|
|
114
|
-
"Always pull before editing.",
|
|
115
|
-
"Lint before publishing.",
|
|
116
|
-
"Optional: enable auto-publish on save during setup.",
|
|
117
|
-
"Magentrix is the source of truth; Git lives beside it.",
|
|
118
|
-
].forEach(tip => console.log(` ${style.bullet} ${tip}`));
|
|
119
|
-
console.log();
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
/** Prints additional resources and support info. */
|
|
123
|
-
const printFooter = () => {
|
|
124
|
-
console.log(
|
|
125
|
-
style.dim("Need more details? See the project README or documentation.\n"),
|
|
126
|
-
);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/* ─────────────────────────────
|
|
130
|
-
🚀 HELP ENTRY POINT
|
|
131
|
-
───────────────────────────── */
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Magentrix CLI comprehensive help display.
|
|
135
|
-
*
|
|
136
|
-
* 1. Ensure credentials are configured (to show current environment).
|
|
137
|
-
* 2. Display detailed usage guide, commands, workflow, and best practices.
|
|
138
|
-
*
|
|
139
|
-
* @async
|
|
140
|
-
* @returns {Promise<void>}
|
|
141
|
-
*/
|
|
142
|
-
export const showHelp = async () => {
|
|
143
|
-
const { apiKey, instanceUrl } = await ensureValidCredentials();
|
|
144
|
-
|
|
145
|
-
/* Mask the key except last 4 chars */
|
|
146
|
-
const maskedKey = `****${apiKey.slice(-4)}`;
|
|
147
|
-
|
|
148
|
-
/* Extract hostname from URL—for display only */
|
|
149
|
-
const hostname = (() => {
|
|
150
|
-
try {
|
|
151
|
-
return new URL(instanceUrl).hostname;
|
|
152
|
-
} catch {
|
|
153
|
-
return instanceUrl.replace(/^https?:\/\//, "").split("/")[0];
|
|
154
|
-
}
|
|
155
|
-
})();
|
|
156
|
-
|
|
157
|
-
/* Render comprehensive help sections */
|
|
158
|
-
printHelpHeader(maskedKey, hostname);
|
|
159
|
-
printDescription();
|
|
160
|
-
printWorkflow();
|
|
161
|
-
printFolders();
|
|
162
|
-
printCommands();
|
|
163
|
-
printTips();
|
|
164
|
-
printFooter();
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { ensureValidCredentials } from "../utils/cli/helpers/ensureCredentials.js";
|
|
3
|
+
|
|
4
|
+
/* ─────────────────────────────
|
|
5
|
+
🎨 COLOR & STYLE SHORTCUTS
|
|
6
|
+
───────────────────────────── */
|
|
7
|
+
const style = {
|
|
8
|
+
header: chalk.bold.magenta,
|
|
9
|
+
section: chalk.underline.bold,
|
|
10
|
+
label: chalk.gray,
|
|
11
|
+
command: chalk.cyan,
|
|
12
|
+
highlight: chalk.yellow,
|
|
13
|
+
bullet: chalk.green("●"),
|
|
14
|
+
dim: chalk.dim,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/* ─────────────────────────────
|
|
18
|
+
📋 DATA SOURCES
|
|
19
|
+
───────────────────────────── */
|
|
20
|
+
|
|
21
|
+
/** All CLI commands with their one-line descriptions. */
|
|
22
|
+
const COMMANDS = [
|
|
23
|
+
{ command: "magentrix", description: "Show current environment and status" },
|
|
24
|
+
{ command: "magentrix setup", description: "Configure / update URL & API key" },
|
|
25
|
+
{ command: "magentrix pull", description: "Fetch all code into this folder" },
|
|
26
|
+
{ command: "magentrix lint", description: "Check for stale files or conflicts" },
|
|
27
|
+
{ command: "magentrix autopublish", description: "Automatically push local file changes safely to Magentrix" },
|
|
28
|
+
{ command: "magentrix status", description: "Show local vs remote differences" },
|
|
29
|
+
{ command: "magentrix create", description: "Interactive wizard for new files" },
|
|
30
|
+
{ command: "magentrix --help", description: "Show this comprehensive help guide" },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/** Key folders that appear after a successful `magentrix pull`. */
|
|
34
|
+
const FOLDERS = [
|
|
35
|
+
{ path: "src/pages", note: "Active Pages (.aspx)" },
|
|
36
|
+
{ path: "src/controllers", note: "Controller_*.cls files" },
|
|
37
|
+
{ path: "src/classes", note: "Utility / helper .cls files" },
|
|
38
|
+
{ path: "src/triggers", note: "Trigger_*.cls files" },
|
|
39
|
+
{ path: ".magentrix/index.json", note: "Mapping & metadata" },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
/* ─────────────────────────────
|
|
43
|
+
🖨️ PRINT HELPERS
|
|
44
|
+
───────────────────────────── */
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Renders the comprehensive help header with current environment info.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} maskedKey – API key with only last 4 chars visible.
|
|
50
|
+
* @param {string} hostname – Magentrix instance hostname.
|
|
51
|
+
*/
|
|
52
|
+
const printHelpHeader = (maskedKey, hostname) => {
|
|
53
|
+
console.log(style.header("\n📚 Magentrix CLI - Help & Usage Guide"));
|
|
54
|
+
console.log(style.dim("─────────────────────────────────────────────"));
|
|
55
|
+
console.log(
|
|
56
|
+
`${style.label("API Key:")} ${style.highlight(maskedKey)} ` +
|
|
57
|
+
`${style.label("Environment:")} ${style.highlight(hostname)}\n`,
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Prints a comprehensive description of what this tool does. */
|
|
62
|
+
const printDescription = () => {
|
|
63
|
+
console.log(
|
|
64
|
+
style.section("What is Magentrix CLI?"),
|
|
65
|
+
"\n" +
|
|
66
|
+
chalk.cyanBright(
|
|
67
|
+
"Sync Active Pages & Classes between Magentrix and your editor—",
|
|
68
|
+
) +
|
|
69
|
+
"edit locally, lint, then publish back safely.\n" +
|
|
70
|
+
style.dim("No built-in Git hooks—manage Git however you like.\n"),
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** Prints the 5-step recommended workflow. */
|
|
75
|
+
const printWorkflow = () => {
|
|
76
|
+
console.log(style.section("Typical Workflow:"));
|
|
77
|
+
const STEPS = [
|
|
78
|
+
{ label: "Setup", cmd: "magentrix setup", detail: "Enter URL & API key (one-time)" },
|
|
79
|
+
{ label: "Pull", cmd: "magentrix pull", detail: "Fetch code locally" },
|
|
80
|
+
{ label: "Edit", cmd: "—", detail: "Use any code editor" },
|
|
81
|
+
{ label: "Lint", cmd: "magentrix lint", detail: "Check for conflicts" },
|
|
82
|
+
{ label: "Publish", cmd: "magentrix publish", detail: "Push changes safely" },
|
|
83
|
+
];
|
|
84
|
+
STEPS.forEach(({ label, cmd, detail }) => {
|
|
85
|
+
console.log(
|
|
86
|
+
` ${style.bullet} ${label.padEnd(7)} ${style.command(cmd.padEnd(20))} ${style.dim(detail)}`,
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
console.log(); // blank line
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** Prints the local folder overview in an uncluttered list. */
|
|
93
|
+
const printFolders = () => {
|
|
94
|
+
console.log(style.section("Local Folder Structure:"));
|
|
95
|
+
FOLDERS.forEach(({ path, note }) => {
|
|
96
|
+
console.log(` ${style.command(path.padEnd(22))} ${style.dim(note)}`);
|
|
97
|
+
});
|
|
98
|
+
console.log();
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** Prints the full command table. */
|
|
102
|
+
const printCommands = () => {
|
|
103
|
+
console.log(style.section("Available Commands:"));
|
|
104
|
+
COMMANDS.forEach(({ command, description }) => {
|
|
105
|
+
console.log(` ${style.command(command.padEnd(22))} ${description}`);
|
|
106
|
+
});
|
|
107
|
+
console.log();
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/** Prints quick best-practice reminders. */
|
|
111
|
+
const printTips = () => {
|
|
112
|
+
console.log(style.section("Best Practices:"));
|
|
113
|
+
[
|
|
114
|
+
"Always pull before editing.",
|
|
115
|
+
"Lint before publishing.",
|
|
116
|
+
"Optional: enable auto-publish on save during setup.",
|
|
117
|
+
"Magentrix is the source of truth; Git lives beside it.",
|
|
118
|
+
].forEach(tip => console.log(` ${style.bullet} ${tip}`));
|
|
119
|
+
console.log();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/** Prints additional resources and support info. */
|
|
123
|
+
const printFooter = () => {
|
|
124
|
+
console.log(
|
|
125
|
+
style.dim("Need more details? See the project README or documentation.\n"),
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/* ─────────────────────────────
|
|
130
|
+
🚀 HELP ENTRY POINT
|
|
131
|
+
───────────────────────────── */
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Magentrix CLI comprehensive help display.
|
|
135
|
+
*
|
|
136
|
+
* 1. Ensure credentials are configured (to show current environment).
|
|
137
|
+
* 2. Display detailed usage guide, commands, workflow, and best practices.
|
|
138
|
+
*
|
|
139
|
+
* @async
|
|
140
|
+
* @returns {Promise<void>}
|
|
141
|
+
*/
|
|
142
|
+
export const showHelp = async () => {
|
|
143
|
+
const { apiKey, instanceUrl } = await ensureValidCredentials();
|
|
144
|
+
|
|
145
|
+
/* Mask the key except last 4 chars */
|
|
146
|
+
const maskedKey = `****${apiKey.slice(-4)}`;
|
|
147
|
+
|
|
148
|
+
/* Extract hostname from URL—for display only */
|
|
149
|
+
const hostname = (() => {
|
|
150
|
+
try {
|
|
151
|
+
return new URL(instanceUrl).hostname;
|
|
152
|
+
} catch {
|
|
153
|
+
return instanceUrl.replace(/^https?:\/\//, "").split("/")[0];
|
|
154
|
+
}
|
|
155
|
+
})();
|
|
156
|
+
|
|
157
|
+
/* Render comprehensive help sections */
|
|
158
|
+
printHelpHeader(maskedKey, hostname);
|
|
159
|
+
printDescription();
|
|
160
|
+
printWorkflow();
|
|
161
|
+
printFolders();
|
|
162
|
+
printCommands();
|
|
163
|
+
printTips();
|
|
164
|
+
printFooter();
|
|
165
165
|
};
|