@ardrive/turbo-sdk 1.44.0-alpha.4 → 1.44.0-alpha.5

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.
@@ -30,6 +30,7 @@ const revokeCredits_js_1 = require("./commands/revokeCredits.js");
30
30
  const shareCredits_js_1 = require("./commands/shareCredits.js");
31
31
  const tokenPrice_js_1 = require("./commands/tokenPrice.js");
32
32
  const x402UploadUnsignedData_js_1 = require("./commands/x402UploadUnsignedData.js");
33
+ const entrypoint_js_1 = require("./entrypoint.js");
33
34
  const options_js_1 = require("./options.js");
34
35
  const utils_js_1 = require("./utils.js");
35
36
  (0, utils_js_1.applyOptions)(commander_1.program
@@ -225,8 +226,6 @@ const utils_js_1 = require("./utils.js");
225
226
  }, null, 2));
226
227
  });
227
228
  });
228
- if (process.argv[1].includes('bin/turbo') || // Running from global .bin
229
- process.argv[1].includes('cli/cli') // Running from source
230
- ) {
229
+ if ((0, entrypoint_js_1.isCliEntrypoint)(process.argv[1])) {
231
230
  commander_1.program.parse(process.argv);
232
231
  }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.isCliEntrypoint = isCliEntrypoint;
19
+ /**
20
+ * Whether `scriptPath` (pass `process.argv[1]`) is the Turbo CLI, so the CLI
21
+ * parses arguments only when it is the script Node was asked to run.
22
+ *
23
+ * Node reports `process.argv[1]` with the platform separator. On Windows,
24
+ * npm's `turbo.cmd`, `turbo.ps1` and Git Bash shims all run
25
+ * `node ...\node_modules\@ardrive\turbo-sdk\lib\esm\cli\cli.js`, so the path
26
+ * holds backslashes and is normalized before matching.
27
+ */
28
+ function isCliEntrypoint(scriptPath) {
29
+ if (scriptPath === undefined) {
30
+ return false;
31
+ }
32
+ const normalizedPath = scriptPath.replace(/\\/g, '/');
33
+ return (normalizedPath.includes('bin/turbo') || // npm symlink in a bin or .bin directory
34
+ normalizedPath.includes('cli/cli') // cli/cli.js or cli/cli.ts, run directly or through a Windows shim
35
+ );
36
+ }
@@ -28,6 +28,7 @@ import { revokeCredits } from './commands/revokeCredits.js';
28
28
  import { shareCredits } from './commands/shareCredits.js';
29
29
  import { tokenPrice } from './commands/tokenPrice.js';
30
30
  import { x402UploadUnsignedFile } from './commands/x402UploadUnsignedData.js';
31
+ import { isCliEntrypoint } from './entrypoint.js';
31
32
  import { addArNSControllerOptions, arnsActionPriceOptions, arnsActionStatusOptions, arnsFiatQuoteOptions, arnsPriceOptions, arnsPurchaseStatusOptions, buyArNSNameOptions, extendArNSLeaseOptions, globalOptions, increaseArNSUndernamesOptions, listSharesOptions, optionMap, removeArNSControllerOptions, removeArNSRecordMetadataOptions, removeArNSRecordOptions, revokeCreditsOptions, setArNSRecordMetadataOptions, setArNSRecordOptions, shareCreditsOptions, transferArNSAntOptions, transferArNSRecordOptions, upgradeArNSNameOptions, uploadFileOptions, uploadFolderOptions, walletOptions, } from './options.js';
32
33
  import { applyOptions, runCommand } from './utils.js';
33
34
  applyOptions(program
@@ -223,8 +224,6 @@ applyOptions(program
223
224
  }, null, 2));
224
225
  });
225
226
  });
226
- if (process.argv[1].includes('bin/turbo') || // Running from global .bin
227
- process.argv[1].includes('cli/cli') // Running from source
228
- ) {
227
+ if (isCliEntrypoint(process.argv[1])) {
229
228
  program.parse(process.argv);
230
229
  }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Whether `scriptPath` (pass `process.argv[1]`) is the Turbo CLI, so the CLI
18
+ * parses arguments only when it is the script Node was asked to run.
19
+ *
20
+ * Node reports `process.argv[1]` with the platform separator. On Windows,
21
+ * npm's `turbo.cmd`, `turbo.ps1` and Git Bash shims all run
22
+ * `node ...\node_modules\@ardrive\turbo-sdk\lib\esm\cli\cli.js`, so the path
23
+ * holds backslashes and is normalized before matching.
24
+ */
25
+ export function isCliEntrypoint(scriptPath) {
26
+ if (scriptPath === undefined) {
27
+ return false;
28
+ }
29
+ const normalizedPath = scriptPath.replace(/\\/g, '/');
30
+ return (normalizedPath.includes('bin/turbo') || // npm symlink in a bin or .bin directory
31
+ normalizedPath.includes('cli/cli') // cli/cli.js or cli/cli.ts, run directly or through a Windows shim
32
+ );
33
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Whether `scriptPath` (pass `process.argv[1]`) is the Turbo CLI, so the CLI
18
+ * parses arguments only when it is the script Node was asked to run.
19
+ *
20
+ * Node reports `process.argv[1]` with the platform separator. On Windows,
21
+ * npm's `turbo.cmd`, `turbo.ps1` and Git Bash shims all run
22
+ * `node ...\node_modules\@ardrive\turbo-sdk\lib\esm\cli\cli.js`, so the path
23
+ * holds backslashes and is normalized before matching.
24
+ */
25
+ export declare function isCliEntrypoint(scriptPath: string | undefined): boolean;
26
+ //# sourceMappingURL=entrypoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../../../src/cli/entrypoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CASvE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ardrive/turbo-sdk",
3
- "version": "1.44.0-alpha.4",
3
+ "version": "1.44.0-alpha.5",
4
4
  "main": "./lib/cjs/node/index.js",
5
5
  "types": "./lib/types/node/index.d.ts",
6
6
  "module": "./lib/esm/node/index.js",