diff --git a/build/gulpfile.reh.js b/build/gulpfile.reh.js index d809898b031..28db854083c 100644 --- a/build/gulpfile.reh.js +++ b/build/gulpfile.reh.js @@ -29,7 +29,8 @@ const glob = require('glob'); const { compileBuildTask } = require('./gulpfile.compile'); const { compileExtensionsBuildTask, compileExtensionMediaBuildTask } = require('./gulpfile.extensions'); // --- Start Positron --- -const { vscodeWebEntryPoints, vscodeWebResourceIncludes, createVSCodeWebFileContentMapper, positronBuildNumber } = require('./gulpfile.vscode.web'); +const { vscodeWebEntryPoints, vscodeWebResourceIncludes, createVSCodeWebFileContentMapper } = require('./gulpfile.vscode.web'); +const { positronBuildNumber } = require('./utils'); // --- End Positron --- const cp = require('child_process'); const log = require('fancy-log'); diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 826eea8ee4c..d933164c907 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -38,9 +38,9 @@ const glob = promisify(require('glob')); const rcedit = promisify(require('rcedit')); // --- Start Positron --- -const child_process = require('child_process'); const fancyLog = require('fancy-log'); const { getQuartoStream } = require('./lib/quarto'); +const { positronBuildNumber } = require('./utils'); // --- End Positron --- // Build @@ -342,14 +342,6 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op // --- Start Positron --- const positronVersion = product.positronVersion; - - // Use the POSITRON_BUILD_NUMBER var if it's set; otherwise, call - // show-version to compute it. - const positronBuildNumber = - process.env.POSITRON_BUILD_NUMBER ?? - child_process.execSync( - `node ${path.dirname(__dirname)}/versions/show-version.js --build`).toString().trim(); - // --- End Positron --- const quality = product.quality; diff --git a/build/gulpfile.vscode.linux.js b/build/gulpfile.vscode.linux.js index ccd36167298..a65e0489528 100644 --- a/build/gulpfile.vscode.linux.js +++ b/build/gulpfile.vscode.linux.js @@ -21,6 +21,10 @@ const path = require('path'); const cp = require('child_process'); const util = require('util'); +// --- Start Positron --- +const { positronBuildNumber } = require('./utils'); +// --- End Positron --- + const exec = util.promisify(cp.exec); const root = path.dirname(__dirname); const commit = getVersion(root); @@ -100,8 +104,8 @@ function prepareDebPackage(arch) { .pipe(replace('@@NAME@@', product.applicationName)) // --- Start Positron --- .pipe(replace('@@VERSION@@', product.version)) - .pipe(replace('@@POSITRONVERSION@@', `${product.positronVersion}+${product.positronBuildNumber}-${linuxPackageRevision}`)) - .pipe(replace('@@BUILDNUMBER@@', product.positronBuildNumber)) + .pipe(replace('@@POSITRONVERSION@@', `${product.positronVersion}+${positronBuildNumber}-${linuxPackageRevision}`)) + .pipe(replace('@@BUILDNUMBER@@', positronBuildNumber)) // --- End Positron --- .pipe(replace('@@ARCHITECTURE@@', debArch)) .pipe(replace('@@DEPENDS@@', dependencies.join(', '))) @@ -226,8 +230,8 @@ function prepareRpmPackage(arch) { .pipe(replace('@@ICON@@', product.linuxIconName)) // --- Start Positron --- .pipe(replace('@@VERSION@@', product.version)) - .pipe(replace('@@POSITRONVERSION@@', `${product.positronVersion}+${product.positronBuildNumber}`)) - .pipe(replace('@@BUILDNUMBER@@', product.positronBuildNumber)) + .pipe(replace('@@POSITRONVERSION@@', `${product.positronVersion}+${positronBuildNumber}`)) + .pipe(replace('@@BUILDNUMBER@@', positronBuildNumber)) // --- End Positron --- .pipe(replace('@@RELEASE@@', linuxPackageRevision)) .pipe(replace('@@ARCHITECTURE@@', rpmArch)) diff --git a/build/gulpfile.vscode.web.js b/build/gulpfile.vscode.web.js index c18944f859c..dab6f93bffd 100644 --- a/build/gulpfile.vscode.web.js +++ b/build/gulpfile.vscode.web.js @@ -24,7 +24,7 @@ const extensions = require('./lib/extensions'); const { isESM } = require('./lib/esm'); // --- Start Positron --- -const child_process = require('child_process'); +const { positronBuildNumber } = require('./utils'); // --- End Positron --- const REPO_ROOT = path.dirname(__dirname); @@ -135,14 +135,6 @@ const vscodeWebEntryPoints = isESM() ? [ buildfile.workbenchWeb() ].flat(); -// --- Begin Positron --- -// Use the POSITRON_BUILD_NUMBER var if it's set; otherwise, call show-version to compute it. -const positronBuildNumber = - process.env.POSITRON_BUILD_NUMBER ?? - child_process.execSync(`node ${REPO_ROOT}/versions/show-version.js --build`).toString().trim(); -exports.positronBuildNumber = positronBuildNumber; -// --- End Positron --- - /** * @param {object} product The parsed product.json file contents */ diff --git a/build/utils.js b/build/utils.js new file mode 100644 index 00000000000..1a4e8ec415c --- /dev/null +++ b/build/utils.js @@ -0,0 +1,19 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (C) 2024 Posit Software, PBC. All rights reserved. + * Licensed under the Elastic License 2.0. See LICENSE.txt for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +const child_process = require('child_process'); +const path = require('path'); + +const REPO_ROOT = path.dirname(__dirname); + +/** + * Get the build number for Positron. + */ +const positronBuildNumber = + process.env.POSITRON_BUILD_NUMBER ?? + child_process.execSync(`node ${REPO_ROOT}/versions/show-version.js --build`).toString().trim(); +exports.positronBuildNumber = positronBuildNumber;