Compare commits

...

5 Commits

Author SHA1 Message Date
Sidharth Vinod
84a2bf1b58 chore: Fixing eslint 2023-08-22 22:54:09 +05:30
Sidharth Vinod
ef28eb8be1 Merge branch 'next' into sidv/runCodeCov
* next:
  remove duplicate `@types/d3-scale` dev dependency
  chore: Move liveReload code into script.
  Fix minify undefined
  chore: Fix minify
  Fix import
  chore: Fix outfile names
  chore: Add analyzer comment
  chore: Split chunks into folders
  chore: Split chunks into folders
  chore: Add defaultOptions to server
  chore: Split chunks into folders
  chore: IIFE to cSpell
  chore: Minor comments
  chore: Replace Date.now with console.time
  chore: Build at start
  chore: Add build times to live reload
  chore: Add live-reload
  chore: Remove @vitest/coverage-c8
  chore: Add esbuild (Breaking change) mermaid.min.js and mermaid.js will now be IIFE instead of UMD.
2023-08-22 22:49:46 +05:30
Sidharth Vinod
c78573d9aa chore: Bump some deps 2023-08-22 19:01:15 +05:30
Sidharth Vinod
1aeef62db1 chore: Fix variable name, bump cypress action version 2023-08-22 19:00:46 +05:30
Sidharth Vinod
d639d5bdc9 debug: Codecov 2023-08-22 16:53:59 +05:30
15 changed files with 1070 additions and 601 deletions

View File

@@ -82,8 +82,8 @@ export function generateDefaults(mermaidConfigSchema: JSONSchemaType<MermaidConf
`schema for subconfig ${key} does not have valid defaults! Errors were ${JSON.stringify( `schema for subconfig ${key} does not have valid defaults! Errors were ${JSON.stringify(
validate.errors, validate.errors,
undefined, undefined,
2 2,
)}` )}`,
); );
} }
} }
@@ -95,8 +95,8 @@ export function generateDefaults(mermaidConfigSchema: JSONSchemaType<MermaidConf
`Mermaid config JSON Schema does not have valid defaults! Errors were ${JSON.stringify( `Mermaid config JSON Schema does not have valid defaults! Errors were ${JSON.stringify(
validate.errors, validate.errors,
undefined, undefined,
2 2,
)}` )}`,
); );
} }

View File

@@ -26,7 +26,7 @@ const buildPackage = async (entryName: keyof typeof packageOptions) => {
// mermaid.js // mermaid.js
{ ...iifeOptions }, { ...iifeOptions },
// mermaid.min.js // mermaid.min.js
{ ...iifeOptions, minify: true, metafile: shouldVisualize } { ...iifeOptions, minify: true, metafile: shouldVisualize },
); );
} }

View File

@@ -6,7 +6,7 @@ import { context } from 'esbuild';
import chokidar from 'chokidar'; import chokidar from 'chokidar';
const mermaidCtx = await context( const mermaidCtx = await context(
getBuildConfig({ ...defaultOptions, minify: false, core: false, entryName: 'mermaid' }) getBuildConfig({ ...defaultOptions, minify: false, core: false, entryName: 'mermaid' }),
); );
const mermaidIIFECtx = await context( const mermaidIIFECtx = await context(
getBuildConfig({ getBuildConfig({
@@ -15,7 +15,7 @@ const mermaidIIFECtx = await context(
core: false, core: false,
entryName: 'mermaid', entryName: 'mermaid',
format: 'iife', format: 'iife',
}) }),
); );
const externalCtx = await context( const externalCtx = await context(
getBuildConfig({ getBuildConfig({
@@ -23,10 +23,10 @@ const externalCtx = await context(
minify: false, minify: false,
core: false, core: false,
entryName: 'mermaid-example-diagram', entryName: 'mermaid-example-diagram',
}) }),
); );
const zenumlCtx = await context( const zenumlCtx = await context(
getBuildConfig({ ...defaultOptions, minify: false, core: false, entryName: 'mermaid-zenuml' }) getBuildConfig({ ...defaultOptions, minify: false, core: false, entryName: 'mermaid-zenuml' }),
); );
const contexts = [mermaidCtx, mermaidIIFECtx, externalCtx, zenumlCtx]; const contexts = [mermaidCtx, mermaidIIFECtx, externalCtx, zenumlCtx];

View File

@@ -69,7 +69,7 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => {
if (core) { if (core) {
const { dependencies } = JSON.parse( const { dependencies } = JSON.parse(
readFileSync(resolve(__dirname, `../packages/${packageName}/package.json`), 'utf-8') readFileSync(resolve(__dirname, `../packages/${packageName}/package.json`), 'utf-8'),
); );
// Core build is used to generate file without bundled dependencies. // Core build is used to generate file without bundled dependencies.
// This is used by downstream projects to bundle dependencies themselves. // This is used by downstream projects to bundle dependencies themselves.

View File

@@ -48,6 +48,8 @@ module.exports = {
'no-prototype-builtins': 'off', 'no-prototype-builtins': 'off',
'no-unused-vars': 'off', 'no-unused-vars': 'off',
'cypress/no-async-tests': 'off', 'cypress/no-async-tests': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error', '@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/ban-ts-comment': [ '@typescript-eslint/ban-ts-comment': [

View File

@@ -30,7 +30,7 @@ jobs:
# Install NPM dependencies, cache them correctly # Install NPM dependencies, cache them correctly
# and run all Cypress tests # and run all Cypress tests
- name: Cypress run - name: Cypress run
uses: cypress-io/github-action@v4 uses: cypress-io/github-action@v6
id: cypress id: cypress
# If CYPRESS_RECORD_KEY is set, run in parallel on all containers # If CYPRESS_RECORD_KEY is set, run in parallel on all containers
# Otherwise (e.g. if running from fork), we run on a single container only # Otherwise (e.g. if running from fork), we run on a single container only
@@ -44,14 +44,19 @@ jobs:
parallel: ${{ secrets.CYPRESS_RECORD_KEY != '' }} parallel: ${{ secrets.CYPRESS_RECORD_KEY != '' }}
env: env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
VITEST_COVERAGE: true VITE_COVERAGE: true
CYPRESS_COVERAGE: true
CYPRESS_COMMIT: ${{ github.sha }} CYPRESS_COMMIT: ${{ github.sha }}
- name: Check coverage files
run: |
ls -lh ./coverage
ls -lh ./coverage/cypress
- name: Upload Coverage to Codecov - name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
# Run step only pushes to develop and pull_requests
if: ${{ steps.cypress.conclusion == 'success' && (github.event_name == 'pull_request' || github.ref == 'refs/heads/develop')}}
with: with:
files: coverage/cypress/lcov.info files: ./coverage/cypress/lcov.info
flags: e2e flags: e2e
name: mermaid-codecov name: mermaid-codecov
fail_ci_if_error: false fail_ci_if_error: false

View File

@@ -43,8 +43,6 @@ jobs:
- name: Upload Coverage to Codecov - name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
# Run step only pushes to develop and pull_requests
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' }}
with: with:
files: ./coverage/vitest/lcov.info files: ./coverage/vitest/lcov.info
flags: unit flags: unit

View File

@@ -32,7 +32,7 @@ const visualizerOptions = (packageName: string, core = false): PluginOption[] =>
template: chartType as TemplateType, template: chartType as TemplateType,
gzipSize: true, gzipSize: true,
brotliSize: true, brotliSize: true,
}) as PluginOption }) as PluginOption,
); );
}; };

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />

View File

@@ -139,6 +139,6 @@ if (typeof document !== 'undefined') {
void contentLoaded().finally(markRendered); void contentLoaded().finally(markRendered);
} }
}, },
false false,
); );
} }

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />

View File

