verdaccio-aws-s3-storage
Advanced tools
Comparing version 9.0.0 to 9.1.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [9.1.0](https://github.com/verdaccio/monorepo/compare/v9.0.0...v9.1.0) (2020-01-25) | ||
### Features | ||
* **verdaccio-aws-s3-storage:** separate s3 subfolders (key prefix for different packages) ([#313](https://github.com/verdaccio/monorepo/issues/313)) ([6639a71](https://github.com/verdaccio/monorepo/commit/6639a71c2d2056f93e913c71e27b4453acb029aa)) | ||
* **verdaccio-aws-s3-storage:** supporting environment variables ([#315](https://github.com/verdaccio/monorepo/issues/315)) ([0c532f0](https://github.com/verdaccio/monorepo/commit/0c532f0198aba786a3292e866e7a2d933a06d2fa)) | ||
# [9.0.0](https://github.com/verdaccio/monorepo/compare/v8.5.3...v9.0.0) (2020-01-07) | ||
@@ -8,0 +20,0 @@ |
@@ -16,2 +16,6 @@ "use strict"; | ||
var _addTrailingSlash = _interopRequireDefault(require("./addTrailingSlash")); | ||
var _setConfigValue = _interopRequireDefault(require("./setConfigValue")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -37,3 +41,3 @@ | ||
this.config = Object.assign({}, config.store['aws-s3-storage']); | ||
this.config = Object.assign(config, config.store['aws-s3-storage']); | ||
@@ -44,5 +48,10 @@ if (!this.config.bucket) { | ||
this.config.bucket = (0, _setConfigValue.default)(this.config.bucket); | ||
this.config.keyPrefix = (0, _setConfigValue.default)(this.config.keyPrefix); | ||
this.config.region = (0, _setConfigValue.default)(this.config.region); | ||
this.config.accessKeyId = (0, _setConfigValue.default)(this.config.accessKeyId); | ||
this.config.secretAccessKey = (0, _setConfigValue.default)(this.config.secretAccessKey); | ||
const configKeyPrefix = this.config.keyPrefix; | ||
this._localData = null; | ||
this.config.keyPrefix = configKeyPrefix != null ? configKeyPrefix.endsWith('/') ? configKeyPrefix : `${configKeyPrefix}/` : ''; | ||
this.config.keyPrefix = (0, _addTrailingSlash.default)(configKeyPrefix); | ||
this.logger.debug({ | ||
@@ -49,0 +58,0 @@ config: JSON.stringify(this.config, null, 4) |
@@ -7,4 +7,5 @@ import { UploadTarball, ReadTarball } from '@verdaccio/streams'; | ||
logger: Logger; | ||
private packageName; | ||
private s3; | ||
private readonly packageName; | ||
private readonly s3; | ||
private readonly packagePath; | ||
constructor(config: S3Config, packageName: string, logger: Logger); | ||
@@ -11,0 +12,0 @@ updatePackage(name: string, updateHandler: Callback, onWrite: Callback, transformPackage: Function, onEnd: Callback): void; |
@@ -18,2 +18,6 @@ "use strict"; | ||
var _addTrailingSlash = _interopRequireDefault(require("./addTrailingSlash")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -33,2 +37,4 @@ | ||
_defineProperty(this, "packagePath", void 0); | ||
this.config = config; | ||
@@ -69,2 +75,11 @@ this.packageName = packageName; | ||
}, 's3: [S3PackageManager constructor] secretAccessKey @{secretAccessKey}'); | ||
const packageAccess = this.config.getMatchedPackagesSpec(packageName); | ||
if (packageAccess) { | ||
const storage = packageAccess.storage; | ||
const packageCustomFolder = (0, _addTrailingSlash.default)(storage); | ||
this.packagePath = `${this.config.keyPrefix}${packageCustomFolder}${this.packageName}`; | ||
} else { | ||
this.packagePath = `${this.config.keyPrefix}${this.packageName}`; | ||
} | ||
} | ||
@@ -108,3 +123,3 @@ | ||
Bucket: this.config.bucket, | ||
Key: `${this.config.keyPrefix}${this.packageName}/${pkgFileName}` | ||
Key: `${this.packagePath}/${pkgFileName}` | ||
}, (err, response) => { | ||
@@ -147,3 +162,3 @@ if (err) { | ||
Bucket: this.config.bucket, | ||
Key: `${this.config.keyPrefix}${this.packageName}/${fileName}` | ||
Key: `${this.packagePath}/${fileName}` | ||
}, err => { | ||
@@ -161,3 +176,3 @@ if (err) { | ||
Bucket: this.config.bucket, | ||
Prefix: `${this.config.keyPrefix}${this.packageName}` | ||
Prefix: `${this.packagePath}` | ||
}, function (err) { | ||
@@ -182,3 +197,3 @@ if (err && (0, _s3Errors.is404Error)(err)) { | ||
Bucket: this.config.bucket, | ||
Key: `${this.config.keyPrefix}${this.packageName}/${pkgFileName}` | ||
Key: `${this.packagePath}/${pkgFileName}` | ||
}, (err, data) => { | ||
@@ -221,3 +236,3 @@ if (err) { | ||
Bucket: this.config.bucket, | ||
Key: `${this.config.keyPrefix}${this.packageName}/${pkgFileName}` | ||
Key: `${this.packagePath}/${pkgFileName}` | ||
}, callback); | ||
@@ -265,3 +280,3 @@ } | ||
Bucket: this.config.bucket, | ||
Key: `${this.config.keyPrefix}${this.packageName}/${name}` | ||
Key: `${this.packagePath}/${name}` | ||
}; // NOTE: I'm using listObjectVersions so I don't have to download the full object with getObject. | ||
@@ -273,3 +288,3 @@ // Preferably, I'd use getObjectMetadata or getDetails when it's available in the node sdk | ||
Bucket: this.config.bucket, | ||
Key: `${this.config.keyPrefix}${this.packageName}/${name}` | ||
Key: `${this.packagePath}/${name}` | ||
}, err => { | ||
@@ -382,3 +397,3 @@ if (err) { | ||
Bucket: this.config.bucket, | ||
Key: `${this.config.keyPrefix}${this.packageName}/${name}` | ||
Key: `${this.packagePath}/${name}` | ||
}); | ||
@@ -385,0 +400,0 @@ let headersSent = false; |
{ | ||
"name": "verdaccio-aws-s3-storage", | ||
"version": "9.0.0", | ||
"version": "9.1.0", | ||
"description": "AWS S3 storage implementation for Verdaccio", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"@verdaccio/streams": "^2.0.0", | ||
"aws-sdk": "2.596.0" | ||
"aws-sdk": "^2.607.0" | ||
}, | ||
@@ -40,2 +40,3 @@ "devDependencies": { | ||
"@verdaccio/types": "^9.0.0", | ||
"jest": "^24.9.0", | ||
"recursive-readdir": "2.2.2" | ||
@@ -57,3 +58,3 @@ }, | ||
}, | ||
"gitHead": "21c47d3360699577961e35d6720cb126f7011036" | ||
"gitHead": "26ddd6afbc9d9c47937c5944f24cb76199a44f49" | ||
} |
@@ -53,1 +53,52 @@ # verdaccio-aws-s3-storage | ||
``` | ||
The configured values can either be the actual value or the name of an environment variable that contains the value for the following options: | ||
- `bucket` | ||
- `keyPrefix` | ||
- `region` | ||
- `accessKeyID` | ||
- `secretAccessKey` | ||
``` yaml | ||
store: | ||
aws-s3-storage: | ||
bucket: S3_BUCKET # If an environment variable named S3_BUCKET is set, it will use that value. Otherwise assumes the bucket is named 'S3_BUCKET' | ||
keyPrefix: S3_KEY_PREFIX # If an environment variable named S3_KEY_PREFIX is set, it will use that value. Otherwise assumes the bucket is named 'S3_KEY_PREFIX' | ||
... | ||
``` | ||
store properties can be defined for packages. The storage location corresponds to the folder in s3 bucket. | ||
``` | ||
packages: | ||
'@scope/*': | ||
access: all | ||
publish: $all | ||
storage: 'scoped' | ||
'**': | ||
access: $all | ||
publish: $all | ||
proxy: npmjs | ||
storage: 'public' | ||
``` | ||
# Developer Testing # | ||
In case of local testing, this project can be used self-efficiently. Four main ingredients are as follows: | ||
* config.yaml, see [verdaccio documentation](https://verdaccio.org/docs/en/configuration.html) | ||
* The provided docker file allows to test the plugin, with no need for main verdaccio application | ||
* The provided docker-compose also provides minio in orchestration as a local substitute for S3 backend | ||
* registry.envs set as follows. This file does not exist on the repo and should be generated after cloning the project. | ||
``` | ||
AWS_ACCESS_KEY_ID=foobar | ||
AWS_SECRET_ACCESS_KEY=1234567e | ||
AWS_DEFAULT_REGION=eu-central-1 | ||
AWS_S3_ENDPOINT=https://localhost:9000/ | ||
AWS_S3_PATH_STYLE=true | ||
``` | ||
The default values should work out of the box. If you change anything, make sure the corresponding variables are set in | ||
other parts of the ingredient as well. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43395
18
820
104
5
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedaws-sdk@2.1692.0(transitive)
+ Addedbuffer@4.9.2(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-arguments@1.1.1(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-generator-function@1.0.10(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedjmespath@0.16.0(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedutil@0.12.5(transitive)
+ Addeduuid@8.0.0(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)
+ Addedxml2js@0.6.2(transitive)
+ Addedxmlbuilder@11.0.1(transitive)
- Removedaws-sdk@2.596.0(transitive)
- Removedbuffer@4.9.1(transitive)
- Removedjmespath@0.15.0(transitive)
- Removeduuid@3.3.2(transitive)
- Removedxml2js@0.4.19(transitive)
- Removedxmlbuilder@9.0.7(transitive)
Updatedaws-sdk@^2.607.0