1
0

YAML-ification and minor output restructure

This commit is contained in:
Bán Dénes 2021-07-21 21:24:12 +02:00
parent 282e117457
commit fa850a643c
22 changed files with 287 additions and 409 deletions

View File

@ -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)) {

View File

@ -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

View File

@ -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
]
}

View 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

View File

@ -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
]
}

View 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

View File

@ -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
]
}

View 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

View File

@ -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"
}
}
}

View 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

View File

@ -0,0 +1,4 @@
u: 19
cx: 18
cy: 17
a: 47

View File

@ -1,6 +0,0 @@
{
"u": 19,
"cx": 18,
"cy": 17,
"a": 47
}

View File

@ -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
]
}

View 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

View File

@ -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"
}
}
}

View 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

View File

@ -0,0 +1,3 @@
u: 19
cx: 18
cy: 17

View File

@ -1,5 +0,0 @@
{
"u": 19,
"cx": 18,
"cy": 17
}