mirror of
https://github.com/strapi/strapi.git
synced 2025-08-18 13:45:25 +00:00
Clean strapi-generate-plugin
This commit is contained in:
parent
ca453c32c7
commit
1d2449763f
11
examples/getstarted/plugins/myplugin/package.json
Normal file
11
examples/getstarted/plugins/myplugin/package.json
Normal 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."
|
||||||
|
}
|
||||||
|
}
|
@ -1 +0,0 @@
|
|||||||
# Strapi plugin
|
|
@ -13,59 +13,33 @@ const _ = require('lodash');
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = scope => {
|
module.exports = scope => {
|
||||||
const cliPkg = scope.strapiPackageJSON || {};
|
|
||||||
|
|
||||||
// Finally, return the JSON.
|
// Finally, return the JSON.
|
||||||
return _.merge(scope.appPackageJSON || {}, {
|
return _.merge(scope.appPackageJSON || {}, {
|
||||||
'name': `strapi-plugin-${scope.id}`,
|
name: `strapi-plugin-${scope.id}`,
|
||||||
'version': '0.0.0',
|
version: '0.0.0',
|
||||||
'description': 'This is the description of the plugin.',
|
description: 'This is the description of the plugin.',
|
||||||
'strapi': {
|
strapi: {
|
||||||
'name': scope.id,
|
name: scope.id,
|
||||||
'icon': 'plug',
|
icon: 'plug',
|
||||||
'description': `Description of ${scope.id} plugin.`
|
description: `Description of ${scope.id} plugin.`,
|
||||||
},
|
},
|
||||||
'scripts': {
|
dependencies: {},
|
||||||
'analyze:clean': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf stats.json',
|
author: {
|
||||||
'preanalyze': 'npm run analyze:clean',
|
name: scope.author || 'A Strapi developer',
|
||||||
'analyze': 'node ./node_modules/strapi-helper-plugin/lib/internals/scripts/analyze.js',
|
email: scope.email || '',
|
||||||
'prebuild': 'npm run build:clean',
|
url: scope.website || '',
|
||||||
'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': {},
|
maintainers: [
|
||||||
'devDependencies': {
|
{
|
||||||
'strapi-helper-plugin': getDependencyVersion(cliPkg, 'strapi')
|
name: scope.author || 'A Strapi developer',
|
||||||
|
email: scope.email || '',
|
||||||
|
url: scope.website || '',
|
||||||
},
|
},
|
||||||
'author': {
|
],
|
||||||
'name': scope.author || 'A Strapi developer',
|
engines: {
|
||||||
'email': scope.email || '',
|
node: '^10.0.0',
|
||||||
'url': scope.website || ''
|
npm: '>= 6.0.0',
|
||||||
},
|
},
|
||||||
'maintainers': [{
|
license: scope.license || 'MIT',
|
||||||
'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'
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Get dependencies version
|
|
||||||
*/
|
|
||||||
|
|
||||||
function getDependencyVersion(packageJSON, module) {
|
|
||||||
return module === packageJSON.name ? packageJSON.version : packageJSON.dependencies && packageJSON.dependencies[module];
|
|
||||||
}
|
|
||||||
|
@ -56,12 +56,6 @@ module.exports = (scope, cb) => {
|
|||||||
const pluginDir = path.resolve(scope.rootPath, 'plugins');
|
const pluginDir = path.resolve(scope.rootPath, 'plugins');
|
||||||
fs.ensureDirSync(pluginDir);
|
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.
|
// Trigger callback with no error to proceed.
|
||||||
return cb.success();
|
return cb.success();
|
||||||
};
|
};
|
||||||
|
@ -43,5 +43,23 @@ module.exports = {
|
|||||||
'plugins/:humanizeId/package.json': {
|
'plugins/:humanizeId/package.json': {
|
||||||
jsonfile: packageJSON
|
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'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
3
packages/strapi-generate-plugin/templates/README.md
Normal file
3
packages/strapi-generate-plugin/templates/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Strapi plugin <%= id %>
|
||||||
|
|
||||||
|
A quick description of <%= id %>.
|
Loading…
x
Reference in New Issue
Block a user