From 5a05a56ad8e8b3f6258c417f54942155f6276153 Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Thu, 17 Aug 2023 15:23:59 -0700 Subject: [PATCH 01/13] Fixes audit --- package-lock.json | 1224 ++++++++++++++++++++------------------------- package.json | 2 +- 2 files changed, 557 insertions(+), 669 deletions(-) diff --git a/package-lock.json b/package-lock.json index f966049..7befb57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,41 +22,65 @@ "postcss-preset-env": "^7.6.0", "prettier": "^2.6.2", "pretty-quick": "^3.1.3", - "release-it": "^15.3.0" + "release-it": "^16.1.5" }, "peerDependencies": { "postcss": "^8.4.14" } }, "node_modules/@babel/code-frame": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", - "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.10.tgz", + "integrity": "sha512-/KKIMG4UEL35WmI9OlvMhurwtytjvXoFcGNrOvyG9zIzA8YmPjVtIZUf7b05+TPO7G7/GEmLHDaoCgACHl9hhA==", "dev": true, "dependencies": { - "@babel/highlight": "^7.18.6" + "@babel/highlight": "^7.22.10", + "chalk": "^2.4.2" }, "engines": { "node": ">=6.9.0" } }, + "node_modules/@babel/code-frame/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", + "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.10.tgz", + "integrity": "sha512-78aUtVcT7MUscr0K5mIEnkwxPE0MaxkR5RxRwuHaQ+JuU5AmTPhY+do2mdzVTnIJJpyBglql2pehuBIWHug+WQ==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.5", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "engines": { @@ -311,22 +335,6 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/@eslint/eslintrc/node_modules/debug": { - "version": "4.3.4", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, "node_modules/@eslint/eslintrc/node_modules/globals": { "version": "13.15.0", "dev": true, @@ -409,6 +417,15 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "node_modules/@ljharb/through": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/@ljharb/through/-/through-2.3.9.tgz", + "integrity": "sha512-yN599ZBuMPPK4tdoToLlvgJB4CLK8fGl7ntfy0Wn7U6ttNvHYurd81bfUiK/6sMkiIwm65R6ck4L6+Y3DfVbNQ==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -445,21 +462,18 @@ } }, "node_modules/@octokit/auth-token": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.3.tgz", - "integrity": "sha512-/aFM2M4HVDBT/jjDBa84sJniv1t9Gm/rLkalaz9htOm+L+8JMj1k9w0CkUdcxNyNxZPlTxKPVko+m1VlM58ZVA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.4.tgz", + "integrity": "sha512-TWFX7cZF2LXoCvdmJWY7XVPi74aSY0+FfBZNSXEXFkMpjcqsQwDSYVv5FhRFaI0V1ECnwbz4j59T/G+rXNWaIQ==", "dev": true, - "dependencies": { - "@octokit/types": "^9.0.0" - }, "engines": { "node": ">= 14" } }, "node_modules/@octokit/core": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-4.2.0.tgz", - "integrity": "sha512-AgvDRUg3COpR82P7PBdGZF/NNqGmtMq2NiPqeSsDIeCfYFOZ9gddqWNQHnFdEUf+YwOj4aZYmJnlPp7OXmDIDg==", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-4.2.4.tgz", + "integrity": "sha512-rYKilwgzQ7/imScn3M9/pFfUf4I1AZEH3KhyJmtPdE2zfaXAn2mFfUy4FbKewzc2We5y/LlKLj36fWJLKC2SIQ==", "dev": true, "dependencies": { "@octokit/auth-token": "^3.0.0", @@ -475,9 +489,9 @@ } }, "node_modules/@octokit/endpoint": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-7.0.5.tgz", - "integrity": "sha512-LG4o4HMY1Xoaec87IqQ41TQ+glvIeTKqfjkCEmt5AIwDZJwQeVZFIEYXrYY6yLwK+pAScb9Gj4q+Nz2qSw1roA==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-7.0.6.tgz", + "integrity": "sha512-5L4fseVRUsDFGR00tMWD/Trdeeihn999rTMGRMC1G/Ldi1uWlWJzI98H4Iak5DB/RVvQuyMYKqSK/R6mbSOQyg==", "dev": true, "dependencies": { "@octokit/types": "^9.0.0", @@ -489,9 +503,9 @@ } }, "node_modules/@octokit/graphql": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-5.0.5.tgz", - "integrity": "sha512-Qwfvh3xdqKtIznjX9lz2D458r7dJPP8l6r4GQkIdWQouZwHQK0mVT88uwiU2bdTU2OtT1uOlKpRciUWldpG0yQ==", + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-5.0.6.tgz", + "integrity": "sha512-Fxyxdy/JH0MnIB5h+UQ3yCoh1FG4kWXfFKkpWqjZHw/p+Kc8Y44Hu/kCgNBT6nU1shNumEchmW/sUO1JuQnPcw==", "dev": true, "dependencies": { "@octokit/request": "^6.0.0", @@ -503,18 +517,19 @@ } }, "node_modules/@octokit/openapi-types": { - "version": "17.1.1", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-17.1.1.tgz", - "integrity": "sha512-/X7Gh/qWiWaooJmUnYD48SYy72fyrk2ceisOSe89JojK7r0j8YrTwYpDi76kI+c6QiqX1KSgdoBTMJvktsDkYw==", + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-18.0.0.tgz", + "integrity": "sha512-V8GImKs3TeQRxRtXFpG2wl19V7444NIOTDF24AWuIbmNaNYOQMWRbjcGDXV5B+0n887fgDcuMNOmlul+k+oJtw==", "dev": true }, "node_modules/@octokit/plugin-paginate-rest": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-6.0.0.tgz", - "integrity": "sha512-Sq5VU1PfT6/JyuXPyt04KZNVsFOSBaYOAq2QRZUwzVlI10KFvcbUo8lR258AAQL1Et60b0WuVik+zOWKLuDZxw==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-6.1.2.tgz", + "integrity": "sha512-qhrmtQeHU/IivxucOV1bbI/xZyC/iOBhclokv7Sut5vnejAIAEXVcGQeRpQlU39E0WwK9lNvJHphHri/DB6lbQ==", "dev": true, "dependencies": { - "@octokit/types": "^9.0.0" + "@octokit/tsconfig": "^1.0.2", + "@octokit/types": "^9.2.3" }, "engines": { "node": ">= 14" @@ -533,13 +548,12 @@ } }, "node_modules/@octokit/plugin-rest-endpoint-methods": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-7.0.1.tgz", - "integrity": "sha512-pnCaLwZBudK5xCdrR823xHGNgqOzRnJ/mpC/76YPpNP7DybdsJtP7mdOwh+wYZxK5jqeQuhu59ogMI4NRlBUvA==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-7.2.3.tgz", + "integrity": "sha512-I5Gml6kTAkzVlN7KCtjOM+Ruwe/rQppp0QU372K1GP7kNOYEKe8Xn5BW4sE62JAHdwpq95OQK/qGNyKQMUzVgA==", "dev": true, "dependencies": { - "@octokit/types": "^9.0.0", - "deprecation": "^2.3.1" + "@octokit/types": "^10.0.0" }, "engines": { "node": ">= 14" @@ -548,10 +562,19 @@ "@octokit/core": ">=3" } }, + "node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/types": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-10.0.0.tgz", + "integrity": "sha512-Vm8IddVmhCgU1fxC1eyinpwqzXPEYu0NrYzD3YZjlGjyftdLBTeqNblRC0jmJmgxbJIsQlyogVeGnrNaaMVzIg==", + "dev": true, + "dependencies": { + "@octokit/openapi-types": "^18.0.0" + } + }, "node_modules/@octokit/request": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-6.2.3.tgz", - "integrity": "sha512-TNAodj5yNzrrZ/VxP+H5HiYaZep0H3GU0O7PaF+fhDrt8FPrnkei9Aal/txsN/1P7V3CPiThG0tIvpPDYUsyAA==", + "version": "6.2.8", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-6.2.8.tgz", + "integrity": "sha512-ow4+pkVQ+6XVVsekSYBzJC0VTVvh/FCTUUgTsboGq+DTeWdyIFV8WSCdo0RIxk6wSkBTHqIK1mYuY7nOBXOchw==", "dev": true, "dependencies": { "@octokit/endpoint": "^7.0.0", @@ -580,27 +603,33 @@ } }, "node_modules/@octokit/rest": { - "version": "19.0.7", - "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-19.0.7.tgz", - "integrity": "sha512-HRtSfjrWmWVNp2uAkEpQnuGMJsu/+dBr47dRc5QVgsCbnIc1+GFEaoKBWkYG+zjrsHpSqcAElMio+n10c0b5JA==", + "version": "19.0.13", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-19.0.13.tgz", + "integrity": "sha512-/EzVox5V9gYGdbAI+ovYj3nXQT1TtTHRT+0eZPcuC05UFSWO3mdO9UY1C0i2eLF9Un1ONJkAk+IEtYGAC+TahA==", "dev": true, "dependencies": { - "@octokit/core": "^4.1.0", - "@octokit/plugin-paginate-rest": "^6.0.0", + "@octokit/core": "^4.2.1", + "@octokit/plugin-paginate-rest": "^6.1.2", "@octokit/plugin-request-log": "^1.0.4", - "@octokit/plugin-rest-endpoint-methods": "^7.0.0" + "@octokit/plugin-rest-endpoint-methods": "^7.1.2" }, "engines": { "node": ">= 14" } }, + "node_modules/@octokit/tsconfig": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-1.0.2.tgz", + "integrity": "sha512-I0vDR0rdtP8p2lGMzvsJzbhdOWy405HcGovrspJ8RRibHnyRgggUSNO5AIox5LmqiwmatHKYsvj6VGFHkqS7lA==", + "dev": true + }, "node_modules/@octokit/types": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-9.2.1.tgz", - "integrity": "sha512-Vx4keMiD/CAiwVFasLcH0xBSVbKIHebIZke9i7ZbUWGNN4vJFWSYH6Nvga7UY9NIJCGa6x3QG849XTbi5wYmkA==", + "version": "9.3.2", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-9.3.2.tgz", + "integrity": "sha512-D4iHGTdAnEEVsB8fl95m1hiz7D5YiRdQ9b/OEb3BYRVwbLsGHcRVPz+u+BgRLNk0Q0/4iZCBqDN96j2XNxfXrA==", "dev": true, "dependencies": { - "@octokit/openapi-types": "^17.1.1" + "@octokit/openapi-types": "^18.0.0" } }, "node_modules/@pnpm/network.ca-file": { @@ -656,6 +685,12 @@ "node": ">= 6" } }, + "node_modules/@tootallnate/quickjs-emscripten": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", + "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==", + "dev": true + }, "node_modules/@types/http-cache-semantics": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz", @@ -697,14 +732,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/acorn-walk": { - "version": "8.2.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/agent-base": { "version": "6.0.2", "dev": true, @@ -919,8 +946,9 @@ }, "node_modules/ast-types": { "version": "0.13.4", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", + "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==", "dev": true, - "license": "MIT", "dependencies": { "tslib": "^2.0.1" }, @@ -1013,6 +1041,15 @@ } ] }, + "node_modules/basic-ftp": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.3.tgz", + "integrity": "sha512-QHX8HLlncOLpy54mh+k/sWIFd0ThmRqwe9ZjELybGZK+tZ8rUb9VO0saKJUROTbE+KhzDUT7xziGpGrW8Kmd+g==", + "dev": true, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/before-after-hook": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", @@ -1246,14 +1283,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/bytes": { - "version": "3.1.2", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/c8": { "version": "7.13.0", "resolved": "https://registry.npmjs.org/c8/-/c8-7.13.0.tgz", @@ -1481,9 +1510,9 @@ } }, "node_modules/chalk": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.2.0.tgz", - "integrity": "sha512-ree3Gqw/nazQAPuJJEy+avdl7QfZMcUvmHIKgEZkGL+xOBzRvup5Hxo6LHuMceSxOabuJLJm5Yp/92R9eMmMvA==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", "dev": true, "engines": { "node": "^12.17.0 || ^14.13 || >=16.0.0" @@ -1617,9 +1646,9 @@ } }, "node_modules/cli-width": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.0.0.tgz", - "integrity": "sha512-ZksGS2xpa/bYkNzN3BAw1wEjsLV/ZKOf/CCrJ/QOBsxx6fOARIkwTutxp1XIOIohi6HKmOFjMoK/XaqDVUpEEw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", "dev": true, "engines": { "node": ">= 12" @@ -1738,15 +1767,10 @@ "safe-buffer": "~5.1.1" } }, - "node_modules/core-util-is": { - "version": "1.0.3", - "dev": true, - "license": "MIT" - }, "node_modules/cosmiconfig": { - "version": "8.1.3", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.1.3.tgz", - "integrity": "sha512-/UkO2JKI18b5jVMJUp0lvKFMpa/Gye+ZgZjKD+DGEN9y7NRcf/nK1A0sp67ONmKtnDCNMS44E6jrk0Yc3bDuUw==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.2.0.tgz", + "integrity": "sha512-3rTMnFJA1tCOPwRxtgF4wd7Ab2qvDbL8jX+3smjIbS4HlZBagTlpERbdN7iAbWlrfxE3M8c27kTwTawQ7st+OQ==", "dev": true, "dependencies": { "import-fresh": "^3.2.1", @@ -1868,26 +1892,31 @@ } }, "node_modules/data-uri-to-buffer": { - "version": "3.0.1", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-5.0.1.tgz", + "integrity": "sha512-a9l6T1qqDogvvnw0nKlfZzqsyikEBZBClF39V3TFoKhDtGBqHu2HkuomJc02j5zft8zrUaXEuoicLeW54RkzPg==", "dev": true, - "license": "MIT", "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/debug": { - "version": "4.1.1", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, - "license": "MIT", "dependencies": { - "ms": "^2.1.1" + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "node_modules/debug/node_modules/ms": { - "version": "2.1.1", - "dev": true, - "license": "MIT" - }, "node_modules/decompress-response": { "version": "6.0.0", "dev": true, @@ -2130,25 +2159,17 @@ } }, "node_modules/degenerator": { - "version": "3.0.2", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", + "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", "dev": true, - "license": "MIT", "dependencies": { - "ast-types": "^0.13.2", - "escodegen": "^1.8.1", - "esprima": "^4.0.0", - "vm2": "^3.9.8" + "ast-types": "^0.13.4", + "escodegen": "^2.1.0", + "esprima": "^4.0.1" }, "engines": { - "node": ">= 6" - } - }, - "node_modules/depd": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" + "node": ">= 14" } }, "node_modules/deprecation": { @@ -2371,80 +2392,26 @@ } }, "node_modules/escodegen": { - "version": "1.14.3", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", + "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" + "estraverse": "^5.2.0", + "esutils": "^2.0.2" }, "bin": { "escodegen": "bin/escodegen.js", "esgenerate": "bin/esgenerate.js" }, "engines": { - "node": ">=4.0" + "node": ">=6.0" }, "optionalDependencies": { "source-map": "~0.6.1" } }, - "node_modules/escodegen/node_modules/estraverse": { - "version": "4.3.0", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/escodegen/node_modules/levn": { - "version": "0.3.0", - "dev": true, - "license": "MIT", - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/optionator": { - "version": "0.8.3", - "dev": true, - "license": "MIT", - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/prelude-ls": { - "version": "1.1.2", - "dev": true, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/type-check": { - "version": "0.3.2", - "dev": true, - "license": "MIT", - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/eslint": { "version": "8.16.0", "dev": true, @@ -2606,22 +2573,6 @@ "dev": true, "license": "MIT" }, - "node_modules/eslint/node_modules/debug": { - "version": "4.3.4", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, "node_modules/eslint/node_modules/escape-string-regexp": { "version": "4.0.0", "dev": true, @@ -2787,9 +2738,9 @@ "license": "Apache-2.0" }, "node_modules/fast-glob": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", - "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -2903,14 +2854,6 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/file-uri-to-path": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 6" - } - }, "node_modules/fill-range": { "version": "7.0.1", "dev": true, @@ -2983,60 +2926,6 @@ "node": ">=8.0.0" } }, - "node_modules/foreground-child/node_modules/cross-spawn": { - "version": "7.0.3", - "dev": true, - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/foreground-child/node_modules/path-key": { - "version": "3.1.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/foreground-child/node_modules/shebang-command": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/foreground-child/node_modules/shebang-regex": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/foreground-child/node_modules/which": { - "version": "2.0.2", - "dev": true, - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/form-data-encoder": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-2.1.4.tgz", @@ -3072,8 +2961,9 @@ }, "node_modules/fs-extra": { "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", "dev": true, - "license": "MIT", "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", @@ -3100,38 +2990,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/ftp": { - "version": "0.3.10", - "dev": true, - "dependencies": { - "readable-stream": "1.1.x", - "xregexp": "2.0.0" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/ftp/node_modules/isarray": { - "version": "0.0.1", - "dev": true, - "license": "MIT" - }, - "node_modules/ftp/node_modules/readable-stream": { - "version": "1.1.14", - "dev": true, - "license": "MIT", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/ftp/node_modules/string_decoder": { - "version": "0.10.31", - "dev": true, - "license": "MIT" - }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -3228,19 +3086,18 @@ } }, "node_modules/get-uri": { - "version": "3.0.2", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.1.tgz", + "integrity": "sha512-7ZqONUVqaabogsYNWlYj0t3YZaL6dhuEueZXGF+/YVmf6dHmaFg8/6psJKqhx9QykIDKzpGcy2cn4oV4YC7V/Q==", "dev": true, - "license": "MIT", "dependencies": { - "@tootallnate/once": "1", - "data-uri-to-buffer": "3", - "debug": "4", - "file-uri-to-path": "2", - "fs-extra": "^8.1.0", - "ftp": "^0.3.10" + "basic-ftp": "^5.0.2", + "data-uri-to-buffer": "^5.0.1", + "debug": "^4.3.4", + "fs-extra": "^8.1.0" }, "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/git-up": { @@ -3322,14 +3179,14 @@ } }, "node_modules/globby": { - "version": "13.1.4", - "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.4.tgz", - "integrity": "sha512-iui/IiiW+QrJ1X1hKH5qwlMQyv34wJAYwH1vrf8b9kBA4sNiif3gKsMHa+BrdnOpEudWjpotfa7LrTzB1ERS/g==", + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.2.2.tgz", + "integrity": "sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w==", "dev": true, "dependencies": { "dir-glob": "^3.0.1", - "fast-glob": "^3.2.11", - "ignore": "^5.2.0", + "fast-glob": "^3.3.0", + "ignore": "^5.2.4", "merge2": "^1.4.1", "slash": "^4.0.0" }, @@ -3353,9 +3210,9 @@ } }, "node_modules/got": { - "version": "12.6.0", - "resolved": "https://registry.npmjs.org/got/-/got-12.6.0.tgz", - "integrity": "sha512-WTcaQ963xV97MN3x0/CbAriXFZcXCfgxVp91I+Ze6pawQOa7SgzwSx2zIJJsX+kTajMnVs0xcFD1TxZKFqhdnQ==", + "version": "12.6.1", + "resolved": "https://registry.npmjs.org/got/-/got-12.6.1.tgz", + "integrity": "sha512-mThBblvlAF1d4O5oqyvN+ZxLAYwIJK7bpMxgYqPD9okW0C3qm5FFn7k811QrcuEBwaogR3ngOFoCfs6mRv7teQ==", "dev": true, "dependencies": { "@sindresorhus/is": "^5.2.0", @@ -3493,21 +3350,6 @@ "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", "dev": true }, - "node_modules/http-errors": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "depd": "2.0.0", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "toidentifier": "1.0.1" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/http-proxy-agent": { "version": "4.0.1", "dev": true, @@ -3569,8 +3411,9 @@ }, "node_modules/iconv-lite": { "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, - "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -3599,9 +3442,10 @@ ] }, "node_modules/ignore": { - "version": "5.2.0", + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", "dev": true, - "license": "MIT", "engines": { "node": ">= 4" } @@ -3676,131 +3520,189 @@ } }, "node_modules/inquirer": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-9.2.0.tgz", - "integrity": "sha512-WWERbVqjsTXjXub1ZW0ZHDit1dyHqy0T9XIkky9TnmKAPrjU9Jkd59nZPK0dUuM3s73GZAZu2Jo4iFU3XSPVLA==", + "version": "9.2.10", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-9.2.10.tgz", + "integrity": "sha512-tVVNFIXU8qNHoULiazz612GFl+yqNfjMTbLuViNJE/d860Qxrd3NMrse8dm40VUQLOQeULvaQF8lpAhvysjeyA==", "dev": true, "dependencies": { - "ansi-escapes": "^6.0.0", - "chalk": "^5.2.0", - "cli-cursor": "^4.0.0", - "cli-width": "^4.0.0", - "external-editor": "^3.0.3", + "@ljharb/through": "^2.3.9", + "ansi-escapes": "^4.3.2", + "chalk": "^5.3.0", + "cli-cursor": "^3.1.0", + "cli-width": "^4.1.0", + "external-editor": "^3.1.0", "figures": "^5.0.0", "lodash": "^4.17.21", "mute-stream": "1.0.0", - "ora": "^6.1.2", - "run-async": "^2.4.0", - "rxjs": "^7.8.0", - "string-width": "^5.1.2", - "strip-ansi": "^7.0.1", - "through": "^2.3.6", - "wrap-ansi": "^8.1.0" + "ora": "^5.4.1", + "run-async": "^3.0.0", + "rxjs": "^7.8.1", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^6.2.0" }, "engines": { "node": ">=14.18.0" } }, - "node_modules/inquirer/node_modules/ansi-escapes": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-6.2.0.tgz", - "integrity": "sha512-kzRaCqXnpzWs+3z5ABPQiVke+iq0KXkHo8xiWV4RPTi5Yli0l97BEQuhXV1s7+aSU/fu1kUuxgS4MsQ0fRuygw==", + "node_modules/inquirer/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "dependencies": { - "type-fest": "^3.0.0" + "color-convert": "^2.0.1" }, "engines": { - "node": ">=14.16" + "node": ">=8" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/inquirer/node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "node_modules/inquirer/node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" } }, - "node_modules/inquirer/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "node_modules/inquirer/node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" } }, - "node_modules/inquirer/node_modules/cli-cursor": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-4.0.0.tgz", - "integrity": "sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==", + "node_modules/inquirer/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "dependencies": { - "restore-cursor": "^4.0.0" + "color-name": "~1.1.4" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=7.0.0" } }, - "node_modules/inquirer/node_modules/restore-cursor": { + "node_modules/inquirer/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/inquirer/node_modules/has-flag": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", - "integrity": "sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/inquirer/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/inquirer/node_modules/is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/inquirer/node_modules/ora": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", "dev": true, "dependencies": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" + "bl": "^4.1.0", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "is-unicode-supported": "^0.1.0", + "log-symbols": "^4.1.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/inquirer/node_modules/strip-ansi": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz", - "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==", + "node_modules/inquirer/node_modules/ora/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "dependencies": { - "ansi-regex": "^6.0.1" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" }, "engines": { - "node": ">=12" + "node": ">=10" }, "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/inquirer/node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "node_modules/inquirer/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" }, "engines": { - "node": ">=12" + "node": ">=8" + } + }, + "node_modules/inquirer/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + "engines": { + "node": ">=8" } }, "node_modules/internal-slot": { @@ -3827,8 +3729,9 @@ }, "node_modules/ip": { "version": "1.1.8", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", + "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==", + "dev": true }, "node_modules/is-arguments": { "version": "1.1.1", @@ -4441,8 +4344,9 @@ }, "node_modules/jsonfile": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", "dev": true, - "license": "MIT", "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -4526,22 +4430,6 @@ "url": "https://opencollective.com/lint-staged" } }, - "node_modules/lint-staged/node_modules/debug": { - "version": "4.3.4", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, "node_modules/lint-staged/node_modules/supports-color": { "version": "9.2.2", "dev": true, @@ -4913,11 +4801,12 @@ } }, "node_modules/lru-cache": { - "version": "5.1.1", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^3.0.2" + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "dev": true, + "engines": { + "node": ">=12" } }, "node_modules/macos-release": { @@ -4947,9 +4836,10 @@ } }, "node_modules/make-dir/node_modules/semver": { - "version": "6.3.0", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, - "license": "ISC", "bin": { "semver": "bin/semver.js" } @@ -5118,27 +5008,6 @@ "dev": true, "license": "MIT" }, - "node_modules/mocha/node_modules/debug": { - "version": "4.3.4", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/mocha/node_modules/debug/node_modules/ms": { - "version": "2.1.2", - "dev": true, - "license": "MIT" - }, "node_modules/mocha/node_modules/escape-string-regexp": { "version": "4.0.0", "dev": true, @@ -5351,8 +5220,9 @@ }, "node_modules/netmask": { "version": "2.0.2", + "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", + "integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==", "dev": true, - "license": "MIT", "engines": { "node": ">= 0.4.0" } @@ -5557,23 +5427,23 @@ } }, "node_modules/ora": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/ora/-/ora-6.3.0.tgz", - "integrity": "sha512-1/D8uRFY0ay2kgBpmAwmSA404w4OoPVhHMqRqtjvrcK/dnzcEZxMJ+V4DUbyICu8IIVRclHcOf5wlD1tMY4GUQ==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-7.0.1.tgz", + "integrity": "sha512-0TUxTiFJWv+JnjWm4o9yvuskpEJLXTcng8MJuKd+SzAzp2o+OP3HWqNhB4OdJRt1Vsd9/mR0oyaEYlOnL7XIRw==", "dev": true, "dependencies": { - "chalk": "^5.0.0", + "chalk": "^5.3.0", "cli-cursor": "^4.0.0", - "cli-spinners": "^2.6.1", + "cli-spinners": "^2.9.0", "is-interactive": "^2.0.0", - "is-unicode-supported": "^1.1.0", + "is-unicode-supported": "^1.3.0", "log-symbols": "^5.1.0", "stdin-discarder": "^0.1.0", - "strip-ansi": "^7.0.1", - "wcwidth": "^1.0.1" + "string-width": "^6.1.0", + "strip-ansi": "^7.1.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -5606,6 +5476,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/ora/node_modules/emoji-regex": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.2.1.tgz", + "integrity": "sha512-97g6QgOk8zlDRdgq1WxwgTMgEWGVAQvB5Fdpgc1MkNy56la5SKP9GsMXKDOdqwn90/41a8yPwIGk1Y6WVbeMQA==", + "dev": true + }, "node_modules/ora/node_modules/is-unicode-supported": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", @@ -5650,10 +5526,27 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/ora/node_modules/string-width": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-6.1.0.tgz", + "integrity": "sha512-k01swCJAgQmuADB0YIc+7TuatfNvTBVOoaUWJjTB9R4VJzR5vNWzf5t42ESVZFPS8xTySF7CAdV4t/aaIm3UnQ==", + "dev": true, + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^10.2.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/ora/node_modules/strip-ansi": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz", - "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "dev": true, "dependencies": { "ansi-regex": "^6.0.1" @@ -5735,35 +5628,74 @@ } }, "node_modules/pac-proxy-agent": { - "version": "5.0.0", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.0.0.tgz", + "integrity": "sha512-t4tRAMx0uphnZrio0S0Jw9zg3oDbz1zVhQ/Vy18FjLfP1XOLNUEjaVxYCYRI6NS+BsMBXKIzV6cTLOkO9AtywA==", "dev": true, - "license": "MIT", "dependencies": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4", - "get-uri": "3", - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "5", - "pac-resolver": "^5.0.0", - "raw-body": "^2.2.0", - "socks-proxy-agent": "5" + "@tootallnate/quickjs-emscripten": "^0.23.0", + "agent-base": "^7.0.2", + "debug": "^4.3.4", + "get-uri": "^6.0.1", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.0", + "pac-resolver": "^7.0.0", + "socks-proxy-agent": "^8.0.1" }, "engines": { - "node": ">= 8" + "node": ">= 14" + } + }, + "node_modules/pac-proxy-agent/node_modules/agent-base": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", + "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", + "dev": true, + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/pac-proxy-agent/node_modules/http-proxy-agent": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz", + "integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==", + "dev": true, + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/pac-proxy-agent/node_modules/https-proxy-agent": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.1.tgz", + "integrity": "sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==", + "dev": true, + "dependencies": { + "agent-base": "^7.0.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" } }, "node_modules/pac-resolver": { - "version": "5.0.1", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.0.tgz", + "integrity": "sha512-Fd9lT9vJbHYRACT8OhCbZBbxr6KRSawSovFpy8nDGshaK99S/EBhVIHp9+crhxrsZOuvLpgL1n23iyPg6Rl2hg==", "dev": true, - "license": "MIT", "dependencies": { - "degenerator": "^3.0.2", - "ip": "^1.1.5", + "degenerator": "^5.0.0", + "ip": "^1.1.8", "netmask": "^2.0.2" }, "engines": { - "node": ">= 8" + "node": ">= 14" } }, "node_modules/package-json": { @@ -6631,27 +6563,67 @@ "dev": true }, "node_modules/proxy-agent": { - "version": "5.0.0", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.3.0.tgz", + "integrity": "sha512-0LdR757eTj/JfuU7TL2YCuAZnxWXu3tkJbg4Oq3geW/qFNT/32T0sp2HnZ9O0lMR4q3vwAt0+xCA8SR0WAD0og==", "dev": true, - "license": "MIT", "dependencies": { - "agent-base": "^6.0.0", - "debug": "4", - "http-proxy-agent": "^4.0.0", - "https-proxy-agent": "^5.0.0", - "lru-cache": "^5.1.1", - "pac-proxy-agent": "^5.0.0", - "proxy-from-env": "^1.0.0", - "socks-proxy-agent": "^5.0.0" + "agent-base": "^7.0.2", + "debug": "^4.3.4", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.0", + "lru-cache": "^7.14.1", + "pac-proxy-agent": "^7.0.0", + "proxy-from-env": "^1.1.0", + "socks-proxy-agent": "^8.0.1" }, "engines": { - "node": ">= 8" + "node": ">= 14" + } + }, + "node_modules/proxy-agent/node_modules/agent-base": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", + "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", + "dev": true, + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/proxy-agent/node_modules/http-proxy-agent": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz", + "integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==", + "dev": true, + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/proxy-agent/node_modules/https-proxy-agent": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.1.tgz", + "integrity": "sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==", + "dev": true, + "dependencies": { + "agent-base": "^7.0.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" } }, "node_modules/proxy-from-env": { "version": "1.1.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true }, "node_modules/pump": { "version": "3.0.0", @@ -6720,20 +6692,6 @@ "safe-buffer": "^5.1.0" } }, - "node_modules/raw-body": { - "version": "2.5.1", - "dev": true, - "license": "MIT", - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/rc": { "version": "1.2.8", "dev": true, @@ -6850,33 +6808,33 @@ } }, "node_modules/release-it": { - "version": "15.10.3", - "resolved": "https://registry.npmjs.org/release-it/-/release-it-15.10.3.tgz", - "integrity": "sha512-OSdHOg76gwkpLbSLBK09GZQj5XWXwBP+S6v//rSoQKkjqklaCLK04Gl5NkTwNrQOHHiihs4ToesDNh2+w55k3w==", + "version": "16.1.5", + "resolved": "https://registry.npmjs.org/release-it/-/release-it-16.1.5.tgz", + "integrity": "sha512-w/zCljPZBSYcCwR9fjDB1zaYwie1CAQganUrwNqjtXacXhrrsS5E6dDUNLcxm2ypu8GWAgZNMJfuBJqIO2E7fA==", "dev": true, "dependencies": { "@iarna/toml": "2.2.5", - "@octokit/rest": "19.0.7", + "@octokit/rest": "19.0.13", "async-retry": "1.3.3", - "chalk": "5.2.0", - "cosmiconfig": "8.1.3", - "execa": "7.1.1", + "chalk": "5.3.0", + "cosmiconfig": "8.2.0", + "execa": "7.2.0", "git-url-parse": "13.1.0", - "globby": "13.1.4", - "got": "12.6.0", - "inquirer": "9.2.0", + "globby": "13.2.2", + "got": "13.0.0", + "inquirer": "9.2.10", "is-ci": "3.0.1", "issue-parser": "6.0.0", "lodash": "4.17.21", "mime-types": "2.1.35", "new-github-release-url": "2.0.0", - "node-fetch": "3.3.1", + "node-fetch": "3.3.2", "open": "9.1.0", - "ora": "6.3.0", + "ora": "7.0.1", "os-name": "5.1.0", "promise.allsettled": "1.0.6", - "proxy-agent": "5.0.0", - "semver": "7.5.0", + "proxy-agent": "6.3.0", + "semver": "7.5.4", "shelljs": "0.8.5", "update-notifier": "6.0.2", "url-join": "5.0.0", @@ -6887,7 +6845,7 @@ "release-it": "bin/release-it.js" }, "engines": { - "node": ">=14.9" + "node": ">=16" } }, "node_modules/release-it/node_modules/data-uri-to-buffer": { @@ -6900,9 +6858,9 @@ } }, "node_modules/release-it/node_modules/execa": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-7.1.1.tgz", - "integrity": "sha512-wH0eMf/UXckdUYnO21+HDztteVv05rq2GXksxT4fCGeHkBhw1DROXh40wcjMcRqDOWE7iPJ4n3M7e2+YFP+76Q==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-7.2.0.tgz", + "integrity": "sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==", "dev": true, "dependencies": { "cross-spawn": "^7.0.3", @@ -6922,6 +6880,31 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, + "node_modules/release-it/node_modules/got": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/got/-/got-13.0.0.tgz", + "integrity": "sha512-XfBk1CxOOScDcMr9O1yKkNaQyy865NbYs+F7dr4H0LZMVgCj2Le59k6PqbNHoL5ToeaEQUYh6c6yMfVcc6SJxA==", + "dev": true, + "dependencies": { + "@sindresorhus/is": "^5.2.0", + "@szmarczak/http-timer": "^5.0.1", + "cacheable-lookup": "^7.0.0", + "cacheable-request": "^10.2.8", + "decompress-response": "^6.0.0", + "form-data-encoder": "^2.1.2", + "get-stream": "^6.0.1", + "http2-wrapper": "^2.1.10", + "lowercase-keys": "^3.0.0", + "p-cancelable": "^3.0.0", + "responselike": "^3.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sindresorhus/got?sponsor=1" + } + }, "node_modules/release-it/node_modules/human-signals": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.1.tgz", @@ -6956,9 +6939,9 @@ } }, "node_modules/release-it/node_modules/node-fetch": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz", - "integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", "dev": true, "dependencies": { "data-uri-to-buffer": "^4.0.0", @@ -7144,9 +7127,9 @@ } }, "node_modules/run-async": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", - "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-3.0.0.tgz", + "integrity": "sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==", "dev": true, "engines": { "node": ">=0.12.0" @@ -7205,13 +7188,14 @@ }, "node_modules/safer-buffer": { "version": "2.1.2", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true }, "node_modules/semver": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.0.tgz", - "integrity": "sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -7263,11 +7247,6 @@ "randombytes": "^2.1.0" } }, - "node_modules/setprototypeof": { - "version": "1.2.0", - "dev": true, - "license": "ISC" - }, "node_modules/shebang-command": { "version": "2.0.0", "dev": true, @@ -7362,17 +7341,19 @@ }, "node_modules/smart-buffer": { "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", "dev": true, - "license": "MIT", "engines": { "node": ">= 6.0.0", "npm": ">= 3.0.0" } }, "node_modules/socks": { - "version": "2.7.0", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", + "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", "dev": true, - "license": "MIT", "dependencies": { "ip": "^2.0.0", "smart-buffer": "^4.2.0" @@ -7383,22 +7364,36 @@ } }, "node_modules/socks-proxy-agent": { - "version": "5.0.1", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.1.tgz", + "integrity": "sha512-59EjPbbgg8U3x62hhKOFVAmySQUcfRQ4C7Q/D5sEHnZTQRrQlNKINks44DMR1gwXp0p4LaVIeccX2KHTTcHVqQ==", "dev": true, - "license": "MIT", "dependencies": { - "agent-base": "^6.0.2", - "debug": "4", - "socks": "^2.3.3" + "agent-base": "^7.0.1", + "debug": "^4.3.4", + "socks": "^2.7.1" }, "engines": { - "node": ">= 6" + "node": ">= 14" + } + }, + "node_modules/socks-proxy-agent/node_modules/agent-base": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", + "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", + "dev": true, + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" } }, "node_modules/socks/node_modules/ip": { "version": "2.0.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", + "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==", + "dev": true }, "node_modules/source-map": { "version": "0.6.1", @@ -7421,14 +7416,6 @@ "dev": true, "license": "BSD-3-Clause" }, - "node_modules/statuses": { - "version": "2.0.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/stdin-discarder": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/stdin-discarder/-/stdin-discarder-0.1.0.tgz", @@ -7667,25 +7654,6 @@ "node": ">=8" } }, - "node_modules/test-exclude/node_modules/glob": { - "version": "7.1.6", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/text-table": { "version": "0.2.0", "dev": true, @@ -7731,14 +7699,6 @@ "node": ">=8.0" } }, - "node_modules/toidentifier": { - "version": "1.0.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.6" - } - }, "node_modules/tr46": { "version": "0.0.3", "dev": true, @@ -7768,21 +7728,6 @@ "node": ">=4" } }, - "node_modules/type-fest": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.10.0.tgz", - "integrity": "sha512-hmAPf1datm+gt3c2mvu0sJyhFy6lTkIGf0GzyaZWxRLnabQfPUqg6tF95RPg6sLxKI7nFLGdFxBcf2/7+GXI+A==", - "dev": true, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - }, - "peerDependencies": { - "typescript": ">=4.7.0" - } - }, "node_modules/typed-array-length": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz", @@ -7805,20 +7750,6 @@ "is-typedarray": "^1.0.0" } }, - "node_modules/typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", - "dev": true, - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=12.20" - } - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -7856,20 +7787,13 @@ }, "node_modules/universalify": { "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", "dev": true, - "license": "MIT", "engines": { "node": ">= 4.0.0" } }, - "node_modules/unpipe": { - "version": "1.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/untildify": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", @@ -7970,22 +7894,6 @@ "node": ">=10.12.0" } }, - "node_modules/vm2": { - "version": "3.9.17", - "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.17.tgz", - "integrity": "sha512-AqwtCnZ/ERcX+AVj9vUsphY56YANXxRuqMb7GsDtAr0m0PcQX3u0Aj3KWiXM0YAHy7i6JEeHrwOnwXbGYgRpAw==", - "dev": true, - "dependencies": { - "acorn": "^8.7.0", - "acorn-walk": "^8.2.0" - }, - "bin": { - "vm2": "bin/vm2" - }, - "engines": { - "node": ">=6.0" - } - }, "node_modules/wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", @@ -8103,9 +8011,10 @@ } }, "node_modules/word-wrap": { - "version": "1.2.3", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, - "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -8179,17 +8088,6 @@ "node": ">=8" } }, - "node_modules/wrap-ansi/node_modules/strip-ansi": { - "version": "6.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/wrappy": { "version": "1.0.2", "dev": true, @@ -8217,16 +8115,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/xregexp": { - "version": "2.0.0", - "dev": true, - "license": "MIT" - }, - "node_modules/yallist": { - "version": "3.1.1", - "dev": true, - "license": "ISC" - }, "node_modules/yaml": { "version": "1.10.2", "dev": true, diff --git a/package.json b/package.json index b6a1972..d178373 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "postcss-preset-env": "^7.6.0", "prettier": "^2.6.2", "pretty-quick": "^3.1.3", - "release-it": "^15.3.0" + "release-it": "^16.1.5" }, "peerDependencies": { "postcss": "^8.4.14" From dc94a9b9be06e1ab2a5130c0347f568d0786598b Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sat, 19 Aug 2023 18:40:43 -0700 Subject: [PATCH 02/13] TypeScript Step 1 --- .gitignore | 2 + lib/core/lg-logic.js | 41 --- lib/core/lg-new-block.js | 33 --- lib/core/lg-utilities.js | 111 ------- lib/lost-gutter.js | 24 -- lib/lost-vars-gutter.js | 3 - lib/lost-vars.js | 50 ---- lost.js | 62 ---- package-lock.json | 279 +++++++++++++++++- package.json | 13 +- src/core/lg-logic.ts | 43 +++ src/core/lg-new-block.ts | 42 +++ src/core/lg-utilities.ts | 90 ++++++ lib/lost-align.js => src/lost-align.ts | 6 +- lib/lost-at-rule.js => src/lost-at-rule.ts | 2 +- lib/lost-center.js => src/lost-center.ts | 13 +- lib/lost-column.js => src/lost-column.ts | 27 +- .../lost-flex-container.ts | 4 +- src/lost-gutter.ts | 44 +++ .../lost-masonry-column.ts | 14 +- .../lost-masonry-wrap.ts | 14 +- lib/lost-move.js => src/lost-move.ts | 22 +- lib/lost-offset.js => src/lost-offset.ts | 30 +- lib/lost-row.js => src/lost-row.ts | 25 +- lib/lost-utility.js => src/lost-utility.ts | 33 +-- .../lost-vars-gutter-local.ts | 4 +- src/lost-vars-gutter.ts | 3 + src/lost-vars.ts | 61 ++++ lib/lost-waffle.js => src/lost-waffle.ts | 55 ++-- src/lost.ts | 63 ++++ test/check.js | 2 +- test/lg-logic.js | 132 +++++---- test/lg-utility.js | 152 +++++----- test/lost-nesting.js | 2 +- test/lost-plugin-options.js | 2 +- test/lost-vars.js | 17 +- test/throws.js | 2 +- tsconfig.json | 17 ++ 38 files changed, 951 insertions(+), 588 deletions(-) delete mode 100644 lib/core/lg-logic.js delete mode 100644 lib/core/lg-new-block.js delete mode 100644 lib/core/lg-utilities.js delete mode 100644 lib/lost-gutter.js delete mode 100644 lib/lost-vars-gutter.js delete mode 100644 lib/lost-vars.js delete mode 100644 lost.js create mode 100644 src/core/lg-logic.ts create mode 100644 src/core/lg-new-block.ts create mode 100644 src/core/lg-utilities.ts rename lib/lost-align.js => src/lost-align.ts (98%) rename lib/lost-at-rule.js => src/lost-at-rule.ts (93%) rename lib/lost-center.js => src/lost-center.ts (89%) rename lib/lost-column.js => src/lost-column.ts (94%) rename lib/lost-flex-container.js => src/lost-flex-container.ts (80%) create mode 100644 src/lost-gutter.ts rename lib/lost-masonry-column.js => src/lost-masonry-column.ts (91%) rename lib/lost-masonry-wrap.js => src/lost-masonry-wrap.ts (89%) rename lib/lost-move.js => src/lost-move.ts (85%) rename lib/lost-offset.js => src/lost-offset.ts (92%) rename lib/lost-row.js => src/lost-row.ts (85%) rename lib/lost-utility.js => src/lost-utility.ts (82%) rename lib/lost-vars-gutter-local.js => src/lost-vars-gutter-local.ts (87%) create mode 100644 src/lost-vars-gutter.ts create mode 100644 src/lost-vars.ts rename lib/lost-waffle.js => src/lost-waffle.ts (89%) create mode 100644 src/lost.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index edad911..9f306dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # Created by https://www.gitignore.io +dist + ### Node ### # Logs logs diff --git a/lib/core/lg-logic.js b/lib/core/lg-logic.js deleted file mode 100644 index b414f06..0000000 --- a/lib/core/lg-logic.js +++ /dev/null @@ -1,41 +0,0 @@ -module.exports = { - calcValue: function (fraction, gutter, rounder, unit) { - var calcValue = ''; - var gutterLogic = ''; - - if (!gutter) { - gutter = '0'; - } - - if (gutter !== '0') { - gutterLogic = ` - (${gutter} - ${gutter} * ${fraction})`; - } - - if (!unit) { - unit = '%'; - } - - calcValue = `calc(${rounder}${unit} * ${fraction}${gutterLogic})`; - return calcValue; - }, - validateUnit: function (value, validUnits) { - var validation = false; - - if (validUnits.indexOf(value) !== -1) { - validation = true; - } - return validation; - }, - parseLostProperty: function (nodes, propertyName, defaultPropertyValue) { - var propertyValue = defaultPropertyValue; - - nodes.forEach((declaration) => { - if (declaration.prop === propertyName) { - propertyValue = declaration.value; - declaration.remove(); - } - }); - - return propertyValue; - }, -}; diff --git a/lib/core/lg-new-block.js b/lib/core/lg-new-block.js deleted file mode 100644 index cc47adc..0000000 --- a/lib/core/lg-new-block.js +++ /dev/null @@ -1,33 +0,0 @@ -module.exports = function newBlock(decl, selector, props, values) { - var completeSelector; - var block; - - function appendToSelectors(_thisSelector, selectorToAppend) { - var appendedSelectors = []; - - _thisSelector.split(',').forEach(function appendSelectorsFunction(item) { - appendedSelectors.push(item + selectorToAppend); - }); - - return appendedSelectors.join(','); - } - - completeSelector = appendToSelectors(decl.parent.selector, selector); - - block = decl.parent.cloneAfter({ - selector: completeSelector, - }); - - block.walkDecls(function removeDeclarationFunction(declaration) { - declaration.remove(); - }); - - props.forEach(function addRulesFunction(prop, i) { - var rule = decl.clone({ - prop: prop, - value: values[i].toString(), - }); - - block.append(rule); - }); -}; diff --git a/lib/core/lg-utilities.js b/lib/core/lg-utilities.js deleted file mode 100644 index d67fd4f..0000000 --- a/lib/core/lg-utilities.js +++ /dev/null @@ -1,111 +0,0 @@ -const testRgb = new RegExp(/rgb/); -//eslint-disable-next-line -const matchRgb = new RegExp(/rgba?\(([^\)]+)\)/); -const testHex = new RegExp(/#\w+/); - -/** - * Glues fraction members, meaning "1 / 6" becomes "1/6" - * @param {string} str - * @returns {string} - */ -const glueFractionMembers = function glueFractionMembers(str) { - return str.replace(/\s*\/\s*/, '/'); -}; - -/** - * Returns a three-member number array from a hex string - * @param hex - * @returns {number[]} - */ -const safeHexToRgb = function safeHexToRgb(hex) { - const value = hex.trim().split('#'); - var c = ['00', '00', '00']; - if (value.length === 1) { - c = value[0].split(''); - } - if (value.length === 2) { - c = value[1].split(''); - } - const l = c.length; - if (l === 3) return [hToD(c[0]), hToD(c[1]), hToD(c[2])]; - if (l === 4) return [hToD(c[0]), hToD(c[1]), hToD(c[2])]; - if (l === 6) return [hToD(c[0], c[1]), hToD(c[2], c[3]), hToD(c[4], c[5])]; - if (l === 8) return [hToD(c[0], c[1]), hToD(c[2], c[3]), hToD(c[4], c[5])]; - return [0, 0, 255]; -}; - -/** - * Returns a sanitized three-number array representing RGB color values, with a safe default. - * @param string - * @returns {number[]} - */ -const getColorValue = function getColorValue(string) { - if (testRgb.test(string)) { - return safeRgbToRgb(string); - } - if (testHex.test(string)) { - return safeHexToRgb(string); - } - return [0, 0, 255]; -}; - -/** - * Extracts the comma-separated numbers from a rgb(a?) string. - * @param string - * @returns {string} - */ -const extractRgbSubstring = function extractRgbSubstring(string) { - var candidate = string.match(matchRgb); - if ( - candidate && - candidate.length > 1 && - candidate[1].length > 0 && - typeof candidate[1] === 'string' - ) { - return candidate[1]; - } - return '0,0,255'; -}; - -/** - * Returns a base10 number from one or two hex digits - * @param h - * @returns {number} - */ -const hToD = function hToD(...h) { - var hh = '00'; - if (h.length === 1) { - hh = '' + h[0] + h[0]; - } else if (h.length === 2) { - hh = '' + h[0] + h[1]; - } - var d = parseInt(hh, 16); - return !isNaN(d) ? d : 0; -}; - -/** - * Returns a three-member number array from a rgb string - * @param rgb - * @returns {number[]} - */ -const safeRgbToRgb = function safeRgbToRgb(rgb) { - var value = extractRgbSubstring(rgb) - .split(',') - .map(function (a) { - var b = parseInt(a, 10); - return !isNaN(b) ? b : 0; - }); - if (value.length >= 3) { - return [value[0], value[1], value[2]]; - } - return [0, 0, 255]; -}; - -module.exports = { - getColorValue, - extractRgbSubstring, - hToD, - safeRgbToRgb, - safeHexToRgb, - glueFractionMembers, -}; diff --git a/lib/lost-gutter.js b/lib/lost-gutter.js deleted file mode 100644 index d6a0c76..0000000 --- a/lib/lost-gutter.js +++ /dev/null @@ -1,24 +0,0 @@ -var lostGutter = require('./lost-vars-gutter'); -var lostGutterLocal = require('./lost-vars-gutter-local'); - -module.exports = function lgGutter(css, settings) { - var gutter, newValue; - - css.walkDecls((declaration) => { - if ( - /(\$lost-gutter)/g.test(declaration.value) && - !/(\$lost-gutter-local)/g.test(declaration.value) - ) { - gutter = lostGutter(declaration, settings); - - newValue = declaration.value.replace(/(\$lost-gutter)/g, gutter); - declaration.value = newValue; - } - if (/(\$lost-gutter-local)/g.test(declaration.value)) { - gutter = lostGutterLocal(declaration, settings); - - newValue = declaration.value.replace(/(\$lost-gutter-local)/g, gutter); - declaration.value = newValue; - } - }); -}; diff --git a/lib/lost-vars-gutter.js b/lib/lost-vars-gutter.js deleted file mode 100644 index 938d1a9..0000000 --- a/lib/lost-vars-gutter.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = function lostVarsGutter(declaration, settings) { - return settings.gutter; -}; diff --git a/lib/lost-vars.js b/lib/lost-vars.js deleted file mode 100644 index 8a18926..0000000 --- a/lib/lost-vars.js +++ /dev/null @@ -1,50 +0,0 @@ -var lostGutter = require('./lost-vars-gutter'); -var lostGutterLocal = require('./lost-vars-gutter-local'); - -var variableFunctions = { - gutter: lostGutter, - 'gutter-local': lostGutterLocal, -}; - -module.exports = function lostVarsDecl(css, settings) { - css.walkDecls((declaration) => { - var value = declaration.value, - variables = [], - // eslint-disable-next-line - re = /lost\-vars\(\s?['"]([\w\-]+)['"]\s?\)/gi, - match = null; - - if (typeof value !== 'string' || value.indexOf('lost-vars(') === -1) { - return; - } - - while ((match = re.exec(value)) !== null) { - var variableFound = match[1].replace(/["']/g, ''); - - if (variables.indexOf(variableFound) === -1) { - variables.push(variableFound); - } - } - - variables.forEach((variable) => { - var func = variableFunctions[variable]; - - if (typeof func !== 'function') { - throw declaration.error( - `lost-vars: variable '${variable}' is unknown.` - ); - } - - var newValue = func(declaration, settings); - var replaceRegex = new RegExp( - // eslint-disable-next-line - `lost-vars\\(\s?['"]${variable}['"]\s?\\)`, - 'gi' - ); - - value = value.replace(replaceRegex, newValue); - }); - - declaration.value = value; - }); -}; diff --git a/lost.js b/lost.js deleted file mode 100644 index 80b180d..0000000 --- a/lost.js +++ /dev/null @@ -1,62 +0,0 @@ -// Module dependencies - -const lostAlign = require('./lib/lost-align'); -const lostAtRule = require('./lib/lost-at-rule'); -const lostCenter = require('./lib/lost-center'); -const lostColumn = require('./lib/lost-column'); -const lostFlexContainer = require('./lib/lost-flex-container'); -const lostGutter = require('./lib/lost-gutter'); -const lostMasonryColumn = require('./lib/lost-masonry-column'); -const lostMasonryWrap = require('./lib/lost-masonry-wrap'); -const lostMove = require('./lib/lost-move'); -const lostOffset = require('./lib/lost-offset'); -const lostRow = require('./lib/lost-row'); -const lostUtility = require('./lib/lost-utility'); -const lostVars = require('./lib/lost-vars'); -const lostWaffle = require('./lib/lost-waffle'); - -// NOTE: Order Matters -const libs = [ - lostVars, - lostGutter, - lostMove, - lostUtility, - lostFlexContainer, - lostCenter, - lostAlign, - lostColumn, - lostRow, - lostWaffle, - lostOffset, - lostMasonryWrap, - lostMasonryColumn, -]; - -const defaultSettings = { - gutter: '30px', - flexbox: 'no-flex', - cycle: 'auto', - clearing: 'both', - rounder: 99.9, - gridUnit: '%', - direction: 'ltr', -}; - -module.exports = (settings = {}) => { - return { - postcssPlugin: 'lost', - prepare() { - const runSettings = { ...defaultSettings, ...settings }; - return { - AtRule(atRule) { - lostAtRule(atRule, runSettings); - }, - OnceExit(css, { result }) { - libs.forEach((lib) => lib(css, runSettings, result)); - }, - }; - }, - }; -}; - -module.exports.postcss = true; diff --git a/package-lock.json b/package-lock.json index 7befb57..aa6678e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,8 @@ "version": "9.0.1", "license": "MIT", "devDependencies": { + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", "c8": "^7.13.0", "chai": "^4.3.6", "clean-css": "^5.3.0", @@ -18,11 +20,14 @@ "husky": "^8.0.0", "lint-staged": "^12.4.2", "mocha": "^10.0.0", + "nodemon": "^3.0.1", "postcss": "^8.4.14", "postcss-preset-env": "^7.6.0", "prettier": "^2.6.2", "pretty-quick": "^3.1.3", - "release-it": "^16.1.5" + "release-it": "^16.1.5", + "ts-node": "^10.9.1", + "typescript": "^5.1.6" }, "peerDependencies": { "postcss": "^8.4.14" @@ -116,6 +121,28 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@csstools/postcss-cascade-layers": { "version": "1.0.2", "dev": true, @@ -691,6 +718,36 @@ "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==", "dev": true }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, + "node_modules/@types/chai": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.5.tgz", + "integrity": "sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==", + "dev": true + }, "node_modules/@types/http-cache-semantics": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz", @@ -708,11 +765,30 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/mocha": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz", + "integrity": "sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==", + "dev": true + }, + "node_modules/@types/node": { + "version": "20.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.0.tgz", + "integrity": "sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==", + "dev": true, + "peer": true + }, "node_modules/@ungap/promise-all-settled": { "version": "1.1.2", "dev": true, "license": "ISC" }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, "node_modules/acorn": { "version": "8.7.1", "dev": true, @@ -732,6 +808,15 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "dev": true, @@ -864,6 +949,12 @@ "node": ">= 8" } }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "1.0.10", "dev": true, @@ -1785,6 +1876,12 @@ "url": "https://github.com/sponsors/d-fischer" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-spawn": { "version": "7.0.3", "dev": true, @@ -3450,6 +3547,12 @@ "node": ">= 4" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, "node_modules/ignore-walk": { "version": "3.0.4", "dev": true, @@ -4844,6 +4947,12 @@ "semver": "bin/semver.js" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/merge-stream": { "version": "2.0.0", "dev": true, @@ -5295,6 +5404,58 @@ "dev": true, "license": "MIT" }, + "node_modules/nodemon": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.1.tgz", + "integrity": "sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^3.2.7", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "dev": true, @@ -6625,6 +6786,12 @@ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", "dev": true }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, "node_modules/pump": { "version": "3.0.0", "dev": true, @@ -7301,6 +7468,18 @@ "dev": true, "license": "ISC" }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/slash": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", @@ -7699,11 +7878,75 @@ "node": ">=8.0" } }, + "node_modules/touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "dev": true, + "dependencies": { + "nopt": "~1.0.10" + }, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, "node_modules/tr46": { "version": "0.0.3", "dev": true, "license": "MIT" }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/tslib": { "version": "2.4.0", "dev": true, @@ -7750,6 +7993,19 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/typescript": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -7765,6 +8021,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, "node_modules/unique-string": { "version": "3.0.0", "dev": true, @@ -7880,6 +8142,12 @@ "dev": true, "license": "MIT" }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/v8-to-istanbul": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", @@ -8159,6 +8427,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "dev": true, diff --git a/package.json b/package.json index d178373..6b7cacd 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "lost", "version": "9.0.1", "description": "LostGrid is a powerful grid system built in PostCSS that works with any preprocessor and even vanilla CSS.", - "main": "lost.js", + "main": "dist/index.js", "repository": { "type": "git", "url": "https://github.com/peterramsing/lost.git" @@ -21,6 +21,8 @@ }, "homepage": "http://lostgrid.org", "devDependencies": { + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", "c8": "^7.13.0", "chai": "^4.3.6", "clean-css": "^5.3.0", @@ -30,22 +32,27 @@ "husky": "^8.0.0", "lint-staged": "^12.4.2", "mocha": "^10.0.0", + "nodemon": "^3.0.1", "postcss": "^8.4.14", "postcss-preset-env": "^7.6.0", "prettier": "^2.6.2", "pretty-quick": "^3.1.3", - "release-it": "^16.1.5" + "release-it": "^16.1.5", + "ts-node": "^10.9.1", + "typescript": "^5.1.6" }, "peerDependencies": { "postcss": "^8.4.14" }, "scripts": { - "test": "c8 mocha", + "test": "c8 mocha test/*.js --require ts-node/register", + "test-specific": "c8 mocha --require ts-node/register --grep", "reset--node": "rm -rf node_modules && npm install", "dev": "c8 mocha --watch", "lint": "eslint .", "report-coverage": "c8 report --reporter=text-lcov > coverage.lcov && codecov", "prepare": "husky install", + "start": "nodemon --watch 'src/**/*.ts' --exec 'tsc -p .'", "release": "release-it" } } diff --git a/src/core/lg-logic.ts b/src/core/lg-logic.ts new file mode 100644 index 0000000..e5d3110 --- /dev/null +++ b/src/core/lg-logic.ts @@ -0,0 +1,43 @@ +const calcValue = ( + fraction: string, + gutter: number | string = '0', //FIXME: this should be a number + rounder: number, + unit: string = '%' +): string => { + let calcValue = ''; + let gutterLogic = ''; + + if (gutter !== '0') { + gutterLogic = ` - (${gutter} - ${gutter} * ${fraction})`; + } + + calcValue = `calc(${rounder}${unit} * ${fraction}${gutterLogic})`; + return calcValue; +}; + +const parseLostProperty = ( + nodes: any, + propertyName: string, + defaultPropertyValue: any +): any => { + let propertyValue = defaultPropertyValue; + + nodes.forEach((declaration: any) => { + if (declaration.prop === propertyName) { + propertyValue = declaration.value; + declaration.remove(); + } + }); + + return propertyValue; +}; + +const validateUnit = (value: string, validUnits: string[]): boolean => { + return validUnits.includes(value); +}; + +export const lgLogic = { + calcValue, + parseLostProperty, + validateUnit, +}; diff --git a/src/core/lg-new-block.ts b/src/core/lg-new-block.ts new file mode 100644 index 0000000..48848d6 --- /dev/null +++ b/src/core/lg-new-block.ts @@ -0,0 +1,42 @@ +export const newBlock = ( + decl: any, + selector: any, + props: any[], + values: any +) => { + let completeSelector: any; + let block: any; + + function appendToSelectors(_thisSelector: string, selectorToAppend: any) { + let appendedSelectors: any[] = []; + + _thisSelector + .split(',') + .forEach(function appendSelectorsFunction(item: any) { + appendedSelectors.push(item + selectorToAppend); + }); + + return appendedSelectors.join(','); + } + + completeSelector = appendToSelectors(decl.parent.selector, selector); + + block = decl.parent.cloneAfter({ + selector: completeSelector, + }); + + block.walkDecls(function removeDeclarationFunction(declaration: { + remove: () => void; + }) { + declaration.remove(); + }); + + props.forEach(function addRulesFunction(prop: any, i: string | number) { + var rule = decl.clone({ + prop: prop, + value: values[i].toString(), + }); + + block.append(rule); + }); +}; diff --git a/src/core/lg-utilities.ts b/src/core/lg-utilities.ts new file mode 100644 index 0000000..a35ae9e --- /dev/null +++ b/src/core/lg-utilities.ts @@ -0,0 +1,90 @@ +const testRgb = /rgb/; +const matchRgb = /rgba?\(([^\)]+)\)/; +const testHex = /#\w+/; + +/** + * Glues fraction members, meaning "1 / 6" becomes "1/6" + */ +const glueFractionMembers = (str: string): string => + str.replace(/\s*\/\s*/, '/'); + +/** + * Returns a base10 number from one or two hex digits + */ +const hToD = function hToD(...h: (string | number)[]): number { + var hh = '00'; + if (h.length === 1) { + hh = '' + h[0] + h[0]; + } else if (h.length === 2) { + hh = '' + h[0] + h[1]; + } + var d = parseInt(hh, 16); + return !isNaN(d) ? d : 0; +}; + +/** + * Extracts the comma-separated numbers from a rgb(a?) string. + */ +const extractRgbSubstring = (string: string): string => { + const candidate = string.match(matchRgb); + if (candidate && typeof candidate[1] === 'string' && candidate[1].length) { + return candidate[1]; + } + return '0,0,255'; +}; + +/** + * Returns a three-member number array from a hex string + */ +const safeHexToRgb = (hex: string): number[] => { + const value = hex.trim().split('#'); + const c = value.length === 1 ? value[0].split('') : value[1].split(''); + const l = c.length; + + switch (l) { + case 3: + case 4: + return [hToD(c[0]), hToD(c[1]), hToD(c[2])]; + case 6: + case 8: + return [hToD(c[0], c[1]), hToD(c[2], c[3]), hToD(c[4], c[5])]; + default: + return [0, 0, 255]; + } +}; + +/** + * Returns a three-member number array from a rgb string + */ +const safeRgbToRgb = (rgb: string): number[] => { + const values = extractRgbSubstring(rgb) + .split(',') + .map((a) => { + const b = parseInt(a, 10); + return isNaN(b) ? 0 : b; + }); + + if (values.length >= 3) { + return [values[0], values[1], values[2]]; + } + + return [0, 0, 255]; +}; + +/** + * Returns a sanitized three-number array representing RGB color values, with a safe default. + */ +const getColorValue = (string: string): number[] => { + if (testRgb.test(string)) return safeRgbToRgb(string); + if (testHex.test(string)) return safeHexToRgb(string); + return [0, 0, 255]; +}; + +export const lgUtils = { + getColorValue, + extractRgbSubstring, + hToD, + safeRgbToRgb, + safeHexToRgb, + glueFractionMembers, +}; diff --git a/lib/lost-align.js b/src/lost-align.ts similarity index 98% rename from lib/lost-align.js rename to src/lost-align.ts index e6e9025..b6b05ba 100644 --- a/lib/lost-align.js +++ b/src/lost-align.ts @@ -1,7 +1,7 @@ -var newBlock = require('./core/lg-new-block.js'); +import { newBlock } from './core/lg-new-block'; -module.exports = function lostAlign(css, settings) { - css.walkDecls('lost-align', function alignDirectionFunction(decl) { +export const lostAlign = (css: any, settings: any) => { + css.walkDecls('lost-align', function alignDirectionFunction(decl: any) { var declArr = []; var alignDirection; var flexbox = settings.flexbox; diff --git a/lib/lost-at-rule.js b/src/lost-at-rule.ts similarity index 93% rename from lib/lost-at-rule.js rename to src/lost-at-rule.ts index 28ce81b..21b85ce 100644 --- a/lib/lost-at-rule.js +++ b/src/lost-at-rule.ts @@ -1,4 +1,4 @@ -module.exports = function lostAtRule(rule, settings) { +export const lostAtRule = (rule: any, settings: any) => { if (rule.name != 'lost') { return; } diff --git a/lib/lost-center.js b/src/lost-center.ts similarity index 89% rename from lib/lost-center.js rename to src/lost-center.ts index cecd92d..57de631 100644 --- a/lib/lost-center.js +++ b/src/lost-center.ts @@ -1,10 +1,9 @@ -var newBlock = require('./core/lg-new-block.js'); +import { newBlock } from './core/lg-new-block'; +import { lgLogic } from './core/lg-logic'; +import { lgUtils } from './core/lg-utilities'; -var lgLogic = require('./core/lg-logic'); -var lgUtils = require('./core/lg-utilities'); - -module.exports = function lostCenterDecl(css, settings, result) { - css.walkDecls('lost-center', function lostCenterFunction(decl) { +export const lostCenter = (css: any, settings: any, result: any) => { + css.walkDecls('lost-center', function lostCenterFunction(decl: any) { var declArr = []; var lostCenterPadding; var lostCenterMaxWidth; @@ -14,7 +13,7 @@ module.exports = function lostCenterDecl(css, settings, result) { var lostColumnGutter = 0; var validUnits = ['%', 'vw']; - var isFractionValue = (value) => { + var isFractionValue = (value: any) => { var lostFractionPattern = /^\d+\/\d+$/; return lostFractionPattern.test(value); }; diff --git a/lib/lost-column.js b/src/lost-column.ts similarity index 94% rename from lib/lost-column.js rename to src/lost-column.ts index e3dc557..fa53455 100644 --- a/lib/lost-column.js +++ b/src/lost-column.ts @@ -1,10 +1,9 @@ -var newBlock = require('./core/lg-new-block.js'); +import { newBlock } from './core/lg-new-block'; +import { lgLogic } from './core/lg-logic'; +import { lgUtils } from './core/lg-utilities'; -var lgLogic = require('./core/lg-logic'); -var lgUtils = require('./core/lg-utilities'); - -module.exports = function lostColumnDecl(css, settings, result) { - css.walkDecls('lost-column', function lostColumnFunction(decl) { +export const lostColumn = (css: any, settings: any, result: any) => { + css.walkDecls('lost-column', function lostColumnFunction(decl: any) { var declArr = []; var gridDirection = settings.direction; var lostColumn; @@ -50,7 +49,9 @@ module.exports = function lostColumnDecl(css, settings, result) { lostColumnFlexbox = 'no-flex'; } - decl.parent.nodes.forEach(function lostColumnCycleFunction(declaration) { + decl.parent.nodes.forEach(function lostColumnCycleFunction( + declaration: any + ) { if (declaration.prop === 'lost-column-cycle') { lostColumnCycle = declaration.value; @@ -61,7 +62,7 @@ module.exports = function lostColumnDecl(css, settings, result) { // Converts the cycle to an integer so that checks on whether it's 0 make sense lostColumnCycle = parseInt(lostColumnCycle); - decl.parent.nodes.forEach((declaration) => { + decl.parent.nodes.forEach((declaration: any) => { if (declaration.prop === 'lost-unit') { if (lgLogic.validateUnit(declaration.value, validUnits)) { unit = declaration.value; @@ -76,7 +77,7 @@ module.exports = function lostColumnDecl(css, settings, result) { }); decl.parent.nodes.forEach(function lostColumnRounderFunction( - declaration + declaration: any ) { if (declaration.prop === 'lost-column-rounder') { lostColumnRounder = declaration.value; @@ -85,7 +86,9 @@ module.exports = function lostColumnDecl(css, settings, result) { } }); - decl.parent.nodes.forEach(function lostColumnGutterFunction(declaration) { + decl.parent.nodes.forEach(function lostColumnGutterFunction( + declaration: any + ) { if (declaration.prop === 'lost-column-gutter') { lostColumnGutter = declaration.value; @@ -94,7 +97,7 @@ module.exports = function lostColumnDecl(css, settings, result) { }); decl.parent.nodes.forEach(function lostColumnFlexboxFunction( - declaration + declaration: any ) { if (declaration.prop === 'lost-column-flexbox') { if (declaration.value === 'flex') { @@ -269,7 +272,7 @@ module.exports = function lostColumnDecl(css, settings, result) { ), }); } else { - decl.parent.nodes.forEach((declaration) => { + decl.parent.nodes.forEach((declaration: any) => { if (declaration.prop === 'lost-column-flexbox') { if (declaration.value === 'flex') { lostColumnFlexbox = 'flex'; diff --git a/lib/lost-flex-container.js b/src/lost-flex-container.ts similarity index 80% rename from lib/lost-flex-container.js rename to src/lost-flex-container.ts index cde12d6..305d4c1 100644 --- a/lib/lost-flex-container.js +++ b/src/lost-flex-container.ts @@ -1,7 +1,7 @@ -module.exports = function lostFlexContainerDecl(css) { +export const lostFlexContainer = (css: any) => { css.walkDecls( 'lost-flex-container', - function lostFlexContainerFunction(decl) { + function lostFlexContainerFunction(decl: any) { decl.cloneBefore({ prop: 'display', value: 'flex', diff --git a/src/lost-gutter.ts b/src/lost-gutter.ts new file mode 100644 index 0000000..b6f15aa --- /dev/null +++ b/src/lost-gutter.ts @@ -0,0 +1,44 @@ +import { lostVarsGutterLocal } from './lost-vars-gutter-local'; +import { lostVarsGutter } from './lost-vars-gutter'; + +export const lostGutter = (css: any, settings: any) => { + var gutter, newValue; + + console.log(css, 'css'); + + css.walkDecls((declaration: any) => { + if ( + /(\$lost-gutter)/g.test(declaration.value) && + !/(\$lost-gutter-local)/g.test(declaration.value) + ) { + gutter = lostVarsGutter(settings); + + newValue = declaration.value.replace(/(\$lost-gutter)/g, gutter); + declaration.value = newValue; + } + if (/(\$lost-gutter-local)/g.test(declaration.value)) { + gutter = lostVarsGutterLocal(declaration, settings); + + newValue = declaration.value.replace(/(\$lost-gutter-local)/g, gutter); + declaration.value = newValue; + } + }); +}; + +// css.walkDecls((declaration) => { +// if ( +// /(\$lost-gutter)/g.test(declaration.value) && +// !/(\$lost-gutter-local)/g.test(declaration.value) +// ) { +// gutter = lostGutter(declaration, settings); + +// newValue = declaration.value.replace(/(\$lost-gutter)/g, gutter); +// declaration.value = newValue; +// } +// if (/(\$lost-gutter-local)/g.test(declaration.value)) { +// gutter = lostGutterLocal(declaration, settings); + +// newValue = declaration.value.replace(/(\$lost-gutter-local)/g, gutter); +// declaration.value = newValue; +// } +// }); diff --git a/lib/lost-masonry-column.js b/src/lost-masonry-column.ts similarity index 91% rename from lib/lost-masonry-column.js rename to src/lost-masonry-column.ts index e0bb382..53177eb 100644 --- a/lib/lost-masonry-column.js +++ b/src/lost-masonry-column.ts @@ -1,9 +1,9 @@ -var lgUtils = require('./core/lg-utilities'); +import { lgUtils } from './core/lg-utilities'; -module.exports = function lostMasonryColumnDecl(css, settings) { +export const lostMasonryColumn = (css: any, settings: any) => { css.walkDecls( 'lost-masonry-column', - function lostMasonryColumnFunction(decl) { + function lostMasonryColumnFunction(decl: any) { var declArr = []; var lostMasonryColumn; var lostMasonryColumnRounder = settings.rounder; @@ -11,7 +11,7 @@ module.exports = function lostMasonryColumnDecl(css, settings) { var lostMasonryColumnGutter = settings.gutter; var lostMasonryColumnGutterUnit; - function cloneAllBefore(props) { + function cloneAllBefore(props: any) { Object.keys(props).forEach(function traverseProps(prop) { decl.cloneBefore({ prop: prop, @@ -37,7 +37,7 @@ module.exports = function lostMasonryColumnDecl(css, settings) { } decl.parent.nodes.forEach(function lostMasonryColumnRounderFunction( - declaration + declaration: any ) { if (declaration.prop === 'lost-masonry-column-rounder') { lostMasonryColumnRounder = declaration.value; @@ -47,7 +47,7 @@ module.exports = function lostMasonryColumnDecl(css, settings) { }); decl.parent.nodes.forEach(function lostMasonryColumnGutterFunction( - declaration + declaration: any ) { if (declaration.prop === 'lost-masonry-column-gutter') { lostMasonryColumnGutter = declaration.value; @@ -56,7 +56,7 @@ module.exports = function lostMasonryColumnDecl(css, settings) { } }); decl.parent.nodes.forEach(function lostMasonryColumnFlexboxFunction( - declaration + declaration: any ) { if (declaration.prop === 'lost-masonry-column-flexbox') { if (declaration.value === 'flex') { diff --git a/lib/lost-masonry-wrap.js b/src/lost-masonry-wrap.ts similarity index 89% rename from lib/lost-masonry-wrap.js rename to src/lost-masonry-wrap.ts index c905beb..7ffd2d4 100644 --- a/lib/lost-masonry-wrap.js +++ b/src/lost-masonry-wrap.ts @@ -1,15 +1,15 @@ -var newBlock = require('./core/lg-new-block.js'); +import { newBlock } from './core/lg-new-block'; -module.exports = function lostMasonryWrapDecl(css, settings) { +export const lostMasonryWrap = (css: any, settings: any) => { css.walkDecls( 'lost-masonry-wrap', - function lostMasonryWrapDeclFunction(decl) { + function lostMasonryWrapDeclFunction(decl: any) { var declArr = []; var lostMasonryWrapFlexbox = settings.flexbox; var lostMasonryWrapGutter = settings.gutter; var lostMasonryWrapGutterUnit; - function cloneAllBefore(props) { + function cloneAllBefore(props: any) { Object.keys(props).forEach(function traverseProps(prop) { decl.cloneBefore({ prop: prop, @@ -40,7 +40,7 @@ module.exports = function lostMasonryWrapDecl(css, settings) { } decl.parent.nodes.forEach(function lostMasonryWrapFlexboxFunction( - declaration + declaration: any ) { if (declaration.prop === 'lost-masonry-wrap-flexbox') { if (declaration.value === 'flex') { @@ -51,7 +51,9 @@ module.exports = function lostMasonryWrapDecl(css, settings) { } }); - decl.parent.nodes.forEach(function lostMasonryWrapFunction(declaration) { + decl.parent.nodes.forEach(function lostMasonryWrapFunction( + declaration: any + ) { if (declaration.prop === 'lost-masonry-wrap-gutter') { lostMasonryWrapGutter = declaration.value; declaration.remove(); diff --git a/lib/lost-move.js b/src/lost-move.ts similarity index 85% rename from lib/lost-move.js rename to src/lost-move.ts index 17ab5f4..dcfeaf2 100644 --- a/lib/lost-move.js +++ b/src/lost-move.ts @@ -1,7 +1,7 @@ -var lgUtils = require('./core/lg-utilities'); +import { lgUtils } from './core/lg-utilities'; -module.exports = function lostMoveDecl(css, settings) { - css.walkDecls('lost-move', function lostMoveDeclFunction(decl) { +export const lostMove = (css: any, settings: any) => { + css.walkDecls('lost-move', function lostMoveDeclFunction(decl: any) { var declArr = []; var lostMove; var lostMoveDirection; @@ -19,7 +19,9 @@ module.exports = function lostMoveDecl(css, settings) { lostMoveDirection = declArr[1]; } - decl.parent.nodes.forEach(function lostMoveRounderFunction(declaration) { + decl.parent.nodes.forEach(function lostMoveRounderFunction( + declaration: any + ) { if (declaration.prop === 'lost-move-rounder') { lostMoveRounder = declaration.value; @@ -27,7 +29,7 @@ module.exports = function lostMoveDecl(css, settings) { } }); - decl.parent.nodes.forEach((declaration) => { + decl.parent.nodes.forEach((declaration: any) => { if (declaration.prop === 'lost-column') { var columnArray = declaration.value.split(' '); if (columnArray[2]) { @@ -39,7 +41,7 @@ module.exports = function lostMoveDecl(css, settings) { } }); - decl.parent.nodes.forEach((declaration) => { + decl.parent.nodes.forEach((declaration: any) => { if (declaration.prop === 'lost-row') { var rowArray = declaration.value.split(' '); if (rowArray[1]) { @@ -55,7 +57,9 @@ module.exports = function lostMoveDecl(css, settings) { lostMoveGutter = declArr[2]; } - decl.parent.nodes.forEach(function lostMoveDirectionFunction(declaration) { + decl.parent.nodes.forEach(function lostMoveDirectionFunction( + declaration: any + ) { if (declaration.prop === 'lost-move-direction') { lostMoveDirection = declaration.value; @@ -63,7 +67,9 @@ module.exports = function lostMoveDecl(css, settings) { } }); - decl.parent.nodes.forEach(function lostMoveGutterFunction(declaration) { + decl.parent.nodes.forEach(function lostMoveGutterFunction( + declaration: any + ) { if (declaration.prop === 'lost-move-gutter') { lostMoveGutter = declaration.value; diff --git a/lib/lost-offset.js b/src/lost-offset.ts similarity index 92% rename from lib/lost-offset.js rename to src/lost-offset.ts index b0114a3..de5d05b 100644 --- a/lib/lost-offset.js +++ b/src/lost-offset.ts @@ -1,15 +1,15 @@ -var lgUtils = require('./core/lg-utilities'); +import { lgUtils } from './core/lg-utilities'; -module.exports = function lostOffsetDecl(css, settings) { - css.walkDecls('lost-offset', function lostOffsetDeclFunction(decl) { - var declArr = []; - var lostOffset; - var lostOffsetNumerator; - var lostOffsetDirection; - var lostOffsetRounder = settings.rounder; - var lostOffsetGutter = settings.gutter; +export const lostOffset = (css: any, settings: any) => { + css.walkDecls('lost-offset', function lostOffsetDeclFunction(decl: any) { + let declArr = []; + let lostOffset: any; + let lostOffsetNumerator: any; + let lostOffsetDirection: any; + let lostOffsetRounder = settings.rounder; + let lostOffsetGutter = settings.gutter; - function cloneAllBefore(props) { + function cloneAllBefore(props: any) { Object.keys(props).forEach(function traverseProps(prop) { decl.cloneBefore({ prop: prop, @@ -34,7 +34,9 @@ module.exports = function lostOffsetDecl(css, settings) { lostOffsetGutter = declArr[2]; } - decl.parent.nodes.forEach(function lostOffsetRounderFunction(declaration) { + decl.parent.nodes.forEach(function lostOffsetRounderFunction( + declaration: any + ) { if (declaration.prop === 'lost-offset-rounder') { lostOffsetRounder = declaration.value; @@ -43,7 +45,7 @@ module.exports = function lostOffsetDecl(css, settings) { }); decl.parent.nodes.forEach(function lostOffsetDirectionFunction( - declaration + declaration: any ) { if (declaration.prop === 'lost-offset-direction') { lostOffsetDirection = declaration.value; @@ -52,7 +54,9 @@ module.exports = function lostOffsetDecl(css, settings) { } }); - decl.parent.nodes.forEach(function lostOffsetGutterFunction(declaration) { + decl.parent.nodes.forEach(function lostOffsetGutterFunction( + declaration: any + ) { if (declaration.prop === 'lost-offset-gutter') { lostOffsetGutter = declaration.value; diff --git a/lib/lost-row.js b/src/lost-row.ts similarity index 85% rename from lib/lost-row.js rename to src/lost-row.ts index c53b048..7e9f557 100644 --- a/lib/lost-row.js +++ b/src/lost-row.ts @@ -1,10 +1,9 @@ -var newBlock = require('./core/lg-new-block.js'); +import { newBlock } from './core/lg-new-block'; +import { lgLogic } from './core/lg-logic'; +import { lgUtils } from './core/lg-utilities'; -var lgLogic = require('./core/lg-logic'); -var lgUtils = require('./core/lg-utilities'); - -module.exports = function lostRowDecl(css, settings, result) { - css.walkDecls('lost-row', function lostRowDeclFunction(decl) { +export const lostRow = (css: any, settings: any, result: any) => { + css.walkDecls('lost-row', function lostRowDeclFunction(decl: any) { var declArr = []; var lostRow; var unit = settings.gridUnit; @@ -30,7 +29,9 @@ module.exports = function lostRowDecl(css, settings, result) { lostRowFlexbox = 'no-flex'; } - decl.parent.nodes.forEach(function lostRowRounderFunction(declaration) { + decl.parent.nodes.forEach(function lostRowRounderFunction( + declaration: any + ) { if (declaration.prop === 'lost-row-rounder') { lostRowRounder = declaration.value; @@ -38,7 +39,9 @@ module.exports = function lostRowDecl(css, settings, result) { } }); - decl.parent.nodes.forEach(function lostRowGutterFunction(declaration) { + decl.parent.nodes.forEach(function lostRowGutterFunction( + declaration: any + ) { if (declaration.prop === 'lost-row-gutter') { lostRowGutter = declaration.value; @@ -46,7 +49,9 @@ module.exports = function lostRowDecl(css, settings, result) { } }); - decl.parent.nodes.forEach(function lostRowFlexboxFunction(declaration) { + decl.parent.nodes.forEach(function lostRowFlexboxFunction( + declaration: any + ) { if (declaration.prop === 'lost-row-flexbox') { if (declaration.value === 'flex') { lostRowFlexbox = 'flex'; @@ -56,7 +61,7 @@ module.exports = function lostRowDecl(css, settings, result) { } }); - decl.parent.nodes.forEach((declaration) => { + decl.parent.nodes.forEach((declaration: any) => { if (declaration.prop === 'lost-unit') { if (lgLogic.validateUnit(declaration.value, validUnits)) { unit = declaration.value; diff --git a/lib/lost-utility.js b/src/lost-utility.ts similarity index 82% rename from lib/lost-utility.js rename to src/lost-utility.ts index 3f1b785..39a218d 100644 --- a/lib/lost-utility.js +++ b/src/lost-utility.ts @@ -1,29 +1,28 @@ -var newBlock = require('./core/lg-new-block.js'); -var getColorValue = require('./core/lg-utilities').getColorValue; +import { newBlock } from './core/lg-new-block'; +import { lgUtils } from './core/lg-utilities'; -function unitsMatch() { - var args = Array.prototype.slice.call(arguments, 0); - var re = /(px|%|em|rem|vh|vw)$/gi; - var extension = args[0].match(re).toString(); - var matched = true; +const unitsMatch = (...args: any) => { + let re = /(px|%|em|rem|vh|vw)$/gi; + let extension = args[0].match(re).toString(); + let matched = true; - args.forEach(function compareExtension(arg) { + args.forEach(function compareExtension(arg: any) { if (arg.match(re).toString() !== extension) { matched = false; } }); return matched; -} +}; -module.exports = function lostUtilityDecl(css) { - css.walkDecls('lost-utility', function lostUtilityDeclFunction(decl) { - var utilityArray = decl.value.split(' '); - var utility = utilityArray[0]; - var color; +export const lostUtility = (css: any) => { + css.walkDecls('lost-utility', function lostUtilityDeclFunction(decl: any) { + let utilityArray = decl.value.split(' '); + let utility = utilityArray[0]; + let color; if (utility === 'edit') { if (utilityArray[1]) { - color = getColorValue(decl.value); + color = lgUtils.getColorValue(decl.value); newBlock( decl, @@ -53,7 +52,7 @@ module.exports = function lostUtilityDecl(css) { } if (utility === 'overlay') { - var maxWidth = utilityArray[1] || '1024px', + let maxWidth = utilityArray[1] || '1024px', numCols = utilityArray[2] || 12, gutter = utilityArray[3] || '20px', totalGutter = parseFloat(gutter) * (numCols - 1), @@ -75,7 +74,7 @@ module.exports = function lostUtilityDecl(css) { ); } - for (var i = 1; i < numCols; i++) { + for (let i = 1; i < numCols; i++) { // Start of color column gradient = gradient + color + ' ' + position + '%, '; diff --git a/lib/lost-vars-gutter-local.js b/src/lost-vars-gutter-local.ts similarity index 87% rename from lib/lost-vars-gutter-local.js rename to src/lost-vars-gutter-local.ts index 05a2e03..b55bf91 100644 --- a/lib/lost-vars-gutter-local.js +++ b/src/lost-vars-gutter-local.ts @@ -1,7 +1,7 @@ -module.exports = function lostVarsGutterLocal(declaration, settings) { +export const lostVarsGutterLocal = (declaration: any, settings: any) => { var newLocalValue = settings.gutter; - declaration.parent.nodes.forEach((parentDeclaration) => { + declaration.parent.nodes.forEach((parentDeclaration: any) => { var declarationArray = parentDeclaration.value.split(' '); if ( diff --git a/src/lost-vars-gutter.ts b/src/lost-vars-gutter.ts new file mode 100644 index 0000000..f6e03ac --- /dev/null +++ b/src/lost-vars-gutter.ts @@ -0,0 +1,3 @@ +export const lostVarsGutter = (settings: any) => { + return settings.gutter; +}; diff --git a/src/lost-vars.ts b/src/lost-vars.ts new file mode 100644 index 0000000..8c292f2 --- /dev/null +++ b/src/lost-vars.ts @@ -0,0 +1,61 @@ +import { lostGutter } from './lost-gutter'; +import { lostVarsGutterLocal } from './lost-vars-gutter-local'; + +export const lostVars = (css: any, settings: any) => { + let variableFunctions = { + gutter: lostGutter, + 'gutter-local': lostVarsGutterLocal, + }; + + css.walkDecls((declaration: any) => { + let value = declaration.value, + variables = [], + // eslint-disable-next-line + re = /lost\-vars\(\s?['"]([\w\-]+)['"]\s?\)/gi, + match = null; + + if (typeof value !== 'string' || value.indexOf('lost-vars(') === -1) { + return; + } + + while ((match = re.exec(value)) !== null) { + let variableFound = match[1].replace(/["']/g, ''); + + if (variables.indexOf(variableFound) === -1) { + variables.push(variableFound); + } + } + + variables.forEach((variable) => { + console.log(declaration, 'declaration'); + // @ts-ignore + let func = variableFunctions[variable]; + + if (typeof func !== 'function') { + throw declaration.error( + `lost-vars: variable '${variable}' is unknown.` + ); + } + let newValue; + if (variable === 'gutter-local') { + newValue = func(declaration, settings); + } else if (variable === 'gutter') { + newValue = func(css, settings); + } else { + throw declaration.error( + `lost-vars: variable '${variable}' is unknown.` + ); + } + + let replaceRegex = new RegExp( + // eslint-disable-next-line + `lost-vars\\(\s?['"]${variable}['"]\s?\\)`, + 'gi' + ); + + value = value.replace(replaceRegex, newValue); + }); + + declaration.value = value; + }); +}; diff --git a/lib/lost-waffle.js b/src/lost-waffle.ts similarity index 89% rename from lib/lost-waffle.js rename to src/lost-waffle.ts index 2203f30..0597103 100644 --- a/lib/lost-waffle.js +++ b/src/lost-waffle.ts @@ -1,22 +1,21 @@ -var newBlock = require('./core/lg-new-block.js'); - -var lgLogic = require('./core/lg-logic'); -var lgUtils = require('./core/lg-utilities'); - -module.exports = function lostWaffleDecl(css, settings) { - css.walkDecls('lost-waffle', function lostWaffleDeclFunction(decl) { - var declArr = []; - var gridDirection = settings.direction; - var lostWaffle; - var floatRight; - var lostWaffleCycle; - var unit = settings.gridUnit; - var lostWaffleRounder = settings.rounder; - var lostWaffleGutter = settings.gutter; - var lostWaffleFlexbox = settings.flexbox; - var validUnits = ['%', 'vh', 'vw']; - - function cloneAllBefore(props) { +import { newBlock } from './core/lg-new-block'; +import { lgLogic } from './core/lg-logic'; +import { lgUtils } from './core/lg-utilities'; + +export const lostWaffle = (css: any, settings: any) => { + css.walkDecls('lost-waffle', function lostWaffleDeclFunction(decl: any) { + let declArr = []; + let gridDirection = settings.direction; + let lostWaffle; + let floatRight; + let lostWaffleCycle; + let unit = settings.gridUnit; + let lostWaffleRounder = settings.rounder; + let lostWaffleGutter = settings.gutter; + let lostWaffleFlexbox = settings.flexbox; + let validUnits = ['%', 'vh', 'vw']; + + function cloneAllBefore(props: any) { Object.keys(props).forEach(function traverseProps(prop) { decl.cloneBefore({ prop: prop, @@ -63,14 +62,18 @@ module.exports = function lostWaffleDecl(css, settings) { floatRight = true; } - decl.parent.nodes.forEach(function lostWaffleRounderFunction(declaration) { + decl.parent.nodes.forEach(function lostWaffleRounderFunction( + declaration: any + ) { if (declaration.prop === 'lost-waffle-rounder') { lostWaffleRounder = declaration.value; declaration.remove(); } }); - decl.parent.nodes.forEach(function lostWaffleCycleFunction(declaration) { + decl.parent.nodes.forEach(function lostWaffleCycleFunction( + declaration: any + ) { if (declaration.prop === 'lost-waffle-cycle') { lostWaffleCycle = declaration.value; @@ -81,7 +84,9 @@ module.exports = function lostWaffleDecl(css, settings) { // Converts the cycle to an integer so that checks on whether it's 0 make sense lostWaffleCycle = parseInt(lostWaffleCycle); - decl.parent.nodes.forEach(function lostWaffleGutterFunction(declaration) { + decl.parent.nodes.forEach(function lostWaffleGutterFunction( + declaration: any + ) { if (declaration.prop === 'lost-waffle-gutter') { lostWaffleGutter = declaration.value; @@ -89,7 +94,7 @@ module.exports = function lostWaffleDecl(css, settings) { } }); - decl.parent.nodes.forEach((declaration) => { + decl.parent.nodes.forEach((declaration: any) => { if (declaration.prop === 'lost-unit') { if (lgLogic.validateUnit(declaration.value, validUnits)) { unit = declaration.value; @@ -102,7 +107,9 @@ module.exports = function lostWaffleDecl(css, settings) { } }); - decl.parent.nodes.forEach(function lostWaffleFlexboxFunction(declaration) { + decl.parent.nodes.forEach(function lostWaffleFlexboxFunction( + declaration: any + ) { if (declaration.prop === 'lost-waffle-flexbox') { if (declaration.value === 'flex') { lostWaffleFlexbox = 'flex'; diff --git a/src/lost.ts b/src/lost.ts new file mode 100644 index 0000000..1400233 --- /dev/null +++ b/src/lost.ts @@ -0,0 +1,63 @@ +// Module dependencies + +import { AtRule } from 'postcss'; +import { lostAlign } from './lost-align'; +import { lostAtRule } from './lost-at-rule'; +import { lostColumn } from './lost-column'; +import { lostCenter } from './lost-center'; +import { lostFlexContainer } from './lost-flex-container'; +import { lostGutter } from './lost-gutter'; +import { lostMasonryColumn } from './lost-masonry-column'; +import { lostMasonryWrap } from './lost-masonry-wrap'; +import { lostMove } from './lost-move'; +import { lostRow } from './lost-row'; +import { lostOffset } from './lost-offset'; +import { lostUtility } from './lost-utility'; +import { lostVars } from './lost-vars'; +import { lostWaffle } from './lost-waffle'; + +// NOTE: Order Matters +const libs = [ + lostVars, + lostGutter, + lostMove, + lostUtility, + lostFlexContainer, + lostCenter, + lostAlign, + lostColumn, + lostRow, + lostWaffle, + lostOffset, + lostMasonryWrap, + lostMasonryColumn, +]; + +const defaultSettings = { + gutter: '30px', + flexbox: 'no-flex', + cycle: 'auto', + clearing: 'both', + rounder: 99.9, + gridUnit: '%', + direction: 'ltr', +}; + +export const lost = (settings = {}) => { + return { + postcssPlugin: 'lost', + prepare() { + const runSettings = { ...defaultSettings, ...settings }; + return { + AtRule(atRule: AtRule) { + lostAtRule(atRule, runSettings); + }, + OnceExit(css: any, { result }: any) { + libs.forEach((lib) => lib(css, runSettings, result)); + }, + }; + }, + }; +}; + +// module.exports.postcss = true; diff --git a/test/check.js b/test/check.js index 0b5733d..615b675 100644 --- a/test/check.js +++ b/test/check.js @@ -1,7 +1,7 @@ 'use strict'; const expect = require('chai').expect; -const lost = require('../lost'); +const { lost } = require('../dist/lost'); const cleanCss = require('clean-css'); const postcss = require('postcss'); diff --git a/test/lg-logic.js b/test/lg-logic.js index cb34977..ed03850 100644 --- a/test/lg-logic.js +++ b/test/lg-logic.js @@ -1,73 +1,75 @@ 'use strict'; var expect = require('chai').expect; -var lgLogic = require('../lib/core/lg-logic.js'); +var { lgLogic } = require('../dist/core/lg-logic.js'); var postcss = require('postcss'); -describe('calcValue works as it should', () => { - it('gutter, rounder, and unit ✅', () => { - var testCase = lgLogic.calcValue('1/3', '30px', 100, 'vw'); - - var expectedResult = 'calc(100vw * 1/3 - (30px - 30px * 1/3))'; - - expect(testCase).to.equal(expectedResult); +describe('lg-logic', () => { + describe('calcValue works as it should', () => { + it('gutter, rounder, and unit ✅', () => { + var testCase = lgLogic.calcValue('1/3', '30px', 100, 'vw'); + + var expectedResult = 'calc(100vw * 1/3 - (30px - 30px * 1/3))'; + + expect(testCase).to.equal(expectedResult); + }); + it('no gutter ✅', () => { + var testCase = lgLogic.calcValue('1/3', '0', 99.9); + + var expectedResult = 'calc(99.9% * 1/3)'; + + expect(testCase).to.equal(expectedResult); + }); + it('no gutter ✅ when gutter is undefined', () => { + var testCase = lgLogic.calcValue('1/3', undefined, 99.9); + + var expectedResult = 'calc(99.9% * 1/3)'; + + expect(testCase).to.equal(expectedResult); + }); }); - it('no gutter ✅', () => { - var testCase = lgLogic.calcValue('1/3', '0', 99.9); - - var expectedResult = 'calc(99.9% * 1/3)'; - - expect(testCase).to.equal(expectedResult); + + describe('Units are validated based on if they make sense', () => { + it('only allows what is in the array of accepted units', () => { + expect(lgLogic.validateUnit('vw', ['%', 'vw'])).to.be.true; + expect(lgLogic.validateUnit('%', ['%', 'vw'])).to.be.true; + expect(lgLogic.validateUnit('px', ['%', 'vw', 'px', 'em'])).to.be.true; + expect(lgLogic.validateUnit('foobar', ['%', 'vw'])).to.not.be.true; + expect(lgLogic.validateUnit(3, ['%', 'vw'])).to.not.be.true; + }); }); - it('no gutter ✅ when gutter is undefined', () => { - var testCase = lgLogic.calcValue('1/3', undefined, 99.9); - - var expectedResult = 'calc(99.9% * 1/3)'; - - expect(testCase).to.equal(expectedResult); - }); -}); - -describe('Units are validated based on if they make sense', () => { - it('only allows what is in the array of accepted units', () => { - expect(lgLogic.validateUnit('vw', ['%', 'vw'])).to.be.true; - expect(lgLogic.validateUnit('%', ['%', 'vw'])).to.be.true; - expect(lgLogic.validateUnit('px', ['%', 'vw', 'px', 'em'])).to.be.true; - expect(lgLogic.validateUnit('foobar', ['%', 'vw'])).to.not.be.true; - expect(lgLogic.validateUnit(3, ['%', 'vw'])).to.not.be.true; - }); -}); - -describe('parseLostProperty works as it should', () => { - it('returns default value if property not found', () => { - var css = 'a { lost-unit: vw; lost-center-padding: 25px }'; - var nodes = postcss.parse(css).nodes[0].nodes; - - var testCase = lgLogic.parseLostProperty(nodes, 'lost-column-rounder', 0); - var expectedResult = 0; - - expect(testCase).to.equal(expectedResult); - }); - - it('returns value if property is found', () => { - var css = 'a { lost-unit: vw; lost-center-padding: 25px }'; - var nodes = postcss.parse(css).nodes[0].nodes; - - var testCase = lgLogic.parseLostProperty(nodes, 'lost-unit', '%'); - var expectedResult = 'vw'; - - expect(testCase).to.equal(expectedResult); - }); - - it('property node removed if found', () => { - var css = 'a { height: 100px; lost-unit: vw; lost-center-padding: 25px }'; - var cssProperties = postcss.parse(css); - - lgLogic.parseLostProperty(cssProperties.nodes[0].nodes, 'lost-unit', '%'); - - var testCase = 'a { height: 100px; lost-center-padding: 25px }'; - var expectedResult = cssProperties.toString(); - - expect(testCase).to.equal(expectedResult); + + describe('parseLostProperty works as it should', () => { + it('returns default value if property not found', () => { + var css = 'a { lost-unit: vw; lost-center-padding: 25px }'; + var nodes = postcss.parse(css).nodes[0].nodes; + + var testCase = lgLogic.parseLostProperty(nodes, 'lost-column-rounder', 0); + var expectedResult = 0; + + expect(testCase).to.equal(expectedResult); + }); + + it('returns value if property is found', () => { + var css = 'a { lost-unit: vw; lost-center-padding: 25px }'; + var nodes = postcss.parse(css).nodes[0].nodes; + + var testCase = lgLogic.parseLostProperty(nodes, 'lost-unit', '%'); + var expectedResult = 'vw'; + + expect(testCase).to.equal(expectedResult); + }); + + it('property node removed if found', () => { + var css = 'a { height: 100px; lost-unit: vw; lost-center-padding: 25px }'; + var cssProperties = postcss.parse(css); + + lgLogic.parseLostProperty(cssProperties.nodes[0].nodes, 'lost-unit', '%'); + + var testCase = 'a { height: 100px; lost-center-padding: 25px }'; + var expectedResult = cssProperties.toString(); + + expect(testCase).to.equal(expectedResult); + }); }); -}); +}); \ No newline at end of file diff --git a/test/lg-utility.js b/test/lg-utility.js index adb0209..d3773ab 100644 --- a/test/lg-utility.js +++ b/test/lg-utility.js @@ -1,83 +1,87 @@ 'use strict'; var expect = require('chai').expect; -var utils = require('../lib/core/lg-utilities.js'); +var { lgUtils } = require('../dist/core/lg-utilities.js'); -describe('glueFractionMembers', () => { - it('glues fraction members together, avoiding a class of parsing errors', () => { - expect(utils.glueFractionMembers('-1 / 8')).to.equal('-1/8'); - expect(utils.glueFractionMembers('27 / 32')).to.equal('27/32'); - expect(utils.glueFractionMembers('1 /1')).to.equal('1/1'); - }); -}); +console.log(lgUtils); -describe('hToD', () => { - it('converts one or two hex digits to an int value', () => { - expect(utils.hToD(0, 0)).to.equal(0); - expect(utils.hToD(0)).to.equal(0); - expect(utils.hToD('A', 0)).to.equal(160); - expect(utils.hToD('A')).to.equal(170); - expect(utils.hToD()).to.equal(0); - expect(utils.hToD('Bats', 'and', 'boats')).to.equal(0); - expect(utils.hToD(NaN)).to.equal(0); +describe('lg-utilities', () => { + describe('glueFractionMembers', () => { + it('glues fraction members together, avoiding a class of parsing errors', () => { + expect(lgUtils.glueFractionMembers('-1 / 8')).to.equal('-1/8'); + expect(lgUtils.glueFractionMembers('27 / 32')).to.equal('27/32'); + expect(lgUtils.glueFractionMembers('1 /1')).to.equal('1/1'); + }); }); -}); - -describe('safeRgbToRgb', () => { - it('converts a rgb(a?) string to an int triple', () => { - const defaultBlue = [0, 0, 255]; - expect(utils.safeRgbToRgb('rgb(0,0,0)')).to.deep.equal([0, 0, 0]); - expect(utils.safeRgbToRgb('rgba(0,255,0,grenoble)')).to.deep.equal([ - 0, - 255, - 0, - ]); - expect(utils.safeRgbToRgb('rgba(0,255,0, 0)')).to.deep.equal([0, 255, 0]); - expect(utils.safeRgbToRgb('rgba(0,0)')).to.deep.equal(defaultBlue); - expect(utils.safeRgbToRgb('rgb(0, 0, 0)')).to.deep.equal([0, 0, 0]); - expect(utils.safeRgbToRgb('0,0')).to.deep.equal(defaultBlue); + + describe('hToD', () => { + it('converts one or two hex digits to an int value', () => { + expect(lgUtils.hToD(0, 0)).to.equal(0); + expect(lgUtils.hToD(0)).to.equal(0); + expect(lgUtils.hToD('A', 0)).to.equal(160); + expect(lgUtils.hToD('A')).to.equal(170); + expect(lgUtils.hToD()).to.equal(0); + expect(lgUtils.hToD('Bats', 'and', 'boats')).to.equal(0); + expect(lgUtils.hToD(NaN)).to.equal(0); + }); }); -}); - -describe('safeHexToRgb', () => { - it('converts a #hex string to an int triple', () => { - const defaultBlue = [0, 0, 255]; - expect(utils.safeHexToRgb('#000')).to.deep.equal([0, 0, 0]); - expect(utils.safeHexToRgb('#0000')).to.deep.equal([0, 0, 0]); - expect(utils.safeHexToRgb('#000000')).to.deep.equal([0, 0, 0]); - expect(utils.safeHexToRgb('#00000000')).to.deep.equal([0, 0, 0]); - expect(utils.safeHexToRgb('000')).to.deep.equal([0, 0, 0]); - expect(utils.safeHexToRgb('0000')).to.deep.equal([0, 0, 0]); - expect(utils.safeHexToRgb('000000')).to.deep.equal([0, 0, 0]); - expect(utils.safeHexToRgb('00000000')).to.deep.equal([0, 0, 0]); - expect(utils.safeHexToRgb('F00')).to.deep.equal([255, 0, 0]); - expect(utils.safeHexToRgb('F000')).to.deep.equal([255, 0, 0]); - expect(utils.safeHexToRgb('FF0000')).to.deep.equal([255, 0, 0]); - expect(utils.safeHexToRgb('FF000000')).to.deep.equal([255, 0, 0]); - expect(utils.safeHexToRgb('ff0000')).to.deep.equal([255, 0, 0]); - expect(utils.safeHexToRgb('Languedoc-roussillon')).to.deep.equal( - defaultBlue - ); + + describe('safeRgbToRgb', () => { + it('converts a rgb(a?) string to an int triple', () => { + const defaultBlue = [0, 0, 255]; + expect(lgUtils.safeRgbToRgb('rgb(0,0,0)')).to.deep.equal([0, 0, 0]); + expect(lgUtils.safeRgbToRgb('rgba(0,255,0,grenoble)')).to.deep.equal([ + 0, + 255, + 0, + ]); + expect(lgUtils.safeRgbToRgb('rgba(0,255,0, 0)')).to.deep.equal([0, 255, 0]); + expect(lgUtils.safeRgbToRgb('rgba(0,0)')).to.deep.equal(defaultBlue); + expect(lgUtils.safeRgbToRgb('rgb(0, 0, 0)')).to.deep.equal([0, 0, 0]); + expect(lgUtils.safeRgbToRgb('0,0')).to.deep.equal(defaultBlue); + }); }); -}); - -describe('getColorValue', () => { - it('converts a string to an int triple, defaulting to blue', () => { - const defaultBlue = [0, 0, 255]; - expect(utils.getColorValue('rgb(0,0,0)')).to.deep.equal([0, 0, 0]); - expect(utils.getColorValue('rgba(0,255,0,grenoble)')).to.deep.equal([ - 0, - 255, - 0, - ]); - expect(utils.getColorValue('rgb(0, 0, 0)')).to.deep.equal([0, 0, 0]); - expect(utils.getColorValue('0,0')).to.deep.equal(defaultBlue); - expect(utils.getColorValue('#F00')).to.deep.equal([255, 0, 0]); - expect(utils.getColorValue('#F000')).to.deep.equal([255, 0, 0]); - expect(utils.getColorValue('#FF0000')).to.deep.equal([255, 0, 0]); - expect(utils.getColorValue('#FF000000')).to.deep.equal([255, 0, 0]); - expect(utils.getColorValue('Languedoc-roussillon')).to.deep.equal( - defaultBlue - ); + + describe('safeHexToRgb', () => { + it('converts a #hex string to an int triple', () => { + const defaultBlue = [0, 0, 255]; + expect(lgUtils.safeHexToRgb('#000')).to.deep.equal([0, 0, 0]); + expect(lgUtils.safeHexToRgb('#0000')).to.deep.equal([0, 0, 0]); + expect(lgUtils.safeHexToRgb('#000000')).to.deep.equal([0, 0, 0]); + expect(lgUtils.safeHexToRgb('#00000000')).to.deep.equal([0, 0, 0]); + expect(lgUtils.safeHexToRgb('000')).to.deep.equal([0, 0, 0]); + expect(lgUtils.safeHexToRgb('0000')).to.deep.equal([0, 0, 0]); + expect(lgUtils.safeHexToRgb('000000')).to.deep.equal([0, 0, 0]); + expect(lgUtils.safeHexToRgb('00000000')).to.deep.equal([0, 0, 0]); + expect(lgUtils.safeHexToRgb('F00')).to.deep.equal([255, 0, 0]); + expect(lgUtils.safeHexToRgb('F000')).to.deep.equal([255, 0, 0]); + expect(lgUtils.safeHexToRgb('FF0000')).to.deep.equal([255, 0, 0]); + expect(lgUtils.safeHexToRgb('FF000000')).to.deep.equal([255, 0, 0]); + expect(lgUtils.safeHexToRgb('ff0000')).to.deep.equal([255, 0, 0]); + expect(lgUtils.safeHexToRgb('Languedoc-roussillon')).to.deep.equal( + defaultBlue + ); + }); + }); + + describe('getColorValue', () => { + it('converts a string to an int triple, defaulting to blue', () => { + const defaultBlue = [0, 0, 255]; + expect(lgUtils.getColorValue('rgb(0,0,0)')).to.deep.equal([0, 0, 0]); + expect(lgUtils.getColorValue('rgba(0,255,0,grenoble)')).to.deep.equal([ + 0, + 255, + 0, + ]); + expect(lgUtils.getColorValue('rgb(0, 0, 0)')).to.deep.equal([0, 0, 0]); + expect(lgUtils.getColorValue('0,0')).to.deep.equal(defaultBlue); + expect(lgUtils.getColorValue('#F00')).to.deep.equal([255, 0, 0]); + expect(lgUtils.getColorValue('#F000')).to.deep.equal([255, 0, 0]); + expect(lgUtils.getColorValue('#FF0000')).to.deep.equal([255, 0, 0]); + expect(lgUtils.getColorValue('#FF000000')).to.deep.equal([255, 0, 0]); + expect(lgUtils.getColorValue('Languedoc-roussillon')).to.deep.equal( + defaultBlue + ); + }); }); -}); +}); \ No newline at end of file diff --git a/test/lost-nesting.js b/test/lost-nesting.js index 0c9cbcd..c23365e 100644 --- a/test/lost-nesting.js +++ b/test/lost-nesting.js @@ -3,7 +3,7 @@ const check = require('./check'); const postcss = require('postcss'); const postcssPresetEnv = require('postcss-preset-env'); -const lost = require('../lost'); +const {lost} = require('../dist/lost'); const expect = require('chai').expect; describe('nesting-queries', () => { diff --git a/test/lost-plugin-options.js b/test/lost-plugin-options.js index d5370ea..eb5a5c7 100644 --- a/test/lost-plugin-options.js +++ b/test/lost-plugin-options.js @@ -1,7 +1,7 @@ 'use strict'; const postcss = require('postcss'); -const lost = require('../lost'); +const {lost} = require('../dist/lost'); const expect = require('chai').expect; describe('plugin-options', () => { diff --git a/test/lost-vars.js b/test/lost-vars.js index 9d8ec2d..64445d0 100644 --- a/test/lost-vars.js +++ b/test/lost-vars.js @@ -12,14 +12,21 @@ describe('lost-vars', () => { }); it('matches multiple variables', () => { + check( - "div { margin: lost-vars('gutter') lost-vars('gutter'); padding: lost-vars('gutter-local'); lost-offset: 1/3 3 100px;}", + "div { margin: lost-vars('gutter') lost-vars('gutter-local'); padding: lost-vars('gutter-local'); lost-offset: 1/3 3 100px;}", 'div { margin: 30px 30px; padding: 100px; margin-left: calc(99.9% * (-1/3 * -1) - (100px - 100px * (-1/3 * -1)) + 100px) !important;}' ); - check( - "div { margin: lost-vars('gutter') lost-vars('gutter-local'); lost-offset: 1/3 3 95px;}", - 'div { margin: 30px 95px; margin-left: calc(99.9% * (-1/3 * -1) - (95px - 95px * (-1/3 * -1)) + 95px) !important;}' - ); + + + // check( + // "div { margin: lost-vars('gutter') lost-vars('gutter'); padding: lost-vars('gutter-local'); lost-offset: 1/3 3 100px;}", + // 'div { margin: 30px 30px; padding: 100px; margin-left: calc(99.9% * (-1/3 * -1) - (100px - 100px * (-1/3 * -1)) + 100px) !important;}' + // ); + // check( + // "div { margin: lost-vars('gutter') lost-vars('gutter-local'); lost-offset: 1/3 3 95px;}", + // 'div { margin: 30px 95px; margin-left: calc(99.9% * (-1/3 * -1) - (95px - 95px * (-1/3 * -1)) + 95px) !important;}' + // ); }); describe('gutter', () => { diff --git a/test/throws.js b/test/throws.js index 1c54287..c37c928 100644 --- a/test/throws.js +++ b/test/throws.js @@ -1,7 +1,7 @@ 'use strict'; var expect = require('chai').expect; -var lost = require('../lost'); +var { lost } = require('../dist/lost'); var postcss = require('postcss'); var CssSyntaxError = require('postcss').CssSyntaxError; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..587bbc6 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2019", + "module": "CommonJS", + "outDir": "./dist", + "strict": true, + "esModuleInterop": true + }, + "include": [ + "src/**/*.ts", + "src/core/lg-logic.test.ts", + "src/core/lg-utilities.test.js", + "src/core/lg-logic.test.js", + "test/lg-utilities.test.ts" + ], + "exclude": ["node_modules"] +} From a8dfbf962b74bc00bee50dfed1867fba8fcba36a Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sat, 19 Aug 2023 23:20:14 -0700 Subject: [PATCH 03/13] TypeScript Step 2 --- package.json | 2 +- src/core/lg-logic.ts | 1 + src/lost-center.ts | 2 +- src/lost-gutter.ts | 5 +---- src/lost-vars-gutter.ts | 2 +- src/lost-vars.ts | 16 +++------------- test/lg-logic.js | 14 ++++++++++++++ test/lg-utility.js | 2 -- test/lost-vars.js | 17 +++++------------ tsconfig.json | 8 +------- 10 files changed, 28 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index 6b7cacd..0a01b88 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "lint": "eslint .", "report-coverage": "c8 report --reporter=text-lcov > coverage.lcov && codecov", "prepare": "husky install", - "start": "nodemon --watch 'src/**/*.ts' --exec 'tsc -p .'", + "start": "nodemon -e ts --ignore dist/ --exec 'tsc -p .' --verbose", "release": "release-it" } } diff --git a/src/core/lg-logic.ts b/src/core/lg-logic.ts index e5d3110..71b30e6 100644 --- a/src/core/lg-logic.ts +++ b/src/core/lg-logic.ts @@ -8,6 +8,7 @@ const calcValue = ( let gutterLogic = ''; if (gutter !== '0') { + // FIXME: there's messed up logic here with lost-center gutterLogic = ` - (${gutter} - ${gutter} * ${fraction})`; } diff --git a/src/lost-center.ts b/src/lost-center.ts index 57de631..cb736aa 100644 --- a/src/lost-center.ts +++ b/src/lost-center.ts @@ -10,7 +10,7 @@ export const lostCenter = (css: any, settings: any, result: any) => { var lostCenterFlexbox = settings.flexbox; var lostUnit = settings.gridUnit; var lostColumnRounder = settings.rounder; - var lostColumnGutter = 0; + var lostColumnGutter = '0'; var validUnits = ['%', 'vw']; var isFractionValue = (value: any) => { diff --git a/src/lost-gutter.ts b/src/lost-gutter.ts index b6f15aa..f39175a 100644 --- a/src/lost-gutter.ts +++ b/src/lost-gutter.ts @@ -3,15 +3,12 @@ import { lostVarsGutter } from './lost-vars-gutter'; export const lostGutter = (css: any, settings: any) => { var gutter, newValue; - - console.log(css, 'css'); - css.walkDecls((declaration: any) => { if ( /(\$lost-gutter)/g.test(declaration.value) && !/(\$lost-gutter-local)/g.test(declaration.value) ) { - gutter = lostVarsGutter(settings); + gutter = lostVarsGutter(declaration, settings); newValue = declaration.value.replace(/(\$lost-gutter)/g, gutter); declaration.value = newValue; diff --git a/src/lost-vars-gutter.ts b/src/lost-vars-gutter.ts index f6e03ac..2cb6a62 100644 --- a/src/lost-vars-gutter.ts +++ b/src/lost-vars-gutter.ts @@ -1,3 +1,3 @@ -export const lostVarsGutter = (settings: any) => { +export const lostVarsGutter = (_declaration: any, settings: any) => { return settings.gutter; }; diff --git a/src/lost-vars.ts b/src/lost-vars.ts index 8c292f2..2d3cc11 100644 --- a/src/lost-vars.ts +++ b/src/lost-vars.ts @@ -1,9 +1,9 @@ -import { lostGutter } from './lost-gutter'; +import { lostVarsGutter } from './lost-vars-gutter'; import { lostVarsGutterLocal } from './lost-vars-gutter-local'; export const lostVars = (css: any, settings: any) => { let variableFunctions = { - gutter: lostGutter, + gutter: lostVarsGutter, 'gutter-local': lostVarsGutterLocal, }; @@ -27,7 +27,6 @@ export const lostVars = (css: any, settings: any) => { } variables.forEach((variable) => { - console.log(declaration, 'declaration'); // @ts-ignore let func = variableFunctions[variable]; @@ -37,16 +36,7 @@ export const lostVars = (css: any, settings: any) => { ); } let newValue; - if (variable === 'gutter-local') { - newValue = func(declaration, settings); - } else if (variable === 'gutter') { - newValue = func(css, settings); - } else { - throw declaration.error( - `lost-vars: variable '${variable}' is unknown.` - ); - } - + newValue = func(declaration, settings); let replaceRegex = new RegExp( // eslint-disable-next-line `lost-vars\\(\s?['"]${variable}['"]\s?\\)`, diff --git a/test/lg-logic.js b/test/lg-logic.js index ed03850..47cd177 100644 --- a/test/lg-logic.js +++ b/test/lg-logic.js @@ -25,6 +25,20 @@ describe('lg-logic', () => { var expectedResult = 'calc(99.9% * 1/3)'; + expect(testCase).to.equal(expectedResult); + }); + it.skip('TODO: no gutter ✅ when gutter is 0', () => { // FIXME: should work + var testCase = lgLogic.calcValue('1/3', 0, 99.9); + + var expectedResult = 'calc(99.9% * 1/3)'; + + expect(testCase).to.equal(expectedResult); + }); + it('no gutter ✅ when gutter is string 0', () => { + var testCase = lgLogic.calcValue('1/3', '0', 99.9); + + var expectedResult = 'calc(99.9% * 1/3)'; + expect(testCase).to.equal(expectedResult); }); }); diff --git a/test/lg-utility.js b/test/lg-utility.js index d3773ab..b47ebdd 100644 --- a/test/lg-utility.js +++ b/test/lg-utility.js @@ -3,8 +3,6 @@ var expect = require('chai').expect; var { lgUtils } = require('../dist/core/lg-utilities.js'); -console.log(lgUtils); - describe('lg-utilities', () => { describe('glueFractionMembers', () => { it('glues fraction members together, avoiding a class of parsing errors', () => { diff --git a/test/lost-vars.js b/test/lost-vars.js index 64445d0..9d8ec2d 100644 --- a/test/lost-vars.js +++ b/test/lost-vars.js @@ -12,21 +12,14 @@ describe('lost-vars', () => { }); it('matches multiple variables', () => { - check( - "div { margin: lost-vars('gutter') lost-vars('gutter-local'); padding: lost-vars('gutter-local'); lost-offset: 1/3 3 100px;}", + "div { margin: lost-vars('gutter') lost-vars('gutter'); padding: lost-vars('gutter-local'); lost-offset: 1/3 3 100px;}", 'div { margin: 30px 30px; padding: 100px; margin-left: calc(99.9% * (-1/3 * -1) - (100px - 100px * (-1/3 * -1)) + 100px) !important;}' ); - - - // check( - // "div { margin: lost-vars('gutter') lost-vars('gutter'); padding: lost-vars('gutter-local'); lost-offset: 1/3 3 100px;}", - // 'div { margin: 30px 30px; padding: 100px; margin-left: calc(99.9% * (-1/3 * -1) - (100px - 100px * (-1/3 * -1)) + 100px) !important;}' - // ); - // check( - // "div { margin: lost-vars('gutter') lost-vars('gutter-local'); lost-offset: 1/3 3 95px;}", - // 'div { margin: 30px 95px; margin-left: calc(99.9% * (-1/3 * -1) - (95px - 95px * (-1/3 * -1)) + 95px) !important;}' - // ); + check( + "div { margin: lost-vars('gutter') lost-vars('gutter-local'); lost-offset: 1/3 3 95px;}", + 'div { margin: 30px 95px; margin-left: calc(99.9% * (-1/3 * -1) - (95px - 95px * (-1/3 * -1)) + 95px) !important;}' + ); }); describe('gutter', () => { diff --git a/tsconfig.json b/tsconfig.json index 587bbc6..266b334 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,12 +6,6 @@ "strict": true, "esModuleInterop": true }, - "include": [ - "src/**/*.ts", - "src/core/lg-logic.test.ts", - "src/core/lg-utilities.test.js", - "src/core/lg-logic.test.js", - "test/lg-utilities.test.ts" - ], + "include": ["src/**/*.ts"], "exclude": ["node_modules"] } From ded97cdb016bf57f328babf5272a2de73bbc1bd4 Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sun, 20 Aug 2023 16:09:35 -0700 Subject: [PATCH 04/13] Fix eslint issues --- .eslintignore | 6 +- .eslintrc.js | 5 +- .vscode/settings.json | 5 +- package-lock.json | 282 +++++++++++++++++++++++++++++++++- package.json | 4 +- src/core/lg-new-block.ts | 11 +- src/core/lg-utilities.ts | 4 +- src/lost-align.ts | 7 +- src/lost-center.ts | 22 +-- src/lost-column.ts | 18 +-- src/lost-gutter.ts | 20 +-- src/lost-masonry-column.ts | 12 +- src/lost-masonry-wrap.ts | 8 +- src/lost-move.ts | 14 +- src/lost-row.ts | 14 +- src/lost-utility.ts | 8 +- src/lost-vars-gutter-local.ts | 4 +- src/lost-vars.ts | 25 +-- src/lost-waffle.ts | 7 +- 19 files changed, 371 insertions(+), 105 deletions(-) diff --git a/.eslintignore b/.eslintignore index d1d7cf4..ffa3d05 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,7 +1,7 @@ docs/* +dist/* +test/* .nyc_output coverage -// FIXME: kill these -test/check.js -test/lost-nesting.js +//FIXME: fix tests \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 5ec575a..63247fd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,11 +3,14 @@ module.exports = { node: true, }, plugins: ['prettier'], - extends: 'eslint:recommended', + extends: 'plugin:@typescript-eslint/recommended', + parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 2022, + sourceType: 'module', }, rules: { + '@typescript-eslint/no-explicit-any': 'off', //FIXME: remove this 'eol-last': 2, 'no-multiple-empty-lines': [2, { max: 2, maxEOF: 1 }], 'linebreak-style': ['error', 'unix'], diff --git a/.vscode/settings.json b/.vscode/settings.json index 83ce20b..4a441ea 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "cSpell.words": ["codecov", "flexbox", "lcov", "linebreak"] + "cSpell.words": ["codecov", "flexbox", "lcov", "linebreak"], + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + } } diff --git a/package-lock.json b/package-lock.json index aa6678e..3d3a2ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,8 @@ "devDependencies": { "@types/chai": "^4.3.5", "@types/mocha": "^10.0.1", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", "c8": "^7.13.0", "chai": "^4.3.6", "clean-css": "^5.3.0", @@ -343,6 +345,30 @@ "postcss-selector-parser": "^6.0.10" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.6.2.tgz", + "integrity": "sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/@eslint/eslintrc": { "version": "1.3.0", "dev": true, @@ -760,6 +786,12 @@ "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", "dev": true }, + "node_modules/@types/json-schema": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", + "dev": true + }, "node_modules/@types/minimatch": { "version": "3.0.5", "dev": true, @@ -778,6 +810,230 @@ "dev": true, "peer": true }, + "node_modules/@types/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", + "dev": true + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.4.0.tgz", + "integrity": "sha512-62o2Hmc7Gs3p8SLfbXcipjWAa6qk2wZGChXG2JbBtYpwSRmti/9KHLqfbLs9uDigOexG+3PaQ9G2g3201FWLKg==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/type-utils": "6.4.0", + "@typescript-eslint/utils": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.4.0.tgz", + "integrity": "sha512-I1Ah1irl033uxjxO9Xql7+biL3YD7w9IU8zF+xlzD/YxY6a4b7DYA08PXUUCbm2sEljwJF6ERFy2kTGAGcNilg==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.4.0.tgz", + "integrity": "sha512-TUS7vaKkPWDVvl7GDNHFQMsMruD+zhkd3SdVW0d7b+7Zo+bd/hXJQ8nsiUZMi1jloWo6c9qt3B7Sqo+flC1nig==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.4.0.tgz", + "integrity": "sha512-TvqrUFFyGY0cX3WgDHcdl2/mMCWCDv/0thTtx/ODMY1QhEiyFtv/OlLaNIiYLwRpAxAtOLOY9SUf1H3Q3dlwAg==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.4.0", + "@typescript-eslint/utils": "6.4.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.4.0.tgz", + "integrity": "sha512-+FV9kVFrS7w78YtzkIsNSoYsnOtrYVnKWSTVXoL1761CsCRv5wpDOINgsXpxD67YCLZtVQekDDyaxfjVWUJmmg==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.4.0.tgz", + "integrity": "sha512-iDPJArf/K2sxvjOR6skeUCNgHR/tCQXBsa+ee1/clRKr3olZjZ/dSkXPZjG6YkPtnW6p5D1egeEPMCW6Gn4yLA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.4.0.tgz", + "integrity": "sha512-BvvwryBQpECPGo8PwF/y/q+yacg8Hn/2XS+DqL/oRsOPK+RPt29h5Ui5dqOKHDlbXrAeHUTnyG3wZA0KTDxRZw==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.4.0.tgz", + "integrity": "sha512-yJSfyT+uJm+JRDWYRYdCm2i+pmvXJSMtPR9Cq5/XQs4QIgNoLcoRtDdzsLbLsFM/c6um6ohQkg/MLxWvoIndJA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.4.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@ungap/promise-all-settled": { "version": "1.1.2", "dev": true, @@ -2618,11 +2874,15 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.3.0", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, - "license": "Apache-2.0", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/ansi-styles": { @@ -3336,6 +3596,12 @@ "dev": true, "license": "ISC" }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -7895,6 +8161,18 @@ "dev": true, "license": "MIT" }, + "node_modules/ts-api-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.2.tgz", + "integrity": "sha512-Cbu4nIqnEdd+THNEsBdkolnOXhg0I8XteoHaEKgvsxpsbWda4IsUut2c187HxywQCvveojow0Dgw/amxtSKVkQ==", + "dev": true, + "engines": { + "node": ">=16.13.0" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", diff --git a/package.json b/package.json index 0a01b88..e39d4a0 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,8 @@ "devDependencies": { "@types/chai": "^4.3.5", "@types/mocha": "^10.0.1", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", "c8": "^7.13.0", "chai": "^4.3.6", "clean-css": "^5.3.0", @@ -49,7 +51,7 @@ "test-specific": "c8 mocha --require ts-node/register --grep", "reset--node": "rm -rf node_modules && npm install", "dev": "c8 mocha --watch", - "lint": "eslint .", + "lint": "eslint '*/**/*.ts' --quiet --fix", "report-coverage": "c8 report --reporter=text-lcov > coverage.lcov && codecov", "prepare": "husky install", "start": "nodemon -e ts --ignore dist/ --exec 'tsc -p .' --verbose", diff --git a/src/core/lg-new-block.ts b/src/core/lg-new-block.ts index 48848d6..7dbf89d 100644 --- a/src/core/lg-new-block.ts +++ b/src/core/lg-new-block.ts @@ -4,11 +4,8 @@ export const newBlock = ( props: any[], values: any ) => { - let completeSelector: any; - let block: any; - function appendToSelectors(_thisSelector: string, selectorToAppend: any) { - let appendedSelectors: any[] = []; + const appendedSelectors: any[] = []; _thisSelector .split(',') @@ -19,9 +16,9 @@ export const newBlock = ( return appendedSelectors.join(','); } - completeSelector = appendToSelectors(decl.parent.selector, selector); + const completeSelector = appendToSelectors(decl.parent.selector, selector); - block = decl.parent.cloneAfter({ + const block = decl.parent.cloneAfter({ selector: completeSelector, }); @@ -32,7 +29,7 @@ export const newBlock = ( }); props.forEach(function addRulesFunction(prop: any, i: string | number) { - var rule = decl.clone({ + const rule = decl.clone({ prop: prop, value: values[i].toString(), }); diff --git a/src/core/lg-utilities.ts b/src/core/lg-utilities.ts index a35ae9e..b47c951 100644 --- a/src/core/lg-utilities.ts +++ b/src/core/lg-utilities.ts @@ -12,13 +12,13 @@ const glueFractionMembers = (str: string): string => * Returns a base10 number from one or two hex digits */ const hToD = function hToD(...h: (string | number)[]): number { - var hh = '00'; + let hh = '00'; if (h.length === 1) { hh = '' + h[0] + h[0]; } else if (h.length === 2) { hh = '' + h[0] + h[1]; } - var d = parseInt(hh, 16); + const d = parseInt(hh, 16); return !isNaN(d) ? d : 0; }; diff --git a/src/lost-align.ts b/src/lost-align.ts index b6b05ba..a8cadb5 100644 --- a/src/lost-align.ts +++ b/src/lost-align.ts @@ -2,12 +2,11 @@ import { newBlock } from './core/lg-new-block'; export const lostAlign = (css: any, settings: any) => { css.walkDecls('lost-align', function alignDirectionFunction(decl: any) { - var declArr = []; - var alignDirection; - var flexbox = settings.flexbox; + let declArr = []; + let flexbox = settings.flexbox; declArr = decl.value.split(' '); - alignDirection = declArr[0]; + const alignDirection = declArr[0]; if (declArr.indexOf('flex') !== -1) { flexbox = 'flex'; diff --git a/src/lost-center.ts b/src/lost-center.ts index cb736aa..1cc152d 100644 --- a/src/lost-center.ts +++ b/src/lost-center.ts @@ -4,17 +4,17 @@ import { lgUtils } from './core/lg-utilities'; export const lostCenter = (css: any, settings: any, result: any) => { css.walkDecls('lost-center', function lostCenterFunction(decl: any) { - var declArr = []; - var lostCenterPadding; - var lostCenterMaxWidth; - var lostCenterFlexbox = settings.flexbox; - var lostUnit = settings.gridUnit; - var lostColumnRounder = settings.rounder; - var lostColumnGutter = '0'; - var validUnits = ['%', 'vw']; - - var isFractionValue = (value: any) => { - var lostFractionPattern = /^\d+\/\d+$/; + let declArr = []; + let lostCenterPadding; + let lostCenterMaxWidth; + let lostCenterFlexbox = settings.flexbox; + let lostUnit = settings.gridUnit; + let lostColumnRounder = settings.rounder; + const lostColumnGutter = '0'; + const validUnits = ['%', 'vw']; + + const isFractionValue = (value: any) => { + const lostFractionPattern = /^\d+\/\d+$/; return lostFractionPattern.test(value); }; diff --git a/src/lost-column.ts b/src/lost-column.ts index fa53455..3744eac 100644 --- a/src/lost-column.ts +++ b/src/lost-column.ts @@ -4,15 +4,15 @@ import { lgUtils } from './core/lg-utilities'; export const lostColumn = (css: any, settings: any, result: any) => { css.walkDecls('lost-column', function lostColumnFunction(decl: any) { - var declArr = []; - var gridDirection = settings.direction; - var lostColumn; - var lostColumnCycle; - var unit = settings.gridUnit; - var lostColumnRounder = settings.rounder; - var lostColumnGutter = settings.gutter; - var lostColumnFlexbox = settings.flexbox; - var validUnits = ['%', 'vw']; + let declArr = []; + const gridDirection = settings.direction; + let lostColumn; + let lostColumnCycle; + let unit = settings.gridUnit; + let lostColumnRounder = settings.rounder; + let lostColumnGutter = settings.gutter; + let lostColumnFlexbox = settings.flexbox; + const validUnits = ['%', 'vw']; if (decl.value !== 'none') { if (settings.cycle === 'auto') { diff --git a/src/lost-gutter.ts b/src/lost-gutter.ts index f39175a..a9d9ff6 100644 --- a/src/lost-gutter.ts +++ b/src/lost-gutter.ts @@ -2,7 +2,7 @@ import { lostVarsGutterLocal } from './lost-vars-gutter-local'; import { lostVarsGutter } from './lost-vars-gutter'; export const lostGutter = (css: any, settings: any) => { - var gutter, newValue; + let gutter, newValue; css.walkDecls((declaration: any) => { if ( /(\$lost-gutter)/g.test(declaration.value) && @@ -21,21 +21,3 @@ export const lostGutter = (css: any, settings: any) => { } }); }; - -// css.walkDecls((declaration) => { -// if ( -// /(\$lost-gutter)/g.test(declaration.value) && -// !/(\$lost-gutter-local)/g.test(declaration.value) -// ) { -// gutter = lostGutter(declaration, settings); - -// newValue = declaration.value.replace(/(\$lost-gutter)/g, gutter); -// declaration.value = newValue; -// } -// if (/(\$lost-gutter-local)/g.test(declaration.value)) { -// gutter = lostGutterLocal(declaration, settings); - -// newValue = declaration.value.replace(/(\$lost-gutter-local)/g, gutter); -// declaration.value = newValue; -// } -// }); diff --git a/src/lost-masonry-column.ts b/src/lost-masonry-column.ts index 53177eb..8c13372 100644 --- a/src/lost-masonry-column.ts +++ b/src/lost-masonry-column.ts @@ -4,12 +4,12 @@ export const lostMasonryColumn = (css: any, settings: any) => { css.walkDecls( 'lost-masonry-column', function lostMasonryColumnFunction(decl: any) { - var declArr = []; - var lostMasonryColumn; - var lostMasonryColumnRounder = settings.rounder; - var lostMasonryColumnFlexbox = settings.flexbox; - var lostMasonryColumnGutter = settings.gutter; - var lostMasonryColumnGutterUnit; + let declArr = []; + let lostMasonryColumn; + let lostMasonryColumnRounder = settings.rounder; + let lostMasonryColumnFlexbox = settings.flexbox; + let lostMasonryColumnGutter = settings.gutter; + let lostMasonryColumnGutterUnit; function cloneAllBefore(props: any) { Object.keys(props).forEach(function traverseProps(prop) { diff --git a/src/lost-masonry-wrap.ts b/src/lost-masonry-wrap.ts index 7ffd2d4..349eaa7 100644 --- a/src/lost-masonry-wrap.ts +++ b/src/lost-masonry-wrap.ts @@ -4,10 +4,10 @@ export const lostMasonryWrap = (css: any, settings: any) => { css.walkDecls( 'lost-masonry-wrap', function lostMasonryWrapDeclFunction(decl: any) { - var declArr = []; - var lostMasonryWrapFlexbox = settings.flexbox; - var lostMasonryWrapGutter = settings.gutter; - var lostMasonryWrapGutterUnit; + let declArr = []; + let lostMasonryWrapFlexbox = settings.flexbox; + let lostMasonryWrapGutter = settings.gutter; + let lostMasonryWrapGutterUnit; function cloneAllBefore(props: any) { Object.keys(props).forEach(function traverseProps(prop) { diff --git a/src/lost-move.ts b/src/lost-move.ts index dcfeaf2..2796cda 100644 --- a/src/lost-move.ts +++ b/src/lost-move.ts @@ -2,11 +2,11 @@ import { lgUtils } from './core/lg-utilities'; export const lostMove = (css: any, settings: any) => { css.walkDecls('lost-move', function lostMoveDeclFunction(decl: any) { - var declArr = []; - var lostMove; - var lostMoveDirection; - var lostMoveRounder = settings.rounder; - var lostMoveGutter = settings.gutter; + let declArr = []; + let lostMove; + let lostMoveDirection; + let lostMoveRounder = settings.rounder; + let lostMoveGutter = settings.gutter; const sanitizedDecl = lgUtils.glueFractionMembers(decl.value); declArr = sanitizedDecl.split(' '); @@ -31,7 +31,7 @@ export const lostMove = (css: any, settings: any) => { decl.parent.nodes.forEach((declaration: any) => { if (declaration.prop === 'lost-column') { - var columnArray = declaration.value.split(' '); + const columnArray = declaration.value.split(' '); if (columnArray[2]) { lostMoveGutter = columnArray[2]; } @@ -43,7 +43,7 @@ export const lostMove = (css: any, settings: any) => { decl.parent.nodes.forEach((declaration: any) => { if (declaration.prop === 'lost-row') { - var rowArray = declaration.value.split(' '); + const rowArray = declaration.value.split(' '); if (rowArray[1]) { lostMoveGutter = rowArray[1]; } diff --git a/src/lost-row.ts b/src/lost-row.ts index 7e9f557..727d6b9 100644 --- a/src/lost-row.ts +++ b/src/lost-row.ts @@ -4,13 +4,13 @@ import { lgUtils } from './core/lg-utilities'; export const lostRow = (css: any, settings: any, result: any) => { css.walkDecls('lost-row', function lostRowDeclFunction(decl: any) { - var declArr = []; - var lostRow; - var unit = settings.gridUnit; - var lostRowRounder = settings.rounder; - var lostRowGutter = settings.gutter; - var lostRowFlexbox = settings.flexbox; - var validUnits = ['%', 'vh']; + let declArr = []; + let lostRow; + let unit = settings.gridUnit; + let lostRowRounder = settings.rounder; + let lostRowGutter = settings.gutter; + let lostRowFlexbox = settings.flexbox; + const validUnits = ['%', 'vh']; if (decl.value !== 'none') { const sanitizedDecl = lgUtils.glueFractionMembers(decl.value); diff --git a/src/lost-utility.ts b/src/lost-utility.ts index 39a218d..c69befd 100644 --- a/src/lost-utility.ts +++ b/src/lost-utility.ts @@ -2,8 +2,8 @@ import { newBlock } from './core/lg-new-block'; import { lgUtils } from './core/lg-utilities'; const unitsMatch = (...args: any) => { - let re = /(px|%|em|rem|vh|vw)$/gi; - let extension = args[0].match(re).toString(); + const re = /(px|%|em|rem|vh|vw)$/gi; + const extension = args[0].match(re).toString(); let matched = true; args.forEach(function compareExtension(arg: any) { @@ -16,8 +16,8 @@ const unitsMatch = (...args: any) => { export const lostUtility = (css: any) => { css.walkDecls('lost-utility', function lostUtilityDeclFunction(decl: any) { - let utilityArray = decl.value.split(' '); - let utility = utilityArray[0]; + const utilityArray = decl.value.split(' '); + const utility = utilityArray[0]; let color; if (utility === 'edit') { diff --git a/src/lost-vars-gutter-local.ts b/src/lost-vars-gutter-local.ts index b55bf91..19884ef 100644 --- a/src/lost-vars-gutter-local.ts +++ b/src/lost-vars-gutter-local.ts @@ -1,8 +1,8 @@ export const lostVarsGutterLocal = (declaration: any, settings: any) => { - var newLocalValue = settings.gutter; + let newLocalValue = settings.gutter; declaration.parent.nodes.forEach((parentDeclaration: any) => { - var declarationArray = parentDeclaration.value.split(' '); + const declarationArray = parentDeclaration.value.split(' '); if ( parentDeclaration.prop === 'lost-column' || diff --git a/src/lost-vars.ts b/src/lost-vars.ts index 2d3cc11..ff29631 100644 --- a/src/lost-vars.ts +++ b/src/lost-vars.ts @@ -2,42 +2,45 @@ import { lostVarsGutter } from './lost-vars-gutter'; import { lostVarsGutterLocal } from './lost-vars-gutter-local'; export const lostVars = (css: any, settings: any) => { - let variableFunctions = { + const variableFunctions = { gutter: lostVarsGutter, 'gutter-local': lostVarsGutterLocal, }; css.walkDecls((declaration: any) => { - let value = declaration.value, - variables = [], + let value = declaration.value; + const variables = [], // eslint-disable-next-line - re = /lost\-vars\(\s?['"]([\w\-]+)['"]\s?\)/gi, - match = null; + re = /lost\-vars\(\s?['"]([\w\-]+)['"]\s?\)/gi; + let match = null; if (typeof value !== 'string' || value.indexOf('lost-vars(') === -1) { return; } + const variablesSet = new Set(); + while ((match = re.exec(value)) !== null) { - let variableFound = match[1].replace(/["']/g, ''); + const variableFound = match[1].replace(/["']/g, ''); - if (variables.indexOf(variableFound) === -1) { + if (!variablesSet.has(variableFound)) { + variablesSet.add(variableFound); variables.push(variableFound); } } variables.forEach((variable) => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - let func = variableFunctions[variable]; + const func = variableFunctions[variable]; if (typeof func !== 'function') { throw declaration.error( `lost-vars: variable '${variable}' is unknown.` ); } - let newValue; - newValue = func(declaration, settings); - let replaceRegex = new RegExp( + const newValue = func(declaration, settings); + const replaceRegex = new RegExp( // eslint-disable-next-line `lost-vars\\(\s?['"]${variable}['"]\s?\\)`, 'gi' diff --git a/src/lost-waffle.ts b/src/lost-waffle.ts index 0597103..7811cab 100644 --- a/src/lost-waffle.ts +++ b/src/lost-waffle.ts @@ -5,15 +5,14 @@ import { lgUtils } from './core/lg-utilities'; export const lostWaffle = (css: any, settings: any) => { css.walkDecls('lost-waffle', function lostWaffleDeclFunction(decl: any) { let declArr = []; - let gridDirection = settings.direction; - let lostWaffle; + const gridDirection = settings.direction; let floatRight; let lostWaffleCycle; let unit = settings.gridUnit; let lostWaffleRounder = settings.rounder; let lostWaffleGutter = settings.gutter; let lostWaffleFlexbox = settings.flexbox; - let validUnits = ['%', 'vh', 'vw']; + const validUnits = ['%', 'vh', 'vw']; function cloneAllBefore(props: any) { Object.keys(props).forEach(function traverseProps(prop) { @@ -32,7 +31,7 @@ export const lostWaffle = (css: any, settings: any) => { const sanitizedDecl = lgUtils.glueFractionMembers(decl.value); declArr = sanitizedDecl.split(' '); - lostWaffle = declArr[0]; + const lostWaffle = declArr[0]; if (declArr[1] !== undefined && declArr[1].search(/^\d/) !== -1) { lostWaffleCycle = declArr[1]; From 099651ae66d70c9d30fc797153d0eb639ad17376 Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sun, 20 Aug 2023 21:59:08 -0700 Subject: [PATCH 05/13] Minor optimizations of lost-column --- src/lost-column.ts | 86 +++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/lost-column.ts b/src/lost-column.ts index 3744eac..1920115 100644 --- a/src/lost-column.ts +++ b/src/lost-column.ts @@ -3,59 +3,58 @@ import { lgLogic } from './core/lg-logic'; import { lgUtils } from './core/lg-utilities'; export const lostColumn = (css: any, settings: any, result: any) => { - css.walkDecls('lost-column', function lostColumnFunction(decl: any) { - let declArr = []; + css.walkDecls('lost-column', (decl: any) => { const gridDirection = settings.direction; - let lostColumn; - let lostColumnCycle; + const validUnits = ['%', 'vw']; + + let lostColumnCycle = + settings.cycle === 'auto' ? decl.value.split('/')[1] : settings.cycle; let unit = settings.gridUnit; let lostColumnRounder = settings.rounder; let lostColumnGutter = settings.gutter; let lostColumnFlexbox = settings.flexbox; - const validUnits = ['%', 'vw']; + let lostColumn; if (decl.value !== 'none') { - if (settings.cycle === 'auto') { - lostColumnCycle = decl.value.split('/')[1]; - } else { - lostColumnCycle = settings.cycle; - } - const sanitizedDecl = lgUtils.glueFractionMembers(decl.value); - declArr = sanitizedDecl.split(' '); + const declArr = sanitizedDecl.split(' '); lostColumn = declArr[0]; - if (declArr[1] !== undefined && declArr[1].search(/^\d/) !== -1) { - lostColumnCycle = declArr[1]; - } - - if ( - declArr[1] === 'flex' || - declArr[1] === 'no-flex' || - declArr[1] === 'auto' - ) { - lostColumnCycle = declArr[0].split('/')[1]; - } - // eslint-disable-next-line - if (declArr[2] !== undefined && declArr[2].search(/^[\.\d]/) !== -1) { - lostColumnGutter = declArr[2]; - } - - if (declArr.indexOf('flex') !== -1) { - lostColumnFlexbox = 'flex'; - } - - if (declArr.indexOf('no-flex') !== -1) { - lostColumnFlexbox = 'no-flex'; - } - - decl.parent.nodes.forEach(function lostColumnCycleFunction( - declaration: any - ) { - if (declaration.prop === 'lost-column-cycle') { - lostColumnCycle = declaration.value; - - declaration.remove(); + decl.parent.nodes.forEach((declaration: any) => { + switch (declaration.prop) { + case 'lost-column-cycle': + lostColumnCycle = declaration.value; + declaration.remove(); + break; + case 'lost-unit': + if (lgLogic.validateUnit(declaration.value, validUnits)) { + unit = declaration.value; + } else { + decl.warn( + result, + `${declaration.value} is not a valid unit for lost-column` + ); + } + declaration.remove(); + break; + case 'lost-column-rounder': + lostColumnRounder = declaration.value; + declaration.remove(); + break; + case 'lost-column-gutter': + lostColumnGutter = declaration.value; + declaration.remove(); + break; + case 'lost-column-flexbox': + if (declaration.value === 'flex') { + lostColumnFlexbox = 'flex'; + } else { + throw declaration.error( + `lost-column-flexbox: property '${declaration.value}' is unknown.` + ); + } + declaration.remove(); + break; } }); @@ -272,6 +271,7 @@ export const lostColumn = (css: any, settings: any, result: any) => { ), }); } else { + // If decl.value is 'none' decl.parent.nodes.forEach((declaration: any) => { if (declaration.prop === 'lost-column-flexbox') { if (declaration.value === 'flex') { From b93dc6d27365503484016c439e55bb96572d42f6 Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sun, 20 Aug 2023 22:05:46 -0700 Subject: [PATCH 06/13] More lint cleanup --- src/lost-masonry-column.ts | 3 +-- src/lost-masonry-wrap.ts | 5 +++-- src/lost-move.ts | 3 +-- src/lost-offset.ts | 6 ++---- src/lost-utility.ts | 8 ++++---- src/lost.ts | 3 --- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/lost-masonry-column.ts b/src/lost-masonry-column.ts index 8c13372..7424609 100644 --- a/src/lost-masonry-column.ts +++ b/src/lost-masonry-column.ts @@ -5,7 +5,6 @@ export const lostMasonryColumn = (css: any, settings: any) => { 'lost-masonry-column', function lostMasonryColumnFunction(decl: any) { let declArr = []; - let lostMasonryColumn; let lostMasonryColumnRounder = settings.rounder; let lostMasonryColumnFlexbox = settings.flexbox; let lostMasonryColumnGutter = settings.gutter; @@ -22,7 +21,7 @@ export const lostMasonryColumn = (css: any, settings: any) => { const sanitizedDecl = lgUtils.glueFractionMembers(decl.value); declArr = sanitizedDecl.split(' '); - lostMasonryColumn = declArr[0]; + const lostMasonryColumn = declArr[0]; if (declArr[1] !== undefined && declArr[1].search(/^\d/) !== -1) { lostMasonryColumnGutter = declArr[1]; diff --git a/src/lost-masonry-wrap.ts b/src/lost-masonry-wrap.ts index 349eaa7..0eb89b3 100644 --- a/src/lost-masonry-wrap.ts +++ b/src/lost-masonry-wrap.ts @@ -7,7 +7,6 @@ export const lostMasonryWrap = (css: any, settings: any) => { let declArr = []; let lostMasonryWrapFlexbox = settings.flexbox; let lostMasonryWrapGutter = settings.gutter; - let lostMasonryWrapGutterUnit; function cloneAllBefore(props: any) { Object.keys(props).forEach(function traverseProps(prop) { @@ -81,7 +80,9 @@ export const lostMasonryWrap = (css: any, settings: any) => { }); } - lostMasonryWrapGutterUnit = lostMasonryWrapGutter.match(/\D/g).join(''); + const lostMasonryWrapGutterUnit = lostMasonryWrapGutter + .match(/\D/g) + .join(''); cloneAllBefore({ 'margin-left': diff --git a/src/lost-move.ts b/src/lost-move.ts index 2796cda..52e45a6 100644 --- a/src/lost-move.ts +++ b/src/lost-move.ts @@ -3,14 +3,13 @@ import { lgUtils } from './core/lg-utilities'; export const lostMove = (css: any, settings: any) => { css.walkDecls('lost-move', function lostMoveDeclFunction(decl: any) { let declArr = []; - let lostMove; let lostMoveDirection; let lostMoveRounder = settings.rounder; let lostMoveGutter = settings.gutter; const sanitizedDecl = lgUtils.glueFractionMembers(decl.value); declArr = sanitizedDecl.split(' '); - lostMove = declArr[0]; + const lostMove = declArr[0]; if ( (declArr[1] !== undefined && declArr[1] === 'row') || diff --git a/src/lost-offset.ts b/src/lost-offset.ts index de5d05b..a7d0286 100644 --- a/src/lost-offset.ts +++ b/src/lost-offset.ts @@ -3,8 +3,6 @@ import { lgUtils } from './core/lg-utilities'; export const lostOffset = (css: any, settings: any) => { css.walkDecls('lost-offset', function lostOffsetDeclFunction(decl: any) { let declArr = []; - let lostOffset: any; - let lostOffsetNumerator: any; let lostOffsetDirection: any; let lostOffsetRounder = settings.rounder; let lostOffsetGutter = settings.gutter; @@ -20,8 +18,8 @@ export const lostOffset = (css: any, settings: any) => { const sanitizedDecl = lgUtils.glueFractionMembers(decl.value); declArr = sanitizedDecl.split(' '); - lostOffset = declArr[0]; - lostOffsetNumerator = declArr[0].split('/')[0]; + const lostOffset = declArr[0]; + const lostOffsetNumerator = parseInt(declArr[0].split('/')[0]); if ( (declArr[1] !== undefined && declArr[1] === 'row') || diff --git a/src/lost-utility.ts b/src/lost-utility.ts index c69befd..cadae21 100644 --- a/src/lost-utility.ts +++ b/src/lost-utility.ts @@ -52,7 +52,7 @@ export const lostUtility = (css: any) => { } if (utility === 'overlay') { - let maxWidth = utilityArray[1] || '1024px', + const maxWidth = utilityArray[1] || '1024px', numCols = utilityArray[2] || 12, gutter = utilityArray[3] || '20px', totalGutter = parseFloat(gutter) * (numCols - 1), @@ -61,9 +61,9 @@ export const lostUtility = (css: any) => { numCols / parseFloat(maxWidth)) * 100, - gutterPercentage = (parseFloat(gutter) / parseFloat(maxWidth)) * 100, - position = 0, - gradient = 'to right, '; + gutterPercentage = (parseFloat(gutter) / parseFloat(maxWidth)) * 100; + let position = 0; + let gradient = 'to right, '; color = utilityArray[4] || '#e6f6ff'; diff --git a/src/lost.ts b/src/lost.ts index 1400233..1733801 100644 --- a/src/lost.ts +++ b/src/lost.ts @@ -1,5 +1,4 @@ // Module dependencies - import { AtRule } from 'postcss'; import { lostAlign } from './lost-align'; import { lostAtRule } from './lost-at-rule'; @@ -59,5 +58,3 @@ export const lost = (settings = {}) => { }, }; }; - -// module.exports.postcss = true; From 0abccfe2691a0f441451b995c92f2b8e20ce8bdf Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sun, 20 Aug 2023 22:06:02 -0700 Subject: [PATCH 07/13] Simplifies the linting guidelines now that Husky is installed --- CONTRIBUTING.md | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3d782d1..31aab4f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,42 +22,4 @@ Thanks, and don't hesitate to reach out if you have any questions! ## Git Hooks for LostGrid -LostGrid requires linting in order for PR's to be accepted. - -Having a pre-commit hook is a great way to enforce this before CI catches it. - -This was taken from Angular's Material project nearly wholesale. Thanks to them for the great docs! -Read how: [Material2's Wiki](https://github.com/angular/material2/wiki/Pre-commit-hook-for-linters) - -`pre-commit` code for LostGrid's linter - -```bash -#!/bin/sh - -pass=true -RED='\033[1;31m' -GREEN='\033[0;32m' -NC='\033[0m' - -echo "Running Linter:" - -# Run elsint and get the output and return code -eslint=$(npm run lint) -ret_code=$? - -# If it didn't pass, announce it failed and print the output -if [ $ret_code != 0 ]; then - printf "\n${RED}eslint failed:${NC}" - echo "$eslint\n" - pass=false -else - printf "${GREEN}eslint passed.${NC}\n" -fi - -# If there were no failures, it is good to commit -if $pass; then - exit 0 -fi - -exit 1 -``` +Husky should take care of this for you now From 818d94a625cc2083c6f1a3ea59abc98d1697dd63 Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sun, 20 Aug 2023 22:12:05 -0700 Subject: [PATCH 08/13] Revert "Minor optimizations of lost-column" This reverts commit 099651ae66d70c9d30fc797153d0eb639ad17376. --- src/lost-column.ts | 86 +++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/lost-column.ts b/src/lost-column.ts index 1920115..3744eac 100644 --- a/src/lost-column.ts +++ b/src/lost-column.ts @@ -3,58 +3,59 @@ import { lgLogic } from './core/lg-logic'; import { lgUtils } from './core/lg-utilities'; export const lostColumn = (css: any, settings: any, result: any) => { - css.walkDecls('lost-column', (decl: any) => { + css.walkDecls('lost-column', function lostColumnFunction(decl: any) { + let declArr = []; const gridDirection = settings.direction; - const validUnits = ['%', 'vw']; - - let lostColumnCycle = - settings.cycle === 'auto' ? decl.value.split('/')[1] : settings.cycle; + let lostColumn; + let lostColumnCycle; let unit = settings.gridUnit; let lostColumnRounder = settings.rounder; let lostColumnGutter = settings.gutter; let lostColumnFlexbox = settings.flexbox; - let lostColumn; + const validUnits = ['%', 'vw']; if (decl.value !== 'none') { + if (settings.cycle === 'auto') { + lostColumnCycle = decl.value.split('/')[1]; + } else { + lostColumnCycle = settings.cycle; + } + const sanitizedDecl = lgUtils.glueFractionMembers(decl.value); - const declArr = sanitizedDecl.split(' '); + declArr = sanitizedDecl.split(' '); lostColumn = declArr[0]; - decl.parent.nodes.forEach((declaration: any) => { - switch (declaration.prop) { - case 'lost-column-cycle': - lostColumnCycle = declaration.value; - declaration.remove(); - break; - case 'lost-unit': - if (lgLogic.validateUnit(declaration.value, validUnits)) { - unit = declaration.value; - } else { - decl.warn( - result, - `${declaration.value} is not a valid unit for lost-column` - ); - } - declaration.remove(); - break; - case 'lost-column-rounder': - lostColumnRounder = declaration.value; - declaration.remove(); - break; - case 'lost-column-gutter': - lostColumnGutter = declaration.value; - declaration.remove(); - break; - case 'lost-column-flexbox': - if (declaration.value === 'flex') { - lostColumnFlexbox = 'flex'; - } else { - throw declaration.error( - `lost-column-flexbox: property '${declaration.value}' is unknown.` - ); - } - declaration.remove(); - break; + if (declArr[1] !== undefined && declArr[1].search(/^\d/) !== -1) { + lostColumnCycle = declArr[1]; + } + + if ( + declArr[1] === 'flex' || + declArr[1] === 'no-flex' || + declArr[1] === 'auto' + ) { + lostColumnCycle = declArr[0].split('/')[1]; + } + // eslint-disable-next-line + if (declArr[2] !== undefined && declArr[2].search(/^[\.\d]/) !== -1) { + lostColumnGutter = declArr[2]; + } + + if (declArr.indexOf('flex') !== -1) { + lostColumnFlexbox = 'flex'; + } + + if (declArr.indexOf('no-flex') !== -1) { + lostColumnFlexbox = 'no-flex'; + } + + decl.parent.nodes.forEach(function lostColumnCycleFunction( + declaration: any + ) { + if (declaration.prop === 'lost-column-cycle') { + lostColumnCycle = declaration.value; + + declaration.remove(); } }); @@ -271,7 +272,6 @@ export const lostColumn = (css: any, settings: any, result: any) => { ), }); } else { - // If decl.value is 'none' decl.parent.nodes.forEach((declaration: any) => { if (declaration.prop === 'lost-column-flexbox') { if (declaration.value === 'flex') { From 3de870589185ccc0ba74596c52a3437438a92722 Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sun, 20 Aug 2023 22:27:35 -0700 Subject: [PATCH 09/13] Fixes main target file --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e39d4a0..7c16c3b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "lost", "version": "9.0.1", "description": "LostGrid is a powerful grid system built in PostCSS that works with any preprocessor and even vanilla CSS.", - "main": "dist/index.js", + "main": "dist/lost.js", "repository": { "type": "git", "url": "https://github.com/peterramsing/lost.git" From 730891d5cf3cf2c6af1e828b30ff47d341e7cbca Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sun, 20 Aug 2023 22:28:08 -0700 Subject: [PATCH 10/13] adds roadmap section --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index fa686d0..31fdd9f 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,13 @@ LostGrid makes use of [`calc()`](https://developer.mozilla.org/en-US/docs/Web/CS Read the docs on [LostGrid.org](http://lostgrid.org/docs.html)! +## Roadmap + +- [ ] Migrate the core of the code to TypeScript +- [ ] Remove a lot of the complexity, focusing on moving complexity to CSS Grid +- [ ] Optimize LostGrid to support CSS Grid, getting out of the way while helping enabled developers to use CSS Grid +- [ ] Maintain backwards compatibility with older browsers for those who need it + ## Browser Support - LostGrid relies on [`calc()`](https://developer.mozilla.org/en-US/docs/Web/CSS/calc) to create the grid. Thus, LostGrid is limited to browsers that support `calc()`. The great thing is that `calc()` is widely supported in all current browsers and the LostGrid usage of `calc()` is supported as far back as IE9+. From 523eedfe25e3dc9fc350e59e9dbff83ba6e53ece Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sun, 20 Aug 2023 22:31:27 -0700 Subject: [PATCH 11/13] Adds build commands --- .github/workflows/node.js.yml | 1 + package.json | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 53e439a..ee4067b 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -30,6 +30,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm ci + - run: npm run build - run: npm test - run: npm run lint - run: npm run report-coverage diff --git a/package.json b/package.json index 7c16c3b..3c313c2 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "report-coverage": "c8 report --reporter=text-lcov > coverage.lcov && codecov", "prepare": "husky install", "start": "nodemon -e ts --ignore dist/ --exec 'tsc -p .' --verbose", + "build": "tsc -p .", "release": "release-it" } } From e78d67375427855d796786bc48f06baf3fe2a945 Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sun, 20 Aug 2023 22:34:48 -0700 Subject: [PATCH 12/13] Adds back Node 14 since its in maintenance to test --- .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 ee4067b..89c53ac 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: - node-version: [16.x, 17.x, 18.x, 19.x, 20.x] + node-version: [14.x, 16.x, 17.x, 18.x, 19.x, 20.x] # See supported Node.js release schedule at https://endoflife.date/nodejs steps: From 4a07a08062e9572d6741b9a83459ac1c70e5160b Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Sun, 20 Aug 2023 22:38:45 -0700 Subject: [PATCH 13/13] Revert "Adds back Node 14 since its in maintenance to test" This reverts commit e78d67375427855d796786bc48f06baf3fe2a945. --- .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 89c53ac..ee4067b 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: - node-version: [14.x, 16.x, 17.x, 18.x, 19.x, 20.x] + node-version: [16.x, 17.x, 18.x, 19.x, 20.x] # See supported Node.js release schedule at https://endoflife.date/nodejs steps: