Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding jq examples #76

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The following security constraints are highly recommended to secure the import-m

If you are not comfortable with running the import-map-deployer at all, you do not have to. Instead, give read/write access to your CI runners for modifying your import map file. Perform all import map modifications the import map inside of your CI process.

If you do this, decide whether you care about the deployment race condition scenario described in the [Why does this exist?](#why-does-this-exist) section. If you are willing to live with that unlikely race condition, see [this example](/examples/ci-for-javascript-repo/gitlab-aws-no-import-map-deployer) for some example CI commands.
If you do this, decide whether you care about the deployment race condition scenario described in the [Why does this exist?](#why-does-this-exist) section. If you are willing to live with that unlikely race condition, see these examples ([1](/examples/ci-for-javascript-repo/gitlab-aws-no-import-map-deployer), [2](/examples/bash-aws-no-import-map-deployer)) for some example CI commands.

If you do want to address the deployment race condition without using import-map-deployer, we'd love to hear what you come up with. Consider leaving a PR to these docs that explain what you did!

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o ./jq
chmod a+x ./jq

# Download the live import map
aws s3 cp s3://bucket-name/live.importmap live.importmap || echo '{"imports": {}}' > live.importmap

echo "Import Map before deployment:"
cat ./live.importmap

cat ./shared.importmap
sed -i 's/$ASSET_CDN/https:\/\/cdn.example.com/g' shared.importmap
echo "Import Map being merged in:"
cat ./shared.importmap

# Modify the import map
./jq -s '.[0] * .[1]' live.importmap shared.importmap > new.importmap

echo "Import Map after deployment"
cat new.importmap

# Upload
aws s3 cp --content-type application/importmap+json --cache-control 'public, must-revalidate, max-age=10;' live.importmap s3://bucket-name/live.importmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o ./jq
chmod a+x ./jq

# Download the import map
aws s3 cp s3://bucket-name/live.importmap live.importmap || echo '{"imports": {}}' > live.importmap

echo "Import Map before deployment:"
cat ./live.importmap

newUrl=https://cdn.example.com/microfrontend-name/$version/js/app.js

# Modify the import map
cat ./live.importmap | ./jq --arg newUrl "$newUrl" '.imports["@fc/styleguide"] = $newUrl' > new.importmap

echo "Import Map after deployment"
cat new.importmap

# Upload
aws s3 cp --content-type application/importmap+json --cache-control 'public, must-revalidate, max-age=10;' live.importmap s3://bucket-name/live.importmap