From 4a25fa6b554a35f3d4c2129fc82b85b0766f8353 Mon Sep 17 00:00:00 2001 From: Neo Ryo Date: Wed, 10 Apr 2024 09:02:12 +0200 Subject: [PATCH 1/9] WIP --- server/entities/country.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 server/entities/country.ts diff --git a/server/entities/country.ts b/server/entities/country.ts new file mode 100644 index 000000000..1853b8e72 --- /dev/null +++ b/server/entities/country.ts @@ -0,0 +1,13 @@ +import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; + +@Entity() +export class Country { + @PrimaryGeneratedColumn() + public id: number; + + @Column({ type: 'text', nullable: false }) + public code: string; + + @Column({ type: 'text', nullable: false }) + public name: string; +} From b3d5117bab72981de9796e02953bd530646d569e Mon Sep 17 00:00:00 2001 From: Neo Ryo Date: Wed, 10 Apr 2024 11:31:23 +0200 Subject: [PATCH 2/9] add new table country + migration and seed all country --- server/entities/country.ts | 2 +- .../1712732757287-New-Country-Table.ts | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 server/migrations/1712732757287-New-Country-Table.ts diff --git a/server/entities/country.ts b/server/entities/country.ts index 1853b8e72..57b12e498 100644 --- a/server/entities/country.ts +++ b/server/entities/country.ts @@ -6,7 +6,7 @@ export class Country { public id: number; @Column({ type: 'text', nullable: false }) - public code: string; + public isoCode: string; @Column({ type: 'text', nullable: false }) public name: string; diff --git a/server/migrations/1712732757287-New-Country-Table.ts b/server/migrations/1712732757287-New-Country-Table.ts new file mode 100644 index 000000000..267ae846e --- /dev/null +++ b/server/migrations/1712732757287-New-Country-Table.ts @@ -0,0 +1,26 @@ +import type { MigrationInterface, QueryRunner } from 'typeorm'; + +import { countries } from '../utils/iso-3166-countries-french'; + +export class NewCountryTable1712732757287 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE IF NOT EXISTS country ( + id int PRIMARY KEY AUTO_INCREMENT, + isoCode varchar(3) UNIQUE NOT NULL, + name varchar(255) UNIQUE NOT NULL + );`); + // seed country in db + for (const country of countries) { + // try catch here to prevent if country is already set in db for some reason + try { + await queryRunner.query(`INSERT INTO country (isoCode, name) VALUES ("${country.isoCode}", "${country.name}");`); + } catch (error) { + console.error(error); + } + } + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE IF EXISTS country;`); + } +} From 6a30e0dc378dc426d1749165af819ce74f60d7fb Mon Sep 17 00:00:00 2001 From: Neo Ryo Date: Fri, 12 Apr 2024 14:08:33 +0200 Subject: [PATCH 3/9] commit --- .pnp.cjs | 11 +++++++++++ .../husky-npm-9.0.11-227bb1e4e4-1aebc3334d.zip | Bin 0 -> 3368 bytes package.json | 12 +++++++++++- yarn.lock | 10 ++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 .yarn/cache/husky-npm-9.0.11-227bb1e4e4-1aebc3334d.zip diff --git a/.pnp.cjs b/.pnp.cjs index 777f16989..9ad838076 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -120,6 +120,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["geojson", "npm:0.5.0"],\ ["helmet", "npm:5.1.1"],\ ["html-to-draftjs", "virtual:f84dba857fa10247bbb4af28a825f1d91a188c858b2b2b1b4a2d3cfedf850e14647ec99dabfb1535752c99ec0ff164e2ec4fb4c32c822be66b30b3cfa4630990#npm:1.5.0"],\ + ["husky", "npm:9.0.11"],\ ["immutable", "npm:4.3.0"],\ ["jest", "virtual:f84dba857fa10247bbb4af28a825f1d91a188c858b2b2b1b4a2d3cfedf850e14647ec99dabfb1535752c99ec0ff164e2ec4fb4c32c822be66b30b3cfa4630990#npm:28.1.1"],\ ["json-stable-stringify", "npm:1.0.2"],\ @@ -267,6 +268,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["geojson", "npm:0.5.0"],\ ["helmet", "npm:5.1.1"],\ ["html-to-draftjs", "virtual:f84dba857fa10247bbb4af28a825f1d91a188c858b2b2b1b4a2d3cfedf850e14647ec99dabfb1535752c99ec0ff164e2ec4fb4c32c822be66b30b3cfa4630990#npm:1.5.0"],\ + ["husky", "npm:9.0.11"],\ ["immutable", "npm:4.3.0"],\ ["jest", "virtual:f84dba857fa10247bbb4af28a825f1d91a188c858b2b2b1b4a2d3cfedf850e14647ec99dabfb1535752c99ec0ff164e2ec4fb4c32c822be66b30b3cfa4630990#npm:28.1.1"],\ ["json-stable-stringify", "npm:1.0.2"],\ @@ -11947,6 +11949,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["husky", [\ + ["npm:9.0.11", {\ + "packageLocation": "./.yarn/cache/husky-npm-9.0.11-227bb1e4e4-1aebc3334d.zip/node_modules/husky/",\ + "packageDependencies": [\ + ["husky", "npm:9.0.11"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["iconv-lite", [\ ["npm:0.4.24", {\ "packageLocation": "./.yarn/cache/iconv-lite-npm-0.4.24-c5c4ac6695-bd9f120f5a.zip/node_modules/iconv-lite/",\ diff --git a/.yarn/cache/husky-npm-9.0.11-227bb1e4e4-1aebc3334d.zip b/.yarn/cache/husky-npm-9.0.11-227bb1e4e4-1aebc3334d.zip new file mode 100644 index 0000000000000000000000000000000000000000..016e634e6a403e7c17d8935f8aade88e8c3e1f81 GIT binary patch literal 3368 zcmaKuc|4SD7stog*JPNijeR#LudG>y3}ZZI5VA9peKK~6vMaL7zDLLwDY7K8j_pOL zQNlxc3`$QZyhC|<^3i+UpX<{&-37Uh&j~659>*0xU zv~l;u__#UZqz!+&6?Am#6(5{yzz+i;faZWL*LdTl02u&KN}BA)8yuLqCyeMlmtl>p zPA^qZj)T!#H4&oq3^STymcqqEVK36|30ESD-(${f6YrT;35d+jyD^4mx+q#d}sytQfqIx z`}#c{TGPuylWBT$Vt3{8Q+8w?k=T8!cVqo;l>+>W?T$>#kO_Tv!giE%QAMlKi9^ToQklcSIOiCfpwL8F}H@R)Fr@5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z-MQIyGXVz-xZTTTYZV|HRWrg=Pm7XcT%L+`704=8pUM3N1$F3P%PuI+(*3I8IZt}Sb$hCHF^ zZii~P7!O-u$O$;gEOh=^%!BvJ)y*ZUBYMb^Kl(rSxVoO3)nV#pz4(&aCtJ!?I@vlX z|5>Om@@(K=^Jri=Drd@Iz1M}^j^R8Y=}v4TSIMpmqy5t+8x~Sp zC1sYmzJa^depL^9IRZ$WBuLVvdHQ%^`kq%9sJk}~@j$dkS{wz}MIt2eVko!-9s%tg z7&01$_e$0^qD7%%eFKP>;j)#a?uHDgM*jPzlyua=Skc)3{33_{&vd^@Jsc|<5~SrX zriU%-_p=ZGouf_bA)xq% Date: Fri, 12 Apr 2024 14:09:40 +0200 Subject: [PATCH 4/9] commit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cfa261d87..fa9504de0 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "typeorm": "typeorm-ts-node-commonjs", "prepare": "husky", "pre-push": "yarn lint && yarn build", - "pre-commit": "echo 'Atomic commits are greats!'" + "pre-commit": "echo Atomic commits are greats!" }, "husky": { "hooks": { From f42d8558ad3b55c09d5d1c08b37e90e72df54f87 Mon Sep 17 00:00:00 2001 From: Neo Ryo Date: Fri, 12 Apr 2024 14:11:55 +0200 Subject: [PATCH 5/9] commit --- .gitignore | 4 +++- package.json | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index bf585a7e0..6296786ef 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,6 @@ test.html docker-compose.build.yml docker-compose.bdd.yml -*.http \ No newline at end of file +*.http + +.husky/ \ No newline at end of file diff --git a/package.json b/package.json index fa9504de0..b444cc61a 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ }, "husky": { "hooks": { - "pre-push": "yarn pre-push", - "pre-commit": "yarn pre-commit" + "pre-push": "yarn pre-push", + "pre-commit": "yarn pre-commit" } }, "jest": { From 74be553ff3f053607ee8d4e901886511390737e0 Mon Sep 17 00:00:00 2001 From: Neo Ryo Date: Fri, 12 Apr 2024 14:41:26 +0200 Subject: [PATCH 6/9] prepare husky file --- prepareHusky.mjs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 prepareHusky.mjs diff --git a/prepareHusky.mjs b/prepareHusky.mjs new file mode 100644 index 000000000..ee0e00e20 --- /dev/null +++ b/prepareHusky.mjs @@ -0,0 +1,25 @@ +/* eslint-disable no-console */ +import fs from 'fs'; + +function checkHuskyFolder() { + const pathHuskyDir = './.husky'; + const huskyFolderExists = fs.existsSync(pathHuskyDir); + if (!huskyFolderExists) { + // eslint-disable-next-line no-undef + const msg = 'You must run the following command first command\n- npx husky init && node ./prepareHusky.mjs'; + // console.log('Husky pre-push setup created!!'); + throw msg; + } else { + fs.unlink(pathHuskyDir + '/pre-commit', (err) => { + // eslint-disable-next-line no-undef + if (err) console.log('No pre-commit file found'); + }); + fs.writeFile(`${pathHuskyDir}/pre-push`, 'yarn pre-push', { ovewrite: true }, function (err) { + if (err) throw err; + // eslint-disable-next-line no-undef + console.log('Husky setup done!!'); + }); + } +} + +checkHuskyFolder(); From 753fe92f38a6f0cc83aeefe05ad284a5a4b43c83 Mon Sep 17 00:00:00 2001 From: Neo Ryo Date: Fri, 12 Apr 2024 14:42:35 +0200 Subject: [PATCH 7/9] done --- prepareHusky.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prepareHusky.mjs b/prepareHusky.mjs index ee0e00e20..108b7f00c 100644 --- a/prepareHusky.mjs +++ b/prepareHusky.mjs @@ -17,7 +17,7 @@ function checkHuskyFolder() { fs.writeFile(`${pathHuskyDir}/pre-push`, 'yarn pre-push', { ovewrite: true }, function (err) { if (err) throw err; // eslint-disable-next-line no-undef - console.log('Husky setup done!!'); + console.log('Husky setup Ok!'); }); } } From 736f681ff537efbe0c85ba6e55cccea30eacc3dc Mon Sep 17 00:00:00 2001 From: Neo Ryo Date: Fri, 12 Apr 2024 14:44:23 +0200 Subject: [PATCH 8/9] cleaned package json --- package.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/package.json b/package.json index b444cc61a..424902819 100644 --- a/package.json +++ b/package.json @@ -26,14 +26,7 @@ "migration:revert-dev": "rm -rf dist && yarn build:server && npx typeorm migration:revert -d dist/server/utils/data-source.js || true", "typeorm": "typeorm-ts-node-commonjs", "prepare": "husky", - "pre-push": "yarn lint && yarn build", - "pre-commit": "echo Atomic commits are greats!" - }, - "husky": { - "hooks": { - "pre-push": "yarn pre-push", - "pre-commit": "yarn pre-commit" - } + "pre-push": "yarn lint && yarn build" }, "jest": { "testEnvironment": "node", From 74a699e6e1228ce33b18475379eb6725acaacc69 Mon Sep 17 00:00:00 2001 From: Neo Ryo Date: Fri, 12 Apr 2024 14:50:15 +0200 Subject: [PATCH 9/9] only build and remove husky hooks not working from package.json --- package.json | 3 +-- prepareHusky.mjs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 424902819..fe59e9571 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ "migration:run-dev": "rm -rf dist && yarn build:server && yarn typeorm migration:run -d dist/server/utils/data-source.js || true", "migration:revert-dev": "rm -rf dist && yarn build:server && npx typeorm migration:revert -d dist/server/utils/data-source.js || true", "typeorm": "typeorm-ts-node-commonjs", - "prepare": "husky", - "pre-push": "yarn lint && yarn build" + "prepare": "husky" }, "jest": { "testEnvironment": "node", diff --git a/prepareHusky.mjs b/prepareHusky.mjs index 108b7f00c..aff3d15bf 100644 --- a/prepareHusky.mjs +++ b/prepareHusky.mjs @@ -14,7 +14,7 @@ function checkHuskyFolder() { // eslint-disable-next-line no-undef if (err) console.log('No pre-commit file found'); }); - fs.writeFile(`${pathHuskyDir}/pre-push`, 'yarn pre-push', { ovewrite: true }, function (err) { + fs.writeFile(`${pathHuskyDir}/pre-push`, 'yarn build', { ovewrite: true }, function (err) { if (err) throw err; // eslint-disable-next-line no-undef console.log('Husky setup Ok!');