commit b4d17173e58a3057c85d4d95e621e6526aaeee7b Author: Ilia Miheev Date: Sat Nov 22 22:14:33 2025 +0300 first commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..db6e15a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +example/ diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..db6e15a --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +node_modules/ +example/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..93bf1de --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Ilia Miheev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cfb674f --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Создание структуры сайта-документации на docsify + +**docidoci** — это cli программа для создания структуры сайта-документации на docsify. + +При базовой конфигурации docsify сайт не выглядит впечатляющим, поэтому в 100% случаев к нему добавляют плагины и изменяют начальную конфигурацию. С помощью docidoci можно создать проект за считанные секунды, в котором не нужно тратить время на подключение: + +1. Навигационной и боковой панели, а так же титульной страницы и страницы 404 + +2. Переключения световой темы + +3. Подсветки и копирования кода + +4. Поиска по документации + +5. Небольшой seo оптимизации сайта + +6. Прочего + +После создания проекта плагины по умолчанию можно легко отключить или подключить свои. + +## Установка + +Скачать docidoci можно с помощью следущей команды: + +```bash +npm i -g docidoci +``` + +## Использование + +Интерфейс программы предоставлет собой три команды: + +### docidoci help + +Выводит список доступных команд. Так же посмотреть список команд можно введя docidoci без параметров + +### docidoci settings + +Создаёт в текущей дирректории файл `docidociSettings.json` с помощью которого осуществляется настройка проекта. В файле можно указать название проекта, ссылку на репозиторий, цветовую тему, данные для seo и другое. Создание файла настроек не является обязательным, но оно поможет ускорить процесс создания сайта. + +### docidoci init + +Самая главная команда, использующаяся для создания структуры проекта. Если в текущей дирректории существует файл `docidociSettings.json`, то проект будет создан на основе вписанных настроек, иначе — будет создана более "скромная" версия проекта. diff --git a/files/docidociSettings.json b/files/docidociSettings.json new file mode 100644 index 0000000..ec68ce9 --- /dev/null +++ b/files/docidociSettings.json @@ -0,0 +1,13 @@ +{ + "projectName": "Название проекта", + "repo": "Ссылка на репозиторий если есть", + "preloaderText": "Текст выводимый при загрузке страницы", + "themeColor": "Цветовая тема сайта", + "seo": { + "title": "Заголовок сайта", + "description": "Описание сайта", + "keywords": "Ключевые слова, через запятую", + "image": "Картинка при отображении ссылки", + "url": "Ссылка на сайт" + } +} diff --git a/files/files.zip b/files/files.zip new file mode 100644 index 0000000..bb4284f Binary files /dev/null and b/files/files.zip differ diff --git a/files/index.html b/files/index.html new file mode 100644 index 0000000..3cac9fa --- /dev/null +++ b/files/index.html @@ -0,0 +1,89 @@ + + + + + + {title} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

{preloaderText}

+
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/files/indexWithoutSettings.html b/files/indexWithoutSettings.html new file mode 100644 index 0000000..42112fb --- /dev/null +++ b/files/indexWithoutSettings.html @@ -0,0 +1,75 @@ + + + + + + О чём будет ваша дока? + + + + + + + + + + + + + + + +
+

Секундочку...

