@stryke/prisma-better-auth-generator 0.14.103 → 0.14.105

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.
Files changed (84) hide show
  1. package/README.md +3 -3
  2. package/dist/_virtual/_rolldown/runtime.cjs +31 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +8 -0
  4. package/dist/access-control.cjs +37 -0
  5. package/dist/access-control.mjs +37 -0
  6. package/dist/access-control.mjs.map +1 -0
  7. package/dist/config.cjs +14 -0
  8. package/dist/config.mjs +13 -0
  9. package/dist/config.mjs.map +1 -0
  10. package/dist/generator.cjs +2 -0
  11. package/dist/generator.d.cts +1 -0
  12. package/dist/generator.d.mts +1 -0
  13. package/dist/generator.mjs +4 -0
  14. package/dist/index.cjs +26 -0
  15. package/dist/index.d.cts +1 -0
  16. package/dist/index.d.mts +1 -0
  17. package/dist/index.mjs +28 -0
  18. package/dist/index.mjs.map +1 -0
  19. package/dist/packages/env/src/ci-checks.cjs +13 -0
  20. package/dist/packages/env/src/ci-checks.mjs +13 -0
  21. package/dist/packages/env/src/ci-checks.mjs.map +1 -0
  22. package/dist/packages/env/src/environment-checks.cjs +96 -0
  23. package/dist/packages/env/src/environment-checks.mjs +88 -0
  24. package/dist/packages/env/src/environment-checks.mjs.map +1 -0
  25. package/dist/packages/env/src/get-env-paths.cjs +87 -0
  26. package/dist/packages/env/src/get-env-paths.mjs +85 -0
  27. package/dist/packages/env/src/get-env-paths.mjs.map +1 -0
  28. package/dist/packages/env/src/index.cjs +6 -0
  29. package/dist/packages/env/src/index.mjs +8 -0
  30. package/dist/packages/env/src/load-env.cjs +10 -0
  31. package/dist/packages/env/src/load-env.mjs +12 -0
  32. package/dist/packages/env/src/load-env.mjs.map +1 -0
  33. package/dist/packages/env/src/providers.cjs +111 -0
  34. package/dist/packages/env/src/providers.mjs +111 -0
  35. package/dist/packages/env/src/providers.mjs.map +1 -0
  36. package/dist/packages/env/src/runtime-checks.cjs +60 -0
  37. package/dist/packages/env/src/runtime-checks.mjs +53 -0
  38. package/dist/packages/env/src/runtime-checks.mjs.map +1 -0
  39. package/dist/packages/string-format/src/acronyms.cjs +414 -0
  40. package/dist/packages/string-format/src/acronyms.mjs +414 -0
  41. package/dist/packages/string-format/src/acronyms.mjs.map +1 -0
  42. package/dist/packages/string-format/src/articles.cjs +10 -0
  43. package/dist/packages/string-format/src/articles.mjs +10 -0
  44. package/dist/packages/string-format/src/articles.mjs.map +1 -0
  45. package/dist/packages/string-format/src/combine.cjs +15 -0
  46. package/dist/packages/string-format/src/combine.mjs +15 -0
  47. package/dist/packages/string-format/src/combine.mjs.map +1 -0
  48. package/dist/packages/string-format/src/conjunctions.cjs +32 -0
  49. package/dist/packages/string-format/src/conjunctions.mjs +32 -0
  50. package/dist/packages/string-format/src/conjunctions.mjs.map +1 -0
  51. package/dist/packages/string-format/src/decamelize.cjs +14 -0
  52. package/dist/packages/string-format/src/decamelize.mjs +14 -0
  53. package/dist/packages/string-format/src/decamelize.mjs.map +1 -0
  54. package/dist/packages/string-format/src/format-special-cases.cjs +33 -0
  55. package/dist/packages/string-format/src/format-special-cases.mjs +34 -0
  56. package/dist/packages/string-format/src/format-special-cases.mjs.map +1 -0
  57. package/dist/packages/string-format/src/lower-case-first.cjs +17 -0
  58. package/dist/packages/string-format/src/lower-case-first.mjs +17 -0
  59. package/dist/packages/string-format/src/lower-case-first.mjs.map +1 -0
  60. package/dist/packages/string-format/src/prepositions.cjs +68 -0
  61. package/dist/packages/string-format/src/prepositions.mjs +68 -0
  62. package/dist/packages/string-format/src/prepositions.mjs.map +1 -0
  63. package/dist/packages/string-format/src/special-cases.cjs +53 -0
  64. package/dist/packages/string-format/src/special-cases.mjs +53 -0
  65. package/dist/packages/string-format/src/special-cases.mjs.map +1 -0
  66. package/dist/packages/string-format/src/title-case.cjs +20 -0
  67. package/dist/packages/string-format/src/title-case.mjs +21 -0
  68. package/dist/packages/string-format/src/title-case.mjs.map +1 -0
  69. package/dist/packages/string-format/src/upper-case-first.cjs +17 -0
  70. package/dist/packages/string-format/src/upper-case-first.mjs +17 -0
  71. package/dist/packages/string-format/src/upper-case-first.mjs.map +1 -0
  72. package/dist/prisma-generator.cjs +47 -0
  73. package/dist/prisma-generator.mjs +47 -0
  74. package/dist/prisma-generator.mjs.map +1 -0
  75. package/dist/project.cjs +15 -0
  76. package/dist/project.mjs +15 -0
  77. package/dist/project.mjs.map +1 -0
  78. package/dist/utils/get-jiti.cjs +22 -0
  79. package/dist/utils/get-jiti.mjs +22 -0
  80. package/dist/utils/get-jiti.mjs.map +1 -0
  81. package/dist/utils/get-prisma-internals.cjs +13 -0
  82. package/dist/utils/get-prisma-internals.mjs +13 -0
  83. package/dist/utils/get-prisma-internals.mjs.map +1 -0
  84. package/package.json +26 -53
package/README.md CHANGED
@@ -5,9 +5,9 @@
5
5
 
6
6
  <div align="center">
7
7
  <picture>
8
- <source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/media/banner-1280x640-dark.gif">
9
- <source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/media/banner-1280x640-light.gif">
10
- <img src="https://public.storm-cdn.com/storm-software/media/banner-1280x640-dark.gif" width="100%" alt="Storm Software" />
8
+ <source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/stryke/media/banner-1280x640-dark.gif">
9
+ <source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/stryke/media/banner-1280x640-light.gif">
10
+ <img src="https://public.storm-cdn.com/stryke/media/banner-1280x640-dark.gif" width="100%" alt="Stryke" />
11
11
  </picture>
12
12
  </div>
13
13
  <br />
