@content-collections/integrations 0.2.1 → 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.
- package/.turbo/turbo-build.log +14 -16
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +61 -82
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +46 -56
- package/package.json +14 -5
- package/src/index.ts +19 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
> @content-collections/integrations@0.
|
|
3
|
-
>
|
|
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
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m143.00 B[39m
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m143.00 B[39m
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.15.12[22m powered by rolldown [2mv1.0.0-beta.45[22m
|
|
6
|
+
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
7
|
+
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
8
|
+
[34mℹ[39m Build start
|
|
9
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mindex.cjs[22m [2m3.16 kB[22m [2m│ gzip: 1.14 kB[22m
|
|
10
|
+
[34mℹ[39m [33m[CJS][39m 1 files, total: 3.16 kB
|
|
11
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mindex.js[22m [2m2.07 kB[22m [2m│ gzip: 0.71 kB[22m
|
|
12
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m0.26 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
13
|
+
[34mℹ[39m [34m[ESM][39m 2 files, total: 2.33 kB
|
|
14
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mindex.d.cts[22m[39m [2m0.26 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
15
|
+
[34mℹ[39m [33m[CJS][39m 1 files, total: 0.26 kB
|
|
16
|
+
[32m✔[39m Build complete in [32m1091ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#633](https://github.com/sdorra/content-collections/pull/633) [`86490bc`](https://github.com/sdorra/content-collections/commit/86490bc8815ba03ede8c3a9dcb45931cd686db9c) Thanks [@sdorra](https://github.com/sdorra)! - Log skipped documents
|
|
14
|
+
|
|
3
15
|
## 0.2.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,98 +1,77 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
39
|
-
|
|
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
|
-
|
|
30
|
+
return !handledErrors.includes(event);
|
|
43
31
|
}
|
|
44
32
|
function registerErrorListeners(builder) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
builder.on("_error", ({ _event, error }) => {
|
|
90
|
-
if (isUnknownError(_event)) {
|
|
91
|
-
console.log("... error", error.message);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
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
|
+
});
|
|
94
74
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
exports.configureLogging = configureLogging;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { Builder } from
|
|
1
|
+
import { Builder } from "@content-collections/core";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
1
|
+
import { Builder } from "@content-collections/core";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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,63 +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
|
-
|
|
2
|
+
|
|
3
|
+
//#region src/errors.ts
|
|
4
|
+
const handledErrors = ["transformer:validation-error", "collector:parse-error"];
|
|
7
5
|
function isUnknownError(event) {
|
|
8
|
-
|
|
6
|
+
return !handledErrors.includes(event);
|
|
9
7
|
}
|
|
10
8
|
function registerErrorListeners(builder) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
builder.on("_error", ({ _event, error }) => {
|
|
56
|
-
if (isUnknownError(_event)) {
|
|
57
|
-
console.log("... error", error.message);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
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
|
+
});
|
|
60
50
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { configureLogging };
|
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@content-collections/integrations",
|
|
3
|
-
"description": "Utils for integrating Content Collections with other tools",
|
|
4
|
-
"version": "0.2.1",
|
|
5
3
|
"type": "module",
|
|
4
|
+
"version": "0.4.0",
|
|
5
|
+
"description": "Utils for integrating Content Collections with other tools",
|
|
6
|
+
"author": "Sebastian Sdorra <s.sdorra@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://content-collections.dev",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/sdorra/content-collections.git",
|
|
12
|
+
"directory": "packages/integrations"
|
|
13
|
+
},
|
|
14
|
+
"bugs": "https://github.com/sdorra/content-collections/issues",
|
|
6
15
|
"main": "dist/index.cjs",
|
|
7
16
|
"module": "dist/index.js",
|
|
8
17
|
"types": "./dist/index.d.ts",
|
|
@@ -16,14 +25,14 @@
|
|
|
16
25
|
},
|
|
17
26
|
"devDependencies": {
|
|
18
27
|
"@types/node": "20",
|
|
19
|
-
"
|
|
28
|
+
"tsdown": "^0.15.12",
|
|
20
29
|
"typescript": "^5.5.4",
|
|
21
|
-
"@content-collections/core": "0.
|
|
30
|
+
"@content-collections/core": "0.13.0"
|
|
22
31
|
},
|
|
23
32
|
"peerDependencies": {
|
|
24
33
|
"@content-collections/core": "0.x"
|
|
25
34
|
},
|
|
26
35
|
"scripts": {
|
|
27
|
-
"build": "
|
|
36
|
+
"build": "tsdown src/index.ts --format esm,cjs --dts -d dist"
|
|
28
37
|
}
|
|
29
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
|
-
|
|
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
|
});
|
|
@@ -31,11 +43,17 @@ export function configureLogging(builder: Builder) {
|
|
|
31
43
|
}
|
|
32
44
|
});
|
|
33
45
|
|
|
46
|
+
builder.on("transformer:document-skipped", (event) => {
|
|
47
|
+
const relativePath = path.relative(process.cwd(), event.filePath);
|
|
48
|
+
console.log("... document", relativePath, "skipped", "due to", event.reason);
|
|
49
|
+
});
|
|
50
|
+
|
|
34
51
|
registerErrorListeners(builder);
|
|
35
52
|
|
|
36
53
|
builder.on("_error", ({ _event, error }) => {
|
|
37
54
|
if (isUnknownError(_event)) {
|
|
38
55
|
console.log("... error", error.message);
|
|
39
56
|
}
|
|
57
|
+
options.handleError?.(error);
|
|
40
58
|
});
|
|
41
59
|
}
|