Skip to content

Commit

Permalink
Implement basic nvector/latlon conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Sep 30, 2023
1 parent 4b8a644 commit 37047b8
Show file tree
Hide file tree
Showing 25 changed files with 602 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/artifacts/
/node_modules/
96 changes: 96 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
module.exports = {
extends: [
"eslint:recommended",
"plugin:n/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:promise/recommended",
"prettier",
],
parserOptions: {
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
env: {
es2022: true,
node: true,
},
rules: {
"no-unused-vars": [
"error",
{
// allow unused args if they start with _
argsIgnorePattern: "^_",
},
],
// handled by import/no-unresolved
"n/no-missing-import": "off",
// don't check for unsupported features - too much config to make this work
"n/no-unsupported-features/es-builtins": "off",
"n/no-unsupported-features/es-syntax": "off",
"n/no-unsupported-features/node-builtins": "off",
},
overrides: [
{
files: ["*.ts", "*.tsx"],
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
parserOptions: {
project: "./tsconfig.json",
},
settings: {
"import/resolver": "typescript",
},
rules: {
"@typescript-eslint/no-unused-vars": [
"error",
{
// allow unused args if they start with _
argsIgnorePattern: "^_",
},
],
// this rule gets in the way of designing APIs
"@typescript-eslint/require-await": "off",
},
},
{
files: [
"*.spec.js",
"*.spec.jsx",
"*.spec.ts",
"*.spec.tsx",
"*.test.js",
"*.test.jsx",
"*.test.ts",
"*.test.tsx",
],
extends: ["plugin:jest/recommended"],
plugins: ["jest"],
env: {
jest: true,
},
rules: {
// focused tests that make it to CI will cause a build failure
"jest/no-focused-tests": "warn",

// allow expect inside fast-check tests
"jest/no-standalone-expect": [
"error",
{ additionalTestBlockFunctions: ["it.prop", "test.prop"] },
],

// allow custom expect functions
"jest/expect-expect": [
"warn",
{
assertFunctionNames: ["expect*"],
},
],
},
},
],
};
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
# TODO
# reviewers:
# - org/team
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
# TODO
# reviewers:
# - org/team
31 changes: 31 additions & 0 deletions .github/workflows/ci-scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI (scheduled)

on:
schedule:
- cron: 0 14 * * 0 # Sunday 2PM UTC = Monday 12AM AEST

jobs:
ci:
name: CI
runs-on: ubuntu-latest

services:
nvector-test-api:
image: ghcr.io/ezzatron/nvector-test-api
ports:
- 17357:8000

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Install dependencies
run: make link-dependencies

- name: Make
run: make ci
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
pull_request:

jobs:
ci:
name: CI
runs-on: ubuntu-latest

services:
nvector-test-api:
image: ghcr.io/ezzatron/nvector-test-api
ports:
- 17357:8000

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Install dependencies
run: make link-dependencies

- name: Make
run: make ci

- name: Publish coverage
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish package

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
publish:
runs-on: ubuntu-latest
name: Publish package

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: make link-dependencies

- name: Make
run: make ci

- name: Set package version
run: make set-package-version

- name: Publish package
if: success()
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish release

on:
push:
tags:
- "*"

jobs:
publish:
runs-on: ubuntu-latest
name: Publish release

permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Publish release
uses: ghalactic/github-release-from-tag@v5
with:
reactions: hooray,heart,rocket
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.makefiles/
/artifacts/
/node_modules/
/package-lock.json
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.github/
/.makefiles/
/artifacts/
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["prettier-plugin-organize-imports"]
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright © 2023 Erin Millard

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.
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export NODE_OPTIONS := --experimental-vm-modules --redirect-warnings=artifacts/node-warnings

CHANGELOG_TAG_URL_PREFIX := https://github.com/ezzatron/nvector-js/releases/tag/

################################################################################

-include .makefiles/Makefile
-include .makefiles/pkg/js/v1/Makefile
-include .makefiles/pkg/js/v1/with-npm.mk
-include .makefiles/pkg/js/v1/with-tsc.mk
-include .makefiles/pkg/changelog/v1/Makefile

.makefiles/%:
@curl -sfL https://makefiles.dev/v1 | bash /dev/stdin "$@"

################################################################################

artifacts/dist: tsconfig.build.json artifacts/link-dependencies.touch $(JS_SOURCE_FILES)
@rm -rf "$@"
$(JS_EXEC) tsc -p "$<"
@touch "$@"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# _n_-vector
15 changes: 15 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @type {import('jest').Config} */
const config = {
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.(t|j)sx?$": "@swc/jest",
},
transformIgnorePatterns: [],
coverageDirectory: "artifacts/coverage/jest",
collectCoverageFrom: ["<rootDir>/src/**/*"],
};

export default config;
54 changes: 54 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "nvector",
"version": "0.0.0",
"description": "TODO",
"keywords": [
"TODO"
],
"repository": "ezzatron/nvector",
"bugs": "https://github.com/ezzatron/nvector/issues",
"homepage": "https://github.com/ezzatron/nvector",
"author": "Erin Millard <[email protected]>",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"type": "module",
"main": "artifacts/dist/index.js",
"types": "artifacts/dist/index.d.ts",
"exports": {
".": {
"types": "./artifacts/dist/index.d.ts",
"import": "./artifacts/dist/index.js",
"default": "./artifacts/dist/index.js"
}
},
"sideEffects": false,
"files": [
"/artifacts/dist/"
],
"scripts": {
"prepublishOnly": "tsc -p tsconfig.build.json"
},
"devDependencies": {
"@fast-check/jest": "^1.7.3",
"@jest/globals": "^29.7.0",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.5",
"@types/ws": "^8.5.5",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "^27.4.0",
"eslint-plugin-n": "^16.1.0",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.7.0",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",
"typescript": "^5.2.2",
"ws": "^8.14.2"
}
}
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
asyncio==3.4.3
numpy==1.26.0
nvector==0.7.7
websockets==11.0.3
Loading

0 comments on commit 37047b8

Please sign in to comment.