@content-collections/integrations 0.3.0 → 0.5.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.5.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.46 kB │ gzip: 1.24 kB
10
+ ℹ [CJS] 1 files, total: 3.46 kB
11
+ ℹ [ESM] dist/index.js 2.37 kB │ gzip: 0.80 kB
12
+ ℹ [ESM] dist/index.d.ts 0.26 kB │ gzip: 0.19 kB
13
+ ℹ [ESM] 2 files, total: 2.63 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 1154ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @content-collections/integrations
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#708](https://github.com/sdorra/content-collections/pull/708) [`9d68701`](https://github.com/sdorra/content-collections/commit/9d68701de6244d5a2dd9c8e87cb1441f151ec148) Thanks [@ExpensiveKoala](https://github.com/ExpensiveKoala)! - Support for singletons #300
8
+
9
+ ## 0.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#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
14
+
3
15
  ## 0.3.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -1,102 +1,83 @@
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:singleton-warning", (event) => {
34
+ console.log();
35
+ console.log(`Singleton collection "${event.collection.name}" matched no documents. Export will be undefined.`);
36
+ console.log();
37
+ });
38
+ builder.on("transformer:validation-error", (event) => {
39
+ console.log();
40
+ const location = "filePath" in event.collection ? event.collection.filePath : node_path.default.join(event.collection.directory, event.file.path);
41
+ console.log("Validation failed on", location + ":");
42
+ console.log(event.error.message);
43
+ console.log();
44
+ });
45
+ builder.on("collector:parse-error", (event) => {
46
+ console.log();
47
+ console.log("Failed to parse file", node_path.default.join(event.filePath) + ":");
48
+ console.log(event.error.message);
49
+ console.log();
50
+ });
60
51
  }
61
52
 
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
- });
53
+ //#endregion
54
+ //#region src/index.ts
55
+ const defaultOptions = { handleError: () => {
56
+ if (process.env.NODE_ENV === "production") process.exit(1);
57
+ } };
58
+ function configureLogging(builder, options = defaultOptions) {
59
+ builder.on("builder:start", () => {
60
+ console.log("build started ...");
61
+ });
62
+ builder.on("builder:end", (event) => {
63
+ 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");
64
+ });
65
+ builder.on("watcher:config-changed", () => console.log("... config changed"));
66
+ builder.on("watcher:file-changed", (event) => {
67
+ const relativePath = node_path.default.relative(process.cwd(), event.filePath);
68
+ if (event.modification === "delete") console.log("... file", relativePath, "deleted");
69
+ else console.log("... file", relativePath, "changed");
70
+ });
71
+ builder.on("transformer:document-skipped", (event) => {
72
+ const relativePath = node_path.default.relative(process.cwd(), event.filePath);
73
+ console.log("... document", relativePath, "skipped", "due to", event.reason);
74
+ });
75
+ registerErrorListeners(builder);
76
+ builder.on("_error", ({ _event, error }) => {
77
+ if (isUnknownError(_event)) console.log("... error", error.message);
78
+ options.handleError?.(error);
79
+ });
98
80
  }
99
- // Annotate the CommonJS export names for ESM import in node:
100
- 0 && (module.exports = {
101
- configureLogging
102
- });
81
+
82
+ //#endregion
83
+ 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,59 @@
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:singleton-warning", (event) => {
10
+ console.log();
11
+ console.log(`Singleton collection "${event.collection.name}" matched no documents. Export will be undefined.`);
12
+ console.log();
13
+ });
14
+ builder.on("transformer:validation-error", (event) => {
15
+ console.log();
16
+ const location = "filePath" in event.collection ? event.collection.filePath : path.join(event.collection.directory, event.file.path);
17
+ console.log("Validation failed on", location + ":");
18
+ console.log(event.error.message);
19
+ console.log();
20
+ });
21
+ builder.on("collector:parse-error", (event) => {
22
+ console.log();
23
+ console.log("Failed to parse file", path.join(event.filePath) + ":");
24
+ console.log(event.error.message);
25
+ console.log();
26
+ });
26
27
  }
27
28
 
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
- });
29
+ //#endregion
30
+ //#region src/index.ts
31
+ const defaultOptions = { handleError: () => {
32
+ if (process.env.NODE_ENV === "production") process.exit(1);
33
+ } };
34
+ function configureLogging(builder, options = defaultOptions) {
35
+ builder.on("builder:start", () => {
36
+ console.log("build started ...");
37
+ });
38
+ builder.on("builder:end", (event) => {
39
+ 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");
40
+ });
41
+ builder.on("watcher:config-changed", () => console.log("... config changed"));
42
+ builder.on("watcher:file-changed", (event) => {
43
+ const relativePath = path.relative(process.cwd(), event.filePath);
44
+ if (event.modification === "delete") console.log("... file", relativePath, "deleted");
45
+ else console.log("... file", relativePath, "changed");
46
+ });
47
+ builder.on("transformer:document-skipped", (event) => {
48
+ const relativePath = path.relative(process.cwd(), event.filePath);
49
+ console.log("... document", relativePath, "skipped", "due to", event.reason);
50
+ });
51
+ registerErrorListeners(builder);
52
+ builder.on("_error", ({ _event, error }) => {
53
+ if (isUnknownError(_event)) console.log("... error", error.message);
54
+ options.handleError?.(error);
55
+ });
64
56
  }
65
- export {
66
- configureLogging
67
- };
57
+
58
+ //#endregion
59
+ 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.5.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.14.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/errors.ts CHANGED
@@ -8,12 +8,19 @@ export function isUnknownError(event: string) {
8
8
  }
9
9
 
10
10
  export function registerErrorListeners(builder: Builder) {
11
+ builder.on("transformer:singleton-warning", (event) => {
12
+ console.log();
13
+ console.log(`Singleton collection "${event.collection.name}" matched no documents. Export will be undefined.`);
14
+ console.log();
15
+ });
16
+
11
17
  builder.on("transformer:validation-error", (event) => {
12
18
  console.log();
13
- console.log(
14
- "Validation failed on",
15
- path.join(event.collection.directory, event.file.path) + ":",
16
- );
19
+ const location =
20
+ "filePath" in (event.collection as any)
21
+ ? (event.collection as any).filePath
22
+ : path.join((event.collection as any).directory, event.file.path);
23
+ console.log("Validation failed on", location + ":");
17
24
  console.log(event.error.message);
18
25
  console.log();
19
26
  });
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
  }