├── .gitattributes ├── .github ├── no-response.yml └── workflows │ └── CI.yml ├── .gitignore ├── .npmignore ├── .pairs ├── BUNDLED_NODE_VERSION ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── LICENSE.md ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── appveyor.yml ├── bin ├── apm ├── apm.cmd ├── npm └── npm.cmd ├── coffeelint.json ├── deprecated-packages.json ├── native-module ├── .gitignore ├── binding.gyp ├── index.js ├── package.json └── src │ └── native.cc ├── package-lock.json ├── package.json ├── script ├── bundled-node-version.js ├── check-version.js ├── download-node.js ├── postinstall.cmd ├── postinstall.js └── postinstall.sh ├── spec ├── apm-cli-spec.coffee ├── ci-spec.coffee ├── clean-spec.coffee ├── command-spec.coffee ├── config-spec.coffee ├── develop-spec.coffee ├── disable-spec.coffee ├── docs-spec.coffee ├── enable-spec.coffee ├── featured-spec.coffee ├── fixtures │ ├── Bad.tmTheme │ ├── Dawn.tmTheme │ ├── SHASUMS256.txt │ ├── atom-2048.json │ ├── available.json │ ├── install-locked-version.json │ ├── install-multi-version.json │ ├── install-test-module-with-bin.json │ ├── install-test-module-with-symlink.json │ ├── install-test-module.json │ ├── install-test-module2.json │ ├── native-module-1.0.0.tgz │ ├── native-module.json │ ├── native-package-1.0.0.tar.gz │ ├── native-package.json │ ├── node-v10.20.1-headers.tar.gz │ ├── node-v10.20.1.tar.gz │ ├── node.lib │ ├── node_x64.lib │ ├── package-with-native-deps │ │ ├── index.js │ │ └── package.json │ ├── packages.json │ ├── packages.txt │ ├── r.tmbundle │ │ ├── Commands │ │ │ ├── CRAN Packages.tmCommand │ │ │ ├── Completion….tmCommand │ │ │ ├── Copy Result into Pasteboard.tmCommand │ │ │ ├── Create Matrix from Selection.tmCommand │ │ │ ├── Create Vector from Selection.tmCommand │ │ │ ├── Descriptives….tmCommand │ │ │ ├── Edit user-defined Function Parameter.tmCommand │ │ │ ├── Function Call.tmCommand │ │ │ ├── Function Definition.tmCommand │ │ │ ├── Help.tmCommand │ │ │ ├── Insert Result.tmCommand │ │ │ ├── Package Name….tmCommand │ │ │ ├── Plots….tmCommand │ │ │ ├── Prefix Package Name current Function.tmCommand │ │ │ ├── R_app.tmCommand │ │ │ ├── Rd Insert arguments tag.tmCommand │ │ │ ├── Rd Preview as HTML.tmCommand │ │ │ ├── Rdaemon.tmCommand │ │ │ ├── Show File Header.tmCommand │ │ │ ├── Show Function Usage.tmCommand │ │ │ ├── Show R Documentation.tmCommand │ │ │ ├── Show Result as Tooltip.tmCommand │ │ │ ├── Summaries….tmCommand │ │ │ ├── Terminate Helper Daemon.tmCommand │ │ │ ├── Tidy.tmCommand │ │ │ ├── arrow-left.tmCommand │ │ │ ├── evaluate-selector.tmCommand │ │ │ ├── load-library-using-library.tmCommand │ │ │ ├── load-library-using-require.tmCommand │ │ │ ├── option-list.tmCommand │ │ │ ├── par-params.tmCommand │ │ │ ├── r-site-search.tmCommand │ │ │ ├── require-current-function.tmCommand │ │ │ ├── run-selector.tmCommand │ │ │ ├── show-word-help.tmCommand │ │ │ └── web-search.tmCommand │ │ ├── DragCommands │ │ │ ├── load.tmDragCommand │ │ │ ├── read_csv.tmDragCommand │ │ │ ├── read_spss.tmDragCommand │ │ │ ├── read_table.tmDragCommand │ │ │ └── source.tmDragCommand │ │ ├── Macros │ │ │ ├── function-params.tmMacro │ │ │ ├── next-list-element.tmMacro │ │ │ ├── previous-list-element.tmMacro │ │ │ └── show-function-usage.tmMacro │ │ ├── Preferences │ │ │ ├── Comments.plist │ │ │ ├── Indentation Rules.tmPreferences │ │ │ ├── Methods.tmPreferences │ │ │ ├── folding-docs.tmPreferences │ │ │ ├── folding-r.tmPreferences │ │ │ ├── symbol-list1.tmPreferences │ │ │ └── symbol-list2.tmPreferences │ │ ├── README.mdown │ │ ├── Snippets │ │ │ ├── Add Tick Marks.tmSnippet │ │ │ ├── Attach.tmSnippet │ │ │ ├── Cummulative.tmSnippet │ │ │ ├── Density.tmSnippet │ │ │ ├── Detach.tmSnippet │ │ │ ├── Divide Into Intervals.tmSnippet │ │ │ ├── Factor.tmSnippet │ │ │ ├── For Loop.tmSnippet │ │ │ ├── Function.tmSnippet │ │ │ ├── Ifelse.tmSnippet │ │ │ ├── Length.tmSnippet │ │ │ ├── Load Dataset.tmSnippet │ │ │ ├── Polygonal Line.tmSnippet │ │ │ ├── Read From File.tmSnippet │ │ │ ├── Sequence (from,to,by).tmSnippet │ │ │ ├── Sort.tmSnippet │ │ │ ├── Source.tmSnippet │ │ │ ├── escaped-dollar.tmSnippet │ │ │ ├── file_choose.tmSnippet │ │ │ └── na_omit.tmSnippet │ │ ├── Support │ │ │ ├── Rmate.css │ │ │ ├── bin │ │ │ │ ├── ProcessHelpFiles.rb │ │ │ │ ├── RhelperDaemon.rb │ │ │ │ ├── RhelperScript.R │ │ │ │ ├── Rsearch.sh │ │ │ │ ├── askRhelperDaemon.sh │ │ │ │ ├── auto_show_func_usage.sh │ │ │ │ ├── initCommandArgsDir.sh │ │ │ │ ├── insert_command_template.rb │ │ │ │ ├── insert_function_param.sh │ │ │ │ ├── insert_package_name.sh │ │ │ │ ├── parseDocForFunctions.sh │ │ │ │ ├── parseHTMLForUsage.sh │ │ │ │ ├── prefix_package_name.sh │ │ │ │ ├── startRhelperDaemon.sh │ │ │ │ └── startRhelperbuilder.sh │ │ │ ├── getSig.R │ │ │ ├── getSigTest.R │ │ │ ├── lib │ │ │ │ ├── command_args │ │ │ │ │ ├── dist │ │ │ │ │ ├── getOption │ │ │ │ │ ├── lines │ │ │ │ │ ├── mean │ │ │ │ │ ├── options │ │ │ │ │ ├── par │ │ │ │ │ ├── plot │ │ │ │ │ └── points │ │ │ │ ├── help.markdown │ │ │ │ ├── historyList.rb │ │ │ │ ├── parsing.rb │ │ │ │ └── popen3.rb │ │ │ ├── pastel.css │ │ │ ├── tests │ │ │ │ ├── historytestFile.Rconsole │ │ │ │ └── testHistoryList.rb │ │ │ └── tmR.rb │ │ ├── Syntaxes │ │ │ ├── R.plist │ │ │ └── Rd (R Documentation).tmLanguage │ │ └── info.plist │ ├── repo.git │ ├── search.json │ ├── stars.json │ ├── test-git-repo.git │ │ ├── HEAD │ │ ├── config │ │ ├── description │ │ ├── hooks │ │ │ └── .gitkeep │ │ ├── info │ │ │ └── exclude │ │ ├── objects │ │ │ └── pack │ │ │ │ ├── pack-fee09f50a19eb47df3c6fd17d5cf1dd967219da1.idx │ │ │ │ └── pack-fee09f50a19eb47df3c6fd17d5cf1dd967219da1.pack │ │ ├── packed-refs │ │ └── refs │ │ │ ├── heads │ │ │ └── .gitkeep │ │ │ └── tags │ │ │ └── .gitkeep │ ├── test-module-1.0.0.tgz │ ├── test-module-1.1.0.tgz │ ├── test-module-1.2.0.tgz │ ├── test-module-three │ │ └── package.json │ ├── test-module-two │ │ └── package.json │ ├── test-module-with-bin-2.0.0.tgz │ ├── test-module-with-dependencies-1.1.0.tgz │ ├── test-module-with-dependencies │ │ └── package.json │ ├── test-module-with-lockfile │ │ ├── package-lock.json │ │ └── package.json │ ├── test-module-with-symlink-5.0.0.tgz │ ├── test-module │ │ ├── index.js │ │ └── package.json │ ├── test-module2-2.0.0.tgz │ ├── themes.json │ ├── upgrade-different-repo.json │ ├── upgrade-multi-version.json │ ├── upgrade-test-module.json │ └── wrap-guide.json ├── help-spec.coffee ├── init-spec.coffee ├── install-spec.coffee ├── link-spec.coffee ├── list-spec.coffee ├── packages-spec.coffee ├── publish-spec.coffee ├── rebuild-spec.coffee ├── search-spec.coffee ├── spec-helper.coffee ├── stars-spec.coffee ├── test-spec.coffee ├── uninstall-spec.coffee ├── unpublish-spec.coffee ├── upgrade-spec.coffee └── view-spec.coffee ├── src ├── apm-cli.coffee ├── apm.coffee ├── auth.coffee ├── ci.coffee ├── clean.coffee ├── cli.coffee ├── command.coffee ├── config.coffee ├── dedupe.coffee ├── deprecated-packages.coffee ├── develop.coffee ├── disable.coffee ├── docs.coffee ├── enable.coffee ├── featured.coffee ├── fs.coffee ├── git.coffee ├── init.coffee ├── install.coffee ├── link.coffee ├── links.coffee ├── list.coffee ├── login.coffee ├── package-converter.coffee ├── packages.coffee ├── publish.coffee ├── rebuild-module-cache.coffee ├── rebuild.coffee ├── request.coffee ├── search.coffee ├── star.coffee ├── stars.coffee ├── test.coffee ├── text-mate-theme.coffee ├── theme-converter.coffee ├── tree.coffee ├── uninstall.coffee ├── unlink.coffee ├── unpublish.coffee ├── unstar.coffee ├── upgrade.coffee └── view.coffee └── templates ├── bundle ├── CHANGELOG.md ├── README.md └── package.json ├── language ├── .gitignore.template ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── grammars │ └── __package-name__.cson ├── package.json ├── settings │ └── language-__package-name__.cson ├── snippets │ └── language-__package-name__.cson └── spec │ └── language-__package-name__-spec.coffee.template ├── package-coffeescript ├── .gitignore.template ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── keymaps │ └── __package-name__.cson.template ├── lib │ ├── __package-name__-view.coffee.template │ └── __package-name__.coffee.template ├── menus │ └── __package-name__.cson.template ├── package.json ├── spec │ ├── __package-name__-spec.coffee.template │ └── __package-name__-view-spec.coffee.template └── styles │ └── __package-name__.less.template ├── package-javascript ├── .gitignore.template ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── keymaps │ └── __package-name__.json.template ├── lib │ ├── __package-name__-view.js.template │ └── __package-name__.js.template ├── menus │ └── __package-name__.json.template ├── package.json ├── spec │ ├── __package-name__-spec.js.template │ └── __package-name__-view-spec.js.template └── styles │ └── __package-name__.less.template └── theme ├── .gitignore.template ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── index.less ├── package.json └── styles ├── colors.less ├── editor.less ├── syntax-variables.less └── syntax.less /.gitattributes: -------------------------------------------------------------------------------- 1 | # Shell scripts (Unix-style line endings) 2 | *.sh text eol=lf 3 | bin/apm text eol=lf 4 | bin/npm text eol=lf 5 | 6 | # Batch files (Windows-style line endings) 7 | *.cmd text eol=crlf 8 | -------------------------------------------------------------------------------- /.github/no-response.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-no-response - https://github.com/probot/no-response 2 | 3 | # Number of days of inactivity before an issue is closed for lack of response 4 | daysUntilClose: 28 5 | 6 | # Label requiring a response 7 | responseRequiredLabel: more-information-needed 8 | 9 | # Comment to post when closing an issue for lack of response. Set to `false` to disable. 10 | closeComment: > 11 | This issue has been automatically closed because there has been no response 12 | to our request for more information from the original author. With only the 13 | information that is currently in the issue, we don't have enough information 14 | to take action. Please reach out if you have or find the answers we need so 15 | that we can investigate further. 16 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | - pull_request 5 | - push 6 | 7 | jobs: 8 | Test: 9 | if: "!contains(github.event.head_commit.message, '[skip ci]')" 10 | runs-on: ${{ matrix.os }} 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | os: 15 | - ubuntu-latest 16 | - macos-latest 17 | - windows-latest 18 | node_version: 19 | - 12 20 | - 14 21 | node_arch: 22 | - x64 23 | include: 24 | - os: windows-2016 25 | node_version: 12 26 | node_arch: x86 27 | steps: 28 | - uses: actions/checkout@v2 29 | 30 | - name: Install Node 31 | uses: actions/setup-node@v2 32 | with: 33 | node-version: ${{ matrix.node_version }} 34 | architecture: ${{ matrix.node_arch }} 35 | 36 | - name: Install npm 37 | run: npm install -g npm 38 | 39 | - name: Install dependencies 40 | run: npm install 41 | 42 | - if: "!contains(matrix.os, 'windows')" 43 | name: Run tests 👩🏾‍💻 44 | run: ./bin/npm test 45 | 46 | Skip: 47 | if: contains(github.event.head_commit.message, '[skip ci]') 48 | runs-on: ubuntu-latest 49 | steps: 50 | - name: Skip CI 🚫 51 | run: echo skip ci 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /bin/node* 3 | /lib/ 4 | .DS_Store 5 | npm-debug.log 6 | *~ 7 | *.pyc 8 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .npmignore 2 | *.coffee 3 | .DS_Store 4 | npm-debug.log 5 | /spec 6 | /bin/node* 7 | .travis.yml 8 | .pairs 9 | appveyor.yml 10 | coffeelint.json 11 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /BUNDLED_NODE_VERSION: -------------------------------------------------------------------------------- 1 | v12.18.3 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | See the [Atom contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md) 2 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | ### Prerequisites 10 | 11 | * [ ] Put an X between the brackets on this line if you have done all of the following: 12 | * Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode 13 | * Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/ 14 | * Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq 15 | * Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom 16 | * Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages 17 | 18 | ### Description 19 | 20 | [Description of the issue] 21 | 22 | ### Steps to Reproduce 23 | 24 | 1. [First Step] 25 | 2. [Second Step] 26 | 3. [and so on...] 27 | 28 | **Expected behavior:** [What you expect to happen] 29 | 30 | **Actual behavior:** [What actually happens] 31 | 32 | **Reproduces how often:** [What percentage of the time does it reproduce?] 33 | 34 | ### Versions 35 | 36 | You can get this information from copy and pasting the output of `atom --version` and `apm --version` from the command line. Also, please include the OS and what version of the OS you're running. 37 | 38 | ### Additional Information 39 | 40 | Any additional information, configuration or data that might be necessary to reproduce the issue. 41 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Requirements 2 | 3 | * Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. 4 | * All new code requires tests to ensure against regressions 5 | 6 | ### Description of the Change 7 | 8 | 13 | 14 | ### Alternate Designs 15 | 16 | 17 | 18 | ### Benefits 19 | 20 | 21 | 22 | ### Possible Drawbacks 23 | 24 | 25 | 26 | ### Verification Process 27 | 28 | 39 | 40 | ### Applicable Issues 41 | 42 | 43 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # empty appveyor 2 | build: off 3 | 4 | branches: 5 | only: 6 | - non-existing 7 | -------------------------------------------------------------------------------- /bin/apm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | initialCwd=`pwd -P` 6 | scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 7 | 8 | apmPath=$0 9 | builtin cd "`dirname "$apmPath"`" 10 | binDir=`basename "$apmPath"` 11 | 12 | # Detect node binary name 13 | osName=`uname -s` 14 | if [ "${osName:0:10}" == 'MINGW32_NT' ]; then 15 | nodeBin="node.exe" 16 | elif [[ $(uname -r) == *-Microsoft ]]; then 17 | nodeBin="node.exe" 18 | else 19 | nodeBin="node" 20 | fi 21 | 22 | while [ -L "$binDir" ] 23 | do 24 | binDir=`readlink "$binDir"` 25 | builtin cd "`dirname "$binDir"`" 26 | binDir=`basename "$binDir"` 27 | done 28 | 29 | binDir=`pwd -P` 30 | 31 | # Force npm to use its builtin node-gyp 32 | unset npm_config_node_gyp 33 | 34 | cliPath="$binDir/../lib/cli.js" 35 | if [[ $(uname -r) == *-Microsoft ]]; then 36 | cliPath="$(echo $cliPath | sed 's/\/mnt\/\([a-z]*\)\(.*\)/\1:\2/')" 37 | cliPath="${cliPath////\\}" 38 | else 39 | builtin cd "$initialCwd" 40 | fi 41 | 42 | "$binDir/$nodeBin" "$cliPath" "$@" 43 | -------------------------------------------------------------------------------- /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 2^>nul') 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*" 2^>nul') 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 | :: Force npm to use its builtin node-gyp 16 | set npm_config_node_gyp= 17 | 18 | if exist "%~dp0\node.exe" ( 19 | "%~dp0\node.exe" "%~dp0/../lib/cli.js" %* 20 | ) else ( 21 | node.exe "%~dp0/../lib/cli.js" %* 22 | ) 23 | -------------------------------------------------------------------------------- /bin/npm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | export PATH="$SCRIPT_DIR:$PATH" 4 | 5 | # Force npm to use its builtin node-gyp 6 | unset npm_config_node_gyp 7 | 8 | "$SCRIPT_DIR"/../node_modules/.bin/npm $@ 9 | -------------------------------------------------------------------------------- /bin/npm.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal EnableDelayedExpansion 3 | 4 | set "PATH=%~dp0;%PATH%" 5 | 6 | :: Force npm to use its builtin node-gyp 7 | set npm_config_node_gyp= 8 | 9 | "%~dp0\..\node_modules\.bin\npm.cmd" %* 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /native-module/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /native-module/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'targets': [ 3 | { 4 | 'target_name': 'native', 5 | 'sources': [ 6 | 'src/native.cc', 7 | ], 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /native-module/index.js: -------------------------------------------------------------------------------- 1 | module.exports = {"hello": "world"}; 2 | -------------------------------------------------------------------------------- /native-module/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "module-with-native-code", 3 | "main": "./index.js" 4 | } 5 | -------------------------------------------------------------------------------- /native-module/src/native.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("i am a native module"); 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "atom-package-manager", 3 | "description": "Atom package manager", 4 | "version": "2.6.5", 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 | "check-version": "node script/check-version.js", 19 | "clean:bin": "shx rm -rf bin/node_darwin_x64 bin/node.exe bin/node", 20 | "clean:lib": "shx rm -rf lib && shx mkdir -p lib", 21 | "clean": "npm run clean:lib && npm run clean:bin", 22 | "lint": "coffeelint src spec", 23 | "coffee": "coffee --compile --output lib src", 24 | "build": "npm run clean:lib && npm run coffee", 25 | "prepare": "npm run build", 26 | "postinstall": "node script/postinstall.js", 27 | "test": "npm run check-version && npm run lint && jasmine-focused --captureExceptions --coffee spec" 28 | }, 29 | "dependencies": { 30 | "@atom/plist": "0.4.4", 31 | "asar-require": "0.3.0", 32 | "async": "^3.2.0", 33 | "colors": "~1.4.0", 34 | "first-mate": "^7.4.3", 35 | "fs-plus": "3.x", 36 | "git-utils": "^5.7.2", 37 | "glob": "^7.1.6", 38 | "hosted-git-info": "^3.0.7", 39 | "keytar": "^7.7.0", 40 | "mv": "2.1.1", 41 | "ncp": "~2.0.0", 42 | "npm": "^6.14.9", 43 | "open": "7.3.0", 44 | "q": "~1.5.1", 45 | "read": "~1.0.7", 46 | "request": "^2.88.2", 47 | "rimraf": "^3.0.2", 48 | "season": "^6.0.2", 49 | "semver": "^7.3.4", 50 | "tar": "^6.0.5", 51 | "temp": "^0.9.4", 52 | "underscore-plus": "1.x", 53 | "wordwrap": "1.0.0", 54 | "wrench": "~1.5.1", 55 | "yargs": "^3.32.0" 56 | }, 57 | "devDependencies": { 58 | "coffee-script": "^1.12.7", 59 | "coffeelint": "<2.0", 60 | "express": "^4.17.1", 61 | "jasmine-focused": ">=1.0.7 <2.0", 62 | "shx": "^0.3.3", 63 | "node-gyp": "^5.1.1" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /script/bundled-node-version.js: -------------------------------------------------------------------------------- 1 | var child_process = require('child_process') 2 | 3 | module.exports = function(filename, callback) { 4 | child_process.exec(filename + ' -v', function(error, stdout) { 5 | if (error != null) { 6 | callback(error); 7 | return; 8 | } 9 | 10 | var version = null; 11 | if (stdout != null) { 12 | version = stdout.toString().trim(); 13 | } 14 | 15 | child_process.exec(filename + " -p 'process.arch'", function(error, stdout) { 16 | var arch = null; 17 | if (stdout != null) { 18 | arch = stdout.toString().trim(); 19 | } 20 | callback(error, version, arch); 21 | }) 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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. 9 | for /f "delims=" %%i in ('.\bin\node.exe -p "process.version + ' ' + process.arch"') do set bundledVersion=%%i 10 | echo ^>^> Rebuilding apm dependencies with bundled Node !bundledVersion! 11 | call .\bin\npm.cmd rebuild 12 | -------------------------------------------------------------------------------- /script/postinstall.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var cp = require('child_process') 4 | var fs = require('fs') 5 | var path = require('path') 6 | 7 | var script = path.join(__dirname, 'postinstall') 8 | if (process.platform === 'win32') { 9 | script += '.cmd' 10 | } else { 11 | script += '.sh' 12 | } 13 | 14 | // Make sure all the scripts have the necessary permissions when we execute them 15 | // (npm does not preserve permissions when publishing packages on Windows, 16 | // so this is especially needed to allow apm to be published successfully on Windows) 17 | fs.chmodSync(script, 0o755) 18 | fs.chmodSync(path.join(__dirname, '..', 'bin', 'apm'), 0o755) 19 | fs.chmodSync(path.join(__dirname, '..', 'bin', 'npm'), 0o755) 20 | 21 | var child = cp.spawn(script, [], { stdio: ['pipe', 'pipe', 'pipe'], shell: true }) 22 | child.stderr.pipe(process.stderr) 23 | child.stdout.pipe(process.stdout) 24 | -------------------------------------------------------------------------------- /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 -p "process.version + ' ' + process.arch")" 10 | ./bin/npm rebuild 11 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | server = http.createServer(app) 19 | 20 | live = false 21 | server.listen 3000, '127.0.0.1', -> 22 | process.env.ATOM_API_URL = "http://localhost:3000" 23 | live = true 24 | waitsFor -> live 25 | 26 | afterEach -> 27 | done = false 28 | server.close -> done = true 29 | waitsFor -> done 30 | 31 | it 'lists the featured packages and themes', -> 32 | callback = jasmine.createSpy('callback') 33 | apm.run(['featured'], callback) 34 | 35 | waitsFor 'waiting for command to complete', -> 36 | callback.callCount > 0 37 | 38 | runs -> 39 | expect(console.log).toHaveBeenCalled() 40 | expect(console.log.argsForCall[1][0]).toContain 'beverly-hills' 41 | expect(console.log.argsForCall[2][0]).toContain 'multi-version' 42 | expect(console.log.argsForCall[3][0]).toContain 'duckblur' 43 | 44 | describe 'when the theme flag is specified', -> 45 | it "lists the featured themes", -> 46 | callback = jasmine.createSpy('callback') 47 | apm.run(['featured', '--themes'], callback) 48 | 49 | waitsFor 'waiting for command to complete', -> 50 | callback.callCount > 0 51 | 52 | runs -> 53 | expect(console.log).toHaveBeenCalled() 54 | expect(console.log.argsForCall[1][0]).toContain 'duckblur' 55 | expect(console.log.argsForCall[2][0]).toBeUndefined() 56 | -------------------------------------------------------------------------------- /spec/fixtures/SHASUMS256.txt: -------------------------------------------------------------------------------- 1 | f2777bf2b140033c01d5f912df510dfa394e748f92bbaed24c832abf36cb3bdf ./node-v10.20.1-headers.tar.gz 2 | ea39a70b715bfbd0281979c95a5b81136ffdc0e5bf66b1fd7dc3ef3473ce2c5a ./node-v10.20.1.tar.gz 3 | 213d72051a68c37afc37a5d185a4c5bfacc985bc35331024e5f28635f084da70 ./x64/node.lib 4 | e5224f36cf5ae52ee8532e383142073fd6c28866745e9967992de28cfbf5b63a ./node.lib 5 | -------------------------------------------------------------------------------- /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/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/install-locked-version.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "1.2.0" 4 | }, 5 | "name": "test-module-with-dependencies", 6 | "versions": { 7 | "1.2.0": { 8 | "engines": { 9 | "atom": ">=1.0" 10 | }, 11 | "dist": { 12 | "tarball": "http://localhost:3000/tarball/no-1.2.0.tgz" 13 | } 14 | }, 15 | "1.1.0": { 16 | "engines": { 17 | "atom": ">=1.0" 18 | }, 19 | "dist": { 20 | "tarball": "http://localhost:3000/tarball/test-module-with-dependencies-1.1.0.tgz" 21 | } 22 | }, 23 | "1.0.0": { 24 | "engines": { 25 | "atom": ">=1.0" 26 | }, 27 | "dist": { 28 | "tarball": "http://localhost:3000/tarball/no-1.0.0.tgz" 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spec/fixtures/install-multi-version.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "1.2.0" 4 | }, 5 | "name": "multi-module", 6 | "versions": { 7 | "1.2.0": { 8 | "engines": { 9 | "atom": ">=2.0" 10 | } 11 | }, 12 | "1.1.0": { 13 | "engines": { 14 | "atom": ">=1.0" 15 | }, 16 | "dist": { 17 | "tarball": "http://localhost:3000/tarball/test-module-1.1.0.tgz" 18 | } 19 | }, 20 | "1.0.0": { 21 | "engines": { 22 | "atom": ">=1.0" 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /spec/fixtures/install-test-module.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "1.2.0" 4 | }, 5 | "name": "test-module", 6 | "versions": { 7 | "1.2.0": { 8 | "dist": { 9 | "tarball": "http://localhost:3000/tarball/test-module-1.2.0.tgz" 10 | } 11 | }, 12 | "1.1.0": { 13 | "dist": { 14 | "tarball": "http://localhost:3000/tarball/test-module-1.1.0.tgz" 15 | } 16 | }, 17 | "1.0.0": { 18 | "dist": { 19 | "tarball": "http://localhost:3000/tarball/test-module-1.0.0.tgz" 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spec/fixtures/install-test-module2.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "2.0.0" 4 | }, 5 | "name": "test-module2", 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 | -------------------------------------------------------------------------------- /spec/fixtures/native-module-1.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/native-module-1.0.0.tgz -------------------------------------------------------------------------------- /spec/fixtures/native-module.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "1.0.0" 4 | }, 5 | "name": "native-module", 6 | "versions": { 7 | "1.0.0": { 8 | "dist": { 9 | "tarball": "http://localhost:3000/tarball/native-module-1.0.0.tgz" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spec/fixtures/native-package-1.0.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/native-package-1.0.0.tar.gz -------------------------------------------------------------------------------- /spec/fixtures/native-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "releases": { 3 | "latest": "1.0.0" 4 | }, 5 | "name": "native-package", 6 | "versions": { 7 | "1.0.0": { 8 | "dist": { 9 | "tarball": "http://localhost:3000/tarball/native-package-1.0.0.tgz" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spec/fixtures/node-v10.20.1-headers.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/node-v10.20.1-headers.tar.gz -------------------------------------------------------------------------------- /spec/fixtures/node-v10.20.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/node-v10.20.1.tar.gz -------------------------------------------------------------------------------- /spec/fixtures/node.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/node.lib -------------------------------------------------------------------------------- /spec/fixtures/node_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/node_x64.lib -------------------------------------------------------------------------------- /spec/fixtures/package-with-native-deps/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/package-with-native-deps/index.js -------------------------------------------------------------------------------- /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/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/packages.txt: -------------------------------------------------------------------------------- 1 | test-module 2 | test-module2 3 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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 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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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 -------------------------------------------------------------------------------- /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/^ /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/Support/lib/command_args/dist: -------------------------------------------------------------------------------- 1 | x 2 | method="euclidean|maximum|manhattan|canberra|binary|minkowski" 3 | diag=FALSE 4 | upper=FALSE 5 | p = 2 -------------------------------------------------------------------------------- /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/Support/lib/command_args/lines: -------------------------------------------------------------------------------- 1 | type="p|l|b|c|o|h|s|S|n" -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/command_args/mean: -------------------------------------------------------------------------------- 1 | trim=0 2 | na.rm=TRUE -------------------------------------------------------------------------------- /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="" -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /spec/fixtures/r.tmbundle/Support/lib/command_args/points: -------------------------------------------------------------------------------- 1 | type="p|l|b|c|o|h|s|S|n" -------------------------------------------------------------------------------- /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/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/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/Support/tests/historytestFile.Rconsole: -------------------------------------------------------------------------------- 1 | > first command 2 | > second command 3 | > 4 | > 5 | not an item 6 | > first command 7 | > third command 8 | > -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /spec/fixtures/repo.git: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/repo.git -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-git-repo.git/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /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/test-git-repo.git/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/hooks/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-git-repo.git/hooks/.gitkeep -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/objects/pack/pack-fee09f50a19eb47df3c6fd17d5cf1dd967219da1.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/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/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-git-repo.git/objects/pack/pack-fee09f50a19eb47df3c6fd17d5cf1dd967219da1.pack -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled 2 | 8ae432341ac6708aff9bb619eb015da14e9d0c0f refs/heads/master 3 | -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/refs/heads/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-git-repo.git/refs/heads/.gitkeep -------------------------------------------------------------------------------- /spec/fixtures/test-git-repo.git/refs/tags/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-git-repo.git/refs/tags/.gitkeep -------------------------------------------------------------------------------- /spec/fixtures/test-module-1.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-module-1.0.0.tgz -------------------------------------------------------------------------------- /spec/fixtures/test-module-1.1.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-module-1.1.0.tgz -------------------------------------------------------------------------------- /spec/fixtures/test-module-1.2.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-module-1.2.0.tgz -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-with-bin-2.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-module-with-bin-2.0.0.tgz -------------------------------------------------------------------------------- /spec/fixtures/test-module-with-dependencies-1.1.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-module-with-dependencies-1.1.0.tgz -------------------------------------------------------------------------------- /spec/fixtures/test-module-with-dependencies/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-module-with-dependencies", 3 | "version": "1.1.0", 4 | "dependencies": { 5 | "test-module": "^1.1.0" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /spec/fixtures/test-module-with-lockfile/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-module-with-lockfile", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "test-module": { 8 | "version": "1.1.0", 9 | "resolved": "http://localhost:3000/tarball/test-module-1.1.0.tgz", 10 | "integrity": "sha512-yVYHjiz+egJ2xVXthDi+uPDR5f71B7viUiglYwzj97W2NDPSkkvL1oITkAZeOqu2sitX2ywr3h8Fuzxp0srf6Q==" 11 | }, 12 | "test-module-with-dependencies": { 13 | "version": "1.1.0", 14 | "resolved": "http://localhost:3000/tarball/test-module-with-dependencies-1.1.0.tgz", 15 | "integrity": "sha512-p5sqTcSG1y2aYtW595aRc9g/lRYXFkYA641Jbx58fCt/1d1/shk4tdprlxbdsD3tnvLjzjYT25qxEbp6Au4zIA==", 16 | "requires": { 17 | "test-module": "^1.1.0" 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spec/fixtures/test-module-with-lockfile/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-module-with-lockfile", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "test-module-with-dependencies": "^1.0.0" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /spec/fixtures/test-module-with-symlink-5.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-module-with-symlink-5.0.0.tgz -------------------------------------------------------------------------------- /spec/fixtures/test-module/index.js: -------------------------------------------------------------------------------- 1 | console.log('what what') 2 | -------------------------------------------------------------------------------- /spec/fixtures/test-module/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-module", 3 | "version": "1.2.0", 4 | "main": "./index.js", 5 | "engines": { 6 | "atom": "*" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spec/fixtures/test-module2-2.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom/apm/d4f986aa53c7a4f83e90ac4ef169c0cc53276187/spec/fixtures/test-module2-2.0.0.tgz -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/packages-spec.coffee: -------------------------------------------------------------------------------- 1 | Packages = require '../lib/packages' 2 | 3 | describe 'getRemote', -> 4 | it 'returns origin if remote could not be determined', -> 5 | expect(Packages.getRemote()).toEqual('origin') 6 | 7 | it 'returns repository.url', -> 8 | pack = 9 | repository: 10 | type: 'git' 11 | url: 'https://github.com/atom/apm.git' 12 | expect(Packages.getRemote(pack)).toEqual(pack.repository.url) 13 | 14 | it 'returns repository', -> 15 | pack = 16 | repository: 'https://github.com/atom/apm' 17 | expect(Packages.getRemote(pack)).toEqual(pack.repository) 18 | -------------------------------------------------------------------------------- /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 | 18 | live = false 19 | server.listen 3000, '127.0.0.1', -> 20 | process.env.ATOM_PACKAGES_URL = "http://localhost:3000" 21 | live = true 22 | waitsFor -> live 23 | 24 | afterEach -> 25 | done = false 26 | server.close -> done = true 27 | waitsFor -> done 28 | 29 | it 'lists the matching packages and excludes deprecated packages', -> 30 | callback = jasmine.createSpy('callback') 31 | apm.run(['search', 'duck'], callback) 32 | 33 | waitsFor 'waiting for command to complete', -> 34 | callback.callCount > 0 35 | 36 | runs -> 37 | expect(console.log).toHaveBeenCalled() 38 | expect(console.log.argsForCall[1][0]).toContain 'duckberg' 39 | expect(console.log.argsForCall[2][0]).toContain 'ducktales' 40 | expect(console.log.argsForCall[3][0]).toContain 'duckblur' 41 | expect(console.log.argsForCall[4][0]).toBeUndefined() 42 | 43 | it "logs an error if the query is missing or empty", -> 44 | callback = jasmine.createSpy('callback') 45 | apm.run(['search'], callback) 46 | 47 | waitsFor 'waiting for command to complete', -> 48 | callback.callCount > 0 49 | 50 | runs -> 51 | expect(console.error).toHaveBeenCalled() 52 | expect(console.error.argsForCall[0][0].length).toBeGreaterThan 0 53 | -------------------------------------------------------------------------------- /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/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 | 18 | live = false 19 | server.listen 3000, '127.0.0.1', -> 20 | process.env.ATOM_PACKAGES_URL = "http://localhost:3000" 21 | live = true 22 | waitsFor -> live 23 | 24 | afterEach -> 25 | done = false 26 | server.close -> done = true 27 | waitsFor -> done 28 | 29 | it 'displays information about the package', -> 30 | callback = jasmine.createSpy('callback') 31 | apm.run(['view', 'wrap-guide'], callback) 32 | 33 | waitsFor 'waiting for view to complete', -> 34 | callback.callCount > 0 35 | 36 | runs -> 37 | expect(console.log).toHaveBeenCalled() 38 | expect(console.log.argsForCall[0][0]).toContain 'wrap-guide' 39 | expect(console.log.argsForCall[1][0]).toContain '0.14.0' 40 | expect(console.log.argsForCall[2][0]).toContain 'https://github.com/atom/wrap-guide' 41 | expect(console.log.argsForCall[3][0]).toContain 'new version' 42 | 43 | it "logs an error if the package name is missing or empty", -> 44 | callback = jasmine.createSpy('callback') 45 | apm.run(['view'], callback) 46 | 47 | waitsFor 'waiting for view to complete', -> 48 | callback.callCount > 0 49 | 50 | runs -> 51 | expect(console.error).toHaveBeenCalled() 52 | expect(console.error.argsForCall[0][0].length).toBeGreaterThan 0 53 | 54 | describe "when a compatible Atom version is specified", -> 55 | it "displays the latest compatible version of the package", -> 56 | callback = jasmine.createSpy('callback') 57 | apm.run(['view', 'wrap-guide', '--compatible', '1.5.0'], callback) 58 | 59 | waitsFor 'waiting for view to complete', 600000, -> 60 | callback.callCount is 1 61 | 62 | runs -> 63 | expect(console.log.argsForCall[0][0]).toContain 'wrap-guide' 64 | expect(console.log.argsForCall[1][0]).toContain '0.3.0' 65 | expect(console.log.argsForCall[2][0]).toContain 'https://github.com/atom2/wrap-guide' 66 | expect(console.log.argsForCall[3][0]).toContain 'old version' 67 | -------------------------------------------------------------------------------- /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: -> Promise.reject() 8 | setPassword: -> Promise.reject() 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 | keytar.findPassword(tokenName) 21 | .then (token) -> 22 | if token 23 | callback(null, token) 24 | else 25 | Promise.reject() 26 | .catch -> 27 | if token = process.env.ATOM_ACCESS_TOKEN 28 | callback(null, token) 29 | else 30 | callback """ 31 | No Atom.io API token in keychain 32 | Run `apm login` or set the `ATOM_ACCESS_TOKEN` environment variable. 33 | """ 34 | 35 | # Save the given token to the keychain. 36 | # 37 | # token - A string token to save. 38 | saveToken: (token) -> 39 | keytar.setPassword(tokenName, 'atom.io', token) 40 | -------------------------------------------------------------------------------- /src/clean.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | 3 | async = require 'async' 4 | CSON = require 'season' 5 | yargs = require 'yargs' 6 | _ = require 'underscore-plus' 7 | 8 | Command = require './command' 9 | config = require './apm' 10 | fs = require './fs' 11 | 12 | module.exports = 13 | class Clean extends Command 14 | @commandNames: ['clean', 'prune'] 15 | 16 | constructor: -> 17 | super() 18 | @atomNpmPath = require.resolve('npm/bin/npm-cli') 19 | 20 | parseOptions: (argv) -> 21 | options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) 22 | 23 | options.usage """ 24 | Usage: apm clean 25 | 26 | Deletes all packages in the node_modules folder that are not referenced 27 | as a dependency in the package.json file. 28 | """ 29 | options.alias('h', 'help').describe('help', 'Print this usage message') 30 | 31 | run: (options) -> 32 | process.stdout.write("Removing extraneous modules ") 33 | @fork @atomNpmPath, ['prune'], (args...) => 34 | @logCommandResults(options.callback, args...) 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | super() 13 | atomDirectory = apm.getAtomDirectory() 14 | @atomNodeDirectory = path.join(atomDirectory, '.node-gyp') 15 | @atomNpmPath = require.resolve('npm/bin/npm-cli') 16 | 17 | parseOptions: (argv) -> 18 | options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) 19 | options.usage """ 20 | 21 | Usage: apm config set 22 | apm config get 23 | apm config delete 24 | apm config list 25 | apm config edit 26 | 27 | """ 28 | options.alias('h', 'help').describe('help', 'Print this usage message') 29 | 30 | run: (options) -> 31 | {callback} = options 32 | options = @parseOptions(options.commandArgs) 33 | 34 | configArgs = ['--globalconfig', apm.getGlobalConfigPath(), '--userconfig', apm.getUserConfigPath(), 'config'] 35 | configArgs = configArgs.concat(options.argv._) 36 | 37 | env = _.extend({}, process.env, {HOME: @atomNodeDirectory, RUSTUP_HOME: apm.getRustupHomeDirPath()}) 38 | configOptions = {env} 39 | 40 | @fork @atomNpmPath, configArgs, configOptions, (code, stderr='', stdout='') -> 41 | if code is 0 42 | process.stdout.write(stdout) if stdout 43 | callback() 44 | else 45 | process.stdout.write(stderr) if stderr 46 | callback(new Error("npm config failed: #{code}")) 47 | -------------------------------------------------------------------------------- /src/dedupe.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | 3 | async = require 'async' 4 | _ = require 'underscore-plus' 5 | yargs = require 'yargs' 6 | 7 | config = require './apm' 8 | Command = require './command' 9 | fs = require './fs' 10 | 11 | module.exports = 12 | class Dedupe extends Command 13 | @commandNames: ['dedupe'] 14 | 15 | constructor: -> 16 | super() 17 | @atomDirectory = config.getAtomDirectory() 18 | @atomPackagesDirectory = path.join(@atomDirectory, 'packages') 19 | @atomNodeDirectory = path.join(@atomDirectory, '.node-gyp') 20 | @atomNpmPath = require.resolve('npm/bin/npm-cli') 21 | 22 | parseOptions: (argv) -> 23 | options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) 24 | options.usage """ 25 | 26 | Usage: apm dedupe [...] 27 | 28 | Reduce duplication in the node_modules folder in the current directory. 29 | 30 | This command is experimental. 31 | """ 32 | options.alias('h', 'help').describe('help', 'Print this usage message') 33 | 34 | dedupeModules: (options, callback) -> 35 | process.stdout.write 'Deduping modules ' 36 | 37 | @forkDedupeCommand options, (args...) => 38 | @logCommandResults(callback, args...) 39 | 40 | forkDedupeCommand: (options, callback) -> 41 | dedupeArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'dedupe'] 42 | dedupeArgs.push(@getNpmBuildFlags()...) 43 | dedupeArgs.push('--silent') if options.argv.silent 44 | dedupeArgs.push('--quiet') if options.argv.quiet 45 | 46 | dedupeArgs.push(packageName) for packageName in options.argv._ 47 | 48 | fs.makeTreeSync(@atomDirectory) 49 | 50 | env = _.extend({}, process.env, {HOME: @atomNodeDirectory, RUSTUP_HOME: config.getRustupHomeDirPath()}) 51 | @addBuildEnvVars(env) 52 | 53 | dedupeOptions = {env} 54 | dedupeOptions.cwd = options.cwd if options.cwd 55 | 56 | @fork(@atomNpmPath, dedupeArgs, dedupeOptions, callback) 57 | 58 | createAtomDirectories: -> 59 | fs.makeTreeSync(@atomDirectory) 60 | fs.makeTreeSync(@atomNodeDirectory) 61 | 62 | run: (options) -> 63 | {callback, cwd} = options 64 | options = @parseOptions(options.commandArgs) 65 | options.cwd = cwd 66 | 67 | @createAtomDirectories() 68 | 69 | commands = [] 70 | commands.push (callback) => @loadInstalledAtomMetadata(callback) 71 | commands.push (callback) => @dedupeModules(options, callback) 72 | async.waterfall commands, callback 73 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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(Math.min(100, yargs.terminalWidth())) 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 | -------------------------------------------------------------------------------- /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(Math.min(100, yargs.terminalWidth())) 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 | -------------------------------------------------------------------------------- /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 | path = require 'path' 7 | 8 | fsAdditions = 9 | list: (directoryPath) -> 10 | if fs.isDirectorySync(directoryPath) 11 | try 12 | fs.readdirSync(directoryPath) 13 | catch e 14 | [] 15 | else 16 | [] 17 | 18 | listRecursive: (directoryPath) -> 19 | wrench.readdirSyncRecursive(directoryPath) 20 | 21 | cp: (sourcePath, destinationPath, callback) -> 22 | rm destinationPath, (error) -> 23 | if error? 24 | callback(error) 25 | else 26 | ncp(sourcePath, destinationPath, callback) 27 | 28 | mv: (sourcePath, destinationPath, callback) -> 29 | rm destinationPath, (error) -> 30 | if error? 31 | callback(error) 32 | else 33 | wrench.mkdirSyncRecursive(path.dirname(destinationPath), 0o755) 34 | fs.rename(sourcePath, destinationPath, callback) 35 | 36 | module.exports = new Proxy({}, { 37 | get: (target, key) -> 38 | fsAdditions[key] or fs[key] 39 | 40 | set: (target, key, value) -> 41 | fsAdditions[key] = value 42 | }) 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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(Math.min(100, yargs.terminalWidth())) 16 | options.usage """ 17 | 18 | Usage: apm link [] [--name ] 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 | packageName = options.argv.name 36 | try 37 | packageName = CSON.readFileSync(CSON.resolve(path.join(linkPath, 'package'))).name unless packageName 38 | packageName = path.basename(linkPath) unless packageName 39 | 40 | if options.argv.dev 41 | targetPath = path.join(config.getAtomDirectory(), 'dev', 'packages', packageName) 42 | else 43 | targetPath = path.join(config.getAtomDirectory(), 'packages', packageName) 44 | 45 | unless fs.existsSync(linkPath) 46 | callback("Package directory does not exist: #{linkPath}") 47 | return 48 | 49 | try 50 | fs.unlinkSync(targetPath) if fs.isSymbolicLinkSync(targetPath) 51 | fs.makeTreeSync path.dirname(targetPath) 52 | fs.symlinkSync(linkPath, targetPath, 'junction') 53 | console.log "#{targetPath} -> #{linkPath}" 54 | callback() 55 | catch error 56 | callback("Linking #{targetPath} to #{linkPath} failed: #{error.message}") 57 | -------------------------------------------------------------------------------- /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 | super() 16 | @devPackagesPath = path.join(config.getAtomDirectory(), 'dev', 'packages') 17 | @packagesPath = path.join(config.getAtomDirectory(), 'packages') 18 | 19 | parseOptions: (argv) -> 20 | options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) 21 | options.usage """ 22 | 23 | Usage: apm links 24 | 25 | List all of the symlinked atom packages in ~/.atom/packages and 26 | ~/.atom/dev/packages. 27 | """ 28 | options.alias('h', 'help').describe('help', 'Print this usage message') 29 | 30 | getDevPackagePath: (packageName) -> path.join(@devPackagesPath, packageName) 31 | 32 | getPackagePath: (packageName) -> path.join(@packagesPath, packageName) 33 | 34 | getSymlinks: (directoryPath) -> 35 | symlinks = [] 36 | for directory in fs.list(directoryPath) 37 | symlinkPath = path.join(directoryPath, directory) 38 | symlinks.push(symlinkPath) if fs.isSymbolicLinkSync(symlinkPath) 39 | symlinks 40 | 41 | logLinks: (directoryPath) -> 42 | links = @getSymlinks(directoryPath) 43 | console.log "#{directoryPath.cyan} (#{links.length})" 44 | tree links, emptyMessage: '(no links)', (link) -> 45 | try 46 | realpath = fs.realpathSync(link) 47 | catch error 48 | realpath = '???'.red 49 | "#{path.basename(link).yellow} -> #{realpath}" 50 | 51 | run: (options) -> 52 | {callback} = options 53 | 54 | @logLinks(@devPackagesPath) 55 | @logLinks(@packagesPath) 56 | callback() 57 | -------------------------------------------------------------------------------- /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(Math.min(100, yargs.terminalWidth())) 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 | -------------------------------------------------------------------------------- /src/packages.coffee: -------------------------------------------------------------------------------- 1 | url = require 'url' 2 | 3 | # Package helpers 4 | module.exports = 5 | # Parse the repository in `name/owner` format from the package metadata. 6 | # 7 | # pack - The package metadata object. 8 | # 9 | # Returns a name/owner string or null if not parseable. 10 | getRepository: (pack={}) -> 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 | 17 | # Determine remote from package metadata. 18 | # 19 | # pack - The package metadata object. 20 | # Returns a the remote or 'origin' if not parseable. 21 | getRemote: (pack={}) -> 22 | pack.repository?.url or pack.repository or 'origin' 23 | -------------------------------------------------------------------------------- /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 | super() 14 | @atomPackagesDirectory = path.join(config.getAtomDirectory(), 'packages') 15 | 16 | parseOptions: (argv) -> 17 | options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) 18 | options.usage """ 19 | 20 | Usage: apm rebuild-module-cache 21 | 22 | Rebuild the module cache for all the packages installed to 23 | ~/.atom/packages 24 | 25 | You can see the state of the module cache for a package by looking 26 | at the _atomModuleCache property in the package's package.json file. 27 | 28 | This command skips all linked packages. 29 | """ 30 | options.alias('h', 'help').describe('help', 'Print this usage message') 31 | 32 | getResourcePath: (callback) -> 33 | if @resourcePath 34 | process.nextTick => callback(@resourcePath) 35 | else 36 | config.getResourcePath (@resourcePath) => callback(@resourcePath) 37 | 38 | rebuild: (packageDirectory, callback) -> 39 | @getResourcePath (resourcePath) => 40 | try 41 | @moduleCache ?= require(path.join(resourcePath, 'src', 'module-cache')) 42 | @moduleCache.create(packageDirectory) 43 | catch error 44 | return callback(error) 45 | 46 | callback() 47 | 48 | run: (options) -> 49 | {callback} = options 50 | 51 | commands = [] 52 | fs.list(@atomPackagesDirectory).forEach (packageName) => 53 | packageDirectory = path.join(@atomPackagesDirectory, packageName) 54 | return if fs.isSymbolicLinkSync(packageDirectory) 55 | return unless fs.isFileSync(path.join(packageDirectory, 'package.json')) 56 | 57 | commands.push (callback) => 58 | process.stdout.write "Rebuilding #{packageName} module cache " 59 | @rebuild packageDirectory, (error) => 60 | if error? 61 | @logFailure() 62 | else 63 | @logSuccess() 64 | callback(error) 65 | 66 | async.waterfall(commands, callback) 67 | -------------------------------------------------------------------------------- /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 | fs = require './fs' 9 | Install = require './install' 10 | 11 | module.exports = 12 | class Rebuild extends Command 13 | @commandNames: ['rebuild'] 14 | 15 | constructor: -> 16 | super() 17 | @atomDirectory = config.getAtomDirectory() 18 | @atomNodeDirectory = path.join(@atomDirectory, '.node-gyp') 19 | @atomNpmPath = require.resolve('npm/bin/npm-cli') 20 | 21 | parseOptions: (argv) -> 22 | options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) 23 | options.usage """ 24 | 25 | Usage: apm rebuild [ [ ...]] 26 | 27 | Rebuild the given modules currently installed in the node_modules folder 28 | in the current working directory. 29 | 30 | All the modules will be rebuilt if no module names are specified. 31 | """ 32 | options.alias('h', 'help').describe('help', 'Print this usage message') 33 | 34 | forkNpmRebuild: (options, callback) -> 35 | process.stdout.write 'Rebuilding modules ' 36 | 37 | rebuildArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'rebuild'] 38 | rebuildArgs.push(@getNpmBuildFlags()...) 39 | rebuildArgs.push(options.argv._...) 40 | 41 | fs.makeTreeSync(@atomDirectory) 42 | 43 | env = _.extend({}, process.env, {HOME: @atomNodeDirectory, RUSTUP_HOME: config.getRustupHomeDirPath()}) 44 | @addBuildEnvVars(env) 45 | 46 | @fork(@atomNpmPath, rebuildArgs, {env}, callback) 47 | 48 | run: (options) -> 49 | {callback} = options 50 | options = @parseOptions(options.commandArgs) 51 | 52 | config.loadNpm (error, @npm) => 53 | @loadInstalledAtomMetadata => 54 | @forkNpmRebuild options, (code, stderr='') => 55 | if code is 0 56 | @logSuccess() 57 | callback() 58 | else 59 | @logFailure() 60 | callback(stderr) 61 | -------------------------------------------------------------------------------- /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 | userAgent = npm.config.get('user-agent') ? "AtomApm/#{require('../package.json').version}" 18 | requestOptions.headers ?= {} 19 | requestOptions.headers['User-Agent'] ?= userAgent 20 | callback() 21 | 22 | module.exports = 23 | get: (requestOptions, callback) -> 24 | configureRequest requestOptions, -> 25 | retryCount = requestOptions.retries ? 0 26 | requestsMade = 0 27 | tryRequest = -> 28 | requestsMade++ 29 | request.get requestOptions, (error, response, body) -> 30 | if retryCount > 0 and error?.code in ['ETIMEDOUT', 'ECONNRESET'] 31 | retryCount-- 32 | tryRequest() 33 | else 34 | if error?.message and requestsMade > 1 35 | error.message += " (#{requestsMade} attempts)" 36 | 37 | callback(error, response, body) 38 | tryRequest() 39 | 40 | del: (requestOptions, callback) -> 41 | configureRequest requestOptions, -> 42 | request.del(requestOptions, callback) 43 | 44 | post: (requestOptions, callback) -> 45 | configureRequest requestOptions, -> 46 | request.post(requestOptions, callback) 47 | 48 | createReadStream: (requestOptions, callback) -> 49 | configureRequest requestOptions, -> 50 | callback(request.get(requestOptions)) 51 | 52 | getErrorMessage: (response, body) -> 53 | if response?.statusCode is 503 54 | 'atom.io is temporarily unavailable, please try again later.' 55 | else 56 | body?.message ? body?.error ? body 57 | 58 | debug: (debug) -> 59 | request.debug = debug 60 | -------------------------------------------------------------------------------- /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(Math.min(100, yargs.terminalWidth())) 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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(Math.min(100, yargs.terminalWidth())) 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 | -------------------------------------------------------------------------------- /templates/bundle/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /templates/bundle/README.md: -------------------------------------------------------------------------------- 1 | # __package-name__ package 2 | 3 | A short description of your package. 4 | -------------------------------------------------------------------------------- /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/.gitignore.template: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /templates/language/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /templates/language/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) __current_year__ 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/README.md: -------------------------------------------------------------------------------- 1 | # __PackageName__ language package 2 | 3 | A short description of your language package. 4 | -------------------------------------------------------------------------------- /templates/language/grammars/__package-name__.cson: -------------------------------------------------------------------------------- 1 | # If this is your first time writing a language grammar, check out: 2 | # - https://flight-manual.atom.io/hacking-atom/sections/creating-a-grammar/ 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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /templates/language/snippets/language-__package-name__.cson: -------------------------------------------------------------------------------- 1 | # If you want some example snippets, check out: 2 | # https://github.com/atom/language-javascript/blob/master/snippets/javascript.cson 3 | 4 | '.source.__package-name__': 5 | 'Method documentation': 6 | 'prefix': 'doc' 7 | 'body': '@@ ${1:method} - ${2:description}' 8 | -------------------------------------------------------------------------------- /templates/language/spec/language-__package-name__-spec.coffee.template: -------------------------------------------------------------------------------- 1 | # If you want an example of language specs, check out: 2 | # https://github.com/atom/language-javascript/blob/master/spec/javascript-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.grammars.grammarForScopeName("source.__package-name__") 13 | 14 | it "parses the grammar", -> 15 | expect(grammar).toBeTruthy() 16 | expect(grammar.scopeName).toBe "source.__package-name__" 17 | -------------------------------------------------------------------------------- /templates/package-coffeescript/.gitignore.template: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /templates/package-coffeescript/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /templates/package-coffeescript/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) __current_year__ 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/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-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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /templates/package-javascript/.gitignore.template: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /templates/package-javascript/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /templates/package-javascript/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) __current_year__ 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/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/keymaps/__package-name__.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "atom-workspace": { 3 | "ctrl-alt-o": "__package-name__:toggle" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-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/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/theme/.gitignore.template: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /templates/theme/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /templates/theme/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) __current_year__ 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/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 | -------------------------------------------------------------------------------- /templates/theme/index.less: -------------------------------------------------------------------------------- 1 | @import "styles/syntax-variables.less"; 2 | @import "styles/syntax.less"; 3 | @import "styles/editor.less"; 4 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /templates/theme/styles/editor.less: -------------------------------------------------------------------------------- 1 | // This defines styling rules for the editor. 2 | 3 | atom-text-editor { 4 | background-color: @syntax-background-color; 5 | color: @syntax-text-color; 6 | 7 | .wrap-guide { 8 | background-color: @syntax-wrap-guide-color; 9 | } 10 | 11 | .indent-guide { 12 | color: @syntax-indent-guide-color; 13 | } 14 | 15 | .invisible-character { 16 | color: @syntax-invisible-character-color; 17 | } 18 | 19 | .gutter { 20 | background-color: @syntax-gutter-background-color; 21 | color: @syntax-gutter-text-color; 22 | 23 | .line-number { 24 | &.cursor-line { 25 | background-color: @syntax-gutter-background-color-selected; 26 | color: @syntax-gutter-text-color-selected; 27 | } 28 | 29 | &.cursor-line-no-selection { 30 | color: @syntax-gutter-text-color-selected; 31 | } 32 | } 33 | } 34 | 35 | .gutter .line-number.folded, 36 | .gutter .line-number:after, 37 | .fold-marker:after { 38 | color: @light-gray; 39 | } 40 | 41 | .invisible { 42 | color: @syntax-text-color; 43 | } 44 | 45 | .cursor { 46 | color: @syntax-cursor-color; 47 | } 48 | 49 | .selection .region { 50 | background-color: @syntax-selection-color; 51 | } 52 | } 53 | 54 | atom-text-editor[mini] .scroll-view { 55 | padding-left: 1px; 56 | } 57 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------