diff --git a/bin/newComponent/index.cjs b/bin/newComponent/index.cjs deleted file mode 100644 index 80b7647d..00000000 --- a/bin/newComponent/index.cjs +++ /dev/null @@ -1,71 +0,0 @@ -const prompts = require('prompts'); -const changeCase = require('change-case'); -const path = require('path'); -const fs = require('fs-extra'); -const glob = require('tiny-glob'); -const { cyan, green, bold } = require('kleur'); - -const ROOT = path.resolve(__dirname, '../../'); -const LIB = path.join(ROOT, 'src/components'); -const TEMPLATE = path.join(__dirname, 'template'); - -const makeNewComponent = async () => { - const { name, folder } = await prompts([ - { - type: 'text', - name: 'name', - message: 'What should we call your new component, e.g., ImagePack?', - }, - { - type: 'text', - name: 'folder', - message: 'What folder should we put it in, e.g., Graphics?', - initial: 'Graphics', - }, - ]); - - if (!name || !folder) return; - - const componentName = changeCase.pascalCase(name); - const componentNameSlug = componentName.toLowerCase(); - const componentFolder = folder; - const componentFolderSlug = folder.toLowerCase().replace(' ', '-'); - const componentDir = path.join(LIB, componentName); - - if (fs.existsSync(componentDir)) { - console.log('Oops! That component already exists. Try another name?'); - return; - } - - fs.mkdirSync(componentDir); - - const files = await glob('**/*', { cwd: TEMPLATE, filesOnly: true }); - - for (const file of files) { - const writePath = path.join( - LIB, - file.replace(/YourComponent/g, componentName) - ); - - fs.ensureDirSync(path.dirname(writePath)); - - if (path.extname(file) === '.jpg') { - fs.copyFileSync(path.join(TEMPLATE, file), writePath); - continue; - } else { - const content = fs.readFileSync(path.join(TEMPLATE, file), 'utf8'); - const writeContent = content - .replace(/YourComponentSlug/g, componentNameSlug) - .replace(/YourComponent/g, componentName) - .replace(/ComponentFolderSlug/g, componentFolderSlug) - .replace(/ComponentFolder/g, componentFolder); - fs.writeFileSync(writePath, writeContent); - } - } - - console.log( - `${green('āœ”')} ${bold('Your component is ready at:')}\nšŸ“ ${cyan(`src/components/${bold(componentName)}/${componentName}.svelte`)}` - ); -}; - -makeNewComponent(); diff --git a/bin/newComponent/template/YourComponent/YourComponent.stories.svelte b/bin/newComponent/template/YourComponent/YourComponent.stories.svelte deleted file mode 100644 index 837857c9..00000000 --- a/bin/newComponent/template/YourComponent/YourComponent.stories.svelte +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - diff --git a/bin/newComponent/template/YourComponent/YourComponent.svelte b/bin/newComponent/template/YourComponent/YourComponent.svelte deleted file mode 100644 index 364fb89e..00000000 --- a/bin/newComponent/template/YourComponent/YourComponent.svelte +++ /dev/null @@ -1,60 +0,0 @@ - - - - - -
-

{altText}

-
- - diff --git a/bin/newComponent/template/YourComponent/stories/docs/component.md b/bin/newComponent/template/YourComponent/stories/docs/component.md deleted file mode 100644 index ce40a33c..00000000 --- a/bin/newComponent/template/YourComponent/stories/docs/component.md +++ /dev/null @@ -1,23 +0,0 @@ -> **Welcome to your new component!** Use this template to build your component and customise its storybook. - -- Build your component in `YourComponent/YourComponent.svelte`. -- Write your component's storybook in `YourComponent/YourComponent.stories.svelte`. -- Don't forget to add your component to `src/index.js`: - - ```javascript - // ... - export { default as YourComponent } from './components/YourComponent/YourComponent.svelte'; - ``` - -- Commit your component to a new branch and push it to GitHub! šŸ - ---- - -```html - - - - -``` diff --git a/bin/newComponent/template/YourComponent/stories/shark.jpg b/bin/newComponent/template/YourComponent/stories/shark.jpg deleted file mode 100644 index 352b0ab9..00000000 Binary files a/bin/newComponent/template/YourComponent/stories/shark.jpg and /dev/null differ diff --git a/package.json b/package.json index 1f3c59e3..6fb482b0 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ }, "scripts": { "start": "storybook dev -p 3000", - "new": "node ./bin/newComponent/index.cjs", "lint": "eslint --fix", "format": "prettier . --write", "build": "rimraf ./dist && svelte-package -i ./src && publint",