@jscad/cli 2.3.3 → 2.3.4

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.3.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.3.3...@jscad/cli@2.3.4) (2024-11-10)
7
+
8
+ **Note:** Version bump only for package @jscad/cli
9
+
10
+
11
+
12
+
13
+
6
14
  ## [2.3.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.3.2...@jscad/cli@2.3.3) (2024-10-06)
7
15
 
8
16
  **Note:** Version bump only for package @jscad/cli
@@ -8,19 +8,23 @@ test.afterEach.always((t) => {
8
8
  // remove files
9
9
  try {
10
10
  if (t.context.file1Path) fs.unlinkSync(t.context.file1Path)
11
- } catch (err) {}
11
+ } catch (err) { }
12
12
 
13
13
  try {
14
14
  if (t.context.file2Path) fs.unlinkSync(t.context.file2Path)
15
- } catch (err) {}
15
+ } catch (err) { }
16
16
 
17
17
  try {
18
18
  if (t.context.file3Path) fs.unlinkSync(t.context.file3Path)
19
- } catch (err) {}
19
+ } catch (err) { }
20
20
 
21
21
  try {
22
22
  if (t.context.file4Path) fs.unlinkSync(t.context.file4Path)
23
- } catch (err) {}
23
+ } catch (err) { }
24
+
25
+ try {
26
+ if (t.context.file5Path) fs.unlinkSync(t.context.file5Path)
27
+ } catch (err) { }
24
28
  })
25
29
 
