Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto activate intelephense if license key is available #165

Closed
strausmann opened this issue Dec 18, 2021 · 8 comments
Closed

Auto activate intelephense if license key is available #165

strausmann opened this issue Dec 18, 2021 · 8 comments
Assignees
Labels
enhancement New feature or request passed-dev-qa Optional state. Use this when QAing other peoples fixes in another branch.ready to be merged to main

Comments

@strausmann
Copy link
Contributor

Problem this feature will solve

every time you start a new GitPod you have to enter your license number for intelephense again. According to the FAQ of intelephense you can create the license in the file $HOME/intelephense/licence.txt and intelephense will be activated automatically.

Proposed Solution

Store the license as GitPod Env, e.g. with the KEY "INTELEPHENSE_LICENSEKEY". If this ENV is present at the start of the GitPod, it should be written into the file $HOME/intelephense/licence.txt.

@strausmann strausmann added the enhancement New feature or request label Dec 18, 2021
@apolopena
Copy link
Owner

Is there is a free key we can use for QA?
Do you know if the key is checked on a workspace restart? If so we will need to persist $HOME/intelephense/licence.txt.

@strausmann
Copy link
Contributor Author

No a free Key is not available, but I have a Key and can do the QA. I think the Key will only be imported. When i enter the Key via VSCode I cant find the Key here $HOME/intelephense/licence.txt

@apolopena
Copy link
Owner

apolopena commented Dec 20, 2021

No a free Key is not available, but I have a Key and can do the QA. I think the Key will only be imported. When i enter the Key via VSCode I cant find the Key here $HOME/intelephense/licence.txt

It looks like $HOME/intelephense/licence.txt has to be generated manually. It also seems like $HOME/intelephense/licence.txt would need to exist before the gitpod vscode container is loaded. I will give you a code snippet and a test plan to try and we can figure it out.

Lastly as of the time of writing this I do belive that without the expiremental beta 'backup workspace' gitpod option turned on by the gitpod admins any files/directories in `$HOME would need to be manually backed up after a workspace stops.

I tend to lean away from adding functionality into the core files that I cannot test. The automagic Intellephense key file could be implemented per project in init-project.sh. This is exactly the kind of thing init-project.sh was designed for. This way if Intellephense changes how their key should be implmented then the core files wont need to be changed to reflect that.
Either way though if you find that adding a code snippet to init-project.sh for each project you build to be too cumbersome we could put it in the core files if it is tested well since it is pretty simple functionality after all and it is unlikely that Intelliphense would change how to implement their key.

@apolopena
Copy link
Owner

@strausmann
The fix for now ( I wrote this blind but it should work ):

  1. Set the environment varaible INTELEPHENSE_LICENSEKEY in your Gitpod dashboard (settings). Set the value to your Intelliphense key.
  2. Put the below code block in a fresh project built from your fork in .gp/bash/init-project.sh push the change to remote, build the workspace and see if Intelliphense recognizes the dynamically generated $HOME/intelephense/licence.txt file.
if [[ -n $INTELLIPHENSE_LICENSEKEY ]]; then
 mkdir -p "$HOME/intelliphense"
 echo "$INTELLIPHENSE_LICENSEKEY" > "$HOME/intelliphense/license.txt"
fi
  1. Verify that your environment variable set in step 1 is present by running: echo "$INTELEPHENSE_LICENSEKEY"
  2. Once step 3 is verified, verify that $HOME/intelephense/licence.txt was indeed generated and contains a single value equal to the Intelliphense license key that you set in the Gitpod dashboard by running the below command after the terminal opens in the gitpod VS-Code IDE.
cat ~/intelliphense/license.txt

Let me know the results of 1, 2, 3 and 4 and then we will proceed from there.

@strausmann
Copy link
Contributor Author

Dear @apolopena

I have now tried the whole thing once. Had been somewhat problematic.

Shortly to the info, in your samples the paths and the name of the licence.txt were not correct. Therefore here again my code block with which it worked.

Using the code block in the init-project.sh is unfortunately way too late if you don't use a prebuild. Therefore it makes more sense to use the block in the before-tasks.sh. Because the license file is deleted after a restart of the workspace.

Why too late? If the user opens a PHP file before the init-project.sh has run, the extension will be loaded and the license file will be checked, if it exists. But since this may not have been created yet, because init-project.sh runs really late, it will not work on images that have not been prebuilt with a prebuild.

if [[ -n $INTELEPHENSE_LICENSEKEY ]]; then
log "Notice: Intelephense Licensekey found, push to $HOME/intelephense/licence.txt"
 mkdir -p "$HOME/intelephense"
 echo "$INTELEPHENSE_LICENSEKEY" > "$HOME/intelephense/licence.txt"
fi

image

image

@apolopena
Copy link
Owner

Sounds fair., thank for explaining the timing and results of your tests. I will work on integrating this into the development branch. Thank you.

@apolopena apolopena added this to the v1.4 release 🚀 milestone Jan 22, 2022
@apolopena apolopena changed the title Auto activate intelephense if licensenkey is available Auto activate intelephense if license key is available Jan 22, 2022
apolopena added a commit that referenced this issue Jan 22, 2022
@apolopena
Copy link
Owner

apolopena commented Jan 22, 2022

@strausmann
Copy link
Contributor Author

Successfully tested. License was detected and activated the first time a PHP file was opened.

@apolopena apolopena added passed-dev-qa Optional state. Use this when QAing other peoples fixes in another branch.ready to be merged to main and removed in-dev-qa labels Jan 22, 2022
apolopena added a commit that referenced this issue Jan 28, 2022
* Update starter.ini

* Update init-gitpod.sh

* Update .gitpod.Dockerfile

Update xdebug configuration to own config file for ioncube support
Add global composer bin folder to $PATH
Add update-ca-certificates

* Update .gitpod.Dockerfile

Add composer bin to $PATH

* Update .gitpod.Dockerfile

* Update ioncube setup

* Update README.md

Fix #153

* Update utils.sh

Fix #152

* Update before-tasks.sh

Fix #151

* Update starter.ini

Fix #149

* Update update-pma-pws-help.txt

Fix #147

* Update README.md

Fix #147

* Update start-server.sh

Fix #145

* BaseImage PHP8

* Update to PHP 8.0

* Update .gitpod.Dockerfile

* Update to PHP 8.0

Fix #155

* Fix PHP8 Path

* Fix PHP 8 Path

* Clear APT lists

* Add Workspace/Project composer bin folder to $PATH

* Add Workspace/Project composer bin folder to $PATH

* Update update-pma-pws-help.txt

* Update .gitpod.yml

* optional php7.4 install

* optional php7.4 install

* 🐛 FIX: optional php7.4 install: add sudo

* 🐛 FIX: optional php7.4 install: in progress

* 🐛 FIX: optional php7.4 install: in progress

* 🐛 FIX: optional php7.4 install: in progress

* ♻️ REFACTOR: comments and #156

* ♻️ REFACTOR: #157 in progress

* ♻️ REFACTOR: Consolidate docker layers: in progress

* 🐛 FIX: 157: consolidate docker layers: bad file names in first RUN instruction

* 🐛 FIX: 157: consolidate docker layers: debug missing tmp file

* 🤖 TEST: 157: consolidate docker layers: use /var/tmp rather than /tmp

* 🐛 FIX: 157: consolidate docker layers: swap gitpod apt-get install function for standard one that doesnt rm /tmp

* 🐛 FIX: 157: consolidate docker layers: swap gitpod apt-get install function for standard one that doesnt rm /tmp

* 🐛 FIX: 157: consolidate docker layers: swap gitpod apt-get install function for standard one that doesnt rm /tmp

* 🐛 FIX: 157: consolidate docker layers: swap gitpod apt-get install function for standard one that doesnt rm /tmp

* 👌 IMPROVE: 156 Install core, additional and optional PHP version packages

* ➕ ADD: get php major and minor version

* 🤖 TEST: force docker image build

* 🐛 FIX: log for unsupported php version in starter.ini

* 🐛 FIX: use array for package args rather than a string

* 🤖 TEST: force docker image build

* 👌 IMPROVE: log messages when swapping php versions

* 🤖 TEST: force docker image build

* 👌 IMPROVE: log messages when swapping php versions

* 💡 UPDATE COMMENTS: everytime should be two words

* 🐛 FIX: capitalize you

* 💡 UPDATE COMMENTS: capitalize the word you in first bullet point of securing phpMyAdmin

* 📖 DOC: make Technology lowercase in Welcome section

* 💡 UPDATE COMMENTS: must be run as a sudo user

* 🐛 FIX: move composer bin to /home/apena/.nvm/versions/node/v12.4.0/bin:/home/apena/go/bin:/home/apena/.local/bin:/home/apena/bin:/usr/local/bin:/home/apena/.vscode-server/bin/fe719cd3e5825bf14e14182fddeb88ee8daf044f/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/PROGRAM FILES/DELL/DW WLAN CARD:/mnt/c/PROGRAM FILES/INTEL/ICLS CLIENT/:/mnt/c/WINDOWS/SYSTEM32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/SYSTEM32/WBEM:/mnt/c/WINDOWS/SYSTEM32/WINDOWSPOWERSHELL/V1.0/:/mnt/c/WINDOWS/SYSTEM32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/SYSTEM32/WBEM:/mnt/c/WINDOWS/SYSTEM32/WINDOWSPOWERSHELL/V1.0/:/mnt/c/WINDOWS/SYSTEM32/OPENSSH/:/mnt/c/PROGRAMDATA/CHOCOLATEY/BIN:/mnt/c/HASHICORP/VAGRANT/BIN:/mnt/c/PROGRAM FILES (X86)/MELD/:/mnt/c/PROGRAM FILES (X86)/INTEL/INTEL(R) MANAGEMENT ENGINE COMPONENTS/DAL:/mnt/c/PROGRAM FILES/INTEL/INTEL(R) MANAGEMENT ENGINE COMPONENTS/DAL:/mnt/c/WINDOWS/SYSTEM32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/SYSTEM32/WBEM:/mnt/c/WINDOWS/SYSTEM32/WINDOWSPOWERSHELL/V1.0/:/mnt/c/WINDOWS/SYSTEM32/OPENSSH/:/mnt/c/USERS/PENAV/APPDATA/ROAMING/NVM:/mnt/c/PROGRAM FILES/NODEJS:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Python27/:/mnt/c/Python27/Scripts:/mnt/c/Users/penav/AppData/Local/Programs/Python/Python38/:/mnt/c/Users/penav/AppData/Local/Programs/Python/Python38/Scripts/:/mnt/c/Users/penav/.poetry/bin:/mnt/c/Users/penav/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/MongoDB/Server/4.2/bin:/mnt/c/Program Files/heroku/bin:/mnt/c/Users/penav/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin:/mnt/c/Users/penav/AppData/Roaming/nvm:/mnt/c/Program Files/nodejs:/mnt/c/Users/penav/AppData/Local/Programs/Microsoft VS Code/bin:/usr/local/go/bin:/home/apena/.config/yarn/global/node_modules/.bin block above setting of initialized flag

* move composer bin to PATH block above setting of initialized flag

* ➕ ADD: dynamic xdebug install

* 🐛 FIX: typos/syntax errors

* 🤖 TEST: force docker image build

* 🐛 FIX: generate xdebug conf

* 🤖 TEST: force docker image build

* 🐛 FIX: xdebug conf not generating

* 🤖 TEST: force docker image build

* 🐛 FIX: xdebug.ini name

* 🤖 TEST: hardcoded php version

* 🤖 TEST: force docker image build

* 🤖 TEST: reverting code

* 🐛 FIX: bad log syntax and set phpize specifically

* 🤖 TEST: install-xdebug.sh

* 🐛 FIX: missing phpize

* 🤖 TEST: force docker image build

* 🤖 TEST: hardcoded php version to 7.4 for now

* 🤖 TEST: hardcode phpize path for php7.4 for now

* ➕ ADD: libapache2-mod-php7.4 and --set php-config

* 🤖 TEST: force docker image build

* ♻️ REFACTOR: #156

* ⚰️ REMOVE: extraneous file

* ♻️ REFACTOR: #156

* 🤖 TEST: force docker image build

* 🤖 TEST: Gitpod us cluster is unstable, forcing docker image build

* 🤖 TEST: force docker image build

* 🤖 TEST: force docker

* ♻️ REFACTOR: #156

* Add GnuPG Support

* Update .gitpod.Dockerfile

* Add Log Notice and Description

Fix #170

* 🐛 FIX: rebuild package list

* 🤖 TEST: build docker image

* 🐛 FIX: try conditionally disabling php module for apache before installing php

* 🤖 TEST: docker image build

* 🤖 TEST: trying to properly purge gp installed php

* 🤖 TEST: docker

* 🤖 TEST: trying to properly purge gp installed php

* 🤖 TEST: docker

* 🐛 FIX: php-fpm conf path

* 🤖 TEST: docker

* 🐛 FIX: apache conf getting overwritten by potential php install

* 🐛 FIX: php-fpm.conf path

* 🤖 TEST: docker

* ♻️ REFACTOR: autogeneration of php-fpm

* 🤖 TEST: docker

* 🐛 FIX: set apache conf

* 🐛 FIX: bad tabs in php-fpm.conf generation

* 🤖 TEST: docker

* ♻️ REFACTOR: apache configuration

* 🐛 FIX: #172

* 🤖 TEST: docker

* 🐛 FIX: typo

* 🤖 TEST: #173

* 🤖 TEST: debugging #171

* 🤖 TEST: docker

* 🐛 FIX: #174

* 🐛 FIX: trim any potential leading or tailing whitepsace from the parsed ppa value

* 🤖 TEST: docker

* 🤖 TEST: #174 again

* 🤖 TEST: docker

* 🐛 FIX: #148

* 🐛 FIX: log messages for #171

* ♻️ REFACTOR: #165 and #170

* 🐛 FIX: #158

* 🐛 FIX: bump hardcoded gls version in preparation for v1.4 release

* 🐛 FIX: #168

* 🐛 FIX: #161 and log messages for #168 and autogeneration of php-fpm.conf

* 🐛 FIX: #161

* 🐛 FIX: #168

* 🤖 TEST: #168

* 🐛 FIX: comment

* 🤖 TEST: #168

* 🤖 TEST: #168

* 🐛 FIX: move autogeneration of files as per starter.ini to after rsync

* 🐛 FIX: shorten log message gor phpinfo.php autogenaration

* 🐛 FIX: parse .vscode/settings.json first

* Show only stderr for gpg

* 💡 UPDATE COMMENTS: improve log msg

* 🐛 FIX: #164

* Update feature-request-.md

Fix hidden comment issue

* 🐛 FIX: 3614991

* 📖 DOC: #160

* 🐛 FIX: #156

* 🤖 TEST: docker

* 📖 DOC: #173

* 🤖 TEST: docker

* 🐛 FIX: #156 for ioncube

* 🤖 TEST: docker

* 🤖 TEST: ioncube install, TODO: swap this back to the default of 0 after testing

* 🤖 TEST: do not install ioncube if php version is > 7.4

* ♻️ REFACTOR: remove generation of php-fpm conf

* ♻️ REFACTOR: generation of php-fpm.conf for #156

* 🤖 TEST: force docker

* ⚰️ REMOVE: autogeneration of php-fpm.conf

* 🤖 TEST: force docker

* 🐛 FIX: proper exit

* 🤖 TEST: force docker

* 🐛 FIX: get current php version

* ♻️ REFACTOR: move autogen of php-fpm.conf

* ♻️ REFACTOR: ioncube install for php 7.4

* 💡 UPDATE COMMENTS: PHP ppa comment

* 🤖 TEST: force docker

* 🐛 FIX: bump npm install to 8.3.2

* 🐛 FIX: add phpfpm install for php versions > 7.4

* 🤖 TEST: force docker

* ♻️ REFACTOR: move invalidate cache back to the bottom of the file

* 🐛 FIX: path to utils.sh

* 🤖 TEST: force docker

* 🐛 FIX: log to workspace-image.log when using existing gitpodlatest version of php

* 🐛 FIX: php version comparison for installing phpfpm

* 🤖 TEST: install php 7.4

* 🤖 TEST: invalid value for php version

* 🤖 TEST: force docker

* 🐛 FIX: fallback routine for #156

* 🤖 TEST: force docker

* 🤖 TEST: #156 install php 7.4 explicity

* 🤖 TEST: force docker

* 🐛 FIX: restore default value for ioncube install to 0

* 🤖 TEST: force docker

* 📖 DOC: #180

* 📖 DOC: #181

* ♻️ REFACTOR: #170

* 🐛 FIX: log gpg_key_id

* 🤖 TEST: gitpod with git signed commit

* 🐛 FIX: unset GPG_KEY once successful

* 🤖 TEST: test gpg trusted key

* 🤖 TEST: gpg signed commit

* 🐛 FIX: #170 swap git email to env GPG_MATCH_GIT_TO_EMAIL if present

* 🐛 FIX: typo

* 🤖 TEST: email match for gpg

* 🐛 FIX: make gpg key logs silent except for errors

* 🐛 FIX: #170 Support GPG_AUTO_ULTIMATE_TRUST to automagically give ultimate trust to a GPG_KEY

* ⚰️ REMOVE: extraneous space in GPG_AUTO_ULTIMATE_TRUST conditional

* 🐛 FIX: #170 make success a slient log for GPG_AUTO_ULTIMATE_TRUST

* 🐛 FIX: reduce verbosity of all log messages

* 🐛 FIX: #170 log improper use of GPG env vars

* ⚰️ REMOVE: redundant file

* 🤖 TEST: remove hotfix #140

* 🤖 TEST: #185

* 🤖 TEST: #185

* 🐛 FIX: #188

* 🐛 FIX: #185

* 📖 DOC: #183

* ⚰️ REMOVE: test file

* 📖 DOC: dev-qa fix for #183

* 👌 IMPROVE: Documentation formatting, broken links and #176

Co-authored-by: Björn Strausmann <bjoern@strausmann.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request passed-dev-qa Optional state. Use this when QAing other peoples fixes in another branch.ready to be merged to main
Projects
None yet
Development

No branches or pull requests

2 participants