Comparing version 6.4.1 to 6.5.0-next.1627490305.70d636cf1825e8ec06a30daa899e4c09c68f7d20
@@ -0,1 +1,2 @@ | ||
import { Errtion } from './util.js'; | ||
export declare type Range = string | boolean; | ||
@@ -77,2 +78,4 @@ export declare type Engines = false | { | ||
engines: Engines; | ||
/** If this edition fails to load, then this property provides any accompanying information. */ | ||
debugging?: Errtion; | ||
} | ||
@@ -79,0 +82,0 @@ /** Editions should be ordered from most preferable first to least desirable last. The source edition should always be first, proceeded by compiled editions. */ |
@@ -102,29 +102,40 @@ var __assign = (this && this.__assign) || function () { | ||
// broadened range | ||
// https://github.com/bevry/editions/blob/master/HISTORY.md#v210-2018-november-15 | ||
// If none of the editions for a package match the current node version, editions will try to find a compatible package by converting strict version ranges likes 4 || 6 || 8 || 10 to looser ones like >=4, and if that fails, then it will attempt to load the last edition for the environment. | ||
// This brings editions handling of engines closer in line with how node handles it, which is as a warning/recommendation, rather than a requirement/enforcement. | ||
// This has the benefit that edition authors can specify ranges as the specific versions that they have tested the edition against that pass, rather than having to omit that information for runtime compatibility. | ||
// As such editions will now automatically select the edition with guaranteed support for the environment, and if there are none with guaranteed support, then editions will select the one is most likely supported, and if there are none that are likely supported, then it will try the last edition, which should be the most compatible edition. | ||
// This is timely, as node v11 is now the version most developers use, yet if edition authors specified only LTS releases, then the editions autoloader would reject loading on v11, despite compatibility being likely with the most upper edition. | ||
// NOTE: That there is only one broadening chance per package, once a broadened edition has been returned, a load will be attempted, and if it fails, then the package failed. This is intentional. | ||
if (broadenRange === true) { | ||
// broaden the range | ||
var index = range.indexOf('||'); | ||
if (index !== -1) { | ||
var broadenedRange = range.substr(index); | ||
// broadened range attempt | ||
try { | ||
if (matchRange(version, broadenedRange)) | ||
return true; | ||
} | ||
catch (error) { | ||
throw errtion({ | ||
message: "The broadened range [" + broadenedRange + "] was invalid, something is wrong within Editions.", | ||
code: 'editions-autoloader-invalid-broadened-range', | ||
level: 'fatal', | ||
}, error); | ||
} | ||
// fail broadened range | ||
// check if range can be broadened, validate it and extract | ||
var broadenedRangeRegex = /^\s*([0-9.]+)\s*(\|\|\s*[0-9.]+\s*)*$/; | ||
var broadenedRangeMatch = range.match(broadenedRangeRegex); | ||
var lowestVersion = (broadenedRangeMatch && broadenedRangeMatch[1]) || ''; | ||
// ^ can't do number conversion, as 1.1.1 is not a number | ||
// this also converts 0 to '' which is what we want for the next check | ||
// confirm the validation | ||
if (lowestVersion === '') | ||
throw errtion({ | ||
message: "The edition range [" + range + "] does not support this engine version [" + version + "], even when broadened to [" + broadenedRange + "]", | ||
code: 'editions-autoloader-engine-incompatible-broadened', | ||
message: "The range [" + range + "] is not able to be broadened, only ranges in format of [lowest] or [lowest || ... || ... ] can be broadened. Update the Editions definition and try again.", | ||
code: 'editions-autoloader-unsupported-broadened-range', | ||
level: 'fatal', | ||
}); | ||
// create the broadened range, and attempt that | ||
var broadenedRange = ">= " + lowestVersion; | ||
try { | ||
if (matchRange(version, broadenedRange)) | ||
return true; | ||
} | ||
// give up | ||
catch (error) { | ||
throw errtion({ | ||
message: "The broadened range [" + broadenedRange + "] was invalid, something is wrong within Editions.", | ||
code: 'editions-autoloader-invalid-broadened-range', | ||
level: 'fatal', | ||
}, error); | ||
} | ||
// broadened range was incompatible | ||
throw errtion({ | ||
message: "The edition range [" + range + "] does not support this engine version [" + version + "] and could not be broadened", | ||
code: 'editions-autoloader-engine-incompatible-nobroad', | ||
message: "The edition range [" + range + "] does not support this engine version [" + version + "], even when broadened to [" + broadenedRange + "]", | ||
code: 'editions-autoloader-engine-incompatible-broadened-range', | ||
}); | ||
@@ -238,3 +249,3 @@ } | ||
isCompatibleEdition(edition, opts); | ||
// return the edition if it is successful | ||
// Success! Return the edition | ||
return edition; | ||
@@ -258,3 +269,3 @@ } | ||
} | ||
// | ||
// Report the failure from above | ||
if (failure) { | ||
@@ -264,3 +275,10 @@ // try broadened | ||
try { | ||
return determineEdition(editions, __assign(__assign({}, opts), { broadenRange: true })); | ||
// return if broadening successfully returned an edition | ||
var broadenedEdition = determineEdition(editions, __assign(__assign({}, opts), { broadenRange: true })); | ||
return __assign(__assign({}, broadenedEdition), { | ||
// bubble the circumstances up in case the loading of the broadened edition fails and needs to be reported | ||
debugging: errtion({ | ||
message: "The edition " + broadenedEdition.description + " was selected to be force loaded as its range was broadened.", | ||
code: 'editions-autoloader-attempt-broadened', | ||
}) }); | ||
} | ||
@@ -292,3 +310,8 @@ catch (error) { | ||
var edition = determineEdition(editions, opts); | ||
return loadEdition(edition, opts); | ||
try { | ||
return loadEdition(edition, opts); | ||
} | ||
catch (error) { | ||
throw errtion(error, edition.debugging); | ||
} | ||
} | ||
@@ -295,0 +318,0 @@ /** |
@@ -110,29 +110,40 @@ "use strict"; | ||
// broadened range | ||
// https://github.com/bevry/editions/blob/master/HISTORY.md#v210-2018-november-15 | ||
// If none of the editions for a package match the current node version, editions will try to find a compatible package by converting strict version ranges likes 4 || 6 || 8 || 10 to looser ones like >=4, and if that fails, then it will attempt to load the last edition for the environment. | ||
// This brings editions handling of engines closer in line with how node handles it, which is as a warning/recommendation, rather than a requirement/enforcement. | ||
// This has the benefit that edition authors can specify ranges as the specific versions that they have tested the edition against that pass, rather than having to omit that information for runtime compatibility. | ||
// As such editions will now automatically select the edition with guaranteed support for the environment, and if there are none with guaranteed support, then editions will select the one is most likely supported, and if there are none that are likely supported, then it will try the last edition, which should be the most compatible edition. | ||
// This is timely, as node v11 is now the version most developers use, yet if edition authors specified only LTS releases, then the editions autoloader would reject loading on v11, despite compatibility being likely with the most upper edition. | ||
// NOTE: That there is only one broadening chance per package, once a broadened edition has been returned, a load will be attempted, and if it fails, then the package failed. This is intentional. | ||
if (broadenRange === true) { | ||
// broaden the range | ||
var index = range.indexOf('||'); | ||
if (index !== -1) { | ||
var broadenedRange = range.substr(index); | ||
// broadened range attempt | ||
try { | ||
if (version_range_1.default(version, broadenedRange)) | ||
return true; | ||
} | ||
catch (error) { | ||
throw util_js_1.errtion({ | ||
message: "The broadened range [" + broadenedRange + "] was invalid, something is wrong within Editions.", | ||
code: 'editions-autoloader-invalid-broadened-range', | ||
level: 'fatal', | ||
}, error); | ||
} | ||
// fail broadened range | ||
// check if range can be broadened, validate it and extract | ||
var broadenedRangeRegex = /^\s*([0-9.]+)\s*(\|\|\s*[0-9.]+\s*)*$/; | ||
var broadenedRangeMatch = range.match(broadenedRangeRegex); | ||
var lowestVersion = (broadenedRangeMatch && broadenedRangeMatch[1]) || ''; | ||
// ^ can't do number conversion, as 1.1.1 is not a number | ||
// this also converts 0 to '' which is what we want for the next check | ||
// confirm the validation | ||
if (lowestVersion === '') | ||
throw util_js_1.errtion({ | ||
message: "The edition range [" + range + "] does not support this engine version [" + version + "], even when broadened to [" + broadenedRange + "]", | ||
code: 'editions-autoloader-engine-incompatible-broadened', | ||
message: "The range [" + range + "] is not able to be broadened, only ranges in format of [lowest] or [lowest || ... || ... ] can be broadened. Update the Editions definition and try again.", | ||
code: 'editions-autoloader-unsupported-broadened-range', | ||
level: 'fatal', | ||
}); | ||
// create the broadened range, and attempt that | ||
var broadenedRange = ">= " + lowestVersion; | ||
try { | ||
if (version_range_1.default(version, broadenedRange)) | ||
return true; | ||
} | ||
// give up | ||
catch (error) { | ||
throw util_js_1.errtion({ | ||
message: "The broadened range [" + broadenedRange + "] was invalid, something is wrong within Editions.", | ||
code: 'editions-autoloader-invalid-broadened-range', | ||
level: 'fatal', | ||
}, error); | ||
} | ||
// broadened range was incompatible | ||
throw util_js_1.errtion({ | ||
message: "The edition range [" + range + "] does not support this engine version [" + version + "] and could not be broadened", | ||
code: 'editions-autoloader-engine-incompatible-nobroad', | ||
message: "The edition range [" + range + "] does not support this engine version [" + version + "], even when broadened to [" + broadenedRange + "]", | ||
code: 'editions-autoloader-engine-incompatible-broadened-range', | ||
}); | ||
@@ -249,3 +260,3 @@ } | ||
isCompatibleEdition(edition, opts); | ||
// return the edition if it is successful | ||
// Success! Return the edition | ||
return edition; | ||
@@ -269,3 +280,3 @@ } | ||
} | ||
// | ||
// Report the failure from above | ||
if (failure) { | ||
@@ -275,3 +286,10 @@ // try broadened | ||
try { | ||
return determineEdition(editions, __assign(__assign({}, opts), { broadenRange: true })); | ||
// return if broadening successfully returned an edition | ||
var broadenedEdition = determineEdition(editions, __assign(__assign({}, opts), { broadenRange: true })); | ||
return __assign(__assign({}, broadenedEdition), { | ||
// bubble the circumstances up in case the loading of the broadened edition fails and needs to be reported | ||
debugging: util_js_1.errtion({ | ||
message: "The edition " + broadenedEdition.description + " was selected to be force loaded as its range was broadened.", | ||
code: 'editions-autoloader-attempt-broadened', | ||
}) }); | ||
} | ||
@@ -304,3 +322,8 @@ catch (error) { | ||
var edition = determineEdition(editions, opts); | ||
return loadEdition(edition, opts); | ||
try { | ||
return loadEdition(edition, opts); | ||
} | ||
catch (error) { | ||
throw util_js_1.errtion(error, edition.debugging); | ||
} | ||
} | ||
@@ -307,0 +330,0 @@ exports.solicitEdition = solicitEdition; |
# History | ||
## v6.5.0 2021 July 29 | ||
- Fixed [#235](https://github.com/bevry/editions/issues/235) | ||
- Validate that the range can be broadened before it is attempted to be, and add more tests and reporting around broadening, its conditions, and its failures. | ||
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation) | ||
## v6.4.1 2021 July 28 | ||
@@ -176,7 +182,7 @@ | ||
- If none of the editions for a package match the current node version, editions will try to find a compatible package by converting strict version ranges likes `4 || 6 || 8 || 10` to looser ones like `>=4`, and if that fails, then it will attempt to load the last edition for the environment. | ||
- This brings editions handling of engines closer in line with how node handles it, which is as a warning/recomendation, rather than a requirement/enforcement. | ||
- This brings editions handling of engines closer in line with how node handles it, which is as a warning/recommendation, rather than a requirement/enforcement. | ||
- This has the benefit that edition authors can specify ranges as the specific versions that they have tested the edition against that pass, rather than having to omit that information for runtime compatibility. | ||
- As such editions will now automatically select the edition with guaranteed support for the environment, and if there are none with guaranteed support, then editions will select the one is most likely supported, and if there are none that are likely supported, then it will try the last edition, which should be the most compatible edition. | ||
- This is timely, as node v11 is now the version most developers use, yet if edition authors specified only LTS releases, then the editions autoloader would reject loading on v11, despite compatibility being likely with the most upper edition. | ||
- This behaviour is dictated by the new `strict` option, which omission of a value enables the above behaviour. | ||
- This behaviour is dictated by the new `strict` option, which omission of a value enables the above behavior. | ||
- Change `syntaxes` to `tags`, with backwards compatibility. This applies to edition specifications, as well as for the blacklist environment variable which is now named `EDITIONS_TAG_BLACKLIST`. | ||
@@ -183,0 +189,0 @@ - Added codes to the different types of errors we may produce. |
{ | ||
"name": "editions", | ||
"version": "6.4.1", | ||
"version": "6.5.0-next.1627490305.70d636cf1825e8ec06a30daa899e4c09c68f7d20", | ||
"description": "Publish multiple editions for your JavaScript packages consistently and easily (e.g. source edition, esnext edition, es2015 edition)", | ||
@@ -100,3 +100,3 @@ "homepage": "https://github.com/bevry/editions", | ||
"engines": { | ||
"node": "4 || 6 || 8 || 10 || 12 || 14", | ||
"node": "4 || 6 || 8 || 10 || 12 || 14 || 16", | ||
"browsers": false | ||
@@ -116,3 +116,3 @@ } | ||
"engines": { | ||
"node": "12 || 14", | ||
"node": "12 || 14 || 16", | ||
"browsers": false | ||
@@ -135,5 +135,6 @@ } | ||
"devDependencies": { | ||
"@bevry/update-contributors": "^1.18.0", | ||
"@bevry/update-contributors": "^1.19.0", | ||
"@typescript-eslint/eslint-plugin": "^4.28.5", | ||
"@typescript-eslint/parser": "^4.28.5", | ||
"assert-helpers": "^8.2.0", | ||
"eslint": "^7.31.0", | ||
@@ -140,0 +141,0 @@ "eslint-config-bevry": "^3.23.0", |
@@ -42,3 +42,3 @@ <!-- TITLE/ --> | ||
[View the Editions Autoloader API documentation.](http://master.editions.bevry.surge.sh/docs/globals.html) | ||
[View the Editions Autoloader API documentation.](http://master.editions.bevry.surge.sh/docs/) | ||
@@ -45,0 +45,0 @@ <!-- HISTORY/ --> |
@@ -85,2 +85,5 @@ // Imports | ||
engines: Engines | ||
/** If this edition fails to load, then this property provides any accompanying information. */ | ||
debugging?: Errtion | ||
} | ||
@@ -229,33 +232,45 @@ | ||
// broadened range | ||
// https://github.com/bevry/editions/blob/master/HISTORY.md#v210-2018-november-15 | ||
// If none of the editions for a package match the current node version, editions will try to find a compatible package by converting strict version ranges likes 4 || 6 || 8 || 10 to looser ones like >=4, and if that fails, then it will attempt to load the last edition for the environment. | ||
// This brings editions handling of engines closer in line with how node handles it, which is as a warning/recommendation, rather than a requirement/enforcement. | ||
// This has the benefit that edition authors can specify ranges as the specific versions that they have tested the edition against that pass, rather than having to omit that information for runtime compatibility. | ||
// As such editions will now automatically select the edition with guaranteed support for the environment, and if there are none with guaranteed support, then editions will select the one is most likely supported, and if there are none that are likely supported, then it will try the last edition, which should be the most compatible edition. | ||
// This is timely, as node v11 is now the version most developers use, yet if edition authors specified only LTS releases, then the editions autoloader would reject loading on v11, despite compatibility being likely with the most upper edition. | ||
// NOTE: That there is only one broadening chance per package, once a broadened edition has been returned, a load will be attempted, and if it fails, then the package failed. This is intentional. | ||
if (broadenRange === true) { | ||
// broaden the range | ||
const index = range.indexOf('||') | ||
if (index !== -1) { | ||
const broadenedRange = range.substr(index) | ||
// check if range can be broadened, validate it and extract | ||
const broadenedRangeRegex = /^\s*([0-9.]+)\s*(\|\|\s*[0-9.]+\s*)*$/ | ||
const broadenedRangeMatch = range.match(broadenedRangeRegex) | ||
const lowestVersion: string = | ||
(broadenedRangeMatch && broadenedRangeMatch[1]) || '' | ||
// ^ can't do number conversion, as 1.1.1 is not a number | ||
// this also converts 0 to '' which is what we want for the next check | ||
// broadened range attempt | ||
try { | ||
if (matchRange(version, broadenedRange)) return true | ||
} catch (error) { | ||
throw errtion( | ||
{ | ||
message: `The broadened range [${broadenedRange}] was invalid, something is wrong within Editions.`, | ||
code: 'editions-autoloader-invalid-broadened-range', | ||
level: 'fatal', | ||
}, | ||
error | ||
) | ||
} | ||
// fail broadened range | ||
// confirm the validation | ||
if (lowestVersion === '') | ||
throw errtion({ | ||
message: `The edition range [${range}] does not support this engine version [${version}], even when broadened to [${broadenedRange}]`, | ||
code: 'editions-autoloader-engine-incompatible-broadened', | ||
message: `The range [${range}] is not able to be broadened, only ranges in format of [lowest] or [lowest || ... || ... ] can be broadened. Update the Editions definition and try again.`, | ||
code: 'editions-autoloader-unsupported-broadened-range', | ||
level: 'fatal', | ||
}) | ||
// create the broadened range, and attempt that | ||
const broadenedRange = `>= ${lowestVersion}` | ||
try { | ||
if (matchRange(version, broadenedRange)) return true | ||
} catch (error) { | ||
throw errtion( | ||
{ | ||
message: `The broadened range [${broadenedRange}] was invalid, something is wrong within Editions.`, | ||
code: 'editions-autoloader-invalid-broadened-range', | ||
level: 'fatal', | ||
}, | ||
error | ||
) | ||
} | ||
// give up | ||
// broadened range was incompatible | ||
throw errtion({ | ||
message: `The edition range [${range}] does not support this engine version [${version}] and could not be broadened`, | ||
code: 'editions-autoloader-engine-incompatible-nobroad', | ||
message: `The edition range [${range}] does not support this engine version [${version}], even when broadened to [${broadenedRange}]`, | ||
code: 'editions-autoloader-engine-incompatible-broadened-range', | ||
}) | ||
@@ -396,3 +411,3 @@ } | ||
// return the edition if it is successful | ||
// Success! Return the edition | ||
return edition | ||
@@ -417,3 +432,3 @@ } catch (error) { | ||
// | ||
// Report the failure from above | ||
if (failure) { | ||
@@ -423,3 +438,15 @@ // try broadened | ||
try { | ||
return determineEdition(editions, { ...opts, broadenRange: true }) | ||
// return if broadening successfully returned an edition | ||
const broadenedEdition = determineEdition(editions, { | ||
...opts, | ||
broadenRange: true, | ||
}) | ||
return { | ||
...broadenedEdition, | ||
// bubble the circumstances up in case the loading of the broadened edition fails and needs to be reported | ||
debugging: errtion({ | ||
message: `The edition ${broadenedEdition.description} was selected to be force loaded as its range was broadened.`, | ||
code: 'editions-autoloader-attempt-broadened', | ||
}), | ||
} | ||
} catch (error) { | ||
@@ -459,3 +486,7 @@ throw errtion( | ||
const edition = determineEdition(editions, opts) | ||
return loadEdition<T>(edition, opts) | ||
try { | ||
return loadEdition<T>(edition, opts) | ||
} catch (error) { | ||
throw errtion(error, edition.debugging) | ||
} | ||
} | ||
@@ -462,0 +493,0 @@ |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
88181
1444
16
1