@powerlines/plugin-content-collections 0.1.46 → 0.1.48

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.
Files changed (71) hide show
  1. package/dist/create-emitter-Bk1iruR0.d.cts +30 -0
  2. package/dist/create-emitter-Bk1iruR0.d.cts.map +1 -0
  3. package/dist/create-emitter-Ccqc-tkP.d.mts +30 -0
  4. package/dist/create-emitter-Ccqc-tkP.d.mts.map +1 -0
  5. package/dist/create-emitter-D2D-OWFH.mjs +2 -0
  6. package/dist/create-emitter-D2D-OWFH.mjs.map +1 -0
  7. package/dist/create-emitter-D5prAv7U.cjs +1 -0
  8. package/dist/create-writer-BUb6uBji.mjs +10 -0
  9. package/dist/create-writer-BUb6uBji.mjs.map +1 -0
  10. package/dist/create-writer-CtxSp06X.d.cts +14 -0
  11. package/dist/create-writer-CtxSp06X.d.cts.map +1 -0
  12. package/dist/create-writer-VShJ9LFt.d.mts +14 -0
  13. package/dist/create-writer-VShJ9LFt.d.mts.map +1 -0
  14. package/dist/create-writer-v6g9eZ0E.cjs +9 -0
  15. package/dist/helpers/create-emitter.cjs +1 -7
  16. package/dist/helpers/create-emitter.d.cts +2 -28
  17. package/dist/helpers/create-emitter.d.mts +2 -0
  18. package/dist/helpers/create-emitter.mjs +1 -0
  19. package/dist/helpers/create-writer.cjs +1 -12
  20. package/dist/helpers/create-writer.d.cts +3 -29
  21. package/dist/helpers/create-writer.d.mts +3 -0
  22. package/dist/helpers/create-writer.mjs +1 -0
  23. package/dist/helpers/index.cjs +1 -1
  24. package/dist/helpers/index.d.cts +5 -22
  25. package/dist/helpers/index.d.mts +5 -0
  26. package/dist/helpers/index.mjs +1 -0
  27. package/dist/helpers-DLqVzgm5.mjs +1 -0
  28. package/dist/index-BL32-cvv.d.cts +1 -0
  29. package/dist/index-BR1oNnaF.d.cts +1 -0
  30. package/dist/index-Bk0eNZmQ.d.mts +1 -0
  31. package/dist/index-DNLi60D-.d.mts +1 -0
  32. package/dist/index.cjs +1 -7
  33. package/dist/index.d.cts +10 -25
  34. package/dist/index.d.cts.map +1 -0
  35. package/dist/index.d.mts +18 -0
  36. package/dist/index.d.mts.map +1 -0
  37. package/dist/index.mjs +2 -0
  38. package/dist/index.mjs.map +1 -0
  39. package/dist/plugin-CPmAQVMr.d.mts +1684 -0
  40. package/dist/plugin-CPmAQVMr.d.mts.map +1 -0
  41. package/dist/plugin-Ckx8qAq8.cjs +0 -0
  42. package/dist/plugin-G4qbpIjB.mjs +1 -0
  43. package/dist/plugin-dE07E9ou.d.cts +1684 -0
  44. package/dist/plugin-dE07E9ou.d.cts.map +1 -0
  45. package/dist/types/index.cjs +1 -1
  46. package/dist/types/index.d.cts +3 -20
  47. package/dist/types/index.d.mts +3 -0
  48. package/dist/types/index.mjs +1 -0
  49. package/dist/types/plugin.cjs +1 -1
  50. package/dist/types/plugin.d.cts +2 -20
  51. package/dist/types/plugin.d.mts +2 -0
  52. package/dist/types/plugin.mjs +1 -0
  53. package/dist/types-CSNCwSXh.mjs +1 -0
  54. package/dist/types-a8gm_IaQ.cjs +0 -0
  55. package/package.json +44 -26
  56. package/dist/chunk-FBBMZ4NC.cjs +0 -7
  57. package/dist/chunk-UCUR73HG.js +0 -7
  58. package/dist/helpers/create-emitter.d.ts +0 -28
  59. package/dist/helpers/create-emitter.js +0 -7
  60. package/dist/helpers/create-writer.d.ts +0 -29
  61. package/dist/helpers/create-writer.js +0 -12
  62. package/dist/helpers/index.d.ts +0 -22
  63. package/dist/helpers/index.js +0 -1
  64. package/dist/index-b8FiWaqe.d.cts +0 -1525
  65. package/dist/index-b8FiWaqe.d.ts +0 -1525
  66. package/dist/index.d.ts +0 -33
  67. package/dist/index.js +0 -7
  68. package/dist/types/index.d.ts +0 -20
  69. package/dist/types/index.js +0 -1
  70. package/dist/types/plugin.d.ts +0 -20
  71. /package/dist/{types/plugin.js → helpers-yB1XkvQI.cjs} +0 -0
