Issue on yarn build with Sage theme when curly braces is present on CSS Classes - roots-sage

We have a problem when we do yarn build on our project. Upon investigating it, we found that the mixins that curly braces create an error.
Below is the mixin that we have:
#mixin headings($from: 1, $to: 6) {
#for $i from $from through $to {
h#{ $i } {
#content;
}
}
}
Currently, here is our package.json
{
"name": "sage",
"private": true,
"browserslist": [
"extends #roots/browserslist-config"
],
"engines": {
"node": ">=16.0.0"
},
"type": "module",
"scripts": {
"dev": "bud dev",
"build": "bud build",
"translate": "yarn translate:pot && yarn translate:update",
"translate:pot": "wp i18n make-pot . ./resources/lang/sage.pot --include=\"app,resources\"",
"translate:update": "for filename in ./resources/lang/*.po; do msgmerge -U $filename ./resources/lang/sage.pot; done; rm -f ./resources/lang/*.po~",
"translate:compile": "yarn translate:mo && yarn translate:js",
"translate:js": "wp i18n make-json ./resources/lang --pretty-print",
"translate:mo": "wp i18n make-mo ./resources/lang ./resources/lang",
"lint": "yarn lint:js && yarn lint:css",
"lint:js": "eslint resources/scripts",
"lint:css": "stylelint \"resources/**/*.{css,scss,vue}\"",
"test": "yarn lint"
},
"devDependencies": {
"#roots/bud": "^6.8.0",
"#roots/bud-eslint": "^6.8.0",
"#roots/bud-prettier": "^6.8.0",
"#roots/bud-sass": "^6.8.0",
"#roots/bud-stylelint": "^6.8.0",
"#roots/bud-tailwindcss": "6.8.0",
"#roots/eslint-config": "^6.8.0",
"#roots/sage": "6.8.0"
},
"dependencies": {
"alpinejs": "^3.11.1"
}
}
We're not sure what is the missing piece here as we already have all the dependencies we need.
Here is the error we experience

Related

SonarQube showing 0% coverage for Unit Test in a NodeJS appliication

On SonarQube server, for all my projects, the scans are happening and I can see the Sonar metrics but the Unit Test coverage is showing as 0% for both 'new code' and 'overall code'.
The project source code is written in NodeJS/JavaScript which I need to scan with SonarQube.
Please refer attached screenshot:-
Package.json:-
{
"name": "analytics",
"version": "1.0.0",
"description": "Microservice to handle CRUD operations of analytics",
"main": "server.js",
"directories": {
"test": "test"
},
"scripts": {
"dev": "node -r dotenv/config server.js",
"dev:watch": "nodemon --watch ../analytics --watch ../../common -r dotenv/config server.js",
"start": "node server.js",
"test": "nyc --reporter=lcov --reporter=text-lcov mocha -r dotenv/config"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.752.0",
"aws-xray-sdk": "^2.5.0",
"axios": "^0.19.2",
"bcrypt": "3.0.8",
"body-parser": "1.19.0",
"cls-hooked": "4.2.2",
"cors": "2.8.5",
"dotenv": "8.2.0",
"express": "4.17.1",
"express-mung": "^0.5.1",
"express-useragent": "^1.0.13",
"fast-csv": "^4.1.3",
"json2csv": "^5.0.5",
"jsonwebtoken": "^8.5.1",
"kafka-node": "^5.0.0",
"lodash": "^4.17.20",
"moment": "^2.24.0",
"multer": "^1.4.2",
"node-cron": "^2.0.3",
"nodemon": "^2.0.5",
"passport-saml": "1.3.3",
"path": "^0.12.7",
"pg": "7.14.0",
"pg-hstore": "2.3.3",
"prom-client": "12.0.0",
"prometheus-api-metrics": "2.2.3",
"qrcode": "1.4.4",
"redis": "^3.0.2",
"redis-clustr": "1.7.0",
"seedrandom": "^3.0.5",
"sequelize": "5.21.2",
"speakeasy": "2.0.0",
"streamifier": "^0.1.1",
"uuid": "3.3.3",
"winston": "3.2.1"
},
"devDependencies": {
"ajv": "6.10.2",
"chai": "4.2.0",
"chai-as-promised": "^7.1.1",
"chai-http": "4.3.0",
"chai-jest-snapshot": "^2.0.0",
"chai-uuid": "1.0.6",
"eslint": "6.8.0",
"mocha": "6.2.2",
"mochawesome": "4.1.0",
"nyc": "14.1.1",
"redis-mock": "0.49.0",
"sequelize-mock": "0.10.2",
"sinon": "7.5.0"
}
}
Jenkinsfile code snippet:-
stages{
stage('Lint Analysis'){
steps{
echo '*************running lint analysis**********'
// sh 'eslint . --ext .js -c .eslintrc.js --fix || true' //To display output on console
// sh 'eslint . --ext .js -c .eslintrc.js --fix -f checkstyle > eslint.xml || true' //To create report which will be use by checkstyle plugin
}
}
stage('Unit Test'){
steps{
//Running Unit test to get Code Coverage report using clover plugin
dir('services/analytics') {
echo '************ Running UT ***********'
// sh 'npm install'
// sh 'npm run coverage'
// step([
// $class: 'CloverPublisher',
// cloverReportDir: 'test/coverage',
// cloverReportFileName: 'clover.xml',
// healthyTarget: [methodCoverage: 80, conditionalCoverage: 80, statementCoverage: 80],
// unhealthyTarget: [methodCoverage: 50, conditionalCoverage: 50, statementCoverage: 50],
// failingTarget: [methodCoverage: 0, conditionalCoverage: 0, statementCoverage: 0]
// ])
}
}
}
stage('Static Code Analysis by SonarQube') {
steps {
script {
withSonarQubeEnv("aws_sonarqube") {
sh "${tool("sonar_scanner")}/bin/sonar-scanner \
-Dproject.settings=./sonar-project.properties \
-Dsonar.login=$SONAR_TOKEN"
}
}
}
}
}
sonar-project.properties:-
sonar.projectKey=test-analytics
sonar.projectName=test-analytics
sonar.projectVersion=1.0
sonar.language=js
sonar.sources=.
sonar.sourceEncoding=UTF-8
# sonar.exclusions=./**/*.spec.js
sonar.tests=.
sonar.test.inclusions=./**/*.spec.js,./**/*.spec.jsx,./**/*.test.js,./**/*.test.jsx
# sonar.coverage.exclusions=./**/*.spec.js,./**/*.mock.js,node_modules/*,coverage/lcov-report/*
sonar.javascript.lcov.reportPaths=./coverage/lcov.info
# sonar.testExecutionReportPaths=test-report.xml
Please advise, thanks

