this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

delay profile validation

+249 -14
+216 -2
package-lock.json
··· 17 17 "consola": "^3.4.2", 18 18 "dark-mode": "^5.0.0", 19 19 "es-toolkit": "^1.45.1", 20 - "mac-terminal": "^5.0.0" 20 + "mac-terminal": "^5.0.0", 21 + "ow": "^3.1.1" 21 22 }, 22 23 "bin": { 23 24 "auto-terminal-profile": "source/cli.js" ··· 1478 1479 "dev": true, 1479 1480 "license": "MIT" 1480 1481 }, 1482 + "node_modules/@sindresorhus/is": { 1483 + "version": "7.2.0", 1484 + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz", 1485 + "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==", 1486 + "license": "MIT", 1487 + "engines": { 1488 + "node": ">=18" 1489 + }, 1490 + "funding": { 1491 + "url": "https://github.com/sindresorhus/is?sponsor=1" 1492 + } 1493 + }, 1481 1494 "node_modules/@sindresorhus/merge-streams": { 1482 1495 "version": "4.0.0", 1483 1496 "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz", ··· 2597 2610 "url": "https://github.com/sponsors/ljharb" 2598 2611 } 2599 2612 }, 2613 + "node_modules/callsites": { 2614 + "version": "4.2.0", 2615 + "resolved": "https://registry.npmjs.org/callsites/-/callsites-4.2.0.tgz", 2616 + "integrity": "sha512-kfzR4zzQtAE9PC7CzZsjl3aBNbXWuXiSeOCdLcPpBfGW8YuCqQHcRPFDbr/BPVmd3EEPVpuFzLyuT/cUhPr4OQ==", 2617 + "license": "MIT", 2618 + "engines": { 2619 + "node": ">=12.20" 2620 + }, 2621 + "funding": { 2622 + "url": "https://github.com/sponsors/sindresorhus" 2623 + } 2624 + }, 2600 2625 "node_modules/caniuse-lite": { 2601 2626 "version": "1.0.30001787", 2602 2627 "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001787.tgz", ··· 2749 2774 "node": "^14.18.0 || >=16.10.0" 2750 2775 } 2751 2776 }, 2777 + "node_modules/convert-hrtime": { 2778 + "version": "5.0.0", 2779 + "resolved": "https://registry.npmjs.org/convert-hrtime/-/convert-hrtime-5.0.0.tgz", 2780 + "integrity": "sha512-lOETlkIeYSJWcbbcvjRKGxVMXJR+8+OQb/mTPbA4ObPMytYIsUbuOE0Jzy60hjARYszq1id0j8KgVhC+WGZVTg==", 2781 + "license": "MIT", 2782 + "engines": { 2783 + "node": ">=12" 2784 + }, 2785 + "funding": { 2786 + "url": "https://github.com/sponsors/sindresorhus" 2787 + } 2788 + }, 2752 2789 "node_modules/convert-source-map": { 2753 2790 "version": "2.0.0", 2754 2791 "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", ··· 3178 3215 "version": "1.1.0", 3179 3216 "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", 3180 3217 "integrity": "sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==", 3181 - "dev": true, 3182 3218 "license": "MIT", 3183 3219 "engines": { 3184 3220 "node": ">=18" ··· 4136 4172 "dev": true, 4137 4173 "license": "Apache-2.0" 4138 4174 }, 4175 + "node_modules/fast-equals": { 4176 + "version": "5.4.0", 4177 + "resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.4.0.tgz", 4178 + "integrity": "sha512-jt2DW/aNFNwke7AUd+Z+e6pz39KO5rzdbbFCg2sGafS4mk13MI7Z8O5z9cADNn5lhGODIgLwug6TZO2ctf7kcw==", 4179 + "license": "MIT", 4180 + "engines": { 4181 + "node": ">=6.0.0" 4182 + } 4183 + }, 4139 4184 "node_modules/fast-glob": { 4140 4185 "version": "3.3.3", 4141 4186 "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", ··· 4386 4431 "url": "https://github.com/sponsors/ljharb" 4387 4432 } 4388 4433 }, 4434 + "node_modules/function-timeout": { 4435 + "version": "1.0.2", 4436 + "resolved": "https://registry.npmjs.org/function-timeout/-/function-timeout-1.0.2.tgz", 4437 + "integrity": "sha512-939eZS4gJ3htTHAldmyyuzlrD58P03fHG49v2JfFXbV6OhvZKRC9j2yAtdHw/zrp2zXHuv05zMIy40F0ge7spA==", 4438 + "license": "MIT", 4439 + "engines": { 4440 + "node": ">=18" 4441 + }, 4442 + "funding": { 4443 + "url": "https://github.com/sponsors/sindresorhus" 4444 + } 4445 + }, 4389 4446 "node_modules/function.prototype.name": { 4390 4447 "version": "1.1.8", 4391 4448 "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.8.tgz", ··· 4798 4855 "node": ">=18.18.0" 4799 4856 } 4800 4857 }, 4858 + "node_modules/identifier-regex": { 4859 + "version": "1.0.1", 4860 + "resolved": "https://registry.npmjs.org/identifier-regex/-/identifier-regex-1.0.1.tgz", 4861 + "integrity": "sha512-ZrYyM0sozNPZlvBvE7Oq9Bn44n0qKGrYu5sQ0JzMUnjIhpgWYE2JB6aBoFwEYdPjqj7jPyxXTMJiHDOxDfd8yw==", 4862 + "license": "MIT", 4863 + "dependencies": { 4864 + "reserved-identifiers": "^1.0.0" 4865 + }, 4866 + "engines": { 4867 + "node": ">=18" 4868 + }, 4869 + "funding": { 4870 + "url": "https://github.com/sponsors/sindresorhus" 4871 + } 4872 + }, 4801 4873 "node_modules/ignore": { 4802 4874 "version": "5.3.2", 4803 4875 "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", ··· 5116 5188 "node": ">=0.10.0" 5117 5189 } 5118 5190 }, 5191 + "node_modules/is-identifier": { 5192 + "version": "1.0.1", 5193 + "resolved": "https://registry.npmjs.org/is-identifier/-/is-identifier-1.0.1.tgz", 5194 + "integrity": "sha512-HQ5v4rEJ7REUV54bCd2l5FaD299SGDEn2UPoVXaTHAyGviLq2menVUD2udi3trQ32uvB6LdAh/0ck2EuizrtpA==", 5195 + "license": "MIT", 5196 + "dependencies": { 5197 + "identifier-regex": "^1.0.0", 5198 + "super-regex": "^1.0.0" 5199 + }, 5200 + "engines": { 5201 + "node": ">=18" 5202 + }, 5203 + "funding": { 5204 + "url": "https://github.com/sponsors/sindresorhus" 5205 + } 5206 + }, 5119 5207 "node_modules/is-in-ssh": { 5120 5208 "version": "1.0.0", 5121 5209 "resolved": "https://registry.npmjs.org/is-in-ssh/-/is-in-ssh-1.0.0.tgz", ··· 5764 5852 "url": "https://github.com/sponsors/sindresorhus" 5765 5853 } 5766 5854 }, 5855 + "node_modules/make-asynchronous": { 5856 + "version": "1.1.0", 5857 + "resolved": "https://registry.npmjs.org/make-asynchronous/-/make-asynchronous-1.1.0.tgz", 5858 + "integrity": "sha512-ayF7iT+44LXdxJLTrTd3TLQpFDDvPCBxXxbv+pMUSuHA5Q8zyAfwkRP6aHHwNVFBUFWtxAHqwNJxF8vMZLAbVg==", 5859 + "license": "MIT", 5860 + "dependencies": { 5861 + "p-event": "^6.0.0", 5862 + "type-fest": "^4.6.0", 5863 + "web-worker": "^1.5.0" 5864 + }, 5865 + "engines": { 5866 + "node": ">=18" 5867 + }, 5868 + "funding": { 5869 + "url": "https://github.com/sponsors/sindresorhus" 5870 + } 5871 + }, 5872 + "node_modules/make-asynchronous/node_modules/type-fest": { 5873 + "version": "4.41.0", 5874 + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", 5875 + "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==", 5876 + "license": "(MIT OR CC0-1.0)", 5877 + "engines": { 5878 + "node": ">=16" 5879 + }, 5880 + "funding": { 5881 + "url": "https://github.com/sponsors/sindresorhus" 5882 + } 5883 + }, 5767 5884 "node_modules/math-intrinsics": { 5768 5885 "version": "1.1.0", 5769 5886 "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", ··· 6175 6292 "node": ">= 0.8.0" 6176 6293 } 6177 6294 }, 6295 + "node_modules/ow": { 6296 + "version": "3.1.1", 6297 + "resolved": "https://registry.npmjs.org/ow/-/ow-3.1.1.tgz", 6298 + "integrity": "sha512-Hixi5roGFYZuiPV2pnnBi1hXdRG0uqifxE8rCCU6lKeCCQS+VGihuJnYxaJSffDz/clyH+xB2z1hXYRzeIcUMA==", 6299 + "license": "MIT", 6300 + "dependencies": { 6301 + "@sindresorhus/is": "^7.1.0", 6302 + "callsites": "^4.2.0", 6303 + "dot-prop": "^10.1.0", 6304 + "environment": "^1.1.0", 6305 + "fast-equals": "^5.3.2", 6306 + "is-identifier": "^1.0.1" 6307 + }, 6308 + "engines": { 6309 + "node": ">=20" 6310 + }, 6311 + "funding": { 6312 + "url": "https://github.com/sponsors/sindresorhus" 6313 + } 6314 + }, 6178 6315 "node_modules/own-keys": { 6179 6316 "version": "1.0.1", 6180 6317 "resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.1.tgz", ··· 6263 6400 "@oxc-resolver/binding-win32-x64-msvc": "11.19.1" 6264 6401 } 6265 6402 }, 6403 + "node_modules/p-event": { 6404 + "version": "6.0.1", 6405 + "resolved": "https://registry.npmjs.org/p-event/-/p-event-6.0.1.tgz", 6406 + "integrity": "sha512-Q6Bekk5wpzW5qIyUP4gdMEujObYstZl6DMMOSenwBvV0BlE5LkDwkjs5yHbZmdCEq2o4RJx4tE1vwxFVf2FG1w==", 6407 + "license": "MIT", 6408 + "dependencies": { 6409 + "p-timeout": "^6.1.2" 6410 + }, 6411 + "engines": { 6412 + "node": ">=16.17" 6413 + }, 6414 + "funding": { 6415 + "url": "https://github.com/sponsors/sindresorhus" 6416 + } 6417 + }, 6266 6418 "node_modules/p-limit": { 6267 6419 "version": "3.1.0", 6268 6420 "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", ··· 6295 6447 "url": "https://github.com/sponsors/sindresorhus" 6296 6448 } 6297 6449 }, 6450 + "node_modules/p-timeout": { 6451 + "version": "6.1.4", 6452 + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-6.1.4.tgz", 6453 + "integrity": "sha512-MyIV3ZA/PmyBN/ud8vV9XzwTrNtR4jFrObymZYnZqMmW0zA8Z17vnT0rBgFE/TlohB+YCHqXMgZzb3Csp49vqg==", 6454 + "license": "MIT", 6455 + "engines": { 6456 + "node": ">=14.16" 6457 + }, 6458 + "funding": { 6459 + "url": "https://github.com/sponsors/sindresorhus" 6460 + } 6461 + }, 6298 6462 "node_modules/package-json-validator": { 6299 6463 "version": "1.3.1", 6300 6464 "resolved": "https://registry.npmjs.org/package-json-validator/-/package-json-validator-1.3.1.tgz", ··· 6655 6819 "license": "MIT", 6656 6820 "engines": { 6657 6821 "node": ">=0.10.0" 6822 + } 6823 + }, 6824 + "node_modules/reserved-identifiers": { 6825 + "version": "1.2.0", 6826 + "resolved": "https://registry.npmjs.org/reserved-identifiers/-/reserved-identifiers-1.2.0.tgz", 6827 + "integrity": "sha512-yE7KUfFvaBFzGPs5H3Ops1RevfUEsDc5Iz65rOwWg4lE8HJSYtle77uul3+573457oHvBKuHYDl/xqUkKpEEdw==", 6828 + "license": "MIT", 6829 + "engines": { 6830 + "node": ">=18" 6831 + }, 6832 + "funding": { 6833 + "url": "https://github.com/sponsors/sindresorhus" 6658 6834 } 6659 6835 }, 6660 6836 "node_modules/resolve": { ··· 7425 7601 "url": "https://github.com/sponsors/sindresorhus" 7426 7602 } 7427 7603 }, 7604 + "node_modules/super-regex": { 7605 + "version": "1.1.0", 7606 + "resolved": "https://registry.npmjs.org/super-regex/-/super-regex-1.1.0.tgz", 7607 + "integrity": "sha512-WHkws2ZflZe41zj6AolvvmaTrWds/VuyeYr9iPVv/oQeaIoVxMKaushfFWpOGDT+GuBrM/sVqF8KUCYQlSSTdQ==", 7608 + "license": "MIT", 7609 + "dependencies": { 7610 + "function-timeout": "^1.0.1", 7611 + "make-asynchronous": "^1.0.1", 7612 + "time-span": "^5.1.0" 7613 + }, 7614 + "engines": { 7615 + "node": ">=18" 7616 + }, 7617 + "funding": { 7618 + "url": "https://github.com/sponsors/sindresorhus" 7619 + } 7620 + }, 7428 7621 "node_modules/supports-color": { 7429 7622 "version": "10.2.2", 7430 7623 "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.2.2.tgz", ··· 7508 7701 "funding": { 7509 7702 "type": "opencollective", 7510 7703 "url": "https://opencollective.com/webpack" 7704 + } 7705 + }, 7706 + "node_modules/time-span": { 7707 + "version": "5.1.0", 7708 + "resolved": "https://registry.npmjs.org/time-span/-/time-span-5.1.0.tgz", 7709 + "integrity": "sha512-75voc/9G4rDIJleOo4jPvN4/YC4GRZrY8yy1uU4lwrB3XEQbWve8zXoO5No4eFrGcTAMYyoY67p8jRQdtA1HbA==", 7710 + "license": "MIT", 7711 + "dependencies": { 7712 + "convert-hrtime": "^5.0.0" 7713 + }, 7714 + "engines": { 7715 + "node": ">=12" 7716 + }, 7717 + "funding": { 7718 + "url": "https://github.com/sponsors/sindresorhus" 7511 7719 } 7512 7720 }, 7513 7721 "node_modules/tinyglobby": { ··· 7903 8111 "engines": { 7904 8112 "node": "20 || >=22" 7905 8113 } 8114 + }, 8115 + "node_modules/web-worker": { 8116 + "version": "1.5.0", 8117 + "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.5.0.tgz", 8118 + "integrity": "sha512-RiMReJrTAiA+mBjGONMnjVDP2u3p9R1vkcGz6gDIrOMT3oGuYwX2WRMYI9ipkphSuE5XKEhydbhNEJh4NY9mlw==", 8119 + "license": "Apache-2.0" 7906 8120 }, 7907 8121 "node_modules/when-exit": { 7908 8122 "version": "2.1.5",
+2 -1
package.json
··· 49 49 "consola": "^3.4.2", 50 50 "dark-mode": "^5.0.0", 51 51 "es-toolkit": "^1.45.1", 52 - "mac-terminal": "^5.0.0" 52 + "mac-terminal": "^5.0.0", 53 + "ow": "^3.1.1" 53 54 }, 54 55 "devDependencies": { 55 56 "@e18e/eslint-plugin": "^0.3.0",
+5 -1
source/cli/actions/config/set-mode.js
··· 1 1 import {consola} from 'consola'; 2 - import {setTerminalProfile} from 'mac-terminal'; 2 + import {getTerminalProfiles, setTerminalProfile} from 'mac-terminal'; 3 + import ow from 'ow'; 3 4 import {getConfig, getCurrentMode} from '#library'; 4 5 5 6 /** 6 7 * @param {{mode: 'dark' | 'light', profile: string}} parameters 8 + * @throws {import('ow').ArgumentError} 7 9 * @returns {Promise<void>} 8 10 */ 9 11 export default async function setMode({mode, profile}) { 12 + ow(profile, ow.string.oneOf(await getTerminalProfiles())); 13 + 10 14 const config = await getConfig(); 11 15 12 16 config.set(`profiles.${mode}`, profile);
+14 -8
source/cli/commands/config/set-mode.js
··· 1 - import {Argument, Command} from 'commander'; 2 - import {getTerminalProfiles} from 'mac-terminal'; 1 + import {Command} from 'commander'; 2 + import {ArgumentError} from 'ow'; 3 3 import * as actions from '#cli/actions'; 4 4 5 5 /** ··· 10 10 export default function setMode(mode) { 11 11 return new Command(mode) 12 12 .description(`set terminal profile for ${mode}`) 13 - .addArgument( 14 - new Argument('<profile>', 'terminal profile name').choices( 15 - await getTerminalProfiles(), 16 - ), 17 - ) 18 - .action(async (profile) => actions.config.setMode({mode, profile})); 13 + .argument('<profile>', 'terminal profile name') 14 + .action(async function (profile) { 15 + try { 16 + await actions.config.setMode({mode, profile}); 17 + } catch (error) { 18 + if (error instanceof ArgumentError) { 19 + this.error(error.message); 20 + } 21 + 22 + throw error; 23 + } 24 + }); 19 25 }
+12 -2
test/config-set-mode.js
··· 4 4 const consola = {success: mock.fn()}; 5 5 mock.module('consola', {namedExports: {consola}}); 6 6 7 - const macTerminal = {setTerminalProfile: mock.fn()}; 7 + const macTerminal = { 8 + getTerminalProfiles: mock.fn(async () => ['Profile']), 9 + setTerminalProfile: mock.fn(), 10 + }; 8 11 mock.module('mac-terminal', {namedExports: macTerminal}); 9 12 10 13 const config = {set: mock.fn()}; ··· 42 45 43 46 assert.match( 44 47 consola.success.mock.calls[0].arguments[0], 45 - /Saved configuration/v, 48 + /saved configuration/v, 46 49 ); 47 50 }); 48 51 ··· 67 70 await setMode({mode: 'dark', profile: 'Profile'}); 68 71 69 72 assert.equal(macTerminal.setTerminalProfile.mock.callCount(), 0); 73 + }); 74 + 75 + it('throws when profile is not a valid terminal profile', async () => { 76 + await assert.rejects( 77 + setMode({mode: 'dark', profile: 'Nonexistent'}), 78 + {name: 'ArgumentError'}, 79 + ); 70 80 }); 71 81 });