@content-collections/integrations 0.1.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 +18 -0
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/dist/index.cjs +91 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +56 -0
- package/package.json +25 -0
- package/src/errors.ts +27 -0
- package/src/index.ts +33 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
> @content-collections/integrations@0.0.0 build /Users/sdorra/Projects/sdorra/content-collections/packages/integrations
|
|
3
|
+
> tsup src/index.ts --format esm,cjs --dts -d dist
|
|
4
|
+
|
|
5
|
+
CLI Building entry: src/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v7.2.0
|
|
8
|
+
CLI Target: es2022
|
|
9
|
+
ESM Build start
|
|
10
|
+
CJS Build start
|
|
11
|
+
ESM dist/index.js 1.50 KB
|
|
12
|
+
ESM ⚡️ Build success in 105ms
|
|
13
|
+
CJS dist/index.cjs 3.19 KB
|
|
14
|
+
CJS ⚡️ Build success in 106ms
|
|
15
|
+
DTS Build start
|
|
16
|
+
DTS ⚡️ Build success in 600ms
|
|
17
|
+
DTS dist/index.d.ts 143.00 B
|
|
18
|
+
DTS dist/index.d.cts 143.00 B
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @content-collections/integrations
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`52376e2`](https://github.com/sdorra/content-collections/commit/52376e2d7b5dff5c2376da57f76b273ef07e2af4) Thanks [@sdorra](https://github.com/sdorra)! - Add integration for Vite
|
|
8
|
+
|
|
9
|
+
- [`a0d3bb0`](https://github.com/sdorra/content-collections/commit/a0d3bb0103371809a41bffd23f4dc5a43b474e4e) Thanks [@sdorra](https://github.com/sdorra)! - Add integration for Next.js
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`842b7e0`](https://github.com/sdorra/content-collections/commit/842b7e0b221172eef51e203a833fbc256af4b501) Thanks [@sdorra](https://github.com/sdorra)! - Core should be a peer dependency of integrations
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`b4f640b`](https://github.com/sdorra/content-collections/commit/b4f640b26f18dbe9eb8b3913428010194d918ad1)]:
|
|
16
|
+
- @content-collections/core@0.1.1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Sebastian Sdorra
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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
|
+
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;
|
|
19
|
+
};
|
|
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);
|
|
29
|
+
|
|
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);
|
|
37
|
+
|
|
38
|
+
// src/errors.ts
|
|
39
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
40
|
+
var handledErrors = ["transformer:validation-error", "collector:parse-error"];
|
|
41
|
+
function isUnknownError(event) {
|
|
42
|
+
return !handledErrors.includes(event);
|
|
43
|
+
}
|
|
44
|
+
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
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
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 in",
|
|
70
|
+
event.endedAt - event.startedAt + "ms"
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
builder.on("watcher:file-changed", (event) => {
|
|
74
|
+
const relativePath = import_node_path2.default.relative(process.cwd(), event.filePath);
|
|
75
|
+
if (event.modification === "delete") {
|
|
76
|
+
console.log("... file deleted", relativePath);
|
|
77
|
+
} else {
|
|
78
|
+
console.log("... file changed", relativePath);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
registerErrorListeners(builder);
|
|
82
|
+
builder.on("_error", ({ _event, error }) => {
|
|
83
|
+
if (isUnknownError(_event)) {
|
|
84
|
+
console.log("... error", error.message);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
configureLogging
|
|
91
|
+
});
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import path2 from "path";
|
|
3
|
+
|
|
4
|
+
// src/errors.ts
|
|
5
|
+
import path from "path";
|
|
6
|
+
var handledErrors = ["transformer:validation-error", "collector:parse-error"];
|
|
7
|
+
function isUnknownError(event) {
|
|
8
|
+
return !handledErrors.includes(event);
|
|
9
|
+
}
|
|
10
|
+
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
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
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 in",
|
|
36
|
+
event.endedAt - event.startedAt + "ms"
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
builder.on("watcher:file-changed", (event) => {
|
|
40
|
+
const relativePath = path2.relative(process.cwd(), event.filePath);
|
|
41
|
+
if (event.modification === "delete") {
|
|
42
|
+
console.log("... file deleted", relativePath);
|
|
43
|
+
} else {
|
|
44
|
+
console.log("... file changed", relativePath);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
registerErrorListeners(builder);
|
|
48
|
+
builder.on("_error", ({ _event, error }) => {
|
|
49
|
+
if (isUnknownError(_event)) {
|
|
50
|
+
console.log("... error", error.message);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
configureLogging
|
|
56
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@content-collections/integrations",
|
|
3
|
+
"description": "Utils for integrating Content Collections with other tools",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@content-collections/core": "0.1.1"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@content-collections/core": "0.1.1"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup src/index.ts --format esm,cjs --dts -d dist"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Builder } from "@content-collections/core";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
const handledErrors = ["transformer:validation-error", "collector:parse-error"];
|
|
5
|
+
|
|
6
|
+
export function isUnknownError(event: string) {
|
|
7
|
+
return !handledErrors.includes(event);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function registerErrorListeners(builder: 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
|
+
|
|
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
|
+
});
|
|
27
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Builder } from "@content-collections/core";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { isUnknownError, registerErrorListeners } from "./errors.js";
|
|
4
|
+
|
|
5
|
+
export function configureLogging(builder: Builder) {
|
|
6
|
+
builder.on("builder:start", () => {
|
|
7
|
+
console.log("build started ...");
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
builder.on("builder:end", (event) => {
|
|
11
|
+
console.log(
|
|
12
|
+
"... finished build in",
|
|
13
|
+
event.endedAt - event.startedAt + "ms"
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
builder.on("watcher:file-changed", (event) => {
|
|
18
|
+
const relativePath = path.relative(process.cwd(), event.filePath);
|
|
19
|
+
if (event.modification === "delete") {
|
|
20
|
+
console.log("... file deleted", relativePath);
|
|
21
|
+
} else {
|
|
22
|
+
console.log("... file changed", relativePath);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
registerErrorListeners(builder);
|
|
27
|
+
|
|
28
|
+
builder.on("_error", ({ _event, error }) => {
|
|
29
|
+
if (isUnknownError(_event)) {
|
|
30
|
+
console.log("... error", error.message);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Base Options: */
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"skipLibCheck": true,
|
|
6
|
+
"target": "es2022",
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"moduleDetection": "force",
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
/* Strictness */
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noUncheckedIndexedAccess": true,
|
|
14
|
+
/* ink */
|
|
15
|
+
"jsx": "react-jsx",
|
|
16
|
+
/* If transpiling with TypeScript: */
|
|
17
|
+
"moduleResolution": "NodeNext",
|
|
18
|
+
"module": "NodeNext",
|
|
19
|
+
"outDir": "dist",
|
|
20
|
+
"sourceMap": true,
|
|
21
|
+
/* If your code doesn't run in the DOM: */
|
|
22
|
+
"lib": ["es2022"]
|
|
23
|
+
}
|
|
24
|
+
}
|