@shopify/oxygen-cli 1.10.4-unstable.20230830.0 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
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 90.
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}${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}` | CI_PROJECT_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
- name: string;
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;
@@ -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 = ciInfo.metadata;
11
- } else {
12
- try {
13
- const gitCommit = await getLatestGitCommit(config.rootPath);
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
  });
@@ -22,6 +22,7 @@ interface DeploymentConfig {
22
22
  environmentTag?: string;
23
23
  healthCheckMaxDuration: number;
24
24
  metadata: {
25
+ description?: string;
25
26
  user?: string;
26
27
  version?: string;
27
28
  url?: string;
@@ -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 = 90;
13
+ declare const maxLabelLength = 85;
14
14
  declare function parseToken(inputToken: string): DeploymentToken;
15
15
  interface VerifyConfigParams {
16
16
  config: DeploymentConfig;
@@ -71,7 +71,7 @@ function stderrLogger(log) {
71
71
  process.stderr.write(`${log}
72
72
  `);
73
73
  }
74
- const maxLabelLength = 90;
74
+ const maxLabelLength = 85;
75
75
  function parseToken(inputToken) {
76
76
  try {
77
77
  const decodedToken = Buffer.from(inputToken, "base64").toString("utf-8");
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.10.4-unstable.20230830.0",
2
+ "version": "1.11.1",
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.10.4-unstable.20230830.0",
8
+ "version": "1.11.1",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "build": "tsup --clean --config ./tsup.config.ts && oclif manifest",
@@ -34,7 +34,7 @@
34
34
  "/oclif.manifest.json"
35
35
  ],
36
36
  "dependencies": {
37
- "@oclif/core": "2.12.0",
37
+ "@oclif/core": "2.13.0",
38
38
  "@shopify/cli-kit": "nightly",
39
39
  "async": "^3.2.4"
40
40
  },
@@ -44,7 +44,7 @@
44
44
  "@shopify/prettier-config": "^1.1.2",
45
45
  "@types/async": "^3.2.18",
46
46
  "@types/node": "^20.5.7",
47
- "eslint": "^8.47.0",
47
+ "eslint": "^8.48.0",
48
48
  "eslint-plugin-prettier": "^5.0.0",
49
49
  "node-fetch": "^3.3.2",
50
50
  "oclif": "^3",