Socket
Socket
Sign inDemoInstall

version-for-publishing

Package Overview
Dependencies
6
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.5 to 0.1.6

.vscode/tasks.json

3

.vscode/launch.json

@@ -17,5 +17,6 @@ {

"GITHUB_WORKSPACE": "${workspaceFolder}\\"
}
},
"preLaunchTask": "build"
}
]
}

@@ -22,3 +22,9 @@ module.exports =

/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/

@@ -62,3 +68,3 @@ /******/ // Flag the module as loaded

try {
const filePath = core.getInput('filePath')
const filePath = core.getInput('filePath') != '' ? core.getInput('filePath') : 'package.json'
const jsonFile = JSON.parse(fs.readFileSync(path.resolve(process.env.GITHUB_WORKSPACE, filePath)))

@@ -71,4 +77,2 @@

fs.writeFileSync(path.resolve(process.env.GITHUB_WORKSPACE, filePath), `${JSON.stringify(jsonFile, null, 2)}\n`)
core.setOutput('version', jsonFile.version);

@@ -81,17 +85,15 @@

function getVersion(branch, packageVersion) {
const separatorIndex = packageVersion.indexOf('-')
if (separatorIndex > -1 ) {
const devVersion = packageVersion.substring(separatorIndex + 1, packageVersion.length)
const baseVersion = packageVersion.substring(0, separatorIndex)
const isCurrentBranch = branch === devVersion.split('.')[0]
const currentVersionNumber = parseInt(devVersion.split('.')[1], 10)
const separatorIndex = packageVersion.indexOf('-');
if (separatorIndex > -1) {
const baseVersion = packageVersion.substring(0, separatorIndex).replace(/\./g, "-");
const isMasterBranch = (branch === 'master' || branch === '');
if (isCurrentBranch) {
return `${baseVersion}-${branch}.${currentVersionNumber + 1}`
if (isMasterBranch) {
return `${baseVersion}`;
}
return `${baseVersion}-${branch}.1`
return `${baseVersion}-${branch}`;
}
return `${packageVersion}-${branch}.1`
const stringVersion = packageVersion.replace(/\./g, "-");
return `${stringVersion}`;
}

@@ -169,4 +171,18 @@

}
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
function escapeData(s) {
return (s || '')
return toCommandValue(s)
.replace(/%/g, '%25')

@@ -177,3 +193,3 @@ .replace(/\r/g, '%0D')

function escapeProperty(s) {
return (s || '')
return toCommandValue(s)
.replace(/%/g, '%25')

@@ -234,7 +250,9 @@ .replace(/\r/g, '%0D')

* @param name the name of the variable to set
* @param val the value of the variable
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) {
process.env[name] = val;
command_1.issueCommand('set-env', { name }, val);
const convertedVal = command_1.toCommandValue(val);
process.env[name] = convertedVal;
command_1.issueCommand('set-env', { name }, convertedVal);
}

@@ -278,4 +296,5 @@ exports.exportVariable = exportVariable;

* @param name name of the output to set
* @param value value to store
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setOutput(name, value) {

@@ -285,2 +304,11 @@ command_1.issueCommand('set-output', { name }, value);

exports.setOutput = setOutput;
/**
* Enables or disables the echoing of commands into stdout for the rest of the step.
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
*
*/
function setCommandEcho(enabled) {
command_1.issue('echo', enabled ? 'on' : 'off');
}
exports.setCommandEcho = setCommandEcho;
//-----------------------------------------------------------------------

@@ -303,2 +331,9 @@ // Results

/**
* Gets whether Actions Step Debug is on or not
*/
function isDebug() {
return process.env['RUNNER_DEBUG'] === '1';
}
exports.isDebug = isDebug;
/**
* Writes debug message to user log

@@ -313,6 +348,6 @@ * @param message debug message

* Adds an error issue
* @param message error issue message
* @param message error issue message. Errors will be converted to string via toString()
*/
function error(message) {
command_1.issue('error', message);
command_1.issue('error', message instanceof Error ? message.toString() : message);
}

@@ -322,6 +357,6 @@ exports.error = error;

* Adds an warning issue
* @param message warning issue message
* @param message warning issue message. Errors will be converted to string via toString()
*/
function warning(message) {
command_1.issue('warning', message);
command_1.issue('warning', message instanceof Error ? message.toString() : message);
}

@@ -384,4 +419,5 @@ exports.warning = warning;

* @param name name of the state to store
* @param value value to store
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function saveState(name, value) {

@@ -388,0 +424,0 @@ command_1.issueCommand('save-state', { name }, value);

@@ -22,3 +22,3 @@ const core = require('@actions/core')

const separatorIndex = packageVersion.indexOf('-');
if (separatorIndex > -1 ) {
if (separatorIndex > -1) {
const baseVersion = packageVersion.substring(0, separatorIndex).replace(/\./g, "-");

@@ -34,3 +34,3 @@ const isMasterBranch = (branch === 'master' || branch === '');

const stringVersion = packageVersion.replace(/\./g, "-");
return `${stringVersion}-${branch}`;
return `${stringVersion}`;
}
{
"name": "version-for-publishing",
"version": "0.1.5",
"version": "0.1.6",
"main": "index.js",

@@ -30,3 +30,3 @@ "repository": {

"scripts": {
"package": "ncc build index.js -o dist",
"build": "ncc build index.js -o dist",
"lint": "eslint *.js"

@@ -33,0 +33,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc