@catladder/cli 2.0.1 → 2.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/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "2.0.1",
56
+ "version": "2.0.3",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -93,7 +93,7 @@
93
93
  "command-exists-promise": "^2.0.2",
94
94
  "common-tags": "^1.8.0",
95
95
  "connection-string-parser": "^1.0.4",
96
- "dayjs": "^1.10.4",
96
+ "date-fns": "^3.6.0",
97
97
  "fs-extra": "^7.0.1",
98
98
  "gitlab": "^4.4.1",
99
99
  "lodash": "^4.17.21",
@@ -1,5 +1,5 @@
1
1
  import type { CommandInstance } from "vorpal";
2
- import dayjs from "dayjs";
2
+ import { add, format } from "date-fns";
3
3
  import { doGitlabRequest, getProjectInfo } from "../../../../../utils/gitlab";
4
4
 
5
5
  const TOKEN_NAME = "semantic-release";
@@ -15,10 +15,10 @@ export const setupAccessTokens = async (instance: CommandInstance) => {
15
15
  (t) => t.name === TOKEN_NAME && t.active === true,
16
16
  );
17
17
 
18
- const expires_at = dayjs()
19
- .add(1, "year")
20
- .subtract(1, "day")
21
- .format("YYYY-MM-DD");
18
+ const expires_at = format(
19
+ add(new Date(), { years: 1, days: -1 }),
20
+ "yyyy-MM-dd",
21
+ );
22
22
 
23
23
  const newToken = token
24
24
  ? await doGitlabRequest(
@@ -1,7 +1,6 @@
1
- import fs from "fs-extra";
1
+ import { readFile as fsExtraReadFile } from "fs-extra";
2
2
 
3
- const readFile = async (file: string) =>
4
- fs.readFile(file, { encoding: "utf-8" });
3
+ const readFile = (file: string) => fsExtraReadFile(file, { encoding: "utf-8" });
5
4
 
6
5
  export const readFileOrError = async (filePath: string) => {
7
6
  try {
@@ -1,4 +1,4 @@
1
- import fs from "fs-extra";
1
+ import { createFile, pathExists, readFile, writeFile } from "fs-extra";
2
2
  import { homedir } from "os";
3
3
 
4
4
  import { parse, stringify } from "yaml";
@@ -6,11 +6,13 @@ const directory = `${homedir()}/.catladder`;
6
6
  const file = `${directory}/preferences.yml`;
7
7
 
8
8
  const getPreferences = async () => {
9
- if (!(await fs.pathExists(file))) {
10
- await fs.createFile(file);
9
+ if (!(await pathExists(file))) {
10
+ await createFile(file);
11
11
  }
12
- return (parse(await fs.readFile(file, { encoding: "utf-8" })) ??
13
- {}) as Record<string, string>;
12
+ return (parse(await readFile(file, { encoding: "utf-8" })) ?? {}) as Record<
13
+ string,
14
+ string
15
+ >;
14
16
  };
15
17
 
16
18
  export const hasPreference = async (key: string) => {
@@ -30,5 +32,5 @@ export const setPreference = async (key: string, value: string | number) => {
30
32
  [key]: value,
31
33
  };
32
34
 
33
- await fs.writeFile(file, stringify(newPreferences));
35
+ await writeFile(file, stringify(newPreferences));
34
36
  };