@@ -0,0 +1,31 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+
28
+ //#endregion
29
+
30
+ exports.__commonJSMin = __commonJSMin;
31
+ exports.__toESM = __toESM;
@@ -0,0 +1,8 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region \0rolldown/runtime.js
4
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
5
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
6
+
7
+ //#endregion
8
+ export { __commonJSMin, __require };
@@ -0,0 +1,37 @@
1
+ const require_lower_case_first = require('./packages/string-format/src/lower-case-first.cjs');
2
+
3
+ //#region src/access-control.ts
4
+ const USER_RESOURCES = [
5
+ "user",
6
+ "session",
7
+ "account",
8
+ "verification"
9
+ ];
10
+ const SOFT_DELETE_OPERATIONS = ["softDelete", "softDeleteMany"];
11
+ async function generateStatements(sourceFile, config, modelOperations) {
12
+ sourceFile.addStatements(`import {
13
+ defaultStatements,
14
+ } from "better-auth/plugins/admin/access";`);
15
+ sourceFile.addStatements(`
16
+ export const statements = {
17
+ ...defaultStatements,
18
+ ${modelOperations.filter((modelOperation) => config.omitUserResources ? !USER_RESOURCES.includes(require_lower_case_first.lowerCaseFirst(modelOperation.model)) : true).map((modelOperation) => {
19
+ const { model, plural: _, ...operations } = modelOperation;
20
+ const operationsList = Object.keys(operations).filter((operation) => !operation.endsWith("ManyAndReturn") && !operation.endsWith("OrThrow"));
21
+ if (config.withSoftDelete) operationsList.push(...SOFT_DELETE_OPERATIONS);
22
+ return `${require_lower_case_first.lowerCaseFirst(model)}: [${operationsList.map((operation) => `"${operation.replace("One", "")}"`).sort().join(", ")}]`;
23
+ }).join(",\n")}
24
+ }`);
25
+ sourceFile.formatText({ indentSize: 2 });
26
+ }
27
+ async function generateAccessControl(sourceFile) {
28
+ sourceFile.addStatements(`import { createAccessControl } from "better-auth/plugins/access";
29
+ import { statements } from "./statements";`);
30
+ sourceFile.addStatements(`
31
+ export const ac = createAccessControl(statements);`);
32
+ sourceFile.formatText({ indentSize: 2 });
33
+ }
34
+
35
+ //#endregion
36
+ exports.generateAccessControl = generateAccessControl;
37
+ exports.generateStatements = generateStatements;
@@ -0,0 +1,37 @@
1
+ import { lowerCaseFirst } from "./packages/string-format/src/lower-case-first.mjs";
2
+
3
+ //#region src/access-control.ts
4
+ const USER_RESOURCES = [
5
+ "user",
6
+ "session",
7
+ "account",
8
+ "verification"
9
+ ];
10
+ const SOFT_DELETE_OPERATIONS = ["softDelete", "softDeleteMany"];
11
+ async function generateStatements(sourceFile, config, modelOperations) {
12
+ sourceFile.addStatements(`import {
13
+ defaultStatements,
14
+ } from "better-auth/plugins/admin/access";`);
15
+ sourceFile.addStatements(`
16
+ export const statements = {
17
+ ...defaultStatements,
18
+ ${modelOperations.filter((modelOperation) => config.omitUserResources ? !USER_RESOURCES.includes(lowerCaseFirst(modelOperation.model)) : true).map((modelOperation) => {
19
+ const { model, plural: _, ...operations } = modelOperation;
20
+ const operationsList = Object.keys(operations).filter((operation) => !operation.endsWith("ManyAndReturn") && !operation.endsWith("OrThrow"));
21
+ if (config.withSoftDelete) operationsList.push(...SOFT_DELETE_OPERATIONS);
22
+ return `${lowerCaseFirst(model)}: [${operationsList.map((operation) => `"${operation.replace("One", "")}"`).sort().join(", ")}]`;
23
+ }).join(",\n")}
24
+ }`);
25
+ sourceFile.formatText({ indentSize: 2 });
26
+ }
27
+ async function generateAccessControl(sourceFile) {
28
+ sourceFile.addStatements(`import { createAccessControl } from "better-auth/plugins/access";
29
+ import { statements } from "./statements";`);
30
+ sourceFile.addStatements(`
31
+ export const ac = createAccessControl(statements);`);
32
+ sourceFile.formatText({ indentSize: 2 });
33
+ }
34
+
35
+ //#endregion
36
+ export { generateAccessControl, generateStatements };
37
+ //# sourceMappingURL=access-control.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-control.mjs","names":[],"sources":["../src/access-control.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\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/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { DMMF } from \"@prisma/generator-helper\";\nimport { lowerCaseFirst } from \"@stryke/string-format/lower-case-first\";\nimport type { SourceFile } from \"ts-morph\";\nimport type { Config } from \"./config\";\n\n// Omit these resources from the generated access control as they are managed by BetterAuth\nexport const USER_RESOURCES: string[] = [\n \"user\",\n \"session\",\n \"account\",\n \"verification\"\n] as const;\n\nexport const SOFT_DELETE_OPERATIONS: string[] = [\n \"softDelete\",\n \"softDeleteMany\"\n] as const;\n\nexport async function generateStatements(\n sourceFile: SourceFile,\n config: Config,\n modelOperations: DMMF.ModelMapping[]\n) {\n sourceFile.addStatements(/* ts */ `import {\n defaultStatements,\n} from \"better-auth/plugins/admin/access\";`);\n\n sourceFile.addStatements(/* ts */ `\nexport const statements = {\n ...defaultStatements,\n${modelOperations\n .filter(modelOperation =>\n config.omitUserResources\n ? !USER_RESOURCES.includes(lowerCaseFirst(modelOperation.model))\n : true\n )\n .map(modelOperation => {\n const { model, plural: _, ...operations } = modelOperation;\n\n const operationsList = Object.keys(operations).filter(\n operation =>\n !operation.endsWith(\"ManyAndReturn\") && !operation.endsWith(\"OrThrow\")\n );\n if (config.withSoftDelete) {\n operationsList.push(...SOFT_DELETE_OPERATIONS);\n }\n\n return `${lowerCaseFirst(model)}: [${operationsList\n .map(operation => `\"${operation.replace(\"One\", \"\")}\"`)\n .sort()\n .join(\", \")}]`;\n })\n .join(\",\\n\")}\n}`);\n\n sourceFile.formatText({\n indentSize: 2\n });\n}\n\nexport async function generateAccessControl(sourceFile: SourceFile) {\n sourceFile.addStatements(/* ts */ `import { createAccessControl } from \"better-auth/plugins/access\";\nimport { statements } from \"./statements\";`);\n\n sourceFile.addStatements(/* ts */ `\nexport const ac = createAccessControl(statements);`);\n\n sourceFile.formatText({\n indentSize: 2\n });\n}\n"],"mappings":";;;AAwBA,MAAa,iBAA2B;CACtC;CACA;CACA;CACA;CACD;AAED,MAAa,yBAAmC,CAC9C,cACA,iBACD;AAED,eAAsB,mBACpB,YACA,QACA,iBACA;AACA,YAAW,cAAuB;;4CAEQ;AAE1C,YAAW,cAAuB;;;EAGlC,gBACC,QAAO,mBACN,OAAO,oBACH,CAAC,eAAe,SAAS,eAAe,eAAe,MAAM,CAAC,GAC9D,KACL,CACA,KAAI,mBAAkB;EACrB,MAAM,EAAE,OAAO,QAAQ,GAAG,GAAG,eAAe;EAE5C,MAAM,iBAAiB,OAAO,KAAK,WAAW,CAAC,QAC7C,cACE,CAAC,UAAU,SAAS,gBAAgB,IAAI,CAAC,UAAU,SAAS,UAAU,CACzE;AACD,MAAI,OAAO,eACT,gBAAe,KAAK,GAAG,uBAAuB;AAGhD,SAAO,GAAG,eAAe,MAAM,CAAC,KAAK,eAClC,KAAI,cAAa,IAAI,UAAU,QAAQ,OAAO,GAAG,CAAC,GAAG,CACrD,MAAM,CACN,KAAK,KAAK,CAAC;GACd,CACD,KAAK,MAAM,CAAC;GACZ;AAED,YAAW,WAAW,EACpB,YAAY,GACb,CAAC;;AAGJ,eAAsB,sBAAsB,YAAwB;AAClE,YAAW,cAAuB;4CACQ;AAE1C,YAAW,cAAuB;oDACgB;AAElD,YAAW,WAAW,EACpB,YAAY,GACb,CAAC"}
@@ -0,0 +1,14 @@
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ let zod = require("zod");
3
+ zod = require_runtime.__toESM(zod, 1);
4
+
5
+ //#region src/config.ts
6
+ const configBoolean = zod.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
7
+ const configSchema = zod.object({
8
+ debug: configBoolean.default("false"),
9
+ withSoftDelete: configBoolean.default("false"),
10
+ omitUserResources: configBoolean.default("false")
11
+ });
12
+
13
+ //#endregion
14
+ exports.configSchema = configSchema;
@@ -0,0 +1,13 @@
1
+ import * as z from "zod";
2
+
3
+ //#region src/config.ts
4
+ const configBoolean = z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
5
+ const configSchema = z.object({
6
+ debug: configBoolean.default("false"),
7
+ withSoftDelete: configBoolean.default("false"),
8
+ omitUserResources: configBoolean.default("false")
9
+ });
10
+
11
+ //#endregion
12
+ export { configSchema };
13
+ //# sourceMappingURL=config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\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/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport * as z from \"zod\";\n\nconst configBoolean = z\n .string()\n .trim()\n .transform(value =>\n !value ||\n value.toLowerCase() === \"false\" ||\n value.toLowerCase() === \"n\" ||\n value.toLowerCase() === \"no\" ||\n value === \"0\"\n ? false\n : value.toLowerCase() === \"true\" ||\n value.toLowerCase() === \"y\" ||\n value.toLowerCase() === \"yes\" ||\n value === \"1\"\n ? true\n : value\n );\n\nexport const configSchema = z.object({\n debug: configBoolean.default(\"false\"),\n withSoftDelete: configBoolean.default(\"false\"),\n omitUserResources: configBoolean.default(\"false\")\n});\n\nexport type Config = z.infer<typeof configSchema>;\n"],"mappings":";;;AAoBA,MAAM,gBAAgB,EACnB,QAAQ,CACR,MAAM,CACN,WAAU,UACT,CAAC,SACD,MAAM,aAAa,KAAK,WACxB,MAAM,aAAa,KAAK,OACxB,MAAM,aAAa,KAAK,QACxB,UAAU,MACN,QACA,MAAM,aAAa,KAAK,UACtB,MAAM,aAAa,KAAK,OACxB,MAAM,aAAa,KAAK,SACxB,UAAU,MACV,OACA,MACP;AAEH,MAAa,eAAe,EAAE,OAAO;CACnC,OAAO,cAAc,QAAQ,QAAQ;CACrC,gBAAgB,cAAc,QAAQ,QAAQ;CAC9C,mBAAmB,cAAc,QAAQ,QAAQ;CAClD,CAAC"}
@@ -0,0 +1,2 @@
1
+ #! /usr/bin/env node
2
+ require('./index.cjs');
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env node
2
+ import "./index.mjs";
3
+
4
+ export { };
package/dist/index.cjs ADDED
@@ -0,0 +1,26 @@
1
+ const require_get_prisma_internals = require('./utils/get-prisma-internals.cjs');
2
+ const require_prisma_generator = require('./prisma-generator.cjs');
3
+
4
+ //#region src/index.ts
5
+ /**
6
+ * The prisma-better-auth-generator library used by Storm Software for building NodeJS applications.
7
+ *
8
+ * @remarks
9
+ * A package containing a Prisma v6 generator for Better-Auth authentication
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ require_get_prisma_internals.getPrismaGeneratorHelper().then((helpers) => {
14
+ helpers.generatorHandler({
15
+ onManifest: () => ({
16
+ defaultOutput: "./generated",
17
+ prettyName: "Storm Software - Prisma Better-Auth Generator",
18
+ requiresGenerators: ["prisma-client-js"]
19
+ }),
20
+ onGenerate: require_prisma_generator.generate
21
+ });
22
+ }).catch((reason) => {
23
+ console.error(`An error occured while generating prisma Better-Auth source code: ${reason}`);
24
+ });
25
+
26
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.mjs ADDED
@@ -0,0 +1,28 @@
1
+ import { getPrismaGeneratorHelper } from "./utils/get-prisma-internals.mjs";
2
+ import { generate } from "./prisma-generator.mjs";
3
+
4
+ //#region src/index.ts
5
+ /**
6
+ * The prisma-better-auth-generator library used by Storm Software for building NodeJS applications.
7
+ *
8
+ * @remarks
9
+ * A package containing a Prisma v6 generator for Better-Auth authentication
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ getPrismaGeneratorHelper().then((helpers) => {
14
+ helpers.generatorHandler({
15
+ onManifest: () => ({
16
+ defaultOutput: "./generated",
17
+ prettyName: "Storm Software - Prisma Better-Auth Generator",
18
+ requiresGenerators: ["prisma-client-js"]
19
+ }),
20
+ onGenerate: generate
21
+ });
22
+ }).catch((reason) => {
23
+ console.error(`An error occured while generating prisma Better-Auth source code: ${reason}`);
24
+ });
25
+
26
+ //#endregion
27
+ export { };
28
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\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/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * The prisma-better-auth-generator library used by Storm Software for building NodeJS applications.\n *\n * @remarks\n * A package containing a Prisma v6 generator for Better-Auth authentication\n *\n * @packageDocumentation\n */\n\nimport { generate } from \"./prisma-generator\";\nimport { getPrismaGeneratorHelper } from \"./utils/get-prisma-internals\";\n\ngetPrismaGeneratorHelper()\n .then(helpers => {\n helpers.generatorHandler({\n onManifest: () => ({\n defaultOutput: \"./generated\",\n prettyName: \"Storm Software - Prisma Better-Auth Generator\",\n requiresGenerators: [\"prisma-client-js\"]\n }),\n onGenerate: generate\n });\n })\n .catch(reason => {\n // eslint-disable-next-line no-console\n console.error(\n `An error occured while generating prisma Better-Auth source code: ${reason}`\n );\n });\n"],"mappings":";;;;;;;;;;;;AA8BA,0BAA0B,CACvB,MAAK,YAAW;AACf,SAAQ,iBAAiB;EACvB,mBAAmB;GACjB,eAAe;GACf,YAAY;GACZ,oBAAoB,CAAC,mBAAmB;GACzC;EACD,YAAY;EACb,CAAC;EACF,CACD,OAAM,WAAU;AAEf,SAAQ,MACN,qEAAqE,SACtE;EACD"}
@@ -0,0 +1,13 @@
1
+
2
+ //#region ../env/src/ci-checks.ts
3
+ /**
4
+ * Returns true if the current environment is a CI environment.
5
+ *
6
+ * @returns True if the current environment is a CI environment.
7
+ */
8
+ const isCI = (env = process.env) => {
9
+ return Boolean(env.STORM_CI || env.CI || env.CONTINUOUS_INTEGRATION || env.BUILD_NUMBER || env.RUN_ID || env.AGOLA_GIT_REF || env.AC_APPCIRCLE || env.APPVEYOR || env.CODEBUILD || env.TF_BUILD || env.bamboo_planKey || env.BITBUCKET_COMMIT || env.BITRISE_IO || env.BUDDY_WORKSPACE_ID || env.BUILDKITE || env.CIRCLECI || env.CIRRUS_CI || env.CF_BUILD_ID || env.CM_BUILD_ID || env.CI_NAME || env.DRONE || env.DSARI || env.EARTHLY_CI || env.EAS_BUILD || env.GERRIT_PROJECT || env.GITEA_ACTIONS || env.GITHUB_ACTIONS || env.GITLAB_CI || env.GOCD || env.BUILDER_OUTPUT || env.HARNESS_BUILD_ID || env.JENKINS_URL || env.BUILD_ID || env.LAYERCI || env.MAGNUM || env.NETLIFY || env.NEVERCODE || env.PROW_JOB_ID || env.RELEASE_BUILD_ID || env.RENDER || env.SAILCI || env.HUDSON || env.JENKINS_URL || env.BUILD_ID || env.SCREWDRIVER || env.SEMAPHORE || env.SOURCEHUT || env.STRIDER || env.TASK_ID || env.RUN_ID || env.TEAMCITY_VERSION || env.TRAVIS || env.VELA || env.NOW_BUILDER || env.APPCENTER_BUILD_ID || env.CI_XCODE_PROJECT || env.XCS || false);
10
+ };
11
+
12
+ //#endregion
13
+ exports.isCI = isCI;
@@ -0,0 +1,13 @@
1
+ //#region ../env/src/ci-checks.ts
2
+ /**
3
+ * Returns true if the current environment is a CI environment.
4
+ *
5
+ * @returns True if the current environment is a CI environment.
6
+ */
7
+ const isCI = (env = process.env) => {
8
+ return Boolean(env.STORM_CI || env.CI || env.CONTINUOUS_INTEGRATION || env.BUILD_NUMBER || env.RUN_ID || env.AGOLA_GIT_REF || env.AC_APPCIRCLE || env.APPVEYOR || env.CODEBUILD || env.TF_BUILD || env.bamboo_planKey || env.BITBUCKET_COMMIT || env.BITRISE_IO || env.BUDDY_WORKSPACE_ID || env.BUILDKITE || env.CIRCLECI || env.CIRRUS_CI || env.CF_BUILD_ID || env.CM_BUILD_ID || env.CI_NAME || env.DRONE || env.DSARI || env.EARTHLY_CI || env.EAS_BUILD || env.GERRIT_PROJECT || env.GITEA_ACTIONS || env.GITHUB_ACTIONS || env.GITLAB_CI || env.GOCD || env.BUILDER_OUTPUT || env.HARNESS_BUILD_ID || env.JENKINS_URL || env.BUILD_ID || env.LAYERCI || env.MAGNUM || env.NETLIFY || env.NEVERCODE || env.PROW_JOB_ID || env.RELEASE_BUILD_ID || env.RENDER || env.SAILCI || env.HUDSON || env.JENKINS_URL || env.BUILD_ID || env.SCREWDRIVER || env.SEMAPHORE || env.SOURCEHUT || env.STRIDER || env.TASK_ID || env.RUN_ID || env.TEAMCITY_VERSION || env.TRAVIS || env.VELA || env.NOW_BUILDER || env.APPCENTER_BUILD_ID || env.CI_XCODE_PROJECT || env.XCS || false);
9
+ };
10
+
11
+ //#endregion
12
+ export { isCI };
13
+ //# sourceMappingURL=ci-checks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ci-checks.mjs","names":[],"sources":["../../../../../env/src/ci-checks.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\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/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Returns true if the current environment is a CI environment.\n *\n * @returns True if the current environment is a CI environment.\n */\nexport const isCI = (\n env: Record<string, string | undefined> = process.env\n): boolean => {\n // From https://github.com/watson/ci-info/blob/44e98cebcdf4403f162195fbcf90b1f69fc6e047/index.js#L54-L61\n // Evaluating at runtime makes it possible to change the values in our tests\n // This list is probably not exhaustive though `process.env.CI` should be enough\n // but since we were using this utility in the past, we want to keep the same behavior\n return Boolean(\n env.STORM_CI || // Custom CI\n env.CI || // Travis CI, CircleCI, Cirrus CI, GitLab CI, Appveyor, CodeShip, dsari\n env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI\n env.BUILD_NUMBER || // Jenkins, TeamCity\n env.RUN_ID || // TaskCluster, dsari\n // From `env` from v4.0.0 https://github.com/watson/ci-info/blob/3e1488e98680f1f776785fe8708a157b7f00e568/vendors.json\n env.AGOLA_GIT_REF ||\n env.AC_APPCIRCLE ||\n env.APPVEYOR ||\n env.CODEBUILD ||\n env.TF_BUILD ||\n env.bamboo_planKey ||\n env.BITBUCKET_COMMIT ||\n env.BITRISE_IO ||\n env.BUDDY_WORKSPACE_ID ||\n env.BUILDKITE ||\n env.CIRCLECI ||\n env.CIRRUS_CI ||\n env.CF_BUILD_ID ||\n env.CM_BUILD_ID ||\n env.CI_NAME ||\n env.DRONE ||\n env.DSARI ||\n env.EARTHLY_CI ||\n env.EAS_BUILD ||\n env.GERRIT_PROJECT ||\n env.GITEA_ACTIONS ||\n env.GITHUB_ACTIONS ||\n env.GITLAB_CI ||\n env.GOCD ||\n env.BUILDER_OUTPUT ||\n env.HARNESS_BUILD_ID ||\n env.JENKINS_URL ||\n env.BUILD_ID ||\n env.LAYERCI ||\n env.MAGNUM ||\n env.NETLIFY ||\n env.NEVERCODE ||\n env.PROW_JOB_ID ||\n env.RELEASE_BUILD_ID ||\n env.RENDER ||\n env.SAILCI ||\n env.HUDSON ||\n env.JENKINS_URL ||\n env.BUILD_ID ||\n env.SCREWDRIVER ||\n env.SEMAPHORE ||\n env.SOURCEHUT ||\n env.STRIDER ||\n env.TASK_ID ||\n env.RUN_ID ||\n env.TEAMCITY_VERSION ||\n env.TRAVIS ||\n env.VELA ||\n env.NOW_BUILDER ||\n // See https://github.com/prisma/prisma/issues/22380 for why we commented it out\n // Users deploying on Vercel might have this env var set in the local dev env\n // env.VERCEL ||\n env.APPCENTER_BUILD_ID ||\n env.CI_XCODE_PROJECT ||\n env.XCS ||\n false\n );\n};\n\n// Same logic as https://github.com/sindresorhus/is-interactive/blob/dc8037ae1a61d828cfb42761c345404055b1e036/index.js\n// But defaults to check `stdin` for our prompts\n// It checks that the stream is TTY, not a dumb terminal\n\n/**\n * Check if the current process is interactive\n *\n * @param stream - The stream to check\n * @returns True if the current process is interactive\n */\nexport const isInteractive = (stream = process.stdin): boolean => {\n return Boolean(stream?.isTTY && process.env.TERM !== \"dumb\");\n};\n"],"mappings":";;;;;;AAuBA,MAAa,QACX,MAA0C,QAAQ,QACtC;AAKZ,QAAO,QACL,IAAI,YACJ,IAAI,MACJ,IAAI,0BACJ,IAAI,gBACJ,IAAI,UAEJ,IAAI,iBACJ,IAAI,gBACJ,IAAI,YACJ,IAAI,aACJ,IAAI,YACJ,IAAI,kBACJ,IAAI,oBACJ,IAAI,cACJ,IAAI,sBACJ,IAAI,aACJ,IAAI,YACJ,IAAI,aACJ,IAAI,eACJ,IAAI,eACJ,IAAI,WACJ,IAAI,SACJ,IAAI,SACJ,IAAI,cACJ,IAAI,aACJ,IAAI,kBACJ,IAAI,iBACJ,IAAI,kBACJ,IAAI,aACJ,IAAI,QACJ,IAAI,kBACJ,IAAI,oBACJ,IAAI,eACJ,IAAI,YACJ,IAAI,WACJ,IAAI,UACJ,IAAI,WACJ,IAAI,aACJ,IAAI,eACJ,IAAI,oBACJ,IAAI,UACJ,IAAI,UACJ,IAAI,UACJ,IAAI,eACJ,IAAI,YACJ,IAAI,eACJ,IAAI,aACJ,IAAI,aACJ,IAAI,WACJ,IAAI,WACJ,IAAI,UACJ,IAAI,oBACJ,IAAI,UACJ,IAAI,QACJ,IAAI,eAIJ,IAAI,sBACJ,IAAI,oBACJ,IAAI,OACJ,MACD"}
@@ -0,0 +1,96 @@
1
+ const require_ci_checks = require('./ci-checks.cjs');
2
+
3
+ //#region ../env/src/environment-checks.ts
4
+ /** Value of process.platform */
5
+ const platform = process?.platform || "";
6
+ /** Detect if stdout.TTY is available */
7
+ const hasTTY = Boolean(process?.stdout && process?.stdout.isTTY);
8
+ /** Detect if `DEBUG` environment variable is set */
9
+ const isDebug = Boolean(process.env.DEBUG);
10
+ /** Detect the `NODE_ENV` environment variable */
11
+ const mode = process.env.STORM_MODE || process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.NODE_ENV || "production";
12
+ /** Detect if the application is running in a staging environment */
13
+ const isStaging = [
14
+ "stg",
15
+ "stage",
16
+ "staging"
17
+ ].includes(mode?.toLowerCase());
18
+ /**
19
+ * Check if the current environment is production.
20
+ *
21
+ * @param mode - The mode string to check.
22
+ * @returns Whether the environment is production
23
+ */
24
+ function isProductionMode(mode) {
25
+ return [
26
+ "prd",
27
+ "prod",
28
+ "production",
29
+ "preprod",
30
+ "preproduction",
31
+ "uat"
32
+ ].includes(mode?.toLowerCase()?.replace(/[\s\-_]/g, ""));
33
+ }
34
+ /** Detect if `NODE_ENV` environment variable is `production` */
35
+ const isProduction = isProductionMode(mode);
36
+ /**
37
+ * Check if the current environment is test.
38
+ *
39
+ * @param mode - The mode string to check.
40
+ * @returns Whether the environment is test
41
+ */
42
+ function isTestMode(mode) {
43
+ return [
44
+ "tst",
45
+ "test",
46
+ "testing",
47
+ "stg",
48
+ "stage",
49
+ "staging",
50
+ "qa",
51
+ "qualityassurance"
52
+ ].includes(mode?.toLowerCase()?.replace(/[\s\-_]/g, ""));
53
+ }
54
+ /** Detect if `NODE_ENV` environment variable is `test` */
55
+ const isTest = isTestMode(mode) || isStaging || Boolean(process.env.TEST);
56
+ /**
57
+ * Check if the current environment is development.
58
+ *
59
+ * @param mode - The mode string to check.
60
+ * @returns Whether the environment is development
61
+ */
62
+ function isDevelopmentMode(mode) {
63
+ return [
64
+ "dev",
65
+ "development",
66
+ "int",
67
+ "integration"
68
+ ].includes(mode?.toLowerCase()?.replace(/[\s\-_]/g, ""));
69
+ }
70
+ /** Detect if `NODE_ENV` environment variable is `dev` or `development` */
71
+ const isDevelopment = isDevelopmentMode(mode) || isDebug;
72
+ /** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */
73
+ const isMinimal = Boolean(process.env.MINIMAL) || require_ci_checks.isCI() || isTest || !hasTTY;
74
+ /** Detect if process.platform is Windows */
75
+ const isWindows = /^win/i.test(platform);
76
+ /** Detect if process.platform is Linux */
77
+ const isLinux = /^linux/i.test(platform);
78
+ /** Detect if process.platform is macOS (darwin kernel) */
79
+ const isMacOS = /^darwin/i.test(platform);
80
+ /** Color Support */
81
+ const isColorSupported = !process.env.NO_COLOR && (Boolean(process.env.FORCE_COLOR) || (hasTTY || isWindows) && process.env.TERM !== "dumb" || require_ci_checks.isCI());
82
+ /** Node.js versions */
83
+ const nodeVersion = (process?.versions?.node || "").replace(/^v/, "") || null;
84
+ const nodeMajorVersion = Number(nodeVersion?.split(".")[0]) || null;
85
+
86
+ //#endregion
87
+ exports.hasTTY = hasTTY;
88
+ exports.isDebug = isDebug;
89
+ exports.isDevelopmentMode = isDevelopmentMode;
90
+ exports.isProductionMode = isProductionMode;
91
+ exports.isStaging = isStaging;
92
+ exports.isTest = isTest;
93
+ exports.isTestMode = isTestMode;
94
+ exports.isWindows = isWindows;
95
+ exports.nodeVersion = nodeVersion;
96
+ exports.platform = platform;
@@ -0,0 +1,88 @@
1
+ import { isCI } from "./ci-checks.mjs";
2
+
3
+ //#region ../env/src/environment-checks.ts
4
+ /** Value of process.platform */
5
+ const platform = process?.platform || "";
6
+ /** Detect if stdout.TTY is available */
7
+ const hasTTY = Boolean(process?.stdout && process?.stdout.isTTY);
8
+ /** Detect if `DEBUG` environment variable is set */
9
+ const isDebug = Boolean(process.env.DEBUG);
10
+ /** Detect the `NODE_ENV` environment variable */
11
+ const mode = process.env.STORM_MODE || process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.NODE_ENV || "production";
12
+ /** Detect if the application is running in a staging environment */
13
+ const isStaging = [
14
+ "stg",
15
+ "stage",
16
+ "staging"
17
+ ].includes(mode?.toLowerCase());
18
+ /**
19
+ * Check if the current environment is production.
20
+ *
21
+ * @param mode - The mode string to check.
22
+ * @returns Whether the environment is production
23
+ */
24
+ function isProductionMode(mode) {
25
+ return [
26
+ "prd",
27
+ "prod",
28
+ "production",
29
+ "preprod",
30
+ "preproduction",
31
+ "uat"
32
+ ].includes(mode?.toLowerCase()?.replace(/[\s\-_]/g, ""));
33
+ }
34
+ /** Detect if `NODE_ENV` environment variable is `production` */
35
+ const isProduction = isProductionMode(mode);
36
+ /**
37
+ * Check if the current environment is test.
38
+ *
39
+ * @param mode - The mode string to check.
40
+ * @returns Whether the environment is test
41
+ */
42
+ function isTestMode(mode) {
43
+ return [
44
+ "tst",
45
+ "test",
46
+ "testing",
47
+ "stg",
48
+ "stage",
49
+ "staging",
50
+ "qa",
51
+ "qualityassurance"
52
+ ].includes(mode?.toLowerCase()?.replace(/[\s\-_]/g, ""));
53
+ }
54
+ /** Detect if `NODE_ENV` environment variable is `test` */
55
+ const isTest = isTestMode(mode) || isStaging || Boolean(process.env.TEST);
56
+ /**
57
+ * Check if the current environment is development.
58
+ *
59
+ * @param mode - The mode string to check.
60
+ * @returns Whether the environment is development
61
+ */
62
+ function isDevelopmentMode(mode) {
63
+ return [
64
+ "dev",
65
+ "development",
66
+ "int",
67
+ "integration"
68
+ ].includes(mode?.toLowerCase()?.replace(/[\s\-_]/g, ""));
69
+ }
70
+ /** Detect if `NODE_ENV` environment variable is `dev` or `development` */
71
+ const isDevelopment = isDevelopmentMode(mode) || isDebug;
72
+ /** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */
73
+ const isMinimal = Boolean(process.env.MINIMAL) || isCI() || isTest || !hasTTY;
74
+ /** Detect if process.platform is Windows */
75
+ const isWindows = /^win/i.test(platform);
76
+ /** Detect if process.platform is Linux */
77
+ const isLinux = /^linux/i.test(platform);
78
+ /** Detect if process.platform is macOS (darwin kernel) */
79
+ const isMacOS = /^darwin/i.test(platform);
80
+ /** Color Support */
81
+ const isColorSupported = !process.env.NO_COLOR && (Boolean(process.env.FORCE_COLOR) || (hasTTY || isWindows) && process.env.TERM !== "dumb" || isCI());
82
+ /** Node.js versions */
83
+ const nodeVersion = (process?.versions?.node || "").replace(/^v/, "") || null;
84
+ const nodeMajorVersion = Number(nodeVersion?.split(".")[0]) || null;
85
+
86
+ //#endregion
87
+ export { hasTTY, isDebug, isDevelopmentMode, isProductionMode, isStaging, isTest, isTestMode, isWindows, nodeVersion, platform };
88
+ //# sourceMappingURL=environment-checks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-checks.mjs","names":[],"sources":["../../../../../env/src/environment-checks.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\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/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isCI } from \"./ci-checks\";\n\n/** Value of process.platform */\nexport const platform = process?.platform || \"\";\n\n/** Detect if stdout.TTY is available */\nexport const hasTTY = Boolean(process?.stdout && process?.stdout.isTTY);\n\n/** Detect if `DEBUG` environment variable is set */\nexport const isDebug = Boolean(process.env.DEBUG);\n\n/** Detect the `NODE_ENV` environment variable */\nconst mode =\n process.env.STORM_MODE ||\n process.env.NEXT_PUBLIC_VERCEL_ENV ||\n process.env.NODE_ENV ||\n \"production\";\n\n/** Detect if the application is running in a staging environment */\nexport const isStaging = [\"stg\", \"stage\", \"staging\"].includes(\n mode?.toLowerCase()\n);\n\n/**\n * Check if the current environment is production.\n *\n * @param mode - The mode string to check.\n * @returns Whether the environment is production\n */\nexport function isProductionMode(mode: string) {\n return [\n \"prd\",\n \"prod\",\n \"production\",\n\n \"preprod\",\n\n \"preproduction\",\n \"uat\"\n ].includes(mode?.toLowerCase()?.replace(/[\\s\\-_]/g, \"\"));\n}\n\n/** Detect if `NODE_ENV` environment variable is `production` */\nexport const isProduction = isProductionMode(mode);\n\n/**\n * Check if the current environment is test.\n *\n * @param mode - The mode string to check.\n * @returns Whether the environment is test\n */\nexport function isTestMode(mode: string) {\n return [\n \"tst\",\n \"test\",\n \"testing\",\n \"stg\",\n \"stage\",\n \"staging\",\n \"qa\",\n\n \"qualityassurance\"\n ].includes(mode?.toLowerCase()?.replace(/[\\s\\-_]/g, \"\"));\n}\n\n/** Detect if `NODE_ENV` environment variable is `test` */\nexport const isTest =\n isTestMode(mode) || isStaging || Boolean(process.env.TEST);\n\n/**\n * Check if the current environment is development.\n *\n * @param mode - The mode string to check.\n * @returns Whether the environment is development\n */\nexport function isDevelopmentMode(mode: string) {\n return [\"dev\", \"development\", \"int\", \"integration\"].includes(\n mode?.toLowerCase()?.replace(/[\\s\\-_]/g, \"\")\n );\n}\n\n/** Detect if `NODE_ENV` environment variable is `dev` or `development` */\nexport const isDevelopment = isDevelopmentMode(mode) || isDebug;\n\n/**\n * Convert a mode string to a standardized mode value of \"production\", \"development\", or \"test\".\n *\n * @param mode - The mode string to convert.\n * @returns The standardized mode value.\n */\nexport function toMode(mode: string): \"production\" | \"development\" | \"test\" {\n if (isProductionMode(mode)) {\n return \"production\";\n } else if (isTestMode(mode)) {\n return \"test\";\n } else if (isDevelopmentMode(mode)) {\n return \"development\";\n }\n\n return \"production\";\n}\n\n/** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */\nexport const isMinimal =\n Boolean(process.env.MINIMAL) || isCI() || isTest || !hasTTY;\n\n/** Detect if process.platform is Windows */\nexport const isWindows = /^win/i.test(platform);\n\n/** Detect if process.platform is Linux */\nexport const isLinux = /^linux/i.test(platform);\n\n/** Detect if process.platform is macOS (darwin kernel) */\nexport const isMacOS = /^darwin/i.test(platform);\n\n/** Color Support */\nexport const isColorSupported =\n !process.env.NO_COLOR &&\n (Boolean(process.env.FORCE_COLOR) ||\n ((hasTTY || isWindows) && process.env.TERM !== \"dumb\") ||\n isCI());\n\nfunction parseVersion(versionString = \"\") {\n if (/^\\d{3,4}$/.test(versionString)) {\n const match = /(\\d{1,2})(\\d{2})/.exec(versionString) ?? [];\n\n return {\n major: 0,\n minor: Number.parseInt(match[1]!, 10),\n patch: Number.parseInt(match[2]!, 10)\n };\n }\n\n const versions = (versionString ?? \"\")\n .split(\".\")\n .map(n => Number.parseInt(n, 10));\n\n return {\n major: versions[0],\n minor: versions[1],\n patch: versions[2]\n };\n}\n\n/**\n * Check if the current environment supports hyperlinks in the terminal.\n *\n * @param stream - The stream to check for TTY support (default: process.stdout)\n * @returns Whether hyperlinks are supported\n */\nexport function isHyperlinkSupported(\n stream: NodeJS.WriteStream = process.stdout\n): boolean {\n if (process.env.FORCE_HYPERLINK) {\n return !(\n process.env.FORCE_HYPERLINK.length > 0 &&\n Number.parseInt(process.env.FORCE_HYPERLINK, 10) === 0\n );\n }\n\n // Netlify does not run a TTY, it does not need `supportsColor` check\n if (process.env.NETLIFY) {\n return true;\n } else if (!isColorSupported) {\n return false;\n } else if (stream && !stream.isTTY) {\n return false;\n } else if (\"WT_SESSION\" in process.env) {\n return true;\n } else if (process.platform === \"win32\") {\n return false;\n } else if (isCI()) {\n return false;\n } else if (process.env.TEAMCITY_VERSION) {\n return false;\n } else if (process.env.TERM_PROGRAM) {\n const version = parseVersion(process.env.TERM_PROGRAM_VERSION);\n\n switch (process.env.TERM_PROGRAM) {\n case \"iTerm.app\": {\n if (version.major === 3) {\n return version.minor !== undefined && version.minor >= 1;\n }\n\n return version.major !== undefined && version.major > 3;\n }\n case \"WezTerm\": {\n return version.major !== undefined && version.major >= 20_200_620;\n }\n case \"vscode\": {\n // Cursor forked VS Code and supports hyperlinks in 0.x.x\n if (process.env.CURSOR_TRACE_ID) {\n return true;\n }\n\n return (\n version.minor !== undefined &&\n version.major !== undefined &&\n (version.major > 1 || (version.major === 1 && version.minor >= 72))\n );\n }\n case \"ghostty\": {\n return true;\n }\n }\n }\n\n if (process.env.VTE_VERSION) {\n // 0.50.0 was supposed to support hyperlinks, but throws a segfault\n if (process.env.VTE_VERSION === \"0.50.0\") {\n return false;\n }\n\n const version = parseVersion(process.env.VTE_VERSION);\n\n return (\n (version.major !== undefined && version.major > 0) ||\n (version.minor !== undefined && version.minor >= 50)\n );\n }\n\n if (process.env.TERM === \"alacritty\") {\n return true;\n }\n\n return false;\n}\n\n/** Node.js versions */\nexport const nodeVersion =\n (process?.versions?.node || \"\").replace(/^v/, \"\") || null;\n\nexport const nodeMajorVersion = Number(nodeVersion?.split(\".\")[0]) || null;\n"],"mappings":";;;;AAqBA,MAAa,WAAW,SAAS,YAAY;;AAG7C,MAAa,SAAS,QAAQ,SAAS,UAAU,SAAS,OAAO,MAAM;;AAGvE,MAAa,UAAU,QAAQ,QAAQ,IAAI,MAAM;;AAGjD,MAAM,OACJ,QAAQ,IAAI,cACZ,QAAQ,IAAI,0BACZ,QAAQ,IAAI,YACZ;;AAGF,MAAa,YAAY;CAAC;CAAO;CAAS;CAAU,CAAC,SACnD,MAAM,aAAa,CACpB;;;;;;;AAQD,SAAgB,iBAAiB,MAAc;AAC7C,QAAO;EACL;EACA;EACA;EAEA;EAEA;EACA;EACD,CAAC,SAAS,MAAM,aAAa,EAAE,QAAQ,YAAY,GAAG,CAAC;;;AAI1D,MAAa,eAAe,iBAAiB,KAAK;;;;;;;AAQlD,SAAgB,WAAW,MAAc;AACvC,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACD,CAAC,SAAS,MAAM,aAAa,EAAE,QAAQ,YAAY,GAAG,CAAC;;;AAI1D,MAAa,SACX,WAAW,KAAK,IAAI,aAAa,QAAQ,QAAQ,IAAI,KAAK;;;;;;;AAQ5D,SAAgB,kBAAkB,MAAc;AAC9C,QAAO;EAAC;EAAO;EAAe;EAAO;EAAc,CAAC,SAClD,MAAM,aAAa,EAAE,QAAQ,YAAY,GAAG,CAC7C;;;AAIH,MAAa,gBAAgB,kBAAkB,KAAK,IAAI;;AAqBxD,MAAa,YACX,QAAQ,QAAQ,IAAI,QAAQ,IAAI,MAAM,IAAI,UAAU,CAAC;;AAGvD,MAAa,YAAY,QAAQ,KAAK,SAAS;;AAG/C,MAAa,UAAU,UAAU,KAAK,SAAS;;AAG/C,MAAa,UAAU,WAAW,KAAK,SAAS;;AAGhD,MAAa,mBACX,CAAC,QAAQ,IAAI,aACZ,QAAQ,QAAQ,IAAI,YAAY,KAC7B,UAAU,cAAc,QAAQ,IAAI,SAAS,UAC/C,MAAM;;AA6GV,MAAa,eACV,SAAS,UAAU,QAAQ,IAAI,QAAQ,MAAM,GAAG,IAAI;AAEvD,MAAa,mBAAmB,OAAO,aAAa,MAAM,IAAI,CAAC,GAAG,IAAI"}
@@ -0,0 +1,87 @@
1
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
2
+ const require_title_case = require('../../string-format/src/title-case.cjs');
3
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
4
+ let node_os = require("node:os");
5
+ node_os = require_runtime.__toESM(node_os, 1);
6
+ let node_path = require("node:path");
7
+ node_path = require_runtime.__toESM(node_path, 1);
8
+
9
+ //#region ../env/src/get-env-paths.ts
10
+ const homedir = node_os.default.homedir();
11
+ const tmpdir = node_os.default.tmpdir();
12
+ const macos = (orgId) => {
13
+ const library = (0, _stryke_path_join_paths.joinPaths)(homedir, "Library");
14
+ return {
15
+ data: (0, _stryke_path_join_paths.joinPaths)(library, "Application Support", orgId),
16
+ config: (0, _stryke_path_join_paths.joinPaths)(library, "Preferences", orgId),
17
+ cache: (0, _stryke_path_join_paths.joinPaths)(library, "Caches", orgId),
18
+ log: (0, _stryke_path_join_paths.joinPaths)(library, "Logs", orgId),
19
+ temp: (0, _stryke_path_join_paths.joinPaths)(tmpdir, orgId)
20
+ };
21
+ };
22
+ const windows = (orgId) => {
23
+ const appData = process.env.APPDATA || (0, _stryke_path_join_paths.joinPaths)(homedir, "AppData", "Roaming");
24
+ const localAppData = process.env.LOCALAPPDATA || (0, _stryke_path_join_paths.joinPaths)(homedir, "AppData", "Local");
25
+ const windowsFormattedOrgId = require_title_case.titleCase(orgId).trim().replace(/\s+/g, "");
26
+ return {
27
+ data: (0, _stryke_path_join_paths.joinPaths)(localAppData, windowsFormattedOrgId, "Data"),
28
+ config: (0, _stryke_path_join_paths.joinPaths)(appData, windowsFormattedOrgId, "Config"),
29
+ cache: (0, _stryke_path_join_paths.joinPaths)(localAppData, "Cache", orgId),
30
+ log: (0, _stryke_path_join_paths.joinPaths)(localAppData, windowsFormattedOrgId, "Log"),
31
+ temp: (0, _stryke_path_join_paths.joinPaths)(tmpdir, orgId)
32
+ };
33
+ };
34
+ const linux = (orgId) => {
35
+ const username = node_path.default.basename(homedir);
36
+ return {
37
+ data: (0, _stryke_path_join_paths.joinPaths)(process.env.XDG_DATA_HOME || (0, _stryke_path_join_paths.joinPaths)(homedir, ".local", "share"), orgId),
38
+ config: (0, _stryke_path_join_paths.joinPaths)(process.env.XDG_CONFIG_HOME || (0, _stryke_path_join_paths.joinPaths)(homedir, ".config"), orgId),
39
+ cache: (0, _stryke_path_join_paths.joinPaths)(process.env.XDG_CACHE_HOME || (0, _stryke_path_join_paths.joinPaths)(homedir, ".cache"), orgId),
40
+ log: (0, _stryke_path_join_paths.joinPaths)(process.env.XDG_STATE_HOME || (0, _stryke_path_join_paths.joinPaths)(homedir, ".local", "state"), orgId),
41
+ temp: process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR ? (0, _stryke_path_join_paths.joinPaths)(process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR, orgId) : (0, _stryke_path_join_paths.joinPaths)(tmpdir, username, orgId)
42
+ };
43
+ };
44
+ /**
45
+ * Get paths for storing things like data, config, logs, and cache in the current runtime environment.
46
+ *
47
+ * @remarks
48
+ * On macOS, directories are generally created in `~/Library/Application Support/<name>`.
49
+ * On Windows, directories are generally created in `%AppData%/<name>`.
50
+ * 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/).
51
+ *
52
+ * 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.
53
+ *
54
+ * @param options - Parameters used to determine the specific paths for the current project/runtime environment
55
+ * @returns An object containing the various paths for the runtime environment
56
+ */
57
+ function getEnvPaths(options = {}) {
58
+ let orgId = options.orgId || "storm-software";
59
+ if (!orgId) throw new Error("You need to provide an orgId to the `getEnvPaths` function");
60
+ if (options.suffix) orgId += `-${typeof options.suffix === "string" ? options.suffix : "nodejs"}`;
61
+ let result = {};
62
+ if (process.platform === "darwin") result = macos(orgId);
63
+ else if (process.platform === "win32") result = windows(orgId);
64
+ else result = linux(orgId);
65
+ if (process.env.STORM_DATA_DIR) result.data = process.env.STORM_DATA_DIR;
66
+ else if (process.env.STORM_CONFIG_DIR) result.config = process.env.STORM_CONFIG_DIR;
67
+ else if (process.env.STORM_CACHE_DIR) result.cache = process.env.STORM_CACHE_DIR;
68
+ else if (process.env.STORM_LOG_DIR) result.log = process.env.STORM_LOG_DIR;
69
+ else if (process.env.STORM_TEMP_DIR) result.temp = process.env.STORM_TEMP_DIR;
70
+ if (options.workspaceRoot) {
71
+ result.cache ??= (0, _stryke_path_join_paths.joinPaths)(options.workspaceRoot, "node_modules", ".cache", orgId);
72
+ result.temp ??= (0, _stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tmp", orgId);
73
+ result.log ??= (0, _stryke_path_join_paths.joinPaths)(result.temp, "logs");
74
+ result.config ??= (0, _stryke_path_join_paths.joinPaths)(options.workspaceRoot, ".config", orgId);
75
+ }
76
+ return Object.keys(result).reduce((ret, key) => {
77
+ if (result[key]) {
78
+ const filePath = result[key];
79
+ ret[key] = options.appId && options.appId !== options.orgId && options.appId !== options.nestedDir ? (0, _stryke_path_join_paths.joinPaths)(filePath, options.appId) : filePath;
80
+ if (options.nestedDir && options.nestedDir !== options.orgId && options.nestedDir !== options.appId) ret[key] = (0, _stryke_path_join_paths.joinPaths)(ret[key], options.nestedDir);
81
+ }
82
+ return ret;
83
+ }, {});
84
+ }
85
+
86
+ //#endregion
87
+ exports.getEnvPaths = getEnvPaths;