├── BUNDLED_NODE_VERSION ├── native-module ├── .gitignore ├── index.js ├── package.json ├── src │ └── native.cc └── binding.gyp ├── spec ├── fixtures │ ├── package-with-native-deps │ │ ├── index.js │ │ └── package.json │ ├── test-git-repo.git │ │ ├── hooks │ │ │ └── .gitkeep │ │ ├── refs │ │ │ ├── heads │ │ │ │ └── .gitkeep │ │ │ └── tags │ │ │ │ └── .gitkeep │ │ ├── HEAD │ │ ├── description │ │ ├── packed-refs │ │ ├── config │ │ ├── objects │ │ │ └── pack │ │ │ │ ├── pack-fee09f50a19eb47df3c6fd17d5cf1dd967219da1.idx │ │ │ │ └── pack-fee09f50a19eb47df3c6fd17d5cf1dd967219da1.pack │ │ └── info │ │ │ └── exclude │ ├── packages.txt │ ├── r.tmbundle │ │ ├── Support │ │ │ ├── lib │ │ │ │ ├── command_args │ │ │ │ │ ├── mean │ │ │ │ │ ├── lines │ │ │ │ │ ├── points │ │ │ │ │ ├── dist │ │ │ │ │ ├── plot │ │ │ │ │ ├── getOption │ │ │ │ │ ├── par │ │ │ │ │ └── options │ │ │ │ ├── popen3.rb │ │ │ │ └── historyList.rb │ │ │ ├── tests │ │ │ │ ├── historytestFile.Rconsole │ │ │ │ └── testHistoryList.rb │ │ │ ├── bin │ │ │ │ ├── initCommandArgsDir.sh │ │ │ │ ├── parseHTMLForUsage.sh │ │ │ │ ├── insert_package_name.sh │ │ │ │ ├── startRhelperDaemon.sh │ │ │ │ ├── parseDocForFunctions.sh │ │ │ │ ├── askRhelperDaemon.sh │ │ │ │ ├── ProcessHelpFiles.rb │ │ │ │ ├── prefix_package_name.sh │ │ │ │ ├── insert_command_template.rb │ │ │ │ ├── startRhelperbuilder.sh │ │ │ │ ├── RhelperScript.R │ │ │ │ └── RhelperDaemon.rb │ │ │ ├── getSigTest.R │ │ │ ├── Rmate.css │ │ │ ├── getSig.R │ │ │ └── pastel.css │ │ ├── Snippets │ │ │ ├── Sort.tmSnippet │ │ │ ├── Detach.tmSnippet │ │ │ ├── Factor.tmSnippet │ │ │ ├── Length.tmSnippet │ │ │ ├── na_omit.tmSnippet │ │ │ ├── Load Dataset.tmSnippet │ │ │ ├── Cummulative.tmSnippet │ │ │ ├── Function.tmSnippet │ │ │ ├── file_choose.tmSnippet │ │ │ ├── Ifelse.tmSnippet │ │ │ ├── Add Tick Marks.tmSnippet │ │ │ ├── Density.tmSnippet │ │ │ ├── For Loop.tmSnippet │ │ │ ├── Source.tmSnippet │ │ │ ├── Polygonal Line.tmSnippet │ │ │ ├── Sequence (from,to,by).tmSnippet │ │ │ ├── Attach.tmSnippet │ │ │ ├── Divide Into Intervals.tmSnippet │ │ │ ├── escaped-dollar.tmSnippet │ │ │ └── Read From File.tmSnippet │ │ ├── Preferences │ │ │ ├── Indentation Rules.tmPreferences │ │ │ ├── folding-r.tmPreferences │ │ │ ├── folding-docs.tmPreferences │ │ │ ├── symbol-list1.tmPreferences │ │ │ ├── Comments.plist │ │ │ ├── symbol-list2.tmPreferences │ │ │ └── Methods.tmPreferences │ │ ├── Commands │ │ │ ├── Package Name….tmCommand │ │ │ ├── Show File Header.tmCommand │ │ │ ├── Rd Preview as HTML.tmCommand │ │ │ ├── Show Result as Tooltip.tmCommand │ │ │ ├── Copy Result into Pasteboard.tmCommand │ │ │ ├── load-library-using-library.tmCommand │ │ │ ├── load-library-using-require.tmCommand │ │ │ ├── Edit user-defined Function Parameter.tmCommand │ │ │ ├── Prefix Package Name current Function.tmCommand │ │ │ ├── arrow-left.tmCommand │ │ │ ├── Insert Result.tmCommand │ │ │ ├── CRAN Packages.tmCommand │ │ │ ├── Show R Documentation.tmCommand │ │ │ ├── Summaries….tmCommand │ │ │ ├── Rd Insert arguments tag.tmCommand │ │ │ ├── Help.tmCommand │ │ │ ├── Terminate Helper Daemon.tmCommand │ │ │ ├── Plots….tmCommand │ │ │ ├── Function Call.tmCommand │ │ │ ├── Create Vector from Selection.tmCommand │ │ │ ├── R_app.tmCommand │ │ │ ├── Descriptives….tmCommand │ │ │ ├── option-list.tmCommand │ │ │ ├── web-search.tmCommand │ │ │ ├── Function Definition.tmCommand │ │ │ ├── r-site-search.tmCommand │ │ │ ├── Create Matrix from Selection.tmCommand │ │ │ ├── evaluate-selector.tmCommand │ │ │ ├── run-selector.tmCommand │ │ │ ├── require-current-function.tmCommand │ │ │ └── par-params.tmCommand │ │ ├── README.mdown │ │ ├── DragCommands │ │ │ ├── load.tmDragCommand │ │ │ ├── source.tmDragCommand │ │ │ ├── read_csv.tmDragCommand │ │ │ ├── read_table.tmDragCommand │ │ │ └── read_spss.tmDragCommand │ │ └── Macros │ │ │ ├── next-list-element.tmMacro │ │ │ ├── previous-list-element.tmMacro │ │ │ ├── function-params.tmMacro │ │ │ └── show-function-usage.tmMacro │ ├── node.lib │ ├── repo.git │ ├── node_x64.lib │ ├── node-v0.10.3.tar.gz │ ├── test-module-1.0.0.tgz │ ├── test-module2-2.0.0.tgz │ ├── SHASUMS256.txt │ ├── test-module-with-bin-2.0.0.tgz │ ├── test-module-with-symlink-5.0.0.tgz │ ├── test-module │ │ └── package.json │ ├── test-module-two │ │ └── package.json │ ├── test-module-three │ │ └── package.json │ ├── stars.json │ ├── test-module-with-dependencies │ │ └── package.json │ ├── upgrade-test-module.json │ ├── upgrade-different-repo.json │ ├── atom-2048.json │ ├── themes.json │ ├── install-test-module.json │ ├── install-test-module2.json │ ├── install-test-module-with-bin.json │ ├── install-test-module-with-symlink.json │ ├── packages.json │ ├── install-multi-version.json │ ├── upgrade-multi-version.json │ ├── available.json │ ├── search.json │ └── wrap-guide.json ├── spec-helper.coffee ├── command-spec.coffee ├── search-spec.coffee ├── config-spec.coffee ├── featured-spec.coffee ├── help-spec.coffee ├── apm-cli-spec.coffee ├── clean-spec.coffee ├── view-spec.coffee ├── rebuild-spec.coffee └── test-spec.coffee ├── templates ├── theme │ ├── index.less │ ├── .gitignore.template │ ├── CHANGELOG.md │ ├── README.md │ ├── styles │ │ ├── colors.less │ │ └── syntax-variables.less │ ├── package.json │ └── LICENSE.md ├── language │ ├── .gitignore.template │ ├── CHANGELOG.md │ ├── README.md │ ├── settings │ │ └── language-__package-name__.cson │ ├── snippets │ │ └── language-__package-name__.cson │ ├── grammars │ │ └── __package-name__.cson │ ├── package.json │ ├── spec │ │ └── language-__package-name__-spec.coffee │ └── LICENSE.md ├── package-javascript │ ├── .gitignore.template │ ├── CHANGELOG.md │ ├── keymaps │ │ └── __package-name__.json.template │ ├── README.md │ ├── spec │ │ └── __package-name__-view-spec.js.template │ ├── styles │ │ └── __package-name__.less.template │ ├── package.json │ ├── menus │ │ └── __package-name__.json.template │ ├── lib │ │ ├── __package-name__-view.js.template │ │ └── __package-name__.js.template │ └── LICENSE.md ├── bundle │ ├── README.md │ ├── CHANGELOG.md │ └── package.json └── package-coffeescript │ ├── .gitignore.template │ ├── CHANGELOG.md │ ├── README.md │ ├── spec │ └── __package-name__-view-spec.coffee.template │ ├── styles │ └── __package-name__.less.template │ ├── keymaps │ └── __package-name__.cson.template │ ├── package.json │ ├── menus │ └── __package-name__.cson.template │ ├── lib │ ├── __package-name__-view.coffee.template │ └── __package-name__.coffee.template │ └── LICENSE.md ├── .gitignore ├── CONTRIBUTING.md ├── .npmignore ├── src ├── cli.coffee ├── deprecated-packages.coffee ├── packages.coffee ├── tree.coffee ├── fs.coffee ├── auth.coffee ├── docs.coffee ├── config.coffee ├── theme-converter.coffee ├── links.coffee ├── link.coffee ├── unstar.coffee ├── enable.coffee ├── rebuild-module-cache.coffee ├── test.coffee ├── request.coffee ├── git.coffee ├── rebuild.coffee └── login.coffee ├── bin ├── npm.cmd ├── npm ├── apm └── apm.cmd ├── script ├── postinstall.sh ├── bundled-node-version.js ├── postinstall.js ├── postinstall.cmd └── check-version.js ├── appveyor.yml ├── .pairs ├── .travis.yml ├── coffeelint.json ├── LICENSE.md ├── Gruntfile.coffee └── package.json /BUNDLED_NODE_VERSION: -------------------------------------------------------------------------------- 1 | v4.4.5 2 | -------------------------------------------------------------------------------- /native-module/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /spec/fixtures/package-with-native-deps/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/hooks/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/refs/heads/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/refs/tags/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /native-module/index.js: -------------------------------------------------------------------------------- 1 | module.exports = {"hello": "world"}; 2 | -------------------------------------------------------------------------------- /spec/fixtures/packages.txt: -------------------------------------------------------------------------------- 1 | test-module 2 | test-module2 3 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /templates/theme/index.less: -------------------------------------------------------------------------------- 1 | @import "./styles/base.less"; 2 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/command_args/mean: -------------------------------------------------------------------------------- 1 | trim=0 2 | na.rm=TRUE -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/command_args/lines: -------------------------------------------------------------------------------- 1 | type="p|l|b|c|o|h|s|S|n" -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/command_args/points: -------------------------------------------------------------------------------- 1 | type="p|l|b|c|o|h|s|S|n" -------------------------------------------------------------------------------- /templates/language/.gitignore.template: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /templates/theme/.gitignore.template: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /bin/node* 3 | /lib/ 4 | .DS_Store 5 | npm-debug.log 6 | *~ 7 | -------------------------------------------------------------------------------- /spec/fixtures/node.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhq/apm/master/spec/fixtures/node.lib -------------------------------------------------------------------------------- /spec/fixtures/repo.git: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhq/apm/master/spec/fixtures/repo.git -------------------------------------------------------------------------------- /spec/fixtures/node_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhq/apm/master/spec/fixtures/node_x64.lib -------------------------------------------------------------------------------- /templates/package-javascript/.gitignore.template: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /templates/bundle/README.md: -------------------------------------------------------------------------------- 1 | # __package-name__ package 2 | 3 | A short description of your package. 4 | -------------------------------------------------------------------------------- /templates/package-coffeescript/.gitignore.template: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /native-module/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "module-with-native-code", 3 | "main": "./index.js" 4 | } 5 | -------------------------------------------------------------------------------- /templates/bundle/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /templates/language/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /templates/theme/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | See the [Atom contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md) 2 | -------------------------------------------------------------------------------- /spec/fixtures/node-v0.10.3.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhq/apm/master/spec/fixtures/node-v0.10.3.tar.gz -------------------------------------------------------------------------------- /native-module/src/native.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("i am a native module"); 5 | } 6 | -------------------------------------------------------------------------------- /spec/fixtures/test-module-1.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhq/apm/master/spec/fixtures/test-module-1.0.0.tgz -------------------------------------------------------------------------------- /spec/fixtures/test-module2-2.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhq/apm/master/spec/fixtures/test-module2-2.0.0.tgz -------------------------------------------------------------------------------- /templates/language/README.md: -------------------------------------------------------------------------------- 1 | # PackageName language package 2 | 3 | A short description of your language package. 4 | -------------------------------------------------------------------------------- /templates/package-javascript/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /spec/fixtures/SHASUMS256.txt: -------------------------------------------------------------------------------- 1 | d5abc24102c80b97f100e921075845ff491646dde6ebf11012635a67bd6aba2a ./node-v0.10.3.tar.gz 2 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /templates/package-coffeescript/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /spec/fixtures/test-module-with-bin-2.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhq/apm/master/spec/fixtures/test-module-with-bin-2.0.0.tgz -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .npmignore 2 | *.coffee 3 | .DS_Store 4 | npm-debug.log 5 | spec/ 6 | tasks/ 7 | bin/node 8 | .travis.yml 9 | .pairs 10 | -------------------------------------------------------------------------------- /spec/fixtures/test-module-with-symlink-5.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhq/apm/master/spec/fixtures/test-module-with-symlink-5.0.0.tgz -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled 2 | 8ae432341ac6708aff9bb619eb015da14e9d0c0f refs/heads/master 3 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/command_args/dist: -------------------------------------------------------------------------------- 1 | x 2 | method="euclidean|maximum|manhattan|canberra|binary|minkowski" 3 | diag=FALSE 4 | upper=FALSE 5 | p = 2 -------------------------------------------------------------------------------- /templates/package-javascript/keymaps/__package-name__.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "atom-workspace": { 3 | "ctrl-alt-o": "__package-name__:toggle" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = true 5 | ignorecase = true 6 | precomposeunicode = true 7 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/tests/historytestFile.Rconsole: -------------------------------------------------------------------------------- 1 | > first command 2 | > second command 3 | > 4 | > 5 | not an item 6 | > first command 7 | > third command 8 | > -------------------------------------------------------------------------------- /src/cli.coffee: -------------------------------------------------------------------------------- 1 | apm = require './apm-cli' 2 | 3 | process.title = 'apm' 4 | 5 | apm.run process.argv.slice(2), (error) -> 6 | process.exitCode = if error? then 1 else 0 7 | -------------------------------------------------------------------------------- /spec/fixtures/test-module/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-module", 3 | "version": "1.0.0", 4 | "main": "./index.js", 5 | "engines": { 6 | "atom": "*" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spec/fixtures/test-module-two/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-module-two", 3 | "version": "1.0.0", 4 | "main": "./index.js", 5 | "engines": { 6 | "atom": "*" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spec/fixtures/test-module-three/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-module-three", 3 | "version": "1.0.0", 4 | "main": "./index.js", 5 | "engines": { 6 | "atom": "*" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /native-module/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'targets': [ 3 | { 4 | 'target_name': 'native', 5 | 'sources': [ 6 | 'src/native.cc', 7 | ], 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /templates/theme/README.md: -------------------------------------------------------------------------------- 1 | # __package-name__ theme 2 | 3 | A short description of your theme. 4 | 5 | ![A screenshot of your theme](https://f.cloud.github.com/assets/69169/2289498/4c3cb0ec-a009-11e3-8dbd-077ee11741e5.gif) 6 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/objects/pack/pack-fee09f50a19eb47df3c6fd17d5cf1dd967219da1.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhq/apm/master/spec/fixtures/test-git-repo.git/objects/pack/pack-fee09f50a19eb47df3c6fd17d5cf1dd967219da1.idx -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/objects/pack/pack-fee09f50a19eb47df3c6fd17d5cf1dd967219da1.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhq/apm/master/spec/fixtures/test-git-repo.git/objects/pack/pack-fee09f50a19eb47df3c6fd17d5cf1dd967219da1.pack -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/command_args/plot: -------------------------------------------------------------------------------- 1 | asp="y/x aspect ratio" 2 | log="x|y|xy|yx" 3 | main="title" 4 | sub="subtitle" 5 | type="p|l|b|c|o|h|s|S|n" 6 | xlab="x-title" 7 | xlog=TRUE 8 | ylab="y-title" 9 | ylog=TRUE 10 | -------------------------------------------------------------------------------- /templates/package-coffeescript/README.md: -------------------------------------------------------------------------------- 1 | # __package-name__ package 2 | 3 | A short description of your package. 4 | 5 | ![A screenshot of your package](https://f.cloud.github.com/assets/69169/2290250/c35d867a-a017-11e3-86be-cd7c5bf3ff9b.gif) 6 | -------------------------------------------------------------------------------- /templates/package-javascript/README.md: -------------------------------------------------------------------------------- 1 | # __package-name__ package 2 | 3 | A short description of your package. 4 | 5 | ![A screenshot of your package](https://f.cloud.github.com/assets/69169/2290250/c35d867a-a017-11e3-86be-cd7c5bf3ff9b.gif) 6 | -------------------------------------------------------------------------------- /spec/fixtures/stars.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "test-module", 4 | "releases": { 5 | "latest": "0.4.0" 6 | }, 7 | "metadata": { 8 | "name": "test-module", 9 | "version": "0.4.0" 10 | } 11 | } 12 | ] 13 | -------------------------------------------------------------------------------- /spec/fixtures/test-module-with-dependencies/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-module-with-dependencies", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "test-module": "http://localhost:3000/tarball/test-module-1.0.0.tgz" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /spec/fixtures/upgrade-test-module.json: -------------------------------------------------------------------------------- 1 | { 2 | "repository": { 3 | "url": "https://github.com/a/b" 4 | }, 5 | "versions": { 6 | "0.4.0": { 7 | "engines": { 8 | "atom": ">=0.20.0" 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /templates/package-coffeescript/spec/__package-name__-view-spec.coffee.template: -------------------------------------------------------------------------------- 1 | __PackageName__View = require '../lib/__package-name__-view' 2 | 3 | describe "__PackageName__View", -> 4 | it "has one valid test", -> 5 | expect("life").toBe "easy" 6 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/initCommandArgsDir.sh: -------------------------------------------------------------------------------- 1 | WDIR="$HOME/Library/Application Support/TextMate/R/help" 2 | 3 | if [ ! -e "$WDIR/command_args" ]; then 4 | mkdir -p "$WDIR/command_args" 5 | cp -R "$TM_BUNDLE_SUPPORT"/lib/command_args "$WDIR" 6 | fi -------------------------------------------------------------------------------- /spec/fixtures/upgrade-different-repo.json: -------------------------------------------------------------------------------- 1 | { 2 | "repository": { 3 | "url": "https://github.com/hello/world" 4 | }, 5 | "versions": { 6 | "0.4.0": { 7 | "engines": { 8 | "atom": "*" 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /templates/language/settings/language-__package-name__.cson: -------------------------------------------------------------------------------- 1 | # If you want some examples of settings, check out: 2 | # https://github.com/atom/language-gfm/blob/master/settings/gfm.cson 3 | 4 | '.source.__package-name__': 5 | 'editor': 6 | 'commentStart': '@@ ' 7 | -------------------------------------------------------------------------------- /spec/fixtures/package-with-native-deps/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-module", 3 | "version": "1.0.0", 4 | "main": "./index.js", 5 | "engines": { 6 | "atom": "*" 7 | }, 8 | "dependencies": { 9 | "native-dep": "./node_modules/native-dep" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spec/fixtures/atom-2048.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "releases": { 4 | "latest": "1.2.3" 5 | }, 6 | "name": "atom-2048", 7 | "versions": { 8 | "1.2.3": { 9 | "dist": { 10 | "tarball": "http://localhost:3000/tarball/test-module-1.0.0.tgz" 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/info/exclude: -------------------------------------------------------------------------------- 1 | # git ls-files --others --exclude-from=.git/info/exclude 2 | # Lines that start with '#' are comments. 3 | # For a project mostly in C, the following would be a good set of 4 | # exclude patterns (uncomment them if you want to use them): 5 | # *.[oa] 6 | # *~ 7 | -------------------------------------------------------------------------------- /bin/npm.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal EnableDelayedExpansion 3 | 4 | set "PATH=%~dp0;%PATH%" 5 | set maybe_node_gyp_path=%~dp0\..\node_modules\node-gyp\bin\node-gyp.js 6 | if exist %maybe_node_gyp_path% ( 7 | set npm_config_node_gyp=%maybe_node_gyp_path% 8 | ) 9 | %~dp0\..\node_modules\.bin\npm.cmd %* 10 | -------------------------------------------------------------------------------- /templates/package-javascript/spec/__package-name__-view-spec.js.template: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import __PackageName__View from '../lib/__package-name__-view'; 4 | 5 | describe('__PackageName__View', () => { 6 | it('has one valid test', () => { 7 | expect('life').toBe('easy'); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /templates/language/snippets/language-__package-name__.cson: -------------------------------------------------------------------------------- 1 | # If you want some example snippets, check out: 2 | # https://github.com/atom/language-gfm/blob/master/snippets/gfm.cson 3 | 4 | '.source.__package-name__': 5 | 'Method documentation': 6 | 'prefix': 'doc' 7 | 'body': '@@ ${1:method} - ${2:description}' 8 | -------------------------------------------------------------------------------- /script/postinstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo ">> Downloading bundled Node" 6 | node script/download-node.js 7 | 8 | echo 9 | echo ">> Rebuilding apm dependencies with bundled Node $(./bin/node -v)" 10 | ./bin/npm rebuild 11 | 12 | echo 13 | echo ">> Deduping apm dependencies" 14 | ./bin/npm dedupe 15 | -------------------------------------------------------------------------------- /spec/fixtures/themes.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "duckblur", 4 | "releases": { 5 | "latest": "19.92" 6 | }, 7 | "metadata": { 8 | "name": "duckblur", 9 | "version": "19.92", 10 | "theme": true, 11 | "description": "Racecars, lasers, airplanes" 12 | } 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /script/bundled-node-version.js: -------------------------------------------------------------------------------- 1 | module.exports = function(filename, callback) { 2 | require('child_process').exec(filename + ' -v', function(error, stdout) { 3 | var version = null; 4 | if (stdout != null) { 5 | version = stdout.toString().trim(); 6 | } 7 | callback(error, version); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /templates/package-javascript/styles/__package-name__.less.template: -------------------------------------------------------------------------------- 1 | // The ui-variables file is provided by base themes provided by Atom. 2 | // 3 | // See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less 4 | // for a full listing of what's available. 5 | @import "ui-variables"; 6 | 7 | .__package-name__ { 8 | } 9 | -------------------------------------------------------------------------------- /templates/package-coffeescript/styles/__package-name__.less.template: -------------------------------------------------------------------------------- 1 | // The ui-variables file is provided by base themes provided by Atom. 2 | // 3 | // See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less 4 | // for a full listing of what's available. 5 | @import "ui-variables"; 6 | 7 | .__package-name__ { 8 | } 9 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | os: Windows Server 2012 R2 4 | 5 | platform: x86 6 | 7 | environment: 8 | nodejs_version: "4.4.5" 9 | 10 | install: 11 | - ps: Install-Product node $env:nodejs_version $env:platform 12 | - npm install -g npm 13 | - npm install 14 | 15 | build: off 16 | 17 | test: off 18 | 19 | deploy: off 20 | -------------------------------------------------------------------------------- /spec/fixtures/install-test-module.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "0.4.0" 4 | }, 5 | "name": "test-module", 6 | "versions": { 7 | "0.4.0": { 8 | "dist": { 9 | "tarball": "http://localhost:3000/tarball/test-module-1.0.0.tgz" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spec/fixtures/install-test-module2.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "2.0.0" 4 | }, 5 | "name": "test-module", 6 | "versions": { 7 | "2.0.0": { 8 | "dist": { 9 | "tarball": "http://localhost:3000/tarball/test-module2-2.0.0.tgz" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /bin/npm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | export PATH="$SCRIPT_DIR:$PATH" 4 | 5 | maybe_node_gyp_path="$SCRIPT_DIR"/../node_modules/.bin/node-gyp 6 | if [ -e "$maybe_node_gyp_path" ] 7 | then 8 | export npm_config_node_gyp="$maybe_node_gyp_path" 9 | fi 10 | 11 | "$SCRIPT_DIR"/../node_modules/.bin/npm $@ 12 | -------------------------------------------------------------------------------- /spec/fixtures/install-test-module-with-bin.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "2.0.0" 4 | }, 5 | "name": "test-module-with-bin", 6 | "versions": { 7 | "2.0.0": { 8 | "dist": { 9 | "tarball": "http://localhost:3000/tarball/test-module-with-bin-2.0.0.tgz" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spec/fixtures/install-test-module-with-symlink.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "5.0.0" 4 | }, 5 | "name": "test-module-with-symlink", 6 | "versions": { 7 | "5.0.0": { 8 | "dist": { 9 | "tarball": "http://localhost:3000/tarball/test-module-with-symlink-5.0.0.tgz" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /templates/bundle/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "__package-name__", 3 | "version": "0.0.0", 4 | "description": "A short description of your package", 5 | "keywords": [ 6 | ], 7 | "repository": "https://github.com/__package-author__/__package-name__", 8 | "license": "MIT", 9 | "engines": { 10 | "atom": ">=1.0.0 <2.0.0" 11 | }, 12 | "dependencies": { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /templates/language/grammars/__package-name__.cson: -------------------------------------------------------------------------------- 1 | # If this is your first time writing a language grammar, check out: 2 | # - http://manual.macromates.com/en/language_grammars 3 | 4 | 'scopeName': 'source.__package-name__' 5 | 'name': 'PackageName' 6 | 'fileTypes': [ 7 | 'extension' 8 | ] 9 | 'patterns': [ 10 | { 11 | 'match': '^\\s*@@.*$' 12 | 'name': 'comment' 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /templates/theme/styles/colors.less: -------------------------------------------------------------------------------- 1 | // These colors are specific to the theme. Do not use in a package! 2 | 3 | @very-light-gray: #c5c8c6; 4 | @light-gray: #969896; 5 | @gray: #373b41; 6 | @dark-gray: #282a2e; 7 | @very-dark-gray: #1d1f21; 8 | 9 | @cyan: #8abeb7; 10 | @blue: #81a2be; 11 | @purple: #b294bb; 12 | @green: #b5bd68; 13 | @red: #cc6666; 14 | @orange: #de935f; 15 | @light-orange: #f0c674; 16 | -------------------------------------------------------------------------------- /script/postinstall.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var cp = require('child_process') 3 | 4 | var script = path.join(__dirname, 'postinstall') 5 | if (process.platform.indexOf('win') === 0) { 6 | script += '.cmd' 7 | } else { 8 | script += '.sh' 9 | } 10 | var child = cp.exec(script, [], {stdio: ['pipe', 'pipe', 'pipe']}) 11 | child.stderr.pipe(process.stderr) 12 | child.stdout.pipe(process.stdout) 13 | -------------------------------------------------------------------------------- /templates/theme/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "__package-name__", 3 | "theme": "syntax", 4 | "version": "0.0.0", 5 | "description": "A short description of your syntax theme", 6 | "keywords": [ 7 | "syntax", 8 | "theme" 9 | ], 10 | "repository": "https://github.com/__package-author__/__package-name__", 11 | "license": "MIT", 12 | "engines": { 13 | "atom": ">=1.0.0 <2.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /templates/language/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-__package-name__", 3 | "version": "0.0.0", 4 | "description": "A short description of your language package", 5 | "keywords": [ 6 | "language", 7 | "grammar" 8 | ], 9 | "repository": "https://github.com/__package-author__/language-__package-name__", 10 | "license": "MIT", 11 | "engines": { 12 | "atom": ">=1.0.0 <2.0.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.pairs: -------------------------------------------------------------------------------- 1 | pairs: 2 | ns: Nathan Sobo; nathan 3 | cj: Corey Johnson; cj 4 | dg: David Graham; dgraham 5 | ks: Kevin Sawicki; kevin 6 | jc: Jerry Cheung; jerry 7 | bl: Brian Lopez; brian 8 | jp: Justin Palmer; justin 9 | gt: Garen Torikian; garen 10 | mc: Matt Colyer; mcolyer 11 | bo: Ben Ogle; benogle 12 | jr: Jason Rudolph; jasonrudolph 13 | jl: Jessica Lord; jlord 14 | email: 15 | domain: github.com 16 | #global: true 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | notifications: 4 | email: 5 | on_success: never 6 | on_failure: change 7 | 8 | node_js: 9 | - "0.10" 10 | - "4" 11 | - "6" 12 | 13 | script: ./bin/npm test 14 | 15 | git: 16 | depth: 10 17 | 18 | branches: 19 | only: 20 | - master 21 | 22 | sudo: false 23 | 24 | addons: 25 | apt: 26 | packages: 27 | - libgnome-keyring-dev 28 | - g++-4.8 29 | sources: 30 | - ubuntu-toolchain-r-test 31 | 32 | env: 33 | - CXX=g++-4.8 34 | -------------------------------------------------------------------------------- /src/deprecated-packages.coffee: -------------------------------------------------------------------------------- 1 | semver = require 'semver' 2 | deprecatedPackages = null 3 | 4 | exports.isDeprecatedPackage = (name, version) -> 5 | deprecatedPackages ?= require('../deprecated-packages') ? {} 6 | return false unless deprecatedPackages.hasOwnProperty(name) 7 | 8 | deprecatedVersionRange = deprecatedPackages[name].version 9 | return true unless deprecatedVersionRange 10 | 11 | semver.valid(version) and semver.validRange(deprecatedVersionRange) and semver.satisfies(version, deprecatedVersionRange) 12 | -------------------------------------------------------------------------------- /templates/package-javascript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "__package-name__", 3 | "main": "./lib/__package-name__", 4 | "version": "0.0.0", 5 | "description": "A short description of your package", 6 | "keywords": [ 7 | ], 8 | "activationCommands": { 9 | "atom-workspace": "__package-name__:toggle" 10 | }, 11 | "repository": "https://github.com/__package-author__/__package-name__", 12 | "license": "MIT", 13 | "engines": { 14 | "atom": ">=1.0.0 <2.0.0" 15 | }, 16 | "dependencies": { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /templates/package-coffeescript/keymaps/__package-name__.cson.template: -------------------------------------------------------------------------------- 1 | # Keybindings require three things to be fully defined: A selector that is 2 | # matched against the focused element, the keystroke and the command to 3 | # execute. 4 | # 5 | # Below is a basic keybinding which registers on all platforms by applying to 6 | # the root workspace element. 7 | 8 | # For more detailed documentation see 9 | # https://atom.io/docs/latest/behind-atom-keymaps-in-depth 10 | 'atom-workspace': 11 | 'ctrl-alt-o': '__package-name__:toggle' 12 | -------------------------------------------------------------------------------- /templates/package-coffeescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "__package-name__", 3 | "main": "./lib/__package-name__", 4 | "version": "0.0.0", 5 | "description": "A short description of your package", 6 | "keywords": [ 7 | ], 8 | "activationCommands": { 9 | "atom-workspace": "__package-name__:toggle" 10 | }, 11 | "repository": "https://github.com/__package-author__/__package-name__", 12 | "license": "MIT", 13 | "engines": { 14 | "atom": ">=1.0.0 <2.0.0" 15 | }, 16 | "dependencies": { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /script/postinstall.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal EnableDelayedExpansion 3 | setlocal EnableExtensions 4 | 5 | echo ^>^> Downloading bundled Node 6 | node .\script\download-node.js 7 | 8 | echo The version of Node we downloaded: 9 | call .\bin\node.exe -v 10 | 11 | echo "" 12 | for /f "delims=" %%i in ('.\bin\node.exe -v') do set bundledVersion=%%i 13 | echo ^>^> Rebuilding apm dependencies with bundled Node !bundledVersion! 14 | call .\bin\npm.cmd rebuild 15 | 16 | echo "" 17 | echo ^>^> Deduping apm dependencies 18 | call .\bin\npm.cmd dedupe 19 | -------------------------------------------------------------------------------- /spec/spec-helper.coffee: -------------------------------------------------------------------------------- 1 | auth = require '../lib/auth' 2 | 3 | global.silenceOutput = (callThrough = false) -> 4 | spyOn(console, 'log') 5 | spyOn(console, 'error') 6 | spyOn(process.stdout, 'write') 7 | spyOn(process.stderr, 'write') 8 | 9 | if callThrough 10 | spy.andCallThrough() for spy in [ 11 | console.log, 12 | console.error, 13 | process.stdout.write, 14 | process.stderr.write 15 | ] 16 | 17 | global.spyOnToken = -> 18 | spyOn(auth, 'getToken').andCallFake (callback) -> callback(null, 'token') 19 | -------------------------------------------------------------------------------- /spec/command-spec.coffee: -------------------------------------------------------------------------------- 1 | Command = require '../lib/command' 2 | 3 | describe "Command", -> 4 | describe "::spawn", -> 5 | it "only calls the callback once if the spawned program fails", -> 6 | exited = false 7 | callbackCount = 0 8 | 9 | command = new Command 10 | child = command.spawn "thisisafakecommand", [], -> 11 | callbackCount++ 12 | child.once "close", -> 13 | exited = true 14 | 15 | waitsFor -> 16 | exited 17 | 18 | runs -> 19 | expect(callbackCount).toEqual 1 20 | -------------------------------------------------------------------------------- /spec/fixtures/packages.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "beverly-hills", 4 | "releases": { 5 | "latest": "9.0.2.1.0" 6 | }, 7 | "metadata": { 8 | "name": "beverly-hills", 9 | "version": "9.0.2.1.0", 10 | "description": "Home of the peach pit after dark" 11 | } 12 | }, 13 | { 14 | "name": "multi-version", 15 | "releases": { 16 | "latest": "2.0.0", 17 | "other": "1.0.0" 18 | }, 19 | "metadata": { 20 | "name": "multi-version", 21 | "version": "2.0.0" 22 | } 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /spec/fixtures/install-multi-version.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "0.4.0" 4 | }, 5 | "name": "multi-module", 6 | "versions": { 7 | "0.4.0": { 8 | "engines": { 9 | "atom": ">=2.0" 10 | } 11 | }, 12 | "0.3.0": { 13 | "engines": { 14 | "atom": ">=1.0" 15 | }, 16 | "dist": { 17 | "tarball": "http://localhost:3000/tarball/test-module-1.0.0.tgz" 18 | } 19 | }, 20 | "0.2.0": { 21 | "engines": { 22 | "atom": ">=1.0" 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Sort.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | sort(${1:x}) 7 | name 8 | Sort 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | sor 13 | uuid 14 | A9D21636-8157-4C3B-967B-B0E24595AA86 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/parseHTMLForUsage.sh: -------------------------------------------------------------------------------- 1 | 2 | export WORD="$1" 3 | export FLAG="$2" 4 | 5 | # FLAG == 1 remove \n and function name for parameter parsing 6 | # FLAG == 0 show function usage 7 | 8 | cat | perl -e ' 9 | undef($/); 10 | $w=$ENV{"WORD"}; 11 | $f=$ENV{"FLAG"}; 12 | $a=<>; 13 | $a=~s!.*?Usage\s*
[^>]*?($w\([^>]*?\)).*?\n.*?
.*!$1!ms; 14 | $a=~s/"\t"/"\\t"/sg; 15 | $a=~s/"\n"/"\\n"/sg; 16 | if($f) { 17 | $a=~s/\n//sg; 18 | $a=~s/^$w//ms; 19 | $a="" if($a!~m/^\(.*\)$/); 20 | } 21 | if($a!~m/^ 11 | if repository = pack.repository?.url ? pack.repository 12 | repoPath = url.parse(repository.replace(/\.git$/, '')).pathname 13 | [name, owner] = repoPath.split('/')[-2..] 14 | return "#{name}/#{owner}" if name and owner 15 | null 16 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Detach.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | detach(${0:}) 7 | name 8 | Detach 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | det 13 | uuid 14 | 481CC207-5003-4AAE-8202-E353889470C9 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Factor.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | factor(${1:x}) 7 | name 8 | Factor 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | fac 13 | uuid 14 | 0D80E89D-F95D-4C5E-B174-342B245CD56B 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Length.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | length(${1:x}) 7 | name 8 | Length 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | len 13 | uuid 14 | CE3CB75A-3283-4BF0-BDD8-FF8F50F61762 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/na_omit.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | na.omit(${0:}) 7 | name 8 | na.omit 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | nao 13 | uuid 14 | C7D7C1F9-E2F7-4B09-8C1A-AD66C19E9CB3 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Load Dataset.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | data(${1:name}) 7 | name 8 | Load Dataset 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | dat 13 | uuid 14 | 5A0EA5CD-5767-4D11-AF9A-C4447A8EA4B4 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Cummulative.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | cum${1:max}(${2:x}) 7 | name 8 | Cummulative 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | cum 13 | uuid 14 | 9BB0E6BD-62E9-4D5A-A1B6-6A5545F58EFD 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Function.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | function(${1:x}) ${3:{$0\}} 7 | name 8 | Function 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | fun 13 | uuid 14 | 02F9D19E-BE8F-4BAA-99EB-2A304BB873FE 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/file_choose.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ${1:file = }file.choose()${0:} 7 | name 8 | file.choose 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | fch 13 | uuid 14 | FA279758-BC29-4BE9-AFD6-045DB6A17711 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/getSigTest.R: -------------------------------------------------------------------------------- 1 | # This file is just used for testing getSig.R 2 | # I committed it to the repo so it can be used for further maintenance of getSig.R 3 | # 4 | # Kevin Ballard 5 | 6 | source("./getSig.R") 7 | 8 | # function to use in testing symbols 9 | fubar <- function (x, y=`+`, z=if (T) "foo" else "bar", q="haha", `a a`=c("heavy", "medium", "light"), meth=mean) { 10 | do.call(y, as.list(x)) 11 | } 12 | 13 | # cat(paste(getSig(if ('p' %in% (ary <- sort(apropos('^p', mode='function')))) 'p' else ary), collapse='\n')) 14 | cat(paste(getSig("fubar"), collapse="\n")) 15 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Ifelse.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ifelse(${1:test}, ${2:yes}, ${3:no}) 7 | name 8 | Ifelse 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | ife 13 | uuid 14 | 69D9877A-4A4C-4DC7-97E5-392B45941A82 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/tree.coffee: -------------------------------------------------------------------------------- 1 | _ = require 'underscore-plus' 2 | 3 | module.exports = (items, options={}, callback) -> 4 | if _.isFunction(options) 5 | callback = options 6 | options = {} 7 | callback ?= (item) -> item 8 | 9 | if items.length is 0 10 | emptyMessage = options.emptyMessage ? '(empty)' 11 | console.log "\u2514\u2500\u2500 #{emptyMessage}" 12 | else 13 | for item, index in items 14 | if index is items.length - 1 15 | itemLine = '\u2514\u2500\u2500 ' 16 | else 17 | itemLine = '\u251C\u2500\u2500 ' 18 | console.log "#{itemLine}#{callback(item)}" 19 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Add Tick Marks.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | rug(${1:jitter(${2:x})}) 7 | name 8 | Add Tick Marks 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | rug 13 | uuid 14 | EB449D09-F66E-4C1B-BFAF-B9FA27DB991C 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Density.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | density(${1:x}${2:, bw = ${3:bandwidth}}) 7 | name 8 | Density 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | den 13 | uuid 14 | 93D9F298-A5FF-4935-A906-1C1E31AF451A 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/For Loop.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | for (${1:i} in ${2:seq}) ${3:{$0\}} 7 | name 8 | For Loop 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | for 13 | uuid 14 | 63A97132-D522-48D9-937A-6A1F04E45F7D 15 | 16 | 17 | -------------------------------------------------------------------------------- /templates/package-coffeescript/menus/__package-name__.cson.template: -------------------------------------------------------------------------------- 1 | # See https://atom.io/docs/latest/hacking-atom-package-word-count#menus for more details 2 | 'context-menu': 3 | 'atom-text-editor': [ 4 | { 5 | 'label': 'Toggle __package-name__' 6 | 'command': '__package-name__:toggle' 7 | } 8 | ] 9 | 'menu': [ 10 | { 11 | 'label': 'Packages' 12 | 'submenu': [ 13 | 'label': '__package-name__' 14 | 'submenu': [ 15 | { 16 | 'label': 'Toggle' 17 | 'command': '__package-name__:toggle' 18 | } 19 | ] 20 | ] 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Source.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | source(${1:"${2:}"}${3:, chdir = ${4:TRUE}}) 7 | name 8 | Source 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | sou 13 | uuid 14 | D7A7E674-E2E6-4454-BA78-952A129FB1E2 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Polygonal Line.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | lines(${1:x}${2:, color=${3:red}}) 7 | name 8 | Polygonal Line 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | lin 13 | uuid 14 | A4E14B93-E8D0-4C8E-AB8E-CCB029E170F0 15 | 16 | 17 | -------------------------------------------------------------------------------- /templates/language/spec/language-__package-name__-spec.coffee: -------------------------------------------------------------------------------- 1 | # If you want an example of language specs, check out: 2 | # https://github.com/atom/language-gfm/blob/master/spec/gfm-spec.coffee 3 | 4 | describe "PackageName grammar", -> 5 | grammar = null 6 | 7 | beforeEach -> 8 | waitsForPromise -> 9 | atom.packages.activatePackage("language-__package-name__") 10 | 11 | runs -> 12 | grammar = atom.syntax.grammarForScopeName("source.__package-name__") 13 | 14 | it "parses the grammar", -> 15 | expect(grammar).toBeTruthy() 16 | expect(grammar.scopeName).toBe "source.__package-name__" 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Sequence (from,to,by).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | seq(${1:from}, ${2:to}, ${3:by}) 7 | name 8 | Sequence (from,to,by) 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | seq 13 | uuid 14 | 4852C9E0-D22C-4FA2-8C85-628B97F6C3B2 15 | 16 | 17 | -------------------------------------------------------------------------------- /templates/package-javascript/menus/__package-name__.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "context-menu": { 3 | "atom-text-editor": [ 4 | { 5 | "label": "Toggle __package-name__", 6 | "command": "__package-name__:toggle" 7 | } 8 | ] 9 | }, 10 | "menu": [ 11 | { 12 | "label": "Packages", 13 | "submenu": [ 14 | { 15 | "label": "__package-name__", 16 | "submenu": [ 17 | { 18 | "label": "Toggle", 19 | "command": "__package-name__:toggle" 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Preferences/Indentation Rules.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Indentation Rules 7 | scope 8 | source.r 9 | settings 10 | 11 | indentNextLinePattern 12 | ^\s*(repeat|else|(((else\s+)?if|for|while)\s*\(.+\))) 13 | 14 | uuid 15 | 8A8DFE5C-EA28-46EB-BD5C-C2B08CAA7352 16 | 17 | 18 | -------------------------------------------------------------------------------- /spec/fixtures/upgrade-multi-version.json: -------------------------------------------------------------------------------- 1 | { 2 | "repository": { 3 | "url": "https://github.com/a/b" 4 | }, 5 | "versions": { 6 | "0.4.0": { 7 | "engines": { 8 | "atom": ">=2.0" 9 | } 10 | }, 11 | "0.3.0": { 12 | "engines": { 13 | "atom": ">=0.5.0" 14 | } 15 | }, 16 | "0.2.1": { 17 | "engines": { 18 | "atom": "invalid" 19 | } 20 | }, 21 | "0.2.0": { 22 | "engines": { 23 | "atom": ">=0.5.0" 24 | } 25 | }, 26 | "0.1.0": { 27 | "engines": { 28 | "atom": ">=0.4.0" 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Attach.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | attach(${1:${TM_FILENAME/.*?(\\w+).*|.*/(?1:$1:NSObject)/}})${TM_C_POINTER: *}outlet 7 | name 8 | Attach 9 | scope 10 | source.rd.tm 11 | tabTrigger 12 | att 13 | uuid 14 | 5F49FB43-86AA-4352-AECB-CA573E9DC7E8 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Divide Into Intervals.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | cut(${1:x}, breaks = c(${2:${3:}, ${4:max(${1:x})}})) 7 | name 8 | Divide Into Intervals 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | cut 13 | uuid 14 | 217EE449-B990-4FDA-A897-F7063022241E 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/escaped-dollar.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | for (my \$${1:var} = 0; \$$1 < ${2:expression}; \$$1++) { 7 | ${3:# body...} 8 | } 9 | 10 | name 11 | For Loop 12 | scope 13 | source.perl 14 | tabTrigger 15 | for 16 | uuid 17 | B2A21D7E-F241-42D3-A6C4-5CA5470EC5C3 18 | 19 | 20 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Preferences/folding-r.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Folding (R) 7 | scope 8 | source.r 9 | settings 10 | 11 | foldingStartMarker 12 | ^[^#]*(\([^\)]*$|\{\s*$) 13 | foldingStopMarker 14 | (^\s*\)|^\s*\}) 15 | 16 | uuid 17 | 88425650-DA1A-44DF-98E8-D37EA091ACA0 18 | 19 | 20 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Preferences/folding-docs.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Folding (Documentation) 7 | scope 8 | text.tex.latex.rd 9 | settings 10 | 11 | foldingStartMarker 12 | /\w*\{\s*$ 13 | foldingStopMarker 14 | ^\s*\} 15 | 16 | uuid 17 | 60CD1452-8D51-4AAA-938F-A40628EA7B9A 18 | 19 | 20 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Preferences/symbol-list1.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Symbol List (Rd Documentation) 7 | scope 8 | keyword.other.section.rd 9 | settings 10 | 11 | showInSymbolList 12 | 1 13 | symbolTransformation 14 | s/\\(.*)/$1/; 15 | 16 | uuid 17 | 5DBBC018-D895-4A52-91D4-60196BC76B49 18 | 19 | 20 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Snippets/Read From File.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | read.table("${1:filename}"${2:, header = ${3:TRUE}, sep = "${4:\t}", stringsAsFactors = ${5:FALSE}}) 7 | name 8 | Read From File 9 | scope 10 | source.r, source.rd.console 11 | tabTrigger 12 | rea 13 | uuid 14 | D8F85702-E792-4856-8D16-54E4EB2F9483 15 | 16 | 17 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/popen3.rb: -------------------------------------------------------------------------------- 1 | # Open a sub-process and return 3 IO objects: stdin, stdout, stderr 2 | # Unlike Open3::popen3, it produces a child, not a grandchild 3 | def popen3(*args) 4 | stdin, stdout, stderr = [IO.pipe, IO.pipe, IO.pipe] 5 | fork do 6 | stdin[1].close 7 | STDIN.reopen(stdin[0]) 8 | stdin[0].close 9 | 10 | stdout[0].close 11 | STDOUT.reopen(stdout[1]) 12 | stdout[1].close 13 | 14 | stderr[0].close 15 | STDERR.reopen(stderr[1]) 16 | stderr[1].close 17 | 18 | exec(*args) 19 | end 20 | stdin[0].close 21 | stdout[1].close 22 | stderr[1].close 23 | [stdin[1], stdout[0], stderr[0]] 24 | end 25 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/insert_package_name.sh: -------------------------------------------------------------------------------- 1 | 2 | "$TM_BUNDLE_SUPPORT"/bin/askRhelperDaemon.sh "@getInstalledPackages()" 3 | 4 | cat "/tmp/textmate_Rhelper_out" | sort -f | /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -e ' 5 | isDIALOG2 = ! ENV["DIALOG"].match(/2$/).nil? 6 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/ui.rb") 7 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/exit_codes.rb") 8 | words = STDIN.read().split("\n") 9 | if isDIALOG2 10 | TextMate::UI.complete(words) 11 | else 12 | index=TextMate::UI.menu(words) 13 | end 14 | if index != nil 15 | print words[index] 16 | else 17 | TextMate.exit_discard() 18 | end 19 | exit 203 20 | ' -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Preferences/Comments.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Comments 7 | scope 8 | source.r 9 | settings 10 | 11 | shellVariables 12 | 13 | 14 | name 15 | TM_COMMENT_START 16 | value 17 | # 18 | 19 | 20 | 21 | uuid 22 | F38E1657-C2D9-48CE-9FFD-3EEA36D8B320 23 | 24 | 25 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Preferences/symbol-list2.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Symbol List: Pragma 7 | scope 8 | comment.line.pragma-mark 9 | settings 10 | 11 | showInSymbolList 12 | 1 13 | symbolTransformation 14 | s/^.*?mark\s+\-+\s*/-/;s/^.*?mark\s+([^\-].+?)/# $1/;s/\s+$//; 15 | 16 | uuid 17 | E4D3F9E2-CE92-4142-B164-0CE1EB1AD453 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/fs.coffee: -------------------------------------------------------------------------------- 1 | _ = require 'underscore-plus' 2 | fs = require 'fs-plus' 3 | ncp = require 'ncp' 4 | rm = require 'rimraf' 5 | wrench = require 'wrench' 6 | 7 | fsAdditions = 8 | list: (directoryPath) -> 9 | if fs.isDirectorySync(directoryPath) 10 | try 11 | fs.readdirSync(directoryPath) 12 | catch e 13 | [] 14 | else 15 | [] 16 | 17 | listRecursive: (directoryPath) -> 18 | wrench.readdirSyncRecursive(directoryPath) 19 | 20 | cp: (sourcePath, destinationPath, callback) -> 21 | rm destinationPath, (error) -> 22 | if error? 23 | callback(error) 24 | else 25 | ncp(sourcePath, destinationPath, callback) 26 | 27 | module.exports = _.extend({}, fs, fsAdditions) 28 | -------------------------------------------------------------------------------- /templates/package-coffeescript/lib/__package-name__-view.coffee.template: -------------------------------------------------------------------------------- 1 | module.exports = 2 | class __PackageName__View 3 | constructor: (serializedState) -> 4 | # Create root element 5 | @element = document.createElement('div') 6 | @element.classList.add('__package-name__') 7 | 8 | # Create message element 9 | message = document.createElement('div') 10 | message.textContent = "The __PackageName__ package is Alive! It's ALIVE!" 11 | message.classList.add('message') 12 | @element.appendChild(message) 13 | 14 | # Returns an object that can be retrieved when package is activated 15 | serialize: -> 16 | 17 | # Tear down any state and detach 18 | destroy: -> 19 | @element.remove() 20 | 21 | getElement: -> 22 | @element 23 | -------------------------------------------------------------------------------- /bin/apm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | initialCwd=`pwd -P` 6 | 7 | apmPath=$0 8 | builtin cd "`dirname "$apmPath"`" 9 | binDir=`basename "$apmPath"` 10 | 11 | # Detect node binary name 12 | osName=`uname -s` 13 | if [ "${osName:0:10}" == 'MINGW32_NT' ]; then 14 | nodeBin="node.exe" 15 | else 16 | nodeBin="node" 17 | fi 18 | 19 | while [ -L "$binDir" ] 20 | do 21 | binDir=`readlink "$binDir"` 22 | builtin cd "`dirname "$binDir"`" 23 | binDir=`basename "$binDir"` 24 | done 25 | 26 | binDir=`pwd -P` 27 | 28 | maybe_node_gyp_path="$binDir"/../node_modules/.bin/node-gyp 29 | if [ -e "$maybe_node_gyp_path" ] 30 | then 31 | export npm_config_node_gyp="$maybe_node_gyp_path" 32 | fi 33 | 34 | builtin cd "$initialCwd" 35 | "$binDir/$nodeBin" "$binDir/../lib/cli.js" "$@" 36 | -------------------------------------------------------------------------------- /coffeelint.json: -------------------------------------------------------------------------------- 1 | { 2 | "max_line_length": { 3 | "level": "ignore" 4 | }, 5 | "no_empty_param_list": { 6 | "level": "error" 7 | }, 8 | "arrow_spacing": { 9 | "level": "error" 10 | }, 11 | "no_interpolation_in_single_quotes": { 12 | "level": "error" 13 | }, 14 | "no_debugger": { 15 | "level": "error" 16 | }, 17 | "prefer_english_operator": { 18 | "level": "error" 19 | }, 20 | "colon_assignment_spacing": { 21 | "spacing": { 22 | "left": 0, 23 | "right": 1 24 | }, 25 | "level": "error" 26 | }, 27 | "braces_spacing": { 28 | "spaces": 0, 29 | "level": "error" 30 | }, 31 | "spacing_after_comma": { 32 | "level": "error" 33 | }, 34 | "no_stand_alone_at": { 35 | "level": "error" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Package Name….tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | "$TM_BUNDLE_SUPPORT"/bin/insert_package_name.sh 9 | input 10 | none 11 | keyEquivalent 12 | ~@L 13 | name 14 | Package Name… 15 | output 16 | discard 17 | scope 18 | source.r, source.rd.console 19 | uuid 20 | 18B3BAF5-A2E0-43A6-9017-56E1D365A055 21 | 22 | 23 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Show File Header.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | head -n 3 "$TM_SELECTED_TEXT" 9 | fallbackInput 10 | none 11 | input 12 | selection 13 | name 14 | Show File Header 15 | output 16 | showAsTooltip 17 | scope 18 | source.r, source.rd.console 19 | uuid 20 | 381D1464-6F33-41E3-A938-C10FAB619C24 21 | 22 | 23 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Rd Preview as HTML.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveActiveFile 7 | command 8 | R CMD Rdconv -t html "$TM_FILEPATH" 9 | input 10 | none 11 | keyEquivalent 12 | ^~@p 13 | name 14 | Rd Preview as HTML 15 | output 16 | showAsHTML 17 | scope 18 | text.tex.latex.rd 19 | uuid 20 | AE350C40-DA76-4BDD-AAD0-27F7247511EB 21 | 22 | 23 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Show Result as Tooltip.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | cat | R --vanilla --slave --no-readline --encoding=UTF-8 9 | input 10 | selection 11 | keyEquivalent 12 | ^@r 13 | name 14 | Show Result as Tooltip 15 | output 16 | showAsTooltip 17 | scope 18 | source.r 19 | uuid 20 | E3EAFF15-1B8D-4E74-8649-2A3CADC0A119 21 | 22 | 23 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Copy Result into Pasteboard.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | cat | R --vanilla --slave --no-readline --encoding=UTF-8 | pbcopy 9 | input 10 | selection 11 | keyEquivalent 12 | ^@r 13 | name 14 | Copy Result into Pasteboard 15 | output 16 | showAsTooltip 17 | scope 18 | source.r 19 | uuid 20 | C666D732-9E4D-49C7-BEEC-BC20590414BF 21 | 22 | 23 | -------------------------------------------------------------------------------- /spec/fixtures/available.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "beverly-hills", 4 | "releases": { 5 | "latest": "9.0.2.1.0" 6 | }, 7 | "metadata": { 8 | "name": "beverly-hills", 9 | "version": "9.0.2.1.0", 10 | "description": "Home of the peach pit after dark" 11 | } 12 | }, 13 | { 14 | "name": "multi-version", 15 | "releases": { 16 | "latest": "2.0.0", 17 | "other": "1.0.0" 18 | }, 19 | "metadata": { 20 | "name": "multi-version", 21 | "version": "2.0.0" 22 | } 23 | }, 24 | { 25 | "name": "duckblur", 26 | "releases": { 27 | "latest": "19.92" 28 | }, 29 | "metadata": { 30 | "name": "duckblur", 31 | "version": "19.92", 32 | "theme": true, 33 | "description": "Racecars, lasers, airplanes" 34 | } 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Preferences/Methods.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Symbol List: Method 7 | scope 8 | keyword.name.function, meta.method.declaration.r 9 | settings 10 | 11 | showInSymbolList 12 | 1 13 | symbolTransformation 14 | s/^.*?\(\s*([\w\d]+\s*=\s*)?(["\x{27}])(.*?)\2[^"\x{27}]+?(["\x{27}])(.*?)\4.*/- $3 ($5)/; 15 | s/^\s*(\S+?)\s*\(\s*([\w\d]+\s*=\s*)?(["\x{27}])([^\3]+?)\3.*/- $1:$4/; 16 | 17 | 18 | uuid 19 | 0AE8C5E0-C202-4965-B877-4CD0B9420A7D 20 | 21 | 22 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/load-library-using-library.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | echo -en 'library(${1:"${2:`"$TM_BUNDLE_SUPPORT"/bin/insert_package_name.sh`}"})${0:}' 9 | input 10 | none 11 | name 12 | Load Library using “library” 13 | output 14 | insertAsSnippet 15 | scope 16 | source.r, source.rd.console 17 | tabTrigger 18 | lib 19 | uuid 20 | 2EBC36A2-A927-4AEC-99A1-9F06C88B6844 21 | 22 | 23 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/load-library-using-require.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | echo -en 'require(${1:"${2:`"$TM_BUNDLE_SUPPORT"/bin/insert_package_name.sh`}"})${0:}' 9 | input 10 | none 11 | name 12 | Load Library using “require” 13 | output 14 | insertAsSnippet 15 | scope 16 | source.r, source.rd.console 17 | tabTrigger 18 | req 19 | uuid 20 | C2ADF348-D6FE-45B5-8BCC-A62B912A881B 21 | 22 | 23 | -------------------------------------------------------------------------------- /templates/package-javascript/lib/__package-name__-view.js.template: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | export default class __PackageName__View { 4 | 5 | constructor(serializedState) { 6 | // Create root element 7 | this.element = document.createElement('div'); 8 | this.element.classList.add('__package-name__'); 9 | 10 | // Create message element 11 | const message = document.createElement('div'); 12 | message.textContent = 'The __PackageName__ package is Alive! It\'s ALIVE!'; 13 | message.classList.add('message'); 14 | this.element.appendChild(message); 15 | } 16 | 17 | // Returns an object that can be retrieved when package is activated 18 | serialize() {} 19 | 20 | // Tear down any state and detach 21 | destroy() { 22 | this.element.remove(); 23 | } 24 | 25 | getElement() { 26 | return this.element; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /bin/apm.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal enabledelayedexpansion 3 | 4 | :: Try to find git.exe in path 5 | for /f "tokens=*" %%G in ('where git') do set "apm_git_path=%%~dpG" 6 | if not defined apm_git_path ( 7 | :: Try to find git.exe in GitHub Desktop, oldest first so we end with newest 8 | for /f "tokens=*" %%d in ('dir /b /s /a:d /od "%LOCALAPPDATA%\GitHub\PortableGit*"') do ( 9 | if exist %%d\cmd\git.exe set apm_git_path=%%d\cmd 10 | ) 11 | :: Found one, add it to the path 12 | if defined apm_git_path set "Path=!apm_git_path!;%PATH%" 13 | ) 14 | 15 | set maybe_node_gyp_path=%~dp0\..\node_modules\node-gyp\bin\node-gyp.js 16 | if exist %maybe_node_gyp_path% ( 17 | set npm_config_node_gyp=%maybe_node_gyp_path% 18 | ) 19 | 20 | if exist "%~dp0\node.exe" ( 21 | "%~dp0\node.exe" "%~dp0/../lib/cli.js" %* 22 | ) else ( 23 | node.exe "%~dp0/../lib/cli.js" %* 24 | ) 25 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Edit user-defined Function Parameter.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | WDIR="$HOME/Library/Application Support/TextMate/R/help/command_args" 9 | 10 | "$TM_BUNDLE_SUPPORT"/bin/initCommandArgsDir.sh 11 | 12 | mate "$WDIR" 13 | input 14 | none 15 | name 16 | Edit user-defined Function Parameter 17 | output 18 | showAsTooltip 19 | scope 20 | source.r, source.rd.console 21 | uuid 22 | BED22435-E025-4C52-9CC5-08B4296F524F 23 | 24 | 25 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/README.mdown: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | You can install this bundle in TextMate by opening the preferences and going to the bundles tab. After installation it will be automatically updated for you. 4 | 5 | # General 6 | 7 | * [Bundle Styleguide](http://kb.textmate.org/bundle_styleguide) — _before you make changes_ 8 | * [Commit Styleguide](http://kb.textmate.org/commit_styleguide) — _before you send a pull request_ 9 | * [Writing Bug Reports](http://kb.textmate.org/writing_bug_reports) — _before you report an issue_ 10 | 11 | # License 12 | 13 | If not otherwise specified (see below), files in this repository fall under the following license: 14 | 15 | Permission to copy, use, modify, sell and distribute this 16 | software is granted. This software is provided "as is" without 17 | express or implied warranty, and with no claim as to its 18 | suitability for any purpose. 19 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Prefix Package Name current Function.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | "$TM_BUNDLE_SUPPORT"/bin/prefix_package_name.sh 9 | fallbackInput 10 | line 11 | input 12 | selection 13 | keyEquivalent 14 | ^~L 15 | name 16 | Prefix Package Name to current Function 17 | output 18 | insertAsSnippet 19 | scope 20 | source.r, source.rd.console 21 | uuid 22 | 7657BD74-1736-49B9-9AB1-4A10E256D484 23 | 24 | 25 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/arrow-left.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | FLAG=$(echo -en "$TM_CURRENT_LINE" | perl -e '$_=<>;m/.*?( $)/;print 1 if defined($1)') 9 | if [ -z "$FLAG" ]; then 10 | echo -n " <- " 11 | else 12 | echo -n "<- " 13 | fi 14 | input 15 | none 16 | keyEquivalent 17 | ^- 18 | name 19 | “ <- ” 20 | output 21 | afterSelectedText 22 | scope 23 | source.r, source.rd.console 24 | uuid 25 | 06BD4251-25D5-4BA0-99BC-5D3061E64128 26 | 27 | 28 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Insert Result.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | if [ -z "$TM_SELECTED_TEXT" ]; then 9 | echo 10 | cat | R --vanilla --slave --no-readline --encoding=UTF-8 11 | else 12 | cat | R --vanilla --slave --no-readline --encoding=UTF-8 13 | exit_replace_text 14 | fi 15 | input 16 | selection 17 | keyEquivalent 18 | ^@r 19 | name 20 | Insert Result 21 | output 22 | afterSelectedText 23 | scope 24 | source.r 25 | uuid 26 | 99E59A8E-A7DC-4CB0-AA51-6305921D3411 27 | 28 | 29 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/startRhelperDaemon.sh: -------------------------------------------------------------------------------- 1 | RPID=$(ps aw | grep '[0-9] /.*TMRHelperDaemon' | awk '{print $1}' ) 2 | #check whether Helper daemon runs if not start it 3 | if [ -z "$RPID" ]; then 4 | WDIR="$TM_BUNDLE_SUPPORT"/bin 5 | PIPE="/tmp/textmate_Rhelper_in" 6 | OUT="/tmp/textmate_Rhelper_console" 7 | cd "$WDIR" 8 | if [ ! -e "$PIPE" ]; then 9 | mkfifo "$PIPE" 10 | else 11 | if [ ! -p "$PIPE" ]; then 12 | rm "$PIPE" 13 | mkfifo "$PIPE" 14 | fi 15 | fi 16 | /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby RhelperDaemon.rb &> /dev/null & 17 | SAFECNT=0 18 | while [ 1 ] 19 | do 20 | SAFECNT=$(($SAFECNT+1)) 21 | if [ $SAFECNT -gt 5000 ]; then 22 | echo -en "Start failed! No response from R Helper server!" 23 | exit 206 24 | fi 25 | RES=$(tail -c 2 "$OUT") 26 | [[ "$RES" == "> " ]] && break 27 | sleep 0.03 28 | done 29 | sleep 0.3 30 | cat "" > /tmp/textmate_Rhelper_data.html 31 | fi 32 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/parseDocForFunctions.sh: -------------------------------------------------------------------------------- 1 | 2 | USE=$(cat | egrep -A 10 "\b${1//./\\.}\b *<\-[ ]*\bfunction\b[ ]*\(" | perl -e ' 3 | undef($/); 4 | $a=<>; 5 | $a=~s/.*?<\-\s*\bfunction\b\s*(\(.*?\))\s*[\t\n\{\w].*/$1/gms; 6 | $a=~s/"\n"/"\\n"/g; 7 | $a=~s/\x27\n\x27/\x27\\n\x27/g; 8 | $a=~s/[\n\t]/ /g; 9 | $a=~s/ {2,}/ /g; 10 | $a=~s/^\(\s*/(/g; 11 | $a=~s/\s*\)$/)/g; 12 | $a=~s/\s*=\s*/ = /g; 13 | $a=~s/\s*,\s*/, /g; 14 | print $a 15 | ') 16 | 17 | # If Rhelper doesn't work, use the following line only 18 | # echo $USE | fmt | perl -e 'undef($/);$a=<>;$a=~s/\n/\n\t/g;$a=~s/\n\t$//;print $a' 19 | if [ ! -z "$USE" ]; then 20 | "$TM_BUNDLE_SUPPORT"/bin/askRhelperDaemon.sh "TM_Rdaemona<-function $USE {};args(TM_Rdaemona)" 21 | # sleep 0.01 22 | OUT=$(cat /tmp/textmate_Rhelper_out | sed '$d' | perl -pe 's/^function //;s/"\n"/"\\n"/g;s/"\t"/"\\t"/g') 23 | if [ -z "$OUT" -a ! -z "$USE" ]; then 24 | echo " declaration possibly erroneous: 25 | $USE" 26 | else 27 | echo -n "$OUT" 28 | fi 29 | fi -------------------------------------------------------------------------------- /script/check-version.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var path = require('path'); 4 | 5 | var getBundledNodeVersion = require('./bundled-node-version') 6 | 7 | var bundledNodePath = path.join(__dirname, '..', 'bin', 'node') 8 | if (process.platform === 'win32') { 9 | bundledNodePath += '.exe' 10 | } 11 | 12 | getBundledNodeVersion(bundledNodePath, function(err, bundledVersion) { 13 | if (err) { 14 | console.error(err); 15 | process.exit(1); 16 | } 17 | 18 | var ourVersion = process.version 19 | 20 | if (ourVersion !== bundledVersion) { 21 | console.error('System node (' + ourVersion + ') does not match bundled node (' + bundledVersion + ').'); 22 | if (process.platform === 'win32') { 23 | console.error('Please use `.\\bin\\node.exe` to run node, and use `.\\bin\\npm.cmd` to run npm scripts.') 24 | } else { 25 | console.error('Please use `./bin/node` to run node, and use `./bin/npm` to run npm scripts.') 26 | } 27 | process.exit(1) 28 | } else { 29 | process.exit(0) 30 | } 31 | }); 32 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/askRhelperDaemon.sh: -------------------------------------------------------------------------------- 1 | 2 | #dispose all frozen ProgressDialogs first 3 | { 4 | while [ 1 ] 5 | do 6 | res=$("$DIALOG" -x `"$DIALOG" -l 2>/dev/null| grep Rdaemon | cut -d " " -f 1` 2>/dev/null) 7 | [[ ${#res} -eq 0 ]] && break 8 | done 9 | } & 10 | 11 | 12 | "$TM_BUNDLE_SUPPORT"/bin/startRhelperDaemon.sh &> /dev/null 13 | echo "$1" > /tmp/textmate_Rhelper_in 14 | sleep 0.01 15 | SAFECNT=0 16 | while [ 1 ] 17 | do 18 | SAFECNT=$(($SAFECNT+1)) 19 | if [ $SAFECNT -gt 5000 ]; then 20 | echo -en "No RESULT from R Helper server!" 21 | exit 206 22 | fi 23 | RES=$(tail -c 2 /tmp/textmate_Rhelper_console) 24 | [[ "$RES" == "> " ]] && break 25 | sleep 0.01 26 | done 27 | if [ -e /tmp/textmate_Rhelper_status ]; then 28 | SAFECNT=0 29 | sleep 0.001 30 | while [ `cat /tmp/textmate_Rhelper_status` != "READY" ] 31 | do 32 | SAFECNT=$(($SAFECNT+1)) 33 | if [ $SAFECNT -gt 1000 ]; then 34 | echo -en "No RESULT from R Helper server!" 35 | exit 206 36 | fi 37 | sleep 0.01 38 | done 39 | fi 40 | 41 | 42 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/CRAN Packages.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | CRAN="http://cran.cnr.berkeley.edu" 9 | SOFILE="$HOME/Library/Application Support/Rdaemon/startOptions.R" 10 | if [ -f "$SOFILE" ]; then 11 | RES=$(cat "$SOFILE" | egrep 'options.*?repos.*?list' | perl -pe 's/^\s*options\s*.*?repos\s*=\s*.*?[\x{27}"](.*?)[\x{27}"].*/$1/g' | tail -n 1) 12 | [[ ! -z "$RES" ]] && [[ "${RES:0:4}" == "http" ]] && CRAN="$RES" 13 | fi 14 | open "$CRAN/web/packages/" 15 | input 16 | none 17 | name 18 | CRAN Packages 19 | output 20 | showAsTooltip 21 | scope 22 | source.r 23 | uuid 24 | 2A3C3EF9-2043-4304-81EC-EA3309286F98 25 | 26 | 27 | -------------------------------------------------------------------------------- /spec/fixtures/search.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "duckberg", 4 | "releases": { 5 | "latest": "1.0" 6 | }, 7 | "metadata": { 8 | "name": "duckberg", 9 | "version": "1.0", 10 | "description": "Life is like a hurricane" 11 | } 12 | }, 13 | { 14 | "name": "ducktales", 15 | "releases": { 16 | "latest": "2.0" 17 | }, 18 | "metadata": { 19 | "name": "ducktales", 20 | "version": "2.0", 21 | "description": "Might solve a mystery or rewrite history" 22 | } 23 | }, 24 | { 25 | "name": "duckblur", 26 | "releases": { 27 | "latest": "19.92" 28 | }, 29 | "metadata": { 30 | "name": "duckblur", 31 | "version": "19.92", 32 | "theme": true, 33 | "description": "Racecars, lasers, airplanes" 34 | } 35 | }, 36 | { 37 | "name": "atom-2048", 38 | "releases": { 39 | "latest": "1.2.3" 40 | }, 41 | "metadata": { 42 | "name": "atom-2048", 43 | "version": "1.2.3", 44 | "description": "Racecars, lasers, airplanes" 45 | } 46 | } 47 | ] 48 | -------------------------------------------------------------------------------- /templates/theme/styles/syntax-variables.less: -------------------------------------------------------------------------------- 1 | @import "colors"; 2 | 3 | // This defines all syntax variables that syntax themes must implement when they 4 | // include a syntax-variables.less file. 5 | 6 | // General colors 7 | @syntax-text-color: @very-light-gray; 8 | @syntax-cursor-color: white; 9 | @syntax-selection-color: lighten(@dark-gray, 10%); 10 | @syntax-background-color: @very-dark-gray; 11 | 12 | // Guide colors 13 | @syntax-wrap-guide-color: @dark-gray; 14 | @syntax-indent-guide-color: @gray; 15 | @syntax-invisible-character-color: @gray; 16 | 17 | // For find and replace markers 18 | @syntax-result-marker-color: @light-gray; 19 | @syntax-result-marker-color-selected: white; 20 | 21 | // Gutter colors 22 | @syntax-gutter-text-color: @very-light-gray; 23 | @syntax-gutter-text-color-selected: @syntax-gutter-text-color; 24 | @syntax-gutter-background-color: @dark-gray; 25 | @syntax-gutter-background-color-selected: @gray; 26 | 27 | // For git diff info. i.e. in the gutter 28 | @syntax-color-renamed: @blue; 29 | @syntax-color-added: @green; 30 | @syntax-color-modified: @orange; 31 | @syntax-color-removed: @red; 32 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 GitHub Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /src/auth.coffee: -------------------------------------------------------------------------------- 1 | try 2 | keytar = require 'keytar' 3 | catch error 4 | # Gracefully handle keytar failing to load due to missing library on Linux 5 | if process.platform is 'linux' 6 | keytar = 7 | findPassword: -> 8 | replacePassword: -> 9 | else 10 | throw error 11 | 12 | tokenName = 'Atom.io API Token' 13 | 14 | module.exports = 15 | # Get the Atom.io API token from the keychain. 16 | # 17 | # callback - A function to call with an error as the first argument and a 18 | # string token as the second argument. 19 | getToken: (callback) -> 20 | if token = keytar.findPassword(tokenName) 21 | callback(null, token) 22 | return 23 | 24 | if token = process.env.ATOM_ACCESS_TOKEN 25 | callback(null, token) 26 | return 27 | 28 | callback """ 29 | No Atom.io API token in keychain 30 | Run `apm login` or set the `ATOM_ACCESS_TOKEN` environment variable. 31 | """ 32 | 33 | # Save the given token to the keychain. 34 | # 35 | # token - A string token to save. 36 | saveToken: (token) -> 37 | keytar.replacePassword(tokenName, 'atom.io', token) 38 | -------------------------------------------------------------------------------- /templates/theme/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /templates/language/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /templates/package-coffeescript/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /templates/package-javascript/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Show R Documentation.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | 9 | 10 | "$TM_BUNDLE_SUPPORT"/bin/askRhelperDaemon.sh "@getHttpPort()" 11 | sleep 0.05 12 | PORT=$(cat /tmp/textmate_Rhelper_out) 13 | 14 | 15 | if [ $PORT -gt 0 ]; then 16 | echo "<base href='http://127.0.0.1:$PORT/doc/html/index.html'>" 17 | curl -sS "http://127.0.0.1:$PORT/doc/html/index.html" 18 | 19 | else 20 | RHOME=${R_HOME:=/Library/Frameworks/R.framework/Versions/Current/Resources} 21 | echo "<base href='file://${RHOME// /%20}/doc/html/index.html'>" 22 | cat "${RHOME// /%20}"/doc/html/index.html 23 | 24 | fi 25 | input 26 | none 27 | name 28 | Show R Documentation 29 | output 30 | showAsHTML 31 | scope 32 | source.r 33 | uuid 34 | F6F4215A-5543-42B3-8EBD-C8C7C9F190C9 35 | 36 | 37 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Summaries….tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 9 | # print "Got:" + STDIN.read 10 | 11 | require ENV['TM_SUPPORT_PATH'] +'/lib/ui.rb' 12 | require ENV['TM_SUPPORT_PATH'] +'/lib/exit_codes.rb' 13 | opts = { "Summary" => "summary(${1:x})", 14 | "Table" => "table(${1:x})"} 15 | keys = opts.keys.sort 16 | ans = TextMate::UI.menu(keys) 17 | TextMate.exit_discard unless ans 18 | print opts[keys[ans]] 19 | fallbackInput 20 | word 21 | input 22 | none 23 | keyEquivalent 24 | ~@S 25 | name 26 | Summaries… 27 | output 28 | insertAsSnippet 29 | scope 30 | source.r, source.rd.console 31 | uuid 32 | 6A931F29-5A2B-4CCB-A958-0A0A9A3F2BEF 33 | 34 | 35 | -------------------------------------------------------------------------------- /templates/package-coffeescript/lib/__package-name__.coffee.template: -------------------------------------------------------------------------------- 1 | __PackageName__View = require './__package-name__-view' 2 | {CompositeDisposable} = require 'atom' 3 | 4 | module.exports = __PackageName__ = 5 | __packageName__View: null 6 | modalPanel: null 7 | subscriptions: null 8 | 9 | activate: (state) -> 10 | @__packageName__View = new __PackageName__View(state.__packageName__ViewState) 11 | @modalPanel = atom.workspace.addModalPanel(item: @__packageName__View.getElement(), visible: false) 12 | 13 | # Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable 14 | @subscriptions = new CompositeDisposable 15 | 16 | # Register command that toggles this view 17 | @subscriptions.add atom.commands.add 'atom-workspace', '__package-name__:toggle': => @toggle() 18 | 19 | deactivate: -> 20 | @modalPanel.destroy() 21 | @subscriptions.dispose() 22 | @__packageName__View.destroy() 23 | 24 | serialize: -> 25 | __packageName__ViewState: @__packageName__View.serialize() 26 | 27 | toggle: -> 28 | console.log '__PackageName__ was toggled!' 29 | 30 | if @modalPanel.isVisible() 31 | @modalPanel.hide() 32 | else 33 | @modalPanel.show() 34 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/DragCommands/load.tmDragCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | bundleUUID 8 | B29D7850-6E70-11D9-A369-000D93B3A10E 9 | command 10 | 11 | if [ "${TM_SCOPE:0:17}" == "source.rd.console" ]; then 12 | echo -n "load(\"$TM_DROPPED_FILEPATH\")" 13 | else 14 | if [ "$TM_MODIFIER_FLAGS" == "SHIFT" ]; then 15 | echo "load(\"$TM_DROPPED_FILEPATH\")" 16 | else 17 | echo "load(\"$TM_DROPPED_FILE\")" 18 | fi 19 | fi 20 | draggedFileExtensions 21 | 22 | rdata 23 | Rdata 24 | rda 25 | Rda 26 | 27 | input 28 | selection 29 | name 30 | load (*.Rdata) 31 | output 32 | insertAsSnippet 33 | scope 34 | source.r, source.rd.console 35 | uuid 36 | BC3C944A-A0D9-4438-A9CF-C813970DD533 37 | 38 | 39 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Rd Insert arguments tag.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -wKU 9 | 10 | rd=STDIN.read() 11 | if rd =~ /(?m).*?\\usage\{.*?\((.*?)\).*/m 12 | rd.gsub!(/(?m).*?\\usage\{.*?\((.*?)\).*/m, '\1') 13 | puts "\\arguments{" 14 | counter=1 15 | rd.scan(/([\w\._]+)\s*=/) do |arg| 16 | puts "\t\\item{#{arg}}{${#{counter}:}}" 17 | counter = counter+1 18 | end 19 | puts "}" 20 | else 21 | puts "\\arguments{" 22 | puts "\t\\item{${1:}}{${2:}}${0:}" 23 | puts "}" 24 | end 25 | 26 | input 27 | document 28 | name 29 | Rd Insert arguments tag 30 | output 31 | insertAsSnippet 32 | scope 33 | text.tex.latex.rd 34 | tabTrigger 35 | arg 36 | uuid 37 | EB595EE3-9439-4AC6-8352-1EC7CAC9B05E 38 | 39 | 40 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Macros/next-list-element.tmMacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | commands 6 | 7 | 8 | argument 9 | 10 | action 11 | findNext 12 | findInProjectIgnoreCase 13 | 14 | findString 15 | (?<=[ ,\(=\"'])-?[^\"', \)\(=\n\t]+(?=([\"']?| *|\" *|' *)[,\)])|(?<=[\"'])(?=[\"']) 16 | ignoreCase 17 | 18 | regularExpression 19 | 20 | replaceAllScope 21 | document 22 | wrapAround 23 | 24 | 25 | command 26 | findWithOptions: 27 | 28 | 29 | keyEquivalent 30 | ^~ 31 | name 32 | Next List Element/Parameter Value 33 | scope 34 | source.r, source.rd.console 35 | uuid 36 | C28E338D-7E5F-4E3C-9603-70C22912166D 37 | 38 | 39 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/DragCommands/source.tmDragCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | bundleUUID 8 | B29D7850-6E70-11D9-A369-000D93B3A10E 9 | command 10 | 11 | if [ "${TM_SCOPE:0:17}" == "source.rd.console" ]; then 12 | echo -n "source(\"$TM_DROPPED_FILEPATH\", chdir = \${1:TRUE})" 13 | else 14 | if [ "$TM_MODIFIER_FLAGS" == "SHIFT" ]; then 15 | echo "source(\"$TM_DROPPED_FILEPATH\", chdir = \${1:TRUE})" 16 | else 17 | echo "source(\"$TM_DROPPED_FILE\", chdir = \${1:TRUE})" 18 | fi 19 | fi 20 | draggedFileExtensions 21 | 22 | r 23 | R 24 | 25 | input 26 | selection 27 | name 28 | source (*.R) 29 | output 30 | insertAsSnippet 31 | scope 32 | source.r, source.rd.console 33 | uuid 34 | 7AA6473C-4B13-4252-8773-9B08675048FB 35 | 36 | 37 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Macros/previous-list-element.tmMacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | commands 6 | 7 | 8 | argument 9 | 10 | action 11 | findPrevious 12 | findInProjectIgnoreCase 13 | 14 | findString 15 | (?<=[ ,\(=\"'])-?[^\"', \)\(=\n\t]+(?=([\"']?| *|\" *|' *)[,\)])|(?<=[\"'])(?=[\"']) 16 | ignoreCase 17 | 18 | regularExpression 19 | 20 | replaceAllScope 21 | document 22 | wrapAround 23 | 24 | 25 | command 26 | findWithOptions: 27 | 28 | 29 | keyEquivalent 30 | ^~ 31 | name 32 | Previous List Element/Parameter Value 33 | scope 34 | source.r, source.rd.console 35 | uuid 36 | C4BEAEEF-970A-40DC-B511-5C4B2C0AB43E 37 | 38 | 39 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Help.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | 9 | # clean unused file 10 | rm -f "$TM_BUNDLE_SUPPORT/help.index" 11 | rm -f "$TM_BUNDLE_SUPPORT/helpshort.index" 12 | rm -f "$TM_BUNDLE_SUPPORT/help.pkgs" 13 | rm -f "$TM_BUNDLE_SUPPORT/libpaths" 14 | rm -f "$TM_BUNDLE_SUPPORT/httpPort" 15 | rm -f "$TM_BUNDLE_SUPPORT/isHelpServer" 16 | rm -f "$TM_BUNDLE_SUPPORT/lib/data.html" 17 | rm -f "$TM_BUNDLE_SUPPORT/lib/head.html" 18 | rm -f "$TM_BUNDLE_SUPPORT/lib/search.html" 19 | 20 | . "$TM_SUPPORT_PATH/lib/webpreview.sh" 21 | html_header "R Bundle Help" "R" 22 | "$TM_SUPPORT_PATH/lib/markdown_to_help.rb" "$TM_BUNDLE_SUPPORT/lib/help.markdown" 23 | html_footer 24 | 25 | input 26 | none 27 | name 28 | Help 29 | output 30 | showAsHTML 31 | scope 32 | source.r -source.rd.console -source.rapp-console 33 | uuid 34 | 8A8B6803-AF20-47EC-9382-62E1EBA76B4A 35 | 36 | 37 | -------------------------------------------------------------------------------- /Gruntfile.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (grunt) -> 2 | grunt.initConfig 3 | pkg: grunt.file.readJSON('package.json') 4 | 5 | coffee: 6 | glob_to_multiple: 7 | expand: true 8 | cwd: 'src' 9 | src: ['**/*.coffee'] 10 | dest: 'lib' 11 | ext: '.js' 12 | 13 | coffeelint: 14 | options: 15 | configFile: 'coffeelint.json' 16 | src: ['src/**/*.coffee'] 17 | test: ['spec/*.coffee'] 18 | gruntfile: ['Gruntfile.coffee'] 19 | 20 | shell: 21 | test: 22 | command: 'node node_modules/jasmine-focused/bin/jasmine-focused --captureExceptions --coffee spec' 23 | options: 24 | stdout: true 25 | stderr: true 26 | failOnError: true 27 | 28 | grunt.loadNpmTasks('grunt-contrib-coffee') 29 | grunt.loadNpmTasks('grunt-shell') 30 | grunt.loadNpmTasks('grunt-coffeelint') 31 | 32 | grunt.registerTask 'clean', -> 33 | grunt.file.delete('lib') if grunt.file.exists('lib') 34 | grunt.file.delete('bin/node_darwin_x64') if grunt.file.exists('bin/node_darwin_x64') 35 | 36 | grunt.registerTask('lint', ['coffeelint']) 37 | grunt.registerTask('default', ['coffee', 'lint']) 38 | grunt.registerTask('test', ['clean', 'default', 'shell:test']) 39 | grunt.registerTask('prepublish', ['clean', 'coffee', 'lint']) 40 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Terminate Helper Daemon.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | RPID=$(ps aw | grep '[0-9] /.*TMRHelperDaemon' | awk '{print $1}' ) 9 | if [ ! -z $RPID ]; then 10 | out=$(kill $RPID) 11 | if [ -z "$out" ]; then 12 | rm -f /tmp/textmate_Rhelper_console 13 | rm -f /tmp/textmate_Rhelper_data.html 14 | rm -f /tmp/textmate_Rhelper_head.html 15 | rm -f /tmp/textmate_Rhelper_in 16 | rm -f /tmp/textmate_Rhelper_out 17 | rm -f /tmp/textmate_Rhelper_search.html 18 | rm -f /tmp/textmate_Rhelper_status 19 | echo "Helper Daemon was terminated." 20 | else 21 | echo "Error while terminating Helper Daemon running as PID $RPID." 22 | fi 23 | else 24 | echo "No Helper Daemon found." 25 | fi 26 | input 27 | none 28 | name 29 | Terminate Helper Daemon 30 | output 31 | showAsTooltip 32 | scope 33 | source.r, source.rd.console 34 | uuid 35 | 90C73568-B9B1-4D3D-BAC5-5C2999BE39BC 36 | 37 | 38 | -------------------------------------------------------------------------------- /spec/fixtures/wrap-guide.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wrap-guide", 3 | "repository": { 4 | "type": "git", 5 | "url": "https://github.com/atom/wrap-guide" 6 | }, 7 | "releases": { 8 | "latest": "0.14.0" 9 | }, 10 | "readme": "# Wrap guide package\n\nDon't cross the line.\n", 11 | "metadata": { 12 | "name": "wrap-guide", 13 | "version": "0.14.0", 14 | "main": "./lib/wrap-guide-view", 15 | "description": "Display a vertical line at the 80th character in the editor.\n\nThis packages uses the config value of `editor.preferredLineLength` when set.", 16 | "repository": "https://github.com/atom/wrap-guide", 17 | "engines": { 18 | "atom": "*" 19 | } 20 | }, 21 | "versions": { 22 | "0.14.0": { 23 | "name": "wrap-guide", 24 | "version": "0.14.0", 25 | "main": "./lib/wrap-guide-view", 26 | "description": "new version", 27 | "repository": "https://github.com/atom/wrap-guide", 28 | "engines": { 29 | "atom": ">=2.0" 30 | } 31 | }, 32 | "0.3.0": { 33 | "name": "wrap-guide", 34 | "version": "0.3.0", 35 | "main": "./lib/wrap-guide-view", 36 | "description": "old version", 37 | "repository": "https://github.com/atom2/wrap-guide", 38 | "engines": { 39 | "atom": ">=1.0" 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/historyList.rb: -------------------------------------------------------------------------------- 1 | def extract_command(string) 2 | return "" if string.nil? 3 | return string.gsub(/^>\s*|\s*\z/,"") 4 | end 5 | class HistoryList 6 | attr_reader :list, :last_line, :text 7 | def initialize(text) 8 | @text = text.split("\n") 9 | @last_line = @text.pop 10 | @list = @text.grep(/^>(.*)$/).map{|m| extract_command(m)}.grep(/./) 11 | @list = @list.reverse.uniq.reverse 12 | end 13 | def next_item(command) 14 | cmd = extract_command(command) 15 | return @list[0] if cmd.empty? 16 | if i=@list.index(cmd) and i<=@list.length then 17 | return @list[i+1] 18 | end 19 | return nil 20 | end 21 | def previous_item(command) 22 | cmd = extract_command(command) 23 | return @list.last if cmd.empty? 24 | if i=@list.index(cmd) and i>=1 then 25 | return @list[i-1] 26 | end 27 | return nil 28 | end 29 | def text 30 | @text.join("\n") + "\n" 31 | end 32 | def add_line(line) 33 | self.text + "> #{extract_command(line)}" 34 | end 35 | def move_up 36 | add_line(previous_item(@last_line)) 37 | end 38 | def move_down 39 | add_line(next_item(@last_line)) 40 | end 41 | def self.move_up(text) 42 | self.new(text).move_up 43 | end 44 | def self.move_down(text) 45 | self.new(text).move_down 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Macros/function-params.tmMacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | commands 6 | 7 | 8 | argument 9 | 10 | beforeRunningCommand 11 | nop 12 | command 13 | "$TM_BUNDLE_SUPPORT"/bin/insert_function_param.sh 14 | fallbackInput 15 | none 16 | input 17 | document 18 | name 19 | Function Parameters… 20 | output 21 | insertAsSnippet 22 | scope 23 | source.r -source.rd.console 24 | uuid 25 | D977E5CA-C8BD-414E-AF8B-98279DF571DC 26 | 27 | command 28 | executeCommandWithOptions: 29 | 30 | 31 | keyEquivalent 32 | ^, 33 | name 34 | Function Parameters… 35 | scope 36 | source.r, source.rd.console 37 | uuid 38 | E16BBBCF-CDD5-49DB-9626-1125A97C4D89 39 | 40 | 41 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/DragCommands/read_csv.tmDragCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | bundleUUID 8 | B29D7850-6E70-11D9-A369-000D93B3A10E 9 | command 10 | 11 | if [ "${TM_SCOPE:0:17}" == "source.rd.console" ]; then 12 | echo -n "read.csv(file = \"$TM_DROPPED_FILEPATH\", header = \${1:TRUE}, stringsAsFactors = \${2:FALSE})" 13 | else 14 | if [ "$TM_MODIFIER_FLAGS" == "SHIFT" ]; then 15 | echo "read.csv(file = \"$TM_DROPPED_FILEPATH\", header = \${1:TRUE}, stringsAsFactors = \${2:FALSE})" 16 | else 17 | echo "read.csv(file = \"$TM_DROPPED_FILE\", header = \${1:TRUE}, stringsAsFactors = \${2:FALSE})" 18 | fi 19 | fi 20 | draggedFileExtensions 21 | 22 | csv 23 | CSV 24 | 25 | input 26 | selection 27 | name 28 | read.csv (*.csv) 29 | output 30 | insertAsSnippet 31 | scope 32 | source.r, source.rd.console 33 | uuid 34 | FF242DDB-CDE9-4FC0-8AC7-3345E49FBACA 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/docs.coffee: -------------------------------------------------------------------------------- 1 | yargs = require 'yargs' 2 | open = require 'open' 3 | 4 | View = require './view' 5 | config = require './apm' 6 | 7 | module.exports = 8 | class Docs extends View 9 | @commandNames: ['docs', 'home', 'open'] 10 | 11 | parseOptions: (argv) -> 12 | options = yargs(argv).wrap(100) 13 | options.usage """ 14 | 15 | Usage: apm docs [options] 16 | 17 | Open a package's homepage in the default browser. 18 | """ 19 | options.alias('h', 'help').describe('help', 'Print this usage message') 20 | options.boolean('p').alias('p', 'print').describe('print', 'Print the URL instead of opening it') 21 | 22 | openRepositoryUrl: (repositoryUrl) -> 23 | open(repositoryUrl) 24 | 25 | run: (options) -> 26 | {callback} = options 27 | options = @parseOptions(options.commandArgs) 28 | [packageName] = options.argv._ 29 | 30 | unless packageName 31 | callback("Missing required package name") 32 | return 33 | 34 | @getPackage packageName, options, (error, pack) => 35 | return callback(error) if error? 36 | 37 | if repository = @getRepository(pack) 38 | if options.argv.print 39 | console.log repository 40 | else 41 | @openRepositoryUrl(repository) 42 | callback() 43 | else 44 | callback("Package \"#{packageName}\" does not contain a repository URL") 45 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/command_args/getOption: -------------------------------------------------------------------------------- 1 | "add.smooth" 2 | "check.bounds" 3 | "continue" 4 | "defaultPackages" 5 | "deparse.max.lines" 6 | "digits" 7 | "digits.secs" 8 | "download.file.method" 9 | "echo" 10 | "encoding" 11 | "error" 12 | "expressions25...500000" 13 | "keep.source" 14 | "keep.source.pkgs" 15 | "mailer" 16 | "max.contour.segments" 17 | "max.print" 18 | "OutDec" 19 | "pager" 20 | "papersize" 21 | "printcmd" 22 | "prompt" 23 | "rl_word_breaks" 24 | "save.defaults" 25 | "save.image.defaults" 26 | "scipen" 27 | "showErrorCalls" 28 | "showWarnCalls" 29 | "showNCalls" 30 | "show.error.messages" 31 | "stringsAsFactors" 32 | "texi2dvi" 33 | "timeout" 34 | "topLevelEnvironment" 35 | "useFancyQuotes" 36 | "verbose" 37 | "warn" 38 | "warnPartialMatchArgs" 39 | "warnPartialMatchAttr" 40 | "warnPartialMatchDollar" 41 | "warning.expression" 42 | "warnings.length" 43 | "width" 44 | - 45 | "device" 46 | "locatorBell" 47 | "par.ask.default" 48 | "X11colortype" 49 | "X11fonts" 50 | "gamma" 51 | - 52 | "contrasts" 53 | "na.action" 54 | "show.coef.Pvalues" 55 | "show.signif.stars" 56 | "ts.eps" 57 | "ts.S.compat" 58 | - 59 | "browser" 60 | "de.cellwidth" 61 | "editor" 62 | "example.ask" 63 | "help.try.all.packages" 64 | "HTTPUserAgent" 65 | "internet.info" 66 | "menu.graphics" 67 | "pkgType" 68 | "repos" 69 | "SweaveHooks" 70 | "SweaveSyntax" 71 | "unzip" 72 | "- 73 | "dvipscmd" 74 | "latexcmd" 75 | "pdfviewer" -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Macros/show-function-usage.tmMacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | commands 6 | 7 | 8 | argument 9 | 10 | beforeRunningCommand 11 | nop 12 | command 13 | "$TM_BUNDLE_SUPPORT"/bin/auto_show_func_usage.sh & 14 | fallbackInput 15 | line 16 | input 17 | document 18 | name 19 | Auto Show Func Usage 20 | output 21 | showAsTooltip 22 | uuid 23 | 9AACF8E0-2705-4994-B67F-77D030F9ABA7 24 | 25 | command 26 | executeCommandWithOptions: 27 | 28 | 29 | argument 30 | ( 31 | command 32 | insertText: 33 | 34 | 35 | isDisabled 36 | 37 | keyEquivalent 38 | ( 39 | name 40 | Show Function Usage + Insert “(” 41 | scope 42 | source.r, source.rd.console 43 | uuid 44 | 280CC3F2-8A69-446D-89A2-2886D3DF9495 45 | 46 | 47 | -------------------------------------------------------------------------------- /templates/package-javascript/lib/__package-name__.js.template: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import __PackageName__View from './__package-name__-view'; 4 | import { CompositeDisposable } from 'atom'; 5 | 6 | export default { 7 | 8 | __packageName__View: null, 9 | modalPanel: null, 10 | subscriptions: null, 11 | 12 | activate(state) { 13 | this.__packageName__View = new __PackageName__View(state.__packageName__ViewState); 14 | this.modalPanel = atom.workspace.addModalPanel({ 15 | item: this.__packageName__View.getElement(), 16 | visible: false 17 | }); 18 | 19 | // Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable 20 | this.subscriptions = new CompositeDisposable(); 21 | 22 | // Register command that toggles this view 23 | this.subscriptions.add(atom.commands.add('atom-workspace', { 24 | '__package-name__:toggle': () => this.toggle() 25 | })); 26 | }, 27 | 28 | deactivate() { 29 | this.modalPanel.destroy(); 30 | this.subscriptions.dispose(); 31 | this.__packageName__View.destroy(); 32 | }, 33 | 34 | serialize() { 35 | return { 36 | __packageName__ViewState: this.__packageName__View.serialize() 37 | }; 38 | }, 39 | 40 | toggle() { 41 | console.log('__PackageName__ was toggled!'); 42 | return ( 43 | this.modalPanel.isVisible() ? 44 | this.modalPanel.hide() : 45 | this.modalPanel.show() 46 | ); 47 | } 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Plots….tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 9 | # print "Got:" + STDIN.read 10 | 11 | require ENV['TM_SUPPORT_PATH'] +'/lib/ui.rb' 12 | require ENV['TM_SUPPORT_PATH'] +'/lib/exit_codes.rb' 13 | opts = { "Formula" => "plot(${1:y~x}${2:, data=${3:frame})", 14 | "Bar Graph" => "barplot(${1:table(${2:x})})", 15 | "Pie Chart" => "pie(${1:x}${2:, col=c(${3:colors})})", 16 | "Histogram" => "hist(${1:x}${2:, breaks = ${3:8}})", 17 | "Box Plot" => "boxplot(${1:x}${2:, horizontal = TRUE})", 18 | "Scatterplot" => "plot(${1:x})"} 19 | keys = opts.keys.sort 20 | ans = TextMate::UI.menu(keys) 21 | TextMate.exit_discard unless ans 22 | print opts[keys[ans]] 23 | fallbackInput 24 | word 25 | input 26 | none 27 | keyEquivalent 28 | ~@P 29 | name 30 | Plots… 31 | output 32 | insertAsSnippet 33 | scope 34 | source.r, source.rd.console 35 | uuid 36 | 90EA3ACF-121E-4BBA-B1EB-3F461BCBDC8D 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/config.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | _ = require 'underscore-plus' 3 | yargs = require 'yargs' 4 | apm = require './apm' 5 | Command = require './command' 6 | 7 | module.exports = 8 | class Config extends Command 9 | @commandNames: ['config'] 10 | 11 | constructor: -> 12 | atomDirectory = apm.getAtomDirectory() 13 | @atomNodeDirectory = path.join(atomDirectory, '.node-gyp') 14 | @atomNpmPath = require.resolve('npm/bin/npm-cli') 15 | 16 | parseOptions: (argv) -> 17 | options = yargs(argv).wrap(100) 18 | options.usage """ 19 | 20 | Usage: apm config set 21 | apm config get 22 | apm config delete 23 | apm config list 24 | apm config edit 25 | 26 | """ 27 | options.alias('h', 'help').describe('help', 'Print this usage message') 28 | 29 | run: (options) -> 30 | {callback} = options 31 | options = @parseOptions(options.commandArgs) 32 | 33 | configArgs = ['--globalconfig', apm.getGlobalConfigPath(), '--userconfig', apm.getUserConfigPath(), 'config'] 34 | configArgs = configArgs.concat(options.argv._) 35 | 36 | env = _.extend({}, process.env, HOME: @atomNodeDirectory) 37 | configOptions = {env} 38 | 39 | @fork @atomNpmPath, configArgs, configOptions, (code, stderr='', stdout='') -> 40 | if code is 0 41 | process.stdout.write(stdout) if stdout 42 | callback() 43 | else 44 | process.stdout.write(stderr) if stderr 45 | callback(new Error("npm config failed: #{code}")) 46 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Function Call.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 9 | require ENV['TM_SUPPORT_PATH'] +'/lib/escape.rb' 10 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/current_word.rb") 11 | if ENV['TM_SELECTED_TEXT'].nil? or ENV['TM_SELECTED_TEXT'].empty? 12 | word = Word.current_word('\w\.') 13 | else 14 | word = ENV['TM_SELECTED_TEXT'] 15 | end 16 | line, col = ENV['TM_CURRENT_LINE'], ENV['TM_LINE_INDEX'].to_i 17 | left = line[0...(col - word.length)].to_s 18 | right = line[col..-1].to_s 19 | if ENV['TM_SELECTED_TEXT'].nil? or ENV['TM_SELECTED_TEXT'].empty? 20 | print "#{e_sn(left)}${1:sum}(#{e_sn(word)})#{e_sn(right)}" 21 | else 22 | print "${1:#{ENV['TM_R_WRAP_DEFAULT_FUNCTION']?ENV['TM_R_WRAP_DEFAULT_FUNCTION']:'sum'}}(#{e_sn(word)})" 23 | end 24 | fallbackInput 25 | line 26 | input 27 | selection 28 | keyEquivalent 29 | ^W 30 | name 31 | Function Call 32 | output 33 | insertAsSnippet 34 | scope 35 | source.r, source.rd.console 36 | uuid 37 | 769AC12C-9EDF-4089-8834-062A301907ED 38 | 39 | 40 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/DragCommands/read_table.tmDragCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | bundleUUID 8 | B29D7850-6E70-11D9-A369-000D93B3A10E 9 | command 10 | #!/usr/bin/env bash 11 | [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 12 | 13 | 14 | if [ "${TM_SCOPE:0:17}" == "source.rd.console" ]; then 15 | echo -n "read.table(file = \"$TM_DROPPED_FILEPATH\", sep = \"\${1:\\t}\", header = \${2:TRUE}, stringsAsFactors = \${3:FALSE})" 16 | else 17 | if [ "$TM_MODIFIER_FLAGS" == "SHIFT" ]; then 18 | echo "read.table(file = \"$TM_DROPPED_FILEPATH\", sep = \"\${1:\\t}\", header = \${2:TRUE}, stringsAsFactors = \${3:FALSE})" 19 | else 20 | echo "read.table(file = \"$TM_DROPPED_FILE\", sep = \"\${1:\\t}\", header = \${2:TRUE}, stringsAsFactors = \${3:FALSE})" 21 | fi 22 | fi 23 | draggedFileExtensions 24 | 25 | tab 26 | TAB 27 | 28 | input 29 | selection 30 | name 31 | read.table (*.tab) 32 | output 33 | insertAsSnippet 34 | scope 35 | source.r, source.rd.console 36 | uuid 37 | 59C40B86-99F3-4713-9C88-C3AD7CE0C821 38 | 39 | 40 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/command_args/par: -------------------------------------------------------------------------------- 1 | adj=0-left|0.5-center|1-right 2 | ann=FALSE 3 | ask=TRUE 4 | bg="" 5 | bty="o|l|7|c|u|n|]" 6 | cex=1 7 | cex.axis=1 8 | cex.lab=1 9 | cex.main=1 10 | cex.sub=1 11 | col="red" 12 | col.axis="red" 13 | col.lab="red" 14 | col.main="red" 15 | col.sub="red" 16 | crt=0 17 | family="" 18 | fg="red" 19 | fig=c(1, 1, 1, 1) 20 | fin=c(width, height) 21 | font=1-plain|2-bold|3-italics|4-bolditalics 22 | font.axis=1-plain|2-bold|3-italics|4-bolditalics 23 | font.lab=1-plain|2-bold|3-italics|4-bolditalics 24 | font.main=1-plain|2-bold|3-italics|4-bolditalics 25 | font.sub=1-plain|2-bold|3-italics|4-bolditalics 26 | gamma=1 27 | lab=c(x, y, len) 28 | las=0-parallel|1-horizontal|2-perpendicular|3-vertical 29 | lend=0-round|1-butt|2-square 30 | lheight=1 31 | ljoin=0-round|1-mitre|2-bevel 32 | lmitre=10 33 | lty=0-blank|1-solid|2-dashed|3-dotted|4-dotdash|5-longdash|6-twodash 34 | lwd=1 35 | mai=c(bottom, left, top, right) 36 | mar=c(bottom, left, top, right) 37 | mex=1 38 | mfcol=c(nr, nc) 39 | mfg=c(i, j) 40 | mfrow=c(nr, nc) 41 | mgp=c(3, 1, 0) 42 | new=TRUE 43 | oma=c(bottom, left, top, right) 44 | omd=c(x1, x2, y1, y2) 45 | omi=c(bottom, left, top, right) 46 | pch="19-solidCircle|20-bullet|21-circle|22-square|23-diamond|24-triangleUp|25-triangleDown" 47 | pin=c(width, height) 48 | plt=c(x1, x2, y1, y2) 49 | ps=10 50 | pty="s|m" 51 | srt=0 52 | tck=1 53 | tcl=-0.5 54 | usr=c(x1, x2, y1, y2) 55 | xaxp=c(x1, x2, 1|2|3) 56 | xaxs="r|i|e|s|d" 57 | xaxt="n|s|l|t" 58 | xlog=TRUE 59 | xpd=TRUE|FALSE|NA 60 | yaxp=c(x1, x2, 1|2|3) 61 | yaxs="r|i|e|s|d" 62 | yaxt="n|s|l|t" 63 | ylog=TRUE -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Create Vector from Selection.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -wKU 9 | require ENV['TM_SUPPORT_PATH'] + "/lib/escape.rb"; 10 | text = STDIN.read 11 | text = `export __CF_USER_TEXT_ENCODING=0x1F5:0x8000100:0x8000100; pbpaste` if text.empty? 12 | text.gsub!(/(^\s+|\s+$)/,"") 13 | text.gsub!(/\s{1,}/," ") 14 | print "${1:${2:x} <- }c(" 15 | out = Array.new 16 | $LFlag = '' 17 | text.split.each{|b| 18 | $LFlag = '' 19 | if b.match(/^\d+L$/) 20 | $LFlag = 'L' 21 | b.gsub!(/L$/, '') 22 | end 23 | if (b.to_f == 0 && ! b.match(/-?\.?0\.?0*/) && ! b.match(/^["'].*["']$/)) || b.match(/^\d+[^\d\-\.eE]+/ ) 24 | out << '"' + e_sn(b) + '"' 25 | else 26 | out << e_sn(b) + $LFlag 27 | end 28 | } 29 | print out.join(', ') 30 | print ")" 31 | 32 | fallbackInput 33 | none 34 | input 35 | selection 36 | keyEquivalent 37 | ^~c 38 | name 39 | Create Vector from Selection 40 | output 41 | insertAsSnippet 42 | scope 43 | source.r, source.rd.console 44 | uuid 45 | F61688AA-C298-4D58-A9DE-87891797B2F9 46 | 47 | 48 | -------------------------------------------------------------------------------- /spec/search-spec.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | express = require 'express' 3 | http = require 'http' 4 | apm = require '../lib/apm-cli' 5 | 6 | describe 'apm search', -> 7 | server = null 8 | 9 | beforeEach -> 10 | silenceOutput() 11 | spyOnToken() 12 | 13 | app = express() 14 | app.get '/search', (request, response) -> 15 | response.sendfile path.join(__dirname, 'fixtures', 'search.json') 16 | server = http.createServer(app) 17 | server.listen(3000) 18 | 19 | process.env.ATOM_PACKAGES_URL = "http://localhost:3000" 20 | 21 | afterEach -> 22 | server.close() 23 | 24 | it 'lists the matching packages and excludes deprecated packages', -> 25 | callback = jasmine.createSpy('callback') 26 | apm.run(['search', 'duck'], callback) 27 | 28 | waitsFor 'waiting for command to complete', -> 29 | callback.callCount > 0 30 | 31 | runs -> 32 | expect(console.log).toHaveBeenCalled() 33 | expect(console.log.argsForCall[1][0]).toContain 'duckberg' 34 | expect(console.log.argsForCall[2][0]).toContain 'ducktales' 35 | expect(console.log.argsForCall[3][0]).toContain 'duckblur' 36 | expect(console.log.argsForCall[4][0]).toBeUndefined() 37 | 38 | it "logs an error if the query is missing or empty", -> 39 | callback = jasmine.createSpy('callback') 40 | apm.run(['search'], callback) 41 | 42 | waitsFor 'waiting for command to complete', -> 43 | callback.callCount > 0 44 | 45 | runs -> 46 | expect(console.error).toHaveBeenCalled() 47 | expect(console.error.argsForCall[0][0].length).toBeGreaterThan 0 48 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/R_app.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env bash 9 | [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 10 | 11 | # input is selection or document 12 | rawText="`cat`" 13 | 14 | curDir='' 15 | if [[ ${#TM_DIRECTORY} -gt 0 ]]; then 16 | curDir="$TM_DIRECTORY" 17 | fi 18 | 19 | osascript -e 'on run(theCode)' \ 20 | -e 'tell application "R" to activate' \ 21 | -e 'if (item 2 of theCode) is not "" then tell application "R" to cmd "setwd('\''" & (item 2 of theCode) & "'\'')"' \ 22 | -e 'tell application "R" to cmd (item 1 of theCode)' \ 23 | -e 'end run' -- "$rawText" "$curDir" 24 | 25 | input 26 | selection 27 | inputFormat 28 | text 29 | keyEquivalent 30 | ~@R 31 | name 32 | R.app 33 | outputCaret 34 | afterOutput 35 | outputFormat 36 | text 37 | outputLocation 38 | toolTip 39 | scope 40 | source.r 41 | semanticClass 42 | process.external.run.r 43 | uuid 44 | 15FF2003-99F5-464C-A0C2-BAFED7AD73EB 45 | version 46 | 2 47 | 48 | 49 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/Rmate.css: -------------------------------------------------------------------------------- 1 | /* 2 | Style sheet rewritten by Felix Jung on 11/27/2012. 3 | */ 4 | body 5 | { 6 | font-family: FONTPLACEHOLDER; 7 | font-size: FONTSIZEPLACEHOLDER; 8 | background-color: rgb(99, 99, 99); 9 | } 10 | 11 | p 12 | { 13 | margin: 0; 14 | padding: 2px 0 2px 0; 15 | } 16 | 17 | p#version 18 | { 19 | font-size: 10pt; 20 | font-weight: bold; 21 | color: rgb(185, 140, 174); 22 | } 23 | 24 | div.framed 25 | { 26 | border-style: dotted; 27 | border-width: 1px 0; 28 | border-color: #666; 29 | margin: 10px 0; 30 | padding: 10px 31 | } 32 | 33 | span.comment 34 | { 35 | color: rgb(143, 144, 141); 36 | } 37 | 38 | div#script_output 39 | { 40 | background-color: rgb(39, 41, 44); 41 | } 42 | 43 | div.img 44 | { 45 | background-color: rgb(255, 255, 255); 46 | } 47 | 48 | span.output 49 | { 50 | color: rgb(162, 181, 112); 51 | } 52 | 53 | span.error 54 | { 55 | background: rgb(170, 71, 68); 56 | color: rgb(247, 202, 141); 57 | } 58 | 59 | span.warning 60 | { 61 | background: rgb(247, 202, 141); 62 | color: rgb(0, 0, 0); 63 | } 64 | 65 | hr 66 | { 67 | border: none; 68 | color: rgb(99, 99, 99); 69 | background-color: rgb(99, 99, 99); 70 | height: 1pt; 71 | } 72 | 73 | pre 74 | { 75 | padding: 0; 76 | margin: 0; 77 | line-height: 1.5; 78 | font-family: FONTPLACEHOLDER; 79 | font-size: FONTSIZEPLACEHOLDER; 80 | color:rgba(231, 231, 231, 1); 81 | } 82 | 83 | a 84 | { 85 | color: rgb(126, 175, 194); 86 | } 87 | 88 | .hidden 89 | { 90 | display: none; 91 | } 92 | 93 | .prompt 94 | { 95 | color: rgb(126, 175, 194); 96 | font-weight: bold; 97 | text-decoration: none; 98 | } -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Descriptives….tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 9 | # print "Got:" + STDIN.read 10 | 11 | require ENV['TM_SUPPORT_PATH'] +'/lib/ui.rb' 12 | require ENV['TM_SUPPORT_PATH'] +'/lib/exit_codes.rb' 13 | opts = { "Mean" => "mean(${1:x})", 14 | "Variance" => "var(${1:x})", 15 | "Std. Dev." => "sd(${1:x})", 16 | "Correlation" => "cor(${1:x})", 17 | "Five Num Sum" => "fivenum(${1:x})", 18 | "Quantiles" => "quantile(${1:x},${2:quantiles})", 19 | "Median" => "median(${1:x})", 20 | "Max" => "max(${1:x}${2:, na.rm=TRUE})", 21 | "Min" => "min(${1:x}${2:, na.rm=TRUE})", 22 | "Range" => "range(${1:x}${2:, na.rm=TRUE})" 23 | } 24 | keys = opts.keys.sort 25 | ans = TextMate::UI.menu(keys) 26 | TextMate.exit_discard unless ans 27 | print opts[keys[ans]] 28 | fallbackInput 29 | word 30 | input 31 | none 32 | keyEquivalent 33 | ~@D 34 | name 35 | Descriptives… 36 | output 37 | insertAsSnippet 38 | scope 39 | source.r, source.rd.console 40 | uuid 41 | 6BC03260-79E4-47B6-87CE-020BD066E0FB 42 | 43 | 44 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/DragCommands/read_spss.tmDragCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | bundleUUID 8 | B29D7850-6E70-11D9-A369-000D93B3A10E 9 | command 10 | #!/usr/bin/env bash 11 | [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 12 | 13 | 14 | 15 | if [ "${TM_SCOPE:0:17}" == "source.rd.console" ]; then 16 | echo -n "read.spss(file=\"$TM_DROPPED_FILEPATH\", use.value.labels=\${1:TRUE}, to.data.frame=\${2:TRUE}, max.value.labels=\${3:Inf}, trim.factor.names=\${4:FALSE})" 17 | else 18 | if [ "$TM_MODIFIER_FLAGS" == "SHIFT" ]; then 19 | echo "read.spss(file=\"$TM_DROPPED_FILEPATH\", use.value.labels=\${1:TRUE}, to.data.frame=\${2:TRUE}, max.value.labels=\${3:Inf}, trim.factor.names=\${4:FALSE})" 20 | else 21 | echo "read.spss(file=\"$TM_DROPPED_FILE\", use.value.labels=\${1:TRUE}, to.data.frame=\${2:TRUE}, max.value.labels=\${3:Inf}, trim.factor.names=\${4:FALSE})" 22 | fi 23 | fi 24 | draggedFileExtensions 25 | 26 | sav 27 | SAV 28 | 29 | input 30 | selection 31 | name 32 | read.spss (*.sav) 33 | output 34 | insertAsSnippet 35 | scope 36 | source.r, source.rd.console 37 | uuid 38 | A6E69150-0E80-4D24-9170-725B7A30EE18 39 | 40 | 41 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/ProcessHelpFiles.rb: -------------------------------------------------------------------------------- 1 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 2 | require 'pp' 3 | Dir.chdir(File.join((ENV["R_HOME"] || "/Library/Frameworks/R.framework/Resources"), "library")) 4 | resources = Dir.glob("*/latex/*.tex") 5 | # puts resources 6 | results = "" 7 | resources.each do |file| 8 | tex = File.read(file) 9 | terms = tex.scan(/\\begin\{verbatim\}\n(.*)\\end\{verbatim\}/m) 10 | #.split(/\n+(?=[\w.]+\()/) 11 | results << terms[0][0] unless terms.empty? 12 | #.map{|line| line.gsub(/\n|( )/,"")} 13 | end 14 | results.gsub!(/\s*#+(\s.*|)$/,"") # Removes comments. Need to watch out for something like "#" 15 | results.gsub!(/^\s*[\w.:]+\s*\n/,"") # Removes stupid lines like a:b 16 | results.gsub!(/^(\.|<)\w.*|.*(\?topic|@name|survexp\.uswhite).*/,"") # removes function names starting with a dot, as well as other random stuff 17 | results.gsub!(/.*value\n/,"") # Removes lines like: tsp(x) <- value 18 | results.gsub!(/^\w\s+.*\n/,"") # Removes lines like: R CMD ... 19 | results.gsub!(/^[\w.]*(?:\[|\$).*\n/,"") # Removes lines starting with: x[[...]] or x$name 20 | results.gsub!(/^[\w.:+-\/><\s;!&|"]*\n/,"") # Removes things like: time1 + time2 21 | results.gsub!(/^(?:if|for|while|function)\(.*\n/,"") # Removes definitions of if/for/while/function 22 | results.gsub!(/\n(?![\w.]+\()/," ") # Brings together arguments on different lines 23 | results.gsub!(/[\t ]+/," ") 24 | results.gsub!(/\s+$/,"") 25 | # puts "Suspicious lines:" # UNCOMMENT FOR DEBUGGIN 26 | # pp results.scan(/^(.*[^ \w\(].\)) +(\w.*)/) #,"\\1\n\\2" # Try to fix some lines that got together 27 | puts "=" * 40 28 | puts results.split("\n").sort.uniq.join("\n") 29 | -------------------------------------------------------------------------------- /src/theme-converter.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | url = require 'url' 3 | fs = require './fs' 4 | request = require './request' 5 | TextMateTheme = require './text-mate-theme' 6 | 7 | # Convert a TextMate theme to an Atom theme 8 | module.exports = 9 | class ThemeConverter 10 | constructor: (@sourcePath, destinationPath) -> 11 | @destinationPath = path.resolve(destinationPath) 12 | 13 | readTheme: (callback) -> 14 | {protocol} = url.parse(@sourcePath) 15 | if protocol is 'http:' or protocol is 'https:' 16 | requestOptions = url: @sourcePath 17 | request.get requestOptions, (error, response, body) => 18 | if error? 19 | if error.code is 'ENOTFOUND' 20 | error = "Could not resolve URL: #{@sourcePath}" 21 | callback(error) 22 | else if response.statusCode isnt 200 23 | callback("Request to #{@sourcePath} failed (#{response.headers.status})") 24 | else 25 | callback(null, body) 26 | else 27 | sourcePath = path.resolve(@sourcePath) 28 | if fs.isFileSync(sourcePath) 29 | callback(null, fs.readFileSync(sourcePath, 'utf8')) 30 | else 31 | callback("TextMate theme file not found: #{sourcePath}") 32 | 33 | convert: (callback) -> 34 | @readTheme (error, themeContents) => 35 | return callback(error) if error? 36 | 37 | try 38 | theme = new TextMateTheme(themeContents) 39 | catch error 40 | return callback(error) 41 | 42 | fs.writeFileSync(path.join(@destinationPath, 'styles', 'base.less'), theme.getStylesheet()) 43 | fs.writeFileSync(path.join(@destinationPath, 'styles', 'syntax-variables.less'), theme.getSyntaxVariables()) 44 | callback() 45 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/option-list.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | LIST=$(cat) 9 | [[ -z "$LIST" ]] && exit_discard 10 | echo -en "$LIST" | /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -e ' 11 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/ui.rb") 12 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/exit_codes.rb") 13 | words = STDIN.read().split("|") 14 | if words.size == 1 15 | if words[0] == "TRUE" || words[0] == "FALSE" || words[0] == "T" || words[0] == "F" 16 | print "FALSE" if words[0] == "TRUE" 17 | print "TRUE" if words[0] == "FALSE" 18 | print "F" if words[0] == "T" 19 | print "T" if words[0] == "F" 20 | else 21 | TextMate.exit_discard() 22 | end 23 | else 24 | index=TextMate::UI.menu(words) 25 | if index != nil 26 | if words[index].match("\-") 27 | print words[index].gsub!(/\-.*/,"") 28 | else 29 | print words[index] 30 | end 31 | else 32 | TextMate.exit_discard() 33 | end 34 | end 35 | ' 36 | 37 | 38 | fallbackInput 39 | word 40 | input 41 | selection 42 | keyEquivalent 43 | ^ 44 | name 45 | Option List as Pull Down… / BoolToggler 46 | output 47 | replaceSelectedText 48 | scope 49 | source.r, source.rd.console 50 | uuid 51 | B2612EB0-22A3-4D09-A851-721EA294DF13 52 | 53 | 54 | -------------------------------------------------------------------------------- /spec/config-spec.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | fs = require 'fs-plus' 3 | temp = require 'temp' 4 | apm = require '../lib/apm-cli' 5 | 6 | describe "apm config", -> 7 | [atomHome, userConfigPath] = [] 8 | 9 | beforeEach -> 10 | spyOnToken() 11 | silenceOutput() 12 | 13 | atomHome = temp.mkdirSync('apm-home-dir-') 14 | process.env.ATOM_HOME = atomHome 15 | userConfigPath = path.join(atomHome, '.apmrc') 16 | 17 | # Make sure the cache used is the one for the test env 18 | delete process.env.npm_config_cache 19 | 20 | describe "apm config get", -> 21 | it "reads the value from the global config when there is no user config", -> 22 | callback = jasmine.createSpy('callback') 23 | apm.run(['config', 'get', 'cache'], callback) 24 | 25 | waitsFor 'waiting for config get to complete', 600000, -> 26 | callback.callCount is 1 27 | 28 | runs -> 29 | expect(process.stdout.write.argsForCall[0][0].trim()).toBe path.join(process.env.ATOM_HOME, '.apm') 30 | 31 | describe "apm config set", -> 32 | it "sets the value in the user config", -> 33 | expect(fs.isFileSync(userConfigPath)).toBe false 34 | 35 | callback = jasmine.createSpy('callback') 36 | apm.run(['config', 'set', 'foo', 'bar'], callback) 37 | 38 | waitsFor 'waiting for config set to complete', 600000, -> 39 | callback.callCount is 1 40 | 41 | runs -> 42 | expect(fs.isFileSync(userConfigPath)).toBe true 43 | 44 | callback.reset() 45 | apm.run(['config', 'get', 'foo'], callback) 46 | 47 | waitsFor 'waiting for config get to complete', 600000, -> 48 | callback.callCount is 1 49 | 50 | runs -> 51 | expect(process.stdout.write.argsForCall[0][0].trim()).toBe 'bar' 52 | -------------------------------------------------------------------------------- /src/links.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | 3 | yargs = require 'yargs' 4 | 5 | Command = require './command' 6 | config = require './apm' 7 | fs = require './fs' 8 | tree = require './tree' 9 | 10 | module.exports = 11 | class Links extends Command 12 | @commandNames: ['linked', 'links', 'lns'] 13 | 14 | constructor: -> 15 | @devPackagesPath = path.join(config.getAtomDirectory(), 'dev', 'packages') 16 | @packagesPath = path.join(config.getAtomDirectory(), 'packages') 17 | 18 | parseOptions: (argv) -> 19 | options = yargs(argv).wrap(100) 20 | options.usage """ 21 | 22 | Usage: apm links 23 | 24 | List all of the symlinked atom packages in ~/.atom/packages and 25 | ~/.atom/dev/packages. 26 | """ 27 | options.alias('h', 'help').describe('help', 'Print this usage message') 28 | 29 | getDevPackagePath: (packageName) -> path.join(@devPackagesPath, packageName) 30 | 31 | getPackagePath: (packageName) -> path.join(@packagesPath, packageName) 32 | 33 | getSymlinks: (directoryPath) -> 34 | symlinks = [] 35 | for directory in fs.list(directoryPath) 36 | symlinkPath = path.join(directoryPath, directory) 37 | symlinks.push(symlinkPath) if fs.isSymbolicLinkSync(symlinkPath) 38 | symlinks 39 | 40 | logLinks: (directoryPath) -> 41 | links = @getSymlinks(directoryPath) 42 | console.log "#{directoryPath.cyan} (#{links.length})" 43 | tree links, emptyMessage: '(no links)', (link) -> 44 | try 45 | realpath = fs.realpathSync(link) 46 | catch error 47 | realpath = '???'.red 48 | "#{path.basename(link).yellow} -> #{realpath}" 49 | 50 | run: (options) -> 51 | {callback} = options 52 | 53 | @logLinks(@devPackagesPath) 54 | @logLinks(@packagesPath) 55 | callback() 56 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/web-search.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env bash 9 | [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 10 | 11 | 12 | if [ -z "$TM_SELECTED_TEXT" ]; then 13 | WORD=$(/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -- <<-SCR1 14 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/current_word.rb") 15 | word = Word.current_word('\w\.') 16 | word.gsub!(/^[\d\.\-]+$/,"") 17 | print word 18 | SCR1 19 | ) 20 | else 21 | WORD=$TM_SELECTED_TEXT 22 | fi 23 | 24 | if [ -z "$WORD" ]; then 25 | open "http://www.rseek.org" 26 | else 27 | open "http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4&q=$WORD&sa=Search+functions%2C+lists%2C+and+more&cof=FORID%3A11" 28 | fi 29 | 30 | fallbackInput 31 | word 32 | input 33 | selection 34 | inputFormat 35 | text 36 | keyEquivalent 37 | ^~@H 38 | name 39 | RSeek Search for Word / Selection 40 | outputCaret 41 | afterOutput 42 | outputFormat 43 | text 44 | outputLocation 45 | toolTip 46 | scope 47 | source.r, source.rd.console 48 | uuid 49 | 4DCF1FF7-D104-43C3-B0E3-8333A50CA5AA 50 | version 51 | 2 52 | 53 | 54 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/prefix_package_name.sh: -------------------------------------------------------------------------------- 1 | [[ -n "$TM_SELECTED_TEXT" ]] && echo "Please unselect first." && exit 206 2 | 3 | LINE=$(cat | perl -e ' 4 | $line=$ENV{"TM_CURRENT_LINE"};$col=$ENV{"TM_LINE_INDEX"}; 5 | $lineL=substr($line,0,$col); 6 | $lineR=substr($line,$col); 7 | if($lineL=~m/([\w_\.]*)$/) { 8 | $lineL=~s/([\w_\.]*)$//; 9 | $lineR=$1.$lineR if(defined $1); 10 | } 11 | $lineL=~s/(?=[\$`\\])/\\/g; 12 | $lineR=~s/(?=[\$`\\])/\\/g; 13 | $lineR=~s/^([\w_\.]*)/$1\${0:}/; 14 | print "$lineL\n$lineR"; 15 | ') 16 | WORD=$(/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -- <<-SCR1 17 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/current_word.rb") 18 | word = Word.current_word('\w._') 19 | print word 20 | SCR1 21 | ) 22 | 23 | WORD=$(echo -en "$WORD" | perl -pe 's/\([^\(]*$//') 24 | 25 | [[ -z "$WORD" ]] && echo "No keyword found" && exit 206 26 | 27 | "$TM_BUNDLE_SUPPORT"/bin/askRhelperDaemon.sh "@getPackageFor('$WORD')" 28 | LIB=$(cat /tmp/textmate_Rhelper_out) 29 | if [ -z "$LIB" ]; then 30 | echo -en "No package found." 31 | exit 206 32 | fi 33 | 34 | if [ `echo "$LIB" | wc -l` -gt 1 ]; then 35 | LIB=$(echo "$LIB" | sort -f | /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -e ' 36 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/ui.rb") 37 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/exit_codes.rb") 38 | words = STDIN.read().split("\n") 39 | index=TextMate::UI.menu(words) 40 | if index != nil 41 | print words[index] 42 | end 43 | ') 44 | fi 45 | [[ -z $LIB ]] && exit 200 46 | 47 | 48 | OUT="${LINE/ 49 | /$LIB::}" 50 | if [ `echo "$OUT" | grep -c "$LIB::"` -lt 1 ]; then 51 | echo "Please set the caret at the end of the function name and redo it." 52 | exit 206 53 | fi 54 | echo -n "$OUT" 55 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/getSig.R: -------------------------------------------------------------------------------- 1 | getSig <- function (..., snippet=T) 2 | sapply(unlist(list(...)), function(name, snipIdx=0, argIdx=0) 3 | paste(c(name, "(", 4 | if (snippet && is.null(formals(name))) 5 | "$1" 6 | else 7 | lapply( 8 | lapply(names(f <- formals(name)), 9 | function (arg) 10 | if (is.symbol(f[[arg]]) && f[[arg]] == "") arg else list(arg, f[[arg]]) 11 | ), 12 | function (arg, escape=function(x) ifelse(snippet, gsub(" *\n +", " ", gsub("([\\$`}])", "\\\\\\1", x)), x)) 13 | if (is.list(arg)) 14 | paste(if (snippet) paste("${", snipIdx <<- snipIdx + 1, ":", sep=""), 15 | ifelse((argIdx <<- argIdx + 1) > 1, ", ", ""), 16 | escape(deparse(as.name(arg[[1]]), backtick=T)), 17 | "=", 18 | if (snippet) paste("${", snipIdx <<- snipIdx + 1, ":", sep=""), 19 | if (is.character(arg[[2]])) 20 | paste('"', 21 | if (snippet) paste('${', snipIdx <<- snipIdx + 1, ":", sep=""), 22 | escape(substr(deparse(arg[[2]]), 2, nchar(deparse(arg[[2]]),type="c")-1)), 23 | ifelse(snippet, '}', ""), 24 | '"', 25 | sep="" 26 | ) 27 | else 28 | escape(paste(deparse(arg[[2]], backtick=T, control="useSource"), collapse="\n")) 29 | , 30 | ifelse(snippet, "}}", ""), 31 | sep="") 32 | else 33 | paste(ifelse((argIdx <<- argIdx + 1) > 1, 34 | ifelse(snippet, paste("${", snipIdx <<- snipIdx + 1, ":, ", sep=""), ", "), 35 | ""), 36 | if (snippet) paste("${", snipIdx <<- snipIdx + 1, ":", sep=""), 37 | escape(arg), 38 | ifelse(snippet, ifelse(argIdx > 1, "}}", "}"), ""), 39 | sep="") 40 | ) 41 | , 42 | ")") 43 | , collapse="" 44 | ) 45 | ) 46 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "atom-package-manager", 3 | "description": "Atom package manager", 4 | "version": "1.12.6", 5 | "license": "MIT", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/atom/apm.git" 9 | }, 10 | "bugs": { 11 | "url": "https://github.com/atom/apm/issues" 12 | }, 13 | "main": "./lib/apm.js", 14 | "bin": { 15 | "apm": "./bin/apm" 16 | }, 17 | "scripts": { 18 | "build": "node script/check-version.js && grunt", 19 | "prepublish": "grunt prepublish", 20 | "install": "node script/postinstall.js", 21 | "test": "node script/check-version.js && grunt test", 22 | "check-version": "node version.js" 23 | }, 24 | "dependencies": { 25 | "asar-require": "0.3.0", 26 | "async": "~0.2.8", 27 | "colors": "~0.6.1", 28 | "first-mate": "^5.0", 29 | "fs-plus": "2.x", 30 | "git-utils": "^4.0", 31 | "hosted-git-info": "^2.1.4", 32 | "keytar": "^3.0", 33 | "mv": "2.0.0", 34 | "ncp": "~0.5.1", 35 | "npm": "3.10.5", 36 | "open": "0.0.4", 37 | "plist": "git+https://github.com/nathansobo/node-plist.git", 38 | "q": "~0.9.7", 39 | "read": "~1.0.5", 40 | "request": "^2.72.0", 41 | "rimraf": "^2.5.2", 42 | "season": ">=5.0.5 <6.0", 43 | "semver": "^5.1.0", 44 | "tar": "^2.2.1", 45 | "temp": "~0.7.0", 46 | "underscore-plus": "1.x", 47 | "wordwrap": "0.0.2", 48 | "wrench": "~1.5.1", 49 | "yargs": "^3.23.0" 50 | }, 51 | "devDependencies": { 52 | "coffee-script": "^1.8.0", 53 | "express": "~3.2.3", 54 | "grunt": "^1.0.1", 55 | "grunt-coffeelint": "0.0.16", 56 | "grunt-cli": "^1.2.0", 57 | "grunt-contrib-coffee": "^1.0.0", 58 | "grunt-shell": "^1.3.0", 59 | "jasmine-focused": ">=1.0.7 <2.0" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Function Definition.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 9 | #require ENV['TM_SUPPORT_PATH'] +'/lib/escape.rb' 10 | #print "${1:${2:x} <- }function(${3:var}) {\n#{if s = ENV['TM_SELECTED_TEXT'] then e_sn(s.chomp.gsub(/(\A|\n)/,"\\1\t")) else "\t\$4" end}\n}" 11 | 12 | require ENV['TM_SUPPORT_PATH'] +'/lib/escape.rb' 13 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/current_word.rb") 14 | if ENV['TM_SELECTED_TEXT'].nil? or ENV['TM_SELECTED_TEXT'].empty? 15 | word = Word.current_word('\w\.') 16 | else 17 | word = ENV['TM_SELECTED_TEXT'] 18 | end 19 | line, col = ENV['TM_CURRENT_LINE'], ENV['TM_LINE_INDEX'].to_i 20 | left = line[0...(col - word.length)].to_s 21 | right = line[col..-1].to_s 22 | if ENV['TM_SELECTED_TEXT'].nil? or ENV['TM_SELECTED_TEXT'].empty? 23 | print "#{e_sn(left)}${1:${2:x} <- }function(${3:var}) {\n\t#{e_sn(word)}\$4\n}#{e_sn(right)}" 24 | else 25 | print "${1:${2:x} <- }function(${3:var}) {\n\t#{e_sn(word)}\$4\n}" 26 | end 27 | fallbackInput 28 | line 29 | input 30 | selection 31 | keyEquivalent 32 | ^@W 33 | name 34 | Function Definition 35 | output 36 | insertAsSnippet 37 | scope 38 | source.r, source.rd.console 39 | uuid 40 | 4C1A1536-31FF-4FF5-B0C5-CD47D21CFD52 41 | 42 | 43 | -------------------------------------------------------------------------------- /spec/featured-spec.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | express = require 'express' 3 | http = require 'http' 4 | apm = require '../lib/apm-cli' 5 | 6 | describe 'apm featured', -> 7 | server = null 8 | 9 | beforeEach -> 10 | silenceOutput() 11 | spyOnToken() 12 | 13 | app = express() 14 | app.get '/packages/featured', (request, response) -> 15 | response.sendfile path.join(__dirname, 'fixtures', 'packages.json') 16 | app.get '/themes/featured', (request, response) -> 17 | response.sendfile path.join(__dirname, 'fixtures', 'themes.json') 18 | 19 | server = http.createServer(app) 20 | server.listen(3000) 21 | 22 | process.env.ATOM_API_URL = "http://localhost:3000" 23 | 24 | afterEach -> 25 | server.close() 26 | 27 | it 'lists the featured packages and themes', -> 28 | callback = jasmine.createSpy('callback') 29 | apm.run(['featured'], callback) 30 | 31 | waitsFor 'waiting for command to complete', -> 32 | callback.callCount > 0 33 | 34 | runs -> 35 | expect(console.log).toHaveBeenCalled() 36 | expect(console.log.argsForCall[1][0]).toContain 'beverly-hills' 37 | expect(console.log.argsForCall[2][0]).toContain 'multi-version' 38 | expect(console.log.argsForCall[3][0]).toContain 'duckblur' 39 | 40 | describe 'when the theme flag is specified', -> 41 | it "lists the featured themes", -> 42 | callback = jasmine.createSpy('callback') 43 | apm.run(['featured', '--themes'], callback) 44 | 45 | waitsFor 'waiting for command to complete', -> 46 | callback.callCount > 0 47 | 48 | runs -> 49 | expect(console.log).toHaveBeenCalled() 50 | expect(console.log.argsForCall[1][0]).toContain 'duckblur' 51 | expect(console.log.argsForCall[2][0]).toBeUndefined() 52 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/r-site-search.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env bash 9 | [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 10 | 11 | 12 | if [ -z "$TM_SELECTED_TEXT" ]; then 13 | WORD=$(/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -- <<-SCR1 14 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/current_word.rb") 15 | word = Word.current_word('\w\.') 16 | word.gsub!(/^[\d\.\-]+$/,"") 17 | print word 18 | SCR1 19 | ) 20 | else 21 | WORD=$TM_SELECTED_TEXT 22 | fi 23 | 24 | if [ -z "$WORD" ]; then 25 | open "http://search.r-project.org/" 26 | else 27 | W=`echo -en "$WORD" | sed 's/ {1,}/+/g'` 28 | open "http://search.r-project.org/cgi-bin/namazu.cgi?query=$W&max=20&result=normal&sort=score&idxname=Rhelp02a&idxname=functions&idxname=docs" 29 | fi 30 | 31 | fallbackInput 32 | word 33 | input 34 | selection 35 | inputFormat 36 | text 37 | keyEquivalent 38 | ^~@H 39 | name 40 | RSite Search for Word / Selection 41 | outputCaret 42 | afterOutput 43 | outputFormat 44 | text 45 | outputLocation 46 | toolTip 47 | scope 48 | source.r, source.rd.console 49 | uuid 50 | B26AF49E-C737-41D4-990F-5BBB138B3FCD 51 | version 52 | 2 53 | 54 | 55 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/Create Matrix from Selection.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 9 | require ENV['TM_SUPPORT_PATH'] + "/lib/escape.rb"; 10 | text = STDIN.read 11 | text = `export __CF_USER_TEXT_ENCODING=0x1F5:0x8000100:0x8000100; pbpaste` if text.empty? 12 | text << "\n" if ! text.match(/\n$/) 13 | rcnt = text.count "\n" 14 | 15 | text.gsub!(/(^\s+|\s+$)/,"") 16 | text.gsub!(/\s{1,}/," ") 17 | print "${1:${2:x} <- }matrix(c(" 18 | out = Array.new 19 | $LFlag = '' 20 | text.split.each{|b| 21 | $LFlag = '' 22 | if b.match(/^\d+L$/) 23 | $LFlag = 'L' 24 | b.gsub!(/L$/, '') 25 | end 26 | if (b.to_f == 0 && ! b.match(/-?\.?0\.?0*/) && ! b.match(/^["'].*["']$/)) || b.match(/^\d+[^\d\-\.eE]+/) 27 | out << '"' + e_sn(b) + '"' 28 | else 29 | out << e_sn(b) + $LFlag 30 | end 31 | } 32 | print out.join(', ') 33 | print "), nrow=#{rcnt}, byrow=TRUE)" 34 | 35 | 36 | 37 | #print "${1:${2:x} <- }matrix(c("+e_sn(text).sub(/\s+$/,"").gsub(/([a-zA-Z]+)/, '"\1"').gsub(/\s+/,", ") + "), nrow=#{rcnt}, byrow=TRUE)" 38 | fallbackInput 39 | none 40 | input 41 | selection 42 | keyEquivalent 43 | ^~c 44 | name 45 | Create Matrix from Selection 46 | output 47 | insertAsSnippet 48 | scope 49 | source.r, source.rd.console 50 | uuid 51 | BC6C2055-67E1-4902-98B0-AACDFEE031BB 52 | 53 | 54 | -------------------------------------------------------------------------------- /spec/help-spec.coffee: -------------------------------------------------------------------------------- 1 | apm = require '../lib/apm-cli' 2 | 3 | describe 'command help', -> 4 | beforeEach -> 5 | spyOnToken() 6 | silenceOutput() 7 | 8 | describe "apm help publish", -> 9 | it "displays the help for the command", -> 10 | callback = jasmine.createSpy('callback') 11 | apm.run(['help', 'publish'], callback) 12 | 13 | waitsFor 'waiting for help to complete', 60000, -> 14 | callback.callCount is 1 15 | 16 | runs -> 17 | expect(console.error.callCount).toBeGreaterThan 0 18 | expect(callback.mostRecentCall.args[0]).toBeUndefined() 19 | 20 | describe "apm publish -h", -> 21 | it "displays the help for the command", -> 22 | callback = jasmine.createSpy('callback') 23 | apm.run(['publish', '-h'], callback) 24 | 25 | waitsFor 'waiting for help to complete', 60000, -> 26 | callback.callCount is 1 27 | 28 | runs -> 29 | expect(console.error.callCount).toBeGreaterThan 0 30 | expect(callback.mostRecentCall.args[0]).toBeUndefined() 31 | 32 | describe "apm help", -> 33 | it "displays the help for apm", -> 34 | callback = jasmine.createSpy('callback') 35 | apm.run(['help'], callback) 36 | 37 | waitsFor 'waiting for help to complete', 60000, -> 38 | callback.callCount is 1 39 | 40 | runs -> 41 | expect(console.error.callCount).toBeGreaterThan 0 42 | expect(callback.mostRecentCall.args[0]).toBeUndefined() 43 | 44 | describe "apm", -> 45 | it "displays the help for apm", -> 46 | callback = jasmine.createSpy('callback') 47 | apm.run([], callback) 48 | 49 | waitsFor 'waiting for help to complete', 60000, -> 50 | callback.callCount is 1 51 | 52 | runs -> 53 | expect(console.error.callCount).toBeGreaterThan 0 54 | expect(callback.mostRecentCall.args[0]).toBeUndefined() 55 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/insert_command_template.rb: -------------------------------------------------------------------------------- 1 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 2 | require File.join(ENV['TM_SUPPORT_PATH'], "lib/exit_codes.rb") 3 | require File.join(ENV['TM_SUPPORT_PATH'], "lib/ui.rb") 4 | require File.join(ENV['TM_SUPPORT_PATH'], 'lib/current_word.rb') 5 | 6 | require File.join(ENV['TM_BUNDLE_SUPPORT'], 'lib/popen3.rb') 7 | 8 | word = Word.current_word('\w\.') 9 | 10 | stdin, stdout, stderr = popen3("R", "--vanilla", "--no-readline", "--slave", "--encoding=UTF-8") 11 | 12 | stdin.write(File.read(File.join(ENV['TM_BUNDLE_SUPPORT'], 'getSig.R'))) 13 | 14 | wordEsc = word.gsub("\\|'", "\\\\\\0") 15 | wordReg = Regexp.escape(word).gsub("\\|'", "\\\\\\0") 16 | stdin.puts("cat(paste(getSig(if ('#{wordEsc}' %in% (ary <- sort(apropos('^#{wordReg}', mode='function')))) '#{wordEsc}' else ary), collapse='\\n'))") 17 | stdin.close 18 | 19 | text = stdout.read() 20 | 21 | TextMate.exit_show_tool_tip("No function signature known for `#{word}'") if text.empty? 22 | 23 | functions = text.split("\n") 24 | if functions.size == 1 25 | function = functions.first 26 | else 27 | # term = TextMate::UI.request_item :title => "Snippet for Command", :prompt => "There were more than one matching commands found", :items => functions.collect { |f| f[0...f.index("(")] } 28 | idx = TextMate::UI.menu functions.collect { |f| f[0...f.index("(")] } 29 | TextMate.exit_discard if idx.nil? 30 | function = functions[idx] 31 | # function = functions.find("") { |f| f[0..term.length] == term + "(" } 32 | end 33 | 34 | TextMate.exit_discard if function.empty? 35 | 36 | if ENV['TM_SELECTED_TEXT'].nil? or ENV['TM_SELECTED_TEXT'].empty? 37 | # we didn't use selected text but instead pulled the word from the line 38 | # so lets only insert everything after the term 39 | print function[word.length..-1] 40 | NameError 41 | else 42 | print function 43 | end 44 | -------------------------------------------------------------------------------- /spec/apm-cli-spec.coffee: -------------------------------------------------------------------------------- 1 | fs = require 'fs' 2 | apm = require '../lib/apm-cli' 3 | 4 | describe 'apm command line interface', -> 5 | beforeEach -> 6 | silenceOutput() 7 | spyOnToken() 8 | 9 | describe 'when no arguments are present', -> 10 | it 'prints a usage message', -> 11 | apm.run([]) 12 | expect(console.log).not.toHaveBeenCalled() 13 | expect(console.error).toHaveBeenCalled() 14 | expect(console.error.argsForCall[0][0].length).toBeGreaterThan 0 15 | 16 | describe 'when the help flag is specified', -> 17 | it 'prints a usage message', -> 18 | apm.run(['-h']) 19 | expect(console.log).not.toHaveBeenCalled() 20 | expect(console.error).toHaveBeenCalled() 21 | expect(console.error.argsForCall[0][0].length).toBeGreaterThan 0 22 | 23 | describe 'when the version flag is specified', -> 24 | it 'prints the version', -> 25 | callback = jasmine.createSpy('callback') 26 | apm.run(['-v', '--no-color'], callback) 27 | 28 | waitsFor -> 29 | callback.callCount is 1 30 | 31 | runs -> 32 | expect(console.error).not.toHaveBeenCalled() 33 | expect(console.log).toHaveBeenCalled() 34 | lines = console.log.argsForCall[0][0].split('\n') 35 | expect(lines[0]).toBe "apm #{require('../package.json').version}" 36 | expect(lines[1]).toBe "npm #{require('npm/package.json').version}" 37 | expect(lines[2]).toBe "node #{process.versions.node}" 38 | 39 | describe 'when an unrecognized command is specified', -> 40 | it 'prints an error message and exits', -> 41 | callback = jasmine.createSpy('callback') 42 | apm.run(['this-will-never-be-a-command'], callback) 43 | expect(console.log).not.toHaveBeenCalled() 44 | expect(console.error).toHaveBeenCalled() 45 | expect(console.error.argsForCall[0][0].length).toBeGreaterThan 0 46 | expect(callback.mostRecentCall.args[0]).not.toBeUndefined() 47 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/command_args/options: -------------------------------------------------------------------------------- 1 | add.smooth=TRUE 2 | check.bounds=FALSE 3 | continue="+ " 4 | defaultPackages=c("datasets", "utils", "grDevices", "graphics", "stats", "methods") 5 | deparse.max.lines=10 6 | digits=7 7 | digits.secs=0...6 8 | download.file.method="internal|wget|lynx|auto" 9 | echo=TRUE 10 | encoding="native.enc" 11 | error=NULL|fun 12 | expressions25...500000 13 | keep.source=TRUE 14 | keep.source.pkgs=FALSE 15 | mailer="none" 16 | max.contour.segments=250000 17 | max.print=99999 18 | OutDec="." 19 | pager="$R_HOME/bin/pager" 20 | papersize="" 21 | printcmd="" 22 | prompt="> " 23 | rl_word_breaks=" \t\n\"\\`><=%;,|&{()}" 24 | save.defaults=list(ascii=TRUE, safe=FALSE) 25 | save.image.defaults=list(ascii=TRUE, safe=FALSE) 26 | scipen=integer_positiveFixed|negativeScientific 27 | showErrorCalls=TRUE 28 | showWarnCalls=TRUE 29 | showNCalls=30...500 30 | show.error.messages=TRUE 31 | stringsAsFactors=TRUE 32 | texi2dvi="NULL|script" 33 | timeout=60 34 | topLevelEnvironment="" 35 | useFancyQuotes=TRUE 36 | verbose=TRUE 37 | warn=-1-ignore|0-default|1-as_occur|2-as_error 38 | warnPartialMatchArgs=TRUE 39 | warnPartialMatchAttr=TRUE 40 | warnPartialMatchDollar=TRUE 41 | warning.expression="func" 42 | warnings.length=100...8170 43 | width=10...10000 44 | - 45 | device="x11|quartz|postscript|pdf" 46 | locatorBell=TRUE 47 | par.ask.default=TRUE 48 | X11colortype="true" 49 | X11fonts=c("", "") 50 | gamma=1 51 | - 52 | contrasts=c("unordered", "ordered") 53 | na.action="func" 54 | show.coef.Pvalues=TRUE. 55 | show.signif.stars=TRUE 56 | ts.eps=1e-05 57 | ts.S.compat=TRUE 58 | - 59 | browser="Safari" 60 | de.cellwidth=|0|negative|NA 61 | editor="mate -w" 62 | example.ask=TRUE 63 | help.try.all.packages=TRUE 64 | HTTPUserAgent="NULL" 65 | internet.info=2|1|0 66 | menu.graphics=FALSE 67 | pkgType="source|mac.binary" 68 | repos=c(CRAN="@CRAN@") 69 | SweaveHooks="" 70 | SweaveSyntax="" 71 | unzip="internal|PATH" 72 | - 73 | dvipscmd="command" 74 | latexcmd="command" 75 | pdfviewer="" -------------------------------------------------------------------------------- /src/link.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | 3 | CSON = require 'season' 4 | yargs = require 'yargs' 5 | 6 | Command = require './command' 7 | config = require './apm' 8 | fs = require './fs' 9 | 10 | module.exports = 11 | class Link extends Command 12 | @commandNames: ['link', 'ln'] 13 | 14 | parseOptions: (argv) -> 15 | options = yargs(argv).wrap(100) 16 | options.usage """ 17 | 18 | Usage: apm link [] 19 | 20 | Create a symlink for the package in ~/.atom/packages. The package in the 21 | current working directory is linked if no path is given. 22 | 23 | Run `apm links` to view all the currently linked packages. 24 | """ 25 | options.alias('h', 'help').describe('help', 'Print this usage message') 26 | options.alias('d', 'dev').boolean('dev').describe('dev', 'Link to ~/.atom/dev/packages') 27 | 28 | run: (options) -> 29 | {callback} = options 30 | options = @parseOptions(options.commandArgs) 31 | 32 | packagePath = options.argv._[0]?.toString() ? '.' 33 | linkPath = path.resolve(process.cwd(), packagePath) 34 | 35 | try 36 | packageName = CSON.readFileSync(CSON.resolve(path.join(linkPath, 'package'))).name 37 | packageName = path.basename(linkPath) unless packageName 38 | 39 | if options.argv.dev 40 | targetPath = path.join(config.getAtomDirectory(), 'dev', 'packages', packageName) 41 | else 42 | targetPath = path.join(config.getAtomDirectory(), 'packages', packageName) 43 | 44 | unless fs.existsSync(linkPath) 45 | callback("Package directory does not exist: #{linkPath}") 46 | return 47 | 48 | try 49 | fs.unlinkSync(targetPath) if fs.isSymbolicLinkSync(targetPath) 50 | fs.makeTreeSync path.dirname(targetPath) 51 | fs.symlinkSync(linkPath, targetPath, 'junction') 52 | console.log "#{targetPath} -> #{linkPath}" 53 | callback() 54 | catch error 55 | callback("Linking #{targetPath} to #{linkPath} failed: #{error.message}") 56 | -------------------------------------------------------------------------------- /src/unstar.coffee: -------------------------------------------------------------------------------- 1 | async = require 'async' 2 | yargs = require 'yargs' 3 | 4 | config = require './apm' 5 | Command = require './command' 6 | Login = require './login' 7 | request = require './request' 8 | 9 | module.exports = 10 | class Unstar extends Command 11 | @commandNames: ['unstar'] 12 | 13 | parseOptions: (argv) -> 14 | options = yargs(argv).wrap(100) 15 | options.usage """ 16 | 17 | Usage: apm unstar ... 18 | 19 | Unstar the given packages on https://atom.io 20 | 21 | Run `apm stars` to see all your starred packages. 22 | """ 23 | options.alias('h', 'help').describe('help', 'Print this usage message') 24 | 25 | starPackage: (packageName, token, callback) -> 26 | process.stdout.write '\uD83D\uDC5F \u2B50 ' if process.platform is 'darwin' 27 | process.stdout.write "Unstarring #{packageName} " 28 | requestSettings = 29 | json: true 30 | url: "#{config.getAtomPackagesUrl()}/#{packageName}/star" 31 | headers: 32 | authorization: token 33 | request.del requestSettings, (error, response, body={}) => 34 | if error? 35 | @logFailure() 36 | callback(error) 37 | else if response.statusCode isnt 204 38 | @logFailure() 39 | message = body.message ? body.error ? body 40 | callback("Unstarring package failed: #{message}") 41 | else 42 | @logSuccess() 43 | callback() 44 | 45 | run: (options) -> 46 | {callback} = options 47 | options = @parseOptions(options.commandArgs) 48 | packageNames = @packageNamesFromArgv(options.argv) 49 | 50 | if packageNames.length is 0 51 | callback("Please specify a package name to unstar") 52 | return 53 | 54 | Login.getTokenOrLogin (error, token) => 55 | return callback(error) if error? 56 | 57 | commands = packageNames.map (packageName) => 58 | (callback) => @starPackage(packageName, token, callback) 59 | async.waterfall(commands, callback) 60 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/evaluate-selector.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | # input is selection or document 9 | rawText="`cat`" 10 | 11 | curDir='' 12 | if [[ ${#TM_DIRECTORY} -gt 0 ]]; then 13 | curDir="$TM_DIRECTORY" 14 | fi 15 | 16 | osascript -e 'on run(theCode)' \ 17 | -e 'tell application "R" to activate' \ 18 | -e 'if (item 2 of theCode) is not "" then tell application "R" to cmd "setwd('\''" & (item 2 of theCode) & "'\'')"' \ 19 | -e 'tell application "R" to cmd (item 1 of theCode)' \ 20 | -e 'end run' -- "$rawText" "$curDir" 21 | 22 | if [ "$TM_LINE_NUMBER" != "" ]; then 23 | open "txmt://open?line=$(($TM_LINE_NUMBER+1))&column=1000000" & 24 | elif [[ $TM_SELECTION =~ [1-9][0-9]*:?[0-9]*-([1-9][0-9]*):?[0-9]* ]]; then 25 | # Regular Selection 26 | open "txmt://open?line=$((${BASH_REMATCH[1]}+1))&column=1000000" & 27 | elif [[ $TM_SELECTION =~ [1-9][0-9]*:?[0-9]*x([1-9][0-9]*):?[0-9]* ]]; then 28 | # Block (option) selection 29 | open "txmt://open?line=$((${BASH_REMATCH[1]}+1))&column=1000000" & 30 | else 31 | open "txmt://open" 32 | fi 33 | fallbackInput 34 | line 35 | input 36 | selection 37 | inputFormat 38 | text 39 | keyEquivalent 40 | ~$ 41 | name 42 | R.app & Step 43 | outputCaret 44 | afterOutput 45 | outputFormat 46 | text 47 | outputLocation 48 | discard 49 | scope 50 | source.r 51 | uuid 52 | ED52D514-DDB8-4D8C-BE0C-F791C70F530A 53 | version 54 | 2 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/enable.coffee: -------------------------------------------------------------------------------- 1 | _ = require 'underscore-plus' 2 | path = require 'path' 3 | CSON = require 'season' 4 | yargs = require 'yargs' 5 | 6 | config = require './apm' 7 | Command = require './command' 8 | 9 | module.exports = 10 | class Enable extends Command 11 | @commandNames: ['enable'] 12 | 13 | parseOptions: (argv) -> 14 | options = yargs(argv).wrap(100) 15 | options.usage """ 16 | 17 | Usage: apm enable []... 18 | 19 | Enables the named package(s). 20 | """ 21 | options.alias('h', 'help').describe('help', 'Print this usage message') 22 | 23 | run: (options) -> 24 | {callback} = options 25 | options = @parseOptions(options.commandArgs) 26 | packageNames = @packageNamesFromArgv(options.argv) 27 | 28 | configFilePath = CSON.resolve(path.join(config.getAtomDirectory(), 'config')) 29 | unless configFilePath 30 | callback("Could not find config.cson. Run Atom first?") 31 | return 32 | 33 | try 34 | settings = CSON.readFileSync(configFilePath) 35 | catch error 36 | callback "Failed to load `#{configFilePath}`: #{error.message}" 37 | return 38 | 39 | keyPath = '*.core.disabledPackages' 40 | disabledPackages = _.valueForKeyPath(settings, keyPath) ? [] 41 | 42 | errorPackages = _.difference(packageNames, disabledPackages) 43 | if errorPackages.length > 0 44 | console.log "Not Disabled:\n #{errorPackages.join('\n ')}" 45 | 46 | # can't enable a package that isn't disabled 47 | packageNames = _.difference(packageNames, errorPackages) 48 | 49 | if packageNames.length is 0 50 | callback("Please specify a package to enable") 51 | return 52 | 53 | result = _.difference(disabledPackages, packageNames) 54 | _.setValueForKeyPath(settings, keyPath, result) 55 | 56 | try 57 | CSON.writeFileSync(configFilePath, settings) 58 | catch error 59 | callback "Failed to save `#{configFilePath}`: #{error.message}" 60 | return 61 | 62 | console.log "Enabled:\n #{packageNames.join('\n ')}" 63 | @logSuccess() 64 | callback() 65 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/pastel.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Blatantly copied from Ruby. Will need to find some uniform system. 4 | Charilaos Skiadas. 05-03-2006 5 | 6 | Stylesheet kindly borrowed from the PyMate command. Eventually I will coordinate something 7 | with the author, so we don't have several identical files around. 8 | By Sune Foldager. 9 | Version 1, 12-08-2005. 10 | 11 | */ 12 | 13 | body 14 | { 15 | font-family: "Lucida Grande"; 16 | font-size: FONTSIZEPLACEHOLDER; 17 | background-color: rgb(170, 200, 255); 18 | margin: 0; 19 | /* height: 100%; */ 20 | } 21 | 22 | p 23 | { 24 | margin: 0; 25 | padding: 2px 0 2px 0; 26 | } 27 | 28 | p#version 29 | { 30 | font-size: 10pt; 31 | font-weight: bold; 32 | color: #005C3E; 33 | } 34 | 35 | div.framed 36 | { 37 | border-style: dotted; 38 | border-width: 1px 0; 39 | border-color: #666; 40 | margin: 10px 0; 41 | padding: 10px 42 | } 43 | 44 | div#script_output 45 | { 46 | background-color: rgb(230, 240, 255); 47 | } 48 | 49 | pre 50 | { 51 | padding: 0; 52 | margin: 0; 53 | line-height: 1.5; 54 | font-family: FONTPLACEHOLDER; 55 | font-size: FONTSIZEPLACEHOLDER; 56 | } 57 | 58 | pre strong 59 | { 60 | /* used for messages */ 61 | font-weight: normal; 62 | color: #0000CC; 63 | } 64 | 65 | pre strong i 66 | { 67 | /* used for messages */ 68 | font-weight: normal; 69 | color: #AAAAAA; 70 | } 71 | 72 | pre em 73 | { 74 | /* used for stderr */ 75 | font-style: normal; 76 | color: #FF5600; 77 | } 78 | 79 | div#exception_report 80 | { 81 | background-color: rgb(210, 220, 255); 82 | } 83 | 84 | p#exception strong 85 | { 86 | color: #FF5600; 87 | } 88 | 89 | p#traceback 90 | { 91 | font-size: FONTSIZEPLACEHOLDER; 92 | } 93 | 94 | table 95 | { 96 | margin: 0; 97 | padding: 0; 98 | } 99 | 100 | td 101 | { 102 | margin: 0; 103 | padding: 2px 2px 2px 5px; 104 | font-size: FONTSIZEPLACEHOLDER; 105 | } 106 | 107 | a 108 | { 109 | color: #FF5600; 110 | } 111 | 112 | .hidden 113 | { 114 | display: none; 115 | } 116 | 117 | .prompt 118 | { 119 | color: darkcyan; 120 | text-decoration: none; 121 | } -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/run-selector.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | autoScrollOutput 6 | 7 | beforeRunningCommand 8 | nop 9 | command 10 | #!/usr/bin/env bash 11 | [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 12 | 13 | cd "${TM_PROJECT_DIRECTORY:-${TM_DIRECTORY:-$HOME}}" 14 | 15 | #only for Mac OSX 10.4 X11 16 | OS=$(uname -r | perl -pe 's/(\d+)\..*/$1/') 17 | [[ $OS -eq 8 ]] && export DISPLAY=:0.0 18 | 19 | CRAN="http://cran.cnr.berkeley.edu" 20 | SOFILE="$HOME/Library/Application Support/Rdaemon/startOptions.R" 21 | if [ -f "$SOFILE" ]; then 22 | RES=$(cat "$SOFILE" | egrep 'options.*?repos.*?list' | perl -pe 's/^\s*options\s*.*?repos\s*=\s*.*?[\x{27}"](.*?)[\x{27}"].*/$1/g' | tail -n 1) 23 | [[ ! -z "$RES" ]] && [[ "${RES:0:4}" == "http" ]] && CRAN="$RES" 24 | fi 25 | 26 | if [ ! -z "$TM_INPUT_START_LINE" ]; then 27 | if [ `echo -en "$TM_SELECTED_TEXT" | egrep -cv '^[ ]*#'` -gt 0 ]; then 28 | echo -en "$TM_SELECTED_TEXT" | "$TM_BUNDLE_SUPPORT/tmR.rb" "$CRAN" 1 29 | else 30 | cat | "$TM_BUNDLE_SUPPORT/tmR.rb" "$CRAN" 0 31 | fi 32 | else 33 | cat | "$TM_BUNDLE_SUPPORT/tmR.rb" "$CRAN" 0 34 | fi 35 | 36 | fallbackInput 37 | document 38 | input 39 | selection 40 | inputFormat 41 | text 42 | keyEquivalent 43 | @r 44 | name 45 | Run Document / Selection in R 46 | outputCaret 47 | afterOutput 48 | outputFormat 49 | html 50 | outputLocation 51 | newWindow 52 | scope 53 | source.r 54 | semanticClass 55 | process.run.script.r 56 | uuid 57 | F5D7F00C-6DEE-469E-AFEE-6E4B7CDD4148 58 | version 59 | 2 60 | 61 | 62 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/startRhelperbuilder.sh: -------------------------------------------------------------------------------- 1 | 2 | 3 | ################################ 4 | ## NOT YET USED !!!!! 5 | ################################ 6 | 7 | 8 | WDIR="$TM_BUNDLE_SUPPORT"/bin 9 | HTMLROOTPATH="$HOME/Library/Application Support/TextMate/R/help/HTML" 10 | 11 | [[ ! -e "$HTMLROOTPATH" ]] && mkdir -p "$HTMLROOTPATH" 12 | 13 | cd "$WDIR" 14 | 15 | if [ ! -e /tmp/r_helper_dummy ]; then 16 | mkfifo /tmp/r_helper_dummy 17 | else 18 | if [ ! -p /tmp/r_helper_dummy ]; then 19 | rm /tmp/r_helper_dummy 20 | mkfifo /tmp/r_helper_dummy 21 | fi 22 | fi 23 | 24 | /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby Rhelperbuilder.rb &> /dev/null & 25 | 26 | ### wait for Rhelper 27 | #safety counter 28 | SAFECNT=0 29 | while [ ! -f /tmp/r_helper_dummy_out ] 30 | do 31 | SAFECNT=$(($SAFECNT+1)) 32 | if [ $SAFECNT -gt 50000 ]; then 33 | echo -en "Start failed! No response from Rhelper!" 34 | exit 206 35 | fi 36 | sleep 0.01 37 | done 38 | 39 | #wait for Rdaemon's output is ready 40 | SAFECNT=0 41 | while [ 1 ] 42 | do 43 | ST=$(tail -n 1 /tmp/r_helper_dummy_out ) 44 | [[ "$ST" == "> " ]] && break 45 | SAFECNT=$(($SAFECNT+1)) 46 | if [ $SAFECNT -gt 50000 ]; then 47 | echo -en "Start failed! No response from Rhelper!" 48 | exit 206 49 | fi 50 | sleep 0.05 51 | done 52 | 53 | exec<"$TM_BUNDLE_SUPPORT/helpshort.index" 54 | # SAFECNT=0 55 | export token=$("$DIALOG" -a ProgressDialog -p "{title=Rdaemon;isIndeterminate=1;summary='R Documentation';details='Create HTML help pages…';}") 56 | while read line 57 | do 58 | OLDIFS="$IFS" 59 | IFS="/" 60 | data=( $line ) 61 | # fun=$(echo -n $line | cut -d '/' -f2) 62 | # lib=$(echo -n $line | cut -d '/' -f1) 63 | [[ ! -e "$HTMLROOTPATH/${data[0]}" ]] && mkdir -p "$HTMLROOTPATH/${data[0]}" 64 | file="$HTMLROOTPATH/${data[0]}/${data[1]}.html" 65 | if [ ! -e "$file" ]; then 66 | curl -sS "http://127.0.0.1:30815/library/${data[0]}/html/${data[1]}.html" > "$file" 67 | fi 68 | # SAFECNT=$(($SAFECNT+1)) 69 | # [[ $SAFECNT -gt 50 ]] && break 70 | done 71 | "$DIALOG" -x $token 2&>/dev/null 72 | 73 | 74 | sleep .1 75 | echo "q('no')" > /tmp/r_helper_dummy 76 | rm /tmp/r_helper_dummy 77 | rm /tmp/r_helper_dummy_out 78 | -------------------------------------------------------------------------------- /src/rebuild-module-cache.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | async = require 'async' 3 | yargs = require 'yargs' 4 | Command = require './command' 5 | config = require './apm' 6 | fs = require './fs' 7 | 8 | module.exports = 9 | class RebuildModuleCache extends Command 10 | @commandNames: ['rebuild-module-cache'] 11 | 12 | constructor: -> 13 | @atomPackagesDirectory = path.join(config.getAtomDirectory(), 'packages') 14 | 15 | parseOptions: (argv) -> 16 | options = yargs(argv).wrap(100) 17 | options.usage """ 18 | 19 | Usage: apm rebuild-module-cache 20 | 21 | Rebuild the module cache for all the packages installed to 22 | ~/.atom/packages 23 | 24 | You can see the state of the module cache for a package by looking 25 | at the _atomModuleCache property in the package's package.json file. 26 | 27 | This command skips all linked packages. 28 | """ 29 | options.alias('h', 'help').describe('help', 'Print this usage message') 30 | 31 | getResourcePath: (callback) -> 32 | if @resourcePath 33 | process.nextTick => callback(@resourcePath) 34 | else 35 | config.getResourcePath (@resourcePath) => callback(@resourcePath) 36 | 37 | rebuild: (packageDirectory, callback) -> 38 | @getResourcePath (resourcePath) => 39 | try 40 | @moduleCache ?= require(path.join(resourcePath, 'src', 'module-cache')) 41 | @moduleCache.create(packageDirectory) 42 | catch error 43 | return callback(error) 44 | 45 | callback() 46 | 47 | run: (options) -> 48 | {callback} = options 49 | 50 | commands = [] 51 | fs.list(@atomPackagesDirectory).forEach (packageName) => 52 | packageDirectory = path.join(@atomPackagesDirectory, packageName) 53 | return if fs.isSymbolicLinkSync(packageDirectory) 54 | return unless fs.isFileSync(path.join(packageDirectory, 'package.json')) 55 | 56 | commands.push (callback) => 57 | process.stdout.write "Rebuilding #{packageName} module cache " 58 | @rebuild packageDirectory, (error) => 59 | if error? 60 | @logFailure() 61 | else 62 | @logSuccess() 63 | callback(error) 64 | 65 | async.waterfall(commands, callback) 66 | -------------------------------------------------------------------------------- /src/test.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | 3 | yargs = require 'yargs' 4 | temp = require 'temp' 5 | 6 | Command = require './command' 7 | fs = require './fs' 8 | 9 | module.exports = 10 | class Test extends Command 11 | @commandNames: ['test'] 12 | 13 | parseOptions: (argv) -> 14 | options = yargs(argv).wrap(100) 15 | 16 | options.usage """ 17 | Usage: 18 | apm test 19 | 20 | Runs the package's tests contained within the spec directory (relative 21 | to the current working directory). 22 | """ 23 | options.alias('h', 'help').describe('help', 'Print this usage message') 24 | options.alias('p', 'path').string('path').describe('path', 'Path to atom command') 25 | 26 | run: (options) -> 27 | {callback} = options 28 | options = @parseOptions(options.commandArgs) 29 | {env} = process 30 | 31 | atomCommand = options.argv.path if options.argv.path 32 | unless fs.existsSync(atomCommand) 33 | atomCommand = 'atom' 34 | atomCommand += '.cmd' if process.platform is 'win32' 35 | 36 | packagePath = process.cwd() 37 | testArgs = ['--dev', '--test', path.join(packagePath, 'spec')] 38 | 39 | if process.platform is 'win32' 40 | logFile = temp.openSync(suffix: '.log', prefix: "#{path.basename(packagePath)}-") 41 | fs.closeSync(logFile.fd) 42 | logFilePath = logFile.path 43 | testArgs.push("--log-file=#{logFilePath}") 44 | 45 | @spawn atomCommand, testArgs, (code) -> 46 | try 47 | loggedOutput = fs.readFileSync(logFilePath, 'utf8') 48 | process.stdout.write("#{loggedOutput}\n") if loggedOutput 49 | 50 | if code is 0 51 | process.stdout.write 'Tests passed\n'.green 52 | callback() 53 | else if code?.message 54 | callback("Error spawning Atom: #{code.message}") 55 | else 56 | callback('Tests failed') 57 | else 58 | @spawn atomCommand, testArgs, {env, streaming: true}, (code) -> 59 | if code is 0 60 | process.stdout.write 'Tests passed\n'.green 61 | callback() 62 | else if code?.message 63 | callback("Error spawning #{atomCommand}: #{code.message}") 64 | else 65 | callback('Tests failed') 66 | -------------------------------------------------------------------------------- /spec/clean-spec.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | fs = require 'fs-plus' 3 | temp = require 'temp' 4 | express = require 'express' 5 | http = require 'http' 6 | wrench = require 'wrench' 7 | apm = require '../lib/apm-cli' 8 | 9 | describe 'apm clean', -> 10 | [moduleDirectory, server] = [] 11 | 12 | beforeEach -> 13 | silenceOutput() 14 | spyOnToken() 15 | 16 | app = express() 17 | app.get '/node/v0.10.3/node-v0.10.3.tar.gz', (request, response) -> 18 | response.sendfile path.join(__dirname, 'fixtures', 'node-v0.10.3.tar.gz') 19 | app.get '/node/v0.10.3/node.lib', (request, response) -> 20 | response.sendfile path.join(__dirname, 'fixtures', 'node.lib') 21 | app.get '/node/v0.10.3/x64/node.lib', (request, response) -> 22 | response.sendfile path.join(__dirname, 'fixtures', 'node_x64.lib') 23 | app.get '/node/v0.10.3/SHASUMS256.txt', (request, response) -> 24 | response.sendfile path.join(__dirname, 'fixtures', 'SHASUMS256.txt') 25 | app.get '/tarball/test-module-1.0.0.tgz', (request, response) -> 26 | response.sendfile path.join(__dirname, 'fixtures', 'test-module-1.0.0.tgz') 27 | server = http.createServer(app) 28 | server.listen(3000) 29 | 30 | atomHome = temp.mkdirSync('apm-home-dir-') 31 | process.env.ATOM_HOME = atomHome 32 | process.env.ATOM_ELECTRON_URL = "http://localhost:3000/node" 33 | process.env.ATOM_ELECTRON_VERSION = 'v0.10.3' 34 | 35 | moduleDirectory = path.join(temp.mkdirSync('apm-test-module-'), 'test-module-with-dependencies') 36 | wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'test-module-with-dependencies'), moduleDirectory) 37 | process.chdir(moduleDirectory) 38 | 39 | afterEach -> 40 | server.close() 41 | 42 | it 'uninstalls any packages not referenced in the package.json', -> 43 | removedPath = path.join(moduleDirectory, 'node_modules', 'will-be-removed') 44 | fs.makeTreeSync(removedPath) 45 | 46 | callback = jasmine.createSpy('callback') 47 | apm.run(['clean'], callback) 48 | 49 | waitsFor 'waiting for command to complete', -> 50 | callback.callCount > 0 51 | 52 | runs -> 53 | expect(callback.mostRecentCall.args[0]).toBeUndefined() 54 | expect(fs.existsSync(removedPath)).toBeFalsy() 55 | -------------------------------------------------------------------------------- /src/request.coffee: -------------------------------------------------------------------------------- 1 | npm = require 'npm' 2 | request = require 'request' 3 | 4 | config = require './apm' 5 | 6 | loadNpm = (callback) -> 7 | npmOptions = 8 | userconfig: config.getUserConfigPath() 9 | globalconfig: config.getGlobalConfigPath() 10 | npm.load(npmOptions, callback) 11 | 12 | configureRequest = (requestOptions, callback) -> 13 | loadNpm -> 14 | requestOptions.proxy ?= npm.config.get('https-proxy') or npm.config.get('proxy') or process.env.HTTPS_PROXY or process.env.HTTP_PROXY 15 | requestOptions.strictSSL ?= npm.config.get('strict-ssl') 16 | 17 | # Bump request timeout on CI to 30 minutes 18 | requestOptions.timeout = 30 * 60 * 1000 if process.env.JANKY_SHA1 19 | 20 | userAgent = npm.config.get('user-agent') ? "AtomApm/#{require('../package.json').version}" 21 | requestOptions.headers ?= {} 22 | requestOptions.headers['User-Agent'] ?= userAgent 23 | callback() 24 | 25 | module.exports = 26 | get: (requestOptions, callback) -> 27 | configureRequest requestOptions, -> 28 | retryCount = requestOptions.retries ? 0 29 | requestsMade = 0 30 | tryRequest = -> 31 | requestsMade++ 32 | request.get requestOptions, (error, response, body) -> 33 | if retryCount > 0 and error?.code in ['ETIMEDOUT', 'ECONNRESET'] 34 | retryCount-- 35 | tryRequest() 36 | else 37 | if error?.message and requestsMade > 1 38 | error.message += " (#{requestsMade} attempts)" 39 | 40 | callback(error, response, body) 41 | tryRequest() 42 | 43 | del: (requestOptions, callback) -> 44 | configureRequest requestOptions, -> 45 | request.del(requestOptions, callback) 46 | 47 | post: (requestOptions, callback) -> 48 | configureRequest requestOptions, -> 49 | request.post(requestOptions, callback) 50 | 51 | createReadStream: (requestOptions, callback) -> 52 | configureRequest requestOptions, -> 53 | callback(request.get(requestOptions)) 54 | 55 | getErrorMessage: (response, body) -> 56 | if response?.statusCode is 503 57 | 'atom.io is temporarily unavailable, please try again later.' 58 | else 59 | body?.message ? body?.error ? body 60 | 61 | debug: (debug) -> 62 | request.debug = debug 63 | -------------------------------------------------------------------------------- /src/git.coffee: -------------------------------------------------------------------------------- 1 | {spawn} = require 'child_process' 2 | path = require 'path' 3 | _ = require 'underscore-plus' 4 | npm = require 'npm' 5 | config = require './apm' 6 | fs = require './fs' 7 | 8 | addPortableGitToEnv = (env) -> 9 | localAppData = env.LOCALAPPDATA 10 | return unless localAppData 11 | 12 | githubPath = path.join(localAppData, 'GitHub') 13 | 14 | try 15 | children = fs.readdirSync(githubPath) 16 | catch error 17 | return 18 | 19 | for child in children when child.indexOf('PortableGit_') is 0 20 | cmdPath = path.join(githubPath, child, 'cmd') 21 | binPath = path.join(githubPath, child, 'bin') 22 | if env.Path 23 | env.Path += "#{path.delimiter}#{cmdPath}#{path.delimiter}#{binPath}" 24 | else 25 | env.Path = "#{cmdPath}#{path.delimiter}#{binPath}" 26 | break 27 | 28 | return 29 | 30 | addGitBashToEnv = (env) -> 31 | if env.ProgramFiles 32 | gitPath = path.join(env.ProgramFiles, 'Git') 33 | 34 | unless fs.isDirectorySync(gitPath) 35 | if env['ProgramFiles(x86)'] 36 | gitPath = path.join(env['ProgramFiles(x86)'], 'Git') 37 | 38 | return unless fs.isDirectorySync(gitPath) 39 | 40 | cmdPath = path.join(gitPath, 'cmd') 41 | binPath = path.join(gitPath, 'bin') 42 | if env.Path 43 | env.Path += "#{path.delimiter}#{cmdPath}#{path.delimiter}#{binPath}" 44 | else 45 | env.Path = "#{cmdPath}#{path.delimiter}#{binPath}" 46 | 47 | exports.addGitToEnv = (env) -> 48 | return if process.platform isnt 'win32' 49 | addPortableGitToEnv(env) 50 | addGitBashToEnv(env) 51 | 52 | exports.getGitVersion = (callback) -> 53 | npmOptions = 54 | userconfig: config.getUserConfigPath() 55 | globalconfig: config.getGlobalConfigPath() 56 | npm.load npmOptions, -> 57 | git = npm.config.get('git') ? 'git' 58 | exports.addGitToEnv(process.env) 59 | spawned = spawn(git, ['--version']) 60 | outputChunks = [] 61 | spawned.stderr.on 'data', (chunk) -> outputChunks.push(chunk) 62 | spawned.stdout.on 'data', (chunk) -> outputChunks.push(chunk) 63 | spawned.on 'error', -> 64 | spawned.on 'close', (code) -> 65 | if code is 0 66 | [gitName, versionName, version] = Buffer.concat(outputChunks).toString().split(' ') 67 | version = version?.trim() 68 | callback(version) 69 | -------------------------------------------------------------------------------- /spec/view-spec.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | express = require 'express' 3 | http = require 'http' 4 | apm = require '../lib/apm-cli' 5 | 6 | describe 'apm view', -> 7 | server = null 8 | 9 | beforeEach -> 10 | silenceOutput() 11 | spyOnToken() 12 | 13 | app = express() 14 | app.get '/wrap-guide', (request, response) -> 15 | response.sendfile path.join(__dirname, 'fixtures', 'wrap-guide.json') 16 | server = http.createServer(app) 17 | server.listen(3000) 18 | 19 | process.env.ATOM_PACKAGES_URL = "http://localhost:3000" 20 | 21 | afterEach -> 22 | server.close() 23 | 24 | it 'displays information about the package', -> 25 | callback = jasmine.createSpy('callback') 26 | apm.run(['view', 'wrap-guide'], callback) 27 | 28 | waitsFor 'waiting for view to complete', -> 29 | callback.callCount > 0 30 | 31 | runs -> 32 | expect(console.log).toHaveBeenCalled() 33 | expect(console.log.argsForCall[0][0]).toContain 'wrap-guide' 34 | expect(console.log.argsForCall[1][0]).toContain '0.14.0' 35 | expect(console.log.argsForCall[2][0]).toContain 'https://github.com/atom/wrap-guide' 36 | expect(console.log.argsForCall[3][0]).toContain 'new version' 37 | 38 | it "logs an error if the package name is missing or empty", -> 39 | callback = jasmine.createSpy('callback') 40 | apm.run(['view'], callback) 41 | 42 | waitsFor 'waiting for view to complete', -> 43 | callback.callCount > 0 44 | 45 | runs -> 46 | expect(console.error).toHaveBeenCalled() 47 | expect(console.error.argsForCall[0][0].length).toBeGreaterThan 0 48 | 49 | describe "when a compatible Atom version is specified", -> 50 | it "displays the latest compatible version of the package", -> 51 | callback = jasmine.createSpy('callback') 52 | apm.run(['view', 'wrap-guide', '--compatible', '1.5.0'], callback) 53 | 54 | waitsFor 'waiting for view to complete', 600000, -> 55 | callback.callCount is 1 56 | 57 | runs -> 58 | expect(console.log.argsForCall[0][0]).toContain 'wrap-guide' 59 | expect(console.log.argsForCall[1][0]).toContain '0.3.0' 60 | expect(console.log.argsForCall[2][0]).toContain 'https://github.com/atom2/wrap-guide' 61 | expect(console.log.argsForCall[3][0]).toContain 'old version' 62 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/tests/testHistoryList.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | require '../lib/historyList.rb' 3 | class TestHistoryList < Test::Unit::TestCase 4 | def setup 5 | @sample = File.read("historyTestFile.Rconsole") 6 | test_init 7 | end 8 | def test_init 9 | assert_nothing_raised() { @list = HistoryList.new(@sample) } 10 | assert_not_nil(@list) 11 | assert_not_nil(@list.list) 12 | assert_not_nil(@list.last_line) 13 | assert_equal(@sample, @list.text + "> ") 14 | end 15 | def test_uniqueness 16 | assert_equal(3, @list.list.length) 17 | assert_equal(["second command","first command","third command"],@list.list) 18 | end 19 | def test_last_line 20 | assert_equal("> ",@list.last_line) 21 | end 22 | def test_add_line 23 | assert_equal(@sample + "hey", @list.add_line("> hey")) 24 | end 25 | def test_next_item 26 | assert_equal("first command", @list.next_item("second command")) 27 | assert_equal("first command", @list.next_item(">second command")) 28 | assert_equal("third command", @list.next_item("first command")) 29 | assert_equal("third command", @list.next_item("> first command")) 30 | assert_equal(nil, @list.next_item("third command")) 31 | assert_equal("second command", @list.next_item(" ")) 32 | assert_equal("second command", @list.next_item("> ")) 33 | assert_equal("second command", @list.next_item("")) 34 | assert_equal("second command", @list.next_item(nil)) 35 | end 36 | def test_previous_item 37 | assert_equal("second command", @list.previous_item("first command")) 38 | assert_equal("second command", @list.previous_item(">first command")) 39 | assert_equal("first command", @list.previous_item("third command")) 40 | assert_equal("first command", @list.previous_item("> third command")) 41 | assert_equal(nil, @list.previous_item("second command")) 42 | assert_equal("third command", @list.previous_item(" ")) 43 | assert_equal("third command", @list.previous_item("> ")) 44 | assert_equal("third command", @list.previous_item("")) 45 | assert_equal("third command", @list.previous_item(nil)) 46 | end 47 | def test_move_commands 48 | assert_equal(@sample + "second command", @list.move_down) 49 | assert_equal(@sample + "third command",@list.move_up) 50 | assert_equal(@sample,HistoryList.move_down(@list.move_up)) 51 | end 52 | end -------------------------------------------------------------------------------- /src/rebuild.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | 3 | _ = require 'underscore-plus' 4 | yargs = require 'yargs' 5 | 6 | config = require './apm' 7 | Command = require './command' 8 | Install = require './install' 9 | 10 | module.exports = 11 | class Rebuild extends Command 12 | @commandNames: ['rebuild'] 13 | 14 | constructor: -> 15 | @atomNodeDirectory = path.join(config.getAtomDirectory(), '.node-gyp') 16 | @atomNpmPath = require.resolve('npm/bin/npm-cli') 17 | 18 | parseOptions: (argv) -> 19 | options = yargs(argv).wrap(100) 20 | options.usage """ 21 | 22 | Usage: apm rebuild [ [ ...]] 23 | 24 | Rebuild the given modules currently installed in the node_modules folder 25 | in the current working directory. 26 | 27 | All the modules will be rebuilt if no module names are specified. 28 | """ 29 | options.alias('h', 'help').describe('help', 'Print this usage message') 30 | 31 | installNode: (callback) -> 32 | config.loadNpm (error, npm) -> 33 | install = new Install() 34 | install.npm = npm 35 | install.loadInstalledAtomMetadata -> install.installNode(callback) 36 | 37 | forkNpmRebuild: (options, callback) -> 38 | process.stdout.write 'Rebuilding modules ' 39 | 40 | rebuildArgs = [ 41 | '--globalconfig' 42 | config.getGlobalConfigPath() 43 | '--userconfig' 44 | config.getUserConfigPath() 45 | 'rebuild' 46 | '--runtime=electron' 47 | "--target=#{@electronVersion}" 48 | "--arch=#{config.getElectronArch()}" 49 | ] 50 | rebuildArgs = rebuildArgs.concat(options.argv._) 51 | 52 | if vsArgs = @getVisualStudioFlags() 53 | rebuildArgs.push(vsArgs) 54 | 55 | env = _.extend({}, process.env, HOME: @atomNodeDirectory) 56 | env.USERPROFILE = env.HOME if config.isWin32() 57 | @addBuildEnvVars(env) 58 | 59 | @fork(@atomNpmPath, rebuildArgs, {env}, callback) 60 | 61 | run: (options) -> 62 | {callback} = options 63 | options = @parseOptions(options.commandArgs) 64 | 65 | config.loadNpm (error, @npm) => 66 | @loadInstalledAtomMetadata => 67 | @installNode (error) => 68 | return callback(error) if error? 69 | 70 | @forkNpmRebuild options, (code, stderr='') => 71 | if code is 0 72 | @logSuccess() 73 | callback() 74 | else 75 | @logFailure() 76 | callback(stderr) 77 | -------------------------------------------------------------------------------- /src/login.coffee: -------------------------------------------------------------------------------- 1 | _ = require 'underscore-plus' 2 | yargs = require 'yargs' 3 | Q = require 'q' 4 | read = require 'read' 5 | open = require 'open' 6 | 7 | auth = require './auth' 8 | Command = require './command' 9 | 10 | module.exports = 11 | class Login extends Command 12 | @getTokenOrLogin: (callback) -> 13 | auth.getToken (error, token) -> 14 | if error? 15 | new Login().run({callback, commandArgs: []}) 16 | else 17 | callback(null, token) 18 | 19 | @commandNames: ['login'] 20 | 21 | parseOptions: (argv) -> 22 | options = yargs(argv).wrap(100) 23 | 24 | options.usage """ 25 | Usage: apm login 26 | 27 | Enter your Atom.io API token and save it to the keychain. This token will 28 | be used to identify you when publishing packages to atom.io. 29 | """ 30 | options.alias('h', 'help').describe('help', 'Print this usage message') 31 | options.string('token').describe('token', 'atom.io API token') 32 | 33 | run: (options) -> 34 | {callback} = options 35 | options = @parseOptions(options.commandArgs) 36 | Q(token: options.argv.token) 37 | .then(@welcomeMessage) 38 | .then(@openURL) 39 | .then(@getToken) 40 | .then(@saveToken) 41 | .then (token) -> callback(null, token) 42 | .catch(callback) 43 | 44 | prompt: (options) -> 45 | readPromise = Q.denodeify(read) 46 | readPromise(options) 47 | 48 | welcomeMessage: (state) => 49 | return Q(state) if state.token 50 | 51 | welcome = """ 52 | Welcome to Atom! 53 | 54 | Before you can publish packages, you'll need an API token. 55 | 56 | Visit your account page on Atom.io #{'https://atom.io/account'.underline}, 57 | copy the token and paste it below when prompted. 58 | 59 | """ 60 | console.log welcome 61 | 62 | @prompt({prompt: "Press [Enter] to open your account page on Atom.io."}) 63 | 64 | openURL: (state) -> 65 | return Q(state) if state.token 66 | 67 | open('https://atom.io/account') 68 | 69 | getToken: (state) => 70 | return Q(state) if state.token 71 | 72 | @prompt({prompt: 'Token>', edit: true}) 73 | .spread (token) -> 74 | state.token = token 75 | Q(state) 76 | 77 | saveToken: ({token}) => 78 | throw new Error("Token is required") unless token 79 | 80 | process.stdout.write('Saving token to Keychain ') 81 | auth.saveToken(token) 82 | @logSuccess() 83 | Q(token) 84 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/RhelperScript.R: -------------------------------------------------------------------------------- 1 | TM_RdaemongetHelpURL <- function(x,...) { 2 | if(getRversion()>='2.10.0') { 3 | a<-gsub(".*/library/(.*?)/.*?/(.*?)(\\.html|$)",paste("http://127.0.0.1:",ifelse(tools:::httpdPort<1,tools::startDynamicHelp(T),tools:::httpdPort),"/library/\\1/html/\\2.html",sep=""),as.vector(help(x,try.all.packages=T,...)),perl=T) 4 | ifelse(length(a),cat(a,sep='\n'),cat("NA",sep='')) 5 | } else { 6 | a<-gsub("(.*?)/library/(.*?)/.*?/(.*?)(\\.html|$)","\\1/library/\\2/html/\\3.html",as.vector(help(x,try.all.packages=T,...)),perl=T) 7 | ifelse(length(a),cat(a,sep='\n'),cat("NA",sep='')) 8 | } 9 | } 10 | 11 | TM_RdaemongetHttpPort <- function() cat(ifelse(getRversion()>='2.10.0',ifelse(tools:::httpdPort<1,tools::startDynamicHelp(T),tools:::httpdPort),-2)) 12 | TM_RdaemongetSearchHelp <- function(x,ic=T) { 13 | if (getRversion()>='2.10.0') { 14 | p<-ifelse(tools:::httpdPort<1,tools::startDynamicHelp(T),tools:::httpdPort) 15 | a<-help.search(x,ignore.case=ic)[[4]][,c(3,1)] 16 | if(length(a)>0){ 17 | if(is.null(dim(a))) {a<-matrix(a,ncol=2)} 18 | cat(sort(apply(a,1,function(x) { 19 | h<-gsub(".*/library/(.*?)/.*?/(.*?)(\\.html|$)",paste("http://127.0.0.1:",p,"/library/\\1/html/\\2.html",sep=""),help(x[2],package=x[1])[1],perl=T) 20 | paste(c(x[1],x[2],h),collapse='\t')})),sep='\n') 21 | } else { 22 | cat("NA",sep='') 23 | } 24 | } else { 25 | a<-help.search(x,ignore.case=ic)[[4]][,c(3,1)] 26 | if(length(a)>0){ 27 | if(is.null(dim(a))) {a<-matrix(a,ncol=2)} 28 | cat(sort(apply(a,1,function(x) { 29 | h<-gsub("(.*?)/library/(.*?)/.*?/(.*?)(\\.html|$)","\\1/library/\\2/html/\\3.html",help(x[2],package=x[1])[1],perl=T) 30 | paste(c(x[1],x[2],h),collapse='\t')})),sep='\n') 31 | } else { 32 | cat("NA",sep='') 33 | } 34 | } 35 | } 36 | TM_RdaemongetInstalledPackages <- function() cat(installed.packages()[,1],sep='\n') 37 | TM_RdaemongetLoadedPackages <- function() cat(sort(.packages()),sep='\n') 38 | TM_RdaemongetPackageFor <- function(x) cat(help.search(paste("^",x,"$",sep=""),ignore.case=F)[[4]][,3],sep='\n') 39 | TM_RdaemongetCompletionList <- function(x,ic=F) { 40 | invisible(help.search("^§!#%$"));db<-utils:::.hsearch_db() 41 | a<-db$Alias[grep(paste("^",x,sep=""),db$Alias[,1],ignore.case=ic,perl=T),c(1,3)] 42 | if(is.null(dim(a))) {a<-matrix(a,ncol=2)} 43 | a<-a[grep("[<,]|-(class|package|method(s)?)|TM_Rdaemon",a[,1],invert=T),] 44 | if(is.null(dim(a))) {a<-matrix(a,ncol=2)} 45 | cat(sort(apply(a,1,function(x)paste(c(x[1],x[2]),collapse='\t'))),sep='\n') 46 | } 47 | -------------------------------------------------------------------------------- /spec/rebuild-spec.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | CSON = require 'season' 3 | fs = require 'fs-plus' 4 | temp = require 'temp' 5 | express = require 'express' 6 | http = require 'http' 7 | wrench = require 'wrench' 8 | apm = require '../lib/apm-cli' 9 | 10 | describe 'apm rebuild', -> 11 | [server, originalPathEnv] = [] 12 | 13 | beforeEach -> 14 | spyOnToken() 15 | silenceOutput() 16 | 17 | app = express() 18 | app.get '/node/v0.10.3/node-v0.10.3.tar.gz', (request, response) -> 19 | response.sendfile path.join(__dirname, 'fixtures', 'node-v0.10.3.tar.gz') 20 | app.get '/node/v0.10.3/node.lib', (request, response) -> 21 | response.sendfile path.join(__dirname, 'fixtures', 'node.lib') 22 | app.get '/node/v0.10.3/x64/node.lib', (request, response) -> 23 | response.sendfile path.join(__dirname, 'fixtures', 'node_x64.lib') 24 | app.get '/node/v0.10.3/SHASUMS256.txt', (request, response) -> 25 | response.sendfile path.join(__dirname, 'fixtures', 'SHASUMS256.txt') 26 | 27 | server = http.createServer(app) 28 | server.listen(3000) 29 | 30 | atomHome = temp.mkdirSync('apm-home-dir-') 31 | process.env.ATOM_HOME = atomHome 32 | process.env.ATOM_ELECTRON_URL = "http://localhost:3000/node" 33 | process.env.ATOM_PACKAGES_URL = "http://localhost:3000/packages" 34 | process.env.ATOM_ELECTRON_VERSION = 'v0.10.3' 35 | process.env.ATOM_RESOURCE_PATH = temp.mkdirSync('atom-resource-path-') 36 | 37 | originalPathEnv = process.env.PATH 38 | process.env.PATH = "" 39 | 40 | afterEach -> 41 | server.close() 42 | process.env.PATH = originalPathEnv 43 | 44 | it "rebuilds all modules when no module names are specified", -> 45 | packageToRebuild = path.join(__dirname, 'fixtures/package-with-native-deps') 46 | 47 | process.chdir(packageToRebuild) 48 | callback = jasmine.createSpy('callback') 49 | apm.run(['rebuild'], callback) 50 | 51 | waitsFor 'waiting for rebuild to complete', 600000, -> 52 | callback.callCount is 1 53 | 54 | runs -> 55 | expect(callback.mostRecentCall.args[0]).toBeUndefined() 56 | 57 | it "rebuilds the specified modules", -> 58 | packageToRebuild = path.join(__dirname, 'fixtures/package-with-native-deps') 59 | 60 | process.chdir(packageToRebuild) 61 | callback = jasmine.createSpy('callback') 62 | apm.run(['rebuild', 'native-dep'], callback) 63 | 64 | waitsFor 'waiting for rebuild to complete', 600000, -> 65 | callback.callCount is 1 66 | 67 | runs -> 68 | expect(callback.mostRecentCall.args[0]).toBeUndefined() 69 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/require-current-function.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | [[ -n "$TM_SELECTED_TEXT" ]] && echo "Please unselect first." && exit_show_tool_tip 9 | 10 | LINE=$(cat | perl -e ' 11 | $line=$ENV{"TM_CURRENT_LINE"};$col=$ENV{"TM_LINE_INDEX"}; 12 | $lineL=substr($line,0,$col); 13 | $lineR=substr($line,$col); 14 | $lineL=~s/(?=[\$`\\])/\\/g; 15 | $lineR=~s/(?=[\$`\\])/\\/g; 16 | print "$lineL\${0:}$lineR"; 17 | ') 18 | WORD=$(/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -- <<-SCR1 19 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/current_word.rb") 20 | word = Word.current_word('\w._\(') 21 | print word 22 | SCR1 23 | ) 24 | 25 | WORD=$(echo -en "$WORD" | perl -pe 's/\([^\(]*$//') 26 | 27 | [[ -z "$WORD" ]] && echo "No keyword found" && exit_show_tool_tip 28 | 29 | "$TM_BUNDLE_SUPPORT"/bin/askRhelperDaemon.sh "@getPackageFor('$WORD')" 30 | LIB=$(cat /tmp/textmate_Rhelper_out) 31 | if [ -z "$LIB" ]; then 32 | echo -en "No package found." 33 | exit 206 34 | fi 35 | 36 | if [ `echo "$LIB" | wc -l` -gt 1 ]; then 37 | LIB=$(echo "$LIB" | sort -f | /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -e ' 38 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/ui.rb") 39 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/exit_codes.rb") 40 | words = STDIN.read().split("\n") 41 | index=TextMate::UI.menu(words) 42 | if index != nil 43 | print words[index] 44 | end 45 | ') 46 | fi 47 | 48 | if [ `echo -n "$TM_SCOPE" | grep -c -F 'source.rd.console'` -gt 0 ]; then 49 | echo -en "> require($LIB); " 50 | echo -n "$LINE" | sed 's/^> //' 51 | else 52 | TABS=$(echo -en "$LINE" | perl -e '$a=<>;$a=~m/^([\t ]+)/;print $1 if defined($1)') 53 | echo -en "$TABS" 54 | echo -e "require($LIB)" 55 | echo -n "$LINE" 56 | fi 57 | 58 | 59 | fallbackInput 60 | line 61 | input 62 | selection 63 | keyEquivalent 64 | ^L 65 | name 66 | “require(xxx)” for current Function 67 | output 68 | insertAsSnippet 69 | scope 70 | source.r, source.rd.console 71 | uuid 72 | 8D7F64A5-B2C5-4BF1-B7C5-352CF6AAEF28 73 | 74 | 75 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Commands/par-params.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | export WORD="par" 9 | 10 | "$TM_BUNDLE_SUPPORT"/bin/initCommandArgsDir.sh 11 | if [ -e "$TM_BUNDLE_SUPPORT"/lib/command_args/$WORD ]; then 12 | export RES=$(cat "$TM_BUNDLE_SUPPORT"/lib/command_args/$WORD | perl -pe 's/\|/:/g;s/,/\|/g;s/\n/,/g;s/ //g;') 13 | fi 14 | 15 | #if no parameter quit 16 | [[ -z "$RES" ]] && exit_discard 17 | 18 | #show all parameters as inline menu and insert the parameter as snippet (if '=' is found only the value) 19 | /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -- <<-SCRIPT 20 | # 2> /dev/null 21 | require File.join(ENV["TM_SUPPORT_PATH"], "lib/exit_codes.rb") 22 | require "#{ENV["TM_SUPPORT_PATH"]}/lib/ui" 23 | word = "$WORD" 24 | text = ENV["RES"] 25 | funs = text.split(",") 26 | funs.collect! {|x| x.gsub(/\|/, ", ").gsub(/=/, " = ").gsub(/:/, "|")} 27 | 28 | TextMate.exit_discard if funs.size < 1 29 | 30 | if funs.size == 1 31 | function = funs.first 32 | else 33 | idx = TextMate::UI.menu(funs) 34 | TextMate.exit_discard if idx.nil? 35 | function = funs[idx] 36 | end 37 | TextMate.exit_discard if function.empty? 38 | curword = ENV['TM_CURRENT_WORD'] 39 | comma="" 40 | if ! curword.match(",") && ! curword.match('\( *\)+$') 41 | comma = "\${200:, }" 42 | end 43 | 44 | if function.match("=") 45 | arr = function.gsub(/ = /, "=").split('=') 46 | if arr[1].match("\"") 47 | print "#{comma}#{arr[0]} = \"\${1:#{arr[1].gsub(/\"/, "")}}\"\${300:}" 48 | else 49 | if arr[1].match("^c\(.*?\)$") 50 | subarr = arr[1].gsub(/^c\(/, "").gsub(/\)$/,"").gsub(/ /,"").split(",") 51 | for i in (0..(subarr.size - 1)) 52 | subarr[i] = "\${#{i+2}:#{subarr[i]}}" 53 | end 54 | print "#{comma}#{arr[0]} = \${1:c(#{subarr.join(", ")})}\${300:}" 55 | else 56 | print "#{comma}#{arr[0]} = \${1:#{arr[1]}}\${30:}" 57 | end 58 | end 59 | else 60 | print "#{comma}\${1:#{function}}\${3:}" 61 | end 62 | SCRIPT 63 | 64 | fallbackInput 65 | none 66 | input 67 | none 68 | keyEquivalent 69 | ^; 70 | name 71 | “par()” Parameters… 72 | output 73 | insertAsSnippet 74 | scope 75 | source.r, source.rd.console 76 | uuid 77 | 38BD6CA7-0916-43BD-88C9-CBFC4ED17FDE 78 | 79 | 80 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/bin/RhelperDaemon.rb: -------------------------------------------------------------------------------- 1 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -KU 2 | 3 | ################################### 4 | # 5 | # R daemon for as Helper 6 | # 7 | # written by Hans-Jörg Bibiko - bibiko@eva.mpg.de 8 | ################################### 9 | 10 | require 'pty' 11 | require 'fileutils' 12 | 13 | $pipe_in = "/tmp/textmate_Rhelper_in" 14 | $pipe_out = "/tmp/textmate_Rhelper_out" 15 | $pipe_status = "/tmp/textmate_Rhelper_status" 16 | $pipe_console = "/tmp/textmate_Rhelper_console" 17 | 18 | # check for valid TM_REXEC; if not use "R" 19 | if ENV['TM_REXEC'] != nil 20 | check = %x{which #{ENV['TM_REXEC']}} 21 | if check == "" 22 | %x{osascript -e 'tell app "TextMate" to display dialog "Please check TM_REXEC shell variable! “#{ENV['TM_REXEC']}” in PATH not found! Using “R” instead." buttons "OK" default button "OK"'} 23 | ENV['TM_REXEC'] = nil 24 | end 25 | end 26 | 27 | cmd = "#{(ENV['TM_REXEC']==nil) ? 'R' : ENV['TM_REXEC']} -q --vanilla --encoding=UTF-8 --TMRHelperDaemon 2&> '#{$pipe_console}'" 28 | 29 | FileUtils.rm_f($pipe_out) 30 | FileUtils.rm_f($pipe_status) 31 | FileUtils.rm_f($pipe_console) 32 | 33 | %x{echo -en "TM_RHelper" > /tmp/textmate_Rhelper_status} 34 | %x{echo -en "TM_RHelper" > /tmp/textmate_Rhelper_out} 35 | 36 | PTY.spawn(cmd) { |r,w,pid| 37 | 38 | r.sync = FALSE 39 | 40 | # write r to the nirvana 41 | Thread.new { 42 | r.read 43 | } 44 | 45 | # Thread to destroy daemon after quitting TextMate 46 | Thread.new do 47 | # Check if TextMate is still running; if not terminate Help Daemon 48 | while TRUE 49 | sleep 10 50 | break if %x{ps -ax | grep "[0-9] /.*app.*/TextMate" | cut -d ' ' -f2}.empty? 51 | end 52 | w.puts("q('no')") 53 | FileUtils.rm_f($pipe_in) 54 | FileUtils.rm_f($pipe_out) 55 | FileUtils.rm_f($pipe_status) 56 | FileUtils.rm_f($pipe_console) 57 | FileUtils.rm_f("/tmp/textmate_Rhelper_head.html") 58 | FileUtils.rm_f("/tmp/textmate_Rhelper_data.html") 59 | FileUtils.rm_f("/tmp/textmate_Rhelper_search.html") 60 | end 61 | 62 | $fin = File.open($pipe_in, "r+") 63 | 64 | w.puts "source('RhelperScript.R')" 65 | 66 | %x{echo -en "STARTED" > '#{$pipe_status}'} 67 | 68 | while TRUE 69 | task = $fin.gets.chomp 70 | %x{echo -en "BUSY" > '#{$pipe_status}'} 71 | if task[0,1] == "@" 72 | w.puts "sink('/tmp/textmate_Rhelper_out');TM_Rdaemon#{task[1..-1]};sink(file=NULL);cat('READY',file='#{$pipe_status}',sep='')" 73 | else 74 | w.puts "sink('/tmp/textmate_Rhelper_out');#{task};sink(file=NULL);cat('READY',file='#{$pipe_status}',sep='')" 75 | end 76 | w.puts "cat('READY',file='#{$pipe_status}',sep='');while(sink.number()>0){sink(file=NULL)}" 77 | end 78 | } 79 | -------------------------------------------------------------------------------- /spec/test-spec.coffee: -------------------------------------------------------------------------------- 1 | child_process = require 'child_process' 2 | fs = require 'fs' 3 | path = require 'path' 4 | temp = require 'temp' 5 | apm = require '../lib/apm-cli' 6 | 7 | describe "apm test", -> 8 | [specPath] = [] 9 | 10 | beforeEach -> 11 | silenceOutput() 12 | spyOnToken() 13 | 14 | currentDir = temp.mkdirSync('apm-init-') 15 | spyOn(process, 'cwd').andReturn(currentDir) 16 | specPath = path.join(currentDir, 'spec') 17 | 18 | it "calls atom to test", -> 19 | atomSpawn = spyOn(child_process, 'spawn').andReturn 20 | stdout: 21 | on: -> 22 | stderr: 23 | on: -> 24 | on: -> 25 | apm.run(['test']) 26 | 27 | waitsFor 'waiting for test to complete', -> 28 | atomSpawn.callCount is 1 29 | 30 | runs -> 31 | if process.platform is 'win32' 32 | expect(atomSpawn.mostRecentCall.args[1][2].indexOf('atom')).not.toBe -1 33 | expect(atomSpawn.mostRecentCall.args[1][2].indexOf('--dev')).not.toBe -1 34 | expect(atomSpawn.mostRecentCall.args[1][2].indexOf('--test')).not.toBe -1 35 | else 36 | expect(atomSpawn.mostRecentCall.args[0]).toEqual 'atom' 37 | expect(atomSpawn.mostRecentCall.args[1][0]).toEqual '--dev' 38 | expect(atomSpawn.mostRecentCall.args[1][1]).toEqual '--test' 39 | expect(atomSpawn.mostRecentCall.args[1][2]).toEqual specPath 40 | expect(atomSpawn.mostRecentCall.args[2].streaming).toBeTruthy() 41 | 42 | describe 'returning', -> 43 | [callback] = [] 44 | 45 | returnWithCode = (type, code) -> 46 | callback = jasmine.createSpy('callback') 47 | atomReturnFn = (e, fn) -> fn(code) if e is type 48 | spyOn(child_process, 'spawn').andReturn 49 | stdout: 50 | on: -> 51 | stderr: 52 | on: -> 53 | on: atomReturnFn 54 | removeListener: -> # no op 55 | apm.run(['test'], callback) 56 | 57 | describe 'successfully', -> 58 | beforeEach -> returnWithCode('close', 0) 59 | 60 | it "prints success", -> 61 | expect(callback).toHaveBeenCalled() 62 | expect(callback.mostRecentCall.args[0]).toBeUndefined() 63 | expect(process.stdout.write.mostRecentCall.args[0]).toEqual 'Tests passed\n'.green 64 | 65 | describe 'with a failure', -> 66 | beforeEach -> returnWithCode('close', 1) 67 | 68 | it "prints failure", -> 69 | expect(callback).toHaveBeenCalled() 70 | expect(callback.mostRecentCall.args[0]).toEqual 'Tests failed' 71 | 72 | describe 'with an error', -> 73 | beforeEach -> returnWithCode('error') 74 | 75 | it "prints failure", -> 76 | expect(callback).toHaveBeenCalled() 77 | expect(callback.mostRecentCall.args[0]).toEqual 'Tests failed' 78 | --------------------------------------------------------------------------------