Skip to content

Commit a6ca015

Browse files
Merge pull request #73 from OperationSpark/72-remove-svn-dependency
Fix Tests
2 parents cc35fc7 + 0a99dc9 commit a6ca015

27 files changed

+2971
-1771
lines changed

.devcontainer/devcontainer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
3+
{
4+
"name": "Node.js",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye",
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"esbenp.prettier-vscode"
11+
]
12+
}
13+
}
14+
15+
// Features to add to the dev container. More info: https://containers.dev/features.
16+
// "features": {},
17+
18+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
19+
// "forwardPorts": [],
20+
21+
// Use 'postCreateCommand' to run commands after the container is created.
22+
// "postCreateCommand": "yarn install",
23+
24+
// Configure tool-specific properties.
25+
// "customizations": {},
26+
27+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
28+
// "remoteUser": "root"
29+
}

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
plugins: ['import'],
44
rules: {
55
// enable additional rules
6-
quotes: ['error', 'single'],
6+
quotes: ['error', 'single', { "avoidEscape": true }],
77
semi: ['error', 'always'],
88

99
// disable rules from base configurations
@@ -15,7 +15,7 @@ module.exports = {
1515
'func-names': 'off',
1616
'consistent-return': 'off',
1717
'prefer-arrow-callback': 'off',
18-
'arrow-parens': 'as-needed',
18+
'arrow-parens': 'off',
1919
// Windows friendly -- does not show errors on every line of every file
2020
'no-unused-vars': 1,
2121
'linebreak-style': 0

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: Ci
2-
on: [push, pull_request]
2+
on: [pull_request, workflow_dispatch]
33
jobs:
44
build:
55
runs-on: ubuntu-latest
66
steps:
7-
- uses: actions/checkout@v3
8-
- uses: actions/setup-node@v3
7+
- uses: actions/checkout@v4
8+
- uses: actions/setup-node@v4
99
with:
10-
node-version: "16"
10+
node-version: "20"
1111
- run: npm ci
1212
- run: npm test

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ test/files/environment/projects
4343
.secrets
4444

4545
user
46-
auth
46+
auth
47+
.env*

.prettierrc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"arrowParens": "avoid",
3+
"bracketSpacing": true,
4+
"endOfLine": "lf",
5+
"insertPragma": false,
6+
"singleAttributePerLine": false,
7+
"bracketSameLine": false,
8+
"jsxBracketSameLine": false,
9+
"jsxSingleQuote": false,
10+
"printWidth": 80,
11+
"proseWrap": "preserve",
12+
"quoteProps": "as-needed",
13+
"requirePragma": false,
14+
"semi": true,
15+
"singleQuote": true,
16+
"tabWidth": 2,
17+
"trailingComma": "none",
18+
"useTabs": false,
19+
"embeddedLanguageFormatting": "auto",
20+
"parser": "babel"
21+
}

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
"enterPartnerName": "Enter the GitHub username of your partner (you can ask them to type it)"}
1818
},
1919
"userAgent": "opspark"
20-
}
20+
}

controller/github.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ const util = require('util');
44
const prompt = require('inquirer').prompt;
55
const mkdirp = require('mkdirp');
66
const fsJson = require('fs-json')();
7-
const octonode = require('octonode');
8-
const rp = require('request-promise');
7+
98
const exec = require('child_process').exec;
109

1110
const env = require('./env');
1211
const config = require('../config.json');
13-
const janitor = require('./janitor');
1412
const {
1513
createGithubToken,
1614
deleteGithubToken,
@@ -95,6 +93,12 @@ function promptForUserInfo() {
9593

9694
module.exports.promptForUserInfo = promptForUserInfo;
9795

96+
/**
97+
*
98+
* @param {object} auth
99+
* @param {string} auth.token GitHub Personal Access Token
100+
* @returns {Promise<{token: string}>}
101+
*/
98102
function writeAuth(auth) {
99103
deleteAuth();
100104
console.log(clc.yellow('Writing auth. . .'));
@@ -137,8 +141,10 @@ function writeUser(auth) {
137141
const { id, message } = JSON.parse(stdout);
138142
if (err) {
139143
rej(err);
144+
return;
140145
} else if (message) {
141146
rej(message);
147+
return;
142148
}
143149
ensureApplicationDirectory();
144150
fsJson.saveSync(userFilePath, {
@@ -291,17 +297,14 @@ function grabLocalAuthToken() {
291297

292298
module.exports.grabLocalAuthToken = grabLocalAuthToken;
293299

294-
function deauthorizeUser() {
295-
return new Promise(function (res, rej) {
296-
promptForUserInfo()
297-
// .then(deleteAuth)
298-
.then(deleteUserInfo)
299-
.then(() => {
300-
console.log(clc.blue('Successfully logged out!'));
301-
res(true);
302-
})
303-
.catch(err => rej(`${err}`.red));
304-
});
300+
async function deauthorizeUser() {
301+
try {
302+
deleteUserInfo();
303+
console.log(clc.blue('Successfully logged out!'));
304+
return true;
305+
} catch (error) {
306+
return Promise.reject(clc.red(`${error}`));
307+
}
305308
}
306309

307310
module.exports.deauthorizeUser = deauthorizeUser;
@@ -336,6 +339,10 @@ function deleteUser() {
336339

337340
module.exports.deleteUser = deleteUser;
338341

342+
// TODO: Should be async
343+
/**
344+
* Deletes the auth and user files.
345+
*/
339346
function deleteUserInfo() {
340347
console.log(clc.red('Deleting files. . .'));
341348
deleteAuth();

controller/greenlight.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const clc = require('cli-color');
22
const rp = require('request-promise');
33

44
const github = require('./github');
5+
const { devGreenlightHost, isDevMode } = require('../dev-config');
56

6-
// TODO: Switch URI for live version
7-
const LOCALHOST = 'http://localhost:3000';
87
const GREENLIGHT = 'https://greenlight.operationspark.org';
9-
const URI = GREENLIGHT;
8+
// TODO: Switch URI for live version
9+
const URI = isDevMode ? devGreenlightHost : GREENLIGHT;
1010

1111
module.exports.URI = URI;
1212

controller/helpers.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports.execAsync = function execAsync(cmd) {
55
return new Promise((res, rej) => {
66
exec(cmd, (err, stdout, stderr) => {
77
if (err) return rej(err);
8-
return res(stdout, stderr);
8+
return res({ stdout, stderr });
99
});
1010
});
1111
};
@@ -27,7 +27,12 @@ module.exports.createGithubToken = function (username, password, note) {
2727
return `curl -u "${username}:${password}" -d '{"scopes":["public_repo", "repo", "gist"],"note":"${note}","note_url":"https://www.npmjs.com/package/opspark"}' https://api.github.com/authorizations`;
2828
};
2929

30-
module.exports.deleteGithubToken = function (username, password, userAgent, authID) {
30+
module.exports.deleteGithubToken = function (
31+
username,
32+
password,
33+
userAgent,
34+
authID
35+
) {
3136
return `curl -X "DELETE" -u "${username}:${password}" -A "${userAgent}" -H "Accept: application/json" https://api.github.com/authorizations/${authID}`;
3237
};
3338

@@ -63,11 +68,11 @@ module.exports.readGistHelper = function (url) {
6368
return `curl ${url}`;
6469
};
6570

66-
module.exports.installProjectDependenciesCmd = function(directory) {
71+
module.exports.installProjectDependenciesCmd = function (directory) {
6772
return `npm install --prefix ${directory} --loglevel=error`;
6873
};
6974

70-
module.exports.removeProjectTestsCmd = function(directory) {
75+
module.exports.removeProjectTestsCmd = function (directory) {
7176
return `rm -rf ${directory}/test`;
7277
};
7378

0 commit comments

Comments
 (0)