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

chore: @talend/scripts module #1098

Merged
merged 18 commits into from
Feb 28, 2018
Merged

Conversation

jsomsanith-tlnd
Copy link
Contributor

@jsomsanith-tlnd jsomsanith-tlnd commented Feb 25, 2018

What is the problem this PR is trying to solve?
Each app has it's build/test/lint configuration, even if they are the same or almost the same.

What is the chosen solution to this problem?
Create a module @talend/scripts that exposes bins to run common scripts with common configuration. Those configurations can be overridden or enhanced by app custom configuration.

This PR is only on build (webpack). Please refer to the README to understand how it works.
It is still on webpack 3 because there are plugins and loaders that are not ready yet :

Please check if the PR fulfills these requirements

  • The PR commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Related design / discussions / pages (not in jira), if any, are all linked or available in the PR

[ ] This PR introduces a breaking change

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

1 similar comment
@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

' | \'--------------\' || \'--------------\' || \'--------------\' || \'--------------\' || \'--------------\' || \'--------------\' || \'--------------\' |\n' +
' \'----------------\' \'----------------\' \'----------------\' \'----------------\' \'----------------\' \'----------------\' \'----------------\' \n' +
'###################################################################################################################################################################');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove that useless ascii art.

try {
pathFromWhich = fs.realpathSync(which.sync(executable));
} catch (_error) {
// ignore _error
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove that try/catch if you don't intend of using the error.

Copy link
Contributor Author

@jsomsanith-tlnd jsomsanith-tlnd Feb 27, 2018

Choose a reason for hiding this comment

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

No it's to not throw the error from which module call. If the command fails, the script should not fail.

* @returns {*} The executable path
*/
function resolveBin(modName, { executable = modName, cwd = process.cwd() } = {}) {
let pathFromWhich;
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename pathFromWhich to something meaningful.

@@ -0,0 +1,175 @@
/* eslint-disable global-require */
Copy link
Contributor

Choose a reason for hiding this comment

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

Please properly rename that script into something that describes its content.

*/
function hereRelative(dirname, p) {
return path
.join(dirname, p)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename p to path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

path is already used by nodeJs' path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll find something

* Create a user configuration getter
* @returns {getUserConfig} The user configuration getter
*/
function createUserConfigGetter() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why you need a getter creator. Can't you just do the call from inside the getter?

Copy link
Contributor Author

@jsomsanith-tlnd jsomsanith-tlnd Feb 27, 2018

Choose a reason for hiding this comment

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

It's to memoize the talendScriptsConfig.
It is transported in environment var, so it is serialized (JSON.stringify). To get it, I parse it (JSON.parse). This allows to parse it 1 time and then each call to get() just use it.

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

### Default usage

1. Add @talend/scripts as dev dependency.
```
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use shell or bash here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

1 similar comment
@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@jsomsanith-tlnd jsomsanith-tlnd merged commit 324356a into master Feb 28, 2018
@jsomsanith-tlnd jsomsanith-tlnd deleted the jsomsanith/chore/talend_scripts branch February 28, 2018 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants