Socket
Socket
Sign inDemoInstall

@ms-cloudpack/config

Package Overview
Dependencies
Maintainers
3
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ms-cloudpack/config - npm Package Compare versions

Comparing version 0.17.1 to 0.17.2

21

lib/compareSettings.js
export function compareSettings(a, b) {
const { name: aName = '', version: aVersion = '*' } = a.match || {};
const { name: bName = '', version: bVersion = '*' } = b.match || {};
// TypeScript's type narrowing doesn't work well with object properties,
// so we can assign them to variables to help it out.
const aMatch = a.match;
const bMatch = b.match;
// Check if the match is a string.
const isAString = typeof aMatch === 'string';
const isBString = typeof bMatch === 'string';
// Place string matches at the beginning of the list.
if (isAString && isBString) {
return aMatch.localeCompare(bMatch);
}
else if (isAString) {
return 1;
}
else if (isBString) {
return -1;
}
const { name: aName = '', version: aVersion = '*' } = aMatch || {};
const { name: bName = '', version: bVersion = '*' } = bMatch || {};
if (aName === bName) {

@@ -5,0 +22,0 @@ return aVersion.localeCompare(bVersion);

@@ -18,2 +18,16 @@ import type { PackageSettings, CloudpackConfig } from '@ms-cloudpack/config-types';

};
/**
* Checks if the package is a match for the given package settings.
* @param name The name of the package.
* @param version The version of the package.
* @param match The match to check against.
* @param firstMatch If true, only the first matching package settings will be returned, rather than the merge of all viable settings.
* @returns True if the package is a match for the given package settings.
*/
export declare function checkMatch(params: {
name: string;
version: string;
match: PackageSettings['match'];
firstMatch?: boolean;
}): boolean;
//# sourceMappingURL=getPackageSettings.d.ts.map

@@ -10,3 +10,6 @@ import { satisfies } from 'semver';

userPackageSettings: filterSettings({ ...params, packageSettings: config.packageSettings }),
generatedPackageSettings: filterSettings({ ...params, packageSettings: config.generated?.packageSettings }),
generatedPackageSettings: filterSettings({
...params,
packageSettings: config.generated?.packageSettings,
}),
};

@@ -19,9 +22,31 @@ }

const { name, version, packageSettings, firstMatch } = params;
const filteredSettings = packageSettings?.filter(({ match }) => match?.name === name && (!match.version || satisfies(version, match.version)));
return filteredSettings?.length
? firstMatch
? filteredSettings[0]
: mergePackageSettings(filteredSettings)
: undefined;
if (firstMatch) {
return packageSettings?.find(({ match }) => checkMatch({ name, version, match, firstMatch }));
}
const filteredSettings = packageSettings?.filter(({ match }) => checkMatch({ name, version, match }));
return filteredSettings?.length ? mergePackageSettings(filteredSettings) : undefined;
}
/**
* Checks if the package is a match for the given package settings.
* @param name The name of the package.
* @param version The version of the package.
* @param match The match to check against.
* @param firstMatch If true, only the first matching package settings will be returned, rather than the merge of all viable settings.
* @returns True if the package is a match for the given package settings.
*/
export function checkMatch(params) {
const { name, version, match, firstMatch } = params;
let matchName, matchVersion;
if (typeof match === 'string') {
matchName = match;
}
else {
matchName = match?.name;
matchVersion = match?.version;
}
if (firstMatch || !matchName.endsWith('*')) {
return matchName === name && (!matchVersion || satisfies(version, matchVersion));
}
return name.startsWith(matchName.slice(0, -1)) && (!matchVersion || satisfies(version, matchVersion));
}
//# sourceMappingURL=getPackageSettings.js.map

2

lib/index.d.ts

@@ -5,3 +5,3 @@ export { configTemplate } from './configTemplate.js';

export { getConfigPath } from './getConfigPath.js';
export { getPackageSettings } from './getPackageSettings.js';
export { getPackageSettings, checkMatch } from './getPackageSettings.js';
export { readConfig } from './readConfig.js';

@@ -8,0 +8,0 @@ export { readGeneratedConfig } from './readGeneratedConfig.js';

@@ -5,3 +5,3 @@ export { configTemplate } from './configTemplate.js';

export { getConfigPath } from './getConfigPath.js';
export { getPackageSettings } from './getPackageSettings.js';
export { getPackageSettings, checkMatch } from './getPackageSettings.js';
export { readConfig } from './readConfig.js';

@@ -8,0 +8,0 @@ export { readGeneratedConfig } from './readGeneratedConfig.js';

@@ -0,1 +1,2 @@

const defaultInputPaths = ['src/**', '*.json', '!**/node_modules/**'];
/**

@@ -41,2 +42,9 @@ * Merges package settings together. Takes care to merge exports maps correctly.

}
if (setting.inputPaths) {
const defaultInputPathsIndex = setting.inputPaths.indexOf('...');
if (defaultInputPathsIndex > -1) {
setting.inputPaths.splice(defaultInputPathsIndex, 1, ...defaultInputPaths);
}
acc.inputPaths = [...(acc.inputPaths || []), ...setting.inputPaths];
}
return acc;

@@ -43,0 +51,0 @@ }, {});

{
"name": "@ms-cloudpack/config",
"version": "0.17.1",
"version": "0.17.2",
"description": "Configuration handling for cloudpack.",

@@ -17,6 +17,6 @@ "license": "MIT",

"dependencies": {
"@ms-cloudpack/bundler-types": "^0.22.0",
"@ms-cloudpack/config-types": "^0.1.0",
"@ms-cloudpack/bundler-types": "^0.23.0",
"@ms-cloudpack/config-types": "^0.1.1",
"@ms-cloudpack/json-utilities": "^0.1.2",
"@ms-cloudpack/package-utilities": "^5.5.2",
"@ms-cloudpack/package-utilities": "^5.6.0",
"semver": "^7.3.7"

@@ -23,0 +23,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc