@gasket/resolve
Advanced tools
Comparing version 6.0.0-canary.0 to 6.0.0-canary.8
# `@gasket/resolve` | ||
### 6.0.0 | ||
- Remove package name fallbacks ([#227]) | ||
### 5.3.1 | ||
@@ -59,3 +63,4 @@ | ||
[#156]: https://github.com/godaddy/gasket/pull/156 | ||
[#227]: https://github.com/godaddy/gasket/pull/227 | ||
[Loader]:/packages/gasket-resolve/docs/api.md#loader |
@@ -9,3 +9,3 @@ const reScope = /(@[\w-.]+)(\/.+)?/; | ||
* @param {string} [type] - Identifier type, defaults to 'plugin' | ||
* @returns {{prefixed: {project: RegExp, user: RegExp}, postfixed: {project: RegExp, user: RegExp}, scope: RegExp}} re | ||
* @returns {{prefixed: {project: RegExp, user: RegExp}, scope: RegExp}} re | ||
* @private | ||
@@ -19,6 +19,2 @@ */ | ||
user: new RegExp(`(@[\\w-.]+)?\\/?${projectName}-${type}-?([\\w-.]+)?`) | ||
}, | ||
postfixed: { | ||
project: new RegExp(`(@${projectName})/([\\w-.]+)-${type}`), | ||
user: new RegExp(`(@[\\w-.]+)?\\/?([\\w-.]+)-${projectName}-${type}`) | ||
} | ||
@@ -33,3 +29,3 @@ }; | ||
* @param {string} [type] - Identifier type, defaults to 'plugin' | ||
* @returns {{prefixed: prefixed, postfixed: postfixed}} expand | ||
* @returns {{prefixed: prefixed}} expand | ||
* @private | ||
@@ -54,11 +50,2 @@ */ | ||
return scope ? `${scope}/${result}` : result; | ||
}, | ||
postfixed: short => { | ||
const [name, scope] = parse(short); | ||
if (scope === projectScope) { | ||
return `${projectScope}/${name}-${type}`; | ||
} | ||
const result = `${name}-${projectName}-${type}`; | ||
return scope ? `${scope}/${result}` : result; | ||
} | ||
@@ -121,3 +108,3 @@ }; | ||
* @param {object} [options] - Options | ||
* @param {boolean} [options.prefixed] - Set this to force prefixed/postfixed format for short names | ||
* @param {boolean} [options.prefixed] - Set this to force prefixed format for short names | ||
* @returns {PackageIdentifier} instance | ||
@@ -165,5 +152,4 @@ */ | ||
const reType = project && 'project' || 'user'; | ||
const fixedAs = prefixed && 'prefixed' || 'postfixed'; | ||
const expand = projectVars.expand[fixedAs]; | ||
const re = projectVars.re[fixedAs][reType]; | ||
const expand = projectVars.expand.prefixed; | ||
const re = projectVars.re.prefixed[reType]; | ||
@@ -296,6 +282,2 @@ return { format, expand, re }; | ||
get isPostfixed() { | ||
return !format.prefixed; | ||
} | ||
get hasScope() { | ||
@@ -346,6 +328,4 @@ return format.scoped; | ||
const nextOptions = {}; | ||
if (format.prefixed) { | ||
nextOptions.prefixed = false; | ||
// If we tried postfixed, and we don't have a scope, force to project scope and prefixed | ||
} else if (!format.scoped) { | ||
// If we don't have a scope, force to project scope and prefixed | ||
if (!format.scoped) { | ||
nextRawName = `${projectScope}/${nextRawName}`; | ||
@@ -352,0 +332,0 @@ nextOptions.prefixed = true; |
{ | ||
"name": "@gasket/resolve", | ||
"version": "6.0.0-canary.0", | ||
"version": "6.0.0-canary.8", | ||
"description": "Essential module resolution & configuration management for gasket plugins & presets.", | ||
@@ -55,3 +55,3 @@ "main": "lib", | ||
}, | ||
"gitHead": "62beeef23361fa8d1e3373de9fa45e2f0dc4e432" | ||
"gitHead": "250c46f89642884b8110842773798b60d7a5a87c" | ||
} |
@@ -41,25 +41,2 @@ # @gasket/resolve | ||
### Fallbacks | ||
To soften the transition of existing apps and plugins using the older postfixed | ||
format, the loader supports fallbacks for short names to postfixed format, and | ||
then to the `@gasket` scope. For example, if a short name of `example` is used, | ||
the package lookup order would be as follows: | ||
``` | ||
example --> gasket-plugin-example --> example-gasket-plugin --> gasket/plugin-example --> gasket/example-plugin | ||
``` | ||
For project and user scoped short names, the loader will fall-back to postfixed | ||
format as well. For example, if the short name `@user/example` is used: | ||
``` | ||
@user/example --> @user/plugin-example --> @user/example-plugin | ||
``` | ||
Use with caution, and don't rely on it. Consider this behavior **deprecated**, | ||
which will be removed in a future major release. Short names without the | ||
`@gasket` scope should be presumed to resolve to the `gasket-plugin-<name>` | ||
format. | ||
## Utilities | ||
@@ -66,0 +43,0 @@ |
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
47027
700
97