Skip to content

Commit

Permalink
formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagarjun Sanji committed Jul 4, 2024
1 parent c7356db commit 31992fa
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"tabWidth": 4,
"endOfLine": "auto"
}
}
10 changes: 5 additions & 5 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defineConfig } from '@vscode/test-cli';
import { defineConfig } from "@vscode/test-cli";

export default defineConfig({
files: 'out/test/**/*.test.js',
mocha: {
ui: 'bdd'
}
files: "out/test/**/*.test.js",
mocha: {
ui: "bdd",
},
});
84 changes: 42 additions & 42 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
const esbuild = require("esbuild");

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

/**
* @type {import('esbuild').Plugin}
*/
const esbuildProblemMatcherPlugin = {
name: 'esbuild-problem-matcher',
name: "esbuild-problem-matcher",

setup(build) {
build.onStart(() => {
console.log('[watch] build started');
});
build.onEnd((result) => {
result.errors.forEach(({ text, location }) => {
console.error(`✘ [ERROR] ${text}`);
console.error(` ${location.file}:${location.line}:${location.column}:`);
});
console.log('[watch] build finished');
});
},
setup(build) {
build.onStart(() => {
console.log("[watch] build started");
});
build.onEnd((result) => {
result.errors.forEach(({ text, location }) => {
console.error(`✘ [ERROR] ${text}`);
console.error(
` ${location.file}:${location.line}:${location.column}:`,
);
});
console.log("[watch] build finished");
});
},
};

