Skip to content

Commit

Permalink
Added support for NPM.
Browse files Browse the repository at this point in the history
Published the codlab-elements on NPM
  • Loading branch information
nicolasgarnier committed Sep 25, 2019
1 parent 87c08e5 commit 74be4cf
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ bazel-*
.drone.sec.yml
.idea/
debug.test
*pb.go
*pb.go
node_modules
12 changes: 12 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ genrule(
],
cmd = "zip -j $@ $(SRCS)",
)

genrule(
name = "npm_dist",
outs = ["npm_dist.zip"],
srcs = [
"LICENSE",
"package.json",
"//codelab-elements:README.md",
"//codelab-elements:all_files",
],
cmd = "zip -j $@ $(SRCS)",
)
20 changes: 20 additions & 0 deletions codelab-elements/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,26 @@ Here's an index.html obtaining the codelab-elements from Google Cloud Storage:
</html>
```

## NPM

The library is published on NPM.js at: https://www.npmjs.com/package/codelab-elements

We also support a build workflow using NPM. To build the library run fro the root of the repo:

```bash
# Install dependencies. This takes care of installing the right version of Bazel.
npm install

# Build the library
npm run build

# The output is a zip file under bazel-genfiles
ls bazel-genfiles npm_dist.zip

# Publish a new version of the library to NPM
npm run dist
```

## Notes

This is not an official Google product.
38 changes: 38 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "codelab-elements",
"version": "1.0.0",
"description": "Custom elements for codelabs",
"main": "index.js",
"scripts": {
"clean": "node_modules/.bin/bazel clean",
"build": "node_modules/.bin/bazel build npm_dist",
"test": "node_modules/.bin/bazel test --test_output=all codelab-elements/demo:hello_test",
"pub": "npm run clean && npm run build && cd bazel-genfiles && unzip npm_dist.zip -d npm_dist && npm publish npm_dist"
},
"author": "Google",
"repository": {
"type": "git",
"url": "https://github.com/googlecodelabs/tools.git"
},
"license": "Apache-2.0",
"devDependencies": {
"@bazel/bazel": "^0.18.1"
}
}

0 comments on commit 74be4cf

Please sign in to comment.