Browse Source

chg: dev: add api-platform and upgrade yarn packages and its dependencies #8

master
Lang 3 months ago
parent
commit
8090a7c8ac
12 changed files with 5480 additions and 2822 deletions
  1. +7
    -0
      assets/js/admin.js
  2. +7
    -0
      config/packages/api_platform.yaml
  3. +10
    -0
      config/packages/nelmio_cors.yaml
  4. +16
    -0
      config/packages/notifier.yaml
  5. +15
    -53
      config/packages/security.yaml
  6. +3
    -0
      config/packages/sensio_framework_extra.yaml
  7. +4
    -0
      config/routes/api_platform.yaml
  8. +5
    -0
      config/routes/api_platform_admin.yaml
  9. +10
    -4
      package.json
  10. +10
    -0
      templates/admin.html.twig
  11. +36
    -25
      webpack.config.js
  12. +5357
    -2740
      yarn.lock

+ 7
- 0
assets/js/admin.js View File

@@ -0,0 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { HydraAdmin } from '@api-platform/admin';

const entrypoint = document.getElementById('api-entrypoint').innerText;

ReactDOM.render(<HydraAdmin entrypoint={entrypoint}/>, document.getElementById('api-platform-admin'));

+ 7
- 0
config/packages/api_platform.yaml View File

@@ -0,0 +1,7 @@
api_platform:
mapping:
paths: ['%kernel.project_dir%/src/Entity']
patch_formats:
json: ['application/merge-patch+json']
swagger:
versions: [3]

+ 10
- 0
config/packages/nelmio_cors.yaml View File

@@ -0,0 +1,10 @@
nelmio_cors:
defaults:
origin_regex: true
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
allow_headers: ['Content-Type', 'Authorization']
expose_headers: ['Link']
max_age: 3600
paths:
'^/': null

+ 16
- 0
config/packages/notifier.yaml View File

@@ -0,0 +1,16 @@
framework:
notifier:
#chatter_transports:
# slack: '%env(SLACK_DSN)%'
# telegram: '%env(TELEGRAM_DSN)%'
#texter_transports:
# twilio: '%env(TWILIO_DSN)%'
# nexmo: '%env(NEXMO_DSN)%'
channel_policy:
# use chat/slack, chat/telegram, sms/twilio or sms/nexmo
urgent: ['email']
high: ['email']
medium: ['email']
low: ['email']
admin_recipients:
- { email: admin@example.com }

+ 15
- 53
config/packages/security.yaml View File

@@ -1,62 +1,24 @@
security:
role_hierarchy:
ROLE_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN]
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
SONATA:
- ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT # if you are using acl then this line must be commented
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
fos_userbundle:
id: fos_user.user_provider.username
users_in_memory: { memory: null }
firewalls:
# Disabling the security for the web debug toolbar, the profiler and Assetic.
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: true
lazy: true
provider: users_in_memory

# -> custom firewall for the admin area of the URL
admin:
pattern: /admin(.*)
context: user
form_login:
provider: fos_userbundle
login_path: /admin/login
use_forward: false
check_path: /admin/login_check
failure_path: null
logout:
path: /admin/logout
target: /admin/login
anonymous: true

# -> end custom configuration
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#firewalls-authentication

# default login area for standard users

# This firewall is used to handle the public login area
# This part is handled by the FOS User Bundle
main:
pattern: .*
context: user
form_login:
provider: fos_userbundle
login_path: /login
use_forward: false
check_path: /login_check
failure_path: null
logout: true
anonymous: true
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true

# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
# Admin login page needs to be accessed without credential
- { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }

# Secured part of the site
# This config requires being logged for the whole site and having the admin role for the admin part.
# Change these rules to adapt them to your needs
- { path: ^/admin/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
- { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
# - { path: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }

+ 3
- 0
config/packages/sensio_framework_extra.yaml View File

@@ -0,0 +1,3 @@
sensio_framework_extra:
router:
annotations: false

+ 4
- 0
config/routes/api_platform.yaml View File

@@ -0,0 +1,4 @@
api_platform:
resource: .
type: api_platform
prefix: /api

+ 5
- 0
config/routes/api_platform_admin.yaml View File

@@ -0,0 +1,5 @@
admin:
path: /admin
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
defaults:
template: admin.html.twig

+ 10
- 4
package.json View File

@@ -1,10 +1,13 @@
{
"devDependencies": {
"@symfony/webpack-encore": "^0.19.0",
"@babel/preset-react": "^7.10.4",
"core-js": "^3.0.0",
"regenerator-runtime": "^0.13.2",
"@symfony/webpack-encore": "^0.30.2",
"autoprefixer": "^9.1.1",
"node-sass": "^4.0",
"node-sass": "^4.14.1",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"sass-loader": "^8.0.0",
"webpack-notifier": "^1.6.0"
},
"license": "UNLICENSED",
@@ -16,11 +19,14 @@
"build": "encore production"
},
"dependencies": {
"@api-platform/admin": "^2.2.1",
"@fortawesome/fontawesome-free": "^5.2.0",
"bootstrap": "^4.1.3",
"froala-design-blocks": "^1.0.2",
"owl.carousel": "^2.3.4",
"popper.js": "^1.14.4"
"popper.js": "^1.14.4",
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"browserslist": [
"last 7 versions",


+ 10
- 0
templates/admin.html.twig View File

@@ -0,0 +1,10 @@
{% extends 'base.html.twig' %}

{% block title %}API Platform Admin{% endblock %}

{% block body %}<div id="api-platform-admin"></div>{% endblock %}

{% block javascripts %}
<script type="text/plain" id="api-entrypoint">{{ path('api_entrypoint') }}</script>
{{ encore_entry_script_tags('admin') }}
{% endblock %}

+ 36
- 25
webpack.config.js View File

@@ -1,21 +1,19 @@
var Encore = require('@symfony/webpack-encore');

// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

Encore
// directory where compiled assets will be stored
// directory where compiled assets will be stored
.setOutputPath('public/build/')
// public path used by the web server to access the output path
.setPublicPath('/build')
// only needed for CDN's or sub-directory deploy
//.setManifestKeyPrefix('build/')

// uncomment if you're having problems with a jQuery plugin
.autoProvidejQuery()
.autoProvideVariables({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
})

/*
* ENTRY CONFIG
*
@@ -23,10 +21,18 @@ Encore
* (including one that's included on every page - e.g. "app")
*
* Each entry will result in one JavaScript file (e.g. app.js)
* and one CSS file (e.g. app.css) if you JavaScript imports CSS.
* and one CSS file (e.g. app.css) if your JavaScript imports CSS.
*/
.addEntry('app', './assets/js/app.js')
.addStyleEntry('style', './assets/css/app.scss')
// .addEntry('app', './assets/js/app.js')
//.addEntry('page1', './assets/js/page1.js')
//.addEntry('page2', './assets/js/page2.js')

// When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
.splitEntryChunks()

// will require an extra script tag for runtime.js
// but, you probably want this, unless you're building a single-page app
.enableSingleRuntimeChunk()

/*
* FEATURE CONFIG
@@ -38,26 +44,31 @@ Encore
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
.enableSassLoader(function (sassOptions) {
}, {resolveUrlLoader: false})
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())

// enables @babel/preset-env polyfills
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
config.corejs = 3;
})

// enables Sass/SCSS support
.enableSassLoader()

// enable autoprefixer
.enablePostCssLoader((options) => {
options.config = {
path: 'config/postcss.config.js'
};
})
.enablePostCssLoader()
// uncomment if you use TypeScript
//.enableTypeScriptLoader()

// uncomment if you use TypeScript
//.enableTypeScriptLoader()
;
// uncomment to get integrity="..." attributes on your script & link tags
// requires WebpackEncoreBundle 1.4 or higher
//.enableIntegrityHashes(Encore.isProduction())

// module.noParse = "/node_modules\\/json-schema\\/lib\\/validate\\.js/";
// uncomment if you're having problems with a jQuery plugin
//.autoProvidejQuery()

// uncomment if you use API Platform Admin (composer req api-admin)
.enableReactPreset()
.addEntry('admin', './assets/js/admin.js')
;

module.exports = Encore.getWebpackConfig();

+ 5357
- 2740
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save