+
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..fa8c91f --- /dev/null +++ b/index.js @@ -0,0 +1,111 @@ +#!/usr/bin/env node + +const fs = require('fs'); +const path = require('path'); +const AdmZip = require('adm-zip'); +const minimist = require('minimist'); + +const helpMessage = `Список доступных команд docidoci: + help — вывод списка доступных команд + settings — создаёт файл в котором нужно указать мета-теги для сайта + init — создание структуры проекта на основе указанных настроек + ` + +function rebrendingData() { + const settingsPath = path.join(process.cwd(), 'docidociSettings.json') + const indexHtmlPath = path.join(process.cwd(), 'index.html') + const settings = JSON.parse(fs.readFileSync(settingsPath)) + + data = String(fs.readFileSync('./index.html')) + htmlSample = data.replace('{projectName}', settings.projectName) + htmlSample = htmlSample.replace('{repo}', settings.repo) + htmlSample = htmlSample.replace(/{themeColor}/g, settings.themeColor) + htmlSample = htmlSample.replace('{preloaderText}', settings.preloaderText) + htmlSample = htmlSample.replace(/{title}/g, settings.seo.title) + htmlSample = htmlSample.replace(/{description}/g, settings.seo.description) + htmlSample = htmlSample.replace('{keywords}', settings.seo.keywords) + htmlSample = htmlSample.replace('{image}', settings.seo.image) + htmlSample = htmlSample.replace('{url}', settings.seo.url) + + fs.writeFileSync(indexHtmlPath, htmlSample) +} + +function castomCopyFile(from, to) { + const originalFile = path.join(__dirname, from); + const copyFile = path.join(process.cwd(), to); + fs.copyFileSync(originalFile, copyFile); +} + + +function commandInit() { + const archivePath = path.join(__dirname, './files/files.zip'); + const targetPath = process.cwd(); + const settingsPath = path.join(process.cwd(), 'docidociSettings.json') + + // Проверяем наличие архива + if (!fs.existsSync(archivePath)) { + console.log('Архив со структурой проекта не найден!'); + process.exit(1) + } + + // Проверяем, существует ли уже проект + let indexHtmlPath = path.join(process.cwd(), './index.html') + if (fs.existsSync(indexHtmlPath) && !argv.y) { + console.log(`Ошибка инициализации! + +В папке "${targetPath}" уже существует проект! +Если хочешь его реинициализировать, то введи команду "docidoci init -y"`); + process.exit(1) + } + + // Разархивировываем архив + const zip = new AdmZip(archivePath); + zip.extractAllTo(targetPath, true); + + // Переносим html шаблон + if (fs.existsSync(settingsPath)) { + castomCopyFile('./files/index.html', 'index.html') + rebrendingData() + } else { + castomCopyFile('./files/indexWithoutSettings.html', 'index.html') + } + + console.log(`Готово, проект инициализирован) + +Проект находится в папке ${targetPath} +Запустить проект docsify можно командой "docsify serve"`); + process.exit() +}; + +function commandSettings() { + castomCopyFile('./files/docidociSettings.json', 'docidociSettings.json') + console.log(`Файл настроек скопирован! + +Заполни поля своими данными или сделай их пустыми. +После выполни команду "docidoci init"`); +} + + +// Обработка аргументов из командной строки +const argv = minimist(process.argv.slice(2)); +if (argv._.length == 0) { + console.log(helpMessage); + return +} else if (argv._.length > 1) { + console.log('За раз можно указывать только одну команду!!!\n'); + console.log(helpMessage); + return +} + + +// Обработка команд +const command = argv._[0] // основная команда +if (command === 'init') { + commandInit(); +} else if (command == 'help') { + console.log(helpMessage) +} else if (command == 'settings') { + commandSettings() +} else { + console.log(`Неизвестная команда "${command}". Введи "docidoci help", чтобы увидеть список доступных команд`); +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..a93d490 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,36 @@ +{ + "name": "docidoci", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "docidoci", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "adm-zip": "^0.5.16", + "minimist": "^1.2.8" + }, + "bin": { + "docidoci": "index.js" + } + }, + "node_modules/adm-zip": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.16.tgz", + "integrity": "sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==", + "engines": { + "node": ">=12.0" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..d7be267 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "docidoci", + "version": "1.0.0", + "description": "Создание структуры сайта-документации на docsify", + "main": "index.js", + "bin": { + "docidoci": "./index.js" + }, + "keywords": [ + "docsify", + "doc", + "documentation", + "maket", + "constructor", + "документация", + "макет", + "конструктор" + ], + "author": { + "name": "m_ilia", + "email": "polo-volumes-ounce@duck.com" + }, + "license": "ISC", + "dependencies": { + "adm-zip": "^0.5.16", + "minimist": "^1.2.8" + } +}