-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add generate plugin command to cli
- Loading branch information
Frantz Kati
committed
Feb 1, 2021
1 parent
8930087
commit 2b3d00d
Showing
49 changed files
with
892 additions
and
20,356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
to: <%= h.changeCase.param(name) %>/.gitignore | ||
--- | ||
|
||
build/ | ||
node_modules/ | ||
mix-manifest.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
to: <%= h.changeCase.param(name) %>/client/app.css | ||
--- | ||
|
||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
to: <%= h.changeCase.param(name) %>/client/app.tsx | ||
--- | ||
|
||
import React from 'react' | ||
import { Tensei, PageWrapper } from '@tensei/components' | ||
|
||
declare var Tensei: Tensei | ||
|
||
const <%= h.changeCase.pascal(name) %> = () => { | ||
return ( | ||
<PageWrapper> | ||
{`Hello <%= h.changeCase.param(name) %>`} | ||
</PageWrapper> | ||
) | ||
} | ||
|
||
Tensei.register(({ route }) => { | ||
route({ | ||
path: '<%= h.changeCase.param(name) %>', | ||
name: '<%= h.changeCase.pascal(name) %>', | ||
icon: 'cog', | ||
component: <%= h.changeCase.pascal(name) %>, | ||
requiredPermissions: [] | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
to: <%= h.changeCase.param(name) %>/package.json | ||
--- | ||
|
||
{ | ||
"name": "tensei-<%= h.changeCase.param(name) %>", | ||
"version": "0.5.8", | ||
"main": "./build/server/plugin.js", | ||
"license": "MIT", | ||
"types": "./build/server/plugin.d.ts", | ||
"files": [ | ||
"build/" | ||
], | ||
"scripts": { | ||
"prettier": "prettier --write './**/*.{js,json,ts,css}'", | ||
"build:server": "tsc --p tsconfig.server.json", | ||
"build:client": "cross-env NODE_ENV=production webpack --config=node_modules/laravel-mix/setup/webpack.config.js", | ||
"dev:server": "tsc --watch --p tsconfig.server.json", | ||
"dev:client": "webpack --config=node_modules/laravel-mix/setup/webpack.config.js --watch", | ||
"test": "jest --verbose --runInBand --forceExit", | ||
"build": "yarn build:server && yarn build:client" | ||
}, | ||
"devDependencies": { | ||
"@tensei/common": "^0.5.8", | ||
"@tensei/components": "^0.5.8", | ||
"laravel-mix": "^6.0.5", | ||
"postcss": "^8.1", | ||
"tailwindcss": "^2.0.2", | ||
"typescript": "^4.1.3" | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/cli/_templates/default/new/server/plugin.ts.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
to: <%= h.changeCase.param(name) %>/server/plugin.ts | ||
--- | ||
|
||
import Path from 'path' | ||
import { plugin } from '@tensei/common' | ||
|
||
class <%= h.changeCase.pascal(name) %> { | ||
plugin() { | ||
return plugin('<%= name %>').boot(({ script, style }) => { | ||
script( | ||
'<%= h.changeCase.param(name) %>.js', | ||
Path.resolve(__dirname, '..', 'build/client/app.js') | ||
) | ||
style( | ||
'<%= h.changeCase.param(name) %>.css', | ||
Path.resolve(__dirname, '..', 'build/client/app.css') | ||
) | ||
}) | ||
} | ||
} | ||
|
||
const <%= h.changeCase.camel(name) %> = () => new <%= h.changeCase.pascal(name) %>() | ||
|
||
export default <%= h.changeCase.camel(name) %> |
44 changes: 44 additions & 0 deletions
44
packages/cli/_templates/default/new/tailwind.config.js.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
to: <%= h.changeCase.param(name) %>/tailwind.config.js | ||
--- | ||
const defaultTheme = require('tailwindcss/defaultTheme') | ||
|
||
module.exports = { | ||
purge: { | ||
enabled: process.env.NODE_ENV === 'production', | ||
content: ['./**/*.tsx'] | ||
}, | ||
theme: { | ||
extend: { | ||
fontFamily: { | ||
sans: ['Nunito', ...defaultTheme.fontFamily.sans] | ||
}, | ||
colors: { | ||
'tensei-primary': '#2346F8', | ||
|
||
'tensei-primary-200': '#D3D8FA', | ||
|
||
'tensei-primary-lighter': '#3f70fa', | ||
|
||
'tensei-primary-darker': '#243de1', | ||
'tensei-secondary': '#33C5FF', | ||
'tensei-darkest': '#21185A', | ||
|
||
'tensei-gray-900': '#2C3E50', | ||
'tensei-gray-800': '#61677C', | ||
'tensei-gray-700': '#949BAF', | ||
'tensei-gray-600': '#EEEFF1', | ||
'tensei-gray-500': '#C3C8D2', | ||
'tensei-gray-400': '#F0F1F4', | ||
'tensei-gray-300': '#EAEBEF', | ||
'tensei-gray-100': '#F7F9FA', | ||
|
||
'tensei-warning': '#F0B103', | ||
'tensei-success': '#00976E', | ||
'tensei-success-lighter': '#00CA93', | ||
'tensei-success-darker': '#006449', | ||
'tensei-error': '#D41B44' | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
to: <%= h.changeCase.param(name) %>/tsconfig.json | ||
--- | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react", | ||
"module": "commonjs", | ||
"noImplicitAny": true, | ||
"outDir": "./build/", | ||
"preserveConstEnums": true, | ||
"removeComments": true, | ||
"sourceMap": true, | ||
"target": "es5", | ||
"baseUrl": "./client", | ||
"esModuleInterop": true, | ||
"declaration": false | ||
}, | ||
"exclude": ["__tests__", "build", "server"] | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/cli/_templates/default/new/tsconfig.server.json.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
to: <%= h.changeCase.param(name) %>/tsconfig.server.json | ||
--- | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2017", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"outDir": "./build/server", | ||
"strict": true, | ||
"baseUrl": "./server", | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"types": ["@types/jest"] | ||
}, | ||
"exclude": ["__tests__", "build", "client"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
to: <%= h.changeCase.param(name) %>/webpack.mix.js | ||
--- | ||
const mix = require('laravel-mix') | ||
|
||
mix.webpackConfig({ | ||
externals: { | ||
react: 'window.React', | ||
'@tensei/components': 'window.Tensei.lib' | ||
} | ||
}) | ||
.postCss('./client/app.css', 'build/client/app.css', [require('tailwindcss')]) | ||
.ts('./client/app.tsx', 'build/client/app.js') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
message: | | ||
hygen {bold generator new} --name [NAME] --action [ACTION] | ||
hygen {bold generator with-prompt} --name [NAME] --action [ACTION] | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t | ||
--- | ||
--- | ||
to: app/hello.js | ||
--- | ||
const hello = ``` | ||
Hello! | ||
This is your first hygen template. | ||
|
||
Learn what it can do here: | ||
|
||
https://github.com/jondot/hygen | ||
``` | ||
|
||
console.log(hello) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t | ||
--- | ||
--- | ||
to: app/hello.js | ||
--- | ||
const hello = ``` | ||
Hello! | ||
This is your first prompt based hygen template. | ||
|
||
Learn what it can do here: | ||
|
||
https://github.com/jondot/hygen | ||
``` | ||
|
||
console.log(hello) | ||
|
||
|
14 changes: 14 additions & 0 deletions
14
packages/cli/_templates/generator/with-prompt/prompt.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
to: _templates/<%= name %>/<%= action || 'new' %>/prompt.js | ||
--- | ||
|
||
// see types of prompts: | ||
// https://github.com/enquirer/enquirer/tree/master/examples | ||
// | ||
module.exports = [ | ||
{ | ||
type: 'input', | ||
name: 'message', | ||
message: "What's your message?" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.