Merge pull request #6447 from atom/ks-do-not-bundle-package-specs

Do not bundle package specs
This commit is contained in:
Kevin Sawicki
2015-04-20 16:47:13 -07:00
4 changed files with 61 additions and 16 deletions

View File

@@ -69,6 +69,8 @@ module.exports = (grunt) ->
expand: true
src: [
'src/**/*.coffee'
'spec/*.coffee'
'!spec/*-spec.coffee'
'exports/**/*.coffee'
'static/**/*.coffee'
]
@@ -125,10 +127,19 @@ module.exports = (grunt) ->
{engines, theme} = grunt.file.readJSON(metadataPath)
if engines?.atom?
coffeeConfig.glob_to_multiple.src.push("#{directory}/**/*.coffee")
coffeeConfig.glob_to_multiple.src.push("!#{directory}/spec/**/*.coffee")
lessConfig.glob_to_multiple.src.push("#{directory}/**/*.less")
prebuildLessConfig.src.push("#{directory}/**/*.less") unless theme
lessConfig.glob_to_multiple.src.push("!#{directory}/spec/**/*.less")
unless theme
prebuildLessConfig.src.push("#{directory}/**/*.less")
prebuildLessConfig.src.push("!#{directory}/spec/**/*.less")
csonConfig.glob_to_multiple.src.push("#{directory}/**/*.cson")
pegConfig.glob_to_multiple.src.push("#{directory}/**/*.pegjs")
csonConfig.glob_to_multiple.src.push("!#{directory}/spec/**/*.cson")
pegConfig.glob_to_multiple.src.push("#{directory}/lib/*.pegjs")
grunt.initConfig
pkg: grunt.file.readJSON('package.json')

View File

@@ -26,6 +26,7 @@ module.exports = (grunt) ->
cp 'package.json', path.join(appDir, 'package.json')
packageNames = []
packageDirectories = []
nonPackageDirectories = [
'benchmark'
@@ -39,6 +40,7 @@ module.exports = (grunt) ->
directory = path.join('node_modules', child)
if isAtomPackage(directory)
packageDirectories.push(directory)
packageNames.push(child)
else
nonPackageDirectories.push(directory)
@@ -61,6 +63,8 @@ module.exports = (grunt) ->
path.join('npm', 'node_modules', '.bin', 'clear')
path.join('npm', 'node_modules', '.bin', 'starwars')
path.join('pegjs', 'examples')
path.join('get-parameter-names', 'node_modules', 'testla')
path.join('get-parameter-names', 'node_modules', '.bin', 'testla')
path.join('jasmine-reporters', 'ext')
path.join('jasmine-node', 'node_modules', 'gaze')
path.join('jasmine-node', 'spec')
@@ -79,19 +83,32 @@ module.exports = (grunt) ->
path.join('resources', 'win')
# These are only require in dev mode when the grammar isn't precompiled
path.join('atom-keymap', 'node_modules', 'loophole')
path.join('atom-keymap', 'node_modules', 'pegjs')
path.join('atom-keymap', 'node_modules', '.bin', 'pegjs')
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'
]
packageNames.forEach (packageName) -> ignoredPaths.push(path.join(packageName, 'spec'))
ignoredPaths = ignoredPaths.map (ignoredPath) -> _.escapeRegExp(ignoredPath)
# Add .* to avoid matching hunspell_dictionaries.
@@ -108,6 +125,7 @@ module.exports = (grunt) ->
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)*"
ignoredPaths.push "#{_.escapeRegExp(path.join('keyboard-layout', 'src') + path.sep)}.*\\.(cc|h|mm)*"
# Ignore build files
ignoredPaths.push "#{_.escapeRegExp(path.sep)}binding\\.gyp$"
@@ -120,7 +138,7 @@ module.exports = (grunt) ->
ignoredPaths.push path.join('spellchecker', 'vendor', 'hunspell_dictionaries')
ignoredPaths = ignoredPaths.map (ignoredPath) -> "(#{ignoredPath})"
testFolderPattern = new RegExp("#{_.escapeRegExp(path.sep)}te?sts?#{_.escapeRegExp(path.sep)}")
testFolderPattern = new RegExp("#{_.escapeRegExp(path.sep)}_*te?sts?_*#{_.escapeRegExp(path.sep)}")
exampleFolderPattern = new RegExp("#{_.escapeRegExp(path.sep)}examples?#{_.escapeRegExp(path.sep)}")
benchmarkFolderPattern = new RegExp("#{_.escapeRegExp(path.sep)}benchmarks?#{_.escapeRegExp(path.sep)}")
@@ -144,7 +162,6 @@ module.exports = (grunt) ->
for directory in packageDirectories
cp directory, path.join(appDir, directory), filter: filterPackage
cp 'spec', path.join(appDir, 'spec'), filter: /fixtures|integration|.+-spec\.coffee/
cp 'src', path.join(appDir, 'src'), filter: /.+\.(cson|coffee)$/
cp 'static', path.join(appDir, 'static')

View File

@@ -54,15 +54,19 @@ module.exports = (grunt) ->
mainPath = require.resolve(path.resolve(moduleDirectory, metadata.main))
pack.main = path.relative(appDir, mainPath)
for keymapPath in fs.listSync(path.join(moduleDirectory, 'keymaps'), ['.cson', '.json'])
keymapsPath = path.join(moduleDirectory, 'keymaps')
for keymapPath in fs.listSync(keymapsPath, ['.cson', '.json'])
relativePath = path.relative(appDir, keymapPath)
pack.keymaps[relativePath] = CSON.readFileSync(keymapPath)
rm keymapPath
rm keymapsPath if fs.listSync(keymapsPath).length is 0
for menuPath in fs.listSync(path.join(moduleDirectory, 'menus'), ['.cson', '.json'])
menusPath = path.join(moduleDirectory, 'menus')
for menuPath in fs.listSync(menusPath, ['.cson', '.json'])
relativePath = path.relative(appDir, menuPath)
pack.menus[relativePath] = CSON.readFileSync(menuPath)
rm menuPath
rm menusPath if fs.listSync(menusPath).length is 0
packages[metadata.name] = pack

View File

@@ -1,3 +1,4 @@
asar = require 'asar'
path = require 'path'
module.exports = (grunt) ->
@@ -5,17 +6,29 @@ module.exports = (grunt) ->
shellAppDir = grunt.config.get('atom.shellAppDir')
types = {}
grunt.file.recurse shellAppDir, (absolutePath, rootPath, relativePath, fileName) ->
extension = path.extname(fileName) or fileName
types[extension] ?= 0
types[extension]++
registerFile = (filePath) ->
extension = path.extname(filePath) or path.basename(filePath)
types[extension] ?= []
types[extension].push(filePath)
if extension is '.asar'
asar.listPackage(filePath).forEach (archivePath) ->
archivePath = archivePath.substring(1)
unless asar.statFile(filePath, archivePath, true).files
registerFile(archivePath)
grunt.file.recurse shellAppDir, (absolutePath, rootPath, relativePath, fileName) -> registerFile(absolutePath)
extensions = Object.keys(types).sort (extension1, extension2) ->
diff = types[extension2] - types[extension1]
diff = types[extension2].length - types[extension1].length
if diff is 0
extension1.toLowerCase().localeCompare(extension2.toLowerCase())
else
diff
extensions.forEach (extension) ->
grunt.log.error "#{extension}: #{types[extension]}"
if extension = grunt.option('extension')
types[extension]?.sort().forEach (filePath) ->
grunt.log.error filePath
else
extensions[0...25].forEach (extension) ->
grunt.log.error "#{extension}: #{types[extension].length}"