@trayai/tray-sync-cli 0.0.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/LICENSE.md +182 -0
- package/README.md +167 -0
- package/dist/api/errors.js +29 -0
- package/dist/api/trayClient.js +69 -0
- package/dist/cli.js +32 -0
- package/dist/commands/auth.js +103 -0
- package/dist/commands/env.js +534 -0
- package/dist/commands/init.js +115 -0
- package/dist/commands/project.js +175 -0
- package/dist/commands/promote.js +289 -0
- package/dist/commands/pull.js +379 -0
- package/dist/commands/status.js +126 -0
- package/dist/config/credentials.js +10 -0
- package/dist/config/environments.js +10 -0
- package/dist/config/io.js +36 -0
- package/dist/config/mappings.js +9 -0
- package/dist/config/paths.js +33 -0
- package/dist/config/projectConfig.js +16 -0
- package/dist/config/pullProgress.js +9 -0
- package/dist/config/state.js +9 -0
- package/dist/config/trayYaml.js +9 -0
- package/dist/config/types.js +21 -0
- package/dist/config/yaml.js +22 -0
- package/dist/lib/authDiscovery.js +76 -0
- package/dist/lib/checksum.js +5 -0
- package/dist/lib/exportStructure.js +23 -0
- package/dist/lib/outputFormat.js +12 -0
- package/dist/lib/pathContainment.js +37 -0
- package/dist/lib/promoteExecute.js +8 -0
- package/dist/lib/promoteReconstruct.js +35 -0
- package/dist/lib/promoteReport.js +44 -0
- package/dist/lib/promoteTarget.js +129 -0
- package/dist/lib/region.js +26 -0
- package/dist/lib/regionDisplay.js +11 -0
- package/dist/lib/regionParsing.js +12 -0
- package/dist/lib/scriptExtraction.js +46 -0
- package/dist/lib/slug.js +14 -0
- package/dist/lib/tokenResolution.js +19 -0
- package/dist/lib/uuid.js +5 -0
- package/dist/views/env/env.js +89 -0
- package/dist/views/env/shared.js +7 -0
- package/dist/views/init/init.js +17 -0
- package/dist/views/project/project.js +35 -0
- package/dist/views/project/shared.js +4 -0
- package/dist/views/promote/promote.js +44 -0
- package/dist/views/promote/shared.js +4 -0
- package/dist/views/pull/pull.js +31 -0
- package/dist/views/pull/shared.js +4 -0
- package/dist/views/shared.js +8 -0
- package/dist/views/status/shared.js +20 -0
- package/dist/views/status/status.js +23 -0
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1172 -0
- package/node_modules/commander/index.js +21 -0
- package/node_modules/commander/lib/argument.js +147 -0
- package/node_modules/commander/lib/command.js +2790 -0
- package/node_modules/commander/lib/error.js +36 -0
- package/node_modules/commander/lib/help.js +731 -0
- package/node_modules/commander/lib/option.js +377 -0
- package/node_modules/commander/lib/suggestSimilar.js +99 -0
- package/node_modules/commander/package-support.json +19 -0
- package/node_modules/commander/package.json +64 -0
- package/node_modules/commander/typings/index.d.ts +1113 -0
- package/node_modules/yaml/LICENSE +13 -0
- package/node_modules/yaml/README.md +172 -0
- package/node_modules/yaml/bin.mjs +11 -0
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
- package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
- package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
- package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +225 -0
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
- package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
- package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
- package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
- package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
- package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
- package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
- package/node_modules/yaml/browser/dist/errors.js +57 -0
- package/node_modules/yaml/browser/dist/index.js +17 -0
- package/node_modules/yaml/browser/dist/log.js +11 -0
- package/node_modules/yaml/browser/dist/nodes/Alias.js +116 -0
- package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
- package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
- package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
- package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
- package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
- package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
- package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
- package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
- package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
- package/node_modules/yaml/browser/dist/public-api.js +102 -0
- package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
- package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
- package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
- package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
- package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
- package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
- package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
- package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
- package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
- package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
- package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
- package/node_modules/yaml/browser/dist/util.js +11 -0
- package/node_modules/yaml/browser/dist/visit.js +233 -0
- package/node_modules/yaml/browser/index.js +5 -0
- package/node_modules/yaml/browser/package.json +3 -0
- package/node_modules/yaml/dist/cli.d.ts +8 -0
- package/node_modules/yaml/dist/cli.mjs +201 -0
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
- package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
- package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
- package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
- package/node_modules/yaml/dist/compose/compose-node.js +112 -0
- package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
- package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
- package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
- package/node_modules/yaml/dist/compose/composer.js +224 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
- package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
- package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
- package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
- package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
- package/node_modules/yaml/dist/doc/Document.js +337 -0
- package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
- package/node_modules/yaml/dist/doc/anchors.js +76 -0
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
- package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
- package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
- package/node_modules/yaml/dist/doc/createNode.js +90 -0
- package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
- package/node_modules/yaml/dist/doc/directives.js +178 -0
- package/node_modules/yaml/dist/errors.d.ts +21 -0
- package/node_modules/yaml/dist/errors.js +62 -0
- package/node_modules/yaml/dist/index.d.ts +25 -0
- package/node_modules/yaml/dist/index.js +50 -0
- package/node_modules/yaml/dist/log.d.ts +3 -0
- package/node_modules/yaml/dist/log.js +19 -0
- package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/Alias.js +118 -0
- package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
- package/node_modules/yaml/dist/nodes/Collection.js +151 -0
- package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/Node.js +40 -0
- package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
- package/node_modules/yaml/dist/nodes/Pair.js +39 -0
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
- package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
- package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
- package/node_modules/yaml/dist/nodes/identity.js +53 -0
- package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/toJS.js +39 -0
- package/node_modules/yaml/dist/options.d.ts +350 -0
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
- package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
- package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
- package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
- package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
- package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
- package/node_modules/yaml/dist/parse/cst.js +112 -0
- package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
- package/node_modules/yaml/dist/parse/lexer.js +723 -0
- package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
- package/node_modules/yaml/dist/parse/line-counter.js +41 -0
- package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
- package/node_modules/yaml/dist/parse/parser.js +980 -0
- package/node_modules/yaml/dist/public-api.d.ts +44 -0
- package/node_modules/yaml/dist/public-api.js +107 -0
- package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
- package/node_modules/yaml/dist/schema/Schema.js +39 -0
- package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/map.js +19 -0
- package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
- package/node_modules/yaml/dist/schema/common/null.js +17 -0
- package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/seq.js +19 -0
- package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/string.js +16 -0
- package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/bool.js +21 -0
- package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/float.js +47 -0
- package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/int.js +42 -0
- package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/core/schema.js +25 -0
- package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
- package/node_modules/yaml/dist/schema/json/schema.js +64 -0
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
- package/node_modules/yaml/dist/schema/tags.js +99 -0
- package/node_modules/yaml/dist/schema/types.d.ts +92 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
- package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
- package/node_modules/yaml/dist/stringify/stringify.js +132 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
- package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
- package/node_modules/yaml/dist/test-events.d.ts +4 -0
- package/node_modules/yaml/dist/test-events.js +134 -0
- package/node_modules/yaml/dist/util.d.ts +16 -0
- package/node_modules/yaml/dist/util.js +28 -0
- package/node_modules/yaml/dist/visit.d.ts +102 -0
- package/node_modules/yaml/dist/visit.js +236 -0
- package/node_modules/yaml/package.json +97 -0
- package/node_modules/yaml/util.js +2 -0
- package/package.json +42 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
This license applies to the published `@trayai/tray-sync-cli` npm package
|
|
2
|
+
(the contents of `dist/`). All other files in this repository remain
|
|
3
|
+
Tray.ai, Inc. proprietary — all rights reserved.
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Tray.ai, Inc.
|
|
6
|
+
|
|
7
|
+
Apache License
|
|
8
|
+
Version 2.0, January 2004
|
|
9
|
+
http://www.apache.org/licenses/
|
|
10
|
+
|
|
11
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
12
|
+
|
|
13
|
+
1. Definitions.
|
|
14
|
+
|
|
15
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
16
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
17
|
+
|
|
18
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
19
|
+
the copyright owner that is granting the License.
|
|
20
|
+
|
|
21
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
22
|
+
other entities that control, are controlled by, or are under common
|
|
23
|
+
control with that entity. For the purposes of this definition,
|
|
24
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
25
|
+
direction or management of such entity, whether by contract or
|
|
26
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
27
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
28
|
+
|
|
29
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
30
|
+
exercising permissions granted by this License.
|
|
31
|
+
|
|
32
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
33
|
+
including but not limited to software source code, documentation
|
|
34
|
+
source, and configuration files.
|
|
35
|
+
|
|
36
|
+
"Object" form shall mean any form resulting from mechanical
|
|
37
|
+
transformation or translation of a Source form, including but
|
|
38
|
+
not limited to compiled object code, generated documentation,
|
|
39
|
+
and conversions to other media types.
|
|
40
|
+
|
|
41
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
42
|
+
Object form, made available under the License, as indicated by a
|
|
43
|
+
copyright notice that is included in or attached to the work
|
|
44
|
+
(an example is provided in the Appendix below).
|
|
45
|
+
|
|
46
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
47
|
+
form, that is based on (or derived from) the Work and for which the
|
|
48
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
49
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
50
|
+
of this License, Derivative Works shall not include works that remain
|
|
51
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
52
|
+
the Work and Derivative Works thereof.
|
|
53
|
+
|
|
54
|
+
"Contribution" shall mean any work of authorship, including
|
|
55
|
+
the original version of the Work and any modifications or additions
|
|
56
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
57
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
58
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
59
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
60
|
+
means any form of electronic, verbal, or written communication sent
|
|
61
|
+
to the Licensor or its representatives, including but not limited to
|
|
62
|
+
communication on electronic mailing lists, source code control systems,
|
|
63
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
64
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
65
|
+
excluding communication that is conspicuously marked or otherwise
|
|
66
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
67
|
+
|
|
68
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
69
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
70
|
+
subsequently incorporated within the Work.
|
|
71
|
+
|
|
72
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
73
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
74
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
75
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
76
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
77
|
+
Work and such Derivative Works in Source or Object form.
|
|
78
|
+
|
|
79
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
80
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
81
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
82
|
+
(except as stated in this section) patent license to make, have made,
|
|
83
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
84
|
+
where such license applies only to those patent claims licensable
|
|
85
|
+
by such Contributor that are necessarily infringed by their
|
|
86
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
87
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
88
|
+
institute patent litigation against any entity (including a
|
|
89
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
90
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
91
|
+
or contributory patent infringement, then any patent licenses
|
|
92
|
+
granted to You under this License for that Work shall terminate
|
|
93
|
+
as of the date such litigation is filed.
|
|
94
|
+
|
|
95
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
96
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
97
|
+
modifications, and in Source or Object form, provided that You
|
|
98
|
+
meet the following conditions:
|
|
99
|
+
|
|
100
|
+
(a) You must give any other recipients of the Work or
|
|
101
|
+
Derivative Works a copy of this License; and
|
|
102
|
+
|
|
103
|
+
(b) You must cause any modified files to carry prominent notices
|
|
104
|
+
stating that You changed the files; and
|
|
105
|
+
|
|
106
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
107
|
+
that You distribute, all copyright, patent, trademark, and
|
|
108
|
+
attribution notices from the Source form of the Work,
|
|
109
|
+
excluding those notices that do not pertain to any part of
|
|
110
|
+
the Derivative Works; and
|
|
111
|
+
|
|
112
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
113
|
+
distribution, then any Derivative Works that You distribute must
|
|
114
|
+
include a readable copy of the attribution notices contained
|
|
115
|
+
within such NOTICE file, excluding those notices that do not
|
|
116
|
+
pertain to any part of the Derivative Works, in at least one
|
|
117
|
+
of the following places: within a NOTICE text file distributed
|
|
118
|
+
as part of the Derivative Works; within the Source form or
|
|
119
|
+
documentation, if provided along with the Derivative Works; or,
|
|
120
|
+
within a display generated by the Derivative Works, if and
|
|
121
|
+
wherever such third-party notices normally appear. The contents
|
|
122
|
+
of the NOTICE file are for informational purposes only and
|
|
123
|
+
do not modify the License. You may add Your own attribution
|
|
124
|
+
notices within Derivative Works that You distribute, alongside
|
|
125
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
126
|
+
that such additional attribution notices cannot be construed
|
|
127
|
+
as modifying the License.
|
|
128
|
+
|
|
129
|
+
You may add Your own copyright statement to Your modifications and
|
|
130
|
+
may provide additional or different license terms and conditions
|
|
131
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
132
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
133
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
134
|
+
the conditions stated in this License.
|
|
135
|
+
|
|
136
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
137
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
138
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
139
|
+
this License, without any additional terms or conditions.
|
|
140
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
141
|
+
the terms of any separate license agreement you may have executed
|
|
142
|
+
with Licensor regarding such Contributions.
|
|
143
|
+
|
|
144
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
145
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
146
|
+
except as required for reasonable and customary use in describing the
|
|
147
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
148
|
+
|
|
149
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
150
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
151
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
152
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
153
|
+
implied, including, without limitation, any warranties or conditions
|
|
154
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
155
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
156
|
+
appropriateness of using or redistributing the Work and assume any
|
|
157
|
+
risks associated with Your exercise of permissions under this License.
|
|
158
|
+
|
|
159
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
160
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
161
|
+
unless required by applicable law (such as deliberate and grossly
|
|
162
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
163
|
+
liable to You for damages, including any direct, indirect, special,
|
|
164
|
+
incidental, or consequential damages of any character arising as a
|
|
165
|
+
result of this License or out of the use or inability to use the
|
|
166
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
167
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
168
|
+
other commercial damages or losses), even if such Contributor
|
|
169
|
+
has been advised of the possibility of such damages.
|
|
170
|
+
|
|
171
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
172
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
173
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
174
|
+
or other liability obligations and/or rights consistent with this
|
|
175
|
+
License. However, in accepting such obligations, You may act only
|
|
176
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
177
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
178
|
+
defend, and hold each Contributor harmless for any liability
|
|
179
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
180
|
+
of your accepting any such warranty or additional liability.
|
|
181
|
+
|
|
182
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# tray-sync-cli
|
|
2
|
+
CLI tool to clone tray projects and related assets on local machine which then can be used with version control system or promoted to different tray environment
|
|
3
|
+
|
|
4
|
+
## Requirements
|
|
5
|
+
|
|
6
|
+
- Node.js >= 22
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @trayai/tray-sync-cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
tray --version
|
|
18
|
+
tray --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Getting started: a first promotion, end to end
|
|
22
|
+
|
|
23
|
+
This is a concrete, step-by-step walkthrough of the most common workflow: pull a project from a source workspace, and promote it to a target workspace. It uses a two-org example (`DEV_ORG` → `PROD_ORG`) since that's the realistic setup for most customer pipelines, but everything here works identically for two workspaces within the same org.
|
|
24
|
+
|
|
25
|
+
### 1. Pick a source and a target environment
|
|
26
|
+
|
|
27
|
+
Decide which workspace you're pulling *from* (the source) and which one you're promoting *to* (the target). For this guide:
|
|
28
|
+
|
|
29
|
+
- Source: `DEV_ORG`
|
|
30
|
+
- Target: `PROD_ORG`
|
|
31
|
+
|
|
32
|
+
You'll need each workspace's ID and region, and a Tray API token with access to it.
|
|
33
|
+
|
|
34
|
+
### 2. Create a local directory for this project
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
mkdir -p ~/tcli-projects/my-first-tcli-project
|
|
38
|
+
cd ~/tcli-projects/my-first-tcli-project
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Everything the CLI manages — `tray.yaml`, `environments.json`, and every pulled project — lives under this directory.
|
|
42
|
+
|
|
43
|
+
### 3. Initialize the repository against your source workspace
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
tray init -r <region> -w <your-SOURCE-workspace-id> -t <your-token> -p <project-id-to-pull>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Example:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
tray init -r us1 -w 11111111-1111-1111-1111-111111111111 -t <token> -p <project_id>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
A few notes on the flags:
|
|
56
|
+
|
|
57
|
+
- **`-p <project-id>`** pulls that project immediately after scaffolding. Omit it and `init` just scaffolds an empty repository — you can pull specific projects later with: `tray pull -p <project_id>` OR `tray project add <project-id>` followed by `tray pull`.
|
|
58
|
+
- **`-s workspace`** (i.e. `tray init -s workspace -r <region> -w <id> -t <token>`, omitting `-p`) switches to workspace scope: every project in the workspace is pulled automatically, and `tray pull` keeps that mirror in sync going forward (including removing projects deleted from Tray). `-p` is ignored in this scope.
|
|
59
|
+
- **`-t <token>`** is optional at `init` time. If you skip it (or need to replace it later — tokens expire), set or refresh it any time with:
|
|
60
|
+
```bash
|
|
61
|
+
tray auth set -w <workspace-id> -r <region> -t <token>
|
|
62
|
+
```
|
|
63
|
+
`tray auth set` always overwrites whatever token was stored for that workspace — no separate "force" flag needed.
|
|
64
|
+
|
|
65
|
+
At this point you have a local mirror of your source project(s), configured against `DEV_ORG`.
|
|
66
|
+
|
|
67
|
+
### 4. Add your target environment
|
|
68
|
+
|
|
69
|
+
Now register where you want to promote *to*:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
tray env add <env-name> -r <region> -w <target-workspace-id> -t <target-token>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Example:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
tray env add PROD_ORG -r us1 -w 22222222-2222-2222-2222-222222222222 -t <prod-token>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
You can add more than one target environment this way (e.g. `STAGING_ORG`, `PROD_ORG`) — each gets its own entry in `environments.json`.
|
|
82
|
+
|
|
83
|
+
Same as `init`, providing `-t` here stores the token in `~/.tray/credentials.json` immediately. You can always set or refresh it independently with `tray auth set -w <target-workspace-id> -r <region> -t <token>`.
|
|
84
|
+
|
|
85
|
+
### 5. Promote
|
|
86
|
+
|
|
87
|
+
You're ready to import your local projects into the target environment. A few common invocations:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Recommended first: see what would happen without changing anything.
|
|
91
|
+
tray promote --to PROD_ORG --dry-run
|
|
92
|
+
|
|
93
|
+
# Promote a single project.
|
|
94
|
+
tray promote --to PROD_ORG -p <project-id>
|
|
95
|
+
|
|
96
|
+
# Promote multiple specific projects.
|
|
97
|
+
tray promote --to PROD_ORG -p <project-id-1> <project-id-2>
|
|
98
|
+
|
|
99
|
+
# Promote every project tracked in this directory (see them with `tray project list`).
|
|
100
|
+
tray promote --to PROD_ORG
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Important: every project needs a `target_project_id` per environment
|
|
104
|
+
|
|
105
|
+
The first time you promote a given project to a given environment — or whenever the target project changes — you need to tell the CLI which project in the target workspace this should import into.
|
|
106
|
+
|
|
107
|
+
Each pulled project has its own `mappings.json`, at:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
projects/<project-id>--<project-name>/mappings.json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
You don't have to create this file by hand — `tray pull` / `tray init` already scaffold it for you (with a placeholder entry showing the full shape) the first time a project is pulled. What you do need to do is edit the target environment's entry and fill in the real `target_project_id`:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"version": 1,
|
|
118
|
+
"environments": {
|
|
119
|
+
"PROD_ORG": {
|
|
120
|
+
"target_project_id": "<project-id>",
|
|
121
|
+
"authentications": {},
|
|
122
|
+
"config": {},
|
|
123
|
+
"connectors": [],
|
|
124
|
+
"services": []
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`target_project_id` here is the ID of the project **in `PROD_ORG`** that this local project should be imported into.
|
|
131
|
+
|
|
132
|
+
#### Authentications
|
|
133
|
+
|
|
134
|
+
If any workflow in the project you're promoting uses an authentication, you'll also need to map it. Tray tracks this per **authentication group** — a logical "auth slot" a workflow step references — not the authentication ID itself. When `tray promote` finds one it doesn't recognize, it tells you and scaffolds a placeholder into `mappings.json` for you:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"version": 1,
|
|
139
|
+
"environments": {
|
|
140
|
+
"PROD_ORG": {
|
|
141
|
+
"target_project_id": "<project-id>",
|
|
142
|
+
"authentications": {
|
|
143
|
+
"<source_authentication_id>": "MISSING_TARGET_AUTHENTICATION"
|
|
144
|
+
},
|
|
145
|
+
"config": {},
|
|
146
|
+
"connectors": [],
|
|
147
|
+
"services": []
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The key (`<source_authentication_id>`) is the source-side auth group ID — leave it as-is. Replace the placeholder value with the ID of the actual authentication in your **target** environment (`PROD_ORG`) that should serve that slot — you can find this in Tray's app, under that workspace's authentications. For example:
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
"authentications": {
|
|
157
|
+
"<source_authentication_id>": "<resolved_target_authentication_id>"
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### If you get it wrong
|
|
162
|
+
|
|
163
|
+
If a required field is missing or still holds a placeholder value, `tray promote` refuses the attempt and tells you exactly what's outstanding and where to fix it — it won't silently promote a project into the wrong target, or with an unresolved authentication.
|
|
164
|
+
|
|
165
|
+
## Contributing
|
|
166
|
+
|
|
167
|
+
For local development setup, the smoke/integration test, and internal architecture notes, see the "For contributors to this repo" section in [docs/getting-started-guide.md](docs/getting-started-guide.md#for-contributors-to-this-repo).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class TrayApiError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export class AuthError extends TrayApiError {
|
|
4
|
+
}
|
|
5
|
+
export class NotFoundError extends TrayApiError {
|
|
6
|
+
}
|
|
7
|
+
export class RateLimitError extends TrayApiError {
|
|
8
|
+
}
|
|
9
|
+
export class NetworkError extends TrayApiError {
|
|
10
|
+
}
|
|
11
|
+
export class IncompatibleApiError extends TrayApiError {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(`${message} — try upgrading tray-sync-cli.`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function errorForStatus(status, body) {
|
|
17
|
+
switch (status) {
|
|
18
|
+
case 401:
|
|
19
|
+
case 403:
|
|
20
|
+
return new AuthError(`Authentication failed (HTTP ${status}): ${body}`);
|
|
21
|
+
case 404:
|
|
22
|
+
return new NotFoundError(`Not found (HTTP ${status}): ${body}`);
|
|
23
|
+
case 429:
|
|
24
|
+
return new RateLimitError(`Rate limited (HTTP ${status}): ${body}`);
|
|
25
|
+
default:
|
|
26
|
+
return new NetworkError(`Request failed (HTTP ${status}): ${body}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { isAllowedUrl, urlsForRegion } from "../lib/region.js";
|
|
2
|
+
import { errorForStatus, IncompatibleApiError, NetworkError } from "./errors.js";
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
4
|
+
export function createTrayClientForRegion(region, token, options) {
|
|
5
|
+
const { apiBaseUrl, graphqlUrl } = urlsForRegion(region);
|
|
6
|
+
for (const url of [apiBaseUrl, graphqlUrl]) {
|
|
7
|
+
if (!isAllowedUrl(url)) {
|
|
8
|
+
throw new NetworkError(`URL is not in the allowlist: ${url}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return new TrayClient({ apiBaseUrl, graphqlUrl, token, ...options });
|
|
12
|
+
}
|
|
13
|
+
export class TrayClient {
|
|
14
|
+
apiBaseUrl;
|
|
15
|
+
graphqlUrl;
|
|
16
|
+
token;
|
|
17
|
+
timeoutMs;
|
|
18
|
+
fetchImpl;
|
|
19
|
+
isAllowedUrlImpl;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.apiBaseUrl = options.apiBaseUrl;
|
|
22
|
+
this.graphqlUrl = options.graphqlUrl;
|
|
23
|
+
this.token = options.token;
|
|
24
|
+
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
25
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
26
|
+
this.isAllowedUrlImpl = options.isAllowedUrlImpl ?? isAllowedUrl;
|
|
27
|
+
}
|
|
28
|
+
async request(method, path, body) {
|
|
29
|
+
return this.fetchJson(`${this.apiBaseUrl}${path}`, method, body);
|
|
30
|
+
}
|
|
31
|
+
async graphql(query, variables, url = this.graphqlUrl) {
|
|
32
|
+
const result = (await this.fetchJson(url, "POST", { query, variables }));
|
|
33
|
+
if (result.errors && result.errors.length > 0) {
|
|
34
|
+
throw new IncompatibleApiError(`GraphQL errors: ${JSON.stringify(result.errors)}`);
|
|
35
|
+
}
|
|
36
|
+
return result.data;
|
|
37
|
+
}
|
|
38
|
+
async fetchJson(url, method, body) {
|
|
39
|
+
if (!this.isAllowedUrlImpl(url)) {
|
|
40
|
+
throw new NetworkError(`URL is not in the allowlist: ${url}`);
|
|
41
|
+
}
|
|
42
|
+
let response;
|
|
43
|
+
try {
|
|
44
|
+
response = await this.fetchImpl(url, {
|
|
45
|
+
method,
|
|
46
|
+
headers: {
|
|
47
|
+
Authorization: `Bearer ${this.token}`,
|
|
48
|
+
"Content-Type": "application/json",
|
|
49
|
+
},
|
|
50
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
51
|
+
signal: AbortSignal.timeout(this.timeoutMs),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
throw new NetworkError(`Request to ${url} failed: ${err.message}`);
|
|
56
|
+
}
|
|
57
|
+
const text = await response.text();
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
throw errorForStatus(response.status, text);
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
return text === "" ? undefined : JSON.parse(text);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
throw new IncompatibleApiError(`Could not parse response from ${url}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=trayClient.js.map
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { initCommand } from "./commands/init.js";
|
|
7
|
+
import { pullCommand } from "./commands/pull.js";
|
|
8
|
+
import { statusCommand } from "./commands/status.js";
|
|
9
|
+
import { projectCommand } from "./commands/project.js";
|
|
10
|
+
import { envCommand } from "./commands/env.js";
|
|
11
|
+
import { authCommand } from "./commands/auth.js";
|
|
12
|
+
import { promoteCommand } from "./commands/promote.js";
|
|
13
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const pkg = JSON.parse(readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
|
|
15
|
+
const program = new Command();
|
|
16
|
+
program
|
|
17
|
+
.name("tray")
|
|
18
|
+
.description("Mirror Tray projects to local files and promote them between Tray environments")
|
|
19
|
+
.version(pkg.version, "-v, --version");
|
|
20
|
+
program.addCommand(initCommand);
|
|
21
|
+
program.addCommand(pullCommand);
|
|
22
|
+
program.addCommand(statusCommand);
|
|
23
|
+
program.addCommand(projectCommand);
|
|
24
|
+
program.addCommand(envCommand);
|
|
25
|
+
program.addCommand(authCommand);
|
|
26
|
+
program.addCommand(promoteCommand);
|
|
27
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
28
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
29
|
+
console.error(message);
|
|
30
|
+
process.exitCode = 1;
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Command, InvalidArgumentError } from "commander";
|
|
2
|
+
import { readCredentials, writeCredentials } from "../config/credentials.js";
|
|
3
|
+
import { describeRegion } from "../lib/regionDisplay.js";
|
|
4
|
+
import { parseRegion } from "../lib/regionParsing.js";
|
|
5
|
+
import { isUuid } from "../lib/uuid.js";
|
|
6
|
+
export function printAuthSetResult(stdout, result) {
|
|
7
|
+
const verb = result.overwrote ? "Updated" : "Set";
|
|
8
|
+
stdout(`${verb} token for workspace ${result.workspaceId} (${describeRegion(result.region)}).`);
|
|
9
|
+
}
|
|
10
|
+
export async function runAuthSet(deps, options) {
|
|
11
|
+
const { env, stdout } = deps;
|
|
12
|
+
const credentials = await readCredentials(env);
|
|
13
|
+
const overwrote = credentials.workspaces[options.workspaceId] !== undefined;
|
|
14
|
+
credentials.workspaces[options.workspaceId] = {
|
|
15
|
+
region: options.region,
|
|
16
|
+
token: options.token,
|
|
17
|
+
};
|
|
18
|
+
await writeCredentials(credentials, env);
|
|
19
|
+
printAuthSetResult(stdout, { workspaceId: options.workspaceId, region: options.region, overwrote });
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
export function printAuthRemoveResult(stdout, result) {
|
|
23
|
+
if (!result.removed) {
|
|
24
|
+
stdout(`No stored credentials for workspace ${result.workspaceId}. Nothing to remove.`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
stdout(`Removed stored credentials for workspace ${result.workspaceId}.`);
|
|
28
|
+
}
|
|
29
|
+
export async function runAuthRemove(deps, options) {
|
|
30
|
+
const { env, stdout } = deps;
|
|
31
|
+
const credentials = await readCredentials(env);
|
|
32
|
+
const removed = credentials.workspaces[options.workspaceId] !== undefined;
|
|
33
|
+
if (removed) {
|
|
34
|
+
delete credentials.workspaces[options.workspaceId];
|
|
35
|
+
await writeCredentials(credentials, env);
|
|
36
|
+
}
|
|
37
|
+
printAuthRemoveResult(stdout, { workspaceId: options.workspaceId, removed });
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
export function printAuthListResult(stdout, result) {
|
|
41
|
+
if (result.entries.length === 0) {
|
|
42
|
+
stdout("No stored credentials.");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const entry of result.entries) {
|
|
46
|
+
stdout(` ${entry.workspaceId} (${describeRegion(entry.region)})`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export async function runAuthList(deps, _options) {
|
|
50
|
+
const { env, stdout } = deps;
|
|
51
|
+
const credentials = await readCredentials(env);
|
|
52
|
+
const entries = Object.entries(credentials.workspaces)
|
|
53
|
+
.map(([workspaceId, entry]) => ({ workspaceId, region: entry.region }))
|
|
54
|
+
.sort((a, b) => a.workspaceId.localeCompare(b.workspaceId));
|
|
55
|
+
printAuthListResult(stdout, { entries });
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
function parseUuid(value, flagName) {
|
|
59
|
+
if (!isUuid(value)) {
|
|
60
|
+
throw new InvalidArgumentError(`${flagName} must be a UUID`);
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
function realDeps() {
|
|
65
|
+
return {
|
|
66
|
+
env: process.env,
|
|
67
|
+
stdout: (line) => console.log(line),
|
|
68
|
+
stderr: (line) => console.error(line),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export const authCommand = new Command("auth").description("Manage ~/.tray/credentials.json directly, independent of tray env");
|
|
72
|
+
authCommand
|
|
73
|
+
.command("set")
|
|
74
|
+
.description("Set (or overwrite) a workspace's token")
|
|
75
|
+
.requiredOption("-w, --workspace-id <id>", "Tray workspace UUID", (value) => parseUuid(value, "--workspace-id"))
|
|
76
|
+
.requiredOption("-r, --region <region>", "Tray region this workspace lives in", parseRegion)
|
|
77
|
+
.requiredOption("-t, --token <token>", "Tray API token to store")
|
|
78
|
+
.action(async (opts) => {
|
|
79
|
+
const exitCode = await runAuthSet(realDeps(), {
|
|
80
|
+
workspaceId: opts.workspaceId,
|
|
81
|
+
region: opts.region,
|
|
82
|
+
token: opts.token,
|
|
83
|
+
});
|
|
84
|
+
process.exitCode = exitCode;
|
|
85
|
+
});
|
|
86
|
+
authCommand
|
|
87
|
+
.command("remove")
|
|
88
|
+
.description("Remove a workspace's stored token")
|
|
89
|
+
.requiredOption("-w, --workspace-id <id>", "Tray workspace UUID", (value) => parseUuid(value, "--workspace-id"))
|
|
90
|
+
.action(async (opts) => {
|
|
91
|
+
const exitCode = await runAuthRemove(realDeps(), {
|
|
92
|
+
workspaceId: opts.workspaceId,
|
|
93
|
+
});
|
|
94
|
+
process.exitCode = exitCode;
|
|
95
|
+
});
|
|
96
|
+
authCommand
|
|
97
|
+
.command("list")
|
|
98
|
+
.description("List workspaces with stored credentials")
|
|
99
|
+
.action(async () => {
|
|
100
|
+
const exitCode = await runAuthList(realDeps(), {});
|
|
101
|
+
process.exitCode = exitCode;
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=auth.js.map
|