New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cloudcms-util

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudcms-util - npm Package Compare versions

Comparing version 2.0.4 to 2.1.0

56

.vscode/launch.json

@@ -10,2 +10,15 @@ {

"request": "launch",
"name": "export n:node instances by query",
"program": "${workspaceFolder}/bin/cloudcms-util.js",
"cwd": "${workspaceFolder}",
"args": [
"export",
"-g", "./gitana/gitana-harry.json",
"-y", "./data-queries/node-test.json",
"-v"
]
},
{
"type": "node",
"request": "launch",
"name": "npx cloudcms-util init",

@@ -173,4 +186,47 @@ "program": "${workspaceFolder}/bin/cloudcms-util.js",

]
},
{
"type": "node",
"request": "launch",
"name": "import cna to local docker",
"program": "${workspaceFolder}/cloudcms-import.js",
"cwd": "${workspaceFolder}",
"args": [
"-g", "./gitana/gitana-local.json",
"-f", "/Users/harry/Documents/Projects/customers/cna/data",
"-q", "cna:showcase","cna:news","cna:alert",
"-i",
"-r",
"-v"
]
},
{
"type": "node",
"request": "launch",
"name": "import csv users to local docker",
"program": "${workspaceFolder}/cloudcms-user-import.js",
"cwd": "${workspaceFolder}",
"args": [
"-g", "./gitana/gitana-local.json",
"--csv-source", "./data/users-test1.csv",
"--project-id", "5751b6235492fef8614d",
"--team-key", "project-managers-team",
"--username", "admin",
"--password", "admin",
"-v"
]
},
{
"type": "node",
"request": "launch",
"name": "list types on unknown project",
"program": "${workspaceFolder}/cloudcms-export.js",
"cwd": "${workspaceFolder}",
"args": [
"-g", "./gitana/gitana-who-knows.json",
"-l",
"-v"
]
}
]
}

5

bin/cloudcms-util.js

@@ -28,2 +28,5 @@ #!/usr/bin/env node

return;
} else if (script === "import-users") {
require('../cloudcms-user-import');
return;
} else if (script === "init") {

@@ -54,3 +57,3 @@ init(handleOptions(script));

function printHelp() {
console.log(chalk.blue("Supported commands are: ") + chalk.green("\n\tinit\n\timport\n\texport\n\texport-users\n\tcreate-definition\n\tcreate-form-fields\n\tcreate-node\n\tcreate-instance-node"));
console.log(chalk.blue("Supported commands are: ") + chalk.green("\n\tinit\n\timport\n\texport\n\texport-users\n\timport-users\n\tcreate-definition\n\tcreate-form-fields\n\tcreate-node\n\tcreate-instance-node"));
}

@@ -57,0 +60,0 @@

20

cloudcms-export.js

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

const fs = require("fs");
const path = require("path");
const path = require("path").posix;
const mime = require('mime-types');

@@ -108,3 +108,3 @@ const async = require("async");

includeRelated: option_includeRelated,
query: require(path.normalize(option_queryFilePath)),
query: require(path.resolve(path.normalize(option_queryFilePath))),
nodes: [],

@@ -259,3 +259,3 @@ relatedIds: [],

var attachmentPath = path.normalize(path.posix.resolve(context.dataFolderPath, pathPart, node._type.replace(':', SC_SEPARATOR), node._doc, "attachments"));
var attachmentPath = path.normalize(path.resolve(context.dataFolderPath, pathPart, node._type.replace(':', SC_SEPARATOR), node._doc, "attachments"));
wrench.mkdirSyncRecursive(path.normalize(attachmentPath));

@@ -284,3 +284,3 @@

var dataFolderPath = path.posix.normalize(context.dataFolderPath);
var dataFolderPath = path.normalize(context.dataFolderPath);

@@ -302,3 +302,3 @@ if (!Gitana.isArray(nodes)) {

var node = cleanNode(nodes[i], "");
var filePath = path.normalize(path.posix.resolve(context.dataFolderPath, pathPart, node._type.replace(':', SC_SEPARATOR), node._doc || node._source_doc, "node.json"));
var filePath = path.normalize(path.resolve(context.dataFolderPath, pathPart, node._type.replace(':', SC_SEPARATOR), node._doc || node._source_doc, "node.json"));
writeJsonFile.sync(filePath, node);

@@ -318,7 +318,7 @@ }

function buildInstancePath(dataFolderPath, node) {
return path.normalize(path.posix.resolve(dataFolderPath, "instances", node._type.replace(':', SC_SEPARATOR), node._source_doc, "node.json"));
return path.normalize(path.resolve(dataFolderPath, "instances", node._type.replace(':', SC_SEPARATOR), node._source_doc, "node.json"));
}
function buildRelatedPath(dataFolderPath, node) {
return path.normalize(path.posix.resolve(dataFolderPath, "related", node._type.replace(':', SC_SEPARATOR), node._source_doc, "node.json"));
return path.normalize(path.resolve(dataFolderPath, "related", node._type.replace(':', SC_SEPARATOR), node._source_doc, "node.json"));
}

@@ -465,3 +465,3 @@

dataFolderPath = path.posix.normalize(dataFolderPath)
dataFolderPath = path.normalize(dataFolderPath)
if (fs.existsSync(dataFolderPath)) {

@@ -506,7 +506,7 @@ Object.keys(typeDefinitions).forEach(function(typeId) {

function buildDefinitionPath(dataFolderPath, node) {
return path.normalize(path.posix.resolve(dataFolderPath, "definitions", node._qname.replace(':', SC_SEPARATOR), "node.json"));
return path.normalize(path.resolve(dataFolderPath, "definitions", node._qname.replace(':', SC_SEPARATOR), "node.json"));
}
function buildDefinitionFormPath(dataFolderPath, node, formKey) {
return path.normalize(path.posix.resolve(dataFolderPath, "definitions", node._qname.replace(':', SC_SEPARATOR), "forms", formKey.replace(':', SC_SEPARATOR) + ".json"));
return path.normalize(path.resolve(dataFolderPath, "definitions", node._qname.replace(':', SC_SEPARATOR), "forms", formKey.replace(':', SC_SEPARATOR) + ".json"));
}

@@ -513,0 +513,0 @@

@@ -75,2 +75,4 @@ #!/usr/bin/env node

util.parseGitana(gitanaConfig);
// if listing types

@@ -81,6 +83,6 @@ if (option_listTypes) {

} else if (option_nodes) {
// download and store data from project/branch to a local folder
// upload from json files on local folder to nodes on the branch
handleNodeImport();
} else if (option_allDefinitions || (option_definitionQNames && Gitana.isArray(option_definitionQNames))) {
// download and store data from project/branch to a local folder
// upload from json files on local folder to nodes on the branch
handleImport();

@@ -168,2 +170,3 @@ } else {

dataFolderPath: option_dataFolderPath,
includeRelated: option_includeRelated,
includeInstances: option_includeInstances,

@@ -170,0 +173,0 @@ overwriteExistingInstances: option_overwriteExistingInstances,

@@ -232,24 +232,6 @@ #!/usr/bin/env node

{
desc: '1. connect to Cloud CMS and list available definition qnames',
desc: '1. Export all user accounts:',
},
{
desc: 'node cloudcms-export.js --list-types'
},
{
desc: '2. export definitions and content records by qname:',
},
{
desc: 'node cloudcms-export.js --definition-qname "my:type1" "my:type2" --include-instances --folder-path ./data'
},
{
desc: '3. export all definition nodes:',
},
{
desc: 'node cloudcms-export.js --all-definitions --include-instances --folder-path ./data'
},
{
desc: '4. export a list of nodes based on a user defined query:',
},
{
desc: 'node cloudcms-export.js -y ./myquery.json --folder-path ./data'
desc: 'npx cloudcms-util export-users --all-users -g ./gitana/gitana.json --folder-path ./data'
}

@@ -256,0 +238,0 @@ ]

#!/usr/bin/env node
/*jshint -W069 */
/*jshint -W104*/
/*jshint -W069 */
/*jshint -W104*/
const Gitana = require("gitana");

@@ -14,11 +15,14 @@ const fs = require("fs");

const _ = require('underscore');
const csv = require('csvtojson');
const wrench = require("wrench");
const Logger = require('basic-logger');
const log = new Logger({
showMillis: false,
showTimestamp: true
showMillis: false,
showTimestamp: true
});
// debug only when using charles proxy ssl proxy when intercepting cloudcms api calls:
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
if (process.env.NODE_ENV !== "production") {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
}

@@ -36,8 +40,12 @@ var options = handleOptions();

var option_prompt = options["prompt"];
var option_username = options["username"];
var option_password = options["password"];
var option_useCredentialsFile = options["use-credentials-file"];
var option_gitanaFilePath = options["gitana-file-path"] || "./gitana.json";
var option_dataFolderPath = options["folder-path"] || "./data";
var option_allUsers = options["all-users"] || false;
var option_domainId = options["domain"] || "primary";
var option_queryFilePath = options["query-file-path"];
var option_dataFolderPath = options["folder-path"];
var option_csvSource = options["csv-source"];
var option_defaultPassword = options["default-password"];
var option_projectId = options["project-id"];
var option_teamKey = options["team-key"];
var option_help = options["help"];

@@ -60,15 +68,25 @@ //

gitanaConfig.password = option_prompt.hide('password: ');
} // else don't override credentials
}
if (option_username) {
gitanaConfig.username = option_username;
}
if (option_password) {
gitanaConfig.password = option_password;
}
util.parseGitana(gitanaConfig);
// if listing types
if (option_allUsers && option_queryFilePath) {
log.error("Can't export all users from a custom query. use either --all-users or query-file-path but not both");
// figure out what to do from specified options
if (option_csvSource && option_dataFolderPath) {
log.error("You must use either --csv-source or --folder-path but not both");
} else if (option_csvSource) {
// import from csv file
handleCsvUsers();
} else if (option_help) {
printHelp(getOptions());
} else if (option_allUsers || option_queryFilePath) {
// export users
} else {
// import from data folder
handleUsers();
} else {
printHelp(getOptions());
}

@@ -81,8 +99,54 @@

//
function handleCsvUsers() {
log.debug("handleCsvUsers()");
util.getBranch(gitanaConfig, "master", function (err, branch, platform, stack, domain, primaryDomain, project) {
if (err) {
log.debug("Error connecting to Cloud CMS: " + err);
return;
}
log.info("connected to project: \"" + project.title + "\" and branch: \"" + (branch.title || branch._doc) + "\"");
log.info("primary domain id: \"" + primaryDomain.__id() + "\"");
var context = {
branch: branch,
platform: platform,
stack: stack,
domain: domain,
primaryDomain: primaryDomain,
project: project,
gitanaConfig: gitanaConfig,
csvSource: option_csvSource,
defaultPassword: option_defaultPassword,
projectId: option_projectId,
teamKey: option_teamKey,
usersToImport: null, // stores the data from the csv file after parsing
existingUsersByName: {}
};
async.waterfall([
async.ensureAsync(async.apply(parseCsv, context)),
async.ensureAsync(queryExistingUsers),
async.ensureAsync(createMissingUsers),
async.ensureAsync(addUsersToProject),
async.ensureAsync(addUsersToProjectTeam)
], function (err, context) {
if (err) {
log.error("Error importing: " + err);
return;
}
log.info("Import complete");
return;
});
});
}
function handleUsers() {
log.debug("handleUsers()");
util.getBranch(gitanaConfig, "master", function(err, branch, platform, stack, domain, primaryDomain, project) {
if (err)
{
util.getBranch(gitanaConfig, "master", function (err, branch, platform, stack, domain, primaryDomain, project) {
if (err) {
log.debug("Error connecting to Cloud CMS: " + err);

@@ -103,3 +167,3 @@ return;

queryFilePath: option_queryFilePath,
dataFolderPath: option_dataFolderPath,
dataFolderPath: option_dataFolderPath || './data',
query: {},

@@ -118,30 +182,49 @@ nodes: []

async.waterfall([
async.apply(queryUsers, context),
async.ensureAsync(async.apply(writeNodesJSONtoDisk, "users")),
async.apply(queryUsers, context)
], function (err, context) {
if(err)
{
if (err) {
log.error("Error exporting: " + err);
return;
}
log.info("Export complete");
return;
});
});
});
}
function queryUsers(context, callback) {
log.debug("queryUsers()");
function parseCsv(context, callback) {
log.debug("parseCsv()");
var query = context.query;
if (!fs.existsSync(option_csvSource)) {
callback("csv file not found: " + option_csvSource, context);
}
context.primaryDomain.queryUsers(query,{
csv({
noheader: false,
headers: ['name','email','first','last','company','password']
}).fromFile(option_csvSource).then(function (data) {
context.usersToImport = data;
log.info("usersToImport: " + JSON.stringify(context.usersToImport, null, 2));
callback(null, context);
return;
});
}
function queryExistingUsers(context, callback) {
log.debug("queryExistingUsers()");
context.primaryDomain.queryUsers({
name: {
"$in": _.pluck(context.usersToImport, 'name')
}
}, {
limit: -1
}).then(function() {
// console.log( JSON.stringify( this.asArray(),null,2) );
context.nodes = _.filter(this.asArray(), function(node){
return !node.name.startsWith("appuser-");
});
}).each(function () {
var node = this;
context.existingUsersByName[node.name] = this;
}).then(function () {
context.existingUsers = this.asArray();
context.existingUserNames = _.pluck(context.existingUsers, 'name');
callback(null, context);

@@ -151,31 +234,90 @@ });

function writeNodesJSONtoDisk(pathPart, context, callback) {
log.debug("writeNodesJSONtoDisk()");
function createMissingUsers(context, callback) {
log.debug("createMissingUsers()");
var dataFolderPath = path.posix.normalize(context.dataFolderPath);
var nodes = context.nodes;
// which users need to be created
var missingUsers = _.filter(context.usersToImport, function (user) {
return _.isEmpty(context.existingUsersByName[user.name]);
});
for(var i = 0; i < nodes.length; i++) {
var node = cleanNode(nodes[i], "");
var filePath = path.normalize(path.posix.resolve(context.dataFolderPath, pathPart, node.name, "node.json"));
writeJsonFile.sync(filePath, node);
if (!option_defaultPassword) {
// if no default password then filter out users with no password
missingUsers = _.filter(missingUsers, function (user) {
return !_.isEmpty(user.password);
});
}
callback(null, context);
async.eachSeries(missingUsers, function (user, callback) {
user.password = user.password || context.defaultPassword;
Chain(context.primaryDomain).trap(function (err) {
log.warn("user create failed on primary domain: " + user.name + " " + JSON.stringify(err.message || err));
callback();
}).createUser(user).then(function () {
var node = this;
context.existingUsersByName[node.name] = node;
context.existingUsers.push(node);
log.info("Created user node " + node._doc + " for \"" + user.name + "\"");
callback();
});
}, function () {
// // update list of users to filter out users who could not be created
// context.usersToImport = _.filter(context.usersToImport, function (user) {
// return !_.isEmpty(user.node);
// });
callback(null, context);
});
}
function cleanNode(node, qnameMod) {
var n = node;
util.enhanceNode(n);
n = JSON.parse(JSON.stringify(n));
// n._source_doc = n._doc;
delete n._doc;
delete n.directoryId;
delete n.identityId;
delete n.domainId;
return n;
function addUsersToProject(context, callback) {
log.debug("addUsersToProject()");
if (!option_projectId) {
// no project id specified
return callback(null, context);
}
async.eachSeries(context.existingUsers,
function (user, callback) {
Chain(context.project).trap(function (err) {
log.warn("Error adding user " + user.name + " " + user._doc + " to the project " + option_projectId + ". " + err);
callback();
}).inviteUser(user._doc).then(function () {
log.info("Added user " + user.name + " " + user._doc + " to the project");
callback(null, context);
});
}, function (err) {
callback(null, context);
}
);
}
function addUsersToProjectTeam(context, callback) {
log.debug("addUsersToProjectTeam()");
if (!option_projectId) {
// no project id specified
return callback(null, context);
}
if (!option_teamKey) {
// no team key specified
return callback(null, context);
}
async.eachSeries(context.existingUsers, function (user, callback) {
Chain(context.stack).trap(function (err) {
log.warn("Error adding user " + user.name + " " + user._doc + " to the project team " + option_teamKey + ". " + err);
callback();
}).readTeam(option_teamKey).addMember(user).then(function () {
log.info("Added user to the project team " + user.name + " " + user._doc + " " + option_teamKey);
callback();
});
}, function (err) {
callback(err, context);
});
}
function logContext(context, callback) {

@@ -187,12 +329,70 @@ log.debug("logContext() " + JSON.stringify(context.branch, null, 2));

function getOptions() {
return [
{name: 'help', alias: 'h', type: Boolean},
{name: 'verbose', alias: 'v', type: Boolean, description: 'verbose logging'},
{name: 'prompt', alias: 'p', type: Boolean, description: 'prompt for username and password. overrides gitana.json credentials'},
{name: 'use-credentials-file', alias: 'c', type: Boolean, description: 'use credentials file ~/.cloudcms/credentials.json. overrides gitana.json credentials'},
{name: 'gitana-file-path', alias: 'g', type: String, description: 'path to gitana.json file to use when connecting. defaults to ./gitana.json'},
{name: 'folder-path', alias: 'f', type: String, description: 'folder to store exported files. defaults to ./data'},
{name: 'all-users', alias: 'a', type: Boolean, description: 'export all users. Or use --query-file-path'},
{name: 'domain-id', alias: 'd', type: String, description: 'id of the domain to query. defaults to "primary"'},
{name: 'query-file-path', alias: 'y', type: String, description: 'path to a json file defining the query. required unless --all-users is specified'}
return [{
name: 'help',
alias: 'h',
type: Boolean
},
{
name: 'verbose',
alias: 'v',
type: Boolean,
description: 'verbose logging'
},
{
name: 'prompt',
alias: 'p',
type: Boolean,
description: 'prompt for username and password. overrides gitana.json credentials'
},
{
name: 'username',
type: String,
description: 'username for api login. overrides gitana.json credentials'
},
{
name: 'password',
type: String,
description: 'password for api login. overrides gitana.json credentials'
},
{
name: 'use-credentials-file',
alias: 'c',
type: Boolean,
description: 'use credentials file ~/.cloudcms/credentials.json. overrides gitana.json credentials'
},
{
name: 'gitana-file-path',
alias: 'g',
type: String,
description: 'path to gitana.json file to use when connecting. defaults to ./gitana.json'
},
{
name: 'folder-path',
alias: 'f',
type: String,
description: 'folder to store import files. defaults to ./data. This value will be concatenated with "/users". Not needed when using csv-source.'
},
{
name: 'csv-source',
type: String,
description: 'path to a csv file with user information. The csv file should have headers: NAME, EMAIL, FIRST, LAST, COMPANY, PASSWORD. COMPANY and PASSWORD values are optional.'
},
{
name: 'default-password',
type: String,
description: 'password to use when a row in the csv does not specify one. This is optional. However, a user cannot be created without a password'
},
{
name: 'project-id',
alias: 'r',
type: String,
description: 'id of the project to which users will be added.'
},
{
name: 'team-key',
alias: 't',
type: String,
default: 'project-users-team',
description: 'Optional key of a project team to which the users should be added. The default is project-users-team.'
}
];

@@ -205,4 +405,3 @@ }

if (options.help)
{
if (options.help) {
printHelp(getOptions());

@@ -216,6 +415,5 @@ return null;

function printHelp(optionsList) {
console.log(commandLineUsage([
{
console.log(commandLineUsage([{
header: 'Cloud CMS Export',
content: 'Export user accounts from a Cloud CMS domain.'
content: 'Create user accounts in Cloud CMS primary platform domain. Optionally add the users to a project.\nExisting users (identified by their account NAME will not be modified).'
},

@@ -228,26 +426,13 @@ {

header: 'Examples',
content: [
{
desc: '1. connect to Cloud CMS and list available definition qnames',
content: [{
desc: '1. Create users from a csv file:',
},
{
desc: 'node cloudcms-export.js --list-types'
desc: 'npx cloudcms-util user-import -g ./my-gitana.json --csv-source ./users.csv\nThe csv file should have headers: NAME, EMAIL, FIRST, LAST, COMPANY, PASSWORD. COMPANY and PASSWORD. Each row defines a user. COMPANY and PASSWORD is optional.'
},
{
desc: '2. export definitions and content records by qname:',
desc: '2. Create users from a csv file:',
},
{
desc: 'node cloudcms-export.js --definition-qname "my:type1" "my:type2" --include-instances --folder-path ./data'
},
{
desc: '3. export all definition nodes:',
},
{
desc: 'node cloudcms-export.js --all-definitions --include-instances --folder-path ./data'
},
{
desc: '4. export a list of nodes based on a user defined query:',
},
{
desc: 'node cloudcms-export.js -y ./myquery.json --folder-path ./data'
desc: 'npx cloudcms-util user-import -g ./my-gitana.json --csv-source ./users.csv --project-id 5751b6235492fef8614d --team-key my-project-team'
}

@@ -254,0 +439,0 @@ ]

@@ -563,3 +563,3 @@ var Gitana = require("gitana");

}
}
};

@@ -566,0 +566,0 @@ var asURL = r.asURL = function(protocol, host, port)

{
"name": "cloudcms-util",
"version": "2.0.4",
"version": "2.1.0",
"description": "Various Cloud CMS command line utilities. Currently supports import and export of Cloud CMS nodes or definitions",

@@ -14,9 +14,10 @@ "bin": {

"dependencies": {
"async": "^2.6.1",
"async": "^2.6.2",
"basic-logger": "^0.4.4",
"chalk": "^2.4.1",
"change-case": "^3.0.2",
"chalk": "^2.4.2",
"change-case": "^3.1.0",
"command-line-args": "5.0.1",
"command-line-usage": "4.1.0",
"gitana": "^1.0.277",
"csvtojson": "^2.0.8",
"gitana": "^1.0.288",
"load-json-file": "^4.0.0",

@@ -33,5 +34,5 @@ "mime-types": "^2.1.21",

"devDependencies": {
"jshint": "^2.9.7"
"jshint": "^2.10.1"
},
"private": false
}

@@ -1,36 +0,54 @@

# npx script: cloudcms-util
## Nodejs command line scripts to perform various Cloud CMS related tasks such as import and export json nodes and binary attachments to and from Cloud CMS repositories.
# Cloud CMS Command Line Utility
[![NPM Version](https://img.shields.io/npm/v/cloudcms-util.svg)](https://www.npmjs.com/package/cloudcms-util)
[![NPM Download](https://img.shields.io/npm/dm/cloudcms-util.svg)](https://www.npmjs.com/package/cloudcms-util)
It is not necessary to install cloudcms-util because it runs as an npx script. But it will run faster if it installed first (otherwise npx will install it on demand and remove it when it finishes executing each command).
Command line scripts to perform various Cloud CMS related tasks such as import and export json nodes and binary attachments to and from Cloud CMS repositories.
## install:
Not to be confused with the official Cloud CMS CLI (https://www.npmjs.com/package/cloudcms-cli)
It is not necessary to install cloudcms-util. It runs as an npx script. But it will run faster if it installed first (otherwise npx will install it on demand and remove it when it finishes executing each command).
## Install:
npm install -g cloudcms-util
## help:
## Help:
npx cloudcms-util -h
## Command list
npx export -h
npx import -h
## List Local Definitions
Connect to Cloud CMS and list available definition qnames',
(requires gitana.json in the folder where the script is executed)
npx cloudcms-util --list-types'
## Export specified defintions and content instance records
npx cloudcms-util export --definition-qname "my:type1" "my:type2" --include-instances
requires gitana.json in the folder where the script is executed
## Export all defintions
npx cloudcms-util export -a
## Export:
### Export defintions and content instance records from a Cloud CMS project branch
## Export a list of nodes based on a user defined query:
create a mongodb query in the file ./myquery.json
{
"_type": "my:type1",
"foo": "bar"
}
connect to Cloud CMS and list available definition qnames',
},
{
desc: 'node cloudcms-export.js --list-types'
},
{
desc: '2. export definitions and content records by qname:',
},
{
desc: 'node cloudcms-export.js --definition-qname "my:type1" "my:type2" --include-instances --folder-path ./data'
},
{
desc: '3. export a list of nodes based on a user defined query:',
},
{
desc: 'node cloudcms-export.js -y ./myquery.json --folder-path ./data'
}
]
npx cloudcms-util export.js -y ./myquery.json
## Import users from a CSV file to the primary platform domain. Optionally add the users to a project.
npx cloudcms-util import-users -g ./gitana/gitana-local.json --csv-source ./data/users-test1.csv --default-password "This13ThePassword" --project-id 5751b6235492fef8614d --team-key project-managers-team --username admin --password admin
Adding users is a platform operation and requires admin privileges. Use either --prompt or --username and --password to enter credentials of a user with sufficient platform privileged.
If the user already exists in the platform it will not be modified. Therefor you can run this import process over and over again to ensure missing users are created or to add the users to a different project and/or project team.
Users require a password. If the PASSWORD column is empty for any user then the user will be skipped. Unless you use the --default-password option. If both are present then the PASSWORD column value takes precedence.
The CSV file is required to have a header as the first row. The headers should be: NAME,EMAIL,FIRST,LAST,COMPANY,PASSWORD. The header text does not actually matter. The first column is expeced to me NAME, the second column EMAIL, etc.
Example:
NAME,EMAIL,FIRST,LAST,COMPANY,PASSWORD
mary,mary.user1@email.com,Marry,User1,this company,
edith,edith.m.user2@anotheremail.com,Edith,User2,,Hello$World.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