2.6.0 • Published 13 days ago

@aurodesignsystem/auro-library v2.6.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
13 days ago

Auro-Library

This repository holds shared scripts, utilities, and workflows utilized across repositories along the Auro Design System.

Scripts

Publish Surge Demo

This is an automated workflow that utilizes GitHub Actions to generate surge demos. Upon making any change to a PR a comment will be added or updated on the PR with a link to the demo similar to the following:

Surge demo deployment succeeded! 🚀🚀🚀

[Auro Web Component Generator](https://surge.sh/)

This workflow utilizes the file ./scripts/config/useBundles.js to update the demo HTML files to use the bundled versions of components so that they can be supported staticly in surge.

In order to add this functionality to an auro component you just need to add the following snippet into the publishDemo.yml file in the ./.github/workflows directory.

name: Deploy Demo

on:
  pull_request:
    branches: [ main ]

jobs:
  call-publish-demo-workflow:
    uses: AlaskaAirlines/auro-library/.github/workflows/publishDemo.yml@main
    secrets:
      SURGE_TOKEN: ${{secrets.AURO_SURGE_TOKEN}}

Note: This will only work properly in components located in the "AlaskaAirlines" organization due to a dependency on the org-wide Actions secret AURO_SURGE_TOKEN.

Afterwards you will want to make sure to update the script tags you want replaced with bundles in your ./demo/*.html files with the data-demo-scripts="true" attribute.

--    <script type="module" src="../index.js"></script>
++    <script type="module" src="../index.js" data-demo-script="true"></script>

Note: If you fail to do this, the components will fail to register in your demo.

Surge Demo Teardown

This workflow works to automatically delete and clear any surge demos that have been active for more than 2+ months. Surge in theory allows us to have an infinite amount of active pages but by clearing unused and stale demos we can keep our Surge account more organized in the future.

Note: This workflow executes on a monthly cronjob on the first of each month.

In order to clear all our surge projects we rely on this GitHub Action to handle the deletion logic.

Dependency Tag Versioning

This is a two part utility for the purpose of generating a custom string for dependency component tag naming. This is important to prevent version conflicts when multiple versions of a given Auro component may be loaded on a single page.

Note: The example configuration used below in all code samples assumes auro-dropdown is the dependency component. Substitute any Auro component in the example code as needed.

Part 1: The Build

Configuration
  1. Create a new file ./scripts/version.js with the following content:
const versionWriter = require("./versionWriter"); // need to update this with the right path when used from node_modules

versionWriter.writeDepVersionFile('@aurodesignsystem/auro-dropdown'); // duplicate this line for each Auro dependency.
  1. Add the following script to the component package.json file:
"build:version": "node scripts/version.js"
  1. The build:version script in package.json should be added as the first step of the build script.
"build": "npm-run-all build:version ... etc.",
Execution

Once configuration is complete, execute npm run build. This must be done once before npm run dev when developing locally. When Auro dependencies are initially installed or updated to new versions then npm run build:version or a complete npm run build must be executed.

Upon execution of build:version, for each Auro dependency defined in the ./scripts/version.js file, a new JS file will be created that contains the installed version of the dependency.

For example, following these steps: 1. Run npm i @aurodesignsystem/auro-dropdown@1.0.0 2. add the following to the ./scripts/version.js script file:

versionWriter.writeDepVersionFile('@aurodesignsystem/auro-dropdown');
  1. Run npm run build

Will result in:

  • A new file created: ./src/dropdownVersion.js
  • File content will export the version of the component installed. In this case: export default '1.0.0'

Part 2: The Runtime

Configuration

In the main component JS file located in the ./src directory add the following:

import { AuroDependencyVersioning } from "../scripts/dependencyTagVersioning.mjs";
import { AuroDropdown } from '@aurodesignsystem/auro-dropdown/src/auro-dropdown.js';
import dropdownVersion from './dropdownVersion';

In the components constructor add the following:

const versioning = new AuroDependencyVersioning();
this.dropdownTag = versioning.generateTag('auro-dropdown', dropdownVersion, AuroDropdown);

In the component properties add the following:

/**
 * @private
 */
dropdownTag: { type: Object }
Usage

The new dynamically named version of auro-dropdown may now be used in your component template as follows:

render() {
  return html`
    <div>
      <${this.dropdownTag}></${this.dropdownTag}>
    </div>
  `;
}

When the component is rendered during runtime the DOM will now show up as follows:

<div>
  <auro-dropdown_1_0_0></auro-dropdown_1_0_0>
</div>

Note: the numbers attached in the tag name will match the version of the dependency that was installed.

Accessing the dynamically named element with JS

The dynamic component is accessible using a the following string in a JS query selector:

this.dropdownTag._$litStatic$
firstUpdated() {
  this.dropdown = this.shadowRoot.querySelector(this.dropdownTag._$litStatic$);
};

Sync All Templates

How to Run the syncAllTemplates.mjs Script

To run the syncAllTemplates.mjs script, you will need to add a new node script into the linked component and point that to the syncAllTemplates.mjs file. You can individually run the workflow configurations by pointing to the syncAllTemplates.mjs file and adding a --github parameter after the path. The same can be done for the linter configurations by adding a --linters parameter.

Example Calls

// Default
"syncTemplates": "./node_modules/@aurodesignsystem/auro-library/scripts/config/syncAllTemplates.mjs"
// Only sync github workflow templates
"syncTemplates": "./node_modules/@aurodesignsystem/auro-library/scripts/config/syncAllTemplates.mjs --github"
// Only sync linter configuration templates
"syncTemplates": "./node_modules/@aurodesignsystem/auro-library/scripts/config/syncAllTemplates.mjs --linters"
2.6.0

13 days ago

2.5.0

3 months ago

2.5.1

3 months ago

2.4.5

3 months ago

2.4.4

3 months ago

2.4.7

3 months ago

2.4.6

3 months ago

2.4.3

3 months ago

2.4.2

3 months ago

2.4.1

3 months ago

2.4.0

4 months ago

2.3.0

4 months ago

2.3.2

4 months ago

2.3.1

4 months ago

2.2.7

4 months ago

2.2.6

4 months ago

2.2.5

4 months ago

2.2.3

4 months ago

2.2.4

4 months ago

2.2.1

4 months ago

2.2.0

4 months ago

2.2.2

4 months ago

2.1.1

5 months ago

2.1.0

5 months ago

2.0.0

7 months ago

1.1.0

9 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago