From b9a46e97636d047d06f32155e4cccf038f98e3ae Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Sun, 9 Oct 2022 21:32:43 +0200 Subject: [PATCH] feat(new-design): Added template specific for tutorial --- packages/new-design/lib/utils.mjs | 48 ++++++--- .../from-tutorial/design/src/bib.mjs.mustache | 9 ++ .../design/src/index.mjs.mustache | 12 +++ .../from-tutorial/package.json.mustache | 97 +++++++++++++++++++ 4 files changed, 155 insertions(+), 11 deletions(-) create mode 100644 packages/new-design/templates/from-tutorial/design/src/bib.mjs.mustache create mode 100644 packages/new-design/templates/from-tutorial/design/src/index.mjs.mustache create mode 100644 packages/new-design/templates/from-tutorial/package.json.mustache diff --git a/packages/new-design/lib/utils.mjs b/packages/new-design/lib/utils.mjs index 948921f5abb..bb2caf372e2 100644 --- a/packages/new-design/lib/utils.mjs +++ b/packages/new-design/lib/utils.mjs @@ -58,6 +58,7 @@ export const getChoices = async () => { 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', @@ -88,17 +89,20 @@ export const getChoices = async () => { initial: 0, }) - const { name } = await prompts({ - type: 'text', - name: 'name', - message: 'What name would you like the design to have? 🏷️ ([a-z] only)', - validate: validateDesignName, - }) + const { name } = + template === 'tutorial' + ? { name: 'tutorial' } + : await prompts({ + type: 'text', + name: 'name', + message: 'What name would you like the design to have? 🏷️ ([a-z] only)', + validate: validateDesignName, + }) const { manager } = await prompts({ type: 'select', name: 'manager', - message: 'Last but not least, what package manager do you use? 📦', + message: 'What package manager should we use? 📦', choices: [ { title: 'yarn', value: 'yarn', description: 'Yarn - Nice if you have it' }, { title: 'npm', value: 'npm', description: 'NPM - Comes with NodeJS' }, @@ -193,7 +197,7 @@ 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 @@ -211,7 +215,29 @@ 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('≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡')} + ${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. + + Have fun 🤓 + `) + else + console.log(` FreeSewing's documentation for developers is available at: ${chalk.green( 'https://freesewing.dev/' @@ -220,9 +246,9 @@ const showTips = (config, choices) => 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 🤓 -`) + `) +} // Creates the environment based on the user's choices export const createEnvironment = async (choices) => { 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 new file mode 100644 index 00000000000..b2c74ab7488 --- /dev/null +++ b/packages/new-design/templates/from-tutorial/design/src/bib.mjs.mustache @@ -0,0 +1,9 @@ +function draftBib({ part }) { + + return part +} + +export const bib = { + name: 'tutorial.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 new file mode 100644 index 00000000000..3bada6576fd --- /dev/null +++ b/packages/new-design/templates/from-tutorial/design/src/index.mjs.mustache @@ -0,0 +1,12 @@ +import { Design } from '@freesewing/core' +import { bib } from './bib.mjs' + +const Pattern = new Design({ + data: { + version: "0.0.1", + name: "Tutorial", + }, + parts: [ bib ], +}) + +export { bib, Pattern } diff --git a/packages/new-design/templates/from-tutorial/package.json.mustache b/packages/new-design/templates/from-tutorial/package.json.mustache new file mode 100644 index 00000000000..1259c67e9fb --- /dev/null +++ b/packages/new-design/templates/from-tutorial/package.json.mustache @@ -0,0 +1,97 @@ +{ + "name": "@freesewing/{{name}}", + "version": "0.0.1", + "description": "A new FreeSewing design", + "author": "Joost De Cock (https://github.com/joostdecock)", + "homepage": "https://freesewing.org/", + "repository": "github:freesewing/freesewing", + "license": "MIT", + "bugs": { + "url": "https://github.com/freesewing/freesewing/issues" + }, + "funding": { + "type": "individual", + "url": "https://freesewing.org/patrons/join" + }, + "keywords": [ + "freesewing", + "design", + "diy", + "fashion", + "parametric design", + "sewing", + "sewing pattern" + ], + "main": "dist/index.js", + "module": "dist/index.mjs", + "scripts": { + "dev": "node --experimental-json-modules ./node_modules/.bin/next dev -p 8000", + "build": "node build.js", + "clean": "rimraf dist", + "mbuild": "NO_MINIFY=1 node build.js", + "test": "BABEL_ENV=production npx mocha tests/*.test.mjs --require @babel/register", + "vbuild": "VERBOSE=1 node build.js" + }, + "dependencies": { + "@freesewing/core": "{{ tag }}", + "@freesewing/plugin-bundle": "{{ tag }}" + }, + "devDependencies": { + "@freesewing/plugin-svgattr": "{{ tag }}", + "@freesewing/plugin-theme": "{{ tag }}", + "@freesewing/plugin-i18n": "{{ tag }}", + "@freesewing/models": "{{ tag }}", + "@headlessui/react": "^1.6.5", + "js-yaml": "^4.1.0", + "file-saver": "^2.0.5", + "axios": "^0.27.2", + "react": "^17.0.2", + "react-dom": "^17.0.2", + "react-sizeme": "^3.0.2", + "react-zoom-pan-pinch": "^2.1.3", + "react-markdown": "^8.0.3", + "roughjs": "^4.5.2", + "@tailwindcss/typography": "^0.5.2", + "d3-dispatch": "^3.0.1", + "d3-drag": "^3.0.0", + "d3-selection": "^3.0.0", + "daisyui": "^2.0.6", + "lodash.get": "^4.4.2", + "lodash.orderby": "^4.6.0", + "lodash.set": "^4.3.2", + "lodash.unset": "^4.5.2", + "lodash.clonedeep": "^4.5.0", + "next": "latest", + "next-i18next": "^11.0.0", + "pdfkit": "^0.13.0", + "react-copy-to-clipboard": "^5.0.4", + "react-hotkeys-hook": "^3.4.4", + "react-swipeable": "^6.2.0", + "react-timeago": "^6.2.1", + "mocha": "^9.1.1", + "chai": "^4.2.0", + "autoprefixer": "^10.4.0", + "eslint-config-next": "12.1.6", + "highlight.js": "^11.5.1", + "js-yaml": "^4.1.0", + "postcss": "^8.4.14", + "postcss-for": "^2.1.1", + "svg-to-pdfkit": "^0.1.8", + "tailwindcss": "^3.1.3", + "tailwindcss-open-variant": "^1.0.0", + "web-worker": "^1.2.0" + }, + "files": [ + "dist/*", + "README.md", + "package.json" + ], + "publishConfig": { + "access": "public", + "tag": "next" + }, + "engines": { + "node": ">=14.0.0", + "npm": ">=6" + } +}