diff --git a/CHANGELOG.md b/CHANGELOG.md index 5951ae4..eeb7930 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Added - `Update` command to manually check for Argon updates +- JSON schema for `*.model.json` files ### Changed - Argon now checks for updates automatically every time you start extension +- `Init` command now overrides the global CLI config ## [2.0.1] - 2024-05-02 diff --git a/assets/data.schema.json b/assets/schemas/data.json similarity index 100% rename from assets/data.schema.json rename to assets/schemas/data.json diff --git a/assets/schemas/model.json b/assets/schemas/model.json new file mode 100644 index 0000000..41a879a --- /dev/null +++ b/assets/schemas/model.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "className": { + "type": "string" + }, + "properties": { + "type": "object", + "properties": { + "Name": false, + "Parent": false + } + }, + "children": { + "type": "array", + "items": { + "$ref": "#/$definitions/node" + } + } + }, + "$definitions": { + "node": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "className": { + "type": "string" + }, + "properties": { + "type": "object", + "properties": { + "Name": false, + "Parent": false + } + }, + "children": { + "type": "array", + "items": { + "$ref": "#/$definitions/node" + } + } + } + } + } +} diff --git a/assets/project.schema.json b/assets/schemas/project.json similarity index 100% rename from assets/project.schema.json rename to assets/schemas/project.json diff --git a/package.json b/package.json index 4e0fdf3..02cfecf 100644 --- a/package.json +++ b/package.json @@ -127,15 +127,19 @@ "jsonValidation": [ { "fileMatch": "*.project.json", - "url": "./assets/project.schema.json" + "url": "./assets/schemas/project.json" }, { "fileMatch": "*.data.json", - "url": "./assets/data.schema.json" + "url": "./assets/schemas/data.json" }, { "fileMatch": "*.meta.json", - "url": "./assets/data.schema.json" + "url": "./assets/schemas/data.json" + }, + { + "fileMatch": "*.model.json", + "url": "./assets/schemas/model.json" } ], "icons": { diff --git a/src/menu/build.ts b/src/menu/build.ts index fe83063..25767e1 100644 --- a/src/menu/build.ts +++ b/src/menu/build.ts @@ -81,7 +81,7 @@ function getOptions(context: vscode.ExtensionContext): Promise { options.forEach((item) => { context.globalState.update( item.id, - items.find((i) => i.id === item.id) !== undefined, + items.some((i) => i.id === item.id), ) }) diff --git a/src/menu/init.ts b/src/menu/init.ts index 9617ee1..2c5fb4d 100644 --- a/src/menu/init.ts +++ b/src/menu/init.ts @@ -11,6 +11,8 @@ export const item: Item = { action: 'init', } +const ALL_OPTIONS = ['--docs', '--git', '--wally', '--ts'] + function getProjectName(): Promise { return new Promise((resolve, reject) => { vscode.window @@ -113,7 +115,7 @@ function getProjectOptions( options.forEach((item) => { context.globalState.update( item.id, - items.find((i) => i.id === item.id) !== undefined, + items.some((i) => i.id === item.id), ) }) @@ -125,7 +127,15 @@ function getProjectOptions( export async function handler(context: vscode.ExtensionContext) { let name = await getProjectName() const template = await getProjectTemplate() - const options = await getProjectOptions(context) + + const selectedOptions = await getProjectOptions(context) + const options: string[] = [] + + ALL_OPTIONS.forEach((option) => { + options.push(`${option}=${selectedOptions.includes(option)}`) + }) + + console.log(options) if (!name.endsWith('.project.json')) { name += '.project.json' diff --git a/src/menu/serve.ts b/src/menu/serve.ts index 39ac07f..6d1a2da 100644 --- a/src/menu/serve.ts +++ b/src/menu/serve.ts @@ -108,13 +108,13 @@ function getOptions( options.forEach((item) => { context.globalState.update( item.id, - items.find((i) => i.id === item.id) !== undefined, + items.some((i) => i.id === item.id), ) }) resolve([ items.flatMap((item) => (item.flag ? [item.flag] : [])), - items.find((item) => item.id === 'customAddress') !== undefined, + items.some((item) => item.id === 'customAddress'), ]) }) }) diff --git a/src/menu/sourcemap.ts b/src/menu/sourcemap.ts index 83196c0..274d1c7 100644 --- a/src/menu/sourcemap.ts +++ b/src/menu/sourcemap.ts @@ -63,7 +63,7 @@ function getOptions(context: vscode.ExtensionContext): Promise { options.forEach((item) => { context.globalState.update( item.id, - items.find((i) => i.id === item.id) !== undefined, + items.some((i) => i.id === item.id), ) })