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

@hubspot/cms-cli

Package Overview
Dependencies
Maintainers
10
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hubspot/cms-cli - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

.DS_Store

17

bin/hscms-auth.js
#!/usr/bin/env node
const program = require('commander');
const { Command } = require('commander');
const { version } = require('../package.json');
const inquirer = require('inquirer');

@@ -17,2 +18,3 @@ const OAuth2Manager = require('@hubspot/api-auth-lib/OAuth2Manager');

} = require('../lib/commonOpts');
const { logDebugInfo } = require('../lib/debugInfo');

@@ -24,3 +26,3 @@ const getAuthContext = async () => {

name: 'portalId',
message: 'Enter your portal ID:',
message: 'Enter the HubSpot CMS portal ID:',
type: 'number',

@@ -30,7 +32,7 @@ },

name: 'clientId',
message: 'Enter your client ID:',
message: 'Enter your OAuth2 client ID:',
},
{
name: 'clientSecret',
message: 'Enter your client secret:',
message: 'Enter your OAuth2 client secret:',
},

@@ -40,6 +42,11 @@ ]);

const program = new Command('hscms auth');
program
.command('auth', 'configure authentication with HubSpot')
.version(version)
.description('Configure authentication for a HubSpot account')
.arguments('<type>')
.action(async (type, options) => {
setLogLevel(options);
logDebugInfo(options);
const { config: configPath } = options;

@@ -46,0 +53,0 @@ loadConfig(configPath);

@@ -5,15 +5,53 @@ #!/usr/bin/env node

const fs = require('fs-extra');
const program = require('commander');
const { Command } = require('commander');
const { version } = require('../package.json');
const { logger, setLogLevel, LOG_LEVEL } = require('@hubspot/cms-lib/logger');
const { logger } = require('@hubspot/cms-lib/logger');
const { getCwd } = require('@hubspot/cms-lib/path');
const { addLoggerOptions, setLogLevel } = require('../lib/commonOpts');
const { logDebugInfo } = require('../lib/debugInfo');
const ASSET_PATHS = {
module: path.resolve(__dirname, '../defaults/Sample.module'),
template: path.resolve(__dirname, '../defaults/template.html'),
};
setLogLevel(LOG_LEVEL.LOG);
const createModule = (name, dest) => {
const assetPath = ASSET_PATHS.module;
const folderName = name.endsWith('.module') ? name : `${name}.module`;
const destPath = path.join(dest, folderName);
if (fs.existsSync(destPath)) {
logger.error(`The ${destPath} path already exists`);
return;
}
logger.log(`Making ${destPath} if needed`);
fs.mkdirp(destPath);
logger.log(`Copying sample module to ${destPath}`);
fs.copySync(assetPath, destPath);
};
const createTemplate = (name, dest) => {
const assetPath = ASSET_PATHS.template;
const filename = name.endsWith('.html') ? name : `${name}.html`;
const filePath = path.join(dest, filename);
if (fs.existsSync(filePath)) {
logger.error(`The ${filePath} path already exists`);
return;
}
logger.log(`Making ${dest} if needed`);
fs.mkdirp(dest);
logger.log(`Copying boilerplate template to ${filePath}`);
fs.copySync(assetPath, filePath);
};
const program = new Command('hscms create');
program
.command('create [type] [dest]', 'create an asset')
.action((type, dest) => {
.version(version)
.description('Create assets from boilerplate.')
.arguments('<type> <name> [dest]')
.action((type, name, dest, options = {}) => {
setLogLevel(options);
logDebugInfo(options);
const assetPath = ASSET_PATHS[type];

@@ -25,4 +63,10 @@ if (!assetPath) {

// For some reason, when `dest` is not passed from the CLI, commander passes `program`
const destPath =
!dest || typeof dest === 'object'
? getCwd()
: path.resolve(getCwd(), dest);
try {
const stats = fs.statSync(dest);
const stats = fs.statSync(destPath);
if (!stats.isDirectory()) {

@@ -36,12 +80,9 @@ logger.error(`The "${dest}" is not a path to a directory`);

}
const destPath = path.join(dest, path.basename(assetPath));
if (fs.existsSync(destPath)) {
logger.error(`The ${destPath} path already exists`);
return;
}
switch (type) {
case 'module':
fs.mkdirp(destPath);
fs.copySync(assetPath, destPath);
createModule(name, destPath);
break;
case 'template':
createTemplate(name, destPath);
break;
default:

@@ -51,2 +92,4 @@ }

addLoggerOptions(program);
program.parse(process.argv);

@@ -18,2 +18,3 @@ #!/usr/bin/env node

program
.version(require('../package.json').version)
.command(

@@ -20,0 +21,0 @@ 'download-builtin-modules [dest]',

@@ -18,2 +18,3 @@ #!/usr/bin/env node

program
.version(require('../package.json').version)
.command(

@@ -20,0 +21,0 @@ 'download-module moduleId [dest]',

#!/usr/bin/env node
const _path = require('path');
const program = require('commander');
const { Command } = require('commander');
const { version } = require('../package.json');
const {
downloadFile,
downloadFolder,
writeFileMapping,
} = require('@hubspot/cms-lib/fileMapper');
const { downloadFileOrFolder } = require('@hubspot/cms-lib/fileMapper');
const { loadConfig } = require('@hubspot/cms-lib');

@@ -22,8 +18,16 @@ const { logger } = require('@hubspot/cms-lib/logger');

} = require('../lib/commonOpts');
const { logDebugInfo } = require('../lib/debugInfo');
const { validateLocalDestinationDirectory } = require('../lib/validation');
const program = new Command('hscms fetch');
program
.command('fetch [path] [dest]', 'fetch a file or directory by path')
.action(async (path, dest, options) => {
.version(version)
.description(
'Fetch a file or directory from HubSpot and write to a path on your computer'
)
.action((path, dest, options) => {
setLogLevel(options);
logDebugInfo(options);
const { config: configPath } = options;

@@ -42,16 +46,4 @@ loadConfig(configPath);

const download = _path.extname(path) ? downloadFile : downloadFolder;
try {
const node = await download(portalId, path);
logger.log(
'Fetch "%s" from portal %d completed successfully',
path,
portalId
);
const { overwrite } = options;
await writeFileMapping(node, dest, { overwrite });
} catch (err) {
logger.error(JSON.stringify(err, null, 2));
}
// Fetch and write file/folder.
downloadFileOrFolder({ portalId, path, dest, options });
});

@@ -58,0 +50,0 @@

#!/usr/bin/env node
const fs = require('fs');
const program = require('commander');
const path = require('path');
const { Command } = require('commander');
const { version } = require('../package.json');
const { loadConfig, sync } = require('@hubspot/cms-lib');
const { getCwd } = require('@hubspot/cms-lib/path');
const { logger } = require('@hubspot/cms-lib/logger');

@@ -16,7 +19,15 @@

} = require('../lib/commonOpts');
const { logDebugInfo } = require('../lib/debugInfo');
const program = new Command('hscms sync');
program
.command('sync [src] [dest]', 'upload a directory of assets')
.version(version)
.description(
'Upload a directory of HubSpot CMS assets from your computer to a HubSpot account'
)
.arguments('<src> <dest>')
.action((src, dest, options = {}) => {
setLogLevel(options);
logDebugInfo(options);
const { config: configPath } = options;

@@ -32,4 +43,5 @@ loadConfig(configPath);

const absoluteSrcPath = path.resolve(getCwd(), src);
try {
const stats = fs.statSync(src);
const stats = fs.statSync(absoluteSrcPath);
if (!stats.isDirectory()) {

@@ -49,3 +61,3 @@ logger.log(`The "${src}" is not a path to a directory`);

sync(portalId, src, dest)
sync(portalId, absoluteSrcPath, dest)
.then(() => {

@@ -52,0 +64,0 @@ logger.log('Sync complete');

@@ -5,6 +5,8 @@ #!/usr/bin/env node

const path = require('path');
const program = require('commander');
const { Command } = require('commander');
const { version } = require('../package.json');
const { upload } = require('@hubspot/cms-lib/fileMapper');
const { upload } = require('@hubspot/cms-lib/api/fileMapper');
const { ALLOWED_EXTENSIONS, loadConfig } = require('@hubspot/cms-lib');
const { getCwd, convertToUnixPath } = require('@hubspot/cms-lib/path');
const { logger } = require('@hubspot/cms-lib/logger');

@@ -19,8 +21,12 @@

} = require('../lib/commonOpts');
const { convertToUnixPath } = require('@hubspot/cms-lib/path');
const { logDebugInfo } = require('../lib/debugInfo');
const program = new Command('hscms upload');
program
.command('upload [src] [dest]', 'upload a single asset')
.action((src, dest, options) => {
.version(version)
.description('Upload a file from your computer to the HubSpot CMS')
.arguments('<src> <dest>')
.action((src, dest, options = {}) => {
setLogLevel(options);
logDebugInfo(options);
const { config: configPath } = options;

@@ -35,3 +41,3 @@ loadConfig(configPath);

const absoluteSrcPath = path.resolve(process.env.INIT_CWD, src);
const absoluteSrcPath = path.resolve(getCwd(), src);
try {

@@ -38,0 +44,0 @@ const stats = fs.statSync(absoluteSrcPath);

#!/usr/bin/env node
const fs = require('fs');
const program = require('commander');
const path = require('path');
const { Command } = require('commander');
const { version } = require('../package.json');
const { watch, loadConfig } = require('@hubspot/cms-lib');
const { getCwd } = require('@hubspot/cms-lib/path');
const { logger } = require('@hubspot/cms-lib/logger');

@@ -16,7 +19,14 @@

} = require('../lib/commonOpts');
const { logDebugInfo } = require('../lib/debugInfo');
const program = new Command('hscms watch');
program
.command('watch [src] [dest]', 'watch a directory of assets and upload files')
.version(version)
.description(
'Watch a directory on your computer for changes and upload the changed files to the HubSpot CMS'
)
.arguments('<src> <dest>')
.action((src, dest, options = {}) => {
setLogLevel(options);
logDebugInfo(options);
const { config: configPath } = options;

@@ -31,4 +41,5 @@ loadConfig(configPath);

const absoluteSrcPath = path.resolve(getCwd(), src);
try {
const stats = fs.statSync(src);
const stats = fs.statSync(absoluteSrcPath);
if (!stats.isDirectory()) {

@@ -48,3 +59,3 @@ logger.log(`The "${src}" is not a path to a directory`);

watch(portalId, src, dest);
watch(portalId, absoluteSrcPath, dest);
});

@@ -51,0 +62,0 @@

#!/usr/bin/env node
const program = require('commander');
const { Command } = require('commander');
const { version } = require('../package.json');
const program = new Command();
program
.version(version)
.description('Tools for working with the HubSpot CMS')
.command('auth [type]', 'configure authentication with HubSpot')
.command('upload [src] [dest]', 'upload a single asset')
.command('upload <src> <dest>', 'upload a single asset')
.command('fetch [path] [dest]', 'fetch a file or directory by path')
.command('sync [src] [dest]', 'upload a directory of assets')
.command('watch [src] [dest]', 'watch a directory of assets and upload files')
.command('create [type] [dest]', 'create an asset')
.command('sync <src> <dest>', 'upload a directory of assets')
.command('watch <src> <dest>', 'watch a directory of assets and upload files')
.command('create <type> <name> [dest]', 'create an asset')
.command(
'download-module [moduleId] [dest]',
'download a module to a directory'
'download a module to a directory',
{ noHelp: true }
)
.command(
'download-builtin-modules [dest]',
'download builtin modules to a directory'
'download builtin modules to a directory',
{ noHelp: true }
)
.parse(process.argv);
[
{
"default": null,
"hierarchical": false,
"default": "<h1>Hello, world!</h1>",
"label": "Rich text field",
"locked": false,
"max_depth": 0,
"name": "text",

@@ -9,0 +7,0 @@ "required": false,

{
"content_tags": [ ],
"css_assets": [ ],

@@ -9,3 +8,2 @@ "external_js": [ ],

"js_assets": [ ],
"label" : null,
"other_assets": [ ],

@@ -12,0 +10,0 @@ "smart_type": "NOT_SMART",

{
"name": "@hubspot/cms-cli",
"version": "0.0.13",
"version": "0.0.14",
"description": "CLI for interacting with the HubSpot CMS",
"license": "Apache-2.0",
"dependencies": {
"@hubspot/api-auth-lib": "^0.0.13",
"@hubspot/cms-lib": "^0.0.13",
"@hubspot/api-auth-lib": "^0.0.14",
"@hubspot/cms-lib": "^0.0.14",
"commander": "^2.16.0",

@@ -21,3 +21,3 @@ "inquirer": "^6.3.1"

},
"gitHead": "6efa49006ea4ac81e854cfc02de2577d653ac1e8"
"gitHead": "7f6633b4ef5f1ff56cf6b45edc26828e569b8fb2"
}
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