UNPKG

5.01 kBMarkdownView Raw
1octopack
2====
3> A nodejs tool for packaging and pushing projects to an Octopus Deploy instance.
4
5## Installation
6Install with [npm](https://www.npmjs.com/package/@octopusdeploy/octopackjs)
7
8```shell
9 npm install @octopusdeploy/octopackjs --save-dev
10```
11
12## API
13
14### var package = octo.pack(type, options)
15
16#### type
17Optional parameter to define the package type. Valid values are `targz`, `tar`, `zip` or `nupkg`. If not provided this defaults to `targz`.
18
19#### options.packagejson
20Path to the `package.json` containing project information used to provide required package metadata.
21
22#### options.id
23Defines the `Id` component of the created package. By default it will extract the name out of `package.json` if present.
24
25#### options.version
26Defines the `version` component of the created package. By default it will extract the version out of `package.json` if present.
27
28#### package.append(filePath, buff, options)
29Adds the `buff` Buffer instance to the package named using the provided `filePath` parameter as a relative path from the root of the archive.
30
31#### package.append(filePath, stream, options)
32Adds the `stream` Stream instance to the package named using the provided `filePath` parameter as a relative path from the root of the archive.
33
34#### package.append(filePath, file)
35Adds the `file` from disk to the package named using the provided `filePath` parameter as a relative path from the root of the archive. If the `filePath` parameter is missing, the provided path to the file on disk will be used as the filePath in the archive.
36
37#### package.toStream(function callback(err, data){})
38Completes the packaging of the files and invokes the provided callback, returning an object containing the stream instance and name.
39
40#### package.toFile(dir, function callback(err, data){})
41Completes the packaging of the files, saves it to disk at the provided directory location and invokes the provided callback, returning an object containing the package path, name and size.
42
43### octo.push(file, options, function callback(err, data){})
44
45#### file
46Package file that is to be pushed to server. This can be an instance of a Stream, Buffer or file path string.
47
48#### options.host
49Required property that points to the Octopus Server instance the package should be pushed to.
50
51#### options.replace
52Flag to force overwrite of existing package if one already exists with the same ID and version.
53
54#### options.apiKey
55Key linked to account with `BuiltInFeedPush` permissions.
56If `options.replace` is set to true and a package with the same ID and version already exists then the `BuiltInFeedAdminister` permission is required.
57
58#### options.name
59If a Stream or Buffer object is provided in the `file` parameter, the package name needs is required to properly store and use in Octopus Deploy. If this value is not provided and a path has been provided in the `file` parameter then the name of the file itself will be used.
60
61#### callback
62Invoked when the HTTP request has completed. The `data` object contains the HTTP response body that was returned as a result of a successful push.
63
64## Usage Examples
65
66#### Pack
67```js
68var octo = require('@octopusdeploy/octopackjs');
69octo.pack()
70 .append('buffer files/hello.txt', new Buffer('hello world'), {date: new Date(2011, 11, 11)})
71 .append('stream.txt', fs.createReadStream('./package.json'))
72 .append('lib/myfile.js')
73 .toFile('./bin', function (err, data) {
74 console.log("Package Saved: "+ data.name);
75 });
76```
77
78#### Push
79```js
80var octo = require('@octopusdeploy/octopackjs');
81
82octo.push('./bin/Sample.Web.3.2.1.tar.gz', {
83 host: 'http://octopus-server/',
84 apiKey: 'API-XXXXXXXXX',
85 replace: true
86 }, function(err, result) {
87 if(!err) {
88 console.log("Package Pushed:" + body.Title + " v"+ body.Version +" (" + fileSizeString(body.PackageSizeBytes) +"nytes)");
89 }
90});
91```
92
93## Tests
94```shell
95 npm test
96```
97
98## License
99
100(MIT License)
101
102Copyright (c) 2015 Octopus Deploy support@octopus.com
103
104Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
105
106The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
107
108THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\No newline at end of file