diff --git a/.vscode/launch.json b/.vscode/launch.json index 23b8f107..b3d36ece 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,16 +1,16 @@ { - "version": "0.2.0", - "configurations": [ - { - "name": "Launch Extension", - "type": "extensionHost", - "request": "launch", - "runtimeExecutable": "${execPath}", - "args": [ - "--extensionDevelopmentPath=${workspaceRoot}" - ], - "sourceMaps": true, - "outDir": "${workspaceRoot}/out", + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Extension", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}" + ], + "sourceMaps": true, + "outDir": "${workspaceRoot}/out", "preLaunchTask": "build" }, { diff --git a/.vscode/settings.json b/.vscode/settings.json index 2502cb8b..6a1b0da9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,12 @@ // Place your settings in this file to overwrite default and user settings. { - "javascript.validate.enable": false, - "files.trimTrailingWhitespace": true, - "eslint.enable": false, - "editor.insertSpaces": true, - "editor.tabSize": 4, - "files.exclude": { - "**/node_modules": true, - "**/out": true - } + "javascript.validate.enable": false, + "files.trimTrailingWhitespace": true, + "eslint.enable": false, + "editor.insertSpaces": true, + "editor.tabSize": 4, + "files.exclude": { + "**/node_modules": true, + "**/out": true + } } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1d25b422..21974bfb 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -3,7 +3,7 @@ "command": "gulp", "isShellCommand": true, "tasks": [ - { + { "taskName": "watch", "args": [], "isBuildCommand": true, diff --git a/gulpfile.js b/gulpfile.js index 83bc9643..f16b8ad4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -17,44 +17,44 @@ var outPath = 'out'; var sources = [ srcPath, -].map(function (tsFolder) { return tsFolder + '/**/*.ts'; }) +].map(function(tsFolder) { return tsFolder + '/**/*.ts'; }) .concat(['test/*.ts']); // TODO: The file property should point to the generated source (this implementation adds an extra folder to the path) // We should also make sure that we always generate urls in all the path properties (We shouldn't have \\s. This seems to // be an issue on Windows platforms) -gulp.task('build', function () { +gulp.task('build', function() { var tsProject = ts.createProject('tsconfig.json'); return tsProject.src() .pipe(sourcemaps.init()) .pipe(ts(tsProject)) .pipe(sourcemaps.write('.', { includeContent: false, - sourceRoot: function (file) { + sourceRoot: function(file) { return path.relative(path.dirname(file.path), __dirname + '/src'); } })) .pipe(gulp.dest(outPath)); }); -gulp.task('watch', ['build'], function (cb) { +gulp.task('watch', ['build'], function(cb) { log('Watching build sources...'); return gulp.watch(sources, ['build']); }); -gulp.task('default', function (callback) { +gulp.task('default', function(callback) { runSequence("clean", "build", "tslint", callback); }); var lintSources = [ srcPath, -].map(function (tsFolder) { return tsFolder + '/**/*.ts'; }); +].map(function(tsFolder) { return tsFolder + '/**/*.ts'; }); lintSources = lintSources.concat([ '!src/typings/**' ]); var tslint = require('gulp-tslint'); -gulp.task('tslint', function () { +gulp.task('tslint', function() { return gulp.src(lintSources, { base: '.' }) .pipe(tslint()) .pipe(tslint.report('verbose')); @@ -67,11 +67,11 @@ function test() { gulp.task('build-test', ['build'], test); gulp.task('test', test); -gulp.task('watch-build-test', ['build', 'build-test'], function () { +gulp.task('watch-build-test', ['build', 'build-test'], function() { return gulp.watch(sources, ['build', 'build-test']); }); -gulp.task("clean", function () { +gulp.task("clean", function() { var del = require("del"); return del([outPath + "/**"], { force: true }); }); \ No newline at end of file diff --git a/js-patched/opn-main.js b/js-patched/opn-main.js index a62daf09..af455178 100644 --- a/js-patched/opn-main.js +++ b/js-patched/opn-main.js @@ -1,7 +1,7 @@ 'use strict'; var opn = require('./index.js'); -module.exports = function (target, opts, cb) { +module.exports = function(target, opts, cb) { if (process.env.REACT_DEBUGGER) { if (opts.app) { console.log("Debugger for React Native is configured. Skipping launch of " + opts.app); @@ -9,5 +9,5 @@ module.exports = function (target, opts, cb) { return; } - return opn(target, opts, cb); + return opn(target, opts, cb); }; diff --git a/package.json b/package.json index 55627ff0..fa38dbe9 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,9 @@ "compile": "node ./node_modules/vscode/bin/compile -watch -p ./", "vscode:prepublish": "gulp" }, - "extensionDependencies": ["andreweinand.node-debug"], + "extensionDependencies": [ + "andreweinand.node-debug" + ], "dependencies": { "q": "^1.4.1", "ws": "^1.0.1" diff --git a/src/common/ios/iOSDebugModeManager.ts b/src/common/ios/iOSDebugModeManager.ts index 029e0118..72971303 100644 --- a/src/common/ios/iOSDebugModeManager.ts +++ b/src/common/ios/iOSDebugModeManager.ts @@ -46,7 +46,7 @@ export class IOSDebugModeManager { const failureString = `Unable to find plist file to ${actionText} debugging`; return pu.retryAsync(() => - this.tryOneAttemptToFindPListFile(), // Operation to retry until succesful + this.tryOneAttemptToFindPListFile(), // Operation to retry until succesful (file: string) => file !== null, // Condition to check if the operation was succesful, and this logic is done IOSDebugModeManager.MAX_RETRIES, diff --git a/src/common/ios/plistBuddy.ts b/src/common/ios/plistBuddy.ts index 1d9faccc..c8fa4b9e 100755 --- a/src/common/ios/plistBuddy.ts +++ b/src/common/ios/plistBuddy.ts @@ -25,11 +25,11 @@ export class PlistBuddy { // Attempt to set the value, and if it fails due to the key not existing attempt to create the key return this.invokePlistBuddy(`Set ${property} ${value}`, plistFile).fail(() => this.invokePlistBuddy(`Add ${property} string ${value}`, plistFile) - ).then(() => {}); + ).then(() => { }); } public deletePlistProperty(plistFile: string, property: string): Q.Promise { - return this.invokePlistBuddy(`Delete ${property}`, plistFile).then(() => {}); + return this.invokePlistBuddy(`Delete ${property}`, plistFile).then(() => { }); } public readPlistProperty(plistFile: string, property: string): Q.Promise { diff --git a/src/common/ios/simulatorPlist.ts b/src/common/ios/simulatorPlist.ts index a5a6b265..64454def 100755 --- a/src/common/ios/simulatorPlist.ts +++ b/src/common/ios/simulatorPlist.ts @@ -21,22 +21,22 @@ export class SimulatorPlist { return Q.all([ new PlistBuddy().getBundleId(this.projectRoot), // Find the name of the application new Node.ChildProcess().exec("xcrun simctl getenv booted HOME").outcome]) // Find the path of the simulator we are running - .spread((bundleId: string, pathBuffer: Buffer) => { - const pathBefore = path.join(pathBuffer.toString().trim(), "Containers", "Data", "Application"); - const pathAfter = path.join("Library", "Preferences", `${bundleId}.plist`); + .spread((bundleId: string, pathBuffer: Buffer) => { + const pathBefore = path.join(pathBuffer.toString().trim(), "Containers", "Data", "Application"); + const pathAfter = path.join("Library", "Preferences", `${bundleId}.plist`); - // Look through $SIMULATOR_HOME/Containers/Data/Application/*/Library/Preferences to find $BUNDLEID.plist - return Q.nfcall(fs.readdir, pathBefore).then((apps: string[]) => { - const mockableFS = new Node.FileSystem(); - const plistCandidates = apps.map((app: string) => path.join(pathBefore, app, pathAfter)).filter(mockableFS.existsSync); - if (plistCandidates.length === 0) { - throw new Error(`Unable to find plist file for ${bundleId}`); - } else if (plistCandidates.length > 1) { - Log.logMessage("Warning: Multiple plist candidates found. Application may not be in debug mode"); - } + // Look through $SIMULATOR_HOME/Containers/Data/Application/*/Library/Preferences to find $BUNDLEID.plist + return Q.nfcall(fs.readdir, pathBefore).then((apps: string[]) => { + const mockableFS = new Node.FileSystem(); + const plistCandidates = apps.map((app: string) => path.join(pathBefore, app, pathAfter)).filter(mockableFS.existsSync); + if (plistCandidates.length === 0) { + throw new Error(`Unable to find plist file for ${bundleId}`); + } else if (plistCandidates.length > 1) { + Log.logMessage("Warning: Multiple plist candidates found. Application may not be in debug mode"); + } - return plistCandidates[0]; + return plistCandidates[0]; + }); }); - }); } } \ No newline at end of file diff --git a/src/common/node/fileSystem.ts b/src/common/node/fileSystem.ts index 60c9e68e..1bd89a43 100644 --- a/src/common/node/fileSystem.ts +++ b/src/common/node/fileSystem.ts @@ -57,7 +57,7 @@ export class FileSystem { */ public exists(filename: string): Q.Promise { return Q.nfcall(fs.stat, filename) - .then(function(){ + .then(function() { return Q.resolve(true); }) .catch(function(err) { @@ -147,14 +147,14 @@ export class FileSystem { return Q.nfcall(fs.mkdir, target); } }) - .then(() => { - return Q.nfcall(fs.readdir, source); - }) - .then(contents => { - Q.all(contents.map((childPath: string): Q.Promise => { - return this.copyRecursive(path.join(source, childPath), path.join(target, childPath)); - })); - }); + .then(() => { + return Q.nfcall(fs.readdir, source); + }) + .then(contents => { + Q.all(contents.map((childPath: string): Q.Promise => { + return this.copyRecursive(path.join(source, childPath), path.join(target, childPath)); + })); + }); } else { return this.copyFile(source, target); } diff --git a/src/common/node/package.ts b/src/common/node/package.ts index 575730f6..c2de3bc1 100644 --- a/src/common/node/package.ts +++ b/src/common/node/package.ts @@ -42,10 +42,10 @@ export class Package { public setMainFile(value: string): Q.Promise { return this.parsePackageInformation() - .then(packageInformation => { - packageInformation.main = value; - return new Node.FileSystem().writeFile(this.informationJsonFilePath(), JSON.stringify(packageInformation)); - }); + .then(packageInformation => { + packageInformation.main = value; + return new Node.FileSystem().writeFile(this.informationJsonFilePath(), JSON.stringify(packageInformation)); + }); } private informationJsonFilePath(): string { diff --git a/src/common/packager.ts b/src/common/packager.ts index 0b545030..16fba182 100644 --- a/src/common/packager.ts +++ b/src/common/packager.ts @@ -40,20 +40,20 @@ export class Packager { this.isRunning().done(running => { if (!running) { return this.monkeyPatchOpnForRNPackager() - .then(() => { - let args = ["--port", Packager.PORT]; - let childEnvForDebugging = Object.assign({}, process.env, { REACT_DEBUGGER: "echo A debugger is not needed: " }); + .then(() => { + let args = ["--port", Packager.PORT]; + let childEnvForDebugging = Object.assign({}, process.env, { REACT_DEBUGGER: "echo A debugger is not needed: " }); - Log.logMessage("Starting Packager", outputChannel); - // The packager will continue running while we debug the application, so we can"t - // wait for this command to finish + Log.logMessage("Starting Packager", outputChannel); + // The packager will continue running while we debug the application, so we can"t + // wait for this command to finish - let spawnOptions = { env: childEnvForDebugging }; + let spawnOptions = { env: childEnvForDebugging }; - new CommandExecutor(this.projectPath).spawnReactCommand("start", args, spawnOptions, outputChannel).then((packagerProcess) => { - this.packagerProcess = packagerProcess; - }); - }).done(); + new CommandExecutor(this.projectPath).spawnReactCommand("start", args, spawnOptions, outputChannel).then((packagerProcess) => { + this.packagerProcess = packagerProcess; + }); + }).done(); } }); @@ -132,7 +132,7 @@ export class Packager { ? Q.resolve(path) : Q.reject("opn package location not found")))); } catch (err) { - console.error ("The package \'opn\' was not found." + err); + console.error("The package \'opn\' was not found." + err); } } @@ -142,20 +142,20 @@ export class Packager { // Finds the 'opn' package return this.findOpnPackage() - .then((opnIndexFilePath) => { - destnFilePath = opnIndexFilePath; - // Read the package's "package.json" - opnPackage = new Package(path.resolve(path.dirname(destnFilePath))); - return opnPackage.parsePackageInformation(); - }).then((packageJson) => { - if (packageJson.main !== Packager.JS_INJECTOR_FILENAME) { - // Copy over the patched 'opn' main file - return new Node.FileSystem().copyFile(Packager.JS_INJECTOR_FILEPATH, path.resolve(path.dirname(destnFilePath), Packager.JS_INJECTOR_FILENAME)) - .then(() => { - // Write/over-write the "main" attribute with the new file - return opnPackage.setMainFile(Packager.JS_INJECTOR_FILENAME); - }); - } - }); + .then((opnIndexFilePath) => { + destnFilePath = opnIndexFilePath; + // Read the package's "package.json" + opnPackage = new Package(path.resolve(path.dirname(destnFilePath))); + return opnPackage.parsePackageInformation(); + }).then((packageJson) => { + if (packageJson.main !== Packager.JS_INJECTOR_FILENAME) { + // Copy over the patched 'opn' main file + return new Node.FileSystem().copyFile(Packager.JS_INJECTOR_FILEPATH, path.resolve(path.dirname(destnFilePath), Packager.JS_INJECTOR_FILENAME)) + .then(() => { + // Write/over-write the "main" attribute with the new file + return opnPackage.setMainFile(Packager.JS_INJECTOR_FILENAME); + }); + } + }); } } diff --git a/src/extension/commandPaletteHandler.ts b/src/extension/commandPaletteHandler.ts index 014ac7a1..9bb42293 100644 --- a/src/extension/commandPaletteHandler.ts +++ b/src/extension/commandPaletteHandler.ts @@ -44,7 +44,7 @@ export class CommandPaletteHandler { public runIos(): void { // Set the Debugging setting to disabled new IOSDebugModeManager(this.workspaceRoot).setSimulatorJSDebuggingModeSetting(/*enable=*/ false) - .catch(() => {}) // If setting the debugging mode fails, we ignore the error and we run the run ios command anyways + .catch(() => { }) // If setting the debugging mode fails, we ignore the error and we run the run ios command anyways .done(() => this.executeCommandInContext(() => this.executeReactNativeRunCommand("run-ios"))); } diff --git a/src/extension/rn-extension.ts b/src/extension/rn-extension.ts index 8fb7c6f6..c1a9ae04 100644 --- a/src/extension/rn-extension.ts +++ b/src/extension/rn-extension.ts @@ -33,7 +33,7 @@ export function activate(context: vscode.ExtensionContext): void { const nodeDebugPath = vscode.extensions.getExtension("andreweinand.node-debug").extensionPath; const fsUtil = new FileSystem(); - fsUtil.writeFile(path.resolve(__dirname, "../", "debugger", "nodeDebugLocation.json"), JSON.stringify({nodeDebugPath})).done(); + fsUtil.writeFile(path.resolve(__dirname, "../", "debugger", "nodeDebugLocation.json"), JSON.stringify({ nodeDebugPath })).done(); } /** @@ -74,10 +74,10 @@ function setupReactNativeIntellisense(): void { } TsConfigHelper.allowJs(true) - .then(function() { - return TsConfigHelper.addExcludePaths(["node_modules"]); - }) - .done(); + .then(function() { + return TsConfigHelper.addExcludePaths(["node_modules"]); + }) + .done(); const reactTypingsSource = path.resolve(__dirname, "..", "..", "ReactTypings"); const reactTypingsDest = path.resolve(vscode.workspace.rootPath, ".vscode", "typings"); diff --git a/src/extension/tsconfigHelper.ts b/src/extension/tsconfigHelper.ts index 07a28ad0..d6cb39b1 100644 --- a/src/extension/tsconfigHelper.ts +++ b/src/extension/tsconfigHelper.ts @@ -21,17 +21,17 @@ export class TsConfigHelper { let fileSystem = new FileSystem(); return fileSystem.exists(tsConfigPath) - .then(function(exists: boolean): Q.Promise { - if (!exists) { - return fileSystem.writeFile(tsConfigPath, "{}"); - } - }) - .then(function(): Q.Promise { - return fileSystem.readFile(tsConfigPath, "utf-8"); - }) - .then(function(jsonContents: string): Q.Promise { - return JSON.parse(jsonContents); - }); + .then(function(exists: boolean): Q.Promise { + if (!exists) { + return fileSystem.writeFile(tsConfigPath, "{}"); + } + }) + .then(function(): Q.Promise { + return fileSystem.readFile(tsConfigPath, "utf-8"); + }) + .then(function(jsonContents: string): Q.Promise { + return JSON.parse(jsonContents); + }); } /** @@ -48,18 +48,18 @@ export class TsConfigHelper { */ public static allowJs(enabled: boolean): Q.Promise { return TsConfigHelper.readConfigJson() - .then(function(tsConfigJson: any): Q.Promise { - tsConfigJson.compilerOptions = tsConfigJson.compilerOptions || {}; + .then(function(tsConfigJson: any): Q.Promise { + tsConfigJson.compilerOptions = tsConfigJson.compilerOptions || {}; - // Return if the setting is already correctly set. - if (tsConfigJson.compilerOptions.allowJs === enabled) { - return Q.resolve(void 0); - } + // Return if the setting is already correctly set. + if (tsConfigJson.compilerOptions.allowJs === enabled) { + return Q.resolve(void 0); + } - tsConfigJson.compilerOptions.allowJs = enabled; + tsConfigJson.compilerOptions.allowJs = enabled; - return TsConfigHelper.writeConfigJson(tsConfigJson); - }); + return TsConfigHelper.writeConfigJson(tsConfigJson); + }); } /** @@ -67,22 +67,22 @@ export class TsConfigHelper { */ public static addExcludePaths(excludePaths: string[]): Q.Promise { return TsConfigHelper.readConfigJson() - .then(function(tsConfigJson: any) { - let currentExcludes: string[] = tsConfigJson.exclude || []; - let isDirty: boolean = false; + .then(function(tsConfigJson: any) { + let currentExcludes: string[] = tsConfigJson.exclude || []; + let isDirty: boolean = false; - excludePaths.forEach(function(exclude: string){ - if (currentExcludes.indexOf(exclude) < 0) { - currentExcludes.push(exclude); - isDirty = true; + excludePaths.forEach(function(exclude: string) { + if (currentExcludes.indexOf(exclude) < 0) { + currentExcludes.push(exclude); + isDirty = true; + } + }); + + if (isDirty) { + tsConfigJson.exclude = currentExcludes; + + return TsConfigHelper.writeConfigJson(tsConfigJson); } }); - - if (isDirty) { - tsConfigJson.exclude = currentExcludes; - - return TsConfigHelper.writeConfigJson(tsConfigJson); - } - }); } } diff --git a/test/SampleApplication/package.json b/test/SampleApplication/package.json index d8c2806b..11ecc227 100644 --- a/test/SampleApplication/package.json +++ b/test/SampleApplication/package.json @@ -1,11 +1,11 @@ { - "name": "SampleApplication", - "version": "0.0.1", - "private": true, - "scripts": { - "start": "node node_modules/react-native/local-cli/cli.js start" - }, - "dependencies": { - "react-native": "^0.19.0" - } -} + "name": "SampleApplication", + "version": "0.0.1", + "private": true, + "scripts": { + "start": "node node_modules/react-native/local-cli/cli.js start" + }, + "dependencies": { + "react-native": "^0.19.0" + } +} \ No newline at end of file diff --git a/tslint.json b/tslint.json index 5b5069af..61600fd3 100644 --- a/tslint.json +++ b/tslint.json @@ -1,112 +1,111 @@ { - "rules": { - "align": [ - true, - "parameters", - "statements" - ], - "ban": false, - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "curly": false, - "forin": true, - "indent": [ - true, - "spaces" - ], - "jsdoc-format": true, - "label-position": true, - "label-undefined": true, - "max-line-length": [ - false, - 140 - ], - "member-access": true, - "member-ordering": [ - true, - "variables-before-functions", - "public-before-private" - ], - "no-any": false, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-construct": true, - "no-debugger": true, - "no-duplicate-key": true, - "no-duplicate-variable": true, - "no-empty": false, - "no-eval": true, - "no-inferrable-types": false, - "no-internal-module": false, - "no-keyword-named-variables": true, - "no-require-imports": false, - "no-shadowed-variable": true, - "no-string-literal": true, - "no-switch-case-fall-through": false, - "no-trailing-whitespace": true, - "no-unreachable": true, - "no-unused-expression": true, - "no-unused-variable": true, - "no-use-before-declare": true, - "no-var-keyword": true, - "no-var-requires": true, - "object-literal-sort-keys": true, - "one-line": [ - true, - "check-open-brace", - "check-catch", - "check-else", - "check-whitespace" - ], - "quotemark": [ - true, - "double" - ], - "radix": true, - "semicolon": true, - "switch-default": true, - "trailing-comma": [ - true, - { - "multiline": "always", - "singleline": "never" - } - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "variable-name": false, - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } -} - + "rules": { + "align": [ + true, + "parameters", + "statements" + ], + "ban": false, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": false, + "forin": true, + "indent": [ + true, + "spaces" + ], + "jsdoc-format": true, + "label-position": true, + "label-undefined": true, + "max-line-length": [ + false, + 140 + ], + "member-access": true, + "member-ordering": [ + true, + "variables-before-functions", + "public-before-private" + ], + "no-any": false, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-inferrable-types": false, + "no-internal-module": false, + "no-keyword-named-variables": true, + "no-require-imports": false, + "no-shadowed-variable": true, + "no-string-literal": true, + "no-switch-case-fall-through": false, + "no-trailing-whitespace": true, + "no-unreachable": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "no-var-requires": true, + "object-literal-sort-keys": true, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "radix": true, + "semicolon": true, + "switch-default": true, + "trailing-comma": [ + true, + { + "multiline": "always", + "singleline": "never" + } + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} \ No newline at end of file