Clean strapi-generate-plugin

This commit is contained in:
Alexandre Bodin 2019-05-15 17:22:24 +02:00 committed by Jim LAURIE
parent ca453c32c7
commit 1d2449763f
8 changed files with 55 additions and 56 deletions

View File

@ -0,0 +1,11 @@
{
"name": "strapi-plugin-my-plugin",
"version": "0.0.0",
"description": "This is the description of my plugin.",
"private": true,
"strapi": {
"name": "my-plugin",
"icon": "plug",
"description": "Description of my plugin."
}
}

View File

@ -1 +0,0 @@
# Strapi plugin

View File

@ -13,59 +13,33 @@ const _ = require('lodash');
*/
module.exports = scope => {
const cliPkg = scope.strapiPackageJSON || {};
// Finally, return the JSON.
return _.merge(scope.appPackageJSON || {}, {
'name': `strapi-plugin-${scope.id}`,
'version': '0.0.0',
'description': 'This is the description of the plugin.',
'strapi': {
'name': scope.id,
'icon': 'plug',
'description': `Description of ${scope.id} plugin.`
name: `strapi-plugin-${scope.id}`,
version: '0.0.0',
description: 'This is the description of the plugin.',
strapi: {
name: scope.id,
icon: 'plug',
description: `Description of ${scope.id} plugin.`,
},
'scripts': {
'analyze:clean': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf stats.json',
'preanalyze': 'npm run analyze:clean',
'analyze': 'node ./node_modules/strapi-helper-plugin/lib/internals/scripts/analyze.js',
'prebuild': 'npm run build:clean',
'build:dev': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress',
'build': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=production node node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress',
'build:clean': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf admin/build',
'start': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/lib/server',
'generate': 'node ./node_modules/strapi-helper-plugin/node_modules/plop --plopfile ./node_modules/strapi-helper-plugin/lib/internals/generators/index.js',
'lint': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/eslint --ignore-path .gitignore --ignore-pattern \'/admin/build/\' --config ./node_modules/strapi-helper-plugin/lib/internals/eslint/.eslintrc.json admin',
'prettier': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/prettier --single-quote --trailing-comma es5 --write "{admin,__{tests,mocks}__}/**/*.js"',
'test': 'npm run lint',
'prepublishOnly': 'npm run build'
dependencies: {},
author: {
name: scope.author || 'A Strapi developer',
email: scope.email || '',
url: scope.website || '',
},
'dependencies': {},
'devDependencies': {
'strapi-helper-plugin': getDependencyVersion(cliPkg, 'strapi')
maintainers: [
{
name: scope.author || 'A Strapi developer',
email: scope.email || '',
url: scope.website || '',
},
],
engines: {
node: '^10.0.0',
npm: '>= 6.0.0',
},
'author': {
'name': scope.author || 'A Strapi developer',
'email': scope.email || '',
'url': scope.website || ''
},
'maintainers': [{
'name': scope.author || 'A Strapi developer',
'email': scope.email || '',
'url': scope.website || ''
}],
'engines': {
"node": "^10.0.0",
"npm": ">= 6.0.0"
},
'license': scope.license || 'MIT'
license: scope.license || 'MIT',
});
};
/**
* Get dependencies version
*/
function getDependencyVersion(packageJSON, module) {
return module === packageJSON.name ? packageJSON.version : packageJSON.dependencies && packageJSON.dependencies[module];
}

View File

@ -56,12 +56,6 @@ module.exports = (scope, cb) => {
const pluginDir = path.resolve(scope.rootPath, 'plugins');
fs.ensureDirSync(pluginDir);
// Copy the admin files.
fs.copySync(
path.resolve(__dirname, '..', 'files'),
path.resolve(scope.rootPath, 'plugins', scope.humanizeId)
);
// Trigger callback with no error to proceed.
return cb.success();
};

View File

@ -43,5 +43,23 @@ module.exports = {
'plugins/:humanizeId/package.json': {
jsonfile: packageJSON
},
// Copy dot files.
'plugins/:humanizeId/.editorconfig': {
copy: 'editorconfig'
},
'plugins/:humanizeId/.gitignore': {
copy: 'gitignore'
},
'plugins/:humanizeId/.gitattributes': {
copy: 'gitattributes'
},
// Copy Markdown files with some information.
'plugins/:humanizeId/README.md': {
template: 'README.md'
},
}
};

View File

@ -0,0 +1,3 @@
# Strapi plugin <%= id %>
A quick description of <%= id %>.