@percy/cli-build 1.31.1-beta.1 → 1.31.1-beta.2

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/README.md CHANGED
@@ -7,6 +7,10 @@ Commands for interacting with Percy builds
7
7
  * [`percy build:finalize`](#percy-buildfinalize)
8
8
  * [`percy build:wait`](#percy-buildwait)
9
9
  * [`percy build:id`](#percy-buildid)
10
+ * [`percy build:approve`](#percy-buildapprove)
11
+ * [`percy build:unapprove`](#percy-buildunapprove)
12
+ * [`percy build:reject`](#percy-buildreject)
13
+ * [`percy build:delete`](#percy-builddelete)
10
14
 
11
15
  ### `percy build:finalize`
12
16
 
@@ -17,10 +21,11 @@ Usage:
17
21
  $ percy build:finalize [options]
18
22
 
19
23
  Global options:
20
- -v, --verbose Log everything
21
- -q, --quiet Log errors only
22
- -s, --silent Log nothing
23
- -h, --help Display command help
24
+ -v, --verbose Log everything
25
+ -q, --quiet Log errors only
26
+ -s, --silent Log nothing
27
+ -l, --labels <string> Associates labels to the build (ex: --labels=dev,prod )
28
+ -h, --help Display command help
24
29
  ```
25
30
 
26
31
  ### `percy build:wait`
@@ -38,12 +43,14 @@ Options:
38
43
  -t, --timeout <ms> Timeout before exiting without updates, defaults to 10 minutes
39
44
  -i, --interval <ms> Interval at which to poll for updates, defaults to 10 second
40
45
  -f, --fail-on-changes Exit with an error when diffs are found
41
- --pass-if-approved Doesn't Exit with an error if the build is approved, requires '--fail-on-changes'
46
+ --pass-if-approved Doesn't exit with an error if the build is approved, regardless of if
47
+ diffs are found.
42
48
 
43
49
  Global options:
44
50
  -v, --verbose Log everything
45
51
  -q, --quiet Log errors only
46
52
  -s, --silent Log nothing
53
+ -l, --labels <string> Associates labels to the build (ex: --labels=dev,prod )
47
54
  -h, --help Display command help
48
55
 
49
56
  Examples:
@@ -60,12 +67,129 @@ Usage:
60
67
  $ percy build:id [options]
61
68
 
62
69
  Percy options:
63
- -P, --port [number] Local CLI server port (default: 5338)
70
+ -P, --port [number] Local CLI server port (default: 5338)
71
+
72
+ Global options:
73
+ -v, --verbose Log everything
74
+ -q, --quiet Log errors only
75
+ -s, --silent Log nothing
76
+ -l, --labels <string> Associates labels to the build (ex: --labels=dev,prod )
77
+ -h, --help Display command help
78
+ ```
79
+
80
+ ### `percy build:approve`
81
+
82
+ Approve Percy builds
83
+
84
+ ```
85
+ Usage:
86
+ $ percy build:approve [options] <build-id>
87
+
88
+ Arguments:
89
+ build-id Build ID to approve
90
+
91
+ Options:
92
+ --username <string> Username for authentication (can also be set via BROWSERSTACK_USERNAME env
93
+ var)
94
+ --access-key <string> Access key for authentication (can also be set via BROWSERSTACK_ACCESS_KEY
95
+ env var)
96
+
97
+ Global options:
98
+ -v, --verbose Log everything
99
+ -q, --quiet Log errors only
100
+ -s, --silent Log nothing
101
+ -l, --labels <string> Associates labels to the build (ex: --labels=dev,prod )
102
+ -h, --help Display command help
103
+
104
+ Examples:
105
+ $ percy build:approve <build-id>
106
+ $ percy build:approve <build-id> --username username --access-key **key**
107
+ ```
108
+
109
+ ### `percy build:unapprove`
110
+
111
+ Unapprove Percy builds
112
+
113
+ ```
114
+ Usage:
115
+ $ percy build:unapprove [options] <build-id>
116
+
117
+ Arguments:
118
+ build-id Build ID to approve
119
+
120
+ Options:
121
+ --username <string> Username for authentication (can also be set via BROWSERSTACK_USERNAME env
122
+ var)
123
+ --access-key <string> Access key for authentication (can also be set via BROWSERSTACK_ACCESS_KEY
124
+ env var)
125
+
126
+ Global options:
127
+ -v, --verbose Log everything
128
+ -q, --quiet Log errors only
129
+ -s, --silent Log nothing
130
+ -l, --labels <string> Associates labels to the build (ex: --labels=dev,prod )
131
+ -h, --help Display command help
132
+
133
+ Examples:
134
+ $ percy build:unapprove <build-id>
135
+ $ percy build:unapprove <build-id> --username username --access-key **key**
136
+ ```
137
+
138
+ ### `percy build:reject`
139
+
140
+ Reject Percy builds
141
+
142
+ ```
143
+ Usage:
144
+ $ percy build:reject [options] <build-id>
145
+
146
+ Arguments:
147
+ build-id Build ID to approve
148
+
149
+ Options:
150
+ --username <string> Username for authentication (can also be set via BROWSERSTACK_USERNAME env
151
+ var)
152
+ --access-key <string> Access key for authentication (can also be set via BROWSERSTACK_ACCESS_KEY
153
+ env var)
154
+
155
+ Global options:
156
+ -v, --verbose Log everything
157
+ -q, --quiet Log errors only
158
+ -s, --silent Log nothing
159
+ -l, --labels <string> Associates labels to the build (ex: --labels=dev,prod )
160
+ -h, --help Display command help
161
+
162
+ Examples:
163
+ $ percy build:reject <build-id>
164
+ $ percy build:reject <build-id> --username username --access-key **key**
165
+ ```
166
+
167
+ ### `percy build:delete`
168
+
169
+ Delete Percy builds
170
+
171
+ ```
172
+ Usage:
173
+ $ percy build:delete [options] <build-id>
174
+
175
+ Arguments:
176
+ build-id Build ID to approve
177
+
178
+ Options:
179
+ --username <string> Username for authentication (can also be set via BROWSERSTACK_USERNAME env
180
+ var)
181
+ --access-key <string> Access key for authentication (can also be set via BROWSERSTACK_ACCESS_KEY
182
+ env var)
64
183
 
65
184
  Global options:
66
- -v, --verbose Log everything
67
- -q, --quiet Log errors only
68
- -s, --silent Log nothing
69
- -h, --help Display command help
185
+ -v, --verbose Log everything
186
+ -q, --quiet Log errors only
187
+ -s, --silent Log nothing
188
+ -l, --labels <string> Associates labels to the build (ex: --labels=dev,prod )
189
+ -h, --help Display command help
190
+
191
+ Examples:
192
+ $ percy build:delete <build-id>
193
+ $ percy build:delete <build-id> --username username --access-key **key**
70
194
  ```
71
195
  <!-- commandsstop -->
@@ -0,0 +1,49 @@
1
+ import command from '@percy/cli-command';
2
+ import { fetchCredentials, reviewCommandConfig } from './utils.js';
3
+
4
+ /**
5
+ * Approve command definition for Percy builds
6
+ * Allows users to approve builds using build ID and authentication credentials
7
+ */
8
+ export const approve = command('approve', {
9
+ description: 'Approve Percy builds',
10
+ ...reviewCommandConfig
11
+ }, async ({
12
+ flags,
13
+ args,
14
+ percy,
15
+ log,
16
+ exit
17
+ }) => {
18
+ // Early return if Percy is disabled
19
+ if (!percy) {
20
+ exit(0, 'Percy is disabled');
21
+ }
22
+
23
+ // Validate and get authentication credentials
24
+ const {
25
+ username,
26
+ accessKey
27
+ } = fetchCredentials(flags);
28
+ if (!username || !accessKey) {
29
+ exit(1, 'Username and access key are required to approve builds.');
30
+ }
31
+ log.info(`Approving build ${args.buildId}...`);
32
+ try {
33
+ // Call the Percy API to approve the build
34
+ const buildApprovalResponse = await percy.client.approveBuild(args.buildId, username, accessKey);
35
+ const approvedBy = buildApprovalResponse.data.attributes['action-performed-by'] || {
36
+ user_email: 'unknown@example.com',
37
+ user_name: username
38
+ };
39
+ log.info(`Build ${args.buildId} approved successfully!`);
40
+ log.info(`Approved by: ${approvedBy.user_name} (${approvedBy.user_email})`);
41
+ } catch (error) {
42
+ log.error(`Failed to approve build ${args.buildId}`);
43
+ log.error(error);
44
+
45
+ // Provide user-friendly error message
46
+ exit(1, 'Failed to approve the build');
47
+ }
48
+ });
49
+ export default approve;
package/dist/build.js CHANGED
@@ -2,8 +2,12 @@ import command from '@percy/cli-command';
2
2
  import finalize from './finalize.js';
3
3
  import wait from './wait.js';
4
4
  import id from './id.js';
5
+ import approve from './approve.js';
6
+ import reject from './reject.js';
7
+ import unapprove from './unapprove.js';
8
+ import deleteBuild from './delete.js';
5
9
  export const build = command('build', {
6
10
  description: 'Finalize and wait on Percy builds',
7
- commands: [finalize, wait, id]
11
+ commands: [finalize, wait, id, approve, unapprove, reject, deleteBuild]
8
12
  });
9
13
  export default build;
package/dist/delete.js ADDED
@@ -0,0 +1,49 @@
1
+ import command from '@percy/cli-command';
2
+ import { fetchCredentials, reviewCommandConfig } from './utils.js';
3
+
4
+ /**
5
+ * Delete command definition for Percy builds
6
+ * Allows users to delete builds using build ID and authentication credentials
7
+ */
8
+ export const deleteBuild = command('delete', {
9
+ description: 'Delete Percy builds',
10
+ ...reviewCommandConfig
11
+ }, async ({
12
+ flags,
13
+ args,
14
+ percy,
15
+ log,
16
+ exit
17
+ }) => {
18
+ // Early return if Percy is disabled
19
+ if (!percy) {
20
+ exit(0, 'Percy is disabled');
21
+ }
22
+
23
+ // Validate and get authentication credentials
24
+ const {
25
+ username,
26
+ accessKey
27
+ } = fetchCredentials(flags);
28
+ if (!username || !accessKey) {
29
+ exit(1, 'Username and access key are required to delete builds.');
30
+ }
31
+ log.info(`Deleting build ${args.buildId}...`);
32
+ try {
33
+ // Call the Percy API to delete the build
34
+ const buildDeletionResponse = await percy.client.deleteBuild(args.buildId, username, accessKey);
35
+ const deletedBy = buildDeletionResponse['action-performed-by'] || {
36
+ user_email: 'unknown@example.com',
37
+ user_name: username
38
+ };
39
+ log.info(`Build ${args.buildId} deleted successfully!`);
40
+ log.info(`Deleted by: ${deletedBy.user_name} (${deletedBy.user_email})`);
41
+ } catch (error) {
42
+ log.error(`Failed to delete build ${args.buildId}`);
43
+ log.error(error);
44
+
45
+ // Provide user-friendly error message
46
+ exit(1, 'Failed to delete the build');
47
+ }
48
+ });
49
+ export default deleteBuild;
package/dist/index.js CHANGED
@@ -1,4 +1,8 @@
1
1
  export { default, build } from './build.js';
2
2
  export { finalize } from './finalize.js';
3
3
  export { wait } from './wait.js';
4
- export { id } from './id.js';
4
+ export { id } from './id.js';
5
+ export { approve } from './approve.js';
6
+ export { reject } from './reject.js';
7
+ export { unapprove } from './unapprove.js';
8
+ export { deleteBuild } from './delete.js';
package/dist/reject.js ADDED
@@ -0,0 +1,49 @@
1
+ import command from '@percy/cli-command';
2
+ import { fetchCredentials, reviewCommandConfig } from './utils.js';
3
+
4
+ /**
5
+ * Reject command definition for Percy builds
6
+ * Allows users to reject builds using build ID and authentication credentials
7
+ */
8
+ export const reject = command('reject', {
9
+ description: 'Reject Percy builds',
10
+ ...reviewCommandConfig
11
+ }, async ({
12
+ flags,
13
+ args,
14
+ percy,
15
+ log,
16
+ exit
17
+ }) => {
18
+ // Early return if Percy is disabled
19
+ if (!percy) {
20
+ exit(0, 'Percy is disabled');
21
+ }
22
+
23
+ // Validate and get authentication credentials
24
+ const {
25
+ username,
26
+ accessKey
27
+ } = fetchCredentials(flags);
28
+ if (!username || !accessKey) {
29
+ exit(1, 'Username and access key are required to reject builds.');
30
+ }
31
+ log.info(`Rejecting build ${args.buildId}...`);
32
+ try {
33
+ // Call the Percy API to reject the build
34
+ const buildRejectionResponse = await percy.client.rejectBuild(args.buildId, username, accessKey);
35
+ const rejectedBy = buildRejectionResponse.data.attributes['action-performed-by'] || {
36
+ user_email: 'unknown@example.com',
37
+ user_name: username
38
+ };
39
+ log.info(`Build ${args.buildId} rejected successfully!`);
40
+ log.info(`Rejected by: ${rejectedBy.user_name} (${rejectedBy.user_email})`);
41
+ } catch (error) {
42
+ log.error(`Failed to reject build ${args.buildId}`);
43
+ log.error(error);
44
+
45
+ // Provide user-friendly error message
46
+ exit(1, 'Failed to reject the build');
47
+ }
48
+ });
49
+ export default reject;
@@ -0,0 +1,49 @@
1
+ import command from '@percy/cli-command';
2
+ import { fetchCredentials, reviewCommandConfig } from './utils.js';
3
+
4
+ /**
5
+ * Unapprove command definition for Percy builds
6
+ * Allows users to unapprove builds using build ID and authentication credentials
7
+ */
8
+ export const unapprove = command('unapprove', {
9
+ description: 'Unapprove Percy builds',
10
+ ...reviewCommandConfig
11
+ }, async ({
12
+ flags,
13
+ args,
14
+ percy,
15
+ log,
16
+ exit
17
+ }) => {
18
+ // Early return if Percy is disabled
19
+ if (!percy) {
20
+ exit(0, 'Percy is disabled');
21
+ }
22
+
23
+ // Validate and get authentication credentials
24
+ const {
25
+ username,
26
+ accessKey
27
+ } = fetchCredentials(flags);
28
+ if (!username || !accessKey) {
29
+ exit(1, 'Username and access key are required to unapprove builds.');
30
+ }
31
+ log.info(`Unapproving build ${args.buildId}...`);
32
+ try {
33
+ // Call the Percy API to unapprove the build
34
+ const buildUnapprovalResponse = await percy.client.unapproveBuild(args.buildId, username, accessKey);
35
+ const unapprovedBy = buildUnapprovalResponse.data.attributes['action-performed-by'] || {
36
+ user_email: 'unknown@example.com',
37
+ user_name: username
38
+ };
39
+ log.info(`Build ${args.buildId} unapproved successfully!`);
40
+ log.info(`Unapproved by: ${unapprovedBy.user_name} (${unapprovedBy.user_email})`);
41
+ } catch (error) {
42
+ log.error(`Failed to unapprove build ${args.buildId}`);
43
+ log.error(error);
44
+
45
+ // Provide user-friendly error message
46
+ exit(1, 'Failed to unapprove the build');
47
+ }
48
+ });
49
+ export default unapprove;
package/dist/utils.js ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Constants for environment variable names and error messages
3
+ */
4
+ const ENV_VARS = {
5
+ BROWSERSTACK_USERNAME: 'BROWSERSTACK_USERNAME',
6
+ BROWSERSTACK_ACCESS_KEY: 'BROWSERSTACK_ACCESS_KEY'
7
+ };
8
+
9
+ /**
10
+ * Validates that required authentication credentials are present
11
+ * @param {Object} flags - Command flags object
12
+ * @returns {Object} Validated credentials object
13
+ */
14
+ export function fetchCredentials(flags) {
15
+ // Use flags if provided, otherwise fallback to environment variables
16
+ const username = flags.username || process.env[ENV_VARS.BROWSERSTACK_USERNAME];
17
+ const accessKey = flags.accessKey || process.env[ENV_VARS.BROWSERSTACK_ACCESS_KEY];
18
+ return {
19
+ username,
20
+ accessKey
21
+ };
22
+ }
23
+
24
+ /** * Configuration for review commands (approve, reject, unapprove)
25
+ * Contains common arguments and flags used across these commands
26
+ */
27
+ export const reviewCommandConfig = {
28
+ args: [{
29
+ name: 'build-id',
30
+ description: 'Build ID to approve',
31
+ type: 'id',
32
+ required: true
33
+ }],
34
+ flags: [{
35
+ name: 'username',
36
+ description: 'Username for authentication (can also be set via BROWSERSTACK_USERNAME env var)',
37
+ type: 'string'
38
+ }, {
39
+ name: 'access-key',
40
+ description: 'Access key for authentication (can also be set via BROWSERSTACK_ACCESS_KEY env var)',
41
+ type: 'string'
42
+ }],
43
+ examples: ['$0 <build-id>', '$0 <build-id> --username username --access-key **key**'],
44
+ percy: true
45
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/cli-build",
3
- "version": "1.31.1-beta.1",
3
+ "version": "1.31.1-beta.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,10 @@
19
19
  ],
20
20
  "main": "./dist/index.js",
21
21
  "type": "module",
22
- "exports": "./dist/index.js",
22
+ "exports": {
23
+ ".": "./dist/index.js",
24
+ "./utils": "./dist/utils.js"
25
+ },
23
26
  "scripts": {
24
27
  "build": "node ../../scripts/build",
25
28
  "lint": "eslint --ignore-path ../../.gitignore .",
@@ -33,7 +36,7 @@
33
36
  ]
34
37
  },
35
38
  "dependencies": {
36
- "@percy/cli-command": "1.31.1-beta.1"
39
+ "@percy/cli-command": "1.31.1-beta.2"
37
40
  },
38
- "gitHead": "5c43f9b5d1088332cf5644e06df162c33f64df5b"
41
+ "gitHead": "809b770761a7a5ad0044e462218452e920a4d1f0"
39
42
  }