refactor optiondocsimages script for mjs
This commit is contained in:
parent
affc6b6c4e
commit
e44d3ef34d
1 changed files with 19 additions and 16 deletions
|
@ -10,17 +10,18 @@
|
||||||
* markdown/org/docs/patterns/[pattern]/[option]/[pattern]_[option]_sample.svg
|
* markdown/org/docs/patterns/[pattern]/[option]/[pattern]_[option]_sample.svg
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const fs = require('fs')
|
import fs from 'fs'
|
||||||
const path = require('path')
|
import path from 'path'
|
||||||
const core = require('../packages/core/dist')
|
import { fileURLToPath } from 'url'
|
||||||
const pi = require('../packages/pattern-info/dist')
|
import { designs } from '../config/software/index.mjs'
|
||||||
const models = require('../packages/models/dist')
|
import { cisFemaleAdult32 } from '../packages/models/dist/index.mjs'
|
||||||
const wb32 = models.withBreasts.size32
|
import { plugin as noVersions } from '../plugins/plugin-versionfree-svg/dist/index.mjs'
|
||||||
const noVersions = require('../plugins/plugin-versionfree-svg')
|
import { capitalize } from '../packages/core/src/utils.mjs'
|
||||||
let { capitalize } = require('../packages/core/src/utils.mjs')
|
import { plugin as theme } from '../plugins/plugin-theme/dist/index.mjs'
|
||||||
capitalize = capitalize.default
|
|
||||||
let theme = require('../plugins/plugin-theme/dist')
|
// when dependabot updates a dependency in a package.json, we want to update it in our dependencies.yaml
|
||||||
theme = theme.default
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
|
const __dirname = path.dirname(__filename)
|
||||||
|
|
||||||
const image = (pattern, option) => `
|
const image = (pattern, option) => `
|
||||||
|
|
||||||
|
@ -34,13 +35,13 @@ const insertImage = (file, pattern, option) => {
|
||||||
fs.writeFileSync(file, md + image(pattern, option))
|
fs.writeFileSync(file, md + image(pattern, option))
|
||||||
}
|
}
|
||||||
|
|
||||||
const createImages = () => {
|
const createImages = async () => {
|
||||||
for (const pattern of pi.list) {
|
for (const pattern in designs) {
|
||||||
if (true || pattern === 'unice') {
|
if (true || pattern === 'unice') {
|
||||||
const Pattern = require(`../designs/${pattern}/dist/index.js`)[capitalize(pattern)]
|
const Pattern = (await import(`../designs/${pattern}/dist/index.mjs`))[capitalize(pattern)]
|
||||||
for (const option of pi.options[pattern]) {
|
for (const option in Pattern.patternConfig.options) {
|
||||||
const p = new Pattern({
|
const p = new Pattern({
|
||||||
measurements: wb32,
|
measurements: cisFemaleAdult32,
|
||||||
settings: {
|
settings: {
|
||||||
idPrefix: `${pattern}_${option}`,
|
idPrefix: `${pattern}_${option}`,
|
||||||
embed: true,
|
embed: true,
|
||||||
|
@ -48,6 +49,8 @@ const createImages = () => {
|
||||||
})
|
})
|
||||||
.use(theme)
|
.use(theme)
|
||||||
.use(noVersions)
|
.use(noVersions)
|
||||||
|
.__init()
|
||||||
|
|
||||||
const file = path.join(
|
const file = path.join(
|
||||||
'markdown',
|
'markdown',
|
||||||
'org',
|
'org',
|
Loading…
Add table
Add a link
Reference in a new issue