Skip to content

Commit 4cf528e

Browse files
committed
refactor: prettier --config ./.prettierrc --list-different \"src/{app,environments,styles}/**/*{.ts,.json,.scss}\"
1 parent 142e978 commit 4cf528e

File tree

14 files changed

+315
-89
lines changed

14 files changed

+315
-89
lines changed

.prettierrc

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
{
22
"printWidth": 100,
3-
"parser": "typescript",
43
"singleQuote": true,
54
"tabWidth": 2,
65
"trailingComma": "all",
7-
"prettier-tslint": true,
8-
"arrowParens": "always"
6+
"arrowParens": "always",
7+
"overrides": [
8+
{
9+
"files": "*.ts",
10+
"options": {
11+
"parser": "typescript"
12+
}
13+
},
14+
{
15+
"files": "*.json",
16+
"options": {
17+
"parser": "json",
18+
"trailingComma": "none"
19+
}
20+
},
21+
{
22+
"files": "*.scss",
23+
"options": {
24+
"parser": "scss",
25+
"trailingComma": "none"
26+
}
27+
},
28+
{
29+
"files": "*.css",
30+
"options": {
31+
"parser": "css",
32+
"trailingComma": "none"
33+
}
34+
}
35+
]
936
}

package-lock.json

Lines changed: 185 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"ssr:sw": "ng run universal-demo:server:dev --watch",
1212
"ssr:webpack": "webpack --watch",
1313
"ssr:server": "nodemon server.js",
14+
"format:check": "prettier --config ./.prettierrc --list-different \"src/{app,environments,styles}/**/*{.ts,.json,.scss}\"",
1415
"build": "ng build",
1516
"build:server": "ng run universal-demo:server:production",
1617
"build:prod": "ng build --prod",
@@ -69,6 +70,7 @@
6970
"karma-jasmine": "1.1.2",
7071
"karma-jasmine-html-reporter": "1.3.1",
7172
"nodemon": "1.18.3",
73+
"prettier-tslint": "^0.4.0",
7274
"protractor": "5.4.0",
7375
"ssri": "6.0.0",
7476
"tslint": "5.11.0",

prerender.ts

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ const files = fs.readdirSync(`${process.cwd()}/dist-server`);
99

1010
global['window'] = win;
1111
Object.defineProperty(win.document.body.style, 'transform', {
12-
value: () => {
13-
return {
14-
enumerable: true,
15-
configurable: true
16-
};
17-
},
12+
value: () => {
13+
return {
14+
enumerable: true,
15+
configurable: true,
16+
};
17+
},
1818
});
1919
global['document'] = win.document;
2020
global['CSS'] = null;
@@ -39,7 +39,7 @@ import { renderModuleFactory } from '@angular/platform-server';
3939
import { ROUTES } from './static.paths';
4040

4141
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
42-
const mainFiles = files.filter(file => file.startsWith('main'));
42+
const mainFiles = files.filter((file) => file.startsWith('main'));
4343
const hash = mainFiles[0].split('.')[1];
4444
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require(`./dist-server/main.${hash}`);
4545
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
@@ -52,34 +52,40 @@ const index = readFileSync(join('dist', 'index.html'), 'utf8');
5252
let previousRender = Promise.resolve();
5353

5454
// Iterate each route path
55-
ROUTES.forEach(route => {
56-
const fullPath = join(BROWSER_FOLDER, route);
55+
ROUTES.forEach((route) => {
56+
const fullPath = join(BROWSER_FOLDER, route);
5757

58-
// Make sure the directory structure is there
59-
if (!existsSync(fullPath)) {
60-
let syncpath = BROWSER_FOLDER;
61-
route.split('/').forEach(element => {
62-
syncpath = syncpath + '/' + element;
63-
mkdirSync(syncpath);
64-
});
65-
}
58+
// Make sure the directory structure is there
59+
if (!existsSync(fullPath)) {
60+
let syncpath = BROWSER_FOLDER;
61+
route.split('/').forEach((element) => {
62+
syncpath = syncpath + '/' + element;
63+
mkdirSync(syncpath);
64+
});
65+
}
6666

67-
// Writes rendered HTML to index.html, replacing the file if it already exists.
68-
previousRender = previousRender.then(_ => renderModuleFactory(AppServerModuleNgFactory, {
67+
// Writes rendered HTML to index.html, replacing the file if it already exists.
68+
previousRender = previousRender
69+
.then((_) =>
70+
renderModuleFactory(AppServerModuleNgFactory, {
6971
document: index,
7072
url: route,
7173
extraProviders: [
72-
provideModuleMap(LAZY_MODULE_MAP),
73-
{
74-
provide: REQUEST, useValue: null
75-
},
76-
{
77-
provide: RESPONSE, useValue: null
78-
},
79-
{
80-
provide: 'ORIGIN_URL',
81-
useValue: environment.host
82-
}
83-
]
84-
})).then(html => writeFileSync(join(fullPath, 'index.html'), html));
74+
provideModuleMap(LAZY_MODULE_MAP),
75+
{
76+
provide: REQUEST,
77+
useValue: null,
78+
},
79+
{
80+
provide: RESPONSE,
81+
useValue: null,
82+
},
83+
{
84+
provide: 'ORIGIN_URL',
85+
useValue: environment.host,
86+
},
87+
],
88+
}),
89+
)
90+
.then((html) => writeFileSync(join(fullPath, 'index.html'), html));
8591
});

0 commit comments

Comments
 (0)