Merge branch 'master' into mb-ns-dock-ui-refinements

This commit is contained in:
Max Brunsfeld
2017-04-07 13:23:19 -07:00
15 changed files with 125 additions and 40 deletions

View File

@@ -29,7 +29,7 @@ To also install the newly built application, use `--create-debian-package` or `-
* `--compress-artifacts`: zips the generated application as `out/atom-{arch}.tar.gz`.
* `--create-debian-package`: creates a .deb package as `out/atom-{arch}.deb`
* `--create-rpm-package`: creates a .rpm package as `out/atom-{arch}.rpm`
* `--install`: installs the application in `/usr/local/`.
* `--install[=dir]`: installs the application in `${dir}`; `${dir}` defaults to `/usr/local`.
### Ubuntu / Debian

View File

@@ -21,7 +21,7 @@ To also install the newly built application, use `script/build --install`.
* `--code-sign`: signs the application with the GitHub certificate specified in `$ATOM_MAC_CODE_SIGNING_CERT_DOWNLOAD_URL`.
* `--compress-artifacts`: zips the generated application as `out/atom-mac.zip`.
* `--install`: installs the application at `/Applications/Atom.app` for dev and stable versions or at `/Applications/Atom-Beta.app` for beta versions.
* `--install[=dir]`: installs the application at `${dir}/Atom.app` for dev and stable versions or at `${dir}/Atom-Beta.app` for beta versions; `${dir}` defaults to `/Applications`.
## Troubleshooting

View File

@@ -35,7 +35,7 @@ To also install the newly built application, use `script\build --create-windows-
* `--code-sign`: signs the application with the GitHub certificate specified in `$WIN_P12KEY_URL`.
* `--compress-artifacts`: zips the generated application as `out\atom-windows.zip` (requires [7-Zip](http://www.7-zip.org)).
* `--create-windows-installer`: creates an `.msi`, an `.exe` and two `.nupkg` packages in the `out` directory.
* `--install`: installs the application in `%LOCALAPPDATA%\Atom\app-dev\`.
* `--install[=dir]`: installs the application in `${dir}\Atom\app-dev`; `${dir}` defaults to `%LOCALAPPDATA%`.
### Running tests

View File

@@ -65,7 +65,6 @@
"sinon": "1.17.4",
"source-map-support": "^0.3.2",
"temp": "^0.8.3",
"test-until": "^1.1.1",
"text-buffer": "11.4.0",
"typescript-simple": "1.0.0",
"underscore-plus": "^1.6.6",
@@ -79,8 +78,8 @@
"atom-light-ui": "0.46.0",
"base16-tomorrow-dark-theme": "1.5.0",
"base16-tomorrow-light-theme": "1.5.0",
"one-dark-ui": "1.10.0",
"one-light-ui": "1.10.0",
"one-dark-ui": "1.10.1",
"one-light-ui": "1.10.1",
"one-dark-syntax": "1.7.1",
"one-light-syntax": "1.7.1",
"solarized-dark-syntax": "1.1.2",
@@ -90,7 +89,7 @@
"autocomplete-atom-api": "0.10.1",
"autocomplete-css": "0.16.1",
"autocomplete-html": "0.7.3",
"autocomplete-plus": "2.35.1",
"autocomplete-plus": "2.35.2",
"autocomplete-snippets": "1.11.0",
"autoflow": "0.29.0",
"autosave": "0.24.2",
@@ -103,7 +102,7 @@
"dev-live-reload": "0.47.1",
"encoding-selector": "0.23.3",
"exception-reporting": "0.41.3",
"find-and-replace": "0.207.4",
"find-and-replace": "0.207.5",
"fuzzy-finder": "1.5.4",
"git-diff": "1.3.5",
"go-to-line": "0.32.0",
@@ -126,7 +125,7 @@
"symbols-view": "0.115.5",
"tabs": "0.105.4",
"timecop": "0.36.0",
"tree-view": "0.216.0",
"tree-view": "0.217.0-2",
"update-package-dependencies": "0.11.0",
"welcome": "0.36.2",
"whitespace": "0.36.2",

View File

@@ -20,6 +20,7 @@ const argv = yargs
.describe('create-rpm-package', 'Create .rpm package (Linux only)')
.describe('compress-artifacts', 'Compress Atom binaries (and symbols on macOS)')
.describe('install', 'Install Atom')
.string('install')
.wrap(yargs.terminalWidth())
.argv
@@ -43,6 +44,7 @@ const transpileBabelPaths = require('./lib/transpile-babel-paths')
const transpileCoffeeScriptPaths = require('./lib/transpile-coffee-script-paths')
const transpileCsonPaths = require('./lib/transpile-cson-paths')
const transpilePegJsPaths = require('./lib/transpile-peg-js-paths')
const transpilePackagesWithCustomTranspilerPaths = require('./lib/transpile-packages-with-custom-transpiler-paths.js')
process.on('unhandledRejection', function (e) {
console.error(e.stack || e)
@@ -52,6 +54,7 @@ process.on('unhandledRejection', function (e) {
checkChromedriverVersion()
cleanOutputDirectory()
copyAssets()
transpilePackagesWithCustomTranspilerPaths()
transpileBabelPaths()
transpileCoffeeScriptPaths()
transpileCsonPaths()
@@ -99,8 +102,8 @@ dumpSymbols()
console.log('Skipping artifacts compression. Specify the --compress-artifacts option to compress Atom binaries (and symbols on macOS)'.gray)
}
if (argv.install) {
installApplication(packagedAppPath)
if (argv.install != null) {
installApplication(packagedAppPath, argv.install)
} else {
console.log('Skipping installation. Specify the --install option to install Atom'.gray)
}

View File

@@ -0,0 +1,24 @@
'use strict'
const os = require('os')
const passwdUser = require('passwd-user')
const path = require('path')
module.exports = function (aPath) {
if (!aPath.startsWith('~')) {
return aPath
}
const sepIndex = aPath.indexOf(path.sep)
const user = (sepIndex < 0) ? aPath.substring(1) : aPath.substring(1, sepIndex)
const rest = (sepIndex < 0) ? '' : aPath.substring(sepIndex)
const home = (user === '') ? os.homedir() : (() => {
const passwd = passwdUser.sync(user);
if (passwd === undefined) {
throw new Error(`Failed to expand the tilde in ${aPath} - user "${user}" does not exist`)
}
return passwd.homedir
})()
return `${home}${rest}`
}

View File

@@ -1,16 +1,18 @@
'use strict'
const fs = require('fs-extra')
const handleTilde = require('./handle-tilde')
const path = require('path')
const runas = require('runas')
const template = require('lodash.template')
const CONFIG = require('../config')
module.exports = function (packagedAppPath) {
module.exports = function (packagedAppPath, installDir) {
const packagedAppFileName = path.basename(packagedAppPath)
if (process.platform === 'darwin') {
const installationDirPath = path.join(path.sep, 'Applications', packagedAppFileName)
const installPrefix = installDir !== '' ? handleTilde(installDir) : path.join(path.sep, 'Applications')
const installationDirPath = path.join(installPrefix, packagedAppFileName)
if (fs.existsSync(installationDirPath)) {
console.log(`Removing previously installed "${packagedAppFileName}" at "${installationDirPath}"`)
fs.removeSync(installationDirPath)
@@ -18,7 +20,8 @@ module.exports = function (packagedAppPath) {
console.log(`Installing "${packagedAppPath}" at "${installationDirPath}"`)
fs.copySync(packagedAppPath, installationDirPath)
} else if (process.platform === 'win32') {
const installationDirPath = path.join(process.env.LOCALAPPDATA, packagedAppFileName, 'app-dev')
const installPrefix = installDir !== '' ? installDir : process.env.LOCALAPPDATA
const installationDirPath = path.join(installPrefix, packagedAppFileName, 'app-dev')
try {
if (fs.existsSync(installationDirPath)) {
console.log(`Removing previously installed "${packagedAppFileName}" at "${installationDirPath}"`)
@@ -39,12 +42,12 @@ module.exports = function (packagedAppPath) {
const apmExecutableName = CONFIG.channel === 'beta' ? 'apm-beta' : 'apm'
const appName = CONFIG.channel === 'beta' ? 'Atom Beta' : 'Atom'
const appDescription = CONFIG.appMetadata.description
const userLocalDirPath = path.join('/usr', 'local')
const shareDirPath = path.join(userLocalDirPath, 'share')
const prefixDirPath = installDir !== '' ? handleTilde(installDir) : path.join('/usr', 'local')
const shareDirPath = path.join(prefixDirPath, 'share')
const installationDirPath = path.join(shareDirPath, atomExecutableName)
const applicationsDirPath = path.join(shareDirPath, 'applications')
const desktopEntryPath = path.join(applicationsDirPath, `${atomExecutableName}.desktop`)
const binDirPath = path.join(userLocalDirPath, 'bin')
const binDirPath = path.join(prefixDirPath, 'bin')
const atomBinDestinationPath = path.join(binDirPath, atomExecutableName)
const apmBinDestinationPath = path.join(binDirPath, apmExecutableName)
@@ -67,7 +70,7 @@ module.exports = function (packagedAppPath) {
const desktopEntryTemplate = fs.readFileSync(path.join(CONFIG.repositoryRootPath, 'resources', 'linux', 'atom.desktop.in'))
const desktopEntryContents = template(desktopEntryTemplate)({
appName, appFileName: atomExecutableName, description: appDescription,
installDir: '/usr', iconPath
installDir: prefixDirPath, iconPath
})
fs.writeFileSync(desktopEntryPath, desktopEntryContents)

View File

@@ -0,0 +1,32 @@
'use strict'
const CompileCache = require('../../src/compile-cache')
const fs = require('fs')
const glob = require('glob')
const path = require('path')
const CONFIG = require('../config')
module.exports = function () {
console.log(`Transpiling packages with custom transpiler configurations in ${CONFIG.intermediateAppPath}`)
let pathsToCompile = []
for (let packageName of Object.keys(CONFIG.appMetadata.packageDependencies)) {
const packagePath = path.join(CONFIG.intermediateAppPath, 'node_modules', packageName)
const metadataPath = path.join(packagePath, 'package.json')
const metadata = require(metadataPath)
if (metadata.atomTranspilers) {
CompileCache.addTranspilerConfigForPath(packagePath, metadata.name, metadata, metadata.atomTranspilers)
for (let config of metadata.atomTranspilers) {
pathsToCompile = pathsToCompile.concat(glob.sync(path.join(packagePath, config.glob)))
}
}
}
for (let path of pathsToCompile) {
transpilePath(path)
}
}
function transpilePath (path) {
fs.writeFileSync(path, CompileCache.addPathToCache(path, CONFIG.atomHomeDirPath))
}

View File

@@ -23,6 +23,7 @@
"mkdirp": "0.5.1",
"normalize-package-data": "2.3.5",
"npm": "3.10.5",
"passwd-user": "2.1.0",
"pegjs": "0.9.0",
"runas": "3.1.1",
"season": "5.3.0",

View File

@@ -1,7 +1,5 @@
/** @babel */
import until from 'test-until'
export function beforeEach (fn) {
global.beforeEach(function () {
const result = fn()
@@ -63,8 +61,14 @@ function waitsForPromise (fn) {
})
}
export function emitterEventPromise (emitter, event, timeout = 5000) {
let emitted = false
emitter.once(event, () => { emitted = true })
return until(`${event} is emitted`, () => emitted, timeout)
export function emitterEventPromise (emitter, event, timeout = 15000) {
return new Promise((resolve, reject) => {
const timeoutHandle = setTimeout(() => {
reject(new Error(`Timed out waiting for '${event}' event`))
}, timeout)
emitter.once(event, () => {
clearTimeout(timeoutHandle)
resolve()
})
})
}

View File

@@ -358,20 +358,23 @@ describe('AtomApplication', function () {
const atomApplication1 = buildAtomApplication()
const app1Window1 = atomApplication1.launch(parseCommandLine([tempDirPath1]))
await app1Window1.loadedPromise
const app1Window2 = atomApplication1.launch(parseCommandLine([tempDirPath2]))
await app1Window2.loadedPromise
await Promise.all([
emitterEventPromise(app1Window1, 'window:locations-opened'),
emitterEventPromise(app1Window2, 'window:locations-opened')
])
await app1Window1.saveState()
await app1Window2.saveState()
await Promise.all([
app1Window1.saveState(),
app1Window2.saveState()
])
const atomApplication2 = buildAtomApplication()
const [app2Window1, app2Window2] = atomApplication2.launch(parseCommandLine([]))
const p1 = emitterEventPromise(app2Window1, 'window:locations-opened', 15000)
const p2 = emitterEventPromise(app2Window2, 'window:locations-opened', 15000)
await Promise.all([p1, p2])
await app2Window1.loadedPromise
await app2Window2.loadedPromise
await Promise.all([
emitterEventPromise(app2Window1, 'window:locations-opened'),
emitterEventPromise(app2Window2, 'window:locations-opened')
])
assert.deepEqual(await getTreeViewRootDirectories(app2Window1), [tempDirPath1])
assert.deepEqual(await getTreeViewRootDirectories(app2Window2), [tempDirPath2])
@@ -425,19 +428,22 @@ describe('AtomApplication', function () {
const atomApplication = buildAtomApplication()
const window = atomApplication.launch(parseCommandLine([dirA, dirB]))
await emitterEventPromise(window, 'window:locations-opened', 15000)
await emitterEventPromise(window, 'window:locations-opened')
await focusWindow(window)
assert.deepEqual(await getTreeViewRootDirectories(window), [dirA, dirB])
const saveStatePromise = emitterEventPromise(atomApplication, 'application:did-save-state')
await evalInWebContents(window.browserWindow.webContents, (sendBackToMainProcess) => {
atom.project.removePath(atom.project.getPaths()[0])
sendBackToMainProcess(null)
})
assert.deepEqual(await getTreeViewRootDirectories(window), [dirB])
await saveStatePromise
// Window state should be saved when the project folder is removed
const atomApplication2 = buildAtomApplication()
const [window2] = atomApplication2.launch(parseCommandLine([]))
await emitterEventPromise(window2, 'window:locations-opened')
await focusWindow(window2)
assert.deepEqual(await getTreeViewRootDirectories(window2), [dirB])
})

View File

@@ -143,5 +143,19 @@ describe("PackageTranspilationRegistry", () => {
expect(wrappedCompiler.compile('source', hitPathMissSubdir)).toEqual('source-original-compiler')
expect(wrappedCompiler.compile('source', nodeModulesFolder)).toEqual('source-original-compiler')
})
describe('when the packages root path contains node_modules', () =>{
beforeEach(() => {
registry.addTranspilerConfigForPath(path.join('/path/with/node_modules/in/root'), 'my-other-package', { some: 'metadata' }, [
jsSpec
])
})
it('returns appropriate values from shouldCompile', () => {
spyOn(originalCompiler, 'shouldCompile').andReturn(false)
expect(wrappedCompiler.shouldCompile('source', '/path/with/node_modules/in/root/lib/test.js')).toBe(true)
expect(wrappedCompiler.shouldCompile('source', '/path/with/node_modules/in/root/lib/node_modules/test.js')).toBe(false)
})
})
})
})

View File

@@ -613,6 +613,7 @@ class AtomApplication
states.push({initialPaths: window.representedDirectoryPaths})
if states.length > 0 or allowEmpty
@storageFolder.storeSync('application.json', states)
@emit('application:did-save-state')
loadState: (options) ->
restorePreviousState = @config.get('core.restorePreviousWindowsOnStart') ? true

View File

@@ -71,11 +71,6 @@ class PackageTranspilationRegistry {
getPackageTranspilerSpecForFilePath (filePath) {
if (this.specByFilePath[filePath] !== undefined) return this.specByFilePath[filePath]
// ignore node_modules
if (filePath.indexOf(path.sep + 'node_modules' + path.sep) > -1) {
return false
}
let thisPath = filePath
let lastPath = null
// Iterate parents from the file path to the root, checking at each level
@@ -85,6 +80,10 @@ class PackageTranspilationRegistry {
while (thisPath !== lastPath) { // until we reach the root
let config = this.configByPackagePath[thisPath]
if (config) {
const relativePath = path.relative(thisPath, filePath)
if (relativePath.startsWith(`node_modules${path.sep}`) || relativePath.indexOf(`${path.sep}node_modules${path.sep}`) > -1) {
return false
}
for (let i = 0; i < config.specs.length; i++) {
const spec = config.specs[i]
if (minimatch(filePath, path.join(config.path, spec.glob))) {

View File

@@ -86,7 +86,6 @@ class Package
@loadMenus()
@registerDeserializerMethods()
@activateCoreStartupServices()
@registerTranspilerConfig()
@configSchemaRegisteredOnLoad = @registerConfigSchemaFromMetadata()
@requireMainModule()
@settingsPromise = @loadSettings()