@stryke/env 0.6.2 → 0.6.4

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.
@@ -22,7 +22,7 @@ const n = _nodeOs.default.homedir(),
22
22
  temp: (0, _joinPaths.joinPaths)(o, e)
23
23
  };
24
24
  },
25
- v = e => {
25
+ E = e => {
26
26
  const a = process.env.APPDATA || (0, _joinPaths.joinPaths)(n, "AppData", "Roaming"),
27
27
  t = process.env.LOCALAPPDATA || (0, _joinPaths.joinPaths)(n, "AppData", "Local"),
28
28
  r = (0, _titleCase.titleCase)(e).trim().replace(/\s+/g, "");
@@ -34,14 +34,14 @@ const n = _nodeOs.default.homedir(),
34
34
  temp: (0, _joinPaths.joinPaths)(o, e)
35
35
  };
36
36
  },
37
- h = e => {
37
+ _ = e => {
38
38
  const a = _nodePath.default.basename(n);
39
39
  return {
40
40
  data: (0, _joinPaths.joinPaths)(process.env.XDG_DATA_HOME || (0, _joinPaths.joinPaths)(n, ".local", "share"), e),
41
41
  config: (0, _joinPaths.joinPaths)(process.env.XDG_CONFIG_HOME || (0, _joinPaths.joinPaths)(n, ".config"), e),
42
42
  cache: (0, _joinPaths.joinPaths)(process.env.XDG_CACHE_HOME || (0, _joinPaths.joinPaths)(n, ".cache"), e),
43
43
  log: (0, _joinPaths.joinPaths)(process.env.XDG_STATE_HOME || (0, _joinPaths.joinPaths)(n, ".local", "state"), e),
44
- temp: (0, _joinPaths.joinPaths)(process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR || o, a, e)
44
+ temp: process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR ? (0, _joinPaths.joinPaths)(process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR, e) : (0, _joinPaths.joinPaths)(o, a, e)
45
45
  };
46
46
  };
47
47
  function getEnvPaths(e = {}) {
@@ -49,7 +49,7 @@ function getEnvPaths(e = {}) {
49
49
  if (!a) throw new Error("You need to provide an orgId to the `getEnvPaths` function");
50
50
  e.suffix && (a += `-${(0, _isString.isString)(e.suffix) ? e.suffix : "nodejs"}`);
51
51
  let t = {};
52
- return process.platform === "darwin" ? t = l(a) : process.platform === "win32" ? t = v(a) : t = h(a), process.env.STORM_DATA_DIRECTORY ? t.data = process.env.STORM_DATA_DIRECTORY : process.env.STORM_CONFIG_DIRECTORY ? t.config = process.env.STORM_CONFIG_DIRECTORY : process.env.STORM_CACHE_DIRECTORY ? t.cache = process.env.STORM_CACHE_DIRECTORY : process.env.STORM_LOG_DIRECTORY ? t.log = process.env.STORM_LOG_DIRECTORY : process.env.STORM_TEMP_DIRECTORY && (t.temp = process.env.STORM_TEMP_DIRECTORY), e.workspaceRoot && (t.cache ??= (0, _joinPaths.joinPaths)(e.workspaceRoot, "node_modules", ".cache", a), t.temp ??= (0, _joinPaths.joinPaths)(e.workspaceRoot, "tmp", a), t.log ??= (0, _joinPaths.joinPaths)(t.temp, "logs"), t.config ??= (0, _joinPaths.joinPaths)(e.workspaceRoot, ".config", a)), Object.keys(t).reduce((r, c) => {
52
+ return process.platform === "darwin" ? t = l(a) : process.platform === "win32" ? t = E(a) : t = _(a), process.env.STORM_DATA_DIR ? t.data = process.env.STORM_DATA_DIR : process.env.STORM_CONFIG_DIR ? t.config = process.env.STORM_CONFIG_DIR : process.env.STORM_CACHE_DIR ? t.cache = process.env.STORM_CACHE_DIR : process.env.STORM_LOG_DIR ? t.log = process.env.STORM_LOG_DIR : process.env.STORM_TEMP_DIR && (t.temp = process.env.STORM_TEMP_DIR), e.workspaceRoot && (t.cache ??= (0, _joinPaths.joinPaths)(e.workspaceRoot, "node_modules", ".cache", a), t.temp ??= (0, _joinPaths.joinPaths)(e.workspaceRoot, "tmp", a), t.log ??= (0, _joinPaths.joinPaths)(t.temp, "logs"), t.config ??= (0, _joinPaths.joinPaths)(e.workspaceRoot, ".config", a)), Object.keys(t).reduce((r, c) => {
53
53
  if (t[c]) {
54
54
  const i = t[c];
55
55
  r[c] = e.appId && e.appId !== e.orgId && e.appId !== e.nestedDir ? (0, _joinPaths.joinPaths)(i, e.appId) : i, e.nestedDir && e.nestedDir !== e.orgId && e.nestedDir !== e.appId && (r[c] = (0, _joinPaths.joinPaths)(r[c], e.nestedDir));
@@ -52,7 +52,7 @@ export interface EnvPaths {
52
52
  * On Windows, directories are generally created in `%AppData%/<name>`.
53
53
  * On Linux, directories are generally created in `~/.config/<name>` - this is determined via the [XDG Base Directory spec](https://specifications.freedesktop.org/basedir-spec/latest/).
54
54
  *
55
- * If the `STORM_DATA_DIRECTORY`, `STORM_CONFIG_DIRECTORY`, `STORM_CACHE_DIRECTORY`, `STORM_LOG_DIRECTORY`, or `STORM_TEMP_DIRECTORY` environment variables are set, they will be used instead of the default paths.
55
+ * If the `STORM_DATA_DIR`, `STORM_CONFIG_DIR`, `STORM_CACHE_DIR`, `STORM_LOG_DIR`, or `STORM_TEMP_DIR` environment variables are set, they will be used instead of the default paths.
56
56
  *
57
57
  * @param options - Parameters used to determine the specific paths for the current project/runtime environment
58
58
  * @returns An object containing the various paths for the runtime environment
@@ -1 +1 @@
1
- import{joinPaths as s}from"@stryke/path/join-paths";import{titleCase as f}from"@stryke/string-format/title-case";import{isString as E}from"@stryke/type-checks/is-string";import p from"node:os";import R from"node:path";const n=p.homedir(),o=p.tmpdir(),l=e=>{const a=s(n,"Library");return{data:s(a,"Application Support",e),config:s(a,"Preferences",e),cache:s(a,"Caches",e),log:s(a,"Logs",e),temp:s(o,e)}},v=e=>{const a=process.env.APPDATA||s(n,"AppData","Roaming"),t=process.env.LOCALAPPDATA||s(n,"AppData","Local"),r=f(e).trim().replace(/\s+/g,"");return{data:s(t,r,"Data"),config:s(a,r,"Config"),cache:s(t,"Cache",e),log:s(t,r,"Log"),temp:s(o,e)}},h=e=>{const a=R.basename(n);return{data:s(process.env.XDG_DATA_HOME||s(n,".local","share"),e),config:s(process.env.XDG_CONFIG_HOME||s(n,".config"),e),cache:s(process.env.XDG_CACHE_HOME||s(n,".cache"),e),log:s(process.env.XDG_STATE_HOME||s(n,".local","state"),e),temp:s(process.env.DEVENV_RUNTIME||process.env.XDG_RUNTIME_DIR||o,a,e)}};export function getEnvPaths(e={}){let a=e.orgId||"storm-software";if(!a)throw new Error("You need to provide an orgId to the `getEnvPaths` function");e.suffix&&(a+=`-${E(e.suffix)?e.suffix:"nodejs"}`);let t={};return process.platform==="darwin"?t=l(a):process.platform==="win32"?t=v(a):t=h(a),process.env.STORM_DATA_DIRECTORY?t.data=process.env.STORM_DATA_DIRECTORY:process.env.STORM_CONFIG_DIRECTORY?t.config=process.env.STORM_CONFIG_DIRECTORY:process.env.STORM_CACHE_DIRECTORY?t.cache=process.env.STORM_CACHE_DIRECTORY:process.env.STORM_LOG_DIRECTORY?t.log=process.env.STORM_LOG_DIRECTORY:process.env.STORM_TEMP_DIRECTORY&&(t.temp=process.env.STORM_TEMP_DIRECTORY),e.workspaceRoot&&(t.cache??=s(e.workspaceRoot,"node_modules",".cache",a),t.temp??=s(e.workspaceRoot,"tmp",a),t.log??=s(t.temp,"logs"),t.config??=s(e.workspaceRoot,".config",a)),Object.keys(t).reduce((r,c)=>{if(t[c]){const i=t[c];r[c]=e.appId&&e.appId!==e.orgId&&e.appId!==e.nestedDir?s(i,e.appId):i,e.nestedDir&&e.nestedDir!==e.orgId&&e.nestedDir!==e.appId&&(r[c]=s(r[c],e.nestedDir))}return r},{})}
1
+ import{joinPaths as s}from"@stryke/path/join-paths";import{titleCase as f}from"@stryke/string-format/title-case";import{isString as v}from"@stryke/type-checks/is-string";import p from"node:os";import D from"node:path";const n=p.homedir(),o=p.tmpdir(),l=e=>{const a=s(n,"Library");return{data:s(a,"Application Support",e),config:s(a,"Preferences",e),cache:s(a,"Caches",e),log:s(a,"Logs",e),temp:s(o,e)}},E=e=>{const a=process.env.APPDATA||s(n,"AppData","Roaming"),t=process.env.LOCALAPPDATA||s(n,"AppData","Local"),r=f(e).trim().replace(/\s+/g,"");return{data:s(t,r,"Data"),config:s(a,r,"Config"),cache:s(t,"Cache",e),log:s(t,r,"Log"),temp:s(o,e)}},_=e=>{const a=D.basename(n);return{data:s(process.env.XDG_DATA_HOME||s(n,".local","share"),e),config:s(process.env.XDG_CONFIG_HOME||s(n,".config"),e),cache:s(process.env.XDG_CACHE_HOME||s(n,".cache"),e),log:s(process.env.XDG_STATE_HOME||s(n,".local","state"),e),temp:process.env.DEVENV_RUNTIME||process.env.XDG_RUNTIME_DIR?s(process.env.DEVENV_RUNTIME||process.env.XDG_RUNTIME_DIR,e):s(o,a,e)}};export function getEnvPaths(e={}){let a=e.orgId||"storm-software";if(!a)throw new Error("You need to provide an orgId to the `getEnvPaths` function");e.suffix&&(a+=`-${v(e.suffix)?e.suffix:"nodejs"}`);let t={};return process.platform==="darwin"?t=l(a):process.platform==="win32"?t=E(a):t=_(a),process.env.STORM_DATA_DIR?t.data=process.env.STORM_DATA_DIR:process.env.STORM_CONFIG_DIR?t.config=process.env.STORM_CONFIG_DIR:process.env.STORM_CACHE_DIR?t.cache=process.env.STORM_CACHE_DIR:process.env.STORM_LOG_DIR?t.log=process.env.STORM_LOG_DIR:process.env.STORM_TEMP_DIR&&(t.temp=process.env.STORM_TEMP_DIR),e.workspaceRoot&&(t.cache??=s(e.workspaceRoot,"node_modules",".cache",a),t.temp??=s(e.workspaceRoot,"tmp",a),t.log??=s(t.temp,"logs"),t.config??=s(e.workspaceRoot,".config",a)),Object.keys(t).reduce((r,c)=>{if(t[c]){const i=t[c];r[c]=e.appId&&e.appId!==e.orgId&&e.appId!==e.nestedDir?s(i,e.appId):i,e.nestedDir&&e.nestedDir!==e.orgId&&e.nestedDir!==e.appId&&(r[c]=s(r[c],e.nestedDir))}return r},{})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/env",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "type": "module",
5
5
  "description": "A package containing utility functions to handle environment specific processes",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  "defu": "^6.1.4",
15
15
  "@stryke/fs": "^0.12.1",
16
16
  "@stryke/json": "^0.7.1",
17
- "@stryke/path": "^0.4.10",
17
+ "@stryke/path": "^0.4.11",
18
18
  "@stryke/string-format": "^0.4.1",
19
19
  "@stryke/type-checks": "^0.3.1"
20
20
  },