Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirasaki committed Nov 11, 2024
1 parent fca742c commit 0cf167f
Show file tree
Hide file tree
Showing 24 changed files with 1,634 additions and 58 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
target-branch: deps # Branch to create PRs against
schedule:
interval: "weekly"
71 changes: 71 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '41 4 * * 6'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ javascript-typescript ]
# CodeQL supports [ $supported-codeql-languages ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
79 changes: 79 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Deploy

on:
workflow_dispatch:
workflow_run:
workflows: [Release]
types:
- completed

jobs:
notify-start:
runs-on: ubuntu-latest
steps:
- name: Discord Webhook - Notify Start Deploy
uses: tsickert/[email protected]
continue-on-error: true
with:
username: "Mirasaki Development CI/CD"
avatar-url: "https://mirasaki.dev/logo.png"
webhook-url: ${{ secrets.DEPLOYMENT_WEBHOOK_URL }}
embed-author-name: "Continuous Deployment by Mirasaki Development"
embed-author-url: "https://mirasaki.dev"
embed-author-icon-url: "https://mirasaki.dev/logo.png"
embed-color: 14228765
embed-title: "⬇️ cftools.js"
embed-description: "⌛ Deploying **`@${{ github.repository }}`**...\n📤 Service is now temporarily unavailable."

deploy:
permissions:
id-token: write
contents: read
name: deploy
needs: notify-start
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Fetch Teleport binaries
uses: teleport-actions/setup@v1
with:
version: 16.4.0
- name: Fetch credentials using Machine ID
id: auth
uses: teleport-actions/auth@v2
with:
proxy: tp.mirasaki.dev:443
token: deploy-bot
certificate-ttl: 1h
anonymous-telemetry: 1
- name: SSH into Server and Prepare Environment
run: |
tsh ssh [email protected] << 'ENDSSH'
cd /var/www/cftools.js
echo "Pulling latest changes..."
git pull origin main
echo "Installing development dependencies..."
npm install
echo "Building the project's documentation..."
npm run build:docs
exit
ENDSSH
notify-finish:
needs: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Discord Webhook - Notify Finish Deploy
uses: tsickert/[email protected]
with:
username: "Mirasaki Development CI/CD"
avatar-url: "https://mirasaki.dev/logo.png"
webhook-url: ${{ secrets.DEPLOYMENT_WEBHOOK_URL }}
embed-author-name: "Continuous Deployment by Mirasaki Development"
embed-author-url: "https://mirasaki.dev"
embed-author-icon-url: "https://mirasaki.dev/logo.png"
embed-color: 9559538
embed-title: "⬆️ cftools.js"
embed-description: "✅ Finished deploying **`@${{ github.repository }}`**\n📥 [Service](https://cftools.mirasaki.dev) is back online"
49 changes: 49 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# ESLint is a tool for identifying and reporting on patterns
# found in ECMAScript/JavaScript code.
# More details at https://github.com/eslint/eslint
# and https://eslint.org

name: ESLint

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]

jobs:
eslint:
name: Run eslint scanning
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Sarif Formatter
run: |
npm install @microsoft/[email protected]
- name: Run ESLint
run: npx eslint .
--config .eslintrc.json
--ext .js,.jsx,.ts,.tsx
--format @microsoft/eslint-formatter-sarif
--output-file eslint-results.sarif
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: eslint-results.sarif
wait-for-processing: true
50 changes: 50 additions & 0 deletions .github/workflows/publish-node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#example-workflow

name: Node.js Package

on:
workflow_dispatch:
workflow_run:
workflows: [Release]
types:
- completed

jobs:
publish-npm:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: https://registry.npmjs.org/
- run: npm install
# NPM doesn't install devDependencies when a user downloads our package
# but it sill counts them in the project dependency count.
- run: npm pkg delete devDependencies
- run: npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} # Use your npm token here

publish-gpr:
needs: [publish-npm]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://npm.pkg.github.com'
- run: npm install
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Local Development
Todo.md

# Documentation
docs/

# Logs
logs
*.log
Expand Down
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
# cftools.js
<p align="center"><img src="https://github.com/user-attachments/assets/0f9a7b07-1573-4f00-a648-1ad6ee62c6fa" alt="CFTools Logo" height="60" style="border-radius:50px"/></p>
<h1 align="center">cftools.js</h1>
<p align="center">
Remotely manage your game-server through <a href="https://cftools.com/">CFTools Cloud</a>. This package provides convenience methods around it's Data API, and provides 100% coverage of it's endpoints and capabilities. TypeScript implementation to be used in NodeJS, JavaScript, and TypeScript projects.
</p>

Remotely manage your game-server through [CFTools Cloud](https://cftools.com/). This package provides convenience methods around it's Data API. TypeScript implementation.
## Installation

```bash
npm install cftools.js --save
```

## Usage

The main entrypoint for this package/library is the `CFToolsClient`. It provides convenience methods to interact with the API, and provides 100% coverage of the Data API.

```js
import { CFToolsClient } from 'cftools.js'; // ESM
const { CFToolsClient } = require('cftools.js'); // CommonJS

// Instantiate our client, the `serverApiId` can be
// omitted and overwritten in individual requests
const client = new CFToolsClient({
applicationId: process.env.CFTOOLS_APPLICATION_ID,
applicationSecret: process.env.CFTOOLS_APPLICATION_SECRET,
serverApiId: process.env.CFTOOLS_SERVER_API_ID,
});

// Do something with the client
```

## Documentation

This library provides rich comments and IntelliSense for API calls implemented in this interface, we also provide detailed guides and documentation to get you started quickly.

- For a complete example, check out [the usage guide](./documents/Usage.md).
- For the complete API reference/documentation, please check out [the docs](https://cftools.mirasaki.dev/).

## Contribution

This is open-source software **for** the community, **by** the community. It is therefor open to contributions of any kind, be it documentation or implementing new API endpoints - your contributions are welcome and appreciated! Get started by [forking the repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) and [creating a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).

> This library is **not** an official wrapper, it is not made or maintained by the CFTools team.
Loading

0 comments on commit 0cf167f

Please sign in to comment.