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/infer-owner/LICENSE
generated
vendored
Normal file
15
node_modules/infer-owner/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
The ISC License
|
||||
|
||||
Copyright (c) npm, Inc. and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
41
node_modules/infer-owner/README.md
generated
vendored
Normal file
41
node_modules/infer-owner/README.md
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
# infer-owner
|
||||
|
||||
Infer the owner of a path based on the owner of its nearest existing parent
|
||||
|
||||
## USAGE
|
||||
|
||||
```js
|
||||
const inferOwner = require('infer-owner')
|
||||
|
||||
inferOwner('/some/cache/folder/file').then(owner => {
|
||||
// owner is {uid, gid} that should be attached to
|
||||
// the /some/cache/folder/file, based on ownership
|
||||
// of /some/cache/folder, /some/cache, /some, or /,
|
||||
// whichever is the first to exist
|
||||
})
|
||||
|
||||
// same, but not async
|
||||
const owner = inferOwner.sync('/some/cache/folder/file')
|
||||
|
||||
// results are cached! to reset the cache (eg, to change
|
||||
// permissions for whatever reason), do this:
|
||||
inferOwner.clearCache()
|
||||
```
|
||||
|
||||
This module endeavors to be as performant as possible. Parallel requests
|
||||
for ownership of the same path will only stat the directories one time.
|
||||
|
||||
## API
|
||||
|
||||
* `inferOwner(path) -> Promise<{ uid, gid }>`
|
||||
|
||||
If the path exists, return its uid and gid. If it does not, look to
|
||||
its parent, then its grandparent, and so on.
|
||||
|
||||
* `inferOwner(path) -> { uid, gid }`
|
||||
|
||||
Sync form of `inferOwner(path)`.
|
||||
|
||||
* `inferOwner.clearCache()`
|
||||
|
||||
Delete all cached ownership information and in-flight tracking.
|
71
node_modules/infer-owner/index.js
generated
vendored
Normal file
71
node_modules/infer-owner/index.js
generated
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
const cache = new Map()
|
||||
const fs = require('fs')
|
||||
const { dirname, resolve } = require('path')
|
||||
|
||||
|
||||
const lstat = path => new Promise((res, rej) =>
|
||||
fs.lstat(path, (er, st) => er ? rej(er) : res(st)))
|
||||
|
||||
const inferOwner = path => {
|
||||
path = resolve(path)
|
||||
if (cache.has(path))
|
||||
return Promise.resolve(cache.get(path))
|
||||
|
||||
const statThen = st => {
|
||||
const { uid, gid } = st
|
||||
cache.set(path, { uid, gid })
|
||||
return { uid, gid }
|
||||
}
|
||||
const parent = dirname(path)
|
||||
const parentTrap = parent === path ? null : er => {
|
||||
return inferOwner(parent).then((owner) => {
|
||||
cache.set(path, owner)
|
||||
return owner
|
||||
})
|
||||
}
|
||||
return lstat(path).then(statThen, parentTrap)
|
||||
}
|
||||
|
||||
const inferOwnerSync = path => {
|
||||
path = resolve(path)
|
||||
if (cache.has(path))
|
||||
return cache.get(path)
|
||||
|
||||
const parent = dirname(path)
|
||||
|
||||
// avoid obscuring call site by re-throwing
|
||||
// "catch" the error by returning from a finally,
|
||||
// only if we're not at the root, and the parent call works.
|
||||
let threw = true
|
||||
try {
|
||||
const st = fs.lstatSync(path)
|
||||
threw = false
|
||||
const { uid, gid } = st
|
||||
cache.set(path, { uid, gid })
|
||||
return { uid, gid }
|
||||
} finally {
|
||||
if (threw && parent !== path) {
|
||||
const owner = inferOwnerSync(parent)
|
||||
cache.set(path, owner)
|
||||
return owner // eslint-disable-line no-unsafe-finally
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const inflight = new Map()
|
||||
module.exports = path => {
|
||||
path = resolve(path)
|
||||
if (inflight.has(path))
|
||||
return Promise.resolve(inflight.get(path))
|
||||
const p = inferOwner(path).then(owner => {
|
||||
inflight.delete(path)
|
||||
return owner
|
||||
})
|
||||
inflight.set(path, p)
|
||||
return p
|
||||
}
|
||||
module.exports.sync = inferOwnerSync
|
||||
module.exports.clearCache = () => {
|
||||
cache.clear()
|
||||
inflight.clear()
|
||||
}
|
63
node_modules/infer-owner/package.json
generated
vendored
Normal file
63
node_modules/infer-owner/package.json
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"_from": "infer-owner@^1.0.4",
|
||||
"_id": "infer-owner@1.0.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==",
|
||||
"_location": "/infer-owner",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "infer-owner@^1.0.4",
|
||||
"name": "infer-owner",
|
||||
"escapedName": "infer-owner",
|
||||
"rawSpec": "^1.0.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cacache",
|
||||
"/pacote"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz",
|
||||
"_shasum": "c4cefcaa8e51051c2a40ba2ce8a3d27295af9467",
|
||||
"_spec": "infer-owner@^1.0.4",
|
||||
"_where": "/home/shimataro/projects/actions/ssh-key-action/node_modules/pacote",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "https://izs.me"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/npm/infer-owner/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Infer the owner of a path based on the owner of its nearest existing parent",
|
||||
"devDependencies": {
|
||||
"mutate-fs": "^2.1.1",
|
||||
"tap": "^12.4.2"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/npm/infer-owner#readme",
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"name": "infer-owner",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/npm/infer-owner.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postpublish": "git push origin --follow-tags",
|
||||
"postversion": "npm publish",
|
||||
"preversion": "npm test",
|
||||
"snap": "TAP_SNAPSHOT=1 tap -J test/*.js --100",
|
||||
"test": "tap -J test/*.js --100"
|
||||
},
|
||||
"version": "1.0.4"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue