@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
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import "../../polyfills/file.polyfill"; // Native support for File is only available on Node 19.2 or above
|
|
2
|
-
|
|
3
|
-
import archiver from "archiver";
|
|
4
|
-
import crypto from "crypto";
|
|
5
|
-
import fs from "fs";
|
|
6
|
-
import path from "path";
|
|
7
|
-
import { Package, PackagesApi } from "../../client/api";
|
|
8
|
-
import { Configuration } from "../../client/configuration";
|
|
9
|
-
import { ClientConfiguration } from "../../clientconfiguration";
|
|
10
|
-
import { logger } from "../../logger";
|
|
11
|
-
import { getConfirmation, prettifyJson, printOutError } from "../../utils";
|
|
12
|
-
import { validateManifest } from "../../validator";
|
|
13
|
-
const packagesApi = new PackagesApi(new Configuration());
|
|
14
|
-
const PACKAGE_MANIFEST_NAME = "publisher.json";
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Record a publish failure: log it (when the caller has a message of its own to give)
|
|
18
|
-
* and mark the process failed.
|
|
19
|
-
*
|
|
20
|
-
* Every early return below is a publish that did not happen, so each one has to carry the
|
|
21
|
-
* same non-zero exit as a server rejection. CI and scripts wrap `cred publish` and read
|
|
22
|
-
* its exit code; exiting 0 tells them a package is there when it is not. Declining the
|
|
23
|
-
* confirmation prompt is deliberately NOT routed through here — that is an answer rather
|
|
24
|
-
* than a failure, and it can only happen interactively.
|
|
25
|
-
*/
|
|
26
|
-
function failPublish(message?: string): void {
|
|
27
|
-
if (message) {
|
|
28
|
-
logger.error(message);
|
|
29
|
-
}
|
|
30
|
-
process.exitCode = 1;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function publish(
|
|
34
|
-
controlPlane: string,
|
|
35
|
-
replicationCount: number,
|
|
36
|
-
debug: boolean,
|
|
37
|
-
autoConfirm: boolean,
|
|
38
|
-
setLatest: boolean,
|
|
39
|
-
) {
|
|
40
|
-
const clientConfig = new ClientConfiguration();
|
|
41
|
-
|
|
42
|
-
if (!clientConfig.doesConfigExists()) {
|
|
43
|
-
failPublish("Please, make sure that you are logged in");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const tokenValidation = clientConfig.isTokenValid();
|
|
48
|
-
if (!tokenValidation.valid) {
|
|
49
|
-
failPublish(
|
|
50
|
-
tokenValidation.reason || "Please, make sure that you are logged in",
|
|
51
|
-
);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!validateManifest()) {
|
|
56
|
-
// validateManifest logs its own reason; only the exit code is missing.
|
|
57
|
-
failPublish();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const environmentName = clientConfig.getProject();
|
|
62
|
-
const organizationName = clientConfig.getOrganization();
|
|
63
|
-
|
|
64
|
-
if (!organizationName) {
|
|
65
|
-
failPublish("Please, make sure that you are logged in");
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!environmentName) {
|
|
70
|
-
failPublish("Please, make sure to set an environment");
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!fs.existsSync(PACKAGE_MANIFEST_NAME)) {
|
|
75
|
-
failPublish(
|
|
76
|
-
`Failed to publish the package. Could not find ${PACKAGE_MANIFEST_NAME}, please ensure you are in a directory containing ${PACKAGE_MANIFEST_NAME}`,
|
|
77
|
-
);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const packageManifestJson = fs.readFileSync(PACKAGE_MANIFEST_NAME);
|
|
82
|
-
const packageManifest = JSON.parse(packageManifestJson.toString());
|
|
83
|
-
|
|
84
|
-
const workingDirectory = process.cwd();
|
|
85
|
-
const packageName = workingDirectory.substring(
|
|
86
|
-
workingDirectory.lastIndexOf("/") + 1,
|
|
87
|
-
);
|
|
88
|
-
const tmpPackagePath = path.join("/tmp", packageName + ".zip");
|
|
89
|
-
if (!autoConfirm) {
|
|
90
|
-
const confirmation = await getConfirmation(
|
|
91
|
-
`Are you sure you that want to publish a package named ${packageName}?`,
|
|
92
|
-
);
|
|
93
|
-
if (!confirmation) {
|
|
94
|
-
logger.info("Operation cancelled.");
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
await createTmpPackageArchive(tmpPackagePath);
|
|
99
|
-
await pushTmpPackageToRemoteServer(
|
|
100
|
-
clientConfig,
|
|
101
|
-
controlPlane,
|
|
102
|
-
replicationCount,
|
|
103
|
-
organizationName,
|
|
104
|
-
environmentName,
|
|
105
|
-
tmpPackagePath,
|
|
106
|
-
packageManifest.name,
|
|
107
|
-
packageManifest.description,
|
|
108
|
-
packageManifest.version,
|
|
109
|
-
debug,
|
|
110
|
-
setLatest,
|
|
111
|
-
);
|
|
112
|
-
await removeTmpPackage(tmpPackagePath);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async function createTmpPackageArchive(
|
|
116
|
-
packagePath: string,
|
|
117
|
-
): Promise<undefined> {
|
|
118
|
-
logger.info("Creating new package version in " + packagePath);
|
|
119
|
-
const output = fs.createWriteStream(packagePath);
|
|
120
|
-
const archive = archiver("zip", {
|
|
121
|
-
zlib: { level: 9 }, // Sets the compression level.
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
return new Promise((resolve, reject) => {
|
|
125
|
-
archive
|
|
126
|
-
.on("warning", function (err) {
|
|
127
|
-
reject(err);
|
|
128
|
-
})
|
|
129
|
-
.on("error", function (err) {
|
|
130
|
-
reject(err);
|
|
131
|
-
})
|
|
132
|
-
.directory(".", false)
|
|
133
|
-
.pipe(output);
|
|
134
|
-
|
|
135
|
-
output.on("close", function () {
|
|
136
|
-
logger.info(archive.pointer() + " total bytes");
|
|
137
|
-
resolve(undefined);
|
|
138
|
-
});
|
|
139
|
-
archive.finalize();
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async function pushTmpPackageToRemoteServer(
|
|
144
|
-
clientConfig: ClientConfiguration,
|
|
145
|
-
controlPlane: string,
|
|
146
|
-
replicationCount: number,
|
|
147
|
-
organizationName: string,
|
|
148
|
-
environmentName: string,
|
|
149
|
-
tmpPackagePath: string,
|
|
150
|
-
name: string,
|
|
151
|
-
description: string,
|
|
152
|
-
versionId: string,
|
|
153
|
-
debug: boolean,
|
|
154
|
-
setLatest: boolean,
|
|
155
|
-
): Promise<undefined> {
|
|
156
|
-
logger.info("Pushing package " + name + " version " + versionId);
|
|
157
|
-
|
|
158
|
-
const packageContents = new File(
|
|
159
|
-
[fs.readFileSync(tmpPackagePath)],
|
|
160
|
-
tmpPackagePath,
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
// Build the post string from an object
|
|
164
|
-
const _package: Package = {
|
|
165
|
-
name: name,
|
|
166
|
-
description: description,
|
|
167
|
-
replicationCount: replicationCount,
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
// Set latest version based on the setLatest flag
|
|
171
|
-
if (setLatest) {
|
|
172
|
-
_package.latestVersion = versionId;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const version = {
|
|
176
|
-
id: versionId,
|
|
177
|
-
};
|
|
178
|
-
try {
|
|
179
|
-
const md5Hash = crypto
|
|
180
|
-
.createHash("md5")
|
|
181
|
-
.update(fs.readFileSync(tmpPackagePath))
|
|
182
|
-
.digest("hex");
|
|
183
|
-
if (debug) {
|
|
184
|
-
logger.debug("Package contents: " + packageContents);
|
|
185
|
-
logger.debug("Organization name: " + organizationName);
|
|
186
|
-
logger.debug("Environment name: " + environmentName);
|
|
187
|
-
logger.debug("Name: " + name);
|
|
188
|
-
logger.debug("Package: " + JSON.stringify(_package));
|
|
189
|
-
logger.debug("Version: " + JSON.stringify(version));
|
|
190
|
-
logger.debug("Control plane: " + controlPlane);
|
|
191
|
-
logger.debug(
|
|
192
|
-
"Client config: " + JSON.stringify(clientConfig.getHeaders()),
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
const response = await packagesApi.createOrUpdatePackage(
|
|
196
|
-
organizationName,
|
|
197
|
-
environmentName,
|
|
198
|
-
name,
|
|
199
|
-
_package,
|
|
200
|
-
version,
|
|
201
|
-
packageContents,
|
|
202
|
-
md5Hash,
|
|
203
|
-
// draftId / workspace: a zip upload has no git-backed draft, so the server
|
|
204
|
-
// records no provenance. Positional because `options` must stay last.
|
|
205
|
-
undefined,
|
|
206
|
-
undefined,
|
|
207
|
-
{
|
|
208
|
-
baseURL: controlPlane,
|
|
209
|
-
headers: clientConfig.getHeaders(),
|
|
210
|
-
},
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
logger.info(prettifyJson(response.data));
|
|
214
|
-
const packageUrl = path.join(
|
|
215
|
-
organizationName,
|
|
216
|
-
environmentName,
|
|
217
|
-
name,
|
|
218
|
-
versionId,
|
|
219
|
-
);
|
|
220
|
-
logger.info(`Package available at: ${packageUrl}`);
|
|
221
|
-
} catch (e) {
|
|
222
|
-
// The server rejected it: a model that does not compile, or a `#@ persist`
|
|
223
|
-
// declaration the publisher refuses to load.
|
|
224
|
-
failPublish("Failed to publish package");
|
|
225
|
-
printOutError(e, debug);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
async function removeTmpPackage(tmpPackagePath: string): Promise<undefined> {
|
|
230
|
-
return new Promise((resolve) => {
|
|
231
|
-
fs.unlink(tmpPackagePath, (err) => {
|
|
232
|
-
if (err) throw err;
|
|
233
|
-
resolve(undefined);
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
}
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import sinon from "sinon";
|
|
3
|
-
import { PackagesApi } from "../../client/api";
|
|
4
|
-
import { ClientConfiguration } from "../../clientconfiguration";
|
|
5
|
-
import { logger } from "../../logger";
|
|
6
|
-
import { updatePackage } from "./updatepackage";
|
|
7
|
-
|
|
8
|
-
describe("set-replication-count", () => {
|
|
9
|
-
let sandbox: sinon.SinonSandbox;
|
|
10
|
-
let updatePackageStub: sinon.SinonStub;
|
|
11
|
-
let loggerStub: sinon.SinonStubbedInstance<typeof logger>;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
sandbox = sinon.createSandbox();
|
|
15
|
-
updatePackageStub = sandbox.stub();
|
|
16
|
-
loggerStub = sandbox.stub(logger);
|
|
17
|
-
|
|
18
|
-
// Mock ClientConfiguration constructor
|
|
19
|
-
sandbox
|
|
20
|
-
.stub(ClientConfiguration.prototype, "getOrganization")
|
|
21
|
-
.returns("test-org");
|
|
22
|
-
sandbox
|
|
23
|
-
.stub(ClientConfiguration.prototype, "getProject")
|
|
24
|
-
.returns("test-project");
|
|
25
|
-
sandbox
|
|
26
|
-
.stub(ClientConfiguration.prototype, "doesConfigExists")
|
|
27
|
-
.returns(true);
|
|
28
|
-
sandbox
|
|
29
|
-
.stub(ClientConfiguration.prototype, "getHeaders")
|
|
30
|
-
.returns({ Authorization: "Bearer test-token" });
|
|
31
|
-
|
|
32
|
-
// Mock PackagesApi constructor and method
|
|
33
|
-
sandbox
|
|
34
|
-
.stub(PackagesApi.prototype, "updatePackage")
|
|
35
|
-
.callsFake(updatePackageStub);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
afterEach(() => {
|
|
39
|
-
sandbox.restore();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe("setReplicationCount", () => {
|
|
43
|
-
it("should set replication count successfully", async () => {
|
|
44
|
-
const mockResponse = { status: 200 };
|
|
45
|
-
updatePackageStub.resolves(mockResponse);
|
|
46
|
-
|
|
47
|
-
await updatePackage(
|
|
48
|
-
"http://test-server",
|
|
49
|
-
"test-package",
|
|
50
|
-
{ replicationCount: 3 },
|
|
51
|
-
false,
|
|
52
|
-
true,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
expect(updatePackageStub.calledOnce).to.be.true;
|
|
56
|
-
expect(updatePackageStub.firstCall.args[0]).to.equal("test-org");
|
|
57
|
-
expect(updatePackageStub.firstCall.args[1]).to.equal("test-project");
|
|
58
|
-
expect(updatePackageStub.firstCall.args[2]).to.equal("test-package");
|
|
59
|
-
expect(updatePackageStub.firstCall.args[3]).to.include({
|
|
60
|
-
replicationCount: 3,
|
|
61
|
-
});
|
|
62
|
-
expect(updatePackageStub.firstCall.args[4]).to.deep.include({
|
|
63
|
-
baseURL: "http://test-server",
|
|
64
|
-
headers: { Authorization: "Bearer test-token" },
|
|
65
|
-
});
|
|
66
|
-
expect(
|
|
67
|
-
loggerStub.info.calledWith(
|
|
68
|
-
sinon.match(
|
|
69
|
-
"Successfully set replication count for package test-package to 3",
|
|
70
|
-
),
|
|
71
|
-
),
|
|
72
|
-
).to.be.true;
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("should handle missing package name", async () => {
|
|
76
|
-
await updatePackage(
|
|
77
|
-
"http://test-server",
|
|
78
|
-
"",
|
|
79
|
-
{ replicationCount: 3 },
|
|
80
|
-
false,
|
|
81
|
-
true,
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
expect(updatePackageStub.called).to.be.false;
|
|
85
|
-
expect(
|
|
86
|
-
loggerStub.error.calledWith(
|
|
87
|
-
sinon.match("Please provide a package name"),
|
|
88
|
-
),
|
|
89
|
-
).to.be.true;
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("should handle API errors", async () => {
|
|
93
|
-
const mockError = new Error("API Error");
|
|
94
|
-
updatePackageStub.rejects(mockError);
|
|
95
|
-
|
|
96
|
-
await updatePackage(
|
|
97
|
-
"http://test-server",
|
|
98
|
-
"test-package",
|
|
99
|
-
{ replicationCount: 3 },
|
|
100
|
-
true,
|
|
101
|
-
true,
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
expect(updatePackageStub.calledOnce).to.be.true;
|
|
105
|
-
expect(
|
|
106
|
-
loggerStub.error.calledWith(
|
|
107
|
-
sinon.match(
|
|
108
|
-
"Failed to set replication count for package test-package",
|
|
109
|
-
),
|
|
110
|
-
),
|
|
111
|
-
).to.be.true;
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("should handle non-200 response status", async () => {
|
|
115
|
-
const mockResponse = { status: 400 };
|
|
116
|
-
updatePackageStub.resolves(mockResponse);
|
|
117
|
-
|
|
118
|
-
await updatePackage(
|
|
119
|
-
"http://test-server",
|
|
120
|
-
"test-package",
|
|
121
|
-
{ replicationCount: 3 },
|
|
122
|
-
false,
|
|
123
|
-
true,
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
expect(updatePackageStub.calledOnce).to.be.true;
|
|
127
|
-
expect(
|
|
128
|
-
loggerStub.error.calledWith(
|
|
129
|
-
sinon.match("Failed to set replication count. Status: 400"),
|
|
130
|
-
),
|
|
131
|
-
).to.be.true;
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
describe("validators", () => {
|
|
136
|
-
describe("authentication validation", () => {
|
|
137
|
-
it("should fail when user is not logged in", async () => {
|
|
138
|
-
sandbox.restore();
|
|
139
|
-
sandbox = sinon.createSandbox();
|
|
140
|
-
updatePackageStub = sandbox.stub();
|
|
141
|
-
loggerStub = sandbox.stub(logger);
|
|
142
|
-
|
|
143
|
-
sandbox
|
|
144
|
-
.stub(ClientConfiguration.prototype, "doesConfigExists")
|
|
145
|
-
.returns(false);
|
|
146
|
-
sandbox
|
|
147
|
-
.stub(PackagesApi.prototype, "updatePackage")
|
|
148
|
-
.callsFake(updatePackageStub);
|
|
149
|
-
|
|
150
|
-
await updatePackage(
|
|
151
|
-
"http://test-server",
|
|
152
|
-
"test-package",
|
|
153
|
-
{ replicationCount: 3 },
|
|
154
|
-
false,
|
|
155
|
-
true,
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
expect(
|
|
159
|
-
loggerStub.error.calledWith(
|
|
160
|
-
sinon.match("Please, make sure that you are logged in"),
|
|
161
|
-
),
|
|
162
|
-
).to.be.true;
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it("should fail when no project is set", async () => {
|
|
166
|
-
sandbox.restore();
|
|
167
|
-
sandbox = sinon.createSandbox();
|
|
168
|
-
updatePackageStub = sandbox.stub();
|
|
169
|
-
loggerStub = sandbox.stub(logger);
|
|
170
|
-
|
|
171
|
-
sandbox
|
|
172
|
-
.stub(ClientConfiguration.prototype, "doesConfigExists")
|
|
173
|
-
.returns(true);
|
|
174
|
-
sandbox
|
|
175
|
-
.stub(ClientConfiguration.prototype, "getProject")
|
|
176
|
-
.returns("");
|
|
177
|
-
sandbox
|
|
178
|
-
.stub(PackagesApi.prototype, "updatePackage")
|
|
179
|
-
.callsFake(updatePackageStub);
|
|
180
|
-
|
|
181
|
-
await updatePackage(
|
|
182
|
-
"http://test-server",
|
|
183
|
-
"test-package",
|
|
184
|
-
{ replicationCount: 3 },
|
|
185
|
-
false,
|
|
186
|
-
true,
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
expect(
|
|
190
|
-
loggerStub.error.calledWith(
|
|
191
|
-
sinon.match("Please, make sure to set an environment"),
|
|
192
|
-
),
|
|
193
|
-
).to.be.true;
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
describe("replication count validation", () => {
|
|
198
|
-
it("should accept valid replication counts", async () => {
|
|
199
|
-
const mockResponse = { status: 200 };
|
|
200
|
-
updatePackageStub.resolves(mockResponse);
|
|
201
|
-
|
|
202
|
-
const validCounts = [1, 2, 5, 10, 100];
|
|
203
|
-
|
|
204
|
-
for (const count of validCounts) {
|
|
205
|
-
await updatePackage(
|
|
206
|
-
"http://test-server",
|
|
207
|
-
"test-package",
|
|
208
|
-
{ replicationCount: count },
|
|
209
|
-
false,
|
|
210
|
-
true,
|
|
211
|
-
);
|
|
212
|
-
expect(updatePackageStub.called).to.be.true;
|
|
213
|
-
expect(updatePackageStub.firstCall.args[3]).to.include({
|
|
214
|
-
replicationCount: count,
|
|
215
|
-
});
|
|
216
|
-
updatePackageStub.reset();
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
describe("updatePackage params", () => {
|
|
223
|
-
it("should pass latestVersion when provided", async () => {
|
|
224
|
-
const mockResponse = { status: 200 };
|
|
225
|
-
updatePackageStub.resolves(mockResponse);
|
|
226
|
-
|
|
227
|
-
await updatePackage(
|
|
228
|
-
"http://test-server",
|
|
229
|
-
"test-package",
|
|
230
|
-
{ latestVersion: "2.0.0" },
|
|
231
|
-
false,
|
|
232
|
-
true,
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
expect(updatePackageStub.calledOnce).to.be.true;
|
|
236
|
-
expect(updatePackageStub.firstCall.args[3]).to.deep.include({
|
|
237
|
-
latestVersion: "2.0.0",
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("should pass description when provided", async () => {
|
|
242
|
-
const mockResponse = { status: 200 };
|
|
243
|
-
updatePackageStub.resolves(mockResponse);
|
|
244
|
-
|
|
245
|
-
await updatePackage(
|
|
246
|
-
"http://test-server",
|
|
247
|
-
"test-package",
|
|
248
|
-
{ description: "Updated description" },
|
|
249
|
-
false,
|
|
250
|
-
true,
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
expect(updatePackageStub.calledOnce).to.be.true;
|
|
254
|
-
expect(updatePackageStub.firstCall.args[3]).to.deep.include({
|
|
255
|
-
description: "Updated description",
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
it("should reject invalid package path with multiple segments", async () => {
|
|
260
|
-
await updatePackage(
|
|
261
|
-
"http://test-server",
|
|
262
|
-
"foo/bar",
|
|
263
|
-
{ replicationCount: 3 },
|
|
264
|
-
false,
|
|
265
|
-
true,
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
expect(updatePackageStub.called).to.be.false;
|
|
269
|
-
expect(
|
|
270
|
-
loggerStub.error.calledWith(sinon.match("Invalid package path")),
|
|
271
|
-
).to.be.true;
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
describe("confirmation flow", () => {
|
|
276
|
-
let getConfirmationStub: sinon.SinonStub;
|
|
277
|
-
|
|
278
|
-
beforeEach(() => {
|
|
279
|
-
getConfirmationStub = sandbox.stub();
|
|
280
|
-
sandbox
|
|
281
|
-
.stub(require("../../utils"), "getConfirmation")
|
|
282
|
-
.callsFake(getConfirmationStub);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it("should request confirmation when autoConfirm is false", async () => {
|
|
286
|
-
const mockResponse = { status: 200 };
|
|
287
|
-
updatePackageStub.resolves(mockResponse);
|
|
288
|
-
getConfirmationStub.resolves(true);
|
|
289
|
-
|
|
290
|
-
await updatePackage(
|
|
291
|
-
"http://test-server",
|
|
292
|
-
"test-package",
|
|
293
|
-
{ replicationCount: 3 },
|
|
294
|
-
false,
|
|
295
|
-
false,
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
expect(getConfirmationStub.calledOnce).to.be.true;
|
|
299
|
-
expect(updatePackageStub.calledOnce).to.be.true;
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it("should cancel when confirmation is denied", async () => {
|
|
303
|
-
getConfirmationStub.resolves(false);
|
|
304
|
-
|
|
305
|
-
await updatePackage(
|
|
306
|
-
"http://test-server",
|
|
307
|
-
"test-package",
|
|
308
|
-
{ replicationCount: 3 },
|
|
309
|
-
false,
|
|
310
|
-
false,
|
|
311
|
-
);
|
|
312
|
-
|
|
313
|
-
expect(getConfirmationStub.calledOnce).to.be.true;
|
|
314
|
-
expect(updatePackageStub.called).to.be.false;
|
|
315
|
-
expect(loggerStub.info.calledWith(sinon.match("Operation cancelled.")))
|
|
316
|
-
.to.be.true;
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { Package, PackagesApi } from "../../client/api";
|
|
2
|
-
import { Configuration } from "../../client/configuration";
|
|
3
|
-
import { ClientConfiguration } from "../../clientconfiguration";
|
|
4
|
-
import { logger } from "../../logger";
|
|
5
|
-
import { getConfirmation, printOutError } from "../../utils";
|
|
6
|
-
|
|
7
|
-
const packagesApi = new PackagesApi(new Configuration());
|
|
8
|
-
|
|
9
|
-
type NewParams = {
|
|
10
|
-
latestVersion?: string;
|
|
11
|
-
replicationCount?: number;
|
|
12
|
-
description?: string;
|
|
13
|
-
};
|
|
14
|
-
export async function updatePackage(
|
|
15
|
-
packageServer: string,
|
|
16
|
-
packageName: string,
|
|
17
|
-
newParams: NewParams,
|
|
18
|
-
debug: boolean,
|
|
19
|
-
autoConfirm: boolean,
|
|
20
|
-
) {
|
|
21
|
-
const clientConfig = new ClientConfiguration();
|
|
22
|
-
const organizationName = clientConfig.getOrganization();
|
|
23
|
-
const environmentName = clientConfig.getProject();
|
|
24
|
-
|
|
25
|
-
if (!clientConfig.doesConfigExists()) {
|
|
26
|
-
logger.error("Please, make sure that you are logged in");
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (!environmentName) {
|
|
31
|
-
logger.error("Please, make sure to set an environment");
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!packageName) {
|
|
36
|
-
logger.error("Please provide a package name");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
logger.info(
|
|
41
|
-
`Setting replication count for package ${packageName} to ${newParams.replicationCount}`,
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
if (!autoConfirm) {
|
|
46
|
-
const confirmation = await getConfirmation(
|
|
47
|
-
`Are you sure you that want to update the replication count for package ${packageName} to ${newParams.replicationCount}?`,
|
|
48
|
-
);
|
|
49
|
-
if (!confirmation) {
|
|
50
|
-
logger.info("Operation cancelled.");
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const packageUpdate: Package = {
|
|
55
|
-
replicationCount: newParams.replicationCount || undefined,
|
|
56
|
-
latestVersion: newParams.latestVersion || undefined,
|
|
57
|
-
description: newParams.description || undefined,
|
|
58
|
-
};
|
|
59
|
-
const pathParts = packageName
|
|
60
|
-
.split("/")
|
|
61
|
-
.filter((part) => part.length > 0);
|
|
62
|
-
if (pathParts.length !== 1) {
|
|
63
|
-
logger.error("Invalid package path. Expected format: /<packageName>");
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
packageName = pathParts[0];
|
|
68
|
-
|
|
69
|
-
const response = await packagesApi.updatePackage(
|
|
70
|
-
organizationName,
|
|
71
|
-
environmentName,
|
|
72
|
-
packageName,
|
|
73
|
-
packageUpdate,
|
|
74
|
-
{
|
|
75
|
-
baseURL: packageServer,
|
|
76
|
-
headers: clientConfig.getHeaders(),
|
|
77
|
-
},
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
if (response.status === 200) {
|
|
81
|
-
logger.info(
|
|
82
|
-
`Successfully set replication count for package ${packageName} to ${newParams.replicationCount}`,
|
|
83
|
-
);
|
|
84
|
-
} else {
|
|
85
|
-
logger.error(
|
|
86
|
-
`Failed to set replication count. Status: ${response.status}`,
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
} catch (e) {
|
|
90
|
-
logger.error(
|
|
91
|
-
`Failed to set replication count for package ${packageName}`,
|
|
92
|
-
);
|
|
93
|
-
printOutError(e, debug);
|
|
94
|
-
}
|
|
95
|
-
}
|