@aws/ml-container-creator 0.2.0 → 0.2.2

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 (36) hide show
  1. package/bin/cli.js +88 -86
  2. package/config/bootstrap-stack.json +211 -0
  3. package/config/parameter-schema.json +88 -0
  4. package/infra/ci-harness/bin/ci-harness.ts +26 -0
  5. package/infra/ci-harness/buildspec.yml +352 -0
  6. package/infra/ci-harness/cdk.json +27 -0
  7. package/infra/ci-harness/lambda/scanner/index.ts +199 -0
  8. package/infra/ci-harness/lib/ci-harness-stack.ts +609 -0
  9. package/infra/ci-harness/package-lock.json +3979 -0
  10. package/infra/ci-harness/package.json +32 -0
  11. package/infra/ci-harness/tsconfig.json +38 -0
  12. package/package.json +19 -10
  13. package/src/app.js +318 -318
  14. package/src/copy-tpl.js +19 -19
  15. package/src/lib/asset-manager.js +74 -74
  16. package/src/lib/aws-profile-parser.js +45 -45
  17. package/src/lib/bootstrap-command-handler.js +560 -547
  18. package/src/lib/bootstrap-config.js +45 -45
  19. package/src/lib/ci-register-helpers.js +19 -19
  20. package/src/lib/ci-report-helpers.js +37 -37
  21. package/src/lib/ci-stage-helpers.js +49 -49
  22. package/src/lib/comment-generator.js +4 -4
  23. package/src/lib/config-manager.js +105 -105
  24. package/src/lib/deployment-config-resolver.js +10 -10
  25. package/src/lib/deployment-registry.js +153 -153
  26. package/src/lib/engine-prefix-resolver.js +8 -8
  27. package/src/lib/key-value-parser.js +6 -6
  28. package/src/lib/manifest-cli.js +108 -108
  29. package/src/lib/prompt-runner.js +224 -224
  30. package/src/lib/prompts.js +121 -121
  31. package/src/lib/registry-command-handler.js +174 -174
  32. package/src/lib/registry-loader.js +52 -52
  33. package/src/lib/sensitive-redactor.js +9 -9
  34. package/src/lib/template-engine.js +1 -1
  35. package/src/lib/template-manager.js +62 -62
  36. package/src/prompt-adapter.js +18 -18
@@ -18,8 +18,8 @@
18
18
  * Validates: Requirements 9.1–9.7
19
19
  */
20
20
 
21
- import AssetManager, { VALID_RESOURCE_TYPES, VALID_STATUSES } from './asset-manager.js'
22
- import BootstrapConfig from './bootstrap-config.js'
21
+ import AssetManager, { VALID_RESOURCE_TYPES, VALID_STATUSES } from './asset-manager.js';
22
+ import BootstrapConfig from './bootstrap-config.js';
23
23
 
24
24
  /**
25
25
  * Parse command-line arguments into a map of flag → value pairs.
@@ -30,36 +30,36 @@ import BootstrapConfig from './bootstrap-config.js'
30
30
  */
31
31
  function parseArgs(argv) {
32
32
  // argv[0] = node, argv[1] = script path, argv[2] = subcommand, argv[3..] = flags
33
- const args = argv.slice(2)
34
- const subcommand = args.length > 0 && !args[0].startsWith('--') ? args[0] : null
35
- const flags = {}
33
+ const args = argv.slice(2);
34
+ const subcommand = args.length > 0 && !args[0].startsWith('--') ? args[0] : null;
35
+ const flags = {};
36
36
 
37
37
  for (let i = subcommand ? 1 : 0; i < args.length; i++) {
38
38
  if (args[i].startsWith('--') && i + 1 < args.length) {
39
- const key = args[i].slice(2)
40
- flags[key] = args[i + 1]
41
- i++
39
+ const key = args[i].slice(2);
40
+ flags[key] = args[i + 1];
41
+ i++;
42
42
  }
43
43
  }
44
44
 
45
- return { subcommand, flags }
45
+ return { subcommand, flags };
46
46
  }
47
47
 
48
48
  /**
49
49
  * Print usage information and exit.
50
50
  */
51
51
  function printUsage() {
52
- console.log('Usage:')
53
- console.log(' manifest add --type <resourceType> --id <resourceId> --project <projectName> [--meta <json>]')
54
- console.log(' manifest delete --id <resourceId>')
55
- console.log(' manifest list [--project <project>] [--status <status>] [--type <type>]')
56
- console.log(' manifest prune')
57
- console.log('')
58
- console.log('Valid resource types:')
59
- console.log(` ${VALID_RESOURCE_TYPES.join(', ')}`)
60
- console.log('')
61
- console.log('Valid statuses:')
62
- console.log(` ${VALID_STATUSES.join(', ')}`)
52
+ console.log('Usage:');
53
+ console.log(' manifest add --type <resourceType> --id <resourceId> --project <projectName> [--meta <json>]');
54
+ console.log(' manifest delete --id <resourceId>');
55
+ console.log(' manifest list [--project <project>] [--status <status>] [--type <type>]');
56
+ console.log(' manifest prune');
57
+ console.log('');
58
+ console.log('Valid resource types:');
59
+ console.log(` ${VALID_RESOURCE_TYPES.join(', ')}`);
60
+ console.log('');
61
+ console.log('Valid statuses:');
62
+ console.log(` ${VALID_STATUSES.join(', ')}`);
63
63
  }
64
64
 
65
65
  /**
@@ -69,40 +69,40 @@ function printUsage() {
69
69
  */
70
70
  function printResourceTable(resources) {
71
71
  if (resources.length === 0) {
72
- console.log('No resources found.')
73
- return
72
+ console.log('No resources found.');
73
+ return;
74
74
  }
75
75
 
76
76
  // Header
77
- const header = ['Type', 'Resource ID', 'Project', 'Status', 'Created At']
78
- const widths = header.map(h => h.length)
77
+ const header = ['Type', 'Resource ID', 'Project', 'Status', 'Created At'];
78
+ const widths = header.map(h => h.length);
79
79
 
80
80
  // Calculate column widths
81
81
  for (const r of resources) {
82
- widths[0] = Math.max(widths[0], (r.resourceType || '').length)
83
- widths[1] = Math.max(widths[1], Math.min((r.resourceId || '').length, 60))
84
- widths[2] = Math.max(widths[2], (r.project || '').length)
85
- widths[3] = Math.max(widths[3], (r.status || '').length)
86
- widths[4] = Math.max(widths[4], (r.createdAt || '').length)
82
+ widths[0] = Math.max(widths[0], (r.resourceType || '').length);
83
+ widths[1] = Math.max(widths[1], Math.min((r.resourceId || '').length, 60));
84
+ widths[2] = Math.max(widths[2], (r.project || '').length);
85
+ widths[3] = Math.max(widths[3], (r.status || '').length);
86
+ widths[4] = Math.max(widths[4], (r.createdAt || '').length);
87
87
  }
88
88
 
89
- const pad = (str, width) => String(str).padEnd(width)
90
- const separator = widths.map(w => '-'.repeat(w)).join(' ')
89
+ const pad = (str, width) => String(str).padEnd(width);
90
+ const separator = widths.map(w => '-'.repeat(w)).join(' ');
91
91
 
92
- console.log(header.map((h, i) => pad(h, widths[i])).join(' '))
93
- console.log(separator)
92
+ console.log(header.map((h, i) => pad(h, widths[i])).join(' '));
93
+ console.log(separator);
94
94
 
95
95
  for (const r of resources) {
96
96
  const id = (r.resourceId || '').length > 60
97
- ? r.resourceId.slice(0, 57) + '...'
98
- : r.resourceId || ''
97
+ ? `${r.resourceId.slice(0, 57) }...`
98
+ : r.resourceId || '';
99
99
  console.log([
100
100
  pad(r.resourceType || '', widths[0]),
101
101
  pad(id, widths[1]),
102
102
  pad(r.project || '', widths[2]),
103
103
  pad(r.status || '', widths[3]),
104
104
  pad(r.createdAt || '', widths[4])
105
- ].join(' '))
105
+ ].join(' '));
106
106
  }
107
107
  }
108
108
 
@@ -113,35 +113,35 @@ function printResourceTable(resources) {
113
113
  * @param {AssetManager} assetManager - The AssetManager instance
114
114
  */
115
115
  function handleAdd(flags, assetManager) {
116
- const { type, id, project, meta } = flags
116
+ const { type, id, project, meta } = flags;
117
117
 
118
118
  if (!type || !id || !project) {
119
- console.error('Error: --type, --id, and --project are required for the add command.')
120
- console.log('')
121
- printUsage()
122
- process.exitCode = 1
123
- return
119
+ console.error('Error: --type, --id, and --project are required for the add command.');
120
+ console.log('');
121
+ printUsage();
122
+ process.exitCode = 1;
123
+ return;
124
124
  }
125
125
 
126
126
  if (!VALID_RESOURCE_TYPES.includes(type)) {
127
- console.error(`Error: Invalid resource type "${type}".`)
128
- console.error(`Valid types: ${VALID_RESOURCE_TYPES.join(', ')}`)
129
- process.exitCode = 1
130
- return
127
+ console.error(`Error: Invalid resource type "${type}".`);
128
+ console.error(`Valid types: ${VALID_RESOURCE_TYPES.join(', ')}`);
129
+ process.exitCode = 1;
130
+ return;
131
131
  }
132
132
 
133
- let metadata = {}
133
+ let metadata = {};
134
134
  if (meta) {
135
135
  try {
136
- metadata = JSON.parse(meta)
136
+ metadata = JSON.parse(meta);
137
137
  } catch (err) {
138
- console.error(`Error: Invalid JSON for --meta: ${err.message}`)
139
- process.exitCode = 1
140
- return
138
+ console.error(`Error: Invalid JSON for --meta: ${err.message}`);
139
+ process.exitCode = 1;
140
+ return;
141
141
  }
142
142
  }
143
143
 
144
- const now = new Date().toISOString()
144
+ const now = new Date().toISOString();
145
145
  const record = {
146
146
  resourceId: id,
147
147
  resourceType: type,
@@ -150,10 +150,10 @@ function handleAdd(flags, assetManager) {
150
150
  project,
151
151
  status: 'active',
152
152
  metadata
153
- }
153
+ };
154
154
 
155
- assetManager.addResource(record)
156
- console.log(`Added ${type}: ${id}`)
155
+ assetManager.addResource(record);
156
+ console.log(`Added ${type}: ${id}`);
157
157
  }
158
158
 
159
159
  /**
@@ -163,21 +163,21 @@ function handleAdd(flags, assetManager) {
163
163
  * @param {AssetManager} assetManager - The AssetManager instance
164
164
  */
165
165
  function handleDelete(flags, assetManager) {
166
- const { id } = flags
166
+ const { id } = flags;
167
167
 
168
168
  if (!id) {
169
- console.error('Error: --id is required for the delete command.')
170
- console.log('')
171
- printUsage()
172
- process.exitCode = 1
173
- return
169
+ console.error('Error: --id is required for the delete command.');
170
+ console.log('');
171
+ printUsage();
172
+ process.exitCode = 1;
173
+ return;
174
174
  }
175
175
 
176
- const updated = assetManager.updateStatus(id, 'deleted')
176
+ const updated = assetManager.updateStatus(id, 'deleted');
177
177
  if (updated) {
178
- console.log(`Marked as deleted: ${id}`)
178
+ console.log(`Marked as deleted: ${id}`);
179
179
  } else {
180
- console.log(`Resource not found in manifest: ${id}`)
180
+ console.log(`Resource not found in manifest: ${id}`);
181
181
  }
182
182
  }
183
183
 
@@ -188,13 +188,13 @@ function handleDelete(flags, assetManager) {
188
188
  * @param {AssetManager} assetManager - The AssetManager instance
189
189
  */
190
190
  function handleList(flags, assetManager) {
191
- const filters = {}
192
- if (flags.project) filters.project = flags.project
193
- if (flags.status) filters.status = flags.status
194
- if (flags.type) filters.resourceType = flags.type
191
+ const filters = {};
192
+ if (flags.project) filters.project = flags.project;
193
+ if (flags.status) filters.status = flags.status;
194
+ if (flags.type) filters.resourceType = flags.type;
195
195
 
196
- const resources = assetManager.listResources(filters)
197
- printResourceTable(resources)
196
+ const resources = assetManager.listResources(filters);
197
+ printResourceTable(resources);
198
198
  }
199
199
 
200
200
  /**
@@ -203,21 +203,21 @@ function handleList(flags, assetManager) {
203
203
  * @param {AssetManager} assetManager - The AssetManager instance
204
204
  */
205
205
  function handlePrune(assetManager) {
206
- const all = assetManager.listResources()
207
- const stale = all.filter(r => r.status === 'deleted' || r.status === 'unknown')
206
+ const all = assetManager.listResources();
207
+ const stale = all.filter(r => r.status === 'deleted' || r.status === 'unknown');
208
208
 
209
209
  if (stale.length === 0) {
210
- console.log('Nothing to prune — no deleted or unknown records found.')
211
- return
210
+ console.log('Nothing to prune — no deleted or unknown records found.');
211
+ return;
212
212
  }
213
213
 
214
214
  for (const resource of stale) {
215
- assetManager.removeResource(resource.resourceId)
216
- console.log(` 🗑️ [${resource.status}] ${resource.resourceType}: ${resource.resourceId}`)
215
+ assetManager.removeResource(resource.resourceId);
216
+ console.log(` 🗑️ [${resource.status}] ${resource.resourceType}: ${resource.resourceId}`);
217
217
  }
218
218
 
219
- const remaining = assetManager.listResources()
220
- console.log(`\nPruned ${stale.length} record${stale.length === 1 ? '' : 's'}. ${remaining.length} remaining.`)
219
+ const remaining = assetManager.listResources();
220
+ console.log(`\nPruned ${stale.length} record${stale.length === 1 ? '' : 's'}. ${remaining.length} remaining.`);
221
221
  }
222
222
 
223
223
  /**
@@ -227,45 +227,45 @@ function handlePrune(assetManager) {
227
227
  * @param {string[]} argv - The raw process.argv array
228
228
  */
229
229
  export function main(argv) {
230
- const { subcommand, flags } = parseArgs(argv)
230
+ const { subcommand, flags } = parseArgs(argv);
231
231
 
232
232
  if (!subcommand) {
233
- printUsage()
234
- process.exitCode = 1
235
- return
233
+ printUsage();
234
+ process.exitCode = 1;
235
+ return;
236
236
  }
237
237
 
238
238
  // Resolve active bootstrap profile
239
- const bootstrapConfig = new BootstrapConfig()
240
- const activeProfile = bootstrapConfig.getActiveProfile()
239
+ const bootstrapConfig = new BootstrapConfig();
240
+ const activeProfile = bootstrapConfig.getActiveProfile();
241
241
 
242
242
  if (!activeProfile) {
243
- console.warn('Warning: No active bootstrap profile configured. Skipping manifest operation.')
244
- console.warn('Run "ml-container-creator bootstrap" to configure a profile.')
245
- return
243
+ console.warn('Warning: No active bootstrap profile configured. Skipping manifest operation.');
244
+ console.warn('Run "ml-container-creator bootstrap" to configure a profile.');
245
+ return;
246
246
  }
247
247
 
248
- const assetManager = new AssetManager(activeProfile.name)
248
+ const assetManager = new AssetManager(activeProfile.name);
249
249
 
250
250
  switch (subcommand) {
251
- case 'add':
252
- handleAdd(flags, assetManager)
253
- break
254
- case 'delete':
255
- handleDelete(flags, assetManager)
256
- break
257
- case 'list':
258
- handleList(flags, assetManager)
259
- break
260
- case 'prune':
261
- handlePrune(assetManager)
262
- break
263
- default:
264
- console.error(`Unknown subcommand: ${subcommand}`)
265
- console.log('')
266
- printUsage()
267
- process.exitCode = 1
268
- break
251
+ case 'add':
252
+ handleAdd(flags, assetManager);
253
+ break;
254
+ case 'delete':
255
+ handleDelete(flags, assetManager);
256
+ break;
257
+ case 'list':
258
+ handleList(flags, assetManager);
259
+ break;
260
+ case 'prune':
261
+ handlePrune(assetManager);
262
+ break;
263
+ default:
264
+ console.error(`Unknown subcommand: ${subcommand}`);
265
+ console.log('');
266
+ printUsage();
267
+ process.exitCode = 1;
268
+ break;
269
269
  }
270
270
  }
271
271
 
@@ -273,8 +273,8 @@ export function main(argv) {
273
273
  const isDirectExecution = process.argv[1] && (
274
274
  process.argv[1].endsWith('manifest-cli.js') ||
275
275
  process.argv[1].endsWith('do/lib/manifest-cli.js')
276
- )
276
+ );
277
277
 
278
278
  if (isDirectExecution) {
279
- main(process.argv)
279
+ main(process.argv);
280
280
  }