@atlaskit/codemod-cli 0.34.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/cli.js +4 -3
- package/dist/cjs/get-transform-module.js +14 -0
- package/dist/cjs/get-transform-path.js +11 -0
- package/dist/cjs/get-transform-version.js +16 -0
- package/dist/cjs/{transforms.js → get-transforms.js} +19 -45
- package/dist/cjs/has-transform.js +10 -0
- package/dist/cjs/index.js +1 -14
- package/dist/cjs/main.js +17 -12
- package/dist/cjs/no-transforms-exist-error.js +23 -0
- package/dist/cjs/parse-transform-path.js +11 -0
- package/dist/cjs/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.js +22 -0
- package/dist/cjs/presets/migrate-deprecated-icon/utils/{mock.js → mock-metadata.js} +1 -17
- package/dist/cjs/presets/migrate-icon-object-to-object/codemods/migrate-icon-object-to-object.js +6 -4
- package/dist/cjs/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.js +12 -0
- package/dist/cjs/presets/migrate-icon-object-to-object/utils/get-new-import-info.js +28 -0
- package/dist/cjs/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.js +13 -0
- package/dist/cjs/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.js +29 -0
- package/dist/cjs/presets/migrate-to-link/codemods/migrate-to-link.js +4 -2
- package/dist/cjs/presets/migrate-to-link/utils/comments.js +2 -13
- package/dist/cjs/presets/migrate-to-link/utils/generic-unsupported-migration-comment.js +11 -0
- package/dist/cjs/presets/migrate-to-link/utils/style-prop-comment.js +12 -0
- package/dist/cjs/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +2 -2
- package/dist/cjs/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +18 -16
- package/dist/cjs/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.js +11 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.js → find-variant-already-imported.js} +1 -5
- package/dist/cjs/presets/migrate-to-new-buttons/utils/{generate-link-element.js → generate-link-component.js} +3 -12
- package/dist/cjs/presets/migrate-to-new-buttons/utils/generate-new-element.js +47 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/get-icon-attributes.js +15 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/get-icon-element.js +13 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/handle-icon-attributes.js +81 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/migrate-fit-container-icon-button.js +4 -3
- package/dist/cjs/presets/migrate-to-new-buttons/utils/modify-button-attributes.js +18 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/modify-link-attributes.js +16 -0
- package/dist/cjs/presets/remove-token-fallbacks/after-all.js +337 -0
- package/dist/cjs/presets/remove-token-fallbacks/before-all.js +33 -0
- package/dist/cjs/presets/remove-token-fallbacks/remove-token-fallbacks.js +4 -360
- package/dist/cjs/presets/remove-token-fallbacks/utils/clear-folder.js +68 -0
- package/dist/cjs/presets/remove-token-fallbacks/utils/{color-utils.js → color-to-hex.js} +0 -37
- package/dist/cjs/presets/remove-token-fallbacks/utils/{reporter.js → combine-reports.js} +59 -182
- package/dist/cjs/presets/remove-token-fallbacks/utils/compare-hex.js +25 -0
- package/dist/cjs/presets/remove-token-fallbacks/utils/is-valid-color.js +41 -0
- package/dist/cjs/presets/remove-token-fallbacks/utils/normalize-values.js +8 -6
- package/dist/cjs/presets/remove-token-fallbacks/utils/write-reports.js +83 -0
- package/dist/cjs/sinceRef.js +2 -2
- package/dist/cjs/types.js +1 -31
- package/dist/cjs/validation-error.js +23 -0
- package/dist/es2019/cli.js +2 -1
- package/dist/es2019/get-transform-module.js +7 -0
- package/dist/es2019/get-transform-path.js +4 -0
- package/dist/es2019/get-transform-version.js +9 -0
- package/dist/es2019/{transforms.js → get-transforms.js} +10 -31
- package/dist/es2019/has-transform.js +2 -0
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/main.js +7 -2
- package/dist/es2019/no-transforms-exist-error.js +1 -0
- package/dist/es2019/parse-transform-path.js +2 -0
- package/dist/es2019/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.js +16 -0
- package/dist/es2019/presets/migrate-deprecated-icon/utils/{mock.js → mock-metadata.js} +0 -16
- package/dist/es2019/presets/migrate-icon-object-to-object/codemods/migrate-icon-object-to-object.js +3 -1
- package/dist/es2019/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.js +6 -0
- package/dist/es2019/presets/migrate-icon-object-to-object/utils/get-new-import-info.js +22 -0
- package/dist/es2019/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.js +5 -0
- package/dist/es2019/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.js +19 -0
- package/dist/es2019/presets/migrate-to-link/codemods/migrate-to-link.js +3 -1
- package/dist/es2019/presets/migrate-to-link/utils/comments.js +1 -11
- package/dist/es2019/presets/migrate-to-link/utils/generic-unsupported-migration-comment.js +4 -0
- package/dist/es2019/presets/migrate-to-link/utils/style-prop-comment.js +6 -0
- package/dist/es2019/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +1 -1
- package/dist/es2019/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +5 -3
- package/dist/es2019/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.js +4 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.js → find-variant-already-imported.js} +0 -3
- package/dist/es2019/presets/migrate-to-new-buttons/utils/{generate-link-element.js → generate-link-component.js} +1 -10
- package/dist/es2019/presets/migrate-to-new-buttons/utils/generate-new-element.js +39 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/get-icon-attributes.js +7 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/get-icon-element.js +7 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/handle-icon-attributes.js +68 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/migrate-fit-container-icon-button.js +2 -1
- package/dist/es2019/presets/migrate-to-new-buttons/utils/modify-button-attributes.js +12 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/modify-link-attributes.js +10 -0
- package/dist/es2019/presets/remove-token-fallbacks/after-all.js +139 -0
- package/dist/es2019/presets/remove-token-fallbacks/before-all.js +8 -0
- package/dist/es2019/presets/remove-token-fallbacks/remove-token-fallbacks.js +2 -150
- package/dist/es2019/presets/remove-token-fallbacks/utils/clear-folder.js +15 -0
- package/dist/es2019/presets/remove-token-fallbacks/utils/{color-utils.js → color-to-hex.js} +0 -34
- package/dist/es2019/presets/remove-token-fallbacks/utils/{reporter.js → combine-reports.js} +1 -50
- package/dist/es2019/presets/remove-token-fallbacks/utils/compare-hex.js +17 -0
- package/dist/es2019/presets/remove-token-fallbacks/utils/is-valid-color.js +35 -0
- package/dist/es2019/presets/remove-token-fallbacks/utils/normalize-values.js +3 -1
- package/dist/es2019/presets/remove-token-fallbacks/utils/write-reports.js +41 -0
- package/dist/es2019/sinceRef.js +1 -1
- package/dist/es2019/types.js +1 -7
- package/dist/es2019/validation-error.js +1 -0
- package/dist/esm/cli.js +2 -1
- package/dist/esm/get-transform-module.js +7 -0
- package/dist/esm/get-transform-path.js +5 -0
- package/dist/esm/get-transform-version.js +9 -0
- package/dist/esm/{transforms.js → get-transforms.js} +16 -42
- package/dist/esm/has-transform.js +4 -0
- package/dist/esm/index.js +1 -2
- package/dist/esm/main.js +7 -2
- package/dist/esm/no-transforms-exist-error.js +16 -0
- package/dist/esm/parse-transform-path.js +4 -0
- package/dist/esm/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.js +16 -0
- package/dist/esm/presets/migrate-deprecated-icon/utils/{mock.js → mock-metadata.js} +0 -16
- package/dist/esm/presets/migrate-icon-object-to-object/codemods/migrate-icon-object-to-object.js +3 -1
- package/dist/esm/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.js +6 -0
- package/dist/esm/presets/migrate-icon-object-to-object/utils/get-new-import-info.js +22 -0
- package/dist/esm/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.js +7 -0
- package/dist/esm/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.js +22 -0
- package/dist/esm/presets/migrate-to-link/codemods/migrate-to-link.js +3 -1
- package/dist/esm/presets/migrate-to-link/utils/comments.js +1 -12
- package/dist/esm/presets/migrate-to-link/utils/generic-unsupported-migration-comment.js +5 -0
- package/dist/esm/presets/migrate-to-link/utils/style-prop-comment.js +6 -0
- package/dist/esm/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +1 -1
- package/dist/esm/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +5 -3
- package/dist/esm/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.js +5 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.js → find-variant-already-imported.js} +0 -4
- package/dist/esm/presets/migrate-to-new-buttons/utils/{generate-link-element.js → generate-link-component.js} +1 -10
- package/dist/esm/presets/migrate-to-new-buttons/utils/generate-new-element.js +41 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/get-icon-attributes.js +9 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/get-icon-element.js +7 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/handle-icon-attributes.js +75 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/migrate-fit-container-icon-button.js +2 -1
- package/dist/esm/presets/migrate-to-new-buttons/utils/modify-button-attributes.js +12 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/modify-link-attributes.js +10 -0
- package/dist/esm/presets/remove-token-fallbacks/after-all.js +331 -0
- package/dist/esm/presets/remove-token-fallbacks/before-all.js +27 -0
- package/dist/esm/presets/remove-token-fallbacks/remove-token-fallbacks.js +2 -357
- package/dist/esm/presets/remove-token-fallbacks/utils/clear-folder.js +62 -0
- package/dist/esm/presets/remove-token-fallbacks/utils/{color-utils.js → color-to-hex.js} +0 -36
- package/dist/esm/presets/remove-token-fallbacks/utils/{reporter.js → combine-reports.js} +57 -180
- package/dist/esm/presets/remove-token-fallbacks/utils/compare-hex.js +19 -0
- package/dist/esm/presets/remove-token-fallbacks/utils/is-valid-color.js +35 -0
- package/dist/esm/presets/remove-token-fallbacks/utils/normalize-values.js +3 -1
- package/dist/esm/presets/remove-token-fallbacks/utils/write-reports.js +75 -0
- package/dist/esm/sinceRef.js +1 -1
- package/dist/esm/types.js +1 -29
- package/dist/esm/validation-error.js +16 -0
- package/dist/types/get-transform-module.d.ts +2 -0
- package/dist/types/get-transform-path.d.ts +2 -0
- package/dist/types/get-transform-version.d.ts +2 -0
- package/dist/types/get-transforms.d.ts +3 -0
- package/dist/types/has-transform.d.ts +1 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/main.d.ts +1 -1
- package/dist/types/no-transforms-exist-error.d.ts +2 -0
- package/dist/types/parse-transform-path.d.ts +2 -0
- package/dist/types/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.d.ts +16 -0
- package/dist/types/presets/migrate-deprecated-icon/utils/{mock.d.ts → mock-metadata.d.ts} +0 -16
- package/dist/types/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.d.ts +1 -0
- package/dist/types/presets/migrate-icon-object-to-object/utils/get-new-import-info.d.ts +4 -0
- package/dist/types/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.d.ts +1 -0
- package/dist/types/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.d.ts +4 -0
- package/dist/types/presets/migrate-to-link/utils/comments.d.ts +0 -5
- package/dist/types/presets/migrate-to-link/utils/generic-unsupported-migration-comment.d.ts +1 -0
- package/dist/types/presets/migrate-to-link/utils/style-prop-comment.d.ts +4 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.d.ts +2 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.d.ts → find-variant-already-imported.d.ts} +0 -1
- package/dist/types/presets/migrate-to-new-buttons/utils/{generate-link-element.d.ts → generate-link-component.d.ts} +0 -1
- package/dist/types/presets/migrate-to-new-buttons/utils/generate-new-element.d.ts +3 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/get-icon-attributes.d.ts +2 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/get-icon-element.d.ts +2 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/handle-icon-attributes.d.ts +2 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/modify-button-attributes.d.ts +2 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/modify-link-attributes.d.ts +2 -0
- package/dist/types/presets/remove-token-fallbacks/after-all.d.ts +2 -0
- package/dist/types/presets/remove-token-fallbacks/before-all.d.ts +2 -0
- package/dist/types/presets/remove-token-fallbacks/remove-token-fallbacks.d.ts +0 -9
- package/dist/types/presets/remove-token-fallbacks/utils/clear-folder.d.ts +1 -0
- package/dist/types/presets/remove-token-fallbacks/utils/color-to-hex.d.ts +1 -0
- package/dist/types/presets/remove-token-fallbacks/utils/combine-reports.d.ts +1 -0
- package/dist/types/presets/remove-token-fallbacks/utils/compare-hex.d.ts +1 -0
- package/dist/types/presets/remove-token-fallbacks/utils/is-valid-color.d.ts +1 -0
- package/dist/types/presets/remove-token-fallbacks/utils/{reporter.d.ts → write-reports.d.ts} +0 -2
- package/dist/types/sinceRef.d.ts +1 -1
- package/dist/types/types.d.ts +0 -4
- package/dist/types/validation-error.d.ts +2 -0
- package/dist/types-ts4.5/get-transform-module.d.ts +2 -0
- package/dist/types-ts4.5/get-transform-path.d.ts +2 -0
- package/dist/types-ts4.5/get-transform-version.d.ts +2 -0
- package/dist/types-ts4.5/get-transforms.d.ts +3 -0
- package/dist/types-ts4.5/has-transform.d.ts +1 -0
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/main.d.ts +1 -1
- package/dist/types-ts4.5/no-transforms-exist-error.d.ts +2 -0
- package/dist/types-ts4.5/parse-transform-path.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.d.ts +16 -0
- package/dist/types-ts4.5/presets/migrate-deprecated-icon/utils/{mock.d.ts → mock-metadata.d.ts} +0 -16
- package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.d.ts +1 -0
- package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/get-new-import-info.d.ts +4 -0
- package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.d.ts +1 -0
- package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.d.ts +4 -0
- package/dist/types-ts4.5/presets/migrate-to-link/utils/comments.d.ts +0 -5
- package/dist/types-ts4.5/presets/migrate-to-link/utils/generic-unsupported-migration-comment.d.ts +1 -0
- package/dist/types-ts4.5/presets/migrate-to-link/utils/style-prop-comment.d.ts +4 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.d.ts → find-variant-already-imported.d.ts} +0 -1
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/{generate-link-element.d.ts → generate-link-component.d.ts} +0 -1
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-new-element.d.ts +3 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/get-icon-attributes.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/get-icon-element.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/handle-icon-attributes.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/modify-button-attributes.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/modify-link-attributes.d.ts +2 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/after-all.d.ts +2 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/before-all.d.ts +2 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/remove-token-fallbacks.d.ts +0 -9
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/clear-folder.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/color-to-hex.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/combine-reports.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/compare-hex.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/is-valid-color.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/{reporter.d.ts → write-reports.d.ts} +0 -2
- package/dist/types-ts4.5/sinceRef.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +0 -4
- package/dist/types-ts4.5/validation-error.d.ts +2 -0
- package/package.json +2 -2
- package/dist/cjs/presets/migrate-icon-object-to-object/utils/icon-mappings.js +0 -81
- package/dist/cjs/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +0 -160
- package/dist/es2019/presets/migrate-icon-object-to-object/utils/icon-mappings.js +0 -67
- package/dist/es2019/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +0 -143
- package/dist/esm/presets/migrate-icon-object-to-object/utils/icon-mappings.js +0 -72
- package/dist/esm/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +0 -154
- package/dist/types/presets/migrate-icon-object-to-object/utils/icon-mappings.d.ts +0 -29
- package/dist/types/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +0 -20
- package/dist/types/presets/remove-token-fallbacks/utils/color-utils.d.ts +0 -3
- package/dist/types/transforms.d.ts +0 -11
- package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/icon-mappings.d.ts +0 -29
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +0 -20
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/color-utils.d.ts +0 -3
- package/dist/types-ts4.5/transforms.d.ts +0 -11
- package/transforms/package.json +0 -14
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
5
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
6
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
7
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
4
|
/* eslint-disable no-console */
|
|
9
|
-
import { exec } from 'child_process';
|
|
10
|
-
import fs from 'fs/promises';
|
|
11
5
|
import path from 'path';
|
|
12
|
-
import { promisify } from 'util';
|
|
13
6
|
import { hasImportDeclaration } from '@hypermod/utils';
|
|
14
7
|
import { findRoot } from '@manypkg/find-root';
|
|
15
8
|
import chalk from 'chalk';
|
|
16
9
|
import { getTokenMap } from './utils/all-tokens';
|
|
17
|
-
import { chunkArray } from './utils/chunk';
|
|
18
10
|
import { getTeamInfo } from './utils/get-team-info';
|
|
19
11
|
import { removeUnusedImports } from './utils/remove-unused-imports';
|
|
20
12
|
import { removeUnusedVariables } from './utils/remove-unused-variables';
|
|
21
|
-
import { clearFolder, combineReports, writeReports } from './utils/reporter';
|
|
22
13
|
import { TokenProcessor } from './utils/token-processor';
|
|
23
|
-
|
|
14
|
+
import { writeReports } from './utils/write-reports';
|
|
24
15
|
|
|
25
16
|
/**
|
|
26
17
|
* Transforms the source code of a file by removing fallback values from the @atlaskit/tokens/token functions.
|
|
@@ -174,350 +165,4 @@ function _transformer() {
|
|
|
174
165
|
}));
|
|
175
166
|
return _transformer.apply(this, arguments);
|
|
176
167
|
}
|
|
177
|
-
export var parser = 'tsx';
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Function executed before all transformations to prepare the environment by clearing the report folder.
|
|
181
|
-
*/
|
|
182
|
-
export function beforeAll(_x4) {
|
|
183
|
-
return _beforeAll.apply(this, arguments);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Function executed after all transformations to combine individual file reports into a comprehensive transformation report.
|
|
188
|
-
* It also applies prettier and eslint (to remove dangling suppressions) to the affected files.
|
|
189
|
-
*/
|
|
190
|
-
function _beforeAll() {
|
|
191
|
-
_beforeAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
192
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
193
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
194
|
-
case 0:
|
|
195
|
-
if (!options.reportFolder) {
|
|
196
|
-
_context2.next = 3;
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
_context2.next = 3;
|
|
200
|
-
return clearFolder(options.reportFolder);
|
|
201
|
-
case 3:
|
|
202
|
-
case "end":
|
|
203
|
-
return _context2.stop();
|
|
204
|
-
}
|
|
205
|
-
}, _callee2);
|
|
206
|
-
}));
|
|
207
|
-
return _beforeAll.apply(this, arguments);
|
|
208
|
-
}
|
|
209
|
-
export function afterAll(_x5) {
|
|
210
|
-
return _afterAll.apply(this, arguments);
|
|
211
|
-
}
|
|
212
|
-
function _afterAll() {
|
|
213
|
-
_afterAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
|
|
214
|
-
var filesTxtPath, fileContent, filePaths, firstFilePath, rootDir;
|
|
215
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
216
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
217
|
-
case 0:
|
|
218
|
-
if (!options.reportFolder) {
|
|
219
|
-
_context3.next = 3;
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
_context3.next = 3;
|
|
223
|
-
return combineReports(options.reportFolder);
|
|
224
|
-
case 3:
|
|
225
|
-
if (!(options.reportFolder && !options.dry)) {
|
|
226
|
-
_context3.next = 35;
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
_context3.prev = 4;
|
|
230
|
-
filesTxtPath = path.join(options.reportFolder, 'files.txt');
|
|
231
|
-
_context3.next = 8;
|
|
232
|
-
return fs.readFile(filesTxtPath, 'utf-8');
|
|
233
|
-
case 8:
|
|
234
|
-
fileContent = _context3.sent;
|
|
235
|
-
if (!(fileContent.length > 0)) {
|
|
236
|
-
_context3.next = 30;
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
filePaths = fileContent.split(/\r?\n/).filter(Boolean); // Get the first file path and strip any quotes
|
|
240
|
-
firstFilePath = filePaths[0].replace(/^['"]|['"]$/g, ''); // Determine the root directory using findRoot
|
|
241
|
-
_context3.next = 14;
|
|
242
|
-
return findRoot(path.dirname(firstFilePath));
|
|
243
|
-
case 14:
|
|
244
|
-
rootDir = _context3.sent;
|
|
245
|
-
console.log('Root directory:', rootDir);
|
|
246
|
-
_context3.next = 18;
|
|
247
|
-
return gitStage(filePaths, rootDir);
|
|
248
|
-
case 18:
|
|
249
|
-
if (options.skipEslint) {
|
|
250
|
-
_context3.next = 23;
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
_context3.next = 21;
|
|
254
|
-
return runEslint(filePaths, rootDir);
|
|
255
|
-
case 21:
|
|
256
|
-
_context3.next = 24;
|
|
257
|
-
break;
|
|
258
|
-
case 23:
|
|
259
|
-
if (options.verbose) {
|
|
260
|
-
console.log(chalk.blue('Skipping ESLint post-processing as requested.'));
|
|
261
|
-
}
|
|
262
|
-
case 24:
|
|
263
|
-
if (options.skipPrettier) {
|
|
264
|
-
_context3.next = 29;
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
_context3.next = 27;
|
|
268
|
-
return runPrettier(filePaths, rootDir);
|
|
269
|
-
case 27:
|
|
270
|
-
_context3.next = 30;
|
|
271
|
-
break;
|
|
272
|
-
case 29:
|
|
273
|
-
if (options.verbose) {
|
|
274
|
-
console.log(chalk.blue('Skipping Prettier post-processing as requested.'));
|
|
275
|
-
}
|
|
276
|
-
case 30:
|
|
277
|
-
_context3.next = 35;
|
|
278
|
-
break;
|
|
279
|
-
case 32:
|
|
280
|
-
_context3.prev = 32;
|
|
281
|
-
_context3.t0 = _context3["catch"](4);
|
|
282
|
-
if (_context3.t0 instanceof Error) {
|
|
283
|
-
console.error(chalk.red("Unexpected error: ".concat(_context3.t0.message)));
|
|
284
|
-
} else {
|
|
285
|
-
console.error(chalk.red('An unknown error occurred.'));
|
|
286
|
-
}
|
|
287
|
-
case 35:
|
|
288
|
-
case "end":
|
|
289
|
-
return _context3.stop();
|
|
290
|
-
}
|
|
291
|
-
}, _callee3, null, [[4, 32]]);
|
|
292
|
-
}));
|
|
293
|
-
return _afterAll.apply(this, arguments);
|
|
294
|
-
}
|
|
295
|
-
function gitStage(_x6, _x7) {
|
|
296
|
-
return _gitStage.apply(this, arguments);
|
|
297
|
-
}
|
|
298
|
-
function _gitStage() {
|
|
299
|
-
_gitStage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(filePaths, cwd) {
|
|
300
|
-
var gitAddCommand, _yield$execAsync, gitAddStdout, gitAddStderr;
|
|
301
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
302
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
303
|
-
case 0:
|
|
304
|
-
gitAddCommand = "git add ".concat(filePaths.join(' '));
|
|
305
|
-
console.log("Executing command: ".concat(gitAddCommand));
|
|
306
|
-
_context4.next = 4;
|
|
307
|
-
return execAsync(gitAddCommand, {
|
|
308
|
-
cwd: cwd
|
|
309
|
-
});
|
|
310
|
-
case 4:
|
|
311
|
-
_yield$execAsync = _context4.sent;
|
|
312
|
-
gitAddStdout = _yield$execAsync.stdout;
|
|
313
|
-
gitAddStderr = _yield$execAsync.stderr;
|
|
314
|
-
if (gitAddStdout) {
|
|
315
|
-
console.log(chalk.blue("Git add output:\n".concat(gitAddStdout)));
|
|
316
|
-
}
|
|
317
|
-
if (gitAddStderr) {
|
|
318
|
-
console.error(chalk.yellow("Git add errors:\n".concat(gitAddStderr)));
|
|
319
|
-
}
|
|
320
|
-
console.log(chalk.green("All changes have been staged."));
|
|
321
|
-
case 10:
|
|
322
|
-
case "end":
|
|
323
|
-
return _context4.stop();
|
|
324
|
-
}
|
|
325
|
-
}, _callee4);
|
|
326
|
-
}));
|
|
327
|
-
return _gitStage.apply(this, arguments);
|
|
328
|
-
}
|
|
329
|
-
function runPrettier(_x8, _x9) {
|
|
330
|
-
return _runPrettier.apply(this, arguments);
|
|
331
|
-
}
|
|
332
|
-
function _runPrettier() {
|
|
333
|
-
_runPrettier = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(filePaths, cwd) {
|
|
334
|
-
var prettierCommand, _yield$execAsync2, prettierStdout, prettierStderr;
|
|
335
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
336
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
337
|
-
case 0:
|
|
338
|
-
prettierCommand = "yarn prettier --write ".concat(filePaths.join(' '));
|
|
339
|
-
console.log("Executing command: ".concat(prettierCommand));
|
|
340
|
-
_context5.next = 4;
|
|
341
|
-
return execAsync(prettierCommand, {
|
|
342
|
-
cwd: cwd
|
|
343
|
-
});
|
|
344
|
-
case 4:
|
|
345
|
-
_yield$execAsync2 = _context5.sent;
|
|
346
|
-
prettierStdout = _yield$execAsync2.stdout;
|
|
347
|
-
prettierStderr = _yield$execAsync2.stderr;
|
|
348
|
-
if (prettierStdout) {
|
|
349
|
-
console.log(chalk.blue("Prettier output:\n".concat(prettierStdout)));
|
|
350
|
-
}
|
|
351
|
-
if (prettierStderr) {
|
|
352
|
-
console.error(chalk.yellow("Prettier errors:\n".concat(prettierStderr)));
|
|
353
|
-
}
|
|
354
|
-
console.log(chalk.green("Prettier was run successfully"));
|
|
355
|
-
case 10:
|
|
356
|
-
case "end":
|
|
357
|
-
return _context5.stop();
|
|
358
|
-
}
|
|
359
|
-
}, _callee5);
|
|
360
|
-
}));
|
|
361
|
-
return _runPrettier.apply(this, arguments);
|
|
362
|
-
}
|
|
363
|
-
function runEslint(_x0, _x1) {
|
|
364
|
-
return _runEslint.apply(this, arguments);
|
|
365
|
-
}
|
|
366
|
-
function _runEslint() {
|
|
367
|
-
_runEslint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(filePaths, cwd) {
|
|
368
|
-
var fileChunks, totalChunks, _iterator, _step, _loop;
|
|
369
|
-
return _regeneratorRuntime.wrap(function _callee7$(_context9) {
|
|
370
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
371
|
-
case 0:
|
|
372
|
-
fileChunks = chunkArray(filePaths, 20);
|
|
373
|
-
totalChunks = fileChunks.length;
|
|
374
|
-
_iterator = _createForOfIteratorHelper(fileChunks.entries());
|
|
375
|
-
_context9.prev = 3;
|
|
376
|
-
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
377
|
-
var _step$value, chunkIndex, fileChunk, eslintCommand, result, stdout, stderr, smallerChunks, totalSmallerChunks, _iterator2, _step2, _loop2;
|
|
378
|
-
return _regeneratorRuntime.wrap(function _loop$(_context8) {
|
|
379
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
380
|
-
case 0:
|
|
381
|
-
_step$value = _slicedToArray(_step.value, 2), chunkIndex = _step$value[0], fileChunk = _step$value[1];
|
|
382
|
-
eslintCommand = "yarn eslint ".concat(fileChunk.join(' '), " --report-unused-disable-directives --fix");
|
|
383
|
-
console.log("Executing command for chunk ".concat(chunkIndex + 1, " of ").concat(totalChunks, ": ").concat(eslintCommand));
|
|
384
|
-
_context8.prev = 3;
|
|
385
|
-
_context8.next = 6;
|
|
386
|
-
return execAsync(eslintCommand, {
|
|
387
|
-
cwd: cwd
|
|
388
|
-
});
|
|
389
|
-
case 6:
|
|
390
|
-
result = _context8.sent;
|
|
391
|
-
stdout = result.stdout, stderr = result.stderr;
|
|
392
|
-
if (stdout) {
|
|
393
|
-
console.log(chalk.blue("ESLint output for chunk ".concat(chunkIndex + 1, " of ").concat(totalChunks, ":\n").concat(stdout)));
|
|
394
|
-
}
|
|
395
|
-
if (stderr) {
|
|
396
|
-
console.error(chalk.yellow("ESLint errors for chunk ".concat(chunkIndex + 1, " of ").concat(totalChunks, ":\n").concat(stderr)));
|
|
397
|
-
}
|
|
398
|
-
_context8.next = 34;
|
|
399
|
-
break;
|
|
400
|
-
case 12:
|
|
401
|
-
_context8.prev = 12;
|
|
402
|
-
_context8.t0 = _context8["catch"](3);
|
|
403
|
-
console.error(chalk.red("Error running ESLint on chunk ".concat(chunkIndex + 1, " of ").concat(totalChunks, ": ").concat(_context8.t0)));
|
|
404
|
-
|
|
405
|
-
// Retry each file individually
|
|
406
|
-
console.log(chalk.yellow("Retrying each file in chunk ".concat(chunkIndex + 1, " of ").concat(totalChunks, " individually...")));
|
|
407
|
-
|
|
408
|
-
// Chunk the files into smaller groups of 5 for parallel retry
|
|
409
|
-
smallerChunks = chunkArray(fileChunk, 5);
|
|
410
|
-
totalSmallerChunks = smallerChunks.length;
|
|
411
|
-
_iterator2 = _createForOfIteratorHelper(smallerChunks.entries());
|
|
412
|
-
_context8.prev = 19;
|
|
413
|
-
_loop2 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop2() {
|
|
414
|
-
var _step2$value, smallChunkIndex, smallerChunk;
|
|
415
|
-
return _regeneratorRuntime.wrap(function _loop2$(_context7) {
|
|
416
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
417
|
-
case 0:
|
|
418
|
-
_step2$value = _slicedToArray(_step2.value, 2), smallChunkIndex = _step2$value[0], smallerChunk = _step2$value[1];
|
|
419
|
-
_context7.next = 3;
|
|
420
|
-
return Promise.all(smallerChunk.map( /*#__PURE__*/function () {
|
|
421
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(file) {
|
|
422
|
-
var individualEslintCommand, _result, _stdout, _stderr;
|
|
423
|
-
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
424
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
425
|
-
case 0:
|
|
426
|
-
_context6.prev = 0;
|
|
427
|
-
individualEslintCommand = "yarn eslint ".concat(file, " --report-unused-disable-directives --fix");
|
|
428
|
-
console.log("Executing command for file in small chunk ".concat(smallChunkIndex + 1, " of ").concat(totalSmallerChunks, ": ").concat(individualEslintCommand));
|
|
429
|
-
_context6.next = 5;
|
|
430
|
-
return execAsync(individualEslintCommand, {
|
|
431
|
-
cwd: cwd
|
|
432
|
-
});
|
|
433
|
-
case 5:
|
|
434
|
-
_result = _context6.sent;
|
|
435
|
-
_stdout = _result.stdout, _stderr = _result.stderr;
|
|
436
|
-
if (_stdout) {
|
|
437
|
-
console.log(chalk.blue("ESLint output for file ".concat(file, " in small chunk ").concat(smallChunkIndex + 1, " of ").concat(totalSmallerChunks, ":\n").concat(_stdout)));
|
|
438
|
-
}
|
|
439
|
-
if (_stderr) {
|
|
440
|
-
console.error(chalk.yellow("ESLint errors for file ".concat(file, " in small chunk ").concat(smallChunkIndex + 1, " of ").concat(totalSmallerChunks, ":\n").concat(_stderr)));
|
|
441
|
-
}
|
|
442
|
-
_context6.next = 14;
|
|
443
|
-
break;
|
|
444
|
-
case 11:
|
|
445
|
-
_context6.prev = 11;
|
|
446
|
-
_context6.t0 = _context6["catch"](0);
|
|
447
|
-
console.error(chalk.red("Error running ESLint on file ".concat(file, " in small chunk ").concat(smallChunkIndex + 1, " of ").concat(totalSmallerChunks, ": ").concat(_context6.t0)));
|
|
448
|
-
case 14:
|
|
449
|
-
case "end":
|
|
450
|
-
return _context6.stop();
|
|
451
|
-
}
|
|
452
|
-
}, _callee6, null, [[0, 11]]);
|
|
453
|
-
}));
|
|
454
|
-
return function (_x10) {
|
|
455
|
-
return _ref2.apply(this, arguments);
|
|
456
|
-
};
|
|
457
|
-
}()));
|
|
458
|
-
case 3:
|
|
459
|
-
case "end":
|
|
460
|
-
return _context7.stop();
|
|
461
|
-
}
|
|
462
|
-
}, _loop2);
|
|
463
|
-
});
|
|
464
|
-
_iterator2.s();
|
|
465
|
-
case 22:
|
|
466
|
-
if ((_step2 = _iterator2.n()).done) {
|
|
467
|
-
_context8.next = 26;
|
|
468
|
-
break;
|
|
469
|
-
}
|
|
470
|
-
return _context8.delegateYield(_loop2(), "t1", 24);
|
|
471
|
-
case 24:
|
|
472
|
-
_context8.next = 22;
|
|
473
|
-
break;
|
|
474
|
-
case 26:
|
|
475
|
-
_context8.next = 31;
|
|
476
|
-
break;
|
|
477
|
-
case 28:
|
|
478
|
-
_context8.prev = 28;
|
|
479
|
-
_context8.t2 = _context8["catch"](19);
|
|
480
|
-
_iterator2.e(_context8.t2);
|
|
481
|
-
case 31:
|
|
482
|
-
_context8.prev = 31;
|
|
483
|
-
_iterator2.f();
|
|
484
|
-
return _context8.finish(31);
|
|
485
|
-
case 34:
|
|
486
|
-
console.log(chalk.green("Finished running ESLint for chunk ".concat(chunkIndex + 1, " of ").concat(totalChunks, ".")));
|
|
487
|
-
case 35:
|
|
488
|
-
case "end":
|
|
489
|
-
return _context8.stop();
|
|
490
|
-
}
|
|
491
|
-
}, _loop, null, [[3, 12], [19, 28, 31, 34]]);
|
|
492
|
-
});
|
|
493
|
-
_iterator.s();
|
|
494
|
-
case 6:
|
|
495
|
-
if ((_step = _iterator.n()).done) {
|
|
496
|
-
_context9.next = 10;
|
|
497
|
-
break;
|
|
498
|
-
}
|
|
499
|
-
return _context9.delegateYield(_loop(), "t0", 8);
|
|
500
|
-
case 8:
|
|
501
|
-
_context9.next = 6;
|
|
502
|
-
break;
|
|
503
|
-
case 10:
|
|
504
|
-
_context9.next = 15;
|
|
505
|
-
break;
|
|
506
|
-
case 12:
|
|
507
|
-
_context9.prev = 12;
|
|
508
|
-
_context9.t1 = _context9["catch"](3);
|
|
509
|
-
_iterator.e(_context9.t1);
|
|
510
|
-
case 15:
|
|
511
|
-
_context9.prev = 15;
|
|
512
|
-
_iterator.f();
|
|
513
|
-
return _context9.finish(15);
|
|
514
|
-
case 18:
|
|
515
|
-
console.log(chalk.green("ESLint was run on all files successfully"));
|
|
516
|
-
case 19:
|
|
517
|
-
case "end":
|
|
518
|
-
return _context9.stop();
|
|
519
|
-
}
|
|
520
|
-
}, _callee7, null, [[3, 12, 15, 18]]);
|
|
521
|
-
}));
|
|
522
|
-
return _runEslint.apply(this, arguments);
|
|
523
|
-
}
|
|
168
|
+
export var parser = 'tsx';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
4
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
6
|
+
/* eslint-disable no-console */
|
|
7
|
+
import fs from 'fs/promises';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
export function clearFolder(_x) {
|
|
10
|
+
return _clearFolder.apply(this, arguments);
|
|
11
|
+
}
|
|
12
|
+
function _clearFolder() {
|
|
13
|
+
_clearFolder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(reportFolder) {
|
|
14
|
+
var filesToDelete, _iterator, _step, file, filePath;
|
|
15
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
16
|
+
while (1) switch (_context.prev = _context.next) {
|
|
17
|
+
case 0:
|
|
18
|
+
console.log('Clearing report folder:', reportFolder);
|
|
19
|
+
// Create the folder if it doesn't exist
|
|
20
|
+
_context.next = 3;
|
|
21
|
+
return fs.mkdir(reportFolder, {
|
|
22
|
+
recursive: true
|
|
23
|
+
});
|
|
24
|
+
case 3:
|
|
25
|
+
_context.next = 5;
|
|
26
|
+
return fs.readdir(reportFolder);
|
|
27
|
+
case 5:
|
|
28
|
+
filesToDelete = _context.sent;
|
|
29
|
+
_iterator = _createForOfIteratorHelper(filesToDelete);
|
|
30
|
+
_context.prev = 7;
|
|
31
|
+
_iterator.s();
|
|
32
|
+
case 9:
|
|
33
|
+
if ((_step = _iterator.n()).done) {
|
|
34
|
+
_context.next = 16;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
file = _step.value;
|
|
38
|
+
filePath = path.join(reportFolder, file);
|
|
39
|
+
_context.next = 14;
|
|
40
|
+
return fs.unlink(filePath);
|
|
41
|
+
case 14:
|
|
42
|
+
_context.next = 9;
|
|
43
|
+
break;
|
|
44
|
+
case 16:
|
|
45
|
+
_context.next = 21;
|
|
46
|
+
break;
|
|
47
|
+
case 18:
|
|
48
|
+
_context.prev = 18;
|
|
49
|
+
_context.t0 = _context["catch"](7);
|
|
50
|
+
_iterator.e(_context.t0);
|
|
51
|
+
case 21:
|
|
52
|
+
_context.prev = 21;
|
|
53
|
+
_iterator.f();
|
|
54
|
+
return _context.finish(21);
|
|
55
|
+
case 24:
|
|
56
|
+
case "end":
|
|
57
|
+
return _context.stop();
|
|
58
|
+
}
|
|
59
|
+
}, _callee, null, [[7, 18, 21, 24]]);
|
|
60
|
+
}));
|
|
61
|
+
return _clearFolder.apply(this, arguments);
|
|
62
|
+
}
|
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
import { diff, rgb_to_lab } from 'color-diff';
|
|
2
|
-
|
|
3
|
-
// Compare hex values using a CIEDE2000 color difference algorithm
|
|
4
|
-
export var compareHex = function compareHex(hex, hex2) {
|
|
5
|
-
return diff(rgb_to_lab(hexToRgbA(hex)), rgb_to_lab(hexToRgbA(hex2)));
|
|
6
|
-
};
|
|
7
|
-
function hexToRgbA(hex) {
|
|
8
|
-
// Remove the leading '#' if present
|
|
9
|
-
hex = hex.replace(/^#/, '');
|
|
10
|
-
// Parse the hex string
|
|
11
|
-
var r = parseInt(hex.substring(0, 2), 16);
|
|
12
|
-
var g = parseInt(hex.substring(2, 4), 16);
|
|
13
|
-
var b = parseInt(hex.substring(4, 6), 16);
|
|
14
|
-
var a = parseInt(hex.substring(6, 8), 16) / 255;
|
|
15
|
-
return {
|
|
16
|
-
R: r,
|
|
17
|
-
G: g,
|
|
18
|
-
B: b,
|
|
19
|
-
A: a
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
1
|
var namedColors = {
|
|
23
2
|
black: '#000000',
|
|
24
3
|
silver: '#C0C0C0',
|
|
@@ -39,21 +18,6 @@ var namedColors = {
|
|
|
39
18
|
teal: '#008080',
|
|
40
19
|
aqua: '#00FFFF'
|
|
41
20
|
};
|
|
42
|
-
export function isValidColor(color) {
|
|
43
|
-
// Check if it's a named color
|
|
44
|
-
if (namedColors[color.toLowerCase()]) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
// Check for hex colors (including those with alpha)
|
|
48
|
-
if (/^#([0-9A-F]{3}){1,2}([0-9A-F]{2})?$/i.test(color)) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
// Check for rgba() values
|
|
52
|
-
if (/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*(?:0?\.)?\d+\s*)?\)$/i.test(color)) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
21
|
export function colorToHex(color) {
|
|
58
22
|
// Handle named colors
|
|
59
23
|
if (namedColors[color.toLowerCase()]) {
|