Inject requirements into packaged application.
@param {string} requirementsPath requirements folder path
@param {string} packagePath target package path
@param {Object} options our options object
@return {Promise} the JSZip object constructed.
480740
function injectRequirements(requirementsPath, packagePath, options) {
  const noDeploy = new Set(options.noDeploy || []);

  return fse
    .readFileAsync(packagePath)
    .then(buffer => JSZip.loadAsync(buffer))
    .then(zip =>
      BbPromise.resolve(
        glob.sync([path.join(requirementsPath, '**')], {
          mark: true,
          dot: true
        })
      )
        .map(file => [file, path.relative(requirementsPath, file)])
        .filter(
          ([file, relativeFile]) =>
            !file.endsWith('/') &&
            !relativeFile.match(/^__pycache__[\\/]/) &&
            !noDeploy.has(relativeFile.split(/([-\\/]|\.py$|\.pyc$)/, 1)[0])
        )
        .map(([file, relativeFile]) =>
          Promise.all([file, relativeFile, fse.statAsync(file)])
        )
        .map(([file, relativeFile, fileStat]) =>
          zipFile(zip, relativeFile, fse.readFileAsync(file), {
            unixPermissions: fileStat.mode
          })
        )
        .then(() => writeZip(zip, packagePath))
    );
}
592497
protected function createPackageFolder($packagePath)
    {
        $this->info('Create package folder.');

        if (File::exists($packagePath)) {
            $this->info('Package folder already exists. Skipping.');

            return;
        }

        if (! File::makeDirectory($packagePath, 0755, true)) {
            throw new RuntimeException('Cannot create package folder');
        }

        $this->info('Package folder was successfully created.');
    }
1320837
function zipRequirements() {
  const rootZip = new JSZip();
  const src = path.join('.serverless', 'requirements');
  const runtimepath = 'python';

  return addTree(rootZip.folder(runtimepath), src).then(() =>
    writeZip(rootZip, path.join('.serverless', 'pythonRequirements.zip'))
  );
}
1308060
function providePromise(obj, providePromiseName) {
    if(!isString(providePromiseName)) {
      throw new Error('Must provide string as name of promised module');
    }
    di.annotate(obj, new di.ProvidePromise(providePromiseName));
  }
979335
function injectAllRequirements(funcArtifact) {
  if (this.options.layer) {
    // The requirements will be placed in a Layer, so just resolve
    return BbPromise.resolve();
  }

  this.serverless.cli.log('Injecting required Python packages to package...');

  if (this.serverless.service.package.individually) {
    return BbPromise.resolve(this.targetFuncs)
      .filter(func =>
        (func.runtime || this.serverless.service.provider.runtime).match(
          /^python.*/
        )
      )
      .map(func => {
        if (!get(func, 'module')) {
          set(func, ['module'], '.');
        }
        return func;
      })
      .map(func => {
        if (func.module !== '.') {
          const artifact = func.package ? func.package.artifact : funcArtifact;
          const newArtifact = path.join(
            '.serverless',
            `${func.module}-${func.name}.zip`
          );
          func.package.artifact = newArtifact;
          return moveModuleUp(artifact, newArtifact, func.module).then(
            () => func
          );
        } else {
          return func;
        }
      })
      .map(func => {
        return this.options.zip
          ? func
          : injectRequirements(
              path.join('.serverless', func.module, 'requirements'),
              func.package.artifact,
              this.options
            );
      });
  } else if (!this.options.zip) {
    return injectRequirements(
      path.join('.serverless', 'requirements'),
      this.serverless.service.package.artifact || funcArtifact,
      this.options
    );
  }
}
514435
function (packagePath, semverIndex)
	{
		// Check if package file exists
		if ( !fs.existsSync(packagePath) )
		{
			throw new Error(`Package file ${packagePath} is not found.`, 1);
		}

		// Read package file content
		const packageData = JSON.parse( fs.readFileSync( packagePath ) );

		// Increment version according to semver increment index
		packageData.version = module.exports.semverIncrement(packageData.version, semverIndex);

		// Write new package.json
		fs.writeFileSync(packagePath, JSON.stringify( packageData, null, 2));

		// Return incremented version
		return packageData.version;
	}
836642
function prepareProject(cordovaPlatforms, args, /* optional */ projectPath) {
    if (typeof (cordovaPlatforms) == "string") {
        cordovaPlatforms = [cordovaPlatforms];
    }

    if (!projectPath) {
        projectPath = defaultConfig.projectPath;
    }

    var appendedVersion = cache.getModuleVersionFromConfig(defaultConfig);
    if (appendedVersion) {
        appendedVersion = '@' + appendedVersion;
    } else {
        appendedVersion = '';
    }

    return utilities.isCompatibleNpmPackage(defaultConfig.nodePackageName + appendedVersion).then(function (compatibilityResult) {
        switch (compatibilityResult) {
            case utilities.NodeCompatibilityResult.IncompatibleVersion4Ios:
                throw new Error('This Cordova version does not support Node.js 4.0.0 for iOS builds. Either downgrade to an earlier version of Node.js or move to Cordova 5.3.3 or later. See http://go.microsoft.com/fwlink/?LinkID=618471');
            case utilities.NodeCompatibilityResult.IncompatibleVersion5:
                throw new Error('This Cordova version does not support Node.js 5.0.0 or later. Either downgrade to an earlier version of Node.js or move to Cordova 5.4.0 or later. See http://go.microsoft.com/fwlink/?LinkID=618471');
        }

        return setupCordova();
    }).then(function (cordova) {
        return addSupportPluginIfRequested(cordova, defaultConfig);
    }).then(function (cordova) {
        // Add platforms if not done already
        var promise = _addPlatformsToProject(cordovaPlatforms, projectPath, cordova);
        //Build each platform with args in args object
        cordovaPlatforms.forEach(function (platform) {
            promise = promise.then(function () {
                // Build app with platform specific args if specified
                var callArgs = utilities.getCallArgs(platform, args);
                var argsString = _getArgsString(callArgs.options);
                console.log('Queueing prepare for platform ' + platform + ' w/options: ' + argsString);
                return cordova.raw.prepare(callArgs);
            });
        });

        return promise;
    });
}
953006
protected void addRequiredPath(String requiredPath) {
        if(requiredPath == null) {
            throw new IllegalArgumentException("Required path can't be null.");
        }
        DefaultOperationRequestAddress requiredAddress = new DefaultOperationRequestAddress();
        CommandLineParser.CallbackHandler handler = new DefaultCallbackHandler(requiredAddress);
        try {
            ParserUtil.parseOperationRequest(requiredPath, handler);
        } catch (CommandFormatException e) {
            throw new IllegalArgumentException("Failed to parse nodeType: " + e.getMessage());
        }
        addRequiredPath(requiredAddress);
    }
