build-strap 3.0.0-dev.42 → 4.0.0

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.
Files changed (130) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -34
  3. package/dist/src/ant.d.ts +19 -0
  4. package/dist/src/ant.js +18 -0
  5. package/dist/src/cert.d.ts +12 -0
  6. package/dist/src/cert.js +91 -0
  7. package/dist/src/clean.d.ts +4 -0
  8. package/dist/src/clean.js +11 -0
  9. package/dist/src/copy.d.ts +7 -0
  10. package/dist/src/copy.js +53 -0
  11. package/dist/src/cp.d.ts +17 -0
  12. package/dist/src/cp.js +88 -0
  13. package/dist/src/docker.container.d.ts +73 -0
  14. package/dist/src/docker.container.js +247 -0
  15. package/dist/src/docker.d.ts +68 -0
  16. package/dist/src/docker.js +188 -0
  17. package/dist/src/docker.network.d.ts +42 -0
  18. package/dist/src/docker.network.js +85 -0
  19. package/dist/src/docker.volume.d.ts +26 -0
  20. package/dist/src/docker.volume.js +62 -0
  21. package/dist/src/dockerCleanup.d.ts +38 -0
  22. package/dist/src/dockerCleanup.js +77 -0
  23. package/dist/src/dockerCompose.d.ts +154 -0
  24. package/dist/src/dockerCompose.js +439 -0
  25. package/dist/src/fs.d.ts +5 -0
  26. package/dist/src/fs.js +38 -0
  27. package/dist/src/git.d.ts +9 -0
  28. package/dist/src/git.js +24 -0
  29. package/dist/src/index.d.ts +20 -0
  30. package/dist/src/index.js +20 -0
  31. package/dist/src/maps.d.ts +33 -0
  32. package/dist/src/maps.js +41 -0
  33. package/dist/src/npm.d.ts +35 -0
  34. package/dist/src/npm.js +104 -0
  35. package/dist/src/pkg.d.ts +33 -0
  36. package/dist/src/pkg.js +33 -0
  37. package/dist/src/publish.d.ts +27 -0
  38. package/dist/src/publish.js +57 -0
  39. package/dist/src/run.d.ts +13 -0
  40. package/dist/src/run.js +44 -0
  41. package/dist/src/tgz.d.ts +13 -0
  42. package/dist/src/tgz.js +67 -0
  43. package/dist/src/version.d.ts +34 -0
  44. package/dist/src/version.js +101 -0
  45. package/dist/src/yarn.d.ts +26 -0
  46. package/dist/src/yarn.js +75 -0
  47. package/package.json +74 -20
  48. package/ant.js +0 -43
  49. package/ant.js.flow +0 -42
  50. package/artifactory.js +0 -617
  51. package/artifactory.js.flow +0 -616
  52. package/cert.conf +0 -20
  53. package/cert.js +0 -153
  54. package/cert.js.flow +0 -152
  55. package/clean.js +0 -20
  56. package/clean.js.flow +0 -19
  57. package/copy.js +0 -80
  58. package/copy.js.flow +0 -79
  59. package/cp.js +0 -173
  60. package/cp.js.flow +0 -172
  61. package/docker.container.js +0 -390
  62. package/docker.container.js.flow +0 -389
  63. package/docker.js +0 -368
  64. package/docker.js.flow +0 -367
  65. package/docker.network.js +0 -160
  66. package/docker.network.js.flow +0 -159
  67. package/docker.volume.js +0 -136
  68. package/docker.volume.js.flow +0 -136
  69. package/dockerCleanup.js +0 -152
  70. package/dockerCleanup.js.flow +0 -151
  71. package/dockerCompose.js +0 -766
  72. package/dockerCompose.js.flow +0 -765
  73. package/flow.js +0 -21
  74. package/flow.js.flow +0 -20
  75. package/fs.js +0 -95
  76. package/fs.js.flow +0 -96
  77. package/git.js +0 -35
  78. package/git.js.flow +0 -34
  79. package/hg.js +0 -35
  80. package/hg.js.flow +0 -34
  81. package/index.js +0 -27
  82. package/index.js.flow +0 -26
  83. package/inline-resources.js +0 -158
  84. package/inline-resources.js.flow +0 -157
  85. package/maps.js +0 -112
  86. package/maps.js.flow +0 -111
  87. package/npm.js +0 -145
  88. package/npm.js.flow +0 -144
  89. package/pkg.js +0 -81
  90. package/pkg.js.flow +0 -80
  91. package/publish.js +0 -145
  92. package/publish.js.flow +0 -144
  93. package/run.js +0 -90
  94. package/run.js.flow +0 -89
  95. package/src/ant.js +0 -42
  96. package/src/artifactory.js +0 -616
  97. package/src/cert.conf +0 -20
  98. package/src/cert.js +0 -152
  99. package/src/clean.js +0 -19
  100. package/src/copy.js +0 -79
  101. package/src/cp.js +0 -172
  102. package/src/docker.container.js +0 -389
  103. package/src/docker.js +0 -367
  104. package/src/docker.network.js +0 -159
  105. package/src/docker.volume.js +0 -136
  106. package/src/dockerCleanup.js +0 -151
  107. package/src/dockerCompose.js +0 -765
  108. package/src/flow.js +0 -20
  109. package/src/fs.js +0 -96
  110. package/src/git.js +0 -34
  111. package/src/hg.js +0 -34
  112. package/src/index.js +0 -26
  113. package/src/inline-resources.js +0 -157
  114. package/src/maps.js +0 -111
  115. package/src/npm.js +0 -144
  116. package/src/pkg.js +0 -80
  117. package/src/publish.js +0 -144
  118. package/src/run.js +0 -89
  119. package/src/test.js +0 -55
  120. package/src/tgz.js +0 -101
  121. package/src/version.js +0 -141
  122. package/src/yarn.js +0 -123
  123. package/test.js +0 -56
  124. package/test.js.flow +0 -55
  125. package/tgz.js +0 -102
  126. package/tgz.js.flow +0 -101
  127. package/version.js +0 -142
  128. package/version.js.flow +0 -141
  129. package/yarn.js +0 -124
  130. package/yarn.js.flow +0 -123
@@ -1,151 +0,0 @@
1
- // @flow
2
- import uniq from 'lodash/uniq';
3
- import {
4
- dockerImages,
5
- dockerRmi,
6
- getUntaggedDockerIds,
7
- getDockerTags,
8
- getDockerRepo,
9
- } from './docker';
10
- import type { DockerImage, DockerImageFilter } from './docker';
11
- import { dockerContainerLs } from './docker.container';
12
- import { buildLog } from './run';
13
-
14
- // flattens arrays of promises and/or promises for arrays
15
- // into a single array of (awaited) values
16
- const flatten = async (input) => {
17
- const result = await input;
18
- return Array.isArray(result)
19
- ? [].concat(...(await Promise.all(result.map(flatten))))
20
- : result;
21
- };
22
-
23
- type CommonDockerCleanupOptions = {|
24
- /** print matched items to console instead of deleting */
25
- dryRun?: boolean,
26
- |};
27
-
28
- type DockerContainerCleanupOptions = {|
29
- ...CommonDockerCleanupOptions,
30
- |};
31
-
32
- /**
33
- * Purge stopped containers
34
- */
35
- export const dockerContainerCleanup = async ({
36
- dryRun = process.argv.includes('--dry-run'),
37
- }: DockerContainerCleanupOptions = {}) => {
38
- const toClean = await dockerContainerLs({
39
- all: true,
40
- filter: (c) => c.exited,
41
- });
42
- if (dryRun) {
43
- buildLog(
44
- `Containers to delete (dry run):\n ${toClean
45
- .map((c) => c.id)
46
- .join('\n ')}`,
47
- );
48
- } else {
49
- await Promise.all(toClean.map(async (c) => c.rm(true)));
50
- }
51
- };
52
-
53
- type DockerImageCleanupOptions = {|
54
- ...CommonDockerCleanupOptions,
55
- /** Image repositories to clean (defaults to the one configured in package.json) */
56
- repos?: string[],
57
- /** Image ids known to be produced by this build */
58
- buildImageIds?: string[],
59
- /** Explicit image names/ids to delete unconditionally */
60
- images?: string[],
61
- /**
62
- * ignore default exclusions of :latest* and images < 1hr old
63
- * this will delete all images in the given repos
64
- */
65
- purgeAll?: boolean,
66
- /**
67
- * looks for other builds of the same repos
68
- * this will still exclude :latest* and images < 1hr old
69
- * useful to clean up after past builds that failed to clean themselves properly
70
- */
71
- purgeOld?: boolean,
72
- |};
73
-
74
- /**
75
- * Purge docker images created during build process
76
- */
77
- export const dockerImageCleanup = async ({
78
- repos = [getDockerRepo()],
79
- buildImageIds = [],
80
- images = [],
81
- purgeAll = process.argv.includes('--purge-all'),
82
- purgeOld = !process.argv.includes('--keep-old'),
83
- dryRun = process.argv.includes('--dry-run'),
84
- }: DockerImageCleanupOptions = {}) => {
85
- // only match images without a :latest tag
86
- const filterLatest: DockerImageFilter = (m: DockerImage) =>
87
- purgeAll || !m.tag.match(/^latest(-\w+)?$/);
88
- // only match images more than an hour old, AND without a :latest* tag
89
- const filterOld: DockerImageFilter = (m: DockerImage) =>
90
- purgeAll || (filterLatest(m) && m.created < Date.now() - 1000 * 60 * 60);
91
-
92
- const uniqueList = uniq([
93
- // the things that we know were just built by us
94
- // remove all tags from the given repos with a matching `buildImageIds`, except for :latest*
95
- ...(await flatten(
96
- repos.map((r) =>
97
- buildImageIds.map(async (b) => getDockerTags(b, r, true, filterLatest)),
98
- ),
99
- )),
100
-
101
- // unconditionally delete explicitly passed images/ids
102
- ...images,
103
-
104
- // images in the given `repos` without a tag, older than 1hr
105
- ...(await flatten(
106
- repos.map(async (r) => getUntaggedDockerIds(r, filterOld)),
107
- )),
108
-
109
- // images with no repo and no tag
110
- ...(
111
- await dockerImages(
112
- null,
113
- (m) => m.repository === '<none>' && m.tag === '<none>' && filterOld(m),
114
- )
115
- ).map((m) => m.id),
116
-
117
- // any leftover tags from prior builds (only if purgeAll or purgeOld)
118
- ...(purgeAll || purgeOld
119
- ? await flatten(
120
- repos.map(async (r) => getDockerTags(null, r, true, filterOld)),
121
- )
122
- : []),
123
- ]);
124
-
125
- if (dryRun) {
126
- buildLog(`Images to delete (dry run):\n ${uniqueList.join('\n ')}`);
127
- } else {
128
- await dockerRmi(uniqueList, true);
129
- }
130
- };
131
-
132
- type DockerCleanupOptions = {|
133
- ...DockerImageCleanupOptions,
134
- ...DockerContainerCleanupOptions,
135
- |};
136
-
137
- /**
138
- * Purge docker images created during build process
139
- */
140
- export const dockerCleanup = async ({
141
- dryRun,
142
- ...rest
143
- }: DockerCleanupOptions = {}) => {
144
- await dockerContainerCleanup({ dryRun });
145
- await dockerImageCleanup({
146
- dryRun,
147
- ...rest,
148
- });
149
- };
150
-
151
- export default dockerCleanup;