@power-plant/core 0.0.89 → 0.0.91

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.
@@ -41,6 +41,8 @@ node_os = __toESM(node_os, 1);
41
41
  let unstorage = require("unstorage");
42
42
  let unstorage_drivers_fs_lite = require("unstorage/drivers/fs-lite");
43
43
  unstorage_drivers_fs_lite = __toESM(unstorage_drivers_fs_lite, 1);
44
+ let unstorage_drivers_memory = require("unstorage/drivers/memory");
45
+ unstorage_drivers_memory = __toESM(unstorage_drivers_memory, 1);
44
46
  let _power_plant_schema_storage = require("@power-plant/schema/storage");
45
47
  let _stryke_resolve_load = require("@stryke/resolve/load");
46
48
  let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
@@ -68,14 +70,23 @@ const paths = (0, _stryke_env_get_env_paths.getEnvPaths)({
68
70
  async function createSessionContext(userConfig = {}) {
69
71
  const cwd = userConfig.cwd || process.cwd();
70
72
  const now = /* @__PURE__ */ new Date();
71
- const storage = (0, unstorage.createStorage)({ driver: (0, unstorage_drivers_fs_lite.default)({ base: cwd }) });
72
- const store = JSON.parse(await (0, _stryke_fs_read_file.readFileIfExisting)((0, _stryke_path_join_paths.joinPaths)(paths.data, ".local-store.json")) || "{}");
73
+ const storage = (0, unstorage.createStorage)({ driver: userConfig.settings?.skipStorage ? (0, unstorage_drivers_memory.default)() : (0, unstorage_drivers_fs_lite.default)({ base: cwd }) });
74
+ let store = {};
75
+ if (!userConfig.settings?.skipStorage) try {
76
+ store = JSON.parse(await (0, _stryke_fs_read_file.readFileIfExisting)((0, _stryke_path_join_paths.joinPaths)(paths.data, ".local-store.json")) || "{}");
77
+ } catch (error) {
78
+ logger.error(`Failed to read local store file (${(0, _stryke_path_join_paths.joinPaths)(paths.data, ".local-store.json")}): ${error instanceof Error ? error.message : "Unknown error"}`);
79
+ }
73
80
  const device = store.device || node_os.default.hostname() || (0, _stryke_unique_id_uuid.uuid)();
74
81
  const user = store.user || node_os.default.userInfo().username || (0, _stryke_unique_id_uuid.uuid)();
75
- if (!(0, _stryke_type_checks_is_set_string.isSetString)(store.device) || !(0, _stryke_type_checks_is_set_string.isSetString)(store.user)) await (0, _stryke_fs_write_file.writeFile)((0, _stryke_path_join_paths.joinPaths)(paths.data, ".local-store.json"), JSON.stringify({
76
- device,
77
- user
78
- }, null, 2));
82
+ if (!userConfig.settings?.skipStorage && (!(0, _stryke_type_checks_is_set_string.isSetString)(store.device) || !(0, _stryke_type_checks_is_set_string.isSetString)(store.user))) try {
83
+ await (0, _stryke_fs_write_file.writeFile)((0, _stryke_path_join_paths.joinPaths)(paths.data, ".local-store.json"), JSON.stringify({
84
+ device,
85
+ user
86
+ }, null, 2));
87
+ } catch (error) {
88
+ logger.error(`Failed to write local store file (${(0, _stryke_path_join_paths.joinPaths)(paths.data, ".local-store.json")}): ${error instanceof Error ? error.message : "Unknown error"}`);
89
+ }
79
90
  return (0, defu.default)({
80
91
  cwd,
81
92
  session: {
@@ -11,6 +11,7 @@ import defu from "defu";
11
11
  import os from "node:os";
12
12
  import { createStorage } from "unstorage";
13
13
  import fsLite from "unstorage/drivers/fs-lite";
14
+ import memory from "unstorage/drivers/memory";
14
15
  import { mapStorageToFileSystem } from "@power-plant/schema/storage";
15
16
  import { load } from "@stryke/resolve/load";
16
17
  import { isFunction } from "@stryke/type-checks/is-function";
@@ -38,14 +39,23 @@ const paths = getEnvPaths({
38
39
  async function createSessionContext(userConfig = {}) {
39
40
  const cwd = userConfig.cwd || process.cwd();
40
41
  const now = /* @__PURE__ */ new Date();
41
- const storage = createStorage({ driver: fsLite({ base: cwd }) });
42
- const store = JSON.parse(await readFileIfExisting(joinPaths(paths.data, ".local-store.json")) || "{}");
42
+ const storage = createStorage({ driver: userConfig.settings?.skipStorage ? memory() : fsLite({ base: cwd }) });
43
+ let store = {};
44
+ if (!userConfig.settings?.skipStorage) try {
45
+ store = JSON.parse(await readFileIfExisting(joinPaths(paths.data, ".local-store.json")) || "{}");
46
+ } catch (error) {
47
+ logger.error(`Failed to read local store file (${joinPaths(paths.data, ".local-store.json")}): ${error instanceof Error ? error.message : "Unknown error"}`);
48
+ }
43
49
  const device = store.device || os.hostname() || uuid();
44
50
  const user = store.user || os.userInfo().username || uuid();
45
- if (!isSetString(store.device) || !isSetString(store.user)) await writeFile(joinPaths(paths.data, ".local-store.json"), JSON.stringify({
46
- device,
47
- user
48
- }, null, 2));
51
+ if (!userConfig.settings?.skipStorage && (!isSetString(store.device) || !isSetString(store.user))) try {
52
+ await writeFile(joinPaths(paths.data, ".local-store.json"), JSON.stringify({
53
+ device,
54
+ user
55
+ }, null, 2));
56
+ } catch (error) {
57
+ logger.error(`Failed to write local store file (${joinPaths(paths.data, ".local-store.json")}): ${error instanceof Error ? error.message : "Unknown error"}`);
58
+ }
49
59
  return defu({
50
60
  cwd,
51
61
  session: {
@@ -462,4 +472,4 @@ async function execute(config, options = {}) {
462
472
 
463
473
  //#endregion
464
474
  export { execute as n, createExecute as t };
465
- //# sourceMappingURL=execute-CC_fSFT9.mjs.map
475
+ //# sourceMappingURL=execute-CMeb6o0g.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-CMeb6o0g.mjs","names":[],"sources":[],"mappings":""}
package/dist/execute.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_execute = require('./execute-BguaVasR.cjs');
2
+ const require_execute = require('./execute-C7wgqV2z.cjs');
3
3
  require('./context.cjs');
4
4
 
5
5
  exports.createExecute = require_execute.createExecute;
package/dist/execute.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./context.mjs";
2
- import { n as execute, t as createExecute } from "./execute-CC_fSFT9.mjs";
2
+ import { n as execute, t as createExecute } from "./execute-CMeb6o0g.mjs";
3
3
 
4
4
  export { createExecute, execute };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_execute = require('./execute-BguaVasR.cjs');
2
+ const require_execute = require('./execute-C7wgqV2z.cjs');
3
3
  const require_config = require('./config.cjs');
4
4
  const require_context = require('./context.cjs');
5
5
  const require_define = require('./define.cjs');
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineConfig } from "./config.mjs";
2
2
  import { callAsyncExecution, callAsyncExecutionContext, callAsyncSession, callAsyncSessionContext, callExecution, callExecutionContext, callSession, callSessionContext, executionAsyncLocalStorage, executionContext, sessionAsyncLocalStorage, sessionContext, tryUseExecution, tryUseExecutionContext, tryUseSession, tryUseSessionContext, useContext, useExecution, useExecutionContext, useSession, useSessionContext } from "./context.mjs";
3
3
  import { defineGenerator, defineInput, defineOutput, defineSchema } from "./define.mjs";
4
- import { n as execute, t as createExecute } from "./execute-CC_fSFT9.mjs";
4
+ import { n as execute, t as createExecute } from "./execute-CMeb6o0g.mjs";
5
5
 
6
6
  export { callAsyncExecution, callAsyncExecutionContext, callAsyncSession, callAsyncSessionContext, callExecution, callExecutionContext, callSession, callSessionContext, createExecute, defineConfig, defineGenerator, defineInput, defineOutput, defineSchema, execute, executionAsyncLocalStorage, executionContext, sessionAsyncLocalStorage, sessionContext, tryUseExecution, tryUseExecutionContext, tryUseSession, tryUseSessionContext, useContext, useExecution, useExecutionContext, useSession, useSessionContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@power-plant/core",
3
- "version": "0.0.89",
3
+ "version": "0.0.91",
4
4
  "private": false,
5
5
  "description": "☢️ Generate anything from a specification",
6
6
  "keywords": ["power-plant", "storm-software"],
@@ -160,29 +160,29 @@
160
160
  "typings": "dist/index.d.mts",
161
161
  "files": ["dist"],
162
162
  "dependencies": {
163
- "@power-plant/schema": "^0.0.87",
164
- "@stryke/convert": "^0.7.39",
165
- "@stryke/date": "^0.0.20",
166
- "@stryke/env": "^0.20.127",
167
- "@stryke/fs": "^0.33.110",
168
- "@stryke/helpers": "^0.10.48",
169
- "@stryke/json": "^0.15.32",
170
- "@stryke/path": "^0.29.35",
171
- "@stryke/resolve": "^0.0.25",
172
- "@stryke/string-format": "^0.17.50",
173
- "@stryke/type-checks": "^0.6.41",
174
- "@stryke/types": "^0.12.36",
175
- "@stryke/unique-id": "^0.3.121",
163
+ "@power-plant/schema": "^0.0.89",
164
+ "@stryke/convert": "^0.7.41",
165
+ "@stryke/date": "^0.0.22",
166
+ "@stryke/env": "^0.20.129",
167
+ "@stryke/fs": "^0.33.112",
168
+ "@stryke/helpers": "^0.10.50",
169
+ "@stryke/json": "^0.15.34",
170
+ "@stryke/path": "^0.29.37",
171
+ "@stryke/resolve": "^0.0.27",
172
+ "@stryke/string-format": "^0.17.52",
173
+ "@stryke/type-checks": "^0.6.43",
174
+ "@stryke/types": "^0.12.38",
175
+ "@stryke/unique-id": "^0.3.123",
176
176
  "c12": "^3.3.4",
177
177
  "defu": "^6.1.7",
178
178
  "jiti": "^2.7.0",
179
179
  "unstorage": "^1.17.5"
180
180
  },
181
181
  "devDependencies": {
182
- "@powerlines/plugin-tsdown": "^0.1.608",
182
+ "@powerlines/plugin-tsdown": "^0.1.612",
183
183
  "@types/node": "^25.9.5",
184
184
  "typescript": "^6.0.3"
185
185
  },
186
186
  "publishConfig": { "access": "public" },
187
- "gitHead": "0138400eb12cad53834c6ea7caa3eef265da1d37"
187
+ "gitHead": "bc1c485164b94d2ba499632c202f5a1335f6e2ca"
188
188
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute-CC_fSFT9.mjs","names":[],"sources":[],"mappings":""}