@aurodesignsystem/auro-library 5.14.1 → 5.14.2
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 +7 -0
- package/bin/generateDocs.mjs +4 -210
- package/bin/generateDocs_index.mjs +4 -210
- package/dist/_chunks/chunk-2MOEVVSZ.mjs +308 -0
- package/dist/_chunks/chunk-H7YO7ERJ.mjs +69 -0
- package/dist/_chunks/chunk-JLCAYVRX.mjs +84 -0
- package/dist/_chunks/chunk-RKBXVLA5.mjs +5983 -0
- package/dist/_chunks/chunk-TDFKN2EP.mjs +38 -0
- package/dist/_chunks/chunk-UY4SIQT6.mjs +201 -0
- package/dist/_chunks/chunk-V7YBXHAI.mjs +32379 -0
- package/dist/bin/generateDocs.mjs +152 -0
- package/dist/bin/generateDocs_index.mjs +152 -0
- package/dist/build/generateDocs.mjs +18 -0
- package/dist/build/generateReadme.mjs +49 -0
- package/dist/build/generateWcaComponent.mjs +6657 -0
- package/dist/build/processors/defaultDocsProcessor.mjs +16 -0
- package/dist/build/processors/defaultDotGithubSync.mjs +12 -0
- package/dist/build/syncGithubFiles.mjs +18 -0
- package/dist/utils/auroTemplateFiller.mjs +8 -0
- package/dist/utils/sharedFileProcessorUtils.mjs +31 -0
- package/package.json +10 -5
- package/scripts/build/generateDocs.mjs +4 -24
- package/scripts/build/generateReadme.mjs +4 -60
- package/scripts/build/generateWcaComponent.mjs +4 -43
- package/scripts/build/postinstall.mjs +10 -10
- package/scripts/build/pre-commit.mjs +13 -7
- package/scripts/build/processors/defaultDocsProcessor.mjs +4 -83
- package/scripts/build/processors/defaultDotGithubSync.mjs +4 -83
- package/scripts/build/syncGithubFiles.mjs +4 -25
- package/scripts/utils/ansiColors.mjs +119 -0
- package/scripts/utils/auroLibraryUtils.mjs +87 -51
- package/scripts/utils/auroTemplateFiller.mjs +4 -178
- package/scripts/utils/logger.mjs +27 -16
- package/scripts/utils/sharedFileProcessorUtils.mjs +4 -270
- package/scripts/build/deprecatedProseToFieldPlugin.spec.js +0 -188
- package/scripts/runtime/ClickTracker/test/ClickTracker.test.js +0 -424
- package/scripts/runtime/FocusTrap/test/FocusTrap.test.js +0 -168
- package/scripts/runtime/Focusables/test/Focusables.test.js +0 -185
- package/scripts/runtime/dateUtilities/dateFormatter.test.js +0 -284
- package/scripts/runtime/dateUtilities/dateUtilities.test.js +0 -80
- package/scripts/runtime/floatingUI/test/floatingUI.test.js +0 -189
- package/scripts/runtime/floatingUI.test.js +0 -478
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
/* eslint-disable arrow-parens, line-comment-position, no-console, no-inline-comments, no-magic-numbers, prefer-arrow-callback, require-unicode-regexp, jsdoc/require-description-complete-sentence, prefer-named-capture-group */
|
|
7
7
|
|
|
8
|
-
import * as fs from
|
|
9
|
-
import * as path from
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
8
|
+
import * as fs from "fs";
|
|
9
|
+
import * as path from "path";
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
import { hex } from "./ansiColors.mjs";
|
|
12
12
|
|
|
13
|
-
import {Logger} from "./logger.mjs";
|
|
13
|
+
import { Logger } from "./logger.mjs";
|
|
14
14
|
|
|
15
15
|
export default class AuroLibraryUtils {
|
|
16
16
|
getDirname() {
|
|
@@ -20,12 +20,15 @@ export default class AuroLibraryUtils {
|
|
|
20
20
|
get getProjectRootPath() {
|
|
21
21
|
const currentDir = this.getDirname();
|
|
22
22
|
|
|
23
|
-
if (!currentDir.includes(
|
|
24
|
-
Logger.warn(
|
|
23
|
+
if (!currentDir.includes("node_modules")) {
|
|
24
|
+
Logger.warn(
|
|
25
|
+
`Unable to determine best project root as node_modules \nis not in the directory path.\n\nAssuming - "${currentDir}"`,
|
|
26
|
+
true,
|
|
27
|
+
);
|
|
25
28
|
return currentDir;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
return currentDir.split(
|
|
31
|
+
return currentDir.split("node_modules")[0];
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
/**
|
|
@@ -36,7 +39,11 @@ export default class AuroLibraryUtils {
|
|
|
36
39
|
*/
|
|
37
40
|
copyDirectory(srcDir, destDir, removeFiles) {
|
|
38
41
|
if (!fs.existsSync(srcDir)) {
|
|
39
|
-
this.auroLogger(
|
|
42
|
+
this.auroLogger(
|
|
43
|
+
`Source directory ${srcDir} does not exist`,
|
|
44
|
+
"error",
|
|
45
|
+
false,
|
|
46
|
+
);
|
|
40
47
|
} else {
|
|
41
48
|
// Removes all files from directory
|
|
42
49
|
if (removeFiles && fs.existsSync(destDir)) {
|
|
@@ -44,16 +51,16 @@ export default class AuroLibraryUtils {
|
|
|
44
51
|
|
|
45
52
|
let filesRemoved = 0;
|
|
46
53
|
|
|
47
|
-
destFiles.forEach(file => {
|
|
54
|
+
destFiles.forEach((file) => {
|
|
48
55
|
const filePath = path.join(destDir, file);
|
|
49
56
|
fs.unlinkSync(filePath);
|
|
50
|
-
this.auroLogger(`Removed file: ${file}`,
|
|
57
|
+
this.auroLogger(`Removed file: ${file}`, "success", false);
|
|
51
58
|
|
|
52
59
|
filesRemoved += 1;
|
|
53
60
|
});
|
|
54
61
|
|
|
55
62
|
if (filesRemoved > 0) {
|
|
56
|
-
this.auroLogger(`Removed ${filesRemoved} files`,
|
|
63
|
+
this.auroLogger(`Removed ${filesRemoved} files`, "success", false);
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -66,7 +73,7 @@ export default class AuroLibraryUtils {
|
|
|
66
73
|
const files = fs.readdirSync(srcDir);
|
|
67
74
|
|
|
68
75
|
// Copies over all files from source directory to destination directory
|
|
69
|
-
files.forEach(file => {
|
|
76
|
+
files.forEach((file) => {
|
|
70
77
|
const sourceFilePath = path.join(srcDir, file);
|
|
71
78
|
const destFilePath = path.join(destDir, file);
|
|
72
79
|
|
|
@@ -77,11 +84,11 @@ export default class AuroLibraryUtils {
|
|
|
77
84
|
} else {
|
|
78
85
|
fs.copyFileSync(sourceFilePath, destFilePath);
|
|
79
86
|
|
|
80
|
-
fs.readFile(destFilePath,
|
|
87
|
+
fs.readFile(destFilePath, "utf8", (err, data) => {
|
|
81
88
|
this.formatFileContents(data, destFilePath);
|
|
82
89
|
});
|
|
83
90
|
|
|
84
|
-
this.auroLogger(`Copied file: ${file}`,
|
|
91
|
+
this.auroLogger(`Copied file: ${file}`, "success");
|
|
85
92
|
}
|
|
86
93
|
});
|
|
87
94
|
}
|
|
@@ -95,38 +102,50 @@ export default class AuroLibraryUtils {
|
|
|
95
102
|
*/
|
|
96
103
|
auroLogger(message, status, section) {
|
|
97
104
|
if (status) {
|
|
98
|
-
const infoColor =
|
|
99
|
-
const successColor =
|
|
100
|
-
const errorColor =
|
|
105
|
+
const infoColor = "#0096FF"; // blue
|
|
106
|
+
const successColor = "#4CBB17"; // green
|
|
107
|
+
const errorColor = "#ff0000"; // red
|
|
101
108
|
|
|
102
|
-
let color
|
|
109
|
+
let color; // eslint-disable-line no-undef-init
|
|
103
110
|
|
|
104
|
-
if (status ===
|
|
111
|
+
if (status === "info") {
|
|
105
112
|
color = infoColor;
|
|
106
|
-
} else if (status ===
|
|
113
|
+
} else if (status === "success") {
|
|
107
114
|
color = successColor;
|
|
108
|
-
} else if (status ===
|
|
115
|
+
} else if (status === "error") {
|
|
109
116
|
color = errorColor;
|
|
110
117
|
}
|
|
111
118
|
|
|
112
119
|
if (section) {
|
|
113
|
-
console.log(
|
|
120
|
+
console.log(
|
|
121
|
+
hex(color)(
|
|
122
|
+
"╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ──────────────────────────────╮\n",
|
|
123
|
+
),
|
|
124
|
+
);
|
|
114
125
|
}
|
|
115
126
|
|
|
116
|
-
console.log(
|
|
127
|
+
console.log(hex(color)(message));
|
|
117
128
|
|
|
118
129
|
if (section) {
|
|
119
|
-
console.log(
|
|
130
|
+
console.log(
|
|
131
|
+
hex(color)(
|
|
132
|
+
"\n╰─────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯",
|
|
133
|
+
),
|
|
134
|
+
);
|
|
120
135
|
}
|
|
121
136
|
} else {
|
|
122
137
|
if (section) {
|
|
123
|
-
console.log(
|
|
138
|
+
console.log(
|
|
139
|
+
"╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ──────────────────────────────╮\n",
|
|
140
|
+
);
|
|
124
141
|
}
|
|
125
142
|
|
|
126
143
|
console.log(message);
|
|
127
144
|
|
|
128
145
|
if (section) {
|
|
129
|
-
console.log(
|
|
146
|
+
console.log(
|
|
147
|
+
"\n╰─────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯",
|
|
148
|
+
);
|
|
130
149
|
}
|
|
131
150
|
}
|
|
132
151
|
}
|
|
@@ -136,31 +155,40 @@ export default class AuroLibraryUtils {
|
|
|
136
155
|
* @returns {Object} result - Object containing data from package.json.
|
|
137
156
|
*/
|
|
138
157
|
nameExtraction() {
|
|
139
|
-
let packageJson = fs.readFileSync(
|
|
158
|
+
let packageJson = fs.readFileSync("package.json", "utf8", (err) => {
|
|
140
159
|
if (err) {
|
|
141
|
-
console.log(
|
|
160
|
+
console.log("ERROR: Unable to read package.json file", err);
|
|
142
161
|
}
|
|
143
162
|
});
|
|
144
163
|
|
|
145
164
|
packageJson = JSON.parse(packageJson);
|
|
146
165
|
|
|
147
166
|
const pName = packageJson.name;
|
|
148
|
-
const npmStart = pName.indexOf(
|
|
149
|
-
const namespaceStart = pName.indexOf(
|
|
150
|
-
const nameStart = pName.indexOf(
|
|
167
|
+
const npmStart = pName.indexOf("@");
|
|
168
|
+
const namespaceStart = pName.indexOf("/");
|
|
169
|
+
const nameStart = pName.indexOf("-");
|
|
151
170
|
|
|
152
171
|
return {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
abstractNodeVersion: packageJson.engines.node.substring(2),
|
|
173
|
+
branchName: packageJson.release.branch,
|
|
174
|
+
npm: pName.substring(npmStart, namespaceStart),
|
|
175
|
+
namespace: pName.substring(namespaceStart + 1, nameStart),
|
|
176
|
+
namespaceCap:
|
|
177
|
+
pName.substring(namespaceStart + 1)[0].toUpperCase() +
|
|
178
|
+
pName.substring(namespaceStart + 2, nameStart),
|
|
179
|
+
name: pName.substring(nameStart + 1),
|
|
180
|
+
nameCap:
|
|
181
|
+
pName.substring(nameStart + 1)[0].toUpperCase() +
|
|
182
|
+
pName.substring(nameStart + 2),
|
|
183
|
+
version: packageJson.version,
|
|
184
|
+
tokensVersion:
|
|
185
|
+
packageJson.peerDependencies?.[
|
|
186
|
+
"@aurodesignsystem/design-tokens"
|
|
187
|
+
]?.substring(1) ?? "",
|
|
188
|
+
wcssVersion:
|
|
189
|
+
packageJson.peerDependencies?.[
|
|
190
|
+
"@aurodesignsystem/webcorestylesheets"
|
|
191
|
+
]?.substring(1) ?? "",
|
|
164
192
|
};
|
|
165
193
|
}
|
|
166
194
|
|
|
@@ -177,7 +205,10 @@ export default class AuroLibraryUtils {
|
|
|
177
205
|
/**
|
|
178
206
|
* Replace placeholder strings.
|
|
179
207
|
*/
|
|
180
|
-
result = result.replace(
|
|
208
|
+
result = result.replace(
|
|
209
|
+
/\[abstractNodeVersion]/g,
|
|
210
|
+
nameExtractionData.abstractNodeVersion,
|
|
211
|
+
);
|
|
181
212
|
result = result.replace(/\[branchName]/g, nameExtractionData.branchName);
|
|
182
213
|
result = result.replace(/\[npm]/g, nameExtractionData.npm);
|
|
183
214
|
result = result.replace(/\[name](?!\()/g, nameExtractionData.name);
|
|
@@ -191,16 +222,21 @@ export default class AuroLibraryUtils {
|
|
|
191
222
|
/**
|
|
192
223
|
* Cleanup line breaks.
|
|
193
224
|
*/
|
|
194
|
-
result = result.replace(/(\r\n|\r|\n)[\s]+(\r\n|\r|\n)/g,
|
|
195
|
-
result = result.replace(/>(\r\n|\r|\n){2,}/g,
|
|
196
|
-
result = result.replace(/>(\r\n|\r|\n)```/g,
|
|
197
|
-
result = result.replace(
|
|
198
|
-
|
|
225
|
+
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.
|
|
226
|
+
result = result.replace(/>(\r\n|\r|\n){2,}/g, ">\r\n"); // Remove empty lines directly after a closing html tag.
|
|
227
|
+
result = result.replace(/>(\r\n|\r|\n)```/g, ">\r\n\r\n```"); // Ensure an empty line before code samples.
|
|
228
|
+
result = result.replace(
|
|
229
|
+
/>(\r\n|\r|\n){2,}```(\r\n|\r|\n)/g,
|
|
230
|
+
">\r\n```\r\n",
|
|
231
|
+
); // Ensure no empty lines before close of code sample.
|
|
232
|
+
result = result.replace(
|
|
233
|
+
/([^(\r\n|\r|\n)])(\r?\n|\r(?!\n))+#/g,
|
|
234
|
+
"$1\r\n\r\n#",
|
|
235
|
+
); // Ensure empty line before header sections.
|
|
199
236
|
|
|
200
237
|
/**
|
|
201
238
|
* Write the result to the destination file.
|
|
202
239
|
*/
|
|
203
|
-
fs.writeFileSync(destination, result, { encoding:
|
|
240
|
+
fs.writeFileSync(destination, result, { encoding: "utf8" });
|
|
204
241
|
}
|
|
205
242
|
}
|
|
206
|
-
|
|
@@ -1,178 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// declare package.json type with jsdoc
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {Object} ExamplePackageJson
|
|
8
|
-
* @property {string} name - Name of the package.
|
|
9
|
-
* @property {string} version - Version of the package.
|
|
10
|
-
* @property {Record<string, string>} peerDependencies - Peer dependencies of the package.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// declare extracted names type with jsdoc
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {Object} ExtractedNames
|
|
16
|
-
* @property {string} npm - NPM of the package.
|
|
17
|
-
* @property {string} namespace - Namespace of the package.
|
|
18
|
-
* @property {string} namespaceCap - Capitalized namespace of the package.
|
|
19
|
-
* @property {string} name - Name of the package.
|
|
20
|
-
* @property {string} nameCap - Capitalized name of the package.
|
|
21
|
-
* @property {string} version - Version of the package.
|
|
22
|
-
* @property {string} tokensVersion - Version of the design tokens.
|
|
23
|
-
* @property {string} wcssVersion - Version of the webcorestylesheets.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export class AuroTemplateFiller {
|
|
28
|
-
static designTokenPackage = '@aurodesignsystem/design-tokens';
|
|
29
|
-
static webCoreStylesheetsPackage = '@aurodesignsystem/webcorestylesheets';
|
|
30
|
-
|
|
31
|
-
constructor () {
|
|
32
|
-
/** @type {ExtractedNames} */
|
|
33
|
-
this.values = null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async prepare() {
|
|
37
|
-
await this.extractNames()
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Extract various data for filling template files from the package.json file.
|
|
42
|
-
* @returns {Promise<ExtractedNames>}
|
|
43
|
-
*/
|
|
44
|
-
async extractNames() {
|
|
45
|
-
const packageJsonData = await fs.readFile('package.json', 'utf8');
|
|
46
|
-
|
|
47
|
-
/** @type {ExamplePackageJson} */
|
|
48
|
-
const parsedPackageJson = JSON.parse(packageJsonData);
|
|
49
|
-
|
|
50
|
-
const pName = parsedPackageJson.name;
|
|
51
|
-
const pVersion = parsedPackageJson.version;
|
|
52
|
-
const pdtVersion = parsedPackageJson.peerDependencies?.[AuroTemplateFiller.designTokenPackage].substring(1) ?? '';
|
|
53
|
-
const wcssVersion = parsedPackageJson.peerDependencies?.[AuroTemplateFiller.webCoreStylesheetsPackage].substring(1) ?? '';
|
|
54
|
-
|
|
55
|
-
const npmStart = pName.indexOf('@');
|
|
56
|
-
const namespaceStart = pName.indexOf('/');
|
|
57
|
-
const nameStart = pName.indexOf('-');
|
|
58
|
-
const packageNamespace = pName.substring(namespaceStart + 1, nameStart);
|
|
59
|
-
|
|
60
|
-
if (nameStart === -1) {
|
|
61
|
-
throw new Error(`No name can be derived from package.json "name" field: '${pName}'. Expected pattern with \`-\` split like [\`@aurodesignsystem/auro-component\` or \`@aurodesignsystem/eslint-config\`, etc.]`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
this.values = {
|
|
65
|
-
'npm': pName.substring(npmStart, namespaceStart),
|
|
66
|
-
'namespace': packageNamespace,
|
|
67
|
-
'namespaceCap': pName.substring(namespaceStart + 1)[0].toUpperCase() + pName.substring(namespaceStart + 2, nameStart),
|
|
68
|
-
'name': pName.substring(nameStart + 1),
|
|
69
|
-
'nameCap': pName.substring(nameStart + 1)[0].toUpperCase() + pName.substring(nameStart + 2),
|
|
70
|
-
'version': pVersion,
|
|
71
|
-
'tokensVersion': pdtVersion,
|
|
72
|
-
wcssVersion
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* @param {string} template - The string to use to run variable replacement
|
|
78
|
-
* @param {object} extraVars - Additional variables to use in the template
|
|
79
|
-
* @return {string}
|
|
80
|
-
*/
|
|
81
|
-
replaceTemplateValues(template, extraVars = {}) {
|
|
82
|
-
const compileResult = Handlebars.compile(template);
|
|
83
|
-
|
|
84
|
-
// replace all handlebars placeholders FIRST, then apply legacy replacements
|
|
85
|
-
let result = compileResult({
|
|
86
|
-
// TODO: consider replacing some of these with handlebars helpers
|
|
87
|
-
name: this.values.name,
|
|
88
|
-
Name: this.values.nameCap,
|
|
89
|
-
namespace: this.values.namespace,
|
|
90
|
-
Namespace: this.values.namespaceCap,
|
|
91
|
-
Version: this.values.version,
|
|
92
|
-
dtVersion: this.values.tokensVersion,
|
|
93
|
-
wcssVersion: this.values.wcssVersion,
|
|
94
|
-
...extraVars
|
|
95
|
-
}, {
|
|
96
|
-
helpers: {
|
|
97
|
-
'capitalize': (str) => str.charAt(0).toUpperCase() + str.slice(1),
|
|
98
|
-
// Hard codes `auro-*` with whatever string is passed in.
|
|
99
|
-
'withAuroNamespace': (str) => `auro-${str}`,
|
|
100
|
-
// Recreats the string from package.json: auro-component, eslint-config, etc.
|
|
101
|
-
'packageName': () => `${this.values['namespace']}-${this.values['name']}`
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Old legacy template variables. We used to use `[varName]` and are now using handlebars `{{varName}}`.
|
|
107
|
-
* @type {[{pattern: RegExp, replacement: string},{pattern: RegExp, replacement: string},{pattern: RegExp, replacement: string},{pattern: RegExp, replacement: string},{pattern: RegExp, replacement: string},null,null,null]}
|
|
108
|
-
*/
|
|
109
|
-
const legacyTemplateVariables = [
|
|
110
|
-
{
|
|
111
|
-
pattern: /\[npm\]/gu,
|
|
112
|
-
replacement: this.values.npm
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
pattern: /\[name\](?!\()/gu,
|
|
116
|
-
replacement: this.values.name
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
pattern: /\[Name\](?!\()/gu,
|
|
120
|
-
replacement: this.values.nameCap
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
pattern: /\[namespace\]/gu,
|
|
124
|
-
replacement: this.values.namespace
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
pattern: /\[Namespace\]/gu,
|
|
128
|
-
replacement: this.values.namespaceCap
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
pattern: /\[Version\]/gu,
|
|
132
|
-
replacement: this.values.version
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
pattern: /\[dtVersion\]/gu,
|
|
136
|
-
replacement: this.values.tokensVersion
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
pattern: /\[wcssVersion\]/gu,
|
|
140
|
-
replacement: this.values.wcssVersion
|
|
141
|
-
}
|
|
142
|
-
];
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Replace legacy placeholder strings.
|
|
146
|
-
*/
|
|
147
|
-
for (const { pattern, replacement } of legacyTemplateVariables) {
|
|
148
|
-
result = result.replace(pattern, replacement);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Cleanup line breaks.
|
|
153
|
-
*/
|
|
154
|
-
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.
|
|
155
|
-
result = result.replace(/>(\r\n|\r|\n){2,}/g, '>\r\n'); // Remove empty lines directly after a closing html tag.
|
|
156
|
-
result = result.replace(/>(\r\n|\r|\n)```/g, '>\r\n\r\n```'); // Ensure an empty line before code samples.
|
|
157
|
-
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.
|
|
158
|
-
result = result.replace(/([^(\r\n|\r|\n)])(\r?\n|\r(?!\n))+#/g, "$1\r\n\r\n#"); // Ensure empty line before header sections.
|
|
159
|
-
|
|
160
|
-
return result;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
*
|
|
166
|
-
* @param {string} content
|
|
167
|
-
*/
|
|
168
|
-
formatApiTable(content) {
|
|
169
|
-
let result = `${content}`;
|
|
170
|
-
|
|
171
|
-
result = result
|
|
172
|
-
.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>`)
|
|
173
|
-
.replace(/\r\n|\r|\n\|\s`([a-zA-Z]*)`/g, '\r\n| [$1](#$1)')
|
|
174
|
-
.replace(/\| \[\]\(#\)/g, "");
|
|
175
|
-
|
|
176
|
-
return result
|
|
177
|
-
}
|
|
178
|
-
}
|
|
1
|
+
// Shim for the pre-compiled build. Do not edit.
|
|
2
|
+
// Generated by build/bundleDocsScripts.mjs from src/utils/auroTemplateFiller.mjs.
|
|
3
|
+
// Edit that file, then run `npm run build:bundles`.
|
|
4
|
+
export * from "../../dist/utils/auroTemplateFiller.mjs";
|
package/scripts/utils/logger.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-inline-comments, no-console, line-comment-position */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { hex } from "./ansiColors.mjs";
|
|
4
4
|
|
|
5
5
|
export class Logger {
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* Logs out messages in a readable format.
|
|
9
8
|
* @param {String} message - Message to be logged.
|
|
@@ -12,41 +11,53 @@ export class Logger {
|
|
|
12
11
|
*/
|
|
13
12
|
static auroLogger(message, status, section) {
|
|
14
13
|
if (status !== false) {
|
|
15
|
-
const infoColor =
|
|
16
|
-
const successColor =
|
|
17
|
-
const errorColor =
|
|
18
|
-
const warningColor =
|
|
14
|
+
const infoColor = "#0096FF"; // blue
|
|
15
|
+
const successColor = "#4CBB17"; // green
|
|
16
|
+
const errorColor = "#ff0000"; // red
|
|
17
|
+
const warningColor = "#FFA500"; // orange
|
|
19
18
|
|
|
20
|
-
let color
|
|
19
|
+
let color; // eslint-disable-line no-undef-init
|
|
21
20
|
|
|
22
|
-
if (status ===
|
|
21
|
+
if (status === "info") {
|
|
23
22
|
color = infoColor;
|
|
24
|
-
} else if (status ===
|
|
23
|
+
} else if (status === "success") {
|
|
25
24
|
color = successColor;
|
|
26
|
-
} else if (status ===
|
|
25
|
+
} else if (status === "error") {
|
|
27
26
|
color = errorColor;
|
|
28
|
-
} else if (status ===
|
|
27
|
+
} else if (status === "warn") {
|
|
29
28
|
color = warningColor;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
if (section) {
|
|
33
|
-
console.log(
|
|
32
|
+
console.log(
|
|
33
|
+
hex(color)(
|
|
34
|
+
"╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ──────────────────────────────╮\n",
|
|
35
|
+
),
|
|
36
|
+
);
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
console.log(
|
|
39
|
+
console.log(hex(color)(message));
|
|
37
40
|
|
|
38
41
|
if (section) {
|
|
39
|
-
console.log(
|
|
42
|
+
console.log(
|
|
43
|
+
hex(color)(
|
|
44
|
+
"\n╰─────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯",
|
|
45
|
+
),
|
|
46
|
+
);
|
|
40
47
|
}
|
|
41
48
|
} else {
|
|
42
49
|
if (section) {
|
|
43
|
-
console.log(
|
|
50
|
+
console.log(
|
|
51
|
+
"╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ──────────────────────────────╮\n",
|
|
52
|
+
);
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
console.log(message);
|
|
47
56
|
|
|
48
57
|
if (section) {
|
|
49
|
-
console.log(
|
|
58
|
+
console.log(
|
|
59
|
+
"\n╰─────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯",
|
|
60
|
+
);
|
|
50
61
|
}
|
|
51
62
|
}
|
|
52
63
|
}
|