mirror of
https://github.com/shimataro/ssh-key-action.git
synced 2025-06-19 22:52:10 +10:00
* first action! (#1)
This commit is contained in:
parent
8deacc95b1
commit
ace1e6a69a
3750 changed files with 1155519 additions and 0 deletions
15
node_modules/promise-retry/.editorconfig
generated
vendored
Normal file
15
node_modules/promise-retry/.editorconfig
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[package.json]
|
||||
indent_size = 2
|
64
node_modules/promise-retry/.jshintrc
generated
vendored
Normal file
64
node_modules/promise-retry/.jshintrc
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"predef": [
|
||||
"console",
|
||||
"require",
|
||||
"define",
|
||||
"describe",
|
||||
"it",
|
||||
"before",
|
||||
"beforeEach",
|
||||
"after",
|
||||
"afterEach",
|
||||
"Promise"
|
||||
],
|
||||
|
||||
"node": true,
|
||||
"devel": true,
|
||||
|
||||
"bitwise": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"forin": false,
|
||||
"immed": true,
|
||||
"latedef": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": false,
|
||||
"nonew": true,
|
||||
"plusplus": false,
|
||||
"regexp": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"quotmark": "single",
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
|
||||
"asi": false,
|
||||
"boss": false,
|
||||
"debug": false,
|
||||
"eqnull": true,
|
||||
"es5": false,
|
||||
"esnext": false,
|
||||
"evil": false,
|
||||
"expr": true,
|
||||
"funcscope": false,
|
||||
"globalstrict": false,
|
||||
"iterator": false,
|
||||
"lastsemic": false,
|
||||
"laxbreak": false,
|
||||
"laxcomma": false,
|
||||
"loopfunc": true,
|
||||
"multistr": false,
|
||||
"onecase": true,
|
||||
"regexdash": false,
|
||||
"scripturl": false,
|
||||
"smarttabs": false,
|
||||
"shadow": false,
|
||||
"sub": false,
|
||||
"supernew": false,
|
||||
"validthis": false,
|
||||
|
||||
"nomen": false,
|
||||
"onevar": false,
|
||||
"white": true
|
||||
}
|
2
node_modules/promise-retry/.npmignore
generated
vendored
Normal file
2
node_modules/promise-retry/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
npm-debug.*
|
5
node_modules/promise-retry/.travis.yml
generated
vendored
Normal file
5
node_modules/promise-retry/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "0.12"
|
||||
- "4"
|
||||
- "5"
|
19
node_modules/promise-retry/LICENSE
generated
vendored
Normal file
19
node_modules/promise-retry/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2014 IndigoUnited
|
||||
|
||||
Permission 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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE 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.
|
92
node_modules/promise-retry/README.md
generated
vendored
Normal file
92
node_modules/promise-retry/README.md
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
# node-promise-retry
|
||||
|
||||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url]
|
||||
|
||||
[npm-url]:https://npmjs.org/package/promise-retry
|
||||
[downloads-image]:http://img.shields.io/npm/dm/promise-retry.svg
|
||||
[npm-image]:http://img.shields.io/npm/v/promise-retry.svg
|
||||
[travis-url]:https://travis-ci.org/IndigoUnited/node-promise-retry
|
||||
[travis-image]:http://img.shields.io/travis/IndigoUnited/node-promise-retry/master.svg
|
||||
[david-dm-url]:https://david-dm.org/IndigoUnited/node-promise-retry
|
||||
[david-dm-image]:https://img.shields.io/david/IndigoUnited/node-promise-retry.svg
|
||||
[david-dm-dev-url]:https://david-dm.org/IndigoUnited/node-promise-retry#info=devDependencies
|
||||
[david-dm-dev-image]:https://img.shields.io/david/dev/IndigoUnited/node-promise-retry.svg
|
||||
|
||||
Retries a function that returns a promise, leveraging the power of the [retry](https://github.com/tim-kos/node-retry) module to the promises world.
|
||||
|
||||
There's already some modules that are able to retry functions that return promises but
|
||||
they were rather difficult to use or do not offer an easy way to do conditional retries.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
`$ npm install promise-retry`
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### promiseRetry(fn, [options])
|
||||
|
||||
Calls `fn` until the returned promise ends up fulfilled or rejected with an error different than
|
||||
a `retry` error.
|
||||
The `options` argument is an object which maps to the [retry](https://github.com/tim-kos/node-retry) module options:
|
||||
|
||||
- `retries`: The maximum amount of times to retry the operation. Default is `10`.
|
||||
- `factor`: The exponential factor to use. Default is `2`.
|
||||
- `minTimeout`: The number of milliseconds before starting the first retry. Default is `1000`.
|
||||
- `maxTimeout`: The maximum number of milliseconds between two retries. Default is `Infinity`.
|
||||
- `randomize`: Randomizes the timeouts by multiplying with a factor between `1` to `2`. Default is `false`.
|
||||
|
||||
|
||||
The `fn` function will receive a `retry` function as its first argument that should be called with an error whenever you want to retry `fn`. The `retry` function will always throw an error.
|
||||
If there's retries left, it will throw a special `retry` error that will be handled internally to call `fn` again.
|
||||
If there's no retries left, it will throw the actual error passed to it.
|
||||
|
||||
If you prefer, you can pass the options first using the alternative function signature `promiseRetry([options], fn)`.
|
||||
|
||||
## Example
|
||||
```js
|
||||
var promiseRetry = require('promise-retry');
|
||||
|
||||
// Simple example
|
||||
promiseRetry(function (retry, number) {
|
||||
console.log('attempt number', number);
|
||||
|
||||
return doSomething()
|
||||
.catch(retry);
|
||||
})
|
||||
.then(function (value) {
|
||||
// ..
|
||||
}, function (err) {
|
||||
// ..
|
||||
});
|
||||
|
||||
// Conditional example
|
||||
promiseRetry(function (retry, number) {
|
||||
console.log('attempt number', number);
|
||||
|
||||
return doSomething()
|
||||
.catch(function (err) {
|
||||
if (err.code === 'ETIMEDOUT') {
|
||||
retry(err);
|
||||
}
|
||||
|
||||
throw err;
|
||||
});
|
||||
})
|
||||
.then(function (value) {
|
||||
// ..
|
||||
}, function (err) {
|
||||
// ..
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## Tests
|
||||
|
||||
`$ npm test`
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
|
52
node_modules/promise-retry/index.js
generated
vendored
Normal file
52
node_modules/promise-retry/index.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
'use strict';
|
||||
|
||||
var errcode = require('err-code');
|
||||
var retry = require('retry');
|
||||
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
||||
|
||||
function isRetryError(err) {
|
||||
return err && err.code === 'EPROMISERETRY' && hasOwn.call(err, 'retried');
|
||||
}
|
||||
|
||||
function promiseRetry(fn, options) {
|
||||
var temp;
|
||||
var operation;
|
||||
|
||||
if (typeof fn === 'object' && typeof options === 'function') {
|
||||
// Swap options and fn when using alternate signature (options, fn)
|
||||
temp = options;
|
||||
options = fn;
|
||||
fn = temp;
|
||||
}
|
||||
|
||||
operation = retry.operation(options);
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
operation.attempt(function (number) {
|
||||
Promise.resolve()
|
||||
.then(function () {
|
||||
return fn(function (err) {
|
||||
if (isRetryError(err)) {
|
||||
err = err.retried;
|
||||
}
|
||||
|
||||
throw errcode('Retrying', 'EPROMISERETRY', { retried: err });
|
||||
}, number);
|
||||
})
|
||||
.then(resolve, function (err) {
|
||||
if (isRetryError(err)) {
|
||||
err = err.retried;
|
||||
|
||||
if (operation.retry(err || new Error())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = promiseRetry;
|
68
node_modules/promise-retry/package.json
generated
vendored
Normal file
68
node_modules/promise-retry/package.json
generated
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"_from": "promise-retry@^1.1.1",
|
||||
"_id": "promise-retry@1.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ZznpaOMFHaIM5kl/srUPaRHfPW0=",
|
||||
"_location": "/promise-retry",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "promise-retry@^1.1.1",
|
||||
"name": "promise-retry",
|
||||
"escapedName": "promise-retry",
|
||||
"rawSpec": "^1.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/make-fetch-happen",
|
||||
"/pacote"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-1.1.1.tgz",
|
||||
"_shasum": "6739e968e3051da20ce6497fb2b50f6911df3d6d",
|
||||
"_spec": "promise-retry@^1.1.1",
|
||||
"_where": "/home/shimataro/projects/actions/ssh-key-action/node_modules/pacote",
|
||||
"author": {
|
||||
"name": "IndigoUnited",
|
||||
"email": "hello@indigounited.com",
|
||||
"url": "http://indigounited.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/IndigoUnited/node-promise-retry/issues/"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"err-code": "^1.0.0",
|
||||
"retry": "^0.10.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Retries a function that returns a promise, leveraging the power of the retry module.",
|
||||
"devDependencies": {
|
||||
"expect.js": "^0.3.1",
|
||||
"mocha": "^3.0.0",
|
||||
"sleep-promise": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"homepage": "https://github.com/IndigoUnited/node-promise-retry#readme",
|
||||
"keywords": [
|
||||
"retry",
|
||||
"promise",
|
||||
"backoff",
|
||||
"repeat",
|
||||
"replay"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "promise-retry",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/IndigoUnited/node-promise-retry.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --bail -t 10000"
|
||||
},
|
||||
"version": "1.1.1"
|
||||
}
|
263
node_modules/promise-retry/test/test.js
generated
vendored
Normal file
263
node_modules/promise-retry/test/test.js
generated
vendored
Normal file
|
@ -0,0 +1,263 @@
|
|||
'use strict';
|
||||
|
||||
var expect = require('expect.js');
|
||||
var promiseRetry = require('../');
|
||||
var promiseDelay = require('sleep-promise');
|
||||
|
||||
describe('promise-retry', function () {
|
||||
it('should call fn again if retry was called', function () {
|
||||
var count = 0;
|
||||
|
||||
return promiseRetry(function (retry) {
|
||||
count += 1;
|
||||
|
||||
return promiseDelay(10)
|
||||
.then(function () {
|
||||
if (count <= 2) {
|
||||
retry(new Error('foo'));
|
||||
}
|
||||
|
||||
return 'final';
|
||||
});
|
||||
}, { factor: 1 })
|
||||
.then(function (value) {
|
||||
expect(value).to.be('final');
|
||||
expect(count).to.be(3);
|
||||
}, function () {
|
||||
throw new Error('should not fail');
|
||||
});
|
||||
});
|
||||
|
||||
it('should call fn with the attempt number', function () {
|
||||
var count = 0;
|
||||
|
||||
return promiseRetry(function (retry, number) {
|
||||
count += 1;
|
||||
expect(count).to.equal(number);
|
||||
|
||||
return promiseDelay(10)
|
||||
.then(function () {
|
||||
if (count <= 2) {
|
||||
retry(new Error('foo'));
|
||||
}
|
||||
|
||||
return 'final';
|
||||
});
|
||||
}, { factor: 1 })
|
||||
.then(function (value) {
|
||||
expect(value).to.be('final');
|
||||
expect(count).to.be(3);
|
||||
}, function () {
|
||||
throw new Error('should not fail');
|
||||
});
|
||||
});
|
||||
|
||||
it('should not retry on fulfillment if retry was not called', function () {
|
||||
var count = 0;
|
||||
|
||||
return promiseRetry(function () {
|
||||
count += 1;
|
||||
|
||||
return promiseDelay(10)
|
||||
.then(function () {
|
||||
return 'final';
|
||||
});
|
||||
})
|
||||
.then(function (value) {
|
||||
expect(value).to.be('final');
|
||||
expect(count).to.be(1);
|
||||
}, function () {
|
||||
throw new Error('should not fail');
|
||||
});
|
||||
});
|
||||
|
||||
it('should not retry on rejection if retry was not called', function () {
|
||||
var count = 0;
|
||||
|
||||
return promiseRetry(function () {
|
||||
count += 1;
|
||||
|
||||
return promiseDelay(10)
|
||||
.then(function () {
|
||||
throw new Error('foo');
|
||||
});
|
||||
})
|
||||
.then(function () {
|
||||
throw new Error('should not succeed');
|
||||
}, function (err) {
|
||||
expect(err.message).to.be('foo');
|
||||
expect(count).to.be(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not retry on rejection if nr of retries is 0', function () {
|
||||
var count = 0;
|
||||
|
||||
return promiseRetry(function (retry) {
|
||||
count += 1;
|
||||
|
||||
return promiseDelay(10)
|
||||
.then(function () {
|
||||
throw new Error('foo');
|
||||
})
|
||||
.catch(retry);
|
||||
}, { retries : 0 })
|
||||
.then(function () {
|
||||
throw new Error('should not succeed');
|
||||
}, function (err) {
|
||||
expect(err.message).to.be('foo');
|
||||
expect(count).to.be(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should reject the promise if the retries were exceeded', function () {
|
||||
var count = 0;
|
||||
|
||||
return promiseRetry(function (retry) {
|
||||
count += 1;
|
||||
|
||||
return promiseDelay(10)
|
||||
.then(function () {
|
||||
throw new Error('foo');
|
||||
})
|
||||
.catch(retry);
|
||||
}, { retries: 2, factor: 1 })
|
||||
.then(function () {
|
||||
throw new Error('should not succeed');
|
||||
}, function (err) {
|
||||
expect(err.message).to.be('foo');
|
||||
expect(count).to.be(3);
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass options to the underlying retry module', function () {
|
||||
var count = 0;
|
||||
|
||||
return promiseRetry(function (retry) {
|
||||
return promiseDelay(10)
|
||||
.then(function () {
|
||||
if (count < 2) {
|
||||
count += 1;
|
||||
retry(new Error('foo'));
|
||||
}
|
||||
|
||||
return 'final';
|
||||
});
|
||||
}, { retries: 1, factor: 1 })
|
||||
.then(function () {
|
||||
throw new Error('should not succeed');
|
||||
}, function (err) {
|
||||
expect(err.message).to.be('foo');
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert direct fulfillments into promises', function () {
|
||||
return promiseRetry(function () {
|
||||
return 'final';
|
||||
}, { factor: 1 })
|
||||
.then(function (value) {
|
||||
expect(value).to.be('final');
|
||||
}, function () {
|
||||
throw new Error('should not fail');
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert direct rejections into promises', function () {
|
||||
promiseRetry(function () {
|
||||
throw new Error('foo');
|
||||
}, { retries: 1, factor: 1 })
|
||||
.then(function () {
|
||||
throw new Error('should not succeed');
|
||||
}, function (err) {
|
||||
expect(err.message).to.be('foo');
|
||||
});
|
||||
});
|
||||
|
||||
it('should not crash on undefined rejections', function () {
|
||||
return promiseRetry(function () {
|
||||
throw undefined;
|
||||
}, { retries: 1, factor: 1 })
|
||||
.then(function () {
|
||||
throw new Error('should not succeed');
|
||||
}, function (err) {
|
||||
expect(err).to.be(undefined);
|
||||
})
|
||||
.then(function () {
|
||||
return promiseRetry(function (retry) {
|
||||
retry();
|
||||
}, { retries: 1, factor: 1 });
|
||||
})
|
||||
.then(function () {
|
||||
throw new Error('should not succeed');
|
||||
}, function (err) {
|
||||
expect(err).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
it('should retry if retry() was called with undefined', function () {
|
||||
var count = 0;
|
||||
|
||||
return promiseRetry(function (retry) {
|
||||
count += 1;
|
||||
|
||||
return promiseDelay(10)
|
||||
.then(function () {
|
||||
if (count <= 2) {
|
||||
retry();
|
||||
}
|
||||
|
||||
return 'final';
|
||||
});
|
||||
}, { factor: 1 })
|
||||
.then(function (value) {
|
||||
expect(value).to.be('final');
|
||||
expect(count).to.be(3);
|
||||
}, function () {
|
||||
throw new Error('should not fail');
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with several retries in the same chain', function () {
|
||||
var count = 0;
|
||||
|
||||
return promiseRetry(function (retry) {
|
||||
count += 1;
|
||||
|
||||
return promiseDelay(10)
|
||||
.then(function () {
|
||||
retry(new Error('foo'));
|
||||
})
|
||||
.catch(function (err) {
|
||||
retry(err);
|
||||
});
|
||||
}, { retries: 1, factor: 1 })
|
||||
.then(function () {
|
||||
throw new Error('should not succeed');
|
||||
}, function (err) {
|
||||
expect(err.message).to.be('foo');
|
||||
expect(count).to.be(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow options to be passed first', function () {
|
||||
var count = 0;
|
||||
|
||||
return promiseRetry({ factor: 1 }, function (retry) {
|
||||
count += 1;
|
||||
|
||||
return promiseDelay(10)
|
||||
.then(function () {
|
||||
if (count <= 2) {
|
||||
retry(new Error('foo'));
|
||||
}
|
||||
|
||||
return 'final';
|
||||
});
|
||||
}).then(function (value) {
|
||||
expect(value).to.be('final');
|
||||
expect(count).to.be(3);
|
||||
}, function () {
|
||||
throw new Error('should not fail');
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue