diff --git a/CHANGELOG.md b/CHANGELOG.md index 695dc16..ce34aa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Change Log +### 0.21.8 + +- Support triggering templates without a `state.json` file + ### 0.21.7 - Added trigger command diff --git a/client/package.json b/client/package.json index 7b4607a..7a76959 100755 --- a/client/package.json +++ b/client/package.json @@ -4,7 +4,7 @@ "description": "Accord Project extension for Visual Studio Code, providing tools for template development.", "author": "Accord Project", "license": "Apache-2.0", - "version": "0.21.7", + "version": "0.21.8", "publisher": "accordproject", "repository": { "type": "git", diff --git a/client/src/commandHandlers.ts b/client/src/commandHandlers.ts index 7463a9d..121ee4c 100755 --- a/client/src/commandHandlers.ts +++ b/client/src/commandHandlers.ts @@ -116,13 +116,6 @@ export async function triggerClause(file: vscode.Uri) { return false; } - const statePath = path.join(file.path, 'state.json'); - - if(!fs.existsSync(statePath)) { - vscode.window.showErrorMessage('Cannot trigger: /state.json file was not found.'); - return false; - } - const sampleText = fs.readFileSync( samplePath, 'utf8'); clause.parse(sampleText); const parseResult = clause.getData(); @@ -144,14 +137,22 @@ export async function triggerClause(file: vscode.Uri) { outputChannel.appendLine( JSON.stringify(request, null, 2) ); outputChannel.appendLine( '' ); - const state = JSON.parse(fs.readFileSync( requestPath, 'utf8')); + const statePath = path.join(file.path, 'state.json'); + const engine = new Engine(); + let state = null; + + if(!fs.existsSync(statePath)) { + const initResult = await engine.init(clause, null); + state = initResult.state; + } else { + state = JSON.parse(fs.readFileSync( statePath, 'utf8')); + } outputChannel.appendLine( 'state.json' ); outputChannel.appendLine( '==========' ); outputChannel.appendLine( JSON.stringify(state, null, 2) ); outputChannel.appendLine( '' ); - const engine = new Engine(); const result = await engine.trigger(clause, request, state, null ); outputChannel.appendLine( 'response' ); diff --git a/package.json b/package.json index 41828ea..89a6642 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Accord Project extension for Visual Studio Code, providing tools for template development.", "author": "Accord Project", "license": "Apache-2.0", - "version": "0.21.7", + "version": "0.21.8", "icon": "icon.png", "repository": { "type": "git", diff --git a/server/package.json b/server/package.json index 63b83ff..96839fe 100755 --- a/server/package.json +++ b/server/package.json @@ -1,7 +1,7 @@ { "name": "cicero-vscode-extension-server", "description": "A language server for Accord Project templates", - "version": "0.21.7", + "version": "0.21.8", "license": "Apache-2.0", "engines": { "node": "*"