You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+62-47Lines changed: 62 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@
6
6
-[How it Works](#how-it-works)
7
7
-[Configuration](#configuration)
8
8
-[Data repository](#data-repository)
9
+
-[Migration from versions prior to v0.13.0](#migration-from-versions-prior-to-v0130)
9
10
-[Summon config File](#summon-config-file)
10
11
-[Build](#build)
11
12
-[Install](#install)
@@ -45,27 +46,40 @@ state (packed scripts or pinned versions of binaries).
45
46
46
47
> NOTE: This project is still a WIP and experimental.
47
48
48
-
To install, you first need to create something to install by populating a [data repository](#Configuration). Then, this data repo is installed by using [gobin](https://github.com/myitcv/gobin) (or go install):
49
+
To install, you first need to create something to install by populating a
50
+
[data repository](#Configuration). Then, this data repo is installed by using
51
+
the `go install` command:
49
52
50
53
```bash
51
-
gobin [your-summon-data-repo]/summon
54
+
go install [your-summon-data-repo]/summon@latest
52
55
```
53
56
54
-
Assuming there is a my-team-utility.sh script hosted in the data repo, (see how to [configure](#Configuration) below) you can do things like:
57
+
Assuming there is a my-team-utility.sh script hosted in the data repo, (see how
58
+
to [configure](#Configuration) below) you can do things like:
55
59
56
60
```bash
57
61
bash $(summon my-team-utility.sh)
58
62
```
59
63
60
64
## How it Works
61
65
62
-
Summon is a library which is consumed by an asset repository (which, by default, has also the `summon` name). This asset repository, managed by your team, provides the summon executable command (it's main() function is in summon/summon.go).
63
-
The library provides the command-line interface, so no coding is necessary in the assert repo.
66
+
Summon is a library which is consumed by an asset repository (which, by default,
67
+
has also the `summon` name). This asset repository, managed by your team,
68
+
provides the summon executable command (it's main() function is in
69
+
summon/summon.go). The library provides the command-line interface, so no
70
+
coding is necessary in the assert repo.
64
71
65
72
Summon also provides a boostrapping feature in the scaffold command.
66
73
67
-
Summon builds upon [packr2](https://github.com/gobuffalo/packr/tree/master/v2) to convert an arbitrary tree of files in go compilable source
68
-
which you then bootstrap at destination using standard go get or [gobin](https://github.com/myitcv/gobin). The invoked files are then placed locally and the summoned file path is returned so it can be consumed by other shell operations.
74
+
> New in v0.13.0
75
+
76
+
Summon builds upon the new go 1.16 [embed.FS](https://pkg.go.dev/embed) feature
77
+
used to pack assets in a go binary. You then install this at destination using
78
+
standard `go install`.
79
+
80
+
When you invoke this binary with a contained asset path, the invoked files are
81
+
placed locally and the summoned file path is returned so it can be consumed by
82
+
other shell operations.
69
83
70
84
## Configuration
71
85
@@ -76,38 +90,49 @@ Use summon's scaffold feature to create a data repository, which will become you
# go run package at a version requires go 1.17 and up
94
+
go run github.com/davidovich/summon/scaffold@latest init [module name]
80
95
```
81
96
82
-
> Be sure to change the [module name] part (usually you will use a module path compatible with where you will host the data repo on a code hosting site).
97
+
> Be sure to change the [module name] part (usually you will use a module path
98
+
> compatible with where you will host the data repo on a code hosting site).
83
99
84
100
You will then have something resembling this structure:
85
101
86
102
```bash
87
103
.
88
104
├── Makefile
89
105
├── README.md
90
-
├── assets
91
-
│ └── summon.config.yaml
92
106
├── go.mod
107
+
├── go.sum
93
108
└── summon
109
+
├── assets
110
+
│ └── summon.config.yaml
94
111
└── summon.go
95
112
```
96
113
97
114
There is an example setup at https://github.com/davidovich/summon-example-assets.
98
115
99
-
You just need to populate the `assets` directory with your own data.
116
+
You just need to populate the `summon/assets` directory with your own data.
117
+
118
+
The `summon/summon.go` file of the main module is the entry point to the summon
119
+
library, and creates the main command executable.
100
120
101
-
The `summon/` directory is the entry point to the summon library, and creates the main command executable. This directory will also host
102
-
[packr2](https://github.com/gobuffalo/packr/tree/master/v2) generated data files which encode asset data into go files.
121
+
#### Migration from versions prior to v0.13.0
122
+
123
+
The v0.13.0 version uses the embed.FS and the `//go:embed assets/*` directive.
124
+
Prior versions used to reference the `assets/` dir at the root of the repo.
125
+
This means that the data being embeded must now be a sibling of the source
126
+
file containing `package main`.
103
127
104
128
### Summon config File
105
129
106
-
The `assets/summon.config.yaml` is an (optional) configuration file to customize summon. You can define:
130
+
The `summon/assets/summon.config.yaml` is an (optional) configuration file to
131
+
customize summon. You can define:
107
132
108
-
* aliases
109
-
* default output-dir
110
-
* executables
133
+
- aliases
134
+
- default output-dir
135
+
- executables
111
136
112
137
> Breaking in v0.11.0: Handles now take an array of params
113
138
@@ -138,9 +163,8 @@ exec:
138
163
# ^ handle to script (must be unique). This is what you use
139
164
# to invoke the script: `summon run hello`.
140
165
141
-
gobin -run: # go gettable executables
142
-
gobin: [github.com/myitcv/gobin@v0.0.8]
143
-
gohack: [github.com/rogppepe/gohack]
166
+
go run: # go gettable executables
167
+
gohack: [github.com/rogppepe/gohack@latest]
144
168
145
169
python -c:
146
170
hello-python: [print("hello from python!")]
@@ -161,7 +185,8 @@ You can invoke executables like so:
161
185
summon run gohack ...
162
186
```
163
187
164
-
This will install gohack using `gobin -run` and forward the arguments that you provide.
188
+
This will call and run gohack using `go run` and forward the arguments that you
189
+
provide.
165
190
166
191
> New in v0.10.0, summon now allows templating in the invocable section. See
167
192
> [Templating](#/templating).
@@ -170,35 +195,22 @@ This will install gohack using `gobin -run` and forward the arguments that you p
170
195
171
196
In an empty asset data repository directory:
172
197
173
-
* First (and once) invoke `go run github.com/davidovich/summon/scaffold init [repo host (module name)]`
198
+
- First (and once) invoke `go run github.com/davidovich/summon/scaffold@latest init [repo host (module name)]`
174
199
This will create code template similar as above
175
200
176
201
1. Add assets that need to be shared amongst consumers
177
-
2. Use the provided Makefile to invoke the packr2 process: `make`
178
-
3. Commit the resulting -packr files so clients can go get the data repo
202
+
2. Use the provided Makefile to create the asset executable: `make`
203
+
3. Commit the all the files so clients can go get the data repo
179
204
4. Tag the repo with semantic version (with the `v`) prefix.
180
205
5. Push to remote.
181
-
6.Install.
206
+
6.On a consumer machine, install.
182
207
183
208
## Install
184
209
185
-
Install (using gobin) the asset repo which will become the summon executable.
186
-
You have these alternatives:
187
-
188
-
* change to a directory that does not contain a go.mod. This installs globally:
189
-
190
-
```bash
191
-
cd /tmp
192
-
GO111MODULE=on go get [your-go-repo-import]/summon[@wanted-version-or-branch]
193
-
cd -
194
-
```
195
-
196
-
* use gobin to install summon in the consuming site:
210
+
Install (using `go install`) the asset repo which will become the summon executable.
197
211
198
212
```bash
199
-
GO111MODULE=off go get -u github.com/myitcv/gobin
200
-
# install the data repository as summon executable at the site
@@ -212,12 +224,13 @@ summon returns the path ot where the resource was instantiated:
212
224
include $(shell summon version.mk)
213
225
```
214
226
215
-
By default, summon will put summoned scripts at the `.summoned/` directory at root of the current directory.
227
+
By default, summon will put summoned scripts at the `.summoned/` directory at
228
+
the root of the current directory. This can be changed with the `-o` flag.
216
229
217
230
### Templating
218
231
219
232
Files in the asset directory can contain go templates. This allows applying
220
-
customization using json data.
233
+
customization using json data, just before rendering the file (and its contents).
221
234
222
235
> New in v0.3.0, summon now uses the [Sprig templating library](https://github.com/Masterminds/sprig), which provides many useful templating functions.
223
236
@@ -230,21 +243,23 @@ For example, consider this file in a summon asset provider:
0 commit comments