screwdriver-api 7.0.218 → 7.0.219

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "7.0.218",
3
+ "version": "7.0.219",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -75,12 +75,11 @@ Example payload:
75
75
  Arguments:
76
76
 
77
77
  * `type` - Return type for build artifact, `download` or `preview`
78
+ * `dir` - If downloading directory or not (`true` or `false`, default `false`). Must be set with `type=download`.
78
79
 
79
80
  `GET /builds/{id}/artifacts/{name*}?type=preview`
80
81
 
81
- `GET /builds/{id}/artifacts/this/is/a/directory/path/?type=download`
82
-
83
- *Note: To download a directory, there must be a trailing slash (`/`) in the name and `type=download`.*
82
+ `GET /builds/{id}/artifacts/this/is/a/directory/path?type=download&dir=true`
84
83
 
85
84
  #### Get build statuses
86
85
  `GET /builds/statuses`
@@ -50,9 +50,9 @@ module.exports = config => ({
50
50
  .then(async () => {
51
51
  // Directory should fetch manifest and
52
52
  // gather all files that belong to that directory
53
- if (artifact.endsWith('/') && req.query.type === 'download') {
53
+ if (req.query.dir && req.query.type === 'download') {
54
54
  // Create a zip name from the directory structure
55
- const zipName = artifact.split('/').slice(-2)[0];
55
+ const zipName = artifact.split('/').slice(-1)[0];
56
56
 
57
57
  try {
58
58
  const token = jwt.sign({
@@ -69,7 +69,7 @@ module.exports = config => ({
69
69
  method: 'GET'
70
70
  }).text();
71
71
  const manifestArray = manifest.trim().split('\n');
72
- const directoryArray = manifestArray.filter(f => f.startsWith(`./${artifact}`));
72
+ const directoryArray = manifestArray.filter(f => f.startsWith(`./${artifact}/`));
73
73
 
74
74
  // Create a stream and set up archiver
75
75
  const archive = archiver('zip', { zlib: { level: 9 } });
@@ -100,7 +100,7 @@ module.exports = config => ({
100
100
  archive.emit('error', err); // Emit error to stop the archive process
101
101
  });
102
102
 
103
- const relativePath = file.replace(`./${artifact}`, `./${zipName}/`);
103
+ const relativePath = file.replace(`./${artifact}/`, `./${zipName}/`);
104
104
 
105
105
  // Append the file stream to the archive with the correct relative path
106
106
  archive.append(fileStream, { name: relativePath });
@@ -168,7 +168,8 @@ module.exports = config => ({
168
168
  name: artifactSchema
169
169
  }),
170
170
  query: joi.object({
171
- type: typeSchema
171
+ type: typeSchema,
172
+ dir: joi.boolean().truthy('true').falsy('false').default(false)
172
173
  }).options({ allowUnknown: true })
173
174
  }
174
175
  }