@kaleido-xlm/cli 0.1.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Kaleido contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # @kaleido-xlm/cli
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ npm install -g @kaleido-xlm/cli
7
+ kaleido --help
8
+ ```
9
+
10
+ ## Requirements
11
+
12
+ - Node.js `>=20`
13
+ - Stellar CLI `>=22.0.0` and `<=22.0.1` available on `PATH`
14
+ - A Kaleido project with `kaleido.config.ts` for project commands such as `build`, `deploy`, `generate`, and `invoke`
15
+
16
+ If your local machine is on a newer Stellar CLI, `--allow-untested-stellar-cli` is the local-only escape hatch. CI and release workflows should stay on the supported range.
17
+
18
+ ## Commands
19
+
20
+ - `kaleido init <projectName>` creates a project from a bundled template and writes `kaleido.artifacts.json`
21
+ - `kaleido build [contract]` builds one configured contract through Stellar CLI and defaults to `counter` when omitted
22
+ - `kaleido deploy [contract] --source <identity> [--network <network>] [--force] [--no-deps]` deploys contracts and records contract IDs in `kaleido.artifacts.json`
23
+ - `kaleido generate <contract> [--network <network>]` generates TypeScript bindings from a deployed contract ID
24
+ - `kaleido invoke <contract.method> --source <identity> [args...]` invokes a deployed contract method through the configured workflow
25
+
26
+ The supported CLI flow is `init -> build -> deploy -> generate -> invoke`.
27
+
28
+ ## Supported Inputs
29
+
30
+ - `--source` accepts a Stellar CLI identity alias or public `G...` account address
31
+ - `--network <network>` selects a configured network such as `testnet`
32
+ - `invoke` expects a `<contract.method>` target and forwards extra args to the underlying Stellar contract invocation
33
+ - `deploy --no-deps` is supported only when deploying a single named contract
34
+
35
+ Unsupported input posture:
36
+
37
+ - secret keys and seed phrases are not supported CLI inputs
38
+ - undocumented private flags or internal repo file paths are not part of the package contract
39
+
40
+ ## Error Behavior
41
+
42
+ `@kaleido-xlm/cli` emits documented `KALEIDO_*` error codes for automation. Consumers should match on the error code, not human-readable text.
43
+
44
+ Common codes include:
45
+
46
+ - `KALEIDO_CONFIG_NOT_FOUND`
47
+ - `KALEIDO_INVALID_CONFIG`
48
+ - `KALEIDO_STELLAR_CLI_NOT_FOUND`
49
+ - `KALEIDO_BUILD_FAILED`
50
+ - `KALEIDO_DEPLOY_FAILED`
51
+ - `KALEIDO_BINDINGS_FAILED`
52
+ - `KALEIDO_INVOKE_FAILED`
53
+ - `KALEIDO_CONTRACT_ID_NOT_FOUND`
54
+ - `KALEIDO_SOURCE_ACCOUNT_REQUIRED`
55
+ - `KALEIDO_TEMPLATE_MANIFEST_NOT_FOUND`
56
+ - `KALEIDO_TEMPLATE_INCOMPATIBLE`
57
+
58
+ ## Relationship To `@kaleido-xlm/core`
59
+
60
+ `@kaleido-xlm/cli` is the supported end-user entrypoint for Kaleido's command workflow. It intentionally stays thin and delegates config loading, artifacts, command orchestration, and shared error primitives to `@kaleido-xlm/core`.
61
+
62
+ If you want the stable packaged workflow, prefer the CLI contract over importing `@kaleido-xlm/core` directly.
63
+
64
+ ## Versioning And Stability
65
+
66
+ This package is the primary supported consumer surface for the Kaleido workflow. Stability applies to the documented commands, inputs, and `KALEIDO_*` error contract.
67
+
68
+ Undocumented internals, private module paths, and placeholder commands such as `kaleido dev` are not part of the stability promise.
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,238 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/program.ts
4
+ import { Command } from "commander";
5
+
6
+ // src/commands/build.command.ts
7
+ import { buildContract, loadConfig } from "@kaleido-xlm/core";
8
+
9
+ // src/utils/errors.ts
10
+ import { toKaleidoError } from "@kaleido-xlm/core";
11
+
12
+ // src/utils/logger.ts
13
+ import chalk from "chalk";
14
+ var logger = {
15
+ info(message) {
16
+ console.log(message);
17
+ },
18
+ success(message) {
19
+ console.log(chalk.green(message));
20
+ },
21
+ warn(message) {
22
+ console.warn(chalk.yellow(message));
23
+ },
24
+ error(message) {
25
+ console.error(chalk.red(message));
26
+ },
27
+ muted(message) {
28
+ console.log(chalk.gray(message));
29
+ }
30
+ };
31
+
32
+ // src/utils/errors.ts
33
+ function printError(error) {
34
+ const kaleidoError = toKaleidoError(error);
35
+ logger.error(`Error: ${kaleidoError.message}`);
36
+ logger.info("");
37
+ logger.info(`Code: ${kaleidoError.code}`);
38
+ if (kaleidoError.hint) {
39
+ logger.info(`Hint: ${kaleidoError.hint}`);
40
+ }
41
+ }
42
+ async function runCliAction(action) {
43
+ try {
44
+ await action();
45
+ } catch (error) {
46
+ printError(error);
47
+ process.exitCode = 1;
48
+ }
49
+ }
50
+
51
+ // src/commands/build.command.ts
52
+ function registerBuildCommand(program2) {
53
+ program2.command("build").description("Build a configured Soroban contract").argument("[contract]", "Contract name", "counter").option("--allow-untested-stellar-cli", "Allow local use of a Stellar CLI version newer than Kaleido's tested maximum").action((contractName, options) => runCliAction(async () => {
54
+ const config = await loadConfig();
55
+ const result = await buildContract({
56
+ config,
57
+ contractName,
58
+ allowUntestedStellarCli: options.allowUntestedStellarCli === true
59
+ });
60
+ logger.success("Contract built");
61
+ logger.info("");
62
+ logger.info(`Contract: ${result.contract.name}`);
63
+ logger.info(`WASM: ${result.contract.config.wasm}`);
64
+ }));
65
+ }
66
+
67
+ // src/commands/deploy.command.ts
68
+ import { deployContractGraph, KaleidoError, KaleidoErrorCode, loadConfig as loadConfig2 } from "@kaleido-xlm/core";
69
+ function registerDeployCommand(program2) {
70
+ program2.command("deploy").description("Deploy one or all configured Soroban contracts").argument("[contract]", "Contract name").option("-n, --network <network>", "Configured network name").requiredOption("-s, --source <source>", "Stellar CLI identity alias or public account address").option("--force", "Redeploy contracts even if artifacts already contain contract IDs").option("--no-deps", "Do not deploy missing dependencies for a selected contract").option("--allow-untested-stellar-cli", "Allow local use of a Stellar CLI version newer than Kaleido's tested maximum").action((contractName, options) => runCliAction(async () => {
71
+ if (options.deps === false && !contractName) {
72
+ throw new KaleidoError(
73
+ "`--no-deps` requires a contract name.",
74
+ KaleidoErrorCode.INVALID_CONFIG,
75
+ "Select a single contract or omit `--no-deps` to deploy the full graph."
76
+ );
77
+ }
78
+ const config = await loadConfig2();
79
+ const result = await deployContractGraph({
80
+ config,
81
+ contractName,
82
+ networkName: options.network,
83
+ source: options.source,
84
+ includeDependencies: options.deps !== false,
85
+ force: options.force === true,
86
+ allowUntestedStellarCli: options.allowUntestedStellarCli === true
87
+ });
88
+ logger.success("Deploy complete");
89
+ logger.info("");
90
+ logger.info(`Network: ${result.network.name}`);
91
+ for (const contract of result.deployedContracts) {
92
+ logger.info(`Contract: ${contract.name}`);
93
+ logger.info(`Contract ID: ${contract.contractId}`);
94
+ }
95
+ logger.info("Artifacts updated: kaleido.artifacts.json");
96
+ }));
97
+ }
98
+
99
+ // src/commands/dev.command.ts
100
+ function registerDevCommand(program2) {
101
+ program2.command("dev").description("Run the local Kaleido development workflow").action(() => runCliAction(async () => {
102
+ logger.warn("kaleido dev is not implemented in the MVP.");
103
+ logger.info("Use kaleido build, deploy, generate, and invoke directly.");
104
+ }));
105
+ }
106
+
107
+ // src/commands/generate.command.ts
108
+ import { generateBindings, loadConfig as loadConfig3 } from "@kaleido-xlm/core";
109
+ function registerGenerateCommand(program2) {
110
+ program2.command("generate").description("Generate TypeScript bindings for a deployed contract").argument("<contract>", "Contract name").option("-n, --network <network>", "Configured network name").option("--allow-untested-stellar-cli", "Allow local use of a Stellar CLI version newer than Kaleido's tested maximum").action((contractName, options) => runCliAction(async () => {
111
+ const config = await loadConfig3();
112
+ const result = await generateBindings({
113
+ config,
114
+ contractName,
115
+ networkName: options.network,
116
+ allowUntestedStellarCli: options.allowUntestedStellarCli === true
117
+ });
118
+ logger.success("Client generated");
119
+ logger.info("");
120
+ logger.info(`Contract: ${result.contractName}`);
121
+ logger.info(`Network: ${result.network.name}`);
122
+ logger.info(`Output: ${result.outputDir}`);
123
+ }));
124
+ }
125
+
126
+ // src/commands/init.command.ts
127
+ import path2 from "path";
128
+ import { createProjectFromTemplate } from "@kaleido-xlm/core";
129
+
130
+ // src/utils/template-path.ts
131
+ import { access } from "fs/promises";
132
+ import path from "path";
133
+ import { fileURLToPath } from "url";
134
+ import { KaleidoError as KaleidoError2, KaleidoErrorCode as KaleidoErrorCode2 } from "@kaleido-xlm/core";
135
+ async function resolveTemplateDir(templateName) {
136
+ const envTemplatesDir = process.env.KALEIDO_TEMPLATES_DIR;
137
+ const candidates = [
138
+ envTemplatesDir ? path.join(envTemplatesDir, templateName) : void 0,
139
+ path.resolve(process.cwd(), "packages", "templates", templateName),
140
+ ...candidatePathsFromModule(templateName)
141
+ ].filter((candidate) => Boolean(candidate));
142
+ for (const candidate of candidates) {
143
+ try {
144
+ await access(candidate);
145
+ return candidate;
146
+ } catch {
147
+ }
148
+ }
149
+ throw new KaleidoError2(
150
+ `Template "${templateName}" was not found.`,
151
+ KaleidoErrorCode2.TEMPLATE_NOT_FOUND,
152
+ "Set KALEIDO_TEMPLATES_DIR or run from a Kaleido checkout that includes packages/templates."
153
+ );
154
+ }
155
+ function candidatePathsFromModule(templateName) {
156
+ const currentFile = fileURLToPath(import.meta.url);
157
+ const start = path.dirname(currentFile);
158
+ const candidates = [];
159
+ let dir = start;
160
+ for (let depth = 0; depth < 8; depth += 1) {
161
+ candidates.push(path.join(dir, "packages", "templates", templateName));
162
+ candidates.push(path.join(dir, "templates", templateName));
163
+ candidates.push(path.join(dir, "node_modules", "@kaleido", "templates", templateName));
164
+ dir = path.dirname(dir);
165
+ }
166
+ return candidates;
167
+ }
168
+
169
+ // src/commands/init.command.ts
170
+ function registerInitCommand(program2) {
171
+ program2.command("init").description("Create a new Kaleido dApp from a template").argument("<projectName>", "Project directory to create").option("-t, --template <template>", "Template name", "react-vite-counter").action((projectName, options) => runCliAction(async () => {
172
+ const templateDir = await resolveTemplateDir(options.template);
173
+ const targetDir = path2.resolve(process.cwd(), projectName);
174
+ const result = await createProjectFromTemplate({
175
+ projectName,
176
+ targetDir,
177
+ templateDir
178
+ });
179
+ logger.success("Project created");
180
+ logger.info("");
181
+ logger.info(`Project: ${projectName}`);
182
+ logger.info(`Template: ${result.template.name}@${result.template.version}`);
183
+ logger.info(`Path: ${targetDir}`);
184
+ logger.info("");
185
+ logger.info("Next steps:");
186
+ logger.info(` cd ${projectName}`);
187
+ logger.info(" npm install");
188
+ logger.info(" npx kaleido build counter");
189
+ }));
190
+ }
191
+
192
+ // src/commands/invoke.command.ts
193
+ import { invokeContract, loadConfig as loadConfig4 } from "@kaleido-xlm/core";
194
+ function registerInvokeCommand(program2) {
195
+ program2.command("invoke").description("Invoke a deployed contract function").argument("<target>", "Invoke target in contract.method format").argument("[args...]", "Arguments forwarded to Stellar CLI after the method name").option("-n, --network <network>", "Configured network name").requiredOption("-s, --source <source>", "Stellar CLI identity alias or public account address").option("--allow-untested-stellar-cli", "Allow local use of a Stellar CLI version newer than Kaleido's tested maximum").allowUnknownOption(true).allowExcessArguments(true).action((target, args, options) => runCliAction(async () => {
196
+ const config = await loadConfig4();
197
+ const result = await invokeContract({
198
+ config,
199
+ target,
200
+ args,
201
+ networkName: options.network,
202
+ source: options.source,
203
+ allowUntestedStellarCli: options.allowUntestedStellarCli === true
204
+ });
205
+ logger.success("Invoke complete");
206
+ logger.info("");
207
+ logger.info(`Network: ${result.network.name}`);
208
+ logger.info(`Contract: ${result.target.contractName}`);
209
+ logger.info(`Method: ${result.target.method}`);
210
+ if (result.result) {
211
+ logger.info("");
212
+ logger.info(result.result);
213
+ }
214
+ }));
215
+ }
216
+
217
+ // src/version.ts
218
+ var KALEIDO_CLI_VERSION = "0.1.0";
219
+
220
+ // src/program.ts
221
+ function createProgram() {
222
+ const program2 = new Command();
223
+ program2.name("kaleido").description("Developer toolkit for Stellar/Soroban dApps").version(KALEIDO_CLI_VERSION);
224
+ registerInitCommand(program2);
225
+ registerDevCommand(program2);
226
+ registerBuildCommand(program2);
227
+ registerDeployCommand(program2);
228
+ registerGenerateCommand(program2);
229
+ registerInvokeCommand(program2);
230
+ return program2;
231
+ }
232
+
233
+ // src/index.ts
234
+ var program = createProgram();
235
+ void program.parseAsync(process.argv).catch((error) => {
236
+ console.error(error);
237
+ process.exitCode = 1;
238
+ });
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@kaleido-xlm/cli",
3
+ "version": "0.1.0",
4
+ "description": "Developer toolkit CLI for building dApps on Stellar/Soroban",
5
+ "keywords": [
6
+ "stellar",
7
+ "soroban",
8
+ "cli",
9
+ "dapp",
10
+ "smart-contracts",
11
+ "blockchain",
12
+ "web3",
13
+ "kaleido"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/Dione-b/kaleido.git",
18
+ "directory": "packages/cli"
19
+ },
20
+ "homepage": "https://github.com/Dione-b/kaleido#readme",
21
+ "author": "Kaleido contributors",
22
+ "license": "MIT",
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "type": "module",
27
+ "bin": {
28
+ "kaleido": "./dist/index.js"
29
+ },
30
+ "main": "./dist/index.js",
31
+ "module": "./dist/index.js",
32
+ "types": "./dist/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js"
37
+ }
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "README.md",
42
+ "LICENSE"
43
+ ],
44
+ "dependencies": {
45
+ "@kaleido-xlm/core": "^0.1.0",
46
+ "chalk": "^5.4.1",
47
+ "commander": "^12.1.0"
48
+ },
49
+ "devDependencies": {
50
+ "tsup": "^8.3.5",
51
+ "tsx": "^4.19.2",
52
+ "typescript": "^5.7.2",
53
+ "vitest": "^2.1.8"
54
+ },
55
+ "scripts": {
56
+ "build": "tsup src/index.ts --format esm --dts --clean",
57
+ "dev": "tsx src/index.ts",
58
+ "test": "vitest run --pool=threads",
59
+ "typecheck": "tsc --noEmit"
60
+ }
61
+ }