@powerlines/plugin-content-collections 0.1.116 → 0.1.118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,29 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
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 +1,33 @@
1
- const e=require(`../_virtual/rolldown_runtime.cjs`);let t=require(`node:events`);function n(){let e=new t.EventEmitter;function n(t,n){e.on(t,n)}function r(t,n){e.emit(t,n),typeof n==`object`&&n&&`error`in n&&e.emit(`_error`,{...n,_event:t}),e.emit(`_all`,{...n,_event:t})}return{on:n,emit:r}}exports.createEmitter=n;
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let node_events = require("node:events");
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 +1,32 @@
1
- import{EventEmitter as e}from"node:events";function t(){let t=new e;function n(e,n){t.on(e,n)}function r(e,n){t.emit(e,n),typeof n==`object`&&n&&`error`in n&&t.emit(`_error`,{...n,_event:e}),t.emit(`_all`,{...n,_event:e})}return{on:n,emit:r}}export{t as createEmitter};
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 };
@@ -1,6 +1,41 @@
1
- const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../powerlines/src/lib/utilities/file-header.cjs`);let n=require(`@content-collections/core`),r=require(`@stryke/path/join-paths`),i=require(`@stryke/string-format/kebab-case`),a=require(`pluralize`);a=e.__toESM(a);const o=e=>(0,a.default)(e.charAt(0).toUpperCase()+e.slice(1)),s=e=>`all${o(e)}`,c=e=>({createJavaScriptFile:async n=>e.emitBuiltin(`${t.getBaseFileHeader(e)}
2
- ${n.collections.map(({name:e})=>`import ${s(e)} from "./${(0,i.kebabCase)(e)}";`).join(`
3
- `)}
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);
4
8
 
5
- export { ${n.collections.map(({name:e})=>s(e)).join(`, `)} };
6
- `,`content`),createTypeDefinitionFile:async e=>Promise.resolve(),createDataFiles:async t=>{await Promise.all(t.map(async t=>e.config.contentCollections.outputPath?e.fs.write((0,r.joinPaths)(e.config.contentCollections.outputPath,(0,i.kebabCase)(t.name)),(0,n.serialize)(t.documents.map(e=>e.document))):e.emitBuiltin((0,n.serialize)(t.documents.map(e=>e.document)),(0,r.joinPaths)(`content`,(0,i.kebabCase)(t.name)))))}});exports.createWriter=c;
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,6 +1,39 @@
1
- import{getBaseFileHeader as e}from"../powerlines/src/lib/utilities/file-header.mjs";import{serialize as t}from"@content-collections/core";import{joinPaths as n}from"@stryke/path/join-paths";import{kebabCase as r}from"@stryke/string-format/kebab-case";import i from"pluralize";const a=e=>i(e.charAt(0).toUpperCase()+e.slice(1)),o=e=>`all${a(e)}`,s=i=>({createJavaScriptFile:async t=>i.emitBuiltin(`${e(i)}
2
- ${t.collections.map(({name:e})=>`import ${o(e)} from "./${r(e)}";`).join(`
3
- `)}
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";
4
6
 
