Skip to content
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
37 changes: 26 additions & 11 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,36 @@
"version": "2.0.0",
"tasks": [
{
"label": "watch",
"label": "watch:extension",
"type": "npm",
"script": "watch",
"script": "watch:extension",
"isBackground": true,
"problemMatcher": "$tsc-watch"
},
{
"label": "watch:webviews",
"type": "npm",
"script": "watch:webviews",
"isBackground": true,
"problemMatcher": {
"background": {
"beginsPattern": "\\[[^\\]]+\\] File change detected. Compiling...",
"endsPattern": "\\[[^\\]]+\\] Compilation complete. Found (?:no|some) errors. Watching for file changes.",
"activeOnStart": false,
"owner": "custom",
"pattern": {
"regexp": "."
},
"base": "$tsc-watch",
},
"presentation": {
"reveal": "never",
},
"background": {
"activeOnStart": true,
"beginsPattern": ".*Building the webviews\\.\\.\\.",
"endsPattern": ".*Watching the webviews\\.\\.\\."
}
}
},
{
"label": "watch",
"dependsOn": [
"watch:extension",
"watch:webviews"
],
"dependsOrder": "parallel"
},
{
"label": "compile",
Expand Down
2 changes: 2 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ out/build**
out/build/**
out/coverage/**
out/**/*.map
out/esm/**
out/shared/**
out/src-orig/**
out/test/**
out/test-resources/**
Expand Down
61 changes: 61 additions & 0 deletions build/bundle-tools.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

/* eslint-disable guard-for-in */
/* eslint-disable no-console */

const fs = require('fs');
const path = require('path');
const { exit } = require('process');
const { esmAliasPlugin } = require('./esbuild.plugins.cjs');

require('esbuild').build({
entryPoints: [path.resolve(__dirname, '..', 'src/downloadUtil/downloadBinaries.ts')],
platform: 'node',
target: 'node18',
format: 'cjs',
outfile: path.resolve(__dirname, '..', 'out/shared/downloadUtil.js'),
bundle: true,
plugins: [ esmAliasPlugin() ]
}).then(() => {
const { downloadFileAndCreateSha256 } = require(path.resolve(__dirname, '..', 'out/shared/downloadUtil.js'));
const configData = require('../src/tools.json');

async function bundleTools() {
if (process.env.REMOTE_CONTAINERS === 'true') {
return;
}
const outFolder = path.resolve('.', 'out');
const toolsCacheFolder = path.join(outFolder, 'tools-cache');
let currentPlatform = process.env.TARGET;
if (!currentPlatform) {
currentPlatform = process.argv.find((arg) => arg === '--platform')
? process.platform
: 'all';
}
console.info(`Download tools to '${toolsCacheFolder}'`);
for (const key in configData) {
const tool = configData[key];
for (const OS in tool.platform) {
if (currentPlatform === 'all' || OS === currentPlatform) {
console.log(`Bundle '${tool.description}' for ${OS}`);
const osSpecificLocation = path.join(outFolder, 'tools', OS);
// eslint-disable-next-line no-await-in-loop
await downloadFileAndCreateSha256(toolsCacheFolder, osSpecificLocation, tool.platform[OS]);
fs.chmodSync(path.join(osSpecificLocation, tool.platform[OS].cmdFileName), 0o765);
}
}
}
}

bundleTools().catch((error) => {
console.log(error);
exit(1);
});

}).catch(err => {
console.error(err);
exit(1);
});
49 changes: 0 additions & 49 deletions build/bundle-tools.ts

This file was deleted.

99 changes: 99 additions & 0 deletions build/esbuild.build.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

const { execSync } = require('child_process');
const esbuild = require('esbuild');
const { esmAliasPlugin, esbuildProblemMatcherPlugin, nativeNodeModulesPlugin, svgrPlugin, verbosePlugin } = require('./esbuild.plugins.cjs');
const { webviews, srcDir, outDir } = require('./esbuild.settings.cjs');
const { sassPlugin } = require('esbuild-sass-plugin');
const { cp, mkdir, stat } = require('node:fs/promises');
const path = require('path');
const { sync } = require('fast-glob');
const { buildWebviews } = require('./esbuild.webviews.cjs');

const production = process.argv.includes('--production');

// eslint-disable no-console

// Run type-checking

/// Verify the extension
try {
// execSync('tsc --noEmit', { stdio: 'inherit' });
execSync('tsc --noEmit -p tsconfig.json', { stdio: 'inherit' });
} catch (err) {
console.error('❌ TypeScript type-checking failed.');
process.exit(1);
}

console.log(`esbuild: building for production: ${production ? 'Yes' : 'No'}`);

const baseConfig = {
bundle: true,
target: 'chrome108',
minify: production,
sourcemap: !production,
logLevel: 'warning',
};

async function buildExtension() {
console.log(`📦 Building the extension for ${ production ? 'Production' : 'Development'}...`);

if (production) {
// Build the extension.js
const extConfig = {
...baseConfig,
platform: 'node',
format: 'cjs',
entryPoints: [`./${srcDir}/extension.ts`],
outfile: `${outDir}/${srcDir}/extension.js`,
external: [ 'vscode', 'shelljs', 'jsonc-parser' ],
plugins: [
nativeNodeModulesPlugin(),
esbuildProblemMatcherPlugin(production) // this one is to be added to the end of plugins array
]
};
await esbuild.build(extConfig);
console.log('✅ Extension build completed');
} else {
// Build the Extension for development
const srcFiles = sync(`${srcDir}/**/*.{js,ts}`, { absolute: false });
const devExtConfig = {
...baseConfig,
platform: 'node',
format: 'cjs',
entryPoints: srcFiles.map(f => `./${f}`),
outbase: srcDir,
outdir: `${outDir}/${srcDir}`,
external: [ 'vscode', 'shelljs', 'jsonc-parser', '@aws-sdk/client-s3' ],
plugins: [
// verbosePlugin(),
esmAliasPlugin(),
nativeNodeModulesPlugin(),
esbuildProblemMatcherPlugin(production) // this one is to be added to the end of plugins array
]
};

await esbuild.build(devExtConfig);

const jsonFiles = sync('src/**/*.json', { absolute: false });
for (const file of jsonFiles) {
const dest = path.join('out', file);
await cp(file, dest, { recursive: false, force: true });
}
await cp('package.json', 'out/package.json');
console.log('✅ Extension build completed');
}
}

async function buildAll() {
await buildExtension();
await buildWebviews();
}

buildAll().catch(err => {
console.error('❌ Build failed:', err);
process.exit(1);
});
Loading
Loading