New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

docx-templates

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docx-templates - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

_config.yml

25

CHANGELOG.md

@@ -5,8 +5,29 @@ # Changelog

## 2.0.0 (Jan. 6, 2017)
* **Breaking changes:**
* `SHORTHAND` has been renamed `ALIAS`
* Alias resolution syntax has changed: `+++[name]+++` is no longer supported; use `+++*name+++` instead (for coherence with other commands)
* **Non-breaking:**
* [M] Add support for **JS code** in `INS`, `VAR` and `FOR`
* [M] Add `EXEC` command (no output)
* [M] Add shorthand notation: `=` for `INS`, `!` for `EXEC`, `*` shorthand for alias resolution
* [M] Improve robustness:
- Much more robust internal algorithm
- Now allows command delimiters to be split across multiple `w:t` elements+
- Better handling of spaces in commands
- Better handling of spaces in text with interspersed commands
* [M] Process **line breaks in input strings** correctly, producing `<w:br/>` tags (can be disabled)
* [M] Allow insertion of **literal XML** (with configurable delimiter, `||` by default)
* [m] Allow customisation of the command delimiter
* [M] Allow **loops in a single paragraph**
* [m] Remove archive.bulk() deprecation warning
* [M] Internal: improve code structure
## 1.0.1, 1.0.2 (Dec. 15, 2016)
* Add docs.
* [M] Add docs
## 1.0.0 (Dec. 15, 2016)
* First public release.
* [M] First public release

29

flow-typed/npm/archiver_vx.x.x.js

@@ -1,3 +0,3 @@

// flow-typed signature: 8324a4e9ad65d119a29d3e62d6c64b18
// flow-typed version: <<STUB>>/archiver_v0.14.4/flow_v0.36.0
// flow-typed signature: 63cc2b7ff222a48d76817239d64f33ec
// flow-typed version: <<STUB>>/archiver_v1.3.0/flow_v0.37.0

