@pd4castr/cli 1.0.0 → 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 +21 -19
  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
@@ -479,8 +479,9 @@ var auth0API = ky2.create({ prefixUrl: `https://${AUTH0_DOMAIN}` });
479
479
  // src/commands/login/utils/complete-auth-flow.ts
480
480
  var FAILED_AUTH_ERRORS = /* @__PURE__ */ new Set(["expired_token", "access_denied"]);
481
481
  async function completeAuthFlow(authCtx) {
482
+ const env = getEnv();
482
483
  const payload = {
483
- client_id: AUTH0_CLIENT_ID,
484
+ client_id: env.auth0ClientId,
484
485
  grant_type: "urn:ietf:params:oauth:grant-type:device_code",
485
486
  device_code: authCtx.deviceCode
486
487
  };
@@ -662,11 +663,12 @@ async function triggerModelRun(modelId, authCtx) {
662
663
  import fs7 from "fs/promises";
663
664
  import path8 from "path";
664
665
  import { produce as produce2 } from "immer";
665
- async function updateProjectConfig(updateFn) {
666
- const projectConfig = await loadProjectContext();
666
+ async function updateProjectConfig(updateFn, configPath) {
667
+ const projectConfig = await loadProjectContext(configPath);
667
668
  const updatedConfig = produce2(projectConfig.config, updateFn);
669
+ const resolvedConfigPath = configPath ? path8.resolve(configPath) : path8.join(projectConfig.projectRoot, PROJECT_CONFIG_FILE);
668
670
  await fs7.writeFile(
669
- path8.join(projectConfig.projectRoot, PROJECT_CONFIG_FILE),
671
+ resolvedConfigPath,
670
672
  JSON.stringify(updatedConfig, void 0, 2)
671
673
  );
672
674
  }
@@ -1018,7 +1020,7 @@ async function handleCreateModelFlow(options, app, spinner, ctx, authCtx) {
1018
1020
  config.$$modelGroupID = model.modelGroupId;
1019
1021
  config.$$revision = model.revision;
1020
1022
  config.$$dockerImage = model.dockerImage;
1021
- });
1023
+ }, options.config);
1022
1024
  spinner.succeed("Model data published successfully");
1023
1025
  spinner.start(
1024
1026
  "Pushing model image to registry - this may take a few minutes..."
@@ -1116,7 +1118,7 @@ async function handleModelRevisionCreateFlow(options, app, spinner, ctx, authCtx
1116
1118
  config.$$modelGroupID = model.modelGroupId;
1117
1119
  config.$$revision = model.revision;
1118
1120
  config.$$dockerImage = model.dockerImage;
1119
- });
1121
+ }, options.config);
1120
1122
  spinner.succeed("Model revision data published successfully");
1121
1123
  spinner.start(
1122
1124
  "Pushing new model revision image to registry - this may take a few minutes..."
@@ -1193,7 +1195,7 @@ async function handleModelRevisionUpdateFlow(options, app, spinner, ctx, authCtx
1193
1195
  config.$$modelGroupID = model.modelGroupId;
1194
1196
  config.$$revision = model.revision;
1195
1197
  config.$$dockerImage = model.dockerImage;
1196
- });
1198
+ }, options.config);
1197
1199
  spinner.succeed("Model revision data updated successfully");
1198
1200
  spinner.start(
1199
1201
  "Pushing updated model image to registry - this may take a few minutes..."
@@ -1264,7 +1266,7 @@ async function handleAction5(options) {
1264
1266
  app.use(express2.urlencoded({ limit: "100mb", extended: true }));
1265
1267
  const webServer = __using(_stack, await startWebServer(app, options.port));
1266
1268
  try {
1267
- const ctx = await loadProjectContext();
1269
+ const ctx = await loadProjectContext(options.config);
1268
1270
  const authCtx = await getAuth();
1269
1271
  await (ctx.config.$$id ? handleUpdateExistingModelFlow(options, app, spinner, ctx, authCtx) : handleCreateModelFlow(options, app, spinner, ctx, authCtx));
1270
1272
  } catch (error) {
@@ -1301,7 +1303,7 @@ function registerPublishCommand(program2) {
1301
1303
  "-p, --port <port>",
1302
1304
  "The port to run the IO testing webserver on",
1303
1305
  TEST_WEBSERVER_PORT.toString()
1304
- ).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);
1305
1307
  }
1306
1308
 
1307
1309
  // src/commands/test/handle-action.ts
@@ -1319,7 +1321,7 @@ async function handleAction6(options) {
1319
1321
  app.use(express3.urlencoded({ limit: "100mb", extended: true }));
1320
1322
  const webServer = __using(_stack, await startWebServer(app, options.port));
1321
1323
  try {
1322
- const ctx = await loadProjectContext();
1324
+ const ctx = await loadProjectContext(options.config);
1323
1325
  const inputFiles = getInputFiles(ctx.config);
1324
1326
  spinner.start("Checking test input data files");
1325
1327
  await checkInputFiles(inputFiles, options.inputDir, ctx);
@@ -1393,7 +1395,7 @@ function registerTestCommand(program2) {
1393
1395
  "-p, --port <port>",
1394
1396
  "The port to run the IO testing webserver on",
1395
1397
  TEST_WEBSERVER_PORT.toString()
1396
- ).action(handleAction6);
1398
+ ).option("-c, --config <path>", "Path to config file", PROJECT_CONFIG_FILE).action(handleAction6);
1397
1399
  }
1398
1400
 
1399
1401
  // src/program.ts
@@ -1402,7 +1404,7 @@ import { Command } from "commander";
1402
1404
  // package.json
1403
1405
  var package_default = {
1404
1406
  name: "@pd4castr/cli",
1405
- version: "1.0.0",
1407
+ version: "1.1.0",
1406
1408
  description: "CLI tool for creating, testing, and publishing pd4castr models",
1407
1409
  main: "dist/index.js",
1408
1410
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pd4castr/cli",
3
- "version": "1.0.0",
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",