@robinpath/cli 1.73.0 → 1.75.0
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/README.md +111 -111
- package/dist/cli.mjs +344 -301
- package/modules/_helpers.js +33 -33
- package/modules/assert.js +270 -270
- package/modules/buffer.js +245 -245
- package/modules/child.js +176 -176
- package/modules/crypto.js +352 -352
- package/modules/dns.js +146 -146
- package/modules/events.js +174 -174
- package/modules/file.js +361 -361
- package/modules/http.js +268 -268
- package/modules/index.js +76 -76
- package/modules/net.js +189 -189
- package/modules/os.js +219 -219
- package/modules/path.js +162 -162
- package/modules/process.js +214 -214
- package/modules/stream.js +322 -322
- package/modules/string_decoder.js +106 -106
- package/modules/timer.js +167 -167
- package/modules/tls.js +264 -264
- package/modules/tty.js +169 -169
- package/modules/url.js +189 -189
- package/modules/util.js +275 -275
- package/modules/zlib.js +126 -126
- package/package.json +1 -1
package/modules/path.js
CHANGED
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Native path module for RobinPath.
|
|
3
|
-
* Wraps Node.js path operations.
|
|
4
|
-
*/
|
|
5
|
-
import { join, resolve, dirname, basename, extname, parse, format, relative, normalize, isAbsolute, sep, delimiter, posix, win32 } from 'node:path';
|
|
6
|
-
import { toStr, requireArgs } from './_helpers.js';
|
|
7
|
-
|
|
8
|
-
export const PathFunctions = {
|
|
9
|
-
|
|
10
|
-
join: (args) => {
|
|
11
|
-
return join(...args.map(a => toStr(a)));
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
resolve: (args) => {
|
|
15
|
-
return resolve(...args.map(a => toStr(a)));
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
dirname: (args) => {
|
|
19
|
-
requireArgs('path.dirname', args, 1);
|
|
20
|
-
return dirname(toStr(args[0]));
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
basename: (args) => {
|
|
24
|
-
requireArgs('path.basename', args, 1);
|
|
25
|
-
const ext = args[1] != null ? toStr(args[1]) : undefined;
|
|
26
|
-
return basename(toStr(args[0]), ext);
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
extname: (args) => {
|
|
30
|
-
requireArgs('path.extname', args, 1);
|
|
31
|
-
return extname(toStr(args[0]));
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
parse: (args) => {
|
|
35
|
-
requireArgs('path.parse', args, 1);
|
|
36
|
-
return parse(toStr(args[0]));
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
format: (args) => {
|
|
40
|
-
requireArgs('path.format', args, 1);
|
|
41
|
-
const obj = args[0];
|
|
42
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
43
|
-
throw new Error('path.format requires an object with root/dir/base/name/ext');
|
|
44
|
-
}
|
|
45
|
-
return format(obj);
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
relative: (args) => {
|
|
49
|
-
requireArgs('path.relative', args, 2);
|
|
50
|
-
return relative(toStr(args[0]), toStr(args[1]));
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
normalize: (args) => {
|
|
54
|
-
requireArgs('path.normalize', args, 1);
|
|
55
|
-
return normalize(toStr(args[0]));
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
isAbsolute: (args) => {
|
|
59
|
-
requireArgs('path.isAbsolute', args, 1);
|
|
60
|
-
return isAbsolute(toStr(args[0]));
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
sep: () => sep,
|
|
64
|
-
|
|
65
|
-
delimiter: () => delimiter,
|
|
66
|
-
|
|
67
|
-
toNamespacedPath: (args) => {
|
|
68
|
-
requireArgs('path.toNamespacedPath', args, 1);
|
|
69
|
-
// On Windows, converts to \\?\ prefix; on POSIX, returns unchanged
|
|
70
|
-
if (process.platform === 'win32') {
|
|
71
|
-
return '\\\\?\\' + resolve(toStr(args[0]));
|
|
72
|
-
}
|
|
73
|
-
return resolve(toStr(args[0]));
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const PathFunctionMetadata = {
|
|
78
|
-
join: {
|
|
79
|
-
description: 'Join path segments together',
|
|
80
|
-
parameters: [{ name: 'segments', dataType: 'string', description: 'Path segments', formInputType: 'text', required: true }],
|
|
81
|
-
returnType: 'string', returnDescription: 'Joined path', example: 'path.join "src" "modules" "test.js"'
|
|
82
|
-
},
|
|
83
|
-
resolve: {
|
|
84
|
-
description: 'Resolve path segments to an absolute path',
|
|
85
|
-
parameters: [{ name: 'segments', dataType: 'string', description: 'Path segments', formInputType: 'text', required: true }],
|
|
86
|
-
returnType: 'string', returnDescription: 'Absolute path', example: 'path.resolve "src" "file.js"'
|
|
87
|
-
},
|
|
88
|
-
dirname: {
|
|
89
|
-
description: 'Get directory name of a path',
|
|
90
|
-
parameters: [{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true }],
|
|
91
|
-
returnType: 'string', returnDescription: 'Directory name', example: 'path.dirname "/home/user/file.txt"'
|
|
92
|
-
},
|
|
93
|
-
basename: {
|
|
94
|
-
description: 'Get the last portion of a path',
|
|
95
|
-
parameters: [
|
|
96
|
-
{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true },
|
|
97
|
-
{ name: 'ext', dataType: 'string', description: 'Extension to strip', formInputType: 'text', required: false }
|
|
98
|
-
],
|
|
99
|
-
returnType: 'string', returnDescription: 'Base name', example: 'path.basename "/home/user/file.txt"'
|
|
100
|
-
},
|
|
101
|
-
extname: {
|
|
102
|
-
description: 'Get file extension',
|
|
103
|
-
parameters: [{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true }],
|
|
104
|
-
returnType: 'string', returnDescription: 'Extension (e.g. ".txt")', example: 'path.extname "file.txt"'
|
|
105
|
-
},
|
|
106
|
-
parse: {
|
|
107
|
-
description: 'Parse a path into components',
|
|
108
|
-
parameters: [{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true }],
|
|
109
|
-
returnType: 'object', returnDescription: 'Object with root, dir, base, name, ext', example: 'path.parse "/home/user/file.txt"'
|
|
110
|
-
},
|
|
111
|
-
format: {
|
|
112
|
-
description: 'Format a path object into a string',
|
|
113
|
-
parameters: [{ name: 'pathObject', dataType: 'object', description: 'Object with root/dir/base/name/ext', formInputType: 'json', required: true }],
|
|
114
|
-
returnType: 'string', returnDescription: 'Formatted path string', example: 'path.format $obj'
|
|
115
|
-
},
|
|
116
|
-
relative: {
|
|
117
|
-
description: 'Get relative path from one path to another',
|
|
118
|
-
parameters: [
|
|
119
|
-
{ name: 'from', dataType: 'string', description: 'Base path', formInputType: 'text', required: true },
|
|
120
|
-
{ name: 'to', dataType: 'string', description: 'Target path', formInputType: 'text', required: true }
|
|
121
|
-
],
|
|
122
|
-
returnType: 'string', returnDescription: 'Relative path', example: 'path.relative "/home" "/home/user/file.txt"'
|
|
123
|
-
},
|
|
124
|
-
normalize: {
|
|
125
|
-
description: 'Normalize a path (resolve . and ..)',
|
|
126
|
-
parameters: [{ name: 'path', dataType: 'string', description: 'Path to normalize', formInputType: 'text', required: true }],
|
|
127
|
-
returnType: 'string', returnDescription: 'Normalized path', example: 'path.normalize "/home/user/../file.txt"'
|
|
128
|
-
},
|
|
129
|
-
isAbsolute: {
|
|
130
|
-
description: 'Check if a path is absolute',
|
|
131
|
-
parameters: [{ name: 'path', dataType: 'string', description: 'Path to check', formInputType: 'text', required: true }],
|
|
132
|
-
returnType: 'boolean', returnDescription: 'true if absolute', example: 'path.isAbsolute "/home/user"'
|
|
133
|
-
},
|
|
134
|
-
sep: {
|
|
135
|
-
description: 'Get the platform-specific path separator',
|
|
136
|
-
parameters: [],
|
|
137
|
-
returnType: 'string', returnDescription: 'Path separator (/ or \\)', example: 'path.sep'
|
|
138
|
-
},
|
|
139
|
-
delimiter: {
|
|
140
|
-
description: 'Get the platform-specific path delimiter',
|
|
141
|
-
parameters: [],
|
|
142
|
-
returnType: 'string', returnDescription: 'Path delimiter (: or ;)', example: 'path.delimiter'
|
|
143
|
-
},
|
|
144
|
-
toNamespacedPath: {
|
|
145
|
-
description: 'Convert to namespaced path (Windows \\\\?\\ prefix)',
|
|
146
|
-
parameters: [{ name: 'path', dataType: 'string', description: 'Path to convert', formInputType: 'text', required: true }],
|
|
147
|
-
returnType: 'string', returnDescription: 'Namespaced path', example: 'path.toNamespacedPath "C:\\Users"'
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export const PathModuleMetadata = {
|
|
152
|
-
description: 'Path manipulation: join, resolve, parse, format, and platform-aware utilities',
|
|
153
|
-
methods: Object.keys(PathFunctions)
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export default {
|
|
157
|
-
name: 'path',
|
|
158
|
-
functions: PathFunctions,
|
|
159
|
-
functionMetadata: PathFunctionMetadata,
|
|
160
|
-
moduleMetadata: PathModuleMetadata,
|
|
161
|
-
global: false
|
|
162
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Native path module for RobinPath.
|
|
3
|
+
* Wraps Node.js path operations.
|
|
4
|
+
*/
|
|
5
|
+
import { join, resolve, dirname, basename, extname, parse, format, relative, normalize, isAbsolute, sep, delimiter, posix, win32 } from 'node:path';
|
|
6
|
+
import { toStr, requireArgs } from './_helpers.js';
|
|
7
|
+
|
|
8
|
+
export const PathFunctions = {
|
|
9
|
+
|
|
10
|
+
join: (args) => {
|
|
11
|
+
return join(...args.map(a => toStr(a)));
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
resolve: (args) => {
|
|
15
|
+
return resolve(...args.map(a => toStr(a)));
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
dirname: (args) => {
|
|
19
|
+
requireArgs('path.dirname', args, 1);
|
|
20
|
+
return dirname(toStr(args[0]));
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
basename: (args) => {
|
|
24
|
+
requireArgs('path.basename', args, 1);
|
|
25
|
+
const ext = args[1] != null ? toStr(args[1]) : undefined;
|
|
26
|
+
return basename(toStr(args[0]), ext);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
extname: (args) => {
|
|
30
|
+
requireArgs('path.extname', args, 1);
|
|
31
|
+
return extname(toStr(args[0]));
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
parse: (args) => {
|
|
35
|
+
requireArgs('path.parse', args, 1);
|
|
36
|
+
return parse(toStr(args[0]));
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
format: (args) => {
|
|
40
|
+
requireArgs('path.format', args, 1);
|
|
41
|
+
const obj = args[0];
|
|
42
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
43
|
+
throw new Error('path.format requires an object with root/dir/base/name/ext');
|
|
44
|
+
}
|
|
45
|
+
return format(obj);
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
relative: (args) => {
|
|
49
|
+
requireArgs('path.relative', args, 2);
|
|
50
|
+
return relative(toStr(args[0]), toStr(args[1]));
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
normalize: (args) => {
|
|
54
|
+
requireArgs('path.normalize', args, 1);
|
|
55
|
+
return normalize(toStr(args[0]));
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
isAbsolute: (args) => {
|
|
59
|
+
requireArgs('path.isAbsolute', args, 1);
|
|
60
|
+
return isAbsolute(toStr(args[0]));
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
sep: () => sep,
|
|
64
|
+
|
|
65
|
+
delimiter: () => delimiter,
|
|
66
|
+
|
|
67
|
+
toNamespacedPath: (args) => {
|
|
68
|
+
requireArgs('path.toNamespacedPath', args, 1);
|
|
69
|
+
// On Windows, converts to \\?\ prefix; on POSIX, returns unchanged
|
|
70
|
+
if (process.platform === 'win32') {
|
|
71
|
+
return '\\\\?\\' + resolve(toStr(args[0]));
|
|
72
|
+
}
|
|
73
|
+
return resolve(toStr(args[0]));
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const PathFunctionMetadata = {
|
|
78
|
+
join: {
|
|
79
|
+
description: 'Join path segments together',
|
|
80
|
+
parameters: [{ name: 'segments', dataType: 'string', description: 'Path segments', formInputType: 'text', required: true }],
|
|
81
|
+
returnType: 'string', returnDescription: 'Joined path', example: 'path.join "src" "modules" "test.js"'
|
|
82
|
+
},
|
|
83
|
+
resolve: {
|
|
84
|
+
description: 'Resolve path segments to an absolute path',
|
|
85
|
+
parameters: [{ name: 'segments', dataType: 'string', description: 'Path segments', formInputType: 'text', required: true }],
|
|
86
|
+
returnType: 'string', returnDescription: 'Absolute path', example: 'path.resolve "src" "file.js"'
|
|
87
|
+
},
|
|
88
|
+
dirname: {
|
|
89
|
+
description: 'Get directory name of a path',
|
|
90
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true }],
|
|
91
|
+
returnType: 'string', returnDescription: 'Directory name', example: 'path.dirname "/home/user/file.txt"'
|
|
92
|
+
},
|
|
93
|
+
basename: {
|
|
94
|
+
description: 'Get the last portion of a path',
|
|
95
|
+
parameters: [
|
|
96
|
+
{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true },
|
|
97
|
+
{ name: 'ext', dataType: 'string', description: 'Extension to strip', formInputType: 'text', required: false }
|
|
98
|
+
],
|
|
99
|
+
returnType: 'string', returnDescription: 'Base name', example: 'path.basename "/home/user/file.txt"'
|
|
100
|
+
},
|
|
101
|
+
extname: {
|
|
102
|
+
description: 'Get file extension',
|
|
103
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true }],
|
|
104
|
+
returnType: 'string', returnDescription: 'Extension (e.g. ".txt")', example: 'path.extname "file.txt"'
|
|
105
|
+
},
|
|
106
|
+
parse: {
|
|
107
|
+
description: 'Parse a path into components',
|
|
108
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'File path', formInputType: 'text', required: true }],
|
|
109
|
+
returnType: 'object', returnDescription: 'Object with root, dir, base, name, ext', example: 'path.parse "/home/user/file.txt"'
|
|
110
|
+
},
|
|
111
|
+
format: {
|
|
112
|
+
description: 'Format a path object into a string',
|
|
113
|
+
parameters: [{ name: 'pathObject', dataType: 'object', description: 'Object with root/dir/base/name/ext', formInputType: 'json', required: true }],
|
|
114
|
+
returnType: 'string', returnDescription: 'Formatted path string', example: 'path.format $obj'
|
|
115
|
+
},
|
|
116
|
+
relative: {
|
|
117
|
+
description: 'Get relative path from one path to another',
|
|
118
|
+
parameters: [
|
|
119
|
+
{ name: 'from', dataType: 'string', description: 'Base path', formInputType: 'text', required: true },
|
|
120
|
+
{ name: 'to', dataType: 'string', description: 'Target path', formInputType: 'text', required: true }
|
|
121
|
+
],
|
|
122
|
+
returnType: 'string', returnDescription: 'Relative path', example: 'path.relative "/home" "/home/user/file.txt"'
|
|
123
|
+
},
|
|
124
|
+
normalize: {
|
|
125
|
+
description: 'Normalize a path (resolve . and ..)',
|
|
126
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'Path to normalize', formInputType: 'text', required: true }],
|
|
127
|
+
returnType: 'string', returnDescription: 'Normalized path', example: 'path.normalize "/home/user/../file.txt"'
|
|
128
|
+
},
|
|
129
|
+
isAbsolute: {
|
|
130
|
+
description: 'Check if a path is absolute',
|
|
131
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'Path to check', formInputType: 'text', required: true }],
|
|
132
|
+
returnType: 'boolean', returnDescription: 'true if absolute', example: 'path.isAbsolute "/home/user"'
|
|
133
|
+
},
|
|
134
|
+
sep: {
|
|
135
|
+
description: 'Get the platform-specific path separator',
|
|
136
|
+
parameters: [],
|
|
137
|
+
returnType: 'string', returnDescription: 'Path separator (/ or \\)', example: 'path.sep'
|
|
138
|
+
},
|
|
139
|
+
delimiter: {
|
|
140
|
+
description: 'Get the platform-specific path delimiter',
|
|
141
|
+
parameters: [],
|
|
142
|
+
returnType: 'string', returnDescription: 'Path delimiter (: or ;)', example: 'path.delimiter'
|
|
143
|
+
},
|
|
144
|
+
toNamespacedPath: {
|
|
145
|
+
description: 'Convert to namespaced path (Windows \\\\?\\ prefix)',
|
|
146
|
+
parameters: [{ name: 'path', dataType: 'string', description: 'Path to convert', formInputType: 'text', required: true }],
|
|
147
|
+
returnType: 'string', returnDescription: 'Namespaced path', example: 'path.toNamespacedPath "C:\\Users"'
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const PathModuleMetadata = {
|
|
152
|
+
description: 'Path manipulation: join, resolve, parse, format, and platform-aware utilities',
|
|
153
|
+
methods: Object.keys(PathFunctions)
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export default {
|
|
157
|
+
name: 'path',
|
|
158
|
+
functions: PathFunctions,
|
|
159
|
+
functionMetadata: PathFunctionMetadata,
|
|
160
|
+
moduleMetadata: PathModuleMetadata,
|
|
161
|
+
global: false
|
|
162
|
+
};
|