-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move classes into separate files
Part of #31
- Loading branch information
Showing
6 changed files
with
77 additions
and
75 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
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,23 @@ | ||
const JsGenerator = require('./JsGenerator') | ||
const TsGenerator = require('./TsGenerator') | ||
const GoGenerator = require('./GoGenerator') | ||
const PyGenerator = require('./PyGenerator') | ||
|
||
module.exports = class Generator { | ||
|
||
static for(lang) { | ||
switch (lang) { | ||
case 'js': | ||
return new JsGenerator() | ||
case 'ts': | ||
return new TsGenerator() | ||
case 'go': | ||
return new GoGenerator() | ||
case 'python': | ||
return new PyGenerator() | ||
default: | ||
throw new Error(`Unsupported language: ${lang}`) | ||
} | ||
} | ||
|
||
} |
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,14 @@ | ||
module.exports = class GoGenerator { | ||
|
||
usageExampleAsText() { | ||
return `Use | ||
export DB_NAME=db DB_USER=user DB_PASSWORD=secret | ||
go run *.go | ||
or | ||
go build -o app | ||
export DB_NAME=db DB_USER=user DB_PASSWORD=secret | ||
./app | ||
to build and run it` | ||
} | ||
|
||
} |
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,12 @@ | ||
module.exports = class JsGenerator { | ||
|
||
usageExampleAsText() { | ||
return `Use | ||
npm install | ||
to install its dependencies and | ||
export DB_NAME=db DB_USER=user DB_PASSWORD=secret | ||
npm start | ||
afteward to run` | ||
} | ||
|
||
} |
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,12 @@ | ||
module.exports = class PyGenerator { | ||
|
||
usageExampleAsText() { | ||
return `Use | ||
pip install -r requirements.txt | ||
to install its dependencies and | ||
export DB_NAME=db DB_USER=user DB_PASSWORD=secret | ||
uvicorn app:app | ||
afteward to run` | ||
} | ||
|
||
} |
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,14 @@ | ||
module.exports = class TsGenerator { | ||
|
||
usageExampleAsText() { | ||
return `Use | ||
npm install | ||
to install its dependencies, | ||
npm run build | ||
to build the application, and | ||
export DB_NAME=db DB_USER=user DB_PASSWORD=secret | ||
npm start | ||
afteward to run` | ||
} | ||
|
||
} |