-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meta: Drafted programmatic updating to the vscode extension manifest
- Loading branch information
1 parent
02e1eef
commit 8d55209
Showing
7 changed files
with
182 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import type { ManifestCommand } from './manifest.types.mjs'; | ||
import { when } from './manifest.when.mjs'; | ||
|
||
export const commands = { | ||
'stitch.assets.reveal': { | ||
command: 'stitch.assets.reveal', | ||
title: 'Stitch: Show Asset', | ||
enablement: `${when.hasProjects} && resourceExtname =~ /\\.(yy|gml)$/`, | ||
}, | ||
'stitch.assets.filters.enable': { | ||
command: 'stitch.assets.filters.enable', | ||
icon: '$(filter)', | ||
title: 'Enable Filter', | ||
enablement: `${when.assetTreeFocused} && ${when.hasProjects}`, | ||
}, | ||
'stitch.assets.filters.disable': { | ||
command: 'stitch.assets.filters.disable', | ||
icon: '$(filter-filled)', | ||
title: 'Disable Filter', | ||
enablement: `${when.assetTreeFocused} && ${when.hasProjects}`, | ||
}, | ||
'stitch.assets.filters.edit': { | ||
command: 'stitch.assets.filters.edit', | ||
title: 'Edit Filter', | ||
}, | ||
'stitch.assets.filters.new': { | ||
command: 'stitch.assets.filters.new', | ||
icon: '$(add)', | ||
title: 'New Filter...', | ||
enablement: `${when.assetTreeFocused} && ${when.hasProjects}`, | ||
}, | ||
'stitch.assets.filters.delete': { | ||
command: 'stitch.assets.filters.delete', | ||
icon: '$(close)', | ||
title: 'Delete Filter', | ||
enablement: `${when.assetTreeFocused} && ${when.hasProjects}`, | ||
}, | ||
'stitch.assets.newFolder': { | ||
command: 'stitch.assets.newFolder', | ||
title: 'New Group...', | ||
icon: '$(new-folder)', | ||
enablement: `${when.assetTreeFocused} && ${when.hasProjects}`, | ||
}, | ||
'stitch.assets.newScript': { | ||
command: 'stitch.assets.newScript', | ||
title: 'New Script...', | ||
enablement: `${when.assetTreeFocused} && ${when.hasProjects}`, | ||
}, | ||
'stitch.assets.newObject': { | ||
command: 'stitch.assets.newObject', | ||
title: 'New Object...', | ||
enablement: `${when.assetTreeFocused} && ${when.hasProjects}`, | ||
}, | ||
'stitch.openIde': { | ||
command: 'stitch.openIde', | ||
title: 'Stitch: Open in GameMaker', | ||
shortTitle: 'Open in GameMaker', | ||
enablement: `(resourceExtname =~ /\\.(yy|yyp|gml)$/) || (${when.assetTreeFocused} && ${when.hasProjects})`, | ||
icon: '$(edit)', | ||
}, | ||
'stitch.run': { | ||
command: 'stitch.run', | ||
title: 'Stitch: Run Project', | ||
shortTitle: 'Run', | ||
icon: '$(play)', | ||
}, | ||
'stitch.clean': { | ||
command: 'stitch.clean', | ||
title: 'Stitch: Clean Project Cache', | ||
shortTitle: 'Clean Cache', | ||
icon: '$(history)', | ||
}, | ||
'stitch.refresh': { | ||
command: 'stitch.refresh', | ||
title: 'Stitch: Refresh Project', | ||
shortTitle: 'Refresh Project', | ||
icon: '$(refresh)', | ||
}, | ||
} satisfies Record<string, ManifestCommand>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// For programmatically updating the manifest.json file, | ||
// making it easier to manage as the feature-set grows. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { ViewContainerId } from './manifest.views.mjs'; | ||
|
||
export interface ManifestCommand { | ||
command: string; | ||
title: string; | ||
shortTitle?: string; | ||
icon?: `$(${string})`; | ||
enablement?: string; | ||
} | ||
|
||
export interface ManifestView { | ||
id: string; | ||
name: string; | ||
icon: './images/stitch-logo-mono.svg'; | ||
type: 'tree'; | ||
} | ||
|
||
export interface ManifestViewContainer { | ||
id: string; | ||
title: string; | ||
icon: './images/stitch-logo-mono.svg'; | ||
} | ||
|
||
export interface Manifest { | ||
contributes: { | ||
commands: ManifestCommand[]; | ||
views: Record<ViewContainerId, ManifestView[]>; | ||
viewsContainers: { | ||
activitybar: ManifestViewContainer[]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { pathy } from '@bscotch/pathy'; | ||
import { keysOf } from '@bscotch/utility'; | ||
import { commands } from './manifest.commands.mjs'; | ||
import type { Manifest } from './manifest.types.mjs'; | ||
import { viewsArray, viewsContainersArray } from './manifest.views.mjs'; | ||
|
||
async function main() { | ||
const manifestPath = pathy('package.json'); | ||
await manifestPath.exists({ assert: true }); | ||
|
||
const manifest = await manifestPath.read<Manifest>(); | ||
|
||
// Update commands | ||
manifest.contributes.commands = []; | ||
for (const command of keysOf(commands)) { | ||
manifest.contributes.commands.push(commands[command]); | ||
} | ||
|
||
// Update views | ||
manifest.contributes.views['bscotch-stitch'] = viewsArray; | ||
manifest.contributes.viewsContainers.activitybar = viewsContainersArray; | ||
|
||
// Write out the updated manifest | ||
await manifestPath.write(manifest); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { keysOf } from '@bscotch/utility'; | ||
import { ManifestView, ManifestViewContainer } from './manifest.types.mjs'; | ||
|
||
export type ViewId = keyof typeof views; | ||
export const views = { | ||
'bscotch-stitch-resources': { | ||
id: 'bscotch-stitch-resources', | ||
name: 'Resources', | ||
icon: './images/stitch-logo-mono.svg', | ||
type: 'tree', | ||
}, | ||
} satisfies Record<string, ManifestView>; | ||
export const viewsArray = keysOf(views).map((key) => views[key]); | ||
|
||
export type ViewContainerId = keyof typeof viewsContainers; | ||
export const viewsContainers = { | ||
'bscotch-stitch': { | ||
id: 'bscotch-stitch', | ||
title: 'Stitch', | ||
icon: './images/stitch-logo-mono.svg', | ||
}, | ||
} satisfies Record<string, ManifestViewContainer>; | ||
export const viewsContainersArray = keysOf(viewsContainers).map( | ||
(key) => viewsContainers[key], | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const when = { | ||
assetTreeFocused: 'view == bscotch-stitch-resources', | ||
hasProjects: 'stitch.projectCount > 0', | ||
hasOneProject: 'stitch.projectCount == 1', | ||
anyGameMakerFileFocused: 'resourceExtname =~ /\\.(yy|gml|yyp)$', | ||
yypFocused: 'resourceExtname == ".yyp"', | ||
yyFocused: 'resourceExtname == ".yyp"', | ||
gmlFocused: 'resourceExtname == ".gml"', | ||
viewItemIsFilter: 'viewItem =~ /^tree-filter-(enabled|disabled)/', | ||
viewItemIsFilterGroup: 'viewItem == "tree-filter-group"', | ||
viewItemIsFilterEnabled: 'viewItem == "tree-filter-enabled"', | ||
viewItemIsFilterDisabled: 'viewItem == "tree-filter-disabled"', | ||
viewItemIsProject: 'viewItem == "project"', | ||
viewItemIsFolder: 'viewItem == "folder"', | ||
}; |