Skip to content

Commit

Permalink
refactor: switch to pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
kokororin committed Apr 20, 2024
1 parent 42e52fd commit bbd4ac4
Show file tree
Hide file tree
Showing 14 changed files with 3,722 additions and 2,824 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
out
27 changes: 10 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,42 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Use PNPM
uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none
tools: composer

- name: Setup Node
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'pnpm'

- name: Start Xvfb
run: /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & echo "Started xvfb"
shell: bash
if: ${{ success() && matrix.os == 'ubuntu-latest' }}

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
run: |
yarn install
pnpm i
- name: Run Lint
run: yarn lint
run: pnpm lint
if: ${{ matrix.os == 'macos-latest' && matrix.php-version == '7.0' }}

- name: Run Tests
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: yarn test
command: pnpm test
env:
DISPLAY: ":99.0"
27 changes: 10 additions & 17 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,32 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Use PNPM
uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none
tools: composer

- name: Setup Node
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
run: |
yarn global add @vscode/vsce ovsx
yarn install
pnpm add -g @vscode/vsce ovsx
pnpm i
- name: Build
run: npm run build
run: pnpm build

- name: Run release script
run: npx tsx ./scripts/release.ts
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
out
dist
node_modules
npm-debug.log
*.vsix
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable-pre-post-scripts=true
29 changes: 8 additions & 21 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
.vscode/**
.vscode-test/**
.github
.*
.**/**
patches/**
src/**
scripts/**
out/scripts
out/test/**
out/**
test/**
testProject/**
**/*.map
.gitignore
*.config.ts
tsconfig*.json
.editorconfig
.prettierignore
yarn.lock
pnpm-lock.yaml
prettier.config.*js
.eslintrc.*js
*.log
node_modules/**/.vscode
node_modules/**/*.md
node_modules/**/*.ts
node_modules/**/*.txt
node_modules/**/.editorconfig
node_modules/**/LICENSE*
node_modules/**/license*
node_modules/**/test/*
node_modules/php-parser
node_modules/compare-versions/lib/esm
*.tgz
*.vsix
24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"displayName": "phpfmt - PHP formatter",
"version": "1.1.40",
"description": "Integrates phpfmt into VS Code",
"main": "./out/src/extension",
"main": "./dist/extension",
"scripts": {
"build": "nr clean && tsc",
"build": "nr clean && tsc && tsup",
"build:docs": "tsx scripts/docs.ts",
"prebuild": "nr build:docs",
"watch": "tsc -watch -p ./",
"watch": "tsup --watch",
"clean": "rimraf out",
"postinstall": "node ./node_modules/phpfmt/v2/install",
"postinstall": "node ./node_modules/phpfmt/v2/install && shx cp ./node_modules/phpfmt/v2/fmt.stub.php ./dist",
"pretest": "nr build",
"test": "node ./out/test/runTest.js",
"format": "prettier --write .",
"lint": "eslint --ext .ts,.js --fix src test scripts",
"prepublishOnly": "nr build && vsce publish"
"prepublishOnly": "nr build && vsce publish --no-dependencies"
},
"keywords": [
"phpfmt",
Expand All @@ -27,7 +27,7 @@
"license": "BSD-3-Clause",
"repository": {
"type": "git",
"url": "https://github.com/kokororin/vscode-phpfmt.git"
"url": "git+https://github.com/kokororin/vscode-phpfmt.git"
},
"bugs": {
"url": "https://github.com/kokororin/vscode-phpfmt/issues"
Expand Down Expand Up @@ -646,9 +646,12 @@
"md5": "^2.3.0",
"mocha": "^10.3.0",
"prettier": "^3.2.5",
"read-pkg-up": "^7.0.1",
"rimraf": "^5.0.5",
"semver": "^7.6.0",
"shx": "^0.3.4",
"simple-git": "^3.22.0",
"tsup": "^8.0.2",
"tsx": "^4.7.1",
"typescript": "~5.3.0"
},
Expand All @@ -657,7 +660,12 @@
"detect-indent": "^6.0.0",
"find-up": "^5.0.0",
"mem": "^8.1.1",
"phpfmt": "^0.0.6",
"pjson": "^1.0.9"
"phpfmt": "^0.0.7"
},
"packageManager": "[email protected]",
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
}
}
}
37 changes: 37 additions & 0 deletions patches/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/parser/index.js b/parser/index.js
index 8860b47ff87e52a587bcc17992ecb1deccd40e92..730877562b1db1a2da081ed2fb5b44c750a06720 100644
--- a/parser/index.js
+++ b/parser/index.js
@@ -21,32 +21,6 @@ parser.getPasses = function (phpfmt, mode) {
passes = passes.filter(function (pass) {
return pass !== 'AdditionalPass';
});
- } else if (mode === parser.MODE_PARSER) {
- var phpParser = new (require('php-parser'))({
- ast: {
- withPositions: true
- }
- });
-
- var ast = phpParser.parseCode(code);
-
- var traverse = function (node) {
- if (node && typeof node === 'object') {
- if (
- node.kind === 'class' &&
- node.extends &&
- (node.extends.name === 'AdditionalPass' ||
- node.extends.name === 'FormatterPass')
- ) {
- passes.push(node.name.name);
- } else {
- for (var prop in node) {
- traverse(node[prop]);
- }
- }
- }
- };
- traverse(ast);
} else {
throw new Error('Unknown mode');
}
Loading

0 comments on commit bbd4ac4

Please sign in to comment.