powerlines 0.40.1 → 0.40.3
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/{api-D1TJOJXE.mjs → api-C9xtrjcq.mjs} +105 -57
- package/dist/api-C9xtrjcq.mjs.map +1 -0
- package/dist/{api-CMgoAQum.cjs → api-CW410d4B.cjs} +104 -56
- package/dist/astro.cjs +5 -5
- package/dist/astro.d.cts +1 -1
- package/dist/astro.d.mts +5 -5
- package/dist/astro.mjs +5 -5
- package/dist/{config-CY-rNoQX.d.cts → config-BNcBL0tI.d.cts} +23 -1
- package/dist/config-BNcBL0tI.d.cts.map +1 -0
- package/dist/{config-BYUOZn2-.d.mts → config-Bu97tgeF.d.cts} +2 -2
- package/dist/{config-BYUOZn2-.d.mts.map → config-Bu97tgeF.d.cts.map} +1 -1
- package/dist/{config-tAvhtoU3.d.cts → config-D2cqq84p.d.mts} +2 -2
- package/dist/{config-tAvhtoU3.d.cts.map → config-D2cqq84p.d.mts.map} +1 -1
- package/dist/{config-B76VxuFj.d.mts → config-jcYnkMvq.d.mts} +23 -1
- package/dist/config-jcYnkMvq.d.mts.map +1 -0
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/context/index.cjs +3 -3
- package/dist/context/index.d.cts +21 -1
- package/dist/context/index.d.cts.map +1 -1
- package/dist/context/index.d.mts +24 -4
- package/dist/context/index.d.mts.map +1 -1
- package/dist/context/index.mjs +3 -3
- package/dist/{esbuild-B8xqzmmF.cjs → esbuild-CiPqZPkA.cjs} +2 -2
- package/dist/{esbuild-Bo7TrGmt.mjs → esbuild-DQAGVDY_.mjs} +3 -3
- package/dist/{esbuild-Bo7TrGmt.mjs.map → esbuild-DQAGVDY_.mjs.map} +1 -1
- package/dist/esbuild.cjs +5 -5
- package/dist/esbuild.d.cts +1 -1
- package/dist/esbuild.d.mts +4 -4
- package/dist/esbuild.mjs +5 -5
- package/dist/farm.cjs +3 -3
- package/dist/farm.d.cts +1 -1
- package/dist/farm.d.mts +4 -4
- package/dist/farm.mjs +3 -3
- package/dist/{index-C60deASW.d.mts → index-4WNH8dg3.d.mts} +2 -2
- package/dist/{index-C60deASW.d.mts.map → index-4WNH8dg3.d.mts.map} +1 -1
- package/dist/{index-Dqk6Rh9U.d.mts → index-BjLkEvse.d.mts} +3 -3
- package/dist/{index-Dqk6Rh9U.d.mts.map → index-BjLkEvse.d.mts.map} +1 -1
- package/dist/{index-DkZkdzSQ.d.cts → index-Cie2X8UH.d.cts} +2 -2
- package/dist/{index-DkZkdzSQ.d.cts.map → index-Cie2X8UH.d.cts.map} +1 -1
- package/dist/{write-file-gkuvUoFn.d.cts → index-DP6juTGE.d.mts} +35 -6
- package/dist/index-DP6juTGE.d.mts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +3 -3
- package/dist/next.cjs +4 -4
- package/dist/next.mjs +4 -4
- package/dist/nuxt.cjs +6 -6
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +4 -4
- package/dist/nuxt.mjs +6 -6
- package/dist/{plugin-DE7BXFkV.d.mts → plugin-CO_BQ0th.d.cts} +2 -2
- package/dist/{plugin-DE7BXFkV.d.mts.map → plugin-CO_BQ0th.d.cts.map} +1 -1
- package/dist/{plugin-CPi1BC54.d.cts → plugin-CvPFipli.d.cts} +3 -3
- package/dist/{plugin-CPi1BC54.d.cts.map → plugin-CvPFipli.d.cts.map} +1 -1
- package/dist/plugin-utils.d.cts +3 -3
- package/dist/plugin-utils.d.cts.map +1 -1
- package/dist/plugin-utils.d.mts +7 -7
- package/dist/plugin-utils.d.mts.map +1 -1
- package/dist/{plugin-XET4WKK4.d.cts → plugin-xJ2LIFca.d.mts} +2 -2
- package/dist/{plugin-XET4WKK4.d.cts.map → plugin-xJ2LIFca.d.mts.map} +1 -1
- package/dist/{resolve-options-B1gzDFxb.cjs → resolve-options-BQnTgg3V.cjs} +1 -1
- package/dist/{resolve-options-Ym_q-Hb7.mjs → resolve-options-DHL3RM8F.mjs} +2 -2
- package/dist/{resolve-options-Ym_q-Hb7.mjs.map → resolve-options-DHL3RM8F.mjs.map} +1 -1
- package/dist/{rolldown-HYYWYM2Y.mjs → rolldown-B2frMllJ.mjs} +2 -2
- package/dist/{rolldown-HYYWYM2Y.mjs.map → rolldown-B2frMllJ.mjs.map} +1 -1
- package/dist/{rolldown-1g-LKcc6.cjs → rolldown-Cop6Gb8O.cjs} +1 -1
- package/dist/rolldown.cjs +4 -4
- package/dist/rolldown.d.cts +1 -1
- package/dist/rolldown.d.mts +4 -4
- package/dist/rolldown.mjs +4 -4
- package/dist/rollup.cjs +3 -3
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.mts +4 -4
- package/dist/rollup.mjs +3 -3
- package/dist/rspack.cjs +3 -3
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.mts +4 -4
- package/dist/rspack.mjs +3 -3
- package/dist/storage/index.cjs +3 -1
- package/dist/storage/index.d.cts +1 -1
- package/dist/storage/index.d.cts.map +1 -1
- package/dist/storage/index.d.mts +4 -4
- package/dist/storage/index.d.mts.map +1 -1
- package/dist/storage/index.mjs +3 -1
- package/dist/tsdown.cjs +4 -4
- package/dist/tsdown.d.cts +1 -1
- package/dist/tsdown.d.mts +4 -4
- package/dist/tsdown.mjs +4 -4
- package/dist/tsup.cjs +5 -5
- package/dist/tsup.d.cts +1 -1
- package/dist/tsup.d.mts +4 -4
- package/dist/tsup.mjs +5 -5
- package/dist/typescript/index.d.cts +1 -1
- package/dist/typescript/index.d.mts +4 -4
- package/dist/unloader.cjs +3 -3
- package/dist/unloader.d.cts +1 -1
- package/dist/unloader.d.mts +4 -4
- package/dist/unloader.mjs +3 -3
- package/dist/unplugin.cjs +3 -3
- package/dist/unplugin.d.cts +2 -2
- package/dist/unplugin.d.mts +4 -4
- package/dist/unplugin.mjs +3 -3
- package/dist/{utils-CxKWmhs2.cjs → utils-BbDma_5Y.cjs} +54 -9
- package/dist/{utils-RU0EjpzP.mjs → utils-DoQcX7Sk.mjs} +40 -7
- package/dist/{utils-RU0EjpzP.mjs.map → utils-DoQcX7Sk.mjs.map} +1 -1
- package/dist/utils.cjs +4 -2
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.mts +3 -3
- package/dist/utils.mjs +2 -2
- package/dist/{virtual-D8bn8LRN.cjs → virtual-B1MLgqnQ.cjs} +10 -2
- package/dist/{virtual-D-9vfvVY.mjs → virtual-B9imjOqe.mjs} +11 -3
- package/dist/virtual-B9imjOqe.mjs.map +1 -0
- package/dist/{vite-C6OXShid.cjs → vite-7nY8fpz4.cjs} +2 -2
- package/dist/{vite-BKmkglFo.mjs → vite-C5AaWEV1.mjs} +3 -3
- package/dist/{vite-BKmkglFo.mjs.map → vite-C5AaWEV1.mjs.map} +1 -1
- package/dist/vite.cjs +5 -5
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.mts +5 -5
- package/dist/vite.mjs +5 -5
- package/dist/{webpack-L3DT059U.cjs → webpack-DAKZgaMR.cjs} +1 -1
- package/dist/{webpack-DZvno7jS.mjs → webpack-L68CX5gk.mjs} +2 -2
- package/dist/{webpack-DZvno7jS.mjs.map → webpack-L68CX5gk.mjs.map} +1 -1
- package/dist/webpack.cjs +4 -4
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.mts +4 -4
- package/dist/webpack.mjs +4 -4
- package/dist/{index-TMfRNrCg.d.mts → write-file-DKA8GehT.d.cts} +35 -6
- package/dist/write-file-DKA8GehT.d.cts.map +1 -0
- package/package.json +28 -28
- package/dist/api-D1TJOJXE.mjs.map +0 -1
- package/dist/config-B76VxuFj.d.mts.map +0 -1
- package/dist/config-CY-rNoQX.d.cts.map +0 -1
- package/dist/index-TMfRNrCg.d.mts.map +0 -1
- package/dist/virtual-D-9vfvVY.mjs.map +0 -1
- package/dist/write-file-gkuvUoFn.d.cts.map +0 -1
package/dist/tsup.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { o as createUnplugin } from "./api-
|
|
1
|
+
import { o as createUnplugin } from "./api-C9xtrjcq.mjs";
|
|
2
2
|
import "./tsconfig-B92heKit.mjs";
|
|
3
3
|
import "./plugin-utils-C3HnZJl1.mjs";
|
|
4
4
|
import "./plugin-E5foRD0k.mjs";
|
|
5
5
|
import "./paths-CS8ecCnW.mjs";
|
|
6
6
|
import "./constants-cXxSHhNp.mjs";
|
|
7
7
|
import "./config-D4Fh2gQL.mjs";
|
|
8
|
-
import "./
|
|
9
|
-
import "./
|
|
10
|
-
import { n as resolveEntry } from "./resolve-options-
|
|
11
|
-
import { t as esbuild_default } from "./esbuild-
|
|
8
|
+
import "./utils-DoQcX7Sk.mjs";
|
|
9
|
+
import "./virtual-B9imjOqe.mjs";
|
|
10
|
+
import { n as resolveEntry } from "./resolve-options-DHL3RM8F.mjs";
|
|
11
|
+
import { t as esbuild_default } from "./esbuild-DQAGVDY_.mjs";
|
|
12
12
|
import { toArray } from "@stryke/convert/to-array";
|
|
13
13
|
import { omit } from "@stryke/helpers/omit";
|
|
14
14
|
import { appendPath } from "@stryke/path/append";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _t as Context, dn as TSConfig, on as ParsedTypeScriptConfig } from "../config-
|
|
1
|
+
import { _t as Context, dn as TSConfig, on as ParsedTypeScriptConfig } from "../config-BNcBL0tI.cjs";
|
|
2
2
|
import { FilterPattern } from "@stryke/types/file";
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
import { FileSystemHost, InMemoryFileSystemHost, Project, ProjectOptions, RuntimeDirEntry } from "ts-morph";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _t as Context, dn as TSConfig, on as ParsedTypeScriptConfig } from "../config-
|
|
2
|
-
import "../config-
|
|
3
|
-
import "../index-
|
|
4
|
-
import "../index-
|
|
1
|
+
import { _t as Context, dn as TSConfig, on as ParsedTypeScriptConfig } from "../config-jcYnkMvq.mjs";
|
|
2
|
+
import "../config-D2cqq84p.mjs";
|
|
3
|
+
import "../index-DP6juTGE.mjs";
|
|
4
|
+
import "../index-BjLkEvse.mjs";
|
|
5
5
|
import { FileSystemHost, InMemoryFileSystemHost, Project, ProjectOptions, RuntimeDirEntry } from "ts-morph";
|
|
6
6
|
import ts from "typescript";
|
|
7
7
|
import { FilterPattern } from "@stryke/types/file";
|
package/dist/unloader.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
3
|
-
const require_api = require('./api-
|
|
3
|
+
const require_api = require('./api-CW410d4B.cjs');
|
|
4
4
|
require('./tsconfig-C8M8X6U0.cjs');
|
|
5
5
|
require('./plugin-utils-Ck3cx3w6.cjs');
|
|
6
6
|
require('./plugin-CZ_PJPpQ.cjs');
|
|
7
7
|
require('./paths-YmyIGEVo.cjs');
|
|
8
8
|
require('./constants-CZh5rsgh.cjs');
|
|
9
9
|
require('./config-D86Vw7SC.cjs');
|
|
10
|
-
require('./
|
|
11
|
-
require('./
|
|
10
|
+
require('./utils-BbDma_5Y.cjs');
|
|
11
|
+
require('./virtual-B1MLgqnQ.cjs');
|
|
12
12
|
let unplugin = require("unplugin");
|
|
13
13
|
|
|
14
14
|
//#region src/unloader.ts
|
package/dist/unloader.d.cts
CHANGED
package/dist/unloader.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { N as UserConfig } from "./config-
|
|
2
|
-
import "./config-
|
|
3
|
-
import "./index-
|
|
4
|
-
import "./index-
|
|
1
|
+
import { N as UserConfig } from "./config-jcYnkMvq.mjs";
|
|
2
|
+
import "./config-D2cqq84p.mjs";
|
|
3
|
+
import "./index-DP6juTGE.mjs";
|
|
4
|
+
import "./index-BjLkEvse.mjs";
|
|
5
5
|
import * as unloader0 from "unloader";
|
|
6
6
|
|
|
7
7
|
//#region src/unloader.d.ts
|
package/dist/unloader.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { a as createUnpluginFactory } from "./api-
|
|
1
|
+
import { a as createUnpluginFactory } from "./api-C9xtrjcq.mjs";
|
|
2
2
|
import "./tsconfig-B92heKit.mjs";
|
|
3
3
|
import "./plugin-utils-C3HnZJl1.mjs";
|
|
4
4
|
import "./plugin-E5foRD0k.mjs";
|
|
5
5
|
import "./paths-CS8ecCnW.mjs";
|
|
6
6
|
import "./constants-cXxSHhNp.mjs";
|
|
7
7
|
import "./config-D4Fh2gQL.mjs";
|
|
8
|
-
import "./
|
|
9
|
-
import "./
|
|
8
|
+
import "./utils-DoQcX7Sk.mjs";
|
|
9
|
+
import "./virtual-B9imjOqe.mjs";
|
|
10
10
|
import { createUnloaderPlugin } from "unplugin";
|
|
11
11
|
|
|
12
12
|
//#region src/unloader.ts
|
package/dist/unplugin.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const require_api = require('./api-
|
|
1
|
+
const require_api = require('./api-CW410d4B.cjs');
|
|
2
2
|
require('./tsconfig-C8M8X6U0.cjs');
|
|
3
3
|
require('./plugin-utils-Ck3cx3w6.cjs');
|
|
4
4
|
require('./plugin-CZ_PJPpQ.cjs');
|
|
5
5
|
require('./paths-YmyIGEVo.cjs');
|
|
6
6
|
require('./constants-CZh5rsgh.cjs');
|
|
7
7
|
require('./config-D86Vw7SC.cjs');
|
|
8
|
-
require('./
|
|
9
|
-
require('./
|
|
8
|
+
require('./utils-BbDma_5Y.cjs');
|
|
9
|
+
require('./virtual-B1MLgqnQ.cjs');
|
|
10
10
|
|
|
11
11
|
exports.combineContexts = require_api.combineContexts;
|
|
12
12
|
exports.createUnplugin = require_api.createUnplugin;
|
package/dist/unplugin.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _t as Context, br as UnpluginOptions$1, kr as API, vr as UnpluginBuilderVariant, yr as UnpluginFactory } from "./config-
|
|
2
|
-
import { a as createUnplugin, c as __ΩCreateUnpluginModuleResolutionFunctionsOptions, d as isUnpluginBuilderVariant, i as __ΩCreateUnpluginResolverOptions, l as createUnpluginModuleResolutionFunctions, n as CreateUnpluginResolverOptions, o as createUnpluginResolver, r as __ΩCreateUnpluginOptions, s as CreateUnpluginModuleResolutionFunctionsOptions, t as CreateUnpluginOptions, u as combineContexts } from "./plugin-
|
|
1
|
+
import { _t as Context, br as UnpluginOptions$1, kr as API, vr as UnpluginBuilderVariant, yr as UnpluginFactory } from "./config-BNcBL0tI.cjs";
|
|
2
|
+
import { a as createUnplugin, c as __ΩCreateUnpluginModuleResolutionFunctionsOptions, d as isUnpluginBuilderVariant, i as __ΩCreateUnpluginResolverOptions, l as createUnpluginModuleResolutionFunctions, n as CreateUnpluginResolverOptions, o as createUnpluginResolver, r as __ΩCreateUnpluginOptions, s as CreateUnpluginModuleResolutionFunctionsOptions, t as CreateUnpluginOptions, u as combineContexts } from "./plugin-CvPFipli.cjs";
|
|
3
3
|
import { UnpluginOptions } from "unplugin";
|
|
4
4
|
|
|
5
5
|
//#region src/unplugin.d.ts
|
package/dist/unplugin.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _t as Context, br as UnpluginOptions$1, kr as API, vr as UnpluginBuilderVariant, yr as UnpluginFactory } from "./config-
|
|
2
|
-
import "./config-
|
|
3
|
-
import "./index-
|
|
4
|
-
import { a as createUnplugin, c as __ΩCreateUnpluginModuleResolutionFunctionsOptions, d as isUnpluginBuilderVariant, i as __ΩCreateUnpluginResolverOptions, l as createUnpluginModuleResolutionFunctions, n as CreateUnpluginResolverOptions, o as createUnpluginResolver, r as __ΩCreateUnpluginOptions, s as CreateUnpluginModuleResolutionFunctionsOptions, t as CreateUnpluginOptions, u as combineContexts } from "./index-
|
|
1
|
+
import { _t as Context, br as UnpluginOptions$1, kr as API, vr as UnpluginBuilderVariant, yr as UnpluginFactory } from "./config-jcYnkMvq.mjs";
|
|
2
|
+
import "./config-D2cqq84p.mjs";
|
|
3
|
+
import "./index-DP6juTGE.mjs";
|
|
4
|
+
import { a as createUnplugin, c as __ΩCreateUnpluginModuleResolutionFunctionsOptions, d as isUnpluginBuilderVariant, i as __ΩCreateUnpluginResolverOptions, l as createUnpluginModuleResolutionFunctions, n as CreateUnpluginResolverOptions, o as createUnpluginResolver, r as __ΩCreateUnpluginOptions, s as CreateUnpluginModuleResolutionFunctionsOptions, t as CreateUnpluginOptions, u as combineContexts } from "./index-BjLkEvse.mjs";
|
|
5
5
|
import { UnpluginOptions } from "unplugin";
|
|
6
6
|
|
|
7
7
|
//#region src/unplugin.d.ts
|
package/dist/unplugin.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as createUnpluginFactory, c as createUnpluginModuleResolutionFunctions, l as combineContexts, o as createUnplugin, s as createUnpluginResolver, u as isUnpluginBuilderVariant } from "./api-
|
|
1
|
+
import { a as createUnpluginFactory, c as createUnpluginModuleResolutionFunctions, l as combineContexts, o as createUnplugin, s as createUnpluginResolver, u as isUnpluginBuilderVariant } from "./api-C9xtrjcq.mjs";
|
|
2
2
|
import "./tsconfig-B92heKit.mjs";
|
|
3
3
|
import "./plugin-utils-C3HnZJl1.mjs";
|
|
4
4
|
import "./plugin-E5foRD0k.mjs";
|
|
5
5
|
import "./paths-CS8ecCnW.mjs";
|
|
6
6
|
import "./constants-cXxSHhNp.mjs";
|
|
7
7
|
import "./config-D4Fh2gQL.mjs";
|
|
8
|
-
import "./
|
|
9
|
-
import "./
|
|
8
|
+
import "./utils-DoQcX7Sk.mjs";
|
|
9
|
+
import "./virtual-B9imjOqe.mjs";
|
|
10
10
|
|
|
11
11
|
export { combineContexts, createUnplugin, createUnpluginFactory, createUnpluginModuleResolutionFunctions, createUnpluginResolver, isUnpluginBuilderVariant };
|
|
@@ -177,18 +177,51 @@ const extendLog = (logFn, name) => {
|
|
|
177
177
|
|
|
178
178
|
//#endregion
|
|
179
179
|
//#region ../core/src/lib/utilities/file-header.ts
|
|
180
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Generates a file header comment with a warning about automatic overwriting.
|
|
182
|
+
*
|
|
183
|
+
* @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.
|
|
184
|
+
* @param framework - The name of the framework to include in the warning message. Defaults to "powerlines".
|
|
185
|
+
* @returns A string containing the file header warning message.
|
|
186
|
+
*/
|
|
187
|
+
function getFileHeaderWarningText(overwrite = true, framework = "powerlines") {
|
|
188
|
+
return overwrite !== false ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.` : `This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${(0, __stryke_string_format_title_case.titleCase)(framework)} while the \`output.overwrite\` option is set to \`true\`.`;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Generates a file header warning message based on the provided context.
|
|
192
|
+
*
|
|
193
|
+
* @param context - The Powerlines context.
|
|
194
|
+
* @returns A string containing the file header warning message.
|
|
195
|
+
*/
|
|
196
|
+
function getFileHeaderWarning(context) {
|
|
197
|
+
return getFileHeaderWarningText(context.config.output?.overwrite, context.config.framework);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Generates a file header comment for a generated source file, including a warning about automatic overwriting.
|
|
201
|
+
*
|
|
202
|
+
* @param context - The Powerlines context.
|
|
203
|
+
* @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.
|
|
204
|
+
* @returns A string containing the file header comment.
|
|
205
|
+
*/
|
|
206
|
+
function getFileHeader(context, comment = "//") {
|
|
181
207
|
return `
|
|
182
|
-
|
|
183
|
-
${
|
|
208
|
+
${comment} Generated by ${(0, __stryke_string_format_title_case.titleCase)(context.config.framework) || "Powerlines"}
|
|
209
|
+
${comment} ${getFileHeaderWarning(context)}
|
|
184
210
|
`;
|
|
185
211
|
}
|
|
186
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.
|
|
214
|
+
*
|
|
215
|
+
* @param context - The Powerlines context.
|
|
216
|
+
* @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.
|
|
217
|
+
* @returns A string containing the file header comment for a TypeScript file.
|
|
218
|
+
*/
|
|
219
|
+
function getTypescriptFileHeader(context, options = {}) {
|
|
187
220
|
const { directive = null, prettierIgnore = false } = options;
|
|
188
221
|
return `/* eslint-disable */
|
|
189
222
|
// biome-ignore lint: disable
|
|
190
223
|
${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
|
|
191
|
-
${
|
|
224
|
+
${getFileHeader(context)}
|
|
192
225
|
|
|
193
226
|
`;
|
|
194
227
|
}
|
|
@@ -324,16 +357,22 @@ Object.defineProperty(exports, 'generateSourceMap', {
|
|
|
324
357
|
return generateSourceMap;
|
|
325
358
|
}
|
|
326
359
|
});
|
|
327
|
-
Object.defineProperty(exports, '
|
|
360
|
+
Object.defineProperty(exports, 'getFileHeader', {
|
|
328
361
|
enumerable: true,
|
|
329
362
|
get: function () {
|
|
330
|
-
return
|
|
363
|
+
return getFileHeader;
|
|
331
364
|
}
|
|
332
365
|
});
|
|
333
|
-
Object.defineProperty(exports, '
|
|
366
|
+
Object.defineProperty(exports, 'getFileHeaderWarning', {
|
|
334
367
|
enumerable: true,
|
|
335
368
|
get: function () {
|
|
336
|
-
return
|
|
369
|
+
return getFileHeaderWarning;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
Object.defineProperty(exports, 'getFileHeaderWarningText', {
|
|
373
|
+
enumerable: true,
|
|
374
|
+
get: function () {
|
|
375
|
+
return getFileHeaderWarningText;
|
|
337
376
|
}
|
|
338
377
|
});
|
|
339
378
|
Object.defineProperty(exports, 'getMagicString', {
|
|
@@ -354,6 +393,12 @@ Object.defineProperty(exports, 'getString', {
|
|
|
354
393
|
return getString;
|
|
355
394
|
}
|
|
356
395
|
});
|
|
396
|
+
Object.defineProperty(exports, 'getTypescriptFileHeader', {
|
|
397
|
+
enumerable: true,
|
|
398
|
+
get: function () {
|
|
399
|
+
return getTypescriptFileHeader;
|
|
400
|
+
}
|
|
401
|
+
});
|
|
357
402
|
Object.defineProperty(exports, 'getUniqueInputs', {
|
|
358
403
|
enumerable: true,
|
|
359
404
|
get: function () {
|
|
@@ -173,18 +173,51 @@ const extendLog = (logFn, name) => {
|
|
|
173
173
|
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region ../core/src/lib/utilities/file-header.ts
|
|
176
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Generates a file header comment with a warning about automatic overwriting.
|
|
178
|
+
*
|
|
179
|
+
* @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.
|
|
180
|
+
* @param framework - The name of the framework to include in the warning message. Defaults to "powerlines".
|
|
181
|
+
* @returns A string containing the file header warning message.
|
|
182
|
+
*/
|
|
183
|
+
function getFileHeaderWarningText(overwrite = true, framework = "powerlines") {
|
|
184
|
+
return overwrite !== false ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.` : `This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${titleCase(framework)} while the \`output.overwrite\` option is set to \`true\`.`;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Generates a file header warning message based on the provided context.
|
|
188
|
+
*
|
|
189
|
+
* @param context - The Powerlines context.
|
|
190
|
+
* @returns A string containing the file header warning message.
|
|
191
|
+
*/
|
|
192
|
+
function getFileHeaderWarning(context) {
|
|
193
|
+
return getFileHeaderWarningText(context.config.output?.overwrite, context.config.framework);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Generates a file header comment for a generated source file, including a warning about automatic overwriting.
|
|
197
|
+
*
|
|
198
|
+
* @param context - The Powerlines context.
|
|
199
|
+
* @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.
|
|
200
|
+
* @returns A string containing the file header comment.
|
|
201
|
+
*/
|
|
202
|
+
function getFileHeader(context, comment = "//") {
|
|
177
203
|
return `
|
|
178
|
-
|
|
179
|
-
${
|
|
204
|
+
${comment} Generated by ${titleCase(context.config.framework) || "Powerlines"}
|
|
205
|
+
${comment} ${getFileHeaderWarning(context)}
|
|
180
206
|
`;
|
|
181
207
|
}
|
|
182
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.
|
|
210
|
+
*
|
|
211
|
+
* @param context - The Powerlines context.
|
|
212
|
+
* @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.
|
|
213
|
+
* @returns A string containing the file header comment for a TypeScript file.
|
|
214
|
+
*/
|
|
215
|
+
function getTypescriptFileHeader(context, options = {}) {
|
|
183
216
|
const { directive = null, prettierIgnore = false } = options;
|
|
184
217
|
return `/* eslint-disable */
|
|
185
218
|
// biome-ignore lint: disable
|
|
186
219
|
${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
|
|
187
|
-
${
|
|
220
|
+
${getFileHeader(context)}
|
|
188
221
|
|
|
189
222
|
`;
|
|
190
223
|
}
|
|
@@ -302,5 +335,5 @@ async function writeFile$1(log, filepath, content, skipFormat = false) {
|
|
|
302
335
|
}
|
|
303
336
|
|
|
304
337
|
//#endregion
|
|
305
|
-
export { getString as a,
|
|
306
|
-
//# sourceMappingURL=utils-
|
|
338
|
+
export { resolveInputs as _, getString as a, getFileHeaderWarningText as c, extendLog as d, getUniqueInputs as f, resolveInput as g, resolveEntryOutput as h, getSourceFile as i, getTypescriptFileHeader as l, isTypeDefinition as m, generateSourceMap as n, getFileHeader as o, isResolvedEntryTypeDefinition as p, getMagicString as r, getFileHeaderWarning as s, writeFile$1 as t, createLog as u, resolveInputsSync as v };
|
|
339
|
+
//# sourceMappingURL=utils-DoQcX7Sk.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-RU0EjpzP.mjs","names":["typeDefinition: TypeDefinition","writeFile","writeFileBase"],"sources":["../../core/src/lib/entry.ts","../../core/src/lib/logger.ts","../../core/src/lib/utilities/file-header.ts","../../core/src/lib/utilities/source-file.ts","../../core/src/lib/utilities/source-map.ts","../../core/src/lib/utilities/write-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 { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash\";\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 { 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 resolveInput(\n context: Context,\n typeDefinition: TypeDefinition,\n input?: TypeDefinitionParameter,\n output?: string\n): ResolvedEntryTypeDefinition {\n return {\n ...typeDefinition,\n input: isSetString(input) ? { file: String(input) } : 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 resolveInputs(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): Promise<ResolvedEntryTypeDefinition[]> {\n return (\n await Promise.all(\n (isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(async 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 {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(\n context,\n typeDefinition.file\n );\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 resolveInput(\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 resolveInput(\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 .flat()\n .filter(Boolean)\n )\n ).flat();\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 resolveInputsSync(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): ResolvedEntryTypeDefinition[] {\n return (\n isObject(typeDefinitions) && !isTypeDefinition(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 {\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 resolveInput(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 resolveInput(context, {\n file,\n name: typeDefinition.name\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(entry: any): 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\n): entry is ResolvedEntryTypeDefinition {\n return (\n isTypeDefinition(entry) &&\n (entry as ResolvedEntryTypeDefinition).output !== undefined\n );\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","/* -------------------------------------------------------------------\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","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { Context } from \"../../types/context\";\n\nexport interface FileHeaderOptions {\n directive?: string | null;\n prettierIgnore?: boolean;\n}\n\nexport function getBaseFileHeader(context: Context): string {\n return `\n// Generated by ${titleCase(context.config.framework) || \"Powerlines\"}\n${\n context.config.output?.overwrite !== false\n ? `// Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \\`output.overwrite\\` option.`\n : `// This file was generated on ${new Date().toLocaleString()} - it will not be overwritten by ${titleCase(context.config.framework)} while the \\`output.overwrite\\` option is set to \\`true\\`.`\n}\n`;\n}\n\nexport function getFileHeader(\n context: Context,\n options: FileHeaderOptions = {}\n): string {\n const { directive = null, prettierIgnore = false } = options;\n\n return `/* eslint-disable */\n// biome-ignore lint: disable\n${prettierIgnore ? `// prettier-ignore` : \"\"}${directive ? `\\n\\n${directive}\\n` : \"\\n\"}\n${getBaseFileHeader(context)}\n\n`;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { 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","/* -------------------------------------------------------------------\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 Diff from \"diff-match-patch\";\nimport type MagicString from \"magic-string\";\nimport type { TransformResult } from \"../../types/context\";\n\nconst dmp = new Diff();\n\n/**\n * Generate code with source map.\n *\n * @param code - The source code.\n * @param id - The file name.\n * @param transpiled - The transpiled code.\n * @returns The compiler result.\n */\nexport function generateSourceMap(\n code: MagicString,\n id: string,\n transpiled?: string\n): TransformResult | undefined {\n if (!transpiled) {\n return;\n }\n\n const diff = dmp.diff_main(code.toString(), transpiled);\n dmp.diff_cleanupSemantic(diff);\n\n let offset = 0;\n\n for (let index = 0; index < diff.length; index++) {\n if (diff[index]) {\n const [type, text] = diff[index]!;\n const textLength = text.length;\n\n switch (type) {\n case 0: {\n offset += textLength;\n break;\n }\n case 1: {\n code.prependLeft(offset, text);\n break;\n }\n case -1: {\n const next = diff.at(index + 1);\n\n if (next && next[0] === 1) {\n const replaceText = next[1];\n\n const firstNonWhitespaceIndexOfText = text.search(/\\S/);\n const offsetStart =\n offset + Math.max(firstNonWhitespaceIndexOfText, 0);\n\n code.update(offsetStart, offset + textLength, replaceText);\n index += 1;\n } else {\n code.remove(offset, offset + textLength);\n }\n\n offset += textLength;\n\n break;\n }\n }\n }\n }\n\n if (!code.hasChanged()) {\n return;\n }\n\n return {\n code: code.toString(),\n map: code.generateMap({\n source: id,\n file: `${id}.map`,\n includeContent: true\n })\n };\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { writeFile as writeFileBase } from \"@stryke/fs/write-file\";\nimport { format, resolveConfig } from \"prettier\";\nimport type { LogFn } from \"../../types/config\";\n\n/**\n * Writes and formats a file to the file system\n *\n * @param log - The logging function to use for logging errors\n * @param filepath - The file path to write the file\n * @param content - The content to write to the file\n * @param skipFormat - Should the plugin skip formatting the `content` string with Prettier\n */\nexport async function writeFile(\n log: LogFn,\n filepath: string,\n content: string,\n skipFormat = false\n) {\n try {\n if (skipFormat) {\n await writeFileBase(filepath, content);\n } else {\n const config = await resolveConfig(filepath);\n const formatted = await format(content, {\n ...(config ?? {}),\n filepath\n });\n\n await writeFileBase(filepath, formatted || \"\");\n }\n } catch (error) {\n log(\n LogLevelLabel.ERROR,\n `Failed to write file ${filepath} to disk \\n${(error as Error)?.message ? (error as Error).message : \"\"}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,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;;AAGH,SAAgB,aACd,SACA,gBACA,OACA,QAC6B;AAC7B,QAAO;EACL,GAAG;EACH,OAAO,YAAY,MAAM,GAAG,EAAE,MAAM,OAAO,MAAM,EAAE,GAAG;EACtD,QAAQ,UAAU,mBAAmB,SAAS,eAAe;EAC9D;;;;;;;;;AAUH,eAAsB,cACpB,SACA,iBAIwC;AACxC,SACE,MAAM,QAAQ,KACX,SAAS,gBAAgB,IAAI,CAAC,iBAAiB,gBAAgB,GAC5D,OAAO,OAAO,gBAAgB,CAAC,MAAM,GACrC,QAAQ,gBAAgB,EAEzB,IAAI,OAAM,UAAS;AAClB,MAAI,8BAA8B,MAAM,CACtC,QAAO;GACL,GAAG;GACH,QAAQ,MAAM,SACV,kBAAkB,SAAS,MAAM,OAAO,GACxC;GACJ,MAAM,kBAAkB,SAAS,MAAM,KAAK;GAC7C;EAGH,IAAIA;AACJ,MAAI,SAAS,MAAM,CACjB,kBAAiB,oBACf,kBAAkB,SAAS,MAAM,CAClC;OACI;AACL,oBAAiB;AACjB,kBAAe,OAAO,kBACpB,SACA,eAAe,KAChB;;EAGH,MAAM,WAAW,eAAe,eA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ACvD,KAAI,qBAAqB,KAAK;CAE9B,IAAI,SAAS;AAEb,MAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,QACvC,KAAI,KAAK,QAAQ;EACf,MAAM,CAAC,MAAM,QAAQ,KAAK;EAC1B,MAAM,aAAa,KAAK;AAExB,UAAQ,MAAR;GACE,KAAK;AACH,cAAU;AACV;GAEF,KAAK;AACH,SAAK,YAAY,QAAQ,KAAK;AAC9B;GAEF,KAAK,IAAI;IACP,MAAM,OAAO,KAAK,GAAG,QAAQ,EAAE;AAE/B,QAAI,QAAQ,KAAK,OAAO,GAAG;KACzB,MAAM,cAAc,KAAK;KAEzB,MAAM,gCAAgC,KAAK,OAAO,KAAK;KACvD,MAAM,cACJ,SAAS,KAAK,IAAI,+BAA+B,EAAE;AAErD,UAAK,OAAO,aAAa,SAAS,YAAY,YAAY;AAC1D,cAAS;UAET,MAAK,OAAO,QAAQ,SAAS,WAAW;AAG1C,cAAU;AAEV;;;;AAMR,KAAI,CAAC,KAAK,YAAY,CACpB;AAGF,QAAO;EACL,MAAM,KAAK,UAAU;EACrB,KAAK,KAAK,YAAY;GACpB,QAAQ;GACR,MAAM,GAAG,GAAG;GACZ,gBAAgB;GACjB,CAAC;EACH;;;;;;;;;;;;;AChEH,eAAsBC,YACpB,KACA,UACA,SACA,aAAa,OACb;AACA,KAAI;AACF,MAAI,WACF,OAAMC,UAAc,UAAU,QAAQ;MAQtC,OAAMA,UAAc,UALF,MAAM,OAAO,SAAS;GACtC,GAFa,MAAM,cAAc,SAAS,IAE5B,EAAE;GAChB;GACD,CAAC,IAEyC,GAAG;UAEzC,OAAO;AACd,MACE,cAAc,OACd,wBAAwB,SAAS,aAAc,OAAiB,UAAW,MAAgB,UAAU,KACtG"}
|
|
1
|
+
{"version":3,"file":"utils-DoQcX7Sk.mjs","names":["typeDefinition: TypeDefinition","writeFile","writeFileBase"],"sources":["../../core/src/lib/entry.ts","../../core/src/lib/logger.ts","../../core/src/lib/utilities/file-header.ts","../../core/src/lib/utilities/source-file.ts","../../core/src/lib/utilities/source-map.ts","../../core/src/lib/utilities/write-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 { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash\";\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 { 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 resolveInput(\n context: Context,\n typeDefinition: TypeDefinition,\n input?: TypeDefinitionParameter,\n output?: string\n): ResolvedEntryTypeDefinition {\n return {\n ...typeDefinition,\n input: isSetString(input) ? { file: String(input) } : 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 resolveInputs(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): Promise<ResolvedEntryTypeDefinition[]> {\n return (\n await Promise.all(\n (isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(async 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 {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(\n context,\n typeDefinition.file\n );\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 resolveInput(\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 resolveInput(\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 .flat()\n .filter(Boolean)\n )\n ).flat();\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 resolveInputsSync(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): ResolvedEntryTypeDefinition[] {\n return (\n isObject(typeDefinitions) && !isTypeDefinition(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 {\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 resolveInput(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 resolveInput(context, {\n file,\n name: typeDefinition.name\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(entry: any): 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\n): entry is ResolvedEntryTypeDefinition {\n return (\n isTypeDefinition(entry) &&\n (entry as ResolvedEntryTypeDefinition).output !== undefined\n );\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","/* -------------------------------------------------------------------\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","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { Context } from \"../../types/context\";\n\nexport interface FileHeaderOptions {\n directive?: string | null;\n prettierIgnore?: boolean;\n}\n\n/**\n * Generates a file header comment with a warning about automatic overwriting.\n *\n * @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.\n * @param framework - The name of the framework to include in the warning message. Defaults to \"powerlines\".\n * @returns A string containing the file header warning message.\n */\nexport function getFileHeaderWarningText(\n overwrite = true,\n framework = \"powerlines\"\n): string {\n return overwrite !== false\n ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \\`output.overwrite\\` option.`\n : `This file was generated on ${new Date().toLocaleString()} - it will not be overwritten by ${titleCase(framework)} while the \\`output.overwrite\\` option is set to \\`true\\`.`;\n}\n\n/**\n * Generates a file header warning message based on the provided context.\n *\n * @param context - The Powerlines context.\n * @returns A string containing the file header warning message.\n */\nexport function getFileHeaderWarning(context: Context): string {\n return getFileHeaderWarningText(\n context.config.output?.overwrite,\n context.config.framework\n );\n}\n\n/**\n * Generates a file header comment for a generated source file, including a warning about automatic overwriting.\n *\n * @param context - The Powerlines context.\n * @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.\n * @returns A string containing the file header comment.\n */\nexport function getFileHeader(context: Context, comment = \"//\"): string {\n return `\n${comment} Generated by ${titleCase(context.config.framework) || \"Powerlines\"}\n${comment} ${getFileHeaderWarning(context)}\n`;\n}\n\n/**\n * Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.\n *\n * @param context - The Powerlines context.\n * @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.\n * @returns A string containing the file header comment for a TypeScript file.\n */\nexport function getTypescriptFileHeader(\n context: Context,\n options: FileHeaderOptions = {}\n): string {\n const { directive = null, prettierIgnore = false } = options;\n\n return `/* eslint-disable */\n// biome-ignore lint: disable\n${prettierIgnore ? `// prettier-ignore` : \"\"}${directive ? `\\n\\n${directive}\\n` : \"\\n\"}\n${getFileHeader(context)}\n\n`;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { 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","/* -------------------------------------------------------------------\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 Diff from \"diff-match-patch\";\nimport type MagicString from \"magic-string\";\nimport type { TransformResult } from \"../../types/context\";\n\nconst dmp = new Diff();\n\n/**\n * Generate code with source map.\n *\n * @param code - The source code.\n * @param id - The file name.\n * @param transpiled - The transpiled code.\n * @returns The compiler result.\n */\nexport function generateSourceMap(\n code: MagicString,\n id: string,\n transpiled?: string\n): TransformResult | undefined {\n if (!transpiled) {\n return;\n }\n\n const diff = dmp.diff_main(code.toString(), transpiled);\n dmp.diff_cleanupSemantic(diff);\n\n let offset = 0;\n\n for (let index = 0; index < diff.length; index++) {\n if (diff[index]) {\n const [type, text] = diff[index]!;\n const textLength = text.length;\n\n switch (type) {\n case 0: {\n offset += textLength;\n break;\n }\n case 1: {\n code.prependLeft(offset, text);\n break;\n }\n case -1: {\n const next = diff.at(index + 1);\n\n if (next && next[0] === 1) {\n const replaceText = next[1];\n\n const firstNonWhitespaceIndexOfText = text.search(/\\S/);\n const offsetStart =\n offset + Math.max(firstNonWhitespaceIndexOfText, 0);\n\n code.update(offsetStart, offset + textLength, replaceText);\n index += 1;\n } else {\n code.remove(offset, offset + textLength);\n }\n\n offset += textLength;\n\n break;\n }\n }\n }\n }\n\n if (!code.hasChanged()) {\n return;\n }\n\n return {\n code: code.toString(),\n map: code.generateMap({\n source: id,\n file: `${id}.map`,\n includeContent: true\n })\n };\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { writeFile as writeFileBase } from \"@stryke/fs/write-file\";\nimport { format, resolveConfig } from \"prettier\";\nimport type { LogFn } from \"../../types/config\";\n\n/**\n * Writes and formats a file to the file system\n *\n * @param log - The logging function to use for logging errors\n * @param filepath - The file path to write the file\n * @param content - The content to write to the file\n * @param skipFormat - Should the plugin skip formatting the `content` string with Prettier\n */\nexport async function writeFile(\n log: LogFn,\n filepath: string,\n content: string,\n skipFormat = false\n) {\n try {\n if (skipFormat) {\n await writeFileBase(filepath, content);\n } else {\n const config = await resolveConfig(filepath);\n const formatted = await format(content, {\n ...(config ?? {}),\n filepath\n });\n\n await writeFileBase(filepath, formatted || \"\");\n }\n } catch (error) {\n log(\n LogLevelLabel.ERROR,\n `Failed to write file ${filepath} to disk \\n${(error as Error)?.message ? (error as Error).message : \"\"}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,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;;AAGH,SAAgB,aACd,SACA,gBACA,OACA,QAC6B;AAC7B,QAAO;EACL,GAAG;EACH,OAAO,YAAY,MAAM,GAAG,EAAE,MAAM,OAAO,MAAM,EAAE,GAAG;EACtD,QAAQ,UAAU,mBAAmB,SAAS,eAAe;EAC9D;;;;;;;;;AAUH,eAAsB,c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AY;AAC1D,cAAS;UAET,MAAK,OAAO,QAAQ,SAAS,WAAW;AAG1C,cAAU;AAEV;;;;AAMR,KAAI,CAAC,KAAK,YAAY,CACpB;AAGF,QAAO;EACL,MAAM,KAAK,UAAU;EACrB,KAAK,KAAK,YAAY;GACpB,QAAQ;GACR,MAAM,GAAG,GAAG;GACZ,gBAAgB;GACjB,CAAC;EACH;;;;;;;;;;;;;AChEH,eAAsBC,YACpB,KACA,UACA,SACA,aAAa,OACb;AACA,KAAI;AACF,MAAI,WACF,OAAMC,UAAc,UAAU,QAAQ;MAQtC,OAAMA,UAAc,UALF,MAAM,OAAO,SAAS;GACtC,GAFa,MAAM,cAAc,SAAS,IAE5B,EAAE;GAChB;GACD,CAAC,IAEyC,GAAG;UAEzC,OAAO;AACd,MACE,cAAc,OACd,wBAAwB,SAAS,aAAc,OAAiB,UAAW,MAAgB,UAAU,KACtG"}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
const require_paths = require('./paths-YmyIGEVo.cjs');
|
|
2
|
-
const require_utils = require('./utils-
|
|
2
|
+
const require_utils = require('./utils-BbDma_5Y.cjs');
|
|
3
3
|
|
|
4
4
|
exports.createLog = require_utils.createLog;
|
|
5
5
|
exports.extendLog = require_utils.extendLog;
|
|
6
6
|
exports.format = require_paths.format;
|
|
7
7
|
exports.formatFolder = require_paths.formatFolder;
|
|
8
8
|
exports.generateSourceMap = require_utils.generateSourceMap;
|
|
9
|
-
exports.getBaseFileHeader = require_utils.getBaseFileHeader;
|
|
10
9
|
exports.getFileHeader = require_utils.getFileHeader;
|
|
10
|
+
exports.getFileHeaderWarning = require_utils.getFileHeaderWarning;
|
|
11
|
+
exports.getFileHeaderWarningText = require_utils.getFileHeaderWarningText;
|
|
11
12
|
exports.getMagicString = require_utils.getMagicString;
|
|
12
13
|
exports.getSourceFile = require_utils.getSourceFile;
|
|
13
14
|
exports.getString = require_utils.getString;
|
|
15
|
+
exports.getTypescriptFileHeader = require_utils.getTypescriptFileHeader;
|
|
14
16
|
exports.getUniqueInputs = require_utils.getUniqueInputs;
|
|
15
17
|
exports.isResolvedEntryTypeDefinition = require_utils.isResolvedEntryTypeDefinition;
|
|
16
18
|
exports.isTypeDefinition = require_utils.isTypeDefinition;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
export { CreateLogOptions, FileHeaderOptions, __ΩCreateLogOptions, __ΩFileHeaderOptions, createLog, extendLog, format, formatFolder, generateSourceMap,
|
|
1
|
+
import { C as resolveInputs, S as resolveInput, _ as extendLog, a as getString, b as isTypeDefinition, c as FileHeaderOptions, d as getFileHeaderWarning, f as getFileHeaderWarningText, g as createLog, h as __ΩCreateLogOptions, i as getSourceFile, l as __ΩFileHeaderOptions, m as CreateLogOptions, n as generateSourceMap, o as format, p as getTypescriptFileHeader, r as getMagicString, s as formatFolder, t as writeFile, u as getFileHeader, v as getUniqueInputs, w as resolveInputsSync, x as resolveEntryOutput, y as isResolvedEntryTypeDefinition } from "./write-file-DKA8GehT.cjs";
|
|
2
|
+
export { CreateLogOptions, FileHeaderOptions, __ΩCreateLogOptions, __ΩFileHeaderOptions, createLog, extendLog, format, formatFolder, generateSourceMap, getFileHeader, getFileHeaderWarning, getFileHeaderWarningText, getMagicString, getSourceFile, getString, getTypescriptFileHeader, getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, writeFile };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./config-
|
|
2
|
-
import { S as
|
|
3
|
-
export { CreateLogOptions, FileHeaderOptions, __ΩCreateLogOptions, __ΩFileHeaderOptions, createLog, extendLog, format, formatFolder, generateSourceMap,
|
|
1
|
+
import "./config-jcYnkMvq.mjs";
|
|
2
|
+
import { C as resolveInputs, S as resolveInput, _ as extendLog, a as getString, b as isTypeDefinition, c as FileHeaderOptions, d as getFileHeaderWarning, f as getFileHeaderWarningText, g as createLog, h as __ΩCreateLogOptions, i as getSourceFile, l as __ΩFileHeaderOptions, m as CreateLogOptions, n as generateSourceMap, o as format, p as getTypescriptFileHeader, r as getMagicString, s as formatFolder, t as writeFile, u as getFileHeader, v as getUniqueInputs, w as resolveInputsSync, x as resolveEntryOutput, y as isResolvedEntryTypeDefinition } from "./index-DP6juTGE.mjs";
|
|
3
|
+
export { CreateLogOptions, FileHeaderOptions, __ΩCreateLogOptions, __ΩFileHeaderOptions, createLog, extendLog, format, formatFolder, generateSourceMap, getFileHeader, getFileHeaderWarning, getFileHeaderWarningText, getMagicString, getSourceFile, getString, getTypescriptFileHeader, getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, writeFile };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { n as format, r as formatFolder } from "./paths-CS8ecCnW.mjs";
|
|
2
|
-
import { a as getString, c as
|
|
2
|
+
import { _ as resolveInputs, a as getString, c as getFileHeaderWarningText, d as extendLog, f as getUniqueInputs, g as resolveInput, h as resolveEntryOutput, i as getSourceFile, l as getTypescriptFileHeader, m as isTypeDefinition, n as generateSourceMap, o as getFileHeader, p as isResolvedEntryTypeDefinition, r as getMagicString, s as getFileHeaderWarning, t as writeFile, u as createLog, v as resolveInputsSync } from "./utils-DoQcX7Sk.mjs";
|
|
3
3
|
|
|
4
|
-
export { createLog, extendLog, format, formatFolder, generateSourceMap,
|
|
4
|
+
export { createLog, extendLog, format, formatFolder, generateSourceMap, getFileHeader, getFileHeaderWarning, getFileHeaderWarningText, getMagicString, getSourceFile, getString, getTypescriptFileHeader, getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, writeFile };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_utils = require('./utils-BbDma_5Y.cjs');
|
|
2
3
|
let __stryke_fs_helpers = require("@stryke/fs/helpers");
|
|
3
4
|
let __stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
4
5
|
let __stryke_path_append = require("@stryke/path/append");
|
|
5
6
|
let __stryke_type_checks_is_error = require("@stryke/type-checks/is-error");
|
|
7
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
6
8
|
let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
7
9
|
let __stryke_path_join = require("@stryke/path/join");
|
|
8
10
|
let node_fs = require("node:fs");
|
|
@@ -320,7 +322,10 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
|
|
|
320
322
|
* @param value - The value to set.
|
|
321
323
|
*/
|
|
322
324
|
setSync(key, value) {
|
|
323
|
-
if (!this.isReadOnly
|
|
325
|
+
if (!this.isReadOnly) if (this.existsSync(this.resolve(key)) && !this.overwrite) {
|
|
326
|
+
const existingValue = this.getSync(this.resolve(key));
|
|
327
|
+
if ((0, __stryke_type_checks_is_set_string.isSetString)(existingValue) && existingValue.includes(require_utils.getFileHeaderWarningText(true, this.context.config.framework))) return (0, __stryke_fs_write_file.writeFileSync)(this.resolve(key), existingValue.replace(require_utils.getFileHeaderWarningText(true, this.context.config.framework), require_utils.getFileHeaderWarningText(false, this.context.config.framework)));
|
|
328
|
+
} else return (0, __stryke_fs_write_file.writeFileSync)(this.resolve(key), value);
|
|
324
329
|
}
|
|
325
330
|
/**
|
|
326
331
|
* Asynchronously sets the value for a given key.
|
|
@@ -329,7 +334,10 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
|
|
|
329
334
|
* @param value - The value to set.
|
|
330
335
|
*/
|
|
331
336
|
async set(key, value) {
|
|
332
|
-
if (!this.isReadOnly
|
|
337
|
+
if (!this.isReadOnly) if (this.existsSync(this.resolve(key)) && !this.overwrite) {
|
|
338
|
+
const existingValue = await this.get(this.resolve(key));
|
|
339
|
+
if ((0, __stryke_type_checks_is_set_string.isSetString)(existingValue) && existingValue.includes(require_utils.getFileHeaderWarningText(true, this.context.config.framework))) return (0, __stryke_fs_write_file.writeFile)(this.resolve(key), existingValue.replace(require_utils.getFileHeaderWarningText(true, this.context.config.framework), require_utils.getFileHeaderWarningText(false, this.context.config.framework)));
|
|
340
|
+
} else return (0, __stryke_fs_write_file.writeFile)(this.resolve(key), value);
|
|
333
341
|
}
|
|
334
342
|
/**
|
|
335
343
|
* Synchronously removes a key from the storage.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { c as getFileHeaderWarningText } from "./utils-DoQcX7Sk.mjs";
|
|
1
2
|
import { createDirectory, createDirectorySync } from "@stryke/fs/helpers";
|
|
2
3
|
import { listFiles, listFilesSync } from "@stryke/fs/list-files";
|
|
3
4
|
import { appendPath } from "@stryke/path/append";
|
|
4
5
|
import { isError } from "@stryke/type-checks/is-error";
|
|
6
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
5
7
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
6
8
|
import { joinPaths } from "@stryke/path/join";
|
|
7
9
|
import { unlinkSync } from "node:fs";
|
|
@@ -319,7 +321,10 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
|
|
|
319
321
|
* @param value - The value to set.
|
|
320
322
|
*/
|
|
321
323
|
setSync(key, value) {
|
|
322
|
-
if (!this.isReadOnly
|
|
324
|
+
if (!this.isReadOnly) if (this.existsSync(this.resolve(key)) && !this.overwrite) {
|
|
325
|
+
const existingValue = this.getSync(this.resolve(key));
|
|
326
|
+
if (isSetString(existingValue) && existingValue.includes(getFileHeaderWarningText(true, this.context.config.framework))) return writeFileSync(this.resolve(key), existingValue.replace(getFileHeaderWarningText(true, this.context.config.framework), getFileHeaderWarningText(false, this.context.config.framework)));
|
|
327
|
+
} else return writeFileSync(this.resolve(key), value);
|
|
323
328
|
}
|
|
324
329
|
/**
|
|
325
330
|
* Asynchronously sets the value for a given key.
|
|
@@ -328,7 +333,10 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
|
|
|
328
333
|
* @param value - The value to set.
|
|
329
334
|
*/
|
|
330
335
|
async set(key, value) {
|
|
331
|
-
if (!this.isReadOnly
|
|
336
|
+
if (!this.isReadOnly) if (this.existsSync(this.resolve(key)) && !this.overwrite) {
|
|
337
|
+
const existingValue = await this.get(this.resolve(key));
|
|
338
|
+
if (isSetString(existingValue) && existingValue.includes(getFileHeaderWarningText(true, this.context.config.framework))) return writeFile(this.resolve(key), existingValue.replace(getFileHeaderWarningText(true, this.context.config.framework), getFileHeaderWarningText(false, this.context.config.framework)));
|
|
339
|
+
} else return writeFile(this.resolve(key), value);
|
|
332
340
|
}
|
|
333
341
|
/**
|
|
334
342
|
* Synchronously removes a key from the storage.
|
|
@@ -502,4 +510,4 @@ var VirtualStorageAdapter = class extends BaseStorageAdapter {
|
|
|
502
510
|
|
|
503
511
|
//#endregion
|
|
504
512
|
export { isFileError as a, ignoreNotfound as i, FileSystemStorageAdapter as n, BaseStorageAdapter as o, ignoreExists as r, VirtualStorageAdapter as t };
|
|
505
|
-
//# sourceMappingURL=virtual-
|
|
513
|
+
//# sourceMappingURL=virtual-B9imjOqe.mjs.map
|