@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
|
@@ -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/index.md`
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
function processDemo() {
|
|
130
|
+
const callback = function(updatedContent, outputConfig) {
|
|
131
|
+
if (fs.existsSync('./demo/index.md')) {
|
|
132
|
+
fs.readFile('./demo/index.md', 'utf8', function(err, data) {
|
|
133
|
+
formatTemplateFileContents(data, './demo/index.md');
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
console.log('ERROR: ./demo/index.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/index.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();
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aurodesignsystem-dev/auro-library",
|
|
3
|
+
"version": "0.0.0-pr187.0",
|
|
4
|
+
"description": "This repository holds shared scripts, utilities, and workflows utilized across repositories along the Auro Design System.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/AlaskaAirlines/auro-library.git"
|
|
8
|
+
},
|
|
9
|
+
"main": "index.js",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": "^20.x || ^22.x"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"generateDocs": "./bin/generateDocs.mjs"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@aurodesignsystem/eslint-config": "1.3.4",
|
|
19
|
+
"@commitlint/cli": "^18.5.0",
|
|
20
|
+
"@commitlint/config-conventional": "^18.5.0",
|
|
21
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
22
|
+
"@semantic-release/git": "^10.0.1",
|
|
23
|
+
"@semantic-release/npm": "^11.0.2",
|
|
24
|
+
"eslint": "^9.8.0",
|
|
25
|
+
"eslint-plugin-jsdoc": "^48.0.2",
|
|
26
|
+
"husky": "^8.0.3",
|
|
27
|
+
"semantic-release": "^23.0.0",
|
|
28
|
+
"vitest": "^2.1.2"
|
|
29
|
+
},
|
|
30
|
+
"release": {
|
|
31
|
+
"branches": [
|
|
32
|
+
{
|
|
33
|
+
"name": "main"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "beta",
|
|
37
|
+
"prerelease": true
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"plugins": [
|
|
41
|
+
"@semantic-release/commit-analyzer",
|
|
42
|
+
"@semantic-release/release-notes-generator",
|
|
43
|
+
[
|
|
44
|
+
"@semantic-release/changelog",
|
|
45
|
+
{
|
|
46
|
+
"changelogFile": "./CHANGELOG.md",
|
|
47
|
+
"changelogTitle": "# Semantic Release Automated Changelog"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"@semantic-release/npm",
|
|
51
|
+
[
|
|
52
|
+
"@semantic-release/git",
|
|
53
|
+
{
|
|
54
|
+
"assets": [
|
|
55
|
+
"./package.json",
|
|
56
|
+
"./CHANGELOG.md",
|
|
57
|
+
"./README.md",
|
|
58
|
+
"./docs/api.md"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"@semantic-release/github"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"prepare": "husky install",
|
|
70
|
+
"esLint": "eslint ./scripts/**/*.js",
|
|
71
|
+
"linters": "npm-run-all esLint",
|
|
72
|
+
"build:docs": "node scripts/build/generateReadme.mjs",
|
|
73
|
+
"test:vitest": "vitest --run",
|
|
74
|
+
"test:vitest:watch": "vitest",
|
|
75
|
+
"test:auro": "auro test --files 'scripts/**/*.test.js'",
|
|
76
|
+
"test:auro:watch": "auro test --watch --files 'scripts/**/*.test.js'",
|
|
77
|
+
"test": "npm-run-all test:vitest test:auro",
|
|
78
|
+
"test:watch": "npm-run-all test:vitest:watch test:auro:watch"
|
|
79
|
+
},
|
|
80
|
+
"bugs": {
|
|
81
|
+
"url": "https://github.com/AlaskaAirlines/auro-library/issues"
|
|
82
|
+
},
|
|
83
|
+
"dependencies": {
|
|
84
|
+
"@aurodesignsystem/auro-cli": "^2.5.0",
|
|
85
|
+
"@floating-ui/dom": "^1.6.11",
|
|
86
|
+
"@open-wc/testing": "^4.0.0",
|
|
87
|
+
"handlebars": "^4.7.8",
|
|
88
|
+
"markdown-magic": "^2.6.1",
|
|
89
|
+
"npm-run-all": "^4.1.5",
|
|
90
|
+
"sinon": "^20.0.0"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// ------------------------------------------------------
|
|
2
|
+
// Docs Generation
|
|
3
|
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
4
|
+
//
|
|
5
|
+
// This script will generate the docs for the component
|
|
6
|
+
// based on example HTML, markdown files, and more.
|
|
7
|
+
//
|
|
8
|
+
// The actions in this file live in:
|
|
9
|
+
// scripts/build/processors/defaultDocsProcessor.mjs
|
|
10
|
+
//
|
|
11
|
+
// This script is intended to be run AS-IS without modification.
|
|
12
|
+
// To run a different processor, please see the defaultDocsProcessor.mjs file
|
|
13
|
+
// and re-create in your repo OR add a new processor file.
|
|
14
|
+
// ------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
import {Logger} from "../utils/logger.mjs";
|
|
17
|
+
import {processDocFiles} from "./processors/defaultDocsProcessor.mjs";
|
|
18
|
+
|
|
19
|
+
processDocFiles().then(() => {
|
|
20
|
+
Logger.log('Docs processed successfully');
|
|
21
|
+
}).
|
|
22
|
+
catch((err) => {
|
|
23
|
+
Logger.error(`Error processing docs: ${err.message}`);
|
|
24
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import markdownMagic from 'markdown-magic';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
|
|
4
|
+
const dirDocs = './docs';
|
|
5
|
+
const readmeFilePath = dirDocs + '/README.md';
|
|
6
|
+
|
|
7
|
+
import AuroLibraryUtils from "../utils/auroLibraryUtils.mjs";
|
|
8
|
+
|
|
9
|
+
const auroLibraryUtils = new AuroLibraryUtils();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Compiles `./docs/README.md` -> `./README.md`
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
function processReadme() {
|
|
16
|
+
const callback = function() {
|
|
17
|
+
|
|
18
|
+
if (fs.existsSync('./README.md')) {
|
|
19
|
+
fs.readFile('./README.md', 'utf8', function(err, data) {
|
|
20
|
+
auroLibraryUtils.formatFileContents(data, './README.md');
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
console.log('ERROR: ./README.md file is missing');
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const config = {
|
|
28
|
+
matchWord: 'AURO-GENERATED-CONTENT',
|
|
29
|
+
outputDir: './'
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const markdownPath = './docs/README.md';
|
|
33
|
+
|
|
34
|
+
markdownMagic(markdownPath, config, callback);
|
|
35
|
+
|
|
36
|
+
fs.copyFileSync(readmeFilePath, './README.md');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Copy README.md template from static source
|
|
41
|
+
* */
|
|
42
|
+
|
|
43
|
+
function copyReadmeLocally() {
|
|
44
|
+
|
|
45
|
+
if (!fs.existsSync(dirDocs)){
|
|
46
|
+
fs.mkdirSync(dirDocs);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!fs.existsSync(readmeFilePath)) {
|
|
50
|
+
fs.writeFile(readmeFilePath, '', function(err) {
|
|
51
|
+
if(err) {
|
|
52
|
+
console.log('ERROR: Unable to create README.md file.', err);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
processReadme();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
copyReadmeLocally();
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import glob from 'glob';
|
|
4
|
+
import util from 'util';
|
|
5
|
+
import getTemplatedComponentCode from './prepWcaCompatibleCode.mjs';
|
|
6
|
+
|
|
7
|
+
const promisifiedGlob = util.promisify(glob);
|
|
8
|
+
|
|
9
|
+
const WAC_DIR = path.resolve(process.cwd(), './scripts/wca');
|
|
10
|
+
|
|
11
|
+
async function globPath(sources) {
|
|
12
|
+
try {
|
|
13
|
+
const fileArrays = await Promise.all(
|
|
14
|
+
sources.map(source => promisifiedGlob(source))
|
|
15
|
+
);
|
|
16
|
+
return fileArrays.flat();
|
|
17
|
+
} catch (err) {
|
|
18
|
+
console.error('Error processing glob patterns:', err);
|
|
19
|
+
throw err; // Re-throw to handle failure at caller
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function createExtendsFile(filePaths) {
|
|
24
|
+
if (!fs.existsSync(WAC_DIR)) {
|
|
25
|
+
await fs.promises.mkdir(WAC_DIR, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (const filePath of filePaths) {
|
|
29
|
+
const resolvedPath = path.resolve(process.cwd(), filePath);
|
|
30
|
+
const fileContent = await fs.promises.readFile(resolvedPath, 'utf-8',);
|
|
31
|
+
const newPath = path.resolve(WAC_DIR, `${path.basename(filePath)}`);
|
|
32
|
+
const newCode = getTemplatedComponentCode(fileContent, path.relative(WAC_DIR, filePath));
|
|
33
|
+
await fs.promises.writeFile(newPath, newCode);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function main() {
|
|
38
|
+
// files to analyze
|
|
39
|
+
const filePaths = await globPath(process.argv.slice(2));
|
|
40
|
+
await createExtendsFile(filePaths);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
main();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* eslint-disable brace-style, eqeqeq, object-property-newline, arrow-parens, array-element-newline, object-shorthand, dot-location, no-use-before-define, prefer-template, consistent-return, no-underscore-dangle, prefer-arrow-callback */
|
|
2
|
+
|
|
3
|
+
import autoprefixer from 'autoprefixer';
|
|
4
|
+
import postcss from 'postcss';
|
|
5
|
+
import comments from 'postcss-discard-comments';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import process from 'process';
|
|
9
|
+
|
|
10
|
+
const __dirname = process.cwd();
|
|
11
|
+
const directoryPath = path.join(__dirname, '/src');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default postCSS run
|
|
15
|
+
* Locates all CSS files within the directory and loop
|
|
16
|
+
* through the standardProcessor() function.
|
|
17
|
+
*/
|
|
18
|
+
fs.readdir(directoryPath, function (err, files) {
|
|
19
|
+
// handling error
|
|
20
|
+
if (err) {
|
|
21
|
+
return console.log('Unable to scan directory: ' + err); // eslint-disable-line no-console
|
|
22
|
+
}
|
|
23
|
+
// listing all files using forEach
|
|
24
|
+
files.forEach(function (file) {
|
|
25
|
+
if (file.includes(".css")) {
|
|
26
|
+
standardProcessor(file);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The standardProcessor function applies tokens for fallback selectors
|
|
33
|
+
* and completes a post cleanup.
|
|
34
|
+
* @param {string} file - The file to process.
|
|
35
|
+
*/
|
|
36
|
+
function standardProcessor(file) {
|
|
37
|
+
fs.readFile(`src/${file}`, (err, css) => {
|
|
38
|
+
postcss([autoprefixer, comments])
|
|
39
|
+
.use(comments({
|
|
40
|
+
remove: function(comment) { return comment[0] == "@"; }
|
|
41
|
+
}))
|
|
42
|
+
.process(css, { from: `src/${file}`, to: `src/${file}` })
|
|
43
|
+
.then(result => {
|
|
44
|
+
fs.writeFile(`src/${file}`, result.css, () => true);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* ALTERNATE script:
|
|
51
|
+
* The following is a static builder for rendering one
|
|
52
|
+
* CSS file at a time if that is required.
|
|
53
|
+
*/
|
|
54
|
+
// fs.readFile('src/style.css', (err, css) => {
|
|
55
|
+
// postcss([autoprefixer, comments])
|
|
56
|
+
// .use(comments({
|
|
57
|
+
// remove: function(comment) { return comment[0] == "@"; }
|
|
58
|
+
// }))
|
|
59
|
+
// .process(css, { from: 'src/style.css', to: 'src/style.css' })
|
|
60
|
+
// .then(result => {
|
|
61
|
+
// fs.writeFile('src/style.css', result.css, () => true)
|
|
62
|
+
// if ( result.map ) {
|
|
63
|
+
// fs.writeFile('src/style.map', result.map, () => true)
|
|
64
|
+
// }
|
|
65
|
+
// })
|
|
66
|
+
// });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { resolve } from 'path';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
const pjson = require(resolve(process.cwd(), 'package.json'));
|
|
10
|
+
|
|
11
|
+
console.log(chalk.hex('#f26135')(`
|
|
12
|
+
|
|
13
|
+
_______ __ __ __
|
|
14
|
+
| __|.---.-.--.--. | |--.-----.| | |.-----.
|
|
15
|
+
|__ || _ | | | | | -__|| | || _ |
|
|
16
|
+
|_______||___._|___ | |__|__|_____||__|__||_____|
|
|
17
|
+
|_____|
|
|
18
|
+
__ _______ __
|
|
19
|
+
| |_.-----. | _ |.--.--.----.-----.| |
|
|
20
|
+
| _| _ | | || | | _| _ ||__|
|
|
21
|
+
|____|_____| |___|___||_____|__| |_____||__|
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ──────────────────────────────╮
|
|
25
|
+
|
|
26
|
+
Thanks for installing the latest version
|
|
27
|
+
of `) + chalk.hex('#ffd200').bold(`${pjson.name} v${pjson.version}.`) + chalk.hex('#f26135')(`
|
|
28
|
+
|
|
29
|
+
╰─────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
|
|
30
|
+
`)
|
|
31
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
console.log(chalk.hex('#ffd200')(`
|
|
6
|
+
|
|
7
|
+
╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ──────────────────────────────╮`) + chalk.hex('#f26135')(`
|
|
8
|
+
|
|
9
|
+
Are you familiar with Auro's Definition of Done?
|
|
10
|
+
|
|
11
|
+
Please be sure to review`) + chalk.hex('#ffd200')(`
|
|
12
|
+
https://auro.alaskaair.com/definition-of-done`) + chalk.hex('#f26135')(`
|
|
13
|
+
before submitting your pull request
|
|
14
|
+
to ensure that you are compliant.`) + chalk.hex('#ffd200')(`
|
|
15
|
+
|
|
16
|
+
╰─────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
|
|
17
|
+
`));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default (code, sourcePath) => {
|
|
2
|
+
const defaultTag = (code.match(/static register\(name \= (.+)\)/) || code.match(/customElements.get\((.+?)\)/))[1];
|
|
3
|
+
const className = code.match(/export class (.+) extends/)?.[1];
|
|
4
|
+
const classDesc = code.match(/\/\*\*((.|\n)*?)(\*\n|\*\/|[@])/)?.[1] || '';
|
|
5
|
+
|
|
6
|
+
if (!defaultTag || !className) {
|
|
7
|
+
return code;
|
|
8
|
+
}
|
|
9
|
+
return `
|
|
10
|
+
import { ${className} } from '${sourcePath}';
|
|
11
|
+
|
|
12
|
+
/**${classDesc}*/
|
|
13
|
+
class ${className}WCA extends ${className} {}
|
|
14
|
+
|
|
15
|
+
if (!customElements.get(${defaultTag})) {
|
|
16
|
+
customElements.define(${defaultTag}, ${className}WCA);
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {Logger} from "../../utils/logger.mjs";
|
|
2
|
+
import {
|
|
3
|
+
fromAuroComponentRoot,
|
|
4
|
+
generateReadmeUrl,
|
|
5
|
+
processContentForFile,
|
|
6
|
+
templateFiller
|
|
7
|
+
} from "../../utils/sharedFileProcessorUtils.mjs";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Processor config object.
|
|
11
|
+
* @typedef {Object} ProcessorConfig
|
|
12
|
+
* @property {boolean} [overwriteLocalCopies=true] - The release version tag to use instead of master.
|
|
13
|
+
* @property {string} [remoteReadmeVersion="master"] - The release version tag to use instead of master.
|
|
14
|
+
* @property {string} [remoteReadmeVariant=""] - The variant string to use for the README source.
|
|
15
|
+
* (like "_esm" to make README_esm.md).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {ProcessorConfig} config - The configuration for this processor.
|
|
21
|
+
*/
|
|
22
|
+
export const defaultDocsProcessorConfig = {
|
|
23
|
+
overwriteLocalCopies: true,
|
|
24
|
+
remoteReadmeVersion: "master",
|
|
25
|
+
// eslint-disable-next-line no-warning-comments
|
|
26
|
+
// TODO: remove this variant when all components are updated to use latest auro-library
|
|
27
|
+
// AND the default README.md is updated to use the new paths
|
|
28
|
+
remoteReadmeVariant: "_updated_paths"
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {ProcessorConfig} config - The configuration for this processor.
|
|
33
|
+
* @returns {import('../utils/sharedFileProcessorUtils').FileProcessorConfig[]}
|
|
34
|
+
*/
|
|
35
|
+
export const fileConfigs = (config) => [
|
|
36
|
+
// README.md
|
|
37
|
+
{
|
|
38
|
+
identifier: 'README.md',
|
|
39
|
+
input: {
|
|
40
|
+
remoteUrl: generateReadmeUrl(config.remoteReadmeVersion, config.remoteReadmeVariant),
|
|
41
|
+
fileName: fromAuroComponentRoot(`/docTemplates/README.md`),
|
|
42
|
+
overwrite: config.overwriteLocalCopies
|
|
43
|
+
},
|
|
44
|
+
output: fromAuroComponentRoot("/README.md")
|
|
45
|
+
},
|
|
46
|
+
// index.md
|
|
47
|
+
{
|
|
48
|
+
identifier: 'index.md',
|
|
49
|
+
input: fromAuroComponentRoot("/docs/partials/index.md"),
|
|
50
|
+
output: fromAuroComponentRoot("/demo/index.md"),
|
|
51
|
+
mdMagicConfig: {
|
|
52
|
+
output: {
|
|
53
|
+
directory: fromAuroComponentRoot("/demo")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
// api.md
|
|
58
|
+
{
|
|
59
|
+
identifier: 'api.md',
|
|
60
|
+
input: fromAuroComponentRoot("/docs/partials/api.md"),
|
|
61
|
+
output: fromAuroComponentRoot("/demo/api.md"),
|
|
62
|
+
preProcessors: [templateFiller.formatApiTable],
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param {ProcessorConfig} config - The configuration for this processor.
|
|
69
|
+
* @return {Promise<void>}
|
|
70
|
+
*/
|
|
71
|
+
export async function processDocFiles(config = defaultDocsProcessorConfig) {
|
|
72
|
+
// setup
|
|
73
|
+
await templateFiller.extractNames();
|
|
74
|
+
|
|
75
|
+
for (const fileConfig of fileConfigs(config)) {
|
|
76
|
+
try {
|
|
77
|
+
// eslint-disable-next-line no-await-in-loop
|
|
78
|
+
await processContentForFile(fileConfig);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
Logger.error(`Error processing ${fileConfig.identifier}: ${err.message}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|