/* eslint-enable no-useless-escape 
Creates a project object (see projectFile.js/parseProjectFile) from
a project path and name

@param {*} projectPath
@param {*} projectName
187134
function createProjectObject (projectPath, projectName) {
    var locations = {
        root: projectPath,
        pbxproj: path.join(projectPath, projectName + '.xcodeproj', 'project.pbxproj')
    };

    return projectFile.parse(locations);
}
950540
function devHandler(curPath, importPath, jsFilename) {
    var absPath = resolve(importPath, jsFilename)

    var projectDir = path.resolve(require.resolve('./index.js'), '..', '..', '..', '..', '..')

    absPath = absPath.replace(projectDir, '@areslabs/babel-plugin-import-css/rncsscache')
    curPath.node.source.value = (absPath + '.js')
}
1197869
function isSafeToCreateProjectIn(root, name) {
  const validFiles = [
    '.DS_Store',
    'Thumbs.db',
    '.git',
    '.gitignore',
    '.idea',
    'README.md',
    'LICENSE',
    'web.iml',
    '.hg',
    '.hgignore',
    '.hgcheck',
  ];
  console.log();

  const conflicts = fs
    .readdirSync(root)
    .filter(file => !validFiles.includes(file));
  if (conflicts.length < 1) {
    return true;
  }

  console.log(
    `The directory ${chalk.green(name)} contains files that could conflict:`
  );
  console.log();
  for (const file of conflicts) {
    console.log(`  ${file}`);
  }
  console.log();
  console.log(
    'Either try using a new directory name, or remove the files listed above.'
  );

  return false;
}
957630
function createDir(srcPath, desPath) {
    var pathInfo = path.parse(desPath);
    var searchvalue = pathInfo.root[pathInfo.root.length - 1]
    var start = 0;
    var found = pathInfo.dir.indexOf(searchvalue);
    var subPath = '';
    var dirs = [];

    if (found != -1) {
        while (true) {
            subPath = pathInfo.dir.substr(start, found - start + 1);
            if (subPath != '') {
                dirs.push(subPath);
            }
            start = found + 1;
            found = pathInfo.dir.indexOf(searchvalue, start);
            if (found == -1) {
                if (start < pathInfo.dir.length) {
                    dirs.push(pathInfo.dir.substr(start));
                }
                break;
            }
        }
    }

    subPath = '';
    dirs.forEach(function (dir, num) {
        subPath += dir;
        if (!fs.existsSync(subPath)) {
            try {
                fs.mkdirSync(subPath);
            } catch (e) {
                if (e.code != 'EEXIST') {
                    console.log('[error] ', e);
                };
            }
            console.log('[info] create  dir:', subPath);
        }
        if (num == dirs.length - 1 && pathInfo.base != '') {
            copyFile(srcPath, desPath);
            //console.log('src file:', srcPath);
            //console.log('des file:', desPath);
        }
    });

}
639455
function parseStringPropertyPath(propertyPath) {
            //jshint maxcomplexity:13
            //jshint maxdepth:3
            //REASON: taken from https://github.com/marklagendijk/lodash-deep/blob/master/lodash-deep.js
            //        Need to look at refactoring it.
            var character = '';
            var parsedPropertyPath = [];
            var parsedPropertyPathPart = '';
            var escapeNextCharacter = false;
            var isSpecialCharacter = false;
            var insideBrackets = false;

            // Walk through the path and find backslashes that escape periods or other backslashes, and split on unescaped
            // periods and brackets.
            for (var i = 0; i < propertyPath.length; i++) {
                character = propertyPath[i];
                isSpecialCharacter = (character === '\\' || character === '[' || character === ']' || character === '.');

                if (isSpecialCharacter && !escapeNextCharacter) {
                    if (insideBrackets && character !== ']') {
                        throw new SyntaxError('unexpected "' + character + '" within brackets at character ' + i + ' in property path ' + propertyPath);
                    }

                    switch (character) {
                        case '\\':
                            escapeNextCharacter = true;
                            break;
                        case ']':
                            insideBrackets = false;
                            break;
                        case '[':
                            insideBrackets = true;
                            /* falls through */
                        case '.':
                            parsedPropertyPath.push(parsedPropertyPathPart);
                            parsedPropertyPathPart = '';
                            break;
                    }
                } else {
                    parsedPropertyPathPart += character;
                    escapeNextCharacter = false;
                }
            }

            if (parsedPropertyPath[0] === '') {
                //allow '[0]', or '.0'
                parsedPropertyPath.splice(0, 1);
            }

            // capture the final part
            parsedPropertyPath.push(parsedPropertyPathPart);
            return parsedPropertyPath;
        }
