angular/aio/tools/examples/create-example-playground-wrapper.mjs
Derek Cormier f37dd0fc96 build(bazel): create AIO example playgrounds for manual testing
After the bazel migration, AIO examples are no longer fully formed in
the source tree.
2022-11-22 13:51:16 -07:00

43 lines
1.2 KiB
JavaScript

import shelljs from 'shelljs';
import yargs from 'yargs'
import {hideBin} from 'yargs/helpers';
import {getNativeBinary as getNativeBazelBinary} from '@bazel/bazelisk';
shelljs.set('-e')
shelljs.set('-v')
/**
* Create an example playground with shared example deps and optionally linked local
* angular packages in the source tree under content/examples/example-playground. This
* is a wrapper around the equivalent bazel binary but adds the --local option to link
* local packages.
*
* Usage: node ./tools/examples/create-example-playground-wrapper.mjs <example> [options]
*
* Args:
* example: name of the example
*
* Flags:
* --local: use locally built angular packages
*/
const options = yargs(hideBin(process.argv))
.command('$0 <example>', 'Set up a playground for <example> in the source tree for manual testing')
.option('local', {default: false, type: 'boolean'})
.version(false)
.strict()
.argv;
const cmd = [
getNativeBazelBinary(),
'run',
'//aio/tools/examples:create-example-playground',
'--',
`--example=${options.example}`,
];
if (options.local) {
cmd.splice(2, 0, '--config=aio_local_deps');
}
shelljs.exec(cmd.join(' '));