5
- export { ${t.collections.map(({name:e})=>o(e)).join(`, `)} };
6
- `,`content`),createTypeDefinitionFile:async e=>Promise.resolve(),createDataFiles:async e=>{await Promise.all(e.map(async e=>i.config.contentCollections.outputPath?i.fs.write(n(i.config.contentCollections.outputPath,r(e.name)),t(e.documents.map(e=>e.document))):i.emitBuiltin(t(e.documents.map(e=>e.document)),n(`content`,r(e.name)))))}});export{s as createWriter};
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
39
+ export { createWriter };
@@ -1 +1,5 @@
1
- const e=require(`./create-emitter.cjs`),t=require(`./create-writer.cjs`);exports.createEmitter=e.createEmitter,exports.createWriter=t.createWriter;
1
+ const require_helpers_create_emitter = require('./create-emitter.cjs');
2
+ const require_helpers_create_writer = require('./create-writer.cjs');
3
+
4
+ exports.createEmitter = require_helpers_create_emitter.createEmitter;
5
+ exports.createWriter = require_helpers_create_writer.createWriter;
@@ -1 +1,4 @@
1
- import{createEmitter as e}from"./create-emitter.mjs";import{createWriter as t}from"./create-writer.mjs";export{e as createEmitter,t as createWriter};
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,68 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./powerlines/src/plugin-utils/paths.cjs`),n=require(`./helpers/create-emitter.cjs`),r=require(`./helpers/create-writer.cjs`);require(`./helpers/index.cjs`);let i=require(`@content-collections/core`),a=require(`@stryke/fs/exists`),o=require(`@stryke/path/join`),s=require(`defu`);s=e.__toESM(s);let c=require(`node:crypto`);const l=e=>({name:`content-collections`,config(){return{contentCollections:(0,s.default)(e,{configFile:`{projectRoot}/content-collections.ts`,collections:[]})}},async configResolved(){this.config.contentCollections.configFile||=t.replacePathTokens(this,this.config.contentCollections.configFile),this.config.contentCollections.outputPath||=t.replacePathTokens(this,this.config.contentCollections.outputPath);let e=n.createEmitter(),l=(0,i.createConfigurationReader)(),u={};try{(0,a.existsSync)(this.config.contentCollections.configFile)&&(u=await l(this.config.contentCollections.configFile,{configName:`config.mjs`,cacheDir:(0,o.joinPaths)(this.cachePath,`content-collections`)}))}catch{}u=(0,s.default)(u??{},this.config.contentCollections),u.checksum=(0,c.createHash)(`sha256`).update(JSON.stringify(u)).digest(`hex`);let d=await(0,i.createBuildContext)({emitter:e,baseDirectory:(0,o.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),outputDirectory:this.config.contentCollections.outputPath||(0,o.joinPaths)(this.builtinsPath,`content`),configuration:u});d.writer=r.createWriter(this),this.contentCollections={context:d,build:async()=>(0,i.build)(d),on:e.on}},async prepare(){return this.contentCollections.build()}});var u=l;exports.createEmitter=n.createEmitter,exports.createWriter=r.createWriter,exports.default=u,exports.plugin=l;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
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
+ let __content_collections_core = require("@content-collections/core");
8
+ let __stryke_fs_exists = require("@stryke/fs/exists");
9
+ let __stryke_path_join = require("@stryke/path/join");
10
+ let defu = require("defu");
11
+ defu = require_rolldown_runtime.__toESM(defu);
12
+ let node_crypto = require("node:crypto");
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: "{projectRoot}/content-collections.ts",
27
+ collections: []
28
+ }) };
29
+ },
30
+ async configResolved() {
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();
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.workspaceConfig.workspaceRoot, this.config.projectRoot),
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
+ var src_default = plugin;
63
+
64
+ //#endregion
65
+ exports.createEmitter = require_helpers_create_emitter.createEmitter;
66
+ exports.createWriter = require_helpers_create_writer.createWriter;
67
+ exports.default = src_default;
68
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1 +1,62 @@
1
- import{replacePathTokens as e}from"./powerlines/src/plugin-utils/paths.mjs";import{createEmitter as t}from"./helpers/create-emitter.mjs";import{createWriter as n}from"./helpers/create-writer.mjs";import"./helpers/index.mjs";import{build as r,createBuildContext as i,createConfigurationReader as a}from"@content-collections/core";import{existsSync as o}from"@stryke/fs/exists";import{joinPaths as s}from"@stryke/path/join";import c from"defu";import{createHash as l}from"node:crypto";const u=u=>({name:`content-collections`,config(){return{contentCollections:c(u,{configFile:`{projectRoot}/content-collections.ts`,collections:[]})}},async configResolved(){this.config.contentCollections.configFile||=e(this,this.config.contentCollections.configFile),this.config.contentCollections.outputPath||=e(this,this.config.contentCollections.outputPath);let u=t(),d=a(),f={};try{o(this.config.contentCollections.configFile)&&(f=await d(this.config.contentCollections.configFile,{configName:`config.mjs`,cacheDir:s(this.cachePath,`content-collections`)}))}catch{}f=c(f??{},this.config.contentCollections),f.checksum=l(`sha256`).update(JSON.stringify(f)).digest(`hex`);let p=await i({emitter:u,baseDirectory:s(this.workspaceConfig.workspaceRoot,this.config.projectRoot),outputDirectory:this.config.contentCollections.outputPath||s(this.builtinsPath,`content`),configuration:f});p.writer=n(this),this.contentCollections={context:p,build:async()=>r(p),on:u.on}},async prepare(){return this.contentCollections.build()}});var d=u;export{t as createEmitter,n as createWriter,d as default,u as plugin};
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";
5
+ import { build, createBuildContext, createConfigurationReader } from "@content-collections/core";
6
+ import { existsSync } from "@stryke/fs/exists";
7
+ import { joinPaths } from "@stryke/path/join";
8
+ import defu from "defu";
9
+ import { createHash } from "node:crypto";
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: "{projectRoot}/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.workspaceConfig.workspaceRoot, this.config.projectRoot),
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
+ var src_default = plugin;
60
+
61
+ //#endregion
62
+ export { createEmitter, createWriter, src_default as default, plugin };
@@ -1,4 +1,13 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/string-format/title-case`);function n(e){return`
2
- // Generated with ${(0,t.titleCase)(e.config.framework)}
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)}
3
8
  // Note: Do not edit this file manually - it will be overwritten automatically
