Our project depends on the bower asset plugin, which has to be installed globally. The question is how to teach scrutinizer to install it before running PHP Analyzer:
Adding it to dependencies doesn't do the trick. Here is the configuration:
build:
dependencies:
# Runs before inferred commands
before:
- 'composer global require "fxp/composer-asset-plugin:~1.1.1"'
tests:
override:
- 'vendor/bin/phpunit'
filter:
excluded_paths:
- 'vendors/*'
- '*/vendors/*'
- '*/tests/*'
- '*/vendor/*'
tools:
js_hint:
filter:
excluded_paths: ['vendors/*','*/vendors/*','*/vendor/*','*/tests/*']
php_mess_detector:
filter:
excluded_paths: ['vendors/*','*/vendors/*','*/vendor/*','*/tests/*']
php_analyzer:
filter:
excluded_paths: ['vendors/*','*/vendors/*','*/vendor/*','*/tests/*']
config:
parameter_reference_check: { enabled: true }
checkstyle: { enabled: false, no_trailing_whitespace: true, naming: { enabled: true, local_variable: '^[a-z][a-zA-Z0-9]*$', abstract_class_name: ^Abstract|Factory$, utility_class_name: 'Utils?$', constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$', property_name: '^[a-z][a-zA-Z0-9]*$', method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$', parameter_name: '^[a-z][a-zA-Z0-9]*$', interface_name: '^[A-Z][a-zA-Z0-9]*Interface$', type_name: '^[A-Z][a-zA-Z0-9]*$', exception_name: '^[A-Z][a-zA-Z0-9]*Exception$', isser_method_name: '^(?:is|has|should|may|supports)' } }
unreachable_code: { enabled: false }
check_access_control: { enabled: false }
typo_checks: { enabled: false }
check_variables: { enabled: false }
suspicious_code: { enabled: false, overriding_parameter: false, overriding_closure_use: false, parameter_closure_use_conflict: false, parameter_multiple_times: false, non_existent_class_in_instanceof_check: false, non_existent_class_in_catch_clause: false, assignment_of_null_return: false, non_commented_switch_fallthrough: false, non_commented_empty_catch_block: false, overriding_private_members: false, use_statement_alias_conflict: false, precedence_in_condition_assignment: false }
dead_assignments: { enabled: false }
verify_php_doc_comments: { enabled: false, parameters: false, return: false, suggest_more_specific_types: false, ask_for_return_if_not_inferrable: false, ask_for_param_type_annotation: false }
loops_must_use_braces: { enabled: true }
check_usage_context: { enabled: true, method_call_on_non_object: { enabled: true, ignore_null_pointer: true }, foreach: { value_as_reference: true, traversable: true }, missing_argument: true, argument_type_checks: lenient }
simplify_boolean_return: { enabled: false }
phpunit_checks: { enabled: false }
reflection_checks: { enabled: false }
precedence_checks: { enabled: true, assignment_in_condition: true, comparison_of_bit_result: true }
basic_semantic_checks: { enabled: false }
doc_comment_fixes: { enabled: false }
reflection_fixes: { enabled: false }
use_statement_fixes: { enabled: true, remove_unused: true, preserve_multiple: false, order_alphabetically: false }
sensiolabs_security_checker:
filter:
excluded_paths: ['vendors/*','*/vendors/*','*/vendor/*','*/tests/*']
php_cpd:
filter:
excluded_paths: ['vendors/*','*/vendors/*','*/vendor/*','*/tests/*']
php_pdepend:
filter:
excluded_paths: ['vendors/*','*/vendors/*','*/vendor/*','*/tests/*']
excluded_dirs:
- vendors
- vendor
checks:
php:
code_rating: true
duplication: true
Here are the Analyzer results
Installing vendors through composer ...
+===================================================================================+
| You can avoid this step by committing your composer.lock file to your repository. |
+===================================================================================+
Identity added: /home/scrutinizer/composer-install/../ssh-key0 (/home/scrutinizer/composer-install/../ssh-key0)
Identity added: /home/scrutinizer/composer-install/../ssh-key1 (/home/scrutinizer/composer-install/../ssh-key1)
You are using the deprecated option "dev". Dev packages are installed by default now.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package bower-asset/jquery could not be found in any version, there may be a typo in the package name.
Problem 2
- The requested package bower-asset/jquery-ui could not be found in any version, there may be a typo in the package name.
Problem 3
- The requested package bower-asset/text could not be found in any version, there may be a typo in the package name.
Problem 4
- The requested package bower-asset/requirejs could not be found in any version, there may be a typo in the package name.
Problem 5
- The requested package bower-asset/jquery-form could not be found in any version, there may be a typo in the package name.
Problem 6
- The requested package bower-asset/jquery-colorbox could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see for more details.
Read for further common problems.
Related
On OSX, after I installed all of dependencies by yarn install, The webpack bundle's output keeps showing the error Error evaluating function ceil: argument must be a number.
I have no idea why this happen but it works on my linux machine with the same package.json
Some info:
webpack: "5.56.0"
less: "^4.1.2"
less-loader: "^10.0.1"
Here is my less-loader config:
{loader: "less-loader"}
It looks like the there is a change of the default options of less based on what I've found in here
https://lesscss.org/usage/#less-options-math
The solution is adding the option for less-loader in webpack config as following:
{
loader: "less-loader",
options: {
lessOptions: {
math: 'always' // <=== add this
}
}
}
Also you should change => strictMath: false
Example (my file config-overrides.js):
const addLessLoader = require("customize-cra-less-loader");
module.exports = override(
addLessLoader({
cssLoaderOptions: {
sourceMap: true,
modules: {
localIdentName: "[hash:base64:8]",
},
},
lessLoaderOptions: {
lessOptions: {
math: "always",
modifyVars: { "#primary-color": "#2a4365" },
javascriptEnabled: true,
strictMath: false,
},
},
})
);
Cron usually worked in the strapi-3.0.0-beta.20 version
but It doesn't work after migrating to version strapi-3.0.0
Strapi-3.0.0-beta.20
./config/environments/{env}/server.json
{
"host": "0.0.0.0",
"port": 1337,
"proxy": {
"enabled": false
},
"cron": {
"enabled": true
},
"admin": {
"autoOpen": false
}
}
Strapi-3.0.0
./config/server.js
module.exports = ({ env }) => ({
host: '0.0.0.0',
port: env.int('PORT', '1337'),
production: env('NODE_ENV') === 'production' ? true : false,
proxy: {
enabled: false
},
cron: {
enabled: true
},
admin: {
autoOpen: false
}
})
This is strapi code that uses the server.js
strapi/packages/strapi/lib/middlewares/cron/index.js
if (strapi.config.get('server.cron.enabled', false) === true) {
_.forEach(_.keys(strapi.config.get('functions.cron', {})), task => {
cron.scheduleJob(task, strapi.config.functions.cron[task]);
});
This is the content registered in the github issue.
Describe the bug
Incorrect information in documentation for new configuration loader
Expected behavior
There is a possibility of misunderstanding in the document regarding the cron setting.
This is a setting to activate cron (3.0.0.beta.20)
./config/environments/{env}/server.json
{
"host": "0.0.0.0",
"port": 1337,
"cron": {
"enabled": true
}
}
The documentation on how to migrate guides like this.
Migrating
Server
Your server configuration can move from ./config/environments/{env}/server.json to
./config/server.js like shown here.
Server
Available options -> cron
However, to enable cron in version 3.0.0 must do it in the middleware.js
./config/middleware.js
timeout: 100,
load: {
before: ['responseTime', 'logger', 'cors', 'responses', 'gzip'],
order: [
"Define the middlewares' load order by putting their name in this array is the right order"
],
after: ['parser', 'router']
},
settings: {
...
cron: { enabled: true }
...
}
Code snippets
After checking the code (strapi/middlewares/index.js), I learned that it should be set in middleware.
System
- Node.js version: v12.14.0
- NPM version: 6.13.6
- Strapi version: 3.0.0
- Database: mongodb
- Operating system: window, linux
Is there a way to thoroughly mangle vue components that have been bundled with webpack?
When applying mangling via terser-webpack-plugin with mangle.properties set to true, then not all of the property names are mangled, for example:
location: {
lng: -.134281,
lat:51.513508,
zoom:13,
pitch:1,
bearing:60
}
becomes
location:{
k:-.134281,
M:51.513508,
zoom:13,
pitch:1,
V:60
}
Edit
As requested: the relevant portion of the Webpack configuration file, in this case the default vie-cli config with the mangle.properties item manually added:
minimizer: [
{
options: {
test: /\.m?js(\?.*)?$/i,
chunkFilter: () => true,
warningsFilter: () => true,
extractComments: false,
sourceMap: false,
cache: true,
cacheKeys: defaultCacheKeys => defaultCacheKeys,
parallel: true,
include: undefined,
exclude: undefined,
minify: undefined,
terserOptions: {
output: {
comments: /^\**!|#preserve|#license|#cc_on/i
},
compress: {
arrows: false,
collapse_vars: false,
comparisons: false,
computed_props: false,
hoist_funs: false,
hoist_props: false,
hoist_vars: false,
inline: false,
loops: false,
negate_iife: false,
properties: false,
reduce_funcs: false,
reduce_vars: false,
switches: false,
toplevel: false,
typeofs: false,
booleans: true,
if_return: true,
sequences: true,
unused: true,
conditionals: true,
dead_code: true,
evaluate: true
},
mangle: {
safari10: true,
properties: true
}
}
}
}
],
These two properties (zoom, pitch) so happened to be included in the reserved name list, have a look at this default domprops.json file which UglifyJS uses internally during mangling.
A default exclusion file is provided in tools/domprops.json which should cover most standard JS and DOM properties defined in various browsers. Pass --mangle-props domprops to disable this feature
If you like to keep this default list, you could do any of the following in the custom minify option of the plugin:
Create your custom reserved name list,
Load up the default list (domprops.json) and pass in a function/filter for removing those unwanted names,
Simply merge these two files if you are sure there is no name conflict.
webpack.config.js
{
optimization: {
minimizer: [
new TerserPlugin({
minify(file, sourceMap) {
const uglifyJsOptions = {
mangle: {
properties: {
reserved: require('your_custom_list')
}
// Or filter them
properties: {
reserved: require('uglify-js/tools/domprops.json')
.filter(name => ![
'zoom',
'pitch'
]
.includes(name))
}
}
};
return require('uglify-js').minify(file, uglifyJsOptions);
},
}),
],
},
}
Also, please mind the similarities between mangle.reserved and mangle.properties.reserved while doing this, as the latter one might be what you need here. Check out the minify option structure.
Here's my less task config:
less: {
development: {
options: {
compress: false,
sourceMap: true,
yuicompress: true,
sourceMapFilename: 'export/style/app.css.map',
sourceMapURL: '/style/app.css.map'
},
files: {
"export/style/app.css": "less/app.less"
}
}
},
If I just type grunt less, in my compiled file i get the /*# sourceMappingURL=/style/app.css.map */ comment correctly.
Instead, when i run grunt and my watch task kicks in, the /*# sourceMappingURL=/style/app.css.map */ comment is removed on compilation.
Here's my watch task for less:
watch: {
less: {
files: ['less/*.less'],
tasks: ['less', 'postcss'],
options: {
livereload: true,
nospaces: true
}
}
},
What am I doing wrong?
it was actually the postcss task preventing the comment to appear. fixed with
postcss: {
options: {
map: true,
For my packages, dojo seems to be appending 'main.js' to end of each file resulting in a '404' has any one experienced this and or have a solution?
GET http://localhost:9000/scripts/prodLayers/main.js 404 (Not Found)
var dojoConfig = {
has: {
"dojo-firebug": true,
"dojo-debug-messages": true
},
tlmSiblingOfDojo: true,
async: true,
parseOnLoad: false,
packages: [
{ name: "prod", location: "/scripts/prodLayers"}
]
};
packages: [
{ name: "prodLayers", location: "/scripts/mylibs", main: "prodLayers"}
]
The "main" attribute is name of the file to be referenced using 'baseUrl' to define the package locations may also help to simplify the "location" params.