commonform-terminal
Advanced tools
Comparing version 0.9.2 to 1.0.0
/* Copyright Kyle E. Mitchell | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you | ||
* may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at | ||
* | ||
@@ -10,15 +10,17 @@ * http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
var decimalStyle = require('decimal-numbering'); | ||
var flatten = require('commonform-flatten'); | ||
var paragraph = require('./paragraph'); | ||
var flatten = require('commonform-flatten') | ||
var paragraph = require('./paragraph') | ||
module.exports = function(form, values) { | ||
return flatten(form, values).map(function(element) { | ||
return paragraph(element, decimalStyle); | ||
}).join(''); | ||
}; | ||
module.exports = function (form, values, options) { | ||
var numbering = options.numbering | ||
return flatten(form, values) | ||
.map(function (element) { | ||
return paragraph(element, numbering) | ||
}) | ||
.join('') | ||
} |
24
index.js
/* Copyright Kyle E. Mitchell | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you | ||
* may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at | ||
* | ||
@@ -10,12 +10,12 @@ * http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
var doc = require('./document'); | ||
var doc = require('./document') | ||
module.exports = function() { | ||
var codes = doc.apply(this, arguments); | ||
return codes.slice(0, codes.length - 2); | ||
}; | ||
module.exports = function () { | ||
var codes = doc.apply(this, arguments) | ||
return codes.slice(0, codes.length - 2) | ||
} |
{ | ||
"name": "commonform-terminal", | ||
"description": "display Common Forms at text terminals", | ||
"version": "0.9.2", | ||
"version": "1.0.0", | ||
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (http://kemitchell.com)", | ||
"bugs": "https://github.com/commonform/commonform-terminal/issues", | ||
"dependencies": { | ||
"chalk": "^1.0.0", | ||
"commonform-flatten": "0.8.x", | ||
"decimal-numbering": "^1.1.0" | ||
"chalk": "^2.1.0", | ||
"commonform-flatten": "^0.8.1" | ||
}, | ||
"devDependencies": { | ||
"defence-cli": "~1.0.1", | ||
"replace-require-self": "~1.0.0" | ||
"decimal-numbering": "^2.0.1", | ||
"defence-cli": "^2.0.1", | ||
"replace-require-self": "^1.1.1", | ||
"standard": "^10.0.3", | ||
"standard-markdown": "^4.0.2" | ||
}, | ||
@@ -30,4 +32,5 @@ "homepage": "https://commonform.github.io", | ||
"scripts": { | ||
"test": "defence README.md | replace-require-self | node" | ||
"test": "FORCE_COLOR=1 defence README.md | replace-require-self | node", | ||
"lint": "standard && standard-markdown" | ||
} | ||
} |
/* Copyright Kyle E. Mitchell | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you | ||
* may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at | ||
* | ||
@@ -10,25 +10,28 @@ * http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
var chalk = require('chalk'); | ||
var run = require('./run'); | ||
var chalk = require('chalk') | ||
var run = require('./run') | ||
var TAB = ' '; | ||
var TAB = ' ' | ||
module.exports = function(paragraph, numberStyle) { | ||
var number = paragraph.hasOwnProperty('numbering') ? | ||
paragraph.numbering : ''; | ||
var conspicuous = paragraph.hasOwnProperty('conspicuous'); | ||
module.exports = function (paragraph, numberStyle) { | ||
var number = paragraph.hasOwnProperty('numbering') | ||
? paragraph.numbering | ||
: '' | ||
var conspicuous = paragraph.hasOwnProperty('conspicuous') | ||
return new Array(paragraph.depth * 4 + 1).join(' ') + | ||
(number ? | ||
chalk.gray(numberStyle(number)) + TAB : '') + | ||
(paragraph.hasOwnProperty('heading') ? | ||
chalk.blue.underline(paragraph.heading) + '. ' : '') + | ||
paragraph.content.map(function(element) { | ||
return run(element, numberStyle, conspicuous); | ||
(number ? chalk.gray(numberStyle(number)) + TAB : '') + | ||
( | ||
paragraph.hasOwnProperty('heading') | ||
? chalk.blue.underline(paragraph.heading) + '. ' | ||
: '' | ||
) + | ||
paragraph.content.map(function (element) { | ||
return run(element, numberStyle, conspicuous) | ||
}).join('') + | ||
'\n\n'; | ||
}; | ||
'\n\n' | ||
} |
100
README.md
```javascript | ||
var terminal = require('commonform-terminal') | ||
var decimal = require('decimal-numbering') | ||
var assert = require('assert') | ||
@@ -7,49 +8,60 @@ | ||
terminal( | ||
{ "content": [ | ||
"This ", | ||
{ use: "Agreement" }, | ||
" (this ", | ||
{ "definition": "Agreement" }, | ||
" is made effective as of the date the last ", | ||
{ "use": "Party" }, | ||
" signs this ", | ||
{ "use": "Agreement" }, | ||
" (the ", | ||
{ "definition": "Effective Date" }, | ||
") by and between ", | ||
{ "blank": "" }, | ||
", a ", | ||
{ "blank": "" }, | ||
" (", | ||
{ "definition": "Company" }, | ||
") and the several purchasers named in ", | ||
{ "reference": "Purchasers" }, | ||
" (", | ||
{ "definition": "Purchasers" }, | ||
", and together with ", | ||
{ use: "Company"}, | ||
", each a ", | ||
{ "definition": "Party" }, | ||
")." ] }, | ||
[ /* no blank values */ ], | ||
{ /* no options */ }), | ||
[ " This \u001b[35mAgreement\u001b[39m (this \"", | ||
"\u001b[32mAgreement\u001b[39m\" is made effective as of ", | ||
"the date the last \u001b[35mParty\u001b[39m signs this ", | ||
"\u001b[35mAgreement\u001b[39m (the \"\u001b[32mEffective ", | ||
"Date\u001b[39m\") by and between \u001b[31m\u001b[4m[_]", | ||
"\u001b[24m\u001b[39m, a \u001b[31m\u001b[4m[_]", | ||
"\u001b[24m\u001b[39m (\"\u001b[32mCompany", | ||
"\u001b[39m\") and the several purchasers named in \u001b[33m", | ||
"Purchasers\u001b[39m (\"\u001b[32mPurchasers\u001b[39m\", and ", | ||
"together with \u001b[35mCompany\u001b[39m, each a \"\u001b[32m", | ||
"Party\u001b[39m\")." ].join('')) | ||
{ | ||
content: [ | ||
'This ', | ||
{use: 'Agreement'}, | ||
' (this ', | ||
{definition: 'Agreement'}, | ||
' is made effective as of the date the last ', | ||
{use: 'Party'}, | ||
' signs this ', | ||
{use: 'Agreement'}, | ||
' (the ', | ||
{definition: 'Effective Date'}, | ||
') by and between ', | ||
{blank: ''}, | ||
', a ', | ||
{blank: ''}, | ||
' (', | ||
{definition: 'Company'}, | ||
') and the several purchasers named in ', | ||
{reference: 'Purchasers'}, | ||
' (', | ||
{definition: 'Purchasers'}, | ||
', and together with ', | ||
{use: 'Company'}, | ||
', each a ', | ||
{definition: 'Party'}, | ||
').' | ||
] | ||
}, | ||
[/* no blank values */], | ||
{numbering: decimal}), | ||
[ | ||
' This \u001b[35mAgreement\u001b[39m (this "', | ||
'\u001b[32mAgreement\u001b[39m" is made effective as of ', | ||
'the date the last \u001b[35mParty\u001b[39m signs this ', | ||
'\u001b[35mAgreement\u001b[39m (the "\u001b[32mEffective ', | ||
'Date\u001b[39m") by and between \u001b[31m\u001b[4m[_]', | ||
'\u001b[24m\u001b[39m, a \u001b[31m\u001b[4m[_]', | ||
'\u001b[24m\u001b[39m ("\u001b[32mCompany', | ||
'\u001b[39m") and the several purchasers named in \u001b[33m', | ||
'Purchasers\u001b[39m ("\u001b[32mPurchasers\u001b[39m", and ', | ||
'together with \u001b[35mCompany\u001b[39m, each a "\u001b[32m', | ||
'Party\u001b[39m").' | ||
].join('') | ||
) | ||
assert.equal( | ||
terminal( | ||
{ "content": [ { "blank": "" } ] }, | ||
[ { blank: [ 'content', 0 ], | ||
value: 'NewCo, Inc.' } ], | ||
{ /* no options */ }), | ||
" \u001b[31m\u001b[4m[NewCo, Inc.]\u001b[24m\u001b[39m") | ||
{content: [{blank: ''}]}, | ||
[ | ||
{ | ||
blank: ['content', 0], | ||
value: 'NewCo, Inc.' | ||
} | ||
], | ||
{numbering: decimal}), | ||
' \u001b[31m\u001b[4m[NewCo, Inc.]\u001b[24m\u001b[39m' | ||
) | ||
``` |
40
run.js
/* Copyright Kyle E. Mitchell | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you | ||
* may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at | ||
* | ||
@@ -10,25 +10,25 @@ * http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
var chalk = require('chalk'); | ||
var chalk = require('chalk') | ||
module.exports = function run(element, numberStyle, conspicuous) { | ||
module.exports = function run (element, numberStyle, conspicuous) { | ||
if (typeof element === 'string') { | ||
return conspicuous ? chalk.magenta(element) : element; | ||
return conspicuous ? chalk.magenta(element) : element | ||
} else if (element.hasOwnProperty('definition')) { | ||
return '"' + chalk.green(element.definition) + '"'; | ||
return '"' + chalk.green(element.definition) + '"' | ||
} else if (element.hasOwnProperty('use')) { | ||
return chalk.magenta(element.use); | ||
return chalk.magenta(element.use) | ||
} else if (element.hasOwnProperty('blank')) { | ||
if (element.blank === undefined) { | ||
return chalk.red.underline('[_]'); | ||
return chalk.red.underline('[_]') | ||
} else { | ||
return chalk.red.underline('[' + element.blank + ']'); | ||
return chalk.red.underline('[' + element.blank + ']') | ||
} | ||
} else if (element.hasOwnProperty('heading')) { | ||
var numbering = element.numbering; | ||
var heading = element.heading; | ||
var numbering = element.numbering | ||
var heading = element.heading | ||
if ( | ||
@@ -38,3 +38,3 @@ element.hasOwnProperty('broken') || | ||
) { | ||
return chalk.yellow(heading); | ||
return chalk.yellow(heading) | ||
} else { | ||
@@ -44,7 +44,7 @@ return chalk.cyan( | ||
' (' + heading + ')' | ||
); | ||
) | ||
} | ||
} else { | ||
throw new Error('Invalid type: ' + JSON.stringify(element)); | ||
throw new Error('Invalid type: ' + JSON.stringify(element)) | ||
} | ||
}; | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
8248
2
7
123
0
67
5
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removeddecimal-numbering@^1.1.0
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removeddecimal-numbering@1.2.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedlower-alpha@1.0.0(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
Updatedchalk@^2.1.0
Updatedcommonform-flatten@^0.8.1