@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/utils/merge.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import * as diff3 from 'node-diff3'; // ESM import all
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Merges local and remote file contents with a common ancestor (base),
|
|
5
|
-
* returning the merged result and whether there was a conflict.
|
|
6
|
-
*
|
|
7
|
-
* @param {string} baseContent - The last synced (common ancestor) file content.
|
|
8
|
-
* @param {string} localContent - The current local file content.
|
|
9
|
-
* @param {string} remoteContent - The remote/server file content.
|
|
10
|
-
* @returns {{ mergedText: string, hasConflict: boolean }}
|
|
11
|
-
*/
|
|
12
|
-
export function mergeFiles(baseContent, localContent, remoteContent) {
|
|
13
|
-
const baseLines = baseContent.split('\n');
|
|
14
|
-
const localLines = localContent.split('\n');
|
|
15
|
-
const remoteLines = remoteContent.split('\n');
|
|
16
|
-
|
|
17
|
-
const result = diff3.merge(localLines, baseLines, remoteLines);
|
|
18
|
-
const mergedText = result.result.join('\n');
|
|
19
|
-
|
|
20
|
-
// Do NOT throw. Just return the merge, which will have conflict markers if unresolved.
|
|
21
|
-
return mergedText;
|
|
22
|
-
}
|
|
1
|
+
import * as diff3 from 'node-diff3'; // ESM import all
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merges local and remote file contents with a common ancestor (base),
|
|
5
|
+
* returning the merged result and whether there was a conflict.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} baseContent - The last synced (common ancestor) file content.
|
|
8
|
+
* @param {string} localContent - The current local file content.
|
|
9
|
+
* @param {string} remoteContent - The remote/server file content.
|
|
10
|
+
* @returns {{ mergedText: string, hasConflict: boolean }}
|
|
11
|
+
*/
|
|
12
|
+
export function mergeFiles(baseContent, localContent, remoteContent) {
|
|
13
|
+
const baseLines = baseContent.split('\n');
|
|
14
|
+
const localLines = localContent.split('\n');
|
|
15
|
+
const remoteLines = remoteContent.split('\n');
|
|
16
|
+
|
|
17
|
+
const result = diff3.merge(localLines, baseLines, remoteLines);
|
|
18
|
+
const mergedText = result.result.join('\n');
|
|
19
|
+
|
|
20
|
+
// Do NOT throw. Just return the merge, which will have conflict markers if unresolved.
|
|
21
|
+
return mergedText;
|
|
22
|
+
}
|
package/utils/permissionError.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import os from 'os';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Display a user-friendly permission error message with platform-specific guidance.
|
|
6
|
-
*
|
|
7
|
-
* @param {object} options - Options for the error message
|
|
8
|
-
* @param {string} options.operation - What operation failed ('delete' or 'restore')
|
|
9
|
-
* @param {string} options.targetPath - The path that couldn't be accessed
|
|
10
|
-
* @param {string} [options.backupPath] - Optional backup path (for restore operations)
|
|
11
|
-
* @param {string} [options.slug] - Optional app slug (for restore operations)
|
|
12
|
-
*/
|
|
13
|
-
export function showPermissionError({ operation, targetPath, backupPath, slug }) {
|
|
14
|
-
const platform = os.platform();
|
|
15
|
-
const username = os.userInfo().username;
|
|
16
|
-
const group = platform === 'darwin' ? 'staff' : username;
|
|
17
|
-
|
|
18
|
-
console.log();
|
|
19
|
-
console.log(chalk.bgYellow.bold.black(' ⚠ Permission Denied '));
|
|
20
|
-
console.log(chalk.yellow('─'.repeat(48)));
|
|
21
|
-
console.log(chalk.white(`Cannot ${operation} files due to permission issues.`));
|
|
22
|
-
console.log();
|
|
23
|
-
console.log(chalk.white('This may happen if:'));
|
|
24
|
-
console.log(chalk.gray(' • A process has the folder locked'));
|
|
25
|
-
console.log(chalk.gray(' • The folder is owned by another user (e.g., root)'));
|
|
26
|
-
if (platform === 'darwin') {
|
|
27
|
-
console.log(chalk.gray(' • macOS Gatekeeper is blocking the operation'));
|
|
28
|
-
}
|
|
29
|
-
console.log();
|
|
30
|
-
console.log(chalk.white('To fix this, try:'));
|
|
31
|
-
console.log(chalk.cyan(' 1. Close any editors that have the folder open'));
|
|
32
|
-
console.log(chalk.cyan(' 2. Run the command again'));
|
|
33
|
-
console.log();
|
|
34
|
-
|
|
35
|
-
// Platform-specific ownership fix
|
|
36
|
-
if (platform === 'win32') {
|
|
37
|
-
console.log(chalk.white('If the folder has wrong ownership, run as Administrator:'));
|
|
38
|
-
console.log(chalk.cyan(` icacls "${targetPath}" /grant ${username}:F /T`));
|
|
39
|
-
} else {
|
|
40
|
-
console.log(chalk.white('If the folder has wrong ownership, run:'));
|
|
41
|
-
console.log(chalk.cyan(` sudo chown -R ${username}:${group} "${targetPath}"`));
|
|
42
|
-
}
|
|
43
|
-
console.log();
|
|
44
|
-
|
|
45
|
-
// Operation-specific manual commands
|
|
46
|
-
if (operation === 'delete') {
|
|
47
|
-
console.log(chalk.white('Or delete manually:'));
|
|
48
|
-
if (platform === 'win32') {
|
|
49
|
-
console.log(chalk.cyan(` rmdir /s /q "${targetPath}"`));
|
|
50
|
-
} else {
|
|
51
|
-
console.log(chalk.cyan(` rm -rf "${targetPath}"`));
|
|
52
|
-
}
|
|
53
|
-
} else if (operation === 'restore' && backupPath && slug) {
|
|
54
|
-
console.log(chalk.white('Or manually restore:'));
|
|
55
|
-
const zipPath = `${backupPath}/${slug}.zip`;
|
|
56
|
-
const destDir = targetPath.replace(/[/\\][^/\\]+$/, ''); // Parent directory
|
|
57
|
-
if (platform === 'win32') {
|
|
58
|
-
console.log(chalk.cyan(` tar -xf "${zipPath}" -C "${destDir}"`));
|
|
59
|
-
} else {
|
|
60
|
-
console.log(chalk.cyan(` unzip "${zipPath}" -d "${destDir}"`));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.log(chalk.yellow('─'.repeat(48)));
|
|
65
|
-
|
|
66
|
-
if (backupPath) {
|
|
67
|
-
console.log();
|
|
68
|
-
console.log(chalk.gray(`Backup preserved at: ${backupPath}`));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Display a user-friendly permission error message with platform-specific guidance.
|
|
6
|
+
*
|
|
7
|
+
* @param {object} options - Options for the error message
|
|
8
|
+
* @param {string} options.operation - What operation failed ('delete' or 'restore')
|
|
9
|
+
* @param {string} options.targetPath - The path that couldn't be accessed
|
|
10
|
+
* @param {string} [options.backupPath] - Optional backup path (for restore operations)
|
|
11
|
+
* @param {string} [options.slug] - Optional app slug (for restore operations)
|
|
12
|
+
*/
|
|
13
|
+
export function showPermissionError({ operation, targetPath, backupPath, slug }) {
|
|
14
|
+
const platform = os.platform();
|
|
15
|
+
const username = os.userInfo().username;
|
|
16
|
+
const group = platform === 'darwin' ? 'staff' : username;
|
|
17
|
+
|
|
18
|
+
console.log();
|
|
19
|
+
console.log(chalk.bgYellow.bold.black(' ⚠ Permission Denied '));
|
|
20
|
+
console.log(chalk.yellow('─'.repeat(48)));
|
|
21
|
+
console.log(chalk.white(`Cannot ${operation} files due to permission issues.`));
|
|
22
|
+
console.log();
|
|
23
|
+
console.log(chalk.white('This may happen if:'));
|
|
24
|
+
console.log(chalk.gray(' • A process has the folder locked'));
|
|
25
|
+
console.log(chalk.gray(' • The folder is owned by another user (e.g., root)'));
|
|
26
|
+
if (platform === 'darwin') {
|
|
27
|
+
console.log(chalk.gray(' • macOS Gatekeeper is blocking the operation'));
|
|
28
|
+
}
|
|
29
|
+
console.log();
|
|
30
|
+
console.log(chalk.white('To fix this, try:'));
|
|
31
|
+
console.log(chalk.cyan(' 1. Close any editors that have the folder open'));
|
|
32
|
+
console.log(chalk.cyan(' 2. Run the command again'));
|
|
33
|
+
console.log();
|
|
34
|
+
|
|
35
|
+
// Platform-specific ownership fix
|
|
36
|
+
if (platform === 'win32') {
|
|
37
|
+
console.log(chalk.white('If the folder has wrong ownership, run as Administrator:'));
|
|
38
|
+
console.log(chalk.cyan(` icacls "${targetPath}" /grant ${username}:F /T`));
|
|
39
|
+
} else {
|
|
40
|
+
console.log(chalk.white('If the folder has wrong ownership, run:'));
|
|
41
|
+
console.log(chalk.cyan(` sudo chown -R ${username}:${group} "${targetPath}"`));
|
|
42
|
+
}
|
|
43
|
+
console.log();
|
|
44
|
+
|
|
45
|
+
// Operation-specific manual commands
|
|
46
|
+
if (operation === 'delete') {
|
|
47
|
+
console.log(chalk.white('Or delete manually:'));
|
|
48
|
+
if (platform === 'win32') {
|
|
49
|
+
console.log(chalk.cyan(` rmdir /s /q "${targetPath}"`));
|
|
50
|
+
} else {
|
|
51
|
+
console.log(chalk.cyan(` rm -rf "${targetPath}"`));
|
|
52
|
+
}
|
|
53
|
+
} else if (operation === 'restore' && backupPath && slug) {
|
|
54
|
+
console.log(chalk.white('Or manually restore:'));
|
|
55
|
+
const zipPath = `${backupPath}/${slug}.zip`;
|
|
56
|
+
const destDir = targetPath.replace(/[/\\][^/\\]+$/, ''); // Parent directory
|
|
57
|
+
if (platform === 'win32') {
|
|
58
|
+
console.log(chalk.cyan(` tar -xf "${zipPath}" -C "${destDir}"`));
|
|
59
|
+
} else {
|
|
60
|
+
console.log(chalk.cyan(` unzip "${zipPath}" -d "${destDir}"`));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log(chalk.yellow('─'.repeat(48)));
|
|
65
|
+
|
|
66
|
+
if (backupPath) {
|
|
67
|
+
console.log();
|
|
68
|
+
console.log(chalk.gray(`Backup preserved at: ${backupPath}`));
|
|
69
|
+
}
|
|
70
|
+
}
|
package/utils/preferences.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Ensures that the .vscode/settings.json file exists in the project root and
|
|
6
|
-
* updates it to associate `.xyz` files with C# syntax highlighting in VS Code.
|
|
7
|
-
* If the file or directory doesn't exist, it will be created. Existing settings
|
|
8
|
-
* are preserved and merged.
|
|
9
|
-
*
|
|
10
|
-
* @async
|
|
11
|
-
* @function ensureVSCodeFileAssociation
|
|
12
|
-
* @param {string} projectRoot - The absolute path to the project root where the `.vscode` folder resides.
|
|
13
|
-
* @returns {Promise<void>} Resolves once the settings file is updated or created.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* await ensureVSCodeFileAssociation(process.cwd());
|
|
17
|
-
*/
|
|
18
|
-
export async function ensureVSCodeFileAssociation(projectRoot) {
|
|
19
|
-
const vscodeDir = path.join(projectRoot, '.vscode');
|
|
20
|
-
const settingsPath = path.join(vscodeDir, 'settings.json');
|
|
21
|
-
|
|
22
|
-
await fs.mkdir(vscodeDir, { recursive: true });
|
|
23
|
-
|
|
24
|
-
let settings = {};
|
|
25
|
-
try {
|
|
26
|
-
const raw = await fs.readFile(settingsPath, 'utf-8');
|
|
27
|
-
settings = JSON.parse(raw);
|
|
28
|
-
} catch (err) {
|
|
29
|
-
// Ignore error if file doesn't exist or is invalid JSON
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
settings['files.associations'] = {
|
|
33
|
-
...settings['files.associations'],
|
|
34
|
-
'*.ac': 'csharp',
|
|
35
|
-
'*.trigger': 'csharp',
|
|
36
|
-
'*.ctrl': 'csharp'
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
await fs.writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
40
|
-
}
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Ensures that the .vscode/settings.json file exists in the project root and
|
|
6
|
+
* updates it to associate `.xyz` files with C# syntax highlighting in VS Code.
|
|
7
|
+
* If the file or directory doesn't exist, it will be created. Existing settings
|
|
8
|
+
* are preserved and merged.
|
|
9
|
+
*
|
|
10
|
+
* @async
|
|
11
|
+
* @function ensureVSCodeFileAssociation
|
|
12
|
+
* @param {string} projectRoot - The absolute path to the project root where the `.vscode` folder resides.
|
|
13
|
+
* @returns {Promise<void>} Resolves once the settings file is updated or created.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* await ensureVSCodeFileAssociation(process.cwd());
|
|
17
|
+
*/
|
|
18
|
+
export async function ensureVSCodeFileAssociation(projectRoot) {
|
|
19
|
+
const vscodeDir = path.join(projectRoot, '.vscode');
|
|
20
|
+
const settingsPath = path.join(vscodeDir, 'settings.json');
|
|
21
|
+
|
|
22
|
+
await fs.mkdir(vscodeDir, { recursive: true });
|
|
23
|
+
|
|
24
|
+
let settings = {};
|
|
25
|
+
try {
|
|
26
|
+
const raw = await fs.readFile(settingsPath, 'utf-8');
|
|
27
|
+
settings = JSON.parse(raw);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
// Ignore error if file doesn't exist or is invalid JSON
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
settings['files.associations'] = {
|
|
33
|
+
...settings['files.associations'],
|
|
34
|
+
'*.ac': 'csharp',
|
|
35
|
+
'*.trigger': 'csharp',
|
|
36
|
+
'*.ctrl': 'csharp'
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
await fs.writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
40
|
+
}
|