@@ -0,0 +1,30 @@
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
29
+ export { createEmitter as t };
30
+ //# sourceMappingURL=create-emitter-Bk1iruR0.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-emitter-Bk1iruR0.d.cts","names":[],"sources":["../src/helpers/create-emitter.ts"],"sourcesContent":[],"mappings":";KAoBK,QAAA,GAAW;UAEN,cAAA,CAFG;EAEH,KAAA,EACD,KADC;AACI;AAGO,UAAX,WAAA,CAIK;EAEL,MAAA,EAAA,MAAA;;KAFL,UAAA,GAAa,cAIV,GAJ2B,WAI3B;UAFE,YAAA,SAAqB,QAAA,CAAA;EAAQ,MAAA,EAC7B,UAD6B;EAKlC,IAAA,EAHG,WAGC;AAA0C;AAQnD,KARK,IAQW,CAAA,gBARU,QAQG,CAAA,GAAA,MARe,OAQf,GAAA,MAAA;KAPxB,QAOyC,CAAA,MAAA,CAAA,GAAA,CAAA,KAAA,EAPd,MAOc,EAAA,GAAA,IAAA;;;;;;AAKhC,iBALE,aAKF,CAAA,gBALgC,QAKhC,CAAA,CAAA,CAAA,EAAA;EAGkB,EAAA,EAAA;IAAL,CAAA,aALA,IAKA,CALK,OAKL,CAAA,CAAA,CAAA,GAAA,EAJlB,IAIkB,EAAA,QAAA,EAHb,QAGa,CAHJ,OAGI,CAHI,IAGJ,CAAA,CAAA,CAAA,EAAA,IAAA;IAClB,CAAA,aADkB,IAClB,CADuB,YACvB,CAAA,CAAA,CAAA,GAAA,EAAA,IAAA,EAAA,QAAA,EACK,QADL,CACc,YADd,CAC2B,IAD3B,CAAA,CAAA,CAAA,EAAA,IAAA;EACc,CAAA;EAAa,IAAA,EAAA,CAAA,aAOP,IAPO,CAOF,OAPE,CAAA,CAAA,CAAA,GAAA,EAOa,IAPb,EAAA,KAAA,EAO0B,OAP1B,CAOkC,IAPlC,CAAA,EAAA,GAAA,IAAA;CAAtB"}
@@ -0,0 +1,30 @@
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
29
+ export { createEmitter as t };
30
+ //# sourceMappingURL=create-emitter-Ccqc-tkP.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-emitter-Ccqc-tkP.d.mts","names":[],"sources":["../src/helpers/create-emitter.ts"],"sourcesContent":[],"mappings":";KAoBK,QAAA,GAAW;UAEN,cAAA,CAFG;EAEH,KAAA,EACD,KADC;AACI;AAGO,UAAX,WAAA,CAIK;EAEL,MAAA,EAAA,MAAA;;KAFL,UAAA,GAAa,cAIV,GAJ2B,WAI3B;UAFE,YAAA,SAAqB,QAAA,CAAA;EAAQ,MAAA,EAC7B,UAD6B;EAKlC,IAAA,EAHG,WAGC;AAA0C;AAQnD,KARK,IAQW,CAAA,gBARU,QAQG,CAAA,GAAA,MARe,OAQf,GAAA,MAAA;KAPxB,QAOyC,CAAA,MAAA,CAAA,GAAA,CAAA,KAAA,EAPd,MAOc,EAAA,GAAA,IAAA;;;;;;AAKhC,iBALE,aAKF,CAAA,gBALgC,QAKhC,CAAA,CAAA,CAAA,EAAA;EAGkB,EAAA,EAAA;IAAL,CAAA,aALA,IAKA,CALK,OAKL,CAAA,CAAA,CAAA,GAAA,EAJlB,IAIkB,EAAA,QAAA,EAHb,QAGa,CAHJ,OAGI,CAHI,IAGJ,CAAA,CAAA,CAAA,EAAA,IAAA;IAClB,CAAA,aADkB,IAClB,CADuB,YACvB,CAAA,CAAA,CAAA,GAAA,EAAA,IAAA,EAAA,QAAA,EACK,QADL,CACc,YADd,CAC2B,IAD3B,CAAA,CAAA,CAAA,EAAA,IAAA;EACc,CAAA;EAAa,IAAA,EAAA,CAAA,aAOP,IAPO,CAOF,OAPE,CAAA,CAAA,CAAA,GAAA,EAOa,IAPb,EAAA,KAAA,EAO0B,OAP1B,CAOkC,IAPlC,CAAA,EAAA,GAAA,IAAA;CAAtB"}
@@ -0,0 +1,2 @@
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};
2
+ //# sourceMappingURL=create-emitter-D2D-OWFH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-emitter-D2D-OWFH.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":"2CA6CA,SAAgB,GAA0C,CACxD,IAAM,EAAU,IAAI,EAYpB,SAAS,EAAG,EAAa,EAAyB,CAChD,EAAQ,GAAG,EAAK,EAAS,CAG3B,SAAS,EAAiC,EAAW,EAAsB,CACzE,EAAQ,KAAK,EAAK,EAAM,CAEpB,OAAO,GAAU,UAAY,GAAkB,UAAW,GAC5D,EAAQ,KAAK,SAAU,CACrB,GAAG,EACH,OAAQ,EACT,CAAC,CAGJ,EAAQ,KAAK,OAAQ,CACnB,GAAG,EACH,OAAQ,EACT,CAAC,CAGJ,MAAO,CACL,KACA,OACD"}
@@ -0,0 +1 @@
1
+ const e=require(`./create-writer-v6g9eZ0E.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}}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
@@ -0,0 +1,10 @@
1
+ import{serialize as e}from"@content-collections/core";import{joinPaths as t}from"@stryke/path/join-paths";import{kebabCase as n}from"@stryke/string-format/kebab-case";import r from"pluralize";import{titleCase as i}from"@stryke/string-format/title-case";function a(e){return`
2
+ // Generated with ${i(e.config.framework)}
3
+ // Note: Do not edit this file manually - it will be overwritten automatically
4
+ `}const o=e=>r(e.charAt(0).toUpperCase()+e.slice(1)),s=e=>`all${o(e)}`,c=r=>({createJavaScriptFile:async e=>r.emitBuiltin(`${a(r)}
5
+ ${e.collections.map(({name:e})=>`import ${s(e)} from "./${n(e)}";`).join(`
6
+ `)}
7
+
8
+ export { ${e.collections.map(({name:e})=>s(e)).join(`, `)} };
9
+ `,`content`),createTypeDefinitionFile:async e=>Promise.resolve(),createDataFiles:async i=>{await Promise.all(i.map(async i=>r.config.contentCollections.outputPath?r.fs.write(t(r.config.contentCollections.outputPath,n(i.name)),e(i.documents.map(e=>e.document))):r.emitBuiltin(e(i.documents.map(e=>e.document)),t(`content`,n(i.name)))))}});export{c as t};
10
+ //# sourceMappingURL=create-writer-BUb6uBji.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-writer-BUb6uBji.mjs","names":[],"sources":["../../powerlines/src/lib/utilities/file-header.ts","../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 { titleCase } from \"@stryke/string-format/title-case\";\nimport { Context } from \"../../types/context\";\n\nexport interface FileHeaderOptions {\n directive?: string | null;\n prettierIgnore?: boolean;\n}\n\nexport function getBaseFileHeader(context: Context): string {\n return `\n// Generated with ${titleCase(context.config.framework)}\n// Note: Do not edit this file manually - it will be overwritten automatically\n`;\n}\n\nexport function getFileHeader(\n context: Context,\n options: FileHeaderOptions = {}\n): string {\n const { directive = null, prettierIgnore = false } = options;\n\n return `/* eslint-disable */\n// biome-ignore lint: disable\n${prettierIgnore ? `// prettier-ignore` : \"\"}${directive ? `\\n\\n${directive}\\n` : \"\\n\"}\n${getBaseFileHeader(context)}\n\n`;\n}\n","/* -------------------------------------------------------------------\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 { getBaseFileHeader } from \"powerlines/lib/utilities/file-header\";\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 *\n * @param context - The Powerlines build plugin\n * @returns\n */\nexport const createWriter = (\n context: ContentCollectionsPluginContext\n): Writer => {\n return {\n createJavaScriptFile: async (\n configuration: JavaScriptFileConfiguration\n ) => {\n return context.emitBuiltin(\n `${getBaseFileHeader(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":"6PA0BA,SAAgB,EAAkB,EAA0B,CAC1D,MAAO;oBACW,EAAU,EAAQ,OAAO,UAAU,CAAC;;ECGxD,MAAM,EAAmB,GAChB,EAAU,EAAK,OAAO,EAAE,CAAC,aAAa,CAAG,EAAK,MAAM,EAAE,CAAC,CAG1D,EAAwB,GACrB,MAAM,EAAgB,EAAK,GAQvB,EACX,IAEO,CACL,qBAAsB,KACpB,IAEO,EAAQ,YACb,GAAG,EAAkB,EAAQ,CAAC;EACpC,EAAc,YACb,KACE,CAAE,UACD,UAAU,EAAqB,EAAK,CAAC,WAAW,EAAU,EAAK,CAAC,IACnE,CACA,KAAK;EAAK,CAAC;;WAEH,EAAc,YACd,KAAK,CAAE,UAAW,EAAqB,EAAK,CAAC,CAC7C,KAAK,KAAK,CAAC;EAEd,UACD,CAEH,yBAA0B,KAAO,IAC/B,QAAQ,SAAS,CACnB,gBAAiB,KAAO,IAA2C,CACjE,MAAM,QAAQ,IACZ,EAAY,IAAI,KAAM,IAChB,EAAQ,OAAO,mBAAmB,WAC7B,EAAQ,GAAG,MAChB,EACE,EAAQ,OAAO,mBAAmB,WAClC,EAAU,EAAW,KAAK,CAC3B,CACD,EAAU,EAAW,UAAU,IAAI,GAAO,EAAI,SAAS,CAAC,CACzD,CAGI,EAAQ,YACb,EAAU,EAAW,UAAU,IAAI,GAAO,EAAI,SAAS,CAAC,CACxD,EAAU,UAAW,EAAU,EAAW,KAAK,CAAC,CACjD,CACD,CACH,EAEJ"}
@@ -0,0 +1,14 @@
1
+ import { n as ContentCollectionsPluginContext } from "./plugin-dE07E9ou.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
13
+ export { createWriter as t };
14
+ //# sourceMappingURL=create-writer-CtxSp06X.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-writer-CtxSp06X.d.cts","names":[],"sources":["../src/helpers/create-writer.ts"],"sourcesContent":[],"mappings":";;;;;;;AA4CA;;;cAAa,wBACF,oCACR"}
@@ -0,0 +1,14 @@
1
+ import { n as ContentCollectionsPluginContext } from "./plugin-CPmAQVMr.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
13
+ export { createWriter as t };
14
+ //# sourceMappingURL=create-writer-VShJ9LFt.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-writer-VShJ9LFt.d.mts","names":[],"sources":["../src/helpers/create-writer.ts"],"sourcesContent":[],"mappings":";;;;;;;AA4CA;;;cAAa,wBACF,oCACR"}
@@ -0,0 +1,9 @@
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));let c=require(`@content-collections/core`),l=require(`@stryke/path/join-paths`),u=require(`@stryke/string-format/kebab-case`),d=require(`pluralize`);d=s(d);let f=require(`@stryke/string-format/title-case`);function p(e){return`
2
+ // Generated with ${(0,f.titleCase)(e.config.framework)}
3
+ // Note: Do not edit this file manually - it will be overwritten automatically
4
+ `}const m=e=>(0,d.default)(e.charAt(0).toUpperCase()+e.slice(1)),h=e=>`all${m(e)}`,g=e=>({createJavaScriptFile:async t=>e.emitBuiltin(`${p(e)}
5
+ ${t.collections.map(({name:e})=>`import ${h(e)} from "./${(0,u.kebabCase)(e)}";`).join(`
6
+ `)}
7
+
8
+ export { ${t.collections.map(({name:e})=>h(e)).join(`, `)} };
9
+ `,`content`),createTypeDefinitionFile:async e=>Promise.resolve(),createDataFiles:async t=>{await Promise.all(t.map(async t=>e.config.contentCollections.outputPath?e.fs.write((0,l.joinPaths)(e.config.contentCollections.outputPath,(0,u.kebabCase)(t.name)),(0,c.serialize)(t.documents.map(e=>e.document))):e.emitBuiltin((0,c.serialize)(t.documents.map(e=>e.document)),(0,l.joinPaths)(`content`,(0,u.kebabCase)(t.name)))))}});Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return g}});
@@ -1,7 +1 @@
1
- 'use strict';var chunkFBBMZ4NC_cjs=require('../chunk-FBBMZ4NC.cjs'),node_events=require('node:events');/*****************************************
2
- *
3
- * ⚡ Built by Storm Software
4
- *
5
- *****************************************/
6
-
7
- function y(){const n=new node_events.EventEmitter;function s(t,e){n.on(t,e);}chunkFBBMZ4NC_cjs.a(s,"on");function i(t,e){n.emit(t,e),typeof e=="object"&&e!==null&&"error"in e&&n.emit("_error",{...e,_event:t}),n.emit("_all",{...e,_event:t});}return chunkFBBMZ4NC_cjs.a(i,"emit"),{on:s,emit:i}}chunkFBBMZ4NC_cjs.a(y,"createEmitter");exports.createEmitter=y;
1
+ const e=require(`../create-emitter-D5prAv7U.cjs`);exports.createEmitter=e.t;
@@ -1,28 +1,2 @@
1
- type EventMap = Record<string, object>;
2
- interface EventWithError {
3
- error: Error;
4
- }
5
- interface SystemEvent {
6
- _event: string;
7
- }
8
- type ErrorEvent = EventWithError & SystemEvent;
9
- interface SystemEvents extends EventMap {
10
- _error: ErrorEvent;
11
- _all: SystemEvent;
12
- }
13
- type Keys<TEvents extends EventMap> = keyof TEvents & string;
14
- type Listener<TEvent> = (event: TEvent) => void;
15
- /**
16
- * Create an event emitter with typed events.
17
- *
18
- * @returns An event emitter instance with typed event handling.
19
- */
20
- declare function createEmitter<TEvents extends EventMap>(): {
21
- on: {
22
- <TKey extends Keys<TEvents>>(key: TKey, listener: Listener<TEvents[TKey]>): void;
23
- <TKey extends Keys<SystemEvents>>(key: TKey, listener: Listener<SystemEvents[TKey]>): void;
24
- };
25
- emit: <TKey extends Keys<TEvents>>(key: TKey, event: TEvents[TKey]) => void;
26
- };
27
-
28
- export { createEmitter };
1
+ import { t as createEmitter } from "../create-emitter-Bk1iruR0.cjs";
2
+ export { createEmitter };
@@ -0,0 +1,2 @@
1
+ import { t as createEmitter } from "../create-emitter-Ccqc-tkP.mjs";
2
+ export { createEmitter };
@@ -0,0 +1 @@
1
+ import{t as e}from"../create-emitter-D2D-OWFH.mjs";export{e as createEmitter};
@@ -1,12 +1 @@
1
- 'use strict';var chunkFBBMZ4NC_cjs=require('../chunk-FBBMZ4NC.cjs'),core=require('@content-collections/core'),joinPaths=require('@stryke/path/join-paths'),kebabCase=require('@stryke/string-format/kebab-case'),m=require('pluralize'),fileHeader=require('powerlines/lib/utilities/file-header');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var m__default=/*#__PURE__*/_interopDefault(m);/*****************************************
2
- *
3
- * ⚡ Built by Storm Software
4
- *
5
- *****************************************/
6
-
7
- const p=chunkFBBMZ4NC_cjs.a(t=>m__default.default(t.charAt(0).toUpperCase()+t.slice(1)),"createConstName"),s=chunkFBBMZ4NC_cjs.a(t=>`all${p(t)}`,"createArrayConstName"),j=chunkFBBMZ4NC_cjs.a(t=>({createJavaScriptFile:chunkFBBMZ4NC_cjs.a(async r=>t.emitBuiltin(`${fileHeader.getBaseFileHeader(t)}
8
- ${r.collections.map(({name:e})=>`import ${s(e)} from "./${kebabCase.kebabCase(e)}";`).join(`
9
- `)}
10
-
11
- export { ${r.collections.map(({name:e})=>s(e)).join(", ")} };
12
- `,"content"),"createJavaScriptFile"),createTypeDefinitionFile:chunkFBBMZ4NC_cjs.a(async r=>Promise.resolve(),"createTypeDefinitionFile"),createDataFiles:chunkFBBMZ4NC_cjs.a(async r=>{await Promise.all(r.map(async e=>t.config.contentCollections.outputPath?t.fs.write(joinPaths.joinPaths(t.config.contentCollections.outputPath,kebabCase.kebabCase(e.name)),core.serialize(e.documents.map(o=>o.document))):t.emitBuiltin(core.serialize(e.documents.map(o=>o.document)),joinPaths.joinPaths("content",kebabCase.kebabCase(e.name)))));},"createDataFiles")}),"createWriter");exports.createWriter=j;
1
+ const e=require(`../create-writer-v6g9eZ0E.cjs`);exports.createWriter=e.t;
@@ -1,29 +1,3 @@
1
- import { Writer } from '@content-collections/core';
2
- import { C as ContentCollectionsPluginContext } from '../index-b8FiWaqe.cjs';
3
- import '@storm-software/build-tools/types';
4
- import '@storm-software/config-tools/types';
5
- import '@storm-software/config/types';
6
- import '@stryke/types/base';
7
- import '@stryke/types/configuration';
8
- import '@stryke/types/file';
9
- import 'vite';
10
- import '@stryke/env/get-env-paths';
11
- import '@stryke/types/package-json';
12
- import 'jiti';
13
- import 'magic-string';
14
- import 'semver';
15
- import 'ts-morph';
16
- import 'unplugin';
17
- import '@stryke/fs/resolve';
18
- import '@stryke/types/tsconfig';
19
- import 'typescript';
20
- import '@stryke/types/array';
21
-
22
- /**
23
- *
24
- * @param context - The Powerlines build plugin
25
- * @returns
26
- */
27
- declare const createWriter: (context: ContentCollectionsPluginContext) => Writer;
28
-
29
- export { createWriter };
1
+ import "../plugin-dE07E9ou.cjs";
2
+ import { t as createWriter } from "../create-writer-CtxSp06X.cjs";
3
+ export { createWriter };
@@ -0,0 +1,3 @@
1
+ import "../plugin-CPmAQVMr.mjs";
2
+ import { t as createWriter } from "../create-writer-VShJ9LFt.mjs";
3
+ export { createWriter };
@@ -0,0 +1 @@
1
+ import{t as e}from"../create-writer-BUb6uBji.mjs";export{e as createWriter};
@@ -1 +1 @@
1
- 'use strict';var createEmitter=require('./create-emitter'),createWriter=require('./create-writer');Object.keys(createEmitter).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return createEmitter[k]}})});Object.keys(createWriter).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return createWriter[k]}})});
1
+ const e=require(`../create-writer-v6g9eZ0E.cjs`),t=require(`../create-emitter-D5prAv7U.cjs`);require(`../helpers-yB1XkvQI.cjs`),exports.createEmitter=t.t,exports.createWriter=e.t;
@@ -1,22 +1,5 @@
1
- export { createEmitter } from './create-emitter.cjs';
2
- export { createWriter } from './create-writer.cjs';
3
- import '@content-collections/core';
4
- import '../index-b8FiWaqe.cjs';
5
- import '@storm-software/build-tools/types';
6
- import '@storm-software/config-tools/types';
7
- import '@storm-software/config/types';
8
- import '@stryke/types/base';
9
- import '@stryke/types/configuration';
10
- import '@stryke/types/file';
11
- import 'vite';
12
- import '@stryke/env/get-env-paths';
13
- import '@stryke/types/package-json';
14
- import 'jiti';
15
- import 'magic-string';
16
- import 'semver';
17
- import 'ts-morph';
18
- import 'unplugin';
19
- import '@stryke/fs/resolve';
20
- import '@stryke/types/tsconfig';
21
- import 'typescript';
22
- import '@stryke/types/array';
1
+ import { t as createEmitter } from "../create-emitter-Bk1iruR0.cjs";
2
+ import "../plugin-dE07E9ou.cjs";
3
+ import { t as createWriter } from "../create-writer-CtxSp06X.cjs";
4
+ import "../index-BR1oNnaF.cjs";
5
+ export { createEmitter, createWriter };
@@ -0,0 +1,5 @@
1
+ import { t as createEmitter } from "../create-emitter-Ccqc-tkP.mjs";
2
+ import "../plugin-CPmAQVMr.mjs";
3
+ import { t as createWriter } from "../create-writer-VShJ9LFt.mjs";
4
+ import "../index-DNLi60D-.mjs";
5
+ export { createEmitter, createWriter };
@@ -0,0 +1 @@
1
+ import{t as e}from"../create-emitter-D2D-OWFH.mjs";import{t}from"../create-writer-BUb6uBji.mjs";import"../helpers-DLqVzgm5.mjs";export{e as createEmitter,t as createWriter};
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.cjs CHANGED
@@ -1,7 +1 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkFBBMZ4NC_cjs=require('./chunk-FBBMZ4NC.cjs'),core=require('@content-collections/core'),exists=require('@stryke/fs/exists'),join=require('@stryke/path/join'),c=require('defu'),node_crypto=require('node:crypto'),paths=require('powerlines/plugin-utils/paths'),createEmitter=require('./helpers/create-emitter'),createWriter=require('./helpers/create-writer'),helpers=require('./helpers'),types=require('./types');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var c__default=/*#__PURE__*/_interopDefault(c);/*****************************************
2
- *
3
- * ⚡ Built by Storm Software
4
- *
5
- *****************************************/
6
-
7
- const m=chunkFBBMZ4NC_cjs.a(r=>({name:"content-collections",config(){return {contentCollections:c__default.default(r,{configFile:"{projectRoot}/content-collections.ts",collections:[]})}},async configResolved(){this.config.contentCollections.configFile||=paths.replacePathTokens(this,this.config.contentCollections.configFile),this.config.contentCollections.outputPath||=paths.replacePathTokens(this,this.config.contentCollections.outputPath);const e=createEmitter.createEmitter(),s=core.createConfigurationReader();let t={};try{exists.existsSync(this.config.contentCollections.configFile)&&(t=await s(this.config.contentCollections.configFile,{configName:"config.mjs",cacheDir:join.joinPaths(this.cachePath,"content-collections")}));}catch{}t=c__default.default(t??{},this.config.contentCollections),t.checksum=node_crypto.createHash("sha256").update(JSON.stringify(t)).digest("hex");const o=await core.createBuildContext({emitter:e,baseDirectory:join.joinPaths(this.workspaceConfig.workspaceRoot,this.config.projectRoot),outputDirectory:this.config.contentCollections.outputPath||join.joinPaths(this.builtinsPath,"content"),configuration:t});o.writer=createWriter.createWriter(this),this.contentCollections={context:o,build:chunkFBBMZ4NC_cjs.a(async()=>core.build(o),"build"),on:e.on};},async prepare(){return this.contentCollections.build()}}),"plugin");var U=m;exports.default=U;exports.plugin=m;Object.keys(helpers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return helpers[k]}})});Object.keys(types).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return types[k]}})});
1
+ Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./create-writer-v6g9eZ0E.cjs`),t=require(`./create-emitter-D5prAv7U.cjs`);require(`./helpers-yB1XkvQI.cjs`),require(`./plugin-Ckx8qAq8.cjs`),require(`./types-a8gm_IaQ.cjs`);let n=require(`@content-collections/core`),r=require(`@stryke/fs/exists`),i=require(`@stryke/path/join`),a=require(`defu`);a=e.n(a);let o=require(`node:crypto`),s=require(`@stryke/path/replace`);function c(e,t){return t&&t.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,s.replacePath)(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,(0,s.replacePath)(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,(0,s.replacePath)(e.entryPath,e.workspaceConfig.workspaceRoot))}const l=s=>({name:`content-collections`,config(){return{contentCollections:(0,a.default)(s,{configFile:`{projectRoot}/content-collections.ts`,collections:[]})}},async configResolved(){this.config.contentCollections.configFile||=c(this,this.config.contentCollections.configFile),this.config.contentCollections.outputPath||=c(this,this.config.contentCollections.outputPath);let s=t.t(),l=(0,n.createConfigurationReader)(),u={};try{(0,r.existsSync)(this.config.contentCollections.configFile)&&(u=await l(this.config.contentCollections.configFile,{configName:`config.mjs`,cacheDir:(0,i.joinPaths)(this.cachePath,`content-collections`)}))}catch{}u=(0,a.default)(u??{},this.config.contentCollections),u.checksum=(0,o.createHash)(`sha256`).update(JSON.stringify(u)).digest(`hex`);let d=await(0,n.createBuildContext)({emitter:s,baseDirectory:(0,i.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),outputDirectory:this.config.contentCollections.outputPath||(0,i.joinPaths)(this.builtinsPath,`content`),configuration:u});d.writer=e.t(this),this.contentCollections={context:d,build:async()=>(0,n.build)(d),on:s.on}},async prepare(){return this.contentCollections.build()}});var u=l;exports.createEmitter=t.t,exports.createWriter=e.t,exports.default=u,exports.plugin=l;
package/dist/index.d.cts CHANGED
@@ -1,26 +1,10 @@
1
- import { C as ContentCollectionsPluginContext, a as ContentCollectionsPluginOptions, P as Plugin } from './index-b8FiWaqe.cjs';
2
- export { b as ContentCollectionsContext, d as ContentCollectionsPluginResolvedConfig, c as ContentCollectionsPluginUserConfig, _ as __ΩContentCollectionsContext, h as __ΩContentCollectionsPluginContext, e as __ΩContentCollectionsPluginOptions, g as __ΩContentCollectionsPluginResolvedConfig, f as __ΩContentCollectionsPluginUserConfig } from './index-b8FiWaqe.cjs';
3
- export { createEmitter } from './helpers/create-emitter.cjs';
4
- export { createWriter } from './helpers/create-writer.cjs';
5
- import '@content-collections/core';
6
- import '@storm-software/build-tools/types';
7
- import '@storm-software/config-tools/types';
8
- import '@storm-software/config/types';
9
- import '@stryke/types/base';
10
- import '@stryke/types/configuration';
11
- import '@stryke/types/file';
12
- import 'vite';
13
- import '@stryke/env/get-env-paths';
14
- import '@stryke/types/package-json';
15
- import 'jiti';
16
- import 'magic-string';
17
- import 'semver';
18
- import 'ts-morph';
19
- import 'unplugin';
20
- import '@stryke/fs/resolve';
21
- import '@stryke/types/tsconfig';
22
- import 'typescript';
23
- import '@stryke/types/array';
1
+ import { t as createEmitter } from "./create-emitter-Bk1iruR0.cjs";
2
+ import { a as ContentCollectionsPluginUserConfig, c as __ΩContentCollectionsPluginOptions, d as Plugin, i as ContentCollectionsPluginResolvedConfig, l as __ΩContentCollectionsPluginResolvedConfig, n as ContentCollectionsPluginContext, o as __ΩContentCollectionsContext, r as ContentCollectionsPluginOptions, s as __ΩContentCollectionsPluginContext, t as ContentCollectionsContext, u as __ΩContentCollectionsPluginUserConfig } from "./plugin-dE07E9ou.cjs";
3
+ import { t as createWriter } from "./create-writer-CtxSp06X.cjs";
4
+ import "./index-BR1oNnaF.cjs";
5
+ import "./index-BL32-cvv.cjs";
6
+
7
+ //#region src/index.d.ts
24
8
 
25
9
  /**
26
10
  * A Powerlines plugin to integrate Content Collections for code generation.
@@ -29,5 +13,6 @@ import '@stryke/types/array';
29
13
  * @returns A Powerlines plugin instance.
30
14
  */
31
15
  declare const plugin: <TContext extends ContentCollectionsPluginContext = ContentCollectionsPluginContext>(options: ContentCollectionsPluginOptions) => Plugin<TContext>;
32
-
33
- export { ContentCollectionsPluginContext, ContentCollectionsPluginOptions, plugin as default, plugin };
16
+ //#endregion
17
+ export { ContentCollectionsContext, ContentCollectionsPluginContext, ContentCollectionsPluginOptions, ContentCollectionsPluginResolvedConfig, ContentCollectionsPluginUserConfig, __ΩContentCollectionsContext, __ΩContentCollectionsPluginContext, __ΩContentCollectionsPluginOptions, __ΩContentCollectionsPluginResolvedConfig, __ΩContentCollectionsPluginUserConfig, createEmitter, createWriter, plugin as default, plugin };
18
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AA+CA;;;AAIW,cAJE,MAIF,EAAA,CAAA,iBAFP,+BAEO,GAF2B,+BAE3B,CAAA,CAAA,OAAA,EAAA,+BAAA,EAAA,GACR,MADQ,CACD,QADC,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { t as createEmitter } from "./create-emitter-Ccqc-tkP.mjs";
2
+ import { a as ContentCollectionsPluginUserConfig, c as __ΩContentCollectionsPluginOptions, d as Plugin, i as ContentCollectionsPluginResolvedConfig, l as __ΩContentCollectionsPluginResolvedConfig, n as ContentCollectionsPluginContext, o as __ΩContentCollectionsContext, r as ContentCollectionsPluginOptions, s as __ΩContentCollectionsPluginContext, t as ContentCollectionsContext, u as __ΩContentCollectionsPluginUserConfig } from "./plugin-CPmAQVMr.mjs";
3
+ import { t as createWriter } from "./create-writer-VShJ9LFt.mjs";
4
+ import "./index-DNLi60D-.mjs";
5
+ import "./index-Bk0eNZmQ.mjs";
6
+
7
+ //#region src/index.d.ts
8
+
9
+ /**
10
+ * A Powerlines plugin to integrate Content Collections for code generation.
11
+ *
12
+ * @param options - The plugin options.
13
+ * @returns A Powerlines plugin instance.
14
+ */
15
+ declare const plugin: <TContext extends ContentCollectionsPluginContext = ContentCollectionsPluginContext>(options: ContentCollectionsPluginOptions) => Plugin<TContext>;
16
+ //#endregion
17
+ export { ContentCollectionsContext, ContentCollectionsPluginContext, ContentCollectionsPluginOptions, ContentCollectionsPluginResolvedConfig, ContentCollectionsPluginUserConfig, __ΩContentCollectionsContext, __ΩContentCollectionsPluginContext, __ΩContentCollectionsPluginOptions, __ΩContentCollectionsPluginResolvedConfig, __ΩContentCollectionsPluginUserConfig, createEmitter, createWriter, plugin as default, plugin };
18
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AA+CA;;;AAIW,cAJE,MAIF,EAAA,CAAA,iBAFP,+BAEO,GAF2B,+BAE3B,CAAA,CAAA,OAAA,EAAA,+BAAA,EAAA,GACR,MADQ,CACD,QADC,CAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./create-emitter-D2D-OWFH.mjs";import{t}from"./create-writer-BUb6uBji.mjs";import"./helpers-DLqVzgm5.mjs";import"./plugin-G4qbpIjB.mjs";import"./types-CSNCwSXh.mjs";import{build as n,createBuildContext as r,createConfigurationReader as i}from"@content-collections/core";import{existsSync as a}from"@stryke/fs/exists";import{joinPaths as o}from"@stryke/path/join";import s from"defu";import{createHash as c}from"node:crypto";import{replacePath as l}from"@stryke/path/replace";function u(e,t){return t&&t.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}`,l(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,l(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,l(e.entryPath,e.workspaceConfig.workspaceRoot))}const d=l=>({name:`content-collections`,config(){return{contentCollections:s(l,{configFile:`{projectRoot}/content-collections.ts`,collections:[]})}},async configResolved(){this.config.contentCollections.configFile||=u(this,this.config.contentCollections.configFile),this.config.contentCollections.outputPath||=u(this,this.config.contentCollections.outputPath);let l=e(),d=i(),f={};try{a(this.config.contentCollections.configFile)&&(f=await d(this.config.contentCollections.configFile,{configName:`config.mjs`,cacheDir:o(this.cachePath,`content-collections`)}))}catch{}f=s(f??{},this.config.contentCollections),f.checksum=c(`sha256`).update(JSON.stringify(f)).digest(`hex`);let p=await r({emitter:l,baseDirectory:o(this.workspaceConfig.workspaceRoot,this.config.projectRoot),outputDirectory:this.config.contentCollections.outputPath||o(this.builtinsPath,`content`),configuration:f});p.writer=t(this),this.contentCollections={context:p,build:async()=>n(p),on:l.on}},async prepare(){return this.contentCollections.build()}});var f=d;export{e as createEmitter,t as createWriter,f as default,d as plugin};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../powerlines/src/plugin-utils/paths.ts","../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 { replacePath } from \"@stryke/path/replace\";\nimport { IsUndefined } from \"@stryke/types/base\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Replaces tokens in the given path string with their corresponding values from the context.\n *\n * @remarks\n * The following tokens are supported:\n * - `{workspaceRoot}` - The root directory of the workspace.\n * - `{root}` - The root directory of the project (same as `{projectRoot}`).\n * - `{projectRoot}` - The root directory of the project (same as `{root}`).\n * - `{sourceRoot}` - The source root directory of the project (usually `./src`).\n * - `{powerlinesPath}` - The directory where Powerlines is installed.\n * - `{cachePath}` - The environment's directory for cached files.\n * - `{dataPath}` - The environment's directory for data files.\n * - `{logPath}` - The environment's directory for log files.\n * - `{tempPath}` - The environment's directory for temporary files.\n * - `{configPath}` - The environment's directory for configuration files.\n * - `{outputPath}` - The configured output directory for the project.\n * - `{buildPath}` - The configured distribution directory for the project.\n * - `{artifactsPath}` - The configured directory for build artifacts.\n * - `{builtinPath}` - The configured directory for generated built-in plugins.\n * - `{entryPath}` - The configured directory for generated entry files.\n *\n * @param context - The context containing the values for the path tokens.\n * @param path - The path string with tokens to replace.\n * @returns The path string with tokens replaced by their corresponding values from the context.\n */\nexport function replacePathTokens(\n context: UnresolvedContext,\n path?: string\n): IsUndefined<typeof path> extends true ? undefined : string {\n if (!path) {\n return path as IsUndefined<typeof path> extends true ? undefined : string;\n }\n\n return path\n .replaceAll(\"{workspaceRoot}\", context.workspaceConfig.workspaceRoot)\n .replaceAll(\"{root}\", context.config.projectRoot)\n .replaceAll(\"{projectRoot}\", context.config.projectRoot)\n .replaceAll(\"{sourceRoot}\", context.config.sourceRoot)\n .replaceAll(\"{powerlinesPath}\", context.powerlinesPath)\n .replaceAll(\"{cachePath}\", context.cachePath)\n .replaceAll(\"{dataPath}\", context.dataPath)\n .replaceAll(\"{logPath}\", context.envPaths.log)\n .replaceAll(\"{tempPath}\", context.envPaths.temp)\n .replaceAll(\"{configPath}\", context.envPaths.config)\n .replaceAll(\"{outputPath}\", context.config.output.outputPath)\n .replaceAll(\"{buildPath}\", context.config.output.buildPath)\n .replaceAll(\n \"{artifactsPath}\",\n replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{builtinPath}\",\n replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{entryPath}\",\n replacePath(context.entryPath, context.workspaceConfig.workspaceRoot)\n );\n}\n","/* -------------------------------------------------------------------\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 { replacePathTokens } from \"powerlines/plugin-utils/paths\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { createEmitter } from \"./helpers/create-emitter\";\nimport { createWriter } from \"./helpers/create-writer\";\nimport {\n ContentCollectionsPluginContext,\n ContentCollectionsPluginOptions,\n ContentCollectionsPluginUserConfig\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\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\n ContentCollectionsPluginContext = ContentCollectionsPluginContext\n>(\n options: ContentCollectionsPluginOptions\n): Plugin<TContext> => {\n return {\n name: \"content-collections\",\n config() {\n return {\n contentCollections: defu(options, {\n configFile: \"{projectRoot}/content-collections.ts\",\n collections: []\n })\n } as Partial<ContentCollectionsPluginUserConfig>;\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(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot\n ),\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":"8eA+CA,SAAgB,EACd,EACA,EAC4D,CAK5D,OAJK,GAIE,EACJ,WAAW,kBAAmB,EAAQ,gBAAgB,cAAc,CACpE,WAAW,SAAU,EAAQ,OAAO,YAAY,CAChD,WAAW,gBAAiB,EAAQ,OAAO,YAAY,CACvD,WAAW,eAAgB,EAAQ,OAAO,WAAW,CACrD,WAAW,mBAAoB,EAAQ,eAAe,CACtD,WAAW,cAAe,EAAQ,UAAU,CAC5C,WAAW,aAAc,EAAQ,SAAS,CAC1C,WAAW,YAAa,EAAQ,SAAS,IAAI,CAC7C,WAAW,aAAc,EAAQ,SAAS,KAAK,CAC/C,WAAW,eAAgB,EAAQ,SAAS,OAAO,CACnD,WAAW,eAAgB,EAAQ,OAAO,OAAO,WAAW,CAC5D,WAAW,cAAe,EAAQ,OAAO,OAAO,UAAU,CAC1D,WACC,kBACA,EAAY,EAAQ,cAAe,EAAQ,gBAAgB,cAAc,CAC1E,CACA,WACC,gBACA,EAAY,EAAQ,aAAc,EAAQ,gBAAgB,cAAc,CACzE,CACA,WACC,cACA,EAAY,EAAQ,UAAW,EAAQ,gBAAgB,cAAc,CACtE,CChCL,MAAa,EAIX,IAEO,CACL,KAAM,sBACN,QAAS,CACP,MAAO,CACL,mBAAoB,EAAK,EAAS,CAChC,WAAY,uCACZ,YAAa,EAAE,CAChB,CAAC,CACH,EAEH,MAAM,gBAAiB,CACrB,KAAK,OAAO,mBAAmB,aAAe,EAC5C,KACA,KAAK,OAAO,mBAAmB,WAChC,CAED,KAAK,OAAO,mBAAmB,aAAe,EAC5C,KACA,KAAK,OAAO,mBAAmB,WAChC,CAED,IAAM,EAAU,GAAe,CACzB,EAAoB,GAA2B,CAEjD,EAAgB,EAAE,CACtB,GAAI,CACE,EAAW,KAAK,OAAO,mBAAmB,WAAW,GACvD,EAAgB,MAAM,EACpB,KAAK,OAAO,mBAAmB,WAC/B,CACE,WAAY,aACZ,SAAU,EAAU,KAAK,UAAW,sBAAsB,CAC3D,CACF,OAEG,EAIR,EAAgB,EAAK,GAAiB,EAAE,CAAE,KAAK,OAAO,mBAAmB,CACzE,EAAc,SAAW,EAAW,SAAS,CAC1C,OAAO,KAAK,UAAU,EAAc,CAAC,CACrC,OAAO,MAAM,CAEhB,IAAM,EAAU,MAAM,EAAmB,CACvC,UACA,cAAe,EACb,KAAK,gBAAgB,cACrB,KAAK,OAAO,YACb,CACD,gBACE,KAAK,OAAO,mBAAmB,YAC/B,EAAU,KAAK,aAAc,UAAU,CACzC,gBACD,CAAC,CACF,EAAQ,OAAS,EAAa,KAAK,CAEnC,KAAK,mBAAqB,CACxB,UACA,MAAO,SAAY,EAAM,EAAQ,CACjC,GAAI,EAAQ,GACb,EAEH,MAAM,SAAU,CACd,OAAO,KAAK,mBAAmB,OAAO,EAEzC,EAGH,IAAA,EAAe"}