@forgehive/forge-cli 0.3.15 → 0.3.17

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.
@@ -1,6 +1,11 @@
1
+ import { type ForgeConf } from '../types';
1
2
  export declare const create: import("@forgehive/task").TaskInstanceType<(argv: {
2
3
  entryPoint: string;
3
4
  outputFile: string;
4
- }, boundaries: import("@forgehive/task").WrappedBoundaries<{}>) => Promise<{
5
+ }, boundaries: import("@forgehive/task").WrappedBoundaries<{
6
+ loadConf: (args: {}) => Promise<Promise<ForgeConf>>;
7
+ }>) => Promise<{
5
8
  outputFile: string;
6
- }>, {}>;
9
+ }>, {
10
+ loadConf: (args: {}) => Promise<Promise<ForgeConf>>;
11
+ }>;
@@ -10,15 +10,22 @@ exports.create = void 0;
10
10
  const task_1 = require("@forgehive/task");
11
11
  const schema_1 = require("@forgehive/schema");
12
12
  const esbuild_1 = __importDefault(require("esbuild"));
13
+ const load_1 = require("../conf/load");
13
14
  const schema = new schema_1.Schema({
14
15
  entryPoint: schema_1.Schema.string(),
15
16
  outputFile: schema_1.Schema.string()
16
17
  });
