Beispiel #1
0
    def prepublish(self, new_version, atom_semver):
        logging.info('Publishing %s to npm at version %s', self.get_package_name(), new_version)

        # Create temporary directory and copy package into it (without dependencies).
        package = self._config.package_directory
        logging.info('Copying %s to tmpdir', self.get_package_name())
        shutil.copytree(package, self._tmp_package, ignore=shutil.ignore_patterns('node_modules'))

        # Make sure that standard boilerplate files are included in the repo.
        for name, src in self._boilerplate_files.items():
            shutil.copyfile(
                src,
                os.path.join(self._tmp_package, name))

        # Load package.json and rewrite version number within it.
        package_file = os.path.join(self._tmp_package, 'package.json')
        package = json_load(package_file)
        package = update_package_json_versions(self.get_package_name(), package,
            self._config.nuclide_npm_package_names, new_version)

        # Specify the license if it is not already specified.
        if 'license' not in package:
            package['license'] = 'SEE LICENSE IN LICENSE'

        # Write the adjusted package file back to the temporary directory and publish it.
        json_dump(package, package_file)

        # Pre-transpile Babel files, as appropriate.
        self._transpiler.transpile_in_place(self.get_package_name(), self._tmp_package)

        rewrite_shrinkwrap_file(self._tmp_package,
            package, self._config.nuclide_npm_package_names, new_version)
Beispiel #2
0
    def prepublish(self, new_version, atom_semver):
        logging.info('Publishing %s to npm at version %s',
                     self.get_package_name(), new_version)

        # Create temporary directory and copy package into it (without dependencies).
        package = self._config.package_directory
        logging.info('Copying %s to tmpdir', self.get_package_name())
        shutil.copytree(package,
                        self._tmp_package,
                        ignore=shutil.ignore_patterns('node_modules'))

        # Make sure that standard boilerplate files are included in the repo.
        for name, src in self._boilerplate_files.items():
            shutil.copyfile(src, os.path.join(self._tmp_package, name))

        # Load package.json and rewrite version number within it.
        package_file = os.path.join(self._tmp_package, 'package.json')
        package = json_load(package_file)
        package = update_package_json_versions(
            self.get_package_name(), package,
            self._config.nuclide_npm_package_names, new_version)

        # Delete "_atomModuleCache" field from package.json.
        # TODO (chenshen): delete following line once '_atomModuleCache' is not fake.
        if '_atomModuleCache' in package:
            del package['_atomModuleCache']

        # Specify the license if it is not already specified.
        if 'license' not in package:
            package['license'] = 'SEE LICENSE IN LICENSE'

        # Write the adjusted package file back to the temporary directory and publish it.
        json_dump(package, package_file)

        # Pre-transpile Babel files, as appropriate.
        self._transpiler.transpile_in_place(self.get_package_name(),
                                            self._tmp_package)

        rewrite_shrinkwrap_file(self._tmp_package, package,
                                self._config.nuclide_npm_package_names,
                                new_version)
Beispiel #3
0
    def prepublish(self, new_version, atom_semver):
        self._repo = self._checkout_apm_repo()

        logging.info('Publishing %s to apm at version %s',
                     self.get_package_name(), new_version)

        # Clean repo out, leaving .git metadata in place.
        logging.info('Cleaning repo for package %s', self.get_package_name())
        self.clean_repo()

        # Copy files from package into repo.
        package = self._config.package_directory
        logging.info('Copying package %s', self.get_package_name())
        self.copy_into_repo(package)

        # Make sure that standard boilerplate files are included in the repo.
        for name, src in self._boilerplate_files.items():
            shutil.copyfile(src, os.path.join(self._repo, name))

        # Load package.json and rewrite version number within it.
        package_file = os.path.join(self._repo, 'package.json')
        package = json_load(package_file)
        package = update_package_json_versions(
            self.get_package_name(), package,
            self._config.nuclide_npm_package_names, new_version)

        # Specify the license if it is not already specified.
        if 'license' not in package:
            package['license'] = 'SEE LICENSE IN LICENSE'

        # Update the version of the Atom engine required.
        package['engines'] = {'atom': '>=%s' % atom_semver}

        # Rewrite the repository URL.
        repository = 'https://github.com/facebooknuclideapm/%s' % self.get_package_name(
        )
        package['repository'] = repository

        # Write the adjusted package file back to the temporary directory and publish it.
        json_dump(package, package_file)

        rewrite_shrinkwrap_file(self._repo, package,
                                self._config.nuclide_npm_package_names,
                                new_version)

        # Add a boilerplate .gitignore file if the package does not already have one.
        path_to_gitignore = os.path.join(self._repo, '.gitignore')
        if not os.path.exists(path_to_gitignore):
            with open(path_to_gitignore, 'w') as f:
                f.write(DEFAULT_GITIGNORE)

        # Prefix the README.md with information about the proper repository.
        path_to_readme = os.path.join(self._repo, 'README.md')
        if os.path.exists(path_to_readme):
            with open(path_to_readme, 'r') as f:
                readme_contents = README_PREFIX + f.read()
        else:
            readme_contents = README_PREFIX
        with open(path_to_readme, 'w') as f:
            f.write(readme_contents)

        # Write out the packages to install for the nuclide-installer package.
        if self.get_package_name() == 'nuclide-installer':
            from publishers.nuclide_installer_config import generate_config
            installer_config_json = generate_config(
                package['version'], self._config.apm_package_names)
            with open(os.path.join(self._repo, 'lib', 'config.json'),
                      'w') as f:
                f.write(installer_config_json)

        # Pre-transpile Babel files, as appropriate.
        self._transpiler.transpile_in_place(self.get_package_name(),
                                            self._repo)
Beispiel #4
0
    def prepublish(self, new_version, atom_semver):
        self._repo = self._checkout_apm_repo()

        logging.info('Publishing %s to apm at version %s', self.get_package_name(), new_version)

        # Clean repo out, leaving .git metadata in place.
        logging.info('Cleaning repo for package %s', self.get_package_name())
        self.clean_repo()

        # Copy files from package into repo.
        package = self._config.package_directory
        logging.info('Copying package %s', self.get_package_name())
        self.copy_into_repo(package)

        # Make sure that standard boilerplate files are included in the repo.
        for name, src in self._boilerplate_files.items():
            shutil.copyfile(
                src,
                os.path.join(self._repo, name))

        # Load package.json and rewrite version number within it.
        package_file = os.path.join(self._repo, 'package.json')
        package = json_load(package_file)
        package = update_package_json_versions(self.get_package_name(), package,
            self._config.nuclide_npm_package_names, new_version)

        # Specify the license if it is not already specified.
        if 'license' not in package:
            package['license'] = 'SEE LICENSE IN LICENSE'

        # Update the version of the Atom engine required.
        package['engines'] = {'atom': '>=%s' % atom_semver}

        # Rewrite the repository URL.
        repository = 'https://github.com/facebooknuclideapm/%s' % self.get_package_name()
        package['repository'] = repository

        # Write the adjusted package file back to the temporary directory and publish it.
        json_dump(package, package_file)

        rewrite_shrinkwrap_file(self._repo,
            package, self._config.nuclide_npm_package_names, new_version)

        # Add a boilerplate .gitignore file if the package does not already have one.
        path_to_gitignore = os.path.join(self._repo, '.gitignore')
        if not os.path.exists(path_to_gitignore):
            with open(path_to_gitignore, 'w') as f:
                f.write(DEFAULT_GITIGNORE)

        # Prefix the README.md with information about the proper repository.
        path_to_readme = os.path.join(self._repo, 'README.md')
        if os.path.exists(path_to_readme):
            with open(path_to_readme, 'r') as f:
                readme_contents = README_PREFIX + f.read()
        else:
            readme_contents = README_PREFIX
        with open(path_to_readme, 'w') as f:
            f.write(readme_contents)

        # Write out the packages to install for the nuclide-installer package.
        if self.get_package_name() == 'nuclide-installer':
            from publishers.nuclide_installer_config import generate_config
            installer_config_json = generate_config(package['version'], self._config.apm_package_names)
            with open(os.path.join(self._repo, 'lib', 'config.json'), 'w') as f:
                f.write(installer_config_json)

        # Pre-transpile Babel files, as appropriate.
        self._transpiler.transpile_in_place(self.get_package_name(), self._repo)