Skip to content

Commit

Permalink
Merge branch 'release/0.7.1'.
Browse files Browse the repository at this point in the history
  • Loading branch information
petrbroz committed May 29, 2019
2 parents 0c265e2 + edf4df5 commit f52fc21
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 110 deletions.
106 changes: 71 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,107 @@ Command line tools for Autodesk Forge services.

[![asciicast](https://asciinema.org/a/244057.svg)](https://asciinema.org/a/244057)

## Usage
## Installation

### Using npm

- install the library, either in your own npm project (`npm install --save forge-cli-utils`),
or globally (`npm install --global forge-cli-utils`)
- setup `FORGE_CLIENT_ID` and `FORGE_CLIENT_SECRET` env. vars with your app credentials
- use the following scripts for different Forge services:
- `forge-dm` - [Forge Data Management](https://forge.autodesk.com/en/docs/data/v2) service
- `forge-md` - [Forge Model Derivative](https://forge.autodesk.com/en/docs/model-derivative/v2) service
- `forge-da` - [Forge Design Automation](https://forge.autodesk.com/en/docs/design-automation/v3) service
Install the `forge-cli-utils` library, either in your own npm project
(`npm install --save forge-cli-utils`), or globally (`npm install --global forge-cli-utils`).

### Self-contained binaries

Scripts in this library are also packaged into self-contained binaries for various platforms
using the [pkg](https://www.npmjs.com/package/pkg) module. You can download the binaries on
the [release](https://github.com/petrbroz/forge-cli-utils/releases) pages.
using the [pkg](https://www.npmjs.com/package/pkg) module. You can download the binaries from
[release](https://github.com/petrbroz/forge-cli-utils/releases) pages.

## Usage

### Bash auto-completion
### Providing Forge credentials

When using bash, use the _tools/autocomplete-bash.sh_ script to setup a simple auto-completion
for the basic commands of each script: `source tools/autocomplete-bash.sh`.
The CLI tools require Forge app credentials to be provided as env. variables.

## Examples
> If you don't have a Forge app yet, check out this tutorial: https://forge.autodesk.com/en/docs/oauth/v2/tutorials/create-app/.
### Data Management
On macOS and linux:
```bash
export FORGE_CLIENT_ID=<your client id>
export FORGE_CLIENT_SECRET=<your client secret>
```

Listing buckets as full JSON
On Windows:
```
set FORGE_CLIENT_ID=<your client id>
set FORGE_CLIENT_SECRET=<your client secret>
```

### Scripts

Use the following scripts for different Forge services:
- `forge-dm` - [Forge Data Management](https://forge.autodesk.com/en/docs/data/v2) service
- `forge-md` - [Forge Model Derivative](https://forge.autodesk.com/en/docs/model-derivative/v2) service
- `forge-da` - [Forge Design Automation](https://forge.autodesk.com/en/docs/design-automation/v3) service

`forge-dm list-buckets`
Each script expects a _subcommand_ similar to `git`. To get a list of all available commands,
run the script with `-h` or `--help`.

Listing object IDs of specific bucket
> When using bash, use the _tools/autocomplete-bash.sh_ script to setup a simple auto-completion
> for the basic commands of each script: `source tools/autocomplete-bash.sh`.
`forge-dm list-objects my-test-bucket --short`
Most commands output raw JSON output from Forge services by default, but in many cases
you can use `-s` or `--short` flag to output a more concise version of the results.
The raw JSON output can also be combined with tools like [jq](https://stedolan.github.io/jq)
to extract just the pieces of information that you need:

Listing object IDs without specifying a bucket (will show an interactive prompt with list of buckets to choose from)
```bash
# Listing buckets as full JSON
forge-dm list-buckets

`forge-dm list-objects --short`
# Listing bucket keys
forge-dm list-buckets --short

Getting an URN of an object
# List creation dates of all buckets
forge-dm list-buckets | jq '.[] | .createdDate'
```

`forge-dm object-urn my-bucket-key my-object-key`
### Examples

### Design Automation
#### Data Management

Creating a new app bundle
```bash
# Listing buckets as full JSON
forge-dm list-buckets

`forge-da create-appbundle BundleName path/to/bundle/zipfile Autodesk.Inventor+23 "Bundle description here."`
# Listing object IDs of specific bucket
forge-dm list-objects my-test-bucket --short

Updating existing activity
# Listing object IDs without specifying a bucket (will show an interactive prompt with list of buckets to choose from)
forge-dm list-objects --short

`forge-da update-activity ActivityName BundleName BundleAlias Autodesk.Inventor+23 --input PartFile --output Thumbnail:thumbnail.bmp`
# Getting an URN of an object
forge-dm object-urn my-bucket-key my-object-key
```

Creating work item
#### Design Automation

`forge-da create-workitem ActivityName ActivityAlias --input PartFile:https://some.url --output Thumbnail:https://another.url --short`
```bash
# Creating a new app bundle
forge-da create-appbundle BundleName path/to/bundle/zipfile Autodesk.Inventor+23 "Bundle description here."

### Model Derivative
# Updating existing activity
forge-da update-activity ActivityName BundleName BundleAlias Autodesk.Inventor+23 --input PartFile --output Thumbnail:thumbnail.bmp

Translating a model based on its URN
# Creating work item
forge-da create-workitem ActivityName ActivityAlias --input PartFile:https://some.url --output Thumbnail:https://another.url --short
```

`forge-md translate dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6cG9jLWJvdXlndWVzLWltbW9iaWxpZXIvaW5wdXQucnZ0`
#### Model Derivative

Showing an interactive prompt with all viewables in an URN, and then getting properties of the selected viewable
```bash
# Translating a model based on its URN
forge-md translate dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6cG9jLWJvdXlndWVzLWltbW9iaWxpZXIvaW5wdXQucnZ0

`forge-md get-viewable-props dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6cG9jLWJvdXlndWVzLWltbW9iaWxpZXIvaW5wdXQucnZ0`
# Showing an interactive prompt with all viewables in an URN, and then getting properties of the selected viewable
forge-md get-viewable-props dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6cG9jLWJvdXlndWVzLWltbW9iaWxpZXIvaW5wdXQucnZ0
```

> For additional examples, check out the _tests_ subfolder.
41 changes: 1 addition & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "forge-cli-utils",
"version": "0.7.0",
"version": "0.7.1",
"description": "Command line tools for Autodesk Forge services.",
"author": "Petr Broz <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -31,7 +31,6 @@
"inquirer": "^6.3.1"
},
"devDependencies": {
"jszip": "^3.2.1",
"pkg": "4.3.8"
},
"engines": {
Expand Down
3 changes: 2 additions & 1 deletion src/forge-da.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { prompt } = require('inquirer');
const FormData = require('form-data');
const { DesignAutomationClient, DesignAutomationURI } = require('forge-nodejs-utils');

const package = require('./package.json');
const { log, warn, error } = require('./common');

const { FORGE_CLIENT_ID, FORGE_CLIENT_SECRET } = process.env;
Expand Down Expand Up @@ -94,7 +95,7 @@ function uploadAppBundleFile(appBundle, appBundleFilename) {
}

program
.version('0.3.0')
.version(package.version)
.description('Command-line tool for accessing Autodesk Forge Design Automation service.');

program
Expand Down
3 changes: 2 additions & 1 deletion src/forge-dm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const program = require('commander');
const { prompt } = require('inquirer');
const { DataManagementClient } = require('forge-nodejs-utils');

const package = require('./package.json');
const { log, warn, error } = require('./common');

const { FORGE_CLIENT_ID, FORGE_CLIENT_SECRET } = process.env;
Expand All @@ -28,7 +29,7 @@ async function promptObject(bucket) {
}

program
.version('0.3.0')
.version(package.version)
.description('Command-line tool for accessing Autodesk Forge Data Management service.');

program
Expand Down
3 changes: 2 additions & 1 deletion src/forge-md.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const program = require('commander');
const { prompt } = require('inquirer');
const { ModelDerivativeClient } = require('forge-nodejs-utils');

const package = require('./package.json');
const { log, warn, error } = require('./common');

const { FORGE_CLIENT_ID, FORGE_CLIENT_SECRET } = process.env;
Expand All @@ -27,7 +28,7 @@ function sleep(ms) {
}

program
.version('0.3.0')
.version(package.version)
.description('Command-line tool for accessing Autodesk Forge Model Derivative service.');

program
Expand Down
30 changes: 0 additions & 30 deletions tools/build.js

This file was deleted.

0 comments on commit f52fc21

Please sign in to comment.