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

hubspot-cos-uploader

v2.0.2

Published

Synchronize a local foldler of templates & assets with Hubspot's design manager

Downloads

16

Readme

Hubspot COS Uploader for NodeJS

Important Notes for V2

Hubspot's ~~COS~~ CMS has changed a lot...it is no longer ideal to serve css & js from the "design manager" (the hubl function get_public_template_url('path/to/asset') is being deprecated, or at least they warn against using it).

So, v2 of this tool has been adapted to place css/js files in the "file manager", and print the cdn url in the console.


Project Info

This project was inspired by Hubspot's original COS Uploader Python tool. It contains a few improvements, including the ability to synchronize with remote templates and more closely ensure that newer work doesn't get overwritten. However, it does currently require you to genrate a "hapikey" rather than putting you throught the OAuth2 flow.

Just like Hubspot's original cos uploader, each template or asset file needs metadata inside a comment:

<!-- [hubspot-metadata] {"type":"page","path":"design/manager/file/path/filename.html"} [end-hubspot-metadata] -->

The type property of the hubspot metadata object can be "asset", "page", "email", "blog", "404", or "partial". Path is the destination location and filename in the design manager. ID will be written back to the file once it is created in Hubspot.

  • Page - a landing or website page
  • Email - an email template
  • Blog - a blog listing or single template
  • Partial - a template that is not "available for new content"...usually for includes
  • 404 - a "system template" for 404 error pages

Usage

The only required option is hapikey, which is a hubspot api key. The root option is the path(s) to watch for file changes.It can be a string or array (path or array of paths), defaults to the current working directory.

//require it
var HubspotUploader = require('hubspot-cos-uploader');

//create an uploader instance
var Uploader = new HubspotUploader({
	
  //required 
  hapikey: 'XXXXXXXXXXX',
  
  // defaults to "hubspot-files"
  files: 'hubspot-files', 

  // defaults to "hubspot-templates"
  templates: 'hubspot-templates',
});

//pull a remote template (currently remote template must have metadata)
//localpath is optional & will default to first directory from "root" option
Uploader.pull(fileId, localpath);

//start watchers
Uploader.start();

//sync with remote, returns a promise...
var sync = Uploader.sync();

//so you can use it as a way to pull updated templates
sync.then(() => Uploader.start());

Use With Build Tools

A common way to use it in a gulp build is to run the start method once (after the sync method finishes) as part of your default gulp task. There is a gulpfile in this package's root that shows a more thorough example of a Gulp integration.

var uploader = require('hubspot-cos-uploader')({
	hapikey: 'XXXXXXXXXX'
});

gulp.task('default', function() {
	uploader.sync().then(uploader.start);
});