Skip to content

Commit

Permalink
fix(sentry-plugin): use package version from env variables instead of…
Browse files Browse the repository at this point in the history
… package.json
  • Loading branch information
seibert-io committed Jun 9, 2020
1 parent f315d97 commit bd3db57
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 172 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

.idea/*

# Editor directories and files
.idea/workspace.xml
.idea/tasks.xml
Expand Down
81 changes: 46 additions & 35 deletions .vscode/settings.template.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
{
"auto-close-tag.enableAutoCloseSelfClosingTag": true,
"auto-close-tag.activationOnLanguage": ["xml", "vue", "HTML (Eex)"],
"editor.rulers": [120],
"editor.formatOnSave": false,
"eslint.trace.server": "messages",
"eslint.validate": [
"vue", "html", "typescript", "javascript", "json", "php", "scss", "md"
],
"vetur.validation.template": false,
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"eslint.enable": true,

"scss.validate": false,
"[scss]": {
"editor.formatOnSave": false,
},
"[php]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "bmewburn.vscode-intelephense-client",
"editor.quickSuggestions": {
"comments": true
}
},
"[markdown]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"importCost.typescriptExtensions": ["\\.tsx?$", "\\.vue$"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
},
"git.inputValidationLength": 82,
"git.inputValidationSubjectLength": 82
"auto-close-tag.enableAutoCloseSelfClosingTag": true,
"auto-close-tag.activationOnLanguage": [
"xml",
"vue",
"HTML (Eex)"
],
"editor.rulers": [
120
],
"editor.formatOnSave": false,
"eslint.trace.server": "messages",
"eslint.validate": [
"vue",
"html",
"typescript",
"javascript"
],
"vetur.validation.template": false,
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"eslint.enable": true,
"scss.validate": false,
"[scss]": {
"editor.formatOnSave": false
},
"[php]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "bmewburn.vscode-intelephense-client",
"editor.quickSuggestions": {
"comments": true
}
},
"[markdown]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"importCost.typescriptExtensions": [
"\\.tsx?$",
"\\.vue$"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
},
"git.inputValidationLength": 82,
"git.inputValidationSubjectLength": 82
}
2 changes: 1 addition & 1 deletion dist/plugins/netlify-plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Plugin from '../base/Plugin';
import * as program from 'commander';
export default class NetlifyPlugin extends Plugin {
getName(): string;
init(program: program.Command): void;
init(rootProgram: program.Command): void;
/**
* Netlify only clones the repo as a shallow copy. If we're in a Netlify build context, the current working branch reported by Git will be != process.env.BRANCH reported by Netlify.
* We will need to switch to the real branch first to make a release commit in the process.env.BRANCH branch.
Expand Down
18 changes: 11 additions & 7 deletions dist/plugins/netlify-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var NetlifyPlugin = /** @class */ (function (_super) {
NetlifyPlugin.prototype.getName = function () {
return 'heyday-release-netlify';
};
NetlifyPlugin.prototype.init = function (program) {
NetlifyPlugin.prototype.init = function (rootProgram) {
this.log('Plugin initialized');
};
/**
Expand Down Expand Up @@ -106,17 +106,21 @@ var NetlifyPlugin = /** @class */ (function (_super) {
* and commit suggestions can be made
*/
NetlifyPlugin.prototype.afterCreateRelease = function (dryRun) {
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2 /*return*/];
}); });
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/];
});
});
};
/**
* Notify Sentry of a deployment of a release
*/
NetlifyPlugin.prototype.afterDeploymentFinished = function () {
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2 /*return*/];
}); });
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/];
});
});
};
NetlifyPlugin.prototype.log = function (message) {
console.log(chalk_1["default"].gray("[" + this.getName() + "]") + " " + message);
Expand Down
4 changes: 2 additions & 2 deletions dist/plugins/sentry-plugin.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Plugin from '../base/Plugin';
import * as program from 'commander';
import Plugin from '../base/Plugin';
export default class SentryPlugin extends Plugin {
getName(): string;
init(program: program.Command): void;
init(rootProgram: program.Command): void;
beforeCreateRelease(dryRun: boolean): Promise<boolean>;
/**
* Notify Sentry of the new release so issues can be linked with releases
Expand Down
13 changes: 5 additions & 8 deletions dist/plugins/sentry-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
}
};
exports.__esModule = true;
var fs = require("fs");
var path = require("path");
var shell = require("shelljs");
var chalk_1 = require("chalk");
var Plugin_1 = require("../base/Plugin");
Expand All @@ -63,9 +61,9 @@ var SentryPlugin = /** @class */ (function (_super) {
SentryPlugin.prototype.getName = function () {
return 'heyday-release-sentry';
};
SentryPlugin.prototype.init = function (program) {
SentryPlugin.prototype.init = function (rootProgram) {
var _this = this;
var sentryCommand = program.command('sentry').description('Sentry operations');
var sentryCommand = rootProgram.command('sentry').description('Sentry operations');
sentryCommand
.command('create-deployment')
.description('Notify sentry of a deployment')
Expand Down Expand Up @@ -127,7 +125,7 @@ var SentryPlugin = /** @class */ (function (_super) {
releaseCommitRef = shell
.exec('git log -1 --format="%H"', { silent: true })
.toString()
.replace(/(\n|\r)/, '');
.replace(/([\n\r])/, '');
shell.exec("sentry-cli releases set-commits \"" + currentVersion + "\" --commit \"" + process.env.SENTRY_REPOSITORY_ID + "@" + releaseCommitRef + "\"", { silent: false });
}
else {
Expand All @@ -143,7 +141,7 @@ var SentryPlugin = /** @class */ (function (_super) {
*/
SentryPlugin.prototype.afterDeploymentFinished = function () {
return __awaiter(this, void 0, void 0, function () {
var packageJson, currentVersion;
var currentVersion;
return __generator(this, function (_a) {
if (!this.isSentryEnabled()) {
console.info('[finish-deployment] Current branch is not configured to deploy a release in Sentry. Skipping sentry deployment notification...');
Expand All @@ -154,8 +152,7 @@ var SentryPlugin = /** @class */ (function (_super) {
return [2 /*return*/];
}
console.log(chalk_1["default"].white('[complete-deployment] Notifying Sentry of release deployment...'));
packageJson = JSON.parse(String(fs.readFileSync(path.resolve(__dirname, '../package.json'))));
currentVersion = packageJson.name + "@" + packageJson.version;
currentVersion = process.env.npm_package_name + "@" + process.env.npm_package_version;
console.log(chalk_1["default"].white("[complete-deployment] Sentry release version to deploy: " + currentVersion));
shell.env.SENTRY_AUTH_TOKEN = process.env.SENTRY_AUTH_TOKEN || '';
shell.env.SENTRY_ORG = process.env.SENTRY_ORG || '';
Expand Down
Loading

0 comments on commit bd3db57

Please sign in to comment.