@magentrix-corp/magentrix-cli 1.3.11 → 1.3.12

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.
@@ -12,6 +12,7 @@ import {
12
12
  EXPORT_ROOT,
13
13
  TYPE_DIR_MAP,
14
14
  IRIS_APPS_DIR,
15
+ ALLOWED_SRC_DIRS,
15
16
  } from "../vars/global.js";
16
17
  import { getFileTag, setFileTag } from "../utils/filetag.js";
17
18
  import { sha256 } from "../utils/hash.js";
@@ -870,16 +871,19 @@ export const runPublish = async (options = {}) => {
870
871
  progress.completeStep('load', `✓ Loaded ${cachedFiles.length} entries (${loadTime}ms load, ${mapTime}ms map)`);
871
872
  }
872
873
 
873
- // Step 3: Scan local workspace (excluding Assets and iris-apps folders)
874
+ // Step 3: Scan local workspace (only whitelisted code entity directories)
874
875
  if (progress) progress.startStep('scan');
875
876
 
876
877
  const walkStart = Date.now();
877
- const localPaths = await walkFiles(EXPORT_ROOT, {
878
- ignore: [
879
- path.join(EXPORT_ROOT, 'Assets'),
880
- path.join(EXPORT_ROOT, IRIS_APPS_DIR)
881
- ]
882
- });
878
+ // Only scan whitelisted directories for code entities (exclude Assets and iris-apps, handled separately)
879
+ const codeEntityDirs = ALLOWED_SRC_DIRS.filter(dir => dir !== 'Assets' && dir !== IRIS_APPS_DIR);
880
+ const localPathArrays = await Promise.all(
881
+ codeEntityDirs.map(dir => {
882
+ const dirPath = path.join(EXPORT_ROOT, dir);
883
+ return fs.existsSync(dirPath) ? walkFiles(dirPath) : Promise.resolve([]);
884
+ })
885
+ );
886
+ const localPaths = localPathArrays.flat();
883
887
  const walkTime = Date.now() - walkStart;
884
888
 
885
889
  const tagStart = Date.now();
package/bin/magentrix.js CHANGED
@@ -20,6 +20,7 @@ import { configWizard } from '../actions/config.js';
20
20
  import { irisLink, irisDev, irisDelete, irisRecover, vueBuildStage } from '../actions/iris/index.js';
21
21
  import Config from '../utils/config.js';
22
22
  import { registerWorkspace, getRegisteredWorkspaces } from '../utils/workspaces.js';
23
+ import { ensureVSCodeFileAssociation } from '../utils/preferences.js';
23
24
 
24
25
  const config = new Config();
25
26
 
