Skip to content

Commit

Permalink
Fix majority of lints
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Oct 8, 2024
1 parent 6fc38c7 commit 058b3c7
Show file tree
Hide file tree
Showing 9 changed files with 2,362 additions and 1,772 deletions.
47 changes: 0 additions & 47 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env node
#!/usr/bin/env node

import fs from 'node:fs';
import path from 'node:path';
Expand All @@ -23,7 +23,7 @@ const argv = minimist(process.argv, {

if (argv.version) {
console.log('openaddresses-deploy@' + JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url))).version);
process.exit(0)
process.exit(0);
}

if (!argv._[2] || argv._[2] === 'help' || (!argv._[2] && argv.help)) Help.main();
Expand Down
11 changes: 5 additions & 6 deletions lib/artifacts/docker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ECRClient, BatchGetImageCommand } from '@aws-sdk/client-ecr';
import path from 'path';
import fs from 'fs';
import Handlebars from 'handlebars';

Expand All @@ -12,7 +11,7 @@ const MAX_RETRIES = 60;
* @param {Credentials} creds Credentials
*/
export default async function check(creds) {
let images = [];
const images = [];

// docker check explicitly disabled
if (
Expand All @@ -27,17 +26,17 @@ export default async function check(creds) {
// No dotdeploy or docker file found
try {
fs.accessSync('./Dockerfile');
} catch(err) {
} catch (err) {
return;
}

images.push(`{{project}}:{{gitsha}}`);
images.push('{{project}}:{{gitsha}}');
} else if (
creds.dotdeploy.artifacts
&& creds.dotdeploy.artifacts.docker
) {
if (typeof creds.dotdeploy.artifacts.docker === 'string') {
images.push(creds.dotdeploy.artifacts.docker)
images.push(creds.dotdeploy.artifacts.docker);
} else {
creds.dotdeploy.artifacts.docker.forEach((image) => {
images.push(image);
Expand Down Expand Up @@ -80,7 +79,7 @@ function single(creds, image) {
}));

if (data && data.images.length) {
console.log(`Found Docker Image: AWS::ECR:${image}`)
console.log(`Found Docker Image: AWS::ECR:${image}`);
return resolve(image);
} else if (retries[image] < MAX_RETRIES) {
if (retries[image] === 0) console.log(`Waiting for Docker Image: AWS::ECR: ${image}`);
Expand Down
10 changes: 4 additions & 6 deletions lib/artifacts/lambda.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { S3Client, HeadObjectCommand } from '@aws-sdk/client-s3';
import path from 'path';
import fs from 'fs';
import Handlebars from 'handlebars';

const retries = {};
Expand All @@ -12,7 +10,7 @@ const MAX_RETRIES = 60;
* @param {Credentials} creds Credentials
*/
export default async function check(creds) {
let lambdas = [];
const lambdas = [];

// docker check explicitly disabled
if (
Expand All @@ -25,7 +23,7 @@ export default async function check(creds) {
&& creds.dotdeploy.artifacts.lambda
) {
if (typeof creds.dotdeploy.artifacts.lambda === 'string') {
lambdas.push(creds.dotdeploy.artifacts.lambda)
lambdas.push(creds.dotdeploy.artifacts.lambda);
} else {
creds.dotdeploy.artifacts.lambda.forEach((l) => {
lambdas.push(l);
Expand All @@ -40,7 +38,7 @@ export default async function check(creds) {
return true;
}

function single(creds, lambda, cb) {
function single(creds, lambda) {
return new Promise((resolve, reject) => {
const s3 = new S3Client({
credentials: creds.aws,
Expand All @@ -64,7 +62,7 @@ function single(creds, lambda, cb) {
}));

if (data && data.ContentLength) {
console.log(`Found Lambda: ${lambda}`)
console.log(`Found Lambda: ${lambda}`);
return resolve(lambda);
} else {
return reject(new Error(`No lambda found for: ${lambda}`));
Expand Down
3 changes: 3 additions & 0 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export default class Credentials {
creds.repo = Git.repo();
creds.sha = Git.sha();

if (!creds.repo) throw new Error('No Git Repo detected! Are you in the correct directory? Or did you download a static non-git copy of the repo?');
if (!creds.sha) throw new Error('Could not determine git sha');

// If GH deployment has been requested, store ID here
creds.deployment = false;

Expand Down
1 change: 1 addition & 0 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class Init {
creds = await fs.readFile(path.resolve(process.env.HOME, '.deployrc.json'));
creds = JSON.parse(creds);
} catch (err) {
console.log(`Could not find .deployrc.json (${err.message})`);
creds = {};
}

Expand Down
4 changes: 2 additions & 2 deletions lib/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default class Tags extends Array {
for (const tag of context.tags) {
if (typeof tag !== 'string') {
known[tag.Key] = tag.Value;
tagSet.add(tag.Key)
tagSet.add(tag.Key);
} else {
tagSet.add(tag)
tagSet.add(tag);
}
}

Expand Down
Loading

0 comments on commit 058b3c7

Please sign in to comment.