Skip to content
This repository has been archived by the owner on May 29, 2023. It is now read-only.

Commit

Permalink
bootstrap project
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Jun 24, 2022
1 parent 7e0d92c commit 981dc31
Show file tree
Hide file tree
Showing 67 changed files with 23,264 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
src/addons/**/node_modules
src/addons/**/cypress
src/addons/**/build
49 changes: 49 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const fs = require('fs');
const path = require('path');
const projectRootPath = __dirname;
const packageJson = require(path.join(projectRootPath, 'package.json'));

let voltoPath = './node_modules/@plone/volto';

let configFile;
if (fs.existsSync(`${this.projectRootPath}/tsconfig.json`))
configFile = `${this.projectRootPath}/tsconfig.json`;
else if (fs.existsSync(`${this.projectRootPath}/jsconfig.json`))
configFile = `${this.projectRootPath}/jsconfig.json`;

if (configFile) {
const jsConfig = require(configFile).compilerOptions;
const pathsConfig = jsConfig.paths;
if (pathsConfig['@plone/volto'])
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
}

const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
const reg = new AddonConfigurationRegistry(__dirname);

// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
const addonAliases = Object.keys(reg.packages).map((o) => [
o,
reg.packages[o].modulePath,
]);

module.exports = {
extends: `${voltoPath}/.eslintrc`,
settings: {
'import/resolver': {
alias: {
map: [
['@plone/volto', '@plone/volto/src'],
...addonAliases,
['@package', `${__dirname}/src`],
['@root', `${__dirname}/src`],
['~', `${__dirname}/src`],
],
extensions: ['.js', '.jsx', '.json'],
},
'babel-plugin-root-import': {
rootPathSuffix: 'src',
},
},
},
};
82 changes: 82 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.vscode/
logs
*.log
npm-debug.log*
.DS_Store

coverage

# Node
node_modules
coverage
jsdoc
webpack-assets.json
webpack-stats.json
npm-debug.log
dist
junit.xml
eslint.xml
yarn-error.log
build

# Other
.DS_Store
.idea
lighthouse-report.html
.vscode/
.#*
*~

# Python
/api/.installed.cfg
/api/.mr.developer.cfg
/api/bin/
/api/develop-eggs/
/api/eggs/
/api/include/
/api/lib/
/api/lib64/
/api/notebook/env/
/api/parts/
/api/share/python-wheels/
/api/src/
/api/var/
/api/venv/
/bin/
/lib/
.Python
include
pip-selfcheck.json
pyvenv.cfg
share

# locales
locales/*.json

# Tests
/tests/bin
/tests/develop-eggs
/tests/parts
/tests/.installed.cfg
*.pyc
geckodriver.log
log.html
output.xml
report.html
selenium-screenshot-*.png
/selenium/
cypress/videos/
cypress/screenshots

# Local environment setup
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

data
omelette

public/critical.css
src/addons/*
120 changes: 120 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
const webpack = require('webpack');
const path = require('path');
const makeLoaderFinder = require('razzle-dev-utils/makeLoaderFinder');
const fileLoaderFinder = makeLoaderFinder('file-loader');

const projectRootPath = path.resolve('.');
const lessPlugin = require('@plone/volto/webpack-plugins/webpack-less-plugin');

const createConfig = require('../node_modules/razzle/config/createConfigAsync.js');
const razzleConfig = require(path.join(projectRootPath, 'razzle.config.js'));

const SVGLOADER = {
test: /icons\/.*\.svg$/,
use: [
{
loader: 'svg-loader',
},
{
loader: 'svgo-loader',
options: {
plugins: [
{ removeTitle: true },
{ convertPathData: false },
{ removeUselessStrokeAndFill: true },
{ removeViewBox: false },
],
},
},
],
};

module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
// '@storybook/preset-scss',
],
webpackFinal: async (config, { configType }) => {
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
// You can change the configuration based on that.
// 'PRODUCTION' is used when building the static version of storybook.

// Make whatever fine-grained changes you need
let baseConfig;
baseConfig = await createConfig(
'web',
'dev',
{
// clearConsole: false,
modifyWebpackConfig: razzleConfig.modifyWebpackConfig,
plugins: razzleConfig.plugins,
},
webpack,
);
const AddonConfigurationRegistry = require('@plone/volto/addon-registry');

const registry = new AddonConfigurationRegistry(projectRootPath);

config = lessPlugin({ registry }).modifyWebpackConfig({
env: { target: 'web', dev: 'dev' },
webpackConfig: config,
webpackObject: webpack,
options: {},
});

// putting SVG loader on top, fix the fileloader manually (Volto plugin does not
// work) since it needs to go first
config.module.rules.unshift(SVGLOADER);
const fileLoader = config.module.rules.find(fileLoaderFinder);
fileLoader.exclude = [/\.(config|variables|overrides)$/, /icons\/.*\.svg$/];

config.plugins.unshift(
new webpack.DefinePlugin({
__DEVELOPMENT__: true,
__CLIENT__: true,
__SERVER__: false,
}),
);

const resultConfig = {
...config,
resolve: {
...config.resolve,
alias: { ...config.resolve.alias, ...baseConfig.resolve.alias },
},
};
resultConfig.module.rules[1].exclude = /node_modules\/(?!(@plone\/volto)\/)/;

const addonExtenders = registry.getAddonExtenders().map((m) => require(m));

const extendedConfig = addonExtenders.reduce(
(acc, extender) =>
extender.modify(acc, { target: 'web', dev: 'dev' }, config),
resultConfig,
);

// Note: we don't actually support razzle plugins, which are also a feature
// of the razzle.extend.js addons file. Those features are probably
// provided in a different manner by Storybook plugins (for example scss
// loaders).

return extendedConfig;
},
babel: async (options) => {
return {
...options,
plugins: [
...options.plugins,
[
'./node_modules/babel-plugin-root-import/build/index.js',
{
rootPathSuffix: './src',
},
],
],
// any extra options you want to set
};
},
};
15 changes: 15 additions & 0 deletions .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { addons } from '@storybook/addons';

addons.setConfig({
isFullscreen: false,
showNav: true,
showPanel: true,
panelPosition: 'bottom',
sidebarAnimations: true,
enableShortcuts: true,
isToolshown: true,
theme: undefined,
selectedPanel: undefined,
initialActive: 'sidebar',
showRoots: true,
});
27 changes: 27 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import '@plone/volto/config'; // This is the bootstrap for the global config - client side
import React from 'react';
import { StaticRouter } from 'react-router-dom';
import { IntlProvider } from 'react-intl';
import enMessages from '@root/../locales/en.json';

import '@root/theme';

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};

export const decorators = [
(Story) => (
<IntlProvider messages={enMessages} locale="en" defaultLocale="en">
<StaticRouter location="/">
<Story />
</StaticRouter>
</IntlProvider>
),
];
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-prefix ""
File renamed without changes.
8 changes: 4 additions & 4 deletions Jenkinsfile.tpl → Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ pipeline {
environment {
RANCHER_STACKID = ""
RANCHER_ENVID = ""
GIT_NAME = "<%= name %>"
registry = "eeacms/<%= name %>"
template = "templates/<%= name %>"
GIT_NAME = "circularity-frontend"
registry = "eeacms/circularity-frontend"
template = "templates/circularity-frontend"
dockerImage = ''
tagName = ''
SONARQUBE_TAG = '<%= name %>.eionet.europa.eu'
SONARQUBE_TAG = 'circularity-frontend.eionet.europa.eu'
}

agent any
Expand Down
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Yeoman Volto App development

### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules

# Update the versions depending on your project requirements | Last Updated 2022-04-21
DOCKER_IMAGE=plone/plone-backend:6.0.0a4
KGS=plone.restapi==8.22.0 plone.volto==4.0.0a4 plone.rest==2.0.0a5 plone.app.iterate==4.0.2 plone.app.vocabularies==4.3.0
NODEBIN = ./node_modules/.bin

# Project settings

DIR=$(shell basename $$(pwd))

# Recipe snippets for reuse

# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`


# Top-level targets
.PHONY: all
all: project

.PHONY: start-test-backend
start-test-backend: ## Start Test Plone Backend
@echo "$(GREEN)==> Start Test Plone Backend$(RESET)"
docker run -i --rm -e ZSERVER_HOST=0.0.0.0 -e ZSERVER_PORT=55001 -p 55001:55001 -e ADDONS='$(KGS) plone.app.robotframework==2.0.0a3 plone.app.testing==7.0.0a2 plone.app.contenttypes' -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,plone.volto:default-homepage -e CONFIGURE_PACKAGES=plone.app.contenttypes,plone.restapi,plone.volto,plone.volto.cors $(DOCKER_IMAGE) ./bin/robot-server plone.app.robotframework.testing.PLONE_ROBOT_TESTING
## KGS in case you need a Plone 5.2 series (comment/remove above line):
# docker run -i --rm -e ZSERVER_HOST=0.0.0.0 -e ZSERVER_PORT=55001 -p 55001:55001 -e ADDONS='$(KGS) plone.app.robotframework==2.0.0a3 plone.app.contenttypes' -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,plone.volto:default-homepage -e CONFIGURE_PACKAGES=plone.app.contenttypes,plone.restapi,plone.volto,plone.volto.cors $(DOCKER_IMAGE) ./bin/robot-server plone.app.robotframework.testing.PLONE_ROBOT_TESTING

.PHONY: start-backend-docker
start-backend-docker: ## Starts a Docker-based backend
@echo "$(GREEN)==> Start Docker-based Plone Backend$(RESET)"
docker run -it --rm --name=backend -p 8080:8080 -e SITE=Plone -e ADDONS='$(KGS)' $(DOCKER_IMAGE)

.PHONY: help
help: ## Show this help.
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
Loading

0 comments on commit 981dc31

Please sign in to comment.