build-strap 4.0.0-dev.46 → 4.0.0-dev.5

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