@credibledata/cred-cli 0.0.103 → 0.0.105
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.md +106 -1
- package/dist/agent-contract.spec.js +548 -0
- package/dist/agent-contract.spec.js.map +1 -0
- package/dist/browser.js +72 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.spec.js +125 -0
- package/dist/browser.spec.js.map +1 -0
- package/dist/client/api.js +4137 -1159
- package/dist/client/api.js.map +1 -1
- package/dist/client-codeassist/api.js +476 -0
- package/dist/client-codeassist/api.js.map +1 -0
- package/dist/client-codeassist/base.js +69 -0
- package/dist/client-codeassist/base.js.map +1 -0
- package/dist/client-codeassist/common.js +162 -0
- package/dist/client-codeassist/common.js.map +1 -0
- package/dist/client-codeassist/configuration.js +44 -0
- package/dist/client-codeassist/configuration.js.map +1 -0
- package/dist/client-codeassist/index.js +32 -0
- package/dist/client-codeassist/index.js.map +1 -0
- package/dist/clientconfiguration.js +17 -289
- package/dist/clientconfiguration.js.map +1 -1
- package/dist/clientconfiguration.spec.js +35 -96
- package/dist/clientconfiguration.spec.js.map +1 -1
- package/dist/commands/add.js +103 -3
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/add.spec.js +113 -0
- package/dist/commands/add.spec.js.map +1 -0
- package/dist/commands/connection/createconnections.js +104 -7
- package/dist/commands/connection/createconnections.js.map +1 -1
- package/dist/commands/connection/createconnections.spec.js +35 -1
- package/dist/commands/connection/createconnections.spec.js.map +1 -1
- package/dist/commands/connection/deleteconnection.js +4 -2
- package/dist/commands/connection/deleteconnection.js.map +1 -1
- package/dist/commands/connection/deleteconnection.spec.js +6 -1
- package/dist/commands/connection/deleteconnection.spec.js.map +1 -1
- package/dist/commands/connection/listconnections.js +2 -0
- package/dist/commands/connection/listconnections.js.map +1 -1
- package/dist/commands/connection/updateconnection.js +365 -0
- package/dist/commands/connection/updateconnection.js.map +1 -0
- package/dist/commands/connection/updateconnection.spec.js +625 -0
- package/dist/commands/connection/updateconnection.spec.js.map +1 -0
- package/dist/commands/database/createdatabase.js +52 -0
- package/dist/commands/database/createdatabase.js.map +1 -0
- package/dist/commands/database/database.spec.js +267 -0
- package/dist/commands/database/database.spec.js.map +1 -0
- package/dist/commands/database/deletedatabase.js +91 -0
- package/dist/commands/database/deletedatabase.js.map +1 -0
- package/dist/commands/database/getdatabase.js +97 -0
- package/dist/commands/database/getdatabase.js.map +1 -0
- package/dist/commands/database/listdatabases.js +36 -0
- package/dist/commands/database/listdatabases.js.map +1 -0
- package/dist/commands/database/shared.js +125 -0
- package/dist/commands/database/shared.js.map +1 -0
- package/dist/commands/database/shared.spec.js +109 -0
- package/dist/commands/database/shared.spec.js.map +1 -0
- package/dist/commands/database/updatedatabase.js +39 -0
- package/dist/commands/database/updatedatabase.js.map +1 -0
- package/dist/commands/environment/createenvironment.js +59 -28
- package/dist/commands/environment/createenvironment.js.map +1 -1
- package/dist/commands/environment/createenvironment.spec.js +29 -0
- package/dist/commands/environment/createenvironment.spec.js.map +1 -1
- package/dist/commands/environment/deleteenvironment.js +3 -2
- package/dist/commands/environment/deleteenvironment.js.map +1 -1
- package/dist/commands/environment/deleteenvironment.spec.js +5 -1
- package/dist/commands/environment/deleteenvironment.spec.js.map +1 -1
- package/dist/commands/environment/getenvironment.js +1 -0
- package/dist/commands/environment/getenvironment.js.map +1 -1
- package/dist/commands/environment/listenvironments.js +40 -8
- package/dist/commands/environment/listenvironments.js.map +1 -1
- package/dist/commands/environment/listenvironments.spec.js +41 -2
- package/dist/commands/environment/listenvironments.spec.js.map +1 -1
- package/dist/commands/environment/setenvironment.js +145 -6
- package/dist/commands/environment/setenvironment.js.map +1 -1
- package/dist/commands/environment/setenvironment.spec.js +256 -8
- package/dist/commands/environment/setenvironment.spec.js.map +1 -1
- package/dist/commands/environment/updateenvironment.js +12 -8
- package/dist/commands/environment/updateenvironment.js.map +1 -1
- package/dist/commands/environment/updateenvironment.spec.js +36 -2
- package/dist/commands/environment/updateenvironment.spec.js.map +1 -1
- package/dist/commands/get.js +64 -1
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/group/addmember.js +3 -1
- package/dist/commands/group/addmember.js.map +1 -1
- package/dist/commands/group/addmember.spec.js +7 -2
- package/dist/commands/group/addmember.spec.js.map +1 -1
- package/dist/commands/group/creategroup.js +2 -0
- package/dist/commands/group/creategroup.js.map +1 -1
- package/dist/commands/group/deletegroup.js +3 -1
- package/dist/commands/group/deletegroup.js.map +1 -1
- package/dist/commands/group/deletegroup.spec.js +7 -1
- package/dist/commands/group/deletegroup.spec.js.map +1 -1
- package/dist/commands/group/getgroup.js +2 -0
- package/dist/commands/group/getgroup.js.map +1 -1
- package/dist/commands/group/listgroups.js +2 -0
- package/dist/commands/group/listgroups.js.map +1 -1
- package/dist/commands/group/removemember.js +3 -1
- package/dist/commands/group/removemember.js.map +1 -1
- package/dist/commands/group/removemember.spec.js +7 -2
- package/dist/commands/group/removemember.spec.js.map +1 -1
- package/dist/commands/groupaccesstoken/deleteToken.js +2 -1
- package/dist/commands/groupaccesstoken/deleteToken.js.map +1 -1
- package/dist/commands/groupaccesstoken/groupContainer.js +2 -0
- package/dist/commands/groupaccesstoken/groupContainer.js.map +1 -1
- package/dist/commands/list.js +24 -4
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/materialization/cancelrun.js +3 -1
- package/dist/commands/materialization/cancelrun.js.map +1 -1
- package/dist/commands/materialization/getindex.js +2 -0
- package/dist/commands/materialization/getindex.js.map +1 -1
- package/dist/commands/materialization/getmaterialization.js +2 -0
- package/dist/commands/materialization/getmaterialization.js.map +1 -1
- package/dist/commands/materialization/getpreaggregate.js +2 -0
- package/dist/commands/materialization/getpreaggregate.js.map +1 -1
- package/dist/commands/materialization/getrun.js +2 -0
- package/dist/commands/materialization/getrun.js.map +1 -1
- package/dist/commands/materialization/listindexes.js +2 -0
- package/dist/commands/materialization/listindexes.js.map +1 -1
- package/dist/commands/materialization/listmaterializations.js +2 -0
- package/dist/commands/materialization/listmaterializations.js.map +1 -1
- package/dist/commands/materialization/listpreaggregates.js +2 -0
- package/dist/commands/materialization/listpreaggregates.js.map +1 -1
- package/dist/commands/materialization/listruns.js +3 -1
- package/dist/commands/materialization/listruns.js.map +1 -1
- package/dist/commands/materialization/rerun.js +3 -1
- package/dist/commands/materialization/rerun.js.map +1 -1
- package/dist/commands/misc/inquirerHost.js +87 -0
- package/dist/commands/misc/inquirerHost.js.map +1 -0
- package/dist/commands/misc/inquirerHost.spec.js +91 -0
- package/dist/commands/misc/inquirerHost.spec.js.map +1 -0
- package/dist/commands/misc/login.js +348 -58
- package/dist/commands/misc/login.js.map +1 -1
- package/dist/commands/misc/login.spec.js +525 -7
- package/dist/commands/misc/login.spec.js.map +1 -1
- package/dist/commands/misc/logout.js +26 -3
- package/dist/commands/misc/logout.js.map +1 -1
- package/dist/commands/misc/logout.spec.js +52 -12
- package/dist/commands/misc/logout.spec.js.map +1 -1
- package/dist/commands/misc/resolveLoginTarget.spec.js +90 -0
- package/dist/commands/misc/resolveLoginTarget.spec.js.map +1 -0
- package/dist/commands/misc/scope.spec.js +108 -0
- package/dist/commands/misc/scope.spec.js.map +1 -0
- package/dist/commands/misc/set-access-token.js +1 -1
- package/dist/commands/misc/set-access-token.js.map +1 -1
- package/dist/commands/misc/set-access-token.spec.js +13 -2
- package/dist/commands/misc/set-access-token.spec.js.map +1 -1
- package/dist/commands/misc/setup.js +819 -0
- package/dist/commands/misc/setup.js.map +1 -0
- package/dist/commands/misc/setup.spec.js +783 -0
- package/dist/commands/misc/setup.spec.js.map +1 -0
- package/dist/commands/misc/status.js +168 -0
- package/dist/commands/misc/status.js.map +1 -0
- package/dist/commands/misc/status.spec.js +301 -0
- package/dist/commands/misc/status.spec.js.map +1 -0
- package/dist/commands/misc/token.js +57 -0
- package/dist/commands/misc/token.js.map +1 -0
- package/dist/commands/misc/token.spec.js +92 -0
- package/dist/commands/misc/token.spec.js.map +1 -0
- package/dist/commands/package/deletepackage.js +4 -2
- package/dist/commands/package/deletepackage.js.map +1 -1
- package/dist/commands/package/deletepackage.spec.js +7 -1
- package/dist/commands/package/deletepackage.spec.js.map +1 -1
- package/dist/commands/package/getpackage.js +142 -0
- package/dist/commands/package/getpackage.js.map +1 -0
- package/dist/commands/package/getpackage.spec.js +246 -0
- package/dist/commands/package/getpackage.spec.js.map +1 -0
- package/dist/commands/package/listpackages.js +2 -0
- package/dist/commands/package/listpackages.js.map +1 -1
- package/dist/commands/package/publish.archive.spec.js +570 -0
- package/dist/commands/package/publish.archive.spec.js.map +1 -0
- package/dist/commands/package/publish.js +780 -49
- package/dist/commands/package/publish.js.map +1 -1
- package/dist/commands/package/publish.spec.js +451 -8
- package/dist/commands/package/publish.spec.js.map +1 -1
- package/dist/commands/package/updatepackage.js +22 -19
- package/dist/commands/package/updatepackage.js.map +1 -1
- package/dist/commands/package/updatepackage.spec.js +36 -1
- package/dist/commands/package/updatepackage.spec.js.map +1 -1
- package/dist/commands/permission/createpermission.js +3 -1
- package/dist/commands/permission/createpermission.js.map +1 -1
- package/dist/commands/permission/deletepermission.js +6 -3
- package/dist/commands/permission/deletepermission.js.map +1 -1
- package/dist/commands/permission/getpermission.js +2 -0
- package/dist/commands/permission/getpermission.js.map +1 -1
- package/dist/commands/permission/listpermissions.js +2 -0
- package/dist/commands/permission/listpermissions.js.map +1 -1
- package/dist/commands/rm.js +21 -0
- package/dist/commands/rm.js.map +1 -1
- package/dist/commands/set.js +40 -6
- package/dist/commands/set.js.map +1 -1
- package/dist/commands/set.spec.js +123 -0
- package/dist/commands/set.spec.js.map +1 -0
- package/dist/commands/table/addtable.js +155 -0
- package/dist/commands/table/addtable.js.map +1 -0
- package/dist/commands/table/deletetable.js +45 -0
- package/dist/commands/table/deletetable.js.map +1 -0
- package/dist/commands/table/gettable.js +32 -0
- package/dist/commands/table/gettable.js.map +1 -0
- package/dist/commands/table/listtables.js +36 -0
- package/dist/commands/table/listtables.js.map +1 -0
- package/dist/commands/table/table.spec.js +304 -0
- package/dist/commands/table/table.spec.js.map +1 -0
- package/dist/commands/table/tablefile.js +195 -0
- package/dist/commands/table/tablefile.js.map +1 -0
- package/dist/commands/table/tablefile.spec.js +158 -0
- package/dist/commands/table/tablefile.spec.js.map +1 -0
- package/dist/commands/update.js +21 -0
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/version/archive-unarchive-version.js +4 -2
- package/dist/commands/version/archive-unarchive-version.js.map +1 -1
- package/dist/commands/version/archive-unarchive-version.spec.js +6 -1
- package/dist/commands/version/archive-unarchive-version.spec.js.map +1 -1
- package/dist/commands/version/listversions.js +2 -0
- package/dist/commands/version/listversions.js.map +1 -1
- package/dist/common/UserGroupId.js +9 -4
- package/dist/common/UserGroupId.js.map +1 -1
- package/dist/common/UserGroupId.spec.js +5 -0
- package/dist/common/UserGroupId.spec.js.map +1 -1
- package/dist/constants.js +37 -143
- package/dist/constants.js.map +1 -1
- package/dist/index.js +487 -90
- package/dist/index.js.map +1 -1
- package/dist/logger.js +42 -9
- package/dist/logger.js.map +1 -1
- package/dist/session.js +56 -0
- package/dist/session.js.map +1 -0
- package/dist/session.spec.js +103 -0
- package/dist/session.spec.js.map +1 -0
- package/dist/setup-core/briefing.js +176 -0
- package/dist/setup-core/briefing.js.map +1 -0
- package/dist/setup-core/credstore.js +415 -0
- package/dist/setup-core/credstore.js.map +1 -0
- package/dist/setup-core/credstore.spec.js +238 -0
- package/dist/setup-core/credstore.spec.js.map +1 -0
- package/dist/setup-core/environments.js +267 -0
- package/dist/setup-core/environments.js.map +1 -0
- package/dist/setup-core/flow.e2e.js +165 -0
- package/dist/setup-core/flow.e2e.js.map +1 -0
- package/dist/setup-core/flow.js +765 -0
- package/dist/setup-core/flow.js.map +1 -0
- package/dist/setup-core/flow.spec.js +1348 -0
- package/dist/setup-core/flow.spec.js.map +1 -0
- package/dist/setup-core/folderconfig.js +283 -0
- package/dist/setup-core/folderconfig.js.map +1 -0
- package/dist/setup-core/git.js +97 -0
- package/dist/setup-core/git.js.map +1 -0
- package/dist/setup-core/host.js +77 -0
- package/dist/setup-core/host.js.map +1 -0
- package/dist/setup-core/importconnections.js +470 -0
- package/dist/setup-core/importconnections.js.map +1 -0
- package/dist/setup-core/importconnections.spec.js +594 -0
- package/dist/setup-core/importconnections.spec.js.map +1 -0
- package/dist/setup-core/liveness.js +94 -0
- package/dist/setup-core/liveness.js.map +1 -0
- package/dist/setup-core/liveness.spec.js +59 -0
- package/dist/setup-core/liveness.spec.js.map +1 -0
- package/dist/setup-core/localpublisherconfig.js +26 -0
- package/dist/setup-core/localpublisherconfig.js.map +1 -0
- package/dist/setup-core/localpublisherconfig.spec.js +29 -0
- package/dist/setup-core/localpublisherconfig.spec.js.map +1 -0
- package/dist/setup-core/mcpconfig.js +198 -0
- package/dist/setup-core/mcpconfig.js.map +1 -0
- package/dist/setup-core/mcpconfig.spec.js +205 -0
- package/dist/setup-core/mcpconfig.spec.js.map +1 -0
- package/dist/setup-core/packagemanifest.js +55 -0
- package/dist/setup-core/packagemanifest.js.map +1 -0
- package/dist/setup-core/ports.js +182 -0
- package/dist/setup-core/ports.js.map +1 -0
- package/dist/setup-core/ports.spec.js +173 -0
- package/dist/setup-core/ports.spec.js.map +1 -0
- package/dist/setup-core/publisherconfig.js +268 -0
- package/dist/setup-core/publisherconfig.js.map +1 -0
- package/dist/setup-core/publisherconfig.oracle.js +166 -0
- package/dist/setup-core/publisherconfig.oracle.js.map +1 -0
- package/dist/setup-core/publisherconfig.spec.js +277 -0
- package/dist/setup-core/publisherconfig.spec.js.map +1 -0
- package/dist/setup-core/publisherversion.js +26 -0
- package/dist/setup-core/publisherversion.js.map +1 -0
- package/dist/setup-core/readiness.spec.js +161 -0
- package/dist/setup-core/readiness.spec.js.map +1 -0
- package/dist/setup-core/readylines.js +169 -0
- package/dist/setup-core/readylines.js.map +1 -0
- package/dist/setup-core/readylines.spec.js +70 -0
- package/dist/setup-core/readylines.spec.js.map +1 -0
- package/dist/setup-core/refresh.js +348 -0
- package/dist/setup-core/refresh.js.map +1 -0
- package/dist/setup-core/refresh.spec.js +501 -0
- package/dist/setup-core/refresh.spec.js.map +1 -0
- package/dist/setup-core/skills.js +279 -0
- package/dist/setup-core/skills.js.map +1 -0
- package/dist/setup-core/skills.spec.js +334 -0
- package/dist/setup-core/skills.spec.js.map +1 -0
- package/dist/setup-core/supervisor.js +879 -0
- package/dist/setup-core/supervisor.js.map +1 -0
- package/dist/setup-core/supervisor.spec.js +833 -0
- package/dist/setup-core/supervisor.spec.js.map +1 -0
- package/dist/setup-core/writefile.js +61 -0
- package/dist/setup-core/writefile.js.map +1 -0
- package/dist/setup-core/writefile.spec.js +68 -0
- package/dist/setup-core/writefile.spec.js.map +1 -0
- package/dist/utils.js +409 -3
- package/dist/utils.js.map +1 -1
- package/dist/utils.spec.js +373 -2
- package/dist/utils.spec.js.map +1 -1
- package/dist/versioncheck-refresh.js +18 -0
- package/dist/versioncheck-refresh.js.map +1 -0
- package/dist/versioncheck.js +324 -0
- package/dist/versioncheck.js.map +1 -0
- package/dist/versioncheck.spec.js +587 -0
- package/dist/versioncheck.spec.js.map +1 -0
- package/node_modules/@credibledata/cli-auth/dist/index.d.ts +86 -0
- package/node_modules/@credibledata/cli-auth/dist/index.js +102 -0
- package/node_modules/@credibledata/cli-auth/package.json +19 -0
- package/package.json +18 -6
- package/.github/workflows/build.yml +0 -23
- package/.mocharc.json +0 -10
- package/.prettierignore +0 -2
- package/.prettierrc +0 -4
- package/README-DEV.md +0 -40
- package/coverage/coverage-summary.json +0 -40
- package/coverage/tmp/coverage-2152-1789496974457-0.json +0 -1
- package/coverage/tmp/coverage-2153-1789496954404-0.json +0 -1
- package/docker/Dockerfile.ci +0 -18
- package/docker-compose.yml +0 -18
- package/eslint.config.mjs +0 -45
- package/generate-client.sh +0 -27
- package/mocha.setup.ts +0 -4
- package/openapitools.json +0 -10
- package/src/client/.openapi-generator/FILES +0 -9
- package/src/client/.openapi-generator/VERSION +0 -1
- package/src/client/.openapi-generator-ignore +0 -23
- package/src/client/api.ts +0 -15999
- package/src/client/base.ts +0 -86
- package/src/client/common.ts +0 -150
- package/src/client/configuration.ts +0 -110
- package/src/client/git_push.sh +0 -57
- package/src/client/index.ts +0 -18
- package/src/clientconfiguration.spec.ts +0 -615
- package/src/clientconfiguration.ts +0 -364
- package/src/commands/add.ts +0 -191
- package/src/commands/connection/createconnections.spec.ts +0 -413
- package/src/commands/connection/createconnections.ts +0 -109
- package/src/commands/connection/deleteconnection.spec.ts +0 -189
- package/src/commands/connection/deleteconnection.ts +0 -57
- package/src/commands/connection/listconnections.spec.ts +0 -132
- package/src/commands/connection/listconnections.ts +0 -58
- package/src/commands/environment/createenvironment.spec.ts +0 -249
- package/src/commands/environment/createenvironment.ts +0 -73
- package/src/commands/environment/deleteenvironment.spec.ts +0 -152
- package/src/commands/environment/deleteenvironment.ts +0 -48
- package/src/commands/environment/getenvironment.spec.ts +0 -110
- package/src/commands/environment/getenvironment.ts +0 -43
- package/src/commands/environment/listenvironments.spec.ts +0 -123
- package/src/commands/environment/listenvironments.ts +0 -67
- package/src/commands/environment/setenvironment.spec.ts +0 -63
- package/src/commands/environment/setenvironment.ts +0 -14
- package/src/commands/environment/updateenvironment.spec.ts +0 -386
- package/src/commands/environment/updateenvironment.ts +0 -168
- package/src/commands/get.ts +0 -153
- package/src/commands/group/addmember.spec.ts +0 -257
- package/src/commands/group/addmember.ts +0 -85
- package/src/commands/group/creategroup.spec.ts +0 -146
- package/src/commands/group/creategroup.ts +0 -54
- package/src/commands/group/deletegroup.spec.ts +0 -120
- package/src/commands/group/deletegroup.ts +0 -45
- package/src/commands/group/getgroup.spec.ts +0 -129
- package/src/commands/group/getgroup.ts +0 -47
- package/src/commands/group/listgroups.spec.ts +0 -137
- package/src/commands/group/listgroups.ts +0 -45
- package/src/commands/group/removemember.spec.ts +0 -224
- package/src/commands/group/removemember.ts +0 -75
- package/src/commands/groupaccesstoken/createToken.spec.ts +0 -211
- package/src/commands/groupaccesstoken/createToken.ts +0 -72
- package/src/commands/groupaccesstoken/deleteToken.spec.ts +0 -147
- package/src/commands/groupaccesstoken/deleteToken.ts +0 -29
- package/src/commands/groupaccesstoken/groupContainer.ts +0 -83
- package/src/commands/groupaccesstoken/listTokens.spec.ts +0 -147
- package/src/commands/groupaccesstoken/listTokens.ts +0 -29
- package/src/commands/legacy.ts +0 -5
- package/src/commands/list.ts +0 -326
- package/src/commands/materialization/cancelrun.ts +0 -70
- package/src/commands/materialization/getindex.ts +0 -55
- package/src/commands/materialization/getmaterialization.ts +0 -57
- package/src/commands/materialization/getpreaggregate.ts +0 -58
- package/src/commands/materialization/getrun.ts +0 -55
- package/src/commands/materialization/listindexes.ts +0 -69
- package/src/commands/materialization/listmaterializations.ts +0 -53
- package/src/commands/materialization/listpreaggregates.ts +0 -74
- package/src/commands/materialization/listruns.ts +0 -77
- package/src/commands/materialization/rerun.ts +0 -123
- package/src/commands/misc/login.spec.ts +0 -371
- package/src/commands/misc/login.ts +0 -343
- package/src/commands/misc/logout.spec.ts +0 -32
- package/src/commands/misc/logout.ts +0 -9
- package/src/commands/misc/loopbackOAuth.ts +0 -127
- package/src/commands/misc/set-access-token.spec.ts +0 -95
- package/src/commands/misc/set-access-token.ts +0 -32
- package/src/commands/package/deletepackage.spec.ts +0 -164
- package/src/commands/package/deletepackage.ts +0 -58
- package/src/commands/package/listpackages.spec.ts +0 -163
- package/src/commands/package/listpackages.ts +0 -74
- package/src/commands/package/publish.spec.ts +0 -642
- package/src/commands/package/publish.ts +0 -236
- package/src/commands/package/updatepackage.spec.ts +0 -319
- package/src/commands/package/updatepackage.ts +0 -95
- package/src/commands/permission/createpermission.spec.ts +0 -507
- package/src/commands/permission/createpermission.ts +0 -181
- package/src/commands/permission/deletepermission.ts +0 -117
- package/src/commands/permission/getpermission.ts +0 -115
- package/src/commands/permission/listpermissions.ts +0 -101
- package/src/commands/permission/scope.ts +0 -180
- package/src/commands/rm.ts +0 -146
- package/src/commands/set.ts +0 -25
- package/src/commands/update.ts +0 -107
- package/src/commands/version/archive-unarchive-version.spec.ts +0 -456
- package/src/commands/version/archive-unarchive-version.ts +0 -108
- package/src/commands/version/listversions.spec.ts +0 -138
- package/src/commands/version/listversions.ts +0 -45
- package/src/common/UserGroupId.spec.ts +0 -115
- package/src/common/UserGroupId.ts +0 -137
- package/src/constants.spec.ts +0 -111
- package/src/constants.ts +0 -228
- package/src/index.ts +0 -378
- package/src/logger.spec.ts +0 -158
- package/src/logger.ts +0 -90
- package/src/polyfills/file.polyfill.ts +0 -6
- package/src/utils.spec.ts +0 -135
- package/src/utils.ts +0 -115
- package/src/validator.spec.ts +0 -51
- package/src/validator.ts +0 -44
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.resolveTarget = resolveTarget;
|
|
16
|
+
exports.scopeCommandToDirectory = scopeCommandToDirectory;
|
|
17
|
+
exports.refuseWriteUnderIgnoredPin = refuseWriteUnderIgnoredPin;
|
|
18
|
+
exports.credStoreToRefresh = credStoreToRefresh;
|
|
19
|
+
exports.needsNoSession = needsNoSession;
|
|
20
|
+
exports.describeIdentity = describeIdentity;
|
|
21
|
+
exports.pinnedIdentity = pinnedIdentity;
|
|
22
|
+
exports.listProxiedConnections = listProxiedConnections;
|
|
23
|
+
exports.parseConnectionsFlag = parseConnectionsFlag;
|
|
24
|
+
exports.parseSkillsFlag = parseSkillsFlag;
|
|
25
|
+
exports.parsePortFlag = parsePortFlag;
|
|
26
|
+
exports.setup = setup;
|
|
27
|
+
exports.dev = dev;
|
|
28
|
+
const path_1 = __importDefault(require("path"));
|
|
29
|
+
const kleur_1 = __importDefault(require("kleur"));
|
|
30
|
+
const axios_1 = require("axios");
|
|
31
|
+
const api_1 = require("../../client/api");
|
|
32
|
+
const shared_1 = require("../database/shared");
|
|
33
|
+
const configuration_1 = require("../../client/configuration");
|
|
34
|
+
const api_2 = require("../../client-codeassist/api");
|
|
35
|
+
const configuration_2 = require("../../client-codeassist/configuration");
|
|
36
|
+
const clientconfiguration_1 = require("../../clientconfiguration");
|
|
37
|
+
const createconnections_1 = require("../connection/createconnections");
|
|
38
|
+
const constants_1 = require("../../constants");
|
|
39
|
+
const logger_1 = require("../../logger");
|
|
40
|
+
const setenvironment_1 = require("../environment/setenvironment");
|
|
41
|
+
const login_1 = require("./login");
|
|
42
|
+
const utils_1 = require("../../utils");
|
|
43
|
+
const folderconfig_1 = require("../../setup-core/folderconfig");
|
|
44
|
+
const flow_1 = require("../../setup-core/flow");
|
|
45
|
+
const briefing_1 = require("../../setup-core/briefing");
|
|
46
|
+
const host_1 = require("../../setup-core/host");
|
|
47
|
+
const ports_1 = require("../../setup-core/ports");
|
|
48
|
+
const publisherversion_1 = require("../../setup-core/publisherversion");
|
|
49
|
+
const importconnections_1 = require("../../setup-core/importconnections");
|
|
50
|
+
const refresh_1 = require("../../setup-core/refresh");
|
|
51
|
+
const skills_1 = require("../../setup-core/skills");
|
|
52
|
+
const inquirerHost_1 = require("./inquirerHost");
|
|
53
|
+
/**
|
|
54
|
+
* `cred init` and `cred dev` — the terminal front door.
|
|
55
|
+
*
|
|
56
|
+
* Both are thin: they build a Host, resolve where the control plane is, and hand
|
|
57
|
+
* off to `setup-core`. Everything worth reviewing is in the library, because the
|
|
58
|
+
* VS Code extension will run exactly the same steps.
|
|
59
|
+
*/
|
|
60
|
+
const connectionsApi = new api_1.ConnectionsApi(new configuration_1.Configuration());
|
|
61
|
+
const codeAssistApi = new api_2.CodeAssistApi(new configuration_2.Configuration());
|
|
62
|
+
/**
|
|
63
|
+
* Which deployment these commands act against, and with whose credentials.
|
|
64
|
+
*
|
|
65
|
+
* `~/.cred` stores tokens, organization and Credible environment *per
|
|
66
|
+
* deployment*, so the deployment has to be resolved before the credential store
|
|
67
|
+
* is read — not after. The store takes the resolved value as an override so
|
|
68
|
+
* every read (token, org, environment) comes from the same deployment the
|
|
69
|
+
* control-plane calls go to; resolving one without the other is how you end up
|
|
70
|
+
* presenting a staging token to production.
|
|
71
|
+
*
|
|
72
|
+
* Precedence lives in {@link resolveDeployment}: `--cell`, the directory's
|
|
73
|
+
* `.credible/config.json` pin, then the global `~/.cred` value.
|
|
74
|
+
*/
|
|
75
|
+
function resolveTarget(cwd,
|
|
76
|
+
/** The global store; `~/.cred` unless a caller (a spec) supplies another. */
|
|
77
|
+
globalStore = new clientconfiguration_1.ClientConfiguration(), flag = (0, utils_1.cellFlag)()) {
|
|
78
|
+
const { deployment, from } = (0, folderconfig_1.resolveDeployment)({
|
|
79
|
+
cwd,
|
|
80
|
+
globalDefault: globalStore.getEnvironment(),
|
|
81
|
+
flag,
|
|
82
|
+
});
|
|
83
|
+
// Always pinned, even when the resolved deployment is the global one: the
|
|
84
|
+
// override then reads the same value the file would have given, so there is
|
|
85
|
+
// no second code path to reason about.
|
|
86
|
+
return {
|
|
87
|
+
deployment,
|
|
88
|
+
from,
|
|
89
|
+
credStore: globalStore.pinnedTo(deployment),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The command paths that run the publish action. `add version` is `publish`
|
|
94
|
+
* under its resource-shaped name.
|
|
95
|
+
*/
|
|
96
|
+
const PUBLISH_COMMANDS = new Set(["publish", "add version"]);
|
|
97
|
+
/**
|
|
98
|
+
* The commands that act on the deployment this directory is pinned to, by
|
|
99
|
+
* command path. Each one's action calls {@link resolveTarget}.
|
|
100
|
+
*/
|
|
101
|
+
const PINNED_COMMANDS = new Set([...PUBLISH_COMMANDS, "add connection"]);
|
|
102
|
+
/**
|
|
103
|
+
* The commands that do not take the directory's pin: they set or report the
|
|
104
|
+
* global identity, or resolve the pin themselves (`init`, `dev`, `status`,
|
|
105
|
+
* and the {@link PINNED_COMMANDS}, which print their own target line).
|
|
106
|
+
*/
|
|
107
|
+
const UNSCOPED_COMMANDS = new Set([
|
|
108
|
+
"login",
|
|
109
|
+
"logout",
|
|
110
|
+
"set-access-token",
|
|
111
|
+
"set",
|
|
112
|
+
"init",
|
|
113
|
+
"dev",
|
|
114
|
+
"status",
|
|
115
|
+
"help",
|
|
116
|
+
]);
|
|
117
|
+
/** Resources that belong to an organization and not to an environment. */
|
|
118
|
+
const ORG_ONLY_RESOURCES = new Set([
|
|
119
|
+
"group",
|
|
120
|
+
"groups",
|
|
121
|
+
"group-access-token",
|
|
122
|
+
"member",
|
|
123
|
+
]);
|
|
124
|
+
/**
|
|
125
|
+
* Scope every org- and environment-scoped command run in `cwd` to the
|
|
126
|
+
* directory's pin, and say so, the way `cred publish` already did. Returns the
|
|
127
|
+
* line printed, or undefined when there is no pin or the command is exempt.
|
|
128
|
+
*
|
|
129
|
+
* `cred set ...` stays global on purpose: it is how a user changes their
|
|
130
|
+
* default, and re-pinning a directory is `cred --cell <cell> init`. In a pinned
|
|
131
|
+
* directory it says so rather than appearing to do nothing.
|
|
132
|
+
*/
|
|
133
|
+
function scopeCommandToDirectory(commandPath, cwd, log) {
|
|
134
|
+
var _a, _b, _c, _d;
|
|
135
|
+
if (!commandPath)
|
|
136
|
+
return undefined;
|
|
137
|
+
const command = commandPath.split(" ")[0];
|
|
138
|
+
if (UNSCOPED_COMMANDS.has(command) && command !== "set")
|
|
139
|
+
return undefined;
|
|
140
|
+
const target = resolveTarget(cwd);
|
|
141
|
+
const identity = pinnedIdentity(cwd, target.credStore);
|
|
142
|
+
const pinned = identity.from === "folder" || target.from === "folder";
|
|
143
|
+
// Groups, their members and tokens belong to the organization alone, so
|
|
144
|
+
// naming an environment there would describe something the command ignores.
|
|
145
|
+
const orgOnly = ORG_ONLY_RESOURCES.has((_a = commandPath.split(" ")[1]) !== null && _a !== void 0 ? _a : "");
|
|
146
|
+
const where = describeIdentity(target.deployment, identity, identity.from, target.from, orgOnly ? "organization" : "environment");
|
|
147
|
+
if (command === "set") {
|
|
148
|
+
if (pinned) {
|
|
149
|
+
log(`This directory stays on ${where} \`cred set\` changes your global settings; \`cred --cell <cell> init\` re-pins this directory.`);
|
|
150
|
+
}
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
// Named in every confirmation, pinned or not: the global case is the one
|
|
154
|
+
// most likely to be wrong, as `describeIdentity` explains.
|
|
155
|
+
(0, utils_1.setCommandTarget)(orgOnly
|
|
156
|
+
? `organization ${(_b = identity.organization) !== null && _b !== void 0 ? _b : "?"} on ${target.deployment}`
|
|
157
|
+
: `${(_c = identity.organization) !== null && _c !== void 0 ? _c : "?"}/${(_d = identity.environment) !== null && _d !== void 0 ? _d : "?"} on ${target.deployment}`);
|
|
158
|
+
// These print their own "Publishing to …" line and resolve the pin
|
|
159
|
+
// themselves.
|
|
160
|
+
if (PINNED_COMMANDS.has(commandPath))
|
|
161
|
+
return undefined;
|
|
162
|
+
if (pinned) {
|
|
163
|
+
clientconfiguration_1.ClientConfiguration.scopeCommand({
|
|
164
|
+
deployment: target.deployment,
|
|
165
|
+
organization: identity.organization,
|
|
166
|
+
environment: identity.environment,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
// Every time, pinned or global, so an agent always has the line to check
|
|
170
|
+
// against the organization and environment it means.
|
|
171
|
+
const line = `Using ${where}`;
|
|
172
|
+
log(line);
|
|
173
|
+
return line;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Refuse a write whose `--cell` makes the directory's pin inert. Takes
|
|
177
|
+
* Commander's resolved command path: the argv heuristic that scopes reads
|
|
178
|
+
* reads `publish --replication 2` as `publish 2`.
|
|
179
|
+
*/
|
|
180
|
+
function refuseWriteUnderIgnoredPin(commandPath, cwd) {
|
|
181
|
+
if (!PINNED_COMMANDS.has(commandPath))
|
|
182
|
+
return;
|
|
183
|
+
const target = resolveTarget(cwd);
|
|
184
|
+
refuseIgnoredPin(commandPath, pinnedIdentity(cwd, target.credStore).ignoredPin, target.deployment);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The credential store the `preAction` refresh has to renew for a command.
|
|
188
|
+
*
|
|
189
|
+
* A pinned command sends the pinned deployment's token, so that is the one to
|
|
190
|
+
* check. Checking the global one instead failed `cred publish` with "not logged
|
|
191
|
+
* in" in a directory pinned to a deployment whose login was fine, whenever the
|
|
192
|
+
* global deployment's login had lapsed.
|
|
193
|
+
*/
|
|
194
|
+
function credStoreToRefresh(commandPath, cwd, globalStore) {
|
|
195
|
+
return PINNED_COMMANDS.has(commandPath)
|
|
196
|
+
? resolveTarget(cwd).credStore
|
|
197
|
+
: globalStore;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Whether the `preAction` refresh must skip this command: `publish --dry-run`
|
|
201
|
+
* (and `add version --dry-run`) uploads nothing and needs no login. Without
|
|
202
|
+
* this, a logged-out user's preview exited 1 before `publish` was reached.
|
|
203
|
+
*/
|
|
204
|
+
function needsNoSession(commandPath, options) {
|
|
205
|
+
return PUBLISH_COMMANDS.has(commandPath) && Boolean(options.dryRun);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Say where a command is about to act, and on whose say-so.
|
|
209
|
+
*
|
|
210
|
+
* Always, not only when a pin was involved. The silent case used to be the
|
|
211
|
+
* global fallback, which is exactly the one most likely to be wrong: `cred
|
|
212
|
+
* init` writes the settled organization and environment back to `~/.cred` as
|
|
213
|
+
* well as to the pin, so running init in `repo/pkg-a` moves the global too —
|
|
214
|
+
* and a later `cred publish` from an unpinned `repo/` picks those up and
|
|
215
|
+
* publishes to pkg-a's environment without a word. Naming the source is what
|
|
216
|
+
* makes that visible before the upload rather than after it.
|
|
217
|
+
*/
|
|
218
|
+
function describeIdentity(deployment, identity, from, deploymentFrom,
|
|
219
|
+
/** `organization` for a command that has no environment, such as groups. */
|
|
220
|
+
scope = "environment") {
|
|
221
|
+
var _a, _b, _c;
|
|
222
|
+
const where = from === "folder"
|
|
223
|
+
? "pinned in .credible/config.json"
|
|
224
|
+
: deploymentFrom === "flag"
|
|
225
|
+
? `set by --cell${identity.ignoredPin ? ` (this directory's pin to ${identity.ignoredPin} is ignored)` : ""}`
|
|
226
|
+
: // Names `cred init` and no flags: the callers, `publish` and
|
|
227
|
+
// `add connection`, have no --organization/--environment.
|
|
228
|
+
"from your global settings (~/.cred) — run `cred init` here to pin this directory";
|
|
229
|
+
const target = scope === "organization"
|
|
230
|
+
? `organization ${(_a = identity.organization) !== null && _a !== void 0 ? _a : "?"}`
|
|
231
|
+
: `${(_b = identity.organization) !== null && _b !== void 0 ? _b : "?"}/${(_c = identity.environment) !== null && _c !== void 0 ? _c : "?"}`;
|
|
232
|
+
return `${target} on ${deployment}, ${where}.`;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* The directory's pin, unless it is for another cell than `deployment`: its
|
|
236
|
+
* organization and environment name things in that cell, so `--cell` ignores
|
|
237
|
+
* them (and `ignoredPin` says which cell they were for).
|
|
238
|
+
*/
|
|
239
|
+
function pinFor(cwd, deployment) {
|
|
240
|
+
var _a;
|
|
241
|
+
const pinCell = (0, folderconfig_1.resolveDeployment)({ cwd, globalDefault: deployment });
|
|
242
|
+
if (pinCell.from === "folder" && pinCell.deployment !== deployment) {
|
|
243
|
+
return { ignoredPin: pinCell.deployment };
|
|
244
|
+
}
|
|
245
|
+
return { pin: (_a = (0, folderconfig_1.findFolderConfig)(cwd)) === null || _a === void 0 ? void 0 : _a.config };
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* `--cell` ignores a pin for another cell, so a write that followed it would
|
|
249
|
+
* act on an organization and environment the directory never named. `cred init`
|
|
250
|
+
* is the one explicit re-pin.
|
|
251
|
+
*/
|
|
252
|
+
function refuseIgnoredPin(command, ignoredPin, deployment) {
|
|
253
|
+
if (!ignoredPin)
|
|
254
|
+
return;
|
|
255
|
+
throw new host_1.SetupError(`\`cred ${command}\` writes, and this directory is pinned to ${ignoredPin}, not ${deployment}.`, `run \`cred --cell ${deployment} init\` to re-pin it on purpose, or drop --cell.`);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The organization and environment a command in `cwd` acts on: the directory's
|
|
259
|
+
* pin when there is one, else the global `~/.cred` value — the same precedence
|
|
260
|
+
* `init` and `dev` apply, minus flags. `cred publish` and the standalone
|
|
261
|
+
* connection import read this rather than the global value alone: a
|
|
262
|
+
* `cred add environment` in another tab moves the global, and a publish that
|
|
263
|
+
* followed it went to that environment while the pin named another.
|
|
264
|
+
*/
|
|
265
|
+
function pinnedIdentity(cwd, credStore) {
|
|
266
|
+
const { pin, ignoredPin } = pinFor(cwd, credStore.getEnvironment());
|
|
267
|
+
const resolved = (0, folderconfig_1.resolveIdentity)({
|
|
268
|
+
flag: {},
|
|
269
|
+
folder: {
|
|
270
|
+
organization: pin === null || pin === void 0 ? void 0 : pin.organization,
|
|
271
|
+
environment: pin === null || pin === void 0 ? void 0 : pin.environment,
|
|
272
|
+
},
|
|
273
|
+
global: {
|
|
274
|
+
organization: credStore.getOrganization(),
|
|
275
|
+
environment: credStore.getProject(),
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
return {
|
|
279
|
+
organization: resolved.organization.value,
|
|
280
|
+
environment: resolved.environment.value,
|
|
281
|
+
from: resolved.environment.from === "folder" ||
|
|
282
|
+
resolved.organization.from === "folder"
|
|
283
|
+
? "folder"
|
|
284
|
+
: "global",
|
|
285
|
+
ignoredPin,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function hasConnections(wired) {
|
|
289
|
+
return wired.config.environments[0].connections.length > 0;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The last line for an environment with no connections. Not "now open
|
|
293
|
+
* claude": the server is up, but every query an agent tries will fail.
|
|
294
|
+
*/
|
|
295
|
+
function servingWithoutConnections(uiUrl) {
|
|
296
|
+
return `Publisher is serving ${kleur_1.default.cyan(uiUrl)}, but the environment has no connections, so there is nothing to query yet. To fix it, ${briefing_1.NO_CONNECTIONS_NEXT_STEP}.`;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* What the local Publisher proxies: the environment's connections, then each
|
|
300
|
+
* `READY` database under its own name (database-design.md §12.5). A database
|
|
301
|
+
* is not on the connections list, but it is addressed through the same
|
|
302
|
+
* router route, so `buildPublisherConfig` gives it the same `connectionUriFor`
|
|
303
|
+
* and `@malloydata/db-publisher` needs no change.
|
|
304
|
+
*
|
|
305
|
+
* A 404 from `listDatabases` is a deployment without databases, so it adds
|
|
306
|
+
* none. Any other failure is a warning, not a failed `cred dev`: the
|
|
307
|
+
* connections alone still serve every model that does not read a database.
|
|
308
|
+
*/
|
|
309
|
+
function listProxiedConnections(controlPlane, credStore, organization, credibleEnvironment) {
|
|
310
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
311
|
+
var _a, _b, _c;
|
|
312
|
+
const options = { baseURL: controlPlane, headers: credStore.getHeaders() };
|
|
313
|
+
const connections = (_a = (yield connectionsApi.listConnections(organization, credibleEnvironment, -1, 0, options)).data) !== null && _a !== void 0 ? _a : [];
|
|
314
|
+
let databases = [];
|
|
315
|
+
try {
|
|
316
|
+
const listed = (_b = (yield shared_1.databasesApi.listDatabases(organization, credibleEnvironment, -1, 0, options)).data) !== null && _b !== void 0 ? _b : [];
|
|
317
|
+
databases = listed
|
|
318
|
+
.filter((database) => database.status === "READY")
|
|
319
|
+
.map((database) => ({ name: database.name }));
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
if (!((0, axios_1.isAxiosError)(error) && ((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) === 404)) {
|
|
323
|
+
logger_1.logger.warn(`Could not list the databases of '${credibleEnvironment}' (${(0, utils_1.describeApiError)(error)}), so the local Publisher has its connections only.`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const named = new Set(connections.map((c) => c.name));
|
|
327
|
+
return [
|
|
328
|
+
...connections,
|
|
329
|
+
...databases.filter((database) => !named.has(database.name)),
|
|
330
|
+
];
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
function buildContext(deployment, credStore, canOpenBrowser, identity) {
|
|
334
|
+
const controlPlane = constants_1.controlPlanesByEnv[deployment];
|
|
335
|
+
return {
|
|
336
|
+
host: (0, inquirerHost_1.createInquirerHost)({ canOpenBrowser, session: credStore }),
|
|
337
|
+
credStore,
|
|
338
|
+
deployment,
|
|
339
|
+
publisherVersion: publisherversion_1.PUBLISHER_VERSION,
|
|
340
|
+
cwd: process.cwd(),
|
|
341
|
+
showAllPublisherOutput: logger_1.debugRequested,
|
|
342
|
+
listConnections: (organization, credibleEnvironment) => listProxiedConnections(controlPlane, credStore, organization, credibleEnvironment),
|
|
343
|
+
// Bound to the pair `chooseTarget` settled, not read from the store at
|
|
344
|
+
// call time: another terminal's `cred set environment` while the
|
|
345
|
+
// credential question is open must not redirect the create.
|
|
346
|
+
createConnection: (0, createconnections_1.makeConnectionCreator)(controlPlane, credStore, {
|
|
347
|
+
organization: identity.organization,
|
|
348
|
+
environment: identity.credibleEnvironment,
|
|
349
|
+
}),
|
|
350
|
+
fetchSkills: (manifest) => __awaiter(this, void 0, void 0, function* () {
|
|
351
|
+
var _a;
|
|
352
|
+
try {
|
|
353
|
+
const response = yield codeAssistApi.getAgentSkills(manifest, undefined, undefined, {
|
|
354
|
+
baseURL: constants_1.codeAssistByEnv[deployment],
|
|
355
|
+
headers: credStore.getHeaders(),
|
|
356
|
+
});
|
|
357
|
+
return response.data;
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
// A deployment without the endpoint has no skills to offer; that
|
|
361
|
+
// is a skip, not a failure. Anything else is reported by the flow.
|
|
362
|
+
if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
throw new Error((0, utils_1.describeApiError)(error));
|
|
366
|
+
}
|
|
367
|
+
}),
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Parse `--connections`. Anything but the two keywords is a name list.
|
|
372
|
+
*
|
|
373
|
+
* Empty names (`a,,b`, a trailing comma) are dropped rather than passed on as
|
|
374
|
+
* a lookup for `''` that fails with a confusing "no connection named ''".
|
|
375
|
+
*/
|
|
376
|
+
function parseConnectionsFlag(value) {
|
|
377
|
+
if (value === undefined)
|
|
378
|
+
return undefined;
|
|
379
|
+
const trimmed = value.trim();
|
|
380
|
+
if (trimmed === "all" || trimmed === "none")
|
|
381
|
+
return trimmed;
|
|
382
|
+
const names = trimmed
|
|
383
|
+
.split(",")
|
|
384
|
+
.map((name) => name.trim())
|
|
385
|
+
.filter(Boolean);
|
|
386
|
+
if (names.length === 0) {
|
|
387
|
+
throw new host_1.UsageError(`${importconnections_1.CONNECTIONS_FLAG} was given '${value}', which names nothing.`, "pass all, none, or a comma-separated list of connection names.");
|
|
388
|
+
}
|
|
389
|
+
return names;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Report a SetupError as its message, and anything else as itself.
|
|
393
|
+
*
|
|
394
|
+
* A question that could not be asked exits 2, not 1: it is the one failure a
|
|
395
|
+
* caller can fix by re-running with the flag the message names, and a script
|
|
396
|
+
* needs to tell that apart from "setup broke".
|
|
397
|
+
*/
|
|
398
|
+
function reportAndExit(error) {
|
|
399
|
+
if (error instanceof host_1.NeedsInputError) {
|
|
400
|
+
logger_1.logger.error(error.message);
|
|
401
|
+
process.exit(error.exitCode);
|
|
402
|
+
}
|
|
403
|
+
if (error instanceof host_1.ReportedSetupError) {
|
|
404
|
+
process.exit(1);
|
|
405
|
+
}
|
|
406
|
+
if (error instanceof host_1.UsageError) {
|
|
407
|
+
logger_1.logger.error(error.message);
|
|
408
|
+
process.exit(error.exitCode);
|
|
409
|
+
}
|
|
410
|
+
if (error instanceof host_1.SetupError) {
|
|
411
|
+
logger_1.logger.error(error.message);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
logger_1.logger.error(error instanceof Error ? error.message : String(error));
|
|
415
|
+
}
|
|
416
|
+
process.exit(1);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Make sure we are logged in with an organization and an environment, prompting
|
|
420
|
+
* for whatever is missing.
|
|
421
|
+
*
|
|
422
|
+
* This is what makes `cred init` the single command a new user is told to type.
|
|
423
|
+
* `cred login` and `cred set environment` still exist — they are what you run
|
|
424
|
+
* *again* — but a first-time user should not have to know they come first, and
|
|
425
|
+
* should certainly not learn it from an error message.
|
|
426
|
+
*
|
|
427
|
+
* This is also why `init` and `dev` are exempt from the global token-refresh
|
|
428
|
+
* hook in `index.ts`: that hook exits the process when it finds no credentials,
|
|
429
|
+
* which for these two commands is the state they exist to resolve. They do their
|
|
430
|
+
* own refresh here instead — a spent-but-refreshable token has to renew silently
|
|
431
|
+
* rather than trigger a browser round-trip, since the `listConnections` call in
|
|
432
|
+
* `wireDirectory` needs a live token either way.
|
|
433
|
+
*
|
|
434
|
+
* `organization` is the one already known — `--organization`, else the pin's.
|
|
435
|
+
* Dropping it failed every AWS login (its tenant needs the organization up
|
|
436
|
+
* front) and, on GCP, opened the organization picker, which exits 2 without a
|
|
437
|
+
* terminal even when `-o` named it.
|
|
438
|
+
*/
|
|
439
|
+
function ensureLoggedIn(credStore, organization) {
|
|
440
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
441
|
+
const refreshed = yield (0, refresh_1.ensureFreshTokens)(credStore);
|
|
442
|
+
if (refreshed.status === "offline" || refreshed.status === "not-renewable") {
|
|
443
|
+
logger_1.logger.warn(refreshed.reason);
|
|
444
|
+
}
|
|
445
|
+
const needsLogin = refreshed.status === "logged-out" || !credStore.isTokenValid().valid;
|
|
446
|
+
if (needsLogin) {
|
|
447
|
+
logger_1.logger.info("You are not logged in yet — starting that now.");
|
|
448
|
+
const currentEnv = credStore.getEnvironment();
|
|
449
|
+
// The cluster is this deployment's, asked for explicitly: named alone,
|
|
450
|
+
// an organization picks its own default cluster, which can be another
|
|
451
|
+
// deployment's (videoamp defaults to gcp), and the tokens would land in
|
|
452
|
+
// a slot nothing here reads.
|
|
453
|
+
let target;
|
|
454
|
+
try {
|
|
455
|
+
target = (0, login_1.resolveLoginTarget)(currentEnv, organization, constants_1.CLUSTER_BY_ENVIRONMENT[currentEnv]);
|
|
456
|
+
}
|
|
457
|
+
catch (error) {
|
|
458
|
+
throw new host_1.SetupError(error instanceof Error ? error.message : String(error));
|
|
459
|
+
}
|
|
460
|
+
yield (0, login_1.login)(organization, constants_1.controlPlanesByEnv[target.targetEnv], undefined, target.cluster,
|
|
461
|
+
// The deployment `credStore` is scoped to. Without it login writes the
|
|
462
|
+
// tokens and organization under the file's global `activeEnvironment`,
|
|
463
|
+
// and the `getOrganization()` check below then reads a slot login
|
|
464
|
+
// never touched — so a directory pinned to a non-global deployment,
|
|
465
|
+
// the case the pin exists for, failed its own first run.
|
|
466
|
+
target.targetEnv);
|
|
467
|
+
}
|
|
468
|
+
if (!credStore.getOrganization()) {
|
|
469
|
+
// login() persists the organization it resolved, so reaching here means
|
|
470
|
+
// login did not complete. Its own output already said why.
|
|
471
|
+
throw new host_1.SetupError("Setup needs an organization and login did not finish.", "run `cred login` and try again.");
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Establish which organization and Credible environment this directory is for.
|
|
477
|
+
*
|
|
478
|
+
* These two values are baked into `.mcp.json`, the agent briefing and the
|
|
479
|
+
* publisher config, and they are the expensive ones to get wrong: a directory
|
|
480
|
+
* wired against the wrong environment looks completely normal until someone
|
|
481
|
+
* queries it.
|
|
482
|
+
*
|
|
483
|
+
* Resolution order is {@link resolveIdentity}'s: a flag, then this directory's
|
|
484
|
+
* pin, then the global `~/.cred` value. What each mode does with the result:
|
|
485
|
+
*
|
|
486
|
+
* - `always-ask` (`init`) asks unless a flag settled it. It is the
|
|
487
|
+
* once-per-directory command, and `selectFromList` skips a prompt with one
|
|
488
|
+
* option, so a single-organization user sees no extra step anyway.
|
|
489
|
+
* - `confirm` (`dev`) states what the pin says and takes a yes, opening the
|
|
490
|
+
* pickers on a no. A flag skips the question and re-pins, which is how
|
|
491
|
+
* `cred dev --environment staging` switches a directory over.
|
|
492
|
+
*
|
|
493
|
+
* Whatever is settled is written back to the directory's pin by
|
|
494
|
+
* {@link wireDirectory}, and to `~/.cred` here so unrelated commands
|
|
495
|
+
* (`cred publish`) act on the same pair.
|
|
496
|
+
*/
|
|
497
|
+
function chooseTarget(credStore, deployment, mode, flags, cwd) {
|
|
498
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
499
|
+
const controlPlane = constants_1.controlPlanesByEnv[deployment];
|
|
500
|
+
const { pin } = pinFor(cwd, deployment);
|
|
501
|
+
const resolved = (0, folderconfig_1.resolveIdentity)({
|
|
502
|
+
flag: flags,
|
|
503
|
+
folder: {
|
|
504
|
+
organization: pin === null || pin === void 0 ? void 0 : pin.organization,
|
|
505
|
+
environment: pin === null || pin === void 0 ? void 0 : pin.environment,
|
|
506
|
+
},
|
|
507
|
+
global: {
|
|
508
|
+
organization: credStore.getOrganization(),
|
|
509
|
+
environment: credStore.getProject(),
|
|
510
|
+
},
|
|
511
|
+
});
|
|
512
|
+
// A flag is an instruction, not a suggestion, so it is never confirmed. It is
|
|
513
|
+
// also the only path a script can take, and a script cannot answer a prompt.
|
|
514
|
+
//
|
|
515
|
+
// Either flag suppresses the confirmation, not both together. The shortcut
|
|
516
|
+
// below persists what it confirms *without validating it*, so with one flag
|
|
517
|
+
// set it read the flag's value back out of `resolveIdentity`, put it in the
|
|
518
|
+
// prompt, and wrote a yes straight to disk — which is how `cred dev
|
|
519
|
+
// --environment stagng` re-pinned a directory to a typo and then failed
|
|
520
|
+
// somewhere far from the cause. A named value goes through `setEnvironment`.
|
|
521
|
+
const flagged = resolved.organization.from === "flag" ||
|
|
522
|
+
resolved.environment.from === "flag";
|
|
523
|
+
// A "no" to the confirmation below. `settleTarget` in `confirm` mode keeps
|
|
524
|
+
// the resolved pair, so without this a decline re-wired the very pair the
|
|
525
|
+
// user had just turned down.
|
|
526
|
+
let declined = false;
|
|
527
|
+
if (!flagged && mode === "confirm") {
|
|
528
|
+
const { value: organization } = resolved.organization;
|
|
529
|
+
const { value: environment } = resolved.environment;
|
|
530
|
+
if (organization && environment) {
|
|
531
|
+
// The confirm re-states recorded state, so without a terminal it is
|
|
532
|
+
// taken as a yes rather than refused: `cred dev` in an agent's shell
|
|
533
|
+
// must start the publisher, not exit asking for a flag that would
|
|
534
|
+
// only repeat what the pin already says. `--yes` is the same answer
|
|
535
|
+
// given on purpose.
|
|
536
|
+
// Taken as a yes silently: `dev` has already printed the target line
|
|
537
|
+
// every scoped command prints, so saying it again here repeated it.
|
|
538
|
+
const keep = flags.yes || !(0, utils_1.isInteractive)()
|
|
539
|
+
? true
|
|
540
|
+
: yield (0, utils_1.getConfirmation)(`Use organization ${kleur_1.default.cyan(organization)} and environment ${kleur_1.default.cyan(environment)}?`, credStore, { flag: "--yes" });
|
|
541
|
+
if (keep)
|
|
542
|
+
return persist(credStore, organization, environment);
|
|
543
|
+
declined = true;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
// `~/.cred` gets the settled pair or nothing. The organization has to be in
|
|
547
|
+
// the store before `setEnvironment` can list its environments, so a refused
|
|
548
|
+
// environment would otherwise leave the new organization beside the old
|
|
549
|
+
// environment — a pair nobody chose, which the next unpinned `cred publish`
|
|
550
|
+
// targets.
|
|
551
|
+
const before = {
|
|
552
|
+
organization: credStore.getOrganization(),
|
|
553
|
+
environment: credStore.getProject(),
|
|
554
|
+
};
|
|
555
|
+
const restore = () => {
|
|
556
|
+
credStore.setOrganization(before.organization);
|
|
557
|
+
credStore.setProject(before.environment);
|
|
558
|
+
};
|
|
559
|
+
// Ctrl-C at a picker does not throw. Inquirer closes the prompt and re-raises
|
|
560
|
+
// SIGINT at the process, and nothing else is listening yet (the supervisor
|
|
561
|
+
// subscribes once it spawns), so Node exited with the new organization and
|
|
562
|
+
// no environment on disk. Listening here is also what keeps Node from
|
|
563
|
+
// exiting on its own, so this handler has to exit.
|
|
564
|
+
const onSignal = (signal) => {
|
|
565
|
+
restore();
|
|
566
|
+
process.exit(signal === "SIGINT" ? 130 : 1);
|
|
567
|
+
};
|
|
568
|
+
for (const signal of inquirerHost_1.INTERRUPTS)
|
|
569
|
+
process.once(signal, onSignal);
|
|
570
|
+
try {
|
|
571
|
+
return yield settleTarget(credStore, controlPlane, declined ? "always-ask" : mode, flags, resolved);
|
|
572
|
+
}
|
|
573
|
+
catch (error) {
|
|
574
|
+
restore();
|
|
575
|
+
throw error;
|
|
576
|
+
}
|
|
577
|
+
finally {
|
|
578
|
+
for (const signal of inquirerHost_1.INTERRUPTS)
|
|
579
|
+
process.off(signal, onSignal);
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
/** The part of {@link chooseTarget} that writes to the store as it goes. */
|
|
584
|
+
function settleTarget(credStore, controlPlane, mode, flags, resolved) {
|
|
585
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
586
|
+
var _a, _b;
|
|
587
|
+
// `confirm` mode keeps the organization it already resolved rather than
|
|
588
|
+
// re-asking: `cred dev --environment other-bars` is a request to change the
|
|
589
|
+
// environment, and answering an organization picker to do it would be a
|
|
590
|
+
// question the user has already answered once for this directory.
|
|
591
|
+
const organization = (_b = (_a = flags.organization) !== null && _a !== void 0 ? _a : (mode === "confirm" ? resolved.organization.value : undefined)) !== null && _b !== void 0 ? _b :
|
|
592
|
+
// `cred init` and `cred dev` both take `--organization`; the default
|
|
593
|
+
// hint names `cred login <organization>`, a different command.
|
|
594
|
+
(yield (0, login_1.resolveOrganization)(undefined, controlPlane, credStore, "--organization <name>"));
|
|
595
|
+
credStore.setOrganization(organization);
|
|
596
|
+
// Both front doors take `--create-environment`. `dev` once pointed at
|
|
597
|
+
// `cred add environment` instead, which creates on the pin's organization:
|
|
598
|
+
// wrong after `cred dev -o other-org`, where this is the one that is meant.
|
|
599
|
+
const hints = setenvironment_1.INIT_ENVIRONMENT_HINTS;
|
|
600
|
+
// The name we asked for, when we named one, for the message below. Left
|
|
601
|
+
// undefined for the picker, whose answer we do not know in advance.
|
|
602
|
+
let requested;
|
|
603
|
+
let accepted;
|
|
604
|
+
if (flags.environment) {
|
|
605
|
+
// Validated rather than trusted: `setEnvironment` refuses a name the
|
|
606
|
+
// organization does not have, and a typo caught here is one that does not
|
|
607
|
+
// reach the publisher config as a dead connectionUri.
|
|
608
|
+
requested = flags.environment;
|
|
609
|
+
accepted = yield (0, setenvironment_1.setEnvironment)(flags.environment, credStore, {
|
|
610
|
+
createIfMissing: flags.createEnvironment,
|
|
611
|
+
hints,
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
else if (mode === "always-ask" || !resolved.environment.value) {
|
|
615
|
+
// Cleared first so the picker is a real choice rather than a confirmation
|
|
616
|
+
// of a stale value. `undefined`, not `""`: an empty string survives
|
|
617
|
+
// `getProject() ?? "Not set"` in `cred status` and prints a blank line,
|
|
618
|
+
// so an interrupted setup would report differently from every other
|
|
619
|
+
// unset-environment path.
|
|
620
|
+
const current = credStore.getProject();
|
|
621
|
+
credStore.setProject(undefined);
|
|
622
|
+
accepted = yield (0, setenvironment_1.setEnvironment)(undefined, credStore, {
|
|
623
|
+
current,
|
|
624
|
+
hints,
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
requested = resolved.environment.value;
|
|
629
|
+
accepted = yield (0, setenvironment_1.setEnvironment)(requested, credStore, {
|
|
630
|
+
hints,
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
// Asked, not inferred from the store. `setEnvironment` refuses a name by
|
|
634
|
+
// returning without writing, and the store can still hold that same name
|
|
635
|
+
// from before: `cred dev --organization other-org` keeps the pin's
|
|
636
|
+
// environment name, and when other-org lacks it the old value matched and
|
|
637
|
+
// the directory was re-pinned to an environment its organization does not
|
|
638
|
+
// have.
|
|
639
|
+
const chosen = credStore.getProject();
|
|
640
|
+
if (!accepted) {
|
|
641
|
+
// `setEnvironment` has already logged what went wrong and how to fix it,
|
|
642
|
+
// in this front door's own hints; saying it again printed two errors.
|
|
643
|
+
throw new host_1.ReportedSetupError("Setup needs a Credible environment.");
|
|
644
|
+
}
|
|
645
|
+
if (!chosen) {
|
|
646
|
+
throw new host_1.SetupError("Setup needs a Credible environment.", requested
|
|
647
|
+
? `check the name '${requested}', or pass --create-environment to create it.`
|
|
648
|
+
: `re-run \`cred ${mode === "confirm" ? "dev" : "init"}\` and pick or create one, or pass --environment <name> [--create-environment].`);
|
|
649
|
+
}
|
|
650
|
+
return { organization, credibleEnvironment: chosen };
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
/** Record the settled pair globally, and hand it back for the flow to pin. */
|
|
654
|
+
function persist(credStore, organization, credibleEnvironment) {
|
|
655
|
+
credStore.setOrganization(organization);
|
|
656
|
+
credStore.setProject(credibleEnvironment);
|
|
657
|
+
return { organization, credibleEnvironment };
|
|
658
|
+
}
|
|
659
|
+
/** Parse `--skills`. A value outside the three is refused, never guessed at. */
|
|
660
|
+
function parseSkillsFlag(value) {
|
|
661
|
+
if (value === undefined)
|
|
662
|
+
return undefined;
|
|
663
|
+
if (value === "replace" || value === "keep" || value === "none")
|
|
664
|
+
return value;
|
|
665
|
+
throw new host_1.UsageError(`${skills_1.SKILLS_FLAG} was given '${value}'.`, "pass replace, keep, or none.");
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Parse `--port`. Refused unless it is a whole number whose MCP partner, 40
|
|
669
|
+
* above it, is a valid port too; never rounded or clamped into one.
|
|
670
|
+
*/
|
|
671
|
+
function parsePortFlag(value) {
|
|
672
|
+
if (value === undefined)
|
|
673
|
+
return undefined;
|
|
674
|
+
const port = Number(value);
|
|
675
|
+
if (!/^\d+$/.test(value) || port < ports_1.MIN_UI_PORT || port > ports_1.MAX_UI_PORT) {
|
|
676
|
+
throw new host_1.UsageError(`${flow_1.PORT_FLAG} was given '${value}'.`, `pass a whole number from ${ports_1.MIN_UI_PORT} to ${ports_1.MAX_UI_PORT}; the MCP server takes the port ${ports_1.MCP_OFFSET} above it. Example: ${flow_1.PORT_FLAG} 4100.`);
|
|
677
|
+
}
|
|
678
|
+
return port;
|
|
679
|
+
}
|
|
680
|
+
function setup(options) {
|
|
681
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
682
|
+
var _a, _b, _c, _d, _e, _f;
|
|
683
|
+
let target;
|
|
684
|
+
try {
|
|
685
|
+
target = resolveTarget((_a = options.directory) !== null && _a !== void 0 ? _a : process.cwd());
|
|
686
|
+
}
|
|
687
|
+
catch (error) {
|
|
688
|
+
reportAndExit(error);
|
|
689
|
+
}
|
|
690
|
+
const { deployment, credStore } = target;
|
|
691
|
+
try {
|
|
692
|
+
// Before logging in or choosing an environment, both of which write.
|
|
693
|
+
(0, flow_1.refuseUnanswerable)(path_1.default.resolve((_b = options.directory) !== null && _b !== void 0 ? _b : process.cwd()), {
|
|
694
|
+
connections: parseConnectionsFlag(options.connections),
|
|
695
|
+
skills: parseSkillsFlag(options.skills),
|
|
696
|
+
package: options.package,
|
|
697
|
+
}, (0, utils_1.isInteractive)());
|
|
698
|
+
const port = parsePortFlag(options.port);
|
|
699
|
+
// A chosen --port is checked even with --no-start: it rewrites the pin
|
|
700
|
+
// and .mcp.json, so a busy or conflicting pair is refused up front.
|
|
701
|
+
if (options.start || port !== undefined) {
|
|
702
|
+
yield (0, flow_1.refuseBesideOtherPublisher)(path_1.default.resolve((_c = options.directory) !== null && _c !== void 0 ? _c : process.cwd()), port);
|
|
703
|
+
}
|
|
704
|
+
const { pin, ignoredPin } = pinFor((_d = options.directory) !== null && _d !== void 0 ? _d : process.cwd(), deployment);
|
|
705
|
+
if (ignoredPin) {
|
|
706
|
+
logger_1.logger.info(`re-pinning this directory from ${ignoredPin} to ${deployment}`);
|
|
707
|
+
}
|
|
708
|
+
yield ensureLoggedIn(credStore, (_e = options.organization) !== null && _e !== void 0 ? _e : pin === null || pin === void 0 ? void 0 : pin.organization);
|
|
709
|
+
const identity = yield chooseTarget(credStore, deployment, "always-ask", {
|
|
710
|
+
organization: options.organization,
|
|
711
|
+
environment: options.environment,
|
|
712
|
+
createEnvironment: options.createEnvironment,
|
|
713
|
+
}, (_f = options.directory) !== null && _f !== void 0 ? _f : process.cwd());
|
|
714
|
+
const context = buildContext(deployment, credStore, options.open, identity);
|
|
715
|
+
const { wired, running } = yield (0, flow_1.runSetup)(context, Object.assign(Object.assign(Object.assign({}, options), identity), { connections: parseConnectionsFlag(options.connections), skills: parseSkillsFlag(options.skills), port }));
|
|
716
|
+
if (!running)
|
|
717
|
+
return;
|
|
718
|
+
// The one next step, printed once, immediately before the server's own
|
|
719
|
+
// output takes over the tab.
|
|
720
|
+
logger_1.logger.info(hasConnections(wired)
|
|
721
|
+
? `Publisher is serving ${kleur_1.default.cyan(running.uiUrl)} — now open ${kleur_1.default.bold("claude")} in another tab.`
|
|
722
|
+
: servingWithoutConnections(running.uiUrl));
|
|
723
|
+
yield waitUntilStopped(running);
|
|
724
|
+
}
|
|
725
|
+
catch (error) {
|
|
726
|
+
reportAndExit(error);
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
function dev(options) {
|
|
731
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
732
|
+
var _a, _b;
|
|
733
|
+
const cwd = process.cwd();
|
|
734
|
+
const found = (0, folderconfig_1.findFolderConfig)(cwd);
|
|
735
|
+
if (!found) {
|
|
736
|
+
logger_1.logger.error("This directory is not set up for Credible yet. Run `cred init` here first.");
|
|
737
|
+
process.exit(1);
|
|
738
|
+
}
|
|
739
|
+
let target;
|
|
740
|
+
try {
|
|
741
|
+
target = resolveTarget(cwd);
|
|
742
|
+
}
|
|
743
|
+
catch (error) {
|
|
744
|
+
reportAndExit(error);
|
|
745
|
+
}
|
|
746
|
+
const { deployment, credStore, from } = target;
|
|
747
|
+
// The same line every scoped command prints, so `cred dev` is checked the
|
|
748
|
+
// same way. The pin's organization and environment, before any `-o`/`-e`.
|
|
749
|
+
const pinned = pinnedIdentity(cwd, credStore);
|
|
750
|
+
try {
|
|
751
|
+
// Before login: wiring would rewrite .mcp.json and the briefing too.
|
|
752
|
+
refuseIgnoredPin("dev", pinned.ignoredPin, deployment);
|
|
753
|
+
}
|
|
754
|
+
catch (error) {
|
|
755
|
+
reportAndExit(error);
|
|
756
|
+
}
|
|
757
|
+
logger_1.logger.info(`Using ${describeIdentity(deployment, pinned, pinned.from, from)}`);
|
|
758
|
+
try {
|
|
759
|
+
// The same gate as init's, before login and the environment write. `dev`
|
|
760
|
+
// never imports connections, so there is no connections question to ask.
|
|
761
|
+
(0, flow_1.refuseUnanswerable)(found.root, {
|
|
762
|
+
connections: "none",
|
|
763
|
+
skills: parseSkillsFlag(options.skills),
|
|
764
|
+
package: options.package,
|
|
765
|
+
}, (0, utils_1.isInteractive)());
|
|
766
|
+
const port = parsePortFlag(options.port);
|
|
767
|
+
yield (0, flow_1.refuseBesideOtherPublisher)(found.root, port);
|
|
768
|
+
yield ensureLoggedIn(credStore, (_a = options.organization) !== null && _a !== void 0 ? _a : (_b = pinFor(cwd, deployment).pin) === null || _b === void 0 ? void 0 : _b.organization);
|
|
769
|
+
const identity = yield chooseTarget(credStore, deployment, "confirm", {
|
|
770
|
+
organization: options.organization,
|
|
771
|
+
environment: options.environment,
|
|
772
|
+
createEnvironment: options.createEnvironment,
|
|
773
|
+
yes: options.yes,
|
|
774
|
+
}, found.root);
|
|
775
|
+
const context = buildContext(deployment, credStore, options.open, identity);
|
|
776
|
+
// Re-wire rather than replay: connections may have changed in Credible
|
|
777
|
+
// since setup ran, and picking that up is cheaper than making the user
|
|
778
|
+
// notice a missing connection and re-run setup.
|
|
779
|
+
const wired = yield (0, flow_1.wireDirectory)(context, Object.assign(Object.assign({ directory: found.root }, identity), { skipConnectionImport: true, package: options.package, skills: parseSkillsFlag(options.skills), port, start: true, open: options.open }));
|
|
780
|
+
const running = yield (0, flow_1.startSession)(context, wired, {
|
|
781
|
+
open: options.open,
|
|
782
|
+
});
|
|
783
|
+
logger_1.logger.info(hasConnections(wired)
|
|
784
|
+
? `Publisher is serving ${kleur_1.default.cyan(running.uiUrl)}.`
|
|
785
|
+
: servingWithoutConnections(running.uiUrl));
|
|
786
|
+
yield waitUntilStopped(running);
|
|
787
|
+
}
|
|
788
|
+
catch (error) {
|
|
789
|
+
reportAndExit(error);
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Hold the terminal until the server exits.
|
|
795
|
+
*
|
|
796
|
+
* Foreground is the v1 lifecycle on purpose: it is also the only channel where a
|
|
797
|
+
* human sees watch mode's deliberately-swallowed compile failures. Ctrl-C is the
|
|
798
|
+
* supervisor's to handle — it subscribed through the host when it spawned the
|
|
799
|
+
* server, so the same handler covers the boot wait and the session.
|
|
800
|
+
*/
|
|
801
|
+
function waitUntilStopped(running) {
|
|
802
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
803
|
+
var _a;
|
|
804
|
+
const code = yield running.waitForExit();
|
|
805
|
+
// A requested stop is not a failure, but it is not a clean finish either:
|
|
806
|
+
// 130 is the shell's code for Ctrl-C, which a waiting script can tell from
|
|
807
|
+
// the 1 a dead server gives. Said aloud so the cleanup is visible.
|
|
808
|
+
if ((_a = running.interrupted) === null || _a === void 0 ? void 0 : _a.call(running)) {
|
|
809
|
+
logger_1.logger.info("Stopped the local Publisher and removed this session's token file.");
|
|
810
|
+
process.exitCode = 130;
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
if (code && code !== 0) {
|
|
814
|
+
logger_1.logger.error(`The publisher exited with code ${code}.`);
|
|
815
|
+
process.exitCode = code;
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
//# sourceMappingURL=setup.js.map
|