From 13decfc57c89c51c94840de16b2e3a332009aaf0 Mon Sep 17 00:00:00 2001 From: Curtis Doty Date: Fri, 5 Jul 2024 22:58:04 +0000 Subject: [PATCH 1/5] Dramatically speed up clasp status - jettison recursive-readdir and use fdir instead - also needed to install @types/picomatch --- package-lock.json | 140 +++++++++++++++++++++++++++++++++------------- package.json | 4 +- src/files.ts | 5 +- 3 files changed, 105 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index 72078dc5..f5bdf2fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "commander": "^8.1.0", "debounce": "^1.2.1", "dotf": "^2.0.2", + "fdir": "^6.1.1", "find-up": "^6.0.0", "fs-extra": "^10.0.0", "fuzzy": "^0.1.3", @@ -34,7 +35,6 @@ "ora": "^6.0.0", "p-map": "^5.1.0", "read-pkg-up": "^8.0.0", - "recursive-readdir": "^2.2.2", "server-destroy": "^1.0.1", "split-lines": "^3.0.0", "strip-bom": "^5.0.0", @@ -51,7 +51,7 @@ "@types/inquirer": "^7.3.3", "@types/mocha": "^9.0.0", "@types/node": "^12.20.21", - "@types/recursive-readdir": "^2.2.0", + "@types/picomatch": "^2.3.4", "@types/server-destroy": "^1.0.1", "@types/tmp": "^0.2.1", "@types/wtfnode": "^0.7.0", @@ -921,14 +921,12 @@ "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz", "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==" }, - "node_modules/@types/recursive-readdir": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@types/recursive-readdir/-/recursive-readdir-2.2.0.tgz", - "integrity": "sha512-HGk753KRu2N4mWduovY4BLjYq4jTOL29gV2OfGdGxHcPSWGFkC5RRIdk+VTs5XmYd7MVAD+JwKrcb5+5Y7FOCg==", + "node_modules/@types/picomatch": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@types/picomatch/-/picomatch-2.3.4.tgz", + "integrity": "sha512-0so8lU8O5zatZS/2Fi4zrwks+vZv7e0dygrgEZXljODXBig97l4cPQD+9LabXfGJOWwoRkTVz6Q4edZvD12UOA==", "dev": true, - "dependencies": { - "@types/node": "*" - } + "license": "MIT" }, "node_modules/@types/responselike": { "version": "1.0.0", @@ -1387,6 +1385,18 @@ "node": ">= 8" } }, + "node_modules/anymatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/append-transform": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", @@ -2945,6 +2955,20 @@ "reusify": "^1.0.4" } }, + "node_modules/fdir": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.1.1.tgz", + "integrity": "sha512-QfKBVg453Dyn3mr0Q0O+Tkr1r79lOTAKSi9f/Ot4+qVEwxWhav2Z+SudrG9vQjM2aYRMQQZ2/Q1zdA8ACM1pDg==", + "license": "MIT", + "peerDependencies": { + "picomatch": "3.x" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, "node_modules/figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -4908,6 +4932,19 @@ "node": ">=8.6" } }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/mime-db": { "version": "1.47.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", @@ -6150,11 +6187,14 @@ "dev": true }, "node_modules/picomatch": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.3.tgz", - "integrity": "sha512-KpELjfwcCDUb9PeigTs2mBJzXUPzAuP2oPcA989He8Rte0+YUAjw1JVedDhuTKPkHjSYzMN3npC9luThGYEKdg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-3.0.1.tgz", + "integrity": "sha512-I3EurrIQMlRc9IaAZnqRR044Phh2DXY+55o7uJ0V+hYZAcQYSuFWsc9q5PvyDHUSCe1Qxn/iBz+78s86zWnGag==", + "license": "MIT", + "optional": true, + "peer": true, "engines": { - "node": ">=8.6" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/jonschlinkert" @@ -6558,15 +6598,16 @@ "node": ">=8.10.0" } }, - "node_modules/recursive-readdir": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.3.tgz", - "integrity": "sha512-8HrF5ZsXk5FAH9dgsx3BlUer73nIhuj+9OrQwEbLTPOBzGkL1lsFCR01am+v+0m2Cmbs1nP12hLDl5FA7EszKA==", - "dependencies": { - "minimatch": "^3.0.5" - }, + "node_modules/readdirp/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "license": "MIT", "engines": { - "node": ">=6.0.0" + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" } }, "node_modules/redent": { @@ -8470,14 +8511,11 @@ "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz", "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==" }, - "@types/recursive-readdir": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@types/recursive-readdir/-/recursive-readdir-2.2.0.tgz", - "integrity": "sha512-HGk753KRu2N4mWduovY4BLjYq4jTOL29gV2OfGdGxHcPSWGFkC5RRIdk+VTs5XmYd7MVAD+JwKrcb5+5Y7FOCg==", - "dev": true, - "requires": { - "@types/node": "*" - } + "@types/picomatch": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@types/picomatch/-/picomatch-2.3.4.tgz", + "integrity": "sha512-0so8lU8O5zatZS/2Fi4zrwks+vZv7e0dygrgEZXljODXBig97l4cPQD+9LabXfGJOWwoRkTVz6Q4edZvD12UOA==", + "dev": true }, "@types/responselike": { "version": "1.0.0", @@ -8784,6 +8822,13 @@ "requires": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" + }, + "dependencies": { + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + } } }, "append-transform": { @@ -9934,6 +9979,12 @@ "reusify": "^1.0.4" } }, + "fdir": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.1.1.tgz", + "integrity": "sha512-QfKBVg453Dyn3mr0Q0O+Tkr1r79lOTAKSi9f/Ot4+qVEwxWhav2Z+SudrG9vQjM2aYRMQQZ2/Q1zdA8ACM1pDg==", + "requires": {} + }, "figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -11364,6 +11415,14 @@ "requires": { "braces": "^3.0.1", "picomatch": "^2.2.3" + }, + "dependencies": { + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + } } }, "mime-db": { @@ -12264,9 +12323,11 @@ "dev": true }, "picomatch": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.3.tgz", - "integrity": "sha512-KpELjfwcCDUb9PeigTs2mBJzXUPzAuP2oPcA989He8Rte0+YUAjw1JVedDhuTKPkHjSYzMN3npC9luThGYEKdg==" + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-3.0.1.tgz", + "integrity": "sha512-I3EurrIQMlRc9IaAZnqRR044Phh2DXY+55o7uJ0V+hYZAcQYSuFWsc9q5PvyDHUSCe1Qxn/iBz+78s86zWnGag==", + "optional": true, + "peer": true }, "pkg-dir": { "version": "4.2.0", @@ -12535,14 +12596,13 @@ "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", "requires": { "picomatch": "^2.2.1" - } - }, - "recursive-readdir": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.3.tgz", - "integrity": "sha512-8HrF5ZsXk5FAH9dgsx3BlUer73nIhuj+9OrQwEbLTPOBzGkL1lsFCR01am+v+0m2Cmbs1nP12hLDl5FA7EszKA==", - "requires": { - "minimatch": "^3.0.5" + }, + "dependencies": { + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + } } }, "redent": { diff --git a/package.json b/package.json index 5c103d4f..496aea14 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "commander": "^8.1.0", "debounce": "^1.2.1", "dotf": "^2.0.2", + "fdir": "^6.1.1", "find-up": "^6.0.0", "fs-extra": "^10.0.0", "fuzzy": "^0.1.3", @@ -85,7 +86,6 @@ "ora": "^6.0.0", "p-map": "^5.1.0", "read-pkg-up": "^8.0.0", - "recursive-readdir": "^2.2.2", "server-destroy": "^1.0.1", "split-lines": "^3.0.0", "strip-bom": "^5.0.0", @@ -99,7 +99,7 @@ "@types/inquirer": "^7.3.3", "@types/mocha": "^9.0.0", "@types/node": "^12.20.21", - "@types/recursive-readdir": "^2.2.0", + "@types/picomatch": "^2.3.4", "@types/server-destroy": "^1.0.1", "@types/tmp": "^0.2.1", "@types/wtfnode": "^0.7.0", diff --git a/src/files.ts b/src/files.ts index cac6213c..a51ffa89 100644 --- a/src/files.ts +++ b/src/files.ts @@ -4,7 +4,7 @@ import makeDir from 'make-dir'; import multimatch from 'multimatch'; import path from 'path'; import pMap from 'p-map'; -import recursive from 'recursive-readdir'; +import {fdir} from 'fdir'; import typescript from 'typescript'; import {GaxiosError} from 'gaxios'; @@ -90,7 +90,8 @@ export const getAllProjectFiles = async (rootDir: string = path.join('.', '/')): // Read all filenames as a flattened tree // Note: filePaths contain relative paths such as "test/bar.ts", "../../src/foo.js" - const files: ProjectFile[] = (await recursive(rootDir)).map((filename): ProjectFile => { + const filelist = await new fdir().withFullPaths().crawl(rootDir).withPromise(); + const files: ProjectFile[] = filelist.map((filename): ProjectFile => { // Replace OS specific path separator to common '/' char for console output const name = filename.replace(/\\/g, '/'); From 8d644a27c81e26fce0efde334f6e7c402e59027a Mon Sep 17 00:00:00 2001 From: Curtis Doty Date: Sat, 6 Jul 2024 00:33:55 +0000 Subject: [PATCH 2/5] File paths need to be relative to base path --- src/files.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/files.ts b/src/files.ts index a51ffa89..69ec4609 100644 --- a/src/files.ts +++ b/src/files.ts @@ -90,7 +90,7 @@ export const getAllProjectFiles = async (rootDir: string = path.join('.', '/')): // Read all filenames as a flattened tree // Note: filePaths contain relative paths such as "test/bar.ts", "../../src/foo.js" - const filelist = await new fdir().withFullPaths().crawl(rootDir).withPromise(); + const filelist = await new fdir().withBasePath().crawl(rootDir).withPromise(); const files: ProjectFile[] = filelist.map((filename): ProjectFile => { // Replace OS specific path separator to common '/' char for console output const name = filename.replace(/\\/g, '/'); From ad54964eca9bc510c49c0c715cee37912bffe701 Mon Sep 17 00:00:00 2001 From: Curtis Doty Date: Sat, 6 Jul 2024 00:46:03 +0000 Subject: [PATCH 3/5] Ignore Python virtual environments --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d52acf36..2d7e6217 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ yarn-debug.log* yarn-error.log* .npm .env +.venv* .nyc_output *.lock From 4b61bb6fc6ad07bcbef818433ed2d16e94363f85 Mon Sep 17 00:00:00 2001 From: Curtis Doty Date: Sat, 6 Jul 2024 00:52:56 +0000 Subject: [PATCH 4/5] Further speedup clasp status by ignoring virtual envs & node_modules --- .claspignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .claspignore diff --git a/.claspignore b/.claspignore new file mode 100644 index 00000000..d258a9f1 --- /dev/null +++ b/.claspignore @@ -0,0 +1,2 @@ +.venv/** +node_modules/** From df7df1bba9f2d10098a0056af617a46c9417f710 Mon Sep 17 00:00:00 2001 From: Curtis Doty Date: Sat, 6 Jul 2024 01:11:16 +0000 Subject: [PATCH 5/5] Reduce confusion by bringing .claspignore into partity - with dotfiles.ts defaultClaspignore --- .claspignore | 16 +++++++++++++++- src/dotfile.ts | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.claspignore b/.claspignore index d258a9f1..ec576b4c 100644 --- a/.claspignore +++ b/.claspignore @@ -1,2 +1,16 @@ -.venv/** +# ignore all files… +**/** + +# except the extensions… +!appsscript.json +!**/*.gs +!**/*.js +!**/*.ts +!**/*.html + +# ignore even valid files if in… +.git/** node_modules/** + +# and Python virtual environments +.venv/** diff --git a/src/dotfile.ts b/src/dotfile.ts index 7c3a102a..4b65c638 100644 --- a/src/dotfile.ts +++ b/src/dotfile.ts @@ -49,6 +49,9 @@ const defaultClaspignore = `# ignore all files… # ignore even valid files if in… .git/** node_modules/** + +# and Python virtual environments +.venv/** `; // Methods for retrieving dotfiles.