1 Star 0 Fork 0

dershine/rxdrag

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
plopfile.js 3.50 KB
一键复制 编辑 原始数据 按行查看 历史
Water.Li 提交于 2023-03-19 19:31 . backup
const Handlebars = require('handlebars');
module.exports = function (plop) {
plop.setHelper('titleCaseWithoutSpace', function (text) {
// Remove spaces in case text is hyphenated
const template = Handlebars.compile('{{titleCase text}}');
const titleCased = template({ text });
return titleCased.split(/\s/).join('');
});
plop.setGenerator('app', {
description: 'Adds a new app to Rxdrag',
prompts: [
{
type: 'input',
name: 'name',
message: 'app package name',
default: 'app-name',
validate: name => {
if (/\s/g.test(name)) {
throw new Error("Name can't have spaces");
}
return true;
},
transformer: name => name.toLowerCase()
},
{
type: 'input',
name: 'description',
message: 'app description',
default: 'Rxdrag Application'
},
{
type: 'input',
name: 'maintainer',
message: 'maintainer name',
default: 'Water.li'
}
],
actions: [
{
type: 'addMany',
destination: 'apps/{{name}}',
base: 'tools/generators/app',
templateFiles: 'tools/generators/app'
},
{
type: 'modify',
path: 'apps/core/package.json',
pattern: /"dependencies":\s*{/,
template: '"dependencies": {\n "@rxdrag/{{name}}": "workspace:*",'
},
{
type: 'modify',
path: 'apps/core/src/App.js',
pattern:
/const CoreApp = React.lazy\(\(\) => import\('\.\/routes'\)\);/,
template: `const CoreApp = React.lazy(() => import('./routes'));
const {{titleCaseWithoutSpace name}}App = React.lazy(() => import('@rxdrag/{{name}}'));`
},
{
type: 'modify',
path: 'apps/core/src/App.js',
pattern: /\{\/\* Applications \*\/\}/,
template: `{/* Applications */}
<Route path="/{{name}}">
<DefaultFallback>
<{{titleCaseWithoutSpace name}}App />
</DefaultFallback>
</Route>
`
},
{
type: 'modify',
path: 'packages/shared/src/constants/apps.js',
pattern: /\/\/ add default apps/,
template: `,{ href: '/{{name}}', icon: HelpIcon, description: '{{description}}', color: '#ffffff', contactEmail: 'hi@agarun.com' }
// add default apps`
},
function runPnpmInstall() {
const { spawn } = require('child_process');
const pnpmInstall = spawn('pnpm', ['install']);
pnpmInstall.stdout.pipe(process.stdout);
pnpmInstall.stderr.pipe(process.stderr);
}
]
});
plop.setGenerator('library', {
description: 'Adds a new library to Rxdrag',
prompts: [
{
type: 'input',
name: 'name',
message: 'library package name',
default: 'library-name',
validate: name => {
if (/\s/g.test(name)) {
throw new Error("Name can't have spaces");
}
return true;
},
transformer: name => name.toLowerCase()
},
{
type: 'input',
name: 'description',
message: 'library description',
default: 'Rxdrag Package'
},
{
type: 'input',
name: 'maintainer',
message: 'maintainer name',
default: 'Water.Li'
}
],
actions: [
{
type: 'addMany',
destination: 'packages/{{name}}',
base: 'tools/generators/library',
templateFiles: 'tools/generators/library'
}
]
});
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/dershine/rxdrag.git
git@gitee.com:dershine/rxdrag.git
dershine
rxdrag
rxdrag
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385