@powerlines/plugin-content-collections 0.1.457 → 0.1.459
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/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/helpers/create-emitter.cjs +34 -1
- package/dist/helpers/create-emitter.mjs +32 -1
- package/dist/helpers/create-emitter.mjs.map +1 -1
- package/dist/helpers/create-writer.cjs +42 -5
- package/dist/helpers/create-writer.mjs +39 -5
- package/dist/helpers/create-writer.mjs.map +1 -1
- package/dist/helpers/index.cjs +6 -1
- package/dist/helpers/index.mjs +4 -1
- package/dist/index.cjs +67 -1
- package/dist/index.mjs +61 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +4 -4
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let node_events = require("node:events");
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/create-emitter.ts
|
|
6
|
+
/**
|
|
7
|
+
* Create an event emitter with typed events.
|
|
8
|
+
*
|
|
9
|
+
* @returns An event emitter instance with typed event handling.
|
|
10
|
+
*/
|
|
11
|
+
function createEmitter() {
|
|
12
|
+
const emitter = new node_events.EventEmitter();
|
|
13
|
+
function on(key, listener) {
|
|
14
|
+
emitter.on(key, listener);
|
|
15
|
+
}
|
|
16
|
+
function emit(key, event) {
|
|
17
|
+
emitter.emit(key, event);
|
|
18
|
+
if (typeof event === "object" && event !== null && "error" in event) emitter.emit("_error", {
|
|
19
|
+
...event,
|
|
20
|
+
_event: key
|
|
21
|
+
});
|
|
22
|
+
emitter.emit("_all", {
|
|
23
|
+
...event,
|
|
24
|
+
_event: key
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
on,
|
|
29
|
+
emit
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.createEmitter = createEmitter;
|
|
@@ -1,2 +1,33 @@
|
|
|
1
|
-
import{EventEmitter
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/create-emitter.ts
|
|
4
|
+
/**
|
|
5
|
+
* Create an event emitter with typed events.
|
|
6
|
+
*
|
|
7
|
+
* @returns An event emitter instance with typed event handling.
|
|
8
|
+
*/
|
|
9
|
+
function createEmitter() {
|
|
10
|
+
const emitter = new EventEmitter();
|
|
11
|
+
function on(key, listener) {
|
|
12
|
+
emitter.on(key, listener);
|
|
13
|
+
}
|
|
14
|
+
function emit(key, event) {
|
|
15
|
+
emitter.emit(key, event);
|
|
16
|
+
if (typeof event === "object" && event !== null && "error" in event) emitter.emit("_error", {
|
|
17
|
+
...event,
|
|
18
|
+
_event: key
|
|
19
|
+
});
|
|
20
|
+
emitter.emit("_all", {
|
|
21
|
+
...event,
|
|
22
|
+
_event: key
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
on,
|
|
27
|
+
emit
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { createEmitter };
|
|
2
33
|
//# sourceMappingURL=create-emitter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-emitter.mjs","names":[],"sources":["../../src/helpers/create-emitter.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { EventEmitter } from \"node:events\";\n\ntype EventMap = Record<string, object>;\n\ninterface EventWithError {\n error: Error;\n}\n\ninterface SystemEvent {\n _event: string;\n}\n\ntype ErrorEvent = EventWithError & SystemEvent;\n\ninterface SystemEvents extends EventMap {\n _error: ErrorEvent;\n _all: SystemEvent;\n}\n\ntype Keys<TEvents extends EventMap> = keyof TEvents & string;\ntype Listener<TEvent> = (event: TEvent) => void;\n\n/**\n * Create an event emitter with typed events.\n *\n * @returns An event emitter instance with typed event handling.\n */\nexport function createEmitter<TEvents extends EventMap>() {\n const emitter = new EventEmitter();\n\n function on<TKey extends Keys<TEvents>>(\n key: TKey,\n listener: Listener<TEvents[TKey]>\n ): void;\n\n function on<TKey extends Keys<SystemEvents>>(\n key: TKey,\n listener: Listener<SystemEvents[TKey]>\n ): void;\n\n function on(key: string, listener: Listener<any>) {\n emitter.on(key, listener);\n }\n\n function emit<TKey extends Keys<TEvents>>(key: TKey, event: TEvents[TKey]) {\n emitter.emit(key, event);\n\n if (typeof event === \"object\" && event !== null && \"error\" in event) {\n emitter.emit(\"_error\", {\n ...event,\n _event: key\n });\n }\n\n emitter.emit(\"_all\", {\n ...event,\n _event: key\n });\n }\n\n return {\n on,\n emit\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-emitter.mjs","names":[],"sources":["../../src/helpers/create-emitter.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { EventEmitter } from \"node:events\";\n\ntype EventMap = Record<string, object>;\n\ninterface EventWithError {\n error: Error;\n}\n\ninterface SystemEvent {\n _event: string;\n}\n\ntype ErrorEvent = EventWithError & SystemEvent;\n\ninterface SystemEvents extends EventMap {\n _error: ErrorEvent;\n _all: SystemEvent;\n}\n\ntype Keys<TEvents extends EventMap> = keyof TEvents & string;\ntype Listener<TEvent> = (event: TEvent) => void;\n\n/**\n * Create an event emitter with typed events.\n *\n * @returns An event emitter instance with typed event handling.\n */\nexport function createEmitter<TEvents extends EventMap>() {\n const emitter = new EventEmitter();\n\n function on<TKey extends Keys<TEvents>>(\n key: TKey,\n listener: Listener<TEvents[TKey]>\n ): void;\n\n function on<TKey extends Keys<SystemEvents>>(\n key: TKey,\n listener: Listener<SystemEvents[TKey]>\n ): void;\n\n function on(key: string, listener: Listener<any>) {\n emitter.on(key, listener);\n }\n\n function emit<TKey extends Keys<TEvents>>(key: TKey, event: TEvents[TKey]) {\n emitter.emit(key, event);\n\n if (typeof event === \"object\" && event !== null && \"error\" in event) {\n emitter.emit(\"_error\", {\n ...event,\n _event: key\n });\n }\n\n emitter.emit(\"_all\", {\n ...event,\n _event: key\n });\n }\n\n return {\n on,\n emit\n };\n}\n"],"mappings":";;;;;;;;AA6CA,SAAgB,gBAA0C;CACxD,MAAM,UAAU,IAAI,cAAc;CAYlC,SAAS,GAAG,KAAa,UAAyB;AAChD,UAAQ,GAAG,KAAK,SAAS;;CAG3B,SAAS,KAAiC,KAAW,OAAsB;AACzE,UAAQ,KAAK,KAAK,MAAM;AAExB,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,WAAW,MAC5D,SAAQ,KAAK,UAAU;GACrB,GAAG;GACH,QAAQ;GACT,CAAC;AAGJ,UAAQ,KAAK,QAAQ;GACnB,GAAG;GACH,QAAQ;GACT,CAAC;;AAGJ,QAAO;EACL;EACA;EACD"}
|
|
@@ -1,6 +1,43 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _content_collections_core = require("@content-collections/core");
|
|
4
|
+
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
5
|
+
let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
6
|
+
let pluralize = require("pluralize");
|
|
7
|
+
pluralize = require_runtime.__toESM(pluralize, 1);
|
|
8
|
+
let powerlines_utils = require("powerlines/utils");
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
//#region src/helpers/create-writer.ts
|
|
11
|
+
const createConstName = (name) => {
|
|
12
|
+
return (0, pluralize.default)(name.charAt(0).toUpperCase() + name.slice(1));
|
|
13
|
+
};
|
|
14
|
+
const createArrayConstName = (name) => {
|
|
15
|
+
return `all${createConstName(name)}`;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Creates a Writer instance for emitting files related to content collections.
|
|
19
|
+
*
|
|
20
|
+
* @param context - The Powerlines build plugin
|
|
21
|
+
* @returns A Writer instance for emitting files related to content collections
|
|
22
|
+
*/
|
|
23
|
+
const createWriter = (context) => {
|
|
24
|
+
return {
|
|
25
|
+
createJavaScriptFile: async (configuration) => {
|
|
26
|
+
return context.emitBuiltin(`${(0, powerlines_utils.getFileHeader)(context)}
|
|
27
|
+
${configuration.collections.map(({ name }) => `import ${createArrayConstName(name)} from "./${(0, _stryke_string_format_kebab_case.kebabCase)(name)}";`).join("\n")}
|
|
28
|
+
|
|
29
|
+
export { ${configuration.collections.map(({ name }) => createArrayConstName(name)).join(", ")} };
|
|
30
|
+
`, "content");
|
|
31
|
+
},
|
|
32
|
+
createTypeDefinitionFile: async (_) => Promise.resolve(),
|
|
33
|
+
createDataFiles: async (collections) => {
|
|
34
|
+
await Promise.all(collections.map(async (collection) => {
|
|
35
|
+
if (context.config.contentCollections.outputPath) return context.fs.write((0, _stryke_path_join_paths.joinPaths)(context.config.contentCollections.outputPath, (0, _stryke_string_format_kebab_case.kebabCase)(collection.name)), (0, _content_collections_core.serialize)(collection.documents.map((doc) => doc.document)));
|
|
36
|
+
return context.emitBuiltin((0, _content_collections_core.serialize)(collection.documents.map((doc) => doc.document)), (0, _stryke_path_join_paths.joinPaths)("content", (0, _stryke_string_format_kebab_case.kebabCase)(collection.name)));
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.createWriter = createWriter;
|
|
@@ -1,7 +1,41 @@
|
|
|
1
|
-
import{serialize
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { serialize } from "@content-collections/core";
|
|
2
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
3
|
+
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
4
|
+
import pluralize from "pluralize";
|
|
5
|
+
import { getFileHeader } from "powerlines/utils";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
//#region src/helpers/create-writer.ts
|
|
8
|
+
const createConstName = (name) => {
|
|
9
|
+
return pluralize(name.charAt(0).toUpperCase() + name.slice(1));
|
|
10
|
+
};
|
|
11
|
+
const createArrayConstName = (name) => {
|
|
12
|
+
return `all${createConstName(name)}`;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Creates a Writer instance for emitting files related to content collections.
|
|
16
|
+
*
|
|
17
|
+
* @param context - The Powerlines build plugin
|
|
18
|
+
* @returns A Writer instance for emitting files related to content collections
|
|
19
|
+
*/
|
|
20
|
+
const createWriter = (context) => {
|
|
21
|
+
return {
|
|
22
|
+
createJavaScriptFile: async (configuration) => {
|
|
23
|
+
return context.emitBuiltin(`${getFileHeader(context)}
|
|
24
|
+
${configuration.collections.map(({ name }) => `import ${createArrayConstName(name)} from "./${kebabCase(name)}";`).join("\n")}
|
|
25
|
+
|
|
26
|
+
export { ${configuration.collections.map(({ name }) => createArrayConstName(name)).join(", ")} };
|
|
27
|
+
`, "content");
|
|
28
|
+
},
|
|
29
|
+
createTypeDefinitionFile: async (_) => Promise.resolve(),
|
|
30
|
+
createDataFiles: async (collections) => {
|
|
31
|
+
await Promise.all(collections.map(async (collection) => {
|
|
32
|
+
if (context.config.contentCollections.outputPath) return context.fs.write(joinPaths(context.config.contentCollections.outputPath, kebabCase(collection.name)), serialize(collection.documents.map((doc) => doc.document)));
|
|
33
|
+
return context.emitBuiltin(serialize(collection.documents.map((doc) => doc.document)), joinPaths("content", kebabCase(collection.name)));
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { createWriter };
|
|
7
41
|
//# sourceMappingURL=create-writer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-writer.mjs","names":[],"sources":["../../src/helpers/create-writer.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n DataFileCollection,\n JavaScriptFileConfiguration,\n serialize,\n TypeDefinitionFileConfiguration,\n Writer\n} from \"@content-collections/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport pluralize from \"pluralize\";\nimport { getFileHeader } from \"powerlines/utils\";\nimport { ContentCollectionsPluginContext } from \"../types/plugin\";\n\nconst createConstName = (name: string) => {\n return pluralize(name.charAt(0).toUpperCase() + name.slice(1));\n};\n\nconst createArrayConstName = (name: string) => {\n return `all${createConstName(name)}`;\n};\n\n/**\n * Creates a Writer instance for emitting files related to content collections.\n *\n * @param context - The Powerlines build plugin\n * @returns A Writer instance for emitting files related to content collections\n */\nexport const createWriter = (\n context: ContentCollectionsPluginContext\n): Writer => {\n return {\n createJavaScriptFile: async (\n configuration: JavaScriptFileConfiguration\n ) => {\n return context.emitBuiltin(\n `${getFileHeader(context)}\n${configuration.collections\n .map(\n ({ name }) =>\n `import ${createArrayConstName(name)} from \"./${kebabCase(name)}\";`\n )\n .join(\"\\n\")}\n\nexport { ${configuration.collections\n .map(({ name }) => createArrayConstName(name))\n .join(\", \")} };\n`,\n \"content\"\n );\n },\n createTypeDefinitionFile: async (_: TypeDefinitionFileConfiguration) =>\n Promise.resolve(),\n createDataFiles: async (collections: Array<DataFileCollection>) => {\n await Promise.all(\n collections.map(async collection => {\n if (context.config.contentCollections.outputPath) {\n return context.fs.write(\n joinPaths(\n context.config.contentCollections.outputPath,\n kebabCase(collection.name)\n ),\n serialize(collection.documents.map(doc => doc.document))\n );\n }\n\n return context.emitBuiltin(\n serialize(collection.documents.map(doc => doc.document)),\n joinPaths(\"content\", kebabCase(collection.name))\n );\n })\n );\n }\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-writer.mjs","names":[],"sources":["../../src/helpers/create-writer.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n DataFileCollection,\n JavaScriptFileConfiguration,\n serialize,\n TypeDefinitionFileConfiguration,\n Writer\n} from \"@content-collections/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport pluralize from \"pluralize\";\nimport { getFileHeader } from \"powerlines/utils\";\nimport { ContentCollectionsPluginContext } from \"../types/plugin\";\n\nconst createConstName = (name: string) => {\n return pluralize(name.charAt(0).toUpperCase() + name.slice(1));\n};\n\nconst createArrayConstName = (name: string) => {\n return `all${createConstName(name)}`;\n};\n\n/**\n * Creates a Writer instance for emitting files related to content collections.\n *\n * @param context - The Powerlines build plugin\n * @returns A Writer instance for emitting files related to content collections\n */\nexport const createWriter = (\n context: ContentCollectionsPluginContext\n): Writer => {\n return {\n createJavaScriptFile: async (\n configuration: JavaScriptFileConfiguration\n ) => {\n return context.emitBuiltin(\n `${getFileHeader(context)}\n${configuration.collections\n .map(\n ({ name }) =>\n `import ${createArrayConstName(name)} from \"./${kebabCase(name)}\";`\n )\n .join(\"\\n\")}\n\nexport { ${configuration.collections\n .map(({ name }) => createArrayConstName(name))\n .join(\", \")} };\n`,\n \"content\"\n );\n },\n createTypeDefinitionFile: async (_: TypeDefinitionFileConfiguration) =>\n Promise.resolve(),\n createDataFiles: async (collections: Array<DataFileCollection>) => {\n await Promise.all(\n collections.map(async collection => {\n if (context.config.contentCollections.outputPath) {\n return context.fs.write(\n joinPaths(\n context.config.contentCollections.outputPath,\n kebabCase(collection.name)\n ),\n serialize(collection.documents.map(doc => doc.document))\n );\n }\n\n return context.emitBuiltin(\n serialize(collection.documents.map(doc => doc.document)),\n joinPaths(\"content\", kebabCase(collection.name))\n );\n })\n );\n }\n };\n};\n"],"mappings":";;;;;;;AA+BA,MAAM,mBAAmB,SAAiB;AACxC,QAAO,UAAU,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE,CAAC;;AAGhE,MAAM,wBAAwB,SAAiB;AAC7C,QAAO,MAAM,gBAAgB,KAAK;;;;;;;;AASpC,MAAa,gBACX,YACW;AACX,QAAO;EACL,sBAAsB,OACpB,kBACG;AACH,UAAO,QAAQ,YACb,GAAG,cAAc,QAAQ,CAAC;EAChC,cAAc,YACb,KACE,EAAE,WACD,UAAU,qBAAqB,KAAK,CAAC,WAAW,UAAU,KAAK,CAAC,IACnE,CACA,KAAK,KAAK,CAAC;;WAEH,cAAc,YACd,KAAK,EAAE,WAAW,qBAAqB,KAAK,CAAC,CAC7C,KAAK,KAAK,CAAC;GAEd,UACD;;EAEH,0BAA0B,OAAO,MAC/B,QAAQ,SAAS;EACnB,iBAAiB,OAAO,gBAA2C;AACjE,SAAM,QAAQ,IACZ,YAAY,IAAI,OAAM,eAAc;AAClC,QAAI,QAAQ,OAAO,mBAAmB,WACpC,QAAO,QAAQ,GAAG,MAChB,UACE,QAAQ,OAAO,mBAAmB,YAClC,UAAU,WAAW,KAAK,CAC3B,EACD,UAAU,WAAW,UAAU,KAAI,QAAO,IAAI,SAAS,CAAC,CACzD;AAGH,WAAO,QAAQ,YACb,UAAU,WAAW,UAAU,KAAI,QAAO,IAAI,SAAS,CAAC,EACxD,UAAU,WAAW,UAAU,WAAW,KAAK,CAAC,CACjD;KACD,CACH;;EAEJ"}
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_helpers_create_emitter = require('./create-emitter.cjs');
|
|
3
|
+
const require_helpers_create_writer = require('./create-writer.cjs');
|
|
4
|
+
|
|
5
|
+
exports.createEmitter = require_helpers_create_emitter.createEmitter;
|
|
6
|
+
exports.createWriter = require_helpers_create_writer.createWriter;
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{createEmitter
|
|
1
|
+
import { createEmitter } from "./create-emitter.mjs";
|
|
2
|
+
import { createWriter } from "./create-writer.mjs";
|
|
3
|
+
|
|
4
|
+
export { createEmitter, createWriter };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,67 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_helpers_create_emitter = require('./helpers/create-emitter.cjs');
|
|
4
|
+
const require_helpers_create_writer = require('./helpers/create-writer.cjs');
|
|
5
|
+
require('./helpers/index.cjs');
|
|
6
|
+
let _content_collections_core = require("@content-collections/core");
|
|
7
|
+
let _stryke_fs_exists = require("@stryke/fs/exists");
|
|
8
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
9
|
+
let defu = require("defu");
|
|
10
|
+
defu = require_runtime.__toESM(defu, 1);
|
|
11
|
+
let node_crypto = require("node:crypto");
|
|
12
|
+
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
13
|
+
|
|
14
|
+
//#region src/index.ts
|
|
15
|
+
/**
|
|
16
|
+
* A Powerlines plugin to integrate Content Collections for code generation.
|
|
17
|
+
*
|
|
18
|
+
* @param options - The plugin options.
|
|
19
|
+
* @returns A Powerlines plugin instance.
|
|
20
|
+
*/
|
|
21
|
+
const plugin = (options) => {
|
|
22
|
+
return {
|
|
23
|
+
name: "content-collections",
|
|
24
|
+
config() {
|
|
25
|
+
return { contentCollections: (0, defu.default)(options, {
|
|
26
|
+
configFile: "{root}/content-collections.ts",
|
|
27
|
+
collections: []
|
|
28
|
+
}) };
|
|
29
|
+
},
|
|
30
|
+
async configResolved() {
|
|
31
|
+
this.config.contentCollections.configFile ||= (0, powerlines_plugin_utils.replacePathTokens)(this, this.config.contentCollections.configFile);
|
|
32
|
+
this.config.contentCollections.outputPath ||= (0, powerlines_plugin_utils.replacePathTokens)(this, this.config.contentCollections.outputPath);
|
|
33
|
+
const emitter = require_helpers_create_emitter.createEmitter();
|
|
34
|
+
const readConfiguration = (0, _content_collections_core.createConfigurationReader)();
|
|
35
|
+
let configuration = {};
|
|
36
|
+
try {
|
|
37
|
+
if ((0, _stryke_fs_exists.existsSync)(this.config.contentCollections.configFile)) configuration = await readConfiguration(this.config.contentCollections.configFile, {
|
|
38
|
+
configName: "config.mjs",
|
|
39
|
+
cacheDir: (0, _stryke_path_join.joinPaths)(this.cachePath, "content-collections")
|
|
40
|
+
});
|
|
41
|
+
} catch {}
|
|
42
|
+
configuration = (0, defu.default)(configuration ?? {}, this.config.contentCollections);
|
|
43
|
+
configuration.checksum = (0, node_crypto.createHash)("sha256").update(JSON.stringify(configuration)).digest("hex");
|
|
44
|
+
const context = await (0, _content_collections_core.createBuildContext)({
|
|
45
|
+
emitter,
|
|
46
|
+
baseDirectory: (0, _stryke_path_join.joinPaths)(this.config.cwd, this.config.root),
|
|
47
|
+
outputDirectory: this.config.contentCollections.outputPath || (0, _stryke_path_join.joinPaths)(this.builtinsPath, "content"),
|
|
48
|
+
configuration
|
|
49
|
+
});
|
|
50
|
+
context.writer = require_helpers_create_writer.createWriter(this);
|
|
51
|
+
this.contentCollections = {
|
|
52
|
+
context,
|
|
53
|
+
build: async () => (0, _content_collections_core.build)(context),
|
|
54
|
+
on: emitter.on
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
async prepare() {
|
|
58
|
+
return this.contentCollections.build();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
exports.createEmitter = require_helpers_create_emitter.createEmitter;
|
|
65
|
+
exports.createWriter = require_helpers_create_writer.createWriter;
|
|
66
|
+
exports.default = plugin;
|
|
67
|
+
exports.plugin = plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,62 @@
|
|
|
1
|
-
import{createEmitter
|
|
1
|
+
import { createEmitter } from "./helpers/create-emitter.mjs";
|
|
2
|
+
import { createWriter } from "./helpers/create-writer.mjs";
|
|
3
|
+
import "./helpers/index.mjs";
|
|
4
|
+
import { build, createBuildContext, createConfigurationReader } from "@content-collections/core";
|
|
5
|
+
import { existsSync } from "@stryke/fs/exists";
|
|
6
|
+
import { joinPaths } from "@stryke/path/join";
|
|
7
|
+
import defu from "defu";
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
|
+
import { replacePathTokens } from "powerlines/plugin-utils";
|
|
10
|
+
|
|
11
|
+
//#region src/index.ts
|
|
12
|
+
/**
|
|
13
|
+
* A Powerlines plugin to integrate Content Collections for code generation.
|
|
14
|
+
*
|
|
15
|
+
* @param options - The plugin options.
|
|
16
|
+
* @returns A Powerlines plugin instance.
|
|
17
|
+
*/
|
|
18
|
+
const plugin = (options) => {
|
|
19
|
+
return {
|
|
20
|
+
name: "content-collections",
|
|
21
|
+
config() {
|
|
22
|
+
return { contentCollections: defu(options, {
|
|
23
|
+
configFile: "{root}/content-collections.ts",
|
|
24
|
+
collections: []
|
|
25
|
+
}) };
|
|
26
|
+
},
|
|
27
|
+
async configResolved() {
|
|
28
|
+
this.config.contentCollections.configFile ||= replacePathTokens(this, this.config.contentCollections.configFile);
|
|
29
|
+
this.config.contentCollections.outputPath ||= replacePathTokens(this, this.config.contentCollections.outputPath);
|
|
30
|
+
const emitter = createEmitter();
|
|
31
|
+
const readConfiguration = createConfigurationReader();
|
|
32
|
+
let configuration = {};
|
|
33
|
+
try {
|
|
34
|
+
if (existsSync(this.config.contentCollections.configFile)) configuration = await readConfiguration(this.config.contentCollections.configFile, {
|
|
35
|
+
configName: "config.mjs",
|
|
36
|
+
cacheDir: joinPaths(this.cachePath, "content-collections")
|
|
37
|
+
});
|
|
38
|
+
} catch {}
|
|
39
|
+
configuration = defu(configuration ?? {}, this.config.contentCollections);
|
|
40
|
+
configuration.checksum = createHash("sha256").update(JSON.stringify(configuration)).digest("hex");
|
|
41
|
+
const context = await createBuildContext({
|
|
42
|
+
emitter,
|
|
43
|
+
baseDirectory: joinPaths(this.config.cwd, this.config.root),
|
|
44
|
+
outputDirectory: this.config.contentCollections.outputPath || joinPaths(this.builtinsPath, "content"),
|
|
45
|
+
configuration
|
|
46
|
+
});
|
|
47
|
+
context.writer = createWriter(this);
|
|
48
|
+
this.contentCollections = {
|
|
49
|
+
context,
|
|
50
|
+
build: async () => build(context),
|
|
51
|
+
on: emitter.on
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
async prepare() {
|
|
55
|
+
return this.contentCollections.build();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { createEmitter, createWriter, plugin as default, plugin };
|
|
2
62
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n build,\n createBuildContext,\n createConfigurationReader,\n InternalConfiguration\n} from \"@content-collections/core\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport defu from \"defu\";\nimport { createHash } from \"node:crypto\";\nimport { Plugin } from \"powerlines\";\nimport { replacePathTokens } from \"powerlines/plugin-utils\";\nimport { createEmitter } from \"./helpers/create-emitter\";\nimport { createWriter } from \"./helpers/create-writer\";\nimport {\n ContentCollectionsPluginContext,\n ContentCollectionsPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n contentCollections?: ContentCollectionsPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to integrate Content Collections for code generation.\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends ContentCollectionsPluginContext =\n ContentCollectionsPluginContext\n>(\n options: ContentCollectionsPluginOptions\n): Plugin<TContext> => {\n return {\n name: \"content-collections\",\n config() {\n return {\n contentCollections: defu(options, {\n configFile: \"{root}/content-collections.ts\",\n collections: []\n })\n };\n },\n async configResolved() {\n this.config.contentCollections.configFile ||= replacePathTokens(\n this,\n this.config.contentCollections.configFile\n );\n\n this.config.contentCollections.outputPath ||= replacePathTokens(\n this,\n this.config.contentCollections.outputPath\n );\n\n const emitter = createEmitter();\n const readConfiguration = createConfigurationReader();\n\n let configuration = {} as InternalConfiguration;\n try {\n if (existsSync(this.config.contentCollections.configFile)) {\n configuration = await readConfiguration(\n this.config.contentCollections.configFile,\n {\n configName: \"config.mjs\",\n cacheDir: joinPaths(this.cachePath, \"content-collections\")\n }\n );\n }\n } catch {\n // Do nothing\n }\n\n configuration = defu(configuration ?? {}, this.config.contentCollections);\n configuration.checksum = createHash(\"sha256\")\n .update(JSON.stringify(configuration))\n .digest(\"hex\");\n\n const context = await createBuildContext({\n emitter,\n baseDirectory: joinPaths(this.config.cwd, this.config.root),\n outputDirectory:\n this.config.contentCollections.outputPath ||\n joinPaths(this.builtinsPath, \"content\"),\n configuration\n });\n context.writer = createWriter(this);\n\n this.contentCollections = {\n context,\n build: async () => build(context),\n on: emitter.on\n };\n },\n async prepare() {\n return this.contentCollections.build();\n }\n };\n};\n\nexport default plugin;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n build,\n createBuildContext,\n createConfigurationReader,\n InternalConfiguration\n} from \"@content-collections/core\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport defu from \"defu\";\nimport { createHash } from \"node:crypto\";\nimport { Plugin } from \"powerlines\";\nimport { replacePathTokens } from \"powerlines/plugin-utils\";\nimport { createEmitter } from \"./helpers/create-emitter\";\nimport { createWriter } from \"./helpers/create-writer\";\nimport {\n ContentCollectionsPluginContext,\n ContentCollectionsPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n contentCollections?: ContentCollectionsPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to integrate Content Collections for code generation.\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends ContentCollectionsPluginContext =\n ContentCollectionsPluginContext\n>(\n options: ContentCollectionsPluginOptions\n): Plugin<TContext> => {\n return {\n name: \"content-collections\",\n config() {\n return {\n contentCollections: defu(options, {\n configFile: \"{root}/content-collections.ts\",\n collections: []\n })\n };\n },\n async configResolved() {\n this.config.contentCollections.configFile ||= replacePathTokens(\n this,\n this.config.contentCollections.configFile\n );\n\n this.config.contentCollections.outputPath ||= replacePathTokens(\n this,\n this.config.contentCollections.outputPath\n );\n\n const emitter = createEmitter();\n const readConfiguration = createConfigurationReader();\n\n let configuration = {} as InternalConfiguration;\n try {\n if (existsSync(this.config.contentCollections.configFile)) {\n configuration = await readConfiguration(\n this.config.contentCollections.configFile,\n {\n configName: \"config.mjs\",\n cacheDir: joinPaths(this.cachePath, \"content-collections\")\n }\n );\n }\n } catch {\n // Do nothing\n }\n\n configuration = defu(configuration ?? {}, this.config.contentCollections);\n configuration.checksum = createHash(\"sha256\")\n .update(JSON.stringify(configuration))\n .digest(\"hex\");\n\n const context = await createBuildContext({\n emitter,\n baseDirectory: joinPaths(this.config.cwd, this.config.root),\n outputDirectory:\n this.config.contentCollections.outputPath ||\n joinPaths(this.builtinsPath, \"content\"),\n configuration\n });\n context.writer = createWriter(this);\n\n this.contentCollections = {\n context,\n build: async () => build(context),\n on: emitter.on\n };\n },\n async prepare() {\n return this.contentCollections.build();\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;AAoDA,MAAa,UAIX,YACqB;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,UAAO,EACL,oBAAoB,KAAK,SAAS;IAChC,YAAY;IACZ,aAAa,EAAE;IAChB,CAAC,EACH;;EAEH,MAAM,iBAAiB;AACrB,QAAK,OAAO,mBAAmB,eAAe,kBAC5C,MACA,KAAK,OAAO,mBAAmB,WAChC;AAED,QAAK,OAAO,mBAAmB,eAAe,kBAC5C,MACA,KAAK,OAAO,mBAAmB,WAChC;GAED,MAAM,UAAU,eAAe;GAC/B,MAAM,oBAAoB,2BAA2B;GAErD,IAAI,gBAAgB,EAAE;AACtB,OAAI;AACF,QAAI,WAAW,KAAK,OAAO,mBAAmB,WAAW,CACvD,iBAAgB,MAAM,kBACpB,KAAK,OAAO,mBAAmB,YAC/B;KACE,YAAY;KACZ,UAAU,UAAU,KAAK,WAAW,sBAAsB;KAC3D,CACF;WAEG;AAIR,mBAAgB,KAAK,iBAAiB,EAAE,EAAE,KAAK,OAAO,mBAAmB;AACzE,iBAAc,WAAW,WAAW,SAAS,CAC1C,OAAO,KAAK,UAAU,cAAc,CAAC,CACrC,OAAO,MAAM;GAEhB,MAAM,UAAU,MAAM,mBAAmB;IACvC;IACA,eAAe,UAAU,KAAK,OAAO,KAAK,KAAK,OAAO,KAAK;IAC3D,iBACE,KAAK,OAAO,mBAAmB,cAC/B,UAAU,KAAK,cAAc,UAAU;IACzC;IACD,CAAC;AACF,WAAQ,SAAS,aAAa,KAAK;AAEnC,QAAK,qBAAqB;IACxB;IACA,OAAO,YAAY,MAAM,QAAQ;IACjC,IAAI,QAAQ;IACb;;EAEH,MAAM,UAAU;AACd,UAAO,KAAK,mBAAmB,OAAO;;EAEzC"}
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-content-collections",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.459",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Powerlines plugin to generate project code using Content Collections.",
|
|
6
6
|
"keywords": [
|
|
@@ -145,11 +145,11 @@
|
|
|
145
145
|
"@stryke/types": "^0.12.0",
|
|
146
146
|
"defu": "^6.1.7",
|
|
147
147
|
"pluralize": "^8.0.0",
|
|
148
|
-
"powerlines": "^0.46.
|
|
148
|
+
"powerlines": "^0.46.6"
|
|
149
149
|
},
|
|
150
150
|
"devDependencies": {
|
|
151
151
|
"@content-collections/core": "^0.12.0",
|
|
152
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
152
|
+
"@powerlines/plugin-plugin": "^0.12.410",
|
|
153
153
|
"@types/node": "^25.6.0",
|
|
154
154
|
"@types/pluralize": "^0.0.33"
|
|
155
155
|
},
|
|
@@ -158,5 +158,5 @@
|
|
|
158
158
|
"@content-collections/core": { "optional": false }
|
|
159
159
|
},
|
|
160
160
|
"publishConfig": { "access": "public" },
|
|
161
|
-
"gitHead": "
|
|
161
|
+
"gitHead": "610c4c943933458c5f433b9002d8c187625b2d3f"
|
|
162
162
|
}
|