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

refactor: automate build with rollup #83

Merged
merged 1 commit into from
Dec 22, 2019
Merged

Conversation

raulfdm
Copy link
Contributor

@raulfdm raulfdm commented Dec 22, 2019

fixes #82.

Basically the proposal is just add a very simple command which does the build process. Consequently is no need to keep bin/docsify versioned anymore.

Also it may allow you guys to write ES6 code in the future if you want. The only configuration it'll need is https://github.com/rollup/rollup-plugin-babel.

Copy link
Member

@anikethsaha anikethsaha left a comment

Choose a reason for hiding this comment

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

Good work 🎉
Left few suggestions

.gitignore Show resolved Hide resolved
main.js Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
rollup.config.js Outdated Show resolved Hide resolved
@anikethsaha
Copy link
Member

Please check why CI is failing.

@anikethsaha
Copy link
Member

@jamesgeorge007 there is an error with e2e . Please check

Copy link
Member

@jamesgeorge007 jamesgeorge007 left a comment

Choose a reason for hiding this comment

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

Update your branch. Ig that is gonna make the CI green.

@anikethsaha
Copy link
Member

Also it may allow you guys to write ES6 code in the future if you want. The only configuration it'll need is https://github.com/rollup/rollup-plugin-babel.

We can do this in future PR, adding this in thie PR will create mess

@raulfdm raulfdm changed the title WIP: refactor: automate build with rollup refactor: automate build with rollup Dec 22, 2019
@raulfdm
Copy link
Contributor Author

raulfdm commented Dec 22, 2019

Also it may allow you guys to write ES6 code in the future if you want. The only configuration it'll need is https://github.com/rollup/rollup-plugin-babel.

We can do this in future PR, adding this in thie PR will create mess

No problem. Just mentioned now it's totally possible and it'll be quite simple to do 😁

Copy link
Member

@anikethsaha anikethsaha left a comment

Choose a reason for hiding this comment

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

Please check the CI. its still failing. else its good to go

@raulfdm
Copy link
Contributor Author

raulfdm commented Dec 22, 2019

Pipeline was failing because the tests depends on bin/docsify be there. Since we don't have it versioned anymore, I just add a "postinstall" script to right after installing dependencies, it generates the build.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@anikethsaha
Copy link
Member

Why rollup is not bundling the file? it should resolve the dependencies so that we can just deploy the bin folder. 🤔

@raulfdm
Copy link
Contributor Author

raulfdm commented Dec 22, 2019

@jamesgeorge007 I need a try/catch around the assertions and it's having issues to read the file generated:

Error: Command failed with EACCES: /Users/raul/projects/open-source/docsify-cli/bin/docsify -h
spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'EACCES',
  code: 'EACCES',
  syscall: 'spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify',
  path: '/Users/raul/projects/open-source/docsify-cli/bin/docsify',
  spawnargs: [ '-h' ],
  originalMessage: 'spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify EACCES',
  shortMessage: 'Command failed with EACCES: /Users/raul/projects/open-source/docsify-cli/bin/docsify -h\n' +
    'spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify EACCES',
  command: '/Users/raul/projects/open-source/docsify-cli/bin/docsify -h',
  exitCode: undefined,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: '',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

@anikethsaha
Copy link
Member

ava 's test reporter is weird, idk but I dont get the tracked path correctly

@anikethsaha
Copy link
Member

@jamesgeorge007 I need a try/catch around the assertions and it's having issues to read the file generated:

Error: Command failed with EACCES: /Users/raul/projects/open-source/docsify-cli/bin/docsify -h
spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'EACCES',
  code: 'EACCES',
  syscall: 'spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify',
  path: '/Users/raul/projects/open-source/docsify-cli/bin/docsify',
  spawnargs: [ '-h' ],
  originalMessage: 'spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify EACCES',
  shortMessage: 'Command failed with EACCES: /Users/raul/projects/open-source/docsify-cli/bin/docsify -h\n' +
    'spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify EACCES',
  command: '/Users/raul/projects/open-source/docsify-cli/bin/docsify -h',
  exitCode: undefined,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: '',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Yup, errors / exceptions are not handled properly

@anikethsaha
Copy link
Member

@raulfdm can you try to run the tests with jest. and check

@anikethsaha
Copy link
Member

I am not a fan of ava anyway, its slower than jest and mocha. Wondering we can migrate soon I guess

@raulfdm
Copy link
Contributor Author

raulfdm commented Dec 22, 2019

I found the issue. Basically rollup does not generate a proper "executable".

To enable via terminal we should do some chmod. But I found a plugin to enable that by default.

Now probably it'll work.

@anikethsaha
Copy link
Member

but still the bin/docsify is not bundled code I guess. cause currently, we need those lib files to ship in order to work with it.

@anikethsaha
Copy link
Member

Cool ... 🎉

@raulfdm
Copy link
Contributor Author

raulfdm commented Dec 22, 2019

@jamesgeorge007 I need a try/catch around the assertions and it's having issues to read the file generated:

Error: Command failed with EACCES: /Users/raul/projects/open-source/docsify-cli/bin/docsify -h
spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'EACCES',
  code: 'EACCES',
  syscall: 'spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify',
  path: '/Users/raul/projects/open-source/docsify-cli/bin/docsify',
  spawnargs: [ '-h' ],
  originalMessage: 'spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify EACCES',
  shortMessage: 'Command failed with EACCES: /Users/raul/projects/open-source/docsify-cli/bin/docsify -h\n' +
    'spawn /Users/raul/projects/open-source/docsify-cli/bin/docsify EACCES',
  command: '/Users/raul/projects/open-source/docsify-cli/bin/docsify -h',
  exitCode: undefined,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: '',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Yup, errors / exceptions are not handled properly

Actually the error is not been handled proper.

I mean, the command is:

// ...rest
test('shows up help message without any args', async t => {
    const { stderr } = await execa(rootCommand, {reject: false});
    t.snapshot(stderr);
});
// ...

Usually async/await is surrounded by a try/catch, but in this case it just throws and ava tries somehow handle it.

I've never use this framework btw, I'm so far satisfied with Jest.

@raulfdm raulfdm requested a review from anikethsaha December 22, 2019 15:59
@anikethsaha
Copy link
Member

I'm so far satisfied with Jest.

true

I hope james will change those in future.

Copy link
Member

@anikethsaha anikethsaha left a comment

Choose a reason for hiding this comment

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

Great work 🎉

@anikethsaha anikethsaha merged commit b8183cd into docsifyjs:master Dec 22, 2019
@anikethsaha
Copy link
Member

Feel free to convert the codebase to es6 but first lets put linters first

@jamesgeorge007 jamesgeorge007 removed their request for review December 22, 2019 16:54
@jamesgeorge007
Copy link
Member

jamesgeorge007 commented Dec 22, 2019

Ava is lightweight and has got a much minimal API as compared to Jest.
https://github.com/avajs/ava#why-not-mocha-tape-tap

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

Successfully merging this pull request may close these issues.

[Proposal] Automate build and releases
3 participants