Skip to content

Commit

Permalink
Merge branch 'release/0.6.6'.
Browse files Browse the repository at this point in the history
  • Loading branch information
petrbroz committed May 21, 2019
2 parents ed1991f + 09f9285 commit 46d187e
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 13 deletions.
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
language: node_js
node_js:
- '10'

os:
- windows
- osx
- linux

script: npm run build

matrix:
allow_failures:
- os: windows

deploy:
- provider: npm
email: $NPM_EMAIL
Expand All @@ -12,7 +22,7 @@ deploy:
- provider: releases
api_key: $GITHUB_TOKEN
file_glob: true
file: bin/*
file: bin/*.zip
skip_cleanup: true
on:
tags: true
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ Scripts in this library are also packaged into self-contained binaries for vario
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.

> While the [Travis CI/CD pipeline](https://travis-ci.org/petrbroz/forge-cli-utils)
> provides an experimental support for _windows_ builds, these don't seem to be working.
> Therefore, only _linux_ and _macos_ binaries are built automatically and attached
> to Github releases. Windows binaries can be built manually by running `npm run build`
> on a Windows system.
## Examples

### Data Management
Expand Down
47 changes: 43 additions & 4 deletions package-lock.json

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

11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
{
"name": "forge-cli-utils",
"version": "0.6.5",
"version": "0.6.6",
"description": "Command line tools for Autodesk Forge services.",
"bin": {
"forge-dm": "src/forge-dm.js",
"forge-da": "src/forge-da.js",
"forge-md": "src/forge-md.js"
},
"scripts": {
"build": "npm run build:win && npm run build:macos",
"build:win": "export FORGE_CLI_ARCH=node10-win-x64 && npm run pack && zip -jr bin/$FORGE_CLI_ARCH.zip bin/$FORGE_CLI_ARCH/* && rm -rf bin/$FORGE_CLI_ARCH",
"build:macos": "export FORGE_CLI_ARCH=node10-macos-x64 && npm run pack && zip -jr bin/$FORGE_CLI_ARCH.zip bin/$FORGE_CLI_ARCH/* && rm -rf bin/$FORGE_CLI_ARCH",
"pack": "npm run pack:dm && npm run pack:md && npm run pack:da",
"pack:dm": "pkg src/forge-dm.js --targets $FORGE_CLI_ARCH --out-path bin/$FORGE_CLI_ARCH",
"pack:md": "pkg src/forge-md.js --targets $FORGE_CLI_ARCH --out-path bin/$FORGE_CLI_ARCH",
"pack:da": "pkg src/forge-da.js --targets $FORGE_CLI_ARCH --out-path bin/$FORGE_CLI_ARCH"
"build": "node tools/build.js"
},
"keywords": [
"autodesk",
Expand All @@ -30,6 +24,7 @@
"inquirer": "^6.3.1"
},
"devDependencies": {
"jszip": "^3.2.1",
"pkg": "^4.4.0"
}
}
30 changes: 30 additions & 0 deletions tools/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const path = require('path');
const fs = require('fs');
const { exec } = require('pkg');
const JSZip = require('jszip');

const SCRIPTS = Object.values(require('../package.json').bin);
const LABEL = `forge-cli-utils.${process.platform}-${process.arch}`;

async function build() {
const binDir = path.resolve(__dirname, '..', 'bin');
const tmpDir = path.resolve(binDir, LABEL);

// Package individual scripts listed in package.json
for (const filename of SCRIPTS) {
const srcPath = path.resolve(__dirname, '..', filename);
console.log('Packaging script', srcPath);
await exec([srcPath, '--target', 'host', '--out-dir', tmpDir]);
}

// Compress scripts into a single zip file
const archive = new JSZip();
for (const filename of fs.readdirSync(tmpDir)) {
const buff = fs.readFileSync(path.resolve(tmpDir, filename));
archive.file(filename, buff);
}
const zipped = await archive.generateAsync({ type: 'nodebuffer' });
fs.writeFileSync(path.resolve(binDir, LABEL + '.zip'), zipped);
}

build();

0 comments on commit 46d187e

Please sign in to comment.