@mochabug/adaptkit 0.12.1 → 0.12.3

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.
Files changed (2) hide show
  1. package/bin/index.js +45 -6
  2. package/package.json +8 -6
package/bin/index.js CHANGED
@@ -2,13 +2,15 @@
2
2
  import chalk from 'chalk';
3
3
  import { program } from 'commander';
4
4
  import figlet from 'figlet';
5
+ import fs from 'fs';
5
6
  import isValidHostname from 'is-valid-hostname';
7
+ import path from 'path';
8
+ import semver from 'semver';
9
+ import updateNotifier from 'update-notifier';
6
10
  import { input, select, confirm } from '@inquirer/prompts';
7
- import fs from 'fs';
8
11
  import { ServiceType, stackIntercept, RpcError } from '@protobuf-ts/runtime-rpc';
9
12
  import { MessageType, reflectionMergePartial, UnknownFieldHandler, WireType } from '@protobuf-ts/runtime';
10
13
  import { mkdirp } from 'mkdirp';
11
- import path from 'path';
12
14
  import { fileURLToPath } from 'url';
13
15
  import { execSync } from 'child_process';
14
16
  import { randomBytes } from 'crypto';
@@ -22,7 +24,6 @@ import fg from 'fast-glob';
22
24
  import { PassThrough } from 'stream';
23
25
  import sharp from 'sharp';
24
26
  import archiver from 'archiver';
25
- import updateNotifier from 'update-notifier';
26
27
 
27
28
  // @generated by protobuf-ts 2.9.4 with parameter client_generic,force_server_none
28
29
  // @generated from protobuf file "mochabugapis/adapt/plugins/v1/plugins.proto" (package "mochabugapis.adapt.plugins.v1", syntax proto3)
@@ -1265,7 +1266,7 @@ async function add(manifest) {
1265
1266
  fs.writeFileSync('manifest.json', Manifest.toJsonString(manifest, {
1266
1267
  enumAsInteger: false,
1267
1268
  prettySpaces: 2,
1268
- emitDefaultValues: true
1269
+ emitDefaultValues: false
1269
1270
  }));
1270
1271
  console.log(chalk.bgGreen('Success'));
1271
1272
  }
@@ -1392,7 +1393,7 @@ async function init(dir) {
1392
1393
  fs.writeFileSync(path.join(cwd, 'manifest.json'), Manifest.toJsonString(manifest, {
1393
1394
  enumAsInteger: false,
1394
1395
  prettySpaces: 2,
1395
- emitDefaultValues: true
1396
+ emitDefaultValues: false
1396
1397
  }));
1397
1398
  console.log(chalk.bgGreen('Success'));
1398
1399
  }
@@ -1984,9 +1985,40 @@ async function handleEmulate(host, cmd) {
1984
1985
  }
1985
1986
  await emulate(manifest, host);
1986
1987
  }
