@sprucelabs/spruce-skill-utils 31.0.544 → 31.0.546

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.
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const error_1 = __importDefault(require("@sprucelabs/error"));
7
7
  class SpruceError extends error_1.default {
8
8
  friendlyMessage() {
9
- var _a, _b;
10
9
  let message = super.friendlyMessage();
11
10
  switch (this.options.code) {
12
11
  case 'FAILED_TO_LOAD_PLUGIN':
@@ -17,7 +16,7 @@ class SpruceError extends error_1.default {
17
16
  message = `"${this.options.suppliedCode}" is not a valid feature code. Valid codes are: ${this.options.validCodes.join(', ')}`;
18
17
  break;
19
18
  case 'SKILL_CRASHED':
20
- message = `Shoot, your skill crashed. Here are some deets:\n\n${(_b = (_a = this.options.originalError) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'UNKNOWN'}`;
19
+ message = `Shoot, your skill crashed. Here are some deets:\n\n${this.options.originalError?.message ?? 'UNKNOWN'}`;
21
20
  break;
22
21
  case 'INVALID_PACKAGE_JSON':
23
22
  message = `I could not open the package.json for this skill. Error was: ${this.options.errorMessage}`;
@@ -2,9 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const locationRenderer = {
4
4
  renderAddress(address) {
5
- var _a, _b, _c, _d, _e, _f;
6
5
  return `${address
7
- ? `${(_a = address.street1) !== null && _a !== void 0 ? _a : ''} ${(_b = address.street2) !== null && _b !== void 0 ? _b : ''} ${(_c = address.city) !== null && _c !== void 0 ? _c : ''} ${(_d = address.province) !== null && _d !== void 0 ? _d : ''} ${(_e = address.zip) !== null && _e !== void 0 ? _e : ''} ${(_f = address.country) !== null && _f !== void 0 ? _f : ''}`
6
+ ? `${address.street1 ?? ''} ${address.street2 ?? ''} ${address.city ?? ''} ${address.province ?? ''} ${address.zip ?? ''} ${address.country ?? ''}`
8
7
  : ``}`
9
8
  .replace(/\s\s+/g, ' ')
10
9
  .trim();
@@ -15,7 +15,6 @@ class AuthService {
15
15
  this.pkg = pkgService;
16
16
  }
17
17
  static Auth(cwd) {
18
- var _a;
19
18
  if (!cwd) {
20
19
  throw new schema_1.SchemaError({
21
20
  code: 'MISSING_PARAMETERS',
@@ -31,7 +30,7 @@ class AuthService {
31
30
  friendlyMessage: 'Could not find a package.json file!',
32
31
  });
33
32
  }
34
- const auth = new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(envService, pkgService);
33
+ const auth = new (this.Class ?? this)(envService, pkgService);
35
34
  return auth;
36
35
  }
37
36
  getLoggedInPerson() {
@@ -55,11 +55,10 @@ class PkgService {
55
55
  return path_1.default.join(this.cwd, 'package.json');
56
56
  }
57
57
  isInstalled(pkg) {
58
- var _a, _b;
59
58
  try {
60
59
  const contents = this.readPackage();
61
- return (!!((_a = contents.dependencies) === null || _a === void 0 ? void 0 : _a[pkg]) ||
62
- !!((_b = contents.devDependencies) === null || _b === void 0 ? void 0 : _b[pkg]));
60
+ return (!!contents.dependencies?.[pkg] ||
61
+ !!contents.devDependencies?.[pkg]);
63
62
  }
64
63
  catch (e) {
65
64
  return false;
@@ -14,9 +14,8 @@ class SettingsService {
14
14
  this.cwd = cwd;
15
15
  }
16
16
  isMarkedAsInstalled(code) {
17
- var _a;
18
17
  const settings = this.loadSettings();
19
- return !!((_a = settings.installed) === null || _a === void 0 ? void 0 : _a.find((c) => c === code));
18
+ return !!settings.installed?.find((c) => c === code);
20
19
  }
21
20
  markAsInstalled(code) {
22
21
  if (!this.isMarkedAsInstalled(code)) {
@@ -44,9 +43,8 @@ class SettingsService {
44
43
  }
45
44
  }
46
45
  isMarkedAsPermanentlySkipped(code) {
47
- var _a;
48
46
  const settings = this.loadSettings();
49
- return !!((_a = settings.skipped) === null || _a === void 0 ? void 0 : _a.find((c) => c === code));
47
+ return !!settings.skipped?.find((c) => c === code);
50
48
  }
51
49
  get(key) {
52
50
  return (0, get_1.default)(this.loadSettings(), key);
@@ -10,7 +10,7 @@ const addonUtil = {
10
10
  const results = await (0, globby_1.default)(path_1.default.join(...path, '**', '*.addon.[t|j]s'));
11
11
  const all = results.map((path) => {
12
12
  const result = require(path);
13
- if (typeof (result === null || result === void 0 ? void 0 : result.default) === 'function') {
13
+ if (typeof result?.default === 'function') {
14
14
  return result.default(options);
15
15
  }
16
16
  });
@@ -21,7 +21,7 @@ const addonUtil = {
21
21
  const results = globby_1.default.sync(path_1.default.join(...path, '**', '*.addon.[t|j]s'));
22
22
  results.forEach((path) => {
23
23
  const result = require(path);
24
- if (typeof (result === null || result === void 0 ? void 0 : result.default) === 'function') {
24
+ if (typeof result?.default === 'function') {
25
25
  result.default(options);
26
26
  }
27
27
  });
@@ -14,22 +14,20 @@ function getProcess() {
14
14
  }
15
15
  let lastLogTimeMs = Date.now();
16
16
  const getMaxLogPrefixesLength = () => {
17
- var _a, _b, _c, _d;
18
- return typeof ((_b = (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.MAXIMUM_LOG_PREFIXES_LENGTH) === 'string'
19
- ? +((_d = (_c = getProcess()) === null || _c === void 0 ? void 0 : _c.env) === null || _d === void 0 ? void 0 : _d.MAXIMUM_LOG_PREFIXES_LENGTH)
17
+ return typeof getProcess()?.env?.MAXIMUM_LOG_PREFIXES_LENGTH === 'string'
18
+ ? +getProcess()?.env?.MAXIMUM_LOG_PREFIXES_LENGTH
20
19
  : undefined;
21
20
  };
22
21
  function buildLog(prefix = undefined, options) {
23
- var _a, _b, _c, _d, _e;
24
- const { colors = {}, log, useColors } = options !== null && options !== void 0 ? options : {};
22
+ const { colors = {}, log, useColors } = options ?? {};
25
23
  const { info = 'yellow', error = 'red' } = colors;
26
- const isInteractive = (_b = (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.stdout) === null || _b === void 0 ? void 0 : _b.isTTY;
24
+ const isInteractive = getProcess()?.stdout?.isTTY;
27
25
  const shouldUseColors = useColors !== false && isInteractive;
28
26
  const pre = prefix ? `${prefix} ::` : undefined;
29
27
  const transports = {
30
- ERROR: (_c = options === null || options === void 0 ? void 0 : options.transportsByLevel) === null || _c === void 0 ? void 0 : _c.ERROR,
31
- INFO: (_d = options === null || options === void 0 ? void 0 : options.transportsByLevel) === null || _d === void 0 ? void 0 : _d.INFO,
32
- WARN: (_e = options === null || options === void 0 ? void 0 : options.transportsByLevel) === null || _e === void 0 ? void 0 : _e.WARN,
28
+ ERROR: options?.transportsByLevel?.ERROR,
29
+ INFO: options?.transportsByLevel?.INFO,
30
+ WARN: options?.transportsByLevel?.WARN,
33
31
  };
34
32
  const logUtil = {
35
33
  prefix,
@@ -59,8 +57,7 @@ function buildLog(prefix = undefined, options) {
59
57
  return transports[level];
60
58
  }
61
59
  function write(chalkMethod, rawArgs, level) {
62
- var _a, _b, _c, _d, _e;
63
- const args = rawArgs.map((a) => { var _a, _b; return (_b = (_a = a === null || a === void 0 ? void 0 : a.toString) === null || _a === void 0 ? void 0 : _a.call(a)) !== null && _b !== void 0 ? _b : 'undefined'; });
60
+ const args = rawArgs.map((a) => a?.toString?.() ?? 'undefined');
64
61
  let chalkArgs = [...args];
65
62
  let builtPrefix = pre;
66
63
  if (pre) {
@@ -79,7 +76,7 @@ function buildLog(prefix = undefined, options) {
79
76
  transport(...[prefix.trim(), ...args].filter((t) => t && t.length > 0));
80
77
  return prefix;
81
78
  }
82
- const env = (_b = (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.env) !== null && _b !== void 0 ? _b : {};
79
+ const env = getProcess()?.env ?? {};
83
80
  let logMethod = 'log';
84
81
  switch (level) {
85
82
  case 'ERROR':
@@ -93,12 +90,12 @@ function buildLog(prefix = undefined, options) {
93
90
  break;
94
91
  }
95
92
  transport =
96
- log !== null && log !== void 0 ? log : (level === 'ERROR' && ((_d = (_c = getProcess()) === null || _c === void 0 ? void 0 : _c.stderr) === null || _d === void 0 ? void 0 : _d.write)
97
- ? (...args) => {
98
- var _a;
99
- (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.stderr.write(args.join(' ') + '\n');
100
- }
101
- : ((_e = console[logMethod]) !== null && _e !== void 0 ? _e : console.log).bind(console));
93
+ log ??
94
+ (level === 'ERROR' && getProcess()?.stderr?.write
95
+ ? (...args) => {
96
+ getProcess()?.stderr.write(args.join(' ') + '\n');
97
+ }
98
+ : (console[logMethod] ?? console.log).bind(console));
102
99
  let message = shouldUseColors === false
103
100
  ? `(${level})${prefix}`
104
101
  : chalkMethod(...chalkArgs);
@@ -122,8 +119,7 @@ function buildLog(prefix = undefined, options) {
122
119
  }
123
120
  exports.testLog = buildLog('TEST', {
124
121
  log: (...parts) => {
125
- var _a, _b, _c;
126
- (_c = (_b = (_a = getProcess()) === null || _a === void 0 ? void 0 : _a.stderr) === null || _b === void 0 ? void 0 : _b.write) === null || _c === void 0 ? void 0 : _c.call(_b, parts.join(' ') + '\n');
122
+ getProcess()?.stderr?.write?.(parts.join(' ') + '\n');
127
123
  },
128
124
  });
129
125
  exports.stubLog = buildLog('STUB', {
@@ -4,7 +4,7 @@ exports.default = joinIntoSentence;
4
4
  function joinIntoSentence(words) {
5
5
  const last = words.pop();
6
6
  if (words.length === 0) {
7
- return last !== null && last !== void 0 ? last : '';
7
+ return last ?? '';
8
8
  }
9
9
  return words.join(', ') + ' & ' + last;
10
10
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "31.0.544",
6
+ "version": "31.0.546",
7
7
  "skill": {
8
8
  "namespace": "skill-utils",
9
9
  "upgradeIgnoreList": [
@@ -58,8 +58,8 @@
58
58
  "lint.tsc": "tsc -p . --noEmit"
59
59
  },
60
60
  "dependencies": {
61
- "@sprucelabs/globby": "^2.0.437",
62
- "@sprucelabs/schema": "^30.0.485",
61
+ "@sprucelabs/globby": "^2.0.439",
62
+ "@sprucelabs/schema": "^30.0.486",
63
63
  "chalk": "^4.1.2",
64
64
  "dotenv": "^16.4.5",
65
65
  "fs-extra": "^11.2.0",
@@ -68,17 +68,17 @@
68
68
  "uuid": "^10.0.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@sprucelabs/esm-postbuild": "^6.0.459",
72
- "@sprucelabs/jest-json-reporter": "^8.0.475",
71
+ "@sprucelabs/esm-postbuild": "^6.0.461",
72
+ "@sprucelabs/jest-json-reporter": "^8.0.478",
73
73
  "@sprucelabs/jest-sheets-reporter": "^3.0.155",
74
- "@sprucelabs/resolve-path-aliases": "^2.0.454",
74
+ "@sprucelabs/resolve-path-aliases": "^2.0.456",
75
75
  "@sprucelabs/semantic-release": "^5.0.2",
76
- "@sprucelabs/test": "^9.0.50",
77
- "@sprucelabs/test-utils": "^5.1.426",
76
+ "@sprucelabs/test": "^9.0.51",
77
+ "@sprucelabs/test-utils": "^5.1.430",
78
78
  "@types/fs-extra": "^11.0.4",
79
79
  "@types/inflection": "^1.13.2",
80
80
  "@types/lodash": "^4.17.10",
81
- "@types/node": "^22.7.5",
81
+ "@types/node": "^22.7.6",
82
82
  "@types/uuid": "^10.0.0",
83
83
  "chokidar-cli": "^3.0.0",
84
84
  "eslint": "^9.12.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"