wiki-plugin-shoppe 0.0.8 → 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.
- package/package.json +1 -1
- package/server/server.js +23 -13
package/package.json
CHANGED
package/server/server.js
CHANGED
|
@@ -9,9 +9,10 @@ const sessionless = require('sessionless-node');
|
|
|
9
9
|
|
|
10
10
|
const SHOPPE_BASE_EMOJI = process.env.SHOPPE_BASE_EMOJI || '🛍️🎨🎁';
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const DATA_DIR = path.join(process.env.HOME || '/root', '.shoppe');
|
|
13
|
+
const TENANTS_FILE = path.join(DATA_DIR, 'tenants.json');
|
|
14
|
+
const CONFIG_FILE = path.join(DATA_DIR, 'config.json');
|
|
15
|
+
const TMP_DIR = '/tmp/shoppe-uploads';
|
|
15
16
|
|
|
16
17
|
// ============================================================
|
|
17
18
|
// CONFIG (allyabase URL, etc.)
|
|
@@ -246,19 +247,27 @@ async function processArchive(zipPath) {
|
|
|
246
247
|
zip.extractAllTo(tmpDir, true);
|
|
247
248
|
|
|
248
249
|
try {
|
|
249
|
-
// Find manifest.json — handle zips
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
|
|
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;
|
|
257
262
|
}
|
|
263
|
+
return null;
|
|
258
264
|
}
|
|
259
|
-
|
|
265
|
+
|
|
266
|
+
const root = findManifest(tmpDir);
|
|
267
|
+
if (!root) {
|
|
260
268
|
throw new Error('Archive is missing manifest.json');
|
|
261
269
|
}
|
|
270
|
+
const manifestPath = path.join(root, 'manifest.json');
|
|
262
271
|
|
|
263
272
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
264
273
|
if (!manifest.uuid || !manifest.emojicode) {
|
|
@@ -705,7 +714,8 @@ function generateShoppeHTML(tenant, goods) {
|
|
|
705
714
|
async function startServer(params) {
|
|
706
715
|
const app = params.app;
|
|
707
716
|
|
|
708
|
-
if (!fs.existsSync(
|
|
717
|
+
if (!fs.existsSync(DATA_DIR)) fs.mkdirSync(DATA_DIR, { recursive: true });
|
|
718
|
+
if (!fs.existsSync(TMP_DIR)) fs.mkdirSync(TMP_DIR, { recursive: true });
|
|
709
719
|
console.log('🛍️ wiki-plugin-shoppe starting...');
|
|
710
720
|
|
|
711
721
|
const owner = (req, res, next) => {
|