Skip to content

Commit

Permalink
chore: Use PHAR instead of Composer (#74)
Browse files Browse the repository at this point in the history
* chore: Download and use phpactor.phar instead of composer, but fall back if composer is available

* Intentionally using an old version, so we can test automatic updating.
  • Loading branch information
zobo authored Nov 13, 2023
1 parent e726f5b commit 70fc297
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '16.14.2'
- run: mkdir artifacts
- run: npm ci
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: composer
- name: Composer Install
run: composer install --prefer-dist --no-interaction --optimize-autoloader --no-dev
- name: Prettier
run: npm run prettier-check
- name: Lint
run: npm run eslint
- name: Download Phpactor
run: npm run download-phpactor
- run: xvfb-run -a npm test
17 changes: 6 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 14
- run: mkdir artifacts
- run: npm ci
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: composer
- name: Composer Install
run: composer install --prefer-dist --no-interaction --optimize-autoloader --no-dev
- run: npm compile
- name: Download Phpactor
run: npm run download-phpactor
- run: npm run compile
- run: mkdir artifacts
- name: Package
run: npx vsce package --out=artifacts/phpactor.vsix ${{ github.event.release.tag_name }}
- name: 'Release Extension'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
.vscode-test/
artifacts/
vendor/
phpactor.phar
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"pretest": "npm run compile",
"compile": "npm run clean && tsc -p ./",
"composer": "composer install",
"download-phpactor": "curl -L https://github.com/phpactor/phpactor/releases/download/2023.08.06-1/phpactor.phar > phpactor.phar",
"package": "npx vsce package --out=artifacts/phpactor.vsix",
"lint": "npm run eslint && npm run prettier",
"eslint": "eslint \"src/**/*.ts\"",
Expand Down
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { LanguageClient, ServerOptions, LanguageClientOptions, StreamInfo } from
import * as vscode from 'vscode'
import { join } from 'path'
import * as net from 'net'
import * as fs from 'fs'

const LanguageID = 'php'

Expand Down Expand Up @@ -32,6 +33,9 @@ export function activate(context: vscode.ExtensionContext): void {

if (!config.path) {
config.path = context.asAbsolutePath(join('vendor', 'phpactor', 'phpactor', 'bin', 'phpactor'))
if (!fs.existsSync(config.path)) {
config.path = context.asAbsolutePath(join('phpactor.phar'))
}
}

if (!config.executablePath) {
Expand Down

0 comments on commit 70fc297

Please sign in to comment.