@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/esm/index.js
CHANGED
|
@@ -122,6 +122,9 @@ var Logger = class _Logger {
|
|
|
122
122
|
this.level = level;
|
|
123
123
|
this.#levelIdx = logLevels.findIndex((l) => l === level);
|
|
124
124
|
}
|
|
125
|
+
static isVerbose() {
|
|
126
|
+
return this.#levelIdx <= 1;
|
|
127
|
+
}
|
|
125
128
|
name;
|
|
126
129
|
constructor(name) {
|
|
127
130
|
this.name = name;
|
|
@@ -380,8 +383,8 @@ import * as fs3 from "fs";
|
|
|
380
383
|
import ora2 from "ora";
|
|
381
384
|
import * as ts from "typescript";
|
|
382
385
|
var parseTsConfig = (tsConfigPath = "./tsconfig.json") => {
|
|
383
|
-
const configFile = ts.readConfigFile(tsConfigPath, (
|
|
384
|
-
return ts.sys.readFile(
|
|
386
|
+
const configFile = ts.readConfigFile(tsConfigPath, (path10) => {
|
|
387
|
+
return ts.sys.readFile(path10);
|
|
385
388
|
});
|
|
386
389
|
return ts.parseJsonConfigFileContent(
|
|
387
390
|
configFile.config,
|
|
@@ -700,46 +703,11 @@ export default getNextConfig(config, appInfo);
|
|
|
700
703
|
|
|
701
704
|
// pkgs/@akanjs/config/src/types.ts
|
|
702
705
|
var archs = ["amd64", "arm64"];
|
|
703
|
-
var getDefaultFileScan = () => ({
|
|
704
|
-
constants: {
|
|
705
|
-
databases: [],
|
|
706
|
-
scalars: []
|
|
707
|
-
},
|
|
708
|
-
dictionary: {
|
|
709
|
-
databases: [],
|
|
710
|
-
services: [],
|
|
711
|
-
scalars: []
|
|
712
|
-
},
|
|
713
|
-
documents: {
|
|
714
|
-
databases: [],
|
|
715
|
-
scalars: []
|
|
716
|
-
},
|
|
717
|
-
services: {
|
|
718
|
-
databases: [],
|
|
719
|
-
services: [],
|
|
720
|
-
scalars: []
|
|
721
|
-
},
|
|
722
|
-
signal: {
|
|
723
|
-
databases: [],
|
|
724
|
-
services: [],
|
|
725
|
-
scalars: []
|
|
726
|
-
},
|
|
727
|
-
store: {
|
|
728
|
-
databases: [],
|
|
729
|
-
services: [],
|
|
730
|
-
scalars: []
|
|
731
|
-
},
|
|
732
|
-
components: {
|
|
733
|
-
databases: [],
|
|
734
|
-
services: [],
|
|
735
|
-
scalars: []
|
|
736
|
-
}
|
|
737
|
-
});
|
|
738
706
|
|
|
739
707
|
// pkgs/@akanjs/config/src/akanConfig.ts
|
|
740
708
|
var jiti = createJiti(import.meta.url);
|
|
741
709
|
var makeAppConfig = (config, props) => {
|
|
742
|
-
const { name, repoName
|
|
710
|
+
const { name, repoName } = props;
|
|
743
711
|
return {
|
|
744
712
|
rootLib: config.rootLib,
|
|
745
713
|
libs: config.libs ?? [],
|
|
@@ -885,18 +853,254 @@ import { exec, fork, spawn } from "child_process";
|
|
|
885
853
|
import dotenv from "dotenv";
|
|
886
854
|
import fs8 from "fs";
|
|
887
855
|
import fsPromise from "fs/promises";
|
|
888
|
-
import
|
|
856
|
+
import path7 from "path";
|
|
889
857
|
|
|
890
|
-
// pkgs/@akanjs/devkit/src/
|
|
858
|
+
// pkgs/@akanjs/devkit/src/getDirname.ts
|
|
859
|
+
import path2 from "path";
|
|
860
|
+
var getDirname = (url) => path2.dirname(new URL(url).pathname);
|
|
861
|
+
|
|
862
|
+
// pkgs/@akanjs/devkit/src/linter.ts
|
|
863
|
+
import chalk from "chalk";
|
|
864
|
+
import { ESLint } from "eslint";
|
|
891
865
|
import * as fs5 from "fs";
|
|
892
|
-
import * as
|
|
866
|
+
import * as path3 from "path";
|
|
867
|
+
var Linter = class {
|
|
868
|
+
#logger = new Logger("Linter");
|
|
869
|
+
#eslint;
|
|
870
|
+
lintRoot;
|
|
871
|
+
constructor(cwdPath) {
|
|
872
|
+
this.lintRoot = this.#findEslintRootPath(cwdPath);
|
|
873
|
+
this.#eslint = new ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
|
|
874
|
+
}
|
|
875
|
+
#findEslintRootPath(dir) {
|
|
876
|
+
const configPath2 = path3.join(dir, "eslint.config.ts");
|
|
877
|
+
if (fs5.existsSync(configPath2))
|
|
878
|
+
return dir;
|
|
879
|
+
const parentDir = path3.dirname(dir);
|
|
880
|
+
return this.#findEslintRootPath(parentDir);
|
|
881
|
+
}
|
|
882
|
+
async lint(filePath, { fix = false, dryRun = false } = {}) {
|
|
883
|
+
if (fix)
|
|
884
|
+
return await this.fixFile(filePath, dryRun);
|
|
885
|
+
return await this.lintFile(filePath);
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Lint a single file using ESLint
|
|
889
|
+
* @param filePath - Path to the file to lint
|
|
890
|
+
* @returns Array of ESLint results
|
|
891
|
+
*/
|
|
892
|
+
async lintFile(filePath) {
|
|
893
|
+
if (!fs5.existsSync(filePath))
|
|
894
|
+
throw new Error(`File not found: ${filePath}`);
|
|
895
|
+
const isIgnored = await this.#eslint.isPathIgnored(filePath);
|
|
896
|
+
if (isIgnored) {
|
|
897
|
+
this.#logger.warn(`File ${filePath} is ignored by ESLint configuration`);
|
|
898
|
+
return { fixed: false, results: [], errors: [], warnings: [] };
|
|
899
|
+
}
|
|
900
|
+
const results = await this.#eslint.lintFiles([filePath]);
|
|
901
|
+
const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
902
|
+
const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
903
|
+
return { fixed: false, results, errors, warnings };
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Format lint results for console output
|
|
907
|
+
* @param results - Array of ESLint results
|
|
908
|
+
* @returns Formatted string
|
|
909
|
+
*/
|
|
910
|
+
formatLintResults(results) {
|
|
911
|
+
if (results.length === 0)
|
|
912
|
+
return "No files to lint";
|
|
913
|
+
const output = [];
|
|
914
|
+
let totalErrors = 0;
|
|
915
|
+
let totalWarnings = 0;
|
|
916
|
+
results.forEach((result) => {
|
|
917
|
+
totalErrors += result.errorCount;
|
|
918
|
+
totalWarnings += result.warningCount;
|
|
919
|
+
if (result.messages.length > 0) {
|
|
920
|
+
output.push(`
|
|
921
|
+
${chalk.cyan(result.filePath)}`);
|
|
922
|
+
let sourceLines = [];
|
|
923
|
+
if (fs5.existsSync(result.filePath)) {
|
|
924
|
+
try {
|
|
925
|
+
const sourceContent = fs5.readFileSync(result.filePath, "utf8");
|
|
926
|
+
sourceLines = sourceContent.split("\n");
|
|
927
|
+
} catch (error) {
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
result.messages.forEach((message) => {
|
|
931
|
+
const type = message.severity === 2 ? "error" : "warning";
|
|
932
|
+
const typeColor = message.severity === 2 ? chalk.red : chalk.yellow;
|
|
933
|
+
const icon = message.severity === 2 ? "\u274C" : "\u26A0\uFE0F";
|
|
934
|
+
const ruleInfo = message.ruleId ? chalk.dim(` (${message.ruleId})`) : "";
|
|
935
|
+
output.push(`
|
|
936
|
+
${icon} ${typeColor(type)}: ${message.message}${ruleInfo}`);
|
|
937
|
+
output.push(` ${chalk.gray("at")} ${result.filePath}:${chalk.bold(`${message.line}:${message.column}`)}`);
|
|
938
|
+
if (sourceLines.length > 0 && message.line <= sourceLines.length) {
|
|
939
|
+
const sourceLine = sourceLines[message.line - 1];
|
|
940
|
+
const lineNumber = message.line.toString().padStart(5, " ");
|
|
941
|
+
output.push(`
|
|
942
|
+
${chalk.dim(lineNumber + " |")} ${sourceLine}`);
|
|
943
|
+
const underlinePrefix = " ".repeat(message.column - 1);
|
|
944
|
+
const underlineLength = message.endColumn ? message.endColumn - message.column : 1;
|
|
945
|
+
const underline = "^".repeat(Math.max(1, underlineLength));
|
|
946
|
+
output.push(`${chalk.dim(" ".repeat(lineNumber.length) + " |")} ${underlinePrefix}${typeColor(underline)}`);
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
if (totalErrors === 0 && totalWarnings === 0)
|
|
952
|
+
return chalk.bold("\u2705 No ESLint errors or warnings found");
|
|
953
|
+
const errorText = totalErrors > 0 ? chalk.red(`${totalErrors} error(s)`) : "0 errors";
|
|
954
|
+
const warningText = totalWarnings > 0 ? chalk.yellow(`${totalWarnings} warning(s)`) : "0 warnings";
|
|
955
|
+
const summary = [`
|
|
956
|
+
${errorText}, ${warningText} found`];
|
|
957
|
+
return summary.concat(output).join("\n");
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Get detailed lint information
|
|
961
|
+
* @param filePath - Path to the file to lint
|
|
962
|
+
* @returns Object containing detailed lint information
|
|
963
|
+
*/
|
|
964
|
+
async getDetailedLintInfo(filePath) {
|
|
965
|
+
const { results } = await this.lintFile(filePath);
|
|
966
|
+
const details = results.flatMap(
|
|
967
|
+
(result) => result.messages.map((message) => ({
|
|
968
|
+
line: message.line,
|
|
969
|
+
column: message.column,
|
|
970
|
+
message: message.message,
|
|
971
|
+
ruleId: message.ruleId,
|
|
972
|
+
severity: message.severity === 2 ? "error" : "warning",
|
|
973
|
+
fix: message.fix,
|
|
974
|
+
suggestions: message.suggestions
|
|
975
|
+
}))
|
|
976
|
+
);
|
|
977
|
+
const stats = results.reduce(
|
|
978
|
+
(acc, result) => ({
|
|
979
|
+
errorCount: acc.errorCount + result.errorCount,
|
|
980
|
+
warningCount: acc.warningCount + result.warningCount,
|
|
981
|
+
fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
|
|
982
|
+
fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount
|
|
983
|
+
}),
|
|
984
|
+
{ errorCount: 0, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0 }
|
|
985
|
+
);
|
|
986
|
+
return { results, details, stats };
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Check if a file has lint errors
|
|
990
|
+
* @param filePath - Path to the file to check
|
|
991
|
+
* @returns true if there are no errors, false otherwise
|
|
992
|
+
*/
|
|
993
|
+
async hasNoLintErrors(filePath) {
|
|
994
|
+
try {
|
|
995
|
+
const { results } = await this.lintFile(filePath);
|
|
996
|
+
return results.every((result) => result.errorCount === 0);
|
|
997
|
+
} catch (error) {
|
|
998
|
+
return false;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Get only error messages (excluding warnings)
|
|
1003
|
+
* @param filePath - Path to the file to lint
|
|
1004
|
+
* @returns Array of error messages
|
|
1005
|
+
*/
|
|
1006
|
+
async getErrors(filePath) {
|
|
1007
|
+
const { results } = await this.lintFile(filePath);
|
|
1008
|
+
return results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Get only warning messages
|
|
1012
|
+
* @param filePath - Path to the file to lint
|
|
1013
|
+
* @returns Array of warning messages
|
|
1014
|
+
*/
|
|
1015
|
+
async getWarnings(filePath) {
|
|
1016
|
+
const { results } = await this.lintFile(filePath);
|
|
1017
|
+
return results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Fix lint errors automatically
|
|
1021
|
+
* @param filePath - Path to the file to fix
|
|
1022
|
+
* @param dryRun - If true, returns the fixed content without writing to file
|
|
1023
|
+
* @returns Fixed content and remaining issues
|
|
1024
|
+
*/
|
|
1025
|
+
async fixFile(filePath, dryRun = false) {
|
|
1026
|
+
if (!fs5.existsSync(filePath))
|
|
1027
|
+
throw new Error(`File not found: ${filePath}`);
|
|
1028
|
+
const eslint = new ESLint({ cwd: this.lintRoot, fix: true });
|
|
1029
|
+
const results = await eslint.lintFiles([filePath]);
|
|
1030
|
+
const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
1031
|
+
const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
1032
|
+
if (!dryRun)
|
|
1033
|
+
await ESLint.outputFixes(results);
|
|
1034
|
+
const fixedResult = results[0];
|
|
1035
|
+
return { fixed: fixedResult.output !== void 0, output: fixedResult.output, results, errors, warnings };
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Get ESLint configuration for a file
|
|
1039
|
+
* @param filePath - Path to the file
|
|
1040
|
+
* @returns ESLint configuration object
|
|
1041
|
+
*/
|
|
1042
|
+
async getConfigForFile(filePath) {
|
|
1043
|
+
const eslint = new ESLint();
|
|
1044
|
+
const config = await eslint.calculateConfigForFile(filePath);
|
|
1045
|
+
return config;
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Get rules that are causing errors in a file
|
|
1049
|
+
* @param filePath - Path to the file to check
|
|
1050
|
+
* @returns Object mapping rule IDs to their error counts
|
|
1051
|
+
*/
|
|
1052
|
+
async getProblematicRules(filePath) {
|
|
1053
|
+
const { results } = await this.lintFile(filePath);
|
|
1054
|
+
const ruleCounts = {};
|
|
1055
|
+
results.forEach((result) => {
|
|
1056
|
+
result.messages.forEach((message) => {
|
|
1057
|
+
if (message.ruleId)
|
|
1058
|
+
ruleCounts[message.ruleId] = (ruleCounts[message.ruleId] || 0) + 1;
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1061
|
+
return ruleCounts;
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
// pkgs/@akanjs/devkit/src/scanInfo.ts
|
|
1066
|
+
import path5 from "path";
|
|
1067
|
+
|
|
1068
|
+
// pkgs/@akanjs/devkit/src/dependencyScanner.ts
|
|
1069
|
+
import * as fs6 from "fs";
|
|
1070
|
+
import * as path4 from "path";
|
|
893
1071
|
import * as ts2 from "typescript";
|
|
894
1072
|
var TypeScriptDependencyScanner = class {
|
|
895
|
-
constructor(directory) {
|
|
896
|
-
this.directory = directory;
|
|
897
|
-
}
|
|
898
1073
|
#fileDependencies = /* @__PURE__ */ new Map();
|
|
899
1074
|
#visitedFiles = /* @__PURE__ */ new Set();
|
|
1075
|
+
directory;
|
|
1076
|
+
tsconfig;
|
|
1077
|
+
rootPackageJson;
|
|
1078
|
+
constructor(directory, { tsconfig, rootPackageJson }) {
|
|
1079
|
+
this.directory = directory;
|
|
1080
|
+
this.tsconfig = tsconfig;
|
|
1081
|
+
this.rootPackageJson = rootPackageJson;
|
|
1082
|
+
}
|
|
1083
|
+
async getMonorepoDependencies(projectName) {
|
|
1084
|
+
const npmSet = new Set(
|
|
1085
|
+
Object.keys({ ...this.rootPackageJson.dependencies, ...this.rootPackageJson.devDependencies })
|
|
1086
|
+
);
|
|
1087
|
+
const pkgPathSet = new Set(
|
|
1088
|
+
Object.keys(this.tsconfig.compilerOptions.paths ?? {}).filter((path10) => this.tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
|
|
1089
|
+
);
|
|
1090
|
+
const libPathSet = new Set(
|
|
1091
|
+
Object.keys(this.tsconfig.compilerOptions.paths ?? {}).filter((path10) => this.tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("libs/"))).map((path10) => path10.replace("/*", ""))
|
|
1092
|
+
);
|
|
1093
|
+
const [npmDepSet, pkgPathDepSet, libPathDepSet] = await this.getImportSets([npmSet, pkgPathSet, libPathSet]);
|
|
1094
|
+
const pkgDeps = [...pkgPathDepSet].map((path10) => {
|
|
1095
|
+
const pathSplitLength = path10.split("/").length;
|
|
1096
|
+
return (this.tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1097
|
+
});
|
|
1098
|
+
const libDeps = [...libPathDepSet].map((path10) => {
|
|
1099
|
+
const pathSplitLength = path10.split("/").length;
|
|
1100
|
+
return (this.tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1101
|
+
}).filter((libName) => libName !== projectName);
|
|
1102
|
+
return { pkgDeps, libDeps, npmDeps: [...npmDepSet] };
|
|
1103
|
+
}
|
|
900
1104
|
async getImportSets(depSets) {
|
|
901
1105
|
const fileDependencies = await this.getDependencies();
|
|
902
1106
|
const importedDepSets = new Array(depSets.length);
|
|
@@ -933,9 +1137,9 @@ var TypeScriptDependencyScanner = class {
|
|
|
933
1137
|
async #findTypeScriptFiles(directory) {
|
|
934
1138
|
const files = [];
|
|
935
1139
|
const processDirectory = async (dir) => {
|
|
936
|
-
const entries = await
|
|
1140
|
+
const entries = await fs6.promises.readdir(dir, { withFileTypes: true });
|
|
937
1141
|
for (const entry of entries) {
|
|
938
|
-
const fullPath =
|
|
1142
|
+
const fullPath = path4.join(dir, entry.name);
|
|
939
1143
|
if (entry.isDirectory()) {
|
|
940
1144
|
if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
|
|
941
1145
|
await processDirectory(fullPath);
|
|
@@ -951,26 +1155,26 @@ var TypeScriptDependencyScanner = class {
|
|
|
951
1155
|
return;
|
|
952
1156
|
this.#visitedFiles.add(filePath);
|
|
953
1157
|
try {
|
|
954
|
-
const fileContent = await
|
|
1158
|
+
const fileContent = await fs6.promises.readFile(filePath, "utf-8");
|
|
955
1159
|
const imports = this.#extractImports(fileContent, filePath);
|
|
956
1160
|
const resolvedImports = imports.map((importPath) => {
|
|
957
1161
|
if (importPath.startsWith(".")) {
|
|
958
|
-
const resolvedPath = "./" +
|
|
1162
|
+
const resolvedPath = "./" + path4.join(path4.relative(baseDir, filePath), importPath);
|
|
959
1163
|
return this.#ensureExtension(resolvedPath);
|
|
960
1164
|
}
|
|
961
1165
|
return importPath;
|
|
962
1166
|
});
|
|
963
|
-
const relativePath =
|
|
1167
|
+
const relativePath = path4.relative(baseDir, filePath);
|
|
964
1168
|
this.#fileDependencies.set(relativePath, resolvedImports);
|
|
965
1169
|
} catch (error) {
|
|
966
1170
|
}
|
|
967
1171
|
}
|
|
968
1172
|
#ensureExtension(filePath) {
|
|
969
|
-
if (
|
|
1173
|
+
if (fs6.existsSync(`${filePath}.ts`))
|
|
970
1174
|
return `${filePath}.ts`;
|
|
971
|
-
else if (
|
|
1175
|
+
else if (fs6.existsSync(`${filePath}.tsx`))
|
|
972
1176
|
return `${filePath}.tsx`;
|
|
973
|
-
else if (
|
|
1177
|
+
else if (fs6.existsSync(filePath))
|
|
974
1178
|
return filePath;
|
|
975
1179
|
return `${filePath}.ts`;
|
|
976
1180
|
}
|
|
@@ -1034,217 +1238,442 @@ var TypeScriptDependencyScanner = class {
|
|
|
1034
1238
|
}
|
|
1035
1239
|
};
|
|
1036
1240
|
|
|
1037
|
-
// pkgs/@akanjs/devkit/src/
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
}
|
|
1079
|
-
const
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
result.messages.forEach((message) => {
|
|
1110
|
-
const type = message.severity === 2 ? "error" : "warning";
|
|
1111
|
-
const typeColor = message.severity === 2 ? chalk.red : chalk.yellow;
|
|
1112
|
-
const icon = message.severity === 2 ? "\u274C" : "\u26A0\uFE0F";
|
|
1113
|
-
const ruleInfo = message.ruleId ? chalk.dim(` (${message.ruleId})`) : "";
|
|
1114
|
-
output.push(`
|
|
1115
|
-
${icon} ${typeColor(type)}: ${message.message}${ruleInfo}`);
|
|
1116
|
-
output.push(` ${chalk.gray("at")} ${result.filePath}:${chalk.bold(`${message.line}:${message.column}`)}`);
|
|
1117
|
-
if (sourceLines.length > 0 && message.line <= sourceLines.length) {
|
|
1118
|
-
const sourceLine = sourceLines[message.line - 1];
|
|
1119
|
-
const lineNumber = message.line.toString().padStart(5, " ");
|
|
1120
|
-
output.push(`
|
|
1121
|
-
${chalk.dim(lineNumber + " |")} ${sourceLine}`);
|
|
1122
|
-
const underlinePrefix = " ".repeat(message.column - 1);
|
|
1123
|
-
const underlineLength = message.endColumn ? message.endColumn - message.column : 1;
|
|
1124
|
-
const underline = "^".repeat(Math.max(1, underlineLength));
|
|
1125
|
-
output.push(`${chalk.dim(" ".repeat(lineNumber.length) + " |")} ${underlinePrefix}${typeColor(underline)}`);
|
|
1126
|
-
}
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1241
|
+
// pkgs/@akanjs/devkit/src/scanInfo.ts
|
|
1242
|
+
var databaseFileTypes = [
|
|
1243
|
+
"constant",
|
|
1244
|
+
"dictionary",
|
|
1245
|
+
"document",
|
|
1246
|
+
"service",
|
|
1247
|
+
"signal",
|
|
1248
|
+
"store",
|
|
1249
|
+
"template",
|
|
1250
|
+
"unit",
|
|
1251
|
+
"util",
|
|
1252
|
+
"view",
|
|
1253
|
+
"zone"
|
|
1254
|
+
];
|
|
1255
|
+
var ScanInfo = class {
|
|
1256
|
+
scanResult;
|
|
1257
|
+
name;
|
|
1258
|
+
scalar = /* @__PURE__ */ new Map();
|
|
1259
|
+
service = /* @__PURE__ */ new Map();
|
|
1260
|
+
database = /* @__PURE__ */ new Map();
|
|
1261
|
+
file = Object.fromEntries(
|
|
1262
|
+
databaseFileTypes.map((type) => [
|
|
1263
|
+
type,
|
|
1264
|
+
{ all: /* @__PURE__ */ new Set(), databases: /* @__PURE__ */ new Set(), services: /* @__PURE__ */ new Set(), scalars: /* @__PURE__ */ new Set() }
|
|
1265
|
+
])
|
|
1266
|
+
);
|
|
1267
|
+
constants = /* @__PURE__ */ new Set();
|
|
1268
|
+
dictionaries = /* @__PURE__ */ new Set();
|
|
1269
|
+
documents = /* @__PURE__ */ new Set();
|
|
1270
|
+
services = /* @__PURE__ */ new Set();
|
|
1271
|
+
signals = /* @__PURE__ */ new Set();
|
|
1272
|
+
stores = /* @__PURE__ */ new Set();
|
|
1273
|
+
templates = /* @__PURE__ */ new Set();
|
|
1274
|
+
units = /* @__PURE__ */ new Set();
|
|
1275
|
+
utils = /* @__PURE__ */ new Set();
|
|
1276
|
+
views = /* @__PURE__ */ new Set();
|
|
1277
|
+
zones = /* @__PURE__ */ new Set();
|
|
1278
|
+
static async getScanResult(exec2) {
|
|
1279
|
+
const akanConfig = await exec2.getConfig();
|
|
1280
|
+
const tsconfig = exec2.getTsConfig();
|
|
1281
|
+
const rootPackageJson = exec2.workspace.getPackageJson();
|
|
1282
|
+
const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
|
|
1283
|
+
const { pkgDeps, libDeps, npmDeps } = await scanner.getMonorepoDependencies(exec2.name);
|
|
1284
|
+
const files = {
|
|
1285
|
+
constant: { databases: [], scalars: [] },
|
|
1286
|
+
dictionary: { databases: [], services: [], scalars: [] },
|
|
1287
|
+
document: { databases: [], scalars: [] },
|
|
1288
|
+
service: { databases: [], services: [] },
|
|
1289
|
+
signal: { databases: [], services: [] },
|
|
1290
|
+
store: { databases: [], services: [] },
|
|
1291
|
+
template: { databases: [], services: [], scalars: [] },
|
|
1292
|
+
unit: { databases: [], services: [], scalars: [] },
|
|
1293
|
+
util: { databases: [], services: [], scalars: [] },
|
|
1294
|
+
view: { databases: [], services: [], scalars: [] },
|
|
1295
|
+
zone: { databases: [], services: [], scalars: [] }
|
|
1296
|
+
};
|
|
1297
|
+
const [{ dirs: dirnames }, scalarDirs] = await Promise.all([
|
|
1298
|
+
exec2.getFilesAndDirs("lib"),
|
|
1299
|
+
exec2.readdir("lib/__scalar")
|
|
1300
|
+
]);
|
|
1301
|
+
const databaseDirs = [];
|
|
1302
|
+
const serviceDirs = [];
|
|
1303
|
+
dirnames.forEach((name) => {
|
|
1304
|
+
if (name.startsWith("_")) {
|
|
1305
|
+
if (name.startsWith("__"))
|
|
1306
|
+
return;
|
|
1307
|
+
else
|
|
1308
|
+
serviceDirs.push(name);
|
|
1309
|
+
} else
|
|
1310
|
+
databaseDirs.push(name);
|
|
1129
1311
|
});
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
(acc, result) => ({
|
|
1158
|
-
errorCount: acc.errorCount + result.errorCount,
|
|
1159
|
-
warningCount: acc.warningCount + result.warningCount,
|
|
1160
|
-
fixableErrorCount: acc.fixableErrorCount + result.fixableErrorCount,
|
|
1161
|
-
fixableWarningCount: acc.fixableWarningCount + result.fixableWarningCount
|
|
1312
|
+
await Promise.all([
|
|
1313
|
+
...databaseDirs.map(async (name) => {
|
|
1314
|
+
const filenames = await exec2.readdir(path5.join("lib", name));
|
|
1315
|
+
filenames.forEach((filename) => {
|
|
1316
|
+
if (filename.endsWith(".constant.ts"))
|
|
1317
|
+
files.constant.databases.push(name);
|
|
1318
|
+
else if (filename.endsWith(".dictionary.ts"))
|
|
1319
|
+
files.dictionary.databases.push(name);
|
|
1320
|
+
else if (filename.endsWith(".document.ts"))
|
|
1321
|
+
files.document.databases.push(name);
|
|
1322
|
+
else if (filename.endsWith(".service.ts"))
|
|
1323
|
+
files.service.databases.push(name);
|
|
1324
|
+
else if (filename.endsWith(".signal.ts"))
|
|
1325
|
+
files.signal.databases.push(name);
|
|
1326
|
+
else if (filename.endsWith(".store.ts"))
|
|
1327
|
+
files.store.databases.push(name);
|
|
1328
|
+
else if (filename.endsWith(".Template.tsx"))
|
|
1329
|
+
files.template.databases.push(name);
|
|
1330
|
+
else if (filename.endsWith(".Unit.tsx"))
|
|
1331
|
+
files.unit.databases.push(name);
|
|
1332
|
+
else if (filename.endsWith(".Util.tsx"))
|
|
1333
|
+
files.util.databases.push(name);
|
|
1334
|
+
else if (filename.endsWith(".View.tsx"))
|
|
1335
|
+
files.view.databases.push(name);
|
|
1336
|
+
else if (filename.endsWith(".Zone.tsx"))
|
|
1337
|
+
files.zone.databases.push(name);
|
|
1338
|
+
});
|
|
1162
1339
|
}),
|
|
1163
|
-
|
|
1340
|
+
...serviceDirs.map(async (dirname3) => {
|
|
1341
|
+
const name = dirname3.slice(1);
|
|
1342
|
+
const filenames = await exec2.readdir(path5.join("lib", dirname3));
|
|
1343
|
+
filenames.forEach((filename) => {
|
|
1344
|
+
if (filename.endsWith(".dictionary.ts"))
|
|
1345
|
+
files.dictionary.services.push(name);
|
|
1346
|
+
else if (filename.endsWith(".service.ts"))
|
|
1347
|
+
files.service.services.push(name);
|
|
1348
|
+
else if (filename.endsWith(".signal.ts"))
|
|
1349
|
+
files.signal.services.push(name);
|
|
1350
|
+
else if (filename.endsWith(".store.ts"))
|
|
1351
|
+
files.store.services.push(name);
|
|
1352
|
+
else if (filename.endsWith(".Template.tsx"))
|
|
1353
|
+
files.template.services.push(name);
|
|
1354
|
+
else if (filename.endsWith(".Unit.tsx"))
|
|
1355
|
+
files.unit.services.push(name);
|
|
1356
|
+
else if (filename.endsWith(".Util.tsx"))
|
|
1357
|
+
files.util.services.push(name);
|
|
1358
|
+
else if (filename.endsWith(".View.tsx"))
|
|
1359
|
+
files.view.services.push(name);
|
|
1360
|
+
else if (filename.endsWith(".Zone.tsx"))
|
|
1361
|
+
files.zone.services.push(name);
|
|
1362
|
+
});
|
|
1363
|
+
}),
|
|
1364
|
+
...scalarDirs.map(async (name) => {
|
|
1365
|
+
const filenames = await exec2.readdir(path5.join("lib/__scalar", name));
|
|
1366
|
+
filenames.forEach((filename) => {
|
|
1367
|
+
if (filename.endsWith(".constant.ts"))
|
|
1368
|
+
files.constant.scalars.push(name);
|
|
1369
|
+
else if (filename.endsWith(".dictionary.ts"))
|
|
1370
|
+
files.dictionary.scalars.push(name);
|
|
1371
|
+
else if (filename.endsWith(".document.ts"))
|
|
1372
|
+
files.document.scalars.push(name);
|
|
1373
|
+
else if (filename.endsWith(".Template.tsx"))
|
|
1374
|
+
files.template.scalars.push(name);
|
|
1375
|
+
else if (filename.endsWith(".Unit.tsx"))
|
|
1376
|
+
files.unit.scalars.push(name);
|
|
1377
|
+
else if (filename.endsWith(".Util.tsx"))
|
|
1378
|
+
files.util.scalars.push(name);
|
|
1379
|
+
else if (filename.endsWith(".View.tsx"))
|
|
1380
|
+
files.view.scalars.push(name);
|
|
1381
|
+
else if (filename.endsWith(".Zone.tsx"))
|
|
1382
|
+
files.zone.scalars.push(name);
|
|
1383
|
+
});
|
|
1384
|
+
})
|
|
1385
|
+
]);
|
|
1386
|
+
const missingLibDeps = [];
|
|
1387
|
+
libDeps.forEach((libName) => {
|
|
1388
|
+
if (!akanConfig.libs.includes(libName))
|
|
1389
|
+
missingLibDeps.push(libName);
|
|
1390
|
+
});
|
|
1391
|
+
if (missingLibDeps.length)
|
|
1392
|
+
throw new Error(
|
|
1393
|
+
`Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
|
|
1394
|
+
);
|
|
1395
|
+
const scanResult = {
|
|
1396
|
+
name: exec2.name,
|
|
1397
|
+
type: exec2.type,
|
|
1398
|
+
repoName: exec2.workspace.repoName,
|
|
1399
|
+
serveDomain: exec2.workspace.getBaseDevEnv().serveDomain,
|
|
1400
|
+
akanConfig,
|
|
1401
|
+
files,
|
|
1402
|
+
libDeps,
|
|
1403
|
+
pkgDeps,
|
|
1404
|
+
dependencies: npmDeps.filter((dep) => !dep.startsWith("@akanjs"))
|
|
1405
|
+
};
|
|
1406
|
+
return scanResult;
|
|
1407
|
+
}
|
|
1408
|
+
constructor(scanResult) {
|
|
1409
|
+
this.name = scanResult.name;
|
|
1410
|
+
this.scanResult = scanResult;
|
|
1411
|
+
Object.entries(scanResult.files).forEach(
|
|
1412
|
+
([key, value]) => {
|
|
1413
|
+
const { databases, services, scalars } = value;
|
|
1414
|
+
databases.forEach((modelName) => {
|
|
1415
|
+
const model = this.database.get(modelName) ?? /* @__PURE__ */ new Set();
|
|
1416
|
+
model.add(key);
|
|
1417
|
+
this.database.set(modelName, model);
|
|
1418
|
+
this.file[key].all.add(modelName);
|
|
1419
|
+
this.file[key].databases.add(modelName);
|
|
1420
|
+
});
|
|
1421
|
+
services?.forEach((serviceName) => {
|
|
1422
|
+
const service = this.service.get(serviceName) ?? /* @__PURE__ */ new Set();
|
|
1423
|
+
service.add(key);
|
|
1424
|
+
this.service.set(serviceName, service);
|
|
1425
|
+
this.file[key].all.add(serviceName);
|
|
1426
|
+
this.file[key].services.add(serviceName);
|
|
1427
|
+
});
|
|
1428
|
+
scalars?.forEach((scalarName) => {
|
|
1429
|
+
const scalar = this.scalar.get(scalarName) ?? /* @__PURE__ */ new Set();
|
|
1430
|
+
scalar.add(key);
|
|
1431
|
+
this.scalar.set(scalarName, scalar);
|
|
1432
|
+
this.file[key].all.add(scalarName);
|
|
1433
|
+
this.file[key].scalars.add(scalarName);
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1164
1436
|
);
|
|
1165
|
-
return { results, details, stats };
|
|
1166
1437
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
* @param filePath - Path to the file to check
|
|
1170
|
-
* @returns true if there are no errors, false otherwise
|
|
1171
|
-
*/
|
|
1172
|
-
async hasNoLintErrors(filePath) {
|
|
1173
|
-
try {
|
|
1174
|
-
const { results } = await this.lintFile(filePath);
|
|
1175
|
-
return results.every((result) => result.errorCount === 0);
|
|
1176
|
-
} catch (error) {
|
|
1177
|
-
return false;
|
|
1178
|
-
}
|
|
1438
|
+
getScanResult() {
|
|
1439
|
+
return this.scanResult;
|
|
1179
1440
|
}
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
* @param filePath - Path to the file to lint
|
|
1183
|
-
* @returns Array of error messages
|
|
1184
|
-
*/
|
|
1185
|
-
async getErrors(filePath) {
|
|
1186
|
-
const { results } = await this.lintFile(filePath);
|
|
1187
|
-
return results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
1441
|
+
getDatabaseModules() {
|
|
1442
|
+
return [...this.database.keys()];
|
|
1188
1443
|
}
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
* @param filePath - Path to the file to lint
|
|
1192
|
-
* @returns Array of warning messages
|
|
1193
|
-
*/
|
|
1194
|
-
async getWarnings(filePath) {
|
|
1195
|
-
const { results } = await this.lintFile(filePath);
|
|
1196
|
-
return results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
1444
|
+
getServiceModules() {
|
|
1445
|
+
return [...this.service.keys()];
|
|
1197
1446
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
* @param filePath - Path to the file to fix
|
|
1201
|
-
* @param dryRun - If true, returns the fixed content without writing to file
|
|
1202
|
-
* @returns Fixed content and remaining issues
|
|
1203
|
-
*/
|
|
1204
|
-
async fixFile(filePath, dryRun = false) {
|
|
1205
|
-
if (!fs6.existsSync(filePath))
|
|
1206
|
-
throw new Error(`File not found: ${filePath}`);
|
|
1207
|
-
const eslint = new ESLint({ cwd: this.lintRoot, fix: true });
|
|
1208
|
-
const results = await eslint.lintFiles([filePath]);
|
|
1209
|
-
const errors = results.flatMap((result) => result.messages.filter((message) => message.severity === 2));
|
|
1210
|
-
const warnings = results.flatMap((result) => result.messages.filter((message) => message.severity === 1));
|
|
1211
|
-
if (!dryRun)
|
|
1212
|
-
await ESLint.outputFixes(results);
|
|
1213
|
-
const fixedResult = results[0];
|
|
1214
|
-
return { fixed: fixedResult.output !== void 0, output: fixedResult.output, results, errors, warnings };
|
|
1447
|
+
getScalarModules() {
|
|
1448
|
+
return [...this.scalar.keys()];
|
|
1215
1449
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
const
|
|
1224
|
-
|
|
1450
|
+
};
|
|
1451
|
+
var AppInfo = class _AppInfo extends ScanInfo {
|
|
1452
|
+
type = "app";
|
|
1453
|
+
exec;
|
|
1454
|
+
akanConfig;
|
|
1455
|
+
static appInfos = /* @__PURE__ */ new Map();
|
|
1456
|
+
static async fromExecutor(exec2, options = {}) {
|
|
1457
|
+
const existingAppInfo = this.appInfos.get(exec2.name);
|
|
1458
|
+
if (existingAppInfo && !options.refresh)
|
|
1459
|
+
return existingAppInfo;
|
|
1460
|
+
const scanResult = await super.getScanResult(exec2);
|
|
1461
|
+
await Promise.all(
|
|
1462
|
+
scanResult.libDeps.map(async (libName) => {
|
|
1463
|
+
LibInfo.loadedLibs.add(libName);
|
|
1464
|
+
const libExecutor = LibExecutor.from(exec2, libName);
|
|
1465
|
+
LibInfo.libInfos.set(libName, await LibInfo.fromExecutor(libExecutor));
|
|
1466
|
+
})
|
|
1467
|
+
);
|
|
1468
|
+
const appInfo = new _AppInfo(exec2, scanResult);
|
|
1469
|
+
this.appInfos.set(exec2.name, appInfo);
|
|
1470
|
+
return appInfo;
|
|
1471
|
+
}
|
|
1472
|
+
constructor(exec2, scanResult) {
|
|
1473
|
+
super(scanResult);
|
|
1474
|
+
this.exec = exec2;
|
|
1475
|
+
this.akanConfig = scanResult.akanConfig;
|
|
1476
|
+
}
|
|
1477
|
+
getScanResult() {
|
|
1478
|
+
return this.scanResult;
|
|
1479
|
+
}
|
|
1480
|
+
#sortedLibs = null;
|
|
1481
|
+
#getSortedLibs() {
|
|
1482
|
+
if (this.#sortedLibs)
|
|
1483
|
+
return this.#sortedLibs;
|
|
1484
|
+
const libIndices = LibInfo.getSortedLibIndices();
|
|
1485
|
+
this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
|
|
1486
|
+
const indexA = libIndices.get(libNameA);
|
|
1487
|
+
const indexB = libIndices.get(libNameB);
|
|
1488
|
+
if (indexA === void 0 || indexB === void 0)
|
|
1489
|
+
throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
|
|
1490
|
+
return indexA - indexB;
|
|
1491
|
+
});
|
|
1492
|
+
return this.#sortedLibs;
|
|
1493
|
+
}
|
|
1494
|
+
getLibs() {
|
|
1495
|
+
return this.#getSortedLibs();
|
|
1496
|
+
}
|
|
1497
|
+
getLibInfo(libName) {
|
|
1498
|
+
const libSet = new Set(this.#getSortedLibs());
|
|
1499
|
+
if (!libSet.has(libName))
|
|
1500
|
+
throw new Error(`LibInfo is invalid: ${libName}`);
|
|
1501
|
+
return LibInfo.libInfos.get(libName);
|
|
1502
|
+
}
|
|
1503
|
+
getLibInfos() {
|
|
1504
|
+
return new Map(
|
|
1505
|
+
this.#getSortedLibs().map((libName) => {
|
|
1506
|
+
const libInfo = LibInfo.libInfos.get(libName);
|
|
1507
|
+
if (!libInfo)
|
|
1508
|
+
throw new Error(`LibInfo not found: ${libName}`);
|
|
1509
|
+
return [libName, libInfo];
|
|
1510
|
+
})
|
|
1511
|
+
);
|
|
1225
1512
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1513
|
+
};
|
|
1514
|
+
var LibInfo = class _LibInfo extends ScanInfo {
|
|
1515
|
+
type = "lib";
|
|
1516
|
+
exec;
|
|
1517
|
+
akanConfig;
|
|
1518
|
+
static loadedLibs = /* @__PURE__ */ new Set();
|
|
1519
|
+
static libInfos = /* @__PURE__ */ new Map();
|
|
1520
|
+
static #sortedLibIndices = null;
|
|
1521
|
+
static getSortedLibIndices() {
|
|
1522
|
+
if (this.#sortedLibIndices)
|
|
1523
|
+
return this.#sortedLibIndices;
|
|
1524
|
+
this.#sortedLibIndices = new Map(
|
|
1525
|
+
[...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.akanConfig.libs.includes(libInfoB.name) ? 1 : -1).map(([libName], index) => [libName, index])
|
|
1526
|
+
);
|
|
1527
|
+
return this.#sortedLibIndices;
|
|
1528
|
+
}
|
|
1529
|
+
static async fromExecutor(exec2, { refresh } = {}) {
|
|
1530
|
+
const existingLibInfo = this.libInfos.get(exec2.name);
|
|
1531
|
+
if (existingLibInfo && !refresh)
|
|
1532
|
+
return existingLibInfo;
|
|
1533
|
+
const scanResult = await super.getScanResult(exec2);
|
|
1534
|
+
await Promise.all(
|
|
1535
|
+
scanResult.libDeps.filter((libName) => !this.loadedLibs.has(libName)).map(async (libName) => {
|
|
1536
|
+
this.loadedLibs.add(libName);
|
|
1537
|
+
this.libInfos.set(libName, await _LibInfo.fromExecutor(exec2));
|
|
1538
|
+
})
|
|
1539
|
+
);
|
|
1540
|
+
const libInfo = new _LibInfo(exec2, scanResult);
|
|
1541
|
+
this.libInfos.set(exec2.name, libInfo);
|
|
1542
|
+
this.#sortedLibIndices = null;
|
|
1543
|
+
return libInfo;
|
|
1544
|
+
}
|
|
1545
|
+
constructor(exec2, scanResult) {
|
|
1546
|
+
super(scanResult);
|
|
1547
|
+
this.exec = exec2;
|
|
1548
|
+
this.akanConfig = scanResult.akanConfig;
|
|
1549
|
+
}
|
|
1550
|
+
getScanResult() {
|
|
1551
|
+
return this.scanResult;
|
|
1552
|
+
}
|
|
1553
|
+
#sortedLibs = null;
|
|
1554
|
+
#getSortedLibs() {
|
|
1555
|
+
if (this.#sortedLibs)
|
|
1556
|
+
return this.#sortedLibs;
|
|
1557
|
+
const libs = _LibInfo.getSortedLibIndices();
|
|
1558
|
+
this.#sortedLibs = this.akanConfig.libs.sort((libNameA, libNameB) => {
|
|
1559
|
+
const indexA = libs.get(libNameA);
|
|
1560
|
+
const indexB = libs.get(libNameB);
|
|
1561
|
+
if (indexA === void 0 || indexB === void 0)
|
|
1562
|
+
throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
|
|
1563
|
+
return indexA - indexB;
|
|
1239
1564
|
});
|
|
1240
|
-
return
|
|
1565
|
+
return this.#sortedLibs;
|
|
1566
|
+
}
|
|
1567
|
+
getLibs() {
|
|
1568
|
+
return this.#getSortedLibs();
|
|
1569
|
+
}
|
|
1570
|
+
getLibInfo(libName) {
|
|
1571
|
+
if (!this.getScanResult().akanConfig.libs.includes(libName))
|
|
1572
|
+
return void 0;
|
|
1573
|
+
const libSet = new Set(this.#getSortedLibs());
|
|
1574
|
+
if (!libSet.has(libName))
|
|
1575
|
+
throw new Error(`LibInfo is invalid: ${libName}`);
|
|
1576
|
+
return _LibInfo.libInfos.get(libName);
|
|
1577
|
+
}
|
|
1578
|
+
getLibInfos() {
|
|
1579
|
+
return new Map(
|
|
1580
|
+
this.#getSortedLibs().map((libName) => {
|
|
1581
|
+
const libInfo = _LibInfo.libInfos.get(libName);
|
|
1582
|
+
if (!libInfo)
|
|
1583
|
+
throw new Error(`LibInfo not found: ${libName}`);
|
|
1584
|
+
return [libName, libInfo];
|
|
1585
|
+
})
|
|
1586
|
+
);
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
var PkgInfo = class _PkgInfo {
|
|
1590
|
+
exec;
|
|
1591
|
+
name;
|
|
1592
|
+
scanResult;
|
|
1593
|
+
static async getScanResult(exec2) {
|
|
1594
|
+
const tsconfig = exec2.getTsConfig();
|
|
1595
|
+
const rootPackageJson = exec2.workspace.getPackageJson();
|
|
1596
|
+
const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, { tsconfig, rootPackageJson });
|
|
1597
|
+
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
1598
|
+
const pkgPathSet = new Set(
|
|
1599
|
+
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
|
|
1600
|
+
);
|
|
1601
|
+
const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
|
|
1602
|
+
const pkgDeps = [...pkgPathDepSet].map((path10) => {
|
|
1603
|
+
const pathSplitLength = path10.split("/").length;
|
|
1604
|
+
return (tsconfig.compilerOptions.paths?.[path10]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1605
|
+
}).filter((pkg) => pkg !== this.name);
|
|
1606
|
+
const pkgScanResult = {
|
|
1607
|
+
name: this.name,
|
|
1608
|
+
pkgDeps,
|
|
1609
|
+
dependencies: [...npmDepSet]
|
|
1610
|
+
};
|
|
1611
|
+
return pkgScanResult;
|
|
1612
|
+
}
|
|
1613
|
+
static #pkgInfos = /* @__PURE__ */ new Map();
|
|
1614
|
+
static async fromExecutor(exec2, options = {}) {
|
|
1615
|
+
const existingPkgInfo = this.#pkgInfos.get(exec2.name);
|
|
1616
|
+
if (existingPkgInfo && !options.refresh)
|
|
1617
|
+
return existingPkgInfo;
|
|
1618
|
+
const scanResult = await this.getScanResult(exec2);
|
|
1619
|
+
const pkgInfo = new _PkgInfo(exec2, scanResult);
|
|
1620
|
+
this.#pkgInfos.set(exec2.name, pkgInfo);
|
|
1621
|
+
return pkgInfo;
|
|
1622
|
+
}
|
|
1623
|
+
constructor(exec2, scanResult) {
|
|
1624
|
+
this.exec = exec2;
|
|
1625
|
+
this.name = exec2.name;
|
|
1626
|
+
this.scanResult = scanResult;
|
|
1627
|
+
}
|
|
1628
|
+
getScanResult() {
|
|
1629
|
+
return this.scanResult;
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
var WorkspaceInfo = class _WorkspaceInfo {
|
|
1633
|
+
constructor(appInfos = /* @__PURE__ */ new Map(), libInfos = /* @__PURE__ */ new Map(), pkgInfos = /* @__PURE__ */ new Map()) {
|
|
1634
|
+
this.appInfos = appInfos;
|
|
1635
|
+
this.libInfos = libInfos;
|
|
1636
|
+
this.pkgInfos = pkgInfos;
|
|
1637
|
+
}
|
|
1638
|
+
static #workspaceInfos = /* @__PURE__ */ new Map();
|
|
1639
|
+
static async fromExecutor(exec2, options = {}) {
|
|
1640
|
+
const existingWorkspaceInfo = this.#workspaceInfos.get(exec2.name);
|
|
1641
|
+
if (existingWorkspaceInfo && !options.refresh)
|
|
1642
|
+
return existingWorkspaceInfo;
|
|
1643
|
+
const [appNames, libNames, pkgNames] = await Promise.all([exec2.getApps(), exec2.getLibs(), exec2.getPkgs()]);
|
|
1644
|
+
const [appInfos, libInfos, pkgInfos] = await Promise.all([
|
|
1645
|
+
Promise.all(
|
|
1646
|
+
appNames.map(async (appName) => {
|
|
1647
|
+
const app = AppExecutor.from(exec2, appName);
|
|
1648
|
+
return await app.scan();
|
|
1649
|
+
})
|
|
1650
|
+
),
|
|
1651
|
+
Promise.all(
|
|
1652
|
+
libNames.map(async (libName) => {
|
|
1653
|
+
const lib = LibExecutor.from(exec2, libName);
|
|
1654
|
+
return await lib.scan();
|
|
1655
|
+
})
|
|
1656
|
+
),
|
|
1657
|
+
Promise.all(
|
|
1658
|
+
pkgNames.map(async (pkgName) => {
|
|
1659
|
+
return await PkgExecutor.from(exec2, pkgName).scan();
|
|
1660
|
+
})
|
|
1661
|
+
)
|
|
1662
|
+
]);
|
|
1663
|
+
const workspaceInfo = new _WorkspaceInfo(
|
|
1664
|
+
new Map(appInfos.map((app) => [app.exec.name, app])),
|
|
1665
|
+
new Map(libInfos.map((lib) => [lib.exec.name, lib])),
|
|
1666
|
+
new Map(pkgInfos.map((pkg) => [pkg.exec.name, pkg]))
|
|
1667
|
+
);
|
|
1668
|
+
this.#workspaceInfos.set(exec2.name, workspaceInfo);
|
|
1669
|
+
return workspaceInfo;
|
|
1241
1670
|
}
|
|
1242
1671
|
};
|
|
1243
1672
|
|
|
1244
1673
|
// pkgs/@akanjs/devkit/src/typeChecker.ts
|
|
1245
1674
|
import chalk2 from "chalk";
|
|
1246
1675
|
import * as fs7 from "fs";
|
|
1247
|
-
import * as
|
|
1676
|
+
import * as path6 from "path";
|
|
1248
1677
|
import * as ts3 from "typescript";
|
|
1249
1678
|
var TypeChecker = class {
|
|
1250
1679
|
configPath;
|
|
@@ -1259,7 +1688,7 @@ var TypeChecker = class {
|
|
|
1259
1688
|
const parsedConfig = ts3.parseJsonConfigFileContent(
|
|
1260
1689
|
this.configFile.config,
|
|
1261
1690
|
ts3.sys,
|
|
1262
|
-
|
|
1691
|
+
path6.dirname(this.configPath),
|
|
1263
1692
|
void 0,
|
|
1264
1693
|
this.configPath
|
|
1265
1694
|
);
|
|
@@ -1525,7 +1954,7 @@ var Executor = class _Executor {
|
|
|
1525
1954
|
});
|
|
1526
1955
|
}
|
|
1527
1956
|
getPath(filePath) {
|
|
1528
|
-
if (
|
|
1957
|
+
if (path7.isAbsolute(filePath))
|
|
1529
1958
|
return filePath;
|
|
1530
1959
|
const baseParts = this.cwdPath.split("/").filter(Boolean);
|
|
1531
1960
|
const targetParts = filePath.split("/").filter(Boolean);
|
|
@@ -1558,6 +1987,22 @@ var Executor = class _Executor {
|
|
|
1558
1987
|
return [];
|
|
1559
1988
|
}
|
|
1560
1989
|
}
|
|
1990
|
+
async getFilesAndDirs(dirPath) {
|
|
1991
|
+
const paths = await this.readdir(dirPath);
|
|
1992
|
+
const files = [];
|
|
1993
|
+
const dirs = [];
|
|
1994
|
+
const fullDirPath = this.getPath(dirPath);
|
|
1995
|
+
await Promise.all(
|
|
1996
|
+
paths.map(async (p) => {
|
|
1997
|
+
const stats = await fsPromise.stat(path7.join(fullDirPath, p));
|
|
1998
|
+
if (stats.isDirectory())
|
|
1999
|
+
dirs.push(p);
|
|
2000
|
+
else
|
|
2001
|
+
files.push(p);
|
|
2002
|
+
})
|
|
2003
|
+
);
|
|
2004
|
+
return { files, dirs };
|
|
2005
|
+
}
|
|
1561
2006
|
exists(filePath) {
|
|
1562
2007
|
const readPath = this.getPath(filePath);
|
|
1563
2008
|
return fs8.existsSync(readPath);
|
|
@@ -1578,7 +2023,7 @@ var Executor = class _Executor {
|
|
|
1578
2023
|
}
|
|
1579
2024
|
writeFile(filePath, content, { overwrite = true } = {}) {
|
|
1580
2025
|
const writePath = this.getPath(filePath);
|
|
1581
|
-
const dir =
|
|
2026
|
+
const dir = path7.dirname(writePath);
|
|
1582
2027
|
if (!fs8.existsSync(dir))
|
|
1583
2028
|
fs8.mkdirSync(dir, { recursive: true });
|
|
1584
2029
|
let contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
@@ -1589,11 +2034,12 @@ var Executor = class _Executor {
|
|
|
1589
2034
|
contentStr = fs8.readFileSync(writePath, "utf-8");
|
|
1590
2035
|
} else {
|
|
1591
2036
|
fs8.writeFileSync(writePath, contentStr, "utf8");
|
|
1592
|
-
|
|
2037
|
+
if (Logger.isVerbose())
|
|
2038
|
+
this.logger.rawLog(chalk3.yellow(`File Update: ${filePath}`));
|
|
1593
2039
|
}
|
|
1594
2040
|
} else {
|
|
1595
2041
|
fs8.writeFileSync(writePath, contentStr, "utf8");
|
|
1596
|
-
this.logger.
|
|
2042
|
+
this.logger.rawLog(chalk3.green(`File Create: ${filePath}`));
|
|
1597
2043
|
}
|
|
1598
2044
|
return { filePath: writePath, content: contentStr };
|
|
1599
2045
|
}
|
|
@@ -1602,7 +2048,7 @@ var Executor = class _Executor {
|
|
|
1602
2048
|
return this;
|
|
1603
2049
|
}
|
|
1604
2050
|
getLocalFile(targetPath) {
|
|
1605
|
-
const filePath =
|
|
2051
|
+
const filePath = path7.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
|
|
1606
2052
|
const content = this.readFile(filePath);
|
|
1607
2053
|
return { filePath, content };
|
|
1608
2054
|
}
|
|
@@ -1630,7 +2076,10 @@ var Executor = class _Executor {
|
|
|
1630
2076
|
spinning(msg, { prefix = `${this.emoji}${this.name}`, indent = 0, enableSpin = !_Executor.verbose } = {}) {
|
|
1631
2077
|
return new Spinner(msg, { prefix, indent, enableSpin }).start();
|
|
1632
2078
|
}
|
|
1633
|
-
|
|
2079
|
+
#tsconfig = null;
|
|
2080
|
+
getTsConfig(pathname = "tsconfig.json", { refresh } = {}) {
|
|
2081
|
+
if (this.#tsconfig && !refresh)
|
|
2082
|
+
return this.#tsconfig;
|
|
1634
2083
|
const tsconfig = this.readJson(pathname);
|
|
1635
2084
|
if (tsconfig.extends) {
|
|
1636
2085
|
const extendsTsconfig = this.getTsConfig(tsconfig.extends);
|
|
@@ -1640,24 +2089,41 @@ var Executor = class _Executor {
|
|
|
1640
2089
|
compilerOptions: { ...extendsTsconfig.compilerOptions, ...tsconfig.compilerOptions }
|
|
1641
2090
|
};
|
|
1642
2091
|
}
|
|
2092
|
+
this.#tsconfig = tsconfig;
|
|
1643
2093
|
return tsconfig;
|
|
1644
2094
|
}
|
|
2095
|
+
setTsConfig(tsconfig) {
|
|
2096
|
+
this.writeJson("tsconfig.json", tsconfig);
|
|
2097
|
+
this.#tsconfig = tsconfig;
|
|
2098
|
+
}
|
|
2099
|
+
#packageJson = null;
|
|
2100
|
+
getPackageJson({ refresh } = {}) {
|
|
2101
|
+
if (this.#packageJson && !refresh)
|
|
2102
|
+
return this.#packageJson;
|
|
2103
|
+
const packageJson = this.readJson("package.json");
|
|
2104
|
+
this.#packageJson = packageJson;
|
|
2105
|
+
return packageJson;
|
|
2106
|
+
}
|
|
2107
|
+
setPackageJson(packageJson) {
|
|
2108
|
+
this.writeJson("package.json", packageJson);
|
|
2109
|
+
this.#packageJson = packageJson;
|
|
2110
|
+
}
|
|
1645
2111
|
async #applyTemplateFile({
|
|
1646
2112
|
templatePath,
|
|
1647
2113
|
targetPath,
|
|
1648
|
-
|
|
2114
|
+
scanInfo,
|
|
1649
2115
|
overwrite = true
|
|
1650
2116
|
}, dict = {}) {
|
|
1651
2117
|
if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
|
|
1652
2118
|
const getContent = await import(templatePath);
|
|
1653
|
-
const result = getContent.default(
|
|
2119
|
+
const result = getContent.default(scanInfo ?? null, dict);
|
|
1654
2120
|
if (result === null)
|
|
1655
2121
|
return null;
|
|
1656
|
-
const filename = typeof result === "object" ? result.filename :
|
|
2122
|
+
const filename = typeof result === "object" ? result.filename : path7.basename(targetPath).replace(".js", ".ts");
|
|
1657
2123
|
const content = typeof result === "object" ? result.content : result;
|
|
1658
|
-
const dirname3 =
|
|
2124
|
+
const dirname3 = path7.dirname(targetPath);
|
|
1659
2125
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
1660
|
-
(
|
|
2126
|
+
(path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
|
|
1661
2127
|
`${dirname3}/${filename}`
|
|
1662
2128
|
);
|
|
1663
2129
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
@@ -1665,7 +2131,7 @@ var Executor = class _Executor {
|
|
|
1665
2131
|
} else if (targetPath.endsWith(".template")) {
|
|
1666
2132
|
const content = await fsPromise.readFile(templatePath, "utf8");
|
|
1667
2133
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
1668
|
-
(
|
|
2134
|
+
(path10, [key, value]) => path10.replace(new RegExp(`__${key}__`, "g"), value),
|
|
1669
2135
|
targetPath.slice(0, -9)
|
|
1670
2136
|
);
|
|
1671
2137
|
const convertedContent = Object.entries(dict).reduce(
|
|
@@ -1680,16 +2146,16 @@ var Executor = class _Executor {
|
|
|
1680
2146
|
async _applyTemplate({
|
|
1681
2147
|
basePath: basePath2,
|
|
1682
2148
|
template,
|
|
1683
|
-
|
|
2149
|
+
scanInfo,
|
|
1684
2150
|
dict = {},
|
|
1685
2151
|
overwrite = true
|
|
1686
2152
|
}) {
|
|
1687
2153
|
const templatePath = `${getDirname(import.meta.url)}/src/templates${template ? `/${template}` : ""}`;
|
|
1688
2154
|
const prefixTemplatePath = templatePath.endsWith(".tsx") ? templatePath : templatePath.replace(".ts", ".js");
|
|
1689
2155
|
if (fs8.statSync(prefixTemplatePath).isFile()) {
|
|
1690
|
-
const filename =
|
|
2156
|
+
const filename = path7.basename(prefixTemplatePath);
|
|
1691
2157
|
const fileContent = await this.#applyTemplateFile(
|
|
1692
|
-
{ templatePath: prefixTemplatePath, targetPath:
|
|
2158
|
+
{ templatePath: prefixTemplatePath, targetPath: path7.join(basePath2, filename), scanInfo, overwrite },
|
|
1693
2159
|
dict
|
|
1694
2160
|
);
|
|
1695
2161
|
return fileContent ? [fileContent] : [];
|
|
@@ -1697,18 +2163,18 @@ var Executor = class _Executor {
|
|
|
1697
2163
|
const subdirs = await this.readdir(templatePath);
|
|
1698
2164
|
const fileContents = (await Promise.all(
|
|
1699
2165
|
subdirs.map(async (subdir) => {
|
|
1700
|
-
const subpath =
|
|
2166
|
+
const subpath = path7.join(templatePath, subdir);
|
|
1701
2167
|
if (fs8.statSync(subpath).isFile()) {
|
|
1702
2168
|
const fileContent = await this.#applyTemplateFile(
|
|
1703
|
-
{ templatePath: subpath, targetPath:
|
|
2169
|
+
{ templatePath: subpath, targetPath: path7.join(basePath2, subdir), scanInfo, overwrite },
|
|
1704
2170
|
dict
|
|
1705
2171
|
);
|
|
1706
2172
|
return fileContent ? [fileContent] : [];
|
|
1707
2173
|
} else
|
|
1708
2174
|
return await this._applyTemplate({
|
|
1709
|
-
basePath:
|
|
1710
|
-
template:
|
|
1711
|
-
|
|
2175
|
+
basePath: path7.join(basePath2, subdir),
|
|
2176
|
+
template: path7.join(template, subdir),
|
|
2177
|
+
scanInfo,
|
|
1712
2178
|
dict,
|
|
1713
2179
|
overwrite
|
|
1714
2180
|
});
|
|
@@ -1731,9 +2197,9 @@ var Executor = class _Executor {
|
|
|
1731
2197
|
return this.typeChecker;
|
|
1732
2198
|
}
|
|
1733
2199
|
typeCheck(filePath) {
|
|
1734
|
-
const
|
|
2200
|
+
const path10 = this.getPath(filePath);
|
|
1735
2201
|
const typeChecker = this.getTypeChecker();
|
|
1736
|
-
const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(
|
|
2202
|
+
const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path10);
|
|
1737
2203
|
const message = typeChecker.formatDiagnostics(fileDiagnostics);
|
|
1738
2204
|
return { fileDiagnostics, fileErrors, fileWarnings, message };
|
|
1739
2205
|
}
|
|
@@ -1742,9 +2208,9 @@ var Executor = class _Executor {
|
|
|
1742
2208
|
return this.linter;
|
|
1743
2209
|
}
|
|
1744
2210
|
async lint(filePath, { fix = false, dryRun = false } = {}) {
|
|
1745
|
-
const
|
|
2211
|
+
const path10 = this.getPath(filePath);
|
|
1746
2212
|
const linter = this.getLinter();
|
|
1747
|
-
const { results, errors, warnings } = await linter.lint(
|
|
2213
|
+
const { results, errors, warnings } = await linter.lint(path10, { fix, dryRun });
|
|
1748
2214
|
const message = linter.formatLintResults(results);
|
|
1749
2215
|
return { results, message, errors, warnings };
|
|
1750
2216
|
}
|
|
@@ -1758,9 +2224,12 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1758
2224
|
this.workspaceRoot = workspaceRoot;
|
|
1759
2225
|
this.repoName = repoName;
|
|
1760
2226
|
}
|
|
1761
|
-
static
|
|
1762
|
-
|
|
1763
|
-
|
|
2227
|
+
static #execs = /* @__PURE__ */ new Map();
|
|
2228
|
+
static fromRoot({
|
|
2229
|
+
workspaceRoot = process.cwd(),
|
|
2230
|
+
repoName = path7.basename(process.cwd())
|
|
2231
|
+
} = {}) {
|
|
2232
|
+
return this.#execs.get(repoName) ?? new _WorkspaceExecutor({ workspaceRoot, repoName });
|
|
1764
2233
|
}
|
|
1765
2234
|
getBaseDevEnv() {
|
|
1766
2235
|
const envFile = dotenv.parse(this.readFile(".env"));
|
|
@@ -1778,36 +2247,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1778
2247
|
return { ...appName ? { name: appName } : {}, repoName, serveDomain, env, portOffset };
|
|
1779
2248
|
}
|
|
1780
2249
|
async scan() {
|
|
1781
|
-
|
|
1782
|
-
const [appScanResults, libScanResults, pkgScanResults] = await Promise.all([
|
|
1783
|
-
Promise.all(
|
|
1784
|
-
appNames.map(async (appName) => {
|
|
1785
|
-
const app = AppExecutor.from(this, appName);
|
|
1786
|
-
const akanConfig = await app.getConfig("scan");
|
|
1787
|
-
return await app.scan({ akanConfig });
|
|
1788
|
-
})
|
|
1789
|
-
),
|
|
1790
|
-
Promise.all(
|
|
1791
|
-
libNames.map(async (libName) => {
|
|
1792
|
-
const lib = LibExecutor.from(this, libName);
|
|
1793
|
-
const akanConfig = await lib.getConfig("scan");
|
|
1794
|
-
return await lib.scan({ akanConfig });
|
|
1795
|
-
})
|
|
1796
|
-
),
|
|
1797
|
-
Promise.all(
|
|
1798
|
-
pkgNames.map(async (pkgName) => {
|
|
1799
|
-
return await PkgExecutor.from(this, pkgName).scan();
|
|
1800
|
-
})
|
|
1801
|
-
)
|
|
1802
|
-
]);
|
|
1803
|
-
return {
|
|
1804
|
-
appNames,
|
|
1805
|
-
libNames,
|
|
1806
|
-
pkgNames,
|
|
1807
|
-
apps: Object.fromEntries(appScanResults.map((app) => [app.name, app])),
|
|
1808
|
-
libs: Object.fromEntries(libScanResults.map((lib) => [lib.name, lib])),
|
|
1809
|
-
pkgs: Object.fromEntries(pkgScanResults.map((pkg) => [pkg.name, pkg]))
|
|
1810
|
-
};
|
|
2250
|
+
return await WorkspaceInfo.fromExecutor(this);
|
|
1811
2251
|
}
|
|
1812
2252
|
async getApps() {
|
|
1813
2253
|
if (!fs8.existsSync(`${this.workspaceRoot}/apps`))
|
|
@@ -1869,7 +2309,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1869
2309
|
dirs.map(async (dir) => {
|
|
1870
2310
|
if (dir.includes("_") || AVOID_DIRS.includes(dir))
|
|
1871
2311
|
return;
|
|
1872
|
-
const dirPath =
|
|
2312
|
+
const dirPath = path7.join(dirname3, dir);
|
|
1873
2313
|
if (fs8.lstatSync(dirPath).isDirectory()) {
|
|
1874
2314
|
results.push(`${prefix}${dir}`);
|
|
1875
2315
|
if (maxDepth > 0)
|
|
@@ -1896,9 +2336,9 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1896
2336
|
dirs.map(async (dir) => {
|
|
1897
2337
|
if (AVOID_DIRS.includes(dir))
|
|
1898
2338
|
return;
|
|
1899
|
-
const dirPath =
|
|
2339
|
+
const dirPath = path7.join(dirname3, dir);
|
|
1900
2340
|
if (fs8.lstatSync(dirPath).isDirectory()) {
|
|
1901
|
-
const hasTargetFile = fs8.existsSync(
|
|
2341
|
+
const hasTargetFile = fs8.existsSync(path7.join(dirPath, targetFilename));
|
|
1902
2342
|
if (hasTargetFile)
|
|
1903
2343
|
results.push(`${prefix}${dir}`);
|
|
1904
2344
|
if (maxDepth > 0)
|
|
@@ -1955,163 +2395,106 @@ var SysExecutor = class extends Executor {
|
|
|
1955
2395
|
this.type = type;
|
|
1956
2396
|
this.emoji = execEmoji[type];
|
|
1957
2397
|
}
|
|
1958
|
-
|
|
1959
|
-
|
|
2398
|
+
#akanConfig = null;
|
|
2399
|
+
async getConfig({ refresh } = {}) {
|
|
2400
|
+
if (this.#akanConfig && !refresh)
|
|
2401
|
+
return this.#akanConfig;
|
|
2402
|
+
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 });
|
|
2403
|
+
return this.#akanConfig;
|
|
1960
2404
|
}
|
|
1961
2405
|
async getModules() {
|
|
1962
|
-
const
|
|
1963
|
-
return await this.workspace.getDirInModule(
|
|
2406
|
+
const path10 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
|
|
2407
|
+
return await this.workspace.getDirInModule(path10, this.name);
|
|
1964
2408
|
}
|
|
2409
|
+
#scanInfo = null;
|
|
1965
2410
|
async scan({
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
const
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
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
|
-
files.services.services.push(name);
|
|
2027
|
-
else if (filename.endsWith(".signal.ts"))
|
|
2028
|
-
files.signal.services.push(name);
|
|
2029
|
-
else if (filename.endsWith(".store.ts"))
|
|
2030
|
-
files.store.services.push(name);
|
|
2031
|
-
else if (filename === "index.tsx")
|
|
2032
|
-
files.components.services.push(name);
|
|
2033
|
-
});
|
|
2034
|
-
})
|
|
2035
|
-
);
|
|
2036
|
-
const scalarDirs = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_"));
|
|
2037
|
-
await Promise.all(
|
|
2038
|
-
scalarDirs.map(async (name) => {
|
|
2039
|
-
const filenames = await this.readdir(path6.join("lib/__scalar", name));
|
|
2040
|
-
filenames.forEach((filename) => {
|
|
2041
|
-
if (filename.endsWith(".constant.ts"))
|
|
2042
|
-
files.constants.scalars.push(name);
|
|
2043
|
-
else if (filename.endsWith(".dictionary.ts"))
|
|
2044
|
-
files.dictionary.scalars.push(name);
|
|
2045
|
-
else if (filename.endsWith(".document.ts"))
|
|
2046
|
-
files.documents.scalars.push(name);
|
|
2047
|
-
else if (filename.endsWith(".service.ts"))
|
|
2048
|
-
files.services.scalars.push(name);
|
|
2049
|
-
else if (filename.endsWith(".signal.ts"))
|
|
2050
|
-
files.signal.scalars.push(name);
|
|
2051
|
-
else if (filename.endsWith(".store.ts"))
|
|
2052
|
-
files.store.scalars.push(name);
|
|
2053
|
-
else if (filename === "index.ts")
|
|
2054
|
-
files.components.scalars.push(name);
|
|
2055
|
-
});
|
|
2056
|
-
})
|
|
2057
|
-
);
|
|
2058
|
-
const missingLibDeps = [];
|
|
2059
|
-
libDeps.forEach((libName) => {
|
|
2060
|
-
if (!akanConfig.libs.includes(libName))
|
|
2061
|
-
missingLibDeps.push(libName);
|
|
2062
|
-
});
|
|
2063
|
-
if (missingLibDeps.length)
|
|
2064
|
-
throw new Error(
|
|
2065
|
-
`Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
|
|
2066
|
-
);
|
|
2067
|
-
for (const libName of akanConfig.libs) {
|
|
2068
|
-
if (libScanResults[libName])
|
|
2069
|
-
continue;
|
|
2070
|
-
const lib = new LibExecutor({ workspace: this.workspace, name: libName });
|
|
2071
|
-
const akanConfig2 = await lib.getConfig();
|
|
2072
|
-
libScanResults[libName] = await lib.scan({ akanConfig: akanConfig2 }, libScanResults);
|
|
2411
|
+
refresh,
|
|
2412
|
+
write = true,
|
|
2413
|
+
writeLib = true
|
|
2414
|
+
} = {}) {
|
|
2415
|
+
if (this.#scanInfo && !refresh)
|
|
2416
|
+
return this.#scanInfo;
|
|
2417
|
+
const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this, { refresh }) : await LibInfo.fromExecutor(this, { refresh });
|
|
2418
|
+
if (write) {
|
|
2419
|
+
await Promise.all([
|
|
2420
|
+
this._applyTemplate({ basePath: "lib", template: "lib", scanInfo }),
|
|
2421
|
+
this._applyTemplate({ basePath: ".", template: "server.ts", scanInfo }),
|
|
2422
|
+
this._applyTemplate({ basePath: ".", template: "client.ts", scanInfo }),
|
|
2423
|
+
this.type === "lib" ? this._applyTemplate({ basePath: ".", template: "index.ts", scanInfo }) : null,
|
|
2424
|
+
...scanInfo.getDatabaseModules().map(
|
|
2425
|
+
(model) => this._applyTemplate({
|
|
2426
|
+
basePath: `lib/${model}`,
|
|
2427
|
+
template: "moduleRoot",
|
|
2428
|
+
scanInfo,
|
|
2429
|
+
dict: { model, Model: capitalize(model) }
|
|
2430
|
+
})
|
|
2431
|
+
),
|
|
2432
|
+
...scanInfo.getServiceModules().map(
|
|
2433
|
+
(model) => this._applyTemplate({
|
|
2434
|
+
basePath: `lib/_${model}`,
|
|
2435
|
+
template: "moduleRoot",
|
|
2436
|
+
scanInfo,
|
|
2437
|
+
dict: { model, Model: capitalize(model) }
|
|
2438
|
+
})
|
|
2439
|
+
)
|
|
2440
|
+
]);
|
|
2441
|
+
this.writeJson(`akan.${this.type}.json`, scanInfo.getScanResult());
|
|
2442
|
+
if (this.type === "lib")
|
|
2443
|
+
this.#updateDependencies(scanInfo);
|
|
2444
|
+
if (writeLib) {
|
|
2445
|
+
const libInfos = [...scanInfo.getLibInfos().values()];
|
|
2446
|
+
await Promise.all(
|
|
2447
|
+
libInfos.map((libInfo) => [
|
|
2448
|
+
libInfo.exec._applyTemplate({ basePath: "lib", template: "lib", scanInfo: libInfo }),
|
|
2449
|
+
libInfo.exec._applyTemplate({ basePath: ".", template: "server.ts", scanInfo: libInfo }),
|
|
2450
|
+
libInfo.exec._applyTemplate({ basePath: ".", template: "client.ts", scanInfo: libInfo }),
|
|
2451
|
+
libInfo.exec._applyTemplate({ basePath: ".", template: "index.ts", scanInfo: libInfo }),
|
|
2452
|
+
...libInfo.getDatabaseModules().map(
|
|
2453
|
+
(model) => libInfo.exec._applyTemplate({
|
|
2454
|
+
basePath: `lib/${model}`,
|
|
2455
|
+
template: "moduleRoot",
|
|
2456
|
+
scanInfo: libInfo,
|
|
2457
|
+
dict: { model, Model: capitalize(model) }
|
|
2458
|
+
})
|
|
2459
|
+
),
|
|
2460
|
+
...libInfo.getServiceModules().map(
|
|
2461
|
+
(model) => libInfo.exec._applyTemplate({
|
|
2462
|
+
basePath: `lib/_${model}`,
|
|
2463
|
+
template: "moduleRoot",
|
|
2464
|
+
scanInfo: libInfo,
|
|
2465
|
+
dict: { model, Model: capitalize(model) }
|
|
2466
|
+
})
|
|
2467
|
+
)
|
|
2468
|
+
]).flat()
|
|
2469
|
+
);
|
|
2470
|
+
}
|
|
2073
2471
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
libDeps,
|
|
2082
|
-
pkgDeps,
|
|
2083
|
-
dependencies: [...npmDepSet].filter((dep) => !dep.startsWith("@akanjs")),
|
|
2084
|
-
libs: Object.fromEntries(akanConfig.libs.map((libName) => [libName, libScanResults[libName]]))
|
|
2085
|
-
};
|
|
2086
|
-
await this._applyTemplate({ basePath: "lib", template: "lib", scanResult });
|
|
2087
|
-
await this._applyTemplate({ basePath: ".", template: "server.ts", scanResult });
|
|
2088
|
-
await this._applyTemplate({ basePath: ".", template: "client.ts", scanResult });
|
|
2089
|
-
if (this.type === "lib")
|
|
2090
|
-
await this._applyTemplate({ basePath: ".", template: "index.ts", scanResult });
|
|
2091
|
-
this.writeJson(`akan.${this.type}.json`, scanResult);
|
|
2092
|
-
if (this.type === "app")
|
|
2093
|
-
return scanResult;
|
|
2094
|
-
const libPackageJson = this.readJson("package.json");
|
|
2472
|
+
this.#scanInfo = scanInfo;
|
|
2473
|
+
return scanInfo;
|
|
2474
|
+
}
|
|
2475
|
+
#updateDependencies(scanInfo) {
|
|
2476
|
+
const rootPackageJson = this.workspace.getPackageJson();
|
|
2477
|
+
const libPackageJson = this.getPackageJson();
|
|
2478
|
+
const dependencies = scanInfo.getScanResult().dependencies;
|
|
2095
2479
|
const libPkgJsonWithDeps = {
|
|
2096
2480
|
...libPackageJson,
|
|
2097
2481
|
dependencies: {
|
|
2098
2482
|
...libPackageJson.dependencies,
|
|
2099
2483
|
...Object.fromEntries(
|
|
2100
|
-
|
|
2484
|
+
dependencies.filter((dep) => rootPackageJson.dependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.dependencies?.[dep]])
|
|
2101
2485
|
)
|
|
2102
2486
|
},
|
|
2103
2487
|
devDependencies: {
|
|
2104
2488
|
...libPackageJson.devDependencies,
|
|
2105
2489
|
...Object.fromEntries(
|
|
2106
|
-
|
|
2490
|
+
dependencies.filter((dep) => rootPackageJson.devDependencies?.[dep]).sort().map((dep) => [dep, rootPackageJson.devDependencies?.[dep]])
|
|
2107
2491
|
)
|
|
2108
2492
|
}
|
|
2109
2493
|
};
|
|
2110
|
-
this.
|
|
2111
|
-
return scanResult;
|
|
2494
|
+
this.setPackageJson(libPkgJsonWithDeps);
|
|
2112
2495
|
}
|
|
2113
2496
|
getLocalFile(targetPath) {
|
|
2114
|
-
const filePath =
|
|
2497
|
+
const filePath = path7.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
|
|
2115
2498
|
const content = this.workspace.readFile(filePath);
|
|
2116
2499
|
return { filePath, content };
|
|
2117
2500
|
}
|
|
@@ -2191,9 +2574,9 @@ var SysExecutor = class extends Executor {
|
|
|
2191
2574
|
)
|
|
2192
2575
|
};
|
|
2193
2576
|
const akanConfig = await this.getConfig();
|
|
2194
|
-
const
|
|
2195
|
-
const fileContents = await this._applyTemplate({ ...options,
|
|
2196
|
-
await this.scan(
|
|
2577
|
+
const scanInfo = await this.scan();
|
|
2578
|
+
const fileContents = await this._applyTemplate({ ...options, scanInfo, dict });
|
|
2579
|
+
await this.scan();
|
|
2197
2580
|
return fileContents;
|
|
2198
2581
|
}
|
|
2199
2582
|
setTsPaths() {
|
|
@@ -2208,21 +2591,29 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
|
2208
2591
|
super({ workspace, name, type: "app" });
|
|
2209
2592
|
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/apps/${name}`);
|
|
2210
2593
|
}
|
|
2594
|
+
static #execs = /* @__PURE__ */ new Map();
|
|
2211
2595
|
static from(executor, name) {
|
|
2212
|
-
|
|
2596
|
+
const exec2 = this.#execs.get(name);
|
|
2597
|
+
if (exec2)
|
|
2598
|
+
return exec2;
|
|
2599
|
+
else if (executor instanceof WorkspaceExecutor)
|
|
2213
2600
|
return new _AppExecutor({ workspace: executor, name });
|
|
2214
|
-
|
|
2601
|
+
else
|
|
2602
|
+
return new _AppExecutor({ workspace: executor.workspace, name });
|
|
2215
2603
|
}
|
|
2216
2604
|
getEnv() {
|
|
2217
2605
|
return this.workspace.getBaseDevEnv().env;
|
|
2218
2606
|
}
|
|
2219
|
-
|
|
2220
|
-
|
|
2607
|
+
#akanConfig = null;
|
|
2608
|
+
async getConfig({ refresh } = {}) {
|
|
2609
|
+
if (this.#akanConfig && !refresh)
|
|
2610
|
+
return this.#akanConfig;
|
|
2611
|
+
this.#akanConfig = await getAppConfig(this.cwdPath, {
|
|
2221
2612
|
...this.workspace.getBaseDevEnv(),
|
|
2222
2613
|
type: "app",
|
|
2223
|
-
name: this.name
|
|
2224
|
-
command
|
|
2614
|
+
name: this.name
|
|
2225
2615
|
});
|
|
2616
|
+
return this.#akanConfig;
|
|
2226
2617
|
}
|
|
2227
2618
|
async syncAssets(libDeps) {
|
|
2228
2619
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
@@ -2259,18 +2650,26 @@ var LibExecutor = class _LibExecutor extends SysExecutor {
|
|
|
2259
2650
|
super({ workspace, name, type: "lib" });
|
|
2260
2651
|
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/libs/${name}`);
|
|
2261
2652
|
}
|
|
2653
|
+
static #execs = /* @__PURE__ */ new Map();
|
|
2262
2654
|
static from(executor, name) {
|
|
2263
|
-
|
|
2655
|
+
const exec2 = this.#execs.get(name);
|
|
2656
|
+
if (exec2)
|
|
2657
|
+
return exec2;
|
|
2658
|
+
else if (executor instanceof WorkspaceExecutor)
|
|
2264
2659
|
return new _LibExecutor({ workspace: executor, name });
|
|
2265
|
-
|
|
2660
|
+
else
|
|
2661
|
+
return new _LibExecutor({ workspace: executor.workspace, name });
|
|
2266
2662
|
}
|
|
2267
|
-
|
|
2268
|
-
|
|
2663
|
+
#akanConfig = null;
|
|
2664
|
+
async getConfig({ refresh } = {}) {
|
|
2665
|
+
if (this.#akanConfig && !refresh)
|
|
2666
|
+
return this.#akanConfig;
|
|
2667
|
+
this.#akanConfig = await getLibConfig(this.cwdPath, {
|
|
2269
2668
|
...this.workspace.getBaseDevEnv(),
|
|
2270
2669
|
type: "lib",
|
|
2271
|
-
name: this.name
|
|
2272
|
-
command
|
|
2670
|
+
name: this.name
|
|
2273
2671
|
});
|
|
2672
|
+
return this.#akanConfig;
|
|
2274
2673
|
}
|
|
2275
2674
|
};
|
|
2276
2675
|
var PkgExecutor = class _PkgExecutor extends Executor {
|
|
@@ -2289,27 +2688,13 @@ var PkgExecutor = class _PkgExecutor extends Executor {
|
|
|
2289
2688
|
return new _PkgExecutor({ workspace: executor, name });
|
|
2290
2689
|
return new _PkgExecutor({ workspace: executor.workspace, name });
|
|
2291
2690
|
}
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
const
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
const pkgPathSet = new Set(
|
|
2300
|
-
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
|
|
2301
|
-
);
|
|
2302
|
-
const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
|
|
2303
|
-
const pkgDeps = [...pkgPathDepSet].map((path9) => {
|
|
2304
|
-
const pathSplitLength = path9.split("/").length;
|
|
2305
|
-
return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
2306
|
-
}).filter((pkg) => pkg !== this.name);
|
|
2307
|
-
const pkgScanResult = {
|
|
2308
|
-
name: this.name,
|
|
2309
|
-
pkgDeps,
|
|
2310
|
-
dependencies: [...npmDepSet]
|
|
2311
|
-
};
|
|
2312
|
-
return pkgScanResult;
|
|
2691
|
+
#scanInfo = null;
|
|
2692
|
+
async scan({ refresh } = {}) {
|
|
2693
|
+
if (this.#scanInfo && !refresh)
|
|
2694
|
+
return this.#scanInfo;
|
|
2695
|
+
const scanInfo = await PkgInfo.fromExecutor(this, { refresh });
|
|
2696
|
+
this.#scanInfo = scanInfo;
|
|
2697
|
+
return scanInfo;
|
|
2313
2698
|
}
|
|
2314
2699
|
};
|
|
2315
2700
|
var ModuleExecutor = class _ModuleExecutor extends Executor {
|
|
@@ -2613,7 +2998,7 @@ var extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =>
|
|
|
2613
2998
|
...pacakgeJson.devDependencies ?? {}
|
|
2614
2999
|
};
|
|
2615
3000
|
const requireRegex = /(?:require\s*\(|import\s*(?:[\w\s{},*]*\s+from\s*)?|import\s*\()\s*['"`]([^'"`]+)['"`]/g;
|
|
2616
|
-
for (const { text } of filepaths.filter(({ path:
|
|
3001
|
+
for (const { text } of filepaths.filter(({ path: path10 }) => path10.endsWith(".js") || path10.endsWith(".ts"))) {
|
|
2617
3002
|
let requireMatch;
|
|
2618
3003
|
while ((requireMatch = requireRegex.exec(text)) !== null) {
|
|
2619
3004
|
const moduleName = requireMatch[1];
|
|
@@ -2895,8 +3280,18 @@ var runCommands = async (...commands) => {
|
|
|
2895
3280
|
});
|
|
2896
3281
|
const __dirname = getDirname(import.meta.url);
|
|
2897
3282
|
const hasPackageJson = fs11.existsSync(`${__dirname}/../package.json`);
|
|
2898
|
-
|
|
2899
|
-
program.version(
|
|
3283
|
+
process.env.AKAN_VERSION = hasPackageJson ? JSON.parse(fs11.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
|
|
3284
|
+
program.version(process.env.AKAN_VERSION).description("Akan CLI");
|
|
3285
|
+
const akanBasePackageJson = fs11.existsSync("./node_modules/@akanjs/base/package.json") ? JSON.parse(fs11.readFileSync("./node_modules/@akanjs/base/package.json", "utf8")) : null;
|
|
3286
|
+
if (akanBasePackageJson && akanBasePackageJson.version !== process.env.AKAN_VERSION) {
|
|
3287
|
+
Logger.rawLog(
|
|
3288
|
+
chalk4.yellow(
|
|
3289
|
+
`
|
|
3290
|
+
Akan CLI version is mismatch with installed package. ${process.env.AKAN_VERSION} (global) vs ${akanBasePackageJson.version} (base)
|
|
3291
|
+
It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`
|
|
3292
|
+
)
|
|
3293
|
+
);
|
|
3294
|
+
}
|
|
2900
3295
|
for (const command of commands) {
|
|
2901
3296
|
const targetMetas = getTargetMetas(command);
|
|
2902
3297
|
for (const targetMeta of targetMetas) {
|
|
@@ -2959,7 +3354,8 @@ var runCommands = async (...commands) => {
|
|
|
2959
3354
|
Logger.rawLog();
|
|
2960
3355
|
} catch (e) {
|
|
2961
3356
|
const errMsg = e instanceof Error ? e.message : typeof e === "string" ? e : JSON.stringify(e);
|
|
2962
|
-
Logger.
|
|
3357
|
+
Logger.rawLog(`
|
|
3358
|
+
${chalk4.red(errMsg)}`);
|
|
2963
3359
|
throw e;
|
|
2964
3360
|
}
|
|
2965
3361
|
});
|
|
@@ -3319,8 +3715,8 @@ var Builder = class {
|
|
|
3319
3715
|
}
|
|
3320
3716
|
};
|
|
3321
3717
|
buildResult.outputFiles.map((file) => this.#distExecutor.writeFile(file.path, file.text));
|
|
3322
|
-
this.#distExecutor.
|
|
3323
|
-
this.#executor.
|
|
3718
|
+
this.#distExecutor.setPackageJson(pkgPackageJson);
|
|
3719
|
+
this.#executor.setPackageJson(pkgPackageJson);
|
|
3324
3720
|
}
|
|
3325
3721
|
};
|
|
3326
3722
|
|
|
@@ -3414,8 +3810,8 @@ var LibraryRunner = class {
|
|
|
3414
3810
|
return LibExecutor.from(workspace, libName);
|
|
3415
3811
|
}
|
|
3416
3812
|
async mergeLibraryDependencies(lib) {
|
|
3417
|
-
const libPackageJson = lib.
|
|
3418
|
-
const rootPackageJson = lib.workspace.
|
|
3813
|
+
const libPackageJson = lib.getPackageJson();
|
|
3814
|
+
const rootPackageJson = lib.workspace.getPackageJson();
|
|
3419
3815
|
const dependencies = {};
|
|
3420
3816
|
const devDependencies = {};
|
|
3421
3817
|
const libDependencies = { ...libPackageJson.dependencies, ...libPackageJson.devDependencies };
|
|
@@ -3435,7 +3831,7 @@ var LibraryRunner = class {
|
|
|
3435
3831
|
devDependencies[dep] = allDependencies[dep];
|
|
3436
3832
|
});
|
|
3437
3833
|
const newRootPackageJson = { ...rootPackageJson, dependencies, devDependencies };
|
|
3438
|
-
lib.workspace.
|
|
3834
|
+
lib.workspace.setPackageJson(newRootPackageJson);
|
|
3439
3835
|
await lib.workspace.spawn("pnpm", ["install", "--reporter=silent"]);
|
|
3440
3836
|
await lib.workspace.commit(`Merge ${lib.name} library dependencies`);
|
|
3441
3837
|
}
|
|
@@ -3481,10 +3877,9 @@ var LibraryScript = class {
|
|
|
3481
3877
|
#runner = new LibraryRunner();
|
|
3482
3878
|
async syncLibrary(lib) {
|
|
3483
3879
|
const syncSpinner = lib.spinning("Syncing library...");
|
|
3484
|
-
const
|
|
3485
|
-
const scanResult = await lib.scan({ akanConfig });
|
|
3880
|
+
const scanInfo = await lib.scan();
|
|
3486
3881
|
syncSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) is synced`);
|
|
3487
|
-
return
|
|
3882
|
+
return scanInfo;
|
|
3488
3883
|
}
|
|
3489
3884
|
async createLibrary(libName, workspace) {
|
|
3490
3885
|
const spinner = workspace.spinning(`Creating ${libName} library`);
|
|
@@ -3546,6 +3941,7 @@ var MultiScrollList = ({ logList, maxLength = 100 }) => {
|
|
|
3546
3941
|
const [boxHeight, setBoxHeight] = useState2(
|
|
3547
3942
|
height - HEADER_HEIGHT - OUTER_BORDER_HEIGHT - FOOTER_HEIGHT - BORDER_HEIGHT
|
|
3548
3943
|
);
|
|
3944
|
+
const [boxWidth, setBoxWidth] = useState2(width - 28);
|
|
3549
3945
|
const getLimitedLogs = (logs) => {
|
|
3550
3946
|
return logs.length > maxLength ? logs.slice(logs.length - maxLength) : logs;
|
|
3551
3947
|
};
|
|
@@ -3597,6 +3993,15 @@ var MultiScrollList = ({ logList, maxLength = 100 }) => {
|
|
|
3597
3993
|
useEffect2(() => {
|
|
3598
3994
|
const getLogsToRender = (logs, index) => {
|
|
3599
3995
|
const limitedLogs = getLimitedLogs(logs);
|
|
3996
|
+
const logWidth = limitedLogs.reduce((acc, log) => acc + log.content.length, 0);
|
|
3997
|
+
if (logWidth > boxWidth) {
|
|
3998
|
+
return limitedLogs.map((log) => {
|
|
3999
|
+
return {
|
|
4000
|
+
type: log.type,
|
|
4001
|
+
content: log.content.slice(0, boxWidth)
|
|
4002
|
+
};
|
|
4003
|
+
});
|
|
4004
|
+
}
|
|
3600
4005
|
if (scrollPos > 0 && tabIndex === index) {
|
|
3601
4006
|
return limitedLogs.slice(limitedLogs.length - boxHeight - scrollPos, limitedLogs.length - scrollPos);
|
|
3602
4007
|
} else if (limitedLogs.length > boxHeight) {
|
|
@@ -3637,9 +4042,9 @@ var MultiScrollList = ({ logList, maxLength = 100 }) => {
|
|
|
3637
4042
|
height: "100%"
|
|
3638
4043
|
},
|
|
3639
4044
|
scrollPos > 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, focusLog.slice(0, focusLog.length - 1).map((log, index) => {
|
|
3640
|
-
return /* @__PURE__ */ React.createElement(Text, { key: index }, log);
|
|
4045
|
+
return /* @__PURE__ */ React.createElement(Text, { color: log.type === "error" ? "red" : "white", key: index }, log.content);
|
|
3641
4046
|
}), /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "Scrolling... +", scrollPos)) : focusLog.map((log, index) => {
|
|
3642
|
-
return /* @__PURE__ */ React.createElement(Text, { key: index }, log);
|
|
4047
|
+
return /* @__PURE__ */ React.createElement(Text, { color: log.type === "error" ? "red" : "white", key: index }, log.content);
|
|
3643
4048
|
})
|
|
3644
4049
|
))), /* @__PURE__ */ React.createElement(Box, { width: "100%", height: FOOTER_HEIGHT }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, /* @__PURE__ */ React.createElement(Text, null, "You can use the following shortcuts:"), /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "tab"), " to switch tab.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "up"), " and ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "down"), " to scroll.", " ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "shift"), " to scroll faster. (x10)", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "space"), " to scroll.", /* @__PURE__ */ React.createElement(Newline, null), "* ", /* @__PURE__ */ React.createElement(Text, { backgroundColor: "green" }, "escape"), " to stop scrolling.")));
|
|
3645
4050
|
};
|
|
@@ -3762,17 +4167,17 @@ var Start = ({ appName, bcp, fcp, csr, maxLength = 100 }) => {
|
|
|
3762
4167
|
logList: [
|
|
3763
4168
|
{
|
|
3764
4169
|
title: `${appName} frontend`,
|
|
3765
|
-
logs: frontendLogs
|
|
4170
|
+
logs: frontendLogs,
|
|
3766
4171
|
color: "#ff493b"
|
|
3767
4172
|
},
|
|
3768
4173
|
{
|
|
3769
4174
|
title: `${appName} backend`,
|
|
3770
|
-
logs: backendLogs
|
|
4175
|
+
logs: backendLogs,
|
|
3771
4176
|
color: "#e535ab"
|
|
3772
4177
|
},
|
|
3773
4178
|
{
|
|
3774
4179
|
title: `${appName} react`,
|
|
3775
|
-
logs: csrLogs
|
|
4180
|
+
logs: csrLogs,
|
|
3776
4181
|
color: "#7cc5d9"
|
|
3777
4182
|
}
|
|
3778
4183
|
],
|
|
@@ -3837,7 +4242,7 @@ import fsPromise3 from "fs/promises";
|
|
|
3837
4242
|
import yaml2 from "js-yaml";
|
|
3838
4243
|
import openBrowser from "open";
|
|
3839
4244
|
import ora3 from "ora";
|
|
3840
|
-
import
|
|
4245
|
+
import path8 from "path";
|
|
3841
4246
|
import * as vite from "vite";
|
|
3842
4247
|
import commonjs from "vite-plugin-commonjs";
|
|
3843
4248
|
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
@@ -3857,17 +4262,12 @@ var ApplicationRunner = class {
|
|
|
3857
4262
|
app.workspace.unsetTsPaths("app", app.name);
|
|
3858
4263
|
}
|
|
3859
4264
|
async getConfig(app) {
|
|
3860
|
-
return await
|
|
3861
|
-
...app.workspace.getBaseDevEnv(),
|
|
3862
|
-
type: "app",
|
|
3863
|
-
name: app.name,
|
|
3864
|
-
command: "start"
|
|
3865
|
-
});
|
|
4265
|
+
return await app.getConfig();
|
|
3866
4266
|
}
|
|
3867
|
-
async scanSync(app
|
|
3868
|
-
const
|
|
3869
|
-
await app.syncAssets(
|
|
3870
|
-
return
|
|
4267
|
+
async scanSync(app) {
|
|
4268
|
+
const scanInfo = await app.scan();
|
|
4269
|
+
await app.syncAssets(scanInfo.getScanResult().libDeps);
|
|
4270
|
+
return scanInfo;
|
|
3871
4271
|
}
|
|
3872
4272
|
async getScriptFilename(app) {
|
|
3873
4273
|
if (!app.exists("scripts")) {
|
|
@@ -3923,12 +4323,12 @@ var ApplicationRunner = class {
|
|
|
3923
4323
|
} else if (target === "csr")
|
|
3924
4324
|
await app.workspace.exec(`rm -rf ${app.workspace.workspaceRoot}/node_modules/.vite/${app.name}`);
|
|
3925
4325
|
else if (target === "backend")
|
|
3926
|
-
await app.cp("assets",
|
|
4326
|
+
await app.cp("assets", path8.join(app.dist.cwdPath, "backend", "assets"));
|
|
3927
4327
|
return { env: this.#getEnv(app, target, { AKAN_COMMAND_TYPE: type }) };
|
|
3928
4328
|
}
|
|
3929
4329
|
async buildBackend(app) {
|
|
3930
4330
|
await this.#prepareCommand(app, "start", "backend");
|
|
3931
|
-
const akanConfig = await app.getConfig(
|
|
4331
|
+
const akanConfig = await app.getConfig();
|
|
3932
4332
|
const buildResult = await esbuild2.build({
|
|
3933
4333
|
write: false,
|
|
3934
4334
|
entryPoints: [`${app.cwdPath}/main.ts`],
|
|
@@ -3939,7 +4339,7 @@ var ApplicationRunner = class {
|
|
|
3939
4339
|
outdir: `${app.dist.cwdPath}/backend`,
|
|
3940
4340
|
logLevel: "warning"
|
|
3941
4341
|
});
|
|
3942
|
-
const rootPackageJson = app.workspace.
|
|
4342
|
+
const rootPackageJson = app.workspace.getPackageJson();
|
|
3943
4343
|
const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson);
|
|
3944
4344
|
buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
|
|
3945
4345
|
const appPackageJson = {
|
|
@@ -3952,7 +4352,7 @@ var ApplicationRunner = class {
|
|
|
3952
4352
|
dependencies
|
|
3953
4353
|
};
|
|
3954
4354
|
app.dist.writeJson("backend/package.json", appPackageJson);
|
|
3955
|
-
app.dist.writeFile(
|
|
4355
|
+
app.dist.writeFile(path8.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.docker.content);
|
|
3956
4356
|
}
|
|
3957
4357
|
async startBackend(app, { open: open2 = false, onStart, withInk = false } = {}) {
|
|
3958
4358
|
const { env } = await this.#prepareCommand(app, "start", "backend");
|
|
@@ -3963,7 +4363,7 @@ var ApplicationRunner = class {
|
|
|
3963
4363
|
packages: "external",
|
|
3964
4364
|
platform: "node",
|
|
3965
4365
|
format: "cjs",
|
|
3966
|
-
outdir:
|
|
4366
|
+
outdir: path8.join(app.dist.cwdPath, "backend"),
|
|
3967
4367
|
logLevel: "warning"
|
|
3968
4368
|
});
|
|
3969
4369
|
await ctx.watch();
|
|
@@ -3979,7 +4379,7 @@ var ApplicationRunner = class {
|
|
|
3979
4379
|
}
|
|
3980
4380
|
async buildFrontend(app, { spawnOptions } = {}) {
|
|
3981
4381
|
const { env } = await this.#prepareCommand(app, "build", "frontend");
|
|
3982
|
-
const akanConfig = await app.getConfig(
|
|
4382
|
+
const akanConfig = await app.getConfig();
|
|
3983
4383
|
await app.spawn("npx", ["next", "build", "--no-lint"], { env, ...spawnOptions });
|
|
3984
4384
|
const buildResult = await esbuild2.build({
|
|
3985
4385
|
entryPoints: [`${app.cwdPath}/next.config.ts`],
|
|
@@ -3991,7 +4391,7 @@ var ApplicationRunner = class {
|
|
|
3991
4391
|
write: false,
|
|
3992
4392
|
logLevel: "warning"
|
|
3993
4393
|
});
|
|
3994
|
-
const rootPackageJson = app.workspace.
|
|
4394
|
+
const rootPackageJson = app.workspace.getPackageJson();
|
|
3995
4395
|
const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson, ["next", "react", "react-dom"]);
|
|
3996
4396
|
buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
|
|
3997
4397
|
const appPackageJson = {
|
|
@@ -4004,8 +4404,8 @@ var ApplicationRunner = class {
|
|
|
4004
4404
|
};
|
|
4005
4405
|
app.dist.writeJson("frontend/package.json", appPackageJson);
|
|
4006
4406
|
await Promise.all([
|
|
4007
|
-
app.cp(".next",
|
|
4008
|
-
app.cp("public",
|
|
4407
|
+
app.cp(".next", path8.join(app.dist.cwdPath, "frontend", ".next")),
|
|
4408
|
+
app.cp("public", path8.join(app.dist.cwdPath, "frontend", "public"))
|
|
4009
4409
|
]);
|
|
4010
4410
|
app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.docker.content);
|
|
4011
4411
|
}
|
|
@@ -4204,6 +4604,11 @@ var ApplicationRunner = class {
|
|
|
4204
4604
|
]);
|
|
4205
4605
|
}
|
|
4206
4606
|
async dbup(workspace) {
|
|
4607
|
+
try {
|
|
4608
|
+
await workspace.exec(`docker ps`);
|
|
4609
|
+
} catch (e) {
|
|
4610
|
+
throw new Error(`Docker daemon is not running. Please install docker or start docker daemon and try again.`);
|
|
4611
|
+
}
|
|
4207
4612
|
await workspace.applyTemplate({
|
|
4208
4613
|
basePath: "local",
|
|
4209
4614
|
template: "localDev",
|
|
@@ -4280,8 +4685,8 @@ var ApplicationRunner = class {
|
|
|
4280
4685
|
)
|
|
4281
4686
|
);
|
|
4282
4687
|
await Promise.all(
|
|
4283
|
-
[".next", "ios", "android", "public/libs"].map(async (
|
|
4284
|
-
const targetPath = `${sourceRoot}/apps/${app.name}/${
|
|
4688
|
+
[".next", "ios", "android", "public/libs"].map(async (path10) => {
|
|
4689
|
+
const targetPath = `${sourceRoot}/apps/${app.name}/${path10}`;
|
|
4285
4690
|
if (fs14.existsSync(targetPath))
|
|
4286
4691
|
await fsPromise3.rm(targetPath, { recursive: true, force: true });
|
|
4287
4692
|
})
|
|
@@ -4299,7 +4704,7 @@ var ApplicationRunner = class {
|
|
|
4299
4704
|
];
|
|
4300
4705
|
await Promise.all(
|
|
4301
4706
|
syncPaths.map(
|
|
4302
|
-
(
|
|
4707
|
+
(path10) => fsPromise3.cp(`${app.workspace.cwdPath}/${path10}`, `${sourceRoot}/${path10}`, { recursive: true })
|
|
4303
4708
|
)
|
|
4304
4709
|
);
|
|
4305
4710
|
const tsconfig = app.workspace.readJson("tsconfig.json");
|
|
@@ -4422,10 +4827,9 @@ var ApplicationScript = class {
|
|
|
4422
4827
|
}
|
|
4423
4828
|
async syncApplication(app) {
|
|
4424
4829
|
const spinner = app.spinning("Scanning application...");
|
|
4425
|
-
const
|
|
4426
|
-
const scanResult = await this.#runner.scanSync(app, akanConfig);
|
|
4830
|
+
const scanInfo = await this.#runner.scanSync(app);
|
|
4427
4831
|
spinner.succeed("Application scanned");
|
|
4428
|
-
return
|
|
4832
|
+
return scanInfo;
|
|
4429
4833
|
}
|
|
4430
4834
|
async script(app, filename) {
|
|
4431
4835
|
const scriptFilename = filename ?? await this.#runner.getScriptFilename(app);
|
|
@@ -4869,8 +5273,8 @@ var PackageRunner = class {
|
|
|
4869
5273
|
return scanResult;
|
|
4870
5274
|
}
|
|
4871
5275
|
async buildPackage(pkg) {
|
|
4872
|
-
const rootPackageJson = pkg.workspace.
|
|
4873
|
-
const pkgJson = pkg.
|
|
5276
|
+
const rootPackageJson = pkg.workspace.getPackageJson();
|
|
5277
|
+
const pkgJson = pkg.getPackageJson();
|
|
4874
5278
|
const builder = new Builder({ executor: pkg, distExecutor: pkg.dist, pkgJson, rootPackageJson });
|
|
4875
5279
|
if (pkg.name === "@akanjs/cli")
|
|
4876
5280
|
await builder.build({
|
|
@@ -5044,7 +5448,7 @@ ${chalk6.green("\u27A4")} Authentication Required`));
|
|
|
5044
5448
|
}
|
|
5045
5449
|
async #updateAkanPkgs(workspace) {
|
|
5046
5450
|
const latestPublishedVersionOfBase = await latestVersion("@akanjs/base");
|
|
5047
|
-
const rootPackageJson = workspace.
|
|
5451
|
+
const rootPackageJson = workspace.getPackageJson();
|
|
5048
5452
|
if (!rootPackageJson.dependencies)
|
|
5049
5453
|
throw new Error("No dependencies found in package.json");
|
|
5050
5454
|
Object.keys(rootPackageJson.dependencies).forEach((dependency) => {
|
|
@@ -5055,7 +5459,7 @@ ${chalk6.green("\u27A4")} Authentication Required`));
|
|
|
5055
5459
|
if (dependency.startsWith("@akanjs/"))
|
|
5056
5460
|
Object.assign(rootPackageJson.devDependencies ?? {}, { [dependency]: latestPublishedVersionOfBase });
|
|
5057
5461
|
});
|
|
5058
|
-
workspace.
|
|
5462
|
+
workspace.setPackageJson(rootPackageJson);
|
|
5059
5463
|
await workspace.spawn("pnpm", ["install"]);
|
|
5060
5464
|
}
|
|
5061
5465
|
};
|
|
@@ -5611,8 +6015,7 @@ var ModuleScript = class {
|
|
|
5611
6015
|
await this.#runner.createModuleTemplate(mod);
|
|
5612
6016
|
if (page && sys3.type === "app")
|
|
5613
6017
|
await this.pageScript.createCrudPage(mod, { app: sys3, basePath: null, single: false });
|
|
5614
|
-
|
|
5615
|
-
await sys3.scan({ akanConfig });
|
|
6018
|
+
await sys3.scan();
|
|
5616
6019
|
}
|
|
5617
6020
|
async createModule(sys3, name, description, schemaDescription) {
|
|
5618
6021
|
const session = new AiSession("createModule", { workspace: sys3.workspace, cacheKey: name });
|
|
@@ -5843,13 +6246,13 @@ PageCommand = __decorateClass([
|
|
|
5843
6246
|
|
|
5844
6247
|
// pkgs/@akanjs/cli/src/workspace/workspace.runner.ts
|
|
5845
6248
|
import latestVersion2 from "latest-version";
|
|
5846
|
-
import
|
|
6249
|
+
import path9 from "path";
|
|
5847
6250
|
import { v5 as uuid } from "uuid";
|
|
5848
6251
|
var WorkspaceRunner = class {
|
|
5849
6252
|
async createWorkspace(repoName, appName, dirname3 = ".") {
|
|
5850
6253
|
const cwdPath = process.cwd();
|
|
5851
|
-
const workspaceRoot =
|
|
5852
|
-
const workspace =
|
|
6254
|
+
const workspaceRoot = path9.join(cwdPath, dirname3, repoName);
|
|
6255
|
+
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
|
|
5853
6256
|
const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
|
|
5854
6257
|
await workspace.applyTemplate({
|
|
5855
6258
|
basePath: ".",
|
|
@@ -5857,7 +6260,7 @@ var WorkspaceRunner = class {
|
|
|
5857
6260
|
dict: { repoName, appName, serveDomain: "localhost" }
|
|
5858
6261
|
});
|
|
5859
6262
|
templateSpinner.succeed(`Workspace files created in ${dirname3}/${repoName}`);
|
|
5860
|
-
const rootPackageJson = workspace.
|
|
6263
|
+
const rootPackageJson = workspace.getPackageJson();
|
|
5861
6264
|
const dependencies = [
|
|
5862
6265
|
"@akanjs/base",
|
|
5863
6266
|
"@akanjs/cli",
|
|
@@ -5888,7 +6291,7 @@ var WorkspaceRunner = class {
|
|
|
5888
6291
|
...Object.fromEntries(devDependencies.map((dependency) => [dependency, latestPublishedVersionOfBase]))
|
|
5889
6292
|
}
|
|
5890
6293
|
};
|
|
5891
|
-
workspace.
|
|
6294
|
+
workspace.setPackageJson(packageJson);
|
|
5892
6295
|
const installSpinner = workspace.spinning("Installing dependencies with pnpm...");
|
|
5893
6296
|
await workspace.spawn("pnpm", ["install", "--reporter=silent"]);
|
|
5894
6297
|
installSpinner.succeed("Dependencies installed with pnpm");
|
|
@@ -6046,15 +6449,15 @@ var GuidelinePrompt = class extends Prompter {
|
|
|
6046
6449
|
async #getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
|
|
6047
6450
|
const matchingPaths = fsPromise5.glob(matchPattern, {
|
|
6048
6451
|
cwd: this.workspace.workspaceRoot,
|
|
6049
|
-
exclude: (
|
|
6452
|
+
exclude: (path10) => avoidDirs.some((dir) => path10.includes(dir))
|
|
6050
6453
|
});
|
|
6051
6454
|
const paths = [];
|
|
6052
|
-
for await (const
|
|
6053
|
-
const fileContent = fs16.readFileSync(
|
|
6455
|
+
for await (const path10 of matchingPaths) {
|
|
6456
|
+
const fileContent = fs16.readFileSync(path10, "utf-8");
|
|
6054
6457
|
const textFilter = filterText ? new RegExp(filterText) : null;
|
|
6055
6458
|
if (filterText && !textFilter?.test(fileContent))
|
|
6056
6459
|
continue;
|
|
6057
|
-
paths.push(
|
|
6460
|
+
paths.push(path10);
|
|
6058
6461
|
}
|
|
6059
6462
|
return paths;
|
|
6060
6463
|
}
|