Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ npm-debug.log*
coverage
.nyc_output

build/*
!build/README.md
/build
dist/

deployment/*.retry
2 changes: 1 addition & 1 deletion bin/plotly-export-server_electron.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const plotlyExporter = require('../')
const plotlyExporter = require('../src/index.js')
const { getServerArgs, getServerHelpMsg } = require('./args')
const pkg = require('../package.json')

Expand Down
2 changes: 1 addition & 1 deletion bin/plotly-graph-exporter_electron.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const plotlyExporter = require('../')
const plotlyExporter = require('../src/index.js')
const { getExporterArgs, getExporterHelpMsg } = require('./args')
const pkg = require('../package.json')

Expand Down
File renamed without changes.
22 changes: 20 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Plotly's image exporting utility",
"license": "MIT",
"main": "src/index.js",
"main": "./bin/plotly-graph-exporter_electron.js",
"bin": {
"plotly-graph-exporter": "./bin/plotly-graph-exporter.js",
"plotly-export-server": "./bin/plotly-export-server.js"
Expand All @@ -17,6 +17,24 @@
"coverage": "npm run test:unit -- --cov",
"lint": "standard --fix"
},
"build": {
"appId": "com.plotly.image-exporter.graph-exporter",
"electronCompile": false,
"productName": "Plotly Graph Exporter",
"copyright": "Copyright © 2018 ${author}",
"appImage": {
"systemIntegration": "doNotAsk",
"category": "Utility"
},
"win": {
"target": [{
"target": "nsis"
}]},
"mac": {
"target": [{
"target": "default"
}]}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding Linux deb target so that I can test it on my laptop? (Sorry for the inconvenience if any),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have Ubuntu as the main OS on my laptop, which is a Debian distribution. AppImage is the default format for this build target. If one runs electron-builder . or similar, one would get an AppImage which one can execute on Debian.

If you require me to address this further, let me know.

},
"author": "Plotly, Inc.",
"keywords": [
"graphing",
Expand All @@ -26,7 +44,6 @@
],
"dependencies": {
"body": "^5.1.0",
"electron": "^1.7.9",
"fast-isnumeric": "^1.1.1",
"file-type": "^7.2.0",
"get-stdin": "^5.0.1",
Expand All @@ -45,6 +62,7 @@
},
"devDependencies": {
"devtron": "^1.4.0",
"electron": "^1.7.9",
"electron-debug": "^1.4.0",
"image-size": "^0.6.1",
"sinon": "^3.2.0",
Expand Down
6 changes: 5 additions & 1 deletion src/util/create-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ const fs = require('fs')
const path = require('path')
const uuid = require('uuid/v4')
const isNonEmptyString = require('./is-non-empty-string')
const os = require('os')

const COMPONENT_GLOBAL = 'PlotlyExporterComponent'
const PATH_TO_BUILD = path.join(__dirname, '..', '..', 'build')
const PATH_TO_BUILD = path.join(os.tmpdir(), 'plotly-graph-exporter-build')
try {
fs.mkdirSync(PATH_TO_BUILD)
} catch (e) {}
const PATH_TO_INIT_RENDERERS = path.join(__dirname, 'init-renderers.js')

/** Create HTML index file
Expand Down
6 changes: 5 additions & 1 deletion src/util/pdftops.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ const childProcess = require('child_process')
const parallel = require('run-parallel')
const series = require('run-series')
const uuid = require('uuid/v4')
const os = require('os')

const PATH_TO_BUILD = path.join(__dirname, '..', '..', 'build')
const PATH_TO_BUILD = path.join(os.tmpdir(), 'plotly-graph-exporter-build')
try {
fs.mkdirSync(PATH_TO_BUILD)
} catch (e) {}

/** Node wrapper for pdftops
*
Expand Down
2 changes: 1 addition & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const urls = {}
const mocks = {}

paths.root = path.join(__dirname, '..')
paths.build = path.join(paths.root, 'build')
paths.build = path.join(path.join(paths.root, 'build'))
paths.bin = path.join(paths.root, 'bin')
paths.readme = path.join(paths.root, 'README.md')
paths.pkg = path.join(paths.root, 'package.json')
Expand Down
5 changes: 3 additions & 2 deletions test/integration/plotly-export-server_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const fs = require('fs')
const request = require('request')
const readChunk = require('read-chunk')
const fileType = require('file-type')
const { paths } = require('../common')

const PORT = 9109
const SERVER_URL = `http://localhost:${PORT}`
Expand Down Expand Up @@ -110,7 +111,7 @@ tap.test('should work for *plotly-dashboard* component', {timeout: 1e5}, t => {
})

t.test('piping info write stream', t => {
const outPath = path.join(ROOT_PATH, 'build', 'dashboard.pdf')
const outPath = path.join(paths.build, 'dashboard.pdf')
const ws = fs.createWriteStream(outPath)

request({
Expand Down Expand Up @@ -139,7 +140,7 @@ tap.test('should work for *plotly-dashboard* component', {timeout: 1e5}, t => {
})

tap.test('should work for *plotly-dashboard-thumbnail* component', t => {
const outPath = path.join(ROOT_PATH, 'build', 'dashboard-thumbnail.png')
const outPath = path.join(paths.build, 'dashboard-thumbnail.png')
const ws = fs.createWriteStream(outPath)

request({
Expand Down
3 changes: 2 additions & 1 deletion test/integration/plotly-graph-exporter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ const tap = require('tap')
const { spawn } = require('child_process')
const path = require('path')
const pkg = require('../../package.json')
const { paths } = require('../common')

const ROOT_PATH = path.join(__dirname, '..', '..')
const BIN = path.join(ROOT_PATH, 'bin', 'plotly-graph-exporter.js')
const BASE_ARGS = [
'--output-dir', path.join(ROOT_PATH, 'build'),
'--output-dir', path.join(paths.build),
'--verbose'
]

Expand Down
8 changes: 4 additions & 4 deletions test/pretest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const mock = JSON.stringify({
}
})

execSync(`${paths.bin}/plotly-graph-exporter.js '${mock}' -f svg -d build -o test-mock`)
console.log('build/test-mock.svg created')
execSync(`${paths.bin}/plotly-graph-exporter.js '${mock}' -f svg -d ${paths.build} -o test-mock`)
console.log(`${paths.build}/test-mock.svg created`)

execSync(`${paths.bin}/plotly-graph-exporter.js '${mock}' -f pdf -d build -o test-mock`)
console.log('build/test-mock.pdf created')
execSync(`${paths.bin}/plotly-graph-exporter.js '${mock}' -f pdf -d ${paths.build} -o test-mock`)
console.log(`${paths.build}/test-mock.pdf created`)
4 changes: 2 additions & 2 deletions test/unit/coerce-component_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const sinon = require('sinon')
const path = require('path')
const fs = require('fs')
const uuid = require('uuid/v4')
const { paths } = require('../common')

const coerceComponent = require('../../src/util/coerce-component')
const PATH_TO_BUILD = path.join(__dirname, '..', '..', 'build')

const testMockComponentModule = (t, compModuleContent, cb) => {
const compPath = path.join(PATH_TO_BUILD, uuid() + '.js')
const compPath = path.join(paths.build, uuid() + '.js')
const comp = {path: compPath}

fs.writeFile(compPath, compModuleContent, (err) => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/pdftops_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tap.test('pdftops.pdf2eps', t => {
if (err) t.fail(err)

const size = fs.statSync(outPath).size
t.ok(size > 1e5, 'min pdf file size')
t.ok(size > 9e4, 'min pdf file size')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This resolves #48 I presume? Nice!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yessir.

t.ok(size < 4e5, 'max pdf file size')
t.ok(fileType(readChunk.sync(outPath, 0, 4100)).mime === 'application/postscript', 'postscript content')
t.end()
Expand Down