Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-libcurl

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-libcurl - npm Package Compare versions

Comparing version 3.0.1-0 to 4.0.0

2

.eslintrc.js

@@ -5,3 +5,3 @@ const noUnusedVarsSetting = { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }

parserOptions: {
ecmaVersion: 2019,
ecmaVersion: 2020,
sourceType: 'module',

@@ -8,0 +8,0 @@ },

@@ -10,6 +10,2 @@ # Changelog

### Breaking Change
- Mininum supported Node.js version is now Node.js 16.14.
- The prebuilt binaries are only available to:
- Node.js 18, 20, and 21
- Electron 27, 27, and 28
### Fixed

@@ -20,2 +16,11 @@ ### Added

## [4.0.0]
### Breaking Change
- Mininum supported Node.js version is now Node.js 16.14.
- The prebuilt binaries are only available on:
- Node.js 18, 20, and 21
- Electron 27, 27, and 28
- NW.js binaries were removed, and may be re-introduced in the future.
## [3.0.0] - 2022-11-17

@@ -22,0 +27,0 @@

{
"name": "node-libcurl",
"version": "3.0.1-0",
"version": "4.0.0",
"description": "The fastest http(s) client (and much more) for Node.js - Node.js bindings for libcurl",

@@ -85,2 +85,3 @@ "keywords": [

"@microsoft/api-extractor": "7.38.3",
"@octokit/rest": "^20.0.2",
"@types/body-parser": "1.19.5",

@@ -113,3 +114,2 @@ "@types/cookie-parser": "1.4.6",

"nyc": "15.1.0",
"octonode": "0.10.2",
"prettier": "3.1.0",

@@ -116,0 +116,0 @@ "progress": "2.0.3",

@@ -7,7 +7,7 @@ /**

*/
const octonode = require('octonode')
const { Octokit } = require('@octokit/rest')
const log = require('npmlog')
const fs = require('fs')
const path = require('path')
const versionTag =
const tag =
process.env['NODE_LIBCURL_VERSION_TAG'] ||

@@ -35,4 +35,7 @@ 'v' + require('../package.json').version //current version of the package.

const octo = octonode.client(process.env['NODE_LIBCURL_GITHUB_TOKEN'])
const repo = octo.repo('JCMais/node-libcurl')
const octo = new Octokit({
auth: process.env['NODE_LIBCURL_GITHUB_TOKEN'],
})
const [owner, repo] = 'JCMais/node-libcurl'.split('/')
const commands = {

@@ -43,72 +46,73 @@ publish: publish,

commands[args[0].replace('--', '')](args[1])
commands[args[0].replace('--', '')](args[1]).catch((error) => {
console.error(error)
process.exit(1)
})
function publish(pathToPackage) {
getReleaseByTag(versionTag, (error, data, headers) => {
if (error) {
if (error.statusCode && error.statusCode === 404) {
createRelease(
versionTag,
attachPackageToRelease.bind(null, pathToPackage),
)
} else {
doSomethingWithError(error)
}
} else {
attachPackageToRelease(pathToPackage, null, data, headers)
}
})
/**
* @param {string} pathToPackage
*/
async function publish(pathToPackage) {
let release = await getReleaseByTag(tag)
if (release) {
log.info('', 'release for tag "%s" found: %s', tag, release.url)
} else {
log.info('', 'release "%s" not found', tag)
release = await createRelease(tag)
}
await attachPackageToRelease(pathToPackage, release)
}
function unpublish(pathToResource) {
getReleaseByTag(versionTag, (error, release /*, headers*/) => {
if (error) {
doSomethingWithError(error)
return
}
async function unpublish(pathToResource) {
const release = await getReleaseByTag(tag)
removePackageFromRelease(pathToResource, release)
})
await removePackageFromRelease(pathToResource, release)
}
function getReleaseByTag(tagName, cb) {
log.info('', 'searching for release "%s"', tagName)
async function getReleaseByTag(tag) {
log.info('', 'searching for release "%s"', tag)
repo.release('tags/' + tagName).info((error, data, headers) => {
if (error && error.statusCode && error.statusCode === 404) {
log.info('', 'release for tag "%s" not found.', tagName)
} else {
log.info('', 'release for tag "%s" found: %s', tagName, data.url)
}
const release = await octo.repos
.getReleaseByTag({
owner,
repo,
tag,
})
.catch((error) => {
if (error.status === 404) {
return null
}
throw error
})
cb(error, data, headers)
})
return release?.data
}
function createRelease(tagName, cb) {
log.info('', 'creating release for tag "%s"', tagName)
async function createRelease(tag) {
log.info('', 'creating release for tag "%s"', tag)
repo.release(
{
tag_name: tagName,
},
cb,
)
const { data } = await octo.repos.createRelease({
owner,
repo,
tag_name: tag,
})
return data
}
function attachPackageToRelease(pckg, err, release /*, headers*/) {
if (err) {
doSomethingWithError(err)
return
}
/**
*
* @param {string} pckg
* @param {Awaited<ReturnType<Octokit["repos"]["getRelease"]>>["data"]} release
* @returns
*/
async function attachPackageToRelease(pckg, release) {
const packagePath = path.resolve(pckg)
if (!fs.existsSync(packagePath)) {
log.error(
'',
'could not find the package in the specified path: "%s"',
packagePath,
throw new Error(
`Could not find the package in the specified path: "${packagePath}"`,
)
process.exit(-1)
}

@@ -130,7 +134,8 @@

'',
'package "%s" already attached to release "%s"',
'package "%s" already attached to release "%s" (%s)',
packageFileName,
release.tag_name,
release.id,
)
process.exit(0)
return
}

@@ -141,25 +146,23 @@ }

repo.release(release.id).uploadAssets(
fileContent,
{
name: packageFileName,
contentType: 'application/x-gzip',
const { data } = await octo.repos.uploadReleaseAsset({
owner,
repo,
name: packageFileName,
data: fileContent,
release_id: release.id,
headers: {
'Content-Type': 'application/x-gzip',
},
(error, data /*, headers*/) => {
if (error) {
doSomethingWithError(error)
return
}
})
log.info(
'',
'package attached with success: %s',
data.browser_download_url,
)
process.exit(0)
},
)
log.info('', 'package attached with success: %s', data.browser_download_url)
}
function removePackageFromRelease(packageToDelete, release) {
/**
*
* @param {string} pckg
* @param {Awaited<ReturnType<Octokit["repos"]["getRelease"]>>["data"]} release
* @returns
*/
async function removePackageFromRelease(packageToDelete, release) {
const packageToDeleteName = path.basename(packageToDelete)

@@ -182,21 +185,13 @@

//@FIXME using internals because there is no way to remove directly
// uri to remove assets is: repos/:owner/:repo/releases/assets/:id
repo.client.del(
'/repos/' + repo.name + '/releases/assets/' + releaseAsset.id,
null,
(error /*, data, headers*/) => {
if (error) {
doSomethingWithError(error)
return
}
await octo.repos.deleteReleaseAsset({
owner,
repo,
asset_id: releaseAsset.id,
})
log.info(
'',
'removed package "%s" from release "%s"',
packageToDelete,
release.tag_name,
)
process.exit(0)
},
log.info(
'',
'removed package "%s" from release "%s"',
packageToDelete,
release.tag_name,
)

@@ -213,9 +208,3 @@ }

)
process.exit(-1)
}
}
function doSomethingWithError(error) {
log.error('', error)
process.exit(-1)
}
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