MCPcopy
hub / github.com/msgbyte/tianji / handler

Function handler

packages/cli/src/commands/worker/deploy.ts:26–154  ·  view source on GitHub ↗
(
  argv: Arguments<DeployOptions>
)

Source from the content-addressed store, hash-verified

24};
25
26export const handler = async (
27 argv: Arguments<DeployOptions>
28): Promise<void> => {
29 console.log(chalk.cyan('\n📦 Deploying Tianji Worker...\n'));
30
31 try {
32 // Check if user is logged in
33 if (!(await isLoggedIn())) {
34 console.error(
35 chalk.red(
36 'Error: Not logged in. Please run "tianji worker login" first.\n'
37 )
38 );
39 process.exit(1);
40 }
41
42 // Load global config
43 const globalConfig = await loadGlobalConfig();
44 if (!globalConfig) {
45 console.error(
46 chalk.red(
47 'Error: Configuration not found. Please run "tianji worker login" first.\n'
48 )
49 );
50 process.exit(1);
51 }
52
53 // Load project config
54 const projectConfig = await loadProjectConfig();
55 if (!projectConfig) {
56 console.error(
57 chalk.red(
58 'Error: .tianjirc not found. Make sure you are in a Tianji Worker project directory.\n'
59 )
60 );
61 process.exit(1);
62 }
63
64 const projectName = projectConfig.name || 'tianji-worker';
65 const workerId = projectConfig.workerId;
66
67 // Check if package.json exists
68 const packageJsonPath = path.join(process.cwd(), 'package.json');
69 if (!(await fs.pathExists(packageJsonPath))) {
70 console.error(
71 chalk.red(
72 'Error: package.json not found. Are you in the project root directory?\n'
73 )
74 );
75 process.exit(1);
76 }
77
78 // Check if node_modules exists
79 const nodeModulesPath = path.join(process.cwd(), 'node_modules');
80 if (!(await fs.pathExists(nodeModulesPath))) {
81 console.error(
82 chalk.red(
83 'Error: node_modules not found. Please run "npm install" first.\n'

Callers

nothing calls this directly

Calls 9

isLoggedInFunction · 0.85
loadGlobalConfigFunction · 0.85
loadProjectConfigFunction · 0.85
createAPIClientFunction · 0.85
saveProjectConfigFunction · 0.85
logMethod · 0.80
errorMethod · 0.80
startMethod · 0.80
upsertWorkerMethod · 0.80

Tested by

no test coverage detected