npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

artifactory-publisher

v1.1.4

Published

A simple tool for publishing files to Artifactory

Downloads

8,372

Readme

NPM

artifactory-publisher

A simple tool for publishing files to Artifactory

artifactory-publisher is a simple tool for publishing files to Artifactory via its REST API.

Also please check this other (more superior) tool - artifactory-client (WIP).

API

publish(filePath, artUrl, options)

Publish filePath file (artifact) to artUrl url with using options.

Returns a Q promise to be resolved when the artifact has published.

filePath

Type: String
Required: yes

A path to a file to publish (in terms of fs Node module).

artUrl

Type: String
Required: yes

Fully qualified url of artifact. For example 'http://artifacts.mydomain.com:8001/my-repo/MyProduct/1.1/Subsystem1/MyProduct.Subsystem1.1.0.0.nupkg'.
Here:

  • "http://artifacts.mydomain.com:8001/" - base Artifactory url (it usually contains /artifactory path)
  • "my-repo" - repository name
  • "MyProduct/1.1/Subsystem1/" - path in repository
  • "MyProduct.Subsystem1.1.0.0.nupkg" - file name (package)

options

Type: Object
Required: no

Options object.

options.credentials

Type: Object
Required: no

An object with fields:

  • username - Artifactory user name
  • password - Artifactory user password
options.proxy

Type: String
Required: no

A proxy url to use for sending http requests.

Examples

via Node

Here's a simple app (to run under Node) which publishes nuget packages into custom folders depending on their file names (it's hard to implement via Repository Layout in Artifactory).

var fs = require("fs");
var path = require("path");
var Q = require("Q");
var async = require("async");
var publisher = require("artifactory-publisher");

var artUrlBase = "http://artifacts.mydomain.com/my-repo/";

var options = {
	credentials: {
		username: "user1",
		password: "password2"
	}
	//proxy: "http://localhost:8888" - to debug with Fiddler
}

var args = [].splice.call(process.argv, 2);
var folderPath;
if (args.length === 0) {
	console.log("USAGE: node publish.js path/to/folder");
	return;
} else  {
	folderPath = args[0];
}

function extractProps (filePath) {
	// XFW3.Core.1.16.0.nupkg => {product: "XFW3", version: "1.16"}
	// XFW3.SmartClient.1.15.2.nupkg => {product: "XFW3.SmartClient", version: "1.15"}
	// XFW3.WebClient.0.19.0.nupkg => {product: "XFW3.WebClient", version: "0.19"}
	if (!fs.statSync(filePath).isFile()) { return; }
	var filename = path.parse(filePath).name;
	if (!filename) { return; }
	var parts = /(.*)\.([\d]+\.[\d]+)\.[\d]+.*\.nupkg/.exec(filename)
	if (!parts) { return; }

	return {
		product: parts[1],
		version: parts[2]
	};
}

fs.readdir(folderPath, function (err,files) {
	if (err != null) {
		throw err;
	}
	async.eachSeries(files, function (fileName, cb) {
		var filePath = path.resolve(folderPath + path.sep + fileName);
		var props = extractProps(filePath);
		if (!props) { 
			cb(); 
			return; 
		}
		var product = props.product.toLowerCase();
		if (product.indexOf("xfw3.webclient") === 0)  {
			product = "WebClient";
		} else if (product.indexOf("xfw3.smartclient") === 0) {
			product = "XFW3.SmartClient";
		} else if (product.indexOf("xfw3") === 0) {
			product = "XFW3";
		} else {
			cb(); 
			return;
		}
		var artUrl = artUrlBase + product + "/" + props.version + "/" + fileName;
		console.log("Publishing " + filePath + " to " + artUrl);
		
		// for test: options.dryRun = true;
		publisher.publish(filePath, artUrl, options).then(function () {
			console.log("OK");
			cb();
		});
	}, function () {
		console.log("Done!\n");
	});
});

via command line

The tool can be run via CLI as well:

artifactory-publisher -f "path/to/local/file.ext" -t http://artifacts.mydomain.com/my-repo/file.ext -u user1 -p password2

Acknowledgments

Code for CLI tool artifactory-publisher was barrowed from package artifactory-push by @beevelop.

Licence

MIT