@content-collections/integrations 0.3.0 → 0.4.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.
@@ -1,18 +1,16 @@
1
1
 
2
- > @content-collections/integrations@0.3.0 build /home/runner/work/content-collections/content-collections/packages/integrations
3
- > tsup src/index.ts --format esm,cjs --dts -d dist
2
+ > @content-collections/integrations@0.4.0 build /home/runner/work/content-collections/content-collections/packages/integrations
3
+ > tsdown src/index.ts --format esm,cjs --dts -d dist
4
4
 
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.2.4
8
- CLI Target: es2022
9
- ESM Build start
10
- CJS Build start
11
- ESM dist/index.js 2.02 KB
12
- ESM ⚡️ Build success in 21ms
13
- CJS dist/index.cjs 3.72 KB
14
- CJS ⚡️ Build success in 21ms
15
- DTS Build start
16
- DTS ⚡️ Build success in 839ms
17
- DTS dist/index.d.ts 143.00 B
18
- DTS dist/index.d.cts 143.00 B
5
+ ℹ tsdown v0.15.12 powered by rolldown v1.0.0-beta.45
6
+ ℹ entry: src/index.ts
7
+ ℹ tsconfig: tsconfig.json
8
+ ℹ Build start
9
+ ℹ [CJS] dist/index.cjs 3.16 kB │ gzip: 1.14 kB
10
+ ℹ [CJS] 1 files, total: 3.16 kB
11
+ ℹ [ESM] dist/index.js 2.07 kB │ gzip: 0.71 kB
12
+ ℹ [ESM] dist/index.d.ts 0.26 kB │ gzip: 0.19 kB
13
+ ℹ [ESM] 2 files, total: 2.33 kB
14
+ ℹ [CJS] dist/index.d.cts 0.26 kB │ gzip: 0.19 kB
15
+ ℹ [CJS] 1 files, total: 0.26 kB
16
+ ✔ Build complete in 1091ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @content-collections/integrations
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#695](https://github.com/sdorra/content-collections/pull/695) [`92abb38`](https://github.com/sdorra/content-collections/commit/92abb380a8c39c558a5fc10ac347008b8a4ceb03) Thanks [@sdorra](https://github.com/sdorra)! - Fix regression: (#692) exit the build on validation errors in production
8
+
3
9
  ## 0.3.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -1,102 +1,77 @@
1
- "use strict";
1
+ //#region rolldown:runtime
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
8
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
29
22
 
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- configureLogging: () => configureLogging
34
- });
35
- module.exports = __toCommonJS(src_exports);
36
- var import_node_path2 = __toESM(require("path"), 1);
23
+ //#endregion
24
+ let node_path = require("node:path");
25
+ node_path = __toESM(node_path);
37
26
 
38
- // src/errors.ts
39
- var import_node_path = __toESM(require("path"), 1);
40
- var handledErrors = ["transformer:validation-error", "collector:parse-error"];
27
+ //#region src/errors.ts
28
+ const handledErrors = ["transformer:validation-error", "collector:parse-error"];
41
29
  function isUnknownError(event) {
42
- return !handledErrors.includes(event);
30
+ return !handledErrors.includes(event);
43
31
  }
44
32
  function registerErrorListeners(builder) {
45
- builder.on("transformer:validation-error", (event) => {
46
- console.log();
47
- console.log(
48
- "Validation failed on",
49
- import_node_path.default.join(event.collection.directory, event.file.path) + ":"
50
- );
51
- console.log(event.error.message);
52
- console.log();
53
- });
54
- builder.on("collector:parse-error", (event) => {
55
- console.log();
56
- console.log("Failed to parse file", import_node_path.default.join(event.filePath) + ":");
57
- console.log(event.error.message);
58
- console.log();
59
- });
33
+ builder.on("transformer:validation-error", (event) => {
34
+ console.log();
35
+ console.log("Validation failed on", node_path.default.join(event.collection.directory, event.file.path) + ":");
36
+ console.log(event.error.message);
37
+ console.log();
38
+ });
39
+ builder.on("collector:parse-error", (event) => {
40
+ console.log();
41
+ console.log("Failed to parse file", node_path.default.join(event.filePath) + ":");
42
+ console.log(event.error.message);
43
+ console.log();
44
+ });
60
45
  }
61
46
 
