-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As [kaoto-ui](https://github.com/KaotoIO/kaoto-ui) migrated to yarn v3, it's time for vscode to do the same. Changes: * Upgrade yarn to v3 - berry * Remove installing global dependencies from CI workflows as those are deprecated in favor of the "yarn dlx" command * Add a local yarn plugin (.yarn/plugins/plugins-list.js) to bring the functionality from yarn v1 "yarn list --prod --json" since the "@vscode/vsce" depends on such functionality. more datails in [the following issue](microsoft/vscode-vsce#517) * Update the CONTRIBUTING.md file to reflect the new API for "yarn link" * Bump "@kie-tools-core/*" from "0.27.0" to "0.29.0" as it's required that the dependencies match from the root package and the linked package. * Add a resolution entry for "zundo" package to support both "[email protected]" and "kaoto-ui@main-branch" fixes: #270
- Loading branch information
Showing
10 changed files
with
8,885 additions
and
5,242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/list-plugin.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], | ||
}; | ||
}, | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,13 +31,13 @@ | |
}, | ||
"dependencies": { | ||
"@kaoto/kaoto-ui": "1.0.0", | ||
"@kie-tools-core/backend": "^0.27.0", | ||
"@kie-tools-core/editor": "^0.27.0", | ||
"@kie-tools-core/i18n": "^0.27.0", | ||
"@kie-tools-core/monaco-editor": "^0.27.0", | ||
"@kie-tools-core/patternfly-base": "^0.27.0", | ||
"@kie-tools-core/vscode-extension": "^0.27.0", | ||
"@kie-tools-core/workspace": "^0.27.0", | ||
"@kie-tools-core/backend": "^0.29.0", | ||
"@kie-tools-core/editor": "^0.29.0", | ||
"@kie-tools-core/i18n": "^0.29.0", | ||
"@kie-tools-core/monaco-editor": "^0.29.0", | ||
"@kie-tools-core/patternfly-base": "^0.29.0", | ||
"@kie-tools-core/vscode-extension": "^0.29.0", | ||
"@kie-tools-core/workspace": "^0.29.0", | ||
"@patternfly/react-core": "4.276.8", | ||
"@redhat-developer/vscode-redhat-telemetry": "^0.6.1", | ||
"async-wait-until": "^2.0.12", | ||
|
@@ -166,7 +166,10 @@ | |
"webpack-merge": "^5.8.0" | ||
}, | ||
"resolutions": { | ||
"@types/react": "18.2.6", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
} | ||
"react-dom": "18.2.0", | ||
"zundo": "2.0.0-beta.19" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { KaotoEditorFactory } from "@kaoto/kaoto-ui/dist/lib/kogito-integration"; | ||
import * as EditorEnvelope from "@kie-tools-core/editor/dist/envelope"; | ||
|
||
import { KaotoEditorFactory } from '@kaoto/kaoto-ui/dist/lib/kogito-integration'; | ||
import { Editor, EditorFactory, KogitoEditorChannelApi } from '@kie-tools-core/editor/dist/api'; | ||
import * as EditorEnvelope from '@kie-tools-core/editor/dist/envelope'; | ||
declare const acquireVsCodeApi: any; | ||
|
||
EditorEnvelope.init({ | ||
container: document.getElementById("envelope-app")!, | ||
container: document.getElementById('envelope-app')!, | ||
bus: acquireVsCodeApi(), | ||
editorFactory: new KaotoEditorFactory(), | ||
editorFactory: new KaotoEditorFactory() as unknown as EditorFactory<Editor, KogitoEditorChannelApi>, | ||
}); |
Oops, something went wrong.