Ejemplo n.º 1
0
    def node_library(self, **kwargs) -> Path:
        # TODO: once we've migrated all Node.js repos to either having
        #  .repo-metadata.json, or excluding README.md, we can remove this.
        if not os.path.exists("./.repo-metadata.json"):
            self.excludes.append("README.md")
            if "samples/README.md" not in self.excludes:
                self.excludes.append("samples/README.md")

        kwargs["metadata"] = node.template_metadata()
        kwargs["publish_token"] = node.get_publish_token(kwargs["metadata"]["name"])

        ignore_src_index = [
            "yes" for f in self.excludes if fnmatch.fnmatch("src/index.ts", f)
        ]
        # generate root-level `src/index.ts` to export multiple versions and its default clients
        if (
            "versions" in kwargs
            and "default_version" in kwargs
            and not ignore_src_index
        ):
            node.generate_index_ts(
                versions=kwargs["versions"], default_version=kwargs["default_version"]
            )

        return self._generic_library("node_library", **kwargs)
Ejemplo n.º 2
0
def test_no_samples():
    # use a non-nodejs template directory
    with util.chdir(FIXTURES):
        metadata = node.template_metadata()

        # should not have populated the quickstart for the README
        assert not metadata["quickstart"]

        assert isinstance(metadata["samples"], list)
        assert len(metadata["samples"]) == 0
Ejemplo n.º 3
0
def test_quickstart_metadata_without_snippet():
    with util.chdir(FIXTURES / "node_templates" / "no_quickstart_snippet"):
        metadata = node.template_metadata()

        # should not have populated the quickstart for the README
        assert not metadata["quickstart"]

        assert isinstance(metadata["samples"], list)

        # should not have a link to the quickstart in the samples
        sample_names = list(
            map(lambda sample: sample["file"], metadata["samples"]))
        assert "samples/quickstart.js" not in sample_names
Ejemplo n.º 4
0
def test_quickstart_metadata_with_snippet():
    with util.chdir(FIXTURES / "node_templates" / "standard"):
        metadata = node.template_metadata()

        # should have loaded the special quickstart sample (ignoring header).
        assert "ID of the Cloud Bigtable instance" in metadata["quickstart"]
        assert "limitations under the License" not in metadata["quickstart"]

        assert isinstance(metadata["samples"], list)

        # should have a link to the quickstart in the samples
        sample_names = list(
            map(lambda sample: sample["file"], metadata["samples"]))
        assert "samples/quickstart.js" in sample_names