From ca3f4b3b6add3d0464aad407d9100f7ea5992667 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 21 Jun 2023 11:31:04 +0200 Subject: [PATCH 001/134] feat(packages/sui-bundler): add support to typescript --- packages/sui-bundler/bin/sui-bundler-dev.js | 7 +- .../loaders/linkLoaderConfigBuilder.js | 2 +- packages/sui-bundler/package.json | 9 +- packages/sui-bundler/shared/index.js | 2 +- .../sui-bundler/shared/module-rules-babel.js | 115 ++++++++++++++---- packages/sui-bundler/webpack.config.dev.js | 2 +- 6 files changed, 103 insertions(+), 34 deletions(-) diff --git a/packages/sui-bundler/bin/sui-bundler-dev.js b/packages/sui-bundler/bin/sui-bundler-dev.js index b2d29cb45..3d2e1b451 100755 --- a/packages/sui-bundler/bin/sui-bundler-dev.js +++ b/packages/sui-bundler/bin/sui-bundler-dev.js @@ -67,12 +67,7 @@ const start = async ({ } = {}) => { clearConsole() // Warn and crash if required files are missing - if ( - !checkRequiredFiles([ - path.join(config.context, 'index.html'), - path.join(config.context, 'app.js') - ]) - ) { + if (!checkRequiredFiles([path.join(config.context, 'index.html')])) { log.error( `โœ– Required files are missing, create and index.html and app.js inside your src folder.` ) diff --git a/packages/sui-bundler/loaders/linkLoaderConfigBuilder.js b/packages/sui-bundler/loaders/linkLoaderConfigBuilder.js index 166e4681e..775fecb45 100644 --- a/packages/sui-bundler/loaders/linkLoaderConfigBuilder.js +++ b/packages/sui-bundler/loaders/linkLoaderConfigBuilder.js @@ -49,7 +49,7 @@ module.exports = ({config, packagesToLink, linkAll}) => { * if neccesary */ const linkLoader = { - test: /\.(jsx?|scss)$/, + test: /\.(jsx?|tsx?|scss)$/, enforce: 'pre', // this will ensure is execute before transformations use: { loader: require.resolve('./LinkLoader'), diff --git a/packages/sui-bundler/package.json b/packages/sui-bundler/package.json index 4fc44938e..eb03be490 100644 --- a/packages/sui-bundler/package.json +++ b/packages/sui-bundler/package.json @@ -21,9 +21,11 @@ }, "homepage": "https://github.com/SUI-Components/sui/tree/master/packages/sui-bundler#readme", "dependencies": { - "@babel/core": "7.18.10", + "@babel/core": "7.21.8", "@s-ui/helpers": "1", "@s-ui/sass-loader": "1", + "@swc/core": "1.3.14", + "@swc/helpers": "0.4.12", "address": "1.2.0", "autoprefixer": "10.4.8", "babel-loader": "8.2.5", @@ -34,7 +36,7 @@ "css-minimizer-webpack-plugin": "4.0.0", "esbuild": "0.15.5", "escape-string-regexp": "4.0.0", - "fast-glob": "3.2.11", + "fast-glob": "3.2.12", "find-free-ports": "3.0.0", "html-webpack-plugin": "5.5.0", "https-browserify": "1.0.0", @@ -46,8 +48,9 @@ "stream-http": "3.2.0", "strip-ansi": "6.0.1", "style-loader": "3.3.1", + "swc-loader": "0.2.1", "url": "0.11.0", - "webpack": "5.74.0", + "webpack": "5.82.1", "webpack-dev-server": "4.10.0", "webpack-manifest-plugin": "5.0.0", "webpack-node-externals": "3.0.0" diff --git a/packages/sui-bundler/shared/index.js b/packages/sui-bundler/shared/index.js index a112101ea..2c9c59415 100644 --- a/packages/sui-bundler/shared/index.js +++ b/packages/sui-bundler/shared/index.js @@ -1,6 +1,6 @@ const {config} = require('./config.js') -exports.MAIN_ENTRY_POINT = './app.js' +exports.MAIN_ENTRY_POINT = './app' exports.config = config exports.cleanList = list => list.filter(Boolean) diff --git a/packages/sui-bundler/shared/module-rules-babel.js b/packages/sui-bundler/shared/module-rules-babel.js index d3bd48f0c..8a64c5e8f 100644 --- a/packages/sui-bundler/shared/module-rules-babel.js +++ b/packages/sui-bundler/shared/module-rules-babel.js @@ -1,3 +1,5 @@ +/* eslint-disable no-console */ +const fs = require('fs-extra') const path = require('path') const {config} = require('./index.js') @@ -5,28 +7,97 @@ const EXCLUDED_FOLDERS_REGEXP = new RegExp( `node_modules(?!${path.sep}@s-ui(${path.sep}studio)(${path.sep}workbench)?${path.sep}src)` ) -module.exports = ({isServer = false, supportLegacyBrowsers = true} = {}) => ({ - test: /\.jsx?$/, - exclude: EXCLUDED_FOLDERS_REGEXP, - use: [ - { - loader: require.resolve('babel-loader'), - options: { - cacheDirectory: true, - cacheCompression: false, - babelrc: false, - compact: true, - presets: [ - [ - require.resolve('babel-preset-sui'), - { - isServer, - isModern: !supportLegacyBrowsers, - targets: config.targets +const getTSConfig = () => { + // Get TS config from the package dir. + const tsConfigPath = path.join(process.cwd(), 'tsconfig.json') + let tsConfig + + try { + if (fs.existsSync(tsConfigPath)) { + tsConfig = JSON.parse(fs.readFileSync(tsConfigPath, {encoding: 'utf8'})) + } + } catch (err) { + console.error(err) + } + + return tsConfig +} + +module.exports = ({isServer = false, supportLegacyBrowsers = true} = {}) => { + const tsConfig = getTSConfig() + // If TS config exists in root dir, set TypeScript as enabled. + const isTypeScriptEnabled = Boolean(tsConfig) + + return isTypeScriptEnabled + ? { + test: /\.(js|ts)x?$/, + exclude: EXCLUDED_FOLDERS_REGEXP, + use: [ + { + loader: require.resolve('swc-loader'), + options: { + minify: true, + jsc: { + parser: { + syntax: 'typescript', + tsx: true, + dynamicImport: true, + privateMethod: true, + functionBind: true, + exportDefaultFrom: true, + exportNamespaceFrom: true, + decorators: true, + decoratorsBeforeExport: true, + topLevelAwait: true, + importMeta: true + }, + transform: { + legacyDecorator: true, + react: { + useBuiltins: true, + runtime: 'automatic' + } + }, + target: 'es5', + loose: true, + externalHelpers: true + }, + env: { + targets: { + ie: '11' + }, + dynamicImport: true, + loose: true, + mode: 'entry', + coreJs: 3 + } } - ] + } ] } - } - ] -}) + : { + test: /\.jsx?$/, + exclude: EXCLUDED_FOLDERS_REGEXP, + use: [ + { + loader: require.resolve('babel-loader'), + options: { + cacheDirectory: true, + cacheCompression: false, + babelrc: false, + compact: true, + presets: [ + [ + require.resolve('babel-preset-sui'), + { + isServer, + isModern: !supportLegacyBrowsers, + targets: config.targets + } + ] + ] + } + } + ] + } +} diff --git a/packages/sui-bundler/webpack.config.dev.js b/packages/sui-bundler/webpack.config.dev.js index 2c501c8f8..8294e0d8f 100644 --- a/packages/sui-bundler/webpack.config.dev.js +++ b/packages/sui-bundler/webpack.config.dev.js @@ -47,7 +47,7 @@ const webpackConfig = { timers: false }, modules: ['node_modules', path.resolve(process.cwd())], - extensions: ['.js', '.json'] + extensions: ['.js', '.tsx', '.ts', '.json'] }, stats: 'errors-only', entry: cleanList([ From 2e4345526fe601518657921cceb0a50e6eda9af6 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 21 Jun 2023 11:31:45 +0200 Subject: [PATCH 002/134] feat(packages/sui-lint): add support to typescript --- packages/sui-lint/eslintrc.js | 12 ++++++++++-- packages/sui-lint/package.json | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/sui-lint/eslintrc.js b/packages/sui-lint/eslintrc.js index bf62bca3b..7a9f790e0 100644 --- a/packages/sui-lint/eslintrc.js +++ b/packages/sui-lint/eslintrc.js @@ -215,14 +215,22 @@ module.exports = { overrides: [ { files: ['**/*.+(ts|tsx)'], - extends: ['standard-with-typescript'], + extends: ['standard-with-typescript', 'standard-react', 'prettier'], parserOptions: { project: './tsconfig.json' }, rules: { 'no-return-await': RULES.OFF, 'prettier/prettier': RULES.OFF, - 'react/react-in-jsx-scope': RULES.OFF + 'react/react-in-jsx-scope': RULES.OFF, + 'react/no-unused-prop-types': RULES.OFF, + '@typescript-eslint/explicit-function-return-type': [ + RULES.OFF, + {allowTypedFunctionExpressions: false} + ], + 'chai-friendly/no-unused-expressions': RULES.ERROR, + '@typescript-eslint/no-unused-expressions': RULES.OFF, + '@typescript-eslint/return-await': RULES.OFF } }, { diff --git a/packages/sui-lint/package.json b/packages/sui-lint/package.json index 3023e77a1..98ef1817b 100644 --- a/packages/sui-lint/package.json +++ b/packages/sui-lint/package.json @@ -18,11 +18,12 @@ "@babel/eslint-parser": "7.18.9", "@babel/eslint-plugin": "7.18.10", "@s-ui/helpers": "1", - "@typescript-eslint/eslint-plugin": "5.33.0", + "@typescript-eslint/eslint-plugin": "5.57.0", "commander": "8.3.0", "eslint": "8.20.0", "eslint-config-prettier": "8.5.0", "eslint-config-standard": "17.0.0", + "eslint-config-standard-react": "13.0.0", "eslint-config-standard-with-typescript": "22.0.0", "eslint-plugin-chai-friendly": "0.7.2", "eslint-plugin-cypress": "2.12.1", From a4eb7cae0cb12254d34eacc41b61067928096fb0 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 21 Jun 2023 11:32:03 +0200 Subject: [PATCH 003/134] feat(packages/sui-react-context): add support to typescript --- packages/sui-react-context/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-react-context/package.json b/packages/sui-react-context/package.json index 4fab32f5d..1cb2a355f 100644 --- a/packages/sui-react-context/package.json +++ b/packages/sui-react-context/package.json @@ -1,9 +1,9 @@ { "name": "@s-ui/react-context", - "version": "1.8.0", + "version": "1.8.1-typescript.0", "description": "", "main": "lib/index", - "types": "src/index.tsx", + "types": "lib/index.d.ts", "scripts": { "lib": "rm -rf ./lib && tsc", "prepublishOnly": "npm run lib" From 486ff09111405f3b021b91bda6c11ed7e8823075 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 21 Jun 2023 11:32:35 +0200 Subject: [PATCH 004/134] feat(packages/sui-studio): add support to typescript --- packages/sui-studio/package.json | 4 ++-- packages/sui-studio/src/components/tryRequire.js | 8 ++++---- .../sui-studio/workbench/src/components/Root/index.js | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/sui-studio/package.json b/packages/sui-studio/package.json index 0420ce10c..fd1c68b94 100644 --- a/packages/sui-studio/package.json +++ b/packages/sui-studio/package.json @@ -11,9 +11,9 @@ "license": "MIT", "dependencies": { "@babel/cli": "7", - "@s-ui/bundler": "9", + "@s-ui/bundler": "typescript", "@s-ui/helpers": "1", - "@s-ui/react-context": "1", + "@s-ui/react-context": "typescript", "@s-ui/react-router": "1", "@s-ui/test": "8", "@testing-library/react": "10.4.9", diff --git a/packages/sui-studio/src/components/tryRequire.js b/packages/sui-studio/src/components/tryRequire.js index b18d0e0cd..3ab913429 100644 --- a/packages/sui-studio/src/components/tryRequire.js +++ b/packages/sui-studio/src/components/tryRequire.js @@ -62,8 +62,8 @@ export const importReactComponent = ({ importFile: () => { return import( /* webpackChunkName: "src-[request]" */ - /* webpackExclude: /\/node_modules\/(.*)\/src\/index.js$/ */ - `${__BASE_DIR__}/components/${category}/${component}/src/index.js` + /* webpackExclude: /\/node_modules\/(.*)\/src\/index$/ */ + `${__BASE_DIR__}/components/${category}/${component}/src/index` ) } }) @@ -74,8 +74,8 @@ const importDemo = ({category, component}) => importFile: () => import( /* webpackChunkName: "demo-[request]" */ - /* webpackExclude: /\/node_modules\/(.*)\/demo\/index.js$/ */ - `${__BASE_DIR__}/components/${category}/${component}/demo/index.js` + /* webpackExclude: /\/node_modules\/(.*)\/demo\/index$/ */ + `${__BASE_DIR__}/components/${category}/${component}/demo/index` ) }) diff --git a/packages/sui-studio/workbench/src/components/Root/index.js b/packages/sui-studio/workbench/src/components/Root/index.js index 8568ccb45..2ea0e4041 100644 --- a/packages/sui-studio/workbench/src/components/Root/index.js +++ b/packages/sui-studio/workbench/src/components/Root/index.js @@ -2,12 +2,12 @@ import {useState} from 'react' import PropTypes from 'prop-types' -import Header from '../Header/index.js' -import Select from '../Select/index.js' -import Test from '../Suite/index.js' +import Header from '../Header/index' +import Select from '../Select/index' +import Test from '../Suite/index' -const importComponent = () => import('component/index.js') -const importTest = () => import('test/index.test.js') +const importComponent = () => import('component/index') +const importTest = () => import('test/index.test') const getFromStorage = (key, defaultValue) => window.sessionStorage[key] || defaultValue From a39c57ef753aad32eebfe401c1e0f0660d5e2656 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 26 Jun 2023 12:13:14 +0200 Subject: [PATCH 005/134] chore(packages/sui-bundler): set new beta version --- packages/sui-bundler/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-bundler/package.json b/packages/sui-bundler/package.json index eb03be490..e0a121ee7 100644 --- a/packages/sui-bundler/package.json +++ b/packages/sui-bundler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/bundler", - "version": "9.38.0", + "version": "9.39.0-typescript.7", "description": "Config-free bundler for ES6 React apps.", "bin": { "sui-bundler": "./bin/sui-bundler.js" From c599db54157be81925a21085dcb367b77bedbb27 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 26 Jun 2023 12:14:33 +0200 Subject: [PATCH 006/134] chore(packages/sui-lint): set new ts tag --- packages/sui-lint/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-lint/package.json b/packages/sui-lint/package.json index 98ef1817b..6fef7e487 100644 --- a/packages/sui-lint/package.json +++ b/packages/sui-lint/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/lint", - "version": "4.33.0", + "version": "4.34.0-typescript.0", "description": "Linting CLI for sui packages", "main": "./bin/sui-lint.js", "bin": { From 505be81d45d3aa0e0bd0d4b8ef506097c35da911 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 26 Jun 2023 12:15:20 +0200 Subject: [PATCH 007/134] chore(packages/sui-react-context): set new ts tag --- packages/sui-react-context/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-react-context/package.json b/packages/sui-react-context/package.json index 1cb2a355f..801b43bad 100644 --- a/packages/sui-react-context/package.json +++ b/packages/sui-react-context/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/react-context", - "version": "1.8.1-typescript.0", + "version": "1.8.1-typescript.1", "description": "", "main": "lib/index", "types": "lib/index.d.ts", From cc743be7653c98ed9774bc6fe0e330b09c33efbd Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 26 Jun 2023 12:15:48 +0200 Subject: [PATCH 008/134] chore(packages/sui-studio): set new ts tag --- packages/sui-studio/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-studio/package.json b/packages/sui-studio/package.json index fd1c68b94..cd266d8d8 100644 --- a/packages/sui-studio/package.json +++ b/packages/sui-studio/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/studio", - "version": "11.33.0", + "version": "11.34.0-typescript.1", "description": "Develop, maintain and publish your SUI components.", "main": "index.js", "bin": { From 12224a58b94649bcbb7c87a519e9a5339d73b42b Mon Sep 17 00:00:00 2001 From: Carlos Villuendas Zambrana Date: Mon, 17 Jul 2023 14:38:47 +0200 Subject: [PATCH 009/134] feat(packages/sui-bundler): Add TS support for dev and build --- packages/sui-bundler/package.json | 6 ++- packages/sui-bundler/scripts/postinstall.js | 52 +++++++++++++++++++ packages/sui-bundler/shared/define.js | 23 ++++++-- .../sui-bundler/shared/module-rules-babel.js | 39 +------------- packages/sui-bundler/shared/resolve-alias.js | 24 ++++++--- packages/sui-bundler/tsconfig.json | 3 ++ packages/sui-bundler/webpack.config.prod.js | 2 +- 7 files changed, 99 insertions(+), 50 deletions(-) create mode 100755 packages/sui-bundler/scripts/postinstall.js create mode 100644 packages/sui-bundler/tsconfig.json diff --git a/packages/sui-bundler/package.json b/packages/sui-bundler/package.json index eb03be490..652c19cbf 100644 --- a/packages/sui-bundler/package.json +++ b/packages/sui-bundler/package.json @@ -1,12 +1,13 @@ { "name": "@s-ui/bundler", - "version": "9.38.0", + "version": "9.39.0-typescript.115", "description": "Config-free bundler for ES6 React apps.", "bin": { "sui-bundler": "./bin/sui-bundler.js" }, "main": "./bin/sui-bundler.js", "scripts": { + "postinstall": "node ./scripts/postinstall.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], @@ -22,8 +23,9 @@ "homepage": "https://github.com/SUI-Components/sui/tree/master/packages/sui-bundler#readme", "dependencies": { "@babel/core": "7.21.8", - "@s-ui/helpers": "1", + "@s-ui/helpers": "typescript", "@s-ui/sass-loader": "1", + "@s-ui/typescript-config": "typescript", "@swc/core": "1.3.14", "@swc/helpers": "0.4.12", "address": "1.2.0", diff --git a/packages/sui-bundler/scripts/postinstall.js b/packages/sui-bundler/scripts/postinstall.js new file mode 100755 index 000000000..e6610d501 --- /dev/null +++ b/packages/sui-bundler/scripts/postinstall.js @@ -0,0 +1,52 @@ +#!/usr/bin/env node + +const crypto = require('crypto') +const fs = require('fs-extra') +const path = require('path') +const {writeFile} = require('@s-ui/helpers/file.js') +const {dynamicPackage} = require('@s-ui/helpers/packages') + +const {INIT_CWD} = process.env +const tsConfigTemplate = `\ +{ + "extends": "@s-ui/bundler/tsconfig.json", + "compilerOptions": { + "rootDir": "./src" + }, + "include": ["src/**/*"] +}` + +const md5 = str => crypto.createHash('md5').update(str).digest('hex') +const TS_CONFIG_PATH = path.join(INIT_CWD, 'tsconfig.json') +const PACKAGE_JSON_CONFIG_PATH = path.join(INIT_CWD, 'package.json') + +const config = require(PACKAGE_JSON_CONFIG_PATH)?.config?.['sui-bundler'] || {} + +const shouldGenerateTSConfig = () => { + try { + if (!config?.type || config?.type !== 'typescript') return false + + if (!fs.existsSync(TS_CONFIG_PATH)) return true + + const tsConfigLocal = fs.readFileSync(TS_CONFIG_PATH, {encoding: 'utf8'}) + return md5(tsConfigLocal) !== md5(tsConfigTemplate) + } catch (err) { + return true + } +} + +async function main() { + console.log( + '๐Ÿ” [sui-bundler postinstall] Checking if tsconfig.json is up to date...' + ) + if (!shouldGenerateTSConfig()) { + console.log('โœ… [sui-bundler postinstall] tsconfig.json is up to date') + process.exit(0) + } + await writeFile(TS_CONFIG_PATH, tsConfigTemplate) + await dynamicPackage('typescript') + console.log( + 'โŒ [sui-bundler postinstall] tsconfig.json was not up to date, so we updated it' + ) +} +main() diff --git a/packages/sui-bundler/shared/define.js b/packages/sui-bundler/shared/define.js index 242a361b5..d19795e35 100644 --- a/packages/sui-bundler/shared/define.js +++ b/packages/sui-bundler/shared/define.js @@ -6,9 +6,24 @@ if (process.platform === 'win32') { process.env.PWD = process.cwd() } -module.exports = (vars = {}) => - new webpack.DefinePlugin({ +const {MAGIC_STRINGS = '{}'} = process.env + +let magic +try { + magic = JSON.parse(MAGIC_STRINGS) +} catch (err) { + magic = {} +} + +module.exports = (vars = {}) => { + const definitions = { __DEV__: false, __BASE_DIR__: JSON.stringify(process.env.PWD), - ...vars - }) + ...vars, + ...Object.fromEntries( + Object.entries(magic).map(([key, value]) => [key, JSON.stringify(value)]) + ) + } + + return new webpack.DefinePlugin(definitions) +} diff --git a/packages/sui-bundler/shared/module-rules-babel.js b/packages/sui-bundler/shared/module-rules-babel.js index 8a64c5e8f..443ea8084 100644 --- a/packages/sui-bundler/shared/module-rules-babel.js +++ b/packages/sui-bundler/shared/module-rules-babel.js @@ -2,6 +2,7 @@ const fs = require('fs-extra') const path = require('path') const {config} = require('./index.js') +const {getSWCConfig} = require('@s-ui/typescript-config') const EXCLUDED_FOLDERS_REGEXP = new RegExp( `node_modules(?!${path.sep}@s-ui(${path.sep}studio)(${path.sep}workbench)?${path.sep}src)` @@ -35,43 +36,7 @@ module.exports = ({isServer = false, supportLegacyBrowsers = true} = {}) => { use: [ { loader: require.resolve('swc-loader'), - options: { - minify: true, - jsc: { - parser: { - syntax: 'typescript', - tsx: true, - dynamicImport: true, - privateMethod: true, - functionBind: true, - exportDefaultFrom: true, - exportNamespaceFrom: true, - decorators: true, - decoratorsBeforeExport: true, - topLevelAwait: true, - importMeta: true - }, - transform: { - legacyDecorator: true, - react: { - useBuiltins: true, - runtime: 'automatic' - } - }, - target: 'es5', - loose: true, - externalHelpers: true - }, - env: { - targets: { - ie: '11' - }, - dynamicImport: true, - loose: true, - mode: 'entry', - coreJs: 3 - } - } + options: getSWCConfig({isModern: false, isTypeScript: true}) } ] } diff --git a/packages/sui-bundler/shared/resolve-alias.js b/packages/sui-bundler/shared/resolve-alias.js index ddd15521a..ebb700fa0 100644 --- a/packages/sui-bundler/shared/resolve-alias.js +++ b/packages/sui-bundler/shared/resolve-alias.js @@ -1,5 +1,6 @@ const path = require('path') const {config} = require('./config.js') +const fs = require('fs') const {PWD} = process.env @@ -11,22 +12,33 @@ const {PWD} = process.env */ const defaultPackagesToAlias = [ 'react', + 'react-dom', 'react-router-dom', + 'react/jsx-dev-runtime', + 'react/jsx-runtime', '@s-ui/pde', '@s-ui/react-context', '@s-ui/react-router' ] -const createAliasPath = pkgName => - path.resolve(path.join(PWD, `./node_modules/${pkgName}`)) +const createAliasPath = pkgName => { + const PWDNodeModules = path.join(PWD, './node_modules') + if (fs.existsSync(PWDNodeModules)) + return path.resolve(path.join(PWDNodeModules, pkgName)) -const mustPackagesToAlias = { - 'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js', - 'react/jsx-runtime': 'react/jsx-runtime.js' + try { + return require.resolve(pkgName).replace(/\/index\.js$/, '') + } catch (e) { + return '' + } } +const mustPackagesToAlias = {} + exports.defaultAlias = Object.fromEntries( - defaultPackagesToAlias.map(pkgName => [pkgName, createAliasPath(pkgName)]) + defaultPackagesToAlias + .map(pkgName => [pkgName, createAliasPath(pkgName)]) + .filter(([, path]) => path) ) const aliasFromConfig = config.alias diff --git a/packages/sui-bundler/tsconfig.json b/packages/sui-bundler/tsconfig.json new file mode 100644 index 000000000..754330a94 --- /dev/null +++ b/packages/sui-bundler/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "@s-ui/typescript-config/tsconfig.json" +} diff --git a/packages/sui-bundler/webpack.config.prod.js b/packages/sui-bundler/webpack.config.prod.js index 3c933dab1..525bd82b0 100644 --- a/packages/sui-bundler/webpack.config.prod.js +++ b/packages/sui-bundler/webpack.config.prod.js @@ -54,7 +54,7 @@ const webpackConfig = { context: path.resolve(CWD, 'src'), resolve: { alias: {...aliasFromConfig}, - extensions: ['.js', '.json'], + extensions: ['.js', '.json', '.ts', '.tsx'], modules: ['node_modules', path.resolve(CWD)], fallback: { assert: false, From dbfded8342e96add990b323337e54b1d34cd6a2b Mon Sep 17 00:00:00 2001 From: Carlos Villuendas Zambrana Date: Mon, 17 Jul 2023 14:39:24 +0200 Subject: [PATCH 010/134] feat(packages/sui-helpers): Add dynamicPackage --- packages/sui-helpers/package.json | 2 +- packages/sui-helpers/packages.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/sui-helpers/package.json b/packages/sui-helpers/package.json index 710286d8d..3ef52141b 100644 --- a/packages/sui-helpers/package.json +++ b/packages/sui-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/helpers", - "version": "1.38.0", + "version": "1.38.0-typescript.1", "description": "A set of internal helpers used by sui-related packages.", "author": "", "dependencies": { diff --git a/packages/sui-helpers/packages.js b/packages/sui-helpers/packages.js index 7a2f3cd3f..6905bf147 100644 --- a/packages/sui-helpers/packages.js +++ b/packages/sui-helpers/packages.js @@ -65,9 +65,23 @@ const resolveLazyNPMBin = async (binPath, pkg, cwd = process.cwd()) => { ).then(resolvePkgBin) } } +const dynamicPackage = async (name, {version} = {}) => { + const packageName = version ? `${name}@${version}` : name + + try { + await getSpawnPromise('npm', ['explain', packageName]) + } catch (error) { + if (error.exitCode === 1) { + await getSpawnPromise('npm', ['install', packageName, '--no-save']) + } + } + + return import(packageName).then(module => module.default) +} module.exports = { getPackageJson, getPackagesPaths, - resolveLazyNPMBin + resolveLazyNPMBin, + dynamicPackage } From a5c8730a271c9271c6882d81fe64349b3af778e2 Mon Sep 17 00:00:00 2001 From: Carlos Villuendas Zambrana Date: Mon, 17 Jul 2023 14:39:56 +0200 Subject: [PATCH 011/134] feat(packages/sui-lint): Add support to parse TS files --- packages/sui-lint/eslintrc.js | 3 ++- packages/sui-lint/package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/sui-lint/eslintrc.js b/packages/sui-lint/eslintrc.js index 7a9f790e0..f25d88611 100644 --- a/packages/sui-lint/eslintrc.js +++ b/packages/sui-lint/eslintrc.js @@ -216,12 +216,13 @@ module.exports = { { files: ['**/*.+(ts|tsx)'], extends: ['standard-with-typescript', 'standard-react', 'prettier'], + parser: '@typescript-eslint/parser', parserOptions: { project: './tsconfig.json' }, rules: { 'no-return-await': RULES.OFF, - 'prettier/prettier': RULES.OFF, + 'prettier/prettier': [RULES.ERROR, prettierOptions], 'react/react-in-jsx-scope': RULES.OFF, 'react/no-unused-prop-types': RULES.OFF, '@typescript-eslint/explicit-function-return-type': [ diff --git a/packages/sui-lint/package.json b/packages/sui-lint/package.json index 98ef1817b..913153646 100644 --- a/packages/sui-lint/package.json +++ b/packages/sui-lint/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/lint", - "version": "4.33.0", + "version": "4.33.0-typescript.10", "description": "Linting CLI for sui packages", "main": "./bin/sui-lint.js", "bin": { From 75d688244571731d1ccf9d7eeb128bf30ee09b0b Mon Sep 17 00:00:00 2001 From: Carlos Villuendas Zambrana Date: Mon, 17 Jul 2023 14:42:35 +0200 Subject: [PATCH 012/134] feat(packages/sui-studio): Use MAGIC_STRING to support sui-bundler with TS --- packages/sui-studio/bin/sui-studio.js | 30 ++++++++++++++++++- packages/sui-studio/package.json | 2 +- .../sui-studio/src/components/layout/index.js | 2 +- .../sui-studio/src/components/tryRequire.js | 5 ++-- packages/sui-studio/src/components/utils.js | 21 ++----------- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/packages/sui-studio/bin/sui-studio.js b/packages/sui-studio/bin/sui-studio.js index 75c4309cb..b28b95712 100755 --- a/packages/sui-studio/bin/sui-studio.js +++ b/packages/sui-studio/bin/sui-studio.js @@ -10,6 +10,33 @@ const copyGlobals = require('./helpers/copyGlobals.js') program.version(version, ' --version') +const listOfComponents = () => { + const fg = require('fast-glob') + const path = require('path') + + const folders = fg.sync('components/*/*', { + deep: 3, + onlyDirectories: true + }) + const components = folders.map(folder => { + const [, category, component] = folder.split(path.sep) + return {category, component} + }) + return components +} + +const config = () => { + const path = require('path') + const {config = {}} = require(path.join(process.cwd(), 'package.json')) + console.log(path.join(process.cwd(), 'package.json')) + return config['sui-studio'] || {} +} + +process.env.MAGIC_STRINGS = JSON.stringify({ + __SUI_STUDIO_COMPONENTS_LIST__: listOfComponents(), + __SUI_STUDIO_CONFIG__: config() +}) + program .command('start') .alias('s') @@ -22,7 +49,8 @@ program const devServerExec = require.resolve('@s-ui/bundler/bin/sui-bundler-dev') const args = ['-c', path.join(__dirname, '..', 'src')] getSpawnPromise(devServerExec, args, { - shell: false + shell: false, + env: process.env }).then(process.exit, process.exit) }) diff --git a/packages/sui-studio/package.json b/packages/sui-studio/package.json index fd1c68b94..381340530 100644 --- a/packages/sui-studio/package.json +++ b/packages/sui-studio/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/studio", - "version": "11.33.0", + "version": "11.34.0-typescript.2", "description": "Develop, maintain and publish your SUI components.", "main": "index.js", "bin": { diff --git a/packages/sui-studio/src/components/layout/index.js b/packages/sui-studio/src/components/layout/index.js index 809db869f..65fbd4579 100644 --- a/packages/sui-studio/src/components/layout/index.js +++ b/packages/sui-studio/src/components/layout/index.js @@ -1,4 +1,4 @@ -import React, {useEffect, useState, useRef} from 'react' +import React, {useEffect, useRef, useState} from 'react' import cx from 'classnames' import PropTypes from 'prop-types' diff --git a/packages/sui-studio/src/components/tryRequire.js b/packages/sui-studio/src/components/tryRequire.js index 3ab913429..d9f766277 100644 --- a/packages/sui-studio/src/components/tryRequire.js +++ b/packages/sui-studio/src/components/tryRequire.js @@ -82,12 +82,13 @@ const importDemo = ({category, component}) => export const importGlobals = () => { // we use a variable for the file so Webpack // could safe fail if the file doesn't exist - const globalsFile = 'globals.js' + // const globalsFile = 'globals.js' return safeImport({ importFile: () => import( /* webpackInclude: /\/components\/globals.js$/ */ - `${__BASE_DIR__}/components/${globalsFile}` + /* webpackExclude: /*.md$/ */ + `${__BASE_DIR__}/components/globals.js` ) }) } diff --git a/packages/sui-studio/src/components/utils.js b/packages/sui-studio/src/components/utils.js index 74a8c9e68..966c4e763 100644 --- a/packages/sui-studio/src/components/utils.js +++ b/packages/sui-studio/src/components/utils.js @@ -1,3 +1,4 @@ +/* globals __SUI_STUDIO_CONFIG__ __SUI_STUDIO_COMPONENTS_LIST__ */ import {forwardRef} from 'react' import hoistNonReactStatics from 'hoist-non-react-statics' @@ -8,27 +9,11 @@ const DEFAULT_LOGO = " " export const getComponentsList = () => { - const listOfComponents = preval` - const fg = require('fast-glob') - const path = require('path') - - const folders = fg.sync('components/*/*', { deep: 3, onlyDirectories: true}) - const components = folders.map(folder => { - const [,category, component] = folder.split(path.sep) - return {category, component} - }) - module.exports = components - ` - return listOfComponents + return __SUI_STUDIO_COMPONENTS_LIST__ } export const getSuiStudioConfig = () => { - const config = preval` - const path = require('path') - const {config = {}} = require(path.join(process.cwd(), 'package.json')) - module.exports = config['sui-studio'] || {} - ` - return config + return __SUI_STUDIO_CONFIG__ } export const getStudioName = () => { From 4d8160d0349d635a0960f6519873816478c25ec8 Mon Sep 17 00:00:00 2001 From: Carlos Villuendas Zambrana Date: Mon, 17 Jul 2023 14:43:08 +0200 Subject: [PATCH 013/134] feat(packages/sui-typescript-config): Create package Add several TS configs shared --- packages/sui-typescript-config/package.json | 22 ++++++++ packages/sui-typescript-config/src/index.js | 56 ++++++++++++++++++++ packages/sui-typescript-config/tsconfig.json | 8 +++ 3 files changed, 86 insertions(+) create mode 100644 packages/sui-typescript-config/package.json create mode 100644 packages/sui-typescript-config/src/index.js create mode 100644 packages/sui-typescript-config/tsconfig.json diff --git a/packages/sui-typescript-config/package.json b/packages/sui-typescript-config/package.json new file mode 100644 index 000000000..e9611c8b6 --- /dev/null +++ b/packages/sui-typescript-config/package.json @@ -0,0 +1,22 @@ +{ + "name": "@s-ui/typescript-config", + "version": "1.0.0-typescript.1", + "description": "Typescript config for SUI projects", + "main": "src/index.js", + "scripts": {}, + "keywords": [], + "author": "", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/SUI-Components/sui.git" + }, + "bugs": { + "url": "https://github.com/SUI-Components/sui/issues" + }, + "homepage": "https://github.com/SUI-Components/sui/tree/master/packages/sui-typescript-config#readme", + "dependencies": { + "@tsconfig/esm": "^1.0.4", + "@tsconfig/vite-react": "^2.0.0" + } +} diff --git a/packages/sui-typescript-config/src/index.js b/packages/sui-typescript-config/src/index.js new file mode 100644 index 000000000..c0d993cf6 --- /dev/null +++ b/packages/sui-typescript-config/src/index.js @@ -0,0 +1,56 @@ +const DEFAULT_LEGACY_BROWSER_TARGETS = { + ie: '11' +} + +const DEFAULT_BROWSER_TARGETS = { + chrome: '98', + edge: '107', + safari: '14.1', + firefox: '108', + ios: '14.5' +} + +const getSWCConfig = ({isModern, isTypeScript}) => { + const targets = isModern + ? DEFAULT_BROWSER_TARGETS + : DEFAULT_LEGACY_BROWSER_TARGETS + const syntaxOptions = isTypeScript + ? {syntax: 'typescript', tsx: true} + : {syntax: 'ecmascript', jsx: true} + + return { + minify: true, + jsc: { + parser: { + ...syntaxOptions, + dynamicImport: true, + privateMethod: true, + functionBind: true, + exportDefaultFrom: true, + exportNamespaceFrom: true, + decorators: true, + decoratorsBeforeExport: true, + topLevelAwait: true, + importMeta: true + }, + transform: { + legacyDecorator: true, + react: { + useBuiltins: true, + runtime: 'automatic' + } + }, + loose: true, + externalHelpers: true + }, + env: { + targets, + dynamicImport: true, + loose: true, + mode: 'entry', + coreJs: 3 + } + } +} + +module.exports.getSWCConfig = getSWCConfig diff --git a/packages/sui-typescript-config/tsconfig.json b/packages/sui-typescript-config/tsconfig.json new file mode 100644 index 000000000..09340ea34 --- /dev/null +++ b/packages/sui-typescript-config/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": ["@tsconfig/esm/tsconfig.json", "@tsconfig/vite-react/tsconfig.json"], + "compilerOptions": { + "allowJs": true, + "target": "ES2022" + } +} + From b4cd94c8234c4be7d3584c6a784da5ca194f8963 Mon Sep 17 00:00:00 2001 From: Carlos Villuendas Zambrana Date: Thu, 20 Jul 2023 11:20:09 +0200 Subject: [PATCH 014/134] fix(packages/sui-studio): fix require globals.js --- packages/sui-studio/package.json | 2 +- packages/sui-studio/src/components/globals.js | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/sui-studio/package.json b/packages/sui-studio/package.json index 8f5849e93..8ce3832ea 100644 --- a/packages/sui-studio/package.json +++ b/packages/sui-studio/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/studio", - "version": "11.35.0-typescript.0", + "version": "11.35.0-typescript.3", "description": "Develop, maintain and publish your SUI components.", "main": "index.js", "bin": { diff --git a/packages/sui-studio/src/components/globals.js b/packages/sui-studio/src/components/globals.js index 7be636942..cace2bba1 100644 --- a/packages/sui-studio/src/components/globals.js +++ b/packages/sui-studio/src/components/globals.js @@ -3,14 +3,11 @@ import {safeImport} from './utils.js' export const importGlobals = () => { - // we use a variable for the file so Webpack - // could safe fail if the file doesn't exist - const globalsFile = 'globals.js' return safeImport({ importFile: () => import( /* webpackInclude: /\/components\/globals.js$/ */ - `${__BASE_DIR__}/components/${globalsFile}` + `${__BASE_DIR__}/components/globals.js` ) }) } From 0bc9fd50006771d5e8c84203854b71b4432b5bfa Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 9 Aug 2023 16:47:32 +0200 Subject: [PATCH 015/134] feat(packages/sui-bundler): add more support to typescript --- packages/sui-bundler/package.json | 2 +- packages/sui-bundler/scripts/postinstall.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/sui-bundler/package.json b/packages/sui-bundler/package.json index 652c19cbf..9f1c0986c 100644 --- a/packages/sui-bundler/package.json +++ b/packages/sui-bundler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/bundler", - "version": "9.39.0-typescript.115", + "version": "9.39.0-typescript.117", "description": "Config-free bundler for ES6 React apps.", "bin": { "sui-bundler": "./bin/sui-bundler.js" diff --git a/packages/sui-bundler/scripts/postinstall.js b/packages/sui-bundler/scripts/postinstall.js index e6610d501..9e1a110f0 100755 --- a/packages/sui-bundler/scripts/postinstall.js +++ b/packages/sui-bundler/scripts/postinstall.js @@ -1,4 +1,5 @@ #!/usr/bin/env node +/* eslint-disable no-console */ const crypto = require('crypto') const fs = require('fs-extra') @@ -11,9 +12,9 @@ const tsConfigTemplate = `\ { "extends": "@s-ui/bundler/tsconfig.json", "compilerOptions": { - "rootDir": "./src" + "rootDir": "./" }, - "include": ["src/**/*"] + "include": ["src", "domain", "components"] }` const md5 = str => crypto.createHash('md5').update(str).digest('hex') From 5397da91d6c2bb2abcc4d81b9c7249941ccc23fa Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 9 Aug 2023 16:48:02 +0200 Subject: [PATCH 016/134] test(packages/sui-react-head): fix some tests --- packages/sui-react-head/test/server/serverSpec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sui-react-head/test/server/serverSpec.js b/packages/sui-react-head/test/server/serverSpec.js index 1b4e75b7e..fc16300fb 100644 --- a/packages/sui-react-head/test/server/serverSpec.js +++ b/packages/sui-react-head/test/server/serverSpec.js @@ -59,7 +59,7 @@ describe.server('react-head on server', () => { renderHeadTagsToString(headTags) expect(headString).to.equal( - 'My awesome title' + 'My awesome title' ) expect(htmlAttributes).to.equal('data-rh="" lang="es"') expect(bodyAttributes).to.equal('data-rh="" class="is-test"') @@ -86,7 +86,7 @@ describe.server('react-head on server', () => { renderHeadTagsToString(headTags) expect(headString).to.equal( - 'My awesome title' + 'My awesome title' ) expect(htmlAttributes).to.equal('data-rh="" lang="es"') expect(bodyAttributes).to.equal('data-rh="" class="is-test"') @@ -121,7 +121,7 @@ describe.server('react-head on server', () => { renderHeadTagsToString(headTags) expect(headString).to.equal( - 'My awesome title' + 'My awesome title' ) expect(htmlAttributes).to.equal('data-rh="" lang="es"') expect(bodyAttributes).to.equal('data-rh="" class="is-test"') From a502a655639003f0f97c342a7e323888fc766c59 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 9 Aug 2023 16:48:59 +0200 Subject: [PATCH 017/134] chore(Root): execute all server tests --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f0951fa56..d28d59a74 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test:server:ci": "npm run test:server", "test:client": "npx @s-ui/test browser -P 'packages/**/!(server)/*Spec.js'", "test:client:watch": "npm run test:client -- --watch", - "test:server": "npx @s-ui/test server -P './packages/sui-test-contract/test/server/setupSpec.js'", + "test:server": "npx @s-ui/test server -P 'packages/**/server/*Spec.js'", "test:server:watch": "npm run test:server -- --watch", "test:e2e": "node ./packages/sui-studio/test/server/integration/static-server.js ./packages/sui-studio/test/server/integration/sample-studio/public && npx @s-ui/test-e2e --baseUrl=http://localhost:1234", "pre-commit": "sui-lint js --staged && sui-lint sass --staged", From e8780da793f2c882c5da73bfe19d945c1a87f461 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 9 Aug 2023 16:49:21 +0200 Subject: [PATCH 018/134] feat(packages/sui-helpers): add more support to typescript --- packages/sui-helpers/package.json | 2 +- packages/sui-helpers/packages.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/sui-helpers/package.json b/packages/sui-helpers/package.json index 3ef52141b..e0a77d7fb 100644 --- a/packages/sui-helpers/package.json +++ b/packages/sui-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/helpers", - "version": "1.38.0-typescript.1", + "version": "1.38.0-typescript.2", "description": "A set of internal helpers used by sui-related packages.", "author": "", "dependencies": { diff --git a/packages/sui-helpers/packages.js b/packages/sui-helpers/packages.js index 6905bf147..242f0949e 100644 --- a/packages/sui-helpers/packages.js +++ b/packages/sui-helpers/packages.js @@ -65,6 +65,14 @@ const resolveLazyNPMBin = async (binPath, pkg, cwd = process.cwd()) => { ).then(resolvePkgBin) } } + +/** + * Installs and imports packages dynamically. + * @param {string} name Name of the NPM package. + * @param {object} options Available options. + * @param {string} options.version Specific version of the package. + * @return {Promise} Returns the default module. + */ const dynamicPackage = async (name, {version} = {}) => { const packageName = version ? `${name}@${version}` : name @@ -72,7 +80,12 @@ const dynamicPackage = async (name, {version} = {}) => { await getSpawnPromise('npm', ['explain', packageName]) } catch (error) { if (error.exitCode === 1) { - await getSpawnPromise('npm', ['install', packageName, '--no-save']) + await getSpawnPromise('npm', [ + 'install', + packageName, + '--no-save', + '--legacy-peer-deps' + ]) } } From bbc43363fe1843c4499b6f792f68af06e692844d Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 9 Aug 2023 16:49:28 +0200 Subject: [PATCH 019/134] feat(packages/sui-js-compiler): add more support to typescript --- packages/sui-js-compiler/index.js | 19 +-------- packages/sui-js-compiler/package.json | 5 ++- packages/sui-js-compiler/swc-config.js | 54 -------------------------- 3 files changed, 5 insertions(+), 73 deletions(-) delete mode 100644 packages/sui-js-compiler/swc-config.js diff --git a/packages/sui-js-compiler/index.js b/packages/sui-js-compiler/index.js index d81b6f13d..7d21f1a8a 100755 --- a/packages/sui-js-compiler/index.js +++ b/packages/sui-js-compiler/index.js @@ -10,9 +10,8 @@ import path from 'node:path' import {transformFile} from '@swc/core' -import {getSpawnPromise} from '@s-ui/helpers/cli.js' - -import {getSWCConfig} from './swc-config.js' +import {dynamicPackage} from '@s-ui/helpers/packages.js' +import {getSWCConfig} from '@s-ui/typescript-config' const SOURCE_DIR = './src' const OUTPUT_DIR = './lib' @@ -34,20 +33,6 @@ const DEFAULT_TS_CONFIG = { types: ['react', 'node'] } -const dynamicPackage = async (name, {version} = {}) => { - const packageName = version ? `${name}@${version}` : name - - try { - await getSpawnPromise('npm', ['explain', packageName]) - } catch (error) { - if (error.exitCode === 1) { - await getSpawnPromise('npm', ['install', packageName, '--no-save']) - } - } - - return import(packageName).then(module => module.default) -} - const getTsConfig = () => { // Get TS config from the package dir. const tsConfigPath = path.join(process.cwd(), 'tsconfig.json') diff --git a/packages/sui-js-compiler/package.json b/packages/sui-js-compiler/package.json index 4bb9089dc..91fc236ad 100644 --- a/packages/sui-js-compiler/package.json +++ b/packages/sui-js-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/js-compiler", - "version": "1.25.0", + "version": "1.26.0-typescript.0", "description": "JavaScript & TypeScript Compiler", "type": "module", "exports": "./src/index.js", @@ -12,7 +12,8 @@ }, "license": "MIT", "dependencies": { - "@s-ui/helpers": "1", + "@s-ui/helpers": "typescript", + "@s-ui/typescript-config": "typescript", "@swc/core": "1.3.14", "@swc/helpers": "0.4.12", "commander": "8.3.0", diff --git a/packages/sui-js-compiler/swc-config.js b/packages/sui-js-compiler/swc-config.js deleted file mode 100644 index 4bd20e808..000000000 --- a/packages/sui-js-compiler/swc-config.js +++ /dev/null @@ -1,54 +0,0 @@ -const DEFAULT_LEGACY_BROWSER_TARGETS = { - ie: '11' -} - -const DEFAULT_BROWSER_TARGETS = { - chrome: '98', - edge: '107', - safari: '14.1', - firefox: '108', - ios: '14.5' -} - -export const getSWCConfig = ({isModern, isTypeScript}) => { - const targets = isModern - ? DEFAULT_BROWSER_TARGETS - : DEFAULT_LEGACY_BROWSER_TARGETS - const syntaxOptions = isTypeScript - ? {syntax: 'typescript', tsx: true} - : {syntax: 'ecmascript', jsx: true} - - return { - minify: true, - jsc: { - parser: { - ...syntaxOptions, - dynamicImport: true, - privateMethod: true, - functionBind: true, - exportDefaultFrom: true, - exportNamespaceFrom: true, - decorators: true, - decoratorsBeforeExport: true, - topLevelAwait: true, - importMeta: true - }, - transform: { - legacyDecorator: true, - react: { - useBuiltins: true, - runtime: 'automatic' - } - }, - loose: true, - externalHelpers: true - }, - env: { - targets, - dynamicImport: true, - loose: true, - mode: 'entry', - coreJs: 3 - } - } -} From b3616dedc3a780abd1380b8d35726601fa9b0354 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 9 Aug 2023 16:49:28 +0200 Subject: [PATCH 020/134] feat(packages/sui-lint): add more support to typescript --- packages/sui-lint/eslintrc.js | 1 + packages/sui-lint/package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sui-lint/eslintrc.js b/packages/sui-lint/eslintrc.js index f25d88611..fb2e25029 100644 --- a/packages/sui-lint/eslintrc.js +++ b/packages/sui-lint/eslintrc.js @@ -221,6 +221,7 @@ module.exports = { project: './tsconfig.json' }, rules: { + 'import/extensions': RULES.OFF, 'no-return-await': RULES.OFF, 'prettier/prettier': [RULES.ERROR, prettierOptions], 'react/react-in-jsx-scope': RULES.OFF, diff --git a/packages/sui-lint/package.json b/packages/sui-lint/package.json index a450172d1..03ad3c5cc 100644 --- a/packages/sui-lint/package.json +++ b/packages/sui-lint/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/lint", - "version": "4.34.0-typescript.10", + "version": "4.34.0-typescript.12", "description": "Linting CLI for sui packages", "main": "./bin/sui-lint.js", "bin": { From c75a1f280b93c86052b1e6c9e38b27b5ff56681f Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 9 Aug 2023 16:49:29 +0200 Subject: [PATCH 021/134] feat(packages/sui-studio): add more support to typescript --- packages/sui-studio/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-studio/package.json b/packages/sui-studio/package.json index 8ce3832ea..a30d01003 100644 --- a/packages/sui-studio/package.json +++ b/packages/sui-studio/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/studio", - "version": "11.35.0-typescript.3", + "version": "11.35.0-typescript.5", "description": "Develop, maintain and publish your SUI components.", "main": "index.js", "bin": { @@ -15,7 +15,7 @@ "@s-ui/helpers": "1", "@s-ui/react-context": "typescript", "@s-ui/react-router": "1", - "@s-ui/test": "8", + "@s-ui/test": "typescript", "@testing-library/react": "10.4.9", "@testing-library/react-hooks": "4.0.1", "@testing-library/user-event": "13.5.0", From 9c84adb60fbcfe968fedb9852b86400e56477b0f Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 9 Aug 2023 16:49:30 +0200 Subject: [PATCH 022/134] feat(packages/sui-test): add more support to typescript --- packages/sui-test/bin/karma/config.js | 2 +- packages/sui-test/bin/mocha/applyEsmOverride.js | 5 +++-- packages/sui-test/bin/mocha/register.js | 17 ++++++++++++++--- packages/sui-test/bin/sui-test-browser.js | 2 +- packages/sui-test/bin/sui-test-server.js | 3 ++- packages/sui-test/package.json | 4 +++- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/sui-test/bin/karma/config.js b/packages/sui-test/bin/karma/config.js index 0ebfcc629..f60c12c5f 100644 --- a/packages/sui-test/bin/karma/config.js +++ b/packages/sui-test/bin/karma/config.js @@ -68,7 +68,7 @@ const config = { ) }, modules: [path.resolve(process.cwd()), 'node_modules'], - extensions: ['.mjs', '.js', '.jsx', '.json'], + extensions: ['.mjs', '.js', '.jsx', '.ts', '.tsx', '.json'], fallback: { assert: false, child_process: false, diff --git a/packages/sui-test/bin/mocha/applyEsmOverride.js b/packages/sui-test/bin/mocha/applyEsmOverride.js index c2e958404..4415ee757 100644 --- a/packages/sui-test/bin/mocha/applyEsmOverride.js +++ b/packages/sui-test/bin/mocha/applyEsmOverride.js @@ -1,4 +1,5 @@ -const _module = require('module') -const fs = require('fs') +const _module = require('node:module') +const fs = require('node:fs') + _module.Module._extensions['.js'] = (module, filename) => module._compile(fs.readFileSync(filename, 'utf8'), filename) diff --git a/packages/sui-test/bin/mocha/register.js b/packages/sui-test/bin/mocha/register.js index f59dd215d..10473db53 100644 --- a/packages/sui-test/bin/mocha/register.js +++ b/packages/sui-test/bin/mocha/register.js @@ -1,10 +1,11 @@ const {serverConfig} = require('../../src/config.js') +const {getSWCConfig} = require('@s-ui/typescript-config') + const { forceTranspilation = [], esmOverride = false, useLibDir = false } = serverConfig - const regexToAdd = forceTranspilation.map( regexString => new RegExp(regexString) ) @@ -23,10 +24,20 @@ const paths = [ libDir, ...regexToAdd ] +const only = useLibDir ? paths : paths.filter(path => path !== libDir) +const swcConfig = getSWCConfig({isTypeScript: true, compileToCJS: true}) + +// Register TS source files +require('@swc/register')({ + ignore: [/(.*)\.(js|cjs|mjs)/], + only, + ...swcConfig +}) +// Register JS source files require('@babel/register')({ - ignore: [], - only: useLibDir ? paths : paths.filter(path => path !== libDir), + ignore: [/(.*)\.ts/], + only, presets: [ [ 'babel-preset-sui', diff --git a/packages/sui-test/bin/sui-test-browser.js b/packages/sui-test/bin/sui-test-browser.js index 60b5bd378..cba9a8eae 100755 --- a/packages/sui-test/bin/sui-test-browser.js +++ b/packages/sui-test/bin/sui-test-browser.js @@ -12,7 +12,7 @@ program .option( '-P, --pattern ', 'Path pattern to include', - 'test/**/*Spec.js' + 'test/**/*Spec.+(js|jsx|ts|tsx)' ) .option( '-I, --ignore-pattern ', diff --git a/packages/sui-test/bin/sui-test-server.js b/packages/sui-test/bin/sui-test-server.js index cf7a207fb..a90e26470 100755 --- a/packages/sui-test/bin/sui-test-server.js +++ b/packages/sui-test/bin/sui-test-server.js @@ -31,8 +31,9 @@ serialSpawn([ require.resolve('mocha/bin/mocha.js'), [ path.join(process.cwd(), path.sep, pattern), - `--require ${path.join(__dirname, 'mocha', 'register.js')}`, '--recursive', + '--extension js,ts,cjs,mjs', + `--require ${path.join(__dirname, 'mocha', 'register.js')}`, inspect && '--inspect-brk', watch && '--watch', timeout && `--timeout ${timeout}`, diff --git a/packages/sui-test/package.json b/packages/sui-test/package.json index 6859a51c8..8688dc1b6 100644 --- a/packages/sui-test/package.json +++ b/packages/sui-test/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/test", - "version": "8.26.0", + "version": "8.27.0-typescript.2", "description": "", "bin": { "sui-test": "bin/sui-test.js" @@ -23,6 +23,8 @@ "@babel/plugin-transform-modules-commonjs": "7.18.6", "@babel/register": "7.18.9", "@s-ui/helpers": "1", + "@s-ui/typescript-config": "typescript", + "@swc/register": "0.1.10", "babel-loader": "8.2.5", "babel-plugin-dynamic-import-node": "2.3.3", "babel-plugin-istanbul": "6.0.0", From 2096ebb53e61f2f48ad4644cbdd62f5a95c4929d Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 9 Aug 2023 16:49:30 +0200 Subject: [PATCH 023/134] feat(packages/sui-typescript-config): add more support to typescript --- packages/sui-typescript-config/package.json | 6 +++--- packages/sui-typescript-config/src/index.js | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/sui-typescript-config/package.json b/packages/sui-typescript-config/package.json index e9611c8b6..e5fb85e15 100644 --- a/packages/sui-typescript-config/package.json +++ b/packages/sui-typescript-config/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/typescript-config", - "version": "1.0.0-typescript.1", + "version": "1.0.0-typescript.2", "description": "Typescript config for SUI projects", "main": "src/index.js", "scripts": {}, @@ -16,7 +16,7 @@ }, "homepage": "https://github.com/SUI-Components/sui/tree/master/packages/sui-typescript-config#readme", "dependencies": { - "@tsconfig/esm": "^1.0.4", - "@tsconfig/vite-react": "^2.0.0" + "@tsconfig/esm": "1.0.4", + "@tsconfig/vite-react": "2.0.0" } } diff --git a/packages/sui-typescript-config/src/index.js b/packages/sui-typescript-config/src/index.js index c0d993cf6..547585f67 100644 --- a/packages/sui-typescript-config/src/index.js +++ b/packages/sui-typescript-config/src/index.js @@ -10,17 +10,23 @@ const DEFAULT_BROWSER_TARGETS = { ios: '14.5' } -const getSWCConfig = ({isModern, isTypeScript}) => { +const getSWCConfig = ({ + isModern = false, + isTypeScript = false, + compileToCJS = false +}) => { const targets = isModern ? DEFAULT_BROWSER_TARGETS : DEFAULT_LEGACY_BROWSER_TARGETS const syntaxOptions = isTypeScript ? {syntax: 'typescript', tsx: true} : {syntax: 'ecmascript', jsx: true} + const moduleOptions = compileToCJS ? {module: {type: 'commonjs'}} : {} return { minify: true, jsc: { + ...moduleOptions, parser: { ...syntaxOptions, dynamicImport: true, From e7a5b353b8ae3947268c5ec6f9b6a573a62d6909 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 00:33:09 +0200 Subject: [PATCH 024/134] fix(packages/sui-typescript-config): fix config --- packages/sui-typescript-config/package.json | 2 +- packages/sui-typescript-config/src/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-typescript-config/package.json b/packages/sui-typescript-config/package.json index e5fb85e15..827c0cb9d 100644 --- a/packages/sui-typescript-config/package.json +++ b/packages/sui-typescript-config/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/typescript-config", - "version": "1.0.0-typescript.2", + "version": "1.0.0-typescript.4", "description": "Typescript config for SUI projects", "main": "src/index.js", "scripts": {}, diff --git a/packages/sui-typescript-config/src/index.js b/packages/sui-typescript-config/src/index.js index 547585f67..692b28a1c 100644 --- a/packages/sui-typescript-config/src/index.js +++ b/packages/sui-typescript-config/src/index.js @@ -26,7 +26,6 @@ const getSWCConfig = ({ return { minify: true, jsc: { - ...moduleOptions, parser: { ...syntaxOptions, dynamicImport: true, @@ -49,6 +48,7 @@ const getSWCConfig = ({ loose: true, externalHelpers: true }, + ...moduleOptions, env: { targets, dynamicImport: true, From db77a2f3b9c69e2ce6983c519edebcd1a2080456 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 00:33:43 +0200 Subject: [PATCH 025/134] fix(packages/sui-test): add proper loader to karma --- packages/sui-test/bin/karma/config.js | 32 ++++++++++++++------------- packages/sui-test/package.json | 4 +++- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/sui-test/bin/karma/config.js b/packages/sui-test/bin/karma/config.js index f60c12c5f..3a4f50a5f 100644 --- a/packages/sui-test/bin/karma/config.js +++ b/packages/sui-test/bin/karma/config.js @@ -3,6 +3,7 @@ const webpack = require('webpack') const path = require('path') const {envVars} = require('@s-ui/bundler/shared/index.js') +const {getSWCConfig} = require('@s-ui/typescript-config') const { bundlerConfig, clientConfig, @@ -11,29 +12,23 @@ const { const {captureConsole = true} = clientConfig const {sep} = path - const mustPackagesToAlias = { 'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js', 'react/jsx-runtime': 'react/jsx-runtime.js' } -/** - * Transform the env config (Array) to an object. - * Where the value is always an empty string. - */ +// Transform the env config (Array) to an object +// where the value is always an empty string. const environmentVariables = envVars(bundlerConfig.env) +const swcConfig = getSWCConfig({isTypeScript: true}) const config = { singleRun: true, - basePath: '', - frameworks: ['mocha', 'webpack'], - proxies: { '/mockServiceWorker.js': `/base/public/mockServiceWorker.js` }, - plugins: [ require.resolve('karma-webpack'), require.resolve('karma-chrome-launcher'), @@ -42,17 +37,12 @@ const config = { require.resolve('karma-coverage'), require.resolve('karma-spec-reporter') ], - reporters: ['spec'], - browsers: ['Chrome'], - browserDisconnectTolerance: 1, - webpackMiddleware: { stats: 'errors-only' }, - webpack: { devtool: 'eval', stats: 'errors-only', @@ -113,6 +103,19 @@ const config = { dataUrl: () => '' } }, + { + test: /\.tsx?$/, + exclude: new RegExp( + `node_modules(?!${sep}@s-ui${sep}studio${sep}src)` + ), + use: { + loader: 'swc-loader', + options: { + sync: true, + ...swcConfig + } + } + }, { test: /\.jsx?$/, exclude: new RegExp( @@ -149,7 +152,6 @@ const config = { ] } }, - client: { captureConsole, mocha: { diff --git a/packages/sui-test/package.json b/packages/sui-test/package.json index 8688dc1b6..f0b521c57 100644 --- a/packages/sui-test/package.json +++ b/packages/sui-test/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/test", - "version": "8.27.0-typescript.2", + "version": "8.27.0-typescript.4", "description": "", "bin": { "sui-test": "bin/sui-test.js" @@ -24,6 +24,7 @@ "@babel/register": "7.18.9", "@s-ui/helpers": "1", "@s-ui/typescript-config": "typescript", + "@swc/core": "1.3.75", "@swc/register": "0.1.10", "babel-loader": "8.2.5", "babel-plugin-dynamic-import-node": "2.3.3", @@ -40,6 +41,7 @@ "mocha": "10.0.0", "process": "0.11.10", "stream-browserify": "3.0.0", + "swc-loader": "0.2.3", "tty-browserify": "0.0.1", "util": "0.12.4", "webpack": "5.74.0" From 793641e025f279d4873f163129da723ac0fcc683 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 00:34:03 +0200 Subject: [PATCH 026/134] chore(packages/sui-js-compiler): bump test version --- packages/sui-js-compiler/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-js-compiler/package.json b/packages/sui-js-compiler/package.json index 91fc236ad..bee7f7689 100644 --- a/packages/sui-js-compiler/package.json +++ b/packages/sui-js-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/js-compiler", - "version": "1.26.0-typescript.0", + "version": "1.26.0-typescript.2", "description": "JavaScript & TypeScript Compiler", "type": "module", "exports": "./src/index.js", From fcdcf9483b1d84a50e0edb0396e17ba24d183fa0 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 00:34:39 +0200 Subject: [PATCH 027/134] chore(Root): fix npm options --- .gitignore | 30 +++++++++++++++--------------- .npmrc | 1 + 2 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 .npmrc diff --git a/.gitignore b/.gitignore index 18fe87d62..0e3e749e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,25 @@ -node_modules/ -lib/ -coverage/ .DS_Store -npm-debug.log -.tern-port -package-lock.json +.idea/ .python-version +.tern-port +.vscode/ + +contract/logs/pact.log +coverage/ jsconfig.json +lib/ +node_modules/ +npm-debug.log +package-lock.json + +!packages/sui-sass-loader/test/server/fixtures/**/node_modules packages/sui-codemod/COMMANDS -sui-components-dashboard-9350df448fcd.json -.idea/ -.vscode/ packages/sui-studio/test/server/integration/empty-studio/components/fake/** +packages/sui-studio/test/server/integration/empty-studio/components/fake/componentnvim packages/sui-studio/test/server/integration/empty-studio/demo/fake/** packages/sui-studio/test/server/integration/empty-studio/test/fake/** -packages/sui-studio/test/server/integration/sample-studio/node_modules/ packages/sui-studio/test/server/integration/sample-studio/components/atom/button/node_modules/ +packages/sui-studio/test/server/integration/sample-studio/node_modules/ packages/sui-studio/test/server/integration/sample-studio/public -packages/sui-studio/test/server/integration/empty-studio/components/fake/componentnvim -!packages/sui-sass-loader/test/server/fixtures/**/node_modules - -contract/logs/pact.log -.npmrc \ No newline at end of file +sui-components-dashboard-9350df448fcd.json \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000..e9ee3cb4d --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +legacy-peer-deps=true \ No newline at end of file From b53ee39213edd2dca80366336d41ea122046fff3 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 13:24:37 +0200 Subject: [PATCH 028/134] fix(packages/sui-bundler): add some fixes --- packages/sui-bundler/package.json | 2 +- packages/sui-bundler/webpack.config.server.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-bundler/package.json b/packages/sui-bundler/package.json index 9f1c0986c..4f282e0f8 100644 --- a/packages/sui-bundler/package.json +++ b/packages/sui-bundler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/bundler", - "version": "9.39.0-typescript.117", + "version": "9.39.0-typescript.118", "description": "Config-free bundler for ES6 React apps.", "bin": { "sui-bundler": "./bin/sui-bundler.js" diff --git a/packages/sui-bundler/webpack.config.server.js b/packages/sui-bundler/webpack.config.server.js index 9d4407749..dc0c1f153 100644 --- a/packages/sui-bundler/webpack.config.server.js +++ b/packages/sui-bundler/webpack.config.server.js @@ -18,7 +18,7 @@ const webpackConfig = { mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', resolve: { alias: {...aliasFromConfig}, - extensions: ['.js', '.json'], + extensions: ['.js', '.json', '.ts', '.tsx'], modules: ['node_modules', path.resolve(process.cwd())] }, entry: './server.js', From f4fa3af2366897ee0aa72b469f9a6667d8c21822 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 13:24:45 +0200 Subject: [PATCH 029/134] fix(packages/sui-helpers): add some fixes --- packages/sui-helpers/package.json | 2 +- packages/sui-helpers/packages.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-helpers/package.json b/packages/sui-helpers/package.json index e0a77d7fb..5c082baf1 100644 --- a/packages/sui-helpers/package.json +++ b/packages/sui-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/helpers", - "version": "1.38.0-typescript.2", + "version": "1.38.0-typescript.4", "description": "A set of internal helpers used by sui-related packages.", "author": "", "dependencies": { diff --git a/packages/sui-helpers/packages.js b/packages/sui-helpers/packages.js index 242f0949e..16a0a218f 100644 --- a/packages/sui-helpers/packages.js +++ b/packages/sui-helpers/packages.js @@ -1,6 +1,6 @@ /* eslint no-console:0 */ const path = require('path') -const {getSpawnPromise} = require('./cli') +const {getSpawnPromise} = require('./cli.js') /** * Get absolute paths of packages From 7001874a03c800984e0116cbc98ddcf242f44baa Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 13:24:46 +0200 Subject: [PATCH 030/134] fix(packages/sui-js-compiler): add some fixes --- packages/sui-js-compiler/index.js | 3 ++- packages/sui-js-compiler/package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/sui-js-compiler/index.js b/packages/sui-js-compiler/index.js index 7d21f1a8a..00e15192e 100755 --- a/packages/sui-js-compiler/index.js +++ b/packages/sui-js-compiler/index.js @@ -10,7 +10,7 @@ import path from 'node:path' import {transformFile} from '@swc/core' -import {dynamicPackage} from '@s-ui/helpers/packages.js' +import helpers from '@s-ui/helpers/packages.js' import {getSWCConfig} from '@s-ui/typescript-config' const SOURCE_DIR = './src' @@ -59,6 +59,7 @@ const compileFile = async (file, options) => { } const compileTypes = async (files, options) => { + const {dynamicPackage} = helpers const {createCompilerHost, createProgram} = await dynamicPackage('typescript') const createdFiles = {} const host = createCompilerHost(options) diff --git a/packages/sui-js-compiler/package.json b/packages/sui-js-compiler/package.json index bee7f7689..1026c220c 100644 --- a/packages/sui-js-compiler/package.json +++ b/packages/sui-js-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/js-compiler", - "version": "1.26.0-typescript.2", + "version": "1.26.0-typescript.4", "description": "JavaScript & TypeScript Compiler", "type": "module", "exports": "./src/index.js", From 09a6949ad393339af331aa13ad5ab6c7783ac29b Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 13:24:48 +0200 Subject: [PATCH 031/134] fix(packages/sui-studio): add some fixes --- packages/sui-studio/package.json | 4 ++-- packages/sui-studio/src/components/tryRequire.js | 4 ++-- packages/sui-studio/src/runtime-mocha/index.js | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/sui-studio/package.json b/packages/sui-studio/package.json index a30d01003..ed4b5aaa4 100644 --- a/packages/sui-studio/package.json +++ b/packages/sui-studio/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/studio", - "version": "11.35.0-typescript.5", + "version": "11.35.0-typescript.7", "description": "Develop, maintain and publish your SUI components.", "main": "index.js", "bin": { @@ -12,7 +12,7 @@ "dependencies": { "@babel/cli": "7", "@s-ui/bundler": "typescript", - "@s-ui/helpers": "1", + "@s-ui/helpers": "typescript", "@s-ui/react-context": "typescript", "@s-ui/react-router": "1", "@s-ui/test": "typescript", diff --git a/packages/sui-studio/src/components/tryRequire.js b/packages/sui-studio/src/components/tryRequire.js index d9f766277..5b1f9fa5a 100644 --- a/packages/sui-studio/src/components/tryRequire.js +++ b/packages/sui-studio/src/components/tryRequire.js @@ -1,6 +1,6 @@ /* global __BASE_DIR__ */ -import {safeImport} from './utils' +import {safeImport} from './utils.js' const fetchStaticFile = path => window @@ -87,7 +87,7 @@ export const importGlobals = () => { importFile: () => import( /* webpackInclude: /\/components\/globals.js$/ */ - /* webpackExclude: /*.md$/ */ + /* webpackExclude: /(.*)\.md$/ */ `${__BASE_DIR__}/components/globals.js` ) }) diff --git a/packages/sui-studio/src/runtime-mocha/index.js b/packages/sui-studio/src/runtime-mocha/index.js index d780f704c..72c8211cd 100644 --- a/packages/sui-studio/src/runtime-mocha/index.js +++ b/packages/sui-studio/src/runtime-mocha/index.js @@ -1,4 +1,5 @@ /* global __BASE_DIR__, CATEGORIES, PATTERN */ +/* eslint-disable no-console */ /** * This file is being executed in browser opened to run tests @@ -13,7 +14,7 @@ addSetupEnvironment(window) window.__STUDIO_CONTEXTS__ = {} window.__STUDIO_COMPONENT__ = {} -const defaultPattern = '**/*.test.{js,jsx}' +const defaultPattern = '**/*.test.{js,jsx,ts,tsx}' const globPattern = PATTERN || defaultPattern const categories = CATEGORIES ? CATEGORIES.split(',') : null @@ -35,7 +36,7 @@ window.__karma__.loaded = () => {} const testsFiles = require.context( `${__BASE_DIR__}/components/`, true, - /\.\/(\w+)\/(\w+)\/test\/(components\.)?(\w+).test.(js|jsx)/ + /\.\/(\w+)\/(\w+)\/test\/(components\.)?(\w+).test.(js|jsx|ts|tsx)/ ) const selectedTestFiles = testsFiles.keys().filter(filterAll) From d407c0231bdff12032fbc0f5098404259fbdad76 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 13:42:57 +0200 Subject: [PATCH 032/134] feat(packages/sui-bundler): add more changes --- packages/sui-bundler/package.json | 4 ++-- packages/sui-bundler/shared/module-rules-babel.js | 2 +- packages/sui-bundler/tsconfig.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/sui-bundler/package.json b/packages/sui-bundler/package.json index 4f282e0f8..1178ef03d 100644 --- a/packages/sui-bundler/package.json +++ b/packages/sui-bundler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/bundler", - "version": "9.39.0-typescript.118", + "version": "9.39.0-typescript.119", "description": "Config-free bundler for ES6 React apps.", "bin": { "sui-bundler": "./bin/sui-bundler.js" @@ -25,7 +25,7 @@ "@babel/core": "7.21.8", "@s-ui/helpers": "typescript", "@s-ui/sass-loader": "1", - "@s-ui/typescript-config": "typescript", + "@s-ui/compiler-config": "typescript", "@swc/core": "1.3.14", "@swc/helpers": "0.4.12", "address": "1.2.0", diff --git a/packages/sui-bundler/shared/module-rules-babel.js b/packages/sui-bundler/shared/module-rules-babel.js index 443ea8084..4e82ddabb 100644 --- a/packages/sui-bundler/shared/module-rules-babel.js +++ b/packages/sui-bundler/shared/module-rules-babel.js @@ -2,7 +2,7 @@ const fs = require('fs-extra') const path = require('path') const {config} = require('./index.js') -const {getSWCConfig} = require('@s-ui/typescript-config') +const {getSWCConfig} = require('@s-ui/compiler-config') const EXCLUDED_FOLDERS_REGEXP = new RegExp( `node_modules(?!${path.sep}@s-ui(${path.sep}studio)(${path.sep}workbench)?${path.sep}src)` diff --git a/packages/sui-bundler/tsconfig.json b/packages/sui-bundler/tsconfig.json index 754330a94..c4f3b5e4a 100644 --- a/packages/sui-bundler/tsconfig.json +++ b/packages/sui-bundler/tsconfig.json @@ -1,3 +1,3 @@ { - "extends": "@s-ui/typescript-config/tsconfig.json" + "extends": "@s-ui/compiler-config/tsconfig.json" } From 0af1a4f478796ea657fb6cfe0ee16b935c45bd04 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 13:43:01 +0200 Subject: [PATCH 033/134] feat(packages/sui-compiler-config): add more changes --- packages/sui-compiler-config/package.json | 22 ++++++++ packages/sui-compiler-config/src/index.js | 62 ++++++++++++++++++++++ packages/sui-compiler-config/tsconfig.json | 8 +++ 3 files changed, 92 insertions(+) create mode 100644 packages/sui-compiler-config/package.json create mode 100644 packages/sui-compiler-config/src/index.js create mode 100644 packages/sui-compiler-config/tsconfig.json diff --git a/packages/sui-compiler-config/package.json b/packages/sui-compiler-config/package.json new file mode 100644 index 000000000..c4ee60b18 --- /dev/null +++ b/packages/sui-compiler-config/package.json @@ -0,0 +1,22 @@ +{ + "name": "@s-ui/compiler-config", + "version": "1.0.0-typescript.0", + "description": "Compilers config (SWC, TS...) for SUI projects.", + "main": "src/index.js", + "scripts": {}, + "keywords": [], + "author": "", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/SUI-Components/sui.git" + }, + "bugs": { + "url": "https://github.com/SUI-Components/sui/issues" + }, + "homepage": "https://github.com/SUI-Components/sui/tree/master/packages/sui-compiler-config#readme", + "dependencies": { + "@tsconfig/esm": "1.0.4", + "@tsconfig/vite-react": "2.0.0" + } +} diff --git a/packages/sui-compiler-config/src/index.js b/packages/sui-compiler-config/src/index.js new file mode 100644 index 000000000..692b28a1c --- /dev/null +++ b/packages/sui-compiler-config/src/index.js @@ -0,0 +1,62 @@ +const DEFAULT_LEGACY_BROWSER_TARGETS = { + ie: '11' +} + +const DEFAULT_BROWSER_TARGETS = { + chrome: '98', + edge: '107', + safari: '14.1', + firefox: '108', + ios: '14.5' +} + +const getSWCConfig = ({ + isModern = false, + isTypeScript = false, + compileToCJS = false +}) => { + const targets = isModern + ? DEFAULT_BROWSER_TARGETS + : DEFAULT_LEGACY_BROWSER_TARGETS + const syntaxOptions = isTypeScript + ? {syntax: 'typescript', tsx: true} + : {syntax: 'ecmascript', jsx: true} + const moduleOptions = compileToCJS ? {module: {type: 'commonjs'}} : {} + + return { + minify: true, + jsc: { + parser: { + ...syntaxOptions, + dynamicImport: true, + privateMethod: true, + functionBind: true, + exportDefaultFrom: true, + exportNamespaceFrom: true, + decorators: true, + decoratorsBeforeExport: true, + topLevelAwait: true, + importMeta: true + }, + transform: { + legacyDecorator: true, + react: { + useBuiltins: true, + runtime: 'automatic' + } + }, + loose: true, + externalHelpers: true + }, + ...moduleOptions, + env: { + targets, + dynamicImport: true, + loose: true, + mode: 'entry', + coreJs: 3 + } + } +} + +module.exports.getSWCConfig = getSWCConfig diff --git a/packages/sui-compiler-config/tsconfig.json b/packages/sui-compiler-config/tsconfig.json new file mode 100644 index 000000000..09340ea34 --- /dev/null +++ b/packages/sui-compiler-config/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": ["@tsconfig/esm/tsconfig.json", "@tsconfig/vite-react/tsconfig.json"], + "compilerOptions": { + "allowJs": true, + "target": "ES2022" + } +} + From c80bcf3c1b4daf88970db698b11341d02aadadfa Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 13:43:03 +0200 Subject: [PATCH 034/134] feat(packages/sui-js-compiler): add more changes --- packages/sui-js-compiler/index.js | 2 +- packages/sui-js-compiler/package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sui-js-compiler/index.js b/packages/sui-js-compiler/index.js index 00e15192e..c9860432c 100755 --- a/packages/sui-js-compiler/index.js +++ b/packages/sui-js-compiler/index.js @@ -10,8 +10,8 @@ import path from 'node:path' import {transformFile} from '@swc/core' +import {getSWCConfig} from '@s-ui/compiler-config' import helpers from '@s-ui/helpers/packages.js' -import {getSWCConfig} from '@s-ui/typescript-config' const SOURCE_DIR = './src' const OUTPUT_DIR = './lib' diff --git a/packages/sui-js-compiler/package.json b/packages/sui-js-compiler/package.json index 1026c220c..34fd51d79 100644 --- a/packages/sui-js-compiler/package.json +++ b/packages/sui-js-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/js-compiler", - "version": "1.26.0-typescript.4", + "version": "1.26.0-typescript.5", "description": "JavaScript & TypeScript Compiler", "type": "module", "exports": "./src/index.js", @@ -13,7 +13,7 @@ "license": "MIT", "dependencies": { "@s-ui/helpers": "typescript", - "@s-ui/typescript-config": "typescript", + "@s-ui/compiler-config": "typescript", "@swc/core": "1.3.14", "@swc/helpers": "0.4.12", "commander": "8.3.0", From 70245200938a712fc7e12e3a79104c65f75b6174 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 13:43:04 +0200 Subject: [PATCH 035/134] feat(packages/sui-test): add more changes --- packages/sui-test/bin/karma/config.js | 2 +- packages/sui-test/bin/mocha/register.js | 2 +- packages/sui-test/package.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/sui-test/bin/karma/config.js b/packages/sui-test/bin/karma/config.js index 3a4f50a5f..83c9b63c6 100644 --- a/packages/sui-test/bin/karma/config.js +++ b/packages/sui-test/bin/karma/config.js @@ -3,7 +3,7 @@ const webpack = require('webpack') const path = require('path') const {envVars} = require('@s-ui/bundler/shared/index.js') -const {getSWCConfig} = require('@s-ui/typescript-config') +const {getSWCConfig} = require('@s-ui/compiler-config') const { bundlerConfig, clientConfig, diff --git a/packages/sui-test/bin/mocha/register.js b/packages/sui-test/bin/mocha/register.js index 10473db53..6d69f397b 100644 --- a/packages/sui-test/bin/mocha/register.js +++ b/packages/sui-test/bin/mocha/register.js @@ -1,5 +1,5 @@ const {serverConfig} = require('../../src/config.js') -const {getSWCConfig} = require('@s-ui/typescript-config') +const {getSWCConfig} = require('@s-ui/compiler-config') const { forceTranspilation = [], diff --git a/packages/sui-test/package.json b/packages/sui-test/package.json index f0b521c57..cc34daa10 100644 --- a/packages/sui-test/package.json +++ b/packages/sui-test/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/test", - "version": "8.27.0-typescript.4", + "version": "8.27.0-typescript.5", "description": "", "bin": { "sui-test": "bin/sui-test.js" @@ -23,7 +23,7 @@ "@babel/plugin-transform-modules-commonjs": "7.18.6", "@babel/register": "7.18.9", "@s-ui/helpers": "1", - "@s-ui/typescript-config": "typescript", + "@s-ui/compiler-config": "typescript", "@swc/core": "1.3.75", "@swc/register": "0.1.10", "babel-loader": "8.2.5", From c7cd349cde7320a174ffd57692ea79f178e3b728 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 13:44:21 +0200 Subject: [PATCH 036/134] feat(Root): remove package --- packages/sui-typescript-config/package.json | 22 ------- packages/sui-typescript-config/src/index.js | 62 -------------------- packages/sui-typescript-config/tsconfig.json | 8 --- 3 files changed, 92 deletions(-) delete mode 100644 packages/sui-typescript-config/package.json delete mode 100644 packages/sui-typescript-config/src/index.js delete mode 100644 packages/sui-typescript-config/tsconfig.json diff --git a/packages/sui-typescript-config/package.json b/packages/sui-typescript-config/package.json deleted file mode 100644 index 827c0cb9d..000000000 --- a/packages/sui-typescript-config/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "@s-ui/typescript-config", - "version": "1.0.0-typescript.4", - "description": "Typescript config for SUI projects", - "main": "src/index.js", - "scripts": {}, - "keywords": [], - "author": "", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/SUI-Components/sui.git" - }, - "bugs": { - "url": "https://github.com/SUI-Components/sui/issues" - }, - "homepage": "https://github.com/SUI-Components/sui/tree/master/packages/sui-typescript-config#readme", - "dependencies": { - "@tsconfig/esm": "1.0.4", - "@tsconfig/vite-react": "2.0.0" - } -} diff --git a/packages/sui-typescript-config/src/index.js b/packages/sui-typescript-config/src/index.js deleted file mode 100644 index 692b28a1c..000000000 --- a/packages/sui-typescript-config/src/index.js +++ /dev/null @@ -1,62 +0,0 @@ -const DEFAULT_LEGACY_BROWSER_TARGETS = { - ie: '11' -} - -const DEFAULT_BROWSER_TARGETS = { - chrome: '98', - edge: '107', - safari: '14.1', - firefox: '108', - ios: '14.5' -} - -const getSWCConfig = ({ - isModern = false, - isTypeScript = false, - compileToCJS = false -}) => { - const targets = isModern - ? DEFAULT_BROWSER_TARGETS - : DEFAULT_LEGACY_BROWSER_TARGETS - const syntaxOptions = isTypeScript - ? {syntax: 'typescript', tsx: true} - : {syntax: 'ecmascript', jsx: true} - const moduleOptions = compileToCJS ? {module: {type: 'commonjs'}} : {} - - return { - minify: true, - jsc: { - parser: { - ...syntaxOptions, - dynamicImport: true, - privateMethod: true, - functionBind: true, - exportDefaultFrom: true, - exportNamespaceFrom: true, - decorators: true, - decoratorsBeforeExport: true, - topLevelAwait: true, - importMeta: true - }, - transform: { - legacyDecorator: true, - react: { - useBuiltins: true, - runtime: 'automatic' - } - }, - loose: true, - externalHelpers: true - }, - ...moduleOptions, - env: { - targets, - dynamicImport: true, - loose: true, - mode: 'entry', - coreJs: 3 - } - } -} - -module.exports.getSWCConfig = getSWCConfig diff --git a/packages/sui-typescript-config/tsconfig.json b/packages/sui-typescript-config/tsconfig.json deleted file mode 100644 index 09340ea34..000000000 --- a/packages/sui-typescript-config/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": ["@tsconfig/esm/tsconfig.json", "@tsconfig/vite-react/tsconfig.json"], - "compilerOptions": { - "allowJs": true, - "target": "ES2022" - } -} - From 0b2e9b64574214a1cdf442449cd07f70aed40311 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 16:14:12 +0200 Subject: [PATCH 037/134] feat(packages/sui-bundler): restore original versions --- packages/sui-bundler/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sui-bundler/package.json b/packages/sui-bundler/package.json index 1178ef03d..382218e25 100644 --- a/packages/sui-bundler/package.json +++ b/packages/sui-bundler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/bundler", - "version": "9.39.0-typescript.119", + "version": "9.38.0", "description": "Config-free bundler for ES6 React apps.", "bin": { "sui-bundler": "./bin/sui-bundler.js" @@ -23,9 +23,9 @@ "homepage": "https://github.com/SUI-Components/sui/tree/master/packages/sui-bundler#readme", "dependencies": { "@babel/core": "7.21.8", - "@s-ui/helpers": "typescript", + "@s-ui/compiler-config": "1", + "@s-ui/helpers": "1", "@s-ui/sass-loader": "1", - "@s-ui/compiler-config": "typescript", "@swc/core": "1.3.14", "@swc/helpers": "0.4.12", "address": "1.2.0", From 80db5eb485dc1caa81b9e3211b04dd410389b566 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 16:14:15 +0200 Subject: [PATCH 038/134] feat(packages/sui-compiler-config): restore original versions --- packages/sui-compiler-config/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-compiler-config/package.json b/packages/sui-compiler-config/package.json index c4ee60b18..24cdef292 100644 --- a/packages/sui-compiler-config/package.json +++ b/packages/sui-compiler-config/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/compiler-config", - "version": "1.0.0-typescript.0", + "version": "1.0.0", "description": "Compilers config (SWC, TS...) for SUI projects.", "main": "src/index.js", "scripts": {}, From 0961a23642b3a5d34c5b5ff332f848e5dd40ccf4 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 16:14:16 +0200 Subject: [PATCH 039/134] feat(packages/sui-helpers): restore original versions --- packages/sui-helpers/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-helpers/package.json b/packages/sui-helpers/package.json index 5c082baf1..710286d8d 100644 --- a/packages/sui-helpers/package.json +++ b/packages/sui-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/helpers", - "version": "1.38.0-typescript.4", + "version": "1.38.0", "description": "A set of internal helpers used by sui-related packages.", "author": "", "dependencies": { From 8dd8cd1cc7e86ba73ba03636b7608a0c070e09fd Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 16:14:16 +0200 Subject: [PATCH 040/134] feat(packages/sui-js-compiler): restore original versions --- packages/sui-js-compiler/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sui-js-compiler/package.json b/packages/sui-js-compiler/package.json index 34fd51d79..36457f289 100644 --- a/packages/sui-js-compiler/package.json +++ b/packages/sui-js-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/js-compiler", - "version": "1.26.0-typescript.5", + "version": "1.25.0", "description": "JavaScript & TypeScript Compiler", "type": "module", "exports": "./src/index.js", @@ -12,8 +12,8 @@ }, "license": "MIT", "dependencies": { - "@s-ui/helpers": "typescript", - "@s-ui/compiler-config": "typescript", + "@s-ui/compiler-config": "1", + "@s-ui/helpers": "1", "@swc/core": "1.3.14", "@swc/helpers": "0.4.12", "commander": "8.3.0", From 015daf5fcf24cee4edb001bcd8c98359f538931d Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 16:14:16 +0200 Subject: [PATCH 041/134] feat(packages/sui-lint): restore original versions --- packages/sui-lint/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-lint/package.json b/packages/sui-lint/package.json index 03ad3c5cc..98ef1817b 100644 --- a/packages/sui-lint/package.json +++ b/packages/sui-lint/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/lint", - "version": "4.34.0-typescript.12", + "version": "4.33.0", "description": "Linting CLI for sui packages", "main": "./bin/sui-lint.js", "bin": { From 48c3efcdebc4e43f7d9872d570d0e192cba983dd Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 16:14:17 +0200 Subject: [PATCH 042/134] feat(packages/sui-react-context): restore original versions --- packages/sui-react-context/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-react-context/package.json b/packages/sui-react-context/package.json index 801b43bad..bcb9e5e04 100644 --- a/packages/sui-react-context/package.json +++ b/packages/sui-react-context/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/react-context", - "version": "1.8.1-typescript.1", + "version": "1.8.0", "description": "", "main": "lib/index", "types": "lib/index.d.ts", From 60e1b778be153f3a1f8b5135a43a1842d32cdc8f Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 16:14:18 +0200 Subject: [PATCH 043/134] feat(packages/sui-studio): restore original versions --- packages/sui-studio/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/sui-studio/package.json b/packages/sui-studio/package.json index ed4b5aaa4..4219631ed 100644 --- a/packages/sui-studio/package.json +++ b/packages/sui-studio/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/studio", - "version": "11.35.0-typescript.7", + "version": "11.35.0", "description": "Develop, maintain and publish your SUI components.", "main": "index.js", "bin": { @@ -11,11 +11,11 @@ "license": "MIT", "dependencies": { "@babel/cli": "7", - "@s-ui/bundler": "typescript", - "@s-ui/helpers": "typescript", - "@s-ui/react-context": "typescript", + "@s-ui/bundler": "9", + "@s-ui/helpers": "1", + "@s-ui/react-context": "1", "@s-ui/react-router": "1", - "@s-ui/test": "typescript", + "@s-ui/test": "8", "@testing-library/react": "10.4.9", "@testing-library/react-hooks": "4.0.1", "@testing-library/user-event": "13.5.0", From d3081ebd961f10159156449ba08a6d2f327bd7b6 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 10 Aug 2023 16:14:19 +0200 Subject: [PATCH 044/134] feat(packages/sui-test): restore original versions --- packages/sui-test/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-test/package.json b/packages/sui-test/package.json index cc34daa10..7e276db87 100644 --- a/packages/sui-test/package.json +++ b/packages/sui-test/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/test", - "version": "8.27.0-typescript.5", + "version": "8.26.0", "description": "", "bin": { "sui-test": "bin/sui-test.js" @@ -22,8 +22,8 @@ "@babel/core": "7.18.10", "@babel/plugin-transform-modules-commonjs": "7.18.6", "@babel/register": "7.18.9", + "@s-ui/compiler-config": "1", "@s-ui/helpers": "1", - "@s-ui/compiler-config": "typescript", "@swc/core": "1.3.75", "@swc/register": "0.1.10", "babel-loader": "8.2.5", From f6c4f9607d7054bc5e044b849fe1741473007dfa Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 11 Aug 2023 09:26:24 +0200 Subject: [PATCH 045/134] feat(packages/sui-bundler): rename module rules --- .../{module-rules-babel.js => module-rules-compiler.js} | 0 packages/sui-bundler/webpack.config.dev.js | 4 ++-- packages/sui-bundler/webpack.config.lib.js | 4 ++-- packages/sui-bundler/webpack.config.prod.js | 4 ++-- packages/sui-bundler/webpack.config.server.js | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) rename packages/sui-bundler/shared/{module-rules-babel.js => module-rules-compiler.js} (100%) diff --git a/packages/sui-bundler/shared/module-rules-babel.js b/packages/sui-bundler/shared/module-rules-compiler.js similarity index 100% rename from packages/sui-bundler/shared/module-rules-babel.js rename to packages/sui-bundler/shared/module-rules-compiler.js diff --git a/packages/sui-bundler/webpack.config.dev.js b/packages/sui-bundler/webpack.config.dev.js index 8294e0d8f..e277d3d80 100644 --- a/packages/sui-bundler/webpack.config.dev.js +++ b/packages/sui-bundler/webpack.config.dev.js @@ -17,7 +17,7 @@ const {aliasFromConfig, defaultAlias} = require('./shared/resolve-alias.js') const {supportLegacyBrowsers} = require('./shared/config.js') const {resolveLoader} = require('./shared/resolve-loader.js') -const createBabelRules = require('./shared/module-rules-babel.js') +const createCompilerRules = require('./shared/module-rules-compiler.js') const outputPath = path.join(process.cwd(), 'dist') @@ -83,7 +83,7 @@ const webpackConfig = { resolveLoader, module: { rules: cleanList([ - createBabelRules({supportLegacyBrowsers}), + createCompilerRules({supportLegacyBrowsers}), { test: /(\.css|\.scss)$/, use: cleanList([ diff --git a/packages/sui-bundler/webpack.config.lib.js b/packages/sui-bundler/webpack.config.lib.js index 188ba9256..6d1e8ba3b 100644 --- a/packages/sui-bundler/webpack.config.lib.js +++ b/packages/sui-bundler/webpack.config.lib.js @@ -9,7 +9,7 @@ const { const path = require('path') const minifyJs = require('./shared/minify-js.js') const definePlugin = require('./shared/define.js') -const createBabelRules = require('./shared/module-rules-babel.js') +const createCompilerRules = require('./shared/module-rules-compiler.js') const sassRules = require('./shared/module-rules-sass.js') const { extractComments, @@ -67,6 +67,6 @@ module.exports = { definePlugin() ]), module: { - rules: [createBabelRules({supportLegacyBrowsers}), sassRules] + rules: [createCompilerRules({supportLegacyBrowsers}), sassRules] } } diff --git a/packages/sui-bundler/webpack.config.prod.js b/packages/sui-bundler/webpack.config.prod.js index 525bd82b0..b61d0d759 100644 --- a/packages/sui-bundler/webpack.config.prod.js +++ b/packages/sui-bundler/webpack.config.prod.js @@ -23,7 +23,7 @@ const { supportLegacyBrowsers } = require('./shared/config.js') const {resolveLoader} = require('./shared/resolve-loader.js') -const createBabelRules = require('./shared/module-rules-babel.js') +const createCompilerRules = require('./shared/module-rules-compiler.js') const sassRules = require('./shared/module-rules-sass.js') const definePlugin = require('./shared/define.js') const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js') @@ -114,7 +114,7 @@ const webpackConfig = { ]), module: { rules: cleanList([ - createBabelRules({supportLegacyBrowsers}), + createCompilerRules({supportLegacyBrowsers}), sassRules, when(config['externals-manifest'], () => manifestLoaderRules(config['externals-manifest']) diff --git a/packages/sui-bundler/webpack.config.server.js b/packages/sui-bundler/webpack.config.server.js index dc0c1f153..eb03634e8 100644 --- a/packages/sui-bundler/webpack.config.server.js +++ b/packages/sui-bundler/webpack.config.server.js @@ -3,7 +3,7 @@ const webpackNodeExternals = require('webpack-node-externals') const path = require('path') const {config, when, cleanList} = require('./shared/index.js') -const createBabelRules = require('./shared/module-rules-babel.js') +const createCompilerRules = require('./shared/module-rules-compiler.js') const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js') const {aliasFromConfig} = require('./shared/resolve-alias.js') const {resolveLoader} = require('./shared/resolve-loader.js') @@ -39,7 +39,7 @@ const webpackConfig = { resolveLoader, module: { rules: cleanList([ - createBabelRules({isServer: true}), + createCompilerRules({isServer: true}), { // ignore css/scss/svg require/imports files in the server test: /(\.svg|\.s?css)$/, From eb68ce2570b6c6d11acc7d55362d4d5dd3c36d2b Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 11 Aug 2023 09:26:43 +0200 Subject: [PATCH 046/134] feat(packages/sui-hoc): remove type module --- packages/sui-hoc/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sui-hoc/package.json b/packages/sui-hoc/package.json index f2d3dab18..3928f2e3d 100644 --- a/packages/sui-hoc/package.json +++ b/packages/sui-hoc/package.json @@ -3,7 +3,6 @@ "version": "1.36.0", "description": "Set of HoC useful for react", "main": "lib/index.js", - "type": "module", "scripts": { "lib": "babel --presets sui ./src --out-dir ./lib", "prepublishOnly": "npm run lib" From c5facd53f196676b5efd842e68d85a995c8e1c89 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 18 Aug 2023 11:44:51 +0200 Subject: [PATCH 047/134] test(packages/sui-js-compiler): log errors --- packages/sui-js-compiler/test/server/jsCompilerSpec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/sui-js-compiler/test/server/jsCompilerSpec.js b/packages/sui-js-compiler/test/server/jsCompilerSpec.js index bca71bfae..e0f6df757 100644 --- a/packages/sui-js-compiler/test/server/jsCompilerSpec.js +++ b/packages/sui-js-compiler/test/server/jsCompilerSpec.js @@ -85,10 +85,12 @@ describe('@s-ui/js-compiler', () => { await fs.outputFile(tsConfigPath, JSON.stringify(tsConfig)) // WHEN execute the compiler command - const {stdout} = await exec('node ../../index.js', { + const {stdout, stderr} = await exec('node ../../index.js', { cwd }) + console.log({stdout, stderr}) const compiledFilenames = await fs.readdir(libPath) + console.log({compiledFilenames}) // THEN package files and types are properly compiled expect(stdout).to.contain('[sui-js-compiler]') From b2487abed6a1e5a007bf21fc0cd7d3ea3579eb24 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 17 Oct 2023 19:43:15 +0200 Subject: [PATCH 048/134] fix(packages/sui-bundler): fix plugin extension --- packages/sui-bundler/webpack.config.lib.js | 2 +- packages/sui-bundler/webpack.config.prod.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-bundler/webpack.config.lib.js b/packages/sui-bundler/webpack.config.lib.js index 6d1e8ba3b..071f8f2f6 100644 --- a/packages/sui-bundler/webpack.config.lib.js +++ b/packages/sui-bundler/webpack.config.lib.js @@ -54,7 +54,7 @@ module.exports = { }, plugins: cleanList([ new webpack.ProvidePlugin({ - process: 'process/browser' + process: 'process/browser.js' }), new MiniCssExtractPlugin({ filename: cssFileName, diff --git a/packages/sui-bundler/webpack.config.prod.js b/packages/sui-bundler/webpack.config.prod.js index b61d0d759..c586b3dac 100644 --- a/packages/sui-bundler/webpack.config.prod.js +++ b/packages/sui-bundler/webpack.config.prod.js @@ -84,7 +84,7 @@ const webpackConfig = { }, plugins: cleanList([ new webpack.ProvidePlugin({ - process: 'process/browser' + process: 'process/browser.js' }), new webpack.ids.HashedModuleIdsPlugin(), new webpack.EnvironmentPlugin(envVars(config.env)), From 561bca9df69c96d5a8f6ac3e0b46c73acc5149f7 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 17 Oct 2023 21:42:45 +0200 Subject: [PATCH 049/134] feat(packages/sui-mock): sync typescript versions --- packages/sui-mock/package.json | 7 +++---- packages/sui-mock/src/browser.js | 11 ++++++++--- packages/sui-mock/src/server.js | 13 +++++++++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/sui-mock/package.json b/packages/sui-mock/package.json index a0c177f5c..6561a5f7c 100644 --- a/packages/sui-mock/package.json +++ b/packages/sui-mock/package.json @@ -2,12 +2,11 @@ "name": "@s-ui/mock", "version": "1.2.0", "main": "lib/index.js", - "description": "mock provider", - "types": "lib/index", + "description": "Mock provider", "scripts": { "lib": "babel --presets sui ./src --out-dir ./lib", "prepublishOnly": "npm run lib", - "test": "npm run test:client && npm run test:server", + "test": "npm run test:browser && npm run test:server", "test:browser": "npx @s-ui/test browser -P './test/browser/**/*Spec.js'", "test:browser:watch": "npm run test:client -- --watch", "test:server": "npx @s-ui/test server -P './test/server/**/*Spec.js'", @@ -17,7 +16,7 @@ "author": "", "license": "MIT", "dependencies": { - "msw": "0.47.4" + "msw": "1.2.1" }, "repository": { "type": "git", diff --git a/packages/sui-mock/src/browser.js b/packages/sui-mock/src/browser.js index 6dca6c6dc..1923d7de2 100644 --- a/packages/sui-mock/src/browser.js +++ b/packages/sui-mock/src/browser.js @@ -5,8 +5,13 @@ export const getBrowserMocker = async (handlers = []) => { const worker = setup(...handlers) return { - ...worker, - listen: worker.start, - close: worker.stop + start: worker.start.bind(worker), + stop: worker.stop.bind(worker), + listen: worker.start.bind(worker), + close: worker.stop.bind(worker), + use: worker.use.bind(worker), + resetHandlers: worker.resetHandlers.bind(worker), + restoreHandlers: worker.restoreHandlers.bind(worker), + printHandlers: worker.printHandlers.bind(worker) } } diff --git a/packages/sui-mock/src/server.js b/packages/sui-mock/src/server.js index a1ca38c4a..0461c967b 100644 --- a/packages/sui-mock/src/server.js +++ b/packages/sui-mock/src/server.js @@ -1,12 +1,17 @@ export {rest} from 'msw' export const getServerMocker = async (handlers = []) => { - const {setupServer} = require('msw/node') + const setupServer = await import('msw/node').then(pkg => pkg.setupServer) const worker = setupServer(...handlers) return { - ...worker, - start: worker.listen, - stop: worker.close + start: worker.listen.bind(worker), + stop: worker.close.bind(worker), + listen: worker.listen.bind(worker), + close: worker.close.bind(worker), + use: worker.use.bind(worker), + resetHandlers: worker.resetHandlers.bind(worker), + restoreHandlers: worker.restoreHandlers.bind(worker), + printHandlers: worker.printHandlers.bind(worker) } } From 5c75ada6b2c6a00f230f84b9d659c10f2b03277c Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 17 Oct 2023 21:42:56 +0200 Subject: [PATCH 050/134] feat(packages/sui-test-contract): sync typescript versions --- packages/sui-test-contract/package.json | 4 ++-- packages/sui-test-contract/src/setup/utils.js | 4 ++-- packages/sui-test-contract/test/server/setupSpec.js | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/sui-test-contract/package.json b/packages/sui-test-contract/package.json index 6d8993431..7e9069923 100644 --- a/packages/sui-test-contract/package.json +++ b/packages/sui-test-contract/package.json @@ -17,8 +17,8 @@ }, "dependencies": { "@pact-foundation/pact": "9.18.1", - "@pactflow/pact-msw-adapter": "1.2.1", - "@s-ui/mock": "1", + "@pactflow/pact-msw-adapter": "2.0.0", + "@s-ui/mock": "typescript", "commander": "8.3.0", "headers-polyfill": "3.1.2" }, diff --git a/packages/sui-test-contract/src/setup/utils.js b/packages/sui-test-contract/src/setup/utils.js index 37b87eb88..b0d009e47 100644 --- a/packages/sui-test-contract/src/setup/utils.js +++ b/packages/sui-test-contract/src/setup/utils.js @@ -1,6 +1,6 @@ import {stringify} from 'qs' -import {writeData2File} from '@pactflow/pact-msw-adapter/dist/utils/utils.js' +import {createWriter} from '@pactflow/pact-msw-adapter/dist/utils/utils.js' const flatEntries = (input, prefix = '') => Object.entries(input).flatMap(([key, value]) => { @@ -61,7 +61,7 @@ export const writerFactory = providers => (path, data) => { }) console.log(`Writing the Pact file "${path}"`) // eslint-disable-line - writeData2File(path, data) + createWriter()(path, data) } export const mapProviders = providers => diff --git a/packages/sui-test-contract/test/server/setupSpec.js b/packages/sui-test-contract/test/server/setupSpec.js index 7dd4de6bc..de31a0e3c 100644 --- a/packages/sui-test-contract/test/server/setupSpec.js +++ b/packages/sui-test-contract/test/server/setupSpec.js @@ -1,11 +1,12 @@ import {expect} from 'chai' import {FetcherFactory} from '@s-ui/domain' -import {rest} from '@s-ui/mock' +import mock from '@s-ui/mock' import {setupContractTests} from '../../src/index.js' import {getContractFileData, removeContractFiles} from '../utils.js' +const {rest} = mock const fetcher = FetcherFactory.httpFetcher({config: {}}) const consumer = 'test-consumer' const fujiAppleResponse = {color: 'red', type: 'Fuji'} From bfd4f8cea375b5291d9bd9b4d1aed0a7e7bd184c Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 30 Oct 2023 23:45:15 +0100 Subject: [PATCH 051/134] chore(Root): upgrade ts versio --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d28d59a74..c9567f9f6 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "chai": "4.3.6", "react": "17", "sinon": "10.0.0", - "typescript": "4.3.2", + "typescript": "5", "validate-commit-msg": "2.14.0" }, "config": { @@ -79,4 +79,4 @@ "stylelint": { "extends": "./node_modules/@s-ui/lint/stylelint.config.js" } -} \ No newline at end of file +} From 1a3585b02b640ea88a3477340da4a57fc3c2b308 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 30 Oct 2023 23:45:40 +0100 Subject: [PATCH 052/134] feat(packages/sui-test): sync ts version --- packages/sui-test/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-test/package.json b/packages/sui-test/package.json index e1887107f..e6bc1745d 100644 --- a/packages/sui-test/package.json +++ b/packages/sui-test/package.json @@ -24,7 +24,7 @@ "@babel/register": "7.18.9", "@s-ui/compiler-config": "1", "@s-ui/helpers": "1", - "@swc/core": "1.3.75", + "@swc/core": "1.3.14", "@swc/register": "0.1.10", "babel-loader": "8.2.5", "babel-plugin-dynamic-import-node": "2.3.3", From b2d8f6678e270d7b4f88c03f6fa1892e36c600d1 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 30 Oct 2023 23:46:19 +0100 Subject: [PATCH 053/134] feat(packages/sui-js-compiler): install ts by default --- packages/sui-js-compiler/index.js | 7 ++++--- packages/sui-js-compiler/package.json | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/sui-js-compiler/index.js b/packages/sui-js-compiler/index.js index c9860432c..ce6cfb7bb 100755 --- a/packages/sui-js-compiler/index.js +++ b/packages/sui-js-compiler/index.js @@ -7,11 +7,11 @@ import program from 'commander' import fg from 'fast-glob' import fs from 'fs-extra' import path from 'node:path' +import typescript from 'typescript' import {transformFile} from '@swc/core' import {getSWCConfig} from '@s-ui/compiler-config' -import helpers from '@s-ui/helpers/packages.js' const SOURCE_DIR = './src' const OUTPUT_DIR = './lib' @@ -59,8 +59,9 @@ const compileFile = async (file, options) => { } const compileTypes = async (files, options) => { - const {dynamicPackage} = helpers - const {createCompilerHost, createProgram} = await dynamicPackage('typescript') + const {createCompilerHost, createProgram} = await import(typescript).then( + module => module.default + ) const createdFiles = {} const host = createCompilerHost(options) host.writeFile = (fileName, contents) => (createdFiles[fileName] = contents) diff --git a/packages/sui-js-compiler/package.json b/packages/sui-js-compiler/package.json index 36457f289..920a6bf1d 100644 --- a/packages/sui-js-compiler/package.json +++ b/packages/sui-js-compiler/package.json @@ -13,7 +13,6 @@ "license": "MIT", "dependencies": { "@s-ui/compiler-config": "1", - "@s-ui/helpers": "1", "@swc/core": "1.3.14", "@swc/helpers": "0.4.12", "commander": "8.3.0", From 6db9f33e0d6f9bcad657f9eda251946a91684995 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 30 Oct 2023 23:46:51 +0100 Subject: [PATCH 054/134] feat(packages/sui-helpers): remove not needed function --- packages/sui-helpers/packages.js | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/packages/sui-helpers/packages.js b/packages/sui-helpers/packages.js index 16a0a218f..d0501174f 100644 --- a/packages/sui-helpers/packages.js +++ b/packages/sui-helpers/packages.js @@ -66,35 +66,8 @@ const resolveLazyNPMBin = async (binPath, pkg, cwd = process.cwd()) => { } } -/** - * Installs and imports packages dynamically. - * @param {string} name Name of the NPM package. - * @param {object} options Available options. - * @param {string} options.version Specific version of the package. - * @return {Promise} Returns the default module. - */ -const dynamicPackage = async (name, {version} = {}) => { - const packageName = version ? `${name}@${version}` : name - - try { - await getSpawnPromise('npm', ['explain', packageName]) - } catch (error) { - if (error.exitCode === 1) { - await getSpawnPromise('npm', [ - 'install', - packageName, - '--no-save', - '--legacy-peer-deps' - ]) - } - } - - return import(packageName).then(module => module.default) -} - module.exports = { getPackageJson, getPackagesPaths, - resolveLazyNPMBin, - dynamicPackage + resolveLazyNPMBin } From 6cab6ffdb4161e9904509d561d485a77b528f6f4 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 31 Oct 2023 09:19:29 +0100 Subject: [PATCH 055/134] feat(packages/sui-bundler): remove dynamic import --- packages/sui-bundler/scripts/postinstall.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/sui-bundler/scripts/postinstall.js b/packages/sui-bundler/scripts/postinstall.js index 9e1a110f0..5d5fa1f89 100755 --- a/packages/sui-bundler/scripts/postinstall.js +++ b/packages/sui-bundler/scripts/postinstall.js @@ -5,7 +5,6 @@ const crypto = require('crypto') const fs = require('fs-extra') const path = require('path') const {writeFile} = require('@s-ui/helpers/file.js') -const {dynamicPackage} = require('@s-ui/helpers/packages') const {INIT_CWD} = process.env const tsConfigTemplate = `\ @@ -45,9 +44,9 @@ async function main() { process.exit(0) } await writeFile(TS_CONFIG_PATH, tsConfigTemplate) - await dynamicPackage('typescript') console.log( 'โŒ [sui-bundler postinstall] tsconfig.json was not up to date, so we updated it' ) } + main() From 5cacd3eac41cd4ba7aa7f243d9e9617ebf19156b Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 31 Oct 2023 10:47:42 +0100 Subject: [PATCH 056/134] chore(Root): fix ts version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c9567f9f6..addb4d8e1 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "chai": "4.3.6", "react": "17", "sinon": "10.0.0", - "typescript": "5", + "typescript": "5.0.4", "validate-commit-msg": "2.14.0" }, "config": { @@ -79,4 +79,4 @@ "stylelint": { "extends": "./node_modules/@s-ui/lint/stylelint.config.js" } -} +} \ No newline at end of file From c7f0a06d0e9ff6a7d65c4482e4280e908eaf52d5 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 31 Oct 2023 10:48:02 +0100 Subject: [PATCH 057/134] test(packages/sui-js-compiler): fix test --- packages/sui-js-compiler/index.js | 3 +-- packages/sui-js-compiler/package.json | 3 ++- packages/sui-js-compiler/test/server/jsCompilerSpec.js | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/sui-js-compiler/index.js b/packages/sui-js-compiler/index.js index ce6cfb7bb..966763269 100755 --- a/packages/sui-js-compiler/index.js +++ b/packages/sui-js-compiler/index.js @@ -7,7 +7,6 @@ import program from 'commander' import fg from 'fast-glob' import fs from 'fs-extra' import path from 'node:path' -import typescript from 'typescript' import {transformFile} from '@swc/core' @@ -59,7 +58,7 @@ const compileFile = async (file, options) => { } const compileTypes = async (files, options) => { - const {createCompilerHost, createProgram} = await import(typescript).then( + const {createCompilerHost, createProgram} = await import('typescript').then( module => module.default ) const createdFiles = {} diff --git a/packages/sui-js-compiler/package.json b/packages/sui-js-compiler/package.json index 920a6bf1d..c0bb9fc5b 100644 --- a/packages/sui-js-compiler/package.json +++ b/packages/sui-js-compiler/package.json @@ -17,6 +17,7 @@ "@swc/helpers": "0.4.12", "commander": "8.3.0", "fast-glob": "3.2.12", - "fs-extra": "10.1.0" + "fs-extra": "10.1.0", + "typescript": "5.0.4" } } diff --git a/packages/sui-js-compiler/test/server/jsCompilerSpec.js b/packages/sui-js-compiler/test/server/jsCompilerSpec.js index e0f6df757..bca71bfae 100644 --- a/packages/sui-js-compiler/test/server/jsCompilerSpec.js +++ b/packages/sui-js-compiler/test/server/jsCompilerSpec.js @@ -85,12 +85,10 @@ describe('@s-ui/js-compiler', () => { await fs.outputFile(tsConfigPath, JSON.stringify(tsConfig)) // WHEN execute the compiler command - const {stdout, stderr} = await exec('node ../../index.js', { + const {stdout} = await exec('node ../../index.js', { cwd }) - console.log({stdout, stderr}) const compiledFilenames = await fs.readdir(libPath) - console.log({compiledFilenames}) // THEN package files and types are properly compiled expect(stdout).to.contain('[sui-js-compiler]') From 27cce44bd84cab877cbffda6e552b8fdb2f1be63 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 31 Oct 2023 13:23:35 +0100 Subject: [PATCH 058/134] test(Root): debug test --- .../test/server/jsCompilerSpec.js | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/packages/sui-js-compiler/test/server/jsCompilerSpec.js b/packages/sui-js-compiler/test/server/jsCompilerSpec.js index bca71bfae..1547f1912 100644 --- a/packages/sui-js-compiler/test/server/jsCompilerSpec.js +++ b/packages/sui-js-compiler/test/server/jsCompilerSpec.js @@ -26,26 +26,42 @@ describe('@s-ui/js-compiler', () => { await fs.remove(tsConfigPath) }) - it('should compile a "src" folder with a JavaScript file and output it to "lib"', async () => { - const {stdout} = await exec('node ../../index.js', { - cwd - }) + it.only( + 'should compile a "src" folder with a JavaScript file and output it to "lib"', + async () => { + const {stdout: stdout1} = await exec('npm ls @swc/core', { + cwd + }) + console.log({stdout1}) + const {stdout: stdout2} = await exec('npm ls @swc/helpers', { + cwd + }) + console.log({stdout2}) + const {stdout: stdout3} = await exec('npm ls typescript', { + cwd + }) + console.log({stdout3}) + const {stdout} = await exec('node ../../index.js', { + cwd + }) - const compiledFilenames = await fs.readdir(libPath) + const compiledFilenames = await fs.readdir(libPath) - expect(compiledFilenames).to.eql(['example.js', 'example.test.js']) + expect(compiledFilenames).to.eql(['example.js', 'example.test.js']) - expect(stdout).to.contain('[sui-js-compiler]') + expect(stdout).to.contain('[sui-js-compiler]') - const compiledFile = await fs.readFile(libFilePath, 'utf-8') + const compiledFile = await fs.readFile(libFilePath, 'utf-8') + console.log({compiledFilenames, compiledFile}) - expect(compiledFile).to.contain('react/jsx-runtime') - expect(compiledFile).to.contain('_jsx') + expect(compiledFile).to.contain('react/jsx-runtime') + expect(compiledFile).to.contain('_jsx') - expect(compiledFile).to.contain('_async_to_generator') - expect(compiledFile).to.contain('_ts_decorate') - expect(compiledFile).to.contain('_ts_generator') - }).timeout(DEFAULT_TIMEOUT) + expect(compiledFile).to.contain('_async_to_generator') + expect(compiledFile).to.contain('_ts_decorate') + expect(compiledFile).to.contain('_ts_generator') + } + ).timeout(DEFAULT_TIMEOUT) it('should exclude all the files matching the passed patterns when the "ignore" option exists', async () => { const {stdout} = await exec( From ba9fd99f39a7b5bc654869105740b612a37fc812 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 31 Oct 2023 13:26:59 +0100 Subject: [PATCH 059/134] test(packages/sui-js-compiler): remove only --- .../test/server/jsCompilerSpec.js | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/packages/sui-js-compiler/test/server/jsCompilerSpec.js b/packages/sui-js-compiler/test/server/jsCompilerSpec.js index 1547f1912..e595b1c3f 100644 --- a/packages/sui-js-compiler/test/server/jsCompilerSpec.js +++ b/packages/sui-js-compiler/test/server/jsCompilerSpec.js @@ -26,42 +26,39 @@ describe('@s-ui/js-compiler', () => { await fs.remove(tsConfigPath) }) - it.only( - 'should compile a "src" folder with a JavaScript file and output it to "lib"', - async () => { - const {stdout: stdout1} = await exec('npm ls @swc/core', { - cwd - }) - console.log({stdout1}) - const {stdout: stdout2} = await exec('npm ls @swc/helpers', { - cwd - }) - console.log({stdout2}) - const {stdout: stdout3} = await exec('npm ls typescript', { - cwd - }) - console.log({stdout3}) - const {stdout} = await exec('node ../../index.js', { - cwd - }) + it('should compile a "src" folder with a JavaScript file and output it to "lib"', async () => { + const {stdout: stdout1} = await exec('npm ls @swc/core', { + cwd + }) + console.log({stdout1}) + const {stdout: stdout2} = await exec('npm ls @swc/helpers', { + cwd + }) + console.log({stdout2}) + const {stdout: stdout3} = await exec('npm ls typescript', { + cwd + }) + console.log({stdout3}) + const {stdout} = await exec('node ../../index.js', { + cwd + }) - const compiledFilenames = await fs.readdir(libPath) + const compiledFilenames = await fs.readdir(libPath) - expect(compiledFilenames).to.eql(['example.js', 'example.test.js']) + expect(compiledFilenames).to.eql(['example.js', 'example.test.js']) - expect(stdout).to.contain('[sui-js-compiler]') + expect(stdout).to.contain('[sui-js-compiler]') - const compiledFile = await fs.readFile(libFilePath, 'utf-8') - console.log({compiledFilenames, compiledFile}) + const compiledFile = await fs.readFile(libFilePath, 'utf-8') + console.log({compiledFilenames, compiledFile}) - expect(compiledFile).to.contain('react/jsx-runtime') - expect(compiledFile).to.contain('_jsx') + expect(compiledFile).to.contain('react/jsx-runtime') + expect(compiledFile).to.contain('_jsx') - expect(compiledFile).to.contain('_async_to_generator') - expect(compiledFile).to.contain('_ts_decorate') - expect(compiledFile).to.contain('_ts_generator') - } - ).timeout(DEFAULT_TIMEOUT) + expect(compiledFile).to.contain('_async_to_generator') + expect(compiledFile).to.contain('_ts_decorate') + expect(compiledFile).to.contain('_ts_generator') + }).timeout(DEFAULT_TIMEOUT) it('should exclude all the files matching the passed patterns when the "ignore" option exists', async () => { const {stdout} = await exec( From d733a17c9a61c4a0bb55e7ec1bfe84eecbc9808a Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 31 Oct 2023 13:37:17 +0100 Subject: [PATCH 060/134] test(packages/sui-js-compiler): remove logs --- .../test/server/jsCompilerSpec.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/packages/sui-js-compiler/test/server/jsCompilerSpec.js b/packages/sui-js-compiler/test/server/jsCompilerSpec.js index e595b1c3f..0bc3aeeb4 100644 --- a/packages/sui-js-compiler/test/server/jsCompilerSpec.js +++ b/packages/sui-js-compiler/test/server/jsCompilerSpec.js @@ -9,7 +9,6 @@ import {promisify} from 'node:util' const DEFAULT_TIMEOUT = 9000 const exec = promisify(execCallback) - const cwd = fileURLToPath(new URL('.', import.meta.url)) const libPath = fileURLToPath(new URL('lib', import.meta.url)) const tsConfigPath = fileURLToPath(new URL('tsconfig.json', import.meta.url)) @@ -27,18 +26,6 @@ describe('@s-ui/js-compiler', () => { }) it('should compile a "src" folder with a JavaScript file and output it to "lib"', async () => { - const {stdout: stdout1} = await exec('npm ls @swc/core', { - cwd - }) - console.log({stdout1}) - const {stdout: stdout2} = await exec('npm ls @swc/helpers', { - cwd - }) - console.log({stdout2}) - const {stdout: stdout3} = await exec('npm ls typescript', { - cwd - }) - console.log({stdout3}) const {stdout} = await exec('node ../../index.js', { cwd }) @@ -46,15 +33,12 @@ describe('@s-ui/js-compiler', () => { const compiledFilenames = await fs.readdir(libPath) expect(compiledFilenames).to.eql(['example.js', 'example.test.js']) - expect(stdout).to.contain('[sui-js-compiler]') const compiledFile = await fs.readFile(libFilePath, 'utf-8') - console.log({compiledFilenames, compiledFile}) expect(compiledFile).to.contain('react/jsx-runtime') expect(compiledFile).to.contain('_jsx') - expect(compiledFile).to.contain('_async_to_generator') expect(compiledFile).to.contain('_ts_decorate') expect(compiledFile).to.contain('_ts_generator') @@ -71,14 +55,12 @@ describe('@s-ui/js-compiler', () => { const compiledFilenames = await fs.readdir(libPath) expect(compiledFilenames).to.eql(['example.js']) - expect(stdout).to.contain('[sui-js-compiler]') const compiledFile = await fs.readFile(libFilePath, 'utf-8') expect(compiledFile).to.contain('react/jsx-runtime') expect(compiledFile).to.contain('_jsx') - expect(compiledFile).to.contain('_async_to_generator') expect(compiledFile).to.contain('_ts_decorate') expect(compiledFile).to.contain('_ts_generator') From c6eb1ee7f05d3c94c28aac5912a890315427afc3 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 31 Oct 2023 15:38:04 +0100 Subject: [PATCH 061/134] test(packages/sui-js-compiler): increase timeout --- packages/sui-js-compiler/test/server/jsCompilerSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-js-compiler/test/server/jsCompilerSpec.js b/packages/sui-js-compiler/test/server/jsCompilerSpec.js index 0bc3aeeb4..c7c11f776 100644 --- a/packages/sui-js-compiler/test/server/jsCompilerSpec.js +++ b/packages/sui-js-compiler/test/server/jsCompilerSpec.js @@ -6,7 +6,7 @@ import {exec as execCallback} from 'node:child_process' import {join} from 'node:path' import {promisify} from 'node:util' -const DEFAULT_TIMEOUT = 9000 +const DEFAULT_TIMEOUT = 15000 const exec = promisify(execCallback) const cwd = fileURLToPath(new URL('.', import.meta.url)) From bbcdf125682e4b0345cba99facedac34bbf5251b Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 6 Nov 2023 12:37:13 +0100 Subject: [PATCH 062/134] test(packages/sui-js-compiler): restore timeout value --- packages/sui-js-compiler/test/server/jsCompilerSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-js-compiler/test/server/jsCompilerSpec.js b/packages/sui-js-compiler/test/server/jsCompilerSpec.js index c7c11f776..0bc3aeeb4 100644 --- a/packages/sui-js-compiler/test/server/jsCompilerSpec.js +++ b/packages/sui-js-compiler/test/server/jsCompilerSpec.js @@ -6,7 +6,7 @@ import {exec as execCallback} from 'node:child_process' import {join} from 'node:path' import {promisify} from 'node:util' -const DEFAULT_TIMEOUT = 15000 +const DEFAULT_TIMEOUT = 9000 const exec = promisify(execCallback) const cwd = fileURLToPath(new URL('.', import.meta.url)) From 96683afe093914f186e9a3bc545b10a1f6764d06 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 7 Nov 2023 11:39:08 +0100 Subject: [PATCH 063/134] test(packages/sui-js-compiler): skip some tests --- .../test/server/jsCompilerSpec.js | 76 ++++++++++--------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/packages/sui-js-compiler/test/server/jsCompilerSpec.js b/packages/sui-js-compiler/test/server/jsCompilerSpec.js index 0bc3aeeb4..7c32da95b 100644 --- a/packages/sui-js-compiler/test/server/jsCompilerSpec.js +++ b/packages/sui-js-compiler/test/server/jsCompilerSpec.js @@ -25,46 +25,52 @@ describe('@s-ui/js-compiler', () => { await fs.remove(tsConfigPath) }) - it('should compile a "src" folder with a JavaScript file and output it to "lib"', async () => { - const {stdout} = await exec('node ../../index.js', { - cwd - }) - - const compiledFilenames = await fs.readdir(libPath) - - expect(compiledFilenames).to.eql(['example.js', 'example.test.js']) - expect(stdout).to.contain('[sui-js-compiler]') - - const compiledFile = await fs.readFile(libFilePath, 'utf-8') - - expect(compiledFile).to.contain('react/jsx-runtime') - expect(compiledFile).to.contain('_jsx') - expect(compiledFile).to.contain('_async_to_generator') - expect(compiledFile).to.contain('_ts_decorate') - expect(compiledFile).to.contain('_ts_generator') - }).timeout(DEFAULT_TIMEOUT) - - it('should exclude all the files matching the passed patterns when the "ignore" option exists', async () => { - const {stdout} = await exec( - 'node ../../index.js --ignore="./src/**.test.js"', - { + it.skip( + 'should compile a "src" folder with a JavaScript file and output it to "lib"', + async () => { + const {stdout} = await exec('node ../../index.js', { cwd - } - ) + }) - const compiledFilenames = await fs.readdir(libPath) + const compiledFilenames = await fs.readdir(libPath) - expect(compiledFilenames).to.eql(['example.js']) - expect(stdout).to.contain('[sui-js-compiler]') + expect(compiledFilenames).to.eql(['example.js', 'example.test.js']) + expect(stdout).to.contain('[sui-js-compiler]') - const compiledFile = await fs.readFile(libFilePath, 'utf-8') + const compiledFile = await fs.readFile(libFilePath, 'utf-8') - expect(compiledFile).to.contain('react/jsx-runtime') - expect(compiledFile).to.contain('_jsx') - expect(compiledFile).to.contain('_async_to_generator') - expect(compiledFile).to.contain('_ts_decorate') - expect(compiledFile).to.contain('_ts_generator') - }).timeout(DEFAULT_TIMEOUT) + expect(compiledFile).to.contain('react/jsx-runtime') + expect(compiledFile).to.contain('_jsx') + expect(compiledFile).to.contain('_async_to_generator') + expect(compiledFile).to.contain('_ts_decorate') + expect(compiledFile).to.contain('_ts_generator') + } + ).timeout(DEFAULT_TIMEOUT) + + it.skip( + 'should exclude all the files matching the passed patterns when the "ignore" option exists', + async () => { + const {stdout} = await exec( + 'node ../../index.js --ignore="./src/**.test.js"', + { + cwd + } + ) + + const compiledFilenames = await fs.readdir(libPath) + + expect(compiledFilenames).to.eql(['example.js']) + expect(stdout).to.contain('[sui-js-compiler]') + + const compiledFile = await fs.readFile(libFilePath, 'utf-8') + + expect(compiledFile).to.contain('react/jsx-runtime') + expect(compiledFile).to.contain('_jsx') + expect(compiledFile).to.contain('_async_to_generator') + expect(compiledFile).to.contain('_ts_decorate') + expect(compiledFile).to.contain('_ts_generator') + } + ).timeout(DEFAULT_TIMEOUT) it('should compile a "src" folder with a JSX file written in TypeScript and output it to "lib"', async () => { // GIVEN a "tsconfig.json" definition in the package root directory From 7fea970a2a44f487818339e5a69b1420a9bb28a1 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 13 Nov 2023 11:53:06 +0100 Subject: [PATCH 064/134] chore(Root): change script --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 7478c36ff..2aa091457 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,7 +26,7 @@ jobs: - uses: browser-actions/setup-chrome@latest - run: sudo apt-get install xvfb - run: npm install --no-save --no-fund --no-audit --legacy-peer-deps - - run: npx -y ultra-runner --raw --recursive prepublishOnly &>/dev/null + - run: npx -y ultra-runner --raw --recursive prepublishOnly - run: npm run lint - run: npm run test:server:ci - run: xvfb-run --auto-servernum npm run test:client:ci From 95153a8fa4267fc5bbfe37a872fff095bbd43d94 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 13 Nov 2023 12:53:41 +0100 Subject: [PATCH 065/134] chore(packages/sui-consents): fix deps --- packages/sui-consents/package.json | 4 ++-- packages/sui-consents/src/useUserConsents.ts | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/sui-consents/package.json b/packages/sui-consents/package.json index a37e72155..a9fed42f5 100644 --- a/packages/sui-consents/package.json +++ b/packages/sui-consents/package.json @@ -12,13 +12,13 @@ "author": "", "license": "MIT", "devDependencies": { - "@s-ui/react-context": "1", + "@s-ui/react-context": "typescript", "@testing-library/react": "11.2.5", "react": "17", "react-dom": "17" }, "peerDependencies": { - "@s-ui/react-context": "1", + "@s-ui/react-context": "typescript", "react": "16 || 17" } } diff --git a/packages/sui-consents/src/useUserConsents.ts b/packages/sui-consents/src/useUserConsents.ts index c4a70d0e3..d088d58f8 100644 --- a/packages/sui-consents/src/useUserConsents.ts +++ b/packages/sui-consents/src/useUserConsents.ts @@ -1,20 +1,20 @@ -import { useContext, useEffect, useState } from 'react' +import {useContext, useEffect, useState} from 'react' import SUIContext from '@s-ui/react-context' -import { TCF_VERSION, TCF_WINDOW_API } from './config' +import {TCF_VERSION, TCF_WINDOW_API} from './config' import hasUserConsents from './hasUserConsents' -import { EventStatus, Purpose } from './types' +import {EventStatus, Purpose} from './types' -export default function useUserConsents (requiredConsents: number[]): boolean { +export default function useUserConsents(requiredConsents: number[]): boolean { /** * Consents acceptance state is inited based on the cookies from the * context, so we know the state of consents from the beginning, even * in SSR. */ - const { cookies } = useContext(SUIContext) + const {cookies} = useContext(SUIContext) const [areConsentsAccepted, setAreConsentsAccepted] = useState(() => - hasUserConsents({ requiredConsents, cookies }) + hasUserConsents({requiredConsents, cookies}) ) /** @@ -25,7 +25,13 @@ export default function useUserConsents (requiredConsents: number[]): boolean { useEffect(() => { const tcfApi = window[TCF_WINDOW_API] if (tcfApi !== undefined) { - const consentsListener = ({ eventStatus, purpose }: { eventStatus: EventStatus, purpose: Purpose}): void => { + const consentsListener = ({ + eventStatus, + purpose + }: { + eventStatus: EventStatus + purpose: Purpose + }): void => { if (eventStatus !== EventStatus.USER_ACTION_COMPLETE) return setAreConsentsAccepted( From 6bde899111a93b9a4532c29159e61ba7bb08fd23 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 13 Nov 2023 12:54:11 +0100 Subject: [PATCH 066/134] chore(Root): put some logs in ci scripts --- .github/workflows/node.js.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 2aa091457..322fa2bee 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,7 +26,10 @@ jobs: - uses: browser-actions/setup-chrome@latest - run: sudo apt-get install xvfb - run: npm install --no-save --no-fund --no-audit --legacy-peer-deps + - run: ls -pal ./node_modules/@s-ui + - run: ls ./node_modules/@s-ui/react-context - run: npx -y ultra-runner --raw --recursive prepublishOnly + - run: ls ./node_modules/@s-ui/react-context - run: npm run lint - run: npm run test:server:ci - run: xvfb-run --auto-servernum npm run test:client:ci From 2d9830a069922d9a186811bbe4cc63a83b635c39 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 21 Nov 2023 11:18:56 +0100 Subject: [PATCH 067/134] chore(Root): execute only one more server test --- package.json | 4 +- .../test/server/jsCompilerSpec.js | 76 +++++++++---------- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/package.json b/package.json index addb4d8e1..1dd8da3a0 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "packages/*" ], "scripts": { - "phoenix": "npx @s-ui/mono phoenix && npx -y ultra-runner --raw --recursive prepublishOnly &>/dev/null", + "phoenix": "npx @s-ui/mono phoenix && npx -y ultra-runner --raw --recursive prepublishOnly --build &>/dev/null", "co": "npx @s-ui/mono commit", "lint": "sui-lint js && sui-lint sass", "test": "npm run test:client && npm run test:server", @@ -20,7 +20,7 @@ "test:server:ci": "npm run test:server", "test:client": "npx @s-ui/test browser -P 'packages/**/!(server)/*Spec.js'", "test:client:watch": "npm run test:client -- --watch", - "test:server": "npx @s-ui/test server -P 'packages/**/server/*Spec.js'", + "test:server": "npx @s-ui/test server -P 'packages/{sui-test-contract,sui-js-compiler}/**/server/*Spec.js'", "test:server:watch": "npm run test:server -- --watch", "test:e2e": "node ./packages/sui-studio/test/server/integration/static-server.js ./packages/sui-studio/test/server/integration/sample-studio/public && npx @s-ui/test-e2e --baseUrl=http://localhost:1234", "pre-commit": "sui-lint js --staged && sui-lint sass --staged", diff --git a/packages/sui-js-compiler/test/server/jsCompilerSpec.js b/packages/sui-js-compiler/test/server/jsCompilerSpec.js index 7c32da95b..0bc3aeeb4 100644 --- a/packages/sui-js-compiler/test/server/jsCompilerSpec.js +++ b/packages/sui-js-compiler/test/server/jsCompilerSpec.js @@ -25,52 +25,46 @@ describe('@s-ui/js-compiler', () => { await fs.remove(tsConfigPath) }) - it.skip( - 'should compile a "src" folder with a JavaScript file and output it to "lib"', - async () => { - const {stdout} = await exec('node ../../index.js', { + it('should compile a "src" folder with a JavaScript file and output it to "lib"', async () => { + const {stdout} = await exec('node ../../index.js', { + cwd + }) + + const compiledFilenames = await fs.readdir(libPath) + + expect(compiledFilenames).to.eql(['example.js', 'example.test.js']) + expect(stdout).to.contain('[sui-js-compiler]') + + const compiledFile = await fs.readFile(libFilePath, 'utf-8') + + expect(compiledFile).to.contain('react/jsx-runtime') + expect(compiledFile).to.contain('_jsx') + expect(compiledFile).to.contain('_async_to_generator') + expect(compiledFile).to.contain('_ts_decorate') + expect(compiledFile).to.contain('_ts_generator') + }).timeout(DEFAULT_TIMEOUT) + + it('should exclude all the files matching the passed patterns when the "ignore" option exists', async () => { + const {stdout} = await exec( + 'node ../../index.js --ignore="./src/**.test.js"', + { cwd - }) + } + ) - const compiledFilenames = await fs.readdir(libPath) + const compiledFilenames = await fs.readdir(libPath) - expect(compiledFilenames).to.eql(['example.js', 'example.test.js']) - expect(stdout).to.contain('[sui-js-compiler]') + expect(compiledFilenames).to.eql(['example.js']) + expect(stdout).to.contain('[sui-js-compiler]') - const compiledFile = await fs.readFile(libFilePath, 'utf-8') + const compiledFile = await fs.readFile(libFilePath, 'utf-8') - expect(compiledFile).to.contain('react/jsx-runtime') - expect(compiledFile).to.contain('_jsx') - expect(compiledFile).to.contain('_async_to_generator') - expect(compiledFile).to.contain('_ts_decorate') - expect(compiledFile).to.contain('_ts_generator') - } - ).timeout(DEFAULT_TIMEOUT) - - it.skip( - 'should exclude all the files matching the passed patterns when the "ignore" option exists', - async () => { - const {stdout} = await exec( - 'node ../../index.js --ignore="./src/**.test.js"', - { - cwd - } - ) - - const compiledFilenames = await fs.readdir(libPath) - - expect(compiledFilenames).to.eql(['example.js']) - expect(stdout).to.contain('[sui-js-compiler]') - - const compiledFile = await fs.readFile(libFilePath, 'utf-8') - - expect(compiledFile).to.contain('react/jsx-runtime') - expect(compiledFile).to.contain('_jsx') - expect(compiledFile).to.contain('_async_to_generator') - expect(compiledFile).to.contain('_ts_decorate') - expect(compiledFile).to.contain('_ts_generator') - } - ).timeout(DEFAULT_TIMEOUT) + expect(compiledFile).to.contain('react/jsx-runtime') + expect(compiledFile).to.contain('_jsx') + expect(compiledFile).to.contain('_async_to_generator') + expect(compiledFile).to.contain('_ts_decorate') + expect(compiledFile).to.contain('_ts_generator') + }).timeout(DEFAULT_TIMEOUT) it('should compile a "src" folder with a JSX file written in TypeScript and output it to "lib"', async () => { // GIVEN a "tsconfig.json" definition in the package root directory From aa7d38b577aa7a1d45d79cd5499478a6fea774bb Mon Sep 17 00:00:00 2001 From: Carlos Villuendas Zambrana Date: Wed, 29 Nov 2023 17:03:45 +0100 Subject: [PATCH 068/134] feat(packages/sui-bundler): add autoload support for MSW --- packages/sui-bundler/package.json | 2 +- packages/sui-bundler/shared/define.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sui-bundler/package.json b/packages/sui-bundler/package.json index 97232213e..59d8d50bc 100644 --- a/packages/sui-bundler/package.json +++ b/packages/sui-bundler/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/bundler", - "version": "9.43.0", + "version": "9.43.0-typescript.1", "description": "Config-free bundler for ES6 React apps.", "bin": { "sui-bundler": "./bin/sui-bundler.js" diff --git a/packages/sui-bundler/shared/define.js b/packages/sui-bundler/shared/define.js index d19795e35..fff933a70 100644 --- a/packages/sui-bundler/shared/define.js +++ b/packages/sui-bundler/shared/define.js @@ -19,6 +19,9 @@ module.exports = (vars = {}) => { const definitions = { __DEV__: false, __BASE_DIR__: JSON.stringify(process.env.PWD), + __MOCKS_API_PATH__: JSON.stringify( + process.env.MOCKS_API_PATH || process.env.PWD + '/mocks/routes' + ), ...vars, ...Object.fromEntries( Object.entries(magic).map(([key, value]) => [key, JSON.stringify(value)]) From dcac5295d2576838541f9879905b4122e8acde9c Mon Sep 17 00:00:00 2001 From: Carlos Villuendas Zambrana Date: Wed, 29 Nov 2023 17:04:26 +0100 Subject: [PATCH 069/134] feat(packages/sui-studio): Use relative paths for monorepos --- packages/sui-studio/bin/sui-studio-test.js | 6 ++++++ packages/sui-studio/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/sui-studio/bin/sui-studio-test.js b/packages/sui-studio/bin/sui-studio-test.js index e583e03e8..b963f3d79 100755 --- a/packages/sui-studio/bin/sui-studio-test.js +++ b/packages/sui-studio/bin/sui-studio-test.js @@ -25,6 +25,11 @@ program const {coverage, watch, ci, headless, timeout} = program.opts() +const relPath = path.relative( + process.cwd(), + require.resolve('@s-ui/studio/src/runtime-mocha/index.js').replace(/\/node_modules.*/, ''), +) + const run = async () => { try { const result = await serialSpawn([ @@ -33,6 +38,7 @@ const run = async () => { [ '--pattern', path.join( + relPath, 'node_modules', '@s-ui', 'studio', diff --git a/packages/sui-studio/package.json b/packages/sui-studio/package.json index 99d6f1701..422f07766 100644 --- a/packages/sui-studio/package.json +++ b/packages/sui-studio/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/studio", - "version": "11.36.0", + "version": "11.36.0-typescript.0", "description": "Develop, maintain and publish your SUI components.", "main": "index.js", "bin": { From c09ccc2be254f8dc1dfa6d18db9e8fcd7522a95e Mon Sep 17 00:00:00 2001 From: Carlos Villuendas Zambrana Date: Wed, 29 Nov 2023 17:05:00 +0100 Subject: [PATCH 070/134] feat(packages/sui-test): use relative paths for monorepos --- packages/sui-test/bin/karma/config.js | 7 ++++++- packages/sui-test/package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/sui-test/bin/karma/config.js b/packages/sui-test/bin/karma/config.js index 83c9b63c6..a97ddef29 100644 --- a/packages/sui-test/bin/karma/config.js +++ b/packages/sui-test/bin/karma/config.js @@ -22,6 +22,11 @@ const mustPackagesToAlias = { const environmentVariables = envVars(bundlerConfig.env) const swcConfig = getSWCConfig({isTypeScript: true}) +const relPath = path.relative( + process.cwd(), + require.resolve('@s-ui/react-context').replace(/\/node_modules.*/, ''), +) + const config = { singleRun: true, basePath: '', @@ -52,7 +57,7 @@ const config = { '@s-ui/react-context': path.resolve( path.join( process.env.PWD, - isWorkspace() ? '../' : './', + isWorkspace() ? relPath : './', 'node_modules/@s-ui/react-context' ) ) diff --git a/packages/sui-test/package.json b/packages/sui-test/package.json index e6bc1745d..da7e9fe5b 100644 --- a/packages/sui-test/package.json +++ b/packages/sui-test/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/test", - "version": "8.27.0", + "version": "8.27.0-typescript.7", "description": "", "bin": { "sui-test": "bin/sui-test.js" From 1b4541bbbc6211bdd8f636b540f6655556cacc01 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 10:40:03 +0100 Subject: [PATCH 071/134] fix(packages/sui-consents): fix linting issues --- packages/sui-consents/src/hasUserConsents.ts | 20 ++++++++++++-------- packages/sui-consents/src/index.ts | 2 +- packages/sui-consents/src/types.ts | 14 +++++++------- packages/sui-consents/src/useUserConsents.ts | 18 +++--------------- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/packages/sui-consents/src/hasUserConsents.ts b/packages/sui-consents/src/hasUserConsents.ts index 5929b6a8e..f2b9cd116 100644 --- a/packages/sui-consents/src/hasUserConsents.ts +++ b/packages/sui-consents/src/hasUserConsents.ts @@ -1,5 +1,5 @@ import atob from './atob' -import { TCF_COOKIE_KEY } from './config' +import {TCF_COOKIE_KEY} from './config' /** * Extracts the cookie value from the cookie string @@ -10,13 +10,13 @@ const readCookie = (key: string, cookies: string): string | null => { return value !== null ? value[1] : null } -const getUserConsents = ({ cookies }: { cookies: string}): object => { +const getUserConsents = ({cookies}: {cookies: string}): object => { const cookieValue = readCookie(TCF_COOKIE_KEY, cookies) if (cookieValue === null) return {} try { - const { purpose } = JSON.parse(atob(cookieValue)) - const { consents } = purpose + const {purpose} = JSON.parse(atob(cookieValue)) + const {consents} = purpose return consents } catch (e) { // eslint-disable-next-line no-console @@ -25,9 +25,13 @@ const getUserConsents = ({ cookies }: { cookies: string}): object => { } } -export default function hasUserConsents ( - { requiredConsents, cookies }: { requiredConsents: number[], cookies: string} -): boolean { - const userConsents = getUserConsents({ cookies }) +export default function hasUserConsents({ + requiredConsents, + cookies +}: { + requiredConsents: number[] + cookies: string +}): boolean { + const userConsents = getUserConsents({cookies}) return requiredConsents.every(purposeId => Boolean(userConsents[purposeId])) } diff --git a/packages/sui-consents/src/index.ts b/packages/sui-consents/src/index.ts index e24fe31b2..409e0d857 100644 --- a/packages/sui-consents/src/index.ts +++ b/packages/sui-consents/src/index.ts @@ -1,4 +1,4 @@ import hasUserConsents from './hasUserConsents' import useUserConsents from './useUserConsents' -export { hasUserConsents, useUserConsents } +export {hasUserConsents, useUserConsents} diff --git a/packages/sui-consents/src/types.ts b/packages/sui-consents/src/types.ts index 3c8cf68ca..98e2977b7 100644 --- a/packages/sui-consents/src/types.ts +++ b/packages/sui-consents/src/types.ts @@ -1,16 +1,16 @@ export interface Purpose { consents: { /** - * true - Consent - * false - No Consent. - */ + * true - Consent + * false - No Consent. + */ [purposeId: number]: boolean | undefined } legitimateInterests: { /** - * true - Legitimate Interest Established, - * false - No Legitimate Interest Established - */ + * true - Legitimate Interest Established, + * false - No Legitimate Interest Established + */ [purposeId: number]: boolean } } @@ -50,5 +50,5 @@ export enum EventStatus { * in accordance with TCF Policy and a CMP is prepared to respond to any * calling scripts with the corresponding TC String. */ - USER_ACTION_COMPLETE = 'useractioncomplete', + USER_ACTION_COMPLETE = 'useractioncomplete' } diff --git a/packages/sui-consents/src/useUserConsents.ts b/packages/sui-consents/src/useUserConsents.ts index d088d58f8..1c4ebe44f 100644 --- a/packages/sui-consents/src/useUserConsents.ts +++ b/packages/sui-consents/src/useUserConsents.ts @@ -13,9 +13,7 @@ export default function useUserConsents(requiredConsents: number[]): boolean { * in SSR. */ const {cookies} = useContext(SUIContext) - const [areConsentsAccepted, setAreConsentsAccepted] = useState(() => - hasUserConsents({requiredConsents, cookies}) - ) + const [areConsentsAccepted, setAreConsentsAccepted] = useState(() => hasUserConsents({requiredConsents, cookies})) /** * From then on, we listen for TCF events so consents changes @@ -25,20 +23,10 @@ export default function useUserConsents(requiredConsents: number[]): boolean { useEffect(() => { const tcfApi = window[TCF_WINDOW_API] if (tcfApi !== undefined) { - const consentsListener = ({ - eventStatus, - purpose - }: { - eventStatus: EventStatus - purpose: Purpose - }): void => { + const consentsListener = ({eventStatus, purpose}: {eventStatus: EventStatus; purpose: Purpose}): void => { if (eventStatus !== EventStatus.USER_ACTION_COMPLETE) return - setAreConsentsAccepted( - requiredConsents.every(purposeId => - Boolean(purpose.consents[purposeId]) - ) - ) + setAreConsentsAccepted(requiredConsents.every(purposeId => Boolean(purpose.consents[purposeId]))) } tcfApi('addEventListener', TCF_VERSION, consentsListener) return () => { From 547c28b7d64be9ed6a80160af9eefa83ddfafab8 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 10:40:13 +0100 Subject: [PATCH 072/134] fix(packages/sui-react-context): fix linting issues --- packages/sui-react-context/src/index.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/sui-react-context/src/index.tsx b/packages/sui-react-context/src/index.tsx index 1c1f0bbd0..69858f98a 100644 --- a/packages/sui-react-context/src/index.tsx +++ b/packages/sui-react-context/src/index.tsx @@ -2,8 +2,7 @@ import * as React from 'react' import hoistNonReactStatics from 'hoist-non-react-statics' -type SUIContextType = React.Context -& { +type SUIContextType = React.Context & { wrapper?: (Component: React.ComponentType, displayName: string) => React.ComponentType } @@ -11,19 +10,15 @@ const SUIContext: SUIContextType = React.createContext({}) SUIContext.wrapper = (Component, displayName): React.ComponentType => { const WrappedComponent = (props: any): JSX.Element => ( - - {context => } - + {context => } ) - WrappedComponent.displayName = Component.displayName !== undefined - ? Component.displayName - : displayName + WrappedComponent.displayName = Component.displayName !== undefined ? Component.displayName : displayName return hoistNonReactStatics(WrappedComponent, Component) } -export function useSuiContext (): React.Context { +export function useSuiContext(): React.Context { return React.useContext(SUIContext) } From 99d0af8d741c7243d4a0582665ad4ebb61301402 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 10:40:13 +0100 Subject: [PATCH 073/134] fix(packages/sui-react-head): fix linting issues --- packages/sui-react-head/src/Body.tsx | 18 ++++---- packages/sui-react-head/src/Html.tsx | 6 +-- packages/sui-react-head/src/index.tsx | 27 ++++-------- packages/sui-react-head/src/server.ts | 25 ++++++----- packages/sui-react-head/src/utils.tsx | 62 +++++++++++++-------------- 5 files changed, 65 insertions(+), 73 deletions(-) diff --git a/packages/sui-react-head/src/Body.tsx b/packages/sui-react-head/src/Body.tsx index e67ac54c3..7b89a6632 100644 --- a/packages/sui-react-head/src/Body.tsx +++ b/packages/sui-react-head/src/Body.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/prop-types */ -import { useEffect } from 'react' -import { Meta } from 'react-head' +import {useEffect} from 'react' +import {Meta} from 'react-head' export const BODY_ATTRIBUTES_KEY = 'bodyattributes' const isClient = typeof window !== 'undefined' @@ -10,24 +10,22 @@ interface BodyProps { attributes: object } -const Body: React.FC = ({ attributes = {} }) => { +const Body: React.FC = ({attributes = {}}) => { useEffect(() => { - const { body } = document + const {body} = document - function toggleBodyAttributes ({ action = 'set' } = {}): void { + function toggleBodyAttributes({action = 'set'} = {}): void { const method = `${action}Attribute` - Object.entries(attributes).forEach(([key, value]) => - body[method](key, value) - ) + Object.entries(attributes).forEach(([key, value]) => body[method](key, value)) } toggleBodyAttributes() - return () => toggleBodyAttributes({ action: 'remove' }) + return () => toggleBodyAttributes({action: 'remove'}) }, [attributes]) if (isClient) return null // on the server, use the Meta tag to extract later - const metaProps = { ...attributes, name: BODY_ATTRIBUTES_KEY } + const metaProps = {...attributes, name: BODY_ATTRIBUTES_KEY} return } diff --git a/packages/sui-react-head/src/Html.tsx b/packages/sui-react-head/src/Html.tsx index 10cd69326..e9335f89d 100644 --- a/packages/sui-react-head/src/Html.tsx +++ b/packages/sui-react-head/src/Html.tsx @@ -1,6 +1,6 @@ /* eslint-disable react/prop-types */ -import { Meta } from 'react-head' +import {Meta} from 'react-head' export const HTML_ATTRIBUTES_KEY = 'htmlattributes' const isClient = typeof window !== 'undefined' @@ -9,10 +9,10 @@ interface HtmlProps { attributes: object } -const Html: React.FC = ({ attributes = {} }) => { +const Html: React.FC = ({attributes = {}}) => { if (isClient) return null // on the server, use the Meta tag to extract later - const metaProps = { ...attributes, name: HTML_ATTRIBUTES_KEY } + const metaProps = {...attributes, name: HTML_ATTRIBUTES_KEY} return } diff --git a/packages/sui-react-head/src/index.tsx b/packages/sui-react-head/src/index.tsx index f655ab2bf..f26489d2d 100644 --- a/packages/sui-react-head/src/index.tsx +++ b/packages/sui-react-head/src/index.tsx @@ -1,13 +1,11 @@ /* eslint-disable react/prop-types */ import * as React from 'react' -import { - HeadProvider, Link, Meta as MetaPrimitive, Style, Title -} from 'react-head' +import {HeadProvider, Link, Meta as MetaPrimitive, Style, Title} from 'react-head' import Body from './Body' import Html from './Html' -import { extractTagsFrom, extractTitleFrom, renderStyles, renderTags } from './utils' +import {extractTagsFrom, extractTitleFrom, renderStyles, renderTags} from './utils' interface HeadProps { bodyAttributes?: object @@ -31,23 +29,16 @@ interface MetaTagInverterProps extends React.MetaHTMLAttributes 'data-rh': string } -const MetaTagInverter: React.FC = ({ 'data-rh': rh, ...others }) => { +const MetaTagInverter: React.FC = ({'data-rh': rh, ...others}) => { return } -const Meta: React.FC = (props) => { +const Meta: React.FC = props => { // @ts-expect-error return } -const Head: React.FC = ({ - bodyAttributes, - children, - htmlAttributes, - title, - meta = [], - link = [] -}) => { +const Head: React.FC = ({bodyAttributes, children, htmlAttributes, title, meta = [], link = []}) => { const metaTagsToRender = extractTagsFrom({ children, tag: 'meta', @@ -73,14 +64,14 @@ const Head: React.FC = ({ return ( <> {titleToRender !== '' && {titleToRender}} - {renderTags({ tagsArray: metaTagsToRender, Component: Meta })} - {renderTags({ tagsArray: linkTagsToRender, Component: Link })} - {renderStyles({ stylesArray: stylesTagsToRender, Component: Style })} + {renderTags({tagsArray: metaTagsToRender, Component: Meta})} + {renderTags({tagsArray: linkTagsToRender, Component: Link})} + {renderStyles({stylesArray: stylesTagsToRender, Component: Style})} {bodyAttributes != null && } {htmlAttributes != null && } ) } -export { HeadProvider } +export {HeadProvider} export default Head diff --git a/packages/sui-react-head/src/server.ts b/packages/sui-react-head/src/server.ts index 8bbfd0aaa..5101f849d 100644 --- a/packages/sui-react-head/src/server.ts +++ b/packages/sui-react-head/src/server.ts @@ -1,8 +1,8 @@ -import { renderToString } from 'react-dom/server' +import {renderToString} from 'react-dom/server' -import { BODY_ATTRIBUTES_KEY } from './Body' -import { HTML_ATTRIBUTES_KEY } from './Html' -import { ComponentTag } from './types' +import {BODY_ATTRIBUTES_KEY} from './Body' +import {HTML_ATTRIBUTES_KEY} from './Html' +import {ComponentTag} from './types' interface ExtractPropsFromConfig { withKey: string @@ -12,13 +12,13 @@ interface ExtractPropsFromConfig { * Extract props from a list of tags a specific tag by using a key * and then discard this key before returning the key */ -const extractPropsFrom = (tags: ComponentTag[], { withKey }: ExtractPropsFromConfig): undefined | { [x: string]: any} => { +const extractPropsFrom = (tags: ComponentTag[], {withKey}: ExtractPropsFromConfig): undefined | {[x: string]: any} => { // search the tag using the key and default to an empty object for simplicity - const tag: ComponentTag | undefined = tags.find(({ props }) => props.name === withKey) + const tag: ComponentTag | undefined = tags.find(({props}) => props.name === withKey) if (tag != null) { // discard the key used to search the tag - const { name, ...restOfTag } = tag.props + const {name, ...restOfTag} = tag.props // return only the desired info for the tag return restOfTag } @@ -27,7 +27,7 @@ const extractPropsFrom = (tags: ComponentTag[], { withKey }: ExtractPropsFromCon /** * Transform the object from the head to a string to be used in the server */ -const transformToString = (headObject: { [key: string]: string} = {}): string => +const transformToString = (headObject: {[key: string]: string} = {}): string => Object.entries(headObject) .map(([key, value]) => `${key}="${value}"`) .join(' ') @@ -35,7 +35,11 @@ const transformToString = (headObject: { [key: string]: string} = {}): string => /** * Render the tags for the head */ -export function renderHeadTagsToString (headTags: any[]): { headString: string, bodyAttributes: string, htmlAttributes: string} { +export function renderHeadTagsToString(headTags: any[]): { + headString: string + bodyAttributes: string + htmlAttributes: string +} { const bodyAttributesProps = extractPropsFrom(headTags, { withKey: BODY_ATTRIBUTES_KEY }) @@ -44,8 +48,7 @@ export function renderHeadTagsToString (headTags: any[]): { headString: string, }) const headTagsToRender = headTags.filter( - ({ props }) => - props.name !== BODY_ATTRIBUTES_KEY && props.name !== HTML_ATTRIBUTES_KEY + ({props}) => props.name !== BODY_ATTRIBUTES_KEY && props.name !== HTML_ATTRIBUTES_KEY ) return { diff --git a/packages/sui-react-head/src/utils.tsx b/packages/sui-react-head/src/utils.tsx index ddb6068cd..c64298390 100644 --- a/packages/sui-react-head/src/utils.tsx +++ b/packages/sui-react-head/src/utils.tsx @@ -1,17 +1,16 @@ import * as React from 'react' -import { Children as ReactChildren } from 'react' +import {Children as ReactChildren} from 'react' -import { Style, Tag } from './types' +import {Style, Tag} from './types' -const checkRelNeedsHref = (rel: string): boolean => - ['alternate', 'preload', 'prefetch'].includes(rel) +const checkRelNeedsHref = (rel: string): boolean => ['alternate', 'preload', 'prefetch'].includes(rel) /** * Use rel as key but put extra info if needed * to avoid duplicated keys */ const extractRelAsKey = (tag: Tag): string | undefined => { - const { rel, href, hreflang } = tag + const {rel, href, hreflang} = tag if (rel != null) { if (hreflang != null) return `${rel}-${hreflang}` if (checkRelNeedsHref(rel) && href != null) return `${rel}-${href}` @@ -23,21 +22,21 @@ const extractRelAsKey = (tag: Tag): string | undefined => { * Extract value in a specific order */ const extractKeyFromTag = (tag: Tag): string | undefined => { - const { name, content } = tag + const {name, content} = tag return name ?? extractRelAsKey(tag) ?? content } /** * Extract children from React by tag type and return an array of React Type Component */ -export const extract = ({ children, byTag }: { children: React.ReactNode, byTag: string}): Tag[] => { +export const extract = ({children, byTag}: {children: React.ReactNode; byTag: string}): Tag[] => { const arrayOfComponents = ReactChildren.toArray(children) - return arrayOfComponents.filter(child => - React.isValidElement(child) && child.type === byTag - ).map(child => { - const el = child as React.ReactElement - return { ...el.props } - }) + return arrayOfComponents + .filter(child => React.isValidElement(child) && child.type === byTag) + .map(child => { + const el = child as React.ReactElement + return {...el.props} + }) } interface extractTagsFromParams { @@ -46,20 +45,23 @@ interface extractTagsFromParams { fallback?: any[] } -export const extractTagsFrom = ({ children, tag, fallback }: extractTagsFromParams): any[] => { +export const extractTagsFrom = ({children, tag, fallback}: extractTagsFromParams): any[] => { if (children != null) { - return extract({ children, byTag: tag }) + return extract({children, byTag: tag}) } - return (fallback != null) ? fallback : [] + return fallback != null ? fallback : [] } -interface extractTitleFromParams { children: React.ReactNode, fallback?: string} +interface extractTitleFromParams { + children: React.ReactNode + fallback?: string +} -export const extractTitleFrom = ({ children, fallback = '' }: extractTitleFromParams): string => { +export const extractTitleFrom = ({children, fallback = ''}: extractTitleFromParams): string => { if (typeof children === 'undefined') return fallback - const listOfTitles = extract({ children, byTag: 'title' }) + const listOfTitles = extract({children, byTag: 'title'}) if (listOfTitles.length > 0) { const [title] = listOfTitles return title.children !== undefined ? title.children : fallback @@ -74,16 +76,10 @@ interface renderTagsParams { tagsArray: any[] Component: React.ComponentType } -export const renderTags = ({ tagsArray = [], Component }: renderTagsParams): JSX.Element[] => +export const renderTags = ({tagsArray = [], Component}: renderTagsParams): JSX.Element[] => tagsArray.map((tag: Tag) => { - const { hreflang: hrefLang, ...restOfTagInfo } = tag - return ( - - ) + const {hreflang: hrefLang, ...restOfTagInfo} = tag + return }) /** @@ -93,8 +89,12 @@ interface renderStylesParams { stylesArray: any[] Component: React.ComponentType } -export const renderStyles = ({ stylesArray = [], Component }: renderStylesParams): JSX.Element[] => +export const renderStyles = ({stylesArray = [], Component}: renderStylesParams): JSX.Element[] => stylesArray.map((style: Style, index: number) => { - const { children, ...styleAttr } = style - return {children} + const {children, ...styleAttr} = style + return ( + + {children} + + ) }) From 19c9633f57e3ad4bc9324973cecd959307b42cf1 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 10:40:13 +0100 Subject: [PATCH 074/134] fix(packages/sui-react-initial-props): fix linting issues --- .../src/createClientContextFactoryParams.ts | 2 +- .../src/createServerContextFactoryParams.ts | 2 +- packages/sui-react-initial-props/src/index.ts | 8 +-- .../src/initialPropsContext.ts | 4 +- .../sui-react-initial-props/src/loadPage.tsx | 59 ++++++++++--------- .../src/ssrComponentWithInitialProps.tsx | 15 +++-- .../sui-react-initial-props/src/types.d.ts | 21 +++---- .../src/withInitialProps.tsx | 41 +++++-------- 8 files changed, 69 insertions(+), 83 deletions(-) diff --git a/packages/sui-react-initial-props/src/createClientContextFactoryParams.ts b/packages/sui-react-initial-props/src/createClientContextFactoryParams.ts index 5f69702f7..b32fb768a 100644 --- a/packages/sui-react-initial-props/src/createClientContextFactoryParams.ts +++ b/packages/sui-react-initial-props/src/createClientContextFactoryParams.ts @@ -1,4 +1,4 @@ -import { ContextFactoryParams } from './types' +import {ContextFactoryParams} from './types' export default (): ContextFactoryParams => ({ appConfig: window.__APP_CONFIG__, diff --git a/packages/sui-react-initial-props/src/createServerContextFactoryParams.ts b/packages/sui-react-initial-props/src/createServerContextFactoryParams.ts index 5012976bf..2bf23553e 100644 --- a/packages/sui-react-initial-props/src/createServerContextFactoryParams.ts +++ b/packages/sui-react-initial-props/src/createServerContextFactoryParams.ts @@ -1,4 +1,4 @@ -import { ContextFactoryParams } from './types' +import {ContextFactoryParams} from './types' export default (req: IncomingMessage.ServerRequest): ContextFactoryParams => ({ appConfig: req.appConfig, diff --git a/packages/sui-react-initial-props/src/index.ts b/packages/sui-react-initial-props/src/index.ts index f043a5c6d..ceeecb070 100644 --- a/packages/sui-react-initial-props/src/index.ts +++ b/packages/sui-react-initial-props/src/index.ts @@ -1,4 +1,4 @@ -export { default as createClientContextFactoryParams } from './createClientContextFactoryParams' -export { default as createServerContextFactoryParams } from './createServerContextFactoryParams' -export { default as loadPage } from './loadPage' -export { default as ssrComponentWithInitialProps } from './ssrComponentWithInitialProps' +export {default as createClientContextFactoryParams} from './createClientContextFactoryParams' +export {default as createServerContextFactoryParams} from './createServerContextFactoryParams' +export {default as loadPage} from './loadPage' +export {default as ssrComponentWithInitialProps} from './ssrComponentWithInitialProps' diff --git a/packages/sui-react-initial-props/src/initialPropsContext.ts b/packages/sui-react-initial-props/src/initialPropsContext.ts index 83d89f74f..b37eb74f3 100644 --- a/packages/sui-react-initial-props/src/initialPropsContext.ts +++ b/packages/sui-react-initial-props/src/initialPropsContext.ts @@ -1,3 +1,3 @@ -import { createContext } from 'react' +import {createContext} from 'react' -export default createContext({ initialProps: {} }) +export default createContext({initialProps: {}}) diff --git a/packages/sui-react-initial-props/src/loadPage.tsx b/packages/sui-react-initial-props/src/loadPage.tsx index 56655d6fe..f2839b18b 100644 --- a/packages/sui-react-initial-props/src/loadPage.tsx +++ b/packages/sui-react-initial-props/src/loadPage.tsx @@ -1,41 +1,42 @@ /* eslint-disable @typescript-eslint/no-floating-promises */ -import { useContext } from 'react' +import {useContext} from 'react' import InitialPropsContext from './initialPropsContext' -import { ClientPageComponent, DoneImportingPageCallback, ReactRouterTypes, WithInitialPropsComponent } from './types' +import {ClientPageComponent, DoneImportingPageCallback, ReactRouterTypes, WithInitialPropsComponent} from './types' import withInitialProps from './withInitialProps' const EMPTY_GET_INITIAL_PROPS = async (): Promise => ({}) -const createUniversalPage = (routeInfo: ReactRouterTypes.RouteInfo) => ({ default: Page }: {default: ClientPageComponent}) => { - // check if the Page page has a getInitialProps, if not put a resolve with an empty object - Page.getInitialProps = - typeof Page.getInitialProps === 'function' - ? Page.getInitialProps - : EMPTY_GET_INITIAL_PROPS +const createUniversalPage = + (routeInfo: ReactRouterTypes.RouteInfo) => + async ({default: Page}: {default: ClientPageComponent}) => { + // check if the Page page has a getInitialProps, if not put a resolve with an empty object + Page.getInitialProps = typeof Page.getInitialProps === 'function' ? Page.getInitialProps : EMPTY_GET_INITIAL_PROPS - // CLIENT - if (typeof window !== 'undefined') { - // let withInitialProps HOC handle client getInitialProps logic - return Promise.resolve(withInitialProps(Page)) + // CLIENT + if (typeof window !== 'undefined') { + // let withInitialProps HOC handle client getInitialProps logic + return Promise.resolve(withInitialProps(Page)) + } + // SERVER + // Create a component that gets the initialProps from context + // this context has been created on the `ssrWithComponentWithInitialProps` + const ServerPage: WithInitialPropsComponent = (props: object) => { + const {initialProps} = useContext(InitialPropsContext) + return + } + // recover the displayName from the original page + ServerPage.displayName = Page.displayName + // detect if the page has getInitialProps and wrap it with the routeInfo + // if we don't have any getInitialProps, just use a empty function returning an empty object + ServerPage.getInitialProps = async ( + context: object, + req: IncomingMessage.ServerRequest, + res: IncomingMessage.ClientResponse + ) => await Page.getInitialProps({context, routeInfo, req, res}) + // return the component to be used on the server + return ServerPage } - // SERVER - // Create a component that gets the initialProps from context - // this context has been created on the `ssrWithComponentWithInitialProps` - const ServerPage: WithInitialPropsComponent = (props: object) => { - const { initialProps } = useContext(InitialPropsContext) - return - } - // recover the displayName from the original page - ServerPage.displayName = Page.displayName - // detect if the page has getInitialProps and wrap it with the routeInfo - // if we don't have any getInitialProps, just use a empty function returning an empty object - ServerPage.getInitialProps = - async (context: object, req: IncomingMessage.ServerRequest, res: IncomingMessage.ClientResponse) => - await Page.getInitialProps({ context, routeInfo, req, res }) - // return the component to be used on the server - return ServerPage -} // TODO: Remove this method on next major as it's using unnecessary contextFactory param // and unnecesary calling done method instead relying on promises diff --git a/packages/sui-react-initial-props/src/ssrComponentWithInitialProps.tsx b/packages/sui-react-initial-props/src/ssrComponentWithInitialProps.tsx index f0ba75dac..48cd03455 100644 --- a/packages/sui-react-initial-props/src/ssrComponentWithInitialProps.tsx +++ b/packages/sui-react-initial-props/src/ssrComponentWithInitialProps.tsx @@ -1,11 +1,11 @@ -import { renderToNodeStream, renderToString } from 'react-dom/server' +import {renderToNodeStream, renderToString} from 'react-dom/server' import InitialPropsContext from './initialPropsContext' -import { InitialProps, SsrComponentWithInitialPropsParams } from './types' +import {InitialProps, SsrComponentWithInitialPropsParams} from './types' const hrTimeToMs = (diff: [number, number]): number => diff[0] * 1e3 + diff[1] * 1e-6 -export default async function ssrComponentWithInitialProps ({ +export default async function ssrComponentWithInitialProps({ Target, context, req, @@ -15,12 +15,11 @@ export default async function ssrComponentWithInitialProps ({ }: SsrComponentWithInitialPropsParams): Promise { const startGetInitialProps = process.hrtime() // use the getInitialProps from the page to retrieve the props to initialize - const { getInitialProps } = - renderProps.components[renderProps.components.length - 1] + const {getInitialProps} = renderProps.components[renderProps.components.length - 1] const initialProps: InitialProps = await getInitialProps(context, req, res) const diffGetInitialProps = process.hrtime(startGetInitialProps) - const { __HTTP__: http } = initialProps + const {__HTTP__: http} = initialProps if (http?.redirectTo !== undefined) { return { @@ -34,7 +33,7 @@ export default async function ssrComponentWithInitialProps ({ // Create App with Context with the initialProps const AppWithContext = ( - + ) @@ -45,7 +44,7 @@ export default async function ssrComponentWithInitialProps ({ // start to calculate renderToString const startRenderToString = process.hrtime() // render with the needed action - const renderResponse = { [renderResponseKey]: renderAction(AppWithContext) } + const renderResponse = {[renderResponseKey]: renderAction(AppWithContext)} // calculate the difference of time used rendering const diffRenderToString = process.hrtime(startRenderToString) // return all the info diff --git a/packages/sui-react-initial-props/src/types.d.ts b/packages/sui-react-initial-props/src/types.d.ts index d53677bb5..1acd21a1f 100644 --- a/packages/sui-react-initial-props/src/types.d.ts +++ b/packages/sui-react-initial-props/src/types.d.ts @@ -1,4 +1,4 @@ -import { RouteInfo } from '@s-ui/react-router/src/types' +import {RouteInfo} from '@s-ui/react-router/src/types' export * as ReactRouterTypes from '@s-ui/react-router/src/types' export interface InitialProps { @@ -19,15 +19,14 @@ export interface ContextFactoryParams { req?: object } -export type ClientPageComponent = React.ComponentType -& PageComponentOptions -& { getInitialProps: GetInitialPropsFunction } +export type ClientPageComponent = React.ComponentType & + PageComponentOptions & {getInitialProps: GetInitialPropsFunction} -export type ServerPageComponent = React.ComponentType -& PageComponentOptions -& { getInitialProps: GetInitialPropsServerFunction } +export type ServerPageComponent = React.ComponentType & + PageComponentOptions & {getInitialProps: GetInitialPropsServerFunction} -export type GetInitialPropsServerFunction = (context: object, +export type GetInitialPropsServerFunction = ( + context: object, req: IncomingMessage.ServerRequest, res: IncomingMessage.ClientResponse ) => Promise @@ -39,11 +38,9 @@ export interface GetInitialPropsClientFunctionParams { res?: IncomingMessage.ClientResponse } -export type GetInitialPropsFunction = - (params: GetInitialPropsClientFunctionParams) => Promise +export type GetInitialPropsFunction = (params: GetInitialPropsClientFunctionParams) => Promise -export type DoneImportingPageCallback = - (err: null, Page: WithInitialPropsComponent) => Promise +export type DoneImportingPageCallback = (err: null, Page: WithInitialPropsComponent) => Promise export interface RenderProps { components: ServerPageComponent[] diff --git a/packages/sui-react-initial-props/src/withInitialProps.tsx b/packages/sui-react-initial-props/src/withInitialProps.tsx index d4a5f4849..6f6427833 100644 --- a/packages/sui-react-initial-props/src/withInitialProps.tsx +++ b/packages/sui-react-initial-props/src/withInitialProps.tsx @@ -1,13 +1,9 @@ -import { useContext, useEffect, useRef, useState } from 'react' +import {useContext, useEffect, useRef, useState} from 'react' import SUIContext from '@s-ui/react-context' -import { RouteInfo } from '@s-ui/react-router/src/types' +import {RouteInfo} from '@s-ui/react-router/src/types' -import { - ClientPageComponent, - InitialProps, - WithInitialPropsComponent -} from './types' +import {ClientPageComponent, InitialProps, WithInitialPropsComponent} from './types' const INITIAL_PROPS_KEY = '__INITIAL_PROPS__' @@ -22,7 +18,7 @@ const getInitialPropsFromWindow = (): object | undefined => { } // extract needed info from props for routeInfo object -const createRouteInfoFromProps = ({ location, params, routes }: RouteInfo): RouteInfo => ({ +const createRouteInfoFromProps = ({location, params, routes}: RouteInfo): RouteInfo => ({ location, params, routes @@ -39,7 +35,7 @@ const createRouteInfoFromProps = ({ location, params, routes }: RouteInfo): Rout // gets props updated. Also, since PageComponent keeps mounted it will receive // an `isLoading` prop while getInitialProps is in progress. export default (Page: ClientPageComponent): WithInitialPropsComponent => { - const { keepMounted = false } = Page + const {keepMounted = false} = Page // gather window initial props for this Page, if present const windowInitialProps = getInitialPropsFromWindow() // remove the variable of the window @@ -55,9 +51,9 @@ export default (Page: ClientPageComponent): WithInitialPropsComponent => { // consume sui context from the context provider const suiContext: object = useContext(SUIContext) // pathName from context is outdated, so we update it from routeInfo - const context = { ...suiContext, pathName: routeInfo.location.pathname } + const context = {...suiContext, pathName: routeInfo.location.pathname} - const [{ initialProps, isLoading }, setState] = useState(() => ({ + const [{initialProps, isLoading}, setState] = useState(() => ({ initialProps: initialPropsFromWindowRef.current ?? {}, isLoading: initialPropsFromWindowRef.current == null })) @@ -70,22 +66,22 @@ export default (Page: ClientPageComponent): WithInitialPropsComponent => { } else { // only update state if already request initial props if (requestedInitialPropsOnceRef.current) { - setState({ initialProps, isLoading: true }) + setState({initialProps, isLoading: true}) } - Page.getInitialProps({ context, routeInfo }) + Page.getInitialProps({context, routeInfo}) .then((initialProps: InitialProps) => { - const { __HTTP__: http } = initialProps + const {__HTTP__: http} = initialProps if (http?.redirectTo !== undefined) { window.location = http.redirectTo return } - setState({ initialProps, isLoading: false }) + setState({initialProps, isLoading: false}) }) .catch((error: Error) => { - setState({ initialProps: { error }, isLoading: false }) + setState({initialProps: {error}, isLoading: false}) }) .finally(() => { if (requestedInitialPropsOnceRef.current) return @@ -94,9 +90,7 @@ export default (Page: ClientPageComponent): WithInitialPropsComponent => { } }, [routeInfo.location]) // eslint-disable-line react-hooks/exhaustive-deps - const renderPage = (): any => ( - - ) + const renderPage = (): any => // if the page has a `keepMounted` property and already requested // initialProps once, just keep rendering the page @@ -106,9 +100,7 @@ export default (Page: ClientPageComponent): WithInitialPropsComponent => { const renderLoading = (): React.ElementType | null => { // check if the page has a `renderLoading` method, if not, just render nothing - return (Page.renderLoading != null) - ? Page.renderLoading({ context, routeInfo }) - : null + return Page.renderLoading != null ? Page.renderLoading({context, routeInfo}) : null } return isLoading ? renderLoading() : renderPage() @@ -116,10 +108,7 @@ export default (Page: ClientPageComponent): WithInitialPropsComponent => { // if `keepMounted` property is found and the component is the same one, // we just reuse it instead of returning a new one - if ( - keepMounted && - Page.displayName === latestClientPage?.Page?.displayName - ) { + if (keepMounted && Page.displayName === latestClientPage?.Page?.displayName) { return latestClientPage } From 1904ca297650c5a7a3f3d6b187ecd9359e9a3d2a Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 10:40:14 +0100 Subject: [PATCH 075/134] fix(packages/sui-studio): fix linting issues --- packages/sui-studio/src/components/preview/_style.scss | 6 ++---- packages/sui-studio/src/styles/_settings.scss | 4 ++-- .../sui-studio/workbench/src/components/Root/index.scss | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/sui-studio/src/components/preview/_style.scss b/packages/sui-studio/src/components/preview/_style.scss index 6c76cbd9c..258cf00f6 100644 --- a/packages/sui-studio/src/components/preview/_style.scss +++ b/packages/sui-studio/src/components/preview/_style.scss @@ -68,8 +68,7 @@ } &:focus { outline: none; - box-shadow: inset 0 0 0 1px $c-primary, - 0 0 0 4px rgba($c-primary, 0.2); + box-shadow: inset 0 0 0 1px $c-primary, 0 0 0 4px rgba($c-primary, 0.2); } } & + button { @@ -134,8 +133,7 @@ } &:focus { outline: none; - box-shadow: inset 0 0 0 1px $c-primary, - 0 0 0 4px rgba($c-primary, 0.2); + box-shadow: inset 0 0 0 1px $c-primary, 0 0 0 4px rgba($c-primary, 0.2); } } } diff --git a/packages/sui-studio/src/styles/_settings.scss b/packages/sui-studio/src/styles/_settings.scss index 63c0d4189..57a732d2d 100644 --- a/packages/sui-studio/src/styles/_settings.scss +++ b/packages/sui-studio/src/styles/_settings.scss @@ -23,8 +23,8 @@ $bgc-tag: #eeeeee; // --- Fonts --- // // Font family -$ff-sans-serif: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, - Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol' !default; +$ff-sans-serif: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', + 'Segoe UI Emoji', 'Segoe UI Symbol' !default; // Font weights $fw-ultra-light: 100 !default; diff --git a/packages/sui-studio/workbench/src/components/Root/index.scss b/packages/sui-studio/workbench/src/components/Root/index.scss index f9e2c8aa7..cf7b0a5d0 100644 --- a/packages/sui-studio/workbench/src/components/Root/index.scss +++ b/packages/sui-studio/workbench/src/components/Root/index.scss @@ -1,6 +1,6 @@ * { - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, - Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', + 'Helvetica Neue', sans-serif; } .Root { From 37213c085abc6ba99e1d784c88e4b026ec161134 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 10:40:15 +0100 Subject: [PATCH 076/134] fix(packages/sui-theme): fix linting issues --- .../sui-theme/src/components/_button.scss | 7 +---- .../src/components/atom/input/_settings.scss | 7 ++--- .../src/settings-compat-v7/_layout.scss | 6 +--- packages/sui-theme/src/utils/_colors.scss | 7 +---- packages/sui-theme/src/utils/_text.scss | 28 +++---------------- 5 files changed, 10 insertions(+), 45 deletions(-) diff --git a/packages/sui-theme/src/components/_button.scss b/packages/sui-theme/src/components/_button.scss index 789766615..3e1fb1cb5 100644 --- a/packages/sui-theme/src/components/_button.scss +++ b/packages/sui-theme/src/components/_button.scss @@ -44,12 +44,7 @@ @include sui-button--flat; } @if $type == 'custom' { - @include sui-button--custom( - $background-color, - $color, - $icon-fill, - $icon-stroke - ); + @include sui-button--custom($background-color, $color, $icon-fill, $icon-stroke); } @if $size == 'small' { diff --git a/packages/sui-theme/src/components/atom/input/_settings.scss b/packages/sui-theme/src/components/atom/input/_settings.scss index ecfc7318b..58c472490 100644 --- a/packages/sui-theme/src/components/atom/input/_settings.scss +++ b/packages/sui-theme/src/components/atom/input/_settings.scss @@ -30,7 +30,6 @@ $c-atom-input--success: $c-success !default; $c-atom-input--error: $c-error !default; $c-atom-input--alert: $c-alert !default; -$sizes-atom-input: xl $h-atom-input--xl, l $h-atom-input--l, m $h-atom-input--m, - xs $h-atom-input--xs, s $h-atom-input--s !default; -$states-atom-input: success $c-atom-input--success, error $c-atom-input--error, - alert $c-atom-input--alert !default; +$sizes-atom-input: xl $h-atom-input--xl, l $h-atom-input--l, m $h-atom-input--m, xs $h-atom-input--xs, + s $h-atom-input--s !default; +$states-atom-input: success $c-atom-input--success, error $c-atom-input--error, alert $c-atom-input--alert !default; diff --git a/packages/sui-theme/src/settings-compat-v7/_layout.scss b/packages/sui-theme/src/settings-compat-v7/_layout.scss index 93727be1f..65979dc0b 100644 --- a/packages/sui-theme/src/settings-compat-v7/_layout.scss +++ b/packages/sui-theme/src/settings-compat-v7/_layout.scss @@ -26,11 +26,7 @@ $breakpoint-names: map-keys($breakpoints) !default; // md @function breakpoint-next($name) { $n: index($breakpoint-names, $name); - @return if( - $n < length($breakpoint-names), - nth($breakpoint-names, $n + 1), - null - ); + @return if($n < length($breakpoint-names), nth($breakpoint-names, $n + 1), null); } // Maximum breakpoint width. Null for the largest (last) breakpoint. diff --git a/packages/sui-theme/src/utils/_colors.scss b/packages/sui-theme/src/utils/_colors.scss index d0b298e14..edb4ca3c2 100644 --- a/packages/sui-theme/src/utils/_colors.scss +++ b/packages/sui-theme/src/utils/_colors.scss @@ -18,12 +18,7 @@ $color-variation-light: white !default; $color-lighten-steps: 25, 50, 75, 90, 95 !default; $color-darken-steps: 20, 35, 55, 75 !default; -@function color-variation( - $color, - $step: 0, - $dark: $color-variation-dark, - $light: $color-variation-light -) { +@function color-variation($color, $step: 0, $dark: $color-variation-dark, $light: $color-variation-light) { $positive-steps: length($color-lighten-steps); $negative-steps: length($color-darken-steps); diff --git a/packages/sui-theme/src/utils/_text.scss b/packages/sui-theme/src/utils/_text.scss index 2f041512d..806068219 100644 --- a/packages/sui-theme/src/utils/_text.scss +++ b/packages/sui-theme/src/utils/_text.scss @@ -51,22 +51,12 @@ @include calc-font-size($fz-caption, $fw-caption, $ls-caption, $lh-caption); } @if $type == 'overline' { - @include calc-font-size( - $fz-overline, - $fw-overline, - $ls-overline, - $lh-overline - ); + @include calc-font-size($fz-overline, $fw-overline, $ls-overline, $lh-overline); } } @mixin font-size-large { - @include calc-font-size( - $fz-large-title, - $fw-large-title, - $ls-large-title, - $lh-large-title - ); + @include calc-font-size($fz-large-title, $fw-large-title, $ls-large-title, $lh-large-title); } @mixin font-size-title1 { @include calc-font-size($fz-title1, $fw-title1, $ls-title1, $lh-title1); @@ -78,20 +68,10 @@ @include calc-font-size($fz-title3, $fw-title3, $ls-title3, $lh-title3); } @mixin font-size-headline1 { - @include calc-font-size( - $fz-headline1, - $fw-headline1, - $ls-headline1, - $lh-headline1 - ); + @include calc-font-size($fz-headline1, $fw-headline1, $ls-headline1, $lh-headline1); } @mixin font-size-headline2 { - @include calc-font-size( - $fz-headline2, - $fw-headline2, - $ls-headline2, - $lh-headline2 - ); + @include calc-font-size($fz-headline2, $fw-headline2, $ls-headline2, $lh-headline2); } // CSS image replacement From 06139b3628ec5fbb01c291b1f5f57daf294ecaea Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 12:35:42 +0100 Subject: [PATCH 077/134] test(packages/sui-consents): fix some imports --- packages/sui-consents/test/common/functionSpec.js | 2 +- packages/sui-consents/test/common/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sui-consents/test/common/functionSpec.js b/packages/sui-consents/test/common/functionSpec.js index ba6dec449..8fc1b87dc 100644 --- a/packages/sui-consents/test/common/functionSpec.js +++ b/packages/sui-consents/test/common/functionSpec.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ import {expect} from 'chai' -import {hasUserConsents} from '../../lib/index' +import {hasUserConsents} from '../../lib/index.js' describe('hasUserConsents', () => { describe('when the user accepts all consents', () => { diff --git a/packages/sui-consents/test/common/index.js b/packages/sui-consents/test/common/index.js index 99bb219c6..e9c5905f5 100644 --- a/packages/sui-consents/test/common/index.js +++ b/packages/sui-consents/test/common/index.js @@ -1,2 +1,2 @@ -import './functionSpec' -import './hookSpec' +import './functionSpec.js' +import './hookSpec.js' From ea9a8859e15fb1e2c44ae7724b99d3d3b305f11a Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 12:49:07 +0100 Subject: [PATCH 078/134] chore(Root): remove logs --- .github/workflows/node.js.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 322fa2bee..2aa091457 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,10 +26,7 @@ jobs: - uses: browser-actions/setup-chrome@latest - run: sudo apt-get install xvfb - run: npm install --no-save --no-fund --no-audit --legacy-peer-deps - - run: ls -pal ./node_modules/@s-ui - - run: ls ./node_modules/@s-ui/react-context - run: npx -y ultra-runner --raw --recursive prepublishOnly - - run: ls ./node_modules/@s-ui/react-context - run: npm run lint - run: npm run test:server:ci - run: xvfb-run --auto-servernum npm run test:client:ci From e022570ea7223e4f907222ff271f4faf72d96599 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 15:29:58 +0100 Subject: [PATCH 079/134] feat(packages/sui-studio): restore package version --- packages/sui-studio/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-studio/package.json b/packages/sui-studio/package.json index 422f07766..99d6f1701 100644 --- a/packages/sui-studio/package.json +++ b/packages/sui-studio/package.json @@ -1,6 +1,6 @@ { "name": "@s-ui/studio", - "version": "11.36.0-typescript.0", + "version": "11.36.0", "description": "Develop, maintain and publish your SUI components.", "main": "index.js", "bin": { From b185cc8ac0f5ae3028d2c85a9234b4d15d25fb3f Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 16:57:49 +0100 Subject: [PATCH 080/134] fix(packages/sui-react-initial-props): fix ts config --- packages/sui-react-initial-props/tsconfig.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/sui-react-initial-props/tsconfig.json b/packages/sui-react-initial-props/tsconfig.json index e7bd7dc4f..89de39364 100644 --- a/packages/sui-react-initial-props/tsconfig.json +++ b/packages/sui-react-initial-props/tsconfig.json @@ -3,5 +3,6 @@ "compilerOptions": { "outDir": "./lib", "rootDir": "./src" - } -} \ No newline at end of file + }, + "exclude": ["./lib"] +} From c28e283c65cb8f1e3e3541b09bf166caccf53b44 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 16:58:09 +0100 Subject: [PATCH 081/134] fix(packages/sui-js-compiler): fix types --- packages/sui-js-compiler/test/server/src/example.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-js-compiler/test/server/src/example.tsx b/packages/sui-js-compiler/test/server/src/example.tsx index d7e209472..e91998d4b 100644 --- a/packages/sui-js-compiler/test/server/src/example.tsx +++ b/packages/sui-js-compiler/test/server/src/example.tsx @@ -4,6 +4,6 @@ interface ThingProps { type?: 'inert' | 'moving' } -export default function Thing({name, type = 'moving'}: ThingProps): React.FC { +export default function Thing({name, type = 'moving'}: ThingProps): React.ReactElement { return
{name}
} From e9e73e746b9c7a897ae0d01dd6cd1975ef390da8 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 16:58:47 +0100 Subject: [PATCH 082/134] chore(Root): add type checking --- .github/workflows/main.yml | 60 +++++++++++++++++++++++++++++++++++ .github/workflows/node.js.yml | 40 ----------------------- package.json | 7 ++-- tsconfig.json | 11 +++---- 4 files changed, 69 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..f680facc9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,60 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Redundant Builds + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ github.token }} + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Setup Node + uses: actions/setup-node@v4 + with: + registry-url: 'https://registry.npmjs.org' + node-version-file: '.nvmrc' + cache: 'npm' + cache-dependency-path: 'package-lock.json' + + - name: Setup Chrome + uses: browser-actions/setup-chrome@latest + + - name: Install + run: | + sudo apt-get install xvfb + npm install --no-save --no-fund --no-audit --legacy-peer-deps + npx -y ultra-runner --raw --recursive prepublishOnly + + - name: Lint + run: npm run lint + + - name: Type Checking + run: npm run types:check + + - name: Tests + run: | + npm run test:server:ci + xvfb-run --auto-servernum npm run test:client:ci + + - name: Release packages + run: npx -p ./packages/sui-ci sui-ci release + env: + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + GITHUB_EMAIL: cloud-accounts@scmspain.com + GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }} + GITHUB_USER: sui-bot + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index 2aa091457..000000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI - -on: - push: - branches: [master] - pull_request: - branches: [master] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Cancel Previous Redundant Builds - uses: styfle/cancel-workflow-action@0.6.0 - with: - access_token: ${{ github.token }} - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - persist-credentials: false - - uses: actions/setup-node@v2 - with: - node-version: 18 - registry-url: 'https://registry.npmjs.org' - - uses: browser-actions/setup-chrome@latest - - run: sudo apt-get install xvfb - - run: npm install --no-save --no-fund --no-audit --legacy-peer-deps - - run: npx -y ultra-runner --raw --recursive prepublishOnly - - run: npm run lint - - run: npm run test:server:ci - - run: xvfb-run --auto-servernum npm run test:client:ci - - run: npx -p ./packages/sui-ci sui-ci release - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - GITHUB_EMAIL: cloud-accounts@scmspain.com - GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }} - GITHUB_USER: sui-bot - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 1dd8da3a0..02b9a1b71 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,9 @@ "test:server:watch": "npm run test:server -- --watch", "test:e2e": "node ./packages/sui-studio/test/server/integration/static-server.js ./packages/sui-studio/test/server/integration/sample-studio/public && npx @s-ui/test-e2e --baseUrl=http://localhost:1234", "pre-commit": "sui-lint js --staged && sui-lint sass --staged", - "pre-push": "npm run test", - "commit-msg": "validate-commit-msg" + "pre-push": "npm run test && npm run types:check", + "commit-msg": "validate-commit-msg", + "types:check": "tsc" }, "devDependencies": { "@babel/cli": "7", @@ -79,4 +80,4 @@ "stylelint": { "extends": "./node_modules/@s-ui/lint/stylelint.config.js" } -} \ No newline at end of file +} diff --git a/tsconfig.json b/tsconfig.json index d90b1d3a1..96482e01e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,11 +11,10 @@ "skipLibCheck": true, "strict": true, "target": "es5", - "types": [ - "react", - "node" - ] + "types": ["react", "node"] }, "exclude": ["node_modules", "lib"], - "typeAcquisition": { "enable": true } -} \ No newline at end of file + "typeAcquisition": { + "enable": true + } +} From 887e8089f45c6ae7690dfcbf3fd0dfae410d6abb Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 17:01:50 +0100 Subject: [PATCH 083/134] chore(Root): fix cache option --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f680facc9..16ec7c07c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,6 @@ jobs: registry-url: 'https://registry.npmjs.org' node-version-file: '.nvmrc' cache: 'npm' - cache-dependency-path: 'package-lock.json' - name: Setup Chrome uses: browser-actions/setup-chrome@latest From 931c7ef6866c839ffd7e1e3546cd82380bbb0c2f Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 18 Dec 2023 17:03:24 +0100 Subject: [PATCH 084/134] chore(Root): remove cache --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 16ec7c07c..05f08efe2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,6 @@ jobs: with: registry-url: 'https://registry.npmjs.org' node-version-file: '.nvmrc' - cache: 'npm' - name: Setup Chrome uses: browser-actions/setup-chrome@latest From 9acc197d5d353933494ea242580a6c0b0707e582 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 20 Dec 2023 11:30:20 +0100 Subject: [PATCH 085/134] chore(Root): modify case --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 05f08efe2..451de9b4b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,7 +47,7 @@ jobs: npm run test:server:ci xvfb-run --auto-servernum npm run test:client:ci - - name: Release packages + - name: Release Packages run: npx -p ./packages/sui-ci sui-ci release env: DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} From f142e815347d9cf85f625baeb739c5ca0a1f3576 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 22 Jan 2024 13:05:00 +0100 Subject: [PATCH 086/134] test(packages/sui-js-compiler): remove clean --- packages/sui-js-compiler/test/server/jsCompilerSpec.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/sui-js-compiler/test/server/jsCompilerSpec.js b/packages/sui-js-compiler/test/server/jsCompilerSpec.js index af0085ba1..873ebe881 100644 --- a/packages/sui-js-compiler/test/server/jsCompilerSpec.js +++ b/packages/sui-js-compiler/test/server/jsCompilerSpec.js @@ -20,11 +20,6 @@ describe('@s-ui/js-compiler', () => { await fs.remove(tsConfigPath) }) - afterEach(async () => { - await fs.remove(libPath) - await fs.remove(tsConfigPath) - }) - it('should compile a "src" folder with a JavaScript file and output it to "lib"', async () => { const {stdout} = await exec('node ../../index.js', { cwd From 9f2c30c4a9db70a8622c02b98100a1bacb2812cb Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 22 Jan 2024 14:56:12 +0100 Subject: [PATCH 087/134] chore(Root): check pr workflow --- .github/workflows/main.yml | 15 +++++++++++++++ package.json | 4 ++++ scripts/publish-tagged-packages.mjs | 21 +++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 scripts/publish-tagged-packages.mjs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be64ee10f..370fdbffd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,3 +60,18 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }} GITHUB_USER: sui-bot NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + publish-tagged-packages: + name: Publish Tagged Packages to NPM + if: github.ref != 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - name: Get Files + id: files + uses: jitterbit/get-changed-files@v1 + with: + format: 'json' + + - name: Publish Packages + working-directory: ${{ github.workspace }} + run: publish-tagged-packages '${{ steps.files.outputs.added_modified }}' diff --git a/package.json b/package.json index 02b9a1b71..897a4fb33 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,9 @@ "workspaces": [ "packages/*" ], + "bin": { + "publish-tagged-packages": "./scripts/publish-tagged-packages.mjs" + }, "scripts": { "phoenix": "npx @s-ui/mono phoenix && npx -y ultra-runner --raw --recursive prepublishOnly --build &>/dev/null", "co": "npx @s-ui/mono commit", @@ -34,6 +37,7 @@ "@s-ui/precommit": "3", "@s-ui/react-context": "1", "chai": "4.3.6", + "commander": "11.1.0", "react": "17", "sinon": "10.0.0", "typescript": "5.0.4", diff --git a/scripts/publish-tagged-packages.mjs b/scripts/publish-tagged-packages.mjs new file mode 100644 index 000000000..98f8f9f7f --- /dev/null +++ b/scripts/publish-tagged-packages.mjs @@ -0,0 +1,21 @@ +#!/usr/bin/env node + +const program = require('commander') + +program + .option('-f, --files [files]', 'JSON-stringified list of added and modified files.') + .on('--help', () => { + console.log(' Examples:') + console.log('') + console.log( + ' $ publish-tagged-packages --tag ongoing-branch --files \'["packages/sui-mono/foo.js", "packages/sui-bundler/bar.js"]\'' + ) + console.log('') + }) + .parse(process.argv) + +const {files} = program.opts() + +console.log({files}) + +program.exit(0) From d7fdf6a1ac2173e1e3606bc2b3bc6705430f849d Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 22 Jan 2024 15:00:24 +0100 Subject: [PATCH 088/134] chore(Root): change script command --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 370fdbffd..da35127e6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,4 +74,4 @@ jobs: - name: Publish Packages working-directory: ${{ github.workspace }} - run: publish-tagged-packages '${{ steps.files.outputs.added_modified }}' + run: node ./scripts/publish-tagged-packages.mjs --tag '${{ github.ref }}' --files '${{ steps.files.outputs.added_modified }}' From 71fcce1db2f59c0a2cb089eba986b33716bca0e7 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 22 Jan 2024 15:21:01 +0100 Subject: [PATCH 089/134] chore(Root): change script execution --- .github/workflows/main.yml | 3 +-- package.json | 4 +--- scripts/publish-tagged-packages.js | 26 ++++++++++++++++++++++++++ scripts/publish-tagged-packages.mjs | 21 --------------------- 4 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 scripts/publish-tagged-packages.js delete mode 100644 scripts/publish-tagged-packages.mjs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index da35127e6..bc0bd65b7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -73,5 +73,4 @@ jobs: format: 'json' - name: Publish Packages - working-directory: ${{ github.workspace }} - run: node ./scripts/publish-tagged-packages.mjs --tag '${{ github.ref }}' --files '${{ steps.files.outputs.added_modified }}' + run: npm run publish-tagged-packages --tag '${{ github.ref_name }}' --files '${{ steps.files.outputs.added_modified }}' diff --git a/package.json b/package.json index 897a4fb33..ba0a885e2 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,6 @@ "workspaces": [ "packages/*" ], - "bin": { - "publish-tagged-packages": "./scripts/publish-tagged-packages.mjs" - }, "scripts": { "phoenix": "npx @s-ui/mono phoenix && npx -y ultra-runner --raw --recursive prepublishOnly --build &>/dev/null", "co": "npx @s-ui/mono commit", @@ -28,6 +25,7 @@ "test:e2e": "node ./packages/sui-studio/test/server/integration/static-server.js ./packages/sui-studio/test/server/integration/sample-studio/public && npx @s-ui/test-e2e --baseUrl=http://localhost:1234", "pre-commit": "sui-lint js --staged && sui-lint sass --staged", "pre-push": "npm run test && npm run types:check", + "publish-tagged-packages": "node ./scripts/publish-tagged-packages.js", "commit-msg": "validate-commit-msg", "types:check": "tsc" }, diff --git a/scripts/publish-tagged-packages.js b/scripts/publish-tagged-packages.js new file mode 100644 index 000000000..3adb35f45 --- /dev/null +++ b/scripts/publish-tagged-packages.js @@ -0,0 +1,26 @@ +#!/usr/bin/env node +const program = require('commander') + +program + .name('publish-tagged-packages') + .description('CLI to publish new tagged versions from modified packages in pull requests.') + .version('0.0.1') + +program + .option('-t, --tag [tag]', 'Tag used to publish the packages to NPM.') + .option('-f, --files [files]', 'JSON-stringified list of added and modified files.') + .on('--help', () => { + console.log(' Examples:') + console.log('') + console.log( + ' $ node ./scripts/publish-tagged-packages.js --tag ongoing-branch --files \'["packages/sui-mono/foo.js", "packages/sui-bundler/bar.js"]\'' + ) + console.log('') + }) + .parse(process.argv) + +const {tag, files} = program.opts() + +console.log({tag, files: JSON.parse(files)}) + +program.parse() diff --git a/scripts/publish-tagged-packages.mjs b/scripts/publish-tagged-packages.mjs deleted file mode 100644 index 98f8f9f7f..000000000 --- a/scripts/publish-tagged-packages.mjs +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env node - -const program = require('commander') - -program - .option('-f, --files [files]', 'JSON-stringified list of added and modified files.') - .on('--help', () => { - console.log(' Examples:') - console.log('') - console.log( - ' $ publish-tagged-packages --tag ongoing-branch --files \'["packages/sui-mono/foo.js", "packages/sui-bundler/bar.js"]\'' - ) - console.log('') - }) - .parse(process.argv) - -const {files} = program.opts() - -console.log({files}) - -program.exit(0) From d8a77204624d59938a0b2103c2ed7041dcf1e650 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 22 Jan 2024 15:22:43 +0100 Subject: [PATCH 090/134] chore(Root): add missing checkout --- .github/workflows/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc0bd65b7..db31ecb5e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,6 +66,12 @@ jobs: if: github.ref != 'refs/heads/master' runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + persist-credentials: false + - name: Get Files id: files uses: jitterbit/get-changed-files@v1 From 8e5184ad632f95b7e1e8ef20d181aaf0b78583ac Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 22 Jan 2024 15:26:50 +0100 Subject: [PATCH 091/134] chore(Root): add install step --- .github/workflows/main.yml | 10 ++++++++++ package.json | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index db31ecb5e..a027126ad 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -72,6 +72,16 @@ jobs: fetch-depth: 0 persist-credentials: false + - name: Setup Node + uses: actions/setup-node@v4 + with: + registry-url: 'https://registry.npmjs.org' + node-version-file: '.nvmrc' + + - name: Install + run: | + npm install -D commander + - name: Get Files id: files uses: jitterbit/get-changed-files@v1 diff --git a/package.json b/package.json index ba0a885e2..10bf72dec 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "@s-ui/precommit": "3", "@s-ui/react-context": "1", "chai": "4.3.6", - "commander": "11.1.0", "react": "17", "sinon": "10.0.0", "typescript": "5.0.4", From 13a3fa23e7e39004eb67385cd7e12b4c014bbdf6 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 22 Jan 2024 15:32:32 +0100 Subject: [PATCH 092/134] chore(Root): fix some stuff --- .github/workflows/main.yml | 2 +- ...publish-tagged-packages.js => publish-tagged-packages.mjs} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename scripts/{publish-tagged-packages.js => publish-tagged-packages.mjs} (86%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a027126ad..7e0a529b0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -89,4 +89,4 @@ jobs: format: 'json' - name: Publish Packages - run: npm run publish-tagged-packages --tag '${{ github.ref_name }}' --files '${{ steps.files.outputs.added_modified }}' + run: npm run publish-tagged-packages -- --tag ${{ github.event.pull_request.base.ref }} --files ${{ steps.files.outputs.added_modified }} diff --git a/scripts/publish-tagged-packages.js b/scripts/publish-tagged-packages.mjs similarity index 86% rename from scripts/publish-tagged-packages.js rename to scripts/publish-tagged-packages.mjs index 3adb35f45..16badba46 100644 --- a/scripts/publish-tagged-packages.js +++ b/scripts/publish-tagged-packages.mjs @@ -13,7 +13,7 @@ program console.log(' Examples:') console.log('') console.log( - ' $ node ./scripts/publish-tagged-packages.js --tag ongoing-branch --files \'["packages/sui-mono/foo.js", "packages/sui-bundler/bar.js"]\'' + ' $ node ./scripts/publish-tagged-packages.js --tag ongoing-branch --files ["packages/sui-mono/foo.js", "packages/sui-bundler/bar.js"]' ) console.log('') }) @@ -23,4 +23,4 @@ const {tag, files} = program.opts() console.log({tag, files: JSON.parse(files)}) -program.parse() +program.parse(process.argv) From 29c0b79f065394bcc58932d9c96528b8f015dc40 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 22 Jan 2024 15:37:02 +0100 Subject: [PATCH 093/134] chore(Root): fix more things --- .github/workflows/main.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7e0a529b0..117d2f2f1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -89,4 +89,4 @@ jobs: format: 'json' - name: Publish Packages - run: npm run publish-tagged-packages -- --tag ${{ github.event.pull_request.base.ref }} --files ${{ steps.files.outputs.added_modified }} + run: npm run publish-tagged-packages -- --tag ${{ github.event.pull_request.head.ref }} --files ${{ steps.files.outputs.added_modified }} diff --git a/package.json b/package.json index 10bf72dec..ef6cba654 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "test:e2e": "node ./packages/sui-studio/test/server/integration/static-server.js ./packages/sui-studio/test/server/integration/sample-studio/public && npx @s-ui/test-e2e --baseUrl=http://localhost:1234", "pre-commit": "sui-lint js --staged && sui-lint sass --staged", "pre-push": "npm run test && npm run types:check", - "publish-tagged-packages": "node ./scripts/publish-tagged-packages.js", + "publish-tagged-packages": "node ./scripts/publish-tagged-packages.mjs", "commit-msg": "validate-commit-msg", "types:check": "tsc" }, From 136dff7017ecb8368273e911ae636d00c01479e2 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 22 Jan 2024 15:41:24 +0100 Subject: [PATCH 094/134] chore(Root): fix some other things --- .github/workflows/main.yml | 2 +- scripts/publish-tagged-packages.mjs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 117d2f2f1..41bc68c13 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -89,4 +89,4 @@ jobs: format: 'json' - name: Publish Packages - run: npm run publish-tagged-packages -- --tag ${{ github.event.pull_request.head.ref }} --files ${{ steps.files.outputs.added_modified }} + run: npm run publish-tagged-packages -- --tag '${{ github.event.pull_request.head.ref }}' --files '${{ steps.files.outputs.added_modified }}' diff --git a/scripts/publish-tagged-packages.mjs b/scripts/publish-tagged-packages.mjs index 16badba46..ccc038cea 100644 --- a/scripts/publish-tagged-packages.mjs +++ b/scripts/publish-tagged-packages.mjs @@ -1,5 +1,7 @@ #!/usr/bin/env node -const program = require('commander') +/* eslint-disable no-console */ + +import program from 'commander' program .name('publish-tagged-packages') @@ -13,7 +15,7 @@ program console.log(' Examples:') console.log('') console.log( - ' $ node ./scripts/publish-tagged-packages.js --tag ongoing-branch --files ["packages/sui-mono/foo.js", "packages/sui-bundler/bar.js"]' + ' $ node ./scripts/publish-tagged-packages.mjs --tag \'ongoing-branch\' --files \'["packages/sui-mono/foo.js", "packages/sui-bundler/bar.js"]\'' ) console.log('') }) From 2da1cb35a8e142331611e9fae9a2bf674029ba94 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 22 Jan 2024 15:44:35 +0100 Subject: [PATCH 095/134] chore(Root): fix import --- scripts/publish-tagged-packages.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish-tagged-packages.mjs b/scripts/publish-tagged-packages.mjs index ccc038cea..3ec2b7d7d 100644 --- a/scripts/publish-tagged-packages.mjs +++ b/scripts/publish-tagged-packages.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node /* eslint-disable no-console */ -import program from 'commander' +import {program} from 'commander' program .name('publish-tagged-packages') From 0d9713745a511890dc4e2e9b2d70b477ae4ccab3 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 09:50:18 +0100 Subject: [PATCH 096/134] chore(Root): update script for tagging releases in prs --- .github/workflows/main.yml | 29 ++++++++-- scripts/publish-tagged-packages.mjs | 87 +++++++++++++++++++++++++++-- 2 files changed, 106 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 41bc68c13..977735cf4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,8 +7,8 @@ on: branches: [master] jobs: - checks-and-release: - name: Checks & Release + checks: + name: Checks runs-on: ubuntu-latest steps: - name: Cancel Previous Redundant Builds @@ -48,7 +48,24 @@ jobs: npm run test:server:ci xvfb-run --auto-servernum npm run test:client:ci - - name: Release Packages + publish: + name: Publish + needs: checks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Setup Node + uses: actions/setup-node@v4 + with: + registry-url: 'https://registry.npmjs.org' + node-version-file: '.nvmrc' + + - name: Publish Packages if: github.ref == 'refs/heads/master' run: | npx -p ./packages/sui-mono sui-mono check @@ -63,6 +80,7 @@ jobs: publish-tagged-packages: name: Publish Tagged Packages to NPM + needs: checks if: github.ref != 'refs/heads/master' runs-on: ubuntu-latest steps: @@ -79,8 +97,7 @@ jobs: node-version-file: '.nvmrc' - name: Install - run: | - npm install -D commander + run: npm install -D commander execa prettier - name: Get Files id: files @@ -90,3 +107,5 @@ jobs: - name: Publish Packages run: npm run publish-tagged-packages -- --tag '${{ github.event.pull_request.head.ref }}' --files '${{ steps.files.outputs.added_modified }}' + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/scripts/publish-tagged-packages.mjs b/scripts/publish-tagged-packages.mjs index 3ec2b7d7d..8ab3ae05e 100644 --- a/scripts/publish-tagged-packages.mjs +++ b/scripts/publish-tagged-packages.mjs @@ -1,7 +1,12 @@ #!/usr/bin/env node -/* eslint-disable no-console */ +import fs from 'node:fs' +import path from 'node:path' import {program} from 'commander' +import {$} from 'execa' +import prettier from 'prettier' + +const PACKAGE_REGEX = /packages\/((([a-z]+)-?)+)/ // matches "packages/sui-any-package-name" program .name('publish-tagged-packages') @@ -10,19 +15,91 @@ program program .option('-t, --tag [tag]', 'Tag used to publish the packages to NPM.') - .option('-f, --files [files]', 'JSON-stringified list of added and modified files.') + .option('-f, --files [files]', 'Comma-separated list of added and modified files.') .on('--help', () => { console.log(' Examples:') console.log('') console.log( - ' $ node ./scripts/publish-tagged-packages.mjs --tag \'ongoing-branch\' --files \'["packages/sui-mono/foo.js", "packages/sui-bundler/bar.js"]\'' + ' $ node ./scripts/publish-tagged-packages.mjs --tag \'ongoing-branch\' --files \'"packages/sui-mono/foo.js","packages/sui-bundler/bar.js"\'' ) console.log('') }) .parse(process.argv) -const {tag, files} = program.opts() +async function getConfig(fileName) { + return import(`../${fileName}/package.json`, { + assert: {type: 'json'} + }).then(module => module.default) +} + +async function getPackageVersion({name, tag}) { + let version = '' + + try { + // Try to get a previously tagged version. + const {stdout: currentTaggedVersion} = await $`npm view ${name}@${tag} version` + const [mainVersion, taggedVersion] = currentTaggedVersion.split(`-${tag}.`) + + version = `${mainVersion}-${tag}.${Number(taggedVersion) + 1}` + } catch (error) { + // If not, create a new tag from the main package version. + const {stdout: currentVersion} = await $`npm view ${name} version` + const [major, minor] = currentVersion.split('.') + + version = `${major}.${Number(minor) + 1}.0-${tag}.0` + } + + return version +} + +async function publishPackages() { + const {tag, files = ''} = program.opts() + + if (!tag) { + throw new Error('๐Ÿคจ Tag is mandatory in order to publish new package versions.') + } + + // Get needed packages to publish. + const packagesToPublish = [ + // Avoid duplicates. + ...new Set( + files + .split(',') + // Filter only packages. + .filter(file => file.match(PACKAGE_REGEX)) + // Return the package path. + .map(file => file.match(PACKAGE_REGEX)[0]) + ) + ] + + if (!packagesToPublish.length) { + console.log('\n๐Ÿ’ There is no new tags to be published.\n') + return + } + + packagesToPublish.forEach(async packageName => { + const packageConfig = await getConfig(packageName) + const {name} = packageConfig + const version = await getPackageVersion({name, tag}) + + // Set the new tagged version. + packageConfig.version = version + + const packagePath = path.join(process.cwd(), packageName) + const packageJsonPath = `${packagePath}/package.json` + const packageJson = await prettier.format(JSON.stringify(packageConfig), {parser: 'json'}) + + // Allow `execa` to execute NPM commands on the cwd of each package. + const $$ = $({cwd: packagePath}) + + console.log(`\n๐Ÿ“ฆ Publishing new tagged version: ${name}@${version}\n`) + + // fs.writeFileSync(packageJsonPath, packageJson) + + // await $$`npm publish --tag ${tag}` + }) +} -console.log({tag, files: JSON.parse(files)}) +await publishPackages() program.parse(process.argv) From 698c932ef2c5bb2ed0ebbe1b11afd165a3a3f9d9 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:50 +0100 Subject: [PATCH 097/134] feat(packages/sui-bundler): use latest version of swc --- packages/sui-bundler/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-bundler/package.json b/packages/sui-bundler/package.json index 680f0eeec..10525c12b 100644 --- a/packages/sui-bundler/package.json +++ b/packages/sui-bundler/package.json @@ -26,8 +26,8 @@ "@s-ui/compiler-config": "1", "@s-ui/helpers": "1", "@s-ui/sass-loader": "1", - "@swc/core": "1.3.14", - "@swc/helpers": "0.4.12", + "@swc/core": "1.3.106", + "@swc/helpers": "0.5.3", "address": "1.2.2", "autoprefixer": "10.4.8", "babel-loader": "8.2.5", From 018c890ac15b3b6e79a235174c3b895677783eda Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:52 +0100 Subject: [PATCH 098/134] feat(packages/sui-consents): use latest version of swc --- packages/sui-consents/package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/sui-consents/package.json b/packages/sui-consents/package.json index a9fed42f5..133fc8b52 100644 --- a/packages/sui-consents/package.json +++ b/packages/sui-consents/package.json @@ -5,20 +5,21 @@ "description": "iab consents handler", "types": "lib/index", "scripts": { - "lib": "rm -rf ./lib && tsc", + "lib": "sui-js-compiler", "prepublishOnly": "npm run lib" }, "keywords": [], "author": "", "license": "MIT", "devDependencies": { - "@s-ui/react-context": "typescript", + "@s-ui/js-compiler": "typescript-support", + "@s-ui/react-context": "typescript-support", "@testing-library/react": "11.2.5", "react": "17", "react-dom": "17" }, "peerDependencies": { - "@s-ui/react-context": "typescript", + "@s-ui/react-context": "typescript-support", "react": "16 || 17" } } From 9986b236f3b8251b77ae8d6c7e2adef2c55d64d6 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:53 +0100 Subject: [PATCH 099/134] feat(packages/sui-decorators): use latest version of swc --- packages/sui-decorators/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sui-decorators/package.json b/packages/sui-decorators/package.json index 24df5bdaf..1abaecc32 100644 --- a/packages/sui-decorators/package.json +++ b/packages/sui-decorators/package.json @@ -4,13 +4,14 @@ "description": "> Set of ES6 decorators to improve your apps", "main": "lib/", "scripts": { - "lib": "babel --presets sui ./src --out-dir ./lib", + "lib": "sui-js-compiler", "prepublishOnly": "npm run lib" }, "keywords": [], "author": "", "license": "MIT", "devDependencies": { + "@s-ui/js-compiler": "typescript-support", "sinon": "10.0.0" }, "browser": { From e5746101f509d1a516d1cee814318a3e2cbbea33 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:53 +0100 Subject: [PATCH 100/134] feat(packages/sui-domain): use latest version of swc --- packages/sui-domain/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sui-domain/package.json b/packages/sui-domain/package.json index 500bc023e..23fa44afe 100644 --- a/packages/sui-domain/package.json +++ b/packages/sui-domain/package.json @@ -5,7 +5,7 @@ "description": "SDK for creating domains", "main": "lib/index.js", "scripts": { - "lib": "babel --presets sui ./src --out-dir ./lib", + "lib": "sui-js-compiler", "prepublishOnly": "npm run lib", "test": "npm run test:server && npm run test:browser", "test:browser": "NODE_ENV=test sui-test browser -P 'test/browser/*Spec.js'", @@ -16,6 +16,9 @@ "keywords": [], "author": "", "license": "MIT", + "devDependencies": { + "@s-ui/js-compiler": "typescript-support" + }, "dependencies": { "axios": "1.6.2" } From 820adf5c0cf1f460a00979e7f6627d12d394e502 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:53 +0100 Subject: [PATCH 101/134] feat(packages/sui-hoc): use latest version of swc --- packages/sui-hoc/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sui-hoc/package.json b/packages/sui-hoc/package.json index 3928f2e3d..418bcc322 100644 --- a/packages/sui-hoc/package.json +++ b/packages/sui-hoc/package.json @@ -4,7 +4,7 @@ "description": "Set of HoC useful for react", "main": "lib/index.js", "scripts": { - "lib": "babel --presets sui ./src --out-dir ./lib", + "lib": "sui-js-compiler", "prepublishOnly": "npm run lib" }, "peerDependencies": { @@ -12,6 +12,9 @@ "prop-types": "15", "react": "16 || 17" }, + "devDependencies": { + "@s-ui/js-compiler": "typescript-support" + }, "dependencies": { "intersection-observer": "0.10.0" } From ea2558192a555f4332f5c4558cb70b3c75715250 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:53 +0100 Subject: [PATCH 102/134] feat(packages/sui-jest): use latest version of swc --- packages/sui-jest/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-jest/package.json b/packages/sui-jest/package.json index fd7cf7240..64acf7b84 100644 --- a/packages/sui-jest/package.json +++ b/packages/sui-jest/package.json @@ -12,7 +12,7 @@ "author": "", "license": "MIT", "dependencies": { - "@swc/jest": "0.2.24", + "@swc/jest": "0.2.31", "@types/jest": "29.2.4", "jest": "29.3.1", "jest-environment-jsdom": "29.3.1", From b1a0c16df6a23ecdba3f837aafdc3e71f966d2d0 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:53 +0100 Subject: [PATCH 103/134] feat(packages/sui-js-compiler): use latest version of swc --- packages/sui-js-compiler/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-js-compiler/package.json b/packages/sui-js-compiler/package.json index 27d9972f3..fdaad467e 100644 --- a/packages/sui-js-compiler/package.json +++ b/packages/sui-js-compiler/package.json @@ -13,8 +13,8 @@ "license": "MIT", "dependencies": { "@s-ui/compiler-config": "1", - "@swc/core": "1.3.14", - "@swc/helpers": "0.4.12", + "@swc/core": "1.3.106", + "@swc/helpers": "0.5.3", "commander": "8.3.0", "fast-glob": "3.2.12", "fs-extra": "10.1.0", From 4b7de4b8197644181994db0c3e84f59d1956fbcb Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:54 +0100 Subject: [PATCH 104/134] feat(packages/sui-mock): use latest version of swc --- packages/sui-mock/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sui-mock/package.json b/packages/sui-mock/package.json index 6561a5f7c..14f005211 100644 --- a/packages/sui-mock/package.json +++ b/packages/sui-mock/package.json @@ -4,7 +4,7 @@ "main": "lib/index.js", "description": "Mock provider", "scripts": { - "lib": "babel --presets sui ./src --out-dir ./lib", + "lib": "sui-js-compiler", "prepublishOnly": "npm run lib", "test": "npm run test:browser && npm run test:server", "test:browser": "npx @s-ui/test browser -P './test/browser/**/*Spec.js'", @@ -15,6 +15,9 @@ "keywords": [], "author": "", "license": "MIT", + "devDependencies": { + "@s-ui/js-compiler": "typescript-support" + }, "dependencies": { "msw": "1.2.1" }, From dbb8c882a64b89088be0a8bd2292d79024ed81c9 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:54 +0100 Subject: [PATCH 105/134] feat(packages/sui-react-context): use latest version of swc --- packages/sui-react-context/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sui-react-context/package.json b/packages/sui-react-context/package.json index bcb9e5e04..276384be2 100644 --- a/packages/sui-react-context/package.json +++ b/packages/sui-react-context/package.json @@ -5,12 +5,15 @@ "main": "lib/index", "types": "lib/index.d.ts", "scripts": { - "lib": "rm -rf ./lib && tsc", + "lib": "sui-js-compiler", "prepublishOnly": "npm run lib" }, "keywords": [], "author": "", "license": "MIT", + "devDependencies": { + "@s-ui/js-compiler": "typescript-support" + }, "dependencies": { "hoist-non-react-statics": "3.3.2" } From c56495ddeb80b1bb2c17bd002e39ec6c95671e71 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:54 +0100 Subject: [PATCH 106/134] feat(packages/sui-react-head): use latest version of swc --- packages/sui-react-head/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sui-react-head/package.json b/packages/sui-react-head/package.json index 9133600e9..43843d51c 100644 --- a/packages/sui-react-head/package.json +++ b/packages/sui-react-head/package.json @@ -5,7 +5,7 @@ "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { - "lib": "rm -rf ./lib && tsc", + "lib": "sui-js-compiler", "prepublishOnly": "npm run lib" }, "keywords": [], @@ -15,6 +15,7 @@ "react-head": "3.4.0" }, "devDependencies": { + "@s-ui/js-compiler": "typescript-support", "@testing-library/react": "11.1.0", "react": "17", "react-dom": "17" From 3e1a7dff8aa073ad3ae13707c150f37562c0614b Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:54 +0100 Subject: [PATCH 107/134] feat(packages/sui-react-initial-props): use latest version of swc --- packages/sui-react-initial-props/package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/sui-react-initial-props/package.json b/packages/sui-react-initial-props/package.json index eaeb937be..4122bb114 100644 --- a/packages/sui-react-initial-props/package.json +++ b/packages/sui-react-initial-props/package.json @@ -5,7 +5,7 @@ "types": "lib/index.d.ts", "description": "Provide a way to get initial props for async pages", "scripts": { - "lib": "rm -rf ./lib && tsc", + "lib": "sui-js-compiler", "prepublishOnly": "npm run lib" }, "keywords": [], @@ -17,10 +17,11 @@ "react": "16 || 17" }, "devDependencies": { + "@s-ui/js-compiler": "typescript-support", + "@s-ui/react-router": "1", "@testing-library/react": "11.1.0", "@types/node": "16", "react": "17", - "react-dom": "17", - "@s-ui/react-router": "1" + "react-dom": "17" } } From a133bd7bf9d598fd2fd7f71010d0af3a59cede34 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:55 +0100 Subject: [PATCH 108/134] feat(packages/sui-test-contract): use latest version of swc --- packages/sui-test-contract/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-test-contract/package.json b/packages/sui-test-contract/package.json index f6109d52f..bfc4bb7c7 100644 --- a/packages/sui-test-contract/package.json +++ b/packages/sui-test-contract/package.json @@ -18,7 +18,7 @@ "dependencies": { "@pact-foundation/pact": "9.18.1", "@pactflow/pact-msw-adapter": "2.0.0", - "@s-ui/mock": "typescript", + "@s-ui/mock": "typescript-support", "commander": "8.3.0", "headers-polyfill": "3.1.2" }, From 18b378329b8113fbaf089ef7fb499b90e27a0090 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:36:55 +0100 Subject: [PATCH 109/134] feat(packages/sui-test): use latest version of swc --- packages/sui-test/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-test/package.json b/packages/sui-test/package.json index 25fa05e02..b6f800a64 100644 --- a/packages/sui-test/package.json +++ b/packages/sui-test/package.json @@ -24,7 +24,7 @@ "@babel/register": "7.18.9", "@s-ui/compiler-config": "1", "@s-ui/helpers": "1", - "@swc/core": "1.3.14", + "@swc/core": "1.3.106", "@swc/register": "0.1.10", "babel-loader": "8.2.5", "babel-plugin-dynamic-import-node": "2.3.3", From 51917398b2000bfc430d92db39a09da875aa9642 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Fri, 26 Jan 2024 10:38:15 +0100 Subject: [PATCH 110/134] chore(Root): uncomment script and fix dev dep version --- package.json | 1 + scripts/publish-tagged-packages.mjs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ef6cba654..91471d5d8 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@s-ui/precommit": "3", "@s-ui/react-context": "1", "chai": "4.3.6", + "pino-pretty": "10.3.1", "react": "17", "sinon": "10.0.0", "typescript": "5.0.4", diff --git a/scripts/publish-tagged-packages.mjs b/scripts/publish-tagged-packages.mjs index 8ab3ae05e..8e6f3c994 100644 --- a/scripts/publish-tagged-packages.mjs +++ b/scripts/publish-tagged-packages.mjs @@ -94,9 +94,9 @@ async function publishPackages() { console.log(`\n๐Ÿ“ฆ Publishing new tagged version: ${name}@${version}\n`) - // fs.writeFileSync(packageJsonPath, packageJson) + fs.writeFileSync(packageJsonPath, packageJson) - // await $$`npm publish --tag ${tag}` + await $$`npm publish --tag ${tag}` }) } From e7eabfd5a610357c258234bc0ea16afb3e63bcd0 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 5 Feb 2024 12:13:46 +0100 Subject: [PATCH 111/134] fix(packages/sui-consents): fix linting issues --- packages/sui-consents/src/types.ts | 16 ++-------------- packages/sui-consents/src/useUserConsents.ts | 4 ++-- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/packages/sui-consents/src/types.ts b/packages/sui-consents/src/types.ts index 98e2977b7..198687f51 100644 --- a/packages/sui-consents/src/types.ts +++ b/packages/sui-consents/src/types.ts @@ -1,18 +1,6 @@ export interface Purpose { - consents: { - /** - * true - Consent - * false - No Consent. - */ - [purposeId: number]: boolean | undefined - } - legitimateInterests: { - /** - * true - Legitimate Interest Established, - * false - No Legitimate Interest Established - */ - [purposeId: number]: boolean - } + consents: Record + legitimateInterests: Record } export enum EventStatus { diff --git a/packages/sui-consents/src/useUserConsents.ts b/packages/sui-consents/src/useUserConsents.ts index 1c4ebe44f..01facd2b6 100644 --- a/packages/sui-consents/src/useUserConsents.ts +++ b/packages/sui-consents/src/useUserConsents.ts @@ -4,7 +4,7 @@ import SUIContext from '@s-ui/react-context' import {TCF_VERSION, TCF_WINDOW_API} from './config' import hasUserConsents from './hasUserConsents' -import {EventStatus, Purpose} from './types' +import {type Purpose, EventStatus} from './types' export default function useUserConsents(requiredConsents: number[]): boolean { /** @@ -12,7 +12,7 @@ export default function useUserConsents(requiredConsents: number[]): boolean { * context, so we know the state of consents from the beginning, even * in SSR. */ - const {cookies} = useContext(SUIContext) + const {cookies}: {cookies: string} = useContext(SUIContext) const [areConsentsAccepted, setAreConsentsAccepted] = useState(() => hasUserConsents({requiredConsents, cookies})) /** From 6b639a8b8250ac7702bcac29e4ee9b19e9b88673 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 5 Feb 2024 12:13:55 +0100 Subject: [PATCH 112/134] fix(packages/sui-domain): fix linting issues --- .../sui-domain/src/fetcher/InterceptableFetcherInterface.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-domain/src/fetcher/InterceptableFetcherInterface.d.ts b/packages/sui-domain/src/fetcher/InterceptableFetcherInterface.d.ts index d50551989..9bd073ddd 100644 --- a/packages/sui-domain/src/fetcher/InterceptableFetcherInterface.d.ts +++ b/packages/sui-domain/src/fetcher/InterceptableFetcherInterface.d.ts @@ -1,6 +1,6 @@ /** @typedef {import('./FetcherInterface').default} FetcherInterface */ /** @extends {FetcherInterface} */ export default interface InterceptableFetcherInterface { - setErrorInterceptor: (callback: Function) => void + setErrorInterceptor: (callback: () => void) => void unsetErrorInterceptor: () => void } From 5c199d4392f5ffb4e4ad3eb895e668812b639e11 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 5 Feb 2024 12:13:56 +0100 Subject: [PATCH 113/134] fix(packages/sui-react-context): fix linting issues --- packages/sui-react-context/src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-react-context/src/index.tsx b/packages/sui-react-context/src/index.tsx index 69858f98a..2c1582a97 100644 --- a/packages/sui-react-context/src/index.tsx +++ b/packages/sui-react-context/src/index.tsx @@ -13,7 +13,7 @@ SUIContext.wrapper = (Component, displayName): React.ComponentType => { {context => } ) - WrappedComponent.displayName = Component.displayName !== undefined ? Component.displayName : displayName + WrappedComponent.displayName = Component.displayName ?? displayName return hoistNonReactStatics(WrappedComponent, Component) } From 7f846664dbf6ff73ba9b1456f8819ee03e6a9a0b Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 5 Feb 2024 12:13:56 +0100 Subject: [PATCH 114/134] fix(packages/sui-react-head): fix linting issues --- packages/sui-react-head/src/Body.tsx | 4 +++- packages/sui-react-head/src/index.tsx | 2 +- packages/sui-react-head/src/server.ts | 9 +++++---- packages/sui-react-head/src/utils.tsx | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/sui-react-head/src/Body.tsx b/packages/sui-react-head/src/Body.tsx index 7b89a6632..dbf9f9aa0 100644 --- a/packages/sui-react-head/src/Body.tsx +++ b/packages/sui-react-head/src/Body.tsx @@ -20,7 +20,9 @@ const Body: React.FC = ({attributes = {}}) => { } toggleBodyAttributes() - return () => toggleBodyAttributes({action: 'remove'}) + return () => { + toggleBodyAttributes({action: 'remove'}) + } }, [attributes]) if (isClient) return null diff --git a/packages/sui-react-head/src/index.tsx b/packages/sui-react-head/src/index.tsx index f26489d2d..99e0a0f80 100644 --- a/packages/sui-react-head/src/index.tsx +++ b/packages/sui-react-head/src/index.tsx @@ -34,7 +34,7 @@ const MetaTagInverter: React.FC = ({'data-rh': rh, ...othe } const Meta: React.FC = props => { - // @ts-expect-error + // @ts-expect-error: We should expect any error return } diff --git a/packages/sui-react-head/src/server.ts b/packages/sui-react-head/src/server.ts index 5101f849d..5e1c19311 100644 --- a/packages/sui-react-head/src/server.ts +++ b/packages/sui-react-head/src/server.ts @@ -1,8 +1,9 @@ +import {type ReactElement} from 'react' import {renderToString} from 'react-dom/server' import {BODY_ATTRIBUTES_KEY} from './Body' import {HTML_ATTRIBUTES_KEY} from './Html' -import {ComponentTag} from './types' +import {type ComponentTag} from './types' interface ExtractPropsFromConfig { withKey: string @@ -12,7 +13,7 @@ interface ExtractPropsFromConfig { * Extract props from a list of tags a specific tag by using a key * and then discard this key before returning the key */ -const extractPropsFrom = (tags: ComponentTag[], {withKey}: ExtractPropsFromConfig): undefined | {[x: string]: any} => { +const extractPropsFrom = (tags: ComponentTag[], {withKey}: ExtractPropsFromConfig): undefined | Record => { // search the tag using the key and default to an empty object for simplicity const tag: ComponentTag | undefined = tags.find(({props}) => props.name === withKey) @@ -27,7 +28,7 @@ const extractPropsFrom = (tags: ComponentTag[], {withKey}: ExtractPropsFromConfi /** * Transform the object from the head to a string to be used in the server */ -const transformToString = (headObject: {[key: string]: string} = {}): string => +const transformToString = (headObject: Record = {}): string => Object.entries(headObject) .map(([key, value]) => `${key}="${value}"`) .join(' ') @@ -35,7 +36,7 @@ const transformToString = (headObject: {[key: string]: string} = {}): string => /** * Render the tags for the head */ -export function renderHeadTagsToString(headTags: any[]): { +export function renderHeadTagsToString(headTags: Array>): { headString: string bodyAttributes: string htmlAttributes: string diff --git a/packages/sui-react-head/src/utils.tsx b/packages/sui-react-head/src/utils.tsx index c64298390..c9430237b 100644 --- a/packages/sui-react-head/src/utils.tsx +++ b/packages/sui-react-head/src/utils.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import {Children as ReactChildren} from 'react' -import {Style, Tag} from './types' +import {type Style, type Tag} from './types' const checkRelNeedsHref = (rel: string): boolean => ['alternate', 'preload', 'prefetch'].includes(rel) @@ -50,7 +50,7 @@ export const extractTagsFrom = ({children, tag, fallback}: extractTagsFromParams return extract({children, byTag: tag}) } - return fallback != null ? fallback : [] + return fallback ?? [] } interface extractTitleFromParams { @@ -64,7 +64,8 @@ export const extractTitleFrom = ({children, fallback = ''}: extractTitleFromPara const listOfTitles = extract({children, byTag: 'title'}) if (listOfTitles.length > 0) { const [title] = listOfTitles - return title.children !== undefined ? title.children : fallback + + return title.children ?? fallback } return fallback } From d580498ec84b7339e87901df30fc989aefe94e7f Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 5 Feb 2024 12:13:57 +0100 Subject: [PATCH 115/134] fix(packages/sui-react-initial-props): fix linting issues --- .../src/createClientContextFactoryParams.ts | 2 +- .../src/createServerContextFactoryParams.ts | 2 +- packages/sui-react-initial-props/src/loadPage.tsx | 7 ++++++- .../src/ssrComponentWithInitialProps.tsx | 2 +- packages/sui-react-initial-props/src/types.d.ts | 6 ++---- packages/sui-react-initial-props/src/withInitialProps.tsx | 4 ++-- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/sui-react-initial-props/src/createClientContextFactoryParams.ts b/packages/sui-react-initial-props/src/createClientContextFactoryParams.ts index b32fb768a..389f098cd 100644 --- a/packages/sui-react-initial-props/src/createClientContextFactoryParams.ts +++ b/packages/sui-react-initial-props/src/createClientContextFactoryParams.ts @@ -1,4 +1,4 @@ -import {ContextFactoryParams} from './types' +import {type ContextFactoryParams} from './types' export default (): ContextFactoryParams => ({ appConfig: window.__APP_CONFIG__, diff --git a/packages/sui-react-initial-props/src/createServerContextFactoryParams.ts b/packages/sui-react-initial-props/src/createServerContextFactoryParams.ts index 2bf23553e..fa437efcf 100644 --- a/packages/sui-react-initial-props/src/createServerContextFactoryParams.ts +++ b/packages/sui-react-initial-props/src/createServerContextFactoryParams.ts @@ -1,4 +1,4 @@ -import {ContextFactoryParams} from './types' +import {type ContextFactoryParams} from './types' export default (req: IncomingMessage.ServerRequest): ContextFactoryParams => ({ appConfig: req.appConfig, diff --git a/packages/sui-react-initial-props/src/loadPage.tsx b/packages/sui-react-initial-props/src/loadPage.tsx index f2839b18b..887335b08 100644 --- a/packages/sui-react-initial-props/src/loadPage.tsx +++ b/packages/sui-react-initial-props/src/loadPage.tsx @@ -2,7 +2,12 @@ import {useContext} from 'react' import InitialPropsContext from './initialPropsContext' -import {ClientPageComponent, DoneImportingPageCallback, ReactRouterTypes, WithInitialPropsComponent} from './types' +import { + type ClientPageComponent, + type DoneImportingPageCallback, + type ReactRouterTypes, + type WithInitialPropsComponent +} from './types' import withInitialProps from './withInitialProps' const EMPTY_GET_INITIAL_PROPS = async (): Promise => ({}) diff --git a/packages/sui-react-initial-props/src/ssrComponentWithInitialProps.tsx b/packages/sui-react-initial-props/src/ssrComponentWithInitialProps.tsx index 48cd03455..8665c3807 100644 --- a/packages/sui-react-initial-props/src/ssrComponentWithInitialProps.tsx +++ b/packages/sui-react-initial-props/src/ssrComponentWithInitialProps.tsx @@ -1,7 +1,7 @@ import {renderToNodeStream, renderToString} from 'react-dom/server' import InitialPropsContext from './initialPropsContext' -import {InitialProps, SsrComponentWithInitialPropsParams} from './types' +import {type InitialProps, type SsrComponentWithInitialPropsParams} from './types' const hrTimeToMs = (diff: [number, number]): number => diff[0] * 1e3 + diff[1] * 1e-6 diff --git a/packages/sui-react-initial-props/src/types.d.ts b/packages/sui-react-initial-props/src/types.d.ts index 1acd21a1f..73e76e4ea 100644 --- a/packages/sui-react-initial-props/src/types.d.ts +++ b/packages/sui-react-initial-props/src/types.d.ts @@ -1,9 +1,7 @@ -import {RouteInfo} from '@s-ui/react-router/src/types' +import {type RouteInfo} from '@s-ui/react-router/src/types' export * as ReactRouterTypes from '@s-ui/react-router/src/types' -export interface InitialProps { - [key: string]: any -} +export type InitialProps = Record export interface PageComponentOptions { keepMounted?: boolean renderLoading?: (params: GetInitialPropsClientFunctionParams) => React.ElementType diff --git a/packages/sui-react-initial-props/src/withInitialProps.tsx b/packages/sui-react-initial-props/src/withInitialProps.tsx index 6f6427833..f1d44a734 100644 --- a/packages/sui-react-initial-props/src/withInitialProps.tsx +++ b/packages/sui-react-initial-props/src/withInitialProps.tsx @@ -1,9 +1,9 @@ import {useContext, useEffect, useRef, useState} from 'react' import SUIContext from '@s-ui/react-context' -import {RouteInfo} from '@s-ui/react-router/src/types' +import {type RouteInfo} from '@s-ui/react-router/src/types' -import {ClientPageComponent, InitialProps, WithInitialPropsComponent} from './types' +import {type ClientPageComponent, type InitialProps, type WithInitialPropsComponent} from './types' const INITIAL_PROPS_KEY = '__INITIAL_PROPS__' From 60569dfc2ea4fa71dbe3d7120eea48af3d0495cb Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 5 Feb 2024 15:31:07 +0100 Subject: [PATCH 116/134] chore(Root): add condition to workflow and modify script --- .github/workflows/main.yml | 3 ++- scripts/publish-tagged-packages.mjs | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 977735cf4..f52acd647 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,6 +5,7 @@ on: branches: [master] pull_request: branches: [master] + types: [labeled] jobs: checks: @@ -81,7 +82,7 @@ jobs: publish-tagged-packages: name: Publish Tagged Packages to NPM needs: checks - if: github.ref != 'refs/heads/master' + if: github.ref != 'refs/heads/master' && contains(github.event.pull_request.labels.*.name, 'feature') runs-on: ubuntu-latest steps: - name: Checkout diff --git a/scripts/publish-tagged-packages.mjs b/scripts/publish-tagged-packages.mjs index 8e6f3c994..9ce60de9d 100644 --- a/scripts/publish-tagged-packages.mjs +++ b/scripts/publish-tagged-packages.mjs @@ -1,9 +1,12 @@ #!/usr/bin/env node +/* eslint-disable no-console */ + +import {createRequire} from 'module' -import fs from 'node:fs' -import path from 'node:path' import {program} from 'commander' import {$} from 'execa' +import fs from 'node:fs' +import path from 'node:path' import prettier from 'prettier' const PACKAGE_REGEX = /packages\/((([a-z]+)-?)+)/ // matches "packages/sui-any-package-name" @@ -26,10 +29,10 @@ program }) .parse(process.argv) -async function getConfig(fileName) { - return import(`../${fileName}/package.json`, { - assert: {type: 'json'} - }).then(module => module.default) +function getConfig(fileName) { + const require = createRequire(import.meta.url) + + return require(`../${fileName}/package.json`) } async function getPackageVersion({name, tag}) { @@ -78,7 +81,7 @@ async function publishPackages() { } packagesToPublish.forEach(async packageName => { - const packageConfig = await getConfig(packageName) + const packageConfig = getConfig(packageName) const {name} = packageConfig const version = await getPackageVersion({name, tag}) From 72ba1229bdc023b35e1d0bb4bc92a751891e84a3 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 12 Feb 2024 16:06:55 +0100 Subject: [PATCH 117/134] fix(packages/sui-bundler): downgrade swc versions --- packages/sui-bundler/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-bundler/package.json b/packages/sui-bundler/package.json index 8e2a70620..3e6b09065 100644 --- a/packages/sui-bundler/package.json +++ b/packages/sui-bundler/package.json @@ -26,8 +26,8 @@ "@s-ui/compiler-config": "1", "@s-ui/helpers": "1", "@s-ui/sass-loader": "1", - "@swc/core": "1.3.106", - "@swc/helpers": "0.5.3", + "@swc/core": "1.3.14", + "@swc/helpers": "0.4.12", "address": "1.2.2", "autoprefixer": "10.4.8", "babel-loader": "8.3.0", From 20ed77bea8cea6a6433657e4a6847f5218a5a858 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 12 Feb 2024 16:06:58 +0100 Subject: [PATCH 118/134] fix(packages/sui-js-compiler): downgrade swc versions --- packages/sui-js-compiler/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-js-compiler/package.json b/packages/sui-js-compiler/package.json index 244fca4a5..b4b7fd639 100644 --- a/packages/sui-js-compiler/package.json +++ b/packages/sui-js-compiler/package.json @@ -13,8 +13,8 @@ "license": "MIT", "dependencies": { "@s-ui/compiler-config": "1", - "@swc/core": "1.3.106", - "@swc/helpers": "0.5.3", + "@swc/core": "1.3.14", + "@swc/helpers": "0.4.12", "commander": "8.3.0", "fast-glob": "3.2.12", "fs-extra": "10.1.0", From f875b6589eb7c79f5470cd744b8c1c2962d8a489 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Mon, 12 Feb 2024 16:07:00 +0100 Subject: [PATCH 119/134] fix(packages/sui-test): downgrade swc versions --- packages/sui-test/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-test/package.json b/packages/sui-test/package.json index b55535752..b5f099b99 100644 --- a/packages/sui-test/package.json +++ b/packages/sui-test/package.json @@ -25,7 +25,7 @@ "@faker-js/faker": "8.0.2", "@s-ui/compiler-config": "1", "@s-ui/helpers": "1", - "@swc/core": "1.3.106", + "@swc/core": "1.3.14", "@swc/register": "0.1.10", "babel-loader": "8.3.0", "babel-plugin-dynamic-import-node": "2.3.3", From 02b592c407dbb5c6ce9ad8e5665e61b7557877aa Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:22:44 +0100 Subject: [PATCH 120/134] fix(packages/sui-consents): update deps --- packages/sui-consents/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sui-consents/package.json b/packages/sui-consents/package.json index 133fc8b52..74ce96328 100644 --- a/packages/sui-consents/package.json +++ b/packages/sui-consents/package.json @@ -12,14 +12,14 @@ "author": "", "license": "MIT", "devDependencies": { - "@s-ui/js-compiler": "typescript-support", - "@s-ui/react-context": "typescript-support", + "@s-ui/js-compiler": "1", + "@s-ui/react-context": "1", "@testing-library/react": "11.2.5", "react": "17", "react-dom": "17" }, "peerDependencies": { - "@s-ui/react-context": "typescript-support", + "@s-ui/react-context": "1", "react": "16 || 17" } } From 038cfefd6e71cd2d42ca3e1ed6fef636c2172793 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:22:47 +0100 Subject: [PATCH 121/134] fix(packages/sui-decorators): update deps --- packages/sui-decorators/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-decorators/package.json b/packages/sui-decorators/package.json index 1abaecc32..02dc788b9 100644 --- a/packages/sui-decorators/package.json +++ b/packages/sui-decorators/package.json @@ -11,7 +11,7 @@ "author": "", "license": "MIT", "devDependencies": { - "@s-ui/js-compiler": "typescript-support", + "@s-ui/js-compiler": "1", "sinon": "10.0.0" }, "browser": { From f57199fbdac2b3cc69d8403a0f109db44f69d312 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:22:47 +0100 Subject: [PATCH 122/134] fix(packages/sui-domain): update deps --- packages/sui-domain/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-domain/package.json b/packages/sui-domain/package.json index 5db862bd3..8dca96d0f 100644 --- a/packages/sui-domain/package.json +++ b/packages/sui-domain/package.json @@ -17,7 +17,7 @@ "author": "", "license": "MIT", "devDependencies": { - "@s-ui/js-compiler": "typescript-support" + "@s-ui/js-compiler": "1" }, "dependencies": { "axios": "1.6.7" From a9d5998c4d9fd6e7031ac9b3bef5ea18e80be0e6 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:22:47 +0100 Subject: [PATCH 123/134] fix(packages/sui-hoc): update deps --- packages/sui-hoc/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-hoc/package.json b/packages/sui-hoc/package.json index 418bcc322..c655d2112 100644 --- a/packages/sui-hoc/package.json +++ b/packages/sui-hoc/package.json @@ -13,7 +13,7 @@ "react": "16 || 17" }, "devDependencies": { - "@s-ui/js-compiler": "typescript-support" + "@s-ui/js-compiler": "1" }, "dependencies": { "intersection-observer": "0.10.0" From b670cc2513de7dc25c9356556ca1a29e87570001 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:22:47 +0100 Subject: [PATCH 124/134] fix(packages/sui-js-compiler): update deps --- packages/sui-js-compiler/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/sui-js-compiler/index.js b/packages/sui-js-compiler/index.js index 34e36df71..cdf725efb 100755 --- a/packages/sui-js-compiler/index.js +++ b/packages/sui-js-compiler/index.js @@ -92,6 +92,8 @@ const {ignore: ignoreOpts = [], modern: isModern = false} = program.opts() const ignore = [...ignoreOpts, '**/__tests__'] ;(async () => { + console.time('[sui-js-compiler]') + const files = await fg('./src/**/*.{js,jsx,ts,tsx}', {ignore}) const filesToCompile = Promise.all( files.map(async file => { @@ -111,4 +113,6 @@ const ignore = [...ignoreOpts, '**/__tests__'] : Promise.resolve() await Promise.all([filesToCompile, typesToCompile]) + + console.timeEnd('[sui-js-compiler]') })() From d9e7f35d6fd0058912113b89bed042f3019ea645 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:22:48 +0100 Subject: [PATCH 125/134] fix(packages/sui-mock): update deps --- packages/sui-mock/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-mock/package.json b/packages/sui-mock/package.json index 2c6172fe2..5733ca469 100644 --- a/packages/sui-mock/package.json +++ b/packages/sui-mock/package.json @@ -16,7 +16,7 @@ "author": "", "license": "MIT", "devDependencies": { - "@s-ui/js-compiler": "typescript-support" + "@s-ui/js-compiler": "1" }, "dependencies": { "msw": "1.2.1" From 3788e5e9f0d72d525276539397923659c27a26a0 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:22:48 +0100 Subject: [PATCH 126/134] fix(packages/sui-react-context): update deps --- packages/sui-react-context/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-react-context/package.json b/packages/sui-react-context/package.json index 276384be2..3bcfcae32 100644 --- a/packages/sui-react-context/package.json +++ b/packages/sui-react-context/package.json @@ -12,7 +12,7 @@ "author": "", "license": "MIT", "devDependencies": { - "@s-ui/js-compiler": "typescript-support" + "@s-ui/js-compiler": "1" }, "dependencies": { "hoist-non-react-statics": "3.3.2" From cf7992d7ad2173c3c3ce5a8c219b31bb80ca5a21 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:22:48 +0100 Subject: [PATCH 127/134] fix(packages/sui-react-head): update deps --- packages/sui-react-head/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-react-head/package.json b/packages/sui-react-head/package.json index 43843d51c..46589942b 100644 --- a/packages/sui-react-head/package.json +++ b/packages/sui-react-head/package.json @@ -15,7 +15,7 @@ "react-head": "3.4.0" }, "devDependencies": { - "@s-ui/js-compiler": "typescript-support", + "@s-ui/js-compiler": "1", "@testing-library/react": "11.1.0", "react": "17", "react-dom": "17" From d55aabc694c3a8fd70ff0cee49c6e26541406fa8 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:22:48 +0100 Subject: [PATCH 128/134] fix(packages/sui-react-initial-props): update deps --- packages/sui-react-initial-props/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-react-initial-props/package.json b/packages/sui-react-initial-props/package.json index da7fe43d4..74f6d6920 100644 --- a/packages/sui-react-initial-props/package.json +++ b/packages/sui-react-initial-props/package.json @@ -17,7 +17,7 @@ "react": "16 || 17" }, "devDependencies": { - "@s-ui/js-compiler": "typescript-support", + "@s-ui/js-compiler": "1", "@s-ui/react-router": "1", "@testing-library/react": "11.1.0", "@types/node": "16", From abb824ba7bc913759abe5d102f4e3eeb6133a1a5 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:22:49 +0100 Subject: [PATCH 129/134] fix(packages/sui-test-contract): update deps --- packages/sui-test-contract/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-test-contract/package.json b/packages/sui-test-contract/package.json index bfc4bb7c7..7abbaabb5 100644 --- a/packages/sui-test-contract/package.json +++ b/packages/sui-test-contract/package.json @@ -18,7 +18,7 @@ "dependencies": { "@pact-foundation/pact": "9.18.1", "@pactflow/pact-msw-adapter": "2.0.0", - "@s-ui/mock": "typescript-support", + "@s-ui/mock": "1", "commander": "8.3.0", "headers-polyfill": "3.1.2" }, From 2e05a91bf74dacc3abed49f506336c00bf71f5ca Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 09:32:34 +0100 Subject: [PATCH 130/134] fix(packages/sui-react-head): fix type --- packages/sui-react-head/src/server.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/sui-react-head/src/server.ts b/packages/sui-react-head/src/server.ts index 5e1c19311..e5cd0f0e0 100644 --- a/packages/sui-react-head/src/server.ts +++ b/packages/sui-react-head/src/server.ts @@ -1,4 +1,3 @@ -import {type ReactElement} from 'react' import {renderToString} from 'react-dom/server' import {BODY_ATTRIBUTES_KEY} from './Body' @@ -36,7 +35,7 @@ const transformToString = (headObject: Record = {}): string => /** * Render the tags for the head */ -export function renderHeadTagsToString(headTags: Array>): { +export function renderHeadTagsToString(headTags: ComponentTag[]): { headString: string bodyAttributes: string htmlAttributes: string From d58414ca04d52a4d5fd9aa7f2deac80e607cc41f Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Tue, 13 Feb 2024 12:22:35 +0100 Subject: [PATCH 131/134] chore(Root): modify workflow execution condition --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f52acd647..5b311f84b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,7 +5,6 @@ on: branches: [master] pull_request: branches: [master] - types: [labeled] jobs: checks: From 173221d314accb50288931740eeca16c3cc5509d Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Wed, 21 Feb 2024 15:40:14 +0100 Subject: [PATCH 132/134] fix(packages/sui-bundler): fix resolve alias --- packages/sui-bundler/shared/resolve-alias.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/sui-bundler/shared/resolve-alias.js b/packages/sui-bundler/shared/resolve-alias.js index be8c5d198..8cdfb6192 100644 --- a/packages/sui-bundler/shared/resolve-alias.js +++ b/packages/sui-bundler/shared/resolve-alias.js @@ -22,8 +22,15 @@ const defaultPackagesToAlias = [ ] const createAliasPath = pkgName => { - const PWDNodeModules = path.join(PWD, './node_modules') - if (fs.existsSync(PWDNodeModules)) return path.resolve(path.join(PWDNodeModules, pkgName)) + const nodeModulesPath = path.join(PWD, './node_modules') + const parentNodeModulesPath = path.join(PWD, '../node_modules') + const pkgPath = nodeModulesPath && path.join(nodeModulesPath, pkgName) + + if (pkgPath && fs.existsSync(pkgPath)) { + return path.resolve(pkgPath) + } else if (fs.existsSync(parentNodeModulesPath)) { + return path.resolve(path.join(parentNodeModulesPath, pkgName)) + } try { return require.resolve(pkgName).replace(/\/index\.js$/, '') From 6d5766555a43810891ce4da66c7079854b10d1e6 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Lloret Date: Thu, 22 Feb 2024 11:17:43 +0100 Subject: [PATCH 133/134] fix(packages/sui-test): support new project structure --- packages/sui-test/bin/karma/config.js | 8 +++++--- packages/sui-test/src/config.js | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/sui-test/bin/karma/config.js b/packages/sui-test/bin/karma/config.js index 6a76d38b1..ac5f5f19a 100644 --- a/packages/sui-test/bin/karma/config.js +++ b/packages/sui-test/bin/karma/config.js @@ -4,7 +4,7 @@ const webpack = require('webpack') const path = require('path') const {envVars} = require('@s-ui/bundler/shared/index.js') const {getSWCConfig} = require('@s-ui/compiler-config') -const {bundlerConfig, clientConfig, isWorkspace} = require('../../src/config.js') +const {bundlerConfig, clientConfig, isWorkspace, isInnerPackage} = require('../../src/config.js') const {captureConsole = true} = clientConfig const {sep} = path @@ -14,7 +14,8 @@ const {sep} = path * Where the value is always an empty string. */ const environmentVariables = envVars(bundlerConfig.env) -const prefix = isWorkspace() ? '../' : './' +const standardPrefix = isWorkspace() ? '../' : './' +const prefix = isInnerPackage() ? '../../' : standardPrefix const pwd = process.env.PWD const swcConfig = getSWCConfig({isTypeScript: true}) const config = { @@ -45,7 +46,8 @@ const config = { alias: { 'react/jsx-dev-runtime': path.resolve(pwd, prefix, 'node_modules/react/jsx-dev-runtime.js'), 'react/jsx-runtime': path.resolve(pwd, prefix, 'node_modules/react/jsx-runtime.js'), - '@s-ui/react-context': path.resolve(path.join(pwd, prefix, 'node_modules/@s-ui/react-context')) + '@s-ui/react-context': path.resolve(path.join(pwd, prefix, 'node_modules/@s-ui/react-context')), + 'studio-utils': path.resolve(path.join(pwd, prefix, 'packages/ui/studio-utils')) }, modules: [path.resolve(process.cwd()), 'node_modules'], extensions: ['.mjs', '.js', '.jsx', '.ts', '.tsx', '.json'], diff --git a/packages/sui-test/src/config.js b/packages/sui-test/src/config.js index 53142e3fe..9f5c978a2 100644 --- a/packages/sui-test/src/config.js +++ b/packages/sui-test/src/config.js @@ -7,9 +7,14 @@ function isWorkspace() { return !workspaces && !isPrivate } +function isInnerPackage() { + return isWorkspace() && Boolean(process.cwd().match(/(.*)\/packages\/(.*)/)) +} + module.exports = { bundlerConfig, clientConfig, serverConfig, - isWorkspace + isWorkspace, + isInnerPackage } From b35b3084549573b00882db3025960e3a5ceda048 Mon Sep 17 00:00:00 2001 From: Carlos Villuendas Zambrana Date: Mon, 29 Apr 2024 13:07:06 +0200 Subject: [PATCH 134/134] Update packages/sui-jest/package.json --- packages/sui-jest/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-jest/package.json b/packages/sui-jest/package.json index 64acf7b84..fd7cf7240 100644 --- a/packages/sui-jest/package.json +++ b/packages/sui-jest/package.json @@ -12,7 +12,7 @@ "author": "", "license": "MIT", "dependencies": { - "@swc/jest": "0.2.31", + "@swc/jest": "0.2.24", "@types/jest": "29.2.4", "jest": "29.3.1", "jest-environment-jsdom": "29.3.1",