chore: Re-structure workspaces, enforce build order
These are some changes in the way the monorepo is structured, that are aimed at making it easier to get started. There are two important changes: **Multiple workspaces** We had a yarn workspaces setup at `packages/*`. But our monorepo has grown to 92 packages which can be overwhelming for people not familiar with the package names. To remedy this, I've split it into 4 different workspaces: - `designs/*`: Holds FreeSewing designs (think patterns) - `plugins/*`: Holds FreeSewing plugins - `packages/*`: Holds other packages published on NPM - `sites/*`: Holds software that is not published as an NPM package, such as our various websites and backend API This should make it easier to find things, and to answer questions like *where do I find the code for the plugins*. **Updated reconfigure script to handle build order** One problem when bootstrapping the repo is inter-dependencies between packages. For example, building a pattern will only work once `plugin-bundle` is built. Which will only work once all plugins in the bundle or built. And that will only work when `core` is built, and so on. This can be frustrating for new users as `yarn buildall` will fail. And it gets overlooked by seasoned devs because they're likely to have every package built in their repo so this issue doesn't concern them. To remedy this, we now have a `config/build-order.mjs` file and the updated `/scripts/reconfigure.mjs` script will enforce the build order so that things *just work*.
This commit is contained in:
parent
895f993a70
commit
e4035b2509
1581 changed files with 2118 additions and 1868 deletions
96
plugins/plugin-bartack/src/bartack.js
Normal file
96
plugins/plugin-bartack/src/bartack.js
Normal file
|
@ -0,0 +1,96 @@
|
|||
const name = (n, so) => `${so.prefix}${n}${so.suffix}`
|
||||
|
||||
const drawBartack = (points, self) => {
|
||||
let path = new self.Path().move(points.path1[0])
|
||||
for (const i in points.path1) {
|
||||
if (points.path1[i]) path = path.line(points.path1[i])
|
||||
if (points.path2[i]) path = path.line(points.path2[i])
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
const getPoints = (path, so) => {
|
||||
let path1 = path.offset(so.width / 2)
|
||||
let path2 = path.offset(so.width / -2)
|
||||
let len = path1.length()
|
||||
let len2 = path2.length()
|
||||
|
||||
// Make sure path1 is always the longest one
|
||||
if (len2 > len) {
|
||||
let tmp = path2
|
||||
path2 = path1
|
||||
path1 = tmp
|
||||
len = len2
|
||||
}
|
||||
|
||||
let points = {
|
||||
path1: [path1.start()],
|
||||
path2: [path2.start()],
|
||||
}
|
||||
let steps = Math.ceil((len / so.width) * so.density)
|
||||
for (let i = 1; i < steps; i++) {
|
||||
points.path1.push(path1.shiftFractionAlong((1 / steps) * i))
|
||||
points.path2.push(path2.shiftFractionAlong((1 / steps) * i))
|
||||
}
|
||||
|
||||
return points
|
||||
}
|
||||
|
||||
const bartackPath = (path, so, self) => (path ? drawBartack(getPoints(path, so), self) : null)
|
||||
|
||||
export default function bartack(so, self) {
|
||||
const defaults = {
|
||||
width: 3,
|
||||
length: 15,
|
||||
density: 3,
|
||||
angle: 0,
|
||||
prefix: '',
|
||||
suffix: '',
|
||||
anchor: false,
|
||||
path: false,
|
||||
from: false,
|
||||
to: false,
|
||||
start: 0,
|
||||
end: 1,
|
||||
bartackAlong: false,
|
||||
bartackFractionAlong: false,
|
||||
}
|
||||
so = { ...defaults, ...so }
|
||||
|
||||
let guide = false
|
||||
|
||||
if (so.anchor)
|
||||
// Anchor + angle + length
|
||||
guide = new self.Path().move(so.anchor).line(so.anchor.shift(so.angle, so.length))
|
||||
else if (so.from && so.to)
|
||||
// From to
|
||||
guide = new self.Path().move(so.from).line(so.to)
|
||||
else if (so.path) {
|
||||
// Along path
|
||||
let start = false
|
||||
let end = false
|
||||
if (so.bartackAlong) guide = so.path.clone()
|
||||
else if (so.bartackFractionAlong) {
|
||||
if (so.start === so.end) return null
|
||||
if (so.start > so.end) {
|
||||
const newEnd = so.start
|
||||
so.start = so.end
|
||||
so.end = newEnd
|
||||
}
|
||||
if (so.start > 0) start = so.path.shiftFractionAlong(so.start)
|
||||
if (so.end < 1) end = so.path.shiftFractionAlong(so.end)
|
||||
if (start && end) guide = so.path.split(start).pop().split(end).shift()
|
||||
else if (start) guide = so.path.split(start).pop()
|
||||
else if (end) guide = so.path.split(end).shift()
|
||||
else guide = so.path.clone()
|
||||
}
|
||||
}
|
||||
|
||||
self.paths[name('bartack', so)] = bartackPath(guide, so, self).attr(
|
||||
'class',
|
||||
'stroke-sm stroke-mark'
|
||||
)
|
||||
|
||||
return true
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue