Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plasma-infra(scaffold): Extend script for update/sync component list #1275

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
"author": "Salute Frontend Team <salute.developers@gmail.com>",
"license": "MIT",
"scripts": {
"scaffold:update-components-docs": "npm run scaffold:components",
"scaffold:docs": "simple-scaffold -c scaffold/scaffold-config.js --name $npm_config_package",
"scaffold:components": "node scaffold/scaffold-components.js",
"scaffold:update-docs-ui": "node scaffold/update-docs-ui.js && npm i --no-audit --no-progress --package-lock-only --lockfile-version 2 --legacy-peer-deps --prefix=$npm_config_dir",
16 changes: 16 additions & 0 deletions scaffold/Readme.md
Original file line number Diff line number Diff line change
@@ -56,3 +56,19 @@ npm run scaffold:docs --package="plasma-asdk" --vertical="plasma-themes" --theme
Чтобы избежать данного warning нужно использовать экранирование `\`.

Например: `style=\{{flexDirection: 'column'}}`

### Как обновить список компонентов в уже имеющейся документации?

Есть отдельная команда - `npm run scaffold:update-components-docs`.

Например, для пакета `caldera-online`:

```console
npm run scaffold:update-components-docs --vertical="caldera-online-themes" --package="caldera-online" --exclude="sheet"
```

Обновит/добавит/синхронизирует список компонентов документации и библиотеки, при этом **исключит** компонент `Sheet`.

**Примечание:**

Аргумент `exclude` принимает перечисление компонентов через запятую: `--exclude="sheet,textarea,etc"`
12 changes: 10 additions & 2 deletions scaffold/scaffold-components.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,13 @@ const fg = require('fast-glob');
// INFO: Генерация компонентов по шаблону и на основе списка компонентов на основе пакета
// INFO: для которого делается документация
async function main() {
const { npm_config_package: npmConfigPackage, npm_config_vertical: npmConfigVertical } = process.env || {};
const {
npm_config_package: npmConfigPackage,
npm_config_vertical: npmConfigVertical,
npm_config_exclude: npmConfigExclude,
} = process.env || {};

const excludeList = npmConfigExclude ? npmConfigExclude.split(',').map((component) => component?.trim()) : [];

if (!npmConfigPackage) {
return;
@@ -25,7 +31,9 @@ async function main() {

// INFO: Получаем актуальный список директорий компонентов
// например ['AutoComplete','Avatar','AvatarGroup','Badge','Button','ButtonGroup','Cell']
const components = await readdir(packageDir);
const components = (await readdir(packageDir)).filter(
(component) => !excludeList.includes(component.toLowerCase()),
);

// INFO: Собираем шаблоны документации для компонентов
// [
Loading