@powerlines/plugin-content-collections 0.1.584 → 0.1.586

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 @@
1
- {"version":3,"file":"create-emitter.d.mts","names":[],"sources":["../../src/helpers/create-emitter.ts"],"mappings":";KAoBK,QAAA,GAAW,MAAM;AAAA,UAEZ,cAAA;EACR,KAAA,EAAO,KAAK;AAAA;AAAA,UAGJ,WAAA;EACR,MAAM;AAAA;AAAA,KAGH,UAAA,GAAa,cAAA,GAAiB,WAAW;AAAA,UAEpC,YAAA,SAAqB,QAAA;EAC7B,MAAA,EAAQ,UAAA;EACR,IAAA,EAAM,WAAA;AAAA;AAAA,KAGH,IAAA,iBAAqB,QAAA,UAAkB,OAAO;AAAA,KAC9C,QAAA,YAAoB,KAAA,EAAO,MAAM;;AAX9B;AAAA;;;iBAkBQ,aAAA,iBAA8B,QAAA;;kBAGnB,IAAA,CAAK,OAAA,GAAQ,GAAA,EAC/B,IAAA,EAAI,QAAA,EACC,QAAA,CAAS,OAAA,CAAQ,IAAA;IAAA,cAGJ,IAAA,CAAK,YAAA,GAAa,GAAA,EACpC,IAAA,EAAI,QAAA,EACC,QAAA,CAAS,YAAA,CAAa,IAAA;EAAA;sBAOP,IAAA,CAAK,OAAA,GAAQ,GAAA,EAAO,IAAA,EAAI,KAAA,EAAS,OAAA,CAAQ,IAAA;AAAA"}
1
+ {"version":3,"file":"create-emitter.d.mts","names":[],"sources":["../../src/helpers/create-emitter.ts"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"create-emitter.mjs","names":[],"sources":["../../src/helpers/create-emitter.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { EventEmitter } from \"node:events\";\n\ntype EventMap = Record<string, object>;\n\ninterface EventWithError {\n error: Error;\n}\n\ninterface SystemEvent {\n _event: string;\n}\n\ntype ErrorEvent = EventWithError & SystemEvent;\n\ninterface SystemEvents extends EventMap {\n _error: ErrorEvent;\n _all: SystemEvent;\n}\n\ntype Keys<TEvents extends EventMap> = keyof TEvents & string;\ntype Listener<TEvent> = (event: TEvent) => void;\n\n/**\n * Create an event emitter with typed events.\n *\n * @returns An event emitter instance with typed event handling.\n */\nexport function createEmitter<TEvents extends EventMap>() {\n const emitter = new EventEmitter();\n\n function on<TKey extends Keys<TEvents>>(\n key: TKey,\n listener: Listener<TEvents[TKey]>\n ): void;\n\n function on<TKey extends Keys<SystemEvents>>(\n key: TKey,\n listener: Listener<SystemEvents[TKey]>\n ): void;\n\n function on(key: string, listener: Listener<any>) {\n emitter.on(key, listener);\n }\n\n function emit<TKey extends Keys<TEvents>>(key: TKey, event: TEvents[TKey]) {\n emitter.emit(key, event);\n\n if (typeof event === \"object\" && event !== null && \"error\" in event) {\n emitter.emit(\"_error\", {\n ...event,\n _event: key\n });\n }\n\n emitter.emit(\"_all\", {\n ...event,\n _event: key\n });\n }\n\n return {\n on,\n emit\n };\n}\n"],"mappings":";;;;;;;;AA6CA,SAAgB,gBAA0C;CACxD,MAAM,UAAU,IAAI,aAAa;CAYjC,SAAS,GAAG,KAAa,UAAyB;EAChD,QAAQ,GAAG,KAAK,QAAQ;CAC1B;CAEA,SAAS,KAAiC,KAAW,OAAsB;EACzE,QAAQ,KAAK,KAAK,KAAK;EAEvB,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,WAAW,OAC5D,QAAQ,KAAK,UAAU;GACrB,GAAG;GACH,QAAQ;EACV,CAAC;EAGH,QAAQ,KAAK,QAAQ;GACnB,GAAG;GACH,QAAQ;EACV,CAAC;CACH;CAEA,OAAO;EACL;EACA;CACF;AACF"}
1
+ {"version":3,"file":"create-emitter.mjs","names":[],"sources":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"create-writer.d.mts","names":[],"sources":["../../src/helpers/create-writer.ts"],"mappings":";;;;;;AA6CA;;;;cAAa,YAAA,GACX,OAAA,EAAS,+BAAA,KACR,MA4CF"}
1
+ {"version":3,"file":"create-writer.d.mts","names":[],"sources":["../../src/helpers/create-writer.ts"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"create-writer.mjs","names":[],"sources":["../../src/helpers/create-writer.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n DataFileCollection,\n FileReferenceFileConfiguration,\n JavaScriptFileConfiguration,\n serialize,\n Writer\n} from \"@content-collections/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport pluralize from \"pluralize\";\nimport { getFileHeader } from \"powerlines/utils\";\nimport { ContentCollectionsPluginContext } from \"../types/plugin\";\n\nconst createConstName = (name: string) => {\n return pluralize(name.charAt(0).toUpperCase() + name.slice(1));\n};\n\nconst createArrayConstName = (name: string) => {\n return `all${createConstName(name)}`;\n};\n\n/**\n * Creates a Writer instance for emitting files related to content collections.\n *\n * @param context - The Powerlines build plugin\n * @returns A Writer instance for emitting files related to content collections\n */\nexport const createWriter = (\n context: ContentCollectionsPluginContext\n): Writer => {\n return {\n createJavaScriptFile: async (\n configuration: JavaScriptFileConfiguration\n ) => {\n return context.emitBuiltin(\n `${getFileHeader(context)}\n${configuration.collections\n .map(\n ({ name }) =>\n `import ${createArrayConstName(name)} from \"./${kebabCase(name)}\";`\n )\n .join(\"\\n\")}\n\nexport { ${configuration.collections\n .map(({ name }) => createArrayConstName(name))\n .join(\", \")} };\n`,\n \"content\"\n );\n },\n createFileReferenceFile: async (_: FileReferenceFileConfiguration) =>\n Promise.resolve(),\n createDataFiles: async (collections: Array<DataFileCollection>) => {\n await Promise.all(\n collections.map(async collection => {\n if (context.config.contentCollections.outputPath) {\n return context.fs.write(\n joinPaths(\n context.config.contentCollections.outputPath,\n kebabCase(collection.name)\n ),\n serialize(collection.documents.map(doc => doc.document))\n );\n }\n\n return context.emitBuiltin(\n serialize(collection.documents.map(doc => doc.document)),\n joinPaths(\"content\", kebabCase(collection.name))\n );\n })\n );\n }\n };\n};\n"],"mappings":";;;;;;;AA+BA,MAAM,mBAAmB,SAAiB;CACxC,OAAO,UAAU,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC;AAC/D;AAEA,MAAM,wBAAwB,SAAiB;CAC7C,OAAO,MAAM,gBAAgB,IAAI;AACnC;;;;;;;AAQA,MAAa,gBACX,YACW;CACX,OAAO;EACL,sBAAsB,OACpB,kBACG;GACH,OAAO,QAAQ,YACb,GAAG,cAAc,OAAO,EAAE;EAChC,cAAc,YACb,KACE,EAAE,WACD,UAAU,qBAAqB,IAAI,EAAE,WAAW,UAAU,IAAI,EAAE,GACpE,EACC,KAAK,IAAI,EAAE;;WAEH,cAAc,YACd,KAAK,EAAE,WAAW,qBAAqB,IAAI,CAAC,EAC5C,KAAK,IAAI,EAAE;GAEd,SACF;EACF;EACA,yBAAyB,OAAO,MAC9B,QAAQ,QAAQ;EAClB,iBAAiB,OAAO,gBAA2C;GACjE,MAAM,QAAQ,IACZ,YAAY,IAAI,OAAM,eAAc;IAClC,IAAI,QAAQ,OAAO,mBAAmB,YACpC,OAAO,QAAQ,GAAG,MAChB,UACE,QAAQ,OAAO,mBAAmB,YAClC,UAAU,WAAW,IAAI,CAC3B,GACA,UAAU,WAAW,UAAU,KAAI,QAAO,IAAI,QAAQ,CAAC,CACzD;IAGF,OAAO,QAAQ,YACb,UAAU,WAAW,UAAU,KAAI,QAAO,IAAI,QAAQ,CAAC,GACvD,UAAU,WAAW,UAAU,WAAW,IAAI,CAAC,CACjD;GACF,CAAC,CACH;EACF;CACF;AACF"}
1
+ {"version":3,"file":"create-writer.mjs","names":[],"sources":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;YAyCY,MAAA;IACR,kBAAA,GAAqB,+BAA+B;EAAA;AAAA;;;;;;;cAU3C,MAAA,oBACM,+BAAA,GACf,+BAAA,EAEF,OAAA,EAAS,+BAAA,KACR,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n build,\n createBuildContext,\n createConfigurationReader,\n InternalConfiguration\n} from \"@content-collections/core\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport defu from \"defu\";\nimport { createHash } from \"node:crypto\";\nimport { Plugin } from \"powerlines\";\nimport { replacePathTokens } from \"powerlines/plugin-utils\";\nimport { createEmitter } from \"./helpers/create-emitter\";\nimport { createWriter } from \"./helpers/create-writer\";\nimport {\n ContentCollectionsPluginContext,\n ContentCollectionsPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n contentCollections?: ContentCollectionsPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to integrate Content Collections for code generation.\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends ContentCollectionsPluginContext =\n ContentCollectionsPluginContext\n>(\n options: ContentCollectionsPluginOptions\n): Plugin<TContext> => {\n return {\n name: \"content-collections\",\n config() {\n return {\n contentCollections: defu(options, {\n configFile: \"{root}/content-collections.ts\",\n collections: []\n })\n };\n },\n async configResolved() {\n this.config.contentCollections.configFile ||= replacePathTokens(\n this,\n this.config.contentCollections.configFile\n );\n\n this.config.contentCollections.outputPath ||= replacePathTokens(\n this,\n this.config.contentCollections.outputPath\n );\n\n const emitter = createEmitter();\n const readConfiguration = createConfigurationReader();\n\n let configuration = {} as InternalConfiguration;\n try {\n if (existsSync(this.config.contentCollections.configFile)) {\n configuration = await readConfiguration(\n this.config.contentCollections.configFile,\n {\n configName: \"config.mjs\",\n cacheDir: joinPaths(this.cachePath, \"content-collections\")\n }\n );\n }\n } catch {\n // Do nothing\n }\n\n configuration = defu(configuration ?? {}, this.config.contentCollections);\n configuration.checksum = createHash(\"sha256\")\n .update(JSON.stringify(configuration))\n .digest(\"hex\");\n\n const context = await createBuildContext({\n emitter,\n baseDirectory: joinPaths(this.config.cwd, this.config.root),\n outputDirectory:\n this.config.contentCollections.outputPath ||\n joinPaths(this.builtinsPath, \"content\"),\n configuration\n });\n context.writer = createWriter(this);\n\n this.contentCollections = {\n context,\n build: async () => build(context),\n on: emitter.on\n };\n },\n async prepare() {\n return this.contentCollections.build();\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;AAoDA,MAAa,UAIX,YACqB;CACrB,OAAO;EACL,MAAM;EACN,SAAS;GACP,OAAO,EACL,oBAAoB,KAAK,SAAS;IAChC,YAAY;IACZ,aAAa,CAAC;GAChB,CAAC,EACH;EACF;EACA,MAAM,iBAAiB;GACrB,KAAK,OAAO,mBAAmB,eAAe,kBAC5C,MACA,KAAK,OAAO,mBAAmB,UACjC;GAEA,KAAK,OAAO,mBAAmB,eAAe,kBAC5C,MACA,KAAK,OAAO,mBAAmB,UACjC;GAEA,MAAM,UAAU,cAAc;GAC9B,MAAM,oBAAoB,0BAA0B;GAEpD,IAAI,gBAAgB,CAAC;GACrB,IAAI;IACF,IAAI,WAAW,KAAK,OAAO,mBAAmB,UAAU,GACtD,gBAAgB,MAAM,kBACpB,KAAK,OAAO,mBAAmB,YAC/B;KACE,YAAY;KACZ,UAAU,UAAU,KAAK,WAAW,qBAAqB;IAC3D,CACF;GAEJ,QAAQ,CAER;GAEA,gBAAgB,KAAK,iBAAiB,CAAC,GAAG,KAAK,OAAO,kBAAkB;GACxE,cAAc,WAAW,WAAW,QAAQ,EACzC,OAAO,KAAK,UAAU,aAAa,CAAC,EACpC,OAAO,KAAK;GAEf,MAAM,UAAU,MAAM,mBAAmB;IACvC;IACA,eAAe,UAAU,KAAK,OAAO,KAAK,KAAK,OAAO,IAAI;IAC1D,iBACE,KAAK,OAAO,mBAAmB,cAC/B,UAAU,KAAK,cAAc,SAAS;IACxC;GACF,CAAC;GACD,QAAQ,SAAS,aAAa,IAAI;GAElC,KAAK,qBAAqB;IACxB;IACA,OAAO,YAAY,MAAM,OAAO;IAChC,IAAI,QAAQ;GACd;EACF;EACA,MAAM,UAAU;GACd,OAAO,KAAK,mBAAmB,MAAM;EACvC;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;KAyBY,yBAAA,GAA4B,IAAA,CACtC,OAAA,CAAQ,UAAA,QAAkB,qBAAA;EAEtB,OAAA,EAAS,YAAA;AAAA;AAAA,UAEE,+BAAA;;;;;;;;;EASf,UAAA;EAbA;;;EAkBA,WAAA,GAAc,aAAa;EAhBd;;AAAiC;AAEhD;;;;;EAwBE,UAAA;AAAA;AAAA,KAGU,kCAAA,GAAqC,UAAA;EAC/C,kBAAA,GAAqB,+BAA+B;AAAA;AAAA,KAG1C,sCAAA,GAAyC,cAAA;EACnD,kBAAA,EAAoB,QAAA,CAClB,IAAA,CAAK,+BAAA,mBAEL,IAAA,CAAK,+BAAA;AAAA;AAAA,KAGG,+BAAA,yBACc,sCAAA,GACtB,sCAAA,IACA,aAAA,CAAc,eAAA;EAChB,kBAAA,EAAoB,yBAAA;AAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-content-collections",
3
- "version": "0.1.584",
3
+ "version": "0.1.586",
4
4
  "private": false,
5
5
  "description": "A Powerlines plugin to generate project code using Content Collections.",
6
6
  "keywords": [
@@ -145,11 +145,11 @@
145
145
  "@stryke/types": "^0.12.12",
146
146
  "defu": "^6.1.7",
147
147
  "pluralize": "^8.0.0",
148
- "powerlines": "^0.47.123"
148
+ "powerlines": "^0.47.125"
149
149
  },
150
150
  "devDependencies": {
151
151
  "@content-collections/core": "^0.12.0",
152
- "@powerlines/plugin-plugin": "^0.12.535",
152
+ "@powerlines/plugin-plugin": "^0.12.537",
153
153
  "@types/node": "^25.9.1",
154
154
  "@types/pluralize": "^0.0.33"
155
155
  },
@@ -158,5 +158,5 @@
158
158
  "@content-collections/core": { "optional": false }
159
159
  },
160
160
  "publishConfig": { "access": "public" },
161
- "gitHead": "f8de1000ffda8a49be7fccbb6f53890449f7bdd3"
161
+ "gitHead": "30ba301952db7af53c07d369bd22f650e5ca9c45"
162
162
  }