@paroicms/demo-app 0.38.16 → 0.39.0

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 +7 -6
  2. package/start.js +14 -5
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@paroicms/demo-app",
3
- "type": "commonjs",
4
- "version": "0.38.16",
3
+ "version": "0.39.0",
5
4
  "description": "ParoiCMS: demo app",
6
5
  "repository": {
7
6
  "type": "git",
@@ -10,10 +9,13 @@
10
9
  },
11
10
  "author": "Paroi Team",
12
11
  "license": "MIT",
12
+ "type": "module",
13
+ "main": "index.js",
13
14
  "dependencies": {
14
- "@paroicms/server": "1.73.2",
15
- "@paroicms/playground_seoul": "0.45.3",
16
- "@paroicms/playground_singapore": "0.51.3"
15
+ "@paroi/data-formatters-lib": "~0.4.0",
16
+ "@paroicms/server": "1.74.0",
17
+ "@paroicms/playground_seoul": "0.46.0",
18
+ "@paroicms/playground_singapore": "0.52.0"
17
19
  },
18
20
  "scripts": {
19
21
  "start": "node start.js"
@@ -21,7 +23,6 @@
21
23
  "bin": {
22
24
  "paroicms-demo-app": "start.js"
23
25
  },
24
- "main": "index.js",
25
26
  "files": [
26
27
  "start.js"
27
28
  ]
package/start.js CHANGED
@@ -1,20 +1,29 @@
1
1
  #!/usr/bin/env node
2
- const { start } = require("@paroicms/server");
3
- const { dependencies } = require("./package.json");
2
+ import { strVal } from "@paroi/data-formatters-lib";
3
+ import { resolveModuleDirectory } from "@paroicms/public-server-lib";
4
+ import { start } from "@paroicms/server";
5
+ import { readFileSync } from "fs";
6
+ import { join } from "path";
7
+
8
+ const packageDir = resolveModuleDirectory(import.meta.url, { parent: true });
9
+ const { dependencies } = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf-8'));
4
10
 
5
11
  start({
6
12
  sitePackPlaces: {
7
- playground: loadSitePlaces(),
13
+ playground: await loadSitePlaces(),
8
14
  }
9
15
  });
10
16
 
11
- function loadSitePlaces() {
17
+ async function loadSitePlaces() {
12
18
  const packagePrefix = "@paroicms/playground_";
13
19
 
14
20
  const sitePlaces = [];
15
21
  for (const dependencyName of Object.keys(dependencies ?? {})) {
16
22
  if (!dependencyName.startsWith(packagePrefix)) continue;
17
- const { siteDir, version } = require(dependencyName);
23
+ const siteDependency = await import(dependencyName);
24
+ const values = siteDependency.default ?? siteDependency;
25
+ const siteDir = strVal(values.siteDir);
26
+ const version = strVal(values.version);
18
27
  const domain = dependencyName.substring(packagePrefix.length);
19
28
  sitePlaces.push({ siteDir, domain, version });
20
29
  }