737107
function inlineResources(projectPath) {

  // Match only TypeScript files in projectPath.
  const files = glob.sync('**/*.ts', {cwd: projectPath});

  // For each file, inline the templates and styles under it and write the new file.
  return Promise.all(files.map(filePath => {
    const fullFilePath = path.join(projectPath, filePath);
    return readFile(fullFilePath, 'utf-8')
      .then(content => inlineResourcesFromString(content, url => {
        // Resolve the template url.
        return path.join(path.dirname(fullFilePath), url);
      }))
      .then(content => writeFile(fullFilePath, content))
      .catch(err => console.error('An error occured: ', err));
  }));
}
465672
public void useProject(String projectName) {
        removeProject(projectName);
        recentProjectsList.addFirst(projectName);
        while (recentProjectsList.size() > MAX_RECENT_FILES) {
            recentProjectsList.removeLast();
        }
    }
232424
function ParsePath(u) {
    //Parse the url
    let p = url.parse(u);
    //Get the path name
    let pname = p.pathname;
    //Check for Windows
    if( process.platform === "win32") {
        //Remove the first / from the path
        //https://github.com/jmjuanes/electron-ejs/pull/4#issuecomment-219254028
        pname = pname.substr(1);
    }
    //Sanitize URL. Spaces turn into `%20` symbols in the path and
    //throws a `File Not Found Event`. This fix allows folder paths to have
    //spaces in the folder name.
    //https://github.com/jmjuanes/electron-ejs/pull/9
    return pname.replace(/\s/g, " ").replace(/%20/g, " ");
}
624149
function(filename, fileInfo) {
		var projectName = path.relative(
			app.config.paths.projects,
			path.dirname(filename)
		);

		if (app.projects.get(projectName)) {
			logger.log('Unload project: "' + projectName + '"');
			app.projects.unload({name: projectName});
		}

		// on add or change (info is falsy on unlink)
		if (fileInfo) {
			logger.log('Load project "' + projectName + '" on change');
			app.projects.load({name: projectName}, function(err) {
				if (err) {
					return logger.error(
						'Error during load project "' + projectName + '": ',
						err.stack || err
					);
				}
				logger.log(
					'Project "' + projectName + '" loaded:',
					JSON.stringify(app.projects.get(projectName), null, 4)
				);
			});
		}
	}
652583
function addWelcomeProjectPath(path) {
        var welcomeProjects = ProjectModel._addWelcomeProjectPath(path,
                                                                 PreferencesManager.getViewState("welcomeProjects"));
        PreferencesManager.setViewState("welcomeProjects", welcomeProjects);
    }
661469
def __load_project_from_file_path(file_path):
    '''
    
    '''
    try:
        project = get_project(project_dir=os.path.dirname(file_path),
                              config_path=[os.path.basename(file_path)])
    except Exception as inst:
        return __handle_except(inst)
    return project
1127073
function(path) {
          var node = path.node;
          // console.log('literal node',node);
          if (typeof node.value === 'string') {
            options.sourceNameVariations.forEach(function(variation,index){
              var sourceIndex, typeIndex, segment;
              var sourceRegexp = new RegExp(variation);
              var destReplacement = options.destNameVariations[index];
              var variationIndex = node.value.indexOf(variation);
              if (variationIndex !== -1) {
                // console.log(node.value.indexOf(variation))
                // console.log('match: ',variation, destReplacement, node)
                if (variationIndex === 0 || node.value.charAt(variationIndex - 1) === ' ') {
                  hasSourceRef = true;
                  // console.log(node.value.replace(sourceRegexp, destReplacement))
                  node.value = node.value.replace(sourceRegexp, destReplacement);
                } else {

                  /*
                  example1: my-app/components/foo/bar/foo-bar.js
                  example2: my-app/components/bar/foo-bar.js
                  sourceName: bar/foo-bar.js
                  match the sourceName, determine if the sourcename is at
                  the type root (components for this example)

                  this probably needs to be handled at a structure level.
                  */
                  // console.log(variation + ' matched: ' + node.value + ', but was not first index');
                  sourceIndex = node.value.indexOf(options.sourceName);
                  typeIndex = node.value.indexOf(options.sourceTypeName);
                  segment = node.value.substr((typeIndex + options.sourceTypeName.length + 1), node.value.length);
                  // console.log('diff', segment, options.sourceName,typeIndex, (typeIndex + options.sourceTypeName.length), sourceIndex, options.sourceTypeName);
                  if (segment === options.sourceName) {
                    hasSourceRef = true;
                    node.value = node.value.replace(sourceRegexp, destReplacement);
                    // console.log('rewriting literal', node.value);
                  }
                }
              }
            });
          }
          this.traverse(path);
        }
