Skip to content

Commit

Permalink
feat: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-lsn committed Dec 24, 2023
0 parents commit b49cd08
Show file tree
Hide file tree
Showing 23 changed files with 1,058 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
};
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Ubuntu Dev Container",
"image": "mcr.microsoft.com/vscode/devcontainers/base:ubuntu",
"features": {
"ghcr.io/shyim/devcontainers-features/bun:0": "0.0.1",
"ghcr.io/devcontainers-contrib/features/act:1": "1.0.14"
},
"customizations": {
"vscode": {
"extensions": ["biomejs.biome"]
}
},
"remoteUser": "vscode"
}
30 changes: 30 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Code quality

on:
push:
pull_request:

jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v1
with:
version: 1.4.1
- name: Run Biome
run: biome ci .
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.19
- run: bun install
- run: bun run test
env:
PIKPAK_USERNAME: ${{secrets.PIKPAK_USERNAME}}
PIKPAK_PASSWORD: ${{secrets.PIKPAK_PASSWORD}}
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release & Publish to NPM
on: workflow_dispatch
jobs:
release:
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: oven-sh/[email protected]
- run: |
bun install --frozen-lockfile
bun run build
- name: Initialize Git user
run: |
git config --global user.email "[email protected]"
git config --global user.name "Release Workflow"
- name: Initialize the NPM config
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Run release
run: npm run release --ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
179 changes: 179 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

build

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store

.act.secrets
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
Empty file added .npmignore
Empty file.
21 changes: 21 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"git": {
"commitMessage": "chore: release v${version}"
},
"npm": {
"publish": true
},
"github": {
"release": true
},
"hooks": {
"before:init": ["git pull", "bun run test"],
"after:bump": "echo Version update successfully"
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": "angular",
"infile": "CHANGELOG.md"
}
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Chris

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# pikpak-js-sdk (unofficial)

This is a simple javascript SDK for the PikPak API.

## Installation

```bash
npm install pikpak
```

## Supported Functions

- [x] Get Tasks
- [x] Create Task
- [x] Delete Task
- [x] Get Folder
- [x] Create Folder
- [x] Delete Folders
- [x] Get File
- [x] Get Quota

> Currently, it only supports the functions mentioned above, but it covers more frequently used features. If you require additional functionality, please [open an issue](https://github.com/chris-lsn/pikpak-js-sdk/issues/new).
## Usage

```javascript
const pikpak = new PikPak("username", "password");
const tasks = await pikpak.getTasks();
```

## Development

This project is based on the js runtime of [Bun](https://github.com/oven-sh/bun). Please make sure you have installed the bun cli before running the project.

To run the project in development mode, run the following command:

```bash
bun run dev
```

## License

[MIT](https://choosealicense.com/licenses/mit/)
15 changes: 15 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"noNonNullAssertion": "off"
}
}
}
}
Binary file added bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions enums/resourceKind.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ResourceKind {
FILE = "drive#file",
FOLDER = "drive#folder",
TASK = "drive#task",
}
5 changes: 5 additions & 0 deletions enums/taskStatus.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum TaskStatus {
PHASE_TYPE_COMPLETE = "PHASE_TYPE_COMPLETE",
PHASE_TYPE_ERROR = "PHASE_TYPE_ERROR",
PHASE_TYPE_RUNNING = "PHASE_TYPE_RUNNING",
}
5 changes: 5 additions & 0 deletions enums/thumbnailSize.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ThumbnailSize {
SIZE_SMALL = "SIZE_SMALL",
SIZE_MEDIUM = "SIZE_MEDIUM",
SIZE_LARGE = "SIZE_LARGE",
}
10 changes: 10 additions & 0 deletions exceptions/pikpakException.exception.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IPikPakFailureResponse } from "../interfaces/pikpakResponse.interface";

export class PikPakException extends Error {
constructor(
message: string,
public details: IPikPakFailureResponse | unknown,
) {
super(message);
}
}
Loading

0 comments on commit b49cd08

Please sign in to comment.