build(docs-infra): ensure `setup-local` and similar scripts build local packages (#33206)

The `setup-local` scripts (and others that are based on it, such as
`setup-local-viewengine`), mainly does two things: Replace the Angular
packages with the locally built ones for `aio/` and the docs examples
(`aio/tools/examples/shared/`). It does this by calling two other npm
scripts: `aio-use-local` and `example-use-local` respectively.

For these scripts to work, the local Angular packages must be already
built (via `scripts/build-packages-dist.sh`). In order to make it easier
for people to test against local packages, the scripts support a
`--build-packages` option, that (if passed) will result in building the
local packages as well.

Given that the same local packages are used for both `aio/` and the
examples, we only need to build the packages once. Also, to speed up
execution on CI, we do not need to build the packages there, because the
packages would have been built already in a previous CI job.

However, the various setup npm scripts were not implemented correctly to
meet these requirements. Specifically, when running locally,
`aio-use-local` would build the packages, while `example-use-local`
would not (it was supposed to use the already built packages from
`aio-use-local`). The `example-use-local` script, though, was configured
to run before `aio-use-local`. As a result, the packages were not built,
by the time `example-use-local` needed them, which would cause an error.

This commit fixes it by ensuring that `aio-use-local` (which builds the
local Angular packages) runs before `example-use-local`, so that the
latter can use the same packages already built by the former.

PR Close #33206
This commit is contained in:
George Kalpakas 2019-10-16 23:15:40 +03:00 committed by Matias Niemelä
parent 16fe90d6ac
commit a9fd36f2f8
1 changed files with 6 additions and 3 deletions

View File

@ -17,11 +17,11 @@
"build": "yarn ~~build",
"prebuild-local": "yarn setup-local",
"build-local": "yarn ~~build",
"prebuild-local-ci": "yarn setup-local --no-build-packages",
"prebuild-local-ci": "yarn setup-local-ci",
"build-local-ci": "yarn ~~build --progress=false",
"prebuild-local-with-viewengine": "node scripts/switch-to-viewengine && yarn setup-local",
"build-local-with-viewengine": "yarn ~~build",
"prebuild-local-with-viewengine-ci": "node scripts/switch-to-viewengine && yarn setup-local --no-build-packages",
"prebuild-local-with-viewengine-ci": "node scripts/switch-to-viewengine && yarn setup-local-ci",
"build-local-with-viewengine-ci": "yarn ~~build --progress=false",
"extract-cli-command-docs": "node tools/transforms/cli-docs-package/extract-cli-commands.js 38635d2d9",
"lint": "yarn check-env && yarn docs-lint && ng lint && yarn example-lint && yarn tools-lint",
@ -32,8 +32,11 @@
"setup": "yarn example-use-npm && yarn aio-use-npm",
"postsetup": "yarn boilerplate:add && yarn extract-cli-command-docs && yarn docs",
"presetup-local": "yarn presetup",
"setup-local": "yarn example-use-local && yarn aio-use-local",
"setup-local": "yarn aio-use-local && yarn example-use-local",
"postsetup-local": "yarn postsetup",
"presetup-local-ci": "yarn presetup-local",
"setup-local-ci": "yarn aio-use-local --no-build-packages && yarn example-use-local",
"postsetup-local-ci": "yarn postsetup-local",
"set-opensearch-url": "node --eval \"const sh = require('shelljs'); sh.set('-e'); sh.sed('-i', /PLACEHOLDER_URL/g, process.argv[1], 'dist/assets/opensearch.xml');\"",
"presmoke-tests": "yarn update-webdriver",
"smoke-tests": "protractor tests/deployment/e2e/protractor.conf.js --suite smoke --baseUrl",