@@ -102,6 +103,13 @@ function ensureWorkspaceRegistered() {
102
103
 
103
104
  async function preMiddleware() {
104
105
  ensureWorkspaceRegistered();
106
+
107
+ // Ensure .vscode folder exists in project root (not in src/) for Magentrix projects
108
+ const magentrixDir = join(CWD, '.magentrix');
109
+ if (existsSync(magentrixDir)) {
110
+ await ensureVSCodeFileAssociation(CWD);
111
+ }
112
+
105
113
  await recacheFileIdIndex(EXPORT_ROOT);
106
114
  await cacheDir(EXPORT_ROOT);
107
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magentrix-corp/magentrix-cli",
3
- "version": "1.3.11",
3
+ "version": "1.3.12",
4
4
  "description": "CLI tool for synchronizing local files with Magentrix cloud platform",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/utils/cacher.js CHANGED
@@ -4,7 +4,7 @@ import Config from './config.js';
4
4
  import { findFileByTag, getFileTag, isPathLinkedToTagByLastKnownPath, setFileTag } from './filetag.js';
5
5
  import { compressString } from './compress.js';
6
6
  import { sha256 } from './hash.js';
7
- import { EXPORT_ROOT } from '../vars/global.js';
7
+ import { EXPORT_ROOT, ALLOWED_SRC_DIRS, IRIS_APPS_DIR } from '../vars/global.js';
8
8
 
9
9
  const config = new Config();
10
10
 
@@ -19,8 +19,15 @@ export const cacheDir = async (dir) => {
19
19
 
20
20
  const absDir = path.resolve(dir);
21
21
 
22
- // Walk files but exclude Assets folder (tracked separately in base.json)
23
- const files = await walkFiles(absDir, { ignore: [path.join(absDir, 'Assets')] });
22
+ // Only walk whitelisted code entity directories (exclude Assets and iris-apps, handled separately)
23
+ const codeEntityDirs = ALLOWED_SRC_DIRS.filter(d => d !== 'Assets' && d !== IRIS_APPS_DIR);
24
+ const fileArrays = await Promise.all(
25
+ codeEntityDirs.map(d => {
26
+ const dirPath = path.join(absDir, d);
27
+ return fs.existsSync(dirPath) ? walkFiles(dirPath) : Promise.resolve([]);
28
+ })
29
+ );
30
+ const files = fileArrays.flat();
24
31
 
25
32
  const cache = config.read('cachedFiles', { global: false, filename: 'fileCache.json' }) || {};
26
33
 
@@ -108,10 +115,17 @@ export const cacheDir = async (dir) => {
108
115
  * @returns {Promise<void>}
109
116
  */
110
117
  export const recacheFileIdIndex = async (dir) => {
111
- // Exclude Assets folder - they don't use file tags, tracked in base.json instead
112
118
  const absDir = path.resolve(dir);
113
- const ignorePath = path.join(absDir, 'Assets');
114
- const files = await walkFiles(absDir, { ignore: [ignorePath] });
119
+
120
+ // Only walk whitelisted code entity directories (exclude Assets and iris-apps, handled separately)
121
+ const codeEntityDirs = ALLOWED_SRC_DIRS.filter(d => d !== 'Assets' && d !== IRIS_APPS_DIR);
122
+ const fileArrays = await Promise.all(
123
+ codeEntityDirs.map(d => {
124
+ const dirPath = path.join(absDir, d);
125
+ return fs.existsSync(dirPath) ? walkFiles(dirPath) : Promise.resolve([]);
126
+ })
127
+ );
128
+ const files = fileArrays.flat();
115
129
  if (!files || files?.length < 1) return;
116
130
 
117
131
  // Process files in parallel batches of 50 for speed
@@ -245,7 +245,7 @@ export const writeRecords = async (records, resolutionMethod, progress = null, l
245
245
  updateBase(filePath, record, cachedFilePath);
246
246
  }
247
247
  } catch (err) {
248
- const msg = `Failed to write file ${cachedFilePath}: ${err.message}`;
248
+ const msg = `Failed to write file ${filePath}: ${err.message}`;
249
249
  if (logger) {
250
250
  logger.error(msg, err);
251
251
  } else {
package/vars/global.js CHANGED
@@ -6,6 +6,22 @@ export const EXPORT_ROOT = "src";
6
6
  export const ASSETS_DIR = "Assets"; // Local directory name for static assets (API uses /contents/assets)
7
7
  export const IRIS_APPS_DIR = "iris-apps"; // Local directory for Iris Vue.js apps
8
8
 
9
+ /**
10
+ * Whitelist of allowed directories inside EXPORT_ROOT.
11
+ * Only these folders will be scanned during publish/cache operations.
12
+ * This prevents accidental processing of hidden folders (.magentrix, .vscode, etc.)
13
+ * or any other unexpected directories users might create.
14
+ */
15
+ export const ALLOWED_SRC_DIRS = [
16
+ "Assets",
17
+ "Classes",
18
+ "Controllers",
19
+ "iris-apps",
20
+ "Pages",
21
+ "Templates",
22
+ "Triggers"
23
+ ];
24
+
9
25
  /**
10
26
  * Maps Magentrix Type fields to local folder names and extensions.
11
27
  * Extensions chosen to avoid collisions and clearly indicate type.