-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from zowe/local-storage-sample
Add local storage sample
- Loading branch information
Showing
9 changed files
with
150 additions
and
0 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
15 changes: 15 additions & 0 deletions
15
vscode-extension-samples/local-storage-sample/.eslintrc.js
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 @@ | ||
/**@type {import('eslint').Linter.Config} */ | ||
// eslint-disable-next-line no-undef | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint"], | ||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
rules: { | ||
semi: [2, "always"], | ||
"@typescript-eslint/no-unused-vars": 0, | ||
"@typescript-eslint/no-explicit-any": 0, | ||
"@typescript-eslint/explicit-module-boundary-types": 0, | ||
"@typescript-eslint/no-non-null-assertion": 0, | ||
}, | ||
}; |
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,4 @@ | ||
out | ||
node_modules | ||
.vscode-test/ | ||
*.vsix |
18 changes: 18 additions & 0 deletions
18
vscode-extension-samples/local-storage-sample/.vscode/launch.json
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,18 @@ | ||
// A launch configuration that compiles the extension and then opens it inside a new window | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run Extension", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": ["--extensionDevelopmentPath=${workspaceFolder}"], | ||
"outFiles": ["${workspaceFolder}/out/**/*.js"], | ||
"preLaunchTask": "npm: watch" | ||
} | ||
] | ||
} |
20 changes: 20 additions & 0 deletions
20
vscode-extension-samples/local-storage-sample/.vscode/tasks.json
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,20 @@ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "watch", | ||
"problemMatcher": "$tsc-watch", | ||
"isBackground": true, | ||
"presentation": { | ||
"reveal": "never" | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
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,14 @@ | ||
# Local Storage Sample | ||
|
||
Demonstrates accessing local storage using the `LocalStorageAccess` facility, exposed through Zowe Explorer's extender API. | ||
|
||
- Displays your data set history as a notification (if you have data set history defined in Zowe Explorer's local storage) | ||
- Displays list of readable and writable keys as a notification | ||
- Displays the error received when trying to access a value for a key w/ no access permissions | ||
|
||
## Running the sample | ||
|
||
- Open this sample in VS Code | ||
- `npm install` | ||
- `npm run compile` | ||
- `F5` to start debugging |
37 changes: 37 additions & 0 deletions
37
vscode-extension-samples/local-storage-sample/package.json
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,37 @@ | ||
{ | ||
"name": "local-storage-sample", | ||
"displayName": "local-storage-sample", | ||
"description": "Local storage sample for Zowe Explorer", | ||
"version": "0.0.1", | ||
"publisher": "Zowe", | ||
"repository": "https://github.com/zowe/zowe-client-samples/tree/main/vscode-extension-samples", | ||
"engines": { | ||
"vscode": "^1.79.0" | ||
}, | ||
"categories": [ | ||
"Other" | ||
], | ||
"activationEvents": [ | ||
"onStartupFinished" | ||
], | ||
"main": "./out/extension.js", | ||
"extensionDependencies": [ | ||
"Zowe.vscode-extension-for-zowe" | ||
], | ||
"scripts": { | ||
"vscode:prepublish": "npm run compile", | ||
"compile": "tsc -p ./", | ||
"lint": "eslint \"src/**/*.ts\"", | ||
"watch": "tsc -watch -p ./" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/node": "^18.19.14", | ||
"@types/vscode": "^1.53.2", | ||
"@typescript-eslint/eslint-plugin": "^5.42.0", | ||
"@typescript-eslint/parser": "^5.42.0", | ||
"@zowe/zowe-explorer-api": "^3.0.0", | ||
"eslint": "^8.26.0", | ||
"typescript": "^5.1.3" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
vscode-extension-samples/local-storage-sample/src/extension.ts
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,28 @@ | ||
// The module 'vscode' contains the VS Code extensibility API | ||
// Import the module and reference it with the alias vscode in your code below | ||
import * as vscode from "vscode"; | ||
|
||
// This method is called when your extension is activated | ||
// Your extension is activated the very first time the command is executed | ||
export function activate(context: vscode.ExtensionContext) { | ||
// Use the console to output diagnostic information (console.log) and errors (console.error) | ||
// This line of code will only be executed once when your extension is activated | ||
console.log('Congratulations, your extension "local-storage-sample" is now active!'); | ||
|
||
const zeApi = vscode.extensions.getExtension("Zowe.vscode-extension-for-zowe")?.exports; | ||
const localStorage = zeApi.getExplorerExtenderApi().getLocalStorage(); | ||
|
||
// access readable and writable keys within local storage: | ||
vscode.window.showInformationMessage(localStorage.getWritableKeys().join(",")); | ||
vscode.window.showInformationMessage(localStorage.getReadableKeys().join(",")); | ||
|
||
vscode.window.showInformationMessage(JSON.stringify(localStorage.getValue("zowe.ds.history"))); | ||
try { | ||
// trying to access a key with insufficient perms will throw an error | ||
localStorage.getValue("zowe.v1MigrationStatus"); | ||
} catch (err) { | ||
if (err instanceof Error) { | ||
vscode.window.showErrorMessage(err.message); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
vscode-extension-samples/local-storage-sample/tsconfig.json
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,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es2020", | ||
"lib": ["es2020"], | ||
"outDir": "out", | ||
"skipLibCheck": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"rootDir": "src" | ||
}, | ||
"exclude": ["node_modules", ".vscode-test"] | ||
} |