Skip to content

Commit

Permalink
Add dotenv, dev greenlight URL, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
harveysanders committed Jan 30, 2024
1 parent 5b42af1 commit 7e221d3
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 18 deletions.
9 changes: 8 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
{
"name": "Node.js",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye"
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye",
"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode"
]
}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
plugins: ['import'],
rules: {
// enable additional rules
quotes: ['error', 'single'],
quotes: ['error', 'single', { "avoidEscape": true }],
semi: ['error', 'always'],

// disable rules from base configurations
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ test/files/environment/projects
.secrets

user
auth
auth
.env*
6 changes: 6 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { GREENLIGHT_HOST, NODE_ENV } = process.env;

module.exports = {
isDevMode: NODE_ENV === 'development',
devGreenlightHost: GREENLIGHT_HOST || 'http://localhost:3000'
};
6 changes: 3 additions & 3 deletions controller/greenlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ const clc = require('cli-color');
const rp = require('request-promise');

const github = require('./github');
const { devGreenlightHost, isDevMode } = require('../config');

// TODO: Switch URI for live version
const LOCALHOST = 'http://localhost:3000';
const GREENLIGHT = 'https://greenlight.operationspark.org';
const URI = GREENLIGHT;
// TODO: Switch URI for live version
const URI = isDevMode ? devGreenlightHost : GREENLIGHT;

module.exports.URI = URI;

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env node

'use strict';

require('dotenv').config();
const program = require('commander');
const fs = require('fs');
const pjson = require('./package.json');
Expand Down
14 changes: 13 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"cli-view": "^1.0.0",
"commander": "^2.11.0",
"cross-env": "^7.0.3",
"dotenv": "^16.4.1",
"express": "^4.15.3",
"fs-extra": "^11.2.0",
"fs-json": "^0.1.2",
Expand Down
12 changes: 6 additions & 6 deletions test/test-auto-install-projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ const projects = proxyquire('../controller/projects', {
}
});

const readAndParse = path => JSON.parse(fs.readFileSync(path));
//recursively grabs projects
const readAndParse = path => JSON.parse(fs.readFileSync(path, 'utf-8'));
// recursively grabs projects

describe('#installProject()', function () {
dummySession.PROJECT.forEach((project) => {
dummySession.PROJECT.forEach(project => {
it(`should install project for ${project.name}`, function (done) {
projects.installProject(project).then(function (results) {
expect(results).to.be.an.object;
expect(results).to.be.an('object');
expect(results.name).to.exist;
expect(results._id).to.exist;
expect(results.desc).to.exist;
expect(results.url).to.exist;
done();
});
})
});
});
});
});
8 changes: 4 additions & 4 deletions test/test-projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('projects', function () {
projects
.selectProject({ session: dummySession, projectAction: 'install' })
.then(function (project) {
expect(project).to.be.an.object;
expect(project).to.be.an('object');
expect(project.name).to.equal('Function Master');
expect(project._id).to.exist;
expect(project._session).to.exist;
Expand All @@ -107,7 +107,7 @@ describe('projects', function () {
projects
.selectProject({ session: dummySession, projectAction: 'install' })
.then(function (project) {
expect(project).to.be.an.object;
expect(project).to.be.an('object');
expect(project.name).to.equal('Function Master');
expect(project._id).to.exist;
expect(project._session).to.exist;
Expand All @@ -129,7 +129,7 @@ describe('projects', function () {

it('should install project', function (done) {
projects.installProject(dummySession.PROJECT[2]).then(function (project) {
expect(project).to.be.an.object;
expect(project).to.be.an('object');
expect(project.name).to.equal('Matchy');
expect(project._id).to.exist;
expect(project._session).to.exist;
Expand All @@ -141,7 +141,7 @@ describe('projects', function () {

it('should install project', function (done) {
projects.installProject(dummySession.PROJECT[3]).then(function (project) {
expect(project).to.be.an.object;
expect(project).to.be.an('object');
expect(project.name).to.equal('Function Master');
expect(project._id).to.exist;
expect(project._session).to.exist;
Expand Down

0 comments on commit 7e221d3

Please sign in to comment.