chore(plugin-bundle): Ported to v3
This commit is contained in:
parent
c8e2a404f0
commit
610302ac21
6 changed files with 77 additions and 103 deletions
|
@ -1,87 +0,0 @@
|
|||
/* eslint no-unused-expressions: "warn" */
|
||||
import banner from '@freesewing/plugin-banner'
|
||||
import bartack from '@freesewing/plugin-bartack'
|
||||
import buttons from '@freesewing/plugin-buttons'
|
||||
import cutonfold from '@freesewing/plugin-cutonfold'
|
||||
import dimension from '@freesewing/plugin-dimension'
|
||||
import grainline from '@freesewing/plugin-grainline'
|
||||
import logo from '@freesewing/plugin-logo'
|
||||
import mirror from '@freesewing/plugin-mirror'
|
||||
import notches from '@freesewing/plugin-notches'
|
||||
import title from '@freesewing/plugin-title'
|
||||
import scalebox from '@freesewing/plugin-scalebox'
|
||||
import round from '@freesewing/plugin-round'
|
||||
import sprinkle from '@freesewing/plugin-sprinkle'
|
||||
import measurements from '@freesewing/plugin-measurements'
|
||||
import pkg from '../package.json'
|
||||
|
||||
const bundledPlugins = [
|
||||
banner,
|
||||
bartack,
|
||||
buttons,
|
||||
cutonfold,
|
||||
dimension,
|
||||
grainline,
|
||||
logo,
|
||||
mirror,
|
||||
notches,
|
||||
title,
|
||||
scalebox,
|
||||
round,
|
||||
sprinkle,
|
||||
measurements,
|
||||
]
|
||||
|
||||
function bundleHooks() {
|
||||
let hooks = {}
|
||||
for (let plugin of bundledPlugins) {
|
||||
for (let i in plugin.hooks) {
|
||||
if (typeof hooks[i] === 'undefined') hooks[i] = []
|
||||
let hook = plugin.hooks[i]
|
||||
if (typeof hook === 'function') hooks[i].push(hook)
|
||||
else if (typeof hook === 'object') {
|
||||
for (let method of hook) hooks[i].push(method)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hooks
|
||||
}
|
||||
|
||||
function bundleMacros() {
|
||||
let macros = {}
|
||||
for (let plugin of bundledPlugins) {
|
||||
for (let i in plugin.macros) macros[i] = plugin.macros[i]
|
||||
}
|
||||
|
||||
return macros
|
||||
}
|
||||
|
||||
const bundle = {
|
||||
name: pkg.name,
|
||||
version: pkg.version,
|
||||
hooks: bundleHooks(),
|
||||
macros: bundleMacros(),
|
||||
}
|
||||
|
||||
// Named exports
|
||||
export {
|
||||
banner,
|
||||
bartack,
|
||||
buttons,
|
||||
cutonfold,
|
||||
dimension,
|
||||
grainline,
|
||||
logo,
|
||||
mirror,
|
||||
notches,
|
||||
title,
|
||||
scalebox,
|
||||
round,
|
||||
sprinkle,
|
||||
measurements,
|
||||
bundle
|
||||
}
|
||||
|
||||
// Default export
|
||||
export default bundle
|
69
plugins/plugin-bundle/src/index.mjs
Normal file
69
plugins/plugin-bundle/src/index.mjs
Normal file
|
@ -0,0 +1,69 @@
|
|||
import { bannerPlugin } from '../../plugin-banner/src/index.mjs'
|
||||
import { bartackPlugin } from '../../plugin-bartack/src/index.mjs'
|
||||
import { buttonsPlugin } from '../../plugin-buttons/src/index.mjs'
|
||||
import { cutonfoldPlugin } from '../../plugin-cutonfold/src/index.mjs'
|
||||
import { dimensionPlugin } from '../../plugin-dimension/src/index.mjs'
|
||||
import { grainlinePlugin } from '../../plugin-grainline/src/index.mjs'
|
||||
import { logoPlugin } from '../../plugin-logo/src/index.mjs'
|
||||
import { mirrorPlugin } from '../../plugin-mirror/src/index.mjs'
|
||||
import { notchesPlugin } from '../../plugin-notches/src/index.mjs'
|
||||
import { titlePlugin } from '../../plugin-title/src/index.mjs'
|
||||
import { scaleboxPlugin } from '../../plugin-scalebox/src/index.mjs'
|
||||
import { roundPlugin } from '../../plugin-round/src/index.mjs'
|
||||
import { sprinklePlugin } from '../../plugin-sprinkle/src/index.mjs'
|
||||
import { measurementsPlugin } from '../../plugin-measurements/src/index.mjs'
|
||||
import { name, version } from '../package.json'
|
||||
|
||||
const bundledPlugins = [
|
||||
bannerPlugin,
|
||||
bartackPlugin,
|
||||
buttonsPlugin,
|
||||
cutonfoldPlugin,
|
||||
dimensionPlugin,
|
||||
grainlinePlugin,
|
||||
logoPlugin,
|
||||
mirrorPlugin,
|
||||
notchesPlugin,
|
||||
titlePlugin,
|
||||
scaleboxPlugin,
|
||||
roundPlugin,
|
||||
sprinklePlugin,
|
||||
measurementsPlugin,
|
||||
]
|
||||
|
||||
function bundleHooks() {
|
||||
const hooks = {}
|
||||
for (const plugin of bundledPlugins) {
|
||||
for (const i in plugin.hooks) {
|
||||
if (typeof hooks[i] === 'undefined') hooks[i] = []
|
||||
const hook = plugin.hooks[i]
|
||||
if (typeof hook === 'function') hooks[i].push(hook)
|
||||
else if (typeof hook === 'object') {
|
||||
for (let method of hook) hooks[i].push(method)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hooks
|
||||
}
|
||||
|
||||
function bundleMacros() {
|
||||
const macros = {}
|
||||
for (const plugin of bundledPlugins) {
|
||||
for (const i in plugin.macros) macros[i] = plugin.macros[i]
|
||||
}
|
||||
|
||||
return macros
|
||||
}
|
||||
|
||||
export const plugin = {
|
||||
name,
|
||||
version,
|
||||
hooks: bundleHooks(),
|
||||
macros: bundleMacros(),
|
||||
}
|
||||
|
||||
// More specifically named exports
|
||||
export const bundlePlugin = plugin
|
||||
export const pluginBundle = plugin
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue