-
Notifications
You must be signed in to change notification settings - Fork 8
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
Showing
11 changed files
with
154 additions
and
35 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,15 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/sern-handler/cli/pkg/extra" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var extraCmd = &cobra.Command{ | ||
Use: "extra", | ||
Short: "Add extra tools to your Sern project.", | ||
Long: `Add extra tools to your Sern project to help you with the setup and development.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
extra.Execute() | ||
}, | ||
} |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package extra | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/gookit/color" | ||
"github.com/sern-handler/cli/pkg/util" | ||
) | ||
|
||
func addDockerfile() error { | ||
var dockerfile string | ||
|
||
_, err := os.Stat("tsconfig.json") | ||
|
||
if err != nil { | ||
dockerfile = "Dockerfile.js" | ||
} else { | ||
dockerfile = "Dockerfile.ts" | ||
} | ||
|
||
color.Info.Prompt("Adding Dockerfile...") | ||
|
||
err = util.CopyFile("templates/extra/"+dockerfile, "Dockerfile") | ||
|
||
if err != nil { | ||
color.Error.Prompt("Couldn't add the Dockerfile, exiting.") | ||
|
||
return err | ||
} | ||
|
||
color.Info.Prompt("Successfully added the Dockerfile.") | ||
|
||
return nil | ||
} |
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,33 @@ | ||
package extra | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/AlecAivazis/survey/v2" | ||
"github.com/gookit/color" | ||
) | ||
|
||
func Execute() { | ||
answers := struct { | ||
Extra string | ||
}{} | ||
|
||
err := survey.Ask(questions, &answers) | ||
|
||
if err != nil { | ||
color.Error.Prompt("Adding extras failed, exiting.") | ||
|
||
os.Exit(1) | ||
} | ||
|
||
switch answers.Extra { | ||
case "Dockerfile": | ||
err = addDockerfile() | ||
|
||
if err != nil { | ||
color.Error.Prompt("Adding the Dockerfile failed, exiting.") | ||
|
||
os.Exit(1) | ||
} | ||
} | ||
} |
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,13 @@ | ||
package extra | ||
|
||
import "github.com/AlecAivazis/survey/v2" | ||
|
||
var questions = []*survey.Question{ | ||
{ | ||
Name: "extra", | ||
Prompt: &survey.Select{ | ||
Message: "What extra do you want to add?", | ||
Options: []string{"Dockerfile"}, | ||
}, | ||
}, | ||
} |
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,11 @@ | ||
FROM node:latest | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json ./ | ||
|
||
RUN npm install | ||
|
||
COPY . . | ||
|
||
RUN node src/index.js |
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,13 @@ | ||
FROM node:latest | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json ./ | ||
|
||
RUN npm install | ||
|
||
COPY . . | ||
|
||
RUN tsc --build | ||
|
||
RUN node dist/index.js |