Пример #1
0
    def _renderHTML(self):
        from girder.utility import server
        from girder.plugin import loadedPlugins
        self.vars['plugins'] = loadedPlugins()
        self.vars['pluginCss'] = []
        self.vars['pluginJs'] = []
        builtDir = os.path.join(constants.STATIC_ROOT_DIR, 'built', 'plugins')
        for plugin in self.vars['plugins']:
            if os.path.exists(os.path.join(builtDir, plugin,
                                           'plugin.min.css')):
                self.vars['pluginCss'].append(plugin)
            if os.path.exists(os.path.join(builtDir, plugin, 'plugin.min.js')):
                self.vars['pluginJs'].append(plugin)

        self.vars['apiRoot'] = server.getApiRoot()
        self.vars['staticPublicPath'] = server.getStaticPublicPath()
        self.vars['brandName'] = Setting().get(SettingKey.BRAND_NAME)
        self.vars['contactEmail'] = Setting().get(
            SettingKey.CONTACT_EMAIL_ADDRESS)
        self.vars['privacyNoticeHref'] = Setting().get(
            SettingKey.PRIVACY_NOTICE)
        self.vars['bannerColor'] = Setting().get(SettingKey.BANNER_COLOR)
        self.vars['registrationPolicy'] = Setting().get(
            SettingKey.REGISTRATION_POLICY)
        self.vars['enablePasswordLogin'] = Setting().get(
            SettingKey.ENABLE_PASSWORD_LOGIN)

        return super(Webroot, self)._renderHTML()
Пример #2
0
def main(dev, mode, watch, watch_plugin, npm, reinstall):
    if shutil.which(npm) is None:
        raise click.UsageError(
            'No npm executable was detected.  Please ensure the npm executable is in your '
            'path, use the --npm flag, or set the "NPM_EXE" environment variable.'
        )

    if dev and mode:
        raise click.ClickException('Conflict between --dev and --mode')
    if dev:
        mode = ServerMode.DEVELOPMENT

    if watch and watch_plugin:
        raise click.UsageError('--watch and --watch-plugins cannot be used together')
    if watch or watch_plugin:
        mode = ServerMode.DEVELOPMENT
        reinstall = False

    staging = _GIRDER_BUILD_ASSETS_PATH
    _generatePackageJSON(staging, os.path.join(_GIRDER_BUILD_ASSETS_PATH, 'package.json.template'))

    if not os.path.isdir(os.path.join(staging, 'node_modules')) or reinstall:
        # The autogeneration of package.json breaks how package-lock.json is
        # intended to work.  If we don't delete it first, you will frequently
        # get "file doesn't exist" errors.
        npmLockFile = os.path.join(staging, 'package-lock.json')
        if os.path.exists(npmLockFile):
            os.unlink(npmLockFile)
        installCommand = [npm, 'install']
        if mode == ServerMode.PRODUCTION:
            installCommand.append('--production')
        check_call(installCommand, cwd=staging)

    quiet = '--no-progress=false' if sys.stdout.isatty() else '--no-progress=true'
    buildCommand = [
        npm, 'run', 'build', '--',
        '--girder-version=%s' % girder.__version__,
        '--static-path=%s' % STATIC_ROOT_DIR,
        '--static-public-path=%s' % server.getStaticPublicPath(),
        quiet
    ]
    if watch:
        buildCommand.append('--watch')
    if watch_plugin:
        buildCommand.extend([
            '--watch',
            'webpack:plugin_%s' % watch_plugin
        ])
    if mode == ServerMode.DEVELOPMENT:
        buildCommand.append('--env=dev')
    else:
        buildCommand.append('--env=prod')
    check_call(buildCommand, cwd=staging)
Пример #3
0
def main(dev, watch, watch_plugin, npm, reinstall):
    if shutil.which(npm) is None:
        raise click.UsageError(
            'No npm executable was detected.  Please ensure the npm executable is in your '
            'path, use the --npm flag, or set the "NPM_EXE" environment variable.'
        )

    if watch and watch_plugin:
        raise click.UsageError('--watch and --watch-plugins cannot be used together')
    if watch or watch_plugin:
        dev = True
        reinstall = False

    staging = _GIRDER_BUILD_ASSETS_PATH
    _generatePackageJSON(staging, os.path.join(_GIRDER_BUILD_ASSETS_PATH, 'package.json.template'))

    if not os.path.isdir(os.path.join(staging, 'node_modules')) or reinstall:
        # The autogeneration of package.json breaks how package-lock.json is
        # intended to work.  If we don't delete it first, you will frequently
        # get "file doesn't exist" errors.
        npmLockFile = os.path.join(staging, 'package-lock.json')
        if os.path.exists(npmLockFile):
            os.unlink(npmLockFile)
        installCommand = [npm, 'install']
        if not dev:
            installCommand.append('--production')
        check_call(installCommand, cwd=staging)

    quiet = '--no-progress=false' if sys.stdout.isatty() else '--no-progress=true'
    buildCommand = [
        npm, 'run', 'build', '--',
        '--static-path=%s' % STATIC_ROOT_DIR,
        '--static-public-path=%s' % server.getStaticPublicPath(),
        quiet
    ]
    if watch:
        buildCommand.append('--watch')
    if watch_plugin:
        buildCommand.extend([
            '--watch',
            'webpack:plugin_%s' % watch_plugin
        ])
    if dev:
        buildCommand.append('--env=dev')
    else:
        buildCommand.append('--env=prod')
    check_call(buildCommand, cwd=staging)
