Skip to content

WIP: Move from npm to yarn #208

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ In particular, if you're making changes not covered by tests - please describe t

Basic checks:

- [ ] `npm run lint`
- [ ] `npm run test`
- [ ] `yarn lint`
- [ ] `yarn test`
10 changes: 5 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache: 'yarn'

- name: Install dependencies
run: npm install
run: yarn install

- name: Run linter
run: npm run lint
run: yarn lint

- name: Run unit tests
run: npm run test
run: yarn test

- name: Fetch E2E image
run: |
Expand All @@ -44,4 +44,4 @@ jobs:
- name: Run E2E tests
env:
ATLASCODE_TEST_USER_API_TOKEN: ${{ secrets.ATLASCODE_TEST_USER_API_TOKEN }}
run: npm run test:e2e:docker
run: yarn test:e2e:docker
15 changes: 7 additions & 8 deletions .github/workflows/release-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache: 'yarn'

- name: Set version
run: |
npm -no-git-tag-version --allow-same-version -f version $PACKAGE_VERSION

- name: Install dependencies
run: npm install
run: yarn install

- name: Run linter
run: npm run lint
run: yarn lint

- name: Run unit tests
run: npm run test
run: yarn test

- name: Fetch E2E image
run: |
Expand All @@ -59,11 +59,10 @@ jobs:
- name: Run E2E tests
env:
ATLASCODE_TEST_USER_API_TOKEN: ${{ secrets.ATLASCODE_TEST_USER_API_TOKEN }}
run: npm run test:e2e:docker
run: yarn test:e2e:docker

# TODO: might want to run this first, and reuse the .vsix in E2E tests instead
- name: Build the extension
run: npm run extension:package:prerelease
- name: Package extension (prerelease)
run: yarn extension:package:prerelease

- name: Publish the pre-release extension
run: |
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache: 'yarn'

- name: Set version
run: npm -no-git-tag-version --allow-same-version -f version $PACKAGE_VERSION

- name: Install dependencies
run: npm install
run: yarn install

- name: Run linter
run: npm run lint
run: yarn lint

- name: Run unit tests
run: npm run test
run: yarn test

- name: Fetch E2E image
run: |
Expand All @@ -65,11 +65,10 @@ jobs:
- name: Run E2E tests
env:
ATLASCODE_TEST_USER_API_TOKEN: ${{ secrets.ATLASCODE_TEST_USER_API_TOKEN }}
run: npm run test:e2e:docker
run: yarn test:e2e:docker

# TODO: might want to run this first, and reuse the .vsix in E2E tests instead
- name: Build the extension
run: npm run extension:package
- name: Package extension
run: yarn extension:package

- name: Publish the extension
run: |
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ coverage
.generated/
e2e/.resources/
e2e/.test-extensions/

