-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
shard.yml.adoc
439 lines (386 loc) · 12.4 KB
/
shard.yml.adoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
= shard.yml(5)
:date: {localdate}
:shards_version: {shards_version}
:man manual: File Formats
:man source: shards {shards_version}
== NAME
shard.yml - metadata for projects managed by shards(1)
== DESCRIPTION
The file _shard.yml_ is a YAML file with metadata about a project managed by shards, known as a *shard*. It must contain at least _name_ and _version_ attributes plus optional additional attributes.
Both libraries and applications will benefit from `shard.yml`.
The metadata for libraries are expected to have more information (e.g., list of
authors, description, license) than applications that may only have a name, version and
dependencies.
== FORMAT
The file must be named _shard.yml_ and be a valid YAML file with UTF-8 encoding.
It must not contain duplicate attributes in any mapping.
It should use an indent of 2 spaces.
It should not use advanced YAML features, only simple mappings, sequences and
strings (Failsafe Schema).
== REQUIRED ATTRIBUTES
*name*::
The name of the project (string, required).
+
--
- It must be unique.
- It must be 50 characters or less.
- It should be lowercase (a-z).
- It should not contain _crystal_.
- It may contain digits (0-9) but not start with one.
- It may contain underscores or dashes but not start/end with one.
- It must not have consecutive underscores or dashes.
--
+
Examples: _minitest_, _mysql2_, _battery-horse_.
*version*::
The version number of the project (string, required).
+
--
- It must contain digits.
- It may contain dots and dashes but not consecutive ones.
- It may contain a letter to make it a 'prerelease'.
--
+
Examples: _1.2.3_, _2.0.0.1_, _1.0.0.alpha_ _2.0.0-rc1_ or _2016.09_.
+
While Shards doesn't enforce it, following a rational versioning scheme like
http://semver.org/[Semantic Versioning] or http://calver.org/[Calendar Versioning]
is highly recommended.
== OPTIONAL ATTRIBUTES
*authors*::
A list of authors, along with their contact email (optional) (sequence of string).
+
--
- Each author must have a name.
- Each author may have an email address, within angle bracket (_<_ and _>_)
chars.
--
+
*Example:*
+
[source,yaml]
----
authors:
- Ary
- Julien Portalier <[email protected]>
----
*crystal*::
A restriction to indicate which are the supported crystal versions. This will
usually express a lower and upper-bound constraints (string, recommended)
+
When resolving dependencies, this information is not used. After dependencies
have been determined shards checks all of them are expected to work with
the current crystal version. If not, a warning appears for the offending
dependencies. The resolved versions are installed and can be used at your
own risk.
+
The valid values are mostly the same as for _dependencies.version_:
+
--
* A version number prefixed by an operator: _<_, _\<=_, _>_, _>=_, _!=_ or _~>_.
* Just _"*"_ if any version will do (this is the default if unspecified).
* Multiple requirements can be separated by commas.
--
There is a special legacy behavior (its use is discouraged) when just a version
number is used as the value: it works exactly the same as a `>=` check:
_x.y.z_ is interpreted as _">= x.y.z"_
+
You are welcome to also specify the upper bound to be lower than the next
(future) major Crystal version, because there's no guarantee that it won't
break your library.
+
*Example:*
+
[source,yaml]
----
crystal: ">= 0.35, < 2.0"
----
*dependencies*::
A list of required dependencies (mapping).
+
Each dependency begins with the name of the dependency as a key (string) then a
list of attributes (mapping) that depend on the resolver type.
+
*Example:*
+
[source,yaml]
----
dependencies:
minitest:
github: ysbaddaden/minitest.cr
version: 0.1.0
----
*development_dependencies*::
A list of dependencies required to work on the project, but not necessary
to build and run the project (mapping).
+
They will be installed for the main project or library itself.
When the library is installed as a dependency for another project the
development dependencies will never be installed.
+
Development dependencies follow the same scheme as dependencies.
+
*Example:*
+
[source,yaml]
----
development_dependencies:
minitest:
github: ysbaddaden/minitest.cr
version: ~> 0.1.3
----
*description*::
A single line description of the project (string, recommended).
*documentation*::
The URL to a website providing the project's documentation for online browsing (string).
*executables*::
A list of executables to be installed (sequence).
+
The executables can be of any type or language (e.g., shell, binary, ruby), must
exist in the _bin_ folder of the Shard, and have the executable bit set (on
POSIX platforms). When installed as a dependency for another project the
executables will be copied to the _bin_ folder of that project.
+
Executables are always installed last, after the _postinstall_ script is run, so
libraries can build the executables when they are installed by Shards. Installation
can be disabled by passing the flag _--skip-executables_.
+
*Example:*
+
[source,yaml]
----
executables:
- micrate
- icr
----
*homepage*::
The URL of the project's homepage (string).
*libraries*::
A list of shared libraries the shard tries to link to (mapping).
+
This field is purely informational. It serves as a canonical way to discover
non Crystal dependencies in shards, both for tools as well as humans.
+
A shard must only list libraries it directly links to, it must not include
libraries that are only referenced by dependencies. It must include all libraries
it directly links to, regardless of a dependency doing it too.
+
It should map from the soname without any extension, path or version,
for example _libsqlite3_ for _/usr/lib/libsqlite3.so.0.8.6_, to a version
constraint.
+
The version constraint has the following format:
+
--
- It may be a version number.
- It may be _"*"_ if any version will do.
- The version number may be prefixed by an operator: _<_, _\<=_, _>_, _>=_, _!=_ or _~>_.
--
+
[source,yaml]
----
libraries:
libQt5Gui: "*"
libQt5Help: "~> 5.7"
libQtBus: ">= 4.8"
----
*license*::
An http://opensource.org/[OSI license] name or an URL to a license file
(string, recommended).
*repository*::
The URL of the project's canonical repository (string, recommended).
+
The URL should be compatible with typical VCS tools without modifications.
_http_/_https_ is preferred over VCS schemes like _git_.
It is recommended that this URL is publicly available.
+
Copies of a shard (such as mirrors, development forks etc.) should point to the same
canonical repository address, even if hosted at different locations.
+
*Example:*
+
[source,yaml]
----
repository: "https://github.com/crystal-lang/shards"
----
*scripts*::
Script hooks to run. Only _postinstall_ is supported.
+
Shards may run scripts automatically after certain actions. The scripts
themselves are mere shell commands.
*postinstall*:::
The _postinstall_ hook of a dependency will be run whenever that dependency is
installed or upgraded in a project that requires it. This may be used to compile
a C library, to build tools to help working on the project, or anything else.
+
The script will be run from the dependency's installation directory, for example
_lib/foo_ for a Shard named _foo_.
+
*Example:*
+
[source,yaml]
----
scripts:
postinstall: cd src/libfoo && make
----
*targets*::
A list of targets to build (mapping).
+
Each target begins with the name of the target as a key (string), then a list of
attributes (mapping). The target name is the built binary name, created in the
_bin_ folder of the project.
+
*Example:*
+
[source,yaml]
----
targets:
server:
main: src/server/cli.cr
worker:
main: src/worker.cr
----
+
The above example will build _bin/server_ from _src/server/cli.cr_ and
_bin/worker_ from _src/worker.cr_.
*main*:::
A path to the source file to compile (string).
== DEPENDENCY ATTRIBUTES
Each dependency needs at least one attribute that defines the resolver for this
dependency. Those can be _path_, _git_, _github_, _gitlab_, _bitbucket_.
*path*::
A local path (string).
+
The library will be installed as a symlink to the local path.
The _version_ attribute isn't required but will be used if present to validate
the dependency.
*git*::
A Git repository URL (string).
+
The URL may be https://git-scm.com/docs/git-clone#_git_urls[any protocol]
supported by Git, which includes SSH, GIT and HTTPS.
+
The Git repository will be cloned, the list of versions (and associated
_shard.yml_) will be extracted from Git tags (e.g., _v1.2.3_).
+
One of the other attributes (_version_, _tag_, _branch_ or _commit_) is
required. When missing, Shards will install the HEAD refs.
+
*Example:* _git: git://git.example.org/crystal-library.git_
*github*::
GitHub repository URL as _user/repo_ (string)
+
Extends the _git_ resolver, and acts exactly like it.
+
*Example:* _github: ysbaddaden/minitest.cr_
*gitlab*::
GitLab repository URL as _user/repo_ (string).
+
Extends the _git_ resolver, and acts exactly like it.
+
Only matches dependencies hosted on _gitlab.com_. For personal GitLab
installations, you must use the generic _git_ resolver.
+
*Example:* _gitlab: thelonlyghost/minitest.cr_
*bitbucket*::
Bitbucket repository URL as _user/repo_ (string).
+
Extends the _git_ resolver, and acts exactly like it.
+
*Example:* _bitbucket: tom/library_
*hg*::
A Mercurial repository URL (string).
+
The URL may be https://www.mercurial-scm.org/repo/hg/help/clone[any protocol]
supported by Mercurial, which includes SSH and HTTPS.
+
The Mercurial repository will be cloned, the list of versions (and associated
_shard.yml_) will be extracted from Mercurial tags (e.g., _v1.2.3_).
+
One of the other attributes (_version_, _tag_, _branch_, _bookmark_ or _commit_) is
required. When missing, Shards will install the _@_ bookmark or _tip_.
+
*Example:* _hg: https://hg.example.org/crystal-library_
*fossil*::
A https://www.fossil-scm.org[Fossil] repository URL (string).
+
The URL may be https://fossil-scm.org/home/help/clone[any protocol]
supported by Fossil, which includes SSH and HTTPS.
+
The Fossil repository will be cloned, the list of versions (and associated
_shard.yml_) will be extracted from Fossil tags (e.g., _v1.2.3_).
+
One of the other attributes (_version_, _tag_, _branch_, or _commit_) is
required. When missing, Shards will install _trunk_.
+
*Example:* _fossil: https://fossil.example.org/crystal-library_
*version*::
A version requirement (string).
+
--
- It may be an explicit version number.
- It may be _"*"_ wildcard if any version will do (this is the default).
Shards will then install the latest tagged version (or HEAD if no tagged
version available).
- The version number may be prefixed by an operator: _<_, _\<=_, _>_, _>=_, _!=_ or _~>_.
- Multiple requirements can be separated by commas.
--
+
Examples: _1.2.3_, _>= 1.0.0_, _>= 1.0.0, < 2.0_ or _~> 2.0_.
+
Most of the version operators, like _>= 1.0.0_, are self-explanatory, but
the _~>_ operator has a special meaning.
It specifies a minimum version, but allows the last digit specified to go up, excluding the major release number:
--
- _~> 0.3.5_ is identical to _>= 0.3.5 and < 0.4.0_.
- _~> 2.0.3_ is identical to _>= 2.0.3 and < 2.1_.
- _~> 2.1_ is identical to _>= 2.1 and < 3.0_.
- _~> 0.3_ is identical to _>= 0.3 and < 1.0_.
- _~> 1_ is identical to _>= 1.0 and < 2.0_.
--
NOTE: Even though _2.1.0-dev_ is strictly before _2.1.0_, a version constraint like _~> 2.0.3_
would not install it since only the _.3_ can change but the _2.0_ part is fixed.
*branch*::
Install the specified branch of a git dependency, or the named branch
of a mercurial or fossil dependency (string).
*commit*::
Install the specified commit of a git, mercurial, or fossil dependency
(string).
*tag*::
Install the specified tag of a git, mercurial, or fossil dependency
(string).
*bookmark*::
Install the specified bookmark of a mercurial dependency (string).
== Example:
Here is an example _shard.yml_ for a library named _shards_ at version _1.2.3_
with some dependencies:
[source,yaml]
----
name: shards
version: 1.2.3
crystal: '>= 0.35.0'
authors:
- Julien Portalier <[email protected]>
license: MIT
description: |
Dependency manager for the Crystal Language
dependencies:
openssl:
github: datanoise/openssl.cr
branch: master
development_dependencies:
minitest:
git: https://github.com/ysbaddaden/minitest.cr.git
version: "~> 0.1.0"
libraries:
libgit2: ~> 0.24
scripts:
postinstall: make ext
targets:
shards:
main: src/shards.cr
----
== AUTHOR
Written by Julien Portalier and the Crystal project.
== SEE ALSO
*shards*(1)