skuilder 0.2.26 → 0.2.28
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/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/dump-user.d.ts +15 -0
- package/dist/commands/dump-user.d.ts.map +1 -0
- package/dist/commands/dump-user.js +103 -0
- package/dist/commands/dump-user.js.map +1 -0
- package/dist/standalone-ui-template/package.json +2 -2
- package/dist/standalone-ui-template/src/router/index.ts +20 -0
- package/dist/standalone-ui-template/src/views/AdminLearnerView.vue +44 -0
- package/dist/studio-ui-src/package.json +2 -2
- package/package.json +10 -10
- package/src/cli.ts +3 -0
- package/src/commands/dump-user.ts +128 -0
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAwBA,eAAO,MAAM,OAAO,EAAE,MAA4B,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ import { createInitCommand } from './commands/init.js';
|
|
|
11
11
|
import { createPackCommand } from './commands/pack.js';
|
|
12
12
|
import { createUnpackCommand } from './commands/unpack.js';
|
|
13
13
|
import { createStudioCommand } from './commands/studio.js';
|
|
14
|
+
import { createDumpUserCommand } from './commands/dump-user.js';
|
|
14
15
|
const __filename = fileURLToPath(import.meta.url);
|
|
15
16
|
const __dirname = dirname(__filename);
|
|
16
17
|
// Read package.json to get version
|
|
@@ -27,6 +28,7 @@ program.addCommand(createInitCommand());
|
|
|
27
28
|
program.addCommand(createPackCommand());
|
|
28
29
|
program.addCommand(createUnpackCommand());
|
|
29
30
|
program.addCommand(createStudioCommand());
|
|
31
|
+
program.addCommand(createDumpUserCommand());
|
|
30
32
|
program.on('--help', () => {
|
|
31
33
|
console.log('');
|
|
32
34
|
console.log('Examples:');
|
|
@@ -39,6 +41,7 @@ program.on('--help', () => {
|
|
|
39
41
|
console.log(' $ skuilder unpack ./my-course --database test-migration --validate');
|
|
40
42
|
console.log(' $ skuilder studio ./my-sui-course');
|
|
41
43
|
console.log(' $ skuilder studio . --port 5985 --no-browser');
|
|
44
|
+
console.log(' $ skuilder dump-user alice --course <courseId> --server https://example.com/couch');
|
|
42
45
|
});
|
|
43
46
|
program.parse();
|
|
44
47
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,8DAA8D;AAC9D,sEAAsE;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,oBAAoB,EAAE,CAAC;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,8DAA8D;AAC9D,sEAAsE;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,oBAAoB,EAAE,CAAC;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE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,EAAE,CAAC,CAAC;AAE5C,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,mEAAmE,CAAC,CAAC;IACjF,OAAO,CAAC,GAAG,CAAC,iEAAiE,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,CAAC,+EAA+E,CAAC,CAAC;IAC7F,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,sEAAsE,CAAC,CAAC;IACpF,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,CAAC,qFAAqF,CAAC,CAAC;AACrG,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
export declare function createDumpUserCommand(): Command;
|
|
3
|
+
interface DumpUserOptions {
|
|
4
|
+
course: string;
|
|
5
|
+
server: string;
|
|
6
|
+
adminUser: string;
|
|
7
|
+
password?: string;
|
|
8
|
+
passwordFile?: string;
|
|
9
|
+
cards: string;
|
|
10
|
+
out: string;
|
|
11
|
+
attachments?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function dumpUser(username: string, options: DumpUserOptions): Promise<void>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=dump-user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dump-user.d.ts","sourceRoot":"","sources":["../../src/commands/dump-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,wBAAgB,qBAAqB,IAAI,OAAO,CAoB/C;AAED,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAuDD,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCxF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'fs';
|
|
4
|
+
import { dirname, join, resolve } from 'path';
|
|
5
|
+
import { showUserError, showUserMessage } from '@vue-skuilder/common';
|
|
6
|
+
import { dumpFileName, fetchLearnerDump } from '@vue-skuilder/db/diagnostics';
|
|
7
|
+
export function createDumpUserCommand() {
|
|
8
|
+
return new Command('dump-user')
|
|
9
|
+
.description("Dump a learner's records for one course to a JSON file, for offline diagnosis")
|
|
10
|
+
.argument('<username>', 'Learner whose user DB to read')
|
|
11
|
+
.requiredOption('-c, --course <courseId>', 'Course id (the coursedb-<id> suffix)')
|
|
12
|
+
.option('-s, --server <url>', 'CouchDB base URL', 'http://localhost:5984')
|
|
13
|
+
.option('--admin-user <name>', 'CouchDB admin username', 'admin')
|
|
14
|
+
.option('-p, --password <password>', 'CouchDB admin password (else $COUCHDB_PASSWORD, else --password-file)')
|
|
15
|
+
.option('--password-file <path>', 'Read the admin password from this file')
|
|
16
|
+
.option('--cards <scope>', 'Course cards to include: touched | all | none', 'touched')
|
|
17
|
+
.option('-o, --out <path>', 'Output file, or a directory for the default name (userdb-<username>-<stamp>.json)', '.')
|
|
18
|
+
.option('--attachments', 'Inline user-DB attachments as base64')
|
|
19
|
+
.action(dumpUser);
|
|
20
|
+
}
|
|
21
|
+
function resolvePassword(options) {
|
|
22
|
+
if (options.password)
|
|
23
|
+
return options.password;
|
|
24
|
+
if (process.env.COUCHDB_PASSWORD)
|
|
25
|
+
return process.env.COUCHDB_PASSWORD;
|
|
26
|
+
if (options.passwordFile)
|
|
27
|
+
return readFileSync(options.passwordFile, 'utf-8').trim();
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
function resolveOutPath(out, dump) {
|
|
31
|
+
const isDir = out.endsWith('/') || (existsSync(out) && statSync(out).isDirectory());
|
|
32
|
+
return resolve(isDir ? join(out, dumpFileName(dump)) : out);
|
|
33
|
+
}
|
|
34
|
+
function countByPrefix(ids) {
|
|
35
|
+
const counts = new Map();
|
|
36
|
+
for (const id of ids) {
|
|
37
|
+
const prefix = id.startsWith('_design/') ? '_design' : id.split(/[-_:]/)[0];
|
|
38
|
+
counts.set(prefix, (counts.get(prefix) ?? 0) + 1);
|
|
39
|
+
}
|
|
40
|
+
return [...counts.entries()].sort((a, b) => b[1] - a[1]);
|
|
41
|
+
}
|
|
42
|
+
function printSummary(dump) {
|
|
43
|
+
for (const [prefix, n] of countByPrefix(dump.docs.map((d) => d._id))) {
|
|
44
|
+
showUserMessage(chalk.gray(` ${String(n).padStart(5)} ${prefix}`));
|
|
45
|
+
}
|
|
46
|
+
const tombstones = dump.tombstones ?? [];
|
|
47
|
+
showUserMessage(chalk.gray(`tombstones: ${tombstones.length}`));
|
|
48
|
+
for (const [prefix, n] of countByPrefix(tombstones.map((t) => t.id))) {
|
|
49
|
+
showUserMessage(chalk.gray(` ${String(n).padStart(5)} ${prefix}`));
|
|
50
|
+
}
|
|
51
|
+
if (dump.course) {
|
|
52
|
+
const c = dump.course;
|
|
53
|
+
showUserMessage(chalk.gray(`course: ${c.courseId} (${c.scope}): ${c.cards.length} cards, ` +
|
|
54
|
+
`${c.displayableData.length} data docs, ${c.tags.length} tags`));
|
|
55
|
+
}
|
|
56
|
+
const sessions = dump.docs
|
|
57
|
+
.filter((d) => d._id.startsWith('SESSION::') && d.courseId === dump.courseId)
|
|
58
|
+
.map((d) => ({ start: String(d.startTime ?? ''), status: String(d.status ?? '?') }))
|
|
59
|
+
.sort((a, b) => a.start.localeCompare(b.start));
|
|
60
|
+
if (sessions.length) {
|
|
61
|
+
const byStatus = new Map();
|
|
62
|
+
for (const s of sessions)
|
|
63
|
+
byStatus.set(s.status, (byStatus.get(s.status) ?? 0) + 1);
|
|
64
|
+
const statuses = [...byStatus].map(([k, v]) => `${v} ${k}`).join(', ');
|
|
65
|
+
const first = sessions[0].start.slice(0, 10);
|
|
66
|
+
const last = sessions[sessions.length - 1].start.slice(0, 10);
|
|
67
|
+
showUserMessage(chalk.gray(`sessions: ${sessions.length} (${statuses}), ${first} .. ${last}`));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export async function dumpUser(username, options) {
|
|
71
|
+
const password = resolvePassword(options);
|
|
72
|
+
if (!password) {
|
|
73
|
+
showUserError(chalk.red('No admin password: pass -p, set COUCHDB_PASSWORD, or use --password-file'));
|
|
74
|
+
process.exit(2);
|
|
75
|
+
}
|
|
76
|
+
if (!['touched', 'all', 'none'].includes(options.cards)) {
|
|
77
|
+
showUserError(chalk.red(`--cards must be touched, all, or none (got ${options.cards})`));
|
|
78
|
+
process.exit(2);
|
|
79
|
+
}
|
|
80
|
+
showUserMessage(chalk.cyan(`Dumping ${username} / ${options.course} from ${options.server}`));
|
|
81
|
+
try {
|
|
82
|
+
const dump = await fetchLearnerDump({
|
|
83
|
+
couchUrl: options.server,
|
|
84
|
+
username,
|
|
85
|
+
courseId: options.course,
|
|
86
|
+
auth: { kind: 'basic', username: options.adminUser, password },
|
|
87
|
+
cards: options.cards,
|
|
88
|
+
attachments: options.attachments === true,
|
|
89
|
+
});
|
|
90
|
+
const outPath = resolveOutPath(options.out, dump);
|
|
91
|
+
mkdirSync(dirname(outPath), { recursive: true });
|
|
92
|
+
writeFileSync(outPath, JSON.stringify(dump, null, 2));
|
|
93
|
+
showUserMessage(chalk.green(`Wrote ${outPath}`));
|
|
94
|
+
printSummary(dump);
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
const err = e;
|
|
98
|
+
const cause = err.cause ? `: ${err.cause.code ?? err.cause.message}` : '';
|
|
99
|
+
showUserError(chalk.red(`${err.message}${cause}`));
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=dump-user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dump-user.js","sourceRoot":"","sources":["../../src/commands/dump-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAoB,MAAM,8BAA8B,CAAC;AAEhG,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC;SAC5B,WAAW,CAAC,+EAA+E,CAAC;SAC5F,QAAQ,CAAC,YAAY,EAAE,+BAA+B,CAAC;SACvD,cAAc,CAAC,yBAAyB,EAAE,sCAAsC,CAAC;SACjF,MAAM,CAAC,oBAAoB,EAAE,kBAAkB,EAAE,uBAAuB,CAAC;SACzE,MAAM,CAAC,qBAAqB,EAAE,w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
|
6
|
+
"version": "0.2.28",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist-lib/questions.cjs.js",
|
|
9
9
|
"module": "./dist-lib/questions.mjs",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"vue-tsc": "^1.8.0",
|
|
59
59
|
"wait-on": "8.0.2"
|
|
60
60
|
},
|
|
61
|
-
"stableVersion": "0.2.
|
|
61
|
+
"stableVersion": "0.2.28"
|
|
62
62
|
}
|
|
@@ -64,6 +64,15 @@ const routes: Array<RouteRecordRaw> = [
|
|
|
64
64
|
requiresAuth: true,
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
|
+
{
|
|
68
|
+
path: '/admin/learners/:username?',
|
|
69
|
+
name: 'AdminLearner',
|
|
70
|
+
component: () => import('../views/AdminLearnerView.vue'),
|
|
71
|
+
props: true,
|
|
72
|
+
meta: {
|
|
73
|
+
requiresAdmin: true,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
67
76
|
];
|
|
68
77
|
|
|
69
78
|
const router = createRouter({
|
|
@@ -73,6 +82,17 @@ const router = createRouter({
|
|
|
73
82
|
|
|
74
83
|
// Navigation guard for protected routes
|
|
75
84
|
router.beforeEach(async (to, _from, next) => {
|
|
85
|
+
// Admin routes read other learners' data; couch enforces this too, but a
|
|
86
|
+
// non-admin shouldn't get the page at all.
|
|
87
|
+
if (to.meta.requiresAdmin) {
|
|
88
|
+
const { getCurrentUser } = await import('@vue-skuilder/common-ui');
|
|
89
|
+
const user = await getCurrentUser();
|
|
90
|
+
if (user?.getUsername() !== 'admin') {
|
|
91
|
+
next({ name: 'login', query: { redirect: to.fullPath } });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
76
96
|
// Check if route requires authentication
|
|
77
97
|
if (to.meta.requiresAuth) {
|
|
78
98
|
// Dynamically import auth store to avoid circular dependencies
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-container>
|
|
3
|
+
<h1 class="text-h5 mb-4">Learner</h1>
|
|
4
|
+
<learner-dataset-source
|
|
5
|
+
:couch-url="couchUrl"
|
|
6
|
+
:course-id="config.course"
|
|
7
|
+
:initial-username="username"
|
|
8
|
+
@loaded="onLoaded"
|
|
9
|
+
/>
|
|
10
|
+
<learner-diagnostics v-if="dataset" :dataset="dataset" class="mt-6" />
|
|
11
|
+
</v-container>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import { shallowRef } from 'vue';
|
|
16
|
+
import { useRouter } from 'vue-router';
|
|
17
|
+
import { ENV } from '@vue-skuilder/db';
|
|
18
|
+
import type { LearnerDataset } from '@vue-skuilder/db/diagnostics';
|
|
19
|
+
import { LearnerDatasetSource, LearnerDiagnostics } from '@vue-skuilder/common-ui/admin';
|
|
20
|
+
import '@vue-skuilder/common-ui/admin/style';
|
|
21
|
+
import config from '../../skuilder.config.json';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Admin view of one learner in this course. Live loading needs the couch data
|
|
25
|
+
* layer and an admin session; any layer can open a dump file.
|
|
26
|
+
*/
|
|
27
|
+
const props = defineProps<{ username?: string }>();
|
|
28
|
+
|
|
29
|
+
const router = useRouter();
|
|
30
|
+
|
|
31
|
+
const couchUrl =
|
|
32
|
+
config.dataLayerType === 'couch' && ENV.COUCHDB_SERVER_URL !== 'NOT_SET'
|
|
33
|
+
? `${ENV.COUCHDB_SERVER_PROTOCOL}://${ENV.COUCHDB_SERVER_URL}`
|
|
34
|
+
: undefined;
|
|
35
|
+
|
|
36
|
+
const dataset = shallowRef<LearnerDataset | null>(null);
|
|
37
|
+
|
|
38
|
+
function onLoaded(loaded: LearnerDataset): void {
|
|
39
|
+
dataset.value = loaded;
|
|
40
|
+
if (loaded.username !== props.username) {
|
|
41
|
+
void router.replace({ name: 'AdminLearner', params: { username: loaded.username } });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.28",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"dev": "vite",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"vite": "^8.0.0",
|
|
33
33
|
"vue-tsc": "^1.8.0"
|
|
34
34
|
},
|
|
35
|
-
"stableVersion": "0.2.
|
|
35
|
+
"stableVersion": "0.2.28"
|
|
36
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skuilder",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI tool for scaffolding Skuilder course applications",
|
|
6
6
|
"bin": {
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@mdi/font": "^7.3.67",
|
|
45
|
-
"@vue-skuilder/common": "0.2.
|
|
46
|
-
"@vue-skuilder/common-ui": "0.2.
|
|
47
|
-
"@vue-skuilder/courseware": "0.2.
|
|
48
|
-
"@vue-skuilder/db": "0.2.
|
|
49
|
-
"@vue-skuilder/edit-ui": "0.2.
|
|
50
|
-
"@vue-skuilder/express": "0.2.
|
|
51
|
-
"@vue-skuilder/mcp": "0.2.
|
|
45
|
+
"@vue-skuilder/common": "0.2.28",
|
|
46
|
+
"@vue-skuilder/common-ui": "0.2.28",
|
|
47
|
+
"@vue-skuilder/courseware": "0.2.28",
|
|
48
|
+
"@vue-skuilder/db": "0.2.28",
|
|
49
|
+
"@vue-skuilder/edit-ui": "0.2.28",
|
|
50
|
+
"@vue-skuilder/express": "0.2.28",
|
|
51
|
+
"@vue-skuilder/mcp": "0.2.28",
|
|
52
52
|
"chalk": "^5.3.0",
|
|
53
53
|
"commander": "^11.0.0",
|
|
54
54
|
"fs-extra": "^11.2.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@types/node": "^22",
|
|
68
68
|
"@types/serve-static": "^1.15.0",
|
|
69
69
|
"@vitejs/plugin-vue": "^6.0.5",
|
|
70
|
-
"@vue-skuilder/studio-ui": "0.2.
|
|
70
|
+
"@vue-skuilder/studio-ui": "0.2.28",
|
|
71
71
|
"cypress": "^15.14.0",
|
|
72
72
|
"typescript": "~5.9.3",
|
|
73
73
|
"vite": "^8.0.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"node": ">=18.0.0"
|
|
79
79
|
},
|
|
80
80
|
"packageManager": "yarn@4.12.0",
|
|
81
|
-
"stableVersion": "0.2.
|
|
81
|
+
"stableVersion": "0.2.28"
|
|
82
82
|
}
|
package/src/cli.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { createInitCommand } from './commands/init.js';
|
|
|
13
13
|
import { createPackCommand } from './commands/pack.js';
|
|
14
14
|
import { createUnpackCommand } from './commands/unpack.js';
|
|
15
15
|
import { createStudioCommand } from './commands/studio.js';
|
|
16
|
+
import { createDumpUserCommand } from './commands/dump-user.js';
|
|
16
17
|
|
|
17
18
|
const __filename = fileURLToPath(import.meta.url);
|
|
18
19
|
const __dirname = dirname(__filename);
|
|
@@ -35,6 +36,7 @@ program.addCommand(createInitCommand());
|
|
|
35
36
|
program.addCommand(createPackCommand());
|
|
36
37
|
program.addCommand(createUnpackCommand());
|
|
37
38
|
program.addCommand(createStudioCommand());
|
|
39
|
+
program.addCommand(createDumpUserCommand());
|
|
38
40
|
|
|
39
41
|
program.on('--help', () => {
|
|
40
42
|
console.log('');
|
|
@@ -48,6 +50,7 @@ program.on('--help', () => {
|
|
|
48
50
|
console.log(' $ skuilder unpack ./my-course --database test-migration --validate');
|
|
49
51
|
console.log(' $ skuilder studio ./my-sui-course');
|
|
50
52
|
console.log(' $ skuilder studio . --port 5985 --no-browser');
|
|
53
|
+
console.log(' $ skuilder dump-user alice --course <courseId> --server https://example.com/couch');
|
|
51
54
|
});
|
|
52
55
|
|
|
53
56
|
program.parse();
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'fs';
|
|
4
|
+
import { dirname, join, resolve } from 'path';
|
|
5
|
+
import { showUserError, showUserMessage } from '@vue-skuilder/common';
|
|
6
|
+
import { dumpFileName, fetchLearnerDump, type LearnerDump } from '@vue-skuilder/db/diagnostics';
|
|
7
|
+
|
|
8
|
+
export function createDumpUserCommand(): Command {
|
|
9
|
+
return new Command('dump-user')
|
|
10
|
+
.description("Dump a learner's records for one course to a JSON file, for offline diagnosis")
|
|
11
|
+
.argument('<username>', 'Learner whose user DB to read')
|
|
12
|
+
.requiredOption('-c, --course <courseId>', 'Course id (the coursedb-<id> suffix)')
|
|
13
|
+
.option('-s, --server <url>', 'CouchDB base URL', 'http://localhost:5984')
|
|
14
|
+
.option('--admin-user <name>', 'CouchDB admin username', 'admin')
|
|
15
|
+
.option(
|
|
16
|
+
'-p, --password <password>',
|
|
17
|
+
'CouchDB admin password (else $COUCHDB_PASSWORD, else --password-file)'
|
|
18
|
+
)
|
|
19
|
+
.option('--password-file <path>', 'Read the admin password from this file')
|
|
20
|
+
.option('--cards <scope>', 'Course cards to include: touched | all | none', 'touched')
|
|
21
|
+
.option(
|
|
22
|
+
'-o, --out <path>',
|
|
23
|
+
'Output file, or a directory for the default name (userdb-<username>-<stamp>.json)',
|
|
24
|
+
'.'
|
|
25
|
+
)
|
|
26
|
+
.option('--attachments', 'Inline user-DB attachments as base64')
|
|
27
|
+
.action(dumpUser);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface DumpUserOptions {
|
|
31
|
+
course: string;
|
|
32
|
+
server: string;
|
|
33
|
+
adminUser: string;
|
|
34
|
+
password?: string;
|
|
35
|
+
passwordFile?: string;
|
|
36
|
+
cards: string;
|
|
37
|
+
out: string;
|
|
38
|
+
attachments?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function resolvePassword(options: DumpUserOptions): string | undefined {
|
|
42
|
+
if (options.password) return options.password;
|
|
43
|
+
if (process.env.COUCHDB_PASSWORD) return process.env.COUCHDB_PASSWORD;
|
|
44
|
+
if (options.passwordFile) return readFileSync(options.passwordFile, 'utf-8').trim();
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function resolveOutPath(out: string, dump: LearnerDump): string {
|
|
49
|
+
const isDir = out.endsWith('/') || (existsSync(out) && statSync(out).isDirectory());
|
|
50
|
+
return resolve(isDir ? join(out, dumpFileName(dump)) : out);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function countByPrefix(ids: string[]): Array<[string, number]> {
|
|
54
|
+
const counts = new Map<string, number>();
|
|
55
|
+
for (const id of ids) {
|
|
56
|
+
const prefix = id.startsWith('_design/') ? '_design' : id.split(/[-_:]/)[0];
|
|
57
|
+
counts.set(prefix, (counts.get(prefix) ?? 0) + 1);
|
|
58
|
+
}
|
|
59
|
+
return [...counts.entries()].sort((a, b) => b[1] - a[1]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function printSummary(dump: LearnerDump): void {
|
|
63
|
+
for (const [prefix, n] of countByPrefix(dump.docs.map((d) => d._id))) {
|
|
64
|
+
showUserMessage(chalk.gray(` ${String(n).padStart(5)} ${prefix}`));
|
|
65
|
+
}
|
|
66
|
+
const tombstones = dump.tombstones ?? [];
|
|
67
|
+
showUserMessage(chalk.gray(`tombstones: ${tombstones.length}`));
|
|
68
|
+
for (const [prefix, n] of countByPrefix(tombstones.map((t) => t.id))) {
|
|
69
|
+
showUserMessage(chalk.gray(` ${String(n).padStart(5)} ${prefix}`));
|
|
70
|
+
}
|
|
71
|
+
if (dump.course) {
|
|
72
|
+
const c = dump.course;
|
|
73
|
+
showUserMessage(
|
|
74
|
+
chalk.gray(
|
|
75
|
+
`course: ${c.courseId} (${c.scope}): ${c.cards.length} cards, ` +
|
|
76
|
+
`${c.displayableData.length} data docs, ${c.tags.length} tags`
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
const sessions = dump.docs
|
|
81
|
+
.filter((d) => d._id.startsWith('SESSION::') && d.courseId === dump.courseId)
|
|
82
|
+
.map((d) => ({ start: String(d.startTime ?? ''), status: String(d.status ?? '?') }))
|
|
83
|
+
.sort((a, b) => a.start.localeCompare(b.start));
|
|
84
|
+
if (sessions.length) {
|
|
85
|
+
const byStatus = new Map<string, number>();
|
|
86
|
+
for (const s of sessions) byStatus.set(s.status, (byStatus.get(s.status) ?? 0) + 1);
|
|
87
|
+
const statuses = [...byStatus].map(([k, v]) => `${v} ${k}`).join(', ');
|
|
88
|
+
const first = sessions[0].start.slice(0, 10);
|
|
89
|
+
const last = sessions[sessions.length - 1].start.slice(0, 10);
|
|
90
|
+
showUserMessage(chalk.gray(`sessions: ${sessions.length} (${statuses}), ${first} .. ${last}`));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function dumpUser(username: string, options: DumpUserOptions): Promise<void> {
|
|
95
|
+
const password = resolvePassword(options);
|
|
96
|
+
if (!password) {
|
|
97
|
+
showUserError(
|
|
98
|
+
chalk.red('No admin password: pass -p, set COUCHDB_PASSWORD, or use --password-file')
|
|
99
|
+
);
|
|
100
|
+
process.exit(2);
|
|
101
|
+
}
|
|
102
|
+
if (!['touched', 'all', 'none'].includes(options.cards)) {
|
|
103
|
+
showUserError(chalk.red(`--cards must be touched, all, or none (got ${options.cards})`));
|
|
104
|
+
process.exit(2);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
showUserMessage(chalk.cyan(`Dumping ${username} / ${options.course} from ${options.server}`));
|
|
108
|
+
try {
|
|
109
|
+
const dump = await fetchLearnerDump({
|
|
110
|
+
couchUrl: options.server,
|
|
111
|
+
username,
|
|
112
|
+
courseId: options.course,
|
|
113
|
+
auth: { kind: 'basic', username: options.adminUser, password },
|
|
114
|
+
cards: options.cards as 'touched' | 'all' | 'none',
|
|
115
|
+
attachments: options.attachments === true,
|
|
116
|
+
});
|
|
117
|
+
const outPath = resolveOutPath(options.out, dump);
|
|
118
|
+
mkdirSync(dirname(outPath), { recursive: true });
|
|
119
|
+
writeFileSync(outPath, JSON.stringify(dump, null, 2));
|
|
120
|
+
showUserMessage(chalk.green(`Wrote ${outPath}`));
|
|
121
|
+
printSummary(dump);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
const err = e as Error & { cause?: { code?: string; message?: string } };
|
|
124
|
+
const cause = err.cause ? `: ${err.cause.code ?? err.cause.message}` : '';
|
|
125
|
+
showUserError(chalk.red(`${err.message}${cause}`));
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
}
|