New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@app-config/git

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@app-config/git - npm Package Compare versions

Comparing version 2.1.5 to 2.1.6

51

dist/es/index.js
import simpleGit from 'simple-git';
import { AppConfigError } from '@app-config/core';
import { forKey, validateOptions } from '@app-config/extension-utils';
/** Access to the git branch and commit ref */
export default function gitRefDirectives(getStatus = gitStatus) {
return (value, [_, key]) => {
if (key === '$git') {
return async (parse) => {
if (typeof value !== 'string') {
throw new AppConfigError('$git directive should be passed a string');
}
switch (value) {
case 'commit':
return getStatus().then(({ commitRef }) => parse(commitRef, { shouldFlatten: true }));
case 'commitShort':
return getStatus().then(({ commitRef }) => parse(commitRef.slice(0, 7), { shouldFlatten: true }));
case 'branch':
case 'branchName':
return getStatus().then(({ branchName }) => {
if (!branchName) {
throw new AppConfigError('The $git directive tried to retrieve branchname, but it appears no branch is checked out');
}
return parse(branchName, { shouldFlatten: true });
});
case 'tag':
return getStatus().then(({ tag }) => {
return parse(tag ?? null, { shouldFlatten: true });
});
default:
throw new AppConfigError('$git directive was not passed a valid option');
}
};
return forKey('$git', validateOptions((SchemaBuilder) => SchemaBuilder.stringSchema(), (value) => async (parse) => {
switch (value) {
case 'commit':
return getStatus().then(({ commitRef }) => parse(commitRef, { shouldFlatten: true }));
case 'commitShort':
return getStatus().then(({ commitRef }) => parse(commitRef.slice(0, 7), { shouldFlatten: true }));
case 'branch':
case 'branchName':
return getStatus().then(({ branchName }) => {
if (!branchName) {
throw new AppConfigError('The $git directive tried to retrieve branchname, but it appears no branch is checked out');
}
return parse(branchName, { shouldFlatten: true });
});
case 'tag':
return getStatus().then(({ tag }) => {
return parse(tag ?? null, { shouldFlatten: true });
});
default:
throw new AppConfigError('$git directive was not passed a valid option');
}
return false;
};
}));
}

@@ -36,0 +29,0 @@ async function gitStatus() {

@@ -8,34 +8,27 @@ "use strict";

const core_1 = require("@app-config/core");
const extension_utils_1 = require("@app-config/extension-utils");
/** Access to the git branch and commit ref */
function gitRefDirectives(getStatus = gitStatus) {
return (value, [_, key]) => {
if (key === '$git') {
return async (parse) => {
if (typeof value !== 'string') {
throw new core_1.AppConfigError('$git directive should be passed a string');
}
switch (value) {
case 'commit':
return getStatus().then(({ commitRef }) => parse(commitRef, { shouldFlatten: true }));
case 'commitShort':
return getStatus().then(({ commitRef }) => parse(commitRef.slice(0, 7), { shouldFlatten: true }));
case 'branch':
case 'branchName':
return getStatus().then(({ branchName }) => {
if (!branchName) {
throw new core_1.AppConfigError('The $git directive tried to retrieve branchname, but it appears no branch is checked out');
}
return parse(branchName, { shouldFlatten: true });
});
case 'tag':
return getStatus().then(({ tag }) => {
return parse(tag !== null && tag !== void 0 ? tag : null, { shouldFlatten: true });
});
default:
throw new core_1.AppConfigError('$git directive was not passed a valid option');
}
};
return extension_utils_1.forKey('$git', extension_utils_1.validateOptions((SchemaBuilder) => SchemaBuilder.stringSchema(), (value) => async (parse) => {
switch (value) {
case 'commit':
return getStatus().then(({ commitRef }) => parse(commitRef, { shouldFlatten: true }));
case 'commitShort':
return getStatus().then(({ commitRef }) => parse(commitRef.slice(0, 7), { shouldFlatten: true }));
case 'branch':
case 'branchName':
return getStatus().then(({ branchName }) => {
if (!branchName) {
throw new core_1.AppConfigError('The $git directive tried to retrieve branchname, but it appears no branch is checked out');
}
return parse(branchName, { shouldFlatten: true });
});
case 'tag':
return getStatus().then(({ tag }) => {
return parse(tag !== null && tag !== void 0 ? tag : null, { shouldFlatten: true });
});
default:
throw new core_1.AppConfigError('$git directive was not passed a valid option');
}
return false;
};
}));
}

@@ -42,0 +35,0 @@ exports.default = gitRefDirectives;

{
"name": "@app-config/git",
"description": "$git directive parsing extension for @app-config",
"version": "2.1.5",
"version": "2.1.6",
"license": "MPL-2.0",

@@ -33,7 +33,8 @@ "author": {

"dependencies": {
"@app-config/core": "^2.1.5",
"@app-config/core": "^2.1.6",
"@app-config/extension-utils": "^2.1.6",
"simple-git": "2"
},
"devDependencies": {
"@app-config/test-utils": "^2.1.5"
"@app-config/test-utils": "^2.1.6"
},

@@ -40,0 +41,0 @@ "prettier": "@lcdev/prettier",

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