17
- const boundaries = {};
18
+ const boundaries = {
19
+ loadConf: load_1.load.asBoundary()
20
+ };
18
21
  exports.create = (0, task_1.createTask)({
19
22
  schema,
20
23
  boundaries,
21
- fn: async function ({ entryPoint, outputFile }) {
24
+ fn: async function ({ entryPoint, outputFile }, { loadConf }) {
25
+ // Load forge configuration
26
+ const forge = await loadConf({});
27
+ // Get external packages from config, default to empty array
28
+ const externalPackages = forge.build?.externalPackages ?? [];
22
29
  // Build using esbuild
23
30
  await esbuild_1.default.build({
24
31
  entryPoints: [entryPoint],
@@ -26,7 +33,8 @@ exports.create = (0, task_1.createTask)({
26
33
  bundle: true,
27
34
  minify: true,
28
35
  platform: 'node',
29
- sourcemap: true
36
+ sourcemap: true,
37
+ external: externalPackages
30
38
  });
31
39
  return { outputFile };
32
40
  }
@@ -122,6 +122,8 @@ exports.fingerprint = (0, task_1.createTask)({
122
122
  console.log(`Generating bundle with fingerprints for task: ${descriptorName}`);
123
123
  console.log(`Entry point: ${entryPoint}`);
124
124
  console.log(`Output: ${outputFile}`);
125
+ // Get external packages from config, default to empty array
126
+ const externalPackages = forgeJson.build?.externalPackages ?? [];
125
127
  // Build with fingerprinting plugin
126
128
  const result = await esbuild_1.default.build({
127
129
  entryPoints: [entryPoint],
@@ -131,7 +133,8 @@ exports.fingerprint = (0, task_1.createTask)({
131
133
  platform: 'node',
132
134
  sourcemap: true,
133
135
  plugins: [taskFingerprintPlugin()],
134
- metafile: true
136
+ metafile: true,
137
+ external: externalPackages
135
138
  });
136
139
  // Extract fingerprints from build result
137
140
  const taskFingerprints = result.fingerprints || [];
@@ -5,6 +5,7 @@ export declare const zip: import("@forgehive/task").TaskInstanceType<(argv: {
5
5
  dir: string;
6
6
  input: string;
7
7
  output: string;
8
+ forgeJsonPath?: string | undefined;
8
9
  }, boundaries: import("@forgehive/task").WrappedBoundaries<{
9
10
  createWriteStream: (outputPath: string) => Promise<fs.WriteStream>;
10
11
  createArchiver: (format: "zip", options: {
@@ -16,7 +16,8 @@ const description = 'Zip a bundle file for distribution';
16
16
  const schema = new schema_1.Schema({
17
17
  dir: schema_1.Schema.string(),
18
18
  input: schema_1.Schema.string(),
19
- output: schema_1.Schema.string()
19
+ output: schema_1.Schema.string(),
20
+ forgeJsonPath: schema_1.Schema.string().optional() // Optional path to forge.json - if provided, it will be included
20
21
  });
21
22
  const boundaries = {
22
23
  createWriteStream: async (outputPath) => {
@@ -36,7 +37,7 @@ const boundaries = {
36
37
  catch {
37
38
  return false;
38
39
  }
39
- }
40
+ },
40
41
  };
41
42
  const bytesToMB = (bytes) => {
42
43
  const MB = bytes / (1024 * 1024);
@@ -46,7 +47,7 @@ exports.bytesToMB = bytesToMB;
46
47
  exports.zip = (0, task_1.createTask)({
47
48
  schema,
48
49
  boundaries,
49
- fn: async function ({ dir, input, output }, { createWriteStream, createArchiver, resolvePathDir, fileExists }) {
50
+ fn: async function ({ dir, input, output, forgeJsonPath }, { createWriteStream, createArchiver, resolvePathDir, fileExists }) {
50
51
  const outputPath = await resolvePathDir(dir, output);
51
52
  const inputPath = await resolvePathDir(dir, input);
52
53
  const inputMapPath = inputPath + '.map';
@@ -57,6 +58,17 @@ exports.zip = (0, task_1.createTask)({
57
58
  }
58
59
  // Check if source map exists before creating Promise
59
60
  const mapExists = await fileExists(inputMapPath);
61
+ // Handle forge.json inclusion - only if path is provided
62
+ let finalForgeJsonPath = null;
63
+ if (forgeJsonPath) {
64
+ const exists = await fileExists(forgeJsonPath);
65
+ if (exists) {
66
+ finalForgeJsonPath = forgeJsonPath;
67
+ }
68
+ else {
69
+ console.warn(`forge.json not found at provided path: ${forgeJsonPath}`);
70
+ }
71
+ }
60
72
  // Handle async operations outside of Promise constructor
61
73
  const outStream = await createWriteStream(outputPath);
62
74
  const archive = await createArchiver('zip', {
@@ -93,6 +105,11 @@ exports.zip = (0, task_1.createTask)({
93
105
  if (mapExists) {
94
106
  archive.file(inputMapPath, { name: 'index.js.map' });
95
107
  }
108
+ // Add forge.json if path was provided and found
109
+ if (finalForgeJsonPath) {
110
+ archive.file(finalForgeJsonPath, { name: 'forge.json' });
111
+ console.log(`Added forge.json from: ${finalForgeJsonPath}`);
112
+ }
96
113
  archive.finalize();
97
114
  });
98
115
  }
@@ -56,6 +56,8 @@ exports.bundle = (0, task_1.createTask)({
56
56
  `);
57
57
  // Ensure target directory exists
58
58
  await ensureDir(path_1.default.dirname(targetPath));
59
+ // Get external packages from config, default to empty array
60
+ const externalPackages = forge.build?.externalPackages ?? [];
59
61
  // Build using esbuild
60
62
  await esbuild_1.default.build({
61
63
  entryPoints: [entryPoint],
@@ -63,7 +65,8 @@ exports.bundle = (0, task_1.createTask)({
63
65
  bundle: true,
64
66
  minify: true,
65
67
  platform: 'node',
66
- sourcemap: true
68
+ sourcemap: true,
69
+ external: externalPackages
67
70
  });
68
71
  return {
69
72
  status: 'Success',
@@ -19,6 +19,7 @@ export declare const publish: import("@forgehive/task").TaskInstanceType<(argv:
19
19
  dir: string;
20
20
  input: string;
21
21
  output: string;
22
+ forgeJsonPath?: string | undefined;
22
23
  }) => Promise<Promise<unknown>>;
23
24
  bundleFingerprint: (args: {
24
25
  descriptorName: string;
@@ -73,6 +74,7 @@ export declare const publish: import("@forgehive/task").TaskInstanceType<(argv:
73
74
  dir: string;
74
75
  input: string;
75
76
  output: string;
77
+ forgeJsonPath?: string | undefined;
76
78
  }) => Promise<Promise<unknown>>;
77
79
  bundleFingerprint: (args: {
78
80
  descriptorName: string;
@@ -108,11 +108,12 @@ exports.publish = (0, task_1.createTask)({
108
108
  outputFile
109
109
  });
110
110
  console.log('Bundle created...');
111
- // Zip the bundle
111
+ // Zip the bundle with forge.json included
112
112
  await bundleZip({
113
113
  dir: buildsPath,
114
114
  input: `${descriptorName}.js`,
115
- output: zipFile
115
+ output: zipFile,
116
+ forgeJsonPath: path_1.default.join(cwd, 'forge.json')
116
117
  });
117
118
  console.log('Bundle zipped...');
118
119
  // Generate task fingerprint
@@ -31,6 +31,9 @@ export interface ForgeConf {
31
31
  infra: Infra;
32
32
  tasks: Record<string, TaskDescriptor>;
33
33
  runners: Record<string, RunnerDescriptor>;
34
+ build?: {
35
+ externalPackages?: string[];
36
+ };
34
37
  }
35
38
  export interface TaskName {
36
39
  descriptor: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgehive/forge-cli",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "description": "TypeScript CLI application",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -10,11 +10,11 @@
10
10
  "publishConfig": {
11
11
  "access": "public",
12
12
  "dependencies": {
13
- "@forgehive/hive-sdk": "^0.1.5",
14
- "@forgehive/record-tape": "^0.2.6",
15
- "@forgehive/runner": "^0.2.6",
13
+ "@forgehive/hive-sdk": "^0.1.6",
14
+ "@forgehive/record-tape": "^0.2.7",
15
+ "@forgehive/runner": "^0.2.7",
16
16
  "@forgehive/schema": "^0.1.4",
17
- "@forgehive/task": "^0.2.6",
17
+ "@forgehive/task": "^0.2.7",
18
18
  "esbuild": "^0.25.0",
19
19
  "handlebars": "^4.7.8",
20
20
  "minimist": "^1.2.8",
@@ -30,11 +30,11 @@
30
30
  "minimist": "^1.2.8",
31
31
  "typescript": "^5.3.3",
32
32
  "uuid": "^11.1.0",
33
+ "@forgehive/runner": "0.2.7",
33
34
  "@forgehive/schema": "0.1.4",
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"
35
+ "@forgehive/task": "0.2.7",
36
+ "@forgehive/record-tape": "0.2.7",
37
+ "@forgehive/hive-sdk": "0.1.6"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/archiver": "^6.0.3",
@@ -5,18 +5,28 @@
5
5
  import { createTask } from '@forgehive/task'
6
6
  import { Schema } from '@forgehive/schema'
7
7
  import esbuild from 'esbuild'
8
+ import { load as loadConf } from '../conf/load'
9
+ import { type ForgeConf } from '../types'
8
10
 
9
11
  const schema = new Schema({
10
12
  entryPoint: Schema.string(),
11
13
  outputFile: Schema.string()
12
14
  })
13
15
 
14
- const boundaries = {}
16
+ const boundaries = {
17
+ loadConf: loadConf.asBoundary()
18
+ }
15
19
 
16
20
  export const create = createTask({
17
21
  schema,
18
22
  boundaries,
19
- fn: async function ({ entryPoint, outputFile }) {
23
+ fn: async function ({ entryPoint, outputFile }, { loadConf }) {
24
+ // Load forge configuration
25
+ const forge: ForgeConf = await loadConf({})
26
+
27
+ // Get external packages from config, default to empty array
28
+ const externalPackages = forge.build?.externalPackages ?? []
29
+
20
30
  // Build using esbuild
21
31
  await esbuild.build({
22
32
  entryPoints: [entryPoint],
@@ -24,7 +34,8 @@ export const create = createTask({
24
34
  bundle: true,
25
35
  minify: true,
26
36
  platform: 'node',
27
- sourcemap: true
37
+ sourcemap: true,
38
+ external: externalPackages
28
39
  })
29
40
 
30
41
  return { outputFile }
@@ -174,6 +174,9 @@ export const fingerprint = createTask({
174
174
  console.log(`Entry point: ${entryPoint}`)
175
175
  console.log(`Output: ${outputFile}`)
176
176
 
177
+ // Get external packages from config, default to empty array
178
+ const externalPackages = forgeJson.build?.externalPackages ?? []
179
+
177
180
  // Build with fingerprinting plugin
178
181
  const result = await esbuild.build({
179
182
  entryPoints: [entryPoint],
@@ -183,7 +186,8 @@ export const fingerprint = createTask({
183
186
  platform: 'node',
184
187
  sourcemap: true,
185
188
  plugins: [taskFingerprintPlugin()],
186
- metafile: true
189
+ metafile: true,
190
+ external: externalPackages
187
191
  })
188
192
 
189
193
  // Extract fingerprints from build result
@@ -13,7 +13,8 @@ const description = 'Zip a bundle file for distribution'
13
13
  const schema = new Schema({
14
14
  dir: Schema.string(),
15
15
  input: Schema.string(),
16
- output: Schema.string()
16
+ output: Schema.string(),
17
+ forgeJsonPath: Schema.string().optional() // Optional path to forge.json - if provided, it will be included
17
18
  })
18
19
 
19
20
  const boundaries = {
@@ -33,7 +34,7 @@ const boundaries = {
33
34
  } catch {
34
35
  return false
35
36
  }
36
- }
37
+ },
37
38
  }
38
39
 
39
40
  export const bytesToMB = (bytes: number): string => {
@@ -44,7 +45,7 @@ export const bytesToMB = (bytes: number): string => {
44
45
  export const zip = createTask({
45
46
  schema,
46
47
  boundaries,
47
- fn: async function ({ dir, input, output }, { createWriteStream, createArchiver, resolvePathDir, fileExists }) {
48
+ fn: async function ({ dir, input, output, forgeJsonPath }, { createWriteStream, createArchiver, resolvePathDir, fileExists }) {
48
49
  const outputPath = await resolvePathDir(dir, output)
49
50
  const inputPath = await resolvePathDir(dir, input)
50
51
  const inputMapPath = inputPath + '.map'
@@ -58,6 +59,17 @@ export const zip = createTask({
58
59
  // Check if source map exists before creating Promise
59
60
  const mapExists = await fileExists(inputMapPath)
60
61
 
62
+ // Handle forge.json inclusion - only if path is provided
63
+ let finalForgeJsonPath: string | null = null
64
+ if (forgeJsonPath) {
65
+ const exists = await fileExists(forgeJsonPath)
66
+ if (exists) {
67
+ finalForgeJsonPath = forgeJsonPath
68
+ } else {
69
+ console.warn(`forge.json not found at provided path: ${forgeJsonPath}`)
70
+ }
71
+ }
72
+
61
73
  // Handle async operations outside of Promise constructor
62
74
  const outStream = await createWriteStream(outputPath)
63
75
  const archive = await createArchiver('zip', {
@@ -101,6 +113,12 @@ export const zip = createTask({
101
113
  archive.file(inputMapPath, { name: 'index.js.map' })
102
114
  }
103
115
 
116
+ // Add forge.json if path was provided and found
117
+ if (finalForgeJsonPath) {
118
+ archive.file(finalForgeJsonPath, { name: 'forge.json' })
119
+ console.log(`Added forge.json from: ${finalForgeJsonPath}`)
120
+ }
121
+
104
122
  archive.finalize()
105
123
  })
106
124
  }
@@ -59,6 +59,9 @@ export const bundle = createTask({
59
59
  // Ensure target directory exists
60
60
  await ensureDir(path.dirname(targetPath))
61
61
 
62
+ // Get external packages from config, default to empty array
63
+ const externalPackages = forge.build?.externalPackages ?? []
64
+
62
65
  // Build using esbuild
63
66
  await esbuild.build({
64
67
  entryPoints: [entryPoint],
@@ -66,7 +69,8 @@ export const bundle = createTask({
66
69
  bundle: true,
67
70
  minify: true,
68
71
  platform: 'node',
69
- sourcemap: true
72
+ sourcemap: true,
73
+ external: externalPackages
70
74
  })
71
75
 
72
76
  return {
@@ -139,11 +139,12 @@ export const publish = createTask({
139
139
 
140
140
  console.log('Bundle created...')
141
141
 
142
- // Zip the bundle
142
+ // Zip the bundle with forge.json included
143
143
  await bundleZip({
144
144
  dir: buildsPath,
145
145
  input: `${descriptorName}.js`,
146
- output: zipFile
146
+ output: zipFile,
147
+ forgeJsonPath: path.join(cwd, 'forge.json')
147
148
  })
148
149
 
149
150
  console.log('Bundle zipped...')
@@ -34,6 +34,9 @@ export interface ForgeConf {
34
34
  infra: Infra
35
35
  tasks: Record<string, TaskDescriptor>
36
36
  runners: Record<string, RunnerDescriptor>
37
+ build?: {
38
+ externalPackages?: string[]
39
+ }
37
40
  }
38
41
 
39
42
  export interface TaskName {