@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,20 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { execFile } from 'child_process';
|
|
2
|
+
const tagPattern = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
3
|
+
function getRemoteTagRefs(repoUrl) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
execFile('git', ['ls-remote', '--tags', '--refs', repoUrl], { encoding: 'utf8' }, (error, stdout, stderr) => {
|
|
6
|
+
if (error) {
|
|
7
|
+
reject(new Error(stderr.trim() || error.message));
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
resolve(stdout);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function parseTagRef(line) {
|
|
15
|
+
const [, ref] = line.trim().split(/\s+/);
|
|
16
|
+
const tagRefPrefix = 'refs/tags/';
|
|
17
|
+
if (!ref?.startsWith(tagRefPrefix)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const tag = ref.slice(tagRefPrefix.length);
|
|
21
|
+
const tagParts = tag.match(tagPattern);
|
|
22
|
+
if (!tagParts) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const [, major, minor, patch, prerelease] = tagParts;
|
|
26
|
+
return {
|
|
27
|
+
tag,
|
|
28
|
+
major: Number(major),
|
|
29
|
+
minor: Number(minor),
|
|
30
|
+
patch: Number(patch),
|
|
31
|
+
prerelease,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function comparePrerelease(left, right) {
|
|
35
|
+
if (!left && !right) {
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
if (!left) {
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
if (!right) {
|
|
42
|
+
return -1;
|
|
43
|
+
}
|
|
44
|
+
const leftParts = left.split('.');
|
|
45
|
+
const rightParts = right.split('.');
|
|
46
|
+
const length = Math.max(leftParts.length, rightParts.length);
|
|
47
|
+
for (let i = 0; i < length; i += 1) {
|
|
48
|
+
const leftPart = leftParts[i];
|
|
49
|
+
const rightPart = rightParts[i];
|
|
50
|
+
if (leftPart === undefined) {
|
|
51
|
+
return -1;
|
|
52
|
+
}
|
|
53
|
+
if (rightPart === undefined) {
|
|
54
|
+
return 1;
|
|
8
55
|
}
|
|
9
|
-
|
|
56
|
+
const leftIsNumber = /^\d+$/.test(leftPart);
|
|
57
|
+
const rightIsNumber = /^\d+$/.test(rightPart);
|
|
58
|
+
if (leftIsNumber && rightIsNumber) {
|
|
59
|
+
const numberComparison = Number(leftPart) - Number(rightPart);
|
|
60
|
+
if (numberComparison !== 0) {
|
|
61
|
+
return numberComparison;
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (leftIsNumber) {
|
|
66
|
+
return -1;
|
|
67
|
+
}
|
|
68
|
+
if (rightIsNumber) {
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
const stringComparison = leftPart.localeCompare(rightPart);
|
|
72
|
+
if (stringComparison !== 0) {
|
|
73
|
+
return stringComparison;
|
|
10
74
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
75
|
+
}
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
function compareTags(left, right) {
|
|
79
|
+
const versionComparison = left.major - right.major ||
|
|
80
|
+
left.minor - right.minor ||
|
|
81
|
+
left.patch - right.patch;
|
|
82
|
+
return (versionComparison || comparePrerelease(left.prerelease, right.prerelease));
|
|
83
|
+
}
|
|
84
|
+
const getRepositoryLatestTag = async (repoUrl) => {
|
|
85
|
+
let refs;
|
|
86
|
+
try {
|
|
87
|
+
refs = await getRemoteTagRefs(repoUrl);
|
|
15
88
|
}
|
|
16
89
|
catch (error) {
|
|
17
|
-
|
|
90
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
91
|
+
throw new Error(`Unable to read tags from repository ${repoUrl}: ${message}`);
|
|
92
|
+
}
|
|
93
|
+
const usableTags = refs
|
|
94
|
+
.split('\n')
|
|
95
|
+
.map(parseTagRef)
|
|
96
|
+
.filter((tag) => Boolean(tag));
|
|
97
|
+
if (usableTags.length === 0) {
|
|
98
|
+
throw new Error(`No usable SemVer tags were found in repository ${repoUrl}.`);
|
|
18
99
|
}
|
|
100
|
+
const latest = usableTags.reduce((currentLatest, tag) => compareTags(tag, currentLatest) > 0 ? tag : currentLatest);
|
|
101
|
+
return latest.tag;
|
|
19
102
|
};
|
|
20
103
|
export default getRepositoryLatestTag;
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
export default function buildComponentDependencyList(components, name) {
|
|
2
|
-
const
|
|
3
|
-
|
|
2
|
+
const componentsByName = new Map();
|
|
3
|
+
for (const component of components) {
|
|
4
|
+
if (!componentsByName.has(component.name)) {
|
|
5
|
+
componentsByName.set(component.name, component);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
if (!componentsByName.has(name))
|
|
4
9
|
return [];
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
];
|
|
12
|
-
|
|
10
|
+
const finalList = [];
|
|
11
|
+
const visited = new Set();
|
|
12
|
+
const stack = [];
|
|
13
|
+
function visit(componentName, referencedBy) {
|
|
14
|
+
const cycleStart = stack.indexOf(componentName);
|
|
15
|
+
if (cycleStart !== -1) {
|
|
16
|
+
const cyclePath = [...stack.slice(cycleStart), componentName].join(' -> ');
|
|
17
|
+
throw new Error(`Circular component dependency detected while resolving "${name}": ${cyclePath}.`);
|
|
18
|
+
}
|
|
19
|
+
if (visited.has(componentName)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const component = componentsByName.get(componentName);
|
|
23
|
+
if (!component) {
|
|
24
|
+
const dependencyPath = [...stack, componentName].join(' -> ');
|
|
25
|
+
const referencedByMessage = referencedBy
|
|
26
|
+
? ` referenced by "${referencedBy}"`
|
|
27
|
+
: '';
|
|
28
|
+
throw new Error(`Cannot resolve component dependency "${componentName}"${referencedByMessage} while resolving "${name}". Dependency path: ${dependencyPath}.`);
|
|
29
|
+
}
|
|
30
|
+
stack.push(componentName);
|
|
31
|
+
visited.add(componentName);
|
|
32
|
+
finalList.push(componentName);
|
|
33
|
+
for (const dependencyName of component.dependency ?? []) {
|
|
34
|
+
visit(dependencyName, componentName);
|
|
35
|
+
}
|
|
36
|
+
stack.pop();
|
|
13
37
|
}
|
|
38
|
+
visit(name);
|
|
14
39
|
return finalList;
|
|
15
40
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { select, confirm } from '@inquirer/prompts';
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
|
-
import {
|
|
3
|
+
import { dirname } from 'path';
|
|
4
4
|
import { pathExists, remove } from 'fs-extra';
|
|
5
5
|
import { cyan, green, bold, yellow } from 'colorette';
|
|
6
6
|
import log from '../../lib/log.js';
|
|
7
7
|
import findFileInCurrentPath from '../fs/findFileInCurrentPath.js';
|
|
8
|
+
import safeResolveWithin from '../fs/safeResolveWithin.js';
|
|
8
9
|
import { EMULSIFY_PROJECT_CONFIG_FILE } from '../../lib/constants.js';
|
|
9
10
|
import deriveComponentNames from '../deriveComponentNames.js';
|
|
10
11
|
import resolveComponentTemplate from './resolveComponentTemplate.js';
|
|
@@ -38,6 +39,7 @@ export default async function generateComponent(variant, componentName, options
|
|
|
38
39
|
if (!path) {
|
|
39
40
|
throw new Error('Unable to find an Emulsify project to create the component into.');
|
|
40
41
|
}
|
|
42
|
+
const projectRoot = dirname(path);
|
|
41
43
|
const format = providedFormat
|
|
42
44
|
? providedFormat
|
|
43
45
|
: canPrompt
|
|
@@ -64,26 +66,10 @@ export default async function generateComponent(variant, componentName, options
|
|
|
64
66
|
if (!structure) {
|
|
65
67
|
throw new Error(`The structure (${directory}) specified within the component ${componentName} is invalid.`);
|
|
66
68
|
}
|
|
67
|
-
const parentPath =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
const destination = join(dirname(path), structure.directory, filename);
|
|
69
|
+
const parentPath = safeResolveWithin(projectRoot, structure.directory, 'Component structure directory', { allowRoot: true });
|
|
70
|
+
const parentExists = await pathExists(parentPath);
|
|
71
|
+
const destination = safeResolveWithin(projectRoot, [structure.directory, filename], 'Component destination');
|
|
72
72
|
const componentExists = await pathExists(destination);
|
|
73
|
-
if (componentExists) {
|
|
74
|
-
const shouldReplace = options.yes ||
|
|
75
|
-
(canPrompt
|
|
76
|
-
? await confirm({
|
|
77
|
-
message: yellow(`The component "${humanName}" already exists in ${structure.directory}. Would you like to replace it?`),
|
|
78
|
-
default: false,
|
|
79
|
-
})
|
|
80
|
-
: false);
|
|
81
|
-
if (!shouldReplace) {
|
|
82
|
-
return log('info', `Component creation canceled.`);
|
|
83
|
-
}
|
|
84
|
-
await remove(destination);
|
|
85
|
-
}
|
|
86
|
-
await fs.mkdir(destination, { recursive: true });
|
|
87
73
|
const templateVars = {
|
|
88
74
|
filename,
|
|
89
75
|
className,
|
|
@@ -136,9 +122,52 @@ export default async function generateComponent(variant, componentName, options
|
|
|
136
122
|
build: () => buildStoriesTemplate(camelName, filename, humanName, directory),
|
|
137
123
|
},
|
|
138
124
|
];
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
125
|
+
const artifacts = [...sharedArtifacts, ...formatArtifacts];
|
|
126
|
+
const artifactDestinations = artifacts.map((artifact) => safeResolveWithin(projectRoot, [structure.directory, filename, artifact.destinationName], 'Component file destination'));
|
|
127
|
+
if (options.dryRun) {
|
|
128
|
+
const realRunAction = componentExists
|
|
129
|
+
? options.yes
|
|
130
|
+
? 'replace the existing component directory'
|
|
131
|
+
: 'prompt before replacing the existing component directory'
|
|
132
|
+
: 'create the component directory';
|
|
133
|
+
const generatedFiles = artifactDestinations
|
|
134
|
+
.map((filePath) => ` - ${filePath}`)
|
|
135
|
+
.join('\n');
|
|
136
|
+
return log('info', [
|
|
137
|
+
`Dry run: component create "${filename}"`,
|
|
138
|
+
`Format: ${format}`,
|
|
139
|
+
`Directory: ${directory}`,
|
|
140
|
+
`Structure path: ${structure.directory}`,
|
|
141
|
+
`Parent directory: ${parentPath} (${parentExists ? 'exists' : 'would be created'})`,
|
|
142
|
+
`Destination: ${destination}`,
|
|
143
|
+
`Destination exists: ${componentExists ? 'yes' : 'no'}`,
|
|
144
|
+
`Real run would: ${realRunAction}`,
|
|
145
|
+
'Generated files:',
|
|
146
|
+
generatedFiles,
|
|
147
|
+
'No files were written, removed, or created.',
|
|
148
|
+
].join('\n'));
|
|
149
|
+
}
|
|
150
|
+
if (!parentExists) {
|
|
151
|
+
await fs.mkdir(parentPath, { recursive: true });
|
|
152
|
+
}
|
|
153
|
+
if (componentExists) {
|
|
154
|
+
const shouldReplace = options.yes ||
|
|
155
|
+
(canPrompt
|
|
156
|
+
? await confirm({
|
|
157
|
+
message: yellow(`The component "${humanName}" already exists in ${structure.directory}. Would you like to replace it?`),
|
|
158
|
+
default: false,
|
|
159
|
+
})
|
|
160
|
+
: false);
|
|
161
|
+
if (!shouldReplace) {
|
|
162
|
+
return log('info', `Component creation canceled.`);
|
|
163
|
+
}
|
|
164
|
+
await remove(destination);
|
|
165
|
+
}
|
|
166
|
+
await fs.mkdir(destination, { recursive: true });
|
|
167
|
+
for (const [index, artifact] of artifacts.entries()) {
|
|
168
|
+
const templateFile = (await resolveComponentTemplate(projectRoot, format, artifact.logicalName, templateVars)) ?? artifact.build();
|
|
169
|
+
const artifactDestination = artifactDestinations[index];
|
|
170
|
+
await fs.writeFile(artifactDestination, templateFile);
|
|
142
171
|
}
|
|
143
172
|
return log('success', `${bold(green('Success!'))} The ${bold(cyan(componentName))} component (${yellow(format.toUpperCase())}) has been created in ${bold(directory)}.`);
|
|
144
173
|
}
|
|
@@ -1,10 +1,44 @@
|
|
|
1
|
+
import { Ajv } from 'ajv';
|
|
1
2
|
import { EMULSIFY_PROJECT_CONFIG_FILE } from '../../lib/constants.js';
|
|
2
3
|
import findFileInCurrentPath from '../fs/findFileInCurrentPath.js';
|
|
3
4
|
import loadJsonFile from '../fs/loadJsonFile.js';
|
|
5
|
+
let validateProjectConfig;
|
|
6
|
+
async function getProjectConfigValidator() {
|
|
7
|
+
if (!validateProjectConfig) {
|
|
8
|
+
const [{ default: projectConfigSchema }, { default: variantSchema }] = await Promise.all([
|
|
9
|
+
import('../../schemas/emulsifyProjectConfig.json', {
|
|
10
|
+
with: { type: 'json' },
|
|
11
|
+
}),
|
|
12
|
+
import('../../schemas/variant.json', { with: { type: 'json' } }),
|
|
13
|
+
]);
|
|
14
|
+
const ajv = new Ajv({ allErrors: true });
|
|
15
|
+
ajv.addSchema(variantSchema, 'variant.json');
|
|
16
|
+
validateProjectConfig = ajv.compile(projectConfigSchema);
|
|
17
|
+
}
|
|
18
|
+
return validateProjectConfig;
|
|
19
|
+
}
|
|
20
|
+
function formatProjectConfigError(error) {
|
|
21
|
+
const location = error.instancePath || '/';
|
|
22
|
+
return `${location} ${error.message}`;
|
|
23
|
+
}
|
|
24
|
+
async function validateEmulsifyConfig(config, path) {
|
|
25
|
+
const validate = await getProjectConfigValidator();
|
|
26
|
+
if (!validate(config)) {
|
|
27
|
+
const errors = (validate.errors || [])
|
|
28
|
+
.map(formatProjectConfigError)
|
|
29
|
+
.join('; ');
|
|
30
|
+
throw new Error(`Invalid Emulsify project configuration in "${path}": ${errors}`);
|
|
31
|
+
}
|
|
32
|
+
return config;
|
|
33
|
+
}
|
|
4
34
|
export default async function getEmulsifyConfig() {
|
|
5
35
|
const path = findFileInCurrentPath(EMULSIFY_PROJECT_CONFIG_FILE);
|
|
6
36
|
if (!path) {
|
|
7
37
|
return undefined;
|
|
8
38
|
}
|
|
9
|
-
|
|
39
|
+
const config = await loadJsonFile(path);
|
|
40
|
+
if (config === undefined) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return validateEmulsifyConfig(config, path);
|
|
10
44
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { pathExists } from 'fs-extra';
|
|
2
|
-
import {
|
|
2
|
+
import { dirname } from 'path';
|
|
3
3
|
import { EMULSIFY_PROJECT_CONFIG_FILE } from '../../lib/constants.js';
|
|
4
4
|
import findFileInCurrentPath from '../fs/findFileInCurrentPath.js';
|
|
5
|
+
import safeResolveWithin from '../fs/safeResolveWithin.js';
|
|
5
6
|
import copyItemFromCache from '../cache/copyItemFromCache.js';
|
|
6
7
|
export function getComponentDestination(variant, componentName, projectConfigPath) {
|
|
7
8
|
const component = variant.components.find(({ name }) => name === componentName);
|
|
@@ -12,7 +13,7 @@ export function getComponentDestination(variant, componentName, projectConfigPat
|
|
|
12
13
|
if (!structure) {
|
|
13
14
|
throw new Error(`The structure (${component.structure}) specified within the component ${componentName} is invalid.`);
|
|
14
15
|
}
|
|
15
|
-
return
|
|
16
|
+
return safeResolveWithin(dirname(projectConfigPath), [structure.directory, component.name], 'Component destination');
|
|
16
17
|
}
|
|
17
18
|
export default async function installComponentFromCache(system, variant, componentName, force = false) {
|
|
18
19
|
const path = findFileInCurrentPath(EMULSIFY_PROJECT_CONFIG_FILE);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dirname } from 'path';
|
|
2
2
|
import { EMULSIFY_PROJECT_CONFIG_FILE } from '../../lib/constants.js';
|
|
3
3
|
import findFileInCurrentPath from '../fs/findFileInCurrentPath.js';
|
|
4
|
+
import safeResolveWithin from '../fs/safeResolveWithin.js';
|
|
4
5
|
import copyItemFromCache from '../cache/copyItemFromCache.js';
|
|
5
6
|
import catchLater from '../catchLater.js';
|
|
6
7
|
export default async function installGeneralAssetsFromCache(system, variant) {
|
|
@@ -8,10 +9,11 @@ export default async function installGeneralAssetsFromCache(system, variant) {
|
|
|
8
9
|
if (!path) {
|
|
9
10
|
throw new Error('Unable to find an Emulsify project to install assets into.');
|
|
10
11
|
}
|
|
12
|
+
const projectRoot = dirname(path);
|
|
11
13
|
const assets = [...(variant.directories || []), ...(variant.files || [])];
|
|
12
14
|
const promises = [];
|
|
13
15
|
for (const asset of assets) {
|
|
14
|
-
const destination =
|
|
16
|
+
const destination = safeResolveWithin(projectRoot, asset.destinationPath, 'General asset destination');
|
|
15
17
|
promises.push(catchLater(copyItemFromCache('systems', [system.name, asset.path], destination, true)));
|
|
16
18
|
}
|
|
17
19
|
await Promise.all(promises);
|
|
@@ -10,10 +10,5 @@ export default async function getAvailableSystems() {
|
|
|
10
10
|
repository: 'https://github.com/emulsify-ds/emulsify-ui-kit.git',
|
|
11
11
|
platforms: ['none', 'drupal'],
|
|
12
12
|
},
|
|
13
|
-
{
|
|
14
|
-
name: 'emulsify-ui-kit',
|
|
15
|
-
repository: 'https://github.com/emulsify-ds/emulsify-ui-kit.git',
|
|
16
|
-
platforms: ['drupal'],
|
|
17
|
-
},
|
|
18
13
|
];
|
|
19
14
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emulsify/cli",
|
|
3
3
|
"productName": "Emulsify CLI",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.1",
|
|
5
5
|
"description": "Command line interface for Emulsify",
|
|
6
6
|
"repository": "git@github.com:emulsify-ds/emulsify-cli.git",
|
|
7
7
|
"author": "Patrick Coffey <patrickcoffey48@gmail.com>",
|
|
@@ -48,28 +48,27 @@
|
|
|
48
48
|
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
49
49
|
"@types/fs-extra": "^11.0.4",
|
|
50
50
|
"@types/jest": "^30.0.0",
|
|
51
|
-
"@types/node": "^25.9.
|
|
51
|
+
"@types/node": "^25.9.3",
|
|
52
|
+
"@types/progress": "^2.0.7",
|
|
52
53
|
"husky": "^9.1.7",
|
|
53
54
|
"jest": "^30.4.2",
|
|
54
55
|
"json-schema-to-typescript": "^15.0.4",
|
|
55
56
|
"lint-staged": "^17.0.7",
|
|
56
57
|
"nodemon": "^3.1.14",
|
|
57
|
-
"prettier": "^3.8.
|
|
58
|
-
"semantic-release": "^25.0.
|
|
58
|
+
"prettier": "^3.8.4",
|
|
59
|
+
"semantic-release": "^25.0.5",
|
|
59
60
|
"ts-jest": "^29.4.11",
|
|
60
61
|
"ts-node": "^10.9.2",
|
|
61
62
|
"typescript": "^6.0.3"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
65
|
"@inquirer/prompts": "^8.5.2",
|
|
65
|
-
"@types/progress": "^2.0.7",
|
|
66
66
|
"ajv": "^8.20.0",
|
|
67
67
|
"ajv-formats": "^3.0.1",
|
|
68
68
|
"boxen": "^8.0.1",
|
|
69
69
|
"colorette": "^2.0.20",
|
|
70
70
|
"commander": "^15.0.0",
|
|
71
71
|
"consola": "^3.4.2",
|
|
72
|
-
"cosmiconfig": "^9.0.1",
|
|
73
72
|
"fs-extra": "^11.3.5",
|
|
74
73
|
"progress": "^2.0.3",
|
|
75
74
|
"simple-git": "^3.36.0"
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# @babel/code-frame
|
|
2
|
-
|
|
3
|
-
> Generate errors that contain a code frame that point to source locations.
|
|
4
|
-
|
|
5
|
-
See our website [@babel/code-frame](https://babeljs.io/docs/babel-code-frame) for more information.
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
Using npm:
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
npm install --save-dev @babel/code-frame
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
or using yarn:
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
yarn add @babel/code-frame --dev
|
|
19
|
-
```
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var picocolors = require('picocolors');
|
|
6
|
-
var jsTokens = require('js-tokens');
|
|
7
|
-
var helperValidatorIdentifier = require('@babel/helper-validator-identifier');
|
|
8
|
-
|
|
9
|
-
function isColorSupported() {
|
|
10
|
-
return (typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? false : picocolors.isColorSupported
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
const compose = (f, g) => v => f(g(v));
|
|
14
|
-
function buildDefs(colors) {
|
|
15
|
-
return {
|
|
16
|
-
keyword: colors.cyan,
|
|
17
|
-
capitalized: colors.yellow,
|
|
18
|
-
jsxIdentifier: colors.yellow,
|
|
19
|
-
punctuator: colors.yellow,
|
|
20
|
-
number: colors.magenta,
|
|
21
|
-
string: colors.green,
|
|
22
|
-
regex: colors.magenta,
|
|
23
|
-
comment: colors.gray,
|
|
24
|
-
invalid: compose(compose(colors.white, colors.bgRed), colors.bold),
|
|
25
|
-
gutter: colors.gray,
|
|
26
|
-
marker: compose(colors.red, colors.bold),
|
|
27
|
-
message: compose(colors.red, colors.bold),
|
|
28
|
-
reset: colors.reset
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const defsOn = buildDefs(picocolors.createColors(true));
|
|
32
|
-
const defsOff = buildDefs(picocolors.createColors(false));
|
|
33
|
-
function getDefs(enabled) {
|
|
34
|
-
return enabled ? defsOn : defsOff;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
|
|
38
|
-
const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
|
|
39
|
-
const BRACKET = /^[()[\]{}]$/;
|
|
40
|
-
let tokenize;
|
|
41
|
-
const JSX_TAG = /^[a-z][\w-]*$/i;
|
|
42
|
-
const getTokenType = function (token, offset, text) {
|
|
43
|
-
if (token.type === "name") {
|
|
44
|
-
const tokenValue = token.value;
|
|
45
|
-
if (helperValidatorIdentifier.isKeyword(tokenValue) || helperValidatorIdentifier.isStrictReservedWord(tokenValue, true) || sometimesKeywords.has(tokenValue)) {
|
|
46
|
-
return "keyword";
|
|
47
|
-
}
|
|
48
|
-
if (JSX_TAG.test(tokenValue) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")) {
|
|
49
|
-
return "jsxIdentifier";
|
|
50
|
-
}
|
|
51
|
-
const firstChar = String.fromCodePoint(tokenValue.codePointAt(0));
|
|
52
|
-
if (firstChar !== firstChar.toLowerCase()) {
|
|
53
|
-
return "capitalized";
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (token.type === "punctuator" && BRACKET.test(token.value)) {
|
|
57
|
-
return "bracket";
|
|
58
|
-
}
|
|
59
|
-
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
|
|
60
|
-
return "punctuator";
|
|
61
|
-
}
|
|
62
|
-
return token.type;
|
|
63
|
-
};
|
|
64
|
-
tokenize = function* (text) {
|
|
65
|
-
let match;
|
|
66
|
-
while (match = jsTokens.default.exec(text)) {
|
|
67
|
-
const token = jsTokens.matchToToken(match);
|
|
68
|
-
yield {
|
|
69
|
-
type: getTokenType(token, match.index, text),
|
|
70
|
-
value: token.value
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
function highlight(text) {
|
|
75
|
-
if (text === "") return "";
|
|
76
|
-
const defs = getDefs(true);
|
|
77
|
-
let highlighted = "";
|
|
78
|
-
for (const {
|
|
79
|
-
type,
|
|
80
|
-
value
|
|
81
|
-
} of tokenize(text)) {
|
|
82
|
-
if (type in defs) {
|
|
83
|
-
highlighted += value.split(NEWLINE$1).map(str => defs[type](str)).join("\n");
|
|
84
|
-
} else {
|
|
85
|
-
highlighted += value;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return highlighted;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
let deprecationWarningShown = false;
|
|
92
|
-
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
93
|
-
function getMarkerLines(loc, source, opts, startLineBaseZero) {
|
|
94
|
-
const startLoc = Object.assign({
|
|
95
|
-
column: 0,
|
|
96
|
-
line: -1
|
|
97
|
-
}, loc.start);
|
|
98
|
-
const endLoc = Object.assign({}, startLoc, loc.end);
|
|
99
|
-
const {
|
|
100
|
-
linesAbove = 2,
|
|
101
|
-
linesBelow = 3
|
|
102
|
-
} = opts || {};
|
|
103
|
-
const startLine = startLoc.line - startLineBaseZero;
|
|
104
|
-
const startColumn = startLoc.column;
|
|
105
|
-
const endLine = endLoc.line - startLineBaseZero;
|
|
106
|
-
const endColumn = endLoc.column;
|
|
107
|
-
let start = Math.max(startLine - (linesAbove + 1), 0);
|
|
108
|
-
let end = Math.min(source.length, endLine + linesBelow);
|
|
109
|
-
if (startLine === -1) {
|
|
110
|
-
start = 0;
|
|
111
|
-
}
|
|
112
|
-
if (endLine === -1) {
|
|
113
|
-
end = source.length;
|
|
114
|
-
}
|
|
115
|
-
const lineDiff = endLine - startLine;
|
|
116
|
-
const markerLines = {};
|
|
117
|
-
if (lineDiff) {
|
|
118
|
-
for (let i = 0; i <= lineDiff; i++) {
|
|
119
|
-
const lineNumber = i + startLine;
|
|
120
|
-
if (!startColumn) {
|
|
121
|
-
markerLines[lineNumber] = true;
|
|
122
|
-
} else if (i === 0) {
|
|
123
|
-
const sourceLength = source[lineNumber - 1].length;
|
|
124
|
-
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
|
|
125
|
-
} else if (i === lineDiff) {
|
|
126
|
-
markerLines[lineNumber] = [0, endColumn];
|
|
127
|
-
} else {
|
|
128
|
-
const sourceLength = source[lineNumber - i].length;
|
|
129
|
-
markerLines[lineNumber] = [0, sourceLength];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
} else {
|
|
133
|
-
if (startColumn === endColumn) {
|
|
134
|
-
if (startColumn) {
|
|
135
|
-
markerLines[startLine] = [startColumn, 0];
|
|
136
|
-
} else {
|
|
137
|
-
markerLines[startLine] = true;
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
140
|
-
markerLines[startLine] = [startColumn, endColumn - startColumn];
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
start,
|
|
145
|
-
end,
|
|
146
|
-
markerLines
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
function codeFrameColumns(rawLines, loc, opts = {}) {
|
|
150
|
-
const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;
|
|
151
|
-
const startLineBaseZero = (opts.startLine || 1) - 1;
|
|
152
|
-
const defs = getDefs(shouldHighlight);
|
|
153
|
-
const lines = rawLines.split(NEWLINE);
|
|
154
|
-
const {
|
|
155
|
-
start,
|
|
156
|
-
end,
|
|
157
|
-
markerLines
|
|
158
|
-
} = getMarkerLines(loc, lines, opts, startLineBaseZero);
|
|
159
|
-
const hasColumns = loc.start && typeof loc.start.column === "number";
|
|
160
|
-
const numberMaxWidth = String(end + startLineBaseZero).length;
|
|
161
|
-
const highlightedLines = shouldHighlight ? highlight(rawLines) : rawLines;
|
|
162
|
-
let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
|
|
163
|
-
const number = start + 1 + index;
|
|
164
|
-
const paddedNumber = ` ${number + startLineBaseZero}`.slice(-numberMaxWidth);
|
|
165
|
-
const gutter = ` ${paddedNumber} |`;
|
|
166
|
-
const hasMarker = markerLines[number];
|
|
167
|
-
const lastMarkerLine = !markerLines[number + 1];
|
|
168
|
-
if (hasMarker) {
|
|
169
|
-
let markerLine = "";
|
|
170
|
-
if (Array.isArray(hasMarker)) {
|
|
171
|
-
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
|
|
172
|
-
const numberOfMarkers = hasMarker[1] || 1;
|
|
173
|
-
markerLine = ["\n ", defs.gutter(gutter.replace(/\d/g, " ")), " ", markerSpacing, defs.marker("^").repeat(numberOfMarkers)].join("");
|
|
174
|
-
if (lastMarkerLine && opts.message) {
|
|
175
|
-
markerLine += " " + defs.message(opts.message);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return [defs.marker(">"), defs.gutter(gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
|
|
179
|
-
} else {
|
|
180
|
-
return ` ${defs.gutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
|
|
181
|
-
}
|
|
182
|
-
}).join("\n");
|
|
183
|
-
if (opts.message && !hasColumns) {
|
|
184
|
-
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
|
185
|
-
}
|
|
186
|
-
if (shouldHighlight) {
|
|
187
|
-
return defs.reset(frame);
|
|
188
|
-
} else {
|
|
189
|
-
return frame;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
function index (rawLines, lineNumber, colNumber, opts = {}) {
|
|
193
|
-
if (!deprecationWarningShown) {
|
|
194
|
-
deprecationWarningShown = true;
|
|
195
|
-
const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
|
|
196
|
-
if (process.emitWarning) {
|
|
197
|
-
process.emitWarning(message, "DeprecationWarning");
|
|
198
|
-
} else {
|
|
199
|
-
const deprecationError = new Error(message);
|
|
200
|
-
deprecationError.name = "DeprecationWarning";
|
|
201
|
-
console.warn(new Error(message));
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
colNumber = Math.max(colNumber, 0);
|
|
205
|
-
const location = {
|
|
206
|
-
start: {
|
|
207
|
-
column: colNumber,
|
|
208
|
-
line: lineNumber
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
return codeFrameColumns(rawLines, location, opts);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
exports.codeFrameColumns = codeFrameColumns;
|
|
215
|
-
exports.default = index;
|
|
216
|
-
exports.highlight = highlight;
|
|
217
|
-
//# sourceMappingURL=index.js.map
|