-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scripts for publishing to VS Code Marketplace #12
Changes from 10 commits
96a22a9
489036e
87ef518
dd7ab87
6ebb82d
fa5ad35
759f0dc
c62a557
a3da78a
4f5fe51
d38a549
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,26 @@ | |
it will ask you to install them. **Please do so since this includes the | ||
linters and formatters**. | ||
|
||
## Pre-requisites for Windows Development | ||
|
||
These are instructions for _developing_ the extensions on Windows since there | ||
are some quirkiness with the way Windows behaves. This does not affect the | ||
actual extensions that we distribute. | ||
|
||
1. Same as above. | ||
1. You should use Bash Shell instead of Powershell or the Command Prompt. | ||
1. If you want to use the integrated terminal in VS Code, you can see that | ||
following the instructions | ||
[here](https://code.visualstudio.com/docs/editor/integrated-terminal#_windows); | ||
1. You should install VS Code Insiders from | ||
[here](https://code.visualstudio.com/insiders). Without this, you won't be | ||
able to run the end-to-end tests while VS Code is open. You will see an error | ||
of the form "Running extension tests from the command line is currently only | ||
supported if no other instance of Code is running." To circumvent that you | ||
could close VS Code each time you run the tests. Or, you can install the | ||
Insiders version so that it can run the tests in Code while you work in the | ||
Insiders version. | ||
|
||
## Structure | ||
|
||
### Packages | ||
|
@@ -39,7 +59,7 @@ You would only do this once after you cloned the repository. | |
You would usually do the following each time you close/reopen VS Code: | ||
|
||
1. [Optional] Open the Command Palette > Tasks: Run Task > Bootstrap (this | ||
essentially runs `lerna bootstrap`). This is required if you change the | ||
essentially runs `npm run bootstrap`). This is required if you change the | ||
dependencies in any of the package.json. | ||
1. If you wish to build, you can invoke Command Palette > Build Task | ||
(Ctrl+Shift+B or Cmd+Shift+B on Mac). The errors will show in the Problems | ||
|
@@ -56,17 +76,19 @@ to run and debug extensions. | |
|
||
When you are ready to commit | ||
|
||
1. Run `lerna run lint` to run tslint in more thorough mode to identify any | ||
1. Run `npm run lint` to run tslint in more thorough mode to identify any | ||
errors. | ||
1. Some of the items can be fixed using `tstlint --project . fix`. Some you | ||
1. Some of the items can be fixed using `tslint --project . fix`. Some you | ||
might need to fix them manually. | ||
|
||
This linting steps should be done later as part of the continuous integration | ||
runs but that is how you would check locally first. | ||
|
||
## List of Useful commands | ||
|
||
### `lerna bootstrap` | ||
_These commands assume that they are executed from the top-level directory. Internally, they delegate to `lerna` to call them on each npm module in the packages directory._ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrapping each one under npm scripts allows the calling mechanism to be simpler (e.g, since you no longer need to remember which ones to call with --concurrency 1). |
||
|
||
### `npm run bootstrap` | ||
|
||
This bootstraps the packages by issuing an `npm install` on each package and | ||
also symlinking any package that are part of the packages folder. | ||
|
@@ -77,27 +99,27 @@ modules. | |
If you change the dependencies in your package.json, you will also need to run | ||
this command. | ||
|
||
### `lerna run compile` | ||
### `npm run compile` | ||
|
||
This runs `npm run compile` on each of the package in packages. | ||
|
||
### `lerna run clean` | ||
### `npm run clean` | ||
|
||
This run `npm run clean` on each of the package in packages. | ||
|
||
### `lerna run --parallel watch` | ||
### `npm run watch` | ||
|
||
This runs `npm run watch` on each of the package in packages. The `--parallel` | ||
flag tell it to run each in a separate process so that it won't block the main | ||
thread. | ||
|
||
### `lerna run test --concurrency 1` | ||
### `npm run test` | ||
|
||
This runs `npm test` on each of the packages. The `--concurrency 1` is essential | ||
for VS Code extension tests since they require an instance of Code to run in. | ||
And, only one instance of that can be running at a single time. | ||
|
||
### `lerna run lint` | ||
### `npm run lint` | ||
|
||
This runs `npm lint` on each of the packages. If there are no errors/warnings | ||
from tslint, then you get a clean output. But, if they are errors from tslint, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Introduction | ||
|
||
This is a guide for publishing to the Visual Studio Code Marketplace. Most | ||
contributors will not need to worry about publishing. However, it might be | ||
worthwhile familiaring yourself with the steps in case you need to share the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. familiarizing? |
||
extensions through the .vsix files. | ||
|
||
# Goal | ||
|
||
The goal of publishing is to take the extensions under /packages, bundle them as | ||
.vsix files, and push them to the [Visual Studio Code | ||
Marketplace](https://marketplace.visualstudio.com/vscode). | ||
|
||
For more information about publishing take a look at | ||
|
||
* [Publishing VS Code Extensions](https://code.visualstudio.com/docs/extensions/publish-extension) | ||
* [Managing Extensions](https://code.visualstudio.com/docs/editor/extension-gallery) | ||
|
||
# Steps | ||
|
||
The scripts/publish.js contains the end-to-end flow. It is possible to run each step manually. | ||
|
||
The files under scripts use [shelljs/shx](https://github.com/shelljs/shx) and | ||
[shelljs/shelljs](https://github.com/shelljs/shelljs) to write scripts in a | ||
portable manner across platforms. | ||
|
||
## Packaging as .vsix | ||
|
||
### Prerequisite | ||
|
||
* Lerna is properly installed. | ||
|
||
### Steps | ||
|
||
1. `npm run bootstrap` to install all the dependencies and to symlink interdependent local modules. | ||
1. `npm run compile` to compile all the TypeScript files. | ||
1. `npm run test` to run all the tests. | ||
1. `lerna publish ...` will increment the version in the individual package.json | ||
to prepare for publication. **This also commits the changes to git and adds a | ||
tag.** | ||
1. `npm run vscode:package` packages _each_ extension as a .vsix. | ||
|
||
**At this stage, it is possible to share the .vsix directly for manual installation.** | ||
|
||
## Generating SHA256 | ||
|
||
Due to [vscode-vsce#191](https://github.com/Microsoft/vscode-vsce/issues/191) | ||
the .vsix are neither signed nor verified. To ensure that they have not been | ||
tampered with, we generate a SHA256 of the contents and publish that to | ||
https://developer.salesforce.com/media/vscode/SHA256 | ||
|
||
### Prequisite | ||
|
||
* You have access to our S3 bucket at s3://dfc-data-production/media/vscode | ||
* You have the [AWS CLI](https://aws.amazon.com/cli/) installed and configured | ||
via `aws configure` or have the `AWS_ACCESS_KEY_ID` and | ||
`AWS_SECRET_ACCESS_KEY` exported as environment variables. | ||
|
||
### Steps | ||
|
||
1. `npm run vscode:sha256` will compute the SHA256 for the .vsix generated in | ||
the previous stage. | ||
1. The SHA256 are appended to the top-level SHA256 file. | ||
1. This file is then copied over to our S3 bucket. | ||
1. Finally the file is added to git so that it can be committed. | ||
|
||
## Pushing .vsix to Visual Studio Marketplace | ||
|
||
### Prequisite | ||
|
||
* You have a personal access token that for the salesforce publisher id that is | ||
exported as `VSCE_PERSONAL_ACCESS_TOKEN`. | ||
* Or, you have vsce installed and configured with the salesforce publisher id. | ||
|
||
### Steps | ||
|
||
1. `npm run vscode:publish` takes the .vsix that you had _before_ and uploads | ||
it to the Visual Studio Code Marketplace. | ||
|
||
It's **crucial** that you publish the .vsix that you had before so that the | ||
SHA256 match. If you were to repackage, the SHA256 woudl be different. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. woudl -> would |
||
|
||
# Tips | ||
|
||
1. After publishing, you will need to run `npm run bootstrap` again to continue | ||
development. This is because the `npm run vscode:package` step does a `npm | ||
prune --production`. This is required due to the way Lerna does symlinking. | ||
See [vscode-vsce#52](https://github.com/Microsoft/vscode-vsce/issues/52) for | ||
more information. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"lerna": "2.0.0-rc.5", | ||
"lerna": "2.0.0", | ||
"packages": [ | ||
"packages/*" | ||
], | ||
"version": "0.1.0" | ||
"version": "0.2.0" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,12 @@ | |
"name": "@salesforce/salesforcedx-utils-vscode", | ||
"displayName": "SFDX Utilities for VS Code", | ||
"description": "Provides utilies to interface the SFDX libraries with VS Code", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"publisher": "salesforce", | ||
"license": "MIT", | ||
"categories": ["Other"], | ||
"categories": [ | ||
"Other" | ||
], | ||
"dependencies": { | ||
"rxjs": "^5.4.1", | ||
"tree-kill": "^1.1.0" | ||
|
@@ -23,8 +25,8 @@ | |
"compile": "tsc -p ./", | ||
"lint": "tslint --project .", | ||
"watch": "tsc -watch -p .", | ||
"clean": "rm -rf node_modules && rm -rf out", | ||
"test": "node ./node_modules/.bin/_mocha --recursive out/test", | ||
"clean": "shx rm -rf node_modules && shx rm -rf out", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use shelljs/shx to make the script portable across platforms. |
||
"test": "./node_modules/.bin/_mocha --recursive out/test", | ||
"coverage": "./node_modules/.bin/nyc npm test" | ||
}, | ||
"main": "./out/src/" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added these tasks so that you can now do Cmd + Shift + P in VS Code, type
task<space>
and get a list of such task to invoke without going to the command line.