From 4af235c659418d8ba3b2029ca1af019628741e2e Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 13 Jul 2017 19:38:59 -0500 Subject: [PATCH 1/7] Update docs --- README.md | 2 +- bit-docs.js | 8 ++++---- package.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 854e4a2..e09ac25 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Adds a `@package` tag for use in `bit-docs` `@package` will add the package's `package.json` info to the `docObject`. -Use: `@pacakge ../../package.json` +Use: `@package ../../package.json` diff --git a/bit-docs.js b/bit-docs.js index fce25f8..fd3d02b 100644 --- a/bit-docs.js +++ b/bit-docs.js @@ -1,16 +1,16 @@ var pkg = require("./package"); /** - * @module {function} bit-docs-tag-package * @parent plugins + * @module {function} bit-docs-tag-package + * @group bit-docs-tag-package/tags tags * * @description Adds a `@package` tag for use in `bit-docs`. * * @body * - * `@package` will add the package's `package.json` info to the `docObject`. - * - * Use: `@pacakge ../../package.json` + * This plugin registers onto the `tags` hook to add the + * [bit-docs-tag-package/tags/package] tag. */ module.exports = function(bitDocs) { bitDocs.register("tags",{ diff --git a/package.js b/package.js index 724221b..d1da482 100644 --- a/package.js +++ b/package.js @@ -1,6 +1,39 @@ var path = require("path"); var fs = require("graceful-fs"); +/** + * @parent bit-docs-tag-package/tags + * @module {bit-docs/types/tag} bit-docs-tag-package/tags/package @package + * + * @description Adds the package's `package.json` info to the + * [bit-docs/types/docObject]. + * + * @signature `@package PATH` + * + * Once added to the [bit-docs/types/docObject], you can reference the + * `package.json` properties like `name`, `description`, `author`, etc in + * `.mustache` templates. + * + * @param {String} PATH The path to a `package.json` file. + * + * @body + * + * An example `package.json` file might look like: + * + * ```js + * { + * "name": "my-package", + * "version": "0.0.1", + * "description": "My cool package.", + * } + * ``` + * + * That gets used like: + * + * ```js + * @@package ./demos/package.json + * ``` + */ module.exports = { add: function(line, curData, scope, objects, currentWrite) { var pkgPath = path.join(path.dirname(this.src.path), line.replace("@package", "").trim()); From 5cffd1a133612a97772933780ab9af769915b0e3 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 21 Sep 2017 01:35:35 -0500 Subject: [PATCH 2/7] small doc change --- package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.js b/package.js index d1da482..58dd806 100644 --- a/package.js +++ b/package.js @@ -3,7 +3,7 @@ var fs = require("graceful-fs"); /** * @parent bit-docs-tag-package/tags - * @module {bit-docs/types/tag} bit-docs-tag-package/tags/package @package + * @module {bit-docs-process-tags/types/tag} bit-docs-tag-package/tags/package @package * * @description Adds the package's `package.json` info to the * [bit-docs/types/docObject]. From b779328cb6dc58d20323a86f6329cdbccc339b26 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 21 Sep 2017 01:36:55 -0500 Subject: [PATCH 3/7] Git ignore package-lock.json --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c3629e..7a7b33a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +package-lock.json node_modules From 1fe5bc5fd67c4a7ef4bd85f327955bf973884572 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 21 Sep 2017 01:37:01 -0500 Subject: [PATCH 4/7] Add .travis.yml --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6c8eb04 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: node +before_install: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" From 7e8af5f4d60e142811a304ee1d73eb2fc80f862e Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 21 Sep 2017 13:11:18 -0500 Subject: [PATCH 5/7] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e09ac25..edae1fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # bit-docs `@package` -Adds a `@package` tag for use in `bit-docs` +Adds a `@package` tag for use in `bit-docs`. `@package` will add the package's `package.json` info to the `docObject`. From 67c76417854207eb842adb8ac27b9cd08ac517f0 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 4 Jun 2019 08:56:40 -0400 Subject: [PATCH 6/7] Improve error messaging when unable to find @package Fixes #6 --- .editorconfig | 9 +++++++++ package.js | 35 ++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..03f326c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +; Unix-style newlines +[*] +end_of_line = LF +indent_style = tab +indent_size = 4 + +[{*.json,*.yml,*.md}] +indent_style = space +indent_size = 2 diff --git a/package.js b/package.js index 58dd806..24a96ad 100644 --- a/package.js +++ b/package.js @@ -4,22 +4,22 @@ var fs = require("graceful-fs"); /** * @parent bit-docs-tag-package/tags * @module {bit-docs-process-tags/types/tag} bit-docs-tag-package/tags/package @package - * + * * @description Adds the package's `package.json` info to the * [bit-docs/types/docObject]. - * + * * @signature `@package PATH` - * + * * Once added to the [bit-docs/types/docObject], you can reference the * `package.json` properties like `name`, `description`, `author`, etc in * `.mustache` templates. - * + * * @param {String} PATH The path to a `package.json` file. - * + * * @body - * + * * An example `package.json` file might look like: - * + * * ```js * { * "name": "my-package", @@ -27,17 +27,30 @@ var fs = require("graceful-fs"); * "description": "My cool package.", * } * ``` - * + * * That gets used like: - * + * * ```js * @@package ./demos/package.json * ``` */ module.exports = { add: function(line, curData, scope, objects, currentWrite) { - var pkgPath = path.join(path.dirname(this.src.path), line.replace("@package", "").trim()); - var pkg = fs.readFileSync(pkgPath).toString(); + var atPackagePath = line.replace("@package", "").trim(); + var pkgPath = path.join(path.dirname(this.src.path), atPackagePath); + var pkg; + try { + pkg = fs.readFileSync(pkgPath).toString(); + } catch(e) { + if(e.code === "ENOENT") { + var newError = new Error('@package: Unable to locate ' + + atPackagePath + " from " + this.src.path + ); + throw newError; + } + + throw e; + } var result = JSON.parse(pkg); // delete things that would be too big From 221961f119c72eee73ec1b5faa584b3fb990d2b7 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 4 Jun 2019 10:07:30 -0400 Subject: [PATCH 7/7] 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6077c78..bf8f0c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bit-docs-tag-package", - "version": "0.0.6", + "version": "1.0.0", "description": "Reference package's package.json", "main": "package.js", "scripts": {