projen 0.80.6 → 0.80.7
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 +41 -41
- package/lib/awscdk/auto-discover.js +5 -5
- 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 +1 -1
- 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/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-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/dependabot.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/mergify.js +1 -1
- package/lib/github/pr-template.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 +1 -1
- package/lib/java/projenrc.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.d.ts +7 -3
- package/lib/python/poetry.js +43 -21
- package/lib/python/projenrc.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/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 +10 -8
- 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/json2toml/CHANGELOG.md +128 -0
- package/node_modules/json2toml/LICENSE.txt +18 -0
- package/node_modules/json2toml/README.md +52 -0
- package/node_modules/json2toml/index.d.ts +13 -0
- package/node_modules/json2toml/index.js +160 -0
- package/node_modules/json2toml/package.json +62 -0
- package/node_modules/lodash.isdate/LICENSE +47 -0
- package/node_modules/lodash.isdate/README.md +18 -0
- package/node_modules/lodash.isdate/index.js +119 -0
- package/node_modules/lodash.isdate/package.json +17 -0
- package/node_modules/lodash.isempty/LICENSE +47 -0
- package/node_modules/lodash.isempty/README.md +18 -0
- package/node_modules/lodash.isempty/index.js +582 -0
- package/node_modules/lodash.isempty/package.json +17 -0
- package/node_modules/lodash.isplainobject/LICENSE +47 -0
- package/node_modules/lodash.isplainobject/README.md +18 -0
- package/node_modules/lodash.isplainobject/index.js +139 -0
- package/node_modules/lodash.isplainobject/package.json +17 -0
- package/node_modules/strftime/Changelog.md +286 -0
- package/node_modules/strftime/Makefile +15 -0
- package/node_modules/strftime/Readme.md +208 -0
- package/node_modules/strftime/bower.json +13 -0
- package/node_modules/strftime/component.json +16 -0
- package/node_modules/strftime/package.json +53 -0
- package/node_modules/strftime/strftime-min.js +21 -0
- package/node_modules/strftime/strftime.js +854 -0
- package/node_modules/strftime/test.js +271 -0
- package/package.json +4 -3
- package/node_modules/@iarna/toml/LICENSE +0 -14
- package/node_modules/@iarna/toml/README.md +0 -301
- package/node_modules/@iarna/toml/index.d.ts +0 -57
- package/node_modules/@iarna/toml/lib/create-date.js +0 -23
- package/node_modules/@iarna/toml/lib/create-datetime-float.js +0 -24
- package/node_modules/@iarna/toml/lib/create-datetime.js +0 -10
- package/node_modules/@iarna/toml/lib/create-time.js +0 -22
- package/node_modules/@iarna/toml/lib/format-num.js +0 -6
- package/node_modules/@iarna/toml/lib/parser-debug.js +0 -60
- package/node_modules/@iarna/toml/lib/parser.js +0 -127
- package/node_modules/@iarna/toml/lib/toml-parser.js +0 -1379
- package/node_modules/@iarna/toml/package.json +0 -82
- package/node_modules/@iarna/toml/parse-async.js +0 -30
- package/node_modules/@iarna/toml/parse-pretty-error.js +0 -33
- package/node_modules/@iarna/toml/parse-stream.js +0 -80
- package/node_modules/@iarna/toml/parse-string.js +0 -18
- package/node_modules/@iarna/toml/parse.js +0 -5
- package/node_modules/@iarna/toml/stringify.js +0 -296
- package/node_modules/@iarna/toml/toml.js +0 -3
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@iarna/toml",
|
|
3
|
-
"version": "2.2.5",
|
|
4
|
-
"main": "toml.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "tap -J --100 test/*.js test/toml-stream/*.js",
|
|
7
|
-
"benchmark": "node benchmark.js && node benchmark-per-file.js && node results2table.js",
|
|
8
|
-
"prerelease": "npm t",
|
|
9
|
-
"prepack": "rm -f *~",
|
|
10
|
-
"postpublish": "git push --follow-tags",
|
|
11
|
-
"pretest": "iarna-standard",
|
|
12
|
-
"update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",
|
|
13
|
-
"update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'",
|
|
14
|
-
"setup-burntsushi-toml-suite": "[ -d test/burntsushi-toml-test ] || (git clone https://github.com/BurntSushi/toml-test test/burntsushi-toml-test; rimraf test/burntsushi-toml-test/.git/hooks/*); cd test/burntsushi-toml-test; git pull",
|
|
15
|
-
"setup-iarna-toml-suite": "[ -d test/spec-test ] || (git clone https://github.com/iarna/toml-spec-tests -b 0.5.0 test/spec-test; rimraf test/spec-test/.git/hooks/*); cd test/spec-test; git pull",
|
|
16
|
-
"prepare": "npm run setup-burntsushi-toml-suite && npm run setup-iarna-toml-suite"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"toml",
|
|
20
|
-
"toml-parser",
|
|
21
|
-
"toml-stringifier",
|
|
22
|
-
"parser",
|
|
23
|
-
"stringifer",
|
|
24
|
-
"emitter",
|
|
25
|
-
"ini",
|
|
26
|
-
"tomlify",
|
|
27
|
-
"encoder",
|
|
28
|
-
"decoder"
|
|
29
|
-
],
|
|
30
|
-
"author": "Rebecca Turner <me@re-becca.org> (http://re-becca.org/)",
|
|
31
|
-
"license": "ISC",
|
|
32
|
-
"description": "Better TOML parsing and stringifying all in that familiar JSON interface.",
|
|
33
|
-
"dependencies": {},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@iarna/standard": "^2.0.2",
|
|
36
|
-
"@ltd/j-toml": "^0.5.107",
|
|
37
|
-
"@perl/qx": "^1.1.0",
|
|
38
|
-
"@sgarciac/bombadil": "^2.3.0",
|
|
39
|
-
"ansi": "^0.3.1",
|
|
40
|
-
"approximate-number": "^2.0.0",
|
|
41
|
-
"benchmark": "^2.1.4",
|
|
42
|
-
"fast-toml": "^0.5.4",
|
|
43
|
-
"funstream": "^4.2.0",
|
|
44
|
-
"glob": "^7.1.6",
|
|
45
|
-
"js-yaml": "^3.13.1",
|
|
46
|
-
"rimraf": "^3.0.2",
|
|
47
|
-
"tap": "^12.0.1",
|
|
48
|
-
"toml": "^3.0.0",
|
|
49
|
-
"toml-j0.4": "^1.1.1",
|
|
50
|
-
"weallbehave": "*",
|
|
51
|
-
"weallcontribute": "*"
|
|
52
|
-
},
|
|
53
|
-
"files": [
|
|
54
|
-
"toml.js",
|
|
55
|
-
"stringify.js",
|
|
56
|
-
"parse.js",
|
|
57
|
-
"parse-string.js",
|
|
58
|
-
"parse-stream.js",
|
|
59
|
-
"parse-async.js",
|
|
60
|
-
"parse-pretty-error.js",
|
|
61
|
-
"lib/parser.js",
|
|
62
|
-
"lib/parser-debug.js",
|
|
63
|
-
"lib/toml-parser.js",
|
|
64
|
-
"lib/create-datetime.js",
|
|
65
|
-
"lib/create-date.js",
|
|
66
|
-
"lib/create-datetime-float.js",
|
|
67
|
-
"lib/create-time.js",
|
|
68
|
-
"lib/format-num.js",
|
|
69
|
-
"index.d.ts"
|
|
70
|
-
],
|
|
71
|
-
"directories": {
|
|
72
|
-
"test": "test"
|
|
73
|
-
},
|
|
74
|
-
"repository": {
|
|
75
|
-
"type": "git",
|
|
76
|
-
"url": "git+https://github.com/iarna/iarna-toml.git"
|
|
77
|
-
},
|
|
78
|
-
"bugs": {
|
|
79
|
-
"url": "https://github.com/iarna/iarna-toml/issues"
|
|
80
|
-
},
|
|
81
|
-
"homepage": "https://github.com/iarna/iarna-toml#readme"
|
|
82
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
module.exports = parseAsync
|
|
3
|
-
|
|
4
|
-
const TOMLParser = require('./lib/toml-parser.js')
|
|
5
|
-
const prettyError = require('./parse-pretty-error.js')
|
|
6
|
-
|
|
7
|
-
function parseAsync (str, opts) {
|
|
8
|
-
if (!opts) opts = {}
|
|
9
|
-
const index = 0
|
|
10
|
-
const blocksize = opts.blocksize || 40960
|
|
11
|
-
const parser = new TOMLParser()
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
setImmediate(parseAsyncNext, index, blocksize, resolve, reject)
|
|
14
|
-
})
|
|
15
|
-
function parseAsyncNext (index, blocksize, resolve, reject) {
|
|
16
|
-
if (index >= str.length) {
|
|
17
|
-
try {
|
|
18
|
-
return resolve(parser.finish())
|
|
19
|
-
} catch (err) {
|
|
20
|
-
return reject(prettyError(err, str))
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
parser.parse(str.slice(index, index + blocksize))
|
|
25
|
-
setImmediate(parseAsyncNext, index + blocksize, blocksize, resolve, reject)
|
|
26
|
-
} catch (err) {
|
|
27
|
-
reject(prettyError(err, str))
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
module.exports = prettyError
|
|
3
|
-
|
|
4
|
-
function prettyError (err, buf) {
|
|
5
|
-
/* istanbul ignore if */
|
|
6
|
-
if (err.pos == null || err.line == null) return err
|
|
7
|
-
let msg = err.message
|
|
8
|
-
msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:\n`
|
|
9
|
-
|
|
10
|
-
/* istanbul ignore else */
|
|
11
|
-
if (buf && buf.split) {
|
|
12
|
-
const lines = buf.split(/\n/)
|
|
13
|
-
const lineNumWidth = String(Math.min(lines.length, err.line + 3)).length
|
|
14
|
-
let linePadding = ' '
|
|
15
|
-
while (linePadding.length < lineNumWidth) linePadding += ' '
|
|
16
|
-
for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
|
|
17
|
-
let lineNum = String(ii + 1)
|
|
18
|
-
if (lineNum.length < lineNumWidth) lineNum = ' ' + lineNum
|
|
19
|
-
if (err.line === ii) {
|
|
20
|
-
msg += lineNum + '> ' + lines[ii] + '\n'
|
|
21
|
-
msg += linePadding + ' '
|
|
22
|
-
for (let hh = 0; hh < err.col; ++hh) {
|
|
23
|
-
msg += ' '
|
|
24
|
-
}
|
|
25
|
-
msg += '^\n'
|
|
26
|
-
} else {
|
|
27
|
-
msg += lineNum + ': ' + lines[ii] + '\n'
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
err.message = msg + '\n'
|
|
32
|
-
return err
|
|
33
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
module.exports = parseStream
|
|
3
|
-
|
|
4
|
-
const stream = require('stream')
|
|
5
|
-
const TOMLParser = require('./lib/toml-parser.js')
|
|
6
|
-
|
|
7
|
-
function parseStream (stm) {
|
|
8
|
-
if (stm) {
|
|
9
|
-
return parseReadable(stm)
|
|
10
|
-
} else {
|
|
11
|
-
return parseTransform(stm)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function parseReadable (stm) {
|
|
16
|
-
const parser = new TOMLParser()
|
|
17
|
-
stm.setEncoding('utf8')
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
let readable
|
|
20
|
-
let ended = false
|
|
21
|
-
let errored = false
|
|
22
|
-
function finish () {
|
|
23
|
-
ended = true
|
|
24
|
-
if (readable) return
|
|
25
|
-
try {
|
|
26
|
-
resolve(parser.finish())
|
|
27
|
-
} catch (err) {
|
|
28
|
-
reject(err)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function error (err) {
|
|
32
|
-
errored = true
|
|
33
|
-
reject(err)
|
|
34
|
-
}
|
|
35
|
-
stm.once('end', finish)
|
|
36
|
-
stm.once('error', error)
|
|
37
|
-
readNext()
|
|
38
|
-
|
|
39
|
-
function readNext () {
|
|
40
|
-
readable = true
|
|
41
|
-
let data
|
|
42
|
-
while ((data = stm.read()) !== null) {
|
|
43
|
-
try {
|
|
44
|
-
parser.parse(data)
|
|
45
|
-
} catch (err) {
|
|
46
|
-
return error(err)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
readable = false
|
|
50
|
-
/* istanbul ignore if */
|
|
51
|
-
if (ended) return finish()
|
|
52
|
-
/* istanbul ignore if */
|
|
53
|
-
if (errored) return
|
|
54
|
-
stm.once('readable', readNext)
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function parseTransform () {
|
|
60
|
-
const parser = new TOMLParser()
|
|
61
|
-
return new stream.Transform({
|
|
62
|
-
objectMode: true,
|
|
63
|
-
transform (chunk, encoding, cb) {
|
|
64
|
-
try {
|
|
65
|
-
parser.parse(chunk.toString(encoding))
|
|
66
|
-
} catch (err) {
|
|
67
|
-
this.emit('error', err)
|
|
68
|
-
}
|
|
69
|
-
cb()
|
|
70
|
-
},
|
|
71
|
-
flush (cb) {
|
|
72
|
-
try {
|
|
73
|
-
this.push(parser.finish())
|
|
74
|
-
} catch (err) {
|
|
75
|
-
this.emit('error', err)
|
|
76
|
-
}
|
|
77
|
-
cb()
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
module.exports = parseString
|
|
3
|
-
|
|
4
|
-
const TOMLParser = require('./lib/toml-parser.js')
|
|
5
|
-
const prettyError = require('./parse-pretty-error.js')
|
|
6
|
-
|
|
7
|
-
function parseString (str) {
|
|
8
|
-
if (global.Buffer && global.Buffer.isBuffer(str)) {
|
|
9
|
-
str = str.toString('utf8')
|
|
10
|
-
}
|
|
11
|
-
const parser = new TOMLParser()
|
|
12
|
-
try {
|
|
13
|
-
parser.parse(str)
|
|
14
|
-
return parser.finish()
|
|
15
|
-
} catch (err) {
|
|
16
|
-
throw prettyError(err, str)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
module.exports = stringify
|
|
3
|
-
module.exports.value = stringifyInline
|
|
4
|
-
|
|
5
|
-
function stringify (obj) {
|
|
6
|
-
if (obj === null) throw typeError('null')
|
|
7
|
-
if (obj === void (0)) throw typeError('undefined')
|
|
8
|
-
if (typeof obj !== 'object') throw typeError(typeof obj)
|
|
9
|
-
|
|
10
|
-
if (typeof obj.toJSON === 'function') obj = obj.toJSON()
|
|
11
|
-
if (obj == null) return null
|
|
12
|
-
const type = tomlType(obj)
|
|
13
|
-
if (type !== 'table') throw typeError(type)
|
|
14
|
-
return stringifyObject('', '', obj)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function typeError (type) {
|
|
18
|
-
return new Error('Can only stringify objects, not ' + type)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function arrayOneTypeError () {
|
|
22
|
-
return new Error("Array values can't have mixed types")
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getInlineKeys (obj) {
|
|
26
|
-
return Object.keys(obj).filter(key => isInline(obj[key]))
|
|
27
|
-
}
|
|
28
|
-
function getComplexKeys (obj) {
|
|
29
|
-
return Object.keys(obj).filter(key => !isInline(obj[key]))
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function toJSON (obj) {
|
|
33
|
-
let nobj = Array.isArray(obj) ? [] : Object.prototype.hasOwnProperty.call(obj, '__proto__') ? {['__proto__']: undefined} : {}
|
|
34
|
-
for (let prop of Object.keys(obj)) {
|
|
35
|
-
if (obj[prop] && typeof obj[prop].toJSON === 'function' && !('toISOString' in obj[prop])) {
|
|
36
|
-
nobj[prop] = obj[prop].toJSON()
|
|
37
|
-
} else {
|
|
38
|
-
nobj[prop] = obj[prop]
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return nobj
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function stringifyObject (prefix, indent, obj) {
|
|
45
|
-
obj = toJSON(obj)
|
|
46
|
-
var inlineKeys
|
|
47
|
-
var complexKeys
|
|
48
|
-
inlineKeys = getInlineKeys(obj)
|
|
49
|
-
complexKeys = getComplexKeys(obj)
|
|
50
|
-
var result = []
|
|
51
|
-
var inlineIndent = indent || ''
|
|
52
|
-
inlineKeys.forEach(key => {
|
|
53
|
-
var type = tomlType(obj[key])
|
|
54
|
-
if (type !== 'undefined' && type !== 'null') {
|
|
55
|
-
result.push(inlineIndent + stringifyKey(key) + ' = ' + stringifyAnyInline(obj[key], true))
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
if (result.length > 0) result.push('')
|
|
59
|
-
var complexIndent = prefix && inlineKeys.length > 0 ? indent + ' ' : ''
|
|
60
|
-
complexKeys.forEach(key => {
|
|
61
|
-
result.push(stringifyComplex(prefix, complexIndent, key, obj[key]))
|
|
62
|
-
})
|
|
63
|
-
return result.join('\n')
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function isInline (value) {
|
|
67
|
-
switch (tomlType(value)) {
|
|
68
|
-
case 'undefined':
|
|
69
|
-
case 'null':
|
|
70
|
-
case 'integer':
|
|
71
|
-
case 'nan':
|
|
72
|
-
case 'float':
|
|
73
|
-
case 'boolean':
|
|
74
|
-
case 'string':
|
|
75
|
-
case 'datetime':
|
|
76
|
-
return true
|
|
77
|
-
case 'array':
|
|
78
|
-
return value.length === 0 || tomlType(value[0]) !== 'table'
|
|
79
|
-
case 'table':
|
|
80
|
-
return Object.keys(value).length === 0
|
|
81
|
-
/* istanbul ignore next */
|
|
82
|
-
default:
|
|
83
|
-
return false
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function tomlType (value) {
|
|
88
|
-
if (value === undefined) {
|
|
89
|
-
return 'undefined'
|
|
90
|
-
} else if (value === null) {
|
|
91
|
-
return 'null'
|
|
92
|
-
/* eslint-disable valid-typeof */
|
|
93
|
-
} else if (typeof value === 'bigint' || (Number.isInteger(value) && !Object.is(value, -0))) {
|
|
94
|
-
return 'integer'
|
|
95
|
-
} else if (typeof value === 'number') {
|
|
96
|
-
return 'float'
|
|
97
|
-
} else if (typeof value === 'boolean') {
|
|
98
|
-
return 'boolean'
|
|
99
|
-
} else if (typeof value === 'string') {
|
|
100
|
-
return 'string'
|
|
101
|
-
} else if ('toISOString' in value) {
|
|
102
|
-
return isNaN(value) ? 'undefined' : 'datetime'
|
|
103
|
-
} else if (Array.isArray(value)) {
|
|
104
|
-
return 'array'
|
|
105
|
-
} else {
|
|
106
|
-
return 'table'
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function stringifyKey (key) {
|
|
111
|
-
var keyStr = String(key)
|
|
112
|
-
if (/^[-A-Za-z0-9_]+$/.test(keyStr)) {
|
|
113
|
-
return keyStr
|
|
114
|
-
} else {
|
|
115
|
-
return stringifyBasicString(keyStr)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function stringifyBasicString (str) {
|
|
120
|
-
return '"' + escapeString(str).replace(/"/g, '\\"') + '"'
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function stringifyLiteralString (str) {
|
|
124
|
-
return "'" + str + "'"
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function numpad (num, str) {
|
|
128
|
-
while (str.length < num) str = '0' + str
|
|
129
|
-
return str
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function escapeString (str) {
|
|
133
|
-
return str.replace(/\\/g, '\\\\')
|
|
134
|
-
.replace(/[\b]/g, '\\b')
|
|
135
|
-
.replace(/\t/g, '\\t')
|
|
136
|
-
.replace(/\n/g, '\\n')
|
|
137
|
-
.replace(/\f/g, '\\f')
|
|
138
|
-
.replace(/\r/g, '\\r')
|
|
139
|
-
/* eslint-disable no-control-regex */
|
|
140
|
-
.replace(/([\u0000-\u001f\u007f])/, c => '\\u' + numpad(4, c.codePointAt(0).toString(16)))
|
|
141
|
-
/* eslint-enable no-control-regex */
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function stringifyMultilineString (str) {
|
|
145
|
-
let escaped = str.split(/\n/).map(str => {
|
|
146
|
-
return escapeString(str).replace(/"(?="")/g, '\\"')
|
|
147
|
-
}).join('\n')
|
|
148
|
-
if (escaped.slice(-1) === '"') escaped += '\\\n'
|
|
149
|
-
return '"""\n' + escaped + '"""'
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function stringifyAnyInline (value, multilineOk) {
|
|
153
|
-
let type = tomlType(value)
|
|
154
|
-
if (type === 'string') {
|
|
155
|
-
if (multilineOk && /\n/.test(value)) {
|
|
156
|
-
type = 'string-multiline'
|
|
157
|
-
} else if (!/[\b\t\n\f\r']/.test(value) && /"/.test(value)) {
|
|
158
|
-
type = 'string-literal'
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return stringifyInline(value, type)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function stringifyInline (value, type) {
|
|
165
|
-
/* istanbul ignore if */
|
|
166
|
-
if (!type) type = tomlType(value)
|
|
167
|
-
switch (type) {
|
|
168
|
-
case 'string-multiline':
|
|
169
|
-
return stringifyMultilineString(value)
|
|
170
|
-
case 'string':
|
|
171
|
-
return stringifyBasicString(value)
|
|
172
|
-
case 'string-literal':
|
|
173
|
-
return stringifyLiteralString(value)
|
|
174
|
-
case 'integer':
|
|
175
|
-
return stringifyInteger(value)
|
|
176
|
-
case 'float':
|
|
177
|
-
return stringifyFloat(value)
|
|
178
|
-
case 'boolean':
|
|
179
|
-
return stringifyBoolean(value)
|
|
180
|
-
case 'datetime':
|
|
181
|
-
return stringifyDatetime(value)
|
|
182
|
-
case 'array':
|
|
183
|
-
return stringifyInlineArray(value.filter(_ => tomlType(_) !== 'null' && tomlType(_) !== 'undefined' && tomlType(_) !== 'nan'))
|
|
184
|
-
case 'table':
|
|
185
|
-
return stringifyInlineTable(value)
|
|
186
|
-
/* istanbul ignore next */
|
|
187
|
-
default:
|
|
188
|
-
throw typeError(type)
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function stringifyInteger (value) {
|
|
193
|
-
/* eslint-disable security/detect-unsafe-regex */
|
|
194
|
-
return String(value).replace(/\B(?=(\d{3})+(?!\d))/g, '_')
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function stringifyFloat (value) {
|
|
198
|
-
if (value === Infinity) {
|
|
199
|
-
return 'inf'
|
|
200
|
-
} else if (value === -Infinity) {
|
|
201
|
-
return '-inf'
|
|
202
|
-
} else if (Object.is(value, NaN)) {
|
|
203
|
-
return 'nan'
|
|
204
|
-
} else if (Object.is(value, -0)) {
|
|
205
|
-
return '-0.0'
|
|
206
|
-
}
|
|
207
|
-
var chunks = String(value).split('.')
|
|
208
|
-
var int = chunks[0]
|
|
209
|
-
var dec = chunks[1] || 0
|
|
210
|
-
return stringifyInteger(int) + '.' + dec
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function stringifyBoolean (value) {
|
|
214
|
-
return String(value)
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function stringifyDatetime (value) {
|
|
218
|
-
return value.toISOString()
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function isNumber (type) {
|
|
222
|
-
return type === 'float' || type === 'integer'
|
|
223
|
-
}
|
|
224
|
-
function arrayType (values) {
|
|
225
|
-
var contentType = tomlType(values[0])
|
|
226
|
-
if (values.every(_ => tomlType(_) === contentType)) return contentType
|
|
227
|
-
// mixed integer/float, emit as floats
|
|
228
|
-
if (values.every(_ => isNumber(tomlType(_)))) return 'float'
|
|
229
|
-
return 'mixed'
|
|
230
|
-
}
|
|
231
|
-
function validateArray (values) {
|
|
232
|
-
const type = arrayType(values)
|
|
233
|
-
if (type === 'mixed') {
|
|
234
|
-
throw arrayOneTypeError()
|
|
235
|
-
}
|
|
236
|
-
return type
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function stringifyInlineArray (values) {
|
|
240
|
-
values = toJSON(values)
|
|
241
|
-
const type = validateArray(values)
|
|
242
|
-
var result = '['
|
|
243
|
-
var stringified = values.map(_ => stringifyInline(_, type))
|
|
244
|
-
if (stringified.join(', ').length > 60 || /\n/.test(stringified)) {
|
|
245
|
-
result += '\n ' + stringified.join(',\n ') + '\n'
|
|
246
|
-
} else {
|
|
247
|
-
result += ' ' + stringified.join(', ') + (stringified.length > 0 ? ' ' : '')
|
|
248
|
-
}
|
|
249
|
-
return result + ']'
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function stringifyInlineTable (value) {
|
|
253
|
-
value = toJSON(value)
|
|
254
|
-
var result = []
|
|
255
|
-
Object.keys(value).forEach(key => {
|
|
256
|
-
result.push(stringifyKey(key) + ' = ' + stringifyAnyInline(value[key], false))
|
|
257
|
-
})
|
|
258
|
-
return '{ ' + result.join(', ') + (result.length > 0 ? ' ' : '') + '}'
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function stringifyComplex (prefix, indent, key, value) {
|
|
262
|
-
var valueType = tomlType(value)
|
|
263
|
-
/* istanbul ignore else */
|
|
264
|
-
if (valueType === 'array') {
|
|
265
|
-
return stringifyArrayOfTables(prefix, indent, key, value)
|
|
266
|
-
} else if (valueType === 'table') {
|
|
267
|
-
return stringifyComplexTable(prefix, indent, key, value)
|
|
268
|
-
} else {
|
|
269
|
-
throw typeError(valueType)
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function stringifyArrayOfTables (prefix, indent, key, values) {
|
|
274
|
-
values = toJSON(values)
|
|
275
|
-
validateArray(values)
|
|
276
|
-
var firstValueType = tomlType(values[0])
|
|
277
|
-
/* istanbul ignore if */
|
|
278
|
-
if (firstValueType !== 'table') throw typeError(firstValueType)
|
|
279
|
-
var fullKey = prefix + stringifyKey(key)
|
|
280
|
-
var result = ''
|
|
281
|
-
values.forEach(table => {
|
|
282
|
-
if (result.length > 0) result += '\n'
|
|
283
|
-
result += indent + '[[' + fullKey + ']]\n'
|
|
284
|
-
result += stringifyObject(fullKey + '.', indent, table)
|
|
285
|
-
})
|
|
286
|
-
return result
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function stringifyComplexTable (prefix, indent, key, value) {
|
|
290
|
-
var fullKey = prefix + stringifyKey(key)
|
|
291
|
-
var result = ''
|
|
292
|
-
if (getInlineKeys(value).length > 0) {
|
|
293
|
-
result += indent + '[' + fullKey + ']\n'
|
|
294
|
-
}
|
|
295
|
-
return result + stringifyObject(fullKey + '.', indent, value)
|
|
296
|
-
}
|