Socket
Socket
Sign inDemoInstall

@dotcms/dotcli

Package Overview
Dependencies
Maintainers
1
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotcms/dotcli - npm Package Compare versions

Comparing version 24.2.26-rc1 to 24.2.26-rc2

2

package.json
{
"name": "@dotcms/dotcli",
"version": "24.02.26-rc1",
"version": "24.02.26-rc2",
"scripts": {

@@ -5,0 +5,0 @@ "postinstall": "node src/postinstall.js install",

# dotCMS CLI
The dotCMS CLI is a command-line tool that you can use to populate and modify your dotCMS instances from a command shell.
The **dotCMS CLI**, sometimes shortened to **dotCLI**, is a standalone tool for interacting with a dotCMS instance through a command shell, allowing a wide array of automated operations and behaviors.
## Quick start
## Getting Started
### Installation
### NPM
The simplest and most recommended way to get the dotCMS CLI is from its npm package:
```shell script
npm install -g @dotcms/cli
```
### Manual JAR Download
1. Download the CLI: The dotCMS CLI is delivered as an uber jar that can be downloaded from [here](https://repo.dotcms.com/artifactory/libs-snapshot-local/com/dotcms/dotcms-cli/).

@@ -6,0 +18,0 @@ Once downloaded, you just need to run it with:

"use strict";
// Dependencies
const path = require('path');

@@ -7,2 +8,3 @@ const fs = require('fs').promises;

// Architecture and platform mappings
const ARCHITECTURE_MAPPING = {

@@ -18,2 +20,8 @@ "x64": "x86_64",

const EXTENSION_MAP = {
"win32": ".exe",
"default": ""
};
// Utility functions
function getGlobalBinPath() {

@@ -25,2 +33,3 @@ const npmGlobalPrefix = process.env.PREFIX || process.env.npm_config_prefix || process.env.HOME;

function validatePackageConfig(packageJson) {
// Validation of package.json configuration
if (!packageJson.version || !packageJson.packageName || !packageJson.alias || !packageJson.binaries || typeof packageJson.binaries !== "object") {

@@ -31,5 +40,6 @@ throw new Error("Invalid package.json. 'version', 'packageName', 'alias' and 'binaries' must be specified.");

// Read and parse package.json
async function parsePackageJson() {
console.log("Installing CLI");
console.log("Installing CLI");
const platform = os.platform();

@@ -41,2 +51,3 @@ const architecture = os.arch();

// Check installation support for platform and architecture
if (!(os.arch() in ARCHITECTURE_MAPPING) || !(os.platform() in PLATFORM_MAPPING)) {

@@ -56,3 +67,3 @@ throw new Error(`Installation is not supported for this ${platform}/${architecture} combination.`);

const binaries = packageJson.binaries;
const extension = platform === "win32" ? ".exe" : "";
const extension = EXTENSION_MAP[platform] || EXTENSION_MAP.default;
const binaryKey = `${packageName}-${platform}-${architecture}`;

@@ -78,25 +89,16 @@ const binaryPath = binaries[binaryKey];

// Create symlink for the binary
async function createSymlink(globalBinPath, config) {
try {
console.info(`Creating symlink for the relevant binary for your platform ${os.platform()}-${os.arch()}`);
async function createSymlink(binarySource, binaryDestination) {
const globalBinPath = getGlobalBinPath();
const symlinkPath = path.join(globalBinPath, binaryDestination);
const currentDir = __dirname;
const targetDir = path.join(currentDir, '..');
const binarySource = path.join(targetDir, config.binaryPath);
const binaryDestination = config.alias;
const fullSymlinkPath = path.join(globalBinPath, binaryDestination);
try {
try {
await fs.access(symlinkPath, fs.constants.F_OK);
// If the symlink exists, remove it.
await fs.unlink(symlinkPath);
console.log(`Existing symlink ${symlinkPath} found and removed.`);
} catch (error) {
// The symlink does not exist, continue.
}
await fs.symlink(binarySource, fullSymlinkPath);
if (os.platform() === "win32") {
// Create a junction for the binary for Windows.
// await fs.symlink(binarySource, symlinkPath, "junction");
} else {
// Create a symlink for the binary for macOS and Linux.
await fs.symlink(binarySource, symlinkPath);
}
console.info(`Created symlink ${symlinkPath} pointing to ${binarySource}`);
console.info(`Created symlink ${fullSymlinkPath} pointing to ${binarySource}`);
} catch (error) {

@@ -108,38 +110,56 @@ console.error("Error while creating symlink:", error);

async function installCli() {
const config = await parsePackageJson();
// Remove symlink if exists
async function removeSymlinkIfExists(globalBinPath, config) {
try {
console.info("Global bin path location:", globalBinPath);
console.log({
config
});
const files = await fs.readdir(globalBinPath);
const symlinkFileName = config.alias + config.extension;
const symlinkPath = files.find(file => file === symlinkFileName);
console.info(`Creating symlink for the relevant binary for your platform ${os.platform()}-${os.arch()}`);
if (!symlinkPath) {
console.warn(`Symlink '${symlinkFileName}' not found in the global bin directory.`);
return;
}
const currentDir = __dirname;
const targetDir = path.join(currentDir, '..');
const binarySource = path.join(targetDir, config.binaryPath);
const binaryDestination = config.alias;
const fullSymlinkPath = path.join(globalBinPath, symlinkPath);
await fs.unlink(fullSymlinkPath);
console.info(`Removed symlink: ${fullSymlinkPath}`);
} catch (error) {
console.warn("Error while removing symlink:", error);
}
}
console.info("Installing cli:", binarySource, binaryDestination);
// Install CLI
async function installCli() {
const config = await parsePackageJson();
const globalBinPath = getGlobalBinPath();
await createSymlink(binarySource, binaryDestination + config.extension);
try{
await removeSymlinkIfExists(globalBinPath, config);
await createSymlink(globalBinPath, config);
} catch (ex) {
console.error("Error while installing:", ex);
throw new Error(`Failed to install ${config.alias}.`);
}
console.info(`${config.alias} installed successfully.`);
}
// Uninstall CLI
async function uninstallCli() {
const config = await parsePackageJson();
const globalBinPath = getGlobalBinPath();
try {
const globalBinPath = getGlobalBinPath();
const symlinkPath = path.join(globalBinPath, config.alias + config.extension);
console.info("Removing symlink:", symlinkPath);
await fs.unlink(symlinkPath);
await removeSymlinkIfExists(globalBinPath, config);
} catch (ex) {
console.error("Error while uninstalling:", ex);
throw new Error(`Failed to uninstall ${config.alias}.`);
}
console.info("Uninstalled cli successfully");
console.info(`${config.alias} uninstalled successfully.`);
}
// Available actions
const actions = {

@@ -150,2 +170,3 @@ "install": installCli,

// Execute action based on provided command
const [cmd] = process.argv.slice(2);

@@ -163,2 +184,2 @@ if (cmd && actions[cmd]) {

process.exit(1);
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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