@emulsify/cli 2.0.0 → 2.1.1
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/README.md +131 -12
- package/dist/handlers/componentInstall.js +65 -4
- package/dist/index.js +2 -0
- package/dist/node_modules/.package-lock.json +6 -216
- package/dist/node_modules/@types/node/README.md +1 -1
- package/dist/node_modules/@types/node/http2.d.ts +1 -0
- package/dist/node_modules/@types/node/package.json +2 -2
- package/dist/package-lock.json +61 -42
- package/dist/package.json +5 -6
- package/dist/schemas/emulsifyProjectConfig.json +80 -0
- package/dist/util/fs/executeScript.js +10 -4
- package/dist/util/fs/loadJsonFile.js +14 -4
- package/dist/util/fs/safeResolveWithin.js +22 -0
- package/dist/util/getRepositoryLatestTag.js +96 -13
- package/dist/util/project/buildComponentDependencyList.js +35 -10
- package/dist/util/project/generateComponent.js +52 -23
- package/dist/util/project/getEmulsifyConfig.js +35 -1
- package/dist/util/project/installComponentFromCache.js +3 -2
- package/dist/util/project/installGeneralAssetsFromCache.js +4 -2
- package/dist/util/system/getAvailableSystems.js +0 -5
- package/package.json +5 -6
- package/dist/node_modules/@babel/code-frame/LICENSE +0 -22
- package/dist/node_modules/@babel/code-frame/README.md +0 -19
- package/dist/node_modules/@babel/code-frame/lib/index.js +0 -217
- package/dist/node_modules/@babel/code-frame/lib/index.js.map +0 -1
- package/dist/node_modules/@babel/code-frame/package.json +0 -32
- package/dist/node_modules/@babel/helper-validator-identifier/LICENSE +0 -22
- package/dist/node_modules/@babel/helper-validator-identifier/README.md +0 -19
- package/dist/node_modules/@babel/helper-validator-identifier/lib/identifier.js +0 -70
- package/dist/node_modules/@babel/helper-validator-identifier/lib/identifier.js.map +0 -1
- package/dist/node_modules/@babel/helper-validator-identifier/lib/index.js +0 -57
- package/dist/node_modules/@babel/helper-validator-identifier/lib/index.js.map +0 -1
- package/dist/node_modules/@babel/helper-validator-identifier/lib/keyword.js +0 -35
- package/dist/node_modules/@babel/helper-validator-identifier/lib/keyword.js.map +0 -1
- package/dist/node_modules/@babel/helper-validator-identifier/package.json +0 -31
- package/dist/node_modules/@types/progress/LICENSE +0 -21
- package/dist/node_modules/@types/progress/README.md +0 -15
- package/dist/node_modules/@types/progress/index.d.ts +0 -143
- package/dist/node_modules/@types/progress/package.json +0 -27
- package/dist/node_modules/argparse/CHANGELOG.md +0 -216
- package/dist/node_modules/argparse/LICENSE +0 -254
- package/dist/node_modules/argparse/README.md +0 -84
- package/dist/node_modules/argparse/argparse.js +0 -3707
- package/dist/node_modules/argparse/lib/sub.js +0 -67
- package/dist/node_modules/argparse/lib/textwrap.js +0 -440
- package/dist/node_modules/argparse/package.json +0 -31
- package/dist/node_modules/callsites/index.d.ts +0 -96
- package/dist/node_modules/callsites/index.js +0 -13
- package/dist/node_modules/callsites/license +0 -9
- package/dist/node_modules/callsites/package.json +0 -39
- package/dist/node_modules/callsites/readme.md +0 -48
- package/dist/node_modules/cosmiconfig/LICENSE +0 -22
- package/dist/node_modules/cosmiconfig/README.md +0 -782
- package/dist/node_modules/cosmiconfig/dist/Explorer.d.ts +0 -2
- package/dist/node_modules/cosmiconfig/dist/Explorer.js +0 -174
- package/dist/node_modules/cosmiconfig/dist/ExplorerBase.d.ts +0 -2
- package/dist/node_modules/cosmiconfig/dist/ExplorerBase.js +0 -126
- package/dist/node_modules/cosmiconfig/dist/ExplorerSync.d.ts +0 -2
- package/dist/node_modules/cosmiconfig/dist/ExplorerSync.js +0 -188
- package/dist/node_modules/cosmiconfig/dist/defaults.d.ts +0 -25
- package/dist/node_modules/cosmiconfig/dist/defaults.js +0 -105
- package/dist/node_modules/cosmiconfig/dist/index.d.ts +0 -6
- package/dist/node_modules/cosmiconfig/dist/index.js +0 -148
- package/dist/node_modules/cosmiconfig/dist/loaders.d.ts +0 -8
- package/dist/node_modules/cosmiconfig/dist/loaders.js +0 -150
- package/dist/node_modules/cosmiconfig/dist/merge.d.ts +0 -9
- package/dist/node_modules/cosmiconfig/dist/merge.js +0 -44
- package/dist/node_modules/cosmiconfig/dist/types.d.ts +0 -98
- package/dist/node_modules/cosmiconfig/dist/types.js +0 -3
- package/dist/node_modules/cosmiconfig/dist/util.d.ts +0 -2
- package/dist/node_modules/cosmiconfig/dist/util.js +0 -108
- package/dist/node_modules/cosmiconfig/package.json +0 -103
- package/dist/node_modules/env-paths/index.d.ts +0 -101
- package/dist/node_modules/env-paths/index.js +0 -74
- package/dist/node_modules/env-paths/license +0 -9
- package/dist/node_modules/env-paths/package.json +0 -45
- package/dist/node_modules/env-paths/readme.md +0 -115
- package/dist/node_modules/error-ex/LICENSE +0 -21
- package/dist/node_modules/error-ex/README.md +0 -144
- package/dist/node_modules/error-ex/index.js +0 -141
- package/dist/node_modules/error-ex/package.json +0 -46
- package/dist/node_modules/import-fresh/index.d.ts +0 -30
- package/dist/node_modules/import-fresh/index.js +0 -34
- package/dist/node_modules/import-fresh/license +0 -9
- package/dist/node_modules/import-fresh/node_modules/resolve-from/index.js +0 -47
- package/dist/node_modules/import-fresh/node_modules/resolve-from/license +0 -9
- package/dist/node_modules/import-fresh/node_modules/resolve-from/package.json +0 -34
- package/dist/node_modules/import-fresh/node_modules/resolve-from/readme.md +0 -72
- package/dist/node_modules/import-fresh/package.json +0 -48
- package/dist/node_modules/import-fresh/readme.md +0 -54
- package/dist/node_modules/is-arrayish/.editorconfig +0 -18
- package/dist/node_modules/is-arrayish/.istanbul.yml +0 -4
- package/dist/node_modules/is-arrayish/.travis.yml +0 -17
- package/dist/node_modules/is-arrayish/LICENSE +0 -21
- package/dist/node_modules/is-arrayish/README.md +0 -16
- package/dist/node_modules/is-arrayish/index.js +0 -10
- package/dist/node_modules/is-arrayish/package.json +0 -34
- package/dist/node_modules/js-tokens/CHANGELOG.md +0 -151
- package/dist/node_modules/js-tokens/LICENSE +0 -21
- package/dist/node_modules/js-tokens/README.md +0 -240
- package/dist/node_modules/js-tokens/index.js +0 -23
- package/dist/node_modules/js-tokens/package.json +0 -30
- package/dist/node_modules/js-yaml/LICENSE +0 -21
- package/dist/node_modules/js-yaml/README.md +0 -231
- package/dist/node_modules/js-yaml/bin/js-yaml.js +0 -117
- package/dist/node_modules/js-yaml/dist/js-yaml.js +0 -2404
- package/dist/node_modules/js-yaml/dist/js-yaml.js.map +0 -1
- package/dist/node_modules/js-yaml/dist/js-yaml.min.js +0 -33
- package/dist/node_modules/js-yaml/dist/js-yaml.min.js.map +0 -1
- package/dist/node_modules/js-yaml/dist/js-yaml.mjs +0 -2382
- package/dist/node_modules/js-yaml/dist/js-yaml.mjs.map +0 -1
- package/dist/node_modules/js-yaml/index.js +0 -44
- package/dist/node_modules/js-yaml/lib/common.js +0 -50
- package/dist/node_modules/js-yaml/lib/dumper.js +0 -937
- package/dist/node_modules/js-yaml/lib/exception.js +0 -51
- package/dist/node_modules/js-yaml/lib/index_vite_proxy.tmp.mjs +0 -37
- package/dist/node_modules/js-yaml/lib/loader.js +0 -1794
- package/dist/node_modules/js-yaml/lib/schema/core.js +0 -9
- package/dist/node_modules/js-yaml/lib/schema/default.js +0 -20
- package/dist/node_modules/js-yaml/lib/schema/failsafe.js +0 -14
- package/dist/node_modules/js-yaml/lib/schema/json.js +0 -17
- package/dist/node_modules/js-yaml/lib/schema.js +0 -109
- package/dist/node_modules/js-yaml/lib/snippet.js +0 -96
- package/dist/node_modules/js-yaml/lib/type/binary.js +0 -122
- package/dist/node_modules/js-yaml/lib/type/bool.js +0 -35
- package/dist/node_modules/js-yaml/lib/type/float.js +0 -99
- package/dist/node_modules/js-yaml/lib/type/int.js +0 -142
- package/dist/node_modules/js-yaml/lib/type/map.js +0 -8
- package/dist/node_modules/js-yaml/lib/type/merge.js +0 -12
- package/dist/node_modules/js-yaml/lib/type/null.js +0 -35
- package/dist/node_modules/js-yaml/lib/type/omap.js +0 -45
- package/dist/node_modules/js-yaml/lib/type/pairs.js +0 -50
- package/dist/node_modules/js-yaml/lib/type/seq.js +0 -8
- package/dist/node_modules/js-yaml/lib/type/set.js +0 -29
- package/dist/node_modules/js-yaml/lib/type/str.js +0 -8
- package/dist/node_modules/js-yaml/lib/type/timestamp.js +0 -88
- package/dist/node_modules/js-yaml/lib/type.js +0 -66
- package/dist/node_modules/js-yaml/package.json +0 -77
- package/dist/node_modules/json-parse-even-better-errors/CHANGELOG.md +0 -50
- package/dist/node_modules/json-parse-even-better-errors/LICENSE.md +0 -25
- package/dist/node_modules/json-parse-even-better-errors/README.md +0 -96
- package/dist/node_modules/json-parse-even-better-errors/index.js +0 -121
- package/dist/node_modules/json-parse-even-better-errors/package.json +0 -33
- package/dist/node_modules/lines-and-columns/LICENSE +0 -21
- package/dist/node_modules/lines-and-columns/README.md +0 -33
- package/dist/node_modules/lines-and-columns/build/index.d.ts +0 -13
- package/dist/node_modules/lines-and-columns/build/index.js +0 -62
- package/dist/node_modules/lines-and-columns/package.json +0 -49
- package/dist/node_modules/parent-module/index.js +0 -37
- package/dist/node_modules/parent-module/license +0 -9
- package/dist/node_modules/parent-module/package.json +0 -46
- package/dist/node_modules/parent-module/readme.md +0 -67
- package/dist/node_modules/parse-json/index.js +0 -54
- package/dist/node_modules/parse-json/license +0 -9
- package/dist/node_modules/parse-json/package.json +0 -45
- package/dist/node_modules/parse-json/readme.md +0 -119
- package/dist/node_modules/picocolors/LICENSE +0 -15
- package/dist/node_modules/picocolors/README.md +0 -21
- package/dist/node_modules/picocolors/package.json +0 -25
- package/dist/node_modules/picocolors/picocolors.browser.js +0 -4
- package/dist/node_modules/picocolors/picocolors.d.ts +0 -5
- package/dist/node_modules/picocolors/picocolors.js +0 -75
- package/dist/node_modules/picocolors/types.d.ts +0 -51
- package/dist/node_modules/typescript/LICENSE.txt +0 -55
- package/dist/node_modules/typescript/README.md +0 -50
- package/dist/node_modules/typescript/SECURITY.md +0 -39
- package/dist/node_modules/typescript/ThirdPartyNoticeText.txt +0 -193
- package/dist/node_modules/typescript/bin/tsc +0 -2
- package/dist/node_modules/typescript/bin/tsserver +0 -2
- package/dist/node_modules/typescript/lib/_tsc.js +0 -134465
- package/dist/node_modules/typescript/lib/_tsserver.js +0 -659
- package/dist/node_modules/typescript/lib/_typingsInstaller.js +0 -222
- package/dist/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2125
- package/dist/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2125
- package/dist/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/lib.d.ts +0 -20
- package/dist/node_modules/typescript/lib/lib.decorators.d.ts +0 -382
- package/dist/node_modules/typescript/lib/lib.decorators.legacy.d.ts +0 -20
- package/dist/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +0 -18
- package/dist/node_modules/typescript/lib/lib.dom.d.ts +0 -45125
- package/dist/node_modules/typescript/lib/lib.dom.iterable.d.ts +0 -18
- package/dist/node_modules/typescript/lib/lib.es2015.collection.d.ts +0 -150
- package/dist/node_modules/typescript/lib/lib.es2015.core.d.ts +0 -595
- package/dist/node_modules/typescript/lib/lib.es2015.d.ts +0 -26
- package/dist/node_modules/typescript/lib/lib.es2015.generator.d.ts +0 -75
- package/dist/node_modules/typescript/lib/lib.es2015.iterable.d.ts +0 -603
- package/dist/node_modules/typescript/lib/lib.es2015.promise.d.ts +0 -79
- package/dist/node_modules/typescript/lib/lib.es2015.proxy.d.ts +0 -126
- package/dist/node_modules/typescript/lib/lib.es2015.reflect.d.ts +0 -142
- package/dist/node_modules/typescript/lib/lib.es2015.symbol.d.ts +0 -44
- package/dist/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -324
- package/dist/node_modules/typescript/lib/lib.es2016.array.include.d.ts +0 -114
- package/dist/node_modules/typescript/lib/lib.es2016.d.ts +0 -19
- package/dist/node_modules/typescript/lib/lib.es2016.full.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.es2016.intl.d.ts +0 -29
- package/dist/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +0 -19
- package/dist/node_modules/typescript/lib/lib.es2017.d.ts +0 -24
- package/dist/node_modules/typescript/lib/lib.es2017.date.d.ts +0 -29
- package/dist/node_modules/typescript/lib/lib.es2017.full.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.es2017.intl.d.ts +0 -42
- package/dist/node_modules/typescript/lib/lib.es2017.object.d.ts +0 -47
- package/dist/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +0 -133
- package/dist/node_modules/typescript/lib/lib.es2017.string.d.ts +0 -43
- package/dist/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +0 -51
- package/dist/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -75
- package/dist/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +0 -51
- package/dist/node_modules/typescript/lib/lib.es2018.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2018.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2018.intl.d.ts +0 -81
- package/dist/node_modules/typescript/lib/lib.es2018.promise.d.ts +0 -28
- package/dist/node_modules/typescript/lib/lib.es2018.regexp.d.ts +0 -35
- package/dist/node_modules/typescript/lib/lib.es2019.array.d.ts +0 -77
- package/dist/node_modules/typescript/lib/lib.es2019.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2019.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2019.intl.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.es2019.object.d.ts +0 -31
- package/dist/node_modules/typescript/lib/lib.es2019.string.d.ts +0 -35
- package/dist/node_modules/typescript/lib/lib.es2019.symbol.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2020.bigint.d.ts +0 -763
- package/dist/node_modules/typescript/lib/lib.es2020.d.ts +0 -25
- package/dist/node_modules/typescript/lib/lib.es2020.date.d.ts +0 -40
- package/dist/node_modules/typescript/lib/lib.es2020.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2020.intl.d.ts +0 -472
- package/dist/node_modules/typescript/lib/lib.es2020.number.d.ts +0 -26
- package/dist/node_modules/typescript/lib/lib.es2020.promise.d.ts +0 -45
- package/dist/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +0 -97
- package/dist/node_modules/typescript/lib/lib.es2020.string.d.ts +0 -42
- package/dist/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -39
- package/dist/node_modules/typescript/lib/lib.es2021.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.es2021.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2021.intl.d.ts +0 -164
- package/dist/node_modules/typescript/lib/lib.es2021.promise.d.ts +0 -46
- package/dist/node_modules/typescript/lib/lib.es2021.string.d.ts +0 -31
- package/dist/node_modules/typescript/lib/lib.es2021.weakref.d.ts +0 -76
- package/dist/node_modules/typescript/lib/lib.es2022.array.d.ts +0 -119
- package/dist/node_modules/typescript/lib/lib.es2022.d.ts +0 -23
- package/dist/node_modules/typescript/lib/lib.es2022.error.d.ts +0 -73
- package/dist/node_modules/typescript/lib/lib.es2022.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2022.intl.d.ts +0 -143
- package/dist/node_modules/typescript/lib/lib.es2022.object.d.ts +0 -24
- package/dist/node_modules/typescript/lib/lib.es2022.regexp.d.ts +0 -37
- package/dist/node_modules/typescript/lib/lib.es2022.string.d.ts +0 -23
- package/dist/node_modules/typescript/lib/lib.es2023.array.d.ts +0 -922
- package/dist/node_modules/typescript/lib/lib.es2023.collection.d.ts +0 -19
- package/dist/node_modules/typescript/lib/lib.es2023.d.ts +0 -20
- package/dist/node_modules/typescript/lib/lib.es2023.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2023.intl.d.ts +0 -62
- package/dist/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +0 -63
- package/dist/node_modules/typescript/lib/lib.es2024.collection.d.ts +0 -27
- package/dist/node_modules/typescript/lib/lib.es2024.d.ts +0 -24
- package/dist/node_modules/typescript/lib/lib.es2024.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2024.object.d.ts +0 -27
- package/dist/node_modules/typescript/lib/lib.es2024.promise.d.ts +0 -33
- package/dist/node_modules/typescript/lib/lib.es2024.regexp.d.ts +0 -23
- package/dist/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +0 -66
- package/dist/node_modules/typescript/lib/lib.es2024.string.d.ts +0 -27
- package/dist/node_modules/typescript/lib/lib.es2025.collection.d.ts +0 -94
- package/dist/node_modules/typescript/lib/lib.es2025.d.ts +0 -23
- package/dist/node_modules/typescript/lib/lib.es2025.float16.d.ts +0 -443
- package/dist/node_modules/typescript/lib/lib.es2025.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2025.intl.d.ts +0 -200
- package/dist/node_modules/typescript/lib/lib.es2025.iterator.d.ts +0 -146
- package/dist/node_modules/typescript/lib/lib.es2025.promise.d.ts +0 -32
- package/dist/node_modules/typescript/lib/lib.es2025.regexp.d.ts +0 -30
- package/dist/node_modules/typescript/lib/lib.es5.d.ts +0 -4599
- package/dist/node_modules/typescript/lib/lib.es6.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.esnext.array.d.ts +0 -33
- package/dist/node_modules/typescript/lib/lib.esnext.collection.d.ts +0 -47
- package/dist/node_modules/typescript/lib/lib.esnext.d.ts +0 -27
- package/dist/node_modules/typescript/lib/lib.esnext.date.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.esnext.decorators.d.ts +0 -26
- package/dist/node_modules/typescript/lib/lib.esnext.disposable.d.ts +0 -191
- package/dist/node_modules/typescript/lib/lib.esnext.error.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.esnext.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.esnext.intl.d.ts +0 -107
- package/dist/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +0 -23
- package/dist/node_modules/typescript/lib/lib.esnext.temporal.d.ts +0 -485
- package/dist/node_modules/typescript/lib/lib.esnext.typedarrays.d.ts +0 -90
- package/dist/node_modules/typescript/lib/lib.scripthost.d.ts +0 -320
- package/dist/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +0 -18
- package/dist/node_modules/typescript/lib/lib.webworker.d.ts +0 -15606
- package/dist/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.webworker.iterable.d.ts +0 -18
- package/dist/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2125
- package/dist/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/tsc.js +0 -8
- package/dist/node_modules/typescript/lib/tsserver.js +0 -8
- package/dist/node_modules/typescript/lib/tsserverlibrary.d.ts +0 -17
- package/dist/node_modules/typescript/lib/tsserverlibrary.js +0 -21
- package/dist/node_modules/typescript/lib/typesMap.json +0 -497
- package/dist/node_modules/typescript/lib/typescript.d.ts +0 -11448
- package/dist/node_modules/typescript/lib/typescript.js +0 -201039
- package/dist/node_modules/typescript/lib/typingsInstaller.js +0 -8
- package/dist/node_modules/typescript/lib/watchGuard.js +0 -53
- package/dist/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -2125
- package/dist/node_modules/typescript/package.json +0 -118
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const hexify = char => {
|
|
4
|
-
const h = char.charCodeAt(0).toString(16).toUpperCase()
|
|
5
|
-
return '0x' + (h.length % 2 ? '0' : '') + h
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const parseError = (e, txt, context) => {
|
|
9
|
-
if (!txt) {
|
|
10
|
-
return {
|
|
11
|
-
message: e.message + ' while parsing empty string',
|
|
12
|
-
position: 0,
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
const badToken = e.message.match(/^Unexpected token (.) .*position\s+(\d+)/i)
|
|
16
|
-
const errIdx = badToken ? +badToken[2]
|
|
17
|
-
: e.message.match(/^Unexpected end of JSON.*/i) ? txt.length - 1
|
|
18
|
-
: null
|
|
19
|
-
|
|
20
|
-
const msg = badToken ? e.message.replace(/^Unexpected token ./, `Unexpected token ${
|
|
21
|
-
JSON.stringify(badToken[1])
|
|
22
|
-
} (${hexify(badToken[1])})`)
|
|
23
|
-
: e.message
|
|
24
|
-
|
|
25
|
-
if (errIdx !== null && errIdx !== undefined) {
|
|
26
|
-
const start = errIdx <= context ? 0
|
|
27
|
-
: errIdx - context
|
|
28
|
-
|
|
29
|
-
const end = errIdx + context >= txt.length ? txt.length
|
|
30
|
-
: errIdx + context
|
|
31
|
-
|
|
32
|
-
const slice = (start === 0 ? '' : '...') +
|
|
33
|
-
txt.slice(start, end) +
|
|
34
|
-
(end === txt.length ? '' : '...')
|
|
35
|
-
|
|
36
|
-
const near = txt === slice ? '' : 'near '
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
message: msg + ` while parsing ${near}${JSON.stringify(slice)}`,
|
|
40
|
-
position: errIdx,
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
return {
|
|
44
|
-
message: msg + ` while parsing '${txt.slice(0, context * 2)}'`,
|
|
45
|
-
position: 0,
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class JSONParseError extends SyntaxError {
|
|
51
|
-
constructor (er, txt, context, caller) {
|
|
52
|
-
context = context || 20
|
|
53
|
-
const metadata = parseError(er, txt, context)
|
|
54
|
-
super(metadata.message)
|
|
55
|
-
Object.assign(this, metadata)
|
|
56
|
-
this.code = 'EJSONPARSE'
|
|
57
|
-
this.systemError = er
|
|
58
|
-
Error.captureStackTrace(this, caller || this.constructor)
|
|
59
|
-
}
|
|
60
|
-
get name () { return this.constructor.name }
|
|
61
|
-
set name (n) {}
|
|
62
|
-
get [Symbol.toStringTag] () { return this.constructor.name }
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const kIndent = Symbol.for('indent')
|
|
66
|
-
const kNewline = Symbol.for('newline')
|
|
67
|
-
// only respect indentation if we got a line break, otherwise squash it
|
|
68
|
-
// things other than objects and arrays aren't indented, so ignore those
|
|
69
|
-
// Important: in both of these regexps, the $1 capture group is the newline
|
|
70
|
-
// or undefined, and the $2 capture group is the indent, or undefined.
|
|
71
|
-
const formatRE = /^\s*[{\[]((?:\r?\n)+)([\s\t]*)/
|
|
72
|
-
const emptyRE = /^(?:\{\}|\[\])((?:\r?\n)+)?$/
|
|
73
|
-
|
|
74
|
-
const parseJson = (txt, reviver, context) => {
|
|
75
|
-
const parseText = stripBOM(txt)
|
|
76
|
-
context = context || 20
|
|
77
|
-
try {
|
|
78
|
-
// get the indentation so that we can save it back nicely
|
|
79
|
-
// if the file starts with {" then we have an indent of '', ie, none
|
|
80
|
-
// otherwise, pick the indentation of the next line after the first \n
|
|
81
|
-
// If the pattern doesn't match, then it means no indentation.
|
|
82
|
-
// JSON.stringify ignores symbols, so this is reasonably safe.
|
|
83
|
-
// if the string is '{}' or '[]', then use the default 2-space indent.
|
|
84
|
-
const [, newline = '\n', indent = ' '] = parseText.match(emptyRE) ||
|
|
85
|
-
parseText.match(formatRE) ||
|
|
86
|
-
[, '', '']
|
|
87
|
-
|
|
88
|
-
const result = JSON.parse(parseText, reviver)
|
|
89
|
-
if (result && typeof result === 'object') {
|
|
90
|
-
result[kNewline] = newline
|
|
91
|
-
result[kIndent] = indent
|
|
92
|
-
}
|
|
93
|
-
return result
|
|
94
|
-
} catch (e) {
|
|
95
|
-
if (typeof txt !== 'string' && !Buffer.isBuffer(txt)) {
|
|
96
|
-
const isEmptyArray = Array.isArray(txt) && txt.length === 0
|
|
97
|
-
throw Object.assign(new TypeError(
|
|
98
|
-
`Cannot parse ${isEmptyArray ? 'an empty array' : String(txt)}`
|
|
99
|
-
), {
|
|
100
|
-
code: 'EJSONPARSE',
|
|
101
|
-
systemError: e,
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
throw new JSONParseError(e, parseText, context, parseJson)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
|
110
|
-
// because the buffer-to-string conversion in `fs.readFileSync()`
|
|
111
|
-
// translates it to FEFF, the UTF-16 BOM.
|
|
112
|
-
const stripBOM = txt => String(txt).replace(/^\uFEFF/, '')
|
|
113
|
-
|
|
114
|
-
module.exports = parseJson
|
|
115
|
-
parseJson.JSONParseError = JSONParseError
|
|
116
|
-
|
|
117
|
-
parseJson.noExceptions = (txt, reviver) => {
|
|
118
|
-
try {
|
|
119
|
-
return JSON.parse(stripBOM(txt), reviver)
|
|
120
|
-
} catch (e) {}
|
|
121
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "json-parse-even-better-errors",
|
|
3
|
-
"version": "2.3.1",
|
|
4
|
-
"description": "JSON.parse with context information on error",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"*.js"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"preversion": "npm t",
|
|
11
|
-
"postversion": "npm publish",
|
|
12
|
-
"prepublishOnly": "git push --follow-tags",
|
|
13
|
-
"test": "tap",
|
|
14
|
-
"snap": "tap"
|
|
15
|
-
},
|
|
16
|
-
"repository": "https://github.com/npm/json-parse-even-better-errors",
|
|
17
|
-
"keywords": [
|
|
18
|
-
"JSON",
|
|
19
|
-
"parser"
|
|
20
|
-
],
|
|
21
|
-
"author": {
|
|
22
|
-
"name": "Kat Marchán",
|
|
23
|
-
"email": "kzm@zkat.tech",
|
|
24
|
-
"twitter": "maybekatz"
|
|
25
|
-
},
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"tap": "^14.6.5"
|
|
29
|
-
},
|
|
30
|
-
"tap": {
|
|
31
|
-
"check-coverage": true
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 Brian Donovan
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# lines-and-columns
|
|
2
|
-
|
|
3
|
-
Maps lines and columns to character offsets and back. This is useful for parsers
|
|
4
|
-
and other text processors that deal in character ranges but process text with
|
|
5
|
-
meaningful lines and columns.
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
$ npm install [--save] lines-and-columns
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
import { LinesAndColumns } from 'lines-and-columns'
|
|
17
|
-
|
|
18
|
-
const lines = new LinesAndColumns(
|
|
19
|
-
`table {
|
|
20
|
-
border: 0
|
|
21
|
-
}`
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
lines.locationForIndex(9)
|
|
25
|
-
// { line: 1, column: 1 }
|
|
26
|
-
|
|
27
|
-
lines.indexForLocation({ line: 1, column: 2 })
|
|
28
|
-
// 10
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## License
|
|
32
|
-
|
|
33
|
-
MIT
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare type SourceLocation = {
|
|
2
|
-
line: number;
|
|
3
|
-
column: number;
|
|
4
|
-
};
|
|
5
|
-
export declare class LinesAndColumns {
|
|
6
|
-
private string;
|
|
7
|
-
private offsets;
|
|
8
|
-
constructor(string: string);
|
|
9
|
-
locationForIndex(index: number): SourceLocation | null;
|
|
10
|
-
indexForLocation(location: SourceLocation): number | null;
|
|
11
|
-
private lengthOfLine;
|
|
12
|
-
}
|
|
13
|
-
export default LinesAndColumns;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.LinesAndColumns = void 0;
|
|
4
|
-
var LF = '\n';
|
|
5
|
-
var CR = '\r';
|
|
6
|
-
var LinesAndColumns = /** @class */ (function () {
|
|
7
|
-
function LinesAndColumns(string) {
|
|
8
|
-
this.string = string;
|
|
9
|
-
var offsets = [0];
|
|
10
|
-
for (var offset = 0; offset < string.length;) {
|
|
11
|
-
switch (string[offset]) {
|
|
12
|
-
case LF:
|
|
13
|
-
offset += LF.length;
|
|
14
|
-
offsets.push(offset);
|
|
15
|
-
break;
|
|
16
|
-
case CR:
|
|
17
|
-
offset += CR.length;
|
|
18
|
-
if (string[offset] === LF) {
|
|
19
|
-
offset += LF.length;
|
|
20
|
-
}
|
|
21
|
-
offsets.push(offset);
|
|
22
|
-
break;
|
|
23
|
-
default:
|
|
24
|
-
offset++;
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
this.offsets = offsets;
|
|
29
|
-
}
|
|
30
|
-
LinesAndColumns.prototype.locationForIndex = function (index) {
|
|
31
|
-
if (index < 0 || index > this.string.length) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
var line = 0;
|
|
35
|
-
var offsets = this.offsets;
|
|
36
|
-
while (offsets[line + 1] <= index) {
|
|
37
|
-
line++;
|
|
38
|
-
}
|
|
39
|
-
var column = index - offsets[line];
|
|
40
|
-
return { line: line, column: column };
|
|
41
|
-
};
|
|
42
|
-
LinesAndColumns.prototype.indexForLocation = function (location) {
|
|
43
|
-
var line = location.line, column = location.column;
|
|
44
|
-
if (line < 0 || line >= this.offsets.length) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
if (column < 0 || column > this.lengthOfLine(line)) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
return this.offsets[line] + column;
|
|
51
|
-
};
|
|
52
|
-
LinesAndColumns.prototype.lengthOfLine = function (line) {
|
|
53
|
-
var offset = this.offsets[line];
|
|
54
|
-
var nextOffset = line === this.offsets.length - 1
|
|
55
|
-
? this.string.length
|
|
56
|
-
: this.offsets[line + 1];
|
|
57
|
-
return nextOffset - offset;
|
|
58
|
-
};
|
|
59
|
-
return LinesAndColumns;
|
|
60
|
-
}());
|
|
61
|
-
exports.LinesAndColumns = LinesAndColumns;
|
|
62
|
-
exports["default"] = LinesAndColumns;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "lines-and-columns",
|
|
3
|
-
"version": "1.2.4",
|
|
4
|
-
"description": "Maps lines and columns to character offsets and back.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"lines",
|
|
7
|
-
"columns",
|
|
8
|
-
"parser"
|
|
9
|
-
],
|
|
10
|
-
"homepage": "https://github.com/eventualbuddha/lines-and-columns#readme",
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/eventualbuddha/lines-and-columns/issues"
|
|
13
|
-
},
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "https://github.com/eventualbuddha/lines-and-columns.git"
|
|
17
|
-
},
|
|
18
|
-
"license": "MIT",
|
|
19
|
-
"author": "Brian Donovan <brian@donovans.cc>",
|
|
20
|
-
"main": "./build/index.js",
|
|
21
|
-
"types": "./build/index.d.ts",
|
|
22
|
-
"files": [
|
|
23
|
-
"build"
|
|
24
|
-
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build:watch": "tsc --build tsconfig.build.json --watch",
|
|
27
|
-
"lint": "eslint .",
|
|
28
|
-
"lint:fix": "eslint . --fix",
|
|
29
|
-
"test": "is-ci test:coverage test:watch",
|
|
30
|
-
"test:coverage": "jest --coverage",
|
|
31
|
-
"test:watch": "jest --watch"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/jest": "^27.0.3",
|
|
35
|
-
"@types/node": "^16.11.9",
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
37
|
-
"@typescript-eslint/parser": "^5.4.0",
|
|
38
|
-
"esbuild": "^0.13.15",
|
|
39
|
-
"esbuild-runner": "^2.2.1",
|
|
40
|
-
"eslint": "^8.2.0",
|
|
41
|
-
"eslint-config-prettier": "^8.3.0",
|
|
42
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
43
|
-
"is-ci-cli": "^2.2.0",
|
|
44
|
-
"jest": "^27.3.1",
|
|
45
|
-
"prettier": "^2.4.1",
|
|
46
|
-
"semantic-release": "^18.0.0",
|
|
47
|
-
"typescript": "^4.5.2"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const callsites = require('callsites');
|
|
3
|
-
|
|
4
|
-
module.exports = filepath => {
|
|
5
|
-
const stacks = callsites();
|
|
6
|
-
|
|
7
|
-
if (!filepath) {
|
|
8
|
-
return stacks[2].getFileName();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let seenVal = false;
|
|
12
|
-
|
|
13
|
-
// Skip the first stack as it's this function
|
|
14
|
-
stacks.shift();
|
|
15
|
-
|
|
16
|
-
for (const stack of stacks) {
|
|
17
|
-
const parentFilepath = stack.getFileName();
|
|
18
|
-
|
|
19
|
-
if (typeof parentFilepath !== 'string') {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (parentFilepath === filepath) {
|
|
24
|
-
seenVal = true;
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Skip native modules
|
|
29
|
-
if (parentFilepath === 'module.js') {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (seenVal && parentFilepath !== filepath) {
|
|
34
|
-
return parentFilepath;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "parent-module",
|
|
3
|
-
"version": "1.0.1",
|
|
4
|
-
"description": "Get the path of the parent module",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": "sindresorhus/parent-module",
|
|
7
|
-
"author": {
|
|
8
|
-
"name": "Sindre Sorhus",
|
|
9
|
-
"email": "sindresorhus@gmail.com",
|
|
10
|
-
"url": "sindresorhus.com"
|
|
11
|
-
},
|
|
12
|
-
"engines": {
|
|
13
|
-
"node": ">=6"
|
|
14
|
-
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"test": "xo && ava"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"index.js"
|
|
20
|
-
],
|
|
21
|
-
"keywords": [
|
|
22
|
-
"parent",
|
|
23
|
-
"module",
|
|
24
|
-
"package",
|
|
25
|
-
"pkg",
|
|
26
|
-
"caller",
|
|
27
|
-
"calling",
|
|
28
|
-
"module",
|
|
29
|
-
"path",
|
|
30
|
-
"callsites",
|
|
31
|
-
"callsite",
|
|
32
|
-
"stacktrace",
|
|
33
|
-
"stack",
|
|
34
|
-
"trace",
|
|
35
|
-
"function",
|
|
36
|
-
"file"
|
|
37
|
-
],
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"callsites": "^3.0.0"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"ava": "^1.4.1",
|
|
43
|
-
"execa": "^1.0.0",
|
|
44
|
-
"xo": "^0.24.0"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# parent-module [](https://travis-ci.org/sindresorhus/parent-module)
|
|
2
|
-
|
|
3
|
-
> Get the path of the parent module
|
|
4
|
-
|
|
5
|
-
Node.js exposes `module.parent`, but it only gives you the first cached parent, which is not necessarily the actual parent.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## Install
|
|
9
|
-
|
|
10
|
-
```
|
|
11
|
-
$ npm install parent-module
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
```js
|
|
18
|
-
// bar.js
|
|
19
|
-
const parentModule = require('parent-module');
|
|
20
|
-
|
|
21
|
-
module.exports = () => {
|
|
22
|
-
console.log(parentModule());
|
|
23
|
-
//=> '/Users/sindresorhus/dev/unicorn/foo.js'
|
|
24
|
-
};
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
```js
|
|
28
|
-
// foo.js
|
|
29
|
-
const bar = require('./bar');
|
|
30
|
-
|
|
31
|
-
bar();
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
## API
|
|
36
|
-
|
|
37
|
-
### parentModule([filepath])
|
|
38
|
-
|
|
39
|
-
By default, it will return the path of the immediate parent.
|
|
40
|
-
|
|
41
|
-
#### filepath
|
|
42
|
-
|
|
43
|
-
Type: `string`<br>
|
|
44
|
-
Default: [`__filename`](https://nodejs.org/api/globals.html#globals_filename)
|
|
45
|
-
|
|
46
|
-
Filepath of the module of which to get the parent path.
|
|
47
|
-
|
|
48
|
-
Useful if you want it to work [multiple module levels down](https://github.com/sindresorhus/parent-module/tree/master/fixtures/filepath).
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
## Tip
|
|
52
|
-
|
|
53
|
-
Combine it with [`read-pkg-up`](https://github.com/sindresorhus/read-pkg-up) to read the package.json of the parent module.
|
|
54
|
-
|
|
55
|
-
```js
|
|
56
|
-
const path = require('path');
|
|
57
|
-
const readPkgUp = require('read-pkg-up');
|
|
58
|
-
const parentModule = require('parent-module');
|
|
59
|
-
|
|
60
|
-
console.log(readPkgUp.sync({cwd: path.dirname(parentModule())}).pkg);
|
|
61
|
-
//=> {name: 'chalk', version: '1.0.0', …}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
## License
|
|
66
|
-
|
|
67
|
-
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const errorEx = require('error-ex');
|
|
3
|
-
const fallback = require('json-parse-even-better-errors');
|
|
4
|
-
const {default: LinesAndColumns} = require('lines-and-columns');
|
|
5
|
-
const {codeFrameColumns} = require('@babel/code-frame');
|
|
6
|
-
|
|
7
|
-
const JSONError = errorEx('JSONError', {
|
|
8
|
-
fileName: errorEx.append('in %s'),
|
|
9
|
-
codeFrame: errorEx.append('\n\n%s\n')
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const parseJson = (string, reviver, filename) => {
|
|
13
|
-
if (typeof reviver === 'string') {
|
|
14
|
-
filename = reviver;
|
|
15
|
-
reviver = null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
try {
|
|
20
|
-
return JSON.parse(string, reviver);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
fallback(string, reviver);
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
} catch (error) {
|
|
26
|
-
error.message = error.message.replace(/\n/g, '');
|
|
27
|
-
const indexMatch = error.message.match(/in JSON at position (\d+) while parsing/);
|
|
28
|
-
|
|
29
|
-
const jsonError = new JSONError(error);
|
|
30
|
-
if (filename) {
|
|
31
|
-
jsonError.fileName = filename;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (indexMatch && indexMatch.length > 0) {
|
|
35
|
-
const lines = new LinesAndColumns(string);
|
|
36
|
-
const index = Number(indexMatch[1]);
|
|
37
|
-
const location = lines.locationForIndex(index);
|
|
38
|
-
|
|
39
|
-
const codeFrame = codeFrameColumns(
|
|
40
|
-
string,
|
|
41
|
-
{start: {line: location.line + 1, column: location.column + 1}},
|
|
42
|
-
{highlightCode: true}
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
jsonError.codeFrame = codeFrame;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
throw jsonError;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
parseJson.JSONError = JSONError;
|
|
53
|
-
|
|
54
|
-
module.exports = parseJson;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "parse-json",
|
|
3
|
-
"version": "5.2.0",
|
|
4
|
-
"description": "Parse JSON with more helpful errors",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": "sindresorhus/parse-json",
|
|
7
|
-
"funding": "https://github.com/sponsors/sindresorhus",
|
|
8
|
-
"author": {
|
|
9
|
-
"name": "Sindre Sorhus",
|
|
10
|
-
"email": "sindresorhus@gmail.com",
|
|
11
|
-
"url": "https://sindresorhus.com"
|
|
12
|
-
},
|
|
13
|
-
"engines": {
|
|
14
|
-
"node": ">=8"
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"test": "xo && nyc ava"
|
|
18
|
-
},
|
|
19
|
-
"files": [
|
|
20
|
-
"index.js",
|
|
21
|
-
"vendor"
|
|
22
|
-
],
|
|
23
|
-
"keywords": [
|
|
24
|
-
"parse",
|
|
25
|
-
"json",
|
|
26
|
-
"graceful",
|
|
27
|
-
"error",
|
|
28
|
-
"message",
|
|
29
|
-
"humanize",
|
|
30
|
-
"friendly",
|
|
31
|
-
"helpful",
|
|
32
|
-
"string"
|
|
33
|
-
],
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"@babel/code-frame": "^7.0.0",
|
|
36
|
-
"error-ex": "^1.3.1",
|
|
37
|
-
"json-parse-even-better-errors": "^2.3.0",
|
|
38
|
-
"lines-and-columns": "^1.1.6"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"ava": "^1.4.1",
|
|
42
|
-
"nyc": "^14.1.1",
|
|
43
|
-
"xo": "^0.24.0"
|
|
44
|
-
}
|
|
45
|
-
}
|