40465
function createPackageJson(plugin_path) {
    var pluginInfo = new PluginInfo(plugin_path);

    var defaults = {
        id:pluginInfo.id,
        version:pluginInfo.version,
        description:pluginInfo.description,
        license:pluginInfo.license,
        keywords:pluginInfo.getKeywordsAndPlatforms(),
        repository:pluginInfo.repo,
        bugs:pluginInfo.issue,
        engines:pluginInfo.getEngines(),
        platforms: pluginInfo.getPlatformsArray()
    };

    fs.writeFile(path.join(__dirname,'defaults.json'), JSON.stringify(defaults), 'utf8', function (err) {
        if (err) throw err;
        events.emit('verbose', 'defaults.json created from plugin.xml');
        var initFile = require.resolve('./init-defaults');
        var dir = process.cwd();

        init(dir, initFile, {}, function (err, data) {
            if(err) throw err;
            events.emit('verbose', 'Package.json successfully created');
        });
    });
    return Q();
}
1297211
async function bundle(opts: *) {
  const directory = process.cwd();
  const configPath = getWebpackConfig(directory, opts.config);

  const [
    configs,
    availablePlatforms,
  ] = makeReactQMLConfig(
    // $FlowFixMe: Dynamic require
    require(configPath),
    {
      root: directory,
      dev: opts.dev,
      minify: opts.minify,
      bundle: true,
    }
  );

  const config = configs[availablePlatforms.indexOf(opts.platform)];

  if (opts.assetsDest) {
    config.output.path = path.isAbsolute(opts.assetsDest)
      ? opts.assetsDest
      : path.join(directory, opts.assetsDest);
  }

  if (opts.bundleOutput) {
    config.output.filename = path.isAbsolute(opts.bundleOutput)
      ? path.relative(config.output.path, opts.bundleOutput)
      : path.relative(
          config.output.path,
          path.join(directory, opts.bundleOutput)
        );
  }

  const compiler = webpack(config);

  logger.info(
    messages.initialBundleInformation({
      entry: config.entry,
      dev: opts.dev,
    })
  );

  const stats = await new Promise((resolve, reject) =>
    compiler.run((err, info) => {
      if (err || info.hasErrors()) {
        reject(
          new MessageError(
            messages.bundleFailed({
              errors: err
                ? [err.message]
                : info.toJson({ errorDetails: true }).errors,
            })
          )
        );
      } else {
        resolve(info);
      }
    })
  );

  clear();

  logger.done(
    messages.bundleBuilt({
      stats,
      platform: opts.platform,
      assetsPath: config.output.path,
      bundlePath: config.output.filename,
    })
  );
}
825389
function (classpath) {
            var basePath = Aria.getLogicalPath(classpath);
            for (var i = 0, l = atExtensions.length; i < l; i++) {
                try {
                    var logicalPath = basePath + atExtensions[i];
                    var cacheItem = require.cache[require.resolve(logicalPath)];
                    if (cacheItem) {
                        return logicalPath;
                    }
                } catch (e) {
                    // require.resolve can throw an exception in node.js if the file does not exist
                    // simply try other extensions in that case
                }
            }
            // it may be the classpath of a resource (which would not appear in the require cache):
            var resMgr = aria.core.ResMgr;
            if (resMgr) {
                return resMgr.getResourceLogicalPath(basePath);
            }
        }
858410
public function bundleCommand(string $packageKey, string $serverScript = null, string $clientScript = null)
    {
        $start = microtime(true);
        $filePathResolver = new FilePathResolver();
        /** @var Package $package */
        $package = $this->packageManager->getPackage($packageKey);
        if ($serverScript !== null) {
            $serverScript = $filePathResolver->resolveFilePath($serverScript);
        } else {
            $serverScript = str_replace('@packageResourcesPath', rtrim($package->getResourcesPath(), '/'), $this->reactServerFilePattern);
        }

        if ($clientScript !== null) {
            $clientScript = $filePathResolver->resolveFilePath($clientScript);
        } else {
            $clientScript = str_replace('@packageResourcesPath', rtrim($package->getResourcesPath(), '/'), $this->reactClientFilePattern);
        }

        $identifier = md5($serverScript);

        $request = new ActionRequest(Request::createFromEnvironment());
        $uriBuilder = new UriBuilder();
        $uriBuilder->setRequest($request);

        $controllerContext = new ControllerContext($request, new Response(), new Arguments(), $uriBuilder);

        $unit = new Unit($controllerContext);

        $unit->work(function (App $app) use ($clientScript, $serverScript, $identifier) {
            $this->outputLine();
            $this->output('Transpiling... ');

            $transpiler = new Transpiler($app);
            $transpiler->transpile($identifier, $serverScript, $clientScript)->done(function () use ($app) {
                $this->outputLine('<success>done</success>');
                $app->end();
            });
        });

        $bundler = new Bundler($controllerContext);
        $this->output('Bundling module... ');
        $bundler->bundle($identifier);
        $this->outputLine('<success>done</success>');

        $this->outputLine();
        $elapsed = round(microtime(true) - $start, 2);
        $this->outputLine('Bundled <success>%s</success> in <success>%s seconds</success>.', [$package->getPackageKey(), $elapsed]);
        $this->outputLine();
    }
