wiki-plugin-shoppe 0.0.9 → 0.0.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/server.js +17 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wiki-plugin-shoppe",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Multi-tenant digital goods shoppe for federated wiki, powered by Sanora",
5
5
  "keywords": [
6
6
  "wiki",
package/server/server.js CHANGED
@@ -247,19 +247,27 @@ async function processArchive(zipPath) {
247
247
  zip.extractAllTo(tmpDir, true);
248
248
 
249
249
  try {
250
- // Find manifest.json — handle zips that wrap everything in a top-level folder
251
- let root = tmpDir;
252
- let manifestPath = path.join(tmpDir, 'manifest.json');
253
- if (!fs.existsSync(manifestPath)) {
254
- const entries = fs.readdirSync(tmpDir);
255
- if (entries.length === 1 && fs.statSync(path.join(tmpDir, entries[0])).isDirectory()) {
256
- root = path.join(tmpDir, entries[0]);
257
- manifestPath = path.join(root, 'manifest.json');
250
+ // Find manifest.json — handle zips wrapped in a top-level folder and
251
+ // macOS zips that include a __MACOSX metadata folder alongside the content.
252
+ function findManifest(dir, depth = 0) {
253
+ const direct = path.join(dir, 'manifest.json');
254
+ if (fs.existsSync(direct)) return dir;
255
+ if (depth >= 2) return null;
256
+ const entries = fs.readdirSync(dir).filter(f =>
257
+ f !== '__MACOSX' && fs.statSync(path.join(dir, f)).isDirectory()
258
+ );
259
+ for (const entry of entries) {
260
+ const found = findManifest(path.join(dir, entry), depth + 1);
261
+ if (found) return found;
258
262
  }
263
+ return null;
259
264
  }
260
- if (!fs.existsSync(manifestPath)) {
265
+
266
+ const root = findManifest(tmpDir);
267
+ if (!root) {
261
268
  throw new Error('Archive is missing manifest.json');
262
269
  }
270
+ const manifestPath = path.join(root, 'manifest.json');
263
271
 
264
272
  const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
265
273
  if (!manifest.uuid || !manifest.emojicode) {