@digicroz/node-backend-kit 1.0.0 → 1.0.1

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.
@@ -125,14 +125,16 @@ export const b2fPortalInit = async (b2fPortalProjects) => {
125
125
  });
126
126
  return;
127
127
  }
128
- const repositoryBackedPortalPath = join(repositoryPath, "b2fPortal");
129
- if (!fs.existsSync(repositoryBackedPortalPath)) {
128
+ const repositoryBackedPortalDirPath = join(repositoryPath, section.repository.dirPath || "b2fPortal");
129
+ if (!fs.existsSync(repositoryBackedPortalDirPath)) {
130
130
  console.log("repositoryBackedPortalPath does not exist");
131
- console.log({ repositoryBackedPortalPath });
131
+ console.log({
132
+ repositoryBackedPortalPath: repositoryBackedPortalDirPath,
133
+ });
132
134
  return;
133
135
  }
134
- const repositoryDistTrpcApiPath = join(repositoryBackedPortalPath, sectionDistTrpcApiPath.replace(clientRootDirPath, ""));
135
- const repositoryPrismaClientPath = join(repositoryBackedPortalPath, projectPrismaClientPath.replace(clientRootDirPath, ""));
136
+ const repositoryDistTrpcApiPath = join(repositoryBackedPortalDirPath, sectionDistTrpcApiPath.replace(clientRootDirPath, ""));
137
+ const repositoryPrismaClientPath = join(repositoryBackedPortalDirPath, projectPrismaClientPath.replace(clientRootDirPath, ""));
136
138
  createModuleFiles(sectionSrcTrpcApiModulePath);
137
139
  // create zod files
138
140
  createZodFiles(sectionSrcTrpcApiModulePath);
@@ -145,25 +147,25 @@ export const b2fPortalInit = async (b2fPortalProjects) => {
145
147
  console.warn(error);
146
148
  }
147
149
  // sync serverB2f
148
- const repositoryServerB2fPath = join(repositoryBackedPortalPath, "serverB2f");
150
+ const repositoryServerB2fPath = join(repositoryBackedPortalDirPath, "serverB2f");
149
151
  await syncFilesAndFolders({
150
152
  sourceDirPath: serverB2fPath,
151
153
  targetDirPath: repositoryServerB2fPath,
152
154
  });
153
155
  // sync projectB2f
154
- const repositoryProjectB2fPath = join(repositoryBackedPortalPath, "projectB2f");
156
+ const repositoryProjectB2fPath = join(repositoryBackedPortalDirPath, "projectB2f");
155
157
  await syncFilesAndFolders({
156
158
  sourceDirPath: projectB2fPath,
157
159
  targetDirPath: repositoryProjectB2fPath,
158
160
  });
159
161
  // sync section common
160
- const repositorySectionB2fPath = join(repositoryBackedPortalPath, section.sectionName, "sectionB2f");
162
+ const repositorySectionB2fPath = join(repositoryBackedPortalDirPath, section.sectionName, "sectionB2f");
161
163
  await syncFilesAndFolders({
162
164
  sourceDirPath: sectionB2fPath,
163
165
  targetDirPath: repositorySectionB2fPath,
164
166
  });
165
167
  // sync zod schemas
166
- const repositoryTrpcApiPath = join(repositoryBackedPortalPath, section.sectionName, "trpcApi");
168
+ const repositoryTrpcApiPath = join(repositoryBackedPortalDirPath, section.sectionName, "trpcApi");
167
169
  await syncFilesAndFolders({
168
170
  sourceDirPath: sectionSrcTrpcApiPath,
169
171
  targetDirPath: repositoryTrpcApiPath,
@@ -187,7 +189,7 @@ export const b2fPortalInit = async (b2fPortalProjects) => {
187
189
  });
188
190
  if (section.needNextJsPatch) {
189
191
  // console.log("Next Js Patch started");
190
- const tsFiles = getTsFiles(repositoryBackedPortalPath);
192
+ const tsFiles = getTsFiles(repositoryBackedPortalDirPath);
191
193
  tsFiles.forEach((filePath) => {
192
194
  updateImports(filePath);
193
195
  });
package/dist/types.d.ts CHANGED
@@ -9,6 +9,7 @@ export type TNbkProjectSection = {
9
9
  repository: {
10
10
  name: string;
11
11
  path: string;
12
+ dirPath?: string;
12
13
  };
13
14
  localPath: string;
14
15
  isZodCreator: boolean;
@@ -186,6 +186,13 @@ function validateSection(section, projectName, index) {
186
186
  if (!section.repository.path) {
187
187
  throw new Error(`Section "${section.sectionName}" in project "${projectName}" has repository missing "path"`);
188
188
  }
189
+ // Optional fields with defaults
190
+ if (!section.repository.dirPath) {
191
+ section.repository.dirPath = "b2fPortal";
192
+ }
193
+ else if (typeof section.repository.dirPath !== "string") {
194
+ throw new Error(`Section "${section.sectionName}" in project "${projectName}" has invalid "dirPath" in repository. Must be a string.`);
195
+ }
189
196
  if (!section.localPath) {
190
197
  throw new Error(`Section "${section.sectionName}" in project "${projectName}" is missing "localPath"`);
191
198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digicroz/node-backend-kit",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "NodeJS Backend Kit - A powerful TypeScript utility for managing backend projects with features like B2F Portal integration, cross-project validation, and Next.js support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -77,4 +77,4 @@
77
77
  "rimraf": "^6.0.1",
78
78
  "simple-git": "^3.27.0"
79
79
  }
80
- }
80
+ }