664032
function(assetsPath, projectPath) {
    if (assetsPath === undefined) {
      throw new Error('ember-cordova: Platform asset path undefined, cant build');
    }

    var platformPath = path.join(projectPath, assetsPath, 'cordova.js');
    var pluginPath = path.join(projectPath, assetsPath, 'cordova_plugins.js');

    if (!existsSync(platformPath) || !existsSync(pluginPath)) {
      logger.warn(
        'Did not find cordova.js or cordova_plugins.js at ' +
        assetsPath +
        '. Ember App LiveReload will still work, but device & plugin APIS will fail.'
      );
    }
  }
499275
public byte[][] load (String packagePath, String key)
        throws IOException
    {
        String[] paths = getPaths(packagePath, key);
        if (paths == null) {
            log.warning("No such sound", "key", key);
            return null;
        }

        byte[][] data = new byte[paths.length][];
        String bundle = getBundle(packagePath);
        for (int ii = 0; ii < paths.length; ii++) {
            data[ii] = loadClipData(bundle, paths[ii]);
        }
        return data;
    }
1277846
function validateSourcePath(sourcePath) {
    const materialPackageJSONPath = pathUtils.resolve(sourcePath, 'package.json');

    return fs.readFileAsync(materialPackageJSONPath, { encoding: 'UTF8' })
        .then(materialPackageJSONString => {
            const package = JSON.parse(materialPackageJSONString);
            if (package.name !== sourcePackageName) {
                throw new Error(`Source path ${sourcePath} does not appear to be a clone of https://github.com/callemall/material-ui`);
            }
            return sourcePath;
        });
}
960701
function requirementsFileExists(servicePath, options, fileName) {
  if (
    options.usePoetry &&
    fse.existsSync(path.join(servicePath, 'pyproject.toml'))
  ) {
    return true;
  }

  if (options.usePipenv && fse.existsSync(path.join(servicePath, 'Pipfile'))) {
    return true;
  }

  if (fse.existsSync(fileName)) {
    return true;
  }

  return false;
}
1190582
function create(modulePath, moduleStack, options) {

        // if flapjack passed in, inject the flapjack and use that without caching anything
        if (options && options.flapjack) {
            return this.injector.injectFlapjack(options.flapjack, moduleStack, options);
        }

        // first check the cache to see if we already loaded it
        if (this.cache[modulePath]) {
            return this.cache[modulePath];
        }

        // if the file doesn't exist throw an error
        var rootDir = this.injector.rootDir;
        var filePath = modulePath;
        if (filePath.indexOf(rootDir) !== 0) { filePath = rootDir + '/' + filePath; }   // add rootDir if not there
        if (!filePath.match(/\.js$/)) { filePath = filePath + '.js'; }                  // add .js if not there
        if (!fs.existsSync(path.normalize(filePath))) {                                                 // if file not there, throw error
            throw new Error('FlapjackFactory got invalid file path: ' + filePath);
        }

        // get the flapjack
        filePath = filePath.substring(0, filePath.length - 3);      // remove the .js
        var flapjack = this.injector.require(filePath);             // require() the module without injecting it
        flapjack = flapjack.server ? flapjack.server : flapjack;    // use the server val if it exists

        // if flapjack is not a function, just return it (i.e. its just a normal require()
        if (!_.isFunction(flapjack)) {
            this.cache[modulePath] = flapjack;
            return flapjack;
        }

        this.cache[modulePath] = this.injector.injectFlapjack(flapjack, moduleStack, options);
        return this.cache[modulePath];
    }