mirror of
https://github.com/portainer/portainer.git
synced 2025-07-18 21:09:40 +02:00
chore(project): add angular components code snippets (#3649)
* chore(project): add angular components code snippets * chore(project): add plopjs templates * feat(project): use class in controller template * chore(client): rename generators * chore(vscode): fix controller snippets * chore(git): ignore only specific files in .vscode * chore(plop): move generators to app * chore(plop): fix portainer module * fix(git): fix gitignore vscode * chore(vscode): remove symling to code-snippets * refactor(build): move plop templates to root * feat(build): add readme for plop
This commit is contained in:
parent
38066ece33
commit
766ced7cb1
9 changed files with 804 additions and 33 deletions
46
plopfile.js
Normal file
46
plopfile.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
module.exports = function (plop) {
|
||||
// use of INIT_CWD instead of process.cwd() because yarn changes the cwd
|
||||
const cwd = process.env.INIT_CWD;
|
||||
plop.addHelper('cwd', () => cwd);
|
||||
plop.setGenerator('component', {
|
||||
prompts: [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'component name please',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'module',
|
||||
message: 'module name please',
|
||||
default: `${getCurrentPortainerModule(cwd)}`,
|
||||
// when: false
|
||||
},
|
||||
], // array of inquirer prompts
|
||||
actions: [
|
||||
{
|
||||
type: 'add',
|
||||
path: `{{cwd}}/{{dashCase name}}/index.js`,
|
||||
templateFile: './plop-templates/component.js.hbs',
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: `{{cwd}}/{{dashCase name}}/{{camelCase name}}Controller.js`,
|
||||
templateFile: './plop-templates/component-controller.js.hbs',
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: `{{cwd}}/{{dashCase name}}/{{camelCase name}}.html`,
|
||||
templateFile: './plop-templates/component.html.hbs',
|
||||
},
|
||||
], // array of actions
|
||||
});
|
||||
};
|
||||
|
||||
function getCurrentPortainerModule(cwd) {
|
||||
const match = cwd.match(/\/app\/([^\/]*)(\/.*)?$/);
|
||||
if (!match || !match.length || match[1] === 'portainer') {
|
||||
return 'app';
|
||||
}
|
||||
return match[1];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue