assistant-ui 0.0.49 → 0.0.50
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/dist/codemods/utils/createTransformer.d.ts +15 -0
- package/dist/codemods/utils/createTransformer.d.ts.map +1 -0
- package/dist/codemods/v0-8/ui-package-split.d.ts +3 -0
- package/dist/codemods/v0-8/ui-package-split.d.ts.map +1 -0
- package/dist/codemods/v0-9/edge-package-split.d.ts +3 -0
- package/dist/codemods/v0-9/edge-package-split.d.ts.map +1 -0
- package/dist/commands/add.d.ts +3 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/create.d.ts +3 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/update.d.ts +3 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/upgrade.d.ts +10 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/install-ai-sdk-lib.d.ts +2 -0
- package/dist/lib/install-ai-sdk-lib.d.ts.map +1 -0
- package/dist/lib/install-edge-lib.d.ts +2 -0
- package/dist/lib/install-edge-lib.d.ts.map +1 -0
- package/dist/lib/install-ui-lib.d.ts +2 -0
- package/dist/lib/install-ui-lib.d.ts.map +1 -0
- package/dist/lib/transform-options.d.ts +7 -0
- package/dist/lib/transform-options.d.ts.map +1 -0
- package/dist/lib/transform.d.ts +21 -0
- package/dist/lib/transform.d.ts.map +1 -0
- package/dist/lib/upgrade.d.ts +9 -0
- package/dist/lib/upgrade.d.ts.map +1 -0
- package/package.json +3 -5
- package/src/codemods/utils/createTransformer.ts +41 -0
- package/src/codemods/v0-8/ui-package-split.ts +203 -0
- package/src/codemods/v0-9/edge-package-split.ts +226 -0
- package/src/commands/add.ts +47 -0
- package/src/commands/create.ts +92 -0
- package/src/commands/init.ts +50 -0
- package/src/commands/update.ts +60 -0
- package/src/commands/upgrade.ts +55 -0
- package/src/index.ts +28 -0
- package/src/lib/install-ai-sdk-lib.ts +92 -0
- package/src/lib/install-edge-lib.ts +92 -0
- package/src/lib/install-ui-lib.ts +92 -0
- package/src/lib/transform-options.ts +6 -0
- package/src/lib/transform.ts +177 -0
- package/src/lib/upgrade.ts +83 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FileInfo, API, JSCodeshift, Collection } from "jscodeshift";
|
|
2
|
+
export type TransformerFunction = (context: TransformContext, fileInfo: FileInfo, api: API, options: any) => void;
|
|
3
|
+
export interface TransformContext {
|
|
4
|
+
/**
|
|
5
|
+
* The jscodeshift API object.
|
|
6
|
+
*/
|
|
7
|
+
j: JSCodeshift;
|
|
8
|
+
/**
|
|
9
|
+
* The root collection of the AST.
|
|
10
|
+
*/
|
|
11
|
+
root: Collection<any>;
|
|
12
|
+
markAsChanged: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createTransformer(transformFn: TransformerFunction): (fileInfo: FileInfo, api: API, options: any) => string | null;
|
|
15
|
+
//# sourceMappingURL=createTransformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTransformer.d.ts","sourceRoot":"","sources":["../../../src/codemods/utils/createTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,GAAG,KACT,IAAI,CAAC;AAEV,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,CAAC,EAAE,WAAW,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAEtB,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,mBAAmB,IACpC,UAAU,QAAQ,EAAE,KAAK,GAAG,EAAE,SAAS,GAAG,mBAgBvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-package-split.d.ts","sourceRoot":"","sources":["../../../src/codemods/v0-8/ui-package-split.ts"],"names":[],"mappings":"AA8BA,QAAA,MAAM,kBAAkB,6HA0KtB,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-package-split.d.ts","sourceRoot":"","sources":["../../../src/codemods/v0-9/edge-package-split.ts"],"names":[],"mappings":"AAqCA,QAAA,MAAM,oBAAoB,6HA0LxB,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,GAAG,SAyCZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,MAAM,SAuFf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,eAAO,MAAM,IAAI,SA0Cb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,eAAO,MAAM,MAAM,SAoDf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
export interface TransformOptions {
|
|
3
|
+
dry?: boolean;
|
|
4
|
+
print?: boolean;
|
|
5
|
+
verbose?: boolean;
|
|
6
|
+
jscodeshift?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const codemodCommand: Command;
|
|
9
|
+
export declare const upgradeCommand: Command;
|
|
10
|
+
//# sourceMappingURL=upgrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAgBD,eAAO,MAAM,cAAc,SAczB,CAAC;AAEH,eAAO,MAAM,cAAc,SAYzB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-ai-sdk-lib.d.ts","sourceRoot":"","sources":["../../src/lib/install-ai-sdk-lib.ts"],"names":[],"mappings":"AAuCA,wBAA8B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAoD7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-edge-lib.d.ts","sourceRoot":"","sources":["../../src/lib/install-edge-lib.ts"],"names":[],"mappings":"AAuCA,wBAA8B,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAoD5D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-ui-lib.d.ts","sourceRoot":"","sources":["../../src/lib/install-ui-lib.ts"],"names":[],"mappings":"AAuCA,wBAA8B,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAoD/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-options.d.ts","sourceRoot":"","sources":["../../src/lib/transform-options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TransformOptions } from "./transform-options";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the list of files that need to be processed in the codebase
|
|
4
|
+
* Only includes files that contain "assistant-ui" to optimize performance
|
|
5
|
+
*/
|
|
6
|
+
export declare function getRelevantFiles(cwd: string): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Counts the number of files that need to be processed
|
|
9
|
+
*/
|
|
10
|
+
export declare function countFilesToProcess(cwd: string): number;
|
|
11
|
+
export type TransformErrors = {
|
|
12
|
+
transform: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
summary: string;
|
|
15
|
+
}[];
|
|
16
|
+
export declare function transform(codemod: string, source: string, transformOptions: TransformOptions, options?: {
|
|
17
|
+
logStatus: boolean;
|
|
18
|
+
onProgress?: (processedFiles: number) => void;
|
|
19
|
+
relevantFiles?: string[];
|
|
20
|
+
}): TransformErrors;
|
|
21
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/lib/transform.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAWvD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAwBtD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAoCD,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,EAAE,CAAC;AAoBJ,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,GAAE;IACP,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CACJ,GACtB,eAAe,CA0DjB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TransformOptions } from "./transform-options";
|
|
2
|
+
/**
|
|
3
|
+
* Runs the upgrade cycle:
|
|
4
|
+
* - Runs each codemod in the bundle.
|
|
5
|
+
* - Displays progress using cli-progress.
|
|
6
|
+
* - After codemods run, checks if any file now imports from the new packages and prompts for install.
|
|
7
|
+
*/
|
|
8
|
+
export declare function upgrade(options: TransformOptions): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=upgrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/lib/upgrade.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAWvD;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,gBAAgB,iBA+DtD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assistant-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"dist",
|
|
32
|
+
"src",
|
|
32
33
|
"README.md"
|
|
33
34
|
],
|
|
34
35
|
"bin": "./dist/index.js",
|
|
@@ -39,14 +40,11 @@
|
|
|
39
40
|
"homepage": "https://www.assistant-ui.com/",
|
|
40
41
|
"repository": {
|
|
41
42
|
"type": "git",
|
|
42
|
-
"url": "
|
|
43
|
+
"url": "https://github.com/assistant-ui/assistant-ui/tree/main/packages/cli"
|
|
43
44
|
},
|
|
44
45
|
"bugs": {
|
|
45
46
|
"url": "https://github.com/assistant-ui/assistant-ui/issues"
|
|
46
47
|
},
|
|
47
|
-
"engines": {
|
|
48
|
-
"node": ">=20.0.0"
|
|
49
|
-
},
|
|
50
48
|
"scripts": {
|
|
51
49
|
"build": "tsx scripts/build.mts"
|
|
52
50
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FileInfo, API, JSCodeshift, Collection } from "jscodeshift";
|
|
2
|
+
|
|
3
|
+
export type TransformerFunction = (
|
|
4
|
+
context: TransformContext,
|
|
5
|
+
fileInfo: FileInfo,
|
|
6
|
+
api: API,
|
|
7
|
+
options: any,
|
|
8
|
+
) => void;
|
|
9
|
+
|
|
10
|
+
export interface TransformContext {
|
|
11
|
+
/**
|
|
12
|
+
* The jscodeshift API object.
|
|
13
|
+
*/
|
|
14
|
+
j: JSCodeshift;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The root collection of the AST.
|
|
18
|
+
*/
|
|
19
|
+
root: Collection<any>;
|
|
20
|
+
|
|
21
|
+
markAsChanged: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createTransformer(transformFn: TransformerFunction) {
|
|
25
|
+
return function transformer(fileInfo: FileInfo, api: API, options: any) {
|
|
26
|
+
const j = api.jscodeshift;
|
|
27
|
+
const root = j(fileInfo.source);
|
|
28
|
+
|
|
29
|
+
let isChanged = false;
|
|
30
|
+
const context: TransformContext = {
|
|
31
|
+
j,
|
|
32
|
+
root,
|
|
33
|
+
markAsChanged: () => {
|
|
34
|
+
isChanged = true;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
transformFn(context, fileInfo, api, options);
|
|
39
|
+
return isChanged ? root.toSource() : null;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { createTransformer } from "../utils/createTransformer";
|
|
2
|
+
|
|
3
|
+
const reactUIExports: string[] = [
|
|
4
|
+
"ThreadConfigProvider",
|
|
5
|
+
"useThreadConfig",
|
|
6
|
+
"ThreadConfig",
|
|
7
|
+
"ThreadWelcomeConfig",
|
|
8
|
+
"UserMessageConfig",
|
|
9
|
+
"AssistantMessageConfig",
|
|
10
|
+
"StringsConfig",
|
|
11
|
+
"SuggestionConfig",
|
|
12
|
+
"ThreadConfigProviderProps",
|
|
13
|
+
"AssistantActionBar",
|
|
14
|
+
"AssistantMessage",
|
|
15
|
+
"AssistantModal",
|
|
16
|
+
"BranchPicker",
|
|
17
|
+
"Composer",
|
|
18
|
+
"ContentPart",
|
|
19
|
+
"AttachmentUI",
|
|
20
|
+
"EditComposer",
|
|
21
|
+
"Thread",
|
|
22
|
+
"ThreadList",
|
|
23
|
+
"ThreadListItem",
|
|
24
|
+
"ThreadWelcome",
|
|
25
|
+
"UserMessage",
|
|
26
|
+
"makeMarkdownText",
|
|
27
|
+
"MakeMarkdownTextProps",
|
|
28
|
+
"CodeHeader",
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const migrateAssistantUI = createTransformer(({ j, root, markAsChanged }) => {
|
|
32
|
+
const sourcesToMigrate: string[] = [
|
|
33
|
+
"@assistant-ui/react",
|
|
34
|
+
"@assistant-ui/react-markdown",
|
|
35
|
+
];
|
|
36
|
+
const movedSpecifiers: any[] = [];
|
|
37
|
+
let lastMigratedImportPath: any = null;
|
|
38
|
+
|
|
39
|
+
root
|
|
40
|
+
.find(j.ImportDeclaration)
|
|
41
|
+
.filter((path: any) => sourcesToMigrate.includes(path.value.source.value))
|
|
42
|
+
.forEach((path: any) => {
|
|
43
|
+
let hadMigratedSpecifiers = false;
|
|
44
|
+
const remainingSpecifiers: any[] = [];
|
|
45
|
+
path.value.specifiers.forEach((specifier: any) => {
|
|
46
|
+
if (
|
|
47
|
+
j.ImportSpecifier.check(specifier) &&
|
|
48
|
+
reactUIExports.includes(specifier.imported.name as string)
|
|
49
|
+
) {
|
|
50
|
+
movedSpecifiers.push(specifier);
|
|
51
|
+
hadMigratedSpecifiers = true;
|
|
52
|
+
} else {
|
|
53
|
+
remainingSpecifiers.push(specifier);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (hadMigratedSpecifiers) {
|
|
57
|
+
lastMigratedImportPath = path;
|
|
58
|
+
}
|
|
59
|
+
if (remainingSpecifiers.length === 0) {
|
|
60
|
+
j(path).remove();
|
|
61
|
+
markAsChanged();
|
|
62
|
+
} else if (remainingSpecifiers.length !== path.value.specifiers.length) {
|
|
63
|
+
path.value.specifiers = remainingSpecifiers;
|
|
64
|
+
markAsChanged();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (movedSpecifiers.length > 0) {
|
|
69
|
+
const existingReactUIImport = root.find(j.ImportDeclaration, {
|
|
70
|
+
source: { value: "@assistant-ui/react-ui" },
|
|
71
|
+
});
|
|
72
|
+
if (existingReactUIImport.size() > 0) {
|
|
73
|
+
existingReactUIImport.forEach((path: any) => {
|
|
74
|
+
movedSpecifiers.forEach((specifier: any) => {
|
|
75
|
+
if (
|
|
76
|
+
!path.value.specifiers.some(
|
|
77
|
+
(s: any) => s.imported.name === specifier.imported.name,
|
|
78
|
+
)
|
|
79
|
+
) {
|
|
80
|
+
path.value.specifiers.push(specifier);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
const newImport = j.importDeclaration(
|
|
86
|
+
movedSpecifiers,
|
|
87
|
+
j.literal("@assistant-ui/react-ui"),
|
|
88
|
+
);
|
|
89
|
+
if (lastMigratedImportPath) {
|
|
90
|
+
j(lastMigratedImportPath).insertAfter(newImport);
|
|
91
|
+
} else {
|
|
92
|
+
const firstImport = root.find(j.ImportDeclaration).at(0);
|
|
93
|
+
if (firstImport.size() > 0) {
|
|
94
|
+
firstImport.insertBefore(newImport);
|
|
95
|
+
} else {
|
|
96
|
+
root.get().node.program.body.unshift(newImport);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
markAsChanged();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const cssReplacements: Record<string, string> = {
|
|
104
|
+
"@assistant-ui/react/styles/index.css":
|
|
105
|
+
"@assistant-ui/react-ui/styles/index.css",
|
|
106
|
+
"@assistant-ui/react/styles/modal.css":
|
|
107
|
+
"@assistant-ui/react-ui/styles/modal.css",
|
|
108
|
+
"@assistant-ui/react-markdown/styles/markdown.css":
|
|
109
|
+
"@assistant-ui/react-ui/styles/markdown.css",
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
root.find(j.ImportDeclaration).forEach((path: any) => {
|
|
113
|
+
const sourceValue: string = path.value.source.value;
|
|
114
|
+
if (cssReplacements[sourceValue]) {
|
|
115
|
+
path.value.source = j.literal(cssReplacements[sourceValue]);
|
|
116
|
+
markAsChanged();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
let removedMarkdownPlugin = false;
|
|
121
|
+
root
|
|
122
|
+
.find(j.CallExpression, { callee: { name: "require" } })
|
|
123
|
+
.filter((path: any) => {
|
|
124
|
+
const arg = path.value.arguments[0];
|
|
125
|
+
return (
|
|
126
|
+
arg &&
|
|
127
|
+
(arg.type === "Literal" || arg.type === "StringLiteral") &&
|
|
128
|
+
arg.value === "@assistant-ui/react-markdown/tailwindcss"
|
|
129
|
+
);
|
|
130
|
+
})
|
|
131
|
+
.forEach((path: any) => {
|
|
132
|
+
removedMarkdownPlugin = true;
|
|
133
|
+
const parent = path.parentPath;
|
|
134
|
+
if (
|
|
135
|
+
parent &&
|
|
136
|
+
parent.value &&
|
|
137
|
+
parent.value.type === "VariableDeclarator"
|
|
138
|
+
) {
|
|
139
|
+
const varDecl = parent.parentPath;
|
|
140
|
+
if (
|
|
141
|
+
varDecl &&
|
|
142
|
+
varDecl.value.declarations &&
|
|
143
|
+
varDecl.value.declarations.length === 1
|
|
144
|
+
) {
|
|
145
|
+
j(varDecl).remove();
|
|
146
|
+
} else {
|
|
147
|
+
varDecl.value.declarations = varDecl.value.declarations.filter(
|
|
148
|
+
(decl: any) => decl !== parent.value,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
markAsChanged();
|
|
152
|
+
} else {
|
|
153
|
+
j(path).remove();
|
|
154
|
+
markAsChanged();
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
root
|
|
159
|
+
.find(j.CallExpression, { callee: { name: "require" } })
|
|
160
|
+
.filter((path: any) => {
|
|
161
|
+
const arg = path.value.arguments[0];
|
|
162
|
+
return (
|
|
163
|
+
arg &&
|
|
164
|
+
(arg.type === "Literal" || arg.type === "StringLiteral") &&
|
|
165
|
+
arg.value === "@assistant-ui/react/tailwindcss"
|
|
166
|
+
);
|
|
167
|
+
})
|
|
168
|
+
.forEach((path: any) => {
|
|
169
|
+
path.value.arguments[0].value = "@assistant-ui/react-ui/tailwindcss";
|
|
170
|
+
markAsChanged();
|
|
171
|
+
if (removedMarkdownPlugin) {
|
|
172
|
+
if (
|
|
173
|
+
path.parentPath &&
|
|
174
|
+
path.parentPath.value &&
|
|
175
|
+
path.parentPath.value.type === "CallExpression" &&
|
|
176
|
+
path.parentPath.value.arguments.length > 0
|
|
177
|
+
) {
|
|
178
|
+
const configObj = path.parentPath.value.arguments[0];
|
|
179
|
+
if (configObj && configObj.type === "ObjectExpression") {
|
|
180
|
+
const componentsProp = configObj.properties.find((prop: any) => {
|
|
181
|
+
return (
|
|
182
|
+
(prop.key.name === "components" ||
|
|
183
|
+
prop.key.value === "components") &&
|
|
184
|
+
prop.value.type === "ArrayExpression"
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
if (componentsProp) {
|
|
188
|
+
const componentsArray = componentsProp.value.elements;
|
|
189
|
+
const hasMarkdown = componentsArray.some(
|
|
190
|
+
(el: any) => el.type === "Literal" && el.value === "markdown",
|
|
191
|
+
);
|
|
192
|
+
if (!hasMarkdown) {
|
|
193
|
+
componentsArray.push(j.literal("markdown"));
|
|
194
|
+
markAsChanged();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
export default migrateAssistantUI;
|