@isardsat/editorial-server 6.6.0 → 6.6.2

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/lib/hooks.js CHANGED
@@ -2,10 +2,15 @@ import { join } from "node:path";
2
2
  export async function createHooks(configDirectory) {
3
3
  const hooksDirPath = join(configDirectory, "hooks");
4
4
  async function loadHook(name) {
5
- const hookScript = join(process.cwd(), hooksDirPath, name);
6
- const module = await import(`${hookScript}.mjs`);
7
- const hookFunction = typeof module.default === "function" ? module.default : null;
8
- return hookFunction;
5
+ try {
6
+ const hookScript = join(process.cwd(), hooksDirPath, name);
7
+ const module = await import(`${hookScript}.mjs`);
8
+ const hookFunction = typeof module.default === "function" ? module.default : null;
9
+ return hookFunction;
10
+ }
11
+ catch {
12
+ return null;
13
+ }
9
14
  }
10
15
  async function executeHook(hookName, ...args) {
11
16
  const hook = await loadHook(hookName);
@@ -29,22 +29,32 @@ export function createActionRoutes(storage, hooks) {
29
29
  }),
30
30
  // TODO: Don't async, let the promises run in the background.
31
31
  async (c) => {
32
+ const { author } = c.req.valid("json");
32
33
  await storage.saveContent({ production: true });
33
34
  const content = await storage.getContent({ production: true });
34
35
  const schema = await storage.getSchema();
35
36
  try {
36
37
  const scriptResult = await hooks.onLocalize(content, schema);
37
- await storage.saveLocalisationMessages(scriptResult);
38
+ if (scriptResult) {
39
+ await storage.saveLocalisationMessages(scriptResult);
40
+ }
38
41
  }
39
42
  catch (error) {
40
- console.error("Error executing script:", error);
43
+ console.error("Error executing onLocalize script:", error);
41
44
  return c.json(false);
42
45
  }
43
46
  try {
44
47
  await hooks.onPublish(content, schema);
45
48
  }
46
49
  catch (error) {
47
- console.error("Error executing script:", error);
50
+ console.error("Error executing onPublish script:", error);
51
+ return c.json(false);
52
+ }
53
+ try {
54
+ await hooks.onPush(author);
55
+ }
56
+ catch (error) {
57
+ console.error("Error executing onPush script:", error);
48
58
  return c.json(false);
49
59
  }
50
60
  return c.json(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isardsat/editorial-server",
3
- "version": "6.6.0",
3
+ "version": "6.6.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,8 +14,8 @@
14
14
  "hono": "^4.6.20",
15
15
  "yaml": "^2.7.0",
16
16
  "zod": "^3.24.1",
17
- "@isardsat/editorial-common": "^6.6.0",
18
- "@isardsat/editorial-admin": "^6.6.0"
17
+ "@isardsat/editorial-admin": "^6.6.2",
18
+ "@isardsat/editorial-common": "^6.6.2"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@tsconfig/node22": "^22.0.0",