wattetheria 0.3.4 → 0.3.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.
- package/README.md +4 -4
- package/lib/cli.js +20 -64
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -557,10 +557,10 @@ native `wattetheria-client-cli`; installed release packages should not require R
|
|
|
557
557
|
machine. The JS wrapper resolves `WATTETHERIA_CLI_BIN` first, then the matching optional native
|
|
558
558
|
package such as `@wattetheria/cli-win32-x64`, then `bin/native/<platform>-<arch>/`, then `PATH`.
|
|
559
559
|
`identity` and `wallet` are lightweight local setup commands for ServiceNet publishing and wallet
|
|
560
|
-
binding
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
native CLI is available.
|
|
560
|
+
binding before a local Wattetheria node is installed. If a local node deployment is already
|
|
561
|
+
installed, the wrapper refuses `identity` and `wallet` commands so users do not create or modify a
|
|
562
|
+
separate local identity or wallet outside the node. ServiceNet commands can still run through an
|
|
563
|
+
installed node when no host native CLI is available.
|
|
564
564
|
|
|
565
565
|
NPM publish flow:
|
|
566
566
|
|
package/lib/cli.js
CHANGED
|
@@ -1344,36 +1344,6 @@ function missingNativeCliError(commandName) {
|
|
|
1344
1344
|
);
|
|
1345
1345
|
}
|
|
1346
1346
|
|
|
1347
|
-
function forwardedSubcommand(rawArgv) {
|
|
1348
|
-
for (let index = 1; index < rawArgv.length; index += 1) {
|
|
1349
|
-
const arg = rawArgv[index];
|
|
1350
|
-
if (arg.startsWith("-")) {
|
|
1351
|
-
if (!arg.includes("=")) {
|
|
1352
|
-
index += 1;
|
|
1353
|
-
}
|
|
1354
|
-
continue;
|
|
1355
|
-
}
|
|
1356
|
-
return arg;
|
|
1357
|
-
}
|
|
1358
|
-
return "";
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
function isIdentityWriteCommand(commandName, rawArgv) {
|
|
1362
|
-
return commandName === "identity" && forwardedSubcommand(rawArgv) === "init";
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
function isWalletWriteCommand(commandName, rawArgv) {
|
|
1366
|
-
if (commandName !== "wallet") {
|
|
1367
|
-
return false;
|
|
1368
|
-
}
|
|
1369
|
-
return new Set([
|
|
1370
|
-
"create-payment-account",
|
|
1371
|
-
"import-payment-account",
|
|
1372
|
-
"watch-payment-account",
|
|
1373
|
-
"bind-payment-account"
|
|
1374
|
-
]).has(forwardedSubcommand(rawArgv));
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
1347
|
function installedNodeArtifacts(deployment = deploymentState()) {
|
|
1378
1348
|
return {
|
|
1379
1349
|
identityPath: path.join(deployment.stateDir, "identity.json"),
|
|
@@ -1382,60 +1352,46 @@ function installedNodeArtifacts(deployment = deploymentState()) {
|
|
|
1382
1352
|
};
|
|
1383
1353
|
}
|
|
1384
1354
|
|
|
1385
|
-
function
|
|
1386
|
-
|
|
1387
|
-
if (!option) {
|
|
1388
|
-
return "";
|
|
1389
|
-
}
|
|
1390
|
-
if (!option.value) {
|
|
1391
|
-
throw new Error("Missing value for --data-dir");
|
|
1392
|
-
}
|
|
1393
|
-
return path.resolve(option.value);
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
function usesSeparateDataDir(rawArgv, deployment) {
|
|
1397
|
-
const dataDir = explicitDataDir(rawArgv);
|
|
1398
|
-
return Boolean(dataDir) && dataDir !== path.resolve(deployment.stateDir);
|
|
1355
|
+
function isLightweightLocalCommand(commandName) {
|
|
1356
|
+
return commandName === "identity" || commandName === "wallet";
|
|
1399
1357
|
}
|
|
1400
1358
|
|
|
1401
|
-
function ensureLightweightCommandAllowed(commandName
|
|
1402
|
-
if (!(
|
|
1359
|
+
function ensureLightweightCommandAllowed(commandName) {
|
|
1360
|
+
if (!isLightweightLocalCommand(commandName)) {
|
|
1403
1361
|
return;
|
|
1404
1362
|
}
|
|
1405
1363
|
const deployment = deploymentState();
|
|
1406
|
-
if (!deployment.installed
|
|
1364
|
+
if (!deployment.installed) {
|
|
1407
1365
|
return;
|
|
1408
1366
|
}
|
|
1409
1367
|
const artifacts = installedNodeArtifacts(deployment);
|
|
1410
|
-
if (
|
|
1368
|
+
if (commandName === "identity") {
|
|
1411
1369
|
throw new Error(
|
|
1412
1370
|
[
|
|
1413
|
-
"Refusing to
|
|
1371
|
+
"Refusing to run a separate local identity command.",
|
|
1414
1372
|
"",
|
|
1415
|
-
|
|
1373
|
+
fs.existsSync(artifacts.identityPath)
|
|
1374
|
+
? "A local Wattetheria node is already installed and has an identity at:"
|
|
1375
|
+
: "A local Wattetheria node is already installed at:",
|
|
1416
1376
|
deployment.stateDir,
|
|
1417
1377
|
"",
|
|
1418
|
-
"`wattetheria identity
|
|
1419
|
-
"node
|
|
1420
|
-
"data directory only for isolated testing."
|
|
1378
|
+
"`wattetheria identity` is only for lightweight local setup when no Wattetheria",
|
|
1379
|
+
"node is installed. Use the installed node's identity instead."
|
|
1421
1380
|
].join("\n")
|
|
1422
1381
|
);
|
|
1423
1382
|
}
|
|
1424
|
-
if (
|
|
1425
|
-
isWalletWriteCommand(commandName, rawArgv)
|
|
1426
|
-
&& fs.existsSync(artifacts.walletMetadataPath)
|
|
1427
|
-
&& fs.existsSync(artifacts.walletKeystorePath)
|
|
1428
|
-
) {
|
|
1383
|
+
if (commandName === "wallet") {
|
|
1429
1384
|
throw new Error(
|
|
1430
1385
|
[
|
|
1431
|
-
"Refusing to
|
|
1386
|
+
"Refusing to run a separate local wallet command.",
|
|
1432
1387
|
"",
|
|
1433
|
-
|
|
1388
|
+
fs.existsSync(artifacts.walletMetadataPath) && fs.existsSync(artifacts.walletKeystorePath)
|
|
1389
|
+
? "A local Wattetheria node is already installed and has wallet state at:"
|
|
1390
|
+
: "A local Wattetheria node is already installed at:",
|
|
1434
1391
|
deployment.stateDir,
|
|
1435
1392
|
"",
|
|
1436
|
-
"`wattetheria wallet`
|
|
1437
|
-
"
|
|
1438
|
-
"separate data directory only for isolated testing."
|
|
1393
|
+
"`wattetheria wallet` is only for lightweight local setup when no Wattetheria",
|
|
1394
|
+
"node is installed. Use the installed node's wallet instead."
|
|
1439
1395
|
].join("\n")
|
|
1440
1396
|
);
|
|
1441
1397
|
}
|
|
@@ -1670,7 +1626,7 @@ function runInstalledNodeCli(commandName, rawArgv, deployment) {
|
|
|
1670
1626
|
}
|
|
1671
1627
|
|
|
1672
1628
|
function forwardToRustBinary(commandName, rawArgv) {
|
|
1673
|
-
ensureLightweightCommandAllowed(commandName
|
|
1629
|
+
ensureLightweightCommandAllowed(commandName);
|
|
1674
1630
|
|
|
1675
1631
|
// Only the Rust binary name is allowed here. The bare `wattetheria` name
|
|
1676
1632
|
// resolves to this JS shim on most user PATHs (via the npm bin link), so
|