stored in the ``dist/`` directory. Use the ``-prod`` flag for a
production build. Navigate to ``https://localhost:8443``.
+Formating TS and SCSS files
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We use `Prettier <https://prettier.io/>`_ to automatically format TS and SCSS
+files.
+To use this plugin you can either install it in your IDE, if supported, or use
+it via the cli.
+
+We added 2 npm scripts to help running prettier commands:
+- ``npm run prettier``, will run prettier formatter on all frontend files
+- ``npm run prettier:lint``, will check all frontend files against prettier linter
+
Running Unit Tests
~~~~~~~~~~~~~~~~~~
"test:ci": "jest --coverage",
"lint": "ng lint",
"e2e": "ng e2e",
- "makePretty": "pretty-quick --staged"
+ "prettier": "prettier --write \"{src,e2e}/**/*.{ts,scss}\"",
+ "prettier:lint": "prettier --list-different \"{src,e2e}/**/*.{ts,scss}\""
},
"private": true,
"jest": {
"jest": "23.2.0",
"jest-canvas-mock": "1.0.3",
"jest-preset-angular": "5.2.3",
- "prettier": "1.13.6",
- "pretty-quick": "1.6.0",
+ "prettier": "1.13.7",
"protractor": "5.3.2",
"ts-node": "5.0.1",
"tslint": "5.10.0",
- "tslint-eslint-rules": "5.3.1",
"typescript": "2.7.2"
}
}
{
"rulesDirectory": ["node_modules/codelyzer"],
- "extends": ["tslint-eslint-rules"],
"rules": {
"no-consecutive-blank-lines": true,
"arrow-return-shorthand": true,
"curly": true,
"eofline": true,
"forin": true,
- "import-blacklist": [
- true,
- "rxjs/Rx"
- ],
+ "import-blacklist": [true, "rxjs/Rx"],
"import-spacing": true,
"indent": [true, "spaces"],
"interface-over-type-literal": true,
"directive-class-suffix": true,
"no-forward-ref": true,
"no-output-named-after-standard-event": true,
- "ordered-imports": true,
- "no-extra-semi": true,
- "ter-no-irregular-whitespace": true,
- "no-multi-spaces": true,
- "brace-style": [
- true,
- "1tbs",
- {
- "allowSingleLine": false
- }
- ],
- "ter-indent": [
- true,
- 2,
- {
- "SwitchCase": 1,
- "FunctionDeclaration": {
- "body": 1,
- "parameters": "first"
- },
- "FunctionExpression": {
- "body": 1,
- "parameters": "first"
- }
- }
- ],
- "space-in-parens": [true, "never"]
+ "ordered-imports": true
}
}
#!/usr/bin/env bash
-set -e
-
+failed=false
cd $CEPH_ROOT/src/pybind/mgr/dashboard/frontend
+. $CEPH_ROOT/build/src/pybind/mgr/dashboard/node-env/bin/activate
+
+# Build
+npm run build -- --prod --progress=false || failed=true
+# Unit Tests
config='src/unit-test-configuration.ts'
if [ -e $config ]; then
mv $config ${config}_old
fi
cp ${config}.sample $config
-. $CEPH_ROOT/build/src/pybind/mgr/dashboard/node-env/bin/activate
-
-npm run build -- --prod --progress=false
-npm run test:ci
-npm run lint
+npm run test:ci || failed=true
rm $config
if [ -e ${config}_old ]; then
mv ${config}_old $config
fi
+# Linting
+npm run lint --silent
+if [ $? -gt 0 ]; then
+ failed=true
+ echo -e "\nTry running 'npm run lint -- --fix' to fix some linting errors."
+fi
+
+npm run prettier:lint --silent
+if [ $? -gt 0 ]; then
+ failed=true
+ echo -e "\nTry running 'npm run prettier' to fix linting errors."
+fi
+
deactivate
+
+if [ "$failed" = "true" ]; then
+ exit 1
+fi