@jscad/cli 2.2.12 → 2.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.2.13](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.12...@jscad/cli@2.2.13) (2022-01-23)
7
+
8
+ **Note:** Version bump only for package @jscad/cli
9
+
10
+
11
+
12
+
13
+
6
14
  ## [2.2.12](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.11...@jscad/cli@2.2.12) (2021-12-26)
7
15
 
8
16
  **Note:** Version bump only for package @jscad/cli
@@ -4,7 +4,7 @@ const path = require('path')
4
4
  const { execSync } = require('child_process')
5
5
  const fs = require('fs')
6
6
 
7
- test.afterEach.always(t => {
7
+ test.afterEach.always((t) => {
8
8
  // remove files
9
9
  try {
10
10
  if (t.context.file1Path) fs.unlinkSync(t.context.file1Path)
@@ -23,7 +23,7 @@ test.afterEach.always(t => {
23
23
  } catch (err) {}
24
24
  })
25
25
 
26
- test.beforeEach(t => {
26
+ test.beforeEach((t) => {
27
27
  const cliName = './cli.js'
28
28
  t.context = {
29
29
  cliPath: path.resolve(__dirname, cliName)
@@ -68,7 +68,7 @@ module.exports = { main, getParameterDefinitions }
68
68
  return filePath
69
69
  }
70
70
 
71
- test('cli (conversions STL)', t => {
71
+ test('cli (conversions STL)', (t) => {
72
72
  const testID = 11
73
73
 
74
74
  // convert from JSCAD script to STL
@@ -101,7 +101,7 @@ test('cli (conversions STL)', t => {
101
101
  t.true(fs.existsSync(file3Path))
102
102
  })
103
103
 
104
- test('cli (conversions DXF)', t => {
104
+ test('cli (conversions DXF)', (t) => {
105
105
  const testID = 12
106
106
 
107
107
  // convert from JSCAD to DXF
@@ -134,7 +134,7 @@ test('cli (conversions DXF)', t => {
134
134
  t.true(fs.existsSync(file3Path))
135
135
  })
136
136
 
137
- test('cli (conversions AMF)', t => {
137
+ test('cli (conversions AMF)', (t) => {
138
138
  const testID = 13
139
139
 
140
140
  // convert from JSCAD to AMF
@@ -167,7 +167,7 @@ test('cli (conversions AMF)', t => {
167
167
  t.true(fs.existsSync(file3Path))
168
168
  })
169
169
 
170
- test('cli (conversions JSON)', t => {
170
+ test('cli (conversions JSON)', (t) => {
171
171
  const testID = 14
172
172
 
173
173
  // convert from JSCAD to JSON
@@ -200,7 +200,7 @@ test('cli (conversions JSON)', t => {
200
200
  t.true(fs.existsSync(file3Path))
201
201
  })
202
202
 
203
- test('cli (conversions SVG)', t => {
203
+ test('cli (conversions SVG)', (t) => {
204
204
  const testID = 15
205
205
 
206
206
  // convert from JSCAD to SVG
@@ -233,7 +233,7 @@ test('cli (conversions SVG)', t => {
233
233
  t.true(fs.existsSync(file3Path))
234
234
  })
235
235
 
236
- test('cli (conversions X3D)', t => {
236
+ test('cli (conversions X3D)', (t) => {
237
237
  const testID = 16
238
238
 
239
239
  // convert from JSCAD to X3D
package/cli.js CHANGED
@@ -59,8 +59,8 @@ const src = fs.readFileSync(inputFile, inputFile.match(/\.stl$/i) ? 'binary' : '
59
59
  // -- convert from JSCAD script into the desired output format
60
60
  // -- and write it to disk
61
61
  generateOutputData(src, params, { outputFile, outputFormat, inputFile, inputFormat, version, addMetaData, inputIsDirectory })
62
- .then(outputData => writeOutput(outputFile, outputData))
63
- .catch(error => {
62
+ .then((outputData) => writeOutput(outputFile, outputData))
63
+ .catch((error) => {
64
64
  console.error(error)
65
65
  process.exit(1)
66
66
  })
@@ -4,7 +4,7 @@ const path = require('path')
4
4
  const { execSync } = require('child_process')
5
5
  const fs = require('fs')
6
6
 
7
- test.afterEach.always(t => {
7
+ test.afterEach.always((t) => {
8
8
  // remove files
9
9
  try {
10
10
  if (t.context.inputPath) fs.unlinkSync(t.context.inputPath)
@@ -19,7 +19,7 @@ test.afterEach.always(t => {
19
19
  } catch (err) {}
20
20
  })
21
21
 
22
- test.beforeEach(t => {
22
+ test.beforeEach((t) => {
23
23
  const cliName = './cli.js'
24
24
  t.context = {
25
25
  cliPath: path.resolve(__dirname, cliName)
@@ -63,7 +63,7 @@ module.exports = { main, getParameterDefinitions }
63
63
  return filePath
64
64
  }
65
65
 
66
- test('cli (single input file)', t => {
66
+ test('cli (single input file)', (t) => {
67
67
  const testID = 1
68
68
 
69
69
  const inputPath = createJscad(testID)
@@ -84,7 +84,7 @@ test('cli (single input file)', t => {
84
84
  t.true(fs.existsSync(outputPath))
85
85
  })
86
86
 
87
- test('cli (single input file, output format)', t => {
87
+ test('cli (single input file, output format)', (t) => {
88
88
  const testID = 2
89
89
 
90
90
  const inputPath = createJscad(testID)
@@ -105,7 +105,7 @@ test('cli (single input file, output format)', t => {
105
105
  t.true(fs.existsSync(outputPath))
106
106
  })
107
107
 
108
- test('cli (single input file, output filename)', t => {
108
+ test('cli (single input file, output filename)', (t) => {
109
109
  const testID = 3
110
110
 
111
111
  const inputPath = createJscad(testID)
@@ -126,7 +126,7 @@ test('cli (single input file, output filename)', t => {
126
126
  t.true(fs.existsSync(outputPath))
127
127
  })
128
128
 
129
- test('cli (folder, output format)', t => {
129
+ test('cli (folder, output format)', (t) => {
130
130
  const testID = 4
131
131
 
132
132
  const inputPath = createJscad(testID)
@@ -161,7 +161,7 @@ test('cli (folder, output format)', t => {
161
161
  t.true(fs.existsSync(outputPath))
162
162
  })
163
163
 
164
- test('cli (single input file, parameters)', t => {
164
+ test('cli (single input file, parameters)', (t) => {
165
165
  const testID = 5
166
166
 
167
167
  const inputPath = createJscad(testID)
@@ -182,7 +182,7 @@ test('cli (single input file, parameters)', t => {
182
182
  t.true(fs.existsSync(outputPath))
183
183
  })
184
184
 
185
- test('cli (no parameters)', t => {
185
+ test('cli (no parameters)', (t) => {
186
186
  const cliPath = t.context.cliPath
187
187
 
188
188
  const cmd = `node ${cliPath}`
@@ -191,11 +191,11 @@ test('cli (no parameters)', t => {
191
191
  })
192
192
  })
193
193
 
194
- test('cli (single input file, invalid jscad)', t => {
194
+ test('cli (single input file, invalid jscad)', (t) => {
195
195
  const testID = 6
196
196
 
197
197
  const inputPath = createJscad(testID)
198
- fs.writeFileSync(inputPath, "INVALID")
198
+ fs.writeFileSync(inputPath, 'INVALID')
199
199
  t.true(fs.existsSync(inputPath))
200
200
 
201
201
  t.context.inputPath = inputPath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jscad/cli",
3
- "version": "2.2.12",
3
+ "version": "2.2.13",
4
4
  "description": "Command Line Interface (CLI) for JSCAD",
5
5
  "repository": "https://github.com/jscad/OpenJSCAD.org",
6
6
  "bin": {
@@ -35,8 +35,8 @@
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
37
  "@jscad/array-utils": "2.1.1",
38
- "@jscad/core": "2.5.2",
39
- "@jscad/io": "2.2.2",
38
+ "@jscad/core": "2.5.3",
39
+ "@jscad/io": "2.2.3",
40
40
  "@jscad/modeling": "2.7.1"
41
41
  },
42
42
  "devDependencies": {
@@ -48,5 +48,5 @@
48
48
  "url": "https://opencollective.com/openjscad",
49
49
  "logo": "https://opencollective.com/openjscad/logo.txt"
50
50
  },
51
- "gitHead": "c8ac21281a7acf5a5575b940c18353c598ffa1a4"
51
+ "gitHead": "95f05c5f11a53bff469a305d69b99f674dc7d6d3"
52
52
  }
package/src/env.js CHANGED
@@ -1,13 +1,13 @@
1
1
  const version = require('../package.json').version
2
2
 
3
- function env () {
4
- var env = 'OpenJSCAD ' + version
3
+ const env = () => {
4
+ let env = 'OpenJSCAD ' + version
5
5
  if (typeof document !== 'undefined') {
6
- var w = document.defaultView
6
+ const w = document.defaultView
7
7
  env = env + ' [' + w.navigator.userAgent + ']'
8
8
  } else {
9
9
  if (typeof require === 'function') {
10
- var os = require('os')
10
+ const os = require('os')
11
11
  env = env + ' [' + os.type() + ':' + os.release() + ',' + os.platform() + ':' + os.arch() + ']'
12
12
  }
13
13
  }
@@ -60,7 +60,7 @@ const generateOutputData = (source, params, options) => {
60
60
  }
61
61
  }
62
62
  })
63
- .then(solids => {
63
+ .then((solids) => {
64
64
  const serializerOptions = Object.assign({ format: outputFormat }, params)
65
65
  return solidsAsBlob(solids, serializerOptions)
66
66
  })
package/src/parseArgs.js CHANGED
@@ -5,7 +5,7 @@ const { supportedInputExtensions, supportedOutputExtensions, supportedOutputForm
5
5
 
6
6
  const env = require('./env')
7
7
 
8
- const parseArgs = args => {
8
+ const parseArgs = (args) => {
9
9
  const inputExtensions = supportedInputExtensions()
10
10
  const outputExtensions = supportedOutputExtensions()
11
11
  const outputFormats = supportedOutputFormats()
@@ -28,17 +28,15 @@ const parseArgs = args => {
28
28
  let addMetaData = false // wether to add metadata to outputs or not : ie version info, timestamp etc
29
29
  let inputIsDirectory = false // did we pass in a folder or a file ?
30
30
 
31
- const isValidInputFileFormat = input => {
31
+ const isValidInputFileFormat = (input) => {
32
32
  if (input === undefined || input === null || !(typeof input === 'string')) {
33
33
  return false
34
34
  }
35
- return inputExtensions.reduce((acc, format) => {
36
- return input.toLowerCase().endsWith('.' + format) || acc
37
- }, false)
35
+ return inputExtensions.reduce((acc, format) => input.toLowerCase().endsWith('.' + format) || acc, false)
38
36
  }
39
- const getFileExtensionFromString = input => (input.substring(input.lastIndexOf('.') + 1)).toLowerCase()
37
+ const getFileExtensionFromString = (input) => (input.substring(input.lastIndexOf('.') + 1)).toLowerCase()
40
38
 
41
- const parseBool = input => input.toLowerCase() === 'true'
39
+ const parseBool = (input) => input.toLowerCase() === 'true'
42
40
 
43
41
  for (let i = 0; i < args.length; i++) {
44
42
  if (args[i] === '-of') { // -of <format>
@@ -54,8 +52,6 @@ const parseArgs = args => {
54
52
  params[RegExp.$1] = RegExp.$2
55
53
  } else if (args[i].match(/^--(\w+)$/)) { // params for main()
56
54
  params[RegExp.$1] = args[++i]
57
- } else if (args[i].match(/^--(\w+)$/)) { // params for main()
58
- params[RegExp.$1] = args[++i]
59
55
  } else if (isValidInputFileFormat(args[i])) {
60
56
  inputFile = args[i]
61
57
  inputFormat = getFileExtensionFromString(args[i])
@@ -2,7 +2,7 @@ const fs = require('fs')
2
2
 
3
3
  const writeOutputDataToFile = (outputFile, outputData) => {
4
4
  fs.writeFile(outputFile, outputData.asBuffer(),
5
- function (err) {
5
+ (err) => {
6
6
  if (err) {
7
7
  console.log('err', err)
8
8
  } else {