mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-15 09:04:04 +02:00
78 lines
1.5 KiB
JavaScript
78 lines
1.5 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
const Generator = require('yeoman-generator');
|
||
|
const chalk = require('chalk');
|
||
|
const yosay = require('yosay');
|
||
|
|
||
|
module.exports = class extends Generator {
|
||
|
prompting() {
|
||
|
this.log(yosay(`Welcome to the fine ${chalk.red('generator-joplin')} generator!`));
|
||
|
|
||
|
const prompts = [
|
||
|
{
|
||
|
type: 'input',
|
||
|
name: 'pluginName',
|
||
|
message: 'Plugin name:',
|
||
|
},
|
||
|
{
|
||
|
type: 'input',
|
||
|
name: 'pluginDescription',
|
||
|
message: 'Plugin description:',
|
||
|
},
|
||
|
{
|
||
|
type: 'input',
|
||
|
name: 'pluginAuthor',
|
||
|
message: 'Author:',
|
||
|
},
|
||
|
{
|
||
|
type: 'input',
|
||
|
name: 'pluginHomepageUrl',
|
||
|
message: 'Homepage URL:',
|
||
|
},
|
||
|
];
|
||
|
|
||
|
return this.prompt(prompts).then(props => {
|
||
|
this.props = props;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
writing() {
|
||
|
// Due to WONTFIX bug in npm, which treats .gitignore and pakage.json in a special way,
|
||
|
// we need to give them a different name in the templates dir and then rename them
|
||
|
// when installing.
|
||
|
// https://github.com/npm/npm/issues/3763
|
||
|
|
||
|
const files = [
|
||
|
'.gitignore_TEMPLATE',
|
||
|
'package_TEMPLATE.json',
|
||
|
'README.md',
|
||
|
'tsconfig.json',
|
||
|
'webpack.config.js',
|
||
|
'src/index.ts',
|
||
|
'src/manifest.json',
|
||
|
];
|
||
|
|
||
|
for (const file of files) {
|
||
|
const destFile = file.replace(/_TEMPLATE/, '');
|
||
|
this.fs.copyTpl(
|
||
|
this.templatePath(file),
|
||
|
this.destinationPath(destFile),
|
||
|
this.props
|
||
|
);
|
||
|
}
|
||
|
|
||
|
this.fs.copy(
|
||
|
this.templatePath('api'),
|
||
|
this.destinationPath('api')
|
||
|
);
|
||
|
}
|
||
|
|
||
|
install() {
|
||
|
this.installDependencies({
|
||
|
npm: true,
|
||
|
bower: false,
|
||
|
yarn: false,
|
||
|
});
|
||
|
}
|
||
|
};
|