Пример #4
0
    def _renderHTML(self):
        from girder.utility import server
        from girder.plugin import loadedPlugins
        self.vars['plugins'] = loadedPlugins()
        self.vars['pluginCss'] = []
        self.vars['pluginJs'] = []
        builtDir = os.path.join(constants.STATIC_ROOT_DIR, 'built', 'plugins')
        for plugin in self.vars['plugins']:
            if os.path.exists(os.path.join(builtDir, plugin, 'plugin.min.css')):
                self.vars['pluginCss'].append(plugin)
            if os.path.exists(os.path.join(builtDir, plugin, 'plugin.min.js')):
                self.vars['pluginJs'].append(plugin)

        self.vars['apiRoot'] = server.getApiRoot()
        self.vars['staticPublicPath'] = server.getStaticPublicPath()
        self.vars['brandName'] = Setting().get(SettingKey.BRAND_NAME)
        self.vars['contactEmail'] = Setting().get(SettingKey.CONTACT_EMAIL_ADDRESS)
        self.vars['privacyNoticeHref'] = Setting().get(SettingKey.PRIVACY_NOTICE)
        self.vars['bannerColor'] = Setting().get(SettingKey.BANNER_COLOR)
        self.vars['registrationPolicy'] = Setting().get(SettingKey.REGISTRATION_POLICY)
        self.vars['enablePasswordLogin'] = Setting().get(SettingKey.ENABLE_PASSWORD_LOGIN)

        return super(Webroot, self)._renderHTML()
Пример #5
0
 def _renderHTML(self):
     from girder.utility import server
     self.vars['apiRoot'] = server.getApiRoot()
     self.vars['staticPublicPath'] = server.getStaticPublicPath()
     self.vars['brandName'] = Setting().get(SettingKey.BRAND_NAME)
     return super(ApiDocs, self)._renderHTML()
Пример #6
0
 def _renderHTML(self):
     from girder.utility import server
     self.vars['apiRoot'] = server.getApiRoot()
     self.vars['staticPublicPath'] = server.getStaticPublicPath()
     self.vars['brandName'] = Setting().get(SettingKey.BRAND_NAME)
     return super(ApiDocs, self)._renderHTML()
Пример #7
0
def main(dev, mode, watch, watch_plugin, npm, reinstall):
    if shutil.which(npm) is None:
        raise click.UsageError(
            'No npm executable was detected.  Please ensure the npm executable is in your '
            'path, use the --npm flag, or set the "NPM_EXE" environment variable.'
        )

    if dev and mode:
        raise click.ClickException('Conflict between --dev and --mode')
    if dev:
        mode = ServerMode.DEVELOPMENT

    if watch and watch_plugin:
        raise click.UsageError('--watch and --watch-plugin cannot be used together')
    if watch or watch_plugin:
        mode = ServerMode.DEVELOPMENT
        reinstall = False

    staging = _GIRDER_BUILD_ASSETS_PATH
    pluginDependencies = _collectPluginDependencies()
    _generatePackageJSON(staging, os.path.join(_GIRDER_BUILD_ASSETS_PATH,
                         'package.json.template'), pluginDependencies)

    if not os.path.isdir(os.path.join(staging, 'node_modules')) or reinstall:
        # The autogeneration of package.json breaks how package-lock.json is
        # intended to work.  If we don't delete it first, you will frequently
        # get "file doesn't exist" errors.
        npmLockFile = os.path.join(staging, 'package-lock.json')
        if os.path.exists(npmLockFile):
            os.unlink(npmLockFile)

        # Remove any lingering node_modules to ensure clean install
        pluginDirs = [
            version.replace('file:', '')
            for version in pluginDependencies.values()
            if version.startswith('file:')
        ]
        pluginSrcDirs = [staging, os.path.join(staging, 'src')] + pluginDirs
        nodeModuleDirs = [os.path.join(d, 'node_modules') for d in pluginSrcDirs]

        for path in nodeModuleDirs:
            # Include ignore_errors=True to delete readonly files
            # and skip over nonexistant directories
            shutil.rmtree(path, ignore_errors=True)

        # Run npm install
        installCommand = [npm, 'install']
        if mode == ServerMode.PRODUCTION:
            installCommand.append('--production')
        check_call(installCommand, cwd=staging)

    quiet = '--no-progress=false' if sys.stdout.isatty() else '--no-progress=true'
    buildCommand = [
        npm, 'run', 'build', '--',
        '--girder-version=%s' % girder.__version__,
        '--static-path=%s' % STATIC_ROOT_DIR,
        '--static-public-path=%s' % server.getStaticPublicPath(),
        quiet
    ]
    if watch:
        buildCommand.append('--watch')
    if watch_plugin:
        buildCommand.extend([
            '--watch',
            'webpack:plugin_%s' % watch_plugin
        ])
    if mode == ServerMode.DEVELOPMENT:
        buildCommand.append('--env=dev')
    else:
        buildCommand.append('--env=prod')
    check_call(buildCommand, cwd=staging)