@magentrix-corp/magentrix-cli 1.3.15 → 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 -45
- 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
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import Config from '../config.js';
|
|
4
|
-
import { deleteApp } from '../magentrix/api/iris.js';
|
|
5
|
-
import {
|
|
6
|
-
detectErrorType,
|
|
7
|
-
ErrorTypes,
|
|
8
|
-
formatPermissionError,
|
|
9
|
-
formatFileLockError,
|
|
10
|
-
formatNetworkError
|
|
11
|
-
} from './errors.js';
|
|
12
|
-
|
|
13
|
-
const config = new Config();
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Delete an Iris app from the server and update cache.
|
|
17
|
-
* Does NOT delete local files or create backups - caller handles that.
|
|
18
|
-
*
|
|
19
|
-
* @param {string} instanceUrl - Magentrix instance URL
|
|
20
|
-
* @param {string} token - OAuth token
|
|
21
|
-
* @param {string} slug - App slug (folder name)
|
|
22
|
-
* @param {object} options - Options
|
|
23
|
-
* @param {boolean} options.updateCache - Whether to update base.json (default: true)
|
|
24
|
-
* @returns {Promise<{success: boolean, error: string | null, cleanedFromCache: boolean}>}
|
|
25
|
-
*/
|
|
26
|
-
export async function deleteIrisAppFromServer(instanceUrl, token, slug, options = {}) {
|
|
27
|
-
const { updateCache = true } = options;
|
|
28
|
-
const result = {
|
|
29
|
-
success: false,
|
|
30
|
-
error: null,
|
|
31
|
-
cleanedFromCache: false
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
// Delete from server
|
|
36
|
-
const deleteResult = await deleteApp(instanceUrl, token, slug);
|
|
37
|
-
|
|
38
|
-
if (!deleteResult.success) {
|
|
39
|
-
result.error = deleteResult.message || deleteResult.error || 'Unknown error';
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
result.success = true;
|
|
44
|
-
|
|
45
|
-
// Update cache if requested
|
|
46
|
-
if (updateCache) {
|
|
47
|
-
config.removeKey(`iris-app:${slug}`, { filename: 'base.json' });
|
|
48
|
-
result.cleanedFromCache = true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return result;
|
|
52
|
-
} catch (error) {
|
|
53
|
-
// Check if this is a "not found" error (app already deleted on server)
|
|
54
|
-
const errorMessage = error?.message || String(error);
|
|
55
|
-
const errorLower = errorMessage.toLowerCase();
|
|
56
|
-
const isNotFound = errorLower.includes('404') ||
|
|
57
|
-
errorLower.includes('not found') ||
|
|
58
|
-
errorLower.includes('does not exist');
|
|
59
|
-
|
|
60
|
-
if (isNotFound) {
|
|
61
|
-
// App doesn't exist on server, but clean up local cache anyway
|
|
62
|
-
if (updateCache) {
|
|
63
|
-
try {
|
|
64
|
-
config.removeKey(`iris-app:${slug}`, { filename: 'base.json' });
|
|
65
|
-
result.cleanedFromCache = true;
|
|
66
|
-
} catch {
|
|
67
|
-
// Ignore cache update errors
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
result.success = true;
|
|
71
|
-
result.error = 'App not found on server (already deleted)';
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Check for network errors and provide helpful messages
|
|
76
|
-
if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED' || error.code === 'ETIMEDOUT') {
|
|
77
|
-
result.error = formatNetworkError({
|
|
78
|
-
operation: 'delete app',
|
|
79
|
-
url: instanceUrl,
|
|
80
|
-
error
|
|
81
|
-
});
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
result.error = errorMessage;
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Delete local Iris app files.
|
|
92
|
-
*
|
|
93
|
-
* @param {string} appPath - Absolute path to the app folder
|
|
94
|
-
* @returns {{success: boolean, existed: boolean, error: string | null, isPermissionError: boolean, isFileLocked: boolean}}
|
|
95
|
-
*/
|
|
96
|
-
export function deleteLocalIrisAppFiles(appPath) {
|
|
97
|
-
if (!fs.existsSync(appPath)) {
|
|
98
|
-
return {
|
|
99
|
-
success: true,
|
|
100
|
-
existed: false,
|
|
101
|
-
error: null,
|
|
102
|
-
isPermissionError: false,
|
|
103
|
-
isFileLocked: false
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
try {
|
|
108
|
-
fs.rmSync(appPath, { recursive: true, force: true });
|
|
109
|
-
return {
|
|
110
|
-
success: true,
|
|
111
|
-
existed: true,
|
|
112
|
-
error: null,
|
|
113
|
-
isPermissionError: false,
|
|
114
|
-
isFileLocked: false
|
|
115
|
-
};
|
|
116
|
-
} catch (error) {
|
|
117
|
-
const errorType = detectErrorType(error);
|
|
118
|
-
|
|
119
|
-
if (errorType === ErrorTypes.PERMISSION) {
|
|
120
|
-
return {
|
|
121
|
-
success: false,
|
|
122
|
-
existed: true,
|
|
123
|
-
error: formatPermissionError({
|
|
124
|
-
operation: 'delete files',
|
|
125
|
-
path: appPath
|
|
126
|
-
}),
|
|
127
|
-
isPermissionError: true,
|
|
128
|
-
isFileLocked: false
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (errorType === ErrorTypes.FILE_LOCKED) {
|
|
133
|
-
return {
|
|
134
|
-
success: false,
|
|
135
|
-
existed: true,
|
|
136
|
-
error: formatFileLockError({ path: appPath }),
|
|
137
|
-
isPermissionError: false,
|
|
138
|
-
isFileLocked: true
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
success: false,
|
|
144
|
-
existed: true,
|
|
145
|
-
error: error.message,
|
|
146
|
-
isPermissionError: false,
|
|
147
|
-
isFileLocked: false
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
}
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import Config from '../config.js';
|
|
4
|
+
import { deleteApp } from '../magentrix/api/iris.js';
|
|
5
|
+
import {
|
|
6
|
+
detectErrorType,
|
|
7
|
+
ErrorTypes,
|
|
8
|
+
formatPermissionError,
|
|
9
|
+
formatFileLockError,
|
|
10
|
+
formatNetworkError
|
|
11
|
+
} from './errors.js';
|
|
12
|
+
|
|
13
|
+
const config = new Config();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Delete an Iris app from the server and update cache.
|
|
17
|
+
* Does NOT delete local files or create backups - caller handles that.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} instanceUrl - Magentrix instance URL
|
|
20
|
+
* @param {string} token - OAuth token
|
|
21
|
+
* @param {string} slug - App slug (folder name)
|
|
22
|
+
* @param {object} options - Options
|
|
23
|
+
* @param {boolean} options.updateCache - Whether to update base.json (default: true)
|
|
24
|
+
* @returns {Promise<{success: boolean, error: string | null, cleanedFromCache: boolean}>}
|
|
25
|
+
*/
|
|
26
|
+
export async function deleteIrisAppFromServer(instanceUrl, token, slug, options = {}) {
|
|
27
|
+
const { updateCache = true } = options;
|
|
28
|
+
const result = {
|
|
29
|
+
success: false,
|
|
30
|
+
error: null,
|
|
31
|
+
cleanedFromCache: false
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
// Delete from server
|
|
36
|
+
const deleteResult = await deleteApp(instanceUrl, token, slug);
|
|
37
|
+
|
|
38
|
+
if (!deleteResult.success) {
|
|
39
|
+
result.error = deleteResult.message || deleteResult.error || 'Unknown error';
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
result.success = true;
|
|
44
|
+
|
|
45
|
+
// Update cache if requested
|
|
46
|
+
if (updateCache) {
|
|
47
|
+
config.removeKey(`iris-app:${slug}`, { filename: 'base.json' });
|
|
48
|
+
result.cleanedFromCache = true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
// Check if this is a "not found" error (app already deleted on server)
|
|
54
|
+
const errorMessage = error?.message || String(error);
|
|
55
|
+
const errorLower = errorMessage.toLowerCase();
|
|
56
|
+
const isNotFound = errorLower.includes('404') ||
|
|
57
|
+
errorLower.includes('not found') ||
|
|
58
|
+
errorLower.includes('does not exist');
|
|
59
|
+
|
|
60
|
+
if (isNotFound) {
|
|
61
|
+
// App doesn't exist on server, but clean up local cache anyway
|
|
62
|
+
if (updateCache) {
|
|
63
|
+
try {
|
|
64
|
+
config.removeKey(`iris-app:${slug}`, { filename: 'base.json' });
|
|
65
|
+
result.cleanedFromCache = true;
|
|
66
|
+
} catch {
|
|
67
|
+
// Ignore cache update errors
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
result.success = true;
|
|
71
|
+
result.error = 'App not found on server (already deleted)';
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Check for network errors and provide helpful messages
|
|
76
|
+
if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED' || error.code === 'ETIMEDOUT') {
|
|
77
|
+
result.error = formatNetworkError({
|
|
78
|
+
operation: 'delete app',
|
|
79
|
+
url: instanceUrl,
|
|
80
|
+
error
|
|
81
|
+
});
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
result.error = errorMessage;
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Delete local Iris app files.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} appPath - Absolute path to the app folder
|
|
94
|
+
* @returns {{success: boolean, existed: boolean, error: string | null, isPermissionError: boolean, isFileLocked: boolean}}
|
|
95
|
+
*/
|
|
96
|
+
export function deleteLocalIrisAppFiles(appPath) {
|
|
97
|
+
if (!fs.existsSync(appPath)) {
|
|
98
|
+
return {
|
|
99
|
+
success: true,
|
|
100
|
+
existed: false,
|
|
101
|
+
error: null,
|
|
102
|
+
isPermissionError: false,
|
|
103
|
+
isFileLocked: false
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
fs.rmSync(appPath, { recursive: true, force: true });
|
|
109
|
+
return {
|
|
110
|
+
success: true,
|
|
111
|
+
existed: true,
|
|
112
|
+
error: null,
|
|
113
|
+
isPermissionError: false,
|
|
114
|
+
isFileLocked: false
|
|
115
|
+
};
|
|
116
|
+
} catch (error) {
|
|
117
|
+
const errorType = detectErrorType(error);
|
|
118
|
+
|
|
119
|
+
if (errorType === ErrorTypes.PERMISSION) {
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
existed: true,
|
|
123
|
+
error: formatPermissionError({
|
|
124
|
+
operation: 'delete files',
|
|
125
|
+
path: appPath
|
|
126
|
+
}),
|
|
127
|
+
isPermissionError: true,
|
|
128
|
+
isFileLocked: false
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (errorType === ErrorTypes.FILE_LOCKED) {
|
|
133
|
+
return {
|
|
134
|
+
success: false,
|
|
135
|
+
existed: true,
|
|
136
|
+
error: formatFileLockError({ path: appPath }),
|
|
137
|
+
isPermissionError: false,
|
|
138
|
+
isFileLocked: true
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
success: false,
|
|
144
|
+
existed: true,
|
|
145
|
+
error: error.message,
|
|
146
|
+
isPermissionError: false,
|
|
147
|
+
isFileLocked: false
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|