@rimori/client 1.4.0 → 1.4.4
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/README.md +77 -71
- package/dist/cli/scripts/init/dev-registration.d.ts +1 -1
- package/dist/cli/scripts/init/dev-registration.js +4 -4
- package/dist/cli/scripts/init/main.js +1 -1
- package/dist/cli/scripts/init/package-setup.d.ts +1 -1
- package/dist/cli/scripts/init/package-setup.js +3 -3
- package/dist/cli/scripts/init/router-transformer.js +19 -12
- package/dist/cli/scripts/init/vite-config.d.ts +2 -2
- package/dist/cli/scripts/init/vite-config.js +2 -2
- package/dist/cli/scripts/release/release-config-upload.js +9 -9
- package/dist/cli/scripts/release/release-db-update.d.ts +1 -1
- package/dist/cli/scripts/release/release-db-update.js +9 -9
- package/dist/cli/scripts/release/release-file-upload.js +1 -1
- package/dist/cli/scripts/release/release.js +2 -2
- package/dist/components/CRUDModal.d.ts +1 -1
- package/dist/components/CRUDModal.js +3 -3
- package/dist/components/MarkdownEditor.js +16 -16
- package/dist/components/Spinner.js +2 -2
- package/dist/components/ai/Assistant.js +7 -8
- package/dist/components/ai/Avatar.d.ts +2 -2
- package/dist/components/ai/Avatar.js +10 -5
- package/dist/components/ai/EmbeddedAssistent/AudioInputField.js +5 -6
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +1 -1
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +1 -2
- package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +1 -2
- package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.js +4 -2
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +2 -3
- package/dist/components/audio/Playbutton.js +10 -7
- package/dist/components/components/ContextMenu.d.ts +1 -1
- package/dist/components/components/ContextMenu.js +19 -16
- package/dist/components.d.ts +10 -10
- package/dist/components.js +10 -10
- package/dist/core/controller/AIController.d.ts +2 -2
- package/dist/core/controller/AIController.js +12 -12
- package/dist/core/controller/ExerciseController.d.ts +2 -2
- package/dist/core/controller/ExerciseController.js +2 -2
- package/dist/core/controller/ObjectController.js +5 -5
- package/dist/core/controller/SettingsController.d.ts +22 -7
- package/dist/core/controller/SettingsController.js +73 -8
- package/dist/core/controller/SharedContentController.d.ts +3 -3
- package/dist/core/controller/SharedContentController.js +38 -20
- package/dist/core/controller/VoiceController.js +6 -4
- package/dist/core/core.d.ts +15 -15
- package/dist/core/core.js +7 -7
- package/dist/fromRimori/EventBus.js +23 -23
- package/dist/fromRimori/PluginTypes.d.ts +4 -4
- package/dist/hooks/UseChatHook.d.ts +3 -3
- package/dist/hooks/UseChatHook.js +9 -3
- package/dist/index.d.ts +10 -10
- package/dist/index.js +9 -9
- package/dist/plugin/AccomplishmentHandler.d.ts +5 -5
- package/dist/plugin/AccomplishmentHandler.js +31 -27
- package/dist/plugin/AudioController.d.ts +1 -1
- package/dist/plugin/AudioController.js +6 -6
- package/dist/plugin/Logger.js +15 -13
- package/dist/plugin/PluginController.d.ts +7 -1
- package/dist/plugin/PluginController.js +32 -27
- package/dist/plugin/RimoriClient.d.ts +17 -18
- package/dist/plugin/RimoriClient.js +31 -31
- package/dist/plugin/StandaloneClient.d.ts +1 -1
- package/dist/plugin/StandaloneClient.js +35 -16
- package/dist/plugin/ThemeSetter.js +4 -4
- package/dist/providers/PluginProvider.js +44 -14
- package/dist/utils/Language.js +57 -57
- package/dist/utils/PluginUtils.js +3 -3
- package/dist/utils/difficultyConverter.d.ts +1 -1
- package/dist/utils/difficultyConverter.js +1 -1
- package/dist/utils/endpoint.js +2 -2
- package/dist/worker/WorkerSetup.d.ts +1 -1
- package/dist/worker/WorkerSetup.js +6 -6
- package/example/docs/devdocs.md +50 -40
- package/example/docs/overview.md +1 -1
- package/example/docs/userdocs.md +4 -1
- package/example/rimori.config.ts +51 -49
- package/example/worker/vite.config.ts +3 -3
- package/example/worker/worker.ts +2 -2
- package/package.json +14 -8
- package/prettier.config.js +1 -1
- package/src/cli/scripts/init/dev-registration.ts +5 -8
- package/src/cli/scripts/init/env-setup.ts +1 -1
- package/src/cli/scripts/init/file-operations.ts +1 -1
- package/src/cli/scripts/init/html-cleaner.ts +2 -5
- package/src/cli/scripts/init/main.ts +16 -13
- package/src/cli/scripts/init/package-setup.ts +11 -15
- package/src/cli/scripts/init/router-transformer.ts +40 -37
- package/src/cli/scripts/init/tailwind-config.ts +17 -26
- package/src/cli/scripts/init/vite-config.ts +3 -3
- package/src/cli/scripts/release/release-config-upload.ts +11 -11
- package/src/cli/scripts/release/release-db-update.ts +12 -12
- package/src/cli/scripts/release/release-file-upload.ts +2 -2
- package/src/cli/scripts/release/release.ts +4 -4
- package/src/cli/types/DatabaseTypes.ts +2 -10
- package/src/components/CRUDModal.tsx +64 -48
- package/src/components/MarkdownEditor.tsx +58 -27
- package/src/components/Spinner.tsx +24 -17
- package/src/components/ai/Assistant.tsx +70 -70
- package/src/components/ai/Avatar.tsx +17 -14
- package/src/components/ai/EmbeddedAssistent/AudioInputField.tsx +63 -54
- package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +14 -5
- package/src/components/ai/EmbeddedAssistent/TTS/MessageSender.ts +75 -74
- package/src/components/ai/EmbeddedAssistent/TTS/Player.ts +3 -4
- package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +109 -94
- package/src/components/ai/utils.ts +4 -4
- package/src/components/audio/Playbutton.tsx +101 -93
- package/src/components/components/ContextMenu.tsx +47 -35
- package/src/components.ts +10 -10
- package/src/core/controller/AIController.ts +29 -19
- package/src/core/controller/ExerciseController.ts +16 -23
- package/src/core/controller/ObjectController.ts +15 -10
- package/src/core/controller/SettingsController.ts +89 -16
- package/src/core/controller/SharedContentController.ts +80 -44
- package/src/core/controller/VoiceController.ts +10 -8
- package/src/core/core.ts +15 -16
- package/src/fromRimori/EventBus.ts +76 -47
- package/src/fromRimori/PluginTypes.ts +26 -17
- package/src/fromRimori/readme.md +2 -2
- package/src/hooks/UseChatHook.ts +25 -15
- package/src/index.ts +10 -10
- package/src/plugin/AccomplishmentHandler.ts +53 -35
- package/src/plugin/AudioController.ts +18 -12
- package/src/plugin/Logger.ts +28 -21
- package/src/plugin/PluginController.ts +60 -44
- package/src/plugin/RimoriClient.ts +102 -72
- package/src/plugin/StandaloneClient.ts +51 -24
- package/src/plugin/ThemeSetter.ts +5 -5
- package/src/providers/PluginProvider.tsx +90 -36
- package/src/style.scss +3 -3
- package/src/utils/Language.ts +58 -58
- package/src/utils/PluginUtils.ts +16 -20
- package/src/utils/difficultyConverter.ts +2 -2
- package/src/utils/endpoint.ts +3 -2
- package/src/worker/WorkerSetup.ts +8 -9
- package/tsconfig.json +2 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimori/client",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -25,23 +25,29 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsc && sass src/style.scss:dist/style.css",
|
|
27
27
|
"dev": "tsc -w --preserveWatchOutput",
|
|
28
|
-
"css-dev": "sass --watch src/style.scss:dist/style.css"
|
|
28
|
+
"css-dev": "sass --watch src/style.scss:dist/style.css",
|
|
29
|
+
"lint": "eslint .",
|
|
30
|
+
"lint:fix": "eslint . --fix",
|
|
31
|
+
"format": "prettier --write .",
|
|
32
|
+
"format:check": "prettier --check .",
|
|
33
|
+
"check": "yarn lint && yarn format:check"
|
|
29
34
|
},
|
|
30
35
|
"peerDependencies": {
|
|
31
36
|
"react": "^18.0.0",
|
|
32
37
|
"react-dom": "^18.0.0"
|
|
33
38
|
},
|
|
34
39
|
"dependencies": {
|
|
35
|
-
"@supabase/supabase-js": "
|
|
40
|
+
"@supabase/supabase-js": "2.49.4",
|
|
36
41
|
"@tiptap/react": "2.10.3",
|
|
37
42
|
"@tiptap/starter-kit": "2.10.3",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"react-
|
|
41
|
-
"
|
|
43
|
+
"dotenv": "16.5.0",
|
|
44
|
+
"html2canvas": "1.4.1",
|
|
45
|
+
"react-icons": "5.4.0",
|
|
46
|
+
"react-markdown": "10.1.0",
|
|
47
|
+
"tiptap-markdown": "0.8.10",
|
|
48
|
+
"prettier": "^3.6.2"
|
|
42
49
|
},
|
|
43
50
|
"devDependencies": {
|
|
44
|
-
"dotenv": "^16.5.0",
|
|
45
51
|
"form-data": "^4.0.2",
|
|
46
52
|
"node-fetch": "^3.3.2",
|
|
47
53
|
"sass": "^1.82.0",
|
package/prettier.config.js
CHANGED
|
@@ -31,7 +31,7 @@ export async function askForCredentials(): Promise<UserCredentials> {
|
|
|
31
31
|
const passwordRl = readline.createInterface({
|
|
32
32
|
input: process.stdin,
|
|
33
33
|
output: process.stdout,
|
|
34
|
-
terminal: false
|
|
34
|
+
terminal: false,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
process.stdout.write('Enter your password: ');
|
|
@@ -113,10 +113,7 @@ export async function askForPort(): Promise<number> {
|
|
|
113
113
|
* @returns Promise resolving to JWT access token.
|
|
114
114
|
* @throws {Error} if authentication fails.
|
|
115
115
|
*/
|
|
116
|
-
export async function authenticateWithSupabase({
|
|
117
|
-
email,
|
|
118
|
-
password,
|
|
119
|
-
}: UserCredentials): Promise<string> {
|
|
116
|
+
export async function authenticateWithSupabase({ email, password }: UserCredentials): Promise<string> {
|
|
120
117
|
console.log('🔐 Authenticating with Supabase...');
|
|
121
118
|
|
|
122
119
|
// Initialize Supabase client (you may need to adjust the URL and key)
|
|
@@ -159,13 +156,13 @@ export async function registerDeveloper(jwtToken: string, port: number): Promise
|
|
|
159
156
|
try {
|
|
160
157
|
const currentFolderName = path.basename(process.cwd());
|
|
161
158
|
const body: any = { port, pluginName: currentFolderName };
|
|
162
|
-
const backendUrl = process.env.RIMORI_BACKEND_URL ||
|
|
159
|
+
const backendUrl = process.env.RIMORI_BACKEND_URL || 'https://api.rimori.se';
|
|
163
160
|
|
|
164
161
|
const response = await fetch(backendUrl + '/developer/register', {
|
|
165
162
|
method: 'POST',
|
|
166
163
|
headers: {
|
|
167
164
|
'Content-Type': 'application/json',
|
|
168
|
-
|
|
165
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
169
166
|
},
|
|
170
167
|
body: JSON.stringify(body),
|
|
171
168
|
});
|
|
@@ -189,4 +186,4 @@ export async function registerDeveloper(jwtToken: string, port: number): Promise
|
|
|
189
186
|
console.error(error);
|
|
190
187
|
throw new Error(`Developer registration failed: ${error}`);
|
|
191
188
|
}
|
|
192
|
-
}
|
|
189
|
+
}
|
|
@@ -8,10 +8,7 @@ import * as path from 'path';
|
|
|
8
8
|
*/
|
|
9
9
|
function removeUnwantedMetaTags(htmlContent: string): string {
|
|
10
10
|
// Remove all meta tags except those with name="viewport" or charset attribute
|
|
11
|
-
let cleanedContent = htmlContent.replace(
|
|
12
|
-
/<meta\s+(?![^>]*(?:name\s*=\s*["']viewport["']|charset\s*=))[^>]*>/gi,
|
|
13
|
-
''
|
|
14
|
-
);
|
|
11
|
+
let cleanedContent = htmlContent.replace(/<meta\s+(?![^>]*(?:name\s*=\s*["']viewport["']|charset\s*=))[^>]*>/gi, '');
|
|
15
12
|
|
|
16
13
|
// Remove empty lines left behind
|
|
17
14
|
cleanedContent = cleanedContent.replace(/^\s*[\r\n]/gm, '');
|
|
@@ -45,4 +42,4 @@ export function cleanHtmlMetaTags(): void {
|
|
|
45
42
|
} catch (error) {
|
|
46
43
|
console.error(`Error processing HTML file ${filePath}:`, error);
|
|
47
44
|
}
|
|
48
|
-
}
|
|
45
|
+
}
|
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
5
|
-
import {
|
|
6
|
-
askForCredentials,
|
|
7
|
-
askForPort,
|
|
8
|
-
authenticateWithSupabase,
|
|
9
|
-
registerDeveloper,
|
|
10
|
-
} from './dev-registration.js';
|
|
5
|
+
import { askForCredentials, askForPort, authenticateWithSupabase, registerDeveloper } from './dev-registration.js';
|
|
11
6
|
import { setupEnvFile, updateGitignore } from './env-setup.js';
|
|
12
7
|
import { copyPluginFiles } from './file-operations.js';
|
|
13
8
|
import { cleanHtmlMetaTags } from './html-cleaner.js';
|
|
@@ -42,8 +37,12 @@ async function main(): Promise<void> {
|
|
|
42
37
|
console.log('❌ Plugin is already initialized!');
|
|
43
38
|
console.log(`Plugin ID: ${packageJson.r_id}`);
|
|
44
39
|
console.log('');
|
|
45
|
-
console.log(
|
|
46
|
-
|
|
40
|
+
console.log(
|
|
41
|
+
'If you want to reinitialize the plugin, please remove the "r_id" field from package.json first.',
|
|
42
|
+
);
|
|
43
|
+
console.log(
|
|
44
|
+
'Or use the --upgrade flag to upgrade the plugin configuration without changing the plugin ID.',
|
|
45
|
+
);
|
|
47
46
|
process.exit(0);
|
|
48
47
|
}
|
|
49
48
|
} catch (error) {
|
|
@@ -83,7 +82,6 @@ async function main(): Promise<void> {
|
|
|
83
82
|
|
|
84
83
|
// Update gitignore
|
|
85
84
|
updateGitignore();
|
|
86
|
-
|
|
87
85
|
} else {
|
|
88
86
|
// Step 1: Get user credentials
|
|
89
87
|
const credentials = await askForCredentials();
|
|
@@ -125,7 +123,9 @@ async function main(): Promise<void> {
|
|
|
125
123
|
updateViteConfigBase();
|
|
126
124
|
console.log('✅ Vite config base updated');
|
|
127
125
|
} catch (error) {
|
|
128
|
-
console.warn(
|
|
126
|
+
console.warn(
|
|
127
|
+
`Warning: Could not update vite.config.ts base property: ${error instanceof Error ? error.message : error}`,
|
|
128
|
+
);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// Clean meta tags from index.html after vite adaptation
|
|
@@ -152,13 +152,16 @@ async function main(): Promise<void> {
|
|
|
152
152
|
console.log('Next steps:');
|
|
153
153
|
console.log('1. Check out ./rimori/readme.md for more information about how to make the most out of the plugin.');
|
|
154
154
|
console.log('2. Adapt the ./rimori/rimori.config.ts file to your needs.');
|
|
155
|
-
console.log(
|
|
155
|
+
console.log(
|
|
156
|
+
'3. Under ./public/docs/ you can find the documentation for an example flashcard plugin to get started easier.',
|
|
157
|
+
);
|
|
156
158
|
console.log('4. Start development with: yarn dev');
|
|
157
159
|
console.log('');
|
|
158
160
|
console.log(`The plugin should now be accessible at: http://localhost:${3000}`);
|
|
159
161
|
console.log('');
|
|
160
|
-
console.log(
|
|
161
|
-
|
|
162
|
+
console.log(
|
|
163
|
+
'If you want to release the plugin, simply run: "yarn release:<alpha|beta|stable>" (details are available in ./rimori/readme.md)',
|
|
164
|
+
);
|
|
162
165
|
} catch (error) {
|
|
163
166
|
console.error(`❌ Error: ${error instanceof Error ? error.message : error}`);
|
|
164
167
|
console.error('');
|
|
@@ -51,11 +51,7 @@ export function getRimoriClientVersion(): string {
|
|
|
51
51
|
* @param param.isUpgrade - Whether this is an upgrade operation.
|
|
52
52
|
* @throws {Error} if plugin directory doesn't exist or package.json is missing.
|
|
53
53
|
*/
|
|
54
|
-
export function updatePackageJson({
|
|
55
|
-
pluginId,
|
|
56
|
-
port,
|
|
57
|
-
isUpgrade = false,
|
|
58
|
-
}: PackageSetupParams): void {
|
|
54
|
+
export function updatePackageJson({ pluginId, port, isUpgrade = false }: PackageSetupParams): void {
|
|
59
55
|
// Get the plugin repo name from the current directory
|
|
60
56
|
const pluginRepoName = path.basename(process.cwd());
|
|
61
57
|
console.log(`Setting up plugin: ${pluginRepoName}`);
|
|
@@ -93,18 +89,18 @@ export function updatePackageJson({
|
|
|
93
89
|
}
|
|
94
90
|
packageJson.scripts = {
|
|
95
91
|
...packageJson.scripts,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
dev: `vite --port ${port || 3000}`,
|
|
93
|
+
build: 'yarn run check && vite build',
|
|
94
|
+
check: 'tsc --project tsconfig.app.json --noEmit --pretty',
|
|
95
|
+
'release:alpha': 'yarn build && yarn rimori-release alpha',
|
|
96
|
+
'release:beta': 'yarn build && yarn rimori-release beta',
|
|
97
|
+
'release:stable': 'yarn build && yarn rimori-release stable',
|
|
98
|
+
'dev:worker': 'VITE_MINIFY=false vite build --watch --config worker/vite.config.ts',
|
|
99
|
+
'build:worker': 'vite build --config worker/vite.config.ts',
|
|
104
100
|
};
|
|
105
101
|
packageJson.dependencies = {
|
|
106
102
|
...packageJson.dependencies,
|
|
107
|
-
|
|
103
|
+
'@rimori/client': rimoriClientVersion,
|
|
108
104
|
};
|
|
109
105
|
|
|
110
106
|
// Write the updated package.json back to file
|
|
@@ -114,4 +110,4 @@ export function updatePackageJson({
|
|
|
114
110
|
} catch (error) {
|
|
115
111
|
throw new Error(`Failed to update package.json: ${error}`);
|
|
116
112
|
}
|
|
117
|
-
}
|
|
113
|
+
}
|
|
@@ -89,14 +89,14 @@ function detectRouteComponents(content: string): RouteComponent[] {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// For each component, find its corresponding import statement
|
|
92
|
-
componentNames.forEach(componentName => {
|
|
92
|
+
componentNames.forEach((componentName) => {
|
|
93
93
|
const importInfo = findImportForComponent(content, componentName);
|
|
94
94
|
if (importInfo) {
|
|
95
95
|
routeComponents.push({
|
|
96
96
|
componentName,
|
|
97
97
|
importStatement: importInfo.importStatement,
|
|
98
98
|
importPath: importInfo.importPath,
|
|
99
|
-
isDefaultImport: importInfo.isDefaultImport
|
|
99
|
+
isDefaultImport: importInfo.isDefaultImport,
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
});
|
|
@@ -111,7 +111,10 @@ function detectRouteComponents(content: string): RouteComponent[] {
|
|
|
111
111
|
* @param componentName - The component name to find import for
|
|
112
112
|
* @returns Import information or null if not found
|
|
113
113
|
*/
|
|
114
|
-
function findImportForComponent(
|
|
114
|
+
function findImportForComponent(
|
|
115
|
+
content: string,
|
|
116
|
+
componentName: string,
|
|
117
|
+
): {
|
|
115
118
|
importStatement: string;
|
|
116
119
|
importPath: string;
|
|
117
120
|
isDefaultImport: boolean;
|
|
@@ -124,7 +127,7 @@ function findImportForComponent(content: string, componentName: string): {
|
|
|
124
127
|
return {
|
|
125
128
|
importStatement: defaultMatch[0],
|
|
126
129
|
importPath: defaultMatch[1],
|
|
127
|
-
isDefaultImport: true
|
|
130
|
+
isDefaultImport: true,
|
|
128
131
|
};
|
|
129
132
|
}
|
|
130
133
|
|
|
@@ -133,12 +136,12 @@ function findImportForComponent(content: string, componentName: string): {
|
|
|
133
136
|
let namedMatch;
|
|
134
137
|
|
|
135
138
|
while ((namedMatch = namedImportRegex.exec(content)) !== null) {
|
|
136
|
-
const imports = namedMatch[1].split(',').map(imp => imp.trim());
|
|
139
|
+
const imports = namedMatch[1].split(',').map((imp) => imp.trim());
|
|
137
140
|
if (imports.includes(componentName)) {
|
|
138
141
|
return {
|
|
139
142
|
importStatement: namedMatch[0],
|
|
140
143
|
importPath: namedMatch[2],
|
|
141
|
-
isDefaultImport: false
|
|
144
|
+
isDefaultImport: false,
|
|
142
145
|
};
|
|
143
146
|
}
|
|
144
147
|
}
|
|
@@ -191,7 +194,10 @@ function addLazyImport(content: string): string {
|
|
|
191
194
|
if (reactImportMatch) {
|
|
192
195
|
// React import exists, add lazy to it
|
|
193
196
|
const existingImports = reactImportMatch[1] || '';
|
|
194
|
-
const importList = existingImports
|
|
197
|
+
const importList = existingImports
|
|
198
|
+
.split(',')
|
|
199
|
+
.map((imp) => imp.trim())
|
|
200
|
+
.filter(Boolean);
|
|
195
201
|
|
|
196
202
|
if (!importList.includes('lazy')) {
|
|
197
203
|
importList.push('lazy');
|
|
@@ -200,16 +206,18 @@ function addLazyImport(content: string): string {
|
|
|
200
206
|
importList.push('Suspense');
|
|
201
207
|
}
|
|
202
208
|
|
|
203
|
-
const newImport =
|
|
204
|
-
? `import React, { ${importList.join(', ')} } from "react";`
|
|
205
|
-
: `import React from "react";`;
|
|
209
|
+
const newImport =
|
|
210
|
+
importList.length > 0 ? `import React, { ${importList.join(', ')} } from "react";` : `import React from "react";`;
|
|
206
211
|
|
|
207
212
|
return content.replace(reactImportMatch[0], newImport);
|
|
208
213
|
} else {
|
|
209
214
|
// No React import found, add it
|
|
210
215
|
const firstImportMatch = content.match(/^import.*$/m);
|
|
211
216
|
if (firstImportMatch) {
|
|
212
|
-
return content.replace(
|
|
217
|
+
return content.replace(
|
|
218
|
+
firstImportMatch[0],
|
|
219
|
+
`import React, { lazy, Suspense } from "react";\n${firstImportMatch[0]}`,
|
|
220
|
+
);
|
|
213
221
|
} else {
|
|
214
222
|
// No imports found, add at the beginning
|
|
215
223
|
return `import React, { lazy, Suspense } from "react";\n${content}`;
|
|
@@ -266,39 +274,34 @@ function transformImports(content: string): string {
|
|
|
266
274
|
// Add new import line for PluginProvider
|
|
267
275
|
const importMatch = content.match(/^(import.*from\s+["']react["'];?\s*\n)/m);
|
|
268
276
|
if (importMatch) {
|
|
269
|
-
content = content.replace(
|
|
270
|
-
importMatch[0],
|
|
271
|
-
`${importMatch[0]}import { PluginProvider } from "@rimori/client";\n`
|
|
272
|
-
);
|
|
277
|
+
content = content.replace(importMatch[0], `${importMatch[0]}import { PluginProvider } from "@rimori/client";\n`);
|
|
273
278
|
} else {
|
|
274
279
|
// If no React import found, add at the beginning
|
|
275
280
|
content = `import { PluginProvider } from "@rimori/client";\n${content}`;
|
|
276
281
|
}
|
|
277
282
|
} else {
|
|
278
283
|
// Update existing @rimori/client import to include PluginProvider
|
|
279
|
-
content = content.replace(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return `import { ${importList.join(', ')} } from "@rimori/client";`;
|
|
284
|
+
content = content.replace(/import\s*{\s*([^}]*)\s*}\s*from\s*["']@rimori\/client["'];?/, (match, imports) => {
|
|
285
|
+
const importList = imports
|
|
286
|
+
.split(',')
|
|
287
|
+
.map((imp: string) => imp.trim())
|
|
288
|
+
.filter(Boolean);
|
|
289
|
+
if (!importList.includes('PluginProvider')) {
|
|
290
|
+
importList.push('PluginProvider');
|
|
287
291
|
}
|
|
288
|
-
|
|
292
|
+
return `import { ${importList.join(', ')} } from "@rimori/client";`;
|
|
293
|
+
});
|
|
289
294
|
}
|
|
290
295
|
|
|
291
296
|
// Transform react-router-dom import: replace BrowserRouter with HashRouter
|
|
292
|
-
content = content.replace(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
);
|
|
297
|
+
content = content.replace(/import\s*{\s*([^}]*)\s*}\s*from\s*["']react-router-dom["'];?/, (match, imports) => {
|
|
298
|
+
const importList = imports
|
|
299
|
+
.split(',')
|
|
300
|
+
.map((imp: string) => imp.trim())
|
|
301
|
+
.filter(Boolean);
|
|
302
|
+
const updatedImports = importList.map((imp: string) => (imp === 'BrowserRouter' ? 'HashRouter' : imp));
|
|
303
|
+
return `import { ${updatedImports.join(', ')} } from "react-router-dom";`;
|
|
304
|
+
});
|
|
302
305
|
|
|
303
306
|
return content;
|
|
304
307
|
}
|
|
@@ -315,15 +318,15 @@ function transformJSX(content: string, pluginId: string): string {
|
|
|
315
318
|
content = content.replace(
|
|
316
319
|
/<BrowserRouter(\s[^>]*)?>/,
|
|
317
320
|
`<PluginProvider pluginId="${pluginId}">
|
|
318
|
-
<HashRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}
|
|
321
|
+
<HashRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>`,
|
|
319
322
|
);
|
|
320
323
|
|
|
321
324
|
// Replace closing BrowserRouter tag
|
|
322
325
|
content = content.replace(
|
|
323
326
|
/<\/BrowserRouter>/,
|
|
324
327
|
`</HashRouter>
|
|
325
|
-
</PluginProvider
|
|
328
|
+
</PluginProvider>`,
|
|
326
329
|
);
|
|
327
330
|
|
|
328
331
|
return content;
|
|
329
|
-
}
|
|
332
|
+
}
|
|
@@ -21,16 +21,10 @@ export function updateTailwindConfig(): void {
|
|
|
21
21
|
|
|
22
22
|
// Set darkMode to "class" if it exists, otherwise add it
|
|
23
23
|
if (updatedContent.includes('darkMode:')) {
|
|
24
|
-
updatedContent = updatedContent.replace(
|
|
25
|
-
/darkMode:\s*\[?"[^"]*"?\]?,?/g,
|
|
26
|
-
'darkMode: ["class"],'
|
|
27
|
-
);
|
|
24
|
+
updatedContent = updatedContent.replace(/darkMode:\s*\[?"[^"]*"?\]?,?/g, 'darkMode: ["class"],');
|
|
28
25
|
} else {
|
|
29
26
|
// Add darkMode after the opening brace
|
|
30
|
-
updatedContent = updatedContent.replace(
|
|
31
|
-
/export default \{/,
|
|
32
|
-
'export default {\n darkMode: ["class"],'
|
|
33
|
-
);
|
|
27
|
+
updatedContent = updatedContent.replace(/export default \{/, 'export default {\n darkMode: ["class"],');
|
|
34
28
|
}
|
|
35
29
|
|
|
36
30
|
// Add Rimori client package to content array if not already present
|
|
@@ -38,31 +32,28 @@ export function updateTailwindConfig(): void {
|
|
|
38
32
|
// Find the content array and add the Rimori client path
|
|
39
33
|
if (updatedContent.includes('content:')) {
|
|
40
34
|
// More precise regex to handle the content array properly
|
|
41
|
-
updatedContent = updatedContent.replace(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// Clean up any existing double commas first
|
|
45
|
-
let cleanContent = content.replace(/,\s*,/g, ',');
|
|
35
|
+
updatedContent = updatedContent.replace(/(content:\s*\[)([\s\S]*?)(\])/, (match, start, content, end) => {
|
|
36
|
+
// Clean up any existing double commas first
|
|
37
|
+
let cleanContent = content.replace(/,\s*,/g, ',');
|
|
46
38
|
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
// Remove trailing comma and whitespace
|
|
40
|
+
cleanContent = cleanContent.replace(/,\s*$/, '');
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
// Add the new path with proper formatting
|
|
43
|
+
const newPath = '"node_modules/@rimori/client/dist/components/**/*.{js,jsx}"';
|
|
52
44
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
45
|
+
// If content is not empty, add comma before new entry
|
|
46
|
+
if (cleanContent.trim()) {
|
|
47
|
+
return `${start}${cleanContent},\n ${newPath}\n ${end}`;
|
|
48
|
+
} else {
|
|
49
|
+
return `${start}\n ${newPath}\n ${end}`;
|
|
59
50
|
}
|
|
60
|
-
);
|
|
51
|
+
});
|
|
61
52
|
} else {
|
|
62
53
|
// Add content array if it doesn't exist
|
|
63
54
|
updatedContent = updatedContent.replace(
|
|
64
55
|
/darkMode: \["class"\],/,
|
|
65
|
-
'darkMode: ["class"],\n content: [\n "./src/**/*.{js,jsx,ts,tsx}",\n "node_modules/@rimori/client/dist/components/**/*.{js,jsx}"\n ],'
|
|
56
|
+
'darkMode: ["class"],\n content: [\n "./src/**/*.{js,jsx,ts,tsx}",\n "node_modules/@rimori/client/dist/components/**/*.{js,jsx}"\n ],',
|
|
66
57
|
);
|
|
67
58
|
}
|
|
68
59
|
}
|
|
@@ -72,4 +63,4 @@ export function updateTailwindConfig(): void {
|
|
|
72
63
|
} catch (error) {
|
|
73
64
|
console.warn(`Warning: Could not update tailwind.config.ts: ${error instanceof Error ? error.message : error}`);
|
|
74
65
|
}
|
|
75
|
-
}
|
|
66
|
+
}
|
|
@@ -10,7 +10,7 @@ import * as path from 'path';
|
|
|
10
10
|
*/
|
|
11
11
|
export function updateViteConfigBase({
|
|
12
12
|
basePath = './',
|
|
13
|
-
configPath = './vite.config.ts'
|
|
13
|
+
configPath = './vite.config.ts',
|
|
14
14
|
}: {
|
|
15
15
|
basePath?: string;
|
|
16
16
|
configPath?: string;
|
|
@@ -56,7 +56,7 @@ export function updateViteConfigBase({
|
|
|
56
56
|
* @returns The current base value or null if not found.
|
|
57
57
|
*/
|
|
58
58
|
export function getCurrentViteBase({
|
|
59
|
-
configPath = './vite.config.ts'
|
|
59
|
+
configPath = './vite.config.ts',
|
|
60
60
|
}: {
|
|
61
61
|
configPath?: string;
|
|
62
62
|
} = {}): string | null {
|
|
@@ -70,4 +70,4 @@ export function getCurrentViteBase({
|
|
|
70
70
|
const baseMatch = configContent.match(/base:\s*['"]([^'"]*)['"]/);
|
|
71
71
|
|
|
72
72
|
return baseMatch ? baseMatch[1] : null;
|
|
73
|
-
}
|
|
73
|
+
}
|
|
@@ -26,7 +26,7 @@ export async function sendConfiguration(config: Config): Promise<string> {
|
|
|
26
26
|
// Transpile TypeScript to JavaScript
|
|
27
27
|
const result = ts.transpile(configContent, {
|
|
28
28
|
target: ts.ScriptTarget.ES2020,
|
|
29
|
-
module: ts.ModuleKind.ES2020
|
|
29
|
+
module: ts.ModuleKind.ES2020,
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
// Create a temporary file to import the transpiled code
|
|
@@ -44,7 +44,7 @@ export async function sendConfiguration(config: Config): Promise<string> {
|
|
|
44
44
|
// Clean up temp file even on error
|
|
45
45
|
try {
|
|
46
46
|
await fs.promises.unlink(tempFile);
|
|
47
|
-
} catch (e) {
|
|
47
|
+
} catch (e) {}
|
|
48
48
|
throw error;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -67,7 +67,7 @@ export async function sendConfiguration(config: Config): Promise<string> {
|
|
|
67
67
|
method: 'POST',
|
|
68
68
|
headers: {
|
|
69
69
|
'Content-Type': 'application/json',
|
|
70
|
-
|
|
70
|
+
Authorization: `Bearer ${config.token}`,
|
|
71
71
|
},
|
|
72
72
|
body: JSON.stringify(requestBody),
|
|
73
73
|
});
|
|
@@ -87,8 +87,8 @@ export async function sendConfiguration(config: Config): Promise<string> {
|
|
|
87
87
|
throw new Error('Configuration upload failed');
|
|
88
88
|
}
|
|
89
89
|
} catch (e) {
|
|
90
|
-
console.log(
|
|
91
|
-
throw new Error(
|
|
90
|
+
console.log('error', e);
|
|
91
|
+
throw new Error('Error sending configuration');
|
|
92
92
|
}
|
|
93
93
|
} catch (error: any) {
|
|
94
94
|
console.error('❌ Error sending configuration:', error.message);
|
|
@@ -101,14 +101,14 @@ export async function releasePlugin(config: Config, release_id: string): Promise
|
|
|
101
101
|
method: 'POST',
|
|
102
102
|
headers: {
|
|
103
103
|
'Content-Type': 'application/json',
|
|
104
|
-
|
|
104
|
+
Authorization: `Bearer ${config.token}`,
|
|
105
105
|
},
|
|
106
|
-
body: JSON.stringify({ plugin_id: config.plugin_id })
|
|
106
|
+
body: JSON.stringify({ plugin_id: config.plugin_id }),
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
if (!response.ok) {
|
|
110
|
-
console.log(
|
|
111
|
-
throw new Error(
|
|
110
|
+
console.log('Response:', await response.text());
|
|
111
|
+
throw new Error('Failed to release plugin');
|
|
112
112
|
}
|
|
113
|
-
console.log(
|
|
114
|
-
}
|
|
113
|
+
console.log('✅ Plugin released successfully');
|
|
114
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import ts from 'typescript';
|
|
4
|
-
import { Config } from
|
|
4
|
+
import { Config } from './release';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Read and send the database configuration to the release endpoint
|
|
@@ -27,7 +27,7 @@ export default async function dbUpdate(config: Config, release_id: string): Prom
|
|
|
27
27
|
// Transpile TypeScript to JavaScript
|
|
28
28
|
const result = ts.transpile(dbConfigContent, {
|
|
29
29
|
target: ts.ScriptTarget.ES2020,
|
|
30
|
-
module: ts.ModuleKind.ES2020
|
|
30
|
+
module: ts.ModuleKind.ES2020,
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
// Create a temporary file to import the transpiled code
|
|
@@ -45,7 +45,7 @@ export default async function dbUpdate(config: Config, release_id: string): Prom
|
|
|
45
45
|
// Clean up temp file even on error
|
|
46
46
|
try {
|
|
47
47
|
await fs.promises.unlink(tempFile);
|
|
48
|
-
} catch (e) {
|
|
48
|
+
} catch (e) {}
|
|
49
49
|
throw error;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -66,32 +66,32 @@ export default async function dbUpdate(config: Config, release_id: string): Prom
|
|
|
66
66
|
method: 'POST',
|
|
67
67
|
headers: {
|
|
68
68
|
'Content-Type': 'application/json',
|
|
69
|
-
|
|
69
|
+
Authorization: `Bearer ${config.token}`,
|
|
70
70
|
},
|
|
71
71
|
body: JSON.stringify(requestBody),
|
|
72
72
|
}).catch((e) => {
|
|
73
|
-
console.log(
|
|
74
|
-
throw new Error(
|
|
73
|
+
console.log('error', e);
|
|
74
|
+
throw new Error('Error sending database configuration');
|
|
75
75
|
});
|
|
76
76
|
try {
|
|
77
77
|
const responseText = await response.text().catch((e) => {
|
|
78
|
-
console.log(
|
|
79
|
-
throw new Error(
|
|
78
|
+
console.log('error', e);
|
|
79
|
+
throw new Error('Error sending database configuration');
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
const responseData = JSON.parse(responseText);
|
|
83
83
|
if (response.ok) {
|
|
84
84
|
console.log('✅ Database configuration deployed successfully!');
|
|
85
85
|
} else {
|
|
86
|
-
console.log(
|
|
86
|
+
console.log('responseData', responseData);
|
|
87
87
|
throw new Error(responseData.message);
|
|
88
88
|
}
|
|
89
89
|
} catch (e) {
|
|
90
|
-
console.log(
|
|
91
|
-
throw new Error(
|
|
90
|
+
console.log('error', e);
|
|
91
|
+
throw new Error('Error sending database configuration');
|
|
92
92
|
}
|
|
93
93
|
} catch (error: any) {
|
|
94
94
|
console.error('❌ Error sending database configuration:', error.message);
|
|
95
95
|
throw error;
|
|
96
96
|
}
|
|
97
|
-
}
|
|
97
|
+
}
|
|
@@ -69,7 +69,7 @@ export async function uploadDirectory(config: Config, release_id: string): Promi
|
|
|
69
69
|
// Upload to the release endpoint
|
|
70
70
|
const response = await fetch(`${config.domain}/release/${release_id}/files`, {
|
|
71
71
|
method: 'POST',
|
|
72
|
-
headers: {
|
|
72
|
+
headers: { Authorization: `Bearer ${config.token}` },
|
|
73
73
|
body: formData,
|
|
74
74
|
});
|
|
75
75
|
|
|
@@ -135,4 +135,4 @@ function getContentType(filePath: string): string {
|
|
|
135
135
|
const contentType = contentTypes[ext || ''];
|
|
136
136
|
if (!contentType) throw new Error(`Unsupported file type: ${ext}`);
|
|
137
137
|
return contentType;
|
|
138
|
-
}
|
|
138
|
+
}
|