From f40f97103b77c461b06d6931bb25473768d1bbb3 Mon Sep 17 00:00:00 2001 From: Jordan Jones Date: Tue, 13 Aug 2024 14:26:03 -0700 Subject: [PATCH] perf: update dependencies and scripts to latest versions --- .husky/commit-msg | 3 - .husky/pre-commit | 3 - demo/api.md | 1 - docs/api.md | 1 - package-lock.json | 48 +++---- package.json | 12 +- scripts/generateDocs.mjs | 210 ------------------------------- scripts/postCss.mjs | 41 ------ scripts/pre-commit.mjs | 17 --- scripts/staticStyles-template.js | 2 - src/auro-select.js | 3 + src/dropdownVersion.js | 2 +- 12 files changed, 34 insertions(+), 309 deletions(-) delete mode 100644 scripts/generateDocs.mjs delete mode 100644 scripts/postCss.mjs delete mode 100644 scripts/pre-commit.mjs delete mode 100644 scripts/staticStyles-template.js diff --git a/.husky/commit-msg b/.husky/commit-msg index 0bd658f..70bd3dd 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - npx --no-install commitlint --edit "$1" diff --git a/.husky/pre-commit b/.husky/pre-commit index deb2b66..ed31d95 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - ./node_modules/.bin/npm-run-all preCommit test linters postinstall diff --git a/demo/api.md b/demo/api.md index 6a14e4a..8ce482d 100644 --- a/demo/api.md +++ b/demo/api.md @@ -17,7 +17,6 @@ The auro-select element is a wrapper for auro-dropdown and auro-menu to create a | Property | Attribute | Type | Default | Description | |---------------------------------|---------------------------------|-----------|------------------------|--------------------------------------------------| | [disabled](#disabled) | `disabled` | `Boolean` | | When attribute is present element shows disabled state. | -| [dropdownTag](#dropdownTag) | | `string` | | | | [error](#error) | `error` | `String` | | When defined, sets persistent validity to `customError` and sets `setCustomValidity` = attribute value. | | [noCheckmark](#noCheckmark) | `noCheckmark` | `Boolean` | | When true, checkmark on selected option will no longer be present. | | [noValidate](#noValidate) | `noValidate` | `Boolean` | | If set, disables auto-validation on blur. | diff --git a/docs/api.md b/docs/api.md index 4ae89f2..05a58d2 100644 --- a/docs/api.md +++ b/docs/api.md @@ -7,7 +7,6 @@ The auro-select element is a wrapper for auro-dropdown and auro-menu to create a | Property | Attribute | Type | Default | Description | |---------------------------------|---------------------------------|-----------|------------------------|--------------------------------------------------| | `disabled` | `disabled` | `Boolean` | | When attribute is present element shows disabled state. | -| `dropdownTag` | | `string` | | | | `error` | `error` | `String` | | When defined, sets persistent validity to `customError` and sets `setCustomValidity` = attribute value. | | `noCheckmark` | `noCheckmark` | `Boolean` | | When true, checkmark on selected option will no longer be present. | | `noValidate` | `noValidate` | `Boolean` | | If set, disables auto-validation on blur. | diff --git a/package-lock.json b/package-lock.json index 06bc3ac..55248ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,10 +10,10 @@ "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@aurodesignsystem/auro-dropdown": "^3.0.0-beta.2", + "@aurodesignsystem/auro-dropdown": "^3.0.0-beta.3", "@aurodesignsystem/auro-formvalidation": "^1.0.3", "@aurodesignsystem/auro-library": "^2.6.3", - "@aurodesignsystem/auro-menu": "^3.12.0-beta.1", + "@aurodesignsystem/auro-menu": "^3.12.0-beta.2", "chalk": "^5.3.0", "lit-element": "^4.1.0", "lit-html": "^3.2.0" @@ -179,12 +179,12 @@ } }, "node_modules/@aurodesignsystem/auro-dropdown": { - "version": "3.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@aurodesignsystem/auro-dropdown/-/auro-dropdown-3.0.0-beta.2.tgz", - "integrity": "sha512-sP+ohHSzNuspnSnaWfc1bAyfiAxmjZNaBK9UmCITt+A7nUvBxAq4sD8MKeUTDNsBm8Viluxj+3J3meoT6qgNGQ==", + "version": "3.0.0-beta.3", + "resolved": "https://registry.npmjs.org/@aurodesignsystem/auro-dropdown/-/auro-dropdown-3.0.0-beta.3.tgz", + "integrity": "sha512-HVX8vRGwOhQAWz7yU+BXriyaSVhMvOtQehFCb9eg56sapJhJdI4OdJutWNXaEpbIOj8ElOgjfQEva542W4rWHA==", "hasInstallScript": true, "dependencies": { - "@aurodesignsystem/auro-icon": "^5.0.0-beta.1", + "@aurodesignsystem/auro-icon": "^4.5.1-beta.1", "@popperjs/core": "^2.11.8", "chalk": "^5.2.0", "lit": "^3.2.0" @@ -198,14 +198,23 @@ "@aurodesignsystem/webcorestylesheets": "^5.0.3" } }, - "node_modules/@aurodesignsystem/auro-dropdown/node_modules/@aurodesignsystem/auro-icon": { - "version": "5.0.0-beta.1", - "resolved": "https://registry.npmjs.org/@aurodesignsystem/auro-icon/-/auro-icon-5.0.0-beta.1.tgz", - "integrity": "sha512-E1dth3K8JiViAdMtNb6ZESPZxIj8pQVlAoozsw6LAAIimWtEay4Mo2Mp22RByIWv2oK/ro3KuAwcyqiSotmQgQ==", + "node_modules/@aurodesignsystem/auro-formvalidation": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@aurodesignsystem/auro-formvalidation/-/auro-formvalidation-1.0.3.tgz", + "integrity": "sha512-diJ5VE64WjVlnSIdSm8Wcj0ouhNPgveXePYrhknWcXwLvepPwt3XZyY+hGFaXTEd1ni9I2VYzypvnTPawkMsOA==", + "hasInstallScript": true, + "engines": { + "node": "^18 || ^20" + } + }, + "node_modules/@aurodesignsystem/auro-icon": { + "version": "4.5.1-beta.1", + "resolved": "https://registry.npmjs.org/@aurodesignsystem/auro-icon/-/auro-icon-4.5.1-beta.1.tgz", + "integrity": "sha512-G+bbcxH451pOfKJuwdCaYF5r9vIxc8id/3aL7i9pg3MCDmapqQZ16evnNWyombW6U5mAsP8i3NqqdqHoVDzcxw==", "hasInstallScript": true, "dependencies": { "chalk": "^5.3.0", - "lit": "^3.1.3" + "lit": "^3.2.0" }, "engines": { "node": "^18.x || ^20.x" @@ -216,15 +225,6 @@ "@aurodesignsystem/webcorestylesheets": "^5.0.8" } }, - "node_modules/@aurodesignsystem/auro-formvalidation": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@aurodesignsystem/auro-formvalidation/-/auro-formvalidation-1.0.3.tgz", - "integrity": "sha512-diJ5VE64WjVlnSIdSm8Wcj0ouhNPgveXePYrhknWcXwLvepPwt3XZyY+hGFaXTEd1ni9I2VYzypvnTPawkMsOA==", - "hasInstallScript": true, - "engines": { - "node": "^18 || ^20" - } - }, "node_modules/@aurodesignsystem/auro-library": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/@aurodesignsystem/auro-library/-/auro-library-2.6.3.tgz", @@ -241,13 +241,13 @@ } }, "node_modules/@aurodesignsystem/auro-menu": { - "version": "3.12.0-beta.1", - "resolved": "https://registry.npmjs.org/@aurodesignsystem/auro-menu/-/auro-menu-3.12.0-beta.1.tgz", - "integrity": "sha512-Vkwk3OQZlFx0Sc65uwGO/Ve0hi0gdTXy27Uoj2VwDhl4FrVEaQWblxOn3SxeJuKqOd8A2MLX+2kdORSesRUIrw==", + "version": "3.12.0-beta.2", + "resolved": "https://registry.npmjs.org/@aurodesignsystem/auro-menu/-/auro-menu-3.12.0-beta.2.tgz", + "integrity": "sha512-kxJv+pVbU14CtzTTBmdMDoTUSKWS24rg/OYonQKH44W1TIgYhJn7L6Ocx0MVANl2C+tDSOl9CYp1jglFIwhi1w==", "hasInstallScript": true, "dependencies": { "chalk": "^5.3.0", - "lit": "^3.1.4", + "lit": "^3.2.0", "mark.js": "8.11.0" }, "engines": { diff --git a/package.json b/package.json index 2dc4967..21ae151 100644 --- a/package.json +++ b/package.json @@ -20,10 +20,10 @@ "node": "^18.x || ^20.x" }, "dependencies": { - "@aurodesignsystem/auro-dropdown": "^3.0.0-beta.2", + "@aurodesignsystem/auro-dropdown": "^3.0.0-beta.3", "@aurodesignsystem/auro-formvalidation": "^1.0.3", "@aurodesignsystem/auro-library": "^2.6.3", - "@aurodesignsystem/auro-menu": "^3.12.0-beta.1", + "@aurodesignsystem/auro-menu": "^3.12.0-beta.2", "chalk": "^5.3.0", "lit-element": "^4.1.0", "lit-html": "^3.2.0" @@ -145,7 +145,7 @@ "build:ci": "npm-run-all sweep build:release", "build:api": "wca analyze 'src/auro-select.js' --outFiles docs/api.md", "build:dev:assets": "npm-run-all build:sass:component postCss:component sass:render build:docs", - "build:docs": "node scripts/generateDocs.mjs", + "build:docs": "node ./node_modules/@aurodesignsystem/auro-library/scripts/build/generateDocs.mjs", "build:sass": "npm-run-all build:sass:component postCss:component sass:render", "build:sass:component": "sass --no-source-map src:src", "build:version": "node scripts/version.mjs", @@ -157,10 +157,10 @@ "dist:js": "copyfiles -u 1 -V './src/**/*.js' ./dist", "esLint": "./node_modules/.bin/eslint src/**/*.js --ignore-pattern 'src/**/*Version.js'", "linters": "npm-run-all scssLint esLint", - "preCommit": "node scripts/pre-commit.mjs", - "postCss:component": "node scripts/postCss.mjs", + "preCommit": "node ./node_modules/@aurodesignsystem/auro-library/scripts/build/pre-commit.mjs", + "postCss:component": "node ./node_modules/@aurodesignsystem/auro-library/scripts/build/postCss.mjs", "postinstall": "node packageScripts/postinstall.mjs", - "sass:render": "sass-render src/*.css -t ./scripts/staticStyles-template.js", + "sass:render": "sass-render src/*.css -t ./node_modules/@aurodesignsystem/auro-library/scripts/build/staticStyles-template.js", "serve": "web-dev-server --open demo/ --node-resolve --watch", "sweep": "rm -rf ./demo/css ./dist | rm ./src/*.css ./src/*-css.js", "test": "wtr --coverage", diff --git a/scripts/generateDocs.mjs b/scripts/generateDocs.mjs deleted file mode 100644 index 1f0526b..0000000 --- a/scripts/generateDocs.mjs +++ /dev/null @@ -1,210 +0,0 @@ -import path from 'path'; -import markdownMagic from 'markdown-magic'; -import fs from 'fs'; -import https from 'https'; - -const __dirname = new URL('.', import.meta.url).pathname; - -const readmeTemplateUrl = 'https://raw.githubusercontent.com/AlaskaAirlines/WC-Generator/master/componentDocs/README.md'; -const dirDocTemplates = './docTemplates'; -const readmeFilePath = dirDocTemplates + '/README.md'; - -/** - * Extract NPM, NAMESPACE and NAME from package.json - */ - -function nameExtraction() { - const packageJson = fs.readFileSync('package.json', 'utf8', function(err, data) { - if (err) { - console.log('ERROR: Unable to read package.json file', err); - } - }) - - let pName = JSON.parse(packageJson).name; - let pVersion = JSON.parse(packageJson).version; - let pdtVersion = JSON.parse(packageJson).peerDependencies['\@aurodesignsystem/design-tokens'].substring(1) - let wcssVersion = JSON.parse(packageJson).peerDependencies['\@aurodesignsystem/webcorestylesheets'].substring(1) - - let npmStart = pName.indexOf('@'); - let namespaceStart = pName.indexOf('/'); - let nameStart = pName.indexOf('-'); - - let result = { - 'npm': pName.substring(npmStart, namespaceStart), - 'namespace': pName.substring(namespaceStart + 1, nameStart), - 'namespaceCap': pName.substring(namespaceStart + 1)[0].toUpperCase() + pName.substring(namespaceStart + 2, nameStart), - 'name': pName.substring(nameStart + 1), - 'nameCap': pName.substring(nameStart + 1)[0].toUpperCase() + pName.substring(nameStart + 2), - 'version': pVersion, - 'tokensVersion': pdtVersion, - 'wcssVersion': wcssVersion - }; - - return result; - } - -/** - * Replace all instances of [npm], [name], [Name], [namespace] and [Namespace] accordingly - */ - -function formatTemplateFileContents(content, destination) { - let nameExtractionData = nameExtraction(); - let result = content; - - /** - * Replace placeholder strings - */ - result = result.replace(/\[npm]/g, nameExtractionData.npm); - result = result.replace(/\[name](?!\()/g, nameExtractionData.name); - result = result.replace(/\[Name](?!\()/g, nameExtractionData.nameCap); - result = result.replace(/\[namespace]/g, nameExtractionData.namespace); - result = result.replace(/\[Namespace]/g, nameExtractionData.namespaceCap); - result = result.replace(/\[Version]/g, nameExtractionData.version); - result = result.replace(/\[dtVersion]/g, nameExtractionData.tokensVersion); - result = result.replace(/\[wcssVersion]/g, nameExtractionData.wcssVersion); - - /** - * Cleanup line breaks - */ - 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. - result = result.replace(/>(\r\n|\r|\n){2,}/g, '>\r\n'); // Remove empty lines directly after a closing html tag. - result = result.replace(/>(\r\n|\r|\n)```/g, '>\r\n\r\n```'); // Ensure an empty line before code samples. - 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. - result = result.replace(/([^(\r\n|\r|\n)])(\r?\n|\r(?!\n))+#/g, "$1\r\n\r\n#"); // Ensure empty line before header sections. - - /** - * Write the result to the destination file - */ - fs.writeFileSync(destination, result, { encoding: 'utf8'}); -} - -function formatApiTableContents(content, destination) { - const nameExtractionData = nameExtraction(); - const wcName = nameExtractionData.namespace + '-' + nameExtractionData.name; - - let result = content; - - result = result - .replace(/\r\n|\r|\n####\s`([a-zA-Z]*)`/g, `\r\n#### \`$1\`back to top`) - .replace(/\r\n|\r|\n\|\s`([a-zA-Z]*)`/g, '\r\n| [$1](#$1)') - .replace(/\| \[\]\(#\)/g, ""); - - fs.writeFileSync(destination, result, { encoding: 'utf8'}); - - fs.readFile('./demo/api.md', 'utf8', function(err, data) { - formatTemplateFileContents(data, './demo/api.md'); - }); -} - -/** - * Compiles `./docTemplates/README.md` -> `./README.md` - */ - -function processReadme() { - const callback = function(updatedContent, outputConfig) { - - if (fs.existsSync('./README.md')) { - fs.readFile('./README.md', 'utf8', function(err, data) { - formatTemplateFileContents(data, './README.md'); - }); - } else { - console.log('ERROR: ./README.md file is missing'); - } - }; - - const config = { - matchWord: 'AURO-GENERATED-CONTENT', - outputDir: './' - }; - - const markdownPath = path.join(__dirname, '../docTemplates/README.md'); - - markdownMagic(markdownPath, config, callback); -} - -/** - * Compiles `./docs/partials/index.md` -> `./demo/index.md` - */ - -function processDemo() { - const callback = function(updatedContent, outputConfig) { - if (fs.existsSync('./demo/index.md')) { - fs.readFile('./demo/index.md', 'utf8', function(err, data) { - formatTemplateFileContents(data, './demo/index.md'); - }); - } else { - console.log('ERROR: ./demo/index.md file is missing'); - } - }; - - const configDemo = { - matchWord: 'AURO-GENERATED-CONTENT', - outputDir: './demo' - }; - - const markdownPath = path.join(__dirname, '../docs/partials/index.md'); - - markdownMagic(markdownPath, configDemo, callback); -} - -/** - * Compiles `./docs/partials/api.md` -> `./demo/api.md` - */ - -function processApiExamples() { - const callback = function(updatedContent, outputConfig) { - if (fs.existsSync('./demo/api.md')) { - fs.readFile('./demo/api.md', 'utf8', function(err, data) { - formatApiTableContents(data, './demo/api.md'); - }); - } else { - console.log('ERROR: ./demo/api.md file is missing'); - } - }; - - const config = { - matchWord: 'AURO-GENERATED-CONTENT', - outputDir: './demo' - }; - - const markdownPath = path.join(__dirname, '../docs/partials/api.md'); - - markdownMagic(markdownPath, config, callback); -} - -/** - * Copy README.md template from static source - * */ - -function copyReadmeLocally() { - - if (!fs.existsSync(dirDocTemplates)){ - fs.mkdirSync(dirDocTemplates); - } - - if (!fs.existsSync(readmeFilePath)) { - fs.writeFile(readmeFilePath, '', function(err) { - if(err) { - console.log('ERROR: Unable to create README.md file.', err); - } - }); - } - - https.get(readmeTemplateUrl, function(response) { - let writeTemplate = response.pipe(fs.createWriteStream(readmeFilePath)); - - writeTemplate.on('finish', () => { - processReadme(); - }); - - }).on('error', (err) => { - console.log('ERROR: Unable to fetch README.md file from server.', err); - }); -} - -/** - * Run all the actual document generation - */ -copyReadmeLocally(); -processApiExamples(); -processDemo(); diff --git a/scripts/postCss.mjs b/scripts/postCss.mjs deleted file mode 100644 index 71d5759..0000000 --- a/scripts/postCss.mjs +++ /dev/null @@ -1,41 +0,0 @@ -import autoprefixer from 'autoprefixer'; -import postcss from 'postcss'; -import comments from 'postcss-discard-comments'; -import path from 'path'; -import fs from 'fs'; -const __dirname = new URL('.', import.meta.url).pathname; -const directoryPath = path.join(__dirname, '../src'); - -/** - * Default postCSS run - */ -fs.readdir(directoryPath, function (err, files) { - //handling error - if (err) { - return console.log('Unable to scan directory: ' + err); - } - //listing all files using forEach - files.forEach(function (file) { - if (file.includes(".css")) { - standardProcessor(file); - } - }); -}); - -/** - * The standardProcessor function applies tokens for fallback selectors - * and completes a post cleanup. - * @param {string} file - */ -function standardProcessor(file) { - fs.readFile(`src/${file}`, (err, css) => { - postcss([autoprefixer, comments]) - .use(comments({ - remove: function(comment) { return comment[0] == "@"; } - })) - .process(css, { from: `src/${file}`, to: `src/${file}` }) - .then(result => { - fs.writeFile(`src/${file}`, result.css, () => true) - }) - }); -} diff --git a/scripts/pre-commit.mjs b/scripts/pre-commit.mjs deleted file mode 100644 index 781e45b..0000000 --- a/scripts/pre-commit.mjs +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -import chalk from 'chalk'; -console.log(chalk.hex('#ffd200')(` - -╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ──────────────────────────────╮`) + chalk.hex('#f26135')(` - - Are you familiar with Auro's Definition of Done? - - Please be sure to review`) + chalk.hex('#ffd200')(` - https://auro.alaskaair.com/definition-of-done`) + chalk.hex('#f26135')(` - before submitting your pull request - to ensure that you are compliant.`) + chalk.hex('#ffd200')(` - -╰─────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ -`) -); diff --git a/scripts/staticStyles-template.js b/scripts/staticStyles-template.js deleted file mode 100644 index 2c41743..0000000 --- a/scripts/staticStyles-template.js +++ /dev/null @@ -1,2 +0,0 @@ -import {css} from 'lit'; -export default css`<% content %>`; diff --git a/src/auro-select.js b/src/auro-select.js index 3515ac8..9cb4e26 100644 --- a/src/auro-select.js +++ b/src/auro-select.js @@ -82,6 +82,9 @@ export class AuroSelect extends LitElement { */ const versioning = new AuroDependencyVersioning(); + /** + * @private + */ this.dropdownTag = versioning.generateTag('auro-dropdown', dropdownVersion, AuroDropdown); } diff --git a/src/dropdownVersion.js b/src/dropdownVersion.js index edcd620..262b55c 100644 --- a/src/dropdownVersion.js +++ b/src/dropdownVersion.js @@ -1 +1 @@ -export default '3.0.0-beta.2' \ No newline at end of file +export default '3.0.0-beta.3' \ No newline at end of file