Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Refactoring #11

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Refactoring #11

wants to merge 19 commits into from

Conversation

denar90
Copy link

@denar90 denar90 commented Jan 17, 2017

  • coffee -> es6 + refactoring

@shvaikalesh
Copy link

Let's not commit yarn.lock. Useless trash.

index.js Outdated
}

// Defaults options
this.options = {

Choose a reason for hiding this comment

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

const defaultOptions = and remove the comment

index.js Outdated

// Defaults options
this.options = {
ignore: /[\\/][.]/,

Choose a reason for hiding this comment

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

/\/\./

index.js Outdated
manifestFile: 'appcache.appcache'
};

// Merge config

Choose a reason for hiding this comment

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

remove the comment pls

index.js Outdated
}

AppCacheCompiler.prototype.brunchPlugin = true;
AppCacheCompiler.prototype.staticTargetExtension = 'html';

Choose a reason for hiding this comment

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

This one is extra

@denar90 denar90 changed the title Refactoring WIP Refactoring Jan 18, 2017
README.md Outdated
staticRoot: '/static'
network: ['*']
```js
exports.config = {
Copy link
Contributor

Choose a reason for hiding this comment

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

module.exports = {

package.json Outdated
"mocha": "^3",
"sinon": "^1.17.7",
"eslint": "^3.12.2",
"eslint-config-brunch": "brunch/eslint-config-brunch"
Copy link
Contributor

Choose a reason for hiding this comment

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

^1.0.0

Copy link

@shvaikalesh shvaikalesh Feb 18, 2017

Choose a reason for hiding this comment

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

^1, ^3 etc.

index.js Outdated
}

processFile(file) {
if (!/[.]appcache$/.test(file.path) && !this.config.ignore.test(file.path) && !this.paths.includes(file.path)) {

Choose a reason for hiding this comment

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

path.endsWith('.appcache')

index.js Outdated
return (Array.from(Object.keys(obj).sort()).map(k => `${k} ${obj[k]}`)).join('\n');
};

_readStream(path) {

Choose a reason for hiding this comment

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

The whole point of rewrite is to not have this method. Use file.data.

package.json Outdated
@@ -8,14 +8,18 @@
"type": "git",
"url": "[email protected]:brunch/appcache-brunch.git"
},
"main": "./lib/index",
"main": "index.js",

Choose a reason for hiding this comment

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

It is default value. We can remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't quite obvious, though

Choose a reason for hiding this comment

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

On pair with index.html.

index.js Outdated
}

_format(obj) {
return (Array.from(Object.keys(obj).sort()).map(k => `${k} ${obj[k]}`)).join('\n');

Choose a reason for hiding this comment

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

- Array.from(iter).map(fn)
+ Array.from(iter, fn)

index.js Outdated
try {
if (this.changedFileContentShasum) {
this.pathsToCache = files
.filter(file => !/[.]appcache$/.test(file.path) && !this.config.ignore.test(file.path) && !this.pathsToCache.includes(file.path))

Choose a reason for hiding this comment

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

path.endsWith('.appcache') and consider extracting this fn.

.map(file => file.path)
.sort();

this.pathsToCache.push(...pathsToCache);
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally, do not prefer this, but it looks acceptable.

Choose a reason for hiding this comment

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

Why?

index.js Outdated
}

_format(obj) {
return (Array.from(Object.keys(obj).sort(), k => `${k} ${obj[k]}`)).join('\n');
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra () aren't necessary

Choose a reason for hiding this comment

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

Didn't we agree this should not be method?

Uses this => method
Otherwise => helper

Easy.

test/test.js Outdated
});

it('should call "_processFile" method', () => {
return plugin.compile(mocks.files[0], () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't plugin.compile returns a Promise? Why do you pass a callback then?

test/test.js Outdated
});

it('sets changedFileContentShasum', () => {
const file = mocks.files[0];
Copy link

@shvaikalesh shvaikalesh Feb 19, 2017

Choose a reason for hiding this comment

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

const [file] = mocks.files as we already dropped Node.js < 6.

test/test.js Outdated
const mocks = require('./fixtures/mocks');
const config = require('./fixtures/brunch.conf');

const Plugin = require('../index');

Choose a reason for hiding this comment

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

require('..')

it('ignores appcache files', () => {
const file = mocks.ignoredFiles[0];
plugin._processFile(file);
assert.deepEqual(plugin.paths, []);

Choose a reason for hiding this comment

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

assert.empty

Copy link
Author

Choose a reason for hiding this comment

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

But assert doesn't have empty method...

Choose a reason for hiding this comment

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

It does in master.

Copy link
Author

Choose a reason for hiding this comment

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

In nodejs master?
Should we keep it as it is until new version be released?

test/test.js Outdated

assert.equal(actualAppCacheContent, expectedAppCacheContent);
})
.catch(e => console.log(e));

Choose a reason for hiding this comment

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

Let's remove this.

index.js Outdated
${format(this.config.fallback)}

CACHE:
${(Array.from(this.pathsToCache).map(p => `${this.config.staticRoot}/${p}`)).join('\n')}
Copy link

@shvaikalesh shvaikalesh Feb 19, 2017

Choose a reason for hiding this comment

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

Array.from(this.pathsToCache, p => `${this.config.staticRoot}/${p}`)

Copy link
Contributor

Choose a reason for hiding this comment

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

and without extra ()

Choose a reason for hiding this comment

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

I disabled no-extra-parens in eslint config cause it gave false-positives. Maybe we should reconsider this.

Copy link
Author

Choose a reason for hiding this comment

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

I've fixed for format method but missed this one...

network: ['*'],
fallback: {},
staticRoot: '.',
manifestFile: 'appcache.appcache',

Choose a reason for hiding this comment

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

Array(2).fill('appcache').join('.') :trollface:

index.js Outdated
}

AppCacheCompiler.prototype.brunchPlugin = true;
AppCacheCompiler.prototype.pattern = /(?:)/;

Choose a reason for hiding this comment

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

const matchesAll = /(?:)/
AppCacheCompiler.prototype.pattern = matchesAll

.travis.yml Outdated
language: node_js
- osx
node_js:
- 7
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use just node — the latest version of Node.js

@denar90
Copy link
Author

denar90 commented May 25, 2017

I think it can go after real world testing aka brunch/brunch.github.io#267
thoughts?

@denar90
Copy link
Author

denar90 commented Jan 9, 2018

Should we stop working on a new version since all browsers support https://caniuse.com/#feat=serviceworkers service workers?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants