@aurodesignsystem/auro-library 2.6.0 → 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 CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env sh
2
2
  . "$(dirname -- "$0")/_/husky.sh"
3
3
 
4
- npm run lint
4
+ npm run linters
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  # [2.6.0](https://github.com/AlaskaAirlines/auro-library/compare/v2.5.1...v2.6.0) (2024-04-29)
4
11
 
5
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurodesignsystem/auro-library",
3
- "version": "2.6.0",
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.0",
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.56.0",
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
- "main"
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
- "lint": "eslint ./scripts/**/*.js",
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 * as fs from 'fs';
3
- import * as https from 'https';
3
+ import fs from 'fs';
4
+ import https from 'https';
5
+ import { fileURLToPath } from 'url';
4
6
 
5
- import AuroLibraryUtils from "../utils/auroLibraryUtils.mjs";
7
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
6
8
 
7
- const auroLibraryUtils = new AuroLibraryUtils();
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
- * Replace all instances of [npm], [name], [Name], [namespace] and [Namespace] accordingly
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 = auroLibraryUtils.nameExtraction();
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="#${wcName}" style="float: right; font-size: 1rem; font-weight: 100;">back to top</a>`)
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
- auroLibraryUtils.formatFileContents(data, './demo/api.md');
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
- auroLibraryUtils.formatFileContents(data, './README.md');
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 = './docTemplates/README.md';
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/demo.md` -> `./demo/index.md`
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
- auroLibraryUtils.formatFileContents(data, './demo/index.md');
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 = './docs/partials/index.md';
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 = './docs/partials/api.md';
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
- fs.readFile('src/style.css', (err, css) => {
7
- postcss([autoprefixer, comments])
8
- .use(comments({
9
- remove: function(comment) { return comment[0] == "@"; }
10
- }))
11
- .process(css, { from: 'src/style.css', to: 'src/style.css' })
12
- .then(result => {
13
- fs.writeFile('src/style.css', result.css, () => true)
14
- if ( result.map ) {
15
- fs.writeFile('src/style.map', result.map, () => true)
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
- 'use strict';
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');
@@ -0,0 +1,2 @@
1
+ import { css } from 'lit';
2
+ export default css`<% content %>`;
@@ -3,6 +3,8 @@
3
3
 
4
4
  // ---------------------------------------------------------------------
5
5
 
6
+ /* eslint-disable no-undef */
7
+
6
8
  const auroSubNameIndex = 5;
7
9
 
8
10
  /**
@@ -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
- const packageJson = fs.readFileSync('package.json', 'utf8', function(err) {
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
- const pName = JSON.parse(packageJson).name;
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
- const result = {
135
- 'abstractNodeVersion': JSON.parse(packageJson).engines.node.substring(2),
136
- 'branchName': JSON.parse(packageJson).release.branch,
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': pVersion,
143
- 'tokensVersion': pdtVersion,
144
- 'wcssVersion': wcssVersion
144
+ 'version': packageJson.version
145
145
  };
146
-
147
- return result;
148
146
  }
149
147
 
150
148
  /**