@atlaskit/codemod-cli 0.11.5 → 0.12.1
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 +16 -0
- package/dist/cjs/cli.js +75 -68
- package/dist/cjs/filepath.js +29 -69
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/main.js +167 -337
- package/dist/cjs/presets/css-to-design-tokens/css-to-design-tokens.js +31 -73
- package/dist/cjs/presets/css-to-design-tokens/utils/legacy-colors.js +3 -3
- package/dist/cjs/presets/css-to-design-tokens/utils/meta.js +6 -19
- package/dist/cjs/presets/index.js +1 -3
- package/dist/cjs/presets/styled-to-emotion/styled-to-emotion.js +12 -19
- package/dist/cjs/presets/theme-to-design-tokens/theme-to-design-tokens.js +32 -61
- package/dist/cjs/presets/theme-to-design-tokens/utils/ast-meta.js +13 -26
- package/dist/cjs/presets/theme-to-design-tokens/utils/color.js +7 -11
- package/dist/cjs/presets/theme-to-design-tokens/utils/fuzzy-search.js +6 -10
- package/dist/cjs/presets/theme-to-design-tokens/utils/legacy-colors.js +3 -3
- package/dist/cjs/presets/theme-to-design-tokens/utils/named-colors.js +1 -1
- package/dist/cjs/presets/theme-to-design-tokens/utils/tokens.js +2 -16
- package/dist/cjs/sinceRef.js +35 -70
- package/dist/cjs/transforms.js +26 -44
- package/dist/cjs/types.js +3 -27
- package/dist/cjs/utils.js +6 -6
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/cli.js +53 -55
- package/dist/esm/filepath.js +50 -54
- package/dist/esm/main.js +220 -230
- package/dist/esm/presets/css-to-design-tokens/css-to-design-tokens.js +11 -13
- package/dist/esm/sinceRef.js +48 -50
- package/dist/esm/version.json +1 -1
- package/dist/types-ts4.0/cli.d.ts +1 -0
- package/dist/types-ts4.0/filepath.d.ts +2 -0
- package/dist/types-ts4.0/index.d.ts +4 -0
- package/dist/types-ts4.0/main.d.ts +19 -0
- package/dist/types-ts4.0/presets/css-to-design-tokens/css-to-design-tokens.d.ts +2 -0
- package/dist/types-ts4.0/presets/css-to-design-tokens/utils/legacy-colors.d.ts +3 -0
- package/dist/types-ts4.0/presets/css-to-design-tokens/utils/meta.d.ts +1 -0
- package/dist/types-ts4.0/presets/index.d.ts +9 -0
- package/dist/types-ts4.0/presets/styled-to-emotion/styled-to-emotion.d.ts +6 -0
- package/dist/types-ts4.0/presets/theme-to-design-tokens/theme-to-design-tokens.d.ts +2 -0
- package/dist/types-ts4.0/presets/theme-to-design-tokens/utils/ast-meta.d.ts +3 -0
- package/dist/types-ts4.0/presets/theme-to-design-tokens/utils/ast.d.ts +3 -0
- package/dist/types-ts4.0/presets/theme-to-design-tokens/utils/color.d.ts +4 -0
- package/dist/types-ts4.0/presets/theme-to-design-tokens/utils/fuzzy-search.d.ts +5 -0
- package/dist/types-ts4.0/presets/theme-to-design-tokens/utils/legacy-colors.d.ts +3 -0
- package/dist/types-ts4.0/presets/theme-to-design-tokens/utils/named-colors.d.ts +1 -0
- package/dist/types-ts4.0/presets/theme-to-design-tokens/utils/tokens.d.ts +2 -0
- package/dist/types-ts4.0/sinceRef.d.ts +5 -0
- package/dist/types-ts4.0/transforms.d.ts +10 -0
- package/dist/types-ts4.0/types.d.ts +59 -0
- package/dist/types-ts4.0/utils.d.ts +1 -0
- package/package.json +2 -2
|
@@ -160,19 +160,17 @@ export default function transformer(_x) {
|
|
|
160
160
|
function _transformer() {
|
|
161
161
|
_transformer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file) {
|
|
162
162
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
163
|
-
while (1) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return _context.stop();
|
|
175
|
-
}
|
|
163
|
+
while (1) switch (_context.prev = _context.next) {
|
|
164
|
+
case 0:
|
|
165
|
+
_context.next = 2;
|
|
166
|
+
return postcss([plugin()]).process(file.source, {
|
|
167
|
+
syntax: lessSyntax
|
|
168
|
+
}).css;
|
|
169
|
+
case 2:
|
|
170
|
+
return _context.abrupt("return", _context.sent);
|
|
171
|
+
case 3:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context.stop();
|
|
176
174
|
}
|
|
177
175
|
}, _callee);
|
|
178
176
|
}));
|
package/dist/esm/sinceRef.js
CHANGED
|
@@ -23,56 +23,54 @@ export var getPackagesSinceRef = /*#__PURE__*/function () {
|
|
|
23
23
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ref) {
|
|
24
24
|
var git, commit, diff, modifiedPackages, addedPackages, upgradedPackages;
|
|
25
25
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
26
|
-
while (1) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return _context.stop();
|
|
75
|
-
}
|
|
26
|
+
while (1) switch (_context.prev = _context.next) {
|
|
27
|
+
case 0:
|
|
28
|
+
git = simpleGit();
|
|
29
|
+
_context.prev = 1;
|
|
30
|
+
_context.next = 4;
|
|
31
|
+
return git.revparse(['--verify', ref]);
|
|
32
|
+
case 4:
|
|
33
|
+
commit = _context.sent;
|
|
34
|
+
_context.next = 10;
|
|
35
|
+
break;
|
|
36
|
+
case 7:
|
|
37
|
+
_context.prev = 7;
|
|
38
|
+
_context.t0 = _context["catch"](1);
|
|
39
|
+
throw new ValidationError("Invalid git ref \"".concat(ref, "\""));
|
|
40
|
+
case 10:
|
|
41
|
+
_context.next = 12;
|
|
42
|
+
return git.diff([commit, '--', 'package.json']);
|
|
43
|
+
case 12:
|
|
44
|
+
diff = _context.sent;
|
|
45
|
+
modifiedPackages = diff.split('\n').map(parseDiffLine).filter(function (pkg) {
|
|
46
|
+
return Boolean(pkg);
|
|
47
|
+
});
|
|
48
|
+
addedPackages = new Map(modifiedPackages.filter(function (pkg) {
|
|
49
|
+
return pkg.type === 'added';
|
|
50
|
+
}).map(function (pkg) {
|
|
51
|
+
return [pkg.name, pkg];
|
|
52
|
+
}));
|
|
53
|
+
/* This is holds the previous version of packages that have been upgraded. Packages are treated as
|
|
54
|
+
* upgraded if they have both an addition/deletion entry in the diff and their versions differ
|
|
55
|
+
*/
|
|
56
|
+
upgradedPackages = modifiedPackages.filter(function (pkg) {
|
|
57
|
+
var addedEntry = addedPackages.get(pkg.name);
|
|
58
|
+
if (pkg.type !== 'deleted' || !addedEntry) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return pkg.version !== addedEntry.version;
|
|
62
|
+
}).map(function (_ref2) {
|
|
63
|
+
var name = _ref2.name,
|
|
64
|
+
version = _ref2.version;
|
|
65
|
+
return {
|
|
66
|
+
name: name,
|
|
67
|
+
version: version
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
return _context.abrupt("return", upgradedPackages);
|
|
71
|
+
case 17:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context.stop();
|
|
76
74
|
}
|
|
77
75
|
}, _callee, null, [[1, 7]]);
|
|
78
76
|
}));
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function run(): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Flags, Default } from './types';
|
|
2
|
+
declare const defaultFlags: {
|
|
3
|
+
parser: "babel";
|
|
4
|
+
extensions: string;
|
|
5
|
+
ignorePattern: string;
|
|
6
|
+
logger: Console;
|
|
7
|
+
};
|
|
8
|
+
export declare type UserFlags = Default<Flags, keyof typeof defaultFlags>;
|
|
9
|
+
export default function main(input: string[], userFlags: UserFlags): Promise<{
|
|
10
|
+
transforms: {
|
|
11
|
+
module: string;
|
|
12
|
+
root: string;
|
|
13
|
+
dir: string;
|
|
14
|
+
base: string;
|
|
15
|
+
ext: string;
|
|
16
|
+
name: string;
|
|
17
|
+
}[];
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cleanMeta(meta: string[]): string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manually import presets to make sure typescript includes them
|
|
3
|
+
* in the final bundle
|
|
4
|
+
*/
|
|
5
|
+
import './styled-to-emotion/styled-to-emotion';
|
|
6
|
+
import './theme-to-design-tokens/theme-to-design-tokens';
|
|
7
|
+
import './css-to-design-tokens/css-to-design-tokens';
|
|
8
|
+
declare const presets: string[];
|
|
9
|
+
export default presets;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FileInfo, API, Options } from 'jscodeshift';
|
|
2
|
+
/**
|
|
3
|
+
* Converts all imports of `styled-components` to `@emotion/styled`
|
|
4
|
+
*/
|
|
5
|
+
export default function transformer(fileInfo: FileInfo, { jscodeshift: j }: API, options: Options): string;
|
|
6
|
+
export declare const parser = "tsx";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const isLegacyColor: (value: string) => boolean;
|
|
2
|
+
export declare const isLegacyNamedColor: (value: string) => boolean;
|
|
3
|
+
export declare const includesHardCodedColor: (raw: string) => boolean;
|
|
4
|
+
export declare const isHardCodedColor: (value: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const namedColors: string[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import path, { ParsedPath } from 'path';
|
|
3
|
+
import { ParsedPkg } from './types';
|
|
4
|
+
export declare const hasTransform: (transformPath: string) => boolean;
|
|
5
|
+
/** Retrieves transforms for `packages` if provided, otherwise all transforms including presets */
|
|
6
|
+
export declare const getTransforms: (packages?: ParsedPkg[] | undefined) => ParsedPath[];
|
|
7
|
+
export declare const parseTransformPath: (transformPath: string) => path.ParsedPath;
|
|
8
|
+
export declare const getTransformPath: ({ dir, base }: ParsedPath) => string;
|
|
9
|
+
export declare const getTransformModule: (transform: ParsedPath) => string;
|
|
10
|
+
export declare const getTransformVersion: (transform: ParsedPath) => string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { FileInfo, API, Options } from 'jscodeshift';
|
|
2
|
+
export declare type Transform = (fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) => string;
|
|
3
|
+
export declare type CliFlags = {
|
|
4
|
+
/**
|
|
5
|
+
* The transform to run
|
|
6
|
+
*/
|
|
7
|
+
transform?: string;
|
|
8
|
+
/**
|
|
9
|
+
* select which transform to run
|
|
10
|
+
*/
|
|
11
|
+
preset?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Comma separated list of packages to run transforms for, @scope/package[@version]. If version is supplied, will only run transforms above that version
|
|
14
|
+
*/
|
|
15
|
+
packages?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Parser to use for parsing the source files
|
|
18
|
+
*/
|
|
19
|
+
parser: 'babel' | 'babylon' | 'flow' | 'ts' | 'tsx';
|
|
20
|
+
/**
|
|
21
|
+
* Transform files with these file extensions (comma separated list)
|
|
22
|
+
*/
|
|
23
|
+
extensions: string;
|
|
24
|
+
/**
|
|
25
|
+
* Ignore files that match a provided glob expression
|
|
26
|
+
*/
|
|
27
|
+
ignorePattern: string;
|
|
28
|
+
/**
|
|
29
|
+
* Determines changed packages since the specified git ref and runs all codemods for them. The ref can be any valid git ref, e.g. a commit hash, HEAD etc.
|
|
30
|
+
*/
|
|
31
|
+
sinceRef?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Return a 1 exit code when errors were found during execution of codemods
|
|
34
|
+
*/
|
|
35
|
+
failOnError?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Filters source paths to package directories that declare a dependency on the package being upgraded
|
|
38
|
+
*/
|
|
39
|
+
filterPaths?: boolean;
|
|
40
|
+
};
|
|
41
|
+
export declare type Flags = CliFlags & {
|
|
42
|
+
logger: {
|
|
43
|
+
log: (...args: any) => void;
|
|
44
|
+
warn: (...args: any) => void;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare type ParsedPkg = {
|
|
48
|
+
name: string;
|
|
49
|
+
version: string | null;
|
|
50
|
+
};
|
|
51
|
+
/** Converts required args to optional if they have a default
|
|
52
|
+
* Example: export type UserFlags = Default<Flags, keyof typeof defaultFlags>;
|
|
53
|
+
*/
|
|
54
|
+
export declare type Default<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
55
|
+
export declare type ValidateShape<T, Shape> = T extends Shape ? Exclude<keyof T, keyof Shape> extends never ? T : never : never;
|
|
56
|
+
export declare class ValidationError extends Error {
|
|
57
|
+
}
|
|
58
|
+
export declare class NoTransformsExistError extends Error {
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fixLineEnding: (source: string, lineEnding: string) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/codemod-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "A cli for distributing codemods for atlassian-frontend components and services",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"codemod-cli": "./bin/codemod-cli.js"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@atlaskit/tokens": "^1.
|
|
27
|
+
"@atlaskit/tokens": "^1.3.0",
|
|
28
28
|
"@babel/runtime": "^7.0.0",
|
|
29
29
|
"@types/jscodeshift": "^0.11.0",
|
|
30
30
|
"chalk": "^4.1.2",
|