@devtion/devcli 0.0.0-004e6ad
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +120 -0
- package/dist/.env +55 -0
- package/dist/index.js +3635 -0
- package/dist/public/mini-semaphore.wasm +0 -0
- package/dist/public/mini-semaphore.zkey +0 -0
- package/dist/types/commands/auth.d.ts +25 -0
- package/dist/types/commands/authBandada.d.ts +2 -0
- package/dist/types/commands/authSIWE.d.ts +7 -0
- package/dist/types/commands/ceremony/index.d.ts +3 -0
- package/dist/types/commands/ceremony/listParticipants.d.ts +2 -0
- package/dist/types/commands/clean.d.ts +6 -0
- package/dist/types/commands/contribute.d.ts +139 -0
- package/dist/types/commands/finalize.d.ts +52 -0
- package/dist/types/commands/index.d.ts +11 -0
- package/dist/types/commands/listCeremonies.d.ts +5 -0
- package/dist/types/commands/logout.d.ts +6 -0
- package/dist/types/commands/observe.d.ts +22 -0
- package/dist/types/commands/setup.d.ts +86 -0
- package/dist/types/commands/validate.d.ts +8 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lib/bandada.d.ts +6 -0
- package/dist/types/lib/errors.d.ts +60 -0
- package/dist/types/lib/files.d.ts +65 -0
- package/dist/types/lib/localConfigs.d.ts +148 -0
- package/dist/types/lib/prompts.d.ts +104 -0
- package/dist/types/lib/services.d.ts +31 -0
- package/dist/types/lib/theme.d.ts +42 -0
- package/dist/types/lib/utils.d.ts +159 -0
- package/dist/types/types/index.d.ts +134 -0
- package/package.json +108 -0
- package/src/commands/auth.ts +214 -0
- package/src/commands/authBandada.ts +120 -0
- package/src/commands/authSIWE.ts +185 -0
- package/src/commands/ceremony/index.ts +20 -0
- package/src/commands/ceremony/listParticipants.ts +56 -0
- package/src/commands/clean.ts +49 -0
- package/src/commands/contribute.ts +1116 -0
- package/src/commands/finalize.ts +395 -0
- package/src/commands/index.ts +11 -0
- package/src/commands/listCeremonies.ts +31 -0
- package/src/commands/logout.ts +69 -0
- package/src/commands/observe.ts +197 -0
- package/src/commands/setup.ts +912 -0
- package/src/commands/validate.ts +28 -0
- package/src/index.ts +88 -0
- package/src/lib/bandada.ts +51 -0
- package/src/lib/errors.ts +77 -0
- package/src/lib/files.ts +102 -0
- package/src/lib/localConfigs.ts +240 -0
- package/src/lib/prompts.ts +745 -0
- package/src/lib/services.ts +214 -0
- package/src/lib/theme.ts +45 -0
- package/src/lib/utils.ts +813 -0
- package/src/types/conf.d.ts +16 -0
- package/src/types/index.ts +145 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { collection, doc, getDocs } from "firebase/firestore"
|
|
2
|
+
import { ParticipantDocument, UserDocument, commonTerms, getAllCeremonies } from "@devtion/actions"
|
|
3
|
+
import theme from "../../lib/theme.js"
|
|
4
|
+
import { bootstrapCommandExecutionAndServices } from "../../lib/services.js"
|
|
5
|
+
import { showError } from "../../lib/errors.js"
|
|
6
|
+
import { promptForCeremonySelection } from "../../lib/prompts.js"
|
|
7
|
+
|
|
8
|
+
const listParticipants = async () => {
|
|
9
|
+
try {
|
|
10
|
+
const { firestoreDatabase } = await bootstrapCommandExecutionAndServices()
|
|
11
|
+
|
|
12
|
+
const allCeremonies = await getAllCeremonies(firestoreDatabase)
|
|
13
|
+
const selectedCeremony = await promptForCeremonySelection(
|
|
14
|
+
allCeremonies,
|
|
15
|
+
true,
|
|
16
|
+
"Which ceremony would you like to see participants?"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
const docRef = doc(firestoreDatabase, commonTerms.collections.ceremonies.name, selectedCeremony.id)
|
|
20
|
+
const participantsRef = collection(docRef, "participants")
|
|
21
|
+
const participantsSnapshot = await getDocs(participantsRef)
|
|
22
|
+
const participants = participantsSnapshot.docs.map(
|
|
23
|
+
(participantDoc) => participantDoc.data() as ParticipantDocument
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const usersRef = collection(firestoreDatabase, "users")
|
|
27
|
+
const usersSnapshot = await getDocs(usersRef)
|
|
28
|
+
const users = usersSnapshot.docs.map((userDoc) => {
|
|
29
|
+
const data = userDoc.data() as UserDocument
|
|
30
|
+
return { id: userDoc.id, ...data }
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const participantDetails = participants
|
|
34
|
+
.map((participant) => {
|
|
35
|
+
const user = users.find((_user) => _user.id === participant.userId)
|
|
36
|
+
if (!user) return null
|
|
37
|
+
return {
|
|
38
|
+
id: user.name,
|
|
39
|
+
status: participant.status,
|
|
40
|
+
contributionStep: participant.contributionStep,
|
|
41
|
+
lastUpdated: new Date(participant.lastUpdated)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
.filter((user) => user !== null)
|
|
45
|
+
|
|
46
|
+
const participantsDone = participantDetails.filter((participant) => participant.status === "DONE")
|
|
47
|
+
console.log(participantDetails)
|
|
48
|
+
console.log(`${theme.text.underlined("Total participants:")} ${participantDetails.length}`)
|
|
49
|
+
console.log(`${theme.text.underlined("Total participants finished:")} ${participantsDone.length}`)
|
|
50
|
+
} catch (err: any) {
|
|
51
|
+
showError(`Something went wrong: ${err.toString()}`, true)
|
|
52
|
+
}
|
|
53
|
+
process.exit(0)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default listParticipants
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { bootstrapCommandExecutionAndServices } from "../lib/services.js"
|
|
4
|
+
import { showError } from "../lib/errors.js"
|
|
5
|
+
import { askForConfirmation } from "../lib/prompts.js"
|
|
6
|
+
import { customSpinner, sleep } from "../lib/utils.js"
|
|
7
|
+
import theme from "../lib/theme.js"
|
|
8
|
+
import { localPaths } from "../lib/localConfigs.js"
|
|
9
|
+
import { deleteDir, directoryExists } from "../lib/files.js"
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Clean command.
|
|
13
|
+
*/
|
|
14
|
+
const clean = async () => {
|
|
15
|
+
try {
|
|
16
|
+
// Initialize services.
|
|
17
|
+
await bootstrapCommandExecutionAndServices()
|
|
18
|
+
|
|
19
|
+
const spinner = customSpinner(`Cleaning up...`, "clock")
|
|
20
|
+
|
|
21
|
+
if (directoryExists(localPaths.output)) {
|
|
22
|
+
console.log(theme.text.bold(`${theme.symbols.warning} Be careful, this action is irreversible!`))
|
|
23
|
+
|
|
24
|
+
const { confirmation } = await askForConfirmation(
|
|
25
|
+
"Are you sure you want to continue with the clean up?",
|
|
26
|
+
"Yes",
|
|
27
|
+
"No"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
if (confirmation) {
|
|
31
|
+
spinner.start()
|
|
32
|
+
|
|
33
|
+
// Do the clean up.
|
|
34
|
+
deleteDir(localPaths.output)
|
|
35
|
+
|
|
36
|
+
// nb. simulate waiting time for 1s.
|
|
37
|
+
await sleep(1000)
|
|
38
|
+
|
|
39
|
+
spinner.succeed(`Cleanup was successfully completed ${theme.emojis.broom}`)
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
console.log(`${theme.symbols.info} There is nothing to clean ${theme.emojis.eyes}`)
|
|
43
|
+
}
|
|
44
|
+
} catch (err: any) {
|
|
45
|
+
showError(`Something went wrong: ${err.toString()}`, true)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default clean
|