@decohere/scaffold 0.0.1-dev.110 → 0.0.1-dev.111

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.
@@ -4,4 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  const _program = require("./program.js");
7
- void (0, _program.runCli)();
7
+ // Exit as soon as the command is done, without waiting for handles it left open.
8
+ process.exit(await (0, _program.runCli)());
@@ -51,14 +51,14 @@ async function runCli(argv = process.argv) {
51
51
  await createProgram().parseAsync(argv);
52
52
  } catch (err) {
53
53
  if (err instanceof _commander.CommanderError) {
54
- process.exit(err.exitCode);
54
+ return err.exitCode;
55
55
  }
56
56
  if (err instanceof _apiname.CreateCliError) {
57
57
  console.error(`\n ${err.message}\n`);
58
- process.exit(1);
58
+ return 1;
59
59
  }
60
60
  console.error(err);
61
- process.exit(1);
61
+ return 1;
62
62
  }
63
- process.exit(process.exitCode ?? 0);
63
+ return typeof process.exitCode === "number" ? process.exitCode : 0;
64
64
  }
@@ -19,15 +19,53 @@ _export(exports, {
19
19
  return openApiToPostmanCollection;
20
20
  }
21
21
  });
22
- const _openapitopostmanv2 = /*#__PURE__*/ _interop_require_default(require("openapi-to-postmanv2"));
23
- function _interop_require_default(obj) {
24
- return obj && obj.__esModule ? obj : {
25
- default: obj
22
+ function _getRequireWildcardCache(nodeInterop) {
23
+ if (typeof WeakMap !== "function") return null;
24
+ var cacheBabelInterop = new WeakMap();
25
+ var cacheNodeInterop = new WeakMap();
26
+ return (_getRequireWildcardCache = function(nodeInterop) {
27
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
28
+ })(nodeInterop);
29
+ }
30
+ function _interop_require_wildcard(obj, nodeInterop) {
31
+ if (!nodeInterop && obj && obj.__esModule) {
32
+ return obj;
33
+ }
34
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
35
+ return {
36
+ default: obj
37
+ };
38
+ }
39
+ var cache = _getRequireWildcardCache(nodeInterop);
40
+ if (cache && cache.has(obj)) {
41
+ return cache.get(obj);
42
+ }
43
+ var newObj = {
44
+ __proto__: null
26
45
  };
46
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
47
+ for(var key in obj){
48
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
49
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
50
+ if (desc && (desc.get || desc.set)) {
51
+ Object.defineProperty(newObj, key, desc);
52
+ } else {
53
+ newObj[key] = obj[key];
54
+ }
55
+ }
56
+ }
57
+ newObj.default = obj;
58
+ if (cache) {
59
+ cache.set(obj, newObj);
60
+ }
61
+ return newObj;
27
62
  }
28
- function convertAsync(data, options) {
63
+ async function convertAsync(data, options) {
64
+ // Loaded here, not at the top: the converter pulls in about 700 modules (lodash, faker, ajv,
65
+ // …), which every scaffolder run paid for even with `--postman none`.
66
+ const { default: converter } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("openapi-to-postmanv2")));
29
67
  return new Promise((resolve, reject)=>{
30
- _openapitopostmanv2.default.convert({
68
+ converter.convert({
31
69
  type: "json",
32
70
  data
33
71
  }, options, (err, result)=>{
package/es6/src/cli.js CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { runCli } from "./program.js";
3
- void runCli();
3
+ // Exit as soon as the command is done, without waiting for handles it left open.
4
+ process.exit(await runCli());
@@ -28,19 +28,23 @@ export function createProgram() {
28
28
  });
29
29
  return program;
30
30
  }
31
- export async function runCli(argv = process.argv) {
31
+ /**
32
+ * Runs the CLI and returns its exit code; the bin (`cli.ts`) exits with it. Returning instead
33
+ * of calling `process.exit` here lets tests run it in process: a run that finished after its
34
+ * test had timed out used to call `process.exit` in whichever test came next (#662).
35
+ */ export async function runCli(argv = process.argv) {
32
36
  try {
33
37
  await createProgram().parseAsync(argv);
34
38
  } catch (err) {
35
39
  if (err instanceof CommanderError) {
36
- process.exit(err.exitCode);
40
+ return err.exitCode;
37
41
  }
38
42
  if (err instanceof CreateCliError) {
39
43
  console.error(`\n ${err.message}\n`);
40
- process.exit(1);
44
+ return 1;
41
45
  }
42
46
  console.error(err);
43
- process.exit(1);
47
+ return 1;
44
48
  }
45
- process.exit(process.exitCode ?? 0);
49
+ return typeof process.exitCode === "number" ? process.exitCode : 0;
46
50
  }
@@ -1,5 +1,7 @@
1
- import converter from "openapi-to-postmanv2";
2
- function convertAsync(data, options) {
1
+ async function convertAsync(data, options) {
2
+ // Loaded here, not at the top: the converter pulls in about 700 modules (lodash, faker, ajv,
3
+ // …), which every scaffolder run paid for even with `--postman none`.
4
+ const { default: converter } = await import("openapi-to-postmanv2");
3
5
  return new Promise((resolve, reject)=>{
4
6
  converter.convert({
5
7
  type: "json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/scaffold",
3
- "version": "0.0.1-dev.110",
3
+ "version": "0.0.1-dev.111",
4
4
  "description": "Decohere project scaffolder (runs inside ghcr.io/typesmiths/decohere/create)",
5
5
  "keywords": [
6
6
  "decohere",
@@ -22,8 +22,8 @@
22
22
  "test": "echo \"Error: no test specified\" && exit 1"
23
23
  },
24
24
  "dependencies": {
25
- "@decohere/crucible": "0.0.1-dev.110",
26
- "@decohere/nexus": "0.0.1-dev.110",
25
+ "@decohere/crucible": "0.0.1-dev.111",
26
+ "@decohere/nexus": "0.0.1-dev.111",
27
27
  "commander": "^13.1.0",
28
28
  "openapi-to-postmanv2": "^5.0.0",
29
29
  "yaml": "^2.9.1"
@@ -1,3 +1,8 @@
1
1
  import { Command } from "commander";
2
2
  export declare function createProgram(): Command;
3
- export declare function runCli(argv?: string[]): Promise<void>;
3
+ /**
4
+ * Runs the CLI and returns its exit code; the bin (`cli.ts`) exits with it. Returning instead
5
+ * of calling `process.exit` here lets tests run it in process: a run that finished after its
6
+ * test had timed out used to call `process.exit` in whichever test came next (#662).
7
+ */
8
+ export declare function runCli(argv?: string[]): Promise<number>;