Skip to content

Commit

Permalink
pre-release cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kkamkou committed Oct 25, 2016
1 parent 5896e13 commit d85a28a
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 97 deletions.
63 changes: 24 additions & 39 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,7 @@ function manifestUpdate(data) {
);
}

function readDir(pathDir, ext) {
var files = fs.readdirSync(pathDir),
results = [];

for (var idx in files) {
var filePath = path.join(pathDir, files[idx]),
stat = fs.statSync(filePath);

if (stat.isDirectory()) {
results = _.union(results, readDir(filePath, ext));
continue;
}

if (!ext || (ext && filePath.match(new RegExp('\\.' + ext + '$')))) {
results.push(filePath);
}
}

return results;
}

function minify (fileSet) {
function minify(fileSet) {
let output = '';
fileSet.forEach(f => {
output += ~f.indexOf('/vendors/')
Expand All @@ -69,6 +48,20 @@ function minify (fileSet) {
return output;
}

function scripts() {
var templatePath = path.join(CONSTANTS.DIR_BUILD, 'views', 'default.html'),
body = fs.readFileSync(templatePath, {encoding: 'utf-8'}),
regex = new RegExp('<script.*src="(.+?)"><\/script>', 'g'),
fileSet = [],
match;

while ((match = regex.exec(body)) !== null) {
fileSet.push(path.join(CONSTANTS.DIR_SRC, match[1]));
}

return fileSet;
}

// default
desc('Default build action');
task('default', ['cleanup-pre', 'layout-modify', 'cleanup-post'], function () {
Expand All @@ -78,14 +71,11 @@ task('default', ['cleanup-pre', 'layout-modify', 'cleanup-post'], function () {
// pack-app
desc('Application scripts packing');
task('pack-app', ['copy-sources'], {async: true}, function () {
var files = [];

['shared', 'lib', 'bootstrap.js', 'controllers'].forEach(function (p) {
if (p.indexOf('.js') !== -1) {
files.push(path.join(CONSTANTS.DIR_APP, p));
return;
const files = [];
scripts().forEach(path => {
if (!~path.indexOf('vendors/')) {
files.push(path);
}
files = files.concat(readDir(path.join(CONSTANTS.DIR_APP, p), 'js').reverse());
});

fs.writeFile(
Expand All @@ -101,17 +91,12 @@ task('pack-app', ['copy-sources'], {async: true}, function () {
// pack-vendors
desc('Vendors scripts packing');
task('pack-vendors', ['copy-sources'], {async: true}, function () {
var templatePath = path.join(CONSTANTS.DIR_BUILD, 'views', 'default.html'),
body = fs.readFileSync(templatePath, {encoding: 'utf-8'}),
regex = new RegExp('<script.*src="(.+?)"><\/script>', 'g'),
fileSet = [],
match;

while ((match = regex.exec(body)) !== null) {
if (!~match[1].indexOf('less/')) {
fileSet.push(path.join(CONSTANTS.DIR_SRC, match[1]));
const fileSet = [];
scripts().forEach(path => {
if (~path.indexOf('vendors/') && !~path.indexOf('less/')) {
fileSet.push(path);
}
}
});

fs.writeFile(
path.join(CONSTANTS.DIR_BUILD_APP, 'vendors.js'), minify(fileSet), () => {
Expand Down
Binary file added packed/chrome-jironimo-5.crx
Binary file not shown.
10 changes: 9 additions & 1 deletion src/app/lib/route/Abstract.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
/**
* chrome-jironimo
*
* @author Kanstantsin Kamkou <2ka.by>
* @link http://github.com/kkamkou/chrome-jironimo
* @license http://opensource.org/licenses/BSL-1.0
*/

'use strict';

class RouteAbstract {
/*final public*/class RouteAbstract {
constructor($scope, scopeMethods) {
this.services = angular.injector(['jironimo']);
this.scope = $scope;
Expand Down
14 changes: 13 additions & 1 deletion src/app/lib/route/settings/General.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
/**
* chrome-jironimo
*
* @author Kanstantsin Kamkou <2ka.by>
* @link http://github.com/kkamkou/chrome-jironimo
* @license http://opensource.org/licenses/BSL-1.0
*/

'use strict';

class RouteSettingsGeneral extends RouteAbstract {
/*final public*/class RouteSettingsGeneral extends RouteAbstract {
constructor($scope) {
super($scope, ['save', 'accountAdd', 'accountRemoveSelected', 'accountAuthVerify']);
this.settings = this.service('cjSettings');
Expand All @@ -13,6 +21,10 @@ class RouteSettingsGeneral extends RouteAbstract {
$scope.$watch('accountSelected', () => {
$scope.accountSelectedAuthStatus = -1;
});

if (!$scope.accountList.find(a => a.enabled)) {
this.scope.notifications.push({type: 'notice', message: 'You have no enabled accounts!'});
}
}

save() {
Expand Down
10 changes: 9 additions & 1 deletion src/app/lib/route/settings/Workspace.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
/**
* chrome-jironimo
*
* @author Kanstantsin Kamkou <2ka.by>
* @link http://github.com/kkamkou/chrome-jironimo
* @license http://opensource.org/licenses/BSL-1.0
*/

'use strict';

class RouteSettingsWorkspace extends RouteAbstract {
/*final public*/class RouteSettingsWorkspace extends RouteAbstract {
constructor($scope) {
super($scope, ['add', 'save', 'remove', 'import', 'accountSwitch', 'isQueryValidForWatch']);

Expand Down
14 changes: 7 additions & 7 deletions src/app/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ angular
defaults.workspaces = [
{
account: 'ALL',
icon: 'target',
title: $filter('i18n')('settingsWorkspaceMyIssues'),
query: 'assignee = currentUser() AND status not in (Closed, Resolved)' +
' ORDER BY updatedDate DESC',
icon: 'share-2',
title: $filter('i18n')('settingsWorkspaceCreatedByMe'),
query: 'reporter = currentUser() ORDER BY created DESC',
changesNotify: true
},
{
account: 'ALL',
icon: 'share-2',
title: $filter('i18n')('settingsWorkspaceCreatedByMe'),
query: 'reporter = currentUser() ORDER BY created DESC',
icon: 'target',
title: $filter('i18n')('settingsWorkspaceMyIssues'),
query: 'assignee = currentUser() AND status not in (Closed, Resolved)' +
' ORDER BY updatedDate DESC',
changesNotify: true
},
{
Expand Down
52 changes: 4 additions & 48 deletions src/app/lib/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,6 @@

'use strict';

/*final public*/class CjWorkLogEntry {
constructor(id, state, timestamp) {
this._id = id;
this._state = state || 'STOPPED';
this._timestamp = timestamp || Date.now();

if (!~['STOPPED', 'STARTED'].indexOf(this._state)) {
throw new TypeError('Unknown state: ' + this._state);
}
}

get id() {
return this._id;
}

get started() {
return this._state === 'STARTED';
}

get stopped() {
return this._state === 'STOPPED';
}

get duration() {
return Date.now() - this._timestamp;
}

resume() {
this._state = 'STARTED';
}

start() {
this._timestamp = Date.now();
this._state = 'STARTED';
}

stop() {
this._state = 'STOPPED';
}

toJSON() {
return {id: this._id, state: this._state, timestamp: this._timestamp};
}
}

angular
.module('jironimo.timer', ['jironimo.settings'])
.factory('cjTimer', ['$rootScope', 'cjSettings', function ($rootScope, cjSettings) {
Expand All @@ -61,8 +16,9 @@ angular
const storage = {},
activity = _.get(cjSettings.activity, `workspace.${account.id}.timers`, {});

Object.keys(activity).forEach(k =>
storage[k] = new CjWorkLogEntry(activity[k].id, activity[k].state, activity[k].timestamp)
Object.keys(activity).forEach(
k => storage[k] =
new TimerWorkLogEntry(activity[k].id, activity[k].state, activity[k].timestamp)
);

return {
Expand Down Expand Up @@ -161,7 +117,7 @@ angular
*/
start: function (issue) {
if (!storage[issue.id]) {
storage[issue.id] = new CjWorkLogEntry(issue.id);
storage[issue.id] = new TimerWorkLogEntry(issue.id);
}

storage[issue.id].start();
Expand Down
54 changes: 54 additions & 0 deletions src/app/lib/timer/TimerWorkLogEntry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* chrome-jironimo
*
* @author Kanstantsin Kamkou <2ka.by>
* @link http://github.com/kkamkou/chrome-jironimo
* @license http://opensource.org/licenses/BSL-1.0
*/

'use strict';

/*final public*/class /* */ TimerWorkLogEntry {
constructor(id, state, timestamp) {
this._id = id;
this._state = state || 'STOPPED';
this._timestamp = timestamp || Date.now();

if (!~['STOPPED', 'STARTED'].indexOf(this._state)) {
throw new TypeError('Unknown state: ' + this._state);
}
}

get id() {
return this._id;
}

get started() {
return this._state === 'STARTED';
}

get stopped() {
return this._state === 'STOPPED';
}

get duration() {
return Date.now() - this._timestamp;
}

resume() {
this._state = 'STARTED';
}

start() {
this._timestamp = Date.now();
this._state = 'STARTED';
}

stop() {
this._state = 'STOPPED';
}

toJSON() {
return {id: this._id, state: this._state, timestamp: this._timestamp};
}
}
1 change: 1 addition & 0 deletions src/views/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<script type="text/javascript" src="/app/lib/jira-api.js"></script>
<script type="text/javascript" src="/app/lib/notifications.js"></script>
<script type="text/javascript" src="/app/lib/timer.js"></script>
<script type="text/javascript" src="/app/lib/timer/TimerWorkLogEntry.js"></script>
<script type="text/javascript" src="/app/lib/route/Abstract.js"></script>
<script type="text/javascript" src="/app/lib/route/settings/General.js"></script>
<script type="text/javascript" src="/app/lib/route/settings/Workspace.js"></script>
Expand Down

0 comments on commit d85a28a

Please sign in to comment.