Exemple #1
0
    def create_spec(self,
                    source_package_names=(),
                    export_target=None,
                    stub_missing_with_empty=False,
                    working_dir=None,
                    build_dir=None,
                    calmjs_module_registry_names=None,
                    source_registry_method='all',
                    source_map_method='all',
                    bundle_map_method='all',
                    transpile_no_indent=False,
                    toolchain=None,
                    **kwargs):
        """
        Accept all arguments, but also the explicit set of arguments
        that get passed down onto the toolchain.
        """

        # the spec takes a different set of keys as it will ultimately
        # derive the final values for the standardized spec keys.
        return create_spec(
            package_names=source_package_names,
            export_target=export_target,
            stub_missing_with_empty=stub_missing_with_empty,
            working_dir=working_dir,
            build_dir=build_dir,
            source_registry_method=source_registry_method,
            source_registries=calmjs_module_registry_names,
            source_map_method=source_map_method,
            bundle_map_method=bundle_map_method,
            transpile_no_indent=transpile_no_indent,
        )
Exemple #2
0
    def create_spec(
            self, source_package_names=(), export_target=None,
            stub_missing_with_empty=False,
            working_dir=None,
            build_dir=None,
            calmjs_module_registry_names=None,
            source_registry_method='all',
            sourcepath_method='all', bundlepath_method='all',
            transpile_no_indent=False,
            toolchain=None, **kwargs):
        """
        Accept all arguments, but also the explicit set of arguments
        that get passed down onto the toolchain.
        """

        # the spec takes a different set of keys as it will ultimately
        # derive the final values for the standardized spec keys.
        return create_spec(
            package_names=source_package_names,
            export_target=export_target,
            stub_missing_with_empty=stub_missing_with_empty,
            working_dir=working_dir,
            build_dir=build_dir,
            source_registry_method=source_registry_method,
            source_registries=calmjs_module_registry_names,
            sourcepath_method=sourcepath_method,
            bundlepath_method=bundlepath_method,
            transpile_no_indent=transpile_no_indent,
        )
Exemple #3
0
def complete_rjs(package_names, export_target):
    """
    Return the toolchain and a spec that when executed together, will
    result in a complete artifact using the provided package names onto
    the export_target.
    """

    return default_toolchain, create_spec(package_names, export_target)
Exemple #4
0
    def test_create_spec_empty(self):
        with pretty_logging(stream=StringIO()) as stream:
            spec = create_spec([])

        self.assertNotIn('packages []', stream.getvalue())
        self.assertIn('no packages specified', stream.getvalue())
        self.assertTrue(isinstance(spec, Spec))
        self.assertEqual(spec['export_target'], 'calmjs.rjs.export.js')
        self.assertEqual(spec['calmjs_module_registry_names'], [])
Exemple #5
0
    def test_create_spec_empty(self):
        with pretty_logging(stream=StringIO()) as stream:
            spec = create_spec([])

        self.assertNotIn('packages []', stream.getvalue())
        self.assertIn('no packages specified', stream.getvalue())
        self.assertTrue(isinstance(spec, Spec))
        self.assertEqual(spec['export_target'], join(
            self.cwd, 'calmjs.rjs.export.js'))
        self.assertEqual(spec['calmjs_module_registry_names'], [])
        self.assertEqual(
            RJS_LOADER_PLUGIN_REGISTRY_NAME,
            spec['calmjs_loaderplugin_registry'].registry_name,
        )
Exemple #6
0
    def test_create_spec_with_calmjs_rjs(self):
        with pretty_logging(stream=StringIO()) as stream:
            spec = create_spec(['calmjs.rjs'])
        self.assertTrue(isinstance(spec, Spec))
        self.assertEqual(spec['export_target'], 'calmjs.rjs.js')
        self.assertEqual(spec['calmjs_module_registry_names'],
                         ['calmjs.module'])
        self.assertEqual(spec['source_package_names'], ['calmjs.rjs'])

        log = stream.getvalue()
        self.assertIn(
            "automatically picked registries ['calmjs.module'] for "
            "building source map",
            log,
        )
Exemple #7
0
    def test_create_spec_with_calmjs_rjs(self):
        with pretty_logging(stream=StringIO()) as stream:
            spec = create_spec(['calmjs.rjs'])
        self.assertTrue(isinstance(spec, Spec))
        self.assertEqual(spec['export_target'], join(
            self.cwd, 'calmjs.rjs.js'))
        self.assertEqual(
            spec['calmjs_module_registry_names'], ['calmjs.module'])
        self.assertEqual(
            spec['source_package_names'], ['calmjs.rjs'])

        log = stream.getvalue()
        self.assertIn(
            "automatically picked registries ['calmjs.module'] for "
            "sourcepaths", log,
        )
Exemple #8
0
 def test_create_spec_with_calmjs_rjs_manual_target(self):
     with pretty_logging(stream=StringIO()):
         spec = create_spec(['calmjs.rjs'], export_target='foo.js')
     self.assertTrue(isinstance(spec, Spec))
     self.assertEqual(spec['export_target'], 'foo.js')
 def test_cli_create_spec(self):
     with pretty_logging(stream=StringIO()):
         spec = cli.create_spec(
             ['site'], source_registries=(self.registry_name,))
     self.assertEqual(
         spec['export_target'], join(self._env_root, 'site.js'))
Exemple #10
0
 def test_cli_create_spec(self):
     with pretty_logging(stream=StringIO()):
         spec = cli.create_spec(
             ['site'], source_registries=(self.registry_name,))
     self.assertEqual(spec['export_target'], 'site.js')