-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b933e7
commit 2ab37a0
Showing
7 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Description: | ||
Creates a Default.sublime-keymap file. Default.sublime-keymap files contain a JSON array that contains JSON objects to specify the key bindings. The JSON objects must contain a keys and command key, and may also contain a args key if the command requires arguments. | ||
|
||
Example: | ||
yo sublime-package:keymap | ||
|
||
This will create: | ||
Default.sublime-keymap: *.sublime-keymap files contain a JSON array that contains JSON objects to specify the key bindings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const config = { | ||
name: 'Keymap', | ||
description: 'Creates a Default.sublime-keymap file. Default.sublime-keymap files contain the key bindings (shortcuts) for a command.', | ||
priority: 4, | ||
versions: { | ||
'4.0.x': '', | ||
}, | ||
prompts: [ | ||
{ | ||
name: 'keymap_shortcut', | ||
message: 'What is the shortcut of your command?', | ||
type: 'input', | ||
default: 'super+ctrl+alt+k', | ||
}, | ||
{ | ||
name: 'keymap_command', | ||
message: 'What is the name of your command?', | ||
type: 'input', | ||
default: '${config.package_name_pascal_case}', | ||
}, | ||
], | ||
}; | ||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
'use strict'; | ||
/* eslint no-empty-function: ["error", { "allow": ["methods"] }] */ | ||
|
||
const Generator = require('yeoman-generator'); | ||
const chalk = require('chalk'); | ||
const yosay = require('yosay'); | ||
const path = require('path'); | ||
const helper = require('./../../src/helper.js'); | ||
const generator = path.basename(__dirname); | ||
const generator_config = require('./config.js'); | ||
|
||
let config = {}; | ||
let answers = {}; | ||
|
||
module.exports = class extends Generator { | ||
// initializing - Your initialization methods (checking current project state, getting configs, etc) | ||
async initializing() { | ||
|
||
// create or update config | ||
await helper.InitConfig(this, generator_config); | ||
|
||
// get current config | ||
config = this.config.getAll(); | ||
config.generator_name = generator_config.name || generator; | ||
config.generator_description = '\n' + generator_config.description || ''; | ||
} | ||
|
||
// prompting - Where you prompt users for options (where you’d call this.prompt()) | ||
async prompting() { | ||
this.log( | ||
yosay( | ||
`${chalk.green(config.generator_name)} ${config.generator_description}`, | ||
), | ||
); | ||
|
||
generator_config.prompts = helper.InterpolatePrompts(this, config, generator_config.prompts); | ||
answers = await this.prompt(generator_config.prompts); | ||
} | ||
|
||
// configuring - Saving configurations and configure the project (creating .editorconfig files and other metadata files) | ||
configuring() {} | ||
|
||
// default - If the method name doesn’t match a priority, it will be pushed to this group. | ||
default() {} | ||
|
||
// writing - Where you write the generator specific files (routes, controllers, etc) | ||
writing() { | ||
|
||
// merge data | ||
const data = { | ||
...config, | ||
...answers, | ||
}; | ||
|
||
this.renderTemplate( | ||
this.templatePath('Default.sublime-keymap'), | ||
this.destinationPath('Default.sublime-keymap'), | ||
data, | ||
); | ||
} | ||
|
||
// conflicts - Where conflicts are handled (used internally) | ||
conflicts() { } | ||
|
||
// install - Where installations are run (npm, bower) | ||
install() {} | ||
|
||
// end - Called last, cleanup, say good bye, etc | ||
end() { | ||
helper.End(this, config); | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{ "keys": ["<%= keymap_shortcut %>"], "command": "<%= keymap_command %>" }, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters