From 12ac37978f54a52e9e44fec578cf43538603cb57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Mart=C3=ADn=20Alconada=20Verzini?= Date: Thu, 4 Jan 2024 09:22:17 -0300 Subject: [PATCH 1/2] feat: add pre-commit hook --- .husky/pre-commit | 4 ++ node_modules/.bin/husky | 1 + node_modules/.yarn-integrity | 16 ++++++++ node_modules/husky/LICENSE | 21 ++++++++++ node_modules/husky/README.md | 38 ++++++++++++++++++ node_modules/husky/husky.sh | 36 +++++++++++++++++ node_modules/husky/lib/bin.d.ts | 2 + node_modules/husky/lib/bin.js | 30 ++++++++++++++ node_modules/husky/lib/index.d.ts | 4 ++ node_modules/husky/lib/index.js | 67 +++++++++++++++++++++++++++++++ node_modules/husky/package.json | 40 ++++++++++++++++++ package.json | 14 +++---- yarn.lock | 8 ++++ 13 files changed, 272 insertions(+), 9 deletions(-) create mode 100755 .husky/pre-commit create mode 120000 node_modules/.bin/husky create mode 100644 node_modules/.yarn-integrity create mode 100644 node_modules/husky/LICENSE create mode 100644 node_modules/husky/README.md create mode 100644 node_modules/husky/husky.sh create mode 100644 node_modules/husky/lib/bin.d.ts create mode 100755 node_modules/husky/lib/bin.js create mode 100644 node_modules/husky/lib/index.d.ts create mode 100644 node_modules/husky/lib/index.js create mode 100644 node_modules/husky/package.json create mode 100644 yarn.lock diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..fd0714c1 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +forge fmt diff --git a/node_modules/.bin/husky b/node_modules/.bin/husky new file mode 120000 index 00000000..adfcbbba --- /dev/null +++ b/node_modules/.bin/husky @@ -0,0 +1 @@ +../husky/lib/bin.js \ No newline at end of file diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity new file mode 100644 index 00000000..6b426be2 --- /dev/null +++ b/node_modules/.yarn-integrity @@ -0,0 +1,16 @@ +{ + "systemParams": "darwin-arm64-115", + "modulesFolders": [ + "node_modules" + ], + "flags": [], + "linkedModules": [], + "topLevelPatterns": [ + "husky@^8.0.3" + ], + "lockfileEntries": { + "husky@^8.0.3": "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" + }, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/node_modules/husky/LICENSE b/node_modules/husky/LICENSE new file mode 100644 index 00000000..049c9dc4 --- /dev/null +++ b/node_modules/husky/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 typicode + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/husky/README.md b/node_modules/husky/README.md new file mode 100644 index 00000000..adfd3773 --- /dev/null +++ b/node_modules/husky/README.md @@ -0,0 +1,38 @@ +# husky + +> Modern native Git hooks made easy + +Husky improves your commits and more 🐶 *woof!* + +# Install + +``` +npm install husky --save-dev +``` + +# Usage + +Edit `package.json > prepare` script and run it once: + +```sh +npm pkg set scripts.prepare="husky install" +npm run prepare +``` + +Add a hook: + +```sh +npx husky add .husky/pre-commit "npm test" +git add .husky/pre-commit +``` + +Make a commit: + +```sh +git commit -m "Keep calm and commit" +# `npm test` will run +``` + +# Documentation + +https://typicode.github.io/husky diff --git a/node_modules/husky/husky.sh b/node_modules/husky/husky.sh new file mode 100644 index 00000000..cec959a6 --- /dev/null +++ b/node_modules/husky/husky.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh +if [ -z "$husky_skip_init" ]; then + debug () { + if [ "$HUSKY_DEBUG" = "1" ]; then + echo "husky (debug) - $1" + fi + } + + readonly hook_name="$(basename -- "$0")" + debug "starting $hook_name..." + + if [ "$HUSKY" = "0" ]; then + debug "HUSKY env variable is set to 0, skipping hook" + exit 0 + fi + + if [ -f ~/.huskyrc ]; then + debug "sourcing ~/.huskyrc" + . ~/.huskyrc + fi + + readonly husky_skip_init=1 + export husky_skip_init + sh -e "$0" "$@" + exitCode="$?" + + if [ $exitCode != 0 ]; then + echo "husky - $hook_name hook exited with code $exitCode (error)" + fi + + if [ $exitCode = 127 ]; then + echo "husky - command not found in PATH=$PATH" + fi + + exit $exitCode +fi diff --git a/node_modules/husky/lib/bin.d.ts b/node_modules/husky/lib/bin.d.ts new file mode 100644 index 00000000..b7988016 --- /dev/null +++ b/node_modules/husky/lib/bin.d.ts @@ -0,0 +1,2 @@ +#!/usr/bin/env node +export {}; diff --git a/node_modules/husky/lib/bin.js b/node_modules/husky/lib/bin.js new file mode 100755 index 00000000..b867ba58 --- /dev/null +++ b/node_modules/husky/lib/bin.js @@ -0,0 +1,30 @@ +#!/usr/bin/env node +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const p = require("path"); +const h = require("./"); +function help(code) { + console.log(`Usage: + husky install [dir] (default: .husky) + husky uninstall + husky set|add [cmd]`); + process.exit(code); +} +const [, , cmd, ...args] = process.argv; +const ln = args.length; +const [x, y] = args; +const hook = (fn) => () => !ln || ln > 2 ? help(2) : fn(x, y); +const cmds = { + install: () => (ln > 1 ? help(2) : h.install(x)), + uninstall: h.uninstall, + set: hook(h.set), + add: hook(h.add), + ['-v']: () => console.log(require(p.join(__dirname, '../package.json')).version), +}; +try { + cmds[cmd] ? cmds[cmd]() : help(0); +} +catch (e) { + console.error(e instanceof Error ? `husky - ${e.message}` : e); + process.exit(1); +} diff --git a/node_modules/husky/lib/index.d.ts b/node_modules/husky/lib/index.d.ts new file mode 100644 index 00000000..52062a04 --- /dev/null +++ b/node_modules/husky/lib/index.d.ts @@ -0,0 +1,4 @@ +export declare function install(dir?: string): void; +export declare function set(file: string, cmd: string): void; +export declare function add(file: string, cmd: string): void; +export declare function uninstall(): void; diff --git a/node_modules/husky/lib/index.js b/node_modules/husky/lib/index.js new file mode 100644 index 00000000..37ef89c7 --- /dev/null +++ b/node_modules/husky/lib/index.js @@ -0,0 +1,67 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.uninstall = exports.add = exports.set = exports.install = void 0; +const cp = require("child_process"); +const fs = require("fs"); +const p = require("path"); +const l = (msg) => console.log(`husky - ${msg}`); +const git = (args) => cp.spawnSync('git', args, { stdio: 'inherit' }); +function install(dir = '.husky') { + if (process.env.HUSKY === '0') { + l('HUSKY env variable is set to 0, skipping install'); + return; + } + if (git(['rev-parse']).status !== 0) { + l(`git command not found, skipping install`); + return; + } + const url = 'https://typicode.github.io/husky/#/?id=custom-directory'; + if (!p.resolve(process.cwd(), dir).startsWith(process.cwd())) { + throw new Error(`.. not allowed (see ${url})`); + } + if (!fs.existsSync('.git')) { + throw new Error(`.git can't be found (see ${url})`); + } + try { + fs.mkdirSync(p.join(dir, '_'), { recursive: true }); + fs.writeFileSync(p.join(dir, '_/.gitignore'), '*'); + fs.copyFileSync(p.join(__dirname, '../husky.sh'), p.join(dir, '_/husky.sh')); + const { error } = git(['config', 'core.hooksPath', dir]); + if (error) { + throw error; + } + } + catch (e) { + l('Git hooks failed to install'); + throw e; + } + l('Git hooks installed'); +} +exports.install = install; +function set(file, cmd) { + const dir = p.dirname(file); + if (!fs.existsSync(dir)) { + throw new Error(`can't create hook, ${dir} directory doesn't exist (try running husky install)`); + } + fs.writeFileSync(file, `#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +${cmd} +`, { mode: 0o0755 }); + l(`created ${file}`); +} +exports.set = set; +function add(file, cmd) { + if (fs.existsSync(file)) { + fs.appendFileSync(file, `${cmd}\n`); + l(`updated ${file}`); + } + else { + set(file, cmd); + } +} +exports.add = add; +function uninstall() { + git(['config', '--unset', 'core.hooksPath']); +} +exports.uninstall = uninstall; diff --git a/node_modules/husky/package.json b/node_modules/husky/package.json new file mode 100644 index 00000000..079ddd7f --- /dev/null +++ b/node_modules/husky/package.json @@ -0,0 +1,40 @@ +{ + "name": "husky", + "version": "8.0.3", + "description": "Modern native Git hooks made easy", + "keywords": [ + "git", + "hooks", + "pre-commit" + ], + "homepage": "https://typicode.github.io/husky", + "repository": "typicode/husky", + "funding": "https://github.com/sponsors/typicode", + "license": "MIT", + "author": "Typicode ", + "bin": "lib/bin.js", + "main": "lib/index.js", + "files": [ + "lib", + "husky.sh" + ], + "scripts": { + "build": "tsc", + "test": "sh test/all.sh", + "lint": "eslint src --ext .ts", + "serve": "docsify serve docs", + "prepare": "npm run build && node lib/bin install" + }, + "devDependencies": { + "@commitlint/cli": "^17.3.0", + "@commitlint/config-conventional": "^17.3.0", + "@tsconfig/node14": "^1.0.3", + "@types/node": "^18.11.18", + "@typicode/eslint-config": "^1.1.0", + "docsify-cli": "^4.4.4", + "typescript": "^4.9.4" + }, + "engines": { + "node": ">=14" + } +} diff --git a/package.json b/package.json index a845f3db..11141863 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,8 @@ { - "name": "kinto-id", - "version": "1.0.0", + "name": "kinto-core", "description": "Kinto ID ", - "main": "index.js", - "author": "Ramon Recuero ", - "license": "MIT", - "scripts": { - "export-testnet": "source .env && node ./utils/export.js $TEST_NETWORK_ID" - }, - "private": true + "repository": "https://github.com/KintoXYZ/kinto-core.git", + "devDependencies": { + "husky": "^8.0.3" + } } diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..4ba8287a --- /dev/null +++ b/yarn.lock @@ -0,0 +1,8 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +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== From fd9ad8b5d4dd6368b69e24e492e36fd113050073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Mart=C3=ADn=20Alconada=20Verzini?= Date: Thu, 4 Jan 2024 15:09:48 -0300 Subject: [PATCH 2/2] chore: ignore node_modules --- .gitignore | 4 ++ node_modules/.bin/husky | 1 - node_modules/.yarn-integrity | 16 -------- node_modules/husky/LICENSE | 21 ---------- node_modules/husky/README.md | 38 ------------------ node_modules/husky/husky.sh | 36 ----------------- node_modules/husky/lib/bin.d.ts | 2 - node_modules/husky/lib/bin.js | 30 -------------- node_modules/husky/lib/index.d.ts | 4 -- node_modules/husky/lib/index.js | 67 ------------------------------- node_modules/husky/package.json | 40 ------------------ 11 files changed, 4 insertions(+), 255 deletions(-) delete mode 120000 node_modules/.bin/husky delete mode 100644 node_modules/.yarn-integrity delete mode 100644 node_modules/husky/LICENSE delete mode 100644 node_modules/husky/README.md delete mode 100644 node_modules/husky/husky.sh delete mode 100644 node_modules/husky/lib/bin.d.ts delete mode 100755 node_modules/husky/lib/bin.js delete mode 100644 node_modules/husky/lib/index.d.ts delete mode 100644 node_modules/husky/lib/index.js delete mode 100644 node_modules/husky/package.json diff --git a/.gitignore b/.gitignore index 26d8207b..c61cf3cd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,7 @@ bin # Dotenv file .env + +# node +node_modules/ +out/ diff --git a/node_modules/.bin/husky b/node_modules/.bin/husky deleted file mode 120000 index adfcbbba..00000000 --- a/node_modules/.bin/husky +++ /dev/null @@ -1 +0,0 @@ -../husky/lib/bin.js \ No newline at end of file diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity deleted file mode 100644 index 6b426be2..00000000 --- a/node_modules/.yarn-integrity +++ /dev/null @@ -1,16 +0,0 @@ -{ - "systemParams": "darwin-arm64-115", - "modulesFolders": [ - "node_modules" - ], - "flags": [], - "linkedModules": [], - "topLevelPatterns": [ - "husky@^8.0.3" - ], - "lockfileEntries": { - "husky@^8.0.3": "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" - }, - "files": [], - "artifacts": {} -} \ No newline at end of file diff --git a/node_modules/husky/LICENSE b/node_modules/husky/LICENSE deleted file mode 100644 index 049c9dc4..00000000 --- a/node_modules/husky/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 typicode - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/husky/README.md b/node_modules/husky/README.md deleted file mode 100644 index adfd3773..00000000 --- a/node_modules/husky/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# husky - -> Modern native Git hooks made easy - -Husky improves your commits and more 🐶 *woof!* - -# Install - -``` -npm install husky --save-dev -``` - -# Usage - -Edit `package.json > prepare` script and run it once: - -```sh -npm pkg set scripts.prepare="husky install" -npm run prepare -``` - -Add a hook: - -```sh -npx husky add .husky/pre-commit "npm test" -git add .husky/pre-commit -``` - -Make a commit: - -```sh -git commit -m "Keep calm and commit" -# `npm test` will run -``` - -# Documentation - -https://typicode.github.io/husky diff --git a/node_modules/husky/husky.sh b/node_modules/husky/husky.sh deleted file mode 100644 index cec959a6..00000000 --- a/node_modules/husky/husky.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env sh -if [ -z "$husky_skip_init" ]; then - debug () { - if [ "$HUSKY_DEBUG" = "1" ]; then - echo "husky (debug) - $1" - fi - } - - readonly hook_name="$(basename -- "$0")" - debug "starting $hook_name..." - - if [ "$HUSKY" = "0" ]; then - debug "HUSKY env variable is set to 0, skipping hook" - exit 0 - fi - - if [ -f ~/.huskyrc ]; then - debug "sourcing ~/.huskyrc" - . ~/.huskyrc - fi - - readonly husky_skip_init=1 - export husky_skip_init - sh -e "$0" "$@" - exitCode="$?" - - if [ $exitCode != 0 ]; then - echo "husky - $hook_name hook exited with code $exitCode (error)" - fi - - if [ $exitCode = 127 ]; then - echo "husky - command not found in PATH=$PATH" - fi - - exit $exitCode -fi diff --git a/node_modules/husky/lib/bin.d.ts b/node_modules/husky/lib/bin.d.ts deleted file mode 100644 index b7988016..00000000 --- a/node_modules/husky/lib/bin.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -export {}; diff --git a/node_modules/husky/lib/bin.js b/node_modules/husky/lib/bin.js deleted file mode 100755 index b867ba58..00000000 --- a/node_modules/husky/lib/bin.js +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env node -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const p = require("path"); -const h = require("./"); -function help(code) { - console.log(`Usage: - husky install [dir] (default: .husky) - husky uninstall - husky set|add [cmd]`); - process.exit(code); -} -const [, , cmd, ...args] = process.argv; -const ln = args.length; -const [x, y] = args; -const hook = (fn) => () => !ln || ln > 2 ? help(2) : fn(x, y); -const cmds = { - install: () => (ln > 1 ? help(2) : h.install(x)), - uninstall: h.uninstall, - set: hook(h.set), - add: hook(h.add), - ['-v']: () => console.log(require(p.join(__dirname, '../package.json')).version), -}; -try { - cmds[cmd] ? cmds[cmd]() : help(0); -} -catch (e) { - console.error(e instanceof Error ? `husky - ${e.message}` : e); - process.exit(1); -} diff --git a/node_modules/husky/lib/index.d.ts b/node_modules/husky/lib/index.d.ts deleted file mode 100644 index 52062a04..00000000 --- a/node_modules/husky/lib/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare function install(dir?: string): void; -export declare function set(file: string, cmd: string): void; -export declare function add(file: string, cmd: string): void; -export declare function uninstall(): void; diff --git a/node_modules/husky/lib/index.js b/node_modules/husky/lib/index.js deleted file mode 100644 index 37ef89c7..00000000 --- a/node_modules/husky/lib/index.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.uninstall = exports.add = exports.set = exports.install = void 0; -const cp = require("child_process"); -const fs = require("fs"); -const p = require("path"); -const l = (msg) => console.log(`husky - ${msg}`); -const git = (args) => cp.spawnSync('git', args, { stdio: 'inherit' }); -function install(dir = '.husky') { - if (process.env.HUSKY === '0') { - l('HUSKY env variable is set to 0, skipping install'); - return; - } - if (git(['rev-parse']).status !== 0) { - l(`git command not found, skipping install`); - return; - } - const url = 'https://typicode.github.io/husky/#/?id=custom-directory'; - if (!p.resolve(process.cwd(), dir).startsWith(process.cwd())) { - throw new Error(`.. not allowed (see ${url})`); - } - if (!fs.existsSync('.git')) { - throw new Error(`.git can't be found (see ${url})`); - } - try { - fs.mkdirSync(p.join(dir, '_'), { recursive: true }); - fs.writeFileSync(p.join(dir, '_/.gitignore'), '*'); - fs.copyFileSync(p.join(__dirname, '../husky.sh'), p.join(dir, '_/husky.sh')); - const { error } = git(['config', 'core.hooksPath', dir]); - if (error) { - throw error; - } - } - catch (e) { - l('Git hooks failed to install'); - throw e; - } - l('Git hooks installed'); -} -exports.install = install; -function set(file, cmd) { - const dir = p.dirname(file); - if (!fs.existsSync(dir)) { - throw new Error(`can't create hook, ${dir} directory doesn't exist (try running husky install)`); - } - fs.writeFileSync(file, `#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -${cmd} -`, { mode: 0o0755 }); - l(`created ${file}`); -} -exports.set = set; -function add(file, cmd) { - if (fs.existsSync(file)) { - fs.appendFileSync(file, `${cmd}\n`); - l(`updated ${file}`); - } - else { - set(file, cmd); - } -} -exports.add = add; -function uninstall() { - git(['config', '--unset', 'core.hooksPath']); -} -exports.uninstall = uninstall; diff --git a/node_modules/husky/package.json b/node_modules/husky/package.json deleted file mode 100644 index 079ddd7f..00000000 --- a/node_modules/husky/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "husky", - "version": "8.0.3", - "description": "Modern native Git hooks made easy", - "keywords": [ - "git", - "hooks", - "pre-commit" - ], - "homepage": "https://typicode.github.io/husky", - "repository": "typicode/husky", - "funding": "https://github.com/sponsors/typicode", - "license": "MIT", - "author": "Typicode ", - "bin": "lib/bin.js", - "main": "lib/index.js", - "files": [ - "lib", - "husky.sh" - ], - "scripts": { - "build": "tsc", - "test": "sh test/all.sh", - "lint": "eslint src --ext .ts", - "serve": "docsify serve docs", - "prepare": "npm run build && node lib/bin install" - }, - "devDependencies": { - "@commitlint/cli": "^17.3.0", - "@commitlint/config-conventional": "^17.3.0", - "@tsconfig/node14": "^1.0.3", - "@types/node": "^18.11.18", - "@typicode/eslint-config": "^1.1.0", - "docsify-cli": "^4.4.4", - "typescript": "^4.9.4" - }, - "engines": { - "node": ">=14" - } -}