@akanjs/cli 0.9.41 → 0.9.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +941 -538
- package/cjs/src/guidelines/___library/sharedUiStructureDescription.en.md +0 -1
- package/cjs/src/guidelines/databaseModule/databaseModule.instruction.md +3 -50
- package/cjs/src/guidelines/modelService/modelService.generate.json +3 -40
- package/cjs/src/guidelines/modelService/modelService.instruction.md +0 -164
- package/cjs/src/guidelines/scalarModule/scalarModule.instruction.md +0 -3
- package/cjs/src/templates/__scalar/__model__/__model__.constant.js +1 -1
- package/cjs/src/templates/__scalar/__model__/__model__.dictionary.js +1 -1
- package/cjs/src/templates/__scalar/__model__/__model__.document.js +1 -1
- package/cjs/src/templates/app/akan.config.js +1 -1
- package/cjs/src/templates/app/app/[lang]/layout.js +1 -1
- package/cjs/src/templates/app/app/[lang]/page.js +1 -1
- package/cjs/src/templates/app/app/csr.js +1 -1
- package/cjs/src/templates/app/app/layout.js +1 -1
- package/cjs/src/templates/app/app/robots.js +1 -1
- package/cjs/src/templates/app/app/sitemap.js +1 -1
- package/cjs/src/templates/app/base/baseLogic.js +1 -1
- package/cjs/src/templates/app/base/index.js +1 -1
- package/cjs/src/templates/app/common/commonLogic.js +1 -1
- package/cjs/src/templates/app/common/index.js +1 -1
- package/cjs/src/templates/app/env/env.client.js +1 -1
- package/cjs/src/templates/app/env/env.client.type.js +1 -1
- package/cjs/src/templates/app/env/env.server.js +1 -1
- package/cjs/src/templates/app/jest.config.js +1 -1
- package/cjs/src/templates/app/lib/___appName__/__appName__.dictionary.js +7 -2
- package/cjs/src/templates/app/lib/___appName__/__appName__.service.js +2 -9
- package/cjs/src/templates/app/lib/___appName__/{_server.js → __appName__.signal.js} +9 -9
- package/cjs/src/templates/app/lib/___appName__/__appName__.store.js +1 -1
- package/cjs/src/templates/app/lib/option.js +1 -1
- package/cjs/src/templates/app/lib/setting/Setting.Template.js +6 -19
- package/cjs/src/templates/app/lib/setting/Setting.Unit.js +3 -3
- package/cjs/src/templates/app/lib/setting/Setting.Util.js +8 -2
- package/cjs/src/templates/app/lib/setting/Setting.View.js +4 -7
- package/cjs/src/templates/app/lib/setting/Setting.Zone.js +2 -8
- package/cjs/src/templates/app/lib/setting/setting.constant.js +1 -1
- package/cjs/src/templates/app/lib/setting/setting.dictionary.js +1 -1
- package/cjs/src/templates/app/lib/setting/setting.document.js +1 -1
- package/cjs/src/templates/app/lib/setting/setting.service.js +1 -1
- package/cjs/src/templates/app/lib/setting/setting.signal.js +1 -1
- package/cjs/src/templates/app/lib/setting/setting.store.js +1 -1
- package/cjs/src/templates/app/lib/summary/Summary.Template.js +5 -4
- package/cjs/src/templates/app/lib/summary/Summary.Unit.js +4 -5
- package/cjs/src/templates/app/lib/summary/Summary.Util.js +10 -3
- package/cjs/src/templates/app/lib/summary/Summary.View.js +5 -9
- package/cjs/src/templates/app/lib/summary/Summary.Zone.js +1 -23
- package/cjs/src/templates/app/lib/summary/summary.constant.js +1 -1
- package/cjs/src/templates/app/lib/summary/summary.dictionary.js +1 -1
- package/cjs/src/templates/app/lib/summary/summary.document.js +1 -1
- package/cjs/src/templates/app/lib/summary/summary.service.js +1 -1
- package/cjs/src/templates/app/lib/summary/summary.signal.js +1 -1
- package/cjs/src/templates/app/lib/summary/summary.store.js +1 -1
- package/cjs/src/templates/app/lib/user/User.Template.js +2 -3
- package/cjs/src/templates/app/lib/user/User.Unit.js +4 -5
- package/cjs/src/templates/app/lib/user/User.Util.js +6 -52
- package/cjs/src/templates/app/lib/user/User.View.js +2 -4
- package/cjs/src/templates/app/lib/user/User.Zone.js +8 -33
- package/cjs/src/templates/app/lib/user/user.constant.js +1 -1
- package/cjs/src/templates/app/lib/user/user.dictionary.js +1 -1
- package/cjs/src/templates/app/lib/user/user.document.js +2 -8
- package/cjs/src/templates/app/lib/user/user.service.js +3 -9
- package/cjs/src/templates/app/lib/user/user.signal.js +1 -1
- package/cjs/src/templates/app/lib/user/user.signal.spec.js +1 -1
- package/cjs/src/templates/app/lib/user/user.signal.test.js +1 -1
- package/cjs/src/templates/app/lib/user/user.store.js +1 -1
- package/cjs/src/templates/app/main.js +1 -1
- package/cjs/src/templates/app/middleware.js +1 -1
- package/cjs/src/templates/app/nest/backendLogic.js +1 -1
- package/cjs/src/templates/app/nest/index.js +1 -1
- package/cjs/src/templates/app/next/frontendLogic.js +1 -1
- package/cjs/src/templates/app/next/index.js +1 -1
- package/cjs/src/templates/app/ui/UiComponent.js +1 -1
- package/cjs/src/templates/app/ui/index.js +1 -1
- package/cjs/src/templates/client.js +11 -5
- package/cjs/src/templates/crudPages/[__model__Id]/edit/page.js +1 -1
- package/cjs/src/templates/crudPages/[__model__Id]/page.js +1 -1
- package/cjs/src/templates/crudPages/new/page.js +1 -1
- package/cjs/src/templates/crudPages/page.js +1 -1
- package/cjs/src/templates/crudSinglePage/page.js +1 -1
- package/cjs/src/templates/index.js +1 -1
- package/cjs/src/templates/lib/__lib/extends/summary.constant.js +7 -5
- package/cjs/src/templates/lib/__lib/lib.constant.js +7 -11
- package/cjs/src/templates/lib/__lib/lib.dictionary.js +4 -4
- package/cjs/src/templates/lib/__lib/lib.document.js +4 -4
- package/cjs/src/templates/lib/__lib/lib.service.js +19 -24
- package/cjs/src/templates/lib/__lib/lib.signal.js +5 -4
- package/cjs/src/templates/lib/__lib/lib.store.js +3 -3
- package/cjs/src/templates/lib/cnst.js +1 -1
- package/cjs/src/templates/lib/cnst_.js +10 -7
- package/cjs/src/templates/lib/db.js +5 -5
- package/cjs/src/templates/lib/dict.js +5 -5
- package/cjs/src/templates/lib/fetch.js +7 -7
- package/cjs/src/templates/lib/sig.js +4 -8
- package/cjs/src/templates/lib/srv.js +5 -8
- package/cjs/src/templates/lib/st.js +3 -3
- package/cjs/src/templates/lib/store.js +7 -10
- package/cjs/src/templates/lib/usePage.js +1 -1
- package/cjs/src/templates/libRoot/akan.config.js +1 -1
- package/cjs/src/templates/libRoot/base/baseLogic.js +1 -1
- package/cjs/src/templates/libRoot/base/index.js +1 -1
- package/cjs/src/templates/libRoot/common/commonLogic.js +1 -1
- package/cjs/src/templates/libRoot/common/index.js +1 -1
- package/cjs/src/templates/libRoot/jest.config.js +1 -1
- package/cjs/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +1 -1
- package/cjs/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -1
- package/cjs/src/templates/libRoot/lib/___libName__/__libName__.store.js +1 -1
- package/cjs/src/templates/libRoot/lib/option.js +1 -1
- package/cjs/src/templates/libRoot/lib/setting/Setting.Template.js +6 -19
- package/cjs/src/templates/libRoot/lib/setting/Setting.Unit.js +3 -3
- package/cjs/src/templates/libRoot/lib/setting/Setting.Util.js +8 -2
- package/cjs/src/templates/libRoot/lib/setting/Setting.View.js +4 -7
- package/cjs/src/templates/libRoot/lib/setting/Setting.Zone.js +2 -8
- package/cjs/src/templates/libRoot/lib/setting/setting.constant.js +1 -1
- package/cjs/src/templates/libRoot/lib/setting/setting.dictionary.js +1 -1
- package/cjs/src/templates/libRoot/lib/setting/setting.document.js +1 -1
- package/cjs/src/templates/libRoot/lib/setting/setting.service.js +1 -1
- package/cjs/src/templates/libRoot/lib/setting/setting.signal.js +1 -1
- package/cjs/src/templates/libRoot/lib/setting/setting.store.js +1 -1
- package/cjs/src/templates/libRoot/lib/summary/Summary.Template.js +5 -4
- package/cjs/src/templates/libRoot/lib/summary/Summary.Unit.js +4 -5
- package/cjs/src/templates/libRoot/lib/summary/Summary.Util.js +10 -3
- package/cjs/src/templates/libRoot/lib/summary/Summary.View.js +5 -9
- package/cjs/src/templates/libRoot/lib/summary/Summary.Zone.js +1 -23
- package/cjs/src/templates/libRoot/lib/summary/summary.constant.js +1 -1
- package/cjs/src/templates/libRoot/lib/summary/summary.dictionary.js +1 -1
- package/cjs/src/templates/libRoot/lib/summary/summary.document.js +1 -1
- package/cjs/src/templates/libRoot/lib/summary/summary.service.js +1 -1
- package/cjs/src/templates/libRoot/lib/summary/summary.signal.js +1 -1
- package/cjs/src/templates/libRoot/lib/summary/summary.store.js +1 -1
- package/cjs/src/templates/libRoot/lib/user/User.Template.js +2 -3
- package/cjs/src/templates/libRoot/lib/user/User.Unit.js +4 -5
- package/cjs/src/templates/libRoot/lib/user/User.Util.js +6 -52
- package/cjs/src/templates/libRoot/lib/user/User.View.js +2 -4
- package/cjs/src/templates/libRoot/lib/user/User.Zone.js +8 -32
- package/cjs/src/templates/libRoot/lib/user/user.constant.js +1 -1
- package/cjs/src/templates/libRoot/lib/user/user.dictionary.js +1 -1
- package/cjs/src/templates/libRoot/lib/user/user.document.js +2 -8
- package/cjs/src/templates/libRoot/lib/user/user.service.js +3 -9
- package/cjs/src/templates/libRoot/lib/user/user.signal.js +1 -1
- package/cjs/src/templates/libRoot/lib/user/user.signal.spec.js +1 -1
- package/cjs/src/templates/libRoot/lib/user/user.signal.test.js +1 -1
- package/cjs/src/templates/libRoot/lib/user/user.store.js +1 -1
- package/cjs/src/templates/libRoot/nest/backendLogic.js +1 -1
- package/cjs/src/templates/libRoot/nest/index.js +1 -1
- package/cjs/src/templates/libRoot/next/frontendLogic.js +1 -1
- package/cjs/src/templates/libRoot/next/index.js +1 -1
- package/cjs/src/templates/libRoot/ui/index.js +1 -1
- package/cjs/src/templates/module/__Model__.Template.js +1 -1
- package/cjs/src/templates/module/__Model__.Unit.js +1 -1
- package/cjs/src/templates/module/__Model__.Util.js +7 -37
- package/cjs/src/templates/module/__Model__.View.js +1 -1
- package/cjs/src/templates/module/__Model__.Zone.js +3 -27
- package/cjs/src/templates/module/__model__.constant.js +1 -1
- package/cjs/src/templates/module/__model__.dictionary.js +1 -1
- package/cjs/src/templates/module/__model__.document.js +2 -8
- package/cjs/src/templates/module/__model__.service.js +2 -8
- package/cjs/src/templates/module/__model__.signal.js +1 -1
- package/cjs/src/templates/module/__model__.signal.spec.js +1 -1
- package/cjs/src/templates/module/__model__.signal.test.js +1 -1
- package/cjs/src/templates/module/__model__.store.js +1 -1
- package/cjs/src/templates/module/index.js +1 -1
- package/cjs/src/templates/{libRoot/lib/user → moduleRoot}/index.js +23 -35
- package/cjs/src/templates/server.js +31 -13
- package/cjs/src/templates/workspaceRoot/.gitignore.template +2 -2
- package/cjs/src/templates/workspaceRoot/.vscode/settings.json.template +0 -1
- package/esm/index.js +942 -539
- package/esm/src/guidelines/___library/sharedUiStructureDescription.en.md +0 -1
- package/esm/src/guidelines/databaseModule/databaseModule.instruction.md +3 -50
- package/esm/src/guidelines/modelService/modelService.generate.json +3 -40
- package/esm/src/guidelines/modelService/modelService.instruction.md +0 -164
- package/esm/src/guidelines/scalarModule/scalarModule.instruction.md +0 -3
- package/esm/src/templates/__scalar/__model__/__model__.constant.js +1 -1
- package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +1 -1
- package/esm/src/templates/__scalar/__model__/__model__.document.js +1 -1
- package/esm/src/templates/app/akan.config.js +1 -1
- package/esm/src/templates/app/app/[lang]/layout.js +1 -1
- package/esm/src/templates/app/app/[lang]/page.js +1 -1
- package/esm/src/templates/app/app/csr.js +1 -1
- package/esm/src/templates/app/app/layout.js +1 -1
- package/esm/src/templates/app/app/robots.js +1 -1
- package/esm/src/templates/app/app/sitemap.js +1 -1
- package/esm/src/templates/app/base/baseLogic.js +1 -1
- package/esm/src/templates/app/base/index.js +1 -1
- package/esm/src/templates/app/common/commonLogic.js +1 -1
- package/esm/src/templates/app/common/index.js +1 -1
- package/esm/src/templates/app/env/env.client.js +1 -1
- package/esm/src/templates/app/env/env.client.type.js +1 -1
- package/esm/src/templates/app/env/env.server.js +1 -1
- package/esm/src/templates/app/jest.config.js +1 -1
- package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +7 -2
- package/esm/src/templates/app/lib/___appName__/__appName__.service.js +2 -9
- package/esm/src/templates/app/lib/___appName__/__appName__.signal.js +14 -0
- package/esm/src/templates/app/lib/___appName__/__appName__.store.js +1 -1
- package/esm/src/templates/app/lib/option.js +1 -1
- package/esm/src/templates/app/lib/setting/Setting.Template.js +6 -19
- package/esm/src/templates/app/lib/setting/Setting.Unit.js +3 -3
- package/esm/src/templates/app/lib/setting/Setting.Util.js +8 -2
- package/esm/src/templates/app/lib/setting/Setting.View.js +4 -7
- package/esm/src/templates/app/lib/setting/Setting.Zone.js +2 -8
- package/esm/src/templates/app/lib/setting/setting.constant.js +1 -1
- package/esm/src/templates/app/lib/setting/setting.dictionary.js +1 -1
- package/esm/src/templates/app/lib/setting/setting.document.js +1 -1
- package/esm/src/templates/app/lib/setting/setting.service.js +1 -1
- package/esm/src/templates/app/lib/setting/setting.signal.js +1 -1
- package/esm/src/templates/app/lib/setting/setting.store.js +1 -1
- package/esm/src/templates/app/lib/summary/Summary.Template.js +5 -4
- package/esm/src/templates/app/lib/summary/Summary.Unit.js +4 -5
- package/esm/src/templates/app/lib/summary/Summary.Util.js +10 -3
- package/esm/src/templates/app/lib/summary/Summary.View.js +5 -9
- package/esm/src/templates/app/lib/summary/Summary.Zone.js +1 -23
- package/esm/src/templates/app/lib/summary/summary.constant.js +1 -1
- package/esm/src/templates/app/lib/summary/summary.dictionary.js +1 -1
- package/esm/src/templates/app/lib/summary/summary.document.js +1 -1
- package/esm/src/templates/app/lib/summary/summary.service.js +1 -1
- package/esm/src/templates/app/lib/summary/summary.signal.js +1 -1
- package/esm/src/templates/app/lib/summary/summary.store.js +1 -1
- package/esm/src/templates/app/lib/user/User.Template.js +2 -3
- package/esm/src/templates/app/lib/user/User.Unit.js +4 -5
- package/esm/src/templates/app/lib/user/User.Util.js +6 -52
- package/esm/src/templates/app/lib/user/User.View.js +2 -4
- package/esm/src/templates/app/lib/user/User.Zone.js +8 -33
- package/esm/src/templates/app/lib/user/user.constant.js +1 -1
- package/esm/src/templates/app/lib/user/user.dictionary.js +1 -1
- package/esm/src/templates/app/lib/user/user.document.js +2 -8
- package/esm/src/templates/app/lib/user/user.service.js +3 -9
- package/esm/src/templates/app/lib/user/user.signal.js +1 -1
- package/esm/src/templates/app/lib/user/user.signal.spec.js +1 -1
- package/esm/src/templates/app/lib/user/user.signal.test.js +1 -1
- package/esm/src/templates/app/lib/user/user.store.js +1 -1
- package/esm/src/templates/app/main.js +1 -1
- package/esm/src/templates/app/middleware.js +1 -1
- package/esm/src/templates/app/nest/backendLogic.js +1 -1
- package/esm/src/templates/app/nest/index.js +1 -1
- package/esm/src/templates/app/next/frontendLogic.js +1 -1
- package/esm/src/templates/app/next/index.js +1 -1
- package/esm/src/templates/app/ui/UiComponent.js +1 -1
- package/esm/src/templates/app/ui/index.js +1 -1
- package/esm/src/templates/client.js +11 -5
- package/esm/src/templates/crudPages/[__model__Id]/edit/page.js +1 -1
- package/esm/src/templates/crudPages/[__model__Id]/page.js +1 -1
- package/esm/src/templates/crudPages/new/page.js +1 -1
- package/esm/src/templates/crudPages/page.js +1 -1
- package/esm/src/templates/crudSinglePage/page.js +1 -1
- package/esm/src/templates/index.js +1 -1
- package/esm/src/templates/lib/__lib/extends/summary.constant.js +7 -5
- package/esm/src/templates/lib/__lib/lib.constant.js +7 -11
- package/esm/src/templates/lib/__lib/lib.dictionary.js +4 -4
- package/esm/src/templates/lib/__lib/lib.document.js +4 -4
- package/esm/src/templates/lib/__lib/lib.service.js +19 -24
- package/esm/src/templates/lib/__lib/lib.signal.js +5 -4
- package/esm/src/templates/lib/__lib/lib.store.js +3 -3
- package/esm/src/templates/lib/cnst.js +1 -1
- package/esm/src/templates/lib/cnst_.js +10 -7
- package/esm/src/templates/lib/db.js +5 -5
- package/esm/src/templates/lib/dict.js +5 -5
- package/esm/src/templates/lib/fetch.js +7 -7
- package/esm/src/templates/lib/sig.js +4 -8
- package/esm/src/templates/lib/srv.js +5 -8
- package/esm/src/templates/lib/st.js +3 -3
- package/esm/src/templates/lib/store.js +7 -10
- package/esm/src/templates/lib/usePage.js +1 -1
- package/esm/src/templates/libRoot/akan.config.js +1 -1
- package/esm/src/templates/libRoot/base/baseLogic.js +1 -1
- package/esm/src/templates/libRoot/base/index.js +1 -1
- package/esm/src/templates/libRoot/common/commonLogic.js +1 -1
- package/esm/src/templates/libRoot/common/index.js +1 -1
- package/esm/src/templates/libRoot/jest.config.js +1 -1
- package/esm/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +1 -1
- package/esm/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -1
- package/esm/src/templates/libRoot/lib/___libName__/__libName__.store.js +1 -1
- package/esm/src/templates/libRoot/lib/option.js +1 -1
- package/esm/src/templates/libRoot/lib/setting/Setting.Template.js +6 -19
- package/esm/src/templates/libRoot/lib/setting/Setting.Unit.js +3 -3
- package/esm/src/templates/libRoot/lib/setting/Setting.Util.js +8 -2
- package/esm/src/templates/libRoot/lib/setting/Setting.View.js +4 -7
- package/esm/src/templates/libRoot/lib/setting/Setting.Zone.js +2 -8
- package/esm/src/templates/libRoot/lib/setting/setting.constant.js +1 -1
- package/esm/src/templates/libRoot/lib/setting/setting.dictionary.js +1 -1
- package/esm/src/templates/libRoot/lib/setting/setting.document.js +1 -1
- package/esm/src/templates/libRoot/lib/setting/setting.service.js +1 -1
- package/esm/src/templates/libRoot/lib/setting/setting.signal.js +1 -1
- package/esm/src/templates/libRoot/lib/setting/setting.store.js +1 -1
- package/esm/src/templates/libRoot/lib/summary/Summary.Template.js +5 -4
- package/esm/src/templates/libRoot/lib/summary/Summary.Unit.js +4 -5
- package/esm/src/templates/libRoot/lib/summary/Summary.Util.js +10 -3
- package/esm/src/templates/libRoot/lib/summary/Summary.View.js +5 -9
- package/esm/src/templates/libRoot/lib/summary/Summary.Zone.js +1 -23
- package/esm/src/templates/libRoot/lib/summary/summary.constant.js +1 -1
- package/esm/src/templates/libRoot/lib/summary/summary.dictionary.js +1 -1
- package/esm/src/templates/libRoot/lib/summary/summary.document.js +1 -1
- package/esm/src/templates/libRoot/lib/summary/summary.service.js +1 -1
- package/esm/src/templates/libRoot/lib/summary/summary.signal.js +1 -1
- package/esm/src/templates/libRoot/lib/summary/summary.store.js +1 -1
- package/esm/src/templates/libRoot/lib/user/User.Template.js +2 -3
- package/esm/src/templates/libRoot/lib/user/User.Unit.js +4 -5
- package/esm/src/templates/libRoot/lib/user/User.Util.js +6 -52
- package/esm/src/templates/libRoot/lib/user/User.View.js +2 -4
- package/esm/src/templates/libRoot/lib/user/User.Zone.js +8 -32
- package/esm/src/templates/libRoot/lib/user/user.constant.js +1 -1
- package/esm/src/templates/libRoot/lib/user/user.dictionary.js +1 -1
- package/esm/src/templates/libRoot/lib/user/user.document.js +2 -8
- package/esm/src/templates/libRoot/lib/user/user.service.js +3 -9
- package/esm/src/templates/libRoot/lib/user/user.signal.js +1 -1
- package/esm/src/templates/libRoot/lib/user/user.signal.spec.js +1 -1
- package/esm/src/templates/libRoot/lib/user/user.signal.test.js +1 -1
- package/esm/src/templates/libRoot/lib/user/user.store.js +1 -1
- package/esm/src/templates/libRoot/nest/backendLogic.js +1 -1
- package/esm/src/templates/libRoot/nest/index.js +1 -1
- package/esm/src/templates/libRoot/next/frontendLogic.js +1 -1
- package/esm/src/templates/libRoot/next/index.js +1 -1
- package/esm/src/templates/libRoot/ui/index.js +1 -1
- package/esm/src/templates/module/__Model__.Template.js +1 -1
- package/esm/src/templates/module/__Model__.Unit.js +1 -1
- package/esm/src/templates/module/__Model__.Util.js +7 -37
- package/esm/src/templates/module/__Model__.View.js +1 -1
- package/esm/src/templates/module/__Model__.Zone.js +3 -27
- package/esm/src/templates/module/__model__.constant.js +1 -1
- package/esm/src/templates/module/__model__.dictionary.js +1 -1
- package/esm/src/templates/module/__model__.document.js +2 -8
- package/esm/src/templates/module/__model__.service.js +2 -8
- package/esm/src/templates/module/__model__.signal.js +1 -1
- package/esm/src/templates/module/__model__.signal.spec.js +1 -1
- package/esm/src/templates/module/__model__.signal.test.js +1 -1
- package/esm/src/templates/module/__model__.store.js +1 -1
- package/esm/src/templates/module/index.js +1 -1
- package/esm/src/templates/moduleRoot/index.js +29 -0
- package/esm/src/templates/server.js +31 -13
- package/esm/src/templates/workspaceRoot/.gitignore.template +2 -2
- package/esm/src/templates/workspaceRoot/.vscode/settings.json.template +0 -1
- package/package.json +1 -1
- package/src/application/application.runner.d.ts +2 -3
- package/src/application/application.script.d.ts +1 -1
- package/src/guidelines/___library/sharedUiStructureDescription.en.md +0 -1
- package/src/guidelines/databaseModule/databaseModule.instruction.md +3 -50
- package/src/guidelines/modelService/modelService.instruction.md +0 -164
- package/src/guidelines/scalarModule/scalarModule.instruction.md +0 -3
- package/src/library/library.script.d.ts +1 -1
- package/src/package/package.runner.d.ts +1 -1
- package/src/package/package.script.d.ts +1 -1
- package/src/templates/__scalar/__model__/__model__.constant.d.ts +2 -2
- package/src/templates/__scalar/__model__/__model__.dictionary.d.ts +2 -2
- package/src/templates/__scalar/__model__/__model__.document.d.ts +2 -2
- package/src/templates/app/akan.config.d.ts +2 -2
- package/src/templates/app/app/[lang]/layout.d.ts +2 -2
- package/src/templates/app/app/[lang]/page.d.ts +2 -2
- package/src/templates/app/app/csr.d.ts +2 -2
- package/src/templates/app/app/layout.d.ts +2 -2
- package/src/templates/app/app/robots.d.ts +2 -2
- package/src/templates/app/app/sitemap.d.ts +2 -2
- package/src/templates/app/base/baseLogic.d.ts +2 -2
- package/src/templates/app/base/index.d.ts +2 -2
- package/src/templates/app/common/commonLogic.d.ts +2 -2
- package/src/templates/app/common/index.d.ts +2 -2
- package/src/templates/app/env/env.client.d.ts +2 -2
- package/src/templates/app/env/env.client.type.d.ts +2 -2
- package/src/templates/app/env/env.server.d.ts +2 -2
- package/src/templates/app/jest.config.d.ts +2 -2
- package/src/templates/app/lib/___appName__/__appName__.dictionary.d.ts +2 -2
- package/src/templates/app/lib/___appName__/__appName__.service.d.ts +2 -2
- package/src/templates/app/lib/___appName__/__appName__.signal.d.ts +7 -0
- package/src/templates/app/lib/___appName__/__appName__.store.d.ts +2 -2
- package/src/templates/app/lib/option.d.ts +2 -2
- package/src/templates/app/lib/setting/Setting.Template.d.ts +2 -2
- package/src/templates/app/lib/setting/Setting.Unit.d.ts +2 -2
- package/src/templates/app/lib/setting/Setting.Util.d.ts +2 -2
- package/src/templates/app/lib/setting/Setting.View.d.ts +2 -2
- package/src/templates/app/lib/setting/Setting.Zone.d.ts +2 -2
- package/src/templates/app/lib/setting/setting.constant.d.ts +2 -2
- package/src/templates/app/lib/setting/setting.dictionary.d.ts +2 -2
- package/src/templates/app/lib/setting/setting.document.d.ts +2 -2
- package/src/templates/app/lib/setting/setting.service.d.ts +2 -2
- package/src/templates/app/lib/setting/setting.signal.d.ts +2 -2
- package/src/templates/app/lib/setting/setting.store.d.ts +2 -2
- package/src/templates/app/lib/summary/Summary.Template.d.ts +2 -2
- package/src/templates/app/lib/summary/Summary.Unit.d.ts +2 -2
- package/src/templates/app/lib/summary/Summary.Util.d.ts +2 -2
- package/src/templates/app/lib/summary/Summary.View.d.ts +2 -2
- package/src/templates/app/lib/summary/Summary.Zone.d.ts +2 -2
- package/src/templates/app/lib/summary/summary.constant.d.ts +2 -2
- package/src/templates/app/lib/summary/summary.dictionary.d.ts +2 -2
- package/src/templates/app/lib/summary/summary.document.d.ts +2 -2
- package/src/templates/app/lib/summary/summary.service.d.ts +2 -2
- package/src/templates/app/lib/summary/summary.signal.d.ts +2 -2
- package/src/templates/app/lib/summary/summary.store.d.ts +2 -2
- package/src/templates/app/lib/user/User.Template.d.ts +2 -2
- package/src/templates/app/lib/user/User.Unit.d.ts +2 -2
- package/src/templates/app/lib/user/User.Util.d.ts +2 -2
- package/src/templates/app/lib/user/User.View.d.ts +2 -2
- package/src/templates/app/lib/user/User.Zone.d.ts +2 -2
- package/src/templates/app/lib/user/user.constant.d.ts +2 -2
- package/src/templates/app/lib/user/user.dictionary.d.ts +2 -2
- package/src/templates/app/lib/user/user.document.d.ts +2 -2
- package/src/templates/app/lib/user/user.service.d.ts +2 -2
- package/src/templates/app/lib/user/user.signal.d.ts +2 -2
- package/src/templates/app/lib/user/user.signal.spec.d.ts +2 -2
- package/src/templates/app/lib/user/user.signal.test.d.ts +2 -2
- package/src/templates/app/lib/user/user.store.d.ts +2 -2
- package/src/templates/app/main.d.ts +2 -2
- package/src/templates/app/middleware.d.ts +2 -2
- package/src/templates/app/nest/backendLogic.d.ts +2 -2
- package/src/templates/app/nest/index.d.ts +2 -2
- package/src/templates/app/next/frontendLogic.d.ts +2 -2
- package/src/templates/app/next/index.d.ts +2 -2
- package/src/templates/app/ui/UiComponent.d.ts +2 -2
- package/src/templates/app/ui/index.d.ts +2 -2
- package/src/templates/client.d.ts +2 -2
- package/src/templates/crudPages/[__model__Id]/edit/page.d.ts +2 -2
- package/src/templates/crudPages/[__model__Id]/page.d.ts +2 -2
- package/src/templates/crudPages/new/page.d.ts +2 -2
- package/src/templates/crudPages/page.d.ts +2 -2
- package/src/templates/crudSinglePage/page.d.ts +2 -2
- package/src/templates/index.d.ts +2 -2
- package/src/templates/lib/__lib/extends/summary.constant.d.ts +2 -2
- package/src/templates/lib/__lib/lib.constant.d.ts +2 -2
- package/src/templates/lib/__lib/lib.dictionary.d.ts +2 -2
- package/src/templates/lib/__lib/lib.document.d.ts +2 -2
- package/src/templates/lib/__lib/lib.service.d.ts +2 -2
- package/src/templates/lib/__lib/lib.signal.d.ts +2 -2
- package/src/templates/lib/__lib/lib.store.d.ts +2 -2
- package/src/templates/lib/cnst.d.ts +2 -2
- package/src/templates/lib/cnst_.d.ts +2 -2
- package/src/templates/lib/db.d.ts +2 -2
- package/src/templates/lib/dict.d.ts +2 -2
- package/src/templates/lib/fetch.d.ts +2 -2
- package/src/templates/lib/sig.d.ts +2 -2
- package/src/templates/lib/srv.d.ts +2 -2
- package/src/templates/lib/st.d.ts +2 -2
- package/src/templates/lib/store.d.ts +2 -2
- package/src/templates/lib/usePage.d.ts +2 -2
- package/src/templates/libRoot/akan.config.d.ts +1 -1
- package/src/templates/libRoot/base/baseLogic.d.ts +1 -1
- package/src/templates/libRoot/base/index.d.ts +1 -1
- package/src/templates/libRoot/common/commonLogic.d.ts +1 -1
- package/src/templates/libRoot/common/index.d.ts +1 -1
- package/src/templates/libRoot/jest.config.d.ts +2 -2
- package/src/templates/libRoot/lib/___libName__/__libName__.dictionary.d.ts +1 -1
- package/src/templates/libRoot/lib/___libName__/__libName__.service.d.ts +1 -1
- package/src/templates/libRoot/lib/___libName__/__libName__.store.d.ts +1 -1
- package/src/templates/libRoot/lib/option.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/Setting.Template.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/Setting.Unit.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/Setting.Util.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/Setting.View.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/Setting.Zone.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/setting.constant.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/setting.dictionary.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/setting.document.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/setting.service.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/setting.signal.d.ts +2 -2
- package/src/templates/libRoot/lib/setting/setting.store.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/Summary.Template.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/Summary.Unit.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/Summary.Util.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/Summary.View.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/Summary.Zone.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/summary.constant.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/summary.dictionary.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/summary.document.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/summary.service.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/summary.signal.d.ts +2 -2
- package/src/templates/libRoot/lib/summary/summary.store.d.ts +2 -2
- package/src/templates/libRoot/lib/user/User.Template.d.ts +2 -2
- package/src/templates/libRoot/lib/user/User.Unit.d.ts +2 -2
- package/src/templates/libRoot/lib/user/User.Util.d.ts +2 -2
- package/src/templates/libRoot/lib/user/User.View.d.ts +2 -2
- package/src/templates/libRoot/lib/user/User.Zone.d.ts +2 -2
- package/src/templates/libRoot/lib/user/user.constant.d.ts +2 -2
- package/src/templates/libRoot/lib/user/user.dictionary.d.ts +2 -2
- package/src/templates/libRoot/lib/user/user.document.d.ts +2 -2
- package/src/templates/libRoot/lib/user/user.service.d.ts +2 -2
- package/src/templates/libRoot/lib/user/user.signal.d.ts +2 -2
- package/src/templates/libRoot/lib/user/user.signal.spec.d.ts +2 -2
- package/src/templates/libRoot/lib/user/user.signal.test.d.ts +2 -2
- package/src/templates/libRoot/lib/user/user.store.d.ts +2 -2
- package/src/templates/libRoot/nest/backendLogic.d.ts +1 -1
- package/src/templates/libRoot/nest/index.d.ts +1 -1
- package/src/templates/libRoot/next/frontendLogic.d.ts +1 -1
- package/src/templates/libRoot/next/index.d.ts +1 -1
- package/src/templates/libRoot/ui/index.d.ts +1 -1
- package/src/templates/module/__Model__.Template.d.ts +2 -2
- package/src/templates/module/__Model__.Unit.d.ts +2 -2
- package/src/templates/module/__Model__.Util.d.ts +2 -2
- package/src/templates/module/__Model__.View.d.ts +2 -2
- package/src/templates/module/__Model__.Zone.d.ts +2 -2
- package/src/templates/module/__model__.constant.d.ts +2 -2
- package/src/templates/module/__model__.dictionary.d.ts +2 -2
- package/src/templates/module/__model__.document.d.ts +2 -2
- package/src/templates/module/__model__.service.d.ts +2 -2
- package/src/templates/module/__model__.signal.d.ts +2 -2
- package/src/templates/module/__model__.signal.spec.d.ts +2 -2
- package/src/templates/module/__model__.signal.test.d.ts +2 -2
- package/src/templates/module/__model__.store.d.ts +2 -2
- package/src/templates/module/index.d.ts +2 -2
- package/src/templates/moduleRoot/index.d.ts +11 -0
- package/src/templates/server.d.ts +2 -2
- package/ui/MultiScrollList.d.ts +4 -1
- package/cjs/src/templates/app/app/[lang]/admin/page.js +0 -63
- package/cjs/src/templates/app/app/[lang]/unknown/page.js +0 -51
- package/cjs/src/templates/app/lib/setting/_server.js +0 -48
- package/cjs/src/templates/app/lib/setting/index.js +0 -61
- package/cjs/src/templates/app/lib/summary/_server.js +0 -48
- package/cjs/src/templates/app/lib/summary/index.js +0 -67
- package/cjs/src/templates/app/lib/user/_server.js +0 -48
- package/cjs/src/templates/app/lib/user/index.js +0 -61
- package/cjs/src/templates/lib/__scalar/_server.js +0 -39
- package/cjs/src/templates/libRoot/lib/___libName__/_server.js +0 -34
- package/cjs/src/templates/libRoot/lib/setting/_server.js +0 -48
- package/cjs/src/templates/libRoot/lib/setting/index.js +0 -61
- package/cjs/src/templates/libRoot/lib/summary/_server.js +0 -48
- package/cjs/src/templates/libRoot/lib/summary/index.js +0 -67
- package/cjs/src/templates/libRoot/lib/user/_server.js +0 -48
- package/cjs/src/templates/module/_server.js +0 -47
- package/esm/src/templates/app/app/[lang]/admin/page.js +0 -43
- package/esm/src/templates/app/app/[lang]/unknown/page.js +0 -31
- package/esm/src/templates/app/lib/___appName__/_server.js +0 -14
- package/esm/src/templates/app/lib/setting/_server.js +0 -28
- package/esm/src/templates/app/lib/setting/index.js +0 -41
- package/esm/src/templates/app/lib/summary/_server.js +0 -28
- package/esm/src/templates/app/lib/summary/index.js +0 -47
- package/esm/src/templates/app/lib/user/_server.js +0 -28
- package/esm/src/templates/app/lib/user/index.js +0 -41
- package/esm/src/templates/lib/__scalar/_server.js +0 -19
- package/esm/src/templates/libRoot/lib/___libName__/_server.js +0 -14
- package/esm/src/templates/libRoot/lib/setting/_server.js +0 -28
- package/esm/src/templates/libRoot/lib/setting/index.js +0 -41
- package/esm/src/templates/libRoot/lib/summary/_server.js +0 -28
- package/esm/src/templates/libRoot/lib/summary/index.js +0 -47
- package/esm/src/templates/libRoot/lib/user/_server.js +0 -28
- package/esm/src/templates/libRoot/lib/user/index.js +0 -41
- package/esm/src/templates/module/_server.js +0 -27
- package/src/templates/app/app/[lang]/admin/page.d.ts +0 -9
- package/src/templates/app/app/[lang]/unknown/page.d.ts +0 -9
- package/src/templates/app/lib/___appName__/_server.d.ts +0 -7
- package/src/templates/app/lib/setting/_server.d.ts +0 -6
- package/src/templates/app/lib/setting/index.d.ts +0 -9
- package/src/templates/app/lib/summary/_server.d.ts +0 -6
- package/src/templates/app/lib/summary/index.d.ts +0 -9
- package/src/templates/app/lib/user/_server.d.ts +0 -6
- package/src/templates/app/lib/user/index.d.ts +0 -9
- package/src/templates/lib/__scalar/_server.d.ts +0 -4
- package/src/templates/libRoot/lib/___libName__/_server.d.ts +0 -7
- package/src/templates/libRoot/lib/setting/_server.d.ts +0 -6
- package/src/templates/libRoot/lib/setting/index.d.ts +0 -9
- package/src/templates/libRoot/lib/summary/_server.d.ts +0 -6
- package/src/templates/libRoot/lib/summary/index.d.ts +0 -9
- package/src/templates/libRoot/lib/user/_server.d.ts +0 -6
- package/src/templates/libRoot/lib/user/index.d.ts +0 -9
- package/src/templates/module/_server.d.ts +0 -8
package/cjs/index.js
CHANGED
|
@@ -142,6 +142,9 @@ var Logger = class _Logger {
|
|
|
142
142
|
this.level = level;
|
|
143
143
|
this.#levelIdx = logLevels.findIndex((l) => l === level);
|
|
144
144
|
}
|
|
145
|
+
static isVerbose() {
|
|
146
|
+
return this.#levelIdx <= 1;
|
|
147
|
+
}
|
|
145
148
|
name;
|
|
146
149
|
constructor(name) {
|
|
147
150
|
this.name = name;
|
|
@@ -400,8 +403,8 @@ var fs3 = __toESM(require("fs"));
|
|
|
400
403
|
var import_ora2 = __toESM(require("ora"));
|
|
401
404
|
var ts = __toESM(require("typescript"));
|
|
402
405
|
var parseTsConfig = (tsConfigPath = "./tsconfig.json") => {
|
|
403
|
-
const configFile = ts.readConfigFile(tsConfigPath, (
|
|
404
|
-
return ts.sys.readFile(
|
|
406
|
+
const configFile = ts.readConfigFile(tsConfigPath, (path10) => {
|
|
407
|
+
return ts.sys.readFile(path10);
|
|
405
408
|
});
|
|
406
409
|
return ts.parseJsonConfigFileContent(
|
|
407
410
|
configFile.config,
|
|
@@ -720,47 +723,12 @@ export default getNextConfig(config, appInfo);
|
|
|
720
723
|
|
|
721
724
|
// pkgs/@akanjs/config/src/types.ts
|
|
722
725
|
var archs = ["amd64", "arm64"];
|
|
723
|
-
var getDefaultFileScan = () => ({
|
|
724
|
-
constants: {
|
|
725
|
-
databases: [],
|
|
726
|
-
scalars: []
|
|
727
|
-
},
|
|
728
|
-
dictionary: {
|
|
729
|
-
databases: [],
|
|
730
|
-
services: [],
|
|
731
|
-
scalars: []
|
|
732
|
-
},
|
|
733
|
-
documents: {
|
|
734
|
-
databases: [],
|
|
735
|
-
scalars: []
|
|
736
|
-
},
|
|
737
|
-
services: {
|
|
738
|
-
databases: [],
|
|
739
|
-
services: [],
|
|
740
|
-
scalars: []
|
|
741
|
-
},
|
|
742
|
-
signal: {
|
|
743
|
-
databases: [],
|
|
744
|
-
services: [],
|
|
745
|
-
scalars: []
|
|
746
|
-
},
|
|
747
|
-
store: {
|
|
748
|
-
databases: [],
|
|
749
|
-
services: [],
|
|
750
|
-
scalars: []
|
|
751
|
-
},
|
|
752
|
-
components: {
|
|
753
|
-
databases: [],
|
|
754
|
-
services: [],
|
|
755
|
-
scalars: []
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
726
|
|
|
759
727
|
// pkgs/@akanjs/config/src/akanConfig.ts
|
|
760
728
|
var import_meta = {};
|
|
761
729
|
var jiti = (0, import_jiti.createJiti)(import_meta.url);
|
|
762
730
|
var makeAppConfig = (config, props) => {
|
|
763
|
-
const { name, repoName
|
|
731
|
+
const { name, repoName } = props;
|
|
764
732
|
return {
|
|
765
733
|
rootLib: config.rootLib,
|
|
766
734
|
libs: config.libs ?? [],
|
|
@@ -906,18 +874,254 @@ var import_child_process = require("child_process");
|
|
|
906
874
|
var import_dotenv = __toESM(require("dotenv"));
|
|
907
875
|
var import_fs4 = __toESM(require("fs"));
|
|
908
876
|
var import_promises = __toESM(require("fs/promises"));
|
|
877
|
+
var import_path4 = __toESM(require("path"));
|
|
878
|
+
|
|
879
|
+
// pkgs/@akanjs/devkit/src/getDirname.ts
|
|
880
|
+
var import_path2 = __toESM(require("path"));
|
|
881
|
+
var getDirname = (url) => import_path2.default.dirname(new URL(url).pathname);
|
|
882
|
+
|
|
883
|
+
// pkgs/@akanjs/devkit/src/linter.ts
|
|
884
|
+
var import_chalk = __toESM(require("chalk"));
|
|
885
|
+
var import_eslint = require("eslint");
|
|
886
|
+
var fs5 = __toESM(require("fs"));
|
|
887
|
+
var path3 = __toESM(require("path"));
|
|
888
|
+
var Linter = class {
|
|
889
|
+
#logger = new Logger("Linter");
|
|
890
|
+
#eslint;
|
|
891
|
+
lintRoot;
|
|
892
|
+
constructor(cwdPath) {
|
|
893
|
+
this.lintRoot = this.#findEslintRootPath(cwdPath);
|
|
894
|
+
this.#eslint = new import_eslint.ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
|
|
895
|
+
}
|
|
896
|
+
#findEslintRootPath(dir) {
|
|
897
|
+
const configPath2 = path3.join(dir, "eslint.config.ts");
|
|
898
|
+
if (fs5.existsSync(configPath2))
|
|
899
|
+
return dir;
|
|
900
|
+
const parentDir = path3.dirname(dir);
|
|
901
|
+
return this.#findEslintRootPath(parentDir);
|
|
902
|
+
}
|
|
903
|
+
async lint(filePath, { fix = false, dryRun = false } = {}) {
|
|
904
|
+
if (fix)
|
|
905
|
+
return await this.fixFile(filePath, dryRun);
|
|
906
|
+
return await this.lintFile(filePath);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Lint a single file using ESLint
|
|
910
|
+
* @param filePath - Path to the file to lint
|
|
911
|
+
* @returns Array of ESLint results
|
|
912
|
+
*/
|
|
913
|
+
async lintFile(filePath) {
|
|
914
|
+
if (!fs5.existsSync(filePath))
|
|
915
|
+
throw new Error(`File not found: ${filePath}`);
|
|
916
|
+
const isIgnored = await this.#eslint.isPathIgnored(filePath);
|
|
917
|
+
if (isIgnored) {
|
|
918
|
+
this.#logger.warn(`File ${filePath} is ignored by ESLint configuration`);
|
|
919
|
+
return { fixed: false, results: [], errors: [], warnings: [] };
|
|
920
|
+
}
|
|
921
|
+
const results = await this.#eslint.lintFiles([filePath]);
|
|
922
|
+
const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
923
|
+
const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
924
|
+
return { fixed: false, results, errors, warnings };
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Format lint results for console output
|
|
928
|
+
* @param results - Array of ESLint results
|
|
929
|
+
* @returns Formatted string
|
|
930
|
+
*/
|
|
931
|
+
formatLintResults(results) {
|
|
932
|
+
if (results.length === 0)
|
|
933
|
+
return "No files to lint";
|
|
934
|
+
const output = [];
|
|
935
|
+
let totalErrors = 0;
|
|
936
|
+
let totalWarnings = 0;
|
|
937
|
+
results.forEach((result) => {
|
|
938
|
+
totalErrors += result.errorCount;
|
|
939
|
+
totalWarnings += result.warningCount;
|
|
940
|
+
if (result.messages.length > 0) {
|
|
941
|
+
output.push(`
|
|
942
|
+
${import_chalk.default.cyan(result.filePath)}`);
|
|
943
|
+
let sourceLines = [];
|
|
944
|
+
if (fs5.existsSync(result.filePath)) {
|
|
945
|
+
try {
|
|
946
|
+
const sourceContent = fs5.readFileSync(result.filePath, "utf8");
|
|
947
|
+
sourceLines = sourceContent.split("\n");
|
|
948
|
+
} catch (error) {
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
result.messages.forEach((message) => {
|
|
952
|
+
const type = message.severity === 2 ? "error" : "warning";
|
|
953
|
+
const typeColor = message.severity === 2 ? import_chalk.default.red : import_chalk.default.yellow;
|
|
954
|
+
const icon = message.severity === 2 ? "\u274C" : "\u26A0\uFE0F";
|
|
955
|
+
const ruleInfo = message.ruleId ? import_chalk.default.dim(` (${message.ruleId})`) : "";
|
|
956
|
+
output.push(`
|
|
957
|
+
${icon} ${typeColor(type)}: ${message.message}${ruleInfo}`);
|
|
958
|
+
output.push(` ${import_chalk.default.gray("at")} ${result.filePath}:${import_chalk.default.bold(`${message.line}:${message.column}`)}`);
|
|
959
|
+
if (sourceLines.length > 0 && message.line <= sourceLines.length) {
|
|
960
|
+
const sourceLine = sourceLines[message.line - 1];
|
|
961
|
+
const lineNumber = message.line.toString().padStart(5, " ");
|
|
962
|
+
output.push(`
|
|
963
|
+
${import_chalk.default.dim(lineNumber + " |")} ${sourceLine}`);
|
|
964
|
+
const underlinePrefix = " ".repeat(message.column - 1);
|
|
965
|
+
const underlineLength = message.endColumn ? message.endColumn - message.column : 1;
|
|
966
|
+
const underline = "^".repeat(Math.max(1, underlineLength));
|
|
967
|
+
output.push(`${import_chalk.default.dim(" ".repeat(lineNumber.length) + " |")} ${underlinePrefix}${typeColor(underline)}`);
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
if (totalErrors === 0 && totalWarnings === 0)
|
|
973
|
+
return import_chalk.default.bold("\u2705 No ESLint errors or warnings found");
|
|
974
|
+
const errorText = totalErrors > 0 ? import_chalk.default.red(`${totalErrors} error(s)`) : "0 errors";
|
|
975
|
+
const warningText = totalWarnings > 0 ? import_chalk.default.yellow(`${totalWarnings} warning(s)`) : "0 warnings";
|
|
976
|
+
const summary = [`
|
|
977
|
+
${errorText}, ${warningText} found`];
|
|
978
|
+
return summary.concat(output).join("\n");
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Get detailed lint information
|
|
982
|
+
* @param filePath - Path to the file to lint
|
|
983
|
+
* @returns Object containing detailed lint information
|
|
984
|
+
*/
|
|
985
|
+
async getDetailedLintInfo(filePath) {
|
|
986
|
+
const { results } = await this.lintFile(filePath);
|
|
987
|
+
const details = results.flatMap(
|
|
988
|
+
(result) => result.messages.map((message) => ({
|
|
989
|
+
line: message.line,
|
|
990
|
+
column: message.column,
|
|
991
|
+
message: message.message,
|
|
992
|
+
ruleId: message.ruleId,
|
|
993
|
+
severity: message.severity === 2 ? "error" : "warning",
|
|
994
|
+
fix: message.fix,
|
|
995
|
+
suggestions: message.suggestions
|
|
996
|
+
}))
|
|
997
|
+
);
|
|
998
|
+
const stats = results.reduce(
|
|
999
|
+
(acc, result) => ({
|
|
1000
|
+
errorCount: acc.errorCount + result.errorCount,
|
|
1001
|
+
warningCount: acc.warningCount + result.warningCount,
|
|
1002
|
+
fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
|
|
1003
|
+
fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount
|
|
1004
|
+
}),
|
|
1005
|
+
{ errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0 }
|
|
1006
|
+
);
|
|
1007
|
+
return { results, details, stats };
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Check if a file has lint errors
|
|
1011
|
+
* @param filePath - Path to the file to check
|
|
1012
|
+
* @returns true if there are no errors, false otherwise
|
|
1013
|
+
*/
|
|
1014
|
+
async hasNoLintErrors(filePath) {
|
|
1015
|
+
try {
|
|
1016
|
+
const { results } = await this.lintFile(filePath);
|
|
1017
|
+
return results.every((result) => result.errorCount === 0);
|
|
1018
|
+
} catch (error) {
|
|
1019
|
+
return false;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Get only error messages (excluding warnings)
|
|
1024
|
+
* @param filePath - Path to the file to lint
|
|
1025
|
+
* @returns Array of error messages
|
|
1026
|
+
*/
|
|
1027
|
+
async getErrors(filePath) {
|
|
1028
|
+
const { results } = await this.lintFile(filePath);
|
|
1029
|
+
return results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Get only warning messages
|
|
1033
|
+
* @param filePath - Path to the file to lint
|
|
1034
|
+
* @returns Array of warning messages
|
|
1035
|
+
*/
|
|
1036
|
+
async getWarnings(filePath) {
|
|
1037
|
+
const { results } = await this.lintFile(filePath);
|
|
1038
|
+
return results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Fix lint errors automatically
|
|
1042
|
+
* @param filePath - Path to the file to fix
|
|
1043
|
+
* @param dryRun - If true, returns the fixed content without writing to file
|
|
1044
|
+
* @returns Fixed content and remaining issues
|
|
1045
|
+
*/
|
|
1046
|
+
async fixFile(filePath, dryRun = false) {
|
|
1047
|
+
if (!fs5.existsSync(filePath))
|
|
1048
|
+
throw new Error(`File not found: ${filePath}`);
|
|
1049
|
+
const eslint = new import_eslint.ESLint({ cwd: this.lintRoot, fix: true });
|
|
1050
|
+
const results = await eslint.lintFiles([filePath]);
|
|
1051
|
+
const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
1052
|
+
const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
1053
|
+
if (!dryRun)
|
|
1054
|
+
await import_eslint.ESLint.outputFixes(results);
|
|
1055
|
+
const fixedResult = results[0];
|
|
1056
|
+
return { fixed: fixedResult.output !== void 0, output: fixedResult.output, results, errors, warnings };
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Get ESLint configuration for a file
|
|
1060
|
+
* @param filePath - Path to the file
|
|
1061
|
+
* @returns ESLint configuration object
|
|
1062
|
+
*/
|
|
1063
|
+
async getConfigForFile(filePath) {
|
|
1064
|
+
const eslint = new import_eslint.ESLint();
|
|
1065
|
+
const config = await eslint.calculateConfigForFile(filePath);
|
|
1066
|
+
return config;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Get rules that are causing errors in a file
|
|
1070
|
+
* @param filePath - Path to the file to check
|
|
1071
|
+
* @returns Object mapping rule IDs to their error counts
|
|
1072
|
+
*/
|
|
1073
|
+
async getProblematicRules(filePath) {
|
|
1074
|
+
const { results } = await this.lintFile(filePath);
|
|
1075
|
+
const ruleCounts = {};
|
|
1076
|
+
results.forEach((result) => {
|
|
1077
|
+
result.messages.forEach((message) => {
|
|
1078
|
+
if (message.ruleId)
|
|
1079
|
+
ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
|
|
1080
|
+
});
|
|
1081
|
+
});
|
|
1082
|
+
return ruleCounts;
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
|
|
1086
|
+
// pkgs/@akanjs/devkit/src/scanInfo.ts
|
|
909
1087
|
var import_path3 = __toESM(require("path"));
|
|
910
1088
|
|
|
911
1089
|
// pkgs/@akanjs/devkit/src/dependencyScanner.ts
|
|
912
|
-
var
|
|
913
|
-
var
|
|
1090
|
+
var fs6 = __toESM(require("fs"));
|
|
1091
|
+
var path4 = __toESM(require("path"));
|
|
914
1092
|
var ts2 = __toESM(require("typescript"));
|
|
915
1093
|
var TypeScriptDependencyScanner = class {
|
|
916
|
-
constructor(directory) {
|
|
917
|
-
this.directory = directory;
|
|
918
|
-
}
|
|
919
1094
|
#fileDependencies = /* @__PURE__ */ new Map();
|
|
920
1095
|
#visitedFiles = /* @__PURE__ */ new Set();
|
|
1096
|
+
directory;
|
|
1097
|
+
tsconfig;
|
|
1098
|
+
rootPackageJson;
|
|
1099
|
+
constructor(directory, { tsconfig, rootPackageJson }) {
|
|
1100
|
+
this.directory = directory;
|
|
1101
|
+
this.tsconfig = tsconfig;
|
|
1102
|
+
this.rootPackageJson = rootPackageJson;
|
|
1103
|
+
}
|
|
1104
|
+
async getMonorepoDependencies(projectName) {
|
|
1105
|
+
const npmSet = new Set(
|
|
1106
|
+
Object.keys({ ...this.rootPackageJson.dependencies, ...this.rootPackageJson.devDependencies })
|
|
1107
|
+
);
|
|
1108
|
+
const pkgPathSet = new Set(
|
|
1109
|
+
Object.keys(this.tsconfig.compilerOptions.paths ?? {}).filter((path10) => this.tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
|
|
1110
|
+
);
|
|
1111
|
+
const libPathSet = new Set(
|
|
1112
|
+
Object.keys(this.tsconfig.compilerOptions.paths ?? {}).filter((path10) => this.tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("libs/"))).map((path10) => path10.replace("/*", ""))
|
|
1113
|
+
);
|
|
1114
|
+
const [npmDepSet, pkgPathDepSet, libPathDepSet] = await this.getImportSets([npmSet, pkgPathSet, libPathSet]);
|
|
1115
|
+
const pkgDeps = [...pkgPathDepSet].map((path10) => {
|
|
1116
|
+
const pathSplitLength = path10.split("/").length;
|
|
1117
|
+
return (this.tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1118
|
+
});
|
|
1119
|
+
const libDeps = [...libPathDepSet].map((path10) => {
|
|
1120
|
+
const pathSplitLength = path10.split("/").length;
|
|
1121
|
+
return (this.tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1122
|
+
}).filter((libName) => libName !== projectName);
|
|
1123
|
+
return { pkgDeps, libDeps, npmDeps: [...npmDepSet] };
|
|
1124
|
+
}
|
|
921
1125
|
async getImportSets(depSets) {
|
|
922
1126
|
const fileDependencies = await this.getDependencies();
|
|
923
1127
|
const importedDepSets = new Array(depSets.length);
|
|
@@ -954,9 +1158,9 @@ var TypeScriptDependencyScanner = class {
|
|
|
954
1158
|
async #findTypeScriptFiles(directory) {
|
|
955
1159
|
const files = [];
|
|
956
1160
|
const processDirectory = async (dir) => {
|
|
957
|
-
const entries = await
|
|
1161
|
+
const entries = await fs6.promises.readdir(dir, { withFileTypes: true });
|
|
958
1162
|
for (const entry of entries) {
|
|
959
|
-
const fullPath =
|
|
1163
|
+
const fullPath = path4.join(dir, entry.name);
|
|
960
1164
|
if (entry.isDirectory()) {
|
|
961
1165
|
if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
|
|
962
1166
|
await processDirectory(fullPath);
|
|
@@ -972,26 +1176,26 @@ var TypeScriptDependencyScanner = class {
|
|
|
972
1176
|
return;
|
|
973
1177
|
this.#visitedFiles.add(filePath);
|
|
974
1178
|
try {
|
|
975
|
-
const fileContent = await
|
|
1179
|
+
const fileContent = await fs6.promises.readFile(filePath, "utf-8");
|
|
976
1180
|
const imports = this.#extractImports(fileContent, filePath);
|
|
977
1181
|
const resolvedImports = imports.map((importPath) => {
|
|
978
1182
|
if (importPath.startsWith(".")) {
|
|
979
|
-
const resolvedPath = "./" +
|
|
1183
|
+
const resolvedPath = "./" + path4.join(path4.relative(baseDir, filePath), importPath);
|
|
980
1184
|
return this.#ensureExtension(resolvedPath);
|
|
981
1185
|
}
|
|
982
1186
|
return importPath;
|
|
983
1187
|
});
|
|
984
|
-
const relativePath =
|
|
1188
|
+
const relativePath = path4.relative(baseDir, filePath);
|
|
985
1189
|
this.#fileDependencies.set(relativePath, resolvedImports);
|
|
986
1190
|
} catch (error) {
|
|
987
1191
|
}
|
|
988
1192
|
}
|
|
989
1193
|
#ensureExtension(filePath) {
|
|
990
|
-
if (
|
|
1194
|
+
if (fs6.existsSync(`${filePath}.ts`))
|
|
991
1195
|
return `${filePath}.ts`;
|
|
992
|
-
else if (
|
|
1196
|
+
else if (fs6.existsSync(`${filePath}.tsx`))
|
|
993
1197
|
return `${filePath}.tsx`;
|
|
994
|
-
else if (
|
|
1198
|
+
else if (fs6.existsSync(filePath))
|
|
995
1199
|
return filePath;
|
|
996
1200
|
return `${filePath}.ts`;
|
|
997
1201
|
}
|
|
@@ -1055,217 +1259,442 @@ var TypeScriptDependencyScanner = class {
|
|
|
1055
1259
|
}
|
|
1056
1260
|
};
|
|
1057
1261
|
|
|
1058
|
-
// pkgs/@akanjs/devkit/src/
|
|
1059
|
-
var
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
}
|
|
1100
|
-
const
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
result.messages.forEach((message) => {
|
|
1131
|
-
const type = message.severity === 2 ? "error" : "warning";
|
|
1132
|
-
const typeColor = message.severity === 2 ? import_chalk.default.red : import_chalk.default.yellow;
|
|
1133
|
-
const icon = message.severity === 2 ? "\u274C" : "\u26A0\uFE0F";
|
|
1134
|
-
const ruleInfo = message.ruleId ? import_chalk.default.dim(` (${message.ruleId})`) : "";
|
|
1135
|
-
output.push(`
|
|
1136
|
-
${icon} ${typeColor(type)}: ${message.message}${ruleInfo}`);
|
|
1137
|
-
output.push(` ${import_chalk.default.gray("at")} ${result.filePath}:${import_chalk.default.bold(`${message.line}:${message.column}`)}`);
|
|
1138
|
-
if (sourceLines.length > 0 && message.line <= sourceLines.length) {
|
|
1139
|
-
const sourceLine = sourceLines[message.line - 1];
|
|
1140
|
-
const lineNumber = message.line.toString().padStart(5, " ");
|
|
1141
|
-
output.push(`
|
|
1142
|
-
${import_chalk.default.dim(lineNumber + " |")} ${sourceLine}`);
|
|
1143
|
-
const underlinePrefix = " ".repeat(message.column - 1);
|
|
1144
|
-
const underlineLength = message.endColumn ? message.endColumn - message.column : 1;
|
|
1145
|
-
const underline = "^".repeat(Math.max(1, underlineLength));
|
|
1146
|
-
output.push(`${import_chalk.default.dim(" ".repeat(lineNumber.length) + " |")} ${underlinePrefix}${typeColor(underline)}`);
|
|
1147
|
-
}
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1262
|
+
// pkgs/@akanjs/devkit/src/scanInfo.ts
|
|
1263
|
+
var databaseFileTypes = [
|
|
1264
|
+
"constant",
|
|
1265
|
+
"dictionary",
|
|
1266
|
+
"document",
|
|
1267
|
+
"service",
|
|
1268
|
+
"signal",
|
|
1269
|
+
"store",
|
|
1270
|
+
"template",
|
|
1271
|
+
"unit",
|
|
1272
|
+
"util",
|
|
1273
|
+
"view",
|
|
1274
|
+
"zone"
|
|
1275
|
+
];
|
|
1276
|
+
var ScanInfo = class {
|
|
1277
|
+
scanResult;
|
|
1278
|
+
name;
|
|
1279
|
+
scalar = /* @__PURE__ */ new Map();
|
|
1280
|
+
service = /* @__PURE__ */ new Map();
|
|
1281
|
+
database = /* @__PURE__ */ new Map();
|
|
1282
|
+
file = Object.fromEntries(
|
|
1283
|
+
databaseFileTypes.map((type) => [
|
|
1284
|
+
type,
|
|
1285
|
+
{ all: /* @__PURE__ */ new Set(), databases: /* @__PURE__ */ new Set(), services: /* @__PURE__ */ new Set(), scalars: /* @__PURE__ */ new Set() }
|
|
1286
|
+
])
|
|
1287
|
+
);
|
|
1288
|
+
constants = /* @__PURE__ */ new Set();
|
|
1289
|
+
dictionaries = /* @__PURE__ */ new Set();
|
|
1290
|
+
documents = /* @__PURE__ */ new Set();
|
|
1291
|
+
services = /* @__PURE__ */ new Set();
|
|
1292
|
+
signals = /* @__PURE__ */ new Set();
|
|
1293
|
+
stores = /* @__PURE__ */ new Set();
|
|
1294
|
+
templates = /* @__PURE__ */ new Set();
|
|
1295
|
+
units = /* @__PURE__ */ new Set();
|
|
1296
|
+
utils = /* @__PURE__ */ new Set();
|
|
1297
|
+
views = /* @__PURE__ */ new Set();
|
|
1298
|
+
zones = /* @__PURE__ */ new Set();
|
|
1299
|
+
static async getScanResult(exec2) {
|
|
1300
|
+
const akanConfig = await exec2.getConfig();
|
|
1301
|
+
const tsconfig = exec2.getTsConfig();
|
|
1302
|
+
const rootPackageJson = exec2.workspace.getPackageJson();
|
|
1303
|
+
const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
|
|
1304
|
+
const { pkgDeps, libDeps, npmDeps } = await scanner.getMonorepoDependencies(exec2.name);
|
|
1305
|
+
const files = {
|
|
1306
|
+
constant: { databases: [], scalars: [] },
|
|
1307
|
+
dictionary: { databases: [], services: [], scalars: [] },
|
|
1308
|
+
document: { databases: [], scalars: [] },
|
|
1309
|
+
service: { databases: [], services: [] },
|
|
1310
|
+
signal: { databases: [], services: [] },
|
|
1311
|
+
store: { databases: [], services: [] },
|
|
1312
|
+
template: { databases: [], services: [], scalars: [] },
|
|
1313
|
+
unit: { databases: [], services: [], scalars: [] },
|
|
1314
|
+
util: { databases: [], services: [], scalars: [] },
|
|
1315
|
+
view: { databases: [], services: [], scalars: [] },
|
|
1316
|
+
zone: { databases: [], services: [], scalars: [] }
|
|
1317
|
+
};
|
|
1318
|
+
const [{ dirs: dirnames }, scalarDirs] = await Promise.all([
|
|
1319
|
+
exec2.getFilesAndDirs("lib"),
|
|
1320
|
+
exec2.readdir("lib/__scalar")
|
|
1321
|
+
]);
|
|
1322
|
+
const databaseDirs = [];
|
|
1323
|
+
const serviceDirs = [];
|
|
1324
|
+
dirnames.forEach((name) => {
|
|
1325
|
+
if (name.startsWith("_")) {
|
|
1326
|
+
if (name.startsWith("__"))
|
|
1327
|
+
return;
|
|
1328
|
+
else
|
|
1329
|
+
serviceDirs.push(name);
|
|
1330
|
+
} else
|
|
1331
|
+
databaseDirs.push(name);
|
|
1150
1332
|
});
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
(acc, result) => ({
|
|
1179
|
-
errorCount: acc.errorCount + result.errorCount,
|
|
1180
|
-
warningCount: acc.warningCount + result.warningCount,
|
|
1181
|
-
fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
|
|
1182
|
-
fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount
|
|
1333
|
+
await Promise.all([
|
|
1334
|
+
...databaseDirs.map(async (name) => {
|
|
1335
|
+
const filenames = await exec2.readdir(import_path3.default.join("lib", name));
|
|
1336
|
+
filenames.forEach((filename) => {
|
|
1337
|
+
if (filename.endsWith(".constant.ts"))
|
|
1338
|
+
files.constant.databases.push(name);
|
|
1339
|
+
else if (filename.endsWith(".dictionary.ts"))
|
|
1340
|
+
files.dictionary.databases.push(name);
|
|
1341
|
+
else if (filename.endsWith(".document.ts"))
|
|
1342
|
+
files.document.databases.push(name);
|
|
1343
|
+
else if (filename.endsWith(".service.ts"))
|
|
1344
|
+
files.service.databases.push(name);
|
|
1345
|
+
else if (filename.endsWith(".signal.ts"))
|
|
1346
|
+
files.signal.databases.push(name);
|
|
1347
|
+
else if (filename.endsWith(".store.ts"))
|
|
1348
|
+
files.store.databases.push(name);
|
|
1349
|
+
else if (filename.endsWith(".Template.tsx"))
|
|
1350
|
+
files.template.databases.push(name);
|
|
1351
|
+
else if (filename.endsWith(".Unit.tsx"))
|
|
1352
|
+
files.unit.databases.push(name);
|
|
1353
|
+
else if (filename.endsWith(".Util.tsx"))
|
|
1354
|
+
files.util.databases.push(name);
|
|
1355
|
+
else if (filename.endsWith(".View.tsx"))
|
|
1356
|
+
files.view.databases.push(name);
|
|
1357
|
+
else if (filename.endsWith(".Zone.tsx"))
|
|
1358
|
+
files.zone.databases.push(name);
|
|
1359
|
+
});
|
|
1183
1360
|
}),
|
|
1184
|
-
|
|
1361
|
+
...serviceDirs.map(async (dirname3) => {
|
|
1362
|
+
const name = dirname3.slice(1);
|
|
1363
|
+
const filenames = await exec2.readdir(import_path3.default.join("lib", dirname3));
|
|
1364
|
+
filenames.forEach((filename) => {
|
|
1365
|
+
if (filename.endsWith(".dictionary.ts"))
|
|
1366
|
+
files.dictionary.services.push(name);
|
|
1367
|
+
else if (filename.endsWith(".service.ts"))
|
|
1368
|
+
files.service.services.push(name);
|
|
1369
|
+
else if (filename.endsWith(".signal.ts"))
|
|
1370
|
+
files.signal.services.push(name);
|
|
1371
|
+
else if (filename.endsWith(".store.ts"))
|
|
1372
|
+
files.store.services.push(name);
|
|
1373
|
+
else if (filename.endsWith(".Template.tsx"))
|
|
1374
|
+
files.template.services.push(name);
|
|
1375
|
+
else if (filename.endsWith(".Unit.tsx"))
|
|
1376
|
+
files.unit.services.push(name);
|
|
1377
|
+
else if (filename.endsWith(".Util.tsx"))
|
|
1378
|
+
files.util.services.push(name);
|
|
1379
|
+
else if (filename.endsWith(".View.tsx"))
|
|
1380
|
+
files.view.services.push(name);
|
|
1381
|
+
else if (filename.endsWith(".Zone.tsx"))
|
|
1382
|
+
files.zone.services.push(name);
|
|
1383
|
+
});
|
|
1384
|
+
}),
|
|
1385
|
+
...scalarDirs.map(async (name) => {
|
|
1386
|
+
const filenames = await exec2.readdir(import_path3.default.join("lib/__scalar", name));
|
|
1387
|
+
filenames.forEach((filename) => {
|
|
1388
|
+
if (filename.endsWith(".constant.ts"))
|
|
1389
|
+
files.constant.scalars.push(name);
|
|
1390
|
+
else if (filename.endsWith(".dictionary.ts"))
|
|
1391
|
+
files.dictionary.scalars.push(name);
|
|
1392
|
+
else if (filename.endsWith(".document.ts"))
|
|
1393
|
+
files.document.scalars.push(name);
|
|
1394
|
+
else if (filename.endsWith(".Template.tsx"))
|
|
1395
|
+
files.template.scalars.push(name);
|
|
1396
|
+
else if (filename.endsWith(".Unit.tsx"))
|
|
1397
|
+
files.unit.scalars.push(name);
|
|
1398
|
+
else if (filename.endsWith(".Util.tsx"))
|
|
1399
|
+
files.util.scalars.push(name);
|
|
1400
|
+
else if (filename.endsWith(".View.tsx"))
|
|
1401
|
+
files.view.scalars.push(name);
|
|
1402
|
+
else if (filename.endsWith(".Zone.tsx"))
|
|
1403
|
+
files.zone.scalars.push(name);
|
|
1404
|
+
});
|
|
1405
|
+
})
|
|
1406
|
+
]);
|
|
1407
|
+
const missingLibDeps = [];
|
|
1408
|
+
libDeps.forEach((libName) => {
|
|
1409
|
+
if (!akanConfig.libs.includes(libName))
|
|
1410
|
+
missingLibDeps.push(libName);
|
|
1411
|
+
});
|
|
1412
|
+
if (missingLibDeps.length)
|
|
1413
|
+
throw new Error(
|
|
1414
|
+
`Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
|
|
1415
|
+
);
|
|
1416
|
+
const scanResult = {
|
|
1417
|
+
name: exec2.name,
|
|
1418
|
+
type: exec2.type,
|
|
1419
|
+
repoName: exec2.workspace.repoName,
|
|
1420
|
+
serveDomain: exec2.workspace.getBaseDevEnv().serveDomain,
|
|
1421
|
+
akanConfig,
|
|
1422
|
+
files,
|
|
1423
|
+
libDeps,
|
|
1424
|
+
pkgDeps,
|
|
1425
|
+
dependencies: npmDeps.filter((dep) => !dep.startsWith("@akanjs"))
|
|
1426
|
+
};
|
|
1427
|
+
return scanResult;
|
|
1428
|
+
}
|
|
1429
|
+
constructor(scanResult) {
|
|
1430
|
+
this.name = scanResult.name;
|
|
1431
|
+
this.scanResult = scanResult;
|
|
1432
|
+
Object.entries(scanResult.files).forEach(
|
|
1433
|
+
([key, value]) => {
|
|
1434
|
+
const { databases, services, scalars } = value;
|
|
1435
|
+
databases.forEach((modelName) => {
|
|
1436
|
+
const model = this.database.get(modelName) ?? /* @__PURE__ */ new Set();
|
|
1437
|
+
model.add(key);
|
|
1438
|
+
this.database.set(modelName, model);
|
|
1439
|
+
this.file[key].all.add(modelName);
|
|
1440
|
+
this.file[key].databases.add(modelName);
|
|
1441
|
+
});
|
|
1442
|
+
services?.forEach((serviceName) => {
|
|
1443
|
+
const service = this.service.get(serviceName) ?? /* @__PURE__ */ new Set();
|
|
1444
|
+
service.add(key);
|
|
1445
|
+
this.service.set(serviceName, service);
|
|
1446
|
+
this.file[key].all.add(serviceName);
|
|
1447
|
+
this.file[key].services.add(serviceName);
|
|
1448
|
+
});
|
|
1449
|
+
scalars?.forEach((scalarName) => {
|
|
1450
|
+
const scalar = this.scalar.get(scalarName) ?? /* @__PURE__ */ new Set();
|
|
1451
|
+
scalar.add(key);
|
|
1452
|
+
this.scalar.set(scalarName, scalar);
|
|
1453
|
+
this.file[key].all.add(scalarName);
|
|
1454
|
+
this.file[key].scalars.add(scalarName);
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1185
1457
|
);
|
|
1186
|
-
return { results, details, stats };
|
|
1187
1458
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
* @param filePath - Path to the file to check
|
|
1191
|
-
* @returns true if there are no errors, false otherwise
|
|
1192
|
-
*/
|
|
1193
|
-
async hasNoLintErrors(filePath) {
|
|
1194
|
-
try {
|
|
1195
|
-
const { results } = await this.lintFile(filePath);
|
|
1196
|
-
return results.every((result) => result.errorCount === 0);
|
|
1197
|
-
} catch (error) {
|
|
1198
|
-
return false;
|
|
1199
|
-
}
|
|
1459
|
+
getScanResult() {
|
|
1460
|
+
return this.scanResult;
|
|
1200
1461
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
* @param filePath - Path to the file to lint
|
|
1204
|
-
* @returns Array of error messages
|
|
1205
|
-
*/
|
|
1206
|
-
async getErrors(filePath) {
|
|
1207
|
-
const { results } = await this.lintFile(filePath);
|
|
1208
|
-
return results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
1462
|
+
getDatabaseModules() {
|
|
1463
|
+
return [...this.database.keys()];
|
|
1209
1464
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
* @param filePath - Path to the file to lint
|
|
1213
|
-
* @returns Array of warning messages
|
|
1214
|
-
*/
|
|
1215
|
-
async getWarnings(filePath) {
|
|
1216
|
-
const { results } = await this.lintFile(filePath);
|
|
1217
|
-
return results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
1465
|
+
getServiceModules() {
|
|
1466
|
+
return [...this.service.keys()];
|
|
1218
1467
|
}
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
* @param filePath - Path to the file to fix
|
|
1222
|
-
* @param dryRun - If true, returns the fixed content without writing to file
|
|
1223
|
-
* @returns Fixed content and remaining issues
|
|
1224
|
-
*/
|
|
1225
|
-
async fixFile(filePath, dryRun = false) {
|
|
1226
|
-
if (!fs6.existsSync(filePath))
|
|
1227
|
-
throw new Error(`File not found: ${filePath}`);
|
|
1228
|
-
const eslint = new import_eslint.ESLint({ cwd: this.lintRoot, fix: true });
|
|
1229
|
-
const results = await eslint.lintFiles([filePath]);
|
|
1230
|
-
const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
1231
|
-
const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
1232
|
-
if (!dryRun)
|
|
1233
|
-
await import_eslint.ESLint.outputFixes(results);
|
|
1234
|
-
const fixedResult = results[0];
|
|
1235
|
-
return { fixed: fixedResult.output !== void 0, output: fixedResult.output, results, errors, warnings };
|
|
1468
|
+
getScalarModules() {
|
|
1469
|
+
return [...this.scalar.keys()];
|
|
1236
1470
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1471
|
+
};
|
|
1472
|
+
var AppInfo = class _AppInfo extends ScanInfo {
|
|
1473
|
+
type = "app";
|
|
1474
|
+
exec;
|
|
1475
|
+
akanConfig;
|
|
1476
|
+
static appInfos = /* @__PURE__ */ new Map();
|
|
1477
|
+
static async fromExecutor(exec2, options = {}) {
|
|
1478
|
+
const existingAppInfo = this.appInfos.get(exec2.name);
|
|
1479
|
+
if (existingAppInfo && !options.refresh)
|
|
1480
|
+
return existingAppInfo;
|
|
1481
|
+
const scanResult = await super.getScanResult(exec2);
|
|
1482
|
+
await Promise.all(
|
|
1483
|
+
scanResult.libDeps.map(async (libName) => {
|
|
1484
|
+
LibInfo.loadedLibs.add(libName);
|
|
1485
|
+
const libExecutor = LibExecutor.from(exec2, libName);
|
|
1486
|
+
LibInfo.libInfos.set(libName, await LibInfo.fromExecutor(libExecutor));
|
|
1487
|
+
})
|
|
1488
|
+
);
|
|
1489
|
+
const appInfo = new _AppInfo(exec2, scanResult);
|
|
1490
|
+
this.appInfos.set(exec2.name, appInfo);
|
|
1491
|
+
return appInfo;
|
|
1492
|
+
}
|
|
1493
|
+
constructor(exec2, scanResult) {
|
|
1494
|
+
super(scanResult);
|
|
1495
|
+
this.exec = exec2;
|
|
1496
|
+
this.akanConfig = scanResult.akanConfig;
|
|
1497
|
+
}
|
|
1498
|
+
getScanResult() {
|
|
1499
|
+
return this.scanResult;
|
|
1500
|
+
}
|
|
1501
|
+
#sortedLibs = null;
|
|
1502
|
+
#getSortedLibs() {
|
|
1503
|
+
if (this.#sortedLibs)
|
|
1504
|
+
return this.#sortedLibs;
|
|
1505
|
+
const libIndices = LibInfo.getSortedLibIndices();
|
|
1506
|
+
this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
|
|
1507
|
+
const indexA = libIndices.get(libNameA);
|
|
1508
|
+
const indexB = libIndices.get(libNameB);
|
|
1509
|
+
if (indexA === void 0 || indexB === void 0)
|
|
1510
|
+
throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
|
|
1511
|
+
return indexA - indexB;
|
|
1512
|
+
});
|
|
1513
|
+
return this.#sortedLibs;
|
|
1514
|
+
}
|
|
1515
|
+
getLibs() {
|
|
1516
|
+
return this.#getSortedLibs();
|
|
1517
|
+
}
|
|
1518
|
+
getLibInfo(libName) {
|
|
1519
|
+
const libSet = new Set(this.#getSortedLibs());
|
|
1520
|
+
if (!libSet.has(libName))
|
|
1521
|
+
throw new Error(`LibInfo is invalid: ${libName}`);
|
|
1522
|
+
return LibInfo.libInfos.get(libName);
|
|
1523
|
+
}
|
|
1524
|
+
getLibInfos() {
|
|
1525
|
+
return new Map(
|
|
1526
|
+
this.#getSortedLibs().map((libName) => {
|
|
1527
|
+
const libInfo = LibInfo.libInfos.get(libName);
|
|
1528
|
+
if (!libInfo)
|
|
1529
|
+
throw new Error(`LibInfo not found: ${libName}`);
|
|
1530
|
+
return [libName, libInfo];
|
|
1531
|
+
})
|
|
1532
|
+
);
|
|
1246
1533
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1534
|
+
};
|
|
1535
|
+
var LibInfo = class _LibInfo extends ScanInfo {
|
|
1536
|
+
type = "lib";
|
|
1537
|
+
exec;
|
|
1538
|
+
akanConfig;
|
|
1539
|
+
static loadedLibs = /* @__PURE__ */ new Set();
|
|
1540
|
+
static libInfos = /* @__PURE__ */ new Map();
|
|
1541
|
+
static #sortedLibIndices = null;
|
|
1542
|
+
static getSortedLibIndices() {
|
|
1543
|
+
if (this.#sortedLibIndices)
|
|
1544
|
+
return this.#sortedLibIndices;
|
|
1545
|
+
this.#sortedLibIndices = new Map(
|
|
1546
|
+
[...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.akanConfig.libs.includes(libInfoB.name) ? 1 : -1).map(([libName], index) => [libName, index])
|
|
1547
|
+
);
|
|
1548
|
+
return this.#sortedLibIndices;
|
|
1549
|
+
}
|
|
1550
|
+
static async fromExecutor(exec2, { refresh } = {}) {
|
|
1551
|
+
const existingLibInfo = this.libInfos.get(exec2.name);
|
|
1552
|
+
if (existingLibInfo && !refresh)
|
|
1553
|
+
return existingLibInfo;
|
|
1554
|
+
const scanResult = await super.getScanResult(exec2);
|
|
1555
|
+
await Promise.all(
|
|
1556
|
+
scanResult.libDeps.filter((libName) => !this.loadedLibs.has(libName)).map(async (libName) => {
|
|
1557
|
+
this.loadedLibs.add(libName);
|
|
1558
|
+
this.libInfos.set(libName, await _LibInfo.fromExecutor(exec2));
|
|
1559
|
+
})
|
|
1560
|
+
);
|
|
1561
|
+
const libInfo = new _LibInfo(exec2, scanResult);
|
|
1562
|
+
this.libInfos.set(exec2.name, libInfo);
|
|
1563
|
+
this.#sortedLibIndices = null;
|
|
1564
|
+
return libInfo;
|
|
1565
|
+
}
|
|
1566
|
+
constructor(exec2, scanResult) {
|
|
1567
|
+
super(scanResult);
|
|
1568
|
+
this.exec = exec2;
|
|
1569
|
+
this.akanConfig = scanResult.akanConfig;
|
|
1570
|
+
}
|
|
1571
|
+
getScanResult() {
|
|
1572
|
+
return this.scanResult;
|
|
1573
|
+
}
|
|
1574
|
+
#sortedLibs = null;
|
|
1575
|
+
#getSortedLibs() {
|
|
1576
|
+
if (this.#sortedLibs)
|
|
1577
|
+
return this.#sortedLibs;
|
|
1578
|
+
const libs = _LibInfo.getSortedLibIndices();
|
|
1579
|
+
this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
|
|
1580
|
+
const indexA = libs.get(libNameA);
|
|
1581
|
+
const indexB = libs.get(libNameB);
|
|
1582
|
+
if (indexA === void 0 || indexB === void 0)
|
|
1583
|
+
throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
|
|
1584
|
+
return indexA - indexB;
|
|
1260
1585
|
});
|
|
1261
|
-
return
|
|
1586
|
+
return this.#sortedLibs;
|
|
1587
|
+
}
|
|
1588
|
+
getLibs() {
|
|
1589
|
+
return this.#getSortedLibs();
|
|
1590
|
+
}
|
|
1591
|
+
getLibInfo(libName) {
|
|
1592
|
+
if (!this.getScanResult().akanConfig.libs.includes(libName))
|
|
1593
|
+
return void 0;
|
|
1594
|
+
const libSet = new Set(this.#getSortedLibs());
|
|
1595
|
+
if (!libSet.has(libName))
|
|
1596
|
+
throw new Error(`LibInfo is invalid: ${libName}`);
|
|
1597
|
+
return _LibInfo.libInfos.get(libName);
|
|
1598
|
+
}
|
|
1599
|
+
getLibInfos() {
|
|
1600
|
+
return new Map(
|
|
1601
|
+
this.#getSortedLibs().map((libName) => {
|
|
1602
|
+
const libInfo = _LibInfo.libInfos.get(libName);
|
|
1603
|
+
if (!libInfo)
|
|
1604
|
+
throw new Error(`LibInfo not found: ${libName}`);
|
|
1605
|
+
return [libName, libInfo];
|
|
1606
|
+
})
|
|
1607
|
+
);
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
var PkgInfo = class _PkgInfo {
|
|
1611
|
+
exec;
|
|
1612
|
+
name;
|
|
1613
|
+
scanResult;
|
|
1614
|
+
static async getScanResult(exec2) {
|
|
1615
|
+
const tsconfig = exec2.getTsConfig();
|
|
1616
|
+
const rootPackageJson = exec2.workspace.getPackageJson();
|
|
1617
|
+
const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
|
|
1618
|
+
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
1619
|
+
const pkgPathSet = new Set(
|
|
1620
|
+
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
|
|
1621
|
+
);
|
|
1622
|
+
const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
|
|
1623
|
+
const pkgDeps = [...pkgPathDepSet].map((path10) => {
|
|
1624
|
+
const pathSplitLength = path10.split("/").length;
|
|
1625
|
+
return (tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1626
|
+
}).filter((pkg) => pkg !== this.name);
|
|
1627
|
+
const pkgScanResult = {
|
|
1628
|
+
name: this.name,
|
|
1629
|
+
pkgDeps,
|
|
1630
|
+
dependencies: [...npmDepSet]
|
|
1631
|
+
};
|
|
1632
|
+
return pkgScanResult;
|
|
1633
|
+
}
|
|
1634
|
+
static #pkgInfos = /* @__PURE__ */ new Map();
|
|
1635
|
+
static async fromExecutor(exec2, options = {}) {
|
|
1636
|
+
const existingPkgInfo = this.#pkgInfos.get(exec2.name);
|
|
1637
|
+
if (existingPkgInfo && !options.refresh)
|
|
1638
|
+
return existingPkgInfo;
|
|
1639
|
+
const scanResult = await this.getScanResult(exec2);
|
|
1640
|
+
const pkgInfo = new _PkgInfo(exec2, scanResult);
|
|
1641
|
+
this.#pkgInfos.set(exec2.name, pkgInfo);
|
|
1642
|
+
return pkgInfo;
|
|
1643
|
+
}
|
|
1644
|
+
constructor(exec2, scanResult) {
|
|
1645
|
+
this.exec = exec2;
|
|
1646
|
+
this.name = exec2.name;
|
|
1647
|
+
this.scanResult = scanResult;
|
|
1648
|
+
}
|
|
1649
|
+
getScanResult() {
|
|
1650
|
+
return this.scanResult;
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
var WorkspaceInfo = class _WorkspaceInfo {
|
|
1654
|
+
constructor(appInfos = /* @__PURE__ */ new Map(), libInfos = /* @__PURE__ */ new Map(), pkgInfos = /* @__PURE__ */ new Map()) {
|
|
1655
|
+
this.appInfos = appInfos;
|
|
1656
|
+
this.libInfos = libInfos;
|
|
1657
|
+
this.pkgInfos = pkgInfos;
|
|
1658
|
+
}
|
|
1659
|
+
static #workspaceInfos = /* @__PURE__ */ new Map();
|
|
1660
|
+
static async fromExecutor(exec2, options = {}) {
|
|
1661
|
+
const existingWorkspaceInfo = this.#workspaceInfos.get(exec2.name);
|
|
1662
|
+
if (existingWorkspaceInfo && !options.refresh)
|
|
1663
|
+
return existingWorkspaceInfo;
|
|
1664
|
+
const [appNames, libNames, pkgNames] = await Promise.all([exec2.getApps(), exec2.getLibs(), exec2.getPkgs()]);
|
|
1665
|
+
const [appInfos, libInfos, pkgInfos] = await Promise.all([
|
|
1666
|
+
Promise.all(
|
|
1667
|
+
appNames.map(async (appName) => {
|
|
1668
|
+
const app = AppExecutor.from(exec2, appName);
|
|
1669
|
+
return await app.scan();
|
|
1670
|
+
})
|
|
1671
|
+
),
|
|
1672
|
+
Promise.all(
|
|
1673
|
+
libNames.map(async (libName) => {
|
|
1674
|
+
const lib = LibExecutor.from(exec2, libName);
|
|
1675
|
+
return await lib.scan();
|
|
1676
|
+
})
|
|
1677
|
+
),
|
|
1678
|
+
Promise.all(
|
|
1679
|
+
pkgNames.map(async (pkgName) => {
|
|
1680
|
+
return await PkgExecutor.from(exec2, pkgName).scan();
|
|
1681
|
+
})
|
|
1682
|
+
)
|
|
1683
|
+
]);
|
|
1684
|
+
const workspaceInfo = new _WorkspaceInfo(
|
|
1685
|
+
new Map(appInfos.map((app) => [app.exec.name, app])),
|
|
1686
|
+
new Map(libInfos.map((lib) => [lib.exec.name, lib])),
|
|
1687
|
+
new Map(pkgInfos.map((pkg) => [pkg.exec.name, pkg]))
|
|
1688
|
+
);
|
|
1689
|
+
this.#workspaceInfos.set(exec2.name, workspaceInfo);
|
|
1690
|
+
return workspaceInfo;
|
|
1262
1691
|
}
|
|
1263
1692
|
};
|
|
1264
1693
|
|
|
1265
1694
|
// pkgs/@akanjs/devkit/src/typeChecker.ts
|
|
1266
1695
|
var import_chalk2 = __toESM(require("chalk"));
|
|
1267
1696
|
var fs7 = __toESM(require("fs"));
|
|
1268
|
-
var
|
|
1697
|
+
var path6 = __toESM(require("path"));
|
|
1269
1698
|
var ts3 = __toESM(require("typescript"));
|
|
1270
1699
|
var TypeChecker = class {
|
|
1271
1700
|
configPath;
|
|
@@ -1280,7 +1709,7 @@ var TypeChecker = class {
|
|
|
1280
1709
|
const parsedConfig = ts3.parseJsonConfigFileContent(
|
|
1281
1710
|
this.configFile.config,
|
|
1282
1711
|
ts3.sys,
|
|
1283
|
-
|
|
1712
|
+
path6.dirname(this.configPath),
|
|
1284
1713
|
void 0,
|
|
1285
1714
|
this.configPath
|
|
1286
1715
|
);
|
|
@@ -1547,7 +1976,7 @@ var Executor = class _Executor {
|
|
|
1547
1976
|
});
|
|
1548
1977
|
}
|
|
1549
1978
|
getPath(filePath) {
|
|
1550
|
-
if (
|
|
1979
|
+
if (import_path4.default.isAbsolute(filePath))
|
|
1551
1980
|
return filePath;
|
|
1552
1981
|
const baseParts = this.cwdPath.split("/").filter(Boolean);
|
|
1553
1982
|
const targetParts = filePath.split("/").filter(Boolean);
|
|
@@ -1580,6 +2009,22 @@ var Executor = class _Executor {
|
|
|
1580
2009
|
return [];
|
|
1581
2010
|
}
|
|
1582
2011
|
}
|
|
2012
|
+
async getFilesAndDirs(dirPath) {
|
|
2013
|
+
const paths = await this.readdir(dirPath);
|
|
2014
|
+
const files = [];
|
|
2015
|
+
const dirs = [];
|
|
2016
|
+
const fullDirPath = this.getPath(dirPath);
|
|
2017
|
+
await Promise.all(
|
|
2018
|
+
paths.map(async (p) => {
|
|
2019
|
+
const stats = await import_promises.default.stat(import_path4.default.join(fullDirPath, p));
|
|
2020
|
+
if (stats.isDirectory())
|
|
2021
|
+
dirs.push(p);
|
|
2022
|
+
else
|
|
2023
|
+
files.push(p);
|
|
2024
|
+
})
|
|
2025
|
+
);
|
|
2026
|
+
return { files, dirs };
|
|
2027
|
+
}
|
|
1583
2028
|
exists(filePath) {
|
|
1584
2029
|
const readPath = this.getPath(filePath);
|
|
1585
2030
|
return import_fs4.default.existsSync(readPath);
|
|
@@ -1600,7 +2045,7 @@ var Executor = class _Executor {
|
|
|
1600
2045
|
}
|
|
1601
2046
|
writeFile(filePath, content, { overwrite = true } = {}) {
|
|
1602
2047
|
const writePath = this.getPath(filePath);
|
|
1603
|
-
const dir =
|
|
2048
|
+
const dir = import_path4.default.dirname(writePath);
|
|
1604
2049
|
if (!import_fs4.default.existsSync(dir))
|
|
1605
2050
|
import_fs4.default.mkdirSync(dir, { recursive: true });
|
|
1606
2051
|
let contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
@@ -1611,11 +2056,12 @@ var Executor = class _Executor {
|
|
|
1611
2056
|
contentStr = import_fs4.default.readFileSync(writePath, "utf-8");
|
|
1612
2057
|
} else {
|
|
1613
2058
|
import_fs4.default.writeFileSync(writePath, contentStr, "utf8");
|
|
1614
|
-
|
|
2059
|
+
if (Logger.isVerbose())
|
|
2060
|
+
this.logger.rawLog(import_chalk3.default.yellow(`File Update: ${filePath}`));
|
|
1615
2061
|
}
|
|
1616
2062
|
} else {
|
|
1617
2063
|
import_fs4.default.writeFileSync(writePath, contentStr, "utf8");
|
|
1618
|
-
this.logger.
|
|
2064
|
+
this.logger.rawLog(import_chalk3.default.green(`File Create: ${filePath}`));
|
|
1619
2065
|
}
|
|
1620
2066
|
return { filePath: writePath, content: contentStr };
|
|
1621
2067
|
}
|
|
@@ -1624,7 +2070,7 @@ var Executor = class _Executor {
|
|
|
1624
2070
|
return this;
|
|
1625
2071
|
}
|
|
1626
2072
|
getLocalFile(targetPath) {
|
|
1627
|
-
const filePath =
|
|
2073
|
+
const filePath = import_path4.default.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
|
|
1628
2074
|
const content = this.readFile(filePath);
|
|
1629
2075
|
return { filePath, content };
|
|
1630
2076
|
}
|
|
@@ -1652,7 +2098,10 @@ var Executor = class _Executor {
|
|
|
1652
2098
|
spinning(msg, { prefix = `${this.emoji}${this.name}`, indent = 0, enableSpin = !_Executor.verbose } = {}) {
|
|
1653
2099
|
return new Spinner(msg, { prefix, indent, enableSpin }).start();
|
|
1654
2100
|
}
|
|
1655
|
-
|
|
2101
|
+
#tsconfig = null;
|
|
2102
|
+
getTsConfig(pathname = "tsconfig.json", { refresh } = {}) {
|
|
2103
|
+
if (this.#tsconfig && !refresh)
|
|
2104
|
+
return this.#tsconfig;
|
|
1656
2105
|
const tsconfig = this.readJson(pathname);
|
|
1657
2106
|
if (tsconfig.extends) {
|
|
1658
2107
|
const extendsTsconfig = this.getTsConfig(tsconfig.extends);
|
|
@@ -1662,24 +2111,41 @@ var Executor = class _Executor {
|
|
|
1662
2111
|
compilerOptions: { ...extendsTsconfig.compilerOptions, ...tsconfig.compilerOptions }
|
|
1663
2112
|
};
|
|
1664
2113
|
}
|
|
2114
|
+
this.#tsconfig = tsconfig;
|
|
1665
2115
|
return tsconfig;
|
|
1666
2116
|
}
|
|
2117
|
+
setTsConfig(tsconfig) {
|
|
2118
|
+
this.writeJson("tsconfig.json", tsconfig);
|
|
2119
|
+
this.#tsconfig = tsconfig;
|
|
2120
|
+
}
|
|
2121
|
+
#packageJson = null;
|
|
2122
|
+
getPackageJson({ refresh } = {}) {
|
|
2123
|
+
if (this.#packageJson && !refresh)
|
|
2124
|
+
return this.#packageJson;
|
|
2125
|
+
const packageJson = this.readJson("package.json");
|
|
2126
|
+
this.#packageJson = packageJson;
|
|
2127
|
+
return packageJson;
|
|
2128
|
+
}
|
|
2129
|
+
setPackageJson(packageJson) {
|
|
2130
|
+
this.writeJson("package.json", packageJson);
|
|
2131
|
+
this.#packageJson = packageJson;
|
|
2132
|
+
}
|
|
1667
2133
|
async #applyTemplateFile({
|
|
1668
2134
|
templatePath,
|
|
1669
2135
|
targetPath,
|
|
1670
|
-
|
|
2136
|
+
scanInfo,
|
|
1671
2137
|
overwrite = true
|
|
1672
2138
|
}, dict = {}) {
|
|
1673
2139
|
if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
|
|
1674
2140
|
const getContent = await import(templatePath);
|
|
1675
|
-
const result = getContent.default(
|
|
2141
|
+
const result = getContent.default(scanInfo ?? null, dict);
|
|
1676
2142
|
if (result === null)
|
|
1677
2143
|
return null;
|
|
1678
|
-
const filename = typeof result === "object" ? result.filename :
|
|
2144
|
+
const filename = typeof result === "object" ? result.filename : import_path4.default.basename(targetPath).replace(".js", ".ts");
|
|
1679
2145
|
const content = typeof result === "object" ? result.content : result;
|
|
1680
|
-
const dirname3 =
|
|
2146
|
+
const dirname3 = import_path4.default.dirname(targetPath);
|
|
1681
2147
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
1682
|
-
(
|
|
2148
|
+
(path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
|
|
1683
2149
|
`${dirname3}/${filename}`
|
|
1684
2150
|
);
|
|
1685
2151
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
@@ -1687,7 +2153,7 @@ var Executor = class _Executor {
|
|
|
1687
2153
|
} else if (targetPath.endsWith(".template")) {
|
|
1688
2154
|
const content = await import_promises.default.readFile(templatePath, "utf8");
|
|
1689
2155
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
1690
|
-
(
|
|
2156
|
+
(path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
|
|
1691
2157
|
targetPath.slice(0, -9)
|
|
1692
2158
|
);
|
|
1693
2159
|
const convertedContent = Object.entries(dict).reduce(
|
|
@@ -1702,16 +2168,16 @@ var Executor = class _Executor {
|
|
|
1702
2168
|
async _applyTemplate({
|
|
1703
2169
|
basePath: basePath2,
|
|
1704
2170
|
template,
|
|
1705
|
-
|
|
2171
|
+
scanInfo,
|
|
1706
2172
|
dict = {},
|
|
1707
2173
|
overwrite = true
|
|
1708
2174
|
}) {
|
|
1709
2175
|
const templatePath = `${getDirname(import_meta2.url)}/src/templates${template ? `/${template}` : ""}`;
|
|
1710
2176
|
const prefixTemplatePath = templatePath.endsWith(".tsx") ? templatePath : templatePath.replace(".ts", ".js");
|
|
1711
2177
|
if (import_fs4.default.statSync(prefixTemplatePath).isFile()) {
|
|
1712
|
-
const filename =
|
|
2178
|
+
const filename = import_path4.default.basename(prefixTemplatePath);
|
|
1713
2179
|
const fileContent = await this.#applyTemplateFile(
|
|
1714
|
-
{ templatePath: prefixTemplatePath, targetPath:
|
|
2180
|
+
{ templatePath: prefixTemplatePath, targetPath: import_path4.default.join(basePath2, filename), scanInfo, overwrite },
|
|
1715
2181
|
dict
|
|
1716
2182
|
);
|
|
1717
2183
|
return fileContent ? [fileContent] : [];
|
|
@@ -1719,18 +2185,18 @@ var Executor = class _Executor {
|
|
|
1719
2185
|
const subdirs = await this.readdir(templatePath);
|
|
1720
2186
|
const fileContents = (await Promise.all(
|
|
1721
2187
|
subdirs.map(async (subdir) => {
|
|
1722
|
-
const subpath =
|
|
2188
|
+
const subpath = import_path4.default.join(templatePath, subdir);
|
|
1723
2189
|
if (import_fs4.default.statSync(subpath).isFile()) {
|
|
1724
2190
|
const fileContent = await this.#applyTemplateFile(
|
|
1725
|
-
{ templatePath: subpath, targetPath:
|
|
2191
|
+
{ templatePath: subpath, targetPath: import_path4.default.join(basePath2, subdir), scanInfo, overwrite },
|
|
1726
2192
|
dict
|
|
1727
2193
|
);
|
|
1728
2194
|
return fileContent ? [fileContent] : [];
|
|
1729
2195
|
} else
|
|
1730
2196
|
return await this._applyTemplate({
|
|
1731
|
-
basePath:
|
|
1732
|
-
template:
|
|
1733
|
-
|
|
2197
|
+
basePath: import_path4.default.join(basePath2, subdir),
|
|
2198
|
+
template: import_path4.default.join(template, subdir),
|
|
2199
|
+
scanInfo,
|
|
1734
2200
|
dict,
|
|
1735
2201
|
overwrite
|
|
1736
2202
|
});
|
|
@@ -1753,9 +2219,9 @@ var Executor = class _Executor {
|
|
|
1753
2219
|
return this.typeChecker;
|
|
1754
2220
|
}
|
|
1755
2221
|
typeCheck(filePath) {
|
|
1756
|
-
const
|
|
2222
|
+
const path10 = this.getPath(filePath);
|
|
1757
2223
|
const typeChecker = this.getTypeChecker();
|
|
1758
|
-
const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(
|
|
2224
|
+
const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path10);
|
|
1759
2225
|
const message = typeChecker.formatDiagnostics(fileDiagnostics);
|
|
1760
2226
|
return { fileDiagnostics, fileErrors, fileWarnings, message };
|
|
1761
2227
|
}
|
|
@@ -1764,9 +2230,9 @@ var Executor = class _Executor {
|
|
|
1764
2230
|
return this.linter;
|
|
1765
2231
|
}
|
|
1766
2232
|
async lint(filePath, { fix = false, dryRun = false } = {}) {
|
|
1767
|
-
const
|
|
2233
|
+
const path10 = this.getPath(filePath);
|
|
1768
2234
|
const linter = this.getLinter();
|
|
1769
|
-
const { results, errors, warnings } = await linter.lint(
|
|
2235
|
+
const { results, errors, warnings } = await linter.lint(path10, { fix, dryRun });
|
|
1770
2236
|
const message = linter.formatLintResults(results);
|
|
1771
2237
|
return { results, message, errors, warnings };
|
|
1772
2238
|
}
|
|
@@ -1780,9 +2246,12 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1780
2246
|
this.workspaceRoot = workspaceRoot;
|
|
1781
2247
|
this.repoName = repoName;
|
|
1782
2248
|
}
|
|
1783
|
-
static
|
|
1784
|
-
|
|
1785
|
-
|
|
2249
|
+
static #execs = /* @__PURE__ */ new Map();
|
|
2250
|
+
static fromRoot({
|
|
2251
|
+
workspaceRoot = process.cwd(),
|
|
2252
|
+
repoName = import_path4.default.basename(process.cwd())
|
|
2253
|
+
} = {}) {
|
|
2254
|
+
return this.#execs.get(repoName) ?? new _WorkspaceExecutor({ workspaceRoot, repoName });
|
|
1786
2255
|
}
|
|
1787
2256
|
getBaseDevEnv() {
|
|
1788
2257
|
const envFile = import_dotenv.default.parse(this.readFile(".env"));
|
|
@@ -1800,36 +2269,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1800
2269
|
return { ...appName ? { name: appName } : {}, repoName, serveDomain, env, portOffset };
|
|
1801
2270
|
}
|
|
1802
2271
|
async scan() {
|
|
1803
|
-
|
|
1804
|
-
const [appScanResults, libScanResults, pkgScanResults] = await Promise.all([
|
|
1805
|
-
Promise.all(
|
|
1806
|
-
appNames.map(async (appName) => {
|
|
1807
|
-
const app = AppExecutor.from(this, appName);
|
|
1808
|
-
const akanConfig = await app.getConfig("scan");
|
|
1809
|
-
return await app.scan({ akanConfig });
|
|
1810
|
-
})
|
|
1811
|
-
),
|
|
1812
|
-
Promise.all(
|
|
1813
|
-
libNames.map(async (libName) => {
|
|
1814
|
-
const lib = LibExecutor.from(this, libName);
|
|
1815
|
-
const akanConfig = await lib.getConfig("scan");
|
|
1816
|
-
return await lib.scan({ akanConfig });
|
|
1817
|
-
})
|
|
1818
|
-
),
|
|
1819
|
-
Promise.all(
|
|
1820
|
-
pkgNames.map(async (pkgName) => {
|
|
1821
|
-
return await PkgExecutor.from(this, pkgName).scan();
|
|
1822
|
-
})
|
|
1823
|
-
)
|
|
1824
|
-
]);
|
|
1825
|
-
return {
|
|
1826
|
-
appNames,
|
|
1827
|
-
libNames,
|
|
1828
|
-
pkgNames,
|
|
1829
|
-
apps: Object.fromEntries(appScanResults.map((app) => [app.name, app])),
|
|
1830
|
-
libs: Object.fromEntries(libScanResults.map((lib) => [lib.name, lib])),
|
|
1831
|
-
pkgs: Object.fromEntries(pkgScanResults.map((pkg) => [pkg.name, pkg]))
|
|
1832
|
-
};
|
|
2272
|
+
return await WorkspaceInfo.fromExecutor(this);
|
|
1833
2273
|
}
|
|
1834
2274
|
async getApps() {
|
|
1835
2275
|
if (!import_fs4.default.existsSync(`${this.workspaceRoot}/apps`))
|
|
@@ -1891,7 +2331,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1891
2331
|
dirs.map(async (dir) => {
|
|
1892
2332
|
if (dir.includes("_") || AVOID_DIRS.includes(dir))
|
|
1893
2333
|
return;
|
|
1894
|
-
const dirPath =
|
|
2334
|
+
const dirPath = import_path4.default.join(dirname3, dir);
|
|
1895
2335
|
if (import_fs4.default.lstatSync(dirPath).isDirectory()) {
|
|
1896
2336
|
results.push(`${prefix}${dir}`);
|
|
1897
2337
|
if (maxDepth > 0)
|
|
@@ -1918,9 +2358,9 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1918
2358
|
dirs.map(async (dir) => {
|
|
1919
2359
|
if (AVOID_DIRS.includes(dir))
|
|
1920
2360
|
return;
|
|
1921
|
-
const dirPath =
|
|
2361
|
+
const dirPath = import_path4.default.join(dirname3, dir);
|
|
1922
2362
|
if (import_fs4.default.lstatSync(dirPath).isDirectory()) {
|
|
1923
|
-
const hasTargetFile = import_fs4.default.existsSync(
|
|
2363
|
+
const hasTargetFile = import_fs4.default.existsSync(import_path4.default.join(dirPath, targetFilename));
|
|
1924
2364
|
if (hasTargetFile)
|
|
1925
2365
|
results.push(`${prefix}${dir}`);
|
|
1926
2366
|
if (maxDepth > 0)
|
|
@@ -1977,163 +2417,106 @@ var SysExecutor = class extends Executor {
|
|
|
1977
2417
|
this.type = type;
|
|
1978
2418
|
this.emoji = execEmoji[type];
|
|
1979
2419
|
}
|
|
1980
|
-
|
|
1981
|
-
|
|
2420
|
+
#akanConfig = null;
|
|
2421
|
+
async getConfig({ refresh } = {}) {
|
|
2422
|
+
if (this.#akanConfig && !refresh)
|
|
2423
|
+
return this.#akanConfig;
|
|
2424
|
+
this.#akanConfig = this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name });
|
|
2425
|
+
return this.#akanConfig;
|
|
1982
2426
|
}
|
|
1983
2427
|
async getModules() {
|
|
1984
|
-
const
|
|
1985
|
-
return await this.workspace.getDirInModule(
|
|
2428
|
+
const path10 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
|
|
2429
|
+
return await this.workspace.getDirInModule(path10, this.name);
|
|
1986
2430
|
}
|
|
2431
|
+
#scanInfo = null;
|
|
1987
2432
|
async scan({
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
const
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
files.services.services.push(name);
|
|
2049
|
-
else if (filename.endsWith(".signal.ts"))
|
|
2050
|
-
files.signal.services.push(name);
|
|
2051
|
-
else if (filename.endsWith(".store.ts"))
|
|
2052
|
-
files.store.services.push(name);
|
|
2053
|
-
else if (filename === "index.tsx")
|
|
2054
|
-
files.components.services.push(name);
|
|
2055
|
-
});
|
|
2056
|
-
})
|
|
2057
|
-
);
|
|
2058
|
-
const scalarDirs = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_"));
|
|
2059
|
-
await Promise.all(
|
|
2060
|
-
scalarDirs.map(async (name) => {
|
|
2061
|
-
const filenames = await this.readdir(import_path3.default.join("lib/__scalar", name));
|
|
2062
|
-
filenames.forEach((filename) => {
|
|
2063
|
-
if (filename.endsWith(".constant.ts"))
|
|
2064
|
-
files.constants.scalars.push(name);
|
|
2065
|
-
else if (filename.endsWith(".dictionary.ts"))
|
|
2066
|
-
files.dictionary.scalars.push(name);
|
|
2067
|
-
else if (filename.endsWith(".document.ts"))
|
|
2068
|
-
files.documents.scalars.push(name);
|
|
2069
|
-
else if (filename.endsWith(".service.ts"))
|
|
2070
|
-
files.services.scalars.push(name);
|
|
2071
|
-
else if (filename.endsWith(".signal.ts"))
|
|
2072
|
-
files.signal.scalars.push(name);
|
|
2073
|
-
else if (filename.endsWith(".store.ts"))
|
|
2074
|
-
files.store.scalars.push(name);
|
|
2075
|
-
else if (filename === "index.ts")
|
|
2076
|
-
files.components.scalars.push(name);
|
|
2077
|
-
});
|
|
2078
|
-
})
|
|
2079
|
-
);
|
|
2080
|
-
const missingLibDeps = [];
|
|
2081
|
-
libDeps.forEach((libName) => {
|
|
2082
|
-
if (!akanConfig.libs.includes(libName))
|
|
2083
|
-
missingLibDeps.push(libName);
|
|
2084
|
-
});
|
|
2085
|
-
if (missingLibDeps.length)
|
|
2086
|
-
throw new Error(
|
|
2087
|
-
`Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
|
|
2088
|
-
);
|
|
2089
|
-
for (const libName of akanConfig.libs) {
|
|
2090
|
-
if (libScanResults[libName])
|
|
2091
|
-
continue;
|
|
2092
|
-
const lib = new LibExecutor({ workspace: this.workspace, name: libName });
|
|
2093
|
-
const akanConfig2 = await lib.getConfig();
|
|
2094
|
-
libScanResults[libName] = await lib.scan({ akanConfig: akanConfig2 }, libScanResults);
|
|
2433
|
+
refresh,
|
|
2434
|
+
write = true,
|
|
2435
|
+
writeLib = true
|
|
2436
|
+
} = {}) {
|
|
2437
|
+
if (this.#scanInfo && !refresh)
|
|
2438
|
+
return this.#scanInfo;
|
|
2439
|
+
const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this, { refresh }) : await LibInfo.fromExecutor(this, { refresh });
|
|
2440
|
+
if (write) {
|
|
2441
|
+
await Promise.all([
|
|
2442
|
+
this._applyTemplate({ basePath: "lib", template: "lib", scanInfo }),
|
|
2443
|
+
this._applyTemplate({ basePath: ".", template: "server.ts", scanInfo }),
|
|
2444
|
+
this._applyTemplate({ basePath: ".", template: "client.ts", scanInfo }),
|
|
2445
|
+
this.type === "lib" ? this._applyTemplate({ basePath: ".", template: "index.ts", scanInfo }) : null,
|
|
2446
|
+
...scanInfo.getDatabaseModules().map(
|
|
2447
|
+
(model) => this._applyTemplate({
|
|
2448
|
+
basePath: `lib/${model}`,
|
|
2449
|
+
template: "moduleRoot",
|
|
2450
|
+
scanInfo,
|
|
2451
|
+
dict: { model, Model: capitalize(model) }
|
|
2452
|
+
})
|
|
2453
|
+
),
|
|
2454
|
+
...scanInfo.getServiceModules().map(
|
|
2455
|
+
(model) => this._applyTemplate({
|
|
2456
|
+
basePath: `lib/_${model}`,
|
|
2457
|
+
template: "moduleRoot",
|
|
2458
|
+
scanInfo,
|
|
2459
|
+
dict: { model, Model: capitalize(model) }
|
|
2460
|
+
})
|
|
2461
|
+
)
|
|
2462
|
+
]);
|
|
2463
|
+
this.writeJson(`akan.${this.type}.json`, scanInfo.getScanResult());
|
|
2464
|
+
if (this.type === "lib")
|
|
2465
|
+
this.#updateDependencies(scanInfo);
|
|
2466
|
+
if (writeLib) {
|
|
2467
|
+
const libInfos = [...scanInfo.getLibInfos().values()];
|
|
2468
|
+
await Promise.all(
|
|
2469
|
+
libInfos.map((libInfo) => [
|
|
2470
|
+
libInfo.exec._applyTemplate({ basePath: "lib", template: "lib", scanInfo: libInfo }),
|
|
2471
|
+
libInfo.exec._applyTemplate({ basePath: ".", template: "server.ts", scanInfo: libInfo }),
|
|
2472
|
+
libInfo.exec._applyTemplate({ basePath: ".", template: "client.ts", scanInfo: libInfo }),
|
|
2473
|
+
libInfo.exec._applyTemplate({ basePath: ".", template: "index.ts", scanInfo: libInfo }),
|
|
2474
|
+
...libInfo.getDatabaseModules().map(
|
|
2475
|
+
(model) => libInfo.exec._applyTemplate({
|
|
2476
|
+
basePath: `lib/${model}`,
|
|
2477
|
+
template: "moduleRoot",
|
|
2478
|
+
scanInfo: libInfo,
|
|
2479
|
+
dict: { model, Model: capitalize(model) }
|
|
2480
|
+
})
|
|
2481
|
+
),
|
|
2482
|
+
...libInfo.getServiceModules().map(
|
|
2483
|
+
(model) => libInfo.exec._applyTemplate({
|
|
2484
|
+
basePath: `lib/_${model}`,
|
|
2485
|
+
template: "moduleRoot",
|
|
2486
|
+
scanInfo: libInfo,
|
|
2487
|
+
dict: { model, Model: capitalize(model) }
|
|
2488
|
+
})
|
|
2489
|
+
)
|
|
2490
|
+
]).flat()
|
|
2491
|
+
);
|
|
2492
|
+
}
|
|
2095
2493
|
}
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
libDeps,
|
|
2104
|
-
pkgDeps,
|
|
2105
|
-
dependencies: [...npmDepSet].filter((dep) => !dep.startsWith("@akanjs")),
|
|
2106
|
-
libs: Object.fromEntries(akanConfig.libs.map((libName) => [libName, libScanResults[libName]]))
|
|
2107
|
-
};
|
|
2108
|
-
await this._applyTemplate({ basePath: "lib", template: "lib", scanResult });
|
|
2109
|
-
await this._applyTemplate({ basePath: ".", template: "server.ts", scanResult });
|
|
2110
|
-
await this._applyTemplate({ basePath: ".", template: "client.ts", scanResult });
|
|
2111
|
-
if (this.type === "lib")
|
|
2112
|
-
await this._applyTemplate({ basePath: ".", template: "index.ts", scanResult });
|
|
2113
|
-
this.writeJson(`akan.${this.type}.json`, scanResult);
|
|
2114
|
-
if (this.type === "app")
|
|
2115
|
-
return scanResult;
|
|
2116
|
-
const libPackageJson = this.readJson("package.json");
|
|
2494
|
+
this.#scanInfo = scanInfo;
|
|
2495
|
+
return scanInfo;
|
|
2496
|
+
}
|
|
2497
|
+
#updateDependencies(scanInfo) {
|
|
2498
|
+
const rootPackageJson = this.workspace.getPackageJson();
|
|
2499
|
+
const libPackageJson = this.getPackageJson();
|
|
2500
|
+
const dependencies = scanInfo.getScanResult().dependencies;
|
|
2117
2501
|
const libPkgJsonWithDeps = {
|
|
2118
2502
|
...libPackageJson,
|
|
2119
2503
|
dependencies: {
|
|
2120
2504
|
...libPackageJson.dependencies,
|
|
2121
2505
|
...Object.fromEntries(
|
|
2122
|
-
|
|
2506
|
+
dependencies.filter((dep) => rootPackageJson.dependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.dependencies?.[dep]])
|
|
2123
2507
|
)
|
|
2124
2508
|
},
|
|
2125
2509
|
devDependencies: {
|
|
2126
2510
|
...libPackageJson.devDependencies,
|
|
2127
2511
|
...Object.fromEntries(
|
|
2128
|
-
|
|
2512
|
+
dependencies.filter((dep) => rootPackageJson.devDependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.devDependencies?.[dep]])
|
|
2129
2513
|
)
|
|
2130
2514
|
}
|
|
2131
2515
|
};
|
|
2132
|
-
this.
|
|
2133
|
-
return scanResult;
|
|
2516
|
+
this.setPackageJson(libPkgJsonWithDeps);
|
|
2134
2517
|
}
|
|
2135
2518
|
getLocalFile(targetPath) {
|
|
2136
|
-
const filePath =
|
|
2519
|
+
const filePath = import_path4.default.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
|
|
2137
2520
|
const content = this.workspace.readFile(filePath);
|
|
2138
2521
|
return { filePath, content };
|
|
2139
2522
|
}
|
|
@@ -2213,9 +2596,9 @@ var SysExecutor = class extends Executor {
|
|
|
2213
2596
|
)
|
|
2214
2597
|
};
|
|
2215
2598
|
const akanConfig = await this.getConfig();
|
|
2216
|
-
const
|
|
2217
|
-
const fileContents = await this._applyTemplate({ ...options,
|
|
2218
|
-
await this.scan(
|
|
2599
|
+
const scanInfo = await this.scan();
|
|
2600
|
+
const fileContents = await this._applyTemplate({ ...options, scanInfo, dict });
|
|
2601
|
+
await this.scan();
|
|
2219
2602
|
return fileContents;
|
|
2220
2603
|
}
|
|
2221
2604
|
setTsPaths() {
|
|
@@ -2230,21 +2613,29 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
|
2230
2613
|
super({ workspace, name, type: "app" });
|
|
2231
2614
|
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/apps/${name}`);
|
|
2232
2615
|
}
|
|
2616
|
+
static #execs = /* @__PURE__ */ new Map();
|
|
2233
2617
|
static from(executor, name) {
|
|
2234
|
-
|
|
2618
|
+
const exec2 = this.#execs.get(name);
|
|
2619
|
+
if (exec2)
|
|
2620
|
+
return exec2;
|
|
2621
|
+
else if (executor instanceof WorkspaceExecutor)
|
|
2235
2622
|
return new _AppExecutor({ workspace: executor, name });
|
|
2236
|
-
|
|
2623
|
+
else
|
|
2624
|
+
return new _AppExecutor({ workspace: executor.workspace, name });
|
|
2237
2625
|
}
|
|
2238
2626
|
getEnv() {
|
|
2239
2627
|
return this.workspace.getBaseDevEnv().env;
|
|
2240
2628
|
}
|
|
2241
|
-
|
|
2242
|
-
|
|
2629
|
+
#akanConfig = null;
|
|
2630
|
+
async getConfig({ refresh } = {}) {
|
|
2631
|
+
if (this.#akanConfig && !refresh)
|
|
2632
|
+
return this.#akanConfig;
|
|
2633
|
+
this.#akanConfig = await getAppConfig(this.cwdPath, {
|
|
2243
2634
|
...this.workspace.getBaseDevEnv(),
|
|
2244
2635
|
type: "app",
|
|
2245
|
-
name: this.name
|
|
2246
|
-
command
|
|
2636
|
+
name: this.name
|
|
2247
2637
|
});
|
|
2638
|
+
return this.#akanConfig;
|
|
2248
2639
|
}
|
|
2249
2640
|
async syncAssets(libDeps) {
|
|
2250
2641
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
@@ -2281,18 +2672,26 @@ var LibExecutor = class _LibExecutor extends SysExecutor {
|
|
|
2281
2672
|
super({ workspace, name, type: "lib" });
|
|
2282
2673
|
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/libs/${name}`);
|
|
2283
2674
|
}
|
|
2675
|
+
static #execs = /* @__PURE__ */ new Map();
|
|
2284
2676
|
static from(executor, name) {
|
|
2285
|
-
|
|
2677
|
+
const exec2 = this.#execs.get(name);
|
|
2678
|
+
if (exec2)
|
|
2679
|
+
return exec2;
|
|
2680
|
+
else if (executor instanceof WorkspaceExecutor)
|
|
2286
2681
|
return new _LibExecutor({ workspace: executor, name });
|
|
2287
|
-
|
|
2682
|
+
else
|
|
2683
|
+
return new _LibExecutor({ workspace: executor.workspace, name });
|
|
2288
2684
|
}
|
|
2289
|
-
|
|
2290
|
-
|
|
2685
|
+
#akanConfig = null;
|
|
2686
|
+
async getConfig({ refresh } = {}) {
|
|
2687
|
+
if (this.#akanConfig && !refresh)
|
|
2688
|
+
return this.#akanConfig;
|
|
2689
|
+
this.#akanConfig = await getLibConfig(this.cwdPath, {
|
|
2291
2690
|
...this.workspace.getBaseDevEnv(),
|
|
2292
2691
|
type: "lib",
|
|
2293
|
-
name: this.name
|
|
2294
|
-
command
|
|
2692
|
+
name: this.name
|
|
2295
2693
|
});
|
|
2694
|
+
return this.#akanConfig;
|
|
2296
2695
|
}
|
|
2297
2696
|
};
|
|
2298
2697
|
var PkgExecutor = class _PkgExecutor extends Executor {
|
|
@@ -2311,27 +2710,13 @@ var PkgExecutor = class _PkgExecutor extends Executor {
|
|
|
2311
2710
|
return new _PkgExecutor({ workspace: executor, name });
|
|
2312
2711
|
return new _PkgExecutor({ workspace: executor.workspace, name });
|
|
2313
2712
|
}
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
const
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
const pkgPathSet = new Set(
|
|
2322
|
-
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
|
|
2323
|
-
);
|
|
2324
|
-
const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
|
|
2325
|
-
const pkgDeps = [...pkgPathDepSet].map((path9) => {
|
|
2326
|
-
const pathSplitLength = path9.split("/").length;
|
|
2327
|
-
return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
2328
|
-
}).filter((pkg) => pkg !== this.name);
|
|
2329
|
-
const pkgScanResult = {
|
|
2330
|
-
name: this.name,
|
|
2331
|
-
pkgDeps,
|
|
2332
|
-
dependencies: [...npmDepSet]
|
|
2333
|
-
};
|
|
2334
|
-
return pkgScanResult;
|
|
2713
|
+
#scanInfo = null;
|
|
2714
|
+
async scan({ refresh } = {}) {
|
|
2715
|
+
if (this.#scanInfo && !refresh)
|
|
2716
|
+
return this.#scanInfo;
|
|
2717
|
+
const scanInfo = await PkgInfo.fromExecutor(this, { refresh });
|
|
2718
|
+
this.#scanInfo = scanInfo;
|
|
2719
|
+
return scanInfo;
|
|
2335
2720
|
}
|
|
2336
2721
|
};
|
|
2337
2722
|
var ModuleExecutor = class _ModuleExecutor extends Executor {
|
|
@@ -2635,7 +3020,7 @@ var extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =>
|
|
|
2635
3020
|
...pacakgeJson.devDependencies ?? {}
|
|
2636
3021
|
};
|
|
2637
3022
|
const requireRegex = /(?:require\s*\(|import\s*(?:[\w\s{},*]*\s+from\s*)?|import\s*\()\s*['"`]([^'"`]+)['"`]/g;
|
|
2638
|
-
for (const { text } of filepaths.filter(({ path:
|
|
3023
|
+
for (const { text } of filepaths.filter(({ path: path10 }) => path10.endsWith(".js") || path10.endsWith(".ts"))) {
|
|
2639
3024
|
let requireMatch;
|
|
2640
3025
|
while ((requireMatch = requireRegex.exec(text)) !== null) {
|
|
2641
3026
|
const moduleName = requireMatch[1];
|
|
@@ -2918,8 +3303,18 @@ var runCommands = async (...commands) => {
|
|
|
2918
3303
|
});
|
|
2919
3304
|
const __dirname = getDirname(import_meta3.url);
|
|
2920
3305
|
const hasPackageJson = import_fs7.default.existsSync(`${__dirname}/../package.json`);
|
|
2921
|
-
|
|
2922
|
-
import_commander.program.version(
|
|
3306
|
+
process.env.AKAN_VERSION = hasPackageJson ? JSON.parse(import_fs7.default.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
|
|
3307
|
+
import_commander.program.version(process.env.AKAN_VERSION).description("Akan CLI");
|
|
3308
|
+
const akanBasePackageJson = import_fs7.default.existsSync("./node_modules/@akanjs/base/package.json") ? JSON.parse(import_fs7.default.readFileSync("./node_modules/@akanjs/base/package.json", "utf8")) : null;
|
|
3309
|
+
if (akanBasePackageJson && akanBasePackageJson.version !== process.env.AKAN_VERSION) {
|
|
3310
|
+
Logger.rawLog(
|
|
3311
|
+
import_chalk4.default.yellow(
|
|
3312
|
+
`
|
|
3313
|
+
Akan CLI version is mismatch with installed package. ${process.env.AKAN_VERSION} (global) vs ${akanBasePackageJson.version} (base)
|
|
3314
|
+
It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`
|
|
3315
|
+
)
|
|
3316
|
+
);
|
|
3317
|
+
}
|
|
2923
3318
|
for (const command of commands) {
|
|
2924
3319
|
const targetMetas = getTargetMetas(command);
|
|
2925
3320
|
for (const targetMeta of targetMetas) {
|
|
@@ -2982,7 +3377,8 @@ var runCommands = async (...commands) => {
|
|
|
2982
3377
|
Logger.rawLog();
|
|
2983
3378
|
} catch (e) {
|
|
2984
3379
|
const errMsg = e instanceof Error ? e.message : typeof e === "string" ? e : JSON.stringify(e);
|
|
2985
|
-
Logger.
|
|
3380
|
+
Logger.rawLog(`
|
|
3381
|
+
${import_chalk4.default.red(errMsg)}`);
|
|
2986
3382
|
throw e;
|
|
2987
3383
|
}
|
|
2988
3384
|
});
|
|
@@ -3337,8 +3733,8 @@ var Builder = class {
|
|
|
3337
3733
|
}
|
|
3338
3734
|
};
|
|
3339
3735
|
buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
|
|
3340
|
-
this.#distExecutor.
|
|
3341
|
-
this.#executor.
|
|
3736
|
+
this.#distExecutor.setPackageJson(pkgPackageJson);
|
|
3737
|
+
this.#executor.setPackageJson(pkgPackageJson);
|
|
3342
3738
|
}
|
|
3343
3739
|
};
|
|
3344
3740
|
|
|
@@ -3433,8 +3829,8 @@ var LibraryRunner = class {
|
|
|
3433
3829
|
return LibExecutor.from(workspace, libName);
|
|
3434
3830
|
}
|
|
3435
3831
|
async mergeLibraryDependencies(lib) {
|
|
3436
|
-
const libPackageJson = lib.
|
|
3437
|
-
const rootPackageJson = lib.workspace.
|
|
3832
|
+
const libPackageJson = lib.getPackageJson();
|
|
3833
|
+
const rootPackageJson = lib.workspace.getPackageJson();
|
|
3438
3834
|
const dependencies = {};
|
|
3439
3835
|
const devDependencies = {};
|
|
3440
3836
|
const libDependencies = { ...libPackageJson.dependencies, ...libPackageJson.devDependencies };
|
|
@@ -3454,7 +3850,7 @@ var LibraryRunner = class {
|
|
|
3454
3850
|
devDependencies[dep] = allDependencies[dep];
|
|
3455
3851
|
});
|
|
3456
3852
|
const newRootPackageJson = { ...rootPackageJson, dependencies, devDependencies };
|
|
3457
|
-
lib.workspace.
|
|
3853
|
+
lib.workspace.setPackageJson(newRootPackageJson);
|
|
3458
3854
|
await lib.workspace.spawn("pnpm", ["install", "--reporter=silent"]);
|
|
3459
3855
|
await lib.workspace.commit(`Merge ${lib.name} library dependencies`);
|
|
3460
3856
|
}
|
|
@@ -3500,10 +3896,9 @@ var LibraryScript = class {
|
|
|
3500
3896
|
#runner = new LibraryRunner();
|
|
3501
3897
|
async syncLibrary(lib) {
|
|
3502
3898
|
const syncSpinner = lib.spinning("Syncing library...");
|
|
3503
|
-
const
|
|
3504
|
-
const scanResult = await lib.scan({ akanConfig });
|
|
3899
|
+
const scanInfo = await lib.scan();
|
|
3505
3900
|
syncSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) is synced`);
|
|
3506
|
-
return
|
|
3901
|
+
return scanInfo;
|
|
3507
3902
|
}
|
|
3508
3903
|
async createLibrary(libName, workspace) {
|
|
3509
3904
|
const spinner = workspace.spinning(`Creating ${libName} library`);
|
|
@@ -3565,6 +3960,7 @@ var MultiScrollList = ({ logList, maxLength = 100 }) => {
|
|
|
3565
3960
|
const [boxHeight, setBoxHeight] = (0, import_react2.useState)(
|
|
3566
3961
|
height - HEADER_HEIGHT - OUTER_BORDER_HEIGHT - FOOTER_HEIGHT - BORDER_HEIGHT
|
|
3567
3962
|
);
|
|
3963
|
+
const [boxWidth, setBoxWidth] = (0, import_react2.useState)(width - 28);
|
|
3568
3964
|
const getLimitedLogs = (logs) => {
|
|
3569
3965
|
return logs.length > maxLength ? logs.slice(logs.length - maxLength) : logs;
|
|
3570
3966
|
};
|
|
@@ -3616,6 +4012,15 @@ var MultiScrollList = ({ logList, maxLength = 100 }) => {
|
|
|
3616
4012
|
(0, import_react2.useEffect)(() => {
|
|
3617
4013
|
const getLogsToRender = (logs, index) => {
|
|
3618
4014
|
const limitedLogs = getLimitedLogs(logs);
|
|
4015
|
+
const logWidth = limitedLogs.reduce((acc, log) => acc + log.content.length, 0);
|
|
4016
|
+
if (logWidth > boxWidth) {
|
|
4017
|
+
return limitedLogs.map((log) => {
|
|
4018
|
+
return {
|
|
4019
|
+
type: log.type,
|
|
4020
|
+
content: log.content.slice(0, boxWidth)
|
|
4021
|
+
};
|
|
4022
|
+
});
|
|
4023
|
+
}
|
|
3619
4024
|
if (scrollPos > 0 && tabIndex === index) {
|
|
3620
4025
|
return limitedLogs.slice(limitedLogs.length - boxHeight - scrollPos, limitedLogs.length - scrollPos);
|
|
3621
4026
|
} else if (limitedLogs.length > boxHeight) {
|
|
@@ -3656,9 +4061,9 @@ var MultiScrollList = ({ logList, maxLength = 100 }) => {
|
|
|
3656
4061
|
height: "100%"
|
|
3657
4062
|
},
|
|
3658
4063
|
scrollPos > 0 ? /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, focusLog.slice(0, focusLog.length - 1).map((log, index) => {
|
|
3659
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { key: index }, log);
|
|
4064
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { color: log.type === "error" ? "red" : "white", key: index }, log.content);
|
|
3660
4065
|
}), /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "Scrolling... +", scrollPos)) : focusLog.map((log, index) => {
|
|
3661
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { key: index }, log);
|
|
4066
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { color: log.type === "error" ? "red" : "white", key: index }, log.content);
|
|
3662
4067
|
})
|
|
3663
4068
|
))), /* @__PURE__ */ import_react2.default.createElement(import_ink2.Box, { width: "100%", height: FOOTER_HEIGHT }, /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { dimColor: true }, /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, null, "You can use the following shortcuts:"), /* @__PURE__ */ import_react2.default.createElement(import_ink2.Newline, null), "* ", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "tab"), " to switch tab.", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Newline, null), "* ", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "shift"), " to scroll faster. (x10)", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Newline, null), "* ", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "space"), " to scroll.", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Newline, null), "* ", /* @__PURE__ */ import_react2.default.createElement(import_ink2.Text, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
|
|
3664
4069
|
};
|
|
@@ -3781,17 +4186,17 @@ var Start = ({ appName, bcp, fcp, csr, maxLength = 100 }) => {
|
|
|
3781
4186
|
logList: [
|
|
3782
4187
|
{
|
|
3783
4188
|
title: `${appName} frontend`,
|
|
3784
|
-
logs: frontendLogs
|
|
4189
|
+
logs: frontendLogs,
|
|
3785
4190
|
color: "#ff493b"
|
|
3786
4191
|
},
|
|
3787
4192
|
{
|
|
3788
4193
|
title: `${appName} backend`,
|
|
3789
|
-
logs: backendLogs
|
|
4194
|
+
logs: backendLogs,
|
|
3790
4195
|
color: "#e535ab"
|
|
3791
4196
|
},
|
|
3792
4197
|
{
|
|
3793
4198
|
title: `${appName} react`,
|
|
3794
|
-
logs: csrLogs
|
|
4199
|
+
logs: csrLogs,
|
|
3795
4200
|
color: "#7cc5d9"
|
|
3796
4201
|
}
|
|
3797
4202
|
],
|
|
@@ -3856,7 +4261,7 @@ var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
|
3856
4261
|
var import_js_yaml2 = __toESM(require("js-yaml"), 1);
|
|
3857
4262
|
var import_open = __toESM(require("open"), 1);
|
|
3858
4263
|
var import_ora3 = __toESM(require("ora"), 1);
|
|
3859
|
-
var
|
|
4264
|
+
var import_path5 = __toESM(require("path"), 1);
|
|
3860
4265
|
var vite = __toESM(require("vite"), 1);
|
|
3861
4266
|
var import_vite_plugin_commonjs = __toESM(require("vite-plugin-commonjs"), 1);
|
|
3862
4267
|
var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
|
|
@@ -3876,17 +4281,12 @@ var ApplicationRunner = class {
|
|
|
3876
4281
|
app.workspace.unsetTsPaths("app", app.name);
|
|
3877
4282
|
}
|
|
3878
4283
|
async getConfig(app) {
|
|
3879
|
-
return await
|
|
3880
|
-
...app.workspace.getBaseDevEnv(),
|
|
3881
|
-
type: "app",
|
|
3882
|
-
name: app.name,
|
|
3883
|
-
command: "start"
|
|
3884
|
-
});
|
|
4284
|
+
return await app.getConfig();
|
|
3885
4285
|
}
|
|
3886
|
-
async scanSync(app
|
|
3887
|
-
const
|
|
3888
|
-
await app.syncAssets(
|
|
3889
|
-
return
|
|
4286
|
+
async scanSync(app) {
|
|
4287
|
+
const scanInfo = await app.scan();
|
|
4288
|
+
await app.syncAssets(scanInfo.getScanResult().libDeps);
|
|
4289
|
+
return scanInfo;
|
|
3890
4290
|
}
|
|
3891
4291
|
async getScriptFilename(app) {
|
|
3892
4292
|
if (!app.exists("scripts")) {
|
|
@@ -3942,12 +4342,12 @@ var ApplicationRunner = class {
|
|
|
3942
4342
|
} else if (target === "csr")
|
|
3943
4343
|
await app.workspace.exec(`rm -rf ${app.workspace.workspaceRoot}/node_modules/.vite/${app.name}`);
|
|
3944
4344
|
else if (target === "backend")
|
|
3945
|
-
await app.cp("assets",
|
|
4345
|
+
await app.cp("assets", import_path5.default.join(app.dist.cwdPath, "backend", "assets"));
|
|
3946
4346
|
return { env: this.#getEnv(app, target, { AKAN_COMMAND_TYPE: type }) };
|
|
3947
4347
|
}
|
|
3948
4348
|
async buildBackend(app) {
|
|
3949
4349
|
await this.#prepareCommand(app, "start", "backend");
|
|
3950
|
-
const akanConfig = await app.getConfig(
|
|
4350
|
+
const akanConfig = await app.getConfig();
|
|
3951
4351
|
const buildResult = await esbuild2.build({
|
|
3952
4352
|
write: false,
|
|
3953
4353
|
entryPoints: [`${app.cwdPath}/main.ts`],
|
|
@@ -3958,7 +4358,7 @@ var ApplicationRunner = class {
|
|
|
3958
4358
|
outdir: `${app.dist.cwdPath}/backend`,
|
|
3959
4359
|
logLevel: "warning"
|
|
3960
4360
|
});
|
|
3961
|
-
const rootPackageJson = app.workspace.
|
|
4361
|
+
const rootPackageJson = app.workspace.getPackageJson();
|
|
3962
4362
|
const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson);
|
|
3963
4363
|
buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
|
|
3964
4364
|
const appPackageJson = {
|
|
@@ -3971,7 +4371,7 @@ var ApplicationRunner = class {
|
|
|
3971
4371
|
dependencies
|
|
3972
4372
|
};
|
|
3973
4373
|
app.dist.writeJson("backend/package.json", appPackageJson);
|
|
3974
|
-
app.dist.writeFile(
|
|
4374
|
+
app.dist.writeFile(import_path5.default.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.docker.content);
|
|
3975
4375
|
}
|
|
3976
4376
|
async startBackend(app, { open: open2 = false, onStart, withInk = false } = {}) {
|
|
3977
4377
|
const { env } = await this.#prepareCommand(app, "start", "backend");
|
|
@@ -3982,7 +4382,7 @@ var ApplicationRunner = class {
|
|
|
3982
4382
|
packages: "external",
|
|
3983
4383
|
platform: "node",
|
|
3984
4384
|
format: "cjs",
|
|
3985
|
-
outdir:
|
|
4385
|
+
outdir: import_path5.default.join(app.dist.cwdPath, "backend"),
|
|
3986
4386
|
logLevel: "warning"
|
|
3987
4387
|
});
|
|
3988
4388
|
await ctx.watch();
|
|
@@ -3998,7 +4398,7 @@ var ApplicationRunner = class {
|
|
|
3998
4398
|
}
|
|
3999
4399
|
async buildFrontend(app, { spawnOptions } = {}) {
|
|
4000
4400
|
const { env } = await this.#prepareCommand(app, "build", "frontend");
|
|
4001
|
-
const akanConfig = await app.getConfig(
|
|
4401
|
+
const akanConfig = await app.getConfig();
|
|
4002
4402
|
await app.spawn("npx", ["next", "build", "--no-lint"], { env, ...spawnOptions });
|
|
4003
4403
|
const buildResult = await esbuild2.build({
|
|
4004
4404
|
entryPoints: [`${app.cwdPath}/next.config.ts`],
|
|
@@ -4010,7 +4410,7 @@ var ApplicationRunner = class {
|
|
|
4010
4410
|
write: false,
|
|
4011
4411
|
logLevel: "warning"
|
|
4012
4412
|
});
|
|
4013
|
-
const rootPackageJson = app.workspace.
|
|
4413
|
+
const rootPackageJson = app.workspace.getPackageJson();
|
|
4014
4414
|
const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson, ["next", "react", "react-dom"]);
|
|
4015
4415
|
buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
|
|
4016
4416
|
const appPackageJson = {
|
|
@@ -4023,8 +4423,8 @@ var ApplicationRunner = class {
|
|
|
4023
4423
|
};
|
|
4024
4424
|
app.dist.writeJson("frontend/package.json", appPackageJson);
|
|
4025
4425
|
await Promise.all([
|
|
4026
|
-
app.cp(".next",
|
|
4027
|
-
app.cp("public",
|
|
4426
|
+
app.cp(".next", import_path5.default.join(app.dist.cwdPath, "frontend", ".next")),
|
|
4427
|
+
app.cp("public", import_path5.default.join(app.dist.cwdPath, "frontend", "public"))
|
|
4028
4428
|
]);
|
|
4029
4429
|
app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.docker.content);
|
|
4030
4430
|
}
|
|
@@ -4223,6 +4623,11 @@ var ApplicationRunner = class {
|
|
|
4223
4623
|
]);
|
|
4224
4624
|
}
|
|
4225
4625
|
async dbup(workspace) {
|
|
4626
|
+
try {
|
|
4627
|
+
await workspace.exec(`docker ps`);
|
|
4628
|
+
} catch (e) {
|
|
4629
|
+
throw new Error(`Docker daemon is not running. Please install docker or start docker daemon and try again.`);
|
|
4630
|
+
}
|
|
4226
4631
|
await workspace.applyTemplate({
|
|
4227
4632
|
basePath: "local",
|
|
4228
4633
|
template: "localDev",
|
|
@@ -4299,8 +4704,8 @@ var ApplicationRunner = class {
|
|
|
4299
4704
|
)
|
|
4300
4705
|
);
|
|
4301
4706
|
await Promise.all(
|
|
4302
|
-
[".next", "ios", "android", "public/libs"].map(async (
|
|
4303
|
-
const targetPath = `${sourceRoot}/apps/${app.name}/${
|
|
4707
|
+
[".next", "ios", "android", "public/libs"].map(async (path10) => {
|
|
4708
|
+
const targetPath = `${sourceRoot}/apps/${app.name}/${path10}`;
|
|
4304
4709
|
if (import_fs10.default.existsSync(targetPath))
|
|
4305
4710
|
await import_promises3.default.rm(targetPath, { recursive: true, force: true });
|
|
4306
4711
|
})
|
|
@@ -4318,7 +4723,7 @@ var ApplicationRunner = class {
|
|
|
4318
4723
|
];
|
|
4319
4724
|
await Promise.all(
|
|
4320
4725
|
syncPaths.map(
|
|
4321
|
-
(
|
|
4726
|
+
(path10) => import_promises3.default.cp(`${app.workspace.cwdPath}/${path10}`, `${sourceRoot}/${path10}`, { recursive: true })
|
|
4322
4727
|
)
|
|
4323
4728
|
);
|
|
4324
4729
|
const tsconfig = app.workspace.readJson("tsconfig.json");
|
|
@@ -4441,10 +4846,9 @@ var ApplicationScript = class {
|
|
|
4441
4846
|
}
|
|
4442
4847
|
async syncApplication(app) {
|
|
4443
4848
|
const spinner = app.spinning("Scanning application...");
|
|
4444
|
-
const
|
|
4445
|
-
const scanResult = await this.#runner.scanSync(app, akanConfig);
|
|
4849
|
+
const scanInfo = await this.#runner.scanSync(app);
|
|
4446
4850
|
spinner.succeed("Application scanned");
|
|
4447
|
-
return
|
|
4851
|
+
return scanInfo;
|
|
4448
4852
|
}
|
|
4449
4853
|
async script(app, filename) {
|
|
4450
4854
|
const scriptFilename = filename ?? await this.#runner.getScriptFilename(app);
|
|
@@ -4888,8 +5292,8 @@ var PackageRunner = class {
|
|
|
4888
5292
|
return scanResult;
|
|
4889
5293
|
}
|
|
4890
5294
|
async buildPackage(pkg) {
|
|
4891
|
-
const rootPackageJson = pkg.workspace.
|
|
4892
|
-
const pkgJson = pkg.
|
|
5295
|
+
const rootPackageJson = pkg.workspace.getPackageJson();
|
|
5296
|
+
const pkgJson = pkg.getPackageJson();
|
|
4893
5297
|
const builder = new Builder({ executor: pkg, distExecutor: pkg.dist, pkgJson, rootPackageJson });
|
|
4894
5298
|
if (pkg.name === "@akanjs/cli")
|
|
4895
5299
|
await builder.build({
|
|
@@ -5063,7 +5467,7 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
|
|
|
5063
5467
|
}
|
|
5064
5468
|
async #updateAkanPkgs(workspace) {
|
|
5065
5469
|
const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base");
|
|
5066
|
-
const rootPackageJson = workspace.
|
|
5470
|
+
const rootPackageJson = workspace.getPackageJson();
|
|
5067
5471
|
if (!rootPackageJson.dependencies)
|
|
5068
5472
|
throw new Error("No dependencies found in package.json");
|
|
5069
5473
|
Object.keys(rootPackageJson.dependencies).forEach((dependency) => {
|
|
@@ -5074,7 +5478,7 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
|
|
|
5074
5478
|
if (dependency.startsWith("@akanjs/"))
|
|
5075
5479
|
Object.assign(rootPackageJson.devDependencies ?? {}, { [dependency]: latestPublishedVersionOfBase });
|
|
5076
5480
|
});
|
|
5077
|
-
workspace.
|
|
5481
|
+
workspace.setPackageJson(rootPackageJson);
|
|
5078
5482
|
await workspace.spawn("pnpm", ["install"]);
|
|
5079
5483
|
}
|
|
5080
5484
|
};
|
|
@@ -5630,8 +6034,7 @@ var ModuleScript = class {
|
|
|
5630
6034
|
await this.#runner.createModuleTemplate(mod);
|
|
5631
6035
|
if (page && sys3.type === "app")
|
|
5632
6036
|
await this.pageScript.createCrudPage(mod, { app: sys3, basePath: null, single: false });
|
|
5633
|
-
|
|
5634
|
-
await sys3.scan({ akanConfig });
|
|
6037
|
+
await sys3.scan();
|
|
5635
6038
|
}
|
|
5636
6039
|
async createModule(sys3, name, description, schemaDescription) {
|
|
5637
6040
|
const session = new AiSession("createModule", { workspace: sys3.workspace, cacheKey: name });
|
|
@@ -5862,13 +6265,13 @@ PageCommand = __decorateClass([
|
|
|
5862
6265
|
|
|
5863
6266
|
// pkgs/@akanjs/cli/src/workspace/workspace.runner.ts
|
|
5864
6267
|
var import_latest_version2 = __toESM(require("latest-version"), 1);
|
|
5865
|
-
var
|
|
6268
|
+
var import_path6 = __toESM(require("path"), 1);
|
|
5866
6269
|
var import_uuid2 = require("uuid");
|
|
5867
6270
|
var WorkspaceRunner = class {
|
|
5868
6271
|
async createWorkspace(repoName, appName, dirname3 = ".") {
|
|
5869
6272
|
const cwdPath = process.cwd();
|
|
5870
|
-
const workspaceRoot =
|
|
5871
|
-
const workspace =
|
|
6273
|
+
const workspaceRoot = import_path6.default.join(cwdPath, dirname3, repoName);
|
|
6274
|
+
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
|
|
5872
6275
|
const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
|
|
5873
6276
|
await workspace.applyTemplate({
|
|
5874
6277
|
basePath: ".",
|
|
@@ -5876,7 +6279,7 @@ var WorkspaceRunner = class {
|
|
|
5876
6279
|
dict: { repoName, appName, serveDomain: "localhost" }
|
|
5877
6280
|
});
|
|
5878
6281
|
templateSpinner.succeed(`Workspace files created in ${dirname3}/${repoName}`);
|
|
5879
|
-
const rootPackageJson = workspace.
|
|
6282
|
+
const rootPackageJson = workspace.getPackageJson();
|
|
5880
6283
|
const dependencies = [
|
|
5881
6284
|
"@akanjs/base",
|
|
5882
6285
|
"@akanjs/cli",
|
|
@@ -5907,7 +6310,7 @@ var WorkspaceRunner = class {
|
|
|
5907
6310
|
...Object.fromEntries(devDependencies.map((dependency) => [dependency, latestPublishedVersionOfBase]))
|
|
5908
6311
|
}
|
|
5909
6312
|
};
|
|
5910
|
-
workspace.
|
|
6313
|
+
workspace.setPackageJson(packageJson);
|
|
5911
6314
|
const installSpinner = workspace.spinning("Installing dependencies with pnpm...");
|
|
5912
6315
|
await workspace.spawn("pnpm", ["install", "--reporter=silent"]);
|
|
5913
6316
|
installSpinner.succeed("Dependencies installed with pnpm");
|
|
@@ -6066,15 +6469,15 @@ var GuidelinePrompt = class extends Prompter {
|
|
|
6066
6469
|
async #getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
|
|
6067
6470
|
const matchingPaths = import_promises5.default.glob(matchPattern, {
|
|
6068
6471
|
cwd: this.workspace.workspaceRoot,
|
|
6069
|
-
exclude: (
|
|
6472
|
+
exclude: (path10) => avoidDirs.some((dir) => path10.includes(dir))
|
|
6070
6473
|
});
|
|
6071
6474
|
const paths = [];
|
|
6072
|
-
for await (const
|
|
6073
|
-
const fileContent = import_fs12.default.readFileSync(
|
|
6475
|
+
for await (const path10 of matchingPaths) {
|
|
6476
|
+
const fileContent = import_fs12.default.readFileSync(path10, "utf-8");
|
|
6074
6477
|
const textFilter = filterText ? new RegExp(filterText) : null;
|
|
6075
6478
|
if (filterText && !textFilter?.test(fileContent))
|
|
6076
6479
|
continue;
|
|
6077
|
-
paths.push(
|
|
6480
|
+
paths.push(path10);
|
|
6078
6481
|
}
|
|
6079
6482
|
return paths;
|
|
6080
6483
|
}
|