@git.zone/tsdeploy 0.2.0 → 0.3.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/ts/cli.ts CHANGED
@@ -6,6 +6,40 @@ const getStringArg = (argvArg: any, keyArg: string): string | undefined => {
6
6
  return typeof value === 'string' && value.trim() ? value.trim() : undefined;
7
7
  };
8
8
 
9
+ const getStringArgByKeys = (argvArg: any, keysArg: string[]): string | undefined => {
10
+ for (const key of keysArg) {
11
+ const value = getStringArg(argvArg, key);
12
+ if (value) return value;
13
+ }
14
+ return undefined;
15
+ };
16
+
17
+ const getBooleanArgByKeys = (argvArg: any, keysArg: string[]): boolean => {
18
+ for (const key of keysArg) {
19
+ const value = argvArg[key];
20
+ if (value === true) return true;
21
+ if (typeof value === 'string' && ['1', 'true', 'yes'].includes(value.toLowerCase())) return true;
22
+ }
23
+ return false;
24
+ };
25
+
26
+ const getNumberArgByKeys = (argvArg: any, keysArg: string[]): number | undefined => {
27
+ let rawValue: string | number | undefined;
28
+ for (const key of keysArg) {
29
+ const value = argvArg[key];
30
+ if (typeof value === 'number' || (typeof value === 'string' && value.trim())) {
31
+ rawValue = value;
32
+ break;
33
+ }
34
+ }
35
+ if (rawValue === undefined) return undefined;
36
+ const parsed = Number(rawValue);
37
+ if (!Number.isFinite(parsed) || parsed < 0) {
38
+ throw new Error(`Expected a non-negative number for --${keysArg[0]}.`);
39
+ }
40
+ return parsed;
41
+ };
42
+
9
43
  const printJson = (valueArg: unknown): void => {
10
44
  console.log(JSON.stringify(valueArg, null, 2));
11
45
  };
@@ -78,6 +112,25 @@ const runDoctor = async (): Promise<void> => {
78
112
  printJson(await createTsDeploy().doctor());
79
113
  };
80
114
 
115
+ const runDeploy = async (argvArg: any): Promise<void> => {
116
+ const tsDeploy = createTsDeploy();
117
+ const result = await tsDeploy.deploy({
118
+ dryRun: getBooleanArgByKeys(argvArg, ['dryRun', 'dry-run']),
119
+ skipChecks: getBooleanArgByKeys(argvArg, ['skipChecks', 'skip-checks']),
120
+ skipPush: getBooleanArgByKeys(argvArg, ['skipPush', 'skip-push']),
121
+ tag: getStringArg(argvArg, 'tag'),
122
+ image: getStringArg(argvArg, 'image'),
123
+ platform: getStringArg(argvArg, 'platform'),
124
+ builder: getStringArg(argvArg, 'builder'),
125
+ verifyUrl: getStringArgByKeys(argvArg, ['verifyUrl', 'verify-url']),
126
+ waitSeconds: getNumberArgByKeys(argvArg, ['waitSeconds', 'wait-seconds']),
127
+ token: getStringArg(argvArg, 'token'),
128
+ username: getStringArg(argvArg, 'username'),
129
+ password: getStringArg(argvArg, 'password'),
130
+ });
131
+ printJson(result);
132
+ };
133
+
81
134
  const printHelp = (): void => {
82
135
  console.log(`
83
136
  Usage: tsdeploy <command> [options]
@@ -89,10 +142,13 @@ Commands:
89
142
  status
90
143
  doctor
91
144
  plan
145
+ deploy [--dryRun] [--skipChecks] [--skipPush] [--tag <tag>] [--platform <platform>] [--builder <name>]
146
+ [--verifyUrl <url>] [--waitSeconds <seconds>] [--token <token>]
92
147
 
93
148
  Notes:
94
149
  tsdeploy stores only the project pointer in .nogit/tsdeploy.json.
95
- Remote deployment mutations are disabled until Cloudly/Onebox APIs are verified.
150
+ Cloudly workload deployment builds and pushes the linked OCI image after validating deployOnPush.
151
+ Onebox deployment mutations are not implemented yet.
96
152
  `);
97
153
  };
98
154
 
@@ -112,6 +168,7 @@ export const runCli = async (): Promise<void> => {
112
168
  cli.addCommand('status').subscribe(runStatus);
113
169
  cli.addCommand('doctor').subscribe(runDoctor);
114
170
  cli.addCommand('plan').subscribe(runPlan);
171
+ cli.addCommand('deploy').subscribe(runDeploy);
115
172
  cli.addCommand('help').subscribe(async () => printHelp());
116
173
  cli.startParse(getSmartcliArgv());
117
174
  };
package/ts/plugins.ts CHANGED
@@ -1,13 +1,25 @@
1
1
  // node native scope
2
2
  import * as fs from 'node:fs/promises';
3
3
  import * as fsSync from 'node:fs';
4
+ import * as childProcess from 'node:child_process';
5
+ import * as crypto from 'node:crypto';
4
6
  import * as os from 'node:os';
5
7
  import * as path from 'node:path';
6
8
 
7
- export { fs, fsSync, os, path };
9
+ export { fs, fsSync, childProcess, crypto, os, path };
10
+
11
+ // @api.global scope
12
+ import * as typedrequest from '@api.global/typedrequest';
13
+
14
+ export { typedrequest };
8
15
 
9
16
  // @push.rocks scope
10
17
  import * as smartcli from '@push.rocks/smartcli';
11
18
  import * as smartconfig from '@push.rocks/smartconfig';
12
19
 
13
20
  export { smartcli, smartconfig };
21
+
22
+ // @serve.zone scope
23
+ import * as servezoneInterfaces from '@serve.zone/interfaces';
24
+
25
+ export { servezoneInterfaces };
package/ts/types.ts CHANGED
@@ -48,7 +48,7 @@ export interface ITsDeployStatus {
48
48
  }
49
49
 
50
50
  export interface ITsDeployPlanAction {
51
- type: 'inspect' | 'noop';
51
+ type: 'inspect' | 'deploy' | 'noop';
52
52
  title: string;
53
53
  description: string;
54
54
  }
@@ -56,7 +56,7 @@ export interface ITsDeployPlanAction {
56
56
  export interface ITsDeployPlan {
57
57
  schemaVersion: 1;
58
58
  projectDir: string;
59
- mutationAllowed: false;
59
+ mutationAllowed: boolean;
60
60
  summary: string;
61
61
  profile?: string;
62
62
  deploymentId?: string;
@@ -76,3 +76,87 @@ export interface ITsDeployDoctorResult {
76
76
  checks: ITsDeployDoctorCheck[];
77
77
  warnings: string[];
78
78
  }
79
+
80
+ export interface ITsDeployCommandRunOptions {
81
+ command: string;
82
+ args: string[];
83
+ cwd: string;
84
+ env?: Record<string, string | undefined>;
85
+ timeoutMs?: number;
86
+ maxOutputBytes?: number;
87
+ }
88
+
89
+ export interface ITsDeployCommandRunResult {
90
+ command: string;
91
+ args: string[];
92
+ exitCode: number;
93
+ stdout: string;
94
+ stderr: string;
95
+ }
96
+
97
+ export interface ITsDeployDeployOptions {
98
+ dryRun?: boolean;
99
+ skipChecks?: boolean;
100
+ skipPush?: boolean;
101
+ tag?: string;
102
+ image?: string;
103
+ platform?: string;
104
+ builder?: string;
105
+ verifyUrl?: string;
106
+ waitSeconds?: number;
107
+ token?: string;
108
+ username?: string;
109
+ password?: string;
110
+ }
111
+
112
+ export interface ITsDeployDeployStep {
113
+ name: string;
114
+ status: 'skipped' | 'passed' | 'failed';
115
+ message: string;
116
+ }
117
+
118
+ export interface ITsDeployCloudlyServiceSummary {
119
+ serviceId: string;
120
+ serviceName: string;
121
+ deployOnPush: boolean;
122
+ registryTarget?: {
123
+ registryHost?: string;
124
+ repository?: string;
125
+ tag?: string;
126
+ imageUrl?: string;
127
+ };
128
+ }
129
+
130
+ export interface ITsDeployDeploymentSummary {
131
+ deploymentId: string;
132
+ serviceId: string;
133
+ serviceName?: string;
134
+ status: string;
135
+ healthStatus?: string;
136
+ nodeName?: string;
137
+ version?: string;
138
+ containerId?: string;
139
+ deployedAt?: number;
140
+ updatedAt?: number;
141
+ }
142
+
143
+ export interface ITsDeployDeployResult {
144
+ schemaVersion: 1;
145
+ projectDir: string;
146
+ profile: string;
147
+ serviceId: string;
148
+ deploymentId?: string;
149
+ dryRun: boolean;
150
+ image: string;
151
+ tag: string;
152
+ platform: string;
153
+ pushed: boolean;
154
+ triggered: boolean;
155
+ verified: boolean;
156
+ digest?: string;
157
+ verifyStatus?: number;
158
+ service?: ITsDeployCloudlyServiceSummary;
159
+ deployments: ITsDeployDeploymentSummary[];
160
+ steps: ITsDeployDeployStep[];
161
+ warnings: string[];
162
+ }