@forgehive/forge-cli 0.2.14 → 0.3.1

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.
Files changed (67) hide show
  1. package/dist/runner.js +3 -1
  2. package/dist/tasks/auth/add.js +23 -19
  3. package/dist/tasks/auth/list.js +20 -16
  4. package/dist/tasks/auth/load.js +19 -15
  5. package/dist/tasks/auth/loadCurrent.js +13 -9
  6. package/dist/tasks/auth/remove.js +30 -26
  7. package/dist/tasks/auth/switch.js +19 -15
  8. package/dist/tasks/bundle/create.js +16 -12
  9. package/dist/tasks/bundle/fingerprint.d.ts +36 -0
  10. package/dist/tasks/bundle/fingerprint.js +164 -0
  11. package/dist/tasks/bundle/load.js +9 -5
  12. package/dist/tasks/bundle/zip.js +49 -45
  13. package/dist/tasks/conf/info.js +23 -19
  14. package/dist/tasks/conf/load.js +8 -4
  15. package/dist/tasks/fixture/download.js +40 -36
  16. package/dist/tasks/init.js +35 -31
  17. package/dist/tasks/runner/bundle.js +34 -30
  18. package/dist/tasks/runner/create.js +28 -24
  19. package/dist/tasks/runner/remove.js +22 -18
  20. package/dist/tasks/task/createTask.js +35 -28
  21. package/dist/tasks/task/describe.js +85 -81
  22. package/dist/tasks/task/download.js +63 -59
  23. package/dist/tasks/task/fingerprint.d.ts +26 -0
  24. package/dist/tasks/task/fingerprint.js +87 -0
  25. package/dist/tasks/task/list.js +27 -23
  26. package/dist/tasks/task/publish.js +72 -68
  27. package/dist/tasks/task/remove.js +24 -20
  28. package/dist/tasks/task/replay.js +94 -90
  29. package/dist/tasks/task/run.js +78 -79
  30. package/dist/test/tasks/create.test.js +6 -5
  31. package/dist/utils/taskAnalysis.d.ts +21 -0
  32. package/dist/utils/taskAnalysis.js +380 -0
  33. package/forge.json +12 -0
  34. package/logs/task:fingerprint.log +10 -0
  35. package/package.json +7 -7
  36. package/specs/fingerprint.md +380 -0
  37. package/src/runner.ts +3 -1
  38. package/src/tasks/README.md +13 -13
  39. package/src/tasks/auth/add.ts +3 -3
  40. package/src/tasks/auth/list.ts +3 -3
  41. package/src/tasks/auth/load.ts +3 -3
  42. package/src/tasks/auth/loadCurrent.ts +3 -3
  43. package/src/tasks/auth/remove.ts +3 -3
  44. package/src/tasks/auth/switch.ts +3 -3
  45. package/src/tasks/bundle/README.md +7 -7
  46. package/src/tasks/bundle/create.ts +4 -4
  47. package/src/tasks/bundle/fingerprint.ts +218 -0
  48. package/src/tasks/bundle/load.ts +4 -4
  49. package/src/tasks/bundle/zip.ts +3 -3
  50. package/src/tasks/conf/info.ts +3 -3
  51. package/src/tasks/conf/load.ts +3 -3
  52. package/src/tasks/fixture/download.ts +3 -3
  53. package/src/tasks/init.ts +3 -3
  54. package/src/tasks/runner/bundle.ts +3 -3
  55. package/src/tasks/runner/create.ts +3 -3
  56. package/src/tasks/runner/remove.ts +3 -3
  57. package/src/tasks/task/createTask.ts +10 -7
  58. package/src/tasks/task/describe.ts +3 -3
  59. package/src/tasks/task/download.ts +3 -3
  60. package/src/tasks/task/fingerprint.ts +107 -0
  61. package/src/tasks/task/list.ts +3 -3
  62. package/src/tasks/task/publish.ts +3 -3
  63. package/src/tasks/task/remove.ts +3 -3
  64. package/src/tasks/task/replay.ts +3 -3
  65. package/src/tasks/task/run.ts +12 -18
  66. package/src/test/tasks/create.test.ts +9 -9
  67. package/src/utils/taskAnalysis.ts +419 -0
@@ -43,54 +43,58 @@ const bytesToMB = (bytes) => {
43
43
  return `${MB.toFixed(2)} MB`;
44
44
  };
