Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "lowcode",
"description": "lowcode tool, support ChatGPT and other LLM",
"author": "wjkang <ruoxieme@gmail.com>",
"version": "1.7.9",
"version": "1.8.0",
"icon": "asset/icon.png",
"publisher": "wjkang",
"repository": "https://github.com/lowcoding/lowcode-vscode",
Expand Down
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { registerQuickGenerateBlock } from './commands/quickGenerateBlock';
import { registerChatGPTViewProvider } from './webview';
import { registerChatGPTCommand } from './commands/chatGPT';
import { registerRunSnippetScript } from './commands/runSnippetScript';
import { runActivate } from './lifecycle';

export function activate(context: vscode.ExtensionContext) {
vscode.window.onDidChangeActiveTextEditor(
Expand All @@ -23,6 +24,8 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions,
);

runActivate();

init({ extensionContext: context, extensionPath: context.extensionPath });

generateCode(context);
Expand Down
29 changes: 29 additions & 0 deletions src/lifecycle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as path from 'path';
import * as fs from 'fs-extra';
import { window } from 'vscode';
import { getSnippets } from './utils/materials';
import { getEnv, rootPath } from './utils/vscodeEnv';

export const runActivate = () => {
const templateList = getSnippets().filter((s) => s.preview.runActivate);
templateList.forEach((template) => {
const scriptFile = path.join(template!.path, 'script/index.js');
if (fs.existsSync(scriptFile)) {
// delete eval('require').cache[eval('require').resolve(scriptFile)];
const script = eval('require')(scriptFile);
if (script.onActivate) {
const context = {
workspaceRootPath: rootPath,
env: getEnv(),
materialPath: template!.path,
code: '',
};
try {
script.onActivate(context);
} catch (ex: any) {
window.showErrorMessage(`${template.name}:${ex.toString()}`);
}
}
}
});
};
2 changes: 2 additions & 0 deletions src/utils/materials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const getLocalMaterials = (
notShowInintellisense?: boolean;
showInRunSnippetScript?: boolean;
showInRunSnippetScriptOnExplorer?: boolean;
runActivate?: boolean;
schema?: string;
chatGPT?: {
commandPrompt?: string;
Expand Down Expand Up @@ -188,6 +189,7 @@ export function getSnippets() {
notShowInintellisense?: boolean;
showInRunSnippetScript?: boolean;
showInRunSnippetScriptOnExplorer?: boolean;
runActivate?: boolean;
schema?: string;
chatGPT?: {
commandPrompt?: string;
Expand Down