@powerlines/core 0.48.55 → 0.48.56
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.
|
@@ -21,7 +21,7 @@ declare const LogCategories: {
|
|
|
21
21
|
readonly BABEL: "babel";
|
|
22
22
|
readonly COMMUNICATION: "communication";
|
|
23
23
|
};
|
|
24
|
-
declare const LOG_CATEGORIES_ARRAY: ("
|
|
24
|
+
declare const LOG_CATEGORIES_ARRAY: ("config" | "fs" | "plugins" | "general" | "performance" | "hooks" | "schema" | "env" | "rpc" | "babel" | "communication")[];
|
|
25
25
|
declare const LOG_CATEGORIES: readonly ["general", "fs", "performance", "config", "plugins", "hooks", "schema", "env", "rpc", "communication", "babel"];
|
|
26
26
|
declare const DEFAULT_DEVELOPMENT_LOG_LEVEL: {
|
|
27
27
|
readonly general: "debug";
|
|
@@ -21,7 +21,7 @@ declare const LogCategories: {
|
|
|
21
21
|
readonly BABEL: "babel";
|
|
22
22
|
readonly COMMUNICATION: "communication";
|
|
23
23
|
};
|
|
24
|
-
declare const LOG_CATEGORIES_ARRAY: ("
|
|
24
|
+
declare const LOG_CATEGORIES_ARRAY: ("config" | "fs" | "plugins" | "general" | "performance" | "hooks" | "schema" | "env" | "rpc" | "babel" | "communication")[];
|
|
25
25
|
declare const LOG_CATEGORIES: readonly ["general", "fs", "performance", "config", "plugins", "hooks", "schema", "env", "rpc", "communication", "babel"];
|
|
26
26
|
declare const DEFAULT_DEVELOPMENT_LOG_LEVEL: {
|
|
27
27
|
readonly general: "debug";
|
|
@@ -31,8 +31,8 @@ async function format(context, path, data, force = false) {
|
|
|
31
31
|
} catch {}
|
|
32
32
|
resolvedConfig ??= _storm_software_prettier.default;
|
|
33
33
|
if (resolvedConfig) code = await (0, prettier.format)(data, (0, defu.defu)({
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
...resolvedConfig,
|
|
35
|
+
filepath: path
|
|
36
36
|
}, (0, _stryke_path_file_path_fns.findFileExtension)(path) === "ts" || (0, _stryke_path_file_path_fns.findFileExtension)(path) === "tsx" ? { plugins: [prettier_plugin_organize_imports.default] } : {}));
|
|
37
37
|
} catch (error) {
|
|
38
38
|
throw new Error(`Failed to format file at ${path} with Prettier: ${error.message}`, { cause: error });
|
|
@@ -27,8 +27,8 @@ async function format(context, path, data, force = false) {
|
|
|
27
27
|
} catch {}
|
|
28
28
|
resolvedConfig ??= prettierConfig;
|
|
29
29
|
if (resolvedConfig) code = await format$1(data, defu$1({
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
...resolvedConfig,
|
|
31
|
+
filepath: path
|
|
32
32
|
}, findFileExtension(path) === "ts" || findFileExtension(path) === "tsx" ? { plugins: [importsPlugin] } : {}));
|
|
33
33
|
} catch (error) {
|
|
34
34
|
throw new Error(`Failed to format file at ${path} with Prettier: ${error.message}`, { cause: error });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","names":["prettier","defu"],"sources":["../../../src/lib/utilities/format.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 prettierConfig from \"@storm-software/prettier\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileExtension } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { defu } from \"defu\";\nimport { Options, format as prettier, resolveConfig } from \"prettier\";\nimport importsPlugin from \"prettier-plugin-organize-imports\";\nimport { Context } from \"../../types/context\";\n\n/**\n * Formats code using Prettier based on the file path.\n *\n * @param context - The Powerlines context.\n * @param path - The file path to use for resolving Prettier configuration.\n * @param data - The code string to format.\n * @param force - Whether to force formatting even for output/build paths.\n * @returns A promise that resolves to the formatted code string.\n */\nexport async function format(\n context: Context,\n path: string,\n data: string,\n force = false\n): Promise<string> {\n if (\n !force &&\n ((context.config.output.copy &&\n isParentPath(\n path,\n appendPath(context.config.output.copy.path, context.config.cwd)\n )) ||\n isParentPath(\n path,\n appendPath(context.config.output.path, context.config.cwd)\n ))\n ) {\n return data;\n }\n\n let code = data;\n try {\n let resolvedConfig = null as Options | null;\n try {\n resolvedConfig = await resolveConfig(path);\n } catch {\n // If resolving the config fails, we can ignore it and use the default Prettier settings\n }\n\n // If no config was found, we can use the default Prettier settings\n resolvedConfig ??= prettierConfig as Options;\n\n if (resolvedConfig) {\n code = await prettier(\n data,\n defu(\n {\n
|
|
1
|
+
{"version":3,"file":"format.mjs","names":["prettier","defu"],"sources":["../../../src/lib/utilities/format.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 prettierConfig from \"@storm-software/prettier\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileExtension } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { defu } from \"defu\";\nimport { Options, format as prettier, resolveConfig } from \"prettier\";\nimport importsPlugin from \"prettier-plugin-organize-imports\";\nimport { Context } from \"../../types/context\";\n\n/**\n * Formats code using Prettier based on the file path.\n *\n * @param context - The Powerlines context.\n * @param path - The file path to use for resolving Prettier configuration.\n * @param data - The code string to format.\n * @param force - Whether to force formatting even for output/build paths.\n * @returns A promise that resolves to the formatted code string.\n */\nexport async function format(\n context: Context,\n path: string,\n data: string,\n force = false\n): Promise<string> {\n if (\n !force &&\n ((context.config.output.copy &&\n isParentPath(\n path,\n appendPath(context.config.output.copy.path, context.config.cwd)\n )) ||\n isParentPath(\n path,\n appendPath(context.config.output.path, context.config.cwd)\n ))\n ) {\n return data;\n }\n\n let code = data;\n try {\n let resolvedConfig = null as Options | null;\n try {\n resolvedConfig = await resolveConfig(path);\n } catch {\n // If resolving the config fails, we can ignore it and use the default Prettier settings\n }\n\n // If no config was found, we can use the default Prettier settings\n resolvedConfig ??= prettierConfig as Options;\n\n if (resolvedConfig) {\n code = await prettier(\n data,\n defu(\n {\n ...resolvedConfig,\n filepath: path\n },\n findFileExtension(path) === \"ts\" || findFileExtension(path) === \"tsx\"\n ? { plugins: [importsPlugin] }\n : {}\n )\n );\n }\n } catch (error) {\n throw new Error(\n `Failed to format file at ${path} with Prettier: ${\n (error as Error).message\n }`,\n { cause: error }\n );\n }\n\n return code;\n}\n\n/**\n * Formats all files in a folder using Prettier based on their file paths.\n *\n * @param context - The Powerlines context.\n * @param path - The folder path containing files to format.\n * @returns A promise that resolves when all files have been formatted.\n */\nexport async function formatFolder(context: Context, path: string) {\n if (\n !context.config.output.copy ||\n (!isParentPath(\n path,\n appendPath(context.config.output.copy.path, context.config.cwd)\n ) &&\n !isParentPath(\n path,\n appendPath(context.config.output.path, context.config.cwd)\n ))\n ) {\n await Promise.allSettled(\n (await listFiles(path)).map(async file => {\n if (\n (!context.config.output.copy ||\n !isParentPath(\n file,\n appendPath(context.config.output.copy.path, context.config.cwd)\n )) &&\n !isParentPath(\n file,\n appendPath(context.config.output.path, context.config.cwd)\n )\n ) {\n const data = await context.fs.read(file);\n if (data) {\n const formatted = await format(context, file, data);\n\n return context.fs.write(file, formatted);\n }\n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O,GAAG,CAC3D,GACA;GACA,MAAM,OAAO,MAAM,QAAQ,GAAG,KAAK,IAAI;GACvC,IAAI,MAAM;IACR,MAAM,YAAY,MAAM,OAAO,SAAS,MAAM,IAAI;IAElD,OAAO,QAAQ,GAAG,MAAM,MAAM,SAAS;GACzC;EACF;CACF,CAAC,CACH;AAEJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/core",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.56",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "An internal core package for Powerlines - please use the `powerlines` package for public usage.",
|
|
6
6
|
"homepage": "https://stormsoftware.com",
|
|
@@ -378,5 +378,5 @@
|
|
|
378
378
|
"undici-types": "^7.27.2"
|
|
379
379
|
},
|
|
380
380
|
"publishConfig": { "access": "public" },
|
|
381
|
-
"gitHead": "
|
|
381
|
+
"gitHead": "5ef45196d8c43e50c12d7000d1faafd27926cad0"
|
|
382
382
|
}
|