assistant-ui 0.0.39 → 0.0.41
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.map +1 -1
- package/dist/codemods/v0-8/ui-package-split.js.map +1 -1
- package/dist/codemods/v0-8/ui-package-split.mjs.map +1 -1
- 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/codemods/v0-9/edge-package-split.js +209 -0
- package/dist/codemods/v0-9/edge-package-split.js.map +1 -0
- package/dist/codemods/v0-9/edge-package-split.mjs +188 -0
- package/dist/codemods/v0-9/edge-package-split.mjs.map +1 -0
- package/dist/commands/init.js +2 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/init.mjs +2 -1
- package/dist/commands/init.mjs.map +1 -1
- 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-ai-sdk-lib.js +121 -0
- package/dist/lib/install-ai-sdk-lib.js.map +1 -0
- package/dist/lib/install-ai-sdk-lib.mjs +90 -0
- package/dist/lib/install-ai-sdk-lib.mjs.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-edge-lib.js +121 -0
- package/dist/lib/install-edge-lib.js.map +1 -0
- package/dist/lib/install-edge-lib.mjs +90 -0
- package/dist/lib/install-edge-lib.mjs.map +1 -0
- package/dist/lib/transform-options.js.map +1 -1
- package/dist/lib/transform.d.ts +11 -0
- package/dist/lib/transform.d.ts.map +1 -1
- package/dist/lib/transform.js +67 -22
- package/dist/lib/transform.js.map +1 -1
- package/dist/lib/transform.mjs +66 -23
- package/dist/lib/transform.mjs.map +1 -1
- package/dist/lib/upgrade.d.ts +1 -2
- package/dist/lib/upgrade.d.ts.map +1 -1
- package/dist/lib/upgrade.js +30 -6
- package/dist/lib/upgrade.js.map +1 -1
- package/dist/lib/upgrade.mjs +31 -7
- package/dist/lib/upgrade.mjs.map +1 -1
- package/package.json +9 -6
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/lib/install-ai-sdk-lib.ts
|
|
31
|
+
var install_ai_sdk_lib_exports = {};
|
|
32
|
+
__export(install_ai_sdk_lib_exports, {
|
|
33
|
+
default: () => installAiSdkLib
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(install_ai_sdk_lib_exports);
|
|
36
|
+
var fs = __toESM(require("fs"));
|
|
37
|
+
var path = __toESM(require("path"));
|
|
38
|
+
var import_child_process = require("child_process");
|
|
39
|
+
var import_glob = require("glob");
|
|
40
|
+
var readline = __toESM(require("readline"));
|
|
41
|
+
var import_detect_package_manager = require("detect-package-manager");
|
|
42
|
+
function askQuestion(query) {
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
const rl = readline.createInterface({
|
|
45
|
+
input: process.stdin,
|
|
46
|
+
output: process.stdout
|
|
47
|
+
});
|
|
48
|
+
rl.question(query, (answer) => {
|
|
49
|
+
rl.close();
|
|
50
|
+
resolve(answer);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function isPackageInstalled(pkg) {
|
|
55
|
+
const cwd = process.cwd();
|
|
56
|
+
try {
|
|
57
|
+
const pkgJsonPath = path.join(cwd, "package.json");
|
|
58
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
59
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
|
60
|
+
const deps = pkgJson.dependencies || {};
|
|
61
|
+
const devDeps = pkgJson.devDependencies || {};
|
|
62
|
+
if (deps[pkg] || devDeps[pkg]) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch (e) {
|
|
67
|
+
}
|
|
68
|
+
const modulePath = path.join(cwd, "node_modules", ...pkg.split("/"));
|
|
69
|
+
return fs.existsSync(modulePath);
|
|
70
|
+
}
|
|
71
|
+
async function installAiSdkLib() {
|
|
72
|
+
const cwd = process.cwd();
|
|
73
|
+
const pattern = "**/*.{js,jsx,ts,tsx}";
|
|
74
|
+
const files = (0, import_glob.sync)(pattern, {
|
|
75
|
+
cwd,
|
|
76
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**"]
|
|
77
|
+
});
|
|
78
|
+
let found = false;
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
const fullPath = path.join(cwd, file);
|
|
81
|
+
const content = fs.readFileSync(fullPath, "utf8");
|
|
82
|
+
if (content.includes("@assistant-ui/react-ai-sdk")) {
|
|
83
|
+
found = true;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (found) {
|
|
88
|
+
if (isPackageInstalled("@assistant-ui/react-ai-sdk")) {
|
|
89
|
+
console.log(
|
|
90
|
+
"@assistant-ui/react-ai-sdk is already installed. Skipping installation."
|
|
91
|
+
);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const answer = await askQuestion(
|
|
95
|
+
"AI SDK imports were added but @assistant-ui/react-ai-sdk is not installed. Do you want to install it? (Y/n) "
|
|
96
|
+
);
|
|
97
|
+
if (answer === "" || answer.toLowerCase().startsWith("y")) {
|
|
98
|
+
const pm = await (0, import_detect_package_manager.detect)();
|
|
99
|
+
let cmd = "";
|
|
100
|
+
if (pm === "yarn") {
|
|
101
|
+
cmd = "yarn add @assistant-ui/react-ai-sdk";
|
|
102
|
+
} else if (pm === "pnpm") {
|
|
103
|
+
cmd = "pnpm add @assistant-ui/react-ai-sdk";
|
|
104
|
+
} else if (pm === "bun") {
|
|
105
|
+
cmd = "bun add @assistant-ui/react-ai-sdk";
|
|
106
|
+
} else {
|
|
107
|
+
cmd = "npm install @assistant-ui/react-ai-sdk";
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
(0, import_child_process.execSync)(cmd, { stdio: "inherit" });
|
|
111
|
+
} catch (e) {
|
|
112
|
+
console.error("Installation failed:", e);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
console.log("Skipping installation.");
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
console.log("No AI SDK imports found; skipping installation.");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=install-ai-sdk-lib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/install-ai-sdk-lib.ts"],"sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\nimport { execSync } from \"child_process\";\nimport { sync as globSync } from \"glob\";\nimport * as readline from \"readline\";\nimport { detect } from \"detect-package-manager\";\n\nfunction askQuestion(query: string): Promise<string> {\n return new Promise((resolve) => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n rl.question(query, (answer) => {\n rl.close();\n resolve(answer);\n });\n });\n}\n\nfunction isPackageInstalled(pkg: string): boolean {\n const cwd = process.cwd();\n try {\n const pkgJsonPath = path.join(cwd, \"package.json\");\n if (fs.existsSync(pkgJsonPath)) {\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf8\"));\n const deps = pkgJson.dependencies || {};\n const devDeps = pkgJson.devDependencies || {};\n if (deps[pkg] || devDeps[pkg]) {\n return true;\n }\n }\n } catch (e) {\n // Fall back to node_modules check below.\n }\n const modulePath = path.join(cwd, \"node_modules\", ...pkg.split(\"/\"));\n return fs.existsSync(modulePath);\n}\n\nexport default async function installAiSdkLib(): Promise<void> {\n const cwd = process.cwd();\n const pattern = \"**/*.{js,jsx,ts,tsx}\";\n const files = globSync(pattern, {\n cwd,\n ignore: [\"**/node_modules/**\", \"**/dist/**\", \"**/build/**\"],\n });\n\n let found = false;\n for (const file of files) {\n const fullPath = path.join(cwd, file);\n const content = fs.readFileSync(fullPath, \"utf8\");\n if (content.includes(\"@assistant-ui/react-ai-sdk\")) {\n found = true;\n break;\n }\n }\n\n if (found) {\n if (isPackageInstalled(\"@assistant-ui/react-ai-sdk\")) {\n console.log(\n \"@assistant-ui/react-ai-sdk is already installed. Skipping installation.\",\n );\n return;\n }\n\n const answer = await askQuestion(\n \"AI SDK imports were added but @assistant-ui/react-ai-sdk is not installed. Do you want to install it? (Y/n) \",\n );\n if (answer === \"\" || answer.toLowerCase().startsWith(\"y\")) {\n const pm = await detect();\n let cmd = \"\";\n if (pm === \"yarn\") {\n cmd = \"yarn add @assistant-ui/react-ai-sdk\";\n } else if (pm === \"pnpm\") {\n cmd = \"pnpm add @assistant-ui/react-ai-sdk\";\n } else if (pm === \"bun\") {\n cmd = \"bun add @assistant-ui/react-ai-sdk\";\n } else {\n cmd = \"npm install @assistant-ui/react-ai-sdk\";\n }\n try {\n execSync(cmd, { stdio: \"inherit\" });\n } catch (e) {\n console.error(\"Installation failed:\", e);\n }\n } else {\n console.log(\"Skipping installation.\");\n }\n } else {\n console.log(\"No AI SDK imports found; skipping installation.\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,2BAAyB;AACzB,kBAAiC;AACjC,eAA0B;AAC1B,oCAAuB;AAEvB,SAAS,YAAY,OAAgC;AACnD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,KAAc,yBAAgB;AAAA,MAClC,OAAO,QAAQ;AAAA,MACf,QAAQ,QAAQ;AAAA,IAClB,CAAC;AACD,OAAG,SAAS,OAAO,CAAC,WAAW;AAC7B,SAAG,MAAM;AACT,cAAQ,MAAM;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;AAEA,SAAS,mBAAmB,KAAsB;AAChD,QAAM,MAAM,QAAQ,IAAI;AACxB,MAAI;AACF,UAAM,cAAmB,UAAK,KAAK,cAAc;AACjD,QAAO,cAAW,WAAW,GAAG;AAC9B,YAAM,UAAU,KAAK,MAAS,gBAAa,aAAa,MAAM,CAAC;AAC/D,YAAM,OAAO,QAAQ,gBAAgB,CAAC;AACtC,YAAM,UAAU,QAAQ,mBAAmB,CAAC;AAC5C,UAAI,KAAK,GAAG,KAAK,QAAQ,GAAG,GAAG;AAC7B,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,QAAM,aAAkB,UAAK,KAAK,gBAAgB,GAAG,IAAI,MAAM,GAAG,CAAC;AACnE,SAAU,cAAW,UAAU;AACjC;AAEA,eAAO,kBAAwD;AAC7D,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,UAAU;AAChB,QAAM,YAAQ,YAAAA,MAAS,SAAS;AAAA,IAC9B;AAAA,IACA,QAAQ,CAAC,sBAAsB,cAAc,aAAa;AAAA,EAC5D,CAAC;AAED,MAAI,QAAQ;AACZ,aAAW,QAAQ,OAAO;AACxB,UAAM,WAAgB,UAAK,KAAK,IAAI;AACpC,UAAM,UAAa,gBAAa,UAAU,MAAM;AAChD,QAAI,QAAQ,SAAS,4BAA4B,GAAG;AAClD,cAAQ;AACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAO;AACT,QAAI,mBAAmB,4BAA4B,GAAG;AACpD,cAAQ;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,SAAS,MAAM;AAAA,MACnB;AAAA,IACF;AACA,QAAI,WAAW,MAAM,OAAO,YAAY,EAAE,WAAW,GAAG,GAAG;AACzD,YAAM,KAAK,UAAM,sCAAO;AACxB,UAAI,MAAM;AACV,UAAI,OAAO,QAAQ;AACjB,cAAM;AAAA,MACR,WAAW,OAAO,QAAQ;AACxB,cAAM;AAAA,MACR,WAAW,OAAO,OAAO;AACvB,cAAM;AAAA,MACR,OAAO;AACL,cAAM;AAAA,MACR;AACA,UAAI;AACF,2CAAS,KAAK,EAAE,OAAO,UAAU,CAAC;AAAA,MACpC,SAAS,GAAG;AACV,gBAAQ,MAAM,wBAAwB,CAAC;AAAA,MACzC;AAAA,IACF,OAAO;AACL,cAAQ,IAAI,wBAAwB;AAAA,IACtC;AAAA,EACF,OAAO;AACL,YAAQ,IAAI,iDAAiD;AAAA,EAC/D;AACF;","names":["globSync"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/lib/install-ai-sdk-lib.ts
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
import { sync as globSync } from "glob";
|
|
6
|
+
import * as readline from "readline";
|
|
7
|
+
import { detect } from "detect-package-manager";
|
|
8
|
+
function askQuestion(query) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
const rl = readline.createInterface({
|
|
11
|
+
input: process.stdin,
|
|
12
|
+
output: process.stdout
|
|
13
|
+
});
|
|
14
|
+
rl.question(query, (answer) => {
|
|
15
|
+
rl.close();
|
|
16
|
+
resolve(answer);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function isPackageInstalled(pkg) {
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
try {
|
|
23
|
+
const pkgJsonPath = path.join(cwd, "package.json");
|
|
24
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
25
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
|
26
|
+
const deps = pkgJson.dependencies || {};
|
|
27
|
+
const devDeps = pkgJson.devDependencies || {};
|
|
28
|
+
if (deps[pkg] || devDeps[pkg]) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} catch (e) {
|
|
33
|
+
}
|
|
34
|
+
const modulePath = path.join(cwd, "node_modules", ...pkg.split("/"));
|
|
35
|
+
return fs.existsSync(modulePath);
|
|
36
|
+
}
|
|
37
|
+
async function installAiSdkLib() {
|
|
38
|
+
const cwd = process.cwd();
|
|
39
|
+
const pattern = "**/*.{js,jsx,ts,tsx}";
|
|
40
|
+
const files = globSync(pattern, {
|
|
41
|
+
cwd,
|
|
42
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**"]
|
|
43
|
+
});
|
|
44
|
+
let found = false;
|
|
45
|
+
for (const file of files) {
|
|
46
|
+
const fullPath = path.join(cwd, file);
|
|
47
|
+
const content = fs.readFileSync(fullPath, "utf8");
|
|
48
|
+
if (content.includes("@assistant-ui/react-ai-sdk")) {
|
|
49
|
+
found = true;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (found) {
|
|
54
|
+
if (isPackageInstalled("@assistant-ui/react-ai-sdk")) {
|
|
55
|
+
console.log(
|
|
56
|
+
"@assistant-ui/react-ai-sdk is already installed. Skipping installation."
|
|
57
|
+
);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const answer = await askQuestion(
|
|
61
|
+
"AI SDK imports were added but @assistant-ui/react-ai-sdk is not installed. Do you want to install it? (Y/n) "
|
|
62
|
+
);
|
|
63
|
+
if (answer === "" || answer.toLowerCase().startsWith("y")) {
|
|
64
|
+
const pm = await detect();
|
|
65
|
+
let cmd = "";
|
|
66
|
+
if (pm === "yarn") {
|
|
67
|
+
cmd = "yarn add @assistant-ui/react-ai-sdk";
|
|
68
|
+
} else if (pm === "pnpm") {
|
|
69
|
+
cmd = "pnpm add @assistant-ui/react-ai-sdk";
|
|
70
|
+
} else if (pm === "bun") {
|
|
71
|
+
cmd = "bun add @assistant-ui/react-ai-sdk";
|
|
72
|
+
} else {
|
|
73
|
+
cmd = "npm install @assistant-ui/react-ai-sdk";
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
execSync(cmd, { stdio: "inherit" });
|
|
77
|
+
} catch (e) {
|
|
78
|
+
console.error("Installation failed:", e);
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
console.log("Skipping installation.");
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
console.log("No AI SDK imports found; skipping installation.");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
installAiSdkLib as default
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=install-ai-sdk-lib.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/install-ai-sdk-lib.ts"],"sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\nimport { execSync } from \"child_process\";\nimport { sync as globSync } from \"glob\";\nimport * as readline from \"readline\";\nimport { detect } from \"detect-package-manager\";\n\nfunction askQuestion(query: string): Promise<string> {\n return new Promise((resolve) => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n rl.question(query, (answer) => {\n rl.close();\n resolve(answer);\n });\n });\n}\n\nfunction isPackageInstalled(pkg: string): boolean {\n const cwd = process.cwd();\n try {\n const pkgJsonPath = path.join(cwd, \"package.json\");\n if (fs.existsSync(pkgJsonPath)) {\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf8\"));\n const deps = pkgJson.dependencies || {};\n const devDeps = pkgJson.devDependencies || {};\n if (deps[pkg] || devDeps[pkg]) {\n return true;\n }\n }\n } catch (e) {\n // Fall back to node_modules check below.\n }\n const modulePath = path.join(cwd, \"node_modules\", ...pkg.split(\"/\"));\n return fs.existsSync(modulePath);\n}\n\nexport default async function installAiSdkLib(): Promise<void> {\n const cwd = process.cwd();\n const pattern = \"**/*.{js,jsx,ts,tsx}\";\n const files = globSync(pattern, {\n cwd,\n ignore: [\"**/node_modules/**\", \"**/dist/**\", \"**/build/**\"],\n });\n\n let found = false;\n for (const file of files) {\n const fullPath = path.join(cwd, file);\n const content = fs.readFileSync(fullPath, \"utf8\");\n if (content.includes(\"@assistant-ui/react-ai-sdk\")) {\n found = true;\n break;\n }\n }\n\n if (found) {\n if (isPackageInstalled(\"@assistant-ui/react-ai-sdk\")) {\n console.log(\n \"@assistant-ui/react-ai-sdk is already installed. Skipping installation.\",\n );\n return;\n }\n\n const answer = await askQuestion(\n \"AI SDK imports were added but @assistant-ui/react-ai-sdk is not installed. Do you want to install it? (Y/n) \",\n );\n if (answer === \"\" || answer.toLowerCase().startsWith(\"y\")) {\n const pm = await detect();\n let cmd = \"\";\n if (pm === \"yarn\") {\n cmd = \"yarn add @assistant-ui/react-ai-sdk\";\n } else if (pm === \"pnpm\") {\n cmd = \"pnpm add @assistant-ui/react-ai-sdk\";\n } else if (pm === \"bun\") {\n cmd = \"bun add @assistant-ui/react-ai-sdk\";\n } else {\n cmd = \"npm install @assistant-ui/react-ai-sdk\";\n }\n try {\n execSync(cmd, { stdio: \"inherit\" });\n } catch (e) {\n console.error(\"Installation failed:\", e);\n }\n } else {\n console.log(\"Skipping installation.\");\n }\n } else {\n console.log(\"No AI SDK imports found; skipping installation.\");\n }\n}\n"],"mappings":";AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,gBAAgB;AACzB,SAAS,QAAQ,gBAAgB;AACjC,YAAY,cAAc;AAC1B,SAAS,cAAc;AAEvB,SAAS,YAAY,OAAgC;AACnD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,KAAc,yBAAgB;AAAA,MAClC,OAAO,QAAQ;AAAA,MACf,QAAQ,QAAQ;AAAA,IAClB,CAAC;AACD,OAAG,SAAS,OAAO,CAAC,WAAW;AAC7B,SAAG,MAAM;AACT,cAAQ,MAAM;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;AAEA,SAAS,mBAAmB,KAAsB;AAChD,QAAM,MAAM,QAAQ,IAAI;AACxB,MAAI;AACF,UAAM,cAAmB,UAAK,KAAK,cAAc;AACjD,QAAO,cAAW,WAAW,GAAG;AAC9B,YAAM,UAAU,KAAK,MAAS,gBAAa,aAAa,MAAM,CAAC;AAC/D,YAAM,OAAO,QAAQ,gBAAgB,CAAC;AACtC,YAAM,UAAU,QAAQ,mBAAmB,CAAC;AAC5C,UAAI,KAAK,GAAG,KAAK,QAAQ,GAAG,GAAG;AAC7B,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,QAAM,aAAkB,UAAK,KAAK,gBAAgB,GAAG,IAAI,MAAM,GAAG,CAAC;AACnE,SAAU,cAAW,UAAU;AACjC;AAEA,eAAO,kBAAwD;AAC7D,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,UAAU;AAChB,QAAM,QAAQ,SAAS,SAAS;AAAA,IAC9B;AAAA,IACA,QAAQ,CAAC,sBAAsB,cAAc,aAAa;AAAA,EAC5D,CAAC;AAED,MAAI,QAAQ;AACZ,aAAW,QAAQ,OAAO;AACxB,UAAM,WAAgB,UAAK,KAAK,IAAI;AACpC,UAAM,UAAa,gBAAa,UAAU,MAAM;AAChD,QAAI,QAAQ,SAAS,4BAA4B,GAAG;AAClD,cAAQ;AACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAO;AACT,QAAI,mBAAmB,4BAA4B,GAAG;AACpD,cAAQ;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,SAAS,MAAM;AAAA,MACnB;AAAA,IACF;AACA,QAAI,WAAW,MAAM,OAAO,YAAY,EAAE,WAAW,GAAG,GAAG;AACzD,YAAM,KAAK,MAAM,OAAO;AACxB,UAAI,MAAM;AACV,UAAI,OAAO,QAAQ;AACjB,cAAM;AAAA,MACR,WAAW,OAAO,QAAQ;AACxB,cAAM;AAAA,MACR,WAAW,OAAO,OAAO;AACvB,cAAM;AAAA,MACR,OAAO;AACL,cAAM;AAAA,MACR;AACA,UAAI;AACF,iBAAS,KAAK,EAAE,OAAO,UAAU,CAAC;AAAA,MACpC,SAAS,GAAG;AACV,gBAAQ,MAAM,wBAAwB,CAAC;AAAA,MACzC;AAAA,IACF,OAAO;AACL,cAAQ,IAAI,wBAAwB;AAAA,IACtC;AAAA,EACF,OAAO;AACL,YAAQ,IAAI,iDAAiD;AAAA,EAC/D;AACF;","names":[]}
|
|
@@ -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,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/lib/install-edge-lib.ts
|
|
31
|
+
var install_edge_lib_exports = {};
|
|
32
|
+
__export(install_edge_lib_exports, {
|
|
33
|
+
default: () => installEdgeLib
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(install_edge_lib_exports);
|
|
36
|
+
var fs = __toESM(require("fs"));
|
|
37
|
+
var path = __toESM(require("path"));
|
|
38
|
+
var import_child_process = require("child_process");
|
|
39
|
+
var import_glob = require("glob");
|
|
40
|
+
var readline = __toESM(require("readline"));
|
|
41
|
+
var import_detect_package_manager = require("detect-package-manager");
|
|
42
|
+
function askQuestion(query) {
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
const rl = readline.createInterface({
|
|
45
|
+
input: process.stdin,
|
|
46
|
+
output: process.stdout
|
|
47
|
+
});
|
|
48
|
+
rl.question(query, (answer) => {
|
|
49
|
+
rl.close();
|
|
50
|
+
resolve(answer);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function isPackageInstalled(pkg) {
|
|
55
|
+
const cwd = process.cwd();
|
|
56
|
+
try {
|
|
57
|
+
const pkgJsonPath = path.join(cwd, "package.json");
|
|
58
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
59
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
|
60
|
+
const deps = pkgJson.dependencies || {};
|
|
61
|
+
const devDeps = pkgJson.devDependencies || {};
|
|
62
|
+
if (deps[pkg] || devDeps[pkg]) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch (e) {
|
|
67
|
+
}
|
|
68
|
+
const modulePath = path.join(cwd, "node_modules", ...pkg.split("/"));
|
|
69
|
+
return fs.existsSync(modulePath);
|
|
70
|
+
}
|
|
71
|
+
async function installEdgeLib() {
|
|
72
|
+
const cwd = process.cwd();
|
|
73
|
+
const pattern = "**/*.{js,jsx,ts,tsx}";
|
|
74
|
+
const files = (0, import_glob.sync)(pattern, {
|
|
75
|
+
cwd,
|
|
76
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**"]
|
|
77
|
+
});
|
|
78
|
+
let found = false;
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
const fullPath = path.join(cwd, file);
|
|
81
|
+
const content = fs.readFileSync(fullPath, "utf8");
|
|
82
|
+
if (content.includes("@assistant-ui/react-edge")) {
|
|
83
|
+
found = true;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (found) {
|
|
88
|
+
if (isPackageInstalled("@assistant-ui/react-edge")) {
|
|
89
|
+
console.log(
|
|
90
|
+
"@assistant-ui/react-edge is already installed. Skipping installation."
|
|
91
|
+
);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const answer = await askQuestion(
|
|
95
|
+
"Edge Runtime imports were added but @assistant-ui/react-edge is not installed. Do you want to install it? (Y/n) "
|
|
96
|
+
);
|
|
97
|
+
if (answer === "" || answer.toLowerCase().startsWith("y")) {
|
|
98
|
+
const pm = await (0, import_detect_package_manager.detect)();
|
|
99
|
+
let cmd = "";
|
|
100
|
+
if (pm === "yarn") {
|
|
101
|
+
cmd = "yarn add @assistant-ui/react-edge";
|
|
102
|
+
} else if (pm === "pnpm") {
|
|
103
|
+
cmd = "pnpm add @assistant-ui/react-edge";
|
|
104
|
+
} else if (pm === "bun") {
|
|
105
|
+
cmd = "bun add @assistant-ui/react-edge";
|
|
106
|
+
} else {
|
|
107
|
+
cmd = "npm install @assistant-ui/react-edge";
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
(0, import_child_process.execSync)(cmd, { stdio: "inherit" });
|
|
111
|
+
} catch (e) {
|
|
112
|
+
console.error("Installation failed:", e);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
console.log("Skipping installation.");
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
console.log("No Edge Runtime imports found; skipping installation.");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=install-edge-lib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/install-edge-lib.ts"],"sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\nimport { execSync } from \"child_process\";\nimport { sync as globSync } from \"glob\";\nimport * as readline from \"readline\";\nimport { detect } from \"detect-package-manager\";\n\nfunction askQuestion(query: string): Promise<string> {\n return new Promise((resolve) => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n rl.question(query, (answer) => {\n rl.close();\n resolve(answer);\n });\n });\n}\n\nfunction isPackageInstalled(pkg: string): boolean {\n const cwd = process.cwd();\n try {\n const pkgJsonPath = path.join(cwd, \"package.json\");\n if (fs.existsSync(pkgJsonPath)) {\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf8\"));\n const deps = pkgJson.dependencies || {};\n const devDeps = pkgJson.devDependencies || {};\n if (deps[pkg] || devDeps[pkg]) {\n return true;\n }\n }\n } catch (e) {\n // Fall back to node_modules check below.\n }\n const modulePath = path.join(cwd, \"node_modules\", ...pkg.split(\"/\"));\n return fs.existsSync(modulePath);\n}\n\nexport default async function installEdgeLib(): Promise<void> {\n const cwd = process.cwd();\n const pattern = \"**/*.{js,jsx,ts,tsx}\";\n const files = globSync(pattern, {\n cwd,\n ignore: [\"**/node_modules/**\", \"**/dist/**\", \"**/build/**\"],\n });\n\n let found = false;\n for (const file of files) {\n const fullPath = path.join(cwd, file);\n const content = fs.readFileSync(fullPath, \"utf8\");\n if (content.includes(\"@assistant-ui/react-edge\")) {\n found = true;\n break;\n }\n }\n\n if (found) {\n if (isPackageInstalled(\"@assistant-ui/react-edge\")) {\n console.log(\n \"@assistant-ui/react-edge is already installed. Skipping installation.\",\n );\n return;\n }\n\n const answer = await askQuestion(\n \"Edge Runtime imports were added but @assistant-ui/react-edge is not installed. Do you want to install it? (Y/n) \",\n );\n if (answer === \"\" || answer.toLowerCase().startsWith(\"y\")) {\n const pm = await detect();\n let cmd = \"\";\n if (pm === \"yarn\") {\n cmd = \"yarn add @assistant-ui/react-edge\";\n } else if (pm === \"pnpm\") {\n cmd = \"pnpm add @assistant-ui/react-edge\";\n } else if (pm === \"bun\") {\n cmd = \"bun add @assistant-ui/react-edge\";\n } else {\n cmd = \"npm install @assistant-ui/react-edge\";\n }\n try {\n execSync(cmd, { stdio: \"inherit\" });\n } catch (e) {\n console.error(\"Installation failed:\", e);\n }\n } else {\n console.log(\"Skipping installation.\");\n }\n } else {\n console.log(\"No Edge Runtime imports found; skipping installation.\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,2BAAyB;AACzB,kBAAiC;AACjC,eAA0B;AAC1B,oCAAuB;AAEvB,SAAS,YAAY,OAAgC;AACnD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,KAAc,yBAAgB;AAAA,MAClC,OAAO,QAAQ;AAAA,MACf,QAAQ,QAAQ;AAAA,IAClB,CAAC;AACD,OAAG,SAAS,OAAO,CAAC,WAAW;AAC7B,SAAG,MAAM;AACT,cAAQ,MAAM;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;AAEA,SAAS,mBAAmB,KAAsB;AAChD,QAAM,MAAM,QAAQ,IAAI;AACxB,MAAI;AACF,UAAM,cAAmB,UAAK,KAAK,cAAc;AACjD,QAAO,cAAW,WAAW,GAAG;AAC9B,YAAM,UAAU,KAAK,MAAS,gBAAa,aAAa,MAAM,CAAC;AAC/D,YAAM,OAAO,QAAQ,gBAAgB,CAAC;AACtC,YAAM,UAAU,QAAQ,mBAAmB,CAAC;AAC5C,UAAI,KAAK,GAAG,KAAK,QAAQ,GAAG,GAAG;AAC7B,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,QAAM,aAAkB,UAAK,KAAK,gBAAgB,GAAG,IAAI,MAAM,GAAG,CAAC;AACnE,SAAU,cAAW,UAAU;AACjC;AAEA,eAAO,iBAAuD;AAC5D,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,UAAU;AAChB,QAAM,YAAQ,YAAAA,MAAS,SAAS;AAAA,IAC9B;AAAA,IACA,QAAQ,CAAC,sBAAsB,cAAc,aAAa;AAAA,EAC5D,CAAC;AAED,MAAI,QAAQ;AACZ,aAAW,QAAQ,OAAO;AACxB,UAAM,WAAgB,UAAK,KAAK,IAAI;AACpC,UAAM,UAAa,gBAAa,UAAU,MAAM;AAChD,QAAI,QAAQ,SAAS,0BAA0B,GAAG;AAChD,cAAQ;AACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAO;AACT,QAAI,mBAAmB,0BAA0B,GAAG;AAClD,cAAQ;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,SAAS,MAAM;AAAA,MACnB;AAAA,IACF;AACA,QAAI,WAAW,MAAM,OAAO,YAAY,EAAE,WAAW,GAAG,GAAG;AACzD,YAAM,KAAK,UAAM,sCAAO;AACxB,UAAI,MAAM;AACV,UAAI,OAAO,QAAQ;AACjB,cAAM;AAAA,MACR,WAAW,OAAO,QAAQ;AACxB,cAAM;AAAA,MACR,WAAW,OAAO,OAAO;AACvB,cAAM;AAAA,MACR,OAAO;AACL,cAAM;AAAA,MACR;AACA,UAAI;AACF,2CAAS,KAAK,EAAE,OAAO,UAAU,CAAC;AAAA,MACpC,SAAS,GAAG;AACV,gBAAQ,MAAM,wBAAwB,CAAC;AAAA,MACzC;AAAA,IACF,OAAO;AACL,cAAQ,IAAI,wBAAwB;AAAA,IACtC;AAAA,EACF,OAAO;AACL,YAAQ,IAAI,uDAAuD;AAAA,EACrE;AACF;","names":["globSync"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/lib/install-edge-lib.ts
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
import { sync as globSync } from "glob";
|
|
6
|
+
import * as readline from "readline";
|
|
7
|
+
import { detect } from "detect-package-manager";
|
|
8
|
+
function askQuestion(query) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
const rl = readline.createInterface({
|
|
11
|
+
input: process.stdin,
|
|
12
|
+
output: process.stdout
|
|
13
|
+
});
|
|
14
|
+
rl.question(query, (answer) => {
|
|
15
|
+
rl.close();
|
|
16
|
+
resolve(answer);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function isPackageInstalled(pkg) {
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
try {
|
|
23
|
+
const pkgJsonPath = path.join(cwd, "package.json");
|
|
24
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
25
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
|
26
|
+
const deps = pkgJson.dependencies || {};
|
|
27
|
+
const devDeps = pkgJson.devDependencies || {};
|
|
28
|
+
if (deps[pkg] || devDeps[pkg]) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} catch (e) {
|
|
33
|
+
}
|
|
34
|
+
const modulePath = path.join(cwd, "node_modules", ...pkg.split("/"));
|
|
35
|
+
return fs.existsSync(modulePath);
|
|
36
|
+
}
|
|
37
|
+
async function installEdgeLib() {
|
|
38
|
+
const cwd = process.cwd();
|
|
39
|
+
const pattern = "**/*.{js,jsx,ts,tsx}";
|
|
40
|
+
const files = globSync(pattern, {
|
|
41
|
+
cwd,
|
|
42
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**"]
|
|
43
|
+
});
|
|
44
|
+
let found = false;
|
|
45
|
+
for (const file of files) {
|
|
46
|
+
const fullPath = path.join(cwd, file);
|
|
47
|
+
const content = fs.readFileSync(fullPath, "utf8");
|
|
48
|
+
if (content.includes("@assistant-ui/react-edge")) {
|
|
49
|
+
found = true;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (found) {
|
|
54
|
+
if (isPackageInstalled("@assistant-ui/react-edge")) {
|
|
55
|
+
console.log(
|
|
56
|
+
"@assistant-ui/react-edge is already installed. Skipping installation."
|
|
57
|
+
);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const answer = await askQuestion(
|
|
61
|
+
"Edge Runtime imports were added but @assistant-ui/react-edge is not installed. Do you want to install it? (Y/n) "
|
|
62
|
+
);
|
|
63
|
+
if (answer === "" || answer.toLowerCase().startsWith("y")) {
|
|
64
|
+
const pm = await detect();
|
|
65
|
+
let cmd = "";
|
|
66
|
+
if (pm === "yarn") {
|
|
67
|
+
cmd = "yarn add @assistant-ui/react-edge";
|
|
68
|
+
} else if (pm === "pnpm") {
|
|
69
|
+
cmd = "pnpm add @assistant-ui/react-edge";
|
|
70
|
+
} else if (pm === "bun") {
|
|
71
|
+
cmd = "bun add @assistant-ui/react-edge";
|
|
72
|
+
} else {
|
|
73
|
+
cmd = "npm install @assistant-ui/react-edge";
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
execSync(cmd, { stdio: "inherit" });
|
|
77
|
+
} catch (e) {
|
|
78
|
+
console.error("Installation failed:", e);
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
console.log("Skipping installation.");
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
console.log("No Edge Runtime imports found; skipping installation.");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
installEdgeLib as default
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=install-edge-lib.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/install-edge-lib.ts"],"sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\nimport { execSync } from \"child_process\";\nimport { sync as globSync } from \"glob\";\nimport * as readline from \"readline\";\nimport { detect } from \"detect-package-manager\";\n\nfunction askQuestion(query: string): Promise<string> {\n return new Promise((resolve) => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n rl.question(query, (answer) => {\n rl.close();\n resolve(answer);\n });\n });\n}\n\nfunction isPackageInstalled(pkg: string): boolean {\n const cwd = process.cwd();\n try {\n const pkgJsonPath = path.join(cwd, \"package.json\");\n if (fs.existsSync(pkgJsonPath)) {\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf8\"));\n const deps = pkgJson.dependencies || {};\n const devDeps = pkgJson.devDependencies || {};\n if (deps[pkg] || devDeps[pkg]) {\n return true;\n }\n }\n } catch (e) {\n // Fall back to node_modules check below.\n }\n const modulePath = path.join(cwd, \"node_modules\", ...pkg.split(\"/\"));\n return fs.existsSync(modulePath);\n}\n\nexport default async function installEdgeLib(): Promise<void> {\n const cwd = process.cwd();\n const pattern = \"**/*.{js,jsx,ts,tsx}\";\n const files = globSync(pattern, {\n cwd,\n ignore: [\"**/node_modules/**\", \"**/dist/**\", \"**/build/**\"],\n });\n\n let found = false;\n for (const file of files) {\n const fullPath = path.join(cwd, file);\n const content = fs.readFileSync(fullPath, \"utf8\");\n if (content.includes(\"@assistant-ui/react-edge\")) {\n found = true;\n break;\n }\n }\n\n if (found) {\n if (isPackageInstalled(\"@assistant-ui/react-edge\")) {\n console.log(\n \"@assistant-ui/react-edge is already installed. Skipping installation.\",\n );\n return;\n }\n\n const answer = await askQuestion(\n \"Edge Runtime imports were added but @assistant-ui/react-edge is not installed. Do you want to install it? (Y/n) \",\n );\n if (answer === \"\" || answer.toLowerCase().startsWith(\"y\")) {\n const pm = await detect();\n let cmd = \"\";\n if (pm === \"yarn\") {\n cmd = \"yarn add @assistant-ui/react-edge\";\n } else if (pm === \"pnpm\") {\n cmd = \"pnpm add @assistant-ui/react-edge\";\n } else if (pm === \"bun\") {\n cmd = \"bun add @assistant-ui/react-edge\";\n } else {\n cmd = \"npm install @assistant-ui/react-edge\";\n }\n try {\n execSync(cmd, { stdio: \"inherit\" });\n } catch (e) {\n console.error(\"Installation failed:\", e);\n }\n } else {\n console.log(\"Skipping installation.\");\n }\n } else {\n console.log(\"No Edge Runtime imports found; skipping installation.\");\n }\n}\n"],"mappings":";AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,gBAAgB;AACzB,SAAS,QAAQ,gBAAgB;AACjC,YAAY,cAAc;AAC1B,SAAS,cAAc;AAEvB,SAAS,YAAY,OAAgC;AACnD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,KAAc,yBAAgB;AAAA,MAClC,OAAO,QAAQ;AAAA,MACf,QAAQ,QAAQ;AAAA,IAClB,CAAC;AACD,OAAG,SAAS,OAAO,CAAC,WAAW;AAC7B,SAAG,MAAM;AACT,cAAQ,MAAM;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;AAEA,SAAS,mBAAmB,KAAsB;AAChD,QAAM,MAAM,QAAQ,IAAI;AACxB,MAAI;AACF,UAAM,cAAmB,UAAK,KAAK,cAAc;AACjD,QAAO,cAAW,WAAW,GAAG;AAC9B,YAAM,UAAU,KAAK,MAAS,gBAAa,aAAa,MAAM,CAAC;AAC/D,YAAM,OAAO,QAAQ,gBAAgB,CAAC;AACtC,YAAM,UAAU,QAAQ,mBAAmB,CAAC;AAC5C,UAAI,KAAK,GAAG,KAAK,QAAQ,GAAG,GAAG;AAC7B,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,QAAM,aAAkB,UAAK,KAAK,gBAAgB,GAAG,IAAI,MAAM,GAAG,CAAC;AACnE,SAAU,cAAW,UAAU;AACjC;AAEA,eAAO,iBAAuD;AAC5D,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,UAAU;AAChB,QAAM,QAAQ,SAAS,SAAS;AAAA,IAC9B;AAAA,IACA,QAAQ,CAAC,sBAAsB,cAAc,aAAa;AAAA,EAC5D,CAAC;AAED,MAAI,QAAQ;AACZ,aAAW,QAAQ,OAAO;AACxB,UAAM,WAAgB,UAAK,KAAK,IAAI;AACpC,UAAM,UAAa,gBAAa,UAAU,MAAM;AAChD,QAAI,QAAQ,SAAS,0BAA0B,GAAG;AAChD,cAAQ;AACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAO;AACT,QAAI,mBAAmB,0BAA0B,GAAG;AAClD,cAAQ;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,SAAS,MAAM;AAAA,MACnB;AAAA,IACF;AACA,QAAI,WAAW,MAAM,OAAO,YAAY,EAAE,WAAW,GAAG,GAAG;AACzD,YAAM,KAAK,MAAM,OAAO;AACxB,UAAI,MAAM;AACV,UAAI,OAAO,QAAQ;AACjB,cAAM;AAAA,MACR,WAAW,OAAO,QAAQ;AACxB,cAAM;AAAA,MACR,WAAW,OAAO,OAAO;AACvB,cAAM;AAAA,MACR,OAAO;AACL,cAAM;AAAA,MACR;AACA,UAAI;AACF,iBAAS,KAAK,EAAE,OAAO,UAAU,CAAC;AAAA,MACpC,SAAS,GAAG;AACV,gBAAQ,MAAM,wBAAwB,CAAC;AAAA,MACzC;AAAA,IACF,OAAO;AACL,cAAQ,IAAI,wBAAwB;AAAA,IACtC;AAAA,EACF,OAAO;AACL,YAAQ,IAAI,uDAAuD;AAAA,EACrE;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/transform-options.ts"],"sourcesContent":["export interface TransformOptions {\n dry?: boolean;\n print?: boolean;\n verbose?: boolean;\n jscodeshift?: string;\n}"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/transform-options.ts"],"sourcesContent":["export interface TransformOptions {\n dry?: boolean;\n print?: boolean;\n verbose?: boolean;\n jscodeshift?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/lib/transform.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
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;
|
|
2
11
|
export type TransformErrors = {
|
|
3
12
|
transform: string;
|
|
4
13
|
filename: string;
|
|
@@ -6,5 +15,7 @@ export type TransformErrors = {
|
|
|
6
15
|
}[];
|
|
7
16
|
export declare function transform(codemod: string, source: string, transformOptions: TransformOptions, options?: {
|
|
8
17
|
logStatus: boolean;
|
|
18
|
+
onProgress?: (processedFiles: number) => void;
|
|
19
|
+
relevantFiles?: string[];
|
|
9
20
|
}): TransformErrors;
|
|
10
21
|
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/lib/transform.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
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,CAkBtD;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"}
|
package/dist/lib/transform.js
CHANGED
|
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/lib/transform.ts
|
|
31
31
|
var transform_exports = {};
|
|
32
32
|
__export(transform_exports, {
|
|
33
|
+
countFilesToProcess: () => countFilesToProcess,
|
|
34
|
+
getRelevantFiles: () => getRelevantFiles,
|
|
33
35
|
transform: () => transform
|
|
34
36
|
});
|
|
35
37
|
module.exports = __toCommonJS(transform_exports);
|
|
@@ -37,26 +39,41 @@ var import_child_process = require("child_process");
|
|
|
37
39
|
var import_debug = __toESM(require("debug"));
|
|
38
40
|
var import_path = __toESM(require("path"));
|
|
39
41
|
var import_url = require("url");
|
|
42
|
+
var fs = __toESM(require("fs"));
|
|
43
|
+
var import_glob = require("glob");
|
|
40
44
|
var import_meta = {};
|
|
41
45
|
var log = (0, import_debug.default)("codemod:transform");
|
|
42
46
|
var error = (0, import_debug.default)("codemod:transform:error");
|
|
43
47
|
var __filename = (0, import_url.fileURLToPath)(import_meta.url);
|
|
44
48
|
var __dirname = import_path.default.dirname(__filename);
|
|
45
|
-
function
|
|
49
|
+
function getRelevantFiles(cwd) {
|
|
50
|
+
const pattern = "**/*.{js,jsx,ts,tsx}";
|
|
51
|
+
const files = (0, import_glob.sync)(pattern, {
|
|
52
|
+
cwd,
|
|
53
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**", "**/*.min.js", "**/*.bundle.js"]
|
|
54
|
+
});
|
|
55
|
+
const relevantFiles = files.filter((file) => {
|
|
56
|
+
try {
|
|
57
|
+
const content = fs.readFileSync(import_path.default.join(cwd, file), "utf8");
|
|
58
|
+
return content.includes("assistant-ui");
|
|
59
|
+
} catch (err) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return relevantFiles.map((file) => import_path.default.join(cwd, file));
|
|
64
|
+
}
|
|
65
|
+
function countFilesToProcess(cwd) {
|
|
66
|
+
return getRelevantFiles(cwd).length;
|
|
67
|
+
}
|
|
68
|
+
function buildCommand(codemodPath, targetFiles, options) {
|
|
46
69
|
const command = [
|
|
47
70
|
"npx",
|
|
48
71
|
"jscodeshift",
|
|
49
72
|
"-t",
|
|
50
73
|
codemodPath,
|
|
51
|
-
|
|
74
|
+
...targetFiles,
|
|
52
75
|
"--parser",
|
|
53
|
-
"tsx"
|
|
54
|
-
"--ignore-pattern=**/node_modules/**",
|
|
55
|
-
"--ignore-pattern=**/.*/**",
|
|
56
|
-
"--ignore-pattern=**/dist/**",
|
|
57
|
-
"--ignore-pattern=**/build/**",
|
|
58
|
-
"--ignore-pattern=**/*.min.js",
|
|
59
|
-
"--ignore-pattern=**/*.bundle.js"
|
|
76
|
+
"tsx"
|
|
60
77
|
];
|
|
61
78
|
if (options.dry) {
|
|
62
79
|
command.push("--dry");
|
|
@@ -92,24 +109,52 @@ function transform(codemod, source, transformOptions, options = { logStatus: tru
|
|
|
92
109
|
log(`Applying codemod '${codemod}': ${source}`);
|
|
93
110
|
}
|
|
94
111
|
const codemodPath = import_path.default.resolve(__dirname, `../codemods/${codemod}.js`);
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
101
|
-
const
|
|
102
|
-
if (options.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
const targetFiles = options.relevantFiles || getRelevantFiles(source);
|
|
113
|
+
if (targetFiles.length === 0) {
|
|
114
|
+
log(`No relevant files found for codemod '${codemod}'`);
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
log(`Found ${targetFiles.length} relevant files for codemod '${codemod}'`);
|
|
118
|
+
const command = buildCommand(codemodPath, targetFiles, transformOptions);
|
|
119
|
+
if (options.onProgress) {
|
|
120
|
+
const result = (0, import_child_process.spawnSync)(command[0], command.slice(1), {
|
|
121
|
+
encoding: "utf8",
|
|
122
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
123
|
+
});
|
|
124
|
+
const stdout = result.stdout || "";
|
|
125
|
+
const processedFiles = (stdout.match(/Processing file/g) || []).length;
|
|
126
|
+
if (options.onProgress) {
|
|
127
|
+
options.onProgress(processedFiles);
|
|
128
|
+
}
|
|
129
|
+
const errors = parseErrors(codemod, stdout);
|
|
130
|
+
if (options.logStatus && errors.length > 0) {
|
|
131
|
+
errors.forEach(({ transform: transform2, filename, summary }) => {
|
|
132
|
+
error(
|
|
133
|
+
`Error applying codemod [codemod=${transform2}, path=${filename}, summary=${summary}]`
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return errors;
|
|
138
|
+
} else {
|
|
139
|
+
const stdout = (0, import_child_process.execFileSync)(command[0], command.slice(1), {
|
|
140
|
+
encoding: "utf8",
|
|
141
|
+
stdio: "pipe"
|
|
107
142
|
});
|
|
143
|
+
const errors = parseErrors(codemod, stdout);
|
|
144
|
+
if (options.logStatus && errors.length > 0) {
|
|
145
|
+
errors.forEach(({ transform: transform2, filename, summary }) => {
|
|
146
|
+
error(
|
|
147
|
+
`Error applying codemod [codemod=${transform2}, path=${filename}, summary=${summary}]`
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return errors;
|
|
108
152
|
}
|
|
109
|
-
return errors;
|
|
110
153
|
}
|
|
111
154
|
// Annotate the CommonJS export names for ESM import in node:
|
|
112
155
|
0 && (module.exports = {
|
|
156
|
+
countFilesToProcess,
|
|
157
|
+
getRelevantFiles,
|
|
113
158
|
transform
|
|
114
159
|
});
|
|
115
160
|
//# sourceMappingURL=transform.js.map
|