Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #68

Merged
merged 20 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
# editorconfig-tools is unable to ignore longs strings or urls
max_line_length = off

[CHANGELOG.md]
indent_size = false
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
env: {
node: true,
commonjs: true,
es2021: true,
},
extends: [
'airbnb-base',
'plugin:ava/recommended',
],
plugins: [
'ava',
],
parserOptions: {
ecmaVersion: 'latest',
},
rules: {
'max-len': 'off',
'no-console': 'off',
},
};
19 changes: 19 additions & 0 deletions .github/workflows/codacy-coverage-reporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: codacy-coverage-reporter

on: ["push"]

jobs:
codacy-coverage-reporter:
runs-on: ubuntu-latest
name: codacy-coverage-reporter
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v2
with:
node-version: 14.x
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
- uses: actions/checkout@v2
24 changes: 24 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Node.js CI

on:
push

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@ const Koa = require('koa');
const serve = require('koa-static');
const logger = require('koa-logger');
const fs = require('fs');
const path = require('path')
const path = require('path');

const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const argv = yargs(hideBin(process.argv)).argv;
const {argv} = yargs(hideBin(process.argv));
const { argv } = yargs(hideBin(process.argv));

// Version only comes in when run with NPM, so make this optional
let antennasVersion = process.env.npm_package_version ? `v${process.env.npm_package_version}` : '';
const antennasVersion = process.env.npm_package_version ? `v${process.env.npm_package_version}` : '';
if (argv.nologo) {
console.log(`Antennas ${antennasVersion}`);
} else {
const logoFile = path.join('assets', 'logo.txt');
const logo = fs.readFileSync(path.resolve(__dirname, logoFile), 'utf8');
console.log('\x1b[34m%s\x1b[0m', logo, antennasVersion);
}
console.log(``)
console.log('');

// Load config
const configHandler = require('./src/configHandler');

const config = argv.config ? configHandler.loadConfig(argv.config) : configHandler.loadConfig();

// Setup Antenna components
Expand All @@ -41,19 +43,17 @@ try {
.use(router.routes())
.use(router.allowedMethods())
.use(serve(path.resolve(__dirname, 'public'), { extensions: true }))
.use(async function pageNotFound(ctx) {
.use(async (ctx) => {
ctx.status = 404;
ctx.type = 'html';
ctx.body = fs.createReadStream(path.resolve(__dirname, path.join('public', '404.html')));
});

app.listen(5004);

console.log(`📡 Antennas are deployed! Proxying from ${config.antennas_url}`);
ssdp.broadcastSSDP(device);
} catch (e) {
console.log('❌ Antennas failed to deploy! 😮 It could be missing a config file, or something is misconfigured. See below for details:');
console.log(e);
}


Loading