@@ -25,6 +25,2 @@ /**

*/
declare module 'archiver/lib/archiver' {
declare module.exports: any;
}
declare module 'archiver/lib/core' {

@@ -46,14 +42,9 @@ declare module.exports: any;

declare module 'archiver/lib/util/file' {
declare module.exports: any;
// Filename aliases
declare module 'archiver/index' {
declare module.exports: $Exports<'archiver'>;
}
declare module 'archiver/lib/util/index' {
declare module.exports: any;
declare module 'archiver/index.js' {
declare module.exports: $Exports<'archiver'>;
}
// Filename aliases
declare module 'archiver/lib/archiver.js' {
declare module.exports: $Exports<'archiver/lib/archiver'>;
}
declare module 'archiver/lib/core.js' {

@@ -71,7 +62,1 @@ declare module.exports: $Exports<'archiver/lib/core'>;

}
declare module 'archiver/lib/util/file.js' {
declare module.exports: $Exports<'archiver/lib/util/file'>;
}
declare module 'archiver/lib/util/index.js' {
declare module.exports: $Exports<'archiver/lib/util/index'>;
}

@@ -1,3 +0,3 @@

// flow-typed signature: f85210a707dde9c9a7a71970d9e6b389
// flow-typed version: <<STUB>>/babel-cli_v6.16.0/flow_v0.36.0
// flow-typed signature: b828deaf5169de1742228d568a335f4e
// flow-typed version: <<STUB>>/babel-cli_v6.18.0/flow_v0.37.0

@@ -45,26 +45,2 @@ /**

declare module 'babel-cli/lib/babel-doctor/index' {
declare module.exports: any;
}
declare module 'babel-cli/lib/babel-doctor/rules/deduped' {
declare module.exports: any;
}
declare module 'babel-cli/lib/babel-doctor/rules/has-config' {
declare module.exports: any;
}
declare module 'babel-cli/lib/babel-doctor/rules/index' {
declare module.exports: any;
}
declare module 'babel-cli/lib/babel-doctor/rules/latest-packages' {
declare module.exports: any;
}
declare module 'babel-cli/lib/babel-doctor/rules/npm-3' {
declare module.exports: any;
}
declare module 'babel-cli/lib/babel-external-helpers' {

@@ -116,20 +92,2 @@ declare module.exports: any;

}
declare module 'babel-cli/lib/babel-doctor/index.js' {
declare module.exports: $Exports<'babel-cli/lib/babel-doctor/index'>;
}
declare module 'babel-cli/lib/babel-doctor/rules/deduped.js' {
declare module.exports: $Exports<'babel-cli/lib/babel-doctor/rules/deduped'>;
}
declare module 'babel-cli/lib/babel-doctor/rules/has-config.js' {
declare module.exports: $Exports<'babel-cli/lib/babel-doctor/rules/has-config'>;
}
declare module 'babel-cli/lib/babel-doctor/rules/index.js' {
declare module.exports: $Exports<'babel-cli/lib/babel-doctor/rules/index'>;
}
declare module 'babel-cli/lib/babel-doctor/rules/latest-packages.js' {
declare module.exports: $Exports<'babel-cli/lib/babel-doctor/rules/latest-packages'>;
}
declare module 'babel-cli/lib/babel-doctor/rules/npm-3.js' {
declare module.exports: $Exports<'babel-cli/lib/babel-doctor/rules/npm-3'>;
}
declare module 'babel-cli/lib/babel-external-helpers.js' {

@@ -136,0 +94,0 @@ declare module.exports: $Exports<'babel-cli/lib/babel-external-helpers'>;

@@ -1,3 +0,3 @@

// flow-typed signature: f9b53dd8176c8f402f30857a737834b4
// flow-typed version: <<STUB>>/babel-core_v6.17.0/flow_v0.36.0
// flow-typed signature: 6a0c2869392ef46bf46d9144307132fa
// flow-typed version: <<STUB>>/babel-core_v6.20.0/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 502f839c7fb5fd0bdc6ab4233fbe6b48
// flow-typed version: <<STUB>>/babel-eslint_v7.0.0/flow_v0.36.0
// flow-typed signature: 9ce3903df979f2d1e7d3a2f8ba5a1af5
// flow-typed version: <<STUB>>/babel-eslint_v7.1.1/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 4a44f1cbe4601dc1e8bad0cddc57cfd6
// flow-typed version: <<STUB>>/babel-jest_v17.0.2/flow_v0.36.0
// flow-typed signature: a64a20ddbccd052f3ab98ce368b182fb
// flow-typed version: <<STUB>>/babel-jest_v18.0.0/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 6a6611150e110d3199a238c97545f238
// flow-typed version: <<STUB>>/babel-preset-es2015_v6.16.0/flow_v0.36.0
// flow-typed signature: 456a5ac798dfdafe120ff2cbdac40e95
// flow-typed version: <<STUB>>/babel-preset-es2015_v6.18.0/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: a046144bbe2cc616f98131dfb0500cb7
// flow-typed version: <<STUB>>/babel-preset-react_v6.16.0/flow_v0.36.0
// flow-typed signature: 129ab7b0aff9a537890f98e9d103819b
// flow-typed version: <<STUB>>/babel-preset-react_v6.16.0/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 5b1c699dfd0fceafad51726836c55ce1
// flow-typed version: <<STUB>>/babel-preset-stage-0_v6.16.0/flow_v0.36.0
// flow-typed signature: d841bec1b349cceeac309688c389a375
// flow-typed version: <<STUB>>/babel-preset-stage-0_v6.16.0/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 46d403b9170ce14f3d506c25fec10490
// flow-typed version: <<STUB>>/coveralls_v2.11.15/flow_v0.36.0
// flow-typed signature: c38ab00a478936c5743086f00711a255
// flow-typed version: <<STUB>>/coveralls_v2.11.15/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 306bdb6c05049d1e7c7aa28928bf6c06
// flow-typed version: <<STUB>>/cross-env_v^1.0.8/flow_v0.36.0
// flow-typed signature: 34080fd334d188df8eb337787812d367
// flow-typed version: <<STUB>>/cross-env_v3.1.3/flow_v0.37.0

@@ -29,2 +29,6 @@ /**

declare module 'cross-env/dist/command' {
declare module.exports: any;
}
declare module 'cross-env/dist/index' {

@@ -34,2 +38,10 @@ declare module.exports: any;

declare module 'cross-env/src/command' {
declare module.exports: any;
}
declare module 'cross-env/src/command.test' {
declare module.exports: any;
}
declare module 'cross-env/src/index' {

@@ -47,5 +59,14 @@ declare module.exports: any;

}
declare module 'cross-env/dist/command.js' {
declare module.exports: $Exports<'cross-env/dist/command'>;
}
declare module 'cross-env/dist/index.js' {
declare module.exports: $Exports<'cross-env/dist/index'>;
}
declare module 'cross-env/src/command.js' {
declare module.exports: $Exports<'cross-env/src/command'>;
}
declare module 'cross-env/src/command.test.js' {
declare module.exports: $Exports<'cross-env/src/command.test'>;
}
declare module 'cross-env/src/index.js' {

@@ -52,0 +73,0 @@ declare module.exports: $Exports<'cross-env/src/index'>;

@@ -1,3 +0,3 @@

// flow-typed signature: 012c474275ce9147df312026c4a18b1f
// flow-typed version: <<STUB>>/eslint-config-airbnb_v12.0.0/flow_v0.36.0
// flow-typed signature: b62b9d723dcd0d91f4b7c02482155c98
// flow-typed version: <<STUB>>/eslint-config-airbnb_v13.0.0/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 276f11f8829a3fb213d4f89a274a8ada
// flow-typed version: <<STUB>>/eslint-plugin-flowtype_v2.20.0/flow_v0.36.0
// flow-typed signature: 0364eebae8a639c16426d07454cb404a
// flow-typed version: <<STUB>>/eslint-plugin-flowtype_v2.29.1/flow_v0.37.0

@@ -53,2 +53,6 @@ /**

declare module 'eslint-plugin-flowtype/dist/rules/noPrimitiveConstructorTypes' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/noWeakTypes' {

@@ -58,2 +62,6 @@ declare module.exports: any;

declare module 'eslint-plugin-flowtype/dist/rules/objectTypeDelimiter' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/requireParameterType' {

@@ -71,2 +79,6 @@ declare module.exports: any;

declare module 'eslint-plugin-flowtype/dist/rules/requireVariableType' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/semi' {

@@ -92,2 +104,34 @@ declare module.exports: any;

declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateFunctions' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeIndexer' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeProperty' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateReturnType' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypeCastExpression' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypical' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/index' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/reporter' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeIdMatch' {

@@ -109,2 +153,10 @@ declare module.exports: any;

declare module 'eslint-plugin-flowtype/dist/utilities/checkFlowFileAnnotation' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/utilities/fuzzyStringMatch' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/utilities/getParameterName' {

@@ -114,2 +166,10 @@ declare module.exports: any;

declare module 'eslint-plugin-flowtype/dist/utilities/getTokenAfterParens' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/utilities/getTokenBeforeParens' {
declare module.exports: any;
}
declare module 'eslint-plugin-flowtype/dist/utilities/index' {

@@ -161,5 +221,11 @@ declare module.exports: any;

}
declare module 'eslint-plugin-flowtype/dist/rules/noPrimitiveConstructorTypes.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noPrimitiveConstructorTypes'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/noWeakTypes.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noWeakTypes'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/objectTypeDelimiter.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/objectTypeDelimiter'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/requireParameterType.js' {

@@ -174,2 +240,5 @@ declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireParameterType'>;

}
declare module 'eslint-plugin-flowtype/dist/rules/requireVariableType.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireVariableType'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/semi.js' {

@@ -190,2 +259,26 @@ declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/semi'>;

}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateFunctions.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateFunctions'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeIndexer.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeIndexer'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeProperty.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeProperty'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateReturnType.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateReturnType'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypeCastExpression.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypeCastExpression'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypical.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypical'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/index.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/index'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/reporter.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/reporter'>;
}
declare module 'eslint-plugin-flowtype/dist/rules/typeIdMatch.js' {

@@ -203,5 +296,17 @@ declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeIdMatch'>;

}
declare module 'eslint-plugin-flowtype/dist/utilities/checkFlowFileAnnotation.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/checkFlowFileAnnotation'>;
}
declare module 'eslint-plugin-flowtype/dist/utilities/fuzzyStringMatch.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/fuzzyStringMatch'>;
}
declare module 'eslint-plugin-flowtype/dist/utilities/getParameterName.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/getParameterName'>;
}
declare module 'eslint-plugin-flowtype/dist/utilities/getTokenAfterParens.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/getTokenAfterParens'>;
}
declare module 'eslint-plugin-flowtype/dist/utilities/getTokenBeforeParens.js' {
declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/getTokenBeforeParens'>;
}
declare module 'eslint-plugin-flowtype/dist/utilities/index.js' {

@@ -208,0 +313,0 @@ declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/index'>;

@@ -1,3 +0,3 @@

// flow-typed signature: fb64a0fc2d9b7898099ef51ab375ef17
// flow-typed version: <<STUB>>/eslint-plugin-import_v1.16.0/flow_v0.36.0
// flow-typed signature: 7dd069c645d2c35bea49e658e14c255e
// flow-typed version: <<STUB>>/eslint-plugin-import_v2.2.0/flow_v0.37.0

@@ -41,26 +41,14 @@ /**

declare module 'eslint-plugin-import/config/stage-0' {
declare module 'eslint-plugin-import/config/recommended' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/config/warnings' {
declare module 'eslint-plugin-import/config/stage-0' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/core/declaredScope' {
declare module 'eslint-plugin-import/config/warnings' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/core/getExports' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/core/hash' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/core/ignore' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/core/importType' {

@@ -70,18 +58,10 @@ declare module.exports: any;

declare module 'eslint-plugin-import/lib/core/module-require' {
declare module 'eslint-plugin-import/lib/core/staticRequire' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/core/parse' {
declare module 'eslint-plugin-import/lib/ExportMap' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/core/resolve' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/core/staticRequire' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/importDeclaration' {

@@ -107,2 +87,6 @@ declare module.exports: any;

declare module 'eslint-plugin-import/lib/rules/first' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/rules/imports-first' {

@@ -172,2 +156,6 @@ declare module.exports: any;

declare module 'eslint-plugin-import/lib/rules/no-named-default' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/rules/no-namespace' {

@@ -185,2 +173,6 @@ declare module.exports: any;

declare module 'eslint-plugin-import/lib/rules/no-unassigned-import' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/rules/no-unresolved' {

@@ -190,2 +182,6 @@ declare module.exports: any;

declare module 'eslint-plugin-import/lib/rules/no-webpack-loader-syntax' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/lib/rules/order' {

@@ -199,2 +195,6 @@ declare module.exports: any;

declare module 'eslint-plugin-import/lib/rules/unambiguous' {
declare module.exports: any;
}
declare module 'eslint-plugin-import/memo-parser/index' {

@@ -217,2 +217,5 @@ declare module.exports: any;

}
declare module 'eslint-plugin-import/config/recommended.js' {
declare module.exports: $Exports<'eslint-plugin-import/config/recommended'>;
}
declare module 'eslint-plugin-import/config/stage-0.js' {

@@ -224,29 +227,11 @@ declare module.exports: $Exports<'eslint-plugin-import/config/stage-0'>;

}
declare module 'eslint-plugin-import/lib/core/declaredScope.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/core/declaredScope'>;
}
declare module 'eslint-plugin-import/lib/core/getExports.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/core/getExports'>;
}
declare module 'eslint-plugin-import/lib/core/hash.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/core/hash'>;
}
declare module 'eslint-plugin-import/lib/core/ignore.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/core/ignore'>;
}
declare module 'eslint-plugin-import/lib/core/importType.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/core/importType'>;
}
declare module 'eslint-plugin-import/lib/core/module-require.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/core/module-require'>;
}
declare module 'eslint-plugin-import/lib/core/parse.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/core/parse'>;
}
declare module 'eslint-plugin-import/lib/core/resolve.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/core/resolve'>;
}
declare module 'eslint-plugin-import/lib/core/staticRequire.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/core/staticRequire'>;
}
declare module 'eslint-plugin-import/lib/ExportMap.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/ExportMap'>;
}
declare module 'eslint-plugin-import/lib/importDeclaration.js' {

@@ -267,2 +252,5 @@ declare module.exports: $Exports<'eslint-plugin-import/lib/importDeclaration'>;

}
declare module 'eslint-plugin-import/lib/rules/first.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/rules/first'>;
}
declare module 'eslint-plugin-import/lib/rules/imports-first.js' {

@@ -316,2 +304,5 @@ declare module.exports: $Exports<'eslint-plugin-import/lib/rules/imports-first'>;

}
declare module 'eslint-plugin-import/lib/rules/no-named-default.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-named-default'>;
}
declare module 'eslint-plugin-import/lib/rules/no-namespace.js' {

@@ -326,5 +317,11 @@ declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-namespace'>;

}
declare module 'eslint-plugin-import/lib/rules/no-unassigned-import.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-unassigned-import'>;
}
declare module 'eslint-plugin-import/lib/rules/no-unresolved.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-unresolved'>;
}
declare module 'eslint-plugin-import/lib/rules/no-webpack-loader-syntax.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-webpack-loader-syntax'>;
}
declare module 'eslint-plugin-import/lib/rules/order.js' {

@@ -336,4 +333,7 @@ declare module.exports: $Exports<'eslint-plugin-import/lib/rules/order'>;

}
declare module 'eslint-plugin-import/lib/rules/unambiguous.js' {
declare module.exports: $Exports<'eslint-plugin-import/lib/rules/unambiguous'>;
}
declare module 'eslint-plugin-import/memo-parser/index.js' {
declare module.exports: $Exports<'eslint-plugin-import/memo-parser/index'>;
}

@@ -1,3 +0,3 @@

// flow-typed signature: eab6911982f6973009f080f48ce92378
// flow-typed version: <<STUB>>/eslint-plugin-jsx-a11y_v2.2.3/flow_v0.36.0
// flow-typed signature: 016aa952ccc2bb5d1b702912834f23cd
// flow-typed version: <<STUB>>/eslint-plugin-jsx-a11y_v2.2.3/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 2ee9a41783aeed5a0f82d6f109b77634
// flow-typed version: <<STUB>>/eslint-plugin-react_v6.4.1/flow_v0.36.0
// flow-typed signature: 86f752d177c541d7bbb149461deb9816
// flow-typed version: <<STUB>>/eslint-plugin-react_v6.8.0/flow_v0.37.0

@@ -117,2 +117,6 @@ /**

declare module 'eslint-plugin-react/lib/rules/jsx-tag-spacing' {
declare module.exports: any;
}
declare module 'eslint-plugin-react/lib/rules/jsx-uses-react' {

@@ -130,2 +134,6 @@ declare module.exports: any;

declare module 'eslint-plugin-react/lib/rules/no-array-index-key' {
declare module.exports: any;
}
declare module 'eslint-plugin-react/lib/rules/no-children-prop' {

@@ -215,2 +223,6 @@ declare module.exports: any;

declare module 'eslint-plugin-react/lib/rules/require-default-props' {
declare module.exports: any;
}
declare module 'eslint-plugin-react/lib/rules/require-extension' {

@@ -248,2 +260,6 @@ declare module.exports: any;

declare module 'eslint-plugin-react/lib/util/annotations' {
declare module.exports: any;
}
declare module 'eslint-plugin-react/lib/util/Components' {

@@ -253,2 +269,6 @@ declare module.exports: any;

declare module 'eslint-plugin-react/lib/util/getTokenBeforeClosingBracket' {
declare module.exports: any;
}
declare module 'eslint-plugin-react/lib/util/pragma' {

@@ -342,2 +362,5 @@ declare module.exports: any;

}
declare module 'eslint-plugin-react/lib/rules/jsx-tag-spacing.js' {
declare module.exports: $Exports<'eslint-plugin-react/lib/rules/jsx-tag-spacing'>;
}
declare module 'eslint-plugin-react/lib/rules/jsx-uses-react.js' {

@@ -352,2 +375,5 @@ declare module.exports: $Exports<'eslint-plugin-react/lib/rules/jsx-uses-react'>;

}
declare module 'eslint-plugin-react/lib/rules/no-array-index-key.js' {
declare module.exports: $Exports<'eslint-plugin-react/lib/rules/no-array-index-key'>;
}
declare module 'eslint-plugin-react/lib/rules/no-children-prop.js' {

@@ -416,2 +442,5 @@ declare module.exports: $Exports<'eslint-plugin-react/lib/rules/no-children-prop'>;

}
declare module 'eslint-plugin-react/lib/rules/require-default-props.js' {
declare module.exports: $Exports<'eslint-plugin-react/lib/rules/require-default-props'>;
}
declare module 'eslint-plugin-react/lib/rules/require-extension.js' {

@@ -441,5 +470,11 @@ declare module.exports: $Exports<'eslint-plugin-react/lib/rules/require-extension'>;

}
declare module 'eslint-plugin-react/lib/util/annotations.js' {
declare module.exports: $Exports<'eslint-plugin-react/lib/util/annotations'>;
}
declare module 'eslint-plugin-react/lib/util/Components.js' {
declare module.exports: $Exports<'eslint-plugin-react/lib/util/Components'>;
}
declare module 'eslint-plugin-react/lib/util/getTokenBeforeClosingBracket.js' {
declare module.exports: $Exports<'eslint-plugin-react/lib/util/getTokenBeforeClosingBracket'>;
}
declare module 'eslint-plugin-react/lib/util/pragma.js' {

@@ -446,0 +481,0 @@ declare module.exports: $Exports<'eslint-plugin-react/lib/util/pragma'>;

@@ -1,3 +0,3 @@

// flow-typed signature: 68ea33d7f3ca7b0975e00cefbd7eb0b6
// flow-typed version: <<STUB>>/extract-docs_v^1.2.0/flow_v0.36.0
// flow-typed signature: 68552197f03ce0f67ef84996ae1816cd
// flow-typed version: <<STUB>>/extract-docs_v^1.2.0/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 312e12d217d304b5c59e30cf4d0df4f9
// flow-typed version: <<STUB>>/flow-copy-source_v1.1.0/flow_v0.36.0
// flow-typed signature: 263e6e194eb71111f8b0c51ec711abe1
// flow-typed version: <<STUB>>/flow-copy-source_v1.1.0/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 2281cf915849eb5783ba91dce671ee86
// flow-typed version: <<STUB>>/fs-extra_v0.23.1/flow_v0.36.0
// flow-typed signature: b8a9a55a7a93237ae0af9309496f186a
// flow-typed version: <<STUB>>/fs-extra_v1.0.0/flow_v0.37.0

@@ -85,2 +85,6 @@ /**

declare module 'fs-extra/lib/json/jsonfile' {
declare module.exports: any;
}
declare module 'fs-extra/lib/json/output-json-sync' {

@@ -106,2 +110,6 @@ declare module.exports: any;

declare module 'fs-extra/lib/mkdirs/win32' {
declare module.exports: any;
}
declare module 'fs-extra/lib/move/index' {

@@ -119,10 +127,6 @@ declare module.exports: any;

declare module 'fs-extra/lib/streams/create-output-stream' {
declare module 'fs-extra/lib/remove/rimraf' {
declare module.exports: any;
}
declare module 'fs-extra/lib/streams/index' {
declare module.exports: any;
}
declare module 'fs-extra/lib/util/assign' {

@@ -136,7 +140,7 @@ declare module.exports: any;

declare module 'fs-extra/lib/walk/index' {
declare module 'fs-extra/lib/walk-sync/index' {
declare module.exports: any;
}
declare module 'fs-extra/lib/walk/walker' {
declare module 'fs-extra/lib/walk/index' {
declare module.exports: any;

@@ -191,2 +195,5 @@ }

}
declare module 'fs-extra/lib/json/jsonfile.js' {
declare module.exports: $Exports<'fs-extra/lib/json/jsonfile'>;
}
declare module 'fs-extra/lib/json/output-json-sync.js' {

@@ -207,2 +214,5 @@ declare module.exports: $Exports<'fs-extra/lib/json/output-json-sync'>;

}
declare module 'fs-extra/lib/mkdirs/win32.js' {
declare module.exports: $Exports<'fs-extra/lib/mkdirs/win32'>;
}
declare module 'fs-extra/lib/move/index.js' {

@@ -217,8 +227,5 @@ declare module.exports: $Exports<'fs-extra/lib/move/index'>;

}
declare module 'fs-extra/lib/streams/create-output-stream.js' {
declare module.exports: $Exports<'fs-extra/lib/streams/create-output-stream'>;
declare module 'fs-extra/lib/remove/rimraf.js' {
declare module.exports: $Exports<'fs-extra/lib/remove/rimraf'>;
}
declare module 'fs-extra/lib/streams/index.js' {
declare module.exports: $Exports<'fs-extra/lib/streams/index'>;
}
declare module 'fs-extra/lib/util/assign.js' {

@@ -230,7 +237,7 @@ declare module.exports: $Exports<'fs-extra/lib/util/assign'>;

}
declare module 'fs-extra/lib/walk-sync/index.js' {
declare module.exports: $Exports<'fs-extra/lib/walk-sync/index'>;
}
declare module 'fs-extra/lib/walk/index.js' {
declare module.exports: $Exports<'fs-extra/lib/walk/index'>;
}
declare module 'fs-extra/lib/walk/walker.js' {
declare module.exports: $Exports<'fs-extra/lib/walk/walker'>;
}

@@ -1,3 +0,3 @@

// flow-typed signature: 132f2bab1474fbfe8e904e426cb13e57
// flow-typed version: <<STUB>>/fstream_v1.0.7/flow_v0.36.0
// flow-typed signature: b37f9bb83160ada694d6cf102684ad48
// flow-typed version: <<STUB>>/fstream_v1.0.10/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: dcef5c5e6a8c6c5a6bce04e624f03949
// flow-typed version: <<STUB>>/jest-html_v^1.3.3/flow_v0.36.0
// flow-typed signature: 278c57f9fc274873b03497a7c3a2ec11
// flow-typed version: <<STUB>>/jest-html_v^1.3.3/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 39fe624bbe2987ffae1875c5979e93ec
// flow-typed version: <<STUB>>/nyc_v8.4.0/flow_v0.36.0
// flow-typed signature: daf37fcd83d398e343532cc43ed1041a
// flow-typed version: <<STUB>>/nyc_v10.0.0/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 96567d510b92e808869eebf1b2f7f52a
// flow-typed version: <<STUB>>/sax_v1.1.1/flow_v0.36.0
// flow-typed signature: ce2ba6495f16f3c31142c53792fa6913
// flow-typed version: <<STUB>>/sax_v1.2.1/flow_v0.37.0

@@ -25,18 +25,2 @@ /**

*/
declare module 'sax/examples/example' {
declare module.exports: any;
}
declare module 'sax/examples/get-products' {
declare module.exports: any;
}
declare module 'sax/examples/hello-world' {
declare module.exports: any;
}
declare module 'sax/examples/pretty-print' {
declare module.exports: any;
}
declare module 'sax/lib/sax' {

@@ -46,360 +30,5 @@ declare module.exports: any;

declare module 'sax/test/attribute-name' {
declare module.exports: any;
}
declare module 'sax/test/attribute-no-space' {
declare module.exports: any;
}
declare module 'sax/test/bom' {
declare module.exports: any;
}
declare module 'sax/test/buffer-overrun' {
declare module.exports: any;
}
declare module 'sax/test/case' {
declare module.exports: any;
}
declare module 'sax/test/cdata-chunked' {
declare module.exports: any;
}
declare module 'sax/test/cdata-end-split' {
declare module.exports: any;
}
declare module 'sax/test/cdata-fake-end' {
declare module.exports: any;
}
declare module 'sax/test/cdata-multiple' {
declare module.exports: any;
}
declare module 'sax/test/cdata' {
declare module.exports: any;
}
declare module 'sax/test/cyrillic' {
declare module.exports: any;
}
declare module 'sax/test/duplicate-attribute' {
declare module.exports: any;
}
declare module 'sax/test/emoji' {
declare module.exports: any;
}
declare module 'sax/test/end_empty_stream' {
declare module.exports: any;
}
declare module 'sax/test/entities' {
declare module.exports: any;
}
declare module 'sax/test/entity-mega' {
declare module.exports: any;
}
declare module 'sax/test/flush' {
declare module.exports: any;
}
declare module 'sax/test/index' {
declare module.exports: any;
}
declare module 'sax/test/issue-23' {
declare module.exports: any;
}
declare module 'sax/test/issue-30' {
declare module.exports: any;
}
declare module 'sax/test/issue-35' {
declare module.exports: any;
}
declare module 'sax/test/issue-47' {
declare module.exports: any;
}
declare module 'sax/test/issue-49' {
declare module.exports: any;
}
declare module 'sax/test/issue-84' {
declare module.exports: any;
}
declare module 'sax/test/issue-86' {
declare module.exports: any;
}
declare module 'sax/test/parser-position' {
declare module.exports: any;
}
declare module 'sax/test/script-close-better' {
declare module.exports: any;
}
declare module 'sax/test/script' {
declare module.exports: any;
}
declare module 'sax/test/self-closing-child-strict' {
declare module.exports: any;
}
declare module 'sax/test/self-closing-child' {
declare module.exports: any;
}
declare module 'sax/test/self-closing-tag' {
declare module.exports: any;
}
declare module 'sax/test/stand-alone-comment' {
declare module.exports: any;
}
declare module 'sax/test/stray-ending' {
declare module.exports: any;
}
declare module 'sax/test/trailing-attribute-no-value' {
declare module.exports: any;
}
declare module 'sax/test/trailing-non-whitespace' {
declare module.exports: any;
}
declare module 'sax/test/unclosed-root' {
declare module.exports: any;
}
declare module 'sax/test/unquoted' {
declare module.exports: any;
}
declare module 'sax/test/utf8-split' {
declare module.exports: any;
}
declare module 'sax/test/xml_entities' {
declare module.exports: any;
}
declare module 'sax/test/xmlns-as-tag-name' {
declare module.exports: any;
}
declare module 'sax/test/xmlns-issue-41' {
declare module.exports: any;
}
declare module 'sax/test/xmlns-rebinding' {
declare module.exports: any;
}
declare module 'sax/test/xmlns-strict' {
declare module.exports: any;
}
declare module 'sax/test/xmlns-unbound-element' {
declare module.exports: any;
}
declare module 'sax/test/xmlns-unbound' {
declare module.exports: any;
}
declare module 'sax/test/xmlns-xml-default-ns' {
declare module.exports: any;
}
declare module 'sax/test/xmlns-xml-default-prefix-attribute' {
declare module.exports: any;
}
declare module 'sax/test/xmlns-xml-default-prefix' {
declare module.exports: any;
}
declare module 'sax/test/xmlns-xml-default-redefine' {
declare module.exports: any;
}
// Filename aliases
declare module 'sax/examples/example.js' {
declare module.exports: $Exports<'sax/examples/example'>;
}
declare module 'sax/examples/get-products.js' {
declare module.exports: $Exports<'sax/examples/get-products'>;
}
declare module 'sax/examples/hello-world.js' {
declare module.exports: $Exports<'sax/examples/hello-world'>;
}
declare module 'sax/examples/pretty-print.js' {
declare module.exports: $Exports<'sax/examples/pretty-print'>;
}
declare module 'sax/lib/sax.js' {
declare module.exports: $Exports<'sax/lib/sax'>;
}
declare module 'sax/test/attribute-name.js' {
declare module.exports: $Exports<'sax/test/attribute-name'>;
}
declare module 'sax/test/attribute-no-space.js' {
declare module.exports: $Exports<'sax/test/attribute-no-space'>;
}
declare module 'sax/test/bom.js' {
declare module.exports: $Exports<'sax/test/bom'>;
}
declare module 'sax/test/buffer-overrun.js' {
declare module.exports: $Exports<'sax/test/buffer-overrun'>;
}
declare module 'sax/test/case.js' {
declare module.exports: $Exports<'sax/test/case'>;
}
declare module 'sax/test/cdata-chunked.js' {
declare module.exports: $Exports<'sax/test/cdata-chunked'>;
}
declare module 'sax/test/cdata-end-split.js' {
declare module.exports: $Exports<'sax/test/cdata-end-split'>;
}
declare module 'sax/test/cdata-fake-end.js' {
declare module.exports: $Exports<'sax/test/cdata-fake-end'>;
}
declare module 'sax/test/cdata-multiple.js' {
declare module.exports: $Exports<'sax/test/cdata-multiple'>;
}
declare module 'sax/test/cdata.js' {
declare module.exports: $Exports<'sax/test/cdata'>;
}
declare module 'sax/test/cyrillic.js' {
declare module.exports: $Exports<'sax/test/cyrillic'>;
}
declare module 'sax/test/duplicate-attribute.js' {
declare module.exports: $Exports<'sax/test/duplicate-attribute'>;
}
declare module 'sax/test/emoji.js' {
declare module.exports: $Exports<'sax/test/emoji'>;
}
declare module 'sax/test/end_empty_stream.js' {
declare module.exports: $Exports<'sax/test/end_empty_stream'>;
}
declare module 'sax/test/entities.js' {
declare module.exports: $Exports<'sax/test/entities'>;
}
declare module 'sax/test/entity-mega.js' {
declare module.exports: $Exports<'sax/test/entity-mega'>;
}
declare module 'sax/test/flush.js' {
declare module.exports: $Exports<'sax/test/flush'>;
}
declare module 'sax/test/index.js' {
declare module.exports: $Exports<'sax/test/index'>;
}
declare module 'sax/test/issue-23.js' {
declare module.exports: $Exports<'sax/test/issue-23'>;
}
declare module 'sax/test/issue-30.js' {
declare module.exports: $Exports<'sax/test/issue-30'>;
}
declare module 'sax/test/issue-35.js' {
declare module.exports: $Exports<'sax/test/issue-35'>;
}
declare module 'sax/test/issue-47.js' {
declare module.exports: $Exports<'sax/test/issue-47'>;
}
declare module 'sax/test/issue-49.js' {
declare module.exports: $Exports<'sax/test/issue-49'>;
}
declare module 'sax/test/issue-84.js' {
declare module.exports: $Exports<'sax/test/issue-84'>;
}
declare module 'sax/test/issue-86.js' {
declare module.exports: $Exports<'sax/test/issue-86'>;
}
declare module 'sax/test/parser-position.js' {
declare module.exports: $Exports<'sax/test/parser-position'>;
}
declare module 'sax/test/script-close-better.js' {
declare module.exports: $Exports<'sax/test/script-close-better'>;
}
declare module 'sax/test/script.js' {
declare module.exports: $Exports<'sax/test/script'>;
}
declare module 'sax/test/self-closing-child-strict.js' {
declare module.exports: $Exports<'sax/test/self-closing-child-strict'>;
}
declare module 'sax/test/self-closing-child.js' {
declare module.exports: $Exports<'sax/test/self-closing-child'>;
}
declare module 'sax/test/self-closing-tag.js' {
declare module.exports: $Exports<'sax/test/self-closing-tag'>;
}
declare module 'sax/test/stand-alone-comment.js' {
declare module.exports: $Exports<'sax/test/stand-alone-comment'>;
}
declare module 'sax/test/stray-ending.js' {
declare module.exports: $Exports<'sax/test/stray-ending'>;
}
declare module 'sax/test/trailing-attribute-no-value.js' {
declare module.exports: $Exports<'sax/test/trailing-attribute-no-value'>;
}
declare module 'sax/test/trailing-non-whitespace.js' {
declare module.exports: $Exports<'sax/test/trailing-non-whitespace'>;
}
declare module 'sax/test/unclosed-root.js' {
declare module.exports: $Exports<'sax/test/unclosed-root'>;
}
declare module 'sax/test/unquoted.js' {
declare module.exports: $Exports<'sax/test/unquoted'>;
}
declare module 'sax/test/utf8-split.js' {
declare module.exports: $Exports<'sax/test/utf8-split'>;
}
declare module 'sax/test/xml_entities.js' {
declare module.exports: $Exports<'sax/test/xml_entities'>;
}
declare module 'sax/test/xmlns-as-tag-name.js' {
declare module.exports: $Exports<'sax/test/xmlns-as-tag-name'>;
}
declare module 'sax/test/xmlns-issue-41.js' {
declare module.exports: $Exports<'sax/test/xmlns-issue-41'>;
}
declare module 'sax/test/xmlns-rebinding.js' {
declare module.exports: $Exports<'sax/test/xmlns-rebinding'>;
}
declare module 'sax/test/xmlns-strict.js' {
declare module.exports: $Exports<'sax/test/xmlns-strict'>;
}
declare module 'sax/test/xmlns-unbound-element.js' {
declare module.exports: $Exports<'sax/test/xmlns-unbound-element'>;
}
declare module 'sax/test/xmlns-unbound.js' {
declare module.exports: $Exports<'sax/test/xmlns-unbound'>;
}
declare module 'sax/test/xmlns-xml-default-ns.js' {
declare module.exports: $Exports<'sax/test/xmlns-xml-default-ns'>;
}
declare module 'sax/test/xmlns-xml-default-prefix-attribute.js' {
declare module.exports: $Exports<'sax/test/xmlns-xml-default-prefix-attribute'>;
}
declare module 'sax/test/xmlns-xml-default-prefix.js' {
declare module.exports: $Exports<'sax/test/xmlns-xml-default-prefix'>;
}
declare module 'sax/test/xmlns-xml-default-redefine.js' {
declare module.exports: $Exports<'sax/test/xmlns-xml-default-redefine'>;
}

@@ -1,3 +0,3 @@

// flow-typed signature: dea3834f1aaf82968a8baf404f38cb56
// flow-typed version: <<STUB>>/unzip_v0.1.11/flow_v0.36.0
// flow-typed signature: f0b06f5b67ea97a2883c9358b69990a8
// flow-typed version: <<STUB>>/unzip_v0.1.11/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

// flow-typed signature: 9abb2a7b6ec05ef875e44b892c27f607
// flow-typed version: <<STUB>>/xxl_v^0.1.1/flow_v0.36.0
// flow-typed signature: a491ad27c1c4567bd3a871b50a8a74b8
// flow-typed version: <<STUB>>/xxl_v^0.1.1/flow_v0.37.0

@@ -4,0 +4,0 @@ /**

@@ -8,6 +8,7 @@ 'use strict';

mainStory = _require.mainStory,
addListener = _require.addListener;
addListener = _require.addListener,
chalk = _require.chalk;
addListener(require('storyboard/lib/listeners/file').default);
addListener(require('storyboard/lib/listeners/console').default);
module.exports = mainStory;
module.exports = { mainStory: mainStory, chalk: chalk };
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var createReport = require('./main').default;
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _os = require('os');
var _os2 = _interopRequireDefault(_os);
var _timm = require('timm');
var _bluebird = require('bluebird');
var _bluebird2 = _interopRequireDefault(_bluebird);
var _fsExtra = require('fs-extra');
var _fsExtra2 = _interopRequireDefault(_fsExtra);
var _archiver = require('archiver');
var _archiver2 = _interopRequireDefault(_archiver);
var _fstream = require('fstream');
var _fstream2 = _interopRequireDefault(_fstream);
var _unzip = require('unzip');
var _unzip2 = _interopRequireDefault(_unzip);
var _sax = require('sax');
var _sax2 = _interopRequireDefault(_sax);
var _uuid = require('uuid');
var _uuid2 = _interopRequireDefault(_uuid);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-disable no-param-reassign */
var DEBUG = false;
var DEFAULT_ESCAPE_SEQUENCE = '+++';
var log = DEBUG ? require('./debug') : null;
var fsPromises = {};
['emptyDir', 'ensureDir', 'readFile', 'writeFile', 'remove'].forEach(function (fn) {
fsPromises[fn] = _bluebird2.default.promisify(_fsExtra2.default[fn]);
});
// ==========================================
// Main
// ==========================================
var getDefaultOutput = function getDefaultOutput(templatePath) {
var _path$parse = _path2.default.parse(templatePath),
dir = _path$parse.dir,
name = _path$parse.name,
ext = _path$parse.ext;
return _path2.default.join(dir, name + '_report' + ext);
};
var createReport = function createReport(options) {
DEBUG && log.debug('Report options:', { attach: options });
var template = options.template,
data = options.data,
queryVars = options.queryVars,
_probe = options._probe;
var output = options.output || getDefaultOutput(template);
DEBUG && log.debug('Output file: ' + output);
var base = _path2.default.join(_os2.default.tmpdir(), _uuid2.default.v1());
var baseUnzipped = base + '_unzipped';
DEBUG && log.debug('Temporary base: ' + base);
var jsTemplate = void 0;
var queryResult = null;
var templatePath = base + '_unzipped/word/document.xml';
var tic = void 0;
var result = void 0;
return _bluebird2.default.resolve()
// Unzip
.then(function () {
DEBUG && log.debug('Unzipping...');
return fsPromises.emptyDir(baseUnzipped).then(function () {
return unzipFile(template, baseUnzipped);
});
})
// Read the 'document.xml' file (the template) and parse it
.then(function () {
DEBUG && log.debug('Reading template...');
return fsPromises.readFile(templatePath, 'utf8').then(function (templateXml) {
DEBUG && log.debug('Template file length: ' + templateXml.length);
DEBUG && log.debug('Parsing XML...');
tic = new Date().getTime();
return parseXml(templateXml);
}).then(function (parseResult) {
jsTemplate = parseResult;
var tac = new Date().getTime();
DEBUG && log.debug('File parsed in ' + (tac - tic) + ' ms', { attach: jsTemplate, attachLevel: 'trace' });
});
})
// Fetch the data that will fill in the template
.then(function () {
if (typeof data !== 'function') {
queryResult = data;
return null;
}
DEBUG && log.debug('Looking for the query in the template...');
var query = getQuery(jsTemplate);
DEBUG && log.debug('Query: ' + (query || 'no query found'));
return _bluebird2.default.resolve(data(query, queryVars)).then(function (o) {
queryResult = o;
});
})
// Generate the report
.then(function () {
DEBUG && log.debug('Generating report...');
return _createReport(queryResult, jsTemplate);
})
// Build output XML and write it to disk
.then(function (report) {
result = report;
if (_probe) return null;
DEBUG && log.debug('Converting report to XML...');
var reportXml = buildXml(report);
DEBUG && log.debug('Writing report...');
return fsPromises.writeFile(templatePath, reportXml);
})
// Zip the results
.then(function () {
if (_probe) {
return fsPromises.remove(baseUnzipped).then(function () {
return result;
});
}
DEBUG && log.debug('Zipping...');
return fsPromises.ensureDir(_path2.default.dirname(output)).then(function () {
return zipFile(baseUnzipped, output);
}).finally(function () {
return fsPromises.remove(baseUnzipped);
});
}).catch(function (err) {
if (err instanceof TypeError || err instanceof ReferenceError || err instanceof SyntaxError) {
console.error(err); // eslint-disable-line no-console
}
throw new Error('REPORT_ERROR');
});
};
// ==========================================
// Report generation
// ==========================================
var _createReport = function _createReport(data, template) {
var out = cloneNodeWithoutChildren(template);
var ctx = {
level: 1,
fCmd: false,
cmd: '',
fSeekQuery: false,
query: null,
buffers: {
'w:p': { text: '', cmds: '', fInsertedText: false },
'w:tr': { text: '', cmds: '', fInsertedText: false }
},
vars: {},
loops: [],
root: template,
pendingCmd: null,
skipAtLevel: null,
shorthands: {}
};
var nodeIn = template;
var nodeOut = out;
// ---------------------------------------------
// Fetch a new node
// ---------------------------------------------
while (true) {
// eslint-disable-line no-constant-condition
// ---------------------------------------------
// Fetch a new node, case 1: go down...
// ---------------------------------------------
if (nodeIn._children.length) {
nodeIn = nodeIn._children[0];
ctx.level += 1;
// ---------------------------------------------
// Fetch a new node, case 2: go to the next sibling
// (at the same level or a higher one)
// ---------------------------------------------
} else {
var fFound = false;
while (nodeIn._parent != null) {
var nodeInParent = nodeIn._parent;
var nodeOutParent = nodeOut._parent;
if (hasNextSibling(nodeIn)) {
fFound = true;
nodeIn = getNextSibling(nodeIn);
break;
}
nodeIn = nodeInParent;
if (nodeOutParent == null) break; // should never happen
nodeOut = nodeOutParent;
ctx.level -= 1;
// On the way up, process commands applicable at `w:p` (paragraph) and
// `w:tr` (table row) level
var _tag2 = nodeIn._fTextNode ? null : nodeIn._tag;
var _pendingCmd = ctx.pendingCmd;
if (_pendingCmd != null) {
var cmdName = _pendingCmd.name;
if (_tag2 === 'w:p' && (cmdName === 'FOR' || cmdName === 'END-FOR') || _tag2 === 'w:tr' && (cmdName === 'FOR-ROW' || cmdName === 'END-FOR-ROW')) {
if (cmdName === 'FOR' || cmdName === 'FOR-ROW') {
var _loopOver = _pendingCmd.loopOver,
_varName = _pendingCmd.varName;
DEBUG && log.debug('Loop ' + _varName + ' iterations: ' + _loopOver.length);
if (ctx.skipAtLevel == null) {
var _getNextItem = getNextItem(_loopOver),
nextItem = _getNextItem.nextItem,
curIdx = _getNextItem.curIdx;
if (nextItem) {
ctx.loops.push({ forNode: nodeIn, varName: _varName, loopOver: _loopOver, idx: curIdx });
ctx.vars[_varName] = (0, _timm.set)(nextItem, '_idx', curIdx + 1);
} else {
ctx.skipAtLevel = ctx.level;
}
}
} else if (cmdName === 'END-FOR' || cmdName === 'END-FOR-ROW') {
if (ctx.level === ctx.skipAtLevel) {
ctx.skipAtLevel = null;
} else if (ctx.skipAtLevel == null) {
var curLoop = ctx.loops[ctx.loops.length - 1];
var _forNode = curLoop.forNode,
_varName2 = curLoop.varName,
_loopOver2 = curLoop.loopOver,
_idx = curLoop.idx;
var _getNextItem2 = getNextItem(_loopOver2, _idx),
_nextItem = _getNextItem2.nextItem,
_curIdx = _getNextItem2.curIdx;
if (_nextItem) {
// repeat loop
DEBUG && log.debug(' - Iteration on ' + _varName2 + ': ' + (_idx + 1));
curLoop.idx = _curIdx;
ctx.vars[_varName2] = (0, _timm.set)(_nextItem, '_idx', _curIdx + 1);
nodeIn = _forNode;
} else {
// loop finished
ctx.loops.pop();
}
}
}
ctx.pendingCmd = null;
}
}
// On the way up, delete corresponding output node if the user inserted a paragraph
// (or table row) with just a command, or if we're skipping nodes due to an empty FOR loop
var fRemoveNode = false;
if ((_tag2 === 'w:p' || _tag2 === 'w:tbl' || _tag2 === 'w:tr') && ctx.skipAtLevel != null && ctx.level >= ctx.skipAtLevel) {
fRemoveNode = true;
} else if (_tag2 === 'w:p' || _tag2 === 'w:tr') {
var _buffers = ctx.buffers[_tag2];
// console.log(`${tag} FULLTEXT: '${buffers.text}'`);
// console.log(`${tag} COMMANDS: '${buffers.cmds}'`);
fRemoveNode = _buffers.text === '' && _buffers.cmds !== '' && !_buffers.fInsertedText;
}
if (fRemoveNode && nodeOut._parent != null) nodeOut._parent._children.pop();
}
// Reached the parent and still no luck? We're done generating the report!
if (!fFound) break;
// In the output tree, move up one level, to correct the attachment point
// for the new node
nodeOut = nodeOut._parent;
}
// ---------------------------------------------
// Process node
// ---------------------------------------------
// Nodes are copied to the new tree, but that doesn't mean they will be kept there.
// In some cases, they will be removed later on; for example, when a paragraph only
// contained a command -- it will be deleted.
var tag = nodeIn._fTextNode ? null : nodeIn._tag;
if (tag === 'w:p' || tag === 'w:tr') {
ctx.buffers[tag] = { text: '', cmds: '', fInsertedText: false };
}
var newNode = cloneNodeWithoutChildren(nodeIn);
newNode._parent = nodeOut;
nodeOut._children.push(newNode);
if (nodeIn._fTextNode) {
var newNodeAsTextNode = newNode;
newNodeAsTextNode._text = processText(data, nodeIn, ctx);
}
nodeOut = newNode;
}
return out;
};
// Go through the document until the query string is found (normally at the beginning)
var getQuery = function getQuery(template) {
var ctx = {
fCmd: false,
cmd: '',
fSeekQuery: true, // ensure no command will be processed, except QUERY
query: null
};
var nodeIn = template;
while (true) {
// eslint-disable-line no-constant-condition
// Move down
if (nodeIn._children.length) nodeIn = nodeIn._children[0];
// Move sideways or up
else {
while (nodeIn._parent != null) {
var parent = nodeIn._parent;
if (hasNextSibling(nodeIn)) {
nodeIn = getNextSibling(nodeIn);
break;
}
nodeIn = parent;
}
}
if (!nodeIn) break;
if (nodeIn._fTextNode) processText(null, nodeIn, ctx);
if (ctx.query != null) break;
}
return ctx.query;
};
// Include isDeleted field in all GraphQL nodes
// const addIsDeleted = (query) => {
// let out = '';
// let parens = 0;
// let level = 0;
// let fQuoted = false;
// for (let i = 0; i < query.length; i++) {
// const c = query[i];
// let moreChars = c;
// if (c === '(') parens += 1;
// else if (c === ')') parens -= 1;
// else if (c === '"') fQuoted = !fQuoted;
// else if (c === '{') {
// level += 1;
// if (level >= 2 && !parens && !fQuoted) {
// moreChars = '{isDeleted, ';
// }
// } else if (c === '}') level -= 1;
// out += moreChars;
// }
// return out;
// };
var processText = function processText(data, node, ctx) {
var text = node._text;
if (text == null || text === '') return '';
var segments = text.split(DEFAULT_ESCAPE_SEQUENCE);
var outText = '';
var fAppendText = node._parent && !node._parent._fTextNode && node._parent._tag === 'w:t';
for (var _idx2 = 0; _idx2 < segments.length; _idx2++) {
// Include the separators in the `buffers` field (used for deleting paragraphs if appropriate)
if (_idx2 > 0 && fAppendText) appendText(DEFAULT_ESCAPE_SEQUENCE, ctx, { fCmd: true });
// Append segment either to the `ctx.cmd` buffer (to be executed), if we are in "command mode",
// or to the output text
var segment = segments[_idx2];
// DEBUG && log.debug(`Token: '${segment}'' (${ctx.fCmd})`);
if (ctx.fCmd) ctx.cmd += segment;else outText += segment;
if (fAppendText) appendText(segment, ctx, { fCmd: ctx.fCmd });
// If there are more segments, execute the command (if we are in "command mode"),
// and toggle "command mode"
if (_idx2 < segments.length - 1) {
if (ctx.fCmd) {
var cmdResultText = processCmd(data, ctx);
if (cmdResultText != null) {
outText += cmdResultText;
if (fAppendText) appendText(cmdResultText, ctx, { fCmd: false, fInsertedText: true });
}
}
ctx.fCmd = !ctx.fCmd;
}
}
return outText;
};
var processCmd = function processCmd(data, ctx) {
var cmd = ctx.cmd.trim();
ctx.cmd = '';
DEBUG && log.debug('Executing: ' + cmd);
// Expand shorthands
var shorthandMatch = /^\[(.+)\]$/.exec(cmd);
if (shorthandMatch != null) {
var shorthandName = shorthandMatch[1];
cmd = ctx.shorthands[shorthandName];
DEBUG && log.debug('Shorthand for: ' + cmd);
}
// Sanitize, tokenize and extract command name
cmd = cmd.replace(/\s+/g, ' ');
var tokens = cmd.split(' ');
if (!tokens.length) throw new Error('Invalid command syntax');
var cmdName = tokens[0].toUpperCase();
// Seeking query?
if (ctx.fSeekQuery) {
if (cmdName === 'QUERY') ctx.query = tokens.slice(1).join(' ');
return null;
}
// Process command
var out = void 0;
if (cmdName === 'QUERY') {
DEBUG && log.debug('Ignoring QUERY command');
} else if (cmdName === 'SHORTHAND') {
var _shorthandName = tokens[1];
var fullCmd = tokens.slice(2).join(' ');
ctx.shorthands[_shorthandName] = fullCmd;
DEBUG && log.debug('Defined shorthand \'' + _shorthandName + '\' as: ' + fullCmd);
} else if (cmdName === 'VAR') {
// VAR <varName> <dataPath>
var _varName3 = tokens[1];
var varPath = tokens[2];
var varValue = extractFromData(data, varPath, ctx);
ctx.vars[_varName3] = varValue;
// DEBUG && log.debug(`${varName} is now: ${JSON.stringify(varValue)}`);
} else if (cmdName === 'FOR' || cmdName === 'FOR-ROW') {
// FOR <varName> IN <collectionDataPath>
ctx.pendingCmd = {
name: cmdName,
varName: tokens[1],
loopOver: extractFromData(data, tokens[3], ctx)
};
} else if (cmdName === 'END-FOR' || cmdName === 'END-FOR-ROW') {
// END-FOR
ctx.pendingCmd = { name: cmdName };
} else if (cmdName === 'INS') {
// INS <scalarDataPath>
if (ctx.skipAtLevel == null) out = extractFromData(data, tokens[1], ctx);
} else throw new Error('Invalid command syntax: \'' + cmd + '\'');
return out;
};
var appendText = function appendText(text, ctx, options) {
if (ctx.fSeekQuery) return;
var fCmd = options.fCmd,
fInsertedText = options.fInsertedText;
var type = fCmd ? 'cmds' : 'text';
Object.keys(ctx.buffers).forEach(function (key) {
var buf = ctx.buffers[key];
buf[type] += text;
if (fInsertedText) buf.fInsertedText = true;
});
};
var extractFromData = function extractFromData(data, dataPath, ctx) {
if (data == null) return '';
var parts = dataPath.split('.');
var out = void 0;
if (parts[0][0] === '$') {
var _varName4 = parts[0].substring(1);
out = ctx.vars[_varName4];
parts.shift();
} else {
out = data;
}
if (out == null) return '';
for (var i = 0; i < parts.length; i++) {
out = out[parts[i]];
if (out == null) return '';
}
return out;
};
var getNextItem = function getNextItem(items, curIdx0) {
var nextItem = null;
var curIdx = curIdx0 != null ? curIdx0 : -1;
while (nextItem == null) {
curIdx += 1;
if (curIdx >= items.length) break;
if (items[curIdx].isDeleted) continue; // TODO: allow user skipping
nextItem = items[curIdx];
}
return { nextItem: nextItem, curIdx: curIdx };
};
// ==========================================
// Utilities: XML <-> JSON conversion
// ==========================================
var parseXml = function parseXml(templateXml) {
var parser = _sax2.default.parser(true, { // true for XML-like (false for HTML-like)
trim: false,
normalize: false
});
var template = null;
var curNode = null;
var numXmlElements = 0;
return new _bluebird2.default(function (resolve, reject) {
parser.onopentag = function (node) {
var newNode = {
_parent: curNode,
_children: [],
_idxChild: curNode != null ? curNode._children.length : undefined,
_fTextNode: false,
_tag: node.name,
_attrs: node.attributes
};
if (curNode != null) curNode._children.push(newNode);else template = newNode;
curNode = newNode;
numXmlElements += 1;
};
parser.onclosetag = function () {
curNode = curNode != null ? curNode._parent : null;
};
parser.ontext = function (text) {
if (curNode == null) return;
curNode._children.push({
_parent: curNode,
_children: [],
_idxChild: curNode._children.length,
_fTextNode: true,
_text: text
});
};
parser.onend = function () {
DEBUG && log.debug('Number of XML elements: ' + numXmlElements);
resolve(template);
};
parser.onerror = function (err) {
reject(err);
};
parser.write(templateXml);
parser.end();
});
};
var buildXml = function buildXml(node) {
var indent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var xml = indent.length ? '' : '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
if (node._fTextNode) xml += sanitizeText(node._text);else {
(function () {
var attrs = '';
var nodeAttrs = node._attrs;
Object.keys(nodeAttrs).forEach(function (key) {
attrs += ' ' + key + '="' + nodeAttrs[key] + '"';
});
var fHasChildren = node._children.length > 0;
var suffix = fHasChildren ? '' : '/';
xml += '\n' + indent + '<' + node._tag + attrs + suffix + '>';
var fLastChildIsNode = false;
node._children.forEach(function (child) {
xml += buildXml(child, indent + ' ');
fLastChildIsNode = !child._fTextNode;
});
if (fHasChildren) {
var indent2 = fLastChildIsNode ? '\n' + indent : '';
xml += indent2 + '</' + node._tag + '>';
}
})();
}
return xml;
};
var sanitizeText = function sanitizeText(str) {
var out = str;
out = out.replace(/&/g, '&amp;'); // must be the first one
out = out.replace(/</g, '&lt;');
out = out.replace(/>/g, '&gt;');
return out;
};
// ==========================================
// Utilities: miscellaneous
// ==========================================
var cloneNodeWithoutChildren = function cloneNodeWithoutChildren(node) {
if (node._fTextNode) {
return {
_parent: null,
_children: [],
_fTextNode: true,
_text: node._text
};
}
return {
_parent: null,
_children: [],
_fTextNode: false,
_tag: node._tag,
_attrs: node._attrs
};
};
var hasNextSibling = function hasNextSibling(node) {
return node._parent != null && node._idxChild != null ? node._idxChild < node._parent._children.length - 1 : false;
};
// Always call `hasNextSibling()` before calling `getNextSibling()`
var getNextSibling = function getNextSibling(node
// $FlowFixMe
) {
return node._parent._children[node._idxChild + 1];
};
// ==========================================
// Utilities: zip/unzip
// ==========================================
var unzipFile = function unzipFile(inputFile, outputFolder) {
var readStream = _fsExtra2.default.createReadStream(inputFile);
var writeStream = _fstream2.default.Writer(outputFolder); // eslint-disable-line new-cap
return new _bluebird2.default(function (resolve) {
readStream.pipe(_unzip2.default.Parse()) // eslint-disable-line new-cap
.pipe(writeStream).on('close', resolve);
});
};
var zipFile = function zipFile(inputFolder, outputFile) {
var output = _fsExtra2.default.createWriteStream(outputFile);
var archive = (0, _archiver2.default)('zip');
return new _bluebird2.default(function (resolve, reject) {
output.on('close', resolve);
archive.on('error', reject);
archive.pipe(output);
archive.bulk([{ expand: true, dot: true, cwd: inputFolder, src: '**' }]);
archive.finalize();
});
};
// ==========================================
// Public API
// ==========================================
exports.default = createReport;
module.exports = createReport;
module.exports.default = createReport;
{
"name": "docx-templates",
"version": "1.0.2",
"version": "2.0.0",
"description": "Template-based docx report creation",

@@ -46,7 +46,7 @@ "main": "lib/index.js",

"dependencies": {
"archiver": "0.14.4",
"bluebird": "2.9.8",
"fs-extra": "0.23.1",
"fstream": "1.0.7",
"sax": "1.1.1",
"archiver": "1.3.0",
"bluebird": "3.4.6",
"fs-extra": "1.0.0",
"fstream": "1.0.10",
"sax": "1.2.1",
"timm": "1.2.3",

@@ -57,24 +57,24 @@ "unzip": "0.1.11",

"devDependencies": {
"babel-cli": "6.16.0",
"babel-core": "6.17.0",
"babel-eslint": "7.0.0",
"babel-jest": "17.0.2",
"babel-polyfill": "6.16.0",
"babel-preset-es2015": "6.16.0",
"babel-cli": "6.18.0",
"babel-core": "6.20.0",
"babel-eslint": "7.1.1",
"babel-jest": "18.0.0",
"babel-preset-es2015": "6.18.0",
"babel-preset-react": "6.16.0",
"babel-preset-stage-0": "6.16.0",
"coveralls": "2.11.15",
"cross-env": "^1.0.8",
"eslint": "3.8.1",
"eslint-config-airbnb": "12.0.0",
"eslint-plugin-flowtype": "2.20.0",
"eslint-plugin-import": "1.16.0",
"cross-env": "3.1.3",
"eslint": "3.12.2",
"eslint-config-airbnb": "13.0.0",
"eslint-plugin-flowtype": "2.29.1",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "2.2.3",
"eslint-plugin-react": "6.4.1",
"eslint-plugin-react": "6.8.0",
"extract-docs": "^1.2.0",
"flow-bin": "0.36.0",
"flow-bin": "0.37.0",
"flow-copy-source": "1.1.0",
"jest": "17.0.3",
"isomorphic-fetch": "2.2.1",
"jest": "18.0.0",
"jest-html": "^1.3.3",
"nyc": "8.4.0",
"nyc": "10.0.0",
"storyboard": "^2.3.1",

@@ -85,6 +85,2 @@ "xxl": "^0.1.1"

"testRegex": "src/.*__tests__/.*\\.(test|spec)\\.(js|jsx)$",
"moduleNameMapper": {
"^.+\\.(css|less|sass)$": "<rootDir>/test/emptyObject.js",
"^.+\\.(gif|ttf|eot|svg)$": "<rootDir>/test/emptyString.js"
},
"coverageDirectory": ".nyc_output",

@@ -101,11 +97,9 @@ "coverageReporters": [

"src/**/*.js",
"src/vendor/**",
"!src/debug.js",
"!test/**",
"!**/webpack*",
"!**/node_modules/**",
"!**/__tests__/**",
"!**/__mocks__/**"
],
"setupTestFrameworkScriptFile": "./test/setup.js"
]
}
}

@@ -7,9 +7,12 @@ # Docx-templates [![Build Status](https://travis-ci.org/guigrpa/docx-templates.svg)](https://travis-ci.org/guigrpa/docx-templates) [![Coverage Status](https://coveralls.io/repos/github/guigrpa/docx-templates/badge.svg?branch=master)](https://coveralls.io/github/guigrpa/docx-templates?branch=master) [![npm version](https://img.shields.io/npm/v/docx-templates.svg)](https://www.npmjs.com/package/docx-templates)

* **Write reports naturally using Word**, just adding commands where needed for dynamic contents
* **Embed your queries in the template itself**, e.g. in GraphQL, following *the Relay way* (in [Relay](https://facebook.github.io/relay/), you declare your data needs alongside the React components that use them)
* A small **custom language**, with commands such as `FOR` (+ `END-FOR`), `FOR-ROW` (+ `END-FOR-ROW`), `INS`, `SHORTHAND`, `QUERY`
* **Nested** loops
* Custom **variables** and **shorthand** commands (useful for writing table templates)
* **Write documents naturally using Word**, just adding some commands where needed for dynamic contents
* **Express your data needs (queries) in the template itself** (`QUERY` command), in whatever query language you want (e.g. in GraphQL). This is similar to *the Relay way™*: in [Relay](https://facebook.github.io/relay/), data requirements are declared alongside the React components that need the data
* **Execute JavaScript snippets** (`EXEC`, or `!` for short)
* **Insert the result of JavaScript snippets** in your document (`INS`, or `=` for short)
* Add **loops** with `FOR`/`END-FOR` commands, with support for table rows, nested loops, and JavaScript processing of elements (filter, sort, etc)
* Define custom **aliases** for some commands (`ALIAS`) — useful for writing table templates!
* Run all JavaScript in a **separate Node VM for security**
* Include **literal XML**
Docx-templates will probably not support all use cases, so **use with caution**. If you need more extensibility, a more mature project, and more bells and whistles please also check out [docxtemplater](https://github.com/open-xml-templating/docxtemplater).
Contributions are welcome!

@@ -32,3 +35,3 @@ ## Installation

Here is a contrived example, injecting data directly as an object:
Here is a (contrived) example, with report data injected directly as an object:

@@ -48,3 +51,3 @@ ```js

This will create a report at the specified location (*all paths are relative to `process.cwd()`*) using the injected data. Some notes:
This will create a report based on the input data at the specified path. Some notes:

@@ -54,3 +57,3 @@ * All paths are relative to `process.cwd()`

You can also **provide a (sync or async) query resolver** instead of an object `data`. See this example:
You can also **provide a sync or Promise-returning callback function (query resolver)** instead of an object `data`:

@@ -67,10 +70,27 @@ ```js

Other options (with defaults):
```js
createReport({
// ...
cmdDelimiter: '+++',
literalXmlDelimiter: '||',
processLineBreaks: true,
});
```
### Writing templates
You can find many examples under https://github.com/guigrpa/docx-templates/tree/master/src/__tests__/templates, many of which are used for tests. Here are a few examples and notes on command syntax:
You can find several template examples in this repo:
#### QUERY
* [SWAPI](https://github.com/guigrpa/docx-templates/tree/master/examples/swapi), a good example of what you can achieve embedding a template (GraphQL in this case) in your report, including a simple script for report generation. Uses the freak-ish online [Star Wars GraphQL API](https://github.com/graphql/swapi-graphql)
* [Several templates](https://github.com/guigrpa/docx-templates/tree/master/examples/sampleTemplates)
* [More specific templates, used for tests]( https://github.com/guigrpa/docx-templates/tree/master/src/__tests__/fixtures)
You can use GraphQL, SQL, whatever you like. As explained above, the query will be passed to your `data` query resolver.
Here is the list of currently supported commands:
#### `QUERY`
You can use GraphQL, SQL, whatever you want: the query will be passed unchanged to your `data` query resolver.
```

@@ -88,3 +108,3 @@ +++QUERY

For the following sections, we assume that our dataset is something like this:
For the following sections (except where noted), we assume the following dataset:

@@ -97,4 +117,4 @@ ```js

people: [
{ name: 'John', since: '2015' },
{ name: 'Robert', since: '2010' },
{ name: 'John', since: 2015 },
{ name: 'Robert', since: 2010 },
]

@@ -105,23 +125,39 @@ },

#### VAR
#### `INS` (`=`)
Declare a custom variable (or an *alias*) for a given datapath:
Inserts the result of a given (JavaScript) snippet:
```
+++VAR details project.details+++
+++INS project.name+++ (+++INS project.details.year+++)
or...
+++INS `${project.name} (${$details.year})`+++
```
#### INS
Note that the last evaluated expression is inserted into the document, so you can include more complex code if you wish:
Insert the value at a given datapath (the second example uses a previously declared variable):
```
+++INS
const a = Math.random();
const b = Math.round((a - 0.5) * 20);
`A number between -10 and 10: ${b}.`
+++
```
You can also use this shorthand notation:
```
+++INS project.name+++ (+++INS project.details.year+++)
+++INS project.name+++ (+++INS $details.year+++)
+++= project.name+++ (+++= project.details.year+++)
+++= `${project.name} (${$details.year})`+++
```
#### FOR (FOR-ROW) and END-FOR (END-FOR-ROW)
Use JavaScript's ternary operator to implement an *if-else* structure:
Loop over a group of elements:
```
+++= $details.year != null ? `(${$details.year})` : ''+++
```
#### `FOR` and `END-FOR`
Loop over a group of elements (resulting from the evaluation of a JavaScript expression):
```

@@ -133,9 +169,16 @@ +++FOR person IN project.people+++

Similarly, for table rows:
Since JavaScript expressions are supported, you can for example filter the loop domain:
```
+++FOR person IN project.people.filter(person => person.since > 2013)+++
...
```
`FOR` loops also work over table rows:
```
----------------------------------------------------------
| Name | Since |
----------------------------------------------------------
| +++FOR-ROW person IN | |
| +++FOR person IN | |
| project.people+++ | |

@@ -145,7 +188,7 @@ ----------------------------------------------------------

----------------------------------------------------------
| +++END-FOR-ROW person+++ | |
| +++END-FOR person+++ | |
----------------------------------------------------------
```
You can nest loops (example uses a different data set):
Finally, you can nest loops (this example assumes a different data set):

@@ -165,9 +208,9 @@ ```

#### SHORTHAND
#### `ALIAS` (and alias resolution with `*`)
Define an alias for a complete command (especially useful for formatting tables):
Define a name for a complete command (especially useful for formatting tables):
```
+++SHORTHAND name INS $person.name+++
+++SHORTHAND since INS $person.since+++
+++ALIAS name INS $person.name+++
+++ALIAS since INS $person.since+++

@@ -177,8 +220,8 @@ ----------------------------------------------------------

----------------------------------------------------------
| +++FOR-ROW person IN | |
| +++FOR person IN | |
| project.people+++ | |
----------------------------------------------------------
| +++[name]+++ | +++[since]+++ |
| +++*name+++ | +++*since+++ |
----------------------------------------------------------
| +++END-FOR-ROW person+++ | |
| +++END-FOR person+++ | |
----------------------------------------------------------

@@ -192,5 +235,5 @@ ```

* [docxtemplater](https://github.com/open-xml-templating/docxtemplater) (just discovered it after brushing up my old CS code for `docx-templates`, publishing it for the first time and bumping into this very similarly named project).
* [docxtemplater](https://github.com/open-xml-templating/docxtemplater) (believe it or not, I just discovered this very similarly-named project after brushing up my old CS code for `docx-templates` and publishing it for the first time!). It provides lots of goodies, but doesn't allow (AFAIK) embedding queries or JS snippets.
* [docx](https://github.com/dolanmiu/docx) and similar ones - generate docx files from scratch, programmatically.
* [docx](https://github.com/dolanmiu/docx) and similar ones - generate docx files from scratch, programmatically. Drawbacks of this approach: they typically do not support all Word features, and producing a complex document can be challenging.

@@ -197,0 +240,0 @@ ## License (MIT)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc