File tree Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 33 "displayName" : " lowcode" ,
44 "description" : " lowcode tool, support ChatGPT and other LLM" ,
55 "author" :
" wjkang <[email protected] >" ,
6- "version" : " 1.7.9 " ,
6+ "version" : " 1.8.0 " ,
77 "icon" : " asset/icon.png" ,
88 "publisher" : " wjkang" ,
99 "repository" : " https://github.com/lowcoding/lowcode-vscode" ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { registerQuickGenerateBlock } from './commands/quickGenerateBlock';
1010import { registerChatGPTViewProvider } from './webview' ;
1111import { registerChatGPTCommand } from './commands/chatGPT' ;
1212import { registerRunSnippetScript } from './commands/runSnippetScript' ;
13+ import { runActivate } from './lifecycle' ;
1314
1415export function activate ( context : vscode . ExtensionContext ) {
1516 vscode . window . onDidChangeActiveTextEditor (
@@ -23,6 +24,8 @@ export function activate(context: vscode.ExtensionContext) {
2324 context . subscriptions ,
2425 ) ;
2526
27+ runActivate ( ) ;
28+
2629 init ( { extensionContext : context , extensionPath : context . extensionPath } ) ;
2730
2831 generateCode ( context ) ;
Original file line number Diff line number Diff line change 1+ import * as path from 'path' ;
2+ import * as fs from 'fs-extra' ;
3+ import { window } from 'vscode' ;
4+ import { getSnippets } from './utils/materials' ;
5+ import { getEnv , rootPath } from './utils/vscodeEnv' ;
6+
7+ export const runActivate = ( ) => {
8+ const templateList = getSnippets ( ) . filter ( ( s ) => s . preview . runActivate ) ;
9+ templateList . forEach ( ( template ) => {
10+ const scriptFile = path . join ( template ! . path , 'script/index.js' ) ;
11+ if ( fs . existsSync ( scriptFile ) ) {
12+ // delete eval('require').cache[eval('require').resolve(scriptFile)];
13+ const script = eval ( 'require' ) ( scriptFile ) ;
14+ if ( script . onActivate ) {
15+ const context = {
16+ workspaceRootPath : rootPath ,
17+ env : getEnv ( ) ,
18+ materialPath : template ! . path ,
19+ code : '' ,
20+ } ;
21+ try {
22+ script . onActivate ( context ) ;
23+ } catch ( ex : any ) {
24+ window . showErrorMessage ( `${ template . name } :${ ex . toString ( ) } ` ) ;
25+ }
26+ }
27+ }
28+ } ) ;
29+ } ;
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export const getLocalMaterials = (
3333 notShowInintellisense ?: boolean ;
3434 showInRunSnippetScript ?: boolean ;
3535 showInRunSnippetScriptOnExplorer ?: boolean ;
36+ runActivate ?: boolean ;
3637 schema ?: string ;
3738 chatGPT ?: {
3839 commandPrompt ?: string ;
@@ -188,6 +189,7 @@ export function getSnippets() {
188189 notShowInintellisense ?: boolean ;
189190 showInRunSnippetScript ?: boolean ;
190191 showInRunSnippetScriptOnExplorer ?: boolean ;
192+ runActivate ?: boolean ;
191193 schema ?: string ;
192194 chatGPT ?: {
193195 commandPrompt ?: string ;
You can’t perform that action at this time.
0 commit comments