Skip to content

Commit

Permalink
got whoami working (on windows)
Browse files Browse the repository at this point in the history
  • Loading branch information
Melody Universe authored and melody-universe committed Apr 20, 2021
1 parent 53eeea1 commit 187d9e5
Show file tree
Hide file tree
Showing 14 changed files with 1,939 additions and 82 deletions.
3 changes: 1 addition & 2 deletions extension/extension-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
"addressable": true
},
{
"path": "package",
"addressable": true
"path": "tasks"
}
]
}
11 changes: 5 additions & 6 deletions gulp/compile.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const ts = require("gulp-typescript");
const gulp = require("gulp");
const sourcemaps = require("gulp-sourcemaps");
const webpackStream = require("webpack-stream");

module.exports = function compile() {
const tsProj = ts.createProject("tsconfig.json");
const config = require("../webpack.config");
return gulp
.src("src/**/*.ts")
.pipe(sourcemaps.init())
.pipe(tsProj())
.pipe(sourcemaps.write("./", { sourceRoot: "./", includeContent: false }))
.pipe(gulp.dest("dist"));
.src("src/tasks/whoami/whoami-v0/index.ts")
.pipe(webpackStream(config))
.pipe(gulp.dest("dist/"));
};
67 changes: 43 additions & 24 deletions gulp/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ const {
rm,
copy,
existsSync,
stat,
write,
writeFile,
} = require("fs-extra");
const createTfxRunner = require("./lib/createTfxRunner");
const { argv } = require("process");
Expand All @@ -25,10 +22,10 @@ module.exports = async () => {
await clean();

await generateNpmPackage();
await copyDependencies();
setVersion(manifest);
setContributions(manifest);
await addTaskJsonFiles();
await removeInvalidFiles();
await copy("extension/assets", `${primedExtensionDir}/assets`, {
recursive: true,
});
Expand All @@ -54,10 +51,22 @@ async function generateNpmPackage() {
const npm = createCommandRunner(pkgFolder, "npm", console);
const results = await npm("pack", "../..");
const fileName = results[0];
console.log(`extracting ${pkgFolder}/${fileName}`);
await extract({
file: `${pkgFolder}/${fileName}`,
cwd: primedExtensionDir,
cwd: pkgFolder,
});
await copy(`${pkgFolder}/package/dist`, primedExtensionDir, {
recursive: true,
});
await removeInvalidFiles();
}

async function removeInvalidFiles() {
await new Promise((resolve) => {
find.file(/[#^[\]<>?\s]/, `out/npm-package/package/bin`, async (files) => {
await Promise.all(files.map((file) => rm(file)));
resolve();
});
});
}

Expand Down Expand Up @@ -96,8 +105,7 @@ function setContributions(manifest) {
type: "ms.vss-distributed-task.task",
targets: ["ms.vss-distributed-task.tasks"],
properties: {
name: task.name,
uri: "package/dist/tasks",
name: `tasks/${task.name}`,
},
})),
...serviceConnections,
Expand All @@ -110,27 +118,35 @@ async function addTaskJsonFiles() {
await Promise.all(
files.map((file) => {
const relativePath = file.replace(/src\//, "");
return copy(
file,
`${primedExtensionDir}/package/dist/${relativePath}`
);
return copy(file, `${primedExtensionDir}/${relativePath}`);
})
);
resolve();
});
});
}

async function removeInvalidFiles() {
async function copyDependencies() {
const nodeModulesFolder = path.resolve(
"out/npm-package/package/node_modules"
);
const binFolder = path.resolve("out/npm-package/package/bin");

await new Promise((resolve) => {
find.file(
/[#^[\]<>?\s]/,
`${primedExtensionDir}/package/bin`,
async (files) => {
await Promise.all(files.map((file) => rm(file)));
resolve();
}
);
find.file(/tasks\/.*\/index\.js$/, primedExtensionDir, async (tasks) => {
const copyPromises = [];
tasks.forEach((task) => {
const taskDir = path.dirname(task);
copyPromises.push(
copy(nodeModulesFolder, `${taskDir}/node_modules`, {
recursive: true,
}),
copy(binFolder, `${taskDir}/bin`, { recursive: true })
);
});
await Promise.all(copyPromises);
resolve();
});
});
}

Expand All @@ -143,19 +159,22 @@ async function generateAllStages(manifest) {

const taskMetadata = require("../extension/task-metadata.json");

for (const stage of ["LIVE", "BETA", "DEV", "EXPERIMENTAL"]) {
for (const stage of ["EXPERIMENTAL"]) {
const stageManifest = JSON.parse(JSON.stringify(manifest));
if (stage !== "LIVE") {
stageManifest.name = `${stageManifest.name} ([${stage}] ${stageManifest.version})`;
stageManifest.id = `${stageManifest.id}-${stage}`;
} else {
stageManifest.name = `${stageManifest.name} (${stageManifest.version})`;
}
await new Promise((resolve) =>
find.file(
/task.json$/,
`${primedExtensionDir}/package/dist`,
`${primedExtensionDir}`,
async (taskFileNames) => {
await Promise.all(
taskFileNames.map(async (taskFileName) => {
const localTaskId = /^out\/primed-extension\/package\/dist\/tasks\/([^/]*)/.exec(
const localTaskId = /^out\/primed-extension\/tasks\/([^/]*)/.exec(
taskFileName
)[1];
const taskJson = require(path.resolve(taskFileName));
Expand Down
Loading

0 comments on commit 187d9e5

Please sign in to comment.