starship-butler-utils 1.0.1 → 1.0.3
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/dist/config.d.mts +61 -0
- package/dist/config.mjs +91 -0
- package/dist/consola-oeMzCFcY.mjs +3 -0
- package/dist/consola.d.mts +2 -0
- package/dist/consola.mjs +3 -0
- package/dist/fs.d.mts +74 -0
- package/dist/fs.mjs +149 -0
- package/dist/highlight-BQrgNBQi.mjs +12 -0
- package/dist/highlight.d.mts +7 -0
- package/dist/highlight.mjs +3 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.mjs +1 -0
- package/dist/path.d.mts +39 -0
- package/dist/path.mjs +46 -0
- package/dist/prompts.d.mts +6 -0
- package/dist/prompts.mjs +3 -0
- package/package.json +2 -3
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ConfigLayerMeta, ConfigLayerMeta as ConfigLayerMeta$1, LoadConfigOptions, LoadConfigOptions as LoadConfigOptions$1, ResolvedConfig, UserInputConfig } from "c12";
|
|
2
|
+
import * as rc90 from "rc9";
|
|
3
|
+
|
|
4
|
+
//#region src/config.d.ts
|
|
5
|
+
type RCOptions = typeof rc90.defaults;
|
|
6
|
+
/**
|
|
7
|
+
* Reads the user rc file (rc file under home directory).
|
|
8
|
+
*
|
|
9
|
+
* Default rc file name is ".butlerrc".
|
|
10
|
+
*
|
|
11
|
+
* @param options Options for rc9.
|
|
12
|
+
* @returns The rc content.
|
|
13
|
+
*/
|
|
14
|
+
declare function readUserRc<RC extends Record<string, any>>(options?: RCOptions): RC;
|
|
15
|
+
/**
|
|
16
|
+
* Writes a user rc file (rc file under home directory).
|
|
17
|
+
*
|
|
18
|
+
* Default rc file name is ".butlerrc".
|
|
19
|
+
*
|
|
20
|
+
* @param config The config to be written to rc file.
|
|
21
|
+
* @param options Options for rc9.
|
|
22
|
+
*/
|
|
23
|
+
declare function writeUserRc(config: any, options?: RCOptions): void;
|
|
24
|
+
/**
|
|
25
|
+
* Updates a user rc file (rc file under home directory).
|
|
26
|
+
*
|
|
27
|
+
* Default rc file name is ".butlerrc".
|
|
28
|
+
*
|
|
29
|
+
* @param config The config to update the rc file.
|
|
30
|
+
* @param options Options for rc9.
|
|
31
|
+
* @returns The updated rc content.
|
|
32
|
+
*/
|
|
33
|
+
declare function updateUserRc(config: any, options?: RCOptions): any;
|
|
34
|
+
/**
|
|
35
|
+
* Removes the user rc file (rc file under home directory).
|
|
36
|
+
*
|
|
37
|
+
* Default rc file name is ".butlerrc".
|
|
38
|
+
*
|
|
39
|
+
* @param options Options for rc9.
|
|
40
|
+
*/
|
|
41
|
+
declare function removeUserRc(options?: RCOptions): void;
|
|
42
|
+
/**
|
|
43
|
+
* Updates or creates a user rc file (rc file under home directory).
|
|
44
|
+
*
|
|
45
|
+
* Default rc file name is ".butlerrc".
|
|
46
|
+
*
|
|
47
|
+
* @param config The config to upsert to the rc file.
|
|
48
|
+
* @param options Options for rc9.
|
|
49
|
+
*/
|
|
50
|
+
declare function upsertUserRc(config: any, options?: RCOptions): void;
|
|
51
|
+
/**
|
|
52
|
+
* Loads the configuration using `c12`.
|
|
53
|
+
*
|
|
54
|
+
* Default config file name is "butler" and rc file loading is disabled.
|
|
55
|
+
*
|
|
56
|
+
* @param options Load config options.
|
|
57
|
+
* @returns Configuration.
|
|
58
|
+
*/
|
|
59
|
+
declare function loadConfig<M extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta$1 = ConfigLayerMeta$1>(options?: LoadConfigOptions$1<M, MT>): Promise<ResolvedConfig<M, MT>>;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { type ConfigLayerMeta, type LoadConfigOptions, RCOptions, loadConfig, readUserRc, removeUserRc, updateUserRc, upsertUserRc, writeUserRc };
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { remove } from "./fs.mjs";
|
|
2
|
+
import { homedir } from "./path.mjs";
|
|
3
|
+
import { loadConfig as loadConfig$1 } from "c12";
|
|
4
|
+
import { readUser, updateUser, writeUser } from "rc9";
|
|
5
|
+
|
|
6
|
+
//#region src/config.ts
|
|
7
|
+
const RC_FILE_NAME = ".butlerrc";
|
|
8
|
+
/**
|
|
9
|
+
* Reads the user rc file (rc file under home directory).
|
|
10
|
+
*
|
|
11
|
+
* Default rc file name is ".butlerrc".
|
|
12
|
+
*
|
|
13
|
+
* @param options Options for rc9.
|
|
14
|
+
* @returns The rc content.
|
|
15
|
+
*/
|
|
16
|
+
function readUserRc(options) {
|
|
17
|
+
return readUser({
|
|
18
|
+
name: RC_FILE_NAME,
|
|
19
|
+
...options ?? {}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Writes a user rc file (rc file under home directory).
|
|
24
|
+
*
|
|
25
|
+
* Default rc file name is ".butlerrc".
|
|
26
|
+
*
|
|
27
|
+
* @param config The config to be written to rc file.
|
|
28
|
+
* @param options Options for rc9.
|
|
29
|
+
*/
|
|
30
|
+
function writeUserRc(config, options) {
|
|
31
|
+
writeUser(config, {
|
|
32
|
+
name: RC_FILE_NAME,
|
|
33
|
+
...options ?? {}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Updates a user rc file (rc file under home directory).
|
|
38
|
+
*
|
|
39
|
+
* Default rc file name is ".butlerrc".
|
|
40
|
+
*
|
|
41
|
+
* @param config The config to update the rc file.
|
|
42
|
+
* @param options Options for rc9.
|
|
43
|
+
* @returns The updated rc content.
|
|
44
|
+
*/
|
|
45
|
+
function updateUserRc(config, options) {
|
|
46
|
+
return updateUser(config, {
|
|
47
|
+
name: RC_FILE_NAME,
|
|
48
|
+
...options ?? {}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Removes the user rc file (rc file under home directory).
|
|
53
|
+
*
|
|
54
|
+
* Default rc file name is ".butlerrc".
|
|
55
|
+
*
|
|
56
|
+
* @param options Options for rc9.
|
|
57
|
+
*/
|
|
58
|
+
function removeUserRc(options) {
|
|
59
|
+
const { dir, name = RC_FILE_NAME } = options ?? {};
|
|
60
|
+
remove(homedir(dir ? `${dir}/${name}` : name));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Updates or creates a user rc file (rc file under home directory).
|
|
64
|
+
*
|
|
65
|
+
* Default rc file name is ".butlerrc".
|
|
66
|
+
*
|
|
67
|
+
* @param config The config to upsert to the rc file.
|
|
68
|
+
* @param options Options for rc9.
|
|
69
|
+
*/
|
|
70
|
+
function upsertUserRc(config, options) {
|
|
71
|
+
if (!readUserRc(options)) writeUserRc(config, options);
|
|
72
|
+
else updateUserRc(config, options);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Loads the configuration using `c12`.
|
|
76
|
+
*
|
|
77
|
+
* Default config file name is "butler" and rc file loading is disabled.
|
|
78
|
+
*
|
|
79
|
+
* @param options Load config options.
|
|
80
|
+
* @returns Configuration.
|
|
81
|
+
*/
|
|
82
|
+
function loadConfig(options) {
|
|
83
|
+
return loadConfig$1({
|
|
84
|
+
name: "butler",
|
|
85
|
+
rcFile: false,
|
|
86
|
+
...options ?? {}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { loadConfig, readUserRc, removeUserRc, updateUserRc, upsertUserRc, writeUserRc };
|
package/dist/consola.mjs
ADDED
package/dist/fs.d.mts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//#region src/fs.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Check if a path exists. Does not dereference symlinks.
|
|
4
|
+
*
|
|
5
|
+
* @param path The path to check.
|
|
6
|
+
* @returns Whether the path exists.
|
|
7
|
+
*/
|
|
8
|
+
declare function exists(path: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Check if a path is a directory.
|
|
11
|
+
*
|
|
12
|
+
* If the path exists, we check the stats, if not, we check if the path ends
|
|
13
|
+
* with `/` or `\`.
|
|
14
|
+
*
|
|
15
|
+
* @param path The path to check.
|
|
16
|
+
* @returns Whether the path is a directory.
|
|
17
|
+
*/
|
|
18
|
+
declare function isDirectory(path: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a path is a symbolic link.
|
|
21
|
+
*
|
|
22
|
+
* @param path The path to check.
|
|
23
|
+
* @returns Whether the path is a symbolic link.
|
|
24
|
+
*/
|
|
25
|
+
declare function isSymbolicLink(path: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Ensure a directory exists.
|
|
28
|
+
*
|
|
29
|
+
* - If the path exists but is not a directory, return false.
|
|
30
|
+
* - If the path does not exist, create the directory and get fails, return false.
|
|
31
|
+
* - Otherwise, return true.
|
|
32
|
+
*
|
|
33
|
+
* @param path The path to ensure.
|
|
34
|
+
* @returns `true` if the path is a directory and exists at the end, `false` otherwise.
|
|
35
|
+
*/
|
|
36
|
+
declare function ensureDirectory(path: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Copy a file.
|
|
39
|
+
*
|
|
40
|
+
* @param sourcePath The path to the source file.
|
|
41
|
+
* @param targetPath The path to the target file.
|
|
42
|
+
* @param force Whether to force overwrite the target file.
|
|
43
|
+
* @returns Whether the file was copied.
|
|
44
|
+
*/
|
|
45
|
+
declare function copyFile(sourcePath: string, targetPath: string, force?: boolean): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Create a symbolic link.
|
|
48
|
+
*
|
|
49
|
+
* @param sourcePath The path to the source file.
|
|
50
|
+
* @param targetPath The path to the target symlink.
|
|
51
|
+
* @param force Whether to force overwrite the target symlink.
|
|
52
|
+
* @returns Whether the symlink was created.
|
|
53
|
+
*/
|
|
54
|
+
declare function createSymlink(sourcePath: string, targetPath: string, force?: boolean): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Remove a path.
|
|
57
|
+
*
|
|
58
|
+
* @param path The path to remove.
|
|
59
|
+
* @param recursive Whether to remove (directories) recursively. If `false`, removing a directory will fail with an error.
|
|
60
|
+
* @returns `true` if the file was removed, `false` otherwise.
|
|
61
|
+
*/
|
|
62
|
+
declare function remove(path: string, recursive?: boolean): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Remove a symbolic link.
|
|
65
|
+
*
|
|
66
|
+
* If the path is not a symlink, a warning will be logged and the function will
|
|
67
|
+
* return false.
|
|
68
|
+
*
|
|
69
|
+
* @param path The path to remove.
|
|
70
|
+
* @returns `true` if the symlink was removed, `false` otherwise.
|
|
71
|
+
*/
|
|
72
|
+
declare function removeSymlink(path: string): boolean;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { copyFile, createSymlink, ensureDirectory, exists, isDirectory, isSymbolicLink, remove, removeSymlink };
|
package/dist/fs.mjs
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { n as consola_default } from "./consola-oeMzCFcY.mjs";
|
|
2
|
+
import { a as info } from "./highlight-BQrgNBQi.mjs";
|
|
3
|
+
import { constants, copyFileSync, lstatSync, mkdirSync, renameSync, rmSync, symlinkSync } from "node:fs";
|
|
4
|
+
|
|
5
|
+
//#region src/fs.ts
|
|
6
|
+
/**
|
|
7
|
+
* Check if a path exists. Does not dereference symlinks.
|
|
8
|
+
*
|
|
9
|
+
* @param path The path to check.
|
|
10
|
+
* @returns Whether the path exists.
|
|
11
|
+
*/
|
|
12
|
+
function exists(path) {
|
|
13
|
+
try {
|
|
14
|
+
if (lstatSync(path).isFile() && path.match(/\/$|\\$/)) return false;
|
|
15
|
+
else return true;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (error instanceof Error && ["ENOENT", "ENOTDIR"].some((str) => error.message.includes(str))) return false;
|
|
18
|
+
else throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if a path is a directory.
|
|
23
|
+
*
|
|
24
|
+
* If the path exists, we check the stats, if not, we check if the path ends
|
|
25
|
+
* with `/` or `\`.
|
|
26
|
+
*
|
|
27
|
+
* @param path The path to check.
|
|
28
|
+
* @returns Whether the path is a directory.
|
|
29
|
+
*/
|
|
30
|
+
function isDirectory(path) {
|
|
31
|
+
if (exists(path)) return lstatSync(path).isDirectory();
|
|
32
|
+
else return (!exists(path) || lstatSync(path).isDirectory()) && path.match(/\/$|\\$/) !== null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check if a path is a symbolic link.
|
|
36
|
+
*
|
|
37
|
+
* @param path The path to check.
|
|
38
|
+
* @returns Whether the path is a symbolic link.
|
|
39
|
+
*/
|
|
40
|
+
function isSymbolicLink(path) {
|
|
41
|
+
return exists(path) && lstatSync(path).isSymbolicLink();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Ensure a directory exists.
|
|
45
|
+
*
|
|
46
|
+
* - If the path exists but is not a directory, return false.
|
|
47
|
+
* - If the path does not exist, create the directory and get fails, return false.
|
|
48
|
+
* - Otherwise, return true.
|
|
49
|
+
*
|
|
50
|
+
* @param path The path to ensure.
|
|
51
|
+
* @returns `true` if the path is a directory and exists at the end, `false` otherwise.
|
|
52
|
+
*/
|
|
53
|
+
function ensureDirectory(path) {
|
|
54
|
+
try {
|
|
55
|
+
if (exists(path)) return isDirectory(path);
|
|
56
|
+
else {
|
|
57
|
+
mkdirSync(path, { recursive: true });
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
} catch {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Copy a file.
|
|
66
|
+
*
|
|
67
|
+
* @param sourcePath The path to the source file.
|
|
68
|
+
* @param targetPath The path to the target file.
|
|
69
|
+
* @param force Whether to force overwrite the target file.
|
|
70
|
+
* @returns Whether the file was copied.
|
|
71
|
+
*/
|
|
72
|
+
function copyFile(sourcePath, targetPath, force = false) {
|
|
73
|
+
const isExist = exists(targetPath);
|
|
74
|
+
if (isExist) {
|
|
75
|
+
if (!force) {
|
|
76
|
+
consola_default.warn(`COPY: Path already exists: ${info(targetPath)}, skip`);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
renameSync(targetPath, `${targetPath}.bak`);
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
copyFileSync(sourcePath, targetPath, force ? constants.COPYFILE_FICLONE : constants.COPYFILE_EXCL);
|
|
83
|
+
if (isExist) remove(`${targetPath}.bak`);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (isExist) renameSync(`${targetPath}.bak`, targetPath);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create a symbolic link.
|
|
92
|
+
*
|
|
93
|
+
* @param sourcePath The path to the source file.
|
|
94
|
+
* @param targetPath The path to the target symlink.
|
|
95
|
+
* @param force Whether to force overwrite the target symlink.
|
|
96
|
+
* @returns Whether the symlink was created.
|
|
97
|
+
*/
|
|
98
|
+
function createSymlink(sourcePath, targetPath, force = false) {
|
|
99
|
+
const isExist = exists(targetPath);
|
|
100
|
+
if (isExist) {
|
|
101
|
+
if (!force) {
|
|
102
|
+
consola_default.warn(`LINK: Path already exists: ${info(targetPath)}, skip`);
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
renameSync(targetPath, `${targetPath}.bak`);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
symlinkSync(sourcePath, targetPath, "file");
|
|
109
|
+
if (isExist) remove(`${targetPath}.bak`);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (isExist) renameSync(`${targetPath}.bak`, targetPath);
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Remove a path.
|
|
118
|
+
*
|
|
119
|
+
* @param path The path to remove.
|
|
120
|
+
* @param recursive Whether to remove (directories) recursively. If `false`, removing a directory will fail with an error.
|
|
121
|
+
* @returns `true` if the file was removed, `false` otherwise.
|
|
122
|
+
*/
|
|
123
|
+
function remove(path, recursive = false) {
|
|
124
|
+
if (!exists(path)) {
|
|
125
|
+
consola_default.warn(`REMOVE: Path not exists: ${info(path)}, skip`);
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
rmSync(path, { recursive });
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Remove a symbolic link.
|
|
133
|
+
*
|
|
134
|
+
* If the path is not a symlink, a warning will be logged and the function will
|
|
135
|
+
* return false.
|
|
136
|
+
*
|
|
137
|
+
* @param path The path to remove.
|
|
138
|
+
* @returns `true` if the symlink was removed, `false` otherwise.
|
|
139
|
+
*/
|
|
140
|
+
function removeSymlink(path) {
|
|
141
|
+
if (!isSymbolicLink(path)) {
|
|
142
|
+
consola_default.warn(`REMOVE: Path is not a symlink: ${info(path)}, skip`);
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
return remove(path);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//#endregion
|
|
149
|
+
export { copyFile, createSymlink, ensureDirectory, exists, isDirectory, isSymbolicLink, remove, removeSymlink };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { bold, bold as bold$1, cyan, cyan as cyan$1, green, magenta, magenta as magenta$1, red, reset } from "ansis";
|
|
2
|
+
|
|
3
|
+
//#region src/highlight.ts
|
|
4
|
+
function info(v) {
|
|
5
|
+
return cyan(v);
|
|
6
|
+
}
|
|
7
|
+
function important(v) {
|
|
8
|
+
return bold(magenta(v));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { info as a, reset as c, important as i, cyan$1 as n, magenta$1 as o, green as r, red as s, bold$1 as t };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { bold, cyan, green, magenta, red, reset } from "ansis";
|
|
2
|
+
|
|
3
|
+
//#region src/highlight.d.ts
|
|
4
|
+
declare function info(v: unknown): string;
|
|
5
|
+
declare function important(v: unknown): string;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { bold, cyan, green, important, info, magenta, red, reset };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ConfigLayerMeta, LoadConfigOptions, RCOptions, loadConfig, readUserRc, removeUserRc, updateUserRc, upsertUserRc, writeUserRc } from "./config.mjs";
|
|
2
|
+
import { LogLevels } from "./consola.mjs";
|
|
3
|
+
import { copyFile, createSymlink, ensureDirectory, exists, isDirectory, isSymbolicLink, remove, removeSymlink } from "./fs.mjs";
|
|
4
|
+
import { bold, cyan, green, important, info, magenta, red, reset } from "./highlight.mjs";
|
|
5
|
+
import { appdata, basename, homedir, join, localAppdata } from "./path.mjs";
|
|
6
|
+
import { n as __reExport, t as __exportAll } from "./prompts.mjs";
|
|
7
|
+
export * from "@clack/prompts";
|
|
8
|
+
|
|
9
|
+
//#region src/index.d.ts
|
|
10
|
+
declare namespace index_d_exports {
|
|
11
|
+
export { ConfigLayerMeta, LoadConfigOptions, LogLevels, RCOptions, appdata, basename, bold, copyFile, createSymlink, cyan, ensureDirectory, exists, green, homedir, important, info, isDirectory, isSymbolicLink, join, loadConfig, localAppdata, magenta, readUserRc, red, remove, removeSymlink, removeUserRc, reset, updateUserRc, upsertUserRc, writeUserRc };
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ConfigLayerMeta, LoadConfigOptions, LogLevels, RCOptions, appdata, basename, bold, copyFile, createSymlink, cyan, ensureDirectory, exists, green, homedir, important, info, isDirectory, isSymbolicLink, join, loadConfig, localAppdata, magenta, readUserRc, red, remove, removeSymlink, removeUserRc, reset, updateUserRc, upsertUserRc, writeUserRc };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/path.d.mts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { basename } from "pathe";
|
|
2
|
+
import * as node_path0 from "node:path";
|
|
3
|
+
|
|
4
|
+
//#region src/path.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Join all arguments together and normalize the resulting path, starting from home directory.
|
|
8
|
+
*
|
|
9
|
+
* @param paths Paths to join.
|
|
10
|
+
* @returns Joined paths.
|
|
11
|
+
* @throws {TypeError} if any of the path segments is not a string.
|
|
12
|
+
*/
|
|
13
|
+
declare const join: typeof node_path0.join;
|
|
14
|
+
/**
|
|
15
|
+
* Join all arguments together and normalize the resulting path, starting from home directory.
|
|
16
|
+
*
|
|
17
|
+
* @param paths Paths to join.
|
|
18
|
+
* @returns Joined paths.
|
|
19
|
+
* @throws {TypeError} if any of the path segments is not a string.
|
|
20
|
+
*/
|
|
21
|
+
declare function homedir(...paths: string[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* Join all arguments together and normalize the resulting path, starting from appdata directory.
|
|
24
|
+
*
|
|
25
|
+
* @param paths Paths to join.
|
|
26
|
+
* @returns Joined paths.
|
|
27
|
+
* @throws {TypeError} if any of the path segments is not a string.
|
|
28
|
+
*/
|
|
29
|
+
declare function appdata(...paths: string[]): string;
|
|
30
|
+
/**
|
|
31
|
+
* Join all arguments together and normalize the resulting path, starting from local appdata directory.
|
|
32
|
+
*
|
|
33
|
+
* @param paths Paths to join.
|
|
34
|
+
* @returns Joined paths.
|
|
35
|
+
* @throws {TypeError} if any of the path segments is not a string.
|
|
36
|
+
*/
|
|
37
|
+
declare function localAppdata(...paths: string[]): string;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { appdata, basename, homedir, join, localAppdata };
|
package/dist/path.mjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { homedir as homedir$1 } from "node:os";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { basename, join as join$1 } from "pathe";
|
|
4
|
+
|
|
5
|
+
//#region src/path.ts
|
|
6
|
+
/**
|
|
7
|
+
* Join all arguments together and normalize the resulting path, starting from home directory.
|
|
8
|
+
*
|
|
9
|
+
* @param paths Paths to join.
|
|
10
|
+
* @returns Joined paths.
|
|
11
|
+
* @throws {TypeError} if any of the path segments is not a string.
|
|
12
|
+
*/
|
|
13
|
+
const join = join$1;
|
|
14
|
+
/**
|
|
15
|
+
* Join all arguments together and normalize the resulting path, starting from home directory.
|
|
16
|
+
*
|
|
17
|
+
* @param paths Paths to join.
|
|
18
|
+
* @returns Joined paths.
|
|
19
|
+
* @throws {TypeError} if any of the path segments is not a string.
|
|
20
|
+
*/
|
|
21
|
+
function homedir(...paths) {
|
|
22
|
+
return join(process.env.XDG_CONFIG_HOME ?? homedir$1(), ...paths);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Join all arguments together and normalize the resulting path, starting from appdata directory.
|
|
26
|
+
*
|
|
27
|
+
* @param paths Paths to join.
|
|
28
|
+
* @returns Joined paths.
|
|
29
|
+
* @throws {TypeError} if any of the path segments is not a string.
|
|
30
|
+
*/
|
|
31
|
+
function appdata(...paths) {
|
|
32
|
+
return join(process.env.APPDATA, ...paths);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Join all arguments together and normalize the resulting path, starting from local appdata directory.
|
|
36
|
+
*
|
|
37
|
+
* @param paths Paths to join.
|
|
38
|
+
* @returns Joined paths.
|
|
39
|
+
* @throws {TypeError} if any of the path segments is not a string.
|
|
40
|
+
*/
|
|
41
|
+
function localAppdata(...paths) {
|
|
42
|
+
return join(process.env.LOCALAPPDATA, ...paths);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { appdata, basename, homedir, join, localAppdata };
|
package/dist/prompts.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starship-butler-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"description": "Utils used by starship butler.",
|
|
6
6
|
"author": "Lumirelle <shabbyacc@outlook.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"exports": {
|
|
22
|
+
".": "./dist/index.mjs",
|
|
22
23
|
"./config": "./dist/config.mjs",
|
|
23
24
|
"./path": "./dist/path.mjs",
|
|
24
25
|
"./fs": "./dist/fs.mjs",
|
|
@@ -26,8 +27,6 @@
|
|
|
26
27
|
"./consola": "./dist/consola.mjs",
|
|
27
28
|
"./prompts": "./dist/prompts.mjs"
|
|
28
29
|
},
|
|
29
|
-
"main": "./dist/index.mjs",
|
|
30
|
-
"module": "./dist/index.mjs",
|
|
31
30
|
"types": "./dist/index.d.mts",
|
|
32
31
|
"files": [
|
|
33
32
|
"dist"
|