@contember/cli 2.1.0-alpha.15 → 2.1.0-alpha.16
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/dist/development/src/commands/actions/ActionsGetEventCommand.cjs +31 -0
- package/dist/development/src/commands/actions/ActionsGetEventCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsGetEventCommand.js +31 -0
- package/dist/development/src/commands/actions/ActionsGetEventCommand.js.map +1 -0
- package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.cjs +60 -0
- package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.js +60 -0
- package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.js.map +1 -0
- package/dist/development/src/commands/actions/ActionsListVariablesCommand.cjs +29 -0
- package/dist/development/src/commands/actions/ActionsListVariablesCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsListVariablesCommand.js +29 -0
- package/dist/development/src/commands/actions/ActionsListVariablesCommand.js.map +1 -0
- package/dist/development/src/commands/actions/ActionsRetryEventCommand.cjs +32 -0
- package/dist/development/src/commands/actions/ActionsRetryEventCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsRetryEventCommand.js +32 -0
- package/dist/development/src/commands/actions/ActionsRetryEventCommand.js.map +1 -0
- package/dist/development/src/commands/actions/ActionsSetVariablesCommand.cjs +40 -0
- package/dist/development/src/commands/actions/ActionsSetVariablesCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsSetVariablesCommand.js +40 -0
- package/dist/development/src/commands/actions/ActionsSetVariablesCommand.js.map +1 -0
- package/dist/development/src/commands/actions/ActionsStopEventCommand.cjs +32 -0
- package/dist/development/src/commands/actions/ActionsStopEventCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsStopEventCommand.js +32 -0
- package/dist/development/src/commands/actions/ActionsStopEventCommand.js.map +1 -0
- package/dist/development/src/commands/migrations/MigrationStatusCommand.cjs +1 -1
- package/dist/development/src/commands/migrations/MigrationStatusCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationStatusCommand.js +1 -1
- package/dist/development/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
- package/dist/development/src/commands/transfer/ExportCommand.cjs +7 -2
- package/dist/development/src/commands/transfer/ExportCommand.cjs.map +1 -1
- package/dist/development/src/commands/transfer/ExportCommand.js +8 -3
- package/dist/development/src/commands/transfer/ExportCommand.js.map +1 -1
- package/dist/development/src/commands/transfer/ImportCommand.cjs +7 -4
- package/dist/development/src/commands/transfer/ImportCommand.cjs.map +1 -1
- package/dist/development/src/commands/transfer/ImportCommand.js +5 -2
- package/dist/development/src/commands/transfer/ImportCommand.js.map +1 -1
- package/dist/development/src/commands/transfer/TransferCommand.cjs +4 -5
- package/dist/development/src/commands/transfer/TransferCommand.cjs.map +1 -1
- package/dist/development/src/commands/transfer/TransferCommand.js +4 -5
- package/dist/development/src/commands/transfer/TransferCommand.js.map +1 -1
- package/dist/development/src/dic.cjs +14 -2
- package/dist/development/src/dic.cjs.map +1 -1
- package/dist/development/src/dic.js +14 -2
- package/dist/development/src/dic.js.map +1 -1
- package/dist/development/src/lib/VersionChecker.cjs +7 -9
- package/dist/development/src/lib/VersionChecker.cjs.map +1 -1
- package/dist/development/src/lib/VersionChecker.js +7 -9
- package/dist/development/src/lib/VersionChecker.js.map +1 -1
- package/dist/development/src/lib/actions/ActionsClient.cjs +91 -0
- package/dist/development/src/lib/actions/ActionsClient.cjs.map +1 -0
- package/dist/development/src/lib/actions/ActionsClient.js +91 -0
- package/dist/development/src/lib/actions/ActionsClient.js.map +1 -0
- package/dist/development/src/lib/migrations/MigrationPrinter.cjs +7 -2
- package/dist/development/src/lib/migrations/MigrationPrinter.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationPrinter.js +7 -2
- package/dist/development/src/lib/migrations/MigrationPrinter.js.map +1 -1
- package/dist/development/src/lib/migrations/MigrationsStatusFacade.cjs +3 -3
- package/dist/development/src/lib/migrations/MigrationsStatusFacade.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationsStatusFacade.js +3 -3
- package/dist/development/src/lib/migrations/MigrationsStatusFacade.js.map +1 -1
- package/dist/development/src/lib/stream.cjs +0 -7
- package/dist/development/src/lib/stream.cjs.map +1 -1
- package/dist/development/src/lib/stream.js +1 -8
- package/dist/development/src/lib/stream.js.map +1 -1
- package/dist/development/src/lib/transfer/DataTransferClient.cjs +23 -34
- package/dist/development/src/lib/transfer/DataTransferClient.cjs.map +1 -1
- package/dist/development/src/lib/transfer/DataTransferClient.js +25 -36
- package/dist/development/src/lib/transfer/DataTransferClient.js.map +1 -1
- package/dist/production/src/commands/actions/ActionsGetEventCommand.cjs +31 -0
- package/dist/production/src/commands/actions/ActionsGetEventCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsGetEventCommand.js +31 -0
- package/dist/production/src/commands/actions/ActionsGetEventCommand.js.map +1 -0
- package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.cjs +60 -0
- package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.js +60 -0
- package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.js.map +1 -0
- package/dist/production/src/commands/actions/ActionsListVariablesCommand.cjs +29 -0
- package/dist/production/src/commands/actions/ActionsListVariablesCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsListVariablesCommand.js +29 -0
- package/dist/production/src/commands/actions/ActionsListVariablesCommand.js.map +1 -0
- package/dist/production/src/commands/actions/ActionsRetryEventCommand.cjs +32 -0
- package/dist/production/src/commands/actions/ActionsRetryEventCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsRetryEventCommand.js +32 -0
- package/dist/production/src/commands/actions/ActionsRetryEventCommand.js.map +1 -0
- package/dist/production/src/commands/actions/ActionsSetVariablesCommand.cjs +40 -0
- package/dist/production/src/commands/actions/ActionsSetVariablesCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsSetVariablesCommand.js +40 -0
- package/dist/production/src/commands/actions/ActionsSetVariablesCommand.js.map +1 -0
- package/dist/production/src/commands/actions/ActionsStopEventCommand.cjs +32 -0
- package/dist/production/src/commands/actions/ActionsStopEventCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsStopEventCommand.js +32 -0
- package/dist/production/src/commands/actions/ActionsStopEventCommand.js.map +1 -0
- package/dist/production/src/commands/migrations/MigrationStatusCommand.cjs +1 -1
- package/dist/production/src/commands/migrations/MigrationStatusCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationStatusCommand.js +1 -1
- package/dist/production/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
- package/dist/production/src/commands/transfer/ExportCommand.cjs +7 -2
- package/dist/production/src/commands/transfer/ExportCommand.cjs.map +1 -1
- package/dist/production/src/commands/transfer/ExportCommand.js +8 -3
- package/dist/production/src/commands/transfer/ExportCommand.js.map +1 -1
- package/dist/production/src/commands/transfer/ImportCommand.cjs +7 -4
- package/dist/production/src/commands/transfer/ImportCommand.cjs.map +1 -1
- package/dist/production/src/commands/transfer/ImportCommand.js +5 -2
- package/dist/production/src/commands/transfer/ImportCommand.js.map +1 -1
- package/dist/production/src/commands/transfer/TransferCommand.cjs +4 -5
- package/dist/production/src/commands/transfer/TransferCommand.cjs.map +1 -1
- package/dist/production/src/commands/transfer/TransferCommand.js +4 -5
- package/dist/production/src/commands/transfer/TransferCommand.js.map +1 -1
- package/dist/production/src/dic.cjs +14 -2
- package/dist/production/src/dic.cjs.map +1 -1
- package/dist/production/src/dic.js +14 -2
- package/dist/production/src/dic.js.map +1 -1
- package/dist/production/src/lib/VersionChecker.cjs +7 -9
- package/dist/production/src/lib/VersionChecker.cjs.map +1 -1
- package/dist/production/src/lib/VersionChecker.js +7 -9
- package/dist/production/src/lib/VersionChecker.js.map +1 -1
- package/dist/production/src/lib/actions/ActionsClient.cjs +91 -0
- package/dist/production/src/lib/actions/ActionsClient.cjs.map +1 -0
- package/dist/production/src/lib/actions/ActionsClient.js +91 -0
- package/dist/production/src/lib/actions/ActionsClient.js.map +1 -0
- package/dist/production/src/lib/migrations/MigrationPrinter.cjs +7 -2
- package/dist/production/src/lib/migrations/MigrationPrinter.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationPrinter.js +7 -2
- package/dist/production/src/lib/migrations/MigrationPrinter.js.map +1 -1
- package/dist/production/src/lib/migrations/MigrationsStatusFacade.cjs +3 -3
- package/dist/production/src/lib/migrations/MigrationsStatusFacade.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationsStatusFacade.js +3 -3
- package/dist/production/src/lib/migrations/MigrationsStatusFacade.js.map +1 -1
- package/dist/production/src/lib/stream.cjs +0 -7
- package/dist/production/src/lib/stream.cjs.map +1 -1
- package/dist/production/src/lib/stream.js +1 -8
- package/dist/production/src/lib/stream.js.map +1 -1
- package/dist/production/src/lib/transfer/DataTransferClient.cjs +23 -34
- package/dist/production/src/lib/transfer/DataTransferClient.cjs.map +1 -1
- package/dist/production/src/lib/transfer/DataTransferClient.js +25 -36
- package/dist/production/src/lib/transfer/DataTransferClient.js.map +1 -1
- package/dist/types/commands/actions/ActionsGetEventCommand.d.ts +16 -0
- package/dist/types/commands/actions/ActionsGetEventCommand.d.ts.map +1 -0
- package/dist/types/commands/actions/ActionsListFailedEventsCommand.d.ts +15 -0
- package/dist/types/commands/actions/ActionsListFailedEventsCommand.d.ts.map +1 -0
- package/dist/types/commands/actions/ActionsListVariablesCommand.d.ts +14 -0
- package/dist/types/commands/actions/ActionsListVariablesCommand.d.ts.map +1 -0
- package/dist/types/commands/actions/ActionsRetryEventCommand.d.ts +16 -0
- package/dist/types/commands/actions/ActionsRetryEventCommand.d.ts.map +1 -0
- package/dist/types/commands/actions/ActionsSetVariablesCommand.d.ts +19 -0
- package/dist/types/commands/actions/ActionsSetVariablesCommand.d.ts.map +1 -0
- package/dist/types/commands/actions/ActionsStopEventCommand.d.ts +16 -0
- package/dist/types/commands/actions/ActionsStopEventCommand.d.ts.map +1 -0
- package/dist/types/commands/transfer/ExportCommand.d.ts.map +1 -1
- package/dist/types/commands/transfer/ImportCommand.d.ts.map +1 -1
- package/dist/types/commands/transfer/TransferCommand.d.ts.map +1 -1
- package/dist/types/dic.d.ts +18 -0
- package/dist/types/dic.d.ts.map +1 -1
- package/dist/types/lib/VersionChecker.d.ts.map +1 -1
- package/dist/types/lib/actions/ActionsClient.d.ts +33 -0
- package/dist/types/lib/actions/ActionsClient.d.ts.map +1 -0
- package/dist/types/lib/migrations/MigrationPrinter.d.ts +1 -1
- package/dist/types/lib/migrations/MigrationPrinter.d.ts.map +1 -1
- package/dist/types/lib/migrations/MigrationsStatusFacade.d.ts +3 -1
- package/dist/types/lib/migrations/MigrationsStatusFacade.d.ts.map +1 -1
- package/dist/types/lib/transfer/DataTransferClient.d.ts +2 -4
- package/dist/types/lib/transfer/DataTransferClient.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/commands/actions/ActionsGetEventCommand.ts +42 -0
- package/src/commands/actions/ActionsListFailedEventsCommand.ts +70 -0
- package/src/commands/actions/ActionsListVariablesCommand.ts +37 -0
- package/src/commands/actions/ActionsRetryEventCommand.ts +42 -0
- package/src/commands/actions/ActionsSetVariablesCommand.ts +56 -0
- package/src/commands/actions/ActionsStopEventCommand.ts +42 -0
- package/src/commands/migrations/MigrationStatusCommand.ts +1 -1
- package/src/commands/transfer/ExportCommand.ts +9 -4
- package/src/commands/transfer/ImportCommand.ts +6 -1
- package/src/commands/transfer/TransferCommand.ts +4 -3
- package/src/dic.ts +27 -2
- package/src/lib/VersionChecker.ts +13 -9
- package/src/lib/actions/ActionsClient.ts +112 -0
- package/src/lib/migrations/MigrationPrinter.ts +7 -2
- package/src/lib/migrations/MigrationsStatusFacade.ts +4 -3
- package/src/lib/transfer/DataTransferClient.ts +24 -43
- package/dist/development/src/lib/migrations/migrations.cjs +0 -43
- package/dist/development/src/lib/migrations/migrations.cjs.map +0 -1
- package/dist/development/src/lib/migrations/migrations.js +0 -43
- package/dist/development/src/lib/migrations/migrations.js.map +0 -1
- package/dist/production/src/lib/migrations/migrations.cjs +0 -43
- package/dist/production/src/lib/migrations/migrations.cjs.map +0 -1
- package/dist/production/src/lib/migrations/migrations.js +0 -43
- package/dist/production/src/lib/migrations/migrations.js.map +0 -1
- package/dist/types/lib/migrations/migrations.d.ts +0 -3
- package/dist/types/lib/migrations/migrations.d.ts.map +0 -1
- package/src/lib/migrations/migrations.ts +0 -45
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsListVariablesCommand.cjs","sources":["../../../../../../packages/cli/src/commands/actions/ActionsListVariablesCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\nimport chalkTable from 'chalk-table'\n\ntype Args = {\n}\n\ntype Options = {\n\tproject?: string\n}\n\nexport class ActionsListVariablesCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Show action variables')\n\t\tconfiguration.option('project').valueRequired()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\t\tconst result = await api.listVariables()\n\t\tconsole.log(chalkTable({\n\t\t\tcolumns: ['name', 'value'],\n\t\t}, result))\n\t}\n}\n"],"names":["Command","ActionsClient"],"mappings":";;;;;AAYO,MAAM,oCAAoCA,UAAAA,QAAuB;AAAA,EACvE,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uBAAuB;AACnC,kBAAA,OAAO,SAAS,EAAE,cAAc;AAAA,EAAA;AAAA,EAG/C,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAMC,4BAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AACxE,UAAA,SAAS,MAAM,IAAI,cAAc;AACvC,YAAQ,IAAI,WAAW;AAAA,MACtB,SAAS,CAAC,QAAQ,OAAO;AAAA,IAC1B,GAAG,MAAM,CAAC;AAAA,EAAA;AAEZ;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Command } from "@contember/cli-common";
|
|
2
|
+
import { ActionsClient } from "../../lib/actions/ActionsClient.js";
|
|
3
|
+
import chalkTable from "chalk-table";
|
|
4
|
+
class ActionsListVariablesCommand extends Command {
|
|
5
|
+
constructor(remoteProjectResolver) {
|
|
6
|
+
super();
|
|
7
|
+
this.remoteProjectResolver = remoteProjectResolver;
|
|
8
|
+
}
|
|
9
|
+
configure(configuration) {
|
|
10
|
+
configuration.description("Show action variables");
|
|
11
|
+
configuration.option("project").valueRequired();
|
|
12
|
+
}
|
|
13
|
+
async execute(input) {
|
|
14
|
+
const dsn = input.getOption("project");
|
|
15
|
+
const project = await this.remoteProjectResolver.resolve(dsn);
|
|
16
|
+
if (!project) {
|
|
17
|
+
throw `Project not defined`;
|
|
18
|
+
}
|
|
19
|
+
const api = ActionsClient.create(project.endpoint, project.name, project.token);
|
|
20
|
+
const result = await api.listVariables();
|
|
21
|
+
console.log(chalkTable({
|
|
22
|
+
columns: ["name", "value"]
|
|
23
|
+
}, result));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
ActionsListVariablesCommand
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=ActionsListVariablesCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsListVariablesCommand.js","sources":["../../../../../../packages/cli/src/commands/actions/ActionsListVariablesCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\nimport chalkTable from 'chalk-table'\n\ntype Args = {\n}\n\ntype Options = {\n\tproject?: string\n}\n\nexport class ActionsListVariablesCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Show action variables')\n\t\tconfiguration.option('project').valueRequired()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\t\tconst result = await api.listVariables()\n\t\tconsole.log(chalkTable({\n\t\t\tcolumns: ['name', 'value'],\n\t\t}, result))\n\t}\n}\n"],"names":[],"mappings":";;;AAYO,MAAM,oCAAoC,QAAuB;AAAA,EACvE,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uBAAuB;AACnC,kBAAA,OAAO,SAAS,EAAE,cAAc;AAAA,EAAA;AAAA,EAG/C,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAM,cAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AACxE,UAAA,SAAS,MAAM,IAAI,cAAc;AACvC,YAAQ,IAAI,WAAW;AAAA,MACtB,SAAS,CAAC,QAAQ,OAAO;AAAA,IAC1B,GAAG,MAAM,CAAC;AAAA,EAAA;AAEZ;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const cliCommon = require("@contember/cli-common");
|
|
4
|
+
const ActionsClient = require("../../lib/actions/ActionsClient.cjs");
|
|
5
|
+
class ActionsRetryEventCommand extends cliCommon.Command {
|
|
6
|
+
constructor(remoteProjectResolver) {
|
|
7
|
+
super();
|
|
8
|
+
this.remoteProjectResolver = remoteProjectResolver;
|
|
9
|
+
}
|
|
10
|
+
configure(configuration) {
|
|
11
|
+
configuration.description("Retry given event");
|
|
12
|
+
configuration.argument("eventId");
|
|
13
|
+
configuration.option("project").valueRequired();
|
|
14
|
+
}
|
|
15
|
+
async execute(input) {
|
|
16
|
+
const dsn = input.getOption("project");
|
|
17
|
+
const project = await this.remoteProjectResolver.resolve(dsn);
|
|
18
|
+
if (!project) {
|
|
19
|
+
throw `Project not defined`;
|
|
20
|
+
}
|
|
21
|
+
const api = ActionsClient.ActionsClient.create(project.endpoint, project.name, project.token);
|
|
22
|
+
const result = await api.retryEvent(input.getArgument("eventId"));
|
|
23
|
+
if (result) {
|
|
24
|
+
console.log("Event requeued for processing");
|
|
25
|
+
} else {
|
|
26
|
+
console.log("Failed to requeue event. Check the event status");
|
|
27
|
+
return 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.ActionsRetryEventCommand = ActionsRetryEventCommand;
|
|
32
|
+
//# sourceMappingURL=ActionsRetryEventCommand.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsRetryEventCommand.cjs","sources":["../../../../../../packages/cli/src/commands/actions/ActionsRetryEventCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\nimport chalkTable from 'chalk-table'\ntype Args = {\n\teventId: string\n}\n\ntype Options = {\n\tproject?: string\n}\n\nexport class ActionsRetryEventCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Retry given event')\n\t\tconfiguration.argument('eventId')\n\t\tconfiguration.option('project').valueRequired()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\n\t\tconst result = await api.retryEvent(input.getArgument('eventId'))\n\t\tif (result) {\n\t\t\tconsole.log('Event requeued for processing')\n\t\t} else {\n\t\t\tconsole.log('Failed to requeue event. Check the event status')\n\t\t\treturn 1\n\t\t}\n\t}\n}\n"],"names":["Command","ActionsClient"],"mappings":";;;;AAYO,MAAM,iCAAiCA,UAAAA,QAAuB;AAAA,EACpE,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,mBAAmB;AAC7C,kBAAc,SAAS,SAAS;AAClB,kBAAA,OAAO,SAAS,EAAE,cAAc;AAAA,EAAA;AAAA,EAG/C,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAMC,4BAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAE9E,UAAM,SAAS,MAAM,IAAI,WAAW,MAAM,YAAY,SAAS,CAAC;AAChE,QAAI,QAAQ;AACX,cAAQ,IAAI,+BAA+B;AAAA,IAAA,OACrC;AACN,cAAQ,IAAI,iDAAiD;AACtD,aAAA;AAAA,IAAA;AAAA,EACR;AAEF;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Command } from "@contember/cli-common";
|
|
2
|
+
import { ActionsClient } from "../../lib/actions/ActionsClient.js";
|
|
3
|
+
class ActionsRetryEventCommand extends Command {
|
|
4
|
+
constructor(remoteProjectResolver) {
|
|
5
|
+
super();
|
|
6
|
+
this.remoteProjectResolver = remoteProjectResolver;
|
|
7
|
+
}
|
|
8
|
+
configure(configuration) {
|
|
9
|
+
configuration.description("Retry given event");
|
|
10
|
+
configuration.argument("eventId");
|
|
11
|
+
configuration.option("project").valueRequired();
|
|
12
|
+
}
|
|
13
|
+
async execute(input) {
|
|
14
|
+
const dsn = input.getOption("project");
|
|
15
|
+
const project = await this.remoteProjectResolver.resolve(dsn);
|
|
16
|
+
if (!project) {
|
|
17
|
+
throw `Project not defined`;
|
|
18
|
+
}
|
|
19
|
+
const api = ActionsClient.create(project.endpoint, project.name, project.token);
|
|
20
|
+
const result = await api.retryEvent(input.getArgument("eventId"));
|
|
21
|
+
if (result) {
|
|
22
|
+
console.log("Event requeued for processing");
|
|
23
|
+
} else {
|
|
24
|
+
console.log("Failed to requeue event. Check the event status");
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
ActionsRetryEventCommand
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=ActionsRetryEventCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsRetryEventCommand.js","sources":["../../../../../../packages/cli/src/commands/actions/ActionsRetryEventCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\nimport chalkTable from 'chalk-table'\ntype Args = {\n\teventId: string\n}\n\ntype Options = {\n\tproject?: string\n}\n\nexport class ActionsRetryEventCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Retry given event')\n\t\tconfiguration.argument('eventId')\n\t\tconfiguration.option('project').valueRequired()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\n\t\tconst result = await api.retryEvent(input.getArgument('eventId'))\n\t\tif (result) {\n\t\t\tconsole.log('Event requeued for processing')\n\t\t} else {\n\t\t\tconsole.log('Failed to requeue event. Check the event status')\n\t\t\treturn 1\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAYO,MAAM,iCAAiC,QAAuB;AAAA,EACpE,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,mBAAmB;AAC7C,kBAAc,SAAS,SAAS;AAClB,kBAAA,OAAO,SAAS,EAAE,cAAc;AAAA,EAAA;AAAA,EAG/C,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAM,cAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAE9E,UAAM,SAAS,MAAM,IAAI,WAAW,MAAM,YAAY,SAAS,CAAC;AAChE,QAAI,QAAQ;AACX,cAAQ,IAAI,+BAA+B;AAAA,IAAA,OACrC;AACN,cAAQ,IAAI,iDAAiD;AACtD,aAAA;AAAA,IAAA;AAAA,EACR;AAEF;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const cliCommon = require("@contember/cli-common");
|
|
4
|
+
const ActionsClient = require("../../lib/actions/ActionsClient.cjs");
|
|
5
|
+
class ActionsSetVariablesCommand extends cliCommon.Command {
|
|
6
|
+
constructor(remoteProjectResolver) {
|
|
7
|
+
super();
|
|
8
|
+
this.remoteProjectResolver = remoteProjectResolver;
|
|
9
|
+
}
|
|
10
|
+
configure(configuration) {
|
|
11
|
+
configuration.description("Set action variables");
|
|
12
|
+
configuration.option("project").valueRequired();
|
|
13
|
+
configuration.option("merge").valueNone().description("merges with new values (default behaviour)");
|
|
14
|
+
configuration.option("set").valueNone().description("replaces all variables");
|
|
15
|
+
configuration.option("append-only-missing").valueNone().description("appends values if not already exist");
|
|
16
|
+
configuration.argument("variables").variadic().description("variables to set, in the form of name=value");
|
|
17
|
+
}
|
|
18
|
+
async execute(input) {
|
|
19
|
+
const dsn = input.getOption("project");
|
|
20
|
+
const project = await this.remoteProjectResolver.resolve(dsn);
|
|
21
|
+
if (!project) {
|
|
22
|
+
throw `Project not defined`;
|
|
23
|
+
}
|
|
24
|
+
const api = ActionsClient.ActionsClient.create(project.endpoint, project.name, project.token);
|
|
25
|
+
const mode = input.getOption("merge") ? "MERGE" : input.getOption("set") ? "SET" : input.getOption("append-only-missing") ? "APPEND_ONLY_MISSING" : "MERGE";
|
|
26
|
+
const variables = input.getArgument("variables").flatMap((it) => it.split("\n")).filter((it) => it.trim().length > 0);
|
|
27
|
+
const result = await api.setVariables(variables.map((it) => {
|
|
28
|
+
const [name, value] = it.split("=");
|
|
29
|
+
return { name, value };
|
|
30
|
+
}), mode);
|
|
31
|
+
if (result) {
|
|
32
|
+
console.log("Success");
|
|
33
|
+
} else {
|
|
34
|
+
console.error("Failed");
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.ActionsSetVariablesCommand = ActionsSetVariablesCommand;
|
|
40
|
+
//# sourceMappingURL=ActionsSetVariablesCommand.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsSetVariablesCommand.cjs","sources":["../../../../../../packages/cli/src/commands/actions/ActionsSetVariablesCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\n\ntype Args = {\n\tvariables: string[]\n}\n\ntype Options = {\n\tproject?: string\n\tmerge?: boolean\n\tset?: boolean\n\t['append-only-missing']?: boolean\n}\n\nexport class ActionsSetVariablesCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Set action variables')\n\t\tconfiguration.option('project').valueRequired()\n\t\tconfiguration.option('merge').valueNone().description('merges with new values (default behaviour)')\n\t\tconfiguration.option('set').valueNone().description('replaces all variables')\n\t\tconfiguration.option('append-only-missing').valueNone().description('appends values if not already exist')\n\t\tconfiguration.argument('variables').variadic().description('variables to set, in the form of name=value')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\t\tconst mode = input.getOption('merge')\n\t\t\t? 'MERGE' as const : input.getOption('set')\n\t\t\t\t? 'SET' as const : input.getOption('append-only-missing')\n\t\t\t\t\t? 'APPEND_ONLY_MISSING' as const : 'MERGE' as const\n\n\t\tconst variables = input.getArgument('variables').flatMap(it => it.split('\\n')).filter(it => it.trim().length > 0)\n\t\tconst result = await api.setVariables(variables.map(it => {\n\t\t\tconst [name, value] = it.split('=')\n\t\t\treturn { name, value }\n\t\t}), mode)\n\t\tif (result) {\n\t\t\tconsole.log('Success')\n\t\t} else {\n\t\t\tconsole.error('Failed')\n\t\t\treturn 1\n\t\t}\n\t}\n}\n"],"names":["Command","ActionsClient"],"mappings":";;;;AAeO,MAAM,mCAAmCA,UAAAA,QAAuB;AAAA,EACtE,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,sBAAsB;AAClC,kBAAA,OAAO,SAAS,EAAE,cAAc;AAC9C,kBAAc,OAAO,OAAO,EAAE,UAAU,EAAE,YAAY,4CAA4C;AAClG,kBAAc,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,wBAAwB;AAC5E,kBAAc,OAAO,qBAAqB,EAAE,UAAU,EAAE,YAAY,qCAAqC;AACzG,kBAAc,SAAS,WAAW,EAAE,SAAS,EAAE,YAAY,6CAA6C;AAAA,EAAA;AAAA,EAGzG,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAMC,4BAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAC9E,UAAM,OAAO,MAAM,UAAU,OAAO,IACjC,UAAmB,MAAM,UAAU,KAAK,IACvC,QAAiB,MAAM,UAAU,qBAAqB,IACrD,wBAAiC;AAEtC,UAAM,YAAY,MAAM,YAAY,WAAW,EAAE,QAAQ,QAAM,GAAG,MAAM,IAAI,CAAC,EAAE,OAAO,CAAA,OAAM,GAAG,KAAK,EAAE,SAAS,CAAC;AAChH,UAAM,SAAS,MAAM,IAAI,aAAa,UAAU,IAAI,CAAM,OAAA;AACzD,YAAM,CAAC,MAAM,KAAK,IAAI,GAAG,MAAM,GAAG;AAC3B,aAAA,EAAE,MAAM,MAAM;AAAA,IACrB,CAAA,GAAG,IAAI;AACR,QAAI,QAAQ;AACX,cAAQ,IAAI,SAAS;AAAA,IAAA,OACf;AACN,cAAQ,MAAM,QAAQ;AACf,aAAA;AAAA,IAAA;AAAA,EACR;AAEF;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Command } from "@contember/cli-common";
|
|
2
|
+
import { ActionsClient } from "../../lib/actions/ActionsClient.js";
|
|
3
|
+
class ActionsSetVariablesCommand extends Command {
|
|
4
|
+
constructor(remoteProjectResolver) {
|
|
5
|
+
super();
|
|
6
|
+
this.remoteProjectResolver = remoteProjectResolver;
|
|
7
|
+
}
|
|
8
|
+
configure(configuration) {
|
|
9
|
+
configuration.description("Set action variables");
|
|
10
|
+
configuration.option("project").valueRequired();
|
|
11
|
+
configuration.option("merge").valueNone().description("merges with new values (default behaviour)");
|
|
12
|
+
configuration.option("set").valueNone().description("replaces all variables");
|
|
13
|
+
configuration.option("append-only-missing").valueNone().description("appends values if not already exist");
|
|
14
|
+
configuration.argument("variables").variadic().description("variables to set, in the form of name=value");
|
|
15
|
+
}
|
|
16
|
+
async execute(input) {
|
|
17
|
+
const dsn = input.getOption("project");
|
|
18
|
+
const project = await this.remoteProjectResolver.resolve(dsn);
|
|
19
|
+
if (!project) {
|
|
20
|
+
throw `Project not defined`;
|
|
21
|
+
}
|
|
22
|
+
const api = ActionsClient.create(project.endpoint, project.name, project.token);
|
|
23
|
+
const mode = input.getOption("merge") ? "MERGE" : input.getOption("set") ? "SET" : input.getOption("append-only-missing") ? "APPEND_ONLY_MISSING" : "MERGE";
|
|
24
|
+
const variables = input.getArgument("variables").flatMap((it) => it.split("\n")).filter((it) => it.trim().length > 0);
|
|
25
|
+
const result = await api.setVariables(variables.map((it) => {
|
|
26
|
+
const [name, value] = it.split("=");
|
|
27
|
+
return { name, value };
|
|
28
|
+
}), mode);
|
|
29
|
+
if (result) {
|
|
30
|
+
console.log("Success");
|
|
31
|
+
} else {
|
|
32
|
+
console.error("Failed");
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
ActionsSetVariablesCommand
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=ActionsSetVariablesCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsSetVariablesCommand.js","sources":["../../../../../../packages/cli/src/commands/actions/ActionsSetVariablesCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\n\ntype Args = {\n\tvariables: string[]\n}\n\ntype Options = {\n\tproject?: string\n\tmerge?: boolean\n\tset?: boolean\n\t['append-only-missing']?: boolean\n}\n\nexport class ActionsSetVariablesCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Set action variables')\n\t\tconfiguration.option('project').valueRequired()\n\t\tconfiguration.option('merge').valueNone().description('merges with new values (default behaviour)')\n\t\tconfiguration.option('set').valueNone().description('replaces all variables')\n\t\tconfiguration.option('append-only-missing').valueNone().description('appends values if not already exist')\n\t\tconfiguration.argument('variables').variadic().description('variables to set, in the form of name=value')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\t\tconst mode = input.getOption('merge')\n\t\t\t? 'MERGE' as const : input.getOption('set')\n\t\t\t\t? 'SET' as const : input.getOption('append-only-missing')\n\t\t\t\t\t? 'APPEND_ONLY_MISSING' as const : 'MERGE' as const\n\n\t\tconst variables = input.getArgument('variables').flatMap(it => it.split('\\n')).filter(it => it.trim().length > 0)\n\t\tconst result = await api.setVariables(variables.map(it => {\n\t\t\tconst [name, value] = it.split('=')\n\t\t\treturn { name, value }\n\t\t}), mode)\n\t\tif (result) {\n\t\t\tconsole.log('Success')\n\t\t} else {\n\t\t\tconsole.error('Failed')\n\t\t\treturn 1\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAeO,MAAM,mCAAmC,QAAuB;AAAA,EACtE,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,sBAAsB;AAClC,kBAAA,OAAO,SAAS,EAAE,cAAc;AAC9C,kBAAc,OAAO,OAAO,EAAE,UAAU,EAAE,YAAY,4CAA4C;AAClG,kBAAc,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,wBAAwB;AAC5E,kBAAc,OAAO,qBAAqB,EAAE,UAAU,EAAE,YAAY,qCAAqC;AACzG,kBAAc,SAAS,WAAW,EAAE,SAAS,EAAE,YAAY,6CAA6C;AAAA,EAAA;AAAA,EAGzG,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAM,cAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAC9E,UAAM,OAAO,MAAM,UAAU,OAAO,IACjC,UAAmB,MAAM,UAAU,KAAK,IACvC,QAAiB,MAAM,UAAU,qBAAqB,IACrD,wBAAiC;AAEtC,UAAM,YAAY,MAAM,YAAY,WAAW,EAAE,QAAQ,QAAM,GAAG,MAAM,IAAI,CAAC,EAAE,OAAO,CAAA,OAAM,GAAG,KAAK,EAAE,SAAS,CAAC;AAChH,UAAM,SAAS,MAAM,IAAI,aAAa,UAAU,IAAI,CAAM,OAAA;AACzD,YAAM,CAAC,MAAM,KAAK,IAAI,GAAG,MAAM,GAAG;AAC3B,aAAA,EAAE,MAAM,MAAM;AAAA,IACrB,CAAA,GAAG,IAAI;AACR,QAAI,QAAQ;AACX,cAAQ,IAAI,SAAS;AAAA,IAAA,OACf;AACN,cAAQ,MAAM,QAAQ;AACf,aAAA;AAAA,IAAA;AAAA,EACR;AAEF;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const cliCommon = require("@contember/cli-common");
|
|
4
|
+
const ActionsClient = require("../../lib/actions/ActionsClient.cjs");
|
|
5
|
+
class ActionsStopEventCommand extends cliCommon.Command {
|
|
6
|
+
constructor(remoteProjectResolver) {
|
|
7
|
+
super();
|
|
8
|
+
this.remoteProjectResolver = remoteProjectResolver;
|
|
9
|
+
}
|
|
10
|
+
configure(configuration) {
|
|
11
|
+
configuration.description("Stop given event");
|
|
12
|
+
configuration.argument("eventId");
|
|
13
|
+
configuration.option("project").valueRequired();
|
|
14
|
+
}
|
|
15
|
+
async execute(input) {
|
|
16
|
+
const dsn = input.getOption("project");
|
|
17
|
+
const project = await this.remoteProjectResolver.resolve(dsn);
|
|
18
|
+
if (!project) {
|
|
19
|
+
throw `Project not defined`;
|
|
20
|
+
}
|
|
21
|
+
const api = ActionsClient.ActionsClient.create(project.endpoint, project.name, project.token);
|
|
22
|
+
const result = await api.stopEvent(input.getArgument("eventId"));
|
|
23
|
+
if (result) {
|
|
24
|
+
console.log("Event stopped");
|
|
25
|
+
} else {
|
|
26
|
+
console.log("Failed to stop event. Check the event id.");
|
|
27
|
+
return 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.ActionsStopEventCommand = ActionsStopEventCommand;
|
|
32
|
+
//# sourceMappingURL=ActionsStopEventCommand.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsStopEventCommand.cjs","sources":["../../../../../../packages/cli/src/commands/actions/ActionsStopEventCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\nimport chalkTable from 'chalk-table'\ntype Args = {\n\teventId: string\n}\n\ntype Options = {\n\tproject?: string\n}\n\nexport class ActionsStopEventCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Stop given event')\n\t\tconfiguration.argument('eventId')\n\t\tconfiguration.option('project').valueRequired()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\n\t\tconst result = await api.stopEvent(input.getArgument('eventId'))\n\t\tif (result) {\n\t\t\tconsole.log('Event stopped')\n\t\t} else {\n\t\t\tconsole.log('Failed to stop event. Check the event id.')\n\t\t\treturn 1\n\t\t}\n\t}\n}\n"],"names":["Command","ActionsClient"],"mappings":";;;;AAYO,MAAM,gCAAgCA,UAAAA,QAAuB;AAAA,EACnE,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kBAAkB;AAC5C,kBAAc,SAAS,SAAS;AAClB,kBAAA,OAAO,SAAS,EAAE,cAAc;AAAA,EAAA;AAAA,EAG/C,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAMC,4BAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAE9E,UAAM,SAAS,MAAM,IAAI,UAAU,MAAM,YAAY,SAAS,CAAC;AAC/D,QAAI,QAAQ;AACX,cAAQ,IAAI,eAAe;AAAA,IAAA,OACrB;AACN,cAAQ,IAAI,2CAA2C;AAChD,aAAA;AAAA,IAAA;AAAA,EACR;AAEF;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Command } from "@contember/cli-common";
|
|
2
|
+
import { ActionsClient } from "../../lib/actions/ActionsClient.js";
|
|
3
|
+
class ActionsStopEventCommand extends Command {
|
|
4
|
+
constructor(remoteProjectResolver) {
|
|
5
|
+
super();
|
|
6
|
+
this.remoteProjectResolver = remoteProjectResolver;
|
|
7
|
+
}
|
|
8
|
+
configure(configuration) {
|
|
9
|
+
configuration.description("Stop given event");
|
|
10
|
+
configuration.argument("eventId");
|
|
11
|
+
configuration.option("project").valueRequired();
|
|
12
|
+
}
|
|
13
|
+
async execute(input) {
|
|
14
|
+
const dsn = input.getOption("project");
|
|
15
|
+
const project = await this.remoteProjectResolver.resolve(dsn);
|
|
16
|
+
if (!project) {
|
|
17
|
+
throw `Project not defined`;
|
|
18
|
+
}
|
|
19
|
+
const api = ActionsClient.create(project.endpoint, project.name, project.token);
|
|
20
|
+
const result = await api.stopEvent(input.getArgument("eventId"));
|
|
21
|
+
if (result) {
|
|
22
|
+
console.log("Event stopped");
|
|
23
|
+
} else {
|
|
24
|
+
console.log("Failed to stop event. Check the event id.");
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
ActionsStopEventCommand
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=ActionsStopEventCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsStopEventCommand.js","sources":["../../../../../../packages/cli/src/commands/actions/ActionsStopEventCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\nimport chalkTable from 'chalk-table'\ntype Args = {\n\teventId: string\n}\n\ntype Options = {\n\tproject?: string\n}\n\nexport class ActionsStopEventCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Stop given event')\n\t\tconfiguration.argument('eventId')\n\t\tconfiguration.option('project').valueRequired()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\n\t\tconst result = await api.stopEvent(input.getArgument('eventId'))\n\t\tif (result) {\n\t\t\tconsole.log('Event stopped')\n\t\t} else {\n\t\t\tconsole.log('Failed to stop event. Check the event id.')\n\t\t\treturn 1\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAYO,MAAM,gCAAgC,QAAuB;AAAA,EACnE,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kBAAkB;AAC5C,kBAAc,SAAS,SAAS;AAClB,kBAAA,OAAO,SAAS,EAAE,cAAc;AAAA,EAAA;AAAA,EAG/C,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAM,cAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAE9E,UAAM,SAAS,MAAM,IAAI,UAAU,MAAM,YAAY,SAAS,CAAC;AAC/D,QAAI,QAAQ;AACX,cAAQ,IAAI,eAAe;AAAA,IAAA,OACrB;AACN,cAAQ,IAAI,2CAA2C;AAChD,aAAA;AAAA,IAAA;AAAA,EACR;AAEF;"}
|
|
@@ -45,7 +45,7 @@ class MigrationStatusCommand extends cliCommon.Command {
|
|
|
45
45
|
...onlyErrors ? status.errorMigrations : [],
|
|
46
46
|
...onlyToExecute ? status.migrationsToExecute : []
|
|
47
47
|
]) : status.allMigrations;
|
|
48
|
-
this.migrationPrinter.printStatusTable(filtered);
|
|
48
|
+
console.log(this.migrationPrinter.printStatusTable(filtered));
|
|
49
49
|
const hasErrors = status.errorMigrations.length > 0;
|
|
50
50
|
if (hasErrors) {
|
|
51
51
|
console.error(chalk.redBright("Some migrations are broken"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationStatusCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationStatusCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationFilesManager, MigrationState, sortMigrations, SystemClient } from '@contember/migrations-client'\nimport chalk from 'chalk'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n}\n\ntype Options = {\n\t['only-to-execute']?: true\n\t['only-errors']?: true\n\t['restore-missing']?: true\n}\n\nexport class MigrationStatusCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly migrationFilesManager: MigrationFilesManager,\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Shows status of executed migrations on an instance & sync status')\n\t\tconfiguration //\n\t\t\t.option('only-errors')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations with an error.')\n\t\tconfiguration //\n\t\t\t.option('only-to-execute')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations to execute.')\n\t\tconfiguration //\n\t\t\t.option('restore-missing')\n\t\t\t.valueNone()\n\t\t\t.description('Restores migrations locally missing')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\n\t\tconst onlyErrors = input.getOption('only-errors')\n\t\tconst onlyToExecute = input.getOption('only-to-execute')\n\t\tconst restoreMissing = input.getOption('restore-missing')\n\n\t\tlet status = await this.migrationsStatusFacade.resolveMigrationsStatus({ allowError: true })\n\n\t\tif (restoreMissing) {\n\t\t\tconst missing = status.errorMigrations.filter(it => it.state === MigrationState.EXECUTED_MISSING)\n\t\t\tfor (const migration of missing) {\n\t\t\t\tconsole.log(`Restoring migration ${migration.name}`)\n\t\t\t\tconst fullMigration = await this.systemClientProvider.get().getExecutedMigration(migration.version)\n\t\t\t\tawait this.migrationFilesManager.createFile(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tformatVersion: fullMigration.formatVersion,\n\t\t\t\t\t\t\tmodifications: fullMigration.modifications,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t'\\t',\n\t\t\t\t\t) + '\\n',\n\t\t\t\t\tfullMigration.name,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstatus = await this.migrationsStatusFacade.resolveMigrationsStatus({})\n\t\t}\n\n\n\n\t\tconst filtered =\n\t\t\tonlyErrors || onlyToExecute\n\t\t\t\t? sortMigrations([\n\t\t\t\t\t...(onlyErrors ? status.errorMigrations : []),\n\t\t\t\t\t...(onlyToExecute ? status.migrationsToExecute : []),\n\t\t\t\t ])\n\t\t\t\t: status.allMigrations\n\n\t\
|
|
1
|
+
{"version":3,"file":"MigrationStatusCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationStatusCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationFilesManager, MigrationState, sortMigrations, SystemClient } from '@contember/migrations-client'\nimport chalk from 'chalk'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n}\n\ntype Options = {\n\t['only-to-execute']?: true\n\t['only-errors']?: true\n\t['restore-missing']?: true\n}\n\nexport class MigrationStatusCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly migrationFilesManager: MigrationFilesManager,\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Shows status of executed migrations on an instance & sync status')\n\t\tconfiguration //\n\t\t\t.option('only-errors')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations with an error.')\n\t\tconfiguration //\n\t\t\t.option('only-to-execute')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations to execute.')\n\t\tconfiguration //\n\t\t\t.option('restore-missing')\n\t\t\t.valueNone()\n\t\t\t.description('Restores migrations locally missing')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\n\t\tconst onlyErrors = input.getOption('only-errors')\n\t\tconst onlyToExecute = input.getOption('only-to-execute')\n\t\tconst restoreMissing = input.getOption('restore-missing')\n\n\t\tlet status = await this.migrationsStatusFacade.resolveMigrationsStatus({ allowError: true })\n\n\t\tif (restoreMissing) {\n\t\t\tconst missing = status.errorMigrations.filter(it => it.state === MigrationState.EXECUTED_MISSING)\n\t\t\tfor (const migration of missing) {\n\t\t\t\tconsole.log(`Restoring migration ${migration.name}`)\n\t\t\t\tconst fullMigration = await this.systemClientProvider.get().getExecutedMigration(migration.version)\n\t\t\t\tawait this.migrationFilesManager.createFile(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tformatVersion: fullMigration.formatVersion,\n\t\t\t\t\t\t\tmodifications: fullMigration.modifications,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t'\\t',\n\t\t\t\t\t) + '\\n',\n\t\t\t\t\tfullMigration.name,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstatus = await this.migrationsStatusFacade.resolveMigrationsStatus({})\n\t\t}\n\n\n\n\t\tconst filtered =\n\t\t\tonlyErrors || onlyToExecute\n\t\t\t\t? sortMigrations([\n\t\t\t\t\t...(onlyErrors ? status.errorMigrations : []),\n\t\t\t\t\t...(onlyToExecute ? status.migrationsToExecute : []),\n\t\t\t\t ])\n\t\t\t\t: status.allMigrations\n\n\t\tconsole.log(this.migrationPrinter.printStatusTable(filtered))\n\n\t\tconst hasErrors = status.errorMigrations.length > 0\n\n\t\tif (hasErrors) {\n\t\t\tconsole.error(chalk.redBright('Some migrations are broken'))\n\t\t}\n\n\t\treturn hasErrors ? 1 : 0\n\t}\n}\n"],"names":["Command","MigrationState","sortMigrations"],"mappings":";;;;;AAgBO,MAAM,+BAA+BA,UAAAA,QAAuB;AAAA,EAClE,YACkB,wBACA,uBACA,sBACA,kBAChB;AACK,UAAA;AALW,SAAA,yBAAA;AACA,SAAA,wBAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kEAAkE;AAC5F,kBACE,OAAO,aAAa,EACpB,UAAU,EACV,YAAY,qCAAqC;AACnD,kBACE,OAAO,iBAAiB,EACxB,UAAU,EACV,YAAY,kCAAkC;AAChD,kBACE,OAAO,iBAAiB,EACxB,UAAU,EACV,YAAY,qCAAqC;AAAA,EAAA;AAAA,EAGpD,MAAgB,QAAQ,OAA8C;AAE/D,UAAA,aAAa,MAAM,UAAU,aAAa;AAC1C,UAAA,gBAAgB,MAAM,UAAU,iBAAiB;AACjD,UAAA,iBAAiB,MAAM,UAAU,iBAAiB;AAEpD,QAAA,SAAS,MAAM,KAAK,uBAAuB,wBAAwB,EAAE,YAAY,MAAM;AAE3F,QAAI,gBAAgB;AACb,YAAA,UAAU,OAAO,gBAAgB,OAAO,QAAM,GAAG,UAAUC,gCAAe,gBAAgB;AAChG,iBAAW,aAAa,SAAS;AAChC,gBAAQ,IAAI,uBAAuB,UAAU,IAAI,EAAE;AAC7C,cAAA,gBAAgB,MAAM,KAAK,qBAAqB,MAAM,qBAAqB,UAAU,OAAO;AAClG,cAAM,KAAK,sBAAsB;AAAA,UAChC,KAAK;AAAA,YACJ;AAAA,cACC,eAAe,cAAc;AAAA,cAC7B,eAAe,cAAc;AAAA,YAC9B;AAAA,YACA;AAAA,YACA;AAAA,UAAA,IACG;AAAA,UACJ,cAAc;AAAA,QACf;AAAA,MAAA;AAED,eAAS,MAAM,KAAK,uBAAuB,wBAAwB,CAAA,CAAE;AAAA,IAAA;AAKhE,UAAA,WACL,cAAc,gBACXC,gCAAe;AAAA,MAChB,GAAI,aAAa,OAAO,kBAAkB,CAAC;AAAA,MAC3C,GAAI,gBAAgB,OAAO,sBAAsB,CAAA;AAAA,IAAC,CAChD,IACD,OAAO;AAEX,YAAQ,IAAI,KAAK,iBAAiB,iBAAiB,QAAQ,CAAC;AAEtD,UAAA,YAAY,OAAO,gBAAgB,SAAS;AAElD,QAAI,WAAW;AACd,cAAQ,MAAM,MAAM,UAAU,4BAA4B,CAAC;AAAA,IAAA;AAG5D,WAAO,YAAY,IAAI;AAAA,EAAA;AAEzB;;"}
|
|
@@ -43,7 +43,7 @@ class MigrationStatusCommand extends Command {
|
|
|
43
43
|
...onlyErrors ? status.errorMigrations : [],
|
|
44
44
|
...onlyToExecute ? status.migrationsToExecute : []
|
|
45
45
|
]) : status.allMigrations;
|
|
46
|
-
this.migrationPrinter.printStatusTable(filtered);
|
|
46
|
+
console.log(this.migrationPrinter.printStatusTable(filtered));
|
|
47
47
|
const hasErrors = status.errorMigrations.length > 0;
|
|
48
48
|
if (hasErrors) {
|
|
49
49
|
console.error(chalk.redBright("Some migrations are broken"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationStatusCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationStatusCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationFilesManager, MigrationState, sortMigrations, SystemClient } from '@contember/migrations-client'\nimport chalk from 'chalk'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n}\n\ntype Options = {\n\t['only-to-execute']?: true\n\t['only-errors']?: true\n\t['restore-missing']?: true\n}\n\nexport class MigrationStatusCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly migrationFilesManager: MigrationFilesManager,\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Shows status of executed migrations on an instance & sync status')\n\t\tconfiguration //\n\t\t\t.option('only-errors')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations with an error.')\n\t\tconfiguration //\n\t\t\t.option('only-to-execute')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations to execute.')\n\t\tconfiguration //\n\t\t\t.option('restore-missing')\n\t\t\t.valueNone()\n\t\t\t.description('Restores migrations locally missing')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\n\t\tconst onlyErrors = input.getOption('only-errors')\n\t\tconst onlyToExecute = input.getOption('only-to-execute')\n\t\tconst restoreMissing = input.getOption('restore-missing')\n\n\t\tlet status = await this.migrationsStatusFacade.resolveMigrationsStatus({ allowError: true })\n\n\t\tif (restoreMissing) {\n\t\t\tconst missing = status.errorMigrations.filter(it => it.state === MigrationState.EXECUTED_MISSING)\n\t\t\tfor (const migration of missing) {\n\t\t\t\tconsole.log(`Restoring migration ${migration.name}`)\n\t\t\t\tconst fullMigration = await this.systemClientProvider.get().getExecutedMigration(migration.version)\n\t\t\t\tawait this.migrationFilesManager.createFile(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tformatVersion: fullMigration.formatVersion,\n\t\t\t\t\t\t\tmodifications: fullMigration.modifications,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t'\\t',\n\t\t\t\t\t) + '\\n',\n\t\t\t\t\tfullMigration.name,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstatus = await this.migrationsStatusFacade.resolveMigrationsStatus({})\n\t\t}\n\n\n\n\t\tconst filtered =\n\t\t\tonlyErrors || onlyToExecute\n\t\t\t\t? sortMigrations([\n\t\t\t\t\t...(onlyErrors ? status.errorMigrations : []),\n\t\t\t\t\t...(onlyToExecute ? status.migrationsToExecute : []),\n\t\t\t\t ])\n\t\t\t\t: status.allMigrations\n\n\t\
|
|
1
|
+
{"version":3,"file":"MigrationStatusCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationStatusCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationFilesManager, MigrationState, sortMigrations, SystemClient } from '@contember/migrations-client'\nimport chalk from 'chalk'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n}\n\ntype Options = {\n\t['only-to-execute']?: true\n\t['only-errors']?: true\n\t['restore-missing']?: true\n}\n\nexport class MigrationStatusCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly migrationFilesManager: MigrationFilesManager,\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Shows status of executed migrations on an instance & sync status')\n\t\tconfiguration //\n\t\t\t.option('only-errors')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations with an error.')\n\t\tconfiguration //\n\t\t\t.option('only-to-execute')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations to execute.')\n\t\tconfiguration //\n\t\t\t.option('restore-missing')\n\t\t\t.valueNone()\n\t\t\t.description('Restores migrations locally missing')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\n\t\tconst onlyErrors = input.getOption('only-errors')\n\t\tconst onlyToExecute = input.getOption('only-to-execute')\n\t\tconst restoreMissing = input.getOption('restore-missing')\n\n\t\tlet status = await this.migrationsStatusFacade.resolveMigrationsStatus({ allowError: true })\n\n\t\tif (restoreMissing) {\n\t\t\tconst missing = status.errorMigrations.filter(it => it.state === MigrationState.EXECUTED_MISSING)\n\t\t\tfor (const migration of missing) {\n\t\t\t\tconsole.log(`Restoring migration ${migration.name}`)\n\t\t\t\tconst fullMigration = await this.systemClientProvider.get().getExecutedMigration(migration.version)\n\t\t\t\tawait this.migrationFilesManager.createFile(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tformatVersion: fullMigration.formatVersion,\n\t\t\t\t\t\t\tmodifications: fullMigration.modifications,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t'\\t',\n\t\t\t\t\t) + '\\n',\n\t\t\t\t\tfullMigration.name,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstatus = await this.migrationsStatusFacade.resolveMigrationsStatus({})\n\t\t}\n\n\n\n\t\tconst filtered =\n\t\t\tonlyErrors || onlyToExecute\n\t\t\t\t? sortMigrations([\n\t\t\t\t\t...(onlyErrors ? status.errorMigrations : []),\n\t\t\t\t\t...(onlyToExecute ? status.migrationsToExecute : []),\n\t\t\t\t ])\n\t\t\t\t: status.allMigrations\n\n\t\tconsole.log(this.migrationPrinter.printStatusTable(filtered))\n\n\t\tconst hasErrors = status.errorMigrations.length > 0\n\n\t\tif (hasErrors) {\n\t\t\tconsole.error(chalk.redBright('Some migrations are broken'))\n\t\t}\n\n\t\treturn hasErrors ? 1 : 0\n\t}\n}\n"],"names":[],"mappings":";;;AAgBO,MAAM,+BAA+B,QAAuB;AAAA,EAClE,YACkB,wBACA,uBACA,sBACA,kBAChB;AACK,UAAA;AALW,SAAA,yBAAA;AACA,SAAA,wBAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kEAAkE;AAC5F,kBACE,OAAO,aAAa,EACpB,UAAU,EACV,YAAY,qCAAqC;AACnD,kBACE,OAAO,iBAAiB,EACxB,UAAU,EACV,YAAY,kCAAkC;AAChD,kBACE,OAAO,iBAAiB,EACxB,UAAU,EACV,YAAY,qCAAqC;AAAA,EAAA;AAAA,EAGpD,MAAgB,QAAQ,OAA8C;AAE/D,UAAA,aAAa,MAAM,UAAU,aAAa;AAC1C,UAAA,gBAAgB,MAAM,UAAU,iBAAiB;AACjD,UAAA,iBAAiB,MAAM,UAAU,iBAAiB;AAEpD,QAAA,SAAS,MAAM,KAAK,uBAAuB,wBAAwB,EAAE,YAAY,MAAM;AAE3F,QAAI,gBAAgB;AACb,YAAA,UAAU,OAAO,gBAAgB,OAAO,QAAM,GAAG,UAAU,eAAe,gBAAgB;AAChG,iBAAW,aAAa,SAAS;AAChC,gBAAQ,IAAI,uBAAuB,UAAU,IAAI,EAAE;AAC7C,cAAA,gBAAgB,MAAM,KAAK,qBAAqB,MAAM,qBAAqB,UAAU,OAAO;AAClG,cAAM,KAAK,sBAAsB;AAAA,UAChC,KAAK;AAAA,YACJ;AAAA,cACC,eAAe,cAAc;AAAA,cAC7B,eAAe,cAAc;AAAA,YAC9B;AAAA,YACA;AAAA,YACA;AAAA,UAAA,IACG;AAAA,UACJ,cAAc;AAAA,QACf;AAAA,MAAA;AAED,eAAS,MAAM,KAAK,uBAAuB,wBAAwB,CAAA,CAAE;AAAA,IAAA;AAKhE,UAAA,WACL,cAAc,gBACX,eAAe;AAAA,MAChB,GAAI,aAAa,OAAO,kBAAkB,CAAC;AAAA,MAC3C,GAAI,gBAAgB,OAAO,sBAAsB,CAAA;AAAA,IAAC,CAChD,IACD,OAAO;AAEX,YAAQ,IAAI,KAAK,iBAAiB,iBAAiB,QAAQ,CAAC;AAEtD,UAAA,YAAY,OAAO,gBAAgB,SAAS;AAElD,QAAI,WAAW;AACd,cAAQ,MAAM,MAAM,UAAU,4BAA4B,CAAC;AAAA,IAAA;AAG5D,WAAO,YAAY,IAAI;AAAA,EAAA;AAEzB;"}
|
|
@@ -6,6 +6,7 @@ const maskToken = require("../../lib/maskToken.cjs");
|
|
|
6
6
|
const promises = require("node:stream/promises");
|
|
7
7
|
const stdio = require("../../lib/transfer/stdio.cjs");
|
|
8
8
|
const node_zlib = require("node:zlib");
|
|
9
|
+
const node_stream = require("node:stream");
|
|
9
10
|
class ExportCommand extends cliCommon.Command {
|
|
10
11
|
constructor(remoteProjectResolver, dataTransferClient) {
|
|
11
12
|
super();
|
|
@@ -43,11 +44,15 @@ class ExportCommand extends cliCommon.Command {
|
|
|
43
44
|
includeSystem,
|
|
44
45
|
gzip: gzipTransfer
|
|
45
46
|
});
|
|
47
|
+
if (!response.body) {
|
|
48
|
+
throw new Error("Response does not contain a readable stream.");
|
|
49
|
+
}
|
|
46
50
|
let transferred = 0;
|
|
47
51
|
let start = Date.now();
|
|
48
52
|
let lastMbReported = 0;
|
|
49
53
|
console.log("");
|
|
50
|
-
response.
|
|
54
|
+
const stream = node_stream.Readable.fromWeb(response.body);
|
|
55
|
+
stream.on("data", (chunk) => {
|
|
51
56
|
transferred += chunk.length;
|
|
52
57
|
const currentMb = Math.floor(transferred / 1024 / 1024);
|
|
53
58
|
if (currentMb > lastMbReported) {
|
|
@@ -58,7 +63,7 @@ class ExportCommand extends cliCommon.Command {
|
|
|
58
63
|
});
|
|
59
64
|
const fileName = input.getOption("output") ?? `${project.name}.jsonl${gzipOutput ? ".gz" : ""}`;
|
|
60
65
|
const fileStream = node_fs.createWriteStream(fileName);
|
|
61
|
-
const responseStream = gzipOutput
|
|
66
|
+
const responseStream = !gzipOutput ? stream : stream.pipe(node_zlib.createGzip());
|
|
62
67
|
await promises.pipeline(responseStream, fileStream);
|
|
63
68
|
console.log("\nExport done.");
|
|
64
69
|
console.log(`Data saved to ${fileName}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportCommand.cjs","sources":["../../../../../../packages/cli/src/commands/transfer/ExportCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { createWriteStream } from 'node:fs'\nimport { maskToken } from '../../lib/maskToken'\nimport { pipeline } from 'node:stream/promises'\nimport { printProgressLine } from '../../lib/transfer/stdio'\nimport { createGunzip, createGzip } from 'node:zlib'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { DataTransferClient } from '../../lib/transfer/DataTransferClient'\n\ntype Args = {\n\tsource?: string\n}\ntype Options = {\n\t'include-system'?: boolean\n\t/** @deprecated */\n\t'no-gzip'?: boolean\n\t'no-gzip-output'?: boolean\n\t'no-gzip-transfer'?: boolean\n\toutput?: string\n\t'exclude-table'?: string[]\n}\n\nexport class ExportCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t\tprivate readonly dataTransferClient: DataTransferClient,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Export data from a project')\n\t\tconfiguration.argument('source').optional()\n\t\tconfiguration.option('include-system').valueNone()\n\t\tconfiguration.option('no-gzip').valueNone().deprecated()\n\t\tconfiguration.option('no-gzip-transfer').valueNone()\n\t\tconfiguration.option('no-gzip-output').valueNone()\n\t\tconfiguration.option('output').valueRequired()\n\t\tconfiguration.option('exclude-table').valueArray()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst from = input.getArgument('source')\n\t\tconst project = await this.remoteProjectResolver.resolve(from)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\n\t\tconsole.log('')\n\t\tconsole.log('Exporting data from a following project')\n\t\tconsole.log('')\n\t\tconsole.log(`Project name: ${project.name}`)\n\t\tconsole.log(`API URL: ${project.endpoint}`)\n\t\tconsole.log(`Token: ${maskToken(project.token)}`)\n\n\t\tconst gzipOutput = !input.getOption('no-gzip-output') && !input.getOption('no-gzip')\n\t\tconst gzipTransfer = !input.getOption('no-gzip-transfer')\n\n\t\tconst includeSystem = input.getOption('include-system') === true\n\n\t\tconst response = await this.dataTransferClient.dataExport({\n\t\t\tproject,\n\t\t\texcludeTables: input.getOption('exclude-table') ?? [],\n\t\t\tincludeSystem,\n\t\t\tgzip: gzipTransfer,\n\t\t})\n\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tlet lastMbReported = 0\n\t\tconsole.log('')\n\t\
|
|
1
|
+
{"version":3,"file":"ExportCommand.cjs","sources":["../../../../../../packages/cli/src/commands/transfer/ExportCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { createWriteStream } from 'node:fs'\nimport { maskToken } from '../../lib/maskToken'\nimport { pipeline } from 'node:stream/promises'\nimport { printProgressLine } from '../../lib/transfer/stdio'\nimport { createGunzip, createGzip } from 'node:zlib'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { DataTransferClient } from '../../lib/transfer/DataTransferClient'\nimport { Readable } from 'node:stream'\n\ntype Args = {\n\tsource?: string\n}\ntype Options = {\n\t'include-system'?: boolean\n\t/** @deprecated */\n\t'no-gzip'?: boolean\n\t'no-gzip-output'?: boolean\n\t'no-gzip-transfer'?: boolean\n\toutput?: string\n\t'exclude-table'?: string[]\n}\n\nexport class ExportCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t\tprivate readonly dataTransferClient: DataTransferClient,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Export data from a project')\n\t\tconfiguration.argument('source').optional()\n\t\tconfiguration.option('include-system').valueNone()\n\t\tconfiguration.option('no-gzip').valueNone().deprecated()\n\t\tconfiguration.option('no-gzip-transfer').valueNone()\n\t\tconfiguration.option('no-gzip-output').valueNone()\n\t\tconfiguration.option('output').valueRequired()\n\t\tconfiguration.option('exclude-table').valueArray()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst from = input.getArgument('source')\n\t\tconst project = await this.remoteProjectResolver.resolve(from)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\n\t\tconsole.log('')\n\t\tconsole.log('Exporting data from a following project')\n\t\tconsole.log('')\n\t\tconsole.log(`Project name: ${project.name}`)\n\t\tconsole.log(`API URL: ${project.endpoint}`)\n\t\tconsole.log(`Token: ${maskToken(project.token)}`)\n\n\t\tconst gzipOutput = !input.getOption('no-gzip-output') && !input.getOption('no-gzip')\n\t\tconst gzipTransfer = !input.getOption('no-gzip-transfer')\n\n\t\tconst includeSystem = input.getOption('include-system') === true\n\n\t\tconst response = await this.dataTransferClient.dataExport({\n\t\t\tproject,\n\t\t\texcludeTables: input.getOption('exclude-table') ?? [],\n\t\t\tincludeSystem,\n\t\t\tgzip: gzipTransfer,\n\t\t})\n\t\tif (!response.body) {\n\t\t\tthrow new Error('Response does not contain a readable stream.')\n\t\t}\n\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tlet lastMbReported = 0\n\t\tconsole.log('')\n\t\tconst stream = Readable.fromWeb(response.body as any)\n\t\tstream.on('data', chunk => {\n\t\t\ttransferred += chunk.length\n\t\t\tconst currentMb = Math.floor(transferred / 1024 / 1024)\n\t\t\tif (currentMb > lastMbReported) {\n\t\t\t\tconst durationS = Math.floor((Date.now() - start) / 1000)\n\t\t\t\tprintProgressLine(`transferred ${currentMb} MiB; ${durationS} seconds`)\n\t\t\t\tlastMbReported = currentMb\n\t\t\t}\n\t\t})\n\n\t\tconst fileName = input.getOption('output') ?? `${project.name}.jsonl${gzipOutput ? '.gz' : ''}`\n\t\tconst fileStream = createWriteStream(fileName)\n\n\t\tconst responseStream = !gzipOutput\n\t\t\t? stream\n\t\t\t: stream.pipe(createGzip())\n\n\t\tawait pipeline(responseStream, fileStream)\n\n\t\tconsole.log('\\nExport done.')\n\t\tconsole.log(`Data saved to ${fileName}`)\n\t}\n}\n"],"names":["Command","maskToken","Readable","printProgressLine","createWriteStream","createGzip","pipeline"],"mappings":";;;;;;;;;AAuBO,MAAM,sBAAsBA,UAAAA,QAAuB;AAAA,EACzD,YACkB,uBACA,oBAChB;AACK,UAAA;AAHW,SAAA,wBAAA;AACA,SAAA,qBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,4BAA4B;AACxC,kBAAA,SAAS,QAAQ,EAAE,SAAS;AAC5B,kBAAA,OAAO,gBAAgB,EAAE,UAAU;AACjD,kBAAc,OAAO,SAAS,EAAE,UAAA,EAAY,WAAW;AACzC,kBAAA,OAAO,kBAAkB,EAAE,UAAU;AACrC,kBAAA,OAAO,gBAAgB,EAAE,UAAU;AACnC,kBAAA,OAAO,QAAQ,EAAE,cAAc;AAC/B,kBAAA,OAAO,eAAe,EAAE,WAAW;AAAA,EAAA;AAAA,EAGlD,MAAgB,QAAQ,OAAqD;AACtE,UAAA,OAAO,MAAM,YAAY,QAAQ;AACvC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,IAAI;AAC7D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAGP,YAAQ,IAAI,EAAE;AACd,YAAQ,IAAI,yCAAyC;AACrD,YAAQ,IAAI,EAAE;AACd,YAAQ,IAAI,iBAAiB,QAAQ,IAAI,EAAE;AAC3C,YAAQ,IAAI,YAAY,QAAQ,QAAQ,EAAE;AAC1C,YAAQ,IAAI,UAAUC,UAAA,UAAU,QAAQ,KAAK,CAAC,EAAE;AAE1C,UAAA,aAAa,CAAC,MAAM,UAAU,gBAAgB,KAAK,CAAC,MAAM,UAAU,SAAS;AACnF,UAAM,eAAe,CAAC,MAAM,UAAU,kBAAkB;AAExD,UAAM,gBAAgB,MAAM,UAAU,gBAAgB,MAAM;AAE5D,UAAM,WAAW,MAAM,KAAK,mBAAmB,WAAW;AAAA,MACzD;AAAA,MACA,eAAe,MAAM,UAAU,eAAe,KAAK,CAAC;AAAA,MACpD;AAAA,MACA,MAAM;AAAA,IAAA,CACN;AACG,QAAA,CAAC,SAAS,MAAM;AACb,YAAA,IAAI,MAAM,8CAA8C;AAAA,IAAA;AAG/D,QAAI,cAAc;AACd,QAAA,QAAQ,KAAK,IAAI;AACrB,QAAI,iBAAiB;AACrB,YAAQ,IAAI,EAAE;AACd,UAAM,SAASC,YAAA,SAAS,QAAQ,SAAS,IAAW;AAC7C,WAAA,GAAG,QAAQ,CAAS,UAAA;AAC1B,qBAAe,MAAM;AACrB,YAAM,YAAY,KAAK,MAAM,cAAc,OAAO,IAAI;AACtD,UAAI,YAAY,gBAAgB;AAC/B,cAAM,YAAY,KAAK,OAAO,KAAK,IAAI,IAAI,SAAS,GAAI;AACxDC,cAAA,kBAAkB,eAAe,SAAS,SAAS,SAAS,UAAU;AACrD,yBAAA;AAAA,MAAA;AAAA,IAClB,CACA;AAEK,UAAA,WAAW,MAAM,UAAU,QAAQ,KAAK,GAAG,QAAQ,IAAI,SAAS,aAAa,QAAQ,EAAE;AACvF,UAAA,aAAaC,0BAAkB,QAAQ;AAE7C,UAAM,iBAAiB,CAAC,aACrB,SACA,OAAO,KAAKC,UAAAA,YAAY;AAErB,UAAAC,SAAA,SAAS,gBAAgB,UAAU;AAEzC,YAAQ,IAAI,gBAAgB;AACpB,YAAA,IAAI,iBAAiB,QAAQ,EAAE;AAAA,EAAA;AAEzC;;"}
|
|
@@ -3,7 +3,8 @@ import { createWriteStream } from "node:fs";
|
|
|
3
3
|
import { maskToken } from "../../lib/maskToken.js";
|
|
4
4
|
import { pipeline } from "node:stream/promises";
|
|
5
5
|
import { printProgressLine } from "../../lib/transfer/stdio.js";
|
|
6
|
-
import { createGzip
|
|
6
|
+
import { createGzip } from "node:zlib";
|
|
7
|
+
import { Readable } from "node:stream";
|
|
7
8
|
class ExportCommand extends Command {
|
|
8
9
|
constructor(remoteProjectResolver, dataTransferClient) {
|
|
9
10
|
super();
|
|
@@ -41,11 +42,15 @@ class ExportCommand extends Command {
|
|
|
41
42
|
includeSystem,
|
|
42
43
|
gzip: gzipTransfer
|
|
43
44
|
});
|
|
45
|
+
if (!response.body) {
|
|
46
|
+
throw new Error("Response does not contain a readable stream.");
|
|
47
|
+
}
|
|
44
48
|
let transferred = 0;
|
|
45
49
|
let start = Date.now();
|
|
46
50
|
let lastMbReported = 0;
|
|
47
51
|
console.log("");
|
|
48
|
-
response.
|
|
52
|
+
const stream = Readable.fromWeb(response.body);
|
|
53
|
+
stream.on("data", (chunk) => {
|
|
49
54
|
transferred += chunk.length;
|
|
50
55
|
const currentMb = Math.floor(transferred / 1024 / 1024);
|
|
51
56
|
if (currentMb > lastMbReported) {
|
|
@@ -56,7 +61,7 @@ class ExportCommand extends Command {
|
|
|
56
61
|
});
|
|
57
62
|
const fileName = input.getOption("output") ?? `${project.name}.jsonl${gzipOutput ? ".gz" : ""}`;
|
|
58
63
|
const fileStream = createWriteStream(fileName);
|
|
59
|
-
const responseStream = gzipOutput
|
|
64
|
+
const responseStream = !gzipOutput ? stream : stream.pipe(createGzip());
|
|
60
65
|
await pipeline(responseStream, fileStream);
|
|
61
66
|
console.log("\nExport done.");
|
|
62
67
|
console.log(`Data saved to ${fileName}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportCommand.js","sources":["../../../../../../packages/cli/src/commands/transfer/ExportCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { createWriteStream } from 'node:fs'\nimport { maskToken } from '../../lib/maskToken'\nimport { pipeline } from 'node:stream/promises'\nimport { printProgressLine } from '../../lib/transfer/stdio'\nimport { createGunzip, createGzip } from 'node:zlib'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { DataTransferClient } from '../../lib/transfer/DataTransferClient'\n\ntype Args = {\n\tsource?: string\n}\ntype Options = {\n\t'include-system'?: boolean\n\t/** @deprecated */\n\t'no-gzip'?: boolean\n\t'no-gzip-output'?: boolean\n\t'no-gzip-transfer'?: boolean\n\toutput?: string\n\t'exclude-table'?: string[]\n}\n\nexport class ExportCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t\tprivate readonly dataTransferClient: DataTransferClient,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Export data from a project')\n\t\tconfiguration.argument('source').optional()\n\t\tconfiguration.option('include-system').valueNone()\n\t\tconfiguration.option('no-gzip').valueNone().deprecated()\n\t\tconfiguration.option('no-gzip-transfer').valueNone()\n\t\tconfiguration.option('no-gzip-output').valueNone()\n\t\tconfiguration.option('output').valueRequired()\n\t\tconfiguration.option('exclude-table').valueArray()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst from = input.getArgument('source')\n\t\tconst project = await this.remoteProjectResolver.resolve(from)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\n\t\tconsole.log('')\n\t\tconsole.log('Exporting data from a following project')\n\t\tconsole.log('')\n\t\tconsole.log(`Project name: ${project.name}`)\n\t\tconsole.log(`API URL: ${project.endpoint}`)\n\t\tconsole.log(`Token: ${maskToken(project.token)}`)\n\n\t\tconst gzipOutput = !input.getOption('no-gzip-output') && !input.getOption('no-gzip')\n\t\tconst gzipTransfer = !input.getOption('no-gzip-transfer')\n\n\t\tconst includeSystem = input.getOption('include-system') === true\n\n\t\tconst response = await this.dataTransferClient.dataExport({\n\t\t\tproject,\n\t\t\texcludeTables: input.getOption('exclude-table') ?? [],\n\t\t\tincludeSystem,\n\t\t\tgzip: gzipTransfer,\n\t\t})\n\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tlet lastMbReported = 0\n\t\tconsole.log('')\n\t\
|
|
1
|
+
{"version":3,"file":"ExportCommand.js","sources":["../../../../../../packages/cli/src/commands/transfer/ExportCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { createWriteStream } from 'node:fs'\nimport { maskToken } from '../../lib/maskToken'\nimport { pipeline } from 'node:stream/promises'\nimport { printProgressLine } from '../../lib/transfer/stdio'\nimport { createGunzip, createGzip } from 'node:zlib'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { DataTransferClient } from '../../lib/transfer/DataTransferClient'\nimport { Readable } from 'node:stream'\n\ntype Args = {\n\tsource?: string\n}\ntype Options = {\n\t'include-system'?: boolean\n\t/** @deprecated */\n\t'no-gzip'?: boolean\n\t'no-gzip-output'?: boolean\n\t'no-gzip-transfer'?: boolean\n\toutput?: string\n\t'exclude-table'?: string[]\n}\n\nexport class ExportCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t\tprivate readonly dataTransferClient: DataTransferClient,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Export data from a project')\n\t\tconfiguration.argument('source').optional()\n\t\tconfiguration.option('include-system').valueNone()\n\t\tconfiguration.option('no-gzip').valueNone().deprecated()\n\t\tconfiguration.option('no-gzip-transfer').valueNone()\n\t\tconfiguration.option('no-gzip-output').valueNone()\n\t\tconfiguration.option('output').valueRequired()\n\t\tconfiguration.option('exclude-table').valueArray()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst from = input.getArgument('source')\n\t\tconst project = await this.remoteProjectResolver.resolve(from)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\n\t\tconsole.log('')\n\t\tconsole.log('Exporting data from a following project')\n\t\tconsole.log('')\n\t\tconsole.log(`Project name: ${project.name}`)\n\t\tconsole.log(`API URL: ${project.endpoint}`)\n\t\tconsole.log(`Token: ${maskToken(project.token)}`)\n\n\t\tconst gzipOutput = !input.getOption('no-gzip-output') && !input.getOption('no-gzip')\n\t\tconst gzipTransfer = !input.getOption('no-gzip-transfer')\n\n\t\tconst includeSystem = input.getOption('include-system') === true\n\n\t\tconst response = await this.dataTransferClient.dataExport({\n\t\t\tproject,\n\t\t\texcludeTables: input.getOption('exclude-table') ?? [],\n\t\t\tincludeSystem,\n\t\t\tgzip: gzipTransfer,\n\t\t})\n\t\tif (!response.body) {\n\t\t\tthrow new Error('Response does not contain a readable stream.')\n\t\t}\n\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tlet lastMbReported = 0\n\t\tconsole.log('')\n\t\tconst stream = Readable.fromWeb(response.body as any)\n\t\tstream.on('data', chunk => {\n\t\t\ttransferred += chunk.length\n\t\t\tconst currentMb = Math.floor(transferred / 1024 / 1024)\n\t\t\tif (currentMb > lastMbReported) {\n\t\t\t\tconst durationS = Math.floor((Date.now() - start) / 1000)\n\t\t\t\tprintProgressLine(`transferred ${currentMb} MiB; ${durationS} seconds`)\n\t\t\t\tlastMbReported = currentMb\n\t\t\t}\n\t\t})\n\n\t\tconst fileName = input.getOption('output') ?? `${project.name}.jsonl${gzipOutput ? '.gz' : ''}`\n\t\tconst fileStream = createWriteStream(fileName)\n\n\t\tconst responseStream = !gzipOutput\n\t\t\t? stream\n\t\t\t: stream.pipe(createGzip())\n\n\t\tawait pipeline(responseStream, fileStream)\n\n\t\tconsole.log('\\nExport done.')\n\t\tconsole.log(`Data saved to ${fileName}`)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAuBO,MAAM,sBAAsB,QAAuB;AAAA,EACzD,YACkB,uBACA,oBAChB;AACK,UAAA;AAHW,SAAA,wBAAA;AACA,SAAA,qBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,4BAA4B;AACxC,kBAAA,SAAS,QAAQ,EAAE,SAAS;AAC5B,kBAAA,OAAO,gBAAgB,EAAE,UAAU;AACjD,kBAAc,OAAO,SAAS,EAAE,UAAA,EAAY,WAAW;AACzC,kBAAA,OAAO,kBAAkB,EAAE,UAAU;AACrC,kBAAA,OAAO,gBAAgB,EAAE,UAAU;AACnC,kBAAA,OAAO,QAAQ,EAAE,cAAc;AAC/B,kBAAA,OAAO,eAAe,EAAE,WAAW;AAAA,EAAA;AAAA,EAGlD,MAAgB,QAAQ,OAAqD;AACtE,UAAA,OAAO,MAAM,YAAY,QAAQ;AACvC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,IAAI;AAC7D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAGP,YAAQ,IAAI,EAAE;AACd,YAAQ,IAAI,yCAAyC;AACrD,YAAQ,IAAI,EAAE;AACd,YAAQ,IAAI,iBAAiB,QAAQ,IAAI,EAAE;AAC3C,YAAQ,IAAI,YAAY,QAAQ,QAAQ,EAAE;AAC1C,YAAQ,IAAI,UAAU,UAAU,QAAQ,KAAK,CAAC,EAAE;AAE1C,UAAA,aAAa,CAAC,MAAM,UAAU,gBAAgB,KAAK,CAAC,MAAM,UAAU,SAAS;AACnF,UAAM,eAAe,CAAC,MAAM,UAAU,kBAAkB;AAExD,UAAM,gBAAgB,MAAM,UAAU,gBAAgB,MAAM;AAE5D,UAAM,WAAW,MAAM,KAAK,mBAAmB,WAAW;AAAA,MACzD;AAAA,MACA,eAAe,MAAM,UAAU,eAAe,KAAK,CAAC;AAAA,MACpD;AAAA,MACA,MAAM;AAAA,IAAA,CACN;AACG,QAAA,CAAC,SAAS,MAAM;AACb,YAAA,IAAI,MAAM,8CAA8C;AAAA,IAAA;AAG/D,QAAI,cAAc;AACd,QAAA,QAAQ,KAAK,IAAI;AACrB,QAAI,iBAAiB;AACrB,YAAQ,IAAI,EAAE;AACd,UAAM,SAAS,SAAS,QAAQ,SAAS,IAAW;AAC7C,WAAA,GAAG,QAAQ,CAAS,UAAA;AAC1B,qBAAe,MAAM;AACrB,YAAM,YAAY,KAAK,MAAM,cAAc,OAAO,IAAI;AACtD,UAAI,YAAY,gBAAgB;AAC/B,cAAM,YAAY,KAAK,OAAO,KAAK,IAAI,IAAI,SAAS,GAAI;AACxD,0BAAkB,eAAe,SAAS,SAAS,SAAS,UAAU;AACrD,yBAAA;AAAA,MAAA;AAAA,IAClB,CACA;AAEK,UAAA,WAAW,MAAM,UAAU,QAAQ,KAAK,GAAG,QAAQ,IAAI,SAAS,aAAa,QAAQ,EAAE;AACvF,UAAA,aAAa,kBAAkB,QAAQ;AAE7C,UAAM,iBAAiB,CAAC,aACrB,SACA,OAAO,KAAK,YAAY;AAErB,UAAA,SAAS,gBAAgB,UAAU;AAEzC,YAAQ,IAAI,gBAAgB;AACpB,YAAA,IAAI,iBAAiB,QAAQ,EAAE;AAAA,EAAA;AAEzC;"}
|
|
@@ -6,7 +6,6 @@ const node_zlib = require("node:zlib");
|
|
|
6
6
|
const utils = require("./utils.cjs");
|
|
7
7
|
const maskToken = require("../../lib/maskToken.cjs");
|
|
8
8
|
const stdio = require("../../lib/transfer/stdio.cjs");
|
|
9
|
-
const stream = require("../../lib/stream.cjs");
|
|
10
9
|
class ImportCommand extends cliCommon.Command {
|
|
11
10
|
constructor(remoteProjectResolver, dataTransferClient) {
|
|
12
11
|
super();
|
|
@@ -38,21 +37,25 @@ class ImportCommand extends cliCommon.Command {
|
|
|
38
37
|
}
|
|
39
38
|
const file = input.getArgument("file");
|
|
40
39
|
const baseInputStream = node_fs.createReadStream(file);
|
|
41
|
-
const stream
|
|
40
|
+
const stream = file.endsWith(".gz") ? baseInputStream.pipe(node_zlib.createGunzip()) : baseInputStream;
|
|
41
|
+
stream.on("error", (err) => {
|
|
42
|
+
console.error("Error in import stream:", err);
|
|
43
|
+
});
|
|
42
44
|
const gzipTransfer = !input.getOption("no-gzip-transfer");
|
|
43
45
|
const response = await this.dataTransferClient.dataImport({
|
|
44
|
-
stream
|
|
46
|
+
stream,
|
|
45
47
|
project,
|
|
46
48
|
printProgress: stdio.printProgressLine,
|
|
47
49
|
gzip: gzipTransfer
|
|
48
50
|
});
|
|
49
51
|
console.log("");
|
|
50
|
-
const responseData =
|
|
52
|
+
const responseData = await response.json();
|
|
51
53
|
if (responseData.ok) {
|
|
52
54
|
console.log("Import done.");
|
|
53
55
|
} else {
|
|
54
56
|
console.error("Import failed:");
|
|
55
57
|
console.log(responseData);
|
|
58
|
+
return 1;
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportCommand.cjs","sources":["../../../../../../packages/cli/src/commands/transfer/ImportCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { createReadStream } from 'node:fs'\nimport { createGunzip } from 'node:zlib'\nimport { confirmImport } from './utils'\nimport { maskToken } from '../../lib/maskToken'\nimport { printProgressLine } from '../../lib/transfer/stdio'\nimport { readStream } from '../../lib/stream'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { DataTransferClient } from '../../lib/transfer/DataTransferClient'\n\ntype Args = {\n\tfile: string\n\ttarget?: string\n}\ntype Options = {\n\t'yes': boolean\n\t'no-gzip-transfer'?: boolean\n}\n\nexport class ImportCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t\tprivate readonly dataTransferClient: DataTransferClient,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Import data into a project')\n\t\tconfiguration.argument('file')\n\t\tconfiguration.argument('target').optional()\n\t\tconfiguration.option('no-gzip-transfer').valueNone()\n\t\tconfiguration.option('yes').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst target = input.getArgument('target')\n\t\tconst project = await this.remoteProjectResolver.resolve(target)\n\t\tif (!project) {\n\t\t\tthrow `Target project not defined`\n\t\t}\n\t\tconsole.log('')\n\t\tconsole.log('Importing data into a following project')\n\t\tconsole.log('')\n\t\tconsole.log(`Project name: ${project.name}`)\n\t\tconsole.log(`API URL: ${project.endpoint}`)\n\t\tconsole.log(`Token: ${maskToken(project.token)}`)\n\t\tconsole.log('')\n\t\tif (!await confirmImport(input)) {\n\t\t\treturn 1\n\t\t}\n\t\tconst file = input.getArgument('file')\n\t\tconst baseInputStream = createReadStream(file)\n\t\tconst stream = (file.endsWith('.gz') ? baseInputStream.pipe(createGunzip()) : baseInputStream)\n\t\tconst gzipTransfer = !input.getOption('no-gzip-transfer')\n\t\tconst response = await this.dataTransferClient.dataImport({\n\t\t\tstream: stream,\n\t\t\tproject,\n\t\t\tprintProgress: printProgressLine,\n\t\t\tgzip: gzipTransfer,\n\t\t})\n\t\tconsole.log('')\n\t\tconst responseData =
|
|
1
|
+
{"version":3,"file":"ImportCommand.cjs","sources":["../../../../../../packages/cli/src/commands/transfer/ImportCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { createReadStream } from 'node:fs'\nimport { createGunzip } from 'node:zlib'\nimport { confirmImport } from './utils'\nimport { maskToken } from '../../lib/maskToken'\nimport { printProgressLine } from '../../lib/transfer/stdio'\nimport { readStream } from '../../lib/stream'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { DataTransferClient } from '../../lib/transfer/DataTransferClient'\n\ntype Args = {\n\tfile: string\n\ttarget?: string\n}\ntype Options = {\n\t'yes': boolean\n\t'no-gzip-transfer'?: boolean\n}\n\nexport class ImportCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t\tprivate readonly dataTransferClient: DataTransferClient,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Import data into a project')\n\t\tconfiguration.argument('file')\n\t\tconfiguration.argument('target').optional()\n\t\tconfiguration.option('no-gzip-transfer').valueNone()\n\t\tconfiguration.option('yes').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst target = input.getArgument('target')\n\t\tconst project = await this.remoteProjectResolver.resolve(target)\n\t\tif (!project) {\n\t\t\tthrow `Target project not defined`\n\t\t}\n\t\tconsole.log('')\n\t\tconsole.log('Importing data into a following project')\n\t\tconsole.log('')\n\t\tconsole.log(`Project name: ${project.name}`)\n\t\tconsole.log(`API URL: ${project.endpoint}`)\n\t\tconsole.log(`Token: ${maskToken(project.token)}`)\n\t\tconsole.log('')\n\t\tif (!await confirmImport(input)) {\n\t\t\treturn 1\n\t\t}\n\t\tconst file = input.getArgument('file')\n\t\tconst baseInputStream = createReadStream(file)\n\t\tconst stream = (file.endsWith('.gz') ? baseInputStream.pipe(createGunzip()) : baseInputStream)\n\t\tstream.on('error', (err: any) => {\n\t\t\tconsole.error('Error in import stream:', err)\n\t\t})\n\n\t\tconst gzipTransfer = !input.getOption('no-gzip-transfer')\n\t\tconst response = await this.dataTransferClient.dataImport({\n\t\t\tstream: stream,\n\t\t\tproject,\n\t\t\tprintProgress: printProgressLine,\n\t\t\tgzip: gzipTransfer,\n\t\t})\n\t\tconsole.log('')\n\t\tconst responseData = await response.json()\n\t\tif (responseData.ok) {\n\t\t\tconsole.log('Import done.')\n\t\t} else {\n\t\t\tconsole.error('Import failed:')\n\t\t\tconsole.log(responseData)\n\t\t\treturn 1\n\t\t}\n\t}\n}\n\n"],"names":["Command","maskToken","confirmImport","createReadStream","createGunzip","printProgressLine"],"mappings":";;;;;;;;AAmBO,MAAM,sBAAsBA,UAAAA,QAAuB;AAAA,EACzD,YACkB,uBACA,oBAChB;AACK,UAAA;AAHW,SAAA,wBAAA;AACA,SAAA,qBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,4BAA4B;AACtD,kBAAc,SAAS,MAAM;AACf,kBAAA,SAAS,QAAQ,EAAE,SAAS;AAC5B,kBAAA,OAAO,kBAAkB,EAAE,UAAU;AACrC,kBAAA,OAAO,KAAK,EAAE,UAAU;AAAA,EAAA;AAAA,EAGvC,MAAgB,QAAQ,OAAqD;AACtE,UAAA,SAAS,MAAM,YAAY,QAAQ;AACzC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,MAAM;AAC/D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAEP,YAAQ,IAAI,EAAE;AACd,YAAQ,IAAI,yCAAyC;AACrD,YAAQ,IAAI,EAAE;AACd,YAAQ,IAAI,iBAAiB,QAAQ,IAAI,EAAE;AAC3C,YAAQ,IAAI,YAAY,QAAQ,QAAQ,EAAE;AAC1C,YAAQ,IAAI,UAAUC,UAAA,UAAU,QAAQ,KAAK,CAAC,EAAE;AAChD,YAAQ,IAAI,EAAE;AACd,QAAI,CAAC,MAAMC,oBAAc,KAAK,GAAG;AACzB,aAAA;AAAA,IAAA;AAEF,UAAA,OAAO,MAAM,YAAY,MAAM;AAC/B,UAAA,kBAAkBC,yBAAiB,IAAI;AACvC,UAAA,SAAU,KAAK,SAAS,KAAK,IAAI,gBAAgB,KAAKC,uBAAc,CAAA,IAAI;AACvE,WAAA,GAAG,SAAS,CAAC,QAAa;AACxB,cAAA,MAAM,2BAA2B,GAAG;AAAA,IAAA,CAC5C;AAED,UAAM,eAAe,CAAC,MAAM,UAAU,kBAAkB;AACxD,UAAM,WAAW,MAAM,KAAK,mBAAmB,WAAW;AAAA,MACzD;AAAA,MACA;AAAA,MACA,eAAeC,MAAA;AAAA,MACf,MAAM;AAAA,IAAA,CACN;AACD,YAAQ,IAAI,EAAE;AACR,UAAA,eAAe,MAAM,SAAS,KAAK;AACzC,QAAI,aAAa,IAAI;AACpB,cAAQ,IAAI,cAAc;AAAA,IAAA,OACpB;AACN,cAAQ,MAAM,gBAAgB;AAC9B,cAAQ,IAAI,YAAY;AACjB,aAAA;AAAA,IAAA;AAAA,EACR;AAEF;;"}
|
|
@@ -4,7 +4,6 @@ import { createGunzip } from "node:zlib";
|
|
|
4
4
|
import { confirmImport } from "./utils.js";
|
|
5
5
|
import { maskToken } from "../../lib/maskToken.js";
|
|
6
6
|
import { printProgressLine } from "../../lib/transfer/stdio.js";
|
|
7
|
-
import { readStream } from "../../lib/stream.js";
|
|
8
7
|
class ImportCommand extends Command {
|
|
9
8
|
constructor(remoteProjectResolver, dataTransferClient) {
|
|
10
9
|
super();
|
|
@@ -37,6 +36,9 @@ class ImportCommand extends Command {
|
|
|
37
36
|
const file = input.getArgument("file");
|
|
38
37
|
const baseInputStream = createReadStream(file);
|
|
39
38
|
const stream = file.endsWith(".gz") ? baseInputStream.pipe(createGunzip()) : baseInputStream;
|
|
39
|
+
stream.on("error", (err) => {
|
|
40
|
+
console.error("Error in import stream:", err);
|
|
41
|
+
});
|
|
40
42
|
const gzipTransfer = !input.getOption("no-gzip-transfer");
|
|
41
43
|
const response = await this.dataTransferClient.dataImport({
|
|
42
44
|
stream,
|
|
@@ -45,12 +47,13 @@ class ImportCommand extends Command {
|
|
|
45
47
|
gzip: gzipTransfer
|
|
46
48
|
});
|
|
47
49
|
console.log("");
|
|
48
|
-
const responseData =
|
|
50
|
+
const responseData = await response.json();
|
|
49
51
|
if (responseData.ok) {
|
|
50
52
|
console.log("Import done.");
|
|
51
53
|
} else {
|
|
52
54
|
console.error("Import failed:");
|
|
53
55
|
console.log(responseData);
|
|
56
|
+
return 1;
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|