webext-buildtools-chrome-webstore-builder
Advanced tools
Comparing version 1.0.8 to 1.1.0
@@ -35,2 +35,9 @@ import { PublishStatus, PublishTarget } from 'typed-chrome-webstore-api'; | ||
waitForSuccess?: IWaitForWebstoreOptions; | ||
/** | ||
* If true or not specified: if the same version is already uploaded throw an UploadVersionValidationError | ||
* If false, do not repeat upload, just put information about uploaded version to the output asset and continue | ||
* @default true | ||
*/ | ||
throwIfVersionAlreadyUploaded?: boolean; | ||
} | ||
@@ -104,2 +111,4 @@ | ||
/** | ||
@@ -106,0 +115,0 @@ * For uploadExt output, optional |
@@ -86,5 +86,16 @@ "use strict"; | ||
if (this._inputManifest && this._inputManifest.version) { | ||
await validateVersion_1.validateVersion(this._inputManifest.version, apiFacade, this._logWrapper); | ||
const throwIfVersionAlreadyUploaded = !(this._options.upload && | ||
this._options.upload.throwIfVersionAlreadyUploaded === false); | ||
const currentlyUploaded = await validateVersion_1.validateVersion(this._inputManifest.version, throwIfVersionAlreadyUploaded, apiFacade, this._logWrapper); | ||
if (!throwIfVersionAlreadyUploaded && currentlyUploaded) { | ||
result.getAssets().uploadedExt = new buildResult_1.ChromeWebstoreUploadedExtAsset({ | ||
extId: currentlyUploaded.id, | ||
extVersion: currentlyUploaded.crxVersion, | ||
apiResource: currentlyUploaded | ||
}); | ||
} | ||
} | ||
result.getAssets().uploadedExt = await upload_1.upload(this._inputZipBuffer, this._options.upload || {}, apiFacade, this._inputManifest); | ||
if (!result.getAssets().uploadedExt) { | ||
result.getAssets().uploadedExt = await upload_1.upload(this._inputZipBuffer, this._options.upload || {}, apiFacade, this._inputManifest); | ||
} | ||
} | ||
@@ -91,0 +102,0 @@ if (this._publishedExtRequired) { |
@@ -6,2 +6,3 @@ "use strict"; | ||
const buildResult_1 = require("../buildResult"); | ||
const errors_1 = require("../errors"); | ||
async function upload(inputZipBuffer, options, apiFacade, inputManifest) { | ||
@@ -26,10 +27,13 @@ let uploadResult; | ||
} | ||
const uploadErrorMsg = Array.isArray(uploadResult.itemError) | ||
const uploadErrorMsg = "Can't upload extension. " + (Array.isArray(uploadResult.itemError) | ||
? uploadResult.itemError | ||
.map(err => err.error_detail) | ||
.join('. ') | ||
: `Upload has ${uploadResult.uploadState} state`; | ||
throw new Error(`Can't upload extension. ${uploadErrorMsg}`); | ||
: `Upload has ${uploadResult.uploadState} state`); | ||
if (uploadResult.isFailedBecauseOfPendingReview()) { | ||
throw new errors_1.UploadInReviewError(uploadErrorMsg); | ||
} | ||
throw new Error(uploadErrorMsg); | ||
} | ||
exports.upload = upload; | ||
//# sourceMappingURL=upload.js.map |
import { LoggerWrapper } from 'webext-buildtools-utils'; | ||
import { ChromeWebstoreApiFacade } from '../chromeWebstoreApiFacade'; | ||
export declare function validateVersion(manifestVersion: string, apiFacade: ChromeWebstoreApiFacade, logWrapper: LoggerWrapper): Promise<void>; | ||
import * as webstoreApi from 'typed-chrome-webstore-api'; | ||
/** | ||
* @param manifestVersion | ||
* @param throwIfAlreadyUploaded throw if current uploaded version equal to manifestVersion | ||
* @param apiFacade | ||
* @param logWrapper | ||
* @return currently uploaded resource info | ||
*/ | ||
export declare function validateVersion(manifestVersion: string, throwIfAlreadyUploaded: boolean, apiFacade: ChromeWebstoreApiFacade, logWrapper: LoggerWrapper): Promise<webstoreApi.WebstoreResource | null>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const semver = require("semver"); | ||
async function validateVersion(manifestVersion, apiFacade, logWrapper) { | ||
if (semver.valid(manifestVersion)) { | ||
const versions = require("compare-versions"); | ||
const errors_1 = require("../errors"); | ||
/** | ||
* @param manifestVersion | ||
* @param throwIfAlreadyUploaded throw if current uploaded version equal to manifestVersion | ||
* @param apiFacade | ||
* @param logWrapper | ||
* @return currently uploaded resource info | ||
*/ | ||
async function validateVersion(manifestVersion, throwIfAlreadyUploaded, apiFacade, logWrapper) { | ||
if (versions.validate(manifestVersion)) { | ||
logWrapper.info(`New extension version is '${manifestVersion}' (from manifest input)`); | ||
} | ||
else { | ||
logWrapper.warn(`New extension semver version is invalid: '${manifestVersion}'`); | ||
return; | ||
throw new errors_1.InvalidManifestVersionError(manifestVersion); | ||
} | ||
const currentVersion = await apiFacade.getCurrentVersion(); | ||
if (currentVersion) { | ||
if (semver.valid(currentVersion) && semver) { | ||
logWrapper.info(`Version of currently published extension is '${currentVersion}'`); | ||
const currentResource = await apiFacade.getCurrentlyUploadedResource(); | ||
const currentVersion = currentResource.crxVersion; | ||
if (!currentVersion) { | ||
return null; | ||
} | ||
if (versions.validate(currentVersion)) { | ||
logWrapper.info(`Version of currently published extension is '${currentVersion}'`); | ||
} | ||
else { | ||
logWrapper.warn(`Invalid semver version of published crx: '${currentVersion}'`); | ||
return null; | ||
} | ||
if (versions.compare(manifestVersion, currentVersion, '=')) { | ||
if (throwIfAlreadyUploaded) { | ||
throw new errors_1.SameVersionAlreadyUploadedError(currentVersion); | ||
} | ||
else { | ||
logWrapper.warn(`Invalid semver version of published crx: '${currentVersion}'`); | ||
} | ||
if (semver.lte(manifestVersion, currentVersion)) { | ||
throw new Error(`New ${manifestVersion} version have to be ` + | ||
`greater than the current ${currentVersion}`); | ||
} | ||
return currentResource; | ||
} | ||
if (versions.compare(manifestVersion, currentVersion, '<=')) { | ||
throw new errors_1.NewerVersionAlreadyUploadedError(manifestVersion, currentVersion); | ||
} | ||
return null; | ||
} | ||
exports.validateVersion = validateVersion; | ||
//# sourceMappingURL=validateVersion.js.map |
@@ -14,5 +14,5 @@ /// <reference types="node" /> | ||
setLogMethod(logMethod?: ILogMethod): void; | ||
getCurrentVersion(): Promise<string | undefined>; | ||
uploadExisting(readStream: Buffer | Readable, waitForSuccess?: IWaitForWebstoreOptions): Promise<webstoreApi.IWebstoreResource>; | ||
getCurrentlyUploadedResource(): Promise<webstoreApi.WebstoreResource>; | ||
uploadExisting(readStream: Buffer | Readable, waitForSuccess?: IWaitForWebstoreOptions): Promise<webstoreApi.WebstoreResource>; | ||
publish(target: webstoreApi.PublishTarget | string): Promise<webstoreApi.IPublishResponse>; | ||
} |
@@ -23,7 +23,7 @@ "use strict"; | ||
} | ||
async getCurrentVersion() { | ||
async getCurrentlyUploadedResource() { | ||
this._logWrapper.info('Loading information about current ext version...'); | ||
const current = await this._api.getUpload(this._extensionId); | ||
this._logWrapper.info('Finished: %o', current); | ||
return current.crxVersion; | ||
return current; | ||
} | ||
@@ -30,0 +30,0 @@ async uploadExisting(readStream, waitForSuccess) { |
@@ -8,1 +8,2 @@ import { ChromeWebstoreBuilder } from './builder'; | ||
export * from './buildResult'; | ||
export * from './errors'; |
@@ -9,2 +9,3 @@ "use strict"; | ||
__export(require("./buildResult")); | ||
__export(require("./errors")); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "webext-buildtools-chrome-webstore-builder", | ||
"version": "1.0.8", | ||
"version": "1.1.0", | ||
"description": "webext-buildtools builder for deploying to Chrome Webstore. Based on chrome-webstore-upload", | ||
@@ -32,4 +32,4 @@ "main": "dist", | ||
"fs-extra": "^7.0.1", | ||
"semver": "^5.6.0", | ||
"typed-chrome-webstore-api": "^0.3.6", | ||
"compare-versions": "^3.6.0", | ||
"typed-chrome-webstore-api": "^0.4.9", | ||
"webext-buildtools-utils": "^1.0.5" | ||
@@ -41,3 +41,3 @@ }, | ||
"@types/fs-extra": "^5.0.5", | ||
"@types/semver": "^5.5.0", | ||
"@types/compare-versions": "^3.3.0", | ||
"@types/axios": "^0.14.0", | ||
@@ -44,0 +44,0 @@ "tslint": "^6.1.2", |
@@ -88,2 +88,12 @@ [![Build Status](https://travis-ci.com/cardinalby/webext-buildtools-chrome-webstore-builder.svg?branch=master)](https://travis-ci.com/cardinalby/webext-buildtools-chrome-webstore-builder) | ||
`const crxFilePath = buildResult.getAssets().publishedCrxFile.getValue()`<br> | ||
`const crxBuffer = buildResult.getAssets().publishedCrxBuffer.getValue()` | ||
`const crxBuffer = buildResult.getAssets().publishedCrxBuffer.getValue()` | ||
### Errors | ||
`builder.build()` call can be rejected with general `Error` or the following specific errors if | ||
extension upload was required: | ||
* `InvalidManifestVersionError` if manifest file has invalid extension version. | ||
* `NewerVersionAlreadyUploadedError` if currently uploaded version is greater than the version in | ||
the extension manifest. | ||
* `SameVersionAlreadyUploadedError` if currently uploaded version equals to the version in | ||
the extension manifest. | ||
* `UploadInReviewError` if upload failed due to item currently in the review state. |
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
42678
37
768
98
+ Addedcompare-versions@^3.6.0
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@1.7.8(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcompare-versions@3.6.0(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedtyped-chrome-webstore-api@0.4.16(transitive)
- Removedsemver@^5.6.0
- Removedaxios@0.19.2(transitive)
- Removedfollow-redirects@1.5.10(transitive)
- Removedsemver@5.7.2(transitive)
- Removedtyped-chrome-webstore-api@0.3.7(transitive)