Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dennykorsukewitz committed Nov 21, 2023
1 parent 797e707 commit 3596939
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
14 changes: 11 additions & 3 deletions generators/plugin/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
const config = {
name: 'README.md',
priority: 5,
name: 'Plugin',
priority: 2,
versions: {
'4.0.x': '',
},
prompts: [],
prompts: [
{
name: 'plugin_name',
message: 'What is the name of your new plugin?',
type: 'input',
default: '${config.package_name_pascal_case}',
store: true,
},
],
};
module.exports = config;
4 changes: 3 additions & 1 deletion generators/plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ module.exports = class extends Generator {
`${chalk.green(config.generator_name)}`,
),
);

generator_config.prompts = helper.InterpolatePrompts(this, config, generator_config.prompts);
answers = await this.prompt(generator_config.prompts);
}

Expand All @@ -51,7 +53,7 @@ module.exports = class extends Generator {

this.renderTemplate(
this.templatePath('plugin.py'),
this.destinationPath(`${data.package_name}.py`),
this.destinationPath(`${data.package_name_pascal_case}.py`),
data,
);
}
Expand Down
2 changes: 1 addition & 1 deletion generators/readme/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const config = {
name: 'README.md',
priority: 5,
priority: 1,
versions: {
'4.0.x': '',
},
Expand Down
18 changes: 11 additions & 7 deletions src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ async function InitConfig(Generator, GeneratorConfig) {
config.generator = Generator._namespace;
config.generator_config = GeneratorConfig;

if (config.init_config) {
return config;
}

// package directory name of current package
config.package_dir = Generator.destinationRoot();
config.init_config = true;

config.file_list = await GetFileList(Generator, config);

Expand Down Expand Up @@ -129,6 +124,9 @@ function GetAvailableGenerators(Generator, config) {

let generators = config.generators_by_versions[config.sublime_version];

console.log('generators');
console.log(generators);

// skip README generator if file already exists
if (config && config.file_list && config.file_list.includes('README.md')) {
generators = generators.filter(function(generator_data) {
Expand Down Expand Up @@ -176,12 +174,12 @@ function SetPackageName(Generator, config) {

const name = config.package_dir.split(/[\\/]/).pop();

config.package_seperator = '-';
const package_name_split = name.split(config.package_seperator);
const package_name_split = name.split('-');

if (package_name_split.length == 2) {
config.package_prefix = package_name_split.shift();
config.package_suffix = package_name_split.pop();
config.package_seperator = '-';
}

if (config && config.package_prefix && config.package_seperator && config.package_suffix) {
Expand All @@ -191,6 +189,12 @@ function SetPackageName(Generator, config) {
else {
config.package_name_predicted = name;
}

if (config && config.package_name) {

config.package_name_pascal_case = changeCase.pascalCase(config.package_name);
}

Generator.config.set('package_name_predicted', config.package_name_predicted);
}

Expand Down

0 comments on commit 3596939

Please sign in to comment.