2022-09-29 18:24:32 +00:00
|
|
|
import shelljs from 'shelljs';
|
|
|
|
|
import yargs from 'yargs'
|
|
|
|
|
import {hideBin} from 'yargs/helpers';
|
|
|
|
|
import {getNativeBinary as getNativeBazelBinary} from '@bazel/bazelisk';
|
2022-10-20 19:41:30 +00:00
|
|
|
import {getNativeBinary as getNativeIBazelBinary} from '@bazel/ibazel';
|
2022-09-29 18:24:32 +00:00
|
|
|
|
|
|
|
|
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
|
2022-10-20 19:41:30 +00:00
|
|
|
* --watch: update playground when source files change
|
2022-09-29 18:24:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
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'})
|
2022-10-20 19:41:30 +00:00
|
|
|
.option('watch', {default: false, type: 'boolean'})
|
2022-09-29 18:24:32 +00:00
|
|
|
.version(false)
|
|
|
|
|
.strict()
|
|
|
|
|
.argv;
|
|
|
|
|
|
|
|
|
|
const cmd = [
|
2022-10-20 19:41:30 +00:00
|
|
|
options.watch ? getNativeIBazelBinary() : getNativeBazelBinary(),
|
2022-09-29 18:24:32 +00:00
|
|
|
'run',
|
2022-10-20 19:41:30 +00:00
|
|
|
`//aio/tools/examples:create-example-playground-${options.example}`,
|
2022-09-29 18:24:32 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (options.local) {
|
|
|
|
|
cmd.splice(2, 0, '--config=aio_local_deps');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shelljs.exec(cmd.join(' '));
|