Skip to content

Commit

Permalink
Updated to v1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaikech committed Oct 20, 2017
1 parent 91154e1 commit 5263f47
Show file tree
Hide file tree
Showing 16 changed files with 1,908 additions and 1,557 deletions.
1,609 changes: 63 additions & 1,546 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Will you want to develop GAS on your local PC? Generally, when we develop GAS, w
7. Download revision files from Google Drive.
8. Rearranges scripts in project.
You can see the release page https://github.com/tanaikech/ggsrun/releases
# Google API
Expand Down
12 changes: 10 additions & 2 deletions ggsrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
func main() {
app := cli.NewApp()
app.Name = appname
app.Author = "tanaike [ https://github.com/tanaikech/ggsrun ] "
app.Author = "Tanaike [ https://github.com/tanaikech/ggsrun ] "
app.Email = "[email protected]"
app.Usage = "Executes Google Apps Script (GAS) on Google and Feeds Back Results."
app.Version = "1.3.1"
app.Version = "1.3.2"
app.Commands = []cli.Command{
{
Name: "exe1",
Expand Down Expand Up @@ -221,6 +221,14 @@ func main() {
Name: "backup, b",
Usage: "Backup project with project ID you set as a file.",
},
cli.BoolFlag{
Name: "rearrange, r",
Usage: "Interactively rearrange scripts in project using your terminal.",
},
cli.StringFlag{
Name: "rearrangewithfile, rf",
Usage: "Rearrange scripts in project using a file.",
},
cli.BoolFlag{
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
Expand Down
1,594 changes: 1,594 additions & 0 deletions help/README.md

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions help/UpdateHistory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
ggsrun
=====

<a name="TOP"></a>
# Update History

## ggsrun
* v1.0.0 (April 24, 2017)

Initial release.

* v1.1.0 (April 28, 2017)

1. Added a command for updating existing project on Google Drive. The detail information is [here](help/README.md#Update_Project).
2. Added "TotalElapsedTime" for Show File List and Search Files.
3. Some modifications.

* v1.2.0 (May 19, 2017)

1. Added a command for retrieving revision files on Google Drive. The detail information is [here](help/README.md#RevisionFile).
2. Some modifications.

* v1.2.1 (May 28, 2017)

1. ggsrun.cfg got be able to be read using the environment variable.
- If the environment variable (**``GGSRUN_CFG_PATH``**) is set, ggsrun.cfg is read using it.
- If it is not set, ggsrun.cfg is read from the current working directory. This is as has been the way until now.
- This is the response for some requests.
- This incofmation was added to [here](help/README.md#environmentvariable).

* v1.2.2 (July 12, 2017)

1. For Google Docs (spreadsheet, document, slide and drawing), since I noticed that the revision files would not be able to be retrieved using Drive API v3, I modified this using new workaround.
- The new workaround is to use Drive API v2. ``drive.revisions.get`` of Drive API v2 can retrieve not only the revision list, but also the export links. I thought of the use of the export links. This became the new workaround.
- For the files except for Google Docs, the revision files can be retrieved using Drive API v3.
- The usage is [here](help/README.md#RevisionFile).

I don't know when this workaround will not be able to be used. But if this could not be used, I would like to investigate of other method.

* v1.3.0 (August 30, 2017)

1. From this version, [container-bound scripts](https://developers.google.com/apps-script/guides/bound) can be downloaded. The container-bound script is the script created at the script editor on Google Sheets, Docs, or Forms file. The usage is [here](help/README.md#DownloadBoundScript).
- In order to download container-bound scripts, the project ID of container-bound scripts is required. The project ID can be retrieved as follows.
- Open the project. And please operate follows using click.
- -> File
- -> Project properties
- -> Get Script ID (**This is the project ID.**)
1. When a project is downloaded, the filename of HTML file had become ``.gs``. This bug was modified.

* v1.3.1 (September 15, 2017)

1. Recently, when scripts on local PC is uploaded to Google Drive as a new project, the time to create on Google became a bit long. (I think that this is due to Google Update.) Under this situation, when the script is uploaded, the timeout error occurs while the new project is created using the script. So the time until timeout of fetch was modified from 10 seconds to 30 seconds. By this, when the script is uploaded, no error occurs and the information of the created project is shown.
- You can create a new project on Google Drive using scripts on local PC. The sample command is ``ggsrun u -f sample.gs1,sample2.gs,sample3.html -pn newprojectname``

* v1.3.2 (October 20, 2017)

1. Updated ggsrun's Install manual (README.md). Since I thought that the manual became too complicated, I separated it to [the simple version](https://github.com/tanaikech/ggsrun/) and [the detail version](https://github.com/tanaikech/ggsrun/help). And also , recently, since Google's specification was updated, about how to deploy API executable and enable APIs for ggsrun's Install manual were updated.
1. From this version, scripts in a project can be rearranged. The rearrangement can be done by interactively on your terminal and/or a configuration file. The usage is [here](help/README.md#rearrangescripts)
- For rearranging scripts, there is one important point. **When scripts in a project is rearranged, version history of scripts is reset once. So if you don't want to reset the version history, before rearranging, please copy the project.** By copying project, the project before rearranging is saved.

## Server
* v1.0.0 (April 24, 2017)

Initial release.

[TOP](#TOP)
Binary file added help/images/demo_rearrange.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added help/images/spreadsheetdemo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 41 additions & 9 deletions projectupdater.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package main

import (
"bufio"
"fmt"
"os"
"path/filepath"
Expand All @@ -14,18 +15,49 @@ import (

// projectUpdateControl : Main method for updating project.
func (e *ExecutionContainer) projectUpdateControl(c *cli.Context) *utl.FileInf {
if len(c.String("filename")) == 0 {
fmt.Fprintf(os.Stderr, "Error: No Files. Please set them using '-f [ File name ]'. ")
os.Exit(1)
}
if len(c.String("projectid")) > 0 {
e.GgsrunCfg.Scriptid = c.String("projectid")
if len(c.String("filename")) > 0 {
return e.defUpdateProjectContainer(c).
projectBackup(c).
ProjectMaker().
projectUpdate().
dispUpdateProjectContainer()
}
if c.Bool("rearrange") {
e.defUpdateProjectContainer(c).
projectBackup(c).
rearrangeByTerminal()
}
if len(c.String("rearrangewithfile")) > 0 {
var data []string
f, err := os.Open(c.String("rearrangewithfile"))
if err != nil {
fmt.Fprintf(os.Stderr, "Error: Script '%s' is not found.\n", c.String("rearrangewithfile"))
os.Exit(1)
}
defer f.Close()
scanner := bufio.NewScanner(f)
for scanner.Scan() {
if scanner.Text() == "end" {
break
}
if scanner.Text() != "" {
data = append(data, scanner.Text())
}
}
if scanner.Err() != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", scanner.Err())
os.Exit(1)
}
e.defUpdateProjectContainer(c).
projectBackup(c).
rearrangeByFile(data)
}
} else {
e.Msg = append(e.Msg, "Error: No options. Please check HELP using 'ggsrun ud -help'.")
}
return e.defUpdateProjectContainer(c).
projectBackup(c).
ProjectMaker().
projectUpdate().
dispUpdateProjectContainer()
return e.dispUpdateProjectContainer()
}

// ProjectMaker : Recreates the project using uploaded scripts.
Expand Down
132 changes: 132 additions & 0 deletions scriptrearrange.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// Package main (scriptrearrange.go) :
// These methods are for rearranging scripts in a project.
package main

import (
"fmt"
"os"
"strconv"
"strings"
"time"

"github.com/briandowns/spinner"
rearrange "github.com/tanaikech/go-rearrange"
)

// rearrangeByTerminal : Rearranging scripts in a project using go-rearrange.
func (e *ExecutionContainer) rearrangeByTerminal() {
var baseProject Project
baseProject = *e.Project
var scripts []string
for _, f := range e.Project.Files {
scripts = append(scripts, f.Name)
}
changedIndx, _, err := rearrange.Do(scripts, 3, false, true)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
var input string
fmt.Printf("## Please be careful.\n")
fmt.Printf("## When the script is rearranged, the revision of script is reset once.\n")
fmt.Printf("Reflect the rearranged result? [y or n] ... ")
if _, err := fmt.Scan(&input); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
if input == "y" {
s := spinner.New([]string{"/", "|", "\\", "|"}, 100*time.Millisecond)
s.UpdateSpeed(200 * time.Millisecond)
fmt.Printf("Please wait a moment...")
s.Start()
e.rearrange(baseProject, changedIndx)
s.Stop()
fmt.Printf("\n")
return
} else {
e.Msg = append(e.Msg, "Scripts of project were NOT rearranged.")
return
}
}

// rearrange : Rearranging scripts in a project using a configuration file.
func (e *ExecutionContainer) rearrangeByFile(data []string) {
var baseProject Project
baseProject = *e.Project
var temp []string
dupChk := map[string]bool{}
for _, e := range data {
if !dupChk[e] {
dupChk[e] = true
temp = append(temp, e)
}
}
if len(temp) == len(data) {
if len(e.Project.Files) == len(data) {
cn := 0
for i, e := range e.Project.Files {
if e.Name == data[i] {
cn += 1
}
}
if cn != len(e.Project.Files) {
cn = 0
var changedIndx []string
for _, f := range data {
for i, g := range e.Project.Files {
if g.Name == f {
cn += 1
changedIndx = append(changedIndx, strconv.Itoa(i))
}
}
}
if cn == len(e.Project.Files) {
e.rearrange(baseProject, changedIndx)
return
} else {
e.Msg = append(e.Msg, "Error: Script names of inputted file are different for script names in project.")
return
}
} else {
e.Msg = append(e.Msg, "Error: Order of inputted file are the same to the order in project.")
return
}
} else {
e.Msg = append(e.Msg, "Error: Number of script names of inputted file are different for number of scripts in project.")
return
}
} else {
e.Msg = append(e.Msg, "Error: There are duplicated names in script names of inputted file.")
return
}
}

// rearrange : Main method for rearranging scripts.
func (e *ExecutionContainer) rearrange(baseProject Project, changedIndx []string) {
var temp1 Project
const layout = "20060102_150405_"
t := time.Now()
dummyScript := &File{
Name: "Dummy_" + t.Format(layout) + t.AddDate(0, 0, 2).Weekday().String(),
Source: "// This is a dummy.",
Type: "server_js",
}
temp1.Files = append(temp1.Files, *dummyScript)
e.Project = &temp1
e.projectUpdate()
var temp2 Project
for i, e := range changedIndx {
idx, _ := strconv.Atoi(e)
temp2.Files = append(temp2.Files, baseProject.Files[idx])
temp2.Files[i].ID = ""
}
e.Project = &temp2
e.projectUpdate()
var from, to []string
for i, f := range e.Project.Files {
from = append(from, baseProject.Files[i].Name)
to = append(to, f.Name)
}
msg := fmt.Sprintf("Scripts in project were rearranged from [%s] to [%s].", strings.Join(from, ", "), strings.Join(to, ", "))
e.Msg = []string{msg}
}

0 comments on commit 5263f47

Please sign in to comment.