Skip to content

Commit

Permalink
update for npm publish
Browse files Browse the repository at this point in the history
  • Loading branch information
shanep committed Sep 28, 2023
1 parent cfa746d commit 23590ac
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cSpell.words": [
"execp",
"ghclass"
"ghclass",
"githubclassroom"
]
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ghclass",
"description": "Utilities for working with classroom.github.com",
"version": "2.0.0",
"version": "2.0.1",
"author": "Shane K. Panter",
"license": "MIT",
"homepage": "https://github.com/shanep/ghclass#readme",
Expand All @@ -24,8 +24,7 @@
},
"files": [
"/lib",
"/dist",
"docs"
"/dist"
],
"type": "module",
"scripts": {
Expand All @@ -38,7 +37,7 @@
"clean": "git clean -xfd",
"build:all": "npm run build && npm run dist",
"test:all": "npm run test && npm run test:coverage",
"package": "npm run test:all && npm run build:all && npm run docs"
"package": "npm run test && npm run build:all"
},
"dependencies": {
"commander": "^11.0.0",
Expand Down
8 changes: 6 additions & 2 deletions src/ghclass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type Student = {
githubUserName: string | undefined,
githubID: string | undefined,
name: string | undefined,
team: string | undefined,
team: string | undefined
};

/**
Expand Down Expand Up @@ -62,8 +62,9 @@ export async function loadRosterCSV(path: string): Promise<Student[]> {
* @param {string} org The github organization
* @param {string} project The project name
* @param {string} roster The path to the class roster
*
*/
export async function cloneAll(org: string, project: string, roster: string) {
export async function cloneAll(org: string, project: string, roster: string) : Promise<number> {
console.log(`Clone with options: ${org} ${project} ${roster}`);
const students = await loadRosterCSV(roster);
const clones: Promise<void | { stdout: string; stderr: string; }>[] = [];
Expand All @@ -79,6 +80,7 @@ export async function cloneAll(org: string, project: string, roster: string) {
});

const results = await Promise.allSettled(clones)
let count = 0;

results.forEach((result) => {
switch (result.status) {
Expand All @@ -89,11 +91,13 @@ export async function cloneAll(org: string, project: string, roster: string) {
break;
case 'fulfilled':
if(result.value){
count++;
console.log(result.value.stderr.trim())
}
break;
default:
console.log("Got an unknown case on a Promise!");
}
});
return count;
}
2 changes: 2 additions & 0 deletions test/data/live.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"identifier","github_username","github_id","name"
"shanepanter@u.boisestate.edu","BSU-ShanePanter","123456","shane"
15 changes: 13 additions & 2 deletions test/ghclass.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import assert from 'node:assert';
import { test } from 'node:test';
import { rmSync } from 'node:fs';

import * as ghclass from '../src/ghclass.js';

test('individual student roster from csv', async (t) => {
test('individual student roster from csv', async () => {
const result = await ghclass.loadRosterCSV('test/data/individual.csv');
assert.deepStrictEqual(
result,
Expand Down Expand Up @@ -42,7 +43,7 @@ test('individual construct repo url from student', () => {
});


test('group student roster from csv', async (t) => {
test('group student roster from csv', async () => {
const result = await ghclass.loadRosterCSV('test/data/group.csv');
assert.deepStrictEqual(
result,
Expand Down Expand Up @@ -79,3 +80,13 @@ test('group construct repo url from student', () => {
const expected = 'git@github.com:shanep-classroom/project1-team-002 team-002';
assert.strictEqual(actual, expected);
});


/* test('test live download with roster', async () => {
const result = await ghclass.cloneAll('shanep-githubclassroom-testing', 'lab01','test/data/live.csv');
assert.equal(result, 1);
rmSync("shanepanter@u.boisestate.edu", { recursive: true, force: true });
});
*/

0 comments on commit 23590ac

Please sign in to comment.