@pd4castr/cli 1.0.1 → 1.1.0

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 (2) hide show
  1. package/dist/index.js +19 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -126,17 +126,17 @@ async function isExistingPath(path15) {
126
126
  }
127
127
 
128
128
  // src/config/load-project-context.ts
129
- async function loadProjectContext() {
129
+ async function loadProjectContext(configPath) {
130
130
  const projectRoot = process.cwd();
131
- const configPath = path.join(projectRoot, PROJECT_CONFIG_FILE);
132
- const configExists = await isExistingPath(configPath);
131
+ const resolvedConfigPath = configPath ? path.resolve(configPath) : path.join(projectRoot, PROJECT_CONFIG_FILE);
132
+ const configExists = await isExistingPath(resolvedConfigPath);
133
133
  if (!configExists) {
134
134
  throw new Error(
135
- "No config found (docs: https://github.com/pipelabs/pd4castr-model-examples/blob/main/docs/005-config.md)."
135
+ `No config found at ${resolvedConfigPath} (docs: https://github.com/pipelabs/pd4castr-model-examples/blob/main/docs/005-config.md).`
136
136
  );
137
137
  }
138
138
  try {
139
- const configFileContents = await fs2.readFile(configPath, "utf8");
139
+ const configFileContents = await fs2.readFile(resolvedConfigPath, "utf8");
140
140
  const rawConfig = JSON.parse(configFileContents);
141
141
  const config = projectConfigSchema.parse(rawConfig);
142
142
  return {
@@ -318,7 +318,7 @@ async function handleAction(options) {
318
318
  const spinner = ora("Starting data fetch...").start();
319
319
  try {
320
320
  const authCtx = await getAuth();
321
- const ctx = await loadProjectContext();
321
+ const ctx = await loadProjectContext(options.config);
322
322
  const inputsWithFetchers = ctx.config.inputs.filter((input2) => input2.fetcher);
323
323
  if (inputsWithFetchers.length === 0) {
324
324
  spinner.info("No inputs with data fetchers found, skipping");
@@ -371,7 +371,7 @@ function registerFetchCommand(program2) {
371
371
  "-i, --input-dir <path>",
372
372
  "The input test data directory",
373
373
  TEST_INPUT_DATA_DIR
374
- ).action(handleAction);
374
+ ).option("-c, --config <path>", "Path to config file", PROJECT_CONFIG_FILE).action(handleAction);
375
375
  }
376
376
 
377
377
  // src/commands/init/handle-action.ts
@@ -663,11 +663,12 @@ async function triggerModelRun(modelId, authCtx) {
663
663
  import fs7 from "fs/promises";
664
664
  import path8 from "path";
665
665
  import { produce as produce2 } from "immer";
666
- async function updateProjectConfig(updateFn) {
667
- const projectConfig = await loadProjectContext();
666
+ async function updateProjectConfig(updateFn, configPath) {
667
+ const projectConfig = await loadProjectContext(configPath);
668
668
  const updatedConfig = produce2(projectConfig.config, updateFn);
669
+ const resolvedConfigPath = configPath ? path8.resolve(configPath) : path8.join(projectConfig.projectRoot, PROJECT_CONFIG_FILE);
669
670
  await fs7.writeFile(
670
- path8.join(projectConfig.projectRoot, PROJECT_CONFIG_FILE),
671
+ resolvedConfigPath,
671
672
  JSON.stringify(updatedConfig, void 0, 2)
672
673
  );
673
674
  }
@@ -1019,7 +1020,7 @@ async function handleCreateModelFlow(options, app, spinner, ctx, authCtx) {
1019
1020
  config.$$modelGroupID = model.modelGroupId;
1020
1021
  config.$$revision = model.revision;
1021
1022
  config.$$dockerImage = model.dockerImage;
1022
- });
1023
+ }, options.config);
1023
1024
  spinner.succeed("Model data published successfully");
1024
1025
  spinner.start(
1025
1026
  "Pushing model image to registry - this may take a few minutes..."
@@ -1117,7 +1118,7 @@ async function handleModelRevisionCreateFlow(options, app, spinner, ctx, authCtx
1117
1118
  config.$$modelGroupID = model.modelGroupId;
1118
1119
  config.$$revision = model.revision;
1119
1120
  config.$$dockerImage = model.dockerImage;
1120
- });
1121
+ }, options.config);
1121
1122
  spinner.succeed("Model revision data published successfully");
1122
1123
  spinner.start(
1123
1124
  "Pushing new model revision image to registry - this may take a few minutes..."
@@ -1194,7 +1195,7 @@ async function handleModelRevisionUpdateFlow(options, app, spinner, ctx, authCtx
1194
1195
  config.$$modelGroupID = model.modelGroupId;
1195
1196
  config.$$revision = model.revision;
1196
1197
  config.$$dockerImage = model.dockerImage;
1197
- });
1198
+ }, options.config);
1198
1199
  spinner.succeed("Model revision data updated successfully");
