@aurodesignsystem/auro-library 2.5.1 → 2.6.1
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/pre-commit +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +64 -59
- package/package.json +14 -6
- package/scripts/build/generateDocs.mjs +89 -19
- package/scripts/build/postCss.mjs +57 -12
- package/scripts/build/pre-commit.mjs +3 -3
- package/scripts/build/prepExampleFiles.mjs +23 -0
- package/scripts/build/staticStyles-template.js +2 -0
- package/scripts/build/versionWriter.js +2 -0
- package/scripts/utils/auroLibraryUtils.mjs +8 -10
- package/scripts/utils/runtimeUtils.mjs +28 -0
package/.husky/pre-commit
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Semantic Release Automated Changelog
|
|
2
2
|
|
|
3
|
+
## [2.6.1](https://github.com/AlaskaAirlines/auro-library/compare/v2.6.0...v2.6.1) (2024-08-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Performance Improvements
|
|
7
|
+
|
|
8
|
+
* cleanup and update existing build scripts ([b6d5d95](https://github.com/AlaskaAirlines/auro-library/commit/b6d5d952c8e0ce8c7636057e612ae821f5e85079))
|
|
9
|
+
|
|
10
|
+
# [2.6.0](https://github.com/AlaskaAirlines/auro-library/compare/v2.5.1...v2.6.0) (2024-04-29)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **tagname:** add new functions for handling custom named components. [#51](https://github.com/AlaskaAirlines/auro-library/issues/51) ([1c7addc](https://github.com/AlaskaAirlines/auro-library/commit/1c7addcb9c637bdf043470e04626b9b4328ed6b6))
|
|
16
|
+
|
|
3
17
|
## [2.5.1](https://github.com/AlaskaAirlines/auro-library/compare/v2.5.0...v2.5.1) (2024-02-07)
|
|
4
18
|
|
|
5
19
|
|
package/README.md
CHANGED
|
@@ -2,46 +2,77 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/description.md) -->
|
|
4
4
|
<!-- The below content is automatically added from ./../docs/partials/description.md -->
|
|
5
|
-
This repository holds shared scripts, utilities, and workflows utilized
|
|
5
|
+
This repository holds shared scripts, utilities, and workflows utilized across repositories along the Auro Design System.
|
|
6
6
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
7
7
|
|
|
8
8
|
## Scripts
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### Publish Surge Demo
|
|
11
11
|
|
|
12
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/
|
|
13
|
-
<!-- The below content is automatically added from ./../docs/partials/
|
|
14
|
-
This
|
|
15
|
-
|
|
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 ]
|
|
16
32
|
|
|
17
|
-
|
|
33
|
+
jobs:
|
|
34
|
+
call-publish-demo-workflow:
|
|
35
|
+
uses: AlaskaAirlines/auro-library/.github/workflows/publishDemo.yml@main
|
|
36
|
+
secrets:
|
|
37
|
+
SURGE_TOKEN: ${{secrets.AURO_SURGE_TOKEN}}
|
|
38
|
+
```
|
|
18
39
|
|
|
19
|
-
|
|
20
|
-
|
|
40
|
+
> 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`.
|
|
41
|
+
|
|
42
|
+
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.
|
|
43
|
+
|
|
44
|
+
```diff
|
|
45
|
+
-- <script type="module" src="../index.js"></script>
|
|
46
|
+
++ <script type="module" src="../index.js" data-demo-script="true"></script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> Note: If you fail to do this, the components will fail to register in your demo.
|
|
50
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
51
|
+
---
|
|
21
52
|
|
|
22
|
-
|
|
53
|
+
### Surge Demo Teardown
|
|
23
54
|
|
|
55
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/demoTeardown.md) -->
|
|
56
|
+
<!-- The below content is automatically added from ./../docs/partials/demoTeardown.md -->
|
|
24
57
|
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.
|
|
25
58
|
|
|
26
|
-
> Note: This workflow
|
|
59
|
+
> Note: This workflow executes on a monthly cronjob on the first of each month.
|
|
27
60
|
|
|
28
61
|
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.
|
|
29
62
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
63
|
+
---
|
|
30
64
|
|
|
31
|
-
|
|
65
|
+
### Dependency Tag Versioning
|
|
32
66
|
|
|
33
67
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/dependencyTagVersioning.md) -->
|
|
34
|
-
<!-- The below content is automatically added from ./../docs/partials/dependencyTagVersioning.md -->
|
|
35
|
-
|
|
36
|
-
## Dependency Tag Versioming
|
|
37
|
-
|
|
68
|
+
<!-- The below content is automatically added from ./../docs/partials/dependencyTagVersioning.md -->
|
|
38
69
|
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.
|
|
39
70
|
|
|
40
71
|
_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._
|
|
41
72
|
|
|
42
|
-
|
|
73
|
+
#### Part 1: The Build
|
|
43
74
|
|
|
44
|
-
|
|
75
|
+
##### Configuration
|
|
45
76
|
|
|
46
77
|
1. Create a new file `./scripts/version.js` with the following content:
|
|
47
78
|
|
|
@@ -63,7 +94,7 @@ versionWriter.writeDepVersionFile('@aurodesignsystem/auro-dropdown'); // duplica
|
|
|
63
94
|
"build": "npm-run-all build:version ... etc.",
|
|
64
95
|
```
|
|
65
96
|
|
|
66
|
-
|
|
97
|
+
##### Execution
|
|
67
98
|
|
|
68
99
|
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.
|
|
69
100
|
|
|
@@ -71,20 +102,20 @@ Upon execution of `build:version`, for each Auro dependency defined in the `./sc
|
|
|
71
102
|
|
|
72
103
|
For example, following these steps:
|
|
73
104
|
1. Run `npm i @aurodesignsystem/auro-dropdown@1.0.0`
|
|
74
|
-
|
|
105
|
+
2. add the following to the `./scripts/version.js` script file:
|
|
75
106
|
```js
|
|
76
107
|
versionWriter.writeDepVersionFile('@aurodesignsystem/auro-dropdown');
|
|
77
108
|
```
|
|
78
|
-
|
|
109
|
+
3. Run `npm run build`
|
|
79
110
|
|
|
80
111
|
Will result in:
|
|
81
112
|
- A new file created: `./src/dropdownVersion.js`
|
|
82
113
|
- File content will export the version of the component installed. In this case:
|
|
83
114
|
`export default '1.0.0'`
|
|
84
115
|
|
|
85
|
-
|
|
116
|
+
#### Part 2: The Runtime
|
|
86
117
|
|
|
87
|
-
|
|
118
|
+
##### Configuration
|
|
88
119
|
|
|
89
120
|
In the main component JS file located in the `./src` directory add the following:
|
|
90
121
|
|
|
@@ -110,7 +141,7 @@ In the component properties add the following:
|
|
|
110
141
|
dropdownTag: { type: Object }
|
|
111
142
|
```
|
|
112
143
|
|
|
113
|
-
|
|
144
|
+
##### Usage
|
|
114
145
|
|
|
115
146
|
The new dynamically named version of `auro-dropdown` may now be used in your component template as follows:
|
|
116
147
|
|
|
@@ -134,57 +165,31 @@ When the component is rendered during runtime the DOM will now show up as follow
|
|
|
134
165
|
|
|
135
166
|
_Note: the numbers attached in the tag name will match the version of the dependency that was installed._
|
|
136
167
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
The dynamic component is accessible using a the following string in a JS query selector: `this.dropdownTag._$litStatic# Auro-Library
|
|
140
|
-
|
|
141
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/description.md) -->
|
|
142
|
-
<!-- The below content is automatically added from ./../docs/partials/description.md -->
|
|
143
|
-
This repository holds shared scripts, utilities, and workflows utilized acorss repositories along the Auro Design System.
|
|
144
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
145
|
-
|
|
146
|
-
## Scripts
|
|
147
|
-
|
|
148
|
-
#### Publish Surge Demo
|
|
149
|
-
|
|
150
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/description.md) -->
|
|
151
|
-
<!-- The below content is automatically added from ./../docs/partials/description.md -->
|
|
152
|
-
This repository holds shared scripts, utilities, and workflows utilized acorss repositories along the Auro Design System.
|
|
153
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
154
|
-
|
|
155
|
-
#### Surge Demo Teardown
|
|
168
|
+
##### Accessing the dynamically named element with JS
|
|
156
169
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
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.
|
|
163
|
-
|
|
164
|
-
> Note: This workflow exectutes on a monthly cronjob on the first of each month.
|
|
170
|
+
The dynamic component is accessible using a the following string in a JS query selector:
|
|
171
|
+
```js
|
|
172
|
+
this.dropdownTag._$litStatic$
|
|
173
|
+
```
|
|
165
174
|
|
|
166
|
-
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.
|
|
167
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
168
|
-
|
|
169
|
-
#### Dependency Tag Versioning
|
|
170
|
-
|
|
171
175
|
```js
|
|
172
176
|
firstUpdated() {
|
|
173
177
|
this.dropdown = this.shadowRoot.querySelector(this.dropdownTag._$litStatic$);
|
|
174
178
|
};
|
|
175
179
|
```
|
|
176
180
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
181
|
+
---
|
|
177
182
|
|
|
178
|
-
|
|
183
|
+
### Sync All Templates
|
|
179
184
|
|
|
180
185
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/syncAllTemplates.md) -->
|
|
181
186
|
<!-- The below content is automatically added from ./../docs/partials/syncAllTemplates.md -->
|
|
182
187
|
|
|
183
|
-
|
|
188
|
+
### How to Run the `syncAllTemplates.mjs` Script
|
|
184
189
|
|
|
185
190
|
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.
|
|
186
191
|
|
|
187
|
-
|
|
192
|
+
#### Example Calls
|
|
188
193
|
|
|
189
194
|
```
|
|
190
195
|
// Default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aurodesignsystem/auro-library",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "This repository holds shared scripts, utilities, and workflows utilized across repositories along the Auro Design System.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,20 +15,26 @@
|
|
|
15
15
|
"generateDocs": "./bin/generateDocs.mjs"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@aurodesignsystem/eslint-config": "^1.3.
|
|
18
|
+
"@aurodesignsystem/eslint-config": "^1.3.2",
|
|
19
19
|
"@commitlint/cli": "^18.5.0",
|
|
20
20
|
"@commitlint/config-conventional": "^18.5.0",
|
|
21
21
|
"@semantic-release/changelog": "^6.0.3",
|
|
22
22
|
"@semantic-release/git": "^10.0.1",
|
|
23
23
|
"@semantic-release/npm": "^11.0.2",
|
|
24
|
-
"eslint": "^8.
|
|
24
|
+
"eslint": "^9.8.0",
|
|
25
25
|
"eslint-plugin-jsdoc": "^48.0.2",
|
|
26
26
|
"husky": "^8.0.3",
|
|
27
27
|
"semantic-release": "^23.0.0"
|
|
28
28
|
},
|
|
29
29
|
"release": {
|
|
30
30
|
"branches": [
|
|
31
|
-
|
|
31
|
+
{
|
|
32
|
+
"name": "main"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "beta",
|
|
36
|
+
"prerelease": true
|
|
37
|
+
}
|
|
32
38
|
],
|
|
33
39
|
"plugins": [
|
|
34
40
|
"@semantic-release/commit-analyzer",
|
|
@@ -60,13 +66,15 @@
|
|
|
60
66
|
},
|
|
61
67
|
"scripts": {
|
|
62
68
|
"prepare": "husky install",
|
|
63
|
-
"
|
|
69
|
+
"esLint": "eslint ./scripts/**/*.js",
|
|
70
|
+
"linters": "npm-run-all esLint",
|
|
64
71
|
"build:docs": "node scripts/build/generateReadme.mjs"
|
|
65
72
|
},
|
|
66
73
|
"bugs": {
|
|
67
74
|
"url": "https://github.com/AlaskaAirlines/auro-library/issues"
|
|
68
75
|
},
|
|
69
76
|
"dependencies": {
|
|
70
|
-
"markdown-magic": "^2.6.1"
|
|
77
|
+
"markdown-magic": "^2.6.1",
|
|
78
|
+
"npm-run-all": "^4.1.5"
|
|
71
79
|
}
|
|
72
80
|
}
|
|
@@ -1,33 +1,103 @@
|
|
|
1
|
+
import path from 'path';
|
|
1
2
|
import markdownMagic from 'markdown-magic';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import https from 'https';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
6
8
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const readmeTemplateUrl = 'https://raw.githubusercontent.com/AlaskaAirlines/WC-Generator/master/componentDocs/README.md';
|
|
9
|
+
const readmeTemplateUrl = 'https://raw.githubusercontent.com/AlaskaAirlines/WC-Generator/master/componentDocs/README_esm.md';
|
|
10
10
|
const dirDocTemplates = './docTemplates';
|
|
11
11
|
const readmeFilePath = dirDocTemplates + '/README.md';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
|
|
14
|
+
* Extract NPM, NAMESPACE and NAME from package.json
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
function nameExtraction() {
|
|
18
|
+
let packageJson = fs.readFileSync('package.json', 'utf8', function(err, data) {
|
|
19
|
+
if (err) {
|
|
20
|
+
console.log('ERROR: Unable to read package.json file', err);
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
packageJson = JSON.parse(packageJson);
|
|
25
|
+
|
|
26
|
+
let pName = packageJson.name;
|
|
27
|
+
let pVersion = packageJson.version;
|
|
28
|
+
let pdtVersion = packageJson.peerDependencies['\@aurodesignsystem/design-tokens'].substring(1)
|
|
29
|
+
let wcssVersion = packageJson.peerDependencies['\@aurodesignsystem/webcorestylesheets'].substring(1)
|
|
30
|
+
|
|
31
|
+
let npmStart = pName.indexOf('@');
|
|
32
|
+
let namespaceStart = pName.indexOf('/');
|
|
33
|
+
let nameStart = pName.indexOf('-');
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
'npm': pName.substring(npmStart, namespaceStart),
|
|
37
|
+
'namespace': pName.substring(namespaceStart + 1, nameStart),
|
|
38
|
+
'namespaceCap': pName.substring(namespaceStart + 1)[0].toUpperCase() + pName.substring(namespaceStart + 2, nameStart),
|
|
39
|
+
'name': pName.substring(nameStart + 1),
|
|
40
|
+
'nameCap': pName.substring(nameStart + 1)[0].toUpperCase() + pName.substring(nameStart + 2),
|
|
41
|
+
'version': pVersion,
|
|
42
|
+
'tokensVersion': pdtVersion,
|
|
43
|
+
'wcssVersion': wcssVersion
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Replace all instances of [npm], [name], [Name], [namespace] and [Namespace] accordingly
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
function formatTemplateFileContents(content, destination) {
|
|
52
|
+
let nameExtractionData = nameExtraction();
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Replace placeholder strings
|
|
56
|
+
*/
|
|
57
|
+
const placeholders = {
|
|
58
|
+
'[npm]': 'npm',
|
|
59
|
+
'[name](?!\\()': 'name',
|
|
60
|
+
'[Name](?!\\()': 'nameCap',
|
|
61
|
+
'[namespace]': 'namespace',
|
|
62
|
+
'[Namespace]': 'namespaceCap',
|
|
63
|
+
'[Version]': 'version',
|
|
64
|
+
'[dtVersion]': 'tokensVersion',
|
|
65
|
+
'[wcssVersion]': 'wcssVersion'
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
let result = Object.entries(placeholders).reduce((acc, [key, value]) =>
|
|
69
|
+
acc.replace(new RegExp(key, 'g'), nameExtractionData[value]), content);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Cleanup line breaks
|
|
15
73
|
*/
|
|
74
|
+
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.
|
|
75
|
+
result = result.replace(/>(\r\n|\r|\n){2,}/g, '>\r\n'); // Remove empty lines directly after a closing html tag.
|
|
76
|
+
result = result.replace(/>(\r\n|\r|\n)```/g, '>\r\n\r\n```'); // Ensure an empty line before code samples.
|
|
77
|
+
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.
|
|
78
|
+
result = result.replace(/([^(\r\n|\r|\n)])(\r?\n|\r(?!\n))+#/g, "$1\r\n\r\n#"); // Ensure empty line before header sections.
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Write the result to the destination file
|
|
82
|
+
*/
|
|
83
|
+
fs.writeFileSync(destination, result, { encoding: 'utf8'});
|
|
84
|
+
}
|
|
85
|
+
|
|
16
86
|
function formatApiTableContents(content, destination) {
|
|
17
|
-
const nameExtractionData =
|
|
87
|
+
const nameExtractionData = nameExtraction();
|
|
18
88
|
const wcName = nameExtractionData.namespace + '-' + nameExtractionData.name;
|
|
19
89
|
|
|
20
90
|
let result = content;
|
|
21
91
|
|
|
22
92
|
result = result
|
|
23
|
-
.replace(/\r\n|\r|\n####\s`([a-zA-Z]*)`/g, `\r\n#### <a name="$1"></a>\`$1\`<a href="
|
|
93
|
+
.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>`)
|
|
24
94
|
.replace(/\r\n|\r|\n\|\s`([a-zA-Z]*)`/g, '\r\n| [$1](#$1)')
|
|
25
95
|
.replace(/\| \[\]\(#\)/g, "");
|
|
26
96
|
|
|
27
97
|
fs.writeFileSync(destination, result, { encoding: 'utf8'});
|
|
28
98
|
|
|
29
99
|
fs.readFile('./demo/api.md', 'utf8', function(err, data) {
|
|
30
|
-
|
|
100
|
+
formatTemplateFileContents(data, './demo/api.md');
|
|
31
101
|
});
|
|
32
102
|
}
|
|
33
103
|
|
|
@@ -36,11 +106,11 @@ function formatApiTableContents(content, destination) {
|
|
|
36
106
|
*/
|
|
37
107
|
|
|
38
108
|
function processReadme() {
|
|
39
|
-
const callback = function() {
|
|
109
|
+
const callback = function(updatedContent, outputConfig) {
|
|
40
110
|
|
|
41
111
|
if (fs.existsSync('./README.md')) {
|
|
42
112
|
fs.readFile('./README.md', 'utf8', function(err, data) {
|
|
43
|
-
|
|
113
|
+
formatTemplateFileContents(data, './README.md');
|
|
44
114
|
});
|
|
45
115
|
} else {
|
|
46
116
|
console.log('ERROR: ./README.md file is missing');
|
|
@@ -52,20 +122,20 @@ function processReadme() {
|
|
|
52
122
|
outputDir: './'
|
|
53
123
|
};
|
|
54
124
|
|
|
55
|
-
const markdownPath = '
|
|
125
|
+
const markdownPath = path.join(__dirname, '../docTemplates/README.md');
|
|
56
126
|
|
|
57
127
|
markdownMagic(markdownPath, config, callback);
|
|
58
128
|
}
|
|
59
129
|
|
|
60
130
|
/**
|
|
61
|
-
* Compiles `./docTemplates/
|
|
131
|
+
* Compiles `./docTemplates/index.md` -> `./demo/index.md`
|
|
62
132
|
*/
|
|
63
133
|
|
|
64
134
|
function processDemo() {
|
|
65
|
-
const callback = function() {
|
|
135
|
+
const callback = function(updatedContent, outputConfig) {
|
|
66
136
|
if (fs.existsSync('./demo/index.md')) {
|
|
67
137
|
fs.readFile('./demo/index.md', 'utf8', function(err, data) {
|
|
68
|
-
|
|
138
|
+
formatTemplateFileContents(data, './demo/index.md');
|
|
69
139
|
});
|
|
70
140
|
} else {
|
|
71
141
|
console.log('ERROR: ./demo/index.md file is missing');
|
|
@@ -77,7 +147,7 @@ function processDemo() {
|
|
|
77
147
|
outputDir: './demo'
|
|
78
148
|
};
|
|
79
149
|
|
|
80
|
-
const markdownPath = '
|
|
150
|
+
const markdownPath = path.join(__dirname, '../docs/partials/index.md');
|
|
81
151
|
|
|
82
152
|
markdownMagic(markdownPath, configDemo, callback);
|
|
83
153
|
}
|
|
@@ -87,7 +157,7 @@ function processDemo() {
|
|
|
87
157
|
*/
|
|
88
158
|
|
|
89
159
|
function processApiExamples() {
|
|
90
|
-
const callback = function() {
|
|
160
|
+
const callback = function(updatedContent, outputConfig) {
|
|
91
161
|
if (fs.existsSync('./demo/api.md')) {
|
|
92
162
|
fs.readFile('./demo/api.md', 'utf8', function(err, data) {
|
|
93
163
|
formatApiTableContents(data, './demo/api.md');
|
|
@@ -102,7 +172,7 @@ function processApiExamples() {
|
|
|
102
172
|
outputDir: './demo'
|
|
103
173
|
};
|
|
104
174
|
|
|
105
|
-
const markdownPath = '
|
|
175
|
+
const markdownPath = path.join(__dirname, '../docs/partials/api.md');
|
|
106
176
|
|
|
107
177
|
markdownMagic(markdownPath, config, callback);
|
|
108
178
|
}
|
|
@@ -1,18 +1,63 @@
|
|
|
1
1
|
import autoprefixer from 'autoprefixer';
|
|
2
2
|
import postcss from 'postcss';
|
|
3
3
|
import comments from 'postcss-discard-comments';
|
|
4
|
+
import path from 'path';
|
|
4
5
|
import fs from 'fs';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
const __dirname = new URL('.', import.meta.url).pathname;
|
|
8
|
+
const directoryPath = path.join(__dirname, '../src');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Default postCSS run
|
|
12
|
+
* Locates all CSS files within the directory and loop
|
|
13
|
+
* through the standardProcessor() function.
|
|
14
|
+
*/
|
|
15
|
+
fs.readdir(directoryPath, function (err, files) {
|
|
16
|
+
//handling error
|
|
17
|
+
if (err) {
|
|
18
|
+
return console.log('Unable to scan directory: ' + err);
|
|
19
|
+
}
|
|
20
|
+
//listing all files using forEach
|
|
21
|
+
files.forEach(function (file) {
|
|
22
|
+
if (file.includes(".css")) {
|
|
23
|
+
standardProcessor(file);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
18
26
|
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The standardProcessor function applies tokens for fallback selectors
|
|
30
|
+
* and completes a post cleanup.
|
|
31
|
+
* @param {string} file
|
|
32
|
+
*/
|
|
33
|
+
function standardProcessor(file) {
|
|
34
|
+
fs.readFile(`src/${file}`, (err, css) => {
|
|
35
|
+
postcss([autoprefixer, comments])
|
|
36
|
+
.use(comments({
|
|
37
|
+
remove: function(comment) { return comment[0] == "@"; }
|
|
38
|
+
}))
|
|
39
|
+
.process(css, { from: `src/${file}`, to: `src/${file}` })
|
|
40
|
+
.then(result => {
|
|
41
|
+
fs.writeFile(`src/${file}`, result.css, () => true)
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* ALTERNATE script:
|
|
48
|
+
* The following is a static builder for rendering one
|
|
49
|
+
* CSS file at a time if that is required.
|
|
50
|
+
*/
|
|
51
|
+
// fs.readFile('src/style.css', (err, css) => {
|
|
52
|
+
// postcss([autoprefixer, comments])
|
|
53
|
+
// .use(comments({
|
|
54
|
+
// remove: function(comment) { return comment[0] == "@"; }
|
|
55
|
+
// }))
|
|
56
|
+
// .process(css, { from: 'src/style.css', to: 'src/style.css' })
|
|
57
|
+
// .then(result => {
|
|
58
|
+
// fs.writeFile('src/style.css', result.css, () => true)
|
|
59
|
+
// if ( result.map ) {
|
|
60
|
+
// fs.writeFile('src/style.map', result.map, () => true)
|
|
61
|
+
// }
|
|
62
|
+
// })
|
|
63
|
+
// });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
2
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
+
|
|
4
5
|
console.log(chalk.hex('#ffd200')(`
|
|
5
6
|
|
|
6
7
|
╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ──────────────────────────────╮`) + chalk.hex('#f26135')(`
|
|
@@ -13,5 +14,4 @@ console.log(chalk.hex('#ffd200')(`
|
|
|
13
14
|
to ensure that you are compliant.`) + chalk.hex('#ffd200')(`
|
|
14
15
|
|
|
15
16
|
╰─────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
|
|
16
|
-
`)
|
|
17
|
-
);
|
|
17
|
+
`));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
function removeExport(path, type) {
|
|
4
|
+
fs.readFile(path, type, (err, data) => {
|
|
5
|
+
if (err) {
|
|
6
|
+
throw err;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const exportPos = data.indexOf('export');
|
|
10
|
+
const exampleScript = data.substring(0, exportPos);
|
|
11
|
+
const writer = fs.createWriteStream(path);
|
|
12
|
+
writer.write(exampleScript, (writeErr) => {
|
|
13
|
+
if (writeErr) {
|
|
14
|
+
throw writeErr;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
writer.end();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
removeExport('./demo/index.min.js', 'utf8');
|
|
23
|
+
removeExport('./demo/api.min.js', 'utf8');
|
|
@@ -119,32 +119,30 @@ export default class AuroLibraryUtils {
|
|
|
119
119
|
* @returns {Object} result - Object containing data from package.json.
|
|
120
120
|
*/
|
|
121
121
|
nameExtraction() {
|
|
122
|
-
|
|
122
|
+
let packageJson = fs.readFileSync('package.json', 'utf8', function(err) {
|
|
123
123
|
if (err) {
|
|
124
124
|
console.log('ERROR: Unable to read package.json file', err);
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
packageJson = JSON.parse(packageJson);
|
|
129
|
+
|
|
130
|
+
const pName = packageJson.name;
|
|
129
131
|
|
|
130
132
|
const npmStart = pName.indexOf('@');
|
|
131
133
|
const namespaceStart = pName.indexOf('/');
|
|
132
134
|
const nameStart = pName.indexOf('-');
|
|
133
135
|
|
|
134
|
-
|
|
135
|
-
'abstractNodeVersion':
|
|
136
|
-
'branchName':
|
|
136
|
+
return {
|
|
137
|
+
'abstractNodeVersion': packageJson.engines.node.substring(2),
|
|
138
|
+
'branchName': packageJson.release.branch,
|
|
137
139
|
'npm': pName.substring(npmStart, namespaceStart),
|
|
138
140
|
'namespace': pName.substring(namespaceStart + 1, nameStart),
|
|
139
141
|
'namespaceCap': pName.substring(namespaceStart + 1)[0].toUpperCase() + pName.substring(namespaceStart + 2, nameStart),
|
|
140
142
|
'name': pName.substring(nameStart + 1),
|
|
141
143
|
'nameCap': pName.substring(nameStart + 1)[0].toUpperCase() + pName.substring(nameStart + 2),
|
|
142
|
-
'version':
|
|
143
|
-
'tokensVersion': pdtVersion,
|
|
144
|
-
'wcssVersion': wcssVersion
|
|
144
|
+
'version': packageJson.version
|
|
145
145
|
};
|
|
146
|
-
|
|
147
|
-
return result;
|
|
148
146
|
}
|
|
149
147
|
|
|
150
148
|
/**
|
|
@@ -25,5 +25,33 @@ export default class AuroLibraryRuntimeUtils {
|
|
|
25
25
|
return __Closest(base);
|
|
26
26
|
}
|
|
27
27
|
/* eslint-enable jsdoc/require-param */
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* If the element passed is registered with a different tag name than what is passed in, the tag name is added as an attribute to the element.
|
|
31
|
+
* @param {Object} elem - The element to check.
|
|
32
|
+
* @param {String} tagName - The name of the Auro component to check for or add as an attribute.
|
|
33
|
+
* @returns {void}
|
|
34
|
+
*/
|
|
35
|
+
handleComponentTagRename(elem, tagName) {
|
|
36
|
+
const tag = tagName.toLowerCase();
|
|
37
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
38
|
+
|
|
39
|
+
if (elemTag !== tag) {
|
|
40
|
+
elem.setAttribute(tag, true);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Validates if an element is a specific Auro component.
|
|
46
|
+
* @param {Object} elem - The element to validate.
|
|
47
|
+
* @param {String} tagName - The name of the Auro component to check against.
|
|
48
|
+
* @returns {Boolean} - Returns true if the element is the specified Auro component.
|
|
49
|
+
*/
|
|
50
|
+
elementMatch(elem, tagName) {
|
|
51
|
+
const tag = tagName.toLowerCase();
|
|
52
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
53
|
+
|
|
54
|
+
return elemTag === tag || elem.hasAttribute(tag);
|
|
55
|
+
}
|
|
28
56
|
}
|
|
29
57
|
|