Skip to content
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

Merged
merged 11 commits into from
Jul 21, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add scripts to help with packaging and publishing of .vsix
@W-4162004@
Nick Chen committed Jul 21, 2017
commit dd7ab87949004b330ab124e76ced7eb1d9c6e050
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -12,7 +12,11 @@
"clean": "lerna run clean",
"compile": "lerna run --stream compile",
"lint": "lerna run lint",
"publish": "node scripts/publish.js",
"test": "lerna run test --concurrency 1",
"vscode:package": "lerna run vscode:package --concurrency 1",
"vscode:sha256": "lerna run vscode:sha256 --concurrency 1",
"vscode:publish": "lerna run vscode:publish --concurrency 1",
"watch": "lerna run --parallel watch"
},
"repository": {
3 changes: 3 additions & 0 deletions packages/salesforcedx-vscode-apex/package.json
Original file line number Diff line number Diff line change
@@ -28,6 +28,9 @@
},
"scripts": {
"vscode:prepublish": "npm prune --production",
"vscode:package": "vsce package",
"vscode:sha256": "node ../../scripts/generate-sha256.js >> ../../SHA256",
"vscode:publish": "node ../../scripts/publish-vsix.js",
"compile": "tsc -p ./",
"lint": "tslint --project .",
"watch": "tsc -watch -p .",
5 changes: 4 additions & 1 deletion packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
@@ -33,7 +33,10 @@
"vscode": "1.1.2"
},
"scripts": {
"vscode:prepublish": "tsc -p ./",
"vscode:prepublish": "npm prune --production",
"vscode:package": "vsce package",
"vscode:sha256": "node ../../scripts/generate-sha256.js >> ../../SHA256",
"vscode:publish": "node ../../scripts/publish-vsix.js",
"compile": "tsc -p ./",
"lint": "tslint --project .",
"watch": "tsc -watch -p .",
5 changes: 4 additions & 1 deletion packages/salesforcedx-vscode-lightning/package.json
Original file line number Diff line number Diff line change
@@ -27,7 +27,10 @@
"vscode": "1.1.2"
},
"scripts": {
"vscode:prepublish": "tsc -p ./",
"vscode:prepublish": "npm prune --production",
"vscode:package": "vsce package",
"vscode:sha256": "node ../../scripts/generate-sha256.js >> ../../SHA256",
"vscode:publish": "node ../../scripts/publish-vsix.js",
"compile": "tsc -p ./",
"lint": "tslint --project .",
"watch": "tsc -watch -p .",
5 changes: 4 additions & 1 deletion packages/salesforcedx-vscode-visualforce/package.json
Original file line number Diff line number Diff line change
@@ -27,7 +27,10 @@
"vscode": "1.1.2"
},
"scripts": {
"vscode:prepublish": "tsc -p ./",
"vscode:prepublish": "npm prune --production",
"vscode:package": "vsce package",
"vscode:sha256": "node ../../scripts/generate-sha256.js >> ../../SHA256",
"vscode:publish": "node ../../scripts/publish-vsix.js",
"compile": "tsc -p ./",
"lint": "tslint --project .",
"watch": "tsc -watch -p .",
8 changes: 7 additions & 1 deletion packages/salesforcedx-vscode/package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"preview": true,
"name": "salesforcedx-vscode",
"displayName": "Visual Studio Code Extension Pack for Salesforce DX",
"description": "Collection of extension for Salesforce DX",
"description": "Collection of extensions for Salesforce DX",
"icon": "images/icon.png",
"galleryBanner": {
"color": "#ECECEC",
@@ -14,6 +14,12 @@
"engines": {
"vscode": "^1.13.0"
},
"scripts": {
"vscode:prepublish": "npm prune --production",
"vscode:package": "vsce package",
"vscode:sha256": "node ../../scripts/generate-sha256.js >> ../../SHA256",
"vscode:publish": "node ../../scripts/publish-vsix.js"
},
"categories": ["Extension Packs"],
"extensionDependencies": [
"salesforce.salesforcedx-vscode-apex",
2 changes: 2 additions & 0 deletions scripts/clean-all-but-jar.js
Original file line number Diff line number Diff line change
@@ -2,4 +2,6 @@

const shell = require('shelljs');

// Removes all files but .jar files at the top-level

shell.rm('-rf', shell.ls().filter(file => !file.match(/\.jar$/)));
19 changes: 19 additions & 0 deletions scripts/generate-sha256.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node

const shell = require('shelljs');

// Generate the SHA256 for the .vsix that matches the version in package.json

const packageVersion = JSON.parse(shell.cat('package.json')).version;
const vsix = shell.ls().filter(file => file.match(`-${packageVersion}.vsix`));

if (!vsix.length) {
shell.error('No VSIX found matching the requested version in package.json');
shell.exit(1);
}

if (/win32/.test(process.platform)) {
shell.exec(`CertUtil -hashfile ${vsix} SHA256`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually foresee us using Windows to publish, but this is just in case.

} else {
shell.exec(`shasum -a 256 ${vsix}`);
}
24 changes: 24 additions & 0 deletions scripts/publish-vsix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node

const shell = require('shelljs');

// Publishes the .vsix that matches the version in package.json

const packageVersion = JSON.parse(shell.cat('package.json')).version;
const vsix = shell.ls().filter(file => file.match(`-${packageVersion}.vsix`));

if (!vsix.length) {
shell.error('No VSIX found matching the requested version in package.json');
shell.exit(1);
}

const vsce = '../../node_modules/.bin/vsce';
const VSCE_PERSONAL_ACCESS_TOKEN = process.env['VSCE_PERSONAL_ACCESS_TOKEN'];
if (VSCE_PERSONAL_ACCESS_TOKEN) {
shell.exec(
`${vsce} publish --pat ${VSCE_PERSONAL_ACCESS_TOKEN} --packagePath ${vsix}`
);
} else {
// Assume that one has already been configured
shell.exec(`${vsce} publish --packagePath ${vsix}`);
}
54 changes: 54 additions & 0 deletions scripts/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env node

const shell = require('shelljs');
shell.set('-e');
shell.set('+v');

/*
* Assumptions:
* 0. The script is running locally - it's not optimized for Travis workflow
* yet.
* 1. The script is running in the right branch.
* 2. The script is running in a clean environment - all changes have been
* committed.
*/

// Bootstrap
shell.exec('npm run bootstrap');

// Compile
shell.exec('npm run compile');

// Test
shell.exec('npm run test');

// lerna publish
// --skip-npm to increment the version number in all packages but not publish to npmjs
// This will still make a commit in Git with the tag of the version used
const nextVersion = process.env['VERSION_INCREMENT'];
if (nextVersion) {
shell.exec(`lerna publish --exact --repo-version ${nextVersion} --skip-npm`);
} else {
shell.exec('lerna publish --exact --cd-version minor --yes --skip-npm');
}

// Generate the .vsix files
shell.exec(`npm run vscode:package`);

// Generate the SHA256 and append to the file
shell.exec(`npm run vscode:sha256`);

// Publish to VS Code Marketplace
shell.exec(`npm run vscode:publish`);

// Push the SHA256 to AWS
shell.exec('aws s3 cp SHA256 s3://dfc-data-production/media/vscode/SHA256');

// Add SHA256 to git
shell.exec(`git add SHA256`);

// Perform these steps manually for now
// Git commit
// shell.exec(`git commit -m "Updated SHA256"`);
// Push back to GitHub
//shell.exec(`git push`);