Skip to content

Commit

Permalink
Initial open source commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jodyheavener committed Jun 6, 2022
0 parents commit ebdba0a
Show file tree
Hide file tree
Showing 50 changed files with 8,937 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"extends": ["./node_modules/@1password/front-end-style/eslintrc.yml"],
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": ["./tsconfig.json"]
},
"rules": {
"unicorn/prefer-node-protocol": "off",
"no-shadow": "off",
"unicorn/filename-case": "off",
"jsdoc/require-jsdoc": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "default",
"format": ["PascalCase", "camelCase", "UPPER_CASE"]
}
],
"import/no-unresolved": [
"error",
{
"ignore": ["vscode"]
}
],
"unicorn/no-null": "off",
"no-case-declarations": "off",
"sonarjs/no-small-switch": "off",
"sonarjs/no-nested-template-literals": "off"
}
}
],
"parser": "@typescript-eslint/parser"
}
42 changes: 42 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Bug report
about: Report bugs and errors found while using op-vscode.
title: ""
labels: bug
assignees: ""
---

### Your environment

<!-- Version of op-vscode when the error occurred -->

op-vscode version:

<!-- Version of VS Code when the error occurred -->

VS Code version:

<!-- What version of the 1Password CLI are you using? -->

CLI version:

<!-- What OS are you running op-vscode on? -->

OS:

## Steps to reproduce

1. <!-- Describe Steps to reproduce the issue -->

## What happened?

<!-- Describe the bug or error -->

## What did you expect to happen?

<!-- Describe what should have happened -->

## Notes & Logs

<!-- Paste any logs here that may help with debugging.
Remember to remove any sensitive information before sharing! -->
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Feature request
about: Suggest an idea for op-vscode
title: ""
labels: feature-request
assignees: ""
---

### Summary

<!-- Briefly describe the feature in one or two sentences. You can include more details later. -->

### Use cases

<!-- Describe the use cases that make this feature useful to others.
The description should help the reader understand why the feature is necessary.
The better we understand your use case, the better we can help create an appropriate solution. -->

### Proposed solution

<!-- If you already have an idea for how the feature should work, use this space to describe it.
We'll work with you to find a workable approach, and any implementation details are appreciated.
-->

### Is there a workaround to accomplish this today?

<!-- If there's a way to accomplish this feature request without changes to the codebase, we'd like to hear it.
-->

### References & Prior Work

<!-- If a similar feature was implemented in another project or tool, add a link so we can better understand your request.
Links to relevant documentation or RFCs are also appreciated. -->

- <!-- Reference 1 -->
- <!-- Reference 2, etc -->
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Test
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16
- run: yarn
- run: yarn typecheck
- run: yarn eslint
- run: yarn prettier
- run: yarn test
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
dist/
coverage/
*.vsix
*.zip
.husky/_/husky.sh
licenses/
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.12.0
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.svg
*.code-snippets
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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=${workspaceRoot}"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.insertSpaces": false,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
19 changes: 19 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.eslintrc
.gitignore
.github/
.husky/
.nvmrc
.prettierignore
.prettierrc
.vscode/
.vscodeignore
compile.ts
coverage/
jest.config.js
node_modules/
package-lock.json
src/
!src/op-vscode.code-snippets
test/
tsconfig.json
types/
97 changes: 97 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Contributing

## Development

