@jscad/cli 2.3.0 → 3.0.0-alpha.0

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,514 +3,294 @@
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.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.26...@jscad/cli@2.3.0) (2023-06-27)
6
+ # [3.0.0-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.24...@jscad/cli@3.0.0-alpha.0) (2023-10-09)
7
7
 
8
+ ### Bug Fixes
8
9
 
9
- ### Features
10
+ * **cli:** rework logic for generating blobs, both singular and multiple as parts ([f88669b](https://github.com/jscad/OpenJSCAD.org/commit/f88669b286d9564165f5c33944703fce730dfc1f))
10
11
 
11
- * **cli:** added options to output designs as individual parts, and create zip archive of parts ([a20b9cf](https://github.com/jscad/OpenJSCAD.org/commit/a20b9cf0edaaeca051427372d237af4c3522b04c))
12
+ ### Features
12
13
 
14
+ * **3mf-deserializer:** initial version of 3MF deserializer and tests ([b22a27f](https://github.com/jscad/OpenJSCAD.org/commit/b22a27fa14c4f42b9160553cdd7b3c126ac72459))
15
+ * **cli:** reworked logic to use new io package exports and functions ([#1199](https://github.com/jscad/OpenJSCAD.org/issues/1199)) ([71a3d27](https://github.com/jscad/OpenJSCAD.org/commit/71a3d27a4cf416b1a9fea57a1fe40f5cfdaa905c))
16
+ * **modeling:** reworked exports to expose a flattened API ([8235238](https://github.com/jscad/OpenJSCAD.org/commit/8235238ad63d063f1e501478cae1208deb130a9c))
17
+ * **regl-renderer:** added rollup configuration to create ES6 bundle, adjusted imports and exports ([#1259](https://github.com/jscad/OpenJSCAD.org/issues/1259)) ([47a66bc](https://github.com/jscad/OpenJSCAD.org/commit/47a66bc07a137a748ce8571ea5d043ebaab9418d))
13
18
 
19
+ # [2.3.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.26...@jscad/cli@2.3.0) (2023-06-27)
14
20
 
21
+ ### Features
15
22
 
23
+ * **cli:** added options to output designs as individual parts, and create zip archive of parts ([a20b9cf](https://github.com/jscad/OpenJSCAD.org/commit/a20b9cf0edaaeca051427372d237af4c3522b04c))
16
24
 
17
25
  ## [2.2.26](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.25...@jscad/cli@2.2.26) (2023-04-30)
18
26
 
19
-
20
27
  ### Bug Fixes
21
28
 
22
29
  * **cli:** corrected CLI help messages ([ba66b6c](https://github.com/jscad/OpenJSCAD.org/commit/ba66b6c855e253a520b2b4b151cf76228204139a))
23
30
 
24
-
25
-
26
-
27
-
28
31
  ## [2.2.25](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.24...@jscad/cli@2.2.25) (2022-11-26)
29
32
 
30
33
  **Note:** Version bump only for package @jscad/cli
31
34
 
32
-
33
-
34
-
35
-
36
35
  ## [2.2.24](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.23...@jscad/cli@2.2.24) (2022-09-23)
37
36
 
38
37
  **Note:** Version bump only for package @jscad/cli
39
38
 
40
-
41
-
42
-
43
-
44
39
  ## [2.2.23](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.22...@jscad/cli@2.2.23) (2022-08-21)
45
40
 
46
41
  **Note:** Version bump only for package @jscad/cli
47
42
 
48
-
49
-
50
-
51
-
52
43
  ## [2.2.22](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.21...@jscad/cli@2.2.22) (2022-07-17)
53
44
 
54
45
  **Note:** Version bump only for package @jscad/cli
55
46
 
56
-
57
-
58
-
59
-
60
47
  ## [2.2.21](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.20...@jscad/cli@2.2.21) (2022-06-12)
61
48
 
62
49
  **Note:** Version bump only for package @jscad/cli
63
50
 
64
-
65
-
66
-
67
-
68
51
  ## [2.2.20](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.19...@jscad/cli@2.2.20) (2022-05-15)
69
52
 
70
53
  **Note:** Version bump only for package @jscad/cli
71
54
 
72
-
73
-
74
-
75
-
76
55
  ## [2.2.19](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.18...@jscad/cli@2.2.19) (2022-04-24)
77
56
 
78
57
  **Note:** Version bump only for package @jscad/cli
79
58
 
80
-
81
-
82
-
83
-
84
59
  ## [2.2.18](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.17...@jscad/cli@2.2.18) (2022-04-03)
85
60
 
86
61
  **Note:** Version bump only for package @jscad/cli
87
62
 
88
-
89
-
90
-
91
-
92
63
  ## [2.2.17](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.16...@jscad/cli@2.2.17) (2022-04-03)
93
64
 
94
65
  **Note:** Version bump only for package @jscad/cli
95
66
 
96
-
97
-
98
-
99
-
100
67
  ## [2.2.16](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.15...@jscad/cli@2.2.16) (2022-03-13)
101
68
 
102
69
  **Note:** Version bump only for package @jscad/cli
103
70
 
104
-
105
-
106
-
107
-
108
71
  ## [2.2.15](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.14...@jscad/cli@2.2.15) (2022-03-06)
109
72
 
110
73
  **Note:** Version bump only for package @jscad/cli
111
74
 
112
-
113
-
114
-
115
-
116
75
  ## [2.2.14](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.13...@jscad/cli@2.2.14) (2022-02-19)
117
76
 
118
77
  **Note:** Version bump only for package @jscad/cli
119
78
 
120
-
121
-
122
-
123
-
124
79
  ## [2.2.13](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.12...@jscad/cli@2.2.13) (2022-01-23)
125
80
 
126
81
  **Note:** Version bump only for package @jscad/cli
127
82
 
128
-
129
-
130
-
131
-
132
83
  ## [2.2.12](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.11...@jscad/cli@2.2.12) (2021-12-26)
133
84
 
134
85
  **Note:** Version bump only for package @jscad/cli
135
86
 
136
-
137
-
138
-
139
-
140
87
  ## [2.2.11](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.10...@jscad/cli@2.2.11) (2021-12-11)
141
88
 
142
89
  **Note:** Version bump only for package @jscad/cli
143
90
 
144
-
145
-
146
-
147
-
148
91
  ## [2.2.10](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.9...@jscad/cli@2.2.10) (2021-11-07)
149
92
 
150
93
  **Note:** Version bump only for package @jscad/cli
151
94
 
152
-
153
-
154
-
155
-
156
95
  ## [2.2.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.8...@jscad/cli@2.2.9) (2021-10-17)
157
96
 
158
-
159
97
  ### Bug Fixes
160
98
 
161
99
  * **cli:** corrected cli to exit with non-zero code in case of errors ([#931](https://github.com/jscad/OpenJSCAD.org/issues/931)) ([e66a285](https://github.com/jscad/OpenJSCAD.org/commit/e66a2851693397d2d667f7d64aef7a4f52282d80))
162
100
  * **cli:** corrected generateOutputData to use registered deserializers from IO module, and added conversion tests ([ac7cba7](https://github.com/jscad/OpenJSCAD.org/commit/ac7cba7547c75e6d7cfc9fb680eba347d7f6a7ae))
163
101
 
164
-
165
-
166
-
167
-
168
102
  ## [2.2.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.7...@jscad/cli@2.2.8) (2021-10-04)
169
103
 
170
104
  **Note:** Version bump only for package @jscad/cli
171
105
 
172
-
173
-
174
-
175
-
176
106
  ## [2.2.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.6...@jscad/cli@2.2.7) (2021-09-27)
177
107
 
178
108
  **Note:** Version bump only for package @jscad/cli
179
109
 
180
-
181
-
182
-
183
-
184
110
  ## [2.2.6](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.5...@jscad/cli@2.2.6) (2021-09-09)
185
111
 
186
-
187
112
  ### Bug Fixes
188
113
 
189
114
  * **web:** added open issues and discord community to help ([4ea1196](https://github.com/jscad/OpenJSCAD.org/commit/4ea11966af4b3ecbb5c1a3d53b7ac90c4cd349b1))
190
115
 
191
-
192
-
193
-
194
-
195
116
  ## [2.2.5](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.4...@jscad/cli@2.2.5) (2021-06-20)
196
117
 
197
118
  **Note:** Version bump only for package @jscad/cli
198
119
 
199
-
200
-
201
-
202
-
203
120
  ## [2.2.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.3...@jscad/cli@2.2.4) (2021-06-11)
204
121
 
205
-
206
122
  ### Bug Fixes
207
123
 
208
124
  * **cli:** corrected assembly of options for serialization and deserialization ([8445254](https://github.com/jscad/OpenJSCAD.org/commit/8445254824a81ffd7e65ba5ab20d38cf4dcc1708))
209
125
 
210
-
211
-
212
-
213
-
214
126
  ## [2.2.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.2...@jscad/cli@2.2.3) (2021-06-01)
215
127
 
216
128
  **Note:** Version bump only for package @jscad/cli
217
129
 
218
-
219
-
220
-
221
-
222
130
  ## [2.2.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.1...@jscad/cli@2.2.2) (2021-05-16)
223
131
 
224
132
  **Note:** Version bump only for package @jscad/cli
225
133
 
226
-
227
-
228
-
229
-
230
134
  ## [2.2.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.2.0...@jscad/cli@2.2.1) (2021-05-07)
231
135
 
232
136
  **Note:** Version bump only for package @jscad/cli
233
137
 
234
-
235
-
236
-
237
-
238
138
  # [2.2.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.1.1...@jscad/cli@2.2.0) (2021-04-20)
239
139
 
240
-
241
140
  ### Features
242
141
 
243
142
  * **cli:** added array-utils to dependencies, enhanced test suite ([d631fc5](https://github.com/jscad/OpenJSCAD.org/commit/d631fc5842653b21fa94de3c6afd9ad8daaa951a))
244
143
 
245
-
246
-
247
-
248
-
249
144
  ## [2.1.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.1.0...@jscad/cli@2.1.1) (2021-04-17)
250
145
 
251
146
  **Note:** Version bump only for package @jscad/cli
252
147
 
253
-
254
-
255
-
256
-
257
148
  # [2.1.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.0...@jscad/cli@2.1.0) (2021-04-15)
258
149
 
259
-
260
150
  ### Bug Fixes
261
151
 
262
152
  * **all:** fix json import ([#675](https://github.com/jscad/OpenJSCAD.org/issues/675)) ([05caf60](https://github.com/jscad/OpenJSCAD.org/commit/05caf60efc3f090313b3e0bddcc0b4f94de67c78))
263
153
  * **all:** V2 : several fixes for modeling ([#705](https://github.com/jscad/OpenJSCAD.org/issues/705)) ([62017a4](https://github.com/jscad/OpenJSCAD.org/commit/62017a41214169d6e000f1e0c11aaefdd68e1097))
264
154
 
265
-
266
155
  ### Features
267
156
 
268
157
  * **core:** V2 : Fix core packaging ([#720](https://github.com/jscad/OpenJSCAD.org/issues/720)) ([e19c10c](https://github.com/jscad/OpenJSCAD.org/commit/e19c10c6d1a8f2b4f15a0b81144be8439095e02f))
269
158
 
270
-
271
-
272
-
273
-
274
159
  # [2.0.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.14...@jscad/cli@2.0.0) (2021-04-12)
275
160
 
276
161
  **Note:** Version bump only for package @jscad/cli
277
162
 
278
-
279
-
280
-
281
-
282
163
  # [2.0.0-alpha.14](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.13...@jscad/cli@2.0.0-alpha.14) (2021-03-07)
283
164
 
284
165
  **Note:** Version bump only for package @jscad/cli
285
166
 
286
-
287
-
288
-
289
-
290
167
  # [2.0.0-alpha.13](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.12...@jscad/cli@2.0.0-alpha.13) (2021-02-07)
291
168
 
292
169
  **Note:** Version bump only for package @jscad/cli
293
170
 
294
-
295
-
296
-
297
-
298
171
  # [2.0.0-alpha.12](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.11...@jscad/cli@2.0.0-alpha.12) (2021-01-02)
299
172
 
300
173
  **Note:** Version bump only for package @jscad/cli
301
174
 
302
-
303
-
304
-
305
-
306
175
  # [2.0.0-alpha.11](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.10...@jscad/cli@2.0.0-alpha.11) (2020-12-04)
307
176
 
308
177
  **Note:** Version bump only for package @jscad/cli
309
178
 
310
-
311
-
312
-
313
-
314
179
  # [2.0.0-alpha.10](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.9...@jscad/cli@2.0.0-alpha.10) (2020-11-07)
315
180
 
316
-
317
181
  ### Features
318
182
 
319
183
  * **core:** V2 : Fix core packaging ([#720](https://github.com/jscad/OpenJSCAD.org/issues/720)) ([e19c10c](https://github.com/jscad/OpenJSCAD.org/commit/e19c10c6d1a8f2b4f15a0b81144be8439095e02f))
320
184
 
321
-
322
-
323
-
324
-
325
185
  # [2.0.0-alpha.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.8...@jscad/cli@2.0.0-alpha.9) (2020-10-24)
326
186
 
327
187
  **Note:** Version bump only for package @jscad/cli
328
188
 
329
-
330
-
331
-
332
-
333
189
  # [2.0.0-alpha.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.7...@jscad/cli@2.0.0-alpha.8) (2020-10-11)
334
190
 
335
-
336
191
  ### Bug Fixes
337
192
 
338
193
  * **all:** V2 : several fixes for modeling ([#705](https://github.com/jscad/OpenJSCAD.org/issues/705)) ([62017a4](https://github.com/jscad/OpenJSCAD.org/commit/62017a41214169d6e000f1e0c11aaefdd68e1097))
339
194
 
340
-
341
-
342
-
343
-
344
195
  # [2.0.0-alpha.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.6...@jscad/cli@2.0.0-alpha.7) (2020-09-29)
345
196
 
346
197
  **Note:** Version bump only for package @jscad/cli
347
198
 
348
-
349
-
350
-
351
-
352
199
  # [2.0.0-alpha.6](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.5...@jscad/cli@2.0.0-alpha.6) (2020-09-28)
353
200
 
354
201
  **Note:** Version bump only for package @jscad/cli
355
202
 
356
-
357
-
358
-
359
-
360
203
  # [2.0.0-alpha.5](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.4...@jscad/cli@2.0.0-alpha.5) (2020-09-19)
361
204
 
362
-
363
205
  ### Bug Fixes
364
206
 
365
207
  * **all:** fix json import ([#675](https://github.com/jscad/OpenJSCAD.org/issues/675)) ([05caf60](https://github.com/jscad/OpenJSCAD.org/commit/05caf60efc3f090313b3e0bddcc0b4f94de67c78))
366
208
 
367
-
368
-
369
-
370
-
371
209
  # [2.0.0-alpha.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.3...@jscad/cli@2.0.0-alpha.4) (2020-09-08)
372
210
 
373
211
  **Note:** Version bump only for package @jscad/cli
374
212
 
375
-
376
-
377
-
378
-
379
213
  # [2.0.0-alpha.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.2...@jscad/cli@2.0.0-alpha.3) (2020-09-02)
380
214
 
381
215
  **Note:** Version bump only for package @jscad/cli
382
216
 
383
-
384
-
385
-
386
-
387
217
  # [2.0.0-alpha.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.1...@jscad/cli@2.0.0-alpha.2) (2020-08-24)
388
218
 
389
219
  **Note:** Version bump only for package @jscad/cli
390
220
 
391
-
392
-
393
-
394
-
395
221
  # [2.0.0-alpha.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.0.0-alpha.0...@jscad/cli@2.0.0-alpha.1) (2020-08-19)
396
222
 
397
223
  **Note:** Version bump only for package @jscad/cli
398
224
 
399
-
400
-
401
-
402
-
403
225
  # [2.0.0-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@1.10.0...@jscad/cli@2.0.0-alpha.0) (2020-08-13)
404
226
 
405
-
406
227
  ### Bug Fixes
407
228
 
408
229
  * **cli:** fix rebuild geometry for cli ([#583](https://github.com/jscad/OpenJSCAD.org/issues/583)) ([828394d](https://github.com/jscad/OpenJSCAD.org/commit/828394ddb88fc1139b1daf155548aa9fab7de823))
409
230
  * **cli:** improved/ added missing formats handling to CLI ([#494](https://github.com/jscad/OpenJSCAD.org/issues/494)) ([caaab97](https://github.com/jscad/OpenJSCAD.org/commit/caaab9765e4d286f740067075a8284fec3e77c39))
410
231
 
411
-
412
232
  ### Features
413
233
 
414
234
  * Overhaul and V2 groundwork ([#382](https://github.com/jscad/OpenJSCAD.org/issues/382)) ([5e66632](https://github.com/jscad/OpenJSCAD.org/commit/5e666327a8b50a7fa6baa4bbdfd790d243f8064f))
415
235
 
416
-
417
-
418
-
419
-
420
236
  <a name="1.10.0"></a>
421
237
  # [1.10.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@1.9.0...@jscad/cli@1.10.0) (2019-01-04)
422
238
 
423
-
424
239
  ### Features
425
240
 
426
241
  * **web:** add standalone umd / embeddable version ([#413](https://github.com/jscad/OpenJSCAD.org/issues/413)) ([f25d8c0](https://github.com/jscad/OpenJSCAD.org/commit/f25d8c0)), closes [#402](https://github.com/jscad/OpenJSCAD.org/issues/402) [#343](https://github.com/jscad/OpenJSCAD.org/issues/343)
427
242
 
428
-
429
-
430
-
431
243
  <a name="1.9.0"></a>
432
244
  # [1.9.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@1.8.4...@jscad/cli@1.9.0) (2018-09-02)
433
245
 
434
-
435
246
  ### Features
436
247
 
437
248
  * **io:** add updated dependencies: enable csg to dxf ([#394](https://github.com/jscad/OpenJSCAD.org/issues/394)) ([1144a78](https://github.com/jscad/OpenJSCAD.org/commit/1144a78))
438
249
 
439
-
440
-
441
-
442
250
  <a name="1.8.4"></a>
443
251
  ## [1.8.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@1.8.3...@jscad/cli@1.8.4) (2018-05-12)
444
252
 
445
-
446
-
447
-
448
253
  **Note:** Version bump only for package @jscad/cli
449
254
 
450
255
  <a name="1.8.3"></a>
451
256
  ## [1.8.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@1.8.2...@jscad/cli@1.8.3) (2018-04-07)
452
257
 
453
-
454
258
  ### Bug Fixes
455
259
 
456
260
  * **dxf-serializer:** updated [@jscad](https://github.com/jscad)/io dependency version for dxf-serializer fixes ([#369](https://github.com/jscad/OpenJSCAD.org/issues/369)) ([fadae24](https://github.com/jscad/OpenJSCAD.org/commit/fadae24))
457
261
 
458
-
459
-
460
-
461
262
  <a name="1.8.2"></a>
462
263
  ## [1.8.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@1.8.1...@jscad/cli@1.8.2) (2018-04-07)
463
264
 
464
-
465
-
466
-
467
265
  **Note:** Version bump only for package @jscad/cli
468
266
 
469
267
  <a name="1.8.1"></a>
470
268
  ## [1.8.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@1.8.0...@jscad/cli@1.8.1) (2018-04-02)
471
269
 
472
-
473
270
  ### Bug Fixes
474
271
 
475
272
  * **svg-serializer:** updated [@jscad](https://github.com/jscad)/io for fix of broken svg export([#365](https://github.com/jscad/OpenJSCAD.org/issues/365)) ([d4ad54c](https://github.com/jscad/OpenJSCAD.org/commit/d4ad54c))
476
273
 
477
-
478
-
479
-
480
274
  <a name="1.8.0"></a>
481
275
  # [1.8.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@1.7.0...@jscad/cli@1.8.0) (2018-03-10)
482
276
 
483
-
484
277
  ### Features
485
278
 
486
279
  * **dxf input support:** add support of dxf files as inputs ([#361](https://github.com/jscad/OpenJSCAD.org/issues/361)) ([bfd2835](https://github.com/jscad/OpenJSCAD.org/commit/bfd2835))
487
280
 
488
-
489
-
490
-
491
281
  <a name="1.7.0"></a>
492
282
  # [1.7.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@1.6.3...@jscad/cli@1.7.0) (2018-03-09)
493
283
 
494
-
495
284
  ### Features
496
285
 
497
286
  * **modules support:** add node.js modules support to cli ([#360](https://github.com/jscad/OpenJSCAD.org/issues/360)) ([74a8b5e](https://github.com/jscad/OpenJSCAD.org/commit/74a8b5e)), closes [#356](https://github.com/jscad/OpenJSCAD.org/issues/356)
498
287
 
499
-
500
-
501
-
502
288
  <a name="1.6.3"></a>
503
289
  ## [1.6.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@1.6.2...@jscad/cli@1.6.3) (2018-02-13)
504
290
 
505
-
506
-
507
-
508
291
  **Note:** Version bump only for package @jscad/cli
509
292
 
510
293
  <a name="1.6.2"></a>
511
294
  ## 1.6.2 (2018-02-13)
512
295
 
513
-
514
-
515
-
516
296
  **Note:** Version bump only for package @jscad/cli
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![License](https://img.shields.io/github/license/jscad/OpenJSCAD.org)](https://github.com/jscad/OpenJSCAD.org/blob/master/LICENSE)
10
10
 
11
11
  [![User Group](https://img.shields.io/badge/maintained%20by-user%20group-blue)](https://openjscad.nodebb.com/)
12
- [![Lerna](https://img.shields.io/badge/maintained%20with-lerna-blue)](https://lerna.js.org/)
12
+ [![lerna--lite](https://img.shields.io/badge/maintained%20with-lerna--lite-e137ff)](https://github.com/ghiscoding/lerna-lite)
13
13
  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-blue)](https://standardjs.com)
14
14
 
15
15
  [![Backers](https://img.shields.io/opencollective/backers/openjscad)](https://opencollective.com/openjscad)
@@ -1,8 +1,10 @@
1
- const test = require('ava')
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+ import { cwd } from 'process'
2
4
 
3
- const path = require('path')
4
- const { execSync } = require('child_process')
5
- const fs = require('fs')
5
+ import test from 'ava'
6
+
7
+ import { execSync } from 'child_process'
6
8
 
7
9
  test.afterEach.always((t) => {
8
10
  // remove files
@@ -26,7 +28,7 @@ test.afterEach.always((t) => {
26
28
  test.beforeEach((t) => {
27
29
  const cliName = './cli.js'
28
30
  t.context = {
29
- cliPath: path.resolve(__dirname, cliName)
31
+ cliPath: path.resolve(cwd(), cliName)
30
32
  }
31
33
  })
32
34
 
@@ -38,32 +40,30 @@ test.beforeEach((t) => {
38
40
  // the script should produce ALL geometry types
39
41
  const createJscad = (id) => {
40
42
  const jscadScript = `// test script ${id}
41
- const { flatten } = require('@jscad/array-utils')
42
- const { primitives } = require('@jscad/modeling')
43
+ import { flatten } from '@jscad/array-utils'
44
+ import { arc, ellipse, ellipsoid } from '@jscad/modeling'
43
45
 
44
- const getParameterDefinitions = () => {
46
+ export const getParameterDefinitions = () => {
45
47
  return flatten([
46
48
  { name: 'segments', caption: 'Segements:', type: 'int', initial: 10, min: 5, max: 20, step: 1 }
47
49
  ])
48
50
  }
49
51
 
50
- const main = (params) => {
52
+ export const main = (params) => {
51
53
  // parameters
52
54
  let segments = params.segments || 16
53
55
 
54
56
  // shapes
55
- let apath2 = primitives.arc()
56
- let ageom2 = primitives.ellipse()
57
- let ageom3 = primitives.ellipsoid()
57
+ let apath2 = arc()
58
+ let ageom2 = ellipse()
59
+ let ageom3 = ellipsoid()
58
60
 
59
61
  return [apath2, ageom2, ageom3]
60
62
  }
61
-
62
- module.exports = { main, getParameterDefinitions }
63
63
  `
64
64
 
65
- const fileName = `./test${id}.jscad`
66
- const filePath = path.resolve(__dirname, fileName)
65
+ const fileName = `./base${id}.js`
66
+ const filePath = path.resolve(cwd(), fileName)
67
67
  fs.writeFileSync(filePath, jscadScript)
68
68
  return filePath
69
69
  }
@@ -78,20 +78,20 @@ test('cli (conversions STL)', (t) => {
78
78
  t.context.file1Path = file1Path
79
79
 
80
80
  const file2Name = `./test${testID}.stl`
81
- const file2Path = path.resolve(__dirname, file2Name)
81
+ const file2Path = path.resolve(cwd(), file2Name)
82
82
  t.false(fs.existsSync(file2Path))
83
83
 
84
84
  t.context.file2Path = file2Path
85
85
 
86
86
  const cliPath = t.context.cliPath
87
87
 
88
- let cmd = `node ${cliPath} ${file1Path}`
88
+ let cmd = `node ${cliPath} ${file1Path} -o ${file2Path}`
89
89
  execSync(cmd, { stdio: [0, 1, 2] })
90
90
  t.true(fs.existsSync(file2Path))
91
91
 
92
92
  // convert from STL to JSCAD script
93
93
  const file3Name = `./test${testID}.js`
94
- const file3Path = path.resolve(__dirname, file3Name)
94
+ const file3Path = path.resolve(cwd(), file3Name)
95
95
  t.false(fs.existsSync(file3Path))
96
96
 
97
97
  t.context.file3Path = file3Path
@@ -111,53 +111,20 @@ test('cli (conversions DXF)', (t) => {
111
111
  t.context.file1Path = file1Path
112
112
 
113
113
  const file2Name = `./test${testID}.dxf`
114
- const file2Path = path.resolve(__dirname, file2Name)
114
+ const file2Path = path.resolve(cwd(), file2Name)
115
115
  t.false(fs.existsSync(file2Path))
116
116
 
117
117
  t.context.file2Path = file2Path
118
118
 
119
119
  const cliPath = t.context.cliPath
120
120
 
121
- let cmd = `node ${cliPath} ${file1Path} -of dxf`
121
+ let cmd = `node ${cliPath} ${file1Path} -o ${file2Path}`
122
122
  execSync(cmd, { stdio: [0, 1, 2] })
123
123
  t.true(fs.existsSync(file2Path))
124
124
 
125
125
  // convert from DXF to JS
126
126
  const file3Name = `./test${testID}.js`
127
- const file3Path = path.resolve(__dirname, file3Name)
128
- t.false(fs.existsSync(file3Path))
129
-
130
- t.context.file3Path = file3Path
131
-
132
- cmd = `node ${cliPath} ${file2Path} -of js`
133
- execSync(cmd, { stdio: [0, 1, 2] })
134
- t.true(fs.existsSync(file3Path))
135
- })
136
-
137
- test('cli (conversions AMF)', (t) => {
138
- const testID = 13
139
-
140
- // convert from JSCAD to AMF
141
- const file1Path = createJscad(testID)
142
- t.true(fs.existsSync(file1Path))
143
-
144
- t.context.file1Path = file1Path
145
-
146
- const file2Name = `./test${testID}.amf`
147
- const file2Path = path.resolve(__dirname, file2Name)
148
- t.false(fs.existsSync(file2Path))
149
-
150
- t.context.file2Path = file2Path
151
-
152
- const cliPath = t.context.cliPath
153
-
154
- let cmd = `node ${cliPath} ${file1Path} -of amf`
155
- execSync(cmd, { stdio: [0, 1, 2] })
156
- t.true(fs.existsSync(file2Path))
157
-
158
- // convert from AMF to JS
159
- const file3Name = `./test${testID}.js`
160
- const file3Path = path.resolve(__dirname, file3Name)
127
+ const file3Path = path.resolve(cwd(), file3Name)
161
128
  t.false(fs.existsSync(file3Path))
162
129
 
163
130
  t.context.file3Path = file3Path
@@ -177,20 +144,20 @@ test('cli (conversions JSON)', (t) => {
177
144
  t.context.file1Path = file1Path
178
145
 
179
146
  const file2Name = `./test${testID}.json`
180
- const file2Path = path.resolve(__dirname, file2Name)
147
+ const file2Path = path.resolve(cwd(), file2Name)
181
148
  t.false(fs.existsSync(file2Path))
182
149
 
183
150
  t.context.file2Path = file2Path
184
151
 
185
152
  const cliPath = t.context.cliPath
186
153
 
187
- let cmd = `node ${cliPath} ${file1Path} -of json`
154
+ let cmd = `node ${cliPath} ${file1Path} -o ${file2Path}`
188
155
  execSync(cmd, { stdio: [0, 1, 2] })
189
156
  t.true(fs.existsSync(file2Path))
190
157
 
191
158
  // convert from JSON to JS
192
159
  const file3Name = `./test${testID}.js`
193
- const file3Path = path.resolve(__dirname, file3Name)
160
+ const file3Path = path.resolve(cwd(), file3Name)
194
161
  t.false(fs.existsSync(file3Path))
195
162
 
196
163
  t.context.file3Path = file3Path
@@ -210,20 +177,20 @@ test('cli (conversions SVG)', (t) => {
210
177
  t.context.file1Path = file1Path
211
178
 
212
179
  const file2Name = `./test${testID}.svg`
213
- const file2Path = path.resolve(__dirname, file2Name)
180
+ const file2Path = path.resolve(cwd(), file2Name)
214
181
  t.false(fs.existsSync(file2Path))
215
182
 
216
183
  t.context.file2Path = file2Path
217
184
 
218
185
  const cliPath = t.context.cliPath
219
186
 
220
- let cmd = `node ${cliPath} ${file1Path} -of svg`
187
+ let cmd = `node ${cliPath} ${file1Path} -o ${file2Path}`
221
188
  execSync(cmd, { stdio: [0, 1, 2] })
222
189
  t.true(fs.existsSync(file2Path))
223
190
 
224
191
  // convert from SVG to JS
225
192
  const file3Name = `./test${testID}.js`
226
- const file3Path = path.resolve(__dirname, file3Name)
193
+ const file3Path = path.resolve(cwd(), file3Name)
227
194
  t.false(fs.existsSync(file3Path))
228
195
 
229
196
  t.context.file3Path = file3Path
@@ -243,20 +210,20 @@ test('cli (conversions X3D)', (t) => {
243
210
  t.context.file1Path = file1Path
244
211
 
245
212
  const file2Name = `./test${testID}.x3d`
246
- const file2Path = path.resolve(__dirname, file2Name)
213
+ const file2Path = path.resolve(cwd(), file2Name)
247
214
  t.false(fs.existsSync(file2Path))
248
215
 
249
216
  t.context.file2Path = file2Path
250
217
 
251
218
  const cliPath = t.context.cliPath
252
219
 
253
- let cmd = `node ${cliPath} ${file1Path} -of x3d`
220
+ let cmd = `node ${cliPath} ${file1Path} -o ${file2Path}`
254
221
  execSync(cmd, { stdio: [0, 1, 2] })
255
222
  t.true(fs.existsSync(file2Path))
256
223
 
257
224
  // convert from X3D to JS
258
225
  const file3Name = `./test${testID}.js`
259
- const file3Path = path.resolve(__dirname, file3Name)
226
+ const file3Path = path.resolve(cwd(), file3Name)
260
227
  t.false(fs.existsSync(file3Path))
261
228
 
262
229
  t.context.file3Path = file3Path
package/cli.js CHANGED
@@ -21,16 +21,17 @@
21
21
  // jscad test.jscad -of stl
22
22
  // jscad name_plate.jscad --name "Just Me" --title "CEO" -o amf test.amf
23
23
  //
24
- const fs = require('fs')
25
- const JSZip = require('jszip')
24
+ import fs from 'fs'
25
+ import JSZip from 'jszip'
26
26
 
27
- const { formats } = require('@jscad/io/formats')
27
+ import { supportedFormats } from '@jscad/io'
28
28
 
29
- const version = require('./package.json').version
30
- const generateOutputData = require('./src/generateOutputData')
31
- const determineOutputNameAndFormat = require('./src/determineOutputNameAndFormat')
32
- const writeOutput = require('./src/writeOutput')
33
- const parseArgs = require('./src/parseArgs')
29
+ import { generateOutputData } from './src/generateOutputData.js'
30
+ import { determineOutputNameAndFormat } from './src/determineOutputNameAndFormat.js'
31
+ import { writeOutput } from './src/writeOutput.js'
32
+ import { parseArgs } from './src/parseArgs.js'
33
+
34
+ const version = '[VI]{version}[/VI]' // version is injected by rollup
34
35
 
35
36
  // handle arguments (inputs, outputs, etc)
36
37
  const args = process.argv.splice(2)
@@ -52,12 +53,16 @@ const clicolors = {
52
53
  const logFileOutput = (outputFile) => {
53
54
  console.log(`${clicolors.blue}JSCAD: generating output ${clicolors.red}
54
55
  from: ${clicolors.green} ${inputFile} ${clicolors.red}
55
- to: ${clicolors.green} ${outputFile} ${clicolors.yellow}(${formats[outputFormat].description}) ${clicolors.black}
56
+ to: ${clicolors.green} ${outputFile} ${clicolors.yellow}(${supportedFormats[outputFormat].description}) ${clicolors.black}
56
57
  `)
57
58
  }
58
59
 
59
60
  // read input data
60
- const src = fs.readFileSync(inputFile, inputFile.match(/\.stl$/i) ? 'binary' : 'UTF8')
61
+ let encoding = 'UTF8'
62
+ if (inputFile.match(/\.stl$/i)) encoding = 'binary'
63
+ if (inputFile.match(/\.3mf$/i)) encoding = null // force raw buffer
64
+
65
+ const src = fs.readFileSync(inputFile, encoding)
61
66
 
62
67
  // -- convert from JSCAD script into the desired output format
63
68
  // -- and write it to disk
@@ -76,13 +81,13 @@ generateOutputData(src, params, { outputFile, outputFormat, inputFile, inputForm
76
81
  if (err) {
77
82
  console.error(err)
78
83
  } else {
79
- logFileOutput(zipFilename)
84
+ logFileOutput(zipFilename)
80
85
  }
81
86
  })
82
87
  })
83
88
  } else {
84
89
  for (let i = 0; i < outputData.length; i++) {
85
- const filename = outputFile.replace(/\.(\w+)$/, `-part-${i + 1}-of-${outputData.length}.$1`)
90
+ const filename = outputFile.replace(/\.(\w+)$/, `-part-${i + 1}-of-${outputData.length}.$1`)
86
91
  logFileOutput(filename)
87
92
  writeOutput(filename, outputData[i])
88
93
  }
@@ -97,7 +102,7 @@ generateOutputData(src, params, { outputFile, outputFormat, inputFile, inputForm
97
102
  if (err) {
98
103
  console.error(err)
99
104
  } else {
100
- logFileOutput(zipFilename)
105
+ logFileOutput(zipFilename)
101
106
  }
102
107
  })
103
108
  })
@@ -1,9 +1,15 @@
1
- const test = require('ava')
2
- const JSZip = require('jszip')
1
+ import fs from 'fs'
2
+ import { dirname, resolve } from 'path'
3
+ import { execSync } from 'child_process'
4
+ import { cwd } from 'process'
5
+ import { fileURLToPath } from 'url'
3
6
 
4
- const path = require('path')
5
- const { execSync } = require('child_process')
6
- const fs = require('fs')
7
+ import JSZip from 'jszip'
8
+
9
+ import test from 'ava'
10
+
11
+ const __filename = fileURLToPath(import.meta.url)
12
+ const __dirname = dirname(__filename)
7
13
 
8
14
  test.afterEach.always((t) => {
9
15
  // remove files
@@ -29,7 +35,7 @@ test.afterEach.always((t) => {
29
35
  test.beforeEach((t) => {
30
36
  const cliName = './cli.js'
31
37
  t.context = {
32
- cliPath: path.resolve(__dirname, cliName)
38
+ cliPath: resolve(cwd(), cliName)
33
39
  }
34
40
  })
35
41
 
@@ -41,31 +47,29 @@ test.beforeEach((t) => {
41
47
  // the script should produce ALL geometry types
42
48
  const createJscad = (id, multipart = false) => {
43
49
  const jscadScript = `// test script ${id}
44
- const { primitives } = require('@jscad/modeling')
50
+ import { arc, ellipse, ellipsoid } from '@jscad/modeling'
45
51
 
46
- const getParameterDefinitions = () => {
52
+ export const getParameterDefinitions = () => {
47
53
  return [
48
- { name: 'segments', caption: 'Segements:', type: 'int', initial: 10, min: 5, max: 20, step: 1 }
54
+ { name: 'segments', caption: 'Segments:', type: 'int', initial: 10, min: 5, max: 20, step: 1 }
49
55
  ]
50
56
  }
51
57
 
52
- const main = (params) => {
58
+ export const main = (params) => {
53
59
  // parameters
54
60
  let segments = params.segments || 16
55
61
 
56
62
  // shapes
57
- let apath2 = primitives.arc()
58
- let ageom2 = primitives.ellipse()
59
- let ageom3 = primitives.ellipsoid()
63
+ let apath2 = arc()
64
+ let ageom2 = ellipse()
65
+ let ageom3 = ellipsoid()
60
66
 
61
- ${multipart ? `return [ageom3, ageom3, ageom3]` : `return [apath2, ageom2, ageom3]`}
67
+ ${multipart ? 'return [ageom3, ageom3, ageom3]' : 'return [apath2, ageom2, ageom3]'}
62
68
  }
63
-
64
- module.exports = { main, getParameterDefinitions }
65
69
  `
66
70
 
67
- const fileName = `./test${id}.jscad`
68
- const filePath = path.resolve(__dirname, fileName)
71
+ const fileName = `./test${id}.js`
72
+ const filePath = resolve(cwd(), fileName)
69
73
  fs.writeFileSync(filePath, jscadScript)
70
74
  return filePath
71
75
  }
@@ -79,7 +83,7 @@ test('cli (single input file)', (t) => {
79
83
  t.context.inputPath = inputPath
80
84
 
81
85
  const outputName = `./test${testID}.stl`
82
- const outputPath = path.resolve(__dirname, outputName)
86
+ const outputPath = resolve(cwd(), outputName)
83
87
  t.false(fs.existsSync(outputPath))
84
88
 
85
89
  t.context.outputPath = outputPath
@@ -100,7 +104,7 @@ test('cli (single input file, output format)', (t) => {
100
104
  t.context.inputPath = inputPath
101
105
 
102
106
  const outputName = `./test${testID}.dxf`
103
- const outputPath = path.resolve(__dirname, outputName)
107
+ const outputPath = resolve(cwd(), outputName)
104
108
  t.false(fs.existsSync(outputPath))
105
109
 
106
110
  t.context.outputPath = outputPath
@@ -120,8 +124,8 @@ test('cli (single input file, output filename)', (t) => {
120
124
 
121
125
  t.context.inputPath = inputPath
122
126
 
123
- const outputName = `./test${testID}.amf`
124
- const outputPath = path.resolve(__dirname, outputName)
127
+ const outputName = `./test${testID}.obj`
128
+ const outputPath = resolve(cwd(), outputName)
125
129
  t.false(fs.existsSync(outputPath))
126
130
 
127
131
  t.context.outputPath = outputPath
@@ -141,7 +145,7 @@ test('cli (folder, output format)', (t) => {
141
145
 
142
146
  t.context.inputPath = inputPath
143
147
 
144
- const folderPath = path.resolve(__dirname, './test-folder')
148
+ const folderPath = resolve(cwd(), './test-folder')
145
149
  t.false(fs.existsSync(folderPath))
146
150
 
147
151
  fs.mkdirSync(folderPath)
@@ -149,14 +153,14 @@ test('cli (folder, output format)', (t) => {
149
153
 
150
154
  t.context.folderPath = folderPath
151
155
 
152
- const mainPath = path.resolve(__dirname, './test-folder/main.js')
156
+ const mainPath = resolve(cwd(), './test-folder/main.js')
153
157
  fs.renameSync(inputPath, mainPath)
154
158
  t.true(fs.existsSync(mainPath))
155
159
 
156
160
  t.context.inputPath = mainPath
157
161
 
158
162
  const outputName = './test-folder/main.dxf'
159
- const outputPath = path.resolve(__dirname, outputName)
163
+ const outputPath = resolve(cwd(), outputName)
160
164
  t.false(fs.existsSync(outputPath))
161
165
 
162
166
  t.context.outputPath = outputPath
@@ -177,7 +181,7 @@ test('cli (single input file, parameters)', (t) => {
177
181
  t.context.inputPath = inputPath
178
182
 
179
183
  const outputName = `./test${testID}.stl`
180
- const outputPath = path.resolve(__dirname, outputName)
184
+ const outputPath = resolve(cwd(), outputName)
181
185
  t.false(fs.existsSync(outputPath))
182
186
 
183
187
  t.context.outputPath = outputPath
@@ -189,7 +193,7 @@ test('cli (single input file, parameters)', (t) => {
189
193
  t.true(fs.existsSync(outputPath))
190
194
  })
191
195
 
192
- test('cli (no parameters)', (t) => {
196
+ test('cli (no parameters, out help)', (t) => {
193
197
  const cliPath = t.context.cliPath
194
198
 
195
199
  const cmd = `node ${cliPath}`
@@ -215,7 +219,6 @@ test('cli (single input file, invalid jscad)', (t) => {
215
219
  })
216
220
  })
217
221
 
218
-
219
222
  test('cli (single input file, multiple output files)', (t) => {
220
223
  const testID = 7
221
224
 
@@ -225,9 +228,9 @@ test('cli (single input file, multiple output files)', (t) => {
225
228
  t.context.inputPath = inputPath
226
229
 
227
230
  const outputName = (partNum) => `./test${testID}-part-${partNum}-of-3.stl`
228
- const outputPath1 = path.resolve(__dirname, outputName(1))
229
- const outputPath2 = path.resolve(__dirname, outputName(2))
230
- const outputPath3 = path.resolve(__dirname, outputName(3))
231
+ const outputPath1 = resolve(__dirname, outputName(1))
232
+ const outputPath2 = resolve(__dirname, outputName(2))
233
+ const outputPath3 = resolve(__dirname, outputName(3))
231
234
  t.false(fs.existsSync(outputPath1))
232
235
  t.false(fs.existsSync(outputPath2))
233
236
  t.false(fs.existsSync(outputPath3))
@@ -239,7 +242,7 @@ test('cli (single input file, multiple output files)', (t) => {
239
242
  const cliPath = t.context.cliPath
240
243
 
241
244
  const cmd = `node ${cliPath} ${inputPath} -gp`
242
- execSync(cmd, { stdio: [0,1,2] })
245
+ execSync(cmd, { stdio: [0, 1, 2] })
243
246
  t.true(fs.existsSync(outputPath1))
244
247
  t.true(fs.existsSync(outputPath2))
245
248
  t.true(fs.existsSync(outputPath3))
@@ -254,24 +257,24 @@ test('cli (single multipart input file, zipped output file)', async (t) => {
254
257
  t.context.inputPath = inputPath
255
258
 
256
259
  const outputName = `./test${testID}.zip`
257
- const outputPath = path.resolve(__dirname, outputName)
260
+ const outputPath = resolve(__dirname, outputName)
258
261
 
259
262
  t.false(fs.existsSync(outputPath))
260
-
263
+
261
264
  t.context.outputPath = outputPath
262
265
 
263
266
  const cliPath = t.context.cliPath
264
267
 
265
268
  const cmd = `node ${cliPath} ${inputPath} -gp -z`
266
- execSync(cmd, { stdio: [0,1,2] })
269
+ execSync(cmd, { stdio: [0, 1, 2] })
267
270
  t.true(fs.existsSync(outputPath))
268
271
 
269
272
  // check contents of zip file
270
273
  const data = await fs.promises.readFile(outputPath)
271
274
  const content = await JSZip.loadAsync(data)
272
- t.true(content.files[path.resolve(__dirname, `./test${testID}-part-1-of-3.stl`)] !== undefined)
273
- t.true(content.files[path.resolve(__dirname, `./test${testID}-part-2-of-3.stl`)] !== undefined)
274
- t.true(content.files[path.resolve(__dirname, `./test${testID}-part-3-of-3.stl`)] !== undefined)
275
+ t.true(content.files[resolve(__dirname, `./test${testID}-part-1-of-3.stl`)] !== undefined)
276
+ t.true(content.files[resolve(__dirname, `./test${testID}-part-2-of-3.stl`)] !== undefined)
277
+ t.true(content.files[resolve(__dirname, `./test${testID}-part-3-of-3.stl`)] !== undefined)
275
278
  })
276
279
 
277
280
  test('cli (single input file, zipped output file)', async (t) => {
@@ -281,22 +284,22 @@ test('cli (single input file, zipped output file)', async (t) => {
281
284
  t.true(fs.existsSync(inputPath))
282
285
 
283
286
  t.context.inputPath = inputPath
284
-
287
+
285
288
  const outputName = `./test${testID}.zip`
286
- const outputPath = path.resolve(__dirname, outputName)
289
+ const outputPath = resolve(__dirname, outputName)
287
290
 
288
291
  t.false(fs.existsSync(outputPath))
289
-
292
+
290
293
  t.context.outputPath = outputPath
291
294
 
292
295
  const cliPath = t.context.cliPath
293
296
 
294
297
  const cmd = `node ${cliPath} ${inputPath} -z`
295
- execSync(cmd, { stdio: [0,1,2] })
298
+ execSync(cmd, { stdio: [0, 1, 2] })
296
299
  t.true(fs.existsSync(outputPath))
297
300
 
298
301
  // check contents of zip file
299
302
  const data = await fs.promises.readFile(outputPath)
300
303
  const content = await JSZip.loadAsync(data)
301
- t.true(content.files[path.resolve(__dirname, `./test${testID}.stl`)] !== undefined)
304
+ t.true(content.files[resolve(__dirname, `./test${testID}.stl`)] !== undefined)
302
305
  })
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@jscad/cli",
3
- "version": "2.3.0",
3
+ "version": "3.0.0-alpha.0",
4
4
  "description": "Command Line Interface (CLI) for JSCAD",
5
5
  "homepage": "https://openjscad.xyz/",
6
6
  "repository": "https://github.com/jscad/OpenJSCAD.org",
7
+ "type": "module",
7
8
  "bin": {
8
9
  "jscad": "./cli.js"
9
10
  },
10
11
  "scripts": {
11
- "coverage": "nyc --all --reporter=html --reporter=text npm test",
12
+ "coverage": "c8 --all --reporter=html --reporter=text npm test",
12
13
  "test": "ava '*.test.js' --serial --verbose --timeout 2m",
13
14
  "postinstall": "node -e \"console.log('\\u001b[35m\\u001b[1mLove JSCAD? You can now donate to our open collective:\\u001b[22m\\u001b[39m\\n > \\u001b[34mhttps://opencollective.com/openjscad/donate\\u001b[0m')\""
14
15
  },
@@ -35,20 +36,21 @@
35
36
  ],
36
37
  "license": "MIT",
37
38
  "dependencies": {
38
- "@jscad/array-utils": "2.1.4",
39
- "@jscad/core": "2.6.7",
40
- "@jscad/io": "2.4.6",
41
- "@jscad/modeling": "2.12.0",
39
+ "@jscad/array-utils": "3.0.0-alpha.0",
40
+ "@jscad/core": "3.0.0-alpha.0",
41
+ "@jscad/io": "3.0.0-alpha.0",
42
+ "@jscad/io-utils": "3.0.0-alpha.0",
43
+ "@jscad/modeling": "3.0.0-alpha.0",
42
44
  "jszip": "^3.10.1"
43
45
  },
44
46
  "devDependencies": {
45
- "ava": "3.15.0",
46
- "nyc": "15.1.0"
47
+ "ava": "^4.3.3",
48
+ "c8": "^8.0.0"
47
49
  },
48
50
  "collective": {
49
51
  "type": "opencollective",
50
52
  "url": "https://opencollective.com/openjscad",
51
53
  "logo": "https://opencollective.com/openjscad/logo.txt"
52
54
  },
53
- "gitHead": "e269f212db5a00cda740d2f7ad3e5206d1eb839f"
55
+ "gitHead": "3656d36ed9cd738ab884e86aae5a2ce08d52adf7"
54
56
  }
@@ -1,6 +1,6 @@
1
- const { supportedOutputExtensions, supportedOutputFormats } = require('@jscad/io/formats')
1
+ import { supportedOutputExtensions, supportedOutputFormats } from '@jscad/io'
2
2
 
3
- const determineOutputNameAndFormat = (outputFormat, outputFile, inputFile) => {
3
+ export const determineOutputNameAndFormat = (outputFormat, outputFile, inputFile) => {
4
4
  const extReg = new RegExp(`\\.(${supportedOutputExtensions().join('|')})$`)
5
5
  const forReg = new RegExp(`(${supportedOutputFormats().join('|')})`, 'i')
6
6
 
@@ -22,5 +22,3 @@ const determineOutputNameAndFormat = (outputFormat, outputFile, inputFile) => {
22
22
  }
23
23
  return { outputFormat, outputFile }
24
24
  }
25
-
26
- module.exports = determineOutputNameAndFormat
package/src/env.js CHANGED
@@ -1,17 +1,14 @@
1
- const version = require('../package.json').version
1
+ import os from 'os'
2
2
 
3
- const env = () => {
3
+ const version = '[VI]{version}[/VI]' // version is injected by rollup
4
+
5
+ export const env = () => {
4
6
  let env = 'JSCAD ' + version
5
7
  if (typeof document !== 'undefined') {
6
8
  const w = document.defaultView
7
9
  env = env + ' [' + w.navigator.userAgent + ']'
8
10
  } else {
9
- if (typeof require === 'function') {
10
- const os = require('os')
11
- env = env + ' [' + os.type() + ':' + os.release() + ',' + os.platform() + ':' + os.arch() + ']'
12
- }
11
+ env = env + ' [' + os.type() + ':' + os.release() + ',' + os.platform() + ':' + os.arch() + ']'
13
12
  }
14
13
  console.log(env)
15
14
  }
16
-
17
- module.exports = env
@@ -1,19 +1,24 @@
1
- const fs = require('fs')
2
- const { isAbsolute, resolve } = require('path')
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+ import { createRequire } from 'module'
3
4
 
4
- const { deserializers, solidsAsBlob } = require('@jscad/io')
5
+ import { deserialize, getMimeType, serialize } from '@jscad/io'
6
+ import { convertToBlob } from '@jscad/io-utils'
5
7
 
6
- const { rebuildGeometryCli } = require('@jscad/core').evaluation
7
- const { registerAllExtensions } = require('@jscad/core').io
8
+ import { evaluation, io } from '@jscad/core'
9
+
10
+ const { rebuildGeometryCli } = evaluation
11
+ const { registerAllExtensions } = io
8
12
 
9
13
  /**
10
- * generate output data from source
14
+ * Create a promise to convert the given source in inputFormat to the desired outputFormat.
15
+ * The given CLI params are passed into deserializer, main, and serializer.
11
16
  * @param {String} source the original source
12
- * @param {Object} params hash of parameters to pass to main function
13
- * @param {String} options
14
- * @return a Promise with the output data
17
+ * @param {Object} cliParams - parameters as provided on the command line
18
+ * @param {Object} options - options for conversion; inputFormat and outputFormat are required
19
+ * @return {Promise} promise function which can convert the given source
15
20
  */
16
- const generateOutputData = (source, params, options) => {
21
+ export const generateOutputData = (source, cliParams, options) => {
17
22
  const defaults = {
18
23
  outputFile: undefined,
19
24
  outputFormat: 'stl',
@@ -23,38 +28,32 @@ const generateOutputData = (source, params, options) => {
23
28
  generateParts: false
24
29
  }
25
30
  options = Object.assign({}, defaults, options)
26
- const { outputFormat, inputFile, inputFormat, generateParts } = options
27
31
 
28
- options.filename = inputFile // for deserializers
32
+ const { inputFile, inputFormat, outputFormat, generateParts } = options
33
+
34
+ const inputMimeType = getMimeType(inputFormat)
35
+ const outputMimeType = getMimeType(outputFormat)
29
36
 
30
- const inputPath = isAbsolute(inputFile) ? inputFile : resolve(process.cwd(), inputFile)
37
+ const inputPath = path.isAbsolute(inputFile) ? inputFile : path.resolve(process.cwd(), inputFile)
31
38
 
32
39
  // setup support for require-ing files with .jscad, .stl etc extensions
40
+ // HACK create the require function if necessary
41
+ const require = createRequire(import.meta.url)
33
42
  registerAllExtensions(fs, require)
34
43
 
35
44
  return new Promise((resolve, reject) => {
36
- let deserializer = deserializers[inputFormat]
37
- if (!deserializer) {
38
- if (inputFormat === 'jscad' || inputFormat === 'js') {
39
- deserializer = (options, source) => source
40
- } else {
41
- reject(new Error(`unsuported input format ${inputFormat}`))
42
- }
43
- }
44
-
45
45
  // convert any inputs
46
46
  const prevsource = source
47
- const deserializerOptions = Object.assign({}, params, options)
48
- source = deserializer(deserializerOptions, source)
47
+ const deserializerOptions = Object.assign({ output: 'script', filename: inputFile }, cliParams)
48
+ source = deserialize(deserializerOptions, inputMimeType, source)
49
49
  const useFakeFs = (source !== prevsource) // conversion, so use a fake file system when rebuilding
50
50
 
51
- if (outputFormat === 'jscad' || outputFormat === 'js') {
51
+ if (outputMimeType === 'application/javascript') {
52
+ // pass back the source
52
53
  resolve(source)
53
54
  } else {
54
- // } else if ((inputFormat === 'jscad' || inputFormat === 'js') &&
55
- // outputFormat !== 'jscad' && outputFormat !== 'js') {
56
55
  try {
57
- const solids = rebuildGeometryCli({ mainPath: inputPath, parameterValues: params, useFakeFs, source })
56
+ const solids = rebuildGeometryCli({ mainPath: inputPath, parameterValues: cliParams, useFakeFs, source })
58
57
  resolve(solids)
59
58
  } catch (error) {
60
59
  reject(error)
@@ -62,16 +61,25 @@ const generateOutputData = (source, params, options) => {
62
61
  }
63
62
  })
64
63
  .then((solids) => {
65
- const serializerOptions = Object.assign({ format: outputFormat }, params)
66
- if (generateParts) {
67
- let blobs = []
68
- for (let i = 0; i < solids.length; i++) {
69
- blobs.push(solidsAsBlob(solids[i], serializerOptions))
70
- }
71
- return blobs
64
+ if (Array.isArray(solids) && generateParts) {
65
+ return solids.map((s) => convertSolidsToBlob({ mimeType: outputMimeType, cliParams }, [s]))
72
66
  }
73
- return solidsAsBlob(solids, serializerOptions)
67
+ return convertSolidsToBlob({ mimeType: outputMimeType, cliParams }, solids)
74
68
  })
75
69
  }
76
70
 
77
- module.exports = generateOutputData
71
+ /*
72
+ * Convert the given solids to the target mimeType, and return as a blob for writing to file.
73
+ */
74
+ const convertSolidsToBlob = (options, solids) => {
75
+ const { mimeType, cliParams } = options
76
+
77
+ if (mimeType === 'application/javascript') {
78
+ // convert the solids (source code) to blob without conversion
79
+ return convertToBlob({ data: [solids], mimeType })
80
+ } else {
81
+ // convert the solids into the mimeType via serializers
82
+ const serializerOptions = Object.assign({}, cliParams)
83
+ return convertToBlob(serialize(serializerOptions, mimeType, solids))
84
+ }
85
+ }
package/src/parseArgs.js CHANGED
@@ -1,11 +1,15 @@
1
- const fs = require('fs')
1
+ import fs from 'fs'
2
+ import path from 'path'
2
3
 
3
- const { getDesignEntryPoint } = require('@jscad/core').loading.requireDesignUtilsFs
4
- const { supportedInputExtensions, supportedOutputExtensions, supportedOutputFormats } = require('@jscad/io/formats')
4
+ import { loading } from '@jscad/core'
5
5
 
6
- const env = require('./env')
6
+ import { supportedInputExtensions, supportedOutputExtensions, supportedOutputFormats } from '@jscad/io'
7
7
 
8
- const parseArgs = (args) => {
8
+ import { env } from './env.js'
9
+
10
+ const { getDesignEntryPoint } = loading
11
+
12
+ export const parseArgs = (args) => {
9
13
  const inputExtensions = supportedInputExtensions()
10
14
  const outputExtensions = supportedOutputExtensions()
11
15
  const outputFormats = supportedOutputFormats()
@@ -13,7 +17,8 @@ const parseArgs = (args) => {
13
17
  // hint: https://github.com/substack/node-optimist
14
18
  // https://github.com/visionmedia/commander.js
15
19
  if (args.length < 1) {
16
- console.log('USAGE:\n\njscad [-v] <file> [-of <format>] [-o <output>]')
20
+ console.log('USAGE:\n\njscad [-v]\n\n')
21
+ console.log('jscad [-gp] [-z] <file> [-of <format>] [-o <output>]')
17
22
  console.log(`\t<file> :\tinput (Supported types: folder, .${inputExtensions.join(', .')})`)
18
23
  console.log(`\t<output>:\toutput (Supported types: folder, .${outputExtensions.join(', .')})`)
19
24
  console.log(`\t<format>:\t${outputFormats.join(', ')}`)
@@ -78,10 +83,10 @@ const parseArgs = (args) => {
78
83
  console.log('Verify main or index exists')
79
84
  process.exit(1)
80
85
  }
81
- inputFormat = require('path').extname(inputFile).substring(1)
86
+ inputFormat = path.extname(inputFile).substring(1)
82
87
  } else {
83
88
  console.log('ERROR: invalid file name or argument <' + args[i] + '>')
84
- console.log("Type 'openjscad' for a list of supported types")
89
+ console.log("Type 'jscad' for a list of supported types")
85
90
  process.exit(1)
86
91
  }
87
92
  }
@@ -92,6 +97,15 @@ const parseArgs = (args) => {
92
97
  if (!outputFormat && !outputFile) {
93
98
  outputFormat = 'stla'
94
99
  }
100
+ if (!outputFormat && outputFile) {
101
+ outputFormat = path.extname(outputFile).substring(1)
102
+ if (outputFormat === 'stl') outputFormat = 'stla'
103
+ }
104
+ if (!outputFormats.includes(outputFormat)) {
105
+ console.log('ERROR: invalid output format <' + outputFormat + '>')
106
+ console.log("Type 'jscad' for a list of supported types")
107
+ process.exit(1)
108
+ }
95
109
 
96
110
  return {
97
111
  inputFile,
@@ -105,5 +119,3 @@ const parseArgs = (args) => {
105
119
  inputIsDirectory
106
120
  }
107
121
  }
108
-
109
- module.exports = parseArgs
@@ -1,15 +1,11 @@
1
- const fs = require('fs')
1
+ import fs from 'fs'
2
2
 
3
- const writeOutputDataToFile = (outputFile, outputData) => {
3
+ export const writeOutput = (outputFile, outputData) => {
4
4
  fs.writeFile(outputFile, outputData.asBuffer(),
5
5
  (err) => {
6
6
  if (err) {
7
7
  console.log('err', err)
8
- } else {
9
- // console.log('success')
10
8
  }
11
9
  }
12
10
  )
13
11
  }
14
-
15
- module.exports = writeOutputDataToFile