Copy module_settings.json and add release and build information
342589
def create_release_settings_action(target, source, env):
    

    with open(str(source[0]), "r") as fileobj:
        settings = json.load(fileobj)

    settings['release'] = True
    settings['release_date'] = datetime.datetime.utcnow().isoformat()
    settings['dependency_versions'] = {}

    #Also insert the versions of every dependency that we used to build this component
    for dep in env['TILE'].dependencies:
        tile = IOTile(os.path.join('build', 'deps', dep['unique_id']))

        settings['dependency_versions'][dep['unique_id']] = str(tile.parsed_version)

    with open(str(target[0]), "w") as fileobj:
        json.dump(settings, fileobj, indent=4)
381823
def update_configs(self, release):
        
        git_repo = release['git_repo']
        git_cache = release['git_cache']
        if not os.path.isdir(git_cache):
            self.call(['git', 'clone', '--mirror', git_repo, git_cache])
        else:
            self.call(['git', 'fetch', '--all', '--prune'], cwd=git_cache)
        git_dir = release['git_dir'] = os.path.join(release['tmp_dir'],
                                                    os.path.basename(git_repo))
        self.call(['git', 'clone', '-b', release['git_branch'],
                   git_cache, git_dir])

        if release['delete_repo_files']:
            for repo_file in glob.glob(os.path.join(git_dir, '*.repo')):
                self.log.info('Deleting %s' % repo_file)
                os.unlink(repo_file)
768541
def dump(self):
        """"""
        try:
            import yaml
            cfg_file = self._cfg_file()
            cfg_dir, __ = os.path.split(cfg_file)
            os.makedirs(cfg_dir, exist_ok=True)
            with open(cfg_file, 'w') as f:
                yaml.dump(self, f)
        except ImportError as err:
            raise RuntimeError(
                'Cannot dump the configuration settings to file. You need to '
                'install the necessary dependencies (pyyaml, appdirs).'
            ) from err
620336
def update_release(id, **kwargs):
    
    data = update_release_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
1173397
def setup(app):
    """"""
    app.add_config_value('jsdoc_source_root', '..', 'env')
    app.add_config_value('jsdoc_output_root', 'javascript', 'env')
    app.add_config_value('jsdoc_exclude', [], 'env')
    app.connect('builder-inited', generate_docs)
158343
def add_info(self, data):
        """"""
        for key in data:
            # verboten
            if key in ('status','state','name','id','application','services','release'):
                raise ValueError("Sorry, cannot set build info with key of {}".format(key))
            self.obj[key] = data[key]
        self.changes.append("Adding build info")
        return self
