Skip to content

Commit

Permalink
Add scripts to help with packaging and publishing of .vsix
Browse files Browse the repository at this point in the history
@W-4162004@
  • Loading branch information
Nick Chen committed Jul 21, 2017
1 parent 1a5ef7b commit 4102410
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 4 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/salesforcedx-vscode-apex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
5 changes: 4 additions & 1 deletion packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
5 changes: 4 additions & 1 deletion packages/salesforcedx-vscode-lightning/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
5 changes: 4 additions & 1 deletion packages/salesforcedx-vscode-visualforce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
8 changes: 7 additions & 1 deletion packages/salesforcedx-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions scripts/clean-all-but-jar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
} 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`);

0 comments on commit 4102410

Please sign in to comment.