Skip to content

Commit a161aff

Browse files
committed
feat: second release
1 parent cb7e45d commit a161aff

File tree

8 files changed

+64
-49
lines changed

8 files changed

+64
-49
lines changed

.github/workflows/publish.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ jobs:
3333
- name: Install Dependencies
3434
run: pnpm install
3535

36+
- name: Build Project
37+
run: pnpm build
38+
3639
- name: Create Release Pull Request or Publish
3740
id: changesets
3841
uses: changesets/action@v1
3942
with:
40-
publish: pnpm publish --access public
43+
publish: pnpm publish --access public --no-git-checks
4144
env:
4245
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
46+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.npmignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ SECURITY.md
4949
BACKERS.md
5050
.prettierrc
5151
.prettierignore
52-
.eslint.config.mjs
52+
eslint.config.mjs

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# cclip
22

3+
## 2.1.1
4+
5+
### Patch Changes
6+
7+
- 965a0ee: Urgent fix
8+
9+
## 2.1.0
10+
11+
### Minor Changes
12+
13+
- 387760d: update files structure
14+
315
## 2.0.1
416

517
### Patch Changes

package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cclip",
3-
"version": "2.0.1",
3+
"version": "2.1.1",
44
"description": "A simple CLI tool to copy text to clipboard",
55
"license": "MIT",
66
"author": "ru44",
@@ -21,7 +21,7 @@
2121
"lintfix": "eslint --fix",
2222
"dev": "tsx ./src/main.ts",
2323
"build": "tsup",
24-
"release": "pnpm run build && changeset publish"
24+
"release": "pnpm build && changeset publish"
2525
},
2626
"keywords": [
2727
"cli",
@@ -34,14 +34,12 @@
3434
"dependencies": {
3535
"axios": "^1.7.7",
3636
"clipboardy": "^4.0.0",
37-
"shelljs": "^0.8.5",
3837
"yargs": "^17.7.2"
3938
},
4039
"devDependencies": {
4140
"@changesets/cli": "^2.27.10",
4241
"@eslint/js": "^9.15.0",
4342
"@types/node": "^22.9.1",
44-
"@types/shelljs": "^0.8.15",
4543
"@types/yargs": "^17.0.33",
4644
"@typescript-eslint/eslint-plugin": "^8.15.0",
4745
"@typescript-eslint/parser": "^8.15.0",

src/helpers/request.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { GistError, GistApiConfig } from '../interfaces/interfaces'
2+
import axios from 'axios'
3+
4+
export async function request(
5+
config: GistApiConfig,
6+
method: string,
7+
endpoint: string,
8+
params = {},
9+
data: any = null
10+
): Promise<any> {
11+
try {
12+
const url = `${config.baseUrl}${endpoint}`
13+
const options = { method, headers: config.headers, params, data }
14+
const response = await axios(url, options)
15+
return response.data
16+
} catch (error) {
17+
if (axios.isAxiosError(error) && error.response) {
18+
throw { code: error.response.status, message: error.response.data.message } as GistError
19+
}
20+
throw { code: -1, message: (error as Error).message } as GistError
21+
}
22+
}
23+
24+
export const createGistApiConfig = (token: string): GistApiConfig => ({
25+
token,
26+
baseUrl: 'https://api.github.com',
27+
headers: {
28+
Authorization: `token ${token}`,
29+
'Content-Type': 'application/json'
30+
}
31+
})

src/main.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ const argvPromise = yargs(hideBin(process.argv))
2424

2525
const configPath = _resolve(process.env.HOME || process.env.USERPROFILE || '', '.cloudclip.json')
2626

27-
const handleError = (error: unknown) => {
27+
function handleError(error: unknown) {
2828
if (error instanceof Error) {
2929
console.error(`Error: ${error.message}`)
3030
} else {
3131
console.error(`Error: ${error}`)
3232
}
3333
}
3434

35-
const readStdin = async (): Promise<string> => {
35+
async function readStdin(): Promise<string> {
3636
return new Promise((resolve, reject) => {
3737
let data = ''
3838
process.stdin
@@ -42,9 +42,9 @@ const readStdin = async (): Promise<string> => {
4242
})
4343
}
4444

45-
const main = async () => {
45+
async function main() {
4646
try {
47-
const argv = await argvPromise;
47+
const argv = await argvPromise
4848
switch (argv._[0]) {
4949
case 'init': {
5050
await init(configPath, argv.token as string, argv.gistId as string)

src/utils/cloudClip.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import { createGistApiConfig, getGist, createGist, editGist } from './gistApi'
21
import { existsSync, readFileSync, writeFileSync } from 'fs'
32
import { CloudClipConfig } from '../interfaces/interfaces'
3+
import { getGist, createGist, editGist } from './gistApi'
4+
import { createGistApiConfig } from '../helpers/request'
45
import clipboardy from 'clipboardy'
56

6-
7-
const readConfig = (configFile: string): CloudClipConfig => {
7+
function readConfig(configFile: string): CloudClipConfig {
88
if (!existsSync(configFile)) {
99
return {}
1010
}
1111
return JSON.parse(readFileSync(configFile, 'utf-8'))
1212
}
1313

14-
const saveConfig = (configFile: string, config: CloudClipConfig) => {
14+
function saveConfig(configFile: string, config: CloudClipConfig) {
1515
writeFileSync(configFile, JSON.stringify(config, null, 2))
1616
}
1717

18-
const setToken = (configFile: string, config: CloudClipConfig, token: string) => {
18+
function setToken(configFile: string, config: CloudClipConfig, token: string) {
1919
config.token = token
2020
saveConfig(configFile, config)
2121
}
2222

23-
const setGistId = (configFile: string, config: CloudClipConfig, gistId: string) => {
23+
function setGistId(configFile: string, config: CloudClipConfig, gistId: string) {
2424
config.gistId = gistId
2525
saveConfig(configFile, config)
2626
}
@@ -96,4 +96,4 @@ export const clear = async (configFile: string) => {
9696
}, {})
9797
await editGist(apiConfig, config.gistId, '<Clipboard>', files)
9898
console.log('Cloud clipboard cleared.')
99-
}
99+
}

src/utils/gistApi.ts

+2-31
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,5 @@
1-
import { GistError, GistApiConfig, GistFile } from '../interfaces/interfaces'
2-
import axios from 'axios'
3-
4-
export const createGistApiConfig = (token: string): GistApiConfig => ({
5-
token,
6-
baseUrl: 'https://api.github.com',
7-
headers: {
8-
Authorization: `token ${token}`,
9-
'Content-Type': 'application/json'
10-
}
11-
})
12-
13-
const request = async (
14-
config: GistApiConfig,
15-
method: string,
16-
endpoint: string,
17-
params = {},
18-
data: any = null
19-
): Promise<any> => {
20-
try {
21-
const url = `${config.baseUrl}${endpoint}`
22-
const options = { method, headers: config.headers, params, data }
23-
const response = await axios(url, options)
24-
return response.data
25-
} catch (error) {
26-
if (axios.isAxiosError(error) && error.response) {
27-
throw { code: error.response.status, message: error.response.data.message } as GistError
28-
}
29-
throw { code: -1, message: (error as Error).message } as GistError
30-
}
31-
}
1+
import { GistApiConfig, GistFile } from '../interfaces/interfaces'
2+
import { request } from '../helpers/request'
323

334
export const listGists = (config: GistApiConfig) => request(config, 'GET', '/gists')
345

0 commit comments

Comments
 (0)