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

@dynamicweb/cli

v1.0.12

Published

Dynamicweb CLI is a commandline tool for interacting with Dynamicweb 10 solutions.

Downloads

252

Readme

DynamicWeb CLI

What is it?

DynamicWeb CLI is a powerful command line tool designed to help developers quickly and efficiently manage any given DynamicWeb 10 solution they may have access to. These tools inclues an easy setup and handling of different environments, access to the Management API and an easy way to update a Swift solution.

Logging into a DynamicWeb 10 solution through the DynamicWeb CLI will create an API Key for the given user, which in turn lets you use any Queries and Commands the solution had, meaning you can control everything you can do in the backend, from your command line. With this, you can hook it up to your own build pipelines and processes, if certain requests needs to happen before or after deployments or changes.

The DynamicWeb CLI can also help with active development of custom addins to solutions. With a simple dw install command it will upload and install your custom code to a solution.

Extracting files from solutions is just as easy as well, with the DynamicWeb CLI you can list out the structure of a solution and get full exports of the files structure and the database. Importing files into a solution is just as easy as well, as long as you have access to the files and the solution, they can be imported with a simple command using the DynamicWeb CLI.

Get started

To install after cloning, move to project dir and run

$ npm install -g .

$ npm install

Note that specific installations might be necessary if you're faced with errors such as 'Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'yargs'' In which case try installing that module specifically;

$ npm install yargs

Commands

All commands and options can be viewed by running

$ dw --help

$ dw <command> --help

Users and environments

As most commands are pulling or pushing data from the DW admin API, the necessary authorization is required.

To generate an Api-key that the CLI will use, login to your environment

$ dw login

This will start an interactive session asking for username and password, as well as the name of the environment, so it's possible to switch between different environments easily. It will also ask for a host, if you're running a local environment, set this to the host it starts up with, i.e localhost:6001.

Each environment has its own users, and each user has its own Api-key assigned to it, swap between environments by using

$ dw env <env>

and swap between users by simply supplying the name of the user in the login command

$ dw login <username>

You can view the current environment and user being used by simply typing

$ dw

The configuration will automatically be created when setting up your first environment, but if you already have an Api-key you want to use for a user, you can modify the config directly in the file located in usr/.dwc. The structure should look like the following

{
    "env": {
        "dev": {
            "host": "localhost:6001",
            "users": {
                "DemoUser": {
                    "apiKey": "<keyPrefix>.<key>"
                }
            },
            "current": {
                "user": "DemoUser"
            }
        }
    },
    "current": {
        "env": "dev"
    }
}

Files

$ dw files <dirPath> <outPath>

The files command is used to list out and export the structure in your Dynamicweb files archive, as such is has multiple options;

  • -l --list This will list the directory given in <dirPath>
  • -f --includeFiles The list will now also show all files in the directories
  • -r --recursive By default it only handles the <dirPath>, but with this option it will handle all directories under this recursively
  • -e --export It will export <dirPath> into <outPath> on your local machine, unzipped by default
  • --raw This will keep the content zipped
  • --iamstupid This will include the export of the /files/system/log and /files/.cache folders

Examples

Exporting all templates from current environment to local solution

$ cd DynamicWebSolution/Files

$ dw files templates ./templates -fre

Listing the system files structure of the current environment

$ dw files system -lr

Swift

$ dw swift <outPath>

The swift command is used to easily get your local environment up to date with the latest swift release. It will override all existing directories and content in those, which can then be adjusted in your source control afterwards. It has multiple options to specify which tag or branch to pull;

  • -t --tag <tag> The tag/branch/release to pull
  • -l --list Will list all the release versions
  • -n --nightly Will pull #HEAD, as default is latest release
  • --force Used if <outPath> is not an empty folder, to override all the content

Examples

Getting all the available releases

$ dw swift -l

Pulling and overriding local solution with latest nightly build

$ cd DynamicWebSolution/Swift

$ dw swift . -n --force

Query

$ dw query <query>

The query command will fire any query towards the admin Api with the given query parameters. This means any query parameter that's necessary for the given query, is required as an option in this command. It's also possible to list which parameters is necessary for the given query through the options;

  • -l --list Will list all the properties for the given <query>
  • -i --interactive Will perform the <query> but without any parameters, as they will be asked for one by one in interactive mode
  • --<queryParam> Any parameter the query needs will be sent by '--key value'

Examples

Getting all properties for a query

$ dw query FileByName -l

Getting file information on a specific file by name

$ dw query FileByName --name DefaultMail.html --directorypath /Templates/Forms/Mail

Command

$ dw command <command>

Using command will, like query, fire any given command in the solution. It works like query, given the query parameters necessary, however if a DataModel is required for the command, it is given in a json-format, either through a path to a .json file or a literal json-string in the command.

  • -l --list Lists all the properties for the command, as well as the json model required currently not working
  • --json Takes a path to a .json file or a literal json, i.e --json '{ abc: "123" }'

Examples

Creating a copy of a page using a json-string

$ dw command PageCopy --json '{ "model": { "SourcePageId": 1189, "DestinationParentPageId": 1129 } }'

Removing a page using a json file

$ dw command PageMove --json ./PageMove.json

Where PageMove.json contains

{ "model": { "SourcePageId": 1383, "DestinationParentPageId": 1376 } }

Deleting a page

$ dw command PageDelete --json '{ "id": "1383" }'

Install

$ dw install <filePath>

Install is somewhat of a shorthand for a few commands. It will upload and install a given .dll or .nupkg addin to your current environment.

It's meant to be used to easily apply custom dlls to a given project, it being local or otherwise, so after having a dotnet library built locally, this command can be run, pointing to the built .dll and it will handle the rest with all the addin installation, and it will be available in the DynamicWeb solution as soon as the command finishes.

Examples

$ dw install ./bin/Release/net6.0/CustomProject.dll

Database

$ dw database <outPath>

This command is used for various actions towards your current environments database.

  • -e --export Exports your current environments database to a .bacpac file at <outPath>

Examples

$ dw database -e ./backup

Config

$ dw config

Config is used to manage the .dwc file through the CLI, given any prop it will create the key/value with the path to it.

  • --<property> The path and name of the property to set

Examples

Changing the host for the dev environment

$ dw config --env.dev.host localhost:6001