@credibledata/cred-cli 0.0.7 → 0.0.102
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-DEV.md +2 -2
- package/bun.lock +113 -337
- package/dist/client/api.js +2999 -1953
- package/dist/client/api.js.map +1 -1
- package/dist/client/base.js +1 -1
- package/dist/client/common.js +1 -1
- package/dist/client/configuration.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/clientconfiguration.js +59 -24
- package/dist/clientconfiguration.js.map +1 -1
- package/dist/clientconfiguration.spec.js +69 -37
- package/dist/clientconfiguration.spec.js.map +1 -1
- package/dist/commands/add.js +18 -5
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/connection/createconnections.js +4 -4
- package/dist/commands/connection/createconnections.js.map +1 -1
- package/dist/commands/connection/createconnections.spec.js +11 -1
- package/dist/commands/connection/createconnections.spec.js.map +1 -1
- package/dist/commands/connection/deleteconnection.js +4 -4
- package/dist/commands/connection/deleteconnection.js.map +1 -1
- package/dist/commands/connection/deleteconnection.spec.js +1 -1
- package/dist/commands/connection/deleteconnection.spec.js.map +1 -1
- package/dist/commands/connection/listconnections.js +4 -4
- package/dist/commands/connection/listconnections.js.map +1 -1
- package/dist/commands/connection/listconnections.spec.js +1 -1
- package/dist/commands/connection/listconnections.spec.js.map +1 -1
- package/dist/commands/{project/createproject.js → environment/createenvironment.js} +17 -14
- package/dist/commands/environment/createenvironment.js.map +1 -0
- package/dist/commands/{project/createproject.spec.js → environment/createenvironment.spec.js} +46 -46
- package/dist/commands/environment/createenvironment.spec.js.map +1 -0
- package/dist/commands/{project/deleteproject.js → environment/deleteenvironment.js} +9 -9
- package/dist/commands/environment/deleteenvironment.js.map +1 -0
- package/dist/commands/{project/deleteproject.spec.js → environment/deleteenvironment.spec.js} +29 -29
- package/dist/commands/environment/deleteenvironment.spec.js.map +1 -0
- package/dist/commands/{project/getproject.js → environment/getenvironment.js} +8 -8
- package/dist/commands/environment/getenvironment.js.map +1 -0
- package/dist/commands/{project/getproject.spec.js → environment/getenvironment.spec.js} +32 -33
- package/dist/commands/environment/getenvironment.spec.js.map +1 -0
- package/dist/commands/{project/listprojects.js → environment/listenvironments.js} +10 -10
- package/dist/commands/environment/listenvironments.js.map +1 -0
- package/dist/commands/{project/listprojects.spec.js → environment/listenvironments.spec.js} +35 -35
- package/dist/commands/environment/listenvironments.spec.js.map +1 -0
- package/dist/commands/{project/setproject.js → environment/setenvironment.js} +6 -5
- package/dist/commands/environment/setenvironment.js.map +1 -0
- package/dist/commands/{project/setproject.spec.js → environment/setenvironment.spec.js} +9 -9
- package/dist/commands/environment/setenvironment.spec.js.map +1 -0
- package/dist/commands/{project/updateproject.js → environment/updateenvironment.js} +13 -13
- package/dist/commands/environment/updateenvironment.js.map +1 -0
- package/dist/commands/{project/updateproject.spec.js → environment/updateenvironment.spec.js} +44 -44
- package/dist/commands/environment/updateenvironment.spec.js.map +1 -0
- package/dist/commands/get.js +15 -5
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/legacy.js +9 -0
- package/dist/commands/legacy.js.map +1 -0
- package/dist/commands/list.js +17 -4
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/misc/login.js +2 -2
- package/dist/commands/misc/login.js.map +1 -1
- package/dist/commands/misc/login.spec.js +41 -5
- package/dist/commands/misc/login.spec.js.map +1 -1
- package/dist/commands/package/deletepackage.js +4 -4
- package/dist/commands/package/deletepackage.js.map +1 -1
- package/dist/commands/package/deletepackage.spec.js +1 -1
- package/dist/commands/package/deletepackage.spec.js.map +1 -1
- package/dist/commands/package/listpackages.js +4 -4
- package/dist/commands/package/listpackages.js.map +1 -1
- package/dist/commands/package/listpackages.spec.js +1 -1
- package/dist/commands/package/listpackages.spec.js.map +1 -1
- package/dist/commands/package/publish.js +10 -10
- package/dist/commands/package/publish.js.map +1 -1
- package/dist/commands/package/publish.spec.js +34 -6
- package/dist/commands/package/publish.spec.js.map +1 -1
- package/dist/commands/package/updatepackage.js +4 -4
- package/dist/commands/package/updatepackage.js.map +1 -1
- package/dist/commands/package/updatepackage.spec.js +1 -1
- package/dist/commands/package/updatepackage.spec.js.map +1 -1
- package/dist/commands/rm.js +15 -4
- package/dist/commands/rm.js.map +1 -1
- package/dist/commands/set.js +12 -4
- package/dist/commands/set.js.map +1 -1
- package/dist/commands/update.js +19 -6
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/version/archive-unarchive-version.js +4 -5
- package/dist/commands/version/archive-unarchive-version.js.map +1 -1
- package/dist/commands/version/archive-unarchive-version.spec.js +4 -4
- package/dist/commands/version/archive-unarchive-version.spec.js.map +1 -1
- package/dist/commands/version/listversions.js +4 -4
- package/dist/commands/version/listversions.js.map +1 -1
- package/dist/commands/version/listversions.spec.js +1 -1
- package/dist/commands/version/listversions.spec.js.map +1 -1
- package/dist/constants.js +47 -19
- package/dist/constants.js.map +1 -1
- package/dist/constants.spec.js +90 -0
- package/dist/constants.spec.js.map +1 -0
- package/dist/index.js +74 -16
- package/dist/index.js.map +1 -1
- package/package.json +7 -8
- package/src/client/api.ts +3552 -2182
- package/src/client/base.ts +1 -1
- package/src/client/common.ts +1 -1
- package/src/client/configuration.ts +1 -1
- package/src/client/index.ts +1 -1
- package/src/clientconfiguration.spec.ts +113 -114
- package/src/clientconfiguration.ts +69 -28
- package/src/commands/add.ts +35 -12
- package/src/commands/connection/createconnections.spec.ts +11 -1
- package/src/commands/connection/createconnections.ts +4 -4
- package/src/commands/connection/deleteconnection.spec.ts +1 -1
- package/src/commands/connection/deleteconnection.ts +4 -4
- package/src/commands/connection/listconnections.spec.ts +1 -1
- package/src/commands/connection/listconnections.ts +4 -4
- package/src/commands/{project/createproject.spec.ts → environment/createenvironment.spec.ts} +56 -54
- package/src/commands/{project/createproject.ts → environment/createenvironment.ts} +17 -14
- package/src/commands/{project/deleteproject.spec.ts → environment/deleteenvironment.spec.ts} +59 -30
- package/src/commands/{project/deleteproject.ts → environment/deleteenvironment.ts} +10 -10
- package/src/commands/environment/getenvironment.spec.ts +110 -0
- package/src/commands/{project/getproject.ts → environment/getenvironment.ts} +9 -9
- package/src/commands/{project/listprojects.spec.ts → environment/listenvironments.spec.ts} +37 -35
- package/src/commands/{project/listprojects.ts → environment/listenvironments.ts} +13 -8
- package/src/commands/{project/setproject.spec.ts → environment/setenvironment.spec.ts} +8 -8
- package/src/commands/{project/setproject.ts → environment/setenvironment.ts} +4 -4
- package/src/commands/{project/updateproject.spec.ts → environment/updateenvironment.spec.ts} +53 -51
- package/src/commands/{project/updateproject.ts → environment/updateenvironment.ts} +19 -17
- package/src/commands/get.ts +22 -9
- package/src/commands/legacy.ts +5 -0
- package/src/commands/list.ts +33 -9
- package/src/commands/misc/login.spec.ts +47 -5
- package/src/commands/misc/login.ts +6 -2
- package/src/commands/package/deletepackage.spec.ts +1 -1
- package/src/commands/package/deletepackage.ts +4 -4
- package/src/commands/package/listpackages.spec.ts +1 -1
- package/src/commands/package/listpackages.ts +4 -4
- package/src/commands/package/publish.spec.ts +36 -6
- package/src/commands/package/publish.ts +12 -8
- package/src/commands/package/updatepackage.spec.ts +1 -1
- package/src/commands/package/updatepackage.ts +4 -4
- package/src/commands/rm.ts +25 -9
- package/src/commands/set.ts +13 -4
- package/src/commands/update.ts +32 -12
- package/src/commands/version/archive-unarchive-version.spec.ts +4 -4
- package/src/commands/version/archive-unarchive-version.ts +4 -7
- package/src/commands/version/listversions.spec.ts +1 -1
- package/src/commands/version/listversions.ts +4 -4
- package/src/constants.spec.ts +111 -0
- package/src/constants.ts +81 -18
- package/src/index.ts +103 -17
- package/dist/commands/project/createproject.js.map +0 -1
- package/dist/commands/project/createproject.spec.js.map +0 -1
- package/dist/commands/project/deleteproject.js.map +0 -1
- package/dist/commands/project/deleteproject.spec.js.map +0 -1
- package/dist/commands/project/getproject.js.map +0 -1
- package/dist/commands/project/getproject.spec.js.map +0 -1
- package/dist/commands/project/listprojects.js.map +0 -1
- package/dist/commands/project/listprojects.spec.js.map +0 -1
- package/dist/commands/project/setproject.js.map +0 -1
- package/dist/commands/project/setproject.spec.js.map +0 -1
- package/dist/commands/project/updateproject.js.map +0 -1
- package/dist/commands/project/updateproject.spec.js.map +0 -1
- package/src/commands/project/getproject.spec.ts +0 -109
|
@@ -50,6 +50,7 @@ describe("publish", () => {
|
|
|
50
50
|
debug: boolean,
|
|
51
51
|
autoConfirm: boolean,
|
|
52
52
|
setLatest: boolean,
|
|
53
|
+
asyncIndexing?: boolean,
|
|
53
54
|
) => Promise<void>;
|
|
54
55
|
|
|
55
56
|
// Store the original archiver module so we can restore it
|
|
@@ -183,12 +184,14 @@ describe("publish", () => {
|
|
|
183
184
|
expect(createOrUpdatePackageStub.firstCall.args[2]).to.equal(
|
|
184
185
|
"test-package",
|
|
185
186
|
);
|
|
186
|
-
|
|
187
|
+
// arg[3] is the new `async` flag; package/version shift by one.
|
|
188
|
+
expect(createOrUpdatePackageStub.firstCall.args[3]).to.equal(false);
|
|
189
|
+
expect(createOrUpdatePackageStub.firstCall.args[4]).to.deep.include({
|
|
187
190
|
name: "test-package",
|
|
188
191
|
description: "Test package",
|
|
189
192
|
replicationCount: 2,
|
|
190
193
|
});
|
|
191
|
-
expect(createOrUpdatePackageStub.firstCall.args[
|
|
194
|
+
expect(createOrUpdatePackageStub.firstCall.args[5]).to.deep.include({
|
|
192
195
|
id: "1.0.0",
|
|
193
196
|
});
|
|
194
197
|
expect(
|
|
@@ -217,7 +220,7 @@ describe("publish", () => {
|
|
|
217
220
|
|
|
218
221
|
await publish("http://test-server", 2, false, true, true);
|
|
219
222
|
|
|
220
|
-
expect(createOrUpdatePackageStub.firstCall.args[
|
|
223
|
+
expect(createOrUpdatePackageStub.firstCall.args[4]).to.deep.include({
|
|
221
224
|
latestVersion: "1.0.0",
|
|
222
225
|
});
|
|
223
226
|
});
|
|
@@ -241,7 +244,7 @@ describe("publish", () => {
|
|
|
241
244
|
|
|
242
245
|
await publish("http://test-server", 2, false, true, false);
|
|
243
246
|
|
|
244
|
-
expect(createOrUpdatePackageStub.firstCall.args[
|
|
247
|
+
expect(createOrUpdatePackageStub.firstCall.args[4]).to.not.have.property(
|
|
245
248
|
"latestVersion",
|
|
246
249
|
);
|
|
247
250
|
});
|
|
@@ -315,7 +318,7 @@ describe("publish", () => {
|
|
|
315
318
|
|
|
316
319
|
await publish("http://test-server", 2, false, true, false);
|
|
317
320
|
|
|
318
|
-
expect(createOrUpdatePackageStub.firstCall.args[
|
|
321
|
+
expect(createOrUpdatePackageStub.firstCall.args[7]).to.equal(
|
|
319
322
|
expectedHash,
|
|
320
323
|
);
|
|
321
324
|
});
|
|
@@ -416,6 +419,11 @@ describe("publish", () => {
|
|
|
416
419
|
sandbox
|
|
417
420
|
.stub(ClientConfiguration.prototype, "getOrganization")
|
|
418
421
|
.returns("");
|
|
422
|
+
// publish calls getProject before the organization check — stub it too
|
|
423
|
+
// so we don't fall through into real loadConfig against a stubbed fs.
|
|
424
|
+
sandbox
|
|
425
|
+
.stub(ClientConfiguration.prototype, "getProject")
|
|
426
|
+
.returns("test-project");
|
|
419
427
|
validateManifestStub.returns(true);
|
|
420
428
|
sandbox
|
|
421
429
|
.stub(PackagesApi.prototype, "createOrUpdatePackage")
|
|
@@ -473,7 +481,7 @@ describe("publish", () => {
|
|
|
473
481
|
expect(createOrUpdatePackageStub.called).to.be.false;
|
|
474
482
|
expect(
|
|
475
483
|
loggerStub.error.calledWith(
|
|
476
|
-
sinon.match("Please, make sure to set
|
|
484
|
+
sinon.match("Please, make sure to set an environment"),
|
|
477
485
|
),
|
|
478
486
|
).to.be.true;
|
|
479
487
|
});
|
|
@@ -564,6 +572,28 @@ describe("publish", () => {
|
|
|
564
572
|
).to.be.true;
|
|
565
573
|
});
|
|
566
574
|
|
|
575
|
+
it("should pass async=true to the API when asyncIndexing is set", async function () {
|
|
576
|
+
this.timeout(5000);
|
|
577
|
+
const mockManifest = {
|
|
578
|
+
name: "test-package",
|
|
579
|
+
version: "1.0.0",
|
|
580
|
+
description: "Test package",
|
|
581
|
+
};
|
|
582
|
+
const mockPackageData = Buffer.from("test package data");
|
|
583
|
+
|
|
584
|
+
readFileSyncStub.callsFake((filePath: string) => {
|
|
585
|
+
if (filePath === "publisher.json") return JSON.stringify(mockManifest);
|
|
586
|
+
return mockPackageData;
|
|
587
|
+
});
|
|
588
|
+
getConfirmationStub.resolves(true);
|
|
589
|
+
createOrUpdatePackageStub.resolves({ data: {} });
|
|
590
|
+
unlinkStub.callsArg(1);
|
|
591
|
+
|
|
592
|
+
await publish("http://test-server", 2, false, true, false, true);
|
|
593
|
+
|
|
594
|
+
expect(createOrUpdatePackageStub.firstCall.args[3]).to.equal(true);
|
|
595
|
+
});
|
|
596
|
+
|
|
567
597
|
it("should log package URL after successful publish", async function () {
|
|
568
598
|
this.timeout(5000);
|
|
569
599
|
const mockManifest = {
|
|
@@ -19,6 +19,7 @@ export async function publish(
|
|
|
19
19
|
debug: boolean,
|
|
20
20
|
autoConfirm: boolean,
|
|
21
21
|
setLatest: boolean,
|
|
22
|
+
asyncIndexing: boolean = false,
|
|
22
23
|
) {
|
|
23
24
|
const clientConfig = new ClientConfiguration();
|
|
24
25
|
|
|
@@ -39,7 +40,7 @@ export async function publish(
|
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
const
|
|
43
|
+
const environmentName = clientConfig.getProject();
|
|
43
44
|
const organizationName = clientConfig.getOrganization();
|
|
44
45
|
|
|
45
46
|
if (!organizationName) {
|
|
@@ -47,8 +48,8 @@ export async function publish(
|
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
if (!
|
|
51
|
-
logger.error("Please, make sure to set
|
|
51
|
+
if (!environmentName) {
|
|
52
|
+
logger.error("Please, make sure to set an environment");
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -82,13 +83,14 @@ export async function publish(
|
|
|
82
83
|
controlPlane,
|
|
83
84
|
replicationCount,
|
|
84
85
|
organizationName,
|
|
85
|
-
|
|
86
|
+
environmentName,
|
|
86
87
|
tmpPackagePath,
|
|
87
88
|
packageManifest.name,
|
|
88
89
|
packageManifest.description,
|
|
89
90
|
packageManifest.version,
|
|
90
91
|
debug,
|
|
91
92
|
setLatest,
|
|
93
|
+
asyncIndexing,
|
|
92
94
|
);
|
|
93
95
|
await removeTmpPackage(tmpPackagePath);
|
|
94
96
|
}
|
|
@@ -126,13 +128,14 @@ async function pushTmpPackageToRemoteServer(
|
|
|
126
128
|
controlPlane: string,
|
|
127
129
|
replicationCount: number,
|
|
128
130
|
organizationName: string,
|
|
129
|
-
|
|
131
|
+
environmentName: string,
|
|
130
132
|
tmpPackagePath: string,
|
|
131
133
|
name: string,
|
|
132
134
|
description: string,
|
|
133
135
|
versionId: string,
|
|
134
136
|
debug: boolean,
|
|
135
137
|
setLatest: boolean,
|
|
138
|
+
asyncIndexing: boolean,
|
|
136
139
|
): Promise<undefined> {
|
|
137
140
|
logger.info("Pushing package " + name + " version " + versionId);
|
|
138
141
|
|
|
@@ -164,7 +167,7 @@ async function pushTmpPackageToRemoteServer(
|
|
|
164
167
|
if (debug) {
|
|
165
168
|
logger.debug("Package contents: " + packageContents);
|
|
166
169
|
logger.debug("Organization name: " + organizationName);
|
|
167
|
-
logger.debug("
|
|
170
|
+
logger.debug("Environment name: " + environmentName);
|
|
168
171
|
logger.debug("Name: " + name);
|
|
169
172
|
logger.debug("Package: " + JSON.stringify(_package));
|
|
170
173
|
logger.debug("Version: " + JSON.stringify(version));
|
|
@@ -175,8 +178,9 @@ async function pushTmpPackageToRemoteServer(
|
|
|
175
178
|
}
|
|
176
179
|
const response = await packagesApi.createOrUpdatePackage(
|
|
177
180
|
organizationName,
|
|
178
|
-
|
|
181
|
+
environmentName,
|
|
179
182
|
name,
|
|
183
|
+
asyncIndexing,
|
|
180
184
|
_package,
|
|
181
185
|
version,
|
|
182
186
|
packageContents,
|
|
@@ -190,7 +194,7 @@ async function pushTmpPackageToRemoteServer(
|
|
|
190
194
|
logger.info(prettifyJson(response.data));
|
|
191
195
|
const packageUrl = path.join(
|
|
192
196
|
organizationName,
|
|
193
|
-
|
|
197
|
+
environmentName,
|
|
194
198
|
name,
|
|
195
199
|
versionId,
|
|
196
200
|
);
|
|
@@ -20,15 +20,15 @@ export async function updatePackage(
|
|
|
20
20
|
) {
|
|
21
21
|
const clientConfig = new ClientConfiguration();
|
|
22
22
|
const organizationName = clientConfig.getOrganization();
|
|
23
|
-
const
|
|
23
|
+
const environmentName = clientConfig.getProject();
|
|
24
24
|
|
|
25
25
|
if (!clientConfig.doesConfigExists()) {
|
|
26
26
|
logger.error("Please, make sure that you are logged in");
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
if (!
|
|
31
|
-
logger.error("Please, make sure to set
|
|
30
|
+
if (!environmentName) {
|
|
31
|
+
logger.error("Please, make sure to set an environment");
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -68,7 +68,7 @@ export async function updatePackage(
|
|
|
68
68
|
|
|
69
69
|
const response = await packagesApi.updatePackage(
|
|
70
70
|
organizationName,
|
|
71
|
-
|
|
71
|
+
environmentName,
|
|
72
72
|
packageName,
|
|
73
73
|
packageUpdate,
|
|
74
74
|
{
|
package/src/commands/rm.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { deleteGroup } from "./group/deletegroup";
|
|
|
5
5
|
import { removeMember } from "./group/removemember";
|
|
6
6
|
import { deleteGroupAccessToken } from "./groupaccesstoken/deleteToken";
|
|
7
7
|
import { deletePackage } from "./package/deletepackage";
|
|
8
|
-
import {
|
|
8
|
+
import { deleteEnvironment } from "./environment/deleteenvironment";
|
|
9
|
+
import { warnProjectDeprecated } from "./legacy";
|
|
9
10
|
|
|
10
11
|
export const registerRmCommands = (cli: Command, environment: Environment) => {
|
|
11
12
|
const rm = cli
|
|
@@ -27,18 +28,33 @@ export const registerRmCommands = (cli: Command, environment: Environment) => {
|
|
|
27
28
|
);
|
|
28
29
|
});
|
|
29
30
|
|
|
31
|
+
const rmEnvironmentAction = (
|
|
32
|
+
environmentName: string,
|
|
33
|
+
options: { debug?: boolean; yes?: boolean },
|
|
34
|
+
) => {
|
|
35
|
+
deleteEnvironment(
|
|
36
|
+
controlPlanesByEnv[environment],
|
|
37
|
+
environmentName,
|
|
38
|
+
options.debug,
|
|
39
|
+
options.yes,
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
rm.command("environment")
|
|
44
|
+
.description("Delete an environment.")
|
|
45
|
+
.argument("<environmentName>", "The name of the environment to delete.")
|
|
46
|
+
.option("--debug")
|
|
47
|
+
.option("-y, --yes", "Skip confirmation.")
|
|
48
|
+
.action(rmEnvironmentAction);
|
|
49
|
+
|
|
30
50
|
rm.command("project")
|
|
31
|
-
.description("
|
|
32
|
-
.argument("<projectName>", "The name of the
|
|
51
|
+
.description("[deprecated] Alias for 'rm environment'.")
|
|
52
|
+
.argument("<projectName>", "The name of the environment to delete.")
|
|
33
53
|
.option("--debug")
|
|
34
54
|
.option("-y, --yes", "Skip confirmation.")
|
|
35
55
|
.action((projectName, options) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
projectName,
|
|
39
|
-
options.debug,
|
|
40
|
-
options.yes,
|
|
41
|
-
);
|
|
56
|
+
warnProjectDeprecated("rm environment");
|
|
57
|
+
rmEnvironmentAction(projectName, options);
|
|
42
58
|
});
|
|
43
59
|
|
|
44
60
|
rm.command("connection")
|
package/src/commands/set.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import {
|
|
2
|
+
import { setEnvironment } from "./environment/setenvironment";
|
|
3
|
+
import { warnProjectDeprecated } from "./legacy";
|
|
3
4
|
|
|
4
5
|
export const registerSetCommands = (cli: Command) => {
|
|
5
6
|
const set = cli
|
|
@@ -7,10 +8,18 @@ export const registerSetCommands = (cli: Command) => {
|
|
|
7
8
|
.description("Set a resource")
|
|
8
9
|
.argument("<resource>", "The resource to set");
|
|
9
10
|
|
|
11
|
+
set.command("environment")
|
|
12
|
+
.description("Set the default environment.")
|
|
13
|
+
.argument("<environmentName>", "The name of the environment to set.")
|
|
14
|
+
.action(setEnvironment);
|
|
15
|
+
|
|
10
16
|
set.command("project")
|
|
11
|
-
.description("
|
|
12
|
-
.argument("<projectName>", "The name of the
|
|
13
|
-
.action(
|
|
17
|
+
.description("[deprecated] Alias for 'set environment'.")
|
|
18
|
+
.argument("<projectName>", "The name of the environment to set.")
|
|
19
|
+
.action((projectName) => {
|
|
20
|
+
warnProjectDeprecated("set environment");
|
|
21
|
+
setEnvironment(projectName);
|
|
22
|
+
});
|
|
14
23
|
|
|
15
24
|
// TODO: It would be nice to `cred set org` and avoid logging again when switching orgs.
|
|
16
25
|
};
|
package/src/commands/update.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import { Command } from "commander";
|
|
2
3
|
import { controlPlanesByEnv, Environment } from "../constants";
|
|
3
4
|
import { updatePackage } from "./package/updatepackage";
|
|
4
|
-
import {
|
|
5
|
+
import { updateEnvironment } from "./environment/updateenvironment";
|
|
6
|
+
import { warnProjectDeprecated } from "./legacy";
|
|
5
7
|
|
|
6
8
|
export const registerUpdateCommands = (
|
|
7
9
|
cli: Command,
|
|
@@ -12,10 +14,35 @@ export const registerUpdateCommands = (
|
|
|
12
14
|
.description("Update a resource")
|
|
13
15
|
.argument("<resource>", "The resource to update");
|
|
14
16
|
|
|
17
|
+
const updateEnvironmentAction = (environmentName: string, options: any) => {
|
|
18
|
+
updateEnvironment(
|
|
19
|
+
controlPlanesByEnv[environment],
|
|
20
|
+
environmentName,
|
|
21
|
+
{
|
|
22
|
+
replicationCount: options.replication,
|
|
23
|
+
},
|
|
24
|
+
options.debug,
|
|
25
|
+
options.yes,
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
update
|
|
30
|
+
.command("environment")
|
|
31
|
+
.description("Update an environment.")
|
|
32
|
+
.argument("<environmentName>", "The name of the environment to update.")
|
|
33
|
+
.option(
|
|
34
|
+
"--replication <replicationCount>",
|
|
35
|
+
"The new replication count (must be at least 1).",
|
|
36
|
+
parseInt,
|
|
37
|
+
)
|
|
38
|
+
.option("--debug")
|
|
39
|
+
.option("-y, --yes", "Skip confirmation.")
|
|
40
|
+
.action(updateEnvironmentAction);
|
|
41
|
+
|
|
15
42
|
update
|
|
16
43
|
.command("project")
|
|
17
|
-
.description("
|
|
18
|
-
.argument("<projectName>", "The name of the
|
|
44
|
+
.description("[deprecated] Alias for 'update environment'.")
|
|
45
|
+
.argument("<projectName>", "The name of the environment to update.")
|
|
19
46
|
.option(
|
|
20
47
|
"--replication <replicationCount>",
|
|
21
48
|
"The new replication count (must be at least 1).",
|
|
@@ -24,15 +51,8 @@ export const registerUpdateCommands = (
|
|
|
24
51
|
.option("--debug")
|
|
25
52
|
.option("-y, --yes", "Skip confirmation.")
|
|
26
53
|
.action((projectName, options) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
projectName,
|
|
30
|
-
{
|
|
31
|
-
replicationCount: options.replication,
|
|
32
|
-
},
|
|
33
|
-
options.debug,
|
|
34
|
-
options.yes,
|
|
35
|
-
);
|
|
54
|
+
warnProjectDeprecated("update environment");
|
|
55
|
+
updateEnvironmentAction(projectName, options);
|
|
36
56
|
});
|
|
37
57
|
|
|
38
58
|
update
|
|
@@ -50,7 +50,7 @@ describe("archive-unarchive-version", () => {
|
|
|
50
50
|
|
|
51
51
|
expect(axiosStub.calledOnce).to.be.true;
|
|
52
52
|
expect(axiosStub.firstCall.args[0]).to.equal(
|
|
53
|
-
"http://test-server/organizations/test-org/
|
|
53
|
+
"http://test-server/organizations/test-org/environments/test-project/packages/test-package/versions/1.0.0",
|
|
54
54
|
);
|
|
55
55
|
expect(axiosStub.firstCall.args[1]).to.deep.equal({
|
|
56
56
|
archiveStatus: "archive",
|
|
@@ -96,7 +96,7 @@ describe("archive-unarchive-version", () => {
|
|
|
96
96
|
|
|
97
97
|
expect(axiosStub.calledOnce).to.be.true;
|
|
98
98
|
expect(axiosStub.firstCall.args[0]).to.equal(
|
|
99
|
-
"http://test-server/organizations/test-org/
|
|
99
|
+
"http://test-server/organizations/test-org/environments/test-project/packages/test-package/versions/1.0.0",
|
|
100
100
|
);
|
|
101
101
|
expect(axiosStub.firstCall.args[1]).to.deep.equal({
|
|
102
102
|
archiveStatus: "unarchive",
|
|
@@ -215,7 +215,7 @@ describe("archive-unarchive-version", () => {
|
|
|
215
215
|
expect(axiosStub.called).to.be.false;
|
|
216
216
|
expect(
|
|
217
217
|
loggerStub.error.calledWith(
|
|
218
|
-
sinon.match("Please, make sure to set
|
|
218
|
+
sinon.match("Please, make sure to set an environment"),
|
|
219
219
|
),
|
|
220
220
|
).to.be.true;
|
|
221
221
|
});
|
|
@@ -425,7 +425,7 @@ describe("archive-unarchive-version", () => {
|
|
|
425
425
|
);
|
|
426
426
|
|
|
427
427
|
expect(axiosStub.firstCall.args[0]).to.equal(
|
|
428
|
-
"https://api.example.com/organizations/test-org/
|
|
428
|
+
"https://api.example.com/organizations/test-org/environments/test-project/packages/my-package/versions/2.0.0",
|
|
429
429
|
);
|
|
430
430
|
});
|
|
431
431
|
|
|
@@ -47,15 +47,15 @@ async function updateVersionArchiveStatus(
|
|
|
47
47
|
) {
|
|
48
48
|
const clientConfig = new ClientConfiguration();
|
|
49
49
|
const organizationName = clientConfig.getOrganization();
|
|
50
|
-
const
|
|
50
|
+
const environmentName = clientConfig.getProject();
|
|
51
51
|
|
|
52
52
|
if (!clientConfig.doesConfigExists()) {
|
|
53
53
|
logger.error("Please, make sure that you are logged in");
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
if (!
|
|
58
|
-
logger.error("Please, make sure to set
|
|
57
|
+
if (!environmentName) {
|
|
58
|
+
logger.error("Please, make sure to set an environment");
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -81,12 +81,9 @@ async function updateVersionArchiveStatus(
|
|
|
81
81
|
logger.info(
|
|
82
82
|
`${action === "archive" ? "Archiving" : "Unarchiving"} version ${packageName}/${versionId}`,
|
|
83
83
|
);
|
|
84
|
-
console.log(
|
|
85
|
-
`${packageServer}/organizations/${organizationName}/projects/${projectName}/packages/${packageName}/versions/${versionId}`,
|
|
86
|
-
);
|
|
87
84
|
try {
|
|
88
85
|
const response = await axios.patch(
|
|
89
|
-
`${packageServer}/organizations/${organizationName}/
|
|
86
|
+
`${packageServer}/organizations/${organizationName}/environments/${environmentName}/packages/${packageName}/versions/${versionId}`,
|
|
90
87
|
{
|
|
91
88
|
archiveStatus: action,
|
|
92
89
|
},
|
|
@@ -119,7 +119,7 @@ describe("list-versions", () => {
|
|
|
119
119
|
expect(listVersionsStub.called).to.be.false;
|
|
120
120
|
expect(
|
|
121
121
|
loggerStub.error.calledWith(
|
|
122
|
-
sinon.match("Please, make sure to set
|
|
122
|
+
sinon.match("Please, make sure to set an environment"),
|
|
123
123
|
),
|
|
124
124
|
).to.be.true;
|
|
125
125
|
});
|
|
@@ -13,15 +13,15 @@ export async function listVersions(
|
|
|
13
13
|
) {
|
|
14
14
|
const clientConfig = new ClientConfiguration();
|
|
15
15
|
const organizationName = clientConfig.getOrganization();
|
|
16
|
-
const
|
|
16
|
+
const environmentName = clientConfig.getProject();
|
|
17
17
|
|
|
18
18
|
if (!clientConfig.doesConfigExists()) {
|
|
19
19
|
logger.error("Please, make sure that you are logged in");
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
if (!
|
|
24
|
-
logger.error("Please, make sure to set
|
|
23
|
+
if (!environmentName) {
|
|
24
|
+
logger.error("Please, make sure to set an environment");
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -29,7 +29,7 @@ export async function listVersions(
|
|
|
29
29
|
const packageName = packagePath.replace("/", "");
|
|
30
30
|
const response = await versionsApi.listVersions(
|
|
31
31
|
organizationName,
|
|
32
|
-
|
|
32
|
+
environmentName,
|
|
33
33
|
packageName,
|
|
34
34
|
{
|
|
35
35
|
baseURL: controlPlane,
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import {
|
|
3
|
+
CLUSTER_BY_ENVIRONMENT,
|
|
4
|
+
DEFAULT_ENVIRONMENT_BY_CLUSTER,
|
|
5
|
+
getAuth0OrganizationIdForCliLogin,
|
|
6
|
+
getCliOrgConfig,
|
|
7
|
+
} from "./constants";
|
|
8
|
+
|
|
9
|
+
describe("constants", () => {
|
|
10
|
+
describe("DEFAULT_ENVIRONMENT_BY_CLUSTER", () => {
|
|
11
|
+
it("defaults gcp to production", () => {
|
|
12
|
+
expect(DEFAULT_ENVIRONMENT_BY_CLUSTER.gcp).to.equal("production");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("defaults aws to videoamp", () => {
|
|
16
|
+
expect(DEFAULT_ENVIRONMENT_BY_CLUSTER.aws).to.equal("videoamp");
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("CLUSTER_BY_ENVIRONMENT", () => {
|
|
21
|
+
it("places videoamp on aws", () => {
|
|
22
|
+
expect(CLUSTER_BY_ENVIRONMENT.videoamp).to.equal("aws");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("places every other env on gcp", () => {
|
|
26
|
+
expect(CLUSTER_BY_ENVIRONMENT.production).to.equal("gcp");
|
|
27
|
+
expect(CLUSTER_BY_ENVIRONMENT.staging).to.equal("gcp");
|
|
28
|
+
expect(CLUSTER_BY_ENVIRONMENT.dev).to.equal("gcp");
|
|
29
|
+
expect(CLUSTER_BY_ENVIRONMENT.localhost).to.equal("gcp");
|
|
30
|
+
expect(CLUSTER_BY_ENVIRONMENT["e2e-test"]).to.equal("gcp");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("agrees with DEFAULT_ENVIRONMENT_BY_CLUSTER round-trip", () => {
|
|
34
|
+
for (const cluster of ["gcp", "aws"] as const) {
|
|
35
|
+
const defaultEnv = DEFAULT_ENVIRONMENT_BY_CLUSTER[cluster];
|
|
36
|
+
expect(CLUSTER_BY_ENVIRONMENT[defaultEnv]).to.equal(cluster);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("getCliOrgConfig", () => {
|
|
42
|
+
it("returns the videoamp registry entry", () => {
|
|
43
|
+
const cfg = getCliOrgConfig("videoamp");
|
|
44
|
+
expect(cfg).to.not.be.undefined;
|
|
45
|
+
expect(cfg!.cliOrgName).to.equal("videoamp");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("lists videoamp's supported clusters and default", () => {
|
|
49
|
+
const cfg = getCliOrgConfig("videoamp")!;
|
|
50
|
+
expect(cfg.supportedClusters).to.have.members(["gcp", "aws"]);
|
|
51
|
+
expect(cfg.defaultCluster).to.be.oneOf(cfg.supportedClusters);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("exposes the aws Auth0 org id for videoamp", () => {
|
|
55
|
+
const cfg = getCliOrgConfig("videoamp")!;
|
|
56
|
+
expect(cfg.auth0OrganizationIds?.aws).to.equal("org_nMRKafeSuxOiuJeG");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("is case-insensitive on the org name", () => {
|
|
60
|
+
expect(getCliOrgConfig("VideoAmp")?.cliOrgName).to.equal("videoamp");
|
|
61
|
+
expect(getCliOrgConfig("VIDEOAMP")?.cliOrgName).to.equal("videoamp");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("returns undefined for unregistered orgs (default gcp/device-flow path)", () => {
|
|
65
|
+
expect(getCliOrgConfig("acme")).to.be.undefined;
|
|
66
|
+
expect(getCliOrgConfig("some-new-customer")).to.be.undefined;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("guarantees defaultCluster is in supportedClusters for every entry", () => {
|
|
70
|
+
for (const name of ["videoamp"]) {
|
|
71
|
+
const cfg = getCliOrgConfig(name)!;
|
|
72
|
+
expect(cfg.supportedClusters).to.include(cfg.defaultCluster);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe("getAuth0OrganizationIdForCliLogin", () => {
|
|
78
|
+
it("returns the aws Auth0 org id when -c aws is the active cluster", () => {
|
|
79
|
+
expect(getAuth0OrganizationIdForCliLogin("videoamp", "aws")).to.equal(
|
|
80
|
+
"org_nMRKafeSuxOiuJeG",
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("returns undefined for videoamp on gcp (no aws-only Auth0 id maps to gcp)", () => {
|
|
85
|
+
expect(getAuth0OrganizationIdForCliLogin("videoamp", "gcp")).to.be
|
|
86
|
+
.undefined;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("falls back to the org's defaultCluster when no cluster is passed", () => {
|
|
90
|
+
const cfg = getCliOrgConfig("videoamp")!;
|
|
91
|
+
const expected = cfg.auth0OrganizationIds?.[cfg.defaultCluster];
|
|
92
|
+
expect(getAuth0OrganizationIdForCliLogin("videoamp")).to.equal(
|
|
93
|
+
expected,
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("is case-insensitive on the org name", () => {
|
|
98
|
+
expect(getAuth0OrganizationIdForCliLogin("VideoAmp", "aws")).to.equal(
|
|
99
|
+
"org_nMRKafeSuxOiuJeG",
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("returns undefined for unregistered orgs (forces device-code flow)", () => {
|
|
104
|
+
expect(getAuth0OrganizationIdForCliLogin("acme")).to.be.undefined;
|
|
105
|
+
expect(getAuth0OrganizationIdForCliLogin("acme", "aws")).to.be
|
|
106
|
+
.undefined;
|
|
107
|
+
expect(getAuth0OrganizationIdForCliLogin("acme", "gcp")).to.be
|
|
108
|
+
.undefined;
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|