Created
February 24, 2023 16:30
-
-
Save chrisjrn/42677a04f6631779d2e0002d0acca624 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Dependencies and source files | |
| files( | |
| name="package-config", | |
| sources=["package.json", "yarn.lock",], | |
| dependencies=[], | |
| ) | |
| # The source files themselves | |
| files( | |
| name="js-sources", | |
| sources=["*.js",], | |
| dependencies=[], | |
| ) | |
| system_binary( | |
| name="yarn", | |
| binary_name="yarn", | |
| fingerprint=r"1\.22\.19", | |
| fingerprint_args=["--version"], | |
| fingerprint_dependencies=[_runnable(name="node", address=":node")], | |
| ) | |
| system_binary( | |
| name="node", | |
| binary_name="node", | |
| fingerprint=r"v19.0.1", | |
| fingerprint_args=["--version"], | |
| ) | |
| # Fetch the dependencies and produce a `node_modules` directory | |
| adhoc_tool( | |
| name="node-modules-pinned", | |
| runnable=":yarn", | |
| args=["install", "--immutable"], | |
| dependencies=[":package-config"], | |
| execution_dependencies=[ | |
| ":package-config", _runnable("node", ":node"), | |
| ], | |
| output_directories=["node_modules"], | |
| timeout=300, | |
| ) | |
| shell_command( | |
| name="node-modules", | |
| command="yarn install --immutable", | |
| tools=[ | |
| "yarn", | |
| "node", | |
| ], | |
| dependencies=[ | |
| ":package-config", | |
| ], | |
| outputs=["node_modules/"], | |
| timeout=300, | |
| ) | |
| # Minify the JS sources and dependencies into a single js file. | |
| shell_command( | |
| name="build-js-app", | |
| command="yarn parcel build", | |
| tools=[ | |
| "yarn", | |
| "node", | |
| ], | |
| dependencies=[":node-modules", ":js-sources",], | |
| outputs=["index.js", "index.js.map",], | |
| root_output_directory=".", | |
| ) | |
| # Run the resulting JS file | |
| run_shell_command( | |
| name="run-js-app", | |
| command="node {chroot}/index.js", | |
| execution_dependencies=[":build-js-app",], | |
| ) | |
| # Demonstrate using the JS file as an input to an artifact | |
| archive( | |
| name="packaged-js", | |
| format="tar", | |
| description="Package containing `index.js` file", | |
| files=[":build-js-app",], | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment