@git.zone/tsdeploy 0.2.0 → 0.4.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,26 @@ 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
+ allowDirty: getBooleanArgByKeys(argvArg, ['allowDirty', 'allow-dirty']),
120
+ skipChecks: getBooleanArgByKeys(argvArg, ['skipChecks', 'skip-checks']),
121
+ skipPush: getBooleanArgByKeys(argvArg, ['skipPush', 'skip-push']),
122
+ tag: getStringArg(argvArg, 'tag'),
123
+ image: getStringArg(argvArg, 'image'),
124
+ platform: getStringArg(argvArg, 'platform'),
125
+ builder: getStringArg(argvArg, 'builder'),
126
+ verifyUrl: getStringArgByKeys(argvArg, ['verifyUrl', 'verify-url']),
127
+ waitSeconds: getNumberArgByKeys(argvArg, ['waitSeconds', 'wait-seconds']),
128
+ token: getStringArg(argvArg, 'token'),
129
+ username: getStringArg(argvArg, 'username'),
130
+ password: getStringArg(argvArg, 'password'),
131
+ });
132
+ printJson(result);
133
+ };
134
+
81
135
  const printHelp = (): void => {
82
136
  console.log(`
83
137
  Usage: tsdeploy <command> [options]
@@ -89,10 +143,13 @@ Commands:
89
143
  status
90
144
  doctor
91
145
  plan
146
+ deploy [--dryRun] [--allowDirty] [--skipChecks] [--skipPush] [--tag <tag>] [--platform <platform>] [--builder <name>]
147
+ [--verifyUrl <url>] [--waitSeconds <seconds>] [--token <token>]
92
148
 
93
149
  Notes:
94
150
  tsdeploy stores only the project pointer in .nogit/tsdeploy.json.
95
- Remote deployment mutations are disabled until Cloudly/Onebox APIs are verified.
151
+ Cloudly workload deployment builds and pushes the linked OCI image after validating deployOnPush.
152
+ Onebox deployment mutations are not implemented yet.
96
153
  `);
97
154
  };
98
155
 
@@ -112,6 +169,7 @@ export const runCli = async (): Promise<void> => {
112
169
  cli.addCommand('status').subscribe(runStatus);
113
170
  cli.addCommand('doctor').subscribe(runDoctor);
114
171
  cli.addCommand('plan').subscribe(runPlan);
172
+ cli.addCommand('deploy').subscribe(runDeploy);
115
173
  cli.addCommand('help').subscribe(async () => printHelp());
116
174
  cli.startParse(getSmartcliArgv());
117
175
  };
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,88 @@ 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
+ allowDirty?: boolean;
100
+ skipChecks?: boolean;
101
+ skipPush?: boolean;
102
+ tag?: string;
103
+ image?: string;
104
+ platform?: string;
105
+ builder?: string;
106
+ verifyUrl?: string;
107
+ waitSeconds?: number;
108
+ token?: string;
109
+ username?: string;
110
+ password?: string;
111
+ }
112
+
113
+ export interface ITsDeployDeployStep {
114
+ name: string;
115
+ status: 'skipped' | 'passed' | 'failed';
116
+ message: string;
117
+ }
118
+
119
+ export interface ITsDeployCloudlyServiceSummary {
120
+ serviceId: string;
121
+ serviceName: string;
122
+ deployOnPush: boolean;
123
+ registryTarget?: {
124
+ registryHost?: string;
125
+ repository?: string;
126
+ tag?: string;
127
+ imageUrl?: string;
128
+ };
129
+ }
130
+
131
+ export interface ITsDeployDeploymentSummary {
132
+ deploymentId: string;
133
+ serviceId: string;
134
+ serviceName?: string;
135
+ status: string;
136
+ healthStatus?: string;
137
+ nodeName?: string;
138
+ version?: string;
139
+ containerId?: string;
140
+ deployedAt?: number;
141
+ updatedAt?: number;
142
+ }
143
+
144
+ export interface ITsDeployDeployResult {
145
+ schemaVersion: 1;
146
+ projectDir: string;
147
+ profile: string;
148
+ serviceId: string;
149
+ deploymentId?: string;
150
+ dryRun: boolean;
151
+ image: string;
152
+ tag: string;
153
+ platform: string;
154
+ pushed: boolean;
155
+ triggered: boolean;
156
+ verified: boolean;
157
+ digest?: string;
158
+ verifyStatus?: number;
159
+ service?: ITsDeployCloudlyServiceSummary;
160
+ deployments: ITsDeployDeploymentSummary[];
161
+ steps: ITsDeployDeployStep[];
162
+ warnings: string[];
163
+ }