diff --git a/bin/cli-plugins b/bin/cli-plugins index 6dc127697..aa2d8f234 100755 --- a/bin/cli-plugins +++ b/bin/cli-plugins @@ -286,7 +286,7 @@ async function createSeedPlugin() { { type: 'input', name: 'pluginName', - message: 'Plugin Name: i.e talk-plugin-permalink', + message: 'Plugin Name:', validate: (input) => { if (pluginNameExists(input)) { @@ -299,18 +299,47 @@ async function createSeedPlugin() { return 'Plugin Name is required.'; } + }, + { + type: 'confirm', + name: 'server', + message: 'Is this a server-side plugin?' + }, + { + type: 'confirm', + name: 'client', + message: 'Is this a client-side plugin?' + }, + { + type: 'confirm', + name: 'client', + message: 'Should we add it to the plugins.json?' } ]); + //============================================================================== // Creating plugin seed + //============================================================================== const seedTemplatePlugin = path.join(dir, 'scripts/templates/plugin'); const newPluginPath = path.join(pluginsDir, answers.pluginName); try { - fs.copySync(seedTemplatePlugin, newPluginPath); + fs.copySync(seedTemplatePlugin, newPluginPath, { + filter: (p) => { + if (!answers.server) { + return /templates\/plugin\/server/.test(p); + } - console.log('Success!'); + if (!answers.client) { + return /templates\/plugin\/client/.test(p); + } + + return true; + } + }); + + console.log(`✨ Yay! Talk Plugin Seed created! Find your plugin in the /plugins folder`); } catch (err) { console.error(err); } diff --git a/scripts/templates/plugin-client/client/.babelrc b/scripts/templates/plugin-client/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/scripts/templates/plugin-client/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/scripts/templates/plugin-client/client/.eslintrc.json b/scripts/templates/plugin-client/client/.eslintrc.json new file mode 100644 index 000000000..9fe56bd14 --- /dev/null +++ b/scripts/templates/plugin-client/client/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "es6": true, + "mocha": true + }, + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "experimentalObjectRestSpread": true, + "jsx": true + } + }, + "parser": "babel-eslint", + "plugins": [ + "react" + ], + "rules": { + "react/jsx-uses-react": "error", + "react/jsx-uses-vars": "error", + "no-console": ["warn", { "allow": ["warn", "error"] }] + } +} diff --git a/scripts/templates/plugin-client/index.js b/scripts/templates/plugin-client/index.js new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/scripts/templates/plugin-client/index.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/scripts/templates/plugin-server/index.js b/scripts/templates/plugin-server/index.js new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/scripts/templates/plugin-server/index.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/scripts/templates/plugin/client/components/MyPluginComponent.js b/scripts/templates/plugin/client/components/MyPluginComponent.js new file mode 100644 index 000000000..ff0fe6c3c --- /dev/null +++ b/scripts/templates/plugin/client/components/MyPluginComponent.js @@ -0,0 +1,15 @@ +import React from 'react'; +import {Icon} from 'plugin-api/beta/client/components/ui'; + +class MyPluginComponent extends React.Component { + render() { + return ( +
+ + Plugin Created by Talk CLI +
+ ); + } +} + +export default MyPluginComponent; diff --git a/scripts/templates/plugin/client/index.js b/scripts/templates/plugin/client/index.js index 931cd722c..acd0910be 100644 --- a/scripts/templates/plugin/client/index.js +++ b/scripts/templates/plugin/client/index.js @@ -1,6 +1,6 @@ /** - This is a client index example file and it should look like this: + This is a client index example file and it could look like this: ``` import LoveButton from './components/LoveButton'; @@ -17,4 +17,10 @@ To read more info on how to build client plugins. Please, go to: https://coralproject.github.io/talk/plugins-client.html */ -export default {}; +import MyPluginComponent from './components/MyPluginComponent'; + +export default { + slots: { + stream: [MyPluginComponent] + } +};