diff --git a/packages/new-design/lib/utils.mjs b/packages/new-design/lib/utils.mjs index 56ccfeb6557..59b94514c6c 100644 --- a/packages/new-design/lib/utils.mjs +++ b/packages/new-design/lib/utils.mjs @@ -9,6 +9,7 @@ import { oraPromise } from 'ora' import { execa } from 'execa' import axios from 'axios' import { fileURLToPath } from 'url' +import { capitalize } from '@freesewing/core' // Current working directory let filename @@ -286,6 +287,7 @@ export const createEnvironment = async (choices) => { // Copy/Template files try { const templateVars = { + Name: capitalize(choices.name), name: choices.name, tag: config.tag, } diff --git a/packages/new-design/package.json b/packages/new-design/package.json index ede78e22ffd..82f9b1c977d 100644 --- a/packages/new-design/package.json +++ b/packages/new-design/package.json @@ -28,6 +28,7 @@ }, "peerDependencies": {}, "dependencies": { + "@freesewing/core": "^3.0.0-alpha.2", "axios": "^1.1.2", "chalk": "^5.0.1", "execa": "^6.1.0", diff --git a/packages/new-design/shared/pages/design.mjs b/packages/new-design/shared/pages/design.mjs.mustache similarity index 60% rename from packages/new-design/shared/pages/design.mjs rename to packages/new-design/shared/pages/design.mjs.mustache index efa2889a4f8..b9bc5a5f519 100644 --- a/packages/new-design/shared/pages/design.mjs +++ b/packages/new-design/shared/pages/design.mjs.mustache @@ -1,4 +1,10 @@ -import { Pattern } from 'design/src/index.mjs' +//{{! +// Change the Mustache delimiter from double curly braces to double dollar signs. +// Dollar signs are allowed in EcmaScript identifier names, +// which is helpful when running unrendered Mustache templates through eslint. +//}}{{=$$ $$=}} + +import { $$Name$$ } from 'design/src/index.mjs' import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import Page from 'site/components/wrappers/page.js' @@ -11,7 +17,7 @@ const WorkbenchPage = (props) => { return ( - + ) } diff --git a/packages/new-design/templates/from-bella/design/src/index.mjs.mustache b/packages/new-design/templates/from-bella/design/src/index.mjs.mustache index e628e6e7c1a..366a2f9db27 100644 --- a/packages/new-design/templates/from-bella/design/src/index.mjs.mustache +++ b/packages/new-design/templates/from-bella/design/src/index.mjs.mustache @@ -1,3 +1,9 @@ +//{{! +// Change the Mustache delimiter from double curly braces to double dollar signs. +// Dollar signs are allowed in EcmaScript identifier names, +// which is helpful when running unrendered Mustache templates through eslint. +//}}{{=$$ $$=}} + // Import Design constructor import { Design } from '@freesewing/core' // Import parts @@ -5,7 +11,7 @@ import { back } from './back' import { front } from './front' // Create the new design -const Pattern = new Design({ +const $$Name$$ = new Design({ data: { /* * If you like, you can add any data you want to your design. @@ -14,7 +20,7 @@ const Pattern = new Design({ * If you don't use this, * you can remove this data key enterely. */ - name: "{{ name }}", + name: "$$ name $$", }, // A list of parts is all that is required. parts: [ back, front ], @@ -26,5 +32,5 @@ const Pattern = new Design({ * We export the design itself as well as each part individually. * This allows us to re-use these parts in other designs. */ -export { back, front, Pattern } +export { back, front, $$Name$$ } diff --git a/packages/new-design/templates/from-bent/design/src/index.mjs.mustache b/packages/new-design/templates/from-bent/design/src/index.mjs.mustache index 59a30ada17f..0d877cda92c 100644 --- a/packages/new-design/templates/from-bent/design/src/index.mjs.mustache +++ b/packages/new-design/templates/from-bent/design/src/index.mjs.mustache @@ -1,3 +1,9 @@ +//{{! +// Change the Mustache delimiter from double curly braces to double dollar signs. +// Dollar signs are allowed in EcmaScript identifier names, +// which is helpful when running unrendered Mustache templates through eslint. +//}}{{=$$ $$=}} + // Import Design constructor import { Design } from '@freesewing/core' // Import parts @@ -7,7 +13,7 @@ import { topSleeve } from './topsleeve.mjs' import { underSleeve } from './undersleeve.mjs' // Create the new design -const Pattern = new Design({ +const $$Name$$ = new Design({ data: { /* * If you like, you can add any data you want to your design. @@ -16,7 +22,7 @@ const Pattern = new Design({ * If you don't use this, * you can remove this data key enterely. */ - name: "{{ name }}", + name: "$$ name $$", }, // A list of parts is all that is required. parts: [ back, front, topSleeve, underSleeve ], @@ -28,5 +34,5 @@ const Pattern = new Design({ * We export the design itself as well as each part individually. * This allows us to re-use these parts in other designs. */ -export { back, front, topSleeve, underSleeve, Pattern } +export { back, front, topSleeve, underSleeve, $$Name$$ } diff --git a/packages/new-design/templates/from-breanna/design/src/index.mjs.mustache b/packages/new-design/templates/from-breanna/design/src/index.mjs.mustache index 076a0a0a6d0..96319916723 100644 --- a/packages/new-design/templates/from-breanna/design/src/index.mjs.mustache +++ b/packages/new-design/templates/from-breanna/design/src/index.mjs.mustache @@ -1,3 +1,9 @@ +//{{! +// Change the Mustache delimiter from double curly braces to double dollar signs. +// Dollar signs are allowed in EcmaScript identifier names, +// which is helpful when running unrendered Mustache templates through eslint. +//}}{{=$$ $$=}} + // Import Design constructor import { Design } from '@freesewing/core' // Import parts @@ -6,7 +12,7 @@ import { front } from './front' import { sleeve } from './sleeve' // Create the new design -const Pattern = new Design({ +const $$Name$$ = new Design({ data: { /* * If you like, you can add any data you want to your design. @@ -15,7 +21,7 @@ const Pattern = new Design({ * If you don't use this, * you can remove this data key enterely. */ - name: "{{ name }}", + name: "$$ name $$", }, // A list of parts is all that is required. parts: [ back, front, sleeve ], @@ -27,5 +33,5 @@ const Pattern = new Design({ * We export the design itself as well as each part individually. * This allows us to re-use these parts in other designs. */ -export { back, front, sleeve, Pattern } +export { back, front, sleeve, $$Name$$ } diff --git a/packages/new-design/templates/from-brian/design/src/index.mjs.mustache b/packages/new-design/templates/from-brian/design/src/index.mjs.mustache index 076a0a0a6d0..96319916723 100644 --- a/packages/new-design/templates/from-brian/design/src/index.mjs.mustache +++ b/packages/new-design/templates/from-brian/design/src/index.mjs.mustache @@ -1,3 +1,9 @@ +//{{! +// Change the Mustache delimiter from double curly braces to double dollar signs. +// Dollar signs are allowed in EcmaScript identifier names, +// which is helpful when running unrendered Mustache templates through eslint. +//}}{{=$$ $$=}} + // Import Design constructor import { Design } from '@freesewing/core' // Import parts @@ -6,7 +12,7 @@ import { front } from './front' import { sleeve } from './sleeve' // Create the new design -const Pattern = new Design({ +const $$Name$$ = new Design({ data: { /* * If you like, you can add any data you want to your design. @@ -15,7 +21,7 @@ const Pattern = new Design({ * If you don't use this, * you can remove this data key enterely. */ - name: "{{ name }}", + name: "$$ name $$", }, // A list of parts is all that is required. parts: [ back, front, sleeve ], @@ -27,5 +33,5 @@ const Pattern = new Design({ * We export the design itself as well as each part individually. * This allows us to re-use these parts in other designs. */ -export { back, front, sleeve, Pattern } +export { back, front, sleeve, $$Name$$ } diff --git a/packages/new-design/templates/from-scratch/design/src/index.mjs.mustache b/packages/new-design/templates/from-scratch/design/src/index.mjs.mustache index 28d42e17195..528d7061d38 100644 --- a/packages/new-design/templates/from-scratch/design/src/index.mjs.mustache +++ b/packages/new-design/templates/from-scratch/design/src/index.mjs.mustache @@ -1,10 +1,16 @@ +//{{! +// Change the Mustache delimiter from double curly braces to double dollar signs. +// Dollar signs are allowed in EcmaScript identifier names, +// which is helpful when running unrendered Mustache templates through eslint. +//}}{{=$$ $$=}} + // Import Design constructor import { Design } from '@freesewing/core' // Import parts import { box } from './box.mjs' // Create the new design -const Pattern = new Design({ +const $$Name$$ = new Design({ data: { /* * If you like, you can add any data you want to your design. @@ -13,7 +19,7 @@ const Pattern = new Design({ * If you don't use this, * you can remove this data key enterely. */ - name: "{{ name }}", + name: "$$ name $$", }, // A list of parts is all that is required. parts: [ box ], @@ -25,5 +31,5 @@ const Pattern = new Design({ * We export the design itself as well as each part individually. * This allows us to re-use these parts in other designs. */ -export { box, Pattern } +export { box, $$Name$$ } diff --git a/packages/new-design/templates/from-titan/design/src/index.mjs.mustache b/packages/new-design/templates/from-titan/design/src/index.mjs.mustache index e628e6e7c1a..366a2f9db27 100644 --- a/packages/new-design/templates/from-titan/design/src/index.mjs.mustache +++ b/packages/new-design/templates/from-titan/design/src/index.mjs.mustache @@ -1,3 +1,9 @@ +//{{! +// Change the Mustache delimiter from double curly braces to double dollar signs. +// Dollar signs are allowed in EcmaScript identifier names, +// which is helpful when running unrendered Mustache templates through eslint. +//}}{{=$$ $$=}} + // Import Design constructor import { Design } from '@freesewing/core' // Import parts @@ -5,7 +11,7 @@ import { back } from './back' import { front } from './front' // Create the new design -const Pattern = new Design({ +const $$Name$$ = new Design({ data: { /* * If you like, you can add any data you want to your design. @@ -14,7 +20,7 @@ const Pattern = new Design({ * If you don't use this, * you can remove this data key enterely. */ - name: "{{ name }}", + name: "$$ name $$", }, // A list of parts is all that is required. parts: [ back, front ], @@ -26,5 +32,5 @@ const Pattern = new Design({ * We export the design itself as well as each part individually. * This allows us to re-use these parts in other designs. */ -export { back, front, Pattern } +export { back, front, $$Name$$ } diff --git a/packages/new-design/templates/from-tutorial/design/src/bib.mjs.mustache b/packages/new-design/templates/from-tutorial/design/src/bib.mjs.mustache index b2c74ab7488..2af04e1e5cc 100644 --- a/packages/new-design/templates/from-tutorial/design/src/bib.mjs.mustache +++ b/packages/new-design/templates/from-tutorial/design/src/bib.mjs.mustache @@ -1,9 +1,8 @@ function draftBib({ part }) { - return part } export const bib = { - name: 'tutorial.bib', + name: '{{ name }}.bib', draft: draftBib, } diff --git a/packages/new-design/templates/from-tutorial/design/src/index.mjs.mustache b/packages/new-design/templates/from-tutorial/design/src/index.mjs.mustache index 3bada6576fd..9ff7c96a38b 100644 --- a/packages/new-design/templates/from-tutorial/design/src/index.mjs.mustache +++ b/packages/new-design/templates/from-tutorial/design/src/index.mjs.mustache @@ -1,12 +1,18 @@ +//{{! +// Change the Mustache delimiter from double curly braces to double dollar signs. +// Dollar signs are allowed in EcmaScript identifier names, +// which is helpful when running unrendered Mustache templates through eslint. +//}}{{=$$ $$=}} + import { Design } from '@freesewing/core' import { bib } from './bib.mjs' -const Pattern = new Design({ +const $$Name$$ = new Design({ data: { - version: "0.0.1", - name: "Tutorial", + version: '0.0.1', + name: '$$ name $$', }, parts: [ bib ], }) -export { bib, Pattern } +export { bib, $$Name$$ }