@schemavaults/auth-server-sdk 0.19.5 → 0.19.7

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.
@@ -1,9 +1,21 @@
1
- import { dirname, join } from "path";
1
+ import { dirname, join, normalize } from "path";
2
+ import { existsSync } from "fs";
2
3
  export default function resolveCodegenTemplatesDirectory() {
3
4
  if (!__dirname) {
4
5
  throw new Error("The __dirname variable is not set for this file in this environment!");
5
6
  }
6
7
  // Templates are copied into the dist/codegen-templates directory during build
7
- return join(dirname(__dirname), "codegen-templates");
8
+ // ... but sometimes this runs from src/NextjsAppDirectoryPlugin/resolve-codegen-templates-directory.ts
9
+ // ... while other times it is running from the bundled version at dist/cli.cjs
10
+ if (existsSync(join(__dirname, "codegen-templates"))) {
11
+ return normalize(join(__dirname, "codegen-templates"));
12
+ }
13
+ else if (existsSync(join(dirname(__dirname), "codegen-templates"))) {
14
+ return normalize(join(dirname(__dirname), "codegen-templates"));
15
+ }
16
+ else if (existsSync(join(dirname(__dirname), "dist", "codegen-templates"))) {
17
+ return normalize(join(dirname(__dirname), "dist", "codegen-templates"));
18
+ }
19
+ throw new Error("Failed to resolve 'codegen-templates' directory!");
8
20
  }
9
21
  //# sourceMappingURL=resolve-codegen-templates-directory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-codegen-templates-directory.js","sourceRoot":"","sources":["../../src/NextjsAppDirectoryPlugin/resolve-codegen-templates-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,gCAAgC;IACtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;IACJ,CAAC;IAED,8EAA8E;IAC9E,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC,CAAC;AACvD,CAAC"}
1
+ {"version":3,"file":"resolve-codegen-templates-directory.js","sourceRoot":"","sources":["../../src/NextjsAppDirectoryPlugin/resolve-codegen-templates-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,MAAM,CAAC,OAAO,UAAU,gCAAgC;IACtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;IACJ,CAAC;IAED,8EAA8E;IAC9E,uGAAuG;IACvG,+EAA+E;IAE/E,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC;QACrD,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC;IACzD,CAAC;SAAM,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC;QACrE,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAClE,CAAC;SAAM,IACL,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,EACjE,CAAC;QACD,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACtE,CAAC"}
package/dist/cli.cjs CHANGED
@@ -46,13 +46,21 @@ function resolveCodegenTemplatesDirectory() {
46
46
  "The __dirname variable is not set for this file in this environment!"
47
47
  );
48
48
  }
49
- return (0, import_path2.join)((0, import_path2.dirname)(__dirname), "codegen-templates");
49
+ if ((0, import_fs2.existsSync)((0, import_path2.join)(__dirname, "codegen-templates"))) {
50
+ return (0, import_path2.normalize)((0, import_path2.join)(__dirname, "codegen-templates"));
51
+ } else if ((0, import_fs2.existsSync)((0, import_path2.join)((0, import_path2.dirname)(__dirname), "codegen-templates"))) {
52
+ return (0, import_path2.normalize)((0, import_path2.join)((0, import_path2.dirname)(__dirname), "codegen-templates"));
53
+ } else if ((0, import_fs2.existsSync)((0, import_path2.join)((0, import_path2.dirname)(__dirname), "dist", "codegen-templates"))) {
54
+ return (0, import_path2.normalize)((0, import_path2.join)((0, import_path2.dirname)(__dirname), "dist", "codegen-templates"));
55
+ }
56
+ throw new Error("Failed to resolve 'codegen-templates' directory!");
50
57
  }
51
- var import_path2;
58
+ var import_path2, import_fs2;
52
59
  var init_resolve_codegen_templates_directory = __esm({
53
60
  "src/NextjsAppDirectoryPlugin/resolve-codegen-templates-directory.ts"() {
54
61
  "use strict";
55
62
  import_path2 = require("path");
63
+ import_fs2 = require("fs");
56
64
  }
57
65
  });
58
66
 