941468
def set_version(version, rootdir = Dir.pwd, options = {})
      exit_status = 0
      type    = (options[:type])    ? options[:type]    : FalkorLib.config[:versioning][:type]
      source  = (options[:source])  ? options[:source]  : FalkorLib.config[:versioning][:source][ type ]
      versionfile = File.join( rootdir, source[:filename] ) unless source[:filename].nil?
      major, minor, patch = major(version), minor(version), patch(version)
      #tocommit = ""
      case type
      when 'file'
        info "writing version changes in #{source[:filename]}"
        File.open(versionfile, 'w') { |f| f.puts version } #if File.exist? ( versionfile )
      when 'gem'
        info "=> writing version changes in #{source[:filename]}"
        File.open(versionfile, 'r+') do |f|
          text = f.read
          text.gsub!(/^(\s*)MAJOR\s*,\s*MINOR,\s*PATCH\s*=\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(.*)$/,
                     '\1' + "MAJOR, MINOR, PATCH = #{major}, #{minor}, #{patch}" + '\5')
          f.rewind
          f.write(text)
        end
      when 'puppet_module'
        info "=> writing version changes in #{source[:filename]}"
        metadata = JSON.parse( IO.read( versionfile ) )
        metadata["version"] = version
        File.open(versionfile, "w") do |f|
          f.write JSON.pretty_generate( metadata )
        end
        #exit 1
      end
      if FalkorLib::Git.init?(rootdir)
        filelist = FalkorLib::Git.list_files( rootdir )
        Dir.chdir( rootdir ) do
          next if source[:filename].nil?
          unless filelist.include?( source[:filename] )
            warning "The version file #{source[:filename]} is not part of the Git repository"
            answer = ask("Adding the file to the repository? (Y|n)", 'Yes')
            next if answer =~ /n.*/i
            exit_status = FalkorLib::Git.add(versionfile, "Adding the version file '#{source[:filename]}', inialized to the '#{version}' version" )
            next
          end
          run %( git diff #{source[:filename]} )
          answer = ask(cyan("=> Commit the changes of the version file to the repository? (Y|n)"), 'Yes')
          next if answer =~ /n.*/i
          run %( git commit -s -m "bump to version '#{version}'" #{source[:filename]} )
          exit_status = $?.to_i
          # if (type == 'gem' && File.exists?(File.join(rootdir, 'Gemfile')) )
          #     run %{
          #        sleep 2
          #        bundle update falkorlib
          #        git commit -s -m "Update Gemfile.lock accordingly" Gemfile.lock
          #     } if command?( 'bundle' )
          # end
        end
      end
      exit_status
    end
1289344
function build(pkgName, pkgVersion) {
    clean();

    // Update framework name/version/build date in Runtime class
    updateRuntimeInfo(Date.now(), pkgName, pkgVersion);

    const buildDir = "./build";

    fse.readdirSync(buildDir).forEach(file => {
        if (file.match(/tsconfig\..+\.json/gi)) {
            const tsconfigPath = path.resolve(buildDir, file);
            const opts = require(tsconfigPath).compilerOptions;
            const target = opts.target + "-" + opts.module;
            const targetDir = "./dist/" + target + "/";

            logInfo("Build distribution package " + target);

            // First, bring the desired tsconfig file into place
            fse.copySync(tsconfigPath, "./" + TS_TARGETDIR + "/tsconfig.json");

            // Transpile TS into JS code, using TS compiler in local typescript npm package.
            // Remove all comments except copy-right header comments, and do not
            // generate corresponding .d.ts files (see next step below).
            childProcess.execSync(path.resolve("./node_modules/.bin/tsc") +
                " --project " + TS_TARGETDIR +
                " --outDir " + targetDir +
                " --removeComments true --declaration false",
                // redirect child output to parent's stdin, stdout and stderr
                { stdio: "inherit" });

            // Only emit .d.ts files, using TS compiler in local typescript npm package.
            // The generated declaration files include all comments so that
            // IDEs can provide this information to developers.
            childProcess.execSync(path.resolve("./node_modules/.bin/tsc") +
            " --project " + TS_TARGETDIR +
            " --outDir " + targetDir +
            " --removeComments false --declaration true --emitDeclarationOnly true",
            // redirect child output to parent's stdin, stdout and stderr
            { stdio: "inherit" });

            // Copy scripts folder into distribution package
            fse.copySync("./scripts", targetDir + "scripts");

            // Copy readme into distribution package
            fse.copySync("./README.md", targetDir + "README.md");

            // Copy license into distribution package
            fse.copySync("./LICENSE", targetDir + "LICENSE");

            // Copy tslint.json into distribution package (for use by Coaty projects)
            fse.copySync("./build/tslint.json", targetDir + "tslint-config.json");

            // Copy .npmignore into distribution package
            fse.copySync("./.npmignore", targetDir + ".npmignore");

            // Copy package.json into distribution package
            fse.copySync("./package.json", targetDir + "package.json");

            // Update package.json to include distribution as prerelease in version
            updatePackageInfo(target, targetDir + "package.json", file !== "tsconfig.es5-commonjs.json");
        }
    });
}
295065
async function copy({ watch } = {}) {
  const ncp = Promise.promisify(require('ncp'));

  await Promise.all([
    ncp('src/public', 'build/public'),
    ncp('src/content', 'build/content'),
  ]);

  await fs.writeFile('./build/package.json', JSON.stringify({
    private: true,
    engines: pkg.engines,
    dependencies: pkg.dependencies,
    scripts: {
      start: 'node server.js',
    },
  }, null, 2));

  if (watch) {
    const watcher = await new Promise((resolve, reject) => {
      gaze('src/content/**/*.*', (err, val) => err ? reject(err) : resolve(val));
    });
    watcher.on('changed', async (file) => {
      const relPath = file.substr(path.join(__dirname, '../src/content/').length);
      await ncp(`src/content/${relPath}`, `build/content/${relPath}`);
    });
  }
}
884491
def build_napalm_ansible_module_docs(app):
    """"""

    # Add script to clone napalm-ansible repo
    status = subprocess.call(
        "./build-ansible-module-docs.sh", stdout=sys.stdout, stderr=sys.stderr
    )

    if status != 0:
        print("Something bad happened when processing the Ansible modules.")
        sys.exit(-1)

    env = Environment(loader=FileSystemLoader("."))

    modules_dir = "./integrations/ansible/modules/source"
    module_files = glob("{0}/*.json".format(modules_dir))
    for module_file in module_files:
        with open(module_file, "r") as f:
            module = module_file.split("/")[-1].split(".")[0]
            data = json.loads(f.read())
            data["name"] = module

        module_dir = "./integrations/ansible/modules/{0}".format(module)

        try:
            os.stat(module_dir)
        except Exception:
            os.mkdir(module_dir)

        template_file = env.get_template("ansible-module.j2")
        rendered_template = template_file.render(**data)

        with open("{0}/index.rst".format(module_dir), "w") as f:
            f.write(rendered_template)
900785
def add_patchs_to_build_without_pkg_config(self, lib_dir, include_dir):
        
        additional_patches = [
            {
                'src': r"pkgconfig\('--libs-only-L'\)",
                'dest': "['{0}']".format(lib_dir),
            },
            # Considering -libs-only-l and -libs-only-L
            # https://github.com/rpm-software-management/rpm/pull/327
            {
                'src': r"pkgconfig\('--libs(-only-l)?'\)",
                'dest': "['rpm', 'rpmio']",
                'required': True,
            },
            {
                'src': r"pkgconfig\('--cflags'\)",
                'dest': "['{0}']".format(include_dir),
                'required': True,
            },
        ]
        self.patches.extend(additional_patches)
657233
function generateRelease() {
    ReleaseOps.generateRelease();
    const releaseInfo = JSON.parse(cat(".eslint-release-info.json"));

    echo("Generating site");
    target.gensite();
    generateBlogPost(releaseInfo);
    commitSiteToGit(`v${releaseInfo.version}`);
}
1192598
function() {
      'use strict';
      var filesToCopy = {
         'widget.json': 'widget.json',
         'gitignore': '.gitignore',
         'spec/spec_runner.html': 'spec/spec_runner.html',
         'spec/spec_runner.js': 'spec/spec_runner.js',
         'spec/widget.spec.js': 'spec/' + this.placeholder.name + '.spec.js'
      };
      var integrationTechnology = this.placeholder.laxarIntegrationTechnology;
      var widget = !this.options.activity;

      if( widget && integrationTechnology !== 'react' ) {
         filesToCopy[ 'default.theme/widget.html' ] = 'default.theme/' + this.placeholder.name + '.html';
      }
      if( widget ) {
         filesToCopy[ 'default.theme/css/widget.css' ] = 'default.theme/css/' + this.placeholder.name + '.css';
      }

      if( integrationTechnology === 'plain' ) {
         if( !widget ) {
            filesToCopy[ 'controller.plain.activity.js' ] = this.placeholder.name + '.js';
         }
         else {
            filesToCopy[ 'controller.plain.widget.js' ] = this.placeholder.name + '.js';
         }
      }
      else if( integrationTechnology === 'angular' ) {
         filesToCopy[ 'controller.angular.js' ] = this.placeholder.name + '.js';
      }
      else if( integrationTechnology === 'react' ) {
         filesToCopy[ 'controller.react.jsx' ] = this.placeholder.name + '.jsx';
      }

      if( this.placeholder.infrastructure ) {
         filesToCopy[ 'README.md' ] = 'README.md';
         if( widget && integrationTechnology !== 'react') {
            filesToCopy[ 'bower.widget.json' ] = 'bower.json';
         }
         else if ( widget && integrationTechnology === 'react' ) {
            filesToCopy[ 'bower.react.widget.json' ] = 'bower.json';
         }
         else {
            filesToCopy[ 'bower.activity.json' ] = 'bower.json';
         }
      }
      for( var file in filesToCopy ) {
         if( filesToCopy.hasOwnProperty( file ) ) {
            this.fs.copyTpl(
               this.templatePath( file ),
               this.destinationPath(
                  path.join( this.widgetDirname, this.placeholder.name, filesToCopy[ file ] )
               ),
               this.placeholder
            );
         }
      }
   }
386920
def _generate_metadata_file(workdir,
                            archive_name,
                            platform,
                            python_versions,
                            package_name,
                            package_version,
                            build_tag,
                            package_source,
                            wheels):
    
    logger.debug('Generating Metadata...')
    metadata = {
        'created_by_wagon_version': _get_wagon_version(),
        'archive_name': archive_name,
        'supported_platform': platform,
        'supported_python_versions': python_versions,
        'build_server_os_properties': {
            'distribution': None,
            'distribution_version': None,
            'distribution_release': None,
        },
        'package_name': package_name,
        'package_version': package_version,
        'package_build_tag': build_tag,
        'package_source': package_source,
        'wheels': wheels,
    }
    if IS_LINUX and platform != ALL_PLATFORMS_TAG:
        distribution, version, release = _get_os_properties()
        metadata.update(
            {'build_server_os_properties': {
                'distribution': distribution.lower(),
                'distribution_version': version.lower(),
                'distribution_release': release.lower()
            }})

    formatted_metadata = json.dumps(metadata, indent=4, sort_keys=True)
    if is_verbose():
        logger.debug('Metadata is: %s', formatted_metadata)
    output_path = os.path.join(workdir, METADATA_FILE_NAME)
    with open(output_path, 'w') as f:
        logger.debug('Writing metadata to file: %s', output_path)
        f.write(formatted_metadata)
268873
function customStrategy(projectDir, builder, cb)
{
  const dest = builder.getTargetDestination(projectDir);
  shelljs.rm('-rf', dest);

  const copyOptions = { overwrite: true, expand: true, dot: true };

  const onCustomInstallerFilesReady = function (err) {
    builder.buildFromSource(dest, projectDir);
    cb();
  };

  const onInstallerFilesReady = function (err) {
    if (err) {
      cb(err);
      return;
    }

    let customInstallerSrc = path.resolve(projectDir, "src", "installer");
    customInstallerSrc = fs.realpathSync(customInstallerSrc);

    const customInstallerTarget = path.resolve(dest, "src", "settings");
    copy(customInstallerSrc, customInstallerTarget, copyOptions, onCustomInstallerFilesReady);
  };

  let installerDir = path.resolve(projectDir, "node_modules", "@deskpro", INSTALLER_PACKAGE_NAME);
  installerDir = fs.realpathSync(installerDir);
  copy(installerDir, dest, copyOptions, onInstallerFilesReady);
}
638930
def load(obj, settings_module, identifier="py", silent=False, key=None):
    """"""
    mod, loaded_from = get_module(obj, settings_module, silent)

    if mod and loaded_from:
        obj.logger.debug("py_loader: {}".format(mod))
    else:
        obj.logger.debug(
            "py_loader: %s (Ignoring, Not Found)", settings_module
        )
        return

    for setting in dir(mod):
        if setting.isupper():
            if key is None or key == setting:
                setting_value = getattr(mod, setting)
                obj.logger.debug(
                    "py_loader: loading %s: %s (%s)",
                    setting,
                    "*****" if "secret" in settings_module else setting_value,
                    identifier,
                )
                obj.set(setting, setting_value, loader_identifier=identifier)

    obj._loaded_files.append(mod.__file__)
967087
def BuildInstallerPkg(self, output_file):
    """"""
    self.CreateInstallDirs()
    self.InterpolateFiles()
    self.RenameGRRPyinstallerBinaries()
    self.SignGRRPyinstallerBinaries()
    self.WriteClientConfig()
    self.Set755Permissions()
    self.RunPkgBuild()
    self.RunProductBuild()
    self.RenamePkgToTemplate(output_file)