@shopify/oxygen-cli 1.10.4-unstable.20230830.0 → 1.11.1-unstable.20230830.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +5 -2
- package/dist/commands/oxygen/deploy.d.ts +1 -0
- package/dist/commands/oxygen/deploy.js +6 -0
- package/dist/deploy/metadata.d.ts +2 -1
- package/dist/deploy/metadata.js +23 -14
- package/dist/deploy/metadata.test.js +2 -0
- package/dist/deploy/types.d.ts +1 -0
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +1 -1
- package/oclif.manifest.json +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -45,11 +45,12 @@ oxygen:deploy [options]
|
|
45
45
|
- -h, --skipHealthCheck: Skip running the health check on the deployment
|
46
46
|
- -d, --healthCheckMaxDuration: The maximum duration (in seconds) that the health check is allowed to run before it is considered failed. Accepts values between 10 and 300.
|
47
47
|
- --publicDeployment: set the deployment to be publicly accessible.
|
48
|
+
- --metadataDescription <metadataDescription>: A brief description of the deployment, typically the commit message associated with the changes being deployed.
|
48
49
|
- --metadataUrl <metadataUrl>: URL that links to the deployment.
|
49
50
|
- --metadataUser <metadataUser>: User that initiated the deployment.
|
50
51
|
- --metadataVersion <metadataVersion>: A version identifier for the deployment.
|
51
52
|
|
52
|
-
**Note**: All metadata options (--metadataUrl, --metadataUser, and --metadataVersion) have a maximum character limit of
|
53
|
+
**Note**: All metadata options (--metadataDescription, --metadataUrl, --metadataUser, and --metadataVersion) have a maximum character limit of 85.
|
53
54
|
|
54
55
|
### Example:
|
55
56
|
|
@@ -78,10 +79,12 @@ The following environment variables are relevant, depending on your environment:
|
|
78
79
|
|- | --------- | --------| ------ | ------ |
|
79
80
|
| User | BITBUCKET_COMMIT_AUTHOR | CIRCLE_USERNAME | GITHUB_ACTOR | GITLAB_USER_LOGIN |
|
80
81
|
| Version | BITBUCKET_COMMIT | CIRCLE_SHA1 | GITHUB_SHA | CI_COMMIT_SHA |
|
81
|
-
| URL | BITBUCKET_BUILD_URL | CIRCLE_BUILD_URL | `${GITHUB_SERVER_URL}
|
82
|
+
| URL | BITBUCKET_BUILD_URL | CIRCLE_BUILD_URL | `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}` | CI_PROJECT_URL |
|
82
83
|
|
83
84
|
These values can be overridden by the command line flags `metadataUser`, `metadataUrl` and `metadataVersion` respectively.
|
84
85
|
|
86
|
+
`oxygen-cli` Will also attempt to execute `git log` in your project folder to retrieve commit data. This allows the commit message and date to be saved and displayed in the Shopify Admin. If desired, the commit message can be overridden using the `--metadataDescription` command line flag.
|
87
|
+
|
85
88
|
The environment tag to deploy to will be derived from the following variables:
|
86
89
|
|
87
90
|
| Service | Branch |
|
@@ -16,6 +16,7 @@ declare class Deploy extends Command {
|
|
16
16
|
token: _oclif_core_lib_interfaces_parser_js.OptionFlag<string, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
17
17
|
workerFolder: _oclif_core_lib_interfaces_parser_js.OptionFlag<string, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
18
18
|
workerOnly: _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
19
|
+
metadataDescription: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
19
20
|
metadataUrl: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
20
21
|
metadataUser: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
21
22
|
metadataVersion: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
@@ -80,6 +80,11 @@ class Deploy extends Command {
|
|
80
80
|
default: false,
|
81
81
|
required: false
|
82
82
|
}),
|
83
|
+
metadataDescription: Flags.string({
|
84
|
+
description: "Description of the deployment. Will be saved and displayed in the Shopify admin",
|
85
|
+
required: false,
|
86
|
+
env: "OXYGEN_METADATA_DESCRIPTION"
|
87
|
+
}),
|
83
88
|
metadataUrl: Flags.string({
|
84
89
|
description: "URL that links to the deployment. Will be saved and displayed in the Shopify admin",
|
85
90
|
required: false,
|
@@ -112,6 +117,7 @@ class Deploy extends Command {
|
|
112
117
|
deploymentUrl,
|
113
118
|
healthCheckMaxDuration: flags.healthCheckMaxDuration,
|
114
119
|
metadata: {
|
120
|
+
description: flags.metadataDescription,
|
115
121
|
url: flags.metadataUrl,
|
116
122
|
user: flags.metadataUser,
|
117
123
|
version: flags.metadataVersion
|
@@ -3,7 +3,8 @@ import { Logger } from '@shopify/cli-kit/node/output';
|
|
3
3
|
import { DeploymentConfig, EnvironmentInput } from './types.js';
|
4
4
|
|
5
5
|
type Metadata = CIMetadata & {
|
6
|
-
|
6
|
+
commitDate?: string;
|
7
|
+
name?: string;
|
7
8
|
};
|
8
9
|
declare function getMetadata(config: DeploymentConfig, logger: Logger): Promise<Metadata>;
|
9
10
|
declare function getEnvironmentInput(config: DeploymentConfig, metadata: CIMetadata): EnvironmentInput | undefined;
|
package/dist/deploy/metadata.js
CHANGED
@@ -6,26 +6,33 @@ import { maxLabelLength } from '../utils/utils.js';
|
|
6
6
|
async function getMetadata(config, logger) {
|
7
7
|
const ciInfo = ciPlatform();
|
8
8
|
let metadata = {};
|
9
|
+
try {
|
10
|
+
const gitCommit = await getLatestGitCommit(config.rootPath);
|
11
|
+
const branch = gitCommit.refs.split(" ");
|
12
|
+
metadata = {
|
13
|
+
actor: gitCommit.author_name,
|
14
|
+
branch: branch[branch.length - 1],
|
15
|
+
commitDate: gitCommit.date,
|
16
|
+
commitSha: gitCommit.hash,
|
17
|
+
commitMessage: gitCommit.message.substring(0, maxLabelLength)
|
18
|
+
};
|
19
|
+
} catch (error) {
|
20
|
+
outputWarn(
|
21
|
+
"Could not retrieve Git history, commit message will be unavailable.",
|
22
|
+
logger
|
23
|
+
);
|
24
|
+
}
|
9
25
|
if (ciInfo.isCI && ciInfo.name !== "unknown") {
|
10
|
-
metadata =
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
const branch = gitCommit.refs.split(" ");
|
15
|
-
metadata = {
|
16
|
-
actor: gitCommit.author_name,
|
17
|
-
branch: branch[branch.length - 1],
|
18
|
-
commitSha: gitCommit.hash,
|
19
|
-
commitMessage: gitCommit.message
|
20
|
-
};
|
21
|
-
} catch (error) {
|
22
|
-
outputWarn("No CI metadata loaded from environment", logger);
|
23
|
-
}
|
26
|
+
metadata = {
|
27
|
+
...metadata,
|
28
|
+
...ciInfo.metadata
|
29
|
+
};
|
24
30
|
}
|
25
31
|
return {
|
26
32
|
name: ciInfo.isCI ? ciInfo.name : "none",
|
27
33
|
...metadata,
|
28
34
|
actor: config.metadata.user ?? metadata.actor,
|
35
|
+
commitMessage: config.metadata.description ?? metadata.commitMessage,
|
29
36
|
commitSha: config.metadata.version ?? metadata.commitSha,
|
30
37
|
url: config.metadata.url ?? metadata.url
|
31
38
|
};
|
@@ -62,6 +69,8 @@ function createLabels(metadata) {
|
|
62
69
|
const keyMapping = {
|
63
70
|
actor: "user",
|
64
71
|
branch: "branch",
|
72
|
+
commitDate: "commit-date",
|
73
|
+
commitMessage: "description",
|
65
74
|
commitSha: "version",
|
66
75
|
url: "url"
|
67
76
|
};
|
@@ -64,6 +64,8 @@ describe("getMetadata", () => {
|
|
64
64
|
const metadataResult = await getMetadata(testConfig, stderrLogger);
|
65
65
|
expect(metadataResult.actor).toBe("gh_author");
|
66
66
|
expect(metadataResult.commitSha).toBe("gh_hash");
|
67
|
+
expect(metadataResult.commitDate).toBe("gh_date");
|
68
|
+
expect(metadataResult.commitMessage).toBe("gh_message");
|
67
69
|
expect(metadataResult.name).toBe("none");
|
68
70
|
expect(metadataResult.url).toBe(void 0);
|
69
71
|
});
|
package/dist/deploy/types.d.ts
CHANGED
package/dist/utils/utils.d.ts
CHANGED
@@ -10,7 +10,7 @@ declare enum Header {
|
|
10
10
|
}
|
11
11
|
declare function isClientError(error: unknown): error is ClientError;
|
12
12
|
declare function stderrLogger(log: string): void;
|
13
|
-
declare const maxLabelLength =
|
13
|
+
declare const maxLabelLength = 85;
|
14
14
|
declare function parseToken(inputToken: string): DeploymentToken;
|
15
15
|
interface VerifyConfigParams {
|
16
16
|
config: DeploymentConfig;
|
package/dist/utils/utils.js
CHANGED
package/oclif.manifest.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "1.
|
2
|
+
"version": "1.11.1-unstable.20230830.0",
|
3
3
|
"commands": {
|
4
4
|
"oxygen:deploy": {
|
5
5
|
"id": "oxygen:deploy",
|
@@ -103,6 +103,13 @@
|
|
103
103
|
"required": false,
|
104
104
|
"allowNo": false
|
105
105
|
},
|
106
|
+
"metadataDescription": {
|
107
|
+
"name": "metadataDescription",
|
108
|
+
"type": "option",
|
109
|
+
"description": "Description of the deployment. Will be saved and displayed in the Shopify admin",
|
110
|
+
"required": false,
|
111
|
+
"multiple": false
|
112
|
+
},
|
106
113
|
"metadataUrl": {
|
107
114
|
"name": "metadataUrl",
|
108
115
|
"type": "option",
|
package/package.json
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org"
|
6
6
|
},
|
7
7
|
"license": "MIT",
|
8
|
-
"version": "1.
|
8
|
+
"version": "1.11.1-unstable.20230830.0",
|
9
9
|
"type": "module",
|
10
10
|
"scripts": {
|
11
11
|
"build": "tsup --clean --config ./tsup.config.ts && oclif manifest",
|