[breaking]: FreeSewing v4 (#7297)
Refer to the CHANGELOG for all info. --------- Co-authored-by: Wouter van Wageningen <wouter.vdub@yahoo.com> Co-authored-by: Josh Munic <jpmunic@gmail.com> Co-authored-by: Jonathan Haas <haasjona@gmail.com>
This commit is contained in:
parent
d22fbe78d9
commit
51dc1d9732
6626 changed files with 142053 additions and 150606 deletions
|
@ -6,14 +6,15 @@ import chalk from 'chalk'
|
|||
import mustache from 'mustache'
|
||||
import conf from '../lerna.json' assert { type: 'json' }
|
||||
const { version } = conf
|
||||
import { software, publishedTypes as types, designs, plugins } from '../config/software/index.mjs'
|
||||
import { capitalize } from '../packages/core/src/index.mjs'
|
||||
import { software, publishedTypes as types, plugins } from '../config/software/index.mjs'
|
||||
import { collection } from '@freesewing/collection'
|
||||
import { capitalize } from '../packages/utils/src/index.mjs'
|
||||
|
||||
// Working directory
|
||||
const cwd = process.cwd()
|
||||
|
||||
/*
|
||||
* When we're building a site (on Vercel for example) SITEBUILD
|
||||
* When we're building a site (on Netlify for example) SITEBUILD
|
||||
* will be set and we'll do things differently to speed up the build.
|
||||
* To make that check easy, we setup this SITEBUILD variable
|
||||
*/
|
||||
|
@ -38,7 +39,6 @@ const repo = {
|
|||
pkg: readTemplateFile('package.dflt.json'),
|
||||
changelog: SITEBUILD ? null : readTemplateFile('changelog.dflt.md'),
|
||||
readme: SITEBUILD ? null : readTemplateFile('readme.dflt.md'),
|
||||
build: SITEBUILD ? null : readTemplateFile('build.dflt.mjs'),
|
||||
pluginTests: SITEBUILD ? null : readTemplateFile('plugin.test.mjs'),
|
||||
designTests: SITEBUILD ? null : readTemplateFile('design.test.mjs.mustache'),
|
||||
data: SITEBUILD ? null : readTemplateFile('data.dflt.mjs.mustache'),
|
||||
|
@ -85,7 +85,7 @@ if (!SITEBUILD) {
|
|||
if (validate()) log.write(chalk.green(' Done\n'))
|
||||
}
|
||||
|
||||
// Step 3: Generate package.json, pkg.mjs, README, and CHANGELOG
|
||||
// Step 3: Generate package.json, README, and CHANGELOG
|
||||
log.write(chalk.blueBright('Generating package-specific files...'))
|
||||
for (const pkg of Object.values(software)) {
|
||||
fs.writeFileSync(
|
||||
|
@ -94,15 +94,15 @@ for (const pkg of Object.values(software)) {
|
|||
)
|
||||
if (!SITEBUILD) {
|
||||
if (pkg.type !== 'site') {
|
||||
fs.writeFileSync(
|
||||
path.join(cwd, pkg.folder, pkg.name, 'data.mjs'),
|
||||
mustache.render(repo.templates.data, { name: fullName(pkg.name), version })
|
||||
)
|
||||
fs.writeFileSync(path.join(cwd, pkg.folder, pkg.name, 'README.md'), readme(pkg))
|
||||
if (repo.exceptions.customBuild.indexOf(pkg.name) === -1) {
|
||||
fs.writeFileSync(path.join(cwd, pkg.folder, pkg.name, 'build.mjs'), repo.templates.build)
|
||||
}
|
||||
fs.writeFileSync(path.join(cwd, pkg.folder, pkg.name, 'CHANGELOG.md'), changelog(pkg))
|
||||
if ([...collection, 'bonny'].includes(pkg.name)) {
|
||||
const aboutFile = path.join(cwd, 'designs', pkg.name, 'about.json')
|
||||
const about = JSON.parse(fs.readFileSync(aboutFile, 'utf-8'))
|
||||
about.version = version
|
||||
about.pkg = `@freesewing/${about.id}`
|
||||
fs.writeFileSync(aboutFile, JSON.stringify(about, null, 2))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ if (!SITEBUILD) fs.writeFileSync(path.join(repo.path, 'CHANGELOG.md'), changelog
|
|||
|
||||
// Step 5: Generate tests for designs and plugins
|
||||
if (!SITEBUILD) {
|
||||
for (const design in designs) {
|
||||
for (const design of collection) {
|
||||
fs.writeFileSync(
|
||||
path.join(repo.path, 'designs', design, 'tests', 'shared.test.mjs'),
|
||||
mustache.render(repo.templates.designTests, { name: design, Name: capitalize(design) })
|
||||
|
@ -127,47 +127,6 @@ if (!SITEBUILD) {
|
|||
}
|
||||
}
|
||||
|
||||
// Step 6: Create file with all design translations
|
||||
fs.writeFileSync(
|
||||
path.join(repo.path, 'sites', 'shared', 'i18n', 'designs.mjs'),
|
||||
`/*
|
||||
* This file is auto-generated by the reconfigure script
|
||||
* Any changes will be overwritten next time the repo is reconfigured
|
||||
*/
|
||||
` +
|
||||
Object.keys(designs)
|
||||
.map((design) => `import { i18n as ${design} } from '@freesewing/${design}'`)
|
||||
.join('\n') +
|
||||
`
|
||||
|
||||
export const designs = {
|
||||
` +
|
||||
Object.keys(designs)
|
||||
.map((design) => ` ${design},`)
|
||||
.join('\n') +
|
||||
`
|
||||
}
|
||||
`
|
||||
)
|
||||
|
||||
// Step 7: Create use-design hooks
|
||||
for (const site of ['org']) {
|
||||
fs.writeFileSync(
|
||||
path.join(repo.path, 'sites', site, 'hooks', 'use-design.mjs'),
|
||||
mustache.render(
|
||||
fs.readFileSync(
|
||||
path.join(repo.path, 'config', 'templates', 'use-design.mjs.mustache'),
|
||||
'utf-8'
|
||||
),
|
||||
{
|
||||
designs: Object.keys(designs)
|
||||
.filter((name) => designs[name][site])
|
||||
.map((name) => ({ name, Name: capitalize(name) })),
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// All done
|
||||
log.write(chalk.green(' All done\n'))
|
||||
process.exit()
|
||||
|
@ -262,19 +221,6 @@ function scripts(pkg) {
|
|||
}
|
||||
}
|
||||
|
||||
// make windows versions of build prebuild scripts
|
||||
runScripts.wbuild = runScripts.wbuild || runScripts.build
|
||||
runScripts.prewbuild = runScripts.prewbuild || runScripts.prebuild
|
||||
|
||||
// make prebuild:all and windows versions of build:all and prebuild:all
|
||||
if (runScripts['build:all'] !== undefined) {
|
||||
runScripts['wbuild:all'] = runScripts['wbuild:all'] || (runScripts.wbuild && 'yarn wbuild')
|
||||
runScripts['prebuild:all'] =
|
||||
runScripts['prebuild:all'] || (runScripts.prebuild && 'yarn prebuild')
|
||||
runScripts['prewbuild:all'] =
|
||||
runScripts['prewbuild:all'] || (runScripts.prewbuild && 'yarn prewbuild')
|
||||
}
|
||||
|
||||
return runScripts
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue