@forgehive/forge-cli 0.3.14 → 0.3.15

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.
@@ -7,10 +7,10 @@ export declare const invoke: import("@forgehive/task").TaskInstanceType<(argv: {
7
7
  loadConf: (args: {}) => Promise<Promise<ForgeConf>>;
8
8
  loadCurrentProfile: (args: {}) => Promise<Promise<Profile>>;
9
9
  parseJSON: (jsonString: string) => Promise<unknown>;
10
- invokeTask: (projectUuid: string, profile: Profile, taskName: string, payload: unknown) => Promise<InvokeResult | null>;
10
+ invokeTask: (projectUuid: string, taskUuid: string, profile: Profile, taskName: string, payload: unknown) => Promise<InvokeResult | null>;
11
11
  }>) => Promise<unknown>, {
12
12
  loadConf: (args: {}) => Promise<Promise<ForgeConf>>;
13
13
  loadCurrentProfile: (args: {}) => Promise<Promise<Profile>>;
14
14
  parseJSON: (jsonString: string) => Promise<unknown>;
15
- invokeTask: (projectUuid: string, profile: Profile, taskName: string, payload: unknown) => Promise<InvokeResult | null>;
15
+ invokeTask: (projectUuid: string, taskUuid: string, profile: Profile, taskName: string, payload: unknown) => Promise<InvokeResult | null>;
16
16
  }>;
@@ -26,17 +26,17 @@ const boundaries = {
26
26
  throw new Error(`Invalid JSON: ${error instanceof Error ? error.message : 'Unknown error'}`);
27
27
  }
28
28
  },
29
- invokeTask: async (projectUuid, profile, taskName, payload) => {
29
+ invokeTask: async (projectUuid, taskUuid, profile, taskName, payload) => {
30
30
  const client = (0, hive_sdk_1.createHiveClient)({
31
31
  projectUuid,
32
32
  apiKey: profile.apiKey,
33
33
  apiSecret: profile.apiSecret,
34
34
  host: profile.url
35
35
  });
36
- console.log(`Invoking task: ${taskName}`);
36
+ console.log(`Invoking task: ${taskName} (${taskUuid})`);
37
37
  console.log('Payload:', payload);
38
38
  console.log(`Using profile: ${profile.name} (${profile.url})`);
39
- return await client.invoke(taskName, payload);
39
+ return await client.invoke(taskUuid, payload);
40
40
  }
41
41
  };
42
42
  exports.invoke = (0, task_1.createTask)({
@@ -51,10 +51,13 @@ exports.invoke = (0, task_1.createTask)({
51
51
  if (taskDescriptor === undefined) {
52
52
  throw new Error(`Task "${descriptorName}" is not defined in forge.json`);
53
53
  }
54
- // Check for project UUID
54
+ // Check for required UUIDs
55
55
  if (!forge.project.uuid) {
56
56
  throw new Error('Project UUID is not defined in forge.json. Please ensure your project has a UUID.');
57
57
  }
58
+ if (!taskDescriptor.uuid) {
59
+ throw new Error(`Task "${descriptorName}" does not have a UUID in forge.json. Please ensure your task has a UUID.`);
60
+ }
58
61
  // Load profile (required for invoke)
59
62
  let profile;
60
63
  try {
@@ -66,7 +69,7 @@ exports.invoke = (0, task_1.createTask)({
66
69
  // Parse the JSON payload
67
70
  const payload = await parseJSON(json);
68
71
  // Invoke the task using the boundary
69
- const result = await invokeTask(forge.project.uuid, profile, descriptorName, payload);
72
+ const result = await invokeTask(forge.project.uuid, taskDescriptor.uuid, profile, descriptorName, payload);
70
73
  if ((0, hive_sdk_1.isInvokeError)(result)) {
71
74
  throw new Error(`Task invocation failed: ${result.error}`);
72
75
  }
@@ -47,7 +47,7 @@ export declare const publish: import("@forgehive/task").TaskInstanceType<(argv:
47
47
  }>>;
48
48
  readFileUtf8: (filePath: string) => Promise<string>;
49
49
  readFileBinary: (filePath: string) => Promise<Buffer>;
50
- publishTask: (data: Record<string, unknown>, profile: Profile) => Promise<{
50
+ publishTask: (projectUuid: string, taskUuid: string, data: Record<string, unknown>, profile: Profile) => Promise<{
51
51
  bundleUploadUrl?: string;
52
52
  }>;
53
53
  uploadBundleWithPresignedUrl: (presignedUrl: string, bundleContent: Buffer) => Promise<boolean>;
@@ -101,7 +101,7 @@ export declare const publish: import("@forgehive/task").TaskInstanceType<(argv:
101
101
  }>>;
102
102
  readFileUtf8: (filePath: string) => Promise<string>;
103
103
  readFileBinary: (filePath: string) => Promise<Buffer>;
104
- publishTask: (data: Record<string, unknown>, profile: Profile) => Promise<{
104
+ publishTask: (projectUuid: string, taskUuid: string, data: Record<string, unknown>, profile: Profile) => Promise<{
105
105
  bundleUploadUrl?: string;
106
106
  }>;
107
107
  uploadBundleWithPresignedUrl: (presignedUrl: string, bundleContent: Buffer) => Promise<boolean>;
@@ -38,8 +38,8 @@ const boundaries = {
38
38
  readFileBinary: async (filePath) => {
39
39
  return promises_1.default.readFile(filePath);
40
40
  },
41
- publishTask: async (data, profile) => {
42
- const publishUrl = `${profile.url}/api/tasks/publish`;
41
+ publishTask: async (projectUuid, taskUuid, data, profile) => {
42
+ const publishUrl = `${profile.url}/api/projects/${projectUuid}/tasks/${taskUuid}/publish`;
43
43
  const authToken = `${profile.apiKey}:${profile.apiSecret}`;
44
44
  try {
45
45
  const response = await axios_1.default.post(publishUrl, data, {
@@ -91,6 +91,13 @@ exports.publish = (0, task_1.createTask)({
91
91
  if (taskDescriptor === undefined) {
92
92
  throw new Error('Task is not defined on forge.json');
93
93
  }
94
+ // Check for required UUIDs
95
+ if (!forgeJson.project.uuid) {
96
+ throw new Error('Project UUID is not defined in forge.json. Please ensure your project has a UUID.');
97
+ }
98
+ if (!taskDescriptor.uuid) {
99
+ throw new Error(`Task "${descriptorName}" does not have a UUID in forge.json. Please ensure your task has a UUID.`);
100
+ }
94
101
  const entryPoint = path_1.default.join(cwd, taskDescriptor.path);
95
102
  const buildsPath = await ensureBuildsFolder();
96
103
  const outputFile = path_1.default.join(buildsPath, `${descriptorName}.js`);
@@ -158,7 +165,7 @@ exports.publish = (0, task_1.createTask)({
158
165
  };
159
166
  // Publish metadata to hive api server
160
167
  console.log(`Publishing metadata and source code to ${profile.url}...`);
161
- const publishResponse = await publishTask(data, profile);
168
+ const publishResponse = await publishTask(forgeJson.project.uuid, taskDescriptor.uuid, data, profile);
162
169
  // Upload zipped bundle using the presigned URL
163
170
  if (publishResponse.bundleUploadUrl) {
164
171
  console.log('Uploading zipped bundle...');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgehive/forge-cli",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "description": "TypeScript CLI application",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -10,7 +10,7 @@
10
10
  "publishConfig": {
11
11
  "access": "public",
12
12
  "dependencies": {
13
- "@forgehive/hive-sdk": "^0.1.4",
13
+ "@forgehive/hive-sdk": "^0.1.5",
14
14
  "@forgehive/record-tape": "^0.2.6",
15
15
  "@forgehive/runner": "^0.2.6",
16
16
  "@forgehive/schema": "^0.1.4",
@@ -30,11 +30,11 @@
30
30
  "minimist": "^1.2.8",
31
31
  "typescript": "^5.3.3",
32
32
  "uuid": "^11.1.0",
33
- "@forgehive/record-tape": "0.2.6",
34
- "@forgehive/hive-sdk": "0.1.4",
35
33
  "@forgehive/schema": "0.1.4",
36
- "@forgehive/runner": "0.2.6",
37
- "@forgehive/task": "0.2.6"
34
+ "@forgehive/task": "0.2.6",
35
+ "@forgehive/hive-sdk": "0.1.5",
36
+ "@forgehive/record-tape": "0.2.6",
37
+ "@forgehive/runner": "0.2.6"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/archiver": "^6.0.3",
@@ -30,6 +30,7 @@ const boundaries = {
30
30
  },
31
31
  invokeTask: async (
32
32
  projectUuid: string,
33
+ taskUuid: string,
33
34
  profile: Profile,
34
35
  taskName: string,
35
36
  payload: unknown
@@ -41,11 +42,11 @@ const boundaries = {
41
42
  host: profile.url
42
43
  })
43
44
 
44
- console.log(`Invoking task: ${taskName}`)
45
+ console.log(`Invoking task: ${taskName} (${taskUuid})`)
45
46
  console.log('Payload:', payload)
46
47
  console.log(`Using profile: ${profile.name} (${profile.url})`)
47
48
 
48
- return await client.invoke(taskName, payload)
49
+ return await client.invoke(taskUuid, payload)
49
50
  }
50
51
  }
51
52
 
@@ -63,11 +64,15 @@ export const invoke = createTask({
63
64
  throw new Error(`Task "${descriptorName}" is not defined in forge.json`)
64
65
  }
65
66
 
66
- // Check for project UUID
67
+ // Check for required UUIDs
67
68
  if (!forge.project.uuid) {
68
69
  throw new Error('Project UUID is not defined in forge.json. Please ensure your project has a UUID.')
69
70
  }
70
71
 
72
+ if (!taskDescriptor.uuid) {
73
+ throw new Error(`Task "${descriptorName}" does not have a UUID in forge.json. Please ensure your task has a UUID.`)
74
+ }
75
+
71
76
  // Load profile (required for invoke)
72
77
  let profile: Profile
73
78
  try {
@@ -80,7 +85,7 @@ export const invoke = createTask({
80
85
  const payload = await parseJSON(json)
81
86
 
82
87
  // Invoke the task using the boundary
83
- const result = await invokeTask(forge.project.uuid, profile, descriptorName, payload)
88
+ const result = await invokeTask(forge.project.uuid, taskDescriptor.uuid, profile, descriptorName, payload)
84
89
 
85
90
  if (isInvokeError(result)) {
86
91
  throw new Error(`Task invocation failed: ${result.error}`)
@@ -39,8 +39,13 @@ const boundaries = {
39
39
  readFileBinary: async (filePath: string): Promise<Buffer> => {
40
40
  return fs.readFile(filePath)
41
41
  },
42
- publishTask: async (data: Record<string, unknown>, profile: Profile): Promise<{ bundleUploadUrl?: string }> => {
43
- const publishUrl = `${profile.url}/api/tasks/publish`
42
+ publishTask: async (
43
+ projectUuid: string,
44
+ taskUuid: string,
45
+ data: Record<string, unknown>,
46
+ profile: Profile
47
+ ): Promise<{ bundleUploadUrl?: string }> => {
48
+ const publishUrl = `${profile.url}/api/projects/${projectUuid}/tasks/${taskUuid}/publish`
44
49
  const authToken = `${profile.apiKey}:${profile.apiSecret}`
45
50
 
46
51
  try {
@@ -112,6 +117,15 @@ export const publish = createTask({
112
117
  throw new Error('Task is not defined on forge.json')
113
118
  }
114
119
 
120
+ // Check for required UUIDs
121
+ if (!forgeJson.project.uuid) {
122
+ throw new Error('Project UUID is not defined in forge.json. Please ensure your project has a UUID.')
123
+ }
124
+
125
+ if (!taskDescriptor.uuid) {
126
+ throw new Error(`Task "${descriptorName}" does not have a UUID in forge.json. Please ensure your task has a UUID.`)
127
+ }
128
+
115
129
  const entryPoint = path.join(cwd, taskDescriptor.path)
116
130
  const buildsPath = await ensureBuildsFolder()
117
131
  const outputFile = path.join(buildsPath, `${descriptorName}.js`)
@@ -190,7 +204,7 @@ export const publish = createTask({
190
204
 
191
205
  // Publish metadata to hive api server
192
206
  console.log(`Publishing metadata and source code to ${profile.url}...`)
193
- const publishResponse = await publishTask(data, profile)
207
+ const publishResponse = await publishTask(forgeJson.project.uuid, taskDescriptor.uuid, data, profile)
194
208
 
195
209
  // Upload zipped bundle using the presigned URL
196
210
  if (publishResponse.bundleUploadUrl) {