@@ -60,37 +60,37 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@applitools/eyes-cypress": "^3.33.1", "@applitools/eyes-cypress": "^3.37.0",
"@commitlint/cli": "^17.6.1", "@commitlint/cli": "^17.6.1",
"@commitlint/config-conventional": "^17.6.1", "@commitlint/config-conventional": "^17.6.1",
"@cspell/eslint-plugin": "^6.31.1", "@cspell/eslint-plugin": "^7.0.1",
"@cypress/code-coverage": "^3.10.7", "@cypress/code-coverage": "^3.11.0",
"@rollup/plugin-typescript": "^11.1.1", "@rollup/plugin-typescript": "^11.1.2",
"@types/cors": "^2.8.13", "@types/cors": "^2.8.13",
"@types/eslint": "^8.37.0", "@types/eslint": "^8.44.2",
"@types/express": "^4.17.17", "@types/express": "^4.17.17",
"@types/js-yaml": "^4.0.5", "@types/js-yaml": "^4.0.5",
"@types/jsdom": "^21.1.1", "@types/jsdom": "^21.1.1",
"@types/lodash": "^4.14.194", "@types/lodash": "^4.14.194",
"@types/mdast": "^3.0.11", "@types/mdast": "^3.0.11",
"@types/node": "^18.16.0", "@types/node": "^18.16.0",
"@types/prettier": "^2.7.2", "@types/prettier": "^3.0.0",
"@types/rollup-plugin-visualizer": "^4.2.1", "@types/rollup-plugin-visualizer": "^4.2.1",
"@typescript-eslint/eslint-plugin": "^5.59.0", "@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^5.59.0", "@typescript-eslint/parser": "^6.4.1",
"@vitest/coverage-v8": "^0.34.0", "@vitest/coverage-v8": "^0.34.2",
"@vitest/spy": "^0.34.0", "@vitest/spy": "^0.34.0",
"@vitest/ui": "^0.34.0", "@vitest/ui": "^0.34.0",
"ajv": "^8.12.0", "ajv": "^8.12.0",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"concurrently": "^8.0.1", "concurrently": "^8.0.1",
"cors": "^2.8.5", "cors": "^2.8.5",
"cypress": "^12.10.0", "cypress": "^12.17.4",
"cypress-image-snapshot": "^4.0.1", "cypress-image-snapshot": "^4.0.1",
"esbuild": "^0.19.0", "esbuild": "^0.19.2",
"eslint": "^8.39.0", "eslint": "^8.47.0",
"eslint-config-prettier": "^8.8.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-cypress": "^2.13.2", "eslint-plugin-cypress": "^2.14.0",
"eslint-plugin-html": "^7.1.0", "eslint-plugin-html": "^7.1.0",
"eslint-plugin-jest": "^27.2.1", "eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jsdoc": "^46.0.0", "eslint-plugin-jsdoc": "^46.0.0",
@@ -111,16 +111,16 @@
"nyc": "^15.1.0", "nyc": "^15.1.0",
"path-browserify": "^1.0.1", "path-browserify": "^1.0.1",
"pnpm": "^8.6.8", "pnpm": "^8.6.8",
"prettier": "^2.8.8", "prettier": "^3.0.2",
"prettier-plugin-jsdoc": "^0.4.2", "prettier-plugin-jsdoc": "^0.4.2",
"rimraf": "^5.0.0", "rimraf": "^5.0.0",
"rollup-plugin-visualizer": "^5.9.2", "rollup-plugin-visualizer": "^5.9.2",
"start-server-and-test": "^2.0.0", "start-server-and-test": "^2.0.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5.1.3", "typescript": "^5.1.6",
"vite": "^4.3.9", "vite": "^4.4.9",
"vite-plugin-istanbul": "^4.1.0", "vite-plugin-istanbul": "^5.0.0",
"vitest": "^0.34.0" "vitest": "^0.34.2"
}, },
"volta": { "volta": {
"node": "18.17.1" "node": "18.17.1"

View File

@@ -24,6 +24,7 @@ import _Ajv2019, { type JSONSchemaType } from 'ajv/dist/2019.js';
// Workaround for wrong AJV types, see // Workaround for wrong AJV types, see
// https://github.com/ajv-validator/ajv/issues/2132#issuecomment-1290409907 // https://github.com/ajv-validator/ajv/issues/2132#issuecomment-1290409907
// @ts-ignore Incorrect types
const Ajv2019 = _Ajv2019 as unknown as typeof _Ajv2019.default; const Ajv2019 = _Ajv2019 as unknown as typeof _Ajv2019.default;
// !!! -- The config.type.js file is created by this script -- !!! // !!! -- The config.type.js file is created by this script -- !!!

1557
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,20 +5,24 @@
* (i.e. the root of the Mermaid project). * (i.e. the root of the Mermaid project).
*/ */
import { readFileSync, writeFileSync } from 'node:fs'; import { readFile, writeFile } from 'node:fs/promises';
import prettier from 'prettier'; import prettier from 'prettier';
const main = async () => {
const filepath = './cSpell.json'; const filepath = './cSpell.json';
const cSpell: { words: string[] } = JSON.parse(readFileSync(filepath, 'utf8')); const cSpell: { words: string[] } = JSON.parse(await readFile(filepath, 'utf8'));
cSpell.words = [...new Set(cSpell.words.map((word) => word.toLowerCase()))]; cSpell.words = [...new Set(cSpell.words.map((word) => word.toLowerCase()))];
cSpell.words.sort((a, b) => a.localeCompare(b)); cSpell.words.sort((a, b) => a.localeCompare(b));
const prettierConfig = prettier.resolveConfig.sync(filepath) ?? {}; const prettierConfig = (await prettier.resolveConfig(filepath)) ?? {};
writeFileSync( await writeFile(
filepath, filepath,
prettier.format(JSON.stringify(cSpell), { await prettier.format(JSON.stringify(cSpell), {
...prettierConfig, ...prettierConfig,
filepath, filepath,
}) }),
); );
};
void main();