Skip to content

Commit

Permalink
refactor: Switching to TypeScript (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
IAreKyleW00t authored Sep 9, 2024
1 parent a90e6d8 commit 3e53fcd
Show file tree
Hide file tree
Showing 31 changed files with 45,759 additions and 263 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
lib/
dist/
node_modules/
coverage/
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf

dist/** -diff linguist-generated=true
14 changes: 11 additions & 3 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
# Security Policy

This project would like to make sure that it stays on top of all vulnerabilities
and address them within a reasonable time. This is done in good faith and best
effort.
and address them within a reasonable time and/or report them to appropriate
upstream project. This is done in good faith and best effort.

## Supported Versions

| Version | Supported |
| ---------- | --------- |
| `>= 1.0.0` ||
| `>= 3.0.0` ||
| `2.x.x` | ⚠️ |
| `1.x.x` | ⚠️ |

`v1` and `v2` will be maintained for critical issues.

## Reporting a Vulnerability

For security related issues with **this project**, please report it privately
using the
[Report a Vulnerability](https://github.com/IAreKyleW00t/crane-installer/security/advisories/new)
form including as much detail as possible.

For security related issues with **crane**, please report it to their respective
project using their guidelines.
<https://github.com/google/go-containerregistry>
14 changes: 10 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
# Maintain GitHub Actions dependencies
- package-ecosystem: github-actions
directory: /
schedule:
interval: "daily"
interval: daily

# Maintain JavaScript dependencies
- package-ecosystem: npm
directory: /
schedule:
interval: daily
80 changes: 80 additions & 0 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
env:
node: true
es6: true
jest: true

globals:
Atomics: readonly
SharedArrayBuffer: readonly

ignorePatterns:
- '!.*'
- '**/node_modules/.*'
- '**/dist/.*'
- '**/coverage/.*'
- '*.json'

parser: '@typescript-eslint/parser'

parserOptions:
ecmaVersion: 2023
sourceType: module
project:
- './.github/linters/tsconfig.json'
- './tsconfig.json'

plugins:
- jest
- '@typescript-eslint'

extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:github/recommended
- plugin:jest/recommended

rules:
{
'camelcase': 'off',
'eslint-comments/no-use': 'off',
'eslint-comments/no-unused-disable': 'off',
'i18n-text/no-en': 'off',
'import/no-namespace': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'error',
'semi': 'off',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/explicit-member-accessibility':
['error', { 'accessibility': 'no-public' }],
'@typescript-eslint/explicit-function-return-type':
['error', { 'allowExpressions': true }],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/unbound-method': 'error'
}
18 changes: 18 additions & 0 deletions .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Unordered list style
MD004:
style: dash

# Ordered list item prefix
MD029:
style: one

# Spaces after list markers
MD030:
ul_single: 1
ol_single: 1
ul_multi: 1
ol_multi: 1

# Code block style
MD046:
style: fenced
10 changes: 10 additions & 0 deletions .github/linters/.yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules:
document-end: disable
document-start:
level: warning
present: false
line-length:
level: warning
max: 80
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
9 changes: 9 additions & 0 deletions .github/linters/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true
},
"include": ["../../__tests__/**/*", "../../src/**/*"],
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
}
55 changes: 55 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Transpiled JavaScript

on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: .node-version
cache: npm

- name: Install Dependencies
run: npm ci

- name: Build dist/ Directory
run: npm run bundle

- name: Compare Directories
id: compare
shell: bash
run: |
if [ ! -d dist/ ]; then
echo "::error::Expected dist/ directory does not exist"
exit 1
fi
[ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -eq 0 ] && DIFF=false || DIFF=true
echo "diff=$DIFF" | tee -a "$GITHUB_OUTPUT"
if [ "$DIFF" == "true" ]; then
echo "::error::Detected uncommitted changes after build"
exit 1
fi
- name: Upload dist/
if: (!cancelled()) && steps.compare.outputs.diff == 'true'
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: dist
path: dist/
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Continuous Integration

on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
test:
name: TypeScript Tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: .node-version
cache: npm

- name: Install Dependencies
run: npm ci

- name: Test
run: npm run ci-test

format:
name: Check formatting
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: .node-version
cache: npm

- name: Install Dependencies
run: npm ci

- name: Check Format
run: npm run format:check

lint:
name: Lint codebase
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: .node-version
cache: npm

- name: Install Dependencies
run: npm ci

- name: Lint
run: npm run lint
33 changes: 33 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CodeQL

on:
workflow_dispatch:
schedule:
- cron: '11 20 * * *'
pull_request:
branches:
- main
push:
branches:
- main

jobs:
codeql:
name: CodeQL scan
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Initialize CodeQL
uses: github/codeql-action/init@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
with:
languages: TypeScript
source-root: src

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
2 changes: 1 addition & 1 deletion .github/workflows/shared-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ run-name: ${{ github.ref_name }}
on:
push:
tags:
- "v*.*.*"
- 'v*.*.*'

jobs:
release:
Expand Down
Loading

0 comments on commit 3e53fcd

Please sign in to comment.