akanjs 2.0.7 → 2.1.0-rc.1
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/README.ko.md +4 -4
- package/README.md +4 -4
- package/client/router.ts +10 -3
- package/document/documentSchema.ts +9 -1
- package/index.ts +187 -0
- package/package.json +6 -50
- package/server/akanApp.ts +2 -24
- package/server/akanAppHeaders.ts +30 -0
- package/server/di/predefinedAdaptor.ts +1 -1
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +8 -8
- package/types/document/documentSchema.d.ts +33 -0
- package/types/document/index.d.ts +1 -1
- package/types/document/schema.d.ts +1 -1
- package/types/document/types.d.ts +1 -1
- package/types/{devkit/akanConfig/types.d.ts → index.d.ts} +45 -54
- package/types/server/akanAppHeaders.d.ts +1 -0
- package/types/server/di/predefinedAdaptor.d.ts +1 -1
- package/types/store/baseSt.d.ts +2 -2
- package/ui/Link/SsrLink.tsx +2 -2
- package/webkit/useCodepush.tsx +1 -1
- package/cli/application/application.command.ts +0 -224
- package/cli/application/application.interface.tsx +0 -225
- package/cli/application/application.runner.ts +0 -355
- package/cli/application/application.script.ts +0 -244
- package/cli/build.ts +0 -27
- package/cli/cloud/cloud.command.ts +0 -48
- package/cli/cloud/cloud.runner.ts +0 -157
- package/cli/cloud/cloud.script.ts +0 -40
- package/cli/guideline/guideline.command.ts +0 -31
- package/cli/guideline/guideline.prompt.ts +0 -212
- package/cli/guideline/guideline.runner.ts +0 -53
- package/cli/guideline/guideline.script.ts +0 -33
- package/cli/guidelines/___library/sharedUiStructureDescription.en.md +0 -767
- package/cli/guidelines/___library/utilUiStructureDescription.en.md +0 -395
- package/cli/guidelines/___lint/lintRuleDescription.en.md +0 -64
- package/cli/guidelines/___module/moduleStructureDescription.en.md +0 -80
- package/cli/guidelines/componentRule/componentRule.generate.json +0 -131
- package/cli/guidelines/componentRule/componentRule.instruction.md +0 -637
- package/cli/guidelines/cssRule/cssRule.generate.json +0 -93
- package/cli/guidelines/cssRule/cssRule.instruction.md +0 -435
- package/cli/guidelines/databaseModule/databaseModule.generate.json +0 -51
- package/cli/guidelines/databaseModule/databaseModule.instruction.md +0 -612
- package/cli/guidelines/docPageRule/docPageRule.generate.json +0 -72
- package/cli/guidelines/docPageRule/docPageRule.instruction.md +0 -389
- package/cli/guidelines/enumConstant/enumConstant.generate.json +0 -24
- package/cli/guidelines/enumConstant/enumConstant.instruction.md +0 -232
- package/cli/guidelines/framework/framework.generate.json +0 -119
- package/cli/guidelines/framework/framework.instruction.md +0 -1110
- package/cli/guidelines/howToUseStore/howToUseStore.generate.json +0 -0
- package/cli/guidelines/modelConstant/modelConstant.generate.json +0 -128
- package/cli/guidelines/modelConstant/modelConstant.instruction.md +0 -506
- package/cli/guidelines/modelDictionary/modelDictionary.generate.json +0 -108
- package/cli/guidelines/modelDictionary/modelDictionary.instruction.md +0 -547
- package/cli/guidelines/modelDocument/modelDocument.generate.json +0 -129
- package/cli/guidelines/modelDocument/modelDocument.instruction.md +0 -509
- package/cli/guidelines/modelService/modelService.generate.json +0 -135
- package/cli/guidelines/modelService/modelService.instruction.md +0 -708
- package/cli/guidelines/modelSignal/modelSignal.generate.json +0 -201
- package/cli/guidelines/modelSignal/modelSignal.instruction.md +0 -552
- package/cli/guidelines/modelStore/modelStore.generate.json +0 -130
- package/cli/guidelines/modelStore/modelStore.instruction.md +0 -585
- package/cli/guidelines/modelTemplate/modelTemplate.generate.json +0 -104
- package/cli/guidelines/modelTemplate/modelTemplate.instruction.md +0 -604
- package/cli/guidelines/modelUnit/modelUnit.generate.json +0 -92
- package/cli/guidelines/modelUnit/modelUnit.instruction.md +0 -541
- package/cli/guidelines/modelUtil/modelUtil.generate.json +0 -93
- package/cli/guidelines/modelUtil/modelUtil.instruction.md +0 -752
- package/cli/guidelines/modelView/modelView.generate.json +0 -80
- package/cli/guidelines/modelView/modelView.instruction.md +0 -1005
- package/cli/guidelines/modelZone/modelZone.generate.json +0 -126
- package/cli/guidelines/modelZone/modelZone.instruction.md +0 -528
- package/cli/guidelines/scalarConstant/scalarConstant.generate.json +0 -106
- package/cli/guidelines/scalarConstant/scalarConstant.instruction.md +0 -442
- package/cli/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -83
- package/cli/guidelines/scalarDictionary/scalarDictionary.instruction.md +0 -273
- package/cli/guidelines/scalarModule/scalarModule.generate.json +0 -35
- package/cli/guidelines/scalarModule/scalarModule.instruction.md +0 -81
- package/cli/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -108
- package/cli/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -310
- package/cli/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -140
- package/cli/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -339
- package/cli/index.js +0 -184444
- package/cli/index.ts +0 -24
- package/cli/library/library.command.ts +0 -28
- package/cli/library/library.runner.ts +0 -66
- package/cli/library/library.script.ts +0 -39
- package/cli/module/module.command.ts +0 -35
- package/cli/module/module.prompt.ts +0 -18
- package/cli/module/module.request.ts +0 -319
- package/cli/module/module.runner.ts +0 -76
- package/cli/module/module.script.ts +0 -161
- package/cli/npmRegistry.ts +0 -13
- package/cli/openBrowser.ts +0 -15
- package/cli/package/package.command.ts +0 -32
- package/cli/package/package.runner.ts +0 -94
- package/cli/package/package.script.ts +0 -35
- package/cli/page/page.command.ts +0 -14
- package/cli/page/page.runner.ts +0 -14
- package/cli/page/page.script.ts +0 -12
- package/cli/pluralizeName.ts +0 -5
- package/cli/scalar/scalar.command.ts +0 -21
- package/cli/scalar/scalar.prompt.ts +0 -131
- package/cli/scalar/scalar.runner.ts +0 -38
- package/cli/scalar/scalar.script.ts +0 -16
- package/cli/semver.ts +0 -18
- package/cli/templates/__scalar/__model__/__model__.constant.ts +0 -15
- package/cli/templates/__scalar/__model__/__model__.dictionary.ts +0 -19
- package/cli/templates/__scalar/__model__/__model__.document.ts +0 -15
- package/cli/templates/app/akan.config.ts +0 -14
- package/cli/templates/app/env/env.client.debug.ts.template +0 -7
- package/cli/templates/app/env/env.client.develop.ts.template +0 -7
- package/cli/templates/app/env/env.client.local.ts.template +0 -7
- package/cli/templates/app/env/env.client.main.ts.template +0 -7
- package/cli/templates/app/env/env.client.testing.ts.template +0 -7
- package/cli/templates/app/env/env.client.ts +0 -21
- package/cli/templates/app/env/env.client.type.ts +0 -16
- package/cli/templates/app/env/env.server.debug.ts.template +0 -7
- package/cli/templates/app/env/env.server.develop.ts.template +0 -7
- package/cli/templates/app/env/env.server.local.ts.template +0 -7
- package/cli/templates/app/env/env.server.main.ts.template +0 -7
- package/cli/templates/app/env/env.server.testing.ts.template +0 -6
- package/cli/templates/app/env/env.server.ts +0 -20
- package/cli/templates/app/lib/___appName__/__appName__.dictionary.ts +0 -17
- package/cli/templates/app/lib/___appName__/__appName__.service.ts +0 -13
- package/cli/templates/app/lib/___appName__/__appName__.signal.ts +0 -17
- package/cli/templates/app/lib/___appName__/__appName__.store.ts +0 -15
- package/cli/templates/app/lib/option.ts +0 -17
- package/cli/templates/app/main.ts +0 -16
- package/cli/templates/app/package.json.template +0 -5
- package/cli/templates/app/page/_index.tsx +0 -296
- package/cli/templates/app/page/_layout.tsx +0 -31
- package/cli/templates/app/page/styles.css.template +0 -53
- package/cli/templates/app/public/favicon.ico +0 -0
- package/cli/templates/app/public/logo.png +0 -0
- package/cli/templates/app/tsconfig.json.template +0 -21
- package/cli/templates/client.ts +0 -46
- package/cli/templates/crudPages/[__model__Id]/edit/page.tsx +0 -47
- package/cli/templates/crudPages/[__model__Id]/page.tsx +0 -52
- package/cli/templates/crudPages/new/page.tsx +0 -42
- package/cli/templates/crudPages/page.tsx +0 -43
- package/cli/templates/crudSinglePage/page.tsx +0 -37
- package/cli/templates/env/_env.server.type.ts +0 -16
- package/cli/templates/facetIndex/index.ts +0 -32
- package/cli/templates/index.ts +0 -10
- package/cli/templates/lib/__lib/lib.constant.ts +0 -38
- package/cli/templates/lib/__lib/lib.dictionary.ts +0 -33
- package/cli/templates/lib/__lib/lib.document.ts +0 -35
- package/cli/templates/lib/__lib/lib.service.ts +0 -33
- package/cli/templates/lib/__lib/lib.signal.ts +0 -34
- package/cli/templates/lib/__lib/lib.store.ts +0 -33
- package/cli/templates/lib/cnst.ts +0 -29
- package/cli/templates/lib/db.ts +0 -32
- package/cli/templates/lib/dict.ts +0 -49
- package/cli/templates/lib/sig.ts +0 -60
- package/cli/templates/lib/srv.ts +0 -34
- package/cli/templates/lib/st.ts +0 -31
- package/cli/templates/lib/useClient.ts +0 -19
- package/cli/templates/lib/useServer.ts +0 -7
- package/cli/templates/libRoot/.gitignore.template +0 -16
- package/cli/templates/libRoot/akan.config.ts +0 -12
- package/cli/templates/libRoot/base/baseLogic.ts +0 -10
- package/cli/templates/libRoot/base/index.ts +0 -8
- package/cli/templates/libRoot/common/commonLogic.ts +0 -10
- package/cli/templates/libRoot/common/index.ts +0 -8
- package/cli/templates/libRoot/env/env.server.example.ts.template +0 -6
- package/cli/templates/libRoot/env/env.server.testing.ts.template +0 -6
- package/cli/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +0 -15
- package/cli/templates/libRoot/lib/___libName__/__libName__.service.ts +0 -11
- package/cli/templates/libRoot/lib/___libName__/__libName__.store.ts +0 -13
- package/cli/templates/libRoot/lib/option.ts +0 -17
- package/cli/templates/libRoot/package.json.template +0 -5
- package/cli/templates/libRoot/srvkit/backendLogic.ts +0 -10
- package/cli/templates/libRoot/srvkit/index.ts +0 -8
- package/cli/templates/libRoot/tsconfig.json.template +0 -11
- package/cli/templates/libRoot/ui/index.ts +0 -7
- package/cli/templates/libRoot/webkit/frontendLogic.ts +0 -10
- package/cli/templates/libRoot/webkit/index.ts +0 -8
- package/cli/templates/localDev/docker-compose.yaml.template +0 -37
- package/cli/templates/module/__Model__.Template.tsx +0 -36
- package/cli/templates/module/__Model__.Unit.tsx +0 -26
- package/cli/templates/module/__Model__.Util.tsx +0 -30
- package/cli/templates/module/__Model__.View.tsx +0 -29
- package/cli/templates/module/__Model__.Zone.tsx +0 -43
- package/cli/templates/module/__model__.constant.ts +0 -24
- package/cli/templates/module/__model__.dictionary.ts +0 -30
- package/cli/templates/module/__model__.document.ts +0 -23
- package/cli/templates/module/__model__.service.ts +0 -16
- package/cli/templates/module/__model__.signal.ts +0 -27
- package/cli/templates/module/__model__.store.ts +0 -19
- package/cli/templates/moduleRoot/index.tsx +0 -31
- package/cli/templates/pkgRoot/tsconfig.json.template +0 -10
- package/cli/templates/server.ts +0 -45
- package/cli/templates/workspaceRoot/.env.template +0 -14
- package/cli/templates/workspaceRoot/.gitignore.template +0 -120
- package/cli/templates/workspaceRoot/.vscode/settings.json.template +0 -23
- package/cli/templates/workspaceRoot/biome.json.template +0 -191
- package/cli/templates/workspaceRoot/bunfig.toml +0 -4
- package/cli/templates/workspaceRoot/package.json.template +0 -7
- package/cli/templates/workspaceRoot/tsconfig.json.template +0 -29
- package/cli/testHelpers.ts +0 -171
- package/cli/workspace/workspace.command.ts +0 -55
- package/cli/workspace/workspace.runner.ts +0 -79
- package/cli/workspace/workspace.script.ts +0 -74
- package/devkit/aiEditor.ts +0 -299
- package/devkit/akanApp/akanApp.host.ts +0 -393
- package/devkit/akanApp/index.ts +0 -1
- package/devkit/akanConfig/akanConfig.ts +0 -360
- package/devkit/akanConfig/index.ts +0 -2
- package/devkit/akanConfig/types.ts +0 -187
- package/devkit/applicationBuildReporter.ts +0 -69
- package/devkit/applicationBuildRunner.ts +0 -302
- package/devkit/applicationReleasePackager.ts +0 -205
- package/devkit/artifact/implicitRootLayout.ts +0 -155
- package/devkit/artifact/index.ts +0 -1
- package/devkit/artifact/routeSeedIndex.ts +0 -128
- package/devkit/auth.ts +0 -41
- package/devkit/builder.ts +0 -164
- package/devkit/capacitor.base.config.ts +0 -88
- package/devkit/capacitorApp.ts +0 -443
- package/devkit/commandDecorators/argMeta.ts +0 -102
- package/devkit/commandDecorators/command.ts +0 -340
- package/devkit/commandDecorators/commandBuilder.ts +0 -224
- package/devkit/commandDecorators/commandMeta.ts +0 -6
- package/devkit/commandDecorators/dependencyBuilder.ts +0 -100
- package/devkit/commandDecorators/helpFormatter.ts +0 -220
- package/devkit/commandDecorators/index.ts +0 -8
- package/devkit/commandDecorators/targetMeta.ts +0 -31
- package/devkit/commandDecorators/types.ts +0 -10
- package/devkit/constants.ts +0 -25
- package/devkit/createTunnel.ts +0 -36
- package/devkit/dependencyScanner.ts +0 -339
- package/devkit/executors.ts +0 -1362
- package/devkit/extractDeps.ts +0 -85
- package/devkit/fileEditor.ts +0 -106
- package/devkit/fileSys.ts +0 -39
- package/devkit/frontendBuild/allRoutesBuilder.ts +0 -103
- package/devkit/frontendBuild/clientBuildTypes.ts +0 -114
- package/devkit/frontendBuild/clientEntriesBundler.ts +0 -300
- package/devkit/frontendBuild/clientEntryDiscovery.ts +0 -196
- package/devkit/frontendBuild/csrArtifactBuilder.ts +0 -237
- package/devkit/frontendBuild/cssCompiler.ts +0 -285
- package/devkit/frontendBuild/cssImportResolver.ts +0 -116
- package/devkit/frontendBuild/fontOptimizer.ts +0 -427
- package/devkit/frontendBuild/hmrChangeClassifier.ts +0 -28
- package/devkit/frontendBuild/hmrWatcher.ts +0 -101
- package/devkit/frontendBuild/index.ts +0 -18
- package/devkit/frontendBuild/pagesBundleBuilder.ts +0 -137
- package/devkit/frontendBuild/pagesEntrySourceGenerator.ts +0 -37
- package/devkit/frontendBuild/precompressArtifacts.ts +0 -59
- package/devkit/frontendBuild/routeClientBuilder.ts +0 -290
- package/devkit/frontendBuild/routesManifestArtifactSerializer.ts +0 -62
- package/devkit/frontendBuild/ssrBaseArtifactBuilder.ts +0 -139
- package/devkit/frontendBuild/vendorSpecifiers.ts +0 -16
- package/devkit/frontendBuild/watchRootResolver.ts +0 -28
- package/devkit/getCredentials.ts +0 -19
- package/devkit/getDirname.ts +0 -3
- package/devkit/getModelFileData.ts +0 -59
- package/devkit/getRelatedCnsts.ts +0 -300
- package/devkit/guideline.ts +0 -19
- package/devkit/incrementalBuilder/incrementalBuilder.host.ts +0 -152
- package/devkit/incrementalBuilder/incrementalBuilder.proc.ts +0 -331
- package/devkit/incrementalBuilder/index.ts +0 -1
- package/devkit/index.ts +0 -36
- package/devkit/lint/no-deep-internal-import.grit +0 -25
- package/devkit/lint/no-import-client-functions.grit +0 -32
- package/devkit/lint/no-import-external-library.grit +0 -21
- package/devkit/lint/no-js-private-class-method.grit +0 -42
- package/devkit/lint/no-use-client-in-server.grit +0 -7
- package/devkit/lint/non-scalar-props-restricted.grit +0 -13
- package/devkit/linter.ts +0 -248
- package/devkit/mobile/index.ts +0 -1
- package/devkit/mobile/mobileTarget.ts +0 -88
- package/devkit/prompter.ts +0 -71
- package/devkit/scanInfo.ts +0 -606
- package/devkit/selectModel.ts +0 -11
- package/devkit/spinner.ts +0 -54
- package/devkit/src/capacitorApp.ts +0 -277
- package/devkit/sshTunnel.ts +0 -151
- package/devkit/streamAi.ts +0 -45
- package/devkit/transforms/barrelAnalyzer.ts +0 -249
- package/devkit/transforms/barrelImportsPlugin.ts +0 -457
- package/devkit/transforms/externalizeFrameworkPlugin.ts +0 -159
- package/devkit/transforms/index.ts +0 -5
- package/devkit/transforms/rscUseClientTransform.ts +0 -52
- package/devkit/transforms/useClientBundlePlugin.ts +0 -47
- package/devkit/typeChecker.ts +0 -260
- package/devkit/types.ts +0 -44
- package/devkit/ui/MultiScrollList.tsx +0 -228
- package/devkit/ui/ScrollList.tsx +0 -106
- package/devkit/ui/index.ts +0 -2
- package/devkit/uploadRelease.ts +0 -95
- package/devkit/useStdoutDimensions.ts +0 -20
- package/types/cli/application/application.command.d.ts +0 -7
- package/types/cli/application/application.interface.d.ts +0 -40
- package/types/cli/application/application.runner.d.ts +0 -66
- package/types/cli/application/application.script.d.ts +0 -72
- package/types/cli/build.d.ts +0 -1
- package/types/cli/cloud/cloud.command.d.ts +0 -7
- package/types/cli/cloud/cloud.runner.d.ts +0 -13
- package/types/cli/cloud/cloud.script.d.ts +0 -23
- package/types/cli/guideline/guideline.command.d.ts +0 -7
- package/types/cli/guideline/guideline.prompt.d.ts +0 -29
- package/types/cli/guideline/guideline.runner.d.ts +0 -21
- package/types/cli/guideline/guideline.script.d.ts +0 -16
- package/types/cli/index.d.ts +0 -2
- package/types/cli/library/library.command.d.ts +0 -7
- package/types/cli/library/library.runner.d.ts +0 -11
- package/types/cli/library/library.script.d.ts +0 -13
- package/types/cli/module/module.command.d.ts +0 -7
- package/types/cli/module/module.prompt.d.ts +0 -13
- package/types/cli/module/module.request.d.ts +0 -63
- package/types/cli/module/module.runner.d.ts +0 -55
- package/types/cli/module/module.script.d.ts +0 -22
- package/types/cli/npmRegistry.d.ts +0 -1
- package/types/cli/openBrowser.d.ts +0 -1
- package/types/cli/package/package.command.d.ts +0 -7
- package/types/cli/package/package.runner.d.ts +0 -13
- package/types/cli/package/package.script.d.ts +0 -18
- package/types/cli/page/page.command.d.ts +0 -7
- package/types/cli/page/page.runner.d.ts +0 -10
- package/types/cli/page/page.script.d.ts +0 -13
- package/types/cli/pluralizeName.d.ts +0 -1
- package/types/cli/scalar/scalar.command.d.ts +0 -7
- package/types/cli/scalar/scalar.prompt.d.ts +0 -23
- package/types/cli/scalar/scalar.runner.d.ts +0 -16
- package/types/cli/scalar/scalar.script.d.ts +0 -11
- package/types/cli/semver.d.ts +0 -1
- package/types/cli/templates/__scalar/__model__/__model__.constant.d.ts +0 -7
- package/types/cli/templates/__scalar/__model__/__model__.dictionary.d.ts +0 -7
- package/types/cli/templates/__scalar/__model__/__model__.document.d.ts +0 -7
- package/types/cli/templates/app/akan.config.d.ts +0 -6
- package/types/cli/templates/app/env/env.client.d.ts +0 -6
- package/types/cli/templates/app/env/env.client.type.d.ts +0 -6
- package/types/cli/templates/app/env/env.server.d.ts +0 -6
- package/types/cli/templates/app/lib/___appName__/__appName__.dictionary.d.ts +0 -7
- package/types/cli/templates/app/lib/___appName__/__appName__.service.d.ts +0 -7
- package/types/cli/templates/app/lib/___appName__/__appName__.signal.d.ts +0 -7
- package/types/cli/templates/app/lib/___appName__/__appName__.store.d.ts +0 -7
- package/types/cli/templates/app/lib/option.d.ts +0 -6
- package/types/cli/templates/app/main.d.ts +0 -6
- package/types/cli/templates/app/page/_index.d.ts +0 -9
- package/types/cli/templates/app/page/_layout.d.ts +0 -11
- package/types/cli/templates/client.d.ts +0 -4
- package/types/cli/templates/crudPages/[__model__Id]/edit/page.d.ts +0 -11
- package/types/cli/templates/crudPages/[__model__Id]/page.d.ts +0 -11
- package/types/cli/templates/crudPages/new/page.d.ts +0 -11
- package/types/cli/templates/crudPages/page.d.ts +0 -11
- package/types/cli/templates/crudSinglePage/page.d.ts +0 -11
- package/types/cli/templates/env/_env.server.type.d.ts +0 -7
- package/types/cli/templates/facetIndex/index.d.ts +0 -13
- package/types/cli/templates/facetIndex.d.ts +0 -1
- package/types/cli/templates/index.d.ts +0 -6
- package/types/cli/templates/lib/__lib/lib.constant.d.ts +0 -4
- package/types/cli/templates/lib/__lib/lib.dictionary.d.ts +0 -4
- package/types/cli/templates/lib/__lib/lib.document.d.ts +0 -4
- package/types/cli/templates/lib/__lib/lib.service.d.ts +0 -4
- package/types/cli/templates/lib/__lib/lib.signal.d.ts +0 -4
- package/types/cli/templates/lib/__lib/lib.store.d.ts +0 -4
- package/types/cli/templates/lib/cnst.d.ts +0 -4
- package/types/cli/templates/lib/db.d.ts +0 -4
- package/types/cli/templates/lib/dict.d.ts +0 -4
- package/types/cli/templates/lib/sig.d.ts +0 -4
- package/types/cli/templates/lib/srv.d.ts +0 -4
- package/types/cli/templates/lib/st.d.ts +0 -4
- package/types/cli/templates/lib/useClient.d.ts +0 -4
- package/types/cli/templates/lib/useServer.d.ts +0 -4
- package/types/cli/templates/libRoot/akan.config.d.ts +0 -5
- package/types/cli/templates/libRoot/base/baseLogic.d.ts +0 -5
- package/types/cli/templates/libRoot/base/index.d.ts +0 -5
- package/types/cli/templates/libRoot/base.d.ts +0 -1
- package/types/cli/templates/libRoot/common/commonLogic.d.ts +0 -5
- package/types/cli/templates/libRoot/common/index.d.ts +0 -5
- package/types/cli/templates/libRoot/common.d.ts +0 -1
- package/types/cli/templates/libRoot/lib/___libName__/__libName__.dictionary.d.ts +0 -6
- package/types/cli/templates/libRoot/lib/___libName__/__libName__.service.d.ts +0 -6
- package/types/cli/templates/libRoot/lib/___libName__/__libName__.store.d.ts +0 -6
- package/types/cli/templates/libRoot/lib/option.d.ts +0 -6
- package/types/cli/templates/libRoot/srvkit/backendLogic.d.ts +0 -5
- package/types/cli/templates/libRoot/srvkit/index.d.ts +0 -5
- package/types/cli/templates/libRoot/srvkit.d.ts +0 -1
- package/types/cli/templates/libRoot/ui/index.d.ts +0 -5
- package/types/cli/templates/libRoot/ui.d.ts +0 -1
- package/types/cli/templates/libRoot/webkit/frontendLogic.d.ts +0 -5
- package/types/cli/templates/libRoot/webkit/index.d.ts +0 -5
- package/types/cli/templates/libRoot/webkit.d.ts +0 -1
- package/types/cli/templates/module/__Model__.Template.d.ts +0 -11
- package/types/cli/templates/module/__Model__.Unit.d.ts +0 -11
- package/types/cli/templates/module/__Model__.Util.d.ts +0 -11
- package/types/cli/templates/module/__Model__.View.d.ts +0 -11
- package/types/cli/templates/module/__Model__.Zone.d.ts +0 -11
- package/types/cli/templates/module/__model__.constant.d.ts +0 -8
- package/types/cli/templates/module/__model__.dictionary.d.ts +0 -8
- package/types/cli/templates/module/__model__.document.d.ts +0 -8
- package/types/cli/templates/module/__model__.service.d.ts +0 -8
- package/types/cli/templates/module/__model__.signal.d.ts +0 -9
- package/types/cli/templates/module/__model__.store.d.ts +0 -8
- package/types/cli/templates/moduleRoot/index.d.ts +0 -11
- package/types/cli/templates/moduleRoot.d.ts +0 -1
- package/types/cli/templates/server.d.ts +0 -4
- package/types/cli/templates.d.ts +0 -1
- package/types/cli/testHelpers.d.ts +0 -64
- package/types/cli/workspace/workspace.command.d.ts +0 -7
- package/types/cli/workspace/workspace.runner.d.ts +0 -14
- package/types/cli/workspace/workspace.script.d.ts +0 -29
- package/types/cli.d.ts +0 -1
- package/types/devkit/aiEditor.d.ts +0 -50
- package/types/devkit/akanApp/akanApp.host.d.ts +0 -16
- package/types/devkit/akanApp/index.d.ts +0 -1
- package/types/devkit/akanApp.d.ts +0 -1
- package/types/devkit/akanConfig/akanConfig.d.ts +0 -36
- package/types/devkit/akanConfig/index.d.ts +0 -2
- package/types/devkit/akanConfig.d.ts +0 -1
- package/types/devkit/applicationBuildReporter.d.ts +0 -25
- package/types/devkit/applicationBuildRunner.d.ts +0 -29
- package/types/devkit/applicationReleasePackager.d.ts +0 -17
- package/types/devkit/artifact/implicitRootLayout.d.ts +0 -17
- package/types/devkit/artifact/index.d.ts +0 -1
- package/types/devkit/artifact/routeSeedIndex.d.ts +0 -38
- package/types/devkit/artifact.d.ts +0 -1
- package/types/devkit/auth.d.ts +0 -9
- package/types/devkit/builder.d.ts +0 -18
- package/types/devkit/capacitor.base.config.d.ts +0 -3
- package/types/devkit/capacitorApp.d.ts +0 -58
- package/types/devkit/commandDecorators/argMeta.d.ts +0 -68
- package/types/devkit/commandDecorators/command.d.ts +0 -2
- package/types/devkit/commandDecorators/commandBuilder.d.ts +0 -60
- package/types/devkit/commandDecorators/commandMeta.d.ts +0 -2
- package/types/devkit/commandDecorators/dependencyBuilder.d.ts +0 -22
- package/types/devkit/commandDecorators/helpFormatter.d.ts +0 -3
- package/types/devkit/commandDecorators/index.d.ts +0 -8
- package/types/devkit/commandDecorators/targetMeta.d.ts +0 -21
- package/types/devkit/commandDecorators/types.d.ts +0 -8
- package/types/devkit/commandDecorators.d.ts +0 -1
- package/types/devkit/constants.d.ts +0 -25
- package/types/devkit/createTunnel.d.ts +0 -8
- package/types/devkit/dependencyScanner.d.ts +0 -33
- package/types/devkit/executors.d.ts +0 -320
- package/types/devkit/extractDeps.d.ts +0 -7
- package/types/devkit/fileEditor.d.ts +0 -16
- package/types/devkit/fileSys.d.ts +0 -12
- package/types/devkit/frontendBuild/allRoutesBuilder.d.ts +0 -18
- package/types/devkit/frontendBuild/clientBuildTypes.d.ts +0 -107
- package/types/devkit/frontendBuild/clientEntriesBundler.d.ts +0 -12
- package/types/devkit/frontendBuild/clientEntryDiscovery.d.ts +0 -19
- package/types/devkit/frontendBuild/csrArtifactBuilder.d.ts +0 -16
- package/types/devkit/frontendBuild/cssCompiler.d.ts +0 -25
- package/types/devkit/frontendBuild/cssImportResolver.d.ts +0 -9
- package/types/devkit/frontendBuild/fontOptimizer.d.ts +0 -14
- package/types/devkit/frontendBuild/hmrChangeClassifier.d.ts +0 -5
- package/types/devkit/frontendBuild/hmrWatcher.d.ts +0 -21
- package/types/devkit/frontendBuild/index.d.ts +0 -18
- package/types/devkit/frontendBuild/pagesBundleBuilder.d.ts +0 -28
- package/types/devkit/frontendBuild/pagesEntrySourceGenerator.d.ts +0 -9
- package/types/devkit/frontendBuild/precompressArtifacts.d.ts +0 -7
- package/types/devkit/frontendBuild/routeClientBuilder.d.ts +0 -50
- package/types/devkit/frontendBuild/routesManifestArtifactSerializer.d.ts +0 -12
- package/types/devkit/frontendBuild/ssrBaseArtifactBuilder.d.ts +0 -16
- package/types/devkit/frontendBuild/vendorSpecifiers.d.ts +0 -2
- package/types/devkit/frontendBuild/watchRootResolver.d.ts +0 -6
- package/types/devkit/frontendBuild.d.ts +0 -1
- package/types/devkit/getCredentials.d.ts +0 -12
- package/types/devkit/getDirname.d.ts +0 -1
- package/types/devkit/getModelFileData.d.ts +0 -16
- package/types/devkit/getRelatedCnsts.d.ts +0 -53
- package/types/devkit/guideline.d.ts +0 -19
- package/types/devkit/incrementalBuilder/incrementalBuilder.host.d.ts +0 -30
- package/types/devkit/incrementalBuilder/incrementalBuilder.proc.d.ts +0 -1
- package/types/devkit/incrementalBuilder/index.d.ts +0 -1
- package/types/devkit/incrementalBuilder.d.ts +0 -1
- package/types/devkit/index.d.ts +0 -36
- package/types/devkit/linter.d.ts +0 -108
- package/types/devkit/mobile/index.d.ts +0 -1
- package/types/devkit/mobile/mobileTarget.d.ts +0 -14
- package/types/devkit/mobile.d.ts +0 -1
- package/types/devkit/prompter.d.ts +0 -15
- package/types/devkit/scanInfo.d.ts +0 -82
- package/types/devkit/selectModel.d.ts +0 -1
- package/types/devkit/spinner.d.ts +0 -20
- package/types/devkit/src/capacitorApp.d.ts +0 -39
- package/types/devkit/sshTunnel.d.ts +0 -14
- package/types/devkit/streamAi.d.ts +0 -6
- package/types/devkit/transforms/barrelAnalyzer.d.ts +0 -27
- package/types/devkit/transforms/barrelImportsPlugin.d.ts +0 -26
- package/types/devkit/transforms/externalizeFrameworkPlugin.d.ts +0 -49
- package/types/devkit/transforms/index.d.ts +0 -5
- package/types/devkit/transforms/rscUseClientTransform.d.ts +0 -10
- package/types/devkit/transforms/useClientBundlePlugin.d.ts +0 -19
- package/types/devkit/transforms.d.ts +0 -1
- package/types/devkit/typeChecker.d.ts +0 -62
- package/types/devkit/types.d.ts +0 -43
- package/types/devkit/ui/MultiScrollList.d.ts +0 -13
- package/types/devkit/ui/ScrollList.d.ts +0 -7
- package/types/devkit/ui/index.d.ts +0 -2
- package/types/devkit/ui.d.ts +0 -1
- package/types/devkit/uploadRelease.d.ts +0 -10
- package/types/devkit/useStdoutDimensions.d.ts +0 -1
- package/types/devkit.d.ts +0 -1
package/cli/testHelpers.ts
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { AppExecutor, LibExecutor, ModuleExecutor, PkgExecutor, WorkspaceExecutor } from "akanjs/devkit";
|
|
5
|
-
|
|
6
|
-
export interface CallRecord {
|
|
7
|
-
name: string;
|
|
8
|
-
args: unknown[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const createCallRecorder = () => {
|
|
12
|
-
const calls: CallRecord[] = [];
|
|
13
|
-
return {
|
|
14
|
-
calls,
|
|
15
|
-
record(name: string, ...args: unknown[]) {
|
|
16
|
-
calls.push({ name, args });
|
|
17
|
-
},
|
|
18
|
-
names() {
|
|
19
|
-
return calls.map((call) => call.name);
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const createFakeSpinner = (recorder = createCallRecorder()) => ({
|
|
25
|
-
succeed: (message?: string) => recorder.record("spinner.succeed", message),
|
|
26
|
-
fail: (message?: string) => recorder.record("spinner.fail", message),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export const createFakeExecutor = <Extra extends object = object>(
|
|
30
|
-
name: string,
|
|
31
|
-
extra: Extra = {} as Extra,
|
|
32
|
-
recorder = createCallRecorder(),
|
|
33
|
-
) =>
|
|
34
|
-
({
|
|
35
|
-
name,
|
|
36
|
-
cwdPath: `/workspace/${name}`,
|
|
37
|
-
workspaceRoot: "/workspace",
|
|
38
|
-
spinning: (message: string) => {
|
|
39
|
-
recorder.record(`${name}.spinning`, message);
|
|
40
|
-
return createFakeSpinner(recorder);
|
|
41
|
-
},
|
|
42
|
-
spawn: async (...args: unknown[]) => {
|
|
43
|
-
recorder.record(`${name}.spawn`, ...args);
|
|
44
|
-
return "";
|
|
45
|
-
},
|
|
46
|
-
exec: async (...args: unknown[]) => {
|
|
47
|
-
recorder.record(`${name}.exec`, ...args);
|
|
48
|
-
return "";
|
|
49
|
-
},
|
|
50
|
-
scan: async (...args: unknown[]) => {
|
|
51
|
-
recorder.record(`${name}.scan`, ...args);
|
|
52
|
-
return { name };
|
|
53
|
-
},
|
|
54
|
-
scanSync: async (...args: unknown[]) => {
|
|
55
|
-
recorder.record(`${name}.scanSync`, ...args);
|
|
56
|
-
return { name };
|
|
57
|
-
},
|
|
58
|
-
...extra,
|
|
59
|
-
}) as Extra & {
|
|
60
|
-
name: string;
|
|
61
|
-
cwdPath: string;
|
|
62
|
-
workspaceRoot: string;
|
|
63
|
-
spinning: (message: string) => ReturnType<typeof createFakeSpinner>;
|
|
64
|
-
spawn: (...args: unknown[]) => Promise<string>;
|
|
65
|
-
exec: (...args: unknown[]) => Promise<string>;
|
|
66
|
-
scan: (...args: unknown[]) => Promise<{ name: string }>;
|
|
67
|
-
scanSync: (...args: unknown[]) => Promise<{ name: string }>;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const makeCliTempWorkspace = async () => {
|
|
71
|
-
const root = await mkdtemp(path.join(os.tmpdir(), "akan-cli-"));
|
|
72
|
-
await mkdir(root, { recursive: true });
|
|
73
|
-
await writeText(path.join(root, ".gitignore"), "");
|
|
74
|
-
const workspace = new WorkspaceExecutor({ workspaceRoot: root, repoName: "repo" });
|
|
75
|
-
return { root, workspace };
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const cleanupCliTempWorkspace = async (root: string) => {
|
|
79
|
-
await rm(root, { recursive: true, force: true });
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const writeText = async (filePath: string, content: string) => {
|
|
83
|
-
await mkdir(path.dirname(filePath), { recursive: true });
|
|
84
|
-
await writeFile(filePath, content);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const writeJson = async (filePath: string, value: object) => {
|
|
88
|
-
await writeText(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const createTempApp = async (appName = "demo") => {
|
|
92
|
-
const { root, workspace } = await makeCliTempWorkspace();
|
|
93
|
-
await writeJson(path.join(root, "package.json"), {
|
|
94
|
-
name: "repo",
|
|
95
|
-
version: "1.0.0",
|
|
96
|
-
description: "repo",
|
|
97
|
-
dependencies: {
|
|
98
|
-
react: "19.0.0",
|
|
99
|
-
"react-dom": "19.0.0",
|
|
100
|
-
"react-server-dom-webpack": "19.0.0",
|
|
101
|
-
sharp: "1.0.0",
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
await writeJson(path.join(root, "tsconfig.json"), {
|
|
105
|
-
compilerOptions: { target: "ESNext", paths: {} },
|
|
106
|
-
references: [],
|
|
107
|
-
});
|
|
108
|
-
await writeJson(path.join(root, "apps", appName, "tsconfig.json"), {
|
|
109
|
-
compilerOptions: { target: "ESNext", paths: {} },
|
|
110
|
-
});
|
|
111
|
-
await writeJson(path.join(root, "apps", appName, "package.json"), {
|
|
112
|
-
name: appName,
|
|
113
|
-
version: "1.0.0",
|
|
114
|
-
description: appName,
|
|
115
|
-
dependencies: {},
|
|
116
|
-
devDependencies: {},
|
|
117
|
-
});
|
|
118
|
-
await writeText(path.join(root, "apps", appName, "akan.config.ts"), "export default {};\n");
|
|
119
|
-
await mkdir(path.join(root, "apps", appName, "lib", "__scalar"), { recursive: true });
|
|
120
|
-
const app = AppExecutor.from(workspace, appName);
|
|
121
|
-
return { root, workspace, app };
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export const createTempLib = async (libName = "shared") => {
|
|
125
|
-
const { root, workspace } = await makeCliTempWorkspace();
|
|
126
|
-
await writeJson(path.join(root, "package.json"), {
|
|
127
|
-
name: "repo",
|
|
128
|
-
version: "1.0.0",
|
|
129
|
-
description: "repo",
|
|
130
|
-
dependencies: {},
|
|
131
|
-
devDependencies: {},
|
|
132
|
-
});
|
|
133
|
-
await writeJson(path.join(root, "tsconfig.json"), {
|
|
134
|
-
compilerOptions: { target: "ESNext", paths: {} },
|
|
135
|
-
references: [],
|
|
136
|
-
});
|
|
137
|
-
const lib = LibExecutor.from(workspace, libName);
|
|
138
|
-
return { root, workspace, lib };
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export const createTempPackage = async (pkgName = "@sample/tool") => {
|
|
142
|
-
const { root, workspace } = await makeCliTempWorkspace();
|
|
143
|
-
await writeJson(path.join(root, "package.json"), {
|
|
144
|
-
name: "repo",
|
|
145
|
-
version: "1.0.0",
|
|
146
|
-
description: "repo",
|
|
147
|
-
dependencies: { lodash: "4.0.0" },
|
|
148
|
-
devDependencies: { typescript: "6.0.0" },
|
|
149
|
-
});
|
|
150
|
-
await writeJson(path.join(root, "tsconfig.json"), {
|
|
151
|
-
compilerOptions: { target: "ESNext", paths: {} },
|
|
152
|
-
});
|
|
153
|
-
await writeJson(path.join(root, "pkgs", pkgName, "package.json"), {
|
|
154
|
-
name: pkgName,
|
|
155
|
-
version: "0.1.0",
|
|
156
|
-
description: "tool",
|
|
157
|
-
exports: {},
|
|
158
|
-
});
|
|
159
|
-
await writeJson(path.join(root, "pkgs", pkgName, "tsconfig.json"), {
|
|
160
|
-
compilerOptions: { target: "ESNext", paths: {} },
|
|
161
|
-
});
|
|
162
|
-
await writeText(path.join(root, "pkgs", pkgName, "index.ts"), 'import "lodash";\nexport const value = 1;\n');
|
|
163
|
-
const pkg = PkgExecutor.from(workspace, pkgName);
|
|
164
|
-
return { root, workspace, pkg };
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export const createTempModule = async (moduleName = "post") => {
|
|
168
|
-
const { root, workspace, app } = await createTempApp("demo");
|
|
169
|
-
const module = ModuleExecutor.from(app, moduleName);
|
|
170
|
-
return { root, workspace, app, module };
|
|
171
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { command, Exec, Workspace } from "akanjs/devkit";
|
|
2
|
-
|
|
3
|
-
import { WorkspaceScript } from "./workspace.script";
|
|
4
|
-
|
|
5
|
-
export class WorkspaceCommand extends command("workspace", [WorkspaceScript], ({ public: target }) => ({
|
|
6
|
-
createWorkspace: target({ desc: "Create a new Akan.js workspace", runsOnWorkspaceRoot: false })
|
|
7
|
-
.arg("workspaceName", String, { desc: "what is the name of your organization?" })
|
|
8
|
-
.option("app", String, {
|
|
9
|
-
desc: "what is the codename of your first application? (e.g. myapp)",
|
|
10
|
-
})
|
|
11
|
-
.option("dir", String, {
|
|
12
|
-
desc: "directory of workspace",
|
|
13
|
-
default: process.env.USE_AKANJS_PKGS === "true" ? "local" : ".",
|
|
14
|
-
})
|
|
15
|
-
.option("libs", Boolean, {
|
|
16
|
-
desc: "Do you want to install shared and util libraries? (admin, user file, etc.)",
|
|
17
|
-
enum: [
|
|
18
|
-
{ label: "No, I want to start with empty workspace (Recommended)", value: false },
|
|
19
|
-
{
|
|
20
|
-
label: "Yes, I want to accelerate development by installing shared and util libraries (for akanjs experts)",
|
|
21
|
-
value: true,
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
})
|
|
25
|
-
.option("init", Boolean, {
|
|
26
|
-
desc: "Do you want to initialize the workspace? (Recommended)",
|
|
27
|
-
default: true,
|
|
28
|
-
})
|
|
29
|
-
.exec(async function (workspaceName, app, dir, libs, init) {
|
|
30
|
-
const appName = app || "app";
|
|
31
|
-
await this.workspaceScript.createWorkspace(
|
|
32
|
-
workspaceName.toLowerCase().replace(/ /g, "-"),
|
|
33
|
-
appName.toLowerCase().replace(/ /g, "-"),
|
|
34
|
-
{ dirname: dir, installLibs: libs, init },
|
|
35
|
-
);
|
|
36
|
-
}),
|
|
37
|
-
lint: target({ desc: "Lint and fix code in a specific app/lib/pkg" })
|
|
38
|
-
.with(Exec)
|
|
39
|
-
.option("fix", Boolean, { default: true })
|
|
40
|
-
.with(Workspace)
|
|
41
|
-
.exec(async function (exec, fix, workspace) {
|
|
42
|
-
await this.workspaceScript.lint(exec, workspace, { fix });
|
|
43
|
-
}),
|
|
44
|
-
lintAll: target({ desc: "Lint and fix code in all apps and libraries" })
|
|
45
|
-
.option("fix", Boolean, { default: true })
|
|
46
|
-
.with(Workspace)
|
|
47
|
-
.exec(async function (fix, workspace) {
|
|
48
|
-
await this.workspaceScript.lintAll(workspace, { fix });
|
|
49
|
-
}),
|
|
50
|
-
syncAll: target({ desc: "Sync dependencies and configuration for all apps and libraries" })
|
|
51
|
-
.with(Workspace)
|
|
52
|
-
.exec(async function (workspace) {
|
|
53
|
-
await this.workspaceScript.syncAll(workspace);
|
|
54
|
-
}),
|
|
55
|
-
})) {}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { type Exec, FileSys, type PackageJson, runner, type Workspace, WorkspaceExecutor } from "akanjs/devkit";
|
|
3
|
-
import { getLatestPackageVersion } from "../npmRegistry";
|
|
4
|
-
|
|
5
|
-
export class WorkspaceRunner extends runner("workspace") {
|
|
6
|
-
async createWorkspace(
|
|
7
|
-
repoName: string,
|
|
8
|
-
appName: string,
|
|
9
|
-
{ dirname = ".", init = true, akanVersion }: { dirname?: string; init?: boolean; akanVersion: string },
|
|
10
|
-
) {
|
|
11
|
-
const cwdPath = process.cwd();
|
|
12
|
-
const workspaceRoot = path.join(cwdPath, dirname, repoName);
|
|
13
|
-
|
|
14
|
-
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
|
|
15
|
-
const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname}/${repoName}...`);
|
|
16
|
-
const latestTypesBunVersion = await getLatestPackageVersion("@types/bun");
|
|
17
|
-
await workspace.applyTemplate({
|
|
18
|
-
basePath: ".",
|
|
19
|
-
template: "workspaceRoot",
|
|
20
|
-
dict: { repoName, appName, serveDomain: "localhost" },
|
|
21
|
-
});
|
|
22
|
-
templateSpinner.succeed(`Workspace files created in ${dirname}/${repoName}`);
|
|
23
|
-
|
|
24
|
-
const [rootPackageJson, peerDependencies] = await Promise.all([
|
|
25
|
-
workspace.getPackageJson(),
|
|
26
|
-
this.#getAkanPeerDependencies(),
|
|
27
|
-
]);
|
|
28
|
-
const packageJson: PackageJson = {
|
|
29
|
-
...rootPackageJson,
|
|
30
|
-
dependencies: {
|
|
31
|
-
...rootPackageJson.dependencies,
|
|
32
|
-
...peerDependencies,
|
|
33
|
-
akanjs: akanVersion,
|
|
34
|
-
},
|
|
35
|
-
devDependencies: {
|
|
36
|
-
...rootPackageJson.devDependencies,
|
|
37
|
-
"@types/bun": latestTypesBunVersion,
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
await workspace.setPackageJson(packageJson);
|
|
41
|
-
|
|
42
|
-
if (init) {
|
|
43
|
-
const installSpinner = workspace.spinning("Installing dependencies with bun...");
|
|
44
|
-
await workspace.spawn("bun", ["install"]);
|
|
45
|
-
installSpinner.succeed("Dependencies installed with bun");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return workspace;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async #getAkanPeerDependencies(): Promise<Record<string, string>> {
|
|
52
|
-
const packageJson = await this.#getAkanPackageJson();
|
|
53
|
-
return packageJson.peerDependencies ?? {};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async #getAkanPackageJson(): Promise<PackageJson> {
|
|
57
|
-
let current = import.meta.dir;
|
|
58
|
-
for (let depth = 0; depth < 6; depth++) {
|
|
59
|
-
const packageJsonPath = path.join(current, "package.json");
|
|
60
|
-
if (await Bun.file(packageJsonPath).exists()) {
|
|
61
|
-
const packageJson = await FileSys.readJson<PackageJson>(packageJsonPath);
|
|
62
|
-
if (packageJson.name === "akanjs") return packageJson;
|
|
63
|
-
}
|
|
64
|
-
const parent = path.dirname(current);
|
|
65
|
-
if (parent === current) break;
|
|
66
|
-
current = parent;
|
|
67
|
-
}
|
|
68
|
-
throw new Error(`[workspace] failed to locate akanjs package.json from ${import.meta.dir}`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async lint(exec: Exec, workspace: Workspace, { fix = true }: { fix?: boolean } = {}) {
|
|
72
|
-
await workspace.spawn("./node_modules/.bin/biome", [
|
|
73
|
-
"check",
|
|
74
|
-
...(fix ? ["--write"] : []),
|
|
75
|
-
"--no-errors-on-unmatched",
|
|
76
|
-
exec.cwdPath,
|
|
77
|
-
]);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { Logger } from "akanjs/common";
|
|
3
|
-
import { AppExecutor, type Exec, LibExecutor, PkgExecutor, script, type Workspace } from "akanjs/devkit";
|
|
4
|
-
|
|
5
|
-
import { ApplicationScript } from "../application/application.script";
|
|
6
|
-
import { LibraryScript } from "../library/library.script";
|
|
7
|
-
import { PackageScript } from "../package/package.script";
|
|
8
|
-
import { WorkspaceRunner } from "./workspace.runner";
|
|
9
|
-
|
|
10
|
-
export class WorkspaceScript extends script("workspace", [
|
|
11
|
-
WorkspaceRunner,
|
|
12
|
-
ApplicationScript,
|
|
13
|
-
LibraryScript,
|
|
14
|
-
PackageScript,
|
|
15
|
-
]) {
|
|
16
|
-
async createWorkspace(
|
|
17
|
-
repoName: string,
|
|
18
|
-
appName: string,
|
|
19
|
-
{ dirname = ".", installLibs = false, init = true }: { dirname?: string; installLibs?: boolean; init?: boolean },
|
|
20
|
-
) {
|
|
21
|
-
const akanVersion = await this.packageScript.version(null, { log: false });
|
|
22
|
-
const workspace = await this.workspaceRunner.createWorkspace(repoName, appName, {
|
|
23
|
-
dirname,
|
|
24
|
-
init,
|
|
25
|
-
akanVersion,
|
|
26
|
-
});
|
|
27
|
-
if (installLibs) {
|
|
28
|
-
await this.libraryScript.installLibrary(workspace, "util");
|
|
29
|
-
await this.libraryScript.installLibrary(workspace, "shared");
|
|
30
|
-
}
|
|
31
|
-
await this.applicationScript.createApplication(appName, workspace, { libs: installLibs ? ["util", "shared"] : [] });
|
|
32
|
-
const gitSpinner = workspace.spinning("Initializing git repository and commit...");
|
|
33
|
-
try {
|
|
34
|
-
await workspace.commit("Initial commit", { init: true });
|
|
35
|
-
gitSpinner.succeed("Git repository initialized and committed");
|
|
36
|
-
} catch (_) {
|
|
37
|
-
gitSpinner.fail("Git repository initialization failed. It's not fatal, you can commit manually");
|
|
38
|
-
}
|
|
39
|
-
const workspacePath = path.join(dirname, repoName);
|
|
40
|
-
Logger.rawLog(`\n🎉 Welcome aboard! Workspace created in ${dirname}/${repoName}`);
|
|
41
|
-
Logger.rawLog(`🚀 Run \`cd ${workspacePath} && akan start ${appName}\` to start the development server.`);
|
|
42
|
-
|
|
43
|
-
Logger.rawLog(`\n👋 Happy coding!`);
|
|
44
|
-
}
|
|
45
|
-
async lint(exec: Exec, workspace: Workspace, { fix = true }: { fix?: boolean } = {}) {
|
|
46
|
-
if (exec instanceof AppExecutor) await this.applicationScript.sync(exec);
|
|
47
|
-
else if (exec instanceof LibExecutor) await this.libraryScript.syncLibrary(exec);
|
|
48
|
-
const spinner = workspace.spinning(`Linting${fix ? " with fix" : ""}...`);
|
|
49
|
-
try {
|
|
50
|
-
await this.workspaceRunner.lint(exec, workspace, { fix });
|
|
51
|
-
spinner.succeed("Lint completed with no errors");
|
|
52
|
-
} catch (error) {
|
|
53
|
-
spinner.fail("Lint failed with errors");
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async lintAll(workspace: Workspace, { fix = true }: { fix?: boolean } = {}) {
|
|
58
|
-
const [appNames, libNames, pkgNames] = await workspace.getExecs();
|
|
59
|
-
await Promise.all(appNames.map((appName) => this.applicationScript.sync(AppExecutor.from(workspace, appName))));
|
|
60
|
-
await Promise.all(libNames.map((libName) => this.libraryScript.syncLibrary(LibExecutor.from(workspace, libName))));
|
|
61
|
-
await Promise.all([
|
|
62
|
-
...appNames.map((appName) => this.workspaceRunner.lint(AppExecutor.from(workspace, appName), workspace, { fix })),
|
|
63
|
-
...libNames.map((libName) => this.workspaceRunner.lint(LibExecutor.from(workspace, libName), workspace, { fix })),
|
|
64
|
-
...pkgNames
|
|
65
|
-
.filter((pkgName) => pkgName !== "contract")
|
|
66
|
-
.map((pkgName) => this.workspaceRunner.lint(PkgExecutor.from(workspace, pkgName), workspace, { fix })),
|
|
67
|
-
]);
|
|
68
|
-
}
|
|
69
|
-
async syncAll(workspace: Workspace) {
|
|
70
|
-
const [appNames, libNames] = await workspace.getExecs();
|
|
71
|
-
for (const libName of libNames) await this.libraryScript.syncLibrary(LibExecutor.from(workspace, libName));
|
|
72
|
-
for (const appName of appNames) await this.applicationScript.sync(AppExecutor.from(workspace, appName));
|
|
73
|
-
}
|
|
74
|
-
}
|
package/devkit/aiEditor.ts
DELETED
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { input, select } from "@inquirer/prompts";
|
|
2
|
-
import {
|
|
3
|
-
AIMessage,
|
|
4
|
-
type BaseMessage,
|
|
5
|
-
HumanMessage,
|
|
6
|
-
mapChatMessagesToStoredMessages,
|
|
7
|
-
mapStoredMessagesToChatMessages,
|
|
8
|
-
type StoredMessage,
|
|
9
|
-
} from "@langchain/core/messages";
|
|
10
|
-
import { ChatDeepSeek } from "@langchain/deepseek";
|
|
11
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
12
|
-
import { Logger } from "akanjs/common";
|
|
13
|
-
import chalk from "chalk";
|
|
14
|
-
|
|
15
|
-
import { getAkanGlobalConfig, setAkanGlobalConfig } from "./auth";
|
|
16
|
-
import type { Executor, WorkspaceExecutor } from "./executors";
|
|
17
|
-
import { Spinner } from "./spinner";
|
|
18
|
-
import type { FileContent } from "./types";
|
|
19
|
-
|
|
20
|
-
const MAX_ASK_TRY = 300;
|
|
21
|
-
|
|
22
|
-
export const supportedLlmModels = ["deepseek-chat", "deepseek-reasoner"] as const;
|
|
23
|
-
export type SupportedLlmModel = (typeof supportedLlmModels)[number];
|
|
24
|
-
|
|
25
|
-
interface EditOptions {
|
|
26
|
-
onReasoning?: (reasoning: string) => void;
|
|
27
|
-
onChunk?: (chunk: string) => void;
|
|
28
|
-
maxTry?: number;
|
|
29
|
-
validate?: string[];
|
|
30
|
-
approve?: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class AiSession {
|
|
34
|
-
static #cacheDir = "node_modules/.cache/akan/aiSession";
|
|
35
|
-
static #chat: ChatDeepSeek | ChatOpenAI | null = null;
|
|
36
|
-
static async init({ temperature = 0, useExisting = true }: { temperature?: number; useExisting?: boolean } = {}) {
|
|
37
|
-
if (useExisting) {
|
|
38
|
-
const llmConfig = await AiSession.getLlmConfig();
|
|
39
|
-
if (llmConfig) {
|
|
40
|
-
AiSession.#setChatModel(llmConfig.model, llmConfig.apiKey);
|
|
41
|
-
Logger.rawLog(chalk.dim(`🤖akan editor uses existing LLM config (${llmConfig.model})`));
|
|
42
|
-
return AiSession;
|
|
43
|
-
}
|
|
44
|
-
} else Logger.rawLog(chalk.yellow("🤖akan-editor is not initialized. LLM configuration should be set first."));
|
|
45
|
-
|
|
46
|
-
const llmConfig = await AiSession.#requestLlmConfig();
|
|
47
|
-
const { model, apiKey } = llmConfig;
|
|
48
|
-
|
|
49
|
-
await AiSession.#validateApiKey(model, apiKey);
|
|
50
|
-
const session = AiSession.#setChatModel(model, apiKey, { temperature });
|
|
51
|
-
await session.setLlmConfig({ model, apiKey });
|
|
52
|
-
return session;
|
|
53
|
-
}
|
|
54
|
-
static #setChatModel(model: SupportedLlmModel, apiKey: string, { temperature = 0 }: { temperature?: number } = {}) {
|
|
55
|
-
AiSession.#chat = new ChatDeepSeek({
|
|
56
|
-
modelName: model,
|
|
57
|
-
temperature,
|
|
58
|
-
streaming: true,
|
|
59
|
-
apiKey,
|
|
60
|
-
});
|
|
61
|
-
return AiSession;
|
|
62
|
-
}
|
|
63
|
-
static async getLlmConfig() {
|
|
64
|
-
const akanConfig = await getAkanGlobalConfig();
|
|
65
|
-
return akanConfig.llm ?? null;
|
|
66
|
-
}
|
|
67
|
-
static async setLlmConfig(llmConfig: { model: SupportedLlmModel; apiKey: string } | null) {
|
|
68
|
-
const akanConfig = await getAkanGlobalConfig();
|
|
69
|
-
akanConfig.llm = llmConfig;
|
|
70
|
-
await setAkanGlobalConfig(akanConfig);
|
|
71
|
-
return AiSession;
|
|
72
|
-
}
|
|
73
|
-
static async #requestLlmConfig() {
|
|
74
|
-
const model = await select<SupportedLlmModel>({ message: "Select a LLM model", choices: supportedLlmModels });
|
|
75
|
-
const apiKey = await input({ message: "Enter your API key" });
|
|
76
|
-
return { model, apiKey };
|
|
77
|
-
}
|
|
78
|
-
static async #validateApiKey(modelName: SupportedLlmModel, apiKey: string) {
|
|
79
|
-
const spinner = new Spinner("Validating LLM API key...", { prefix: `🤖akan-editor` }).start();
|
|
80
|
-
const chat = new ChatOpenAI({
|
|
81
|
-
modelName,
|
|
82
|
-
temperature: 0,
|
|
83
|
-
configuration: { baseURL: "https://api.deepseek.com/v1", apiKey },
|
|
84
|
-
});
|
|
85
|
-
try {
|
|
86
|
-
await chat.invoke("Hi, and just say 'ok'");
|
|
87
|
-
spinner.succeed("LLM API key is valid");
|
|
88
|
-
return true;
|
|
89
|
-
} catch (error) {
|
|
90
|
-
spinner.fail(
|
|
91
|
-
chalk.red(
|
|
92
|
-
`LLM API key is invalid. Please check your API key and try again. You can set it again by running "akan set-llm" or reset by running "akan reset-llm"`,
|
|
93
|
-
),
|
|
94
|
-
);
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
static async clearCache(workspaceRoot: string) {
|
|
99
|
-
const cacheDir = `${workspaceRoot}/${AiSession.#cacheDir}`;
|
|
100
|
-
await Bun.$`rm -rf ${cacheDir}`;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
messageHistory: BaseMessage[] = [];
|
|
104
|
-
readonly sessionKey: string;
|
|
105
|
-
isCacheLoaded: boolean = false;
|
|
106
|
-
workspace: WorkspaceExecutor;
|
|
107
|
-
constructor(
|
|
108
|
-
type: string,
|
|
109
|
-
{ workspace, cacheKey, isContinued }: { workspace: WorkspaceExecutor; cacheKey?: string; isContinued?: boolean },
|
|
110
|
-
) {
|
|
111
|
-
this.workspace = workspace;
|
|
112
|
-
this.sessionKey = `${type}${cacheKey ? `-${cacheKey}` : ""}`;
|
|
113
|
-
if (isContinued) this.#cacheLoadPromise = this.#loadCache();
|
|
114
|
-
}
|
|
115
|
-
#cacheLoadPromise: Promise<void> | null = null;
|
|
116
|
-
async #loadCache() {
|
|
117
|
-
const cacheFile = `${AiSession.#cacheDir}/${this.sessionKey}.json`;
|
|
118
|
-
const isCacheExists = await this.workspace.exists(cacheFile);
|
|
119
|
-
if (isCacheExists)
|
|
120
|
-
this.messageHistory = mapStoredMessagesToChatMessages(
|
|
121
|
-
(await this.workspace.readJson(cacheFile)) as StoredMessage[],
|
|
122
|
-
);
|
|
123
|
-
else this.messageHistory = [];
|
|
124
|
-
this.isCacheLoaded = isCacheExists;
|
|
125
|
-
}
|
|
126
|
-
async #saveCache() {
|
|
127
|
-
const cacheFilePath = `${AiSession.#cacheDir}/${this.sessionKey}.json`;
|
|
128
|
-
await this.workspace.writeJson(cacheFilePath, mapChatMessagesToStoredMessages(this.messageHistory));
|
|
129
|
-
}
|
|
130
|
-
async ask(
|
|
131
|
-
question: string,
|
|
132
|
-
{
|
|
133
|
-
onReasoning = (reasoning: string) => {
|
|
134
|
-
Logger.raw(chalk.dim(reasoning));
|
|
135
|
-
},
|
|
136
|
-
onChunk = (chunk: string) => {
|
|
137
|
-
Logger.raw(chunk);
|
|
138
|
-
},
|
|
139
|
-
}: EditOptions = {},
|
|
140
|
-
): Promise<{ content: string; messageHistory: BaseMessage[] }> {
|
|
141
|
-
if (!AiSession.#chat) await AiSession.init();
|
|
142
|
-
if (this.#cacheLoadPromise) await this.#cacheLoadPromise;
|
|
143
|
-
|
|
144
|
-
if (!AiSession.#chat) throw new Error("Failed to initialize the AI session");
|
|
145
|
-
const loader = new Spinner(`${AiSession.#chat.model} is thinking...`, {
|
|
146
|
-
prefix: `🤖akan-editor`,
|
|
147
|
-
}).start();
|
|
148
|
-
try {
|
|
149
|
-
const humanMessage = new HumanMessage(question);
|
|
150
|
-
this.messageHistory.push(humanMessage);
|
|
151
|
-
const stream = await AiSession.#chat.stream(this.messageHistory);
|
|
152
|
-
let reasoningResponse = "",
|
|
153
|
-
fullResponse = "",
|
|
154
|
-
tokenIdx = 0;
|
|
155
|
-
for await (const chunk of stream) {
|
|
156
|
-
if (loader.isSpinning()) loader.succeed(`${AiSession.#chat.model} responded`);
|
|
157
|
-
|
|
158
|
-
if (!fullResponse.length) {
|
|
159
|
-
const reasoningContent = (chunk.additional_kwargs as { reasoning_content?: string }).reasoning_content ?? "";
|
|
160
|
-
if (reasoningContent.length) {
|
|
161
|
-
reasoningResponse += reasoningContent;
|
|
162
|
-
onReasoning(reasoningContent);
|
|
163
|
-
continue;
|
|
164
|
-
} else if (chunk.content.length) {
|
|
165
|
-
reasoningResponse += "\n";
|
|
166
|
-
onReasoning(reasoningResponse);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const content = chunk.content;
|
|
171
|
-
if (typeof content === "string") {
|
|
172
|
-
fullResponse += content;
|
|
173
|
-
onChunk(content);
|
|
174
|
-
}
|
|
175
|
-
tokenIdx++;
|
|
176
|
-
}
|
|
177
|
-
fullResponse += "\n";
|
|
178
|
-
onChunk("\n");
|
|
179
|
-
this.messageHistory.push(new AIMessage(fullResponse));
|
|
180
|
-
return { content: fullResponse, messageHistory: this.messageHistory };
|
|
181
|
-
} catch (error) {
|
|
182
|
-
loader.fail(`${AiSession.#chat.model} failed to respond`);
|
|
183
|
-
throw new Error("Failed to stream response");
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async edit(question: string, { onChunk, onReasoning, maxTry = MAX_ASK_TRY, validate, approve }: EditOptions = {}) {
|
|
187
|
-
for (let tryCount = 0; tryCount < maxTry; tryCount++) {
|
|
188
|
-
let response = await this.ask(question, { onChunk, onReasoning });
|
|
189
|
-
if (validate?.length && tryCount === 0) {
|
|
190
|
-
const validateQuestion = `Double check if the response meets the requirements and conditions, and follow the instructions. If not, rewrite it.
|
|
191
|
-
${validate.map((v) => `- ${v}`).join("\n")}`;
|
|
192
|
-
response = await this.ask(validateQuestion, { onChunk, onReasoning });
|
|
193
|
-
}
|
|
194
|
-
const isConfirmed = approve
|
|
195
|
-
? true
|
|
196
|
-
: await select({
|
|
197
|
-
message: "Do you want to edit the response?",
|
|
198
|
-
choices: [
|
|
199
|
-
{ name: "✅ Yes, confirm and apply this result", value: true },
|
|
200
|
-
{ name: "🔄 No, I want to edit it more", value: false },
|
|
201
|
-
],
|
|
202
|
-
});
|
|
203
|
-
if (isConfirmed) {
|
|
204
|
-
await this.#saveCache();
|
|
205
|
-
return response.content;
|
|
206
|
-
}
|
|
207
|
-
question = await input({ message: "What do you want to change?" });
|
|
208
|
-
tryCount++;
|
|
209
|
-
}
|
|
210
|
-
throw new Error("Failed to edit");
|
|
211
|
-
}
|
|
212
|
-
async editTypescript(question: string, options: EditOptions = {}) {
|
|
213
|
-
const content = await this.edit(question, options);
|
|
214
|
-
return this.#getTypescriptCode(content);
|
|
215
|
-
}
|
|
216
|
-
#getTypescriptCode(content: string) {
|
|
217
|
-
|
|
218
|
-
const code = /```(typescript|tsx)([\s\S]*?)```/.exec(content);
|
|
219
|
-
|
|
220
|
-
return code?.[2] ?? content;
|
|
221
|
-
}
|
|
222
|
-
addToolMessgaes(messages: { type: string; content: string }[]) {
|
|
223
|
-
|
|
224
|
-
const toolMessages = messages.map((message) => new HumanMessage(message.content));
|
|
225
|
-
this.messageHistory.push(...toolMessages);
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
async writeTypescripts(question: string, executor: Executor, options: EditOptions = {}) {
|
|
229
|
-
const content = await this.edit(question, options);
|
|
230
|
-
const writes = this.#getTypescriptCodes(content);
|
|
231
|
-
for (const write of writes) await executor.writeFile(write.filePath, write.content);
|
|
232
|
-
return await this.#tryFixTypescripts(writes, executor, options);
|
|
233
|
-
}
|
|
234
|
-
async #editTypescripts(question: string, options: EditOptions = {}) {
|
|
235
|
-
const content = await this.edit(question, options);
|
|
236
|
-
return this.#getTypescriptCodes(content);
|
|
237
|
-
}
|
|
238
|
-
async #tryFixTypescripts(writes: FileContent[], executor: Executor, options: EditOptions = {}) {
|
|
239
|
-
const MAX_EDIT_TRY = 5;
|
|
240
|
-
for (let tryCount = 0; tryCount < MAX_EDIT_TRY; tryCount++) {
|
|
241
|
-
const loader = new Spinner(`Type checking and linting...`, { prefix: `🤖akan-editor` }).start();
|
|
242
|
-
const fileChecks = await Promise.all(
|
|
243
|
-
writes.map(async ({ filePath }) => {
|
|
244
|
-
const typeCheckResult = executor.typeCheck(filePath);
|
|
245
|
-
const lintResult = await executor.lint(filePath);
|
|
246
|
-
const needFix = !!typeCheckResult.fileErrors.length || !!lintResult.errors.length;
|
|
247
|
-
return { filePath, typeCheckResult, lintResult, needFix };
|
|
248
|
-
}),
|
|
249
|
-
);
|
|
250
|
-
const needFix = fileChecks.some((fileCheck) => fileCheck.needFix);
|
|
251
|
-
if (needFix) {
|
|
252
|
-
loader.fail("Type checking and linting has some errors, try to fix them");
|
|
253
|
-
fileChecks.forEach((fileCheck) => {
|
|
254
|
-
Logger.rawLog(
|
|
255
|
-
`TypeCheck Result \n${fileCheck.typeCheckResult.message}\nLint Result \n${fileCheck.lintResult.message}`,
|
|
256
|
-
);
|
|
257
|
-
this.addToolMessgaes([
|
|
258
|
-
{ type: "typescript", content: fileCheck.typeCheckResult.message },
|
|
259
|
-
{ type: "eslint", content: fileCheck.lintResult.message },
|
|
260
|
-
]);
|
|
261
|
-
});
|
|
262
|
-
writes = await this.#editTypescripts("Fix the typescript and eslint errors", {
|
|
263
|
-
...options,
|
|
264
|
-
validate: undefined,
|
|
265
|
-
approve: true,
|
|
266
|
-
});
|
|
267
|
-
for (const write of writes) await executor.writeFile(write.filePath, write.content);
|
|
268
|
-
} else {
|
|
269
|
-
loader.succeed("Type checking and linting has no errors");
|
|
270
|
-
return writes;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
throw new Error("Failed to create scalar");
|
|
274
|
-
}
|
|
275
|
-
#getTypescriptCodes(text: string): FileContent[] {
|
|
276
|
-
const codes = text.match(/```(typescript|tsx)([\s\S]*?)```/g);
|
|
277
|
-
if (!codes) return [];
|
|
278
|
-
const result = codes.map((code) => {
|
|
279
|
-
const content = /```(typescript|tsx)([\s\S]*?)```/.exec(code)?.[2];
|
|
280
|
-
if (!content) return null;
|
|
281
|
-
const filePath = /\/\/ File: (.*?)(?:\n|$)/.exec(content)?.[1]?.trim();
|
|
282
|
-
if (!filePath) return null;
|
|
283
|
-
const contentWithoutFilepath = content.replace(`// File: ${filePath}\n`, "").trim();
|
|
284
|
-
return { filePath, content: contentWithoutFilepath };
|
|
285
|
-
});
|
|
286
|
-
return result.filter((code) => code !== null) as FileContent[];
|
|
287
|
-
}
|
|
288
|
-
async editMarkdown(request: string, options: EditOptions = {}) {
|
|
289
|
-
const content = await this.edit(request, options);
|
|
290
|
-
return this.#getMarkdownContent(content);
|
|
291
|
-
}
|
|
292
|
-
#getMarkdownContent(text: string) {
|
|
293
|
-
const searchText = "```markdown";
|
|
294
|
-
const firstIndex = text.indexOf("```markdown");
|
|
295
|
-
const lastIndex = text.lastIndexOf("```");
|
|
296
|
-
if (firstIndex === -1) return text;
|
|
297
|
-
else return text.slice(firstIndex + searchText.length, lastIndex).trim();
|
|
298
|
-
}
|
|
299
|
-
}
|