1199
1200
  spinner.start(
1200
1201
  "Pushing updated model image to registry - this may take a few minutes..."
@@ -1265,7 +1266,7 @@ async function handleAction5(options) {
1265
1266
  app.use(express2.urlencoded({ limit: "100mb", extended: true }));
1266
1267
  const webServer = __using(_stack, await startWebServer(app, options.port));
1267
1268
  try {
1268
- const ctx = await loadProjectContext();
1269
+ const ctx = await loadProjectContext(options.config);
1269
1270
  const authCtx = await getAuth();
1270
1271
  await (ctx.config.$$id ? handleUpdateExistingModelFlow(options, app, spinner, ctx, authCtx) : handleCreateModelFlow(options, app, spinner, ctx, authCtx));
1271
1272
  } catch (error) {
@@ -1302,7 +1303,7 @@ function registerPublishCommand(program2) {
1302
1303
  "-p, --port <port>",
1303
1304
  "The port to run the IO testing webserver on",
1304
1305
  TEST_WEBSERVER_PORT.toString()
1305
- ).option("--sc, --skip-checks", "Skip the model I/O checks", false).option("--st, --skip-trigger", "Skip the model trigger", false).action(handleAction5);
1306
+ ).option("--sc, --skip-checks", "Skip the model I/O checks", false).option("--st, --skip-trigger", "Skip the model trigger", false).option("-c, --config <path>", "Path to config file", PROJECT_CONFIG_FILE).action(handleAction5);
1306
1307
  }
1307
1308
 
1308
1309
  // src/commands/test/handle-action.ts
@@ -1320,7 +1321,7 @@ async function handleAction6(options) {
1320
1321
  app.use(express3.urlencoded({ limit: "100mb", extended: true }));
1321
1322
  const webServer = __using(_stack, await startWebServer(app, options.port));
1322
1323
  try {
1323
- const ctx = await loadProjectContext();
1324
+ const ctx = await loadProjectContext(options.config);
1324
1325
  const inputFiles = getInputFiles(ctx.config);
1325
1326
  spinner.start("Checking test input data files");
1326
1327
  await checkInputFiles(inputFiles, options.inputDir, ctx);
@@ -1394,7 +1395,7 @@ function registerTestCommand(program2) {
1394
1395
  "-p, --port <port>",
1395
1396
  "The port to run the IO testing webserver on",
1396
1397
  TEST_WEBSERVER_PORT.toString()
1397
- ).action(handleAction6);
1398
+ ).option("-c, --config <path>", "Path to config file", PROJECT_CONFIG_FILE).action(handleAction6);
1398
1399
  }
1399
1400
 
1400
1401
  // src/program.ts
@@ -1403,7 +1404,7 @@ import { Command } from "commander";
1403
1404
  // package.json
1404
1405
  var package_default = {
1405
1406
  name: "@pd4castr/cli",
1406
- version: "1.0.1",
1407
+ version: "1.1.0",
1407
1408
  description: "CLI tool for creating, testing, and publishing pd4castr models",
1408
1409
  main: "dist/index.js",
1409
1410
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pd4castr/cli",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "CLI tool for creating, testing, and publishing pd4castr models",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",