@primate/core 0.1.0 → 0.1.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Primate core",
5
5
  "homepage": "https://primatejs.com",
6
6
  "bugs": "https://github.com/primatejs/primate/issues",
@@ -21,14 +21,14 @@
21
21
  "@rcompat/build": "^0.4.0",
22
22
  "@rcompat/cli": "^0.5.1",
23
23
  "@rcompat/crypto": "^0.5.0",
24
- "@rcompat/fs": "^0.4.0",
24
+ "@rcompat/fs": "^0.4.1",
25
25
  "@rcompat/function": "^0.4.0",
26
- "@rcompat/http": "^0.5.1",
26
+ "@rcompat/http": "^0.5.2",
27
27
  "@rcompat/invariant": "^0.5.0",
28
28
  "@rcompat/object": "^0.5.0",
29
29
  "@rcompat/package": "^0.7.0",
30
30
  "@rcompat/platform": "^0.3.0",
31
- "@rcompat/stdio": "^0.4.0",
31
+ "@rcompat/stdio": "^0.5.0",
32
32
  "@rcompat/sync": "^0.3.0"
33
33
  },
34
34
  "type": "module",
@@ -8,6 +8,7 @@ import join from "@rcompat/fs/join";
8
8
  import exclude from "@rcompat/object/exclude";
9
9
  import stringify from "@rcompat/object/stringify";
10
10
  import manifest from "@rcompat/package/manifest";
11
+ import root from "@rcompat/package/root";
11
12
  import copy_includes from "./copy_includes.js";
12
13
  import $router from "./router.js";
13
14
 
@@ -163,7 +164,12 @@ const post = async (app, mode, target) => {
163
164
  await write_bootstrap(build_number, app, mode);
164
165
 
165
166
  // copy config file
166
- await app.root.join(config_filename).copy(app.path.build.join(config_filename));
167
+ const local_config = app.root.join(config_filename);
168
+ const build_config = app.path.build.join(config_filename);
169
+ const root_base = await root(import.meta.url);
170
+ const default_config = root_base.join("/src/private/config.js");
171
+ (await local_config.exists() ? local_config : default_config)
172
+ .copy(build_config);
167
173
 
168
174
  const manifest_data = await manifest();
169
175
  // create package.json
@@ -12,18 +12,27 @@ import platform from "@rcompat/platform";
12
12
  import app from "./app.js";
13
13
  import { build, init } from "./hook/exports.js";
14
14
 
15
+ const empty_config = config => config === undefined || empty(config);
16
+
15
17
  const get_config = async project_root => {
16
18
  const local_config = project_root.join(config_filename);
17
- return await local_config.exists()
18
- ? tryreturn(async _ => {
19
+ const exists = await local_config.exists()
20
+ if (exists) {
21
+ try {
19
22
  const imported = await local_config.import("default");
20
23
 
21
- empty(imported) && empty_config_file(local_config);
24
+ empty_config(imported) && empty_config_file(local_config);
22
25
 
23
26
  return imported;
24
- }).orelse(({ message }) =>
25
- error_in_config_file(message, `${platform} ${local_config}`))
26
- : config;
27
+ } catch (error) {
28
+ if (error.level === undefined) {
29
+ error_in_config_file(error.message, `${platform} ${local_config}`);
30
+ } else {
31
+ throw error;
32
+ }
33
+ }
34
+ }
35
+ return config;
27
36
  };
28
37
 
29
38
  export default async (mode, target) => tryreturn(async _ => {
@@ -22,7 +22,7 @@ export default async app => {
22
22
  const pages = await Promise.all((await collect(d, html, { recursive: true }))
23
23
  .map(async file => `${file}`.replace(`${d}/`, _ => "")));
24
24
  const pages_str = pages.map(page =>
25
- `"${page}": await file("./${location.pages}/${page}").text(),`).join("\n");
25
+ `"${page}": await join(import.meta.url, "../${location.pages}/${page}").text(),`).join("\n");
26
26
 
27
27
  const assets_scripts = `
28
28
  import file from "@rcompat/fs/file";