1988
+ function handleVersion(bump, cmd) {
1989
+ if (cmd.args.length >= 1) {
1990
+ console.error(chalk.red(`Error: Invalid sub-command or arguments provided.`));
1991
+ console.log(`For more information, use: ${chalk.blue('adaptkit help version')}`);
1992
+ process.exit(1);
1993
+ }
1994
+ const manifest = readManifest('manifest.json');
1995
+ if (!manifest) {
1996
+ console.log(`For more information, use: ${chalk.blue('adaptkit help version')}`);
1997
+ process.exit(1);
1998
+ }
1999
+ const manVer = semver.parse(manifest.version);
2000
+ if (!manVer) {
2001
+ console.error(chalk.red(`Error: The version in the manifest is not a valid semver version: ${manifest.version}`));
2002
+ console.log(`For more information, use: ${chalk.blue('adaptkit help version')}`);
2003
+ process.exit(1);
2004
+ }
2005
+ if (bump === null) {
2006
+ console.error(chalk.red('You must provide either --patch --minor or --major to bump the version.'));
2007
+ console.log(`For more information, use: ${chalk.blue('adaptkit help version')}`);
2008
+ process.exit(1);
2009
+ }
2010
+ const prevVersion = manifest.version;
2011
+ manifest.version = manVer.inc(bump).toString();
2012
+ fs.writeFileSync(path.join(process.cwd(), 'manifest.json'), Manifest.toJsonString(manifest, {
2013
+ enumAsInteger: false,
2014
+ prettySpaces: 2,
2015
+ emitDefaultValues: false
2016
+ }));
2017
+ console.log(chalk.green(`Bumped the version from ${prevVersion} to ${manifest.version}`));
2018
+ }
1987
2019
  async function main() {
1988
2020
  const notifier = updateNotifier({
1989
- pkg: JSON.parse('{"name":"@mochabug/adaptkit","version":"0.12.1"}')
2021
+ pkg: JSON.parse('{"name":"@mochabug/adaptkit","version":"0.12.3"}')
1990
2022
  });
1991
2023
  notifier.notify({ isGlobal: true, defer: false });
1992
2024
  program
@@ -2024,6 +2056,13 @@ async function main() {
2024
2056
  .option('-h, --host <host>', 'Specify the URL to test your plugin in the emulator. Ideal for custom port configurations.', 'localhost:51001')
2025
2057
  .description('Take your plugin for a test drive. Best used in conjunction with your build pipeline.')
2026
2058
  .action(({ host }, cmd) => handleEmulate(host, cmd));
2059
+ program
2060
+ .command('version')
2061
+ .option('--patch', 'Bump the manifest version to the next patch version')
2062
+ .option('--minor', 'Bump the manifest version to the next minor version')
2063
+ .option('--major', 'Bump the manifest version to the next major version')
2064
+ .description('The version command can manipulate the version of the plugin manifest.')
2065
+ .action(({ major, minor, patch }, cmd) => handleVersion(major ? 'major' : minor ? 'minor' : patch ? 'patch' : null, cmd));
2027
2066
  // Set a custom help action
2028
2067
  program.addHelpText('beforeAll', banner() + '\n');
2029
2068
  program.showHelpAfterError();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mochabug/adaptkit",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "A cmd to create, emulate and publish Mochabug Adapt plugins",
5
5
  "main": "bin/index.js",
6
6
  "type": "module",
@@ -43,18 +43,19 @@
43
43
  "@mochabug/adapt-plugin-typings": "^0.2.0-alpha.2",
44
44
  "@rollup/plugin-commonjs": "^26.0.1",
45
45
  "@rollup/plugin-json": "^6.1.0",
46
- "@rollup/plugin-node-resolve": "^15.2.3",
46
+ "@rollup/plugin-node-resolve": "^15.2.4",
47
47
  "@rollup/plugin-replace": "^5.0.7",
48
48
  "@rollup/plugin-terser": "^0.4.4",
49
- "@rollup/plugin-typescript": "^11.1.6",
49
+ "@rollup/plugin-typescript": "^12.1.0",
50
50
  "@types/archiver": "^6.0.2",
51
51
  "@types/express": "^4.17.21",
52
52
  "@types/figlet": "^1.5.8",
53
53
  "@types/jest": "^29.5.13",
54
54
  "@types/node": "^22.5.5",
55
+ "@types/semver": "^7.5.8",
55
56
  "@types/update-notifier": "^6.0.8",
56
57
  "jest": "^29.7.0",
57
- "rollup": "^4.21.3",
58
+ "rollup": "^4.22.4",
58
59
  "rollup-plugin-string": "^3.0.0",
59
60
  "ts-jest": "^29.2.5",
60
61
  "ts-node": "^10.9.2",
@@ -62,7 +63,7 @@
62
63
  "typescript": "^5.6.2"
63
64
  },
64
65
  "dependencies": {
65
- "@grpc/grpc-js": "^1.11.2",
66
+ "@grpc/grpc-js": "^1.11.3",
66
67
  "@inquirer/prompts": "^6.0.1",
67
68
  "@protobuf-ts/grpc-transport": "^2.9.4",
68
69
  "@protobuf-ts/runtime": "^2.9.4",
@@ -78,7 +79,8 @@
78
79
  "node-fetch": "^3.3.2",
79
80
  "open": "^10.1.0",
80
81
  "pkce-challenge": "^4.1.0",
82
+ "semver": "^7.6.3",
81
83
  "sharp": "^0.33.5",
82
84
  "update-notifier": "^7.3.1"
83
85
  }
84
- }
86
+ }