26
30
  test.beforeEach((t) => {
@@ -68,6 +72,56 @@ module.exports = { main, getParameterDefinitions }
68
72
  return filePath
69
73
  }
70
74
 
75
+ const createImportJscad = (id, extension) => {
76
+ const jscadScript = `// test script ${id} -- import
77
+
78
+ const main = () => {
79
+ return require('./test${id}.${extension}')
80
+ }
81
+
82
+ module.exports = { main }
83
+ `
84
+
85
+ const fileName = `./test${id}-import.jscad`
86
+ const filePath = path.resolve(__dirname, fileName)
87
+ fs.writeFileSync(filePath, jscadScript)
88
+ return filePath
89
+ }
90
+
91
+ const testBackImport = (t, testID, extension) => {
92
+ const cliPath = t.context.cliPath
93
+
94
+ const file4Path = createImportJscad(testID, extension)
95
+ t.context.file4Path = file4Path
96
+ t.true(fs.existsSync(file4Path))
97
+
98
+ const file5Name = `./test${testID}-import.stl`
99
+ const file5Path = path.resolve(__dirname, file5Name)
100
+ t.context.file5Path = file5Path
101
+ t.false(fs.existsSync(file5Path))
102
+
103
+ const cmd = `node ${cliPath} ${file4Path}`
104
+ execSync(cmd, { stdio: [0, 1, 2] })
105
+ t.true(fs.existsSync(file5Path))
106
+ }
107
+
108
+ const runOnFixture = (t, fixtureName) => {
109
+ const inputFile = path.resolve(
110
+ __dirname,
111
+ path.join('test_fixtures', fixtureName, 'index.js'))
112
+
113
+ const outputFile = inputFile.replace('.js', '.stl')
114
+ t.context.file1Path = outputFile
115
+
116
+ t.false(fs.existsSync(outputFile))
117
+
118
+ const cmd = `node ${t.context.cliPath} ${inputFile}`
119
+ execSync(cmd, { stdio: [0, 1, 2] })
120
+ t.true(fs.existsSync(outputFile))
121
+
122
+ return outputFile
123
+ }
124
+
71
125
  test('cli (conversions STL)', (t) => {
72
126
  const testID = 11
73
127
 
@@ -99,6 +153,8 @@ test('cli (conversions STL)', (t) => {
99
153
  cmd = `node ${cliPath} ${file2Path} -o ${file3Path} -v -add-metadata false`
100
154
  execSync(cmd, { stdio: [0, 1, 2] })
101
155
  t.true(fs.existsSync(file3Path))
156
+
157
+ testBackImport(t, testID, 'stl')
102
158
  })
103
159
 
104
160
  test('cli (conversions DXF)', (t) => {
@@ -132,6 +188,8 @@ test('cli (conversions DXF)', (t) => {
132
188
  cmd = `node ${cliPath} ${file2Path} -of js`
133
189
  execSync(cmd, { stdio: [0, 1, 2] })
134
190
  t.true(fs.existsSync(file3Path))
191
+
192
+ testBackImport(t, testID, 'dxf')
135
193
  })
136
194
 
137
195
  test('cli (conversions AMF)', (t) => {
@@ -165,6 +223,8 @@ test('cli (conversions AMF)', (t) => {
165
223
  cmd = `node ${cliPath} ${file2Path} -of js`
166
224
  execSync(cmd, { stdio: [0, 1, 2] })
167
225
  t.true(fs.existsSync(file3Path))
226
+
227
+ testBackImport(t, testID, 'amf')
168
228
  })
169
229
 
170
230
  test('cli (conversions JSON)', (t) => {
@@ -198,6 +258,8 @@ test('cli (conversions JSON)', (t) => {
198
258
  cmd = `node ${cliPath} ${file2Path} -of js`
199
259
  execSync(cmd, { stdio: [0, 1, 2] })
200
260
  t.true(fs.existsSync(file3Path))
261
+
262
+ testBackImport(t, testID, 'json')
201
263
  })
202
264
 
203
265
  test('cli (conversions SVG)', (t) => {
@@ -264,4 +326,12 @@ test('cli (conversions X3D)', (t) => {
264
326
  cmd = `node ${cliPath} ${file2Path} -of js`
265
327
  execSync(cmd, { stdio: [0, 1, 2] })
266
328
  t.true(fs.existsSync(file3Path))
329
+
330
+ testBackImport(t, testID, 'x3d')
331
+ })
332
+
333
+ test('cli (import STL)', (t) => {
334
+ // const testID = 17
335
+
336
+ runOnFixture(t, 'stl_import')
267
337
  })
package/cli.js CHANGED
@@ -76,13 +76,13 @@ generateOutputData(src, params, { outputFile, outputFormat, inputFile, inputForm
76
76
  if (err) {
77
77
  console.error(err)
78
78
  } else {
79
- logFileOutput(zipFilename)
79
+ logFileOutput(zipFilename)
80
80
  }
81
81
  })
82
82
  })
83
83
  } else {
84
84
  for (let i = 0; i < outputData.length; i++) {
85
- const filename = outputFile.replace(/\.(\w+)$/, `-part-${i + 1}-of-${outputData.length}.$1`)
85
+ const filename = outputFile.replace(/\.(\w+)$/, `-part-${i + 1}-of-${outputData.length}.$1`)
86
86
  logFileOutput(filename)
87
87
  writeOutput(filename, outputData[i])
88
88
  }
@@ -97,7 +97,7 @@ generateOutputData(src, params, { outputFile, outputFormat, inputFile, inputForm
97
97
  if (err) {
98
98
  console.error(err)
99
99
  } else {
100
- logFileOutput(zipFilename)
100
+ logFileOutput(zipFilename)
101
101
  }
102
102
  })
103
103
  })
@@ -58,7 +58,7 @@ const main = (params) => {
58
58
  let ageom2 = primitives.ellipse()
59
59
  let ageom3 = primitives.ellipsoid()
60
60
 
61
- ${multipart ? `return [ageom3, ageom3, ageom3]` : `return [apath2, ageom2, ageom3]`}
61
+ ${multipart ? 'return [ageom3, ageom3, ageom3]' : 'return [apath2, ageom2, ageom3]'}
62
62
  }
63
63
 
64
64
  module.exports = { main, getParameterDefinitions }
@@ -215,7 +215,6 @@ test('cli (single input file, invalid jscad)', (t) => {
215
215
  })
216
216
  })
217
217
 
218
-
219
218
  test('cli (single input file, multiple output files)', (t) => {
220
219
  const testID = 7
221
220
 
@@ -239,7 +238,7 @@ test('cli (single input file, multiple output files)', (t) => {
239
238
  const cliPath = t.context.cliPath
240
239
 
241
240
  const cmd = `node ${cliPath} ${inputPath} -gp`
242
- execSync(cmd, { stdio: [0,1,2] })
241
+ execSync(cmd, { stdio: [0, 1, 2] })
243
242
  t.true(fs.existsSync(outputPath1))
244
243
  t.true(fs.existsSync(outputPath2))
245
244
  t.true(fs.existsSync(outputPath3))
@@ -257,13 +256,13 @@ test('cli (single multipart input file, zipped output file)', async (t) => {
257
256
  const outputPath = path.resolve(__dirname, outputName)
258
257
 
259
258
  t.false(fs.existsSync(outputPath))
260
-
259
+
261
260
  t.context.outputPath = outputPath
262
261
 
263
262
  const cliPath = t.context.cliPath
264
263
 
265
264
  const cmd = `node ${cliPath} ${inputPath} -gp -z`
266
- execSync(cmd, { stdio: [0,1,2] })
265
+ execSync(cmd, { stdio: [0, 1, 2] })
267
266
  t.true(fs.existsSync(outputPath))
268
267
 
269
268
  // check contents of zip file
@@ -281,18 +280,18 @@ test('cli (single input file, zipped output file)', async (t) => {
281
280
  t.true(fs.existsSync(inputPath))
282
281
 
283
282
  t.context.inputPath = inputPath
284
-
283
+
285
284
  const outputName = `./test${testID}.zip`
286
285
  const outputPath = path.resolve(__dirname, outputName)
287
286
 
288
287
  t.false(fs.existsSync(outputPath))
289
-
288
+
290
289
  t.context.outputPath = outputPath
291
290
 
292
291
  const cliPath = t.context.cliPath
293
292
 
294
293
  const cmd = `node ${cliPath} ${inputPath} -z`
295
- execSync(cmd, { stdio: [0,1,2] })
294
+ execSync(cmd, { stdio: [0, 1, 2] })
296
295
  t.true(fs.existsSync(outputPath))
297
296
 
298
297
  // check contents of zip file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jscad/cli",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "Command Line Interface (CLI) for JSCAD",
5
5
  "homepage": "https://openjscad.xyz/",
6
6
  "repository": "https://github.com/jscad/OpenJSCAD.org",
@@ -36,9 +36,9 @@
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
38
  "@jscad/array-utils": "2.1.4",
39
- "@jscad/core": "2.6.10",
40
- "@jscad/io": "2.4.9",
41
- "@jscad/modeling": "2.12.3",
39
+ "@jscad/core": "2.6.11",
40
+ "@jscad/io": "2.4.10",
41
+ "@jscad/modeling": "2.12.4",
42
42
  "jszip": "^3.10.1"
43
43
  },
44
44
  "devDependencies": {
@@ -50,5 +50,5 @@
50
50
  "url": "https://opencollective.com/openjscad",
51
51
  "logo": "https://opencollective.com/openjscad/logo.txt"
52
52
  },
53
- "gitHead": "4627312c2337120447a607ff3ac3da10056ce132"
53
+ "gitHead": "ce4978ee40c30803cba05d1c96ba8b6aaf3abc61"
54
54
  }
@@ -64,7 +64,7 @@ const generateOutputData = (source, params, options) => {
64
64
  .then((solids) => {
65
65
  const serializerOptions = Object.assign({ format: outputFormat }, params)
66
66
  if (generateParts) {
67
- let blobs = []
67
+ const blobs = []
68
68
  for (let i = 0; i < solids.length; i++) {
69
69
  blobs.push(solidsAsBlob(solids[i], serializerOptions))
70
70
  }
@@ -0,0 +1,4 @@
1
+
2
+ const main = () => require('./binary_stl.stl')
3
+
4
+ module.exports = { main }