62
- // src/index.ts
63
- function configureLogging(builder) {
64
- builder.on("builder:start", () => {
65
- console.log("build started ...");
66
- });
67
- builder.on("builder:end", (event) => {
68
- console.log(
69
- "... finished build of",
70
- event.stats.collections,
71
- event.stats.collections === 1 ? "collection" : "collections",
72
- "and",
73
- event.stats.documents,
74
- event.stats.documents === 1 ? "document" : "documents",
75
- "in",
76
- event.endedAt - event.startedAt + "ms"
77
- );
78
- });
79
- builder.on("watcher:config-changed", () => console.log("... config changed"));
80
- builder.on("watcher:file-changed", (event) => {
81
- const relativePath = import_node_path2.default.relative(process.cwd(), event.filePath);
82
- if (event.modification === "delete") {
83
- console.log("... file", relativePath, "deleted");
84
- } else {
85
- console.log("... file", relativePath, "changed");
86
- }
87
- });
88
- builder.on("transformer:document-skipped", (event) => {
89
- const relativePath = import_node_path2.default.relative(process.cwd(), event.filePath);
90
- console.log("... document", relativePath, "skipped", "due to", event.reason);
91
- });
92
- registerErrorListeners(builder);
93
- builder.on("_error", ({ _event, error }) => {
94
- if (isUnknownError(_event)) {
95
- console.log("... error", error.message);
96
- }
97
- });
47
+ //#endregion
48
+ //#region src/index.ts
49
+ const defaultOptions = { handleError: () => {
50
+ if (process.env.NODE_ENV === "production") process.exit(1);
51
+ } };
52
+ function configureLogging(builder, options = defaultOptions) {
53
+ builder.on("builder:start", () => {
54
+ console.log("build started ...");
55
+ });
56
+ builder.on("builder:end", (event) => {
57
+ console.log("... finished build of", event.stats.collections, event.stats.collections === 1 ? "collection" : "collections", "and", event.stats.documents, event.stats.documents === 1 ? "document" : "documents", "in", event.endedAt - event.startedAt + "ms");
58
+ });
59
+ builder.on("watcher:config-changed", () => console.log("... config changed"));
60
+ builder.on("watcher:file-changed", (event) => {
61
+ const relativePath = node_path.default.relative(process.cwd(), event.filePath);
62
+ if (event.modification === "delete") console.log("... file", relativePath, "deleted");
63
+ else console.log("... file", relativePath, "changed");
64
+ });
65
+ builder.on("transformer:document-skipped", (event) => {
66
+ const relativePath = node_path.default.relative(process.cwd(), event.filePath);
67
+ console.log("... document", relativePath, "skipped", "due to", event.reason);
68
+ });
69
+ registerErrorListeners(builder);
70
+ builder.on("_error", ({ _event, error }) => {
71
+ if (isUnknownError(_event)) console.log("... error", error.message);
72
+ options.handleError?.(error);
73
+ });
98
74
  }
99
- // Annotate the CommonJS export names for ESM import in node:
100
- 0 && (module.exports = {
101
- configureLogging
102
- });
75
+
76
+ //#endregion
77
+ exports.configureLogging = configureLogging;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,9 @@
1
- import { Builder } from '@content-collections/core';
1
+ import { Builder } from "@content-collections/core";
2
2
 
3
- declare function configureLogging(builder: Builder): void;
4
-
5
- export { configureLogging };
3
+ //#region src/index.d.ts
4
+ type Options = {
5
+ handleError?: (error: Error) => void;
6
+ };
7
+ declare function configureLogging(builder: Builder, options?: Options): void;
8
+ //#endregion
9
+ export { configureLogging };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
- import { Builder } from '@content-collections/core';
1
+ import { Builder } from "@content-collections/core";
2
2
 
3
- declare function configureLogging(builder: Builder): void;
4
-
5
- export { configureLogging };
3
+ //#region src/index.d.ts
4
+ type Options = {
5
+ handleError?: (error: Error) => void;
6
+ };
7
+ declare function configureLogging(builder: Builder, options?: Options): void;
8
+ //#endregion
9
+ export { configureLogging };
package/dist/index.js CHANGED
@@ -1,67 +1,53 @@
1
- // src/index.ts
2
- import path2 from "node:path";
3
-
4
- // src/errors.ts
5
1
  import path from "node:path";
6
- var handledErrors = ["transformer:validation-error", "collector:parse-error"];
2
+
3
+ //#region src/errors.ts
4
+ const handledErrors = ["transformer:validation-error", "collector:parse-error"];
7
5
  function isUnknownError(event) {
8
- return !handledErrors.includes(event);
6
+ return !handledErrors.includes(event);
9
7
  }
10
8
  function registerErrorListeners(builder) {
11
- builder.on("transformer:validation-error", (event) => {
12
- console.log();
13
- console.log(
14
- "Validation failed on",
15
- path.join(event.collection.directory, event.file.path) + ":"
16
- );
17
- console.log(event.error.message);
18
- console.log();
19
- });
20
- builder.on("collector:parse-error", (event) => {
21
- console.log();
22
- console.log("Failed to parse file", path.join(event.filePath) + ":");
23
- console.log(event.error.message);
24
- console.log();
25
- });
9
+ builder.on("transformer:validation-error", (event) => {
10
+ console.log();
11
+ console.log("Validation failed on", path.join(event.collection.directory, event.file.path) + ":");
12
+ console.log(event.error.message);
13
+ console.log();
14
+ });
15
+ builder.on("collector:parse-error", (event) => {
16
+ console.log();
17
+ console.log("Failed to parse file", path.join(event.filePath) + ":");
18
+ console.log(event.error.message);
19
+ console.log();
20
+ });
26
21
  }
27
22
 
28
- // src/index.ts
29
- function configureLogging(builder) {
30
- builder.on("builder:start", () => {
31
- console.log("build started ...");
32
- });
33
- builder.on("builder:end", (event) => {
34
- console.log(
35
- "... finished build of",
36
- event.stats.collections,
37
- event.stats.collections === 1 ? "collection" : "collections",
38
- "and",
39
- event.stats.documents,
40
- event.stats.documents === 1 ? "document" : "documents",
41
- "in",
42
- event.endedAt - event.startedAt + "ms"
43
- );
44
- });
45
- builder.on("watcher:config-changed", () => console.log("... config changed"));
46
- builder.on("watcher:file-changed", (event) => {
47
- const relativePath = path2.relative(process.cwd(), event.filePath);
48
- if (event.modification === "delete") {
49
- console.log("... file", relativePath, "deleted");
50
- } else {
51
- console.log("... file", relativePath, "changed");
52
- }
53
- });
54
- builder.on("transformer:document-skipped", (event) => {
55
- const relativePath = path2.relative(process.cwd(), event.filePath);
56
- console.log("... document", relativePath, "skipped", "due to", event.reason);
57
- });
58
- registerErrorListeners(builder);
59
- builder.on("_error", ({ _event, error }) => {
60
- if (isUnknownError(_event)) {
61
- console.log("... error", error.message);
62
- }
63
- });
23
+ //#endregion
24
+ //#region src/index.ts
25
+ const defaultOptions = { handleError: () => {
26
+ if (process.env.NODE_ENV === "production") process.exit(1);
27
+ } };
28
+ function configureLogging(builder, options = defaultOptions) {
29
+ builder.on("builder:start", () => {
30
+ console.log("build started ...");
31
+ });
32
+ builder.on("builder:end", (event) => {
33
+ console.log("... finished build of", event.stats.collections, event.stats.collections === 1 ? "collection" : "collections", "and", event.stats.documents, event.stats.documents === 1 ? "document" : "documents", "in", event.endedAt - event.startedAt + "ms");
34
+ });
35
+ builder.on("watcher:config-changed", () => console.log("... config changed"));
36
+ builder.on("watcher:file-changed", (event) => {
37
+ const relativePath = path.relative(process.cwd(), event.filePath);
38
+ if (event.modification === "delete") console.log("... file", relativePath, "deleted");
39
+ else console.log("... file", relativePath, "changed");
40
+ });
41
+ builder.on("transformer:document-skipped", (event) => {
42
+ const relativePath = path.relative(process.cwd(), event.filePath);
43
+ console.log("... document", relativePath, "skipped", "due to", event.reason);
44
+ });
45
+ registerErrorListeners(builder);
46
+ builder.on("_error", ({ _event, error }) => {
47
+ if (isUnknownError(_event)) console.log("... error", error.message);
48
+ options.handleError?.(error);
49
+ });
64
50
  }
65
- export {
66
- configureLogging
67
- };
51
+
52
+ //#endregion
53
+ export { configureLogging };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@content-collections/integrations",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "description": "Utils for integrating Content Collections with other tools",
6
6
  "author": "Sebastian Sdorra <s.sdorra@gmail.com>",
7
7
  "license": "MIT",
@@ -25,14 +25,14 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "20",
28
- "tsup": "^8.2.4",
28
+ "tsdown": "^0.15.12",
29
29
  "typescript": "^5.5.4",
30
- "@content-collections/core": "0.11.0"
30
+ "@content-collections/core": "0.13.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@content-collections/core": "0.x"
34
34
  },
35
35
  "scripts": {
36
- "build": "tsup src/index.ts --format esm,cjs --dts -d dist"
36
+ "build": "tsdown src/index.ts --format esm,cjs --dts -d dist"
37
37
  }
38
38
  }
package/src/index.ts CHANGED
@@ -2,7 +2,19 @@ import { Builder } from "@content-collections/core";
2
2
  import path from "node:path";
3
3
  import { isUnknownError, registerErrorListeners } from "./errors.js";
4
4
 
5
- export function configureLogging(builder: Builder) {
5
+ type Options = {
6
+ handleError?: (error: Error) => void;
7
+ };
8
+
9
+ const defaultOptions: Options = {
10
+ handleError: () => {
11
+ if (process.env.NODE_ENV === "production") {
12
+ process.exit(1);
13
+ }
14
+ },
15
+ };
16
+
17
+ export function configureLogging(builder: Builder, options: Options = defaultOptions) {
6
18
  builder.on("builder:start", () => {
7
19
  console.log("build started ...");
8
20
  });
@@ -42,5 +54,6 @@ export function configureLogging(builder: Builder) {
42
54
  if (isUnknownError(_event)) {
43
55
  console.log("... error", error.message);
44
56
  }
57
+ options.handleError?.(error);
45
58
  });
46
59
  }