2016-03-23 07:40:44 +03:00
|
|
|
// This module exports paths, names, and other metadata that is referenced
|
|
|
|
// throughout the build.
|
|
|
|
|
2019-05-31 19:33:56 +03:00
|
|
|
'use strict';
|
2016-03-23 07:40:44 +03:00
|
|
|
|
2019-05-31 19:33:56 +03:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
const spawnSync = require('./lib/spawn-sync');
|
2016-03-23 07:40:44 +03:00
|
|
|
|
2019-05-31 19:33:56 +03:00
|
|
|
const repositoryRootPath = path.resolve(__dirname, '..');
|
|
|
|
const apmRootPath = path.join(repositoryRootPath, 'apm');
|
|
|
|
const scriptRootPath = path.join(repositoryRootPath, 'script');
|
|
|
|
const buildOutputPath = path.join(repositoryRootPath, 'out');
|
|
|
|
const docsOutputPath = path.join(repositoryRootPath, 'docs', 'output');
|
|
|
|
const intermediateAppPath = path.join(buildOutputPath, 'app');
|
|
|
|
const symbolsPath = path.join(buildOutputPath, 'symbols');
|
|
|
|
const electronDownloadPath = path.join(repositoryRootPath, 'electron');
|
|
|
|
const homeDirPath = process.env.HOME || process.env.USERPROFILE;
|
|
|
|
const atomHomeDirPath =
|
|
|
|
process.env.ATOM_HOME || path.join(homeDirPath, '.atom');
|
2016-03-23 07:40:44 +03:00
|
|
|
|
2019-06-01 01:29:10 +03:00
|
|
|
const appMetadata = require(path.join(repositoryRootPath, 'package.json'));
|
|
|
|
const apmMetadata = require(path.join(apmRootPath, 'package.json'));
|
|
|
|
const computedAppVersion = computeAppVersion(
|
|
|
|
process.env.ATOM_RELEASE_VERSION || appMetadata.version
|
|
|
|
);
|
|
|
|
const channel = getChannel(computedAppVersion);
|
|
|
|
const appName = getAppName(channel);
|
|
|
|
const executableName = getExecutableName(channel, appName);
|
2019-06-25 18:58:50 +03:00
|
|
|
const channelName = getChannelName(channel);
|
2016-08-02 15:04:45 +03:00
|
|
|
|
2016-03-23 07:40:44 +03:00
|
|
|
module.exports = {
|
2017-01-25 19:13:42 +03:00
|
|
|
appMetadata,
|
|
|
|
apmMetadata,
|
|
|
|
channel,
|
2019-06-25 18:58:50 +03:00
|
|
|
channelName,
|
2018-07-12 20:14:15 +03:00
|
|
|
appName,
|
2018-09-20 22:05:01 +03:00
|
|
|
executableName,
|
2018-06-19 07:00:18 +03:00
|
|
|
computedAppVersion,
|
2017-01-25 19:13:42 +03:00
|
|
|
repositoryRootPath,
|
|
|
|
apmRootPath,
|
|
|
|
scriptRootPath,
|
|
|
|
buildOutputPath,
|
|
|
|
docsOutputPath,
|
|
|
|
intermediateAppPath,
|
|
|
|
symbolsPath,
|
|
|
|
electronDownloadPath,
|
|
|
|
atomHomeDirPath,
|
|
|
|
homeDirPath,
|
|
|
|
getApmBinPath,
|
2017-03-24 07:27:57 +03:00
|
|
|
getNpmBinPath,
|
2017-03-09 16:23:58 +03:00
|
|
|
snapshotAuxiliaryData: {}
|
2019-05-31 19:33:56 +03:00
|
|
|
};
|
2016-07-28 19:52:23 +03:00
|
|
|
|
2019-06-25 18:58:50 +03:00
|
|
|
function getChannelName(channel) {
|
2019-06-26 17:32:07 +03:00
|
|
|
return channel === 'stable' ? 'atom' : `atom-${channel}`;
|
2019-06-25 18:58:50 +03:00
|
|
|
}
|
|
|
|
|
2019-05-31 19:33:56 +03:00
|
|
|
function getChannel(version) {
|
|
|
|
const match = version.match(/\d+\.\d+\.\d+(-([a-z]+)(\d+|-\w{4,})?)?$/);
|
2018-06-24 01:09:13 +03:00
|
|
|
if (!match) {
|
2019-05-31 19:33:56 +03:00
|
|
|
throw new Error(`Found incorrectly formatted Atom version ${version}`);
|
2018-06-24 01:09:13 +03:00
|
|
|
} else if (match[2]) {
|
2019-05-31 19:33:56 +03:00
|
|
|
return match[2];
|
2016-07-28 19:52:23 +03:00
|
|
|
}
|
2018-06-24 01:09:13 +03:00
|
|
|
|
2019-05-31 19:33:56 +03:00
|
|
|
return 'stable';
|
2016-07-28 19:52:23 +03:00
|
|
|
}
|
|
|
|
|
2019-05-31 19:33:56 +03:00
|
|
|
function getAppName(channel) {
|
2018-07-12 20:14:15 +03:00
|
|
|
return channel === 'stable'
|
|
|
|
? 'Atom'
|
2019-05-31 19:33:56 +03:00
|
|
|
: `Atom ${process.env.ATOM_CHANNEL_DISPLAY_NAME ||
|
|
|
|
channel.charAt(0).toUpperCase() + channel.slice(1)}`;
|
2018-06-26 22:35:41 +03:00
|
|
|
}
|
|
|
|
|
2019-06-01 01:29:10 +03:00
|
|
|
function getExecutableName(channel, appName) {
|
2018-09-20 22:05:01 +03:00
|
|
|
if (process.platform === 'darwin') {
|
2019-06-01 01:29:10 +03:00
|
|
|
return appName;
|
2018-09-20 22:05:01 +03:00
|
|
|
} else if (process.platform === 'win32') {
|
2019-06-01 01:29:10 +03:00
|
|
|
return channel === 'stable' ? 'atom.exe' : `atom-${channel}.exe`;
|
2018-09-20 22:05:01 +03:00
|
|
|
} else {
|
2019-06-01 01:29:10 +03:00
|
|
|
return 'atom';
|
2018-09-20 22:05:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-01 01:29:10 +03:00
|
|
|
function computeAppVersion(version) {
|
2018-06-24 01:09:13 +03:00
|
|
|
if (version.match(/-dev$/)) {
|
2019-05-31 19:33:56 +03:00
|
|
|
const result = spawnSync('git', ['rev-parse', '--short', 'HEAD'], {
|
|
|
|
cwd: repositoryRootPath
|
|
|
|
});
|
|
|
|
const commitHash = result.stdout.toString().trim();
|
|
|
|
version += '-' + commitHash;
|
2018-06-19 07:00:18 +03:00
|
|
|
}
|
2019-05-31 19:33:56 +03:00
|
|
|
return version;
|
2018-06-19 07:00:18 +03:00
|
|
|
}
|
|
|
|
|
2019-05-31 19:33:56 +03:00
|
|
|
function getApmBinPath() {
|
|
|
|
const apmBinName = process.platform === 'win32' ? 'apm.cmd' : 'apm';
|
|
|
|
return path.join(
|
|
|
|
apmRootPath,
|
|
|
|
'node_modules',
|
|
|
|
'atom-package-manager',
|
|
|
|
'bin',
|
|
|
|
apmBinName
|
|
|
|
);
|
2016-08-02 15:04:45 +03:00
|
|
|
}
|
|
|
|
|
2019-05-31 19:33:56 +03:00
|
|
|
function getNpmBinPath(external = false) {
|
|
|
|
if (process.env.NPM_BIN_PATH) return process.env.NPM_BIN_PATH;
|
2019-04-18 16:24:19 +03:00
|
|
|
|
2019-05-31 19:33:56 +03:00
|
|
|
const npmBinName = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
|
|
const localNpmBinPath = path.resolve(
|
|
|
|
repositoryRootPath,
|
|
|
|
'script',
|
|
|
|
'node_modules',
|
|
|
|
'.bin',
|
|
|
|
npmBinName
|
|
|
|
);
|
|
|
|
return !external && fs.existsSync(localNpmBinPath)
|
|
|
|
? localNpmBinPath
|
|
|
|
: npmBinName;
|
2016-08-02 15:04:45 +03:00
|
|
|
}
|