Skip to content

Commit

Permalink
Move vscode builtin production from yarn to npm
Browse files Browse the repository at this point in the history
Also updates builtin to 1.94.0

fixes eclipse-theia#131

contributed on behalf of STMicroelectronics

Signed-off-by: Remi Schnekenburger <[email protected]>
  • Loading branch information
rschnekenbu committed Oct 9, 2024
1 parent 5586e40 commit ec31c74
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 42 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0",
"scripts": {
"build:extensions": "yarn --cwd vscode && yarn compile:extensions && yarn bundle:extensions",
"build:extensions": "npm --prefix vscode install && yarn compile:extensions && yarn bundle:extensions",
"compile:extensions": "cross-env NODE_OPTIONS=--max-old-space-size=8192 node ./src/compile.js",
"bundle:extensions": "cross-env NODE_OPTIONS=--max-old-space-size=8192 node ./src/bundle.js",
"publish:vsix": "node ./src/publish-vsix.js",
Expand Down
6 changes: 3 additions & 3 deletions src/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ async function createMissingLockFiles(extensionsPath) {

for (let subFolderName of subFolderNames) {
let subFolderPath = path.join(extensionsPath, subFolderName);
let yarnLockExists = fs.existsSync(path.join(subFolderPath, 'yarn.lock'));
if (!yarnLockExists) {
await run('yarn', ['install'], subFolderPath );
let packageLockExists = fs.existsSync(path.join(subFolderPath, 'package-lock.json'));
if (!packageLockExists) {
await run('npm', ['install'], subFolderPath );
}
}
}
8 changes: 4 additions & 4 deletions src/create-extension-pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ const externalBuiltins = ['ms-vscode.js-debug-companion', 'ms-vscode.js-debug'];
fs.writeFileSync(licensePath, generateLicense());
fs.writeFileSync(readmePath, generateReadme());

await createYarnLock(packFolderPath);
await createPackageLock(packFolderPath);
await vsce.createVSIX({
'cwd': packFolderPath,
'packagePath': dist(),
'useYarn': true
'useYarn': false
});

async function resolveExtensions(extensionsArr) {
Expand Down Expand Up @@ -163,8 +163,8 @@ const externalBuiltins = ['ms-vscode.js-debug-companion', 'ms-vscode.js-debug'];
/**
* @param {string} folderPath
*/
async function createYarnLock(folderPath) {
await run('yarn', ['install'], folderPath);
async function createPackageLock(folderPath) {
await run('npm', ['install'], folderPath);
}

function generateLicense() {
Expand Down
2 changes: 1 addition & 1 deletion src/package-vsix.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const repository = {
await vsce.createVSIX({
'cwd': extensions(extension),
'packagePath': dist(),
'useYarn': true,
'useYarn': false,
'allowStarActivation': true
});
result.push('successfully packaged: ' + pck.name);
Expand Down
2 changes: 1 addition & 1 deletion src/publish-vsix.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async function publishExtension(vsix) {
console.log(`Extension ${extension} v${version} is already published - skipping!`);
} else {
console.log('Publishing: ', dist(vsix), ' ...');
const results = await ovsx.publish({ extensionFile: dist(vsix), yarn: true });
const results = await ovsx.publish({ extensionFile: dist(vsix), yarn: false });
for (const result of results) {
if (result.status === 'rejected') {
message = `Error(s) Generated when publishing ${extension} v${version}!`;
Expand Down
33 changes: 2 additions & 31 deletions src/vscode-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,15 @@
const rimraf = require('../vscode/node_modules/rimraf');
const vfs = require('../vscode/node_modules/vinyl-fs');
const ext = require('../vscode/build/lib/extensions');
const { theiaExtension, extensions, run, vscodeExtensions } = require('./paths.js');

const fs = require('fs');
const path = require('path');
const { theiaExtension, extensions, run } = require('./paths.js');

rimraf.sync(extensions());
(async () => {
await new Promise((resolve, reject) => {
ext.packageLocalExtensionsStream(false)
ext.packageLocalExtensionsStream(false, false)
.pipe(vfs.dest(theiaExtension()))
.on('error', reject)
.on('end', resolve);
});
copyYarnLock(vscodeExtensions(), extensions())
await run('yarn', ['install', '--production'], extensions('emmet'));
})();

/**
* The 'yarn.lock' file is now required by the 'vsce' cli.
* This method copies it from the given source folder to a corresponding
* folder in the target.
*
* The method assumes that for each subfolder in the target a corresponding
* subfolder with the same name exists in the source folder.
*
* @param {string} sourceDir - The path of the source folder.
* @param {string} targetDir - The path of the destination folder.
*/
function copyYarnLock(sourceDir, targetDir) {
let subFolderNames = fs.readdirSync(targetDir, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);

for (let subFolderName of subFolderNames) {
let sourceYarnLockPath = path.join(sourceDir, subFolderName, 'yarn.lock');
if (fs.existsSync(sourceYarnLockPath)) {
console.log(`copying: ${sourceYarnLockPath} ${path.join(targetDir, subFolderName)}`);
fs.copyFileSync(sourceYarnLockPath, path.join(targetDir, subFolderName, 'yarn.lock'));
}
}
}
2 changes: 1 addition & 1 deletion vscode
Submodule vscode updated 5314 files

0 comments on commit ec31c74

Please sign in to comment.