From cb8041c446079990ab05fbf7ea18925ee302d3e2 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 14:05:15 +0100 Subject: [PATCH 01/12] add husky and pretty-quick packages --- package.json | 2 ++ yarn.lock | 76 ++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 136f03fa9c..5abd4aec77 100644 --- a/package.json +++ b/package.json @@ -313,6 +313,7 @@ "gulp": "^4.0.2", "hardhat": "^2.14.0", "https-browserify": "^1.0.0", + "husky": "^8.0.3", "ipfs-http-client": "^47.0.1", "ipfs-mini": "^1.1.5", "is-electron": "^2.2.0", @@ -335,6 +336,7 @@ "nyc": "^13.3.0", "onchange": "^3.2.1", "os-browserify": "^0.3.0", + "pretty-quick": "^3.1.3", "process": "^0.11.10", "react-refresh": "^0.14.0", "react-test-renderer": "^17.0.2", diff --git a/yarn.lock b/yarn.lock index 0cc5034dac..622cfda848 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5754,7 +5754,7 @@ resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10" integrity sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA== -"@types/minimatch@*": +"@types/minimatch@*", "@types/minimatch@^3.0.3": version "3.0.5" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== @@ -7380,6 +7380,11 @@ array-differ@^2.0.3: resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-2.1.0.tgz#4b9c1c3f14b906757082925769e8ab904f4801b1" integrity sha512-KbUpJgx909ZscOc/7CLATBFam7P1Z1QRQInvgT0UztM9Q72aGKCunKASAl7WNW0tnPmPyEMeMhdsfWhfmW037w== +array-differ@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" + integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== + array-each@^1.0.0, array-each@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/array-each/-/array-each-1.0.1.tgz#a794af0c05ab1752846ee753a1f211a05ba0c44f" @@ -7522,6 +7527,11 @@ arrify@^1.0.1, arrify@~1.0.1: resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== +arrify@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa" + integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug== + asap@^2.0.0, asap@~2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.5.tgz#522765b50c3510490e52d7dcfe085ef9ba96958f" @@ -9583,6 +9593,14 @@ chalk@^2.0.0, chalk@^2.3.0, chalk@^2.3.1, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4 escape-string-regexp "^1.0.5" supports-color "^5.3.0" +chalk@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" + integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -10795,7 +10813,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -12855,6 +12873,21 @@ execa@^1.0.0: signal-exit "^3.0.0" strip-eof "^1.0.0" +execa@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a" + integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA== + dependencies: + cross-spawn "^7.0.0" + get-stream "^5.0.0" + human-signals "^1.1.1" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.0" + onetime "^5.1.0" + signal-exit "^3.0.2" + strip-final-newline "^2.0.0" + execa@^5.0.0: version "5.1.1" resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" @@ -14143,7 +14176,7 @@ get-stream@^4.0.0, get-stream@^4.1.0: dependencies: pump "^3.0.0" -get-stream@^5.1.0: +get-stream@^5.0.0, get-stream@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== @@ -15259,6 +15292,11 @@ https-proxy-agent@^5.0.0: agent-base "6" debug "4" +human-signals@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" + integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== + human-signals@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" @@ -15271,6 +15309,11 @@ humanize-ms@^1.2.1: dependencies: ms "^2.0.0" +husky@^8.0.3: + version "8.0.3" + resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" + integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== + hyperscript-attribute-to-property@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/hyperscript-attribute-to-property/-/hyperscript-attribute-to-property-1.0.2.tgz#66ad4164f88beefacf46ec884bd3d1173c1c382a" @@ -19436,7 +19479,7 @@ move-concurrently@^1.0.1, move-concurrently@~1.0.1: rimraf "^2.5.4" run-queue "^1.0.3" -mri@^1.1.0: +mri@^1.1.0, mri@^1.1.5: version "1.2.0" resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b" integrity sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA== @@ -19611,6 +19654,17 @@ multimatch@^3.0.0: arrify "^1.0.1" minimatch "^3.0.4" +multimatch@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-4.0.0.tgz#8c3c0f6e3e8449ada0af3dd29efb491a375191b3" + integrity sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ== + dependencies: + "@types/minimatch" "^3.0.3" + array-differ "^3.0.0" + array-union "^2.1.0" + arrify "^2.0.1" + minimatch "^3.0.4" + murmurhash3js-revisited@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz#6bd36e25de8f73394222adc6e41fa3fac08a5869" @@ -20280,7 +20334,7 @@ npm-run-path@^2.0.0: dependencies: path-key "^2.0.0" -npm-run-path@^4.0.1: +npm-run-path@^4.0.0, npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== @@ -22111,6 +22165,18 @@ pretty-ms@^2.1.0: parse-ms "^1.0.0" plur "^1.0.0" +pretty-quick@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-3.1.3.tgz#15281108c0ddf446675157ca40240099157b638e" + integrity sha512-kOCi2FJabvuh1as9enxYmrnBC6tVMoVOenMaBqRfsvBHB0cbpYHjdQEpSglpASDFEXVwplpcGR4CLEaisYAFcA== + dependencies: + chalk "^3.0.0" + execa "^4.0.0" + find-up "^4.1.0" + ignore "^5.1.4" + mri "^1.1.5" + multimatch "^4.0.0" + private@^0.1.6: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" From 9f3f33f19454d1f884e37cbbe515b581e740552b Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 14:31:20 +0100 Subject: [PATCH 02/12] add prettier config --- .prettierrc.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .prettierrc.json diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000000..eb9e1f1f9e --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,14 @@ +{ + "tabWidth": 2, + "useTabs": false, + "semi": false, + "singleQuote": true, + "quoteProps": "consistent", + "jsxSingleQuote": false, + "bracketSpacing": false, + "trailingComma": "none", + "jsxBracketSameLine": false, + "arrowParens": "always", + "singleAttributePerLine": false, + "ignorePath": ".prettierignore" +} From a65c0d2540d234ebbe5d1bfb9286f980e8a41531 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 14:32:55 +0100 Subject: [PATCH 03/12] add prettierignore file --- .prettierignore | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..e9c70767c5 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,13 @@ +**/.yarn/* + +# Ignore node_modules +./node_modules + +# Ignore e2e files +./apps/remix-ide-e2e/* + +# Ignore build artefacts +./dist + +# Ignore all json files +**/*.json From 9a3b2c21184e92e263d13fb7b1eca61925974e3a Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 14:39:04 +0100 Subject: [PATCH 04/12] add husky precommit and pretty-quick script in package.json --- .husky/pre-commit | 4 ++++ package.json | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..618c2bfbc7 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + + diff --git a/package.json b/package.json index 5abd4aec77..b95b547635 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,8 @@ "watch": "watchify apps/remix-ide/src/index.js -dv -p browserify-reload -o apps/remix-ide/build/app.js --exclude solc", "reinstall": "rm ./node-modules/ -rf && rm yarn.lock && rm ./build/ -rf && yarn install & yarn run build", "ganache-cli": "npx ganache-cli", - "build-contracts": "find ./node_modules/@openzeppelin/contracts | grep -i '.sol' > libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt && find ./node_modules/@uniswap/v3-core/contracts | grep -i '.sol' >> libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt" + "build-contracts": "find ./node_modules/@openzeppelin/contracts | grep -i '.sol' > libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt && find ./node_modules/@uniswap/v3-core/contracts | grep -i '.sol' >> libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt", + "prepare": "husky install" }, "dependencies": { "@babel/plugin-proposal-class-properties": "^7.16.0", @@ -313,7 +314,7 @@ "gulp": "^4.0.2", "hardhat": "^2.14.0", "https-browserify": "^1.0.0", - "husky": "^8.0.3", + "husky": "^8.0.0", "ipfs-http-client": "^47.0.1", "ipfs-mini": "^1.1.5", "is-electron": "^2.2.0", @@ -365,5 +366,10 @@ }, "resolutions": { "@types/react": "^17.0.24" + }, + "husky": { + "hooks": { + "pre-commit": "pretty-quick --staged --pattern \"**/*.{js,jsx,ts,tsx}\"" + } } } From 92bcdb10a154d98eb3e56534bad9bb0b6c26fb66 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 14:42:09 +0100 Subject: [PATCH 05/12] add hustky pretty-quick staged script --- .husky/pre-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 618c2bfbc7..0da96d6baa 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" - +npx pretty-quick --staged From 57d71acebcd2ed7567b95bce148b114bd71713af Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 14:48:41 +0100 Subject: [PATCH 06/12] testing precommit hook --- .../workspace/src/lib/reducers/workspace.ts | 1353 ++++++++++------- 1 file changed, 779 insertions(+), 574 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index a6d82f2885..66170be1d2 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -1,71 +1,71 @@ -import { extractNameFromKey } from '@remix-ui/helper' -import { action, FileType } from '../types' +import {extractNameFromKey} from '@remix-ui/helper' +import {action, FileType} from '../types' import * as _ from 'lodash' -import { fileDecoration } from '@remix-ui/file-decorators' -import { ROOT_PATH } from '../utils/constants' +import {fileDecoration} from '@remix-ui/file-decorators' +import {ROOT_PATH} from '../utils/constants' interface Action { type: string payload: any } export interface BrowserState { browser: { - currentWorkspace: string, + currentWorkspace: string workspaces: { - name: string; - isGitRepo: boolean; + name: string + isGitRepo: boolean branches?: { - remote: any; - name: string; - }[], + remote: any + name: string + }[] currentBranch?: string - }[], - files: { [x: string]: Record }, + }[] + files: {[x: string]: Record} expandPath: string[] - isRequestingDirectory: boolean, - isSuccessfulDirectory: boolean, - isRequestingWorkspace: boolean, - isSuccessfulWorkspace: boolean, - isRequestingCloning: boolean, - isSuccessfulCloning: boolean, - error: string, + isRequestingDirectory: boolean + isSuccessfulDirectory: boolean + isRequestingWorkspace: boolean + isSuccessfulWorkspace: boolean + isRequestingCloning: boolean + isSuccessfulCloning: boolean + error: string contextMenu: { - registeredMenuItems: action[], - removedMenuItems: action[], + registeredMenuItems: action[] + removedMenuItems: action[] error: string - }, + } fileState: fileDecoration[] - }, + } localhost: { - sharedFolder: string, - files: { [x: string]: Record }, - expandPath: string[], - isRequestingDirectory: boolean, - isSuccessfulDirectory: boolean, - isRequestingLocalhost: boolean, - isSuccessfulLocalhost: boolean, - error: string, + sharedFolder: string + files: {[x: string]: Record} + expandPath: string[] + isRequestingDirectory: boolean + isSuccessfulDirectory: boolean + isRequestingLocalhost: boolean + isSuccessfulLocalhost: boolean + error: string contextMenu: { - registeredMenuItems: action[], - removedMenuItems: action[], + registeredMenuItems: action[] + removedMenuItems: action[] error: string - }, + } fileState: [] - }, - mode: 'browser' | 'localhost', + } + mode: 'browser' | 'localhost' notification: { - title: string, - message: string, - actionOk: () => void, - actionCancel: (() => void) | null, - labelOk: string, + title: string + message: string + actionOk: () => void + actionCancel: (() => void) | null + labelOk: string labelCancel: string - }, - readonly: boolean, - popup: string, - focusEdit: string, - focusElement: { key: string, type: 'file' | 'folder' | 'gist' }[], - initializingFS: boolean, - gitConfig: { username: string, email: string, token: string }, + } + readonly: boolean + popup: string + focusEdit: string + focusElement: {key: string; type: 'file' | 'folder' | 'gist'}[] + initializingFS: boolean + gitConfig: {username: string; email: string; token: string} } export const browserInitialState: BrowserState = { @@ -108,8 +108,8 @@ export const browserInitialState: BrowserState = { notification: { title: '', message: '', - actionOk: () => { }, - actionCancel: () => { }, + actionOk: () => {}, + actionCancel: () => {}, labelOk: '', labelCancel: '' }, @@ -118,645 +118,790 @@ export const browserInitialState: BrowserState = { focusEdit: '', focusElement: [], initializingFS: true, - gitConfig: { username: '', email: '', token: '' } + gitConfig: {username: '', email: '', token: ''} } export const browserReducer = (state = browserInitialState, action: Action) => { switch (action.type) { - case 'SET_CURRENT_WORKSPACE': { - const payload = action.payload as { name: string; isGitRepo: boolean; branches?: { remote: any; name: string; }[], currentBranch?: string } - const workspaces = state.browser.workspaces.find(({ name }) => name === payload.name) ? state.browser.workspaces : [...state.browser.workspaces, action.payload] - - return { - ...state, - browser: { - ...state.browser, - currentWorkspace: payload.name, - workspaces: workspaces.filter(workspace => workspace) + case 'SET_CURRENT_WORKSPACE': { + const payload = action.payload as { + name: string + isGitRepo: boolean + branches?: {remote: any; name: string}[] + currentBranch?: string + } + const workspaces = state.browser.workspaces.find( + ({name}) => name === payload.name + ) + ? state.browser.workspaces + : [...state.browser.workspaces, action.payload] + + return { + ...state, + browser: { + ...state.browser, + currentWorkspace: payload.name, + workspaces: workspaces.filter((workspace) => workspace) + } } } - } - case 'SET_WORKSPACES': { - const payload = action.payload as { name: string; isGitRepo: boolean; branches?: { remote: any; name: string; }[], currentBranch?: string }[] - - return { - ...state, - browser: { - ...state.browser, - workspaces: payload.filter(workspace => workspace) + case 'SET_WORKSPACES': { + const payload = action.payload as { + name: string + isGitRepo: boolean + branches?: {remote: any; name: string}[] + currentBranch?: string + }[] + + return { + ...state, + browser: { + ...state.browser, + workspaces: payload.filter((workspace) => workspace) + } } } - } - case 'SET_MODE': { - const payload = action.payload as 'browser' | 'localhost' + case 'SET_MODE': { + const payload = action.payload as 'browser' | 'localhost' - return { - ...state, - mode: payload + return { + ...state, + mode: payload + } } - } - case 'FETCH_DIRECTORY_REQUEST': { - return { - ...state, - browser: { - ...state.browser, - isRequestingDirectory: state.mode === 'browser', - isSuccessfulDirectory: false, - error: null - }, - localhost: { - ...state.localhost, - isRequestingDirectory: state.mode === 'localhost', - isSuccessfulDirectory: false, - error: null + case 'FETCH_DIRECTORY_REQUEST': { + return { + ...state, + browser: { + ...state.browser, + isRequestingDirectory: state.mode === 'browser', + isSuccessfulDirectory: false, + error: null + }, + localhost: { + ...state.localhost, + isRequestingDirectory: state.mode === 'localhost', + isSuccessfulDirectory: false, + error: null + } } } - } - - case 'FETCH_DIRECTORY_SUCCESS': { - const payload = action.payload as { path: string, fileTree } - return { - ...state, - browser: { - ...state.browser, - files: state.mode === 'browser' ? fetchDirectoryContent(state, payload) : state.browser.files, - isRequestingDirectory: false, - isSuccessfulDirectory: true, - error: null - }, - localhost: { - ...state.localhost, - files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload) : state.localhost.files, - isRequestingDirectory: false, - isSuccessfulDirectory: true, - error: null + case 'FETCH_DIRECTORY_SUCCESS': { + const payload = action.payload as {path: string; fileTree} + + return { + ...state, + browser: { + ...state.browser, + files: + state.mode === 'browser' + ? fetchDirectoryContent(state, payload) + : state.browser.files, + isRequestingDirectory: false, + isSuccessfulDirectory: true, + error: null + }, + localhost: { + ...state.localhost, + files: + state.mode === 'localhost' + ? fetchDirectoryContent(state, payload) + : state.localhost.files, + isRequestingDirectory: false, + isSuccessfulDirectory: true, + error: null + } } } - } - case 'FETCH_DIRECTORY_ERROR': { - return { - ...state, - browser: { - ...state.browser, - isRequestingDirectory: false, - isSuccessfulDirectory: false, - error: state.mode === 'browser' ? action.payload : null - }, - localhost: { - ...state.localhost, - isRequestingDirectory: false, - isSuccessfulDirectory: false, - error: state.mode === 'localhost' ? action.payload : null + case 'FETCH_DIRECTORY_ERROR': { + return { + ...state, + browser: { + ...state.browser, + isRequestingDirectory: false, + isSuccessfulDirectory: false, + error: state.mode === 'browser' ? action.payload : null + }, + localhost: { + ...state.localhost, + isRequestingDirectory: false, + isSuccessfulDirectory: false, + error: state.mode === 'localhost' ? action.payload : null + } } } - } - case 'FETCH_WORKSPACE_DIRECTORY_REQUEST': { - return { - ...state, - browser: { - ...state.browser, - isRequestingWorkspace: state.mode === 'browser', - isSuccessfulWorkspace: false, - error: null - }, - localhost: { - ...state.localhost, - isRequestingWorkspace: state.mode === 'localhost', - isSuccessfulWorkspace: false, - error: null + case 'FETCH_WORKSPACE_DIRECTORY_REQUEST': { + return { + ...state, + browser: { + ...state.browser, + isRequestingWorkspace: state.mode === 'browser', + isSuccessfulWorkspace: false, + error: null + }, + localhost: { + ...state.localhost, + isRequestingWorkspace: state.mode === 'localhost', + isSuccessfulWorkspace: false, + error: null + } } } - } - case 'FETCH_WORKSPACE_DIRECTORY_SUCCESS': { - const payload = action.payload as { path: string, fileTree } - - return { - ...state, - browser: { - ...state.browser, - files: state.mode === 'browser' ? fetchWorkspaceDirectoryContent(state, payload) : state.browser.files, - isRequestingWorkspace: false, - isSuccessfulWorkspace: true, - error: null - }, - localhost: { - ...state.localhost, - files: state.mode === 'localhost' ? fetchWorkspaceDirectoryContent(state, payload) : state.localhost.files, - isRequestingWorkspace: false, - isSuccessfulWorkspace: true, - error: null, - sharedFolder: null + case 'FETCH_WORKSPACE_DIRECTORY_SUCCESS': { + const payload = action.payload as {path: string; fileTree} + + return { + ...state, + browser: { + ...state.browser, + files: + state.mode === 'browser' + ? fetchWorkspaceDirectoryContent(state, payload) + : state.browser.files, + isRequestingWorkspace: false, + isSuccessfulWorkspace: true, + error: null + }, + localhost: { + ...state.localhost, + files: + state.mode === 'localhost' + ? fetchWorkspaceDirectoryContent(state, payload) + : state.localhost.files, + isRequestingWorkspace: false, + isSuccessfulWorkspace: true, + error: null, + sharedFolder: null + } } } - } - case 'FETCH_WORKSPACE_DIRECTORY_ERROR': { - return { - ...state, - browser: { - ...state.browser, - isRequestingWorkspace: false, - isSuccessfulWorkspace: false, - error: state.mode === 'browser' ? action.payload : null - }, - localhost: { - ...state.localhost, - isRequestingWorkspace: false, - isSuccessfulWorkspace: false, - error: state.mode === 'localhost' ? action.payload : null + case 'FETCH_WORKSPACE_DIRECTORY_ERROR': { + return { + ...state, + browser: { + ...state.browser, + isRequestingWorkspace: false, + isSuccessfulWorkspace: false, + error: state.mode === 'browser' ? action.payload : null + }, + localhost: { + ...state.localhost, + isRequestingWorkspace: false, + isSuccessfulWorkspace: false, + error: state.mode === 'localhost' ? action.payload : null + } } } - } - case 'DISPLAY_NOTIFICATION': { - const payload = action.payload as { title: string, message: string, actionOk: () => void, actionCancel: () => void, labelOk: string, labelCancel: string } + case 'DISPLAY_NOTIFICATION': { + const payload = action.payload as { + title: string + message: string + actionOk: () => void + actionCancel: () => void + labelOk: string + labelCancel: string + } - return { - ...state, - notification: { - title: payload.title, - message: payload.message, - actionOk: payload.actionOk || browserInitialState.notification.actionOk, - actionCancel: payload.actionCancel || browserInitialState.notification.actionCancel, - labelOk: payload.labelOk, - labelCancel: payload.labelCancel + return { + ...state, + notification: { + title: payload.title, + message: payload.message, + actionOk: + payload.actionOk || browserInitialState.notification.actionOk, + actionCancel: + payload.actionCancel || + browserInitialState.notification.actionCancel, + labelOk: payload.labelOk, + labelCancel: payload.labelCancel + } } } - } - case 'HIDE_NOTIFICATION': { - return { - ...state, - notification: browserInitialState.notification + case 'HIDE_NOTIFICATION': { + return { + ...state, + notification: browserInitialState.notification + } } - } - - case 'FILE_ADDED_SUCCESS': { - const payload = action.payload as string - return { - ...state, - browser: { - ...state.browser, - files: state.mode === 'browser' ? fileAdded(state, payload) : state.browser.files, - expandPath: state.mode === 'browser' ? [...new Set([...state.browser.expandPath, payload])] : state.browser.expandPath - }, - localhost: { - ...state.localhost, - files: state.mode === 'localhost' ? fileAdded(state, payload) : state.localhost.files, - expandPath: state.mode === 'localhost' ? [...new Set([...state.localhost.expandPath, payload])] : state.localhost.expandPath + case 'FILE_ADDED_SUCCESS': { + const payload = action.payload as string + + return { + ...state, + browser: { + ...state.browser, + files: + state.mode === 'browser' + ? fileAdded(state, payload) + : state.browser.files, + expandPath: + state.mode === 'browser' + ? [...new Set([...state.browser.expandPath, payload])] + : state.browser.expandPath + }, + localhost: { + ...state.localhost, + files: + state.mode === 'localhost' + ? fileAdded(state, payload) + : state.localhost.files, + expandPath: + state.mode === 'localhost' + ? [...new Set([...state.localhost.expandPath, payload])] + : state.localhost.expandPath + } } } - } - case 'FOLDER_ADDED_SUCCESS': { - const payload = action.payload as { path: string, folderPath: string, fileTree } + case 'FOLDER_ADDED_SUCCESS': { + const payload = action.payload as { + path: string + folderPath: string + fileTree + } - return { - ...state, - browser: { - ...state.browser, - files: state.mode === 'browser' ? fetchDirectoryContent(state, payload) : state.browser.files, - expandPath: state.mode === 'browser' ? [...new Set([...state.browser.expandPath, payload.folderPath])] : state.browser.expandPath - }, - localhost: { - ...state.localhost, - files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload) : state.localhost.files, - expandPath: state.mode === 'localhost' ? [...new Set([...state.localhost.expandPath, payload.folderPath])] : state.localhost.expandPath + return { + ...state, + browser: { + ...state.browser, + files: + state.mode === 'browser' + ? fetchDirectoryContent(state, payload) + : state.browser.files, + expandPath: + state.mode === 'browser' + ? [...new Set([...state.browser.expandPath, payload.folderPath])] + : state.browser.expandPath + }, + localhost: { + ...state.localhost, + files: + state.mode === 'localhost' + ? fetchDirectoryContent(state, payload) + : state.localhost.files, + expandPath: + state.mode === 'localhost' + ? [ + ...new Set([ + ...state.localhost.expandPath, + payload.folderPath + ]) + ] + : state.localhost.expandPath + } } } - } - - case 'FILE_REMOVED_SUCCESS': { - const payload = action.payload as string - return { - ...state, - browser: { - ...state.browser, - files: state.mode === 'browser' ? fileRemoved(state, payload) : state.browser.files, - expandPath: state.mode === 'browser' ? [...(state.browser.expandPath.filter(path => path !== payload))] : state.browser.expandPath - }, - localhost: { - ...state.localhost, - files: state.mode === 'localhost' ? fileRemoved(state, payload) : state.localhost.files, - expandPath: state.mode === 'localhost' ? [...(state.browser.expandPath.filter(path => path !== payload))] : state.localhost.expandPath + case 'FILE_REMOVED_SUCCESS': { + const payload = action.payload as string + + return { + ...state, + browser: { + ...state.browser, + files: + state.mode === 'browser' + ? fileRemoved(state, payload) + : state.browser.files, + expandPath: + state.mode === 'browser' + ? [...state.browser.expandPath.filter((path) => path !== payload)] + : state.browser.expandPath + }, + localhost: { + ...state.localhost, + files: + state.mode === 'localhost' + ? fileRemoved(state, payload) + : state.localhost.files, + expandPath: + state.mode === 'localhost' + ? [...state.browser.expandPath.filter((path) => path !== payload)] + : state.localhost.expandPath + } } } - } - case 'ROOT_FOLDER_CHANGED': { - const payload = action.payload as string - return { - ...state, - localhost: { - ...state.localhost, - sharedFolder: payload, - files: {} + case 'ROOT_FOLDER_CHANGED': { + const payload = action.payload as string + return { + ...state, + localhost: { + ...state.localhost, + sharedFolder: payload, + files: {} + } } } - } - case 'ADD_INPUT_FIELD': { - const payload = action.payload as { path: string, fileTree, type: 'file' | 'folder' } + case 'ADD_INPUT_FIELD': { + const payload = action.payload as { + path: string + fileTree + type: 'file' | 'folder' + } - return { - ...state, - browser: { - ...state.browser, - files: state.mode === 'browser' ? fetchDirectoryContent(state, payload) : state.browser.files - }, - localhost: { - ...state.localhost, - files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload) : state.localhost.files - }, - focusEdit: payload.path + '/' + 'blank' + return { + ...state, + browser: { + ...state.browser, + files: + state.mode === 'browser' + ? fetchDirectoryContent(state, payload) + : state.browser.files + }, + localhost: { + ...state.localhost, + files: + state.mode === 'localhost' + ? fetchDirectoryContent(state, payload) + : state.localhost.files + }, + focusEdit: payload.path + '/' + 'blank' + } } - } - - case 'REMOVE_INPUT_FIELD': { - const payload = action.payload as { path: string, fileTree } - return { - ...state, - browser: { - ...state.browser, - files: state.mode === 'browser' ? removeInputField(state, payload.path) : state.browser.files - }, - localhost: { - ...state.localhost, - files: state.mode === 'localhost' ? removeInputField(state, payload.path) : state.localhost.files - }, - focusEdit: null + case 'REMOVE_INPUT_FIELD': { + const payload = action.payload as {path: string; fileTree} + + return { + ...state, + browser: { + ...state.browser, + files: + state.mode === 'browser' + ? removeInputField(state, payload.path) + : state.browser.files + }, + localhost: { + ...state.localhost, + files: + state.mode === 'localhost' + ? removeInputField(state, payload.path) + : state.localhost.files + }, + focusEdit: null + } } - } - case 'SET_READ_ONLY_MODE': { - const payload = action.payload as boolean + case 'SET_READ_ONLY_MODE': { + const payload = action.payload as boolean - return { - ...state, - readonly: payload + return { + ...state, + readonly: payload + } } - } - - case 'FILE_RENAMED_SUCCESS': { - const payload = action.payload as { path: string, oldPath: string, fileTree } - return { - ...state, - browser: { - ...state.browser, - files: state.mode === 'browser' ? fetchDirectoryContent(state, payload, payload.oldPath) : state.browser.files - }, - localhost: { - ...state.localhost, - files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload, payload.oldPath) : state.localhost.files + case 'FILE_RENAMED_SUCCESS': { + const payload = action.payload as { + path: string + oldPath: string + fileTree } - } - } - case 'CREATE_WORKSPACE_REQUEST': { - return { - ...state, - browser: { - ...state.browser, - isRequestingWorkspace: true, - isSuccessfulWorkspace: false, - error: null + return { + ...state, + browser: { + ...state.browser, + files: + state.mode === 'browser' + ? fetchDirectoryContent(state, payload, payload.oldPath) + : state.browser.files + }, + localhost: { + ...state.localhost, + files: + state.mode === 'localhost' + ? fetchDirectoryContent(state, payload, payload.oldPath) + : state.localhost.files + } } } - } - case 'CREATE_WORKSPACE_SUCCESS': { - const payload = action.payload as { name: string; isGitRepo: boolean; branches?: { remote: any; name: string; }[], currentBranch?: string } - const workspaces = state.browser.workspaces.find(({ name }) => name === payload.name) ? state.browser.workspaces : [...state.browser.workspaces, action.payload] - - return { - ...state, - browser: { - ...state.browser, - currentWorkspace: payload.name, - workspaces: workspaces.filter(workspace => workspace), - isRequestingWorkspace: false, - isSuccessfulWorkspace: true, - error: null + case 'CREATE_WORKSPACE_REQUEST': { + return { + ...state, + browser: { + ...state.browser, + isRequestingWorkspace: true, + isSuccessfulWorkspace: false, + error: null + } } } - } - case 'CREATE_WORKSPACE_ERROR': { - return { - ...state, - browser: { - ...state.browser, - isRequestingWorkspace: false, - isSuccessfulWorkspace: false, - error: action.payload + case 'CREATE_WORKSPACE_SUCCESS': { + const payload = action.payload as { + name: string + isGitRepo: boolean + branches?: {remote: any; name: string}[] + currentBranch?: string + } + const workspaces = state.browser.workspaces.find( + ({name}) => name === payload.name + ) + ? state.browser.workspaces + : [...state.browser.workspaces, action.payload] + + return { + ...state, + browser: { + ...state.browser, + currentWorkspace: payload.name, + workspaces: workspaces.filter((workspace) => workspace), + isRequestingWorkspace: false, + isSuccessfulWorkspace: true, + error: null + } } } - } - case 'RENAME_WORKSPACE': { - const payload = action.payload as { oldName: string, workspaceName: string } - let renamedWorkspace - const workspaces = state.browser.workspaces.filter(({ name, isGitRepo, branches, currentBranch }) => { - if (name && (name !== payload.oldName)) { - return true - } else { - renamedWorkspace = { - name: payload.workspaceName, - isGitRepo, - branches, - currentBranch + case 'CREATE_WORKSPACE_ERROR': { + return { + ...state, + browser: { + ...state.browser, + isRequestingWorkspace: false, + isSuccessfulWorkspace: false, + error: action.payload } - return false } - }) + } - return { - ...state, - browser: { - ...state.browser, - currentWorkspace: payload.workspaceName, - workspaces: [...workspaces, renamedWorkspace], - expandPath: [] + case 'RENAME_WORKSPACE': { + const payload = action.payload as {oldName: string; workspaceName: string} + let renamedWorkspace + const workspaces = state.browser.workspaces.filter( + ({name, isGitRepo, branches, currentBranch}) => { + if (name && name !== payload.oldName) { + return true + } else { + renamedWorkspace = { + name: payload.workspaceName, + isGitRepo, + branches, + currentBranch + } + return false + } + } + ) + + return { + ...state, + browser: { + ...state.browser, + currentWorkspace: payload.workspaceName, + workspaces: [...workspaces, renamedWorkspace], + expandPath: [] + } } } - } - - case 'DELETE_WORKSPACE': { - const payload = action.payload as string - const workspaces = state.browser.workspaces.filter(({ name }) => name && (name !== payload)) - return { - ...state, - browser: { - ...state.browser, - workspaces: workspaces + case 'DELETE_WORKSPACE': { + const payload = action.payload as string + const workspaces = state.browser.workspaces.filter( + ({name}) => name && name !== payload + ) + + return { + ...state, + browser: { + ...state.browser, + workspaces: workspaces + } } } - } - case 'DISPLAY_POPUP_MESSAGE': { - const payload = action.payload as string + case 'DISPLAY_POPUP_MESSAGE': { + const payload = action.payload as string - return { - ...state, - popup: payload + return { + ...state, + popup: payload + } } - } - case 'HIDE_POPUP_MESSAGE': { - return { - ...state, - popup: '' + case 'HIDE_POPUP_MESSAGE': { + return { + ...state, + popup: '' + } } - } - case 'SET_FOCUS_ELEMENT': { - const payload = action.payload as { key: string, type: 'file' | 'folder' | 'gist' }[] + case 'SET_FOCUS_ELEMENT': { + const payload = action.payload as { + key: string + type: 'file' | 'folder' | 'gist' + }[] - return { - ...state, - focusElement: payload + return { + ...state, + focusElement: payload + } } - } - case 'REMOVE_FOCUS_ELEMENT': { - const payload: string = action.payload + case 'REMOVE_FOCUS_ELEMENT': { + const payload: string = action.payload - return { - ...state, - focusElement: state.focusElement.filter(element => element.key !== payload) + return { + ...state, + focusElement: state.focusElement.filter( + (element) => element.key !== payload + ) + } } - } - case 'SET_CONTEXT_MENU_ITEM': { - const payload = action.payload as action - - return { - ...state, - browser: { - ...state.browser, - contextMenu: addContextMenuItem(state, payload) - }, - localhost: { - ...state.localhost, - contextMenu: addContextMenuItem(state, payload) + case 'SET_CONTEXT_MENU_ITEM': { + const payload = action.payload as action + + return { + ...state, + browser: { + ...state.browser, + contextMenu: addContextMenuItem(state, payload) + }, + localhost: { + ...state.localhost, + contextMenu: addContextMenuItem(state, payload) + } } } - } - - case 'REMOVE_CONTEXT_MENU_ITEM': { - const payload = action.payload - return { - ...state, - browser: { - ...state.browser, - contextMenu: removeContextMenuItem(state, payload) - }, - localhost: { - ...state.localhost, - contextMenu: removeContextMenuItem(state, payload) + case 'REMOVE_CONTEXT_MENU_ITEM': { + const payload = action.payload + + return { + ...state, + browser: { + ...state.browser, + contextMenu: removeContextMenuItem(state, payload) + }, + localhost: { + ...state.localhost, + contextMenu: removeContextMenuItem(state, payload) + } } } - } - - case 'SET_EXPAND_PATH': { - const payload = action.payload as string[] - return { - ...state, - browser: { - ...state.browser, - expandPath: payload - }, - localhost: { - ...state.localhost, - expandPath: payload + case 'SET_EXPAND_PATH': { + const payload = action.payload as string[] + + return { + ...state, + browser: { + ...state.browser, + expandPath: payload + }, + localhost: { + ...state.localhost, + expandPath: payload + } } } - } - case 'LOAD_LOCALHOST_REQUEST': { - return { - ...state, - localhost: { - ...state.localhost, - isRequestingLocalhost: true, - isSuccessfulLocalhost: false, - error: null + case 'LOAD_LOCALHOST_REQUEST': { + return { + ...state, + localhost: { + ...state.localhost, + isRequestingLocalhost: true, + isSuccessfulLocalhost: false, + error: null + } } } - } - case 'LOAD_LOCALHOST_SUCCESS': { - return { - ...state, - localhost: { - ...state.localhost, - isRequestingLocalhost: false, - isSuccessfulLocalhost: true, - error: null + case 'LOAD_LOCALHOST_SUCCESS': { + return { + ...state, + localhost: { + ...state.localhost, + isRequestingLocalhost: false, + isSuccessfulLocalhost: true, + error: null + } } } - } - case 'LOAD_LOCALHOST_ERROR': { - const payload = action.payload as string + case 'LOAD_LOCALHOST_ERROR': { + const payload = action.payload as string - return { - ...state, - localhost: { - ...state.localhost, - isRequestingLocalhost: false, - isSuccessfulLocalhost: false, - error: payload + return { + ...state, + localhost: { + ...state.localhost, + isRequestingLocalhost: false, + isSuccessfulLocalhost: false, + error: payload + } } } - } - case 'CLONE_REPOSITORY_REQUEST': { - return { - ...state, - browser: { - ...state.browser, - isRequestingCloning: true, - isSuccessfulCloning: false + case 'CLONE_REPOSITORY_REQUEST': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: true, + isSuccessfulCloning: false + } } } - } - case 'CLONE_REPOSITORY_SUCCESS': { - return { - ...state, - browser: { - ...state.browser, - isRequestingCloning: false, - isSuccessfulCloning: true + case 'CLONE_REPOSITORY_SUCCESS': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: false, + isSuccessfulCloning: true + } } } - } - case 'CLONE_REPOSITORY_FAILED': { - return { - ...state, - browser: { - ...state.browser, - isRequestingCloning: false, - isSuccessfulCloning: false + case 'CLONE_REPOSITORY_FAILED': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: false, + isSuccessfulCloning: false + } } } - } - case 'FS_INITIALIZATION_COMPLETED': { - return { - ...state, - initializingFS: false + case 'FS_INITIALIZATION_COMPLETED': { + return { + ...state, + initializingFS: false + } } - } - case 'SET_FILE_DECORATION_SUCCESS': { - return { - ...state, - browser: { - ...state.browser, - fileState: action.payload + case 'SET_FILE_DECORATION_SUCCESS': { + return { + ...state, + browser: { + ...state.browser, + fileState: action.payload + } } } - } - case 'SET_CURRENT_WORKSPACE_BRANCHES': { - const payload: { remote: any, name: string }[] = action.payload - - return { - ...state, - browser: { - ...state.browser, - workspaces: state.browser.workspaces.map((workspace) => { - if (workspace.name === state.browser.currentWorkspace) workspace.branches = payload - return workspace - }) + case 'SET_CURRENT_WORKSPACE_BRANCHES': { + const payload: {remote: any; name: string}[] = action.payload + + return { + ...state, + browser: { + ...state.browser, + workspaces: state.browser.workspaces.map((workspace) => { + if (workspace.name === state.browser.currentWorkspace) + workspace.branches = payload + return workspace + }) + } } } - } - - case 'SET_CURRENT_WORKSPACE_CURRENT_BRANCH': { - const payload: string = action.payload - return { - ...state, - browser: { - ...state.browser, - workspaces: state.browser.workspaces.map((workspace) => { - if (workspace.name === state.browser.currentWorkspace) workspace.currentBranch = payload - return workspace - }) + case 'SET_CURRENT_WORKSPACE_CURRENT_BRANCH': { + const payload: string = action.payload + + return { + ...state, + browser: { + ...state.browser, + workspaces: state.browser.workspaces.map((workspace) => { + if (workspace.name === state.browser.currentWorkspace) + workspace.currentBranch = payload + return workspace + }) + } } } - } - - case 'SET_CURRENT_WORKSPACE_IS_GITREPO': { - const payload: boolean = action.payload - return { - ...state, - browser: { - ...state.browser, - workspaces: state.browser.workspaces.map((workspace) => { - if (workspace.name === state.browser.currentWorkspace) workspace.isGitRepo = payload - return workspace - }) + case 'SET_CURRENT_WORKSPACE_IS_GITREPO': { + const payload: boolean = action.payload + + return { + ...state, + browser: { + ...state.browser, + workspaces: state.browser.workspaces.map((workspace) => { + if (workspace.name === state.browser.currentWorkspace) + workspace.isGitRepo = payload + return workspace + }) + } } } - } - case 'SET_GIT_CONFIG' : { - const payload: { username: string, token: string, email: string } = action.payload - return { - ...state, - gitConfig: payload + case 'SET_GIT_CONFIG': { + const payload: {username: string; token: string; email: string} = + action.payload + return { + ...state, + gitConfig: payload + } } - } - - default: - throw new Error() + default: + throw new Error() } } -const fileAdded = (state: BrowserState, path: string): { [x: string]: Record } => { - let files = state.mode === 'browser' ? state.browser.files : state.localhost.files +const fileAdded = ( + state: BrowserState, + path: string +): {[x: string]: Record} => { + let files = + state.mode === 'browser' ? state.browser.files : state.localhost.files const _path = splitPath(state, path) - files = _.setWith(files, _path, { - path: path, - name: extractNameFromKey(path), - isDirectory: false, - type: 'file' - }, Object) + files = _.setWith( + files, + _path, + { + path: path, + name: extractNameFromKey(path), + isDirectory: false, + type: 'file' + }, + Object + ) return files } -const fileRemoved = (state: BrowserState, path: string): { [x: string]: Record } => { - const files = state.mode === 'browser' ? state.browser.files : state.localhost.files +const fileRemoved = ( + state: BrowserState, + path: string +): {[x: string]: Record} => { + const files = + state.mode === 'browser' ? state.browser.files : state.localhost.files const _path = splitPath(state, path) _.unset(files, _path) return files } -const removeInputField = (state: BrowserState, path: string): { [x: string]: Record } => { - let files = state.mode === 'browser' ? state.browser.files : state.localhost.files +const removeInputField = ( + state: BrowserState, + path: string +): {[x: string]: Record} => { + let files = + state.mode === 'browser' ? state.browser.files : state.localhost.files const root = state.mode === 'browser' ? ROOT_PATH : state.mode if (path === root) { @@ -767,35 +912,51 @@ const removeInputField = (state: BrowserState, path: string): { [x: string]: Rec const prevFiles = _.get(files, _path) if (prevFiles) { - prevFiles.child && prevFiles.child[path + '/' + 'blank'] && delete prevFiles.child[path + '/' + 'blank'] - files = _.setWith(files, _path, { - isDirectory: true, - path, - name: extractNameFromKey(path), - type: extractNameFromKey(path).indexOf('gist-') === 0 ? 'gist' : 'folder', - child: prevFiles ? prevFiles.child : {} - }, Object) + prevFiles.child && + prevFiles.child[path + '/' + 'blank'] && + delete prevFiles.child[path + '/' + 'blank'] + files = _.setWith( + files, + _path, + { + isDirectory: true, + path, + name: extractNameFromKey(path), + type: + extractNameFromKey(path).indexOf('gist-') === 0 ? 'gist' : 'folder', + child: prevFiles ? prevFiles.child : {} + }, + Object + ) } return files } // IDEA: Modify function to remove blank input field without fetching content -const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: string, type?: 'file' | 'folder' }, deletePath?: string): { [x: string]: Record } => { - if (!payload.fileTree) return state.mode === 'browser' ? state.browser.files : state[state.mode].files +const fetchDirectoryContent = ( + state: BrowserState, + payload: {fileTree; path: string; type?: 'file' | 'folder'}, + deletePath?: string +): {[x: string]: Record} => { + if (!payload.fileTree) + return state.mode === 'browser' + ? state.browser.files + : state[state.mode].files if (state.mode === 'browser') { if (payload.path === ROOT_PATH) { let files = normalize(payload.fileTree, ROOT_PATH, payload.type) files = _.merge(files, state.browser.files[ROOT_PATH]) if (deletePath) delete files[deletePath] - return { [ROOT_PATH]: files } + return {[ROOT_PATH]: files} } else { let files = state.browser.files const _path = splitPath(state, payload.path) let prevFiles = _.get(files, _path) if (!prevFiles) { - const object = {}; let o = object + const object = {} + let o = object for (const pa of _path) { o = o[pa] = {} } @@ -804,7 +965,10 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s } if (prevFiles) { - prevFiles.child = _.merge(normalize(payload.fileTree, payload.path, payload.type), prevFiles.child) + prevFiles.child = _.merge( + normalize(payload.fileTree, payload.path, payload.type), + prevFiles.child + ) if (deletePath) { if (deletePath.endsWith('/blank')) delete prevFiles.child[deletePath] else { @@ -814,7 +978,13 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s } files = _.setWith(files, _path, prevFiles, Object) } else if (payload.fileTree && payload.path) { - files = { [payload.path]: normalize(payload.fileTree, payload.path, payload.type) } + files = { + [payload.path]: normalize( + payload.fileTree, + payload.path, + payload.type + ) + } } return files } @@ -823,14 +993,17 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s let files = normalize(payload.fileTree, ROOT_PATH, payload.type) files = _.merge(files, state.localhost.files[ROOT_PATH]) if (deletePath) delete files[deletePath] - return { [ROOT_PATH]: files } + return {[ROOT_PATH]: files} } else { let files = state.localhost.files const _path = splitPath(state, payload.path) const prevFiles = _.get(files, _path) if (prevFiles) { - prevFiles.child = _.merge(normalize(payload.fileTree, payload.path, payload.type), prevFiles.child) + prevFiles.child = _.merge( + normalize(payload.fileTree, payload.path, payload.type), + prevFiles.child + ) if (deletePath) { if (deletePath.endsWith('/blank')) delete prevFiles.child[deletePath] else { @@ -840,24 +1013,37 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s } files = _.setWith(files, _path, prevFiles, Object) } else { - files = { [payload.path]: normalize(payload.fileTree, payload.path, payload.type) } + files = { + [payload.path]: normalize( + payload.fileTree, + payload.path, + payload.type + ) + } } return files } } } -const fetchWorkspaceDirectoryContent = (state: BrowserState, payload: { fileTree, path: string }): { [x: string]: Record } => { +const fetchWorkspaceDirectoryContent = ( + state: BrowserState, + payload: {fileTree; path: string} +): {[x: string]: Record} => { const files = normalize(payload.fileTree, ROOT_PATH) - return { [ROOT_PATH]: files } + return {[ROOT_PATH]: files} } -const normalize = (filesList, directory?: string, newInputType?: 'folder' | 'file'): Record => { +const normalize = ( + filesList, + directory?: string, + newInputType?: 'folder' | 'file' +): Record => { const folders = {} const files = {} - Object.keys(filesList || {}).forEach(key => { + Object.keys(filesList || {}).forEach((key) => { key = key.replace(/^\/|\/$/g, '') // remove first and last slash let path = key path = path.replace(/^\/|\/$/g, '') // remove first and last slash @@ -867,7 +1053,8 @@ const normalize = (filesList, directory?: string, newInputType?: 'folder' | 'fil path, name: extractNameFromKey(path), isDirectory: filesList[key].isDirectory, - type: extractNameFromKey(path).indexOf('gist-') === 0 ? 'gist' : 'folder' + type: + extractNameFromKey(path).indexOf('gist-') === 0 ? 'gist' : 'folder' } } else { files[extractNameFromKey(key)] = { @@ -904,24 +1091,35 @@ const normalize = (filesList, directory?: string, newInputType?: 'folder' | 'fil const splitPath = (state: BrowserState, path: string): string[] | string => { const root = ROOT_PATH - const pathArr: string[] = (path || '').split('/').filter(value => value) + const pathArr: string[] = (path || '').split('/').filter((value) => value) if (pathArr[0] !== root) pathArr.unshift(root) - const _path = pathArr.map((key, index) => index > 1 ? ['child', key] : key).reduce((acc: string[], cur) => { - return Array.isArray(cur) ? [...acc, ...cur] : [...acc, cur] - }, []) + const _path = pathArr + .map((key, index) => (index > 1 ? ['child', key] : key)) + .reduce((acc: string[], cur) => { + return Array.isArray(cur) ? [...acc, ...cur] : [...acc, cur] + }, []) return _path } -const addContextMenuItem = (state: BrowserState, item: action): { registeredMenuItems: action[], removedMenuItems: action[], error: string } => { +const addContextMenuItem = ( + state: BrowserState, + item: action +): { + registeredMenuItems: action[] + removedMenuItems: action[] + error: string +} => { let registeredItems = state[state.mode].contextMenu.registeredMenuItems let removedItems = state[state.mode].contextMenu.removedMenuItems let error = null - if (registeredItems.filter((o) => { - return o.id === item.id && o.name === item.name - }).length) { + if ( + registeredItems.filter((o) => { + return o.id === item.id && o.name === item.name + }).length + ) { error = `Action ${item.name} already exists on ${item.id}` return { registeredMenuItems: registeredItems, @@ -930,7 +1128,7 @@ const addContextMenuItem = (state: BrowserState, item: action): { registeredMenu } } registeredItems = [...registeredItems, item] - removedItems = removedItems.filter(menuItem => item.id !== menuItem.id) + removedItems = removedItems.filter((menuItem) => item.id !== menuItem.id) return { registeredMenuItems: registeredItems, removedMenuItems: removedItems, @@ -938,7 +1136,14 @@ const addContextMenuItem = (state: BrowserState, item: action): { registeredMenu } } -const removeContextMenuItem = (state: BrowserState, plugin): { registeredMenuItems: action[], removedMenuItems: action[], error: string } => { +const removeContextMenuItem = ( + state: BrowserState, + plugin +): { + registeredMenuItems: action[] + removedMenuItems: action[] + error: string +} => { let registeredItems = state[state.mode].contextMenu.registeredMenuItems const removedItems = state[state.mode].contextMenu.removedMenuItems const error = null From e8c1c55ac9ba0d037a1b356cf89091f51ddbbb10 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 15:04:11 +0100 Subject: [PATCH 07/12] testing formatting of workspace.ts --- libs/remix-ui/workspace/src/lib/reducers/workspace.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index 66170be1d2..936ec12e4d 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -1065,6 +1065,7 @@ const normalize = ( } } }) + // do sorting here. if (newInputType === 'folder') { const path = directory + '/blank' From f0a4eaf6feb68b6232b9fb3597311614e0d04314 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 15:26:02 +0100 Subject: [PATCH 08/12] remove pretty-quick and install lint-staged --- package.json | 2 +- yarn.lock | 322 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 254 insertions(+), 70 deletions(-) diff --git a/package.json b/package.json index b95b547635..986cd4295a 100644 --- a/package.json +++ b/package.json @@ -322,6 +322,7 @@ "js-base64": "^2.1.9", "js-beautify": "1.6.14", "lerna": "^3.22.1", + "lint-staged": "^13.2.3", "minixhr": "^4.0.0", "mkdirp": "^0.5.1", "mocha": "^8.0.1", @@ -337,7 +338,6 @@ "nyc": "^13.3.0", "onchange": "^3.2.1", "os-browserify": "^0.3.0", - "pretty-quick": "^3.1.3", "process": "^0.11.10", "react-refresh": "^0.14.0", "react-test-renderer": "^17.0.2", diff --git a/yarn.lock b/yarn.lock index 622cfda848..acfcdec195 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5754,7 +5754,7 @@ resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10" integrity sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA== -"@types/minimatch@*", "@types/minimatch@^3.0.3": +"@types/minimatch@*": version "3.0.5" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== @@ -7170,6 +7170,11 @@ ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== + ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" @@ -7194,6 +7199,11 @@ ansi-styles@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== +ansi-styles@^6.0.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== + ansi-to-html@^0.7.2: version "0.7.2" resolved "https://registry.yarnpkg.com/ansi-to-html/-/ansi-to-html-0.7.2.tgz#a92c149e4184b571eb29a0135ca001a8e2d710cb" @@ -7380,11 +7390,6 @@ array-differ@^2.0.3: resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-2.1.0.tgz#4b9c1c3f14b906757082925769e8ab904f4801b1" integrity sha512-KbUpJgx909ZscOc/7CLATBFam7P1Z1QRQInvgT0UztM9Q72aGKCunKASAl7WNW0tnPmPyEMeMhdsfWhfmW037w== -array-differ@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" - integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== - array-each@^1.0.0, array-each@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/array-each/-/array-each-1.0.1.tgz#a794af0c05ab1752846ee753a1f211a05ba0c44f" @@ -7527,11 +7532,6 @@ arrify@^1.0.1, arrify@~1.0.1: resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== -arrify@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa" - integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug== - asap@^2.0.0, asap@~2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.5.tgz#522765b50c3510490e52d7dcfe085ef9ba96958f" @@ -7590,6 +7590,11 @@ ast-types-flow@^0.0.7: resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad" integrity sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag== +astral-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" + integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== + async-done@^1.2.0, async-done@^1.2.2: version "1.3.2" resolved "https://registry.yarnpkg.com/async-done/-/async-done-1.3.2.tgz#5e15aa729962a4b07414f528a88cdf18e0b290a2" @@ -8822,7 +8827,7 @@ braces@^2.3.1, braces@^2.3.2: split-string "^3.0.2" to-regex "^3.0.1" -braces@^3.0.1, braces@~3.0.2: +braces@^3.0.1, braces@^3.0.2, braces@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== @@ -9573,6 +9578,11 @@ chai@^4.3.7: pathval "^1.1.1" type-detect "^4.0.5" +chalk@5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.2.0.tgz#249623b7d66869c673699fb66d65723e54dfcfb3" + integrity sha512-ree3Gqw/nazQAPuJJEy+avdl7QfZMcUvmHIKgEZkGL+xOBzRvup5Hxo6LHuMceSxOabuJLJm5Yp/92R9eMmMvA== + chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" @@ -9593,14 +9603,6 @@ chalk@^2.0.0, chalk@^2.3.0, chalk@^2.3.1, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4 escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" - integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -9914,6 +9916,22 @@ cli-table@^0.3.1: dependencies: colors "1.0.3" +cli-truncate@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-2.1.0.tgz#c39e28bf05edcde5be3b98992a22deed5a2b93c7" + integrity sha512-n8fOixwDD6b/ObinzTrp1ZKFzbgvKZvuz/TvejnLn1aQfC6r52XEx85FmuC+3HI+JM7coBRXUvNqEU2PHVrHpg== + dependencies: + slice-ansi "^3.0.0" + string-width "^4.2.0" + +cli-truncate@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-3.1.0.tgz#3f23ab12535e3d73e839bb43e73c9de487db1389" + integrity sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA== + dependencies: + slice-ansi "^5.0.0" + string-width "^5.0.0" + cli-usage@^0.1.1: version "0.1.10" resolved "https://registry.yarnpkg.com/cli-usage/-/cli-usage-0.1.10.tgz#2c9d30a3824b48d161580a8f8d5dfe53d66b00d2" @@ -10140,6 +10158,11 @@ colorette@^2.0.10, colorette@^2.0.14: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.19.tgz#cdf044f47ad41a0f4b56b3a0d5b4e6e1a2d5a798" integrity sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ== +colorette@^2.0.19: + version "2.0.20" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" + integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== + colors-browserify@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/colors-browserify/-/colors-browserify-0.1.1.tgz#286cc80fb00d62a1271f99045ee07d031a9acb76" @@ -10217,6 +10240,11 @@ commander@3.0.2: resolved "https://registry.yarnpkg.com/commander/-/commander-3.0.2.tgz#6837c3fb677ad9933d1cfba42dd14d5117d6b39e" integrity sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow== +commander@^10.0.0: + version "10.0.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" + integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug== + commander@^2.12.1, commander@^2.15.0, commander@^2.20.0, commander@^2.20.3, commander@^2.9.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" @@ -10813,7 +10841,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -11905,6 +11933,11 @@ each-props@^1.3.2: is-plain-object "^2.0.1" object.defaults "^1.1.0" +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + ecc-jsbn@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" @@ -12873,21 +12906,6 @@ execa@^1.0.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -execa@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a" - integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA== - dependencies: - cross-spawn "^7.0.0" - get-stream "^5.0.0" - human-signals "^1.1.1" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.0" - onetime "^5.1.0" - signal-exit "^3.0.2" - strip-final-newline "^2.0.0" - execa@^5.0.0: version "5.1.1" resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" @@ -12903,6 +12921,21 @@ execa@^5.0.0: signal-exit "^3.0.3" strip-final-newline "^2.0.0" +execa@^7.0.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-7.2.0.tgz#657e75ba984f42a70f38928cedc87d6f2d4fe4e9" + integrity sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.1" + human-signals "^4.3.0" + is-stream "^3.0.0" + merge-stream "^2.0.0" + npm-run-path "^5.1.0" + onetime "^6.0.0" + signal-exit "^3.0.7" + strip-final-newline "^3.0.0" + execr@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/execr/-/execr-1.0.1.tgz#79865e89a940f56f72be2dd6656ffffd7f2b7c8b" @@ -14176,7 +14209,7 @@ get-stream@^4.0.0, get-stream@^4.1.0: dependencies: pump "^3.0.0" -get-stream@^5.0.0, get-stream@^5.1.0: +get-stream@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== @@ -15292,16 +15325,16 @@ https-proxy-agent@^5.0.0: agent-base "6" debug "4" -human-signals@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" - integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== - human-signals@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +human-signals@^4.3.0: + version "4.3.1" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-4.3.1.tgz#ab7f811e851fca97ffbd2c1fe9a958964de321b2" + integrity sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ== + humanize-ms@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" @@ -15309,7 +15342,7 @@ humanize-ms@^1.2.1: dependencies: ms "^2.0.0" -husky@^8.0.3: +husky@^8.0.0: version "8.0.3" resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== @@ -16055,6 +16088,11 @@ is-fullwidth-code-point@^3.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== +is-fullwidth-code-point@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz#fae3167c729e7463f8461ce512b080a49268aa88" + integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== + is-function@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.2.tgz#4f097f30abf6efadac9833b17ca5dc03f8144e08" @@ -16314,6 +16352,11 @@ is-stream@^2.0.0: resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== +is-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-3.0.0.tgz#e6bfd7aa6bef69f4f472ce9bb681e3e57b4319ac" + integrity sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA== + is-string@^1.0.5, is-string@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.7.tgz#0dd12bf2006f255bb58f695110eff7491eebc0fd" @@ -17712,6 +17755,11 @@ lightercollective@^0.1.0: resolved "https://registry.yarnpkg.com/lightercollective/-/lightercollective-0.1.0.tgz#70df102c530dcb8d0ccabfe6175a8d00d5f61300" integrity sha512-J9tg5uraYoQKaWbmrzDDexbG6hHnMcWS1qLYgJSWE+mpA3U5OCSeMUhb+K55otgZJ34oFdR0ECvdIb3xuO5JOQ== +lilconfig@2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.1.0.tgz#78e23ac89ebb7e1bfbf25b18043de756548e7f52" + integrity sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ== + lilconfig@^2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.4.tgz#f4507d043d7058b380b6a8f5cb7bcd4b34cee082" @@ -17732,6 +17780,39 @@ lines-and-columns@~2.0.3: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-2.0.3.tgz#b2f0badedb556b747020ab8ea7f0373e22efac1b" integrity sha512-cNOjgCnLB+FnvWWtyRTzmB3POJ+cXxTA81LoW7u8JdmhfXzriropYwpjShnz1QLLWsQwY7nIxoDmcPTwphDK9w== +lint-staged@^13.2.3: + version "13.2.3" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-13.2.3.tgz#f899aad6c093473467e9c9e316e3c2d8a28f87a7" + integrity sha512-zVVEXLuQIhr1Y7R7YAWx4TZLdvuzk7DnmrsTNL0fax6Z3jrpFcas+vKbzxhhvp6TA55m1SQuWkpzI1qbfDZbAg== + dependencies: + chalk "5.2.0" + cli-truncate "^3.1.0" + commander "^10.0.0" + debug "^4.3.4" + execa "^7.0.0" + lilconfig "2.1.0" + listr2 "^5.0.7" + micromatch "^4.0.5" + normalize-path "^3.0.0" + object-inspect "^1.12.3" + pidtree "^0.6.0" + string-argv "^0.3.1" + yaml "^2.2.2" + +listr2@^5.0.7: + version "5.0.8" + resolved "https://registry.yarnpkg.com/listr2/-/listr2-5.0.8.tgz#a9379ffeb4bd83a68931a65fb223a11510d6ba23" + integrity sha512-mC73LitKHj9w6v30nLNGPetZIlfpUniNSsxxrbaPcWOjDb92SHPzJPi/t+v1YC/lxKz/AJ9egOjww0qUuFxBpA== + dependencies: + cli-truncate "^2.1.0" + colorette "^2.0.19" + log-update "^4.0.0" + p-map "^4.0.0" + rfdc "^1.3.0" + rxjs "^7.8.0" + through "^2.3.8" + wrap-ansi "^7.0.0" + lit-element@^3.3.0: version "3.3.2" resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-3.3.2.tgz#9913bf220b85065f0e5f1bb8878cc44f36b50cfa" @@ -18107,6 +18188,16 @@ log-symbols@4.1.0, log-symbols@^4.1.0: chalk "^4.1.0" is-unicode-supported "^0.1.0" +log-update@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/log-update/-/log-update-4.0.0.tgz#589ecd352471f2a1c0c570287543a64dfd20e0a1" + integrity sha512-9fkkDevMefjg0mmzWFBW8YkFP91OrizzkW3diF7CpG+S2EYdy4+TVfGwz1zeF8x7hCx1ovSPTOE9Ngib74qqUg== + dependencies: + ansi-escapes "^4.3.0" + cli-cursor "^3.1.0" + slice-ansi "^4.0.0" + wrap-ansi "^6.2.0" + logform@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/logform/-/logform-2.3.0.tgz#a3997a05985de2ebd325ae0d166dffc9c6fe6b57" @@ -19016,6 +19107,14 @@ micromatch@^4.0.0, micromatch@^4.0.2, micromatch@^4.0.4: braces "^3.0.1" picomatch "^2.2.3" +micromatch@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + miller-rabin@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" @@ -19056,6 +19155,11 @@ mimic-fn@^2.0.0, mimic-fn@^2.1.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== +mimic-fn@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-4.0.0.tgz#60a90550d5cb0b239cca65d893b1a53b29871ecc" + integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw== + mimic-response@^1.0.0, mimic-response@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" @@ -19479,7 +19583,7 @@ move-concurrently@^1.0.1, move-concurrently@~1.0.1: rimraf "^2.5.4" run-queue "^1.0.3" -mri@^1.1.0, mri@^1.1.5: +mri@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b" integrity sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA== @@ -19654,17 +19758,6 @@ multimatch@^3.0.0: arrify "^1.0.1" minimatch "^3.0.4" -multimatch@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-4.0.0.tgz#8c3c0f6e3e8449ada0af3dd29efb491a375191b3" - integrity sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ== - dependencies: - "@types/minimatch" "^3.0.3" - array-differ "^3.0.0" - array-union "^2.1.0" - arrify "^2.0.1" - minimatch "^3.0.4" - murmurhash3js-revisited@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz#6bd36e25de8f73394222adc6e41fa3fac08a5869" @@ -20334,13 +20427,20 @@ npm-run-path@^2.0.0: dependencies: path-key "^2.0.0" -npm-run-path@^4.0.0, npm-run-path@^4.0.1: +npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== dependencies: path-key "^3.0.0" +npm-run-path@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-5.1.0.tgz#bc62f7f3f6952d9894bd08944ba011a6ee7b7e00" + integrity sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q== + dependencies: + path-key "^4.0.0" + npm-user-validate@~0.1.5: version "0.1.5" resolved "https://registry.yarnpkg.com/npm-user-validate/-/npm-user-validate-0.1.5.tgz#52465d50c2d20294a57125b996baedbf56c5004b" @@ -20646,6 +20746,11 @@ object-inspect@^1.12.2, object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.2.tgz#c0641f26394532f28ab8d796ab954e43c009a8ea" integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== +object-inspect@^1.12.3: + version "1.12.3" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" + integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== + object-is@^1.0.1, object-is@^1.1.4: version "1.1.5" resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" @@ -20863,6 +20968,13 @@ onetime@^5.1.0, onetime@^5.1.2: dependencies: mimic-fn "^2.1.0" +onetime@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-6.0.0.tgz#7c24c18ed1fd2e9bca4bd26806a33613c77d34b4" + integrity sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ== + dependencies: + mimic-fn "^4.0.0" + open@^8.0.9, open@^8.4.0: version "8.4.0" resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8" @@ -21473,6 +21585,11 @@ path-key@^3.0.0, path-key@^3.1.0: resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== +path-key@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-4.0.0.tgz#295588dc3aee64154f877adb9d780b81c554bf18" + integrity sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ== + path-parse@^1.0.6, path-parse@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" @@ -21562,7 +21679,7 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972" integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw== -picomatch@^2.2.2: +picomatch@^2.2.2, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -21572,6 +21689,11 @@ pidtree@^0.3.0: resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.3.1.tgz#ef09ac2cc0533df1f3250ccf2c4d366b0d12114a" integrity sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA== +pidtree@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.6.0.tgz#90ad7b6d42d5841e69e0a2419ef38f8883aa057c" + integrity sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g== + pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" @@ -22165,18 +22287,6 @@ pretty-ms@^2.1.0: parse-ms "^1.0.0" plur "^1.0.0" -pretty-quick@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-3.1.3.tgz#15281108c0ddf446675157ca40240099157b638e" - integrity sha512-kOCi2FJabvuh1as9enxYmrnBC6tVMoVOenMaBqRfsvBHB0cbpYHjdQEpSglpASDFEXVwplpcGR4CLEaisYAFcA== - dependencies: - chalk "^3.0.0" - execa "^4.0.0" - find-up "^4.1.0" - ignore "^5.1.4" - mri "^1.1.5" - multimatch "^4.0.0" - private@^0.1.6: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -23755,6 +23865,11 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== +rfdc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" + integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== + rgbcolor@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/rgbcolor/-/rgbcolor-1.0.1.tgz#d6505ecdb304a6595da26fa4b43307306775945d" @@ -23943,6 +24058,13 @@ rxjs@^6.4.0, rxjs@^6.5.4, rxjs@^6.6.3: dependencies: tslib "^1.9.0" +rxjs@^7.8.0: + version "7.8.1" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543" + integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg== + dependencies: + tslib "^2.1.0" + sade@^1.7.3: version "1.8.1" resolved "https://registry.yarnpkg.com/sade/-/sade-1.8.1.tgz#0a78e81d658d394887be57d2a409bf703a3b2701" @@ -24509,6 +24631,32 @@ slash@^4.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-4.0.0.tgz#2422372176c4c6c5addb5e2ada885af984b396a7" integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew== +slice-ansi@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-3.0.0.tgz#31ddc10930a1b7e0b67b08c96c2f49b77a789787" + integrity sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ== + dependencies: + ansi-styles "^4.0.0" + astral-regex "^2.0.0" + is-fullwidth-code-point "^3.0.0" + +slice-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b" + integrity sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ== + dependencies: + ansi-styles "^4.0.0" + astral-regex "^2.0.0" + is-fullwidth-code-point "^3.0.0" + +slice-ansi@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-5.0.0.tgz#b73063c57aa96f9cd881654b15294d95d285c42a" + integrity sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ== + dependencies: + ansi-styles "^6.0.0" + is-fullwidth-code-point "^4.0.0" + slide@^1.1.3, slide@^1.1.5, slide@^1.1.6, slide@~1.1.3, slide@~1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" @@ -25065,6 +25213,11 @@ strict-uri-encode@^2.0.0: resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ== +string-argv@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.2.tgz#2b6d0ef24b656274d957d54e0a4bbf6153dc02b6" + integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q== + string-hash@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/string-hash/-/string-hash-1.1.3.tgz#e8aafc0ac1855b4666929ed7dd1275df5d6c811b" @@ -25118,6 +25271,15 @@ string-width@^3.0.0, string-width@^3.1.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" +string-width@^5.0.0: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" + string.prototype.matchall@^4.0.7: version "4.0.7" resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.7.tgz#8e6ecb0d8a1fb1fda470d81acecb2dba057a481d" @@ -25243,6 +25405,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== + dependencies: + ansi-regex "^6.0.1" + strip-bom@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" @@ -25270,6 +25439,11 @@ strip-final-newline@^2.0.0: resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== +strip-final-newline@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-3.0.0.tgz#52894c313fbff318835280aed60ff71ebf12b8fd" + integrity sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw== + strip-hex-prefix@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz#0c5f155fef1151373377de9dbb588da05500e36f" @@ -26129,6 +26303,11 @@ tslib@^2.0.3, tslib@^2.3.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== +tslib@^2.1.0: + version "2.6.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410" + integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig== + tslint@~6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/tslint/-/tslint-6.0.0.tgz#1c0148beac4779924216302f192cdaa153618310" @@ -27969,6 +28148,11 @@ yaml@^1.10.0, yaml@^1.10.2, yaml@^1.7.2: resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== +yaml@^2.2.2: + version "2.3.1" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.1.tgz#02fe0975d23cd441242aa7204e09fc28ac2ac33b" + integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ== + yargs-parser@20.2.4, yargs-parser@^20.2.2: version "20.2.4" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" From 34a261aaa53280daf84352bb1e4c35ecbd825fb7 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 15:26:14 +0100 Subject: [PATCH 09/12] remove redundant script --- .husky/pre-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 0da96d6baa..14aa362cd9 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npx pretty-quick --staged +#npx pretty-quick --staged From d61a736651c2a7067bc607030042b4e18747e667 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 15:50:49 +0100 Subject: [PATCH 10/12] switched over to lint-staged --- .husky/pre-commit | 2 +- .lintstagedrc.json | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .lintstagedrc.json diff --git a/.husky/pre-commit b/.husky/pre-commit index 14aa362cd9..5a182ef106 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -#npx pretty-quick --staged +yarn lint-staged diff --git a/.lintstagedrc.json b/.lintstagedrc.json new file mode 100644 index 0000000000..2bb8f13b60 --- /dev/null +++ b/.lintstagedrc.json @@ -0,0 +1,3 @@ +{ + "*.{tsx,ts,js,jsx,mjs,cjs}": ["prettier --write","eslint --fix"] +} From e82887bc202706ba428bcc8f5a87174adc46797c Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 2 Aug 2023 15:52:55 +0100 Subject: [PATCH 11/12] test --- .../workspace/src/lib/reducers/workspace.ts | 983 +++++++++--------- 1 file changed, 491 insertions(+), 492 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index 936ec12e4d..1058dfb8a4 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -123,186 +123,186 @@ export const browserInitialState: BrowserState = { export const browserReducer = (state = browserInitialState, action: Action) => { switch (action.type) { - case 'SET_CURRENT_WORKSPACE': { - const payload = action.payload as { + case 'SET_CURRENT_WORKSPACE': { + const payload = action.payload as { name: string isGitRepo: boolean branches?: {remote: any; name: string}[] currentBranch?: string } - const workspaces = state.browser.workspaces.find( - ({name}) => name === payload.name - ) - ? state.browser.workspaces - : [...state.browser.workspaces, action.payload] - - return { - ...state, - browser: { - ...state.browser, - currentWorkspace: payload.name, - workspaces: workspaces.filter((workspace) => workspace) - } + const workspaces = state.browser.workspaces.find( + ({name}) => name === payload.name + ) + ? state.browser.workspaces + : [...state.browser.workspaces, action.payload] + + return { + ...state, + browser: { + ...state.browser, + currentWorkspace: payload.name, + workspaces: workspaces.filter((workspace) => workspace) } } + } - case 'SET_WORKSPACES': { - const payload = action.payload as { + case 'SET_WORKSPACES': { + const payload = action.payload as { name: string isGitRepo: boolean branches?: {remote: any; name: string}[] currentBranch?: string }[] - return { - ...state, - browser: { - ...state.browser, - workspaces: payload.filter((workspace) => workspace) - } + return { + ...state, + browser: { + ...state.browser, + workspaces: payload.filter((workspace) => workspace) } } + } - case 'SET_MODE': { - const payload = action.payload as 'browser' | 'localhost' + case 'SET_MODE': { + const payload = action.payload as 'browser' | 'localhost' - return { - ...state, - mode: payload - } + return { + ...state, + mode: payload } + } - case 'FETCH_DIRECTORY_REQUEST': { - return { - ...state, - browser: { - ...state.browser, - isRequestingDirectory: state.mode === 'browser', - isSuccessfulDirectory: false, - error: null - }, - localhost: { - ...state.localhost, - isRequestingDirectory: state.mode === 'localhost', - isSuccessfulDirectory: false, - error: null - } + case 'FETCH_DIRECTORY_REQUEST': { + return { + ...state, + browser: { + ...state.browser, + isRequestingDirectory: state.mode === 'browser', + isSuccessfulDirectory: false, + error: null + }, + localhost: { + ...state.localhost, + isRequestingDirectory: state.mode === 'localhost', + isSuccessfulDirectory: false, + error: null } } + } - case 'FETCH_DIRECTORY_SUCCESS': { - const payload = action.payload as {path: string; fileTree} + case 'FETCH_DIRECTORY_SUCCESS': { + const payload = action.payload as {path: string; fileTree} - return { - ...state, - browser: { - ...state.browser, - files: + return { + ...state, + browser: { + ...state.browser, + files: state.mode === 'browser' ? fetchDirectoryContent(state, payload) : state.browser.files, - isRequestingDirectory: false, - isSuccessfulDirectory: true, - error: null - }, - localhost: { - ...state.localhost, - files: + isRequestingDirectory: false, + isSuccessfulDirectory: true, + error: null + }, + localhost: { + ...state.localhost, + files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload) : state.localhost.files, - isRequestingDirectory: false, - isSuccessfulDirectory: true, - error: null - } + isRequestingDirectory: false, + isSuccessfulDirectory: true, + error: null } } + } - case 'FETCH_DIRECTORY_ERROR': { - return { - ...state, - browser: { - ...state.browser, - isRequestingDirectory: false, - isSuccessfulDirectory: false, - error: state.mode === 'browser' ? action.payload : null - }, - localhost: { - ...state.localhost, - isRequestingDirectory: false, - isSuccessfulDirectory: false, - error: state.mode === 'localhost' ? action.payload : null - } + case 'FETCH_DIRECTORY_ERROR': { + return { + ...state, + browser: { + ...state.browser, + isRequestingDirectory: false, + isSuccessfulDirectory: false, + error: state.mode === 'browser' ? action.payload : null + }, + localhost: { + ...state.localhost, + isRequestingDirectory: false, + isSuccessfulDirectory: false, + error: state.mode === 'localhost' ? action.payload : null } } + } - case 'FETCH_WORKSPACE_DIRECTORY_REQUEST': { - return { - ...state, - browser: { - ...state.browser, - isRequestingWorkspace: state.mode === 'browser', - isSuccessfulWorkspace: false, - error: null - }, - localhost: { - ...state.localhost, - isRequestingWorkspace: state.mode === 'localhost', - isSuccessfulWorkspace: false, - error: null - } + case 'FETCH_WORKSPACE_DIRECTORY_REQUEST': { + return { + ...state, + browser: { + ...state.browser, + isRequestingWorkspace: state.mode === 'browser', + isSuccessfulWorkspace: false, + error: null + }, + localhost: { + ...state.localhost, + isRequestingWorkspace: state.mode === 'localhost', + isSuccessfulWorkspace: false, + error: null } } + } - case 'FETCH_WORKSPACE_DIRECTORY_SUCCESS': { - const payload = action.payload as {path: string; fileTree} + case 'FETCH_WORKSPACE_DIRECTORY_SUCCESS': { + const payload = action.payload as {path: string; fileTree} - return { - ...state, - browser: { - ...state.browser, - files: + return { + ...state, + browser: { + ...state.browser, + files: state.mode === 'browser' ? fetchWorkspaceDirectoryContent(state, payload) : state.browser.files, - isRequestingWorkspace: false, - isSuccessfulWorkspace: true, - error: null - }, - localhost: { - ...state.localhost, - files: + isRequestingWorkspace: false, + isSuccessfulWorkspace: true, + error: null + }, + localhost: { + ...state.localhost, + files: state.mode === 'localhost' ? fetchWorkspaceDirectoryContent(state, payload) : state.localhost.files, - isRequestingWorkspace: false, - isSuccessfulWorkspace: true, - error: null, - sharedFolder: null - } + isRequestingWorkspace: false, + isSuccessfulWorkspace: true, + error: null, + sharedFolder: null } } + } - case 'FETCH_WORKSPACE_DIRECTORY_ERROR': { - return { - ...state, - browser: { - ...state.browser, - isRequestingWorkspace: false, - isSuccessfulWorkspace: false, - error: state.mode === 'browser' ? action.payload : null - }, - localhost: { - ...state.localhost, - isRequestingWorkspace: false, - isSuccessfulWorkspace: false, - error: state.mode === 'localhost' ? action.payload : null - } + case 'FETCH_WORKSPACE_DIRECTORY_ERROR': { + return { + ...state, + browser: { + ...state.browser, + isRequestingWorkspace: false, + isSuccessfulWorkspace: false, + error: state.mode === 'browser' ? action.payload : null + }, + localhost: { + ...state.localhost, + isRequestingWorkspace: false, + isSuccessfulWorkspace: false, + error: state.mode === 'localhost' ? action.payload : null } } + } - case 'DISPLAY_NOTIFICATION': { - const payload = action.payload as { + case 'DISPLAY_NOTIFICATION': { + const payload = action.payload as { title: string message: string actionOk: () => void @@ -311,554 +311,554 @@ export const browserReducer = (state = browserInitialState, action: Action) => { labelCancel: string } - return { - ...state, - notification: { - title: payload.title, - message: payload.message, - actionOk: + return { + ...state, + notification: { + title: payload.title, + message: payload.message, + actionOk: payload.actionOk || browserInitialState.notification.actionOk, - actionCancel: + actionCancel: payload.actionCancel || browserInitialState.notification.actionCancel, - labelOk: payload.labelOk, - labelCancel: payload.labelCancel - } + labelOk: payload.labelOk, + labelCancel: payload.labelCancel } } + } - case 'HIDE_NOTIFICATION': { - return { - ...state, - notification: browserInitialState.notification - } + case 'HIDE_NOTIFICATION': { + return { + ...state, + notification: browserInitialState.notification } + } - case 'FILE_ADDED_SUCCESS': { - const payload = action.payload as string + case 'FILE_ADDED_SUCCESS': { + const payload = action.payload as string - return { - ...state, - browser: { - ...state.browser, - files: + return { + ...state, + browser: { + ...state.browser, + files: state.mode === 'browser' ? fileAdded(state, payload) : state.browser.files, - expandPath: + expandPath: state.mode === 'browser' ? [...new Set([...state.browser.expandPath, payload])] : state.browser.expandPath - }, - localhost: { - ...state.localhost, - files: + }, + localhost: { + ...state.localhost, + files: state.mode === 'localhost' ? fileAdded(state, payload) : state.localhost.files, - expandPath: + expandPath: state.mode === 'localhost' ? [...new Set([...state.localhost.expandPath, payload])] : state.localhost.expandPath - } } } + } - case 'FOLDER_ADDED_SUCCESS': { - const payload = action.payload as { + case 'FOLDER_ADDED_SUCCESS': { + const payload = action.payload as { path: string folderPath: string fileTree } - return { - ...state, - browser: { - ...state.browser, - files: + return { + ...state, + browser: { + ...state.browser, + files: state.mode === 'browser' ? fetchDirectoryContent(state, payload) : state.browser.files, - expandPath: + expandPath: state.mode === 'browser' ? [...new Set([...state.browser.expandPath, payload.folderPath])] : state.browser.expandPath - }, - localhost: { - ...state.localhost, - files: + }, + localhost: { + ...state.localhost, + files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload) : state.localhost.files, - expandPath: + expandPath: state.mode === 'localhost' ? [ - ...new Set([ - ...state.localhost.expandPath, - payload.folderPath - ]) - ] + ...new Set([ + ...state.localhost.expandPath, + payload.folderPath + ]) + ] : state.localhost.expandPath - } } } + } - case 'FILE_REMOVED_SUCCESS': { - const payload = action.payload as string + case 'FILE_REMOVED_SUCCESS': { + const payload = action.payload as string - return { - ...state, - browser: { - ...state.browser, - files: + return { + ...state, + browser: { + ...state.browser, + files: state.mode === 'browser' ? fileRemoved(state, payload) : state.browser.files, - expandPath: + expandPath: state.mode === 'browser' ? [...state.browser.expandPath.filter((path) => path !== payload)] : state.browser.expandPath - }, - localhost: { - ...state.localhost, - files: + }, + localhost: { + ...state.localhost, + files: state.mode === 'localhost' ? fileRemoved(state, payload) : state.localhost.files, - expandPath: + expandPath: state.mode === 'localhost' ? [...state.browser.expandPath.filter((path) => path !== payload)] : state.localhost.expandPath - } } } + } - case 'ROOT_FOLDER_CHANGED': { - const payload = action.payload as string - return { - ...state, - localhost: { - ...state.localhost, - sharedFolder: payload, - files: {} - } + case 'ROOT_FOLDER_CHANGED': { + const payload = action.payload as string + return { + ...state, + localhost: { + ...state.localhost, + sharedFolder: payload, + files: {} } } + } - case 'ADD_INPUT_FIELD': { - const payload = action.payload as { + case 'ADD_INPUT_FIELD': { + const payload = action.payload as { path: string fileTree type: 'file' | 'folder' } - return { - ...state, - browser: { - ...state.browser, - files: + return { + ...state, + browser: { + ...state.browser, + files: state.mode === 'browser' ? fetchDirectoryContent(state, payload) : state.browser.files - }, - localhost: { - ...state.localhost, - files: + }, + localhost: { + ...state.localhost, + files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload) : state.localhost.files - }, - focusEdit: payload.path + '/' + 'blank' - } + }, + focusEdit: payload.path + '/' + 'blank' } + } - case 'REMOVE_INPUT_FIELD': { - const payload = action.payload as {path: string; fileTree} + case 'REMOVE_INPUT_FIELD': { + const payload = action.payload as {path: string; fileTree} - return { - ...state, - browser: { - ...state.browser, - files: + return { + ...state, + browser: { + ...state.browser, + files: state.mode === 'browser' ? removeInputField(state, payload.path) : state.browser.files - }, - localhost: { - ...state.localhost, - files: + }, + localhost: { + ...state.localhost, + files: state.mode === 'localhost' ? removeInputField(state, payload.path) : state.localhost.files - }, - focusEdit: null - } + }, + focusEdit: null } + } - case 'SET_READ_ONLY_MODE': { - const payload = action.payload as boolean + case 'SET_READ_ONLY_MODE': { + const payload = action.payload as boolean - return { - ...state, - readonly: payload - } + return { + ...state, + readonly: payload } + } - case 'FILE_RENAMED_SUCCESS': { - const payload = action.payload as { + case 'FILE_RENAMED_SUCCESS': { + const payload = action.payload as { path: string oldPath: string fileTree } - return { - ...state, - browser: { - ...state.browser, - files: + return { + ...state, + browser: { + ...state.browser, + files: state.mode === 'browser' ? fetchDirectoryContent(state, payload, payload.oldPath) : state.browser.files - }, - localhost: { - ...state.localhost, - files: + }, + localhost: { + ...state.localhost, + files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload, payload.oldPath) : state.localhost.files - } } } + } - case 'CREATE_WORKSPACE_REQUEST': { - return { - ...state, - browser: { - ...state.browser, - isRequestingWorkspace: true, - isSuccessfulWorkspace: false, - error: null - } + case 'CREATE_WORKSPACE_REQUEST': { + return { + ...state, + browser: { + ...state.browser, + isRequestingWorkspace: true, + isSuccessfulWorkspace: false, + error: null } } + } - case 'CREATE_WORKSPACE_SUCCESS': { - const payload = action.payload as { + case 'CREATE_WORKSPACE_SUCCESS': { + const payload = action.payload as { name: string isGitRepo: boolean branches?: {remote: any; name: string}[] currentBranch?: string } - const workspaces = state.browser.workspaces.find( - ({name}) => name === payload.name - ) - ? state.browser.workspaces - : [...state.browser.workspaces, action.payload] - - return { - ...state, - browser: { - ...state.browser, - currentWorkspace: payload.name, - workspaces: workspaces.filter((workspace) => workspace), - isRequestingWorkspace: false, - isSuccessfulWorkspace: true, - error: null - } + const workspaces = state.browser.workspaces.find( + ({name}) => name === payload.name + ) + ? state.browser.workspaces + : [...state.browser.workspaces, action.payload] + + return { + ...state, + browser: { + ...state.browser, + currentWorkspace: payload.name, + workspaces: workspaces.filter((workspace) => workspace), + isRequestingWorkspace: false, + isSuccessfulWorkspace: true, + error: null } } + } - case 'CREATE_WORKSPACE_ERROR': { - return { - ...state, - browser: { - ...state.browser, - isRequestingWorkspace: false, - isSuccessfulWorkspace: false, - error: action.payload - } + case 'CREATE_WORKSPACE_ERROR': { + return { + ...state, + browser: { + ...state.browser, + isRequestingWorkspace: false, + isSuccessfulWorkspace: false, + error: action.payload } } + } - case 'RENAME_WORKSPACE': { - const payload = action.payload as {oldName: string; workspaceName: string} - let renamedWorkspace - const workspaces = state.browser.workspaces.filter( - ({name, isGitRepo, branches, currentBranch}) => { - if (name && name !== payload.oldName) { - return true - } else { - renamedWorkspace = { - name: payload.workspaceName, - isGitRepo, - branches, - currentBranch - } - return false + case 'RENAME_WORKSPACE': { + const payload = action.payload as {oldName: string; workspaceName: string} + let renamedWorkspace + const workspaces = state.browser.workspaces.filter( + ({name, isGitRepo, branches, currentBranch}) => { + if (name && name !== payload.oldName) { + return true + } else { + renamedWorkspace = { + name: payload.workspaceName, + isGitRepo, + branches, + currentBranch } + return false } - ) + } + ) - return { - ...state, - browser: { - ...state.browser, - currentWorkspace: payload.workspaceName, - workspaces: [...workspaces, renamedWorkspace], - expandPath: [] - } + return { + ...state, + browser: { + ...state.browser, + currentWorkspace: payload.workspaceName, + workspaces: [...workspaces, renamedWorkspace], + expandPath: [] } } + } - case 'DELETE_WORKSPACE': { - const payload = action.payload as string - const workspaces = state.browser.workspaces.filter( - ({name}) => name && name !== payload - ) + case 'DELETE_WORKSPACE': { + const payload = action.payload as string + const workspaces = state.browser.workspaces.filter( + ({name}) => name && name !== payload + ) - return { - ...state, - browser: { - ...state.browser, - workspaces: workspaces - } + return { + ...state, + browser: { + ...state.browser, + workspaces: workspaces } } + } - case 'DISPLAY_POPUP_MESSAGE': { - const payload = action.payload as string + case 'DISPLAY_POPUP_MESSAGE': { + const payload = action.payload as string - return { - ...state, - popup: payload - } + return { + ...state, + popup: payload } + } - case 'HIDE_POPUP_MESSAGE': { - return { - ...state, - popup: '' - } + case 'HIDE_POPUP_MESSAGE': { + return { + ...state, + popup: '' } + } - case 'SET_FOCUS_ELEMENT': { - const payload = action.payload as { + case 'SET_FOCUS_ELEMENT': { + const payload = action.payload as { key: string type: 'file' | 'folder' | 'gist' }[] - return { - ...state, - focusElement: payload - } + return { + ...state, + focusElement: payload } + } - case 'REMOVE_FOCUS_ELEMENT': { - const payload: string = action.payload + case 'REMOVE_FOCUS_ELEMENT': { + const payload: string = action.payload - return { - ...state, - focusElement: state.focusElement.filter( - (element) => element.key !== payload - ) - } + return { + ...state, + focusElement: state.focusElement.filter( + (element) => element.key !== payload + ) } + } - case 'SET_CONTEXT_MENU_ITEM': { - const payload = action.payload as action - - return { - ...state, - browser: { - ...state.browser, - contextMenu: addContextMenuItem(state, payload) - }, - localhost: { - ...state.localhost, - contextMenu: addContextMenuItem(state, payload) - } + case 'SET_CONTEXT_MENU_ITEM': { + const payload = action.payload as action + + return { + ...state, + browser: { + ...state.browser, + contextMenu: addContextMenuItem(state, payload) + }, + localhost: { + ...state.localhost, + contextMenu: addContextMenuItem(state, payload) } } + } - case 'REMOVE_CONTEXT_MENU_ITEM': { - const payload = action.payload - - return { - ...state, - browser: { - ...state.browser, - contextMenu: removeContextMenuItem(state, payload) - }, - localhost: { - ...state.localhost, - contextMenu: removeContextMenuItem(state, payload) - } + case 'REMOVE_CONTEXT_MENU_ITEM': { + const payload = action.payload + + return { + ...state, + browser: { + ...state.browser, + contextMenu: removeContextMenuItem(state, payload) + }, + localhost: { + ...state.localhost, + contextMenu: removeContextMenuItem(state, payload) } } + } - case 'SET_EXPAND_PATH': { - const payload = action.payload as string[] - - return { - ...state, - browser: { - ...state.browser, - expandPath: payload - }, - localhost: { - ...state.localhost, - expandPath: payload - } + case 'SET_EXPAND_PATH': { + const payload = action.payload as string[] + + return { + ...state, + browser: { + ...state.browser, + expandPath: payload + }, + localhost: { + ...state.localhost, + expandPath: payload } } + } - case 'LOAD_LOCALHOST_REQUEST': { - return { - ...state, - localhost: { - ...state.localhost, - isRequestingLocalhost: true, - isSuccessfulLocalhost: false, - error: null - } + case 'LOAD_LOCALHOST_REQUEST': { + return { + ...state, + localhost: { + ...state.localhost, + isRequestingLocalhost: true, + isSuccessfulLocalhost: false, + error: null } } + } - case 'LOAD_LOCALHOST_SUCCESS': { - return { - ...state, - localhost: { - ...state.localhost, - isRequestingLocalhost: false, - isSuccessfulLocalhost: true, - error: null - } + case 'LOAD_LOCALHOST_SUCCESS': { + return { + ...state, + localhost: { + ...state.localhost, + isRequestingLocalhost: false, + isSuccessfulLocalhost: true, + error: null } } + } - case 'LOAD_LOCALHOST_ERROR': { - const payload = action.payload as string + case 'LOAD_LOCALHOST_ERROR': { + const payload = action.payload as string - return { - ...state, - localhost: { - ...state.localhost, - isRequestingLocalhost: false, - isSuccessfulLocalhost: false, - error: payload - } + return { + ...state, + localhost: { + ...state.localhost, + isRequestingLocalhost: false, + isSuccessfulLocalhost: false, + error: payload } } + } - case 'CLONE_REPOSITORY_REQUEST': { - return { - ...state, - browser: { - ...state.browser, - isRequestingCloning: true, - isSuccessfulCloning: false - } + case 'CLONE_REPOSITORY_REQUEST': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: true, + isSuccessfulCloning: false } } + } - case 'CLONE_REPOSITORY_SUCCESS': { - return { - ...state, - browser: { - ...state.browser, - isRequestingCloning: false, - isSuccessfulCloning: true - } + case 'CLONE_REPOSITORY_SUCCESS': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: false, + isSuccessfulCloning: true } } + } - case 'CLONE_REPOSITORY_FAILED': { - return { - ...state, - browser: { - ...state.browser, - isRequestingCloning: false, - isSuccessfulCloning: false - } + case 'CLONE_REPOSITORY_FAILED': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: false, + isSuccessfulCloning: false } } + } - case 'FS_INITIALIZATION_COMPLETED': { - return { - ...state, - initializingFS: false - } + case 'FS_INITIALIZATION_COMPLETED': { + return { + ...state, + initializingFS: false } + } - case 'SET_FILE_DECORATION_SUCCESS': { - return { - ...state, - browser: { - ...state.browser, - fileState: action.payload - } + case 'SET_FILE_DECORATION_SUCCESS': { + return { + ...state, + browser: { + ...state.browser, + fileState: action.payload } } + } - case 'SET_CURRENT_WORKSPACE_BRANCHES': { - const payload: {remote: any; name: string}[] = action.payload - - return { - ...state, - browser: { - ...state.browser, - workspaces: state.browser.workspaces.map((workspace) => { - if (workspace.name === state.browser.currentWorkspace) - workspace.branches = payload - return workspace - }) - } + case 'SET_CURRENT_WORKSPACE_BRANCHES': { + const payload: {remote: any; name: string}[] = action.payload + + return { + ...state, + browser: { + ...state.browser, + workspaces: state.browser.workspaces.map((workspace) => { + if (workspace.name === state.browser.currentWorkspace) + workspace.branches = payload + return workspace + }) } } + } - case 'SET_CURRENT_WORKSPACE_CURRENT_BRANCH': { - const payload: string = action.payload - - return { - ...state, - browser: { - ...state.browser, - workspaces: state.browser.workspaces.map((workspace) => { - if (workspace.name === state.browser.currentWorkspace) - workspace.currentBranch = payload - return workspace - }) - } + case 'SET_CURRENT_WORKSPACE_CURRENT_BRANCH': { + const payload: string = action.payload + + return { + ...state, + browser: { + ...state.browser, + workspaces: state.browser.workspaces.map((workspace) => { + if (workspace.name === state.browser.currentWorkspace) + workspace.currentBranch = payload + return workspace + }) } } + } - case 'SET_CURRENT_WORKSPACE_IS_GITREPO': { - const payload: boolean = action.payload - - return { - ...state, - browser: { - ...state.browser, - workspaces: state.browser.workspaces.map((workspace) => { - if (workspace.name === state.browser.currentWorkspace) - workspace.isGitRepo = payload - return workspace - }) - } + case 'SET_CURRENT_WORKSPACE_IS_GITREPO': { + const payload: boolean = action.payload + + return { + ...state, + browser: { + ...state.browser, + workspaces: state.browser.workspaces.map((workspace) => { + if (workspace.name === state.browser.currentWorkspace) + workspace.isGitRepo = payload + return workspace + }) } } + } - case 'SET_GIT_CONFIG': { - const payload: {username: string; token: string; email: string} = + case 'SET_GIT_CONFIG': { + const payload: {username: string; token: string; email: string} = action.payload - return { - ...state, - gitConfig: payload - } + return { + ...state, + gitConfig: payload } + } - default: - throw new Error() + default: + throw new Error() } } @@ -1065,7 +1065,6 @@ const normalize = ( } } }) - // do sorting here. if (newInputType === 'folder') { const path = directory + '/blank'