This is an extension for Visual Studio Code, please refer to the [Extension API](https://code.visualstudio.com/api) documentation.

Requires [Node](https://nodejs.org/en/), [VS Code](https://code.visualstudio.com/), and [vsce](https://github.com/microsoft/vscode-vsce) installed globally.

### Dependencies

To install dependencies:

```shell
yarn # or yarn install
```

### Running locally

While you're working on the extension you should watch for changes:

```shell
yarn watch
```

This will recompile the extension into the `/dist` folder whenever a file changes.

To preview the extension while you're working on it, hit `F5` to trigger the "Run Extension" debugger (or go to the "Run and Debug" panel and hit the play button next to the "Run Extension (op-vscode)" item). This will open a local [Extension Host](https://code.visualstudio.com/api/advanced-topics/extension-host) with the extension running directly from the working directory. With the extension running in a new window, your development window will have a debugger toolbar to stop and reload the extension as needed.

### Linting and formatting

Code should be linted and formatted where appropriate. We have commands for all types of code in this project:

```shell
# Run Prettier on all TS files
yarn prettier

# Run ESLint on all TS files
yarn eslint

# Typecheck all TS files
yarn typecheck
```

The above commands will only return linting reports. You can optionally attach the appropriate `--fix` / `--write` flag when running the commands, which will modify the files to fix issues that can be done so automatically. Some issues will need to be manually addressed.

#### Pre-commit checks

This project is set up to use [Husky](https://typicode.github.io/husky/), which allows us to hook into Git operations, and [lint-staged](https://www.npmjs.com/package/lint-staged), a way to run commands against globs of files staged in Git.

When you run `git commit` Husky invokes its pre-commit hook, which runs lint-staged, resulting in all the above linter commands getting called with flags set to automatically fix issues. If the linters have issues that can't be automatically addressed the commit will be aborted, giving you a chance to manually fix things. The purpose of this is to enforce code consistency across the project.

There may come a time when you need to skip these checks; to prevent the pre-commit hook from running add `--no-verify` to your commit command.

### Testing

Code should be reasonably tested. We do not currently have any required coverage threshold, but if you are adding new or changing existing functionality you should consider writing/updating tests.

This project uses [Jest](https://jestjs.io/). Commands are pretty straightforward:

```shell
# Run the entire test suite
yarn test

# Run the test suite, re-running on changes
yarn test --watch

# Run only tests that have a specific description
yarn test -t="returns the custom fields"
```

## Distribution

### Building & Packaging

When you want to build and package up the extension for creating a release, run the following:

```shell
vsce package
```

This will run `yarn build` to create a minified version of the extension, and then package it up into a file called `op-vscode-[version].vsix`. This is just a ZIP file with a fancy extension, but with it anyone can install the extension manually by going to the Extension panel, opening the context menu, and clicking "Install from VSIX...".

### Publishing

To publish a new version of the extension, first make sure you are logged into the publisher account used for publishing new releases via `vsce login 1Password`.

Bump up the version in `package.json`, then run:

```shell
vsce publish
```

This will create a new version of the extension on the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=1Password.op-vscode).

## Acknowledgments

Special thanks to Liam Barry, Elazar Cohen, Eric Amodio, Taras Novak, and others from the [VS Code Dev Slack](https://aka.ms/vscode-dev-community) who helped provided guidance and suggestions during development.
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2022 1Password

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 1Password for VS Code

1Password for VS Code provides you with a set of tools to integrate your development workflow with 1Password, powered by the [1Password CLI](https://developer.1password.com/docs/cli).

## Quick start

⚡️ This quick start guide will get you up and running with the extension.

1. **Set up the CLI** - v2.4.0 or greater of the 1Password CLI needs to be [installed on your system](https://developer.1password.com/docs/cli/get-started#install).
2. **Enable biometric unlock** - You must have [biometric unlock](https://developer.1password.com/docs/cli/about-biometric-unlock) enabled. If you don't have a biometric device, you'll still be able to use your device user password.
3. **Install the extension** - From the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=1Password.op-vscode) or [GitHub](https://github.com/1Password/op-vscode/releases) install the latest version of the extension.
4. **Follow the prompts** - You'll be prompted to choose a 1Password account and vault. Follow these prompts to finish setup of the extension.

You're all set.

## Contributing and feedback

1Password for VS Code is an open source project.

🐛 If you find an issue you'd like to report, or otherwise have feedback, please [file a new Issue](https://github.com/1Password/op-vscode/issues/new).

🧑‍💻 If you'd like to contribute to the extension please start by filing or commenting on an [Issue](https://github.com/1Password/op-vscode/issues) so we can track the work. Refer to the [Contributing doc](https://github.com/1Password/op-vscode/blob/main/CONTRIBUTING.md) for development setup instructions.

💬 Share your feedback and connect with the Developer Products team in the [1Password Developers Slack](https://join.slack.com/t/1password-devs/shared_invite/zt-15k6lhima-GRb5Ga~fo7mjS9xPzDaF2A) workspace.

## License

MIT
36 changes: 36 additions & 0 deletions compile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { build, BuildOptions } from "esbuild";
import { existsSync, rmSync } from "fs";

const srcPath = "src";
const distPath = "dist";

const args = process.argv.slice(2);
const isProd = process.env.NODE_ENV === "production";
const watch = args.includes("--watch");

const createWatcher = (name: string): BuildOptions["watch"] => {
if (!watch) return false;
return {
onRebuild(error: Error): void {
if (error) {
console.error(`[${name}] failed to build:`, error);
} else {
console.log(`[${name}] watch build succeeded`);
}
},
};
};

if (existsSync(distPath)) {
rmSync(distPath, { recursive: true });
}

build({
entryPoints: [`${srcPath}/extension.ts`],
bundle: true,
platform: "node",
external: ["vscode"],
outfile: `${distPath}/extension.js`,
minify: isProd,
watch: createWatcher("extension"),
}).catch(() => process.exit(1));
Loading

0 comments on commit ebdba0a

Please sign in to comment.