mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-13 03:29:46 +08:00
488dff0f90
Converted all references of global atom to NylasEnv Temporary rename atom.io find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.io/temporaryAtomIoReplacement/g' atom.config to NylasEnv.config find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.config/NylasEnv.config/g' atom.packages -> NylasEnv.packages atom.commands -> NylasEnv.commands atom.getLoadSettings find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.commands/NylasEnv.commands/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.getLoadSettings/NylasEnv.getLoadSettings/g' More common atom methods find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.styles/NylasEnv.styles/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.emitError/NylasEnv.emitError/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.inSpecMode/NylasEnv.inSpecMode/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.inDevMode/NylasEnv.inDevMode/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.getWindowType/NylasEnv.getWindowType/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.displayWindow/NylasEnv.displayWindow/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.quit/NylasEnv.quit/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.close/NylasEnv.close/g' More atom method changes find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.keymaps/NylasEnv.keymaps/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.hide/NylasEnv.hide/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.getCurrentWindow/NylasEnv.getCurrentWindow/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.menu/NylasEnv.menu/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.getConfigDirPath/NylasEnv.getConfigDirPath/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.isMainWindow/NylasEnv.isMainWindow/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.finishUnload/NylasEnv.finishUnload/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.isWorkWindow/NylasEnv.isWorkWindow/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.showSaveDialog/NylasEnv.showSaveDialog/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.append/NylasEnv.append/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.confirm/NylasEnv.confirm/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.clipboard/NylasEnv.clipboard/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.getVersion/NylasEnv.getVersion/g' More atom renaming Rename atom methods More atom methods Fix grunt config variable Change atom.cmd to N1.cmd Rename atom.coffee and atom.js to nylas-env.coffee nylas-env.js Fix atom global reference in specs manually Fix atom requires Change engine from atom to nylas got rid of global/nylas-env rename to nylas-win-bootup Fix onWindowPropsChanged to onWindowPropsReceived fix nylas-workspace atom-text-editor to nylas-theme-wrap atom-text-editor -> nylas-theme-wrap Replacing atom keyword AtomWindow -> NylasWindow Replace Atom -> N1 Rename atom items nylas.asar -> atom.asar Remove more atom references Remove 6to5 references Remove license exception for atom
195 lines
8.7 KiB
CoffeeScript
195 lines
8.7 KiB
CoffeeScript
fs = require 'fs'
|
|
path = require 'path'
|
|
_ = require 'underscore'
|
|
|
|
module.exports = (grunt) ->
|
|
{cp, isNylasPackage, mkdir, rm} = require('./task-helpers')(grunt)
|
|
|
|
escapeRegExp = (string) ->
|
|
if string
|
|
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
|
|
else
|
|
return ''
|
|
|
|
grunt.registerTask 'build', 'Build the application', ->
|
|
shellAppDir = grunt.config.get('nylasGruntConfig.shellAppDir')
|
|
buildDir = grunt.config.get('nylasGruntConfig.buildDir')
|
|
appDir = grunt.config.get('nylasGruntConfig.appDir')
|
|
|
|
rm shellAppDir
|
|
rm path.join(buildDir, 'installer')
|
|
mkdir path.dirname(buildDir)
|
|
|
|
if process.platform is 'darwin'
|
|
cp 'electron/Electron.app', shellAppDir, filter: /default_app/
|
|
cp(path.join(shellAppDir, 'Contents', 'MacOS', 'Electron'),
|
|
path.join(shellAppDir, 'Contents', 'MacOS', 'Nylas'))
|
|
rm path.join(shellAppDir, 'Contents', 'MacOS', 'Electron')
|
|
else if process.platform is 'win32'
|
|
cp 'electron', shellAppDir, filter: /default_app/
|
|
cp path.join(shellAppDir, 'electron.exe'), path.join(shellAppDir, 'nylas.exe')
|
|
rm path.join(shellAppDir, 'electron.exe')
|
|
else
|
|
cp 'electron', shellAppDir, filter: /default_app/
|
|
cp path.join(shellAppDir, 'electron'), path.join(shellAppDir, 'nylas')
|
|
rm path.join(shellAppDir, 'electron')
|
|
|
|
mkdir appDir
|
|
|
|
if process.platform isnt 'win32'
|
|
cp 'N1.sh', path.resolve(appDir, '..', 'new-app', 'N1.sh')
|
|
|
|
cp 'package.json', path.join(appDir, 'package.json')
|
|
cp path.join('build', 'resources', 'nylas.png'), path.join(appDir, 'nylas.png')
|
|
|
|
packageNames = []
|
|
packageDirectories = []
|
|
nonPackageDirectories = [
|
|
'dot-nylas'
|
|
]
|
|
|
|
{devDependencies} = grunt.file.readJSON('package.json')
|
|
for packageFolder in ['node_modules', 'internal_packages']
|
|
for child in fs.readdirSync(packageFolder)
|
|
directory = path.join(packageFolder, child)
|
|
if isNylasPackage(directory)
|
|
packageDirectories.push(directory)
|
|
packageNames.push(child)
|
|
else
|
|
nonPackageDirectories.push(directory)
|
|
|
|
# Put any paths here that shouldn't end up in the built Electron.app
|
|
# so that it doesn't becomes larger than it needs to be.
|
|
ignoredPaths = [
|
|
path.join('less', 'dist')
|
|
path.join('npm', 'doc')
|
|
path.join('npm', 'html')
|
|
path.join('npm', 'man')
|
|
path.join('npm', 'node_modules', '.bin', 'beep')
|
|
path.join('npm', 'node_modules', '.bin', 'clear')
|
|
path.join('npm', 'node_modules', '.bin', 'starwars')
|
|
path.join('pegjs', 'examples')
|
|
path.join('jasmine-reporters', 'ext')
|
|
path.join('jasmine-node', 'node_modules', 'gaze')
|
|
path.join('jasmine-node', 'spec')
|
|
path.join('node_modules', 'nan')
|
|
path.join('build', 'binding.Makefile')
|
|
path.join('build', 'config.gypi')
|
|
path.join('build', 'gyp-mac-tool')
|
|
path.join('build', 'Makefile')
|
|
path.join('build', 'Release', 'obj.target')
|
|
path.join('build', 'Release', 'obj')
|
|
path.join('build', 'Release', '.deps')
|
|
path.join('build', 'resources')
|
|
path.join('build', 'resources', 'linux')
|
|
path.join('build', 'resources', 'mac')
|
|
path.join('build', 'resources', 'win')
|
|
path.join('vendor', 'apm')
|
|
|
|
# These are only require in dev mode when the grammar isn't precompiled
|
|
path.join('snippets', 'node_modules', 'loophole')
|
|
path.join('snippets', 'node_modules', 'pegjs')
|
|
path.join('snippets', 'node_modules', '.bin', 'pegjs')
|
|
|
|
# These aren't needed since WeakMap is built-in
|
|
path.join('emissary', 'node_modules', 'es6-weak-map')
|
|
path.join('property-accessors', 'node_modules', 'es6-weak-map')
|
|
|
|
'.DS_Store'
|
|
'.jshintrc'
|
|
'.npmignore'
|
|
'.pairs'
|
|
'.travis.yml'
|
|
'appveyor.yml'
|
|
'.idea'
|
|
'.editorconfig'
|
|
'.lint'
|
|
'.lintignore'
|
|
'.eslintrc'
|
|
'.jshintignore'
|
|
'.gitattributes'
|
|
'.gitkeep'
|
|
]
|
|
|
|
ignoredPaths = ignoredPaths.map (ignoredPath) -> escapeRegExp(ignoredPath)
|
|
|
|
# Add .* to avoid matching hunspell_dictionaries.
|
|
ignoredPaths.push "#{escapeRegExp(path.join('spellchecker', 'vendor', 'hunspell') + path.sep)}.*"
|
|
ignoredPaths.push "#{escapeRegExp(path.join('build', 'Release') + path.sep)}.*\\.pdb"
|
|
|
|
# Ignore *.cc and *.h files from native modules
|
|
ignoredPaths.push "#{escapeRegExp(path.join('ctags', 'src') + path.sep)}.*\\.(cc|h)*"
|
|
ignoredPaths.push "#{escapeRegExp(path.join('keytar', 'src') + path.sep)}.*\\.(cc|h)*"
|
|
ignoredPaths.push "#{escapeRegExp(path.join('nslog', 'src') + path.sep)}.*\\.(cc|h)*"
|
|
ignoredPaths.push "#{escapeRegExp(path.join('pathwatcher', 'src') + path.sep)}.*\\.(cc|h)*"
|
|
ignoredPaths.push "#{escapeRegExp(path.join('runas', 'src') + path.sep)}.*\\.(cc|h)*"
|
|
ignoredPaths.push "#{escapeRegExp(path.join('scrollbar-style', 'src') + path.sep)}.*\\.(cc|h)*"
|
|
ignoredPaths.push "#{escapeRegExp(path.join('spellchecker', 'src') + path.sep)}.*\\.(cc|h)*"
|
|
|
|
# Ignore build files
|
|
ignoredPaths.push "#{escapeRegExp(path.sep)}binding\\.gyp$"
|
|
ignoredPaths.push "#{escapeRegExp(path.sep)}.+\\.target.mk$"
|
|
ignoredPaths.push "#{escapeRegExp(path.sep)}linker\\.lock$"
|
|
ignoredPaths.push "#{escapeRegExp(path.join('build', 'Release') + path.sep)}.+\\.node\\.dSYM"
|
|
|
|
# Hunspell dictionaries are only not needed on OS X.
|
|
if process.platform is 'darwin'
|
|
ignoredPaths.push path.join('spellchecker', 'vendor', 'hunspell_dictionaries')
|
|
ignoredPaths = ignoredPaths.map (ignoredPath) -> "(#{ignoredPath})"
|
|
|
|
testFolderPattern = new RegExp("#{escapeRegExp(path.sep)}te?sts?#{escapeRegExp(path.sep)}")
|
|
exampleFolderPattern = new RegExp("#{escapeRegExp(path.sep)}examples?#{escapeRegExp(path.sep)}")
|
|
|
|
nodeModulesFilter = new RegExp(ignoredPaths.join('|'))
|
|
filterNodeModule = (pathToCopy) ->
|
|
pathToCopy = path.resolve(pathToCopy)
|
|
nodeModulesFilter.test(pathToCopy) or testFolderPattern.test(pathToCopy) or exampleFolderPattern.test(pathToCopy)
|
|
|
|
packageFilter = new RegExp("(#{ignoredPaths.join('|')})|(.+\\.(cson|coffee|cjsx|jsx)$)")
|
|
filterPackage = (pathToCopy) ->
|
|
pathToCopy = path.resolve(pathToCopy)
|
|
packageFilter.test(pathToCopy) or testFolderPattern.test(pathToCopy) or exampleFolderPattern.test(pathToCopy)
|
|
|
|
for directory in nonPackageDirectories
|
|
cp directory, path.join(appDir, directory), filter: filterNodeModule
|
|
|
|
for directory in packageDirectories
|
|
cp directory, path.join(appDir, directory), filter: filterPackage
|
|
|
|
cp 'spec', path.join(appDir, 'spec')
|
|
cp 'examples', path.join(appDir, 'examples')
|
|
cp 'src', path.join(appDir, 'src'), filter: /.+\.(cson|coffee|cjsx|jsx)$/
|
|
cp 'static', path.join(appDir, 'static')
|
|
|
|
# Move all of the node modules inside /apm/node_modules to new-app/apm/node_modules
|
|
apmInstallDir = path.resolve(appDir, '..', 'new-app', 'apm')
|
|
mkdir apmInstallDir
|
|
cp path.join('apm', 'node_modules'), path.resolve(apmInstallDir, 'node_modules'), filter: filterNodeModule
|
|
|
|
# Move /apm/node_modules/atom-package-manager to new-app/apm. We're essentially
|
|
# pulling the atom-package-manager module up outside of the node_modules folder,
|
|
# which is necessary because npmV3 installs nested dependencies in the same dir.
|
|
apmPackageDir = path.join(apmInstallDir, 'node_modules', 'atom-package-manager')
|
|
for name in fs.readdirSync(apmPackageDir)
|
|
fs.renameSync path.join(apmPackageDir, name), path.join(apmInstallDir, name)
|
|
fs.unlinkSync(path.join(apmInstallDir, 'node_modules', '.bin', 'apm'))
|
|
fs.rmdirSync(apmPackageDir)
|
|
|
|
if process.platform is 'darwin'
|
|
grunt.file.recurse path.join('build', 'resources', 'mac'), (sourcePath, rootDirectory, subDirectory='', filename) ->
|
|
unless /.+\.plist/.test(sourcePath)
|
|
grunt.file.copy(sourcePath, path.resolve(appDir, '..', subDirectory, filename))
|
|
|
|
if process.platform is 'win32'
|
|
cp path.join('build', 'resources', 'win', 'N1.cmd'), path.join(shellAppDir, 'resources', 'cli', 'N1.cmd')
|
|
cp path.join('build', 'resources', 'win', 'N1.sh'), path.join(shellAppDir, 'resources', 'cli', 'N1.sh')
|
|
cp path.join('build', 'resources', 'win', 'nylas-win-bootup.js'), path.join(shellAppDir, 'resources', 'cli', 'nylas-win-bootup.js')
|
|
cp path.join('build', 'resources', 'win', 'apm.sh'), path.join(shellAppDir, 'resources', 'cli', 'apm.sh')
|
|
|
|
if process.platform is 'linux'
|
|
cp path.join('build', 'resources', 'linux', 'icons'), path.join(buildDir, 'icons')
|
|
|
|
dependencies = ['compile', 'generate-license:save', 'generate-module-cache', 'compile-packages-slug']
|
|
dependencies.push('copy-info-plist') if process.platform is 'darwin'
|
|
dependencies.push('set-exe-icon') if process.platform is 'win32'
|
|
grunt.task.run(dependencies...)
|