@sprucelabs/heartwood-polish 7.1.272 → 7.1.274

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.
@@ -8,7 +8,7 @@ class SpruceError extends error_1.default {
8
8
  friendlyMessage() {
9
9
  const { options } = this;
10
10
  let message;
11
- switch (options === null || options === void 0 ? void 0 : options.code) {
11
+ switch (options?.code) {
12
12
  case 'INVALID_TARGET':
13
13
  message = `The target you passed was invalid! You passed:\n\n${JSON.stringify(options.target, undefined, 4)}`;
14
14
  break;
@@ -11,7 +11,6 @@ const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
11
11
  const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
12
12
  class StepLoader {
13
13
  constructor(options) {
14
- var _a;
15
14
  const { cwd } = (0, schema_1.assertOptions)(options, ['cwd']);
16
15
  this.cwd = cwd;
17
16
  this.packageJsonPath = spruce_skill_utils_1.diskUtil.resolvePath(this.cwd, 'package.json');
@@ -30,7 +29,7 @@ class StepLoader {
30
29
  });
31
30
  }
32
31
  const content = require(this.packageJsonPath);
33
- if (!((_a = content === null || content === void 0 ? void 0 : content.skill) === null || _a === void 0 ? void 0 : _a.namespace)) {
32
+ if (!content?.skill?.namespace) {
34
33
  throw new SpruceError_1.default({
35
34
  code: 'NAMESPACE_NOT_FOUND',
36
35
  friendlyMessage: `I could not find a skill.namespace in '${this.packageJsonPath}'`,
@@ -40,7 +39,7 @@ class StepLoader {
40
39
  this.namespace = content.skill.namespace;
41
40
  }
42
41
  async load(altNamespace) {
43
- this.glob = spruce_skill_utils_1.diskUtil.resolvePath(this.cwd, 'src', '**', `${altNamespace !== null && altNamespace !== void 0 ? altNamespace : this.namespace}.polish.ts`);
42
+ this.glob = spruce_skill_utils_1.diskUtil.resolvePath(this.cwd, 'src', '**', `${altNamespace ?? this.namespace}.polish.ts`);
44
43
  const matches = this.glob ? await (0, globby_1.default)(this.glob) : [];
45
44
  if (matches.length === 0) {
46
45
  throw new SpruceError_1.default({
@@ -82,23 +81,21 @@ class StepLoader {
82
81
  }
83
82
  static async execute(cmd, args) {
84
83
  return new Promise((resolve, reject) => {
85
- var _a, _b;
86
84
  let stdout = '';
87
85
  let stderr = '';
88
86
  const child = (0, child_process_1.spawn)(cmd, args, {
89
87
  shell: true,
90
88
  });
91
- (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.addListener('data', (data) => {
89
+ child.stdout?.addListener('data', (data) => {
92
90
  stdout += data;
93
91
  });
94
- (_b = child.stderr) === null || _b === void 0 ? void 0 : _b.addListener('data', (data) => {
92
+ child.stderr?.addListener('data', (data) => {
95
93
  stderr += data;
96
94
  });
97
95
  const closeHandler = (code) => {
98
96
  setTimeout(() => {
99
- var _a, _b;
100
- (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
101
- (_b = child.stderr) === null || _b === void 0 ? void 0 : _b.removeAllListeners();
97
+ child.stdout?.removeAllListeners();
98
+ child.stderr?.removeAllListeners();
102
99
  child.removeAllListeners();
103
100
  if (code === 0) {
104
101
  stdout = stdout.replace(StepLoader.divider, '').trim();
@@ -46,10 +46,9 @@ class AssertAction extends AbstractAction_1.default {
46
46
  });
47
47
  }
48
48
  async getProperty(selector, name) {
49
- var _a;
50
49
  const element = await this.page.$(selector);
51
- const prop = await (element === null || element === void 0 ? void 0 : element.getProperty(name));
52
- const actual = await ((_a = prop === null || prop === void 0 ? void 0 : prop.jsonValue) === null || _a === void 0 ? void 0 : _a.call(prop));
50
+ const prop = await element?.getProperty(name);
51
+ const actual = await prop?.jsonValue?.();
53
52
  return actual;
54
53
  }
55
54
  async getInnerHtml(selector) {
@@ -19,7 +19,7 @@ class DragAndDropAction extends AbstractAction_1.default {
19
19
  const source = await this.waitForSelector(this.sourceSelector);
20
20
  const destination = await this.waitForSelector(this.destinationSelector);
21
21
  const sourceBox = await source.boundingBox();
22
- const destinationBox = await (destination === null || destination === void 0 ? void 0 : destination.boundingBox());
22
+ const destinationBox = await destination?.boundingBox();
23
23
  await this.page.mouse.move(sourceBox.x + sourceBox.width / 2, sourceBox.y + sourceBox.height / 2);
24
24
  await this.page.mouse.down();
25
25
  await this.page.mouse.move(destinationBox.x + destinationBox.width / 2, destinationBox.y + destinationBox.height / 2, {
@@ -13,7 +13,7 @@ class FileAction extends AbstractAction_1.default {
13
13
  }
14
14
  async go() {
15
15
  const element = await this.page.$(this.target);
16
- await (element === null || element === void 0 ? void 0 : element.uploadFile(this.absoluteFilePath));
16
+ await element?.uploadFile(this.absoluteFilePath);
17
17
  }
18
18
  }
19
19
  exports.default = FileAction;
@@ -9,10 +9,9 @@ const ActionFactory_1 = __importDefault(require("./ActionFactory"));
9
9
  const clearField_1 = require("./clearField");
10
10
  class TypeTextAction extends AbstractAction_1.default {
11
11
  process(options) {
12
- var _a;
13
12
  this.selector = this.targets.generate(options.target);
14
13
  this.text = options.text;
15
- this.shouldClearFirst = (_a = options.shouldClearFirst) !== null && _a !== void 0 ? _a : false;
14
+ this.shouldClearFirst = options.shouldClearFirst ?? false;
16
15
  }
17
16
  async go() {
18
17
  await this.waitForSelector(this.selector);
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const SpruceError_1 = __importDefault(require("../../errors/SpruceError"));
7
7
  const AssertAction_1 = require("../AssertAction");
8
8
  async function assertDoesNotInclude(options) {
9
- var _a;
10
9
  const { targetSelector, value, getInnerHtml } = options;
11
- const actual = (_a = (await getInnerHtml(targetSelector))) !== null && _a !== void 0 ? _a : '';
10
+ const actual = (await getInnerHtml(targetSelector)) ?? '';
12
11
  const foundIdx = actual.indexOf(value);
13
12
  if (foundIdx > -1) {
14
13
  throw new SpruceError_1.default({
@@ -35,7 +35,7 @@ async function assertPresentSlide(options) {
35
35
  if (hasSlideNumber) {
36
36
  const selector = `${targetSelector} .swipe_dots_wrapper span.dot:nth-of-type(${slideIdx + 1}).current`;
37
37
  const className = await getProperty(selector, 'className');
38
- if ((className !== null && className !== void 0 ? className : '').length === 0) {
38
+ if ((className ?? '').length === 0) {
39
39
  throw new SpruceError_1.default({
40
40
  code: 'ASSERTION_FAILED',
41
41
  friendlyMessage: `I expected to find the 'current' slide as slide #${slideIdx}. I was looking for ${selector}.`,
package/build/polish.js CHANGED
@@ -54,21 +54,21 @@ async function go() {
54
54
  process.exit();
55
55
  }
56
56
  function getNamespace() {
57
- return argv === null || argv === void 0 ? void 0 : argv.namespace;
57
+ return argv?.namespace;
58
58
  }
59
59
  function getBaseUrl() {
60
- return process.env.POLISH_BASE_URL || (argv === null || argv === void 0 ? void 0 : argv.baseUrl) || 'https://spruce.bot';
60
+ return process.env.POLISH_BASE_URL || argv?.baseUrl || 'https://spruce.bot';
61
61
  }
62
62
  function getIsHeadless() {
63
63
  return process.env.HEADLESS
64
64
  ? process.env.HEADLESS !== 'false'
65
- : (argv === null || argv === void 0 ? void 0 : argv.isHeadless) === 'true';
65
+ : argv?.isHeadless === 'true';
66
66
  }
67
67
  function getWindowSize() {
68
68
  const str = process.env.WINDOW_SIZE
69
69
  ? process.env.WINDOW_SIZE
70
- : argv === null || argv === void 0 ? void 0 : argv.windowSize;
71
- const [width, height] = (str !== null && str !== void 0 ? str : '1024,768').split(',');
70
+ : argv?.windowSize;
71
+ const [width, height] = (str ?? '1024,768').split(',');
72
72
  return {
73
73
  width: parseInt(width, 10),
74
74
  height: parseInt(height, 10),
@@ -10,7 +10,7 @@ class Polisher {
10
10
  ]);
11
11
  this.page = page;
12
12
  this.log = log;
13
- this.stepWaitMs = stepWaitMs !== null && stepWaitMs !== void 0 ? stepWaitMs : this.stepWaitMs;
13
+ this.stepWaitMs = stepWaitMs ?? this.stepWaitMs;
14
14
  this.page.on('console', (msg) => this.log.info(msg.text()));
15
15
  }
16
16
  async start(url, steps) {
@@ -99,13 +99,11 @@ class TargetSelectorGenerator {
99
99
  return match;
100
100
  }
101
101
  generateSelectorSuffixFromString(component, id) {
102
- var _a;
103
- const map = (_a = this.selectorStringMap[component]) !== null && _a !== void 0 ? _a : this.selectorStringMap._default;
102
+ const map = this.selectorStringMap[component] ?? this.selectorStringMap._default;
104
103
  return map(id);
105
104
  }
106
105
  generateSelectorSuffixFromNumber(component, id) {
107
- var _a;
108
- const map = (_a = this.selectorNumberMap[component]) !== null && _a !== void 0 ? _a : this.selectorNumberMap._default;
106
+ const map = this.selectorNumberMap[component] ?? this.selectorNumberMap._default;
109
107
  return map(id);
110
108
  }
111
109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprucelabs/heartwood-polish",
3
- "version": "7.1.272",
3
+ "version": "7.1.274",
4
4
  "main": "build/index.js",
5
5
  "license": "MIT",
6
6
  "access": "public",
@@ -41,25 +41,25 @@
41
41
  "update.dependencies": "yarn run clean.dependencies && yarn"
42
42
  },
43
43
  "dependencies": {
44
- "@sprucelabs/error": "^6.0.477",
45
- "@sprucelabs/globby": "^2.0.438",
46
- "@sprucelabs/schema": "^30.0.486",
47
- "@sprucelabs/spruce-core-schemas": "^40.1.472",
48
- "@sprucelabs/spruce-skill-utils": "^31.0.545",
49
- "puppeteer": "^23.5.3",
44
+ "@sprucelabs/error": "^6.0.480",
45
+ "@sprucelabs/globby": "^2.0.441",
46
+ "@sprucelabs/schema": "^30.0.489",
47
+ "@sprucelabs/spruce-core-schemas": "^40.1.475",
48
+ "@sprucelabs/spruce-skill-utils": "^31.0.548",
49
+ "puppeteer": "^23.6.0",
50
50
  "yargs": "^17.7.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@sprucelabs/jest-json-reporter": "^8.0.477",
53
+ "@sprucelabs/jest-json-reporter": "^8.0.481",
54
54
  "@sprucelabs/jest-sheets-reporter": "^3.0.155",
55
- "@sprucelabs/resolve-path-aliases": "^2.0.456",
55
+ "@sprucelabs/resolve-path-aliases": "^2.0.457",
56
56
  "@sprucelabs/semantic-release": "^5.0.2",
57
- "@sprucelabs/spruce-test-fixtures": "^62.3.43",
58
- "@sprucelabs/test": "^9.0.50",
59
- "@sprucelabs/test-utils": "^5.1.427",
60
- "@types/node": "^22.7.5",
57
+ "@sprucelabs/spruce-test-fixtures": "^62.3.45",
58
+ "@sprucelabs/test": "^9.0.51",
59
+ "@sprucelabs/test-utils": "^5.1.433",
60
+ "@types/node": "^22.7.6",
61
61
  "chokidar-cli": "^3.0.0",
62
- "devtools-protocol": "^0.0.1366620",
62
+ "devtools-protocol": "^0.0.1368592",
63
63
  "eslint": "^9.12.0",
64
64
  "eslint-config-spruce": "^11.2.26",
65
65
  "jest": "^29.7.0",
package/tsconfig.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "skipLibCheck": true,
4
4
  "module": "commonjs",
5
5
  "esModuleInterop": true,
6
- "target": "ES2019",
6
+ "target": "ES2020",
7
7
  "lib": [
8
8
  "DOM",
9
9
  "ES2022"