45
45
  exports.bytesToMB = bytesToMB;
46
- exports.zip = (0, task_1.createTask)(schema, boundaries, async function ({ dir, input, output }, { createWriteStream, createArchiver, resolvePathDir, fileExists }) {
47
- const outputPath = await resolvePathDir(dir, output);
48
- const inputPath = await resolvePathDir(dir, input);
49
- const inputMapPath = inputPath + '.map';
50
- // Check if input file exists
51
- const inputExists = await fileExists(inputPath);
52
- if (!inputExists) {
53
- throw new Error(`Input file does not exist: ${inputPath}`);
54
- }
55
- // Check if source map exists before creating Promise
56
- const mapExists = await fileExists(inputMapPath);
57
- // Handle async operations outside of Promise constructor
58
- const outStream = await createWriteStream(outputPath);
59
- const archive = await createArchiver('zip', {
60
- zlib: { level: 9 } // Sets the compression level
61
- });
62
- return new Promise((resolve, reject) => {
63
- archive.on('error', function (err) {
64
- reject(err);
65
- });
66
- outStream.on('end', function () {
67
- console.log('Data has been drained');
68
- });
69
- outStream.on('close', function () {
70
- setTimeout(() => {
71
- resolve({
72
- output,
73
- outputPath,
74
- size: archive.pointer()
75
- });
76
- }, 100);
46
+ exports.zip = (0, task_1.createTask)({
47
+ schema,
48
+ boundaries,
49
+ fn: async function ({ dir, input, output }, { createWriteStream, createArchiver, resolvePathDir, fileExists }) {
50
+ const outputPath = await resolvePathDir(dir, output);
51
+ const inputPath = await resolvePathDir(dir, input);
52
+ const inputMapPath = inputPath + '.map';
53
+ // Check if input file exists
54
+ const inputExists = await fileExists(inputPath);
55
+ if (!inputExists) {
56
+ throw new Error(`Input file does not exist: ${inputPath}`);
57
+ }
58
+ // Check if source map exists before creating Promise
59
+ const mapExists = await fileExists(inputMapPath);
60
+ // Handle async operations outside of Promise constructor
61
+ const outStream = await createWriteStream(outputPath);
62
+ const archive = await createArchiver('zip', {
63
+ zlib: { level: 9 } // Sets the compression level
77
64
  });
78
- archive.on('warning', function (err) {
79
- if (err.code === 'ENOENT') {
80
- console.warn('ENOENT', err);
81
- }
82
- else {
65
+ return new Promise((resolve, reject) => {
66
+ archive.on('error', function (err) {
83
67
  reject(err);
68
+ });
69
+ outStream.on('end', function () {
70
+ console.log('Data has been drained');
71
+ });
72
+ outStream.on('close', function () {
73
+ setTimeout(() => {
74
+ resolve({
75
+ output,
76
+ outputPath,
77
+ size: archive.pointer()
78
+ });
79
+ }, 100);
80
+ });
81
+ archive.on('warning', function (err) {
82
+ if (err.code === 'ENOENT') {
83
+ console.warn('ENOENT', err);
84
+ }
85
+ else {
86
+ reject(err);
87
+ }
88
+ });
89
+ archive.pipe(outStream);
90
+ // Add the main bundle file
91
+ archive.file(inputPath, { name: 'index.js' });
92
+ // Add source map if it exists
93
+ if (mapExists) {
94
+ archive.file(inputMapPath, { name: 'index.js.map' });
84
95
  }
96
+ archive.finalize();
85
97
  });
86
- archive.pipe(outStream);
87
- // Add the main bundle file
88
- archive.file(inputPath, { name: 'index.js' });
89
- // Add source map if it exists
90
- if (mapExists) {
91
- archive.file(inputMapPath, { name: 'index.js.map' });
92
- }
93
- archive.finalize();
94
- });
98
+ }
95
99
  });
96
100
  exports.zip.setDescription(description);
@@ -47,25 +47,29 @@ const boundaries = {
47
47
  readFile: async (filePath) => fs.promises.readFile(filePath, 'utf-8'),
48
48
  loadCurrentProfile: loadCurrent_1.loadCurrent.asBoundary()
49
49
  };
50
- exports.info = (0, task_1.createTask)(schema, boundaries, async function (_argv, { loadCurrentProfile, readFile }) {
51
- const packageJsonPath = path.join(__dirname, '../../../package.json');
52
- const packageJsonContent = await readFile(packageJsonPath);
53
- const packageJson = JSON.parse(packageJsonContent);
54
- const info = {
55
- version: packageJson.version,
56
- profile: {}
57
- };
58
- let profile;
59
- try {
60
- profile = await loadCurrentProfile({});
61
- info.profile = {
62
- name: profile.name,
63
- url: profile.url,
64
- apiKey: profile.apiKey
50
+ exports.info = (0, task_1.createTask)({
51
+ schema,
52
+ boundaries,
53
+ fn: async function (_argv, { loadCurrentProfile, readFile }) {
54
+ const packageJsonPath = path.join(__dirname, '../../../package.json');
55
+ const packageJsonContent = await readFile(packageJsonPath);
56
+ const packageJson = JSON.parse(packageJsonContent);
57
+ const info = {
58
+ version: packageJson.version,
59
+ profile: {}
65
60
  };
61
+ let profile;
62
+ try {
63
+ profile = await loadCurrentProfile({});
64
+ info.profile = {
65
+ name: profile.name,
66
+ url: profile.url,
67
+ apiKey: profile.apiKey
68
+ };
69
+ }
70
+ catch (error) {
71
+ console.log('No default profile set. Please run forge task:run auth:add to create a profile.');
72
+ }
73
+ return info;
66
74
  }
67
- catch (error) {
68
- console.log('No default profile set. Please run forge task:run auth:add to create a profile.');
69
- }
70
- return info;
71
75
  });
@@ -14,8 +14,12 @@ const boundaries = {
14
14
  return await promises_1.default.readFile(filePath, 'utf-8');
15
15
  }
16
16
  };
17
- exports.load = (0, task_1.createTask)(schema, boundaries, async function (_, { readFile }) {
18
- const forgePath = path_1.default.join(process.cwd(), 'forge.json');
19
- const content = await readFile(forgePath);
20
- return JSON.parse(content);
17
+ exports.load = (0, task_1.createTask)({
18
+ schema,
19
+ boundaries,
20
+ fn: async function (_, { readFile }) {
21
+ const forgePath = path_1.default.join(process.cwd(), 'forge.json');
22
+ const content = await readFile(forgePath);
23
+ return JSON.parse(content);
24
+ }
21
25
  });
@@ -45,38 +45,41 @@ const boundaries = {
45
45
  };
46
46
  }
47
47
  };
48
- exports.download = (0, task_1.createTask)(schema, boundaries, async function ({ uuid }, { downloadFixture, getCwd, persistFixture, loadCurrentProfile, loadConf }) {
49
- console.log('==================================================');
50
- console.log(`Attempting to download fixture with uuid: ${uuid}`);
51
- console.log('==================================================');
52
- const profile = await loadCurrentProfile({});
53
- const cwd = await getCwd();
54
- const forge = await loadConf({});
55
- // Download from hive api server first to get the task descriptor
56
- let response;
57
- try {
58
- response = await downloadFixture(uuid, profile);
59
- }
60
- catch (e) {
61
- const error = e;
62
- console.error('Error downloading fixture:', error.message, error.status);
63
- if (error.status === 404) {
64
- throw new Error('Fixture not found');
48
+ exports.download = (0, task_1.createTask)({
49
+ schema,
50
+ boundaries,
51
+ fn: async function ({ uuid }, { downloadFixture, getCwd, persistFixture, loadCurrentProfile, loadConf }) {
52
+ console.log('==================================================');
53
+ console.log(`Attempting to download fixture with uuid: ${uuid}`);
54
+ console.log('==================================================');
55
+ const profile = await loadCurrentProfile({});
56
+ const cwd = await getCwd();
57
+ const forge = await loadConf({});
58
+ // Download from hive api server first to get the task descriptor
59
+ let response;
60
+ try {
61
+ response = await downloadFixture(uuid, profile);
65
62
  }
66
- throw new Error('Failed to download fixture');
67
- }
68
- const fixture = response.fixture;
69
- const taskName = fixture.taskName;
70
- // Determine the output path using forge fixtures path and task descriptor
71
- const fixturesBasePath = forge.paths.fixtures || 'fixtures';
72
- const fixtureDir = path_1.default.join(fixturesBasePath, taskName);
73
- const fixturePath = path_1.default.join(fixtureDir, `${uuid}.json`);
74
- const filePath = path_1.default.resolve(cwd, fixturePath);
75
- // Persist fixture to file
76
- await persistFixture(filePath, response.fixture);
77
- // Get the relative path for display in the replay command
78
- const shortPath = path_1.default.join(taskName, `${uuid}.json`);
79
- console.log(`
63
+ catch (e) {
64
+ const error = e;
65
+ console.error('Error downloading fixture:', error.message, error.status);
66
+ if (error.status === 404) {
67
+ throw new Error('Fixture not found');
68
+ }
69
+ throw new Error('Failed to download fixture');
70
+ }
71
+ const fixture = response.fixture;
72
+ const taskName = fixture.taskName;
73
+ // Determine the output path using forge fixtures path and task descriptor
74
+ const fixturesBasePath = forge.paths.fixtures || 'fixtures';
75
+ const fixtureDir = path_1.default.join(fixturesBasePath, taskName);
76
+ const fixturePath = path_1.default.join(fixtureDir, `${uuid}.json`);
77
+ const filePath = path_1.default.resolve(cwd, fixturePath);
78
+ // Persist fixture to file
79
+ await persistFixture(filePath, response.fixture);
80
+ // Get the relative path for display in the replay command
81
+ const shortPath = path_1.default.join(taskName, `${uuid}.json`);
82
+ console.log(`
80
83
  ==================================================
81
84
  Fixture download completed!
82
85
  ==================================================
@@ -90,10 +93,11 @@ Replay with:
90
93
  forge task:replay ${taskName} --path ${shortPath}
91
94
  ==================================================
92
95
  `);
93
- return {
94
- status: 'Downloaded',
95
- path: filePath,
96
- shortPath: shortPath
97
- };
96
+ return {
97
+ status: 'Downloaded',
98
+ path: filePath,
99
+ shortPath: shortPath
100
+ };
101
+ }
98
102
  });
99
103
  exports.download.setDescription(description);
@@ -20,36 +20,40 @@ const boundaries = {
20
20
  }
21
21
  };
22
22
  // Create a task with type inference from schema and boundaries
23
- exports.init = (0, task_1.createTask)(schema, boundaries, async function (argv, { saveFile, getCwd }) {
24
- // Handle the dryRun flag
25
- const isDryRun = Boolean(argv.dryRun);
26
- const cwd = await getCwd();
27
- const forgePath = path_1.default.join(cwd, 'forge.json');
28
- const config = {
29
- project: {
30
- name: 'BaseProject'
31
- },
32
- paths: {
33
- logs: 'logs/',
34
- fixtures: 'fixtures/',
35
- tasks: 'src/tasks/',
36
- runners: 'src/runners/',
37
- tests: 'src/tests/'
38
- },
39
- infra: {
40
- region: 'us-west-2',
41
- bucket: ''
42
- },
43
- tasks: {},
44
- runners: {}
45
- };
46
- const content = JSON.stringify(config, null, 2);
47
- if (!isDryRun) {
48
- await saveFile(forgePath, content);
23
+ exports.init = (0, task_1.createTask)({
24
+ schema,
25
+ boundaries,
26
+ fn: async function (argv, { saveFile, getCwd }) {
27
+ // Handle the dryRun flag
28
+ const isDryRun = Boolean(argv.dryRun);
29
+ const cwd = await getCwd();
30
+ const forgePath = path_1.default.join(cwd, 'forge.json');
31
+ const config = {
32
+ project: {
33
+ name: 'BaseProject'
34
+ },
35
+ paths: {
36
+ logs: 'logs/',
37
+ fixtures: 'fixtures/',
38
+ tasks: 'src/tasks/',
39
+ runners: 'src/runners/',
40
+ tests: 'src/tests/'
41
+ },
42
+ infra: {
43
+ region: 'us-west-2',
44
+ bucket: ''
45
+ },
46
+ tasks: {},
47
+ runners: {}
48
+ };
49
+ const content = JSON.stringify(config, null, 2);
50
+ if (!isDryRun) {
51
+ await saveFile(forgePath, content);
52
+ }
53
+ else {
54
+ console.log('Dry run, not creating forge.json');
55
+ console.log(content);
56
+ }
57
+ return config;
49
58
  }
50
- else {
51
- console.log('Dry run, not creating forge.json');
52
- console.log(content);
53
- }
54
- return config;
55
59
  });
@@ -31,19 +31,22 @@ const boundaries = {
31
31
  }
32
32
  }
33
33
  };
34
- exports.bundle = (0, task_1.createTask)(schema, boundaries, async function ({ runnerName, targetPath }, { loadConf, getCwd, ensureDir }) {
35
- // Load forge configuration
36
- const forge = await loadConf({});
37
- const cwd = await getCwd();
38
- // Verify runner exists in forge.json
39
- if (!forge.runners || !forge.runners[runnerName]) {
40
- throw new Error(`Runner '${runnerName}' not found in forge.json configuration`);
41
- }
42
- // Get runner entry point from forge.json
43
- const runnerConfig = forge.runners[runnerName];
44
- const entryPoint = path_1.default.join(cwd, runnerConfig.path);
45
- const outputFile = path_1.default.join(targetPath, `${runnerName}.js`);
46
- console.log(`
34
+ exports.bundle = (0, task_1.createTask)({
35
+ schema,
36
+ boundaries,
37
+ fn: async function ({ runnerName, targetPath }, { loadConf, getCwd, ensureDir }) {
38
+ // Load forge configuration
39
+ const forge = await loadConf({});
40
+ const cwd = await getCwd();
41
+ // Verify runner exists in forge.json
42
+ if (!forge.runners || !forge.runners[runnerName]) {
43
+ throw new Error(`Runner '${runnerName}' not found in forge.json configuration`);
44
+ }
45
+ // Get runner entry point from forge.json
46
+ const runnerConfig = forge.runners[runnerName];
47
+ const entryPoint = path_1.default.join(cwd, runnerConfig.path);
48
+ const outputFile = path_1.default.join(targetPath, `${runnerName}.js`);
49
+ console.log(`
47
50
  ==================================================
48
51
  Starting runner creation!
49
52
  Creating runner: ${runnerName}
@@ -51,21 +54,22 @@ exports.bundle = (0, task_1.createTask)(schema, boundaries, async function ({ ru
51
54
  Output file: ${outputFile}
52
55
  ==================================================
53
56
  `);
54
- // Ensure target directory exists
55
- await ensureDir(path_1.default.dirname(targetPath));
56
- // Build using esbuild
57
- await esbuild_1.default.build({
58
- entryPoints: [entryPoint],
59
- outfile: outputFile,
60
- bundle: true,
61
- minify: true,
62
- platform: 'node',
63
- sourcemap: true
64
- });
65
- return {
66
- status: 'Success',
67
- runnerName,
68
- entryPoint,
69
- outputFile: path_1.default.join(targetPath, `${runnerName}.js`)
70
- };
57
+ // Ensure target directory exists
58
+ await ensureDir(path_1.default.dirname(targetPath));
59
+ // Build using esbuild
60
+ await esbuild_1.default.build({
61
+ entryPoints: [entryPoint],
62
+ outfile: outputFile,
63
+ bundle: true,
64
+ minify: true,
65
+ platform: 'node',
66
+ sourcemap: true
67
+ });
68
+ return {
69
+ status: 'Success',
70
+ runnerName,
71
+ entryPoint,
72
+ outputFile: path_1.default.join(targetPath, `${runnerName}.js`)
73
+ };
74
+ }
71
75
  });
@@ -63,35 +63,39 @@ const boundaries = {
63
63
  await promises_1.default.writeFile(forgePath, JSON.stringify(forge, null, 2));
64
64
  }
65
65
  };
66
- exports.create = (0, task_1.createTask)(schema, boundaries, async function ({ runnerName }, { persistRunner, loadConf, persistConf, getCwd }) {
67
- const formattedName = (0, camelCase_1.camelCase)(runnerName);
68
- const cwd = await getCwd();
69
- const forge = await loadConf({});
70
- const runnerPath = forge.paths.runners;
71
- console.log(`
66
+ exports.create = (0, task_1.createTask)({
67
+ schema,
68
+ boundaries,
69
+ fn: async function ({ runnerName }, { persistRunner, loadConf, persistConf, getCwd }) {
70
+ const formattedName = (0, camelCase_1.camelCase)(runnerName);
71
+ const cwd = await getCwd();
72
+ const forge = await loadConf({});
73
+ const runnerPath = forge.paths.runners;
74
+ console.log(`
72
75
  ==================================================
73
76
  Starting runner creation!
74
77
  Creating runner: ${formattedName}
75
78
  Into: ${runnerPath}${formattedName}/index.ts
76
79
  ==================================================
77
80
  `);
78
- const comp = handlebars_1.default.compile(RUNNER_TEMPLATE);
79
- const content = comp({
80
- runnerName: formattedName
81
- });
82
- await persistRunner(runnerPath, formattedName, content);
83
- if (forge.runners === undefined) {
84
- forge.runners = {};
81
+ const comp = handlebars_1.default.compile(RUNNER_TEMPLATE);
82
+ const content = comp({
83
+ runnerName: formattedName
84
+ });
85
+ await persistRunner(runnerPath, formattedName, content);
86
+ if (forge.runners === undefined) {
87
+ forge.runners = {};
88
+ }
89
+ // Create runner descriptor
90
+ const runnerDescriptor = {
91
+ path: `${runnerPath}${formattedName}/index.ts`,
92
+ version: '0.0.1'
93
+ };
94
+ forge.runners[formattedName] = runnerDescriptor;
95
+ await persistConf(forge, cwd);
96
+ return {
97
+ runnerPath: `${runnerPath}/${formattedName}`,
98
+ runnerName: formattedName
99
+ };
85
100
  }
86
- // Create runner descriptor
87
- const runnerDescriptor = {
88
- path: `${runnerPath}${formattedName}/index.ts`,
89
- version: '0.0.1'
90
- };
91
- forge.runners[formattedName] = runnerDescriptor;
92
- await persistConf(forge, cwd);
93
- return {
94
- runnerPath: `${runnerPath}/${formattedName}`,
95
- runnerName: formattedName
96
- };
97
101
  });
@@ -32,27 +32,31 @@ const boundaries = {
32
32
  await promises_1.default.writeFile(forgePath, JSON.stringify(forge, null, 2));
33
33
  }
34
34
  };
35
- exports.remove = (0, task_1.createTask)(schema, boundaries, async function ({ runnerName }, { loadConf, getCwd, removeRunner, persistConf }) {
36
- const formattedName = (0, camelCase_1.camelCase)(runnerName);
37
- const cwd = await getCwd();
38
- const forge = await loadConf({});
39
- if (!forge.runners || !forge.runners[formattedName]) {
40
- throw new Error(`Runner '${formattedName}' not found in forge.json configuration`);
41
- }
42
- const runnerConfig = forge.runners[formattedName];
43
- const runnerFolder = path_1.default.join(cwd, path_1.default.dirname(runnerConfig.path));
44
- console.log(`
35
+ exports.remove = (0, task_1.createTask)({
36
+ schema,
37
+ boundaries,
38
+ fn: async function ({ runnerName }, { loadConf, getCwd, removeRunner, persistConf }) {
39
+ const formattedName = (0, camelCase_1.camelCase)(runnerName);
40
+ const cwd = await getCwd();
41
+ const forge = await loadConf({});
42
+ if (!forge.runners || !forge.runners[formattedName]) {
43
+ throw new Error(`Runner '${formattedName}' not found in forge.json configuration`);
44
+ }
45
+ const runnerConfig = forge.runners[formattedName];
46
+ const runnerFolder = path_1.default.join(cwd, path_1.default.dirname(runnerConfig.path));
47
+ console.log(`
45
48
  ==================================================
46
49
  Removing runner: ${formattedName}
47
50
  Path: ${runnerFolder}
48
51
  ==================================================
49
52
  `);
50
- await removeRunner(runnerFolder);
51
- delete forge.runners[formattedName];
52
- await persistConf(forge, cwd);
53
- return {
54
- status: 'success',
55
- message: `Runner '${formattedName}' successfully removed`,
56
- runnerName: formattedName
57
- };
53
+ await removeRunner(runnerFolder);
54
+ delete forge.runners[formattedName];
55
+ await persistConf(forge, cwd);
56
+ return {
57
+ status: 'success',
58
+ message: `Runner '${formattedName}' successfully removed`,
59
+ runnerName: formattedName
60
+ };
61
+ }
58
62
  });
@@ -20,6 +20,7 @@ const TASK_TEMPLATE = `// TASK: {{ taskName }}
20
20
  import { createTask } from '@forgehive/task'
21
21
  import { Schema } from '@forgehive/schema'
22
22
 
23
+ const name = '{{ taskDescriptor }}'
23
24
  const description = 'Add task description here'
24
25
 
25
26
  const schema = new Schema({
@@ -32,10 +33,12 @@ const boundaries = {
32
33
  // example: readFile: async (path: string) => fs.readFile(path, 'utf-8')
33
34
  }
34
35
 
35
- export const {{ taskName }} = createTask(
36
+ export const {{ taskName }} = createTask({
37
+ name,
38
+ description,
36
39
  schema,
37
40
  boundaries,
38
- async function (argv, boundaries) {
41
+ fn: async function (argv, boundaries) {
39
42
  console.log('input:', argv)
40
43
  console.log('boundaries:', boundaries)
41
44
  // Your task implementation goes here
@@ -43,9 +46,8 @@ export const {{ taskName }} = createTask(
43
46
 
44
47
  return status
45
48
  }
46
- )
49
+ })
47
50
 
48
- {{ taskName }}.setDescription(description)
49
51
  `;
50
52
  const schema = new schema_1.Schema({
51
53
  descriptorName: schema_1.Schema.string()
@@ -100,36 +102,41 @@ const boundaries = {
100
102
  await promises_1.default.writeFile(forgePath, JSON.stringify(forge, null, 2));
101
103
  }
102
104
  };
103
- exports.createTaskCommand = (0, task_1.createTask)(schema, boundaries, async function ({ descriptorName }, { loadTemplate, persistTask, loadConf, persistConf, parseTaskName, getCwd }) {
104
- const { taskName, fileName, descriptor, dir } = await parseTaskName(descriptorName);
105
- const cwd = await getCwd();
106
- const forge = await loadConf({});
107
- let taskPath = forge.paths.tasks;
108
- if (dir !== undefined) {
109
- taskPath = path_1.default.join(taskPath, dir);
110
- }
111
- console.log(`
105
+ exports.createTaskCommand = (0, task_1.createTask)({
106
+ schema,
107
+ boundaries,
108
+ fn: async function ({ descriptorName }, { loadTemplate, persistTask, loadConf, persistConf, parseTaskName, getCwd }) {
109
+ const { taskName, fileName, descriptor, dir } = await parseTaskName(descriptorName);
110
+ const cwd = await getCwd();
111
+ const forge = await loadConf({});
112
+ let taskPath = forge.paths.tasks;
113
+ if (dir !== undefined) {
114
+ taskPath = path_1.default.join(taskPath, dir);
115
+ }
116
+ console.log(`
112
117
  ==================================================
113
118
  Starting task creation!
114
119
  Creating: ${taskName}
120
+ Descriptor: ${descriptor}
115
121
  Dir: ${dir ?? ''}
116
122
  Into: ${taskPath}
117
123
  ==================================================
118
124
  `);
119
- const template = await loadTemplate();
120
- const comp = handlebars_1.default.compile(template);
121
- const content = comp({
122
- taskName,
123
- taskDescriptor: descriptor
124
- });
125
- await persistTask(taskPath, fileName, content, cwd);
126
- if (forge.tasks === undefined) {
127
- forge.tasks = {};
125
+ const template = await loadTemplate();
126
+ const comp = handlebars_1.default.compile(template);
127
+ const content = comp({
128
+ taskName,
129
+ taskDescriptor: descriptor
130
+ });
131
+ await persistTask(taskPath, fileName, content, cwd);
132
+ if (forge.tasks === undefined) {
133
+ forge.tasks = {};
134
+ }
135
+ forge.tasks[descriptor] = {
136
+ path: `${taskPath}/${fileName}`,
137
+ handler: taskName
138
+ };
139
+ await persistConf(forge, cwd);
140
+ return { taskPath, fileName };
128
141
  }
129
- forge.tasks[descriptor] = {
130
- path: `${taskPath}/${fileName}`,
131
- handler: taskName
132
- };
133
- await persistConf(forge, cwd);
134
- return { taskPath, fileName };
135
142
  });