diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index f2181a4ce..000000000 --- a/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -node_modules -lib -packages/mjml-core/src/types* -type.js -test-html-attributes.js -test.js -babel.config.js diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 3223c1842..000000000 --- a/.eslintrc +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": [ - "airbnb-base", - "prettier" - ], - "parser": "babel-eslint", - "rules": { - "comma-dangle": [ 2, "always-multiline" ], - "semi": [ 2, "never" ], - "no-mixed-operators": 0, - "no-shadow": 0, - "no-param-reassign": 0, - "no-restricted-syntax": 0 - }, - "env": { - "node": true - } -} diff --git a/.github/workflows/mjml-workflow.yml b/.github/workflows/mjml-workflow.yml index 06a6a6011..19ec1fb05 100644 --- a/.github/workflows/mjml-workflow.yml +++ b/.github/workflows/mjml-workflow.yml @@ -1,26 +1,36 @@ -name: Mjml CI -on: [push, pull_request] +name: CI + +on: + push: + branches: + - main + pull_request: + +permissions: + actions: read + contents: read + jobs: - build: + main: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.x, 22.x] steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 with: - node-version: ${{ matrix.node-version }} - - name: Run linting & tests - run: | - yarn install - yarn build - yarn lint - cd packages/mjml-parser-xml - yarn install - yarn test --debug - cd ../../packages/mjml-core - yarn test --debug - cd ../../packages/mjml - yarn test + fetch-depth: 0 + + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + # This enables task distribution via Nx Cloud + # Run this command as early as possible, before dependencies are installed + # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun + - run: bunx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build" + + - run: bun install --no-cache + - uses: nrwl/nx-set-shas@v4 + + # Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud + # - run: bun nx-cloud record -- echo Hello World + # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected + - run: bun nx affected -t lint test build diff --git a/.gitignore b/.gitignore index 5d16e1ae4..4f4d87b1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,42 @@ -.DS_Store -*.log -.idea/ -lib +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +dist +tmp +/out-tsc + +# dependencies node_modules -test.html -/**/npmignore + +# IDEs and editors +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# misc +/.sass-cache +/connect.lock +/coverage +/libpeerconnection.log +npm-debug.log +yarn-error.log +testem.log +/typings + +# System Files +.DS_Store +Thumbs.db + +.nx/cache +.nx/workspace-data diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index ec6d3cdd7..000000000 --- a/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -package.json diff --git a/.prettierrc b/.prettierrc index 82463d954..353215abd 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,8 @@ { - "printWidth": 80, "semi": false, + "trailingComma": "none", "singleQuote": true, - "trailingComma": "all" + "printWidth": 120, + "tabWidth": 2, + "arrowParens": "avoid" } diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..bf14b26d3 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + + "nrwl.angular-console" + ] +} diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index 04c3ed896..000000000 --- a/babel.config.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - presets: [['@babel/env', { - targets: { node: '10' }, - include: ['transform-classes'], - }]], - plugins: [ - '@babel/proposal-class-properties', - [ - '@babel/transform-runtime', - { - // by default the plugin assumes we have 7.0.0-beta.0 version of runtime - // and inline all missing helpers instead of requiring them - version: require('@babel/plugin-transform-runtime/package.json') - .version, - }, - ], - 'add-module-exports', - 'lodash', - ], -} diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 000000000..87daa9ddb Binary files /dev/null and b/bun.lockb differ diff --git a/ci.yml b/ci.yml new file mode 100644 index 000000000..12d2dd59a --- /dev/null +++ b/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +permissions: + actions: read + contents: read + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + + # This enables task distribution via Nx Cloud + # Run this command as early as possible, before dependencies are installed + # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun + - run: bunx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build" + + + - run: bun install --no-cache + - uses: nrwl/nx-set-shas@v4 + + # Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud + # - run: bun nx-cloud record -- echo Hello World + # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected + - run: bun nx affected -t lint test build diff --git a/lerna.json b/lerna.json deleted file mode 100644 index 0395eb4b8..000000000 --- a/lerna.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "packages": [ - "packages/*" - ], - "command": { - "publish": { - "exact": true - } - }, - "npmClient": "yarn", - "useWorkspaces": true, - "version": "5.0.0-alpha.6" -} diff --git a/main.js b/main.js new file mode 100644 index 000000000..4b8950c24 --- /dev/null +++ b/main.js @@ -0,0 +1 @@ +// ? diff --git a/nx.json b/nx.json new file mode 100644 index 000000000..5cc2f90c5 --- /dev/null +++ b/nx.json @@ -0,0 +1,13 @@ +{ + "extends": "nx/presets/npm.json", + "$schema": "./node_modules/nx/schemas/nx-schema.json", + "nxCloudId": "66ffc8309ce17251260acaf7", + "namedInputs": { + "sharedGlobals": [ + "{workspaceRoot}/.github/workflows/ci.yml" + ], + "default": [ + "sharedGlobals" + ] + } +} diff --git a/package.json b/package.json old mode 100755 new mode 100644 index 5be26fb74..f8f0bdfd4 --- a/package.json +++ b/package.json @@ -1,34 +1,18 @@ { - "name": "mjml-master", + "name": "mjml-next", + "version": "0.0.0", + "license": "MIT", + "main": "main.js", + "scripts": {}, "private": true, - "scripts": { - "build:watch": "lerna run build --parallel -- -- -w", - "build": "lerna run build --parallel --ignore mjml-browser", - "build-browser": "cd packages/mjml-browser && yarn build", - "lint": "eslint .", - "lint:fix": "eslint . --fix", - "postinstall": "lerna bootstrap", - "prettier": "prettier --write \"packages/**/{src,bin}/**/*.?(js|json)\"" + "dependencies": { + "typescript": "^5.6.2" + }, + "devDependencies": { + "@nx/js": "19.8.3", + "nx": "19.8.3" }, "workspaces": [ "packages/*" - ], - "devDependencies": { - "@babel/core": "^7.8.7", - "@babel/plugin-proposal-class-properties": "^7.8.3", - "@babel/plugin-transform-runtime": "^7.8.3", - "@babel/preset-env": "^7.8.7", - "@babel/register": "^7.8.6", - "babel-eslint": "^10.1.0", - "babel-plugin-add-module-exports": "^1.0.2", - "babel-plugin-lodash": "^3.3.4", - "eslint": "^6.8.0", - "eslint-config-airbnb-base": "^14.1.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-import": "^2.21.1", - "lerna": "^3.22.1", - "open": "^7.3.0", - "prettier": "^3.2.4", - "rimraf": "^3.0.2" - } + ] } diff --git a/packages/.gitkeep b/packages/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/packages/mjml-accordion/package.json b/packages/mjml-accordion/package.json index 317adc277..90847ca3e 100644 --- a/packages/mjml-accordion/package.json +++ b/packages/mjml-accordion/package.json @@ -1,8 +1,8 @@ { "name": "mjml-accordion", "description": "mjml-accordion", - "version": "5.0.0-alpha.6", - "main": "lib/index.js", + "version": "5.0.0-alpha.4", + "main": "src/index.js", "files": [ "lib" ], @@ -16,17 +16,8 @@ "url": "https://github.com/mjmlio/mjml/issues" }, "homepage": "https://mjml.io", - "scripts": { - "clean": "rimraf lib", - "build": "babel src --out-dir lib --root-mode upward" - }, "dependencies": { - "@babel/runtime": "^7.23.9", "lodash": "^4.17.21", - "mjml-core": "5.0.0-alpha.6" - }, - "devDependencies": { - "@babel/cli": "^7.8.4", - "rimraf": "^3.0.2" + "mjml-core": "5.0.0-alpha.4" } } diff --git a/packages/mjml-accordion/project.json b/packages/mjml-accordion/project.json new file mode 100644 index 000000000..6ca5ea733 --- /dev/null +++ b/packages/mjml-accordion/project.json @@ -0,0 +1,21 @@ +{ + "name": "mjml-accordion", + "targets": { + "build": { + "executor": "@nrwl/node:package", + "options": { + "outputPath": "dist/packages/mjml-accordion", + "tsConfig": "packages/mjml-accordion/tsconfig.json", + "packageJson": "packages/mjml-accordion/package.json", + "main": "packages/mjml-accordion/src/index.ts", + "assets": ["packages/mjml-accordion/README.md"] + } + }, + "release": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish dist/packages/mjml-accordion --access public" + } + } + } +} \ No newline at end of file diff --git a/packages/mjml-accordion/src/AccordionElement.js b/packages/mjml-accordion/src/AccordionElement.js index 1475a5f83..62d5fe642 100644 --- a/packages/mjml-accordion/src/AccordionElement.js +++ b/packages/mjml-accordion/src/AccordionElement.js @@ -1,6 +1,6 @@ import { BodyComponent } from 'mjml-core' import { find } from 'lodash' -import conditionalTag from 'mjml-core/lib/helpers/conditionalTag' +import conditionalTag from 'mjml-core/src/helpers/conditionalTag' import AccordionText from './AccordionText' import AccordionTitle from './AccordionTitle' @@ -18,31 +18,31 @@ export default class MjAccordionElement extends BodyComponent { 'icon-wrapped-alt': 'string', 'icon-unwrapped-url': 'string', 'icon-unwrapped-alt': 'string', - 'icon-position': 'enum(left,right)', + 'icon-position': 'enum(left,right)' } static defaultAttributes = { title: { img: { width: '32px', - height: '32px', - }, - }, + height: '32px' + } + } } getStyles() { return { td: { padding: '0px', - 'background-color': this.getAttribute('background-color'), + 'background-color': this.getAttribute('background-color') }, label: { 'font-size': '13px', - 'font-family': this.getAttribute('font-family'), + 'font-family': this.getAttribute('font-family') }, input: { - display: 'none', - }, + display: 'none' + } } } @@ -57,13 +57,13 @@ export default class MjAccordionElement extends BodyComponent { 'icon-wrapped-url', 'icon-wrapped-alt', 'icon-unwrapped-url', - 'icon-unwrapped-alt', + 'icon-unwrapped-alt' ].reduce( (res, val) => ({ ...res, - [val]: this.getAttribute(val), + [val]: this.getAttribute(val) }), - {}, + {} ) const result = [] @@ -72,8 +72,8 @@ export default class MjAccordionElement extends BodyComponent { result.push( new AccordionTitle({ attributes: childrenAttr, - context: this.getChildContext(), - }).render(), + context: this.getChildContext() + }).render() ) } @@ -83,8 +83,8 @@ export default class MjAccordionElement extends BodyComponent { result.push( new AccordionText({ attributes: childrenAttr, - context: this.getChildContext(), - }).render(), + context: this.getChildContext() + }).render() ) } @@ -95,14 +95,14 @@ export default class MjAccordionElement extends BodyComponent { return `