From 926e9de5578cd15e8b2123895d29f6156e106a14 Mon Sep 17 00:00:00 2001 From: l4legenda Date: Sun, 10 Sep 2023 18:17:23 +0000 Subject: [PATCH 01/11] feat: support codespaces --- devcontainer.json | 3 +++ package.json | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 devcontainer.json diff --git a/devcontainer.json b/devcontainer.json new file mode 100644 index 00000000..ec29a5b4 --- /dev/null +++ b/devcontainer.json @@ -0,0 +1,3 @@ +{ + "forwardPorts": [3007, 3006, 8080] +} \ No newline at end of file diff --git a/package.json b/package.json index bfa8abaf..b32503fc 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "childScript": "cross-env-shell \"echo Hello $GREET\"", "gulp": "gulp", "test": "(cd packages/deeplinks; npm run test)", + "codespaces-prepare": "npm run gitpod-prepare", "gitpod-prepare": "npm run git-shh-to-https && sudo apt update && (yes | sudo apt install screen) && (yes | sudo apt install rsync) && (yes | sudo apt install net-tools) && screen -S docker -d -m sudo docker-up", "packages": "(npx gulp packages:get) && (npx gulp packages:ci)", "packages-ci": "(cd packages && for d in */; do (cd $d && npm ci); done)", @@ -31,6 +32,10 @@ "electron-build-core": "(cross-env npm_config_yes=true NEXT_PUBLIC_ENGINES=1 NEXT_PUBLIC_HIDEPATH=1 MIGRATIONS_ID_TYPE_SQL=bigint MIGRATIONS_ID_TYPE_GQL=bigint MIGRATIONS_HASURA_PATH=localhost:8080 MIGRATIONS_HASURA_SSL=0 MIGRATIONS_HASURA_SECRET=myadminsecretkey NEXT_PUBLIC_DEEPLINKS_SERVER=http://localhost:3007 NEXT_PUBLIC_GQL_PATH=localhost:3006/gql NEXT_PUBLIC_GQL_SSL=0 DEEPLINKS_HASURA_PATH=localhost:8080 DEEPLINKS_HASURA_SSL=0 MIGRATIONS_DEEPLINKS_APP_URL=http://host.docker.internal:3007 NEXT_PUBLIC_DEEPLINKS_URL=MIGRATIONS_DEEPLINKS_URL=http://host.docker.internal:3006 NEXT_PUBLIC_DEEPLINKS_URL=http://localhost:3006 DEEPLINKS_PUBLIC_URL=http://localhost:3006 npm run deepcase-build)", "electron-build-pack": "cd packages/deepcase-app/electron && npm run electron:pack", "electron-build-pack-demo": "cd packages/deepcase-app/electron && CSC_IDENTITY_AUTO_DISCOVERY=false npm run electron:pack-demo", + "codespaces-codespaces-name": "export CODESPACE_NAME=$(jq -r \".CODESPACE_NAME\" /workspaces/.codespaces/shared/environment-variables.json)", + "codespaces-variables": "npm run codespaces-codespaces-name", + "codespaces-init": "npm run codespaces-variables && npm run codespaces-prepare && npm ci && npm run packages && npm run apply-deeplinks && npm run apply-hasura", + "codespaces-start": "export NEXT_PUBLIC_ENGINES=0; export NEXT_PUBLIC_HIDEPATH=1; export npm_config_yes=true; export JWT_SECRET=\"{\\\"type\\\":\\\"HS256\\\",\\\"key\\\":\\\"3EK6FD+o0+c7tzBNVfjpMkNDi2yARAAKzQlk8O2IKoxQu4nF7EdAh8s3TwpHwrdWT6R\\\"}\" export MIGRATIONS_ID_TYPE_SQL=bigint; export MIGRATIONS_ID_TYPE_GQL=bigint; export MIGRATIONS_HASURA_PATH=localhost:8080; export DEEPLINKS_HASURA_PATH=localhost:8080; export MIGRATIONS_HASURA_SSL=1; export MIGRATIONS_HASURA_SECRET=myadminsecretkey; export DEEPLINKS_HASURA_SECRET=myadminsecretkey; export NEXT_PUBLIC_DEEPLINKS_SERVER=https://$(echo \"https://${CODESPACE_NAME}-3007.app.github.dev\" | awk -F[/:] '{print $4}'); export NEXT_PUBLIC_GQL_PATH=$(echo \"https://${CODESPACE_NAME}-3006.app.github.dev\" | awk -F[/:] '{print $4}')/gql; export NEXT_PUBLIC_GQL_SSL=1 DEEPLINKS_HASURA_PATH=localhost:8080; export MIGRATIONS_DEEPLINKS_APP_URL=$(echo \"https://${CODESPACE_NAME}-3007.app.github.dev\"); export MIGRATIONS_DEEPLINKS_URL=$(echo \"https://${CODESPACE_NAME}-3006.app.github.dev\"); export DEEPLINKS_PUBLIC_URL=$(echo \"https://${CODESPACE_NAME}-3006.app.github.dev\"); export NEXT_PUBLIC_DEEPLINKS_URL=$(echo \"https://${CODESPACE_NAME}-3006.app.github.dev\"); export DOCKER_DEEPLINKS_URL=http://host.docker.internal:3006; export DEEPLINKS_ROUTE_HANDLERS_HOST=host.docker.internal; concurrently \"npm run deepcase\" \"npm run deeplinks\" \"npm run gitpod-engine\" \"npm run sdk\" \"sleep 120 && npm run codespaces-hasura-reattach\"", "gitpod-init": "npm run gitpod-prepare && npm ci && npm run packages && npm run apply-deeplinks && npm run apply-hasura", "gitpod-start": "export NEXT_PUBLIC_ENGINES=0; export NEXT_PUBLIC_HIDEPATH=1; export npm_config_yes=true; export JWT_SECRET=\"{\\\"type\\\":\\\"HS256\\\",\\\"key\\\":\\\"3EK6FD+o0+c7tzBNVfjpMkNDi2yARAAKzQlk8O2IKoxQu4nF7EdAh8s3TwpHwrdWT6R\\\"}\" export MIGRATIONS_ID_TYPE_SQL=bigint; export MIGRATIONS_ID_TYPE_GQL=bigint; export MIGRATIONS_HASURA_PATH=$(echo $(gp url 8080) | awk -F[/:] '{print $4}'); export DEEPLINKS_HASURA_PATH=$(echo $(gp url 8080) | awk -F[/:] '{print $4}'); export MIGRATIONS_HASURA_SSL=1; export DEEPLINKS_HASURA_SSL=1; export MIGRATIONS_HASURA_SECRET=myadminsecretkey; export DEEPLINKS_HASURA_SECRET=myadminsecretkey; export NEXT_PUBLIC_DEEPLINKS_SERVER=https://$(echo $(gp url 3007) | awk -F[/:] '{print $4}'); export NEXT_PUBLIC_GQL_PATH=$(echo $(gp url 3006) | awk -F[/:] '{print $4}')/gql; export NEXT_PUBLIC_GQL_SSL=1 DEEPLINKS_HASURA_PATH=$(echo $(gp url 8080) | awk -F[/:] '{print $4}'); export DEEPLINKS_HASURA_SSL=1; export MIGRATIONS_DEEPLINKS_APP_URL=$(gp url 3007); export MIGRATIONS_DEEPLINKS_URL=$(gp url 3006); export DEEPLINKS_PUBLIC_URL=$(gp url 3006); export NEXT_PUBLIC_DEEPLINKS_URL=$(gp url 3006); export DOCKER_DEEPLINKS_URL=http://host.docker.internal:3006; export DEEPLINKS_ROUTE_HANDLERS_HOST=host.docker.internal; concurrently \"npm run deepcase\" \"npm run deeplinks\" \"npm run gitpod-engine\" \"npm run sdk\" \"sleep 120 && npm run gitpod-hasura-reattach\"", "gitpod-engine": "cd packages/deeplinks && npm run start-engine-docker", @@ -73,7 +78,8 @@ "gitpod-recreate": "npm run gitpod-unmigrate; npm run docker-clear; npm run rm-migrates; npm run gitpod-engine; npm run gitpod-migrate;", "local-reinit": "npm run docker-clear; npm run rm-migrates; npm run local-engine;", "gitpod-reinit": "npm run docker-clear; npm run rm-migrates; npm run gitpod-engine;", - "gitpod-hasura-reattach": "export REATTACH_HASURA_SECRET=myadminsecretkey; export REATTACH_HASURA_PATH=$(echo $(gp url 8080) | awk -F[/:] '{print $4}'); export REATTACH_HASURA_SSL=1; export REATTACH_DEEPLINKS_PATH=$(echo $(gp url 3006) | awk -F[/:] '{print $4}'); npx gulp gitpod:hasura:reattach" + "gitpod-hasura-reattach": "export REATTACH_HASURA_SECRET=myadminsecretkey; export REATTACH_HASURA_PATH=$(echo $(gp url 8080) | awk -F[/:] '{print $4}'); export REATTACH_HASURA_SSL=1; export REATTACH_DEEPLINKS_PATH=$(echo $(gp url 3006) | awk -F[/:] '{print $4}'); npx gulp gitpod:hasura:reattach", + "codespaces-hasura-reattach": "export REATTACH_HASURA_SECRET=myadminsecretkey; export REATTACH_HASURA_PATH=localhost:8080; export REATTACH_HASURA_SSL=0; export REATTACH_DEEPLINKS_PATH=host.docker.internal:3006; npx gulp gitpod:hasura:reattach" }, "repository": { "type": "git", From f2478200b68ec6699bc221323e9910a0eabdc5d7 Mon Sep 17 00:00:00 2001 From: l4legenda Date: Sun, 10 Sep 2023 18:23:11 +0000 Subject: [PATCH 02/11] update: devcontainer in folder .devcontainer --- devcontainer.json => .devcontainer/devcontainer.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename devcontainer.json => .devcontainer/devcontainer.json (100%) diff --git a/devcontainer.json b/.devcontainer/devcontainer.json similarity index 100% rename from devcontainer.json rename to .devcontainer/devcontainer.json From d56a312df65fdcd369b19fbd5396e7bdd1520232 Mon Sep 17 00:00:00 2001 From: l4legenda Date: Sun, 10 Sep 2023 19:02:59 +0000 Subject: [PATCH 03/11] update: devcontainer --- .devcontainer/devcontainer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ec29a5b4..54f04be1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,3 +1,9 @@ { - "forwardPorts": [3007, 3006, 8080] + "name": "Node.js", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/javascript-node:0-18-bullseye", + "features": {}, + "forwardPorts": [3007, 3006, 8080], + "initializeCommand": "{ npm i -g npm; npm ci; npm run codespaces-init; docker pull deepf/deeplinks:main; docker run -v $(pwd)/packages/deeplinks:/deeplinks --rm --name links --entrypoint \"sh\" deepf/deeplinks:main -c \"cp -r /snapshots/* /deeplinks/snapshots/ && chown -R 33333:33333 /deeplinks/snapshots/\"; (cd packages/deeplinks && npm run snapshot:last); npm install -g concurrently; npm run gitpod-engine; npm cache clean --force; };", + "postCreateCommand": "(cd packages/deeplinks; if git merge-base --is-ancestor origin/main main; then echo ''; else ( echo 'NEED TO PULL DEEPLINKS!'; git checkout main; git pull; cd ../../; npm run apply-deeplinks); fi) && (cd packages/deepcase-app; if (git merge-base --is-ancestor origin/main main); then echo ''; else ( echo 'NEED TO PULL DEEPCASE!'; git checkout main; git pull; npm ci); fi) && npm run codespaces-start;", } \ No newline at end of file From 89900b4898bfe0e6ff3dfcc03f78147d84d2e763 Mon Sep 17 00:00:00 2001 From: l4legenda Date: Mon, 11 Sep 2023 01:35:30 +0500 Subject: [PATCH 04/11] Update devcontainer.json --- .devcontainer/devcontainer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 54f04be1..50b3cc0a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,7 @@ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/javascript-node:0-18-bullseye", "features": {}, - "forwardPorts": [3007, 3006, 8080], + "forwardPorts": [3007, 3006, 4000, 8080], "initializeCommand": "{ npm i -g npm; npm ci; npm run codespaces-init; docker pull deepf/deeplinks:main; docker run -v $(pwd)/packages/deeplinks:/deeplinks --rm --name links --entrypoint \"sh\" deepf/deeplinks:main -c \"cp -r /snapshots/* /deeplinks/snapshots/ && chown -R 33333:33333 /deeplinks/snapshots/\"; (cd packages/deeplinks && npm run snapshot:last); npm install -g concurrently; npm run gitpod-engine; npm cache clean --force; };", "postCreateCommand": "(cd packages/deeplinks; if git merge-base --is-ancestor origin/main main; then echo ''; else ( echo 'NEED TO PULL DEEPLINKS!'; git checkout main; git pull; cd ../../; npm run apply-deeplinks); fi) && (cd packages/deepcase-app; if (git merge-base --is-ancestor origin/main main); then echo ''; else ( echo 'NEED TO PULL DEEPCASE!'; git checkout main; git pull; npm ci); fi) && npm run codespaces-start;", -} \ No newline at end of file +} From c4c39542595c8a3d1a1fe076d21a19e3d089ebcc Mon Sep 17 00:00:00 2001 From: l4legenda Date: Mon, 11 Sep 2023 10:13:47 +0500 Subject: [PATCH 05/11] Create prepare-codespace.sh --- .devcontainer/prepare-codespace.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 .devcontainer/prepare-codespace.sh diff --git a/.devcontainer/prepare-codespace.sh b/.devcontainer/prepare-codespace.sh new file mode 100644 index 00000000..e9067ffc --- /dev/null +++ b/.devcontainer/prepare-codespace.sh @@ -0,0 +1 @@ +{ npm i -g npm; npm ci; npm run codespaces-init; docker pull deepf/deeplinks:main; docker run -v $(pwd)/packages/deeplinks:/deeplinks --rm --name links --entrypoint "sh" deepf/deeplinks:main -c "cp -r /snapshots/* /deeplinks/snapshots/ && chown -R 33333:33333 /deeplinks/snapshots/"; (cd packages/deeplinks && npm run snapshot:last); npm install -g concurrently; npm run gitpod-engine; npm cache clean --force; }; From a2bbc7df70abbc131d5e40e613429bb875a4b0b2 Mon Sep 17 00:00:00 2001 From: l4legenda Date: Mon, 11 Sep 2023 10:14:25 +0500 Subject: [PATCH 06/11] Create start-codespace.sh --- .devcontainer/start-codespace.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 .devcontainer/start-codespace.sh diff --git a/.devcontainer/start-codespace.sh b/.devcontainer/start-codespace.sh new file mode 100644 index 00000000..ef451562 --- /dev/null +++ b/.devcontainer/start-codespace.sh @@ -0,0 +1 @@ +(cd packages/deeplinks; if git merge-base --is-ancestor origin/main main; then echo ''; else ( echo 'NEED TO PULL DEEPLINKS!'; git checkout main; git pull; cd ../../; npm run apply-deeplinks); fi) && (cd packages/deepcase-app; if (git merge-base --is-ancestor origin/main main); then echo ''; else ( echo 'NEED TO PULL DEEPCASE!'; git checkout main; git pull; npm ci); fi) && npm run codespaces-start; From ad8de5215cff7b6a6bada3971858ba25b5f8200a Mon Sep 17 00:00:00 2001 From: l4legenda Date: Mon, 11 Sep 2023 10:15:31 +0500 Subject: [PATCH 07/11] Update devcontainer.json --- .devcontainer/devcontainer.json | 42 +++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 50b3cc0a..fb6ce356 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,9 +1,37 @@ { - "name": "Node.js", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/javascript-node:0-18-bullseye", - "features": {}, - "forwardPorts": [3007, 3006, 4000, 8080], - "initializeCommand": "{ npm i -g npm; npm ci; npm run codespaces-init; docker pull deepf/deeplinks:main; docker run -v $(pwd)/packages/deeplinks:/deeplinks --rm --name links --entrypoint \"sh\" deepf/deeplinks:main -c \"cp -r /snapshots/* /deeplinks/snapshots/ && chown -R 33333:33333 /deeplinks/snapshots/\"; (cd packages/deeplinks && npm run snapshot:last); npm install -g concurrently; npm run gitpod-engine; npm cache clean --force; };", - "postCreateCommand": "(cd packages/deeplinks; if git merge-base --is-ancestor origin/main main; then echo ''; else ( echo 'NEED TO PULL DEEPLINKS!'; git checkout main; git pull; cd ../../; npm run apply-deeplinks); fi) && (cd packages/deepcase-app; if (git merge-base --is-ancestor origin/main main); then echo ''; else ( echo 'NEED TO PULL DEEPCASE!'; git checkout main; git pull; npm ci); fi) && npm run codespaces-start;", + "name": "Ubuntu", + "image": "mcr.microsoft.com/devcontainers/base:jammy", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/git:1": {}, + "ghcr.io/devcontainers-contrib/features/npm-package:1": {}, + "ghcr.io/wxw-matt/devcontainer-features/command_runner:0": {}, + "ghcr.io/devcontainers/features/node:1": {}, + "ghcr.io/devcontainers-contrib/features/bash-command:1": {} + }, + "forwardPorts": [ + 3007, + 4000, + 3006, + 8080 + ], + "onCreateCommand": { + "add_prepare_command": ["chmod", "+x", ".devcontainer/prepare-codespace.sh"], + "prepare": [".devcontainer/prepare-codespace.sh"] + }, + "postStartCommand": { + "add_prepare_command": ["chmod", "+x", ".devcontainer/start-codespace.sh"], + "prepare": [".devcontainer/start-codespace.sh"] + }, + "portsAttributes": { + "3006": { + "label": "Deep.Links" + }, + "3007": { + "label": "Deep.Case" + }, + "8080": { + "label": "Hasura" + } + } } From a6770c8e6bfa644dada6c47cadbc8cdae40ee5d3 Mon Sep 17 00:00:00 2001 From: l4legenda Date: Mon, 11 Sep 2023 10:32:34 +0500 Subject: [PATCH 08/11] Update prepare-codespace.sh --- .devcontainer/prepare-codespace.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/prepare-codespace.sh b/.devcontainer/prepare-codespace.sh index e9067ffc..b70fcdff 100644 --- a/.devcontainer/prepare-codespace.sh +++ b/.devcontainer/prepare-codespace.sh @@ -1 +1,2 @@ +#!/bin/bash { npm i -g npm; npm ci; npm run codespaces-init; docker pull deepf/deeplinks:main; docker run -v $(pwd)/packages/deeplinks:/deeplinks --rm --name links --entrypoint "sh" deepf/deeplinks:main -c "cp -r /snapshots/* /deeplinks/snapshots/ && chown -R 33333:33333 /deeplinks/snapshots/"; (cd packages/deeplinks && npm run snapshot:last); npm install -g concurrently; npm run gitpod-engine; npm cache clean --force; }; From d1e57108d42484155a2320f513d741dd1f2d8f1c Mon Sep 17 00:00:00 2001 From: l4legenda Date: Mon, 11 Sep 2023 10:33:05 +0500 Subject: [PATCH 09/11] Update prepare-codespace.sh From 4490e170f5ec92252b5682df8e6882511878a0a0 Mon Sep 17 00:00:00 2001 From: l4legenda Date: Mon, 11 Sep 2023 18:11:38 +0000 Subject: [PATCH 10/11] update: #!/bin/bash --- .devcontainer/start-codespace.sh | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 .devcontainer/start-codespace.sh diff --git a/.devcontainer/start-codespace.sh b/.devcontainer/start-codespace.sh old mode 100644 new mode 100755 index ef451562..0b12b38d --- a/.devcontainer/start-codespace.sh +++ b/.devcontainer/start-codespace.sh @@ -1 +1,2 @@ +#!/bin/bash (cd packages/deeplinks; if git merge-base --is-ancestor origin/main main; then echo ''; else ( echo 'NEED TO PULL DEEPLINKS!'; git checkout main; git pull; cd ../../; npm run apply-deeplinks); fi) && (cd packages/deepcase-app; if (git merge-base --is-ancestor origin/main main); then echo ''; else ( echo 'NEED TO PULL DEEPCASE!'; git checkout main; git pull; npm ci); fi) && npm run codespaces-start; From 6382b46fdba53369a0f9e151a66f484dfe0b0a6c Mon Sep 17 00:00:00 2001 From: l4legenda Date: Tue, 12 Sep 2023 19:47:45 +0500 Subject: [PATCH 11/11] Update devcontainer.json --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index fb6ce356..eaaa2642 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,7 +7,8 @@ "ghcr.io/devcontainers-contrib/features/npm-package:1": {}, "ghcr.io/wxw-matt/devcontainer-features/command_runner:0": {}, "ghcr.io/devcontainers/features/node:1": {}, - "ghcr.io/devcontainers-contrib/features/bash-command:1": {} + "ghcr.io/devcontainers-contrib/features/bash-command:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} }, "forwardPorts": [ 3007,