@@ -64,21 +72,21 @@ __export(codegen_exports, {
64
72
  function createClientPages(appDirectory, templatesDir) {
65
73
  for (const page of pagesToCreate) {
66
74
  const destPath = (0, import_path4.join)(appDirectory, page.app_dir_path, "page.tsx");
67
- if ((0, import_fs2.existsSync)(destPath)) {
75
+ if ((0, import_fs3.existsSync)(destPath)) {
68
76
  console.log(
69
77
  ` - skipping '${page.app_dir_path}/page.tsx' (already exists)`
70
78
  );
71
79
  continue;
72
80
  }
73
81
  const destDir = (0, import_path3.dirname)(destPath);
74
- if (!(0, import_fs2.existsSync)(destDir)) {
75
- (0, import_fs2.mkdirSync)(destDir, { recursive: true });
82
+ if (!(0, import_fs3.existsSync)(destDir)) {
83
+ (0, import_fs3.mkdirSync)(destDir, { recursive: true });
76
84
  }
77
85
  const templatePath = (0, import_path4.join)(templatesDir, page.codegen_template_path);
78
- const templateContent = (0, import_fs2.readFileSync)(templatePath, {
86
+ const templateContent = (0, import_fs3.readFileSync)(templatePath, {
79
87
  encoding: "utf-8"
80
88
  });
81
- (0, import_fs2.writeFileSync)(destPath, templateContent, { encoding: "utf-8" });
89
+ (0, import_fs3.writeFileSync)(destPath, templateContent, { encoding: "utf-8" });
82
90
  console.log(` - created '${page.app_dir_path}/page.tsx'`);
83
91
  }
84
92
  }
@@ -89,18 +97,18 @@ function createClientAuthProvider(appDirectory, templatesDir) {
89
97
  "auth-provider.tsx"
90
98
  );
91
99
  const destPath = (0, import_path4.join)(appDirectory, "auth", "auth-provider.tsx");
92
- if ((0, import_fs2.existsSync)(destPath)) {
100
+ if ((0, import_fs3.existsSync)(destPath)) {
93
101
  console.log(` - skipping 'auth/auth-provider.tsx' (already exists)`);
94
102
  return;
95
103
  }
96
104
  const destDir = (0, import_path3.dirname)(destPath);
97
- if (!(0, import_fs2.existsSync)(destDir)) {
98
- (0, import_fs2.mkdirSync)(destDir, { recursive: true });
105
+ if (!(0, import_fs3.existsSync)(destDir)) {
106
+ (0, import_fs3.mkdirSync)(destDir, { recursive: true });
99
107
  }
100
- const templateContent = (0, import_fs2.readFileSync)(srcTemplatePath, {
108
+ const templateContent = (0, import_fs3.readFileSync)(srcTemplatePath, {
101
109
  encoding: "utf-8"
102
110
  });
103
- (0, import_fs2.writeFileSync)(destPath, templateContent, { encoding: "utf-8" });
111
+ (0, import_fs3.writeFileSync)(destPath, templateContent, { encoding: "utf-8" });
104
112
  console.log(` - created 'auth/auth-provider.tsx'`);
105
113
  }
106
114
  async function codegen(opts) {
@@ -110,8 +118,8 @@ async function codegen(opts) {
110
118
  const appDirectory = resolveAppDirectory();
111
119
  console.log(` - resolved /app directory at '${appDirectory}'`);
112
120
  const authDirectory = (0, import_path4.join)(appDirectory, "auth");
113
- if (!(0, import_fs2.existsSync)(authDirectory)) {
114
- (0, import_fs2.mkdirSync)(authDirectory);
121
+ if (!(0, import_fs3.existsSync)(authDirectory)) {
122
+ (0, import_fs3.mkdirSync)(authDirectory);
115
123
  console.log(` - created /auth directory at '${authDirectory}'`);
116
124
  } else {
117
125
  console.log(` - /auth directory already exists at '${authDirectory}'`);
@@ -124,11 +132,11 @@ async function codegen(opts) {
124
132
  `[@schemavaults/auth-server-sdk/NextjsAppDirectoryPlugin] Codegen complete.`
125
133
  );
126
134
  }
127
- var import_fs2, import_path3, import_path4, pagesToCreate;
135
+ var import_fs3, import_path3, import_path4, pagesToCreate;
128
136
  var init_codegen = __esm({
129
137
  "src/NextjsAppDirectoryPlugin/codegen.ts"() {
130
138
  "use strict";
131
- import_fs2 = require("fs");
139
+ import_fs3 = require("fs");
132
140
  import_path3 = require("path");
133
141
  init_resolve_app_directory();
134
142
  import_path4 = require("path");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@schemavaults/auth-server-sdk",
3
3
  "description": "TypeScript SDK for building authenticated endpoints/middlewares for the Auth Server and Resource Servers",
4
- "version": "0.19.5",
4
+ "version": "0.19.7",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
7
7
  "repository": {
@@ -14,7 +14,7 @@
14
14
  "module": "dist/index.js",
15
15
  "types": "dist/index.d.ts",
16
16
  "bin": {
17
- "auth-server-sdk": "./cli.cjs"
17
+ "auth-server-sdk": "./dist/cli.cjs"
18
18
  },
19
19
  "dependencies": {
20
20
  "zod": "3.23.8",