YAML-ification and minor output restructure
This commit is contained in:
parent
282e117457
commit
fa850a643c
22 changed files with 287 additions and 409 deletions
16
src/cli.js
16
src/cli.js
|
@ -67,9 +67,7 @@ const single = (data, rel) => {
|
|||
if (!data) return
|
||||
const abs = path.join(args.o, rel)
|
||||
fs.mkdirpSync(path.dirname(abs))
|
||||
if (abs.endsWith('.json')) {
|
||||
fs.writeJSONSync(abs, data, {spaces: 4})
|
||||
} else if (abs.endsWith('.yaml')) {
|
||||
if (abs.endsWith('.yaml')) {
|
||||
fs.writeFileSync(abs, yaml.dump(data, {indent: 4}))
|
||||
} else {
|
||||
fs.writeFileSync(abs, data)
|
||||
|
@ -79,9 +77,9 @@ const single = (data, rel) => {
|
|||
const composite = (data, rel) => {
|
||||
if (!data) return
|
||||
const abs = path.join(args.o, rel)
|
||||
if (data.json) {
|
||||
if (data.yaml) {
|
||||
fs.mkdirpSync(path.dirname(abs))
|
||||
fs.writeJSONSync(abs + '.json', data.json, {spaces: 4})
|
||||
fs.writeFileSync(abs + '.yaml', yaml.dump(data.yaml, {indent: 4}))
|
||||
}
|
||||
for (const format of ['svg', 'dxf', 'jscad', 'stl']) {
|
||||
if (data[format]) {
|
||||
|
@ -101,11 +99,11 @@ if (args.clean) {
|
|||
console.log('Writing output to disk...')
|
||||
fs.mkdirpSync(args.o)
|
||||
|
||||
single(results.raw, 'raw.txt')
|
||||
single(results.canonical, 'canonical.yaml')
|
||||
single(results.units, 'units.json')
|
||||
single(results.raw, 'source/raw.txt')
|
||||
single(results.canonical, 'source/canonical.yaml')
|
||||
|
||||
single(results.points, 'points/points.json')
|
||||
single(results.units, 'points/units.yaml')
|
||||
single(results.points, 'points/points.yaml')
|
||||
composite(results.demo, 'points/demo')
|
||||
|
||||
for (const [name, outline] of Object.entries(results.outlines)) {
|
||||
|
|
|
@ -60,7 +60,7 @@ exports.twodee = (model, debug) => {
|
|||
dxf: makerjs.exporter.toDXF(assembly),
|
||||
}
|
||||
if (debug) {
|
||||
result.json = assembly
|
||||
result.yaml = assembly
|
||||
result.svg = makerjs.exporter.toSVG(assembly)
|
||||
}
|
||||
return result
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
{
|
||||
"models": {
|
||||
"export": {
|
||||
"models": {
|
||||
"a": {
|
||||
"models": {},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
"b": {
|
||||
"models": {
|
||||
"a": {
|
||||
"models": {},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
"b": {
|
||||
"paths": {
|
||||
"ShapeLine1": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
-9,
|
||||
-9
|
||||
],
|
||||
"end": [
|
||||
9,
|
||||
-9
|
||||
]
|
||||
},
|
||||
"ShapeLine2": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
9,
|
||||
-9
|
||||
],
|
||||
"end": [
|
||||
9,
|
||||
9
|
||||
]
|
||||
},
|
||||
"ShapeLine3": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
9,
|
||||
9
|
||||
],
|
||||
"end": [
|
||||
-9,
|
||||
9
|
||||
]
|
||||
},
|
||||
"ShapeLine4": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
-9,
|
||||
9
|
||||
],
|
||||
"end": [
|
||||
-9,
|
||||
-9
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"units": "mm",
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
62
test/cli/big/reference/outlines/_export.yaml
Normal file
62
test/cli/big/reference/outlines/_export.yaml
Normal file
|
@ -0,0 +1,62 @@
|
|||
models:
|
||||
export:
|
||||
models:
|
||||
a:
|
||||
models: {}
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
b:
|
||||
models:
|
||||
a:
|
||||
models: {}
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
b:
|
||||
paths:
|
||||
ShapeLine1:
|
||||
type: line
|
||||
origin:
|
||||
- -9
|
||||
- -9
|
||||
end:
|
||||
- 9
|
||||
- -9
|
||||
ShapeLine2:
|
||||
type: line
|
||||
origin:
|
||||
- 9
|
||||
- -9
|
||||
end:
|
||||
- 9
|
||||
- 9
|
||||
ShapeLine3:
|
||||
type: line
|
||||
origin:
|
||||
- 9
|
||||
- 9
|
||||
end:
|
||||
- -9
|
||||
- 9
|
||||
ShapeLine4:
|
||||
type: line
|
||||
origin:
|
||||
- -9
|
||||
- 9
|
||||
end:
|
||||
- -9
|
||||
- -9
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
units: mm
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
|
@ -1,91 +0,0 @@
|
|||
{
|
||||
"models": {
|
||||
"export": {
|
||||
"models": {
|
||||
"a": {
|
||||
"models": {},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
"b": {
|
||||
"models": {
|
||||
"a": {
|
||||
"models": {},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
"b": {
|
||||
"paths": {
|
||||
"ShapeLine1": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
-9,
|
||||
-9
|
||||
],
|
||||
"end": [
|
||||
9,
|
||||
-9
|
||||
]
|
||||
},
|
||||
"ShapeLine2": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
9,
|
||||
-9
|
||||
],
|
||||
"end": [
|
||||
9,
|
||||
9
|
||||
]
|
||||
},
|
||||
"ShapeLine3": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
9,
|
||||
9
|
||||
],
|
||||
"end": [
|
||||
-9,
|
||||
9
|
||||
]
|
||||
},
|
||||
"ShapeLine4": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
-9,
|
||||
9
|
||||
],
|
||||
"end": [
|
||||
-9,
|
||||
-9
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"units": "mm",
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
62
test/cli/big/reference/outlines/export.yaml
Normal file
62
test/cli/big/reference/outlines/export.yaml
Normal file
|
@ -0,0 +1,62 @@
|
|||
models:
|
||||
export:
|
||||
models:
|
||||
a:
|
||||
models: {}
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
b:
|
||||
models:
|
||||
a:
|
||||
models: {}
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
b:
|
||||
paths:
|
||||
ShapeLine1:
|
||||
type: line
|
||||
origin:
|
||||
- -9
|
||||
- -9
|
||||
end:
|
||||
- 9
|
||||
- -9
|
||||
ShapeLine2:
|
||||
type: line
|
||||
origin:
|
||||
- 9
|
||||
- -9
|
||||
end:
|
||||
- 9
|
||||
- 9
|
||||
ShapeLine3:
|
||||
type: line
|
||||
origin:
|
||||
- 9
|
||||
- 9
|
||||
end:
|
||||
- -9
|
||||
- 9
|
||||
ShapeLine4:
|
||||
type: line
|
||||
origin:
|
||||
- -9
|
||||
- 9
|
||||
end:
|
||||
- -9
|
||||
- -9
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
units: mm
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
|
@ -1,69 +0,0 @@
|
|||
{
|
||||
"models": {
|
||||
"export": {
|
||||
"models": {
|
||||
"matrix_col_row": {
|
||||
"paths": {
|
||||
"top": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
-9,
|
||||
9
|
||||
],
|
||||
"end": [
|
||||
9,
|
||||
9
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
9,
|
||||
9
|
||||
],
|
||||
"end": [
|
||||
9,
|
||||
-9
|
||||
]
|
||||
},
|
||||
"bottom": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
9,
|
||||
-9
|
||||
],
|
||||
"end": [
|
||||
-9,
|
||||
-9
|
||||
]
|
||||
},
|
||||
"left": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
-9,
|
||||
-9
|
||||
],
|
||||
"end": [
|
||||
-9,
|
||||
9
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"units": "mm",
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
47
test/cli/big/reference/points/demo.yaml
Normal file
47
test/cli/big/reference/points/demo.yaml
Normal file
|
@ -0,0 +1,47 @@
|
|||
models:
|
||||
export:
|
||||
models:
|
||||
matrix_col_row:
|
||||
paths:
|
||||
top:
|
||||
type: line
|
||||
origin:
|
||||
- -9
|
||||
- 9
|
||||
end:
|
||||
- 9
|
||||
- 9
|
||||
right:
|
||||
type: line
|
||||
origin:
|
||||
- 9
|
||||
- 9
|
||||
end:
|
||||
- 9
|
||||
- -9
|
||||
bottom:
|
||||
type: line
|
||||
origin:
|
||||
- 9
|
||||
- -9
|
||||
end:
|
||||
- -9
|
||||
- -9
|
||||
left:
|
||||
type: line
|
||||
origin:
|
||||
- -9
|
||||
- -9
|
||||
end:
|
||||
- -9
|
||||
- 9
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
units: mm
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
"matrix_col_row": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"r": 0,
|
||||
"meta": {
|
||||
"shift": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"rotate": 0,
|
||||
"padding": 19,
|
||||
"width": 1,
|
||||
"height": 1,
|
||||
"skip": false,
|
||||
"asym": "both",
|
||||
"name": "matrix_col_row",
|
||||
"colrow": "col_row",
|
||||
"col": {
|
||||
"stagger": 0,
|
||||
"spread": 0,
|
||||
"rotate": 0,
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"rows": {},
|
||||
"key": {},
|
||||
"name": "col"
|
||||
},
|
||||
"row": "row"
|
||||
}
|
||||
}
|
||||
}
|
27
test/cli/big/reference/points/points.yaml
Normal file
27
test/cli/big/reference/points/points.yaml
Normal file
|
@ -0,0 +1,27 @@
|
|||
matrix_col_row:
|
||||
x: 0
|
||||
'y': 0
|
||||
r: 0
|
||||
meta:
|
||||
shift:
|
||||
- 0
|
||||
- 0
|
||||
rotate: 0
|
||||
padding: 19
|
||||
width: 1
|
||||
height: 1
|
||||
skip: false
|
||||
asym: both
|
||||
name: matrix_col_row
|
||||
colrow: col_row
|
||||
col:
|
||||
stagger: 0
|
||||
spread: 0
|
||||
rotate: 0
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
rows: {}
|
||||
key: {}
|
||||
name: col
|
||||
row: row
|
4
test/cli/big/reference/points/units.yaml
Normal file
4
test/cli/big/reference/points/units.yaml
Normal file
|
@ -0,0 +1,4 @@
|
|||
u: 19
|
||||
cx: 18
|
||||
cy: 17
|
||||
a: 47
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"u": 19,
|
||||
"cx": 18,
|
||||
"cy": 17,
|
||||
"a": 47
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
{
|
||||
"models": {
|
||||
"export": {
|
||||
"models": {
|
||||
"matrix_col_row": {
|
||||
"paths": {
|
||||
"top": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
-9,
|
||||
9
|
||||
],
|
||||
"end": [
|
||||
9,
|
||||
9
|
||||
]
|
||||
},
|
||||
"right": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
9,
|
||||
9
|
||||
],
|
||||
"end": [
|
||||
9,
|
||||
-9
|
||||
]
|
||||
},
|
||||
"bottom": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
9,
|
||||
-9
|
||||
],
|
||||
"end": [
|
||||
-9,
|
||||
-9
|
||||
]
|
||||
},
|
||||
"left": {
|
||||
"type": "line",
|
||||
"origin": [
|
||||
-9,
|
||||
-9
|
||||
],
|
||||
"end": [
|
||||
-9,
|
||||
9
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
"units": "mm",
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
47
test/cli/minimal/reference/points/demo.yaml
Normal file
47
test/cli/minimal/reference/points/demo.yaml
Normal file
|
@ -0,0 +1,47 @@
|
|||
models:
|
||||
export:
|
||||
models:
|
||||
matrix_col_row:
|
||||
paths:
|
||||
top:
|
||||
type: line
|
||||
origin:
|
||||
- -9
|
||||
- 9
|
||||
end:
|
||||
- 9
|
||||
- 9
|
||||
right:
|
||||
type: line
|
||||
origin:
|
||||
- 9
|
||||
- 9
|
||||
end:
|
||||
- 9
|
||||
- -9
|
||||
bottom:
|
||||
type: line
|
||||
origin:
|
||||
- 9
|
||||
- -9
|
||||
end:
|
||||
- -9
|
||||
- -9
|
||||
left:
|
||||
type: line
|
||||
origin:
|
||||
- -9
|
||||
- -9
|
||||
end:
|
||||
- -9
|
||||
- 9
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
units: mm
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
"matrix_col_row": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"r": 0,
|
||||
"meta": {
|
||||
"shift": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"rotate": 0,
|
||||
"padding": 19,
|
||||
"width": 1,
|
||||
"height": 1,
|
||||
"skip": false,
|
||||
"asym": "both",
|
||||
"name": "matrix_col_row",
|
||||
"colrow": "col_row",
|
||||
"col": {
|
||||
"stagger": 0,
|
||||
"spread": 0,
|
||||
"rotate": 0,
|
||||
"origin": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"rows": {},
|
||||
"key": {},
|
||||
"name": "col"
|
||||
},
|
||||
"row": "row"
|
||||
}
|
||||
}
|
||||
}
|
27
test/cli/minimal/reference/points/points.yaml
Normal file
27
test/cli/minimal/reference/points/points.yaml
Normal file
|
@ -0,0 +1,27 @@
|
|||
matrix_col_row:
|
||||
x: 0
|
||||
'y': 0
|
||||
r: 0
|
||||
meta:
|
||||
shift:
|
||||
- 0
|
||||
- 0
|
||||
rotate: 0
|
||||
padding: 19
|
||||
width: 1
|
||||
height: 1
|
||||
skip: false
|
||||
asym: both
|
||||
name: matrix_col_row
|
||||
colrow: col_row
|
||||
col:
|
||||
stagger: 0
|
||||
spread: 0
|
||||
rotate: 0
|
||||
origin:
|
||||
- 0
|
||||
- 0
|
||||
rows: {}
|
||||
key: {}
|
||||
name: col
|
||||
row: row
|
3
test/cli/minimal/reference/points/units.yaml
Normal file
3
test/cli/minimal/reference/points/units.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
u: 19
|
||||
cx: 18
|
||||
cy: 17
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"u": 19,
|
||||
"cx": 18,
|
||||
"cy": 17
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue