@powerlines/plugin-content-collections 0.1.117 → 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.
- package/dist/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/helpers/create-emitter.cjs +33 -1
- package/dist/helpers/create-emitter.mjs +32 -1
- package/dist/helpers/create-writer.cjs +40 -5
- package/dist/helpers/create-writer.mjs +38 -5
- package/dist/helpers/index.cjs +5 -1
- package/dist/helpers/index.mjs +4 -1
- package/dist/index.cjs +68 -1
- package/dist/index.mjs +62 -1
- package/dist/powerlines/src/lib/utilities/file-header.cjs +12 -3
- package/dist/powerlines/src/lib/utilities/file-header.mjs +11 -3
- package/dist/powerlines/src/plugin-utils/paths.cjs +36 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +35 -1
- package/dist/powerlines/src/types/context.d.cts +27 -3
- package/dist/powerlines/src/types/context.d.mts +27 -3
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +10 -10
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
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
|
|
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
|
|
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
|
|
2
|
-
|
|
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
|
-
|
|
6
|
-
|
|
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
|
|
2
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
+
//#region src/helpers/create-writer.ts
|
|
8
|
+
const createConstName = (name) => {
|
|
9
|
+
return pluralize(name.charAt(0).toUpperCase() + name.slice(1));
|
|
10
|
+
};
|
|
11
|
+
const createArrayConstName = (name) => {
|
|
12
|
+
return `all${createConstName(name)}`;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param context - The Powerlines build plugin
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
const createWriter = (context) => {
|
|
20
|
+
return {
|
|
21
|
+
createJavaScriptFile: async (configuration) => {
|
|
22
|
+
return context.emitBuiltin(`${getBaseFileHeader(context)}
|
|
23
|
+
${configuration.collections.map(({ name }) => `import ${createArrayConstName(name)} from "./${kebabCase(name)}";`).join("\n")}
|
|
24
|
+
|
|
25
|
+
export { ${configuration.collections.map(({ name }) => createArrayConstName(name)).join(", ")} };
|
|
26
|
+
`, "content");
|
|
27
|
+
},
|
|
28
|
+
createTypeDefinitionFile: async (_) => Promise.resolve(),
|
|
29
|
+
createDataFiles: async (collections) => {
|
|
30
|
+
await Promise.all(collections.map(async (collection) => {
|
|
31
|
+
if (context.config.contentCollections.outputPath) return context.fs.write(joinPaths(context.config.contentCollections.outputPath, kebabCase(collection.name)), serialize(collection.documents.map((doc) => doc.document)));
|
|
32
|
+
return context.emitBuiltin(serialize(collection.documents.map((doc) => doc.document)), joinPaths("content", kebabCase(collection.name)));
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { createWriter };
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
const
|
|
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;
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{createEmitter
|
|
1
|
+
import { createEmitter } from "./create-emitter.mjs";
|
|
2
|
+
import { createWriter } from "./create-writer.mjs";
|
|
3
|
+
|
|
4
|
+
export { createEmitter, createWriter };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,68 @@
|
|
|
1
|
-
Object.defineProperty(exports
|
|
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
|
|
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
|
|
2
|
-
|
|
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
|
-
|
|
9
|
+
`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.getBaseFileHeader = getBaseFileHeader;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import{titleCase
|
|
2
|
-
|
|
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
|
-
|
|
8
|
+
`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getBaseFileHeader };
|
|
@@ -1 +1,36 @@
|
|
|
1
|
-
const
|
|
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
|
|
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 =
|
|
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,7 @@ 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?:
|
|
327
|
+
emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
|
|
304
328
|
/**
|
|
305
329
|
* Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
306
330
|
*
|
|
@@ -309,7 +333,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
309
333
|
* @param path - An optional path to write the builtin file to
|
|
310
334
|
* @param options - Additional options for writing the builtin file
|
|
311
335
|
*/
|
|
312
|
-
emitBuiltinSync: (code: string, id: string, path?: string, options?:
|
|
336
|
+
emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
|
|
313
337
|
/**
|
|
314
338
|
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
315
339
|
*
|
|
@@ -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 =
|
|
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,7 @@ 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?:
|
|
327
|
+
emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
|
|
304
328
|
/**
|
|
305
329
|
* Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
306
330
|
*
|
|
@@ -309,7 +333,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
309
333
|
* @param path - An optional path to write the builtin file to
|
|
310
334
|
* @param options - Additional options for writing the builtin file
|
|
311
335
|
*/
|
|
312
|
-
emitBuiltinSync: (code: string, id: string, path?: string, options?:
|
|
336
|
+
emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
|
|
313
337
|
/**
|
|
314
338
|
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
315
339
|
*
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-content-collections",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.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.
|
|
127
|
-
"@stryke/string-format": "^0.12.
|
|
128
|
-
"@stryke/path": "^0.24.
|
|
129
|
-
"@stryke/type-checks": "^0.5.
|
|
130
|
-
"@stryke/types": "^0.10.
|
|
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.
|
|
133
|
+
"powerlines": "^0.36.23"
|
|
134
134
|
},
|
|
135
135
|
"devDependencies": {
|
|
136
|
-
"@powerlines/nx": "^0.11.
|
|
137
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
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": "
|
|
143
|
+
"gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
|
|
144
144
|
}
|