@powerlines/plugin-content-collections 0.1.123 → 0.1.125
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 -0
- package/dist/helpers/create-emitter.cjs +32 -2
- package/dist/helpers/create-emitter.d.cts +28 -1
- package/dist/helpers/create-emitter.d.mts +28 -1
- package/dist/helpers/create-emitter.mjs +30 -1
- package/dist/helpers/create-writer.cjs +40 -2
- package/dist/helpers/create-writer.d.cts +12 -2
- package/dist/helpers/create-writer.d.mts +12 -2
- package/dist/helpers/create-writer.mjs +37 -1
- package/dist/helpers/index.cjs +4 -5
- package/dist/helpers/index.d.cts +2 -4
- package/dist/helpers/index.d.mts +2 -4
- package/dist/helpers/index.mjs +2 -3
- package/dist/index.cjs +12 -45
- package/dist/index.d.cts +4 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +4 -38
- package/dist/powerlines/src/lib/utilities/file-header.cjs +13 -0
- package/dist/powerlines/src/lib/utilities/file-header.mjs +12 -0
- package/dist/powerlines/src/plugin-utils/paths.cjs +36 -0
- package/dist/powerlines/src/plugin-utils/paths.mjs +35 -0
- package/dist/powerlines/src/types/build.d.cts +145 -0
- package/dist/powerlines/src/types/build.d.mts +145 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +8 -0
- package/dist/powerlines/src/types/config.d.cts +376 -0
- package/dist/powerlines/src/types/config.d.mts +376 -0
- package/dist/powerlines/src/types/context.d.cts +403 -0
- package/dist/powerlines/src/types/context.d.mts +403 -0
- package/dist/powerlines/src/types/fs.d.cts +486 -0
- package/dist/powerlines/src/types/fs.d.mts +486 -0
- package/dist/powerlines/src/types/plugin.d.cts +231 -0
- package/dist/powerlines/src/types/plugin.d.mts +231 -0
- package/dist/powerlines/src/types/resolved.d.cts +81 -0
- package/dist/powerlines/src/types/resolved.d.mts +81 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.mts +1 -2
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +48 -1
- package/dist/types/plugin.d.mts +48 -1
- package/dist/types/plugin.mjs +0 -2
- package/package.json +5 -5
- package/dist/create-emitter-Bk1iruR0.d.cts +0 -29
- package/dist/create-emitter-Ccqc-tkP.d.mts +0 -29
- package/dist/create-emitter-CdX9SXDY.mjs +0 -32
- package/dist/create-emitter-D5ApNfU0.cjs +0 -38
- package/dist/create-writer-C24rz3d5.d.cts +0 -13
- package/dist/create-writer-CiaQl13h.d.mts +0 -13
- package/dist/create-writer-Du15htg7.mjs +0 -48
- package/dist/create-writer-gvbqS_Gu.cjs +0 -87
- package/dist/helpers-y2jvHwgF.mjs +0 -1
- package/dist/helpers-yB1XkvQI.cjs +0 -0
- package/dist/index-BL32-cvv.d.cts +0 -1
- package/dist/index-BR1oNnaF.d.cts +0 -1
- package/dist/index-Bk0eNZmQ.d.mts +0 -1
- package/dist/index-DNLi60D-.d.mts +0 -1
- package/dist/plugin-B0q2kj8i.mjs +0 -1
- package/dist/plugin-BQjCVJPf.d.cts +0 -1800
- package/dist/plugin-Ckx8qAq8.cjs +0 -0
- package/dist/plugin-VnXa5UaX.d.mts +0 -1800
- package/dist/types--fVOUYBq.mjs +0 -1
- package/dist/types-a8gm_IaQ.cjs +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
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,3 +1,33 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let node_events = require("node:events");
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
//#region src/helpers/create-emitter.ts
|
|
5
|
+
/**
|
|
6
|
+
* Create an event emitter with typed events.
|
|
7
|
+
*
|
|
8
|
+
* @returns An event emitter instance with typed event handling.
|
|
9
|
+
*/
|
|
10
|
+
function createEmitter() {
|
|
11
|
+
const emitter = new node_events.EventEmitter();
|
|
12
|
+
function on(key, listener) {
|
|
13
|
+
emitter.on(key, listener);
|
|
14
|
+
}
|
|
15
|
+
function emit(key, event) {
|
|
16
|
+
emitter.emit(key, event);
|
|
17
|
+
if (typeof event === "object" && event !== null && "error" in event) emitter.emit("_error", {
|
|
18
|
+
...event,
|
|
19
|
+
_event: key
|
|
20
|
+
});
|
|
21
|
+
emitter.emit("_all", {
|
|
22
|
+
...event,
|
|
23
|
+
_event: key
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
on,
|
|
28
|
+
emit
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.createEmitter = createEmitter;
|
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/helpers/create-emitter.d.ts
|
|
2
|
+
type EventMap = Record<string, object>;
|
|
3
|
+
interface EventWithError {
|
|
4
|
+
error: Error;
|
|
5
|
+
}
|
|
6
|
+
interface SystemEvent {
|
|
7
|
+
_event: string;
|
|
8
|
+
}
|
|
9
|
+
type ErrorEvent = EventWithError & SystemEvent;
|
|
10
|
+
interface SystemEvents extends EventMap {
|
|
11
|
+
_error: ErrorEvent;
|
|
12
|
+
_all: SystemEvent;
|
|
13
|
+
}
|
|
14
|
+
type Keys<TEvents extends EventMap> = keyof TEvents & string;
|
|
15
|
+
type Listener<TEvent> = (event: TEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Create an event emitter with typed events.
|
|
18
|
+
*
|
|
19
|
+
* @returns An event emitter instance with typed event handling.
|
|
20
|
+
*/
|
|
21
|
+
declare function createEmitter<TEvents extends EventMap>(): {
|
|
22
|
+
on: {
|
|
23
|
+
<TKey extends Keys<TEvents>>(key: TKey, listener: Listener<TEvents[TKey]>): void;
|
|
24
|
+
<TKey extends Keys<SystemEvents>>(key: TKey, listener: Listener<SystemEvents[TKey]>): void;
|
|
25
|
+
};
|
|
26
|
+
emit: <TKey extends Keys<TEvents>>(key: TKey, event: TEvents[TKey]) => void;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
2
29
|
export { createEmitter };
|
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/helpers/create-emitter.d.ts
|
|
2
|
+
type EventMap = Record<string, object>;
|
|
3
|
+
interface EventWithError {
|
|
4
|
+
error: Error;
|
|
5
|
+
}
|
|
6
|
+
interface SystemEvent {
|
|
7
|
+
_event: string;
|
|
8
|
+
}
|
|
9
|
+
type ErrorEvent = EventWithError & SystemEvent;
|
|
10
|
+
interface SystemEvents extends EventMap {
|
|
11
|
+
_error: ErrorEvent;
|
|
12
|
+
_all: SystemEvent;
|
|
13
|
+
}
|
|
14
|
+
type Keys<TEvents extends EventMap> = keyof TEvents & string;
|
|
15
|
+
type Listener<TEvent> = (event: TEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Create an event emitter with typed events.
|
|
18
|
+
*
|
|
19
|
+
* @returns An event emitter instance with typed event handling.
|
|
20
|
+
*/
|
|
21
|
+
declare function createEmitter<TEvents extends EventMap>(): {
|
|
22
|
+
on: {
|
|
23
|
+
<TKey extends Keys<TEvents>>(key: TKey, listener: Listener<TEvents[TKey]>): void;
|
|
24
|
+
<TKey extends Keys<SystemEvents>>(key: TKey, listener: Listener<SystemEvents[TKey]>): void;
|
|
25
|
+
};
|
|
26
|
+
emit: <TKey extends Keys<TEvents>>(key: TKey, event: TEvents[TKey]) => void;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
2
29
|
export { createEmitter };
|
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
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
|
|
3
32
|
export { createEmitter };
|
|
@@ -1,3 +1,41 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_file_header = require('../powerlines/src/lib/utilities/file-header.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_rolldown_runtime.__toESM(pluralize);
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
//#region src/helpers/create-writer.ts
|
|
10
|
+
const createConstName = (name) => {
|
|
11
|
+
return (0, pluralize.default)(name.charAt(0).toUpperCase() + name.slice(1));
|
|
12
|
+
};
|
|
13
|
+
const createArrayConstName = (name) => {
|
|
14
|
+
return `all${createConstName(name)}`;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param context - The Powerlines build plugin
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
const createWriter = (context) => {
|
|
22
|
+
return {
|
|
23
|
+
createJavaScriptFile: async (configuration) => {
|
|
24
|
+
return context.emitBuiltin(`${require_file_header.getBaseFileHeader(context)}
|
|
25
|
+
${configuration.collections.map(({ name }) => `import ${createArrayConstName(name)} from "./${(0, __stryke_string_format_kebab_case.kebabCase)(name)}";`).join("\n")}
|
|
26
|
+
|
|
27
|
+
export { ${configuration.collections.map(({ name }) => createArrayConstName(name)).join(", ")} };
|
|
28
|
+
`, "content");
|
|
29
|
+
},
|
|
30
|
+
createTypeDefinitionFile: async (_) => Promise.resolve(),
|
|
31
|
+
createDataFiles: async (collections) => {
|
|
32
|
+
await Promise.all(collections.map(async (collection) => {
|
|
33
|
+
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)));
|
|
34
|
+
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)));
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.createWriter = createWriter;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import "../plugin
|
|
2
|
-
import {
|
|
1
|
+
import { ContentCollectionsPluginContext } from "../types/plugin.cjs";
|
|
2
|
+
import { Writer } from "@content-collections/core";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/create-writer.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param context - The Powerlines build plugin
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
declare const createWriter: (context: ContentCollectionsPluginContext) => Writer;
|
|
12
|
+
//#endregion
|
|
3
13
|
export { createWriter };
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import "../plugin
|
|
2
|
-
import {
|
|
1
|
+
import { ContentCollectionsPluginContext } from "../types/plugin.mjs";
|
|
2
|
+
import { Writer } from "@content-collections/core";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/create-writer.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param context - The Powerlines build plugin
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
declare const createWriter: (context: ContentCollectionsPluginContext) => Writer;
|
|
12
|
+
//#endregion
|
|
3
13
|
export { createWriter };
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getBaseFileHeader } from "../powerlines/src/lib/utilities/file-header.mjs";
|
|
2
|
+
import { serialize } from "@content-collections/core";
|
|
3
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
4
|
+
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
5
|
+
import pluralize from "pluralize";
|
|
2
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
|
+
*
|
|
16
|
+
* @param context - The Powerlines build plugin
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
const createWriter = (context) => {
|
|
20
|
+
return {
|
|
21
|
+
createJavaScriptFile: async (configuration) => {
|
|
22
|
+
return context.emitBuiltin(`${getBaseFileHeader(context)}
|
|
23
|
+
${configuration.collections.map(({ name }) => `import ${createArrayConstName(name)} from "./${kebabCase(name)}";`).join("\n")}
|
|
24
|
+
|
|
25
|
+
export { ${configuration.collections.map(({ name }) => createArrayConstName(name)).join(", ")} };
|
|
26
|
+
`, "content");
|
|
27
|
+
},
|
|
28
|
+
createTypeDefinitionFile: async (_) => Promise.resolve(),
|
|
29
|
+
createDataFiles: async (collections) => {
|
|
30
|
+
await Promise.all(collections.map(async (collection) => {
|
|
31
|
+
if (context.config.contentCollections.outputPath) return context.fs.write(joinPaths(context.config.contentCollections.outputPath, kebabCase(collection.name)), serialize(collection.documents.map((doc) => doc.document)));
|
|
32
|
+
return context.emitBuiltin(serialize(collection.documents.map((doc) => doc.document)), joinPaths("content", kebabCase(collection.name)));
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
3
39
|
export { createWriter };
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
require('../helpers-yB1XkvQI.cjs');
|
|
1
|
+
const require_helpers_create_emitter = require('./create-emitter.cjs');
|
|
2
|
+
const require_helpers_create_writer = require('./create-writer.cjs');
|
|
4
3
|
|
|
5
|
-
exports.createEmitter =
|
|
6
|
-
exports.createWriter =
|
|
4
|
+
exports.createEmitter = require_helpers_create_emitter.createEmitter;
|
|
5
|
+
exports.createWriter = require_helpers_create_writer.createWriter;
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import { t as createWriter } from "../create-writer-C24rz3d5.cjs";
|
|
4
|
-
import "../index-BR1oNnaF.cjs";
|
|
1
|
+
import { createEmitter } from "./create-emitter.cjs";
|
|
2
|
+
import { createWriter } from "./create-writer.cjs";
|
|
5
3
|
export { createEmitter, createWriter };
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import { t as createWriter } from "../create-writer-CiaQl13h.mjs";
|
|
4
|
-
import "../index-DNLi60D-.mjs";
|
|
1
|
+
import { createEmitter } from "./create-emitter.mjs";
|
|
2
|
+
import { createWriter } from "./create-writer.mjs";
|
|
5
3
|
export { createEmitter, createWriter };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "../helpers-y2jvHwgF.mjs";
|
|
1
|
+
import { createEmitter } from "./create-emitter.mjs";
|
|
2
|
+
import { createWriter } from "./create-writer.mjs";
|
|
4
3
|
|
|
5
4
|
export { createEmitter, createWriter };
|
package/dist/index.cjs
CHANGED
|
@@ -1,49 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
require('./helpers-
|
|
5
|
-
require('./
|
|
6
|
-
require('./
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_paths = require('./powerlines/src/plugin-utils/paths.cjs');
|
|
4
|
+
const require_helpers_create_emitter = require('./helpers/create-emitter.cjs');
|
|
5
|
+
const require_helpers_create_writer = require('./helpers/create-writer.cjs');
|
|
6
|
+
require('./helpers/index.cjs');
|
|
7
7
|
let __content_collections_core = require("@content-collections/core");
|
|
8
8
|
let __stryke_fs_exists = require("@stryke/fs/exists");
|
|
9
9
|
let __stryke_path_join = require("@stryke/path/join");
|
|
10
10
|
let defu = require("defu");
|
|
11
|
-
defu =
|
|
11
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
12
12
|
let node_crypto = require("node:crypto");
|
|
13
|
-
let __stryke_path_replace = require("@stryke/path/replace");
|
|
14
13
|
|
|
15
|
-
//#region ../powerlines/src/plugin-utils/paths.ts
|
|
16
|
-
/**
|
|
17
|
-
* Replaces tokens in the given path string with their corresponding values from the context.
|
|
18
|
-
*
|
|
19
|
-
* @remarks
|
|
20
|
-
* The following tokens are supported:
|
|
21
|
-
* - `{workspaceRoot}` - The root directory of the workspace.
|
|
22
|
-
* - `{root}` - The root directory of the project (same as `{projectRoot}`).
|
|
23
|
-
* - `{projectRoot}` - The root directory of the project (same as `{root}`).
|
|
24
|
-
* - `{sourceRoot}` - The source root directory of the project (usually `./src`).
|
|
25
|
-
* - `{powerlinesPath}` - The directory where Powerlines is installed.
|
|
26
|
-
* - `{cachePath}` - The environment's directory for cached files.
|
|
27
|
-
* - `{dataPath}` - The environment's directory for data files.
|
|
28
|
-
* - `{logPath}` - The environment's directory for log files.
|
|
29
|
-
* - `{tempPath}` - The environment's directory for temporary files.
|
|
30
|
-
* - `{configPath}` - The environment's directory for configuration files.
|
|
31
|
-
* - `{outputPath}` - The configured output directory for the project.
|
|
32
|
-
* - `{buildPath}` - The configured distribution directory for the project.
|
|
33
|
-
* - `{artifactsPath}` - The configured directory for build artifacts.
|
|
34
|
-
* - `{builtinPath}` - The configured directory for generated built-in plugins.
|
|
35
|
-
* - `{entryPath}` - The configured directory for generated entry files.
|
|
36
|
-
*
|
|
37
|
-
* @param context - The context containing the values for the path tokens.
|
|
38
|
-
* @param path - The path string with tokens to replace.
|
|
39
|
-
* @returns The path string with tokens replaced by their corresponding values from the context.
|
|
40
|
-
*/
|
|
41
|
-
function replacePathTokens(context, path) {
|
|
42
|
-
if (!path) return path;
|
|
43
|
-
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", (0, __stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, __stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, __stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
14
|
//#region src/index.ts
|
|
48
15
|
/**
|
|
49
16
|
* A Powerlines plugin to integrate Content Collections for code generation.
|
|
@@ -61,9 +28,9 @@ const plugin = (options) => {
|
|
|
61
28
|
}) };
|
|
62
29
|
},
|
|
63
30
|
async configResolved() {
|
|
64
|
-
this.config.contentCollections.configFile ||= replacePathTokens(this, this.config.contentCollections.configFile);
|
|
65
|
-
this.config.contentCollections.outputPath ||= replacePathTokens(this, this.config.contentCollections.outputPath);
|
|
66
|
-
const emitter =
|
|
31
|
+
this.config.contentCollections.configFile ||= require_paths.replacePathTokens(this, this.config.contentCollections.configFile);
|
|
32
|
+
this.config.contentCollections.outputPath ||= require_paths.replacePathTokens(this, this.config.contentCollections.outputPath);
|
|
33
|
+
const emitter = require_helpers_create_emitter.createEmitter();
|
|
67
34
|
const readConfiguration = (0, __content_collections_core.createConfigurationReader)();
|
|
68
35
|
let configuration = {};
|
|
69
36
|
try {
|
|
@@ -80,7 +47,7 @@ const plugin = (options) => {
|
|
|
80
47
|
outputDirectory: this.config.contentCollections.outputPath || (0, __stryke_path_join.joinPaths)(this.builtinsPath, "content"),
|
|
81
48
|
configuration
|
|
82
49
|
});
|
|
83
|
-
context.writer =
|
|
50
|
+
context.writer = require_helpers_create_writer.createWriter(this);
|
|
84
51
|
this.contentCollections = {
|
|
85
52
|
context,
|
|
86
53
|
build: async () => (0, __content_collections_core.build)(context),
|
|
@@ -95,7 +62,7 @@ const plugin = (options) => {
|
|
|
95
62
|
var src_default = plugin;
|
|
96
63
|
|
|
97
64
|
//#endregion
|
|
98
|
-
exports.createEmitter =
|
|
99
|
-
exports.createWriter =
|
|
65
|
+
exports.createEmitter = require_helpers_create_emitter.createEmitter;
|
|
66
|
+
exports.createWriter = require_helpers_create_writer.createWriter;
|
|
100
67
|
exports.default = src_default;
|
|
101
68
|
exports.plugin = plugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
5
|
-
import "./index-BL32-cvv.cjs";
|
|
1
|
+
import { createEmitter } from "./helpers/create-emitter.cjs";
|
|
2
|
+
import { Plugin } from "./powerlines/src/types/plugin.cjs";
|
|
3
|
+
import { ContentCollectionsContext, ContentCollectionsPluginContext, ContentCollectionsPluginOptions, ContentCollectionsPluginResolvedConfig, ContentCollectionsPluginUserConfig, __ΩContentCollectionsContext, __ΩContentCollectionsPluginContext, __ΩContentCollectionsPluginOptions, __ΩContentCollectionsPluginResolvedConfig, __ΩContentCollectionsPluginUserConfig } from "./types/plugin.cjs";
|
|
4
|
+
import { createWriter } from "./helpers/create-writer.cjs";
|
|
6
5
|
|
|
7
6
|
//#region src/index.d.ts
|
|
8
7
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
5
|
-
import "./index
|
|
1
|
+
import { createEmitter } from "./helpers/create-emitter.mjs";
|
|
2
|
+
import { Plugin } from "./powerlines/src/types/plugin.mjs";
|
|
3
|
+
import { ContentCollectionsContext, ContentCollectionsPluginContext, ContentCollectionsPluginOptions, ContentCollectionsPluginResolvedConfig, ContentCollectionsPluginUserConfig, __ΩContentCollectionsContext, __ΩContentCollectionsPluginContext, __ΩContentCollectionsPluginOptions, __ΩContentCollectionsPluginResolvedConfig, __ΩContentCollectionsPluginUserConfig } from "./types/plugin.mjs";
|
|
4
|
+
import { createWriter } from "./helpers/create-writer.mjs";
|
|
5
|
+
import "./helpers/index.mjs";
|
|
6
|
+
import "./types/index.mjs";
|
|
6
7
|
|
|
7
8
|
//#region src/index.d.ts
|
|
8
9
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,47 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "./helpers-
|
|
4
|
-
import "./
|
|
5
|
-
import "./types--fVOUYBq.mjs";
|
|
1
|
+
import { replacePathTokens } from "./powerlines/src/plugin-utils/paths.mjs";
|
|
2
|
+
import { createEmitter } from "./helpers/create-emitter.mjs";
|
|
3
|
+
import { createWriter } from "./helpers/create-writer.mjs";
|
|
4
|
+
import "./helpers/index.mjs";
|
|
6
5
|
import { build, createBuildContext, createConfigurationReader } from "@content-collections/core";
|
|
7
6
|
import { existsSync } from "@stryke/fs/exists";
|
|
8
7
|
import { joinPaths } from "@stryke/path/join";
|
|
9
8
|
import defu from "defu";
|
|
10
9
|
import { createHash } from "node:crypto";
|
|
11
|
-
import { replacePath } from "@stryke/path/replace";
|
|
12
10
|
|
|
13
|
-
//#region ../powerlines/src/plugin-utils/paths.ts
|
|
14
|
-
/**
|
|
15
|
-
* Replaces tokens in the given path string with their corresponding values from the context.
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* The following tokens are supported:
|
|
19
|
-
* - `{workspaceRoot}` - The root directory of the workspace.
|
|
20
|
-
* - `{root}` - The root directory of the project (same as `{projectRoot}`).
|
|
21
|
-
* - `{projectRoot}` - The root directory of the project (same as `{root}`).
|
|
22
|
-
* - `{sourceRoot}` - The source root directory of the project (usually `./src`).
|
|
23
|
-
* - `{powerlinesPath}` - The directory where Powerlines is installed.
|
|
24
|
-
* - `{cachePath}` - The environment's directory for cached files.
|
|
25
|
-
* - `{dataPath}` - The environment's directory for data files.
|
|
26
|
-
* - `{logPath}` - The environment's directory for log files.
|
|
27
|
-
* - `{tempPath}` - The environment's directory for temporary files.
|
|
28
|
-
* - `{configPath}` - The environment's directory for configuration files.
|
|
29
|
-
* - `{outputPath}` - The configured output directory for the project.
|
|
30
|
-
* - `{buildPath}` - The configured distribution directory for the project.
|
|
31
|
-
* - `{artifactsPath}` - The configured directory for build artifacts.
|
|
32
|
-
* - `{builtinPath}` - The configured directory for generated built-in plugins.
|
|
33
|
-
* - `{entryPath}` - The configured directory for generated entry files.
|
|
34
|
-
*
|
|
35
|
-
* @param context - The context containing the values for the path tokens.
|
|
36
|
-
* @param path - The path string with tokens to replace.
|
|
37
|
-
* @returns The path string with tokens replaced by their corresponding values from the context.
|
|
38
|
-
*/
|
|
39
|
-
function replacePathTokens(context, path) {
|
|
40
|
-
if (!path) return path;
|
|
41
|
-
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
11
|
//#region src/index.ts
|
|
46
12
|
/**
|
|
47
13
|
* A Powerlines plugin to integrate Content Collections for code generation.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
3
|
+
|
|
4
|
+
//#region ../powerlines/src/lib/utilities/file-header.ts
|
|
5
|
+
function getBaseFileHeader(context) {
|
|
6
|
+
return `
|
|
7
|
+
// Generated with ${(0, __stryke_string_format_title_case.titleCase)(context.config.framework)}
|
|
8
|
+
// Note: Do not edit this file manually - it will be overwritten automatically
|
|
9
|
+
`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.getBaseFileHeader = getBaseFileHeader;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
2
|
+
|
|
3
|
+
//#region ../powerlines/src/lib/utilities/file-header.ts
|
|
4
|
+
function getBaseFileHeader(context) {
|
|
5
|
+
return `
|
|
6
|
+
// Generated with ${titleCase(context.config.framework)}
|
|
7
|
+
// Note: Do not edit this file manually - it will be overwritten automatically
|
|
8
|
+
`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getBaseFileHeader };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_path_replace = require("@stryke/path/replace");
|
|
3
|
+
|
|
4
|
+
//#region ../powerlines/src/plugin-utils/paths.ts
|
|
5
|
+
/**
|
|
6
|
+
* Replaces tokens in the given path string with their corresponding values from the context.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* The following tokens are supported:
|
|
10
|
+
* - `{workspaceRoot}` - The root directory of the workspace.
|
|
11
|
+
* - `{root}` - The root directory of the project (same as `{projectRoot}`).
|
|
12
|
+
* - `{projectRoot}` - The root directory of the project (same as `{root}`).
|
|
13
|
+
* - `{sourceRoot}` - The source root directory of the project (usually `./src`).
|
|
14
|
+
* - `{powerlinesPath}` - The directory where Powerlines is installed.
|
|
15
|
+
* - `{cachePath}` - The environment's directory for cached files.
|
|
16
|
+
* - `{dataPath}` - The environment's directory for data files.
|
|
17
|
+
* - `{logPath}` - The environment's directory for log files.
|
|
18
|
+
* - `{tempPath}` - The environment's directory for temporary files.
|
|
19
|
+
* - `{configPath}` - The environment's directory for configuration files.
|
|
20
|
+
* - `{outputPath}` - The configured output directory for the project.
|
|
21
|
+
* - `{buildPath}` - The configured distribution directory for the project.
|
|
22
|
+
* - `{artifactsPath}` - The configured directory for build artifacts.
|
|
23
|
+
* - `{builtinPath}` - The configured directory for generated built-in plugins.
|
|
24
|
+
* - `{entryPath}` - The configured directory for generated entry files.
|
|
25
|
+
*
|
|
26
|
+
* @param context - The context containing the values for the path tokens.
|
|
27
|
+
* @param path - The path string with tokens to replace.
|
|
28
|
+
* @returns The path string with tokens replaced by their corresponding values from the context.
|
|
29
|
+
*/
|
|
30
|
+
function replacePathTokens(context, path) {
|
|
31
|
+
if (!path) return path;
|
|
32
|
+
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", (0, __stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, __stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, __stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.replacePathTokens = replacePathTokens;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { replacePath } from "@stryke/path/replace";
|
|
2
|
+
|
|
3
|
+
//#region ../powerlines/src/plugin-utils/paths.ts
|
|
4
|
+
/**
|
|
5
|
+
* Replaces tokens in the given path string with their corresponding values from the context.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The following tokens are supported:
|
|
9
|
+
* - `{workspaceRoot}` - The root directory of the workspace.
|
|
10
|
+
* - `{root}` - The root directory of the project (same as `{projectRoot}`).
|
|
11
|
+
* - `{projectRoot}` - The root directory of the project (same as `{root}`).
|
|
12
|
+
* - `{sourceRoot}` - The source root directory of the project (usually `./src`).
|
|
13
|
+
* - `{powerlinesPath}` - The directory where Powerlines is installed.
|
|
14
|
+
* - `{cachePath}` - The environment's directory for cached files.
|
|
15
|
+
* - `{dataPath}` - The environment's directory for data files.
|
|
16
|
+
* - `{logPath}` - The environment's directory for log files.
|
|
17
|
+
* - `{tempPath}` - The environment's directory for temporary files.
|
|
18
|
+
* - `{configPath}` - The environment's directory for configuration files.
|
|
19
|
+
* - `{outputPath}` - The configured output directory for the project.
|
|
20
|
+
* - `{buildPath}` - The configured distribution directory for the project.
|
|
21
|
+
* - `{artifactsPath}` - The configured directory for build artifacts.
|
|
22
|
+
* - `{builtinPath}` - The configured directory for generated built-in plugins.
|
|
23
|
+
* - `{entryPath}` - The configured directory for generated entry files.
|
|
24
|
+
*
|
|
25
|
+
* @param context - The context containing the values for the path tokens.
|
|
26
|
+
* @param path - The path string with tokens to replace.
|
|
27
|
+
* @returns The path string with tokens replaced by their corresponding values from the context.
|
|
28
|
+
*/
|
|
29
|
+
function replacePathTokens(context, path) {
|
|
30
|
+
if (!path) return path;
|
|
31
|
+
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { replacePathTokens };
|