mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-23 15:31:26 +00:00
Initial commit
This commit is contained in:
51
revel/package.go
Normal file
51
revel/package.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/revel/revel"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var cmdPackage = &Command{
|
||||
UsageLine: "package [import path]",
|
||||
Short: "package a Revel application (e.g. for deployment)",
|
||||
Long: `
|
||||
Package the Revel web application named by the given import path.
|
||||
This allows it to be deployed and run on a machine that lacks a Go installation.
|
||||
|
||||
For example:
|
||||
|
||||
revel package github.com/revel/revel/samples/chat
|
||||
`,
|
||||
}
|
||||
|
||||
func init() {
|
||||
cmdPackage.Run = packageApp
|
||||
}
|
||||
|
||||
func packageApp(args []string) {
|
||||
if len(args) == 0 {
|
||||
fmt.Fprint(os.Stderr, cmdPackage.Long)
|
||||
return
|
||||
}
|
||||
|
||||
appImportPath := args[0]
|
||||
revel.Init("", appImportPath, "")
|
||||
|
||||
// Remove the archive if it already exists.
|
||||
destFile := filepath.Base(revel.BasePath) + ".tar.gz"
|
||||
os.Remove(destFile)
|
||||
|
||||
// Collect stuff in a temp directory.
|
||||
tmpDir, err := ioutil.TempDir("", filepath.Base(revel.BasePath))
|
||||
panicOnError(err, "Failed to get temp dir")
|
||||
|
||||
buildApp([]string{args[0], tmpDir})
|
||||
|
||||
// Create the zip file.
|
||||
archiveName := mustTarGzDir(destFile, tmpDir)
|
||||
|
||||
fmt.Println("Your archive is ready:", archiveName)
|
||||
}
|
||||
Reference in New Issue
Block a user