diff --git a/packages/new-design/lib/cli.mjs b/packages/new-design/lib/cli.mjs
index 1b594864f12..2074e96e59e 100644
--- a/packages/new-design/lib/cli.mjs
+++ b/packages/new-design/lib/cli.mjs
@@ -11,6 +11,6 @@ export const cli = async () => {
// Get user input
const choices = await getChoices()
- // Create environment from template
+ // Create environment
createEnvironment(choices)
}
diff --git a/packages/new-design/lib/config.mjs b/packages/new-design/lib/config.mjs
index 42c9b7d3f47..dfa0b7f1b24 100644
--- a/packages/new-design/lib/config.mjs
+++ b/packages/new-design/lib/config.mjs
@@ -4,7 +4,7 @@ export const config = {
// Whether we're publishing next or latest tags
tag: 'next',
// Minimum node version
- node: 16,
+ node: 18,
// Site to download from
fileUri: 'https://raw.githubusercontent.com',
// Repository to download from
@@ -19,7 +19,7 @@ export const config = {
'workbench',
'errors',
'i18n',
- 'lab',
+ 'sde',
'measurements',
'optiongroups',
'o_bella',
@@ -54,8 +54,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
-# e2e test results
-playwright-report
`,
fetch: {
config: [
@@ -65,176 +63,161 @@ playwright-report
},
],
sites: [
- 'shared/utils.mjs',
- 'shared/designs/index.js',
- 'shared/config/freesewing.mjs',
+ {
+ from: 'sde/env.local',
+ to: 'sde/.env.local',
+ },
+ 'sde/i18n.config.mjs',
+ 'sde/next-i18next.config.js',
+ 'sde/next.config.mjs',
+ 'sde/package.json',
+ 'sde/postcss.config.js',
+ 'sde/site.config.mjs',
+ 'sde/tailwind.config.mjs',
+ 'sde/hooks/use-design.mjs',
+ 'sde/components/dynamic-org-docs.mjs',
+ 'sde/components/feeds.mjs',
+ 'sde/components/search.mjs',
+ 'sde/components/header/design-picker.mjs',
+ 'sde/components/header/index.mjs',
+ 'sde/components/navigation/modal-menu.mjs',
+ 'sde/components/layouts/bare.mjs',
+ 'sde/components/layouts/default.mjs',
+ 'sde/components/layouts/workbench.mjs',
+ 'sde/components/wrappers/page.mjs',
+ 'sde/design/from-bent/src/back.mjs',
+ 'sde/design/from-bent/src/front.mjs',
+ 'sde/design/from-bent/src/index.mjs',
+ 'sde/design/from-bent/src/top-sleeve.mjs',
+ 'sde/design/from-bent/src/under-sleeve.mjs',
+ 'sde/design/from-bent/i18n/de.json',
+ 'sde/design/from-bent/i18n/en.json',
+ 'sde/design/from-bent/i18n/es.json',
+ 'sde/design/from-bent/i18n/fr.json',
+ 'sde/design/from-bent/i18n/index.mjs',
+ 'sde/design/from-bent/i18n/nl.json',
+ 'sde/design/from-bent/i18n/uk.json',
+ 'sde/design/from-bella/en.json',
+ 'sde/design/from-bella/src/back.mjs',
+ 'sde/design/from-bella/src/front.mjs',
+ 'sde/design/from-bella/src/index.mjs',
+ 'sde/design/from-bella/i18n/de.json',
+ 'sde/design/from-bella/i18n/en.json',
+ 'sde/design/from-bella/i18n/es.json',
+ 'sde/design/from-bella/i18n/fr.json',
+ 'sde/design/from-bella/i18n/index.mjs',
+ 'sde/design/from-bella/i18n/nl.json',
+ 'sde/design/from-bella/i18n/uk.json',
+ 'sde/design/from-breanna/src/back.mjs',
+ 'sde/design/from-breanna/src/front.mjs',
+ 'sde/design/from-breanna/src/index.mjs',
+ 'sde/design/from-breanna/src/sleeve.mjs',
+ 'sde/design/from-breanna/i18n/de.json',
+ 'sde/design/from-breanna/i18n/en.json',
+ 'sde/design/from-breanna/i18n/es.json',
+ 'sde/design/from-breanna/i18n/fr.json',
+ 'sde/design/from-breanna/i18n/index.mjs',
+ 'sde/design/from-breanna/i18n/nl.json',
+ 'sde/design/from-breanna/i18n/uk.json',
+ 'sde/design/from-brian/i18n/de.json',
+ 'sde/design/from-brian/i18n/en.json',
+ 'sde/design/from-brian/i18n/es.json',
+ 'sde/design/from-brian/i18n/fr.json',
+ 'sde/design/from-brian/i18n/index.mjs',
+ 'sde/design/from-brian/i18n/nl.json',
+ 'sde/design/from-brian/i18n/uk.json',
+ 'sde/design/from-brian/src/back.mjs',
+ 'sde/design/from-brian/src/front.mjs',
+ 'sde/design/from-brian/src/index.mjs',
+ 'sde/design/from-brian/src/sleeve.mjs',
+ 'sde/design/from-titan/i18n/de.json',
+ 'sde/design/from-titan/i18n/en.json',
+ 'sde/design/from-titan/i18n/es.json',
+ 'sde/design/from-titan/i18n/fr.json',
+ 'sde/design/from-titan/i18n/index.mjs',
+ 'sde/design/from-titan/i18n/nl.json',
+ 'sde/design/from-titan/i18n/uk.json',
+ 'sde/design/from-titan/src/back.mjs',
+ 'sde/design/from-titan/src/front.mjs',
+ 'sde/design/from-titan/src/index.mjs',
+ 'sde/design/from-scratch/i18n/de.json',
+ 'sde/design/from-scratch/i18n/en.json',
+ 'sde/design/from-scratch/i18n/es.json',
+ 'sde/design/from-scratch/i18n/fr.json',
+ 'sde/design/from-scratch/i18n/index.mjs',
+ 'sde/design/from-scratch/i18n/nl.json',
+ 'sde/design/from-scratch/i18n/uk.json',
+ 'sde/design/from-scratch/src/index.mjs',
+ 'sde/design/from-scratch/src/scratch.mjs',
+ 'sde/design/tutorial/i18n/de.json',
+ 'sde/design/tutorial/i18n/en.json',
+ 'sde/design/tutorial/i18n/es.json',
+ 'sde/design/tutorial/i18n/fr.json',
+ 'sde/design/tutorial/i18n/index.mjs',
+ 'sde/design/tutorial/i18n/nl.json',
+ 'sde/design/tutorial/i18n/uk.json',
+ 'sde/design/tutorial/src/bib.mjs',
+ 'sde/design/tutorial/src/index.mjs',
+ 'sde/public/brands/algolia.svg',
+ 'sde/public/brands/bugsnag.svg',
+ 'sde/public/brands/crowdin.svg',
+ 'sde/public/brands/netlify.svg',
+ 'sde/public/brands/vercel.svg',
+ 'sde/pages/_app.mjs',
+ 'sde/pages/design.mjs',
+ 'sde/pages/index.mjs',
+ 'sde/pages/support.mjs',
+ 'sde/pages/code/index.mjs',
+ 'sde/pages/design/[design].mjs',
+ 'sde/pages/docs/index.mjs',
+ 'sde/pages/sde/en.yaml',
+ 'sde/pages/sde/index.mjs',
+ 'sde/pages/sets/[id].mjs',
+ 'sde/pages/signup/index.mjs',
+ 'sde/pages/patterns/index.mjs',
+ 'sde/pages/patterns/[id]/edit.mjs',
+ 'sde/pages/patterns/[id]/index.mjs',
+ 'sde/pages/signin/index.mjs',
+ 'sde/pages/signin/callback/[provider].mjs',
+ 'sde/pages/account/[platform].mjs',
+ 'sde/pages/account/bio.mjs',
+ 'sde/pages/account/compare.mjs',
+ 'sde/pages/account/consent.mjs',
+ 'sde/pages/account/control.mjs',
+ 'sde/pages/account/email.mjs',
+ 'sde/pages/account/export.mjs',
+ 'sde/pages/account/github.mjs',
+ 'sde/pages/account/img.mjs',
+ 'sde/pages/account/index.mjs',
+ 'sde/pages/account/language.mjs',
+ 'sde/pages/account/mfa.mjs',
+ 'sde/pages/account/newsletter.mjs',
+ 'sde/pages/account/password.mjs',
+ 'sde/pages/account/privacy.mjs',
+ 'sde/pages/account/reload.mjs',
+ 'sde/pages/account/remove.mjs',
+ 'sde/pages/account/restrict.mjs',
+ 'sde/pages/account/units.mjs',
+ 'sde/pages/account/username.mjs',
+ 'sde/pages/account/apikeys/[id].mjs',
+ 'sde/pages/account/apikeys/index.mjs',
+ 'sde/pages/account/bookmarks/[id].mjs',
+ 'sde/pages/account/bookmarks/index.mjs',
+ 'sde/pages/account/sets/[id].mjs',
+ 'sde/pages/account/sets/index.mjs',
+ 'sde/pages/account/patterns/index.mjs',
+ 'sde/pages/account/patterns/[id]/edit.mjs',
+ 'sde/pages/account/patterns/[id]/index.mjs',
+ 'shared/config/cloudflare.mjs',
+ 'shared/config/designs.mjs',
+ 'shared/config/freesewing.config.mjs',
'shared/config/i18n.config.mjs',
'shared/config/next.mjs',
+ 'shared/config/paypal.mjs',
+ 'shared/config/playwright.mjs',
'shared/config/postcss.config.js',
'shared/config/tailwind-force.html',
- 'shared/config/tailwind.config.js',
- 'shared/hooks/useGist.mjs',
- 'shared/hooks/useLocalStorage.mjs',
- 'shared/hooks/useTheme.mjs',
- 'shared/mdx/compiler.mjs',
- 'shared/mdx/loader.mjs',
- 'shared/mdx/mdx-plugin-toc.mjs',
- 'shared/mdx/remark-intro-plugin.mjs',
- 'shared/strapi/loader.js',
- 'shared/strapi/qa.mjs',
- 'shared/themes/dark.js',
- 'shared/themes/hax0r.js',
- 'shared/themes/index.js',
- 'shared/themes/lgbtq.js',
- 'shared/themes/light.js',
- 'shared/themes/runtime.mjs',
- 'shared/styles/code.css',
- 'shared/styles/globals.css',
- 'shared/styles/svg-freesewing-draft.css',
- 'shared/prebuild/contributors.mjs',
- 'shared/prebuild/feed.mjs',
- 'shared/prebuild/i18n-only.mjs',
- 'shared/prebuild/i18n.mjs',
- 'shared/prebuild/index.mjs',
- 'shared/prebuild/lab.mjs',
- 'shared/prebuild/md-intro.mjs',
- 'shared/prebuild/mdx.mjs',
- 'shared/prebuild/navigation.mjs',
- 'shared/prebuild/patrons.mjs',
- 'shared/prebuild/strapi.mjs',
- 'shared/prebuild/og/index.mjs',
- 'shared/components/breadcrumbs.mjs',
- 'shared/components/code.mjs',
- 'shared/components/copy-to-clipboard.mjs',
- 'shared/components/docs-link.mjs',
- 'shared/components/icons.mjs',
- 'shared/components/json.mjs',
- 'shared/components/lightbox.mjs',
- 'shared/components/loader.mjs',
- 'shared/components/modal.mjs',
- 'shared/components/link.mjs',
- 'shared/components/picker.mjs',
- 'shared/components/popout.mjs',
- 'shared/components/raw-span.mjs',
- 'shared/components/ribbon.mjs',
- 'shared/components/spinner.mjs',
- 'shared/components/web-link.mjs',
- 'shared/components/wordmark.mjs',
- 'shared/components/worm.mjs',
- 'shared/components/yaml.mjs',
- 'shared/components/error/error-boundary.mjs',
- 'shared/components/error/reset-buttons.mjs',
- 'shared/components/error/view.mjs',
- 'shared/components/icons/flip.js',
- 'shared/components/icons/rotate.js',
- 'shared/components/locale-picker/index.mjs',
- 'shared/components/locale-picker/locales.de.yaml',
- 'shared/components/locale-picker/locales.en.yaml',
- 'shared/components/locale-picker/locales.es.yaml',
- 'shared/components/locale-picker/locales.fr.yaml',
- 'shared/components/locale-picker/locales.nl.yaml',
- 'shared/components/logos/cc-by.mjs',
- 'shared/components/logos/cc.mjs',
- 'shared/components/logos/freesewing.mjs',
- 'shared/components/logos/osi.mjs',
- 'shared/components/mdx/figure.mjs',
- 'shared/components/mdx/highlight.mjs',
- 'shared/components/mdx/http.mjs',
- 'shared/components/mdx/index.mjs',
- 'shared/components/mdx/mermaid.mjs',
- 'shared/components/mdx/prev-next.mjs',
- 'shared/components/mdx/read-more.mjs',
- 'shared/components/mdx/tabbed-example.mjs',
- 'shared/components/mdx/tabs.mjs',
- 'shared/components/mdx/youtube.mjs',
- 'shared/components/navigation/aside.mjs',
- 'shared/components/navigation/primary.mjs',
- 'shared/components/robot/index.mjs',
- 'shared/components/robot/poses.mjs',
- 'shared/components/theme-picker/index.mjs',
- 'shared/components/theme-picker/themes.de.yaml',
- 'shared/components/theme-picker/themes.en.yaml',
- 'shared/components/theme-picker/themes.es.yaml',
- 'shared/components/theme-picker/themes.fr.yaml',
- 'shared/components/theme-picker/themes.nl.yaml',
- 'shared/components/wrappers/img.mjs',
- 'shared/components/wrappers/mdx.mjs',
- 'shared/components/wrappers/page.mjs',
- 'shared/components/wrappers/toc.mjs',
- 'shared/components/wrappers/workbench.mjs',
- 'shared/components/workbench/gist.mjs',
- 'shared/components/workbench/logs.mjs',
- 'shared/components/workbench/preloaders.mjs',
- 'shared/components/workbench/sample.mjs',
- 'shared/components/workbench/edit/index.mjs',
- 'shared/components/workbench/edit/gist-validator.mjs',
- 'shared/components/workbench/exporting/export-handler.mjs',
- 'shared/components/workbench/exporting/export-worker.js',
- 'shared/components/workbench/exporting/index.mjs',
- 'shared/components/workbench/exporting/pdf-maker.mjs',
- 'shared/components/workbench/inputs/design-option-count.mjs',
- 'shared/components/workbench/inputs/design-option-list.mjs',
- 'shared/components/workbench/inputs/design-option-pct-deg.mjs',
- 'shared/components/workbench/inputs/measurement.mjs',
- 'shared/components/workbench/measurements/index.mjs',
- 'shared/components/workbench/draft/circle.mjs',
- 'shared/components/workbench/draft/defs.mjs',
- 'shared/components/workbench/draft/error.mjs',
- 'shared/components/workbench/draft/index.mjs',
- 'shared/components/workbench/draft/part.mjs',
- 'shared/components/workbench/draft/path.mjs',
- 'shared/components/workbench/draft/point.mjs',
- 'shared/components/workbench/draft/snippet.mjs',
- 'shared/components/workbench/draft/stack.mjs',
- 'shared/components/workbench/draft/svg.mjs',
- 'shared/components/workbench/draft/text.mjs',
- 'shared/components/workbench/draft/utils.mjs',
- 'shared/components/workbench/layout/default.mjs',
- 'shared/components/workbench/layout/cut/index.mjs',
- 'shared/components/workbench/layout/cut/plugin-cut-layout.mjs',
- 'shared/components/workbench/layout/cut/settings.mjs',
- 'shared/components/workbench/layout/print/index.mjs',
- 'shared/components/workbench/layout/print/orientation-picker.mjs',
- 'shared/components/workbench/layout/print/pagesize-picker.mjs',
- 'shared/components/workbench/layout/plugin-layout-part.mjs',
- 'shared/components/workbench/layout/print/settings.mjs',
- 'shared/components/workbench/layout/draft/buttons.mjs',
- 'shared/components/workbench/layout/draft/index.mjs',
- 'shared/components/workbench/layout/draft/stack.mjs',
- 'shared/components/workbench/menu/index.mjs',
- 'shared/components/workbench/menu/view.mjs',
- 'shared/components/workbench/menu/design-options/index.mjs',
- 'shared/components/workbench/menu/design-options/option-group.mjs',
- 'shared/components/workbench/menu/design-options/option-input.mjs',
- 'shared/components/workbench/menu/design-options/option-value.mjs',
- 'shared/components/workbench/menu/design-options/option.mjs',
- 'shared/components/workbench/menu/test-design-options/index.mjs',
- 'shared/components/workbench/menu/test-design-options/option.mjs',
- 'shared/components/workbench/menu/core-settings/core-setting-bool.mjs',
- 'shared/components/workbench/menu/core-settings/core-setting-list.mjs',
- 'shared/components/workbench/menu/core-settings/core-setting-mm.mjs',
- 'shared/components/workbench/menu/core-settings/core-setting-nr.mjs',
- 'shared/components/workbench/menu/core-settings/core-setting-only.mjs',
- 'shared/components/workbench/menu/core-settings/core-setting-sa-bool.mjs',
- 'shared/components/workbench/menu/core-settings/core-setting-sa-mm.mjs',
- 'shared/components/workbench/menu/core-settings/index.mjs',
- 'shared/components/workbench/menu/core-settings/setting.mjs',
- 'shared/components/workbench/menu/xray/attributes.mjs',
- 'shared/components/workbench/menu/xray/disable.mjs',
- 'shared/components/workbench/menu/xray/index.mjs',
- 'shared/components/workbench/menu/xray/list.mjs',
- 'shared/components/workbench/menu/xray/log.mjs',
- 'shared/components/workbench/menu/xray/path-ops.mjs',
- 'shared/components/workbench/menu/xray/path.mjs',
- 'shared/components/workbench/menu/xray/point.mjs',
- 'shared/components/workbench/menu/xray/reset.mjs',
- 'lab/components/about.mjs',
- 'lab/components/design-picker.mjs',
- 'lab/components/header.mjs',
- 'lab/components/layouts/bare.mjs',
- 'lab/components/layouts/lab.mjs',
- 'lab/components/wrappers/layout.mjs',
- 'lab/components/wrappers/page.mjs',
+ 'shared/config/tailwind.config.mjs',
],
},
}
diff --git a/packages/new-design/lib/utils.mjs b/packages/new-design/lib/utils.mjs
index 08bb47b153c..2d2b6c9152e 100644
--- a/packages/new-design/lib/utils.mjs
+++ b/packages/new-design/lib/utils.mjs
@@ -24,7 +24,7 @@ const nl = '\n'
const tab = ' '
const nlt = nl + tab
-// Checks for node 16 or higher
+// Checks for node 18 or higher
export const checkNodeVersion = () => {
const node_version = process.version.slice(1).split('.')[0]
if (parseInt(node_version) < config.node) {
@@ -47,70 +47,24 @@ export const checkNodeVersion = () => {
}
}
-// Helper method to validate the design name
-const validateDesignName = (name) => {
- if (/^([a-z][a-z0-9_]*)$/.test(name)) return true
- else
- return ' ๐ Please use only lowercase letters, digits, or underscores. Names must start with a lowercase letter. ๐คท'
-}
-
// Gets user input to figure out what to do
export const getChoices = async () => {
- const { template } = await prompts({
- type: 'select',
- name: 'template',
- message: 'What template would you like to use? ๐',
- choices: [
- { title: 'Tutorial', value: 'tutorial', description: 'Setup the pattern design tutorial' },
- { title: 'From Scratch', value: 'scratch', description: 'Create a design from scratch' },
- {
- title: 'Extend Brian',
- value: 'brian',
- description: 'Extend the Brian design (basic torso block for menswear)',
- },
- {
- title: 'Extend Bent',
- value: 'bent',
- description: 'Extend the Bent design (like brian with added two-part sleeve)',
- },
- {
- title: 'Extend Bella',
- value: 'bella',
- description: 'Extend the Bella design (womenswear torso block)',
- },
- {
- title: 'Extend Breanna',
- value: 'breanna',
- description: 'Extend the Breanna design (womenswear torso block - YMMV)',
- },
- {
- title: 'Extend Titan',
- value: 'titan',
- description: 'Extend the Titan design (gender-neutral trouser block)',
- },
- ],
- initial: 0,
- })
-
let finalName = false // we're going to use this to track whether we stay in the naming loop
let overwrite = true // should we overwrite existing files?
- const cwd = process.cwd()
let name // name will go here
+ let sideStep // allows to do something custom
+ const cwd = process.cwd()
// while we're not finalized on a name
while (finalName === false) {
// request a name
- name =
- template === 'tutorial' && name === undefined
- ? 'tutorial'
- : (
- await prompts({
- type: 'text',
- name: 'name',
- message: 'What name would you like the design to have? ๐ท๏ธ ([a-z0-9_] only)',
- validate: validateDesignName,
- })
- ).name
+ name = (
+ await prompts({
+ type: 'text',
+ name: 'name',
+ message: 'Give a folder name in which we can setup the development environment? ๐ท๏ธ ',
+ })
+ ).name
// check whether a folder with that name already exists
const dest = join(cwd, name)
@@ -127,19 +81,28 @@ export const getChoices = async () => {
const { nextStep } = await prompts({
type: 'select',
name: 'nextStep',
- message:
- 'It looks like you already have a design by that name in progress. What should we do?',
+ message: 'It looks like that folder already exists. What should we do?',
choices: [
- { title: 'Rename', value: 'rename', description: 'Choose a new name for this design' },
- { title: 'Overwrite', value: 'overwrite', description: 'Overwrite the existing design' },
+ { title: 'Go back', value: 'rename', description: 'Choose a different folder name' },
+ {
+ title: 'Overwrite',
+ value: 'overwrite',
+ description: 'Overwrite the contents in the existing folder',
+ },
{
title: 'Re-initialize',
value: 'reinit',
description:
- "Bring in a fresh workbench, but don't overwrite existing design files (useful for updating to the latest dev environment)",
+ 'Re-install depenencies, and update the development environment in this folder',
+ },
+ {
+ title: 'Re-download',
+ value: 'redownload',
+ description: 'Update the development environment in this folder',
},
],
})
+ sideStep = nextStep
// if they said rename, we loop again. otherwise
if (nextStep !== 'rename') {
@@ -160,7 +123,7 @@ export const getChoices = async () => {
initial: 0,
})
- return { template, name, manager, overwrite }
+ return { name, manager, overwrite, sideStep }
}
const capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1)
@@ -209,111 +172,6 @@ const copyFileOrTemplate = async (
}
}
-// Template the package.json
-const copyPackageJson = async (config, choices) => {
- const packageJsonTemplate = await readFile(
- config.relativeFiles.templates['package.json'],
- 'utf-8'
- )
-
- await copyFileOrTemplate(packageJsonTemplate, config.dest, 'package.json', {
- name: choices.name,
- tag: config.tag,
- dependencies: config.templateData.dependencies,
- includeTests: choices.includeTests,
- })
-}
-
-// Template the design index file
-const copyIndexFile = async (config, choices) => {
- // Template the index file
- const indexTemplate = await readFile(config.relativeFiles.templates['index'], 'utf-8')
-
- // get the part names based on how they are given in the configuration
- const partNames = config.complexParts
- ? config.templateData.parts.map((p) => p.part)
- : config.templateData.parts
- // write the file
- await copyFileOrTemplate(
- indexTemplate,
- config.dest,
- `${designSrcDir}/index.mjs`,
- {
- name: choices.name,
- Name: capitalize(choices.name),
- parts: partNames,
- },
- choices.overwrite
- )
-}
-
-// Template the part files
-const copyPartFiles = async (config, choices) => {
- // Template the parts
- const partTemplate = await readFile(config.relativeFiles.templates.part, 'utf-8')
- // does this design inherit from another?
- const doesInherit = !config.templateData.noInheritance
-
- // all part templates need these arguments
- const baseConfig = {
- name: choices.name, // the name of the design
- doesInherit, // whether it's an inherited design
- draftUses: {}, // what parameters need to be uncommented in the draft method (default none because part is always uncommented)
- }
-
- // if it inherits, we also need the name of the design it inherits from
- if (doesInherit) {
- baseConfig.baseName = choices.template
- baseConfig.BaseName = capitalize(choices.template)
- }
-
- // for each part
- return config.templateData.parts.map((p) => {
- // set up the arguments based on what's in the part's config
- const templateArgs = config.complexParts
- ? {
- ...baseConfig,
- ...p,
- }
- : {
- ...baseConfig,
- part: p,
- }
-
- // add an uppercase version of the partName
- templateArgs.Part = capitalize(templateArgs.part)
-
- // write the part file
- return copyFileOrTemplate(
- partTemplate,
- config.dest,
- `${designSrcDir}/${templateArgs.part}.mjs`,
- templateArgs,
- choices.overwrite
- )
- })
-}
-
-// Helper method to copy template files
-const copyAll = async (config, choices) => {
- let promises = []
-
- // Copy shared files
- promises = promises.concat(
- config.relativeFiles.shared.map((from) => {
- if (choices.includeTests || !from.match(/e2e|playwright/))
- copyFileOrTemplate(config.source.shared, config.dest, from)
- })
- )
-
- // template design files
- promises.push(copyPackageJson(config, choices))
- promises.push(copyIndexFile(config, choices))
- promises = promises.concat(copyPartFiles(config, choices))
-
- await Promise.all(promises)
-}
-
// Helper method to run [yarn|npm] install
const installDependencies = async (config, choices) =>
await execa(`${choices.manager} install`, {
@@ -322,22 +180,28 @@ const installDependencies = async (config, choices) =>
})
// Helper method to download web environment
-const downloadLabFiles = async (config) => {
+const downloadFiles = async (config) => {
const promises = []
for (const dir in config.fetch) {
promises.push(
...config.fetch[dir].map(async (file) => {
- const to = typeof file === 'string' ? join(config.dest, file) : join(config.dest, file.to)
+ const to =
+ typeof file === 'string'
+ ? join(config.dest, file.slice(0, 4) === 'sde/' ? file.slice(4) : file)
+ : join(config.dest, file.to)
await ensureDir(to)
+ const url = `${config.fileUri}/${config.repo}/${config.branch}/${dir}/${
+ typeof file === 'string' ? file : file.from
+ }`
try {
- const res = await axios.get(
- `${config.fileUri}/${config.repo}/${config.branch}/${dir}/${
- typeof file === 'string' ? file : file.from
- }`
+ const res = await axios.get(url)
+ await writeFile(
+ to,
+ typeof res.data === 'object' ? JSON.stringify(res.data, null, 2) : res.data
)
- await writeFile(to, res.data)
} catch (err) {
- console.log(err)
+ if (err.response?.status === 404) console.log(`404: ${url}`)
+ else console.log(err)
}
})
)
@@ -351,7 +215,7 @@ const initGitRepo = async (config, choices) => {
await copyFileOrTemplate(config.gitignore, config.dest, '.gitignore', {}, choices.overwrite)
return execa(
- `git init -b main && git add . && git commit -m ":tada: Initialized ${choices.name} repository"`,
+ `git init -b main && git add . && git commit -m ":tada: Initialized FreeSewing stand-alone development environment"`,
{
cwd: config.dest,
shell: true,
@@ -360,13 +224,13 @@ const initGitRepo = async (config, choices) => {
}
// Tips
-const showTips = (config, choices) => {
+const showTips = (config, choices) =>
console.log(`
- All done ๐ค Your new design ${chalk.yellow.bold(
- choices.name
- )} was initialized in: ${chalk.green.bold(config.dest)}
+ All done ๐ค Your FreeSewing development environment was initialized in: ${chalk.green.bold(
+ config.dest
+ )}
- The code for your design is in the ${chalk.yellow.bold('design')} folder.
+ The templates for various designs are in the ${chalk.yellow.bold('design')} folder.
The other files and folders are the development environment. You can safely ignore those.
To start your development environment, follow these three steps:
@@ -377,41 +241,12 @@ const showTips = (config, choices) => {
)}
3) Now open your browser and navigate to ${chalk.green('http://localhost:8000/')}
- ${chalk.bold.yellow('๐ค More info & help')}
- ${chalk.gray('โกโกโกโกโกโกโกโกโกโกโกโกโกโกโกโกโกโกโก')}`)
-
- if (choices.template === 'tutorial')
- console.log(`
- Our pattern design tutorial is available at: ${chalk.green(
- 'https://freesewing.dev/tutorials/pattern-design'
- )}
-
- It will walk your through the process step by step.
- If you get stuck, reach out to our community on Discord: ${chalk.green(
- 'https://discord.freesewing.dev/'
- )}
- The ${chalk.bold('development-help')} channel is a good place to ask questions
-
- Don't be shy to reach out. If something is not clear, that's on us, not on you.
- So your feedback really helps us improve our tutorial/documentation.
-
- Thanks for giving FreeSewing a shot. We hope you'll ๐ it.
+ Thanks for giving FreeSewing a shot. I hope you'll ๐ it.
Have fun ๐ค
- `)
- else
- console.log(`
- FreeSewing's documentation for developers is available at: ${chalk.green(
- 'https://freesewing.dev/'
- )}
-
- Our community is on Discord: ${chalk.green('https://discord.freesewing.dev/')}
- The ${chalk.bold('development-help')} channel is a good place to ask for help if you get stuck
-
- Happy hacking ๐ค
- `)
-}
+ joost
+`)
// Creates the environment based on the user's choices
export const createEnvironment = async (choices) => {
@@ -423,87 +258,60 @@ export const createEnvironment = async (choices) => {
shared: join(newDesignDir, `shared`),
}
- // Create target directory
- await mkdir(config.dest, { recursive: true })
-
- // get the template files in a dictionary
- const templates = {}
- const templateFiles = await rdir(config.source.templates)
- templateFiles.forEach((file) => {
- const relativeName = relative(config.source.templates, file).replace(/(\.mjs)*\.mustache/, '')
- templates[relativeName] = file
- })
-
- config.relativeFiles = {
- templates,
- shared: (await rdir(config.source.shared)).map((file) => relative(config.source.shared, file)),
- }
-
- config.templateData = await import(pathToFileURL(config.source.templateData))
- // does this base have parts with a lot of attending config?
- config.complexParts = typeof config.templateData.parts[0] === 'object'
-
// Output a linebreak
console.log()
- // Copy/Template files
+ // Download files from GitHub
try {
- await oraPromise(copyAll(config, choices), {
+ await oraPromise(downloadFiles(config), {
text:
- chalk.white.bold('๐จโฌโฌโฌ Copying template files') +
- chalk.white.dim(' | Just a moment'),
- successText: chalk.white.bold('๐ฉโฌโฌโฌ Copied template files'),
- failText: chalk.white.bold(
- '๐ฅโฌโฌโฌ Failed to copy template files | Development environment will not function'
- ),
- })
- } catch (err) {
- console.log(err)
- }
-
- // Install dependencies
- try {
- await oraPromise(installDependencies(config, choices), {
- text:
- chalk.white.bold('๐ฉ๐จโฌโฌ Installing dependencies') +
- chalk.white.dim(' | Please wait, this will take a while'),
- successText: chalk.white.bold('๐ฉ๐ฉโฌโฌ Installed dependencies'),
- failText: chalk.white.bold(
- '๐ฉ๐ฅโฌโฌ Failed to install dependencies | Development environment will not function'
- ),
- })
- } catch (err) {
- /* no feedback here */
- }
-
- // Fetch web components
- try {
- await oraPromise(downloadLabFiles(config), {
- text:
- chalk.white.bold('๐ฉ๐ฉ๐จโฌ Downloading web components') +
+ chalk.white.bold('๐งโฌโฌ Downloading components from GitHub') +
chalk.white.dim(' | Almost there'),
- successText: chalk.white.bold('๐ฉ๐ฉ๐ฉโฌ Downloaded web components'),
+ successText: chalk.white.bold('๐ฉโฌโฌ Downloaded components from GitHub'),
failText: chalk.white.bold(
- '๐ฉ๐ฉ๐ฅโฌ Failed to download web components | Development environment will not function'
+ '๐ฅโฌโฌ Failed to download components from GitHub | The development environment will not function'
),
})
} catch (err) {
+ console.log(err)
/* no feedback here */
}
- // Initialize git repository
- try {
- await oraPromise(initGitRepo(config, choices), {
- text:
- chalk.white.bold('๐ฉ๐ฉ๐ฉโฌ Initializing git repository') +
- chalk.white.dim(' | You have git, right?'),
- successText: chalk.white.bold('๐ฉ๐ฉ๐ฉ๐ฉ Initialized git repository'),
- failText:
- chalk.white.bold('๐ฉ๐ฉ๐ฉ๐ฅ Failed to initialize git repository') +
- chalk.white.dim(' | This does not stop you from developing your design'),
- })
- } catch (err) {
- console.log(err)
+ if (!choices.sideStep) {
+ // Create target directory
+ await mkdir(config.dest, { recursive: true })
+
+ // Install dependencies
+ try {
+ await oraPromise(installDependencies(config, choices), {
+ text:
+ chalk.white.bold('๐ฉ๐งโฌ Installing dependencies') +
+ chalk.white.dim(' | Please wait, this will take a while'),
+ successText: chalk.white.bold('๐ฉ๐ฉโฌ Installed dependencies'),
+ failText: chalk.white.bold(
+ '๐ฉ๐ฅโฌ Failed to install dependencies | The development environment will not function'
+ ),
+ })
+ } catch (err) {
+ /* no feedback here */
+ }
+ }
+
+ if (!choices.sideStep) {
+ // Initialize git repository
+ try {
+ await oraPromise(initGitRepo(config, choices), {
+ text:
+ chalk.white.bold('๐ฉ๐ฉ๐ง Initializing git repository') +
+ chalk.white.dim(' | You have git, right?'),
+ successText: chalk.white.bold('๐ฉ๐ฉ๐ฉ Initialized git repository'),
+ failText:
+ chalk.white.bold('๐ฉ๐ฉ๐ฅ Failed to initialize git repository') +
+ chalk.white.dim(' | This does not stop the development environment from functioning'),
+ })
+ } catch (err) {
+ console.log(err)
+ }
}
// All done. Show tips
diff --git a/packages/new-design/scripts/filelist.mjs b/packages/new-design/scripts/filelist.mjs
index 75880d0c724..117f6da32d3 100644
--- a/packages/new-design/scripts/filelist.mjs
+++ b/packages/new-design/scripts/filelist.mjs
@@ -2,16 +2,25 @@ import rdir from 'recursive-readdir'
import path from 'path'
const ignore = [
- 'package.json',
'node_modules',
'.eslint',
'.gitignore',
'.md',
- 'lab/components/header.js',
- 'lab/components/help-us.js',
- 'lab/components/search.js',
- 'lab/components/footer.js',
+ '.next',
+ 'prebuild.mjs',
+ 'prebuild',
+ 'public/locales',
'shared/config/measurements.js',
+ 'sde/public/android-chrome-192x192.png',
+ 'sde/public/android-chrome-384x384.png',
+ 'sde/public/apple-touch-icon.png',
+ 'sde/public/browserconfig.xml',
+ 'sde/public/favicon-16x16.png',
+ 'sde/public/favicon-32x32.png',
+ 'sde/public/favicon.ico',
+ 'sde/public/mstile-150x150.png',
+ 'sde/public/safari-pinned-tab.svg',
+ 'sde/public/site.webmanifest',
]
const getFiles = async (dir) => {
@@ -28,9 +37,9 @@ const getFiles = async (dir) => {
const doIt = async () => {
let files = []
- const shared = await getFiles('../../sites/shared')
- const lab = await getFiles('../../sites/lab/components')
- console.log(JSON.stringify([...shared, ...lab], null, 2))
+ const sde = await getFiles('../../sites/sde')
+ const shared = await getFiles('../../sites/shared/config')
+ console.log(JSON.stringify([...shared, ...sde], null, 2))
}
doIt()
diff --git a/packages/new-design/shared/e2e/lab.spec.js b/packages/new-design/shared/e2e/lab.spec.js
deleted file mode 100644
index eace815748a..00000000000
--- a/packages/new-design/shared/e2e/lab.spec.js
+++ /dev/null
@@ -1,19 +0,0 @@
-import { test, expect } from '@playwright/test'
-
-test('Compiles and drafts', async ({ page }) => {
- await page.goto('http://localhost:8000/design')
-
- await page.waitForSelector('main')
- if (await page.getByRole('heading', { name: 'Preload a set of measurements' }).isVisible()) {
- await page
- .getByRole('list')
- .filter({ hasText: 'Size 28Size 30Size 32Size 34Size 36Size 38Size 40Size 42Size 44Size 46' })
- .getByRole('button', { name: 'Size 36' })
- .click()
- await page.getByTitle('draftDesign').click()
- }
-
- await expect(page.getByText('Something went wrong')).toHaveCount(0)
- await expect(page.getByText('Unhandled Runtime Error')).toHaveCount(0)
- await expect(page.getByTitle('Measurements')).toBeVisible()
-})
diff --git a/packages/new-design/shared/lab/components/footer.mjs b/packages/new-design/shared/lab/components/footer.mjs
deleted file mode 100644
index 71f128f84f3..00000000000
--- a/packages/new-design/shared/lab/components/footer.mjs
+++ /dev/null
@@ -1,145 +0,0 @@
-// Hooks
-import { useTranslation } from 'next-i18next'
-// Components
-import Link from 'next/link'
-import { FreeSewingLogo } from 'shared/components/logos/freesewing.mjs'
-import { OsiLogo } from 'shared/components/logos/osi.mjs'
-import { CCLogo } from 'shared/components/logos/cc.mjs'
-import { CCByLogo } from 'shared/components/logos/cc-by.mjs'
-import { Ribbon } from 'shared/components/ribbon.mjs'
-import { WordMark } from 'shared/components/wordmark.mjs'
-import {
- DiscordIcon,
- FacebookIcon,
- GithubIcon,
- InstagramIcon,
- RedditIcon,
- TwitterIcon,
-} from 'shared/components/icons.mjs'
-
-// Classes
-const link = 'text-secondary font-bold hover:pointer hover:underline px-1'
-const accent = 'text-accent font-bold text-lg px-1 block sm:inline'
-const freesewing = 'px-1 text-lg font-bold block sm:inline'
-
-// Keep these translations in the component because they're only used here
-const translations = {
- cc: (
-
- Content on FreeSewing.org is available under{' '}
-
- a Creative Commons license
-
-
- ),
- mit: (
-
- The FreeSewing source code is{' '}
-
- available on Github
- {' '}
- under{' '}
-
- the MIT license
-
-
- ),
- sponsors: (
- <>
- FreeSewing is sponsored by these{' '}
- awesome companies
- >
- ),
-}
-
-const icon = { className: 'w-8 lg:w-12 h-8 lg:h-12' }
-const social = {
- Discord: {
- icon:
{t('patrons:patronLead')}
-{t('patrons:patronPitch')}
-{translations.discord[app.locale]}
- -{t('patrons:patronLead')}
-{t('patrons:patronPitch')}
-- {props.children} --