@catladder/cli 2.7.3 → 2.7.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.
- package/dist/bundles/catenv/index.js +1 -1
- package/dist/bundles/cli/index.js +1 -1
- package/dist/cli/src/utils/gitlab.js +1 -1
- package/dist/cli/src/utils/gitlab.js.map +1 -1
- package/dist/cli/src/utils/preferences.d.ts +1 -0
- package/dist/cli/src/utils/preferences.js +17 -11
- package/dist/cli/src/utils/preferences.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/utils/gitlab.ts +1 -1
- package/src/utils/preferences.ts +28 -9
package/package.json
CHANGED
package/src/utils/gitlab.ts
CHANGED
|
@@ -27,7 +27,7 @@ export const setupGitlabToken = async (vorpal: CommandInstance) => {
|
|
|
27
27
|
getGitRemoteHostAndPath(),
|
|
28
28
|
]);
|
|
29
29
|
|
|
30
|
-
open(`https://${gitRemoteHost}/-/
|
|
30
|
+
open(`https://${gitRemoteHost}/-/user_settings/personal_access_tokens`);
|
|
31
31
|
|
|
32
32
|
vorpal.log("Please type in gitlab's personal access token");
|
|
33
33
|
|
package/src/utils/preferences.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
readFile,
|
|
3
|
+
writeFile,
|
|
4
|
+
mkdir,
|
|
5
|
+
rename,
|
|
6
|
+
cp,
|
|
7
|
+
rmdir,
|
|
8
|
+
chmod,
|
|
9
|
+
} from "fs/promises";
|
|
2
10
|
import { existsSync } from "fs";
|
|
3
11
|
import { join, dirname } from "path";
|
|
4
12
|
import { homedir } from "os";
|
|
@@ -8,26 +16,37 @@ const legacyPreferencesPath = join(homedir(), ".catladder/preferences.yml");
|
|
|
8
16
|
const preferencesPath = join(homedir(), ".config/catladder/preferences.yml");
|
|
9
17
|
|
|
10
18
|
const ensurePreferencesFile = async () => {
|
|
19
|
+
if (existsSync(legacyPreferencesPath)) {
|
|
20
|
+
await mkdir(dirname(preferencesPath), { recursive: true, mode: 0o700 });
|
|
21
|
+
await cp(legacyPreferencesPath, preferencesPath);
|
|
22
|
+
await chmod(dirname(preferencesPath), 0o600);
|
|
23
|
+
await rename(
|
|
24
|
+
legacyPreferencesPath,
|
|
25
|
+
join(dirname(preferencesPath), "old_preferences_backup.yml"),
|
|
26
|
+
);
|
|
27
|
+
await chmod(
|
|
28
|
+
join(dirname(preferencesPath), "old_preferences_backup.yml"),
|
|
29
|
+
0o600,
|
|
30
|
+
);
|
|
31
|
+
await rmdir(dirname(legacyPreferencesPath));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
11
34
|
if (existsSync(preferencesPath)) {
|
|
12
|
-
return
|
|
35
|
+
return;
|
|
13
36
|
}
|
|
14
37
|
await mkdir(dirname(preferencesPath), { recursive: true, mode: 0o700 });
|
|
15
38
|
await writeFile(preferencesPath, "---\n{}", {
|
|
16
39
|
encoding: "utf-8",
|
|
17
40
|
mode: 0o600,
|
|
18
41
|
});
|
|
19
|
-
if (existsSync(legacyPreferencesPath)) {
|
|
20
|
-
return legacyPreferencesPath;
|
|
21
|
-
}
|
|
22
|
-
return preferencesPath;
|
|
23
42
|
};
|
|
24
43
|
|
|
25
44
|
const loadPreferences = async () => {
|
|
26
|
-
|
|
27
|
-
return readFile(
|
|
45
|
+
await ensurePreferencesFile();
|
|
46
|
+
return readFile(preferencesPath, { encoding: "utf-8" });
|
|
28
47
|
};
|
|
29
48
|
|
|
30
|
-
const getPreferences = async () => {
|
|
49
|
+
export const getPreferences = async () => {
|
|
31
50
|
const yamlContent = await loadPreferences();
|
|
32
51
|
return (parse(yamlContent) ?? {}) as Record<string, string>;
|
|
33
52
|
};
|