eas-cli
Version:
EAS command line tool
79 lines (77 loc) • 3.14 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeploymentsMutation = void 0;
const tslib_1 = require("tslib");
const assert_1 = tslib_1.__importDefault(require("assert"));
const graphql_1 = require("graphql");
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
const WorkerDeployment_1 = require("./fragments/WorkerDeployment");
const WorkerDeploymentAlias_1 = require("./fragments/WorkerDeploymentAlias");
const client_1 = require("../graphql/client");
exports.DeploymentsMutation = {
async createSignedDeploymentUrlAsync(graphqlClient, deploymentVariables) {
const data = await (0, client_1.withErrorHandlingAsync)(graphqlClient
.mutation((0, graphql_tag_1.default) `
mutation createDeploymentUrlMutation($appId: ID!, $deploymentIdentifier: ID) {
deployments {
createSignedDeploymentUrl(
appId: $appId
deploymentIdentifier: $deploymentIdentifier
) {
pendingWorkerDeploymentId
deploymentIdentifier
url
}
}
}
`, deploymentVariables)
.toPromise());
const url = data.deployments?.createSignedDeploymentUrl.url;
(0, assert_1.default)(url, 'Deployment URL must be defined');
return url;
},
async assignDevDomainNameAsync(graphqlClient, devDomainNameVariables) {
const data = await (0, client_1.withErrorHandlingAsync)(graphqlClient
.mutation((0, graphql_tag_1.default) `
mutation AssignDevDomainName($appId: ID!, $name: DevDomainName!) {
devDomainName {
assignDevDomainName(appId: $appId, name: $name) {
id
name
}
}
}
`, devDomainNameVariables)
.toPromise());
return data.devDomainName.assignDevDomainName.name === devDomainNameVariables.name;
},
async assignAliasAsync(graphqlClient, aliasVariables) {
const data = await (0, client_1.withErrorHandlingAsync)(graphqlClient
.mutation((0, graphql_tag_1.default) `
mutation AssignAlias(
$appId: ID!
$deploymentId: ID!
$aliasName: WorkerDeploymentIdentifier
) {
deployments {
assignAlias(
appId: $appId
deploymentIdentifier: $deploymentId
aliasName: $aliasName
) {
id
...WorkerDeploymentAliasFragment
workerDeployment {
id
...WorkerDeploymentFragment
}
}
}
}
${(0, graphql_1.print)(WorkerDeployment_1.WorkerDeploymentFragmentNode)}
${(0, graphql_1.print)(WorkerDeploymentAlias_1.WorkerDeploymentAliasFragmentNode)}
`, aliasVariables)
.toPromise());
return data.deployments.assignAlias;
},
};