@mochabug/adaptkit 0.8.6 → 0.8.7
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/bin/index.js +61 -23
- package/bin/publish.d.ts.map +1 -1
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -1475,6 +1475,17 @@ class PluginServiceClient {
|
|
|
1475
1475
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1476
1476
|
// See the License for the specific language governing permissions and
|
|
1477
1477
|
// limitations under the License.
|
|
1478
|
+
function printStatus(status) {
|
|
1479
|
+
if (status.code !== 'OK') {
|
|
1480
|
+
console.error('Error: The server returned a non-successful status code.');
|
|
1481
|
+
console.error(`Status Code: ${status.code}`);
|
|
1482
|
+
console.error(`Details: ${status.detail}`);
|
|
1483
|
+
console.log(chalk.bgRed('FAILURE'));
|
|
1484
|
+
}
|
|
1485
|
+
else {
|
|
1486
|
+
console.log(chalk.green('Stream message was sent successfully'));
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1478
1489
|
async function resize(filepath, height, width) {
|
|
1479
1490
|
const extname = path.extname(filepath);
|
|
1480
1491
|
switch (extname) {
|
|
@@ -1501,9 +1512,10 @@ async function sendPlugin(manifest, client, metadata) {
|
|
|
1501
1512
|
console.log('Sending the plugin to the server');
|
|
1502
1513
|
const stream = client.uploadPlugin({ meta: metadata });
|
|
1503
1514
|
const lookup = {};
|
|
1515
|
+
// Returns success / false
|
|
1504
1516
|
async function send(filePath, imgOpts) {
|
|
1505
1517
|
if (!filePath || lookup[filePath]) {
|
|
1506
|
-
return;
|
|
1518
|
+
return true;
|
|
1507
1519
|
}
|
|
1508
1520
|
if (!fs.existsSync(filePath)) {
|
|
1509
1521
|
throw new Error(`The file does not exists: ${filePath}. Invalid manifest`);
|
|
@@ -1529,6 +1541,9 @@ async function sendPlugin(manifest, client, metadata) {
|
|
|
1529
1541
|
};
|
|
1530
1542
|
await stream.requests.send(message);
|
|
1531
1543
|
lookup[filePath] = true;
|
|
1544
|
+
const status = await stream.status;
|
|
1545
|
+
printStatus(status);
|
|
1546
|
+
return status.code === 'OK';
|
|
1532
1547
|
}
|
|
1533
1548
|
// The first message must be the manifest
|
|
1534
1549
|
// All the other messages must be files and must be described in the manifest
|
|
@@ -1539,45 +1554,68 @@ async function sendPlugin(manifest, client, metadata) {
|
|
|
1539
1554
|
}
|
|
1540
1555
|
};
|
|
1541
1556
|
await stream.requests.send(request);
|
|
1542
|
-
await
|
|
1543
|
-
await send('
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1557
|
+
printStatus(await stream.status);
|
|
1558
|
+
let success = await send('README.md');
|
|
1559
|
+
if (!success) {
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
success = await send('LICENSE.md');
|
|
1563
|
+
if (!success) {
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
success = await send(manifest.executorEsm);
|
|
1567
|
+
if (!success) {
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1570
|
+
success = await send(manifest.configuratorEsm);
|
|
1571
|
+
if (!success) {
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1574
|
+
success = await send(manifest.logo, [80, 80]);
|
|
1575
|
+
if (!success) {
|
|
1576
|
+
return;
|
|
1577
|
+
}
|
|
1547
1578
|
// Send everything inside the asset directory as assets
|
|
1548
1579
|
if (manifest.assetsDir && fs.existsSync(manifest.assetsDir)) {
|
|
1549
1580
|
const paths = await fg(path.join(manifest.assetsDir, '**', '*'));
|
|
1550
|
-
console.log('Found in assets directory:');
|
|
1551
|
-
console.log(paths);
|
|
1552
1581
|
for (let filepath of paths) {
|
|
1553
1582
|
if (fs.statSync(filepath).isFile()) {
|
|
1554
|
-
await send(filepath);
|
|
1583
|
+
success = await send(filepath);
|
|
1584
|
+
if (!success) {
|
|
1585
|
+
return;
|
|
1586
|
+
}
|
|
1555
1587
|
}
|
|
1556
1588
|
}
|
|
1557
1589
|
}
|
|
1558
1590
|
// Send everything related to the vertices. Logos, schemas and configs
|
|
1559
1591
|
for (let vertex of manifest.vertices) {
|
|
1560
|
-
await send(vertex.logo, [40, 40]);
|
|
1561
|
-
|
|
1592
|
+
success = await send(vertex.logo, [40, 40]);
|
|
1593
|
+
if (!success) {
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
success = await send(vertex.defaultConfig);
|
|
1597
|
+
if (!success) {
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1562
1600
|
for (let mtls of vertex.mtls) {
|
|
1563
|
-
await send(mtls.trustedCa);
|
|
1601
|
+
success = await send(mtls.trustedCa);
|
|
1602
|
+
if (!success) {
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1564
1605
|
}
|
|
1565
1606
|
}
|
|
1566
1607
|
// Send the ca bundles
|
|
1567
1608
|
for (let mtls of manifest.mtls) {
|
|
1568
|
-
await send(mtls.trustedCa);
|
|
1609
|
+
success = await send(mtls.trustedCa);
|
|
1610
|
+
if (!success) {
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1569
1613
|
}
|
|
1570
1614
|
await stream.requests.complete();
|
|
1571
|
-
const result = await stream;
|
|
1615
|
+
const result = await stream.response;
|
|
1616
|
+
console.log(chalk.bgGreen('SUCCESS'));
|
|
1617
|
+
console.log(chalk.green('Publishing done'));
|
|
1572
1618
|
console.log(result);
|
|
1573
|
-
if (result.status.code === 'OK') {
|
|
1574
|
-
console.log(chalk.green('Publishing done'));
|
|
1575
|
-
console.log(chalk.bgGreen('SUCCESS'));
|
|
1576
|
-
}
|
|
1577
|
-
else {
|
|
1578
|
-
console.log('The publishing failed. See log messages for error');
|
|
1579
|
-
console.log(chalk.bgRed('FAILURE'));
|
|
1580
|
-
}
|
|
1581
1619
|
}
|
|
1582
1620
|
async function emulate(manifest, host) {
|
|
1583
1621
|
const transport = new GrpcTransport({
|
|
@@ -1614,7 +1652,7 @@ async function publish(manifest, host, accessToken, insecure) {
|
|
|
1614
1652
|
}
|
|
1615
1653
|
|
|
1616
1654
|
var name = "@mochabug/adaptkit";
|
|
1617
|
-
var version = "0.8.
|
|
1655
|
+
var version = "0.8.7";
|
|
1618
1656
|
var description = "A cmd to create, emulate and publish Mochabug Adapt plugins";
|
|
1619
1657
|
var main$1 = "bin/index.js";
|
|
1620
1658
|
var type = "module";
|
package/bin/publish.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,QAAQ,EAET,MAAM,kDAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,QAAQ,EAET,MAAM,kDAAkD,CAAC;AAyK1D,wBAAsB,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,iBAc7D;AAED,wBAAsB,OAAO,CAC3B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,iBAoBlB"}
|