Skip to content

Commit

Permalink
remove need to add generated libs to git
Browse files Browse the repository at this point in the history
  • Loading branch information
gkovacs committed Jul 13, 2016
1 parent 025c8df commit adf76a2
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/src_vulcanize
*.deps.js
.tmp
/src/generated_libs
5 changes: 4 additions & 1 deletion gulpfile.ls
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require! {
'del'
'deepcopy'
'js-yaml'
'mkdirp'
}

gen_deps = require './scripts/generate_polymer_dependencies_lib.ls'
Expand Down Expand Up @@ -313,14 +314,15 @@ gulp.task 'generate_polymer_dependencies', (done) ->
done()

gulp.task 'generate_libs_frontend', (done) ->
mkdirp.sync 'src/generated_libs/libs_frontend'
for lib_name in function_signatures.list_libs()
lib_contents = """// This file is generated from libs_common/function_signatures.ls
// Do not edit this file directly. To regenerate, run gulp
const {import_lib} = require('libs_frontend/import_lib');
module.exports = import_lib('#{lib_name}');
"""
fs.writeFileSync "src/libs_frontend/#{lib_name}.js", lib_contents
fs.writeFileSync "src/generated_libs/libs_frontend/#{lib_name}.js", lib_contents
done()

gulp.task 'build_base', gulp.parallel('generate_polymer_dependencies', 'generate_libs_frontend', 'yaml_build', 'copy_build') #tasks_and_patterns.map((.0))
Expand Down Expand Up @@ -428,6 +430,7 @@ gulp.task 'clean', ->
'dist'
'src_vulcanize'
'src_gen'
'src/generated_libs'
]

#gulp.task 'build_then_lint', ['webpack_watch', 'webpack_content_scripts_watch'], ->
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"karma-webpack": "^1.7.0",
"livescript": "^1.5.0",
"livescript-loader": "^0.1.5",
"mkdirp": "^0.5.1",
"mocha": "^2.5.3",
"optionator": "^0.8.1",
"rewire": "^2.5.2",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Next, for all functions in that library you wish to expose to content scripts, a
}
```

Now, run `gulp`. It will generate a library under [`libs_frontend`](https://github.com/habitlab/habitlab-chrome/tree/master/src/libs_frontend) that imports the functions from the exposed background library. See [`libs_frontend/tab_utils.js`](https://github.com/habitlab/habitlab-chrome/blob/master/src/libs_frontend/tab_utils.js) for an example. Remember to add it via git.
Now, run `gulp`. It will generate a library that imports the functions from the exposed background library (it will be under `src/generated_libs/libs_frontend` but you should not need to ever look at it).

Now you can use the library in your content scripts as follows (note that all functions are asynchronous and will return a promise).

Expand Down
4 changes: 0 additions & 4 deletions src/libs_frontend/db_utils.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/libs_frontend/intervention_utils.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/libs_frontend/log_utils.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/libs_frontend/tab_utils.js

This file was deleted.

1 change: 1 addition & 0 deletions webpack.config.ls
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module.exports = {
}
fallback: [
fromcwd('src')
fromcwd(path.join('src', 'generated_libs'))
]
}
node: {
Expand Down

0 comments on commit adf76a2

Please sign in to comment.