Skip to content

Commit

Permalink
Add settings and project settings contribution files (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcouch-sil authored Feb 9, 2024
2 parents 44d449c + f4ff35a commit 20e72a5
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 4 deletions.
4 changes: 2 additions & 2 deletions extensions/lib/add-remotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
try {
await execGitCommand(`git remote add ${MULTI_TEMPLATE_NAME} ${MULTI_TEMPLATE_URL}`);
} catch (e) {
if (e.toString().includes(ERROR_STRINGS.multiRemoteExists))
if (e.toString().toLowerCase().includes(ERROR_STRINGS.multiRemoteExists.toLowerCase()))
console.log(`Remote ${MULTI_TEMPLATE_NAME} already exists. This is likely not a problem.`);
else {
console.error(`Error on adding remote ${MULTI_TEMPLATE_NAME}: ${e}`);
Expand All @@ -25,7 +25,7 @@ import {
try {
await execGitCommand(`git remote add ${SINGLE_TEMPLATE_NAME} ${SINGLE_TEMPLATE_URL}`);
} catch (e) {
if (e.toString().includes(ERROR_STRINGS.singleRemoteExists))
if (e.toString().toLowerCase().includes(ERROR_STRINGS.singleRemoteExists.toLowerCase()))
console.log(`Remote ${SINGLE_TEMPLATE_NAME} already exists. This is likely not a problem.`);
else {
console.error(`Error on adding remote ${SINGLE_TEMPLATE_NAME}: ${e}`);
Expand Down
4 changes: 3 additions & 1 deletion extensions/lib/update-from-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ import { ExtensionInfo, getExtensions, subtreeRootFolder } from '../webpack/webp
e
.toString()
.toLowerCase()
.includes(ERROR_STRINGS.subtreeNeverAdded.replace('{0}', ext.dirPathOSIndependent))
.includes(
ERROR_STRINGS.subtreeNeverAdded.replace('{0}', ext.dirPathOSIndependent).toLowerCase(),
)
)
// If this folder isn't a subtree, it may be intentionally not based on the template. Continue
console.warn(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions extensions/src/hello-someone/contributions/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
3 changes: 3 additions & 0 deletions extensions/src/hello-someone/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"license": "MIT",
"main": "src/main.ts",
"types": "src/types/hello-someone.d.ts",
"menus": "contributions/menus.json",
"settings": "contributions/settings.json",
"projectSettings": "contributions/projectSettings.json",
"activationEvents": [
"onCommand:helloSomeone.helloSomeone",
"onCommand:helloSomeone.echoSomeoneRenderer"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions extensions/src/hello-world/contributions/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
3 changes: 3 additions & 0 deletions extensions/src/hello-world/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"license": "MIT",
"main": "src/main.ts",
"types": "src/types/hello-world.d.ts",
"menus": "contributions/menus.json",
"settings": "contributions/settings.json",
"projectSettings": "contributions/projectSettings.json",
"activationEvents": ["onCommand:helloWorld.helloWorld", "onCommand:helloWorld.helloException"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions extensions/src/quick-verse/contributions/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
3 changes: 3 additions & 0 deletions extensions/src/quick-verse/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"license": "MIT",
"main": "src/main.ts",
"types": "src/types/quick-verse.d.ts",
"menus": "contributions/menus.json",
"settings": "contributions/settings.json",
"projectSettings": "contributions/projectSettings.json",
"activationEvents": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions extensions/src/resource-viewer/contributions/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
3 changes: 3 additions & 0 deletions extensions/src/resource-viewer/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"license": "MIT",
"main": "src/main.ts",
"types": "src/types/resource-viewer.d.ts",
"menus": "contributions/menus.json",
"settings": "contributions/settings.json",
"projectSettings": "contributions/projectSettings.json",
"activationEvents": []
}
12 changes: 11 additions & 1 deletion extensions/webpack/webpack.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ const staticFiles: {
{ from: '<types>', noErrorOnMissing: true },
// Copy the menu JSON file into the output folder based on its listing in `manifest.menus`
{ from: '<menus>', noErrorOnMissing: true },
// Copy the settings JSON file into the output folder based on its listing in `manifest.settings`
{ from: '<settings>', noErrorOnMissing: true },
// Copy the project settings JSON file into the output folder based on its listing in `manifest.projectSettings`
{ from: '<project_settings>', noErrorOnMissing: true },
];

/** Get the actual static file name from the template static file name */
function getStaticFileName(staticFile: string, extensionInfo: ExtensionInfo) {
return staticFile
.replace(/<name>/g, extensionInfo.name)
.replace(/<types>/g, extensionInfo.types ?? '')
.replace(/<menus>/g, extensionInfo.menus ?? '');
.replace(/<menus>/g, extensionInfo.menus ?? '')
.replace(/<settings>/g, extensionInfo.menus ?? '')
.replace(/<project_settings>/g, extensionInfo.menus ?? '');
}

/** Get CopyFile plugin patterns for copying static files for an extension */
Expand Down Expand Up @@ -286,6 +292,10 @@ type ExtensionManifest = {
types?: string;
/** Path to the JSON file that defines the menu items this extension is adding. */
menus?: string;
/** Path to the JSON file that defines the settings this extension is adding. */
settings?: string;
/** Path to the JSON file that defines the project settings this extension is adding. */
projectSettings?: string;
activationEvents: string[];
};

Expand Down
6 changes: 6 additions & 0 deletions lib/papi-dts/papi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4190,6 +4190,12 @@ declare module 'extension-host/extension-types/extension-manifest.model' {
* for more information about extension type declaration files.
*/
types?: string;
/** Path to the JSON file that defines the menu items this extension is adding. */
menus?: string;
/** Path to the JSON file that defines the settings this extension is adding. */
settings?: string;
/** Path to the JSON file that defines the project settings this extension is adding. */
projectSettings?: string;
/**
* List of events that occur that should cause this extension to be activated. Not yet
* implemented.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export type ExtensionManifest = {
types?: string;
/** Path to the JSON file that defines the menu items this extension is adding. */
menus?: string;
/** Path to the JSON file that defines the settings this extension is adding. */
settings?: string;
/** Path to the JSON file that defines the project settings this extension is adding. */
projectSettings?: string;
/**
* List of events that occur that should cause this extension to be activated. Not yet
* implemented.
Expand Down

0 comments on commit 20e72a5

Please sign in to comment.