projen 0.99.71 → 0.99.73
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/.jsii +3 -3
- package/lib/ai-instructions.js +2 -2
- package/lib/awscdk/auto-discover.js +6 -6
- package/lib/awscdk/awscdk-app-java.js +1 -1
- package/lib/awscdk/awscdk-app-py.js +1 -1
- package/lib/awscdk/awscdk-app-ts.js +1 -1
- package/lib/awscdk/awscdk-construct.js +2 -2
- package/lib/awscdk/awscdk-deps-java.js +1 -1
- package/lib/awscdk/awscdk-deps-js.js +1 -1
- package/lib/awscdk/awscdk-deps-py.js +1 -1
- package/lib/awscdk/awscdk-deps.js +1 -1
- package/lib/awscdk/cdk-config.js +4 -4
- package/lib/awscdk/cdk-tasks.js +1 -1
- package/lib/awscdk/integration-test.js +1 -1
- package/lib/awscdk/lambda-extension.js +1 -1
- package/lib/awscdk/lambda-function.js +2 -2
- package/lib/awscdk/private/feature-flags-v2.const.d.ts +1 -1
- package/lib/awscdk/private/feature-flags-v2.const.js +2 -2
- package/lib/build/build-workflow.js +1 -1
- package/lib/cdk/auto-discover-base.js +2 -2
- package/lib/cdk/construct-lib.js +1 -1
- package/lib/cdk/integration-test-base.js +1 -1
- package/lib/cdk/jsii-build.js +1 -1
- package/lib/cdk/jsii-docgen.js +1 -1
- package/lib/cdk/jsii-project.js +1 -1
- package/lib/cdk8s/auto-discover.js +2 -2
- package/lib/cdk8s/cdk8s-app-py.js +1 -1
- package/lib/cdk8s/cdk8s-app-ts.js +1 -1
- package/lib/cdk8s/cdk8s-construct.js +1 -1
- package/lib/cdk8s/cdk8s-deps-py.js +1 -1
- package/lib/cdk8s/cdk8s-deps.js +1 -1
- package/lib/cdk8s/integration-test.js +1 -1
- package/lib/cdktf/cdktf-construct.js +1 -1
- package/lib/circleci/circleci.js +1 -1
- package/lib/component.js +1 -1
- package/lib/dependencies.js +1 -1
- package/lib/dev-env.js +1 -1
- package/lib/docker-compose/docker-compose-service.js +1 -1
- package/lib/docker-compose/docker-compose.js +1 -1
- package/lib/file.js +1 -1
- package/lib/gitattributes.js +1 -1
- package/lib/github/actions-provider.js +1 -1
- package/lib/github/auto-approve.js +1 -1
- package/lib/github/auto-merge.js +1 -1
- package/lib/github/auto-queue.js +1 -1
- package/lib/github/dependabot.js +1 -1
- package/lib/github/dependency-review.js +1 -1
- package/lib/github/github-credentials.js +1 -1
- package/lib/github/github-project.js +1 -1
- package/lib/github/github.js +1 -1
- package/lib/github/merge-queue.js +1 -1
- package/lib/github/mergify.js +1 -1
- package/lib/github/pr-template.js +1 -1
- package/lib/github/pull-request-backport.js +1 -1
- package/lib/github/pull-request-lint.js +1 -1
- package/lib/github/stale.js +1 -1
- package/lib/github/task-workflow-job.js +1 -1
- package/lib/github/task-workflow.js +1 -1
- package/lib/github/workflow-actions.js +1 -1
- package/lib/github/workflow-jobs.js +1 -1
- package/lib/github/workflow-steps.js +1 -1
- package/lib/github/workflows.js +1 -1
- package/lib/gitlab/configuration.js +1 -1
- package/lib/gitlab/gitlab-configuration.js +1 -1
- package/lib/gitlab/nested-configuration.js +1 -1
- package/lib/gitpod.js +1 -1
- package/lib/ignore-file.js +1 -1
- package/lib/ini.js +1 -1
- package/lib/java/java-project.js +1 -1
- package/lib/java/junit.js +1 -1
- package/lib/java/maven-compile.js +1 -1
- package/lib/java/maven-packaging.js +1 -1
- package/lib/java/maven-sample.js +1 -1
- package/lib/java/pom.js +2 -2
- package/lib/java/projenrc.js +1 -1
- package/lib/javascript/biome/biome.js +1 -1
- package/lib/javascript/bundler.js +1 -1
- package/lib/javascript/eslint.js +1 -1
- package/lib/javascript/jest.js +4 -4
- package/lib/javascript/license-checker.js +1 -1
- package/lib/javascript/node-package.js +1 -1
- package/lib/javascript/node-project.js +1 -1
- package/lib/javascript/npm-config.js +1 -1
- package/lib/javascript/prettier.js +1 -1
- package/lib/javascript/projenrc.js +1 -1
- package/lib/javascript/typescript-config.js +2 -2
- package/lib/javascript/upgrade-dependencies.js +2 -2
- package/lib/javascript/yarnrc.js +1 -1
- package/lib/json-patch.js +1 -1
- package/lib/json.js +1 -1
- package/lib/license.js +1 -1
- package/lib/logger.js +1 -1
- package/lib/makefile.js +1 -1
- package/lib/object-file.js +1 -1
- package/lib/project-build.js +1 -1
- package/lib/project-tree.js +1 -1
- package/lib/project.js +1 -1
- package/lib/projects.js +1 -1
- package/lib/projenrc-json.js +2 -2
- package/lib/projenrc.js +1 -1
- package/lib/python/pip.js +1 -1
- package/lib/python/poetry.js +2 -2
- package/lib/python/projenrc.js +1 -1
- package/lib/python/pyproject-toml-file.js +1 -1
- package/lib/python/pytest-sample.js +1 -1
- package/lib/python/pytest.js +1 -1
- package/lib/python/python-project.js +1 -1
- package/lib/python/python-sample.js +1 -1
- package/lib/python/requirements-file.js +1 -1
- package/lib/python/setuppy.js +1 -1
- package/lib/python/setuptools.js +1 -1
- package/lib/python/uv.js +1 -1
- package/lib/python/venv.js +1 -1
- package/lib/readme.js +1 -1
- package/lib/release/publisher.js +1 -1
- package/lib/release/release-trigger.js +1 -1
- package/lib/release/release.js +1 -1
- package/lib/renovatebot.js +1 -1
- package/lib/sample-file.js +2 -2
- package/lib/semver.js +1 -1
- package/lib/source-code.js +1 -1
- package/lib/task-runtime.js +1 -1
- package/lib/task.js +1 -1
- package/lib/tasks.js +1 -1
- package/lib/testing.js +1 -1
- package/lib/textfile.js +1 -1
- package/lib/toml.js +1 -1
- package/lib/typescript/projenrc-ts.js +1 -1
- package/lib/typescript/projenrc.js +1 -1
- package/lib/typescript/typescript-typedoc.js +1 -1
- package/lib/typescript/typescript.js +6 -6
- package/lib/version.js +2 -2
- package/lib/vscode/devcontainer.js +1 -1
- package/lib/vscode/extensions.js +1 -1
- package/lib/vscode/launch-config.js +1 -1
- package/lib/vscode/settings.js +1 -1
- package/lib/vscode/vscode.js +1 -1
- package/lib/web/next.js +3 -3
- package/lib/web/postcss.js +1 -1
- package/lib/web/react.js +4 -4
- package/lib/web/tailwind.js +1 -1
- package/lib/xmlfile.js +1 -1
- package/lib/yaml.js +1 -1
- package/node_modules/{shelljs/node_modules/cross-spawn → cross-spawn}/README.md +10 -15
- package/node_modules/{shelljs/node_modules/cross-spawn → cross-spawn}/lib/enoent.js +1 -1
- package/node_modules/{shelljs/node_modules/cross-spawn → cross-spawn}/lib/parse.js +1 -35
- package/node_modules/{shelljs/node_modules/cross-spawn → cross-spawn}/lib/util/readShebang.js +1 -10
- package/node_modules/{shelljs/node_modules/cross-spawn → cross-spawn}/lib/util/resolveCommand.js +4 -3
- package/node_modules/{shelljs/node_modules/cross-spawn → cross-spawn}/package.json +23 -25
- package/node_modules/execa/index.d.ts +564 -0
- package/node_modules/execa/index.js +268 -0
- package/node_modules/execa/lib/command.js +52 -0
- package/node_modules/execa/lib/error.js +88 -0
- package/node_modules/execa/lib/kill.js +115 -0
- package/node_modules/execa/lib/promise.js +46 -0
- package/node_modules/execa/lib/stdio.js +52 -0
- package/node_modules/execa/lib/stream.js +97 -0
- package/node_modules/execa/license +9 -0
- package/node_modules/execa/package.json +74 -0
- package/node_modules/execa/readme.md +663 -0
- package/node_modules/fastq/README.md +0 -2
- package/node_modules/fastq/eslint.config.js +11 -0
- package/node_modules/fastq/example.mjs +0 -2
- package/node_modules/fastq/index.d.ts +2 -0
- package/node_modules/fastq/package.json +5 -9
- package/node_modules/fastq/queue.js +36 -1
- package/node_modules/fastq/test/promise.js +34 -0
- package/node_modules/fastq/test/test.js +80 -0
- package/node_modules/get-stream/buffer-stream.js +52 -0
- package/node_modules/get-stream/index.d.ts +105 -0
- package/node_modules/get-stream/index.js +61 -0
- package/node_modules/get-stream/license +9 -0
- package/node_modules/{shelljs/node_modules/get-stream → get-stream}/package.json +11 -10
- package/node_modules/{shelljs/node_modules/get-stream → get-stream}/readme.md +19 -18
- package/node_modules/human-signals/LICENSE +201 -0
- package/node_modules/human-signals/README.md +165 -0
- package/node_modules/human-signals/build/src/core.js +273 -0
- package/node_modules/human-signals/build/src/core.js.map +1 -0
- package/node_modules/human-signals/build/src/main.d.ts +52 -0
- package/node_modules/human-signals/build/src/main.js +71 -0
- package/node_modules/human-signals/build/src/main.js.map +1 -0
- package/node_modules/human-signals/build/src/realtime.js +19 -0
- package/node_modules/human-signals/build/src/realtime.js.map +1 -0
- package/node_modules/human-signals/build/src/signals.js +35 -0
- package/node_modules/human-signals/build/src/signals.js.map +1 -0
- package/node_modules/human-signals/package.json +64 -0
- package/node_modules/is-stream/index.d.ts +79 -0
- package/node_modules/is-stream/index.js +28 -0
- package/node_modules/is-stream/license +9 -0
- package/node_modules/is-stream/package.json +42 -0
- package/node_modules/is-stream/readme.md +60 -0
- package/node_modules/js-yaml/README.md +4 -20
- package/node_modules/js-yaml/bin/js-yaml.js +53 -62
- package/node_modules/js-yaml/dist/js-yaml.js +2404 -3880
- package/node_modules/js-yaml/dist/js-yaml.js.map +1 -0
- package/node_modules/js-yaml/dist/js-yaml.min.js +33 -2
- package/node_modules/js-yaml/dist/js-yaml.min.js.map +1 -0
- package/node_modules/js-yaml/dist/js-yaml.mjs +2381 -3855
- package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -0
- package/node_modules/js-yaml/index.js +32 -35
- package/node_modules/js-yaml/lib/common.js +28 -37
- package/node_modules/js-yaml/lib/dumper.js +450 -478
- package/node_modules/js-yaml/lib/exception.js +23 -27
- package/node_modules/js-yaml/lib/index_vite_proxy.tmp.mjs +37 -0
- package/node_modules/js-yaml/lib/loader.js +927 -866
- package/node_modules/js-yaml/lib/schema/core.js +2 -4
- package/node_modules/js-yaml/lib/schema/default.js +2 -4
- package/node_modules/js-yaml/lib/schema/failsafe.js +3 -6
- package/node_modules/js-yaml/lib/schema/json.js +2 -4
- package/node_modules/js-yaml/lib/schema.js +56 -68
- package/node_modules/js-yaml/lib/snippet.js +47 -52
- package/node_modules/js-yaml/lib/type/binary.js +61 -64
- package/node_modules/js-yaml/lib/type/bool.js +14 -14
- package/node_modules/js-yaml/lib/type/float.js +47 -45
- package/node_modules/js-yaml/lib/type/int.js +65 -79
- package/node_modules/js-yaml/lib/type/map.js +4 -4
- package/node_modules/js-yaml/lib/type/merge.js +5 -5
- package/node_modules/js-yaml/lib/type/null.js +16 -16
- package/node_modules/js-yaml/lib/type/omap.js +22 -21
- package/node_modules/js-yaml/lib/type/pairs.js +24 -27
- package/node_modules/js-yaml/lib/type/seq.js +4 -4
- package/node_modules/js-yaml/lib/type/set.js +12 -12
- package/node_modules/js-yaml/lib/type/str.js +4 -4
- package/node_modules/js-yaml/lib/type/timestamp.js +53 -53
- package/node_modules/js-yaml/lib/type.js +30 -30
- package/node_modules/js-yaml/package.json +32 -21
- package/node_modules/{nice-try → merge-stream}/LICENSE +1 -1
- package/node_modules/merge-stream/README.md +78 -0
- package/node_modules/merge-stream/index.js +41 -0
- package/node_modules/merge-stream/package.json +19 -0
- package/node_modules/mimic-fn/index.d.ts +54 -0
- package/node_modules/mimic-fn/index.js +13 -0
- package/node_modules/mimic-fn/package.json +42 -0
- package/node_modules/mimic-fn/readme.md +69 -0
- package/node_modules/npm-run-path/index.d.ts +89 -0
- package/node_modules/npm-run-path/index.js +47 -0
- package/node_modules/npm-run-path/package.json +44 -0
- package/node_modules/{shelljs/node_modules/npm-run-path → npm-run-path}/readme.md +39 -5
- package/node_modules/onetime/index.d.ts +64 -0
- package/node_modules/onetime/index.js +44 -0
- package/node_modules/onetime/license +9 -0
- package/node_modules/onetime/package.json +43 -0
- package/node_modules/onetime/readme.md +94 -0
- package/node_modules/path-key/index.d.ts +40 -0
- package/node_modules/path-key/index.js +16 -0
- package/node_modules/path-key/license +9 -0
- package/node_modules/path-key/package.json +39 -0
- package/node_modules/{shelljs/node_modules/path-key → path-key}/readme.md +15 -5
- package/node_modules/semver/classes/range.js +11 -2
- package/node_modules/semver/package.json +2 -2
- package/node_modules/shebang-command/index.js +19 -0
- package/node_modules/shebang-command/license +9 -0
- package/node_modules/shebang-command/package.json +34 -0
- package/node_modules/{shelljs/node_modules/shebang-command → shebang-command}/readme.md +1 -6
- package/node_modules/shebang-regex/index.d.ts +22 -0
- package/node_modules/shebang-regex/index.js +2 -0
- package/node_modules/shebang-regex/license +9 -0
- package/node_modules/shebang-regex/package.json +35 -0
- package/node_modules/shebang-regex/readme.md +33 -0
- package/node_modules/shelljs/README.md +7 -1
- package/node_modules/shelljs/global.js +4 -1
- package/node_modules/shelljs/package.json +8 -13
- package/node_modules/shelljs/shell.js +9 -7
- package/node_modules/shelljs/src/cat.js +1 -1
- package/node_modules/shelljs/src/chmod.js +1 -1
- package/node_modules/shelljs/src/cmd.js +25 -9
- package/node_modules/shelljs/src/common.js +11 -8
- package/node_modules/shelljs/src/dirs.js +1 -1
- package/node_modules/shelljs/src/exec.js +6 -6
- package/node_modules/shelljs/src/grep.js +121 -7
- package/node_modules/shelljs/src/head.js +1 -1
- package/node_modules/shelljs/src/ls.js +1 -1
- package/node_modules/shelljs/src/mkdir.js +1 -1
- package/node_modules/shelljs/src/rm.js +1 -1
- package/node_modules/shelljs/src/sed.js +1 -1
- package/node_modules/shelljs/src/sort.js +1 -1
- package/node_modules/shelljs/src/tail.js +1 -1
- package/node_modules/shelljs/src/tempdir.js +1 -1
- package/node_modules/shelljs/src/test.js +1 -1
- package/node_modules/shelljs/src/to.js +1 -1
- package/node_modules/shelljs/src/toEnd.js +1 -1
- package/node_modules/shelljs/src/touch.js +1 -1
- package/node_modules/shelljs/src/uniq.js +1 -1
- package/node_modules/shelljs/src/which.js +1 -1
- package/node_modules/strip-final-newline/index.js +16 -0
- package/node_modules/strip-final-newline/license +9 -0
- package/node_modules/strip-final-newline/package.json +40 -0
- package/node_modules/strip-final-newline/readme.md +30 -0
- package/node_modules/{shelljs/node_modules/which → which}/README.md +3 -0
- package/node_modules/which/package.json +43 -0
- package/node_modules/which/which.js +125 -0
- package/package.json +5 -2
- package/node_modules/end-of-stream/LICENSE +0 -21
- package/node_modules/end-of-stream/README.md +0 -54
- package/node_modules/end-of-stream/index.js +0 -96
- package/node_modules/end-of-stream/package.json +0 -37
- package/node_modules/fastq/.github/dependabot.yml +0 -11
- package/node_modules/fastq/.github/workflows/ci.yml +0 -75
- package/node_modules/function-bind/.eslintrc +0 -21
- package/node_modules/function-bind/.github/FUNDING.yml +0 -12
- package/node_modules/function-bind/.github/SECURITY.md +0 -3
- package/node_modules/function-bind/.nycrc +0 -13
- package/node_modules/function-bind/CHANGELOG.md +0 -136
- package/node_modules/function-bind/LICENSE +0 -20
- package/node_modules/function-bind/README.md +0 -46
- package/node_modules/function-bind/implementation.js +0 -84
- package/node_modules/function-bind/index.js +0 -5
- package/node_modules/function-bind/package.json +0 -87
- package/node_modules/function-bind/test/.eslintrc +0 -9
- package/node_modules/function-bind/test/index.js +0 -252
- package/node_modules/hasown/.eslintrc +0 -5
- package/node_modules/hasown/.github/FUNDING.yml +0 -12
- package/node_modules/hasown/.nycrc +0 -13
- package/node_modules/hasown/CHANGELOG.md +0 -40
- package/node_modules/hasown/LICENSE +0 -21
- package/node_modules/hasown/README.md +0 -40
- package/node_modules/hasown/index.d.ts +0 -3
- package/node_modules/hasown/index.js +0 -8
- package/node_modules/hasown/package.json +0 -92
- package/node_modules/hasown/tsconfig.json +0 -6
- package/node_modules/interpret/LICENSE +0 -22
- package/node_modules/interpret/README.md +0 -187
- package/node_modules/interpret/index.js +0 -168
- package/node_modules/interpret/mjs-stub.js +0 -1
- package/node_modules/interpret/package.json +0 -75
- package/node_modules/is-core-module/.eslintrc +0 -18
- package/node_modules/is-core-module/.nycrc +0 -9
- package/node_modules/is-core-module/CHANGELOG.md +0 -218
- package/node_modules/is-core-module/LICENSE +0 -20
- package/node_modules/is-core-module/README.md +0 -40
- package/node_modules/is-core-module/core.json +0 -162
- package/node_modules/is-core-module/index.js +0 -69
- package/node_modules/is-core-module/package.json +0 -76
- package/node_modules/is-core-module/test/index.js +0 -157
- package/node_modules/nice-try/README.md +0 -32
- package/node_modules/nice-try/package.json +0 -33
- package/node_modules/nice-try/src/index.js +0 -12
- package/node_modules/once/README.md +0 -79
- package/node_modules/once/once.js +0 -42
- package/node_modules/once/package.json +0 -33
- package/node_modules/p-finally/index.js +0 -15
- package/node_modules/p-finally/license +0 -21
- package/node_modules/p-finally/package.json +0 -42
- package/node_modules/p-finally/readme.md +0 -47
- package/node_modules/path-parse/LICENSE +0 -21
- package/node_modules/path-parse/README.md +0 -42
- package/node_modules/path-parse/index.js +0 -75
- package/node_modules/path-parse/package.json +0 -33
- package/node_modules/pump/.github/FUNDING.yml +0 -2
- package/node_modules/pump/.travis.yml +0 -5
- package/node_modules/pump/LICENSE +0 -21
- package/node_modules/pump/README.md +0 -74
- package/node_modules/pump/SECURITY.md +0 -5
- package/node_modules/pump/index.js +0 -86
- package/node_modules/pump/package.json +0 -24
- package/node_modules/pump/test-browser.js +0 -66
- package/node_modules/pump/test-node.js +0 -53
- package/node_modules/rechoir/.npmignore +0 -1
- package/node_modules/rechoir/.travis.yml +0 -24
- package/node_modules/rechoir/CHANGELOG +0 -38
- package/node_modules/rechoir/LICENSE +0 -22
- package/node_modules/rechoir/README.md +0 -42
- package/node_modules/rechoir/index.js +0 -59
- package/node_modules/rechoir/lib/extension.js +0 -11
- package/node_modules/rechoir/lib/normalize.js +0 -15
- package/node_modules/rechoir/lib/register.js +0 -15
- package/node_modules/rechoir/package.json +0 -88
- package/node_modules/resolve/.editorconfig +0 -37
- package/node_modules/resolve/.eslintrc +0 -65
- package/node_modules/resolve/.github/FUNDING.yml +0 -12
- package/node_modules/resolve/.github/INCIDENT_RESPONSE_PROCESS.md +0 -119
- package/node_modules/resolve/.github/THREAT_MODEL.md +0 -74
- package/node_modules/resolve/LICENSE +0 -21
- package/node_modules/resolve/SECURITY.md +0 -11
- package/node_modules/resolve/async.js +0 -3
- package/node_modules/resolve/bin/resolve +0 -50
- package/node_modules/resolve/example/async.js +0 -5
- package/node_modules/resolve/example/sync.js +0 -3
- package/node_modules/resolve/index.js +0 -6
- package/node_modules/resolve/lib/async.js +0 -333
- package/node_modules/resolve/lib/caller.js +0 -8
- package/node_modules/resolve/lib/core.js +0 -12
- package/node_modules/resolve/lib/core.json +0 -162
- package/node_modules/resolve/lib/homedir.js +0 -24
- package/node_modules/resolve/lib/is-core.js +0 -5
- package/node_modules/resolve/lib/node-modules-paths.js +0 -45
- package/node_modules/resolve/lib/normalize-options.js +0 -10
- package/node_modules/resolve/lib/sync.js +0 -212
- package/node_modules/resolve/package.json +0 -75
- package/node_modules/resolve/readme.markdown +0 -301
- package/node_modules/resolve/sync.js +0 -3
- package/node_modules/resolve/test/core.js +0 -88
- package/node_modules/resolve/test/dotdot/abc/index.js +0 -2
- package/node_modules/resolve/test/dotdot/index.js +0 -1
- package/node_modules/resolve/test/dotdot.js +0 -29
- package/node_modules/resolve/test/faulty_basedir.js +0 -29
- package/node_modules/resolve/test/filter.js +0 -34
- package/node_modules/resolve/test/filter_sync.js +0 -33
- package/node_modules/resolve/test/home_paths.js +0 -127
- package/node_modules/resolve/test/home_paths_sync.js +0 -114
- package/node_modules/resolve/test/mock.js +0 -315
- package/node_modules/resolve/test/mock_sync.js +0 -214
- package/node_modules/resolve/test/module_dir/xmodules/aaa/index.js +0 -1
- package/node_modules/resolve/test/module_dir/ymodules/aaa/index.js +0 -1
- package/node_modules/resolve/test/module_dir/zmodules/bbb/main.js +0 -1
- package/node_modules/resolve/test/module_dir/zmodules/bbb/package.json +0 -3
- package/node_modules/resolve/test/module_dir.js +0 -56
- package/node_modules/resolve/test/node-modules-paths.js +0 -143
- package/node_modules/resolve/test/node_path/x/aaa/index.js +0 -1
- package/node_modules/resolve/test/node_path/x/ccc/index.js +0 -1
- package/node_modules/resolve/test/node_path/y/bbb/index.js +0 -1
- package/node_modules/resolve/test/node_path/y/ccc/index.js +0 -1
- package/node_modules/resolve/test/node_path.js +0 -70
- package/node_modules/resolve/test/nonstring.js +0 -9
- package/node_modules/resolve/test/pathfilter/deep_ref/main.js +0 -0
- package/node_modules/resolve/test/pathfilter.js +0 -75
- package/node_modules/resolve/test/precedence/aaa/index.js +0 -1
- package/node_modules/resolve/test/precedence/aaa/main.js +0 -1
- package/node_modules/resolve/test/precedence/aaa.js +0 -1
- package/node_modules/resolve/test/precedence/bbb/main.js +0 -1
- package/node_modules/resolve/test/precedence/bbb.js +0 -1
- package/node_modules/resolve/test/precedence.js +0 -23
- package/node_modules/resolve/test/resolver/baz/doom.js +0 -0
- package/node_modules/resolve/test/resolver/baz/package.json +0 -4
- package/node_modules/resolve/test/resolver/baz/quux.js +0 -1
- package/node_modules/resolve/test/resolver/browser_field/a.js +0 -0
- package/node_modules/resolve/test/resolver/browser_field/b.js +0 -0
- package/node_modules/resolve/test/resolver/browser_field/package.json +0 -5
- package/node_modules/resolve/test/resolver/cup.coffee +0 -1
- package/node_modules/resolve/test/resolver/dot_main/index.js +0 -1
- package/node_modules/resolve/test/resolver/dot_main/package.json +0 -3
- package/node_modules/resolve/test/resolver/dot_slash_main/index.js +0 -1
- package/node_modules/resolve/test/resolver/dot_slash_main/package.json +0 -3
- package/node_modules/resolve/test/resolver/false_main/index.js +0 -0
- package/node_modules/resolve/test/resolver/false_main/package.json +0 -4
- package/node_modules/resolve/test/resolver/foo.js +0 -1
- package/node_modules/resolve/test/resolver/incorrect_main/index.js +0 -2
- package/node_modules/resolve/test/resolver/incorrect_main/package.json +0 -3
- package/node_modules/resolve/test/resolver/invalid_main/package.json +0 -7
- package/node_modules/resolve/test/resolver/mug.coffee +0 -0
- package/node_modules/resolve/test/resolver/mug.js +0 -0
- package/node_modules/resolve/test/resolver/multirepo/lerna.json +0 -6
- package/node_modules/resolve/test/resolver/multirepo/package.json +0 -20
- package/node_modules/resolve/test/resolver/multirepo/packages/package-a/index.js +0 -35
- package/node_modules/resolve/test/resolver/multirepo/packages/package-a/package.json +0 -14
- package/node_modules/resolve/test/resolver/multirepo/packages/package-b/index.js +0 -0
- package/node_modules/resolve/test/resolver/multirepo/packages/package-b/package.json +0 -14
- package/node_modules/resolve/test/resolver/nested_symlinks/mylib/async.js +0 -26
- package/node_modules/resolve/test/resolver/nested_symlinks/mylib/package.json +0 -15
- package/node_modules/resolve/test/resolver/nested_symlinks/mylib/sync.js +0 -12
- package/node_modules/resolve/test/resolver/other_path/lib/other-lib.js +0 -0
- package/node_modules/resolve/test/resolver/other_path/root.js +0 -0
- package/node_modules/resolve/test/resolver/quux/foo/index.js +0 -1
- package/node_modules/resolve/test/resolver/same_names/foo/index.js +0 -1
- package/node_modules/resolve/test/resolver/same_names/foo.js +0 -1
- package/node_modules/resolve/test/resolver/symlinked/_/node_modules/foo.js +0 -0
- package/node_modules/resolve/test/resolver/symlinked/_/symlink_target/.gitkeep +0 -0
- package/node_modules/resolve/test/resolver/symlinked/package/bar.js +0 -1
- package/node_modules/resolve/test/resolver/symlinked/package/package.json +0 -3
- package/node_modules/resolve/test/resolver/without_basedir/main.js +0 -5
- package/node_modules/resolve/test/resolver.js +0 -597
- package/node_modules/resolve/test/resolver_sync.js +0 -730
- package/node_modules/resolve/test/shadowed_core/node_modules/util/index.js +0 -0
- package/node_modules/resolve/test/shadowed_core.js +0 -54
- package/node_modules/resolve/test/subdirs.js +0 -13
- package/node_modules/resolve/test/symlinks.js +0 -176
- package/node_modules/shelljs/bin/shjs +0 -48
- package/node_modules/shelljs/node_modules/execa/index.js +0 -361
- package/node_modules/shelljs/node_modules/execa/lib/errname.js +0 -39
- package/node_modules/shelljs/node_modules/execa/lib/stdio.js +0 -41
- package/node_modules/shelljs/node_modules/execa/package.json +0 -69
- package/node_modules/shelljs/node_modules/execa/readme.md +0 -327
- package/node_modules/shelljs/node_modules/get-stream/buffer-stream.js +0 -51
- package/node_modules/shelljs/node_modules/get-stream/index.js +0 -50
- package/node_modules/shelljs/node_modules/is-stream/index.js +0 -21
- package/node_modules/shelljs/node_modules/is-stream/license +0 -21
- package/node_modules/shelljs/node_modules/is-stream/package.json +0 -38
- package/node_modules/shelljs/node_modules/is-stream/readme.md +0 -42
- package/node_modules/shelljs/node_modules/npm-run-path/index.js +0 -39
- package/node_modules/shelljs/node_modules/npm-run-path/license +0 -21
- package/node_modules/shelljs/node_modules/npm-run-path/package.json +0 -45
- package/node_modules/shelljs/node_modules/path-key/index.js +0 -13
- package/node_modules/shelljs/node_modules/path-key/license +0 -21
- package/node_modules/shelljs/node_modules/path-key/package.json +0 -39
- package/node_modules/shelljs/node_modules/semver/LICENSE +0 -15
- package/node_modules/shelljs/node_modules/semver/README.md +0 -412
- package/node_modules/shelljs/node_modules/semver/bin/semver +0 -160
- package/node_modules/shelljs/node_modules/semver/package.json +0 -38
- package/node_modules/shelljs/node_modules/semver/range.bnf +0 -16
- package/node_modules/shelljs/node_modules/semver/semver.js +0 -1525
- package/node_modules/shelljs/node_modules/shebang-command/index.js +0 -19
- package/node_modules/shelljs/node_modules/shebang-command/license +0 -21
- package/node_modules/shelljs/node_modules/shebang-command/package.json +0 -39
- package/node_modules/shelljs/node_modules/shebang-regex/index.js +0 -2
- package/node_modules/shelljs/node_modules/shebang-regex/license +0 -21
- package/node_modules/shelljs/node_modules/shebang-regex/package.json +0 -32
- package/node_modules/shelljs/node_modules/shebang-regex/readme.md +0 -29
- package/node_modules/shelljs/node_modules/which/LICENSE +0 -15
- package/node_modules/shelljs/node_modules/which/package.json +0 -30
- package/node_modules/shelljs/node_modules/which/which.js +0 -135
- package/node_modules/strip-eof/index.js +0 -15
- package/node_modules/strip-eof/license +0 -21
- package/node_modules/strip-eof/package.json +0 -39
- package/node_modules/strip-eof/readme.md +0 -28
- package/node_modules/supports-preserve-symlinks-flag/.eslintrc +0 -14
- package/node_modules/supports-preserve-symlinks-flag/.github/FUNDING.yml +0 -12
- package/node_modules/supports-preserve-symlinks-flag/.nycrc +0 -9
- package/node_modules/supports-preserve-symlinks-flag/CHANGELOG.md +0 -22
- package/node_modules/supports-preserve-symlinks-flag/LICENSE +0 -21
- package/node_modules/supports-preserve-symlinks-flag/README.md +0 -42
- package/node_modules/supports-preserve-symlinks-flag/browser.js +0 -3
- package/node_modules/supports-preserve-symlinks-flag/index.js +0 -9
- package/node_modules/supports-preserve-symlinks-flag/package.json +0 -70
- package/node_modules/supports-preserve-symlinks-flag/test/index.js +0 -29
- package/node_modules/wrappy/LICENSE +0 -15
- package/node_modules/wrappy/README.md +0 -36
- package/node_modules/wrappy/package.json +0 -29
- package/node_modules/wrappy/wrappy.js +0 -33
- /package/node_modules/{shelljs/node_modules/cross-spawn → cross-spawn}/LICENSE +0 -0
- /package/node_modules/{shelljs/node_modules/cross-spawn → cross-spawn}/index.js +0 -0
- /package/node_modules/{shelljs/node_modules/cross-spawn → cross-spawn}/lib/util/escape.js +0 -0
- /package/node_modules/{picomatch → micromatch/node_modules/picomatch}/LICENSE +0 -0
- /package/node_modules/{picomatch → micromatch/node_modules/picomatch}/README.md +0 -0
- /package/node_modules/{picomatch → micromatch/node_modules/picomatch}/index.js +0 -0
- /package/node_modules/{picomatch → micromatch/node_modules/picomatch}/lib/constants.js +0 -0
- /package/node_modules/{picomatch → micromatch/node_modules/picomatch}/lib/parse.js +0 -0
- /package/node_modules/{picomatch → micromatch/node_modules/picomatch}/lib/picomatch.js +0 -0
- /package/node_modules/{picomatch → micromatch/node_modules/picomatch}/lib/scan.js +0 -0
- /package/node_modules/{picomatch → micromatch/node_modules/picomatch}/lib/utils.js +0 -0
- /package/node_modules/{picomatch → micromatch/node_modules/picomatch}/package.json +0 -0
- /package/node_modules/{shelljs/node_modules/execa → mimic-fn}/license +0 -0
- /package/node_modules/{shelljs/node_modules/get-stream → npm-run-path}/license +0 -0
- /package/node_modules/{once → which}/LICENSE +0 -0
- /package/node_modules/{shelljs/node_modules/which/bin/which → which/bin/node-which} +0 -0
|
@@ -1,202 +1,195 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
ESCAPE_SEQUENCES[
|
|
41
|
-
ESCAPE_SEQUENCES[
|
|
42
|
-
ESCAPE_SEQUENCES[
|
|
43
|
-
ESCAPE_SEQUENCES[
|
|
44
|
-
ESCAPE_SEQUENCES[
|
|
45
|
-
ESCAPE_SEQUENCES[
|
|
46
|
-
ESCAPE_SEQUENCES[
|
|
47
|
-
ESCAPE_SEQUENCES[
|
|
48
|
-
ESCAPE_SEQUENCES[
|
|
49
|
-
ESCAPE_SEQUENCES[
|
|
50
|
-
ESCAPE_SEQUENCES[
|
|
51
|
-
ESCAPE_SEQUENCES[
|
|
52
|
-
ESCAPE_SEQUENCES[
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const common = require('./common')
|
|
4
|
+
const YAMLException = require('./exception')
|
|
5
|
+
const DEFAULT_SCHEMA = require('./schema/default')
|
|
6
|
+
|
|
7
|
+
const _toString = Object.prototype.toString
|
|
8
|
+
const _hasOwnProperty = Object.prototype.hasOwnProperty
|
|
9
|
+
|
|
10
|
+
const CHAR_BOM = 0xFEFF
|
|
11
|
+
const CHAR_TAB = 0x09 /* Tab */
|
|
12
|
+
const CHAR_LINE_FEED = 0x0A /* LF */
|
|
13
|
+
const CHAR_CARRIAGE_RETURN = 0x0D /* CR */
|
|
14
|
+
const CHAR_SPACE = 0x20 /* Space */
|
|
15
|
+
const CHAR_EXCLAMATION = 0x21 /* ! */
|
|
16
|
+
const CHAR_DOUBLE_QUOTE = 0x22 /* " */
|
|
17
|
+
const CHAR_SHARP = 0x23 /* # */
|
|
18
|
+
const CHAR_PERCENT = 0x25 /* % */
|
|
19
|
+
const CHAR_AMPERSAND = 0x26 /* & */
|
|
20
|
+
const CHAR_SINGLE_QUOTE = 0x27 /* ' */
|
|
21
|
+
const CHAR_ASTERISK = 0x2A /* * */
|
|
22
|
+
const CHAR_COMMA = 0x2C /* , */
|
|
23
|
+
const CHAR_MINUS = 0x2D /* - */
|
|
24
|
+
const CHAR_COLON = 0x3A /* : */
|
|
25
|
+
const CHAR_EQUALS = 0x3D /* = */
|
|
26
|
+
const CHAR_GREATER_THAN = 0x3E /* > */
|
|
27
|
+
const CHAR_QUESTION = 0x3F /* ? */
|
|
28
|
+
const CHAR_COMMERCIAL_AT = 0x40 /* @ */
|
|
29
|
+
const CHAR_LEFT_SQUARE_BRACKET = 0x5B /* [ */
|
|
30
|
+
const CHAR_RIGHT_SQUARE_BRACKET = 0x5D /* ] */
|
|
31
|
+
const CHAR_GRAVE_ACCENT = 0x60 /* ` */
|
|
32
|
+
const CHAR_LEFT_CURLY_BRACKET = 0x7B /* { */
|
|
33
|
+
const CHAR_VERTICAL_LINE = 0x7C /* | */
|
|
34
|
+
const CHAR_RIGHT_CURLY_BRACKET = 0x7D /* } */
|
|
35
|
+
|
|
36
|
+
const ESCAPE_SEQUENCES = {}
|
|
37
|
+
|
|
38
|
+
ESCAPE_SEQUENCES[0x00] = '\\0'
|
|
39
|
+
ESCAPE_SEQUENCES[0x07] = '\\a'
|
|
40
|
+
ESCAPE_SEQUENCES[0x08] = '\\b'
|
|
41
|
+
ESCAPE_SEQUENCES[0x09] = '\\t'
|
|
42
|
+
ESCAPE_SEQUENCES[0x0A] = '\\n'
|
|
43
|
+
ESCAPE_SEQUENCES[0x0B] = '\\v'
|
|
44
|
+
ESCAPE_SEQUENCES[0x0C] = '\\f'
|
|
45
|
+
ESCAPE_SEQUENCES[0x0D] = '\\r'
|
|
46
|
+
ESCAPE_SEQUENCES[0x1B] = '\\e'
|
|
47
|
+
ESCAPE_SEQUENCES[0x22] = '\\"'
|
|
48
|
+
ESCAPE_SEQUENCES[0x5C] = '\\\\'
|
|
49
|
+
ESCAPE_SEQUENCES[0x85] = '\\N'
|
|
50
|
+
ESCAPE_SEQUENCES[0xA0] = '\\_'
|
|
51
|
+
ESCAPE_SEQUENCES[0x2028] = '\\L'
|
|
52
|
+
ESCAPE_SEQUENCES[0x2029] = '\\P'
|
|
53
|
+
|
|
54
|
+
const DEPRECATED_BOOLEANS_SYNTAX = [
|
|
57
55
|
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
|
58
56
|
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
|
59
|
-
]
|
|
57
|
+
]
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
const DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/
|
|
62
60
|
|
|
63
|
-
function compileStyleMap(schema, map) {
|
|
64
|
-
|
|
61
|
+
function compileStyleMap (schema, map) {
|
|
62
|
+
if (map === null) return {}
|
|
65
63
|
|
|
66
|
-
|
|
64
|
+
const result = {}
|
|
65
|
+
const keys = Object.keys(map)
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
72
|
-
tag = keys[index];
|
|
73
|
-
style = String(map[tag]);
|
|
67
|
+
for (let index = 0, length = keys.length; index < length; index += 1) {
|
|
68
|
+
let tag = keys[index]
|
|
69
|
+
let style = String(map[tag])
|
|
74
70
|
|
|
75
71
|
if (tag.slice(0, 2) === '!!') {
|
|
76
|
-
tag = 'tag:yaml.org,2002:' + tag.slice(2)
|
|
72
|
+
tag = 'tag:yaml.org,2002:' + tag.slice(2)
|
|
77
73
|
}
|
|
78
|
-
type = schema.compiledTypeMap['fallback'][tag]
|
|
74
|
+
const type = schema.compiledTypeMap['fallback'][tag]
|
|
79
75
|
|
|
80
76
|
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
|
81
|
-
style = type.styleAliases[style]
|
|
77
|
+
style = type.styleAliases[style]
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
result[tag] = style
|
|
80
|
+
result[tag] = style
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
return result
|
|
83
|
+
return result
|
|
88
84
|
}
|
|
89
85
|
|
|
90
|
-
function encodeHex(character) {
|
|
91
|
-
|
|
86
|
+
function encodeHex (character) {
|
|
87
|
+
let handle
|
|
88
|
+
let length
|
|
92
89
|
|
|
93
|
-
string = character.toString(16).toUpperCase()
|
|
90
|
+
const string = character.toString(16).toUpperCase()
|
|
94
91
|
|
|
95
92
|
if (character <= 0xFF) {
|
|
96
|
-
handle = 'x'
|
|
97
|
-
length = 2
|
|
93
|
+
handle = 'x'
|
|
94
|
+
length = 2
|
|
98
95
|
} else if (character <= 0xFFFF) {
|
|
99
|
-
handle = 'u'
|
|
100
|
-
length = 4
|
|
96
|
+
handle = 'u'
|
|
97
|
+
length = 4
|
|
101
98
|
} else if (character <= 0xFFFFFFFF) {
|
|
102
|
-
handle = 'U'
|
|
103
|
-
length = 8
|
|
99
|
+
handle = 'U'
|
|
100
|
+
length = 8
|
|
104
101
|
} else {
|
|
105
|
-
throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF')
|
|
102
|
+
throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF')
|
|
106
103
|
}
|
|
107
104
|
|
|
108
|
-
return '\\' + handle + common.repeat('0', length - string.length) + string
|
|
105
|
+
return '\\' + handle + common.repeat('0', length - string.length) + string
|
|
109
106
|
}
|
|
110
107
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this.
|
|
117
|
-
this.
|
|
118
|
-
this.
|
|
119
|
-
this.
|
|
120
|
-
this.
|
|
121
|
-
this.
|
|
122
|
-
this.
|
|
123
|
-
this.
|
|
124
|
-
this.
|
|
125
|
-
this.
|
|
126
|
-
this.
|
|
127
|
-
this.
|
|
128
|
-
this.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
this.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
this.
|
|
138
|
-
this.usedDuplicates = null;
|
|
108
|
+
const QUOTING_TYPE_SINGLE = 1
|
|
109
|
+
const QUOTING_TYPE_DOUBLE = 2
|
|
110
|
+
|
|
111
|
+
function State (options) {
|
|
112
|
+
this.schema = options['schema'] || DEFAULT_SCHEMA
|
|
113
|
+
this.indent = Math.max(1, (options['indent'] || 2))
|
|
114
|
+
this.noArrayIndent = options['noArrayIndent'] || false
|
|
115
|
+
this.skipInvalid = options['skipInvalid'] || false
|
|
116
|
+
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel'])
|
|
117
|
+
this.styleMap = compileStyleMap(this.schema, options['styles'] || null)
|
|
118
|
+
this.sortKeys = options['sortKeys'] || false
|
|
119
|
+
this.lineWidth = options['lineWidth'] || 80
|
|
120
|
+
this.noRefs = options['noRefs'] || false
|
|
121
|
+
this.noCompatMode = options['noCompatMode'] || false
|
|
122
|
+
this.condenseFlow = options['condenseFlow'] || false
|
|
123
|
+
this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE
|
|
124
|
+
this.forceQuotes = options['forceQuotes'] || false
|
|
125
|
+
this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null
|
|
126
|
+
|
|
127
|
+
this.implicitTypes = this.schema.compiledImplicit
|
|
128
|
+
this.explicitTypes = this.schema.compiledExplicit
|
|
129
|
+
|
|
130
|
+
this.tag = null
|
|
131
|
+
this.result = ''
|
|
132
|
+
|
|
133
|
+
this.duplicates = []
|
|
134
|
+
this.usedDuplicates = null
|
|
139
135
|
}
|
|
140
136
|
|
|
141
137
|
// Indents every line in a string. Empty lines (\n only) are not indented.
|
|
142
|
-
function indentString(string, spaces) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
line,
|
|
148
|
-
length = string.length;
|
|
138
|
+
function indentString (string, spaces) {
|
|
139
|
+
const ind = common.repeat(' ', spaces)
|
|
140
|
+
let position = 0
|
|
141
|
+
let result = ''
|
|
142
|
+
const length = string.length
|
|
149
143
|
|
|
150
144
|
while (position < length) {
|
|
151
|
-
|
|
145
|
+
let line
|
|
146
|
+
const next = string.indexOf('\n', position)
|
|
152
147
|
if (next === -1) {
|
|
153
|
-
line = string.slice(position)
|
|
154
|
-
position = length
|
|
148
|
+
line = string.slice(position)
|
|
149
|
+
position = length
|
|
155
150
|
} else {
|
|
156
|
-
line = string.slice(position, next + 1)
|
|
157
|
-
position = next + 1
|
|
151
|
+
line = string.slice(position, next + 1)
|
|
152
|
+
position = next + 1
|
|
158
153
|
}
|
|
159
154
|
|
|
160
|
-
if (line.length && line !== '\n') result += ind
|
|
155
|
+
if (line.length && line !== '\n') result += ind
|
|
161
156
|
|
|
162
|
-
result += line
|
|
157
|
+
result += line
|
|
163
158
|
}
|
|
164
159
|
|
|
165
|
-
return result
|
|
160
|
+
return result
|
|
166
161
|
}
|
|
167
162
|
|
|
168
|
-
function generateNextLine(state, level) {
|
|
169
|
-
return '\n' + common.repeat(' ', state.indent * level)
|
|
163
|
+
function generateNextLine (state, level) {
|
|
164
|
+
return '\n' + common.repeat(' ', state.indent * level)
|
|
170
165
|
}
|
|
171
166
|
|
|
172
|
-
function testImplicitResolving(state, str) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
176
|
-
type = state.implicitTypes[index];
|
|
167
|
+
function testImplicitResolving (state, str) {
|
|
168
|
+
for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
169
|
+
const type = state.implicitTypes[index]
|
|
177
170
|
|
|
178
171
|
if (type.resolve(str)) {
|
|
179
|
-
return true
|
|
172
|
+
return true
|
|
180
173
|
}
|
|
181
174
|
}
|
|
182
175
|
|
|
183
|
-
return false
|
|
176
|
+
return false
|
|
184
177
|
}
|
|
185
178
|
|
|
186
179
|
// [33] s-white ::= s-space | s-tab
|
|
187
|
-
function isWhitespace(c) {
|
|
188
|
-
return c === CHAR_SPACE || c === CHAR_TAB
|
|
180
|
+
function isWhitespace (c) {
|
|
181
|
+
return c === CHAR_SPACE || c === CHAR_TAB
|
|
189
182
|
}
|
|
190
183
|
|
|
191
184
|
// Returns true if the character can be printed without escaping.
|
|
192
185
|
// From YAML 1.2: "any allowed characters known to be non-printable
|
|
193
186
|
// should also be escaped. [However,] This isn’t mandatory"
|
|
194
187
|
// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
|
|
195
|
-
function isPrintable(c) {
|
|
196
|
-
return
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
188
|
+
function isPrintable (c) {
|
|
189
|
+
return (c >= 0x00020 && c <= 0x00007E) ||
|
|
190
|
+
((c >= 0x000A1 && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) ||
|
|
191
|
+
((c >= 0x0E000 && c <= 0x00FFFD) && c !== CHAR_BOM) ||
|
|
192
|
+
(c >= 0x10000 && c <= 0x10FFFF)
|
|
200
193
|
}
|
|
201
194
|
|
|
202
195
|
// [34] ns-char ::= nb-char - s-white
|
|
@@ -204,12 +197,12 @@ function isPrintable(c) {
|
|
|
204
197
|
// [26] b-char ::= b-line-feed | b-carriage-return
|
|
205
198
|
// Including s-white (for some reason, examples doesn't match specs in this aspect)
|
|
206
199
|
// ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark
|
|
207
|
-
function isNsCharOrWhitespace(c) {
|
|
208
|
-
return isPrintable(c)
|
|
209
|
-
|
|
200
|
+
function isNsCharOrWhitespace (c) {
|
|
201
|
+
return isPrintable(c) &&
|
|
202
|
+
c !== CHAR_BOM &&
|
|
210
203
|
// - b-char
|
|
211
|
-
|
|
212
|
-
|
|
204
|
+
c !== CHAR_CARRIAGE_RETURN &&
|
|
205
|
+
c !== CHAR_LINE_FEED
|
|
213
206
|
}
|
|
214
207
|
|
|
215
208
|
// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out
|
|
@@ -221,91 +214,96 @@ function isNsCharOrWhitespace(c) {
|
|
|
221
214
|
// [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” )
|
|
222
215
|
// | ( /* An ns-char preceding */ “#” )
|
|
223
216
|
// | ( “:” /* Followed by an ns-plain-safe(c) */ )
|
|
224
|
-
function isPlainSafe(c, prev, inblock) {
|
|
225
|
-
|
|
226
|
-
|
|
217
|
+
function isPlainSafe (c, prev, inblock) {
|
|
218
|
+
const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c)
|
|
219
|
+
const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c)
|
|
227
220
|
return (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
221
|
+
(
|
|
222
|
+
// ns-plain-safe
|
|
223
|
+
inblock // c = flow-in
|
|
224
|
+
? cIsNsCharOrWhitespace
|
|
225
|
+
: cIsNsCharOrWhitespace &&
|
|
226
|
+
// - c-flow-indicator
|
|
227
|
+
c !== CHAR_COMMA &&
|
|
228
|
+
c !== CHAR_LEFT_SQUARE_BRACKET &&
|
|
229
|
+
c !== CHAR_RIGHT_SQUARE_BRACKET &&
|
|
230
|
+
c !== CHAR_LEFT_CURLY_BRACKET &&
|
|
231
|
+
c !== CHAR_RIGHT_CURLY_BRACKET
|
|
232
|
+
) &&
|
|
239
233
|
// ns-plain-char
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
234
|
+
c !== CHAR_SHARP && // false on '#'
|
|
235
|
+
!(prev === CHAR_COLON && !cIsNsChar)
|
|
236
|
+
) || // false on ': '
|
|
237
|
+
(isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) || // change to true on '[^ ]#'
|
|
238
|
+
(prev === CHAR_COLON && cIsNsChar) // change to true on ':[^ ]'
|
|
244
239
|
}
|
|
245
240
|
|
|
246
241
|
// Simplified test for values allowed as the first character in plain style.
|
|
247
|
-
function isPlainSafeFirst(c) {
|
|
242
|
+
function isPlainSafeFirst (c) {
|
|
248
243
|
// Uses a subset of ns-char - c-indicator
|
|
249
244
|
// where ns-char = nb-char - s-white.
|
|
250
245
|
// No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part
|
|
251
|
-
return isPrintable(c) &&
|
|
252
|
-
|
|
246
|
+
return isPrintable(c) &&
|
|
247
|
+
c !== CHAR_BOM &&
|
|
248
|
+
!isWhitespace(c) && // - s-white
|
|
253
249
|
// - (c-indicator ::=
|
|
254
250
|
// “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
251
|
+
c !== CHAR_MINUS &&
|
|
252
|
+
c !== CHAR_QUESTION &&
|
|
253
|
+
c !== CHAR_COLON &&
|
|
254
|
+
c !== CHAR_COMMA &&
|
|
255
|
+
c !== CHAR_LEFT_SQUARE_BRACKET &&
|
|
256
|
+
c !== CHAR_RIGHT_SQUARE_BRACKET &&
|
|
257
|
+
c !== CHAR_LEFT_CURLY_BRACKET &&
|
|
258
|
+
c !== CHAR_RIGHT_CURLY_BRACKET &&
|
|
263
259
|
// | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
260
|
+
c !== CHAR_SHARP &&
|
|
261
|
+
c !== CHAR_AMPERSAND &&
|
|
262
|
+
c !== CHAR_ASTERISK &&
|
|
263
|
+
c !== CHAR_EXCLAMATION &&
|
|
264
|
+
c !== CHAR_VERTICAL_LINE &&
|
|
265
|
+
c !== CHAR_EQUALS &&
|
|
266
|
+
c !== CHAR_GREATER_THAN &&
|
|
267
|
+
c !== CHAR_SINGLE_QUOTE &&
|
|
268
|
+
c !== CHAR_DOUBLE_QUOTE &&
|
|
273
269
|
// | “%” | “@” | “`”)
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
270
|
+
c !== CHAR_PERCENT &&
|
|
271
|
+
c !== CHAR_COMMERCIAL_AT &&
|
|
272
|
+
c !== CHAR_GRAVE_ACCENT
|
|
277
273
|
}
|
|
278
274
|
|
|
279
275
|
// Simplified test for values allowed as the last character in plain style.
|
|
280
|
-
function isPlainSafeLast(c) {
|
|
276
|
+
function isPlainSafeLast (c) {
|
|
281
277
|
// just not whitespace or colon, it will be checked to be plain character later
|
|
282
|
-
return !isWhitespace(c) && c !== CHAR_COLON
|
|
278
|
+
return !isWhitespace(c) && c !== CHAR_COLON
|
|
283
279
|
}
|
|
284
280
|
|
|
285
281
|
// Same as 'string'.codePointAt(pos), but works in older browsers.
|
|
286
|
-
function codePointAt(string, pos) {
|
|
287
|
-
|
|
282
|
+
function codePointAt (string, pos) {
|
|
283
|
+
const first = string.charCodeAt(pos)
|
|
284
|
+
let second
|
|
285
|
+
|
|
288
286
|
if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) {
|
|
289
|
-
second = string.charCodeAt(pos + 1)
|
|
287
|
+
second = string.charCodeAt(pos + 1)
|
|
290
288
|
if (second >= 0xDC00 && second <= 0xDFFF) {
|
|
291
289
|
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
|
292
|
-
return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000
|
|
290
|
+
return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000
|
|
293
291
|
}
|
|
294
292
|
}
|
|
295
|
-
return first
|
|
293
|
+
return first
|
|
296
294
|
}
|
|
297
295
|
|
|
298
296
|
// Determines whether block indentation indicator is required.
|
|
299
|
-
function needIndentIndicator(string) {
|
|
300
|
-
|
|
301
|
-
return leadingSpaceRe.test(string)
|
|
297
|
+
function needIndentIndicator (string) {
|
|
298
|
+
const leadingSpaceRe = /^\n* /
|
|
299
|
+
return leadingSpaceRe.test(string)
|
|
302
300
|
}
|
|
303
301
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
302
|
+
const STYLE_PLAIN = 1
|
|
303
|
+
const STYLE_SINGLE = 2
|
|
304
|
+
const STYLE_LITERAL = 3
|
|
305
|
+
const STYLE_FOLDED = 4
|
|
306
|
+
const STYLE_DOUBLE = 5
|
|
309
307
|
|
|
310
308
|
// Determines which scalar styles are possible and returns the preferred style.
|
|
311
309
|
// lineWidth = -1 => no limit.
|
|
@@ -314,54 +312,53 @@ var STYLE_PLAIN = 1,
|
|
|
314
312
|
// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
|
|
315
313
|
// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
|
|
316
314
|
// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
|
|
317
|
-
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth,
|
|
315
|
+
function chooseScalarStyle (string, singleLineOnly, indentPerLevel, lineWidth,
|
|
318
316
|
testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
&& isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
317
|
+
let i
|
|
318
|
+
let char = 0
|
|
319
|
+
let prevChar = null
|
|
320
|
+
let hasLineBreak = false
|
|
321
|
+
let hasFoldableLine = false // only checked if shouldTrackWidth
|
|
322
|
+
const shouldTrackWidth = lineWidth !== -1
|
|
323
|
+
let previousLineBreak = -1 // count the first line correctly
|
|
324
|
+
let plain = isPlainSafeFirst(codePointAt(string, 0)) &&
|
|
325
|
+
isPlainSafeLast(codePointAt(string, string.length - 1))
|
|
329
326
|
|
|
330
327
|
if (singleLineOnly || forceQuotes) {
|
|
331
328
|
// Case: no block styles.
|
|
332
329
|
// Check for disallowed characters to rule out plain and single.
|
|
333
330
|
for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) {
|
|
334
|
-
char = codePointAt(string, i)
|
|
331
|
+
char = codePointAt(string, i)
|
|
335
332
|
if (!isPrintable(char)) {
|
|
336
|
-
return STYLE_DOUBLE
|
|
333
|
+
return STYLE_DOUBLE
|
|
337
334
|
}
|
|
338
|
-
plain = plain && isPlainSafe(char, prevChar, inblock)
|
|
339
|
-
prevChar = char
|
|
335
|
+
plain = plain && isPlainSafe(char, prevChar, inblock)
|
|
336
|
+
prevChar = char
|
|
340
337
|
}
|
|
341
338
|
} else {
|
|
342
339
|
// Case: block styles permitted.
|
|
343
340
|
for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) {
|
|
344
|
-
char = codePointAt(string, i)
|
|
341
|
+
char = codePointAt(string, i)
|
|
345
342
|
if (char === CHAR_LINE_FEED) {
|
|
346
|
-
hasLineBreak = true
|
|
343
|
+
hasLineBreak = true
|
|
347
344
|
// Check if any line can be folded.
|
|
348
345
|
if (shouldTrackWidth) {
|
|
349
346
|
hasFoldableLine = hasFoldableLine ||
|
|
350
347
|
// Foldable line = too long, and not more-indented.
|
|
351
348
|
(i - previousLineBreak - 1 > lineWidth &&
|
|
352
|
-
string[previousLineBreak + 1] !== ' ')
|
|
353
|
-
previousLineBreak = i
|
|
349
|
+
string[previousLineBreak + 1] !== ' ')
|
|
350
|
+
previousLineBreak = i
|
|
354
351
|
}
|
|
355
352
|
} else if (!isPrintable(char)) {
|
|
356
|
-
return STYLE_DOUBLE
|
|
353
|
+
return STYLE_DOUBLE
|
|
357
354
|
}
|
|
358
|
-
plain = plain && isPlainSafe(char, prevChar, inblock)
|
|
359
|
-
prevChar = char
|
|
355
|
+
plain = plain && isPlainSafe(char, prevChar, inblock)
|
|
356
|
+
prevChar = char
|
|
360
357
|
}
|
|
361
358
|
// in case the end is missing a \n
|
|
362
359
|
hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
|
|
363
360
|
(i - previousLineBreak - 1 > lineWidth &&
|
|
364
|
-
string[previousLineBreak + 1] !== ' '))
|
|
361
|
+
string[previousLineBreak + 1] !== ' '))
|
|
365
362
|
}
|
|
366
363
|
// Although every style can represent \n without escaping, prefer block styles
|
|
367
364
|
// for multiline, since they're more readable and they don't add empty lines.
|
|
@@ -370,20 +367,20 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth,
|
|
|
370
367
|
// Strings interpretable as another type have to be quoted;
|
|
371
368
|
// e.g. the string 'true' vs. the boolean true.
|
|
372
369
|
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
373
|
-
return STYLE_PLAIN
|
|
370
|
+
return STYLE_PLAIN
|
|
374
371
|
}
|
|
375
|
-
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE
|
|
372
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE
|
|
376
373
|
}
|
|
377
374
|
// Edge case: block indentation indicator can only have one digit.
|
|
378
375
|
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
379
|
-
return STYLE_DOUBLE
|
|
376
|
+
return STYLE_DOUBLE
|
|
380
377
|
}
|
|
381
378
|
// At this point we know block styles are valid.
|
|
382
379
|
// Prefer literal style unless we want to fold.
|
|
383
380
|
if (!forceQuotes) {
|
|
384
|
-
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL
|
|
381
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL
|
|
385
382
|
}
|
|
386
|
-
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE
|
|
383
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE
|
|
387
384
|
}
|
|
388
385
|
|
|
389
386
|
// Note: line breaking/folding is implemented for only the folded style.
|
|
@@ -392,18 +389,18 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth,
|
|
|
392
389
|
// • No ending newline => unaffected; already using strip "-" chomping.
|
|
393
390
|
// • Ending newline => removed then restored.
|
|
394
391
|
// Importantly, this keeps the "+" chomp indicator from gaining an extra line.
|
|
395
|
-
function writeScalar(state, string, level, iskey, inblock) {
|
|
392
|
+
function writeScalar (state, string, level, iskey, inblock) {
|
|
396
393
|
state.dump = (function () {
|
|
397
394
|
if (string.length === 0) {
|
|
398
|
-
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"
|
|
395
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"
|
|
399
396
|
}
|
|
400
397
|
if (!state.noCompatMode) {
|
|
401
398
|
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
402
|
-
return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'")
|
|
399
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'")
|
|
403
400
|
}
|
|
404
401
|
}
|
|
405
402
|
|
|
406
|
-
|
|
403
|
+
const indent = state.indent * Math.max(1, level) // no 0-indent scalars
|
|
407
404
|
// As indentation gets deeper, let the width decrease monotonically
|
|
408
405
|
// to the lower bound min(state.lineWidth, 40).
|
|
409
406
|
// Note that this implies
|
|
@@ -411,461 +408,441 @@ function writeScalar(state, string, level, iskey, inblock) {
|
|
|
411
408
|
// state.lineWidth > 40 + state.indent: width decreases until the lower bound.
|
|
412
409
|
// This behaves better than a constant minimum width which disallows narrower options,
|
|
413
410
|
// or an indent threshold which causes the width to suddenly increase.
|
|
414
|
-
|
|
415
|
-
? -1
|
|
411
|
+
const lineWidth = (state.lineWidth === -1)
|
|
412
|
+
? -1
|
|
413
|
+
: Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent)
|
|
416
414
|
|
|
417
415
|
// Without knowing if keys are implicit/explicit, assume implicit for safety.
|
|
418
|
-
|
|
416
|
+
const singleLineOnly = iskey ||
|
|
419
417
|
// No block styles in flow mode.
|
|
420
|
-
|
|
421
|
-
function testAmbiguity(string) {
|
|
422
|
-
return testImplicitResolving(state, string)
|
|
418
|
+
(state.flowLevel > -1 && level >= state.flowLevel)
|
|
419
|
+
function testAmbiguity (string) {
|
|
420
|
+
return testImplicitResolving(state, string)
|
|
423
421
|
}
|
|
424
422
|
|
|
425
423
|
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth,
|
|
426
424
|
testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
|
|
427
|
-
|
|
428
425
|
case STYLE_PLAIN:
|
|
429
|
-
return string
|
|
426
|
+
return string
|
|
430
427
|
case STYLE_SINGLE:
|
|
431
|
-
return "'" + string.replace(/'/g, "''") + "'"
|
|
428
|
+
return "'" + string.replace(/'/g, "''") + "'"
|
|
432
429
|
case STYLE_LITERAL:
|
|
433
|
-
return '|' + blockHeader(string, state.indent)
|
|
434
|
-
|
|
430
|
+
return '|' + blockHeader(string, state.indent) +
|
|
431
|
+
dropEndingNewline(indentString(string, indent))
|
|
435
432
|
case STYLE_FOLDED:
|
|
436
|
-
return '>' + blockHeader(string, state.indent)
|
|
437
|
-
|
|
433
|
+
return '>' + blockHeader(string, state.indent) +
|
|
434
|
+
dropEndingNewline(indentString(foldString(string, lineWidth), indent))
|
|
438
435
|
case STYLE_DOUBLE:
|
|
439
|
-
return '"' + escapeString(string, lineWidth) + '"'
|
|
436
|
+
return '"' + escapeString(string, lineWidth) + '"'
|
|
440
437
|
default:
|
|
441
|
-
throw new YAMLException('impossible error: invalid scalar style')
|
|
438
|
+
throw new YAMLException('impossible error: invalid scalar style')
|
|
442
439
|
}
|
|
443
|
-
}())
|
|
440
|
+
}())
|
|
444
441
|
}
|
|
445
442
|
|
|
446
443
|
// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
|
|
447
|
-
function blockHeader(string, indentPerLevel) {
|
|
448
|
-
|
|
444
|
+
function blockHeader (string, indentPerLevel) {
|
|
445
|
+
const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''
|
|
449
446
|
|
|
450
447
|
// note the special case: the string '\n' counts as a "trailing" empty line.
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
448
|
+
const clip = string[string.length - 1] === '\n'
|
|
449
|
+
const keep = clip && (string[string.length - 2] === '\n' || string === '\n')
|
|
450
|
+
const chomp = keep ? '+' : (clip ? '' : '-')
|
|
454
451
|
|
|
455
|
-
return indentIndicator + chomp + '\n'
|
|
452
|
+
return indentIndicator + chomp + '\n'
|
|
456
453
|
}
|
|
457
454
|
|
|
458
455
|
// (See the note for writeScalar.)
|
|
459
|
-
function dropEndingNewline(string) {
|
|
460
|
-
return string[string.length - 1] === '\n' ? string.slice(0, -1) : string
|
|
456
|
+
function dropEndingNewline (string) {
|
|
457
|
+
return string[string.length - 1] === '\n' ? string.slice(0, -1) : string
|
|
461
458
|
}
|
|
462
459
|
|
|
463
460
|
// Note: a long line without a suitable break point will exceed the width limit.
|
|
464
461
|
// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
|
|
465
|
-
function foldString(string, width) {
|
|
462
|
+
function foldString (string, width) {
|
|
466
463
|
// In folded style, $k$ consecutive newlines output as $k+1$ newlines—
|
|
467
464
|
// unless they're before or after a more-indented line, or at the very
|
|
468
465
|
// beginning or end, in which case $k$ maps to $k$.
|
|
469
466
|
// Therefore, parse each chunk as newline(s) followed by a content line.
|
|
470
|
-
|
|
467
|
+
const lineRe = /(\n+)([^\n]*)/g
|
|
471
468
|
|
|
472
469
|
// first line (possibly an empty line)
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
nextLF = nextLF !== -1 ? nextLF : string.length
|
|
476
|
-
lineRe.lastIndex = nextLF
|
|
477
|
-
return foldLine(string.slice(0, nextLF), width)
|
|
478
|
-
}())
|
|
470
|
+
let result = (function () {
|
|
471
|
+
let nextLF = string.indexOf('\n')
|
|
472
|
+
nextLF = nextLF !== -1 ? nextLF : string.length
|
|
473
|
+
lineRe.lastIndex = nextLF
|
|
474
|
+
return foldLine(string.slice(0, nextLF), width)
|
|
475
|
+
}())
|
|
479
476
|
// If we haven't reached the first content line yet, don't add an extra \n.
|
|
480
|
-
|
|
481
|
-
|
|
477
|
+
let prevMoreIndented = string[0] === '\n' || string[0] === ' '
|
|
478
|
+
let moreIndented
|
|
482
479
|
|
|
483
480
|
// rest of the lines
|
|
484
|
-
|
|
481
|
+
let match
|
|
485
482
|
while ((match = lineRe.exec(string))) {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
483
|
+
const prefix = match[1]
|
|
484
|
+
const line = match[2]
|
|
485
|
+
|
|
486
|
+
moreIndented = (line[0] === ' ')
|
|
487
|
+
result += prefix +
|
|
488
|
+
((!prevMoreIndented && !moreIndented && line !== '') ? '\n' : '') +
|
|
489
|
+
foldLine(line, width)
|
|
490
|
+
prevMoreIndented = moreIndented
|
|
493
491
|
}
|
|
494
492
|
|
|
495
|
-
return result
|
|
493
|
+
return result
|
|
496
494
|
}
|
|
497
495
|
|
|
498
496
|
// Greedy line breaking.
|
|
499
497
|
// Picks the longest line under the limit each time,
|
|
500
498
|
// otherwise settles for the shortest line over the limit.
|
|
501
499
|
// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
|
|
502
|
-
function foldLine(line, width) {
|
|
503
|
-
if (line === '' || line[0] === ' ') return line
|
|
500
|
+
function foldLine (line, width) {
|
|
501
|
+
if (line === '' || line[0] === ' ') return line
|
|
504
502
|
|
|
505
503
|
// Since a more-indented line adds a \n, breaks can't be followed by a space.
|
|
506
|
-
|
|
507
|
-
|
|
504
|
+
const breakRe = / [^ ]/g // note: the match index will always be <= length-2.
|
|
505
|
+
let match
|
|
508
506
|
// start is an inclusive index. end, curr, and next are exclusive.
|
|
509
|
-
|
|
510
|
-
|
|
507
|
+
let start = 0
|
|
508
|
+
let end
|
|
509
|
+
let curr = 0
|
|
510
|
+
let next = 0
|
|
511
|
+
let result = ''
|
|
511
512
|
|
|
512
513
|
// Invariants: 0 <= start <= length-1.
|
|
513
514
|
// 0 <= curr <= next <= max(0, length-2). curr - start <= width.
|
|
514
515
|
// Inside the loop:
|
|
515
516
|
// A match implies length >= 2, so curr and next are <= length-2.
|
|
516
517
|
while ((match = breakRe.exec(line))) {
|
|
517
|
-
next = match.index
|
|
518
|
+
next = match.index
|
|
518
519
|
// maintain invariant: curr - start <= width
|
|
519
520
|
if (next - start > width) {
|
|
520
|
-
end = (curr > start) ? curr : next
|
|
521
|
-
result += '\n' + line.slice(start, end)
|
|
521
|
+
end = (curr > start) ? curr : next // derive end <= length-2
|
|
522
|
+
result += '\n' + line.slice(start, end)
|
|
522
523
|
// skip the space that was output as \n
|
|
523
|
-
start = end + 1
|
|
524
|
+
start = end + 1 // derive start <= length-1
|
|
524
525
|
}
|
|
525
|
-
curr = next
|
|
526
|
+
curr = next
|
|
526
527
|
}
|
|
527
528
|
|
|
528
529
|
// By the invariants, start <= length-1, so there is something left over.
|
|
529
530
|
// It is either the whole string or a part starting from non-whitespace.
|
|
530
|
-
result += '\n'
|
|
531
|
+
result += '\n'
|
|
531
532
|
// Insert a break if the remainder is too long and there is a break available.
|
|
532
533
|
if (line.length - start > width && curr > start) {
|
|
533
|
-
result += line.slice(start, curr) + '\n' + line.slice(curr + 1)
|
|
534
|
+
result += line.slice(start, curr) + '\n' + line.slice(curr + 1)
|
|
534
535
|
} else {
|
|
535
|
-
result += line.slice(start)
|
|
536
|
+
result += line.slice(start)
|
|
536
537
|
}
|
|
537
538
|
|
|
538
|
-
return result.slice(1)
|
|
539
|
+
return result.slice(1) // drop extra \n joiner
|
|
539
540
|
}
|
|
540
541
|
|
|
541
542
|
// Escapes a double-quoted string.
|
|
542
|
-
function escapeString(string) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
var escapeSeq;
|
|
543
|
+
function escapeString (string) {
|
|
544
|
+
let result = ''
|
|
545
|
+
let char = 0
|
|
546
546
|
|
|
547
|
-
for (
|
|
548
|
-
char = codePointAt(string, i)
|
|
549
|
-
escapeSeq = ESCAPE_SEQUENCES[char]
|
|
547
|
+
for (let i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) {
|
|
548
|
+
char = codePointAt(string, i)
|
|
549
|
+
const escapeSeq = ESCAPE_SEQUENCES[char]
|
|
550
550
|
|
|
551
551
|
if (!escapeSeq && isPrintable(char)) {
|
|
552
|
-
result += string[i]
|
|
553
|
-
if (char >= 0x10000) result += string[i + 1]
|
|
552
|
+
result += string[i]
|
|
553
|
+
if (char >= 0x10000) result += string[i + 1]
|
|
554
554
|
} else {
|
|
555
|
-
result += escapeSeq || encodeHex(char)
|
|
555
|
+
result += escapeSeq || encodeHex(char)
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
return result
|
|
559
|
+
return result
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
-
function writeFlowSequence(state, level, object) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
index,
|
|
566
|
-
length,
|
|
567
|
-
value;
|
|
562
|
+
function writeFlowSequence (state, level, object) {
|
|
563
|
+
let _result = ''
|
|
564
|
+
const _tag = state.tag
|
|
568
565
|
|
|
569
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
570
|
-
value = object[index]
|
|
566
|
+
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
567
|
+
let value = object[index]
|
|
571
568
|
|
|
572
569
|
if (state.replacer) {
|
|
573
|
-
value = state.replacer.call(object, String(index), value)
|
|
570
|
+
value = state.replacer.call(object, String(index), value)
|
|
574
571
|
}
|
|
575
572
|
|
|
576
573
|
// Write only valid elements, put null instead of invalid elements.
|
|
577
574
|
if (writeNode(state, level, value, false, false) ||
|
|
578
575
|
(typeof value === 'undefined' &&
|
|
579
576
|
writeNode(state, level, null, false, false))) {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
_result += state.dump;
|
|
577
|
+
if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : '')
|
|
578
|
+
_result += state.dump
|
|
583
579
|
}
|
|
584
580
|
}
|
|
585
581
|
|
|
586
|
-
state.tag = _tag
|
|
587
|
-
state.dump = '[' + _result + ']'
|
|
582
|
+
state.tag = _tag
|
|
583
|
+
state.dump = '[' + _result + ']'
|
|
588
584
|
}
|
|
589
585
|
|
|
590
|
-
function writeBlockSequence(state, level, object, compact) {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
index,
|
|
594
|
-
length,
|
|
595
|
-
value;
|
|
586
|
+
function writeBlockSequence (state, level, object, compact) {
|
|
587
|
+
let _result = ''
|
|
588
|
+
const _tag = state.tag
|
|
596
589
|
|
|
597
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
598
|
-
value = object[index]
|
|
590
|
+
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
591
|
+
let value = object[index]
|
|
599
592
|
|
|
600
593
|
if (state.replacer) {
|
|
601
|
-
value = state.replacer.call(object, String(index), value)
|
|
594
|
+
value = state.replacer.call(object, String(index), value)
|
|
602
595
|
}
|
|
603
596
|
|
|
604
597
|
// Write only valid elements, put null instead of invalid elements.
|
|
605
598
|
if (writeNode(state, level + 1, value, true, true, false, true) ||
|
|
606
599
|
(typeof value === 'undefined' &&
|
|
607
600
|
writeNode(state, level + 1, null, true, true, false, true))) {
|
|
608
|
-
|
|
609
601
|
if (!compact || _result !== '') {
|
|
610
|
-
_result += generateNextLine(state, level)
|
|
602
|
+
_result += generateNextLine(state, level)
|
|
611
603
|
}
|
|
612
604
|
|
|
613
605
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
614
|
-
_result += '-'
|
|
606
|
+
_result += '-'
|
|
615
607
|
} else {
|
|
616
|
-
_result += '- '
|
|
608
|
+
_result += '- '
|
|
617
609
|
}
|
|
618
610
|
|
|
619
|
-
_result += state.dump
|
|
611
|
+
_result += state.dump
|
|
620
612
|
}
|
|
621
613
|
}
|
|
622
614
|
|
|
623
|
-
state.tag = _tag
|
|
624
|
-
state.dump = _result || '[]'
|
|
615
|
+
state.tag = _tag
|
|
616
|
+
state.dump = _result || '[]' // Empty sequence if no valid values.
|
|
625
617
|
}
|
|
626
618
|
|
|
627
|
-
function writeFlowMapping(state, level, object) {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
index,
|
|
632
|
-
length,
|
|
633
|
-
objectKey,
|
|
634
|
-
objectValue,
|
|
635
|
-
pairBuffer;
|
|
636
|
-
|
|
637
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
619
|
+
function writeFlowMapping (state, level, object) {
|
|
620
|
+
let _result = ''
|
|
621
|
+
const _tag = state.tag
|
|
622
|
+
const objectKeyList = Object.keys(object)
|
|
638
623
|
|
|
639
|
-
|
|
640
|
-
|
|
624
|
+
for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
625
|
+
let pairBuffer = ''
|
|
626
|
+
if (_result !== '') pairBuffer += ', '
|
|
641
627
|
|
|
642
|
-
if (state.condenseFlow) pairBuffer += '"'
|
|
628
|
+
if (state.condenseFlow) pairBuffer += '"'
|
|
643
629
|
|
|
644
|
-
objectKey = objectKeyList[index]
|
|
645
|
-
objectValue = object[objectKey]
|
|
630
|
+
const objectKey = objectKeyList[index]
|
|
631
|
+
let objectValue = object[objectKey]
|
|
646
632
|
|
|
647
633
|
if (state.replacer) {
|
|
648
|
-
objectValue = state.replacer.call(object, objectKey, objectValue)
|
|
634
|
+
objectValue = state.replacer.call(object, objectKey, objectValue)
|
|
649
635
|
}
|
|
650
636
|
|
|
651
637
|
if (!writeNode(state, level, objectKey, false, false)) {
|
|
652
|
-
continue
|
|
638
|
+
continue // Skip this pair because of invalid key;
|
|
653
639
|
}
|
|
654
640
|
|
|
655
|
-
if (state.dump.length > 1024) pairBuffer += '? '
|
|
641
|
+
if (state.dump.length > 1024) pairBuffer += '? '
|
|
656
642
|
|
|
657
|
-
pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ')
|
|
643
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ')
|
|
658
644
|
|
|
659
645
|
if (!writeNode(state, level, objectValue, false, false)) {
|
|
660
|
-
continue
|
|
646
|
+
continue // Skip this pair because of invalid value.
|
|
661
647
|
}
|
|
662
648
|
|
|
663
|
-
pairBuffer += state.dump
|
|
649
|
+
pairBuffer += state.dump
|
|
664
650
|
|
|
665
651
|
// Both key and value are valid.
|
|
666
|
-
_result += pairBuffer
|
|
652
|
+
_result += pairBuffer
|
|
667
653
|
}
|
|
668
654
|
|
|
669
|
-
state.tag = _tag
|
|
670
|
-
state.dump = '{' + _result + '}'
|
|
655
|
+
state.tag = _tag
|
|
656
|
+
state.dump = '{' + _result + '}'
|
|
671
657
|
}
|
|
672
658
|
|
|
673
|
-
function writeBlockMapping(state, level, object, compact) {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
index,
|
|
678
|
-
length,
|
|
679
|
-
objectKey,
|
|
680
|
-
objectValue,
|
|
681
|
-
explicitPair,
|
|
682
|
-
pairBuffer;
|
|
659
|
+
function writeBlockMapping (state, level, object, compact) {
|
|
660
|
+
let _result = ''
|
|
661
|
+
const _tag = state.tag
|
|
662
|
+
const objectKeyList = Object.keys(object)
|
|
683
663
|
|
|
684
664
|
// Allow sorting keys so that the output file is deterministic
|
|
685
665
|
if (state.sortKeys === true) {
|
|
686
666
|
// Default sorting
|
|
687
|
-
objectKeyList.sort()
|
|
667
|
+
objectKeyList.sort()
|
|
688
668
|
} else if (typeof state.sortKeys === 'function') {
|
|
689
669
|
// Custom sort function
|
|
690
|
-
objectKeyList.sort(state.sortKeys)
|
|
670
|
+
objectKeyList.sort(state.sortKeys)
|
|
691
671
|
} else if (state.sortKeys) {
|
|
692
672
|
// Something is wrong
|
|
693
|
-
throw new YAMLException('sortKeys must be a boolean or a function')
|
|
673
|
+
throw new YAMLException('sortKeys must be a boolean or a function')
|
|
694
674
|
}
|
|
695
675
|
|
|
696
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
697
|
-
pairBuffer = ''
|
|
676
|
+
for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
677
|
+
let pairBuffer = ''
|
|
698
678
|
|
|
699
679
|
if (!compact || _result !== '') {
|
|
700
|
-
pairBuffer += generateNextLine(state, level)
|
|
680
|
+
pairBuffer += generateNextLine(state, level)
|
|
701
681
|
}
|
|
702
682
|
|
|
703
|
-
objectKey = objectKeyList[index]
|
|
704
|
-
objectValue = object[objectKey]
|
|
683
|
+
const objectKey = objectKeyList[index]
|
|
684
|
+
let objectValue = object[objectKey]
|
|
705
685
|
|
|
706
686
|
if (state.replacer) {
|
|
707
|
-
objectValue = state.replacer.call(object, objectKey, objectValue)
|
|
687
|
+
objectValue = state.replacer.call(object, objectKey, objectValue)
|
|
708
688
|
}
|
|
709
689
|
|
|
710
690
|
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
711
|
-
continue
|
|
691
|
+
continue // Skip this pair because of invalid key.
|
|
712
692
|
}
|
|
713
693
|
|
|
714
|
-
explicitPair = (state.tag !== null && state.tag !== '?') ||
|
|
715
|
-
(state.dump && state.dump.length > 1024)
|
|
694
|
+
const explicitPair = (state.tag !== null && state.tag !== '?') ||
|
|
695
|
+
(state.dump && state.dump.length > 1024)
|
|
716
696
|
|
|
717
697
|
if (explicitPair) {
|
|
718
698
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
719
|
-
pairBuffer += '?'
|
|
699
|
+
pairBuffer += '?'
|
|
720
700
|
} else {
|
|
721
|
-
pairBuffer += '? '
|
|
701
|
+
pairBuffer += '? '
|
|
722
702
|
}
|
|
723
703
|
}
|
|
724
704
|
|
|
725
|
-
pairBuffer += state.dump
|
|
705
|
+
pairBuffer += state.dump
|
|
726
706
|
|
|
727
707
|
if (explicitPair) {
|
|
728
|
-
pairBuffer += generateNextLine(state, level)
|
|
708
|
+
pairBuffer += generateNextLine(state, level)
|
|
729
709
|
}
|
|
730
710
|
|
|
731
711
|
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
732
|
-
continue
|
|
712
|
+
continue // Skip this pair because of invalid value.
|
|
733
713
|
}
|
|
734
714
|
|
|
735
715
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
736
|
-
pairBuffer += ':'
|
|
716
|
+
pairBuffer += ':'
|
|
737
717
|
} else {
|
|
738
|
-
pairBuffer += ': '
|
|
718
|
+
pairBuffer += ': '
|
|
739
719
|
}
|
|
740
720
|
|
|
741
|
-
pairBuffer += state.dump
|
|
721
|
+
pairBuffer += state.dump
|
|
742
722
|
|
|
743
723
|
// Both key and value are valid.
|
|
744
|
-
_result += pairBuffer
|
|
724
|
+
_result += pairBuffer
|
|
745
725
|
}
|
|
746
726
|
|
|
747
|
-
state.tag = _tag
|
|
748
|
-
state.dump = _result || '{}'
|
|
727
|
+
state.tag = _tag
|
|
728
|
+
state.dump = _result || '{}' // Empty mapping if no valid pairs.
|
|
749
729
|
}
|
|
750
730
|
|
|
751
|
-
function detectType(state, object, explicit) {
|
|
752
|
-
|
|
731
|
+
function detectType (state, object, explicit) {
|
|
732
|
+
const typeList = explicit ? state.explicitTypes : state.implicitTypes
|
|
753
733
|
|
|
754
|
-
|
|
734
|
+
for (let index = 0, length = typeList.length; index < length; index += 1) {
|
|
735
|
+
const type = typeList[index]
|
|
755
736
|
|
|
756
|
-
|
|
757
|
-
type = typeList[index];
|
|
758
|
-
|
|
759
|
-
if ((type.instanceOf || type.predicate) &&
|
|
737
|
+
if ((type.instanceOf || type.predicate) &&
|
|
760
738
|
(!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
|
|
761
|
-
(!type.predicate
|
|
762
|
-
|
|
739
|
+
(!type.predicate || type.predicate(object))) {
|
|
763
740
|
if (explicit) {
|
|
764
741
|
if (type.multi && type.representName) {
|
|
765
|
-
state.tag = type.representName(object)
|
|
742
|
+
state.tag = type.representName(object)
|
|
766
743
|
} else {
|
|
767
|
-
state.tag = type.tag
|
|
744
|
+
state.tag = type.tag
|
|
768
745
|
}
|
|
769
746
|
} else {
|
|
770
|
-
state.tag = '?'
|
|
747
|
+
state.tag = '?'
|
|
771
748
|
}
|
|
772
749
|
|
|
773
750
|
if (type.represent) {
|
|
774
|
-
style = state.styleMap[type.tag] || type.defaultStyle
|
|
751
|
+
const style = state.styleMap[type.tag] || type.defaultStyle
|
|
775
752
|
|
|
753
|
+
let _result
|
|
776
754
|
if (_toString.call(type.represent) === '[object Function]') {
|
|
777
|
-
_result = type.represent(object, style)
|
|
755
|
+
_result = type.represent(object, style)
|
|
778
756
|
} else if (_hasOwnProperty.call(type.represent, style)) {
|
|
779
|
-
_result = type.represent[style](object, style)
|
|
757
|
+
_result = type.represent[style](object, style)
|
|
780
758
|
} else {
|
|
781
|
-
throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style')
|
|
759
|
+
throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style')
|
|
782
760
|
}
|
|
783
761
|
|
|
784
|
-
state.dump = _result
|
|
762
|
+
state.dump = _result
|
|
785
763
|
}
|
|
786
764
|
|
|
787
|
-
return true
|
|
765
|
+
return true
|
|
788
766
|
}
|
|
789
767
|
}
|
|
790
768
|
|
|
791
|
-
return false
|
|
769
|
+
return false
|
|
792
770
|
}
|
|
793
771
|
|
|
794
772
|
// Serializes `object` and writes it to global `result`.
|
|
795
773
|
// Returns true on success, or false on invalid object.
|
|
796
774
|
//
|
|
797
|
-
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
798
|
-
state.tag = null
|
|
799
|
-
state.dump = object
|
|
775
|
+
function writeNode (state, level, object, block, compact, iskey, isblockseq) {
|
|
776
|
+
state.tag = null
|
|
777
|
+
state.dump = object
|
|
800
778
|
|
|
801
779
|
if (!detectType(state, object, false)) {
|
|
802
|
-
detectType(state, object, true)
|
|
780
|
+
detectType(state, object, true)
|
|
803
781
|
}
|
|
804
782
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
var tagStr;
|
|
783
|
+
const type = _toString.call(state.dump)
|
|
784
|
+
const inblock = block
|
|
808
785
|
|
|
809
786
|
if (block) {
|
|
810
|
-
block = (state.flowLevel < 0 || state.flowLevel > level)
|
|
787
|
+
block = (state.flowLevel < 0 || state.flowLevel > level)
|
|
811
788
|
}
|
|
812
789
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
790
|
+
const objectOrArray = type === '[object Object]' || type === '[object Array]'
|
|
791
|
+
let duplicateIndex
|
|
792
|
+
let duplicate
|
|
816
793
|
|
|
817
794
|
if (objectOrArray) {
|
|
818
|
-
duplicateIndex = state.duplicates.indexOf(object)
|
|
819
|
-
duplicate = duplicateIndex !== -1
|
|
795
|
+
duplicateIndex = state.duplicates.indexOf(object)
|
|
796
|
+
duplicate = duplicateIndex !== -1
|
|
820
797
|
}
|
|
821
798
|
|
|
822
799
|
if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
|
|
823
|
-
compact = false
|
|
800
|
+
compact = false
|
|
824
801
|
}
|
|
825
802
|
|
|
826
803
|
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
827
|
-
state.dump = '*ref_' + duplicateIndex
|
|
804
|
+
state.dump = '*ref_' + duplicateIndex
|
|
828
805
|
} else {
|
|
829
806
|
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
830
|
-
state.usedDuplicates[duplicateIndex] = true
|
|
807
|
+
state.usedDuplicates[duplicateIndex] = true
|
|
831
808
|
}
|
|
832
809
|
if (type === '[object Object]') {
|
|
833
810
|
if (block && (Object.keys(state.dump).length !== 0)) {
|
|
834
|
-
writeBlockMapping(state, level, state.dump, compact)
|
|
811
|
+
writeBlockMapping(state, level, state.dump, compact)
|
|
835
812
|
if (duplicate) {
|
|
836
|
-
state.dump = '&ref_' + duplicateIndex + state.dump
|
|
813
|
+
state.dump = '&ref_' + duplicateIndex + state.dump
|
|
837
814
|
}
|
|
838
815
|
} else {
|
|
839
|
-
writeFlowMapping(state, level, state.dump)
|
|
816
|
+
writeFlowMapping(state, level, state.dump)
|
|
840
817
|
if (duplicate) {
|
|
841
|
-
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump
|
|
818
|
+
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump
|
|
842
819
|
}
|
|
843
820
|
}
|
|
844
821
|
} else if (type === '[object Array]') {
|
|
845
822
|
if (block && (state.dump.length !== 0)) {
|
|
846
823
|
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
847
|
-
writeBlockSequence(state, level - 1, state.dump, compact)
|
|
824
|
+
writeBlockSequence(state, level - 1, state.dump, compact)
|
|
848
825
|
} else {
|
|
849
|
-
writeBlockSequence(state, level, state.dump, compact)
|
|
826
|
+
writeBlockSequence(state, level, state.dump, compact)
|
|
850
827
|
}
|
|
851
828
|
if (duplicate) {
|
|
852
|
-
state.dump = '&ref_' + duplicateIndex + state.dump
|
|
829
|
+
state.dump = '&ref_' + duplicateIndex + state.dump
|
|
853
830
|
}
|
|
854
831
|
} else {
|
|
855
|
-
writeFlowSequence(state, level, state.dump)
|
|
832
|
+
writeFlowSequence(state, level, state.dump)
|
|
856
833
|
if (duplicate) {
|
|
857
|
-
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump
|
|
834
|
+
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump
|
|
858
835
|
}
|
|
859
836
|
}
|
|
860
837
|
} else if (type === '[object String]') {
|
|
861
838
|
if (state.tag !== '?') {
|
|
862
|
-
writeScalar(state, state.dump, level, iskey, inblock)
|
|
839
|
+
writeScalar(state, state.dump, level, iskey, inblock)
|
|
863
840
|
}
|
|
864
841
|
} else if (type === '[object Undefined]') {
|
|
865
|
-
return false
|
|
842
|
+
return false
|
|
866
843
|
} else {
|
|
867
|
-
if (state.skipInvalid) return false
|
|
868
|
-
throw new YAMLException('unacceptable kind of an object to dump ' + type)
|
|
844
|
+
if (state.skipInvalid) return false
|
|
845
|
+
throw new YAMLException('unacceptable kind of an object to dump ' + type)
|
|
869
846
|
}
|
|
870
847
|
|
|
871
848
|
if (state.tag !== null && state.tag !== '?') {
|
|
@@ -882,84 +859,79 @@ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
|
882
859
|
//
|
|
883
860
|
// Also need to encode '!' because it has special meaning (end of tag prefix).
|
|
884
861
|
//
|
|
885
|
-
tagStr = encodeURI(
|
|
862
|
+
let tagStr = encodeURI(
|
|
886
863
|
state.tag[0] === '!' ? state.tag.slice(1) : state.tag
|
|
887
|
-
).replace(/!/g, '%21')
|
|
864
|
+
).replace(/!/g, '%21')
|
|
888
865
|
|
|
889
866
|
if (state.tag[0] === '!') {
|
|
890
|
-
tagStr = '!' + tagStr
|
|
867
|
+
tagStr = '!' + tagStr
|
|
891
868
|
} else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') {
|
|
892
|
-
tagStr = '!!' + tagStr.slice(18)
|
|
869
|
+
tagStr = '!!' + tagStr.slice(18)
|
|
893
870
|
} else {
|
|
894
|
-
tagStr = '!<' + tagStr + '>'
|
|
871
|
+
tagStr = '!<' + tagStr + '>'
|
|
895
872
|
}
|
|
896
873
|
|
|
897
|
-
state.dump = tagStr + ' ' + state.dump
|
|
874
|
+
state.dump = tagStr + ' ' + state.dump
|
|
898
875
|
}
|
|
899
876
|
}
|
|
900
877
|
|
|
901
|
-
return true
|
|
878
|
+
return true
|
|
902
879
|
}
|
|
903
880
|
|
|
904
|
-
function getDuplicateReferences(object, state) {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
index,
|
|
908
|
-
length;
|
|
881
|
+
function getDuplicateReferences (object, state) {
|
|
882
|
+
const objects = []
|
|
883
|
+
const duplicatesIndexes = []
|
|
909
884
|
|
|
910
|
-
inspectNode(object, objects, duplicatesIndexes)
|
|
885
|
+
inspectNode(object, objects, duplicatesIndexes)
|
|
911
886
|
|
|
912
|
-
|
|
913
|
-
|
|
887
|
+
const length = duplicatesIndexes.length
|
|
888
|
+
for (let index = 0; index < length; index += 1) {
|
|
889
|
+
state.duplicates.push(objects[duplicatesIndexes[index]])
|
|
914
890
|
}
|
|
915
|
-
state.usedDuplicates = new Array(length)
|
|
891
|
+
state.usedDuplicates = new Array(length)
|
|
916
892
|
}
|
|
917
893
|
|
|
918
|
-
function inspectNode(object, objects, duplicatesIndexes) {
|
|
919
|
-
var objectKeyList,
|
|
920
|
-
index,
|
|
921
|
-
length;
|
|
922
|
-
|
|
894
|
+
function inspectNode (object, objects, duplicatesIndexes) {
|
|
923
895
|
if (object !== null && typeof object === 'object') {
|
|
924
|
-
index = objects.indexOf(object)
|
|
896
|
+
const index = objects.indexOf(object)
|
|
925
897
|
if (index !== -1) {
|
|
926
898
|
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
927
|
-
duplicatesIndexes.push(index)
|
|
899
|
+
duplicatesIndexes.push(index)
|
|
928
900
|
}
|
|
929
901
|
} else {
|
|
930
|
-
objects.push(object)
|
|
902
|
+
objects.push(object)
|
|
931
903
|
|
|
932
904
|
if (Array.isArray(object)) {
|
|
933
|
-
for (
|
|
934
|
-
inspectNode(object[
|
|
905
|
+
for (let i = 0, length = object.length; i < length; i += 1) {
|
|
906
|
+
inspectNode(object[i], objects, duplicatesIndexes)
|
|
935
907
|
}
|
|
936
908
|
} else {
|
|
937
|
-
objectKeyList = Object.keys(object)
|
|
909
|
+
const objectKeyList = Object.keys(object)
|
|
938
910
|
|
|
939
|
-
for (
|
|
940
|
-
inspectNode(object[objectKeyList[
|
|
911
|
+
for (let i = 0, length = objectKeyList.length; i < length; i += 1) {
|
|
912
|
+
inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes)
|
|
941
913
|
}
|
|
942
914
|
}
|
|
943
915
|
}
|
|
944
916
|
}
|
|
945
917
|
}
|
|
946
918
|
|
|
947
|
-
function dump(input, options) {
|
|
948
|
-
options = options || {}
|
|
919
|
+
function dump (input, options) {
|
|
920
|
+
options = options || {}
|
|
949
921
|
|
|
950
|
-
|
|
922
|
+
const state = new State(options)
|
|
951
923
|
|
|
952
|
-
if (!state.noRefs) getDuplicateReferences(input, state)
|
|
924
|
+
if (!state.noRefs) getDuplicateReferences(input, state)
|
|
953
925
|
|
|
954
|
-
|
|
926
|
+
let value = input
|
|
955
927
|
|
|
956
928
|
if (state.replacer) {
|
|
957
|
-
value = state.replacer.call({ '': value }, '', value)
|
|
929
|
+
value = state.replacer.call({ '': value }, '', value)
|
|
958
930
|
}
|
|
959
931
|
|
|
960
|
-
if (writeNode(state, 0, value, true, true)) return state.dump + '\n'
|
|
932
|
+
if (writeNode(state, 0, value, true, true)) return state.dump + '\n'
|
|
961
933
|
|
|
962
|
-
return ''
|
|
934
|
+
return ''
|
|
963
935
|
}
|
|
964
936
|
|
|
965
|
-
module.exports.dump = dump
|
|
937
|
+
module.exports.dump = dump
|