Ejemplo n.º 1
0
def test_command_nowait(pkg):
    """Test non-existing command."""
    npmpkg = NPMPackage(pkg)
    proc = npmpkg.run_script('test', wait=False)
    # Just check output of last line
    for l in proc.stdout:
        pass
    assert l.decode() == u'test\n'
Ejemplo n.º 2
0
 def package_npm(self):
     pkg = NPMPackage(f'{self.code_path}/package.json')
     self.console('正在执行npm install,请稍后...')
     p = pkg.install(wait=False)
     for line in iter(p.stdout.readline, b''):
         line = line.rstrip().decode('utf8')
         self.console(line)
     self.console('正在执行npm build,此过程可能需要几分钟,请耐心等待...')
     p = pkg.run_script('build', '--report', wait=False)
     flag = True
     for line in iter(p.stdout.readline, b''):
         line = line.rstrip().decode('utf8', 'ignore')
         if '● Webpack' in line:
             flag = False
         if '✔ Webpack' in line:
             flag = True
         if line.isprintable() and flag:
             self.console(line)
             time.sleep(0.05)
     self.package_tar(sub_path='dist')
Ejemplo n.º 3
0
 def npmpkg(self):
     """Get API to NPM package."""
     return NPMPackage(self.path)
def node(name):
    print("done")
    p = NPMPackage(path + name + "/package.json")
    p.init()
Ejemplo n.º 5
0
def test_command_install(pkg, deppkg):
    """Test non-existing command."""
    npmpkg = NPMPackage(pkg)
    assert npmpkg.install() == 0
Ejemplo n.º 6
0
def test_command(pkg):
    """Test non-existing command."""
    npmpkg = NPMPackage(pkg)
    assert npmpkg.run_script('test') == 0
Ejemplo n.º 7
0
def test_nonexsting_command(pkg):
    """Test non-existing command."""
    npmpkg = NPMPackage(pkg)
    pytest.raises(AttributeError, getattr, npmpkg, 'cmd_doesnotexists')
Ejemplo n.º 8
0
def test_disabled_command(pkg):
    """Test command that has been disabled."""
    npmpkg = NPMPackage(pkg, commands=['run-script'])
    pytest.raises(AttributeError, getattr, npmpkg, 'install')
Ejemplo n.º 9
0
def test_package_json(pkg, pkgjson_source):
    """Test package JSON content."""
    npmpkg = NPMPackage(pkg)
    assert npmpkg.package_json == pkgjson_source
Ejemplo n.º 10
0
def test_package_json_path(pkg):
    """Test package JSON content."""
    npmpkg = NPMPackage(pkg)
    assert npmpkg.package_json_path == pkg
    npmpkg = NPMPackage(dirname(pkg))
    assert npmpkg.package_json_path == pkg
 def run_client():
     from pynpm import NPMPackage
     pkg = NPMPackage(join(dirname(__file__),
                           '../web/package.json')).run_script('serve')
Ejemplo n.º 12
0
 def _module_pkg(path):
     """NPM package for the given path."""
     return NPMPackage(Path(path) / 'package.json')
Ejemplo n.º 13
0
copyright = '2019-%d, %s' % (datetime.now().year, author)

slug = project.lower()
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
mermaid_build_locally = os.environ.get('MERMAID_BUILD_LOCALLY', not on_rtd)

docs_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = os.path.dirname(docs_dir)
src_dir = os.path.join(os.path.abspath(root_dir), 'src', slug)
ext_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ext')
docs_modules_dir = os.path.join(docs_dir, 'modules')
tpl_dir = os.path.join(docs_dir, 'templates')

if mermaid_build_locally:
    from pynpm import NPMPackage
    npm_process = NPMPackage(os.path.join(docs_dir, 'package.json')).install(wait=False)

sys.path.insert(0, root_dir)
sys.path.insert(0, src_dir)
sys.path.insert(0, ext_dir)

# -- Auto build module docs --------------------------------------------------
sphinx_apidoc(['-e', '-f', '-t', tpl_dir, '-o', docs_modules_dir, src_dir])
os.remove(os.path.join(docs_modules_dir, 'modules.rst'))

# -- Auto build api docs -----------------------------------------------------

with open(os.path.join(docs_dir, 'api-methods.rst'), 'w') as f:
    f.write("Available JSON-RPC methods\n==========================\n\n\n")
    f.write(".. attention::\n\n")
    f.write("    Only supported for Python versions 3.6 and above\n\n\n")
Ejemplo n.º 14
0
def run_npm_install(dir_name):
    pck = NPMPackage(dir_name + '/package.json')
    pck.install()
Ejemplo n.º 15
0
 def run(self):
     pkg = NPMPackage(os.path.join('comet', 'assets', 'package.json'))
     pkg.install()
     pkg.run_script('build')
     build_py.run(self)