Skip to content

Commit

Permalink
VSTS-268 HotFix shelljs dependency at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
7PH committed May 27, 2024
1 parent cdd6684 commit e6db73b
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 3 deletions.
16 changes: 13 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require("path");
const gulp = require("gulp");
const gulpFile = require("gulp-file");
const fs = require("fs-extra");
const yargs = require("yargs");
const gulpReplace = require("gulp-replace");
Expand Down Expand Up @@ -110,11 +111,11 @@ gulp.task("build:typescript", () => {
* Bundle tasks
*/
gulp.task("build:bundle", async () => {
const tasks = globby.sync(["src/extensions/*/tasks/*/v*/*.ts"]);
const tasks = globby.sync(path.join(SOURCE_DIR, "extensions", "*", "tasks", "*", "v*", "*.ts"));
for (const task of tasks) {
const [extension, , taskName, version] = task.split(path.sep).slice(-5);
const commonFolder = getTaskCommonFolder(taskName, version);
const outFilePath = task.replace(/^src/, BUILD_DIR).replace(/\.ts$/, ".js");
const outFilePath = task.replace(SOURCE_DIR, BUILD_DIR).replace(/\.ts$/, ".js");

// eslint-disable-next-line import/no-dynamic-require
const esbuildConfig = require(
Expand Down Expand Up @@ -175,9 +176,18 @@ gulp.task("build:copy", () => {
const version = path.basename(path.dirname(task));
const commonPath = getTaskCommonFolder(taskName, version); // What common files to copy (latest vs legacy?)

// Where to copy the task code
// Where to copy the task files
const outPath = path.join(BUILD_EXTENSION_DIR, extension, "tasks", taskName, version);

/**
* Hotfix for shelljs dependency
* @see https://github.com/microsoft/azure-pipelines-task-lib/issues/942#issuecomment-1904939900
*/
const createShellJsDummyFile = gulpFile("index.js", "", { src: true }).pipe(
gulp.dest(path.join(outPath, "node_modules", "shelljs")),
);
streams.push(createShellJsDummyFile);

// Copy task icon
streams.push(
gulp
Expand Down
63 changes: 63 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"gulp-decompress": "2.0.2",
"gulp-download": "0.0.1",
"gulp-exec": "5.0.0",
"gulp-file": "^0.4.0",
"gulp-json-editor": "2.5.6",
"gulp-rename": "1.2.2",
"gulp-replace": "0.6.1",
Expand Down
4 changes: 4 additions & 0 deletions src/common/latest/esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ module.exports = {
format: "cjs",
target: "node10",
minify: true,
/**
* @see https://github.com/microsoft/azure-pipelines-task-lib/issues/942#issuecomment-1904939900
*/
external: ["shelljs"],
};
1 change: 1 addition & 0 deletions src/common/sonarcloud-v1/esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ module.exports = {
format: "cjs",
target: "node10",
minify: true,
external: ["shelljs"],
};
1 change: 1 addition & 0 deletions src/common/sonarqube-v4/esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ module.exports = {
format: "cjs",
target: "node8",
minify: true,
external: ["shelljs"],
};
1 change: 1 addition & 0 deletions src/common/sonarqube-v5/esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ module.exports = {
format: "cjs",
target: "node10",
minify: true,
external: ["shelljs"],
};

0 comments on commit e6db73b

Please sign in to comment.