@verdnatura/myt 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -14
- package/docker/server/Dockerfile.myt +1 -4
- package/myt-build.js +7 -8
- package/myt-run.js +32 -10
- package/myt.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ development, so any help is welcomed! Feel free to contribute.
|
|
|
9
9
|
## Requirements
|
|
10
10
|
|
|
11
11
|
* Git
|
|
12
|
-
* Docker (Optional, used to manage local server)
|
|
12
|
+
* Docker >= 23 with BuildKit (Optional, used to manage local server)
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -62,7 +62,13 @@ Local server management commands:
|
|
|
62
62
|
* **run**: Build and start local database server container.
|
|
63
63
|
* **start**: Start local database server container.
|
|
64
64
|
|
|
65
|
-
Each command can have its own specific commandline options
|
|
65
|
+
Each command can have its own specific commandline options, you can see them by
|
|
66
|
+
running the command along with the _--help_ parameter, only the most commonly
|
|
67
|
+
used ones are documented here.
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
$ myt <command> [<args>] [-h|--help]
|
|
71
|
+
```
|
|
66
72
|
|
|
67
73
|
### Usage as library
|
|
68
74
|
|
|
@@ -225,16 +231,15 @@ should be named like this: `filename.foo.sql`.
|
|
|
225
231
|
Initializes an empty workspace.
|
|
226
232
|
|
|
227
233
|
```text
|
|
228
|
-
$ myt init
|
|
234
|
+
$ myt init [<args>]
|
|
229
235
|
```
|
|
230
236
|
|
|
231
|
-
|
|
232
237
|
### pull
|
|
233
238
|
|
|
234
239
|
Incorporates database routine changes into workspace.
|
|
235
240
|
|
|
236
241
|
```text
|
|
237
|
-
$ myt pull [
|
|
242
|
+
$ myt pull [<args>] [-f|--force] [<remote>]
|
|
238
243
|
```
|
|
239
244
|
|
|
240
245
|
When *--checkout* option is provided, it does the following before export:
|
|
@@ -247,7 +252,7 @@ When *--checkout* option is provided, it does the following before export:
|
|
|
247
252
|
Applies versions and routine changes into database.
|
|
248
253
|
|
|
249
254
|
```text
|
|
250
|
-
$ myt push [<
|
|
255
|
+
$ myt push [<args>] [-f|--force] [-c|--commit] [<remote>]
|
|
251
256
|
```
|
|
252
257
|
|
|
253
258
|
Commit is saved into database only if *--commit* option is provided, it
|
|
@@ -261,7 +266,7 @@ Creates a new version folder, when name is not specified it generates a random
|
|
|
261
266
|
name mixing a color with a plant name.
|
|
262
267
|
|
|
263
268
|
```text
|
|
264
|
-
$ myt version [<name>]
|
|
269
|
+
$ myt version [<args>] [<name>]
|
|
265
270
|
```
|
|
266
271
|
|
|
267
272
|
### create
|
|
@@ -269,7 +274,7 @@ $ myt version [<name>]
|
|
|
269
274
|
Creates a new routine file with a default template.
|
|
270
275
|
|
|
271
276
|
```text
|
|
272
|
-
$ myt create [-t <type>] <schema>.<name>
|
|
277
|
+
$ myt create [<args>] [-t <type>] <schema>.<name>
|
|
273
278
|
```
|
|
274
279
|
|
|
275
280
|
### clean
|
|
@@ -288,7 +293,7 @@ Exports database structure and fixtures from remote into hidden files located
|
|
|
288
293
|
in *dump* folder. If no remote is specified *production* is used.
|
|
289
294
|
|
|
290
295
|
```text
|
|
291
|
-
$ myt dump [<
|
|
296
|
+
$ myt dump [<args>] [-l|--lock] [<remote>]
|
|
292
297
|
```
|
|
293
298
|
|
|
294
299
|
### fixtures
|
|
@@ -297,7 +302,7 @@ Exports local database fixtures into *dump/fixtures.sql* files. If no remote is
|
|
|
297
302
|
specified *local* is used.
|
|
298
303
|
|
|
299
304
|
```text
|
|
300
|
-
$ myt fixtures [<remote>]
|
|
305
|
+
$ myt fixtures [<args>] [<remote>]
|
|
301
306
|
```
|
|
302
307
|
|
|
303
308
|
### build
|
|
@@ -306,7 +311,7 @@ Builds local database server image. It only rebuilds the image when sources
|
|
|
306
311
|
have been modified.
|
|
307
312
|
|
|
308
313
|
```text
|
|
309
|
-
$ myt build [-n|--name] [-t|--tag] [-f|--force] [
|
|
314
|
+
$ myt build [<args>] [-n|--name] [-t|--tag] [-f|--force] [<realm>]
|
|
310
315
|
```
|
|
311
316
|
|
|
312
317
|
### apply
|
|
@@ -315,7 +320,7 @@ Applies structure, fixtures and changes to database. Primarily used by the
|
|
|
315
320
|
build command to rebuild the local database.
|
|
316
321
|
|
|
317
322
|
```text
|
|
318
|
-
$ myt apply [
|
|
323
|
+
$ myt apply [<args>] [<realm>]
|
|
319
324
|
```
|
|
320
325
|
|
|
321
326
|
### run
|
|
@@ -324,7 +329,7 @@ Builds and starts local database server container. It only rebuilds the image
|
|
|
324
329
|
when dump have been modified.
|
|
325
330
|
|
|
326
331
|
```text
|
|
327
|
-
$ myt run [<
|
|
332
|
+
$ myt run [<args>] [-c|--ci] [-r|--random] [<realm>]
|
|
328
333
|
```
|
|
329
334
|
|
|
330
335
|
### start
|
|
@@ -335,7 +340,7 @@ mind that when you do not rebuild the docker you may be using an outdated
|
|
|
335
340
|
version of it.
|
|
336
341
|
|
|
337
342
|
```text
|
|
338
|
-
$ myt start
|
|
343
|
+
$ myt start [<args>]
|
|
339
344
|
```
|
|
340
345
|
|
|
341
346
|
## Why
|
|
@@ -23,11 +23,8 @@ RUN apt-get update \
|
|
|
23
23
|
# && rm -rf /var/lib/apt/lists/*
|
|
24
24
|
|
|
25
25
|
WORKDIR /myt
|
|
26
|
-
COPY pnpm-lock.yaml ./
|
|
27
|
-
RUN pnpm fetch --prod --frozen-lockfile --ignore-scripts
|
|
28
|
-
|
|
29
26
|
COPY package.json ./
|
|
30
|
-
RUN pnpm install --prod --
|
|
27
|
+
RUN pnpm install --prod --ignore-scripts
|
|
31
28
|
|
|
32
29
|
COPY . ./
|
|
33
30
|
RUN npm install -g /myt
|
package/myt-build.js
CHANGED
|
@@ -133,13 +133,8 @@ class Build extends Command {
|
|
|
133
133
|
const tagSha = tagHash.digest('hex');
|
|
134
134
|
const shortSha = tagSha.substring(0, cfg.gitShortLen);
|
|
135
135
|
|
|
136
|
-
let imageTag =
|
|
137
|
-
if (
|
|
138
|
-
imageTag = opts.tag;
|
|
139
|
-
} else if (shortSha) {
|
|
140
|
-
imageTag = shortSha;
|
|
141
|
-
if (realm) imageTag += `-${realm}`;
|
|
142
|
-
}
|
|
136
|
+
let imageTag = shortSha;
|
|
137
|
+
if (realm) imageTag += `-${realm}`;
|
|
143
138
|
|
|
144
139
|
const imageName = opts.name || cfg.code;
|
|
145
140
|
const tag = `${imageName}:${imageTag}`;
|
|
@@ -262,8 +257,12 @@ class Build extends Command {
|
|
|
262
257
|
if (realm)
|
|
263
258
|
buildArgs.push(`MYT_REALM=${realm}`);
|
|
264
259
|
|
|
260
|
+
const tags = [tag, `${imageName}:latest`];
|
|
261
|
+
if (opts.tag)
|
|
262
|
+
tags.push(`${imageName}:${opts.tag}`);
|
|
263
|
+
|
|
265
264
|
await docker.build(ctx.mytDir, {
|
|
266
|
-
tag:
|
|
265
|
+
tag: tags,
|
|
267
266
|
file: path.join(serverDir, 'Dockerfile'),
|
|
268
267
|
label: imageLabels,
|
|
269
268
|
buildArg: buildArgs
|
package/myt-run.js
CHANGED
|
@@ -13,36 +13,46 @@ class Run extends Command {
|
|
|
13
13
|
static usage = {
|
|
14
14
|
description: 'Build and start local database server container',
|
|
15
15
|
params: {
|
|
16
|
-
ci: 'Workaround for continuous integration system',
|
|
17
16
|
network: 'Docker network to attach container to',
|
|
18
17
|
random: 'Whether to use a random container name and port',
|
|
19
18
|
persist: 'Whether to not use tmpfs mount for MySQL data',
|
|
20
19
|
keep: 'Keep container on failure',
|
|
21
20
|
realm: 'Name of fixture realm to use',
|
|
22
|
-
ip: 'Bind to container IP instead of localhost'
|
|
21
|
+
ip: 'Bind to container IP instead of localhost',
|
|
22
|
+
build: 'Whether to skip image build',
|
|
23
|
+
name: 'Built image name',
|
|
24
|
+
tag: 'Built image tag',
|
|
25
|
+
force: 'Whether to force build'
|
|
23
26
|
},
|
|
24
27
|
operand: 'realm'
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
static args = {
|
|
28
31
|
alias: {
|
|
29
|
-
network: '
|
|
32
|
+
network: 'e',
|
|
30
33
|
random: 'r',
|
|
31
34
|
persist: 'p',
|
|
32
35
|
keep: 'k',
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
ip: 'i',
|
|
37
|
+
build: 'b',
|
|
38
|
+
name: 'n',
|
|
39
|
+
tag: 't',
|
|
40
|
+
force: 'f',
|
|
41
|
+
realm: 'm'
|
|
35
42
|
},
|
|
36
43
|
string: [
|
|
37
44
|
'network',
|
|
45
|
+
'name',
|
|
46
|
+
'tag',
|
|
38
47
|
'realm'
|
|
39
48
|
],
|
|
40
49
|
boolean: [
|
|
41
|
-
'ci',
|
|
42
50
|
'random',
|
|
43
51
|
'persist',
|
|
44
52
|
'keep',
|
|
45
|
-
'ip'
|
|
53
|
+
'ip',
|
|
54
|
+
'build',
|
|
55
|
+
'force'
|
|
46
56
|
]
|
|
47
57
|
};
|
|
48
58
|
|
|
@@ -55,9 +65,21 @@ class Run extends Command {
|
|
|
55
65
|
};
|
|
56
66
|
|
|
57
67
|
async _run(myt, ctx, cfg, opts) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
let tag;
|
|
69
|
+
|
|
70
|
+
if (!opts.build) {
|
|
71
|
+
tag = await myt.run(Build, {
|
|
72
|
+
name: opts.name,
|
|
73
|
+
tag: opts.tag,
|
|
74
|
+
force: opts.force,
|
|
75
|
+
realm: opts.realm
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
if (!opts.name)
|
|
79
|
+
throw new Error('Build ommitted but no image passed');
|
|
80
|
+
tag = opts.name;
|
|
81
|
+
if (opts.tag) tag += `:${opts.tag}`;
|
|
82
|
+
}
|
|
61
83
|
|
|
62
84
|
this.emit('runningContainer');
|
|
63
85
|
|
package/myt.js
CHANGED