@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/filetag.js
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import Config from './config.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const platform = os.platform();
|
|
8
|
-
const config = new Config(); // uses default project config
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Generates a unique key from a file's stat object
|
|
12
|
-
* @param {fs.Stats} stats
|
|
13
|
-
* @returns {string}
|
|
14
|
-
*/
|
|
15
|
-
function getFileKey(stats) {
|
|
16
|
-
return `${stats.dev}:${stats.ino}`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Tags a file with a persistent ID using platform-specific methods and stores it via Config.
|
|
21
|
-
*
|
|
22
|
-
* @param {string} filePath - Path to the file.
|
|
23
|
-
* @param {string} tag - Tag to assign.
|
|
24
|
-
* @returns {Promise<void>}
|
|
25
|
-
*/
|
|
26
|
-
export async function setFileTag(filePath, tag) {
|
|
27
|
-
const absPath = path.resolve(filePath);
|
|
28
|
-
const stats = fs.statSync(absPath);
|
|
29
|
-
const key = getFileKey(stats);
|
|
30
|
-
|
|
31
|
-
// Try platform tagging
|
|
32
|
-
try {
|
|
33
|
-
if (platform === 'darwin' || platform === 'linux') {
|
|
34
|
-
const xattr = await import('xattr');
|
|
35
|
-
await xattr.set(absPath, 'user.fileTag', Buffer.from(tag));
|
|
36
|
-
} else if (platform === 'win32') {
|
|
37
|
-
const streamPath = `${absPath}:fileTag`;
|
|
38
|
-
fs.writeFileSync(streamPath, tag);
|
|
39
|
-
}
|
|
40
|
-
} catch {
|
|
41
|
-
// xattr/ADS is optional; we fall back to config
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const tracked = config.read('trackedFileTags', { global: false, filename: 'fileIdIndex.json' }) || {};
|
|
45
|
-
tracked[key] = { tag, lastKnownPath: absPath };
|
|
46
|
-
config.save('trackedFileTags', tracked, { global: false, filename: 'fileIdIndex.json' });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Retrieves a file tag from metadata or Config, even after renames.
|
|
51
|
-
*
|
|
52
|
-
* @param {string} filePath - Current path to the file.
|
|
53
|
-
* @returns {Promise<string|null>}
|
|
54
|
-
*/
|
|
55
|
-
export async function getFileTag(filePath) {
|
|
56
|
-
const absPath = path.resolve(filePath);
|
|
57
|
-
let stats;
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
stats = fs.statSync(absPath);
|
|
61
|
-
} catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const key = getFileKey(stats);
|
|
66
|
-
const tracked = config.read('trackedFileTags', { global: false, filename: 'fileIdIndex.json' }) || {};
|
|
67
|
-
|
|
68
|
-
// Try platform method first
|
|
69
|
-
try {
|
|
70
|
-
if (platform === 'darwin' || platform === 'linux') {
|
|
71
|
-
const xattr = await import('xattr');
|
|
72
|
-
const buf = await xattr.get(absPath, 'user.fileTag');
|
|
73
|
-
return buf.toString();
|
|
74
|
-
} else if (platform === 'win32') {
|
|
75
|
-
const streamPath = `${absPath}:fileTag`;
|
|
76
|
-
return fs.readFileSync(streamPath, 'utf8');
|
|
77
|
-
}
|
|
78
|
-
} catch {
|
|
79
|
-
// fallback below
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return tracked[key]?.tag ?? null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Retrieves a file path from its tag.
|
|
87
|
-
*
|
|
88
|
-
* @param {string} tag - The file tag.
|
|
89
|
-
* @returns {Promise<string|null>}
|
|
90
|
-
*/
|
|
91
|
-
export function findFileByTag(tag) {
|
|
92
|
-
const tracked = config.read('trackedFileTags', { global: false, filename: 'fileIdIndex.json' }) || {};
|
|
93
|
-
for (const record of Object.values(tracked)) {
|
|
94
|
-
if (record.tag === tag) return record.lastKnownPath;
|
|
95
|
-
}
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Checks if the given file path is tracked in fileIdIndex.json as a lastKnownPath.
|
|
101
|
-
* Returns the tag if found, or null if not linked.
|
|
102
|
-
*
|
|
103
|
-
* @param {string} filePath - Path to check.
|
|
104
|
-
* @returns {string|null} The tag if the path is tracked, otherwise null.
|
|
105
|
-
*/
|
|
106
|
-
export function isPathLinkedToTagByLastKnownPath(filePath) {
|
|
107
|
-
const absPath = path.resolve(filePath);
|
|
108
|
-
const tracked = config.read('trackedFileTags', { global: false, filename: 'fileIdIndex.json' }) || {};
|
|
109
|
-
for (const record of Object.values(tracked)) {
|
|
110
|
-
if (record.lastKnownPath === absPath) {
|
|
111
|
-
return record.tag;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import Config from './config.js';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const platform = os.platform();
|
|
8
|
+
const config = new Config(); // uses default project config
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generates a unique key from a file's stat object
|
|
12
|
+
* @param {fs.Stats} stats
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
function getFileKey(stats) {
|
|
16
|
+
return `${stats.dev}:${stats.ino}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Tags a file with a persistent ID using platform-specific methods and stores it via Config.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} filePath - Path to the file.
|
|
23
|
+
* @param {string} tag - Tag to assign.
|
|
24
|
+
* @returns {Promise<void>}
|
|
25
|
+
*/
|
|
26
|
+
export async function setFileTag(filePath, tag) {
|
|
27
|
+
const absPath = path.resolve(filePath);
|
|
28
|
+
const stats = fs.statSync(absPath);
|
|
29
|
+
const key = getFileKey(stats);
|
|
30
|
+
|
|
31
|
+
// Try platform tagging
|
|
32
|
+
try {
|
|
33
|
+
if (platform === 'darwin' || platform === 'linux') {
|
|
34
|
+
const xattr = await import('xattr');
|
|
35
|
+
await xattr.set(absPath, 'user.fileTag', Buffer.from(tag));
|
|
36
|
+
} else if (platform === 'win32') {
|
|
37
|
+
const streamPath = `${absPath}:fileTag`;
|
|
38
|
+
fs.writeFileSync(streamPath, tag);
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
// xattr/ADS is optional; we fall back to config
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const tracked = config.read('trackedFileTags', { global: false, filename: 'fileIdIndex.json' }) || {};
|
|
45
|
+
tracked[key] = { tag, lastKnownPath: absPath };
|
|
46
|
+
config.save('trackedFileTags', tracked, { global: false, filename: 'fileIdIndex.json' });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves a file tag from metadata or Config, even after renames.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} filePath - Current path to the file.
|
|
53
|
+
* @returns {Promise<string|null>}
|
|
54
|
+
*/
|
|
55
|
+
export async function getFileTag(filePath) {
|
|
56
|
+
const absPath = path.resolve(filePath);
|
|
57
|
+
let stats;
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
stats = fs.statSync(absPath);
|
|
61
|
+
} catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const key = getFileKey(stats);
|
|
66
|
+
const tracked = config.read('trackedFileTags', { global: false, filename: 'fileIdIndex.json' }) || {};
|
|
67
|
+
|
|
68
|
+
// Try platform method first
|
|
69
|
+
try {
|
|
70
|
+
if (platform === 'darwin' || platform === 'linux') {
|
|
71
|
+
const xattr = await import('xattr');
|
|
72
|
+
const buf = await xattr.get(absPath, 'user.fileTag');
|
|
73
|
+
return buf.toString();
|
|
74
|
+
} else if (platform === 'win32') {
|
|
75
|
+
const streamPath = `${absPath}:fileTag`;
|
|
76
|
+
return fs.readFileSync(streamPath, 'utf8');
|
|
77
|
+
}
|
|
78
|
+
} catch {
|
|
79
|
+
// fallback below
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return tracked[key]?.tag ?? null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Retrieves a file path from its tag.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} tag - The file tag.
|
|
89
|
+
* @returns {Promise<string|null>}
|
|
90
|
+
*/
|
|
91
|
+
export function findFileByTag(tag) {
|
|
92
|
+
const tracked = config.read('trackedFileTags', { global: false, filename: 'fileIdIndex.json' }) || {};
|
|
93
|
+
for (const record of Object.values(tracked)) {
|
|
94
|
+
if (record.tag === tag) return record.lastKnownPath;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Checks if the given file path is tracked in fileIdIndex.json as a lastKnownPath.
|
|
101
|
+
* Returns the tag if found, or null if not linked.
|
|
102
|
+
*
|
|
103
|
+
* @param {string} filePath - Path to check.
|
|
104
|
+
* @returns {string|null} The tag if the path is tracked, otherwise null.
|
|
105
|
+
*/
|
|
106
|
+
export function isPathLinkedToTagByLastKnownPath(filePath) {
|
|
107
|
+
const absPath = path.resolve(filePath);
|
|
108
|
+
const tracked = config.read('trackedFileTags', { global: false, filename: 'fileIdIndex.json' }) || {};
|
|
109
|
+
for (const record of Object.values(tracked)) {
|
|
110
|
+
if (record.lastKnownPath === absPath) {
|
|
111
|
+
return record.tag;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
package/utils/hash.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Hash any data to a lowercase hex SHA-256 string.
|
|
5
|
-
* @param {string|Buffer} input
|
|
6
|
-
* @returns {string}
|
|
7
|
-
*/
|
|
8
|
-
export function sha256(input) {
|
|
9
|
-
return crypto.createHash('sha256').update(input).digest('hex');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// --- Usage Example ---
|
|
13
|
-
// import sha256 from './lib/sha256.js';
|
|
14
|
-
// const hash = sha256('some string to hash');
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hash any data to a lowercase hex SHA-256 string.
|
|
5
|
+
* @param {string|Buffer} input
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export function sha256(input) {
|
|
9
|
+
return crypto.createHash('sha256').update(input).digest('hex');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// --- Usage Example ---
|
|
13
|
+
// import sha256 from './lib/sha256.js';
|
|
14
|
+
// const hash = sha256('some string to hash');
|