1362340
function Logger(name) {
    var prjName = module.exports.PROJECT_NAME;
    this.name = prjName ? prjName + ':' + name : name;
    this._debug = debug(this.name);
    this._debug.log = logDebug;
    this.debugEnabled = debug.enabled(this.name);
    if (this.debugEnabled) {
        logDebug('[%s] debug is %s', this.name.blue, 'ENABLED'.green);
    }
}
1131720
function(configPath, configNames, config) {
	var configsUsed = [];

	config = config || projectConfig;

	// work with the raw configuration object
	if (config && config.root) {
		config = config.root();
	}

	config = convict(config);
	configPath = path.resolve(appPath, configPath);
	configNames = configNames || [];

	configNames.forEach(function(configName) {
		var file;

		// Ignore local config in production mode
		if (configName == 'local' && nodeEnv === 'production') { return; }

		file = path.join(configPath, 'config-'+configName);
		file += configName === 'default' ? '.js' : '.json';

		if (fs.existsSync(file)) {

			if (configName === 'default') {
				config = convict( require(file) );
				config.load(dynamicDefaults);
			}
			else {
				config.loadFile( file );
			}

			// logging
			configName === 'default' ? configsUsed.push('xtc defaults') : configsUsed.push(configName);
		}
	});

	// be informative
	!process.env.testRun
		&& configsUsed.push('env', 'args')
		&& console.log('configuration:', configsUsed.join(' < '));

	return config;
}
978624
private String getProjectFile( String projectName, String filePattern)
    {
    String projectFile = null;
    if( !StringUtils.isBlank( filePattern))
      {
      Matcher matcher = projectFilePattern_.matcher( filePattern);
      if( matcher.matches())
        {
        projectFile =
          StringUtils.isBlank( matcher.group(2))
          ? filePattern
          : matcher.group(1) + projectName + matcher.group(3);
        }
      }
    
    return projectFile;
    }
471743
function nameAnonymousExports(programPath) {
    // Name anonymous exported locals.
    programPath.get('body').forEach(child => {
        if (!child.isExportDefaultDeclaration()) {
            return;
        }

        // export default foo;
        const declaration = child.get('declaration');
        if (declaration.isFunctionDeclaration()) {
            if (!declaration.node.id) {
                declaration.node.id = declaration.scope.generateUidIdentifier('default');
            }
        }
        else if (declaration.isClassDeclaration()) {
            if (!declaration.node.id) {
                declaration.node.id = declaration.scope.generateUidIdentifier('default');
            }
        }
        else {
            const id = declaration.scope.generateUidIdentifier('default');
            const namedDecl = babelTypes.exportNamedDeclaration(null, [
                babelTypes.exportSpecifier(babelTypes.identifier(id.name), babelTypes.identifier('default')),
            ]);
            namedDecl._blockHoist = child.node._blockHoist;

            const varDecl = babelTypes.variableDeclaration('var', [
                babelTypes.variableDeclarator(id, declaration.node),
            ]);
            varDecl._blockHoist = child.node._blockHoist;

            child.replaceWithMultiple([namedDecl, varDecl]);
        }
    });
}
1223602
public boolean projectExists(String name) throws IllegalArgumentException {
        if (name == null || name.isEmpty()) {
            throw new IllegalArgumentException("Project name cannot be empty");
        }
        return listProjects().stream()
            .map(p -> p.getMetadata().getName())
            .anyMatch(Predicate.isEqual(name));
    }