Skip to content

Commit

Permalink
add: add back commander and util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
YUUU23 committed Aug 14, 2024
1 parent 3cbb4da commit 076038d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
16 changes: 16 additions & 0 deletions cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fsExtra from "fs-extra";

import { cert, initializeApp } from "firebase-admin/app"; // eslint-disable-line import/no-unresolved
import { getFirestore } from "firebase-admin/firestore"; // eslint-disable-line import/no-unresolved
import { Command } from "commander";

/** -------------------- GLOBALS -------------------- */

Expand Down Expand Up @@ -422,6 +423,21 @@ async function confirmOverwritePrompt(file, overwriteAll) {
return answer;
}

/** -------------------- FIRESTORE VALIDATIONS -------------------- */
/** helper to check if the given study (input) is in firestore */
async function validateStudyFirebase(input) {
// subcollection is programmatically generated, if it doesn't exist then input must not be a valid studyID
const studyIDCollections = await getStudyRef(input).listCollections();
return studyIDCollections.find((c) => c.id === PARTICIPANTS_COL);
}

/** helper to check if the given participant (input) is in firestore under study */
async function validateParticipantFirebase(input) {
// subcollection is programmatically generated, if it doesn't exist then input must not be a valid participantID
const studyIDCollections = await getParticipantRef(STUDY_ID, input).listCollections();
return studyIDCollections.find((c) => c.id === DATA_COL);
}

/** -------------------- FIRESTORE HELPERS -------------------- */

const RESPONSES_COL = "participant_responses";
Expand Down
39 changes: 16 additions & 23 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@jspsych/plugin-instructions": "^1.1.3",
"@jspsych/plugin-preload": "^1.1.2",
"@jspsych/plugin-survey": "^1.0.1",
"commander": "^12.1.0",
"electron-log": "^5.0.0",
"electron-squirrel-startup": "^1.0.0",
"firebase": "^10.11.0",
Expand Down

0 comments on commit 076038d

Please sign in to comment.