@storm-software/unbuild 0.25.3 → 0.26.1

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/bin/unbuild.cjs CHANGED
@@ -1140,35 +1140,6 @@ var import_path = require("path");
1140
1140
  // ../build-tools/src/utilities/copy-assets.ts
1141
1141
  var import_devkit3 = require("@nx/devkit");
1142
1142
  var import_js = require("@nx/js");
1143
-
1144
- // ../config-tools/src/logger/create-logger.ts
1145
- var import_chalk3 = __toESM(require("chalk"), 1);
1146
- async function createLogger(config) {
1147
- const workspaceRoot = findWorkspaceRoot();
1148
- if (!workspaceRoot) {
1149
- throw new Error("Cannot find workspace root");
1150
- }
1151
- const writeFatal2 = getLogFn(LogLevel.FATAL, config, import_chalk3.default);
1152
- const writeError2 = getLogFn(LogLevel.ERROR, config, import_chalk3.default);
1153
- const writeWarning2 = getLogFn(LogLevel.WARN, config, import_chalk3.default);
1154
- const writeInfo2 = getLogFn(LogLevel.INFO, config, import_chalk3.default);
1155
- const writeSuccess2 = getLogFn(LogLevel.SUCCESS, config, import_chalk3.default);
1156
- const writeDebug2 = getLogFn(LogLevel.DEBUG, config, import_chalk3.default);
1157
- const writeTrace2 = getLogFn(LogLevel.DEBUG, config, import_chalk3.default);
1158
- return {
1159
- fatal: writeFatal2,
1160
- error: writeError2,
1161
- warning: writeWarning2,
1162
- info: writeInfo2,
1163
- success: writeSuccess2,
1164
- debug: writeDebug2,
1165
- trace: writeTrace2,
1166
- getStopwatch
1167
- };
1168
- }
1169
- __name(createLogger, "createLogger");
1170
-
1171
- // ../build-tools/src/utilities/copy-assets.ts
1172
1143
  var import_glob = require("glob");
1173
1144
  var import_promises2 = require("fs/promises");
1174
1145
 
@@ -1415,11 +1386,10 @@ var import_create_task_graph = require("nx/src/tasks-runner/create-task-graph");
1415
1386
 
1416
1387
  // src/build.ts
1417
1388
  var import_defu5 = __toESM(require("defu"), 1);
1418
- var import_jiti3 = require("jiti");
1419
1389
  var import_node_fs8 = require("fs");
1420
1390
  var import_promises7 = require("fs/promises");
1421
1391
  var import_node_path6 = require("path");
1422
- var import_find_workspace_root6 = require("nx/src/utils/find-workspace-root");
1392
+ var import_find_workspace_root5 = require("nx/src/utils/find-workspace-root");
1423
1393
 
1424
1394
  // ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/shared/unbuild.B2_7OVir.mjs
1425
1395
  var import_node_module2 = __toESM(require("module"), 1);
@@ -2899,18 +2869,18 @@ var onErrorPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
2899
2869
  name: "storm:on-error",
2900
2870
  buildEnd(error) {
2901
2871
  if (error) {
2902
- resolvedOptions.logger.error(`The following errors occurred during the build:
2872
+ writeError(`The following errors occurred during the build:
2903
2873
  ${error ? error.message : "Unknown build error"}
2904
2874
 
2905
- `);
2875
+ `, resolvedOptions.config);
2906
2876
  throw new Error("Storm unbuild process failed with errors.");
2907
2877
  }
2908
2878
  },
2909
2879
  renderError(error) {
2910
- resolvedOptions.logger.error(`The following errors occurred during the build:
2880
+ writeError(`The following errors occurred during the build:
2911
2881
  ${error ? error.message : "Unknown build error"}
2912
2882
 
2913
- `);
2883
+ `, resolvedOptions.config);
2914
2884
  throw new Error("Storm unbuild process failed with errors.");
2915
2885
  }
2916
2886
  }), "onErrorPlugin");
@@ -3006,35 +2976,25 @@ var getDefaultBuildPlugins = /* @__PURE__ */ __name(async (options, resolvedOpti
3006
2976
  ].map((plugin) => Promise.resolve(plugin))), "getDefaultBuildPlugins");
3007
2977
 
3008
2978
  // src/build.ts
3009
- async function resolveOptions(options) {
3010
- const projectRoot = options.projectRoot;
3011
- if (!projectRoot) {
3012
- throw new Error("Cannot find project root");
3013
- }
3014
- const outputPath = options.outputPath || joinPaths("dist", projectRoot);
3015
- const workspaceRoot = (0, import_find_workspace_root6.findWorkspaceRoot)(projectRoot);
3016
- if (!workspaceRoot) {
3017
- throw new Error("Cannot find workspace root");
3018
- }
3019
- const config = await loadStormConfig(workspaceRoot.dir);
3020
- const logger = await createLogger(config);
3021
- logger.debug(" \u2699\uFE0F Resolving build options");
3022
- const stopwatch = logger.getStopwatch("Build options resolution");
2979
+ async function resolveOptions(options, config) {
2980
+ writeDebug(" \u2699\uFE0F Resolving build options", config);
2981
+ const stopwatch = getStopwatch("Build options resolution");
3023
2982
  if (options.configPath) {
3024
2983
  const configFile = await loadConfig2(options.configPath);
3025
2984
  if (configFile) {
3026
2985
  options = (0, import_defu5.default)(options, configFile);
3027
2986
  }
3028
2987
  }
2988
+ const outputPath = options.outputPath || joinPaths("dist", options.projectRoot);
3029
2989
  const projectGraph = (0, import_devkit6.readCachedProjectGraph)();
3030
- const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
2990
+ const projectJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "project.json");
3031
2991
  if (!(0, import_node_fs8.existsSync)(projectJsonPath)) {
3032
2992
  throw new Error("Cannot find project.json configuration");
3033
2993
  }
3034
2994
  const projectJsonContent = await (0, import_promises7.readFile)(projectJsonPath, "utf8");
3035
2995
  const projectJson = JSON.parse(projectJsonContent);
3036
2996
  const projectName = projectJson.name;
3037
- const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
2997
+ const packageJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "package.json");
3038
2998
  if (!(0, import_node_fs8.existsSync)(packageJsonPath)) {
3039
2999
  throw new Error("Cannot find package.json configuration");
3040
3000
  }
@@ -3042,51 +3002,45 @@ async function resolveOptions(options) {
3042
3002
  const packageJson = JSON.parse(packageJsonContent);
3043
3003
  let tsconfig = options.tsconfig;
3044
3004
  if (!tsconfig) {
3045
- tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
3005
+ tsconfig = joinPaths(config.workspaceRoot, options.projectRoot, "tsconfig.json");
3046
3006
  }
3047
3007
  if (!(0, import_node_fs8.existsSync)(tsconfig)) {
3048
3008
  throw new Error("Cannot find tsconfig.json configuration");
3049
3009
  }
3050
3010
  let sourceRoot = projectJson.sourceRoot;
3051
3011
  if (!sourceRoot) {
3052
- sourceRoot = joinPaths(projectRoot, "src");
3012
+ sourceRoot = joinPaths(options.projectRoot, "src");
3053
3013
  }
3054
3014
  if (!(0, import_node_fs8.existsSync)(sourceRoot)) {
3055
3015
  throw new Error("Cannot find sourceRoot directory");
3056
3016
  }
3057
- const result = (0, import_buildable_libs_utils4.calculateProjectBuildableDependencies)(void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
3017
+ const result = (0, import_buildable_libs_utils4.calculateProjectBuildableDependencies)(void 0, projectGraph, config.workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
3058
3018
  let dependencies = result.dependencies;
3059
3019
  const tsLibDependency = (0, import_js2.getHelperDependency)(import_js2.HelperDependency.tsc, tsconfig, dependencies, projectGraph, true);
3060
3020
  if (tsLibDependency) {
3061
3021
  dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
3062
3022
  dependencies.push(tsLibDependency);
3063
3023
  }
3064
- const jiti = (0, import_jiti3.createJiti)(config.workspaceRoot, {
3065
- fsCache: config.skipCache ? false : joinPaths(config.directories.cache || "node_modules/.cache/storm", "jiti"),
3066
- interopDefault: true
3067
- });
3068
3024
  const resolvedOptions = {
3069
3025
  name: projectName,
3070
3026
  config,
3071
- projectRoot,
3027
+ projectRoot: options.projectRoot,
3072
3028
  sourceRoot,
3073
3029
  projectName,
3074
3030
  tsconfig,
3075
- jiti,
3076
- logger,
3077
3031
  clean: false,
3078
3032
  entries: [
3079
3033
  {
3080
3034
  builder: "mkdist",
3081
- input: `.${sourceRoot.replace(projectRoot, "")}`,
3082
- outDir: joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
3035
+ input: `.${sourceRoot.replace(options.projectRoot, "")}`,
3036
+ outDir: joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
3083
3037
  declaration: options.emitTypes !== false,
3084
3038
  format: "esm"
3085
3039
  },
3086
3040
  {
3087
3041
  builder: "mkdist",
3088
- input: `.${sourceRoot.replace(projectRoot, "")}`,
3089
- outDir: joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
3042
+ input: `.${sourceRoot.replace(options.projectRoot, "")}`,
3043
+ outDir: joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
3090
3044
  declaration: options.emitTypes !== false,
3091
3045
  format: "cjs",
3092
3046
  ext: "cjs"
@@ -3181,8 +3135,8 @@ async function resolveOptions(options) {
3181
3135
  __name(resolveOptions, "resolveOptions");
3182
3136
  async function generatePackageJson(options) {
3183
3137
  if (options.generatePackageJson !== false && (0, import_node_fs8.existsSync)(joinPaths(options.projectRoot, "package.json"))) {
3184
- options.logger.debug(" \u270D\uFE0F Writing package.json file");
3185
- const stopwatch = options.logger.getStopwatch("Write package.json file");
3138
+ writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
3139
+ const stopwatch = getStopwatch("Write package.json file");
3186
3140
  const packageJsonPath = joinPaths(options.projectRoot, "project.json");
3187
3141
  if (!(0, import_node_fs8.existsSync)(packageJsonPath)) {
3188
3142
  throw new Error("Cannot find package.json configuration");
@@ -3201,11 +3155,12 @@ async function generatePackageJson(options) {
3201
3155
  }
3202
3156
  __name(generatePackageJson, "generatePackageJson");
3203
3157
  async function executeUnbuild(options) {
3204
- options.logger.debug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`);
3205
- const stopwatch = options.logger.getStopwatch(`${options.name} (${options.projectRoot}) build`);
3158
+ writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
3159
+ const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
3206
3160
  try {
3207
3161
  await build(options.projectRoot, false, {
3208
3162
  ...options,
3163
+ config: null,
3209
3164
  rootDir: options.projectRoot
3210
3165
  });
3211
3166
  } finally {
@@ -3215,8 +3170,8 @@ async function executeUnbuild(options) {
3215
3170
  }
3216
3171
  __name(executeUnbuild, "executeUnbuild");
3217
3172
  async function copyBuildAssets(options) {
3218
- options.logger.debug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`);
3219
- const stopwatch = options.logger.getStopwatch(`${options.name} asset copy`);
3173
+ writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
3174
+ const stopwatch = getStopwatch(`${options.name} asset copy`);
3220
3175
  await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.projectName, options.sourceRoot, options.generatePackageJson, options.includeSrc);
3221
3176
  stopwatch();
3222
3177
  return options;
@@ -3224,8 +3179,8 @@ async function copyBuildAssets(options) {
3224
3179
  __name(copyBuildAssets, "copyBuildAssets");
3225
3180
  async function cleanOutputPath(options) {
3226
3181
  if (options.clean !== false && options.outDir) {
3227
- options.logger.debug(` \u{1F9F9} Cleaning ${options.name} output path: ${options.outDir}`);
3228
- const stopwatch = options.logger.getStopwatch(`${options.name} output clean`);
3182
+ writeDebug(` \u{1F9F9} Cleaning ${options.name} output path: ${options.outDir}`, options.config);
3183
+ const stopwatch = getStopwatch(`${options.name} output clean`);
3229
3184
  await cleanDirectories(options.name, options.outDir, options.config);
3230
3185
  stopwatch();
3231
3186
  }
@@ -3233,17 +3188,27 @@ async function cleanOutputPath(options) {
3233
3188
  }
3234
3189
  __name(cleanOutputPath, "cleanOutputPath");
3235
3190
  async function build2(options) {
3236
- const resolvedOptions = await resolveOptions(options);
3237
- resolvedOptions.logger.debug(` \u26A1 Executing Storm Unbuild pipeline`);
3238
- const stopwatch = resolvedOptions.logger.getStopwatch("Unbuild pipeline");
3191
+ const projectRoot = options.projectRoot;
3192
+ if (!projectRoot) {
3193
+ throw new Error("Cannot find project root");
3194
+ }
3195
+ const workspaceRoot = (0, import_find_workspace_root5.findWorkspaceRoot)(projectRoot);
3196
+ if (!workspaceRoot) {
3197
+ throw new Error("Cannot find workspace root");
3198
+ }
3199
+ const config = await loadStormConfig(workspaceRoot.dir);
3200
+ writeDebug(` \u26A1 Executing Storm Unbuild pipeline`, config);
3201
+ const stopwatch = getStopwatch("Unbuild pipeline");
3239
3202
  try {
3203
+ options.projectRoot = projectRoot;
3204
+ const resolvedOptions = await resolveOptions(options, config);
3240
3205
  await cleanOutputPath(resolvedOptions);
3241
3206
  await generatePackageJson(resolvedOptions);
3242
3207
  await executeUnbuild(resolvedOptions);
3243
3208
  await copyBuildAssets(resolvedOptions);
3244
- resolvedOptions.logger.success(` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`);
3209
+ writeSuccess(` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`, config);
3245
3210
  } catch (error) {
3246
- resolvedOptions.logger.fatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
3211
+ writeFatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.", config);
3247
3212
  throw error;
3248
3213
  } finally {
3249
3214
  stopwatch();
package/bin/unbuild.js CHANGED
@@ -1115,35 +1115,6 @@ import { relative } from "path";
1115
1115
  // ../build-tools/src/utilities/copy-assets.ts
1116
1116
  import { readCachedProjectGraph, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
1117
1117
  import { copyAssets as copyAssetsBase } from "@nx/js";
1118
-
1119
- // ../config-tools/src/logger/create-logger.ts
1120
- import chalk2 from "chalk";
1121
- async function createLogger(config) {
1122
- const workspaceRoot = findWorkspaceRoot();
1123
- if (!workspaceRoot) {
1124
- throw new Error("Cannot find workspace root");
1125
- }
1126
- const writeFatal2 = getLogFn(LogLevel.FATAL, config, chalk2);
1127
- const writeError2 = getLogFn(LogLevel.ERROR, config, chalk2);
1128
- const writeWarning2 = getLogFn(LogLevel.WARN, config, chalk2);
1129
- const writeInfo2 = getLogFn(LogLevel.INFO, config, chalk2);
1130
- const writeSuccess2 = getLogFn(LogLevel.SUCCESS, config, chalk2);
1131
- const writeDebug2 = getLogFn(LogLevel.DEBUG, config, chalk2);
1132
- const writeTrace2 = getLogFn(LogLevel.DEBUG, config, chalk2);
1133
- return {
1134
- fatal: writeFatal2,
1135
- error: writeError2,
1136
- warning: writeWarning2,
1137
- info: writeInfo2,
1138
- success: writeSuccess2,
1139
- debug: writeDebug2,
1140
- trace: writeTrace2,
1141
- getStopwatch
1142
- };
1143
- }
1144
- __name(createLogger, "createLogger");
1145
-
1146
- // ../build-tools/src/utilities/copy-assets.ts
1147
1118
  import { glob } from "glob";
1148
1119
  import { readFile as readFile2, writeFile } from "node:fs/promises";
1149
1120
 
@@ -1390,7 +1361,6 @@ import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-r
1390
1361
 
1391
1362
  // src/build.ts
1392
1363
  import defu4 from "defu";
1393
- import { createJiti as createJiti2 } from "jiti";
1394
1364
  import { existsSync as existsSync6 } from "node:fs";
1395
1365
  import { readFile as readFile4 } from "node:fs/promises";
1396
1366
  import { relative as relative4 } from "node:path";
@@ -2874,18 +2844,18 @@ var onErrorPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
2874
2844
  name: "storm:on-error",
2875
2845
  buildEnd(error) {
2876
2846
  if (error) {
2877
- resolvedOptions.logger.error(`The following errors occurred during the build:
2847
+ writeError(`The following errors occurred during the build:
2878
2848
  ${error ? error.message : "Unknown build error"}
2879
2849
 
2880
- `);
2850
+ `, resolvedOptions.config);
2881
2851
  throw new Error("Storm unbuild process failed with errors.");
2882
2852
  }
2883
2853
  },
2884
2854
  renderError(error) {
2885
- resolvedOptions.logger.error(`The following errors occurred during the build:
2855
+ writeError(`The following errors occurred during the build:
2886
2856
  ${error ? error.message : "Unknown build error"}
2887
2857
 
2888
- `);
2858
+ `, resolvedOptions.config);
2889
2859
  throw new Error("Storm unbuild process failed with errors.");
2890
2860
  }
2891
2861
  }), "onErrorPlugin");
@@ -2981,35 +2951,25 @@ var getDefaultBuildPlugins = /* @__PURE__ */ __name(async (options, resolvedOpti
2981
2951
  ].map((plugin) => Promise.resolve(plugin))), "getDefaultBuildPlugins");
2982
2952
 
2983
2953
  // src/build.ts
2984
- async function resolveOptions(options) {
2985
- const projectRoot = options.projectRoot;
2986
- if (!projectRoot) {
2987
- throw new Error("Cannot find project root");
2988
- }
2989
- const outputPath = options.outputPath || joinPaths("dist", projectRoot);
2990
- const workspaceRoot = findWorkspaceRoot2(projectRoot);
2991
- if (!workspaceRoot) {
2992
- throw new Error("Cannot find workspace root");
2993
- }
2994
- const config = await loadStormConfig(workspaceRoot.dir);
2995
- const logger = await createLogger(config);
2996
- logger.debug(" \u2699\uFE0F Resolving build options");
2997
- const stopwatch = logger.getStopwatch("Build options resolution");
2954
+ async function resolveOptions(options, config) {
2955
+ writeDebug(" \u2699\uFE0F Resolving build options", config);
2956
+ const stopwatch = getStopwatch("Build options resolution");
2998
2957
  if (options.configPath) {
2999
2958
  const configFile = await loadConfig2(options.configPath);
3000
2959
  if (configFile) {
3001
2960
  options = defu4(options, configFile);
3002
2961
  }
3003
2962
  }
2963
+ const outputPath = options.outputPath || joinPaths("dist", options.projectRoot);
3004
2964
  const projectGraph = readCachedProjectGraph4();
3005
- const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
2965
+ const projectJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "project.json");
3006
2966
  if (!existsSync6(projectJsonPath)) {
3007
2967
  throw new Error("Cannot find project.json configuration");
3008
2968
  }
3009
2969
  const projectJsonContent = await readFile4(projectJsonPath, "utf8");
3010
2970
  const projectJson = JSON.parse(projectJsonContent);
3011
2971
  const projectName = projectJson.name;
3012
- const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
2972
+ const packageJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "package.json");
3013
2973
  if (!existsSync6(packageJsonPath)) {
3014
2974
  throw new Error("Cannot find package.json configuration");
3015
2975
  }
@@ -3017,51 +2977,45 @@ async function resolveOptions(options) {
3017
2977
  const packageJson = JSON.parse(packageJsonContent);
3018
2978
  let tsconfig = options.tsconfig;
3019
2979
  if (!tsconfig) {
3020
- tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
2980
+ tsconfig = joinPaths(config.workspaceRoot, options.projectRoot, "tsconfig.json");
3021
2981
  }
3022
2982
  if (!existsSync6(tsconfig)) {
3023
2983
  throw new Error("Cannot find tsconfig.json configuration");
3024
2984
  }
3025
2985
  let sourceRoot = projectJson.sourceRoot;
3026
2986
  if (!sourceRoot) {
3027
- sourceRoot = joinPaths(projectRoot, "src");
2987
+ sourceRoot = joinPaths(options.projectRoot, "src");
3028
2988
  }
3029
2989
  if (!existsSync6(sourceRoot)) {
3030
2990
  throw new Error("Cannot find sourceRoot directory");
3031
2991
  }
3032
- const result = calculateProjectBuildableDependencies3(void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
2992
+ const result = calculateProjectBuildableDependencies3(void 0, projectGraph, config.workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
3033
2993
  let dependencies = result.dependencies;
3034
2994
  const tsLibDependency = getHelperDependency2(HelperDependency2.tsc, tsconfig, dependencies, projectGraph, true);
3035
2995
  if (tsLibDependency) {
3036
2996
  dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
3037
2997
  dependencies.push(tsLibDependency);
3038
2998
  }
3039
- const jiti = createJiti2(config.workspaceRoot, {
3040
- fsCache: config.skipCache ? false : joinPaths(config.directories.cache || "node_modules/.cache/storm", "jiti"),
3041
- interopDefault: true
3042
- });
3043
2999
  const resolvedOptions = {
3044
3000
  name: projectName,
3045
3001
  config,
3046
- projectRoot,
3002
+ projectRoot: options.projectRoot,
3047
3003
  sourceRoot,
3048
3004
  projectName,
3049
3005
  tsconfig,
3050
- jiti,
3051
- logger,
3052
3006
  clean: false,
3053
3007
  entries: [
3054
3008
  {
3055
3009
  builder: "mkdist",
3056
- input: `.${sourceRoot.replace(projectRoot, "")}`,
3057
- outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
3010
+ input: `.${sourceRoot.replace(options.projectRoot, "")}`,
3011
+ outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
3058
3012
  declaration: options.emitTypes !== false,
3059
3013
  format: "esm"
3060
3014
  },
3061
3015
  {
3062
3016
  builder: "mkdist",
3063
- input: `.${sourceRoot.replace(projectRoot, "")}`,
3064
- outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
3017
+ input: `.${sourceRoot.replace(options.projectRoot, "")}`,
3018
+ outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
3065
3019
  declaration: options.emitTypes !== false,
3066
3020
  format: "cjs",
3067
3021
  ext: "cjs"
@@ -3156,8 +3110,8 @@ async function resolveOptions(options) {
3156
3110
  __name(resolveOptions, "resolveOptions");
3157
3111
  async function generatePackageJson(options) {
3158
3112
  if (options.generatePackageJson !== false && existsSync6(joinPaths(options.projectRoot, "package.json"))) {
3159
- options.logger.debug(" \u270D\uFE0F Writing package.json file");
3160
- const stopwatch = options.logger.getStopwatch("Write package.json file");
3113
+ writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
3114
+ const stopwatch = getStopwatch("Write package.json file");
3161
3115
  const packageJsonPath = joinPaths(options.projectRoot, "project.json");
3162
3116
  if (!existsSync6(packageJsonPath)) {
3163
3117
  throw new Error("Cannot find package.json configuration");
@@ -3176,11 +3130,12 @@ async function generatePackageJson(options) {
3176
3130
  }
3177
3131
  __name(generatePackageJson, "generatePackageJson");
3178
3132
  async function executeUnbuild(options) {
3179
- options.logger.debug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`);
3180
- const stopwatch = options.logger.getStopwatch(`${options.name} (${options.projectRoot}) build`);
3133
+ writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
3134
+ const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
3181
3135
  try {
3182
3136
  await build(options.projectRoot, false, {
3183
3137
  ...options,
3138
+ config: null,
3184
3139
  rootDir: options.projectRoot
3185
3140
  });
3186
3141
  } finally {
@@ -3190,8 +3145,8 @@ async function executeUnbuild(options) {
3190
3145
  }
3191
3146
  __name(executeUnbuild, "executeUnbuild");
3192
3147
  async function copyBuildAssets(options) {
3193
- options.logger.debug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`);
3194
- const stopwatch = options.logger.getStopwatch(`${options.name} asset copy`);
3148
+ writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
3149
+ const stopwatch = getStopwatch(`${options.name} asset copy`);
3195
3150
  await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.projectName, options.sourceRoot, options.generatePackageJson, options.includeSrc);
3196
3151
  stopwatch();
3197
3152
  return options;
@@ -3199,8 +3154,8 @@ async function copyBuildAssets(options) {
3199
3154
  __name(copyBuildAssets, "copyBuildAssets");
3200
3155
  async function cleanOutputPath(options) {
3201
3156
  if (options.clean !== false && options.outDir) {
3202
- options.logger.debug(` \u{1F9F9} Cleaning ${options.name} output path: ${options.outDir}`);
3203
- const stopwatch = options.logger.getStopwatch(`${options.name} output clean`);
3157
+ writeDebug(` \u{1F9F9} Cleaning ${options.name} output path: ${options.outDir}`, options.config);
3158
+ const stopwatch = getStopwatch(`${options.name} output clean`);
3204
3159
  await cleanDirectories(options.name, options.outDir, options.config);
3205
3160
  stopwatch();
3206
3161
  }
@@ -3208,17 +3163,27 @@ async function cleanOutputPath(options) {
3208
3163
  }
3209
3164
  __name(cleanOutputPath, "cleanOutputPath");
3210
3165
  async function build2(options) {
3211
- const resolvedOptions = await resolveOptions(options);
3212
- resolvedOptions.logger.debug(` \u26A1 Executing Storm Unbuild pipeline`);
3213
- const stopwatch = resolvedOptions.logger.getStopwatch("Unbuild pipeline");
3166
+ const projectRoot = options.projectRoot;
3167
+ if (!projectRoot) {
3168
+ throw new Error("Cannot find project root");
3169
+ }
3170
+ const workspaceRoot = findWorkspaceRoot2(projectRoot);
3171
+ if (!workspaceRoot) {
3172
+ throw new Error("Cannot find workspace root");
3173
+ }
3174
+ const config = await loadStormConfig(workspaceRoot.dir);
3175
+ writeDebug(` \u26A1 Executing Storm Unbuild pipeline`, config);
3176
+ const stopwatch = getStopwatch("Unbuild pipeline");
3214
3177
  try {
3178
+ options.projectRoot = projectRoot;
3179
+ const resolvedOptions = await resolveOptions(options, config);
3215
3180
  await cleanOutputPath(resolvedOptions);
3216
3181
  await generatePackageJson(resolvedOptions);
3217
3182
  await executeUnbuild(resolvedOptions);
3218
3183
  await copyBuildAssets(resolvedOptions);
3219
- resolvedOptions.logger.success(` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`);
3184
+ writeSuccess(` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`, config);
3220
3185
  } catch (error) {
3221
- resolvedOptions.logger.fatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
3186
+ writeFatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.", config);
3222
3187
  throw error;
3223
3188
  } finally {
3224
3189
  stopwatch();
package/dist/build.cjs CHANGED
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkHYDGJLPGcjs = require('./chunk-HYDGJLPG.cjs');
4
- require('./chunk-KUMAH6IZ.cjs');
5
- require('./chunk-ADWBQYE6.cjs');
6
- require('./chunk-LUXNRUAP.cjs');
3
+ var _chunkKA5JSIMFcjs = require('./chunk-KA5JSIMF.cjs');
4
+ require('./chunk-TRA2WJ3W.cjs');
5
+ require('./chunk-HO6B5DC7.cjs');
6
+ require('./chunk-KAXKUEZ7.cjs');
7
7
  require('./chunk-SHHAZOHN.cjs');
8
- require('./chunk-4AWYDOEH.cjs');
9
- require('./chunk-36OA7HRF.cjs');
10
- require('./chunk-D5YXD4XE.cjs');
8
+ require('./chunk-UV35N5R4.cjs');
9
+ require('./chunk-XKHSZIHP.cjs');
10
+ require('./chunk-GHVDJY3S.cjs');
11
11
  require('./chunk-YDYGZTJK.cjs');
12
12
 
13
13
 
14
- exports.build = _chunkHYDGJLPGcjs.build;
14
+ exports.build = _chunkKA5JSIMFcjs.build;
package/dist/build.d.cts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { UnbuildOptions } from './types.cjs';
2
2
  import '@storm-software/build-tools';
3
- import '@storm-software/config-tools/types';
4
- import 'jiti';
5
3
  import 'unbuild';
6
4
 
7
5
  /**
package/dist/build.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { UnbuildOptions } from './types.js';
2
2
  import '@storm-software/build-tools';
3
- import '@storm-software/config-tools/types';
4
- import 'jiti';
5
3
  import 'unbuild';
6
4
 
7
5
  /**
package/dist/build.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  build
3
- } from "./chunk-T2Q5LQOI.js";
4
- import "./chunk-RHYLM6VP.js";
5
- import "./chunk-T6BV33KD.js";
6
- import "./chunk-BE5U4XRE.js";
3
+ } from "./chunk-5DNFZ6NI.js";
4
+ import "./chunk-JIVM7FQJ.js";
5
+ import "./chunk-TFMXUACY.js";
6
+ import "./chunk-VEX5RCZW.js";
7
7
  import "./chunk-ESRR2FD2.js";
8
- import "./chunk-2RMUO4GG.js";
9
- import "./chunk-RWW6C7JH.js";
10
- import "./chunk-JKBKJSU6.js";
8
+ import "./chunk-YCGXRIUD.js";
9
+ import "./chunk-4RR7YISH.js";
10
+ import "./chunk-BRHZNXQM.js";
11
11
  import "./chunk-3GQAWCBQ.js";
12
12
  export {
13
13
  build
@@ -1,3 +1,6 @@
1
+ import {
2
+ writeError
3
+ } from "./chunk-BRHZNXQM.js";
1
4
  import {
2
5
  __name
3
6
  } from "./chunk-3GQAWCBQ.js";
@@ -7,18 +10,18 @@ var onErrorPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
7
10
  name: "storm:on-error",
8
11
  buildEnd(error) {
9
12
  if (error) {
10
- resolvedOptions.logger.error(`The following errors occurred during the build:
13
+ writeError(`The following errors occurred during the build:
11
14
  ${error ? error.message : "Unknown build error"}
12
15
 
13
- `);
16
+ `, resolvedOptions.config);
14
17
  throw new Error("Storm unbuild process failed with errors.");
15
18
  }
16
19
  },
17
20
  renderError(error) {
18
- resolvedOptions.logger.error(`The following errors occurred during the build:
21
+ writeError(`The following errors occurred during the build:
19
22
  ${error ? error.message : "Unknown build error"}
20
23
 
21
- `);
24
+ `, resolvedOptions.config);
22
25
  throw new Error("Storm unbuild process failed with errors.");
23
26
  }
24
27
  }), "onErrorPlugin");