quizmill 0.2.3 → 0.2.5
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/bin/quizmill.js +43 -4
- package/package.json +1 -1
package/bin/quizmill.js
CHANGED
|
@@ -23,6 +23,7 @@ const path = require('node:path');
|
|
|
23
23
|
const ENGINE_REPO = 'https://github.com/quizmill/quizmill.git';
|
|
24
24
|
const HOME = process.env.QUIZMILL_HOME || path.join(os.homedir(), '.quizmill');
|
|
25
25
|
const ENGINE = process.env.QUIZMILL_ENGINE || path.join(HOME, 'engine');
|
|
26
|
+
const CLI_VERSION = require('../package.json').version;
|
|
26
27
|
|
|
27
28
|
const log = (s) => console.log(s);
|
|
28
29
|
const die = (s) => {
|
|
@@ -46,9 +47,27 @@ function ensureEngine() {
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
function engineSha() {
|
|
51
|
+
try {
|
|
52
|
+
return execSync('git rev-parse --short HEAD', { cwd: ENGINE }).toString().trim();
|
|
53
|
+
} catch {
|
|
54
|
+
return '?';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
49
58
|
function engineNpm(args) {
|
|
50
59
|
ensureEngine();
|
|
51
|
-
|
|
60
|
+
const env = { ...process.env };
|
|
61
|
+
// The cached engine is a shallow, tagless clone, so its own
|
|
62
|
+
// `git describe` can't resolve a release tag — the in-app version would
|
|
63
|
+
// fall back to the 0.0.0-dev sentinel. Stamp the build with the CLI's
|
|
64
|
+
// version instead (the CLI is published in lockstep with the engine).
|
|
65
|
+
// Skipped when QUIZMILL_ENGINE points at a real checkout (let its git
|
|
66
|
+
// tags win) or when the caller set the version explicitly.
|
|
67
|
+
if (!process.env.QUIZMILL_ENGINE && !env.NEXT_PUBLIC_APP_VERSION) {
|
|
68
|
+
env.NEXT_PUBLIC_APP_VERSION = CLI_VERSION;
|
|
69
|
+
}
|
|
70
|
+
run('npm', args, { cwd: ENGINE, env });
|
|
52
71
|
}
|
|
53
72
|
|
|
54
73
|
/** Resolve a pack argument: absolute path for dirs, verbatim otherwise
|
|
@@ -152,11 +171,27 @@ function cmdValidate(arg) {
|
|
|
152
171
|
|
|
153
172
|
function cmdUpgrade() {
|
|
154
173
|
ensureEngine();
|
|
155
|
-
if (
|
|
156
|
-
|
|
174
|
+
if (process.env.QUIZMILL_ENGINE) {
|
|
175
|
+
log('QUIZMILL_ENGINE points at your own checkout — its update is up to you.');
|
|
176
|
+
} else {
|
|
177
|
+
const before = engineSha();
|
|
178
|
+
try {
|
|
179
|
+
// The cache is a depth-1 shallow clone, so `git pull --ff-only` can't
|
|
180
|
+
// fast-forward across the grafted history once main advances. Fetch
|
|
181
|
+
// the latest main and hard-reset onto it — the cache holds no local
|
|
182
|
+
// commits worth keeping (gitignored content/ and out/ are untouched).
|
|
183
|
+
run('git', ['fetch', '--depth', '1', 'origin', 'main'], { cwd: ENGINE });
|
|
184
|
+
run('git', ['reset', '--hard', 'FETCH_HEAD'], { cwd: ENGINE });
|
|
185
|
+
} catch {
|
|
186
|
+
log('… update failed — re-cloning the engine fresh');
|
|
187
|
+
fs.rmSync(ENGINE, { recursive: true, force: true });
|
|
188
|
+
ensureEngine();
|
|
189
|
+
}
|
|
190
|
+
const after = engineSha();
|
|
191
|
+
log(before === after ? `engine already current (${after})` : `engine ${before} → ${after}`);
|
|
157
192
|
}
|
|
158
193
|
run('npm', ['install', '--no-fund', '--no-audit'], { cwd: ENGINE });
|
|
159
|
-
log(
|
|
194
|
+
log(`✓ quizmill ${CLI_VERSION} ready — engine deps installed`);
|
|
160
195
|
}
|
|
161
196
|
|
|
162
197
|
const HELP = `quizmill — the mill that grinds questions into knowledge
|
|
@@ -169,6 +204,7 @@ usage:
|
|
|
169
204
|
quizmill build [dir|owner/repo] build a static app into <pack-id>-app/
|
|
170
205
|
quizmill list published packs you can install
|
|
171
206
|
quizmill upgrade update the cached engine (~/.quizmill)
|
|
207
|
+
quizmill --version print the CLI version (stamped into builds)
|
|
172
208
|
|
|
173
209
|
A learning pack is three JSON files. You can write them, but the
|
|
174
210
|
intended author is your AI agent — see the create-learning-pack skill
|
|
@@ -183,6 +219,9 @@ try {
|
|
|
183
219
|
case 'build': cmdBuild(arg); break;
|
|
184
220
|
case 'list': engineNpm(['run', 'pack:list']); break;
|
|
185
221
|
case 'upgrade': cmdUpgrade(); break;
|
|
222
|
+
case 'version':
|
|
223
|
+
case '--version':
|
|
224
|
+
case '-v': log(CLI_VERSION); break;
|
|
186
225
|
case 'help':
|
|
187
226
|
case '--help':
|
|
188
227
|
case undefined: log(HELP); break;
|
package/package.json
CHANGED