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

fix/schematic #488

Open
wants to merge 66 commits into
base: master
Choose a base branch
from
Open

fix/schematic #488

wants to merge 66 commits into from

Conversation

kirill-ivanovvv
Copy link
Member

closes #409

README_RU.md Outdated
@@ -90,7 +90,7 @@

### Генерация

- `yarn generate project` - генерация схематики проекта
- `yarn generate` - генерация схематики проекта
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что-то помимо project будем генерировать? Если да, то надо оставить как было

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

там был еще скрипт "library". его не трогал

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тогда возвращай

"sort-package-json@2.4.1": "patch:sort-package-json@npm%3A2.4.1#./.yarn/patches/sort-package-json-npm-2.4.1-8ff012947f.patch",
"typescript": "5.5.4"
},
"dependencies": {
"@atls/schematics": "workspace:*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лишнее

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • мы на уровне plugin-schematic запрашиваем путь до самого schematic. нам нужны исходники шаблонов
  • соответственно собранный бандл цепляет зависимости из корня
  • если этой зависимости в корне не будет, то мы не найдет путь до пакета -> ошибка

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так. Давай заново.

У тебя корень всего и вся - cli. В нем ты собираешь бандл и плагины. Плагины у тебя в зависимостях. В плагинах должно быть в зависимостях все то, что им нужно для работы. Они это ниоткуда не должны получать кроме как сами запрашивать.

Поэтому если ты в проекте запрашиваешь в корневом package.json запрашиваешь эту зависимость и бандл "работает", то он работает не благодаря а вопреки.

Возьми любой плагин, тот же image, format. Посмотри как они работают с зависимостями.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • например в image вижу зависимости импортируются как обычные
  • тоесть в package.json - dependencies
  • в src - через обычный импорт
  • импортируемые пакеты просто упаковываются в бандл и все

  • angular/schematics использует шаблоны с определенным неймингом - https://github.com/atls/raijin/tree/fix/schematic/schematics/schematics/src/schematic/templates
  • тоесть упаковать в бандл эту историю мы не можем, она должна быть изолированна и неизменна.
    • либо конвертировать все шаблоны в строки. при запуске плагина записывать эти строки по файлам и потом уже выполнять миграции. тоесть написать js-прослойку, чтобы шаблоны были в js-формате. далее чистка этих файлов НАПРИМЕР
    • если делать так, то нужно перед тем, как запускать сборку бандла - запусть еще и сборку @atls/schematics, тоесть связать эти сборки

  • у меня вот так сделанно - https://github.com/atls/raijin/blob/fix/schematic/yarn/plugin-schematics/sources/getters/collection-path.getter.ts
    • я нашел этот метод в старой версии плагина + ГПТ
    • мы запрашиваем путь до коллекции (она находится в @atls/schematics + собранная в cjs + адаптация к cjs типо замены путей импортов и тд), и по этому пути берем конфиг для миграции
    • соответственно я не могу включить это в бандл, потомучто это не JS (структура файлов и папок)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ты можешь либо насильно их импортировать в ts либо конвертировать в строки

.yarnrc.yml Outdated
yarnPath: yarn/cli/src/cli.dev.mjs
# yarnPath: .yarn/releases/yarn-4.5.1.cjs
yarnPath: .yarn/releases/yarn.mjs
# yarnPath: yarn/cli/dist/yarn.mjs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как будто опять дубли

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • .yarn/releases/yarn.mjs - смотрит зависимости в корневом package.json
  • yarn/cli/dist/yarn.mjs - смотрит зависимости в yarn/cli
  • ну и дев-вариант

путь до releases удалить?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у тебя должны быть:

  • releases - путь до стокового бандла
  • cli/src/cli.dev.mjs - наш дев

Остальное - лишнее

"globby": "13.2.2"
},
"peerDependencies": {
"@atls/code-runtime": "*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что-то странное - выше обычная зависимость, а тут - пир

@@ -1,6 +1,6 @@
{
"name": "@atls/yarn-cli",
"version": "1.1.5",
"version": "1.1.5-atls",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

постфикс делается билдом бандла. В гит не должно попадать

@@ -39,6 +39,7 @@
"typescript": "5.5.4"
},
"peerDependencies": {
"@atls/schematics": "*",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что-то странное - выше обычные зависимости, а тут пир

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schematic: исправить использование
2 participants