feat:添加IDEVersion字段,编译出deb版本号、在about页面和命令行查看显示IDEVersion版本号

This commit is contained in:
wangpenglong 2024-03-14 19:11:52 +08:00
parent 3461c787ea
commit ba6b8fdd8d
12 changed files with 39 additions and 31 deletions

View File

@ -286,14 +286,15 @@ function packageTask(type, platform, arch, sourceFolderName, destinationFolderNa
version += '-' + quality; version += '-' + quality;
} }
const IDEVersion = packageJson.IDEVersion;
const name = product.nameShort; const name = product.nameShort;
const packageJsonStream = gulp.src(['remote/package.json'], { base: 'remote' }) const packageJsonStream = gulp.src(['remote/package.json'], { base: 'remote' })
.pipe(json({ name, version, dependencies: undefined, optionalDependencies: undefined })); .pipe(json({ name, IDEVersion, version, dependencies: undefined, optionalDependencies: undefined }));
const date = new Date().toISOString(); const date = new Date().toISOString();
const productJsonStream = gulp.src(['product.json'], { base: '.' }) const productJsonStream = gulp.src(['product.json'], { base: '.' })
.pipe(json({ commit, date, version })); .pipe(json({ commit, date, IDEVersion, version }));
const license = gulp.src(['remote/LICENSE'], { base: 'remote', allowEmpty: true }); const license = gulp.src(['remote/LICENSE'], { base: 'remote', allowEmpty: true });

View File

@ -238,8 +238,9 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
version += '-' + quality; version += '-' + quality;
} }
const IDEVersion = packageJson.IDEVersion;
const name = product.nameShort; const name = product.nameShort;
const packageJsonUpdates = { name, version }; const packageJsonUpdates = { name, version, IDEVersion };
// for linux url handling // for linux url handling
if (platform === 'linux') { if (platform === 'linux') {
@ -250,7 +251,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
.pipe(json(packageJsonUpdates)); .pipe(json(packageJsonUpdates));
const date = new Date().toISOString(); const date = new Date().toISOString();
const productJsonUpdate = { commit, date, checksums, version }; const productJsonUpdate = { commit, date, checksums, version, IDEVersion };
const productJsonStream = gulp.src(['product.json'], { base: '.' }) const productJsonStream = gulp.src(['product.json'], { base: '.' })
.pipe(json(productJsonUpdate)); .pipe(json(productJsonUpdate));

View File

@ -23,7 +23,7 @@ const path = require('path');
const root = path.dirname(__dirname); const root = path.dirname(__dirname);
const commit = getVersion(root); const commit = getVersion(root);
const linuxPackageRevision = Math.floor(new Date().getTime() / 1000); // const linuxPackageRevision = Math.floor(new Date().getTime() / 1000);
/** /**
* @param {string} arch * @param {string} arch
@ -86,7 +86,7 @@ function prepareDebPackage(arch) {
const dependencies = dependenciesGenerator.getDependencies('deb', binaryDir, product.applicationName, debArch, sysroot); const dependencies = dependenciesGenerator.getDependencies('deb', binaryDir, product.applicationName, debArch, sysroot);
gulp.src('resources/linux/debian/control.template', { base: '.' }) gulp.src('resources/linux/debian/control.template', { base: '.' })
.pipe(replace('@@NAME@@', product.applicationName)) .pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@VERSION@@', packageJson.version + '-' + linuxPackageRevision)) .pipe(replace('@@VERSION@@', packageJson.IDEVersion))
.pipe(replace('@@ARCHITECTURE@@', debArch)) .pipe(replace('@@ARCHITECTURE@@', debArch))
.pipe(replace('@@DEPENDS@@', dependencies.join(', '))) .pipe(replace('@@DEPENDS@@', dependencies.join(', ')))
.pipe(replace('@@RECOMMENDS@@', debianRecommendedDependencies.join(', '))) .pipe(replace('@@RECOMMENDS@@', debianRecommendedDependencies.join(', ')))
@ -186,19 +186,23 @@ function prepareRpmPackage(arch) {
const code = gulp.src(binaryDir + '/**/*', { base: binaryDir }) const code = gulp.src(binaryDir + '/**/*', { base: binaryDir })
.pipe(rename(function (p) { p.dirname = 'BUILD/usr/share/' + product.applicationName + '/' + p.dirname; })); .pipe(rename(function (p) { p.dirname = 'BUILD/usr/share/' + product.applicationName + '/' + p.dirname; }));
const dependencies = dependenciesGenerator.getDependencies('rpm', binaryDir, product.applicationName, rpmArch); const spec = code.pipe(es.through(
const spec = gulp.src('resources/linux/rpm/code.spec.template', { base: '.' }) async function () {
const that = this;
const dependencies = await dependenciesGenerator.getDependencies('rpm', binaryDir, product.applicationName, rpmArch);
gulp.src('resources/linux/rpm/code.spec.template', { base: '.' })
.pipe(replace('@@NAME@@', product.applicationName)) .pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@NAME_LONG@@', product.nameLong)) .pipe(replace('@@NAME_LONG@@', product.nameLong))
.pipe(replace('@@ICON@@', product.linuxIconName)) .pipe(replace('@@ICON@@', product.linuxIconName))
.pipe(replace('@@VERSION@@', packageJson.version)) .pipe(replace('@@VERSION@@', packageJson.IDEVersion))
.pipe(replace('@@RELEASE@@', linuxPackageRevision))
.pipe(replace('@@ARCHITECTURE@@', rpmArch)) .pipe(replace('@@ARCHITECTURE@@', rpmArch))
.pipe(replace('@@LICENSE@@', product.licenseName)) .pipe(replace('@@LICENSE@@', product.licenseName))
.pipe(replace('@@QUALITY@@', product.quality || '@@QUALITY@@')) .pipe(replace('@@QUALITY@@', product.quality || '@@QUALITY@@'))
.pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@')) .pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@'))
.pipe(replace('@@DEPENDENCIES@@', dependencies.join(', '))) .pipe(replace('@@DEPENDENCIES@@', dependencies.join(', ')))
.pipe(rename('SPECS/' + product.applicationName + '.spec')); .pipe(rename('SPECS/' + product.applicationName + '.spec'))
.pipe(es.through(function (f) { that.emit('data', f); }, function () { that.emit('end'); }));
}));
const specIcon = gulp.src('resources/linux/rpm/code.xpm', { base: '.' }) const specIcon = gulp.src('resources/linux/rpm/code.xpm', { base: '.' })
.pipe(rename('SOURCES/' + product.applicationName + '.xpm')); .pipe(rename('SOURCES/' + product.applicationName + '.xpm'));
@ -265,7 +269,7 @@ function prepareSnapPackage(arch) {
const snapcraft = gulp.src('resources/linux/snap/snapcraft.yaml', { base: '.' }) const snapcraft = gulp.src('resources/linux/snap/snapcraft.yaml', { base: '.' })
.pipe(replace('@@NAME@@', product.applicationName)) .pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@VERSION@@', commit.substr(0, 8))) .pipe(replace('@@VERSION@@', packageJson.IDEVersion))
// Possible run-on values https://snapcraft.io/docs/architectures // Possible run-on values https://snapcraft.io/docs/architectures
.pipe(replace('@@ARCHITECTURE@@', arch === 'x64' ? 'amd64' : arch)) .pipe(replace('@@ARCHITECTURE@@', arch === 'x64' ? 'amd64' : arch))
.pipe(rename('snap/snapcraft.yaml')); .pipe(rename('snap/snapcraft.yaml'));

View File

@ -28,7 +28,7 @@ const WEB_FOLDER = path.join(REPO_ROOT, 'remote', 'web');
const commit = getVersion(REPO_ROOT); const commit = getVersion(REPO_ROOT);
const quality = product.quality; const quality = product.quality;
const version = (quality && quality !== 'stable') ? `${packageJson.version}-${quality}` : packageJson.version; const version = (quality && quality !== 'stable') ? `${packageJson.IDEVersion}-${quality}` : packageJson.IDEVersion;
const vscodeWebResourceIncludes = [ const vscodeWebResourceIncludes = [
// Workbench // Workbench

View File

@ -88,8 +88,8 @@ function buildWin32Setup(arch, target) {
NameLong: product.nameLong, NameLong: product.nameLong,
NameShort: product.nameShort, NameShort: product.nameShort,
DirName: product.win32DirName, DirName: product.win32DirName,
Version: pkg.version, Version: pkg.IDEVersion,
RawVersion: pkg.version.replace(/-\w+$/, ''), RawVersion: pkg.IDEVersion.replace(/-\w+$/, ''),
NameVersion: product.win32NameVersion + (target === 'user' ? ' (User)' : ''), NameVersion: product.win32NameVersion + (target === 'user' ? ' (User)' : ''),
ExeBasename: product.nameShort, ExeBasename: product.nameShort,
RegValueName: product.win32RegValueName, RegValueName: product.win32RegValueName,

View File

@ -55,6 +55,7 @@ export type ExtensionVirtualWorkspaceSupport = {
}; };
export interface IProductConfiguration { export interface IProductConfiguration {
readonly IDEVersion: string;
readonly version: string; readonly version: string;
readonly date?: string; readonly date?: string;
readonly quality?: string; readonly quality?: string;

View File

@ -83,12 +83,12 @@ export async function main(argv: string[]): Promise<any> {
// Help // Help
if (args.help) { if (args.help) {
const executable = `${product.applicationName}${isWindows ? '.exe' : ''}`; const executable = `${product.applicationName}${isWindows ? '.exe' : ''}`;
console.log(buildHelpMessage(product.nameLong, executable, product.version, OPTIONS)); console.log(buildHelpMessage(product.nameLong, executable, product.IDEVersion, OPTIONS));
} }
// Version Info // Version Info
else if (args.version) { else if (args.version) {
console.log(buildVersionMessage(product.version, product.commit)); console.log(buildVersionMessage(product.IDEVersion, product.commit));
} }
// Shell integration // Shell integration

View File

@ -222,7 +222,7 @@ export class DiagnosticsService implements IDiagnosticsService {
private formatEnvironment(info: IMainProcessDiagnostics): string { private formatEnvironment(info: IMainProcessDiagnostics): string {
const output: string[] = []; const output: string[] = [];
output.push(`Version: ${this.productService.nameShort} ${this.productService.version} (${this.productService.commit || 'Commit unknown'}, ${this.productService.date || 'Date unknown'})`); output.push(`Version: ${this.productService.nameShort} ${this.productService.IDEVersion} (${this.productService.commit || 'Commit unknown'}, ${this.productService.date || 'Date unknown'})`);
output.push(`OS Version: ${osLib.type()} ${osLib.arch()} ${osLib.release()}`); output.push(`OS Version: ${osLib.type()} ${osLib.arch()} ${osLib.release()}`);
const cpus = osLib.cpus(); const cpus = osLib.cpus();
if (cpus && cpus.length > 0) { if (cpus && cpus.length > 0) {

View File

@ -41,9 +41,10 @@ else if (globalThis._VSCODE_PRODUCT_JSON && globalThis._VSCODE_PACKAGE_JSON) {
// want to have it running out of sources so we // want to have it running out of sources so we
// read it from package.json only when we need it. // read it from package.json only when we need it.
if (!product.version) { if (!product.version) {
const pkg = globalThis._VSCODE_PACKAGE_JSON as { version: string }; const pkg = globalThis._VSCODE_PACKAGE_JSON as { IDEVersion: string; version: string };
Object.assign(product, { Object.assign(product, {
IDEVersion: pkg.IDEVersion,
version: pkg.version version: pkg.version
}); });
} }

View File

@ -177,12 +177,12 @@ function eventuallyExit(code: number): void {
export async function run(args: ServerParsedArgs, REMOTE_DATA_FOLDER: string, optionDescriptions: OptionDescriptions<ServerParsedArgs>): Promise<void> { export async function run(args: ServerParsedArgs, REMOTE_DATA_FOLDER: string, optionDescriptions: OptionDescriptions<ServerParsedArgs>): Promise<void> {
if (args.help) { if (args.help) {
const executable = product.serverApplicationName + (isWindows ? '.cmd' : ''); const executable = product.serverApplicationName + (isWindows ? '.cmd' : '');
console.log(buildHelpMessage(product.nameLong, executable, product.version, optionDescriptions, { noInputFiles: true, noPipe: true })); console.log(buildHelpMessage(product.nameLong, executable, product.IDEVersion, optionDescriptions, { noInputFiles: true, noPipe: true }));
return; return;
} }
// Version Info // Version Info
if (args.version) { if (args.version) {
console.log(buildVersionMessage(product.version, product.commit)); console.log(buildVersionMessage(product.IDEVersion, product.commit));
return; return;
} }

View File

@ -79,7 +79,7 @@ export class BrowserDialogHandler extends AbstractDialogHandler {
const detailString = (useAgo: boolean): string => { const detailString = (useAgo: boolean): string => {
return localize('aboutDetail', return localize('aboutDetail',
"Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}", "Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
this.productService.version || 'Unknown', this.productService.IDEVersion || 'Unknown',
this.productService.commit || 'Unknown', this.productService.commit || 'Unknown',
this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(new Date(this.productService.date), true) + ')' : ''}` : 'Unknown', this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(new Date(this.productService.date), true) + ')' : ''}` : 'Unknown',
navigator.userAgent navigator.userAgent

View File

@ -67,7 +67,7 @@ export class NativeDialogHandler extends AbstractDialogHandler {
} }
async about(): Promise<void> { async about(): Promise<void> {
let version = this.productService.version; let version = this.productService.IDEVersion;
if (this.productService.target) { if (this.productService.target) {
version = `${version} (${this.productService.target} setup)`; version = `${version} (${this.productService.target} setup)`;
} else if (this.productService.darwinUniversalAssetId) { } else if (this.productService.darwinUniversalAssetId) {