Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Dodge committed Jul 21, 2021
2 parents f94adb9 + 7dbc993 commit 7a56153
Show file tree
Hide file tree
Showing 15 changed files with 812 additions and 390 deletions.
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,47 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.1.0] - 2021-07-21

### Fixed
- Fix file structure generated when npm package name has `@scope/` prefix

### Added
- **NEW**: Auto-generated typescript definitions! No more manually maintaining `.d.ts` files
- **NEW**: Cli flags to auto-answer prompts. Opens the door for better integration into automated processes, easier bash aliases, etc.

### Changed/Removed
- Update cli dependencies
- chalk 4.1.1
- ejs 3.1.6
- minimist 1.2.5
- prompts 2.4.1
- eslint 7.30.0
- eslint-plugin-import 2.23.4
- husky 4.3.8
- Update template dependencies
- @babel/core 7.14.6
- @babel/preset-env 7.14.7
- @babel/preset-typescript 7.14.5
- @rollup/plugin-alias 3.1.2
- @rollup/plugin-babel 5.3.0
- @rollup/plugin-commonjs 14.0.0
- @rollup/plugin-node-resolve 9.0.0
- @rollup/plugin-replace 2.4.2
- @vue/cli-plugin-babel 4.5.13
- @vue/cli-plugin-typescript 4.5.13
- @vue/cli-service 4.5.13
- @vue/compiler-sfc 3.0.11
- @zerollup/ts-transform-paths 1.7.18
- typescript 4.0.3
- postcss 8.2.10
- rollup 2.52.8
- vue 2.6.14
- vue-template-compiler 2.6.14
- **NEW** rimraf 3.0.2
- **NEW** rollup-plugin-typescript2 0.30.0
- **NEW** ttypescript 1.5.12

## [4.0.5] - 2021-04-12

### Fixed
Expand Down
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ npm run build

## Details

The vue-sfc-rollup utility scaffolds the essential files you need to kick of your SFC development. These files include:
The vue-sfc-rollup utility scaffolds the essential files you need to kick off your SFC development. These files include:
- a minimal [rollup](https://rollupjs.org) config
- a corresponding package.json file with build/dev scripts and dependencies
- a minimal babel.config.js and .browserslistrc file for transpiling
Expand All @@ -45,7 +45,6 @@ The vue-sfc-rollup utility scaffolds the essential files you need to kick of you
In library mode, there is also an 'index' which declares the components exposed as part of your library.

When developing typescript-based components/libraries, the following supporting files will also be created:
- A basic typescript declaration file for your component/library
- The basic typescript shim declaration file(s) common to vue-typescript development
- A basic tsconfig.json file

Expand Down Expand Up @@ -74,13 +73,29 @@ The wizard will then prompt you for the following:

- *select vue version*: Declare whether you are writing a component for Vue 2 or Vue 3
- *select mode*: Declare whether you want to scaffold a single component or a library of components.
- *npm name*: This is how people will find your component/library in npm. Please refer to [the official npm docs](https://docs.npmjs.com/files/package.json#name) for details of what to enter here
- *npm name*: This is how people will find your component/library in npm. Please refer to [the official npm docs](https://docs.npmjs.com/files/package.json#name) for details of what to enter here.
- *component name* (Single Component Mode Only): This is the kebab-case version of your SFC component name - what your component's tag would be if you were to use this in an HTML page or another component. Since any kebab-case tag name would also be a safe file name, this will also be the name of the generated files.
- *javascript/typescript*: Do you wish to use typescript to develop your component/library?
- *save path*: Where do you want to save this component? By default, the wizard will use your current directory and create a new folder with the kebab-case name as your component/library (eg. ./my-component-or-library).
- *save path*: Where do you want to save this component? By default, the wizard will use your current directory and create a new folder based off of your npm name (eg. ./my-component-or-library).

After prompting you for this information, the wizard then creates copies of the files found in the `templates` directory and performs some variable replacement using the information entered.

### Using the vue-sfc-rollup cli flags

For those who use this utility frequently and/or in automated processes, vue-sfc-rollup supports flags to specify the answers for all questions in the prompts. For example:

```bash
sfc-init --version=2 --mode=component --name=@scope/sampleComponent --lang=js --write

sfc-init --version=3 --mode=library --name=sampleLibrary --lang=ts
```

The first command in the example would scaffold a single vue 2 component with the npm name of `@scope/sampleComponent`, written in plain javascript, in the directory `./scope_sample-component`. It would write the files immediately.

The second command would scaffoled a vue 3 library with the npm name of `sampleLibrary`, written in typescript, and would suggest the directory `sample-library`, but would not write the files immediately, prompting for that last step instead.

All flags are optional, and the cli will prompt for values covered by flags which were missing.

### Developing your SFC

vue-sfc-rollup is focused on packaging your SFC for distribution via npm. The [Vue CLI](https://cli.vuejs.org/) is excellent for the actual development process of your SFC, and vue-sfc-rollup comes pre-wired to use this process. With the Vue CLI installed, you can truly develop your SFC with zero configuration just by entering the following commands:
Expand Down
4 changes: 4 additions & 0 deletions lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const path = require('path');
const fs = require('fs');

// Helper to convert scoped name to avoid unintentional nested-directories
const convertScope = (string, replaceSlash = '-') => string.replace(/@(.*?)\//, `$1${replaceSlash}`);

// Helpers for creating kebab-case/PascalCase versions of string
const pascalify = (str) => {
const camelized = str.replace(/-([a-z])/g, (c) => c[1].toUpperCase());
Expand All @@ -19,6 +22,7 @@ const ensureDirectoryExists = (filePath) => {
};

module.exports = {
convertScope,
pascalify,
kebabcase,
ensureDirectoryExists,
Expand Down
Loading

0 comments on commit 7a56153

Please sign in to comment.