@arela/uploader 1.0.4 → 1.0.5

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.
@@ -37,7 +37,7 @@ C:\Users\Docs → C:/Users/Docs (stored) → scan_palco_local_c_users_docs
37
37
  ### cli_registry Table
38
38
  - `company_slug`: Company identifier
39
39
  - `server_id`: Server identifier
40
- - `base_path_full`: Absolute path with forward slashes (`C:/Users/Documents/2023`)
40
+ - `base_path_full`: Absolute path (preserves original format for Windows paths like `O:\expediente\archivos`)
41
41
  - `table_name`: Sanitized version (`scan_palco_local_c_users_documents_2023`)
42
42
  - **Removed**: `base_path_label` (was redundant - same as base_path_full)
43
43
 
@@ -46,18 +46,22 @@ C:\Users\Docs → C:/Users/Docs (stored) → scan_palco_local_c_users_docs
46
46
  - `relative_path`: Relative to base with forward slashes
47
47
  - `absolute_path`: Absolute path with forward slashes
48
48
 
49
- **Note**: All paths stored with forward slashes for consistency, but work on all platforms.
49
+ **Note**: Paths are stored consistently. Windows absolute paths (with drive letters) are preserved when the CLI runs on the same Windows machine or a different OS (macOS/Linux).
50
50
 
51
51
  ## Key Features
52
52
 
53
- ### 1. Cross-Platform Path Normalization
53
+ ### 1. Cross-Platform Path Detection
54
54
 
55
- All paths are normalized to POSIX format (forward slashes) for consistency:
55
+ The CLI correctly identifies Windows absolute paths even when running on macOS/Linux:
56
56
 
57
- - **Windows paths**: `C:\Users\Documents` → `/Users/Documents`
58
- - **Unix paths**: `/home/user/docs` → `/home/user/docs`
59
- - **Relative paths**: `../parent/folder` → `../parent/folder`
60
- - **Network drives**: `O:/data/files` → `/data/files`
57
+ - **Windows paths on any OS**: `O:\expediente\archivos` → recognized as absolute, preserved as-is
58
+ - **Unix paths**: `/home/user/docs` → recognized as absolute, normalized
59
+ - **Relative paths**: `./sample` → resolved against cwd
60
+
61
+ This allows:
62
+ - Running `arela scan` on Windows server → creates table with Windows path in `base_path_full`
63
+ - Running `arela identify` on macOS (for testing) → correctly uses the same Windows path
64
+ - Both resolve to the same table lookup
61
65
 
62
66
  ### 2. Full Path in Table Names
63
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arela/uploader",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "CLI to upload files/directories to Arela",
5
5
  "bin": {
6
6
  "arela": "./src/index.js"
@@ -34,10 +34,10 @@ class Config {
34
34
  const __dirname = path.dirname(__filename);
35
35
  const packageJsonPath = path.resolve(__dirname, '../../package.json');
36
36
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
37
- return packageJson.version || '1.0.4';
37
+ return packageJson.version || '1.0.5';
38
38
  } catch (error) {
39
39
  console.warn('⚠️ Could not read package.json version, using fallback');
40
- return '1.0.4';
40
+ return '1.0.5';
41
41
  }
42
42
  }
43
43
 
@@ -257,11 +257,13 @@ class Config {
257
257
  if (!basePathLabel && process.env.UPLOAD_BASE_PATH) {
258
258
  const basePath = process.env.UPLOAD_BASE_PATH;
259
259
  // Resolve to absolute path (handles ../sample vs ./sample correctly)
260
+ // Note: toAbsolutePath handles Windows paths (O:\...) even on macOS/Linux
260
261
  basePathLabel = PathNormalizer.toAbsolutePath(basePath);
261
262
  }
262
263
 
263
264
  // If basePathLabel is provided, ensure it's absolute
264
- if (basePathLabel && !path.isAbsolute(basePathLabel)) {
265
+ // Use PathNormalizer.isAbsolutePath for cross-platform Windows path detection
266
+ if (basePathLabel && !PathNormalizer.isAbsolutePath(basePathLabel)) {
265
267
  basePathLabel = PathNormalizer.toAbsolutePath(basePathLabel);
266
268
  }
267
269
 
@@ -10,31 +10,83 @@ import { fileURLToPath } from 'url';
10
10
  * 2. Store absolute paths in base_path_full
11
11
  * 3. Normalize ONLY for table name generation (sanitize special chars)
12
12
  * 4. Keep full path structure in table names (hash if too long)
13
+ *
14
+ * Cross-platform support:
15
+ * - Recognizes Windows paths (C:\, D:\, etc.) even when running on macOS/Linux
16
+ * - Preserves Windows paths as-is when detected (for remote server scenarios)
17
+ * - This allows CLI running on macOS to work with paths stored from Windows servers
13
18
  */
14
19
  export class PathNormalizer {
20
+ /**
21
+ * Check if a path is a Windows-style absolute path (has drive letter)
22
+ * This works on any OS, not just Windows
23
+ *
24
+ * Examples:
25
+ * - C:\Users\Documents -> true
26
+ * - O:\expediente\archivos -> true
27
+ * - /home/user/docs -> false
28
+ * - ./relative/path -> false
29
+ *
30
+ * @param {string} inputPath - Path to check
31
+ * @returns {boolean} True if path has a Windows drive letter
32
+ */
33
+ static isWindowsAbsolutePath(inputPath) {
34
+ if (!inputPath || typeof inputPath !== 'string') return false;
35
+ // Match drive letter followed by colon and backslash or forward slash
36
+ // e.g., C:\, D:/, O:\
37
+ return /^[A-Za-z]:[/\\]/.test(inputPath);
38
+ }
39
+
40
+ /**
41
+ * Check if a path is absolute (works cross-platform)
42
+ * Recognizes both Unix and Windows absolute paths regardless of current OS
43
+ *
44
+ * @param {string} inputPath - Path to check
45
+ * @returns {boolean} True if path is absolute (Unix or Windows style)
46
+ */
47
+ static isAbsolutePath(inputPath) {
48
+ if (!inputPath) return false;
49
+ // Check native absolute path first, then Windows-style
50
+ return path.isAbsolute(inputPath) || this.isWindowsAbsolutePath(inputPath);
51
+ }
52
+
15
53
  /**
16
54
  * Resolve a path to an absolute path
17
55
  * This ensures ../sample and ./sample are treated as different paths
18
56
  *
57
+ * Cross-platform behavior:
58
+ * - Windows paths (C:\, O:\, etc.) are preserved as-is, even on macOS/Linux
59
+ * - Unix paths are normalized using native path.resolve
60
+ * - Relative paths are resolved against basePath or cwd
61
+ *
19
62
  * Examples:
20
63
  * - ../sample (from /data/project) -> /data/sample
21
64
  * - ./sample (from /data/project) -> /data/project/sample
22
- * - C:\Users\Documents -> C:\Users\Documents (on Windows)
65
+ * - C:\Users\Documents -> C:\Users\Documents (preserved on any OS)
66
+ * - O:\expediente\archivos -> O:\expediente\archivos (preserved on any OS)
23
67
  * - /home/user/docs -> /home/user/docs (on Unix)
24
68
  *
25
69
  * @param {string} inputPath - Path to resolve
26
70
  * @param {string} basePath - Base path for resolving relative paths (defaults to cwd)
27
- * @returns {string} Absolute path in native OS format
71
+ * @returns {string} Absolute path (native format for Unix, preserved for Windows)
28
72
  */
29
73
  static toAbsolutePath(inputPath, basePath = null) {
30
74
  if (!inputPath) return '';
31
75
 
32
- // If already absolute, return as-is
76
+ // Check for Windows absolute path first (works on any OS)
77
+ // This prevents macOS from treating "O:\path" as relative
78
+ if (this.isWindowsAbsolutePath(inputPath)) {
79
+ // Normalize Windows path but preserve the format
80
+ // Replace forward slashes with backslashes for consistency
81
+ return inputPath.replace(/\//g, '\\');
82
+ }
83
+
84
+ // If native absolute path, return normalized
33
85
  if (path.isAbsolute(inputPath)) {
34
86
  return path.normalize(inputPath);
35
87
  }
36
88
 
37
- // Resolve relative path
89
+ // Resolve relative path against base
38
90
  const base = basePath || process.cwd();
39
91
  return path.resolve(base, inputPath);
40
92
  }