Skip to content

Commit 489ef97

Browse files
committed
initial version
0 parents  commit 489ef97

8 files changed

Lines changed: 152 additions & 0 deletions

File tree

.github/workflows/npm_release.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish Package to npmjs
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
id-token: write
11+
steps:
12+
- uses: actions/checkout@v5
13+
# Setup .npmrc file to publish to npm
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: '22.x'
17+
registry-url: 'https://registry.npmjs.org'
18+
- run: npm ci
19+
- run: npm publish --provenance --access public
20+
env:
21+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22+

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
vendor
2+
node_modules
3+
dist
4+
.openapi-generator
5+
.openapi-generator-ignore

conf/openapi_config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"paramNaming": "snake_case",
3+
"enumPropertyNaming": "snake_case",
4+
"modelPropertyNaming": "snake_case",
5+
"useSingleRequestParameter": "true",
6+
"stringEnums": true,
7+
"enumNameSuffix": "Enum"
8+
}

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@bitly/api-client",
3+
"version": "0.0.1",
4+
"description": "Bitly API Client",
5+
"keywords": [
6+
"Bitly",
7+
"Bitly API",
8+
"Bitly node API",
9+
"Link Shortening",
10+
"QR Codes"
11+
],
12+
"homepage": "https://github.com/bitly/bitlyapi.js#readme",
13+
"bugs": {
14+
"url": "https://github.com/bitly/bitlyapi.js/issues"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "git+https://github.com/bitly/bitlyapi.js.git"
19+
},
20+
"license": "ISC",
21+
"author": "",
22+
"type": "commonjs",
23+
"main": "dist/index.js",
24+
"typings": "dist/index.d.ts",
25+
"scripts": {
26+
"build": "tsc"
27+
},
28+
"files": ["dist"],
29+
"devDependencies": {
30+
"typescript": "^5.9.3"
31+
}
32+
}

scripts/generate_ts_api.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
SCRIPT_PATH=$(readlink -f "$0")
3+
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
4+
VENDOR_DIR=$SCRIPT_DIR/../vendor
5+
6+
set -e
7+
8+
# fetch current openapi spec
9+
if [ ! -e $VENDOR_DIR/v4.json ]; then
10+
echo "downloading API spec"
11+
mkdir -p $VENDOR_DIR
12+
wget https://dev.bitly.com/v4/v4.json -O $VENDOR_DIR/v4.json
13+
fi
14+
15+
./openapi-generator-cli.sh generate \
16+
--input-spec $VENDOR_DIR/v4.json \
17+
--generator-name typescript-fetch \
18+
--config ../conf/openapi_config.json \
19+
--output ../src

scripts/openapi-generator-cli.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
SCRIPT_PATH=$(readlink -f "$0")
3+
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
4+
VENDOR_DIR=$SCRIPT_DIR/../vendor
5+
6+
# https://github.com/OpenAPITools/openapi-generator/releases
7+
VERSION=7.16.0
8+
SOURCE=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${VERSION}/openapi-generator-cli-${VERSION}.jar
9+
FILENAME=$(basename $SOURCE)
10+
mkdir -p $VENDOR_DIR
11+
set -e
12+
if [ ! -f $VENDOR_DIR/$FILENAME ]; then
13+
echo "Downloading OpenAPI Generator CLI version $VERSION"
14+
wget $SOURCE -O $VENDOR_DIR/$FILENAME
15+
fi
16+
exec java -jar $VENDOR_DIR/$FILENAME "$@"

tsconfig.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"declaration": true,
4+
"target": "es5",
5+
"module": "commonjs",
6+
"moduleResolution": "node",
7+
"outDir": "dist",
8+
"lib": [
9+
"es6",
10+
"dom"
11+
],
12+
"typeRoots": [
13+
"node_modules/@types"
14+
]
15+
},
16+
"exclude": [
17+
"dist",
18+
"node_modules"
19+
]
20+
}

0 commit comments

Comments
 (0)