@aurodesignsystem-dev/auro-library 0.0.0-pr187.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.tool-versions +1 -0
- package/CHANGELOG.md +664 -0
- package/LICENSE +201 -0
- package/README.md +235 -0
- package/bin/generateDocs.mjs +210 -0
- package/bin/generateDocs_index.mjs +210 -0
- package/package.json +92 -0
- package/scripts/build/generateDocs.mjs +24 -0
- package/scripts/build/generateReadme.mjs +60 -0
- package/scripts/build/generateWcaComponent.mjs +43 -0
- package/scripts/build/postCss.mjs +66 -0
- package/scripts/build/postinstall.mjs +31 -0
- package/scripts/build/pre-commit.mjs +17 -0
- package/scripts/build/prepWcaCompatibleCode.mjs +19 -0
- package/scripts/build/processors/defaultDocsProcessor.mjs +83 -0
- package/scripts/build/processors/defaultDotGithubSync.mjs +83 -0
- package/scripts/build/staticStyles-template.js +2 -0
- package/scripts/build/syncGithubFiles.mjs +25 -0
- package/scripts/build/versionWriter.js +26 -0
- package/scripts/runtime/FocusTrap/FocusTrap.mjs +194 -0
- package/scripts/runtime/FocusTrap/index.mjs +1 -0
- package/scripts/runtime/FocusTrap/test/FocusTrap.test.js +168 -0
- package/scripts/runtime/Focusables/Focusables.mjs +157 -0
- package/scripts/runtime/Focusables/index.mjs +1 -0
- package/scripts/runtime/Focusables/test/Focusables.test.js +165 -0
- package/scripts/runtime/dateUtilities/baseDateUtilities.mjs +58 -0
- package/scripts/runtime/dateUtilities/dateConstraints.mjs +11 -0
- package/scripts/runtime/dateUtilities/dateFormatter.mjs +104 -0
- package/scripts/runtime/dateUtilities/dateUtilities.mjs +218 -0
- package/scripts/runtime/dateUtilities/index.mjs +26 -0
- package/scripts/runtime/dependencyTagVersioning.mjs +42 -0
- package/scripts/runtime/floatingUI.mjs +646 -0
- package/scripts/test-plugin/iterateWithA11Check.mjs +82 -0
- package/scripts/utils/auroFileHandler.mjs +70 -0
- package/scripts/utils/auroLibraryUtils.mjs +206 -0
- package/scripts/utils/auroTemplateFiller.mjs +178 -0
- package/scripts/utils/logger.mjs +73 -0
- package/scripts/utils/runtimeUtils.mjs +70 -0
- package/scripts/utils/sharedFileProcessorUtils.mjs +270 -0
- package/shellScripts/README.md +58 -0
- package/shellScripts/automation.sh +104 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Auro-Library
|
|
2
|
+
|
|
3
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/description.md) -->
|
|
4
|
+
<!-- The below content is automatically added from ./../docs/partials/description.md -->
|
|
5
|
+
This repository holds shared scripts, utilities, and workflows utilized across repositories along the Auro Design System.
|
|
6
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
7
|
+
|
|
8
|
+
## Scripts
|
|
9
|
+
|
|
10
|
+
### Publish Surge Demo
|
|
11
|
+
|
|
12
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/publishDemo.md) -->
|
|
13
|
+
<!-- The below content is automatically added from ./../docs/partials/publishDemo.md -->
|
|
14
|
+
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:
|
|
15
|
+
|
|
16
|
+
```md
|
|
17
|
+
Surge demo deployment succeeded! 🚀🚀🚀
|
|
18
|
+
|
|
19
|
+
[Auro Web Component Generator](https://surge.sh/)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
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.
|
|
23
|
+
|
|
24
|
+
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.
|
|
25
|
+
|
|
26
|
+
```yml
|
|
27
|
+
name: Deploy Demo
|
|
28
|
+
|
|
29
|
+
on:
|
|
30
|
+
pull_request:
|
|
31
|
+
branches: [ main ]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
jobs:
|
|
35
|
+
call-publish-demo-workflow:
|
|
36
|
+
uses: AlaskaAirlines/auro-library/.github/workflows/publishDemo.yml@main
|
|
37
|
+
secrets:
|
|
38
|
+
SURGE_TOKEN: ${{secrets.AURO_SURGE_TOKEN}}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
> 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`.
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
```diff
|
|
46
|
+
-- <script type="module" src="../index.js"></script>
|
|
47
|
+
++ <script type="module" src="../index.js" data-demo-script="true"></script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
> Note: If you fail to do this, the components will fail to register in your demo.
|
|
51
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### Surge Demo Teardown
|
|
56
|
+
|
|
57
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/demoTeardown.md) -->
|
|
58
|
+
<!-- The below content is automatically added from ./../docs/partials/demoTeardown.md -->
|
|
59
|
+
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.
|
|
60
|
+
|
|
61
|
+
> Note: This workflow executes on a monthly cronjob on the first of each month.
|
|
62
|
+
|
|
63
|
+
In order to clear all our surge projects we rely on [this GitHub Action](https://github.com/marketplace/actions/surge-sh-teardown) to handle the deletion logic.
|
|
64
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
### Dependency Tag Versioning
|
|
69
|
+
|
|
70
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/dependencyTagVersioning.md) -->
|
|
71
|
+
<!-- The below content is automatically added from ./../docs/partials/dependencyTagVersioning.md -->
|
|
72
|
+
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](https://www.thinktecture.com/en/web-components/web-components-flaws/#elementor-toc__heading-anchor-0) when multiple versions of a given Auro component may be loaded on a single page.
|
|
73
|
+
|
|
74
|
+
_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._
|
|
75
|
+
|
|
76
|
+
#### Part 1: The Build
|
|
77
|
+
|
|
78
|
+
##### Configuration
|
|
79
|
+
|
|
80
|
+
1. Create a new file `./scripts/version.js` with the following content:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
const versionWriter = require("./versionWriter"); // need to update this with the right path when used from node_modules
|
|
84
|
+
|
|
85
|
+
versionWriter.writeDepVersionFile('@aurodesignsystem/auro-dropdown'); // duplicate this line for each Auro dependency.
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
2. Add the following script to the component `package.json` file:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
"build:version": "node scripts/version.js"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
3. The `build:version` script in `package.json` should be added as the first step of the `build` script.
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
"build": "npm-run-all build:version ... etc.",
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
##### Execution
|
|
101
|
+
|
|
102
|
+
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.
|
|
103
|
+
|
|
104
|
+
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.
|
|
105
|
+
|
|
106
|
+
For example, following these steps:
|
|
107
|
+
1. Run `npm i @aurodesignsystem/auro-dropdown@1.0.0`
|
|
108
|
+
2. add the following to the `./scripts/version.js` script file:
|
|
109
|
+
```js
|
|
110
|
+
versionWriter.writeDepVersionFile('@aurodesignsystem/auro-dropdown');
|
|
111
|
+
```
|
|
112
|
+
3. Run `npm run build`
|
|
113
|
+
|
|
114
|
+
Will result in:
|
|
115
|
+
- A new file created: `./src/dropdownVersion.js`
|
|
116
|
+
- File content will export the version of the component installed. In this case:
|
|
117
|
+
`export default '1.0.0'`
|
|
118
|
+
|
|
119
|
+
#### Part 2: The Runtime
|
|
120
|
+
|
|
121
|
+
##### Configuration
|
|
122
|
+
|
|
123
|
+
In the main component JS file located in the `./src` directory add the following:
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
import { AuroDependencyVersioning } from "../scripts/dependencyTagVersioning.mjs";
|
|
127
|
+
import { AuroDropdown } from '@aurodesignsystem/auro-dropdown/src/auro-dropdown.js';
|
|
128
|
+
import dropdownVersion from './dropdownVersion';
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
In the components constructor add the following:
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
const versioning = new AuroDependencyVersioning();
|
|
135
|
+
this.dropdownTag = versioning.generateTag('auro-dropdown', dropdownVersion, AuroDropdown);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
In the component properties add the following:
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
/**
|
|
142
|
+
* @private
|
|
143
|
+
*/
|
|
144
|
+
dropdownTag: { type: Object }
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
##### Usage
|
|
148
|
+
|
|
149
|
+
The new dynamically named version of `auro-dropdown` may now be used in your component template as follows:
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
render() {
|
|
153
|
+
return html`
|
|
154
|
+
<div>
|
|
155
|
+
<${this.dropdownTag}></${this.dropdownTag}>
|
|
156
|
+
</div>
|
|
157
|
+
`;
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
When the component is rendered during runtime the DOM will now show up as follows:
|
|
162
|
+
|
|
163
|
+
```html
|
|
164
|
+
<div>
|
|
165
|
+
<auro-dropdown_1_0_0></auro-dropdown_1_0_0>
|
|
166
|
+
</div>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
_Note: the numbers attached in the tag name will match the version of the dependency that was installed._
|
|
170
|
+
|
|
171
|
+
##### Accessing the dynamically named element with JS
|
|
172
|
+
|
|
173
|
+
The dynamic component is accessible using a the following string in a JS query selector:
|
|
174
|
+
```js
|
|
175
|
+
this.dropdownTag._$litStatic$
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
firstUpdated() {
|
|
180
|
+
this.dropdown = this.shadowRoot.querySelector(this.dropdownTag._$litStatic$);
|
|
181
|
+
};
|
|
182
|
+
```
|
|
183
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
### Sync All Templates
|
|
188
|
+
|
|
189
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/syncAllTemplates.md) -->
|
|
190
|
+
<!-- The below content is automatically added from ./../docs/partials/syncAllTemplates.md -->
|
|
191
|
+
### How to Run the `syncAllTemplates.mjs` Script
|
|
192
|
+
|
|
193
|
+
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.
|
|
194
|
+
|
|
195
|
+
#### Example Calls
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
// Default
|
|
199
|
+
"syncTemplates": "./node_modules/@aurodesignsystem/auro-library/scripts/config/syncAllTemplates.mjs"
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
// Only sync github workflow templates
|
|
204
|
+
"syncTemplates": "./node_modules/@aurodesignsystem/auro-library/scripts/config/syncAllTemplates.mjs --github"
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
// Only sync linter configuration templates
|
|
209
|
+
"syncTemplates": "./node_modules/@aurodesignsystem/auro-library/scripts/config/syncAllTemplates.mjs --linters"
|
|
210
|
+
```
|
|
211
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
### Prep to build api.md
|
|
217
|
+
|
|
218
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/generateWcaComponent.md) -->
|
|
219
|
+
<!-- The below content is automatically added from ./../docs/partials/generateWcaComponent.md -->
|
|
220
|
+
# How to Run the `generateWcaComponent.mjs` Script
|
|
221
|
+
|
|
222
|
+
To run the `generateWcaComponent.mjs` script, you need to provide the file paths for the components you want to process with WCA. This script should be executed only once after adding a new component to the project. Upon running the script, `.js` files will be generated in the `scripts/wca` folder.
|
|
223
|
+
|
|
224
|
+
## Example Calls
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
// Common case: 1 component in 1 project
|
|
228
|
+
"build:api:prepare": "node ./node_modules/@aurodesignsystem/auro-library/scripts/generateWcaComponent.mjs 'src/auro-flight.js'"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
// multiple components in 1 project
|
|
233
|
+
"build:api:prepare": "node ./node_modules/@aurodesignsystem/auro-library/scripts/config/syncAllTemplates.mjs 'src/auro-flight*.js'"
|
|
234
|
+
```
|
|
235
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import markdownMagic from 'markdown-magic';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import https from 'https';
|
|
5
|
+
|
|
6
|
+
const __dirname = new URL('.', import.meta.url).pathname;
|
|
7
|
+
|
|
8
|
+
const readmeTemplateUrl = 'https://raw.githubusercontent.com/AlaskaAirlines/WC-Generator/master/componentDocs/README.md';
|
|
9
|
+
const dirDocTemplates = './docTemplates';
|
|
10
|
+
const readmeFilePath = dirDocTemplates + '/README.md';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Extract NPM, NAMESPACE and NAME from package.json
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function nameExtraction() {
|
|
17
|
+
const packageJson = fs.readFileSync('package.json', 'utf8', function(err, data) {
|
|
18
|
+
if (err) {
|
|
19
|
+
console.log('ERROR: Unable to read package.json file', err);
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
let pName = JSON.parse(packageJson).name;
|
|
24
|
+
let pVersion = JSON.parse(packageJson).version;
|
|
25
|
+
let pdtVersion = JSON.parse(packageJson).peerDependencies['\@aurodesignsystem/design-tokens'].substring(1)
|
|
26
|
+
let wcssVersion = JSON.parse(packageJson).peerDependencies['\@aurodesignsystem/webcorestylesheets'].substring(1)
|
|
27
|
+
|
|
28
|
+
let npmStart = pName.indexOf('@');
|
|
29
|
+
let namespaceStart = pName.indexOf('/');
|
|
30
|
+
let nameStart = pName.indexOf('-');
|
|
31
|
+
|
|
32
|
+
let result = {
|
|
33
|
+
'npm': pName.substring(npmStart, namespaceStart),
|
|
34
|
+
'namespace': pName.substring(namespaceStart + 1, nameStart),
|
|
35
|
+
'namespaceCap': pName.substring(namespaceStart + 1)[0].toUpperCase() + pName.substring(namespaceStart + 2, nameStart),
|
|
36
|
+
'name': pName.substring(nameStart + 1),
|
|
37
|
+
'nameCap': pName.substring(nameStart + 1)[0].toUpperCase() + pName.substring(nameStart + 2),
|
|
38
|
+
'version': pVersion,
|
|
39
|
+
'tokensVersion': pdtVersion,
|
|
40
|
+
'wcssVersion': wcssVersion
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Replace all instances of [npm], [name], [Name], [namespace] and [Namespace] accordingly
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
function formatTemplateFileContents(content, destination) {
|
|
51
|
+
let nameExtractionData = nameExtraction();
|
|
52
|
+
let result = content;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Replace placeholder strings
|
|
56
|
+
*/
|
|
57
|
+
result = result.replace(/\[npm]/g, nameExtractionData.npm);
|
|
58
|
+
result = result.replace(/\[name](?!\()/g, nameExtractionData.name);
|
|
59
|
+
result = result.replace(/\[Name](?!\()/g, nameExtractionData.nameCap);
|
|
60
|
+
result = result.replace(/\[namespace]/g, nameExtractionData.namespace);
|
|
61
|
+
result = result.replace(/\[Namespace]/g, nameExtractionData.namespaceCap);
|
|
62
|
+
result = result.replace(/\[Version]/g, nameExtractionData.version);
|
|
63
|
+
result = result.replace(/\[dtVersion]/g, nameExtractionData.tokensVersion);
|
|
64
|
+
result = result.replace(/\[wcssVersion]/g, nameExtractionData.wcssVersion);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Cleanup line breaks
|
|
68
|
+
*/
|
|
69
|
+
result = result.replace(/(\r\n|\r|\n)[\s]+(\r\n|\r|\n)/g, '\r\n\r\n'); // Replace lines containing only whitespace with a carriage return.
|
|
70
|
+
result = result.replace(/>(\r\n|\r|\n){2,}/g, '>\r\n'); // Remove empty lines directly after a closing html tag.
|
|
71
|
+
result = result.replace(/>(\r\n|\r|\n)```/g, '>\r\n\r\n```'); // Ensure an empty line before code samples.
|
|
72
|
+
result = result.replace(/>(\r\n|\r|\n){2,}```(\r\n|\r|\n)/g, '>\r\n```\r\n'); // Ensure no empty lines before close of code sample.
|
|
73
|
+
result = result.replace(/([^(\r\n|\r|\n)])(\r?\n|\r(?!\n))+#/g, "$1\r\n\r\n#"); // Ensure empty line before header sections.
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Write the result to the destination file
|
|
77
|
+
*/
|
|
78
|
+
fs.writeFileSync(destination, result, { encoding: 'utf8'});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function formatApiTableContents(content, destination) {
|
|
82
|
+
const nameExtractionData = nameExtraction();
|
|
83
|
+
const wcName = nameExtractionData.namespace + '-' + nameExtractionData.name;
|
|
84
|
+
|
|
85
|
+
let result = content;
|
|
86
|
+
|
|
87
|
+
result = result
|
|
88
|
+
.replace(/\r\n|\r|\n####\s`([a-zA-Z]*)`/g, `\r\n#### <a name="$1"></a>\`$1\`<a href="#" style="float: right; font-size: 1rem; font-weight: 100;">back to top</a>`)
|
|
89
|
+
.replace(/\r\n|\r|\n\|\s`([a-zA-Z]*)`/g, '\r\n| [$1](#$1)')
|
|
90
|
+
.replace(/\| \[\]\(#\)/g, "");
|
|
91
|
+
|
|
92
|
+
fs.writeFileSync(destination, result, { encoding: 'utf8'});
|
|
93
|
+
|
|
94
|
+
fs.readFile('./demo/apiExamples.md', 'utf8', function(err, data) {
|
|
95
|
+
formatTemplateFileContents(data, './demo/apiExamples.md');
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Compiles `./docTemplates/README.md` -> `./README.md`
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
function processReadme() {
|
|
104
|
+
const callback = function(updatedContent, outputConfig) {
|
|
105
|
+
|
|
106
|
+
if (fs.existsSync('./README.md')) {
|
|
107
|
+
fs.readFile('./README.md', 'utf8', function(err, data) {
|
|
108
|
+
formatTemplateFileContents(data, './README.md');
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
console.log('ERROR: ./README.md file is missing');
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const config = {
|
|
116
|
+
matchWord: 'AURO-GENERATED-CONTENT',
|
|
117
|
+
outputDir: './'
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const markdownPath = path.join(__dirname, '../docTemplates/README.md');
|
|
121
|
+
|
|
122
|
+
markdownMagic(markdownPath, config, callback);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Compiles `./docTemplates/demo.md` -> `./demo/demo.md`
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
function processDemo() {
|
|
130
|
+
const callback = function(updatedContent, outputConfig) {
|
|
131
|
+
if (fs.existsSync('./demo/demo.md')) {
|
|
132
|
+
fs.readFile('./demo/demo.md', 'utf8', function(err, data) {
|
|
133
|
+
formatTemplateFileContents(data, './demo/demo.md');
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
console.log('ERROR: ./demo/demo.md file is missing');
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const configDemo = {
|
|
141
|
+
matchWord: 'AURO-GENERATED-CONTENT',
|
|
142
|
+
outputDir: './demo'
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const markdownPath = path.join(__dirname, '../docs/partials/demo.md');
|
|
146
|
+
|
|
147
|
+
markdownMagic(markdownPath, configDemo, callback);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Compiles `./docTemplates/apiExamples.md` -> `./demo/apiExamples.md`
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
function processApiExamples() {
|
|
155
|
+
const callback = function(updatedContent, outputConfig) {
|
|
156
|
+
if (fs.existsSync('./demo/apiExamples.md')) {
|
|
157
|
+
fs.readFile('./demo/apiExamples.md', 'utf8', function(err, data) {
|
|
158
|
+
formatApiTableContents(data, './demo/apiExamples.md');
|
|
159
|
+
});
|
|
160
|
+
} else {
|
|
161
|
+
console.log('ERROR: ./demo/apiExamples.md file is missing');
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const config = {
|
|
166
|
+
matchWord: 'AURO-GENERATED-CONTENT',
|
|
167
|
+
outputDir: './demo'
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const markdownPath = path.join(__dirname, '../docs/partials/apiExamples.md');
|
|
171
|
+
|
|
172
|
+
markdownMagic(markdownPath, config, callback);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Copy README.md template from static source
|
|
177
|
+
* */
|
|
178
|
+
|
|
179
|
+
function copyReadmeLocally() {
|
|
180
|
+
|
|
181
|
+
if (!fs.existsSync(dirDocTemplates)){
|
|
182
|
+
fs.mkdirSync(dirDocTemplates);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (!fs.existsSync(readmeFilePath)) {
|
|
186
|
+
fs.writeFile(readmeFilePath, '', function(err) {
|
|
187
|
+
if(err) {
|
|
188
|
+
console.log('ERROR: Unable to create README.md file.', err);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
https.get(readmeTemplateUrl, function(response) {
|
|
194
|
+
let writeTemplate = response.pipe(fs.createWriteStream(readmeFilePath));
|
|
195
|
+
|
|
196
|
+
writeTemplate.on('finish', () => {
|
|
197
|
+
processReadme();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
}).on('error', (err) => {
|
|
201
|
+
console.log('ERROR: Unable to fetch README.md file from server.', err);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Run all the actual document generation
|
|
207
|
+
*/
|
|
208
|
+
copyReadmeLocally();
|
|
209
|
+
processApiExamples();
|
|
210
|
+
processDemo();
|