@powerlines/engine 0.43.27 → 0.43.29

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.
@@ -72,6 +72,7 @@ let _stryke_fs_get_workspace_root = require("@stryke/fs/get-workspace-root");
72
72
  let _stryke_hash = require("@stryke/hash");
73
73
  let _stryke_hash_node = require("@stryke/hash/node");
74
74
  let _stryke_http_fetch = require("@stryke/http/fetch");
75
+ let _stryke_path_is_equal = require("@stryke/path/is-equal");
75
76
  let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
76
77
  let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
77
78
  let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
@@ -2163,6 +2164,10 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2163
2164
  */
2164
2165
  options;
2165
2166
  /**
2167
+ * The input options used to initialize the context, which may be used when cloning the context to ensure the same configuration is applied to the new context
2168
+ */
2169
+ inputOptions = {};
2170
+ /**
2166
2171
  * The parsed configuration file for the project
2167
2172
  */
2168
2173
  configFile;
@@ -2196,7 +2201,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2196
2201
  return (0, _stryke_env_get_env_paths.getEnvPaths)({
2197
2202
  orgId: this.options.organization,
2198
2203
  appId: this.options.framework || "powerlines",
2199
- workspaceRoot: this.options.cwd || process.cwd() || "."
2204
+ workspaceRoot: this.options.cwd
2200
2205
  });
2201
2206
  }
2202
2207
  /**
@@ -2315,26 +2320,28 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2315
2320
  * @param options - The configuration options to initialize the context with
2316
2321
  */
2317
2322
  async init(options = {}) {
2323
+ this.inputOptions = options;
2318
2324
  if (!this.powerlinesPath) {
2319
2325
  const powerlinesPath = await (0, _stryke_fs_resolve.resolvePackage)("powerlines");
2320
2326
  if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
2321
2327
  this.powerlinesPath = powerlinesPath;
2322
2328
  }
2329
+ const cwd = options.cwd || this.options?.cwd || process.cwd();
2330
+ const root = (options.root || this.options?.root) && (options.root || this.options.root).replace(/^\.\/?/, "") && !(0, _stryke_path_is_equal.isEqual)(options.root || this.options.root, cwd) ? options.root || this.options.root : ".";
2323
2331
  this.options = (0, defu.default)({
2324
- root: options.root,
2325
- cwd: options.cwd,
2332
+ root,
2333
+ cwd,
2326
2334
  mode: options.mode,
2327
2335
  framework: options.framework,
2328
2336
  organization: options.organization,
2329
2337
  configFile: options.configFile
2330
2338
  }, this.options ?? {}, {
2331
- cwd: process.cwd() || ".",
2332
2339
  mode: "production",
2333
2340
  framework: "powerlines"
2334
2341
  });
2335
2342
  this.resolver = createResolver({
2336
- workspaceRoot: this.options.cwd,
2337
- root: this.options.root,
2343
+ workspaceRoot: cwd,
2344
+ root,
2338
2345
  cacheDir: this.envPaths.cache,
2339
2346
  mode: this.options.mode,
2340
2347
  logLevel: this.logLevel
@@ -3042,6 +3049,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3042
3049
  copyTo(context) {
3043
3050
  for (const [key, value] of Object.entries(this)) if (!SKIP_CLONING_PROPS.includes(key)) if ((0, _stryke_type_checks_is_object.isObject)(value) || Array.isArray(value)) context[key] = (0, _stryke_helpers_deep_clone.deepClone)(value);
3044
3051
  else context[key] = value;
3052
+ context.inputOptions = (0, _stryke_helpers_deep_clone.deepClone)(this.inputOptions);
3045
3053
  context.dependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.dependencies);
3046
3054
  context.devDependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.devDependencies);
3047
3055
  context.persistedMeta = this.persistedMeta ? (0, _stryke_helpers_deep_clone.deepClone)(this.persistedMeta) : void 0;
@@ -3064,14 +3072,14 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3064
3072
  async init(options = {}) {
3065
3073
  await super.init(options);
3066
3074
  this.options.configIndex = options.configIndex ?? this.options.configIndex ?? 0;
3067
- const projectJsonPath = (0, _stryke_path_join.joinPaths)(this.options.root, "project.json");
3075
+ const projectJsonPath = (0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root, "project.json");
3068
3076
  if ((0, _stryke_fs_exists.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs_json.readJsonFile)(projectJsonPath);
3069
- const packageJsonPath = (0, _stryke_path_join.joinPaths)(this.options.root, "package.json");
3077
+ const packageJsonPath = (0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root, "package.json");
3070
3078
  if ((0, _stryke_fs_exists.existsSync)(packageJsonPath)) {
3071
3079
  this.packageJson = await (0, _stryke_fs_json.readJsonFile)(packageJsonPath);
3072
3080
  this.options.organization ??= (0, _stryke_type_checks_is_set_object.isSetObject)(this.packageJson?.author) ? (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author?.name) : (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author);
3073
3081
  }
3074
- this.#checksum = await this.generateChecksum(this.options.root);
3082
+ this.#checksum = await this.generateChecksum((0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root));
3075
3083
  const userConfig = this.configFile.config ? Array.isArray(this.configFile.config) && this.configFile.config.length > this.options.configIndex ? this.configFile.config[this.options.configIndex] : this.configFile.config : {};
3076
3084
  this.resolvedConfig = {
3077
3085
  ...this.options,
@@ -3083,6 +3091,14 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3083
3091
  * Initialize the context with the provided configuration options
3084
3092
  */
3085
3093
  async innerSetup() {
3094
+ if (!this.inputOptions.mode && !this.config.userConfig?.mode && !this.config.inlineConfig?.mode && !this.config.pluginConfig?.mode) {
3095
+ this.options.mode = "production";
3096
+ this.config.mode = "production";
3097
+ }
3098
+ if (!this.inputOptions.framework && !this.config.userConfig?.framework && !this.config.inlineConfig?.framework && !this.config.pluginConfig?.framework) {
3099
+ this.options.framework = "powerlines";
3100
+ this.config.framework = "powerlines";
3101
+ }
3086
3102
  this.resolvedConfig.compatibilityDate = (0, compatx.resolveCompatibilityDates)(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
3087
3103
  this.logger = {
3088
3104
  log: this.createLog(this.config.name),
@@ -3124,13 +3140,14 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3124
3140
  if (this.config.output.path) this.config.output.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, this.config.output.path), this.config.cwd);
3125
3141
  if (this.config.output.copy !== false) {
3126
3142
  this.config.output.copy ??= {};
3127
- this.config.output.copy.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, this.config.output.copy.path || (0, _stryke_path_join.joinPaths)("dist", this.config.root)), this.config.cwd);
3143
+ if (!this.config.root.replace(/^\.\/?/, "")) this.config.output.copy.path = this.config.output.copy.path ? (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, this.config.output.copy.path), this.config.cwd) : this.config.output.path;
3144
+ else this.config.output.copy.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, this.config.output.copy.path || (0, _stryke_path_join.joinPaths)("dist", this.config.root)), this.config.cwd);
3128
3145
  }
3129
3146
  if (this.config.output.dts !== false && this.config.output.types !== false) this.config.output.types = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, this.config.output.types || (0, _stryke_path_join.joinPaths)(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`)), this.config.cwd);
3130
3147
  if (this.config.output.copy && this.config.output.copy.path && this.config.output.copy.assets && Array.isArray(this.config.output.copy.assets)) this.config.output.copy.assets = (0, _stryke_helpers_get_unique.getUniqueBy)(this.config.output.copy.assets.map((asset) => {
3131
3148
  return {
3132
3149
  glob: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) ? asset.glob : asset,
3133
- input: (0, _stryke_type_checks_is_string.isString)(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.options.cwd : (0, _stryke_path_is_parent_path.isParentPath)(asset.input, this.config.cwd) || asset.input === this.config.cwd ? asset.input : (0, _stryke_path_append.appendPath)(asset.input, this.config.cwd),
3150
+ input: (0, _stryke_type_checks_is_string.isString)(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.options.cwd : (0, _stryke_path_is_parent_path.isParentPath)(asset.input, this.config.cwd) || (0, _stryke_path_is_equal.isEqual)(asset.input, this.config.cwd) ? asset.input : (0, _stryke_path_append.appendPath)(asset.input, this.config.cwd),
3134
3151
  output: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) && asset.output ? (0, _stryke_path_is_parent_path.isParentPath)(asset.output, this.config.cwd) ? asset.output : (0, _stryke_path_append.appendPath)((0, _stryke_path_join.joinPaths)(this.config.output.copy.path, (0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)(asset.output, (0, _stryke_path_replace.replacePath)(this.config.output.copy.path, this.config.cwd)), this.config.output.copy.path)), this.config.cwd) : (0, _stryke_path_append.appendPath)(this.config.output.copy.path, this.config.cwd),
3135
3152
  ignore: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) && asset.ignore ? (0, _stryke_convert_to_array.toArray)(asset.ignore) : void 0
3136
3153
  };
@@ -41,6 +41,7 @@ import { relativeToWorkspaceRoot } from "@stryke/fs/get-workspace-root";
41
41
  import { murmurhash } from "@stryke/hash";
42
42
  import { hashDirectory } from "@stryke/hash/node";
43
43
  import { fetchRequest } from "@stryke/http/fetch";
44
+ import { isEqual } from "@stryke/path/is-equal";
44
45
  import { kebabCase } from "@stryke/string-format/kebab-case";
45
46
  import { isNull } from "@stryke/type-checks/is-null";
46
47
  import { uuid } from "@stryke/unique-id/uuid";
@@ -2130,6 +2131,10 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2130
2131
  */
2131
2132
  options;
2132
2133
  /**
2134
+ * The input options used to initialize the context, which may be used when cloning the context to ensure the same configuration is applied to the new context
2135
+ */
2136
+ inputOptions = {};
2137
+ /**
2133
2138
  * The parsed configuration file for the project
2134
2139
  */
2135
2140
  configFile;
@@ -2163,7 +2168,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2163
2168
  return getEnvPaths({
2164
2169
  orgId: this.options.organization,
2165
2170
  appId: this.options.framework || "powerlines",
2166
- workspaceRoot: this.options.cwd || process.cwd() || "."
2171
+ workspaceRoot: this.options.cwd
2167
2172
  });
2168
2173
  }
2169
2174
  /**
@@ -2282,26 +2287,28 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2282
2287
  * @param options - The configuration options to initialize the context with
2283
2288
  */
2284
2289
  async init(options = {}) {
2290
+ this.inputOptions = options;
2285
2291
  if (!this.powerlinesPath) {
2286
2292
  const powerlinesPath = await resolvePackage("powerlines");
2287
2293
  if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
2288
2294
  this.powerlinesPath = powerlinesPath;
2289
2295
  }
2296
+ const cwd = options.cwd || this.options?.cwd || process.cwd();
2297
+ const root = (options.root || this.options?.root) && (options.root || this.options.root).replace(/^\.\/?/, "") && !isEqual(options.root || this.options.root, cwd) ? options.root || this.options.root : ".";
2290
2298
  this.options = defu({
2291
- root: options.root,
2292
- cwd: options.cwd,
2299
+ root,
2300
+ cwd,
2293
2301
  mode: options.mode,
2294
2302
  framework: options.framework,
2295
2303
  organization: options.organization,
2296
2304
  configFile: options.configFile
2297
2305
  }, this.options ?? {}, {
2298
- cwd: process.cwd() || ".",
2299
2306
  mode: "production",
2300
2307
  framework: "powerlines"
2301
2308
  });
2302
2309
  this.resolver = createResolver({
2303
- workspaceRoot: this.options.cwd,
2304
- root: this.options.root,
2310
+ workspaceRoot: cwd,
2311
+ root,
2305
2312
  cacheDir: this.envPaths.cache,
2306
2313
  mode: this.options.mode,
2307
2314
  logLevel: this.logLevel
@@ -3009,6 +3016,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3009
3016
  copyTo(context) {
3010
3017
  for (const [key, value] of Object.entries(this)) if (!SKIP_CLONING_PROPS.includes(key)) if (isObject(value) || Array.isArray(value)) context[key] = deepClone(value);
3011
3018
  else context[key] = value;
3019
+ context.inputOptions = deepClone(this.inputOptions);
3012
3020
  context.dependencies = deepClone(this.dependencies);
3013
3021
  context.devDependencies = deepClone(this.devDependencies);
3014
3022
  context.persistedMeta = this.persistedMeta ? deepClone(this.persistedMeta) : void 0;
@@ -3031,14 +3039,14 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3031
3039
  async init(options = {}) {
3032
3040
  await super.init(options);
3033
3041
  this.options.configIndex = options.configIndex ?? this.options.configIndex ?? 0;
3034
- const projectJsonPath = joinPaths$1(this.options.root, "project.json");
3042
+ const projectJsonPath = joinPaths$1(this.options.cwd, this.options.root, "project.json");
3035
3043
  if (existsSync(projectJsonPath)) this.projectJson = await readJsonFile(projectJsonPath);
3036
- const packageJsonPath = joinPaths$1(this.options.root, "package.json");
3044
+ const packageJsonPath = joinPaths$1(this.options.cwd, this.options.root, "package.json");
3037
3045
  if (existsSync(packageJsonPath)) {
3038
3046
  this.packageJson = await readJsonFile(packageJsonPath);
3039
3047
  this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
3040
3048
  }
3041
- this.#checksum = await this.generateChecksum(this.options.root);
3049
+ this.#checksum = await this.generateChecksum(joinPaths$1(this.options.cwd, this.options.root));
3042
3050
  const userConfig = this.configFile.config ? Array.isArray(this.configFile.config) && this.configFile.config.length > this.options.configIndex ? this.configFile.config[this.options.configIndex] : this.configFile.config : {};
3043
3051
  this.resolvedConfig = {
3044
3052
  ...this.options,
@@ -3050,6 +3058,14 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3050
3058
  * Initialize the context with the provided configuration options
3051
3059
  */
3052
3060
  async innerSetup() {
3061
+ if (!this.inputOptions.mode && !this.config.userConfig?.mode && !this.config.inlineConfig?.mode && !this.config.pluginConfig?.mode) {
3062
+ this.options.mode = "production";
3063
+ this.config.mode = "production";
3064
+ }
3065
+ if (!this.inputOptions.framework && !this.config.userConfig?.framework && !this.config.inlineConfig?.framework && !this.config.pluginConfig?.framework) {
3066
+ this.options.framework = "powerlines";
3067
+ this.config.framework = "powerlines";
3068
+ }
3053
3069
  this.resolvedConfig.compatibilityDate = resolveCompatibilityDates(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
3054
3070
  this.logger = {
3055
3071
  log: this.createLog(this.config.name),
@@ -3091,13 +3107,14 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3091
3107
  if (this.config.output.path) this.config.output.path = appendPath(replacePathTokens(this, this.config.output.path), this.config.cwd);
3092
3108
  if (this.config.output.copy !== false) {
3093
3109
  this.config.output.copy ??= {};
3094
- this.config.output.copy.path = appendPath(replacePathTokens(this, this.config.output.copy.path || joinPaths$1("dist", this.config.root)), this.config.cwd);
3110
+ if (!this.config.root.replace(/^\.\/?/, "")) this.config.output.copy.path = this.config.output.copy.path ? appendPath(replacePathTokens(this, this.config.output.copy.path), this.config.cwd) : this.config.output.path;
3111
+ else this.config.output.copy.path = appendPath(replacePathTokens(this, this.config.output.copy.path || joinPaths$1("dist", this.config.root)), this.config.cwd);
3095
3112
  }
3096
3113
  if (this.config.output.dts !== false && this.config.output.types !== false) this.config.output.types = appendPath(replacePathTokens(this, this.config.output.types || joinPaths$1(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`)), this.config.cwd);
3097
3114
  if (this.config.output.copy && this.config.output.copy.path && this.config.output.copy.assets && Array.isArray(this.config.output.copy.assets)) this.config.output.copy.assets = getUniqueBy(this.config.output.copy.assets.map((asset) => {
3098
3115
  return {
3099
3116
  glob: isSetObject(asset) ? asset.glob : asset,
3100
- input: isString(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.options.cwd : isParentPath(asset.input, this.config.cwd) || asset.input === this.config.cwd ? asset.input : appendPath(asset.input, this.config.cwd),
3117
+ input: isString(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.options.cwd : isParentPath(asset.input, this.config.cwd) || isEqual(asset.input, this.config.cwd) ? asset.input : appendPath(asset.input, this.config.cwd),
3101
3118
  output: isSetObject(asset) && asset.output ? isParentPath(asset.output, this.config.cwd) ? asset.output : appendPath(joinPaths$1(this.config.output.copy.path, replacePath(replacePath(asset.output, replacePath(this.config.output.copy.path, this.config.cwd)), this.config.output.copy.path)), this.config.cwd) : appendPath(this.config.output.copy.path, this.config.cwd),
3102
3119
  ignore: isSetObject(asset) && asset.ignore ? toArray(asset.ignore) : void 0
3103
3120
  };