Giter VIP home page Giter VIP logo

create-snippet's People

Contributors

zharinov-nikita avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

create-snippet's Issues

run command

Выполнить массив команд переданных через консоль

Flat

Создание файлов без дополнительной директории

loading

Статус загрузки в момент создания компонента

Добавить подсказки (any-string-in-kebab-case)

private async addOptions() {
const data = async () => [
{
type: 'select',
name: 'snippetName',
message: 'Pick a snippet',
choices: fs.readdirSync(this.rootDirConfig).map((path) => {
return { title: path, value: path }
}),
initial: 0,
},
{ type: 'text', name: 'name', message: 'Pick a name' },
{ type: 'text', name: 'path', message: 'Pick a path' },
{
type: 'toggle',
name: 'isFlat',
message: 'Create a flat file structure?',
initial: false,
active: 'yes',
inactive: 'no',
},
{
type: async (_: any, values: TypeOptionsSnippetGeneration) => {
return (await this.check(values.snippetName)).isPrefix ? 'text' : null
},
name: 'prefix',
message: 'Pick a prefix',
},
{
type: async (_: any, values: TypeOptionsSnippetGeneration) => {
return (await this.check(values.snippetName)).isSuffix ? 'text' : null
},
name: 'suffix',
message: 'Pick a suffix',
},
]

Refactoring (ModuleSnippet)

if (new RegExp(enumPrefixName.camelCase).test(data)) prefix += 1
if (new RegExp(enumPrefixName.lowerKebabCase).test(data)) prefix += 1
if (new RegExp(enumPrefixName.lowerSnakeCase).test(data)) prefix += 1
if (new RegExp(enumPrefixName.pascalCase).test(data)) prefix += 1
if (new RegExp(enumPrefixName.upperKebabCase).test(data)) prefix += 1
if (new RegExp(enumPrefixName.upperSnakeCase).test(data)) prefix += 1
if (new RegExp(enumSuffixName.camelCase).test(data)) suffix += 1
if (new RegExp(enumSuffixName.lowerKebabCase).test(data)) suffix += 1
if (new RegExp(enumSuffixName.lowerSnakeCase).test(data)) suffix += 1
if (new RegExp(enumSuffixName.pascalCase).test(data)) suffix += 1
if (new RegExp(enumSuffixName.upperKebabCase).test(data)) suffix += 1
if (new RegExp(enumSuffixName.upperSnakeCase).test(data)) suffix += 1

PrefixName и SuffixName

Добавить возможность в файлах вместе с TemplateName использовать PreffixName

[is]-snippet-name

Если передать название снипепета как is-snippet-name, то будет предложен выбор (true/false) для его создания

Передавать через настройки путь к верхней директории

  1. Чтобы создать все файлы за один проход, достаточно указать путь к папке ui
  2. Чтобы создать определенный файл, достаточно указать путь к определенному файлу или массив файлов ["ui/template-name.hook.ts", "index.ts"]
📁ui
├──📁template-name.component.ts
├──📁temlate-name.hook.ts
└──📁index.ts

github-actions (npm published)

При пуше нового тега обновить версию в package.json и отправить пакет в npm

  • 1. Обновить версию в package.json при создании нового тега
  • 2. При пуше в репозиторий тега сделать сборку и отправить в npm

JSON.stringify

Заменить метод JSON.stringify на точное копирование строки 🤔

formatSnippet - refactoring

private formatSnippet(pathToSnippet: string) {
const unformattedSnippet = JSON.stringify(fs.readFileSync(nodePath.join(pathToSnippet), 'utf-8'))
const formattedSnippet = unformattedSnippet
.replaceAll(enumSnippetName.camelCase, `${this.moduleString.toCamelCase(this.options.name)}`)
.replaceAll(enumSnippetName.pascalCase, `${this.moduleString.toPascalCase(this.options.name)}`)
.replaceAll(enumSnippetName.lowerSnakeCase, `${this.moduleString.toLowerSnakeCase(this.options.name)}`)
.replaceAll(enumSnippetName.upperSnakeCase, `${this.moduleString.toUpperSnakeCase(this.options.name)}`)
.replaceAll(enumSnippetName.lowerKebabCase, `${this.moduleString.toLowerKebabCase(this.options.name)}`)
.replaceAll(enumSnippetName.upperKebabCase, `${this.moduleString.toUpperKebabCase(this.options.name)}`)
.replaceAll(enumPrefixName.camelCase, `${this.moduleString.toCamelCase(this.options.prefix)}`)
.replaceAll(enumPrefixName.pascalCase, `${this.moduleString.toPascalCase(this.options.prefix)}`)
.replaceAll(enumPrefixName.lowerSnakeCase, `${this.moduleString.toLowerSnakeCase(this.options.prefix)}`)
.replaceAll(enumPrefixName.upperSnakeCase, `${this.moduleString.toUpperSnakeCase(this.options.prefix)}`)
.replaceAll(enumPrefixName.lowerKebabCase, `${this.moduleString.toLowerKebabCase(this.options.prefix)}`)
.replaceAll(enumPrefixName.upperKebabCase, `${this.moduleString.toUpperKebabCase(this.options.prefix)}`)
.replaceAll(enumSuffixName.camelCase, `${this.moduleString.toCamelCase(this.options.suffix)}`)
.replaceAll(enumSuffixName.pascalCase, `${this.moduleString.toPascalCase(this.options.suffix)}`)
.replaceAll(enumSuffixName.lowerSnakeCase, `${this.moduleString.toLowerSnakeCase(this.options.suffix)}`)
.replaceAll(enumSuffixName.upperSnakeCase, `${this.moduleString.toUpperSnakeCase(this.options.suffix)}`)
.replaceAll(enumSuffixName.lowerKebabCase, `${this.moduleString.toLowerKebabCase(this.options.suffix)}`)
.replaceAll(enumSuffixName.upperKebabCase, `${this.moduleString.toUpperKebabCase(this.options.suffix)}`)
return JSON.parse(formattedSnippet)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.