mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
Fixes for app and prettier (#1028)
* fix for app * prettier * fix for app * prettier * update prettierignore * prettier * prettier * fix prism vendoring
This commit is contained in:
@@ -1,18 +1,23 @@
|
|||||||
|
# Files are relative to .prettierignore at the root of this monorepo.
|
||||||
|
# <https://github.com/prettier/prettier-vscode/issues/1252>
|
||||||
|
|
||||||
*.hbs
|
*.hbs
|
||||||
*.md
|
*.md
|
||||||
!docs/docs/patterns/**/*.md
|
!packages/webawesome/docs/docs/patterns/**/*.md
|
||||||
docs/docs/patterns/blog-news/post-list.md
|
docs/docs/patterns/blog-news/post-list.md
|
||||||
.cache
|
**/*/.cache
|
||||||
.github
|
.github
|
||||||
cspell.json
|
cspell.json
|
||||||
dist
|
packages/**/*/dist
|
||||||
docs/search.json
|
packages/**/*/dist-cdn
|
||||||
src/components/icon/icons
|
packages/**/*/docs/search.json
|
||||||
src/react/index.ts
|
packages/**/*/src/components/icon/icons
|
||||||
|
packages/**/*/src/react/index.ts
|
||||||
|
**/*/package.json
|
||||||
|
**/*/package-lock.json
|
||||||
|
**/*/tsconfig.json
|
||||||
|
**/*/tsconfig.prod.json
|
||||||
node_modules
|
node_modules
|
||||||
package.json
|
|
||||||
package-lock.json
|
packages/**/*/_site
|
||||||
tsconfig.json
|
packages/webawesome/docs/assets/scripts/prism-downloaded.js
|
||||||
cdn
|
|
||||||
_site
|
|
||||||
docs/assets/scripts/prism-downloaded.js
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { customElementVsCodePlugin } from 'custom-element-vs-code-integration';
|
|||||||
// import { customElementVuejsPlugin } from 'custom-element-vuejs-integration';
|
// import { customElementVuejsPlugin } from 'custom-element-vuejs-integration';
|
||||||
import { parse } from 'comment-parser';
|
import { parse } from 'comment-parser';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import * as path from 'node:path';
|
||||||
import { pascalCase } from 'pascal-case';
|
import { pascalCase } from 'pascal-case';
|
||||||
import * as url from 'url';
|
import * as url from 'url';
|
||||||
import * as path from "node:path"
|
|
||||||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
||||||
|
|
||||||
const packageData = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
|
const packageData = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
|
||||||
@@ -186,4 +186,3 @@ export default {
|
|||||||
// })
|
// })
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import * as fs from 'node:fs';
|
||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
import * as fs from "node:fs"
|
|
||||||
import { anchorHeadingsPlugin } from './_utils/anchor-headings.js';
|
import { anchorHeadingsPlugin } from './_utils/anchor-headings.js';
|
||||||
import { codeExamplesPlugin } from './_utils/code-examples.js';
|
import { codeExamplesPlugin } from './_utils/code-examples.js';
|
||||||
import { copyCodePlugin } from './_utils/copy-code.js';
|
import { copyCodePlugin } from './_utils/copy-code.js';
|
||||||
@@ -41,7 +41,7 @@ export default async function (eleventyConfig) {
|
|||||||
*/
|
*/
|
||||||
const passThroughExtensions = ['js', 'css', 'png', 'svg', 'jpg', 'mp4'];
|
const passThroughExtensions = ['js', 'css', 'png', 'svg', 'jpg', 'mp4'];
|
||||||
|
|
||||||
const docsDir = path.join(process.env.BASE_DIR || ".", 'docs');
|
const docsDir = path.join(process.env.BASE_DIR || '.', 'docs');
|
||||||
const passThrough = [...passThroughExtensions.map(ext => path.join(docsDir, '**/*.' + ext))];
|
const passThrough = [...passThroughExtensions.map(ext => path.join(docsDir, '**/*.' + ext))];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,9 +176,8 @@ export default async function (eleventyConfig) {
|
|||||||
// eleventyConfig.addPlugin(formatCodePlugin());
|
// eleventyConfig.addPlugin(formatCodePlugin());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
let assetsDir = path.join(process.env.BASE_DIR || 'docs', 'assets');
|
||||||
let assetsDir = path.join(process.env.BASE_DIR || "docs", "assets")
|
fs.cpSync(assetsDir, path.join(eleventyConfig.directories.output, 'assets'), { recursive: true });
|
||||||
fs.cpSync(assetsDir, path.join(eleventyConfig.directories.output, "assets"), { recursive: true })
|
|
||||||
|
|
||||||
for (let glob of passThrough) {
|
for (let glob of passThrough) {
|
||||||
eleventyConfig.addPassthroughCopy(glob);
|
eleventyConfig.addPassthroughCopy(glob);
|
||||||
@@ -210,7 +209,6 @@ export default async function (eleventyConfig) {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
markdownTemplateEngine: 'njk',
|
markdownTemplateEngine: 'njk',
|
||||||
dir: {
|
dir: {
|
||||||
@@ -219,5 +217,4 @@ export const config = {
|
|||||||
layouts: '_layouts',
|
layouts: '_layouts',
|
||||||
},
|
},
|
||||||
templateFormats: ['njk', 'md'],
|
templateFormats: ['njk', 'md'],
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
* @module components Fetches components from custom-elements.json and exposes them in a saner format.
|
* @module components Fetches components from custom-elements.json and exposes them in a saner format.
|
||||||
*/
|
*/
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { join, dirname, resolve } from 'path';
|
import { dirname, join, resolve } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
const customElementsJSON = process.env.DIST_DIR
|
const customElementsJSON = process.env.DIST_DIR
|
||||||
? join(process.env.DIST_DIR, "custom-elements.json")
|
? join(process.env.DIST_DIR, 'custom-elements.json')
|
||||||
: resolve(__dirname, '../../dist/custom-elements.json')
|
: resolve(__dirname, '../../dist/custom-elements.json');
|
||||||
|
|
||||||
const manifest = JSON.parse(readFileSync(customElementsJSON), 'utf-8');
|
const manifest = JSON.parse(readFileSync(customElementsJSON), 'utf-8');
|
||||||
|
|
||||||
@@ -76,4 +76,3 @@ components.sort((a, b) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export default components;
|
export default components;
|
||||||
|
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0
|
|||||||
Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/};
|
Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/};
|
||||||
Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp("(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])"),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp("((?:^|[^$\\w\\xA0-\\uFFFF.\"'\\])\\s]|\\b(?:return|yield))\\s*)/(?:(?:\\[(?:[^\\]\\\\\r\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\r\n])+/[dgimyus]{0,7}|(?:\\[(?:[^[\\]\\\\\r\n]|\\\\.|\\[(?:[^[\\]\\\\\r\n]|\\\\.|\\[(?:[^[\\]\\\\\r\n]|\\\\.)*\\])*\\])*\\]|\\\\.|[^/\\\\\\[\r\n])+/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\\s|/\\*(?:[^*]|\\*(?!/))*\\*/)*(?:$|[\r\n,.;:})\\]]|//))"),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute("on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)","javascript")),Prism.languages.js=Prism.languages.javascript;
|
Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp("(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])"),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp("((?:^|[^$\\w\\xA0-\\uFFFF.\"'\\])\\s]|\\b(?:return|yield))\\s*)/(?:(?:\\[(?:[^\\]\\\\\r\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\r\n])+/[dgimyus]{0,7}|(?:\\[(?:[^[\\]\\\\\r\n]|\\\\.|\\[(?:[^[\\]\\\\\r\n]|\\\\.|\\[(?:[^[\\]\\\\\r\n]|\\\\.)*\\])*\\])*\\]|\\\\.|[^/\\\\\\[\r\n])+/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\\s|/\\*(?:[^*]|\\*(?!/))*\\*/)*(?:$|[\r\n,.;:})\\]]|//))"),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute("on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)","javascript")),Prism.languages.js=Prism.languages.javascript;
|
||||||
!function(){if("undefined"!=typeof Prism){var n,s,a="";Prism.plugins.customClass={add:function(s){n=s},map:function(n){s="function"==typeof n?n:function(s){return n[s]||s}},prefix:function(n){a=n||""},apply:t},Prism.hooks.add("wrap",(function(e){if(n){var u=n({content:e.content,type:e.type,language:e.language});Array.isArray(u)?e.classes.push.apply(e.classes,u):u&&e.classes.push(u)}(s||a)&&(e.classes=e.classes.map((function(n){return t(n,e.language)})))}))}function t(n,t){return a+(s?s(n,t):n)}}();
|
!function(){if("undefined"!=typeof Prism){var n,s,a="";Prism.plugins.customClass={add:function(s){n=s},map:function(n){s="function"==typeof n?n:function(s){return n[s]||s}},prefix:function(n){a=n||""},apply:t},Prism.hooks.add("wrap",(function(e){if(n){var u=n({content:e.content,type:e.type,language:e.language});Array.isArray(u)?e.classes.push.apply(e.classes,u):u&&e.classes.push(u)}(s||a)&&(e.classes=e.classes.map((function(n){return t(n,e.language)})))}))}function t(n,t){return a+(s?s(n,t):n)}}();
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
"test:component": "CSR_ONLY=\"true\" web-test-runner -- --watch --group",
|
"test:component": "CSR_ONLY=\"true\" web-test-runner -- --watch --group",
|
||||||
"test:contrast": "cd src/styles/color && node contrast.test.js",
|
"test:contrast": "cd src/styles/color && node contrast.test.js",
|
||||||
"test:watch": "web-test-runner --watch --group default",
|
"test:watch": "web-test-runner --watch --group default",
|
||||||
"prettier": "prettier --check --log-level=warn --ignore-path=\"../../.prettierignore\".",
|
"prettier": "prettier --check --log-level=warn --ignore-path=\"../../.prettierignore\" .",
|
||||||
"prettier:fix": "prettier --write --log-level=warn --ignore-path=\"../../.prettierignore\" .",
|
"prettier:fix": "prettier --write --log-level=warn --ignore-path=\"../../.prettierignore\" .",
|
||||||
"spellcheck": "cspell \"**/*.{js,ts,json,html,css,md}\" --no-progress --config=\"../../cspell.json\"",
|
"spellcheck": "cspell \"**/*.{js,ts,json,html,css,md}\" --no-progress --config=\"../../cspell.json\"",
|
||||||
"verify": "npm run prettier && npm run build && npm run test",
|
"verify": "npm run prettier && npm run build && npm run test",
|
||||||
|
|||||||
@@ -8,19 +8,12 @@ import { replace } from 'esbuild-plugin-replace';
|
|||||||
import { mkdir, readFile } from 'fs/promises';
|
import { mkdir, readFile } from 'fs/promises';
|
||||||
import getPort, { portNumbers } from 'get-port';
|
import getPort, { portNumbers } from 'get-port';
|
||||||
import { globby } from 'globby';
|
import { globby } from 'globby';
|
||||||
import ora from 'ora';
|
|
||||||
import { dirname, join, relative } from 'node:path';
|
import { dirname, join, relative } from 'node:path';
|
||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
import copy from 'recursive-copy';
|
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import {
|
import ora from 'ora';
|
||||||
getCdnDir,
|
import copy from 'recursive-copy';
|
||||||
getDistDir,
|
import { getCdnDir, getDistDir, getDocsDir, getRootDir, getSiteDir, runScript } from './utils.js';
|
||||||
getDocsDir,
|
|
||||||
getRootDir,
|
|
||||||
getSiteDir,
|
|
||||||
runScript,
|
|
||||||
} from './utils.js';
|
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
const isDeveloping = process.argv.includes('--develop');
|
const isDeveloping = process.argv.includes('--develop');
|
||||||
@@ -42,19 +35,18 @@ let buildContexts = {
|
|||||||
/**
|
/**
|
||||||
* @param {BuildOptions} [options={}]
|
* @param {BuildOptions} [options={}]
|
||||||
*/
|
*/
|
||||||
export async function build (options = {}) {
|
export async function build(options = {}) {
|
||||||
if (!options.watchedSrcDirectories) {
|
if (!options.watchedSrcDirectories) {
|
||||||
options.watchedSrcDirectories = ['src']
|
options.watchedSrcDirectories = ['src'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.watchedDocsDirectories) {
|
if (!options.watchedDocsDirectories) {
|
||||||
options.watchedDocsDirectories = [getDocsDir()]
|
options.watchedDocsDirectories = [getDocsDir()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the full build.
|
* Runs the full build.
|
||||||
*/
|
*/
|
||||||
async function buildAll() {
|
async function buildAll() {
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
|
|
||||||
@@ -92,8 +84,8 @@ export async function build (options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analyzes components and generates the custom elements manifest file.
|
* Analyzes components and generates the custom elements manifest file.
|
||||||
*/
|
*/
|
||||||
function generateManifest() {
|
function generateManifest() {
|
||||||
spinner.start('Generating CEM');
|
spinner.start('Generating CEM');
|
||||||
|
|
||||||
@@ -113,14 +105,14 @@ export async function build (options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates React wrappers for all components.
|
* Generates React wrappers for all components.
|
||||||
*/
|
*/
|
||||||
function generateReactWrappers() {
|
function generateReactWrappers() {
|
||||||
spinner.start('Generating React wrappers');
|
spinner.start('Generating React wrappers');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// need to run make-react from this directories.
|
// need to run make-react from this directories.
|
||||||
execSync(`node ${join(__dirname, "make-react.js")} --outdir "${getCdnDir()}"`, { stdio: 'inherit' });
|
execSync(`node ${join(__dirname, 'make-react.js')} --outdir "${getCdnDir()}"`, { stdio: 'inherit' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`\n\n${error.message}`);
|
console.error(`\n\n${error.message}`);
|
||||||
|
|
||||||
@@ -134,8 +126,8 @@ export async function build (options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies theme stylesheets to the dist.
|
* Copies theme stylesheets to the dist.
|
||||||
*/
|
*/
|
||||||
async function generateStyles() {
|
async function generateStyles() {
|
||||||
spinner.start('Copying stylesheets');
|
spinner.start('Copying stylesheets');
|
||||||
|
|
||||||
@@ -147,20 +139,20 @@ export async function build (options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs TypeScript to generate types.
|
* Runs TypeScript to generate types.
|
||||||
*/
|
*/
|
||||||
async function generateTypes() {
|
async function generateTypes() {
|
||||||
spinner.start('Running the TypeScript compiler');
|
spinner.start('Running the TypeScript compiler');
|
||||||
|
|
||||||
const cwd = process.cwd()
|
const cwd = process.cwd();
|
||||||
try {
|
try {
|
||||||
if (process.env.ROOT_DIR) {
|
if (process.env.ROOT_DIR) {
|
||||||
process.chdir(process.env.ROOT_DIR)
|
process.chdir(process.env.ROOT_DIR);
|
||||||
}
|
}
|
||||||
execSync(`tsc --project ./tsconfig.prod.json --outdir "${getCdnDir()}"`);
|
execSync(`tsc --project ./tsconfig.prod.json --outdir "${getCdnDir()}"`);
|
||||||
process.chdir(cwd)
|
process.chdir(cwd);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
process.chdir(cwd)
|
process.chdir(cwd);
|
||||||
if (!isDeveloping) {
|
if (!isDeveloping) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -173,12 +165,12 @@ export async function build (options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs esbuild to generate the final dist.
|
* Runs esbuild to generate the final dist.
|
||||||
*/
|
*/
|
||||||
async function generateBundle() {
|
async function generateBundle() {
|
||||||
spinner.start('Bundling with esbuild');
|
spinner.start('Bundling with esbuild');
|
||||||
|
|
||||||
const rootDir = process.env.ROOT_DIR || "."
|
const rootDir = process.env.ROOT_DIR || '.';
|
||||||
// Bundled config
|
// Bundled config
|
||||||
const config = {
|
const config = {
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
@@ -246,8 +238,8 @@ export async function build (options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Incrementally rebuilds the source files. Must be called only after `generateBundle()` has been called.
|
* Incrementally rebuilds the source files. Must be called only after `generateBundle()` has been called.
|
||||||
*/
|
*/
|
||||||
async function regenerateBundle() {
|
async function regenerateBundle() {
|
||||||
try {
|
try {
|
||||||
spinner.start('Re-bundling with esbuild');
|
spinner.start('Re-bundling with esbuild');
|
||||||
@@ -266,12 +258,12 @@ export async function build (options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the documentation site.
|
* Generates the documentation site.
|
||||||
*/
|
*/
|
||||||
async function generateDocs() {
|
async function generateDocs() {
|
||||||
/**
|
/**
|
||||||
* Used by the webawesome-app to skip doc generation since it will do its own.
|
* Used by the webawesome-app to skip doc generation since it will do its own.
|
||||||
*/
|
*/
|
||||||
if (process.env.SKIP_ELEVENTY === 'true') {
|
if (process.env.SKIP_ELEVENTY === 'true') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -375,19 +367,19 @@ export async function build (options = {}) {
|
|||||||
|
|
||||||
// TODO: Should probably listen for all of these instead of just "change"
|
// TODO: Should probably listen for all of these instead of just "change"
|
||||||
const watchEvents = [
|
const watchEvents = [
|
||||||
"change",
|
'change',
|
||||||
// "unlink",
|
// "unlink",
|
||||||
// "add"
|
// "add"
|
||||||
]
|
];
|
||||||
// Rebuild and reload when source files change
|
// Rebuild and reload when source files change
|
||||||
options.watchedSrcDirectories.forEach((dir) => {
|
options.watchedSrcDirectories.forEach(dir => {
|
||||||
const watcher = bs.watch(join(dir, "**", "!(*.test).*"))
|
const watcher = bs.watch(join(dir, '**', '!(*.test).*'));
|
||||||
|
|
||||||
watchEvents.forEach((evt) => {
|
watchEvents.forEach(evt => {
|
||||||
watcher.on(evt, handleWatchEvent(evt))
|
watcher.on(evt, handleWatchEvent(evt));
|
||||||
})
|
});
|
||||||
function handleWatchEvent (evt) {
|
function handleWatchEvent(evt) {
|
||||||
return async (filename) => {
|
return async filename => {
|
||||||
spinner.info(`File modified ${chalk.gray(`(${relative(getRootDir(), filename)})`)}`);
|
spinner.info(`File modified ${chalk.gray(`(${relative(getRootDir(), filename)})`)}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -401,8 +393,8 @@ export async function build (options = {}) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof options.onWatchEvent === "function") {
|
if (typeof options.onWatchEvent === 'function') {
|
||||||
await options.onWatchEvent(evt, filename)
|
await options.onWatchEvent(evt, filename);
|
||||||
}
|
}
|
||||||
await regenerateBundle();
|
await regenerateBundle();
|
||||||
|
|
||||||
@@ -427,29 +419,29 @@ export async function build (options = {}) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// Rebuild the docs and reload when the docs change
|
// Rebuild the docs and reload when the docs change
|
||||||
options.watchedDocsDirectories.forEach((dir) => {
|
options.watchedDocsDirectories.forEach(dir => {
|
||||||
const watcher = bs.watch(join(dir, "**", "*.*"))
|
const watcher = bs.watch(join(dir, '**', '*.*'));
|
||||||
|
|
||||||
watchEvents.forEach((evt) => {
|
watchEvents.forEach(evt => {
|
||||||
watcher.on(evt, handleWatchEvent(evt))
|
watcher.on(evt, handleWatchEvent(evt));
|
||||||
})
|
});
|
||||||
|
|
||||||
function handleWatchEvent (evt) {
|
function handleWatchEvent(evt) {
|
||||||
return async (filename) => {
|
return async filename => {
|
||||||
spinner.info(`File modified ${chalk.gray(`(${relative(getRootDir(), filename)})`)}`);
|
spinner.info(`File modified ${chalk.gray(`(${relative(getRootDir(), filename)})`)}`);
|
||||||
if (typeof options.onWatchEvent === "function") {
|
if (typeof options.onWatchEvent === 'function') {
|
||||||
await options.onWatchEvent(evt, filename)
|
await options.onWatchEvent(evt, filename);
|
||||||
}
|
}
|
||||||
await generateDocs();
|
await generateDocs();
|
||||||
reload();
|
reload();
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -468,22 +460,23 @@ export async function build (options = {}) {
|
|||||||
|
|
||||||
process.on('SIGINT', terminate);
|
process.on('SIGINT', terminate);
|
||||||
process.on('SIGTERM', terminate);
|
process.on('SIGTERM', terminate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://exploringjs.com/nodejs-shell-scripting/ch_nodejs-path.html#detecting-if-module-is-main
|
// https://exploringjs.com/nodejs-shell-scripting/ch_nodejs-path.html#detecting-if-module-is-main
|
||||||
// Detects if this was called via node scripts/build.js
|
// Detects if this was called via node scripts/build.js
|
||||||
function isRunAsMain () {
|
function isRunAsMain() {
|
||||||
if (import.meta.url.startsWith('file:')) { // (A)
|
if (import.meta.url.startsWith('file:')) {
|
||||||
|
// (A)
|
||||||
const modulePath = fileURLToPath(import.meta.url);
|
const modulePath = fileURLToPath(import.meta.url);
|
||||||
if (process.argv[1] === modulePath) { // (B)
|
if (process.argv[1] === modulePath) {
|
||||||
return true
|
// (B)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRunAsMain()) {
|
if (isRunAsMain()) {
|
||||||
await build()
|
await build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import Eleventy from '@11ty/eleventy';
|
import Eleventy from '@11ty/eleventy';
|
||||||
import { deleteAsync } from 'del';
|
import { deleteAsync } from 'del';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { getDocsDir, getSiteDir } from './utils.js';
|
import { getDocsDir, getEleventyConfigPath, getSiteDir } from './utils.js';
|
||||||
|
|
||||||
const elev = new Eleventy(getDocsDir(), getSiteDir(), {
|
const elev = new Eleventy(getDocsDir(), getSiteDir(), {
|
||||||
quietMode: true,
|
quietMode: true,
|
||||||
configPath: join(getDocsDir(), '.eleventy.js'),
|
configPath: getEleventyConfigPath(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
@@ -13,4 +13,3 @@ await deleteAsync(getSiteDir());
|
|||||||
|
|
||||||
// Write it
|
// Write it
|
||||||
await elev.write();
|
await elev.write();
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import { getAllComponents } from './shared.js';
|
|||||||
|
|
||||||
const { outdir } = commandLineArgs({ name: 'outdir', type: String });
|
const { outdir } = commandLineArgs({ name: 'outdir', type: String });
|
||||||
|
|
||||||
const reactDir = path.join(process.env.ROOT_DIR || ".", 'src', 'react');
|
const reactDir = path.join(process.env.ROOT_DIR || '.', 'src', 'react');
|
||||||
const srcDir = process.env.ROOT_DIR ? path.join(process.env.ROOT_DIR, "src") : "."
|
const srcDir = process.env.ROOT_DIR ? path.join(process.env.ROOT_DIR, 'src') : '.';
|
||||||
|
|
||||||
// Clear build directory
|
// Clear build directory
|
||||||
deleteSync(reactDir);
|
deleteSync(reactDir);
|
||||||
@@ -25,7 +25,7 @@ for await (const component of components) {
|
|||||||
const tagWithoutPrefix = component.tagName.replace(/^wa-/, '');
|
const tagWithoutPrefix = component.tagName.replace(/^wa-/, '');
|
||||||
const componentDir = path.join(reactDir, tagWithoutPrefix);
|
const componentDir = path.join(reactDir, tagWithoutPrefix);
|
||||||
const componentFile = path.join(componentDir, 'index.ts');
|
const componentFile = path.join(componentDir, 'index.ts');
|
||||||
const importPath = path.relative(srcDir, component.path)
|
const importPath = path.relative(srcDir, component.path);
|
||||||
|
|
||||||
// We only want to wrap wa- prefixed events, because the others are native
|
// We only want to wrap wa- prefixed events, because the others are native
|
||||||
const eventsToWrap = component.events?.filter(event => event.name.startsWith('wa-')) || [];
|
const eventsToWrap = component.events?.filter(event => event.name.startsWith('wa-')) || [];
|
||||||
@@ -81,4 +81,3 @@ for await (const component of components) {
|
|||||||
|
|
||||||
// Generate the index file
|
// Generate the index file
|
||||||
fs.writeFileSync(path.join(reactDir, 'index.ts'), index.join('\n'), 'utf8');
|
fs.writeFileSync(path.join(reactDir, 'index.ts'), index.join('\n'), 'utf8');
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export const getDistDir = () => process.env.DIST_DIR || join(getRootDir(), 'dist
|
|||||||
export const getCdnDir = () => process.env.CDN_DIR || join(getRootDir(), 'dist-cdn');
|
export const getCdnDir = () => process.env.CDN_DIR || join(getRootDir(), 'dist-cdn');
|
||||||
export const getDocsDir = () => process.env.DOCS_DIR || join(getRootDir(), 'docs');
|
export const getDocsDir = () => process.env.DOCS_DIR || join(getRootDir(), 'docs');
|
||||||
export const getSiteDir = () => process.env.SITE_DIR || join(getRootDir(), '_site');
|
export const getSiteDir = () => process.env.SITE_DIR || join(getRootDir(), '_site');
|
||||||
|
export const getEleventyConfigPath = () => process.env.ELEVENTY_CONFIG_PATH || join(getDocsDir(), '.eleventy.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a script and returns a promise that resolves with the content of stdout when the script exits or rejects with
|
* Runs a script and returns a promise that resolves with the content of stdout when the script exits or rejects with
|
||||||
@@ -57,4 +58,3 @@ export function runScript(scriptPath, args = [], options = {}) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,9 +108,9 @@ describe('<wa-radio-group>', () => {
|
|||||||
|
|
||||||
// TODO: Go back to clickOnElement when we can determine why CI is not cleaning up elements.
|
// TODO: Go back to clickOnElement when we can determine why CI is not cleaning up elements.
|
||||||
// await clickOnElement(secondRadio);
|
// await clickOnElement(secondRadio);
|
||||||
secondRadio.click()
|
secondRadio.click();
|
||||||
await secondRadio.updateComplete;
|
await secondRadio.updateComplete;
|
||||||
await radioGroup.updateComplete
|
await radioGroup.updateComplete;
|
||||||
|
|
||||||
expect(radioGroup.checkValidity()).to.be.true;
|
expect(radioGroup.checkValidity()).to.be.true;
|
||||||
expect(radioGroup.customStates.has('user-invalid')).to.be.false;
|
expect(radioGroup.customStates.has('user-invalid')).to.be.false;
|
||||||
@@ -135,7 +135,7 @@ describe('<wa-radio-group>', () => {
|
|||||||
|
|
||||||
// TODO: Go back to clickOnElement when we can determine why CI is not cleaning up elements.
|
// TODO: Go back to clickOnElement when we can determine why CI is not cleaning up elements.
|
||||||
// await clickOnElement(secondRadio);
|
// await clickOnElement(secondRadio);
|
||||||
secondRadio.click()
|
secondRadio.click();
|
||||||
await radioGroup.updateComplete;
|
await radioGroup.updateComplete;
|
||||||
radioGroup.value = '';
|
radioGroup.value = '';
|
||||||
await radioGroup.updateComplete;
|
await radioGroup.updateComplete;
|
||||||
|
|||||||
@@ -100,4 +100,3 @@ export function preventTurboFouce(timeout = 2000) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user