Skip to content

Commit

Permalink
[add] GitHub Issue forms & repository settings
Browse files Browse the repository at this point in the history
[add] VS Code extensions configuration
[optimize] simplify some Type & Logic details
  • Loading branch information
TechQuery committed Dec 23, 2023
1 parent 3c3543a commit 89e0088
Show file tree
Hide file tree
Showing 12 changed files with 358 additions and 54 deletions.
187 changes: 187 additions & 0 deletions .github/ISSUE_TEMPLATE/developer-bug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
name: 🐛 Developer Bug report
description: File a Code bug/issue
title: <title>
labels:
- bug
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues
required: true

- type: textarea
attributes:
label: Current Behavior
description: A concise description of what you're experiencing.
validations:
required: true

- type: textarea
attributes:
label: Expected Behavior
description: A concise description of what you expected to happen.
validations:
required: true

- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: true

- type: dropdown
id: system
attributes:
label: On which operating system are you experiencing the problem?
multiple: true
options:
- BSD
- Linux
- Windows
- MacOS
- iOS
- Android
validations:
required: true

- type: input
id: system-version
attributes:
label: The version of your Operation System
validations:
required: true

- type: dropdown
id: subsystem
attributes:
label: What subsystem is the problem related to?
multiple: true
options:
- Docker
- WSL
- WINE

- type: input
id: subsystem-version
attributes:
label: The version of your Sub-system

- type: dropdown
id: Web-browser
attributes:
label: What browsers are you seeing the problem on?
multiple: true
options:
- Firefox
- Chrome
- Safari
- Microsoft Edge
- Opera
- Brave
- Arc Browser
- UC Browser
validations:
required: true

- type: input
id: Web-browser-version
attributes:
label: The version of your Web browser
validations:
required: true

- type: dropdown
id: network-region
attributes:
label: What network region are you in?
multiple: true
options:
- Global
- China mainland
validations:
required: true

- type: dropdown
id: cli
attributes:
label: Which command line terminal are you using?
multiple: true
options:
- Shell
- CMD
- Powershell
validations:
required: true

- type: input
id: cli-version
attributes:
label: The version of your Command-line Terminal

- type: dropdown
id: JavaScript-runtime
attributes:
label: Which JavaScript runtime are you using?
multiple: true
options:
- Node.js
- Bun
- Deno
validations:
required: true

- type: input
id: JavaScript-runtime-version
attributes:
label: The version of your JavaScript runtime
validations:
required: true

- type: dropdown
id: JavaScript-package-manager
attributes:
label: Which JavaScript package manager are you using?
multiple: true
options:
- npm
- Yarn
- pnpm
- Bun
validations:
required: true

- type: input
id: JavaScript-package-manager-version
attributes:
label: The version of your JavaScript package manager
validations:
required: true

- type: dropdown
id: development_environment
attributes:
label: Which development environment are you using?
multiple: true
options:
- Local
- Gitpod
- GitHub Codespaces
validations:
required: true

- type: textarea
attributes:
label: Anything else?
description: |
Links? References? Anything that will give us more context about the issue you are encountering!
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-enhancement.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: ✨ Feature/Enhancement
description: Request a new feature or enhancement
title: <title>
labels:
- enhancement
body:
- type: checkboxes
attributes:
label: Is there an existing feature request for this?
description: Please search to see if a feature request already exists for the enhancement you are proposing.
options:
- label: I have searched the existing feature requests
required: true

- type: textarea
attributes:
label: Description
description: |
A detailed description of the new feature or enhancement you are proposing. Additionally, provide any relevant
links, references, or attachments to offer more context about the proposal. You can also attach images or other
files by clicking this area to highlight it and then dragging files in.
Tip: You can attach images or other files by clicking this area to highlight it and then dragging files in.
validations:
required: true

- type: textarea
attributes:
label: Use Case
description: Provide a use case or scenario where this feature or enhancement would be beneficial.

- type: textarea
attributes:
label: Proposed Solution
description: If you have a specific solution in mind, please describe it here.
85 changes: 85 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# These settings are synced to GitHub by https://probot.github.io/apps/settings/

repository:
allow_merge_commit: false

delete_branch_on_merge: true

enable_vulnerability_alerts: true

labels:
- name: bug
color: '#d73a4a'
description: Something isn't working

- name: documentation
color: '#0075ca'
description: Improvements or additions to documentation

- name: duplicate
color: '#cfd3d7'
description: This issue or pull request already exists

- name: enhancement
color: '#a2eeef'
description: Some improvements

- name: feature
color: '#16b33f'
description: New feature or request

- name: good first issue
color: '#7057ff'
description: Good for newcomers

- name: help wanted
color: '#008672'
description: Extra attention is needed

- name: invalid
color: '#e4e669'
description: This doesn't seem right

- name: question
color: '#d876e3'
description: Further information is requested

- name: wontfix
color: '#ffffff'
description: This will not be worked on

branches:
- name: main
# https://docs.github.com/en/rest/reference/repos#update-branch-protection
protection:
# Required. Require at least one approving review on a pull request, before merging. Set to null to disable.
required_pull_request_reviews:
# The number of approvals required. (1-6)
required_approving_review_count: 1
# Dismiss approved reviews automatically when a new commit is pushed.
dismiss_stale_reviews: true
# Blocks merge until code owners have reviewed.
require_code_owner_reviews: true
# Specify which users and teams can dismiss pull request reviews.
# Pass an empty dismissal_restrictions object to disable.
# User and team dismissal_restrictions are only available for organization-owned repositories.
# Omit this parameter for personal repositories.
dismissal_restrictions:
# users: []
# teams: []
# Required. Require status checks to pass before merging. Set to null to disable
required_status_checks:
# Required. Require branches to be up to date before merging.
strict: true
# Required. The list of status checks to require in order to merge into this branch
contexts: []
# Required. Enforce all configured restrictions for administrators.
# Set to true to enforce required status checks for repository administrators.
# Set to null to disable.
enforce_admins: true
# Prevent merge commits from being pushed to matching branches
required_linear_history: true
# Required. Restrict who can push to this branch.
# Team and user restrictions are only available for organization-owned repositories.
# Set to null to disable.
restrictions: null
15 changes: 15 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"recommendations": [
"yzhang.markdown-all-in-one",
"redhat.vscode-yaml",
"akamud.vscode-caniuse",
"visualstudioexptteam.intellicode-api-usage-examples",
"pflannery.vscode-versionlens",
"christian-kohler.npm-intellisense",
"esbenp.prettier-vscode",
"rangav.vscode-thunder-client",
"eamodio.gitlens",
"github.vscode-pull-request-github",
"github.vscode-github-actions"
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobx-lark",
"version": "1.1.0-rc.0",
"version": "1.1.0",
"license": "LGPL-3.0",
"author": "shiy2008@gmail.com",
"description": "Unofficial TypeScript SDK for FeiShu/Lark API, which is based on MobX-RESTful.",
Expand Down
32 changes: 10 additions & 22 deletions src/Lark.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context, HTTPClient, HTTPError, makeFormData, request } from 'koajax';
import { Context, HTTPClient, makeFormData } from 'koajax';
import { buildURLData, cache, Second } from 'web-utility';

import {
Expand Down Expand Up @@ -113,7 +113,7 @@ export class LarkApp implements LarkAppOption {
async getUserMeta(code: string) {
await this.getAccessToken();

const { body } = await this.client.post<UserMeta>(
const { body } = await this.client.post<LarkData<UserMeta>>(
'authen/v1/access_token',
{ grant_type: 'authorization_code', code }
);
Expand All @@ -126,7 +126,8 @@ export class LarkApp implements LarkAppOption {
getJSTicket = cache(async clean => {
await this.getAccessToken();

const { body } = await this.client.post<JSTicket>('jssdk/ticket/get');
const { body } =
await this.client.post<LarkData<JSTicket>>('jssdk/ticket/get');
const { expire_in, ticket } = body!.data!;

setTimeout(clean, expire_in * Second);
Expand Down Expand Up @@ -155,32 +156,19 @@ export class LarkApp implements LarkAppOption {
parent_type: UploadTargetType,
parent_node: string
) {
const token = await this.getAccessToken();
await this.getAccessToken();

const body = makeFormData({
const form = makeFormData({
file,
file_name: file.name,
size: file.size,
parent_type,
parent_node
});
const { response } = request<LarkData<{ file_token: string }>>({
method: 'POST',
path: this.client.baseURI + 'drive/v1/medias/upload_all',
headers: { Authorization: `Bearer ${token}` },
body
});
const res = await response;

if (res.status < 300) return res.body!.data!.file_token;
const { body } = await this.client.post<
LarkData<{ file_token: string }>
>('drive/v1/medias/upload_all', form);

const error = res.body as unknown as Blob;

const raw = new TextDecoder().decode(await error.arrayBuffer());

throw new HTTPError(res.statusText, {
...res,
body: JSON.parse(raw)
});
return body!.data!.file_token;
}
}
Loading

0 comments on commit 89e0088

Please sign in to comment.