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

chore: update yarn to v3 #273

Merged
merged 7 commits into from
Jun 15, 2023
Merged
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
6 changes: 0 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ jobs:
with:
node-version: '16'
cache: 'yarn'
- name: Install prerequisites
run: |
yarn global add rimraf
yarn global add @vscode/vsce
yarn global add webpack-cli
yarn global add webpack
- name: yarn
run: yarn --network-timeout 1000000
- name: yarn build:dev
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/main-kaoto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,14 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install prerequisites
- name: Kaoto-ui build
working-directory: kaoto-ui
run: |
yarn global add rimraf
yarn global add @vscode/vsce
yarn global add webpack-cli
yarn global add webpack
- name: Kaoto-ui link and build
run: |
cd kaoto-ui
yarn
yarn link
yarn build:lib
- name: yarn
- name: yarn link kaoto-ui
working-directory: vscode-kaoto
run: |
yarn
yarn link @kaoto/kaoto-ui
run: yarn link ../kaoto-ui
- name: yarn build:dev
working-directory: vscode-kaoto
run: yarn build:dev
Expand Down
13 changes: 8 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# dependencies
/node_modules
dist
# no longer using yarn berry
/.yarn
.pnp.js
.pnp.cjs
.pnp.loader.mjs

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# testing
/coverage
Expand Down
138 changes: 138 additions & 0 deletions .yarn/plugins/plugin-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// Workaround for https://github.com/microsoft/vscode-vsce/issues/517
// taken from https://gist.githubusercontent.com/arendjr/415747652a8c79f12b005ce3cfb2f808/raw/a4a227070319e1d4c61e982b74153765d6338694/list-plugin.js

const fs = require('fs');

// Setup: Place this file in `.yarn/plugins/plugin-list.js` and the following
// to `.yarnrc.yml`:
//
// ```
// plugins:
// - path: .yarn/plugins/plugin-list.js
// ```
module.exports = {
name: 'plugin-list',
factory: (require) => {
const { BaseCommand } = require('@yarnpkg/cli');
const { Command, Option } = require('clipanion');
const { parseSyml } = require('@yarnpkg/parsers');
const { Manifest } = require('@yarnpkg/core');

class ListCommand extends BaseCommand {
static paths = [['list']];

static usage = Command.Usage({
description: 'Lists installed packages.',
});

prod = Option.Boolean('--prod', false);
json = Option.Boolean('--json', false);
manifest = new Manifest();
trees = [];

async execute() {
await this.manifest.loadFile(Manifest.fileName, {});

if (!this.prod || !this.json) {
throw new Error(
'This command can only be used with the --prod and --json ' +
'args to match the behavior required by VSCE. See: ' +
'https://github.com/microsoft/vscode-vsce/blob/main/src/npm.ts'
);
}

const packageJsonContents = fs.readFileSync('package.json', 'utf-8');
const { dependencies, resolutions } = JSON.parse(packageJsonContents);

const lockContents = fs.readFileSync('yarn.lock', 'utf-8');
const resolved = parseSyml(lockContents);

this.addDependencies(dependencies, resolved, resolutions);

const output = {
type: 'tree',
data: { type: 'list', trees: this.trees },
};

this.context.stdout.write(JSON.stringify(output));
}

addDependencies(dependencies, resolved, resolutions) {
for (const [packageName, versionSpecifier] of Object.entries(dependencies)) {
this.addDependency(packageName, versionSpecifier, resolved, resolutions);
}
}

addDependency(packageName, versionSpecifier, resolved, resolutions) {
const packageInfo = this.lookup(resolved, packageName, versionSpecifier, resolutions);
if (!packageInfo) {
throw new Error(
`Cannot resolve "${packageName}" with version range "${versionSpecifier}"`
);
}

const { version, dependencies } = packageInfo;
const name = `${packageName}@${version}`;
if (this.trees.find((tree) => tree.name === name)) {
return; // Dependency already added as part of another tree.
}

if (dependencies) {
const children = Object.entries(dependencies).map(([name, range]) => ({
name: `${name}@${range}`,
}));
this.trees.push({ name, children });

this.addDependencies(dependencies, resolved, resolutions);
} else {
this.trees.push({ name, children: [] });
}
}

/**
* @param resolved All the resolved dependencies as found in the lock file.
* @param packageName The package name to look up.
* @param versionSpecifier The package version range as declared in the package.json.
* @param resolutions The resolutions override as declared in the package.json.
*/
lookup(resolved, packageName, versionSpecifier, resolutions) {
const dependencyKey = this.getLockFileKey(packageName, versionSpecifier, resolutions);

const packageInfo = resolved[dependencyKey];
if (packageInfo) {
return packageInfo;
}

// Fall back to slower iteration-based lookup for combined keys.
for (const [key, packageInfo] of Object.entries(resolved)) {
// Resolving ranges: "@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.12.13, @babel/runtime@npm:^7.12.5"
const versionsRange = key.split(',');

// Resolving yarn link resolutions: "@kaoto/kaoto-ui@portal:/home/rmartinez/repos/kaoto-ui::locator=vscode-kaoto%40workspace%3A."
const yarnLinkResolution = key.split('::')[0];

if (
versionsRange.some((key) => key.trim() === dependencyKey) ||
yarnLinkResolution === dependencyKey
) {
return packageInfo;
}
}
}

getLockFileKey(packageName, versionSpecifier, resolutions) {
// If the package name is in the resolutions field, use the version from there.
const resolvedVersionSpecifier = resolutions[packageName] ?? versionSpecifier;

// If the version field contains a URL, don't attempt to use the NPM registry
return resolvedVersionSpecifier.includes(':')
? `${packageName}@${resolvedVersionSpecifier}`
: `${packageName}@npm:${resolvedVersionSpecifier}`;
}
}

return {
commands: [ListCommand],
};
},
};
874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.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 @@
yarnPath: .yarn/releases/yarn-3.6.0.cjs

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/plugin-list.js
34 changes: 20 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Everyone is welcome to contribute to Kaoto.
Everyone is welcome to contribute to Kaoto.

We have a Kanban board with good first issues in https://github.com/orgs/KaotoIO/projects/4

Expand All @@ -14,7 +14,7 @@ Always **use one of the templates available** and answer as many of the question
If you are **submitting a bug**, provide a simple step by step explanation of how to reproduce it and what is the expected outcome.

If you are **submitting a feature**, be ready to follow up and contribute with its development. Features that are proposed but don't have
funds or developers ready to implement it may be closed due to not enough interest raised. If you can't fund or implement it yourself and
funds or developers ready to implement it may be closed due to not enough interest raised. If you can't fund or implement it yourself and
you want the feature implemented, you must look for a way to find resources to implement it.

### Clarifying bugs
Expand All @@ -23,7 +23,7 @@ You can also contribute by looking for open bugs and test corner cases to add mo

### Implementing bug fixes or features

Feel free to work on any of the open issues. Add a comment to it saying that you want to work on it and deliver regular updates on the
Feel free to work on any of the open issues. Add a comment to it saying that you want to work on it and deliver regular updates on the
status of the development.

If you can no longer work on an issue, please, let us know as soon as possible so someone else can work on it.
Expand All @@ -32,14 +32,14 @@ See pull request section.

## Pull Requests

If you are reviewing pull requests, please use the [conventional comments](https://conventionalcomments.org/) standard to do so.
If you are reviewing pull requests, please use the [conventional comments](https://conventionalcomments.org/) standard to do so.
Comments that don't follow this standard may be ignored.

There are a few things to consider when sending a pull request merge:

* Small commits. We prefer small commits because they are easier to review
* All commits must pass tests: Each commit should have consistency on its own and don't break any functionality
* All jobs/checks must be green: This includes test coverage, code smells, security issues,...
* All jobs/checks must be green: This includes test coverage, code smells, security issues,...
* Be descriptive on the PR text about what the changes are. Better to have duplicated explanation than no explanation at all. Provide examples.
* Add screenshots and videos of what your PR is doing. Especially if you are adding a new feature.
* High test coverage: Your code must be covered by unit and e2e tests. If for some reason your PR can't or shouldn't, be very clear why. The tests must be included in the same PR.
Expand All @@ -48,8 +48,8 @@ There are a few things to consider when sending a pull request merge:

**All your commits should follow the [conventional commits standard](https://www.conventionalcommits.org/).**

The Conventional Commits specification is a lightweight convention on top of commit messages.
It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of.
The Conventional Commits specification is a lightweight convention on top of commit messages.
It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of.
This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages.

The commit message should be structured as follows:
Expand All @@ -66,13 +66,13 @@ The commit contains the following structural elements, to communicate intent to

* fix: a commit of the type fix patches a bug in your codebase (this correlates with PATCH in Semantic Versioning).
* feat: a commit of the type feat introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning).
* BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change
* BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change
(correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
* types other than fix: and feat: are allowed, like build:, chore:, ci:, docs:, style:, refactor:, perf:, test:, and others.
* footers other than BREAKING CHANGE: `description` may be provided and follow a convention similar to git trailer format.

Additional types are not mandated by the Conventional Commits specification, and have no implicit effect in Semantic Versioning
(unless they include a BREAKING CHANGE). A scope may be provided to a commit’s type, to provide additional contextual information and
Additional types are not mandated by the Conventional Commits specification, and have no implicit effect in Semantic Versioning
(unless they include a BREAKING CHANGE). A scope may be provided to a commit’s type, to provide additional contextual information and
is contained within parenthesis, e.g., `feat(parser): add ability to parse arrays`.

## Development environment
Expand Down Expand Up @@ -101,18 +101,24 @@ If you'd like to test latest Kaoto UI and not rely on a released version, follow

* In `kaoto-ui` local clone folder:
* `yarn`
* `yarn link`
* `yarn build:lib`
* Open VS Code on `vscode-kaoto` local clone folder
* `yarn`
* `yarn link @kaoto/kaoto-ui`
* `yarn link` _\<kaoto-ui local clone folder uri>_
* i.e. `yarn link ~/repositories/kaoto-ui`
* `yarn build:dev`
* In `Run and debug` perspective, call the `Run Extension` launch configuration
* In the new VS Code opened (which has `[Extension Development host]` in window title,
* In the new VS Code opened (which has `[Extension Development host]` in window title),
* Open a folder (use the one you want)
* Create a file named with the following pattern `*.kaoto.yaml`
* Open the file


To return to the default Kaoto UI version, just write on `vscode-kaoto` local clone folder:
* `yarn unlink` _\<kaoto-ui local clone folder uri>_
* i.e. `yarn unlink ~/repositories/kaoto-ui`

More information about [linking](https://yarnpkg.com/cli/link) and [unlinking](https://yarnpkg.com/cli/unlink) local packages with [yarn](https://yarnpkg.com/)

### How to debug Kaoto UI embedded in VS Code

The command `Developer: Toggle Developer Tools` gives access to classic developer tools for web applications. See [official documentation](https://code.visualstudio.com/api/extension-guides/webview#inspecting-and-debugging-webviews) for more details.
Expand Down
7 changes: 2 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ def installBuildRequirements(){
def nodeHome = tool 'nodejs-lts'
env.PATH="${env.PATH}:${nodeHome}/bin"
sh "npm install --global yarn"
sh "yarn global add @vscode/vsce"
sh "yarn global add webpack-cli"
sh "yarn global add webpack"
}

node('rhel9'){
Expand All @@ -30,7 +27,7 @@ node('rhel9'){

stage 'Package vscode-kaoto'
def packageJson = readJSON file: 'package.json'
sh "vsce package --yarn -o vscode-kaoto-${packageJson.version}-${env.BUILD_NUMBER}.vsix"
sh "yarn vsce package --yarn -o vscode-kaoto-${packageJson.version}-${env.BUILD_NUMBER}.vsix"

stage 'Upload vscode-kaoto to staging'
def vsix = findFiles(glob: '**.vsix')
Expand All @@ -49,7 +46,7 @@ node('rhel9'){
def vsix = findFiles(glob: '**.vsix')
// VS Code Marketplace
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
sh 'vsce publish -p ${TOKEN} --packagePath' + " ${vsix[0].path}"
sh 'yarn vsce publish -p ${TOKEN} --packagePath' + " ${vsix[0].path}"
}

// Open-vsx Marketplace
Expand Down
Loading