Skip to content

Commit

Permalink
feat: vue template support (#7)
Browse files Browse the repository at this point in the history
* feat: vue template support

* feat: update create command description

* fix: create typo description

* fix: manifest destination folder
  • Loading branch information
miguelramos authored Jun 13, 2022
1 parent 83d086a commit c27f5f5
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 12 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ Creating a library or package is on the same command, only parameter changes
|---|---|
| --name | This will be the folder name for creating lib or pkg, also will be prepend with scope for packing name |
| --type | Defines the type, supported are: lib or pkg |
| --template | Template to use for your lib/pkg (lit, solid, vue, react, typescript) |
| --template | Template to use for your lib/pkg (lit, solid, vue, typescript) |

**Current templates available: lit, typescript, solid**
**Default template is: lit**

Global parameters, can be used with any command before calling the command itself. There are two global parameters:

Expand Down
4 changes: 2 additions & 2 deletions cmd/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ func (ctx *ActionCommand) ReleaseArtifact(cmd *cobra.Command) {

var manifestDestination = ""
if ctx.Kind == "branch" {
manifestDestination = fmt.Sprintf("%s@%s-%s", pkgJson.Name, pkgJson.Version, hash)
manifestDestination = fmt.Sprintf("%s/%s", pkgJson.Name, ctx.Environment)
} else {
manifestDestination = fmt.Sprintf("%s@%s", pkgJson.Name, pkgJson.Version)
manifestDestination = pkgJson.Name
}

supabase.Upload("manifests", manifestFile.Name(), manifestDestination)
Expand Down
18 changes: 10 additions & 8 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func init() {
templates := []LibTemplate{
{
Type: "vue",
Link: "",
Link: "[email protected]:websublime/sublime-vue-template.git",
},
{
Type: "lit",
Expand All @@ -61,10 +61,6 @@ func init() {
Type: "solid",
Link: "[email protected]:websublime/sublime-solid-template.git",
},
{
Type: "react",
Link: "",
},
{
Type: "typescript",
Link: "[email protected]:websublime/sublime-typescript-template.git",
Expand All @@ -83,14 +79,14 @@ func init() {
createCmd.Flags().StringVar(&cmd.Type, "type", "", "Type of package (lib or pkg) [REQUIRED]")
createCmd.MarkFlagRequired("name")

createCmd.Flags().StringVar(&cmd.Template, "template", "lit", "Kind of template (lit) incoming support to: (react, solid, vue, typescript)")
createCmd.Flags().StringVar(&cmd.Template, "template", "lit", "Kind of template: (lit, solid, vue, typescript)")
createCmd.MarkFlagRequired("template")
}

func NewCreateCmd(cmdCreate *CreateCommand) *cobra.Command {
return &cobra.Command{
Use: "create",
Short: "Create libs or packages from lit, solid, vue or react",
Short: "Create libs or packages from lit, solid, vue or typescript",
Run: func(cmd *cobra.Command, args []string) {
cmdCreate.CreatPackage((cmd))
cmdCreate.YarnLink()
Expand Down Expand Up @@ -121,7 +117,7 @@ func (ctx *CreateCommand) CreatPackage(cmd *cobra.Command) {
}

if link == "" {
color.Error.Println("Unable to determine template. Valid types are: lit, solid, vue, react or typescript")
color.Error.Println("Unable to determine template. Valid types are: lit, solid, vue or typescript")
cobra.CheckErr("Template error")
}

Expand All @@ -144,6 +140,12 @@ func (ctx *CreateCommand) CreatPackage(cmd *cobra.Command) {
libViteConfigJson = "templates/vite-config-solid.json"
}

if ctx.Template == "vue" {
libPackageJson = "templates/lib-package-vue.json"
libTsconfigJson = "templates/tsconfig-lib-vue.json"
libViteConfigJson = "templates/vite-config-vue.json"
}

if ctx.Template == "typescript" {
libViteConfigJson = "templates/vite-config-typescript.json"
}
Expand Down
64 changes: 64 additions & 0 deletions cmd/templates/lib-package-vue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "{{ .Namespace }}",
"private": false,
"version": "0.0.4",
"source": "./src",
"scripts": {
"start": "vite --debug",
"build": "yarn dts && vite build --mode=production && yarn types",
"dts": "tsc --declaration --emitDeclarationOnly",
"types": "mkdir dist/docs && api-extractor run --local && rm -rf ./declarations",
"release": "yarn changeset publish"
},
"devDependencies": {
"{{ .Scope }}/vite": "0.0.1",
"@vitejs/plugin-vue": "^2.3.3",
"@microsoft/api-documenter": "^7.17.15",
"@microsoft/api-extractor": "^7.24.1",
"@types/jest": "^27.0.1",
"@types/node": "^16.11.12",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.0",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-sort-destructure-keys": "^1.4.0",
"eslint-plugin-unicorn": "^42.0.0",
"jest": "^26.1.0",
"prettier": "^2.5.1",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-postcss-lit": "^2.0.0",
"rollup-plugin-typescript2": "^0.31.2",
"sass": "^1.51.0",
"ts-jest": "^26.1.1",
"typescript": "^4.5.4",
"vite": "^2.8.0"
},
"dependencies": {
"vue": "^3.2.37"
},
"main": "./dist/{{ .Name }}.cjs.js",
"module": "./dist/{{ .Name }}.es.js",
"types": "./dist/@types/index.d.ts",
"exports": {
".": {
"require": "./dist/{{ .Name }}.cjs.js",
"import": "./dist/{{ .Name }}.es.js"
}
},
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
"repository": {
"type": "git",
"url": "ssh://[email protected]:{{ .Repo }}.git",
"directory": "libs/{{ .Name }}"
},
"files": [
"dist/",
"./LICENSE.md",
"./README.md"
]
}

39 changes: 39 additions & 0 deletions cmd/templates/tsconfig-lib-vue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"useDefineForClassFields": false,
"declaration": true,
"experimentalDecorators": true,
"importHelpers": true,
"inlineSources": true,
"isolatedModules": true,
"lib": ["es2017", "dom", "dom.iterable"],
"module": "esNext",
"moduleResolution": "node",
"noImplicitReturns": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"noImplicitAny": false,
"rootDir": ".",
"skipLibCheck": true,
"strict": true,
"sourceMap": true,
"target": "es2017",
"baseUrl": ".",
"paths": {
"*": ["./types/*", "*"],
"{{ .Namespace }}/*": ["./src/*"]
},
"declarationDir": "./declarations",
"removeComments": false,
"incremental": false,
"composite": false
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "types/**/*.d.ts", "src/**/*.tsx", "types/**/*.d.ts"],
"extends": "../../tsconfig.base.json",
"references": [
{
"path": "{{ .Vite }}"
}
]
}
56 changes: 56 additions & 0 deletions cmd/templates/vite-config-vue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-import-module-exports */
import path from 'path';

import { workspacesAlias } from '{{ .Scope }}/vite';
import postcss from 'rollup-plugin-postcss';
import vue from '@vitejs/plugin-vue';
import { defineConfig } from 'vite';

module.exports = defineConfig({
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.tsx'),
fileName: (format) => `{{ .Name }}.${format}.js`,
formats: ['es', 'cjs', 'umd'],
name: '{{ .Name }}'
},
polyfillDynamicImport: false,
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: [],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {}
}
},
sourcemap: true,
target: 'modules'
},
css: {
preprocessorOptions: {
sass: {
includePaths: ['node_modules']
},
scss: {
includePaths: ['node_modules']
}
}
},
plugins: [
postcss({
inject: false
}),
vue({
template: {
compilerOptions: {
// treat all tags with a dash as custom elements
isCustomElement: (tag) => tag.includes('-')
}
}
}),
workspacesAlias(['../../'], ['vite'])
]
});

0 comments on commit c27f5f5

Please sign in to comment.