Skip to content

Commit

Permalink
Add JSON schema for *.model.json files, improve Init command
Browse files Browse the repository at this point in the history
  • Loading branch information
DervexDev committed May 4, 2024
1 parent 3317917 commit c07ce69
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
File renamed without changes.
48 changes: 48 additions & 0 deletions assets/schemas/model.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
}
File renamed without changes.
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/menu/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function getOptions(context: vscode.ExtensionContext): Promise<string[]> {
options.forEach((item) => {
context.globalState.update(
item.id,
items.find((i) => i.id === item.id) !== undefined,
items.some((i) => i.id === item.id),
)
})

Expand Down
14 changes: 12 additions & 2 deletions src/menu/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const item: Item = {
action: 'init',
}

const ALL_OPTIONS = ['--docs', '--git', '--wally', '--ts']

function getProjectName(): Promise<string> {
return new Promise((resolve, reject) => {
vscode.window
Expand Down Expand Up @@ -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),
)
})

Expand All @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions src/menu/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
])
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/menu/sourcemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function getOptions(context: vscode.ExtensionContext): Promise<string[]> {
options.forEach((item) => {
context.globalState.update(
item.id,
items.find((i) => i.id === item.id) !== undefined,
items.some((i) => i.id === item.id),
)
})

Expand Down

0 comments on commit c07ce69

Please sign in to comment.