-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1554a10
commit 19f5c63
Showing
44 changed files
with
8,556 additions
and
37,268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20.1.0 | ||
20.12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ | |
"**/node_modules/*.*" | ||
], | ||
"smartStep": true | ||
} | ||
}, | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/code-generator/generation-logic/features/choose-web-framework.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import path from "path"; | ||
import * as fsExtra from "fs-extra"; | ||
import { generationOptions } from "../generation-options"; | ||
import { | ||
getMicroservicePath, | ||
replacePhraseInAllFiles, | ||
replacePhraseInFile, | ||
} from "../string-manipulation-helpers"; | ||
|
||
export async function chooseWebFramework( | ||
generatedAppRoot: string, | ||
options: generationOptions | ||
) { | ||
const microservicePath = getMicroservicePath(generatedAppRoot); | ||
if (options.webFramework === "express") { | ||
await adjustTheCodeToExpressFramework(microservicePath); | ||
} else if (options.webFramework === "fastify") { | ||
await adjustTheCodeToFastifyFramework(microservicePath); | ||
} | ||
} | ||
|
||
async function adjustTheCodeToFastifyFramework(microservicePath: string) { | ||
const expressFolder = path.join(microservicePath, "entry-points-express"); | ||
await fsExtra.rmdir(expressFolder, { recursive: true }); | ||
const fastifyFolderOldName = path.join( | ||
microservicePath, | ||
"entry-points-fastify" | ||
); | ||
const packageJSONPath = path.join(microservicePath, "package.json"); | ||
await replacePhraseInFile( | ||
packageJSONPath, | ||
'"(.*?)express(.*?)": "(.*)"(,?)\n', | ||
"" | ||
); | ||
const fastifyFolderNewName = path.join(microservicePath, "entry-points"); | ||
await fsExtra.move(fastifyFolderOldName, fastifyFolderNewName, { | ||
overwrite: true, | ||
}); | ||
await replacePhraseInAllFiles( | ||
microservicePath, | ||
"/entry-points-fastify/api/", | ||
"/entry-points/api/" | ||
); | ||
} | ||
|
||
async function adjustTheCodeToExpressFramework(microservicePath: string) { | ||
const fastifyFolder = path.join(microservicePath, "entry-points-fastify"); | ||
await fsExtra.rmdir(fastifyFolder, { recursive: true }); | ||
const expressFolderOldName = path.join( | ||
microservicePath, | ||
"entry-points-express" | ||
); | ||
const packageJSONPath = path.join(microservicePath, "package.json"); | ||
await replacePhraseInFile( | ||
packageJSONPath, | ||
'"(.*?)fastify(.*?)": "(.*)"(,?)\n', | ||
"" | ||
); | ||
const expressFolderNewName = path.join(microservicePath, "entry-points"); | ||
await fsExtra.rename(expressFolderOldName, expressFolderNewName); | ||
await replacePhraseInAllFiles( | ||
microservicePath, | ||
"/entry-points-fastify/api/", | ||
"/entry-points/api/" | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/code-generator/generation-logic/string-manipulation-helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import path from "node:path"; | ||
import * as replacementUtilities from "replace-in-file"; | ||
|
||
export async function replacePhraseInFile( | ||
path: string, | ||
whatToReplaceInRegex: string, | ||
replacement: string | ||
) { | ||
await replacementUtilities.replaceInFile({ | ||
files: path, | ||
from: new RegExp(whatToReplaceInRegex, "g"), | ||
to: replacement, | ||
}); | ||
} | ||
|
||
export async function replacePhraseInAllFiles( | ||
pathToRoot: string, | ||
whatToReplaceInRegex: string, | ||
replacement: string | ||
) { | ||
await replacementUtilities.replaceInFile({ | ||
files: [`${pathToRoot}/**/*.*`], | ||
from: new RegExp(whatToReplaceInRegex, "g"), | ||
to: replacement, | ||
}); | ||
} | ||
|
||
export function getMicroservicePath(rootPath: string) { | ||
return path.join(rootPath, "services", "order-service"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20.1.0 | ||
20.12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export class AppError extends Error { | ||
constructor( | ||
public name: string, | ||
public message: string, | ||
public HTTPStatus: number = 500, | ||
public isCatastrophic = false, | ||
public cause?: unknown | ||
) { | ||
super(message); | ||
} | ||
} |
Oops, something went wrong.