@shopify/oxygen-cli 3.0.1-unstable.202311291846.0 → 3.1.2-unstable.202312011142.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +12 -0
- package/dist/deploy/build-cancel.d.ts +1 -0
- package/dist/deploy/build-initiate.d.ts +1 -0
- package/dist/deploy/build-project.d.ts +1 -0
- package/dist/deploy/deployment-cancel.d.ts +1 -0
- package/dist/deploy/deployment-complete.d.ts +1 -0
- package/dist/deploy/deployment-initiate.d.ts +1 -0
- package/dist/deploy/get-upload-files.d.ts +1 -0
- package/dist/deploy/graphql/build-cancel.d.ts +1 -0
- package/dist/deploy/graphql/build-initiate.d.ts +1 -0
- package/dist/deploy/graphql/deployment-cancel.d.ts +1 -0
- package/dist/deploy/graphql/deployment-complete.d.ts +1 -0
- package/dist/deploy/graphql/deployment-initiate.d.ts +7 -2
- package/dist/deploy/graphql/deployment-initiate.js +3 -0
- package/dist/deploy/graphql/deployment-initiate.js.map +1 -1
- package/dist/deploy/graphql/deployment-verification-details.d.ts +17 -0
- package/dist/deploy/graphql/deployment-verification-details.js +20 -0
- package/dist/deploy/graphql/deployment-verification-details.js.map +1 -0
- package/dist/deploy/index.d.ts +1 -0
- package/dist/deploy/index.js +12 -2
- package/dist/deploy/index.js.map +1 -1
- package/dist/deploy/metadata.d.ts +1 -0
- package/dist/deploy/types.d.ts +9 -1
- package/dist/deploy/types.js +3 -1
- package/dist/deploy/types.js.map +1 -1
- package/dist/deploy/upload-files.d.ts +1 -0
- package/dist/deploy/verify-deployment-completed.d.ts +13 -0
- package/dist/deploy/verify-deployment-completed.js +55 -0
- package/dist/deploy/verify-deployment-completed.js.map +1 -0
- package/dist/deploy/verify-deployment.d.ts +1 -0
- package/dist/deploy/verify-deployment.js +2 -2
- package/dist/deploy/verify-deployment.js.map +1 -1
- package/dist/utils/test-helper.d.ts +1 -0
- package/dist/utils/utils.d.ts +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @shopify/oxygen-cli
|
2
2
|
|
3
|
+
## 3.1.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 57f8ad5: Fixes
|
8
|
+
|
9
|
+
## 3.1.0
|
10
|
+
|
11
|
+
### Minor Changes
|
12
|
+
|
13
|
+
- 61dc304: Add deployment completion verification step that allows for faster feedback of the deployment status
|
14
|
+
|
3
15
|
## 3.0.0
|
4
16
|
|
5
17
|
### Major Changes
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Logger } from '@shopify/cli-kit/node/output';
|
2
2
|
import { DeploymentConfig } from './types.js';
|
3
3
|
import { BuildCancelResponse } from './graphql/build-cancel.js';
|
4
|
+
import './graphql/deployment-verification-details.js';
|
4
5
|
|
5
6
|
interface BuildCancelOptions {
|
6
7
|
config: DeploymentConfig;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Logger } from '@shopify/cli-kit/node/output';
|
2
2
|
import { DeploymentConfig, EnvironmentInput } from './types.js';
|
3
3
|
import { BuildInitiateResponse } from './graphql/build-initiate.js';
|
4
|
+
import './graphql/deployment-verification-details.js';
|
4
5
|
|
5
6
|
interface BuildInitiateOptions {
|
6
7
|
config: DeploymentConfig;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Logger } from '@shopify/cli-kit/node/output';
|
2
2
|
import { DeploymentConfig } from './types.js';
|
3
3
|
import { DeploymentCancelResponse } from './graphql/deployment-cancel.js';
|
4
|
+
import './graphql/deployment-verification-details.js';
|
4
5
|
|
5
6
|
interface DeploymentCancelOptions {
|
6
7
|
config: DeploymentConfig;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { DeploymentCompleteResponse } from './graphql/deployment-complete.js';
|
2
2
|
import { DeploymentConfig } from './types.js';
|
3
|
+
import './graphql/deployment-verification-details.js';
|
3
4
|
|
4
5
|
declare function deploymentComplete(config: DeploymentConfig, deploymentId: string): Promise<DeploymentCompleteResponse>;
|
5
6
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Logger } from '@shopify/cli-kit/node/output';
|
2
2
|
import { DeploymentConfig, DeploymentManifestFile, EnvironmentInput } from './types.js';
|
3
3
|
import { DeploymentInitiateResponse } from './graphql/deployment-initiate.js';
|
4
|
+
import './graphql/deployment-verification-details.js';
|
4
5
|
|
5
6
|
type DeploymentInitiateInput = {
|
6
7
|
buildId: string;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { MetricsExporter } from '../utils/metrics-exporter.js';
|
2
2
|
import { DeploymentConfig, DeploymentManifestFile } from './types.js';
|
3
|
+
import './graphql/deployment-verification-details.js';
|
3
4
|
|
4
5
|
declare function getUploadFiles(config: DeploymentConfig, metricsExporter?: MetricsExporter): Promise<DeploymentManifestFile[]>;
|
5
6
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { OxygenError } from '../types.js';
|
2
|
+
import './deployment-verification-details.js';
|
2
3
|
|
3
4
|
declare const BuildCancelQuery = "\n mutation BuildCancel($buildId: ID!, $reason: String!) {\n buildCancel(id: $buildId, reason: $reason) {\n build {\n id\n }\n userErrors {\n message\n }\n }\n }\n";
|
4
5
|
interface BuildCancelQueryData {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { OxygenError } from '../types.js';
|
2
|
+
import './deployment-verification-details.js';
|
2
3
|
|
3
4
|
declare const BuildInitiateQuery = "\n mutation BuildInitiate($environment: EnvironmentSelectorInput, $labels: [String!]) {\n buildInitiate(environment: $environment, labels: $labels) {\n build {\n id\n assetPath\n }\n userErrors {\n message\n }\n }\n }\n";
|
4
5
|
interface BuildInitiateQueryData {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { OxygenError } from '../types.js';
|
2
|
+
import './deployment-verification-details.js';
|
2
3
|
|
3
4
|
declare const DeploymentCancelQuery = "\nmutation DeploymentCancel($deploymentId: ID!, $reason: String!) {\n deploymentCancel(id: $deploymentId, reason: $reason) {\n deployment {\n id\n }\n userErrors {\n message\n }\n }\n}\n";
|
4
5
|
interface DeploymentCancelQueryData {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { OxygenError } from '../types.js';
|
2
|
+
import './deployment-verification-details.js';
|
2
3
|
|
3
4
|
declare const DeploymentCompleteQuery = "\n mutation DeploymentComplete($deploymentId: ID!, $generateAuthBypassToken: Boolean) {\n deploymentComplete(id: $deploymentId, generateAuthBypassToken: $generateAuthBypassToken) {\n deployment {\n id\n url\n }\n authBypassToken\n userErrors {\n message\n }\n }\n }\n";
|
4
5
|
interface DeploymentCompleteQueryData {
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import { OxygenError } from '../types.js';
|
2
|
+
import './deployment-verification-details.js';
|
2
3
|
|
3
|
-
declare const DeploymentInitiateQuery = "\n mutation DeploymentInitiate($buildId: ID, $environment: EnvironmentSelectorInput, $labels: [String!], $files: [FileInput!]!, $isPrivate: Boolean) {\n deploymentInitiate(buildId: $buildId, environment: $environment, labels: $labels, files: $files, isPrivate: $isPrivate) {\n deployment {\n id\n }\n deploymentTargets {\n filePath\n fileSize\n uploadUrl\n fileType\n parameters {\n name\n value\n }\n }\n userErrors {\n message\n }\n }\n }\n";
|
4
|
+
declare const DeploymentInitiateQuery = "\n mutation DeploymentInitiate($buildId: ID, $environment: EnvironmentSelectorInput, $labels: [String!], $files: [FileInput!]!, $isPrivate: Boolean) {\n deploymentInitiate(buildId: $buildId, environment: $environment, labels: $labels, files: $files, isPrivate: $isPrivate) {\n deployment {\n id\n }\n deploymentTargets {\n filePath\n fileSize\n uploadUrl\n fileType\n parameters {\n name\n value\n }\n }\n deploymentConfiguration {\n timeoutInSeconds\n }\n userErrors {\n message\n }\n }\n }\n";
|
4
5
|
interface DeploymentInitiateQueryData {
|
5
6
|
deploymentInitiate: DeploymentInitiateResponse;
|
6
7
|
}
|
7
8
|
interface DeploymentInitiateResponse {
|
8
9
|
deployment: Deployment;
|
9
10
|
deploymentTargets: DeploymentTargetResponse[];
|
11
|
+
deploymentConfiguration: DeploymentConfigurationResponse;
|
10
12
|
userErrors: OxygenError[];
|
11
13
|
}
|
12
14
|
interface DeploymentTargetResponse {
|
@@ -16,6 +18,9 @@ interface DeploymentTargetResponse {
|
|
16
18
|
fileType: string;
|
17
19
|
parameters: DeploymentInitiateParameters[] | null;
|
18
20
|
}
|
21
|
+
interface DeploymentConfigurationResponse {
|
22
|
+
timeoutInSeconds: number;
|
23
|
+
}
|
19
24
|
interface Deployment {
|
20
25
|
id: string;
|
21
26
|
}
|
@@ -24,4 +29,4 @@ interface DeploymentInitiateParameters {
|
|
24
29
|
value: string;
|
25
30
|
}
|
26
31
|
|
27
|
-
export { DeploymentInitiateQuery, type DeploymentInitiateQueryData, type DeploymentInitiateResponse, type DeploymentTargetResponse };
|
32
|
+
export { type DeploymentConfigurationResponse, DeploymentInitiateQuery, type DeploymentInitiateQueryData, type DeploymentInitiateResponse, type DeploymentTargetResponse };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/deploy/graphql/deployment-initiate.ts"],"names":[],"mappings":"AAEO,MAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["import {OxygenError} from '../types.js';\n\nexport const DeploymentInitiateQuery = `\n mutation DeploymentInitiate($buildId: ID, $environment: EnvironmentSelectorInput, $labels: [String!], $files: [FileInput!]!, $isPrivate: Boolean) {\n deploymentInitiate(buildId: $buildId, environment: $environment, labels: $labels, files: $files, isPrivate: $isPrivate) {\n deployment {\n id\n }\n deploymentTargets {\n filePath\n fileSize\n uploadUrl\n fileType\n parameters {\n name\n value\n }\n }\n userErrors {\n message\n }\n }\n }\n`;\n\nexport interface DeploymentInitiateQueryData {\n deploymentInitiate: DeploymentInitiateResponse;\n}\n\nexport interface DeploymentInitiateResponse {\n deployment: Deployment;\n deploymentTargets: DeploymentTargetResponse[];\n userErrors: OxygenError[];\n}\n\nexport interface DeploymentTargetResponse {\n filePath: string;\n fileSize: number;\n uploadUrl: string;\n fileType: string;\n parameters: DeploymentInitiateParameters[] | null;\n}\n\ninterface Deployment {\n id: string;\n}\n\ninterface DeploymentInitiateParameters {\n name: string;\n value: string;\n}\n"]}
|
1
|
+
{"version":3,"sources":["../../../src/deploy/graphql/deployment-initiate.ts"],"names":[],"mappings":"AAEO,MAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["import {OxygenError} from '../types.js';\n\nexport const DeploymentInitiateQuery = `\n mutation DeploymentInitiate($buildId: ID, $environment: EnvironmentSelectorInput, $labels: [String!], $files: [FileInput!]!, $isPrivate: Boolean) {\n deploymentInitiate(buildId: $buildId, environment: $environment, labels: $labels, files: $files, isPrivate: $isPrivate) {\n deployment {\n id\n }\n deploymentTargets {\n filePath\n fileSize\n uploadUrl\n fileType\n parameters {\n name\n value\n }\n }\n deploymentConfiguration {\n timeoutInSeconds\n }\n userErrors {\n message\n }\n }\n }\n`;\n\nexport interface DeploymentInitiateQueryData {\n deploymentInitiate: DeploymentInitiateResponse;\n}\n\nexport interface DeploymentInitiateResponse {\n deployment: Deployment;\n deploymentTargets: DeploymentTargetResponse[];\n deploymentConfiguration: DeploymentConfigurationResponse;\n userErrors: OxygenError[];\n}\n\nexport interface DeploymentTargetResponse {\n filePath: string;\n fileSize: number;\n uploadUrl: string;\n fileType: string;\n parameters: DeploymentInitiateParameters[] | null;\n}\n\nexport interface DeploymentConfigurationResponse {\n timeoutInSeconds: number;\n}\n\ninterface Deployment {\n id: string;\n}\n\ninterface DeploymentInitiateParameters {\n name: string;\n value: string;\n}\n"]}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
declare const DeploymentVerificationDetailsQuery = "\n query DeploymentVerificationDetails($deploymentId: ID!) {\n deploymentVerificationDetails(id: $deploymentId) {\n url\n status\n error\n }\n }\n";
|
2
|
+
interface DeploymentVerificationDetailsQueryData {
|
3
|
+
deploymentVerificationDetails: DeploymentVerificationDetailsResponse;
|
4
|
+
}
|
5
|
+
interface DeploymentVerificationDetailsResponse {
|
6
|
+
url: string;
|
7
|
+
status: string;
|
8
|
+
error?: string;
|
9
|
+
}
|
10
|
+
declare enum Status {
|
11
|
+
Pending = "PENDING",
|
12
|
+
Deployed = "DEPLOYED",
|
13
|
+
Failed = "FAILED",
|
14
|
+
Cancelled = "CANCELLED"
|
15
|
+
}
|
16
|
+
|
17
|
+
export { DeploymentVerificationDetailsQuery, type DeploymentVerificationDetailsQueryData, type DeploymentVerificationDetailsResponse, Status };
|
@@ -0,0 +1,20 @@
|
|
1
|
+
const DeploymentVerificationDetailsQuery = `
|
2
|
+
query DeploymentVerificationDetails($deploymentId: ID!) {
|
3
|
+
deploymentVerificationDetails(id: $deploymentId) {
|
4
|
+
url
|
5
|
+
status
|
6
|
+
error
|
7
|
+
}
|
8
|
+
}
|
9
|
+
`;
|
10
|
+
var Status = /* @__PURE__ */ ((Status2) => {
|
11
|
+
Status2["Pending"] = "PENDING";
|
12
|
+
Status2["Deployed"] = "DEPLOYED";
|
13
|
+
Status2["Failed"] = "FAILED";
|
14
|
+
Status2["Cancelled"] = "CANCELLED";
|
15
|
+
return Status2;
|
16
|
+
})(Status || {});
|
17
|
+
|
18
|
+
export { DeploymentVerificationDetailsQuery, Status };
|
19
|
+
//# sourceMappingURL=out.js.map
|
20
|
+
//# sourceMappingURL=deployment-verification-details.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/deploy/graphql/deployment-verification-details.ts"],"names":["Status"],"mappings":"AAAO,MAAM,qCAAqC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoB3C,IAAK,SAAL,kBAAKA,YAAL;AACL,EAAAA,QAAA,aAAU;AACV,EAAAA,QAAA,cAAW;AACX,EAAAA,QAAA,YAAS;AACT,EAAAA,QAAA,eAAY;AAJF,SAAAA;AAAA,GAAA","sourcesContent":["export const DeploymentVerificationDetailsQuery = `\n query DeploymentVerificationDetails($deploymentId: ID!) {\n deploymentVerificationDetails(id: $deploymentId) {\n url\n status\n error\n }\n }\n`;\n\nexport interface DeploymentVerificationDetailsQueryData {\n deploymentVerificationDetails: DeploymentVerificationDetailsResponse;\n}\n\nexport interface DeploymentVerificationDetailsResponse {\n url: string;\n status: string;\n error?: string;\n}\n\nexport enum Status {\n Pending = 'PENDING',\n Deployed = 'DEPLOYED',\n Failed = 'FAILED',\n Cancelled = 'CANCELLED',\n}\n"]}
|
package/dist/deploy/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Logger } from '@shopify/cli-kit/node/output';
|
2
2
|
import { DeploymentConfig, DeploymentHooks } from './types.js';
|
3
3
|
export { parseToken } from '../utils/utils.js';
|
4
|
+
import './graphql/deployment-verification-details.js';
|
4
5
|
|
5
6
|
interface CreateDeployOptions {
|
6
7
|
config: DeploymentConfig;
|
package/dist/deploy/index.js
CHANGED
@@ -11,7 +11,8 @@ import { deploymentComplete } from './deployment-complete.js';
|
|
11
11
|
import { verifyDeployment } from './verify-deployment.js';
|
12
12
|
import { deploymentCancel } from './deployment-cancel.js';
|
13
13
|
import { uploadFiles } from './upload-files.js';
|
14
|
-
import {
|
14
|
+
import { verifyDeploymentCompleted } from './verify-deployment-completed.js';
|
15
|
+
import { VerificationError, DeploymentCompletedVerificationError } from './types.js';
|
15
16
|
import { buildProject } from './build-project.js';
|
16
17
|
import { getMetadata, createLabels, getEnvironmentInput } from './metadata.js';
|
17
18
|
|
@@ -82,6 +83,15 @@ async function createDeploy(options) {
|
|
82
83
|
);
|
83
84
|
metricsExporter.add(MetricName.TotalTime, performance.now() - cliStartTime);
|
84
85
|
await metricsExporter.export();
|
86
|
+
await verifyDeploymentCompleted(
|
87
|
+
{
|
88
|
+
config,
|
89
|
+
hooks,
|
90
|
+
logger,
|
91
|
+
timeoutInSeconds: deployment.deploymentConfiguration.timeoutInSeconds
|
92
|
+
},
|
93
|
+
deployment.deployment.id
|
94
|
+
);
|
85
95
|
if (!config.skipVerification) {
|
86
96
|
await verifyDeployment({
|
87
97
|
config,
|
@@ -113,7 +123,7 @@ The deployment can be reached at the ${completedDeployment.url} ${urlPrivacy} pr
|
|
113
123
|
console.error("Unknown error", error);
|
114
124
|
return Promise.reject(new Error("Unknown error"));
|
115
125
|
}
|
116
|
-
if (error instanceof VerificationError) {
|
126
|
+
if (error instanceof VerificationError || error instanceof DeploymentCompletedVerificationError) {
|
117
127
|
outputWarn(error.message, logger);
|
118
128
|
} else if (build.id && !buildCompleted) {
|
119
129
|
outputWarn(
|
package/dist/deploy/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/deploy/index.ts"],"names":[],"mappings":"AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAQ,cAAc,oBAAmB;AACzC,SAAQ,YAAY,yBAAwB;AAC5C,SAAQ,iBAAiB,kBAAiB;AAE1C,SAAQ,qBAAoB;AAC5B,SAAQ,mBAAkB;AAC1B,SAAQ,sBAAqB;AAC7B,SAAQ,0BAAyB;AACjC,SAAQ,0BAAyB;AACjC,SAAQ,wBAAuB;AAC/B,SAAQ,wBAAuB;AAC/B,SAAQ,mBAAkB;AAC1B;AAAA,
|
1
|
+
{"version":3,"sources":["../../src/deploy/index.ts"],"names":[],"mappings":"AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAQ,cAAc,oBAAmB;AACzC,SAAQ,YAAY,yBAAwB;AAC5C,SAAQ,iBAAiB,kBAAiB;AAE1C,SAAQ,qBAAoB;AAC5B,SAAQ,mBAAkB;AAC1B,SAAQ,sBAAqB;AAC7B,SAAQ,0BAAyB;AACjC,SAAQ,0BAAyB;AACjC,SAAQ,wBAAuB;AAC/B,SAAQ,wBAAuB;AAC/B,SAAQ,mBAAkB;AAC1B,SAAQ,iCAAgC;AACxC;AAAA,EAEE;AAAA,EAGA;AAAA,OACK;AACP,SAAQ,oBAAmB;AAC3B,SAAQ,cAAc,aAAa,2BAA0B;AAa7D,eAAsB,aACpB,SAC0C;AAC1C,QAAM,eAAe,YAAY,IAAI;AACrC,oBAAkB,CAAC,QAAQ,OAAO,OAAO;AACzC,QAAM,UAAU,WAAW;AAC3B,WAAS,YAAY,UAAU;AAAA,IAC7B,GAAG,QAAQ;AAAA,IACX,iBAAiB,EAAC,GAAG,QAAQ,OAAO,iBAAiB,aAAa,MAAK;AAAA,EACzE,CAAC;AAED,QAAM,EAAC,QAAQ,MAAK,IAAI;AACxB,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,QAAQ,CAAC;AACf,MAAI;AACJ,MAAI;AAEJ,MAAI;AACF,UAAM,WAAW,MAAM,YAAY,QAAQ,MAAM;AACjD,UAAM,SAAS,aAAa,QAAQ;AACpC,UAAM,cAAc,oBAAoB,QAAQ,QAAQ;AACxD,aAAS,YAAY,YAAY;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,kBAAkB,IAAI,gBAAgB;AAAA,MAC1C,YAAY,SAAS,QAAQ;AAAA,MAC7B,UAAU,OAAO;AAAA,IACnB,CAAC;AAED,QAAI,CAAC,OAAO,cAAc,CAAC,OAAO,WAAW;AAC3C,YAAM,wBAAwB,MAAM,cAAc;AAAA,QAChD;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AACD,YAAM,KAAK,sBAAsB,MAAM;AACvC,YAAM,YAAY,sBAAsB,MAAM;AAAA,IAChD;AAEA,QAAI,CAAC,OAAO,WAAW;AACrB,YAAM,aAAa;AAAA,QACjB;AAAA,QACA,WAAW,MAAM;AAAA,QACjB;AAAA,QACA;AAAA,MACF,CAAC;AACD,YAAM,aAAa,EAAC,QAAQ,gBAAgB,KAAI,CAAC;AAAA,IACnD;AACA,qBAAiB;AAEjB,UAAM,WAAW,MAAM,eAAe,QAAQ,eAAe;AAC7D,aAAS,YAAY,YAAY,QAAQ;AACzC,UAAM,0BAA0B,MAAM,KAClC,EAAC,SAAS,MAAM,IAAI,SAAQ,IAC5B,EAAC,aAAa,UAAU,OAAM;AAElC,iBAAa,MAAM,mBAAmB;AAAA,MACpC;AAAA,MACA,OAAO;AAAA,MACP;AAAA,IACF,CAAC;AAED,UAAM,YAAY;AAAA,MAChB;AAAA,MACA,SAAS,WAAW;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,uBAAuB,MAAM;AAAA,MACjC;AAAA,MACA,WAAW,WAAW;AAAA,IACxB;AACA,oBAAgB,IAAI,WAAW,WAAW,YAAY,IAAI,IAAI,YAAY;AAC1E,UAAM,gBAAgB,OAAO;AAE7B,UAAM;AAAA,MACJ;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAkB,WAAW,wBAAwB;AAAA,MACvD;AAAA,MACA,WAAW,WAAW;AAAA,IACxB;AAEA,QAAI,CAAC,OAAO,kBAAkB;AAC5B,YAAM,iBAAiB;AAAA,QACrB;AAAA,QACA,KAAK,qBAAqB,WAAW;AAAA,QACrC;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,UAAM,sBAA2C;AAAA,MAC/C,KAAK,qBAAqB,WAAW;AAAA,IACvC;AAEA,UAAM,aAAa,OAAO,mBAAmB,WAAW;AAExD,QAAI,iBAAiB;AAAA,uCAA0C,oBAAoB,GAAG,IAAI,UAAU;AAEpG,QAAI,qBAAqB,iBAAiB;AACxC,0BAAoB,kBAClB,qBAAqB;AAEvB,wBAAkB,iDAAiD,oBAAoB,eAAe;AAAA,IACxG;AAEA,kBAAc,gBAAgB,MAAM;AAGpC,QAAI,SAAS,SAAS,QAAQ;AAC5B,iBAAW,KAAK,UAAU,mBAAmB,CAAC;AAAA,IAChD;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,QACE,OAAO,WACP,YACC,iBAAiB,SAAS,OAAO,UAAU,WAC5C;AACA,cAAQ,OAAO,KAAK;AAAA,IACtB;AAEA,QAAI,EAAE,iBAAiB,QAAQ;AAE7B,cAAQ,MAAM,iBAAiB,KAAK;AACpC,aAAO,QAAQ,OAAO,IAAI,MAAM,eAAe,CAAC;AAAA,IAClD;AAEA,QACE,iBAAiB,qBACjB,iBAAiB,sCACjB;AACA,iBAAW,MAAM,SAAS,MAAM;AAAA,IAClC,WAAW,MAAM,MAAM,CAAC,gBAAgB;AACtC;AAAA,QACE,sBAAsB,MAAM,OAAO;AAAA,QACnC;AAAA,MACF;AAEA,YAAM,YAAY;AAAA,QAChB;AAAA,QACA,SAAS,MAAM;AAAA,QACf,QAAQ,MAAM;AAAA,QACd;AAAA,MACF,CAAC,EAAE,MAAM,CAAC,QAAQ;AAChB,YAAI,eAAe,OAAO;AACxB,qBAAW,2BAA2B,IAAI,OAAO,IAAI,MAAM;AAAA,QAC7D;AAAA,MACF,CAAC;AAAA,IACH,WAAW,YAAY,WAAW,IAAI;AACpC;AAAA,QACE,2BAA2B,MAAM,OAAO;AAAA,QACxC;AAAA,MACF;AACA,YAAM,iBAAiB;AAAA,QACrB;AAAA,QACA,cAAc,WAAW,WAAW;AAAA,QACpC,QAAQ,MAAM;AAAA,QACd;AAAA,MACF,CAAC,EAAE,MAAM,CAAC,QAAQ;AAChB,YAAI,eAAe,OAAO;AACxB,qBAAW,gCAAgC,IAAI,OAAO,IAAI,MAAM;AAAA,QAClE;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO,QAAQ,OAAO,KAAK;AAAA,EAC7B;AACF;AAGA,SAAQ,kBAAiB","sourcesContent":["import {\n Logger,\n outputInfo,\n outputSuccess,\n outputWarn,\n} from '@shopify/cli-kit/node/output';\n\nimport {stderrLogger, verifyConfig} from '../utils/utils.js';\nimport {getBugsnag, initializeBugsnag} from '../utils/bugsnag.js';\nimport {MetricsExporter, MetricName} from '../utils/metrics-exporter.js';\n\nimport {buildInitiate} from './build-initiate.js';\nimport {buildCancel} from './build-cancel.js';\nimport {getUploadFiles} from './get-upload-files.js';\nimport {deploymentInitiate} from './deployment-initiate.js';\nimport {deploymentComplete} from './deployment-complete.js';\nimport {verifyDeployment} from './verify-deployment.js';\nimport {deploymentCancel} from './deployment-cancel.js';\nimport {uploadFiles} from './upload-files.js';\nimport {verifyDeploymentCompleted} from './verify-deployment-completed.js';\nimport {\n Build,\n DeploymentCompletedVerificationError,\n DeploymentConfig,\n DeploymentHooks,\n VerificationError,\n} from './types.js';\nimport {buildProject} from './build-project.js';\nimport {createLabels, getMetadata, getEnvironmentInput} from './metadata.js';\n\ninterface CreateDeployOptions {\n config: DeploymentConfig;\n hooks?: DeploymentHooks;\n logger?: Logger;\n}\n\ninterface CompletedDeployment {\n url: string;\n authBypassToken?: string;\n}\n\nexport async function createDeploy(\n options: CreateDeployOptions,\n): Promise<CompletedDeployment | undefined> {\n const cliStartTime = performance.now();\n initializeBugsnag(!options.config.bugsnag);\n const Bugsnag = getBugsnag();\n Bugsnag?.addMetadata('config', {\n ...options.config,\n deploymentToken: {...options.config.deploymentToken, accessToken: '***'},\n });\n\n const {config, hooks} = options;\n const logger = options.logger ?? stderrLogger;\n const build = {} as Build;\n let buildCompleted;\n let deployment;\n\n try {\n const metadata = await getMetadata(config, logger);\n const labels = createLabels(metadata);\n const environment = getEnvironmentInput(config, metadata);\n Bugsnag?.addMetadata('metadata', {\n environment,\n labels,\n metadata,\n });\n const metricsExporter = new MetricsExporter({\n ciProvider: metadata.name || 'unknown',\n rootPath: config.rootPath!,\n });\n\n if (!config.workerOnly && !config.skipBuild) {\n const buildInitiateResponse = await buildInitiate({\n config,\n environment,\n labels,\n logger,\n });\n build.id = buildInitiateResponse.build.id;\n build.assetPath = buildInitiateResponse.build.assetPath;\n }\n\n if (!config.skipBuild) {\n await buildProject({\n config,\n assetPath: build.assetPath,\n hooks,\n metricsExporter,\n });\n await verifyConfig({config, performedBuild: true});\n }\n buildCompleted = true;\n\n const manifest = await getUploadFiles(config, metricsExporter);\n Bugsnag?.addMetadata('manifest', manifest);\n const deploymentInitiateInput = build.id\n ? {buildId: build.id, manifest}\n : {environment, manifest, labels};\n\n deployment = await deploymentInitiate({\n config,\n input: deploymentInitiateInput,\n logger,\n });\n\n await uploadFiles({\n config,\n targets: deployment.deploymentTargets,\n hooks,\n logger,\n metricsExporter,\n });\n const deploymentCompleteOp = await deploymentComplete(\n config,\n deployment.deployment.id,\n );\n metricsExporter.add(MetricName.TotalTime, performance.now() - cliStartTime);\n await metricsExporter.export();\n\n await verifyDeploymentCompleted(\n {\n config,\n hooks,\n logger,\n timeoutInSeconds: deployment.deploymentConfiguration.timeoutInSeconds,\n },\n deployment.deployment.id,\n );\n\n if (!config.skipVerification) {\n await verifyDeployment({\n config,\n url: deploymentCompleteOp.deployment.url,\n logger,\n hooks,\n });\n }\n\n const completedDeployment: CompletedDeployment = {\n url: deploymentCompleteOp.deployment.url,\n };\n\n const urlPrivacy = config.publicDeployment ? 'public' : 'private';\n\n let successMessage = `\\nThe deployment can be reached at the ${completedDeployment.url} ${urlPrivacy} preview URL`;\n\n if (deploymentCompleteOp.authBypassToken) {\n completedDeployment.authBypassToken =\n deploymentCompleteOp.authBypassToken;\n\n successMessage += `. The auth bypass token for the deployment is ${completedDeployment.authBypassToken}`;\n }\n\n outputSuccess(successMessage, logger);\n\n // in CI environments, we want to output the URL + auth bypass token to stdout\n if (metadata.name !== 'none') {\n outputInfo(JSON.stringify(completedDeployment));\n }\n\n return completedDeployment;\n } catch (error) {\n if (\n config.bugsnag &&\n Bugsnag &&\n (error instanceof Error || typeof error === 'string')\n ) {\n Bugsnag.notify(error);\n }\n\n if (!(error instanceof Error)) {\n // eslint-disable-next-line no-console\n console.error('Unknown error', error);\n return Promise.reject(new Error('Unknown error'));\n }\n\n if (\n error instanceof VerificationError ||\n error instanceof DeploymentCompletedVerificationError\n ) {\n outputWarn(error.message, logger);\n } else if (build.id && !buildCompleted) {\n outputWarn(\n `Build failed with: ${error.message}, cancelling build.`,\n logger,\n );\n\n await buildCancel({\n config,\n buildId: build.id!,\n reason: error.message,\n logger,\n }).catch((err) => {\n if (err instanceof Error) {\n outputWarn(`Failed to cancel build: ${err.message}`, logger);\n }\n });\n } else if (deployment?.deployment.id) {\n outputWarn(\n `Deployment failed with: ${error.message}, cancelling deployment.`,\n logger,\n );\n await deploymentCancel({\n config,\n deploymentId: deployment.deployment.id,\n reason: error.message,\n logger,\n }).catch((err) => {\n if (err instanceof Error) {\n outputWarn(`Failed to cancel deployment: ${err.message}`, logger);\n }\n });\n }\n return Promise.reject(error);\n }\n}\n\nexport type {DeploymentConfig, DeploymentHooks, CompletedDeployment};\nexport {parseToken} from '../utils/utils.js';\n"]}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { CIMetadata } from '@shopify/cli-kit/node/context/local';
|
2
2
|
import { Logger } from '@shopify/cli-kit/node/output';
|
3
3
|
import { DeploymentConfig, EnvironmentInput } from './types.js';
|
4
|
+
import './graphql/deployment-verification-details.js';
|
4
5
|
|
5
6
|
type Metadata = CIMetadata & {
|
6
7
|
commitDate?: string;
|
package/dist/deploy/types.d.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import { DeploymentVerificationDetailsResponse } from './graphql/deployment-verification-details.js';
|
2
|
+
|
1
3
|
interface Build {
|
2
4
|
id: string;
|
3
5
|
assetPath: string;
|
@@ -7,6 +9,10 @@ interface ClientError extends Error {
|
|
7
9
|
}
|
8
10
|
interface DeploymentHooks {
|
9
11
|
buildFunction?: (urlPath?: string) => Promise<void>;
|
12
|
+
onDeploymentCompletedVerificationStart?: () => void;
|
13
|
+
onDeploymentCompletedVerificationError?: () => void;
|
14
|
+
onDeploymentFailed?: (responseData: DeploymentVerificationDetailsResponse) => void;
|
15
|
+
onDeploymentCompleted?: () => void;
|
10
16
|
onVerificationStart?: () => void;
|
11
17
|
onVerificationComplete?: () => void;
|
12
18
|
onVerificationError?: (error: Error) => void;
|
@@ -65,5 +71,7 @@ interface OxygenError {
|
|
65
71
|
}
|
66
72
|
declare class VerificationError extends Error {
|
67
73
|
}
|
74
|
+
declare class DeploymentCompletedVerificationError extends Error {
|
75
|
+
}
|
68
76
|
|
69
|
-
export { type Build, type ClientError, type DeploymentConfig, type DeploymentHooks, type DeploymentManifestFile, type DeploymentToken, type EnvironmentInput, FileType, type OxygenError, VerificationError };
|
77
|
+
export { type Build, type ClientError, DeploymentCompletedVerificationError, type DeploymentConfig, type DeploymentHooks, type DeploymentManifestFile, type DeploymentToken, type EnvironmentInput, FileType, type OxygenError, VerificationError };
|
package/dist/deploy/types.js
CHANGED
@@ -5,7 +5,9 @@ var FileType = /* @__PURE__ */ ((FileType2) => {
|
|
5
5
|
})(FileType || {});
|
6
6
|
class VerificationError extends Error {
|
7
7
|
}
|
8
|
+
class DeploymentCompletedVerificationError extends Error {
|
9
|
+
}
|
8
10
|
|
9
|
-
export { FileType, VerificationError };
|
11
|
+
export { DeploymentCompletedVerificationError, FileType, VerificationError };
|
10
12
|
//# sourceMappingURL=out.js.map
|
11
13
|
//# sourceMappingURL=types.js.map
|
package/dist/deploy/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/deploy/types.ts"],"names":["FileType"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../src/deploy/types.ts"],"names":["FileType"],"mappings":"AAyEO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;AASL,MAAM,0BAA0B,MAAM;AAAC;AAEvC,MAAM,6CAA6C,MAAM;AAAC","sourcesContent":["import {DeploymentVerificationDetailsResponse} from './graphql/deployment-verification-details.js';\n\nexport interface Build {\n id: string;\n assetPath: string;\n}\n\nexport interface ClientError extends Error {\n statusCode: number;\n}\n\nexport interface DeploymentHooks {\n buildFunction?: (urlPath?: string) => Promise<void>;\n onDeploymentCompletedVerificationStart?: () => void;\n onDeploymentCompletedVerificationError?: () => void;\n onDeploymentFailed?: (\n responseData: DeploymentVerificationDetailsResponse,\n ) => void;\n onDeploymentCompleted?: () => void;\n onVerificationStart?: () => void;\n onVerificationComplete?: () => void;\n onVerificationError?: (error: Error) => void;\n onUploadFilesStart?: () => void;\n onUploadFilesError?: (error: Error) => void;\n onUploadFilesComplete?: () => void;\n}\n\nexport interface DeploymentConfig {\n assetsDir?: string;\n bugsnag: boolean;\n buildCommand?: string;\n deploymentToken: DeploymentToken;\n deploymentUrl: string;\n environmentTag?: string;\n metadata: {\n description?: string;\n user?: string;\n version?: string;\n url?: string;\n };\n publicDeployment: boolean;\n rootPath?: string;\n skipBuild: boolean;\n skipVerification: boolean;\n verificationMaxDuration: number;\n workerDir?: string;\n workerOnly: boolean;\n generateAuthBypassToken: boolean;\n}\n\nexport interface DeploymentToken {\n accessToken: string;\n allowedResource: string;\n appId: string;\n client: string;\n expiresAt: string;\n namespace: string;\n namespaceId: string;\n}\n\nexport interface DeploymentManifestFile {\n filePath: string;\n fileSize: number;\n mimeType: string;\n fileHash: string;\n fileType: string;\n}\n\nexport interface EnvironmentInput {\n handle?: string;\n tag?: string;\n}\n\nexport enum FileType {\n Worker = 'WORKER',\n Asset = 'ASSET',\n}\n\nexport interface OxygenError {\n message: string;\n}\n\nexport class VerificationError extends Error {}\n\nexport class DeploymentCompletedVerificationError extends Error {}\n"]}
|
@@ -2,6 +2,7 @@ import { Logger } from '@shopify/cli-kit/node/output';
|
|
2
2
|
import { MetricsExporter } from '../utils/metrics-exporter.js';
|
3
3
|
import { DeploymentConfig, DeploymentHooks } from './types.js';
|
4
4
|
import { DeploymentTargetResponse } from './graphql/deployment-initiate.js';
|
5
|
+
import './graphql/deployment-verification-details.js';
|
5
6
|
|
6
7
|
interface UploadFilesOptions {
|
7
8
|
config: DeploymentConfig;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { Logger } from '@shopify/cli-kit/node/output';
|
2
|
+
import { DeploymentConfig, DeploymentHooks } from './types.js';
|
3
|
+
import { DeploymentVerificationDetailsResponse } from './graphql/deployment-verification-details.js';
|
4
|
+
|
5
|
+
interface DeploymentVerificationDetailsOptions {
|
6
|
+
config: DeploymentConfig;
|
7
|
+
hooks?: DeploymentHooks;
|
8
|
+
timeoutInSeconds: number;
|
9
|
+
logger: Logger;
|
10
|
+
}
|
11
|
+
declare function verifyDeploymentCompleted(options: DeploymentVerificationDetailsOptions, deploymentId: string): Promise<DeploymentVerificationDetailsResponse>;
|
12
|
+
|
13
|
+
export { verifyDeploymentCompleted };
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { graphqlRequest } from '@shopify/cli-kit/node/api/graphql';
|
2
|
+
import { outputInfo, outputCompleted } from '@shopify/cli-kit/node/output';
|
3
|
+
import { Header } from '../utils/utils.js';
|
4
|
+
import { DeploymentCompletedVerificationError } from './types.js';
|
5
|
+
import { DeploymentVerificationDetailsQuery, Status } from './graphql/deployment-verification-details.js';
|
6
|
+
|
7
|
+
async function verifyDeploymentCompleted(options, deploymentId) {
|
8
|
+
const { config, logger, timeoutInSeconds, hooks } = options;
|
9
|
+
const variables = {
|
10
|
+
deploymentId
|
11
|
+
};
|
12
|
+
hooks?.onDeploymentCompletedVerificationStart?.();
|
13
|
+
outputInfo("Verifying deployment completed...", logger);
|
14
|
+
const startTime = Date.now();
|
15
|
+
const handleInterval = async () => {
|
16
|
+
const delay = 3e3;
|
17
|
+
const elapsedTime = (Date.now() - startTime) / 1e3;
|
18
|
+
if (elapsedTime + delay / 1e3 > timeoutInSeconds) {
|
19
|
+
hooks?.onDeploymentCompletedVerificationError?.();
|
20
|
+
throw new Error(`Deployment not completed after ${timeoutInSeconds}`);
|
21
|
+
}
|
22
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
23
|
+
return check();
|
24
|
+
};
|
25
|
+
const check = async () => {
|
26
|
+
const response = await graphqlRequest({
|
27
|
+
query: DeploymentVerificationDetailsQuery,
|
28
|
+
api: "Oxygen",
|
29
|
+
url: `${config.deploymentUrl}/api/v2/admin/graphql`,
|
30
|
+
token: config.deploymentToken.accessToken,
|
31
|
+
variables,
|
32
|
+
addedHeaders: {
|
33
|
+
[Header.OxygenNamespaceHandle]: config.deploymentToken.namespace
|
34
|
+
}
|
35
|
+
});
|
36
|
+
const data = response.deploymentVerificationDetails;
|
37
|
+
if (data.status === Status.Deployed) {
|
38
|
+
outputCompleted("Deployment to Oxygen completed successfully", logger);
|
39
|
+
hooks?.onDeploymentCompleted?.();
|
40
|
+
return data;
|
41
|
+
}
|
42
|
+
if (data.status === Status.Failed || data.status === Status.Cancelled) {
|
43
|
+
hooks?.onDeploymentFailed?.(data);
|
44
|
+
throw new DeploymentCompletedVerificationError(
|
45
|
+
data.error ? `Deployment ${data.status.toLocaleLowerCase()}, error: ${data.error}` : `Deployment ${data.status.toLocaleLowerCase()}`
|
46
|
+
);
|
47
|
+
}
|
48
|
+
return handleInterval();
|
49
|
+
};
|
50
|
+
return check();
|
51
|
+
}
|
52
|
+
|
53
|
+
export { verifyDeploymentCompleted };
|
54
|
+
//# sourceMappingURL=out.js.map
|
55
|
+
//# sourceMappingURL=verify-deployment-completed.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/deploy/verify-deployment-completed.ts"],"names":[],"mappings":"AAAA,SAAQ,sBAAqB;AAC7B;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAEP,SAAQ,cAAa;AAErB;AAAA,EAGE;AAAA,OACK;AACP;AAAA,EACE;AAAA,EAGA;AAAA,OACK;AASP,eAAsB,0BACpB,SACA,cACgD;AAChD,QAAM,EAAC,QAAQ,QAAQ,kBAAkB,MAAK,IAAI;AAClD,QAAM,YAAY;AAAA,IAChB;AAAA,EACF;AAEA,SAAO,yCAAyC;AAChD,aAAW,qCAAqC,MAAM;AAEtD,MAAI,WAAW;AACf,QAAM,YAAY,KAAK,IAAI;AAE3B,QAAM,iBAAiB,YAAY;AACjC,UAAM,QAAQ;AACd,UAAM,eAAe,KAAK,IAAI,IAAI,aAAa;AAC/C,QAAI,cAAc,QAAQ,MAAO,kBAAkB;AACjD,aAAO,yCAAyC;AAChD,YAAM,IAAI,MAAM,kCAAkC,gBAAgB,EAAE;AAAA,IACtE;AACA;AACA,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,KAAK,CAAC;AACzD,WAAO,MAAM;AAAA,EACf;AAEA,QAAM,QAAQ,YAA4D;AACxE,UAAM,WACJ,MAAM,eAAe;AAAA,MACnB,OAAO;AAAA,MACP,KAAK;AAAA,MACL,KAAK,GAAG,OAAO,aAAa;AAAA,MAC5B,OAAO,OAAO,gBAAgB;AAAA,MAC9B;AAAA,MACA,cAAc;AAAA,QACZ,CAAC,OAAO,qBAAqB,GAAG,OAAO,gBAAgB;AAAA,MACzD;AAAA,IACF,CAAC;AAEH,UAAM,OAAO,SAAS;AACtB,QAAI,KAAK,WAAW,OAAO,UAAU;AACnC,sBAAgB,+CAA+C,MAAM;AACrE,aAAO,wBAAwB;AAC/B,aAAO;AAAA,IACT;AAEA,QAAI,KAAK,WAAW,OAAO,UAAU,KAAK,WAAW,OAAO,WAAW;AACrE,aAAO,qBAAqB,IAAI;AAChC,YAAM,IAAI;AAAA,QACR,KAAK,QACD,cAAc,KAAK,OAAO,kBAAkB,CAAC,YAC3C,KAAK,KACP,KACA,cAAc,KAAK,OAAO,kBAAkB,CAAC;AAAA,MACnD;AAAA,IACF;AAEA,WAAO,eAAe;AAAA,EACxB;AAEA,SAAO,MAAM;AACf","sourcesContent":["import {graphqlRequest} from '@shopify/cli-kit/node/api/graphql';\nimport {\n Logger,\n outputCompleted,\n outputInfo,\n} from '@shopify/cli-kit/node/output';\n\nimport {Header} from '../utils/utils.js';\n\nimport {\n DeploymentConfig,\n DeploymentHooks,\n DeploymentCompletedVerificationError,\n} from './types.js';\nimport {\n DeploymentVerificationDetailsQuery,\n DeploymentVerificationDetailsQueryData,\n DeploymentVerificationDetailsResponse,\n Status,\n} from './graphql/deployment-verification-details.js';\n\ninterface DeploymentVerificationDetailsOptions {\n config: DeploymentConfig;\n hooks?: DeploymentHooks;\n timeoutInSeconds: number;\n logger: Logger;\n}\n\nexport async function verifyDeploymentCompleted(\n options: DeploymentVerificationDetailsOptions,\n deploymentId: string,\n): Promise<DeploymentVerificationDetailsResponse> {\n const {config, logger, timeoutInSeconds, hooks} = options;\n const variables = {\n deploymentId,\n };\n\n hooks?.onDeploymentCompletedVerificationStart?.();\n outputInfo('Verifying deployment completed...', logger);\n\n let attempts = 0;\n const startTime = Date.now();\n\n const handleInterval = async () => {\n const delay = 3000;\n const elapsedTime = (Date.now() - startTime) / 1000;\n if (elapsedTime + delay / 1000 > timeoutInSeconds) {\n hooks?.onDeploymentCompletedVerificationError?.();\n throw new Error(`Deployment not completed after ${timeoutInSeconds}`);\n }\n attempts++;\n await new Promise((resolve) => setTimeout(resolve, delay));\n return check();\n };\n\n const check = async (): Promise<DeploymentVerificationDetailsResponse> => {\n const response: DeploymentVerificationDetailsQueryData =\n await graphqlRequest({\n query: DeploymentVerificationDetailsQuery,\n api: 'Oxygen',\n url: `${config.deploymentUrl}/api/v2/admin/graphql`,\n token: config.deploymentToken.accessToken,\n variables,\n addedHeaders: {\n [Header.OxygenNamespaceHandle]: config.deploymentToken.namespace,\n },\n });\n\n const data = response.deploymentVerificationDetails;\n if (data.status === Status.Deployed) {\n outputCompleted('Deployment to Oxygen completed successfully', logger);\n hooks?.onDeploymentCompleted?.();\n return data;\n }\n\n if (data.status === Status.Failed || data.status === Status.Cancelled) {\n hooks?.onDeploymentFailed?.(data);\n throw new DeploymentCompletedVerificationError(\n data.error\n ? `Deployment ${data.status.toLocaleLowerCase()}, error: ${\n data.error\n }`\n : `Deployment ${data.status.toLocaleLowerCase()}`,\n );\n }\n\n return handleInterval();\n };\n\n return check();\n}\n"]}
|
@@ -5,7 +5,7 @@ import { VerificationError } from './types.js';
|
|
5
5
|
async function verifyDeployment(options) {
|
6
6
|
const { config, url, logger, hooks } = options;
|
7
7
|
hooks?.onVerificationStart?.();
|
8
|
-
outputInfo("Verifying worker deployment
|
8
|
+
outputInfo("Verifying worker deployment is routable...", logger);
|
9
9
|
let attempts = 0;
|
10
10
|
let delay = 0;
|
11
11
|
let calledVerificationError = false;
|
@@ -19,7 +19,7 @@ async function verifyDeployment(options) {
|
|
19
19
|
const elapsedTime = (Date.now() - startTime) / 1e3;
|
20
20
|
if (elapsedTime + delay / 1e3 > config.verificationMaxDuration) {
|
21
21
|
const error = new VerificationError(
|
22
|
-
"Unable to verify worker
|
22
|
+
"Unable to verify that the worker is accessible."
|
23
23
|
);
|
24
24
|
if (!calledVerificationError) {
|
25
25
|
calledVerificationError = true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/deploy/verify-deployment.ts"],"names":[],"mappings":"AAAA,SAAQ,aAAY;AACpB,SAAgB,kBAAiB;AAEjC,SAA2C,yBAAwB;AASnE,eAAsB,iBACpB,SACe;AACf,QAAM,EAAC,QAAQ,KAAK,QAAQ,MAAK,IAAI;AACrC,SAAO,sBAAsB;AAC7B,aAAW,
|
1
|
+
{"version":3,"sources":["../../src/deploy/verify-deployment.ts"],"names":[],"mappings":"AAAA,SAAQ,aAAY;AACpB,SAAgB,kBAAiB;AAEjC,SAA2C,yBAAwB;AASnE,eAAsB,iBACpB,SACe;AACf,QAAM,EAAC,QAAQ,KAAK,QAAQ,MAAK,IAAI;AACrC,SAAO,sBAAsB;AAC7B,aAAW,8CAA8C,MAAM;AAE/D,MAAI,WAAW;AACf,MAAI,QAAQ;AACZ,MAAI,0BAA0B;AAC9B,QAAM,YAAY,KAAK,IAAI;AAE3B,QAAM,iBAAiB,YAAY;AACjC,QAAI,WAAW,IAAI;AACjB,cAAQ;AAAA,IACV,WAAW,WAAW,MAAM,GAAG;AAC7B,eAAS;AAAA,IACX;AACA,UAAM,eAAe,KAAK,IAAI,IAAI,aAAa;AAC/C,QAAI,cAAc,QAAQ,MAAO,OAAO,yBAAyB;AAC/D,YAAM,QAAQ,IAAI;AAAA,QAChB;AAAA,MACF;AACA,UAAI,CAAC,yBAAyB;AAC5B,kCAA0B;AAC1B,eAAO,sBAAsB,KAAK;AAAA,MACpC;AACA,YAAM;AAAA,IACR;AACA;AACA,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,KAAK,CAAC;AACzD,UAAM,MAAM;AAAA,EACd;AAEA,QAAM,QAAQ,YAAY;AACxB,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,GAAG,GAAG,uBAAuB;AAAA,QACxD,QAAQ;AAAA,MACV,CAAC;AACD,UAAI,SAAS,WAAW,KAAK;AAC3B,mBAAW,wCAAwC,MAAM;AACzD,eAAO,yBAAyB;AAChC,eAAO,QAAQ,QAAQ;AAAA,MACzB;AACA,YAAM,eAAe;AAAA,IACvB,QAAQ;AACN,YAAM,eAAe;AAAA,IACvB;AAAA,EACF;AAEA,QAAM,MAAM;AACd","sourcesContent":["import {fetch} from '@shopify/cli-kit/node/http';\nimport {Logger, outputInfo} from '@shopify/cli-kit/node/output';\n\nimport {DeploymentConfig, DeploymentHooks, VerificationError} from './types.js';\n\ninterface VerificationOptions {\n config: DeploymentConfig;\n hooks?: DeploymentHooks;\n logger: Logger;\n url: string;\n}\n\nexport async function verifyDeployment(\n options: VerificationOptions,\n): Promise<void> {\n const {config, url, logger, hooks} = options;\n hooks?.onVerificationStart?.();\n outputInfo('Verifying worker deployment is routable...', logger);\n\n let attempts = 0;\n let delay = 0;\n let calledVerificationError = false;\n const startTime = Date.now();\n\n const handleInterval = async () => {\n if (attempts < 10) {\n delay = 500;\n } else if (attempts % 5 === 0) {\n delay += 5000;\n }\n const elapsedTime = (Date.now() - startTime) / 1000;\n if (elapsedTime + delay / 1000 > config.verificationMaxDuration) {\n const error = new VerificationError(\n 'Unable to verify that the worker is accessible.',\n );\n if (!calledVerificationError) {\n calledVerificationError = true;\n hooks?.onVerificationError?.(error);\n }\n throw error;\n }\n attempts++;\n await new Promise((resolve) => setTimeout(resolve, delay));\n await check();\n };\n\n const check = async () => {\n try {\n const response = await fetch(`${url}/.oxygen/deployment`, {\n method: 'HEAD',\n });\n if (response.status === 200) {\n outputInfo('Deployment verification check passed', logger);\n hooks?.onVerificationComplete?.();\n return Promise.resolve();\n }\n await handleInterval();\n } catch {\n await handleInterval();\n }\n };\n\n await check();\n}\n"]}
|
package/dist/utils/utils.d.ts
CHANGED
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org"
|
6
6
|
},
|
7
7
|
"license": "MIT",
|
8
|
-
"version": "3.
|
8
|
+
"version": "3.1.2-unstable.202312011142.0",
|
9
9
|
"type": "module",
|
10
10
|
"scripts": {
|
11
11
|
"build": "tsup --sourcemap --clean --config ./tsup.config.ts && oclif manifest",
|