Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit d303c92

Browse files
authored
Merge pull request #1605 from NativeScript/trifonov/build-improvements
Build improvements
2 parents b831eb8 + d48a48e commit d303c92

File tree

6 files changed

+146
-130
lines changed

6 files changed

+146
-130
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Most of the content in this repository is shared between the two environments, b
2929

3030
2. If you have a page that should be appear in both environments but has different content for certain sections, you can use our built-in environment block tags. The blocks are named `angular` and `nativescript`, respectively, and can be used like this:
3131

32-
```
32+
```md
3333
{% nativescript %}This paragraph appears only in the vanilla NativeScript documentation{% endnativescript %}
3434

3535
This paragraph appears in both environments.
@@ -44,6 +44,7 @@ If you plan to work on a non-trivial change, you will most probably want to run
4444
### Prerequisites
4545

4646
Docker should be installed on your machine:
47+
4748
* Open the [official Docker install page](https://docs.docker.com/engine/installation/) and follow the instructions.
4849

4950
The NativeScript documentation is composed from multiple repositories:
@@ -64,15 +65,17 @@ Open a console box (**Windows users should run a Git bash session!**) and clone
6465
mkdir ns-docs
6566
cd ns-docs
6667
git clone https://github.com/NativeScript/docs.git
67-
git clone https://github.com/NativeScript/NativeScript.git
6868
git clone https://github.com/NativeScript/nativescript-angular.git
69-
git clone https://github.com/NativeScript/nativescript-sdk-examples-js.git
70-
git clone https://github.com/NativeScript/nativescript-sdk-examples-ng.git
71-
git clone https://github.com/NativeScript/nativescript-cli.git
7269
```
7370

7471
Optional:
72+
7573
```bash
74+
git clone https://github.com/NativeScript/NativeScript.git
75+
git clone https://github.com/NativeScript/nativescript-sdk-examples-js.git
76+
git clone https://github.com/NativeScript/nativescript-sdk-examples-ng.git
77+
git clone https://github.com/NativeScript/nativescript-cli.git
78+
7679
git clone https://github.com/NativeScript/nativescript-ui-listview
7780
git clone https://github.com/NativeScript/nativescript-ui-autocomplete
7881
git clone https://github.com/NativeScript/nativescript-ui-dataform
@@ -82,8 +85,7 @@ git clone https://github.com/NativeScript/nativescript-ui-gauge
8285
git clone https://github.com/NativeScript/nativescript-ui-sidedrawer
8386
```
8487

85-
> **NOTE**: `nativescript-ui` is private repository used for building the Api Reference for the NativeScript UI components.
86-
88+
> **NOTE**: `nativescript-ui-...` are private repositories used for building the Api Reference for the NativeScript UI components.
8789
> **NOTE**: If you have these repositories locally from previous work with the documentation, be sure to delete them and start from scratch as some old files can cause problems with the current setup.
8890
8991
Then build the docker image by using the following command from the `ns-docs` folder:

build/Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ GEM
1212
execjs (2.6.0)
1313
fastimage (1.8.0)
1414
addressable (~> 2.3, >= 2.3.5)
15-
ffi (1.9.10)
15+
ffi (1.9.24)
1616
github-markdown (0.6.9)
1717
hike (1.2.3)
1818
html-pipeline (2.2.2)
@@ -53,9 +53,9 @@ GEM
5353
mini_portile2 (2.3.0)
5454
minitest (5.8.2)
5555
multi_json (1.11.2)
56-
nokogiri (1.8.4)
56+
nokogiri (1.8.5)
5757
mini_portile2 (~> 2.3.0)
58-
rack (1.6.4)
58+
rack (1.6.11)
5959
rb-fsevent (0.9.7)
6060
rb-inotify (0.9.7)
6161
ffi (>= 0.5.0)

build/build-docs.sh

Lines changed: 49 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -24,49 +24,38 @@ NS_UI_GA=$SCRIPT_PATH"/../../nativescript-ui-gauge"
2424
NS_UI_SD=$SCRIPT_PATH"/../../nativescript-ui-sidedrawer"
2525
NS_UI_API_REF=$DOCS_ROOT"/ns_ui_api-reference"
2626

27-
if [ -d "$ROOT" ]; then
28-
rm -rf $ROOT
29-
fi
27+
[ ! -d "$ROOT" ] && rm -rf $ROOT
3028

3129
mkdir $ROOT
3230

33-
if [ ! -d "$CONTENT_ROOT" ]; then
34-
mkdir $CONTENT_ROOT
35-
fi
36-
37-
if [ ! -d "$WWW_ROOT" ]; then
38-
mkdir $WWW_ROOT
39-
fi
31+
[ -d "$CONTENT_ROOT" ] || mkdir $CONTENT_ROOT
32+
[ -d "$WWW_ROOT" ] || mkdir $WWW_ROOT
4033

4134
bundle config build.nokogiri --use-system-libraries
4235

43-
cd $CLI_ROOT
44-
./docs/build-jekyll-md.sh
36+
[ ! -d $CLI_ROOT ] || (cd $CLI_ROOT && ./docs/build-jekyll-md.sh)
4537

4638
cd $SCRIPT_PATH
4739
bundle install
4840

4941
cp -r $SCRIPT_PATH"/_config_vuejs.yml" \
50-
$SCRIPT_PATH"/_assets" \
51-
$SCRIPT_PATH"/_layouts" \
52-
$SCRIPT_PATH"/_plugins" \
53-
$SCRIPT_PATH"/_includes" \
54-
$SCRIPT_PATH"/fonts" \
55-
$VUEJS_ROOT
42+
$SCRIPT_PATH"/_assets" \
43+
$SCRIPT_PATH"/_layouts" \
44+
$SCRIPT_PATH"/_plugins" \
45+
$SCRIPT_PATH"/_includes" \
46+
$SCRIPT_PATH"/fonts" \
47+
$VUEJS_ROOT
5648

5749
rm $VUEJS_ROOT"/_plugins/redirect_generator.rb" \
58-
$VUEJS_ROOT"/_plugins/snippet.rb" \
59-
$VUEJS_ROOT"/_plugins/ns_cookbook.rb"
50+
$VUEJS_ROOT"/_plugins/snippet.rb" \
51+
$VUEJS_ROOT"/_plugins/ns_cookbook.rb"
6052

6153
# NativeScript UI Docs Api Reference build. Docs snippet injecting
62-
if [ -f $NS_UI_LV"/README.md" ]; then
54+
declare -a examples=($NS_UI_AC $NS_UI_CA $NS_UI_CH $NS_UI_DF $NS_UI_GA $NS_UI_LV $NS_UI_SD)
6355

64-
set +e
65-
set -e
66-
declare -a examples=($NS_UI_AC $NS_UI_CA $NS_UI_CH $NS_UI_DF $NS_UI_GA $NS_UI_LV $NS_UI_SD)
67-
68-
for i in "${examples[@]}"
69-
do
56+
for i in "${examples[@]}"
57+
do
58+
if [ -d $i ]; then
7059
cd $i
7160
# Generating Angular d.ts
7261
cd "src"
@@ -83,29 +72,21 @@ if [ -f $NS_UI_LV"/README.md" ]; then
8372
cd "../demo-angular"
8473
npm install markdown-snippet-injector
8574
npm run inject
75+
atLeastOneNSUIExists=1
76+
fi
77+
done
8678

87-
88-
done
89-
79+
if [ -n "$atLeastOneNSUIExists" -a -d $NS_UI_API_REF ]; then
9080
cd $NS_UI_API_REF
9181
npm i
9282
gulp
9383
fi
9484

95-
cd $SDK_ROOT_NG
96-
./build-docs.sh
97-
98-
cd $SDK_ROOT_JS
99-
./build-docs.sh
100-
101-
cd $NG_ROOT
102-
./build-doc-snippets.sh
103-
104-
cd $MODULES_ROOT
105-
./build-docs.sh
106-
107-
cd $NG_ROOT
108-
./build-docs.sh
85+
[ ! -d $SDK_ROOT_NG ] || (cd $SDK_ROOT_NG && ./build-docs.sh)
86+
[ ! -d $SDK_ROOT_JS ] || (cd $SDK_ROOT_JS && ./build-docs.sh)
87+
[ ! -d $NG_ROOT ] || (cd $NG_ROOT && ./build-doc-snippets.sh)
88+
[ ! -d $MODULES_ROOT ] || (cd $MODULES_ROOT && ./build-docs.sh)
89+
[ ! -d $NG_ROOT ] || (cd $NG_ROOT && ./build-docs.sh)
10990

11091
cp $SCRIPT_PATH"/_config_angular.yml" \
11192
$SCRIPT_PATH"/_config_nativescript.yml" \
@@ -117,21 +98,19 @@ for JEKYLL_DIR in {_assets,_includes,_layouts,_plugins,fonts,images}; do
11798
rsync -a --delete $JEKYLL_DIR $CONTENT_ROOT
11899
done
119100

120-
cp -R $DOCS_ROOT"/docs/./" \
121-
$SDK_ROOT_JS"/dist/cookbook/ns-framework-modules" \
122-
$MODULES_ROOT"/bin/dist/snippets" \
123-
$NG_ROOT"/bin/dist/snippets" \
124-
$SDK_ROOT_NG"/dist/code-samples/ng-framework-modules" \
125-
$SDK_ROOT_NG"/dist/code-samples/ng-hardware-access" \
126-
$CONTENT_ROOT
101+
cp -R $DOCS_ROOT"/docs/./" $CONTENT_ROOT
127102

128-
cp -R $CLI_ROOT"/docs-cli" $CONTENT_ROOT"/tooling"
129-
cp -R $SDK_ROOT_JS"/dist/cookbook/ns-ui-widgets" $CONTENT_ROOT"/ui"
130-
cp -R $SDK_ROOT_JS"/dist/cookbook/ns-ui/." $CONTENT_ROOT"/ui"
131-
cp -R $SDK_ROOT_NG"/dist/code-samples/ng-ui-widgets" $CONTENT_ROOT"/ui"
132-
cp -R $SDK_ROOT_NG"/dist/code-samples/common-screens" $CONTENT_ROOT"/app-and-screen-templates"
133-
cp -R $SDK_ROOT_NG"/dist/code-samples/ng-ui/." $CONTENT_ROOT"/ui"
103+
[ ! -d $SDK_ROOT_JS ] || cp -R $SDK_ROOT_JS"/dist/cookbook/ns-framework-modules" $CONTENT_ROOT
104+
[ ! -d $SDK_ROOT_NG ] || cp -R $SDK_ROOT_NG"/dist/code-samples/ng-framework-modules" \
105+
$SDK_ROOT_NG"/dist/code-samples/ng-hardware-access" \
106+
$CONTENT_ROOT
134107

108+
[ ! -d $MODULES_ROOT ] || cp -R $MODULES_ROOT"/bin/dist/snippets" $CONTENT_ROOT
109+
[ ! -d $NG_ROOT ] || cp -R $NG_ROOT"/bin/dist/snippets" $CONTENT_ROOT
110+
[ ! -d $CLI_ROOT ] || cp -R $CLI_ROOT"/docs-cli" $CONTENT_ROOT"/tooling"
111+
[ ! -d $SDK_ROOT_JS ] || cp -R $SDK_ROOT_JS"/dist/cookbook/ns-ui-widgets" $SDK_ROOT_JS"/dist/cookbook/ns-ui/." $CONTENT_ROOT"/ui"
112+
[ ! -d $SDK_ROOT_NG ] || cp -R $SDK_ROOT_NG"/dist/code-samples/ng-ui-widgets" $SDK_ROOT_NG"/dist/code-samples/ng-ui/." $CONTENT_ROOT"/ui"
113+
[ ! -d $SDK_ROOT_NG ] || cp -R $SDK_ROOT_NG"/dist/code-samples/common-screens" $CONTENT_ROOT"/app-and-screen-templates"
135114

136115
cp $SCRIPT_PATH"/nginx.conf" $CONTENT_ROOT
137116

@@ -146,25 +125,27 @@ fi
146125

147126
export JEKYLL_ENV="nativescript"
148127
jekyll build --config _config_nativescript.yml,_config.yml
149-
export JEKYLL_ENV="angular"
150-
jekyll build --config _config_angular.yml,_config.yml
151128

129+
[ ! -d $NG_ROOT ] || (export JEKYLL_ENV="angular" && jekyll build --config _config_angular.yml,_config.yml)
152130

153131
cd $VUEJS_ROOT
154132

155133
export JEKYLL_ENV="vuejs"
156134
jekyll build --config _config_vuejs.yml --trace
157135

136+
cp -R $VUEJS_ROOT"/vuejs" $WWW_ROOT
137+
158138
cd $ROOT
159139

160-
cp -R $MODULES_ROOT"/bin/dist/api-reference" \
161-
$NG_ROOT"/nativescript-angular/bin/dist/ng-api-reference" \
162-
$VUEJS_ROOT"/vuejs" \
163-
$WWW_ROOT
164-
if [ -f $NS_UI_LV"/README.md" ]; then
165-
cp -R $NS_UI_API_REF"/ns-ui-api-reference" \
166-
$WWW_ROOT
140+
[ ! -d $MODULES_ROOT ] || cp -R $MODULES_ROOT"/bin/dist/api-reference" $WWW_ROOT
141+
[ ! -d $NG_ROOT ] || cp -R $NG_ROOT"/nativescript-angular/bin/dist/ng-api-reference" $WWW_ROOT
142+
143+
if [ -d $NS_UI_LV ]; then
144+
if [ -d $NS_UI_API_REF"/ns-ui-api-reference" ]; then
145+
cp -R $NS_UI_API_REF"/ns-ui-api-reference" \
146+
$WWW_ROOT
147+
fi
167148
fi
168-
cp -R $NS_DIST_ROOT"/./" $WWW_ROOT
169-
cp -R $NG_DIST_ROOT"/./" $WWW_ROOT"/angular"
170149

150+
cp -R $NS_DIST_ROOT"/./" $WWW_ROOT
151+
[ ! -d $NG_ROOT ] || cp -R $NG_DIST_ROOT"/./" $WWW_ROOT"/angular"

build/docs-watcher/paths.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ module.exports.distRoot = path.join(module.exports.binRoot, "site");
99
module.exports.docsRoot = path.join(module.exports.root, "..", "docs");
1010
module.exports.modulesRoot = path.join(module.exports.root, "..", "..", "NativeScript");
1111
module.exports.nativescriptAngularRoot = path.join(module.exports.root, "..", "..", "nativescript-angular");
12-
module.exports.sdkExamplesRoot = path.join(module.exports.root, "..", "..", "nativescript-sdk-examples-ng");
12+
module.exports.sdkExamplesRootNG = path.join(module.exports.root, "..", "..", "nativescript-sdk-examples-ng");
1313
module.exports.sdkExamplesRootJS = path.join(module.exports.root, "..", "..", "nativescript-sdk-examples-js");
14-
module.exports.sdkExamplesRootJS = path.join(module.exports.root, "..", "..", "nativescript-ui-listview");
15-
module.exports.sdkExamplesRootJS = path.join(module.exports.root, "..", "..", "nativescript-ui-autocomplete");
16-
module.exports.sdkExamplesRootJS = path.join(module.exports.root, "..", "..", "nativescript-ui-dataform");
17-
module.exports.sdkExamplesRootJS = path.join(module.exports.root, "..", "..", "nativescript-ui-chart");
18-
module.exports.sdkExamplesRootJS = path.join(module.exports.root, "..", "..", "nativescript-ui-calendar");
19-
module.exports.sdkExamplesRootJS = path.join(module.exports.root, "..", "..", "nativescript-ui-gauge");
20-
module.exports.sdkExamplesRootJS = path.join(module.exports.root, "..", "..", "nativescript-ui-sidedrawer");
14+
module.exports.nsUIListView = path.join(module.exports.root, "..", "..", "nativescript-ui-listview");
15+
module.exports.nsUIAutoComplete = path.join(module.exports.root, "..", "..", "nativescript-ui-autocomplete");
16+
module.exports.nsUIDataForm = path.join(module.exports.root, "..", "..", "nativescript-ui-dataform");
17+
module.exports.nsUIChart = path.join(module.exports.root, "..", "..", "nativescript-ui-chart");
18+
module.exports.nsUICalendar = path.join(module.exports.root, "..", "..", "nativescript-ui-calendar");
19+
module.exports.nsUIGauge = path.join(module.exports.root, "..", "..", "nativescript-ui-gauge");
20+
module.exports.nsUISideDrawer = path.join(module.exports.root, "..", "..", "nativescript-ui-sidedrawer");
2121
module.exports.cliRoot = path.join(module.exports.root, "..", "..", "nativescript-cli");
2222
module.exports.vuejsRoot = path.join(module.exports.root, "..", "vuejs-docs");
2323

@@ -27,3 +27,19 @@ module.exports.assetsPaths = [
2727
path.join(module.exports.sourceFilesRoot, "docs", "build", "_layouts"),
2828
path.join(module.exports.sourceFilesRoot, "docs", "build", "_includes"),
2929
];
30+
31+
module.exports.sourcePathsInImage = [
32+
`${module.exports.sourceFilesRoot}/docs`,
33+
`${module.exports.sourceFilesRoot}/NativeScript`,
34+
`${module.exports.sourceFilesRoot}/nativescript-angular`,
35+
`${module.exports.sourceFilesRoot}/nativescript-cli`,
36+
`${module.exports.sourceFilesRoot}/nativescript-sdk-examples-js`,
37+
`${module.exports.sourceFilesRoot}/nativescript-sdk-examples-ng`,
38+
`${module.exports.sourceFilesRoot}/nativescript-ui-autocomplete`,
39+
`${module.exports.sourceFilesRoot}/nativescript-ui-calendar`,
40+
`${module.exports.sourceFilesRoot}/nativescript-ui-chart`,
41+
`${module.exports.sourceFilesRoot}/nativescript-ui-dataform`,
42+
`${module.exports.sourceFilesRoot}/nativescript-ui-gauge`,
43+
`${module.exports.sourceFilesRoot}/nativescript-ui-listview`,
44+
`${module.exports.sourceFilesRoot}/nativescript-ui-sidedrawer`,
45+
];

build/docs-watcher/start.sh

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,54 +25,46 @@ trap 'sigint_handler' SIGINT
2525

2626
mkdir -p /www
2727

28-
if [ ! -d /root/./nativescript-ui-listview ]; then
29-
mkdir /root/./nativescript-ui-listview
28+
echo "Start copying mounted folders..."
3029

31-
fi
32-
if [ ! -d /root/./nativescript-ui-autocomplete ]; then
33-
mkdir /root/./nativescript-ui-autocomplete
30+
rsync --relative -az --exclude node_modules/ --exclude .git \
31+
/root/./docs \
32+
/root/./nativescript-angular \
33+
/www
3434

35+
if [ -d /root/./NativeScript ]; then
36+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./NativeScript /www
3537
fi
36-
if [ ! -d /root/./nativescript-ui-dataform ]; then
37-
mkdir /root/./nativescript-ui-dataform
38-
38+
if [ -d /root/./nativescript-sdk-examples-ng ]; then
39+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./nativescript-sdk-examples-ng /www
3940
fi
40-
if [ ! -d /root/./nativescript-ui-chart ]; then
41-
mkdir /root/./nativescript-ui-chart
42-
41+
if [ -d /root/./nativescript-sdk-examples-js ]; then
42+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./nativescript-sdk-examples-js /www
4343
fi
44-
if [ ! -d /root/./nativescript-ui-calendar ]; then
45-
mkdir /root/./nativescript-ui-calendar
46-
44+
if [ -d /root/./nativescript-cli ]; then
45+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./nativescript-cli /www
4746
fi
48-
if [ ! -d /root/./nativescript-ui-gauge ]; then
49-
mkdir /root/./nativescript-ui-gauge
50-
47+
if [ -d /root/./nativescript-ui-listview ]; then
48+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./nativescript-ui-listview /www
5149
fi
52-
if [ ! -d /root/./nativescript-ui-sidedrawer ]; then
53-
mkdir /root/./nativescript-ui-sidedrawer
54-
50+
if [ -d /root/./nativescript-ui-autocomplete ]; then
51+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./nativescript-ui-autocomplete /www
5552
fi
56-
if [ ! -d /root/./docs/ns_ui_api-reference/ns-ui-api-reference ]; then
57-
mkdir /root/./docs/ns_ui_api-reference/ns-ui-api-reference
58-
53+
if [ -d /root/./nativescript-ui-dataform ]; then
54+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./nativescript-ui-dataform /www
55+
fi
56+
if [ -d /root/./nativescript-ui-chart ]; then
57+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./nativescript-ui-chart /www
58+
fi
59+
if [ -d /root/./nativescript-ui-calendar ]; then
60+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./nativescript-ui-calendar /www
61+
fi
62+
if [ -d /root/./nativescript-ui-gauge ]; then
63+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./nativescript-ui-gauge /www
64+
fi
65+
if [ -d /root/./nativescript-ui-sidedrawer ]; then
66+
rsync --relative -az --exclude node_modules/ --exclude .git /root/./nativescript-ui-sidedrawer /www
5967
fi
60-
echo "Start copying mounted folders..."
61-
rsync --relative -az --exclude node_modules/ --exclude .git \
62-
/root/./docs \
63-
/root/./NativeScript \
64-
/root/./nativescript-angular \
65-
/root/./nativescript-sdk-examples-ng \
66-
/root/./nativescript-sdk-examples-js \
67-
/root/./nativescript-ui-listview \
68-
/root/./nativescript-ui-autocomplete \
69-
/root/./nativescript-ui-dataform \
70-
/root/./nativescript-ui-chart \
71-
/root/./nativescript-ui-calendar \
72-
/root/./nativescript-ui-gauge \
73-
/root/./nativescript-ui-sidedrawer \
74-
/root/./nativescript-cli \
75-
/www
7668

7769
/www/docs/build/build-docs.sh
7870
/www/docs/build/nginx-setup.sh

0 commit comments

Comments
 (0)