generated from Tinkoff/angular-open-source-starter
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(demo): automatically generate
routesFile.txt
before prerender
…
…command (#245)
- Loading branch information
1 parent
1fcd17e
commit 4c1033f
Showing
5 changed files
with
56 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,4 @@ Thumbs.db | |
|
||
.ssl | ||
RELEASE_BODY.md | ||
projects/demo/routesFile.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {readFileSync, writeFileSync} from 'fs'; | ||
import {join} from 'path'; | ||
|
||
import {infoLog, SMALL_TAB_SYMBOL, titleLog} from './helpers/colored-log'; | ||
|
||
const EXCEPTIONS = ['/', 'angular/Setup']; | ||
|
||
/** | ||
* This script is required for correct of `nx prerender demo` command. | ||
* `@nguniversal/builders:prerender` (version 12) can't extract routes for lazy-loading modules. | ||
* See: https://github.com/angular/universal/issues/1769 | ||
* ___ | ||
* TODO: after update to the newer version of Angular and `@nguniversal/builders`, check if this script is still required. | ||
*/ | ||
(function main(): void { | ||
const demoPathEnumContent = readFileSync( | ||
join(process.cwd(), `projects`, `demo`, `src`, `app`, `demo-path.ts`), | ||
`utf-8`, | ||
); | ||
const routes = | ||
demoPathEnumContent | ||
.match(/['"`](.*)['"`]/g) | ||
?.map(route => route.replace(/['"`]/g, '')) || []; | ||
|
||
routes.forEach(route => { | ||
if (route.startsWith('kit')) { | ||
routes.push(`${route}/API`); | ||
} | ||
}); | ||
routes.push(...EXCEPTIONS); | ||
|
||
titleLog('Generated routes:'); | ||
infoLog(`${SMALL_TAB_SYMBOL}* ${routes?.join(`\n${SMALL_TAB_SYMBOL}* `)}`); | ||
|
||
writeFileSync( | ||
join(process.cwd(), `projects`, `demo`, `routesFile.txt`), | ||
routes?.join('\n') || '', | ||
); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters