@patch-adams/core 1.4.33 → 1.4.34
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.cjs +36 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +35 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +36 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,7 @@ import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
|
4
4
|
import { resolve, basename, extname } from 'path';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import ora from 'ora';
|
|
7
|
+
import crypto from 'crypto';
|
|
7
8
|
import AdmZip from 'adm-zip';
|
|
8
9
|
import archiver from 'archiver';
|
|
9
10
|
import { PassThrough } from 'stream';
|
|
@@ -5441,6 +5442,22 @@ $1</resource>`
|
|
|
5441
5442
|
return [];
|
|
5442
5443
|
}
|
|
5443
5444
|
}
|
|
5445
|
+
/**
|
|
5446
|
+
* Update the manifest identifier attribute to a new value.
|
|
5447
|
+
* Used to ensure every course has a unique identifier (e.g., project UUID).
|
|
5448
|
+
*/
|
|
5449
|
+
updateIdentifier(zip, newIdentifier) {
|
|
5450
|
+
const entry = zip.getEntry("imsmanifest.xml");
|
|
5451
|
+
if (!entry) return false;
|
|
5452
|
+
const xml = entry.getData().toString("utf-8");
|
|
5453
|
+
const updated = xml.replace(
|
|
5454
|
+
/(<manifest[^>]+identifier\s*=\s*["'])[^"']+(["'])/i,
|
|
5455
|
+
`$1${newIdentifier}$2`
|
|
5456
|
+
);
|
|
5457
|
+
if (updated === xml) return false;
|
|
5458
|
+
zip.updateFile("imsmanifest.xml", Buffer.from(updated, "utf-8"));
|
|
5459
|
+
return true;
|
|
5460
|
+
}
|
|
5444
5461
|
/**
|
|
5445
5462
|
* Get the file paths that will be added to the package
|
|
5446
5463
|
*/
|
|
@@ -5945,6 +5962,24 @@ var Patcher = class {
|
|
|
5945
5962
|
if (metadata.description) console.log(` - Description: ${metadata.description.substring(0, 50)}...`);
|
|
5946
5963
|
if (metadata.language) console.log(` - Language: ${metadata.language}`);
|
|
5947
5964
|
if (metadata.masteryScore !== null) console.log(` - Mastery Score: ${metadata.masteryScore}`);
|
|
5965
|
+
const configDocGuid = this.config.lrsBridge?.documentGuid;
|
|
5966
|
+
if (configDocGuid) {
|
|
5967
|
+
console.log(`[Patcher] Overriding courseId with documentGuid: ${configDocGuid}`);
|
|
5968
|
+
metadata.courseId = configDocGuid;
|
|
5969
|
+
metadata.courseIdSource = "manifest";
|
|
5970
|
+
result.courseId = configDocGuid;
|
|
5971
|
+
if (this.manifestUpdater.updateIdentifier(zip, configDocGuid)) {
|
|
5972
|
+
console.log(`[Patcher] Updated manifest identifier to: ${configDocGuid}`);
|
|
5973
|
+
}
|
|
5974
|
+
} else if (metadata.courseIdSource === "fallback") {
|
|
5975
|
+
const generated = crypto.randomUUID();
|
|
5976
|
+
console.log(`[Patcher] No course identifier found, generating UUID: ${generated}`);
|
|
5977
|
+
metadata.courseId = generated;
|
|
5978
|
+
result.courseId = generated;
|
|
5979
|
+
if (this.manifestUpdater.updateIdentifier(zip, generated)) {
|
|
5980
|
+
console.log(`[Patcher] Wrote generated UUID to manifest identifier`);
|
|
5981
|
+
}
|
|
5982
|
+
}
|
|
5948
5983
|
const htmlInjector = this.getHtmlInjector(toolInfo.tool);
|
|
5949
5984
|
htmlInjector.setMetadata(metadata);
|
|
5950
5985
|
let fetchedFallbacks = {};
|