ic-mops 0.14.1 → 0.15.1

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/cli.js CHANGED
@@ -20,6 +20,7 @@ import {template} from './commands/template.js';
20
20
  import {selfUpdate} from './commands/self-update.js';
21
21
  import {remove} from './commands/remove.js';
22
22
  import {getUserProp, setUserProp} from './commands/user.js';
23
+ import {bump} from './commands/bump.js';
23
24
  // import {docs} from './commands/docs.js';
24
25
 
25
26
  program.name('mops');
@@ -279,4 +280,12 @@ program
279
280
  }
280
281
  });
281
282
 
283
+ // bump
284
+ program
285
+ .command('bump [major|minor|patch]')
286
+ .description('Bump current package version')
287
+ .action(async (part) => {
288
+ bump(part);
289
+ });
290
+
282
291
  program.parse();
@@ -0,0 +1,58 @@
1
+ import prompts from 'prompts';
2
+ import chalk from 'chalk';
3
+ import {checkConfigFile, readConfig, writeConfig} from '../mops.js';
4
+
5
+ export async function bump(part) {
6
+ if (!checkConfigFile()) {
7
+ return;
8
+ }
9
+
10
+ if (part && !['major', 'minor', 'patch'].includes(part)) {
11
+ console.log(chalk.red('Unknown version part. Available parts: major, minor, patch'));
12
+ process.exit(1);
13
+ }
14
+
15
+ let config = readConfig();
16
+
17
+ if (!config.package) {
18
+ console.log(chalk.red('No [package] section found in mops.toml.'));
19
+ process.exit(1);
20
+ }
21
+
22
+ console.log(`Current version: ${chalk.yellow.bold(config.package.version)}`);
23
+
24
+ if (!part) {
25
+ let res = await prompts({
26
+ type: 'select',
27
+ name: 'part',
28
+ message: 'Select new version:',
29
+ choices: [
30
+ {title: `${updateVersion(config.package.version, 'major')} ${chalk.dim('(major, breaking changes)')}`, value: 'major'},
31
+ {title: `${updateVersion(config.package.version, 'minor')} ${chalk.dim('(minor, new features)')}`, value: 'minor'},
32
+ {title: `${updateVersion(config.package.version, 'patch')} ${chalk.dim('(patch, bug fixes)')}`, value: 'patch'},
33
+ ],
34
+ initial: 2,
35
+ });
36
+ if (!res.part) {
37
+ return;
38
+ }
39
+ part = res.part;
40
+ }
41
+
42
+ config.package.version = updateVersion(config.package.version, part);
43
+ writeConfig(config);
44
+ console.log(`Updated version: ${chalk.green.bold(config.package.version)}`);
45
+ }
46
+
47
+ function updateVersion(version, part) {
48
+ let parts = version.split('.');
49
+ let idx = ['major', 'minor', 'patch'].indexOf(part);
50
+ if (idx < 0) {
51
+ throw new Error(`Invalid version part: ${part}`);
52
+ }
53
+ parts[idx] = parseInt(parts[idx]) + 1;
54
+ for (let i = idx + 1; i < parts.length; i++) {
55
+ parts[i] = 0;
56
+ }
57
+ return parts.join('.');
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "cli.js"
@@ -28,6 +28,7 @@
28
28
  "@dfinity/principal": "^0.11.1",
29
29
  "@iarna/toml": "^2.2.5",
30
30
  "as-table": "^1.0.55",
31
+ "cacheable-request": "10.2.10",
31
32
  "chalk": "^4.1.2",
32
33
  "chokidar": "^3.5.3",
33
34
  "commander": "^9.2.0",
@@ -36,11 +37,11 @@
36
37
  "del": "^6.0.0",
37
38
  "dhall-to-json-cli": "^1.7.6",
38
39
  "eslint": "^8.15.0",
39
- "execa": "^6.1.0",
40
+ "execa": "6.1.0",
40
41
  "get-folder-size": "^4.0.0",
41
42
  "glob": "^8.1.0",
42
43
  "globby": "^13.1.1",
43
- "got": "^12.5.3",
44
+ "got": "12.5.3",
44
45
  "log-update": "^5.0.1",
45
46
  "minimatch": "^5.0.1",
46
47
  "ncp": "^2.0.0",