@powerlines/plugin-esbuild 0.13.299 → 0.13.300
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/core/src/lib/entry.mjs +22 -0
- package/dist/core/src/lib/entry.mjs.map +1 -0
- package/dist/core/src/lib/logger.mjs +40 -0
- package/dist/core/src/lib/logger.mjs.map +1 -0
- package/dist/core/src/lib/unplugin/helpers.mjs +19 -0
- package/dist/core/src/lib/unplugin/helpers.mjs.map +1 -0
- package/dist/core/src/lib/unplugin/index.mjs +5 -0
- package/dist/core/src/lib/unplugin/module-resolution.mjs +66 -0
- package/dist/core/src/lib/unplugin/module-resolution.mjs.map +1 -0
- package/dist/core/src/lib/unplugin/plugin.mjs +103 -0
- package/dist/core/src/lib/unplugin/plugin.mjs.map +1 -0
- package/dist/core/src/lib/utilities/source-file.mjs +21 -0
- package/dist/core/src/lib/utilities/source-file.mjs.map +1 -0
- package/dist/core/src/plugin-utils/paths.mjs +4 -0
- package/dist/core/src/types/api.d.mts +103 -0
- package/dist/core/src/types/api.d.mts.map +1 -0
- package/dist/core/src/types/commands.d.mts +10 -0
- package/dist/core/src/types/commands.d.mts.map +1 -0
- package/dist/core/src/types/config.d.mts +551 -0
- package/dist/core/src/types/config.d.mts.map +1 -0
- package/dist/core/src/types/context.d.mts +511 -0
- package/dist/core/src/types/context.d.mts.map +1 -0
- package/dist/core/src/types/fs.d.mts +487 -0
- package/dist/core/src/types/fs.d.mts.map +1 -0
- package/dist/core/src/types/hooks.d.mts +99 -0
- package/dist/core/src/types/hooks.d.mts.map +1 -0
- package/dist/core/src/types/index.d.mts +9 -0
- package/dist/core/src/types/plugin.d.mts +204 -0
- package/dist/core/src/types/plugin.d.mts.map +1 -0
- package/dist/core/src/types/tsconfig.d.mts +70 -0
- package/dist/core/src/types/tsconfig.d.mts.map +1 -0
- package/dist/core/src/types/unplugin.d.mts +25 -0
- package/dist/core/src/types/unplugin.d.mts.map +1 -0
- package/dist/core/src/types/unplugin.mjs +22 -0
- package/dist/core/src/types/unplugin.mjs.map +1 -0
- package/dist/helpers/bundle.d.mts +17 -0
- package/dist/helpers/bundle.d.mts.map +1 -0
- package/dist/helpers/bundle.mjs +42 -0
- package/dist/helpers/bundle.mjs.map +1 -0
- package/dist/helpers/index.d.mts +5 -2
- package/dist/helpers/index.mjs +5 -2
- package/dist/helpers/resolve-options.d.mts +25 -0
- package/dist/helpers/resolve-options.d.mts.map +1 -0
- package/dist/helpers/resolve-options.mjs +87 -0
- package/dist/helpers/resolve-options.mjs.map +1 -0
- package/dist/helpers/resolve.d.mts +28 -0
- package/dist/helpers/resolve.d.mts.map +1 -0
- package/dist/helpers/resolve.mjs +62 -0
- package/dist/helpers/resolve.mjs.map +1 -0
- package/dist/helpers/unplugin.d.mts +3 -3
- package/dist/helpers/unplugin.mjs +6 -5
- package/dist/helpers/unplugin.mjs.map +1 -1
- package/dist/index.d.mts +10 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +8 -6
- package/dist/index.mjs.map +1 -1
- package/dist/types/build.d.mts +8 -0
- package/dist/types/build.d.mts.map +1 -0
- package/dist/types/build.mjs +1 -0
- package/dist/types/index.d.mts +3 -2
- package/dist/types/plugin.d.mts +17 -10
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +28 -93
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/helpers/index.cjs +0 -3
- package/dist/helpers/index.d.cts +0 -2
- package/dist/helpers/unplugin.cjs +0 -11
- package/dist/helpers/unplugin.d.cts +0 -8
- package/dist/helpers/unplugin.d.cts.map +0 -1
- package/dist/index.cjs +0 -40
- package/dist/index.d.cts +0 -14
- package/dist/index.d.cts.map +0 -1
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +0 -2
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +0 -14
- package/dist/types/plugin.d.cts.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "../plugin-utils/paths.mjs";
|
|
2
|
+
import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
|
|
3
|
+
import "@stryke/convert/to-array";
|
|
4
|
+
import "@stryke/hash/murmurhash";
|
|
5
|
+
import "@stryke/helpers/get-unique";
|
|
6
|
+
import "@stryke/path/append";
|
|
7
|
+
import "@stryke/path/is-type";
|
|
8
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
9
|
+
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
10
|
+
import "@stryke/type-checks/is-object";
|
|
11
|
+
import "@stryke/type-checks/is-regexp";
|
|
12
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
13
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
14
|
+
|
|
15
|
+
//#region ../core/src/lib/entry.ts
|
|
16
|
+
function resolveEntryOutput(context, typeDefinition) {
|
|
17
|
+
return replaceExtension(replacePath(replacePath(replacePath(replacePath(replacePath(typeDefinition.file, joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, "src")), joinPaths(context.workspaceConfig.workspaceRoot, context.config.root)), joinPaths(context.config.root, "src")), context.config.root), "src"));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { resolveEntryOutput };
|
|
22
|
+
//# sourceMappingURL=entry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.mjs","names":[],"sources":["../../../../../core/src/lib/entry.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 { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash/murmurhash\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { replacePathTokens } from \"../plugin-utils/paths\";\nimport { BaseConfig } from \"../types\";\nimport { ResolvedEntryTypeDefinition } from \"../types/config\";\nimport type { Context } from \"../types/context\";\n\nexport function resolveEntryOutput(\n context: Context,\n typeDefinition: TypeDefinition\n): string {\n return replaceExtension(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n typeDefinition.file,\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n \"src\"\n )\n ),\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root\n )\n ),\n joinPaths(context.config.root, \"src\")\n ),\n context.config.root\n ),\n \"src\"\n )\n );\n}\n\nexport function resolveEntry(\n context: Context,\n typeDefinition: TypeDefinition,\n input?: string | RegExp | TypeDefinition | undefined,\n output?: string\n): ResolvedEntryTypeDefinition {\n return {\n ...typeDefinition,\n input:\n isSetString(input) || isRegExp(input)\n ? { file: String(input) }\n : typeDefinition,\n output: output || resolveEntryOutput(context, typeDefinition)\n };\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport async function resolveEntries(\n context: Context,\n typeDefinitions: Array<TypeDefinitionParameter | ResolvedEntryTypeDefinition>\n): Promise<ResolvedEntryTypeDefinition[]> {\n return (\n await Promise.all(\n typeDefinitions.map(async entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return { ...entry, file: replacePathTokens(context, entry.file) };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(context, typeDefinition.file);\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (await context.fs.isFile(filePath)) {\n return resolveEntry(\n context,\n {\n file: replacePath(filePath, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n );\n }\n\n return (\n await context.fs.glob(\n appendPath(filePath, context.workspaceConfig.workspaceRoot)\n )\n ).map(file =>\n resolveEntry(\n context,\n {\n file: replacePath(file, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n )\n );\n })\n )\n )\n .flat()\n .filter(Boolean);\n}\n\n/**\n * Checks if the provided entry is a type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a type definition, false otherwise.\n */\nexport function isTypeDefinition(\n entry: TypeDefinitionParameter\n): entry is TypeDefinition {\n return !isString(entry) && entry.file !== undefined;\n}\n\n/**\n * Checks if the provided entry is a resolved entry type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a resolved entry type definition, false otherwise.\n */\nexport function isResolvedEntryTypeDefinition(\n entry: TypeDefinitionParameter | ResolvedEntryTypeDefinition | RegExp\n): entry is ResolvedEntryTypeDefinition {\n return (\n !isRegExp(entry) &&\n isTypeDefinition(entry) &&\n (entry as ResolvedEntryTypeDefinition).output !== undefined\n );\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport function resolveEntriesSync(\n context: Context,\n typeDefinitions:\n | TypeDefinition\n | ResolvedEntryTypeDefinition\n | string\n | RegExp\n | (string | RegExp | TypeDefinition | ResolvedEntryTypeDefinition)[]\n | Record<\n string,\n string | RegExp | TypeDefinition | (string | RegExp | TypeDefinition)[]\n >\n): ResolvedEntryTypeDefinition[] {\n return (\n isObject(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else if (isRegExp(entry)) {\n typeDefinition = { file: replacePathTokens(context, entry.source) };\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(context, typeDefinition.file);\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (context.fs.isFileSync(filePath)) {\n return resolveEntry(context, {\n file: appendPath(filePath, context.workspaceConfig.workspaceRoot),\n name: typeDefinition.name\n });\n }\n\n return context.fs\n .globSync(appendPath(filePath, context.workspaceConfig.workspaceRoot))\n .map(file =>\n resolveEntry(context, {\n file,\n name: typeDefinition.name\n })\n );\n })\n .flat()\n .filter(Boolean);\n}\n\n/**\n * Get unique inputs from the provided list.\n *\n * @param inputs - The entry points to process.\n * @returns An array of unique inputs (by file path or content hash).\n */\nexport function getUniqueInputs(\n inputs: BaseConfig[\"input\"] = []\n): BaseConfig[\"input\"] {\n return isObject(inputs)\n ? inputs\n : getUniqueBy(toArray(inputs), (item: TypeDefinitionParameter) =>\n isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 })\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,SAAgB,mBACd,SACA,gBACQ;AACR,QAAO,iBACL,YACE,YACE,YACE,YACE,YACE,eAAe,MACf,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,MACf,MACD,CACF,EACD,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,KAChB,CACF,EACD,UAAU,QAAQ,OAAO,MAAM,MAAM,CACtC,EACD,QAAQ,OAAO,KAChB,EACD,MACD,CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
2
|
+
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
3
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
4
|
+
import "@storm-software/config-tools/logger";
|
|
5
|
+
import "@storm-software/config-tools/utilities/colors";
|
|
6
|
+
import "@stryke/helpers/noop";
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
|
|
9
|
+
//#region ../core/src/lib/logger.ts
|
|
10
|
+
const BADGE_COLORS = [
|
|
11
|
+
"#00A0DD",
|
|
12
|
+
"#6FCE4E",
|
|
13
|
+
"#FBBF24",
|
|
14
|
+
"#F43F5E",
|
|
15
|
+
"#3B82F6",
|
|
16
|
+
"#A855F7",
|
|
17
|
+
"#469592",
|
|
18
|
+
"#288EDF",
|
|
19
|
+
"#D8B4FE",
|
|
20
|
+
"#10B981",
|
|
21
|
+
"#EF4444",
|
|
22
|
+
"#F0EC56",
|
|
23
|
+
"#F472B6",
|
|
24
|
+
"#22D3EE",
|
|
25
|
+
"#EAB308",
|
|
26
|
+
"#84CC16",
|
|
27
|
+
"#F87171",
|
|
28
|
+
"#0EA5E9",
|
|
29
|
+
"#D946EF",
|
|
30
|
+
"#FACC15",
|
|
31
|
+
"#34D399",
|
|
32
|
+
"#8B5CF6"
|
|
33
|
+
];
|
|
34
|
+
const extendLog = (logFn, name) => {
|
|
35
|
+
return (type, ...args) => logFn(type, ` ${chalk.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { extendLog };
|
|
40
|
+
//# sourceMappingURL=logger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.mjs","names":[],"sources":["../../../../../core/src/lib/logger.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 { getLogFn, getLogLevel } from \"@storm-software/config-tools/logger\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { getColor } from \"@storm-software/config-tools/utilities/colors\";\nimport { noop } from \"@stryke/helpers/noop\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport chalk from \"chalk\";\nimport type { LogFn, WorkspaceConfig } from \"../types\";\n\nexport interface CreateLogOptions {\n name?: string;\n logLevel?: LogLevelLabel | null;\n customLogger?: LogFn;\n colors?: WorkspaceConfig[\"colors\"];\n}\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function.\n * @returns A logging function.\n */\nexport const createLog = (\n name: string | null,\n options: CreateLogOptions = {}\n): LogFn => {\n const logLevel =\n options.logLevel === null\n ? LogLevelLabel.SILENT\n : options.logLevel || LogLevelLabel.INFO;\n if (logLevel === LogLevelLabel.SILENT) {\n return noop;\n }\n\n if (options.customLogger) {\n return options.customLogger;\n }\n\n return (type: LogLevelLabel, ...args: string[]) =>\n getLogFn(getLogLevel(type), {\n ...options,\n logLevel\n })(\n `${chalk.bold.hex(\n getColor(\"brand\", options as Parameters<typeof getColor>[1])\n )(\n `${name ? kebabCase(name) : \"\"}${options.name ? `${name ? chalk.gray(\" > \") : \"\"}${kebabCase(options.name)}` : \"\"}${chalk.gray(\" > \")}`\n )}${args.join(\" \")} `.trim()\n );\n};\n\nconst BADGE_COLORS = [\n \"#00A0DD\",\n \"#6FCE4E\",\n \"#FBBF24\",\n \"#F43F5E\",\n \"#3B82F6\",\n \"#A855F7\",\n \"#469592\",\n \"#288EDF\",\n \"#D8B4FE\",\n \"#10B981\",\n \"#EF4444\",\n \"#F0EC56\",\n \"#F472B6\",\n \"#22D3EE\",\n \"#EAB308\",\n \"#84CC16\",\n \"#F87171\",\n \"#0EA5E9\",\n \"#D946EF\",\n \"#FACC15\",\n \"#34D399\",\n \"#8B5CF6\"\n] as const;\n\nexport const extendLog = (logFn: LogFn, name: string): LogFn => {\n return (type: LogLevelLabel, ...args: string[]) =>\n logFn(\n type,\n ` ${chalk.inverse.hex(\n BADGE_COLORS[\n name\n .split(\"\")\n .map(char => char.charCodeAt(0))\n .reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length\n ] || BADGE_COLORS[0]\n )(` ${titleCase(name)} `)} ${args.join(\" \")} `\n );\n};\n"],"mappings":";;;;;;;;;AAsEA,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,aAAa,OAAc,SAAwB;AAC9D,SAAQ,MAAqB,GAAG,SAC9B,MACE,MACA,IAAI,MAAM,QAAQ,IAChB,aACE,KACG,MAAM,GAAG,CACT,KAAI,SAAQ,KAAK,WAAW,EAAE,CAAC,CAC/B,QAAQ,KAAK,aAAa,MAAM,UAAU,EAAE,GAAG,aAAa,WAC5D,aAAa,GACnB,CAAC,IAAI,UAAU,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,GAC9C"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "../../types/unplugin.mjs";
|
|
2
|
+
import { defu as defu$1 } from "defu";
|
|
3
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
4
|
+
|
|
5
|
+
//#region ../core/src/lib/unplugin/helpers.ts
|
|
6
|
+
/**
|
|
7
|
+
* Merges a base plugin context with an unplugin context, combining their properties.
|
|
8
|
+
*
|
|
9
|
+
* @param contextA - The base plugin context to merge into.
|
|
10
|
+
* @param contextB - The unplugin context to merge from.
|
|
11
|
+
* @returns The merged context.
|
|
12
|
+
*/
|
|
13
|
+
function combineContexts(contextA, contextB) {
|
|
14
|
+
return defu$1(contextA, contextB);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { combineContexts };
|
|
19
|
+
//# sourceMappingURL=helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":["defu"],"sources":["../../../../../../core/src/lib/unplugin/helpers.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 { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport { UnpluginBuildContext } from \"unplugin\";\nimport { UnresolvedContext } from \"../../types/context\";\nimport {\n UNPLUGIN_BUILDER_VARIANTS,\n UnpluginBuilderVariant\n} from \"../../types/unplugin\";\n\n/**\n * Merges a base plugin context with an unplugin context, combining their properties.\n *\n * @param contextA - The base plugin context to merge into.\n * @param contextB - The unplugin context to merge from.\n * @returns The merged context.\n */\nexport function combineContexts<\n TContextA extends UnresolvedContext | UnpluginBuildContext,\n TContextB extends UnresolvedContext | UnpluginBuildContext\n>(contextA: TContextA, contextB: TContextB): TContextA & TContextB {\n return defu(contextA, contextB) as TContextA & TContextB;\n}\n\n/**\n * Checks if a value is a valid UnpluginBuilderVariant.\n *\n * @param str - The value to check.\n * @returns True if the value is a UnpluginBuilderVariant, false otherwise.\n */\nexport function isUnpluginBuilderVariant(\n str: unknown\n): str is UnpluginBuilderVariant {\n return (\n isSetString(str) &&\n UNPLUGIN_BUILDER_VARIANTS.includes(str as UnpluginBuilderVariant)\n );\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,SAAgB,gBAGd,UAAqB,UAA4C;AACjE,QAAOA,OAAK,UAAU,SAAS"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region ../core/src/lib/unplugin/module-resolution.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates the module resolution hook functions for a Powerlines unplugin plugin instance.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This includes the `resolveId` and `load` hooks.
|
|
7
|
+
*
|
|
8
|
+
* @see https://rollupjs.org/plugin-development/#resolveid
|
|
9
|
+
* @see https://rollupjs.org/plugin-development/#load
|
|
10
|
+
*
|
|
11
|
+
* @param context - The plugin context.
|
|
12
|
+
* @returns The module resolution hooks (`resolveId` and `load`).
|
|
13
|
+
*/
|
|
14
|
+
function createUnpluginModuleResolutionFunctions(context) {
|
|
15
|
+
const ctx = context;
|
|
16
|
+
async function resolveId(id, importer, opts = { isEntry: false }) {
|
|
17
|
+
let result = await ctx.$$internal.callHook("resolveId", {
|
|
18
|
+
sequential: true,
|
|
19
|
+
result: "first",
|
|
20
|
+
order: "pre"
|
|
21
|
+
}, id, importer, opts);
|
|
22
|
+
if (result) return result;
|
|
23
|
+
result = await ctx.$$internal.callHook("resolveId", {
|
|
24
|
+
sequential: true,
|
|
25
|
+
result: "first",
|
|
26
|
+
order: "normal"
|
|
27
|
+
}, id, importer, opts);
|
|
28
|
+
if (result) return result;
|
|
29
|
+
result = await ctx.resolve(id, importer, opts);
|
|
30
|
+
if (result) return result;
|
|
31
|
+
return ctx.$$internal.callHook("resolveId", {
|
|
32
|
+
sequential: true,
|
|
33
|
+
result: "first",
|
|
34
|
+
order: "post"
|
|
35
|
+
}, id, importer, opts);
|
|
36
|
+
}
|
|
37
|
+
async function load(id) {
|
|
38
|
+
let result = await ctx.$$internal.callHook("load", {
|
|
39
|
+
sequential: true,
|
|
40
|
+
result: "first",
|
|
41
|
+
order: "pre"
|
|
42
|
+
}, id);
|
|
43
|
+
if (result) return result;
|
|
44
|
+
result = await ctx.$$internal.callHook("load", {
|
|
45
|
+
sequential: true,
|
|
46
|
+
result: "first",
|
|
47
|
+
order: "normal"
|
|
48
|
+
}, id);
|
|
49
|
+
if (result) return result;
|
|
50
|
+
result = await ctx.load(id);
|
|
51
|
+
if (result) return result;
|
|
52
|
+
return ctx.$$internal.callHook("load", {
|
|
53
|
+
sequential: true,
|
|
54
|
+
result: "first",
|
|
55
|
+
order: "post"
|
|
56
|
+
}, id);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
resolveId,
|
|
60
|
+
load
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { createUnpluginModuleResolutionFunctions };
|
|
66
|
+
//# sourceMappingURL=module-resolution.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-resolution.mjs","names":[],"sources":["../../../../../../core/src/lib/unplugin/module-resolution.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 { LoadResult } from \"rollup\";\nimport type {\n ExternalIdResult,\n HookFnMap,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { UNSAFE_PluginContext } from \"../../types/_internal\";\nimport { PluginContext } from \"../../types/context\";\n\n/**\n * Creates the module resolution hook functions for a Powerlines unplugin plugin instance.\n *\n * @remarks\n * This includes the `resolveId` and `load` hooks.\n *\n * @see https://rollupjs.org/plugin-development/#resolveid\n * @see https://rollupjs.org/plugin-development/#load\n *\n * @param context - The plugin context.\n * @returns The module resolution hooks (`resolveId` and `load`).\n */\nexport function createUnpluginModuleResolutionFunctions<\n TContext extends PluginContext = PluginContext\n>(context: TContext): Pick<HookFnMap, \"resolveId\" | \"load\"> {\n const ctx = context as unknown as UNSAFE_PluginContext;\n\n async function resolveId(\n this: UnpluginBuildContext & UnpluginContext,\n id: string,\n importer?: string,\n opts: {\n isEntry: boolean;\n } = { isEntry: false }\n ): Promise<string | ExternalIdResult | null | undefined> {\n let result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n id,\n importer,\n opts\n );\n if (result) {\n return result;\n }\n\n result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n id,\n importer,\n opts\n );\n if (result) {\n return result;\n }\n\n result = await ctx.resolve(id, importer, opts);\n if (result) {\n return result;\n }\n\n return ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n id,\n importer,\n opts\n );\n }\n\n async function load(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<LoadResult | null | undefined> {\n let result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n id\n );\n if (result) {\n return result;\n }\n\n result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n id\n );\n if (result) {\n return result;\n }\n\n result = await ctx.load(id);\n if (result) {\n return result;\n }\n\n return ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n id\n );\n }\n\n return {\n resolveId,\n load\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAwCA,SAAgB,wCAEd,SAA0D;CAC1D,MAAM,MAAM;CAEZ,eAAe,UAEb,IACA,UACA,OAEI,EAAE,SAAS,OAAO,EACiC;EACvD,IAAI,SAAS,MAAM,IAAI,WAAW,SAChC,aACA;GACE,YAAY;GACZ,QAAQ;GACR,OAAO;GACR,EACD,IACA,UACA,KACD;AACD,MAAI,OACF,QAAO;AAGT,WAAS,MAAM,IAAI,WAAW,SAC5B,aACA;GACE,YAAY;GACZ,QAAQ;GACR,OAAO;GACR,EACD,IACA,UACA,KACD;AACD,MAAI,OACF,QAAO;AAGT,WAAS,MAAM,IAAI,QAAQ,IAAI,UAAU,KAAK;AAC9C,MAAI,OACF,QAAO;AAGT,SAAO,IAAI,WAAW,SACpB,aACA;GACE,YAAY;GACZ,QAAQ;GACR,OAAO;GACR,EACD,IACA,UACA,KACD;;CAGH,eAAe,KAEb,IACwC;EACxC,IAAI,SAAS,MAAM,IAAI,WAAW,SAChC,QACA;GACE,YAAY;GACZ,QAAQ;GACR,OAAO;GACR,EACD,GACD;AACD,MAAI,OACF,QAAO;AAGT,WAAS,MAAM,IAAI,WAAW,SAC5B,QACA;GACE,YAAY;GACZ,QAAQ;GACR,OAAO;GACR,EACD,GACD;AACD,MAAI,OACF,QAAO;AAGT,WAAS,MAAM,IAAI,KAAK,GAAG;AAC3B,MAAI,OACF,QAAO;AAGT,SAAO,IAAI,WAAW,SACpB,QACA;GACE,YAAY;GACZ,QAAQ;GACR,OAAO;GACR,EACD,GACD;;AAGH,QAAO;EACL;EACA;EACD"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { combineContexts } from "./helpers.mjs";
|
|
2
|
+
import { createUnpluginModuleResolutionFunctions } from "./module-resolution.mjs";
|
|
3
|
+
import { extendLog } from "../logger.mjs";
|
|
4
|
+
import { getString } from "../utilities/source-file.mjs";
|
|
5
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
6
|
+
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
7
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
8
|
+
import { setParseImpl } from "unplugin";
|
|
9
|
+
|
|
10
|
+
//#region ../core/src/lib/unplugin/plugin.ts
|
|
11
|
+
/**
|
|
12
|
+
* Creates a Powerlines unplugin instance.
|
|
13
|
+
*
|
|
14
|
+
* @param context - The plugin context.
|
|
15
|
+
* @returns The unplugin instance.
|
|
16
|
+
*/
|
|
17
|
+
function createUnpluginResolver(context, name = "unplugin") {
|
|
18
|
+
const ctx = context;
|
|
19
|
+
setParseImpl(ctx.parse);
|
|
20
|
+
return () => {
|
|
21
|
+
const log = extendLog(ctx.log, name);
|
|
22
|
+
log(LogLevelLabel.DEBUG, `Initializing ${name.toLowerCase() === "unplugin" ? "Unplugin" : `${titleCase(name)} - Unplugin`} plugin`);
|
|
23
|
+
try {
|
|
24
|
+
const { resolveId, load } = createUnpluginModuleResolutionFunctions(context);
|
|
25
|
+
return {
|
|
26
|
+
name: name.toLowerCase() === "unplugin" ? "powerlines" : `powerlines:${kebabCase(name)}`,
|
|
27
|
+
api: ctx.$$internal.api,
|
|
28
|
+
resolveId: {
|
|
29
|
+
filter: { id: { include: [/.*/] } },
|
|
30
|
+
handler: resolveId
|
|
31
|
+
},
|
|
32
|
+
load: {
|
|
33
|
+
filter: { id: { include: [/.*/] } },
|
|
34
|
+
handler: load
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
} catch (error) {
|
|
38
|
+
log(LogLevelLabel.FATAL, error?.message);
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a Powerlines unplugin instance.
|
|
45
|
+
*
|
|
46
|
+
* @param context - The plugin context.
|
|
47
|
+
* @returns The unplugin instance.
|
|
48
|
+
*/
|
|
49
|
+
function createUnplugin(context, name = "unplugin") {
|
|
50
|
+
const ctx = context;
|
|
51
|
+
setParseImpl(ctx.parse);
|
|
52
|
+
return () => {
|
|
53
|
+
const log = extendLog(ctx.log, name);
|
|
54
|
+
log(LogLevelLabel.DEBUG, `Initializing ${name.toLowerCase() === "unplugin" ? "Unplugin" : `${titleCase(name)} - Unplugin`} plugin`);
|
|
55
|
+
try {
|
|
56
|
+
const { resolveId, load } = createUnpluginModuleResolutionFunctions(context);
|
|
57
|
+
async function buildStart() {
|
|
58
|
+
log(LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
|
|
59
|
+
await ctx.$$internal.callHook("buildStart", { sequential: true });
|
|
60
|
+
}
|
|
61
|
+
async function transform(code, id) {
|
|
62
|
+
let transformed = code;
|
|
63
|
+
for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
|
|
64
|
+
const result = await hook.handler.apply(combineContexts(ctx, this), [getString(transformed), id]);
|
|
65
|
+
if (result) transformed = result;
|
|
66
|
+
}
|
|
67
|
+
return transformed;
|
|
68
|
+
}
|
|
69
|
+
async function buildEnd() {
|
|
70
|
+
log(LogLevelLabel.DEBUG, "Powerlines build plugin finishing...");
|
|
71
|
+
return ctx.$$internal.callHook("buildEnd", { sequential: true });
|
|
72
|
+
}
|
|
73
|
+
async function writeBundle() {
|
|
74
|
+
log(LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
|
|
75
|
+
return ctx.$$internal.callHook("writeBundle", { sequential: true });
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
name: name.toLowerCase() === "unplugin" ? "powerlines" : `powerlines:${kebabCase(name)}`,
|
|
79
|
+
api: ctx.$$internal.api,
|
|
80
|
+
resolveId: {
|
|
81
|
+
filter: { id: { include: [/.*/] } },
|
|
82
|
+
handler: resolveId
|
|
83
|
+
},
|
|
84
|
+
load: {
|
|
85
|
+
filter: { id: { include: [/.*/] } },
|
|
86
|
+
handler: load
|
|
87
|
+
},
|
|
88
|
+
transform,
|
|
89
|
+
buildStart,
|
|
90
|
+
buildEnd,
|
|
91
|
+
writeBundle,
|
|
92
|
+
vite: { sharedDuringBuild: true }
|
|
93
|
+
};
|
|
94
|
+
} catch (error) {
|
|
95
|
+
log(LogLevelLabel.FATAL, error?.message);
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { createUnplugin, createUnpluginResolver };
|
|
103
|
+
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":["transformed: TransformResult | string","result: TransformResult | string | undefined"],"sources":["../../../../../../core/src/lib/unplugin/plugin.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 { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { UNSAFE_PluginContext } from \"../../types/_internal\";\nimport { PluginContext } from \"../../types/context\";\nimport { UnpluginFactory } from \"../../types/unplugin\";\nimport { extendLog } from \"../logger\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\nimport { createUnpluginModuleResolutionFunctions } from \"./module-resolution\";\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnpluginResolver<\n TContext extends PluginContext = PluginContext\n>(context: TContext, name = \"unplugin\"): UnpluginFactory<TContext> {\n const ctx = context as unknown as UNSAFE_PluginContext;\n setParseImpl(ctx.parse);\n\n return () => {\n const log = extendLog(ctx.log, name);\n log(\n LogLevelLabel.DEBUG,\n `Initializing ${\n name.toLowerCase() === \"unplugin\"\n ? \"Unplugin\"\n : `${titleCase(name)} - Unplugin`\n } plugin`\n );\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context);\n\n return {\n name:\n name.toLowerCase() === \"unplugin\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId: {\n filter: {\n id: {\n include: [/.*/]\n }\n },\n handler: resolveId\n },\n load: {\n filter: {\n id: {\n include: [/.*/]\n }\n },\n handler: load\n }\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<TContext extends PluginContext = PluginContext>(\n context: TContext,\n name = \"unplugin\"\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as UNSAFE_PluginContext;\n setParseImpl(ctx.parse);\n\n return () => {\n const log = extendLog(ctx.log, name);\n log(\n LogLevelLabel.DEBUG,\n `Initializing ${\n name.toLowerCase() === \"unplugin\"\n ? \"Unplugin\"\n : `${titleCase(name)} - Unplugin`\n } plugin`\n );\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context);\n\n async function buildStart(this: UnpluginBuildContext) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin starting...\");\n\n await ctx.$$internal.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const hook of ctx.$$internal.environment.selectHooks(\n \"transform\"\n )) {\n const result: TransformResult | string | undefined =\n await hook.handler.apply(combineContexts(ctx, this), [\n getString(transformed),\n id\n ]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin finishing...\");\n\n return ctx.$$internal.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Finalizing Powerlines project output...\");\n\n return ctx.$$internal.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return {\n name:\n name.toLowerCase() === \"unplugin\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId: {\n filter: {\n id: {\n include: [/.*/]\n }\n },\n handler: resolveId\n },\n load: {\n filter: {\n id: {\n include: [/.*/]\n }\n },\n handler: load\n },\n transform,\n buildStart,\n buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyCA,SAAgB,uBAEd,SAAmB,OAAO,YAAuC;CACjE,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;AAEvB,cAAa;EACX,MAAM,MAAM,UAAU,IAAI,KAAK,KAAK;AACpC,MACE,cAAc,OACd,gBACE,KAAK,aAAa,KAAK,aACnB,aACA,GAAG,UAAU,KAAK,CAAC,aACxB,SACF;AAED,MAAI;GACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,QAAQ;AAE5D,UAAO;IACL,MACE,KAAK,aAAa,KAAK,aACnB,eACA,cAAc,UAAU,KAAK;IACnC,KAAK,IAAI,WAAW;IACpB,WAAW;KACT,QAAQ,EACN,IAAI,EACF,SAAS,CAAC,KAAK,EAChB,EACF;KACD,SAAS;KACV;IACD,MAAM;KACJ,QAAQ,EACN,IAAI,EACF,SAAS,CAAC,KAAK,EAChB,EACF;KACD,SAAS;KACV;IACF;WACM,OAAO;AACd,OAAI,cAAc,OAAQ,OAAiB,QAAQ;AAEnD,SAAM;;;;;;;;;;AAWZ,SAAgB,eACd,SACA,OAAO,YACoB;CAC3B,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;AAEvB,cAAa;EACX,MAAM,MAAM,UAAU,IAAI,KAAK,KAAK;AACpC,MACE,cAAc,OACd,gBACE,KAAK,aAAa,KAAK,aACnB,aACA,GAAG,UAAU,KAAK,CAAC,aACxB,SACF;AAED,MAAI;GACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,QAAQ;GAE5D,eAAe,aAAuC;AACpD,QAAI,cAAc,OAAO,sCAAsC;AAE/D,UAAM,IAAI,WAAW,SAAS,cAAc,EAC1C,YAAY,MACb,CAAC;;GAGJ,eAAe,UAEb,MACA,IAC6C;IAC7C,IAAIA,cAAwC;AAE5C,SAAK,MAAM,QAAQ,IAAI,WAAW,YAAY,YAC5C,YACD,EAAE;KACD,MAAMC,SACJ,MAAM,KAAK,QAAQ,MAAM,gBAAgB,KAAK,KAAK,EAAE,CACnD,UAAU,YAAY,EACtB,GACD,CAAC;AACJ,SAAI,OACF,eAAc;;AAIlB,WAAO;;GAGT,eAAe,WAAoD;AACjE,QAAI,cAAc,OAAO,uCAAuC;AAEhE,WAAO,IAAI,WAAW,SAAS,YAAY,EACzC,YAAY,MACb,CAAC;;GAGJ,eAAe,cAA6B;AAC1C,QAAI,cAAc,OAAO,0CAA0C;AAEnE,WAAO,IAAI,WAAW,SAAS,eAAe,EAC5C,YAAY,MACb,CAAC;;AAGJ,UAAO;IACL,MACE,KAAK,aAAa,KAAK,aACnB,eACA,cAAc,UAAU,KAAK;IACnC,KAAK,IAAI,WAAW;IACpB,WAAW;KACT,QAAQ,EACN,IAAI,EACF,SAAS,CAAC,KAAK,EAChB,EACF;KACD,SAAS;KACV;IACD,MAAM;KACJ,QAAQ,EACN,IAAI,EACF,SAAS,CAAC,KAAK,EAChB,EACF;KACD,SAAS;KACV;IACD;IACA;IACA;IACA;IACA,MAAM,EACJ,mBAAmB,MACpB;IACF;WACM,OAAO;AACd,OAAI,cAAc,OAAQ,OAAiB,QAAQ;AAEnD,SAAM"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
2
|
+
import "@stryke/fs/read-file";
|
|
3
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
4
|
+
|
|
5
|
+
//#region ../core/src/lib/utilities/source-file.ts
|
|
6
|
+
/**
|
|
7
|
+
* Get the string from the source.
|
|
8
|
+
*
|
|
9
|
+
* @param code - The source string or magic string.
|
|
10
|
+
* @returns The source string.
|
|
11
|
+
*/
|
|
12
|
+
function getString(code) {
|
|
13
|
+
if (!code) return "";
|
|
14
|
+
if (isString(code)) return code;
|
|
15
|
+
if (isSetObject(code) && "code" in code) return code.code;
|
|
16
|
+
return code.toString();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getString };
|
|
21
|
+
//# sourceMappingURL=source-file.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-file.mjs","names":[],"sources":["../../../../../../core/src/lib/utilities/source-file.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 { readFileIfExistingSync } from \"@stryke/fs/read-file\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport MagicString from \"magic-string\";\nimport { TransformResult } from \"unplugin\";\nimport { SourceFile } from \"../../types/context\";\n\n/**\n * Get the string from the source.\n *\n * @param code - The source string or magic string.\n * @returns The source string.\n */\nexport function getString(\n code: string | MagicString | TransformResult\n): string {\n if (!code) {\n return \"\";\n }\n\n if (isString(code)) {\n return code;\n }\n\n if (isSetObject(code) && \"code\" in code) {\n return code.code;\n }\n\n return code.toString();\n}\n\n/**\n * Get the magic string.\n *\n * @param code - The source string or magic string.\n * @returns The magic string.\n */\nexport function getMagicString(code: string | MagicString): MagicString {\n if (isString(code)) {\n return new MagicString(code);\n }\n\n return code;\n}\n\n/**\n * Get the source file.\n *\n * @param code - The source code.\n * @param id - The name of the file.\n * @returns The source file.\n */\nexport function getSourceFile(\n code: string | MagicString,\n id: string\n): SourceFile {\n const content = code ?? readFileIfExistingSync(id);\n\n return {\n id,\n code: getMagicString(content),\n env: []\n };\n}\n"],"mappings":";;;;;;;;;;;AA+BA,SAAgB,UACd,MACQ;AACR,KAAI,CAAC,KACH,QAAO;AAGT,KAAI,SAAS,KAAK,CAChB,QAAO;AAGT,KAAI,YAAY,KAAK,IAAI,UAAU,KACjC,QAAO,KAAK;AAGd,QAAO,KAAK,UAAU"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CallHookOptions, InferHookParameters, InferHookReturnType } from "./hooks.mjs";
|
|
2
|
+
import { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, LintInlineConfig, NewInlineConfig, PrepareInlineConfig, ResolvedConfig } from "./config.mjs";
|
|
3
|
+
import { APIContext, EnvironmentContext, PluginContext } from "./context.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../core/src/types/api.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Powerlines API Interface
|
|
9
|
+
*/
|
|
10
|
+
interface API<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
|
|
11
|
+
/**
|
|
12
|
+
* The Powerlines shared API context
|
|
13
|
+
*/
|
|
14
|
+
context: APIContext<TResolvedConfig>;
|
|
15
|
+
/**
|
|
16
|
+
* Prepare the Powerlines API
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
20
|
+
*
|
|
21
|
+
* @param inlineConfig - The inline configuration for the prepare command
|
|
22
|
+
*/
|
|
23
|
+
prepare: (inlineConfig: PrepareInlineConfig | NewInlineConfig | CleanInlineConfig | BuildInlineConfig | LintInlineConfig | DocsInlineConfig | DeployInlineConfig) => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new Powerlines project
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* This method will create a new Powerlines project in the current directory.
|
|
29
|
+
*
|
|
30
|
+
* @param inlineConfig - The inline configuration for the new command
|
|
31
|
+
* @returns A promise that resolves when the project has been created
|
|
32
|
+
*/
|
|
33
|
+
new: (inlineConfig: NewInlineConfig) => Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Clean any previously prepared artifacts
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* This method will remove the previous Powerlines artifacts from the project.
|
|
39
|
+
*
|
|
40
|
+
* @param inlineConfig - The inline configuration for the clean command
|
|
41
|
+
* @returns A promise that resolves when the clean command has completed
|
|
42
|
+
*/
|
|
43
|
+
clean: (inlineConfig: CleanInlineConfig | PrepareInlineConfig) => Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Lint the project source code
|
|
46
|
+
*
|
|
47
|
+
* @param inlineConfig - The inline configuration for the lint command
|
|
48
|
+
* @returns A promise that resolves when the lint command has completed
|
|
49
|
+
*/
|
|
50
|
+
lint: (inlineConfig: LintInlineConfig) => Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Build the project
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
56
|
+
*
|
|
57
|
+
* @param inlineConfig - The inline configuration for the build command
|
|
58
|
+
* @returns A promise that resolves when the build command has completed
|
|
59
|
+
*/
|
|
60
|
+
build: (inlineConfig: BuildInlineConfig) => Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Prepare the documentation for the project
|
|
63
|
+
*
|
|
64
|
+
* @param inlineConfig - The inline configuration for the docs command
|
|
65
|
+
* @returns A promise that resolves when the documentation generation has completed
|
|
66
|
+
*/
|
|
67
|
+
docs: (inlineConfig: DocsInlineConfig) => Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Deploy the project source code
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
73
|
+
*
|
|
74
|
+
* @param inlineConfig - The inline configuration for the deploy command
|
|
75
|
+
*/
|
|
76
|
+
deploy: (inlineConfig: DeployInlineConfig) => Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Finalization process
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
82
|
+
*
|
|
83
|
+
* @returns A promise that resolves when the finalization process has completed
|
|
84
|
+
*/
|
|
85
|
+
finalize: () => Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Invokes the configured plugin hooks
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
|
|
91
|
+
*
|
|
92
|
+
* @param hook - The hook to call
|
|
93
|
+
* @param options - The options to provide to the hook
|
|
94
|
+
* @param args - The arguments to pass to the hook
|
|
95
|
+
* @returns The result of the hook call
|
|
96
|
+
*/
|
|
97
|
+
callHook: <TKey extends string>(hook: TKey, options: CallHookOptions & {
|
|
98
|
+
environment?: string | EnvironmentContext<TResolvedConfig>;
|
|
99
|
+
}, ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>) => Promise<InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined>;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { API };
|
|
103
|
+
//# sourceMappingURL=api.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.mts","names":[],"sources":["../../../../../core/src/types/api.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAsCA;AAA6C,UAA5B,GAA4B,CAAA,wBAAA,cAAA,GAAiB,cAAjB,CAAA,CAAA;EAAiB;;;EAgBtD,OAAA,EAZG,UAYH,CAZc,eAYd,CAAA;EACA;;;;;;;;EAiBkC,OAAA,EAAA,CAAA,YAAA,EAlBlC,mBAkBkC,GAjBlC,eAiBkC,GAhBlC,iBAgBkC,GAflC,iBAekC,GAdlC,gBAckC,GAblC,gBAakC,GAZlC,kBAYkC,EAAA,GAXnC,OAWmC,CAAA,IAAA,CAAA;EAYxB;;;;;;;;;EAsCO,GAAA,EAAA,CAAA,YAAA,EAlDH,eAkDG,EAAA,GAlDiB,OAkDjB,CAAA,IAAA,CAAA;EAAuB;;;;;;;;;EA4BnC,KAAA,EAAA,CAAA,YAAA,EAlEK,iBAkEL,GAlEyB,mBAkEzB,EAAA,GAjEN,OAiEM,CAAA,IAAA,CAAA;EAEyB;;;;;;uBA3Df,qBAAqB;;;;;;;;;;wBAWpB,sBAAsB;;;;;;;uBAQvB,qBAAqB;;;;;;;;;yBAUnB,uBAAuB;;;;;;;;;kBAU9B;;;;;;;;;;;;wCAcR,eACG;2BACgB,mBAAmB;cAEnC,oBAAoB,cAAc,kBAAkB,UAC1D,QACH,oBAAoB,cAAc,kBAAkB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./context.mjs";
|
|
2
|
+
import { MaybePromise } from "@stryke/types/base";
|
|
3
|
+
import { ArrayValues } from "@stryke/types/array";
|
|
4
|
+
|
|
5
|
+
//#region ../core/src/types/commands.d.ts
|
|
6
|
+
declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
|
|
7
|
+
type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { CommandType, SUPPORTED_COMMANDS };
|
|
10
|
+
//# sourceMappingURL=commands.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.mts","names":[],"sources":["../../../../../core/src/types/commands.ts"],"sourcesContent":[],"mappings":";;;;;cAsBa;KAYD,WAAA,GAAc,mBAAmB"}
|