@xano/cli 0.0.95-beta.1 → 0.0.95-beta.2
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 +5 -0
- package/dist/commands/release/deploy/index.d.ts +17 -0
- package/dist/commands/release/deploy/index.js +107 -0
- package/oclif.manifest.json +2457 -2365
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -235,6 +235,11 @@ xano release pull ./my-release -r v1.0 --env --records
|
|
|
235
235
|
xano release push ./my-release -n "v2.0"
|
|
236
236
|
xano release push ./my-release -n "v2.0" --hotfix -d "Critical fix"
|
|
237
237
|
xano release push ./my-release -n "v2.0" --no-records --no-env
|
|
238
|
+
|
|
239
|
+
# Deploy a release to its workspace as a new branch
|
|
240
|
+
xano release deploy "v1.0"
|
|
241
|
+
xano release deploy "v1.0" --branch "restore-v1" --no-set_live
|
|
242
|
+
xano release deploy "v1.0" -w 40 -o json
|
|
238
243
|
```
|
|
239
244
|
|
|
240
245
|
### Platforms
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import BaseCommand from '../../../base-command.js';
|
|
2
|
+
export default class ReleaseDeploy extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
release_name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
set_live: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseCommand from '../../../base-command.js';
|
|
3
|
+
export default class ReleaseDeploy extends BaseCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
release_name: Args.string({
|
|
6
|
+
description: 'Name of the release to deploy',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static description = 'Deploy a release to its workspace as a new branch';
|
|
11
|
+
static examples = [
|
|
12
|
+
`$ xano release deploy "v1.0"
|
|
13
|
+
Deployed release "v1.0" to workspace 40 (branch: v1.0, set live)
|
|
14
|
+
`,
|
|
15
|
+
`$ xano release deploy "v1.0" --branch "restore-v1" --no-set_live`,
|
|
16
|
+
`$ xano release deploy "v1.0" -w 40 -o json`,
|
|
17
|
+
];
|
|
18
|
+
static flags = {
|
|
19
|
+
...BaseCommand.baseFlags,
|
|
20
|
+
branch: Flags.string({
|
|
21
|
+
char: 'b',
|
|
22
|
+
description: 'Branch label for the new branch (defaults to release branch name)',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
output: Flags.string({
|
|
26
|
+
char: 'o',
|
|
27
|
+
default: 'summary',
|
|
28
|
+
description: 'Output format',
|
|
29
|
+
options: ['summary', 'json'],
|
|
30
|
+
required: false,
|
|
31
|
+
}),
|
|
32
|
+
set_live: Flags.boolean({
|
|
33
|
+
default: false,
|
|
34
|
+
description: 'Set the new branch as live',
|
|
35
|
+
required: false,
|
|
36
|
+
}),
|
|
37
|
+
workspace: Flags.string({
|
|
38
|
+
char: 'w',
|
|
39
|
+
description: 'Workspace ID (uses profile workspace if not provided)',
|
|
40
|
+
required: false,
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
async run() {
|
|
44
|
+
const { args, flags } = await this.parse(ReleaseDeploy);
|
|
45
|
+
const profileName = flags.profile || this.getDefaultProfile();
|
|
46
|
+
const credentials = this.loadCredentialsFile();
|
|
47
|
+
if (!credentials || !(profileName in credentials.profiles)) {
|
|
48
|
+
this.error(`Profile '${profileName}' not found.\n` + `Create a profile using 'xano profile create'`);
|
|
49
|
+
}
|
|
50
|
+
const profile = credentials.profiles[profileName];
|
|
51
|
+
if (!profile.instance_origin) {
|
|
52
|
+
this.error(`Profile '${profileName}' is missing instance_origin`);
|
|
53
|
+
}
|
|
54
|
+
if (!profile.access_token) {
|
|
55
|
+
this.error(`Profile '${profileName}' is missing access_token`);
|
|
56
|
+
}
|
|
57
|
+
const workspaceId = flags.workspace || profile.workspace;
|
|
58
|
+
if (!workspaceId) {
|
|
59
|
+
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
60
|
+
}
|
|
61
|
+
const releaseName = encodeURIComponent(args.release_name);
|
|
62
|
+
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/release/${releaseName}/deploy`;
|
|
63
|
+
const body = {
|
|
64
|
+
set_live: flags.set_live,
|
|
65
|
+
};
|
|
66
|
+
if (flags.branch)
|
|
67
|
+
body.branch = flags.branch;
|
|
68
|
+
this.warn('This may take a few minutes. Please be patient.');
|
|
69
|
+
const startTime = Date.now();
|
|
70
|
+
try {
|
|
71
|
+
const response = await this.verboseFetch(apiUrl, {
|
|
72
|
+
body: JSON.stringify(body),
|
|
73
|
+
headers: {
|
|
74
|
+
accept: 'application/json',
|
|
75
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
76
|
+
'Content-Type': 'application/json',
|
|
77
|
+
},
|
|
78
|
+
method: 'POST',
|
|
79
|
+
}, flags.verbose, profile.access_token);
|
|
80
|
+
if (!response.ok) {
|
|
81
|
+
const errorText = await response.text();
|
|
82
|
+
this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
|
|
83
|
+
}
|
|
84
|
+
const release = (await response.json());
|
|
85
|
+
if (flags.output === 'json') {
|
|
86
|
+
this.log(JSON.stringify(release, null, 2));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
90
|
+
const branchLabel = flags.branch || release.branch || 'default';
|
|
91
|
+
const liveStatus = flags.set_live ? ', set live' : '';
|
|
92
|
+
this.log(`Deployed release "${release.name}" to workspace ${workspaceId} (branch: ${branchLabel}${liveStatus})`);
|
|
93
|
+
if (release.description)
|
|
94
|
+
this.log(` Description: ${release.description}`);
|
|
95
|
+
this.log(` Time: ${elapsed}s`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (error instanceof Error) {
|
|
100
|
+
this.error(`Failed to deploy release: ${error.message}`);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.error(`Failed to deploy release: ${String(error)}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|