mirror of
https://github.com/atom/atom.git
synced 2026-01-25 14:59:03 -05:00
Merge branch 'master' of github.com:atom/atom into content-regex
This commit is contained in:
3
apm/package-lock.json
generated
3
apm/package-lock.json
generated
@@ -21,6 +21,7 @@
|
||||
"node-gyp": "3.4.0",
|
||||
"npm": "6.2.0",
|
||||
"open": "0.0.5",
|
||||
"plist": "git+https://github.com/nathansobo/node-plist.git#bd3a93387f1d4b2cff819b200870d35465796e77",
|
||||
"q": "~0.9.7",
|
||||
"read": "~1.0.5",
|
||||
"request": "^2.87.0",
|
||||
@@ -3973,7 +3974,7 @@
|
||||
},
|
||||
"plist": {
|
||||
"version": "git+https://github.com/nathansobo/node-plist.git#bd3a93387f1d4b2cff819b200870d35465796e77",
|
||||
"from": "git+https://github.com/nathansobo/node-plist.git#bd3a93387f1d4b2cff819b200870d35465796e77",
|
||||
"from": "git+https://github.com/nathansobo/node-plist.git",
|
||||
"requires": {
|
||||
"xmlbuilder": "0.4.x",
|
||||
"xmldom": "0.1.x"
|
||||
|
||||
344
package-lock.json
generated
344
package-lock.json
generated
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"name": "atom",
|
||||
"version": "1.36.0-dev",
|
||||
"version": "1.37.0-dev",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@atom/nsfw": {
|
||||
"version": "1.0.21",
|
||||
"resolved": "https://registry.npmjs.org/@atom/nsfw/-/nsfw-1.0.21.tgz",
|
||||
"integrity": "sha512-ERz76RZstjDvZPM4FHwgO+9dzGkki0mJsn2r+Mu4yn29MzUuAtSmtyJDPmupVUvmz2PF7KvRbC/W2A8A6BHQhA==",
|
||||
"version": "1.0.18",
|
||||
"resolved": "https://registry.npmjs.org/@atom/nsfw/-/nsfw-1.0.18.tgz",
|
||||
"integrity": "sha512-YceKV9a3X62mh4Q78Nyi8aTRaoVGdpeJBHogL8gxU17iBhEpYvxGgMfTe02j1hH2taFT4barkZ5RdZkGKIsJ/w==",
|
||||
"requires": {
|
||||
"fs-extra": "^7.0.0",
|
||||
"fs-extra": "^0.26.5",
|
||||
"lodash.isinteger": "^4.0.4",
|
||||
"lodash.isundefined": "^3.0.1",
|
||||
"nan": "^2.10.0",
|
||||
"promisify-node": "^0.5.0"
|
||||
"nan": "^2.0.0",
|
||||
"promisify-node": "^0.3.0"
|
||||
}
|
||||
},
|
||||
"@atom/source-map-support": {
|
||||
@@ -34,33 +34,30 @@
|
||||
}
|
||||
},
|
||||
"@atom/watcher": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@atom/watcher/-/watcher-1.0.8.tgz",
|
||||
"integrity": "sha512-53un+vGSaY7Fsbvmg8gerYOA3ISipMWR3qiYR9hZWqSfvFsksXJfGrmFsfbBj3uqGRQ3gPTi6wpxcFSWjbWVFQ==",
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@atom/watcher/-/watcher-1.3.1.tgz",
|
||||
"integrity": "sha512-UjGisruWlcRLMzddE3pwvOx6wQCFN/+gg6Z4cJZvH1kjT5QT5eA04hUDs8QXF/QH8ZxMiOtP8x9SWTw0hCNelg==",
|
||||
"requires": {
|
||||
"event-kit": "^2.5.0",
|
||||
"fs-extra": "^6.0.0",
|
||||
"nan": "^2.10.0",
|
||||
"node-pre-gyp": "^0.10.0"
|
||||
"event-kit": "2.5.3",
|
||||
"fs-extra": "7.0.1",
|
||||
"nan": "2.12.1",
|
||||
"prebuild-install": "5.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-extra": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz",
|
||||
"integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==",
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
|
||||
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.2",
|
||||
"jsonfile": "^4.0.0",
|
||||
"universalify": "^0.1.0"
|
||||
}
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
|
||||
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
"nan": {
|
||||
"version": "2.12.1",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz",
|
||||
"integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -78,11 +75,6 @@
|
||||
"resolved": "https://registry.npmjs.org/CSSwhat/-/CSSwhat-0.4.7.tgz",
|
||||
"integrity": "sha1-hn2g/zn3eGEyQsRM/qg/CqTr35s="
|
||||
},
|
||||
"abbrev": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
||||
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="
|
||||
},
|
||||
"about": {
|
||||
"version": "file:packages/about",
|
||||
"requires": {
|
||||
@@ -314,9 +306,9 @@
|
||||
}
|
||||
},
|
||||
"atom-keymap": {
|
||||
"version": "8.2.12",
|
||||
"resolved": "https://registry.npmjs.org/atom-keymap/-/atom-keymap-8.2.12.tgz",
|
||||
"integrity": "sha512-qAXylPa/uysvYhZC1zJR7yG7QFs2RqU+2646JYGeiqgm0nMxLpdJpJ9ABIXbDNxzjhlRXNmZkr5V6N22RWjh4Q==",
|
||||
"version": "8.2.13",
|
||||
"resolved": "https://registry.npmjs.org/atom-keymap/-/atom-keymap-8.2.13.tgz",
|
||||
"integrity": "sha512-RNf+5KbAiXpNV2KZT0+XYpTRFE8rhq7NrBryghJAOlwayY3g3z6Kp9tMfaPJ05BkPo9mChcaFO6SKUL8LTQcBg==",
|
||||
"requires": {
|
||||
"clear-cut": "^2",
|
||||
"emissary": "^1.1.0",
|
||||
@@ -1172,6 +1164,14 @@
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
|
||||
"integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg="
|
||||
},
|
||||
"cached-run-in-this-context": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/cached-run-in-this-context/-/cached-run-in-this-context-0.5.0.tgz",
|
||||
"integrity": "sha512-FdtDP0u8WjetQ95nLz9vI06efJTFrmtmk5ZT6FECpyTKi9aakNLMHyMH21WRbGYyWlbmB/QlRoB/g1lcEpyjMw==",
|
||||
"requires": {
|
||||
"nan": "^2.10.0"
|
||||
}
|
||||
},
|
||||
"caller-callsite": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz",
|
||||
@@ -1311,6 +1311,11 @@
|
||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz",
|
||||
"integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE="
|
||||
},
|
||||
"circular-json": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.7.tgz",
|
||||
"integrity": "sha512-/pXoV1JA847qRKPrHbBK6YIBGFF8GOP4wzSgUOA7q0ew0vAv0iJswP+2/nZQ9uzA3Azi7eTrg9L2yzXc/7ZMIA=="
|
||||
},
|
||||
"classnames": {
|
||||
"version": "2.2.6",
|
||||
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.6.tgz",
|
||||
@@ -1638,9 +1643,9 @@
|
||||
}
|
||||
},
|
||||
"date-format": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/date-format/-/date-format-2.0.0.tgz",
|
||||
"integrity": "sha512-M6UqVvZVgFYqZL1SfHsRGIQSz3ZL+qgbsV5Lp1Vj61LZVYuEwcMXYay7DRDtYs2HQQBK5hQtQ0fD9aEJ89V0LA=="
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/date-format/-/date-format-1.2.0.tgz",
|
||||
"integrity": "sha1-YV6CjiM90aubua4JUODOzPpuytg="
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
@@ -2227,8 +2232,8 @@
|
||||
}
|
||||
},
|
||||
"find-and-replace": {
|
||||
"version": "https://www.atom.io/api/packages/find-and-replace/versions/0.218.0/tarball",
|
||||
"integrity": "sha512-c77OpEcgce8cfPgjPQStEvK016AVmNMUfKIuCYgzYbjTik2lCSU+QAEG3q6MitIzqoFiSW6WW3FL502HFyZwKg==",
|
||||
"version": "https://www.atom.io/api/packages/find-and-replace/versions/0.218.9/tarball",
|
||||
"integrity": "sha512-j1KWRa8Ki9P3G3//kP9sWUqa8vva3+HiWfZJAR8kAaOJFUqy9EGOp6SR3Xs6ChQbk8kHmQBnIcYUjCz/gDoJ/g==",
|
||||
"requires": {
|
||||
"binary-search": "^1.3.3",
|
||||
"element-resize-detector": "^1.1.10",
|
||||
@@ -2274,11 +2279,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"flatted": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz",
|
||||
"integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg=="
|
||||
},
|
||||
"flatten": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/flatten/-/flatten-1.0.2.tgz",
|
||||
@@ -2393,13 +2393,25 @@
|
||||
"integrity": "sha1-a+Dem+mYzhavivwkSXue6bfM2a0="
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.0.tgz",
|
||||
"integrity": "sha512-EglNDLRpmaTWiD/qraZn6HREAEAHJcJOmxNEYwq6xeMKnVMAy3GUcFB+wXt2C6k4CNvB/mP1y/U3dzvKKj5OtQ==",
|
||||
"version": "0.26.7",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz",
|
||||
"integrity": "sha1-muH92UiXeY7at20JGM9C0MMYT6k=",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.2",
|
||||
"jsonfile": "^4.0.0",
|
||||
"universalify": "^0.1.0"
|
||||
"jsonfile": "^2.1.0",
|
||||
"klaw": "^1.0.0",
|
||||
"path-is-absolute": "^1.0.0",
|
||||
"rimraf": "^2.2.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"jsonfile": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
|
||||
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fs-minipass": {
|
||||
@@ -2411,9 +2423,9 @@
|
||||
}
|
||||
},
|
||||
"fs-plus": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/fs-plus/-/fs-plus-3.1.1.tgz",
|
||||
"integrity": "sha512-Se2PJdOWXqos1qVTkvqqjb0CSnfBnwwD+pq+z4ksT+e97mEShod/hrNg0TRCCsXPbJzcIq+NuzQhigunMWMJUA==",
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/fs-plus/-/fs-plus-3.0.2.tgz",
|
||||
"integrity": "sha1-a19Sp3EolMTd6f2PgfqMYN8EHz0=",
|
||||
"requires": {
|
||||
"async": "^1.5.2",
|
||||
"mkdirp": "^0.5.1",
|
||||
@@ -2423,7 +2435,7 @@
|
||||
"dependencies": {
|
||||
"async": {
|
||||
"version": "1.5.2",
|
||||
"resolved": "http://registry.npmjs.org/async/-/async-1.5.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
|
||||
"integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="
|
||||
}
|
||||
}
|
||||
@@ -2472,8 +2484,8 @@
|
||||
"integrity": "sha1-gy9kifvodnaUWVmckUpnDsIpR+4="
|
||||
},
|
||||
"fuzzy-finder": {
|
||||
"version": "https://www.atom.io/api/packages/fuzzy-finder/versions/1.9.0/tarball",
|
||||
"integrity": "sha512-YJTPPMZLQmDiUa6eoONhHF7sOvAPQqrXNFLfPGAUItDUoJxvJBwkPcxh+ryCHLlO8MuoJdDvAKHsU0mGzb/JeQ==",
|
||||
"version": "https://www.atom.io/api/packages/fuzzy-finder/versions/1.9.2/tarball",
|
||||
"integrity": "sha512-gpr1DXfxCEwMO48uCudocIZomhHlMJk+l1lAXJXwamtprDRsuzSqVMFjlyM49/cn4P5ToMhVHHHFngg0wklpvw==",
|
||||
"requires": {
|
||||
"async": "0.2.6",
|
||||
"atom-select-list": "^0.7.0",
|
||||
@@ -2825,14 +2837,6 @@
|
||||
"safer-buffer": ">= 2.1.2 < 3"
|
||||
}
|
||||
},
|
||||
"ignore-walk": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz",
|
||||
"integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==",
|
||||
"requires": {
|
||||
"minimatch": "^3.0.4"
|
||||
}
|
||||
},
|
||||
"image-size": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz",
|
||||
@@ -3233,6 +3237,14 @@
|
||||
"is-buffer": "^1.1.5"
|
||||
}
|
||||
},
|
||||
"klaw": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz",
|
||||
"integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.9"
|
||||
}
|
||||
},
|
||||
"language-c": {
|
||||
"version": "https://www.atom.io/api/packages/language-c/versions/0.60.14/tarball",
|
||||
"integrity": "sha512-jGFMc9vNutvBflFdoUXWJqxBFdMFG7n13PxS8z+SB8H0taZStq55JixDaQ0i/qu7ay4K5BCJ7y/PHdL13vjouQ==",
|
||||
@@ -3293,8 +3305,8 @@
|
||||
"integrity": "sha512-kdTsc2efREnuj72WsAfcx28h0RqrVUIGF7BQcS5zy+ZibqbvnaB5DiVunRFYLhefGoaKVkAyTdRkZWMKH/yIWg=="
|
||||
},
|
||||
"language-javascript": {
|
||||
"version": "https://www.atom.io/api/packages/language-javascript/versions/0.129.19/tarball",
|
||||
"integrity": "sha512-ClPU0dc41WqagaPd+qy5DQ5ahDCVcfFxC1nwppyQSsSXzrzsiE2+FuYzG33OMaSGDA6/zZ6gBkHXnXXPFzWcNA==",
|
||||
"version": "https://www.atom.io/api/packages/language-javascript/versions/0.129.20/tarball",
|
||||
"integrity": "sha512-zHIaVdZYxxoabugCVDnOsrhy0oZC8hLPVKOZoT8EwPIWfRRNedTshFVhABUTH+dmiOUUS++izylwng2yWggpzA==",
|
||||
"requires": {
|
||||
"tree-sitter-javascript": "^0.13.10",
|
||||
"tree-sitter-jsdoc": "^0.13.4",
|
||||
@@ -3677,21 +3689,21 @@
|
||||
"integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE="
|
||||
},
|
||||
"log4js": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/log4js/-/log4js-4.0.0.tgz",
|
||||
"integrity": "sha512-XlxZfcFAvQjnjCJBIV/EpsPmrVC12n+TxNUKgrmQh6eeA+9X+6UqvaRNV8t6dpMtXszl1LAQimB4pqyp2Gsgfw==",
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/log4js/-/log4js-3.0.5.tgz",
|
||||
"integrity": "sha512-IX5c3G/7fuTtdr0JjOT2OIR12aTESVhsH6cEsijloYwKgcPRlO6DgOU72v0UFhWcoV1HN6+M3dwT89qVPLXm0w==",
|
||||
"requires": {
|
||||
"date-format": "^2.0.0",
|
||||
"circular-json": "^0.5.5",
|
||||
"date-format": "^1.2.0",
|
||||
"debug": "^3.1.0",
|
||||
"flatted": "^2.0.0",
|
||||
"rfdc": "^1.1.2",
|
||||
"streamroller": "^1.0.1"
|
||||
"streamroller": "0.7.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
|
||||
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
|
||||
"version": "3.2.5",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.5.tgz",
|
||||
"integrity": "sha512-D61LaDQPQkxJ5AUM2mbSJRbPkNs/TmdmOeLAi1hgDkpDfIfetSrjmWhccwtuResSwMbACjx/xXQofvM9CE/aeg==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
@@ -3884,14 +3896,6 @@
|
||||
"yallist": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"minizlib": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz",
|
||||
"integrity": "sha1-EeE2WM5GvDpwomeqxYNZ0eDCnOs=",
|
||||
"requires": {
|
||||
"minipass": "^2.2.1"
|
||||
}
|
||||
},
|
||||
"mixto": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mixto/-/mixto-1.0.0.tgz",
|
||||
@@ -4070,16 +4074,6 @@
|
||||
"underscore": ">=1.3.1"
|
||||
}
|
||||
},
|
||||
"needle": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/needle/-/needle-2.2.2.tgz",
|
||||
"integrity": "sha512-mW7W8dKuVYefCpNzE3Z7xUmPI9wSrSL/1qH31YGMxmSOAnjatS3S9Zv3cmiHrhx3Jkp1SrWWBdOFXjfF48Uq3A==",
|
||||
"requires": {
|
||||
"debug": "^2.1.2",
|
||||
"iconv-lite": "^0.4.4",
|
||||
"sax": "^1.2.4"
|
||||
}
|
||||
},
|
||||
"next-tick": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
|
||||
@@ -4117,30 +4111,6 @@
|
||||
"is-stream": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node-pre-gyp": {
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.10.0.tgz",
|
||||
"integrity": "sha512-G7kEonQLRbcA/mOoFoxvlMrw6Q6dPf92+t/l0DFSMuSlDoWaI9JWIyPwK0jyE1bph//CUEL65/Fz1m2vJbmjQQ==",
|
||||
"requires": {
|
||||
"detect-libc": "^1.0.2",
|
||||
"mkdirp": "^0.5.1",
|
||||
"needle": "^2.2.0",
|
||||
"nopt": "^4.0.1",
|
||||
"npm-packlist": "^1.1.6",
|
||||
"npmlog": "^4.0.2",
|
||||
"rc": "^1.1.7",
|
||||
"rimraf": "^2.6.1",
|
||||
"semver": "^5.3.0",
|
||||
"tar": "^4"
|
||||
},
|
||||
"dependencies": {
|
||||
"semver": {
|
||||
"version": "5.5.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz",
|
||||
"integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"node-uuid": {
|
||||
"version": "1.4.8",
|
||||
"resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz",
|
||||
@@ -4159,15 +4129,6 @@
|
||||
"resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz",
|
||||
"integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI="
|
||||
},
|
||||
"nopt": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz",
|
||||
"integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=",
|
||||
"requires": {
|
||||
"abbrev": "1",
|
||||
"osenv": "^0.1.4"
|
||||
}
|
||||
},
|
||||
"normalize-package-data": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
|
||||
@@ -4192,20 +4153,6 @@
|
||||
"temp": "^0.8.1"
|
||||
}
|
||||
},
|
||||
"npm-bundled": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.5.tgz",
|
||||
"integrity": "sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g=="
|
||||
},
|
||||
"npm-packlist": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.11.tgz",
|
||||
"integrity": "sha512-CxKlZ24urLkJk+9kCm48RTQ7L4hsmgSVzEk0TLGPzzyuFxD7VNgy5Sl24tOLMzQv773a/NeJ1ce1DKeacqffEA==",
|
||||
"requires": {
|
||||
"ignore-walk": "^3.0.1",
|
||||
"npm-bundled": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"npmlog": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
|
||||
@@ -4299,15 +4246,6 @@
|
||||
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
||||
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
|
||||
},
|
||||
"osenv": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz",
|
||||
"integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==",
|
||||
"requires": {
|
||||
"os-homedir": "^1.0.0",
|
||||
"os-tmpdir": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"output-file-sync": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/output-file-sync/-/output-file-sync-1.1.2.tgz",
|
||||
@@ -4352,9 +4290,9 @@
|
||||
"integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME="
|
||||
},
|
||||
"pathwatcher": {
|
||||
"version": "8.0.2",
|
||||
"resolved": "https://registry.npmjs.org/pathwatcher/-/pathwatcher-8.0.2.tgz",
|
||||
"integrity": "sha512-zuP+fLmB2IB6z89ikcehA+vG/ITx3Cmhaj3DJrBgnbdss6dwPolSq7cDBjgZ78Vl+SXmG7CHGIOM5mqdT9h7BQ==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pathwatcher/-/pathwatcher-8.0.1.tgz",
|
||||
"integrity": "sha1-UaLOKgHbbDLYZ/ZYXvKEvmvQo64=",
|
||||
"requires": {
|
||||
"async": "~0.2.10",
|
||||
"emissary": "^1.3.2",
|
||||
@@ -4362,19 +4300,19 @@
|
||||
"fs-plus": "^3.0.0",
|
||||
"grim": "^2.0.1",
|
||||
"iconv-lite": "~0.4.4",
|
||||
"nan": "^2.10.0",
|
||||
"nan": "2.x",
|
||||
"underscore-plus": "~1.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"async": {
|
||||
"version": "0.2.10",
|
||||
"resolved": "http://registry.npmjs.org/async/-/async-0.2.10.tgz",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
|
||||
"integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E="
|
||||
},
|
||||
"grim": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/grim/-/grim-2.0.2.tgz",
|
||||
"integrity": "sha512-Qj7hTJRfd87E/gUgfvM0YIH/g2UA2SV6niv6BYXk1o6w4mhgv+QyYM1EjOJQljvzgEj4SqSsRWldXIeKHz3e3Q==",
|
||||
"integrity": "sha1-52CinKe4NDsMH/r2ziDyGkbuiu0=",
|
||||
"requires": {
|
||||
"event-kit": "^2.0.0"
|
||||
}
|
||||
@@ -4512,12 +4450,11 @@
|
||||
}
|
||||
},
|
||||
"promisify-node": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/promisify-node/-/promisify-node-0.5.0.tgz",
|
||||
"integrity": "sha512-GR2E4qgCoKFTprhULqP2OP3bl8kHo16XtnqtkHH6be7tPW1yL6rXd15nl3oV2sLTFv1+j6tqoF69VVpFtJ/j+A==",
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/promisify-node/-/promisify-node-0.3.0.tgz",
|
||||
"integrity": "sha1-tLVaz5D6p9K4uQyjlomQhsAwYM8=",
|
||||
"requires": {
|
||||
"nodegit-promise": "^4.0.0",
|
||||
"object-assign": "^4.1.1"
|
||||
"nodegit-promise": "~4.0.0"
|
||||
}
|
||||
},
|
||||
"prop-types": {
|
||||
@@ -4920,11 +4857,6 @@
|
||||
"resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz",
|
||||
"integrity": "sha1-vsEf3IOp/aBjQBIQ5AF2wwJNFWc="
|
||||
},
|
||||
"sax": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||
},
|
||||
"scandal": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/scandal/-/scandal-3.1.0.tgz",
|
||||
@@ -5071,8 +5003,8 @@
|
||||
"integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
|
||||
},
|
||||
"settings-view": {
|
||||
"version": "https://www.atom.io/api/packages/settings-view/versions/0.259.0/tarball",
|
||||
"integrity": "sha512-jNQuTozGf1uQtS4Y4hlUT15STnmnKlAWzzJOIe+ts2S/SdrGHZwxhNykJFzM8gC8j4N3Kjb8CkgmbCDzZ98aEw==",
|
||||
"version": "https://www.atom.io/api/packages/settings-view/versions/0.260.0/tarball",
|
||||
"integrity": "sha512-uZspfpknxC+47Zr9FJmkrAzR+a7yprv6hevZU6dUIQ1q2n0ws/Bxm6mgZVjyxpDmnNRwxiMrzCl2UArE05sNOg==",
|
||||
"requires": {
|
||||
"async": "~0.2.9",
|
||||
"dompurify": "^1.0.2",
|
||||
@@ -5182,8 +5114,8 @@
|
||||
"integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU="
|
||||
},
|
||||
"snippets": {
|
||||
"version": "https://www.atom.io/api/packages/snippets/versions/1.4.0/tarball",
|
||||
"integrity": "sha512-pfw/YOwYeU4xJBEe/qztZx8Lq0ODLtSy7seoaMRu4w1lGlzl0HsqBeqTwLxR6bak3nS5WLj+k3hSJO+yNJWH2w==",
|
||||
"version": "https://www.atom.io/api/packages/snippets/versions/1.4.1/tarball",
|
||||
"integrity": "sha512-bLQmuMmyC+Sfjm/jdPbY3j/Vml3E4ApKhMFRb4AJLTde5m7TEhdTmsQBtkf+vFqGfr76tZ144F9NWH12ryS5rw==",
|
||||
"requires": {
|
||||
"async": "~0.2.6",
|
||||
"atom-select-list": "^0.7.0",
|
||||
@@ -5256,22 +5188,22 @@
|
||||
"integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc="
|
||||
},
|
||||
"spell-check": {
|
||||
"version": "https://www.atom.io/api/packages/spell-check/versions/0.74.3/tarball",
|
||||
"integrity": "sha512-QYy0xpSKp8OSZjlvq7fOjrf/NdG4BncHvn9AmO/vcuJvWAoiwEWhqqB+BSA6uSrxOxJeJhbDJSxOrvm4YXs1xQ==",
|
||||
"version": "https://www.atom.io/api/packages/spell-check/versions/0.74.2/tarball",
|
||||
"integrity": "sha512-WhwhDF4nznhQuwnRemZbXODI6aqax2HlHudfLEjbhzkRGjEbfssRK82lRRvCK9LmQh3fAqCqbmELU40NEODJ8Q==",
|
||||
"requires": {
|
||||
"atom-pathspec": "^0.0.0",
|
||||
"atom-select-list": "^0.7.0",
|
||||
"multi-integer-range": "^2.0.0",
|
||||
"natural": "^0.4.0",
|
||||
"spellchecker": "^3.5.1",
|
||||
"spellchecker": "^3.4.4",
|
||||
"spelling-manager": "^1.1.0",
|
||||
"underscore-plus": "^1"
|
||||
}
|
||||
},
|
||||
"spellchecker": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/spellchecker/-/spellchecker-3.5.1.tgz",
|
||||
"integrity": "sha512-R1qUBsDZzio+7MFZN6/AtPUe5NGvnc0wywckuXAlp9akASaYSFqKuI5O8p3rSiA+yKP31qC7Iijjoygmzkh6xw==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/spellchecker/-/spellchecker-3.5.0.tgz",
|
||||
"integrity": "sha512-Xa7XnRulYhh5N/XENeL2O8/875XhLBjos7Bemv0rfcgV6ojNYMSrXscUZUGJwniX2t67eY+lNUJeptD1bMauHQ==",
|
||||
"requires": {
|
||||
"any-promise": "^1.3.0",
|
||||
"nan": "^2.10.0"
|
||||
@@ -5370,38 +5302,24 @@
|
||||
}
|
||||
},
|
||||
"streamroller": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/streamroller/-/streamroller-1.0.1.tgz",
|
||||
"integrity": "sha512-FKL2mEB0A+XTIWSOlBHm2DvdsER5cGraqrUufO0lFMfsVY+Gpb3TC29Z+6/l0Urbb7vtm6m9zJOQBVl6fEkZBA==",
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/streamroller/-/streamroller-0.7.0.tgz",
|
||||
"integrity": "sha1-odG3z4PTmvsNYwSaWsv5NJO99ks=",
|
||||
"requires": {
|
||||
"async": "^2.6.1",
|
||||
"date-format": "^2.0.0",
|
||||
"date-format": "^1.2.0",
|
||||
"debug": "^3.1.0",
|
||||
"fs-extra": "^7.0.0",
|
||||
"lodash": "^4.17.10"
|
||||
"mkdirp": "^0.5.1",
|
||||
"readable-stream": "^2.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"async": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
|
||||
"integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
|
||||
"requires": {
|
||||
"lodash": "^4.17.10"
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
|
||||
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
|
||||
"version": "3.2.5",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.5.tgz",
|
||||
"integrity": "sha512-D61LaDQPQkxJ5AUM2mbSJRbPkNs/TmdmOeLAi1hgDkpDfIfetSrjmWhccwtuResSwMbACjx/xXQofvM9CE/aeg==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.11",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
|
||||
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
|
||||
@@ -5473,9 +5391,9 @@
|
||||
}
|
||||
},
|
||||
"superstring": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/superstring/-/superstring-2.3.6.tgz",
|
||||
"integrity": "sha512-kDTXCXArhHL1lRk2zBW7ByRJByqVwoLK3E3jlf8+LcwQLZgSMs9dwrDHDpBdoOm89kstSBSrGcW8OJqNkxjWrQ==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/superstring/-/superstring-2.3.4.tgz",
|
||||
"integrity": "sha512-DcNkTCdB9F3FMZRdURSALsHi+7DWqFCI0cH+Eg8mwBg+kxQs6GeB3LrGUvCI5bEB6Dtlu2ox8UYN0onPN4JeZQ==",
|
||||
"requires": {
|
||||
"nan": "^2.10.0"
|
||||
}
|
||||
@@ -5518,20 +5436,6 @@
|
||||
"underscore-plus": "1.x"
|
||||
}
|
||||
},
|
||||
"tar": {
|
||||
"version": "4.4.6",
|
||||
"resolved": "https://registry.npmjs.org/tar/-/tar-4.4.6.tgz",
|
||||
"integrity": "sha512-tMkTnh9EdzxyfW+6GK6fCahagXsnYk6kE6S9Gr9pjVdys769+laCTbodXDhPAjzVtEBazRgP0gYqOjnk9dQzLg==",
|
||||
"requires": {
|
||||
"chownr": "^1.0.1",
|
||||
"fs-minipass": "^1.2.5",
|
||||
"minipass": "^2.3.3",
|
||||
"minizlib": "^1.1.0",
|
||||
"mkdirp": "^0.5.0",
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"tar-fs": {
|
||||
"version": "1.16.3",
|
||||
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.3.tgz",
|
||||
@@ -5609,21 +5513,21 @@
|
||||
}
|
||||
},
|
||||
"text-buffer": {
|
||||
"version": "13.15.3",
|
||||
"resolved": "https://registry.npmjs.org/text-buffer/-/text-buffer-13.15.3.tgz",
|
||||
"integrity": "sha512-H2fz/N15g0fBP7R33FUFLnIyND+Lji/xmuvHg9rKgmfCh7NAVxiFIvnZTabuBhL9InqPrtV5t4hkUy+r3dNXMg==",
|
||||
"version": "13.15.1",
|
||||
"resolved": "https://registry.npmjs.org/text-buffer/-/text-buffer-13.15.1.tgz",
|
||||
"integrity": "sha512-LZx7EKhVwjo50Y9ZF6WDP2S4zLUcHAagHZhn6HzHjr0SxyWtm95HG7ApSzgLGvIzCZEoTzMYt62scUdesfzYuw==",
|
||||
"requires": {
|
||||
"delegato": "^1.0.0",
|
||||
"diff": "^2.2.1",
|
||||
"emissary": "^1.0.0",
|
||||
"event-kit": "^2.4.0",
|
||||
"fs-admin": "^0.1.7",
|
||||
"fs-admin": "^0.1.4",
|
||||
"fs-plus": "^3.0.0",
|
||||
"grim": "^2.0.2",
|
||||
"mkdirp": "^0.5.1",
|
||||
"pathwatcher": "8.0.2",
|
||||
"pathwatcher": "8.0.1",
|
||||
"serializable": "^1.0.3",
|
||||
"superstring": "2.3.6",
|
||||
"superstring": "2.3.4",
|
||||
"underscore-plus": "^1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -6066,8 +5970,8 @@
|
||||
"integrity": "sha1-BNoCcKh6d4VAFzzb8KLbSZqNnik="
|
||||
},
|
||||
"welcome": {
|
||||
"version": "https://www.atom.io/api/packages/welcome/versions/0.36.7/tarball",
|
||||
"integrity": "sha512-z1EOTRYfN23fBL75Shrbe/j2VDelw2c8oKRXC2MqLLBiWUCFDkxsEo1R7OfiCaNZi7q/0ue0fqLCpENHker4FA==",
|
||||
"version": "https://www.atom.io/api/packages/welcome/versions/0.36.8/tarball",
|
||||
"integrity": "sha512-U2EFFqgGxqQ5eMFFP3bl5oBSSvb0kx4VZwQVyO8oXqjuveiV2gUSrnDP68C9yCqJxcMR9ZP4ZYTLsf255F7CsA==",
|
||||
"requires": {
|
||||
"etch": "0.9.0"
|
||||
},
|
||||
|
||||
45
package.json
45
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "atom",
|
||||
"productName": "Atom",
|
||||
"version": "1.36.0-dev",
|
||||
"version": "1.37.0-dev",
|
||||
"description": "A hackable text editor for the 21st Century.",
|
||||
"main": "./src/main-process/main.js",
|
||||
"repository": {
|
||||
@@ -12,17 +12,17 @@
|
||||
"url": "https://github.com/atom/atom/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"electronVersion": "3.0.14",
|
||||
"electronVersion": "2.0.16",
|
||||
"dependencies": {
|
||||
"@atom/nsfw": "1.0.21",
|
||||
"@atom/nsfw": "1.0.18",
|
||||
"@atom/source-map-support": "^0.3.4",
|
||||
"@atom/watcher": "1.0.8",
|
||||
"@atom/watcher": "1.3.1",
|
||||
"about": "file:packages/about",
|
||||
"archive-view": "https://www.atom.io/api/packages/archive-view/versions/0.65.1/tarball",
|
||||
"async": "0.2.6",
|
||||
"atom-dark-syntax": "file:packages/atom-dark-syntax",
|
||||
"atom-dark-ui": "file:packages/atom-dark-ui",
|
||||
"atom-keymap": "8.2.12",
|
||||
"atom-keymap": "8.2.13",
|
||||
"atom-light-syntax": "file:packages/atom-light-syntax",
|
||||
"atom-light-ui": "file:packages/atom-light-ui",
|
||||
"atom-select-list": "^0.7.2",
|
||||
@@ -39,6 +39,7 @@
|
||||
"base16-tomorrow-light-theme": "file:packages/base16-tomorrow-light-theme",
|
||||
"bookmarks": "https://www.atom.io/api/packages/bookmarks/versions/0.46.0/tarball",
|
||||
"bracket-matcher": "https://www.atom.io/api/packages/bracket-matcher/versions/0.90.4/tarball",
|
||||
"cached-run-in-this-context": "0.5.0",
|
||||
"chai": "3.5.0",
|
||||
"chart.js": "^2.3.0",
|
||||
"clear-cut": "^2.0.2",
|
||||
@@ -54,15 +55,15 @@
|
||||
"etch": "^0.12.6",
|
||||
"event-kit": "^2.5.3",
|
||||
"exception-reporting": "file:packages/exception-reporting",
|
||||
"find-and-replace": "https://www.atom.io/api/packages/find-and-replace/versions/0.218.0/tarball",
|
||||
"find-and-replace": "https://www.atom.io/api/packages/find-and-replace/versions/0.218.9/tarball",
|
||||
"find-parent-dir": "^0.3.0",
|
||||
"first-mate": "7.1.3",
|
||||
"focus-trap": "2.4.5",
|
||||
"fs-admin": "^0.1.7",
|
||||
"fs-plus": "^3.1.1",
|
||||
"fs-plus": "^3.0.1",
|
||||
"fstream": "0.1.24",
|
||||
"fuzzaldrin": "^2.1",
|
||||
"fuzzy-finder": "https://www.atom.io/api/packages/fuzzy-finder/versions/1.9.0/tarball",
|
||||
"fuzzy-finder": "https://www.atom.io/api/packages/fuzzy-finder/versions/1.9.2/tarball",
|
||||
"git-diff": "file:packages/git-diff",
|
||||
"git-utils": "5.2.1",
|
||||
"github": "https://www.atom.io/api/packages/github/versions/0.26.0/tarball",
|
||||
@@ -88,7 +89,7 @@
|
||||
"language-html": "https://www.atom.io/api/packages/language-html/versions/0.52.0/tarball",
|
||||
"language-hyperlink": "https://www.atom.io/api/packages/language-hyperlink/versions/0.17.0/tarball",
|
||||
"language-java": "https://www.atom.io/api/packages/language-java/versions/0.31.1/tarball",
|
||||
"language-javascript": "https://www.atom.io/api/packages/language-javascript/versions/0.129.19/tarball",
|
||||
"language-javascript": "https://www.atom.io/api/packages/language-javascript/versions/0.129.20/tarball",
|
||||
"language-json": "https://www.atom.io/api/packages/language-json/versions/0.19.2/tarball",
|
||||
"language-less": "https://www.atom.io/api/packages/language-less/versions/0.34.3/tarball",
|
||||
"language-make": "https://www.atom.io/api/packages/language-make/versions/0.23.0/tarball",
|
||||
@@ -132,7 +133,7 @@
|
||||
"one-light-ui": "file:packages/one-light-ui",
|
||||
"open-on-github": "https://www.atom.io/api/packages/open-on-github/versions/1.3.1/tarball",
|
||||
"package-generator": "https://www.atom.io/api/packages/package-generator/versions/1.3.0/tarball",
|
||||
"pathwatcher": "8.0.2",
|
||||
"pathwatcher": "8.0.1",
|
||||
"postcss": "5.2.4",
|
||||
"postcss-selector-parser": "2.2.1",
|
||||
"property-accessors": "^1.1.3",
|
||||
@@ -144,18 +145,18 @@
|
||||
"season": "^6.0.2",
|
||||
"semver": "^4.3.3",
|
||||
"service-hub": "^0.7.4",
|
||||
"settings-view": "https://www.atom.io/api/packages/settings-view/versions/0.259.0/tarball",
|
||||
"settings-view": "https://www.atom.io/api/packages/settings-view/versions/0.260.0/tarball",
|
||||
"sinon": "1.17.4",
|
||||
"snippets": "https://www.atom.io/api/packages/snippets/versions/1.4.0/tarball",
|
||||
"snippets": "https://www.atom.io/api/packages/snippets/versions/1.4.1/tarball",
|
||||
"solarized-dark-syntax": "file:packages/solarized-dark-syntax",
|
||||
"solarized-light-syntax": "file:packages/solarized-light-syntax",
|
||||
"spell-check": "https://www.atom.io/api/packages/spell-check/versions/0.74.3/tarball",
|
||||
"spell-check": "https://www.atom.io/api/packages/spell-check/versions/0.74.2/tarball",
|
||||
"status-bar": "https://www.atom.io/api/packages/status-bar/versions/1.8.17/tarball",
|
||||
"styleguide": "https://www.atom.io/api/packages/styleguide/versions/0.49.12/tarball",
|
||||
"symbols-view": "https://www.atom.io/api/packages/symbols-view/versions/0.118.2/tarball",
|
||||
"tabs": "https://www.atom.io/api/packages/tabs/versions/0.110.0/tarball",
|
||||
"temp": "^0.8.3",
|
||||
"text-buffer": "13.15.3",
|
||||
"text-buffer": "13.15.1",
|
||||
"timecop": "https://www.atom.io/api/packages/timecop/versions/0.36.2/tarball",
|
||||
"tree-sitter": "0.13.23",
|
||||
"tree-sitter-css": "^0.13.7",
|
||||
@@ -163,7 +164,7 @@
|
||||
"typescript-simple": "1.0.0",
|
||||
"underscore-plus": "^1.6.8",
|
||||
"update-package-dependencies": "https://www.atom.io/api/packages/update-package-dependencies/versions/0.13.1/tarball",
|
||||
"welcome": "https://www.atom.io/api/packages/welcome/versions/0.36.7/tarball",
|
||||
"welcome": "https://www.atom.io/api/packages/welcome/versions/0.36.8/tarball",
|
||||
"whitespace": "https://www.atom.io/api/packages/whitespace/versions/0.37.7/tarball",
|
||||
"winreg": "^1.2.1",
|
||||
"wrap-guide": "https://www.atom.io/api/packages/wrap-guide/versions/0.41.0/tarball",
|
||||
@@ -200,8 +201,8 @@
|
||||
"dev-live-reload": "file:./packages/dev-live-reload",
|
||||
"encoding-selector": "0.23.9",
|
||||
"exception-reporting": "file:./packages/exception-reporting",
|
||||
"find-and-replace": "0.218.0",
|
||||
"fuzzy-finder": "1.9.0",
|
||||
"find-and-replace": "0.218.9",
|
||||
"fuzzy-finder": "1.9.2",
|
||||
"github": "0.26.0",
|
||||
"git-diff": "file:./packages/git-diff",
|
||||
"go-to-line": "file:./packages/go-to-line",
|
||||
@@ -216,9 +217,9 @@
|
||||
"notifications": "0.70.6",
|
||||
"open-on-github": "1.3.1",
|
||||
"package-generator": "1.3.0",
|
||||
"settings-view": "0.259.0",
|
||||
"snippets": "1.4.0",
|
||||
"spell-check": "0.74.3",
|
||||
"settings-view": "0.260.0",
|
||||
"snippets": "1.4.1",
|
||||
"spell-check": "0.74.2",
|
||||
"status-bar": "1.8.17",
|
||||
"styleguide": "0.49.12",
|
||||
"symbols-view": "0.118.2",
|
||||
@@ -226,7 +227,7 @@
|
||||
"timecop": "0.36.2",
|
||||
"tree-view": "0.224.5",
|
||||
"update-package-dependencies": "0.13.1",
|
||||
"welcome": "0.36.7",
|
||||
"welcome": "0.36.8",
|
||||
"whitespace": "0.37.7",
|
||||
"wrap-guide": "0.41.0",
|
||||
"language-c": "0.60.14",
|
||||
@@ -240,7 +241,7 @@
|
||||
"language-html": "0.52.0",
|
||||
"language-hyperlink": "0.17.0",
|
||||
"language-java": "0.31.1",
|
||||
"language-javascript": "0.129.19",
|
||||
"language-javascript": "0.129.20",
|
||||
"language-json": "0.19.2",
|
||||
"language-less": "0.34.3",
|
||||
"language-make": "0.23.0",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const {CompositeDisposable, Emitter} = require('atom')
|
||||
const { CompositeDisposable, Emitter } = require('atom')
|
||||
const AboutView = require('./components/about-view')
|
||||
|
||||
// Deferred requires
|
||||
@@ -14,16 +14,22 @@ module.exports = class About {
|
||||
aboutView: null
|
||||
}
|
||||
|
||||
this.subscriptions.add(atom.workspace.addOpener((uriToOpen) => {
|
||||
if (uriToOpen === this.state.uri) {
|
||||
return this.deserialize()
|
||||
}
|
||||
}))
|
||||
this.subscriptions.add(
|
||||
atom.workspace.addOpener(uriToOpen => {
|
||||
if (uriToOpen === this.state.uri) {
|
||||
return this.deserialize()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
this.subscriptions.add(atom.commands.add('atom-workspace', 'about:view-release-notes', () => {
|
||||
shell = shell || require('electron').shell
|
||||
shell.openExternal(this.state.updateManager.getReleaseNotesURLForCurrentVersion())
|
||||
}))
|
||||
this.subscriptions.add(
|
||||
atom.commands.add('atom-workspace', 'about:view-release-notes', () => {
|
||||
shell = shell || require('electron').shell
|
||||
shell.openExternal(
|
||||
this.state.updateManager.getReleaseNotesURLForCurrentVersion()
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
destroy () {
|
||||
@@ -31,14 +37,14 @@ module.exports = class About {
|
||||
this.views.aboutView = null
|
||||
|
||||
if (this.state.updateManager) this.state.updateManager.dispose()
|
||||
this.setState({updateManager: null})
|
||||
this.setState({ updateManager: null })
|
||||
|
||||
this.subscriptions.dispose()
|
||||
}
|
||||
|
||||
setState (newState) {
|
||||
if (newState && typeof newState === 'object') {
|
||||
let {state} = this
|
||||
let { state } = this
|
||||
this.state = Object.assign({}, state, newState)
|
||||
|
||||
this.didChange()
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
const {CompositeDisposable} = require('atom')
|
||||
const { CompositeDisposable } = require('atom')
|
||||
const etch = require('etch')
|
||||
const EtchComponent = require('../etch-component')
|
||||
|
||||
const $ = etch.dom
|
||||
|
||||
module.exports =
|
||||
class AboutStatusBar extends EtchComponent {
|
||||
module.exports = class AboutStatusBar extends EtchComponent {
|
||||
constructor () {
|
||||
super()
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
|
||||
this.subscriptions.add(atom.tooltips.add(this.element, {title: 'An update will be installed the next time Atom is relaunched.<br/><br/>Click the squirrel icon for more information.'}))
|
||||
this.subscriptions.add(
|
||||
atom.tooltips.add(this.element, {
|
||||
title:
|
||||
'An update will be installed the next time Atom is relaunched.<br/><br/>Click the squirrel icon for more information.'
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
handleClick () {
|
||||
@@ -18,8 +22,12 @@ class AboutStatusBar extends EtchComponent {
|
||||
}
|
||||
|
||||
render () {
|
||||
return $.div({className: 'about-release-notes inline-block', onclick: this.handleClick.bind(this)},
|
||||
$.span({type: 'button', className: 'icon icon-squirrel'})
|
||||
return $.div(
|
||||
{
|
||||
className: 'about-release-notes inline-block',
|
||||
onclick: this.handleClick.bind(this)
|
||||
},
|
||||
$.span({ type: 'button', className: 'icon icon-squirrel' })
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const {Disposable} = require('atom')
|
||||
const { Disposable } = require('atom')
|
||||
const etch = require('etch')
|
||||
const shell = require('shell')
|
||||
const AtomLogo = require('./atom-logo')
|
||||
@@ -7,8 +7,7 @@ const UpdateView = require('./update-view')
|
||||
|
||||
const $ = etch.dom
|
||||
|
||||
module.exports =
|
||||
class AboutView extends EtchComponent {
|
||||
module.exports = class AboutView extends EtchComponent {
|
||||
handleAtomVersionClick (e) {
|
||||
e.preventDefault()
|
||||
atom.clipboard.write(this.props.currentAtomVersion)
|
||||
@@ -31,12 +30,17 @@ class AboutView extends EtchComponent {
|
||||
|
||||
handleReleaseNotesClick (e) {
|
||||
e.preventDefault()
|
||||
shell.openExternal(this.props.updateManager.getReleaseNotesURLForAvailableVersion())
|
||||
shell.openExternal(
|
||||
this.props.updateManager.getReleaseNotesURLForAvailableVersion()
|
||||
)
|
||||
}
|
||||
|
||||
handleLicenseClick (e) {
|
||||
e.preventDefault()
|
||||
atom.commands.dispatch(atom.views.getView(atom.workspace), 'application:open-license')
|
||||
atom.commands.dispatch(
|
||||
atom.views.getView(atom.workspace),
|
||||
'application:open-license'
|
||||
)
|
||||
}
|
||||
|
||||
handleTermsOfUseClick (e) {
|
||||
@@ -46,7 +50,9 @@ class AboutView extends EtchComponent {
|
||||
|
||||
handleHowToUpdateClick (e) {
|
||||
e.preventDefault()
|
||||
shell.openExternal('https://flight-manual.atom.io/getting-started/sections/installing-atom/')
|
||||
shell.openExternal(
|
||||
'https://flight-manual.atom.io/getting-started/sections/installing-atom/'
|
||||
)
|
||||
}
|
||||
|
||||
handleShowMoreClick (e) {
|
||||
@@ -66,39 +72,87 @@ class AboutView extends EtchComponent {
|
||||
}
|
||||
|
||||
render () {
|
||||
return $.div({className: 'pane-item native-key-bindings about'},
|
||||
$.div({className: 'about-container'},
|
||||
$.header({className: 'about-header'},
|
||||
$.a({className: 'about-atom-io', href: 'https://atom.io'},
|
||||
return $.div(
|
||||
{ className: 'pane-item native-key-bindings about' },
|
||||
$.div(
|
||||
{ className: 'about-container' },
|
||||
$.header(
|
||||
{ className: 'about-header' },
|
||||
$.a(
|
||||
{ className: 'about-atom-io', href: 'https://atom.io' },
|
||||
$(AtomLogo)
|
||||
),
|
||||
$.div({className: 'about-header-info'},
|
||||
$.span({className: 'about-version-container inline-block atom', onclick: this.handleAtomVersionClick.bind(this)},
|
||||
$.span({className: 'about-version'}, `${this.props.currentAtomVersion} ${process.arch}`),
|
||||
$.span({className: 'icon icon-clippy about-copy-version'})
|
||||
$.div(
|
||||
{ className: 'about-header-info' },
|
||||
$.span(
|
||||
{
|
||||
className: 'about-version-container inline-block atom',
|
||||
onclick: this.handleAtomVersionClick.bind(this)
|
||||
},
|
||||
$.span(
|
||||
{ className: 'about-version' },
|
||||
`${this.props.currentAtomVersion} ${process.arch}`
|
||||
),
|
||||
$.span({ className: 'icon icon-clippy about-copy-version' })
|
||||
),
|
||||
$.a({className: 'about-header-release-notes', onclick: this.handleReleaseNotesClick.bind(this)}, 'Release Notes')
|
||||
$.a(
|
||||
{
|
||||
className: 'about-header-release-notes',
|
||||
onclick: this.handleReleaseNotesClick.bind(this)
|
||||
},
|
||||
'Release Notes'
|
||||
)
|
||||
),
|
||||
$.span({className: 'about-version-container inline-block show-more-expand', onclick: this.handleShowMoreClick.bind(this)},
|
||||
$.span({className: 'about-more-expand'}, 'Show more')
|
||||
$.span(
|
||||
{
|
||||
className:
|
||||
'about-version-container inline-block show-more-expand',
|
||||
onclick: this.handleShowMoreClick.bind(this)
|
||||
},
|
||||
$.span({ className: 'about-more-expand' }, 'Show more')
|
||||
),
|
||||
$.div({className: 'show-more hidden about-more-info'},
|
||||
$.div({className: 'about-more-info'},
|
||||
$.span({className: 'about-version-container inline-block electron', onclick: this.handleElectronVersionClick.bind(this)},
|
||||
$.span({className: 'about-more-version'}, `Electron: ${this.props.currentElectronVersion} `),
|
||||
$.span({className: 'icon icon-clippy about-copy-version'})
|
||||
$.div(
|
||||
{ className: 'show-more hidden about-more-info' },
|
||||
$.div(
|
||||
{ className: 'about-more-info' },
|
||||
$.span(
|
||||
{
|
||||
className: 'about-version-container inline-block electron',
|
||||
onclick: this.handleElectronVersionClick.bind(this)
|
||||
},
|
||||
$.span(
|
||||
{ className: 'about-more-version' },
|
||||
`Electron: ${this.props.currentElectronVersion} `
|
||||
),
|
||||
$.span({ className: 'icon icon-clippy about-copy-version' })
|
||||
)
|
||||
),
|
||||
$.div({className: 'about-more-info'},
|
||||
$.span({className: 'about-version-container inline-block chrome', onclick: this.handleChromeVersionClick.bind(this)},
|
||||
$.span({className: 'about-more-version'}, `Chrome: ${this.props.currentChromeVersion} `),
|
||||
$.span({className: 'icon icon-clippy about-copy-version'})
|
||||
$.div(
|
||||
{ className: 'about-more-info' },
|
||||
$.span(
|
||||
{
|
||||
className: 'about-version-container inline-block chrome',
|
||||
onclick: this.handleChromeVersionClick.bind(this)
|
||||
},
|
||||
$.span(
|
||||
{ className: 'about-more-version' },
|
||||
`Chrome: ${this.props.currentChromeVersion} `
|
||||
),
|
||||
$.span({ className: 'icon icon-clippy about-copy-version' })
|
||||
)
|
||||
),
|
||||
$.div({className: 'about-more-info'},
|
||||
$.span({className: 'about-version-container inline-block node', onclick: this.handleNodeVersionClick.bind(this)},
|
||||
$.span({className: 'about-more-version'}, `Node: ${this.props.currentNodeVersion} `),
|
||||
$.span({className: 'icon icon-clippy about-copy-version'})
|
||||
$.div(
|
||||
{ className: 'about-more-info' },
|
||||
$.span(
|
||||
{
|
||||
className: 'about-version-container inline-block node',
|
||||
onclick: this.handleNodeVersionClick.bind(this)
|
||||
},
|
||||
$.span(
|
||||
{ className: 'about-more-version' },
|
||||
`Node: ${this.props.currentNodeVersion} `
|
||||
),
|
||||
$.span({ className: 'icon icon-clippy about-copy-version' })
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -112,24 +166,43 @@ class AboutView extends EtchComponent {
|
||||
viewUpdateInstructions: this.handleHowToUpdateClick.bind(this)
|
||||
}),
|
||||
|
||||
$.div({className: 'about-actions group-item'},
|
||||
$.div({className: 'btn-group'},
|
||||
$.button({className: 'btn view-license', onclick: this.handleLicenseClick.bind(this)}, 'License'),
|
||||
$.button({className: 'btn terms-of-use', onclick: this.handleTermsOfUseClick.bind(this)}, 'Terms of Use')
|
||||
$.div(
|
||||
{ className: 'about-actions group-item' },
|
||||
$.div(
|
||||
{ className: 'btn-group' },
|
||||
$.button(
|
||||
{
|
||||
className: 'btn view-license',
|
||||
onclick: this.handleLicenseClick.bind(this)
|
||||
},
|
||||
'License'
|
||||
),
|
||||
$.button(
|
||||
{
|
||||
className: 'btn terms-of-use',
|
||||
onclick: this.handleTermsOfUseClick.bind(this)
|
||||
},
|
||||
'Terms of Use'
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
$.div({className: 'about-love group-start'},
|
||||
$.span({className: 'icon icon-code'}),
|
||||
$.span({className: 'inline'}, ' with '),
|
||||
$.span({className: 'icon icon-heart'}),
|
||||
$.span({className: 'inline'}, ' by '),
|
||||
$.a({className: 'icon icon-logo-github', href: 'https://github.com'})
|
||||
$.div(
|
||||
{ className: 'about-love group-start' },
|
||||
$.span({ className: 'icon icon-code' }),
|
||||
$.span({ className: 'inline' }, ' with '),
|
||||
$.span({ className: 'icon icon-heart' }),
|
||||
$.span({ className: 'inline' }, ' by '),
|
||||
$.a({ className: 'icon icon-logo-github', href: 'https://github.com' })
|
||||
),
|
||||
|
||||
$.div({className: 'about-credits group-item'},
|
||||
$.span({className: 'inline'}, 'And the awesome '),
|
||||
$.a({href: 'https://github.com/atom/atom/contributors'}, 'Atom Community')
|
||||
$.div(
|
||||
{ className: 'about-credits group-item' },
|
||||
$.span({ className: 'inline' }, 'And the awesome '),
|
||||
$.a(
|
||||
{ href: 'https://github.com/atom/atom/contributors' },
|
||||
'Atom Community'
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,23 +3,74 @@ const EtchComponent = require('../etch-component')
|
||||
|
||||
const $ = etch.dom
|
||||
|
||||
module.exports =
|
||||
class AtomLogo extends EtchComponent {
|
||||
module.exports = class AtomLogo extends EtchComponent {
|
||||
render () {
|
||||
return $.svg({className: 'about-logo', width: '330px', height: '68px', viewBox: '0 0 330 68'},
|
||||
$.g({stroke: 'none', 'stroke-width': '1', fill: 'none', 'fill-rule': 'evenodd'},
|
||||
$.g({transform: 'translate(2.000000, 1.000000)'},
|
||||
$.g({transform: 'translate(96.000000, 8.000000)', fill: 'currentColor'},
|
||||
$.path({d: 'M185.498,3.399 C185.498,2.417 186.34,1.573 187.324,1.573 L187.674,1.573 C188.447,1.573 189.01,1.995 189.5,2.628 L208.676,30.862 L227.852,2.628 C228.272,1.995 228.905,1.573 229.676,1.573 L230.028,1.573 C231.01,1.573 231.854,2.417 231.854,3.399 L231.854,49.403 C231.854,50.387 231.01,51.231 230.028,51.231 C229.044,51.231 228.202,50.387 228.202,49.403 L228.202,8.246 L210.151,34.515 C209.729,35.148 209.237,35.428 208.606,35.428 C207.973,35.428 207.481,35.148 207.061,34.515 L189.01,8.246 L189.01,49.475 C189.01,50.457 188.237,51.231 187.254,51.231 C186.27,51.231 185.498,50.458 185.498,49.475 L185.498,3.399 L185.498,3.399 Z'}),
|
||||
$.path({d: 'M113.086,26.507 L113.086,26.367 C113.086,12.952 122.99,0.941 137.881,0.941 C152.77,0.941 162.533,12.811 162.533,26.225 L162.533,26.367 C162.533,39.782 152.629,51.792 137.74,51.792 C122.85,51.792 113.086,39.923 113.086,26.507 M158.74,26.507 L158.74,26.367 C158.74,14.216 149.89,4.242 137.74,4.242 C125.588,4.242 116.879,14.075 116.879,26.225 L116.879,26.367 C116.879,38.518 125.729,48.491 137.881,48.491 C150.031,48.491 158.74,38.658 158.74,26.507'}),
|
||||
$.path({d: 'M76.705,5.155 L60.972,5.155 C60.06,5.155 59.287,4.384 59.287,3.469 C59.287,2.556 60.059,1.783 60.972,1.783 L96.092,1.783 C97.004,1.783 97.778,2.555 97.778,3.469 C97.778,4.383 97.005,5.155 96.092,5.155 L80.358,5.155 L80.358,49.405 C80.358,50.387 79.516,51.231 78.532,51.231 C77.55,51.231 76.706,50.387 76.706,49.405 L76.706,5.155 L76.705,5.155 Z'}),
|
||||
$.path({d: 'M0.291,48.562 L21.291,3.05 C21.783,1.995 22.485,1.292 23.75,1.292 L23.891,1.292 C25.155,1.292 25.858,1.995 26.348,3.05 L47.279,48.421 C47.49,48.843 47.56,49.194 47.56,49.546 C47.56,50.458 46.788,51.231 45.803,51.231 C44.961,51.231 44.329,50.599 43.978,49.826 L38.219,37.183 L9.21,37.183 L3.45,49.897 C3.099,50.739 2.538,51.231 1.694,51.231 C0.781,51.231 0.008,50.529 0.008,49.685 C0.009,49.404 0.08,48.983 0.291,48.562 L0.291,48.562 Z M36.673,33.882 L23.749,5.437 L10.755,33.882 L36.673,33.882 L36.673,33.882 Z'})
|
||||
return $.svg(
|
||||
{
|
||||
className: 'about-logo',
|
||||
width: '330px',
|
||||
height: '68px',
|
||||
viewBox: '0 0 330 68'
|
||||
},
|
||||
$.g(
|
||||
{
|
||||
stroke: 'none',
|
||||
'stroke-width': '1',
|
||||
fill: 'none',
|
||||
'fill-rule': 'evenodd'
|
||||
},
|
||||
$.g(
|
||||
{ transform: 'translate(2.000000, 1.000000)' },
|
||||
$.g(
|
||||
{
|
||||
transform: 'translate(96.000000, 8.000000)',
|
||||
fill: 'currentColor'
|
||||
},
|
||||
$.path({
|
||||
d:
|
||||
'M185.498,3.399 C185.498,2.417 186.34,1.573 187.324,1.573 L187.674,1.573 C188.447,1.573 189.01,1.995 189.5,2.628 L208.676,30.862 L227.852,2.628 C228.272,1.995 228.905,1.573 229.676,1.573 L230.028,1.573 C231.01,1.573 231.854,2.417 231.854,3.399 L231.854,49.403 C231.854,50.387 231.01,51.231 230.028,51.231 C229.044,51.231 228.202,50.387 228.202,49.403 L228.202,8.246 L210.151,34.515 C209.729,35.148 209.237,35.428 208.606,35.428 C207.973,35.428 207.481,35.148 207.061,34.515 L189.01,8.246 L189.01,49.475 C189.01,50.457 188.237,51.231 187.254,51.231 C186.27,51.231 185.498,50.458 185.498,49.475 L185.498,3.399 L185.498,3.399 Z'
|
||||
}),
|
||||
$.path({
|
||||
d:
|
||||
'M113.086,26.507 L113.086,26.367 C113.086,12.952 122.99,0.941 137.881,0.941 C152.77,0.941 162.533,12.811 162.533,26.225 L162.533,26.367 C162.533,39.782 152.629,51.792 137.74,51.792 C122.85,51.792 113.086,39.923 113.086,26.507 M158.74,26.507 L158.74,26.367 C158.74,14.216 149.89,4.242 137.74,4.242 C125.588,4.242 116.879,14.075 116.879,26.225 L116.879,26.367 C116.879,38.518 125.729,48.491 137.881,48.491 C150.031,48.491 158.74,38.658 158.74,26.507'
|
||||
}),
|
||||
$.path({
|
||||
d:
|
||||
'M76.705,5.155 L60.972,5.155 C60.06,5.155 59.287,4.384 59.287,3.469 C59.287,2.556 60.059,1.783 60.972,1.783 L96.092,1.783 C97.004,1.783 97.778,2.555 97.778,3.469 C97.778,4.383 97.005,5.155 96.092,5.155 L80.358,5.155 L80.358,49.405 C80.358,50.387 79.516,51.231 78.532,51.231 C77.55,51.231 76.706,50.387 76.706,49.405 L76.706,5.155 L76.705,5.155 Z'
|
||||
}),
|
||||
$.path({
|
||||
d:
|
||||
'M0.291,48.562 L21.291,3.05 C21.783,1.995 22.485,1.292 23.75,1.292 L23.891,1.292 C25.155,1.292 25.858,1.995 26.348,3.05 L47.279,48.421 C47.49,48.843 47.56,49.194 47.56,49.546 C47.56,50.458 46.788,51.231 45.803,51.231 C44.961,51.231 44.329,50.599 43.978,49.826 L38.219,37.183 L9.21,37.183 L3.45,49.897 C3.099,50.739 2.538,51.231 1.694,51.231 C0.781,51.231 0.008,50.529 0.008,49.685 C0.009,49.404 0.08,48.983 0.291,48.562 L0.291,48.562 Z M36.673,33.882 L23.749,5.437 L10.755,33.882 L36.673,33.882 L36.673,33.882 Z'
|
||||
})
|
||||
),
|
||||
$.g({},
|
||||
$.path({d: 'M40.363,32.075 C40.874,34.44 39.371,36.77 37.006,37.282 C34.641,37.793 32.311,36.29 31.799,33.925 C31.289,31.56 32.791,29.23 35.156,28.718 C37.521,28.207 39.851,29.71 40.363,32.075', fill: 'currentColor'}),
|
||||
$.path({d: 'M48.578,28.615 C56.851,45.587 58.558,61.581 52.288,64.778 C45.822,68.076 33.326,56.521 24.375,38.969 C15.424,21.418 13.409,4.518 19.874,1.221 C22.689,-0.216 26.648,1.166 30.959,4.629', stroke: 'currentColor', 'stroke-width': '3.08', 'stroke-linecap': 'round'}),
|
||||
$.path({d: 'M7.64,39.45 C2.806,36.94 -0.009,33.915 0.154,30.79 C0.531,23.542 16.787,18.497 36.462,19.52 C56.137,20.544 71.781,27.249 71.404,34.497 C71.241,37.622 68.127,40.338 63.06,42.333', stroke: 'currentColor', 'stroke-width': '3.08', 'stroke-linecap': 'round'}),
|
||||
$.path({d: 'M28.828,59.354 C23.545,63.168 18.843,64.561 15.902,62.653 C9.814,58.702 13.572,42.102 24.296,25.575 C35.02,9.048 48.649,-1.149 54.736,2.803 C57.566,4.639 58.269,9.208 57.133,15.232', stroke: 'currentColor', 'stroke-width': '3.08', 'stroke-linecap': 'round'})
|
||||
$.g(
|
||||
{},
|
||||
$.path({
|
||||
d:
|
||||
'M40.363,32.075 C40.874,34.44 39.371,36.77 37.006,37.282 C34.641,37.793 32.311,36.29 31.799,33.925 C31.289,31.56 32.791,29.23 35.156,28.718 C37.521,28.207 39.851,29.71 40.363,32.075',
|
||||
fill: 'currentColor'
|
||||
}),
|
||||
$.path({
|
||||
d:
|
||||
'M48.578,28.615 C56.851,45.587 58.558,61.581 52.288,64.778 C45.822,68.076 33.326,56.521 24.375,38.969 C15.424,21.418 13.409,4.518 19.874,1.221 C22.689,-0.216 26.648,1.166 30.959,4.629',
|
||||
stroke: 'currentColor',
|
||||
'stroke-width': '3.08',
|
||||
'stroke-linecap': 'round'
|
||||
}),
|
||||
$.path({
|
||||
d:
|
||||
'M7.64,39.45 C2.806,36.94 -0.009,33.915 0.154,30.79 C0.531,23.542 16.787,18.497 36.462,19.52 C56.137,20.544 71.781,27.249 71.404,34.497 C71.241,37.622 68.127,40.338 63.06,42.333',
|
||||
stroke: 'currentColor',
|
||||
'stroke-width': '3.08',
|
||||
'stroke-linecap': 'round'
|
||||
}),
|
||||
$.path({
|
||||
d:
|
||||
'M28.828,59.354 C23.545,63.168 18.843,64.561 15.902,62.653 C9.814,58.702 13.572,42.102 24.296,25.575 C35.02,9.048 48.649,-1.149 54.736,2.803 C57.566,4.639 58.269,9.208 57.133,15.232',
|
||||
stroke: 'currentColor',
|
||||
'stroke-width': '3.08',
|
||||
'stroke-linecap': 'round'
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -4,12 +4,14 @@ const UpdateManager = require('../update-manager')
|
||||
|
||||
const $ = etch.dom
|
||||
|
||||
module.exports =
|
||||
class UpdateView extends EtchComponent {
|
||||
module.exports = class UpdateView extends EtchComponent {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
|
||||
if (this.props.updateManager.getAutoUpdatesEnabled() && this.props.updateManager.getState() === UpdateManager.State.Idle) {
|
||||
if (
|
||||
this.props.updateManager.getAutoUpdatesEnabled() &&
|
||||
this.props.updateManager.getState() === UpdateManager.State.Idle
|
||||
) {
|
||||
this.props.updateManager.checkForUpdate()
|
||||
}
|
||||
}
|
||||
@@ -19,12 +21,18 @@ class UpdateView extends EtchComponent {
|
||||
}
|
||||
|
||||
shouldUpdateActionButtonBeDisabled () {
|
||||
let {state} = this.props.updateManager
|
||||
return state === UpdateManager.State.CheckingForUpdate || state === UpdateManager.State.DownloadingUpdate
|
||||
let { state } = this.props.updateManager
|
||||
return (
|
||||
state === UpdateManager.State.CheckingForUpdate ||
|
||||
state === UpdateManager.State.DownloadingUpdate
|
||||
)
|
||||
}
|
||||
|
||||
executeUpdateAction () {
|
||||
if (this.props.updateManager.state === UpdateManager.State.UpdateAvailableToInstall) {
|
||||
if (
|
||||
this.props.updateManager.state ===
|
||||
UpdateManager.State.UpdateAvailableToInstall
|
||||
) {
|
||||
this.props.updateManager.restartAndInstallUpdate()
|
||||
} else {
|
||||
this.props.updateManager.checkForUpdate()
|
||||
@@ -36,44 +44,86 @@ class UpdateView extends EtchComponent {
|
||||
|
||||
switch (this.props.updateManager.state) {
|
||||
case UpdateManager.State.Idle:
|
||||
updateStatus = $.div({className: 'about-updates-item is-shown about-default-update-message'},
|
||||
this.props.updateManager.getAutoUpdatesEnabled() ? 'Atom will check for updates automatically' : 'Automatic updates are disabled please check manually'
|
||||
updateStatus = $.div(
|
||||
{
|
||||
className:
|
||||
'about-updates-item is-shown about-default-update-message'
|
||||
},
|
||||
this.props.updateManager.getAutoUpdatesEnabled()
|
||||
? 'Atom will check for updates automatically'
|
||||
: 'Automatic updates are disabled please check manually'
|
||||
)
|
||||
break
|
||||
case UpdateManager.State.CheckingForUpdate:
|
||||
updateStatus = $.div({className: 'about-updates-item app-checking-for-updates'},
|
||||
$.span({className: 'about-updates-label icon icon-search'}, 'Checking for updates...')
|
||||
updateStatus = $.div(
|
||||
{ className: 'about-updates-item app-checking-for-updates' },
|
||||
$.span(
|
||||
{ className: 'about-updates-label icon icon-search' },
|
||||
'Checking for updates...'
|
||||
)
|
||||
)
|
||||
break
|
||||
case UpdateManager.State.DownloadingUpdate:
|
||||
updateStatus = $.div({className: 'about-updates-item app-downloading-update'},
|
||||
$.span({className: 'loading loading-spinner-tiny inline-block'}),
|
||||
$.span({className: 'about-updates-label'}, 'Downloading update')
|
||||
updateStatus = $.div(
|
||||
{ className: 'about-updates-item app-downloading-update' },
|
||||
$.span({ className: 'loading loading-spinner-tiny inline-block' }),
|
||||
$.span({ className: 'about-updates-label' }, 'Downloading update')
|
||||
)
|
||||
break
|
||||
case UpdateManager.State.UpdateAvailableToInstall:
|
||||
updateStatus = $.div({className: 'about-updates-item app-update-available-to-install'},
|
||||
$.span({className: 'about-updates-label icon icon-squirrel'}, 'New update'),
|
||||
$.span({className: 'about-updates-version'}, this.props.availableVersion),
|
||||
$.a({className: 'about-updates-release-notes', onclick: this.props.viewUpdateReleaseNotes}, 'Release Notes')
|
||||
updateStatus = $.div(
|
||||
{ className: 'about-updates-item app-update-available-to-install' },
|
||||
$.span(
|
||||
{ className: 'about-updates-label icon icon-squirrel' },
|
||||
'New update'
|
||||
),
|
||||
$.span(
|
||||
{ className: 'about-updates-version' },
|
||||
this.props.availableVersion
|
||||
),
|
||||
$.a(
|
||||
{
|
||||
className: 'about-updates-release-notes',
|
||||
onclick: this.props.viewUpdateReleaseNotes
|
||||
},
|
||||
'Release Notes'
|
||||
)
|
||||
)
|
||||
break
|
||||
case UpdateManager.State.UpToDate:
|
||||
updateStatus = $.div({className: 'about-updates-item app-up-to-date'},
|
||||
$.span({className: 'icon icon-check'}),
|
||||
$.span({className: 'about-updates-label is-strong'}, 'Atom is up to date!')
|
||||
updateStatus = $.div(
|
||||
{ className: 'about-updates-item app-up-to-date' },
|
||||
$.span({ className: 'icon icon-check' }),
|
||||
$.span(
|
||||
{ className: 'about-updates-label is-strong' },
|
||||
'Atom is up to date!'
|
||||
)
|
||||
)
|
||||
break
|
||||
case UpdateManager.State.Unsupported:
|
||||
updateStatus = $.div({className: 'about-updates-item app-unsupported'},
|
||||
$.span({className: 'about-updates-label is-strong'}, 'Your system does not support automatic updates'),
|
||||
$.a({className: 'about-updates-instructions', onclick: this.props.viewUpdateInstructions}, 'How to update')
|
||||
updateStatus = $.div(
|
||||
{ className: 'about-updates-item app-unsupported' },
|
||||
$.span(
|
||||
{ className: 'about-updates-label is-strong' },
|
||||
'Your system does not support automatic updates'
|
||||
),
|
||||
$.a(
|
||||
{
|
||||
className: 'about-updates-instructions',
|
||||
onclick: this.props.viewUpdateInstructions
|
||||
},
|
||||
'How to update'
|
||||
)
|
||||
)
|
||||
break
|
||||
case UpdateManager.State.Error:
|
||||
updateStatus = $.div({className: 'about-updates-item app-update-error'},
|
||||
$.span({className: 'icon icon-x'}),
|
||||
$.span({className: 'about-updates-label app-error-message is-strong'}, this.props.updateManager.getErrorMessage())
|
||||
updateStatus = $.div(
|
||||
{ className: 'about-updates-item app-update-error' },
|
||||
$.span({ className: 'icon icon-x' }),
|
||||
$.span(
|
||||
{ className: 'about-updates-label app-error-message is-strong' },
|
||||
this.props.updateManager.getErrorMessage()
|
||||
)
|
||||
)
|
||||
break
|
||||
}
|
||||
@@ -82,37 +132,47 @@ class UpdateView extends EtchComponent {
|
||||
}
|
||||
|
||||
render () {
|
||||
return $.div({className: 'about-updates group-start'},
|
||||
$.div({className: 'about-updates-box'},
|
||||
$.div({className: 'about-updates-status'}, this.renderUpdateStatus()),
|
||||
return $.div(
|
||||
{ className: 'about-updates group-start' },
|
||||
$.div(
|
||||
{ className: 'about-updates-box' },
|
||||
$.div({ className: 'about-updates-status' }, this.renderUpdateStatus()),
|
||||
$.button(
|
||||
{
|
||||
className: 'btn about-update-action-button',
|
||||
disabled: this.shouldUpdateActionButtonBeDisabled(),
|
||||
onclick: this.executeUpdateAction.bind(this),
|
||||
style: {
|
||||
display: this.props.updateManager.state === UpdateManager.State.Unsupported ? 'none' : 'block'
|
||||
display:
|
||||
this.props.updateManager.state ===
|
||||
UpdateManager.State.Unsupported
|
||||
? 'none'
|
||||
: 'block'
|
||||
}
|
||||
},
|
||||
this.props.updateManager.state === 'update-available' ? 'Restart and install' : 'Check now'
|
||||
this.props.updateManager.state === 'update-available'
|
||||
? 'Restart and install'
|
||||
: 'Check now'
|
||||
)
|
||||
),
|
||||
$.div(
|
||||
{
|
||||
className: 'about-auto-updates',
|
||||
style: {
|
||||
display: this.props.updateManager.state === UpdateManager.State.Unsupported ? 'none' : 'block'
|
||||
display:
|
||||
this.props.updateManager.state === UpdateManager.State.Unsupported
|
||||
? 'none'
|
||||
: 'block'
|
||||
}
|
||||
},
|
||||
$.label({},
|
||||
$.input(
|
||||
{
|
||||
className: 'input-checkbox',
|
||||
type: 'checkbox',
|
||||
checked: this.props.updateManager.getAutoUpdatesEnabled(),
|
||||
onchange: this.handleAutoUpdateCheckbox.bind(this)
|
||||
}
|
||||
),
|
||||
$.label(
|
||||
{},
|
||||
$.input({
|
||||
className: 'input-checkbox',
|
||||
type: 'checkbox',
|
||||
checked: this.props.updateManager.getAutoUpdatesEnabled(),
|
||||
onchange: this.handleAutoUpdateCheckbox.bind(this)
|
||||
}),
|
||||
$.span({}, 'Automatically download updates')
|
||||
)
|
||||
)
|
||||
|
||||
@@ -4,8 +4,7 @@ const etch = require('etch')
|
||||
Public: Abstract class for handling the initialization
|
||||
boilerplate of an Etch component.
|
||||
*/
|
||||
module.exports =
|
||||
class EtchComponent {
|
||||
module.exports = class EtchComponent {
|
||||
constructor (props) {
|
||||
this.props = props
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const {CompositeDisposable} = require('atom')
|
||||
const { CompositeDisposable } = require('atom')
|
||||
const semver = require('semver')
|
||||
const UpdateManager = require('./update-manager')
|
||||
const About = require('./about')
|
||||
@@ -16,20 +16,33 @@ module.exports = {
|
||||
this.createModel()
|
||||
|
||||
let availableVersion = window.localStorage.getItem(AvailableUpdateVersion)
|
||||
if (atom.getReleaseChannel() === 'dev' || (availableVersion && semver.lte(availableVersion, atom.getVersion()))) {
|
||||
if (
|
||||
atom.getReleaseChannel() === 'dev' ||
|
||||
(availableVersion && semver.lte(availableVersion, atom.getVersion()))
|
||||
) {
|
||||
this.clearUpdateState()
|
||||
}
|
||||
|
||||
this.subscriptions.add(updateManager.onDidChange(() => {
|
||||
if (updateManager.getState() === UpdateManager.State.UpdateAvailableToInstall) {
|
||||
window.localStorage.setItem(AvailableUpdateVersion, updateManager.getAvailableVersion())
|
||||
this.showStatusBarIfNeeded()
|
||||
}
|
||||
}))
|
||||
this.subscriptions.add(
|
||||
updateManager.onDidChange(() => {
|
||||
if (
|
||||
updateManager.getState() ===
|
||||
UpdateManager.State.UpdateAvailableToInstall
|
||||
) {
|
||||
window.localStorage.setItem(
|
||||
AvailableUpdateVersion,
|
||||
updateManager.getAvailableVersion()
|
||||
)
|
||||
this.showStatusBarIfNeeded()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
this.subscriptions.add(atom.commands.add('atom-workspace', 'about:clear-update-state', () => {
|
||||
this.clearUpdateState()
|
||||
}))
|
||||
this.subscriptions.add(
|
||||
atom.commands.add('atom-workspace', 'about:clear-update-state', () => {
|
||||
this.clearUpdateState()
|
||||
})
|
||||
)
|
||||
},
|
||||
|
||||
deactivate () {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const {Emitter, CompositeDisposable} = require('atom')
|
||||
const { Emitter, CompositeDisposable } = require('atom')
|
||||
|
||||
const Unsupported = 'unsupported'
|
||||
const Idle = 'idle'
|
||||
@@ -27,7 +27,7 @@ let UpdateManager = class UpdateManager {
|
||||
atom.autoUpdater.onDidBeginDownloadingUpdate(() => {
|
||||
this.setState(DownloadingUpdate)
|
||||
}),
|
||||
atom.autoUpdater.onDidCompleteDownloadingUpdate(({releaseVersion}) => {
|
||||
atom.autoUpdater.onDidCompleteDownloadingUpdate(({ releaseVersion }) => {
|
||||
this.setAvailableVersion(releaseVersion)
|
||||
}),
|
||||
atom.autoUpdater.onUpdateNotAvailable(() => {
|
||||
@@ -36,7 +36,7 @@ let UpdateManager = class UpdateManager {
|
||||
atom.autoUpdater.onUpdateError(() => {
|
||||
this.setState(ErrorState)
|
||||
}),
|
||||
atom.config.observe('core.automaticallyUpdate', (value) => {
|
||||
atom.config.observe('core.automaticallyUpdate', value => {
|
||||
this.autoUpdatesEnabled = value
|
||||
this.emitDidChange()
|
||||
})
|
||||
@@ -61,7 +61,9 @@ let UpdateManager = class UpdateManager {
|
||||
}
|
||||
|
||||
getAutoUpdatesEnabled () {
|
||||
return this.autoUpdatesEnabled && this.state !== UpdateManager.State.Unsupported
|
||||
return (
|
||||
this.autoUpdatesEnabled && this.state !== UpdateManager.State.Unsupported
|
||||
)
|
||||
}
|
||||
|
||||
setAutoUpdatesEnabled (enabled) {
|
||||
@@ -82,7 +84,9 @@ let UpdateManager = class UpdateManager {
|
||||
}
|
||||
|
||||
resetState () {
|
||||
this.state = atom.autoUpdater.platformSupportsUpdates() ? atom.autoUpdater.getState() : Unsupported
|
||||
this.state = atom.autoUpdater.platformSupportsUpdates()
|
||||
? atom.autoUpdater.getState()
|
||||
: Unsupported
|
||||
this.emitDidChange()
|
||||
}
|
||||
|
||||
@@ -128,7 +132,8 @@ let UpdateManager = class UpdateManager {
|
||||
appVersion = `v${appVersion}`
|
||||
}
|
||||
|
||||
const releaseRepo = appVersion.indexOf('nightly') > -1 ? 'atom-nightly-releases' : 'atom'
|
||||
const releaseRepo =
|
||||
appVersion.indexOf('nightly') > -1 ? 'atom-nightly-releases' : 'atom'
|
||||
return `https://github.com/atom/${releaseRepo}/releases/tag/${appVersion}`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const {it, fit, ffit, fffit, beforeEach, afterEach} = require('./helpers/async-spec-helpers') // eslint-disable-line no-unused-vars
|
||||
|
||||
describe('About', () => {
|
||||
let workspaceElement
|
||||
|
||||
@@ -9,7 +7,7 @@ describe('About', () => {
|
||||
spyOn(window.localStorage, 'setItem').andCallFake((key, value) => {
|
||||
storage[key] = value
|
||||
})
|
||||
spyOn(window.localStorage, 'getItem').andCallFake((key) => {
|
||||
spyOn(window.localStorage, 'getItem').andCallFake(key => {
|
||||
return storage[key]
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const {it, fit, ffit, fffit, beforeEach, afterEach, conditionPromise} = require('./helpers/async-spec-helpers') // eslint-disable-line no-unused-vars
|
||||
const { conditionPromise } = require('./helpers/async-spec-helpers')
|
||||
const MockUpdater = require('./mocks/updater')
|
||||
|
||||
describe('the status bar', () => {
|
||||
@@ -11,7 +11,7 @@ describe('the status bar', () => {
|
||||
spyOn(window.localStorage, 'setItem').andCallFake((key, value) => {
|
||||
storage[key] = value
|
||||
})
|
||||
spyOn(window.localStorage, 'getItem').andCallFake((key) => {
|
||||
spyOn(window.localStorage, 'getItem').andCallFake(key => {
|
||||
return storage[key]
|
||||
})
|
||||
spyOn(atom, 'getVersion').andCallFake(() => {
|
||||
|
||||
@@ -1,36 +1,7 @@
|
||||
/** @babel */
|
||||
|
||||
const {now} = Date
|
||||
const {setTimeout} = global
|
||||
|
||||
export function beforeEach (fn) {
|
||||
global.beforeEach(function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function afterEach (fn) {
|
||||
global.afterEach(function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
['it', 'fit', 'ffit', 'fffit'].forEach(function (name) {
|
||||
module.exports[name] = function (description, fn) {
|
||||
global[name](description, function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
const { now } = Date
|
||||
const { setTimeout } = global
|
||||
|
||||
export async function conditionPromise (condition) {
|
||||
const startTime = now()
|
||||
@@ -53,13 +24,3 @@ export function timeoutPromise (timeout) {
|
||||
setTimeout(resolve, timeout)
|
||||
})
|
||||
}
|
||||
|
||||
function waitsForPromise (fn) {
|
||||
const promise = fn()
|
||||
global.waitsFor('spec promise to resolve', function (done) {
|
||||
promise.then(done, function (error) {
|
||||
jasmine.getEnv().currentSpec.fail(error)
|
||||
done()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ module.exports = {
|
||||
},
|
||||
|
||||
finishDownloadingUpdate (releaseVersion) {
|
||||
atom.autoUpdater.emitter.emit('did-complete-downloading-update', {releaseVersion})
|
||||
atom.autoUpdater.emitter.emit('did-complete-downloading-update', {
|
||||
releaseVersion
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,24 @@ describe('UpdateManager', () => {
|
||||
|
||||
describe('::getReleaseNotesURLForVersion', () => {
|
||||
it('returns atom.io releases when dev version', () => {
|
||||
expect(updateManager.getReleaseNotesURLForVersion('1.7.0-dev-e44b57d')).toContain('atom.io/releases')
|
||||
expect(
|
||||
updateManager.getReleaseNotesURLForVersion('1.7.0-dev-e44b57d')
|
||||
).toContain('atom.io/releases')
|
||||
})
|
||||
|
||||
it('returns the page for the release when not a dev version', () => {
|
||||
expect(updateManager.getReleaseNotesURLForVersion('1.7.0')).toContain('atom/atom/releases/tag/v1.7.0')
|
||||
expect(updateManager.getReleaseNotesURLForVersion('v1.7.0')).toContain('atom/atom/releases/tag/v1.7.0')
|
||||
expect(updateManager.getReleaseNotesURLForVersion('1.7.0-beta10')).toContain('atom/atom/releases/tag/v1.7.0-beta10')
|
||||
expect(updateManager.getReleaseNotesURLForVersion('1.7.0-nightly10')).toContain('atom/atom-nightly-releases/releases/tag/v1.7.0-nightly10')
|
||||
expect(updateManager.getReleaseNotesURLForVersion('1.7.0')).toContain(
|
||||
'atom/atom/releases/tag/v1.7.0'
|
||||
)
|
||||
expect(updateManager.getReleaseNotesURLForVersion('v1.7.0')).toContain(
|
||||
'atom/atom/releases/tag/v1.7.0'
|
||||
)
|
||||
expect(
|
||||
updateManager.getReleaseNotesURLForVersion('1.7.0-beta10')
|
||||
).toContain('atom/atom/releases/tag/v1.7.0-beta10')
|
||||
expect(
|
||||
updateManager.getReleaseNotesURLForVersion('1.7.0-nightly10')
|
||||
).toContain('atom/atom-nightly-releases/releases/tag/v1.7.0-nightly10')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const {shell} = require('electron')
|
||||
const {it, fit, ffit, fffit, beforeEach, afterEach} = require('./helpers/async-spec-helpers') // eslint-disable-line no-unused-vars
|
||||
const { shell } = require('electron')
|
||||
const main = require('../lib/main')
|
||||
const AboutView = require('../lib/components/about-view')
|
||||
const UpdateView = require('../lib/components/update-view')
|
||||
@@ -17,7 +16,7 @@ describe('UpdateView', () => {
|
||||
spyOn(window.localStorage, 'setItem').andCallFake((key, value) => {
|
||||
storage[key] = value
|
||||
})
|
||||
spyOn(window.localStorage, 'getItem').andCallFake((key) => {
|
||||
spyOn(window.localStorage, 'getItem').andCallFake(key => {
|
||||
return storage[key]
|
||||
})
|
||||
|
||||
@@ -45,13 +44,19 @@ describe('UpdateView', () => {
|
||||
})
|
||||
|
||||
it('hides the auto update UI and shows the update instructions link', async () => {
|
||||
expect(aboutElement.querySelector('.about-update-action-button')).not.toBeVisible()
|
||||
expect(aboutElement.querySelector('.about-auto-updates')).not.toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button')
|
||||
).not.toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-auto-updates')
|
||||
).not.toBeVisible()
|
||||
})
|
||||
|
||||
it('opens the update instructions page when the instructions link is clicked', async () => {
|
||||
spyOn(shell, 'openExternal')
|
||||
let link = aboutElement.querySelector('.app-unsupported .about-updates-instructions')
|
||||
let link = aboutElement.querySelector(
|
||||
'.app-unsupported .about-updates-instructions'
|
||||
)
|
||||
link.click()
|
||||
|
||||
let args = shell.openExternal.mostRecentCall.args
|
||||
@@ -72,66 +77,116 @@ describe('UpdateView', () => {
|
||||
})
|
||||
|
||||
it('shows the correct panels when the app checks for updates and there is no update available', async () => {
|
||||
expect(aboutElement.querySelector('.about-default-update-message')).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
).toBeVisible()
|
||||
|
||||
MockUpdater.checkForUpdate()
|
||||
await scheduler.getNextUpdatePromise()
|
||||
expect(aboutElement.querySelector('.app-up-to-date')).not.toBeVisible()
|
||||
expect(aboutElement.querySelector('.app-checking-for-updates')).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.app-checking-for-updates')
|
||||
).toBeVisible()
|
||||
|
||||
MockUpdater.updateNotAvailable()
|
||||
await scheduler.getNextUpdatePromise()
|
||||
expect(aboutElement.querySelector('.app-up-to-date')).toBeVisible()
|
||||
expect(aboutElement.querySelector('.app-checking-for-updates')).not.toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.app-checking-for-updates')
|
||||
).not.toBeVisible()
|
||||
})
|
||||
|
||||
it('shows the correct panels when the app checks for updates and encounters an error', async () => {
|
||||
expect(aboutElement.querySelector('.about-default-update-message')).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
).toBeVisible()
|
||||
|
||||
MockUpdater.checkForUpdate()
|
||||
await scheduler.getNextUpdatePromise()
|
||||
expect(aboutElement.querySelector('.app-up-to-date')).not.toBeVisible()
|
||||
expect(aboutElement.querySelector('.app-checking-for-updates')).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.app-checking-for-updates')
|
||||
).toBeVisible()
|
||||
|
||||
spyOn(atom.autoUpdater, 'getErrorMessage').andReturn('an error message')
|
||||
MockUpdater.updateError()
|
||||
await scheduler.getNextUpdatePromise()
|
||||
expect(aboutElement.querySelector('.app-update-error')).toBeVisible()
|
||||
expect(aboutElement.querySelector('.app-error-message').textContent).toBe('an error message')
|
||||
expect(aboutElement.querySelector('.app-checking-for-updates')).not.toBeVisible()
|
||||
expect(aboutElement.querySelector('.about-update-action-button').disabled).toBe(false)
|
||||
expect(aboutElement.querySelector('.about-update-action-button').textContent).toBe('Check now')
|
||||
expect(
|
||||
aboutElement.querySelector('.app-error-message').textContent
|
||||
).toBe('an error message')
|
||||
expect(
|
||||
aboutElement.querySelector('.app-checking-for-updates')
|
||||
).not.toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').disabled
|
||||
).toBe(false)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').textContent
|
||||
).toBe('Check now')
|
||||
})
|
||||
|
||||
it('shows the correct panels and button states when the app checks for updates and an update is downloaded', async () => {
|
||||
expect(aboutElement.querySelector('.about-default-update-message')).toBeVisible()
|
||||
expect(aboutElement.querySelector('.about-update-action-button').disabled).toBe(false)
|
||||
expect(aboutElement.querySelector('.about-update-action-button').textContent).toBe('Check now')
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').disabled
|
||||
).toBe(false)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').textContent
|
||||
).toBe('Check now')
|
||||
|
||||
MockUpdater.checkForUpdate()
|
||||
await scheduler.getNextUpdatePromise()
|
||||
|
||||
expect(aboutElement.querySelector('.app-up-to-date')).not.toBeVisible()
|
||||
expect(aboutElement.querySelector('.app-checking-for-updates')).toBeVisible()
|
||||
expect(aboutElement.querySelector('.about-update-action-button').disabled).toBe(true)
|
||||
expect(aboutElement.querySelector('.about-update-action-button').textContent).toBe('Check now')
|
||||
expect(
|
||||
aboutElement.querySelector('.app-checking-for-updates')
|
||||
).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').disabled
|
||||
).toBe(true)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').textContent
|
||||
).toBe('Check now')
|
||||
|
||||
MockUpdater.downloadUpdate()
|
||||
await scheduler.getNextUpdatePromise()
|
||||
expect(aboutElement.querySelector('.app-checking-for-updates')).not.toBeVisible()
|
||||
expect(aboutElement.querySelector('.app-downloading-update')).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.app-checking-for-updates')
|
||||
).not.toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.app-downloading-update')
|
||||
).toBeVisible()
|
||||
// TODO: at some point it would be nice to be able to cancel an update download, and then this would be a cancel button
|
||||
expect(aboutElement.querySelector('.about-update-action-button').disabled).toBe(true)
|
||||
expect(aboutElement.querySelector('.about-update-action-button').textContent).toBe('Check now')
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').disabled
|
||||
).toBe(true)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').textContent
|
||||
).toBe('Check now')
|
||||
|
||||
MockUpdater.finishDownloadingUpdate('42.0.0')
|
||||
await scheduler.getNextUpdatePromise()
|
||||
expect(aboutElement.querySelector('.app-downloading-update')).not.toBeVisible()
|
||||
expect(aboutElement.querySelector('.app-update-available-to-install')).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.app-downloading-update')
|
||||
).not.toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.app-update-available-to-install')
|
||||
).toBeVisible()
|
||||
|
||||
expect(aboutElement.querySelector('.app-update-available-to-install .about-updates-version').textContent).toBe('42.0.0')
|
||||
expect(aboutElement.querySelector('.about-update-action-button').disabled).toBe(false)
|
||||
expect(aboutElement.querySelector('.about-update-action-button').textContent).toBe('Restart and install')
|
||||
expect(
|
||||
aboutElement.querySelector(
|
||||
'.app-update-available-to-install .about-updates-version'
|
||||
).textContent
|
||||
).toBe('42.0.0')
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').disabled
|
||||
).toBe(false)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').textContent
|
||||
).toBe('Restart and install')
|
||||
})
|
||||
|
||||
it('opens the release notes for the downloaded release when the release notes link are clicked', async () => {
|
||||
@@ -139,7 +194,9 @@ describe('UpdateView', () => {
|
||||
await scheduler.getNextUpdatePromise()
|
||||
|
||||
spyOn(shell, 'openExternal')
|
||||
let link = aboutElement.querySelector('.app-update-available-to-install .about-updates-release-notes')
|
||||
let link = aboutElement.querySelector(
|
||||
'.app-update-available-to-install .about-updates-release-notes'
|
||||
)
|
||||
link.click()
|
||||
|
||||
let args = shell.openExternal.mostRecentCall.args
|
||||
@@ -168,10 +225,18 @@ describe('UpdateView', () => {
|
||||
updateManager.resetState()
|
||||
|
||||
await scheduler.getNextUpdatePromise()
|
||||
expect(aboutElement.querySelector('.app-checking-for-updates')).not.toBeVisible()
|
||||
expect(aboutElement.querySelector('.app-downloading-update')).toBeVisible()
|
||||
expect(aboutElement.querySelector('.about-update-action-button').disabled).toBe(true)
|
||||
expect(aboutElement.querySelector('.about-update-action-button').textContent).toBe('Check now')
|
||||
expect(
|
||||
aboutElement.querySelector('.app-checking-for-updates')
|
||||
).not.toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.app-downloading-update')
|
||||
).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').disabled
|
||||
).toBe(true)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').textContent
|
||||
).toBe('Check now')
|
||||
})
|
||||
|
||||
describe('when core.automaticallyUpdate is toggled', () => {
|
||||
@@ -181,36 +246,66 @@ describe('UpdateView', () => {
|
||||
})
|
||||
|
||||
it('shows the auto update UI', async () => {
|
||||
expect(aboutElement.querySelector('.about-auto-updates input').checked).toBe(true)
|
||||
expect(aboutElement.querySelector('.about-default-update-message')).toBeVisible()
|
||||
expect(aboutElement.querySelector('.about-default-update-message').textContent).toBe('Atom will check for updates automatically')
|
||||
expect(
|
||||
aboutElement.querySelector('.about-auto-updates input').checked
|
||||
).toBe(true)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
.textContent
|
||||
).toBe('Atom will check for updates automatically')
|
||||
|
||||
atom.config.set('core.automaticallyUpdate', false)
|
||||
await scheduler.getNextUpdatePromise()
|
||||
|
||||
expect(aboutElement.querySelector('.about-auto-updates input').checked).toBe(false)
|
||||
expect(aboutElement.querySelector('.about-default-update-message')).toBeVisible()
|
||||
expect(aboutElement.querySelector('.about-default-update-message').textContent).toBe('Automatic updates are disabled please check manually')
|
||||
expect(
|
||||
aboutElement.querySelector('.about-auto-updates input').checked
|
||||
).toBe(false)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
.textContent
|
||||
).toBe('Automatic updates are disabled please check manually')
|
||||
})
|
||||
|
||||
it('updates config and the UI when the checkbox is used to toggle', async () => {
|
||||
expect(aboutElement.querySelector('.about-auto-updates input').checked).toBe(true)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-auto-updates input').checked
|
||||
).toBe(true)
|
||||
|
||||
aboutElement.querySelector('.about-auto-updates input').click()
|
||||
await scheduler.getNextUpdatePromise()
|
||||
|
||||
expect(atom.config.get('core.automaticallyUpdate')).toBe(false)
|
||||
expect(aboutElement.querySelector('.about-auto-updates input').checked).toBe(false)
|
||||
expect(aboutElement.querySelector('.about-default-update-message')).toBeVisible()
|
||||
expect(aboutElement.querySelector('.about-default-update-message').textContent).toBe('Automatic updates are disabled please check manually')
|
||||
expect(
|
||||
aboutElement.querySelector('.about-auto-updates input').checked
|
||||
).toBe(false)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
.textContent
|
||||
).toBe('Automatic updates are disabled please check manually')
|
||||
|
||||
aboutElement.querySelector('.about-auto-updates input').click()
|
||||
await scheduler.getNextUpdatePromise()
|
||||
|
||||
expect(atom.config.get('core.automaticallyUpdate')).toBe(true)
|
||||
expect(aboutElement.querySelector('.about-auto-updates input').checked).toBe(true)
|
||||
expect(aboutElement.querySelector('.about-default-update-message')).toBeVisible()
|
||||
expect(aboutElement.querySelector('.about-default-update-message').textContent).toBe('Atom will check for updates automatically')
|
||||
expect(
|
||||
aboutElement.querySelector('.about-auto-updates input').checked
|
||||
).toBe(true)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector('.about-default-update-message')
|
||||
.textContent
|
||||
).toBe('Atom will check for updates automatically')
|
||||
})
|
||||
|
||||
describe('checking for updates', function () {
|
||||
@@ -271,10 +366,20 @@ describe('UpdateView', () => {
|
||||
updateManager = main.model.state.updateManager
|
||||
scheduler = AboutView.getScheduler()
|
||||
|
||||
expect(aboutElement.querySelector('.app-update-available-to-install')).toBeVisible()
|
||||
expect(aboutElement.querySelector('.app-update-available-to-install .about-updates-version').textContent).toBe('42.0.0')
|
||||
expect(aboutElement.querySelector('.about-update-action-button').disabled).toBe(false)
|
||||
expect(aboutElement.querySelector('.about-update-action-button').textContent).toBe('Restart and install')
|
||||
expect(
|
||||
aboutElement.querySelector('.app-update-available-to-install')
|
||||
).toBeVisible()
|
||||
expect(
|
||||
aboutElement.querySelector(
|
||||
'.app-update-available-to-install .about-updates-version'
|
||||
).textContent
|
||||
).toBe('42.0.0')
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').disabled
|
||||
).toBe(false)
|
||||
expect(
|
||||
aboutElement.querySelector('.about-update-action-button').textContent
|
||||
).toBe('Restart and install')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -13,7 +13,9 @@ module.exports = {
|
||||
const names = atom.packages.getAvailablePackageNames()
|
||||
for (let name of names) {
|
||||
if (atom.packages.isBundledPackage(name)) {
|
||||
const isDuplicatedPackage = await this.isInstalledAsCommunityPackage(name)
|
||||
const isDuplicatedPackage = await this.isInstalledAsCommunityPackage(
|
||||
name
|
||||
)
|
||||
if (isDuplicatedPackage) {
|
||||
duplicatePackages.push(name)
|
||||
}
|
||||
|
||||
@@ -17,20 +17,49 @@ describe('dalek', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
availablePackages = {
|
||||
'an-unduplicated-installed-package': path.join('Users', 'username', '.atom', 'packages', 'an-unduplicated-installed-package'),
|
||||
'duplicated-package': path.join('Users', 'username', '.atom', 'packages', 'duplicated-package'),
|
||||
'unduplicated-package': path.join(`${atom.getLoadSettings().resourcePath}`, 'node_modules', 'unduplicated-package')
|
||||
'an-unduplicated-installed-package': path.join(
|
||||
'Users',
|
||||
'username',
|
||||
'.atom',
|
||||
'packages',
|
||||
'an-unduplicated-installed-package'
|
||||
),
|
||||
'duplicated-package': path.join(
|
||||
'Users',
|
||||
'username',
|
||||
'.atom',
|
||||
'packages',
|
||||
'duplicated-package'
|
||||
),
|
||||
'unduplicated-package': path.join(
|
||||
`${atom.getLoadSettings().resourcePath}`,
|
||||
'node_modules',
|
||||
'unduplicated-package'
|
||||
)
|
||||
}
|
||||
|
||||
atom.devMode = false
|
||||
bundledPackages = ['duplicated-package', 'unduplicated-package']
|
||||
packageDirPaths = [path.join('Users', 'username', '.atom', 'packages')]
|
||||
sandbox = sinon.sandbox.create()
|
||||
sandbox.stub(dalek, 'realpath').callsFake((filePath) => Promise.resolve(realPaths[filePath] || filePath))
|
||||
sandbox.stub(atom.packages, 'isBundledPackage').callsFake((packageName) => { return bundledPackages.includes(packageName) })
|
||||
sandbox.stub(atom.packages, 'getAvailablePackageNames').callsFake(() => Object.keys(availablePackages))
|
||||
sandbox.stub(atom.packages, 'getPackageDirPaths').callsFake(() => { return packageDirPaths })
|
||||
sandbox.stub(fs, 'existsSync').callsFake((candidate) => { return Object.values(availablePackages).includes(candidate) && !candidate.includes(atom.getLoadSettings().resourcePath) })
|
||||
sandbox
|
||||
.stub(dalek, 'realpath')
|
||||
.callsFake(filePath => Promise.resolve(realPaths[filePath] || filePath))
|
||||
sandbox.stub(atom.packages, 'isBundledPackage').callsFake(packageName => {
|
||||
return bundledPackages.includes(packageName)
|
||||
})
|
||||
sandbox
|
||||
.stub(atom.packages, 'getAvailablePackageNames')
|
||||
.callsFake(() => Object.keys(availablePackages))
|
||||
sandbox.stub(atom.packages, 'getPackageDirPaths').callsFake(() => {
|
||||
return packageDirPaths
|
||||
})
|
||||
sandbox.stub(fs, 'existsSync').callsFake(candidate => {
|
||||
return (
|
||||
Object.values(availablePackages).includes(candidate) &&
|
||||
!candidate.includes(atom.getLoadSettings().resourcePath)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
@@ -54,7 +83,13 @@ describe('dalek', function () {
|
||||
describe('when a package is symlinked into the package directory', async function () {
|
||||
beforeEach(function () {
|
||||
const realPath = path.join('Users', 'username', 'duplicated-package')
|
||||
const packagePath = path.join('Users', 'username', '.atom', 'packages', 'duplicated-package')
|
||||
const packagePath = path.join(
|
||||
'Users',
|
||||
'username',
|
||||
'.atom',
|
||||
'packages',
|
||||
'duplicated-package'
|
||||
)
|
||||
realPaths[packagePath] = realPath
|
||||
})
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
const createRunner = require('atom-mocha-test-runner').createRunner
|
||||
module.exports = createRunner({testSuffixes: ['test.js']})
|
||||
module.exports = createRunner({ testSuffixes: ['test.js'] })
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/** @jsx etch.dom */
|
||||
|
||||
import _ from 'underscore-plus'
|
||||
import {CompositeDisposable} from 'atom'
|
||||
import { CompositeDisposable } from 'atom'
|
||||
import etch from 'etch'
|
||||
import fs from 'fs-plus'
|
||||
import Grim from 'grim'
|
||||
@@ -11,23 +11,45 @@ import path from 'path'
|
||||
import shell from 'shell'
|
||||
|
||||
export default class DeprecationCopView {
|
||||
constructor ({uri}) {
|
||||
constructor ({ uri }) {
|
||||
this.uri = uri
|
||||
this.subscriptions = new CompositeDisposable
|
||||
this.subscriptions.add(Grim.on('updated', () => { etch.update(this) }))
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
this.subscriptions.add(
|
||||
Grim.on('updated', () => {
|
||||
etch.update(this)
|
||||
})
|
||||
)
|
||||
// TODO: Remove conditional when the new StyleManager deprecation APIs reach stable.
|
||||
if (atom.styles.onDidUpdateDeprecations) {
|
||||
this.subscriptions.add(atom.styles.onDidUpdateDeprecations(() => { etch.update(this) }))
|
||||
this.subscriptions.add(
|
||||
atom.styles.onDidUpdateDeprecations(() => {
|
||||
etch.update(this)
|
||||
})
|
||||
)
|
||||
}
|
||||
etch.initialize(this)
|
||||
this.subscriptions.add(atom.commands.add(this.element, {
|
||||
'core:move-up': () => { this.scrollUp() },
|
||||
'core:move-down': () => { this.scrollDown() },
|
||||
'core:page-up': () => { this.pageUp() },
|
||||
'core:page-down': () => { this.pageDown() },
|
||||
'core:move-to-top': () => { this.scrollToTop() },
|
||||
'core:move-to-bottom': () => { this.scrollToBottom() }
|
||||
}))
|
||||
this.subscriptions.add(
|
||||
atom.commands.add(this.element, {
|
||||
'core:move-up': () => {
|
||||
this.scrollUp()
|
||||
},
|
||||
'core:move-down': () => {
|
||||
this.scrollDown()
|
||||
},
|
||||
'core:page-up': () => {
|
||||
this.pageUp()
|
||||
},
|
||||
'core:page-down': () => {
|
||||
this.pageDown()
|
||||
},
|
||||
'core:move-to-top': () => {
|
||||
this.scrollToTop()
|
||||
},
|
||||
'core:move-to-bottom': () => {
|
||||
this.scrollToBottom()
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
serialize () {
|
||||
@@ -49,25 +71,35 @@ export default class DeprecationCopView {
|
||||
|
||||
render () {
|
||||
return (
|
||||
<div className='deprecation-cop pane-item native-key-bindings' tabIndex='-1'>
|
||||
<div
|
||||
className='deprecation-cop pane-item native-key-bindings'
|
||||
tabIndex='-1'
|
||||
>
|
||||
<div className='panel'>
|
||||
<div className='padded deprecation-overview'>
|
||||
<div className='pull-right btn-group'>
|
||||
<button
|
||||
className='btn btn-primary check-for-update'
|
||||
onclick={(event) => {
|
||||
onclick={event => {
|
||||
event.preventDefault()
|
||||
this.checkForUpdates()
|
||||
}}>Check for Updates</button>
|
||||
}}
|
||||
>
|
||||
Check for Updates
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='panel-heading'><span>Deprecated calls</span></div>
|
||||
<div className='panel-heading'>
|
||||
<span>Deprecated calls</span>
|
||||
</div>
|
||||
<ul className='list-tree has-collapsable-children'>
|
||||
{this.renderDeprecatedCalls()}
|
||||
</ul>
|
||||
|
||||
<div className='panel-heading'><span>Deprecated selectors</span></div>
|
||||
<div className='panel-heading'>
|
||||
<span>Deprecated selectors</span>
|
||||
</div>
|
||||
<ul className='selectors list-tree has-collapsable-children'>
|
||||
{this.renderDeprecatedSelectors()}
|
||||
</ul>
|
||||
@@ -82,37 +114,57 @@ export default class DeprecationCopView {
|
||||
if (packageNames.length === 0) {
|
||||
return <li className='list-item'>No deprecated calls</li>
|
||||
} else {
|
||||
return packageNames.sort().map((packageName) => (
|
||||
return packageNames.sort().map(packageName => (
|
||||
<li className='deprecation list-nested-item collapsed'>
|
||||
<div className='deprecation-info list-item' onclick={(event) => event.target.parentElement.classList.toggle('collapsed')}>
|
||||
<div
|
||||
className='deprecation-info list-item'
|
||||
onclick={event =>
|
||||
event.target.parentElement.classList.toggle('collapsed')
|
||||
}
|
||||
>
|
||||
<span className='text-highlight'>{packageName || 'atom core'}</span>
|
||||
<span>{` (${_.pluralize(deprecationsByPackageName[packageName].length, 'deprecation')})`}</span>
|
||||
<span>{` (${_.pluralize(
|
||||
deprecationsByPackageName[packageName].length,
|
||||
'deprecation'
|
||||
)})`}</span>
|
||||
</div>
|
||||
|
||||
<ul className='list'>
|
||||
{this.renderPackageActionsIfNeeded(packageName)}
|
||||
{deprecationsByPackageName[packageName].map(({deprecation, stack}) => (
|
||||
<li className='list-item deprecation-detail'>
|
||||
<span className='text-warning icon icon-alert' />
|
||||
<div className='list-item deprecation-message' innerHTML={marked(deprecation.getMessage())} />
|
||||
{this.renderIssueURLIfNeeded(packageName, deprecation, this.buildIssueURL(packageName, deprecation, stack))}
|
||||
<div className='stack-trace'>
|
||||
{stack.map(({functionName, location}) => (
|
||||
<div className='stack-line'>
|
||||
<span>{functionName}</span>
|
||||
<span> - </span>
|
||||
<a
|
||||
className='stack-line-location'
|
||||
href={location}
|
||||
onclick={(event) => {
|
||||
event.preventDefault()
|
||||
this.openLocation(location)
|
||||
}}>{location}</a>
|
||||
{deprecationsByPackageName[packageName].map(
|
||||
({ deprecation, stack }) => (
|
||||
<li className='list-item deprecation-detail'>
|
||||
<span className='text-warning icon icon-alert' />
|
||||
<div
|
||||
className='list-item deprecation-message'
|
||||
innerHTML={marked(deprecation.getMessage())}
|
||||
/>
|
||||
{this.renderIssueURLIfNeeded(
|
||||
packageName,
|
||||
deprecation,
|
||||
this.buildIssueURL(packageName, deprecation, stack)
|
||||
)}
|
||||
<div className='stack-trace'>
|
||||
{stack.map(({ functionName, location }) => (
|
||||
<div className='stack-line'>
|
||||
<span>{functionName}</span>
|
||||
<span> - </span>
|
||||
<a
|
||||
className='stack-line-location'
|
||||
href={location}
|
||||
onclick={event => {
|
||||
event.preventDefault()
|
||||
this.openLocation(location)
|
||||
}}
|
||||
>
|
||||
{location}
|
||||
</a>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</li>
|
||||
)
|
||||
)}
|
||||
</ul>
|
||||
</li>
|
||||
))
|
||||
@@ -123,41 +175,61 @@ export default class DeprecationCopView {
|
||||
const deprecationsByPackageName = this.getDeprecatedSelectorsByPackageName()
|
||||
const packageNames = Object.keys(deprecationsByPackageName)
|
||||
if (packageNames.length === 0) {
|
||||
return (
|
||||
<li className='list-item'>No deprecated selectors</li>
|
||||
)
|
||||
return <li className='list-item'>No deprecated selectors</li>
|
||||
} else {
|
||||
return packageNames.map((packageName) => (
|
||||
return packageNames.map(packageName => (
|
||||
<li className='deprecation list-nested-item collapsed'>
|
||||
<div className='deprecation-info list-item' onclick={(event) => event.target.parentElement.classList.toggle('collapsed')}>
|
||||
<div
|
||||
className='deprecation-info list-item'
|
||||
onclick={event =>
|
||||
event.target.parentElement.classList.toggle('collapsed')
|
||||
}
|
||||
>
|
||||
<span className='text-highlight'>{packageName}</span>
|
||||
</div>
|
||||
|
||||
<ul className='list'>
|
||||
{this.renderPackageActionsIfNeeded(packageName)}
|
||||
{deprecationsByPackageName[packageName].map(({packagePath, sourcePath, deprecation}) => {
|
||||
const relativeSourcePath = path.relative(packagePath, sourcePath)
|
||||
const issueTitle = `Deprecated selector in \`${relativeSourcePath}\``
|
||||
const issueBody = `In \`${relativeSourcePath}\`: \n\n${deprecation.message}`
|
||||
return (
|
||||
<li className='list-item source-file'>
|
||||
<a
|
||||
className='source-url'
|
||||
href={sourcePath}
|
||||
onclick={(event) => {
|
||||
event.preventDefault()
|
||||
this.openLocation(sourcePath)
|
||||
}}>{relativeSourcePath}</a>
|
||||
<ul className='list'>
|
||||
<li className='list-item deprecation-detail'>
|
||||
<span className='text-warning icon icon-alert' />
|
||||
<div className='list-item deprecation-message' innerHTML={marked(deprecation.message)} />
|
||||
{this.renderSelectorIssueURLIfNeeded(packageName, issueTitle, issueBody)}
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
{deprecationsByPackageName[packageName].map(
|
||||
({ packagePath, sourcePath, deprecation }) => {
|
||||
const relativeSourcePath = path.relative(
|
||||
packagePath,
|
||||
sourcePath
|
||||
)
|
||||
const issueTitle = `Deprecated selector in \`${relativeSourcePath}\``
|
||||
const issueBody = `In \`${relativeSourcePath}\`: \n\n${
|
||||
deprecation.message
|
||||
}`
|
||||
return (
|
||||
<li className='list-item source-file'>
|
||||
<a
|
||||
className='source-url'
|
||||
href={sourcePath}
|
||||
onclick={event => {
|
||||
event.preventDefault()
|
||||
this.openLocation(sourcePath)
|
||||
}}
|
||||
>
|
||||
{relativeSourcePath}
|
||||
</a>
|
||||
<ul className='list'>
|
||||
<li className='list-item deprecation-detail'>
|
||||
<span className='text-warning icon icon-alert' />
|
||||
<div
|
||||
className='list-item deprecation-message'
|
||||
innerHTML={marked(deprecation.message)}
|
||||
/>
|
||||
{this.renderSelectorIssueURLIfNeeded(
|
||||
packageName,
|
||||
issueTitle,
|
||||
issueBody
|
||||
)}
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
)}
|
||||
</ul>
|
||||
</li>
|
||||
))
|
||||
@@ -171,17 +243,23 @@ export default class DeprecationCopView {
|
||||
<div className='btn-group'>
|
||||
<button
|
||||
className='btn check-for-update'
|
||||
onclick={(event) => {
|
||||
onclick={event => {
|
||||
event.preventDefault()
|
||||
this.checkForUpdates()
|
||||
}}>Check for Update</button>
|
||||
}}
|
||||
>
|
||||
Check for Update
|
||||
</button>
|
||||
<button
|
||||
className='btn disable-package'
|
||||
data-package-name={packageName}
|
||||
onclick={(event) => {
|
||||
onclick={event => {
|
||||
event.preventDefault()
|
||||
this.disablePackage(packageName)
|
||||
}}>Disable Package</button>
|
||||
}}
|
||||
>
|
||||
Disable Package
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -191,13 +269,18 @@ export default class DeprecationCopView {
|
||||
}
|
||||
|
||||
encodeURI (str) {
|
||||
return encodeURI(str).replace(/#/g, '%23').replace(/;/g, '%3B').replace(/%20/g, '+')
|
||||
return encodeURI(str)
|
||||
.replace(/#/g, '%23')
|
||||
.replace(/;/g, '%3B')
|
||||
.replace(/%20/g, '+')
|
||||
}
|
||||
|
||||
renderSelectorIssueURLIfNeeded (packageName, issueTitle, issueBody) {
|
||||
const repoURL = this.getRepoURL(packageName)
|
||||
if (repoURL) {
|
||||
const issueURL = `${repoURL}/issues/new?title=${this.encodeURI(issueTitle)}&body=${this.encodeURI(issueBody)}`
|
||||
const issueURL = `${repoURL}/issues/new?title=${this.encodeURI(
|
||||
issueTitle
|
||||
)}&body=${this.encodeURI(issueBody)}`
|
||||
return (
|
||||
<div className='btn-toolbar'>
|
||||
<button
|
||||
@@ -205,10 +288,13 @@ export default class DeprecationCopView {
|
||||
data-issue-title={issueTitle}
|
||||
data-repo-url={repoURL}
|
||||
data-issue-url={issueURL}
|
||||
onclick={(event) => {
|
||||
onclick={event => {
|
||||
event.preventDefault()
|
||||
this.openIssueURL(repoURL, issueURL, issueTitle)
|
||||
}}>Report Issue</button>
|
||||
}}
|
||||
>
|
||||
Report Issue
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
@@ -227,10 +313,13 @@ export default class DeprecationCopView {
|
||||
data-issue-title={issueTitle}
|
||||
data-repo-url={repoURL}
|
||||
data-issue-url={issueURL}
|
||||
onclick={(event) => {
|
||||
onclick={event => {
|
||||
event.preventDefault()
|
||||
this.openIssueURL(repoURL, issueURL, issueTitle)
|
||||
}}>Report Issue</button>
|
||||
}}
|
||||
>
|
||||
Report Issue
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
@@ -242,9 +331,13 @@ export default class DeprecationCopView {
|
||||
const repoURL = this.getRepoURL(packageName)
|
||||
if (repoURL) {
|
||||
const title = `${deprecation.getOriginName()} is deprecated.`
|
||||
const stacktrace = stack.map(({functionName, location}) => `${functionName} (${location})`).join("\n")
|
||||
const stacktrace = stack
|
||||
.map(({ functionName, location }) => `${functionName} (${location})`)
|
||||
.join('\n')
|
||||
const body = `${deprecation.getMessage()}\n\`\`\`\n${stacktrace}\n\`\`\``
|
||||
return `${repoURL}/issues/new?title=${encodeURI(title)}&body=${encodeURI(body)}`
|
||||
return `${repoURL}/issues/new?title=${encodeURI(title)}&body=${encodeURI(
|
||||
body
|
||||
)}`
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
@@ -266,13 +359,16 @@ export default class DeprecationCopView {
|
||||
const url = 'https://api.github.com/search/issues'
|
||||
const repo = repoURL.replace(/http(s)?:\/\/(\d+\.)?github.com\//gi, '')
|
||||
const query = `${issueTitle} repo:${repo}`
|
||||
const response = await window.fetch(`${url}?q=${encodeURI(query)}&sort=created`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/vnd.github.v3+json',
|
||||
'Content-Type': 'application/json'
|
||||
const response = await window.fetch(
|
||||
`${url}?q=${encodeURI(query)}&sort=created`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/vnd.github.v3+json',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
@@ -284,21 +380,25 @@ export default class DeprecationCopView {
|
||||
}
|
||||
}
|
||||
|
||||
return (issues.open || issues.closed)
|
||||
return issues.open || issues.closed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async shortenURL (url) {
|
||||
let encodedUrl = encodeURIComponent(url).substr(0, 5000) // is.gd has 5000 char limit
|
||||
let incompletePercentEncoding = encodedUrl.indexOf('%', encodedUrl.length - 2)
|
||||
if (incompletePercentEncoding >= 0) { // Handle an incomplete % encoding cut-off
|
||||
let incompletePercentEncoding = encodedUrl.indexOf(
|
||||
'%',
|
||||
encodedUrl.length - 2
|
||||
)
|
||||
if (incompletePercentEncoding >= 0) {
|
||||
// Handle an incomplete % encoding cut-off
|
||||
encodedUrl = encodedUrl.substr(0, incompletePercentEncoding)
|
||||
}
|
||||
|
||||
let result = await fetch('https://is.gd/create.php?format=simple', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: `url=${encodedUrl}`
|
||||
})
|
||||
|
||||
@@ -307,8 +407,14 @@ export default class DeprecationCopView {
|
||||
|
||||
getRepoURL (packageName) {
|
||||
const loadedPackage = atom.packages.getLoadedPackage(packageName)
|
||||
if (loadedPackage && loadedPackage.metadata && loadedPackage.metadata.repository) {
|
||||
const url = loadedPackage.metadata.repository.url || loadedPackage.metadata.repository
|
||||
if (
|
||||
loadedPackage &&
|
||||
loadedPackage.metadata &&
|
||||
loadedPackage.metadata.repository
|
||||
) {
|
||||
const url =
|
||||
loadedPackage.metadata.repository.url ||
|
||||
loadedPackage.metadata.repository
|
||||
return url.replace(/\.git$/, '')
|
||||
} else {
|
||||
return null
|
||||
@@ -330,8 +436,9 @@ export default class DeprecationCopView {
|
||||
packageName = (this.getPackageName(stack) || '').toLowerCase()
|
||||
}
|
||||
|
||||
deprecatedCallsByPackageName[packageName] = deprecatedCallsByPackageName[packageName] || []
|
||||
deprecatedCallsByPackageName[packageName].push({deprecation, stack})
|
||||
deprecatedCallsByPackageName[packageName] =
|
||||
deprecatedCallsByPackageName[packageName] || []
|
||||
deprecatedCallsByPackageName[packageName].push({ deprecation, stack })
|
||||
}
|
||||
}
|
||||
return deprecatedCallsByPackageName
|
||||
@@ -352,11 +459,18 @@ export default class DeprecationCopView {
|
||||
packagePath = ''
|
||||
} else {
|
||||
packageName = components[packagesComponentIndex + 1]
|
||||
packagePath = components.slice(0, packagesComponentIndex + 1).join(path.sep)
|
||||
packagePath = components
|
||||
.slice(0, packagesComponentIndex + 1)
|
||||
.join(path.sep)
|
||||
}
|
||||
|
||||
deprecatedSelectorsByPackageName[packageName] = deprecatedSelectorsByPackageName[packageName] || []
|
||||
deprecatedSelectorsByPackageName[packageName].push({packagePath, sourcePath, deprecation})
|
||||
deprecatedSelectorsByPackageName[packageName] =
|
||||
deprecatedSelectorsByPackageName[packageName] || []
|
||||
deprecatedSelectorsByPackageName[packageName].push({
|
||||
packagePath,
|
||||
sourcePath,
|
||||
deprecation
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,13 +480,16 @@ export default class DeprecationCopView {
|
||||
getPackageName (stack) {
|
||||
const packagePaths = this.getPackagePathsByPackageName()
|
||||
for (const [packageName, packagePath] of packagePaths) {
|
||||
if (packagePath.includes('.atom/dev/packages') || packagePath.includes('.atom/packages')) {
|
||||
if (
|
||||
packagePath.includes('.atom/dev/packages') ||
|
||||
packagePath.includes('.atom/packages')
|
||||
) {
|
||||
packagePaths.set(packageName, fs.absolute(packagePath))
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 1; i < stack.length; i++) {
|
||||
const {fileName} = stack[i]
|
||||
const { fileName } = stack[i]
|
||||
|
||||
// Empty when it was run from the dev console
|
||||
if (!fileName) {
|
||||
@@ -426,7 +543,7 @@ export default class DeprecationCopView {
|
||||
if (process.platform === 'win32') {
|
||||
pathToOpen = pathToOpen.replace(/^\//, '')
|
||||
}
|
||||
atom.open({pathsToOpen: [pathToOpen]})
|
||||
atom.open({ pathsToOpen: [pathToOpen] })
|
||||
}
|
||||
|
||||
getURI () {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const {Disposable, CompositeDisposable} = require('atom')
|
||||
const { Disposable, CompositeDisposable } = require('atom')
|
||||
const DeprecationCopView = require('./deprecation-cop-view')
|
||||
const DeprecationCopStatusBarView = require('./deprecation-cop-status-bar-view')
|
||||
const ViewURI = 'atom://deprecation-cop'
|
||||
@@ -6,14 +6,18 @@ const ViewURI = 'atom://deprecation-cop'
|
||||
class DeprecationCopPackage {
|
||||
activate () {
|
||||
this.disposables = new CompositeDisposable()
|
||||
this.disposables.add(atom.workspace.addOpener((uri) => {
|
||||
if (uri === ViewURI) {
|
||||
return this.deserializeDeprecationCopView({uri})
|
||||
}
|
||||
}))
|
||||
this.disposables.add(atom.commands.add('atom-workspace', 'deprecation-cop:view', () => {
|
||||
atom.workspace.open(ViewURI)
|
||||
}))
|
||||
this.disposables.add(
|
||||
atom.workspace.addOpener(uri => {
|
||||
if (uri === ViewURI) {
|
||||
return this.deserializeDeprecationCopView({ uri })
|
||||
}
|
||||
})
|
||||
)
|
||||
this.disposables.add(
|
||||
atom.commands.add('atom-workspace', 'deprecation-cop:view', () => {
|
||||
atom.workspace.open(ViewURI)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
deactivate () {
|
||||
@@ -30,9 +34,20 @@ class DeprecationCopPackage {
|
||||
|
||||
consumeStatusBar (statusBar) {
|
||||
const statusBarView = new DeprecationCopStatusBarView()
|
||||
const statusBarTile = statusBar.addRightTile({item: statusBarView, priority: 150})
|
||||
this.disposables.add(new Disposable(() => { statusBarView.destroy() }))
|
||||
this.disposables.add(new Disposable(() => { statusBarTile.destroy() }))
|
||||
const statusBarTile = statusBar.addRightTile({
|
||||
item: statusBarView,
|
||||
priority: 150
|
||||
})
|
||||
this.disposables.add(
|
||||
new Disposable(() => {
|
||||
statusBarView.destroy()
|
||||
})
|
||||
)
|
||||
this.disposables.add(
|
||||
new Disposable(() => {
|
||||
statusBarTile.destroy()
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,16 +2,19 @@ const fs = require('fs-plus')
|
||||
const path = require('path')
|
||||
const Watcher = require('./watcher')
|
||||
|
||||
module.exports =
|
||||
class BaseThemeWatcher extends Watcher {
|
||||
module.exports = class BaseThemeWatcher extends Watcher {
|
||||
constructor () {
|
||||
super()
|
||||
this.stylesheetsPath = path.dirname(atom.themes.resolveStylesheet('../static/atom.less'))
|
||||
this.stylesheetsPath = path.dirname(
|
||||
atom.themes.resolveStylesheet('../static/atom.less')
|
||||
)
|
||||
this.watch()
|
||||
}
|
||||
|
||||
watch () {
|
||||
const filePaths = fs.readdirSync(this.stylesheetsPath).filter(filePath => path.extname(filePath).includes('less'))
|
||||
const filePaths = fs
|
||||
.readdirSync(this.stylesheetsPath)
|
||||
.filter(filePath => path.extname(filePath).includes('less'))
|
||||
|
||||
for (const filePath of filePaths) {
|
||||
this.watchFile(path.join(this.stylesheetsPath, filePath))
|
||||
|
||||
@@ -5,7 +5,9 @@ module.exports = {
|
||||
if (atom.packages.hasActivatedInitialPackages()) {
|
||||
this.startWatching()
|
||||
} else {
|
||||
this.activatedDisposable = atom.packages.onDidActivateInitialPackages(() => this.startWatching())
|
||||
this.activatedDisposable = atom.packages.onDidActivateInitialPackages(
|
||||
() => this.startWatching()
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -17,8 +19,12 @@ module.exports = {
|
||||
|
||||
startWatching () {
|
||||
const UIWatcher = require('./ui-watcher')
|
||||
this.uiWatcher = new UIWatcher({themeManager: atom.themes})
|
||||
this.commandDisposable = atom.commands.add('atom-workspace', 'dev-live-reload:reload-all', () => this.uiWatcher.reloadAll())
|
||||
this.uiWatcher = new UIWatcher({ themeManager: atom.themes })
|
||||
this.commandDisposable = atom.commands.add(
|
||||
'atom-workspace',
|
||||
'dev-live-reload:reload-all',
|
||||
() => this.uiWatcher.reloadAll()
|
||||
)
|
||||
if (this.activatedDisposable) this.activatedDisposable.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@ const fs = require('fs-plus')
|
||||
|
||||
const Watcher = require('./watcher')
|
||||
|
||||
module.exports =
|
||||
class PackageWatcher extends Watcher {
|
||||
module.exports = class PackageWatcher extends Watcher {
|
||||
static supportsPackage (pack, type) {
|
||||
if (pack.getType() === type && pack.getStylesheetPaths().length) return true
|
||||
return false
|
||||
@@ -24,7 +23,9 @@ class PackageWatcher extends Watcher {
|
||||
|
||||
const stylesheetsPath = this.pack.getStylesheetsPath()
|
||||
|
||||
if (fs.isDirectorySync(stylesheetsPath)) this.watchDirectory(stylesheetsPath)
|
||||
if (fs.isDirectorySync(stylesheetsPath)) {
|
||||
this.watchDirectory(stylesheetsPath)
|
||||
}
|
||||
|
||||
const stylesheetPaths = new Set(this.pack.getStylesheetPaths())
|
||||
const onFile = stylesheetPath => stylesheetPaths.add(stylesheetPath)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
const {CompositeDisposable} = require('atom')
|
||||
const { CompositeDisposable } = require('atom')
|
||||
|
||||
const BaseThemeWatcher = require('./base-theme-watcher')
|
||||
const PackageWatcher = require('./package-watcher')
|
||||
|
||||
module.exports =
|
||||
class UIWatcher {
|
||||
module.exports = class UIWatcher {
|
||||
constructor () {
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
this.reloadAll = this.reloadAll.bind(this)
|
||||
@@ -16,39 +15,63 @@ class UIWatcher {
|
||||
watchPackages () {
|
||||
this.watchedThemes = new Map()
|
||||
this.watchedPackages = new Map()
|
||||
for (const theme of atom.themes.getActiveThemes()) { this.watchTheme(theme) }
|
||||
for (const pack of atom.packages.getActivePackages()) { this.watchPackage(pack) }
|
||||
for (const theme of atom.themes.getActiveThemes()) {
|
||||
this.watchTheme(theme)
|
||||
}
|
||||
for (const pack of atom.packages.getActivePackages()) {
|
||||
this.watchPackage(pack)
|
||||
}
|
||||
this.watchForPackageChanges()
|
||||
}
|
||||
|
||||
watchForPackageChanges () {
|
||||
this.subscriptions.add(atom.themes.onDidChangeActiveThemes(() => {
|
||||
// We need to destroy all theme watchers as all theme packages are destroyed
|
||||
// when a theme changes.
|
||||
for (const theme of this.watchedThemes.values()) { theme.destroy() }
|
||||
this.subscriptions.add(
|
||||
atom.themes.onDidChangeActiveThemes(() => {
|
||||
// We need to destroy all theme watchers as all theme packages are destroyed
|
||||
// when a theme changes.
|
||||
for (const theme of this.watchedThemes.values()) {
|
||||
theme.destroy()
|
||||
}
|
||||
|
||||
this.watchedThemes.clear()
|
||||
this.watchedThemes.clear()
|
||||
|
||||
// Rewatch everything!
|
||||
for (const theme of atom.themes.getActiveThemes()) { this.watchTheme(theme) }
|
||||
}))
|
||||
// Rewatch everything!
|
||||
for (const theme of atom.themes.getActiveThemes()) {
|
||||
this.watchTheme(theme)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
this.subscriptions.add(atom.packages.onDidActivatePackage(pack => this.watchPackage(pack)))
|
||||
this.subscriptions.add(
|
||||
atom.packages.onDidActivatePackage(pack => this.watchPackage(pack))
|
||||
)
|
||||
|
||||
this.subscriptions.add(atom.packages.onDidDeactivatePackage(pack => {
|
||||
// This only handles packages - onDidChangeActiveThemes handles themes
|
||||
const watcher = this.watchedPackages.get(pack.name)
|
||||
if (watcher) watcher.destroy()
|
||||
this.watchedPackages.delete(pack.name)
|
||||
}))
|
||||
this.subscriptions.add(
|
||||
atom.packages.onDidDeactivatePackage(pack => {
|
||||
// This only handles packages - onDidChangeActiveThemes handles themes
|
||||
const watcher = this.watchedPackages.get(pack.name)
|
||||
if (watcher) watcher.destroy()
|
||||
this.watchedPackages.delete(pack.name)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
watchTheme (theme) {
|
||||
if (PackageWatcher.supportsPackage(theme, 'theme')) this.watchedThemes.set(theme.name, this.createWatcher(new PackageWatcher(theme)))
|
||||
if (PackageWatcher.supportsPackage(theme, 'theme')) {
|
||||
this.watchedThemes.set(
|
||||
theme.name,
|
||||
this.createWatcher(new PackageWatcher(theme))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
watchPackage (pack) {
|
||||
if (PackageWatcher.supportsPackage(pack, 'atom')) this.watchedPackages.set(pack.name, this.createWatcher(new PackageWatcher(pack)))
|
||||
if (PackageWatcher.supportsPackage(pack, 'atom')) {
|
||||
this.watchedPackages.set(
|
||||
pack.name,
|
||||
this.createWatcher(new PackageWatcher(pack))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
createWatcher (watcher) {
|
||||
@@ -56,7 +79,9 @@ class UIWatcher {
|
||||
console.log('Global changed, reloading all styles')
|
||||
this.reloadAll()
|
||||
})
|
||||
watcher.onDidDestroy(() => this.watchers.splice(this.watchers.indexOf(watcher), 1))
|
||||
watcher.onDidDestroy(() =>
|
||||
this.watchers.splice(this.watchers.indexOf(watcher), 1)
|
||||
)
|
||||
this.watchers.push(watcher)
|
||||
return watcher
|
||||
}
|
||||
@@ -64,18 +89,26 @@ class UIWatcher {
|
||||
reloadAll () {
|
||||
this.baseTheme.loadAllStylesheets()
|
||||
for (const pack of atom.packages.getActivePackages()) {
|
||||
if (PackageWatcher.supportsPackage(pack, 'atom')) pack.reloadStylesheets()
|
||||
if (PackageWatcher.supportsPackage(pack, 'atom')) {
|
||||
pack.reloadStylesheets()
|
||||
}
|
||||
}
|
||||
|
||||
for (const theme of atom.themes.getActiveThemes()) {
|
||||
if (PackageWatcher.supportsPackage(theme, 'theme')) theme.reloadStylesheets()
|
||||
if (PackageWatcher.supportsPackage(theme, 'theme')) {
|
||||
theme.reloadStylesheets()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
destroy () {
|
||||
this.subscriptions.dispose()
|
||||
this.baseTheme.destroy()
|
||||
for (const pack of this.watchedPackages.values()) { pack.destroy() }
|
||||
for (const theme of this.watchedThemes.values()) { theme.destroy() }
|
||||
for (const pack of this.watchedPackages.values()) {
|
||||
pack.destroy()
|
||||
}
|
||||
for (const theme of this.watchedThemes.values()) {
|
||||
theme.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
const {CompositeDisposable, File, Directory, Emitter} = require('atom')
|
||||
const { CompositeDisposable, File, Directory, Emitter } = require('atom')
|
||||
const path = require('path')
|
||||
|
||||
module.exports =
|
||||
class Watcher {
|
||||
module.exports = class Watcher {
|
||||
constructor () {
|
||||
this.destroy = this.destroy.bind(this)
|
||||
this.emitter = new Emitter()
|
||||
@@ -66,7 +65,10 @@ class Watcher {
|
||||
}
|
||||
|
||||
isInAsarArchive (pathToCheck) {
|
||||
const {resourcePath} = atom.getLoadSettings()
|
||||
return pathToCheck.startsWith(`${resourcePath}${path.sep}`) && path.extname(resourcePath) === '.asar'
|
||||
const { resourcePath } = atom.getLoadSettings()
|
||||
return (
|
||||
pathToCheck.startsWith(`${resourcePath}${path.sep}`) &&
|
||||
path.extname(resourcePath) === '.asar'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,9 @@
|
||||
/** @babel */
|
||||
|
||||
export function beforeEach (fn) {
|
||||
global.beforeEach(function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function afterEach (fn) {
|
||||
global.afterEach(function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
['it', 'fit', 'ffit', 'fffit'].forEach(function (name) {
|
||||
module.exports[name] = function (description, fn) {
|
||||
if (fn === undefined) {
|
||||
global[name](description)
|
||||
return
|
||||
}
|
||||
|
||||
global[name](description, function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export async function conditionPromise (condition, description = 'anonymous condition') {
|
||||
export async function conditionPromise (
|
||||
condition,
|
||||
description = 'anonymous condition'
|
||||
) {
|
||||
const startTime = Date.now()
|
||||
|
||||
while (true) {
|
||||
@@ -55,49 +24,3 @@ export function timeoutPromise (timeout) {
|
||||
global.setTimeout(resolve, timeout)
|
||||
})
|
||||
}
|
||||
|
||||
function waitsForPromise (fn) {
|
||||
const promise = fn()
|
||||
global.waitsFor('spec promise to resolve', function (done) {
|
||||
promise.then(done, function (error) {
|
||||
jasmine.getEnv().currentSpec.fail(error)
|
||||
done()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function emitterEventPromise (emitter, event, timeout = 15000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeoutHandle = setTimeout(() => {
|
||||
reject(new Error(`Timed out waiting for '${event}' event`))
|
||||
}, timeout)
|
||||
emitter.once(event, () => {
|
||||
clearTimeout(timeoutHandle)
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function promisify (original) {
|
||||
return function (...args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
args.push((err, ...results) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(...results)
|
||||
}
|
||||
})
|
||||
|
||||
return original(...args)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function promisifySome (obj, fnNames) {
|
||||
const result = {}
|
||||
for (const fnName of fnNames) {
|
||||
result[fnName] = promisify(obj[fnName])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const {it, fit, ffit, afterEach, beforeEach} = require('./async-spec-helpers') // eslint-disable-line no-unused-vars
|
||||
|
||||
describe('Dev Live Reload', () => {
|
||||
describe('package activation', () => {
|
||||
let [pack, mainModule] = []
|
||||
@@ -85,7 +83,9 @@ describe('Dev Live Reload', () => {
|
||||
|
||||
it('stops watching all files', async () => {
|
||||
spyOn(atom.packages, 'hasActivatedInitialPackages').andReturn(true)
|
||||
const {mainModule} = await atom.packages.activatePackage('dev-live-reload')
|
||||
const { mainModule } = await atom.packages.activatePackage(
|
||||
'dev-live-reload'
|
||||
)
|
||||
expect(mainModule.uiWatcher).not.toBeNull()
|
||||
|
||||
spyOn(mainModule.uiWatcher, 'destroy')
|
||||
@@ -95,7 +95,9 @@ describe('Dev Live Reload', () => {
|
||||
})
|
||||
|
||||
it('unsubscribes from the onDidActivateInitialPackages subscription if it is disabled before all initial packages are activated', async () => {
|
||||
const {mainModule} = await atom.packages.activatePackage('dev-live-reload')
|
||||
const { mainModule } = await atom.packages.activatePackage(
|
||||
'dev-live-reload'
|
||||
)
|
||||
expect(mainModule.activatedDisposable.disposed).toBe(false)
|
||||
|
||||
await atom.packages.deactivatePackage('dev-live-reload')
|
||||
@@ -109,16 +111,18 @@ describe('Dev Live Reload', () => {
|
||||
it('removes its commands', async () => {
|
||||
spyOn(atom.packages, 'hasActivatedInitialPackages').andReturn(true)
|
||||
await atom.packages.activatePackage('dev-live-reload')
|
||||
expect(atom.commands
|
||||
.findCommands({target: atom.views.getView(atom.workspace)})
|
||||
.filter(command => command.name.startsWith('dev-live-reload'))
|
||||
.length).toBeGreaterThan(0)
|
||||
expect(
|
||||
atom.commands
|
||||
.findCommands({ target: atom.views.getView(atom.workspace) })
|
||||
.filter(command => command.name.startsWith('dev-live-reload')).length
|
||||
).toBeGreaterThan(0)
|
||||
|
||||
await atom.packages.deactivatePackage('dev-live-reload')
|
||||
expect(atom.commands
|
||||
.findCommands({target: atom.views.getView(atom.workspace)})
|
||||
.filter(command => command.name.startsWith('dev-live-reload'))
|
||||
.length).toBe(0)
|
||||
expect(
|
||||
atom.commands
|
||||
.findCommands({ target: atom.views.getView(atom.workspace) })
|
||||
.filter(command => command.name.startsWith('dev-live-reload')).length
|
||||
).toBe(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,25 +2,31 @@ const path = require('path')
|
||||
|
||||
const UIWatcher = require('../lib/ui-watcher')
|
||||
|
||||
const {it, fit, ffit, afterEach, beforeEach, conditionPromise} = require('./async-spec-helpers') // eslint-disable-line no-unused-vars
|
||||
const { conditionPromise } = require('./async-spec-helpers')
|
||||
|
||||
describe('UIWatcher', () => {
|
||||
let uiWatcher = null
|
||||
|
||||
beforeEach(() => atom.packages.packageDirPaths.push(path.join(__dirname, 'fixtures')))
|
||||
beforeEach(() =>
|
||||
atom.packages.packageDirPaths.push(path.join(__dirname, 'fixtures'))
|
||||
)
|
||||
|
||||
afterEach(() => uiWatcher && uiWatcher.destroy())
|
||||
|
||||
describe("when a base theme's file changes", () => {
|
||||
beforeEach(() => {
|
||||
spyOn(atom.themes, 'resolveStylesheet').andReturn(path.join(__dirname, 'fixtures', 'static', 'atom.less'))
|
||||
spyOn(atom.themes, 'resolveStylesheet').andReturn(
|
||||
path.join(__dirname, 'fixtures', 'static', 'atom.less')
|
||||
)
|
||||
uiWatcher = new UIWatcher()
|
||||
})
|
||||
|
||||
it('reloads all the base styles', () => {
|
||||
spyOn(atom.themes, 'reloadBaseStylesheets')
|
||||
|
||||
expect(uiWatcher.baseTheme.entities[0].getPath()).toContain(`${path.sep}static${path.sep}`)
|
||||
expect(uiWatcher.baseTheme.entities[0].getPath()).toContain(
|
||||
`${path.sep}static${path.sep}`
|
||||
)
|
||||
|
||||
uiWatcher.baseTheme.entities[0].emitter.emit('did-change')
|
||||
expect(atom.themes.reloadBaseStylesheets).toHaveBeenCalled()
|
||||
@@ -28,7 +34,11 @@ describe('UIWatcher', () => {
|
||||
})
|
||||
|
||||
it("watches all the style sheets in the theme's styles folder", async () => {
|
||||
const packagePath = path.join(__dirname, 'fixtures', 'package-with-styles-folder')
|
||||
const packagePath = path.join(
|
||||
__dirname,
|
||||
'fixtures',
|
||||
'package-with-styles-folder'
|
||||
)
|
||||
|
||||
await atom.packages.activatePackage(packagePath)
|
||||
uiWatcher = new UIWatcher()
|
||||
@@ -36,15 +46,25 @@ describe('UIWatcher', () => {
|
||||
const lastWatcher = uiWatcher.watchers[uiWatcher.watchers.length - 1]
|
||||
|
||||
expect(lastWatcher.entities.length).toBe(4)
|
||||
expect(lastWatcher.entities[0].getPath()).toBe(path.join(packagePath, 'styles'))
|
||||
expect(lastWatcher.entities[1].getPath()).toBe(path.join(packagePath, 'styles', '3.css'))
|
||||
expect(lastWatcher.entities[2].getPath()).toBe(path.join(packagePath, 'styles', 'sub', '1.css'))
|
||||
expect(lastWatcher.entities[3].getPath()).toBe(path.join(packagePath, 'styles', 'sub', '2.less'))
|
||||
expect(lastWatcher.entities[0].getPath()).toBe(
|
||||
path.join(packagePath, 'styles')
|
||||
)
|
||||
expect(lastWatcher.entities[1].getPath()).toBe(
|
||||
path.join(packagePath, 'styles', '3.css')
|
||||
)
|
||||
expect(lastWatcher.entities[2].getPath()).toBe(
|
||||
path.join(packagePath, 'styles', 'sub', '1.css')
|
||||
)
|
||||
expect(lastWatcher.entities[3].getPath()).toBe(
|
||||
path.join(packagePath, 'styles', 'sub', '2.less')
|
||||
)
|
||||
})
|
||||
|
||||
describe('when a package stylesheet file changes', async () => {
|
||||
beforeEach(async () => {
|
||||
await atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'package-with-styles-manifest'))
|
||||
await atom.packages.activatePackage(
|
||||
path.join(__dirname, 'fixtures', 'package-with-styles-manifest')
|
||||
)
|
||||
uiWatcher = new UIWatcher()
|
||||
})
|
||||
|
||||
@@ -71,7 +91,10 @@ describe('UIWatcher', () => {
|
||||
|
||||
describe('when a package global file changes', () => {
|
||||
beforeEach(async () => {
|
||||
atom.config.set('core.themes', ['theme-with-ui-variables', 'theme-with-multiple-imported-files'])
|
||||
atom.config.set('core.themes', [
|
||||
'theme-with-ui-variables',
|
||||
'theme-with-multiple-imported-files'
|
||||
])
|
||||
|
||||
await atom.themes.activateThemes()
|
||||
uiWatcher = new UIWatcher()
|
||||
@@ -85,7 +108,9 @@ describe('UIWatcher', () => {
|
||||
spyOn(theme, 'reloadStylesheets')
|
||||
}
|
||||
|
||||
for (const entity of uiWatcher.watchedThemes.get('theme-with-multiple-imported-files').entities) {
|
||||
for (const entity of uiWatcher.watchedThemes.get(
|
||||
'theme-with-multiple-imported-files'
|
||||
).entities) {
|
||||
if (entity.getPath().indexOf('variables') > -1) varEntity = entity
|
||||
}
|
||||
varEntity.emitter.emit('did-change')
|
||||
@@ -101,21 +126,31 @@ describe('UIWatcher', () => {
|
||||
uiWatcher = new UIWatcher()
|
||||
expect(uiWatcher.watchedPackages.size).toBe(0)
|
||||
|
||||
await atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'package-with-styles-folder'))
|
||||
expect(uiWatcher.watchedPackages.get('package-with-styles-folder')).not.toBeUndefined()
|
||||
await atom.packages.activatePackage(
|
||||
path.join(__dirname, 'fixtures', 'package-with-styles-folder')
|
||||
)
|
||||
expect(
|
||||
uiWatcher.watchedPackages.get('package-with-styles-folder')
|
||||
).not.toBeUndefined()
|
||||
})
|
||||
|
||||
it('unwatches a package after it is deactivated', async () => {
|
||||
await atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'package-with-styles-folder'))
|
||||
await atom.packages.activatePackage(
|
||||
path.join(__dirname, 'fixtures', 'package-with-styles-folder')
|
||||
)
|
||||
uiWatcher = new UIWatcher()
|
||||
const watcher = uiWatcher.watchedPackages.get('package-with-styles-folder')
|
||||
const watcher = uiWatcher.watchedPackages.get(
|
||||
'package-with-styles-folder'
|
||||
)
|
||||
expect(watcher).not.toBeUndefined()
|
||||
|
||||
const watcherDestructionSpy = jasmine.createSpy('watcher-on-did-destroy')
|
||||
watcher.onDidDestroy(watcherDestructionSpy)
|
||||
|
||||
await atom.packages.deactivatePackage('package-with-styles-folder')
|
||||
expect(uiWatcher.watchedPackages.get('package-with-styles-folder')).toBeUndefined()
|
||||
expect(
|
||||
uiWatcher.watchedPackages.get('package-with-styles-folder')
|
||||
).toBeUndefined()
|
||||
expect(uiWatcher.watchedPackages.size).toBe(0)
|
||||
expect(watcherDestructionSpy).toHaveBeenCalled()
|
||||
})
|
||||
@@ -124,7 +159,9 @@ describe('UIWatcher', () => {
|
||||
uiWatcher = new UIWatcher()
|
||||
uiWatcher.destroy()
|
||||
|
||||
await atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'package-with-styles-folder'))
|
||||
await atom.packages.activatePackage(
|
||||
path.join(__dirname, 'fixtures', 'package-with-styles-folder')
|
||||
)
|
||||
expect(uiWatcher.watchedPackages.size).toBe(0)
|
||||
})
|
||||
})
|
||||
@@ -132,7 +169,10 @@ describe('UIWatcher', () => {
|
||||
describe('minimal theme packages', () => {
|
||||
let pack = null
|
||||
beforeEach(async () => {
|
||||
atom.config.set('core.themes', ['theme-with-syntax-variables', 'theme-with-index-less'])
|
||||
atom.config.set('core.themes', [
|
||||
'theme-with-syntax-variables',
|
||||
'theme-with-index-less'
|
||||
])
|
||||
await atom.themes.activateThemes()
|
||||
uiWatcher = new UIWatcher()
|
||||
pack = atom.themes.getActiveThemes()[0]
|
||||
@@ -157,7 +197,10 @@ describe('UIWatcher', () => {
|
||||
describe('theme packages', () => {
|
||||
let pack = null
|
||||
beforeEach(async () => {
|
||||
atom.config.set('core.themes', ['theme-with-syntax-variables', 'theme-with-multiple-imported-files'])
|
||||
atom.config.set('core.themes', [
|
||||
'theme-with-syntax-variables',
|
||||
'theme-with-multiple-imported-files'
|
||||
])
|
||||
|
||||
await atom.themes.activateThemes()
|
||||
uiWatcher = new UIWatcher()
|
||||
@@ -170,7 +213,9 @@ describe('UIWatcher', () => {
|
||||
spyOn(pack, 'reloadStylesheets')
|
||||
spyOn(atom.themes, 'reloadBaseStylesheets')
|
||||
|
||||
const watcher = uiWatcher.watchedThemes.get('theme-with-multiple-imported-files')
|
||||
const watcher = uiWatcher.watchedThemes.get(
|
||||
'theme-with-multiple-imported-files'
|
||||
)
|
||||
|
||||
expect(watcher.entities.length).toBe(6)
|
||||
|
||||
@@ -186,14 +231,21 @@ describe('UIWatcher', () => {
|
||||
jasmine.useRealClock()
|
||||
|
||||
atom.config.set('core.themes', [])
|
||||
await conditionPromise(() => !uiWatcher.watchedThemes['theme-with-multiple-imported-files'])
|
||||
await conditionPromise(
|
||||
() => !uiWatcher.watchedThemes['theme-with-multiple-imported-files']
|
||||
)
|
||||
})
|
||||
|
||||
it('watches a new theme when it is deactivated', async () => {
|
||||
jasmine.useRealClock()
|
||||
|
||||
atom.config.set('core.themes', ['theme-with-syntax-variables', 'theme-with-package-file'])
|
||||
await conditionPromise(() => uiWatcher.watchedThemes.get('theme-with-package-file'))
|
||||
atom.config.set('core.themes', [
|
||||
'theme-with-syntax-variables',
|
||||
'theme-with-package-file'
|
||||
])
|
||||
await conditionPromise(() =>
|
||||
uiWatcher.watchedThemes.get('theme-with-package-file')
|
||||
)
|
||||
|
||||
pack = atom.themes.getActiveThemes()[0]
|
||||
spyOn(pack, 'reloadStylesheets')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** @babel */
|
||||
|
||||
import {CompositeDisposable} from 'atom'
|
||||
import { CompositeDisposable } from 'atom'
|
||||
|
||||
let reporter
|
||||
|
||||
@@ -13,36 +13,44 @@ function getReporter () {
|
||||
}
|
||||
|
||||
export default {
|
||||
activate() {
|
||||
activate () {
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
|
||||
if (!atom.config.get('exception-reporting.userId')) {
|
||||
atom.config.set('exception-reporting.userId', require('node-uuid').v4())
|
||||
}
|
||||
|
||||
this.subscriptions.add(atom.onDidThrowError(({message, url, line, column, originalError}) => {
|
||||
try {
|
||||
getReporter().reportUncaughtException(originalError)
|
||||
} catch (secondaryException) {
|
||||
this.subscriptions.add(
|
||||
atom.onDidThrowError(({ message, url, line, column, originalError }) => {
|
||||
try {
|
||||
console.error("Error reporting uncaught exception", secondaryException)
|
||||
getReporter().reportUncaughtException(secondaryException)
|
||||
} catch (error) { }
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if (atom.onDidFailAssertion != null) {
|
||||
this.subscriptions.add(atom.onDidFailAssertion(error => {
|
||||
try {
|
||||
getReporter().reportFailedAssertion(error)
|
||||
getReporter().reportUncaughtException(originalError)
|
||||
} catch (secondaryException) {
|
||||
try {
|
||||
console.error("Error reporting assertion failure", secondaryException)
|
||||
console.error(
|
||||
'Error reporting uncaught exception',
|
||||
secondaryException
|
||||
)
|
||||
getReporter().reportUncaughtException(secondaryException)
|
||||
} catch (error) {}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if (atom.onDidFailAssertion != null) {
|
||||
this.subscriptions.add(
|
||||
atom.onDidFailAssertion(error => {
|
||||
try {
|
||||
getReporter().reportFailedAssertion(error)
|
||||
} catch (secondaryException) {
|
||||
try {
|
||||
console.error(
|
||||
'Error reporting assertion failure',
|
||||
secondaryException
|
||||
)
|
||||
getReporter().reportUncaughtException(secondaryException)
|
||||
} catch (error) {}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** @babel */
|
||||
|
||||
import _ from 'underscore-plus'
|
||||
import os from 'os'
|
||||
import stackTrace from 'stack-trace'
|
||||
import fs from 'fs-plus'
|
||||
@@ -13,9 +12,15 @@ const StackTraceCache = new WeakMap()
|
||||
export default class Reporter {
|
||||
constructor (params = {}) {
|
||||
this.request = params.request || window.fetch
|
||||
this.alwaysReport = params.hasOwnProperty('alwaysReport') ? params.alwaysReport : false
|
||||
this.reportPreviousErrors = params.hasOwnProperty('reportPreviousErrors') ? params.reportPreviousErrors : true
|
||||
this.resourcePath = this.normalizePath(params.resourcePath || process.resourcesPath)
|
||||
this.alwaysReport = params.hasOwnProperty('alwaysReport')
|
||||
? params.alwaysReport
|
||||
: false
|
||||
this.reportPreviousErrors = params.hasOwnProperty('reportPreviousErrors')
|
||||
? params.reportPreviousErrors
|
||||
: true
|
||||
this.resourcePath = this.normalizePath(
|
||||
params.resourcePath || process.resourcesPath
|
||||
)
|
||||
this.reportedErrors = []
|
||||
this.reportedAssertionFailures = []
|
||||
}
|
||||
@@ -28,22 +33,24 @@ export default class Reporter {
|
||||
version: LIB_VERSION,
|
||||
url: 'https://www.atom.io'
|
||||
},
|
||||
events: [{
|
||||
payloadVersion: "2",
|
||||
exceptions: [this.buildExceptionJSON(error, params.projectRoot)],
|
||||
severity: params.severity,
|
||||
user: {
|
||||
id: params.userId
|
||||
},
|
||||
app: {
|
||||
version: params.appVersion,
|
||||
releaseStage: params.releaseStage
|
||||
},
|
||||
device: {
|
||||
osVersion: params.osVersion
|
||||
},
|
||||
metaData: error.metadata
|
||||
}]
|
||||
events: [
|
||||
{
|
||||
payloadVersion: '2',
|
||||
exceptions: [this.buildExceptionJSON(error, params.projectRoot)],
|
||||
severity: params.severity,
|
||||
user: {
|
||||
id: params.userId
|
||||
},
|
||||
app: {
|
||||
version: params.appVersion,
|
||||
releaseStage: params.releaseStage
|
||||
},
|
||||
device: {
|
||||
osVersion: params.osVersion
|
||||
},
|
||||
metaData: error.metadata
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +66,8 @@ export default class Reporter {
|
||||
return this.parseStackTrace(error).map(callSite => {
|
||||
return {
|
||||
file: this.scrubPath(callSite.getFileName()),
|
||||
method: callSite.getMethodName() || callSite.getFunctionName() || "none",
|
||||
method:
|
||||
callSite.getMethodName() || callSite.getFunctionName() || 'none',
|
||||
lineNumber: callSite.getLineNumber(),
|
||||
columnNumber: callSite.getColumnNumber(),
|
||||
inProject: !/node_modules/.test(callSite.getFileName())
|
||||
@@ -69,8 +77,8 @@ export default class Reporter {
|
||||
|
||||
normalizePath (pathToNormalize) {
|
||||
return pathToNormalize
|
||||
.replace('file:///', '') // Sometimes it's a uri
|
||||
.replace(/\\/g, '/') // Unify path separators across Win/macOS/Linux
|
||||
.replace('file:///', '') // Sometimes it's a uri
|
||||
.replace(/\\/g, '/') // Unify path separators across Win/macOS/Linux
|
||||
}
|
||||
|
||||
scrubPath (pathToScrub) {
|
||||
@@ -96,17 +104,17 @@ export default class Reporter {
|
||||
}
|
||||
|
||||
getReleaseChannel (version) {
|
||||
return (version.indexOf('beta') > -1)
|
||||
return version.indexOf('beta') > -1
|
||||
? 'beta'
|
||||
: (version.indexOf('dev') > -1)
|
||||
? 'dev'
|
||||
: 'stable'
|
||||
: version.indexOf('dev') > -1
|
||||
? 'dev'
|
||||
: 'stable'
|
||||
}
|
||||
|
||||
performRequest (json) {
|
||||
this.request.call(null, 'https://notify.bugsnag.com', {
|
||||
method: 'POST',
|
||||
headers: new Headers({'Content-Type': 'application/json'}),
|
||||
headers: new Headers({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify(json)
|
||||
})
|
||||
}
|
||||
@@ -118,7 +126,10 @@ export default class Reporter {
|
||||
|
||||
const topFrame = this.parseStackTrace(error)[0]
|
||||
const fileName = topFrame ? topFrame.getFileName() : null
|
||||
return fileName && (this.isBundledFile(fileName) || this.isTeletypeFile(fileName))
|
||||
return (
|
||||
fileName &&
|
||||
(this.isBundledFile(fileName) || this.isTeletypeFile(fileName))
|
||||
)
|
||||
}
|
||||
|
||||
parseStackTrace (error) {
|
||||
@@ -169,21 +180,24 @@ export default class Reporter {
|
||||
|
||||
notification = atom.notifications.addInfo(message, {
|
||||
detail: error.privateMetadataDescription,
|
||||
description: "Are you willing to submit this information to a private server for debugging purposes?",
|
||||
description:
|
||||
'Are you willing to submit this information to a private server for debugging purposes?',
|
||||
dismissable: true,
|
||||
buttons: [
|
||||
{
|
||||
text: "No",
|
||||
text: 'No',
|
||||
onDidClick: reportWithoutPrivateMetadata
|
||||
},
|
||||
{
|
||||
text: "Yes, Submit for Debugging",
|
||||
text: 'Yes, Submit for Debugging',
|
||||
onDidClick: reportWithPrivateMetadata
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
dismissSubscription = notification.onDidDismiss(reportWithoutPrivateMetadata)
|
||||
dismissSubscription = notification.onDidDismiss(
|
||||
reportWithoutPrivateMetadata
|
||||
)
|
||||
}
|
||||
|
||||
addPackageMetadata (error) {
|
||||
@@ -200,7 +214,9 @@ export default class Reporter {
|
||||
}
|
||||
}
|
||||
|
||||
if (error.metadata == null) { error.metadata = {} }
|
||||
if (error.metadata == null) {
|
||||
error.metadata = {}
|
||||
}
|
||||
error.metadata.bundledPackages = bundledPackages
|
||||
error.metadata.userPackages = userPackages
|
||||
}
|
||||
@@ -209,8 +225,12 @@ export default class Reporter {
|
||||
addPreviousErrorsMetadata (error) {
|
||||
if (!this.reportPreviousErrors) return
|
||||
if (!error.metadata) error.metadata = {}
|
||||
error.metadata.previousErrors = this.reportedErrors.map(error => error.message)
|
||||
error.metadata.previousAssertionFailures = this.reportedAssertionFailures.map(error => error.message)
|
||||
error.metadata.previousErrors = this.reportedErrors.map(
|
||||
error => error.message
|
||||
)
|
||||
error.metadata.previousAssertionFailures = this.reportedAssertionFailures.map(
|
||||
error => error.message
|
||||
)
|
||||
}
|
||||
|
||||
reportUncaughtException (error) {
|
||||
@@ -219,13 +239,20 @@ export default class Reporter {
|
||||
this.addPackageMetadata(error)
|
||||
this.addPreviousErrorsMetadata(error)
|
||||
|
||||
if ((error.privateMetadata != null) && (error.privateMetadataDescription != null)) {
|
||||
this.requestPrivateMetadataConsent(error, "The Atom team would like to collect the following information to resolve this error:", error => this.reportUncaughtException(error))
|
||||
if (
|
||||
error.privateMetadata != null &&
|
||||
error.privateMetadataDescription != null
|
||||
) {
|
||||
this.requestPrivateMetadataConsent(
|
||||
error,
|
||||
'The Atom team would like to collect the following information to resolve this error:',
|
||||
error => this.reportUncaughtException(error)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
let params = this.getDefaultNotificationParams()
|
||||
params.severity = "error"
|
||||
params.severity = 'error'
|
||||
this.performRequest(this.buildNotificationJSON(error, params))
|
||||
this.reportedErrors.push(error)
|
||||
}
|
||||
@@ -236,13 +263,20 @@ export default class Reporter {
|
||||
this.addPackageMetadata(error)
|
||||
this.addPreviousErrorsMetadata(error)
|
||||
|
||||
if ((error.privateMetadata != null) && (error.privateMetadataDescription != null)) {
|
||||
this.requestPrivateMetadataConsent(error, "The Atom team would like to collect some information to resolve an unexpected condition:", error => this.reportFailedAssertion(error))
|
||||
if (
|
||||
error.privateMetadata != null &&
|
||||
error.privateMetadataDescription != null
|
||||
) {
|
||||
this.requestPrivateMetadataConsent(
|
||||
error,
|
||||
'The Atom team would like to collect some information to resolve an unexpected condition:',
|
||||
error => this.reportFailedAssertion(error)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
let params = this.getDefaultNotificationParams()
|
||||
params.severity = "warning"
|
||||
params.severity = 'warning'
|
||||
this.performRequest(this.buildNotificationJSON(error, params))
|
||||
this.reportedAssertionFailures.push(error)
|
||||
}
|
||||
@@ -258,10 +292,11 @@ export default class Reporter {
|
||||
|
||||
isTeletypeFile (fileName) {
|
||||
const teletypePath = atom.packages.resolvePackagePath('teletype')
|
||||
return teletypePath && this.normalizePath(fileName).indexOf(teletypePath) === 0
|
||||
return (
|
||||
teletypePath && this.normalizePath(fileName).indexOf(teletypePath) === 0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reporter.API_KEY = API_KEY
|
||||
Reporter.LIB_VERSION = LIB_VERSION
|
||||
|
||||
@@ -6,25 +6,31 @@ const fs = require('fs-plus')
|
||||
let osVersion = `${os.platform()}-${os.arch()}-${os.release()}`
|
||||
|
||||
let getReleaseChannel = version => {
|
||||
return (version.indexOf('beta') > -1)
|
||||
return version.indexOf('beta') > -1
|
||||
? 'beta'
|
||||
: (version.indexOf('dev') > -1)
|
||||
: version.indexOf('dev') > -1
|
||||
? 'dev'
|
||||
: 'stable'
|
||||
}
|
||||
|
||||
describe("Reporter", () => {
|
||||
let reporter, requests, initialStackTraceLimit, initialFsGetHomeDirectory, mockActivePackages
|
||||
describe('Reporter', () => {
|
||||
let reporter,
|
||||
requests,
|
||||
initialStackTraceLimit,
|
||||
initialFsGetHomeDirectory,
|
||||
mockActivePackages
|
||||
|
||||
beforeEach(() => {
|
||||
reporter = new Reporter({
|
||||
request: (url, options) => requests.push(Object.assign({url}, options)),
|
||||
request: (url, options) => requests.push(Object.assign({ url }, options)),
|
||||
alwaysReport: true,
|
||||
reportPreviousErrors: false
|
||||
})
|
||||
requests = []
|
||||
mockActivePackages = []
|
||||
spyOn(atom.packages, 'getActivePackages').andCallFake(() => mockActivePackages)
|
||||
spyOn(atom.packages, 'getActivePackages').andCallFake(
|
||||
() => mockActivePackages
|
||||
)
|
||||
|
||||
initialStackTraceLimit = Error.stackTraceLimit
|
||||
Error.stackTraceLimit = 1
|
||||
@@ -37,11 +43,12 @@ describe("Reporter", () => {
|
||||
Error.stackTraceLimit = initialStackTraceLimit
|
||||
})
|
||||
|
||||
describe(".reportUncaughtException(error)", () => {
|
||||
it("posts errors originated inside Atom Core to BugSnag", () => {
|
||||
describe('.reportUncaughtException(error)', () => {
|
||||
it('posts errors originated inside Atom Core to BugSnag', () => {
|
||||
const repositoryRootPath = path.join(__dirname, '..')
|
||||
reporter = new Reporter({
|
||||
request: (url, options) => requests.push(Object.assign({url}, options)),
|
||||
request: (url, options) =>
|
||||
requests.push(Object.assign({ url }, options)),
|
||||
alwaysReport: true,
|
||||
reportPreviousErrors: false,
|
||||
resourcePath: repositoryRootPath
|
||||
@@ -50,111 +57,123 @@ describe("Reporter", () => {
|
||||
let error = new Error()
|
||||
Error.captureStackTrace(error)
|
||||
reporter.reportUncaughtException(error)
|
||||
let [lineNumber, columnNumber] = error.stack.match(/.js:(\d+):(\d+)/).slice(1).map(s => parseInt(s))
|
||||
let [lineNumber, columnNumber] = error.stack
|
||||
.match(/.js:(\d+):(\d+)/)
|
||||
.slice(1)
|
||||
.map(s => parseInt(s))
|
||||
|
||||
expect(requests.length).toBe(1)
|
||||
let [request] = requests
|
||||
expect(request.method).toBe("POST")
|
||||
expect(request.url).toBe("https://notify.bugsnag.com")
|
||||
expect(request.headers.get("Content-Type")).toBe("application/json")
|
||||
expect(request.method).toBe('POST')
|
||||
expect(request.url).toBe('https://notify.bugsnag.com')
|
||||
expect(request.headers.get('Content-Type')).toBe('application/json')
|
||||
let body = JSON.parse(request.body)
|
||||
// Delete `inProject` field because tests may fail when run as part of Atom core
|
||||
// (i.e. when this test file will be located under `node_modules/exception-reporting/spec`)
|
||||
delete body.events[0].exceptions[0].stacktrace[0].inProject
|
||||
|
||||
expect(body).toEqual({
|
||||
"apiKey": Reporter.API_KEY,
|
||||
"notifier": {
|
||||
"name": "Atom",
|
||||
"version": Reporter.LIB_VERSION,
|
||||
"url": "https://www.atom.io"
|
||||
apiKey: Reporter.API_KEY,
|
||||
notifier: {
|
||||
name: 'Atom',
|
||||
version: Reporter.LIB_VERSION,
|
||||
url: 'https://www.atom.io'
|
||||
},
|
||||
"events": [
|
||||
events: [
|
||||
{
|
||||
"payloadVersion": "2",
|
||||
"exceptions": [
|
||||
payloadVersion: '2',
|
||||
exceptions: [
|
||||
{
|
||||
"errorClass": "Error",
|
||||
"message": "",
|
||||
"stacktrace": [
|
||||
errorClass: 'Error',
|
||||
message: '',
|
||||
stacktrace: [
|
||||
{
|
||||
"method": semver.gt(process.versions.electron, '1.6.0') ? 'Spec.it' : 'it',
|
||||
"file": "spec/reporter-spec.js",
|
||||
"lineNumber": lineNumber,
|
||||
"columnNumber": columnNumber
|
||||
method: semver.gt(process.versions.electron, '1.6.0')
|
||||
? 'Spec.it'
|
||||
: 'it',
|
||||
file: 'spec/reporter-spec.js',
|
||||
lineNumber: lineNumber,
|
||||
columnNumber: columnNumber
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"severity": "error",
|
||||
"user": {},
|
||||
"app": {
|
||||
"version": atom.getVersion(),
|
||||
"releaseStage": getReleaseChannel(atom.getVersion())
|
||||
severity: 'error',
|
||||
user: {},
|
||||
app: {
|
||||
version: atom.getVersion(),
|
||||
releaseStage: getReleaseChannel(atom.getVersion())
|
||||
},
|
||||
"device": {
|
||||
"osVersion": osVersion
|
||||
device: {
|
||||
osVersion: osVersion
|
||||
}
|
||||
}
|
||||
]
|
||||
});})
|
||||
})
|
||||
})
|
||||
|
||||
it("posts errors originated outside Atom Core to BugSnag", () => {
|
||||
it('posts errors originated outside Atom Core to BugSnag', () => {
|
||||
fs.getHomeDirectory = () => path.join(__dirname, '..', '..')
|
||||
|
||||
let error = new Error()
|
||||
Error.captureStackTrace(error)
|
||||
reporter.reportUncaughtException(error)
|
||||
let [lineNumber, columnNumber] = error.stack.match(/.js:(\d+):(\d+)/).slice(1).map(s => parseInt(s))
|
||||
let [lineNumber, columnNumber] = error.stack
|
||||
.match(/.js:(\d+):(\d+)/)
|
||||
.slice(1)
|
||||
.map(s => parseInt(s))
|
||||
|
||||
expect(requests.length).toBe(1)
|
||||
let [request] = requests
|
||||
expect(request.method).toBe("POST")
|
||||
expect(request.url).toBe("https://notify.bugsnag.com")
|
||||
expect(request.headers.get("Content-Type")).toBe("application/json")
|
||||
expect(request.method).toBe('POST')
|
||||
expect(request.url).toBe('https://notify.bugsnag.com')
|
||||
expect(request.headers.get('Content-Type')).toBe('application/json')
|
||||
let body = JSON.parse(request.body)
|
||||
// Delete `inProject` field because tests may fail when run as part of Atom core
|
||||
// (i.e. when this test file will be located under `node_modules/exception-reporting/spec`)
|
||||
delete body.events[0].exceptions[0].stacktrace[0].inProject
|
||||
|
||||
expect(body).toEqual({
|
||||
"apiKey": Reporter.API_KEY,
|
||||
"notifier": {
|
||||
"name": "Atom",
|
||||
"version": Reporter.LIB_VERSION,
|
||||
"url": "https://www.atom.io"
|
||||
apiKey: Reporter.API_KEY,
|
||||
notifier: {
|
||||
name: 'Atom',
|
||||
version: Reporter.LIB_VERSION,
|
||||
url: 'https://www.atom.io'
|
||||
},
|
||||
"events": [
|
||||
events: [
|
||||
{
|
||||
"payloadVersion": "2",
|
||||
"exceptions": [
|
||||
payloadVersion: '2',
|
||||
exceptions: [
|
||||
{
|
||||
"errorClass": "Error",
|
||||
"message": "",
|
||||
"stacktrace": [
|
||||
errorClass: 'Error',
|
||||
message: '',
|
||||
stacktrace: [
|
||||
{
|
||||
"method": semver.gt(process.versions.electron, '1.6.0') ? 'Spec.it' : 'it',
|
||||
"file": '~/exception-reporting/spec/reporter-spec.js',
|
||||
"lineNumber": lineNumber,
|
||||
"columnNumber": columnNumber
|
||||
method: semver.gt(process.versions.electron, '1.6.0')
|
||||
? 'Spec.it'
|
||||
: 'it',
|
||||
file: '~/exception-reporting/spec/reporter-spec.js',
|
||||
lineNumber: lineNumber,
|
||||
columnNumber: columnNumber
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"severity": "error",
|
||||
"user": {},
|
||||
"app": {
|
||||
"version": atom.getVersion(),
|
||||
"releaseStage": getReleaseChannel(atom.getVersion())
|
||||
severity: 'error',
|
||||
user: {},
|
||||
app: {
|
||||
version: atom.getVersion(),
|
||||
releaseStage: getReleaseChannel(atom.getVersion())
|
||||
},
|
||||
"device": {
|
||||
"osVersion": osVersion
|
||||
device: {
|
||||
osVersion: osVersion
|
||||
}
|
||||
}
|
||||
]
|
||||
});})
|
||||
})
|
||||
})
|
||||
|
||||
describe("when the error object has `privateMetadata` and `privateMetadataDescription` fields", () => {
|
||||
describe('when the error object has `privateMetadata` and `privateMetadataDescription` fields', () => {
|
||||
let [error, notification] = []
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -164,17 +183,17 @@ describe("Reporter", () => {
|
||||
error = new Error()
|
||||
Error.captureStackTrace(error)
|
||||
|
||||
error.metadata = {foo: "bar"}
|
||||
error.privateMetadata = {baz: "quux"}
|
||||
error.privateMetadataDescription = "The contents of baz"
|
||||
error.metadata = { foo: 'bar' }
|
||||
error.privateMetadata = { baz: 'quux' }
|
||||
error.privateMetadataDescription = 'The contents of baz'
|
||||
})
|
||||
|
||||
it("posts a notification asking for consent", () => {
|
||||
it('posts a notification asking for consent', () => {
|
||||
reporter.reportUncaughtException(error)
|
||||
expect(atom.notifications.addInfo).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("submits the error with the private metadata if the user consents", () => {
|
||||
it('submits the error with the private metadata if the user consents', () => {
|
||||
spyOn(reporter, 'reportUncaughtException').andCallThrough()
|
||||
reporter.reportUncaughtException(error)
|
||||
reporter.reportUncaughtException.reset()
|
||||
@@ -189,12 +208,12 @@ describe("Reporter", () => {
|
||||
expect(reporter.reportUncaughtException.callCount).toBe(1)
|
||||
expect(error.privateMetadata).toBeUndefined()
|
||||
expect(error.privateMetadataDescription).toBeUndefined()
|
||||
expect(error.metadata).toEqual({foo: "bar", baz: "quux"})
|
||||
expect(error.metadata).toEqual({ foo: 'bar', baz: 'quux' })
|
||||
|
||||
expect(notification.isDismissed()).toBe(true)
|
||||
})
|
||||
|
||||
it("submits the error without the private metadata if the user does not consent", () => {
|
||||
it('submits the error without the private metadata if the user does not consent', () => {
|
||||
spyOn(reporter, 'reportUncaughtException').andCallThrough()
|
||||
reporter.reportUncaughtException(error)
|
||||
reporter.reportUncaughtException.reset()
|
||||
@@ -209,12 +228,12 @@ describe("Reporter", () => {
|
||||
expect(reporter.reportUncaughtException.callCount).toBe(1)
|
||||
expect(error.privateMetadata).toBeUndefined()
|
||||
expect(error.privateMetadataDescription).toBeUndefined()
|
||||
expect(error.metadata).toEqual({foo: "bar"})
|
||||
expect(error.metadata).toEqual({ foo: 'bar' })
|
||||
|
||||
expect(notification.isDismissed()).toBe(true)
|
||||
})
|
||||
|
||||
it("submits the error without the private metadata if the user dismisses the notification", () => {
|
||||
it('submits the error without the private metadata if the user dismisses the notification', () => {
|
||||
spyOn(reporter, 'reportUncaughtException').andCallThrough()
|
||||
reporter.reportUncaughtException(error)
|
||||
reporter.reportUncaughtException.reset()
|
||||
@@ -226,14 +245,34 @@ describe("Reporter", () => {
|
||||
expect(reporter.reportUncaughtException.callCount).toBe(1)
|
||||
expect(error.privateMetadata).toBeUndefined()
|
||||
expect(error.privateMetadataDescription).toBeUndefined()
|
||||
expect(error.metadata).toEqual({foo: "bar"});});})
|
||||
expect(error.metadata).toEqual({ foo: 'bar' })
|
||||
})
|
||||
})
|
||||
|
||||
it('treats packages located in atom.packages.getPackageDirPaths as user packages', () => {
|
||||
mockActivePackages = [
|
||||
{name: 'user-1', path: '/Users/user/.atom/packages/user-1', metadata: {version: '1.0.0'}},
|
||||
{name: 'user-2', path: '/Users/user/.atom/packages/user-2', metadata: {version: '1.2.0'}},
|
||||
{name: 'bundled-1', path: '/Applications/Atom.app/Contents/Resources/app.asar/node_modules/bundled-1', metadata: {version: '1.0.0'}},
|
||||
{name: 'bundled-2', path: '/Applications/Atom.app/Contents/Resources/app.asar/node_modules/bundled-2', metadata: {version: '1.2.0'}},
|
||||
{
|
||||
name: 'user-1',
|
||||
path: '/Users/user/.atom/packages/user-1',
|
||||
metadata: { version: '1.0.0' }
|
||||
},
|
||||
{
|
||||
name: 'user-2',
|
||||
path: '/Users/user/.atom/packages/user-2',
|
||||
metadata: { version: '1.2.0' }
|
||||
},
|
||||
{
|
||||
name: 'bundled-1',
|
||||
path:
|
||||
'/Applications/Atom.app/Contents/Resources/app.asar/node_modules/bundled-1',
|
||||
metadata: { version: '1.0.0' }
|
||||
},
|
||||
{
|
||||
name: 'bundled-2',
|
||||
path:
|
||||
'/Applications/Atom.app/Contents/Resources/app.asar/node_modules/bundled-2',
|
||||
metadata: { version: '1.2.0' }
|
||||
}
|
||||
]
|
||||
|
||||
const packageDirPaths = ['/Users/user/.atom/packages']
|
||||
@@ -269,69 +308,78 @@ describe("Reporter", () => {
|
||||
const lastRequest = requests[requests.length - 1]
|
||||
const body = JSON.parse(lastRequest.body)
|
||||
|
||||
console.log(body);
|
||||
console.log(body)
|
||||
expect(body.events[0].metaData.previousErrors).toEqual(['A', 'B'])
|
||||
expect(body.events[0].metaData.previousAssertionFailures).toEqual(['X', 'Y'])
|
||||
expect(body.events[0].metaData.previousAssertionFailures).toEqual([
|
||||
'X',
|
||||
'Y'
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe(".reportFailedAssertion(error)", () => {
|
||||
it("posts warnings to bugsnag", () => {
|
||||
describe('.reportFailedAssertion(error)', () => {
|
||||
it('posts warnings to bugsnag', () => {
|
||||
fs.getHomeDirectory = () => path.join(__dirname, '..', '..')
|
||||
|
||||
let error = new Error()
|
||||
Error.captureStackTrace(error)
|
||||
reporter.reportFailedAssertion(error)
|
||||
let [lineNumber, columnNumber] = error.stack.match(/.js:(\d+):(\d+)/).slice(1).map(s => parseInt(s))
|
||||
let [lineNumber, columnNumber] = error.stack
|
||||
.match(/.js:(\d+):(\d+)/)
|
||||
.slice(1)
|
||||
.map(s => parseInt(s))
|
||||
|
||||
expect(requests.length).toBe(1)
|
||||
let [request] = requests
|
||||
expect(request.method).toBe("POST")
|
||||
expect(request.url).toBe("https://notify.bugsnag.com")
|
||||
expect(request.headers.get("Content-Type")).toBe("application/json")
|
||||
expect(request.method).toBe('POST')
|
||||
expect(request.url).toBe('https://notify.bugsnag.com')
|
||||
expect(request.headers.get('Content-Type')).toBe('application/json')
|
||||
let body = JSON.parse(request.body)
|
||||
// Delete `inProject` field because tests may fail when run as part of Atom core
|
||||
// (i.e. when this test file will be located under `node_modules/exception-reporting/spec`)
|
||||
delete body.events[0].exceptions[0].stacktrace[0].inProject
|
||||
|
||||
expect(body).toEqual({
|
||||
"apiKey": Reporter.API_KEY,
|
||||
"notifier": {
|
||||
"name": "Atom",
|
||||
"version": Reporter.LIB_VERSION,
|
||||
"url": "https://www.atom.io"
|
||||
apiKey: Reporter.API_KEY,
|
||||
notifier: {
|
||||
name: 'Atom',
|
||||
version: Reporter.LIB_VERSION,
|
||||
url: 'https://www.atom.io'
|
||||
},
|
||||
"events": [
|
||||
events: [
|
||||
{
|
||||
"payloadVersion": "2",
|
||||
"exceptions": [
|
||||
payloadVersion: '2',
|
||||
exceptions: [
|
||||
{
|
||||
"errorClass": "Error",
|
||||
"message": "",
|
||||
"stacktrace": [
|
||||
errorClass: 'Error',
|
||||
message: '',
|
||||
stacktrace: [
|
||||
{
|
||||
"method": semver.gt(process.versions.electron, '1.6.0') ? 'Spec.it' : 'it',
|
||||
"file": '~/exception-reporting/spec/reporter-spec.js',
|
||||
"lineNumber": lineNumber,
|
||||
"columnNumber": columnNumber
|
||||
method: semver.gt(process.versions.electron, '1.6.0')
|
||||
? 'Spec.it'
|
||||
: 'it',
|
||||
file: '~/exception-reporting/spec/reporter-spec.js',
|
||||
lineNumber: lineNumber,
|
||||
columnNumber: columnNumber
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"severity": "warning",
|
||||
"user": {},
|
||||
"app": {
|
||||
"version": atom.getVersion(),
|
||||
"releaseStage": getReleaseChannel(atom.getVersion())
|
||||
severity: 'warning',
|
||||
user: {},
|
||||
app: {
|
||||
version: atom.getVersion(),
|
||||
releaseStage: getReleaseChannel(atom.getVersion())
|
||||
},
|
||||
"device": {
|
||||
"osVersion": osVersion
|
||||
device: {
|
||||
osVersion: osVersion
|
||||
}
|
||||
}
|
||||
]
|
||||
});})
|
||||
})
|
||||
})
|
||||
|
||||
describe("when the error object has `privateMetadata` and `privateMetadataDescription` fields", () => {
|
||||
describe('when the error object has `privateMetadata` and `privateMetadataDescription` fields', () => {
|
||||
let [error, notification] = []
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -341,17 +389,17 @@ describe("Reporter", () => {
|
||||
error = new Error()
|
||||
Error.captureStackTrace(error)
|
||||
|
||||
error.metadata = {foo: "bar"}
|
||||
error.privateMetadata = {baz: "quux"}
|
||||
error.privateMetadataDescription = "The contents of baz"
|
||||
error.metadata = { foo: 'bar' }
|
||||
error.privateMetadata = { baz: 'quux' }
|
||||
error.privateMetadataDescription = 'The contents of baz'
|
||||
})
|
||||
|
||||
it("posts a notification asking for consent", () => {
|
||||
it('posts a notification asking for consent', () => {
|
||||
reporter.reportFailedAssertion(error)
|
||||
expect(atom.notifications.addInfo).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("submits the error with the private metadata if the user consents", () => {
|
||||
it('submits the error with the private metadata if the user consents', () => {
|
||||
spyOn(reporter, 'reportFailedAssertion').andCallThrough()
|
||||
reporter.reportFailedAssertion(error)
|
||||
reporter.reportFailedAssertion.reset()
|
||||
@@ -366,12 +414,12 @@ describe("Reporter", () => {
|
||||
expect(reporter.reportFailedAssertion.callCount).toBe(1)
|
||||
expect(error.privateMetadata).toBeUndefined()
|
||||
expect(error.privateMetadataDescription).toBeUndefined()
|
||||
expect(error.metadata).toEqual({foo: "bar", baz: "quux"})
|
||||
expect(error.metadata).toEqual({ foo: 'bar', baz: 'quux' })
|
||||
|
||||
expect(notification.isDismissed()).toBe(true)
|
||||
})
|
||||
|
||||
it("submits the error without the private metadata if the user does not consent", () => {
|
||||
it('submits the error without the private metadata if the user does not consent', () => {
|
||||
spyOn(reporter, 'reportFailedAssertion').andCallThrough()
|
||||
reporter.reportFailedAssertion(error)
|
||||
reporter.reportFailedAssertion.reset()
|
||||
@@ -386,12 +434,12 @@ describe("Reporter", () => {
|
||||
expect(reporter.reportFailedAssertion.callCount).toBe(1)
|
||||
expect(error.privateMetadata).toBeUndefined()
|
||||
expect(error.privateMetadataDescription).toBeUndefined()
|
||||
expect(error.metadata).toEqual({foo: "bar"})
|
||||
expect(error.metadata).toEqual({ foo: 'bar' })
|
||||
|
||||
expect(notification.isDismissed()).toBe(true)
|
||||
})
|
||||
|
||||
it("submits the error without the private metadata if the user dismisses the notification", () => {
|
||||
it('submits the error without the private metadata if the user dismisses the notification', () => {
|
||||
spyOn(reporter, 'reportFailedAssertion').andCallThrough()
|
||||
reporter.reportFailedAssertion(error)
|
||||
reporter.reportFailedAssertion.reset()
|
||||
@@ -403,13 +451,17 @@ describe("Reporter", () => {
|
||||
expect(reporter.reportFailedAssertion.callCount).toBe(1)
|
||||
expect(error.privateMetadata).toBeUndefined()
|
||||
expect(error.privateMetadataDescription).toBeUndefined()
|
||||
expect(error.metadata).toEqual({foo: "bar"})
|
||||
expect(error.metadata).toEqual({ foo: 'bar' })
|
||||
})
|
||||
|
||||
it("only notifies the user once for a given 'privateMetadataRequestName'", () => {
|
||||
let fakeStorage = {}
|
||||
spyOn(global.localStorage, 'setItem').andCallFake((key, value) => fakeStorage[key] = value)
|
||||
spyOn(global.localStorage, 'getItem').andCallFake(key => fakeStorage[key])
|
||||
spyOn(global.localStorage, 'setItem').andCallFake(
|
||||
(key, value) => (fakeStorage[key] = value)
|
||||
)
|
||||
spyOn(global.localStorage, 'getItem').andCallFake(
|
||||
key => fakeStorage[key]
|
||||
)
|
||||
|
||||
error.privateMetadataRequestName = 'foo'
|
||||
|
||||
@@ -423,7 +475,7 @@ describe("Reporter", () => {
|
||||
let error2 = new Error()
|
||||
Error.captureStackTrace(error2)
|
||||
error2.privateMetadataDescription = 'Something about you'
|
||||
error2.privateMetadata = {baz: 'quux'}
|
||||
error2.privateMetadata = { baz: 'quux' }
|
||||
error2.privateMetadataRequestName = 'bar'
|
||||
|
||||
reporter.reportFailedAssertion(error2)
|
||||
@@ -433,10 +485,28 @@ describe("Reporter", () => {
|
||||
|
||||
it('treats packages located in atom.packages.getPackageDirPaths as user packages', () => {
|
||||
mockActivePackages = [
|
||||
{name: 'user-1', path: '/Users/user/.atom/packages/user-1', metadata: {version: '1.0.0'}},
|
||||
{name: 'user-2', path: '/Users/user/.atom/packages/user-2', metadata: {version: '1.2.0'}},
|
||||
{name: 'bundled-1', path: '/Applications/Atom.app/Contents/Resources/app.asar/node_modules/bundled-1', metadata: {version: '1.0.0'}},
|
||||
{name: 'bundled-2', path: '/Applications/Atom.app/Contents/Resources/app.asar/node_modules/bundled-2', metadata: {version: '1.2.0'}},
|
||||
{
|
||||
name: 'user-1',
|
||||
path: '/Users/user/.atom/packages/user-1',
|
||||
metadata: { version: '1.0.0' }
|
||||
},
|
||||
{
|
||||
name: 'user-2',
|
||||
path: '/Users/user/.atom/packages/user-2',
|
||||
metadata: { version: '1.2.0' }
|
||||
},
|
||||
{
|
||||
name: 'bundled-1',
|
||||
path:
|
||||
'/Applications/Atom.app/Contents/Resources/app.asar/node_modules/bundled-1',
|
||||
metadata: { version: '1.0.0' }
|
||||
},
|
||||
{
|
||||
name: 'bundled-2',
|
||||
path:
|
||||
'/Applications/Atom.app/Contents/Resources/app.asar/node_modules/bundled-2',
|
||||
metadata: { version: '1.2.0' }
|
||||
}
|
||||
]
|
||||
|
||||
const packageDirPaths = ['/Users/user/.atom/packages']
|
||||
@@ -473,7 +543,10 @@ describe("Reporter", () => {
|
||||
const body = JSON.parse(lastRequest.body)
|
||||
|
||||
expect(body.events[0].metaData.previousErrors).toEqual(['A', 'B'])
|
||||
expect(body.events[0].metaData.previousAssertionFailures).toEqual(['X', 'Y'])
|
||||
expect(body.events[0].metaData.previousAssertionFailures).toEqual([
|
||||
'X',
|
||||
'Y'
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
const SelectListView = require('atom-select-list')
|
||||
const {repositoryForPath} = require('./helpers')
|
||||
const { repositoryForPath } = require('./helpers')
|
||||
|
||||
module.exports =
|
||||
class DiffListView {
|
||||
module.exports = class DiffListView {
|
||||
constructor () {
|
||||
this.selectListView = new SelectListView({
|
||||
emptyMessage: 'No diffs in file',
|
||||
items: [],
|
||||
filterKeyForItem: (diff) => diff.lineText,
|
||||
elementForItem: (diff) => {
|
||||
filterKeyForItem: diff => diff.lineText,
|
||||
elementForItem: diff => {
|
||||
const li = document.createElement('li')
|
||||
li.classList.add('two-lines')
|
||||
|
||||
@@ -19,15 +18,19 @@ class DiffListView {
|
||||
|
||||
const secondaryLine = document.createElement('div')
|
||||
secondaryLine.classList.add('secondary-line')
|
||||
secondaryLine.textContent = `-${diff.oldStart},${diff.oldLines} +${diff.newStart},${diff.newLines}`
|
||||
secondaryLine.textContent = `-${diff.oldStart},${diff.oldLines} +${
|
||||
diff.newStart
|
||||
},${diff.newLines}`
|
||||
li.appendChild(secondaryLine)
|
||||
|
||||
return li
|
||||
},
|
||||
didConfirmSelection: (diff) => {
|
||||
didConfirmSelection: diff => {
|
||||
this.cancel()
|
||||
const bufferRow = diff.newStart > 0 ? diff.newStart - 1 : diff.newStart
|
||||
this.editor.setCursorBufferPosition([bufferRow, 0], {autoscroll: true})
|
||||
this.editor.setCursorBufferPosition([bufferRow, 0], {
|
||||
autoscroll: true
|
||||
})
|
||||
this.editor.moveToFirstCharacterOfLine()
|
||||
},
|
||||
didCancelSelection: () => {
|
||||
@@ -35,7 +38,10 @@ class DiffListView {
|
||||
}
|
||||
})
|
||||
this.selectListView.element.classList.add('diff-list-view')
|
||||
this.panel = atom.workspace.addModalPanel({item: this.selectListView, visible: false})
|
||||
this.panel = atom.workspace.addModalPanel({
|
||||
item: this.selectListView,
|
||||
visible: false
|
||||
})
|
||||
}
|
||||
|
||||
attach () {
|
||||
@@ -66,7 +72,9 @@ class DiffListView {
|
||||
} else if (editor) {
|
||||
this.editor = editor
|
||||
const repository = repositoryForPath(this.editor.getPath())
|
||||
let diffs = repository ? repository.getLineDiffs(this.editor.getPath(), this.editor.getText()) : []
|
||||
let diffs = repository
|
||||
? repository.getLineDiffs(this.editor.getPath(), this.editor.getText())
|
||||
: []
|
||||
if (!diffs) diffs = []
|
||||
for (let diff of diffs) {
|
||||
const bufferRow = diff.newStart > 0 ? diff.newStart - 1 : diff.newStart
|
||||
@@ -74,7 +82,7 @@ class DiffListView {
|
||||
diff.lineText = lineText ? lineText.trim() : ''
|
||||
}
|
||||
|
||||
await this.selectListView.update({items: diffs})
|
||||
await this.selectListView.update({ items: diffs })
|
||||
this.attach()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
const {CompositeDisposable} = require('atom')
|
||||
const {repositoryForPath} = require('./helpers')
|
||||
const { CompositeDisposable } = require('atom')
|
||||
const { repositoryForPath } = require('./helpers')
|
||||
|
||||
const MAX_BUFFER_LENGTH_TO_DIFF = 2 * 1024 * 1024
|
||||
|
||||
module.exports =
|
||||
class GitDiffView {
|
||||
module.exports = class GitDiffView {
|
||||
constructor (editor) {
|
||||
this.updateDiffs = this.updateDiffs.bind(this)
|
||||
this.editor = editor
|
||||
@@ -22,10 +21,18 @@ class GitDiffView {
|
||||
this.editor.onDidStopChanging(this.updateDiffs),
|
||||
this.editor.onDidChangePath(this.updateDiffs),
|
||||
atom.project.onDidChangePaths(() => this.subscribeToRepository()),
|
||||
atom.commands.add(editorElement, 'git-diff:move-to-next-diff', () => this.moveToNextDiff()),
|
||||
atom.commands.add(editorElement, 'git-diff:move-to-previous-diff', () => this.moveToPreviousDiff()),
|
||||
atom.config.onDidChange('git-diff.showIconsInEditorGutter', () => this.updateIconDecoration()),
|
||||
atom.config.onDidChange('editor.showLineNumbers', () => this.updateIconDecoration()),
|
||||
atom.commands.add(editorElement, 'git-diff:move-to-next-diff', () =>
|
||||
this.moveToNextDiff()
|
||||
),
|
||||
atom.commands.add(editorElement, 'git-diff:move-to-previous-diff', () =>
|
||||
this.moveToPreviousDiff()
|
||||
),
|
||||
atom.config.onDidChange('git-diff.showIconsInEditorGutter', () =>
|
||||
this.updateIconDecoration()
|
||||
),
|
||||
atom.config.onDidChange('editor.showLineNumbers', () =>
|
||||
this.updateIconDecoration()
|
||||
),
|
||||
editorElement.onDidAttach(() => this.updateIconDecoration()),
|
||||
this.editor.onDidDestroy(() => {
|
||||
this.cancelUpdate()
|
||||
@@ -43,7 +50,7 @@ class GitDiffView {
|
||||
let nextDiffLineNumber = null
|
||||
let firstDiffLineNumber = null
|
||||
if (this.diffs) {
|
||||
for (const {newStart} of this.diffs) {
|
||||
for (const { newStart } of this.diffs) {
|
||||
if (newStart > cursorLineNumber) {
|
||||
if (nextDiffLineNumber == null) nextDiffLineNumber = newStart - 1
|
||||
nextDiffLineNumber = Math.min(newStart - 1, nextDiffLineNumber)
|
||||
@@ -55,7 +62,10 @@ class GitDiffView {
|
||||
}
|
||||
|
||||
// Wrap around to the first diff in the file
|
||||
if (atom.config.get('git-diff.wrapAroundOnMoveToDiff') && nextDiffLineNumber == null) {
|
||||
if (
|
||||
atom.config.get('git-diff.wrapAroundOnMoveToDiff') &&
|
||||
nextDiffLineNumber == null
|
||||
) {
|
||||
nextDiffLineNumber = firstDiffLineNumber
|
||||
}
|
||||
|
||||
@@ -65,7 +75,10 @@ class GitDiffView {
|
||||
updateIconDecoration () {
|
||||
const gutter = this.editor.getElement().querySelector('.gutter')
|
||||
if (gutter) {
|
||||
if (atom.config.get('editor.showLineNumbers') && atom.config.get('git-diff.showIconsInEditorGutter')) {
|
||||
if (
|
||||
atom.config.get('editor.showLineNumbers') &&
|
||||
atom.config.get('git-diff.showIconsInEditorGutter')
|
||||
) {
|
||||
gutter.classList.add('git-diff-icon')
|
||||
} else {
|
||||
gutter.classList.remove('git-diff-icon')
|
||||
@@ -78,16 +91,22 @@ class GitDiffView {
|
||||
let previousDiffLineNumber = -1
|
||||
let lastDiffLineNumber = -1
|
||||
if (this.diffs) {
|
||||
for (const {newStart} of this.diffs) {
|
||||
for (const { newStart } of this.diffs) {
|
||||
if (newStart < cursorLineNumber) {
|
||||
previousDiffLineNumber = Math.max(newStart - 1, previousDiffLineNumber)
|
||||
previousDiffLineNumber = Math.max(
|
||||
newStart - 1,
|
||||
previousDiffLineNumber
|
||||
)
|
||||
}
|
||||
lastDiffLineNumber = Math.max(newStart - 1, lastDiffLineNumber)
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap around to the last diff in the file
|
||||
if (atom.config.get('git-diff.wrapAroundOnMoveToDiff') && previousDiffLineNumber === -1) {
|
||||
if (
|
||||
atom.config.get('git-diff.wrapAroundOnMoveToDiff') &&
|
||||
previousDiffLineNumber === -1
|
||||
) {
|
||||
previousDiffLineNumber = lastDiffLineNumber
|
||||
}
|
||||
|
||||
@@ -104,12 +123,16 @@ class GitDiffView {
|
||||
subscribeToRepository () {
|
||||
this.repository = repositoryForPath(this.editor.getPath())
|
||||
if (this.repository) {
|
||||
this.subscriptions.add(this.repository.onDidChangeStatuses(() => {
|
||||
this.scheduleUpdate()
|
||||
}))
|
||||
this.subscriptions.add(this.repository.onDidChangeStatus(changedPath => {
|
||||
if (changedPath === this.editor.getPath()) this.scheduleUpdate()
|
||||
}))
|
||||
this.subscriptions.add(
|
||||
this.repository.onDidChangeStatuses(() => {
|
||||
this.scheduleUpdate()
|
||||
})
|
||||
)
|
||||
this.subscriptions.add(
|
||||
this.repository.onDidChangeStatus(changedPath => {
|
||||
if (changedPath === this.editor.getPath()) this.scheduleUpdate()
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,16 +149,21 @@ class GitDiffView {
|
||||
if (this.editor.isDestroyed()) return
|
||||
this.removeDecorations()
|
||||
const path = this.editor && this.editor.getPath()
|
||||
if (path && this.editor.getBuffer().getLength() < MAX_BUFFER_LENGTH_TO_DIFF) {
|
||||
this.diffs = this.repository && this.repository.getLineDiffs(path, this.editor.getText())
|
||||
if (
|
||||
path &&
|
||||
this.editor.getBuffer().getLength() < MAX_BUFFER_LENGTH_TO_DIFF
|
||||
) {
|
||||
this.diffs =
|
||||
this.repository &&
|
||||
this.repository.getLineDiffs(path, this.editor.getText())
|
||||
if (this.diffs) this.addDecorations(this.diffs)
|
||||
}
|
||||
}
|
||||
|
||||
addDecorations (diffs) {
|
||||
for (const {newStart, oldLines, newLines} of diffs) {
|
||||
for (const { newStart, oldLines, newLines } of diffs) {
|
||||
const startRow = newStart - 1
|
||||
const endRow = (newStart + newLines) - 1
|
||||
const endRow = newStart + newLines - 1
|
||||
if (oldLines === 0 && newLines > 0) {
|
||||
this.markRange(startRow, endRow, 'git-line-added')
|
||||
} else if (newLines === 0 && oldLines > 0) {
|
||||
@@ -156,8 +184,10 @@ class GitDiffView {
|
||||
}
|
||||
|
||||
markRange (startRow, endRow, klass) {
|
||||
const marker = this.editor.markBufferRange([[startRow, 0], [endRow, 0]], {invalidate: 'never'})
|
||||
this.editor.decorateMarker(marker, {type: 'line-number', class: klass})
|
||||
const marker = this.editor.markBufferRange([[startRow, 0], [endRow, 0]], {
|
||||
invalidate: 'never'
|
||||
})
|
||||
this.editor.decorateMarker(marker, { type: 'line-number', class: klass })
|
||||
this.markers.push(marker)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,14 @@ module.exports = {
|
||||
if (watchedEditors.has(editor)) return
|
||||
|
||||
new GitDiffView(editor).start()
|
||||
atom.commands.add(atom.views.getView(editor), 'git-diff:toggle-diff-list', () => {
|
||||
if (diffListView == null) diffListView = new DiffListView()
|
||||
diffListView.toggle()
|
||||
})
|
||||
atom.commands.add(
|
||||
atom.views.getView(editor),
|
||||
'git-diff:toggle-diff-list',
|
||||
() => {
|
||||
if (diffListView == null) diffListView = new DiffListView()
|
||||
diffListView.toggle()
|
||||
}
|
||||
)
|
||||
|
||||
watchedEditors.add(editor)
|
||||
editor.onDidDestroy(() => watchedEditors.delete(editor))
|
||||
|
||||
@@ -8,7 +8,10 @@ describe('git-diff:toggle-diff-list', () => {
|
||||
beforeEach(() => {
|
||||
const projectPath = temp.mkdirSync('git-diff-spec-')
|
||||
fs.copySync(path.join(__dirname, 'fixtures', 'working-dir'), projectPath)
|
||||
fs.moveSync(path.join(projectPath, 'git.git'), path.join(projectPath, '.git'))
|
||||
fs.moveSync(
|
||||
path.join(projectPath, 'git.git'),
|
||||
path.join(projectPath, '.git')
|
||||
)
|
||||
atom.project.setPaths([projectPath])
|
||||
|
||||
jasmine.attachToDOM(atom.workspace.getElement())
|
||||
@@ -19,7 +22,7 @@ describe('git-diff:toggle-diff-list', () => {
|
||||
|
||||
runs(() => {
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
editor.setCursorBufferPosition([4, 29])
|
||||
editor.setCursorBufferPosition([8, 30])
|
||||
editor.insertText('a')
|
||||
atom.commands.dispatch(editor.getElement(), 'git-diff:toggle-diff-list')
|
||||
})
|
||||
@@ -32,12 +35,15 @@ describe('git-diff:toggle-diff-list', () => {
|
||||
|
||||
it('shows a list of all diff hunks', () => {
|
||||
diffListView = document.querySelector('.diff-list-view ol')
|
||||
expect(diffListView.textContent).toBe('while(items.length > 0) {a-5,1 +5,1')
|
||||
expect(diffListView.textContent).toBe('while (items.length > 0) {a-9,1 +9,1')
|
||||
})
|
||||
|
||||
it('moves the cursor to the selected hunk', () => {
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
atom.commands.dispatch(document.querySelector('.diff-list-view'), 'core:confirm')
|
||||
expect(editor.getCursorBufferPosition()).toEqual([4, 4])
|
||||
atom.commands.dispatch(
|
||||
document.querySelector('.diff-list-view'),
|
||||
'core:confirm'
|
||||
)
|
||||
expect(editor.getCursorBufferPosition()).toEqual([8, 4])
|
||||
})
|
||||
})
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
90820108a054b6f49c0d21031313244b6f7d69dc
|
||||
065a272b55ec2ee84530dffd60b6869f7bf5d99c
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
var quicksort = function () {
|
||||
var sort = function(items) {
|
||||
if (items.length <= 1) return items;
|
||||
var pivot = items.shift(), current, left = [], right = [];
|
||||
while(items.length > 0) {
|
||||
current = items.shift();
|
||||
current < pivot ? left.push(current) : right.push(current);
|
||||
}
|
||||
return sort(left).concat(pivot).concat(sort(right));
|
||||
};
|
||||
module.exports.quicksort = function () {
|
||||
var sort = function (items) {
|
||||
if (items.length <= 1) return items
|
||||
var pivot = items.shift()
|
||||
var current
|
||||
var left = []
|
||||
var right = []
|
||||
|
||||
return sort(Array.apply(this, arguments));
|
||||
};
|
||||
while (items.length > 0) {
|
||||
current = items.shift()
|
||||
current < pivot ? left.push(current) : right.push(current)
|
||||
}
|
||||
return sort(left)
|
||||
.concat(pivot)
|
||||
.concat(sort(right))
|
||||
}
|
||||
|
||||
return sort(Array.apply(this, arguments))
|
||||
}
|
||||
|
||||
@@ -12,12 +12,17 @@ describe('GitDiff package', () => {
|
||||
const otherPath = temp.mkdirSync('some-other-path-')
|
||||
|
||||
fs.copySync(path.join(__dirname, 'fixtures', 'working-dir'), projectPath)
|
||||
fs.moveSync(path.join(projectPath, 'git.git'), path.join(projectPath, '.git'))
|
||||
fs.moveSync(
|
||||
path.join(projectPath, 'git.git'),
|
||||
path.join(projectPath, '.git')
|
||||
)
|
||||
atom.project.setPaths([otherPath, projectPath])
|
||||
|
||||
jasmine.attachToDOM(atom.workspace.getElement())
|
||||
|
||||
waitsForPromise(() => atom.workspace.open(path.join(projectPath, 'sample.js')))
|
||||
waitsForPromise(() =>
|
||||
atom.workspace.open(path.join(projectPath, 'sample.js'))
|
||||
)
|
||||
|
||||
runs(() => {
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
@@ -29,11 +34,18 @@ describe('GitDiff package', () => {
|
||||
|
||||
describe('when the editor has modified lines', () => {
|
||||
it('highlights the modified lines', () => {
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(0)
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(
|
||||
0
|
||||
)
|
||||
editor.insertText('a')
|
||||
advanceClock(editor.getBuffer().stoppedChangingDelay)
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(1)
|
||||
expect(editorElement.querySelector('.git-line-modified')).toHaveData('buffer-row', 0)
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(
|
||||
1
|
||||
)
|
||||
expect(editorElement.querySelector('.git-line-modified')).toHaveData(
|
||||
'buffer-row',
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -45,7 +57,10 @@ describe('GitDiff package', () => {
|
||||
editor.insertText('a')
|
||||
advanceClock(editor.getBuffer().stoppedChangingDelay)
|
||||
expect(editorElement.querySelectorAll('.git-line-added').length).toBe(1)
|
||||
expect(editorElement.querySelector('.git-line-added')).toHaveData('buffer-row', 1)
|
||||
expect(editorElement.querySelector('.git-line-added')).toHaveData(
|
||||
'buffer-row',
|
||||
1
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -56,7 +71,10 @@ describe('GitDiff package', () => {
|
||||
editor.deleteLine()
|
||||
advanceClock(editor.getBuffer().stoppedChangingDelay)
|
||||
expect(editorElement.querySelectorAll('.git-line-removed').length).toBe(1)
|
||||
expect(editorElement.querySelector('.git-line-removed')).toHaveData('buffer-row', 4)
|
||||
expect(editorElement.querySelector('.git-line-removed')).toHaveData(
|
||||
'buffer-row',
|
||||
4
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -66,29 +84,44 @@ describe('GitDiff package', () => {
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
editor.deleteLine()
|
||||
advanceClock(editor.getBuffer().stoppedChangingDelay)
|
||||
expect(editorElement.querySelectorAll('.git-previous-line-removed').length).toBe(1)
|
||||
expect(editorElement.querySelector('.git-previous-line-removed')).toHaveData('buffer-row', 0)
|
||||
expect(
|
||||
editorElement.querySelectorAll('.git-previous-line-removed').length
|
||||
).toBe(1)
|
||||
expect(
|
||||
editorElement.querySelector('.git-previous-line-removed')
|
||||
).toHaveData('buffer-row', 0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when a modified line is restored to the HEAD version contents', () => {
|
||||
it('removes the diff highlight', () => {
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(0)
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(
|
||||
0
|
||||
)
|
||||
editor.insertText('a')
|
||||
advanceClock(editor.getBuffer().stoppedChangingDelay)
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(1)
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(
|
||||
1
|
||||
)
|
||||
editor.backspace()
|
||||
advanceClock(editor.getBuffer().stoppedChangingDelay)
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(0)
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when a modified file is opened', () => {
|
||||
it('highlights the changed lines', () => {
|
||||
fs.writeFileSync(path.join(projectPath, 'sample.txt'), 'Some different text.')
|
||||
fs.writeFileSync(
|
||||
path.join(projectPath, 'sample.txt'),
|
||||
'Some different text.'
|
||||
)
|
||||
let nextTick = false
|
||||
|
||||
waitsForPromise(() => atom.workspace.open(path.join(projectPath, 'sample.txt')))
|
||||
waitsForPromise(() =>
|
||||
atom.workspace.open(path.join(projectPath, 'sample.txt'))
|
||||
)
|
||||
|
||||
runs(() => {
|
||||
editorElement = atom.workspace.getActiveTextEditor().getElement()
|
||||
@@ -101,8 +134,13 @@ describe('GitDiff package', () => {
|
||||
waitsFor(() => nextTick)
|
||||
|
||||
runs(() => {
|
||||
expect(editorElement.querySelectorAll('.git-line-modified').length).toBe(1)
|
||||
expect(editorElement.querySelector('.git-line-modified')).toHaveData('buffer-row', 0)
|
||||
expect(
|
||||
editorElement.querySelectorAll('.git-line-modified').length
|
||||
).toBe(1)
|
||||
expect(editorElement.querySelector('.git-line-modified')).toHaveData(
|
||||
'buffer-row',
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -148,7 +186,9 @@ describe('GitDiff package', () => {
|
||||
})
|
||||
|
||||
describe('when the wrapAroundOnMoveToDiff config option is false', () => {
|
||||
beforeEach(() => atom.config.set('git-diff.wrapAroundOnMoveToDiff', false))
|
||||
beforeEach(() =>
|
||||
atom.config.set('git-diff.wrapAroundOnMoveToDiff', false)
|
||||
)
|
||||
|
||||
it('does not wraps around to the first/last diff in the file', () => {
|
||||
editor.insertText('a')
|
||||
@@ -177,19 +217,28 @@ describe('GitDiff package', () => {
|
||||
atom.config.set('git-diff.showIconsInEditorGutter', true)
|
||||
})
|
||||
|
||||
it('the gutter has a git-diff-icon class', () => expect(editorElement.querySelector('.gutter')).toHaveClass('git-diff-icon'))
|
||||
it('the gutter has a git-diff-icon class', () =>
|
||||
expect(editorElement.querySelector('.gutter')).toHaveClass(
|
||||
'git-diff-icon'
|
||||
))
|
||||
|
||||
it('keeps the git-diff-icon class when editor.showLineNumbers is toggled', () => {
|
||||
atom.config.set('editor.showLineNumbers', false)
|
||||
expect(editorElement.querySelector('.gutter')).not.toHaveClass('git-diff-icon')
|
||||
expect(editorElement.querySelector('.gutter')).not.toHaveClass(
|
||||
'git-diff-icon'
|
||||
)
|
||||
|
||||
atom.config.set('editor.showLineNumbers', true)
|
||||
expect(editorElement.querySelector('.gutter')).toHaveClass('git-diff-icon')
|
||||
expect(editorElement.querySelector('.gutter')).toHaveClass(
|
||||
'git-diff-icon'
|
||||
)
|
||||
})
|
||||
|
||||
it('removes the git-diff-icon class when the showIconsInEditorGutter config option set to false', () => {
|
||||
atom.config.set('git-diff.showIconsInEditorGutter', false)
|
||||
expect(editorElement.querySelector('.gutter')).not.toHaveClass('git-diff-icon')
|
||||
expect(editorElement.querySelector('.gutter')).not.toHaveClass(
|
||||
'git-diff-icon'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -21,7 +21,7 @@ atom-text-editor {
|
||||
left: 0;
|
||||
height: 0;
|
||||
width: 0;
|
||||
content: " ";
|
||||
content: "";
|
||||
border: solid transparent;
|
||||
border-left-color: @syntax-color-removed;
|
||||
border-width: @size;
|
||||
@@ -37,22 +37,19 @@ atom-text-editor {
|
||||
}
|
||||
|
||||
.gutter.git-diff-icon .line-number {
|
||||
width: 100%;
|
||||
border-left: none;
|
||||
padding-left: 0.4em;
|
||||
border-left-width: 0;
|
||||
padding-left: 1.4em; // space for diff icon
|
||||
|
||||
&:before {
|
||||
.octicon-font();
|
||||
.octicon-font();
|
||||
content: "";
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: -.05em;
|
||||
|
||||
// make sure it doesnt affect the gutter line height.
|
||||
height: 0px;
|
||||
position: absolute;
|
||||
top: .2em;
|
||||
left: .4em;
|
||||
height: 0px; // make sure it doesnt affect the gutter line height.
|
||||
width: 1em;
|
||||
content: " ";
|
||||
padding-right: 0.4em;
|
||||
font-size: .95em;
|
||||
font-size: .75em;
|
||||
}
|
||||
|
||||
&.git-line-modified:before {
|
||||
@@ -70,13 +67,12 @@ atom-text-editor {
|
||||
border: none; // reset triangle
|
||||
content: @dash;
|
||||
color: @syntax-color-removed;
|
||||
position: relative;
|
||||
}
|
||||
&.git-line-removed:before {
|
||||
top: .6em;
|
||||
top: 1em;
|
||||
}
|
||||
&.git-previous-line-removed:before {
|
||||
top: -.6em;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ class GoToLineView {
|
||||
atom.commands.add(this.miniEditor.element, 'core:cancel', () => {
|
||||
this.close()
|
||||
})
|
||||
this.miniEditor.onWillInsertText((arg) => {
|
||||
this.miniEditor.onWillInsertText(arg => {
|
||||
if (arg.text.match(/[^0-9:]/)) {
|
||||
arg.cancel()
|
||||
}
|
||||
})
|
||||
this.miniEditor.onDidChange(() => {
|
||||
this.navigate({keepOpen: true})
|
||||
this.navigate({ keepOpen: true })
|
||||
})
|
||||
}
|
||||
|
||||
@@ -62,9 +62,11 @@ class GoToLineView {
|
||||
|
||||
const currentRow = editor.getCursorBufferPosition().row
|
||||
const rowLineNumber = lineNumber.split(/:+/)[0] || ''
|
||||
const row = rowLineNumber.length > 0 ? parseInt(rowLineNumber) - 1 : currentRow
|
||||
const row =
|
||||
rowLineNumber.length > 0 ? parseInt(rowLineNumber) - 1 : currentRow
|
||||
const columnLineNumber = lineNumber.split(/:+/)[1] || ''
|
||||
const column = columnLineNumber.length > 0 ? parseInt(columnLineNumber) - 1 : -1
|
||||
const column =
|
||||
columnLineNumber.length > 0 ? parseInt(columnLineNumber) - 1 : -1
|
||||
|
||||
const position = new Point(row, column)
|
||||
editor.setCursorBufferPosition(position)
|
||||
@@ -83,7 +85,10 @@ class GoToLineView {
|
||||
}
|
||||
|
||||
restoreFocus () {
|
||||
if (this.previouslyFocusedElement && this.previouslyFocusedElement.parentElement) {
|
||||
if (
|
||||
this.previouslyFocusedElement &&
|
||||
this.previouslyFocusedElement.parentElement
|
||||
) {
|
||||
return this.previouslyFocusedElement.focus()
|
||||
}
|
||||
atom.views.getView(atom.workspace).focus()
|
||||
@@ -93,7 +98,8 @@ class GoToLineView {
|
||||
if (this.panel.isVisible() || !atom.workspace.getActiveTextEditor()) return
|
||||
this.storeFocusedElement()
|
||||
this.panel.show()
|
||||
this.message.textContent = 'Enter a <row> or <row>:<column> to go there. Examples: "3" for row 3 or "2:7" for row 2 and column 7'
|
||||
this.message.textContent =
|
||||
'Enter a <row> or <row>:<column> to go there. Examples: "3" for row 3 or "2:7" for row 2 and column 7'
|
||||
this.miniEditor.element.focus()
|
||||
}
|
||||
}
|
||||
|
||||
108
packages/go-to-line/spec/fixtures/sample.js
vendored
108
packages/go-to-line/spec/fixtures/sample.js
vendored
@@ -1,70 +1,84 @@
|
||||
var quicksort = function () {
|
||||
var sort = function(items) {
|
||||
if (items.length <= 1) return items;
|
||||
var pivot = items.shift(), current, left = [], right = [];
|
||||
while(items.length > 0) {
|
||||
current = items.shift();
|
||||
current < pivot ? left.push(current) : right.push(current);
|
||||
}
|
||||
return sort(left).concat(pivot).concat(sort(right));
|
||||
};
|
||||
var sort = function (items) {
|
||||
if (items.length <= 1) return items
|
||||
var pivot = items.shift()
|
||||
var current
|
||||
var left = []
|
||||
var right = []
|
||||
|
||||
return sort(Array.apply(this, arguments));
|
||||
};
|
||||
while (items.length > 0) {
|
||||
current = items.shift()
|
||||
current < pivot ? left.push(current) : right.push(current)
|
||||
}
|
||||
return sort(left)
|
||||
.concat(pivot)
|
||||
.concat(sort(right))
|
||||
}
|
||||
|
||||
return sort(Array.apply(this, arguments))
|
||||
}
|
||||
|
||||
// adapted from:
|
||||
// https://github.com/nzakas/computer-science-in-javascript/tree/master/algorithms/sorting/merge-sort-recursive
|
||||
var mergeSort function (items){
|
||||
var merge = function (left, right){
|
||||
var result = [];
|
||||
var il = 0;
|
||||
var ir = 0;
|
||||
var mergeSort = function (items) {
|
||||
var merge = function (left, right) {
|
||||
var result = []
|
||||
var il = 0
|
||||
var ir = 0
|
||||
|
||||
while (il < left.length && ir < right.length){
|
||||
if (left[il] < right[ir]){
|
||||
result.push(left[il++]);
|
||||
while (il < left.length && ir < right.length) {
|
||||
if (left[il] < right[ir]) {
|
||||
result.push(left[il++])
|
||||
} else {
|
||||
result.push(right[ir++]);
|
||||
result.push(right[ir++])
|
||||
}
|
||||
}
|
||||
|
||||
return result.concat(left.slice(il)).concat(right.slice(ir));
|
||||
};
|
||||
|
||||
if (items.length < 2) {
|
||||
return items;
|
||||
return result.concat(left.slice(il)).concat(right.slice(ir))
|
||||
}
|
||||
|
||||
var middle = Math.floor(items.length / 2),
|
||||
left = items.slice(0, middle),
|
||||
right = items.slice(middle),
|
||||
params = merge(mergeSort(left), mergeSort(right));
|
||||
if (items.length < 2) {
|
||||
return items
|
||||
}
|
||||
|
||||
var middle = Math.floor(items.length / 2)
|
||||
var left = items.slice(0, middle)
|
||||
var right = items.slice(middle)
|
||||
var params = merge(mergeSort(left), mergeSort(right))
|
||||
|
||||
// Add the arguments to replace everything between 0 and last item in the array
|
||||
params.unshift(0, items.length);
|
||||
items.splice.apply(items, params);
|
||||
return items;
|
||||
};
|
||||
params.unshift(0, items.length)
|
||||
items.splice.apply(items, params)
|
||||
return items
|
||||
}
|
||||
|
||||
// adapted from:
|
||||
// https://github.com/nzakas/computer-science-in-javascript/blob/master/algorithms/sorting/bubble-sort/bubble-sort.js
|
||||
var bubbleSort = function (items){
|
||||
var swap = function (items, firstIndex, secondIndex){
|
||||
var temp = items[firstIndex];
|
||||
items[firstIndex] = items[secondIndex];
|
||||
items[secondIndex] = temp;
|
||||
};
|
||||
var bubbleSort = function (items) {
|
||||
var swap = function (items, firstIndex, secondIndex) {
|
||||
var temp = items[firstIndex]
|
||||
items[firstIndex] = items[secondIndex]
|
||||
items[secondIndex] = temp
|
||||
}
|
||||
|
||||
var len = items.length,
|
||||
i, j, stop;
|
||||
var len = items.length
|
||||
var i
|
||||
var j
|
||||
var stop
|
||||
|
||||
for (i=0; i < len; i++){
|
||||
for (j=0, stop=len-i; j < stop; j++){
|
||||
if (items[j] > items[j+1]){
|
||||
swap(items, j, j+1);
|
||||
for (i = 0; i < len; i++) {
|
||||
for (j = 0, stop = len - i; j < stop; j++) {
|
||||
if (items[j] > items[j + 1]) {
|
||||
swap(items, j, j + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
};
|
||||
return items
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
bubbleSort,
|
||||
mergeSort,
|
||||
quicksort
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ describe('GoToLine', () => {
|
||||
|
||||
describe('when typing line numbers (auto-navigation)', () => {
|
||||
it('automatically scrolls to the desired line', () => {
|
||||
goToLine.miniEditor.insertText('13')
|
||||
expect(editor.getCursorBufferPosition()).toEqual([12, 0])
|
||||
goToLine.miniEditor.insertText('19')
|
||||
expect(editor.getCursorBufferPosition()).toEqual([18, 0])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -76,8 +76,12 @@ describe('GoToLine', () => {
|
||||
atom.commands.dispatch(goToLine.miniEditor.element, 'core:confirm')
|
||||
const rowsPerPage = editor.getRowsPerPage()
|
||||
const currentRow = editor.getCursorBufferPosition().row - 1
|
||||
expect(editor.getFirstVisibleScreenRow()).toBe(currentRow - Math.ceil(rowsPerPage / 2))
|
||||
expect(editor.getLastVisibleScreenRow()).toBe(currentRow + Math.floor(rowsPerPage / 2))
|
||||
expect(editor.getFirstVisibleScreenRow()).toBe(
|
||||
currentRow - Math.ceil(rowsPerPage / 2)
|
||||
)
|
||||
expect(editor.getLastVisibleScreenRow()).toBe(
|
||||
currentRow + Math.floor(rowsPerPage / 2)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -86,10 +90,10 @@ describe('GoToLine', () => {
|
||||
atom.commands.dispatch(editorView, 'go-to-line:toggle')
|
||||
expect(goToLine.panel.isVisible()).toBeTruthy()
|
||||
expect(goToLine.miniEditor.getText()).toBe('')
|
||||
goToLine.miniEditor.insertText('71')
|
||||
goToLine.miniEditor.insertText('78')
|
||||
atom.commands.dispatch(goToLine.miniEditor.element, 'core:confirm')
|
||||
expect(goToLine.panel.isVisible()).toBeFalsy()
|
||||
expect(editor.getCursorBufferPosition()).toEqual([70, 0])
|
||||
expect(editor.getCursorBufferPosition()).toEqual([77, 0])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -101,7 +105,7 @@ describe('GoToLine', () => {
|
||||
goToLine.miniEditor.insertText('3:43')
|
||||
atom.commands.dispatch(goToLine.miniEditor.element, 'core:confirm')
|
||||
expect(goToLine.panel.isVisible()).toBeFalsy()
|
||||
expect(editor.getCursorBufferPosition()).toEqual([2, 40])
|
||||
expect(editor.getCursorBufferPosition()).toEqual([2, 39])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -116,12 +120,12 @@ describe('GoToLine', () => {
|
||||
|
||||
describe('when the line number entered is nested within foldes', () => {
|
||||
it('unfolds all folds containing the given row', () => {
|
||||
expect(editor.indentationForBufferRow(6)).toEqual(3)
|
||||
expect(editor.indentationForBufferRow(9)).toEqual(3)
|
||||
editor.foldAll()
|
||||
expect(editor.screenRowForBufferRow(6)).toEqual(0)
|
||||
goToLine.miniEditor.insertText('7')
|
||||
expect(editor.screenRowForBufferRow(9)).toEqual(0)
|
||||
goToLine.miniEditor.insertText('10')
|
||||
atom.commands.dispatch(goToLine.miniEditor.element, 'core:confirm')
|
||||
expect(editor.getCursorBufferPosition()).toEqual([6, 6])
|
||||
expect(editor.getCursorBufferPosition()).toEqual([9, 6])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
const SelectListView = require('atom-select-list')
|
||||
|
||||
module.exports =
|
||||
class GrammarListView {
|
||||
module.exports = class GrammarListView {
|
||||
constructor () {
|
||||
this.autoDetect = {name: 'Auto Detect'}
|
||||
this.autoDetect = { name: 'Auto Detect' }
|
||||
this.selectListView = new SelectListView({
|
||||
itemsClassList: ['mark-active'],
|
||||
items: [],
|
||||
filterKeyForItem: (grammar) => grammar.name,
|
||||
elementForItem: (grammar) => {
|
||||
filterKeyForItem: grammar => grammar.name,
|
||||
elementForItem: grammar => {
|
||||
const grammarName = grammar.name || grammar.scopeName
|
||||
const element = document.createElement('li')
|
||||
if (grammar === this.currentGrammar) {
|
||||
@@ -29,7 +28,7 @@ class GrammarListView {
|
||||
|
||||
return element
|
||||
},
|
||||
didConfirmSelection: (grammar) => {
|
||||
didConfirmSelection: grammar => {
|
||||
this.cancel()
|
||||
if (grammar === this.autoDetect) {
|
||||
atom.textEditors.clearGrammarOverride(this.editor)
|
||||
@@ -64,7 +63,7 @@ class GrammarListView {
|
||||
attach () {
|
||||
this.previouslyFocusedElement = document.activeElement
|
||||
if (this.panel == null) {
|
||||
this.panel = atom.workspace.addModalPanel({item: this.selectListView})
|
||||
this.panel = atom.workspace.addModalPanel({ item: this.selectListView })
|
||||
}
|
||||
this.selectListView.focus()
|
||||
this.selectListView.reset()
|
||||
@@ -80,7 +79,7 @@ class GrammarListView {
|
||||
this.currentGrammar = this.autoDetect
|
||||
}
|
||||
|
||||
const grammars = atom.grammars.getGrammars().filter((grammar) => {
|
||||
const grammars = atom.grammars.getGrammars().filter(grammar => {
|
||||
return grammar !== atom.grammars.nullGrammar && grammar.name
|
||||
})
|
||||
grammars.sort((a, b) => {
|
||||
@@ -97,7 +96,7 @@ class GrammarListView {
|
||||
}
|
||||
})
|
||||
grammars.unshift(this.autoDetect)
|
||||
await this.selectListView.update({items: grammars})
|
||||
await this.selectListView.update({ items: grammars })
|
||||
this.attach()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const {Disposable} = require('atom')
|
||||
const { Disposable } = require('atom')
|
||||
|
||||
module.exports =
|
||||
class GrammarStatusView {
|
||||
module.exports = class GrammarStatusView {
|
||||
constructor (statusBar) {
|
||||
this.statusBar = statusBar
|
||||
this.element = document.createElement('grammar-selector-status')
|
||||
@@ -10,15 +9,25 @@ class GrammarStatusView {
|
||||
this.grammarLink.classList.add('inline-block')
|
||||
this.element.appendChild(this.grammarLink)
|
||||
|
||||
this.activeItemSubscription = atom.workspace.observeActiveTextEditor(this.subscribeToActiveTextEditor.bind(this))
|
||||
this.activeItemSubscription = atom.workspace.observeActiveTextEditor(
|
||||
this.subscribeToActiveTextEditor.bind(this)
|
||||
)
|
||||
|
||||
this.configSubscription = atom.config.observe('grammar-selector.showOnRightSideOfStatusBar', this.attach.bind(this))
|
||||
const clickHandler = (event) => {
|
||||
this.configSubscription = atom.config.observe(
|
||||
'grammar-selector.showOnRightSideOfStatusBar',
|
||||
this.attach.bind(this)
|
||||
)
|
||||
const clickHandler = event => {
|
||||
event.preventDefault()
|
||||
atom.commands.dispatch(atom.views.getView(atom.workspace.getActiveTextEditor()), 'grammar-selector:show')
|
||||
atom.commands.dispatch(
|
||||
atom.views.getView(atom.workspace.getActiveTextEditor()),
|
||||
'grammar-selector:show'
|
||||
)
|
||||
}
|
||||
this.element.addEventListener('click', clickHandler)
|
||||
this.clickSubscription = new Disposable(() => { this.element.removeEventListener('click', clickHandler) })
|
||||
this.clickSubscription = new Disposable(() => {
|
||||
this.element.removeEventListener('click', clickHandler)
|
||||
})
|
||||
}
|
||||
|
||||
attach () {
|
||||
@@ -27,8 +36,8 @@ class GrammarStatusView {
|
||||
}
|
||||
|
||||
this.tile = atom.config.get('grammar-selector.showOnRightSideOfStatusBar')
|
||||
? this.statusBar.addRightTile({item: this.element, priority: 10})
|
||||
: this.statusBar.addLeftTile({item: this.element, priority: 10})
|
||||
? this.statusBar.addRightTile({ item: this.element, priority: 10 })
|
||||
: this.statusBar.addLeftTile({ item: this.element, priority: 10 })
|
||||
}
|
||||
|
||||
destroy () {
|
||||
@@ -65,7 +74,9 @@ class GrammarStatusView {
|
||||
|
||||
const editor = atom.workspace.getActiveTextEditor()
|
||||
if (editor) {
|
||||
this.grammarSubscription = editor.onDidChangeGrammar(this.updateGrammarText.bind(this))
|
||||
this.grammarSubscription = editor.onDidChangeGrammar(
|
||||
this.updateGrammarText.bind(this)
|
||||
)
|
||||
}
|
||||
this.updateGrammarText()
|
||||
}
|
||||
@@ -92,7 +103,9 @@ class GrammarStatusView {
|
||||
this.grammarLink.dataset.grammar = grammarName
|
||||
this.element.style.display = ''
|
||||
|
||||
this.tooltip = atom.tooltips.add(this.element, {title: `File uses the ${grammarName} grammar`})
|
||||
this.tooltip = atom.tooltips.add(this.element, {
|
||||
title: `File uses the ${grammarName} grammar`
|
||||
})
|
||||
} else {
|
||||
this.element.style.display = 'none'
|
||||
}
|
||||
|
||||
@@ -7,10 +7,14 @@ let grammarStatusView = null
|
||||
|
||||
module.exports = {
|
||||
activate () {
|
||||
commandDisposable = atom.commands.add('atom-text-editor', 'grammar-selector:show', () => {
|
||||
if (!grammarListView) grammarListView = new GrammarListView()
|
||||
grammarListView.toggle()
|
||||
})
|
||||
commandDisposable = atom.commands.add(
|
||||
'atom-text-editor',
|
||||
'grammar-selector:show',
|
||||
() => {
|
||||
if (!grammarListView) grammarListView = new GrammarListView()
|
||||
grammarListView.toggle()
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
deactivate () {
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
exports.beforeEach = function beforeEach (fn) {
|
||||
global.beforeEach(function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise('beforeEach promise', result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
exports.afterEach = function afterEach (fn) {
|
||||
global.afterEach(function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise('afterEach promise', result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
;['it', 'fit', 'ffit', 'fffit'].forEach(function (name) {
|
||||
exports[name] = function (description, fn) {
|
||||
if (fn === undefined) {
|
||||
global[name](description)
|
||||
return
|
||||
}
|
||||
|
||||
global[name](description, function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise('test promise', result)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
function waitsForPromise (message, promise) {
|
||||
global.waitsFor(message, (done) => {
|
||||
promise.then(done, (error) => {
|
||||
jasmine.getEnv().currentSpec.fail(error)
|
||||
done()
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
const path = require('path')
|
||||
const SelectListView = require('atom-select-list')
|
||||
const {it, fit, ffit, beforeEach, afterEach} = require('./async-spec-helpers') // eslint-disable-line
|
||||
|
||||
describe('GrammarSelector', () => {
|
||||
let [editor, textGrammar, jsGrammar] = []
|
||||
@@ -13,7 +12,9 @@ describe('GrammarSelector', () => {
|
||||
await atom.packages.activatePackage('grammar-selector')
|
||||
await atom.packages.activatePackage('language-text')
|
||||
await atom.packages.activatePackage('language-javascript')
|
||||
await atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-with-no-name'))
|
||||
await atom.packages.activatePackage(
|
||||
path.join(__dirname, 'fixtures', 'language-with-no-name')
|
||||
)
|
||||
|
||||
editor = await atom.workspace.open('sample.js')
|
||||
|
||||
@@ -33,15 +34,24 @@ describe('GrammarSelector', () => {
|
||||
// TODO: Remove once Atom 1.23 reaches stable
|
||||
if (parseFloat(atom.getVersion()) >= 1.23) {
|
||||
// Do not take into account the two JS regex grammars or language-with-no-name
|
||||
expect(grammarView.querySelectorAll('li').length).toBe(atom.grammars.grammars.length - 3)
|
||||
expect(grammarView.querySelectorAll('li').length).toBe(
|
||||
atom.grammars.grammars.length - 3
|
||||
)
|
||||
} else {
|
||||
expect(grammarView.querySelectorAll('li').length).toBe(atom.grammars.grammars.length - 1)
|
||||
expect(grammarView.querySelectorAll('li').length).toBe(
|
||||
atom.grammars.grammars.length - 1
|
||||
)
|
||||
}
|
||||
expect(grammarView.querySelectorAll('li')[0].textContent).toBe('Auto Detect')
|
||||
expect(grammarView.querySelectorAll('li')[0].textContent).toBe(
|
||||
'Auto Detect'
|
||||
)
|
||||
expect(grammarView.textContent.includes('source.a')).toBe(false)
|
||||
grammarView.querySelectorAll('li').forEach(li => expect(li.textContent).not.toBe(atom.grammars.nullGrammar.name))
|
||||
})
|
||||
)
|
||||
grammarView
|
||||
.querySelectorAll('li')
|
||||
.forEach(li =>
|
||||
expect(li.textContent).not.toBe(atom.grammars.nullGrammar.name)
|
||||
)
|
||||
}))
|
||||
|
||||
describe('when a grammar is selected', () =>
|
||||
it('sets the new grammar on the editor', async () => {
|
||||
@@ -51,8 +61,7 @@ describe('GrammarSelector', () => {
|
||||
const grammarView = atom.workspace.getModalPanels()[0].getItem()
|
||||
grammarView.props.didConfirmSelection(textGrammar)
|
||||
expect(editor.getGrammar()).toBe(textGrammar)
|
||||
})
|
||||
)
|
||||
}))
|
||||
|
||||
describe('when auto-detect is selected', () =>
|
||||
it('restores the auto-detected grammar on the editor', async () => {
|
||||
@@ -69,8 +78,7 @@ describe('GrammarSelector', () => {
|
||||
grammarView = atom.workspace.getModalPanels()[0].getItem()
|
||||
grammarView.props.didConfirmSelection(grammarView.items[0])
|
||||
expect(editor.getGrammar()).toBe(jsGrammar)
|
||||
})
|
||||
)
|
||||
}))
|
||||
|
||||
describe("when the editor's current grammar is the null grammar", () =>
|
||||
it('displays Auto Detect as the selected grammar', async () => {
|
||||
@@ -79,9 +87,10 @@ describe('GrammarSelector', () => {
|
||||
await SelectListView.getScheduler().getNextUpdatePromise()
|
||||
|
||||
const grammarView = atom.workspace.getModalPanels()[0].getItem().element
|
||||
expect(grammarView.querySelector('li.active').textContent).toBe('Auto Detect')
|
||||
})
|
||||
)
|
||||
expect(grammarView.querySelector('li.active').textContent).toBe(
|
||||
'Auto Detect'
|
||||
)
|
||||
}))
|
||||
|
||||
describe('when editor is untitled', () =>
|
||||
it('sets the new grammar on the editor', async () => {
|
||||
@@ -94,8 +103,7 @@ describe('GrammarSelector', () => {
|
||||
const grammarView = atom.workspace.getModalPanels()[0].getItem()
|
||||
grammarView.props.didConfirmSelection(jsGrammar)
|
||||
expect(editor.getGrammar()).toBe(jsGrammar)
|
||||
})
|
||||
)
|
||||
}))
|
||||
|
||||
describe('Status bar grammar label', () => {
|
||||
let [grammarStatus, grammarTile, statusBar] = []
|
||||
@@ -114,7 +122,9 @@ describe('GrammarSelector', () => {
|
||||
|
||||
it('displays the name of the current grammar', () => {
|
||||
expect(grammarStatus.querySelector('a').textContent).toBe('JavaScript')
|
||||
expect(getTooltipText(grammarStatus)).toBe('File uses the JavaScript grammar')
|
||||
expect(getTooltipText(grammarStatus)).toBe(
|
||||
'File uses the JavaScript grammar'
|
||||
)
|
||||
})
|
||||
|
||||
it('displays Plain Text when the current grammar is the null grammar', async () => {
|
||||
@@ -123,7 +133,9 @@ describe('GrammarSelector', () => {
|
||||
|
||||
expect(grammarStatus.querySelector('a').textContent).toBe('Plain Text')
|
||||
expect(grammarStatus).toBeVisible()
|
||||
expect(getTooltipText(grammarStatus)).toBe('File uses the Plain Text grammar')
|
||||
expect(getTooltipText(grammarStatus)).toBe(
|
||||
'File uses the Plain Text grammar'
|
||||
)
|
||||
|
||||
editor.setGrammar(atom.grammars.grammarForScopeName('source.js'))
|
||||
await atom.views.getNextUpdatePromise()
|
||||
@@ -142,20 +154,31 @@ describe('GrammarSelector', () => {
|
||||
|
||||
describe('when the grammar-selector.showOnRightSideOfStatusBar setting changes', () =>
|
||||
it('moves the item to the preferred side of the status bar', () => {
|
||||
expect(statusBar.getLeftTiles().map(tile => tile.getItem())).toContain(grammarStatus)
|
||||
expect(statusBar.getRightTiles().map(tile => tile.getItem())).not.toContain(grammarStatus)
|
||||
expect(statusBar.getLeftTiles().map(tile => tile.getItem())).toContain(
|
||||
grammarStatus
|
||||
)
|
||||
expect(
|
||||
statusBar.getRightTiles().map(tile => tile.getItem())
|
||||
).not.toContain(grammarStatus)
|
||||
|
||||
atom.config.set('grammar-selector.showOnRightSideOfStatusBar', true)
|
||||
|
||||
expect(statusBar.getLeftTiles().map(tile => tile.getItem())).not.toContain(grammarStatus)
|
||||
expect(statusBar.getRightTiles().map(tile => tile.getItem())).toContain(grammarStatus)
|
||||
expect(
|
||||
statusBar.getLeftTiles().map(tile => tile.getItem())
|
||||
).not.toContain(grammarStatus)
|
||||
expect(statusBar.getRightTiles().map(tile => tile.getItem())).toContain(
|
||||
grammarStatus
|
||||
)
|
||||
|
||||
atom.config.set('grammar-selector.showOnRightSideOfStatusBar', false)
|
||||
|
||||
expect(statusBar.getLeftTiles().map(tile => tile.getItem())).toContain(grammarStatus)
|
||||
expect(statusBar.getRightTiles().map(tile => tile.getItem())).not.toContain(grammarStatus)
|
||||
})
|
||||
)
|
||||
expect(statusBar.getLeftTiles().map(tile => tile.getItem())).toContain(
|
||||
grammarStatus
|
||||
)
|
||||
expect(
|
||||
statusBar.getRightTiles().map(tile => tile.getItem())
|
||||
).not.toContain(grammarStatus)
|
||||
}))
|
||||
|
||||
describe("when the editor's grammar changes", () =>
|
||||
it('displays the new grammar of the editor', async () => {
|
||||
@@ -163,32 +186,37 @@ describe('GrammarSelector', () => {
|
||||
await atom.views.getNextUpdatePromise()
|
||||
|
||||
expect(grammarStatus.querySelector('a').textContent).toBe('Plain Text')
|
||||
expect(getTooltipText(grammarStatus)).toBe('File uses the Plain Text grammar')
|
||||
expect(getTooltipText(grammarStatus)).toBe(
|
||||
'File uses the Plain Text grammar'
|
||||
)
|
||||
|
||||
editor.setGrammar(atom.grammars.grammarForScopeName('source.a'))
|
||||
await atom.views.getNextUpdatePromise()
|
||||
|
||||
expect(grammarStatus.querySelector('a').textContent).toBe('source.a')
|
||||
expect(getTooltipText(grammarStatus)).toBe('File uses the source.a grammar')
|
||||
})
|
||||
)
|
||||
expect(getTooltipText(grammarStatus)).toBe(
|
||||
'File uses the source.a grammar'
|
||||
)
|
||||
}))
|
||||
|
||||
describe('when clicked', () =>
|
||||
it('shows the grammar selector modal', () => {
|
||||
const eventHandler = jasmine.createSpy('eventHandler')
|
||||
atom.commands.add(editor.getElement(), 'grammar-selector:show', eventHandler)
|
||||
atom.commands.add(
|
||||
editor.getElement(),
|
||||
'grammar-selector:show',
|
||||
eventHandler
|
||||
)
|
||||
grammarStatus.click()
|
||||
expect(eventHandler).toHaveBeenCalled()
|
||||
})
|
||||
)
|
||||
}))
|
||||
|
||||
describe('when the package is deactivated', () =>
|
||||
it('removes the view', () => {
|
||||
spyOn(grammarTile, 'destroy')
|
||||
atom.packages.deactivatePackage('grammar-selector')
|
||||
expect(grammarTile.destroy).toHaveBeenCalled()
|
||||
})
|
||||
)
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/** @babel */
|
||||
/** @jsx etch.dom */
|
||||
|
||||
import {BufferedProcess} from 'atom'
|
||||
import etch from 'etch'
|
||||
|
||||
import VIEW_URI from './view-uri'
|
||||
@@ -11,8 +10,8 @@ const REBUILD_SUCCEEDED = 'rebuild-succeeded'
|
||||
|
||||
export default class IncompatiblePackagesComponent {
|
||||
constructor (packageManager) {
|
||||
this.rebuildStatuses = new Map
|
||||
this.rebuildFailureOutputs = new Map
|
||||
this.rebuildStatuses = new Map()
|
||||
this.rebuildFailureOutputs = new Map()
|
||||
this.rebuildInProgress = false
|
||||
this.rebuiltPackageCount = 0
|
||||
this.packageManager = packageManager
|
||||
@@ -25,13 +24,15 @@ export default class IncompatiblePackagesComponent {
|
||||
global.setImmediate(this.populateIncompatiblePackages.bind(this))
|
||||
}
|
||||
|
||||
this.element.addEventListener('click', (event) => {
|
||||
this.element.addEventListener('click', event => {
|
||||
if (event.target === this.refs.rebuildButton) {
|
||||
this.rebuildIncompatiblePackages()
|
||||
} else if (event.target === this.refs.reloadButton) {
|
||||
atom.reload()
|
||||
} else if (event.target.classList.contains('view-settings')) {
|
||||
atom.workspace.open(`atom://config/packages/${event.target.package.name}`)
|
||||
atom.workspace.open(
|
||||
`atom://config/packages/${event.target.package.name}`
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -44,7 +45,10 @@ export default class IncompatiblePackagesComponent {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='incompatible-packages padded native-key-bindings' tabIndex='-1'>
|
||||
<div
|
||||
className='incompatible-packages padded native-key-bindings'
|
||||
tabIndex='-1'
|
||||
>
|
||||
{this.renderHeading()}
|
||||
{this.renderIncompatiblePackageList()}
|
||||
</div>
|
||||
@@ -55,15 +59,14 @@ export default class IncompatiblePackagesComponent {
|
||||
if (this.incompatiblePackages.length > 0) {
|
||||
if (this.rebuiltPackageCount > 0) {
|
||||
let alertClass =
|
||||
(this.rebuiltPackageCount === this.incompatiblePackages.length)
|
||||
this.rebuiltPackageCount === this.incompatiblePackages.length
|
||||
? 'alert-success icon-check'
|
||||
: 'alert-warning icon-bug'
|
||||
|
||||
return (
|
||||
<div className={'alert icon ' + alertClass}>
|
||||
{this.rebuiltPackageCount} of {this.incompatiblePackages.length} packages
|
||||
were rebuilt successfully. Reload Atom to activate them.
|
||||
|
||||
{this.rebuiltPackageCount} of {this.incompatiblePackages.length}{' '}
|
||||
packages were rebuilt successfully. Reload Atom to activate them.
|
||||
<button ref='reloadButton' className='btn pull-right'>
|
||||
Reload Atom
|
||||
</button>
|
||||
@@ -72,10 +75,13 @@ export default class IncompatiblePackagesComponent {
|
||||
} else {
|
||||
return (
|
||||
<div className='alert alert-danger icon icon-bug'>
|
||||
Some installed packages could not be loaded because they contain native
|
||||
modules that were compiled for an earlier version of Atom.
|
||||
|
||||
<button ref='rebuildButton' className='btn pull-right' disabled={this.rebuildInProgress}>
|
||||
Some installed packages could not be loaded because they contain
|
||||
native modules that were compiled for an earlier version of Atom.
|
||||
<button
|
||||
ref='rebuildButton'
|
||||
className='btn pull-right'
|
||||
disabled={this.rebuildInProgress}
|
||||
>
|
||||
Rebuild Packages
|
||||
</button>
|
||||
</div>
|
||||
@@ -92,9 +98,11 @@ export default class IncompatiblePackagesComponent {
|
||||
|
||||
renderIncompatiblePackageList () {
|
||||
return (
|
||||
<div>{
|
||||
this.incompatiblePackages.map(this.renderIncompatiblePackage.bind(this))
|
||||
}</div>
|
||||
<div>
|
||||
{this.incompatiblePackages.map(
|
||||
this.renderIncompatiblePackage.bind(this)
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -104,15 +112,18 @@ export default class IncompatiblePackagesComponent {
|
||||
return (
|
||||
<div className={'incompatible-package'}>
|
||||
{this.renderRebuildStatusIndicator(rebuildStatus)}
|
||||
<button className='btn view-settings icon icon-gear pull-right' package={pack}>Package Settings</button>
|
||||
<button
|
||||
className='btn view-settings icon icon-gear pull-right'
|
||||
package={pack}
|
||||
>
|
||||
Package Settings
|
||||
</button>
|
||||
<h4 className='heading'>
|
||||
{pack.name} {pack.metadata.version}
|
||||
</h4>
|
||||
{
|
||||
rebuildStatus
|
||||
{rebuildStatus
|
||||
? this.renderRebuildOutput(pack)
|
||||
: this.renderIncompatibleModules(pack)
|
||||
}
|
||||
: this.renderIncompatibleModules(pack)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -151,23 +162,23 @@ export default class IncompatiblePackagesComponent {
|
||||
|
||||
renderIncompatibleModules (pack) {
|
||||
return (
|
||||
<ul>{
|
||||
pack.incompatibleModules.map((nativeModule) =>
|
||||
<ul>
|
||||
{pack.incompatibleModules.map(nativeModule => (
|
||||
<li>
|
||||
<div className='icon icon-file-binary'>
|
||||
{nativeModule.name}@{nativeModule.version || 'unknown'} – <span className='text-warning'>{nativeModule.error}</span>
|
||||
{nativeModule.name}@{nativeModule.version || 'unknown'} –{' '}
|
||||
<span className='text-warning'>{nativeModule.error}</span>
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
}</ul>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
populateIncompatiblePackages () {
|
||||
this.incompatiblePackages =
|
||||
this.packageManager
|
||||
.getLoadedPackages()
|
||||
.filter(pack => !pack.isCompatible())
|
||||
this.incompatiblePackages = this.packageManager
|
||||
.getLoadedPackages()
|
||||
.filter(pack => !pack.isCompatible())
|
||||
|
||||
for (let pack of this.incompatiblePackages) {
|
||||
let buildFailureOutput = pack.getBuildFailureOutput()
|
||||
@@ -186,7 +197,7 @@ export default class IncompatiblePackagesComponent {
|
||||
let rebuiltPackageCount = 0
|
||||
for (let pack of this.incompatiblePackages) {
|
||||
this.setPackageStatus(pack, REBUILDING)
|
||||
let {code, stderr} = await pack.rebuild()
|
||||
let { code, stderr } = await pack.rebuild()
|
||||
if (code === 0) {
|
||||
this.setPackageStatus(pack, REBUILD_SUCCEEDED)
|
||||
rebuiltPackageCount++
|
||||
@@ -223,6 +234,6 @@ export default class IncompatiblePackagesComponent {
|
||||
}
|
||||
|
||||
serialize () {
|
||||
return {deserializer: 'IncompatiblePackagesComponent'}
|
||||
return { deserializer: 'IncompatiblePackagesComponent' }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** @babel */
|
||||
|
||||
import {Disposable, CompositeDisposable} from 'atom'
|
||||
import { Disposable, CompositeDisposable } from 'atom'
|
||||
import VIEW_URI from './view-uri'
|
||||
|
||||
let disposables = null
|
||||
@@ -8,17 +8,21 @@ let disposables = null
|
||||
export function activate () {
|
||||
disposables = new CompositeDisposable()
|
||||
|
||||
disposables.add(atom.workspace.addOpener((uri) => {
|
||||
if (uri === VIEW_URI) {
|
||||
return deserializeIncompatiblePackagesComponent()
|
||||
}
|
||||
}))
|
||||
disposables.add(
|
||||
atom.workspace.addOpener(uri => {
|
||||
if (uri === VIEW_URI) {
|
||||
return deserializeIncompatiblePackagesComponent()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
disposables.add(atom.commands.add('atom-workspace', {
|
||||
'incompatible-packages:view': () => {
|
||||
atom.workspace.open(VIEW_URI)
|
||||
}
|
||||
}))
|
||||
disposables.add(
|
||||
atom.commands.add('atom-workspace', {
|
||||
'incompatible-packages:view': () => {
|
||||
atom.workspace.open(VIEW_URI)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
export function deactivate () {
|
||||
@@ -33,7 +37,7 @@ export function consumeStatusBar (statusBar) {
|
||||
|
||||
if (incompatibleCount > 0) {
|
||||
let icon = createIcon(incompatibleCount)
|
||||
let tile = statusBar.addRightTile({item: icon, priority: 200})
|
||||
let tile = statusBar.addRightTile({ item: icon, priority: 200 })
|
||||
icon.element.addEventListener('click', () => {
|
||||
atom.commands.dispatch(icon.element, 'incompatible-packages:view')
|
||||
})
|
||||
@@ -48,5 +52,5 @@ export function deserializeIncompatiblePackagesComponent () {
|
||||
|
||||
function createIcon (count) {
|
||||
const StatusIconComponent = require('./status-icon-component')
|
||||
return new StatusIconComponent({count})
|
||||
return new StatusIconComponent({ count })
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import etch from 'etch'
|
||||
|
||||
export default class StatusIconComponent {
|
||||
constructor ({count}) {
|
||||
constructor ({ count }) {
|
||||
this.count = count
|
||||
etch.initialize(this)
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export default class StatusIconComponent {
|
||||
render () {
|
||||
return (
|
||||
<div className='incompatible-packages-status inline-block text text-error'>
|
||||
<span className='icon icon-bug'></span>
|
||||
<span className='icon icon-bug' />
|
||||
<span className='incompatible-packages-count'>{this.count}</span>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
return false
|
||||
},
|
||||
rebuild: function () {
|
||||
return new Promise((resolve) => this.resolveRebuild = resolve)
|
||||
return new Promise(resolve => (this.resolveRebuild = resolve))
|
||||
},
|
||||
getBuildFailureOutput () {
|
||||
return null
|
||||
@@ -27,8 +27,8 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
version: '1.0.0'
|
||||
},
|
||||
incompatibleModules: [
|
||||
{name: 'x', version: '1.0.0', error: 'Expected version X, got Y'},
|
||||
{name: 'y', version: '1.0.0', error: 'Expected version X, got Z'}
|
||||
{ name: 'x', version: '1.0.0', error: 'Expected version X, got Y' },
|
||||
{ name: 'y', version: '1.0.0', error: 'Expected version X, got Z' }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -37,7 +37,7 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
return false
|
||||
},
|
||||
rebuild () {
|
||||
return new Promise((resolve) => this.resolveRebuild = resolve)
|
||||
return new Promise(resolve => (this.resolveRebuild = resolve))
|
||||
},
|
||||
getBuildFailureOutput () {
|
||||
return null
|
||||
@@ -48,7 +48,7 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
version: '1.0.0'
|
||||
},
|
||||
incompatibleModules: [
|
||||
{name: 'z', version: '1.0.0', error: 'Expected version X, got Y'}
|
||||
{ name: 'z', version: '1.0.0', error: 'Expected version X, got Y' }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -67,7 +67,7 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
repository: 'https://github.com/atom/b',
|
||||
version: '1.0.0'
|
||||
},
|
||||
incompatibleModules: [],
|
||||
incompatibleModules: []
|
||||
}
|
||||
]
|
||||
})
|
||||
@@ -75,18 +75,21 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
describe('when packages have not finished loading', () => {
|
||||
it('delays rendering incompatible packages until the end of the tick', () => {
|
||||
waitsForPromise(async () => {
|
||||
let component =
|
||||
new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => [],
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let {element} = component
|
||||
let component = new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => [],
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let { element } = component
|
||||
|
||||
expect(element.querySelectorAll('.incompatible-package').length).toEqual(0)
|
||||
expect(
|
||||
element.querySelectorAll('.incompatible-package').length
|
||||
).toEqual(0)
|
||||
|
||||
await etchScheduler.getNextUpdatePromise()
|
||||
|
||||
expect(element.querySelectorAll('.incompatible-package').length).toBeGreaterThan(0)
|
||||
expect(
|
||||
element.querySelectorAll('.incompatible-package').length
|
||||
).toBeGreaterThan(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -97,12 +100,11 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
expect(packages[2].isCompatible()).toBe(true)
|
||||
let compatiblePackages = [packages[2]]
|
||||
|
||||
let component =
|
||||
new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => compatiblePackages,
|
||||
getLoadedPackages: () => compatiblePackages
|
||||
})
|
||||
let {element} = component
|
||||
let component = new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => compatiblePackages,
|
||||
getLoadedPackages: () => compatiblePackages
|
||||
})
|
||||
let { element } = component
|
||||
|
||||
await etchScheduler.getNextUpdatePromise()
|
||||
|
||||
@@ -119,18 +121,23 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
return 'The build failed'
|
||||
}
|
||||
|
||||
let component =
|
||||
new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => packages,
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let {element} = component
|
||||
let component = new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => packages,
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let { element } = component
|
||||
|
||||
await etchScheduler.getNextUpdatePromise()
|
||||
let packageElement = element.querySelector('.incompatible-package:nth-child(2)')
|
||||
let packageElement = element.querySelector(
|
||||
'.incompatible-package:nth-child(2)'
|
||||
)
|
||||
|
||||
expect(packageElement.querySelector('.badge').textContent).toBe('Rebuild Failed')
|
||||
expect(packageElement.querySelector('pre').textContent).toBe('The build failed')
|
||||
expect(packageElement.querySelector('.badge').textContent).toBe(
|
||||
'Rebuild Failed'
|
||||
)
|
||||
expect(packageElement.querySelector('pre').textContent).toBe(
|
||||
'The build failed'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -138,75 +145,101 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
describe('when there are incompatible packages', () => {
|
||||
it('renders incompatible packages and the rebuild button', () => {
|
||||
waitsForPromise(async () => {
|
||||
let component =
|
||||
new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => packages,
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let {element} = component
|
||||
let component = new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => packages,
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let { element } = component
|
||||
|
||||
await etchScheduler.getNextUpdatePromise()
|
||||
|
||||
expect(element.querySelectorAll('.incompatible-package').length).toEqual(2)
|
||||
expect(
|
||||
element.querySelectorAll('.incompatible-package').length
|
||||
).toEqual(2)
|
||||
expect(element.querySelector('button')).not.toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the "Rebuild All" button is clicked', () => {
|
||||
it('rebuilds every incompatible package, updating each package\'s view with status', () => {
|
||||
it("rebuilds every incompatible package, updating each package's view with status", () => {
|
||||
waitsForPromise(async () => {
|
||||
let component =
|
||||
new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => packages,
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let {element} = component
|
||||
let component = new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => packages,
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let { element } = component
|
||||
jasmine.attachToDOM(element)
|
||||
|
||||
await etchScheduler.getNextUpdatePromise()
|
||||
|
||||
component.refs.rebuildButton.dispatchEvent(new CustomEvent('click', {bubbles: true}))
|
||||
component.refs.rebuildButton.dispatchEvent(
|
||||
new CustomEvent('click', { bubbles: true })
|
||||
)
|
||||
await etchScheduler.getNextUpdatePromise() // view update
|
||||
|
||||
expect(component.refs.rebuildButton.disabled).toBe(true)
|
||||
|
||||
expect(packages[0].resolveRebuild).toBeDefined()
|
||||
|
||||
expect(element.querySelector('.incompatible-package:nth-child(1) .badge').textContent).toBe('Rebuilding')
|
||||
expect(element.querySelector('.incompatible-package:nth-child(2) .badge')).toBeNull()
|
||||
expect(
|
||||
element.querySelector('.incompatible-package:nth-child(1) .badge')
|
||||
.textContent
|
||||
).toBe('Rebuilding')
|
||||
expect(
|
||||
element.querySelector('.incompatible-package:nth-child(2) .badge')
|
||||
).toBeNull()
|
||||
|
||||
packages[0].resolveRebuild({code: 0}) // simulate rebuild success
|
||||
packages[0].resolveRebuild({ code: 0 }) // simulate rebuild success
|
||||
await etchScheduler.getNextUpdatePromise() // view update
|
||||
|
||||
expect(packages[1].resolveRebuild).toBeDefined()
|
||||
|
||||
expect(element.querySelector('.incompatible-package:nth-child(1) .badge').textContent).toBe('Rebuild Succeeded')
|
||||
expect(element.querySelector('.incompatible-package:nth-child(2) .badge').textContent).toBe('Rebuilding')
|
||||
expect(
|
||||
element.querySelector('.incompatible-package:nth-child(1) .badge')
|
||||
.textContent
|
||||
).toBe('Rebuild Succeeded')
|
||||
expect(
|
||||
element.querySelector('.incompatible-package:nth-child(2) .badge')
|
||||
.textContent
|
||||
).toBe('Rebuilding')
|
||||
|
||||
packages[1].resolveRebuild({code: 12, stderr: 'This is an error from the test!'}) // simulate rebuild failure
|
||||
packages[1].resolveRebuild({
|
||||
code: 12,
|
||||
stderr: 'This is an error from the test!'
|
||||
}) // simulate rebuild failure
|
||||
await etchScheduler.getNextUpdatePromise() // view update
|
||||
|
||||
expect(element.querySelector('.incompatible-package:nth-child(1) .badge').textContent).toBe('Rebuild Succeeded')
|
||||
expect(element.querySelector('.incompatible-package:nth-child(2) .badge').textContent).toBe('Rebuild Failed')
|
||||
expect(element.querySelector('.incompatible-package:nth-child(2) pre').textContent).toBe('This is an error from the test!')
|
||||
expect(
|
||||
element.querySelector('.incompatible-package:nth-child(1) .badge')
|
||||
.textContent
|
||||
).toBe('Rebuild Succeeded')
|
||||
expect(
|
||||
element.querySelector('.incompatible-package:nth-child(2) .badge')
|
||||
.textContent
|
||||
).toBe('Rebuild Failed')
|
||||
expect(
|
||||
element.querySelector('.incompatible-package:nth-child(2) pre')
|
||||
.textContent
|
||||
).toBe('This is an error from the test!')
|
||||
})
|
||||
})
|
||||
|
||||
it('displays a prompt to reload Atom when the packages finish rebuilding', () => {
|
||||
waitsForPromise(async () => {
|
||||
let component =
|
||||
new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => packages,
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let {element} = component
|
||||
let component = new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => packages,
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let { element } = component
|
||||
jasmine.attachToDOM(element)
|
||||
await etchScheduler.getNextUpdatePromise() // view update
|
||||
|
||||
component.refs.rebuildButton.dispatchEvent(new CustomEvent('click', {bubbles: true}))
|
||||
expect(packages[0].resolveRebuild({code: 0}))
|
||||
component.refs.rebuildButton.dispatchEvent(
|
||||
new CustomEvent('click', { bubbles: true })
|
||||
)
|
||||
expect(packages[0].resolveRebuild({ code: 0 }))
|
||||
await new Promise(global.setImmediate)
|
||||
expect(packages[1].resolveRebuild({code: 0}))
|
||||
expect(packages[1].resolveRebuild({ code: 0 }))
|
||||
|
||||
await etchScheduler.getNextUpdatePromise() // view update
|
||||
|
||||
@@ -214,7 +247,9 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
expect(element.querySelector('.alert').textContent).toMatch(/2 of 2/)
|
||||
|
||||
spyOn(atom, 'reload')
|
||||
component.refs.reloadButton.dispatchEvent(new CustomEvent('click', {bubbles: true}))
|
||||
component.refs.reloadButton.dispatchEvent(
|
||||
new CustomEvent('click', { bubbles: true })
|
||||
)
|
||||
expect(atom.reload).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -223,19 +258,22 @@ describe('IncompatiblePackagesComponent', () => {
|
||||
describe('when the "Package Settings" button is clicked', () => {
|
||||
it('opens the settings panel for the package', () => {
|
||||
waitsForPromise(async () => {
|
||||
let component =
|
||||
new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => packages,
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let {element} = component
|
||||
let component = new IncompatiblePackagesComponent({
|
||||
getActivePackages: () => packages,
|
||||
getLoadedPackages: () => packages
|
||||
})
|
||||
let { element } = component
|
||||
jasmine.attachToDOM(element)
|
||||
|
||||
await etchScheduler.getNextUpdatePromise()
|
||||
|
||||
spyOn(atom.workspace, 'open')
|
||||
element.querySelector('.incompatible-package:nth-child(2) button').dispatchEvent(new CustomEvent('click', {bubbles: true}))
|
||||
expect(atom.workspace.open).toHaveBeenCalledWith('atom://config/packages/incompatible-2')
|
||||
element
|
||||
.querySelector('.incompatible-package:nth-child(2) button')
|
||||
.dispatchEvent(new CustomEvent('click', { bubbles: true }))
|
||||
expect(atom.workspace.open).toHaveBeenCalledWith(
|
||||
'atom://config/packages/incompatible-2'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -36,7 +36,9 @@ describe('Incompatible packages', () => {
|
||||
)
|
||||
spyOn(incompatiblePackage, 'isCompatible').andReturn(false)
|
||||
incompatiblePackage.incompatibleModules = []
|
||||
waitsForPromise(() => atom.packages.activatePackage("incompatible-packages"))
|
||||
waitsForPromise(() =>
|
||||
atom.packages.activatePackage('incompatible-packages')
|
||||
)
|
||||
|
||||
waits(1)
|
||||
})
|
||||
@@ -63,13 +65,15 @@ describe('Incompatible packages', () => {
|
||||
|
||||
describe('when there are no packages with incompatible native modules', () => {
|
||||
beforeEach(() => {
|
||||
waitsForPromise(() => atom.packages.activatePackage("incompatible-packages"))
|
||||
waitsForPromise(() =>
|
||||
atom.packages.activatePackage('incompatible-packages')
|
||||
)
|
||||
})
|
||||
|
||||
it('does not add an icon to the status bar', () => {
|
||||
let statusBarItemClasses = statusBar
|
||||
.getRightTiles()
|
||||
.map((tile) => tile.getItem().className)
|
||||
.map(tile => tile.getItem().className)
|
||||
|
||||
expect(statusBarItemClasses).not.toContain('incompatible-packages')
|
||||
})
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
'use babel'
|
||||
|
||||
import _ from 'underscore-plus'
|
||||
import {CompositeDisposable, Disposable} from 'atom'
|
||||
import { CompositeDisposable, Disposable } from 'atom'
|
||||
import SelectListView from 'atom-select-list'
|
||||
import StatusBarItem from './status-bar-item'
|
||||
import helpers from './helpers'
|
||||
|
||||
const LineEndingRegExp = /\r\n|\n/g
|
||||
|
||||
// the following regular expression is executed natively via the `substring` package,
|
||||
// where `\A` corresponds to the beginning of the string.
|
||||
// More info: https://github.com/atom/line-ending-selector/pull/56
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
const LFRegExp = /(\A|[^\r])\n/g
|
||||
const CRLFRegExp = /\r\n/g
|
||||
|
||||
@@ -17,48 +22,60 @@ let lineEndingListView = null
|
||||
export function activate () {
|
||||
disposables = new CompositeDisposable()
|
||||
|
||||
disposables.add(atom.commands.add('atom-text-editor', {
|
||||
'line-ending-selector:show': (event) => {
|
||||
if (!modalPanel) {
|
||||
lineEndingListView = new SelectListView({
|
||||
items: [{name: 'LF', value: '\n'}, {name: 'CRLF', value: '\r\n'}],
|
||||
filterKeyForItem: (lineEnding) => lineEnding.name,
|
||||
didConfirmSelection: (lineEnding) => {
|
||||
setLineEnding(atom.workspace.getActiveTextEditor(), lineEnding.value)
|
||||
modalPanel.hide()
|
||||
},
|
||||
didCancelSelection: () => {
|
||||
modalPanel.hide()
|
||||
},
|
||||
elementForItem: (lineEnding) => {
|
||||
const element = document.createElement('li')
|
||||
element.textContent = lineEnding.name
|
||||
return element
|
||||
}
|
||||
})
|
||||
modalPanel = atom.workspace.addModalPanel({item: lineEndingListView})
|
||||
disposables.add(new Disposable(() => {
|
||||
lineEndingListView.destroy()
|
||||
modalPanel.destroy()
|
||||
modalPanel = null
|
||||
}))
|
||||
disposables.add(
|
||||
atom.commands.add('atom-text-editor', {
|
||||
'line-ending-selector:show': event => {
|
||||
if (!modalPanel) {
|
||||
lineEndingListView = new SelectListView({
|
||||
items: [
|
||||
{ name: 'LF', value: '\n' },
|
||||
{ name: 'CRLF', value: '\r\n' }
|
||||
],
|
||||
filterKeyForItem: lineEnding => lineEnding.name,
|
||||
didConfirmSelection: lineEnding => {
|
||||
setLineEnding(
|
||||
atom.workspace.getActiveTextEditor(),
|
||||
lineEnding.value
|
||||
)
|
||||
modalPanel.hide()
|
||||
},
|
||||
didCancelSelection: () => {
|
||||
modalPanel.hide()
|
||||
},
|
||||
elementForItem: lineEnding => {
|
||||
const element = document.createElement('li')
|
||||
element.textContent = lineEnding.name
|
||||
return element
|
||||
}
|
||||
})
|
||||
modalPanel = atom.workspace.addModalPanel({
|
||||
item: lineEndingListView
|
||||
})
|
||||
disposables.add(
|
||||
new Disposable(() => {
|
||||
lineEndingListView.destroy()
|
||||
modalPanel.destroy()
|
||||
modalPanel = null
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
lineEndingListView.reset()
|
||||
modalPanel.show()
|
||||
lineEndingListView.focus()
|
||||
},
|
||||
|
||||
'line-ending-selector:convert-to-LF': event => {
|
||||
const editorElement = event.target.closest('atom-text-editor')
|
||||
setLineEnding(editorElement.getModel(), '\n')
|
||||
},
|
||||
|
||||
'line-ending-selector:convert-to-CRLF': event => {
|
||||
const editorElement = event.target.closest('atom-text-editor')
|
||||
setLineEnding(editorElement.getModel(), '\r\n')
|
||||
}
|
||||
|
||||
lineEndingListView.reset()
|
||||
modalPanel.show()
|
||||
lineEndingListView.focus()
|
||||
},
|
||||
|
||||
'line-ending-selector:convert-to-LF': (event) => {
|
||||
const editorElement = event.target.closest('atom-text-editor')
|
||||
setLineEnding(editorElement.getModel(), '\n')
|
||||
},
|
||||
|
||||
'line-ending-selector:convert-to-CRLF': (event) => {
|
||||
const editorElement = event.target.closest('atom-text-editor')
|
||||
setLineEnding(editorElement.getModel(), '\r\n')
|
||||
}
|
||||
}))
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
export function deactivate () {
|
||||
@@ -70,8 +87,8 @@ export function consumeStatusBar (statusBar) {
|
||||
let currentBufferDisposable = null
|
||||
let tooltipDisposable = null
|
||||
|
||||
const updateTile = _.debounce((buffer) => {
|
||||
getLineEndings(buffer).then((lineEndings) => {
|
||||
const updateTile = _.debounce(buffer => {
|
||||
getLineEndings(buffer).then(lineEndings => {
|
||||
if (lineEndings.size === 0) {
|
||||
let defaultLineEnding = getDefaultLineEnding()
|
||||
buffer.setPreferredLineEnding(defaultLineEnding)
|
||||
@@ -81,45 +98,49 @@ export function consumeStatusBar (statusBar) {
|
||||
})
|
||||
}, 0)
|
||||
|
||||
disposables.add(atom.workspace.observeActiveTextEditor((editor) => {
|
||||
if (currentBufferDisposable) currentBufferDisposable.dispose()
|
||||
disposables.add(
|
||||
atom.workspace.observeActiveTextEditor(editor => {
|
||||
if (currentBufferDisposable) currentBufferDisposable.dispose()
|
||||
|
||||
if (editor && editor.getBuffer) {
|
||||
let buffer = editor.getBuffer()
|
||||
updateTile(buffer)
|
||||
currentBufferDisposable = buffer.onDidChange(({oldText, newText}) => {
|
||||
if (!statusBarItem.hasLineEnding('\n')) {
|
||||
if (newText.indexOf('\n') >= 0) {
|
||||
if (editor && editor.getBuffer) {
|
||||
let buffer = editor.getBuffer()
|
||||
updateTile(buffer)
|
||||
currentBufferDisposable = buffer.onDidChange(({ oldText, newText }) => {
|
||||
if (!statusBarItem.hasLineEnding('\n')) {
|
||||
if (newText.indexOf('\n') >= 0) {
|
||||
updateTile(buffer)
|
||||
}
|
||||
} else if (!statusBarItem.hasLineEnding('\r\n')) {
|
||||
if (newText.indexOf('\r\n') >= 0) {
|
||||
updateTile(buffer)
|
||||
}
|
||||
} else if (oldText.indexOf('\n')) {
|
||||
updateTile(buffer)
|
||||
}
|
||||
} else if (!statusBarItem.hasLineEnding('\r\n')) {
|
||||
if (newText.indexOf('\r\n') >= 0) {
|
||||
updateTile(buffer)
|
||||
}
|
||||
} else if (oldText.indexOf('\n')) {
|
||||
updateTile(buffer)
|
||||
})
|
||||
} else {
|
||||
statusBarItem.setLineEndings(new Set())
|
||||
currentBufferDisposable = null
|
||||
}
|
||||
|
||||
if (tooltipDisposable) {
|
||||
disposables.remove(tooltipDisposable)
|
||||
tooltipDisposable.dispose()
|
||||
}
|
||||
tooltipDisposable = atom.tooltips.add(statusBarItem.element, {
|
||||
title () {
|
||||
return `File uses ${statusBarItem.description()} line endings`
|
||||
}
|
||||
})
|
||||
} else {
|
||||
statusBarItem.setLineEndings(new Set())
|
||||
currentBufferDisposable = null
|
||||
}
|
||||
|
||||
if (tooltipDisposable) {
|
||||
disposables.remove(tooltipDisposable)
|
||||
tooltipDisposable.dispose()
|
||||
}
|
||||
tooltipDisposable = atom.tooltips.add(statusBarItem.element, {
|
||||
title () {
|
||||
return `File uses ${statusBarItem.description()} line endings`
|
||||
}
|
||||
disposables.add(tooltipDisposable)
|
||||
})
|
||||
disposables.add(tooltipDisposable)
|
||||
}))
|
||||
)
|
||||
|
||||
disposables.add(new Disposable(() => {
|
||||
if (currentBufferDisposable) currentBufferDisposable.dispose()
|
||||
}))
|
||||
disposables.add(
|
||||
new Disposable(() => {
|
||||
if (currentBufferDisposable) currentBufferDisposable.dispose()
|
||||
})
|
||||
)
|
||||
|
||||
statusBarItem.onClick(() => {
|
||||
const editor = atom.workspace.getActiveTextEditor()
|
||||
@@ -129,7 +150,7 @@ export function consumeStatusBar (statusBar) {
|
||||
)
|
||||
})
|
||||
|
||||
let tile = statusBar.addRightTile({item: statusBarItem, priority: 200})
|
||||
let tile = statusBar.addRightTile({ item: statusBarItem, priority: 200 })
|
||||
disposables.add(new Disposable(() => tile.destroy()))
|
||||
}
|
||||
|
||||
@@ -141,23 +162,22 @@ function getDefaultLineEnding () {
|
||||
return '\r\n'
|
||||
case 'OS Default':
|
||||
default:
|
||||
return (helpers.getProcessPlatform() === 'win32') ? '\r\n' : '\n'
|
||||
return helpers.getProcessPlatform() === 'win32' ? '\r\n' : '\n'
|
||||
}
|
||||
}
|
||||
|
||||
function getLineEndings (buffer) {
|
||||
if (typeof buffer.find === 'function') {
|
||||
return Promise.all([
|
||||
buffer.find(LFRegExp),
|
||||
buffer.find(CRLFRegExp)
|
||||
]).then(([hasLF, hasCRLF]) => {
|
||||
const result = new Set()
|
||||
if (hasLF) result.add('\n')
|
||||
if (hasCRLF) result.add('\r\n')
|
||||
return result
|
||||
})
|
||||
return Promise.all([buffer.find(LFRegExp), buffer.find(CRLFRegExp)]).then(
|
||||
([hasLF, hasCRLF]) => {
|
||||
const result = new Set()
|
||||
if (hasLF) result.add('\n')
|
||||
if (hasCRLF) result.add('\r\n')
|
||||
return result
|
||||
}
|
||||
)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise(resolve => {
|
||||
const result = new Set()
|
||||
for (let i = 0; i < buffer.getLineCount() - 1; i++) {
|
||||
result.add(buffer.lineEndingForRow(i))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const {Emitter} = require('atom')
|
||||
const { Emitter } = require('atom')
|
||||
|
||||
module.exports =
|
||||
class StatusBarItem {
|
||||
module.exports = class StatusBarItem {
|
||||
constructor () {
|
||||
this.element = document.createElement('a')
|
||||
this.element.className = 'line-ending-tile inline-block'
|
||||
@@ -46,9 +45,13 @@ function lineEndingName (lineEndings) {
|
||||
|
||||
function lineEndingDescription (lineEndings) {
|
||||
switch (lineEndingName(lineEndings)) {
|
||||
case 'Mixed': return 'mixed'
|
||||
case 'LF': return 'LF (Unix)'
|
||||
case 'CRLF': return 'CRLF (Windows)'
|
||||
default: return 'unknown'
|
||||
case 'Mixed':
|
||||
return 'mixed'
|
||||
case 'LF':
|
||||
return 'LF (Unix)'
|
||||
case 'CRLF':
|
||||
return 'CRLF (Windows)'
|
||||
default:
|
||||
return 'unknown'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helpers = require('../lib/helpers')
|
||||
const {TextEditor} = require('atom')
|
||||
const { TextEditor } = require('atom')
|
||||
|
||||
describe('line ending selector', () => {
|
||||
let lineEndingTile
|
||||
@@ -30,7 +30,7 @@ describe('line ending selector', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
waitsForPromise(() => {
|
||||
return atom.workspace.open('mixed-endings.md').then((e) => {
|
||||
return atom.workspace.open('mixed-endings.md').then(e => {
|
||||
editor = e
|
||||
editorElement = atom.views.getView(editor)
|
||||
jasmine.attachToDOM(editorElement)
|
||||
@@ -41,7 +41,10 @@ describe('line ending selector', () => {
|
||||
describe('When "line-ending-selector:convert-to-LF" is run', () => {
|
||||
it('converts the file to LF line endings', () => {
|
||||
editorElement.focus()
|
||||
atom.commands.dispatch(document.activeElement, 'line-ending-selector:convert-to-LF')
|
||||
atom.commands.dispatch(
|
||||
document.activeElement,
|
||||
'line-ending-selector:convert-to-LF'
|
||||
)
|
||||
expect(editor.getText()).toBe('Hello\nGoodbye\nMixed\n')
|
||||
})
|
||||
})
|
||||
@@ -49,7 +52,10 @@ describe('line ending selector', () => {
|
||||
describe('When "line-ending-selector:convert-to-LF" is run', () => {
|
||||
it('converts the file to CRLF line endings', () => {
|
||||
editorElement.focus()
|
||||
atom.commands.dispatch(document.activeElement, 'line-ending-selector:convert-to-CRLF')
|
||||
atom.commands.dispatch(
|
||||
document.activeElement,
|
||||
'line-ending-selector:convert-to-CRLF'
|
||||
)
|
||||
expect(editor.getText()).toBe('Hello\r\nGoodbye\r\nMixed\r\n')
|
||||
})
|
||||
})
|
||||
@@ -58,30 +64,34 @@ describe('line ending selector', () => {
|
||||
describe('Status bar tile', () => {
|
||||
describe('when an empty file is opened', () => {
|
||||
it('uses the default line endings for the platform', () => {
|
||||
waitsFor((done) => {
|
||||
waitsFor(done => {
|
||||
spyOn(helpers, 'getProcessPlatform').andReturn('win32')
|
||||
|
||||
atom.workspace.open('').then((editor) => {
|
||||
atom.workspace.open('').then(editor => {
|
||||
const subscription = lineEndingTile.onDidChange(() => {
|
||||
subscription.dispose()
|
||||
expect(lineEndingTile.element.textContent).toBe('CRLF')
|
||||
expect(editor.getBuffer().getPreferredLineEnding()).toBe('\r\n')
|
||||
expect(getTooltipText(lineEndingTile.element)).toBe('File uses CRLF (Windows) line endings')
|
||||
expect(getTooltipText(lineEndingTile.element)).toBe(
|
||||
'File uses CRLF (Windows) line endings'
|
||||
)
|
||||
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
waitsFor((done) => {
|
||||
waitsFor(done => {
|
||||
helpers.getProcessPlatform.andReturn('darwin')
|
||||
|
||||
atom.workspace.open('').then((editor) => {
|
||||
atom.workspace.open('').then(editor => {
|
||||
const subscription = lineEndingTile.onDidChange(() => {
|
||||
subscription.dispose()
|
||||
expect(lineEndingTile.element.textContent).toBe('LF')
|
||||
expect(editor.getBuffer().getPreferredLineEnding()).toBe('\n')
|
||||
expect(getTooltipText(lineEndingTile.element)).toBe('File uses LF (Unix) line endings')
|
||||
expect(getTooltipText(lineEndingTile.element)).toBe(
|
||||
'File uses LF (Unix) line endings'
|
||||
)
|
||||
|
||||
done()
|
||||
})
|
||||
@@ -95,10 +105,10 @@ describe('line ending selector', () => {
|
||||
})
|
||||
|
||||
it('uses LF line endings, regardless of the platform', () => {
|
||||
waitsFor((done) => {
|
||||
waitsFor(done => {
|
||||
spyOn(helpers, 'getProcessPlatform').andReturn('win32')
|
||||
|
||||
atom.workspace.open('').then((editor) => {
|
||||
atom.workspace.open('').then(editor => {
|
||||
lineEndingTile.onDidChange(() => {
|
||||
expect(lineEndingTile.element.textContent).toBe('LF')
|
||||
expect(editor.getBuffer().getPreferredLineEnding()).toBe('\n')
|
||||
@@ -115,8 +125,8 @@ describe('line ending selector', () => {
|
||||
})
|
||||
|
||||
it('uses CRLF line endings, regardless of the platform', () => {
|
||||
waitsFor((done) => {
|
||||
atom.workspace.open('').then((editor) => {
|
||||
waitsFor(done => {
|
||||
atom.workspace.open('').then(editor => {
|
||||
lineEndingTile.onDidChange(() => {
|
||||
expect(lineEndingTile.element.textContent).toBe('CRLF')
|
||||
expect(editor.getBuffer().getPreferredLineEnding()).toBe('\r\n')
|
||||
@@ -130,7 +140,7 @@ describe('line ending selector', () => {
|
||||
|
||||
describe('when a file is opened that contains only CRLF line endings', () => {
|
||||
it('displays "CRLF" as the line ending', () => {
|
||||
waitsFor((done) => {
|
||||
waitsFor(done => {
|
||||
atom.workspace.open('windows-endings.md').then(() => {
|
||||
lineEndingTile.onDidChange(() => {
|
||||
expect(lineEndingTile.element.textContent).toBe('CRLF')
|
||||
@@ -143,8 +153,8 @@ describe('line ending selector', () => {
|
||||
|
||||
describe('when a file is opened that contains only LF line endings', () => {
|
||||
it('displays "LF" as the line ending', () => {
|
||||
waitsFor((done) => {
|
||||
atom.workspace.open('unix-endings.md').then((editor) => {
|
||||
waitsFor(done => {
|
||||
atom.workspace.open('unix-endings.md').then(editor => {
|
||||
lineEndingTile.onDidChange(() => {
|
||||
expect(lineEndingTile.element.textContent).toBe('LF')
|
||||
expect(editor.getBuffer().getPreferredLineEnding()).toBe(null)
|
||||
@@ -157,7 +167,7 @@ describe('line ending selector', () => {
|
||||
|
||||
describe('when a file is opened that contains mixed line endings', () => {
|
||||
it('displays "Mixed" as the line ending', () => {
|
||||
waitsFor((done) => {
|
||||
waitsFor(done => {
|
||||
atom.workspace.open('mixed-endings.md').then(() => {
|
||||
lineEndingTile.onDidChange(() => {
|
||||
expect(lineEndingTile.element.textContent).toBe('Mixed')
|
||||
@@ -174,10 +184,10 @@ describe('line ending selector', () => {
|
||||
beforeEach(() => {
|
||||
jasmine.attachToDOM(atom.views.getView(atom.workspace))
|
||||
|
||||
waitsFor((done) =>
|
||||
atom.workspace.open('unix-endings.md').then(() =>
|
||||
lineEndingTile.onDidChange(done)
|
||||
)
|
||||
waitsFor(done =>
|
||||
atom.workspace
|
||||
.open('unix-endings.md')
|
||||
.then(() => lineEndingTile.onDidChange(done))
|
||||
)
|
||||
})
|
||||
|
||||
@@ -192,7 +202,9 @@ describe('line ending selector', () => {
|
||||
lineEndingSelector = lineEndingModal.getItem()
|
||||
|
||||
expect(lineEndingModal.isVisible()).toBe(true)
|
||||
expect(lineEndingSelector.element.contains(document.activeElement)).toBe(true)
|
||||
expect(
|
||||
lineEndingSelector.element.contains(document.activeElement)
|
||||
).toBe(true)
|
||||
let listItems = lineEndingSelector.element.querySelectorAll('li')
|
||||
expect(listItems[0].textContent).toBe('LF')
|
||||
expect(listItems[1].textContent).toBe('CRLF')
|
||||
@@ -210,7 +222,9 @@ describe('line ending selector', () => {
|
||||
lineEndingSelector = lineEndingModal.getItem()
|
||||
|
||||
expect(lineEndingModal.isVisible()).toBe(true)
|
||||
expect(lineEndingSelector.element.contains(document.activeElement)).toBe(true)
|
||||
expect(
|
||||
lineEndingSelector.element.contains(document.activeElement)
|
||||
).toBe(true)
|
||||
let listItems = lineEndingSelector.element.querySelectorAll('li')
|
||||
expect(listItems[0].textContent).toBe('LF')
|
||||
expect(listItems[1].textContent).toBe('CRLF')
|
||||
@@ -264,12 +278,12 @@ describe('line ending selector', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the buffer\'s line endings change', () => {
|
||||
describe("when the buffer's line endings change", () => {
|
||||
let editor
|
||||
|
||||
beforeEach(() => {
|
||||
waitsFor((done) => {
|
||||
atom.workspace.open('unix-endings.md').then((e) => {
|
||||
waitsFor(done => {
|
||||
atom.workspace.open('unix-endings.md').then(e => {
|
||||
editor = e
|
||||
lineEndingTile.onDidChange(done)
|
||||
})
|
||||
@@ -291,33 +305,47 @@ describe('line ending selector', () => {
|
||||
})
|
||||
|
||||
expect(lineEndingTile.element.textContent).toBe('LF')
|
||||
expect(getTooltipText(lineEndingTile.element)).toBe('File uses LF (Unix) line endings')
|
||||
expect(getTooltipText(lineEndingTile.element)).toBe(
|
||||
'File uses LF (Unix) line endings'
|
||||
)
|
||||
|
||||
waitsFor((done) => {
|
||||
waitsFor(done => {
|
||||
editor.setTextInBufferRange([[0, 0], [0, 0]], '... ')
|
||||
editor.setTextInBufferRange([[0, Infinity], [1, 0]], '\r\n', {normalizeLineEndings: false})
|
||||
editor.setTextInBufferRange([[0, Infinity], [1, 0]], '\r\n', {
|
||||
normalizeLineEndings: false
|
||||
})
|
||||
lineEndingTile.onDidChange(done)
|
||||
})
|
||||
|
||||
runs(() => {
|
||||
expect(tileUpdateCount).toBe(1)
|
||||
expect(lineEndingTile.element.textContent).toBe('Mixed')
|
||||
expect(getTooltipText(lineEndingTile.element)).toBe('File uses mixed line endings')
|
||||
expect(getTooltipText(lineEndingTile.element)).toBe(
|
||||
'File uses mixed line endings'
|
||||
)
|
||||
})
|
||||
|
||||
waitsFor((done) => {
|
||||
atom.commands.dispatch(editor.getElement(), 'line-ending-selector:convert-to-CRLF')
|
||||
waitsFor(done => {
|
||||
atom.commands.dispatch(
|
||||
editor.getElement(),
|
||||
'line-ending-selector:convert-to-CRLF'
|
||||
)
|
||||
lineEndingTile.onDidChange(done)
|
||||
})
|
||||
|
||||
runs(() => {
|
||||
expect(tileUpdateCount).toBe(2)
|
||||
expect(lineEndingTile.element.textContent).toBe('CRLF')
|
||||
expect(getTooltipText(lineEndingTile.element)).toBe('File uses CRLF (Windows) line endings')
|
||||
expect(getTooltipText(lineEndingTile.element)).toBe(
|
||||
'File uses CRLF (Windows) line endings'
|
||||
)
|
||||
})
|
||||
|
||||
waitsFor((done) => {
|
||||
atom.commands.dispatch(editor.getElement(), 'line-ending-selector:convert-to-LF')
|
||||
waitsFor(done => {
|
||||
atom.commands.dispatch(
|
||||
editor.getElement(),
|
||||
'line-ending-selector:convert-to-LF'
|
||||
)
|
||||
lineEndingTile.onDidChange(done)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
const url = require('url')
|
||||
const {shell} = require('electron')
|
||||
const { shell } = require('electron')
|
||||
const _ = require('underscore-plus')
|
||||
|
||||
const LINK_SCOPE_REGEX = /markup\.underline\.link/
|
||||
|
||||
module.exports = {
|
||||
activate () {
|
||||
this.commandDisposable = atom.commands.add('atom-text-editor', 'link:open', () => this.openLink())
|
||||
this.commandDisposable = atom.commands.add(
|
||||
'atom-text-editor',
|
||||
'link:open',
|
||||
() => this.openLink()
|
||||
)
|
||||
},
|
||||
|
||||
deactivate () {
|
||||
@@ -24,8 +28,10 @@ module.exports = {
|
||||
link = this.linkForName(editor, link)
|
||||
}
|
||||
|
||||
const {protocol} = url.parse(link)
|
||||
if (protocol === 'http:' || protocol === 'https:' || protocol === 'atom:') shell.openExternal(link)
|
||||
const { protocol } = url.parse(link)
|
||||
if (protocol === 'http:' || protocol === 'https:' || protocol === 'atom:') {
|
||||
shell.openExternal(link)
|
||||
}
|
||||
},
|
||||
|
||||
// Get the link under the cursor in the editor
|
||||
@@ -47,7 +53,11 @@ module.exports = {
|
||||
// Returns a {String} link or undefined if no link found.
|
||||
linkAtPosition (editor, bufferPosition) {
|
||||
const token = editor.tokenForBufferPosition(bufferPosition)
|
||||
if (token && token.value && token.scopes.some(scope => LINK_SCOPE_REGEX.test(scope))) {
|
||||
if (
|
||||
token &&
|
||||
token.value &&
|
||||
token.scopes.some(scope => LINK_SCOPE_REGEX.test(scope))
|
||||
) {
|
||||
return token.value
|
||||
}
|
||||
},
|
||||
@@ -65,11 +75,18 @@ module.exports = {
|
||||
// Returns a {String} link
|
||||
linkForName (editor, linkName) {
|
||||
let link = linkName
|
||||
const regex = new RegExp(`^\\s*\\[${_.escapeRegExp(linkName)}\\]\\s*:\\s*(.+)$`, 'g')
|
||||
editor.backwardsScanInBufferRange(regex, [[0, 0], [Infinity, Infinity]], ({match, stop}) => {
|
||||
link = match[1]
|
||||
stop()
|
||||
})
|
||||
const regex = new RegExp(
|
||||
`^\\s*\\[${_.escapeRegExp(linkName)}\\]\\s*:\\s*(.+)$`,
|
||||
'g'
|
||||
)
|
||||
editor.backwardsScanInBufferRange(
|
||||
regex,
|
||||
[[0, 0], [Infinity, Infinity]],
|
||||
({ match, stop }) => {
|
||||
link = match[1]
|
||||
stop()
|
||||
}
|
||||
)
|
||||
return link
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/** @babel */
|
||||
|
||||
export function beforeEach (fn) {
|
||||
global.beforeEach(function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function afterEach (fn) {
|
||||
global.afterEach(function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
['it', 'fit', 'ffit', 'fffit'].forEach(function (name) {
|
||||
module.exports[name] = function (description, fn) {
|
||||
if (fn === undefined) {
|
||||
global[name](description)
|
||||
return
|
||||
}
|
||||
|
||||
global[name](description, function () {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export async function conditionPromise (condition, description = 'anonymous condition') {
|
||||
const startTime = Date.now()
|
||||
|
||||
while (true) {
|
||||
await timeoutPromise(100)
|
||||
|
||||
if (await condition()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (Date.now() - startTime > 5000) {
|
||||
throw new Error('Timed out waiting on ' + description)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function timeoutPromise (timeout) {
|
||||
return new Promise(function (resolve) {
|
||||
global.setTimeout(resolve, timeout)
|
||||
})
|
||||
}
|
||||
|
||||
function waitsForPromise (fn) {
|
||||
const promise = fn()
|
||||
global.waitsFor('spec promise to resolve', function (done) {
|
||||
promise.then(done, function (error) {
|
||||
jasmine.getEnv().currentSpec.fail(error)
|
||||
done()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function emitterEventPromise (emitter, event, timeout = 15000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeoutHandle = setTimeout(() => {
|
||||
reject(new Error(`Timed out waiting for '${event}' event`))
|
||||
}, timeout)
|
||||
emitter.once(event, () => {
|
||||
clearTimeout(timeoutHandle)
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function promisify (original) {
|
||||
return function (...args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
args.push((err, ...results) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(...results)
|
||||
}
|
||||
})
|
||||
|
||||
return original(...args)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function promisifySome (obj, fnNames) {
|
||||
const result = {}
|
||||
for (const fnName of fnNames) {
|
||||
result[fnName] = promisify(obj[fnName])
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
const {shell} = require('electron')
|
||||
|
||||
const {it, fit, ffit, afterEach, beforeEach} = require('./async-spec-helpers') // eslint-disable-line no-unused-vars
|
||||
const { shell } = require('electron')
|
||||
|
||||
describe('link package', () => {
|
||||
beforeEach(async () => {
|
||||
@@ -47,13 +45,15 @@ describe('link package', () => {
|
||||
// only works in Atom >= 1.33.0
|
||||
// https://github.com/atom/link/pull/33#issuecomment-419643655
|
||||
const atomVersion = atom.getVersion().split('.')
|
||||
console.error("atomVersion", atomVersion)
|
||||
console.error('atomVersion', atomVersion)
|
||||
if (+atomVersion[0] > 1 || +atomVersion[1] >= 33) {
|
||||
it("opens an 'atom:' link", async () => {
|
||||
await atom.workspace.open('sample.md')
|
||||
|
||||
const editor = atom.workspace.getActiveTextEditor()
|
||||
editor.setText('// "atom://core/open/file?filename=sample.js&line=1&column=2"')
|
||||
editor.setText(
|
||||
'// "atom://core/open/file?filename=sample.js&line=1&column=2"'
|
||||
)
|
||||
|
||||
spyOn(shell, 'openExternal')
|
||||
atom.commands.dispatch(atom.views.getView(editor), 'link:open')
|
||||
@@ -63,21 +63,27 @@ describe('link package', () => {
|
||||
atom.commands.dispatch(atom.views.getView(editor), 'link:open')
|
||||
|
||||
expect(shell.openExternal).toHaveBeenCalled()
|
||||
expect(shell.openExternal.argsForCall[0][0]).toBe('atom://core/open/file?filename=sample.js&line=1&column=2')
|
||||
expect(shell.openExternal.argsForCall[0][0]).toBe(
|
||||
'atom://core/open/file?filename=sample.js&line=1&column=2'
|
||||
)
|
||||
|
||||
shell.openExternal.reset()
|
||||
editor.setCursorBufferPosition([0, 8])
|
||||
atom.commands.dispatch(atom.views.getView(editor), 'link:open')
|
||||
|
||||
expect(shell.openExternal).toHaveBeenCalled()
|
||||
expect(shell.openExternal.argsForCall[0][0]).toBe('atom://core/open/file?filename=sample.js&line=1&column=2')
|
||||
expect(shell.openExternal.argsForCall[0][0]).toBe(
|
||||
'atom://core/open/file?filename=sample.js&line=1&column=2'
|
||||
)
|
||||
|
||||
shell.openExternal.reset()
|
||||
editor.setCursorBufferPosition([0, 60])
|
||||
atom.commands.dispatch(atom.views.getView(editor), 'link:open')
|
||||
|
||||
expect(shell.openExternal).toHaveBeenCalled()
|
||||
expect(shell.openExternal.argsForCall[0][0]).toBe('atom://core/open/file?filename=sample.js&line=1&column=2')
|
||||
expect(shell.openExternal.argsForCall[0][0]).toBe(
|
||||
'atom://core/open/file?filename=sample.js&line=1&column=2'
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -91,8 +97,7 @@ you should [click][here]
|
||||
you should not [click][her]
|
||||
|
||||
[here]: http://github.com\
|
||||
`
|
||||
)
|
||||
`)
|
||||
|
||||
spyOn(shell, 'openExternal')
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
@@ -110,8 +115,7 @@ you should not [click][her]
|
||||
atom.commands.dispatch(atom.views.getView(editor), 'link:open')
|
||||
|
||||
expect(shell.openExternal).not.toHaveBeenCalled()
|
||||
})
|
||||
)
|
||||
}))
|
||||
|
||||
it('does not open non http/https/atom links', async () => {
|
||||
await atom.workspace.open('sample.md')
|
||||
|
||||
@@ -14,31 +14,45 @@ describe(`${themeName} theme`, () => {
|
||||
|
||||
it('allows the tab sizing to be set via config', () => {
|
||||
atom.config.set(`${themeName}.tabSizing`, 'Maximum')
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-tabsizing`)).toBe('maximum')
|
||||
expect(
|
||||
document.documentElement.getAttribute(`theme-${themeName}-tabsizing`)
|
||||
).toBe('maximum')
|
||||
})
|
||||
|
||||
it('allows the tab sizing to be set via config', () => {
|
||||
atom.config.set(`${themeName}.tabSizing`, 'Minimum')
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-tabsizing`)).toBe('minimum')
|
||||
expect(
|
||||
document.documentElement.getAttribute(`theme-${themeName}-tabsizing`)
|
||||
).toBe('minimum')
|
||||
})
|
||||
|
||||
it('allows the tab close button to be shown on the left via config', () => {
|
||||
atom.config.set(`${themeName}.tabCloseButton`, 'Left')
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-tab-close-button`)).toBe('left')
|
||||
expect(
|
||||
document.documentElement.getAttribute(
|
||||
`theme-${themeName}-tab-close-button`
|
||||
)
|
||||
).toBe('left')
|
||||
})
|
||||
|
||||
it('allows the dock toggle buttons to be hidden via config', () => {
|
||||
atom.config.set(`${themeName}.hideDockButtons`, true)
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-dock-buttons`)).toBe('hidden')
|
||||
expect(
|
||||
document.documentElement.getAttribute(`theme-${themeName}-dock-buttons`)
|
||||
).toBe('hidden')
|
||||
})
|
||||
|
||||
it('allows the tree-view headers to be sticky via config', () => {
|
||||
atom.config.set(`${themeName}.stickyHeaders`, true)
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-sticky-headers`)).toBe('sticky')
|
||||
expect(
|
||||
document.documentElement.getAttribute(`theme-${themeName}-sticky-headers`)
|
||||
).toBe('sticky')
|
||||
})
|
||||
|
||||
it('allows the tree-view headers to not be sticky via config', () => {
|
||||
atom.config.set(`${themeName}.stickyHeaders`, false)
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-sticky-headers`)).toBe(null)
|
||||
expect(
|
||||
document.documentElement.getAttribute(`theme-${themeName}-sticky-headers`)
|
||||
).toBe(null)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -14,31 +14,45 @@ describe(`${themeName} theme`, () => {
|
||||
|
||||
it('allows the tab sizing to be set via config', () => {
|
||||
atom.config.set(`${themeName}.tabSizing`, 'Maximum')
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-tabsizing`)).toBe('maximum')
|
||||
expect(
|
||||
document.documentElement.getAttribute(`theme-${themeName}-tabsizing`)
|
||||
).toBe('maximum')
|
||||
})
|
||||
|
||||
it('allows the tab sizing to be set via config', () => {
|
||||
atom.config.set(`${themeName}.tabSizing`, 'Minimum')
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-tabsizing`)).toBe('minimum')
|
||||
expect(
|
||||
document.documentElement.getAttribute(`theme-${themeName}-tabsizing`)
|
||||
).toBe('minimum')
|
||||
})
|
||||
|
||||
it('allows the tab close button to be shown on the left via config', () => {
|
||||
atom.config.set(`${themeName}.tabCloseButton`, 'Left')
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-tab-close-button`)).toBe('left')
|
||||
expect(
|
||||
document.documentElement.getAttribute(
|
||||
`theme-${themeName}-tab-close-button`
|
||||
)
|
||||
).toBe('left')
|
||||
})
|
||||
|
||||
it('allows the dock toggle buttons to be hidden via config', () => {
|
||||
atom.config.set(`${themeName}.hideDockButtons`, true)
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-dock-buttons`)).toBe('hidden')
|
||||
expect(
|
||||
document.documentElement.getAttribute(`theme-${themeName}-dock-buttons`)
|
||||
).toBe('hidden')
|
||||
})
|
||||
|
||||
it('allows the tree-view headers to be sticky via config', () => {
|
||||
atom.config.set(`${themeName}.stickyHeaders`, true)
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-sticky-headers`)).toBe('sticky')
|
||||
expect(
|
||||
document.documentElement.getAttribute(`theme-${themeName}-sticky-headers`)
|
||||
).toBe('sticky')
|
||||
})
|
||||
|
||||
it('allows the tree-view headers to not be sticky via config', () => {
|
||||
atom.config.set(`${themeName}.stickyHeaders`, false)
|
||||
expect(document.documentElement.getAttribute(`theme-${themeName}-sticky-headers`)).toBe(null)
|
||||
expect(
|
||||
document.documentElement.getAttribute(`theme-${themeName}-sticky-headers`)
|
||||
).toBe(null)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -35,7 +35,7 @@ function dumpSymbol (binaryPath) {
|
||||
const symbolDirPath = path.join(CONFIG.symbolsPath, filename, moduleLine[1])
|
||||
const symbolFilePath = path.join(symbolDirPath, `${filename}.sym`)
|
||||
fs.mkdirpSync(symbolDirPath)
|
||||
fs.writeFileSync(symbolFilePath)
|
||||
fs.writeFileSync(symbolFilePath, content)
|
||||
resolve()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ module.exports = function (packagedAppPath) {
|
||||
requiredModuleRelativePath === path.join('..', 'src', 'electron-shims.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'node_modules', 'atom-keymap', 'lib', 'command-event.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'node_modules', 'babel-core', 'index.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'node_modules', 'cached-run-in-this-context', 'lib', 'main.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'node_modules', 'debug', 'node.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'node_modules', 'git-utils', 'src', 'git.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'node_modules', 'glob', 'glob.js') ||
|
||||
@@ -96,36 +97,22 @@ module.exports = function (packagedAppPath) {
|
||||
{env: Object.assign({}, process.env, {ELECTRON_RUN_AS_NODE: 1})}
|
||||
)
|
||||
|
||||
console.log('Generating startup blob with mksnapshot')
|
||||
childProcess.spawnSync(
|
||||
process.execPath, [
|
||||
path.join(CONFIG.repositoryRootPath, 'script', 'node_modules', 'electron-mksnapshot', 'mksnapshot.js'),
|
||||
snapshotScriptPath,
|
||||
'--output_dir',
|
||||
CONFIG.buildOutputPath
|
||||
]
|
||||
const generatedStartupBlobPath = path.join(CONFIG.buildOutputPath, 'snapshot_blob.bin')
|
||||
console.log(`Generating startup blob at "${generatedStartupBlobPath}"`)
|
||||
childProcess.execFileSync(
|
||||
path.join(CONFIG.repositoryRootPath, 'script', 'node_modules', 'electron-mksnapshot', 'bin', 'mksnapshot'),
|
||||
['--no-use_ic', snapshotScriptPath, '--startup_blob', generatedStartupBlobPath]
|
||||
)
|
||||
|
||||
let startupBlobDestinationPath
|
||||
if (process.platform === 'darwin') {
|
||||
startupBlobDestinationPath = `${packagedAppPath}/Contents/Frameworks/Electron Framework.framework/Resources`
|
||||
startupBlobDestinationPath = `${packagedAppPath}/Contents/Frameworks/Electron Framework.framework/Resources/snapshot_blob.bin`
|
||||
} else {
|
||||
startupBlobDestinationPath = packagedAppPath
|
||||
startupBlobDestinationPath = path.join(packagedAppPath, 'snapshot_blob.bin')
|
||||
}
|
||||
|
||||
const snapshotBinaries = ['v8_context_snapshot.bin', 'snapshot_blob.bin']
|
||||
for (let snapshotBinary of snapshotBinaries) {
|
||||
const destinationPath = path.join(startupBlobDestinationPath, snapshotBinary)
|
||||
console.log(`Moving generated startup blob into "${destinationPath}"`)
|
||||
try {
|
||||
fs.unlinkSync(destinationPath)
|
||||
} catch (err) {
|
||||
// Doesn't matter if the file doesn't exist already
|
||||
if (!err.code || err.code !== 'ENOENT') {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
fs.renameSync(path.join(CONFIG.buildOutputPath, snapshotBinary), destinationPath)
|
||||
}
|
||||
console.log(`Moving generated startup blob into "${startupBlobDestinationPath}"`)
|
||||
fs.unlinkSync(startupBlobDestinationPath)
|
||||
fs.renameSync(generatedStartupBlobPath, startupBlobDestinationPath)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,28 +6,46 @@ const path = require('path')
|
||||
|
||||
const CONFIG = require('../config')
|
||||
|
||||
module.exports = function () {
|
||||
module.exports = async function () {
|
||||
const globPathsToLint = [
|
||||
path.join(CONFIG.repositoryRootPath, 'exports', '**', '*.js'),
|
||||
path.join(CONFIG.repositoryRootPath, 'packages', '**', '*.js'),
|
||||
path.join(CONFIG.repositoryRootPath, 'script', '**', '*.js'),
|
||||
path.join(CONFIG.repositoryRootPath, 'spec', '**', '*.js'),
|
||||
path.join(CONFIG.repositoryRootPath, 'src', '**', '*.js'),
|
||||
path.join(CONFIG.repositoryRootPath, 'static', '*.js')
|
||||
]
|
||||
return expandGlobPaths(globPathsToLint).then((paths) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
standard.lintFiles(paths, (error, lintOutput) => {
|
||||
if (error) {
|
||||
reject(error)
|
||||
} else {
|
||||
const errors = []
|
||||
for (let result of lintOutput.results) {
|
||||
for (let message of result.messages) {
|
||||
errors.push({path: result.filePath, lineNumber: message.line, message: message.message, rule: message.ruleId})
|
||||
}
|
||||
const globPathsToIgnore = [
|
||||
path.join(CONFIG.repositoryRootPath, 'spec', 'fixtures', '**', '*.js')
|
||||
]
|
||||
|
||||
const [includePaths, excludePaths] = await Promise.all([
|
||||
expandGlobPaths(globPathsToLint),
|
||||
expandGlobPaths(globPathsToIgnore)
|
||||
])
|
||||
|
||||
const paths = includePaths.filter(
|
||||
myPath => !excludePaths.includes(myPath)
|
||||
)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
standard.lintFiles(paths, (error, lintOutput) => {
|
||||
if (error) {
|
||||
reject(error)
|
||||
} else {
|
||||
const errors = []
|
||||
for (let result of lintOutput.results) {
|
||||
for (let message of result.messages) {
|
||||
errors.push({
|
||||
path: result.filePath,
|
||||
lineNumber: message.line,
|
||||
message: message.message,
|
||||
rule: message.ruleId
|
||||
})
|
||||
}
|
||||
resolve(errors)
|
||||
}
|
||||
})
|
||||
resolve(errors)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
497
script/package-lock.json
generated
497
script/package-lock.json
generated
@@ -22,6 +22,11 @@
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.0.tgz",
|
||||
"integrity": "sha512-LAQ1d4OPfSJ/BMbI2DuizmYrrkD9JMaTdi2hQTlI53lQ4kRQPyZQRS4CYQ7O66bnBBnP/oYdRxbk++X0xuFU6A=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "11.9.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.9.4.tgz",
|
||||
"integrity": "sha512-Zl8dGvAcEmadgs1tmSPcvwzO1YRsz38bVJQvH1RvRqSR9/5n61Q1ktcDL0ht3FXWR+ZpVmXVwN1LuH4Ax23NsA=="
|
||||
},
|
||||
"abbrev": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
||||
@@ -376,22 +381,6 @@
|
||||
"postcss-value-parser": "^3.2.3"
|
||||
}
|
||||
},
|
||||
"aws-sdk": {
|
||||
"version": "2.275.1",
|
||||
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.275.1.tgz",
|
||||
"integrity": "sha512-lcpgoiHLhdcolUT7aJdg/CmlYO5ecf+3A+4dIceO72mFovCWZde1Rvr07QNbQ8gT0paqr5j2rs2b6c23Y/K0RQ==",
|
||||
"requires": {
|
||||
"buffer": "4.9.1",
|
||||
"events": "1.1.1",
|
||||
"ieee754": "1.1.8",
|
||||
"jmespath": "0.15.0",
|
||||
"querystring": "0.2.0",
|
||||
"sax": "1.2.1",
|
||||
"url": "0.10.3",
|
||||
"uuid": "3.1.0",
|
||||
"xml2js": "0.4.19"
|
||||
}
|
||||
},
|
||||
"aws-sign2": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
|
||||
@@ -625,11 +614,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
|
||||
"integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw=="
|
||||
},
|
||||
"bcrypt-pbkdf": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
|
||||
@@ -691,6 +675,11 @@
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz",
|
||||
"integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE="
|
||||
},
|
||||
"boolbase": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
||||
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
||||
},
|
||||
"boom": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/boom/-/boom-0.4.2.tgz",
|
||||
@@ -737,16 +726,6 @@
|
||||
"electron-to-chromium": "^1.3.47"
|
||||
}
|
||||
},
|
||||
"buffer": {
|
||||
"version": "4.9.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
|
||||
"integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
|
||||
"requires": {
|
||||
"base64-js": "^1.0.2",
|
||||
"ieee754": "^1.1.4",
|
||||
"isarray": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"buffer-alloc": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz",
|
||||
@@ -920,6 +899,19 @@
|
||||
"resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.2.tgz",
|
||||
"integrity": "sha512-7I/xceXfKyUJmSAn/jw8ve/9DyOP7XxufNYLI9Px7CmsKgEUaZLUTax6nZxGQtaoiZCjpu6cHPj20xC/vqRReQ=="
|
||||
},
|
||||
"cheerio": {
|
||||
"version": "1.0.0-rc.2",
|
||||
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz",
|
||||
"integrity": "sha1-S59TqBsn5NXawxwP/Qz6A8xoMNs=",
|
||||
"requires": {
|
||||
"css-select": "~1.2.0",
|
||||
"dom-serializer": "~0.1.0",
|
||||
"entities": "~1.1.1",
|
||||
"htmlparser2": "^3.9.1",
|
||||
"lodash": "^4.15.0",
|
||||
"parse5": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"chownr": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz",
|
||||
@@ -969,11 +961,6 @@
|
||||
"restore-cursor": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"cli-width": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/cli-width/-/cli-width-1.1.1.tgz",
|
||||
"integrity": "sha1-pNKT72frt7iNSk1CwMzwDE0eNm0="
|
||||
},
|
||||
"cliui": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
|
||||
@@ -1259,11 +1246,38 @@
|
||||
"resolved": "https://registry.npmjs.org/css-parse/-/css-parse-1.7.0.tgz",
|
||||
"integrity": "sha1-Mh9s9zeCpv91ERE5D8BeLGV9jJs="
|
||||
},
|
||||
"css-select": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz",
|
||||
"integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=",
|
||||
"requires": {
|
||||
"boolbase": "~1.0.0",
|
||||
"css-what": "2.1",
|
||||
"domutils": "1.5.1",
|
||||
"nth-check": "~1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"domutils": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz",
|
||||
"integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=",
|
||||
"requires": {
|
||||
"dom-serializer": "0",
|
||||
"domelementtype": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"css-value": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/css-value/-/css-value-0.0.1.tgz",
|
||||
"integrity": "sha1-Xv1sLupeof1rasV+wEJ7GEUkJOo="
|
||||
},
|
||||
"css-what": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz",
|
||||
"integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg=="
|
||||
},
|
||||
"ctype": {
|
||||
"version": "0.5.3",
|
||||
"resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz",
|
||||
@@ -1668,14 +1682,6 @@
|
||||
"is-obj": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"duplexer2": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz",
|
||||
"integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=",
|
||||
"requires": {
|
||||
"readable-stream": "~1.1.9"
|
||||
}
|
||||
},
|
||||
"ecc-jsbn": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
|
||||
@@ -1685,78 +1691,51 @@
|
||||
"jsbn": "~0.1.0"
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/editor/-/editor-1.0.0.tgz",
|
||||
"integrity": "sha1-YMf4e9YrzGqJT6jM1q+3gjok90I="
|
||||
},
|
||||
"electron-chromedriver": {
|
||||
"version": "3.0.0-beta.1",
|
||||
"resolved": "https://registry.npmjs.org/electron-chromedriver/-/electron-chromedriver-3.0.0-beta.1.tgz",
|
||||
"integrity": "sha512-S8KuOWqTISSfeVccrh1XjqR5tARdkAbF93azz8TvuNJTKoIw7V54mLKoyhi2Hj5UvKuPLcrHmfa4B9Uh45A5lA==",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/electron-chromedriver/-/electron-chromedriver-2.0.0.tgz",
|
||||
"integrity": "sha512-kERk/Wzhc9RzW9jUKXA5kJc4m8BlL6c9p5QH+CrIlst0saeqZL1Up7vzD4ZOnuBDpAVBBYJ4jhkAKIssf8ZlXg==",
|
||||
"requires": {
|
||||
"electron-download": "^4.1.0",
|
||||
"extract-zip": "^1.6.5"
|
||||
}
|
||||
},
|
||||
"electron-download": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/electron-download/-/electron-download-4.1.1.tgz",
|
||||
"integrity": "sha512-FjEWG9Jb/ppK/2zToP+U5dds114fM1ZOJqMAR4aXXL5CvyPE9fiqBK/9YcwC9poIFQTEJk/EM/zyRwziziRZrg==",
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/electron-download/-/electron-download-4.1.0.tgz",
|
||||
"integrity": "sha1-v5MsdG8vh//MCdHdRy8v9rkYeEU=",
|
||||
"requires": {
|
||||
"debug": "^3.0.0",
|
||||
"debug": "^2.2.0",
|
||||
"env-paths": "^1.0.0",
|
||||
"fs-extra": "^4.0.1",
|
||||
"fs-extra": "^2.0.0",
|
||||
"minimist": "^1.2.0",
|
||||
"nugget": "^2.0.1",
|
||||
"nugget": "^2.0.0",
|
||||
"path-exists": "^3.0.0",
|
||||
"rc": "^1.2.1",
|
||||
"semver": "^5.4.1",
|
||||
"sumchecker": "^2.0.2"
|
||||
"rc": "^1.1.2",
|
||||
"semver": "^5.3.0",
|
||||
"sumchecker": "^2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz",
|
||||
"integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==",
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-2.1.2.tgz",
|
||||
"integrity": "sha1-BGxwFjzvmq1GsOSn+kZ/si1x3jU=",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.2",
|
||||
"jsonfile": "^4.0.0",
|
||||
"universalify": "^0.1.0"
|
||||
}
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
|
||||
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
"jsonfile": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"path-exists": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
|
||||
"integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU="
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.5.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz",
|
||||
"integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"electron-link": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/electron-link/-/electron-link-0.3.3.tgz",
|
||||
"integrity": "sha512-dxFY3o3E9kBkOyfaY66PWabK1AL5Re8qmy2Abz2/VhVkp2KtvUn6BZODTm9XpC0REgWxlQfRyHlNTlXRBPrWCQ==",
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/electron-link/-/electron-link-0.3.2.tgz",
|
||||
"integrity": "sha512-V7QmtujzWgvrW5BI2CKmIRF+q+pkrFO5Lecd8TpibbBz+FfW5WQ4kCN0sZjNaUOMtGGroCib721OqIDEynjwgA==",
|
||||
"requires": {
|
||||
"ast-util": "^0.6.0",
|
||||
"encoding-down": "~5.0.0",
|
||||
@@ -1774,9 +1753,9 @@
|
||||
"integrity": "sha512-UY7+9DPzlJ9VM8eY0b2TUZcZvF+1pO0hzMtAyjBYKhOmnvRlqYNYnWdtsMj0V16CGaMlpL0G1jnLbLo4AyotuQ=="
|
||||
},
|
||||
"core-js": {
|
||||
"version": "2.6.3",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.3.tgz",
|
||||
"integrity": "sha512-l00tmFFZOBHtYhN4Cz7k32VM7vTn3rE2ANjQDxdEN6zmXZ/xq1jQuutnmHvMG1ZJ7xd72+TA5YpUK8wz3rWsfQ=="
|
||||
"version": "2.6.5",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz",
|
||||
"integrity": "sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A=="
|
||||
},
|
||||
"esprima": {
|
||||
"version": "4.0.1",
|
||||
@@ -1810,13 +1789,12 @@
|
||||
}
|
||||
},
|
||||
"electron-mksnapshot": {
|
||||
"version": "3.0.10",
|
||||
"resolved": "https://registry.npmjs.org/electron-mksnapshot/-/electron-mksnapshot-3.0.10.tgz",
|
||||
"integrity": "sha512-Toy6sAC3t9tgvq1kUYsx+4TRNPDj7Bzoo+1gx5FD8Q0YCS+tq+ter62Ot6dBXCKG9SwoaGBz84b++MgO0VobYw==",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/electron-mksnapshot/-/electron-mksnapshot-2.0.0.tgz",
|
||||
"integrity": "sha512-OoZwZJNKgHP+DwhCGVTJEuDSeb478hOzAbHeg7dKGCHDbKKmUWmjGc+pEjxGutpqQ3Mn8hCdLzdx2c/lAJcTLA==",
|
||||
"requires": {
|
||||
"electron-download": "^4.1.0",
|
||||
"extract-zip": "^1.6.5",
|
||||
"temp": "^0.8.3"
|
||||
"extract-zip": "^1.6.5"
|
||||
}
|
||||
},
|
||||
"electron-osx-sign": {
|
||||
@@ -2236,11 +2214,6 @@
|
||||
"es5-ext": "~0.10.14"
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
|
||||
"integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ="
|
||||
},
|
||||
"execa": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/execa/-/execa-0.4.0.tgz",
|
||||
@@ -2991,49 +2964,6 @@
|
||||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"ghauth": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ghauth/-/ghauth-2.0.1.tgz",
|
||||
"integrity": "sha1-ebfWiwvPjn0IUqI7FHU539MUrPY=",
|
||||
"requires": {
|
||||
"bl": "~0.9.4",
|
||||
"hyperquest": "~1.2.0",
|
||||
"mkdirp": "~0.5.0",
|
||||
"read": "~1.0.5",
|
||||
"xtend": "~4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bl": {
|
||||
"version": "0.9.5",
|
||||
"resolved": "https://registry.npmjs.org/bl/-/bl-0.9.5.tgz",
|
||||
"integrity": "sha1-wGt5evCF6gC8Unr8jvzxHeIjIFQ=",
|
||||
"requires": {
|
||||
"readable-stream": "~1.0.26"
|
||||
}
|
||||
},
|
||||
"isarray": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "1.0.34",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
|
||||
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.1",
|
||||
"isarray": "0.0.1",
|
||||
"string_decoder": "~0.10.x"
|
||||
}
|
||||
},
|
||||
"xtend": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
|
||||
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
|
||||
}
|
||||
}
|
||||
},
|
||||
"github-from-package": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz",
|
||||
@@ -3049,14 +2979,6 @@
|
||||
"resolved": "https://registry.npmjs.org/github-url-from-username-repo/-/github-url-from-username-repo-1.0.2.tgz",
|
||||
"integrity": "sha1-fdeTMNKr5pwQws73lxTJchV5Hfo="
|
||||
},
|
||||
"github-url-to-object": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/github-url-to-object/-/github-url-to-object-1.6.0.tgz",
|
||||
"integrity": "sha1-iR73+7+rqP7XFRCs2xtOk0apcNw=",
|
||||
"requires": {
|
||||
"is-url": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.0.3.tgz",
|
||||
@@ -3345,47 +3267,6 @@
|
||||
"sshpk": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"hyperquest": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/hyperquest/-/hyperquest-1.2.0.tgz",
|
||||
"integrity": "sha1-OeH+9miI3Hzg3sbA3YFPb8iUStU=",
|
||||
"requires": {
|
||||
"duplexer2": "~0.0.2",
|
||||
"through2": "~0.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"isarray": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "1.0.34",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
|
||||
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.1",
|
||||
"isarray": "0.0.1",
|
||||
"string_decoder": "~0.10.x"
|
||||
}
|
||||
},
|
||||
"through2": {
|
||||
"version": "0.6.5",
|
||||
"resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz",
|
||||
"integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=",
|
||||
"requires": {
|
||||
"readable-stream": ">=1.0.33-1 <1.1.0-0",
|
||||
"xtend": ">=4.0.0 <4.1.0-0"
|
||||
}
|
||||
},
|
||||
"xtend": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
|
||||
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
|
||||
}
|
||||
}
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.23",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz",
|
||||
@@ -3394,11 +3275,6 @@
|
||||
"safer-buffer": ">= 2.1.2 < 3"
|
||||
}
|
||||
},
|
||||
"ieee754": {
|
||||
"version": "1.1.8",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz",
|
||||
"integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q="
|
||||
},
|
||||
"ignore": {
|
||||
"version": "3.3.10",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz",
|
||||
@@ -3456,33 +3332,6 @@
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
|
||||
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
|
||||
},
|
||||
"inquirer": {
|
||||
"version": "0.8.5",
|
||||
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.8.5.tgz",
|
||||
"integrity": "sha1-29dAz2yjtzEpamPOb22WGFHzNt8=",
|
||||
"requires": {
|
||||
"ansi-regex": "^1.1.1",
|
||||
"chalk": "^1.0.0",
|
||||
"cli-width": "^1.0.1",
|
||||
"figures": "^1.3.5",
|
||||
"lodash": "^3.3.1",
|
||||
"readline2": "^0.1.1",
|
||||
"rx": "^2.4.3",
|
||||
"through": "^2.3.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz",
|
||||
"integrity": "sha1-QchHGUZGN15qGl0Qw8oFTvn8mA0="
|
||||
},
|
||||
"lodash": {
|
||||
"version": "3.10.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz",
|
||||
"integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y="
|
||||
}
|
||||
}
|
||||
},
|
||||
"invert-kv": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",
|
||||
@@ -3746,11 +3595,6 @@
|
||||
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
|
||||
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
|
||||
},
|
||||
"is-url": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz",
|
||||
"integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww=="
|
||||
},
|
||||
"is-utf8": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
|
||||
@@ -3804,11 +3648,6 @@
|
||||
"resolved": "https://registry.npmjs.org/jju/-/jju-1.3.0.tgz",
|
||||
"integrity": "sha1-2t2e8BkkvHKLA/L3l5vb1i96Kqo="
|
||||
},
|
||||
"jmespath": {
|
||||
"version": "0.15.0",
|
||||
"resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz",
|
||||
"integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc="
|
||||
},
|
||||
"joanna": {
|
||||
"version": "0.0.10",
|
||||
"resolved": "https://registry.npmjs.org/joanna/-/joanna-0.0.10.tgz",
|
||||
@@ -4463,11 +4302,6 @@
|
||||
"regex-cache": "^0.4.2"
|
||||
}
|
||||
},
|
||||
"mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.33.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz",
|
||||
@@ -4647,11 +4481,6 @@
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"mute-stream": {
|
||||
"version": "0.0.7",
|
||||
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
|
||||
"integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s="
|
||||
},
|
||||
"mv": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz",
|
||||
@@ -4746,9 +4575,9 @@
|
||||
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw="
|
||||
},
|
||||
"node-abi": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.7.0.tgz",
|
||||
"integrity": "sha512-egTtvNoZLMjwxkL/5iiJKYKZgn2im0zP+G+PncMxICYGiD3aZtXUvEsDmu0pF8gpASvLZyD8v53qi1/ELaRZpg==",
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.7.1.tgz",
|
||||
"integrity": "sha512-OV8Bq1OrPh6z+Y4dqwo05HqrRL9YNF7QVMRfq1/pguwKLG+q9UB/Lk0x5qXjO23JjJg+/jqCHSTaG1P3tfKfuw==",
|
||||
"requires": {
|
||||
"semver": "^5.4.1"
|
||||
},
|
||||
@@ -7572,6 +7401,14 @@
|
||||
"set-blocking": "~2.0.0"
|
||||
}
|
||||
},
|
||||
"nth-check": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz",
|
||||
"integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==",
|
||||
"requires": {
|
||||
"boolbase": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"nugget": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/nugget/-/nugget-2.0.1.tgz",
|
||||
@@ -7800,6 +7637,14 @@
|
||||
"error-ex": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"parse5": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz",
|
||||
"integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==",
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"pascalcase": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz",
|
||||
@@ -7904,11 +7749,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"pkginfo": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz",
|
||||
"integrity": "sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE="
|
||||
},
|
||||
"plist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/plist/-/plist-1.2.0.tgz",
|
||||
@@ -8279,43 +8119,6 @@
|
||||
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
|
||||
"integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM="
|
||||
},
|
||||
"publish-release": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/publish-release/-/publish-release-1.6.0.tgz",
|
||||
"integrity": "sha512-t+NFXTQN/VDTg9yJ8Uv5ZWQ7Ud1T5W1tPW+bmuo4g6uYVQTVNiwwRF6Td3EtXFTOafpEXJQEZqGG7IvIJwLwIg==",
|
||||
"requires": {
|
||||
"async": "^0.9.0",
|
||||
"ghauth": "^2.0.0",
|
||||
"github-url-to-object": "^1.4.2",
|
||||
"inquirer": "^0.8.2",
|
||||
"lodash": "^3.6.0",
|
||||
"mime": "^1.3.4",
|
||||
"minimist": "^1.1.1",
|
||||
"pkginfo": "^0.3.0",
|
||||
"pretty-bytes": "^1.0.4",
|
||||
"progress-stream": "^1.0.1",
|
||||
"request": "^2.54.0",
|
||||
"single-line-log": "^0.4.1",
|
||||
"string-editor": "^0.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"async": {
|
||||
"version": "0.9.2",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz",
|
||||
"integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0="
|
||||
},
|
||||
"lodash": {
|
||||
"version": "3.10.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz",
|
||||
"integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y="
|
||||
},
|
||||
"single-line-log": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/single-line-log/-/single-line-log-0.4.1.tgz",
|
||||
"integrity": "sha1-h6VWSfdJ14PsDc2AToFA2Yc8fO4="
|
||||
}
|
||||
}
|
||||
},
|
||||
"pump": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz",
|
||||
@@ -8408,14 +8211,6 @@
|
||||
"resolved": "https://registry.npmjs.org/rcedit/-/rcedit-0.5.1.tgz",
|
||||
"integrity": "sha1-0L3PXSgKnRwp2m8RjMzizhU87x0="
|
||||
},
|
||||
"read": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz",
|
||||
"integrity": "sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ=",
|
||||
"requires": {
|
||||
"mute-stream": "~0.0.4"
|
||||
}
|
||||
},
|
||||
"read-installed": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/read-installed/-/read-installed-3.1.3.tgz",
|
||||
@@ -8543,35 +8338,6 @@
|
||||
"once": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"readline2": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/readline2/-/readline2-0.1.1.tgz",
|
||||
"integrity": "sha1-mUQ7pug7gw7zBRv9fcJBqCco1Wg=",
|
||||
"requires": {
|
||||
"mute-stream": "0.0.4",
|
||||
"strip-ansi": "^2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz",
|
||||
"integrity": "sha1-QchHGUZGN15qGl0Qw8oFTvn8mA0="
|
||||
},
|
||||
"mute-stream": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.4.tgz",
|
||||
"integrity": "sha1-qSGZYKbV1dBGWXruUSUsZlX3F34="
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-2.0.1.tgz",
|
||||
"integrity": "sha1-32LBqpTtLxFOHQ8h/R1QSCt5pg4=",
|
||||
"requires": {
|
||||
"ansi-regex": "^1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"recast": {
|
||||
"version": "0.10.33",
|
||||
"resolved": "https://registry.npmjs.org/recast/-/recast-0.10.33.tgz",
|
||||
@@ -8788,24 +8554,6 @@
|
||||
"uuid": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"request-promise-core": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz",
|
||||
"integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=",
|
||||
"requires": {
|
||||
"lodash": "^4.13.1"
|
||||
}
|
||||
},
|
||||
"request-promise-native": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.5.tgz",
|
||||
"integrity": "sha1-UoF3D2jgyXGeUWP9P6tIIhX0/aU=",
|
||||
"requires": {
|
||||
"request-promise-core": "1.1.1",
|
||||
"stealthy-require": "^1.1.0",
|
||||
"tough-cookie": ">=2.3.3"
|
||||
}
|
||||
},
|
||||
"require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
@@ -8919,11 +8667,6 @@
|
||||
"resolved": "https://registry.npmjs.org/run-series/-/run-series-1.1.8.tgz",
|
||||
"integrity": "sha512-+GztYEPRpIsQoCSraWHDBs9WVy4eVME16zhOtDB4H9J4xN0XRhknnmLOl+4gRgZtu8dpp9N/utSPjKH/xmDzXg=="
|
||||
},
|
||||
"rx": {
|
||||
"version": "2.5.3",
|
||||
"resolved": "https://registry.npmjs.org/rx/-/rx-2.5.3.tgz",
|
||||
"integrity": "sha1-Ia3H2A8CACr1Da6X/Z2/JIdV9WY="
|
||||
},
|
||||
"rx-lite": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz",
|
||||
@@ -8947,11 +8690,6 @@
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"sax": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz",
|
||||
"integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o="
|
||||
},
|
||||
"season": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/season/-/season-5.3.0.tgz",
|
||||
@@ -9356,19 +9094,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"stealthy-require": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz",
|
||||
"integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks="
|
||||
},
|
||||
"string-editor": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/string-editor/-/string-editor-0.1.2.tgz",
|
||||
"integrity": "sha1-9f8bWsSu16xsL7jeI20VUbIPYdA=",
|
||||
"requires": {
|
||||
"editor": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
||||
@@ -9978,15 +9703,20 @@
|
||||
}
|
||||
},
|
||||
"terser": {
|
||||
"version": "3.8.1",
|
||||
"resolved": "https://registry.npmjs.org/terser/-/terser-3.8.1.tgz",
|
||||
"integrity": "sha512-FRin3gKQ0vm0xPPLuxw1FqpVgv1b2pBpYCaFb5qe6A7sD749Fnq1VbDiX3CEFM0BV0fqDzFtBfgmxhxCdzKQIg==",
|
||||
"version": "3.10.8",
|
||||
"resolved": "https://registry.npmjs.org/terser/-/terser-3.10.8.tgz",
|
||||
"integrity": "sha512-GQJHWJ/vbx0EgRk+lBMONMmKaT+ifeo/XgT/hi3KpzEEFOERVyFuJSVXH8grcmJjiqKY35ds8rBCxvABUeyyuQ==",
|
||||
"requires": {
|
||||
"commander": "~2.16.0",
|
||||
"commander": "~2.17.1",
|
||||
"source-map": "~0.6.1",
|
||||
"source-map-support": "~0.5.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "2.17.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz",
|
||||
"integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg=="
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
@@ -10332,11 +10062,6 @@
|
||||
"unist-util-is": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"universalify": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
|
||||
},
|
||||
"unset-value": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz",
|
||||
@@ -10680,20 +10405,6 @@
|
||||
"resolved": "https://registry.npmjs.org/x-is-string/-/x-is-string-0.1.0.tgz",
|
||||
"integrity": "sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI="
|
||||
},
|
||||
"xml2js": {
|
||||
"version": "0.4.19",
|
||||
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz",
|
||||
"integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==",
|
||||
"requires": {
|
||||
"sax": ">=0.6.0",
|
||||
"xmlbuilder": "~9.0.1"
|
||||
}
|
||||
},
|
||||
"xmlbuilder": {
|
||||
"version": "9.0.7",
|
||||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
|
||||
"integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0="
|
||||
},
|
||||
"xmldom": {
|
||||
"version": "0.1.27",
|
||||
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz",
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
"dependencies": {
|
||||
"7zip-bin": "^4.0.2",
|
||||
"async": "2.0.1",
|
||||
"aws-sdk": "^2.5.2",
|
||||
"babel-core": "5.8.38",
|
||||
"cheerio": "1.0.0-rc.2",
|
||||
"coffeelint": "1.15.7",
|
||||
"colors": "1.1.2",
|
||||
"donna": "1.0.16",
|
||||
"electron-chromedriver": "~3.0.0-beta.1",
|
||||
"electron-link": "0.3.3",
|
||||
"electron-mksnapshot": "~3.0.10",
|
||||
"electron-chromedriver": "~2.0",
|
||||
"electron-link": "0.3.2",
|
||||
"electron-mksnapshot": "~2.0",
|
||||
"electron-packager": "7.3.0",
|
||||
"electron-winstaller": "2.6.4",
|
||||
"fs-admin": "^0.1.5",
|
||||
@@ -28,10 +28,7 @@
|
||||
"npm": "6.2.0",
|
||||
"passwd-user": "2.1.0",
|
||||
"pegjs": "0.9.0",
|
||||
"publish-release": "^1.6.0",
|
||||
"random-seed": "^0.3.0",
|
||||
"request": "^2.87.0",
|
||||
"request-promise-native": "^1.0.5",
|
||||
"season": "5.3.0",
|
||||
"semver": "5.3.0",
|
||||
"standard": "8.4.0",
|
||||
|
||||
87
script/postprocess-junit-results
Executable file
87
script/postprocess-junit-results
Executable file
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const yargs = require('yargs')
|
||||
|
||||
const argv = yargs
|
||||
.usage('Usage: $0 [options]')
|
||||
.help('help')
|
||||
.option('search-folder', {
|
||||
string: true,
|
||||
demandOption: true,
|
||||
requiresArg: true,
|
||||
describe: 'Directory to search for JUnit XML results'
|
||||
})
|
||||
.option('test-results-files', {
|
||||
string: true,
|
||||
demandOption: true,
|
||||
requiresArg: true,
|
||||
describe: 'Glob that matches JUnit XML files within searchFolder'
|
||||
})
|
||||
.wrap(yargs.terminalWidth())
|
||||
.argv
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
const cheerio = require('cheerio')
|
||||
|
||||
function discoverTestFiles() {
|
||||
return new Promise((resolve, reject) => {
|
||||
glob(argv.testResultsFiles, {cwd: argv.searchFolder}, (err, paths) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(paths)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function postProcessJUnitXML(junitXmlPath) {
|
||||
const fullPath = path.resolve(argv.searchFolder, junitXmlPath)
|
||||
const friendlyName = path.basename(junitXmlPath, '.xml').replace(/-+/g, ' ')
|
||||
|
||||
console.log(`${fullPath}: loading`)
|
||||
|
||||
const original = await new Promise((resolve, reject) => {
|
||||
fs.readFile(fullPath, {encoding: 'utf8'}, (err, content) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(content)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const $ = cheerio.load(original, { xmlMode: true })
|
||||
$('testcase').attr('name', (i, oldName) => `[${friendlyName}] ${oldName}`)
|
||||
const modified = $.xml()
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
fs.writeFile(fullPath, modified, {encoding: 'utf8'}, err => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
console.log(`${fullPath}: complete`)
|
||||
}
|
||||
|
||||
;(async function() {
|
||||
const testResultFiles = await discoverTestFiles()
|
||||
console.log(`Post-processing ${testResultFiles.length} JUnit XML files`)
|
||||
|
||||
await Promise.all(
|
||||
testResultFiles.map(postProcessJUnitXML)
|
||||
)
|
||||
|
||||
console.log(`${testResultFiles.length} JUnit XML files complete`)
|
||||
})().then(
|
||||
() => process.exit(0),
|
||||
err => {
|
||||
console.error(err.stack || err)
|
||||
process.exit(1)
|
||||
}
|
||||
)
|
||||
5
script/postprocess-junit-results.cmd
Normal file
5
script/postprocess-junit-results.cmd
Normal file
@@ -0,0 +1,5 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\postprocess-junit-results" %*
|
||||
) ELSE (
|
||||
node "%~dp0\postprocess-junit-results" %*
|
||||
)
|
||||
@@ -1,91 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
const publishRelease = require('publish-release')
|
||||
const uploadToS3 = require('./lib/upload-to-s3')
|
||||
const uploadLinuxPackages = require('./lib/upload-linux-packages')
|
||||
|
||||
const CONFIG = require('./config')
|
||||
|
||||
const yargs = require('yargs')
|
||||
const argv = yargs
|
||||
.usage('Usage: $0 [options]')
|
||||
.help('help')
|
||||
.describe('assets-path', 'Path to the folder where all release assets are stored')
|
||||
.describe('s3-path', 'Indicates the S3 path in which the assets should be uploaded')
|
||||
.describe('create-github-release', 'Creates a GitHub release for this build, draft if release branch or public if Nightly')
|
||||
.describe('linux-repo-name', 'If specified, uploads Linux packages to the given repo name on packagecloud')
|
||||
.wrap(yargs.terminalWidth())
|
||||
.argv
|
||||
|
||||
const assetsPath = argv.assetsPath || path.join(CONFIG.repositoryRootPath, 'out')
|
||||
const assetsPattern = '/**/*(*.exe|*.zip|*.nupkg|*.tar.gz|*.rpm|*.deb|RELEASES*|atom-api.json)'
|
||||
const assets = glob.sync(assetsPattern, { root: assetsPath, nodir: true })
|
||||
const bucketPath = argv.s3Path || `releases/v${CONFIG.computedAppVersion}/`
|
||||
|
||||
if (!assets || assets.length === 0) {
|
||||
console.error(`No assets found under specified path: ${assetsPath}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
async function uploadRelease() {
|
||||
console.log(`Uploading ${assets.length} release assets for ${CONFIG.computedAppVersion} to S3 under '${bucketPath}'`)
|
||||
|
||||
await uploadToS3(
|
||||
process.env.ATOM_RELEASES_S3_KEY,
|
||||
process.env.ATOM_RELEASES_S3_SECRET,
|
||||
process.env.ATOM_RELEASES_S3_BUCKET,
|
||||
bucketPath,
|
||||
assets)
|
||||
|
||||
if (argv.linuxRepoName) {
|
||||
await uploadLinuxPackages(
|
||||
argv.linuxRepoName,
|
||||
process.env.PACKAGE_CLOUD_API_KEY,
|
||||
CONFIG.computedAppVersion,
|
||||
assets)
|
||||
} else {
|
||||
console.log("Skipping upload of Linux packages")
|
||||
}
|
||||
|
||||
if (argv.createGithubRelease) {
|
||||
console.log(`Creating GitHub release v${CONFIG.computedAppVersion}`)
|
||||
const release =
|
||||
await publishReleaseAsync({
|
||||
token: process.env.GITHUB_TOKEN,
|
||||
owner: 'atom',
|
||||
repo: CONFIG.channel !== 'nightly' ? 'atom' : 'atom-nightly-releases',
|
||||
name: CONFIG.computedAppVersion,
|
||||
tag: `v${CONFIG.computedAppVersion}`,
|
||||
draft: false,
|
||||
prerelease: CONFIG.channel !== 'stable',
|
||||
reuseRelease: true,
|
||||
skipIfPublished: true,
|
||||
assets
|
||||
})
|
||||
|
||||
console.log("Release published successfully: ", release.html_url)
|
||||
} else {
|
||||
console.log("Skipping GitHub release creation")
|
||||
}
|
||||
}
|
||||
|
||||
async function publishReleaseAsync(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
publishRelease(options, (err, release) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(release)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
uploadRelease().catch((err) => {
|
||||
console.error('An error occurred while uploading the release:\n\n', err)
|
||||
process.exit(1)
|
||||
})
|
||||
@@ -1,5 +0,0 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\publish-release" %*
|
||||
) ELSE (
|
||||
node "%~dp0\publish-release" %*
|
||||
)
|
||||
@@ -68,7 +68,8 @@ function prepareEnv (suiteName) {
|
||||
if (process.env.TEST_JUNIT_XML_ROOT) {
|
||||
// Tell Jasmine to output this suite's results as a JUnit XML file to a subdirectory of the root, so that a
|
||||
// CI system can interpret it.
|
||||
const outputPath = path.join(process.env.TEST_JUNIT_XML_ROOT, suiteName, 'test-results.xml')
|
||||
const fileName = suiteName + '.xml'
|
||||
const outputPath = path.join(process.env.TEST_JUNIT_XML_ROOT, fileName)
|
||||
env.TEST_JUNIT_XML_PATH = outputPath
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const argv = yargs
|
||||
.argv
|
||||
|
||||
async function getReleaseVersion () {
|
||||
let releaseVersion = appMetadata.version
|
||||
let releaseVersion = process.env.ATOM_RELEASE_VERSION || appMetadata.version
|
||||
if (argv.nightly) {
|
||||
const releases = await request({
|
||||
url: 'https://api.github.com/repos/atom/atom-nightly-releases/releases',
|
||||
@@ -42,16 +42,17 @@ async function getReleaseVersion () {
|
||||
if (!process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER) {
|
||||
// Only set the build number on non-PR builds as it causes build errors when
|
||||
// non-admins send PRs to the repo
|
||||
console.log(`##vso[build.updatebuildnumber]${releaseVersion}+${process.env.BUILD_BUILDNUMBER}`)
|
||||
console.log(`##vso[build.updatebuildnumber]${releaseVersion}+${process.env.BUILD_BUILDID}`)
|
||||
}
|
||||
|
||||
// Write out some variables that indicate whether artifacts should be uploaded
|
||||
const buildBranch = process.env.BUILD_SOURCEBRANCHNAME
|
||||
const isReleaseBranch = process.env.IS_RELEASE_BRANCH || argv.nightly || buildBranch.match(/\d\.\d+-releases/) !== null
|
||||
const isSignedZipBranch =
|
||||
process.env.IS_SIGNED_ZIP_BRANCH ||
|
||||
buildBranch.startsWith('electron-') ||
|
||||
buildBranch === 'master' && !process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
|
||||
!isReleaseBranch &&
|
||||
(process.env.IS_SIGNED_ZIP_BRANCH ||
|
||||
buildBranch.startsWith('electron-') ||
|
||||
buildBranch === 'master' && !process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER)
|
||||
console.log(`##vso[task.setvariable variable=IsReleaseBranch;isOutput=true]${isReleaseBranch}`)
|
||||
console.log(`##vso[task.setvariable variable=IsSignedZipBranch;isOutput=true]${isSignedZipBranch}`)
|
||||
}
|
||||
|
||||
135
script/vsts/lib/release-notes.js
Normal file
135
script/vsts/lib/release-notes.js
Normal file
@@ -0,0 +1,135 @@
|
||||
const semver = require('semver')
|
||||
const octokit = require('@octokit/rest')()
|
||||
const changelog = require('pr-changelog')
|
||||
const childProcess = require('child_process')
|
||||
|
||||
module.exports.getRelease = async function (releaseVersion, githubToken) {
|
||||
if (githubToken) {
|
||||
octokit.authenticate({
|
||||
type: 'oauth',
|
||||
token: githubToken
|
||||
})
|
||||
}
|
||||
|
||||
const releases = await octokit.repos.getReleases({owner: 'atom', repo: 'atom'})
|
||||
const release = releases.data.find(r => semver.eq(r.name, releaseVersion))
|
||||
|
||||
return {
|
||||
exists: release !== undefined,
|
||||
isDraft: release && release.draft,
|
||||
releaseNotes: release ? release.body : undefined
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.generateForVersion = async function (releaseVersion, githubToken, oldReleaseNotes) {
|
||||
let oldVersion = null
|
||||
let oldVersionName = null
|
||||
const parsedVersion = semver.parse(releaseVersion)
|
||||
const newVersionBranch = getBranchForVersion(parsedVersion)
|
||||
|
||||
if (githubToken) {
|
||||
changelog.setGithubAccessToken(githubToken)
|
||||
octokit.authenticate({
|
||||
type: 'oauth',
|
||||
token: githubToken
|
||||
})
|
||||
}
|
||||
|
||||
if (parsedVersion.prerelease && parsedVersion.prerelease[0] === 'beta0') {
|
||||
// For beta0 releases, stable hasn't been released yet so compare against
|
||||
// the stable version's release branch
|
||||
oldVersion = `${parsedVersion.major}.${parsedVersion.minor - 1}-releases`
|
||||
oldVersionName = `v${parsedVersion.major}.${parsedVersion.minor - 1}.0`
|
||||
} else {
|
||||
let releases = await octokit.repos.getReleases({owner: 'atom', repo: 'atom'})
|
||||
oldVersion = 'v' + getPreviousRelease(releaseVersion, releases.data).name
|
||||
oldVersionName = oldVersion
|
||||
}
|
||||
|
||||
const allChangesText = await changelog.getChangelog({
|
||||
owner: 'atom',
|
||||
repo: 'atom',
|
||||
fromTag: oldVersion,
|
||||
toTag: newVersionBranch,
|
||||
dependencyKey: 'packageDependencies',
|
||||
changelogFormatter: function ({pullRequests, owner, repo, fromTag, toTag}) {
|
||||
let prString = changelog.pullRequestsToString(pullRequests)
|
||||
let title = repo
|
||||
if (repo === 'atom') {
|
||||
title = 'Atom Core'
|
||||
fromTag = oldVersionName
|
||||
toTag = releaseVersion
|
||||
}
|
||||
return `### [${title}](https://github.com/${owner}/${repo})\n\n${fromTag}...${toTag}\n\n${prString}`
|
||||
}
|
||||
})
|
||||
|
||||
const writtenReleaseNotes =
|
||||
extractWrittenReleaseNotes(oldReleaseNotes) ||
|
||||
'**TODO**: Pull relevant changes here!'
|
||||
|
||||
return `## Notable Changes\n
|
||||
${writtenReleaseNotes}\n
|
||||
<details>
|
||||
<summary>All Changes</summary>\n
|
||||
${allChangesText}
|
||||
</details>
|
||||
`
|
||||
}
|
||||
|
||||
module.exports.generateForNightly = async function (releaseVersion, githubToken) {
|
||||
const releases = await octokit.repos.getReleases({owner: 'atom', repo: 'atom-nightly-releases'})
|
||||
const previousRelease = getPreviousRelease(releaseVersion, releases.data)
|
||||
const oldReleaseNotes = previousRelease ? previousRelease.body : undefined
|
||||
|
||||
const latestCommitResult = childProcess.spawnSync('git', ['rev-parse', '--short', 'HEAD'])
|
||||
|
||||
if (latestCommitResult && oldReleaseNotes) {
|
||||
const latestCommit = latestCommitResult.stdout.toString().trim()
|
||||
const extractMatch = oldReleaseNotes.match(/atom\/atom\/compare\/([0-9a-f]{5,40})\.\.\.([0-9a-f]{5,40})/)
|
||||
if (extractMatch) {
|
||||
return `### Click [here](https://github.com/atom/atom/compare/${extractMatch[2]}...${latestCommit}) to see the changes included with this release! :atom: :night_with_stars:`
|
||||
}
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
function extractWrittenReleaseNotes (oldReleaseNotes) {
|
||||
if (oldReleaseNotes) {
|
||||
const extractMatch = oldReleaseNotes.match(/^## Notable Changes\r\n([\s\S]*)<details>/)
|
||||
if (extractMatch && extractMatch[1]) {
|
||||
return extractMatch[1].trim()
|
||||
}
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
function getPreviousRelease (version, allReleases) {
|
||||
const versionIsStable = semver.prerelease(version) === null
|
||||
|
||||
// Make sure versions are sorted before using them
|
||||
allReleases.sort((v1, v2) => semver.rcompare(v1.name, v2.name))
|
||||
|
||||
for (let release of allReleases) {
|
||||
if (versionIsStable && semver.prerelease(release.name)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (semver.lt(release.name, version)) {
|
||||
return release
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function getBranchForVersion (version) {
|
||||
let parsedVersion = version
|
||||
if (!(version instanceof semver.SemVer)) {
|
||||
parsedVersion = semver.parse(version)
|
||||
}
|
||||
|
||||
return `${parsedVersion.major}.${parsedVersion.minor}-releases`
|
||||
}
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
# This has to be done separately because VSTS inexplicably
|
||||
# exits the script block after `npm install` completes.
|
||||
- script: |
|
||||
cd script
|
||||
cd script\vsts
|
||||
npm install
|
||||
displayName: npm install
|
||||
|
||||
@@ -54,7 +54,7 @@ jobs:
|
||||
displayName: Download Release Artifacts
|
||||
|
||||
- script: |
|
||||
$(Build.SourcesDirectory)\script\publish-release.cmd --create-github-release --assets-path "$(System.ArtifactsDirectory)"
|
||||
node $(Build.SourcesDirectory)\script\vsts\upload-artifacts.js --create-github-release --assets-path "$(System.ArtifactsDirectory)"
|
||||
env:
|
||||
GITHUB_TOKEN: $(GITHUB_TOKEN)
|
||||
ATOM_RELEASE_VERSION: $(ReleaseVersion)
|
||||
|
||||
1462
script/vsts/package-lock.json
generated
1462
script/vsts/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,15 @@
|
||||
"name": "atom-release-scripts",
|
||||
"description": "Atom release scripts",
|
||||
"dependencies": {
|
||||
"@octokit/rest": "^15.9.5",
|
||||
"aws-sdk": "^2.5.2",
|
||||
"download": "^7.1.0",
|
||||
"glob": "7.0.3",
|
||||
"pr-changelog": "^0.3.2",
|
||||
"publish-release": "^1.6.0",
|
||||
"request": "^2.87.0",
|
||||
"request-promise-native": "^1.0.5",
|
||||
"semver": "5.3.0",
|
||||
"yargs": "4.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,25 @@ jobs:
|
||||
CI: true
|
||||
CI_PROVIDER: VSTS
|
||||
ATOM_JASMINE_REPORTER: list
|
||||
TEST_JUNIT_XML_ROOT: $(Common.TestResultsDirectory)/junit
|
||||
displayName: Run tests
|
||||
condition: and(succeeded(), ne(variables['Atom.SkipTests'], 'true'))
|
||||
|
||||
- script: script/postprocess-junit-results --search-folder "${TEST_JUNIT_XML_ROOT}" --test-results-files "**/*.xml"
|
||||
env:
|
||||
TEST_JUNIT_XML_ROOT: $(Common.TestResultsDirectory)/junit
|
||||
displayName: Post-process test results
|
||||
condition: ne(variables['Atom.SkipTests'], 'true')
|
||||
|
||||
- task: PublishTestResults@2
|
||||
inputs:
|
||||
testResultsFormat: JUnit
|
||||
searchFolder: $(Common.TestResultsDirectory)/junit
|
||||
testResultsFiles: "**/*.xml"
|
||||
mergeTestResults: true
|
||||
testRunTitle: Linux
|
||||
condition: ne(variables['Atom.SkipTests'], 'true')
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
PathtoPublish: $(Build.SourcesDirectory)/out/atom.x86_64.rpm
|
||||
|
||||
@@ -45,13 +45,35 @@ jobs:
|
||||
CI: true
|
||||
CI_PROVIDER: VSTS
|
||||
ATOM_JASMINE_REPORTER: list
|
||||
TEST_JUNIT_XML_ROOT: $(Common.TestResultsDirectory)/junit
|
||||
displayName: Run tests
|
||||
condition: and(succeeded(), ne(variables['Atom.SkipTests'], 'true'))
|
||||
|
||||
- script: script/postprocess-junit-results --search-folder "${TEST_JUNIT_XML_ROOT}" --test-results-files "**/*.xml"
|
||||
env:
|
||||
TEST_JUNIT_XML_ROOT: $(Common.TestResultsDirectory)/junit
|
||||
displayName: Post-process test results
|
||||
condition: ne(variables['Atom.SkipTests'], 'true')
|
||||
|
||||
- task: PublishTestResults@2
|
||||
inputs:
|
||||
testResultsFormat: JUnit
|
||||
searchFolder: $(Common.TestResultsDirectory)/junit
|
||||
testResultsFiles: "**/*.xml"
|
||||
mergeTestResults: true
|
||||
testRunTitle: MacOS
|
||||
condition: ne(variables['Atom.SkipTests'], 'true')
|
||||
|
||||
- script: |
|
||||
cp $(Build.SourcesDirectory)/out/*.zip $(Build.ArtifactStagingDirectory)
|
||||
displayName: Stage Artifacts
|
||||
|
||||
- script: |
|
||||
mkdir -p $(Build.ArtifactStagingDirectory)/crash-reports
|
||||
cp ${HOME}/Library/Logs/DiagnosticReports/*.crash $(Build.ArtifactStagingDirectory)/crash-reports
|
||||
displayName: Stage Crash Reports
|
||||
condition: failed()
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
PathtoPublish: $(Build.ArtifactStagingDirectory)/atom-mac.zip
|
||||
@@ -75,3 +97,10 @@ jobs:
|
||||
ArtifactType: Container
|
||||
displayName: Upload atom-api.json
|
||||
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
PathtoPublish: $(Build.ArtifactStagingDirectory)/crash-reports
|
||||
ArtifactName: crash-reports.zip
|
||||
displayName: Upload Crash Reports
|
||||
condition: failed()
|
||||
|
||||
@@ -70,10 +70,28 @@ jobs:
|
||||
CI: true
|
||||
CI_PROVIDER: VSTS
|
||||
ATOM_JASMINE_REPORTER: list
|
||||
TEST_JUNIT_XML_ROOT: $(Common.TestResultsDirectory)\junit
|
||||
BUILD_ARCH: $(buildArch)
|
||||
displayName: Run tests
|
||||
condition: and(succeeded(), ne(variables['Atom.SkipTests'], 'true'))
|
||||
|
||||
- script: >
|
||||
node script\vsts\windows-run.js script\postprocess-junit-results.cmd
|
||||
--search-folder %TEST_JUNIT_XML_ROOT% --test-results-files "**/*.xml"
|
||||
env:
|
||||
TEST_JUNIT_XML_ROOT: $(Common.TestResultsDirectory)\junit
|
||||
displayName: Post-process test results
|
||||
condition: ne(variables['Atom.SkipTests'], 'true')
|
||||
|
||||
- task: PublishTestResults@2
|
||||
inputs:
|
||||
testResultsFormat: JUnit
|
||||
searchFolder: $(Common.TestResultsDirectory)\junit
|
||||
testResultsFiles: "**/*.xml"
|
||||
mergeTestResults: true
|
||||
testRunTitle: Windows $(buildArch)
|
||||
condition: ne(variables['Atom.SkipTests'], 'true')
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
PathtoPublish: $(Build.SourcesDirectory)/out/atom-x64-windows.zip
|
||||
@@ -98,6 +116,15 @@ jobs:
|
||||
displayName: Upload atom-x64-$(ReleaseVersion)-full.nupkg
|
||||
condition: and(succeeded(), eq(variables['IsReleaseBranch'], 'true'), eq(variables['buildArch'], 'x64'))
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
PathtoPublish: $(Build.SourcesDirectory)/out/atom-x64-$(ReleaseVersion)-delta.nupkg
|
||||
ArtifactName: atom-x64-$(ReleaseVersion)-delta.nupkg
|
||||
ArtifactType: Container
|
||||
displayName: Upload atom-x64-$(ReleaseVersion)-delta.nupkg
|
||||
condition: and(succeeded(), eq(variables['IsReleaseBranch'], 'true'), eq(variables['buildArch'], 'x64'))
|
||||
continueOnError: true # Nightly builds don't produce delta packages yet, so don't fail the build
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
PathtoPublish: $(Build.SourcesDirectory)/out/RELEASES-x64
|
||||
@@ -130,6 +157,15 @@ jobs:
|
||||
displayName: Upload atom-$(ReleaseVersion)-full.nupkg
|
||||
condition: and(succeeded(), eq(variables['IsReleaseBranch'], 'true'), eq(variables['buildArch'], 'x86'))
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
PathtoPublish: $(Build.SourcesDirectory)/out/atom-$(ReleaseVersion)-delta.nupkg
|
||||
ArtifactName: atom-$(ReleaseVersion)-delta.nupkg
|
||||
ArtifactType: Container
|
||||
displayName: Upload atom-$(ReleaseVersion)-delta.nupkg
|
||||
condition: and(succeeded(), eq(variables['IsReleaseBranch'], 'true'), eq(variables['buildArch'], 'x86'))
|
||||
continueOnError: true # Nightly builds don't produce delta packages yet, so don't fail the build
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
PathtoPublish: $(Build.SourcesDirectory)/out/RELEASES
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
trigger:
|
||||
- master
|
||||
- 1.* # VSTS only supports wildcards at the end
|
||||
- electron-*
|
||||
|
||||
resources:
|
||||
containers:
|
||||
@@ -49,7 +50,7 @@ jobs:
|
||||
# This has to be done separately because VSTS inexplicably
|
||||
# exits the script block after `npm install` completes.
|
||||
- script: |
|
||||
cd script
|
||||
cd script\vsts
|
||||
npm install
|
||||
displayName: npm install
|
||||
|
||||
@@ -60,12 +61,23 @@ jobs:
|
||||
displayName: Download Release Artifacts
|
||||
|
||||
- script: |
|
||||
$(Build.SourcesDirectory)\script\publish-release.cmd --assets-path "$(System.ArtifactsDirectory)" --s3-path "vsts-artifacts/$(Build.BuildId)/"
|
||||
node $(Build.SourcesDirectory)\script\vsts\upload-artifacts.js --create-github-release --assets-path "$(System.ArtifactsDirectory)" --linux-repo-name "atom-staging"
|
||||
env:
|
||||
GITHUB_TOKEN: $(GITHUB_TOKEN)
|
||||
ATOM_RELEASE_VERSION: $(ReleaseVersion)
|
||||
ATOM_RELEASES_S3_KEY: $(ATOM_RELEASES_S3_KEY)
|
||||
ATOM_RELEASES_S3_SECRET: $(ATOM_RELEASES_S3_SECRET)
|
||||
ATOM_RELEASES_S3_BUCKET: $(ATOM_RELEASES_S3_BUCKET)
|
||||
PACKAGE_CLOUD_API_KEY: $(PACKAGE_CLOUD_API_KEY)
|
||||
displayName: Create Draft Release
|
||||
condition: and(succeeded(), eq(variables['IsReleaseBranch'], 'true'))
|
||||
|
||||
- script: |
|
||||
node $(Build.SourcesDirectory)\script\vsts\upload-artifacts.js --assets-path "$(System.ArtifactsDirectory)" --s3-path "vsts-artifacts/$(Build.BuildId)/"
|
||||
env:
|
||||
ATOM_RELEASE_VERSION: $(ReleaseVersion)
|
||||
ATOM_RELEASES_S3_KEY: $(ATOM_RELEASES_S3_KEY)
|
||||
ATOM_RELEASES_S3_SECRET: $(ATOM_RELEASES_S3_SECRET)
|
||||
ATOM_RELEASES_S3_BUCKET: $(ATOM_RELEASES_S3_BUCKET)
|
||||
displayName: Upload CI Artifacts to S3
|
||||
condition: and(succeeded(), eq(variables['IsSignedZipBranch'], 'true'))
|
||||
|
||||
136
script/vsts/upload-artifacts.js
Normal file
136
script/vsts/upload-artifacts.js
Normal file
@@ -0,0 +1,136 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('fs')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
const publishRelease = require('publish-release')
|
||||
const releaseNotes = require('./lib/release-notes')
|
||||
const uploadToS3 = require('./lib/upload-to-s3')
|
||||
const uploadLinuxPackages = require('./lib/upload-linux-packages')
|
||||
|
||||
const CONFIG = require('../config')
|
||||
|
||||
const yargs = require('yargs')
|
||||
const argv = yargs
|
||||
.usage('Usage: $0 [options]')
|
||||
.help('help')
|
||||
.describe('assets-path', 'Path to the folder where all release assets are stored')
|
||||
.describe('s3-path', 'Indicates the S3 path in which the assets should be uploaded')
|
||||
.describe('create-github-release', 'Creates a GitHub release for this build, draft if release branch or public if Nightly')
|
||||
.describe('linux-repo-name', 'If specified, uploads Linux packages to the given repo name on packagecloud')
|
||||
.wrap(yargs.terminalWidth())
|
||||
.argv
|
||||
|
||||
const releaseVersion = CONFIG.computedAppVersion
|
||||
const isNightlyRelease = CONFIG.channel === 'nightly'
|
||||
const assetsPath = argv.assetsPath || CONFIG.buildOutputPath
|
||||
const assetsPattern = '/**/*(*.exe|*.zip|*.nupkg|*.tar.gz|*.rpm|*.deb|RELEASES*|atom-api.json)'
|
||||
const assets = glob.sync(assetsPattern, { root: assetsPath, nodir: true })
|
||||
const bucketPath = argv.s3Path || `releases/v${releaseVersion}/`
|
||||
|
||||
if (!assets || assets.length === 0) {
|
||||
console.error(`No assets found under specified path: ${assetsPath}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
async function uploadArtifacts () {
|
||||
let releaseForVersion =
|
||||
await releaseNotes.getRelease(
|
||||
releaseVersion,
|
||||
process.env.GITHUB_TOKEN)
|
||||
|
||||
if (releaseForVersion.exists && !releaseForVersion.isDraft) {
|
||||
console.log(`Published release already exists for ${releaseVersion}, skipping upload.`)
|
||||
return
|
||||
}
|
||||
|
||||
console.log(`Uploading ${assets.length} release assets for ${releaseVersion} to S3 under '${bucketPath}'`)
|
||||
|
||||
await uploadToS3(
|
||||
process.env.ATOM_RELEASES_S3_KEY,
|
||||
process.env.ATOM_RELEASES_S3_SECRET,
|
||||
process.env.ATOM_RELEASES_S3_BUCKET,
|
||||
bucketPath,
|
||||
assets)
|
||||
|
||||
if (argv.linuxRepoName) {
|
||||
await uploadLinuxPackages(
|
||||
argv.linuxRepoName,
|
||||
process.env.PACKAGE_CLOUD_API_KEY,
|
||||
releaseVersion,
|
||||
assets)
|
||||
} else {
|
||||
console.log('\nNo Linux package repo name specified, skipping Linux package upload.')
|
||||
}
|
||||
|
||||
const oldReleaseNotes = releaseForVersion.releaseNotes
|
||||
if (oldReleaseNotes) {
|
||||
const oldReleaseNotesPath = path.resolve(os.tmpdir(), 'OLD_RELEASE_NOTES.md')
|
||||
console.log(`Saving existing ${releaseVersion} release notes to ${oldReleaseNotesPath}`)
|
||||
fs.writeFileSync(oldReleaseNotesPath, oldReleaseNotes, 'utf8')
|
||||
|
||||
// This line instructs VSTS to upload the file as an artifact
|
||||
console.log(`##vso[artifact.upload containerfolder=OldReleaseNotes;artifactname=OldReleaseNotes;]${oldReleaseNotesPath}`)
|
||||
}
|
||||
|
||||
if (argv.createGithubRelease) {
|
||||
console.log(`\nGenerating new release notes for ${releaseVersion}`)
|
||||
let newReleaseNotes = ''
|
||||
if (isNightlyRelease) {
|
||||
newReleaseNotes =
|
||||
await releaseNotes.generateForNightly(
|
||||
releaseVersion,
|
||||
process.env.GITHUB_TOKEN,
|
||||
oldReleaseNotes)
|
||||
} else {
|
||||
newReleaseNotes =
|
||||
await releaseNotes.generateForVersion(
|
||||
releaseVersion,
|
||||
process.env.GITHUB_TOKEN,
|
||||
oldReleaseNotes)
|
||||
}
|
||||
|
||||
console.log(`New release notes:\n\n${newReleaseNotes}`)
|
||||
|
||||
console.log(`Creating GitHub release v${releaseVersion}`)
|
||||
const release =
|
||||
await publishReleaseAsync({
|
||||
token: process.env.GITHUB_TOKEN,
|
||||
owner: 'atom',
|
||||
repo: !isNightlyRelease ? 'atom' : 'atom-nightly-releases',
|
||||
name: CONFIG.computedAppVersion,
|
||||
notes: newReleaseNotes,
|
||||
tag: `v${CONFIG.computedAppVersion}`,
|
||||
draft: !isNightlyRelease,
|
||||
prerelease: CONFIG.channel !== 'stable',
|
||||
editRelease: true,
|
||||
reuseRelease: true,
|
||||
skipIfPublished: true,
|
||||
assets
|
||||
})
|
||||
|
||||
console.log('Release published successfully: ', release.html_url)
|
||||
} else {
|
||||
console.log('Skipping GitHub release creation')
|
||||
}
|
||||
}
|
||||
|
||||
async function publishReleaseAsync (options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
publishRelease(options, (err, release) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(release)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Wrap the call the async function and catch errors from its promise because
|
||||
// Node.js doesn't yet allow use of await at the script scope
|
||||
uploadArtifacts().catch(err => {
|
||||
console.error('An error occurred while uploading the release:\n\n', err)
|
||||
process.exit(1)
|
||||
})
|
||||
@@ -1,14 +1,13 @@
|
||||
/** @babel */
|
||||
|
||||
import {it, fit, ffit, fffit, beforeEach, afterEach} from './async-spec-helpers'
|
||||
import ApplicationDelegate from '../src/application-delegate'
|
||||
|
||||
describe('ApplicationDelegate', function () {
|
||||
describe('set/getTemporaryWindowState', function () {
|
||||
it('can serialize object trees containing redundant child object references', async function () {
|
||||
const applicationDelegate = new ApplicationDelegate()
|
||||
const childObject = {c: 1}
|
||||
const sentObject = {a: childObject, b: childObject}
|
||||
const childObject = { c: 1 }
|
||||
const sentObject = { a: childObject, b: childObject }
|
||||
|
||||
await applicationDelegate.setTemporaryWindowState(sentObject)
|
||||
const receivedObject = await applicationDelegate.getTemporaryWindowState()
|
||||
|
||||
@@ -1,38 +1,7 @@
|
||||
function beforeEach (fn) {
|
||||
global.beforeEach(() => {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function afterEach (fn) {
|
||||
global.afterEach(() => {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
;['it', 'fit', 'ffit', 'fffit'].forEach(name => {
|
||||
exports[name] = (description, fn) => {
|
||||
if (fn === undefined) {
|
||||
global[name](description)
|
||||
return
|
||||
}
|
||||
|
||||
global[name](description, () => {
|
||||
const result = fn()
|
||||
if (result instanceof Promise) {
|
||||
waitsForPromise(() => result)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
async function conditionPromise (condition, description = 'anonymous condition') {
|
||||
async function conditionPromise (
|
||||
condition,
|
||||
description = 'anonymous condition'
|
||||
) {
|
||||
const startTime = Date.now()
|
||||
|
||||
while (true) {
|
||||
@@ -54,16 +23,6 @@ function timeoutPromise (timeout) {
|
||||
})
|
||||
}
|
||||
|
||||
function waitsForPromise (fn) {
|
||||
const promise = fn()
|
||||
global.waitsFor('spec promise to resolve', done => {
|
||||
promise.then(done, error => {
|
||||
jasmine.getEnv().currentSpec.fail(error)
|
||||
done()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function emitterEventPromise (emitter, event, timeout = 15000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeoutHandle = setTimeout(() => {
|
||||
@@ -76,34 +35,6 @@ function emitterEventPromise (emitter, event, timeout = 15000) {
|
||||
})
|
||||
}
|
||||
|
||||
function promisify (original) {
|
||||
return function (...args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
args.push((err, ...results) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(...results)
|
||||
}
|
||||
})
|
||||
|
||||
return original(...args)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function promisifySome (obj, fnNames) {
|
||||
const result = {}
|
||||
for (const fnName of fnNames) {
|
||||
result[fnName] = promisify(obj[fnName])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
exports.afterEach = afterEach
|
||||
exports.beforeEach = beforeEach
|
||||
exports.conditionPromise = conditionPromise
|
||||
exports.emitterEventPromise = emitterEventPromise
|
||||
exports.promisify = promisify
|
||||
exports.promisifySome = promisifySome
|
||||
exports.timeoutPromise = timeoutPromise
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const {it, fit, ffit, beforeEach, afterEach, conditionPromise} = require('./async-spec-helpers')
|
||||
const _ = require('underscore-plus')
|
||||
const { conditionPromise } = require('./async-spec-helpers')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const temp = require('temp').track()
|
||||
@@ -15,26 +14,26 @@ describe('AtomEnvironment', () => {
|
||||
describe('window sizing methods', () => {
|
||||
describe('::getPosition and ::setPosition', () => {
|
||||
let originalPosition = null
|
||||
beforeEach(() => originalPosition = atom.getPosition())
|
||||
beforeEach(() => (originalPosition = atom.getPosition()))
|
||||
|
||||
afterEach(() => atom.setPosition(originalPosition.x, originalPosition.y))
|
||||
|
||||
it('sets the position of the window, and can retrieve the position just set', () => {
|
||||
atom.setPosition(22, 45)
|
||||
expect(atom.getPosition()).toEqual({x: 22, y: 45})
|
||||
expect(atom.getPosition()).toEqual({ x: 22, y: 45 })
|
||||
})
|
||||
})
|
||||
|
||||
describe('::getSize and ::setSize', () => {
|
||||
let originalSize = null
|
||||
beforeEach(() => originalSize = atom.getSize())
|
||||
beforeEach(() => (originalSize = atom.getSize()))
|
||||
afterEach(() => atom.setSize(originalSize.width, originalSize.height))
|
||||
|
||||
it('sets the size of the window, and can retrieve the size just set', async () => {
|
||||
const newWidth = originalSize.width - 12
|
||||
const newHeight = originalSize.height - 23
|
||||
await atom.setSize(newWidth, newHeight)
|
||||
expect(atom.getSize()).toEqual({width: newWidth, height: newHeight})
|
||||
expect(atom.getSize()).toEqual({ width: newWidth, height: newHeight })
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -67,9 +66,9 @@ describe('AtomEnvironment', () => {
|
||||
|
||||
it('will open the dev tools when an error is triggered', async () => {
|
||||
try {
|
||||
a + 1
|
||||
a + 1 // eslint-disable-line no-undef
|
||||
} catch (e) {
|
||||
window.onerror.call(window, e.toString(), 'abc', 2, 3, e)
|
||||
window.onerror(e.toString(), 'abc', 2, 3, e)
|
||||
}
|
||||
|
||||
await devToolsPromise
|
||||
@@ -88,10 +87,10 @@ describe('AtomEnvironment', () => {
|
||||
let error = null
|
||||
atom.onWillThrowError(willThrowSpy)
|
||||
try {
|
||||
a + 1
|
||||
a + 1 // eslint-disable-line no-undef
|
||||
} catch (e) {
|
||||
error = e
|
||||
window.onerror.call(window, e.toString(), 'abc', 2, 3, e)
|
||||
window.onerror(e.toString(), 'abc', 2, 3, e)
|
||||
}
|
||||
|
||||
delete willThrowSpy.mostRecentCall.args[0].preventDefault
|
||||
@@ -109,9 +108,9 @@ describe('AtomEnvironment', () => {
|
||||
atom.onWillThrowError(willThrowSpy)
|
||||
|
||||
try {
|
||||
a + 1
|
||||
a + 1 // eslint-disable-line no-undef
|
||||
} catch (e) {
|
||||
window.onerror.call(window, e.toString(), 'abc', 2, 3, e)
|
||||
window.onerror(e.toString(), 'abc', 2, 3, e)
|
||||
}
|
||||
|
||||
expect(willThrowSpy).toHaveBeenCalled()
|
||||
@@ -122,16 +121,16 @@ describe('AtomEnvironment', () => {
|
||||
|
||||
describe('::onDidThrowError', () => {
|
||||
let didThrowSpy = null
|
||||
beforeEach(() => didThrowSpy = jasmine.createSpy())
|
||||
beforeEach(() => (didThrowSpy = jasmine.createSpy()))
|
||||
|
||||
it('is called when there is an error', () => {
|
||||
let error = null
|
||||
atom.onDidThrowError(didThrowSpy)
|
||||
try {
|
||||
a + 1
|
||||
a + 1 // eslint-disable-line no-undef
|
||||
} catch (e) {
|
||||
error = e
|
||||
window.onerror.call(window, e.toString(), 'abc', 2, 3, e)
|
||||
window.onerror(e.toString(), 'abc', 2, 3, e)
|
||||
}
|
||||
expect(didThrowSpy).toHaveBeenCalledWith({
|
||||
message: error.toString(),
|
||||
@@ -165,22 +164,24 @@ describe('AtomEnvironment', () => {
|
||||
describe('if passed a callback function', () => {
|
||||
it("calls the callback with the assertion failure's error object", () => {
|
||||
let error = null
|
||||
atom.assert(false, 'a == b', e => error = e)
|
||||
atom.assert(false, 'a == b', e => (error = e))
|
||||
expect(error).toBe(errors[0])
|
||||
})
|
||||
})
|
||||
|
||||
describe('if passed metadata', () => {
|
||||
it("assigns the metadata on the assertion failure's error object", () => {
|
||||
atom.assert(false, 'a == b', {foo: 'bar'})
|
||||
expect(errors[0].metadata).toEqual({foo: 'bar'})
|
||||
atom.assert(false, 'a == b', { foo: 'bar' })
|
||||
expect(errors[0].metadata).toEqual({ foo: 'bar' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('when Atom has been built from source', () => {
|
||||
it('throws an error', () => {
|
||||
atom.isReleasedVersion.andReturn(false)
|
||||
expect(() => atom.assert(false, 'testing')).toThrow('Assertion failed: testing')
|
||||
expect(() => atom.assert(false, 'testing')).toThrow(
|
||||
'Assertion failed: testing'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -195,9 +196,9 @@ describe('AtomEnvironment', () => {
|
||||
})
|
||||
|
||||
describe('saving and loading', () => {
|
||||
beforeEach(() => atom.enablePersistence = true)
|
||||
beforeEach(() => (atom.enablePersistence = true))
|
||||
|
||||
afterEach(() => atom.enablePersistence = false)
|
||||
afterEach(() => (atom.enablePersistence = false))
|
||||
|
||||
it('selects the state based on the current project paths', async () => {
|
||||
jasmine.useRealClock()
|
||||
@@ -210,7 +211,7 @@ describe('AtomEnvironment', () => {
|
||||
})
|
||||
|
||||
spyOn(atom, 'getLoadSettings').andCallFake(() => loadSettings)
|
||||
spyOn(atom, 'serialize').andReturn({stuff: 'cool'})
|
||||
spyOn(atom, 'serialize').andReturn({ stuff: 'cool' })
|
||||
|
||||
atom.project.setPaths([dir1, dir2])
|
||||
|
||||
@@ -221,7 +222,7 @@ describe('AtomEnvironment', () => {
|
||||
expect(await atom.loadState()).toBeFalsy()
|
||||
|
||||
loadSettings.initialPaths = [dir2, dir1]
|
||||
expect(await atom.loadState()).toEqual({stuff: 'cool'})
|
||||
expect(await atom.loadState()).toEqual({ stuff: 'cool' })
|
||||
})
|
||||
|
||||
it('saves state when the CPU is idle after a keydown or mousedown event', () => {
|
||||
@@ -231,7 +232,9 @@ describe('AtomEnvironment', () => {
|
||||
const idleCallbacks = []
|
||||
atomEnv.initialize({
|
||||
window: {
|
||||
requestIdleCallback (callback) { idleCallbacks.push(callback) },
|
||||
requestIdleCallback (callback) {
|
||||
idleCallbacks.push(callback)
|
||||
},
|
||||
addEventListener () {},
|
||||
removeEventListener () {}
|
||||
},
|
||||
@@ -244,16 +247,16 @@ describe('AtomEnvironment', () => {
|
||||
atomEnv.document.dispatchEvent(keydown)
|
||||
advanceClock(atomEnv.saveStateDebounceInterval)
|
||||
idleCallbacks.shift()()
|
||||
expect(atomEnv.saveState).toHaveBeenCalledWith({isUnloading: false})
|
||||
expect(atomEnv.saveState).not.toHaveBeenCalledWith({isUnloading: true})
|
||||
expect(atomEnv.saveState).toHaveBeenCalledWith({ isUnloading: false })
|
||||
expect(atomEnv.saveState).not.toHaveBeenCalledWith({ isUnloading: true })
|
||||
|
||||
atomEnv.saveState.reset()
|
||||
const mousedown = new MouseEvent('mousedown')
|
||||
atomEnv.document.dispatchEvent(mousedown)
|
||||
advanceClock(atomEnv.saveStateDebounceInterval)
|
||||
idleCallbacks.shift()()
|
||||
expect(atomEnv.saveState).toHaveBeenCalledWith({isUnloading: false})
|
||||
expect(atomEnv.saveState).not.toHaveBeenCalledWith({isUnloading: true})
|
||||
expect(atomEnv.saveState).toHaveBeenCalledWith({ isUnloading: false })
|
||||
expect(atomEnv.saveState).not.toHaveBeenCalledWith({ isUnloading: true })
|
||||
|
||||
atomEnv.destroy()
|
||||
})
|
||||
@@ -265,7 +268,9 @@ describe('AtomEnvironment', () => {
|
||||
const idleCallbacks = []
|
||||
atomEnv.initialize({
|
||||
window: {
|
||||
requestIdleCallback (callback) { idleCallbacks.push(callback) },
|
||||
requestIdleCallback (callback) {
|
||||
idleCallbacks.push(callback)
|
||||
},
|
||||
addEventListener () {},
|
||||
removeEventListener () {}
|
||||
},
|
||||
@@ -278,7 +283,7 @@ describe('AtomEnvironment', () => {
|
||||
atomEnv.document.dispatchEvent(mousedown)
|
||||
expect(atomEnv.saveState).not.toHaveBeenCalled()
|
||||
await atomEnv.prepareToUnloadEditorWindow()
|
||||
expect(atomEnv.saveState).toHaveBeenCalledWith({isUnloading: true})
|
||||
expect(atomEnv.saveState).toHaveBeenCalledWith({ isUnloading: true })
|
||||
|
||||
advanceClock(atomEnv.saveStateDebounceInterval)
|
||||
idleCallbacks.shift()()
|
||||
@@ -294,11 +299,13 @@ describe('AtomEnvironment', () => {
|
||||
})
|
||||
|
||||
it('serializes the project state with all the options supplied in saveState', async () => {
|
||||
spyOn(atom.project, 'serialize').andReturn({foo: 42})
|
||||
spyOn(atom.project, 'serialize').andReturn({ foo: 42 })
|
||||
|
||||
await atom.saveState({anyOption: 'any option'})
|
||||
await atom.saveState({ anyOption: 'any option' })
|
||||
expect(atom.project.serialize.calls.length).toBe(1)
|
||||
expect(atom.project.serialize.mostRecentCall.args[0]).toEqual({anyOption: 'any option'})
|
||||
expect(atom.project.serialize.mostRecentCall.args[0]).toEqual({
|
||||
anyOption: 'any option'
|
||||
})
|
||||
})
|
||||
|
||||
it('serializes the text editor registry', async () => {
|
||||
@@ -309,20 +316,22 @@ describe('AtomEnvironment', () => {
|
||||
const atom2 = new AtomEnvironment({
|
||||
applicationDelegate: atom.applicationDelegate,
|
||||
window: document.createElement('div'),
|
||||
document: Object.assign(
|
||||
document.createElement('div'),
|
||||
{
|
||||
body: document.createElement('div'),
|
||||
head: document.createElement('div')
|
||||
}
|
||||
)
|
||||
document: Object.assign(document.createElement('div'), {
|
||||
body: document.createElement('div'),
|
||||
head: document.createElement('div')
|
||||
})
|
||||
})
|
||||
atom2.initialize({document, window})
|
||||
atom2.initialize({ document, window })
|
||||
|
||||
await atom2.deserialize(atom.serialize())
|
||||
await atom2.packages.activatePackage('language-text')
|
||||
const editor2 = atom2.workspace.getActiveTextEditor()
|
||||
expect(editor2.getBuffer().getLanguageMode().getLanguageId()).toBe('text.plain')
|
||||
expect(
|
||||
editor2
|
||||
.getBuffer()
|
||||
.getLanguageMode()
|
||||
.getLanguageId()
|
||||
).toBe('text.plain')
|
||||
atom2.destroy()
|
||||
})
|
||||
|
||||
@@ -335,10 +344,13 @@ describe('AtomEnvironment', () => {
|
||||
})
|
||||
spyOn(atom.notifications, 'addError')
|
||||
|
||||
await atom.deserialize({project: 'should work'})
|
||||
expect(atom.notifications.addError).toHaveBeenCalledWith('Unable to open project directory', {
|
||||
description: 'Project directory `/foo` is no longer on disk.'
|
||||
})
|
||||
await atom.deserialize({ project: 'should work' })
|
||||
expect(atom.notifications.addError).toHaveBeenCalledWith(
|
||||
'Unable to open project directory',
|
||||
{
|
||||
description: 'Project directory `/foo` is no longer on disk.'
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('accumulates and reports two errors with one notification', async () => {
|
||||
@@ -349,10 +361,14 @@ describe('AtomEnvironment', () => {
|
||||
})
|
||||
spyOn(atom.notifications, 'addError')
|
||||
|
||||
await atom.deserialize({project: 'should work'})
|
||||
expect(atom.notifications.addError).toHaveBeenCalledWith('Unable to open 2 project directories', {
|
||||
description: 'Project directories `/foo` and `/wat` are no longer on disk.'
|
||||
})
|
||||
await atom.deserialize({ project: 'should work' })
|
||||
expect(atom.notifications.addError).toHaveBeenCalledWith(
|
||||
'Unable to open 2 project directories',
|
||||
{
|
||||
description:
|
||||
'Project directories `/foo` and `/wat` are no longer on disk.'
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('accumulates and reports three+ errors with one notification', async () => {
|
||||
@@ -363,17 +379,23 @@ describe('AtomEnvironment', () => {
|
||||
})
|
||||
spyOn(atom.notifications, 'addError')
|
||||
|
||||
await atom.deserialize({project: 'should work'})
|
||||
expect(atom.notifications.addError).toHaveBeenCalledWith('Unable to open 4 project directories', {
|
||||
description: 'Project directories `/foo`, `/wat`, `/stuff`, and `/things` are no longer on disk.'
|
||||
})
|
||||
await atom.deserialize({ project: 'should work' })
|
||||
expect(atom.notifications.addError).toHaveBeenCalledWith(
|
||||
'Unable to open 4 project directories',
|
||||
{
|
||||
description:
|
||||
'Project directories `/foo`, `/wat`, `/stuff`, and `/things` are no longer on disk.'
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('openInitialEmptyEditorIfNecessary', () => {
|
||||
describe('when there are no paths set', () => {
|
||||
beforeEach(() => spyOn(atom, 'getLoadSettings').andReturn({initialPaths: []}))
|
||||
beforeEach(() =>
|
||||
spyOn(atom, 'getLoadSettings').andReturn({ initialPaths: [] })
|
||||
)
|
||||
|
||||
it('opens an empty buffer', () => {
|
||||
spyOn(atom.workspace, 'open')
|
||||
@@ -396,7 +418,9 @@ describe('AtomEnvironment', () => {
|
||||
|
||||
describe('when the project has a path', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(atom, 'getLoadSettings').andReturn({initialPaths: ['something']})
|
||||
spyOn(atom, 'getLoadSettings').andReturn({
|
||||
initialPaths: ['something']
|
||||
})
|
||||
spyOn(atom.workspace, 'open')
|
||||
})
|
||||
|
||||
@@ -410,7 +434,6 @@ describe('AtomEnvironment', () => {
|
||||
describe('adding a project folder', () => {
|
||||
it('does nothing if the user dismisses the file picker', () => {
|
||||
const initialPaths = atom.project.getPaths()
|
||||
const tempDirectory = temp.mkdirSync('a-new-directory')
|
||||
spyOn(atom, 'pickFolder').andCallFake(callback => callback(null))
|
||||
atom.addProjectFolder()
|
||||
expect(atom.project.getPaths()).toEqual(initialPaths)
|
||||
@@ -423,9 +446,11 @@ describe('AtomEnvironment', () => {
|
||||
})
|
||||
|
||||
it('adds the selected folder to the project', async () => {
|
||||
const initialPaths = atom.project.setPaths([])
|
||||
atom.project.setPaths([])
|
||||
const tempDirectory = temp.mkdirSync('a-new-directory')
|
||||
spyOn(atom, 'pickFolder').andCallFake(callback => callback([tempDirectory]))
|
||||
spyOn(atom, 'pickFolder').andCallFake(callback =>
|
||||
callback([tempDirectory])
|
||||
)
|
||||
await atom.addProjectFolder()
|
||||
expect(atom.project.getPaths()).toEqual([tempDirectory])
|
||||
expect(atom.attemptRestoreProjectStateForPaths).not.toHaveBeenCalled()
|
||||
@@ -437,7 +462,9 @@ describe('AtomEnvironment', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(atom, 'getStateKey').andCallFake(dirs => dirs.join(':'))
|
||||
spyOn(atom, 'loadState').andCallFake(async (key) => key === __dirname ? state : null)
|
||||
spyOn(atom, 'loadState').andCallFake(async key =>
|
||||
key === __dirname ? state : null
|
||||
)
|
||||
spyOn(atom, 'attemptRestoreProjectStateForPaths')
|
||||
spyOn(atom, 'pickFolder').andCallFake(callback => callback([__dirname]))
|
||||
atom.project.setPaths([])
|
||||
@@ -446,7 +473,10 @@ describe('AtomEnvironment', () => {
|
||||
describe('when there are no project folders', () => {
|
||||
it('attempts to restore the project state', async () => {
|
||||
await atom.addProjectFolder()
|
||||
expect(atom.attemptRestoreProjectStateForPaths).toHaveBeenCalledWith(state, [__dirname])
|
||||
expect(atom.attemptRestoreProjectStateForPaths).toHaveBeenCalledWith(
|
||||
state,
|
||||
[__dirname]
|
||||
)
|
||||
expect(atom.project.getPaths()).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -481,7 +511,9 @@ describe('AtomEnvironment', () => {
|
||||
fs.writeFileSync(filePath2, 'def')
|
||||
fs.writeFileSync(filePath3, 'ghi')
|
||||
|
||||
const env1 = new AtomEnvironment({applicationDelegate: atom.applicationDelegate})
|
||||
const env1 = new AtomEnvironment({
|
||||
applicationDelegate: atom.applicationDelegate
|
||||
})
|
||||
env1.project.setPaths([projectPath])
|
||||
await env1.workspace.open(filePath1)
|
||||
await env1.workspace.open(filePath2)
|
||||
@@ -489,8 +521,14 @@ describe('AtomEnvironment', () => {
|
||||
const env1State = env1.serialize()
|
||||
env1.destroy()
|
||||
|
||||
const env2 = new AtomEnvironment({applicationDelegate: atom.applicationDelegate})
|
||||
await env2.attemptRestoreProjectStateForPaths(env1State, [projectPath], [filePath2])
|
||||
const env2 = new AtomEnvironment({
|
||||
applicationDelegate: atom.applicationDelegate
|
||||
})
|
||||
await env2.attemptRestoreProjectStateForPaths(
|
||||
env1State,
|
||||
[projectPath],
|
||||
[filePath2]
|
||||
)
|
||||
const restoredURIs = env2.workspace.getPaneItems().map(p => p.getURI())
|
||||
expect(restoredURIs).toEqual([filePath1, filePath2, filePath3])
|
||||
env2.destroy()
|
||||
@@ -500,12 +538,18 @@ describe('AtomEnvironment', () => {
|
||||
it("doesn't prompt the user to restore state", () => {
|
||||
const dock = atom.workspace.getLeftDock()
|
||||
dock.getActivePane().addItem({
|
||||
getTitle () { return 'title' },
|
||||
getTitle () {
|
||||
return 'title'
|
||||
},
|
||||
element: document.createElement('div')
|
||||
})
|
||||
const state = {}
|
||||
spyOn(atom, 'confirm')
|
||||
atom.attemptRestoreProjectStateForPaths(state, [__dirname], [__filename])
|
||||
atom.attemptRestoreProjectStateForPaths(
|
||||
state,
|
||||
[__dirname],
|
||||
[__filename]
|
||||
)
|
||||
expect(atom.confirm).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -527,7 +571,11 @@ describe('AtomEnvironment', () => {
|
||||
spyOn(atom.project, 'addPath')
|
||||
spyOn(atom.workspace, 'open')
|
||||
const state = Symbol()
|
||||
atom.attemptRestoreProjectStateForPaths(state, [__dirname], [__filename])
|
||||
atom.attemptRestoreProjectStateForPaths(
|
||||
state,
|
||||
[__dirname],
|
||||
[__filename]
|
||||
)
|
||||
expect(atom.confirm).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -539,7 +587,11 @@ describe('AtomEnvironment', () => {
|
||||
spyOn(atom.workspace, 'open')
|
||||
const state = Symbol()
|
||||
|
||||
atom.attemptRestoreProjectStateForPaths(state, [__dirname], [__filename])
|
||||
atom.attemptRestoreProjectStateForPaths(
|
||||
state,
|
||||
[__dirname],
|
||||
[__filename]
|
||||
)
|
||||
expect(atom.confirm).toHaveBeenCalled()
|
||||
await conditionPromise(() => atom.project.addPath.callCount === 1)
|
||||
|
||||
@@ -554,7 +606,11 @@ describe('AtomEnvironment', () => {
|
||||
spyOn(atom, 'open')
|
||||
const state = Symbol()
|
||||
|
||||
atom.attemptRestoreProjectStateForPaths(state, [__dirname], [__filename])
|
||||
atom.attemptRestoreProjectStateForPaths(
|
||||
state,
|
||||
[__dirname],
|
||||
[__filename]
|
||||
)
|
||||
expect(atom.confirm).toHaveBeenCalled()
|
||||
await conditionPromise(() => atom.open.callCount === 1)
|
||||
expect(atom.open).toHaveBeenCalledWith({
|
||||
@@ -571,8 +627,16 @@ describe('AtomEnvironment', () => {
|
||||
it('saves the BlobStore so it can be loaded after reload', () => {
|
||||
const configDirPath = temp.mkdirSync('atom-spec-environment')
|
||||
const fakeBlobStore = jasmine.createSpyObj('blob store', ['save'])
|
||||
const atomEnvironment = new AtomEnvironment({applicationDelegate: atom.applicationDelegate, enablePersistence: true})
|
||||
atomEnvironment.initialize({configDirPath, blobStore: fakeBlobStore, window, document})
|
||||
const atomEnvironment = new AtomEnvironment({
|
||||
applicationDelegate: atom.applicationDelegate,
|
||||
enablePersistence: true
|
||||
})
|
||||
atomEnvironment.initialize({
|
||||
configDirPath,
|
||||
blobStore: fakeBlobStore,
|
||||
window,
|
||||
document
|
||||
})
|
||||
|
||||
atomEnvironment.unloadEditorWindow()
|
||||
|
||||
@@ -584,16 +648,19 @@ describe('AtomEnvironment', () => {
|
||||
|
||||
describe('::destroy()', () => {
|
||||
it('does not throw exceptions when unsubscribing from ipc events (regression)', async () => {
|
||||
const configDirPath = temp.mkdirSync('atom-spec-environment')
|
||||
const fakeDocument = {
|
||||
addEventListener () {},
|
||||
removeEventListener () {},
|
||||
head: document.createElement('head'),
|
||||
body: document.createElement('body')
|
||||
}
|
||||
const atomEnvironment = new AtomEnvironment({applicationDelegate: atom.applicationDelegate})
|
||||
atomEnvironment.initialize({window, document: fakeDocument})
|
||||
spyOn(atomEnvironment.packages, 'loadPackages').andReturn(Promise.resolve())
|
||||
const atomEnvironment = new AtomEnvironment({
|
||||
applicationDelegate: atom.applicationDelegate
|
||||
})
|
||||
atomEnvironment.initialize({ window, document: fakeDocument })
|
||||
spyOn(atomEnvironment.packages, 'loadPackages').andReturn(
|
||||
Promise.resolve()
|
||||
)
|
||||
spyOn(atomEnvironment.packages, 'activate').andReturn(Promise.resolve())
|
||||
spyOn(atomEnvironment, 'displayWindow').andReturn(Promise.resolve())
|
||||
await atomEnvironment.startEditorWindow()
|
||||
@@ -606,17 +673,21 @@ describe('AtomEnvironment', () => {
|
||||
let atomEnvironment, envLoaded, spy
|
||||
|
||||
beforeEach(() => {
|
||||
let resolve = null
|
||||
const promise = new Promise((r) => { resolve = r })
|
||||
let resolvePromise = null
|
||||
const promise = new Promise(resolve => {
|
||||
resolvePromise = resolve
|
||||
})
|
||||
envLoaded = () => {
|
||||
resolve()
|
||||
resolvePromise()
|
||||
return promise
|
||||
}
|
||||
atomEnvironment = new AtomEnvironment({
|
||||
applicationDelegate: atom.applicationDelegate,
|
||||
updateProcessEnv () { return promise }
|
||||
updateProcessEnv () {
|
||||
return promise
|
||||
}
|
||||
})
|
||||
atomEnvironment.initialize({window, document})
|
||||
atomEnvironment.initialize({ window, document })
|
||||
spy = jasmine.createSpy()
|
||||
})
|
||||
|
||||
@@ -650,23 +721,30 @@ describe('AtomEnvironment', () => {
|
||||
describe('when the opened path exists', () => {
|
||||
it('opens a file', async () => {
|
||||
const pathToOpen = __filename
|
||||
await atom.openLocations([{pathToOpen}])
|
||||
await atom.openLocations([{ pathToOpen }])
|
||||
expect(atom.project.getPaths()).toEqual([])
|
||||
})
|
||||
|
||||
it('opens a directory as a project folder', async () => {
|
||||
const pathToOpen = __dirname
|
||||
await atom.openLocations([{pathToOpen}])
|
||||
expect(atom.workspace.getTextEditors().map(e => e.getPath())).toEqual([])
|
||||
await atom.openLocations([{ pathToOpen }])
|
||||
expect(atom.workspace.getTextEditors().map(e => e.getPath())).toEqual(
|
||||
[]
|
||||
)
|
||||
expect(atom.project.getPaths()).toEqual([pathToOpen])
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the opened path does not exist', () => {
|
||||
it('opens it as a new file', async () => {
|
||||
const pathToOpen = path.join(__dirname, 'this-path-does-not-exist.txt')
|
||||
await atom.openLocations([{pathToOpen}])
|
||||
expect(atom.workspace.getTextEditors().map(e => e.getPath())).toEqual([pathToOpen])
|
||||
const pathToOpen = path.join(
|
||||
__dirname,
|
||||
'this-path-does-not-exist.txt'
|
||||
)
|
||||
await atom.openLocations([{ pathToOpen }])
|
||||
expect(atom.workspace.getTextEditors().map(e => e.getPath())).toEqual(
|
||||
[pathToOpen]
|
||||
)
|
||||
expect(atom.project.getPaths()).toEqual([])
|
||||
})
|
||||
|
||||
@@ -678,9 +756,9 @@ describe('AtomEnvironment', () => {
|
||||
const existingDir = path.join(__dirname, 'fixtures')
|
||||
|
||||
await atom.openLocations([
|
||||
{pathToOpen: nonExistent, mustBeDirectory: true},
|
||||
{pathToOpen: existingFile, mustBeDirectory: true},
|
||||
{pathToOpen: existingDir, mustBeDirectory: true}
|
||||
{ pathToOpen: nonExistent, mustBeDirectory: true },
|
||||
{ pathToOpen: existingFile, mustBeDirectory: true },
|
||||
{ pathToOpen: existingDir, mustBeDirectory: true }
|
||||
])
|
||||
|
||||
expect(atom.workspace.getTextEditors()).toEqual([])
|
||||
@@ -688,7 +766,9 @@ describe('AtomEnvironment', () => {
|
||||
|
||||
expect(atom.notifications.addWarning).toHaveBeenCalledWith(
|
||||
'Unable to open project folders',
|
||||
{description: `The directories \`${nonExistent}\` and \`${existingFile}\` do not exist.`}
|
||||
{
|
||||
description: `The directories \`${nonExistent}\` and \`${existingFile}\` do not exist.`
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -697,15 +777,23 @@ describe('AtomEnvironment', () => {
|
||||
let serviceDisposable
|
||||
|
||||
beforeEach(() => {
|
||||
serviceDisposable = atom.packages.serviceHub.provide('atom.directory-provider', '0.1.0', {
|
||||
directoryForURISync (uri) {
|
||||
if (uri.startsWith('remote://')) {
|
||||
return { getPath() { return uri } }
|
||||
} else {
|
||||
return null
|
||||
serviceDisposable = atom.packages.serviceHub.provide(
|
||||
'atom.directory-provider',
|
||||
'0.1.0',
|
||||
{
|
||||
directoryForURISync (uri) {
|
||||
if (uri.startsWith('remote://')) {
|
||||
return {
|
||||
getPath () {
|
||||
return uri
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
waitsFor(() => atom.project.directoryProviders.length > 0)
|
||||
})
|
||||
@@ -717,7 +805,7 @@ describe('AtomEnvironment', () => {
|
||||
it("adds it to the project's paths as is", async () => {
|
||||
const pathToOpen = 'remote://server:7644/some/dir/path'
|
||||
spyOn(atom.project, 'addPath')
|
||||
await atom.openLocations([{pathToOpen}])
|
||||
await atom.openLocations([{ pathToOpen }])
|
||||
expect(atom.project.addPath).toHaveBeenCalledWith(pathToOpen)
|
||||
})
|
||||
})
|
||||
@@ -729,7 +817,11 @@ describe('AtomEnvironment', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(atom, 'getStateKey').andCallFake(dirs => dirs.join(':'))
|
||||
spyOn(atom, 'loadState').andCallFake(function (key) {
|
||||
if (key === __dirname) { return Promise.resolve(state) } else { return Promise.resolve(null) }
|
||||
if (key === __dirname) {
|
||||
return Promise.resolve(state)
|
||||
} else {
|
||||
return Promise.resolve(null)
|
||||
}
|
||||
})
|
||||
spyOn(atom, 'attemptRestoreProjectStateForPaths')
|
||||
})
|
||||
@@ -737,8 +829,12 @@ describe('AtomEnvironment', () => {
|
||||
describe('when there are no project folders', () => {
|
||||
it('attempts to restore the project state', async () => {
|
||||
const pathToOpen = __dirname
|
||||
await atom.openLocations([{pathToOpen}])
|
||||
expect(atom.attemptRestoreProjectStateForPaths).toHaveBeenCalledWith(state, [pathToOpen], [])
|
||||
await atom.openLocations([{ pathToOpen }])
|
||||
expect(atom.attemptRestoreProjectStateForPaths).toHaveBeenCalledWith(
|
||||
state,
|
||||
[pathToOpen],
|
||||
[]
|
||||
)
|
||||
expect(atom.project.getPaths()).toEqual([])
|
||||
})
|
||||
|
||||
@@ -755,17 +851,28 @@ describe('AtomEnvironment', () => {
|
||||
})
|
||||
|
||||
await atom.openLocations([
|
||||
{pathToOpen: existingDir},
|
||||
{pathToOpen: missingDir, mustBeDirectory: true}
|
||||
{ pathToOpen: existingDir },
|
||||
{ pathToOpen: missingDir, mustBeDirectory: true }
|
||||
])
|
||||
|
||||
expect(atom.attemptRestoreProjectStateForPaths).toHaveBeenCalledWith(state, [existingDir], [])
|
||||
expect(atom.attemptRestoreProjectStateForPaths).toHaveBeenCalledWith(
|
||||
state,
|
||||
[existingDir],
|
||||
[]
|
||||
)
|
||||
expect(atom.project.getPaths(), [existingDir])
|
||||
})
|
||||
|
||||
it('opens the specified files', async () => {
|
||||
await atom.openLocations([{pathToOpen: __dirname}, {pathToOpen: __filename}])
|
||||
expect(atom.attemptRestoreProjectStateForPaths).toHaveBeenCalledWith(state, [__dirname], [__filename])
|
||||
await atom.openLocations([
|
||||
{ pathToOpen: __dirname },
|
||||
{ pathToOpen: __filename }
|
||||
])
|
||||
expect(atom.attemptRestoreProjectStateForPaths).toHaveBeenCalledWith(
|
||||
state,
|
||||
[__dirname],
|
||||
[__filename]
|
||||
)
|
||||
expect(atom.project.getPaths()).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -775,7 +882,7 @@ describe('AtomEnvironment', () => {
|
||||
|
||||
it('does not attempt to restore the project state, instead adding the project paths', async () => {
|
||||
const pathToOpen = path.join(__dirname, 'fixtures')
|
||||
await atom.openLocations([{pathToOpen, forceAddToWindow: true}])
|
||||
await atom.openLocations([{ pathToOpen, forceAddToWindow: true }])
|
||||
expect(atom.attemptRestoreProjectStateForPaths).not.toHaveBeenCalled()
|
||||
expect(atom.project.getPaths()).toEqual([__dirname, pathToOpen])
|
||||
})
|
||||
@@ -783,8 +890,10 @@ describe('AtomEnvironment', () => {
|
||||
it('opens the specified files', async () => {
|
||||
const pathToOpen = path.join(__dirname, 'fixtures')
|
||||
const fileToOpen = path.join(pathToOpen, 'michelle-is-awesome.txt')
|
||||
await atom.openLocations([{pathToOpen}, {pathToOpen: fileToOpen}])
|
||||
expect(atom.attemptRestoreProjectStateForPaths).not.toHaveBeenCalledWith(state, [pathToOpen], [fileToOpen])
|
||||
await atom.openLocations([{ pathToOpen }, { pathToOpen: fileToOpen }])
|
||||
expect(
|
||||
atom.attemptRestoreProjectStateForPaths
|
||||
).not.toHaveBeenCalledWith(state, [pathToOpen], [fileToOpen])
|
||||
expect(atom.project.getPaths()).toEqual([__dirname, pathToOpen])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
/** @babel */
|
||||
|
||||
import {it, fit, ffit, fffit, beforeEach, afterEach} from './async-spec-helpers'
|
||||
import {app} from 'remote'
|
||||
import { app } from 'remote'
|
||||
import atomPaths from '../src/atom-paths'
|
||||
import fs from 'fs-plus'
|
||||
import path from 'path'
|
||||
const temp = require('temp').track()
|
||||
|
||||
describe("AtomPaths", () => {
|
||||
const portableAtomHomePath = path.join(atomPaths.getAppDirectory(), '..', '.atom')
|
||||
describe('AtomPaths', () => {
|
||||
const portableAtomHomePath = path.join(
|
||||
atomPaths.getAppDirectory(),
|
||||
'..',
|
||||
'.atom'
|
||||
)
|
||||
|
||||
afterEach(() => {
|
||||
atomPaths.setAtomHome(app.getPath('home'))
|
||||
@@ -18,8 +21,9 @@ describe("AtomPaths", () => {
|
||||
describe('when a portable .atom folder exists', () => {
|
||||
beforeEach(() => {
|
||||
delete process.env.ATOM_HOME
|
||||
if (!fs.existsSync(portableAtomHomePath))
|
||||
if (!fs.existsSync(portableAtomHomePath)) {
|
||||
fs.mkdirSync(portableAtomHomePath)
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
@@ -69,6 +73,7 @@ describe("AtomPaths", () => {
|
||||
})
|
||||
|
||||
describe('setUserData', () => {
|
||||
let tempAtomConfigPath = null
|
||||
let tempAtomHomePath = null
|
||||
let electronUserDataPath = null
|
||||
let defaultElectronUserDataPath = null
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const AutoUpdateManager = require('../src/auto-update-manager')
|
||||
const {remote} = require('electron')
|
||||
const { remote } = require('electron')
|
||||
const electronAutoUpdater = remote.require('electron').autoUpdater
|
||||
|
||||
describe('AutoUpdateManager (renderer)', () => {
|
||||
@@ -8,7 +8,9 @@ describe('AutoUpdateManager (renderer)', () => {
|
||||
let autoUpdateManager
|
||||
|
||||
beforeEach(() => {
|
||||
autoUpdateManager = new AutoUpdateManager({applicationDelegate: atom.applicationDelegate})
|
||||
autoUpdateManager = new AutoUpdateManager({
|
||||
applicationDelegate: atom.applicationDelegate
|
||||
})
|
||||
autoUpdateManager.initialize()
|
||||
})
|
||||
|
||||
@@ -69,14 +71,16 @@ describe('AutoUpdateManager (renderer)', () => {
|
||||
autoUpdateManager.onUpdateError(spy)
|
||||
electronAutoUpdater.emit('error', {}, 'an error message')
|
||||
waitsFor(() => spy.callCount === 1)
|
||||
runs(() => expect(autoUpdateManager.getErrorMessage()).toBe('an error message'))
|
||||
runs(() =>
|
||||
expect(autoUpdateManager.getErrorMessage()).toBe('an error message')
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('::platformSupportsUpdates', () => {
|
||||
let state, releaseChannel
|
||||
it('returns true on macOS and Windows when in stable', () => {
|
||||
spyOn(autoUpdateManager, 'getState').andCallFake(() => state)
|
||||
spyOn(autoUpdateManager, 'getState').andCallFake(() => state)
|
||||
spyOn(atom, 'getReleaseChannel').andCallFake(() => releaseChannel)
|
||||
|
||||
state = 'idle'
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const path = require('path')
|
||||
const fs = require('fs-plus')
|
||||
const temp = require('temp').track()
|
||||
const {it, fit, ffit, fffit, beforeEach, afterEach} = require('./async-spec-helpers');
|
||||
const CommandInstaller = require('../src/command-installer')
|
||||
|
||||
describe('CommandInstaller on #darwin', () => {
|
||||
@@ -12,14 +11,25 @@ describe('CommandInstaller on #darwin', () => {
|
||||
|
||||
resourcesPath = temp.mkdirSync('atom-app')
|
||||
atomBinPath = path.join(resourcesPath, 'app', 'atom.sh')
|
||||
apmBinPath = path.join(resourcesPath, 'app', 'apm', 'node_modules', '.bin', 'apm')
|
||||
apmBinPath = path.join(
|
||||
resourcesPath,
|
||||
'app',
|
||||
'apm',
|
||||
'node_modules',
|
||||
'.bin',
|
||||
'apm'
|
||||
)
|
||||
fs.writeFileSync(atomBinPath, '')
|
||||
fs.writeFileSync(apmBinPath, '')
|
||||
fs.chmodSync(atomBinPath, '755')
|
||||
fs.chmodSync(apmBinPath, '755')
|
||||
|
||||
spyOn(CommandInstaller.prototype, 'getResourcesDirectory').andReturn(resourcesPath)
|
||||
spyOn(CommandInstaller.prototype, 'getInstallDirectory').andReturn(installationPath)
|
||||
spyOn(CommandInstaller.prototype, 'getResourcesDirectory').andReturn(
|
||||
resourcesPath
|
||||
)
|
||||
spyOn(CommandInstaller.prototype, 'getInstallDirectory').andReturn(
|
||||
installationPath
|
||||
)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
@@ -32,7 +42,9 @@ describe('CommandInstaller on #darwin', () => {
|
||||
const appDelegate = jasmine.createSpyObj('appDelegate', ['confirm'])
|
||||
installer = new CommandInstaller(appDelegate)
|
||||
installer.initialize('2.0.2')
|
||||
spyOn(installer, 'installAtomCommand').andCallFake((__, callback) => callback(new Error('an error')))
|
||||
spyOn(installer, 'installAtomCommand').andCallFake((__, callback) =>
|
||||
callback(new Error('an error'))
|
||||
)
|
||||
|
||||
installer.installShellCommandsInteractively()
|
||||
|
||||
@@ -43,7 +55,9 @@ describe('CommandInstaller on #darwin', () => {
|
||||
|
||||
appDelegate.confirm.reset()
|
||||
installer.installAtomCommand.andCallFake((__, callback) => callback())
|
||||
spyOn(installer, 'installApmCommand').andCallFake((__, callback) => callback(new Error('another error')))
|
||||
spyOn(installer, 'installApmCommand').andCallFake((__, callback) =>
|
||||
callback(new Error('another error'))
|
||||
)
|
||||
|
||||
installer.installShellCommandsInteractively()
|
||||
|
||||
@@ -57,8 +71,12 @@ describe('CommandInstaller on #darwin', () => {
|
||||
const appDelegate = jasmine.createSpyObj('appDelegate', ['confirm'])
|
||||
installer = new CommandInstaller(appDelegate)
|
||||
installer.initialize('2.0.2')
|
||||
spyOn(installer, 'installAtomCommand').andCallFake((__, callback) => callback(undefined, 'atom'))
|
||||
spyOn(installer, 'installApmCommand').andCallFake((__, callback) => callback(undefined, 'apm'))
|
||||
spyOn(installer, 'installAtomCommand').andCallFake((__, callback) =>
|
||||
callback(undefined, 'atom')
|
||||
)
|
||||
spyOn(installer, 'installApmCommand').andCallFake((__, callback) =>
|
||||
callback(undefined, 'apm')
|
||||
)
|
||||
|
||||
installer.installShellCommandsInteractively()
|
||||
|
||||
@@ -81,9 +99,13 @@ describe('CommandInstaller on #darwin', () => {
|
||||
waitsFor(done => {
|
||||
installer.installAtomCommand(false, error => {
|
||||
expect(error).toBeNull()
|
||||
expect(fs.realpathSync(installedAtomPath)).toBe(fs.realpathSync(atomBinPath))
|
||||
expect(fs.realpathSync(installedAtomPath)).toBe(
|
||||
fs.realpathSync(atomBinPath)
|
||||
)
|
||||
expect(fs.isExecutableSync(installedAtomPath)).toBe(true)
|
||||
expect(fs.isFileSync(path.join(installationPath, 'atom-beta'))).toBe(false)
|
||||
expect(fs.isFileSync(path.join(installationPath, 'atom-beta'))).toBe(
|
||||
false
|
||||
)
|
||||
done()
|
||||
})
|
||||
})
|
||||
@@ -96,9 +118,13 @@ describe('CommandInstaller on #darwin', () => {
|
||||
waitsFor(done => {
|
||||
installer.installApmCommand(false, error => {
|
||||
expect(error).toBeNull()
|
||||
expect(fs.realpathSync(installedApmPath)).toBe(fs.realpathSync(apmBinPath))
|
||||
expect(fs.realpathSync(installedApmPath)).toBe(
|
||||
fs.realpathSync(apmBinPath)
|
||||
)
|
||||
expect(fs.isExecutableSync(installedApmPath)).toBeTruthy()
|
||||
expect(fs.isFileSync(path.join(installationPath, 'apm-beta'))).toBe(false)
|
||||
expect(fs.isFileSync(path.join(installationPath, 'apm-beta'))).toBe(
|
||||
false
|
||||
)
|
||||
done()
|
||||
})
|
||||
})
|
||||
@@ -118,7 +144,9 @@ describe('CommandInstaller on #darwin', () => {
|
||||
waitsFor(done => {
|
||||
installer.installAtomCommand(false, error => {
|
||||
expect(error).toBeNull()
|
||||
expect(fs.realpathSync(installedAtomPath)).toBe(fs.realpathSync(atomBinPath))
|
||||
expect(fs.realpathSync(installedAtomPath)).toBe(
|
||||
fs.realpathSync(atomBinPath)
|
||||
)
|
||||
expect(fs.isExecutableSync(installedAtomPath)).toBe(true)
|
||||
expect(fs.isFileSync(path.join(installationPath, 'atom'))).toBe(false)
|
||||
done()
|
||||
@@ -133,7 +161,9 @@ describe('CommandInstaller on #darwin', () => {
|
||||
waitsFor(done => {
|
||||
installer.installApmCommand(false, error => {
|
||||
expect(error).toBeNull()
|
||||
expect(fs.realpathSync(installedApmPath)).toBe(fs.realpathSync(apmBinPath))
|
||||
expect(fs.realpathSync(installedApmPath)).toBe(
|
||||
fs.realpathSync(apmBinPath)
|
||||
)
|
||||
expect(fs.isExecutableSync(installedApmPath)).toBeTruthy()
|
||||
expect(fs.isFileSync(path.join(installationPath, 'apm'))).toBe(false)
|
||||
done()
|
||||
@@ -155,7 +185,9 @@ describe('CommandInstaller on #darwin', () => {
|
||||
waitsFor(done => {
|
||||
installer.installAtomCommand(false, error => {
|
||||
expect(error).toBeNull()
|
||||
expect(fs.realpathSync(installedAtomPath)).toBe(fs.realpathSync(atomBinPath))
|
||||
expect(fs.realpathSync(installedAtomPath)).toBe(
|
||||
fs.realpathSync(atomBinPath)
|
||||
)
|
||||
expect(fs.isExecutableSync(installedAtomPath)).toBe(true)
|
||||
expect(fs.isFileSync(path.join(installationPath, 'atom'))).toBe(false)
|
||||
done()
|
||||
@@ -170,9 +202,13 @@ describe('CommandInstaller on #darwin', () => {
|
||||
waitsFor(done => {
|
||||
installer.installApmCommand(false, error => {
|
||||
expect(error).toBeNull()
|
||||
expect(fs.realpathSync(installedApmPath)).toBe(fs.realpathSync(apmBinPath))
|
||||
expect(fs.realpathSync(installedApmPath)).toBe(
|
||||
fs.realpathSync(apmBinPath)
|
||||
)
|
||||
expect(fs.isExecutableSync(installedApmPath)).toBeTruthy()
|
||||
expect(fs.isFileSync(path.join(installationPath, 'nightly'))).toBe(false)
|
||||
expect(fs.isFileSync(path.join(installationPath, 'nightly'))).toBe(
|
||||
false
|
||||
)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,289 +1,306 @@
|
||||
const CommandRegistry = require('../src/command-registry');
|
||||
const _ = require('underscore-plus');
|
||||
const {it, fit, ffit, fffit, beforeEach, afterEach} = require('./async-spec-helpers');
|
||||
const CommandRegistry = require('../src/command-registry')
|
||||
const _ = require('underscore-plus')
|
||||
|
||||
describe("CommandRegistry", () => {
|
||||
let registry, parent, child, grandchild;
|
||||
describe('CommandRegistry', () => {
|
||||
let registry, parent, child, grandchild
|
||||
|
||||
beforeEach(() => {
|
||||
parent = document.createElement("div");
|
||||
child = document.createElement("div");
|
||||
grandchild = document.createElement("div");
|
||||
parent.classList.add('parent');
|
||||
child.classList.add('child');
|
||||
grandchild.classList.add('grandchild');
|
||||
child.appendChild(grandchild);
|
||||
parent.appendChild(child);
|
||||
document.querySelector('#jasmine-content').appendChild(parent);
|
||||
parent = document.createElement('div')
|
||||
child = document.createElement('div')
|
||||
grandchild = document.createElement('div')
|
||||
parent.classList.add('parent')
|
||||
child.classList.add('child')
|
||||
grandchild.classList.add('grandchild')
|
||||
child.appendChild(grandchild)
|
||||
parent.appendChild(child)
|
||||
document.querySelector('#jasmine-content').appendChild(parent)
|
||||
|
||||
registry = new CommandRegistry;
|
||||
registry.attach(parent);
|
||||
});
|
||||
registry = new CommandRegistry()
|
||||
registry.attach(parent)
|
||||
})
|
||||
|
||||
afterEach(() => registry.destroy());
|
||||
afterEach(() => registry.destroy())
|
||||
|
||||
describe("when a command event is dispatched on an element", () => {
|
||||
it("invokes callbacks with selectors matching the target", () => {
|
||||
let called = false;
|
||||
describe('when a command event is dispatched on an element', () => {
|
||||
it('invokes callbacks with selectors matching the target', () => {
|
||||
let called = false
|
||||
registry.add('.grandchild', 'command', function (event) {
|
||||
expect(this).toBe(grandchild);
|
||||
expect(event.type).toBe('command');
|
||||
expect(event.eventPhase).toBe(Event.BUBBLING_PHASE);
|
||||
expect(event.target).toBe(grandchild);
|
||||
expect(event.currentTarget).toBe(grandchild);
|
||||
called = true;
|
||||
});
|
||||
expect(this).toBe(grandchild)
|
||||
expect(event.type).toBe('command')
|
||||
expect(event.eventPhase).toBe(Event.BUBBLING_PHASE)
|
||||
expect(event.target).toBe(grandchild)
|
||||
expect(event.currentTarget).toBe(grandchild)
|
||||
called = true
|
||||
})
|
||||
|
||||
grandchild.dispatchEvent(new CustomEvent('command', {bubbles: true}));
|
||||
expect(called).toBe(true);
|
||||
});
|
||||
grandchild.dispatchEvent(new CustomEvent('command', { bubbles: true }))
|
||||
expect(called).toBe(true)
|
||||
})
|
||||
|
||||
it("invokes callbacks with selectors matching ancestors of the target", () => {
|
||||
const calls = [];
|
||||
it('invokes callbacks with selectors matching ancestors of the target', () => {
|
||||
const calls = []
|
||||
|
||||
registry.add('.child', 'command', function (event) {
|
||||
expect(this).toBe(child);
|
||||
expect(event.target).toBe(grandchild);
|
||||
expect(event.currentTarget).toBe(child);
|
||||
calls.push('child');
|
||||
});
|
||||
expect(this).toBe(child)
|
||||
expect(event.target).toBe(grandchild)
|
||||
expect(event.currentTarget).toBe(child)
|
||||
calls.push('child')
|
||||
})
|
||||
|
||||
registry.add('.parent', 'command', function (event) {
|
||||
expect(this).toBe(parent);
|
||||
expect(event.target).toBe(grandchild);
|
||||
expect(event.currentTarget).toBe(parent);
|
||||
calls.push('parent');
|
||||
});
|
||||
registry.add('.parent', 'command', function (event) {
|
||||
expect(this).toBe(parent)
|
||||
expect(event.target).toBe(grandchild)
|
||||
expect(event.currentTarget).toBe(parent)
|
||||
calls.push('parent')
|
||||
})
|
||||
|
||||
grandchild.dispatchEvent(new CustomEvent('command', {bubbles: true}));
|
||||
expect(calls).toEqual(['child', 'parent']);
|
||||
});
|
||||
grandchild.dispatchEvent(new CustomEvent('command', { bubbles: true }))
|
||||
expect(calls).toEqual(['child', 'parent'])
|
||||
})
|
||||
|
||||
it("invokes inline listeners prior to listeners applied via selectors", () => {
|
||||
const calls = [];
|
||||
registry.add('.grandchild', 'command', () => calls.push('grandchild'));
|
||||
registry.add(child, 'command', () => calls.push('child-inline'));
|
||||
registry.add('.child', 'command', () => calls.push('child'));
|
||||
registry.add('.parent', 'command', () => calls.push('parent'));
|
||||
it('invokes inline listeners prior to listeners applied via selectors', () => {
|
||||
const calls = []
|
||||
registry.add('.grandchild', 'command', () => calls.push('grandchild'))
|
||||
registry.add(child, 'command', () => calls.push('child-inline'))
|
||||
registry.add('.child', 'command', () => calls.push('child'))
|
||||
registry.add('.parent', 'command', () => calls.push('parent'))
|
||||
|
||||
grandchild.dispatchEvent(new CustomEvent('command', {bubbles: true}));
|
||||
expect(calls).toEqual(['grandchild', 'child-inline', 'child', 'parent']);
|
||||
});
|
||||
grandchild.dispatchEvent(new CustomEvent('command', { bubbles: true }))
|
||||
expect(calls).toEqual(['grandchild', 'child-inline', 'child', 'parent'])
|
||||
})
|
||||
|
||||
it("orders multiple matching listeners for an element by selector specificity", () => {
|
||||
child.classList.add('foo', 'bar');
|
||||
const calls = [];
|
||||
it('orders multiple matching listeners for an element by selector specificity', () => {
|
||||
child.classList.add('foo', 'bar')
|
||||
const calls = []
|
||||
|
||||
registry.add('.foo.bar', 'command', () => calls.push('.foo.bar'));
|
||||
registry.add('.foo', 'command', () => calls.push('.foo'));
|
||||
registry.add('.bar', 'command', () => calls.push('.bar')); // specificity ties favor commands added later, like CSS
|
||||
registry.add('.foo.bar', 'command', () => calls.push('.foo.bar'))
|
||||
registry.add('.foo', 'command', () => calls.push('.foo'))
|
||||
registry.add('.bar', 'command', () => calls.push('.bar')) // specificity ties favor commands added later, like CSS
|
||||
|
||||
grandchild.dispatchEvent(new CustomEvent('command', {bubbles: true}));
|
||||
expect(calls).toEqual(['.foo.bar', '.bar', '.foo']);
|
||||
});
|
||||
grandchild.dispatchEvent(new CustomEvent('command', { bubbles: true }))
|
||||
expect(calls).toEqual(['.foo.bar', '.bar', '.foo'])
|
||||
})
|
||||
|
||||
it("orders inline listeners by reverse registration order", () => {
|
||||
const calls = [];
|
||||
registry.add(child, 'command', () => calls.push('child1'));
|
||||
registry.add(child, 'command', () => calls.push('child2'));
|
||||
child.dispatchEvent(new CustomEvent('command', {bubbles: true}));
|
||||
expect(calls).toEqual(['child2', 'child1']);
|
||||
});
|
||||
it('orders inline listeners by reverse registration order', () => {
|
||||
const calls = []
|
||||
registry.add(child, 'command', () => calls.push('child1'))
|
||||
registry.add(child, 'command', () => calls.push('child2'))
|
||||
child.dispatchEvent(new CustomEvent('command', { bubbles: true }))
|
||||
expect(calls).toEqual(['child2', 'child1'])
|
||||
})
|
||||
|
||||
it("stops bubbling through ancestors when .stopPropagation() is called on the event", () => {
|
||||
const calls = [];
|
||||
it('stops bubbling through ancestors when .stopPropagation() is called on the event', () => {
|
||||
const calls = []
|
||||
|
||||
registry.add('.parent', 'command', () => calls.push('parent'));
|
||||
registry.add('.child', 'command', () => calls.push('child-2'));
|
||||
registry.add('.child', 'command', (event) => {
|
||||
calls.push('child-1');
|
||||
event.stopPropagation();
|
||||
});
|
||||
registry.add('.parent', 'command', () => calls.push('parent'))
|
||||
registry.add('.child', 'command', () => calls.push('child-2'))
|
||||
registry.add('.child', 'command', event => {
|
||||
calls.push('child-1')
|
||||
event.stopPropagation()
|
||||
})
|
||||
|
||||
const dispatchedEvent = new CustomEvent('command', {bubbles: true});
|
||||
spyOn(dispatchedEvent, 'stopPropagation');
|
||||
grandchild.dispatchEvent(dispatchedEvent);
|
||||
expect(calls).toEqual(['child-1', 'child-2']);
|
||||
expect(dispatchedEvent.stopPropagation).toHaveBeenCalled();
|
||||
});
|
||||
const dispatchedEvent = new CustomEvent('command', { bubbles: true })
|
||||
spyOn(dispatchedEvent, 'stopPropagation')
|
||||
grandchild.dispatchEvent(dispatchedEvent)
|
||||
expect(calls).toEqual(['child-1', 'child-2'])
|
||||
expect(dispatchedEvent.stopPropagation).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("stops invoking callbacks when .stopImmediatePropagation() is called on the event", () => {
|
||||
const calls = [];
|
||||
it('stops invoking callbacks when .stopImmediatePropagation() is called on the event', () => {
|
||||
const calls = []
|
||||
|
||||
registry.add('.parent', 'command', () => calls.push('parent'));
|
||||
registry.add('.child', 'command', () => calls.push('child-2'));
|
||||
registry.add('.child', 'command', (event) => {
|
||||
calls.push('child-1');
|
||||
event.stopImmediatePropagation();
|
||||
});
|
||||
registry.add('.parent', 'command', () => calls.push('parent'))
|
||||
registry.add('.child', 'command', () => calls.push('child-2'))
|
||||
registry.add('.child', 'command', event => {
|
||||
calls.push('child-1')
|
||||
event.stopImmediatePropagation()
|
||||
})
|
||||
|
||||
const dispatchedEvent = new CustomEvent('command', {bubbles: true});
|
||||
spyOn(dispatchedEvent, 'stopImmediatePropagation');
|
||||
grandchild.dispatchEvent(dispatchedEvent);
|
||||
expect(calls).toEqual(['child-1']);
|
||||
expect(dispatchedEvent.stopImmediatePropagation).toHaveBeenCalled();
|
||||
});
|
||||
const dispatchedEvent = new CustomEvent('command', { bubbles: true })
|
||||
spyOn(dispatchedEvent, 'stopImmediatePropagation')
|
||||
grandchild.dispatchEvent(dispatchedEvent)
|
||||
expect(calls).toEqual(['child-1'])
|
||||
expect(dispatchedEvent.stopImmediatePropagation).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("forwards .preventDefault() calls from the synthetic event to the original", () => {
|
||||
registry.add('.child', 'command', event => event.preventDefault());
|
||||
it('forwards .preventDefault() calls from the synthetic event to the original', () => {
|
||||
registry.add('.child', 'command', event => event.preventDefault())
|
||||
|
||||
const dispatchedEvent = new CustomEvent('command', {bubbles: true});
|
||||
spyOn(dispatchedEvent, 'preventDefault');
|
||||
grandchild.dispatchEvent(dispatchedEvent);
|
||||
expect(dispatchedEvent.preventDefault).toHaveBeenCalled();
|
||||
});
|
||||
const dispatchedEvent = new CustomEvent('command', { bubbles: true })
|
||||
spyOn(dispatchedEvent, 'preventDefault')
|
||||
grandchild.dispatchEvent(dispatchedEvent)
|
||||
expect(dispatchedEvent.preventDefault).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("forwards .abortKeyBinding() calls from the synthetic event to the original", () => {
|
||||
registry.add('.child', 'command', event => event.abortKeyBinding());
|
||||
it('forwards .abortKeyBinding() calls from the synthetic event to the original', () => {
|
||||
registry.add('.child', 'command', event => event.abortKeyBinding())
|
||||
|
||||
const dispatchedEvent = new CustomEvent('command', {bubbles: true});
|
||||
dispatchedEvent.abortKeyBinding = jasmine.createSpy('abortKeyBinding');
|
||||
grandchild.dispatchEvent(dispatchedEvent);
|
||||
expect(dispatchedEvent.abortKeyBinding).toHaveBeenCalled();
|
||||
});
|
||||
const dispatchedEvent = new CustomEvent('command', { bubbles: true })
|
||||
dispatchedEvent.abortKeyBinding = jasmine.createSpy('abortKeyBinding')
|
||||
grandchild.dispatchEvent(dispatchedEvent)
|
||||
expect(dispatchedEvent.abortKeyBinding).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("copies non-standard properties from the original event to the synthetic event", () => {
|
||||
let syntheticEvent = null;
|
||||
registry.add('.child', 'command', event => syntheticEvent = event);
|
||||
it('copies non-standard properties from the original event to the synthetic event', () => {
|
||||
let syntheticEvent = null
|
||||
registry.add('.child', 'command', event => (syntheticEvent = event))
|
||||
|
||||
const dispatchedEvent = new CustomEvent('command', {bubbles: true});
|
||||
dispatchedEvent.nonStandardProperty = 'testing';
|
||||
grandchild.dispatchEvent(dispatchedEvent);
|
||||
expect(syntheticEvent.nonStandardProperty).toBe('testing');
|
||||
});
|
||||
const dispatchedEvent = new CustomEvent('command', { bubbles: true })
|
||||
dispatchedEvent.nonStandardProperty = 'testing'
|
||||
grandchild.dispatchEvent(dispatchedEvent)
|
||||
expect(syntheticEvent.nonStandardProperty).toBe('testing')
|
||||
})
|
||||
|
||||
it("allows listeners to be removed via a disposable returned by ::add", () => {
|
||||
let calls = [];
|
||||
it('allows listeners to be removed via a disposable returned by ::add', () => {
|
||||
let calls = []
|
||||
|
||||
const disposable1 = registry.add('.parent', 'command', () => calls.push('parent'));
|
||||
const disposable2 = registry.add('.child', 'command', () => calls.push('child'));
|
||||
const disposable1 = registry.add('.parent', 'command', () =>
|
||||
calls.push('parent')
|
||||
)
|
||||
const disposable2 = registry.add('.child', 'command', () =>
|
||||
calls.push('child')
|
||||
)
|
||||
|
||||
disposable1.dispose();
|
||||
grandchild.dispatchEvent(new CustomEvent('command', {bubbles: true}));
|
||||
expect(calls).toEqual(['child']);
|
||||
disposable1.dispose()
|
||||
grandchild.dispatchEvent(new CustomEvent('command', { bubbles: true }))
|
||||
expect(calls).toEqual(['child'])
|
||||
|
||||
calls = [];
|
||||
disposable2.dispose();
|
||||
grandchild.dispatchEvent(new CustomEvent('command', {bubbles: true}));
|
||||
expect(calls).toEqual([]);
|
||||
});
|
||||
calls = []
|
||||
disposable2.dispose()
|
||||
grandchild.dispatchEvent(new CustomEvent('command', { bubbles: true }))
|
||||
expect(calls).toEqual([])
|
||||
})
|
||||
|
||||
it("allows multiple commands to be registered under one selector when called with an object", () => {
|
||||
let calls = [];
|
||||
it('allows multiple commands to be registered under one selector when called with an object', () => {
|
||||
let calls = []
|
||||
|
||||
const disposable = registry.add('.child', {
|
||||
'command-1'() {
|
||||
calls.push('command-1');
|
||||
'command-1' () {
|
||||
calls.push('command-1')
|
||||
},
|
||||
'command-2'() {
|
||||
calls.push('command-2');
|
||||
'command-2' () {
|
||||
calls.push('command-2')
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
grandchild.dispatchEvent(new CustomEvent('command-1', {bubbles: true}));
|
||||
grandchild.dispatchEvent(new CustomEvent('command-2', {bubbles: true}));
|
||||
grandchild.dispatchEvent(new CustomEvent('command-1', { bubbles: true }))
|
||||
grandchild.dispatchEvent(new CustomEvent('command-2', { bubbles: true }))
|
||||
|
||||
expect(calls).toEqual(['command-1', 'command-2']);
|
||||
expect(calls).toEqual(['command-1', 'command-2'])
|
||||
|
||||
calls = [];
|
||||
disposable.dispose();
|
||||
grandchild.dispatchEvent(new CustomEvent('command-1', {bubbles: true}));
|
||||
grandchild.dispatchEvent(new CustomEvent('command-2', {bubbles: true}));
|
||||
expect(calls).toEqual([]);
|
||||
});
|
||||
calls = []
|
||||
disposable.dispose()
|
||||
grandchild.dispatchEvent(new CustomEvent('command-1', { bubbles: true }))
|
||||
grandchild.dispatchEvent(new CustomEvent('command-2', { bubbles: true }))
|
||||
expect(calls).toEqual([])
|
||||
})
|
||||
|
||||
it("invokes callbacks registered with ::onWillDispatch and ::onDidDispatch", () => {
|
||||
const sequence = [];
|
||||
it('invokes callbacks registered with ::onWillDispatch and ::onDidDispatch', () => {
|
||||
const sequence = []
|
||||
|
||||
registry.onDidDispatch(event => sequence.push(['onDidDispatch', event]));
|
||||
registry.onDidDispatch(event => sequence.push(['onDidDispatch', event]))
|
||||
|
||||
registry.add('.grandchild', 'command', event => sequence.push(['listener', event]));
|
||||
registry.add('.grandchild', 'command', event =>
|
||||
sequence.push(['listener', event])
|
||||
)
|
||||
|
||||
registry.onWillDispatch(event => sequence.push(['onWillDispatch', event]));
|
||||
registry.onWillDispatch(event => sequence.push(['onWillDispatch', event]))
|
||||
|
||||
grandchild.dispatchEvent(new CustomEvent('command', {bubbles: true}));
|
||||
grandchild.dispatchEvent(new CustomEvent('command', { bubbles: true }))
|
||||
|
||||
expect(sequence[0][0]).toBe('onWillDispatch');
|
||||
expect(sequence[1][0]).toBe('listener');
|
||||
expect(sequence[2][0]).toBe('onDidDispatch');
|
||||
expect(sequence[0][0]).toBe('onWillDispatch')
|
||||
expect(sequence[1][0]).toBe('listener')
|
||||
expect(sequence[2][0]).toBe('onDidDispatch')
|
||||
|
||||
expect(sequence[0][1] === sequence[1][1] && sequence[1][1] === sequence[2][1]).toBe(true);
|
||||
expect(sequence[0][1].constructor).toBe(CustomEvent);
|
||||
expect(sequence[0][1].target).toBe(grandchild);
|
||||
});
|
||||
});
|
||||
expect(
|
||||
sequence[0][1] === sequence[1][1] && sequence[1][1] === sequence[2][1]
|
||||
).toBe(true)
|
||||
expect(sequence[0][1].constructor).toBe(CustomEvent)
|
||||
expect(sequence[0][1].target).toBe(grandchild)
|
||||
})
|
||||
})
|
||||
|
||||
describe("::add(selector, commandName, callback)", () => {
|
||||
it("throws an error when called with an invalid selector", () => {
|
||||
const badSelector = '<>';
|
||||
let addError = null;
|
||||
describe('::add(selector, commandName, callback)', () => {
|
||||
it('throws an error when called with an invalid selector', () => {
|
||||
const badSelector = '<>'
|
||||
let addError = null
|
||||
try {
|
||||
registry.add(badSelector, 'foo:bar', () => {});
|
||||
registry.add(badSelector, 'foo:bar', () => {})
|
||||
} catch (error) {
|
||||
addError = error;
|
||||
addError = error
|
||||
}
|
||||
expect(addError.message).toContain(badSelector);
|
||||
});
|
||||
expect(addError.message).toContain(badSelector)
|
||||
})
|
||||
|
||||
it("throws an error when called with a null callback and selector target", () => {
|
||||
const badCallback = null;
|
||||
it('throws an error when called with a null callback and selector target', () => {
|
||||
const badCallback = null
|
||||
|
||||
expect(() => {
|
||||
registry.add('.selector', 'foo:bar', badCallback);
|
||||
}).toThrow(new Error('Cannot register a command with a null listener.'));
|
||||
});
|
||||
registry.add('.selector', 'foo:bar', badCallback)
|
||||
}).toThrow(new Error('Cannot register a command with a null listener.'))
|
||||
})
|
||||
|
||||
it("throws an error when called with a null callback and object target", () => {
|
||||
const badCallback = null;
|
||||
it('throws an error when called with a null callback and object target', () => {
|
||||
const badCallback = null
|
||||
|
||||
expect(() => {
|
||||
registry.add(document.body, 'foo:bar', badCallback);
|
||||
}).toThrow(new Error('Cannot register a command with a null listener.'));
|
||||
});
|
||||
registry.add(document.body, 'foo:bar', badCallback)
|
||||
}).toThrow(new Error('Cannot register a command with a null listener.'))
|
||||
})
|
||||
|
||||
it("throws an error when called with an object listener without a didDispatch method", () => {
|
||||
it('throws an error when called with an object listener without a didDispatch method', () => {
|
||||
const badListener = {
|
||||
title: 'a listener without a didDispatch callback',
|
||||
description: 'this should throw an error'
|
||||
};
|
||||
}
|
||||
|
||||
expect(() => {
|
||||
registry.add(document.body, 'foo:bar', badListener);
|
||||
}).toThrow(new Error('Listener must be a callback function or an object with a didDispatch method.'));
|
||||
});
|
||||
});
|
||||
registry.add(document.body, 'foo:bar', badListener)
|
||||
}).toThrow(
|
||||
new Error(
|
||||
'Listener must be a callback function or an object with a didDispatch method.'
|
||||
)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("::findCommands({target})", () => {
|
||||
it("returns command descriptors that can be invoked on the target or its ancestors", () => {
|
||||
registry.add('.parent', 'namespace:command-1', () => {});
|
||||
registry.add('.child', 'namespace:command-2', () => {});
|
||||
registry.add('.grandchild', 'namespace:command-3', () => {});
|
||||
registry.add('.grandchild.no-match', 'namespace:command-4', () => {});
|
||||
describe('::findCommands({target})', () => {
|
||||
it('returns command descriptors that can be invoked on the target or its ancestors', () => {
|
||||
registry.add('.parent', 'namespace:command-1', () => {})
|
||||
registry.add('.child', 'namespace:command-2', () => {})
|
||||
registry.add('.grandchild', 'namespace:command-3', () => {})
|
||||
registry.add('.grandchild.no-match', 'namespace:command-4', () => {})
|
||||
|
||||
registry.add(grandchild, 'namespace:inline-command-1', () => {});
|
||||
registry.add(child, 'namespace:inline-command-2', () => {});
|
||||
registry.add(grandchild, 'namespace:inline-command-1', () => {})
|
||||
registry.add(child, 'namespace:inline-command-2', () => {})
|
||||
|
||||
const commands = registry.findCommands({target: grandchild});
|
||||
const nonJqueryCommands = _.reject(commands, cmd => cmd.jQuery);
|
||||
const commands = registry.findCommands({ target: grandchild })
|
||||
const nonJqueryCommands = _.reject(commands, cmd => cmd.jQuery)
|
||||
expect(nonJqueryCommands).toEqual([
|
||||
{name: 'namespace:inline-command-1', displayName: 'Namespace: Inline Command 1'},
|
||||
{name: 'namespace:command-3', displayName: 'Namespace: Command 3'},
|
||||
{name: 'namespace:inline-command-2', displayName: 'Namespace: Inline Command 2'},
|
||||
{name: 'namespace:command-2', displayName: 'Namespace: Command 2'},
|
||||
{name: 'namespace:command-1', displayName: 'Namespace: Command 1'}
|
||||
]);
|
||||
});
|
||||
{
|
||||
name: 'namespace:inline-command-1',
|
||||
displayName: 'Namespace: Inline Command 1'
|
||||
},
|
||||
{ name: 'namespace:command-3', displayName: 'Namespace: Command 3' },
|
||||
{
|
||||
name: 'namespace:inline-command-2',
|
||||
displayName: 'Namespace: Inline Command 2'
|
||||
},
|
||||
{ name: 'namespace:command-2', displayName: 'Namespace: Command 2' },
|
||||
{ name: 'namespace:command-1', displayName: 'Namespace: Command 1' }
|
||||
])
|
||||
})
|
||||
|
||||
it("returns command descriptors with arbitrary metadata if set in a listener object", () => {
|
||||
registry.add('.grandchild', 'namespace:command-1', () => {});
|
||||
it('returns command descriptors with arbitrary metadata if set in a listener object', () => {
|
||||
registry.add('.grandchild', 'namespace:command-1', () => {})
|
||||
registry.add('.grandchild', 'namespace:command-2', {
|
||||
displayName: 'Custom Command 2',
|
||||
metadata: {
|
||||
some: 'other',
|
||||
object: 'data'
|
||||
},
|
||||
didDispatch() {}
|
||||
});
|
||||
didDispatch () {}
|
||||
})
|
||||
registry.add('.grandchild', 'namespace:command-3', {
|
||||
name: 'some:other:incorrect:commandname',
|
||||
displayName: 'Custom Command 3',
|
||||
@@ -291,10 +308,10 @@ describe("CommandRegistry", () => {
|
||||
some: 'other',
|
||||
object: 'data'
|
||||
},
|
||||
didDispatch() {}
|
||||
});
|
||||
didDispatch () {}
|
||||
})
|
||||
|
||||
const commands = registry.findCommands({target: grandchild});
|
||||
const commands = registry.findCommands({ target: grandchild })
|
||||
expect(commands).toEqual([
|
||||
{
|
||||
displayName: 'Namespace: Command 1',
|
||||
@@ -303,143 +320,163 @@ describe("CommandRegistry", () => {
|
||||
{
|
||||
displayName: 'Custom Command 2',
|
||||
metadata: {
|
||||
some : 'other',
|
||||
object : 'data'
|
||||
some: 'other',
|
||||
object: 'data'
|
||||
},
|
||||
name: 'namespace:command-2'
|
||||
},
|
||||
{
|
||||
displayName: 'Custom Command 3',
|
||||
metadata: {
|
||||
some : 'other',
|
||||
object : 'data'
|
||||
some: 'other',
|
||||
object: 'data'
|
||||
},
|
||||
name: 'namespace:command-3'
|
||||
}
|
||||
]);
|
||||
});
|
||||
])
|
||||
})
|
||||
|
||||
it("returns command descriptors with arbitrary metadata if set on a listener function", () => {
|
||||
it('returns command descriptors with arbitrary metadata if set on a listener function', () => {
|
||||
function listener () {}
|
||||
listener.displayName = 'Custom Command 2'
|
||||
listener.metadata = {
|
||||
some: 'other',
|
||||
object: 'data'
|
||||
};
|
||||
}
|
||||
|
||||
registry.add('.grandchild', 'namespace:command-2', listener);
|
||||
const commands = registry.findCommands({target: grandchild});
|
||||
registry.add('.grandchild', 'namespace:command-2', listener)
|
||||
const commands = registry.findCommands({ target: grandchild })
|
||||
expect(commands).toEqual([
|
||||
{
|
||||
displayName : 'Custom Command 2',
|
||||
displayName: 'Custom Command 2',
|
||||
metadata: {
|
||||
some: 'other',
|
||||
object: 'data'
|
||||
},
|
||||
name: 'namespace:command-2'
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("::dispatch(target, commandName)", () => {
|
||||
it("simulates invocation of the given command ", () => {
|
||||
let called = false;
|
||||
registry.add('.grandchild', 'command', function (event) {
|
||||
expect(this).toBe(grandchild);
|
||||
expect(event.type).toBe('command');
|
||||
expect(event.eventPhase).toBe(Event.BUBBLING_PHASE);
|
||||
expect(event.target).toBe(grandchild);
|
||||
expect(event.currentTarget).toBe(grandchild);
|
||||
called = true;
|
||||
});
|
||||
|
||||
registry.dispatch(grandchild, 'command');
|
||||
expect(called).toBe(true);
|
||||
});
|
||||
|
||||
it("returns a promise if any listeners matched the command", () => {
|
||||
registry.add('.grandchild', 'command', () => {});
|
||||
|
||||
expect(registry.dispatch(grandchild, 'command').constructor.name).toBe("Promise");
|
||||
expect(registry.dispatch(grandchild, 'bogus')).toBe(null);
|
||||
expect(registry.dispatch(parent, 'command')).toBe(null);
|
||||
});
|
||||
|
||||
it("returns a promise that resolves when the listeners resolve", async () => {
|
||||
jasmine.useRealClock();
|
||||
registry.add('.grandchild', 'command', () => 1);
|
||||
registry.add('.grandchild', 'command', () => Promise.resolve(2));
|
||||
registry.add('.grandchild', 'command', () => new Promise((resolve) => {
|
||||
setTimeout(() => { resolve(3); }, 1);
|
||||
}));
|
||||
|
||||
const values = await registry.dispatch(grandchild, 'command');
|
||||
expect(values).toEqual([3, 2, 1]);
|
||||
});
|
||||
|
||||
it("returns a promise that rejects when a listener is rejected", async () => {
|
||||
jasmine.useRealClock();
|
||||
registry.add('.grandchild', 'command', () => 1);
|
||||
registry.add('.grandchild', 'command', () => Promise.resolve(2));
|
||||
registry.add('.grandchild', 'command', () => new Promise((resolve, reject) => {
|
||||
setTimeout(() => { reject(3); }, 1);
|
||||
}));
|
||||
|
||||
let value;
|
||||
try {
|
||||
value = await registry.dispatch(grandchild, 'command');
|
||||
} catch (err) {
|
||||
value = err;
|
||||
}
|
||||
expect(value).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("::getSnapshot and ::restoreSnapshot", () =>
|
||||
it("removes all command handlers except for those in the snapshot", () => {
|
||||
registry.add('.parent', 'namespace:command-1', () => {});
|
||||
registry.add('.child', 'namespace:command-2', () => {});
|
||||
const snapshot = registry.getSnapshot();
|
||||
registry.add('.grandchild', 'namespace:command-3', () => {});
|
||||
|
||||
expect(registry.findCommands({target: grandchild}).slice(0, 3)).toEqual([
|
||||
{name: 'namespace:command-3', displayName: 'Namespace: Command 3'},
|
||||
{name: 'namespace:command-2', displayName: 'Namespace: Command 2'},
|
||||
{name: 'namespace:command-1', displayName: 'Namespace: Command 1'}
|
||||
]);
|
||||
|
||||
registry.restoreSnapshot(snapshot);
|
||||
|
||||
expect(registry.findCommands({target: grandchild}).slice(0, 2)).toEqual([
|
||||
{name: 'namespace:command-2', displayName: 'Namespace: Command 2'},
|
||||
{name: 'namespace:command-1', displayName: 'Namespace: Command 1'}
|
||||
]);
|
||||
|
||||
registry.add('.grandchild', 'namespace:command-3', () => {});
|
||||
registry.restoreSnapshot(snapshot);
|
||||
|
||||
expect(registry.findCommands({target: grandchild}).slice(0, 2)).toEqual([
|
||||
{name: 'namespace:command-2', displayName: 'Namespace: Command 2'},
|
||||
{name: 'namespace:command-1', displayName: 'Namespace: Command 1'}
|
||||
]);
|
||||
})
|
||||
);
|
||||
|
||||
describe("::attach(rootNode)", () =>
|
||||
it("adds event listeners for any previously-added commands", () => {
|
||||
const registry2 = new CommandRegistry;
|
||||
|
||||
const commandSpy = jasmine.createSpy('command-callback');
|
||||
registry2.add('.grandchild', 'command-1', commandSpy);
|
||||
|
||||
grandchild.dispatchEvent(new CustomEvent('command-1', {bubbles: true}));
|
||||
expect(commandSpy).not.toHaveBeenCalled();
|
||||
|
||||
registry2.attach(parent);
|
||||
|
||||
grandchild.dispatchEvent(new CustomEvent('command-1', {bubbles: true}));
|
||||
expect(commandSpy).toHaveBeenCalled();
|
||||
])
|
||||
})
|
||||
);
|
||||
});
|
||||
})
|
||||
|
||||
describe('::dispatch(target, commandName)', () => {
|
||||
it('simulates invocation of the given command ', () => {
|
||||
let called = false
|
||||
registry.add('.grandchild', 'command', function (event) {
|
||||
expect(this).toBe(grandchild)
|
||||
expect(event.type).toBe('command')
|
||||
expect(event.eventPhase).toBe(Event.BUBBLING_PHASE)
|
||||
expect(event.target).toBe(grandchild)
|
||||
expect(event.currentTarget).toBe(grandchild)
|
||||
called = true
|
||||
})
|
||||
|
||||
registry.dispatch(grandchild, 'command')
|
||||
expect(called).toBe(true)
|
||||
})
|
||||
|
||||
it('returns a promise if any listeners matched the command', () => {
|
||||
registry.add('.grandchild', 'command', () => {})
|
||||
|
||||
expect(registry.dispatch(grandchild, 'command').constructor.name).toBe(
|
||||
'Promise'
|
||||
)
|
||||
expect(registry.dispatch(grandchild, 'bogus')).toBe(null)
|
||||
expect(registry.dispatch(parent, 'command')).toBe(null)
|
||||
})
|
||||
|
||||
it('returns a promise that resolves when the listeners resolve', async () => {
|
||||
jasmine.useRealClock()
|
||||
registry.add('.grandchild', 'command', () => 1)
|
||||
registry.add('.grandchild', 'command', () => Promise.resolve(2))
|
||||
registry.add(
|
||||
'.grandchild',
|
||||
'command',
|
||||
() =>
|
||||
new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(3)
|
||||
}, 1)
|
||||
})
|
||||
)
|
||||
|
||||
const values = await registry.dispatch(grandchild, 'command')
|
||||
expect(values).toEqual([3, 2, 1])
|
||||
})
|
||||
|
||||
it('returns a promise that rejects when a listener is rejected', async () => {
|
||||
jasmine.useRealClock()
|
||||
registry.add('.grandchild', 'command', () => 1)
|
||||
registry.add('.grandchild', 'command', () => Promise.resolve(2))
|
||||
registry.add(
|
||||
'.grandchild',
|
||||
'command',
|
||||
() =>
|
||||
new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
reject(3)
|
||||
}, 1)
|
||||
})
|
||||
)
|
||||
|
||||
let value
|
||||
try {
|
||||
value = await registry.dispatch(grandchild, 'command')
|
||||
} catch (err) {
|
||||
value = err
|
||||
}
|
||||
expect(value).toBe(3)
|
||||
})
|
||||
})
|
||||
|
||||
describe('::getSnapshot and ::restoreSnapshot', () =>
|
||||
it('removes all command handlers except for those in the snapshot', () => {
|
||||
registry.add('.parent', 'namespace:command-1', () => {})
|
||||
registry.add('.child', 'namespace:command-2', () => {})
|
||||
const snapshot = registry.getSnapshot()
|
||||
registry.add('.grandchild', 'namespace:command-3', () => {})
|
||||
|
||||
expect(registry.findCommands({ target: grandchild }).slice(0, 3)).toEqual(
|
||||
[
|
||||
{ name: 'namespace:command-3', displayName: 'Namespace: Command 3' },
|
||||
{ name: 'namespace:command-2', displayName: 'Namespace: Command 2' },
|
||||
{ name: 'namespace:command-1', displayName: 'Namespace: Command 1' }
|
||||
]
|
||||
)
|
||||
|
||||
registry.restoreSnapshot(snapshot)
|
||||
|
||||
expect(registry.findCommands({ target: grandchild }).slice(0, 2)).toEqual(
|
||||
[
|
||||
{ name: 'namespace:command-2', displayName: 'Namespace: Command 2' },
|
||||
{ name: 'namespace:command-1', displayName: 'Namespace: Command 1' }
|
||||
]
|
||||
)
|
||||
|
||||
registry.add('.grandchild', 'namespace:command-3', () => {})
|
||||
registry.restoreSnapshot(snapshot)
|
||||
|
||||
expect(registry.findCommands({ target: grandchild }).slice(0, 2)).toEqual(
|
||||
[
|
||||
{ name: 'namespace:command-2', displayName: 'Namespace: Command 2' },
|
||||
{ name: 'namespace:command-1', displayName: 'Namespace: Command 1' }
|
||||
]
|
||||
)
|
||||
}))
|
||||
|
||||
describe('::attach(rootNode)', () =>
|
||||
it('adds event listeners for any previously-added commands', () => {
|
||||
const registry2 = new CommandRegistry()
|
||||
|
||||
const commandSpy = jasmine.createSpy('command-callback')
|
||||
registry2.add('.grandchild', 'command-1', commandSpy)
|
||||
|
||||
grandchild.dispatchEvent(new CustomEvent('command-1', { bubbles: true }))
|
||||
expect(commandSpy).not.toHaveBeenCalled()
|
||||
|
||||
registry2.attach(parent)
|
||||
|
||||
grandchild.dispatchEvent(new CustomEvent('command-1', { bubbles: true }))
|
||||
expect(commandSpy).toHaveBeenCalled()
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const {it, fit, ffit, beforeEach, afterEach, conditionPromise} = require('./async-spec-helpers')
|
||||
const fs = require('fs-plus')
|
||||
const path = require('path')
|
||||
const temp = require('temp').track()
|
||||
@@ -42,22 +41,25 @@ describe('ConfigFile', () => {
|
||||
|
||||
const event = new Promise(resolve => configFile.onDidChange(resolve))
|
||||
|
||||
writeFileSync(filePath, dedent `
|
||||
writeFileSync(
|
||||
filePath,
|
||||
dedent`
|
||||
'*':
|
||||
foo: 'bar'
|
||||
|
||||
'javascript':
|
||||
foo: 'baz'
|
||||
`)
|
||||
`
|
||||
)
|
||||
|
||||
expect(await event).toEqual({
|
||||
'*': {foo: 'bar'},
|
||||
'javascript': {foo: 'baz'}
|
||||
'*': { foo: 'bar' },
|
||||
javascript: { foo: 'baz' }
|
||||
})
|
||||
|
||||
expect(configFile.get()).toEqual({
|
||||
'*': {foo: 'bar'},
|
||||
'javascript': {foo: 'baz'}
|
||||
'*': { foo: 'bar' },
|
||||
javascript: { foo: 'baz' }
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -69,25 +71,33 @@ describe('ConfigFile', () => {
|
||||
|
||||
const message = new Promise(resolve => configFile.onDidError(resolve))
|
||||
|
||||
writeFileSync(filePath, dedent `
|
||||
writeFileSync(
|
||||
filePath,
|
||||
dedent`
|
||||
um what?
|
||||
`, 2)
|
||||
`,
|
||||
2
|
||||
)
|
||||
|
||||
expect(await message).toContain('Failed to load `the-config.cson`')
|
||||
|
||||
const event = new Promise(resolve => configFile.onDidChange(resolve))
|
||||
|
||||
writeFileSync(filePath, dedent `
|
||||
writeFileSync(
|
||||
filePath,
|
||||
dedent`
|
||||
'*':
|
||||
foo: 'bar'
|
||||
|
||||
'javascript':
|
||||
foo: 'baz'
|
||||
`, 4)
|
||||
`,
|
||||
4
|
||||
)
|
||||
|
||||
expect(await event).toEqual({
|
||||
'*': {foo: 'bar'},
|
||||
'javascript': {foo: 'baz'}
|
||||
'*': { foo: 'bar' },
|
||||
javascript: { foo: 'baz' }
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -115,7 +125,7 @@ describe('ConfigFile', () => {
|
||||
})
|
||||
|
||||
function writeFileSync (filePath, content, seconds = 2) {
|
||||
const utime = (Date.now() / 1000) + seconds
|
||||
const utime = Date.now() / 1000 + seconds
|
||||
fs.writeFileSync(filePath, content)
|
||||
fs.utimesSync(filePath, utime, utime)
|
||||
}
|
||||
|
||||
1107
spec/config-spec.js
1107
spec/config-spec.js
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,6 @@
|
||||
DecorationManager = require '../src/decoration-manager'
|
||||
TextEditor = require '../src/text-editor'
|
||||
|
||||
# Tests crash the renderer process on Electron 3.0, disabling for now.
|
||||
describe "DecorationManager", ->
|
||||
[decorationManager, buffer, editor, markerLayer1, markerLayer2] = []
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
const Grim = require('grim')
|
||||
|
||||
import {it, fit, ffit, fffit, beforeEach, afterEach} from './async-spec-helpers'
|
||||
import etch from 'etch'
|
||||
|
||||
const getNextUpdatePromise = () => etch.getScheduler().nextUpdatePromise
|
||||
@@ -16,7 +15,12 @@ describe('Dock', () => {
|
||||
dock.onDidChangeVisible(didChangeVisibleSpy)
|
||||
|
||||
expect(dock.isVisible()).toBe(false)
|
||||
expect(document.activeElement).toBe(atom.workspace.getCenter().getActivePane().getElement())
|
||||
expect(document.activeElement).toBe(
|
||||
atom.workspace
|
||||
.getCenter()
|
||||
.getActivePane()
|
||||
.getElement()
|
||||
)
|
||||
dock.activate()
|
||||
expect(dock.isVisible()).toBe(true)
|
||||
expect(document.activeElement).toBe(dock.getActivePane().getElement())
|
||||
@@ -36,7 +40,12 @@ describe('Dock', () => {
|
||||
expect(didChangeVisibleSpy.mostRecentCall.args[0]).toBe(true)
|
||||
|
||||
dock.hide()
|
||||
expect(document.activeElement).toBe(atom.workspace.getCenter().getActivePane().getElement())
|
||||
expect(document.activeElement).toBe(
|
||||
atom.workspace
|
||||
.getCenter()
|
||||
.getActivePane()
|
||||
.getElement()
|
||||
)
|
||||
expect(didChangeVisibleSpy.mostRecentCall.args[0]).toBe(false)
|
||||
|
||||
dock.activate()
|
||||
@@ -44,13 +53,18 @@ describe('Dock', () => {
|
||||
expect(didChangeVisibleSpy.mostRecentCall.args[0]).toBe(true)
|
||||
|
||||
dock.toggle()
|
||||
expect(document.activeElement).toBe(atom.workspace.getCenter().getActivePane().getElement())
|
||||
expect(document.activeElement).toBe(
|
||||
atom.workspace
|
||||
.getCenter()
|
||||
.getActivePane()
|
||||
.getElement()
|
||||
)
|
||||
expect(didChangeVisibleSpy.mostRecentCall.args[0]).toBe(false)
|
||||
|
||||
// Don't change focus if the dock was not focused in the first place
|
||||
const modalElement = document.createElement('div')
|
||||
modalElement.setAttribute('tabindex', -1)
|
||||
atom.workspace.addModalPanel({item: modalElement})
|
||||
atom.workspace.addModalPanel({ item: modalElement })
|
||||
modalElement.focus()
|
||||
expect(document.activeElement).toBe(modalElement)
|
||||
|
||||
@@ -68,13 +82,18 @@ describe('Dock', () => {
|
||||
it('opens the dock', async () => {
|
||||
const item = {
|
||||
element: document.createElement('div'),
|
||||
getDefaultLocation() { return 'left' }
|
||||
getDefaultLocation () {
|
||||
return 'left'
|
||||
}
|
||||
}
|
||||
|
||||
await atom.workspace.open(item, {activatePane: false})
|
||||
await atom.workspace.open(item, { activatePane: false })
|
||||
expect(atom.workspace.getLeftDock().isVisible()).toBe(false)
|
||||
|
||||
atom.workspace.getLeftDock().getPanes()[0].activate()
|
||||
atom.workspace
|
||||
.getLeftDock()
|
||||
.getPanes()[0]
|
||||
.activate()
|
||||
expect(atom.workspace.getLeftDock().isVisible()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -145,47 +164,63 @@ describe('Dock', () => {
|
||||
|
||||
describe('when the dock resize handle is double-clicked', () => {
|
||||
describe('when the dock is open', () => {
|
||||
it('resizes a vertically-oriented dock to the current item\'s preferred width', async () => {
|
||||
it("resizes a vertically-oriented dock to the current item's preferred width", async () => {
|
||||
jasmine.attachToDOM(atom.workspace.getElement())
|
||||
|
||||
const item = {
|
||||
element: document.createElement('div'),
|
||||
getDefaultLocation() { return 'left' },
|
||||
getPreferredWidth() { return 142 },
|
||||
getPreferredHeight() { return 122 }
|
||||
getDefaultLocation () {
|
||||
return 'left'
|
||||
},
|
||||
getPreferredWidth () {
|
||||
return 142
|
||||
},
|
||||
getPreferredHeight () {
|
||||
return 122
|
||||
}
|
||||
}
|
||||
|
||||
await atom.workspace.open(item)
|
||||
const dock = atom.workspace.getLeftDock()
|
||||
const dockElement = dock.getElement()
|
||||
|
||||
dock.setState({size: 300})
|
||||
dock.setState({ size: 300 })
|
||||
await getNextUpdatePromise()
|
||||
expect(dockElement.offsetWidth).toBe(300)
|
||||
dockElement.querySelector('.atom-dock-resize-handle').dispatchEvent(new MouseEvent('mousedown', {detail: 2}))
|
||||
dockElement
|
||||
.querySelector('.atom-dock-resize-handle')
|
||||
.dispatchEvent(new MouseEvent('mousedown', { detail: 2 }))
|
||||
await getNextUpdatePromise()
|
||||
|
||||
expect(dockElement.offsetWidth).toBe(item.getPreferredWidth())
|
||||
})
|
||||
|
||||
it('resizes a horizontally-oriented dock to the current item\'s preferred width', async () => {
|
||||
it("resizes a horizontally-oriented dock to the current item's preferred width", async () => {
|
||||
jasmine.attachToDOM(atom.workspace.getElement())
|
||||
|
||||
const item = {
|
||||
element: document.createElement('div'),
|
||||
getDefaultLocation() { return 'bottom' },
|
||||
getPreferredWidth() { return 122 },
|
||||
getPreferredHeight() { return 142 }
|
||||
getDefaultLocation () {
|
||||
return 'bottom'
|
||||
},
|
||||
getPreferredWidth () {
|
||||
return 122
|
||||
},
|
||||
getPreferredHeight () {
|
||||
return 142
|
||||
}
|
||||
}
|
||||
|
||||
await atom.workspace.open(item)
|
||||
const dock = atom.workspace.getBottomDock()
|
||||
const dockElement = dock.getElement()
|
||||
|
||||
dock.setState({size: 300})
|
||||
dock.setState({ size: 300 })
|
||||
await getNextUpdatePromise()
|
||||
expect(dockElement.offsetHeight).toBe(300)
|
||||
dockElement.querySelector('.atom-dock-resize-handle').dispatchEvent(new MouseEvent('mousedown', {detail: 2}))
|
||||
dockElement
|
||||
.querySelector('.atom-dock-resize-handle')
|
||||
.dispatchEvent(new MouseEvent('mousedown', { detail: 2 }))
|
||||
await getNextUpdatePromise()
|
||||
|
||||
expect(dockElement.offsetHeight).toBe(item.getPreferredHeight())
|
||||
@@ -198,19 +233,31 @@ describe('Dock', () => {
|
||||
|
||||
const item = {
|
||||
element: document.createElement('div'),
|
||||
getDefaultLocation() { return 'bottom' },
|
||||
getPreferredWidth() { return 122 },
|
||||
getPreferredHeight() { return 142 }
|
||||
getDefaultLocation () {
|
||||
return 'bottom'
|
||||
},
|
||||
getPreferredWidth () {
|
||||
return 122
|
||||
},
|
||||
getPreferredHeight () {
|
||||
return 142
|
||||
}
|
||||
}
|
||||
|
||||
await atom.workspace.open(item, {activatePane: false})
|
||||
await atom.workspace.open(item, { activatePane: false })
|
||||
|
||||
const dockElement = atom.workspace.getBottomDock().getElement()
|
||||
dockElement.querySelector('.atom-dock-resize-handle').dispatchEvent(new MouseEvent('mousedown', {detail: 2}))
|
||||
dockElement
|
||||
.querySelector('.atom-dock-resize-handle')
|
||||
.dispatchEvent(new MouseEvent('mousedown', { detail: 2 }))
|
||||
expect(dockElement.offsetHeight).toBe(0)
|
||||
expect(dockElement.querySelector('.atom-dock-inner').offsetHeight).toBe(0)
|
||||
expect(dockElement.querySelector('.atom-dock-inner').offsetHeight).toBe(
|
||||
0
|
||||
)
|
||||
// The content should be masked away.
|
||||
expect(dockElement.querySelector('.atom-dock-mask').offsetHeight).toBe(0)
|
||||
expect(dockElement.querySelector('.atom-dock-mask').offsetHeight).toBe(
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -222,8 +269,12 @@ describe('Dock', () => {
|
||||
|
||||
const createItem = preferredWidth => ({
|
||||
element: document.createElement('div'),
|
||||
getDefaultLocation() { return 'left' },
|
||||
getPreferredWidth() { return preferredWidth }
|
||||
getDefaultLocation () {
|
||||
return 'left'
|
||||
},
|
||||
getPreferredWidth () {
|
||||
return preferredWidth
|
||||
}
|
||||
})
|
||||
|
||||
const dock = atom.workspace.getLeftDock()
|
||||
@@ -257,7 +308,9 @@ describe('Dock', () => {
|
||||
|
||||
const item = {
|
||||
element: document.createElement('div'),
|
||||
getDefaultLocation() { return 'left' }
|
||||
getDefaultLocation () {
|
||||
return 'left'
|
||||
}
|
||||
}
|
||||
const dock = atom.workspace.getLeftDock()
|
||||
expect(dock.getPaneItems()).toHaveLength(0)
|
||||
@@ -275,11 +328,15 @@ describe('Dock', () => {
|
||||
|
||||
const item = {
|
||||
element: document.createElement('div'),
|
||||
getDefaultLocation() { return 'left' },
|
||||
getPreferredWidth() { return 122 },
|
||||
serialize: () => ({deserializer: 'DockTestItem'})
|
||||
getDefaultLocation () {
|
||||
return 'left'
|
||||
},
|
||||
getPreferredWidth () {
|
||||
return 122
|
||||
},
|
||||
serialize: () => ({ deserializer: 'DockTestItem' })
|
||||
}
|
||||
const itemDeserializer = atom.deserializers.add({
|
||||
atom.deserializers.add({
|
||||
name: 'DockTestItem',
|
||||
deserialize: () => item
|
||||
})
|
||||
@@ -287,10 +344,10 @@ describe('Dock', () => {
|
||||
const dockElement = dock.getElement()
|
||||
|
||||
await atom.workspace.open(item)
|
||||
dock.setState({size: 150})
|
||||
dock.setState({ size: 150 })
|
||||
expect(dockElement.offsetWidth).toBe(150)
|
||||
const serialized = dock.serialize()
|
||||
dock.setState({size: 122})
|
||||
dock.setState({ size: 122 })
|
||||
expect(dockElement.offsetWidth).toBe(122)
|
||||
dock.destroyActivePane()
|
||||
dock.deserialize(serialized, atom.deserializers)
|
||||
@@ -302,8 +359,12 @@ describe('Dock', () => {
|
||||
|
||||
const item = {
|
||||
element: document.createElement('div'),
|
||||
getDefaultLocation() { return 'left' },
|
||||
getPreferredWidth() { return 122 }
|
||||
getDefaultLocation () {
|
||||
return 'left'
|
||||
},
|
||||
getPreferredWidth () {
|
||||
return 122
|
||||
}
|
||||
}
|
||||
const dock = atom.workspace.getLeftDock()
|
||||
|
||||
@@ -324,16 +385,22 @@ describe('Dock', () => {
|
||||
element.setAttribute('is', 'tabs-tab')
|
||||
element.item = {
|
||||
element,
|
||||
getDefaultLocation() { return 'left' },
|
||||
getPreferredWidth() { return 144 }
|
||||
getDefaultLocation () {
|
||||
return 'left'
|
||||
},
|
||||
getPreferredWidth () {
|
||||
return 144
|
||||
}
|
||||
}
|
||||
|
||||
const dragEvent = new DragEvent('dragstart')
|
||||
Object.defineProperty(dragEvent, 'target', {value: element})
|
||||
Object.defineProperty(dragEvent, 'target', { value: element })
|
||||
|
||||
atom.workspace.getElement().handleDragStart(dragEvent)
|
||||
await getNextUpdatePromise()
|
||||
expect(atom.workspace.getLeftDock().refs.wrapperElement.offsetWidth).toBe(144)
|
||||
expect(atom.workspace.getLeftDock().refs.wrapperElement.offsetWidth).toBe(
|
||||
144
|
||||
)
|
||||
})
|
||||
|
||||
it('does nothing when text nodes are dragged', () => {
|
||||
@@ -342,9 +409,11 @@ describe('Dock', () => {
|
||||
const textNode = document.createTextNode('hello')
|
||||
|
||||
const dragEvent = new DragEvent('dragstart')
|
||||
Object.defineProperty(dragEvent, 'target', {value: textNode})
|
||||
Object.defineProperty(dragEvent, 'target', { value: textNode })
|
||||
|
||||
expect(() => atom.workspace.getElement().handleDragStart(dragEvent)).not.toThrow()
|
||||
expect(() =>
|
||||
atom.workspace.getElement().handleDragStart(dragEvent)
|
||||
).not.toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
2
spec/fixtures/babel/invalid.js
vendored
2
spec/fixtures/babel/invalid.js
vendored
@@ -1,3 +1,3 @@
|
||||
'use 6to6';
|
||||
|
||||
export default 42;
|
||||
module.exports = async function* hello() {}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user