async function main() {
const ctx = await esbuild.context({
entryPoints: [
'src/extension.ts'
],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'node',
outfile: 'dist/extension.js',
external: ['vscode'],
logLevel: 'silent',
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin,
],
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
const ctx = await esbuild.context({
entryPoints: ["src/extension.ts"],
bundle: true,
format: "cjs",
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: "node",
outfile: "dist/extension.js",
external: ["vscode"],
logLevel: "silent",
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin,
],
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}

main().catch(e => {
console.error(e);
process.exit(1);
main().catch((e) => {
console.error(e);
process.exit(1);
});
132 changes: 66 additions & 66 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
{
"name": "vs-code-extension",
"displayName": "debricked",
"description": "A fast and flexible software composition analysis VS Code Extension and CLI tool, given to you by Debricked.",
"publisher": "debricked",
"version": "0.0.1",
"engines": {
"vscode": "^1.90.0"
},
"categories": [
"Other"
],
"activationEvents": [],
"main": "./dist/extension.js",
"contributes": {
"commands": [
{
"command": "debricked.debricked",
"title": "Debricked : A fast and flexible software composition analysis CLI tool, given to you by Debricked.",
"category": "debricked"
},
{
"command": "debricked.help",
"title": "Help about any command",
"category": "debricked"
}
]
},
"scripts": {
"vscode:prepublish": "npm run package",
"compile": "npm run check-types && npm run lint && node esbuild.js",
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"package": "npm run check-types && npm run lint && node esbuild.js --production",
"compile-tests": "npm run clean && tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"check-types": "tsc --noEmit",
"lint": "eslint src --ext ts",
"lint:fix": "eslint --fix src --ext ts",
"test": "vscode-test --coverage",
"clean": "rimraf out && rimraf dist && rimraf coverage",
"clean-all": "rimraf out && rimraf dist && rimraf coverage && rimraf .vscode-test",
"postinstall": "node ./postinstall.js"
},
"devDependencies": {
"@types/chai": "^4.3.16",
"@types/mocha": "^10.0.6",
"@types/node": "20.x",
"@types/sinon": "^17.0.3",
"@types/vscode": "^1.90.0",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.0",
"chai": "^5.1.1",
"esbuild": "^0.21.5",
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-config-prettier": "^9.1.0",
"mocha": "^10.4.0",
"npm-run-all": "^4.1.5",
"sinon": "^18.0.0",
"typescript": "^5.4.5"
}
}
"name": "vs-code-extension",
"displayName": "debricked",
"description": "A fast and flexible software composition analysis VS Code Extension and CLI tool, given to you by Debricked.",
"publisher": "debricked",
"version": "0.0.1",
"engines": {
"vscode": "^1.90.0"
},
"categories": [
"Other"
],
"activationEvents": [],
"main": "./dist/extension.js",
"contributes": {
"commands": [
{
"command": "debricked.debricked",
"title": "Debricked : A fast and flexible software composition analysis CLI tool, given to you by Debricked.",
"category": "debricked"
},
{
"command": "debricked.help",
"title": "Help about any command",
"category": "debricked"
}
]
},
"scripts": {
"vscode:prepublish": "npm run package",
"compile": "npm run check-types && npm run lint && node esbuild.js",
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"package": "npm run check-types && npm run lint && node esbuild.js --production",
"compile-tests": "npm run clean && tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"check-types": "tsc --noEmit",
"lint": "eslint src --ext ts",
"lint:fix": "eslint --fix src --ext ts",
"test": "vscode-test --coverage",
"clean": "rimraf out && rimraf dist && rimraf coverage",
"clean-all": "rimraf out && rimraf dist && rimraf coverage && rimraf .vscode-test",
"postinstall": "node ./postinstall.js"
},
"devDependencies": {
"@types/chai": "^4.3.16",
"@types/mocha": "^10.0.6",
"@types/node": "20.x",
"@types/sinon": "^17.0.3",
"@types/vscode": "^1.90.0",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.0",
"chai": "^5.1.1",
"esbuild": "^0.21.5",
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-config-prettier": "^9.1.0",
"mocha": "^10.4.0",
"npm-run-all": "^4.1.5",
"sinon": "^18.0.0",
"typescript": "^5.4.5"
}
}
50 changes: 27 additions & 23 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
const { exec } = require('child_process');
const path = require('path');
const os = require('os');
const { exec } = require("child_process");
const path = require("path");
const os = require("os");

const platform = os.platform();
console.info("Debricked running on:", platform);

function getScriptPaths() {
const scriptDir = path.join(__dirname, './resources/debricked-cli');
const scriptDir = path.join(__dirname, "./resources/debricked-cli");
switch (platform) {
case 'win32':
case "win32":
return {
uninstall: path.join(scriptDir, 'uninstall-debricked.bat'),
install: path.join(scriptDir, 'install-debricked.bat'),
command: '' // No command prefix needed for .bat files
uninstall: path.join(scriptDir, "uninstall-debricked.bat"),
install: path.join(scriptDir, "install-debricked.bat"),
command: "", // No command prefix needed for .bat files
};
case 'linux':
case 'darwin':
case "linux":
case "darwin":
return {
uninstall: path.join(scriptDir, 'uninstall-debricked.sh'),
install: path.join(scriptDir, 'install-debricked.sh'),
command: 'bash'
uninstall: path.join(scriptDir, "uninstall-debricked.sh"),
install: path.join(scriptDir, "install-debricked.sh"),
command: "bash",
};
default:
throw new Error('Unsupported operating system');
throw new Error("Unsupported operating system");
}
}

Expand All @@ -42,21 +42,25 @@ async function runScripts() {
try {
const { uninstall, install, command } = getScriptPaths();

console.log('Starting un-installation...');
const uninstallCommand = platform === 'win32' ? `"${uninstall}"` : `${command} "${uninstall}"`;
console.log("Starting un-installation...");
const uninstallCommand =
platform === "win32"
? `"${uninstall}"`
: `${command} "${uninstall}"`;
const uninstallOutput = await executeCommand(uninstallCommand);
console.log('Uninstall output:', uninstallOutput);
console.log("Uninstall output:", uninstallOutput);

console.log('Starting installation...');
const installCommand = platform === 'win32' ? `"${install}"` : `${command} "${install}"`;
console.log("Starting installation...");
const installCommand =
platform === "win32" ? `"${install}"` : `${command} "${install}"`;
const installOutput = await executeCommand(installCommand);
console.log('Install output:', installOutput);
console.log("Install output:", installOutput);

console.log('Scripts executed successfully');
console.log("Scripts executed successfully");
} catch (error) {
console.error('Script execution failed:', error.message);
console.error("Script execution failed:", error.message);
process.exit(1);
}
}

runScripts();
runScripts();

0 comments on commit 31992fa

Please sign in to comment.