@amaster.ai/runtime-cli 1.1.12 → 1.1.13

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.
package/dist/cli.d.cts CHANGED
@@ -3,5 +3,6 @@ import { AmasterClient } from '@amaster.ai/client';
3
3
 
4
4
  declare function resolveAppCode(optionsApp: string | undefined): string;
5
5
  declare function createAmasterClient(appCode: string): AmasterClient;
6
+ declare function isDirectCliExecution(entryArg?: string | undefined): boolean;
6
7
 
7
- export { createAmasterClient, resolveAppCode };
8
+ export { createAmasterClient, isDirectCliExecution, resolveAppCode };
package/dist/cli.d.ts CHANGED
@@ -3,5 +3,6 @@ import { AmasterClient } from '@amaster.ai/client';
3
3
 
4
4
  declare function resolveAppCode(optionsApp: string | undefined): string;
5
5
  declare function createAmasterClient(appCode: string): AmasterClient;
6
+ declare function isDirectCliExecution(entryArg?: string | undefined): boolean;
6
7
 
7
- export { createAmasterClient, resolveAppCode };
8
+ export { createAmasterClient, isDirectCliExecution, resolveAppCode };
package/dist/cli.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, rmSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
2
+ import { existsSync, rmSync, mkdirSync, readFileSync, writeFileSync, realpathSync } from 'fs';
3
3
  import { join, resolve, basename } from 'path';
4
4
  import { homedir } from 'os';
5
+ import { fileURLToPath } from 'url';
5
6
  import { Command, Option } from 'commander';
6
7
  import chalk3 from 'chalk';
7
8
  import { createClient } from '@amaster.ai/client';
@@ -3182,8 +3183,17 @@ s3Cmd.command("metadata <key>").description("Get file metadata").option("--app <
3182
3183
  format: options.format
3183
3184
  });
3184
3185
  });
3185
- var isMainModule = import.meta.url === new URL(process.argv[1] || "", import.meta.url).href || import.meta.url.endsWith(process.argv[1] || "") || process.argv[1]?.includes("cli.js") || false;
3186
- if (isMainModule) {
3186
+ function isDirectCliExecution(entryArg = process.argv[1]) {
3187
+ if (!entryArg) {
3188
+ return false;
3189
+ }
3190
+ try {
3191
+ return realpathSync(entryArg) === realpathSync(fileURLToPath(import.meta.url));
3192
+ } catch {
3193
+ return false;
3194
+ }
3195
+ }
3196
+ if (isDirectCliExecution()) {
3187
3197
  program.parseAsync(process.argv).then(
3188
3198
  () => process.exit(0),
3189
3199
  (err) => {
@@ -3193,6 +3203,6 @@ if (isMainModule) {
3193
3203
  );
3194
3204
  }
3195
3205
 
3196
- export { createAmasterClient, resolveAppCode };
3206
+ export { createAmasterClient, isDirectCliExecution, resolveAppCode };
3197
3207
  //# sourceMappingURL=cli.js.map
3198
3208
  //# sourceMappingURL=cli.js.map