@forgehive/forge-cli 0.2.13 → 0.2.14

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/dist/runner.js CHANGED
@@ -13,16 +13,18 @@ const info_1 = require("./tasks/conf/info");
13
13
  const createTask_1 = require("./tasks/task/createTask");
14
14
  const run_1 = require("./tasks/task/run");
15
15
  const remove_1 = require("./tasks/task/remove");
16
- const create_1 = require("./tasks/runner/create");
17
- const remove_2 = require("./tasks/runner/remove");
18
- const bundle_1 = require("./tasks/runner/bundle");
19
16
  const publish_1 = require("./tasks/task/publish");
20
17
  const download_1 = require("./tasks/task/download");
21
18
  const replay_1 = require("./tasks/task/replay");
19
+ const list_1 = require("./tasks/task/list");
20
+ const describe_1 = require("./tasks/task/describe");
21
+ const create_1 = require("./tasks/runner/create");
22
+ const remove_2 = require("./tasks/runner/remove");
23
+ const bundle_1 = require("./tasks/runner/bundle");
22
24
  const download_2 = require("./tasks/fixture/download");
23
25
  const add_1 = require("./tasks/auth/add");
24
26
  const switch_1 = require("./tasks/auth/switch");
25
- const list_1 = require("./tasks/auth/list");
27
+ const list_2 = require("./tasks/auth/list");
26
28
  const remove_3 = require("./tasks/auth/remove");
27
29
  const runner = new runner_1.Runner((data) => {
28
30
  const { _, ...filteredObj } = data;
@@ -42,6 +44,8 @@ runner.load('task:remove', remove_1.remove);
42
44
  runner.load('task:publish', publish_1.publish);
43
45
  runner.load('task:download', download_1.download);
44
46
  runner.load('task:replay', replay_1.replay);
47
+ runner.load('task:list', list_1.list);
48
+ runner.load('task:describe', describe_1.describe);
45
49
  // Runner commands
46
50
  runner.load('runner:create', create_1.create);
47
51
  runner.load('runner:remove', remove_2.remove);
@@ -51,7 +55,7 @@ runner.load('fixture:download', download_2.download);
51
55
  // Auth commands
52
56
  runner.load('auth:add', add_1.add);
53
57
  runner.load('auth:switch', switch_1.switchProfile);
54
- runner.load('auth:list', list_1.list);
58
+ runner.load('auth:list', list_2.list);
55
59
  runner.load('auth:remove', remove_3.remove);
56
60
  // Set handler
57
61
  runner.setHandler(async (data) => {
@@ -67,10 +71,9 @@ runner.setHandler(async (data) => {
67
71
  }
68
72
  try {
69
73
  let result;
70
- const commandsWithDescriptor = ['task:create', 'task:remove', 'task:publish'];
74
+ const commandsWithDescriptor = ['task:create', 'task:remove', 'task:publish', 'task:describe'];
71
75
  const commandsWithRunner = ['runner:create', 'runner:remove'];
72
76
  if (commandsWithDescriptor.includes(taskName)) {
73
- console.log('Running:', taskName, action);
74
77
  result = await task.run({ descriptorName: action });
75
78
  }
76
79
  else if (commandsWithRunner.includes(taskName)) {
@@ -131,6 +134,9 @@ runner.setHandler(async (data) => {
131
134
  else {
132
135
  result = await task.run(args);
133
136
  }
137
+ if (taskName === 'task:describe' || taskName === 'task:list') {
138
+ silent = true;
139
+ }
134
140
  return {
135
141
  silent,
136
142
  outcome: 'Success',
@@ -0,0 +1,35 @@
1
+ import { type ForgeConf } from '../types';
2
+ export declare const describe: import("@forgehive/task").TaskInstanceType<(argv: {
3
+ descriptorName: string;
4
+ }, boundaries: import("@forgehive/task").WrappedBoundaries<{
5
+ loadConf: (args: {}) => Promise<Promise<ForgeConf>>;
6
+ bundleCreate: (args: {
7
+ entryPoint: string;
8
+ outputFile: string;
9
+ }) => Promise<Promise<{
10
+ outputFile: string;
11
+ }>>;
12
+ bundleLoad: (args: {
13
+ bundlePath: string;
14
+ }) => Promise<Promise<any>>;
15
+ ensureBuildsFolder: () => Promise<string>;
16
+ }>) => Promise<{
17
+ name: string;
18
+ path: string;
19
+ handler: string;
20
+ description: any;
21
+ schema: any;
22
+ boundaries: string[];
23
+ }>, {
24
+ loadConf: (args: {}) => Promise<Promise<ForgeConf>>;
25
+ bundleCreate: (args: {
26
+ entryPoint: string;
27
+ outputFile: string;
28
+ }) => Promise<Promise<{
29
+ outputFile: string;
30
+ }>>;
31
+ bundleLoad: (args: {
32
+ bundlePath: string;
33
+ }) => Promise<Promise<any>>;
34
+ ensureBuildsFolder: () => Promise<string>;
35
+ }>;
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ // TASK: describe
3
+ // Run this task with:
4
+ // forge task:run task:describe
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.describe = void 0;
10
+ const path_1 = __importDefault(require("path"));
11
+ const os_1 = __importDefault(require("os"));
12
+ const promises_1 = __importDefault(require("fs/promises"));
13
+ const task_1 = require("@forgehive/task");
14
+ const schema_1 = require("@forgehive/schema");
15
+ const create_1 = require("../bundle/create");
16
+ const load_1 = require("../bundle/load");
17
+ const load_2 = require("../conf/load");
18
+ const description = 'Describe a task with detailed information about its schema, boundaries and configuration';
19
+ const schema = new schema_1.Schema({
20
+ descriptorName: schema_1.Schema.string()
21
+ });
22
+ const boundaries = {
23
+ loadConf: load_2.load.asBoundary(),
24
+ bundleCreate: create_1.create.asBoundary(),
25
+ bundleLoad: load_1.load.asBoundary(),
26
+ ensureBuildsFolder: async () => {
27
+ const buildsPath = path_1.default.join(os_1.default.homedir(), '.forge', 'builds');
28
+ try {
29
+ await promises_1.default.access(buildsPath);
30
+ }
31
+ catch {
32
+ await promises_1.default.mkdir(buildsPath, { recursive: true });
33
+ }
34
+ return buildsPath;
35
+ }
36
+ };
37
+ exports.describe = (0, task_1.createTask)(schema, boundaries, async function ({ descriptorName }, { loadConf, bundleCreate, bundleLoad, ensureBuildsFolder }) {
38
+ // Load forge configuration
39
+ const forge = await loadConf({});
40
+ const taskDescriptor = forge.tasks[descriptorName];
41
+ if (taskDescriptor === undefined) {
42
+ throw new Error(`Task "${descriptorName}" is not defined in forge.json`);
43
+ }
44
+ // Prepare paths
45
+ const entryPoint = path_1.default.join(process.cwd(), taskDescriptor.path);
46
+ const buildsPath = await ensureBuildsFolder();
47
+ const outputFile = path_1.default.join(buildsPath, `${descriptorName}.js`);
48
+ // Bundle the task
49
+ await bundleCreate({
50
+ entryPoint,
51
+ outputFile
52
+ });
53
+ // Load the bundled task
54
+ const bundle = await bundleLoad({
55
+ bundlePath: outputFile
56
+ });
57
+ // Get the task handler
58
+ const task = bundle[taskDescriptor.handler];
59
+ if (!task) {
60
+ throw new Error(`Handler "${taskDescriptor.handler}" not found in bundle`);
61
+ }
62
+ console.log('===============================================');
63
+ console.log(`Task: ${descriptorName}`);
64
+ console.log('===============================================');
65
+ console.log(`Path: ${taskDescriptor.path}`);
66
+ console.log(`Handler: ${taskDescriptor.handler}`);
67
+ // Get task description
68
+ const taskDescription = task.getDescription?.() || 'No description available';
69
+ console.log(`Description: ${taskDescription}`);
70
+ console.log('');
71
+ console.log('Schema:');
72
+ console.log('-------');
73
+ // Get schema information
74
+ const taskSchema = task.getSchema?.();
75
+ if (taskSchema && taskSchema.shape) {
76
+ const schemaKeys = Object.keys(taskSchema.shape);
77
+ if (schemaKeys.length === 0) {
78
+ console.log(' No schema parameters defined');
79
+ }
80
+ else {
81
+ schemaKeys.forEach(key => {
82
+ const field = taskSchema.shape[key];
83
+ const fieldType = field.type || 'unknown';
84
+ const fieldDescription = field.description || '';
85
+ if (fieldDescription) {
86
+ console.log(` • ${key} (${fieldType}): ${fieldDescription}`);
87
+ }
88
+ else {
89
+ console.log(` • ${key} (${fieldType})`);
90
+ }
91
+ });
92
+ }
93
+ }
94
+ else {
95
+ console.log(' No schema information available');
96
+ }
97
+ console.log('');
98
+ console.log('Boundaries:');
99
+ console.log('-----------');
100
+ // Get boundaries information
101
+ const taskBoundaries = task.getBoundaries?.();
102
+ if (taskBoundaries) {
103
+ const boundaryKeys = Object.keys(taskBoundaries);
104
+ if (boundaryKeys.length === 0) {
105
+ console.log(' No boundaries defined');
106
+ }
107
+ else {
108
+ boundaryKeys.forEach(boundaryName => {
109
+ console.log(` • ${boundaryName}`);
110
+ });
111
+ }
112
+ }
113
+ else {
114
+ console.log(' No boundary information available');
115
+ }
116
+ console.log('===============================================');
117
+ return {
118
+ name: descriptorName,
119
+ path: taskDescriptor.path,
120
+ handler: taskDescriptor.handler,
121
+ description: taskDescription,
122
+ schema: taskSchema?.shape || {},
123
+ boundaries: taskBoundaries ? Object.keys(taskBoundaries) : []
124
+ };
125
+ });
126
+ exports.describe.setDescription(description);
@@ -0,0 +1,12 @@
1
+ import { type ForgeConf } from '../types';
2
+ export declare const list: import("@forgehive/task").TaskInstanceType<(argv: {}, boundaries: import("@forgehive/task").WrappedBoundaries<{
3
+ loadConf: (args: {}) => Promise<Promise<ForgeConf>>;
4
+ }>) => Promise<{
5
+ taskCount: number;
6
+ tasks: never[];
7
+ } | {
8
+ taskCount: number;
9
+ tasks?: undefined;
10
+ }>, {
11
+ loadConf: (args: {}) => Promise<Promise<ForgeConf>>;
12
+ }>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ // TASK: list
3
+ // Run this task with:
4
+ // forge task:run task:list
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.list = void 0;
7
+ const task_1 = require("@forgehive/task");
8
+ const schema_1 = require("@forgehive/schema");
9
+ const load_1 = require("../conf/load");
10
+ const description = 'List all available tasks in the current project';
11
+ const schema = new schema_1.Schema({
12
+ // No arguments needed
13
+ });
14
+ const boundaries = {
15
+ loadConf: load_1.load.asBoundary()
16
+ };
17
+ exports.list = (0, task_1.createTask)(schema, boundaries, async function (argv, { loadConf }) {
18
+ // Load forge configuration
19
+ const forge = await loadConf({});
20
+ console.log('Available tasks:');
21
+ console.log('===============================================');
22
+ const tasks = forge.tasks;
23
+ const taskNames = Object.keys(tasks).sort();
24
+ if (taskNames.length === 0) {
25
+ console.log('No tasks found in forge.json');
26
+ return { taskCount: 0, tasks: [] };
27
+ }
28
+ // Find the longest task name for alignment
29
+ const maxNameLength = Math.max(...taskNames.map(name => name.length));
30
+ taskNames.forEach((taskName) => {
31
+ const task = tasks[taskName];
32
+ const paddedName = taskName.padEnd(maxNameLength + 1);
33
+ console.log(`• ${paddedName} - ${task.path}`);
34
+ });
35
+ console.log('===============================================');
36
+ console.log('Total tasks: ', taskNames.length);
37
+ console.log('===============================================');
38
+ return {
39
+ taskCount: taskNames.length
40
+ };
41
+ });
42
+ exports.list.setDescription(description);
File without changes
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ // Global test setup - mocks for problematic ES modules
3
+ // Mock archiver to avoid ES module issues
4
+ jest.mock('archiver', () => ({
5
+ __esModule: true,
6
+ default: jest.fn(() => ({
7
+ pipe: jest.fn(),
8
+ finalize: jest.fn(),
9
+ directory: jest.fn(),
10
+ file: jest.fn(),
11
+ on: jest.fn(),
12
+ pointer: jest.fn(() => 0)
13
+ }))
14
+ }));
package/forge.json CHANGED
@@ -89,6 +89,14 @@
89
89
  "bundle:zip": {
90
90
  "path": "src/tasks/bundle/zip.ts",
91
91
  "handler": "zip"
92
+ },
93
+ "task:list": {
94
+ "path": "src/tasks/task/list.ts",
95
+ "handler": "list"
96
+ },
97
+ "task:describe": {
98
+ "path": "src/tasks/task/describe.ts",
99
+ "handler": "describe"
92
100
  }
93
101
  },
94
102
  "runners": {}
package/jest.config.js CHANGED
@@ -3,7 +3,8 @@ module.exports = {
3
3
  preset: 'ts-jest',
4
4
  testEnvironment: 'node',
5
5
  testMatch: ['**/*.test.ts'],
6
+ setupFilesAfterEnv: ['<rootDir>/src/test/setup.ts'],
6
7
  transform: {
7
8
  '^.+\\.tsx?$': 'ts-jest',
8
9
  },
9
- };
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgehive/forge-cli",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "TypeScript CLI application",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "minimist": "^1.2.8",
29
29
  "@forgehive/record-tape": "0.1.6",
30
30
  "@forgehive/runner": "0.1.12",
31
- "@forgehive/task": "0.1.13",
32
- "@forgehive/schema": "0.1.4"
31
+ "@forgehive/schema": "0.1.4",
32
+ "@forgehive/task": "0.1.13"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/archiver": "^6.0.3",
package/src/runner.ts CHANGED
@@ -12,13 +12,15 @@ import { info } from './tasks/conf/info'
12
12
  import { createTaskCommand } from './tasks/task/createTask'
13
13
  import { run as taskRunCommand } from './tasks/task/run'
14
14
  import { remove as taskRemoveCommand } from './tasks/task/remove'
15
+ import { publish as publishTask } from './tasks/task/publish'
16
+ import { download as downloadTask } from './tasks/task/download'
17
+ import { replay as replayTask } from './tasks/task/replay'
18
+ import { list as listTasks } from './tasks/task/list'
19
+ import { describe as describeTask } from './tasks/task/describe'
15
20
 
16
21
  import { create as createRunner } from './tasks/runner/create'
17
22
  import { remove as removeRunner } from './tasks/runner/remove'
18
23
  import { bundle as bundleRunner } from './tasks/runner/bundle'
19
- import { publish as publishTask } from './tasks/task/publish'
20
- import { download as downloadTask } from './tasks/task/download'
21
- import { replay as replayTask } from './tasks/task/replay'
22
24
 
23
25
  import { download as downloadFixture } from './tasks/fixture/download'
24
26
 
@@ -52,6 +54,8 @@ runner.load('task:remove', taskRemoveCommand)
52
54
  runner.load('task:publish', publishTask)
53
55
  runner.load('task:download', downloadTask)
54
56
  runner.load('task:replay', replayTask)
57
+ runner.load('task:list', listTasks)
58
+ runner.load('task:describe', describeTask)
55
59
 
56
60
  // Runner commands
57
61
  runner.load('runner:create', createRunner)
@@ -85,11 +89,10 @@ runner.setHandler(async (data: ParsedArgs): Promise<unknown> => {
85
89
  try {
86
90
  let result
87
91
 
88
- const commandsWithDescriptor = ['task:create', 'task:remove', 'task:publish']
92
+ const commandsWithDescriptor = ['task:create', 'task:remove', 'task:publish', 'task:describe']
89
93
  const commandsWithRunner = ['runner:create', 'runner:remove']
90
94
 
91
95
  if (commandsWithDescriptor.includes(taskName)) {
92
- console.log('Running:', taskName, action)
93
96
  result = await task.run({ descriptorName: action })
94
97
  } else if (commandsWithRunner.includes(taskName)) {
95
98
  result = await task.run({
@@ -147,6 +150,10 @@ runner.setHandler(async (data: ParsedArgs): Promise<unknown> => {
147
150
  result = await task.run(args)
148
151
  }
149
152
 
153
+ if (taskName === 'task:describe' || taskName === 'task:list') {
154
+ silent = true
155
+ }
156
+
150
157
  return {
151
158
  silent,
152
159
  outcome: 'Success',
@@ -0,0 +1,148 @@
1
+ // TASK: describe
2
+ // Run this task with:
3
+ // forge task:run task:describe
4
+
5
+ import path from 'path'
6
+ import os from 'os'
7
+ import fs from 'fs/promises'
8
+
9
+ import { createTask } from '@forgehive/task'
10
+ import { Schema } from '@forgehive/schema'
11
+
12
+ import { create as bundleCreate } from '../bundle/create'
13
+ import { load as bundleLoad } from '../bundle/load'
14
+ import { load as loadConf } from '../conf/load'
15
+ import { type ForgeConf } from '../types'
16
+
17
+ const description = 'Describe a task with detailed information about its schema, boundaries and configuration'
18
+
19
+ const schema = new Schema({
20
+ descriptorName: Schema.string()
21
+ })
22
+
23
+ const boundaries = {
24
+ loadConf: loadConf.asBoundary(),
25
+ bundleCreate: bundleCreate.asBoundary(),
26
+ bundleLoad: bundleLoad.asBoundary(),
27
+ ensureBuildsFolder: async (): Promise<string> => {
28
+ const buildsPath = path.join(os.homedir(), '.forge', 'builds')
29
+ try {
30
+ await fs.access(buildsPath)
31
+ } catch {
32
+ await fs.mkdir(buildsPath, { recursive: true })
33
+ }
34
+
35
+ return buildsPath
36
+ }
37
+ }
38
+
39
+ export const describe = createTask(
40
+ schema,
41
+ boundaries,
42
+ async function ({ descriptorName }, {
43
+ loadConf,
44
+ bundleCreate,
45
+ bundleLoad,
46
+ ensureBuildsFolder
47
+ }) {
48
+ // Load forge configuration
49
+ const forge: ForgeConf = await loadConf({})
50
+ const taskDescriptor = forge.tasks[descriptorName as keyof typeof forge.tasks]
51
+
52
+ if (taskDescriptor === undefined) {
53
+ throw new Error(`Task "${descriptorName}" is not defined in forge.json`)
54
+ }
55
+
56
+ // Prepare paths
57
+ const entryPoint = path.join(process.cwd(), taskDescriptor.path)
58
+ const buildsPath = await ensureBuildsFolder()
59
+ const outputFile = path.join(buildsPath, `${descriptorName}.js`)
60
+
61
+ // Bundle the task
62
+ await bundleCreate({
63
+ entryPoint,
64
+ outputFile
65
+ })
66
+
67
+ // Load the bundled task
68
+ const bundle = await bundleLoad({
69
+ bundlePath: outputFile
70
+ })
71
+
72
+ // Get the task handler
73
+ const task = bundle[taskDescriptor.handler]
74
+
75
+ if (!task) {
76
+ throw new Error(`Handler "${taskDescriptor.handler}" not found in bundle`)
77
+ }
78
+
79
+ console.log('===============================================')
80
+ console.log(`Task: ${descriptorName}`)
81
+ console.log('===============================================')
82
+ console.log(`Path: ${taskDescriptor.path}`)
83
+ console.log(`Handler: ${taskDescriptor.handler}`)
84
+
85
+ // Get task description
86
+ const taskDescription = task.getDescription?.() || 'No description available'
87
+ console.log(`Description: ${taskDescription}`)
88
+
89
+ console.log('')
90
+ console.log('Schema:')
91
+ console.log('-------')
92
+
93
+ // Get schema information
94
+ const taskSchema = task.getSchema?.()
95
+ if (taskSchema && taskSchema.shape) {
96
+ const schemaKeys = Object.keys(taskSchema.shape)
97
+ if (schemaKeys.length === 0) {
98
+ console.log(' No schema parameters defined')
99
+ } else {
100
+ schemaKeys.forEach(key => {
101
+ const field = taskSchema.shape[key]
102
+ const fieldType = field.type || 'unknown'
103
+ const fieldDescription = field.description || ''
104
+
105
+ if (fieldDescription) {
106
+ console.log(` • ${key} (${fieldType}): ${fieldDescription}`)
107
+ } else {
108
+ console.log(` • ${key} (${fieldType})`)
109
+ }
110
+ })
111
+ }
112
+ } else {
113
+ console.log(' No schema information available')
114
+ }
115
+
116
+ console.log('')
117
+ console.log('Boundaries:')
118
+ console.log('-----------')
119
+
120
+ // Get boundaries information
121
+ const taskBoundaries = task.getBoundaries?.()
122
+ if (taskBoundaries) {
123
+ const boundaryKeys = Object.keys(taskBoundaries)
124
+ if (boundaryKeys.length === 0) {
125
+ console.log(' No boundaries defined')
126
+ } else {
127
+ boundaryKeys.forEach(boundaryName => {
128
+ console.log(` • ${boundaryName}`)
129
+ })
130
+ }
131
+ } else {
132
+ console.log(' No boundary information available')
133
+ }
134
+
135
+ console.log('===============================================')
136
+
137
+ return {
138
+ name: descriptorName,
139
+ path: taskDescriptor.path,
140
+ handler: taskDescriptor.handler,
141
+ description: taskDescription,
142
+ schema: taskSchema?.shape || {},
143
+ boundaries: taskBoundaries ? Object.keys(taskBoundaries) : []
144
+ }
145
+ }
146
+ )
147
+
148
+ describe.setDescription(description)
@@ -0,0 +1,58 @@
1
+ // TASK: list
2
+ // Run this task with:
3
+ // forge task:run task:list
4
+
5
+ import { createTask } from '@forgehive/task'
6
+ import { Schema } from '@forgehive/schema'
7
+
8
+ import { load as loadConf } from '../conf/load'
9
+ import { type ForgeConf } from '../types'
10
+
11
+ const description = 'List all available tasks in the current project'
12
+
13
+ const schema = new Schema({
14
+ // No arguments needed
15
+ })
16
+
17
+ const boundaries = {
18
+ loadConf: loadConf.asBoundary()
19
+ }
20
+
21
+ export const list = createTask(
22
+ schema,
23
+ boundaries,
24
+ async function (argv, { loadConf }) {
25
+ // Load forge configuration
26
+ const forge: ForgeConf = await loadConf({})
27
+
28
+ console.log('Available tasks:')
29
+ console.log('===============================================')
30
+
31
+ const tasks = forge.tasks
32
+ const taskNames = Object.keys(tasks).sort()
33
+
34
+ if (taskNames.length === 0) {
35
+ console.log('No tasks found in forge.json')
36
+ return { taskCount: 0, tasks: [] }
37
+ }
38
+
39
+ // Find the longest task name for alignment
40
+ const maxNameLength = Math.max(...taskNames.map(name => name.length))
41
+
42
+ taskNames.forEach((taskName) => {
43
+ const task = tasks[taskName]
44
+ const paddedName = taskName.padEnd(maxNameLength + 1)
45
+ console.log(`• ${paddedName} - ${task.path}`)
46
+ })
47
+
48
+ console.log('===============================================')
49
+ console.log('Total tasks: ', taskNames.length)
50
+ console.log('===============================================')
51
+
52
+ return {
53
+ taskCount: taskNames.length
54
+ }
55
+ }
56
+ )
57
+
58
+ list.setDescription(description)
@@ -0,0 +1,14 @@
1
+ // Global test setup - mocks for problematic ES modules
2
+
3
+ // Mock archiver to avoid ES module issues
4
+ jest.mock('archiver', () => ({
5
+ __esModule: true,
6
+ default: jest.fn(() => ({
7
+ pipe: jest.fn(),
8
+ finalize: jest.fn(),
9
+ directory: jest.fn(),
10
+ file: jest.fn(),
11
+ on: jest.fn(),
12
+ pointer: jest.fn(() => 0)
13
+ }))
14
+ }))
@@ -1,34 +0,0 @@
1
- import { TaskInstanceType, BaseFunction, Boundaries, ExecutionRecord, ReplayConfig } from '@forgehive/task';
2
- import { SchemaDescription } from '@forgehive/schema';
3
- /**
4
- * TaskAdapter wraps a TaskInstanceType to make it compatible with Runner
5
- * by handling boundary type issues
6
- */
7
- export declare class TaskAdapter<F extends BaseFunction, B extends Boundaries> {
8
- private task;
9
- constructor(task: TaskInstanceType<F, B>);
10
- get version(): string;
11
- getDescription(): string | undefined;
12
- describe(): SchemaDescription;
13
- run(argv?: Parameters<F>[0]): Promise<ReturnType<F>>;
14
- safeReplay(executionLog: ExecutionRecord<any, any, any>, config: ReplayConfig<any>): Promise<[ReturnType<F> | null, Error | null, ExecutionRecord<Parameters<F>[0], ReturnType<F>, B>]>;
15
- getMode(): import("@forgehive/task").Mode;
16
- setMode(mode: string): void;
17
- validate(argv?: any): any;
18
- isValid(argv?: any): boolean;
19
- addListener(fn: any): void;
20
- removeListener(): void;
21
- emit(data: any): void;
22
- asBoundary(): (args: Parameters<F>[0]) => Promise<ReturnType<F>>;
23
- getBoundaries(): import("@forgehive/task").WrappedBoundaries<B>;
24
- setBoundariesData(data: any): void;
25
- getBondariesData(): Record<string, unknown>;
26
- mockBoundary(name: any, mockFn: any): any;
27
- resetMock(name: any): any;
28
- resetMocks(): void;
29
- safeRun(argv?: Parameters<F>[0]): Promise<[ReturnType<F> | null, Error | null, ExecutionRecord<Parameters<F>[0], ReturnType<F>, B>]>;
30
- }
31
- /**
32
- * Helper function to adapt a task instance for Runner compatibility
33
- */
34
- export declare function adaptTask<F extends BaseFunction, B extends Boundaries>(task: TaskInstanceType<F, B>): TaskInstanceType;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaskAdapter = void 0;
4
- exports.adaptTask = adaptTask;
5
- /**
6
- * TaskAdapter wraps a TaskInstanceType to make it compatible with Runner
7
- * by handling boundary type issues
8
- */
9
- class TaskAdapter {
10
- constructor(task) {
11
- this.task = task;
12
- }
13
- // Forward all required methods to the underlying task
14
- get version() {
15
- return this.task.version;
16
- }
17
- getDescription() {
18
- return this.task.getDescription();
19
- }
20
- describe() {
21
- return this.task.describe();
22
- }
23
- async run(argv) {
24
- return this.task.run(argv);
25
- }
26
- // This is the problematic method with boundary type incompatibilities
27
- // Our implementation uses type assertions to make it compatible
28
- async safeReplay(executionLog, config) {
29
- // Type assertion to bridge the boundary type gap
30
- return this.task.safeReplay(executionLog, config);
31
- }
32
- // Forward other methods as needed
33
- getMode() {
34
- return this.task.getMode();
35
- }
36
- setMode(mode) {
37
- return this.task.setMode(mode);
38
- }
39
- validate(argv) {
40
- return this.task.validate(argv);
41
- }
42
- isValid(argv) {
43
- return this.task.isValid(argv);
44
- }
45
- addListener(fn) {
46
- return this.task.addListener(fn);
47
- }
48
- removeListener() {
49
- return this.task.removeListener();
50
- }
51
- emit(data) {
52
- return this.task.emit(data);
53
- }
54
- asBoundary() {
55
- return this.task.asBoundary();
56
- }
57
- getBoundaries() {
58
- return this.task.getBoundaries();
59
- }
60
- setBoundariesData(data) {
61
- return this.task.setBoundariesData(data);
62
- }
63
- getBondariesData() {
64
- return this.task.getBondariesData();
65
- }
66
- mockBoundary(name, mockFn) {
67
- return this.task.mockBoundary(name, mockFn);
68
- }
69
- resetMock(name) {
70
- return this.task.resetMock(name);
71
- }
72
- resetMocks() {
73
- return this.task.resetMocks();
74
- }
75
- async safeRun(argv) {
76
- return this.task.safeRun(argv);
77
- }
78
- }
79
- exports.TaskAdapter = TaskAdapter;
80
- /**
81
- * Helper function to adapt a task instance for Runner compatibility
82
- */
83
- function adaptTask(task) {
84
- return new TaskAdapter(task);
85
- }
@@ -1,23 +0,0 @@
1
- # Templates Directory
2
-
3
- This directory contains Handlebars templates used by the CLI to generate files.
4
-
5
- ## Templates
6
-
7
- - `task.hbs`: Template for generating new tasks
8
-
9
- ## Important Note
10
-
11
- These templates are copied to the `dist/templates` directory during the build process.
12
- This ensures that the templates are available when the CLI is installed and used in production.
13
-
14
- The build script in `package.json` includes a step to copy these templates:
15
-
16
- ```json
17
- "scripts": {
18
- "build": "tsc && npm run copy-templates",
19
- "copy-templates": "mkdir -p dist/templates && cp -r src/templates/* dist/templates/"
20
- }
21
- ```
22
-
23
- If you add new templates, make sure they are properly copied to the dist folder.
@@ -1,27 +0,0 @@
1
- // TASK: {{ taskName }}
2
- // Run this task with:
3
- // shadow-cli {{ taskDescriptor }}
4
-
5
- import { createTask } from '@shadow/task'
6
- import { Schema } from '@shadow/schema'
7
-
8
- const schema = new Schema({
9
- // Add your schema definitions here
10
- // example: myParam: Schema.string()
11
- })
12
-
13
- const boundaries = {
14
- // Add your boundary functions here
15
- // example: readFile: async (path: string) => fs.readFile(path, 'utf-8')
16
- }
17
-
18
- export const {{ taskName }} = createTask(
19
- schema,
20
- boundaries,
21
- async function (argv, boundaryFns) {
22
- // Your task implementation goes here
23
- const status = { status: 'Ok' }
24
-
25
- return status
26
- }
27
- )
@@ -1,2 +0,0 @@
1
- import { type WrappedBoundaryFunction } from '@forgehive/task';
2
- export declare const createBoundaryMock: () => WrappedBoundaryFunction;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createBoundaryMock = void 0;
4
- const createBoundaryMock = () => {
5
- const mockFn = jest.fn().mockResolvedValue(undefined);
6
- const boundaryMock = mockFn;
7
- // Add required methods to satisfy the interface
8
- boundaryMock.getTape = jest.fn().mockReturnValue([]);
9
- boundaryMock.setTape = jest.fn();
10
- boundaryMock.getMode = jest.fn().mockReturnValue('proxy');
11
- boundaryMock.setMode = jest.fn();
12
- boundaryMock.startRun = jest.fn();
13
- boundaryMock.stopRun = jest.fn();
14
- boundaryMock.getRunData = jest.fn().mockReturnValue([]);
15
- return boundaryMock;
16
- };
17
- exports.createBoundaryMock = createBoundaryMock;
@@ -1,4 +0,0 @@
1
- {"name":"auth:list","type":"success","input":{},"output":{"status":"Ok","profiles":[{"name":"local","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:4000"},{"name":"localNext","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:3000"}],"default":"localNext"},"boundaries":{"loadProfiles":[{"input":[{}],"output":{"default":"localNext","profiles":[{"name":"local","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:4000"},{"name":"localNext","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:3000"}]}},{"input":[{}],"output":{"default":"localNext","profiles":[{"name":"local","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:4000"},{"name":"localNext","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:3000"}]}}]}}
2
- {"name":"auth:list","type":"success","input":{},"output":{"status":"Ok","default":"localNext"},"boundaries":{"loadProfiles":[{"input":[{}],"output":{"default":"localNext","profiles":[{"name":"local","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:4000"},{"name":"localNext","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:3000"}]}}]}}
3
- {"name":"auth:list","type":"success","input":{},"output":{"default":"localNext"},"boundaries":{"loadProfiles":[{"input":[{}],"output":{"default":"localNext","profiles":[{"name":"local","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:4000"},{"name":"localNext","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:3000"}]}}]}}
4
- {"name":"auth:list","type":"success","input":{},"output":{"default":"localNext"},"boundaries":{"loadProfiles":[{"input":[{}],"output":{"default":"localNext","profiles":[{"name":"local","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:4000"},{"name":"localNext","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:3000"}]}}]}}
@@ -1,2 +0,0 @@
1
- {"name":"auth:load","type":"error","input":{},"error":"ENOENT: no such file or directory, open '/Users/danielzavaladlvega/.forge/profiles.json'","boundaries":{"ensureBuildsFolder":[{"input":[],"output":"/Users/danielzavaladlvega/.forge"},{"input":[],"output":"/Users/danielzavaladlvega/.forge"}]}}
2
- {"name":"auth:load","type":"success","input":{},"output":{"profiles":[]},"boundaries":{"ensureBuildsFolder":[{"input":[],"output":"/Users/danielzavaladlvega/.forge"}]}}
@@ -1 +0,0 @@
1
- {"name":"auth:loadCurrent","type":"success","input":{},"output":{"name":"local","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:4000"},"boundaries":{"loadProfiles":[{"input":[{}],"output":{"default":"local","profiles":[{"name":"local","apiKey":"b4b5a766fcd7dc2d059e8f96a57c8edd","apiSecret":"2900246cb8bebcbeaadbe6348477592f42d62788d13fd4067588438bc11bf116","url":"http://localhost:4000"}]}}]}}
@@ -1,2 +0,0 @@
1
- {"name":"conf:info","type":"error","input":{},"error":"ENOENT: no such file or directory, open '/Users/package.json'","boundaries":{"readFile":[{"input":["/Users/package.json"],"error":"ENOENT: no such file or directory, open '/Users/package.json'"},{"input":["/Users/package.json"],"error":"ENOENT: no such file or directory, open '/Users/package.json'"}],"loadCurrentProfile":[]}}
2
- {"name":"conf:info","type":"error","input":{"name":"foobar"},"error":"ENOENT: no such file or directory, open '/Users/package.json'","boundaries":{"readFile":[{"input":["/Users/package.json"],"error":"ENOENT: no such file or directory, open '/Users/package.json'"}],"loadCurrentProfile":[]}}
@@ -1,4 +0,0 @@
1
- {"name":"runner:create","type":"success","input":{},"output":{"status":"Ok"},"boundaries":{}}
2
- {"name":"runner:create","type":"success","input":{"runnerName":"inventory"},"output":{},"boundaries":{"loadConf":[{"input":[{}],"output":{"project":{"name":"forge-cli"},"paths":{"logs":"logs/","tasks":"src/tasks/","runners":"src/runners/","fixtures":"src/tests/fixtures","tests":"src/tests/"},"infra":{"region":"us-west-2","bucket":""},"tasks":{"bundle:create":{"path":"src/tasks/bundle/create.ts","handler":"create"},"bundle:load":{"path":"src/tasks/bundle/load.ts","handler":"load"},"task:run":{"path":"src/tasks/task/run.ts","handler":"run"},"task:remove":{"path":"src/tasks/task/remove.ts","handler":"remove"},"conf:info":{"path":"src/tasks/conf/info.ts","handler":"info"},"runner:create":{"path":"src/tasks/runner/create.ts","handler":"create"}},"runners":{}}},{"input":[{}],"output":{"project":{"name":"forge-cli"},"paths":{"logs":"logs/","tasks":"src/tasks/","runners":"src/runners/","fixtures":"src/tests/fixtures","tests":"src/tests/"},"infra":{"region":"us-west-2","bucket":""},"tasks":{"bundle:create":{"path":"src/tasks/bundle/create.ts","handler":"create"},"bundle:load":{"path":"src/tasks/bundle/load.ts","handler":"load"},"task:run":{"path":"src/tasks/task/run.ts","handler":"run"},"task:remove":{"path":"src/tasks/task/remove.ts","handler":"remove"},"conf:info":{"path":"src/tasks/conf/info.ts","handler":"info"},"runner:create":{"path":"src/tasks/runner/create.ts","handler":"create"}},"runners":{}}}],"getCwd":[{"input":[],"output":"/Users/danielzavaladlvega/forgehive/mono/apps/cli"},{"input":[],"output":"/Users/danielzavaladlvega/forgehive/mono/apps/cli"}],"persistRunner":[],"persistConf":[]}}
3
- {"name":"runner:create","type":"success","input":{"runnerName":"inventory"},"output":{},"boundaries":{"loadConf":[{"input":[{}],"output":{"project":{"name":"forge-cli"},"paths":{"logs":"logs/","tasks":"src/tasks/","runners":"src/runners/","fixtures":"src/tests/fixtures","tests":"src/tests/"},"infra":{"region":"us-west-2","bucket":""},"tasks":{"bundle:create":{"path":"src/tasks/bundle/create.ts","handler":"create"},"bundle:load":{"path":"src/tasks/bundle/load.ts","handler":"load"},"task:run":{"path":"src/tasks/task/run.ts","handler":"run"},"task:remove":{"path":"src/tasks/task/remove.ts","handler":"remove"},"conf:info":{"path":"src/tasks/conf/info.ts","handler":"info"},"runner:create":{"path":"src/tasks/runner/create.ts","handler":"create"}},"runners":{}}}],"getCwd":[{"input":[],"output":"/Users/danielzavaladlvega/forgehive/mono/apps/cli"}],"persistRunner":[],"persistConf":[]}}
4
- {"name":"runner:create","type":"error","input":{},"error":"Invalid input on: runnerName: Required","boundaries":{"loadConf":[],"getCwd":[],"persistRunner":[],"persistConf":[]}}