Error in Opening Electron App in Mac:"file:///Applications/../Contents/Resources/app.asar/dist/index.html"

I have build the electron app for mac but when I ran it , it is giving the below error
"Not allowed to load local resource: file:///Applications/e-admin.app/Contents/Resources/app.asar/dist/index.html".
Here are the steps I did.
1) electron-builder build --mac
It created the following files are dist folder.
a) e-admin-0.0.0.dmg , e-admin-0.0.0-mac.zip,index.html and a mac folder
b) in mac folder I could see mac/e-admin.app/Contents/Resources/app.asar file( not the folder)
2) I double clicked and installed the e-admin-0.0.0.dmg and moved to application folder.
3) Opened the app.
Do I have to do any thing with app.asar file?(unpack or some thing?) or any etc procedure to make it work?
my package.json
{
"name": "e-admin",
"version": "0.0.0",
"scripts": {
"postinstall": "electron-builder install-app-deps",
"ng": "ng",
"start": "npm-run-all -p electron:serve ng:serve",
"build": "npm run electron:serve-tsc && ng build",
"build:dev": "npm run build -- -c dev",
"build:prod": "npm run build -- -c production",
"ng:serve": "ng serve",
"ng:serve:web": "ng serve -c web -o",
"electron:serve-tsc": "tsc -p tsconfig-serve.json",
"electron:serve": "wait-on http-get://localhost:4200/ && npm run electron:serve-tsc && electron . --serve",
"electron:local": "npm run build:prod && electron .",
"electron:linux": "npm run build:prod && electron-builder build --linux",
"electron:windows": "npm run build:prod && electron-builder build --windows",
"electron:mac": "npm run build:prod && electron-builder build --mac",
"test": "ng test",
"e2e": "npm run build:prod && cross-env TS_NODE_PROJECT='e2e/tsconfig.e2e.json' mocha --timeout 300000 --require ts-node/register e2e/**/*.e2e.ts",
"version": "conventional-changelog -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
"lint": "ng lint"
},
"main": "main.js",
"private": true,
"dependencies": {...}
and angular.josn file
"projects": {
"eAdmin": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "#angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
....
main.ts contains
if (serve) {
require('electron-reload')(__dirname, {
electron: require(`${__dirname}/node_modules/electron`)
});
win.loadURL('http://localhost:4200');
} else {
win.loadURL(url.format({
pathname: path.join(__dirname, 'dist/index.html'),
protocol: 'file:',
slashes: true
}));
}
After muiltple trial and error, The following changes worked for me
1) index.html
`<base href="/">`
to
<base href="./">
2) in main.ts, change the directory name dist to something else
from :
win.loadURL(url.format({
pathname: path.join(__dirname, 'dist/index.html'),
protocol: 'file:',
slashes: true
}));
To:
win.loadURL(url.format({
pathname: path.join(__dirname, 'angular_build/index.html'),
protocol: 'file:',
slashes: true
}));
3) Angular.js
"outputPath": "dist/",
to
"outputPath": "angular_build/",
Although I have seen suggesions to change step 2 & 3 , I was quite skepitcal.
Looks like dist directlory some how does not work and have to change to some thing like as mentioned above

How to debug yarn / npm in WebStorm

Normally I use yarn and start my Node.js app with yarn start. I tried the same in WebStorm to debug it, but app does not starts in browser, what is wrong? I can start app, but not debug it.
Package.json:
{
"name": "ticket",
"version": "0.1.0",
"private": true,
"dependencies": {
"#material-ui/core": "^4.6.1",
"#material-ui/icons": "^4.5.1",
"axios": "^0.19.0",
"facebookgraph": "^0.4.0",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-facebook-login": "^4.1.1",
"react-scripts": "3.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"prettier": "^1.19.1",
"pretty-quick": "^2.0.1"
}
}
WebStorm reads the package.json by default and places all commands in the left menu
So if you wanna add more commands just edit the scripts section in your package.json
You can click for example on start an will be run the script

Decoupled Deployment of Web App using Heroku, gh-pages, and MySQL

My team and I created a MERN stack application (M for MySQL) that is planning on hosting our client on gh-pages and our server on heroku. So far we have been unable to deploy because we keep getting errors about our use of the npm package concurrently. Although we can access our heroku url and our gh-pages url, we are unable to connect the two
We have already tried adding a proxy to our package.json within our client folder and have added a .env.development Host name (heroku url)
Root Directory
- client
- package.json
- package-lock.json
- config
- config.json
- passport.json
- controllers
- models
- routes
- .env
- .env.development
- .gitignore
- package-lock.json
- package.json
- server.js
Server package.json
{
"name": "traveler",
"version": "1.0.0",
"homepage": "http://dchicchon.github.io/Traveler",
"description": "A social media platform for people who love traveling and those who want to explore.",
"main": "server.js",
"scripts": {
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:prod": "node server.js",
"start:dev": "concurrently \"nodemon --ignore 'client/*'\" \"npm run client\"",
"client": "cd client && npm run start",
"seed": "node scripts/seedDB.js",
"install": "cd client && npm install",
"build": "cd client && npm run build",
"heroku-postbuild": "npm run build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.511.0",
"bcryptjs": "^2.4.3",
"concurrently": "^4.1.1",
"dotenv": "^8.0.0",
"express": "^4.17.1",
"express-session": "^1.16.2",
"gh-pages": "^2.0.1",
"multer": "^1.4.2",
"multer-s3": "^2.9.0",
"mysql2": "^1.6.5",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"sequelize": "^5.13.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/dchicchon/Traveler.git"
},
"bugs": {
"url": "https://github.com/dchicchon/Traveler/issues"
}
}
Client package.json
{
"name": "traveler",
"version": "0.1.0",
"proxy": "https://travelersite.herokuapp.com/",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"google-map-react": "^1.1.4",
"lodash": "^4.17.15",
"materialize-css": "^1.0.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-router-dom": "^5.0.1",
"react-scripts": "3.1.0",
"styled-components": "^4.3.2"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"gh-pages": "^2.1.1"
}
}
After entering the command heroku create and git push heroku master we would expect that our server will be pushed to heroku and our client will be deployed to gh-pages.
Does removing heroku-postbuild script from your backend package.json work?

React-native command unrecognized

I have installed react-native and built some simple application. I ran it and everything was fine. After a while, I could not run anymore my application, because every time I type "react-native start" in cmd, it gets me something like in the picture below. Does anyone have any idea?
EDIT: package json looks like:
{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "15.3.2",
"react-native": "0.36.0",
"react-native-checkbox": "^1.0.15",
"react-native-mail": "^2.0.0"
},
"jest": {
"preset": "jest-react-native"
},
"devDependencies": {
"babel-jest": "16.0.0",
"babel-preset-react-native": "1.9.0",
"jest": "16.0.2",
"jest-react-native": "16.0.0",
"react-test-renderer": "15.3.2"
}
}
according to me you need to run npm install from your root project dir because you might have deleted some file from node_module folder which will be recovered after running the above command.

Resources