|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 |
| -# Fetch material2 assets from material2-docs-content repo. |
| 3 | +# |
| 4 | +# Script that fetches material2 assets from the material2-docs-content repo. |
| 5 | +# |
4 | 6 |
|
| 7 | +cd $(dirname ${0})/../ |
5 | 8 |
|
6 |
| -# Dir where documentation assets will be copied (overviews, api docs) |
7 |
| -docAssetsPath=./src/assets/documents/ |
| 9 | +# Directory where documentation assets should be copied to (overviews, api docs) |
| 10 | +documentsDestination=./src/assets/documents/ |
8 | 11 |
|
9 |
| -# Dir where live-example assets will be copied |
10 |
| -exampleAssetsPath=./src/assets/ |
| 12 | +# Directory where the live example assets will be copied to. |
| 13 | +examplesDestination=./src/assets/ |
11 | 14 |
|
12 |
| -stackblitzxampleAssetsPath=./src/assets/stackblitz/ |
| 15 | +# Path to the directory where the Stackblitz examples should be copied to. |
| 16 | +stackblitzDestination=./src/assets/stackblitz/ |
13 | 17 |
|
14 |
| -# Dir where published assets will temporarily copied to (using `git clone`). |
15 |
| -tmpAssetClonePath=/tmp/material-assets |
| 18 | +# Path to the @angular/material-examples package in the node modules. |
| 19 | +materialExamplesDestination=./node_modules/@angular/material-examples |
16 | 20 |
|
17 |
| -# GitHub repo which contains snapshots of the docs content from angular/material2. |
18 |
| -docsContentRepo=https://github.com/angular/material2-docs-content |
| 21 | +# Git HTTP clone URL for the material2-docs-content repository. |
| 22 | +docsContentRepoUrl="https://github.com/angular/material2-docs-content" |
19 | 23 |
|
20 |
| -# Dirs for each of api docs, guides, overviews, and live-examples within the |
21 |
| -# cloned content repo. The absense of the trailing slash here is significant if |
22 |
| -# someone is running on a Mac. |
23 |
| -apiPath=${tmpAssetClonePath}/api |
24 |
| -guidesPath=${tmpAssetClonePath}/guides |
25 |
| -overviewPath=${tmpAssetClonePath}/overview |
26 |
| -examplesPath=${tmpAssetClonePath}/examples |
27 |
| -stackblitzExamplesPath=${tmpAssetClonePath}/stackblitz/examples |
| 24 | +# Path to the directory where the docs-content will be cloned. |
| 25 | +docsContentPath=/tmp/material2-docs-content |
28 | 26 |
|
29 |
| -# Create folders into which to copy content and assets. |
30 |
| -mkdir -p ${tmpAssetClonePath} |
31 |
| -mkdir -p ${exampleAssetsPath} ${docAssetsPath} |
| 27 | +# Create all necessary directories if they don't exist. |
| 28 | +mkdir -p ${documentsDestination} |
| 29 | +mkdir -p ${examplesDestination} |
| 30 | +mkdir -p ${stackblitzDestination} |
| 31 | +mkdir -p ${materialExamplesDestination} |
32 | 32 |
|
33 |
| -# Clone the assets from Github but only fetch the last commit to download less unused data. |
34 |
| -git clone ${docsContentRepo} ${tmpAssetClonePath} --depth 1 |
| 33 | +# Remove previous repository if directory is present. |
| 34 | +rm -Rf ${docsContentPath} |
35 | 35 |
|
36 |
| -# Copy files over to their proper place in src/assets |
37 |
| -cp -R ${apiPath} ${overviewPath} ${guidesPath} ${docAssetsPath} |
38 |
| -cp -R ${examplesPath} ${exampleAssetsPath} |
39 |
| -cp -R ${stackblitzExamplesPath} ${stackblitzExampleAssetsPath} |
| 36 | +# Clone the docs-content repository. |
| 37 | +git clone ${docsContentRepoUrl} ${docsContentPath} --depth 1 |
40 | 38 |
|
41 |
| -# Install the live examples component library |
42 |
| -mkdir -p ./node_modules/@angular/material-examples |
43 |
| -cp -R ${tmpAssetClonePath}/examples-package/* ./node_modules/@angular/material-examples |
| 39 | +# Copy all document assets (API, overview and guides). |
| 40 | +cp -R ${docsContentPath}/api ${documentsDestination} |
| 41 | +cp -R ${docsContentPath}/overview ${documentsDestination} |
| 42 | +cp -R ${docsContentPath}/guides ${documentsDestination} |
44 | 43 |
|
45 |
| -# Remove temporary directory |
46 |
| -rm -rf ${tmpAssetClonePath} |
| 44 | +# Copy the example assets to the docs. |
| 45 | +cp -R ${docsContentPath}/examples ${examplesDestination} |
| 46 | + |
| 47 | +# Copy the StackBlitz examples to the docs. |
| 48 | +cp -R ${docsContentPath}/stackblitz/examples ${stackblitzDestination} |
| 49 | + |
| 50 | +# Manually install the @angular/material-examples package from the docs-content. |
| 51 | +cp -R ${docsContentPath}/examples-package/* ${materialExamplesDestination} |
0 commit comments