@aurodesignsystem/auro-library 2.6.0 → 2.6.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/.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,19 @@
1
1
  # Semantic Release Automated Changelog
2
2
 
3
+ ## [2.6.2](https://github.com/AlaskaAirlines/auro-library/compare/v2.6.1...v2.6.2) (2024-08-07)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * update various build scripts ([9b726b3](https://github.com/AlaskaAirlines/auro-library/commit/9b726b3ad2fd616987a4488cc440f0f7498c0028))
9
+
10
+ ## [2.6.1](https://github.com/AlaskaAirlines/auro-library/compare/v2.6.0...v2.6.1) (2024-08-06)
11
+
12
+
13
+ ### Performance Improvements
14
+
15
+ * cleanup and update existing build scripts ([b6d5d95](https://github.com/AlaskaAirlines/auro-library/commit/b6d5d952c8e0ce8c7636057e612ae821f5e85079))
16
+
3
17
  # [2.6.0](https://github.com/AlaskaAirlines/auro-library/compare/v2.5.1...v2.6.0) (2024-04-29)
4
18
 
5
19
 
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.2",
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
7
  import AuroLibraryUtils from "../utils/auroLibraryUtils.mjs";
6
8
 
7
9
  const auroLibraryUtils = new AuroLibraryUtils();
8
10
 
9
- const readmeTemplateUrl = 'https://raw.githubusercontent.com/AlaskaAirlines/WC-Generator/master/componentDocs/README.md';
11
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
12
+
13
+ const readmeTemplateUrl = 'https://raw.githubusercontent.com/AlaskaAirlines/WC-Generator/master/componentDocs/README_esm.md';
10
14
  const dirDocTemplates = './docTemplates';
11
15
  const readmeFilePath = dirDocTemplates + '/README.md';
12
16
 
13
17
  /**
14
- * Replace all instances of [npm], [name], [Name], [namespace] and [Namespace] accordingly
18
+ * Extract NPM, NAMESPACE and NAME from package.json
19
+ */
20
+
21
+ function nameExtraction() {
22
+ let 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
+ packageJson = JSON.parse(packageJson);
29
+
30
+ let pName = packageJson.name;
31
+ let pVersion = packageJson.version;
32
+ let pdtVersion = packageJson.peerDependencies['\@aurodesignsystem/design-tokens'].substring(1)
33
+ let wcssVersion = packageJson.peerDependencies['\@aurodesignsystem/webcorestylesheets'].substring(1)
34
+
35
+ let npmStart = pName.indexOf('@');
36
+ let namespaceStart = pName.indexOf('/');
37
+ let nameStart = pName.indexOf('-');
38
+
39
+ return {
40
+ 'npm': pName.substring(npmStart, namespaceStart),
41
+ 'namespace': pName.substring(namespaceStart + 1, nameStart),
42
+ 'namespaceCap': pName.substring(namespaceStart + 1)[0].toUpperCase() + pName.substring(namespaceStart + 2, nameStart),
43
+ 'name': pName.substring(nameStart + 1),
44
+ 'nameCap': pName.substring(nameStart + 1)[0].toUpperCase() + pName.substring(nameStart + 2),
45
+ 'version': pVersion,
46
+ 'tokensVersion': pdtVersion,
47
+ 'wcssVersion': wcssVersion
48
+ };
49
+ }
50
+
51
+ /**
52
+ * Replace all instances of [npm], [name], [Name], [namespace] and [Namespace] accordingly
53
+ */
54
+
55
+ function formatTemplateFileContents(content, destination) {
56
+ let nameExtractionData = nameExtraction();
57
+ let result = content;
58
+
59
+ /**
60
+ * Replace placeholder strings
61
+ */
62
+ result = result.replace(/\[npm]/g, nameExtractionData.npm);
63
+ result = result.replace(/\[name](?!\()/g, nameExtractionData.name);
64
+ result = result.replace(/\[Name](?!\()/g, nameExtractionData.nameCap);
65
+ result = result.replace(/\[namespace]/g, nameExtractionData.namespace);
66
+ result = result.replace(/\[Namespace]/g, nameExtractionData.namespaceCap);
67
+ result = result.replace(/\[Version]/g, nameExtractionData.version);
68
+ result = result.replace(/\[dtVersion]/g, nameExtractionData.tokensVersion);
69
+ result = result.replace(/\[wcssVersion]/g, nameExtractionData.wcssVersion);
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,19 +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) {
138
+ // formatTemplateFileContents(data, './demo/index.md');
68
139
  auroLibraryUtils.formatFileContents(data, './demo/index.md');
69
140
  });
70
141
  } else {
@@ -77,7 +148,7 @@ function processDemo() {
77
148
  outputDir: './demo'
78
149
  };
79
150
 
80
- const markdownPath = './docs/partials/index.md';
151
+ const markdownPath = path.join(__dirname, './../../../../../docs/partials/index.md');
81
152
 
82
153
  markdownMagic(markdownPath, configDemo, callback);
83
154
  }
@@ -87,7 +158,7 @@ function processDemo() {
87
158
  */
88
159
 
89
160
  function processApiExamples() {
90
- const callback = function() {
161
+ const callback = function(updatedContent, outputConfig) {
91
162
  if (fs.existsSync('./demo/api.md')) {
92
163
  fs.readFile('./demo/api.md', 'utf8', function(err, data) {
93
164
  formatApiTableContents(data, './demo/api.md');
@@ -102,7 +173,7 @@ function processApiExamples() {
102
173
  outputDir: './demo'
103
174
  };
104
175
 
105
- const markdownPath = './docs/partials/api.md';
176
+ const markdownPath = path.join(__dirname, './../../../../../docs/partials/api.md');
106
177
 
107
178
  markdownMagic(markdownPath, config, callback);
108
179
  }
@@ -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,32 @@ 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
129
 
130
+ const pName = packageJson.name;
130
131
  const npmStart = pName.indexOf('@');
131
132
  const namespaceStart = pName.indexOf('/');
132
133
  const nameStart = pName.indexOf('-');
133
134
 
134
- const result = {
135
- 'abstractNodeVersion': JSON.parse(packageJson).engines.node.substring(2),
136
- 'branchName': JSON.parse(packageJson).release.branch,
135
+ return {
136
+ 'abstractNodeVersion': packageJson.engines.node.substring(2),
137
+ 'branchName': packageJson.release.branch,
137
138
  'npm': pName.substring(npmStart, namespaceStart),
138
139
  'namespace': pName.substring(namespaceStart + 1, nameStart),
139
140
  'namespaceCap': pName.substring(namespaceStart + 1)[0].toUpperCase() + pName.substring(namespaceStart + 2, nameStart),
140
141
  'name': pName.substring(nameStart + 1),
141
142
  'nameCap': pName.substring(nameStart + 1)[0].toUpperCase() + pName.substring(nameStart + 2),
142
- 'version': pVersion,
143
- 'tokensVersion': pdtVersion,
144
- 'wcssVersion': wcssVersion
145
- };
143
+ 'version': packageJson.version,
144
+ 'tokensVersion': packageJson.peerDependencies['\@aurodesignsystem/design-tokens'].substring(1),
145
+ 'wcssVersion': packageJson.peerDependencies['\@aurodesignsystem/webcorestylesheets'].substring(1)
146
146
 
147
- return result;
147
+ };
148
148
  }
149
149
 
150
150
  /**