Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 3f1ff3b

Browse files
devversionjelbourn
authored andcommitted
build: fix fetch assets script (#360)
* Updates the fetch assets to work on initial postinstall. * Refactors the fetch assets script to be more clean and aligned with the material2/ scripts.
1 parent b029f91 commit 3f1ff3b

File tree

1 file changed

+37
-32
lines changed

1 file changed

+37
-32
lines changed

tools/fetch-assets.sh

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
11
#!/bin/bash
22

3-
# Fetch material2 assets from material2-docs-content repo.
3+
#
4+
# Script that fetches material2 assets from the material2-docs-content repo.
5+
#
46

7+
cd $(dirname ${0})/../
58

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/
811

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/
1114

12-
stackblitzxampleAssetsPath=./src/assets/stackblitz/
15+
# Path to the directory where the Stackblitz examples should be copied to.
16+
stackblitzDestination=./src/assets/stackblitz/
1317

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
1620

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"
1923

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
2826

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}
3232

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}
3535

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
4038

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}
4443

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

Comments
 (0)