# Yarn Berry
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*
4 changes: 2 additions & 2 deletions .vscode/launch.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"outFiles": [
"${workspaceFolder}/build/**/*.js"
],
"preLaunchTask": "npm: devcompile"
"preLaunchTask": "yarn: devcompile"
},
{
// This configuration requires npm run dev to be running externally
// This configuration requires yarn dev to be running externally
// It will pick up the re-compiled extension code but not hot-swap it
"name": "Extension (watch/external)",
"type": "extensionHost",
Expand Down
935 changes: 935 additions & 0 deletions .yarn/releases/yarn-4.7.0.cjs

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.7.0.cjs

# npmRegistryServer: "https://packages.atlassian.com/api/npm/npm-remote"
# unsafeHttpWhitelist: ["packages.atlassian.com"]
2 changes: 1 addition & 1 deletion HOMEPAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Please read our [Code of Conduct](CODE_OF_CONDUCT.md).

Running and debugging the extension:

- Atlassian for VS Code is a node project, as such you'll need to run `npm install` before building.
- Atlassian for VS Code is a node project, as such you'll need to run `yarn install` before building.
- To debug the extension from within VS Code you'll need a `launch.json`.
** An example `launch.json` that will be suitable for most users is included as `.vscode/launch.json.example`.
** To use the example file simply copy it to `launch.json`.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Please use the in-app feedback form to tell us what you think! It's available fr

Running and debugging the extension:

- Atlassian for VS Code is a node project, as such you'll need to run `npm install` before building.
- Atlassian for VS Code is a node project, as such you'll need to run `yarn install` before building.
- To debug the extension from within VS Code you'll need a `launch.json`.
** An example `launch.json` that will be suitable for most users is included as `.vscode/launch.json.example`.
** To use the example file simply copy it to `launch.json`.
Expand Down Expand Up @@ -86,7 +86,7 @@ VSCode provides some very helpful [documentation](https://code.visualstudio.com/
To run `atlascode` in such a way, please follow the VSCode documentation:

- Install [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) VSCode Extension
- Run `npm install` like you normally would
- Run `yarn install` like you normally would
- In VSCode, choose `Dev Containers: Rebuild and Reopen in Container` from the command pallette
- Wait for the VSCode to re-open in the container evnironment - you'll be able to see the difference in the header/search bar
- Proceed to run or debug the extension as usual - it will now be running as it would in remote execution
Expand All @@ -100,7 +100,7 @@ Note: for advanced use-cases, it is possible to run scripts in dev containers vi
## Tests

```
npm run test
yarn test
```

## Contributions
Expand Down
5 changes: 4 additions & 1 deletion e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor
&& apt update \
&& apt install -y code \
&& rm -rf /var/lib/apt/lists/* \
&& npm install -g npm@latest
&& npm install -g yarn

# Install corepack to enable Yarn
RUN corepack enable

# Running vscode as root is not recommended, so let's create a user.
# We need that user's $HOME to exist for the test process to work properly.
Expand Down
14 changes: 7 additions & 7 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ What do these tests use?
Commands related to e2e tests:

# Compile the tests in this folder into JS
npm run test:e2e:compile
yarn test:e2e:compile

# Build the extension, e2e tests, configure the test runner,
# then run the E2E tests
npm run test:e2e
yarn test:e2e

# Run the tests without rebuilding the extension
# Use this one when iterating
npm run test:e2e:rerun
yarn test:e2e:rerun

### Running E2E Tests Headless

I'm sure we all love looking at the VSCode UI - but sometimes one might want to take a break from that, and run their tests in console only 😉 Unfortunately, [vscode-extension-tester](https://github.com/redhat-developer/vscode-extension-tester) doesn't have built-in support for [headless](https://en.wikipedia.org/wiki/Headless_browser) execution.

However, we can work around that - by running our tests in Docker! We can mount our whole working directory, and run tests in [xvfb](https://en.wikipedia.org/wiki/Xvfb).

In this folder, there's a `Dockerfile` with a rather lightweight image - `vscode`, `xvfb`, their dependencies, and `npm`/`node` - and some scripts to run it. The intended usage is as follows:
In this folder, there's a `Dockerfile` with a rather lightweight image - `vscode`, `xvfb`, their dependencies, and `node`/`yarn` - and some scripts to run it. The intended usage is as follows:

- Build the docker image by running `npm run test:e2e:docker:build`. You only need to do it once
- Build the docker image by running `yarn test:e2e:docker:build`. You only need to do it once
- Run one of the two commands:
- `npm run test:e2e:docker` - this will do the full cycle of building the extension and setting up tests. You typically want to run this when you've just updated the extension
- `npm run test:e2e:docker:rerun` - a much faster command to rerun the tests against an already prepared setup. Use this when iterating on tests themselves
- `yarn test:e2e:docker` - this will do the full cycle of building the extension and setting up tests. You typically want to run this when you've just updated the extension
- `yarn test:e2e:docker:rerun` - a much faster command to rerun the tests against an already prepared setup. Use this when iterating on tests themselves
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,36 @@
"scripts": {
"precommit": "pretty-quick --staged",
"vscode:uninstall": "node ./build/extension/uninstall.js",
"vscode:prepublish": "npm run compile",
"vscode:prepublish": "yarn compile",
"clean": "rm -rf ./build",
"format": "prettier --write --log-level warn src e2e",
"lint": "eslint ./src ./e2e --ext .js,.jsx,.ts,.tsx",
"lint:fix": "eslint --fix ./src ./e2e --ext .js,.jsx,.ts,.tsx",
"compile": "npm run clean && npm run compile:react && npm run compile:extension",
"compile": "yarn clean && yarn compile:react && yarn compile:extension",
"compile:extension": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode production --config webpack.extension.prod.js",
"compile:react": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode production --config webpack.react.prod.js",
"postinstall": "cp ./scripts/githooks/pre-commit ./.git/hooks && patch-package",
"extension:clean": "rm -rf ./atlascode-*.vsix",
"extension:package:prerelease": "npm run extension:clean && vsce package --pre-release --baseContentUrl https://raw.githubusercontent.com/atlassian/atlascode/main/",
"extension:package": "npm run extension:clean && vsce package --baseContentUrl https://raw.githubusercontent.com/atlassian/atlascode/main/",
"extension:install": "npm run extension:package && code --install-extension ./atlascode-*.vsix --force",
"test": "rm -rf coverage && npm run test:unit && npm run test:react && istanbul-merge --out coverage/coverage-final.json coverage/react/coverage-final.json coverage/unit/coverage-final.json && echo '\n\nTotal test coverage:' && nyc report --reporter clover --reporter lcov --reporter html --reporter text-summary -t coverage/ --report-dir coverage/",
"extension:package:prerelease": "yarn extension:clean && vsce package --pre-release --baseContentUrl https://raw.githubusercontent.com/atlassian/atlascode/main/",
"extension:package": "yarn extension:clean && vsce package --baseContentUrl https://raw.githubusercontent.com/atlassian/atlascode/main/",
"extension:install": "yarn extension:package && code --install-extension ./atlascode-*.vsix --force",
"test": "rm -rf coverage && yarn test:unit && yarn test:react && istanbul-merge --out coverage/coverage-final.json coverage/react/coverage-final.json coverage/unit/coverage-final.json && echo '\n\nTotal test coverage:' && nyc report --reporter clover --reporter lcov --reporter html --reporter text-summary -t coverage/ --report-dir coverage/",
"test:unit": "jest -c jest.unit.config.js",
"test:react": "jest -c jest.react.config.js",
"test:e2e": "echo 'token length' && echo ${#ATLASCODE_TEST_USER_API_TOKEN} && npm run test:e2e:compile && e2e/scripts/run",
"test:e2e:compile": "tsc --project e2e/tsconfig.e2e.json",
"test:e2e:rerun": "npm run test:e2e:compile && e2e/scripts/run --rerun",
"test:e2e:rerun": "yarn test:e2e:compile && e2e/scripts/run --rerun",
"test:e2e:docker": "e2e/scripts/in-docker npm run test:e2e",
"test:e2e:docker:build": "e2e/scripts/build-docker",
"test:e2e:docker:rerun": "e2e/scripts/in-docker npm run test:e2e:rerun",
"test:e2e:docker:rerun": "e2e/scripts/in-docker yarn test:e2e:rerun",
"devcompile": "npm-run-all --parallel devcompile:react devcompile:extension",
"devcompile:react": "webpack --mode development --config webpack.react.dev.js",
"devcompile:extension": "webpack --mode development --config webpack.extension.dev.js",
"release:stable": "scripts/release.sh",
"watch": "concurrently -r \"npm:watch:*\"",
"watch": "concurrently -r \"yarn watch:extension\" \"yarn watch:react\"",
"watch:extension": "WATCH=true webpack --mode development --config webpack.react.dev.js --progress --watch",
"watch:react": "WATCH=true webpack --mode development --config webpack.extension.dev.js --progress --watch",
"dev": "concurrently -r npm:watch:extension npm:watch:react",
"dev": "concurrently -r yarn:watch:extension yarn:watch:react",
"mui:atlascodeSettings:dark": "cross-env PAGETSX=\"config/ConfigPage.tsx\" VIEW=\"atlascodeSettingsV2\" THEME=\"dark\" webpack-dev-server --open --config webpack.mui.webview.js",
"mui:atlascodeSettings:light": "cross-env PAGETSX=\"config/ConfigPage.tsx\" VIEW=\"atlascodeSettingsV2\" THEME=\"light\" webpack-dev-server --open --config webpack.mui.webview.js",
"mui:atlascodeOnboarding:dark": "cross-env PAGETSX=\"onboarding/OnboardingPage.tsx\" VIEW=\"atlascodeOnboardingV2\" THEME=\"dark\" webpack-dev-server --open --config webpack.mui.webview.js",
Expand Down Expand Up @@ -1606,7 +1606,6 @@
"@types/lodash.debounce": "^4.0.6",
"@types/lodash.orderby": "^4.6.6",
"@types/lodash.truncate": "^4.4.6",
"@types/mocha": "^10.0.10",
"@types/node": "^18.16.19",
"@types/node-ipc": "^9.2.0",
"@types/prosemirror-state": "^1.2.5",
Expand All @@ -1619,10 +1618,10 @@
"@types/terser-webpack-plugin": "^2.2.0",
"@types/turndown": "^5.0.1",
"@types/uuid": "^3.4.7",
"@types/vscode": "^1.77.0",
"@types/vscode": "1.96.0",
"@types/webpack": "^5.28.5",
"@types/webpack-manifest-plugin": "^2.1.0",
"@types/websocket": "^1.0.0",
"@types/websocket": "1.0.0",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@vscode/vsce": "^3.1.0",
Expand All @@ -1648,6 +1647,7 @@
"jest-environment-jsdom": "^29.7.0",
"jest-mock-vscode": "^4.0.4",
"mini-css-extract-plugin": "^2.9.1",
"mocha": "11.0.1",
"npm-run-all": "^4.1.5",
"nyc": "^17.1.0",
"ovsx": "^0.10.1",
Expand Down
2 changes: 1 addition & 1 deletion scripts/githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run lint
yarn lint
Loading
Loading