@aurodesignsystem/auro-library 2.2.3 → 2.2.5
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/CHANGELOG.md +14 -0
- package/bin/generateDocs.mjs +78 -17
- package/package.json +1 -1
- package/scripts/build/postinstall.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Semantic Release Automated Changelog
|
|
2
2
|
|
|
3
|
+
## [2.2.5](https://github.com/AlaskaAirlines/auro-library/compare/v2.2.4...v2.2.5) (2024-01-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* update package location ref ([e8cdbf8](https://github.com/AlaskaAirlines/auro-library/commit/e8cdbf8114dcc1e8a9a2af0e37fdca7a5616f6be))
|
|
9
|
+
|
|
10
|
+
## [2.2.4](https://github.com/AlaskaAirlines/auro-library/compare/v2.2.3...v2.2.4) (2024-01-11)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Performance Improvements
|
|
14
|
+
|
|
15
|
+
* add script to bin dir ([80476b5](https://github.com/AlaskaAirlines/auro-library/commit/80476b5d434446c34bf9a5c22749d4541fb5d8b9))
|
|
16
|
+
|
|
3
17
|
## [2.2.3](https://github.com/AlaskaAirlines/auro-library/compare/v2.2.2...v2.2.3) (2024-01-10)
|
|
4
18
|
|
|
5
19
|
|
package/bin/generateDocs.mjs
CHANGED
|
@@ -1,20 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This version is sans dependencies
|
|
3
|
+
* Create for use with the SSR updates
|
|
4
|
+
*/
|
|
4
5
|
|
|
5
|
-
import
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import markdownMagic from 'markdown-magic';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import https from 'https';
|
|
6
10
|
|
|
7
|
-
const
|
|
11
|
+
const __dirname = new URL('.', import.meta.url).pathname;
|
|
8
12
|
|
|
9
13
|
const readmeTemplateUrl = 'https://raw.githubusercontent.com/AlaskaAirlines/WC-Generator/master/componentDocs/README.md';
|
|
10
14
|
const dirDocTemplates = './docTemplates';
|
|
11
15
|
const readmeFilePath = dirDocTemplates + '/README.md';
|
|
12
16
|
|
|
13
17
|
/**
|
|
14
|
-
|
|
18
|
+
* Extract NPM, NAMESPACE and NAME from package.json
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
function nameExtraction() {
|
|
22
|
+
const packageJson = fs.readFileSync('package.json', 'utf8', function(err, data) {
|
|
23
|
+
if (err) {
|
|
24
|
+
console.log('ERROR: Unable to read package.json file', err);
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
let pName = JSON.parse(packageJson).name;
|
|
29
|
+
|
|
30
|
+
let npmStart = pName.indexOf('@');
|
|
31
|
+
let namespaceStart = pName.indexOf('/');
|
|
32
|
+
let nameStart = pName.indexOf('-');
|
|
33
|
+
|
|
34
|
+
let result = {
|
|
35
|
+
'npm': pName.substring(npmStart, namespaceStart),
|
|
36
|
+
'namespace': pName.substring(namespaceStart + 1, nameStart),
|
|
37
|
+
'namespaceCap': pName.substring(namespaceStart + 1)[0].toUpperCase() + pName.substring(namespaceStart + 2, nameStart),
|
|
38
|
+
'name': pName.substring(nameStart + 1),
|
|
39
|
+
'nameCap': pName.substring(nameStart + 1)[0].toUpperCase() + pName.substring(nameStart + 2)
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Replace all instances of [npm], [name], [Name], [namespace] and [Namespace] accordingly
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
function formatTemplateFileContents(content, destination) {
|
|
50
|
+
let nameExtractionData = nameExtraction();
|
|
51
|
+
let result = content;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Replace placeholder strings
|
|
15
55
|
*/
|
|
56
|
+
result = result.replace(/\[npm]/g, nameExtractionData.npm);
|
|
57
|
+
result = result.replace(/\[name]/g, nameExtractionData.name);
|
|
58
|
+
result = result.replace(/\[Name]/g, nameExtractionData.nameCap);
|
|
59
|
+
result = result.replace(/\[namespace]/g, nameExtractionData.namespace);
|
|
60
|
+
result = result.replace(/\[Namespace]/g, nameExtractionData.namespaceCap);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Cleanup line breaks
|
|
64
|
+
*/
|
|
65
|
+
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.
|
|
66
|
+
result = result.replace(/>(\r\n|\r|\n){2,}/g, '>\r\n'); // Remove empty lines directly after a closing html tag.
|
|
67
|
+
result = result.replace(/>(\r\n|\r|\n)```/g, '>\r\n\r\n```'); // Ensure an empty line before code samples.
|
|
68
|
+
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.
|
|
69
|
+
result = result.replace(/([^(\r\n|\r|\n)])(\r\n|\r|\n)+#/g, "$1\r\n\r\n#"); // Ensure empty line before header sections.
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Write the result to the destination file
|
|
73
|
+
*/
|
|
74
|
+
fs.writeFileSync(destination, result, { encoding: 'utf8'});
|
|
75
|
+
}
|
|
76
|
+
|
|
16
77
|
function formatApiTableContents(content, destination) {
|
|
17
|
-
const nameExtractionData =
|
|
78
|
+
const nameExtractionData = nameExtraction();
|
|
18
79
|
const wcName = nameExtractionData.namespace + '-' + nameExtractionData.name;
|
|
19
80
|
|
|
20
81
|
let result = content;
|
|
@@ -27,7 +88,7 @@ function formatApiTableContents(content, destination) {
|
|
|
27
88
|
fs.writeFileSync(destination, result, { encoding: 'utf8'});
|
|
28
89
|
|
|
29
90
|
fs.readFile('./demo/api.md', 'utf8', function(err, data) {
|
|
30
|
-
|
|
91
|
+
formatTemplateFileContents(data, './demo/api.md');
|
|
31
92
|
});
|
|
32
93
|
}
|
|
33
94
|
|
|
@@ -36,11 +97,11 @@ function formatApiTableContents(content, destination) {
|
|
|
36
97
|
*/
|
|
37
98
|
|
|
38
99
|
function processReadme() {
|
|
39
|
-
const callback = function() {
|
|
100
|
+
const callback = function(updatedContent, outputConfig) {
|
|
40
101
|
|
|
41
102
|
if (fs.existsSync('./README.md')) {
|
|
42
103
|
fs.readFile('./README.md', 'utf8', function(err, data) {
|
|
43
|
-
|
|
104
|
+
formatTemplateFileContents(data, './README.md');
|
|
44
105
|
});
|
|
45
106
|
} else {
|
|
46
107
|
console.log('ERROR: ./README.md file is missing');
|
|
@@ -52,7 +113,7 @@ function processReadme() {
|
|
|
52
113
|
outputDir: './'
|
|
53
114
|
};
|
|
54
115
|
|
|
55
|
-
const markdownPath = '
|
|
116
|
+
const markdownPath = path.join(__dirname, '../docTemplates/README.md');
|
|
56
117
|
|
|
57
118
|
markdownMagic(markdownPath, config, callback);
|
|
58
119
|
}
|
|
@@ -62,10 +123,10 @@ function processReadme() {
|
|
|
62
123
|
*/
|
|
63
124
|
|
|
64
125
|
function processDemo() {
|
|
65
|
-
const callback = function() {
|
|
126
|
+
const callback = function(updatedContent, outputConfig) {
|
|
66
127
|
if (fs.existsSync('./demo/demo.md')) {
|
|
67
128
|
fs.readFile('./demo/demo.md', 'utf8', function(err, data) {
|
|
68
|
-
|
|
129
|
+
formatTemplateFileContents(data, './demo/demo.md');
|
|
69
130
|
});
|
|
70
131
|
} else {
|
|
71
132
|
console.log('ERROR: ./demo/demo.md file is missing');
|
|
@@ -77,17 +138,17 @@ function processDemo() {
|
|
|
77
138
|
outputDir: './demo'
|
|
78
139
|
};
|
|
79
140
|
|
|
80
|
-
const markdownPath = '
|
|
141
|
+
const markdownPath = path.join(__dirname, '../docs/partials/demo.md');
|
|
81
142
|
|
|
82
143
|
markdownMagic(markdownPath, configDemo, callback);
|
|
83
144
|
}
|
|
84
145
|
|
|
85
146
|
/**
|
|
86
|
-
* Compiles `./docTemplates/
|
|
147
|
+
* Compiles `./docTemplates/apiExamples.md` -> `./demo/apiExamples.md`
|
|
87
148
|
*/
|
|
88
149
|
|
|
89
150
|
function processApiExamples() {
|
|
90
|
-
const callback = function() {
|
|
151
|
+
const callback = function(updatedContent, outputConfig) {
|
|
91
152
|
if (fs.existsSync('./demo/api.md')) {
|
|
92
153
|
fs.readFile('./demo/api.md', 'utf8', function(err, data) {
|
|
93
154
|
formatApiTableContents(data, './demo/api.md');
|
|
@@ -102,7 +163,7 @@ function processApiExamples() {
|
|
|
102
163
|
outputDir: './demo'
|
|
103
164
|
};
|
|
104
165
|
|
|
105
|
-
const markdownPath = '
|
|
166
|
+
const markdownPath = path.join(__dirname, '../docs/partials/api.md');
|
|
106
167
|
|
|
107
168
|
markdownMagic(markdownPath, config, callback);
|
|
108
169
|
}
|
package/package.json
CHANGED