Skip to content

Commit

Permalink
feat: create package
Browse files Browse the repository at this point in the history
  • Loading branch information
boywithkeyboard committed May 29, 2024
0 parents commit 1a0a1cb
Show file tree
Hide file tree
Showing 11 changed files with 26,766 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
versioning-strategy: increase

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
71 changes: 71 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: update

on:
schedule:
- cron: 0 0 * * 5
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest

permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 18

- name: Install Dependencies
run: npm i

- name: Determine Version
uses: actions/github-script@v7
with:
script: |
const { readFileSync, writeFileSync } = require('node:fs')
const year = new Date().getFullYear().toString()
let month = new Date().getMonth() + 1
let day = new Date().getDate()
if (month < 10)
month = '0' + month.toString()
if (day < 10)
day = '0' + day.toString()
const version = `1.${year + month + day}.0`
core.exportVariable('VERSION', version)
const packageJson = JSON.parse(readFileSync('./package.json', { encoding: 'utf-8' }))
packageJson.version = version
writeFileSync('./package.json', JSON.stringify(packageJson, null, 2))
- name: Build Package
run: npm run build

- name: Publish Package
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
provenance: true

- name: Commit Changes
run: |
git config --global user.name "GitHub"
git config --global user.email "noreply@github.com"
git commit -am "refactor: autoupdate"
git push
- name: Create Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create $VERSION --title $VERSION
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
node_modules
spec.ts
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
13 changes: 13 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import _createClient from 'openapi-fetch'
import { paths } from './spec'

export type Client = ReturnType<typeof _createClient<paths>>

export function createClient({ token }: { token: string }) {
return _createClient<paths>({
baseUrl: 'https://api.vultr.com/v2',
headers: {
Authorization: `Bearer ${token}`
}
})
}
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) 2024 Samuel Kopp

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.
47 changes: 47 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "vultr-api-client",
"version": "1.20240529.0",
"author": "Samuel Kopp (https://samuelkopp.de)",
"license": "MIT",
"description": "A preconfigured, up-to-date OpenAPI client for Vultr.",
"funding": "https://github.com/sponsors/boywithkeyboard",
"repository": "github:boywithkeyboard/vultr-api-client",
"keywords": [
"vultr",
"openapi"
],
"main": "./build/index.cjs",
"module": "./build/index.mjs",
"types": "./build/index.d.ts",
"files": [
"./build"
],
"exports": {
".": {
"import": {
"default": "./build/index.mjs",
"types": "./build/index.d.ts"
},
"require": {
"default": "./build/index.cjs",
"types": "./build/index.d.ts"
}
}
},
"scripts": {
"download": "openapi-typescript ./spec.json -o ./spec.ts",
"build": "npm run download && tsc && esbuild index.ts --bundle --minify --format=esm --outfile=build/index.mjs && esbuild index.ts --bundle --minify --format=cjs --outfile=build/index.cjs"
},
"dependencies": {
"openapi-fetch": "^0.9.7"
},
"devDependencies": {
"@types/node": "^20.12.12",
"esbuild": "^0.21.4",
"openapi-typescript": "^6.7.6",
"typescript": "^5.4.5"
},
"engines": {
"node": ">=18"
}
}
19 changes: 19 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## vultr-api-client

This package is **auto-generated** from Vultr's OpenAPI specification.

### Setup

```bash
npm i vultr-api-client
```

### Usage

```ts
import { createClient } from 'vultr-api-client'

const client = createClient({
token: '...'
})
```
Loading

0 comments on commit 1a0a1cb

Please sign in to comment.