@entelligentsia/forgecli 0.6.6 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/README.md +28 -1
- package/dist/bin/forge.js +20 -0
- package/dist/bin/forge.js.map +1 -1
- package/dist/extensions/forgecli/approve.d.ts +24 -0
- package/dist/extensions/forgecli/approve.js +202 -0
- package/dist/extensions/forgecli/approve.js.map +1 -0
- package/dist/extensions/forgecli/audience-gate.d.ts +4 -0
- package/dist/extensions/forgecli/audience-gate.js +8 -5
- package/dist/extensions/forgecli/audience-gate.js.map +1 -1
- package/dist/extensions/forgecli/collate.d.ts +24 -0
- package/dist/extensions/forgecli/collate.js +199 -0
- package/dist/extensions/forgecli/collate.js.map +1 -0
- package/dist/extensions/forgecli/commit.d.ts +24 -0
- package/dist/extensions/forgecli/commit.js +202 -0
- package/dist/extensions/forgecli/commit.js.map +1 -0
- package/dist/extensions/forgecli/fix-bug.d.ts +75 -0
- package/dist/extensions/forgecli/fix-bug.js +1133 -0
- package/dist/extensions/forgecli/fix-bug.js.map +1 -0
- package/dist/extensions/forgecli/forge-commands.js +7 -0
- package/dist/extensions/forgecli/forge-commands.js.map +1 -1
- package/dist/extensions/forgecli/forge-init.js +16 -8
- package/dist/extensions/forgecli/forge-init.js.map +1 -1
- package/dist/extensions/forgecli/forge-subagent.d.ts +29 -0
- package/dist/extensions/forgecli/forge-subagent.js +14 -1
- package/dist/extensions/forgecli/forge-subagent.js.map +1 -1
- package/dist/extensions/forgecli/hook-dispatcher.d.ts +53 -1
- package/dist/extensions/forgecli/hook-dispatcher.js +47 -1
- package/dist/extensions/forgecli/hook-dispatcher.js.map +1 -1
- package/dist/extensions/forgecli/hooks/post-init-hook.d.ts +15 -0
- package/dist/extensions/forgecli/hooks/post-init-hook.js +127 -0
- package/dist/extensions/forgecli/hooks/post-init-hook.js.map +1 -0
- package/dist/extensions/forgecli/hooks/post-sprint-hook.d.ts +37 -0
- package/dist/extensions/forgecli/hooks/post-sprint-hook.js +166 -0
- package/dist/extensions/forgecli/hooks/post-sprint-hook.js.map +1 -0
- package/dist/extensions/forgecli/index.js +47 -0
- package/dist/extensions/forgecli/index.js.map +1 -1
- package/dist/extensions/forgecli/review-code.d.ts +24 -0
- package/dist/extensions/forgecli/review-code.js +202 -0
- package/dist/extensions/forgecli/review-code.js.map +1 -0
- package/dist/extensions/forgecli/review-plan.d.ts +24 -0
- package/dist/extensions/forgecli/review-plan.js +203 -0
- package/dist/extensions/forgecli/review-plan.js.map +1 -0
- package/dist/extensions/forgecli/run-sprint.d.ts +18 -0
- package/dist/extensions/forgecli/run-sprint.js +33 -1
- package/dist/extensions/forgecli/run-sprint.js.map +1 -1
- package/dist/extensions/forgecli/run-task.d.ts +21 -2
- package/dist/extensions/forgecli/run-task.js +33 -9
- package/dist/extensions/forgecli/run-task.js.map +1 -1
- package/dist/extensions/forgecli/session-registry.d.ts +10 -0
- package/dist/extensions/forgecli/session-registry.js +9 -0
- package/dist/extensions/forgecli/session-registry.js.map +1 -1
- package/dist/extensions/forgecli/validate.d.ts +24 -0
- package/dist/extensions/forgecli/validate.js +202 -0
- package/dist/extensions/forgecli/validate.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/engine.d.ts +23 -0
- package/dist/extensions/forgecli/wf-engine/engine.js +384 -0
- package/dist/extensions/forgecli/wf-engine/engine.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/event-parser.d.ts +6 -0
- package/dist/extensions/forgecli/wf-engine/event-parser.js +29 -0
- package/dist/extensions/forgecli/wf-engine/event-parser.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/id-gen.d.ts +6 -0
- package/dist/extensions/forgecli/wf-engine/id-gen.js +17 -0
- package/dist/extensions/forgecli/wf-engine/id-gen.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/loader.d.ts +2 -0
- package/dist/extensions/forgecli/wf-engine/loader.js +100 -0
- package/dist/extensions/forgecli/wf-engine/loader.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/predicate.d.ts +7 -0
- package/dist/extensions/forgecli/wf-engine/predicate.js +36 -0
- package/dist/extensions/forgecli/wf-engine/predicate.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/prompt-compiler.d.ts +15 -0
- package/dist/extensions/forgecli/wf-engine/prompt-compiler.js +23 -0
- package/dist/extensions/forgecli/wf-engine/prompt-compiler.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/register.d.ts +9 -0
- package/dist/extensions/forgecli/wf-engine/register.js +59 -0
- package/dist/extensions/forgecli/wf-engine/register.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/remit-check.d.ts +6 -0
- package/dist/extensions/forgecli/wf-engine/remit-check.js +42 -0
- package/dist/extensions/forgecli/wf-engine/remit-check.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/state-store.d.ts +13 -0
- package/dist/extensions/forgecli/wf-engine/state-store.js +43 -0
- package/dist/extensions/forgecli/wf-engine/state-store.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/types.d.ts +66 -0
- package/dist/extensions/forgecli/wf-engine/types.js +2 -0
- package/dist/extensions/forgecli/wf-engine/types.js.map +1 -0
- package/dist/extensions/forgecli/wf-engine/worker.d.ts +11 -0
- package/dist/extensions/forgecli/wf-engine/worker.js +50 -0
- package/dist/extensions/forgecli/wf-engine/worker.js.map +1 -0
- package/dist/forge-payload/.base-pack/workflows/_fragments/context-injection.md +10 -4
- package/dist/forge-payload/.base-pack/workflows/fix_bug.md +12 -0
- package/dist/forge-payload/.schemas/bug.schema.json +4 -2
- package/dist/forge-payload/.schemas/event.schema.json +22 -3
- package/dist/forge-payload/commands/add-pipeline.md +342 -0
- package/dist/forge-payload/commands/add-task.md +269 -0
- package/dist/forge-payload/commands/ask.md +43 -0
- package/dist/forge-payload/commands/calibrate.md +356 -0
- package/dist/forge-payload/commands/config.md +202 -0
- package/dist/forge-payload/commands/enhance.md +38 -0
- package/dist/forge-payload/commands/health.md +225 -0
- package/dist/forge-payload/commands/init.md +165 -0
- package/dist/forge-payload/commands/materialize.md +119 -0
- package/dist/forge-payload/commands/migrate.md +160 -0
- package/dist/forge-payload/commands/quiz-agent.md +38 -0
- package/dist/forge-payload/commands/regenerate.md +673 -0
- package/dist/forge-payload/commands/remove.md +174 -0
- package/dist/forge-payload/commands/report-bug.md +191 -0
- package/dist/forge-payload/commands/store-query.md +73 -0
- package/dist/forge-payload/commands/store-repair.md +187 -0
- package/dist/forge-payload/commands/update-tools.md +56 -0
- package/dist/forge-payload/commands/update.md +1376 -0
- package/dist/forge-payload/tools/preflight-gate.cjs +2 -1
- package/dist/forge-payload/tools/read-verdict.cjs +41 -8
- package/dist/forge-payload/tools/store-cli.cjs +4 -3
- package/node_modules/argparse/CHANGELOG.md +216 -0
- package/node_modules/argparse/LICENSE +254 -0
- package/node_modules/argparse/README.md +84 -0
- package/node_modules/argparse/argparse.js +3707 -0
- package/node_modules/argparse/lib/sub.js +67 -0
- package/node_modules/argparse/lib/textwrap.js +440 -0
- package/node_modules/argparse/package.json +31 -0
- package/node_modules/cliui/CHANGELOG.md +121 -0
- package/node_modules/color-convert/CHANGELOG.md +54 -0
- package/node_modules/esprima/ChangeLog +235 -0
- package/node_modules/js-yaml/LICENSE +21 -0
- package/node_modules/js-yaml/README.md +247 -0
- package/node_modules/js-yaml/bin/js-yaml.js +126 -0
- package/node_modules/js-yaml/dist/js-yaml.js +3880 -0
- package/node_modules/js-yaml/dist/js-yaml.min.js +2 -0
- package/node_modules/js-yaml/dist/js-yaml.mjs +3856 -0
- package/node_modules/js-yaml/index.js +47 -0
- package/node_modules/js-yaml/lib/common.js +59 -0
- package/node_modules/js-yaml/lib/dumper.js +965 -0
- package/node_modules/js-yaml/lib/exception.js +55 -0
- package/node_modules/js-yaml/lib/loader.js +1733 -0
- package/node_modules/js-yaml/lib/schema/core.js +11 -0
- package/node_modules/js-yaml/lib/schema/default.js +22 -0
- package/node_modules/js-yaml/lib/schema/failsafe.js +17 -0
- package/node_modules/js-yaml/lib/schema/json.js +19 -0
- package/node_modules/js-yaml/lib/schema.js +121 -0
- package/node_modules/js-yaml/lib/snippet.js +101 -0
- package/node_modules/js-yaml/lib/type/binary.js +125 -0
- package/node_modules/js-yaml/lib/type/bool.js +35 -0
- package/node_modules/js-yaml/lib/type/float.js +97 -0
- package/node_modules/js-yaml/lib/type/int.js +156 -0
- package/node_modules/js-yaml/lib/type/map.js +8 -0
- package/node_modules/js-yaml/lib/type/merge.js +12 -0
- package/node_modules/js-yaml/lib/type/null.js +35 -0
- package/node_modules/js-yaml/lib/type/omap.js +44 -0
- package/node_modules/js-yaml/lib/type/pairs.js +53 -0
- package/node_modules/js-yaml/lib/type/seq.js +8 -0
- package/node_modules/js-yaml/lib/type/set.js +29 -0
- package/node_modules/js-yaml/lib/type/str.js +8 -0
- package/node_modules/js-yaml/lib/type/timestamp.js +88 -0
- package/node_modules/js-yaml/lib/type.js +66 -0
- package/node_modules/js-yaml/package.json +66 -0
- package/node_modules/mz/HISTORY.md +66 -0
- package/node_modules/proper-lockfile/CHANGELOG.md +108 -0
- package/node_modules/source-map/CHANGELOG.md +301 -0
- package/node_modules/thenify/History.md +11 -0
- package/node_modules/thenify-all/History.md +11 -0
- package/node_modules/y18n/CHANGELOG.md +100 -0
- package/node_modules/yargs/CHANGELOG.md +88 -0
- package/node_modules/yargs-parser/CHANGELOG.md +263 -0
- package/package.json +6 -2
- package/workflows/lead-qualifier/prompts/digest.md +44 -0
- package/workflows/lead-qualifier/prompts/draft-outreach.md +44 -0
- package/workflows/lead-qualifier/prompts/enrich.md +52 -0
- package/workflows/lead-qualifier/prompts/intake.md +48 -0
- package/workflows/lead-qualifier/prompts/mark-cold.md +38 -0
- package/workflows/lead-qualifier/prompts/score.md +45 -0
- package/workflows/lead-qualifier/workflow.yaml +95 -0
- package/workflows/research-brief/prompts/brief-synthesize.md +43 -0
- package/workflows/research-brief/prompts/intake.md +51 -0
- package/workflows/research-brief/prompts/source-critique.md +38 -0
- package/workflows/research-brief/prompts/source-score.md +38 -0
- package/workflows/research-brief/prompts/source-summarize.md +54 -0
- package/workflows/research-brief/workflow.yaml +66 -0
- package/dist/extensions/forgecli/session-monitor-widget.d.ts +0 -37
- package/dist/extensions/forgecli/session-monitor-widget.js +0 -320
- package/dist/extensions/forgecli/session-monitor-widget.js.map +0 -1
- package/dist/extensions/forgecli/session-monitor.d.ts +0 -2
- package/dist/extensions/forgecli/session-monitor.js +0 -135
- package/dist/extensions/forgecli/session-monitor.js.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 1.0.0 - 2016-01-07
|
|
2
|
+
|
|
3
|
+
- Removed: unused speed test
|
|
4
|
+
- Added: Automatic routing between previously unsupported conversions
|
|
5
|
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
6
|
+
- Removed: `xxx2xxx()` and `xxx2xxxRaw()` functions
|
|
7
|
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
8
|
+
- Removed: `convert()` class
|
|
9
|
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
10
|
+
- Changed: all functions to lookup dictionary
|
|
11
|
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
12
|
+
- Changed: `ansi` to `ansi256`
|
|
13
|
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
14
|
+
- Fixed: argument grouping for functions requiring only one argument
|
|
15
|
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
16
|
+
|
|
17
|
+
# 0.6.0 - 2015-07-23
|
|
18
|
+
|
|
19
|
+
- Added: methods to handle
|
|
20
|
+
[ANSI](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) 16/256 colors:
|
|
21
|
+
- rgb2ansi16
|
|
22
|
+
- rgb2ansi
|
|
23
|
+
- hsl2ansi16
|
|
24
|
+
- hsl2ansi
|
|
25
|
+
- hsv2ansi16
|
|
26
|
+
- hsv2ansi
|
|
27
|
+
- hwb2ansi16
|
|
28
|
+
- hwb2ansi
|
|
29
|
+
- cmyk2ansi16
|
|
30
|
+
- cmyk2ansi
|
|
31
|
+
- keyword2ansi16
|
|
32
|
+
- keyword2ansi
|
|
33
|
+
- ansi162rgb
|
|
34
|
+
- ansi162hsl
|
|
35
|
+
- ansi162hsv
|
|
36
|
+
- ansi162hwb
|
|
37
|
+
- ansi162cmyk
|
|
38
|
+
- ansi162keyword
|
|
39
|
+
- ansi2rgb
|
|
40
|
+
- ansi2hsl
|
|
41
|
+
- ansi2hsv
|
|
42
|
+
- ansi2hwb
|
|
43
|
+
- ansi2cmyk
|
|
44
|
+
- ansi2keyword
|
|
45
|
+
([#18](https://github.com/harthur/color-convert/pull/18))
|
|
46
|
+
|
|
47
|
+
# 0.5.3 - 2015-06-02
|
|
48
|
+
|
|
49
|
+
- Fixed: hsl2hsv does not return `NaN` anymore when using `[0,0,0]`
|
|
50
|
+
([#15](https://github.com/harthur/color-convert/issues/15))
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
Check out commit logs for older releases
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
2018-06-17: Version 4.0.1
|
|
2
|
+
|
|
3
|
+
* Fix parsing async get/set in a class (issue 1861, 1875)
|
|
4
|
+
* Account for different return statement argument (issue 1829, 1897, 1928)
|
|
5
|
+
* Correct the handling of HTML comment when parsing a module (issue 1841)
|
|
6
|
+
* Fix incorrect parse async with proto-identifier-shorthand (issue 1847)
|
|
7
|
+
* Fix negative column in binary expression (issue 1844)
|
|
8
|
+
* Fix incorrect YieldExpression in object methods (issue 1834)
|
|
9
|
+
* Various documentation fixes
|
|
10
|
+
|
|
11
|
+
2017-06-10: Version 4.0.0
|
|
12
|
+
|
|
13
|
+
* Support ES2017 async function and await expression (issue 1079)
|
|
14
|
+
* Support ES2017 trailing commas in function parameters (issue 1550)
|
|
15
|
+
* Explicitly distinguish parsing a module vs a script (issue 1576)
|
|
16
|
+
* Fix JSX non-empty container (issue 1786)
|
|
17
|
+
* Allow JSX element in a yield expression (issue 1765)
|
|
18
|
+
* Allow `in` expression in a concise body with a function body (issue 1793)
|
|
19
|
+
* Setter function argument must not be a rest parameter (issue 1693)
|
|
20
|
+
* Limit strict mode directive to functions with a simple parameter list (issue 1677)
|
|
21
|
+
* Prohibit any escape sequence in a reserved word (issue 1612)
|
|
22
|
+
* Only permit hex digits in hex escape sequence (issue 1619)
|
|
23
|
+
* Prohibit labelled class/generator/function declaration (issue 1484)
|
|
24
|
+
* Limit function declaration as if statement clause only in non-strict mode (issue 1657)
|
|
25
|
+
* Tolerate missing ) in a with and do-while statement (issue 1481)
|
|
26
|
+
|
|
27
|
+
2016-12-22: Version 3.1.3
|
|
28
|
+
|
|
29
|
+
* Support binding patterns as rest element (issue 1681)
|
|
30
|
+
* Account for different possible arguments of a yield expression (issue 1469)
|
|
31
|
+
|
|
32
|
+
2016-11-24: Version 3.1.2
|
|
33
|
+
|
|
34
|
+
* Ensure that import specifier is more restrictive (issue 1615)
|
|
35
|
+
* Fix duplicated JSX tokens (issue 1613)
|
|
36
|
+
* Scan template literal in a JSX expression container (issue 1622)
|
|
37
|
+
* Improve XHTML entity scanning in JSX (issue 1629)
|
|
38
|
+
|
|
39
|
+
2016-10-31: Version 3.1.1
|
|
40
|
+
|
|
41
|
+
* Fix assignment expression problem in an export declaration (issue 1596)
|
|
42
|
+
* Fix incorrect tokenization of hex digits (issue 1605)
|
|
43
|
+
|
|
44
|
+
2016-10-09: Version 3.1.0
|
|
45
|
+
|
|
46
|
+
* Do not implicitly collect comments when comment attachment is specified (issue 1553)
|
|
47
|
+
* Fix incorrect handling of duplicated proto shorthand fields (issue 1485)
|
|
48
|
+
* Prohibit initialization in some variants of for statements (issue 1309, 1561)
|
|
49
|
+
* Fix incorrect parsing of export specifier (issue 1578)
|
|
50
|
+
* Fix ESTree compatibility for assignment pattern (issue 1575)
|
|
51
|
+
|
|
52
|
+
2016-09-03: Version 3.0.0
|
|
53
|
+
|
|
54
|
+
* Support ES2016 exponentiation expression (issue 1490)
|
|
55
|
+
* Support JSX syntax (issue 1467)
|
|
56
|
+
* Use the latest Unicode 8.0 (issue 1475)
|
|
57
|
+
* Add the support for syntax node delegate (issue 1435)
|
|
58
|
+
* Fix ESTree compatibility on meta property (issue 1338)
|
|
59
|
+
* Fix ESTree compatibility on default parameter value (issue 1081)
|
|
60
|
+
* Fix ESTree compatibility on try handler (issue 1030)
|
|
61
|
+
|
|
62
|
+
2016-08-23: Version 2.7.3
|
|
63
|
+
|
|
64
|
+
* Fix tokenizer confusion with a comment (issue 1493, 1516)
|
|
65
|
+
|
|
66
|
+
2016-02-02: Version 2.7.2
|
|
67
|
+
|
|
68
|
+
* Fix out-of-bound error location in an invalid string literal (issue 1457)
|
|
69
|
+
* Fix shorthand object destructuring defaults in variable declarations (issue 1459)
|
|
70
|
+
|
|
71
|
+
2015-12-10: Version 2.7.1
|
|
72
|
+
|
|
73
|
+
* Do not allow trailing comma in a variable declaration (issue 1360)
|
|
74
|
+
* Fix assignment to `let` in non-strict mode (issue 1376)
|
|
75
|
+
* Fix missing delegate property in YieldExpression (issue 1407)
|
|
76
|
+
|
|
77
|
+
2015-10-22: Version 2.7.0
|
|
78
|
+
|
|
79
|
+
* Fix the handling of semicolon in a break statement (issue 1044)
|
|
80
|
+
* Run the test suite with major web browsers (issue 1259, 1317)
|
|
81
|
+
* Allow `let` as an identifier in non-strict mode (issue 1289)
|
|
82
|
+
* Attach orphaned comments as `innerComments` (issue 1328)
|
|
83
|
+
* Add the support for token delegator (issue 1332)
|
|
84
|
+
|
|
85
|
+
2015-09-01: Version 2.6.0
|
|
86
|
+
|
|
87
|
+
* Properly allow or prohibit `let` in a binding identifier/pattern (issue 1048, 1098)
|
|
88
|
+
* Add sourceType field for Program node (issue 1159)
|
|
89
|
+
* Ensure that strict mode reserved word binding throw an error (issue 1171)
|
|
90
|
+
* Run the test suite with Node.js and IE 11 on Windows (issue 1294)
|
|
91
|
+
* Allow binding pattern with no initializer in a for statement (issue 1301)
|
|
92
|
+
|
|
93
|
+
2015-07-31: Version 2.5.0
|
|
94
|
+
|
|
95
|
+
* Run the test suite in a browser environment (issue 1004)
|
|
96
|
+
* Ensure a comma between imported default binding and named imports (issue 1046)
|
|
97
|
+
* Distinguish `yield` as a keyword vs an identifier (issue 1186)
|
|
98
|
+
* Support ES6 meta property `new.target` (issue 1203)
|
|
99
|
+
* Fix the syntax node for yield with expression (issue 1223)
|
|
100
|
+
* Fix the check of duplicated proto in property names (issue 1225)
|
|
101
|
+
* Fix ES6 Unicode escape in identifier name (issue 1229)
|
|
102
|
+
* Support ES6 IdentifierStart and IdentifierPart (issue 1232)
|
|
103
|
+
* Treat await as a reserved word when parsing as a module (issue 1234)
|
|
104
|
+
* Recognize identifier characters from Unicode SMP (issue 1244)
|
|
105
|
+
* Ensure that export and import can be followed by a comma (issue 1250)
|
|
106
|
+
* Fix yield operator precedence (issue 1262)
|
|
107
|
+
|
|
108
|
+
2015-07-01: Version 2.4.1
|
|
109
|
+
|
|
110
|
+
* Fix some cases of comment attachment (issue 1071, 1175)
|
|
111
|
+
* Fix the handling of destructuring in function arguments (issue 1193)
|
|
112
|
+
* Fix invalid ranges in assignment expression (issue 1201)
|
|
113
|
+
|
|
114
|
+
2015-06-26: Version 2.4.0
|
|
115
|
+
|
|
116
|
+
* Support ES6 for-of iteration (issue 1047)
|
|
117
|
+
* Support ES6 spread arguments (issue 1169)
|
|
118
|
+
* Minimize npm payload (issue 1191)
|
|
119
|
+
|
|
120
|
+
2015-06-16: Version 2.3.0
|
|
121
|
+
|
|
122
|
+
* Support ES6 generator (issue 1033)
|
|
123
|
+
* Improve parsing of regular expressions with `u` flag (issue 1179)
|
|
124
|
+
|
|
125
|
+
2015-04-17: Version 2.2.0
|
|
126
|
+
|
|
127
|
+
* Support ES6 import and export declarations (issue 1000)
|
|
128
|
+
* Fix line terminator before arrow not recognized as error (issue 1009)
|
|
129
|
+
* Support ES6 destructuring (issue 1045)
|
|
130
|
+
* Support ES6 template literal (issue 1074)
|
|
131
|
+
* Fix the handling of invalid/incomplete string escape sequences (issue 1106)
|
|
132
|
+
* Fix ES3 static member access restriction (issue 1120)
|
|
133
|
+
* Support for `super` in ES6 class (issue 1147)
|
|
134
|
+
|
|
135
|
+
2015-03-09: Version 2.1.0
|
|
136
|
+
|
|
137
|
+
* Support ES6 class (issue 1001)
|
|
138
|
+
* Support ES6 rest parameter (issue 1011)
|
|
139
|
+
* Expand the location of property getter, setter, and methods (issue 1029)
|
|
140
|
+
* Enable TryStatement transition to a single handler (issue 1031)
|
|
141
|
+
* Support ES6 computed property name (issue 1037)
|
|
142
|
+
* Tolerate unclosed block comment (issue 1041)
|
|
143
|
+
* Support ES6 lexical declaration (issue 1065)
|
|
144
|
+
|
|
145
|
+
2015-02-06: Version 2.0.0
|
|
146
|
+
|
|
147
|
+
* Support ES6 arrow function (issue 517)
|
|
148
|
+
* Support ES6 Unicode code point escape (issue 521)
|
|
149
|
+
* Improve the speed and accuracy of comment attachment (issue 522)
|
|
150
|
+
* Support ES6 default parameter (issue 519)
|
|
151
|
+
* Support ES6 regular expression flags (issue 557)
|
|
152
|
+
* Fix scanning of implicit octal literals (issue 565)
|
|
153
|
+
* Fix the handling of automatic semicolon insertion (issue 574)
|
|
154
|
+
* Support ES6 method definition (issue 620)
|
|
155
|
+
* Support ES6 octal integer literal (issue 621)
|
|
156
|
+
* Support ES6 binary integer literal (issue 622)
|
|
157
|
+
* Support ES6 object literal property value shorthand (issue 624)
|
|
158
|
+
|
|
159
|
+
2015-03-03: Version 1.2.5
|
|
160
|
+
|
|
161
|
+
* Fix scanning of implicit octal literals (issue 565)
|
|
162
|
+
|
|
163
|
+
2015-02-05: Version 1.2.4
|
|
164
|
+
|
|
165
|
+
* Fix parsing of LeftHandSideExpression in ForInStatement (issue 560)
|
|
166
|
+
* Fix the handling of automatic semicolon insertion (issue 574)
|
|
167
|
+
|
|
168
|
+
2015-01-18: Version 1.2.3
|
|
169
|
+
|
|
170
|
+
* Fix division by this (issue 616)
|
|
171
|
+
|
|
172
|
+
2014-05-18: Version 1.2.2
|
|
173
|
+
|
|
174
|
+
* Fix duplicated tokens when collecting comments (issue 537)
|
|
175
|
+
|
|
176
|
+
2014-05-04: Version 1.2.1
|
|
177
|
+
|
|
178
|
+
* Ensure that Program node may still have leading comments (issue 536)
|
|
179
|
+
|
|
180
|
+
2014-04-29: Version 1.2.0
|
|
181
|
+
|
|
182
|
+
* Fix semicolon handling for expression statement (issue 462, 533)
|
|
183
|
+
* Disallow escaped characters in regular expression flags (issue 503)
|
|
184
|
+
* Performance improvement for location tracking (issue 520)
|
|
185
|
+
* Improve the speed of comment attachment (issue 522)
|
|
186
|
+
|
|
187
|
+
2014-03-26: Version 1.1.1
|
|
188
|
+
|
|
189
|
+
* Fix token handling of forward slash after an array literal (issue 512)
|
|
190
|
+
|
|
191
|
+
2014-03-23: Version 1.1.0
|
|
192
|
+
|
|
193
|
+
* Optionally attach comments to the owning syntax nodes (issue 197)
|
|
194
|
+
* Simplify binary parsing with stack-based shift reduce (issue 352)
|
|
195
|
+
* Always include the raw source of literals (issue 376)
|
|
196
|
+
* Add optional input source information (issue 386)
|
|
197
|
+
* Tokenizer API for pure lexical scanning (issue 398)
|
|
198
|
+
* Improve the web site and its online demos (issue 337, 400, 404)
|
|
199
|
+
* Performance improvement for location tracking (issue 417, 424)
|
|
200
|
+
* Support HTML comment syntax (issue 451)
|
|
201
|
+
* Drop support for legacy browsers (issue 474)
|
|
202
|
+
|
|
203
|
+
2013-08-27: Version 1.0.4
|
|
204
|
+
|
|
205
|
+
* Minimize the payload for packages (issue 362)
|
|
206
|
+
* Fix missing cases on an empty switch statement (issue 436)
|
|
207
|
+
* Support escaped ] in regexp literal character classes (issue 442)
|
|
208
|
+
* Tolerate invalid left-hand side expression (issue 130)
|
|
209
|
+
|
|
210
|
+
2013-05-17: Version 1.0.3
|
|
211
|
+
|
|
212
|
+
* Variable declaration needs at least one declarator (issue 391)
|
|
213
|
+
* Fix benchmark's variance unit conversion (issue 397)
|
|
214
|
+
* IE < 9: \v should be treated as vertical tab (issue 405)
|
|
215
|
+
* Unary expressions should always have prefix: true (issue 418)
|
|
216
|
+
* Catch clause should only accept an identifier (issue 423)
|
|
217
|
+
* Tolerate setters without parameter (issue 426)
|
|
218
|
+
|
|
219
|
+
2012-11-02: Version 1.0.2
|
|
220
|
+
|
|
221
|
+
Improvement:
|
|
222
|
+
|
|
223
|
+
* Fix esvalidate JUnit output upon a syntax error (issue 374)
|
|
224
|
+
|
|
225
|
+
2012-10-28: Version 1.0.1
|
|
226
|
+
|
|
227
|
+
Improvements:
|
|
228
|
+
|
|
229
|
+
* esvalidate understands shebang in a Unix shell script (issue 361)
|
|
230
|
+
* esvalidate treats fatal parsing failure as an error (issue 361)
|
|
231
|
+
* Reduce Node.js package via .npmignore (issue 362)
|
|
232
|
+
|
|
233
|
+
2012-10-22: Version 1.0.0
|
|
234
|
+
|
|
235
|
+
Initial release.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2011-2015 by Vitaly Puzrin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
JS-YAML - YAML 1.2 parser / writer for JavaScript
|
|
2
|
+
=================================================
|
|
3
|
+
|
|
4
|
+
[](https://github.com/nodeca/js-yaml/actions)
|
|
5
|
+
[](https://www.npmjs.org/package/js-yaml)
|
|
6
|
+
|
|
7
|
+
__[Online Demo](https://nodeca.github.io/js-yaml/)__
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
This is an implementation of [YAML](https://yaml.org/), a human-friendly data
|
|
11
|
+
serialization language. Started as [PyYAML](https://pyyaml.org/) port, it was
|
|
12
|
+
completely rewritten from scratch. Now it's very fast, and supports 1.2 spec.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Installation
|
|
16
|
+
------------
|
|
17
|
+
|
|
18
|
+
### YAML module for node.js
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
npm install js-yaml
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### CLI executable
|
|
26
|
+
|
|
27
|
+
If you want to inspect your YAML files from CLI, install js-yaml globally:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
npm install -g js-yaml
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### Usage
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
usage: js-yaml [-h] [-v] [-c] [-t] file
|
|
37
|
+
|
|
38
|
+
Positional arguments:
|
|
39
|
+
file File with YAML document(s)
|
|
40
|
+
|
|
41
|
+
Optional arguments:
|
|
42
|
+
-h, --help Show this help message and exit.
|
|
43
|
+
-v, --version Show program's version number and exit.
|
|
44
|
+
-c, --compact Display errors in compact mode
|
|
45
|
+
-t, --trace Show stack trace on error
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
API
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
Here we cover the most 'useful' methods. If you need advanced details (creating
|
|
53
|
+
your own tags), see [examples](https://github.com/nodeca/js-yaml/tree/master/examples)
|
|
54
|
+
for more info.
|
|
55
|
+
|
|
56
|
+
``` javascript
|
|
57
|
+
const yaml = require('js-yaml');
|
|
58
|
+
const fs = require('fs');
|
|
59
|
+
|
|
60
|
+
// Get document, or throw exception on error
|
|
61
|
+
try {
|
|
62
|
+
const doc = yaml.load(fs.readFileSync('/home/ixti/example.yml', 'utf8'));
|
|
63
|
+
console.log(doc);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
console.log(e);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### load (string [ , options ])
|
|
71
|
+
|
|
72
|
+
Parses `string` as single YAML document. Returns either a
|
|
73
|
+
plain object, a string, a number, `null` or `undefined`, or throws `YAMLException` on error. By default, does
|
|
74
|
+
not support regexps, functions and undefined.
|
|
75
|
+
|
|
76
|
+
options:
|
|
77
|
+
|
|
78
|
+
- `filename` _(default: null)_ - string to be used as a file path in
|
|
79
|
+
error/warning messages.
|
|
80
|
+
- `onWarning` _(default: null)_ - function to call on warning messages.
|
|
81
|
+
Loader will call this function with an instance of `YAMLException` for each warning.
|
|
82
|
+
- `schema` _(default: `DEFAULT_SCHEMA`)_ - specifies a schema to use.
|
|
83
|
+
- `FAILSAFE_SCHEMA` - only strings, arrays and plain objects:
|
|
84
|
+
https://www.yaml.org/spec/1.2/spec.html#id2802346
|
|
85
|
+
- `JSON_SCHEMA` - all JSON-supported types:
|
|
86
|
+
https://www.yaml.org/spec/1.2/spec.html#id2803231
|
|
87
|
+
- `CORE_SCHEMA` - same as `JSON_SCHEMA`:
|
|
88
|
+
https://www.yaml.org/spec/1.2/spec.html#id2804923
|
|
89
|
+
- `DEFAULT_SCHEMA` - all supported YAML types.
|
|
90
|
+
- `json` _(default: false)_ - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.
|
|
91
|
+
|
|
92
|
+
NOTE: This function **does not** understand multi-document sources, it throws
|
|
93
|
+
exception on those.
|
|
94
|
+
|
|
95
|
+
NOTE: JS-YAML **does not** support schema-specific tag resolution restrictions.
|
|
96
|
+
So, the JSON schema is not as strictly defined in the YAML specification.
|
|
97
|
+
It allows numbers in any notation, use `Null` and `NULL` as `null`, etc.
|
|
98
|
+
The core schema also has no such restrictions. It allows binary notation for integers.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
### loadAll (string [, iterator] [, options ])
|
|
102
|
+
|
|
103
|
+
Same as `load()`, but understands multi-document sources. Applies
|
|
104
|
+
`iterator` to each document if specified, or returns array of documents.
|
|
105
|
+
|
|
106
|
+
``` javascript
|
|
107
|
+
const yaml = require('js-yaml');
|
|
108
|
+
|
|
109
|
+
yaml.loadAll(data, function (doc) {
|
|
110
|
+
console.log(doc);
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
### dump (object [ , options ])
|
|
116
|
+
|
|
117
|
+
Serializes `object` as a YAML document. Uses `DEFAULT_SCHEMA`, so it will
|
|
118
|
+
throw an exception if you try to dump regexps or functions. However, you can
|
|
119
|
+
disable exceptions by setting the `skipInvalid` option to `true`.
|
|
120
|
+
|
|
121
|
+
options:
|
|
122
|
+
|
|
123
|
+
- `indent` _(default: 2)_ - indentation width to use (in spaces).
|
|
124
|
+
- `noArrayIndent` _(default: false)_ - when true, will not add an indentation level to array elements
|
|
125
|
+
- `skipInvalid` _(default: false)_ - do not throw on invalid types (like function
|
|
126
|
+
in the safe schema) and skip pairs and single values with such types.
|
|
127
|
+
- `flowLevel` _(default: -1)_ - specifies level of nesting, when to switch from
|
|
128
|
+
block to flow style for collections. -1 means block style everwhere
|
|
129
|
+
- `styles` - "tag" => "style" map. Each tag may have own set of styles.
|
|
130
|
+
- `schema` _(default: `DEFAULT_SCHEMA`)_ specifies a schema to use.
|
|
131
|
+
- `sortKeys` _(default: `false`)_ - if `true`, sort keys when dumping YAML. If a
|
|
132
|
+
function, use the function to sort the keys.
|
|
133
|
+
- `lineWidth` _(default: `80`)_ - set max line width. Set `-1` for unlimited width.
|
|
134
|
+
- `noRefs` _(default: `false`)_ - if `true`, don't convert duplicate objects into references
|
|
135
|
+
- `noCompatMode` _(default: `false`)_ - if `true` don't try to be compatible with older
|
|
136
|
+
yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1
|
|
137
|
+
- `condenseFlow` _(default: `false`)_ - if `true` flow sequences will be condensed, omitting the space between `a, b`. Eg. `'[a,b]'`, and omitting the space between `key: value` and quoting the key. Eg. `'{"a":b}'` Can be useful when using yaml for pretty URL query params as spaces are %-encoded.
|
|
138
|
+
- `quotingType` _(`'` or `"`, default: `'`)_ - strings will be quoted using this quoting style. If you specify single quotes, double quotes will still be used for non-printable characters.
|
|
139
|
+
- `forceQuotes` _(default: `false`)_ - if `true`, all non-key strings will be quoted even if they normally don't need to.
|
|
140
|
+
- `replacer` - callback `function (key, value)` called recursively on each key/value in source object (see `replacer` docs for `JSON.stringify`).
|
|
141
|
+
|
|
142
|
+
The following table show availlable styles (e.g. "canonical",
|
|
143
|
+
"binary"...) available for each tag (.e.g. !!null, !!int ...). Yaml
|
|
144
|
+
output is shown on the right side after `=>` (default setting) or `->`:
|
|
145
|
+
|
|
146
|
+
``` none
|
|
147
|
+
!!null
|
|
148
|
+
"canonical" -> "~"
|
|
149
|
+
"lowercase" => "null"
|
|
150
|
+
"uppercase" -> "NULL"
|
|
151
|
+
"camelcase" -> "Null"
|
|
152
|
+
"empty" -> ""
|
|
153
|
+
|
|
154
|
+
!!int
|
|
155
|
+
"binary" -> "0b1", "0b101010", "0b1110001111010"
|
|
156
|
+
"octal" -> "0o1", "0o52", "0o16172"
|
|
157
|
+
"decimal" => "1", "42", "7290"
|
|
158
|
+
"hexadecimal" -> "0x1", "0x2A", "0x1C7A"
|
|
159
|
+
|
|
160
|
+
!!bool
|
|
161
|
+
"lowercase" => "true", "false"
|
|
162
|
+
"uppercase" -> "TRUE", "FALSE"
|
|
163
|
+
"camelcase" -> "True", "False"
|
|
164
|
+
|
|
165
|
+
!!float
|
|
166
|
+
"lowercase" => ".nan", '.inf'
|
|
167
|
+
"uppercase" -> ".NAN", '.INF'
|
|
168
|
+
"camelcase" -> ".NaN", '.Inf'
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Example:
|
|
172
|
+
|
|
173
|
+
``` javascript
|
|
174
|
+
dump(object, {
|
|
175
|
+
'styles': {
|
|
176
|
+
'!!null': 'canonical' // dump null as ~
|
|
177
|
+
},
|
|
178
|
+
'sortKeys': true // sort object keys
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Supported YAML types
|
|
183
|
+
--------------------
|
|
184
|
+
|
|
185
|
+
The list of standard YAML tags and corresponding JavaScript types. See also
|
|
186
|
+
[YAML tag discussion](https://pyyaml.org/wiki/YAMLTagDiscussion) and
|
|
187
|
+
[YAML types repository](https://yaml.org/type/).
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
!!null '' # null
|
|
191
|
+
!!bool 'yes' # bool
|
|
192
|
+
!!int '3...' # number
|
|
193
|
+
!!float '3.14...' # number
|
|
194
|
+
!!binary '...base64...' # buffer
|
|
195
|
+
!!timestamp 'YYYY-...' # date
|
|
196
|
+
!!omap [ ... ] # array of key-value pairs
|
|
197
|
+
!!pairs [ ... ] # array or array pairs
|
|
198
|
+
!!set { ... } # array of objects with given keys and null values
|
|
199
|
+
!!str '...' # string
|
|
200
|
+
!!seq [ ... ] # array
|
|
201
|
+
!!map { ... } # object
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**JavaScript-specific tags**
|
|
205
|
+
|
|
206
|
+
See [js-yaml-js-types](https://github.com/nodeca/js-yaml-js-types) for
|
|
207
|
+
extra types.
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
Caveats
|
|
211
|
+
-------
|
|
212
|
+
|
|
213
|
+
Note, that you use arrays or objects as key in JS-YAML. JS does not allow objects
|
|
214
|
+
or arrays as keys, and stringifies (by calling `toString()` method) them at the
|
|
215
|
+
moment of adding them.
|
|
216
|
+
|
|
217
|
+
``` yaml
|
|
218
|
+
---
|
|
219
|
+
? [ foo, bar ]
|
|
220
|
+
: - baz
|
|
221
|
+
? { foo: bar }
|
|
222
|
+
: - baz
|
|
223
|
+
- baz
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
``` javascript
|
|
227
|
+
{ "foo,bar": ["baz"], "[object Object]": ["baz", "baz"] }
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Also, reading of properties on implicit block mapping keys is not supported yet.
|
|
231
|
+
So, the following YAML document cannot be loaded.
|
|
232
|
+
|
|
233
|
+
``` yaml
|
|
234
|
+
&anchor foo:
|
|
235
|
+
foo: bar
|
|
236
|
+
*anchor: duplicate key
|
|
237
|
+
baz: bat
|
|
238
|
+
*anchor: duplicate key
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
js-yaml for enterprise
|
|
243
|
+
----------------------
|
|
244
|
+
|
|
245
|
+
Available as part of the Tidelift Subscription
|
|
246
|
+
|
|
247
|
+
The maintainers of js-yaml and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-js-yaml?utm_source=npm-js-yaml&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
/*eslint-disable no-console*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var fs = require('fs');
|
|
10
|
+
var argparse = require('argparse');
|
|
11
|
+
var yaml = require('..');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var cli = new argparse.ArgumentParser({
|
|
18
|
+
prog: 'js-yaml',
|
|
19
|
+
add_help: true
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
cli.add_argument('-v', '--version', {
|
|
23
|
+
action: 'version',
|
|
24
|
+
version: require('../package.json').version
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
cli.add_argument('-c', '--compact', {
|
|
28
|
+
help: 'Display errors in compact mode',
|
|
29
|
+
action: 'store_true'
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// deprecated (not needed after we removed output colors)
|
|
33
|
+
// option suppressed, but not completely removed for compatibility
|
|
34
|
+
cli.add_argument('-j', '--to-json', {
|
|
35
|
+
help: argparse.SUPPRESS,
|
|
36
|
+
dest: 'json',
|
|
37
|
+
action: 'store_true'
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
cli.add_argument('-t', '--trace', {
|
|
41
|
+
help: 'Show stack trace on error',
|
|
42
|
+
action: 'store_true'
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
cli.add_argument('file', {
|
|
46
|
+
help: 'File to read, utf-8 encoded without BOM',
|
|
47
|
+
nargs: '?',
|
|
48
|
+
default: '-'
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
var options = cli.parse_args();
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
59
|
+
|
|
60
|
+
function readFile(filename, encoding, callback) {
|
|
61
|
+
if (options.file === '-') {
|
|
62
|
+
// read from stdin
|
|
63
|
+
|
|
64
|
+
var chunks = [];
|
|
65
|
+
|
|
66
|
+
process.stdin.on('data', function (chunk) {
|
|
67
|
+
chunks.push(chunk);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
process.stdin.on('end', function () {
|
|
71
|
+
return callback(null, Buffer.concat(chunks).toString(encoding));
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
fs.readFile(filename, encoding, callback);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
readFile(options.file, 'utf8', function (error, input) {
|
|
79
|
+
var output, isYaml;
|
|
80
|
+
|
|
81
|
+
if (error) {
|
|
82
|
+
if (error.code === 'ENOENT') {
|
|
83
|
+
console.error('File not found: ' + options.file);
|
|
84
|
+
process.exit(2);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
console.error(
|
|
88
|
+
options.trace && error.stack ||
|
|
89
|
+
error.message ||
|
|
90
|
+
String(error));
|
|
91
|
+
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
output = JSON.parse(input);
|
|
97
|
+
isYaml = false;
|
|
98
|
+
} catch (err) {
|
|
99
|
+
if (err instanceof SyntaxError) {
|
|
100
|
+
try {
|
|
101
|
+
output = [];
|
|
102
|
+
yaml.loadAll(input, function (doc) { output.push(doc); }, {});
|
|
103
|
+
isYaml = true;
|
|
104
|
+
|
|
105
|
+
if (output.length === 0) output = null;
|
|
106
|
+
else if (output.length === 1) output = output[0];
|
|
107
|
+
|
|
108
|
+
} catch (e) {
|
|
109
|
+
if (options.trace && err.stack) console.error(e.stack);
|
|
110
|
+
else console.error(e.toString(options.compact));
|
|
111
|
+
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
console.error(
|
|
116
|
+
options.trace && err.stack ||
|
|
117
|
+
err.message ||
|
|
118
|
+
String(err));
|
|
119
|
+
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (isYaml) console.log(JSON.stringify(output, null, ' '));
|
|
125
|
+
else console.log(yaml.dump(output));
|
|
126
|
+
});
|