build-strap 4.0.0-dev.46 → 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 (129) hide show
  1. package/README.md +3 -34
  2. package/dist/src/ant.d.ts +19 -0
  3. package/dist/src/ant.js +18 -0
  4. package/dist/src/cert.d.ts +12 -0
  5. package/dist/src/cert.js +91 -0
  6. package/dist/src/clean.d.ts +4 -0
  7. package/dist/src/clean.js +11 -0
  8. package/dist/src/copy.d.ts +7 -0
  9. package/dist/src/copy.js +53 -0
  10. package/dist/src/cp.d.ts +17 -0
  11. package/dist/src/cp.js +88 -0
  12. package/dist/src/docker.container.d.ts +73 -0
  13. package/dist/src/docker.container.js +247 -0
  14. package/dist/src/docker.d.ts +68 -0
  15. package/dist/src/docker.js +188 -0
  16. package/dist/src/docker.network.d.ts +42 -0
  17. package/dist/src/docker.network.js +85 -0
  18. package/dist/src/docker.volume.d.ts +26 -0
  19. package/dist/src/docker.volume.js +62 -0
  20. package/dist/src/dockerCleanup.d.ts +38 -0
  21. package/dist/src/dockerCleanup.js +77 -0
  22. package/dist/src/dockerCompose.d.ts +154 -0
  23. package/dist/src/dockerCompose.js +439 -0
  24. package/dist/src/fs.d.ts +5 -0
  25. package/dist/src/fs.js +38 -0
  26. package/dist/src/git.d.ts +9 -0
  27. package/dist/src/git.js +24 -0
  28. package/dist/src/index.d.ts +20 -0
  29. package/dist/src/index.js +20 -0
  30. package/dist/src/maps.d.ts +33 -0
  31. package/dist/src/maps.js +41 -0
  32. package/dist/src/npm.d.ts +35 -0
  33. package/dist/src/npm.js +104 -0
  34. package/dist/src/pkg.d.ts +33 -0
  35. package/dist/src/pkg.js +33 -0
  36. package/dist/src/publish.d.ts +27 -0
  37. package/dist/src/publish.js +57 -0
  38. package/dist/src/run.d.ts +13 -0
  39. package/dist/src/run.js +44 -0
  40. package/dist/src/tgz.d.ts +13 -0
  41. package/dist/src/tgz.js +67 -0
  42. package/dist/src/version.d.ts +34 -0
  43. package/dist/src/version.js +101 -0
  44. package/dist/src/yarn.d.ts +26 -0
  45. package/dist/src/yarn.js +75 -0
  46. package/package.json +74 -20
  47. package/ant.js +0 -43
  48. package/ant.js.flow +0 -42
  49. package/artifactory.js +0 -617
  50. package/artifactory.js.flow +0 -616
  51. package/cert.conf +0 -20
  52. package/cert.js +0 -153
  53. package/cert.js.flow +0 -152
  54. package/clean.js +0 -20
  55. package/clean.js.flow +0 -19
  56. package/copy.js +0 -80
  57. package/copy.js.flow +0 -79
  58. package/cp.js +0 -173
  59. package/cp.js.flow +0 -172
  60. package/docker.container.js +0 -390
  61. package/docker.container.js.flow +0 -389
  62. package/docker.js +0 -365
  63. package/docker.js.flow +0 -364
  64. package/docker.network.js +0 -160
  65. package/docker.network.js.flow +0 -159
  66. package/docker.volume.js +0 -136
  67. package/docker.volume.js.flow +0 -136
  68. package/dockerCleanup.js +0 -152
  69. package/dockerCleanup.js.flow +0 -151
  70. package/dockerCompose.js +0 -766
  71. package/dockerCompose.js.flow +0 -765
  72. package/flow.js +0 -21
  73. package/flow.js.flow +0 -20
  74. package/fs.js +0 -95
  75. package/fs.js.flow +0 -96
  76. package/git.js +0 -35
  77. package/git.js.flow +0 -34
  78. package/hg.js +0 -35
  79. package/hg.js.flow +0 -34
  80. package/index.js +0 -27
  81. package/index.js.flow +0 -26
  82. package/inline-resources.js +0 -158
  83. package/inline-resources.js.flow +0 -157
  84. package/maps.js +0 -112
  85. package/maps.js.flow +0 -111
  86. package/npm.js +0 -145
  87. package/npm.js.flow +0 -144
  88. package/pkg.js +0 -81
  89. package/pkg.js.flow +0 -80
  90. package/publish.js +0 -145
  91. package/publish.js.flow +0 -144
  92. package/run.js +0 -90
  93. package/run.js.flow +0 -89
  94. package/src/ant.js +0 -42
  95. package/src/artifactory.js +0 -616
  96. package/src/cert.conf +0 -20
  97. package/src/cert.js +0 -152
  98. package/src/clean.js +0 -19
  99. package/src/copy.js +0 -79
  100. package/src/cp.js +0 -172
  101. package/src/docker.container.js +0 -389
  102. package/src/docker.js +0 -364
  103. package/src/docker.network.js +0 -159
  104. package/src/docker.volume.js +0 -136
  105. package/src/dockerCleanup.js +0 -151
  106. package/src/dockerCompose.js +0 -765
  107. package/src/flow.js +0 -20
  108. package/src/fs.js +0 -96
  109. package/src/git.js +0 -34
  110. package/src/hg.js +0 -34
  111. package/src/index.js +0 -26
  112. package/src/inline-resources.js +0 -157
  113. package/src/maps.js +0 -111
  114. package/src/npm.js +0 -144
  115. package/src/pkg.js +0 -80
  116. package/src/publish.js +0 -144
  117. package/src/run.js +0 -89
  118. package/src/test.js +0 -55
  119. package/src/tgz.js +0 -101
  120. package/src/version.js +0 -142
  121. package/src/yarn.js +0 -123
  122. package/test.js +0 -56
  123. package/test.js.flow +0 -55
  124. package/tgz.js +0 -102
  125. package/tgz.js.flow +0 -101
  126. package/version.js +0 -143
  127. package/version.js.flow +0 -142
  128. package/yarn.js +0 -124
  129. 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;