4
- `}exports.getBaseFileHeader=n;
9
+ `;
10
+ }
11
+
12
+ //#endregion
13
+ exports.getBaseFileHeader = getBaseFileHeader;
@@ -1,4 +1,12 @@
1
- import{titleCase as e}from"@stryke/string-format/title-case";function t(t){return`
2
- // Generated with ${e(t.config.framework)}
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)}
3
7
  // Note: Do not edit this file manually - it will be overwritten automatically
4
- `}export{t as getBaseFileHeader};
8
+ `;
9
+ }
10
+
11
+ //#endregion
12
+ export { getBaseFileHeader };
@@ -1 +1,36 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/replace`);function n(e,n){return n&&n.replaceAll(`{workspaceRoot}`,e.workspaceConfig.workspaceRoot).replaceAll(`{root}`,e.config.projectRoot).replaceAll(`{projectRoot}`,e.config.projectRoot).replaceAll(`{sourceRoot}`,e.config.sourceRoot).replaceAll(`{powerlinesPath}`,e.powerlinesPath).replaceAll(`{cachePath}`,e.cachePath).replaceAll(`{dataPath}`,e.dataPath).replaceAll(`{logPath}`,e.envPaths.log).replaceAll(`{tempPath}`,e.envPaths.temp).replaceAll(`{configPath}`,e.envPaths.config).replaceAll(`{outputPath}`,e.config.output.outputPath).replaceAll(`{buildPath}`,e.config.output.buildPath).replaceAll(`{artifactsPath}`,(0,t.replacePath)(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,(0,t.replacePath)(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,(0,t.replacePath)(e.entryPath,e.workspaceConfig.workspaceRoot))}exports.replacePathTokens=n;
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;
@@ -1 +1,35 @@
1
- import{replacePath as e}from"@stryke/path/replace";function t(t,n){return n&&n.replaceAll(`{workspaceRoot}`,t.workspaceConfig.workspaceRoot).replaceAll(`{root}`,t.config.projectRoot).replaceAll(`{projectRoot}`,t.config.projectRoot).replaceAll(`{sourceRoot}`,t.config.sourceRoot).replaceAll(`{powerlinesPath}`,t.powerlinesPath).replaceAll(`{cachePath}`,t.cachePath).replaceAll(`{dataPath}`,t.dataPath).replaceAll(`{logPath}`,t.envPaths.log).replaceAll(`{tempPath}`,t.envPaths.temp).replaceAll(`{configPath}`,t.envPaths.config).replaceAll(`{outputPath}`,t.config.output.outputPath).replaceAll(`{buildPath}`,t.config.output.buildPath).replaceAll(`{artifactsPath}`,e(t.artifactsPath,t.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,e(t.builtinsPath,t.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,e(t.entryPath,t.workspaceConfig.workspaceRoot))}export{t as replacePathTokens};
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 };
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
78
78
  */
79
79
  allowReturnOutsideFunction?: boolean;
80
80
  }
81
+ interface EmitOptions extends WriteOptions {
82
+ /**
83
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
84
+ */
85
+ emitWithBundler?: boolean;
86
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
87
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
88
+ }
81
89
  /**
82
90
  * Options for emitting entry virtual files
83
91
  */
84
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
92
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
85
93
  /**
86
94
  * The unresolved Powerlines context.
87
95
  *
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
292
300
  * The Powerlines builtin virtual files
293
301
  */
294
302
  getBuiltins: () => Promise<VirtualFile[]>;
303
+ /**
304
+ * Resolves a file and writes it to the VFS if it does not already exist
305
+ *
306
+ * @param code - The source code of the file
307
+ * @param path - The path to write the file to
308
+ * @param options - Additional options for writing the file
309
+ */
310
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
311
+ /**
312
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
313
+ *
314
+ * @param code - The source code of the file
315
+ * @param path - The path to write the file to
316
+ * @param options - Additional options for writing the file
317
+ */
318
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
295
319
  /**
296
320
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
297
321
  *
@@ -300,7 +324,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
300
324
  * @param path - An optional path to write the builtin file to
301
325
  * @param options - Additional options for writing the builtin file
302
326
  */
303
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
327
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
328
+ /**
329
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
330
+ *
331
+ * @param code - The source code of the builtin file
332
+ * @param id - The unique identifier of the builtin file
333
+ * @param path - An optional path to write the builtin file to
334
+ * @param options - Additional options for writing the builtin file
335
+ */
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
304
337
  /**
305
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
306
339
  *
@@ -309,6 +342,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
342
  * @param options - Additional options for writing the entry file
310
343
  */
311
344
  emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
345
+ /**
346
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
347
+ *
348
+ * @param code - The source code of the entry file
349
+ * @param path - An optional path to write the entry file to
350
+ * @param options - Additional options for writing the entry file
351
+ */
352
+ emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
312
353
  /**
313
354
  * A function to update the context fields using a new user configuration options
314
355
  */
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
78
78
  */
79
79
  allowReturnOutsideFunction?: boolean;
80
80
  }
81
+ interface EmitOptions extends WriteOptions {
82
+ /**
83
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
84
+ */
85
+ emitWithBundler?: boolean;
86
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
87
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
88
+ }
81
89
  /**
82
90
  * Options for emitting entry virtual files
83
91
  */
84
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
92
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
85
93
  /**
86
94
  * The unresolved Powerlines context.
87
95
  *
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
292
300
  * The Powerlines builtin virtual files
293
301
  */
294
302
  getBuiltins: () => Promise<VirtualFile[]>;
303
+ /**
304
+ * Resolves a file and writes it to the VFS if it does not already exist
305
+ *
306
+ * @param code - The source code of the file
307
+ * @param path - The path to write the file to
308
+ * @param options - Additional options for writing the file
309
+ */
310
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
311
+ /**
312
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
313
+ *
314
+ * @param code - The source code of the file
315
+ * @param path - The path to write the file to
316
+ * @param options - Additional options for writing the file
317
+ */
318
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
295
319
  /**
296
320
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
297
321
  *
@@ -300,7 +324,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
300
324
  * @param path - An optional path to write the builtin file to
301
325
  * @param options - Additional options for writing the builtin file
302
326
  */
303
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
327
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
328
+ /**
329
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
330
+ *
331
+ * @param code - The source code of the builtin file
332
+ * @param id - The unique identifier of the builtin file
333
+ * @param path - An optional path to write the builtin file to
334
+ * @param options - Additional options for writing the builtin file
335
+ */
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
304
337
  /**
305
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
306
339
  *
@@ -309,6 +342,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
342
  * @param options - Additional options for writing the entry file
310
343
  */
311
344
  emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
345
+ /**
346
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
347
+ *
348
+ * @param code - The source code of the entry file
349
+ * @param path - An optional path to write the entry file to
350
+ * @param options - Additional options for writing the entry file
351
+ */
352
+ emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
312
353
  /**
313
354
  * A function to update the context fields using a new user configuration options
314
355
  */
@@ -13,6 +13,13 @@ interface StorageAdapter {
13
13
  * A name identifying the storage adapter type.
14
14
  */
15
15
  name: string;
16
+ /**
17
+ * The storage preset for the adapter.
18
+ *
19
+ * @remarks
20
+ * This can be used as an alternate way to identify the type of storage being used.
21
+ */
22
+ preset?: StoragePreset | null;
16
23
  /**
17
24
  * Checks if a key exists in the storage.
18
25
  *
@@ -207,6 +214,13 @@ interface WriteOptions {
207
214
  * @defaultValue false
208
215
  */
209
216
  skipFormat?: boolean;
217
+ /**
218
+ * The storage preset or adapter name for the output file.
219
+ *
220
+ * @remarks
221
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
222
+ */
223
+ storage?: StoragePreset | string;
210
224
  /**
211
225
  * Additional metadata for the file.
212
226
  */
@@ -13,6 +13,13 @@ interface StorageAdapter {
13
13
  * A name identifying the storage adapter type.
14
14
  */
15
15
  name: string;
16
+ /**
17
+ * The storage preset for the adapter.
18
+ *
19
+ * @remarks
20
+ * This can be used as an alternate way to identify the type of storage being used.
21
+ */
22
+ preset?: StoragePreset | null;
16
23
  /**
17
24
  * Checks if a key exists in the storage.
18
25
  *
@@ -207,6 +214,13 @@ interface WriteOptions {
207
214
  * @defaultValue false
208
215
  */
209
216
  skipFormat?: boolean;
217
+ /**
218
+ * The storage preset or adapter name for the output file.
219
+ *
220
+ * @remarks
221
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
222
+ */
223
+ storage?: StoragePreset | string;
210
224
  /**
211
225
  * Additional metadata for the file.
212
226
  */
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -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.116",
3
+ "version": "0.1.118",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to generate project code using Content Collections.",
6
6
  "repository": {
@@ -123,22 +123,22 @@
123
123
  ],
124
124
  "dependencies": {
125
125
  "@content-collections/core": "^0.12.0",
126
- "@stryke/fs": "^0.33.26",
127
- "@stryke/string-format": "^0.12.29",
128
- "@stryke/path": "^0.24.0",
129
- "@stryke/type-checks": "^0.5.14",
130
- "@stryke/types": "^0.10.28",
126
+ "@stryke/fs": "^0.33.27",
127
+ "@stryke/string-format": "^0.12.30",
128
+ "@stryke/path": "^0.24.1",
129
+ "@stryke/type-checks": "^0.5.15",
130
+ "@stryke/types": "^0.10.29",
131
131
  "defu": "^6.1.4",
132
132
  "pluralize": "^8.0.0",
133
- "powerlines": "^0.36.21"
133
+ "powerlines": "^0.36.23"
134
134
  },
135
135
  "devDependencies": {
136
- "@powerlines/nx": "^0.11.47",
137
- "@powerlines/plugin-plugin": "^0.12.68",
136
+ "@powerlines/nx": "^0.11.49",
137
+ "@powerlines/plugin-plugin": "^0.12.70",
138
138
  "@standard-schema/spec": "^1.1.0",
139
139
  "@types/node": "^24.10.4",
140
140
  "@types/pluralize": "^0.0.33"
141
141
  },
142
142
  "publishConfig": { "access": "public" },
143
- "gitHead": "b16324cf857ea5743fd7ad06e18607b1ba32abe0"
143
+ "gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
144
144
  }