diff --git a/package-lock.json b/package-lock.json index 8cf8d0454..1d2cc1659 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,15 @@ "source-map": "0.1.32" } }, + "@atom/temp": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@atom/temp/-/temp-0.8.4.tgz", + "integrity": "sha1-RVFIywz2ygNI5xpc+ZiGq8rERek=", + "requires": { + "os-tmpdir": "^1.0.0", + "rimraf": "~2.6.2" + } + }, "@atom/watcher": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/@atom/watcher/-/watcher-1.0.8.tgz", @@ -6025,13 +6034,13 @@ } }, "tree-view": { - "version": "https://www.atom.io/api/packages/tree-view/versions/0.222.0/tarball", - "integrity": "sha512-H3l7Q6+mUMKdUUxmxDl+23hGC77R6dbJG93jy8cNPMfMvHqdKgtW5THVYSPpsqABvN0HrrufR0dWBS9kUWYZMw==", + "version": "https://www.atom.io/api/packages/tree-view/versions/0.224.2/tarball", + "integrity": "sha512-zQgrwWo2aBInkSCsldNP9sZJA4OnzznQgKJzQNhClMZJMWEr1Pl1tWnq3x67ie6dINkJ/JWqzbjxz2v2T5U2ig==", "requires": { + "@atom/temp": "~0.8.4", "fs-plus": "3.0.2", "minimatch": "0.3.0", "pathwatcher": "8.0.1", - "temp": "0.8.3", "underscore-plus": "1.6.8" }, "dependencies": { diff --git a/package.json b/package.json index 022aff911..e038ba272 100644 --- a/package.json +++ b/package.json @@ -160,7 +160,7 @@ "text-buffer": "13.14.6", "timecop": "https://www.atom.io/api/packages/timecop/versions/0.36.2/tarball", "tree-sitter": "0.13.6", - "tree-view": "https://www.atom.io/api/packages/tree-view/versions/0.222.0/tarball", + "tree-view": "https://www.atom.io/api/packages/tree-view/versions/0.224.2/tarball", "typescript-simple": "1.0.0", "underscore-plus": "^1.6.8", "update-package-dependencies": "https://www.atom.io/api/packages/update-package-dependencies/versions/0.13.1/tarball", @@ -225,7 +225,7 @@ "symbols-view": "0.118.2", "tabs": "0.109.2", "timecop": "0.36.2", - "tree-view": "0.222.0", + "tree-view": "0.224.2", "update-package-dependencies": "0.13.1", "welcome": "0.36.7", "whitespace": "0.37.6", diff --git a/script/bootstrap b/script/bootstrap index 6e92b1f59..1abfc48d0 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -2,8 +2,9 @@ 'use strict' -const childProcess = require('child_process') +const path = require('path') const CONFIG = require('./config') +const childProcess = require('child_process') const cleanDependencies = require('./lib/clean-dependencies') const deleteMsbuildFromPath = require('./lib/delete-msbuild-from-path') const dependenciesFingerprint = require('./lib/dependencies-fingerprint') @@ -42,4 +43,28 @@ childProcess.execFileSync( ) runApmInstall(CONFIG.repositoryRootPath, ci) +if (!process.env.CI) { + require('colors') + const glob = require('glob') + const {spawn} = require('child_process') + + // Install the local core packages in-place so they can be used in dev mode + const files = glob.sync(path.join(CONFIG.repositoryRootPath, 'packages/*/package.json')) + if (files.length > 0) { + console.log('Installing core packages for use in dev mode...') + + files.forEach(file => { + const packageDir = path.dirname(file) + process.stdout.write(`Installing packages/${path.basename(packageDir)} `) + runApmInstall(path.dirname(file), false, ['inherit', 'pipe', 'inherit']) + + if (process.platform === 'win32') { + return process.stdout.write('done\n'.green) + } else { + return process.stdout.write('\u2713\n'.green) + } + }) + } +} + dependenciesFingerprint.write() diff --git a/script/lib/run-apm-install.js b/script/lib/run-apm-install.js index 2993a3319..982ed7165 100644 --- a/script/lib/run-apm-install.js +++ b/script/lib/run-apm-install.js @@ -4,7 +4,7 @@ const childProcess = require('child_process') const CONFIG = require('../config') -module.exports = function (packagePath, ci) { +module.exports = function (packagePath, ci, stdioOptions) { const installEnv = Object.assign({}, process.env) // Set resource path so that apm can load metadata related to Atom. installEnv.ATOM_RESOURCE_PATH = CONFIG.repositoryRootPath @@ -14,6 +14,6 @@ module.exports = function (packagePath, ci) { childProcess.execFileSync( CONFIG.getApmBinPath(), ['--loglevel=error', ci ? 'ci' : 'install'], - {env: installEnv, cwd: packagePath, stdio: 'inherit'} + {env: installEnv, cwd: packagePath, stdio: stdioOptions || 'inherit'} ) } diff --git a/spec/package-manager-spec.js b/spec/package-manager-spec.js index 73f948536..dd87f85fa 100644 --- a/spec/package-manager-spec.js +++ b/spec/package-manager-spec.js @@ -30,13 +30,15 @@ describe('PackageManager', () => { expect(packageManger.packageDirPaths[0]).toBe(path.join(configDirPath, 'packages')) }) - it('adds regular package path and dev package path in dev mode', () => { + it('adds regular package path, dev package path, and Atom repo package path in dev mode and dev resource path is set', () => { const packageManger = new PackageManager({}) const configDirPath = path.join('~', 'someConfig') - packageManger.initialize({configDirPath, devMode: true}) - expect(packageManger.packageDirPaths.length).toBe(2) + const resourcePath = path.join('~', '/atom') + packageManger.initialize({configDirPath, resourcePath, devMode: true}) + expect(packageManger.packageDirPaths.length).toBe(3) expect(packageManger.packageDirPaths).toContain(path.join(configDirPath, 'packages')) expect(packageManger.packageDirPaths).toContain(path.join(configDirPath, 'dev', 'packages')) + expect(packageManger.packageDirPaths).toContain(path.join(resourcePath, 'packages')) }) }) diff --git a/src/main-process/atom-protocol-handler.js b/src/main-process/atom-protocol-handler.js index 1affba02a..47c3da14f 100644 --- a/src/main-process/atom-protocol-handler.js +++ b/src/main-process/atom-protocol-handler.js @@ -20,6 +20,7 @@ class AtomProtocolHandler { if (!safeMode) { this.loadPaths.push(path.join(process.env.ATOM_HOME, 'dev', 'packages')) + this.loadPaths.push(path.join(resourcePath, 'packages')) } this.loadPaths.push(path.join(process.env.ATOM_HOME, 'packages')) diff --git a/src/main-process/auto-update-manager.coffee b/src/main-process/auto-update-manager.coffee index bc81d425d..74bf2f886 100644 --- a/src/main-process/auto-update-manager.coffee +++ b/src/main-process/auto-update-manager.coffee @@ -94,7 +94,7 @@ class AutoUpdateManager scheduleUpdateCheck: -> # Only schedule update check periodically if running in release version and # and there is no existing scheduled update check. - unless /\w{7}/.test(@version) or @checkForUpdatesIntervalID + unless /-dev/.test(@version) or @checkForUpdatesIntervalID checkForUpdates = => @check(hidePopups: true) fourHours = 1000 * 60 * 60 * 4 @checkForUpdatesIntervalID = setInterval(checkForUpdates, fourHours) diff --git a/src/main-process/get-dev-resource-path.js b/src/main-process/get-dev-resource-path.js new file mode 100644 index 000000000..fe89e58fb --- /dev/null +++ b/src/main-process/get-dev-resource-path.js @@ -0,0 +1,31 @@ +'use strict' + +const path = require('path') +const fs = require('fs-plus') +const CSON = require('season') +const electron = require('electron') + +module.exports = function () { + const appResourcePath = path.dirname(path.dirname(__dirname)) + const defaultRepositoryPath = path.join(electron.app.getPath('home'), 'github', 'atom') + + if (process.env.ATOM_DEV_RESOURCE_PATH) { + return process.env.ATOM_DEV_RESOURCE_PATH + } else if (isAtomRepoPath(process.cwd())) { + return process.cwd() + } else if (fs.statSyncNoException(defaultRepositoryPath)) { + return defaultRepositoryPath + } + + return appResourcePath +} + +function isAtomRepoPath (repoPath) { + let packageJsonPath = path.join(repoPath, 'package.json') + if (fs.statSyncNoException(packageJsonPath)) { + let packageJson = CSON.readFileSync(packageJsonPath) + return packageJson.name === 'atom' + } + + return false +} diff --git a/src/main-process/main.js b/src/main-process/main.js index ee7b96232..77dacd792 100644 --- a/src/main-process/main.js +++ b/src/main-process/main.js @@ -4,10 +4,9 @@ if (typeof snapshotResult !== 'undefined') { const startTime = Date.now() -const electron = require('electron') -const fs = require('fs') const path = require('path') const yargs = require('yargs') +const getDevResourcePath = require('./get-dev-resource-path') const args = yargs(process.argv) @@ -21,16 +20,8 @@ if (args.resourcePath) { resourcePath = args.resourcePath } else { const stableResourcePath = path.dirname(path.dirname(__dirname)) - const defaultRepositoryPath = path.join(electron.app.getPath('home'), 'github', 'atom') - if (args.dev || args.test || args.benchmark || args.benchmarkTest) { - if (process.env.ATOM_DEV_RESOURCE_PATH) { - resourcePath = process.env.ATOM_DEV_RESOURCE_PATH - } else if (fs.statSyncNoException(defaultRepositoryPath)) { - resourcePath = defaultRepositoryPath - } else { - resourcePath = stableResourcePath - } + resourcePath = getDevResourcePath() || stableResourcePath } else { resourcePath = stableResourcePath } diff --git a/src/main-process/parse-command-line.js b/src/main-process/parse-command-line.js index f24422ef4..1d25fe70c 100644 --- a/src/main-process/parse-command-line.js +++ b/src/main-process/parse-command-line.js @@ -5,6 +5,7 @@ const yargs = require('yargs') const {app} = require('electron') const path = require('path') const fs = require('fs-plus') +const getDevResourcePath = require('./get-dev-resource-path') module.exports = function parseCommandLine (processArgs) { const options = yargs(processArgs).wrap(yargs.terminalWidth()) @@ -119,7 +120,7 @@ module.exports = function parseCommandLine (processArgs) { let pathsToOpen = [] let urlsToOpen = [] let devMode = args['dev'] - let devResourcePath = process.env.ATOM_DEV_RESOURCE_PATH || path.join(app.getPath('home'), 'github', 'atom') + let devResourcePath = getDevResourcePath() let resourcePath = null for (const path of args._) { diff --git a/src/package-manager.js b/src/package-manager.js index 17a5f2214..0c7943bca 100644 --- a/src/package-manager.js +++ b/src/package-manager.js @@ -61,6 +61,7 @@ module.exports = class PackageManager { if (params.configDirPath != null && !params.safeMode) { if (this.devMode) { this.packageDirPaths.push(path.join(params.configDirPath, 'dev', 'packages')) + this.packageDirPaths.push(path.join(this.resourcePath, 'packages')) } this.packageDirPaths.push(path.join(params.configDirPath, 'packages')) }