build-strap 3.0.0-dev.42 → 4.0.0-dev.2

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 (108) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -34
  3. package/ant.d.ts +19 -0
  4. package/ant.js +12 -37
  5. package/cert.d.ts +12 -0
  6. package/cert.js +89 -151
  7. package/clean.d.ts +4 -0
  8. package/clean.js +7 -16
  9. package/copy.d.ts +7 -0
  10. package/copy.js +49 -76
  11. package/cp.d.ts +17 -0
  12. package/cp.js +85 -170
  13. package/docker.container.d.ts +73 -0
  14. package/docker.container.js +219 -362
  15. package/docker.d.ts +68 -0
  16. package/docker.js +167 -347
  17. package/docker.network.d.ts +42 -0
  18. package/docker.network.js +69 -144
  19. package/docker.volume.d.ts +26 -0
  20. package/docker.volume.js +52 -126
  21. package/dockerCleanup.d.ts +38 -0
  22. package/dockerCleanup.js +66 -141
  23. package/dockerCompose.d.ts +154 -0
  24. package/dockerCompose.js +400 -727
  25. package/fs.d.ts +5 -0
  26. package/fs.js +38 -95
  27. package/git.d.ts +9 -0
  28. package/git.js +19 -30
  29. package/index.d.ts +20 -0
  30. package/index.js +20 -27
  31. package/maps.d.ts +33 -0
  32. package/maps.js +16 -87
  33. package/npm.d.ts +34 -0
  34. package/npm.js +97 -138
  35. package/package.json +23 -19
  36. package/pkg.d.ts +39 -0
  37. package/pkg.js +26 -74
  38. package/publish.d.ts +27 -0
  39. package/publish.js +52 -140
  40. package/run.d.ts +13 -0
  41. package/run.js +39 -85
  42. package/tgz.d.ts +13 -0
  43. package/tgz.js +61 -96
  44. package/version.d.ts +34 -0
  45. package/version.js +86 -127
  46. package/yarn.d.ts +26 -0
  47. package/yarn.js +70 -119
  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.flow +0 -152
  53. package/clean.js.flow +0 -19
  54. package/copy.js.flow +0 -79
  55. package/cp.js.flow +0 -172
  56. package/docker.container.js.flow +0 -389
  57. package/docker.js.flow +0 -367
  58. package/docker.network.js.flow +0 -159
  59. package/docker.volume.js.flow +0 -136
  60. package/dockerCleanup.js.flow +0 -151
  61. package/dockerCompose.js.flow +0 -765
  62. package/flow.js +0 -21
  63. package/flow.js.flow +0 -20
  64. package/fs.js.flow +0 -96
  65. package/git.js.flow +0 -34
  66. package/hg.js +0 -35
  67. package/hg.js.flow +0 -34
  68. package/index.js.flow +0 -26
  69. package/inline-resources.js +0 -158
  70. package/inline-resources.js.flow +0 -157
  71. package/maps.js.flow +0 -111
  72. package/npm.js.flow +0 -144
  73. package/pkg.js.flow +0 -80
  74. package/publish.js.flow +0 -144
  75. package/run.js.flow +0 -89
  76. package/src/ant.js +0 -42
  77. package/src/artifactory.js +0 -616
  78. package/src/cert.conf +0 -20
  79. package/src/cert.js +0 -152
  80. package/src/clean.js +0 -19
  81. package/src/copy.js +0 -79
  82. package/src/cp.js +0 -172
  83. package/src/docker.container.js +0 -389
  84. package/src/docker.js +0 -367
  85. package/src/docker.network.js +0 -159
  86. package/src/docker.volume.js +0 -136
  87. package/src/dockerCleanup.js +0 -151
  88. package/src/dockerCompose.js +0 -765
  89. package/src/flow.js +0 -20
  90. package/src/fs.js +0 -96
  91. package/src/git.js +0 -34
  92. package/src/hg.js +0 -34
  93. package/src/index.js +0 -26
  94. package/src/inline-resources.js +0 -157
  95. package/src/maps.js +0 -111
  96. package/src/npm.js +0 -144
  97. package/src/pkg.js +0 -80
  98. package/src/publish.js +0 -144
  99. package/src/run.js +0 -89
  100. package/src/test.js +0 -55
  101. package/src/tgz.js +0 -101
  102. package/src/version.js +0 -141
  103. package/src/yarn.js +0 -123
  104. package/test.js +0 -56
  105. package/test.js.flow +0 -55
  106. package/tgz.js.flow +0 -101
  107. package/version.js.flow +0 -141
  108. 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;