@atlaskit/codemod-cli 0.34.8 → 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 +13 -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 +4 -4
- 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,19 +1,14 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import { exec } from 'child_process';
|
|
3
|
-
import fs from 'fs/promises';
|
|
4
2
|
import path from 'path';
|
|
5
|
-
import { promisify } from 'util';
|
|
6
3
|
import { hasImportDeclaration } from '@hypermod/utils';
|
|
7
4
|
import { findRoot } from '@manypkg/find-root';
|
|
8
5
|
import chalk from 'chalk';
|
|
9
6
|
import { getTokenMap } from './utils/all-tokens';
|
|
10
|
-
import { chunkArray } from './utils/chunk';
|
|
11
7
|
import { getTeamInfo } from './utils/get-team-info';
|
|
12
8
|
import { removeUnusedImports } from './utils/remove-unused-imports';
|
|
13
9
|
import { removeUnusedVariables } from './utils/remove-unused-variables';
|
|
14
|
-
import { clearFolder, combineReports, writeReports } from './utils/reporter';
|
|
15
10
|
import { TokenProcessor } from './utils/token-processor';
|
|
16
|
-
|
|
11
|
+
import { writeReports } from './utils/write-reports';
|
|
17
12
|
|
|
18
13
|
/**
|
|
19
14
|
* Transforms the source code of a file by removing fallback values from the @atlaskit/tokens/token functions.
|
|
@@ -130,147 +125,4 @@ export default async function transformer(fileInfo, {
|
|
|
130
125
|
return fileInfo.source;
|
|
131
126
|
}
|
|
132
127
|
}
|
|
133
|
-
export const parser = 'tsx';
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Function executed before all transformations to prepare the environment by clearing the report folder.
|
|
137
|
-
*/
|
|
138
|
-
export async function beforeAll(options) {
|
|
139
|
-
if (options.reportFolder) {
|
|
140
|
-
await clearFolder(options.reportFolder);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Function executed after all transformations to combine individual file reports into a comprehensive transformation report.
|
|
146
|
-
* It also applies prettier and eslint (to remove dangling suppressions) to the affected files.
|
|
147
|
-
*/
|
|
148
|
-
export async function afterAll(options) {
|
|
149
|
-
if (options.reportFolder) {
|
|
150
|
-
await combineReports(options.reportFolder);
|
|
151
|
-
}
|
|
152
|
-
if (options.reportFolder && !options.dry) {
|
|
153
|
-
try {
|
|
154
|
-
const filesTxtPath = path.join(options.reportFolder, 'files.txt');
|
|
155
|
-
const fileContent = await fs.readFile(filesTxtPath, 'utf-8');
|
|
156
|
-
if (fileContent.length > 0) {
|
|
157
|
-
const filePaths = fileContent.split(/\r?\n/).filter(Boolean);
|
|
158
|
-
|
|
159
|
-
// Get the first file path and strip any quotes
|
|
160
|
-
const firstFilePath = filePaths[0].replace(/^['"]|['"]$/g, '');
|
|
161
|
-
|
|
162
|
-
// Determine the root directory using findRoot
|
|
163
|
-
const rootDir = await findRoot(path.dirname(firstFilePath));
|
|
164
|
-
console.log('Root directory:', rootDir);
|
|
165
|
-
await gitStage(filePaths, rootDir);
|
|
166
|
-
if (!options.skipEslint) {
|
|
167
|
-
await runEslint(filePaths, rootDir);
|
|
168
|
-
} else if (options.verbose) {
|
|
169
|
-
console.log(chalk.blue('Skipping ESLint post-processing as requested.'));
|
|
170
|
-
}
|
|
171
|
-
if (!options.skipPrettier) {
|
|
172
|
-
await runPrettier(filePaths, rootDir);
|
|
173
|
-
} else if (options.verbose) {
|
|
174
|
-
console.log(chalk.blue('Skipping Prettier post-processing as requested.'));
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
} catch (error) {
|
|
178
|
-
if (error instanceof Error) {
|
|
179
|
-
console.error(chalk.red(`Unexpected error: ${error.message}`));
|
|
180
|
-
} else {
|
|
181
|
-
console.error(chalk.red('An unknown error occurred.'));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async function gitStage(filePaths, cwd) {
|
|
187
|
-
const gitAddCommand = `git add ${filePaths.join(' ')}`;
|
|
188
|
-
console.log(`Executing command: ${gitAddCommand}`);
|
|
189
|
-
const {
|
|
190
|
-
stdout: gitAddStdout,
|
|
191
|
-
stderr: gitAddStderr
|
|
192
|
-
} = await execAsync(gitAddCommand, {
|
|
193
|
-
cwd
|
|
194
|
-
});
|
|
195
|
-
if (gitAddStdout) {
|
|
196
|
-
console.log(chalk.blue(`Git add output:\n${gitAddStdout}`));
|
|
197
|
-
}
|
|
198
|
-
if (gitAddStderr) {
|
|
199
|
-
console.error(chalk.yellow(`Git add errors:\n${gitAddStderr}`));
|
|
200
|
-
}
|
|
201
|
-
console.log(chalk.green(`All changes have been staged.`));
|
|
202
|
-
}
|
|
203
|
-
async function runPrettier(filePaths, cwd) {
|
|
204
|
-
const prettierCommand = `yarn prettier --write ${filePaths.join(' ')}`;
|
|
205
|
-
console.log(`Executing command: ${prettierCommand}`);
|
|
206
|
-
const {
|
|
207
|
-
stdout: prettierStdout,
|
|
208
|
-
stderr: prettierStderr
|
|
209
|
-
} = await execAsync(prettierCommand, {
|
|
210
|
-
cwd
|
|
211
|
-
});
|
|
212
|
-
if (prettierStdout) {
|
|
213
|
-
console.log(chalk.blue(`Prettier output:\n${prettierStdout}`));
|
|
214
|
-
}
|
|
215
|
-
if (prettierStderr) {
|
|
216
|
-
console.error(chalk.yellow(`Prettier errors:\n${prettierStderr}`));
|
|
217
|
-
}
|
|
218
|
-
console.log(chalk.green(`Prettier was run successfully`));
|
|
219
|
-
}
|
|
220
|
-
async function runEslint(filePaths, cwd) {
|
|
221
|
-
const fileChunks = chunkArray(filePaths, 20);
|
|
222
|
-
const totalChunks = fileChunks.length;
|
|
223
|
-
for (const [chunkIndex, fileChunk] of fileChunks.entries()) {
|
|
224
|
-
const eslintCommand = `yarn eslint ${fileChunk.join(' ')} --report-unused-disable-directives --fix`;
|
|
225
|
-
console.log(`Executing command for chunk ${chunkIndex + 1} of ${totalChunks}: ${eslintCommand}`);
|
|
226
|
-
try {
|
|
227
|
-
const result = await execAsync(eslintCommand, {
|
|
228
|
-
cwd
|
|
229
|
-
});
|
|
230
|
-
const {
|
|
231
|
-
stdout,
|
|
232
|
-
stderr
|
|
233
|
-
} = result;
|
|
234
|
-
if (stdout) {
|
|
235
|
-
console.log(chalk.blue(`ESLint output for chunk ${chunkIndex + 1} of ${totalChunks}:\n${stdout}`));
|
|
236
|
-
}
|
|
237
|
-
if (stderr) {
|
|
238
|
-
console.error(chalk.yellow(`ESLint errors for chunk ${chunkIndex + 1} of ${totalChunks}:\n${stderr}`));
|
|
239
|
-
}
|
|
240
|
-
} catch (error) {
|
|
241
|
-
console.error(chalk.red(`Error running ESLint on chunk ${chunkIndex + 1} of ${totalChunks}: ${error}`));
|
|
242
|
-
|
|
243
|
-
// Retry each file individually
|
|
244
|
-
console.log(chalk.yellow(`Retrying each file in chunk ${chunkIndex + 1} of ${totalChunks} individually...`));
|
|
245
|
-
|
|
246
|
-
// Chunk the files into smaller groups of 5 for parallel retry
|
|
247
|
-
const smallerChunks = chunkArray(fileChunk, 5);
|
|
248
|
-
const totalSmallerChunks = smallerChunks.length;
|
|
249
|
-
for (const [smallChunkIndex, smallerChunk] of smallerChunks.entries()) {
|
|
250
|
-
await Promise.all(smallerChunk.map(async file => {
|
|
251
|
-
try {
|
|
252
|
-
const individualEslintCommand = `yarn eslint ${file} --report-unused-disable-directives --fix`;
|
|
253
|
-
console.log(`Executing command for file in small chunk ${smallChunkIndex + 1} of ${totalSmallerChunks}: ${individualEslintCommand}`);
|
|
254
|
-
const result = await execAsync(individualEslintCommand, {
|
|
255
|
-
cwd
|
|
256
|
-
});
|
|
257
|
-
const {
|
|
258
|
-
stdout,
|
|
259
|
-
stderr
|
|
260
|
-
} = result;
|
|
261
|
-
if (stdout) {
|
|
262
|
-
console.log(chalk.blue(`ESLint output for file ${file} in small chunk ${smallChunkIndex + 1} of ${totalSmallerChunks}:\n${stdout}`));
|
|
263
|
-
}
|
|
264
|
-
if (stderr) {
|
|
265
|
-
console.error(chalk.yellow(`ESLint errors for file ${file} in small chunk ${smallChunkIndex + 1} of ${totalSmallerChunks}:\n${stderr}`));
|
|
266
|
-
}
|
|
267
|
-
} catch (fileError) {
|
|
268
|
-
console.error(chalk.red(`Error running ESLint on file ${file} in small chunk ${smallChunkIndex + 1} of ${totalSmallerChunks}: ${fileError}`));
|
|
269
|
-
}
|
|
270
|
-
}));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
console.log(chalk.green(`Finished running ESLint for chunk ${chunkIndex + 1} of ${totalChunks}.`));
|
|
274
|
-
}
|
|
275
|
-
console.log(chalk.green(`ESLint was run on all files successfully`));
|
|
276
|
-
}
|
|
128
|
+
export const parser = 'tsx';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
export async function clearFolder(reportFolder) {
|
|
5
|
+
console.log('Clearing report folder:', reportFolder);
|
|
6
|
+
// Create the folder if it doesn't exist
|
|
7
|
+
await fs.mkdir(reportFolder, {
|
|
8
|
+
recursive: true
|
|
9
|
+
});
|
|
10
|
+
const filesToDelete = await fs.readdir(reportFolder);
|
|
11
|
+
for (const file of filesToDelete) {
|
|
12
|
+
const filePath = path.join(reportFolder, file);
|
|
13
|
+
await fs.unlink(filePath);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
import { diff, rgb_to_lab } from 'color-diff';
|
|
2
|
-
|
|
3
|
-
// Compare hex values using a CIEDE2000 color difference algorithm
|
|
4
|
-
export const compareHex = (hex, hex2) => diff(rgb_to_lab(hexToRgbA(hex)), rgb_to_lab(hexToRgbA(hex2)));
|
|
5
|
-
function hexToRgbA(hex) {
|
|
6
|
-
// Remove the leading '#' if present
|
|
7
|
-
hex = hex.replace(/^#/, '');
|
|
8
|
-
// Parse the hex string
|
|
9
|
-
const r = parseInt(hex.substring(0, 2), 16);
|
|
10
|
-
const g = parseInt(hex.substring(2, 4), 16);
|
|
11
|
-
const b = parseInt(hex.substring(4, 6), 16);
|
|
12
|
-
const a = parseInt(hex.substring(6, 8), 16) / 255;
|
|
13
|
-
return {
|
|
14
|
-
R: r,
|
|
15
|
-
G: g,
|
|
16
|
-
B: b,
|
|
17
|
-
A: a
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
1
|
const namedColors = {
|
|
21
2
|
black: '#000000',
|
|
22
3
|
silver: '#C0C0C0',
|
|
@@ -37,21 +18,6 @@ const namedColors = {
|
|
|
37
18
|
teal: '#008080',
|
|
38
19
|
aqua: '#00FFFF'
|
|
39
20
|
};
|
|
40
|
-
export function isValidColor(color) {
|
|
41
|
-
// Check if it's a named color
|
|
42
|
-
if (namedColors[color.toLowerCase()]) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
// Check for hex colors (including those with alpha)
|
|
46
|
-
if (/^#([0-9A-F]{3}){1,2}([0-9A-F]{2})?$/i.test(color)) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
// Check for rgba() values
|
|
50
|
-
if (/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*(?:0?\.)?\d+\s*)?\)$/i.test(color)) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
21
|
export function colorToHex(color) {
|
|
56
22
|
// Handle named colors
|
|
57
23
|
if (namedColors[color.toLowerCase()]) {
|
|
@@ -1,42 +1,11 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
6
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
7
|
-
async function writeToCsv(filePath, data) {
|
|
8
|
-
await fs.writeFile(filePath, data.join('\n'), 'utf-8');
|
|
9
|
-
}
|
|
4
|
+
import { clearFolder } from './clear-folder';
|
|
10
5
|
async function readCsv(filePath) {
|
|
11
6
|
const data = await fs.readFile(filePath, 'utf-8');
|
|
12
7
|
return data.split('\n').filter(line => line.trim() !== '');
|
|
13
8
|
}
|
|
14
|
-
function escapeCsvValue(value) {
|
|
15
|
-
if (!value) {
|
|
16
|
-
return value;
|
|
17
|
-
}
|
|
18
|
-
if (value.includes('"')) {
|
|
19
|
-
// Escape double quotes by doubling them
|
|
20
|
-
value = value.replace(/"/g, '""');
|
|
21
|
-
}
|
|
22
|
-
if (value.includes(',') || value.includes('"') || value.includes('\n')) {
|
|
23
|
-
// Surround the value with double quotes if it contains a comma, double quotes, or newlines
|
|
24
|
-
value = `"${value}"`;
|
|
25
|
-
}
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
export async function clearFolder(reportFolder) {
|
|
29
|
-
console.log('Clearing report folder:', reportFolder);
|
|
30
|
-
// Create the folder if it doesn't exist
|
|
31
|
-
await fs.mkdir(reportFolder, {
|
|
32
|
-
recursive: true
|
|
33
|
-
});
|
|
34
|
-
const filesToDelete = await fs.readdir(reportFolder);
|
|
35
|
-
for (const file of filesToDelete) {
|
|
36
|
-
const filePath = path.join(reportFolder, file);
|
|
37
|
-
await fs.unlink(filePath);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
9
|
async function saveFilePaths(reportFolder, files) {
|
|
41
10
|
const filesTxtPath = path.join(reportFolder, 'files.txt');
|
|
42
11
|
const sortedFiles = Array.from(files).sort(); // Sort the file paths alphabetically
|
|
@@ -106,22 +75,4 @@ export async function combineReports(reportFolder) {
|
|
|
106
75
|
await fs.writeFile(combinedNonReplacementsPath, [header, ...sortedNonReplacements].join('\n'), 'utf-8');
|
|
107
76
|
// Extract unique file paths
|
|
108
77
|
await saveFilePaths(reportFolder, affectedPaths);
|
|
109
|
-
}
|
|
110
|
-
function prepareCsvData(items) {
|
|
111
|
-
return items.map(item => {
|
|
112
|
-
var _item$difference$toFi, _item$difference;
|
|
113
|
-
return [escapeCsvValue(item.teamInfo.teamName), escapeCsvValue(item.teamInfo.packageName), escapeCsvValue(item.filePath), escapeCsvValue(String(item.lineNumber)), escapeCsvValue(item.tokenKey), escapeCsvValue(item.rawFallbackValue), escapeCsvValue(item.resolvedTokenValue), escapeCsvValue(item.resolvedFallbackValue), escapeCsvValue((_item$difference$toFi = (_item$difference = item.difference) === null || _item$difference === void 0 ? void 0 : _item$difference.toFixed(1)) !== null && _item$difference$toFi !== void 0 ? _item$difference$toFi : '')].join(',');
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
export async function writeReports(details, reportFolder) {
|
|
117
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
118
|
-
const replacementsFilePath = path.join(reportFolder, `${uuidv4()}_success.csv`);
|
|
119
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
120
|
-
const nonReplacementsFilePath = path.join(reportFolder, `${uuidv4()}_failed.csv`);
|
|
121
|
-
await fs.mkdir(reportFolder, {
|
|
122
|
-
recursive: true
|
|
123
|
-
});
|
|
124
|
-
const replacementData = prepareCsvData(details.replaced);
|
|
125
|
-
const nonReplacementData = prepareCsvData(details.notReplaced);
|
|
126
|
-
await Promise.all([writeToCsv(replacementsFilePath, replacementData), writeToCsv(nonReplacementsFilePath, nonReplacementData)]);
|
|
127
78
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { diff, rgb_to_lab } from 'color-diff';
|
|
2
|
+
function hexToRgbA(hex) {
|
|
3
|
+
// Remove the leading '#' if present
|
|
4
|
+
hex = hex.replace(/^#/, '');
|
|
5
|
+
// Parse the hex string
|
|
6
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
7
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
8
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
9
|
+
const a = parseInt(hex.substring(6, 8), 16) / 255;
|
|
10
|
+
return {
|
|
11
|
+
R: r,
|
|
12
|
+
G: g,
|
|
13
|
+
B: b,
|
|
14
|
+
A: a
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export const compareHex = (hex, hex2) => diff(rgb_to_lab(hexToRgbA(hex)), rgb_to_lab(hexToRgbA(hex2)));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const namedColors = {
|
|
2
|
+
black: '#000000',
|
|
3
|
+
silver: '#C0C0C0',
|
|
4
|
+
gray: '#808080',
|
|
5
|
+
grey: '#808080',
|
|
6
|
+
pink: '#FFC0CB',
|
|
7
|
+
white: '#FFFFFF',
|
|
8
|
+
maroon: '#800000',
|
|
9
|
+
red: '#FF0000',
|
|
10
|
+
purple: '#800080',
|
|
11
|
+
fuchsia: '#FF00FF',
|
|
12
|
+
green: '#008000',
|
|
13
|
+
lime: '#00FF00',
|
|
14
|
+
olive: '#808000',
|
|
15
|
+
yellow: '#FFFF00',
|
|
16
|
+
navy: '#000080',
|
|
17
|
+
blue: '#0000FF',
|
|
18
|
+
teal: '#008080',
|
|
19
|
+
aqua: '#00FFFF'
|
|
20
|
+
};
|
|
21
|
+
export function isValidColor(color) {
|
|
22
|
+
// Check if it's a named color
|
|
23
|
+
if (namedColors[color.toLowerCase()]) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
// Check for hex colors (including those with alpha)
|
|
27
|
+
if (/^#([0-9A-F]{3}){1,2}([0-9A-F]{2})?$/i.test(color)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
// Check for rgba() values
|
|
31
|
+
if (/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*(?:0?\.)?\d+\s*)?\)$/i.test(color)) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { colorToHex
|
|
2
|
+
import { colorToHex } from './color-to-hex';
|
|
3
|
+
import { compareHex } from './compare-hex';
|
|
4
|
+
import { isValidColor } from './is-valid-color';
|
|
3
5
|
|
|
4
6
|
// Default threshold values
|
|
5
7
|
const DEFAULT_COLOR_DIFFERENCE = 15;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
6
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
7
|
+
function escapeCsvValue(value) {
|
|
8
|
+
if (!value) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
if (value.includes('"')) {
|
|
12
|
+
// Escape double quotes by doubling them
|
|
13
|
+
value = value.replace(/"/g, '""');
|
|
14
|
+
}
|
|
15
|
+
if (value.includes(',') || value.includes('"') || value.includes('\n')) {
|
|
16
|
+
// Surround the value with double quotes if it contains a comma, double quotes, or newlines
|
|
17
|
+
value = `"${value}"`;
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
async function writeToCsv(filePath, data) {
|
|
22
|
+
await fs.writeFile(filePath, data.join('\n'), 'utf-8');
|
|
23
|
+
}
|
|
24
|
+
function prepareCsvData(items) {
|
|
25
|
+
return items.map(item => {
|
|
26
|
+
var _item$difference$toFi, _item$difference;
|
|
27
|
+
return [escapeCsvValue(item.teamInfo.teamName), escapeCsvValue(item.teamInfo.packageName), escapeCsvValue(item.filePath), escapeCsvValue(String(item.lineNumber)), escapeCsvValue(item.tokenKey), escapeCsvValue(item.rawFallbackValue), escapeCsvValue(item.resolvedTokenValue), escapeCsvValue(item.resolvedFallbackValue), escapeCsvValue((_item$difference$toFi = (_item$difference = item.difference) === null || _item$difference === void 0 ? void 0 : _item$difference.toFixed(1)) !== null && _item$difference$toFi !== void 0 ? _item$difference$toFi : '')].join(',');
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export async function writeReports(details, reportFolder) {
|
|
31
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
32
|
+
const replacementsFilePath = path.join(reportFolder, `${uuidv4()}_success.csv`);
|
|
33
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
34
|
+
const nonReplacementsFilePath = path.join(reportFolder, `${uuidv4()}_failed.csv`);
|
|
35
|
+
await fs.mkdir(reportFolder, {
|
|
36
|
+
recursive: true
|
|
37
|
+
});
|
|
38
|
+
const replacementData = prepareCsvData(details.replaced);
|
|
39
|
+
const nonReplacementData = prepareCsvData(details.notReplaced);
|
|
40
|
+
await Promise.all([writeToCsv(replacementsFilePath, replacementData), writeToCsv(nonReplacementsFilePath, nonReplacementData)]);
|
|
41
|
+
}
|
package/dist/es2019/sinceRef.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line @repo/internal/fs/filename-pattern-match
|
|
2
2
|
import simpleGit from 'simple-git';
|
|
3
|
-
import { ValidationError } from './
|
|
3
|
+
import { ValidationError } from './validation-error';
|
|
4
4
|
const packageRegex = /"(@(?:atlaskit|atlassian|atlassiansox)\/.*)": "(.*)"/;
|
|
5
5
|
const parseDiffLine = line => {
|
|
6
6
|
const type = line.startsWith('-') ? 'deleted' : line.startsWith('+') ? 'added' : null;
|
package/dist/es2019/types.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Converts required args to optional if they have a default
|
|
3
|
-
* Example: export type UserFlags = Default<Flags, keyof typeof defaultFlags>;
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export class ValidationError extends Error {}
|
|
7
|
-
export class NoTransformsExistError extends Error {}
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class ValidationError extends Error {}
|
package/dist/esm/cli.js
CHANGED
|
@@ -3,7 +3,8 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import meow from 'meow';
|
|
5
5
|
import main from './main';
|
|
6
|
-
import { NoTransformsExistError
|
|
6
|
+
import { NoTransformsExistError } from './no-transforms-exist-error';
|
|
7
|
+
import { ValidationError } from './validation-error';
|
|
7
8
|
export function run() {
|
|
8
9
|
return _run.apply(this, arguments);
|
|
9
10
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
export var getTransformModule = function getTransformModule(transform) {
|
|
3
|
+
var pathSegments = transform.dir.split(path.sep);
|
|
4
|
+
var nodeModulesIdx = pathSegments.indexOf('node_modules');
|
|
5
|
+
// pathSegments will be of the form [node_modules, '@atlaskit', 'avatar', 'codemods']
|
|
6
|
+
return pathSegments.slice(nodeModulesIdx + 1, nodeModulesIdx + 3).join('/');
|
|
7
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
export var getTransformVersion = function getTransformVersion(transform) {
|
|
3
|
+
var transformName = transform.base;
|
|
4
|
+
if (transformName.startsWith('index.')) {
|
|
5
|
+
var pathSegments = transform.dir.split(path.sep);
|
|
6
|
+
transformName = pathSegments[pathSegments.length - 1];
|
|
7
|
+
}
|
|
8
|
+
return transformName.split('-')[0];
|
|
9
|
+
};
|
|
@@ -2,6 +2,9 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { globSync } from 'glob';
|
|
4
4
|
import semver from 'semver';
|
|
5
|
+
import { getTransformModule } from './get-transform-module';
|
|
6
|
+
import { getTransformVersion } from './get-transform-version';
|
|
7
|
+
import { parseTransformPath } from './parse-transform-path';
|
|
5
8
|
import presets from './presets';
|
|
6
9
|
var basePath = function basePath(packages) {
|
|
7
10
|
var packageDirectory = packages && packages.length > 0 ? ["{".concat(packages.map(function (pkg) {
|
|
@@ -9,48 +12,6 @@ var basePath = function basePath(packages) {
|
|
|
9
12
|
}).join(','), ",}")] : ['@{atlaskit,atlassian,atlassiansox}', '*'];
|
|
10
13
|
return path.join.apply(path, [process.cwd(), 'node_modules'].concat(packageDirectory, ['codemods']));
|
|
11
14
|
};
|
|
12
|
-
export var hasTransform = function hasTransform(transformPath) {
|
|
13
|
-
return globSync(transformPath).length > 0;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Retrieves transforms for `packages` if provided, otherwise all transforms including presets
|
|
18
|
-
*/
|
|
19
|
-
export var getTransforms = function getTransforms(packages) {
|
|
20
|
-
var transforms = [path.join(basePath(packages), '*.@(ts|tsx|js)'), path.join(basePath(packages), '*', 'index.@(ts|tsx|js)')];
|
|
21
|
-
if (!packages) {
|
|
22
|
-
transforms.unshift.apply(transforms, _toConsumableArray(presets));
|
|
23
|
-
}
|
|
24
|
-
return transforms.map(function (transform) {
|
|
25
|
-
return globSync(transform);
|
|
26
|
-
}).reduce(function (acc, val) {
|
|
27
|
-
return acc.concat(val);
|
|
28
|
-
}, []).map(function (transform) {
|
|
29
|
-
return parseTransformPath(transform);
|
|
30
|
-
}).filter(filterTransforms(packages)).sort();
|
|
31
|
-
};
|
|
32
|
-
export var parseTransformPath = function parseTransformPath(transformPath) {
|
|
33
|
-
return path.parse(transformPath);
|
|
34
|
-
};
|
|
35
|
-
export var getTransformPath = function getTransformPath(_ref) {
|
|
36
|
-
var dir = _ref.dir,
|
|
37
|
-
base = _ref.base;
|
|
38
|
-
return "".concat(dir, "/").concat(base);
|
|
39
|
-
};
|
|
40
|
-
export var getTransformModule = function getTransformModule(transform) {
|
|
41
|
-
var pathSegments = transform.dir.split(path.sep);
|
|
42
|
-
var nodeModulesIdx = pathSegments.indexOf('node_modules');
|
|
43
|
-
// pathSegments will be of the form [node_modules, '@atlaskit', 'avatar', 'codemods']
|
|
44
|
-
return pathSegments.slice(nodeModulesIdx + 1, nodeModulesIdx + 3).join('/');
|
|
45
|
-
};
|
|
46
|
-
export var getTransformVersion = function getTransformVersion(transform) {
|
|
47
|
-
var transformName = transform.base;
|
|
48
|
-
if (transformName.startsWith('index.')) {
|
|
49
|
-
var pathSegments = transform.dir.split(path.sep);
|
|
50
|
-
transformName = pathSegments[pathSegments.length - 1];
|
|
51
|
-
}
|
|
52
|
-
return transformName.split('-')[0];
|
|
53
|
-
};
|
|
54
15
|
var filterTransforms = function filterTransforms(packages) {
|
|
55
16
|
if (!packages || packages.length === 0) {
|
|
56
17
|
return function () {
|
|
@@ -74,4 +35,17 @@ var filterTransforms = function filterTransforms(packages) {
|
|
|
74
35
|
return false;
|
|
75
36
|
}
|
|
76
37
|
};
|
|
38
|
+
};
|
|
39
|
+
export var getTransforms = function getTransforms(packages) {
|
|
40
|
+
var transforms = [path.join(basePath(packages), '*.@(ts|tsx|js)'), path.join(basePath(packages), '*', 'index.@(ts|tsx|js)')];
|
|
41
|
+
if (!packages) {
|
|
42
|
+
transforms.unshift.apply(transforms, _toConsumableArray(presets));
|
|
43
|
+
}
|
|
44
|
+
return transforms.map(function (transform) {
|
|
45
|
+
return globSync(transform);
|
|
46
|
+
}).reduce(function (acc, val) {
|
|
47
|
+
return acc.concat(val);
|
|
48
|
+
}, []).map(function (transform) {
|
|
49
|
+
return parseTransformPath(transform);
|
|
50
|
+
}).filter(filterTransforms(packages)).sort();
|
|
77
51
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { default } from './main';
|
|
2
|
-
export { ValidationError, NoTransformsExistError } from './types';
|
|
1
|
+
export { default } from './main';
|
package/dist/esm/main.js
CHANGED
|
@@ -14,10 +14,15 @@ import spawn from 'projector-spawn';
|
|
|
14
14
|
import semver from 'semver';
|
|
15
15
|
var jscodeshift = require.resolve('.bin/jscodeshift');
|
|
16
16
|
import { findDependentPackagePaths } from './filepath';
|
|
17
|
+
import { getTransformModule } from './get-transform-module';
|
|
18
|
+
import { getTransformPath } from './get-transform-path';
|
|
19
|
+
import { getTransforms } from './get-transforms';
|
|
20
|
+
import { hasTransform } from './has-transform';
|
|
21
|
+
import { NoTransformsExistError } from './no-transforms-exist-error';
|
|
22
|
+
import { parseTransformPath } from './parse-transform-path';
|
|
17
23
|
import { getPackagesSinceRef } from './sinceRef';
|
|
18
|
-
import { getTransformModule, getTransformPath, getTransforms, hasTransform, parseTransformPath } from './transforms';
|
|
19
|
-
import { NoTransformsExistError, ValidationError } from './types';
|
|
20
24
|
import { fixLineEnding } from './utils';
|
|
25
|
+
import { ValidationError } from './validation-error';
|
|
21
26
|
var applyTransformMeta = function applyTransformMeta(transforms) {
|
|
22
27
|
return transforms.map(function (transform) {
|
|
23
28
|
var moduleMatch = transform.dir.match(/\/@atlaskit\/[^\/]+\//);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
+
export var NoTransformsExistError = /*#__PURE__*/function (_Error) {
|
|
10
|
+
function NoTransformsExistError() {
|
|
11
|
+
_classCallCheck(this, NoTransformsExistError);
|
|
12
|
+
return _callSuper(this, NoTransformsExistError, arguments);
|
|
13
|
+
}
|
|
14
|
+
_inherits(NoTransformsExistError, _Error);
|
|
15
|
+
return _createClass(NoTransformsExistError);
|
|
16
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var mockDeprecatedIcons = {
|
|
2
|
+
deprecatedCore: {
|
|
3
|
+
'@atlaskit/icon/core/capture': {
|
|
4
|
+
message: 'The icon "capture" is deprecated in favour of "focus-area" from "@atlaskit/icon/core"'
|
|
5
|
+
},
|
|
6
|
+
'@atlaskit/icon/core/chart-matrix': {
|
|
7
|
+
message: 'The icon "chart-matrix" is deprecated in favour of "chart-bubble" from "@atlaskit/icon/core"'
|
|
8
|
+
},
|
|
9
|
+
'@atlaskit/icon/core/close': {
|
|
10
|
+
message: 'The icon "close" is deprecated in favour of "cross" from "@atlaskit/icon/core"'
|
|
11
|
+
},
|
|
12
|
+
'@atlaskit/icon/core/error': {
|
|
13
|
+
message: 'The icon "error" is deprecated in favour of "status-error" from "@atlaskit/icon/core"'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -56,20 +56,4 @@ export var mockMetadata = {
|
|
|
56
56
|
status: 'deprecated'
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
};
|
|
60
|
-
export var mockDeprecatedIcons = {
|
|
61
|
-
deprecatedCore: {
|
|
62
|
-
'@atlaskit/icon/core/capture': {
|
|
63
|
-
message: 'The icon "capture" is deprecated in favour of "focus-area" from "@atlaskit/icon/core"'
|
|
64
|
-
},
|
|
65
|
-
'@atlaskit/icon/core/chart-matrix': {
|
|
66
|
-
message: 'The icon "chart-matrix" is deprecated in favour of "chart-bubble" from "@atlaskit/icon/core"'
|
|
67
|
-
},
|
|
68
|
-
'@atlaskit/icon/core/close': {
|
|
69
|
-
message: 'The icon "close" is deprecated in favour of "cross" from "@atlaskit/icon/core"'
|
|
70
|
-
},
|
|
71
|
-
'@atlaskit/icon/core/error': {
|
|
72
|
-
message: 'The icon "error" is deprecated in favour of "status-error" from "@atlaskit/icon/core"'
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
59
|
};
|
package/dist/esm/presets/migrate-icon-object-to-object/codemods/migrate-icon-object-to-object.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/fs/filename-pattern-match */
|
|
2
2
|
|
|
3
3
|
import { OLD_ICON_OBJECT_ENTRY_POINT, PRINT_SETTINGS } from '../utils/constants';
|
|
4
|
-
import { createDefaultImportDeclaration
|
|
4
|
+
import { createDefaultImportDeclaration } from '../utils/create-default-import-declaration';
|
|
5
|
+
import { getNewImportInfo } from '../utils/get-new-import-info';
|
|
6
|
+
import { parseIconObjectImport } from '../utils/parse-icon-object-import';
|
|
5
7
|
var transformer = function transformer(file, api) {
|
|
6
8
|
var j = api.jscodeshift;
|
|
7
9
|
var fileSource = j(file.source);
|
package/dist/esm/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/fs/filename-pattern-match */
|
|
2
|
+
|
|
3
|
+
export function createDefaultImportDeclaration(j, componentName, importPath) {
|
|
4
|
+
var defaultSpecifier = j.importDefaultSpecifier(j.identifier(componentName));
|
|
5
|
+
return j.importDeclaration([defaultSpecifier], j.stringLiteral(importPath));
|
|
6
|
+
}
|