in build-scripts/packageExtension.ts [85:184]
function packagePlugin(options: CommandLineOptions) {
fs.mkdirpSync(folders.packageRoot)
fs.mkdirpSync(folders.packageTasks)
const npmFolder = path.join(folders.buildRoot, 'npmcache')
fs.copySync(path.join(folders.repoRoot, 'LICENSE'), path.join(folders.packageRoot, 'LICENSE'), { overwrite: true })
fs.copySync(path.join(folders.repoRoot, 'README.md'), path.join(folders.packageRoot, 'README.md'), {
overwrite: true
})
fs.copySync(path.join(folders.repoRoot, 'build', manifestFile), path.join(folders.packageRoot, manifestFile), {
overwrite: true
})
generateGitHashFile()
// stage manifest images
fs.copySync(path.join(folders.repoRoot, 'images'), path.join(folders.packageRoot, 'images'), { overwrite: true })
// get required npm packages that will be copied
installNodePackages(npmFolder)
shelljsPatch.patch()
// clean, dedupe and pack each task as needed
findMatchingFiles(folders.sourceTasks).forEach(function(taskName) {
console.log('Processing task ' + taskName)
if (ignoredFolders.some(folderName => folderName === taskName)) {
console.log('Skpping task ' + taskName)
return
}
const taskBuildFolder = path.join(folders.buildTasks, taskName)
const taskPackageFolder = path.join(folders.packageTasks, taskName)
fs.mkdirpSync(taskPackageFolder)
// eslint-disable-next-line @typescript-eslint/no-var-requires
const taskDef = require(path.join(taskBuildFolder, 'task.json'))
if (
!Object.hasOwnProperty.call(taskDef.execution, 'Node') &&
!Object.hasOwnProperty.call(taskDef.execution, 'Node10') &&
!Object.hasOwnProperty.call(taskDef.execution, 'Node14')
) {
console.log('Copying non-node task ' + taskName)
fs.copySync(taskBuildFolder, taskPackageFolder)
return
}
for (const resourceFile of vstsFiles) {
fs.copySync(path.join(taskBuildFolder, resourceFile), path.join(taskPackageFolder, resourceFile), {
overwrite: true
})
}
// we also need lib.json from azure pipelines task lib or else localization will not work properly
fs.copySync(
path.join(folders.repoRoot, 'node_modules/azure-pipelines-task-lib/lib.json'),
path.join(taskPackageFolder, 'lib.json'),
{ overwrite: true }
)
const inputFilename = path.join(taskBuildFolder, taskName + '.runner.js')
console.log('packing node-based task')
const result = esbuild.buildSync({
entryPoints: [inputFilename],
bundle: true,
platform: 'node',
target: ['node10'],
minify: true,
outfile: `${taskPackageFolder}/${taskName}.js`
})
result.warnings.forEach(warning => console.log(warning))
})
shelljsPatch.unpatch()
console.log('Creating deployment vsix')
const binName = os.platform() === 'win32' ? `tfx.cmd` : 'tfx'
const tfx = path.join(process.cwd(), 'node_modules', '.bin', binName)
const args: string[] = ['extension', 'create', '--root', folders.packageRoot]
args.push('--output-path', folders.packageRoot)
args.push('--manifests', path.join(folders.packageRoot, manifestFile))
if (options.publisher) {
args.push('--publisher', options.publisher)
}
console.log('Packaging with:' + `${tfx} ${args.join(' ')}`)
ncp.execFileSync(tfx, args, {
stdio: 'inherit',
shell: os.platform() === 'win32' // for tfx.cmd on Windows.
})
console.log('Packaging successful')
}