diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,57 +1,56 @@ -exclude: '^swh/web/tests/resources/' +exclude: "^swh/web/tests/resources/" repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 - hooks: - - id: trailing-whitespace - - id: check-json - - id: check-yaml - -- repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.3 - hooks: - - id: flake8 - -- repo: https://github.com/codespell-project/codespell - rev: v1.16.0 - hooks: - - id: codespell - exclude: > - (?x)^( - cypress/integration/directory.spec.js| - yarn.lock| - package.json - )$ - -- repo: local - hooks: - - id: mypy - name: mypy - entry: env DJANGO_SETTINGS_MODULE=swh.web.settings.development mypy - args: [swh] - pass_filenames: false - language: system - types: [python] - -- repo: local - hooks: - - id: eslint - name: eslint - entry: node_modules/.bin/eslint -c swh/web/assets/config/.eslintrc - language: system - types: [javascript] - -- repo: https://github.com/PyCQA/isort - rev: 5.5.2 - hooks: - - id: isort - -- repo: https://github.com/python/black - rev: 19.10b0 - hooks: - - id: black - + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.4.0 + hooks: + - id: trailing-whitespace + - id: check-json + - id: check-yaml + + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.3 + hooks: + - id: flake8 + + - repo: https://github.com/codespell-project/codespell + rev: v1.16.0 + hooks: + - id: codespell + exclude: > + (?x)^( + cypress/integration/directory.spec.js| + yarn.lock| + package.json + )$ + + - repo: local + hooks: + - id: mypy + name: mypy + entry: env DJANGO_SETTINGS_MODULE=swh.web.settings.development mypy + args: [swh] + pass_filenames: false + language: system + types: [python] + + - repo: local + hooks: + - id: eslint + name: eslint + entry: node_modules/.bin/eslint -c assets/config/.eslintrc + language: system + types: [javascript] + + - repo: https://github.com/PyCQA/isort + rev: 5.5.2 + hooks: + - id: isort + + - repo: https://github.com/python/black + rev: 19.10b0 + hooks: + - id: black # unfortunately, we are far from being able to enable this... # - repo: https://github.com/PyCQA/pydocstyle.git # rev: 4.0.0 diff --git a/MANIFEST.in b/MANIFEST.in --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,7 +5,7 @@ include version.txt recursive-include swh py.typed -recursive-include swh/web/assets * +recursive-include assets * recursive-include swh/web/templates * recursive-include swh/web/tests/resources * diff --git a/swh/web/assets/config/.bootstraprc b/assets/config/.bootstraprc rename from swh/web/assets/config/.bootstraprc rename to assets/config/.bootstraprc --- a/swh/web/assets/config/.bootstraprc +++ b/assets/config/.bootstraprc @@ -44,7 +44,7 @@ # Usually this endpoint-file contains list of @imports of your application styles # # appStyles: ./path/to/your/app/styles/endpoint.scss -appStyles: ../../../../node_modules/admin-lte/build/scss/_adminlte.raw.scss +appStyles: ../../node_modules/admin-lte/build/scss/_adminlte.raw.scss ### Bootstrap styles styles: diff --git a/assets/config/.eslintignore b/assets/config/.eslintignore new file mode 100644 --- /dev/null +++ b/assets/config/.eslintignore @@ -0,0 +1 @@ +assets/src/thirdparty/**/*.js diff --git a/swh/web/assets/config/.eslintrc b/assets/config/.eslintrc rename from swh/web/assets/config/.eslintrc rename to assets/config/.eslintrc diff --git a/swh/web/assets/config/bootstrap-pre-customize.scss b/assets/config/bootstrap-pre-customize.scss rename from swh/web/assets/config/bootstrap-pre-customize.scss rename to assets/config/bootstrap-pre-customize.scss diff --git a/swh/web/assets/config/webpack-plugins/dump-highlightjs-languages-data-plugin.js b/assets/config/webpack-plugins/dump-highlightjs-languages-data-plugin.js rename from swh/web/assets/config/webpack-plugins/dump-highlightjs-languages-data-plugin.js rename to assets/config/webpack-plugins/dump-highlightjs-languages-data-plugin.js diff --git a/swh/web/assets/config/webpack-plugins/fix-swh-source-maps-webpack-plugin.js b/assets/config/webpack-plugins/fix-swh-source-maps-webpack-plugin.js rename from swh/web/assets/config/webpack-plugins/fix-swh-source-maps-webpack-plugin.js rename to assets/config/webpack-plugins/fix-swh-source-maps-webpack-plugin.js diff --git a/swh/web/assets/config/webpack-plugins/fix-webpack-stats-format-plugin.js b/assets/config/webpack-plugins/fix-webpack-stats-format-plugin.js rename from swh/web/assets/config/webpack-plugins/fix-webpack-stats-format-plugin.js rename to assets/config/webpack-plugins/fix-webpack-stats-format-plugin.js diff --git a/swh/web/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/README.md b/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/README.md rename from swh/web/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/README.md rename to assets/config/webpack-plugins/generate-weblabels-webpack-plugin/README.md diff --git a/swh/web/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/index.js b/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/index.js rename from swh/web/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/index.js rename to assets/config/webpack-plugins/generate-weblabels-webpack-plugin/index.js diff --git a/swh/web/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/jslicenses.ejs b/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/jslicenses.ejs rename from swh/web/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/jslicenses.ejs rename to assets/config/webpack-plugins/generate-weblabels-webpack-plugin/jslicenses.ejs diff --git a/swh/web/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/plugin-options-schema.json b/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/plugin-options-schema.json rename from swh/web/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/plugin-options-schema.json rename to assets/config/webpack-plugins/generate-weblabels-webpack-plugin/plugin-options-schema.json diff --git a/swh/web/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/spdx-licenses-mapping.js b/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/spdx-licenses-mapping.js rename from swh/web/assets/config/webpack-plugins/generate-weblabels-webpack-plugin/spdx-licenses-mapping.js rename to assets/config/webpack-plugins/generate-weblabels-webpack-plugin/spdx-licenses-mapping.js diff --git a/swh/web/assets/config/webpack.config.development.js b/assets/config/webpack.config.development.js rename from swh/web/assets/config/webpack.config.development.js rename to assets/config/webpack.config.development.js --- a/swh/web/assets/config/webpack.config.development.js +++ b/assets/config/webpack.config.development.js @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2020 The Software Heritage developers + * Copyright (C) 2018-2021 The Software Heritage developers * See the AUTHORS file at the top-level directory of this distribution * License: GNU Affero General Public License version 3, or any later version * See top-level LICENSE file for more information @@ -32,7 +32,7 @@ // our assets or not const publicPath = isDevServer ? devServerPublicPath : '/static/'; -const nodeModules = path.resolve(__dirname, '../../../../node_modules/'); +const nodeModules = path.resolve(__dirname, '../../node_modules/'); // collect all bundles we want to produce with webpack var bundles = {}; @@ -73,7 +73,7 @@ 'no-descending-specificity': null }, 'ignoreFiles': ['node_modules/**/*.css', - 'swh/web/assets/src/thirdparty/**/*.css'] + 'assets/src/thirdparty/**/*.css'] } }], // automatically add vendor prefixes to css rules @@ -401,11 +401,11 @@ patterns: [ { from: path.resolve(nodeModules, 'pdfjs-dist/build/pdf.worker.min.js'), - to: path.resolve(__dirname, '../../../../static/js/') + to: path.resolve(__dirname, '../../static/js/') }, { from: path.resolve(nodeModules, 'mathjax/es5/output/chtml/fonts/woff-v2/**'), - to: path.resolve(__dirname, '../../../../static/fonts/[name].[ext]') + to: path.resolve(__dirname, '../../static/fonts/[name].[ext]') } ] }), @@ -420,9 +420,9 @@ './node_modules/admin-lte/dist/js/adminlte.js' }, licenseOverride: { - './swh/web/assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.js': { + './assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.js': { 'spdxLicenseExpression': 'GPL-3.0', - 'licenseFilePath': './swh/web/assets/src/thirdparty/jquery.tabSlideOut/LICENSE' + 'licenseFilePath': './assets/src/thirdparty/jquery.tabSlideOut/LICENSE' } }, additionalScripts: Object.assign( diff --git a/swh/web/assets/config/webpack.config.production.js b/assets/config/webpack.config.production.js rename from swh/web/assets/config/webpack.config.production.js rename to assets/config/webpack.config.production.js diff --git a/swh/web/assets/src/bundles/admin/deposit.js b/assets/src/bundles/admin/deposit.js rename from swh/web/assets/src/bundles/admin/deposit.js rename to assets/src/bundles/admin/deposit.js diff --git a/swh/web/assets/src/bundles/admin/index.js b/assets/src/bundles/admin/index.js rename from swh/web/assets/src/bundles/admin/index.js rename to assets/src/bundles/admin/index.js diff --git a/swh/web/assets/src/bundles/admin/origin-save.js b/assets/src/bundles/admin/origin-save.js rename from swh/web/assets/src/bundles/admin/origin-save.js rename to assets/src/bundles/admin/origin-save.js diff --git a/swh/web/assets/src/bundles/auth/auth.css b/assets/src/bundles/auth/auth.css rename from swh/web/assets/src/bundles/auth/auth.css rename to assets/src/bundles/auth/auth.css diff --git a/swh/web/assets/src/bundles/auth/index.js b/assets/src/bundles/auth/index.js rename from swh/web/assets/src/bundles/auth/index.js rename to assets/src/bundles/auth/index.js diff --git a/swh/web/assets/src/bundles/browse/breadcrumbs.css b/assets/src/bundles/browse/breadcrumbs.css rename from swh/web/assets/src/bundles/browse/breadcrumbs.css rename to assets/src/bundles/browse/breadcrumbs.css diff --git a/swh/web/assets/src/bundles/browse/browse-utils.js b/assets/src/bundles/browse/browse-utils.js rename from swh/web/assets/src/bundles/browse/browse-utils.js rename to assets/src/bundles/browse/browse-utils.js diff --git a/swh/web/assets/src/bundles/browse/browse.css b/assets/src/bundles/browse/browse.css rename from swh/web/assets/src/bundles/browse/browse.css rename to assets/src/bundles/browse/browse.css diff --git a/swh/web/assets/src/bundles/browse/content.css b/assets/src/bundles/browse/content.css rename from swh/web/assets/src/bundles/browse/content.css rename to assets/src/bundles/browse/content.css diff --git a/swh/web/assets/src/bundles/browse/index.js b/assets/src/bundles/browse/index.js rename from swh/web/assets/src/bundles/browse/index.js rename to assets/src/bundles/browse/index.js diff --git a/swh/web/assets/src/bundles/browse/origin-search.js b/assets/src/bundles/browse/origin-search.js rename from swh/web/assets/src/bundles/browse/origin-search.js rename to assets/src/bundles/browse/origin-search.js diff --git a/swh/web/assets/src/bundles/browse/snapshot-navigation.css b/assets/src/bundles/browse/snapshot-navigation.css rename from swh/web/assets/src/bundles/browse/snapshot-navigation.css rename to assets/src/bundles/browse/snapshot-navigation.css diff --git a/swh/web/assets/src/bundles/browse/snapshot-navigation.js b/assets/src/bundles/browse/snapshot-navigation.js rename from swh/web/assets/src/bundles/browse/snapshot-navigation.js rename to assets/src/bundles/browse/snapshot-navigation.js diff --git a/swh/web/assets/src/bundles/browse/swhid-utils.js b/assets/src/bundles/browse/swhid-utils.js rename from swh/web/assets/src/bundles/browse/swhid-utils.js rename to assets/src/bundles/browse/swhid-utils.js diff --git a/swh/web/assets/src/bundles/origin/index.js b/assets/src/bundles/origin/index.js rename from swh/web/assets/src/bundles/origin/index.js rename to assets/src/bundles/origin/index.js diff --git a/swh/web/assets/src/bundles/origin/visits-calendar.js b/assets/src/bundles/origin/visits-calendar.js rename from swh/web/assets/src/bundles/origin/visits-calendar.js rename to assets/src/bundles/origin/visits-calendar.js diff --git a/swh/web/assets/src/bundles/origin/visits-histogram.js b/assets/src/bundles/origin/visits-histogram.js rename from swh/web/assets/src/bundles/origin/visits-histogram.js rename to assets/src/bundles/origin/visits-histogram.js diff --git a/swh/web/assets/src/bundles/origin/visits-reporting.css b/assets/src/bundles/origin/visits-reporting.css rename from swh/web/assets/src/bundles/origin/visits-reporting.css rename to assets/src/bundles/origin/visits-reporting.css diff --git a/swh/web/assets/src/bundles/origin/visits-reporting.js b/assets/src/bundles/origin/visits-reporting.js rename from swh/web/assets/src/bundles/origin/visits-reporting.js rename to assets/src/bundles/origin/visits-reporting.js diff --git a/swh/web/assets/src/bundles/revision/diff-panel.ejs b/assets/src/bundles/revision/diff-panel.ejs rename from swh/web/assets/src/bundles/revision/diff-panel.ejs rename to assets/src/bundles/revision/diff-panel.ejs diff --git a/swh/web/assets/src/bundles/revision/diff-utils.js b/assets/src/bundles/revision/diff-utils.js rename from swh/web/assets/src/bundles/revision/diff-utils.js rename to assets/src/bundles/revision/diff-utils.js diff --git a/swh/web/assets/src/bundles/revision/index.js b/assets/src/bundles/revision/index.js rename from swh/web/assets/src/bundles/revision/index.js rename to assets/src/bundles/revision/index.js diff --git a/swh/web/assets/src/bundles/revision/log-utils.js b/assets/src/bundles/revision/log-utils.js rename from swh/web/assets/src/bundles/revision/log-utils.js rename to assets/src/bundles/revision/log-utils.js diff --git a/swh/web/assets/src/bundles/revision/revision.css b/assets/src/bundles/revision/revision.css rename from swh/web/assets/src/bundles/revision/revision.css rename to assets/src/bundles/revision/revision.css diff --git a/swh/web/assets/src/bundles/save/index.js b/assets/src/bundles/save/index.js rename from swh/web/assets/src/bundles/save/index.js rename to assets/src/bundles/save/index.js diff --git a/swh/web/assets/src/bundles/vault/index.js b/assets/src/bundles/vault/index.js rename from swh/web/assets/src/bundles/vault/index.js rename to assets/src/bundles/vault/index.js diff --git a/swh/web/assets/src/bundles/vault/vault-create-tasks.js b/assets/src/bundles/vault/vault-create-tasks.js rename from swh/web/assets/src/bundles/vault/vault-create-tasks.js rename to assets/src/bundles/vault/vault-create-tasks.js diff --git a/swh/web/assets/src/bundles/vault/vault-table-row.ejs b/assets/src/bundles/vault/vault-table-row.ejs rename from swh/web/assets/src/bundles/vault/vault-table-row.ejs rename to assets/src/bundles/vault/vault-table-row.ejs diff --git a/swh/web/assets/src/bundles/vault/vault-ui.js b/assets/src/bundles/vault/vault-ui.js rename from swh/web/assets/src/bundles/vault/vault-ui.js rename to assets/src/bundles/vault/vault-ui.js diff --git a/swh/web/assets/src/bundles/vault/vault.css b/assets/src/bundles/vault/vault.css rename from swh/web/assets/src/bundles/vault/vault.css rename to assets/src/bundles/vault/vault.css diff --git a/swh/web/assets/src/bundles/vendors/datatables.css b/assets/src/bundles/vendors/datatables.css rename from swh/web/assets/src/bundles/vendors/datatables.css rename to assets/src/bundles/vendors/datatables.css diff --git a/swh/web/assets/src/bundles/vendors/elementsfrompoint-polyfill.js b/assets/src/bundles/vendors/elementsfrompoint-polyfill.js rename from swh/web/assets/src/bundles/vendors/elementsfrompoint-polyfill.js rename to assets/src/bundles/vendors/elementsfrompoint-polyfill.js diff --git a/swh/web/assets/src/bundles/vendors/index.js b/assets/src/bundles/vendors/index.js rename from swh/web/assets/src/bundles/vendors/index.js rename to assets/src/bundles/vendors/index.js --- a/swh/web/assets/src/bundles/vendors/index.js +++ b/assets/src/bundles/vendors/index.js @@ -16,7 +16,7 @@ // jquery and bootstrap import 'jquery'; -import 'bootstrap-loader/lib/bootstrap.loader?configFilePath=../../../swh/web/assets/config/.bootstraprc!bootstrap-loader/no-op.js'; +import 'bootstrap-loader/lib/bootstrap.loader?configFilePath=../../../assets/config/.bootstraprc!bootstrap-loader/no-op.js'; // admin-lte scripts import 'admin-lte'; diff --git a/swh/web/assets/src/bundles/webapp/badges.js b/assets/src/bundles/webapp/badges.js rename from swh/web/assets/src/bundles/webapp/badges.js rename to assets/src/bundles/webapp/badges.js diff --git a/swh/web/assets/src/bundles/webapp/breadcrumbs.css b/assets/src/bundles/webapp/breadcrumbs.css rename from swh/web/assets/src/bundles/webapp/breadcrumbs.css rename to assets/src/bundles/webapp/breadcrumbs.css diff --git a/swh/web/assets/src/bundles/webapp/code-highlighting.js b/assets/src/bundles/webapp/code-highlighting.js rename from swh/web/assets/src/bundles/webapp/code-highlighting.js rename to assets/src/bundles/webapp/code-highlighting.js diff --git a/swh/web/assets/src/bundles/webapp/history-counters.css b/assets/src/bundles/webapp/history-counters.css rename from swh/web/assets/src/bundles/webapp/history-counters.css rename to assets/src/bundles/webapp/history-counters.css diff --git a/swh/web/assets/src/bundles/webapp/history-counters.js b/assets/src/bundles/webapp/history-counters.js rename from swh/web/assets/src/bundles/webapp/history-counters.js rename to assets/src/bundles/webapp/history-counters.js diff --git a/swh/web/assets/src/bundles/webapp/index.js b/assets/src/bundles/webapp/index.js rename from swh/web/assets/src/bundles/webapp/index.js rename to assets/src/bundles/webapp/index.js diff --git a/swh/web/assets/src/bundles/webapp/math-typesetting.js b/assets/src/bundles/webapp/math-typesetting.js rename from swh/web/assets/src/bundles/webapp/math-typesetting.js rename to assets/src/bundles/webapp/math-typesetting.js diff --git a/swh/web/assets/src/bundles/webapp/notebook-rendering.js b/assets/src/bundles/webapp/notebook-rendering.js rename from swh/web/assets/src/bundles/webapp/notebook-rendering.js rename to assets/src/bundles/webapp/notebook-rendering.js diff --git a/swh/web/assets/src/bundles/webapp/notebook.css b/assets/src/bundles/webapp/notebook.css rename from swh/web/assets/src/bundles/webapp/notebook.css rename to assets/src/bundles/webapp/notebook.css diff --git a/swh/web/assets/src/bundles/webapp/pdf-rendering.js b/assets/src/bundles/webapp/pdf-rendering.js rename from swh/web/assets/src/bundles/webapp/pdf-rendering.js rename to assets/src/bundles/webapp/pdf-rendering.js diff --git a/swh/web/assets/src/bundles/webapp/readme-rendering.js b/assets/src/bundles/webapp/readme-rendering.js rename from swh/web/assets/src/bundles/webapp/readme-rendering.js rename to assets/src/bundles/webapp/readme-rendering.js diff --git a/swh/web/assets/src/bundles/webapp/sentry.js b/assets/src/bundles/webapp/sentry.js rename from swh/web/assets/src/bundles/webapp/sentry.js rename to assets/src/bundles/webapp/sentry.js diff --git a/swh/web/assets/src/bundles/webapp/status-widget.css b/assets/src/bundles/webapp/status-widget.css rename from swh/web/assets/src/bundles/webapp/status-widget.css rename to assets/src/bundles/webapp/status-widget.css diff --git a/swh/web/assets/src/bundles/webapp/status-widget.js b/assets/src/bundles/webapp/status-widget.js rename from swh/web/assets/src/bundles/webapp/status-widget.js rename to assets/src/bundles/webapp/status-widget.js diff --git a/swh/web/assets/src/bundles/webapp/webapp-utils.js b/assets/src/bundles/webapp/webapp-utils.js rename from swh/web/assets/src/bundles/webapp/webapp-utils.js rename to assets/src/bundles/webapp/webapp-utils.js diff --git a/swh/web/assets/src/bundles/webapp/webapp.css b/assets/src/bundles/webapp/webapp.css rename from swh/web/assets/src/bundles/webapp/webapp.css rename to assets/src/bundles/webapp/webapp.css diff --git a/swh/web/assets/src/bundles/webapp/xss-filtering.js b/assets/src/bundles/webapp/xss-filtering.js rename from swh/web/assets/src/bundles/webapp/xss-filtering.js rename to assets/src/bundles/webapp/xss-filtering.js diff --git a/swh/web/assets/src/thirdparty/jquery.tabSlideOut/LICENSE b/assets/src/thirdparty/jquery.tabSlideOut/LICENSE rename from swh/web/assets/src/thirdparty/jquery.tabSlideOut/LICENSE rename to assets/src/thirdparty/jquery.tabSlideOut/LICENSE diff --git a/swh/web/assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.css b/assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.css rename from swh/web/assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.css rename to assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.css diff --git a/swh/web/assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.js b/assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.js rename from swh/web/assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.js rename to assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.js diff --git a/swh/web/assets/src/utils/constants.js b/assets/src/utils/constants.js rename from swh/web/assets/src/utils/constants.js rename to assets/src/utils/constants.js diff --git a/swh/web/assets/src/utils/d3.js b/assets/src/utils/d3.js rename from swh/web/assets/src/utils/d3.js rename to assets/src/utils/d3.js diff --git a/swh/web/assets/src/utils/functions.js b/assets/src/utils/functions.js rename from swh/web/assets/src/utils/functions.js rename to assets/src/utils/functions.js diff --git a/swh/web/assets/src/utils/highlightjs.css b/assets/src/utils/highlightjs.css rename from swh/web/assets/src/utils/highlightjs.css rename to assets/src/utils/highlightjs.css diff --git a/swh/web/assets/src/utils/highlightjs.js b/assets/src/utils/highlightjs.js rename from swh/web/assets/src/utils/highlightjs.js rename to assets/src/utils/highlightjs.js diff --git a/swh/web/assets/src/utils/mathjax.js b/assets/src/utils/mathjax.js rename from swh/web/assets/src/utils/mathjax.js rename to assets/src/utils/mathjax.js diff --git a/swh/web/assets/src/utils/org.css b/assets/src/utils/org.css rename from swh/web/assets/src/utils/org.css rename to assets/src/utils/org.css diff --git a/swh/web/assets/src/utils/org.js b/assets/src/utils/org.js rename from swh/web/assets/src/utils/org.js rename to assets/src/utils/org.js diff --git a/swh/web/assets/src/utils/showdown.css b/assets/src/utils/showdown.css rename from swh/web/assets/src/utils/showdown.css rename to assets/src/utils/showdown.css diff --git a/swh/web/assets/src/utils/showdown.js b/assets/src/utils/showdown.js rename from swh/web/assets/src/utils/showdown.js rename to assets/src/utils/showdown.js diff --git a/package.json b/package.json --- a/package.json +++ b/package.json @@ -3,12 +3,12 @@ "version": "0.0.289", "description": "Static assets management for swh-web", "scripts": { - "build-dev": "NODE_ENV=development webpack --config ./swh/web/assets/config/webpack.config.development.js --color", - "build-test": "NODE_ENV=test webpack --config ./swh/web/assets/config/webpack.config.development.js --color", - "start-dev": "NODE_ENV=development nodemon --watch swh/web/api --watch swh/web/browse --watch swh/web/templates --watch swh/web/common --watch swh/web/settings --watch swh/web/assets/config --ext py,html,js --exec \"webpack serve --config ./swh/web/assets/config/webpack.config.development.js --color\"", - "build": "NODE_ENV=production webpack --config ./swh/web/assets/config/webpack.config.production.js --color", + "build-dev": "NODE_ENV=development webpack --config assets/config/webpack.config.development.js --color", + "build-test": "NODE_ENV=test webpack --config assets/config/webpack.config.development.js --color", + "start-dev": "NODE_ENV=development nodemon --watch swh/web/api --watch swh/web/browse --watch swh/web/templates --watch swh/web/common --watch swh/web/settings --watch assets/config --ext py,html,js --exec \"webpack serve --config assets/config/webpack.config.development.js --color\"", + "build": "NODE_ENV=production webpack --config assets/config/webpack.config.production.js --color", "mochawesome": "mochawesome-merge cypress/mochawesome/results/*.json > cypress/mochawesome/mochawesome.json && marge -o cypress/mochawesome/report cypress/mochawesome/mochawesome.json", - "eslint": "eslint -c swh/web/assets/config/.eslintrc --fix swh/web/assets/** cypress/integration/** cypress/plugins/** cypress/support/**", + "eslint": "eslint -c assets/config/.eslintrc --fix assets/** cypress/integration/** cypress/plugins/** cypress/support/**", "preinstall": "npm -v || (SWH_WEB=$PWD && cd /tmp && yarn add npm && cd node_modules/npm && yarn link && cd $SWH_WEB && yarn link npm)", "nyc-report": "nyc report --reporter=lcov" }, @@ -125,11 +125,11 @@ "nyc": { "report-dir": "cypress/coverage", "exclude": [ - "swh/web/assets/src/bundles/vendors/index.js", - "swh/web/assets/src/thirdparty/**/*.js" + "assets/src/bundles/vendors/index.js", + "assets/src/thirdparty/**/*.js" ] }, "engines": { "node": ">=8.9.0" } } \ No newline at end of file diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -38,9 +38,10 @@ # package generated static assets as module data files data_files = [] -for root, _, files in os.walk("static/"): - root_files = [os.path.join(root, i) for i in files] - data_files.append((os.path.join("share/swh/web", root), root_files)) +for folder in ("static/", "assets/"): + for root, _, files in os.walk(folder): + root_files = [os.path.join(root, i) for i in files] + data_files.append((os.path.join("share/swh/web", root), root_files)) setup( name="swh.web", diff --git a/swh/web/assets/config/.eslintignore b/swh/web/assets/config/.eslintignore deleted file mode 100644 --- a/swh/web/assets/config/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -swh/web/assets/src/thirdparty/**/*.js diff --git a/swh/web/tests/conftest.py b/swh/web/tests/conftest.py --- a/swh/web/tests/conftest.py +++ b/swh/web/tests/conftest.py @@ -61,6 +61,7 @@ # explicitly specified in pytest option if config.getoption("--hypothesis-profile") is None: settings.load_profile("swh-web-fast") + # Small hack in order to be able to run the unit tests # without static assets generated by webpack. # Those assets are not really needed for the Python tests @@ -71,18 +72,26 @@ # that issue. test_dir = os.path.dirname(__file__) # location of the static folder when running tests through tox - static_dir = os.path.join(sys.prefix, "share/swh/web/static") + data_dir = os.path.join(sys.prefix, "share/swh/web") + static_dir = os.path.join(data_dir, "static") if not os.path.exists(static_dir): # location of the static folder when running tests locally with pytest static_dir = os.path.join(test_dir, "../../../static") + webpack_stats = os.path.join(static_dir, "webpack-stats.json") if os.path.exists(webpack_stats): return - bundles_dir = os.path.join(test_dir, "../assets/src/bundles") - _, dirs, _ = next(os.walk(bundles_dir)) + + bundles_dir = os.path.join(test_dir, "../../../assets/src/bundles") + if not os.path.exists(bundles_dir): + # location of the bundles folder when running tests with tox + bundles_dir = os.path.join(data_dir, "assets/src/bundles") + + _, bundles, _ = next(os.walk(bundles_dir)) + mock_webpack_stats = {"status": "done", "publicPath": "/static", "chunks": {}} - for bundle in dirs: + for bundle in bundles: asset = "js/%s.js" % bundle mock_webpack_stats["chunks"][bundle] = [ {